hash
stringlengths
64
64
content
stringlengths
0
1.51M
3f4593c3aea71bbff600bff2e5ad24a178fa3e893e2874456a65978118fbe4ef
"""Geometrical Points. Contains ======== Point Point2D Point3D When methods of Point require 1 or more points as arguments, they can be passed as a sequence of coordinates or Points: >>> from sympy.geometry.point import Point >>> Point(1, 1).is_collinear((2, 2), (3, 4)) False >>> Point(1, 1).is_collinear(Point(2, 2), Point(3, 4)) False """ from __future__ import division, print_function import warnings from sympy.core import S, sympify, Expr from sympy.core.compatibility import is_sequence from sympy.core.containers import Tuple from sympy.simplify import nsimplify, simplify from sympy.geometry.exceptions import GeometryError from sympy.functions.elementary.miscellaneous import sqrt from sympy.functions.elementary.complexes import im from sympy.matrices import Matrix from sympy.core.numbers import Float from sympy.core.evaluate import global_evaluate from sympy.core.add import Add from sympy.utilities.iterables import uniq from sympy.utilities.misc import filldedent, func_name, Undecidable from .entity import GeometryEntity class Point(GeometryEntity): """A point in a n-dimensional Euclidean space. Parameters ========== coords : sequence of n-coordinate values. In the special case where n=2 or 3, a Point2D or Point3D will be created as appropriate. evaluate : if `True` (default), all floats are turn into exact types. dim : number of coordinates the point should have. If coordinates are unspecified, they are padded with zeros. on_morph : indicates what should happen when the number of coordinates of a point need to be changed by adding or removing zeros. Possible values are `'warn'`, `'error'`, or `ignore` (default). No warning or error is given when `*args` is empty and `dim` is given. An error is always raised when trying to remove nonzero coordinates. Attributes ========== length origin: A `Point` representing the origin of the appropriately-dimensioned space. Raises ====== TypeError : When instantiating with anything but a Point or sequence ValueError : when instantiating with a sequence with length < 2 or when trying to reduce dimensions if keyword `on_morph='error'` is set. See Also ======== sympy.geometry.line.Segment : Connects two Points Examples ======== >>> from sympy.geometry import Point >>> from sympy.abc import x >>> Point(1, 2, 3) Point3D(1, 2, 3) >>> Point([1, 2]) Point2D(1, 2) >>> Point(0, x) Point2D(0, x) >>> Point(dim=4) Point(0, 0, 0, 0) Floats are automatically converted to Rational unless the evaluate flag is False: >>> Point(0.5, 0.25) Point2D(1/2, 1/4) >>> Point(0.5, 0.25, evaluate=False) Point2D(0.5, 0.25) """ is_Point = True def __new__(cls, *args, **kwargs): evaluate = kwargs.get('evaluate', global_evaluate[0]) on_morph = kwargs.get('on_morph', 'ignore') # unpack into coords coords = args[0] if len(args) == 1 else args # check args and handle quickly handle Point instances if isinstance(coords, Point): # even if we're mutating the dimension of a point, we # don't reevaluate its coordinates evaluate = False if len(coords) == kwargs.get('dim', len(coords)): return coords if not is_sequence(coords): raise TypeError(filldedent(''' Expecting sequence of coordinates, not `{}`''' .format(func_name(coords)))) # A point where only `dim` is specified is initialized # to zeros. if len(coords) == 0 and kwargs.get('dim', None): coords = (S.Zero,)*kwargs.get('dim') coords = Tuple(*coords) dim = kwargs.get('dim', len(coords)) if len(coords) < 2: raise ValueError(filldedent(''' Point requires 2 or more coordinates or keyword `dim` > 1.''')) if len(coords) != dim: message = ("Dimension of {} needs to be changed" "from {} to {}.").format(coords, len(coords), dim) if on_morph == 'ignore': pass elif on_morph == "error": raise ValueError(message) elif on_morph == 'warn': warnings.warn(message) else: raise ValueError(filldedent(''' on_morph value should be 'error', 'warn' or 'ignore'.''')) if any(coords[dim:]): raise ValueError('Nonzero coordinates cannot be removed.') if any(a.is_number and im(a) for a in coords): raise ValueError('Imaginary coordinates are not permitted.') if not all(isinstance(a, Expr) for a in coords): raise TypeError('Coordinates must be valid SymPy expressions.') # pad with zeros appropriately coords = coords[:dim] + (S.Zero,)*(dim - len(coords)) # Turn any Floats into rationals and simplify # any expressions before we instantiate if evaluate: coords = coords.xreplace(dict( [(f, simplify(nsimplify(f, rational=True))) for f in coords.atoms(Float)])) # return 2D or 3D instances if len(coords) == 2: kwargs['_nocheck'] = True return Point2D(*coords, **kwargs) elif len(coords) == 3: kwargs['_nocheck'] = True return Point3D(*coords, **kwargs) # the general Point return GeometryEntity.__new__(cls, *coords) def __abs__(self): """Returns the distance between this point and the origin.""" origin = Point([0]*len(self)) return Point.distance(origin, self) def __add__(self, other): """Add other to self by incrementing self's coordinates by those of other. Notes ===== >>> from sympy.geometry.point import Point When sequences of coordinates are passed to Point methods, they are converted to a Point internally. This __add__ method does not do that so if floating point values are used, a floating point result (in terms of SymPy Floats) will be returned. >>> Point(1, 2) + (.1, .2) Point2D(1.1, 2.2) If this is not desired, the `translate` method can be used or another Point can be added: >>> Point(1, 2).translate(.1, .2) Point2D(11/10, 11/5) >>> Point(1, 2) + Point(.1, .2) Point2D(11/10, 11/5) See Also ======== sympy.geometry.point.Point.translate """ try: s, o = Point._normalize_dimension(self, Point(other, evaluate=False)) except TypeError: raise GeometryError("Don't know how to add {} and a Point object".format(other)) coords = [simplify(a + b) for a, b in zip(s, o)] return Point(coords, evaluate=False) def __contains__(self, item): return item in self.args def __div__(self, divisor): """Divide point's coordinates by a factor.""" divisor = sympify(divisor) coords = [simplify(x/divisor) for x in self.args] return Point(coords, evaluate=False) def __eq__(self, other): if not isinstance(other, Point) or len(self.args) != len(other.args): return False return self.args == other.args def __getitem__(self, key): return self.args[key] def __hash__(self): return hash(self.args) def __iter__(self): return self.args.__iter__() def __len__(self): return len(self.args) def __mul__(self, factor): """Multiply point's coordinates by a factor. Notes ===== >>> from sympy.geometry.point import Point When multiplying a Point by a floating point number, the coordinates of the Point will be changed to Floats: >>> Point(1, 2)*0.1 Point2D(0.1, 0.2) If this is not desired, the `scale` method can be used or else only multiply or divide by integers: >>> Point(1, 2).scale(1.1, 1.1) Point2D(11/10, 11/5) >>> Point(1, 2)*11/10 Point2D(11/10, 11/5) See Also ======== sympy.geometry.point.Point.scale """ factor = sympify(factor) coords = [simplify(x*factor) for x in self.args] return Point(coords, evaluate=False) def __neg__(self): """Negate the point.""" coords = [-x for x in self.args] return Point(coords, evaluate=False) def __sub__(self, other): """Subtract two points, or subtract a factor from this point's coordinates.""" return self + [-x for x in other] @classmethod def _normalize_dimension(cls, *points, **kwargs): """Ensure that points have the same dimension. By default `on_morph='warn'` is passed to the `Point` constructor.""" # if we have a built-in ambient dimension, use it dim = getattr(cls, '_ambient_dimension', None) # override if we specified it dim = kwargs.get('dim', dim) # if no dim was given, use the highest dimensional point if dim is None: dim = max(i.ambient_dimension for i in points) if all(i.ambient_dimension == dim for i in points): return list(points) kwargs['dim'] = dim kwargs['on_morph'] = kwargs.get('on_morph', 'warn') return [Point(i, **kwargs) for i in points] @staticmethod def affine_rank(*args): """The affine rank of a set of points is the dimension of the smallest affine space containing all the points. For example, if the points lie on a line (and are not all the same) their affine rank is 1. If the points lie on a plane but not a line, their affine rank is 2. By convention, the empty set has affine rank -1.""" if len(args) == 0: return -1 # make sure we're genuinely points # and translate every point to the origin points = Point._normalize_dimension(*[Point(i) for i in args]) origin = points[0] points = [i - origin for i in points[1:]] m = Matrix([i.args for i in points]) return m.rank() @property def ambient_dimension(self): """Number of components this point has.""" return getattr(self, '_ambient_dimension', len(self)) @classmethod def are_coplanar(cls, *points): """Return True if there exists a plane in which all the points lie. A trivial True value is returned if `len(points) < 3` or all Points are 2-dimensional. Parameters ========== A set of points Raises ====== ValueError : if less than 3 unique points are given Returns ======= boolean Examples ======== >>> from sympy import Point3D >>> p1 = Point3D(1, 2, 2) >>> p2 = Point3D(2, 7, 2) >>> p3 = Point3D(0, 0, 2) >>> p4 = Point3D(1, 1, 2) >>> Point3D.are_coplanar(p1, p2, p3, p4) True >>> p5 = Point3D(0, 1, 3) >>> Point3D.are_coplanar(p1, p2, p3, p5) False """ if len(points) <= 1: return True points = cls._normalize_dimension(*[Point(i) for i in points]) # quick exit if we are in 2D if points[0].ambient_dimension == 2: return True points = list(uniq(points)) return Point.affine_rank(*points) <= 2 def distance(self, other): """The Euclidean distance between self and another GeometricEntity. Returns ======= distance : number or symbolic expression. Raises ====== TypeError : if other is not recognized as a GeometricEntity or is a GeometricEntity for which distance is not defined. See Also ======== sympy.geometry.line.Segment.length sympy.geometry.point.Point.taxicab_distance Examples ======== >>> from sympy.geometry import Point, Line >>> p1, p2 = Point(1, 1), Point(4, 5) >>> l = Line((3, 1), (2, 2)) >>> p1.distance(p2) 5 >>> p1.distance(l) sqrt(2) The computed distance may be symbolic, too: >>> from sympy.abc import x, y >>> p3 = Point(x, y) >>> p3.distance((0, 0)) sqrt(x**2 + y**2) """ if not isinstance(other, GeometryEntity): try: other = Point(other, dim=self.ambient_dimension) except TypeError: raise TypeError("not recognized as a GeometricEntity: %s" % type(other)) if isinstance(other, Point): s, p = Point._normalize_dimension(self, Point(other)) return sqrt(Add(*((a - b)**2 for a, b in zip(s, p)))) distance = getattr(other, 'distance', None) if distance is None: raise TypeError("distance between Point and %s is not defined" % type(other)) return distance(self) def dot(self, p): """Return dot product of self with another Point.""" if not is_sequence(p): p = Point(p) # raise the error via Point return Add(*(a*b for a, b in zip(self, p))) def equals(self, other): """Returns whether the coordinates of self and other agree.""" # a point is equal to another point if all its components are equal if not isinstance(other, Point) or len(self) != len(other): return False return all(a.equals(b) for a, b in zip(self, other)) def evalf(self, prec=None, **options): """Evaluate the coordinates of the point. This method will, where possible, create and return a new Point where the coordinates are evaluated as floating point numbers to the precision indicated (default=15). Parameters ========== prec : int Returns ======= point : Point Examples ======== >>> from sympy import Point, Rational >>> p1 = Point(Rational(1, 2), Rational(3, 2)) >>> p1 Point2D(1/2, 3/2) >>> p1.evalf() Point2D(0.5, 1.5) """ coords = [x.evalf(prec, **options) for x in self.args] return Point(*coords, evaluate=False) def intersection(self, other): """The intersection between this point and another GeometryEntity. Parameters ========== other : Point Returns ======= intersection : list of Points Notes ===== The return value will either be an empty list if there is no intersection, otherwise it will contain this point. Examples ======== >>> from sympy import Point >>> p1, p2, p3 = Point(0, 0), Point(1, 1), Point(0, 0) >>> p1.intersection(p2) [] >>> p1.intersection(p3) [Point2D(0, 0)] """ if not isinstance(other, GeometryEntity): other = Point(other) if isinstance(other, Point): if self == other: return [self] p1, p2 = Point._normalize_dimension(self, other) if p1 == self and p1 == p2: return [self] return [] return other.intersection(self) def is_collinear(self, *args): """Returns `True` if there exists a line that contains `self` and `points`. Returns `False` otherwise. A trivially True value is returned if no points are given. Parameters ========== args : sequence of Points Returns ======= is_collinear : boolean See Also ======== sympy.geometry.line.Line Examples ======== >>> from sympy import Point >>> from sympy.abc import x >>> p1, p2 = Point(0, 0), Point(1, 1) >>> p3, p4, p5 = Point(2, 2), Point(x, x), Point(1, 2) >>> Point.is_collinear(p1, p2, p3, p4) True >>> Point.is_collinear(p1, p2, p3, p5) False """ points = (self,) + args points = Point._normalize_dimension(*[Point(i) for i in points]) points = list(uniq(points)) return Point.affine_rank(*points) <= 1 def is_concyclic(self, *args): """Do `self` and the given sequence of points lie in a circle? Returns True if the set of points are concyclic and False otherwise. A trivial value of True is returned if there are fewer than 2 other points. Parameters ========== args : sequence of Points Returns ======= is_concyclic : boolean Examples ======== >>> from sympy import Point Define 4 points that are on the unit circle: >>> p1, p2, p3, p4 = Point(1, 0), (0, 1), (-1, 0), (0, -1) >>> p1.is_concyclic() == p1.is_concyclic(p2, p3, p4) == True True Define a point not on that circle: >>> p = Point(1, 1) >>> p.is_concyclic(p1, p2, p3) False """ points = (self,) + args points = Point._normalize_dimension(*[Point(i) for i in points]) points = list(uniq(points)) if not Point.affine_rank(*points) <= 2: return False origin = points[0] points = [p - origin for p in points] # points are concyclic if they are coplanar and # there is a point c so that ||p_i-c|| == ||p_j-c|| for all # i and j. Rearranging this equation gives us the following # condition: the matrix `mat` must not a pivot in the last # column. mat = Matrix([list(i) + [i.dot(i)] for i in points]) rref, pivots = mat.rref() if len(origin) not in pivots: return True return False @property def is_nonzero(self): """True if any coordinate is nonzero, False if every coordinate is zero, and None if it cannot be determined.""" is_zero = self.is_zero if is_zero is None: return None return not is_zero def is_scalar_multiple(self, p): """Returns whether each coordinate of `self` is a scalar multiple of the corresponding coordinate in point p. """ s, o = Point._normalize_dimension(self, Point(p)) # 2d points happen a lot, so optimize this function call if s.ambient_dimension == 2: (x1, y1), (x2, y2) = s.args, o.args rv = (x1*y2 - x2*y1).equals(0) if rv is None: raise Undecidable(filldedent( '''can't determine if %s is a scalar multiple of %s''' % (s, o))) # if the vectors p1 and p2 are linearly dependent, then they must # be scalar multiples of each other m = Matrix([s.args, o.args]) return m.rank() < 2 @property def is_zero(self): """True if every coordinate is zero, False if any coordinate is not zero, and None if it cannot be determined.""" nonzero = [x.is_nonzero for x in self.args] if any(nonzero): return False if any(x is None for x in nonzero): return None return True @property def length(self): """ Treating a Point as a Line, this returns 0 for the length of a Point. Examples ======== >>> from sympy import Point >>> p = Point(0, 1) >>> p.length 0 """ return S.Zero def midpoint(self, p): """The midpoint between self and point p. Parameters ========== p : Point Returns ======= midpoint : Point See Also ======== sympy.geometry.line.Segment.midpoint Examples ======== >>> from sympy.geometry import Point >>> p1, p2 = Point(1, 1), Point(13, 5) >>> p1.midpoint(p2) Point2D(7, 3) """ s, p = Point._normalize_dimension(self, Point(p)) return Point([simplify((a + b)*S.Half) for a, b in zip(s, p)]) @property def origin(self): """A point of all zeros of the same ambient dimension as the current point""" return Point([0]*len(self), evaluate=False) @property def orthogonal_direction(self): """Returns a non-zero point that is orthogonal to the line containing `self` and the origin. Examples ======== >>> from sympy.geometry import Line, Point >>> a = Point(1, 2, 3) >>> a.orthogonal_direction Point3D(-2, 1, 0) >>> b = _ >>> Line(b, b.origin).is_perpendicular(Line(a, a.origin)) True """ dim = self.ambient_dimension # if a coordinate is zero, we can put a 1 there and zeros elsewhere if self[0] == S.Zero: return Point([1] + (dim - 1)*[0]) if self[1] == S.Zero: return Point([0,1] + (dim - 2)*[0]) # if the first two coordinates aren't zero, we can create a non-zero # orthogonal vector by swapping them, negating one, and padding with zeros return Point([-self[1], self[0]] + (dim - 2)*[0]) @staticmethod def project(a, b): """Project the point `a` onto the line between the origin and point `b` along the normal direction. Parameters ========== a : Point b : Point Returns ======= p : Point See Also ======== sympy.geometry.line.LinearEntity.projection Examples ======== >>> from sympy.geometry import Line, Point >>> a = Point(1, 2) >>> b = Point(2, 5) >>> z = a.origin >>> p = Point.project(a, b) >>> Line(p, a).is_perpendicular(Line(p, b)) True >>> Point.is_collinear(z, p, b) True """ a, b = Point._normalize_dimension(Point(a), Point(b)) if b.is_zero: raise ValueError("Cannot project to the zero vector.") return b*(a.dot(b) / b.dot(b)) def taxicab_distance(self, p): """The Taxicab Distance from self to point p. Returns the sum of the horizontal and vertical distances to point p. Parameters ========== p : Point Returns ======= taxicab_distance : The sum of the horizontal and vertical distances to point p. See Also ======== sympy.geometry.point.Point.distance Examples ======== >>> from sympy.geometry import Point >>> p1, p2 = Point(1, 1), Point(4, 5) >>> p1.taxicab_distance(p2) 7 """ s, p = Point._normalize_dimension(self, Point(p)) return Add(*(abs(a - b) for a, b in zip(s, p))) def canberra_distance(self, p): """The Canberra Distance from self to point p. Returns the weighted sum of horizontal and vertical distances to point p. Parameters ========== p : Point Returns ======= canberra_distance : The weighted sum of horizontal and vertical distances to point p. The weight used is the sum of absolute values of the coordinates. Examples ======== >>> from sympy.geometry import Point >>> p1, p2 = Point(1, 1), Point(3, 3) >>> p1.canberra_distance(p2) 1 >>> p1, p2 = Point(0, 0), Point(3, 3) >>> p1.canberra_distance(p2) 2 Raises ====== ValueError when both vectors are zero. See Also ======== sympy.geometry.point.Point.distance """ s, p = Point._normalize_dimension(self, Point(p)) if self.is_zero and p.is_zero: raise ValueError("Cannot project to the zero vector.") return Add(*((abs(a - b)/(abs(a) + abs(b))) for a, b in zip(s, p))) @property def unit(self): """Return the Point that is in the same direction as `self` and a distance of 1 from the origin""" return self / abs(self) n = evalf __truediv__ = __div__ class Point2D(Point): """A point in a 2-dimensional Euclidean space. Parameters ========== coords : sequence of 2 coordinate values. Attributes ========== x y length Raises ====== TypeError When trying to add or subtract points with different dimensions. When trying to create a point with more than two dimensions. When `intersection` is called with object other than a Point. See Also ======== sympy.geometry.line.Segment : Connects two Points Examples ======== >>> from sympy.geometry import Point2D >>> from sympy.abc import x >>> Point2D(1, 2) Point2D(1, 2) >>> Point2D([1, 2]) Point2D(1, 2) >>> Point2D(0, x) Point2D(0, x) Floats are automatically converted to Rational unless the evaluate flag is False: >>> Point2D(0.5, 0.25) Point2D(1/2, 1/4) >>> Point2D(0.5, 0.25, evaluate=False) Point2D(0.5, 0.25) """ _ambient_dimension = 2 def __new__(cls, *args, **kwargs): if not kwargs.pop('_nocheck', False): kwargs['dim'] = 2 args = Point(*args, **kwargs) return GeometryEntity.__new__(cls, *args) def __contains__(self, item): return item == self @property def bounds(self): """Return a tuple (xmin, ymin, xmax, ymax) representing the bounding rectangle for the geometric figure. """ return (self.x, self.y, self.x, self.y) def rotate(self, angle, pt=None): """Rotate ``angle`` radians counterclockwise about Point ``pt``. See Also ======== rotate, scale Examples ======== >>> from sympy import Point2D, pi >>> t = Point2D(1, 0) >>> t.rotate(pi/2) Point2D(0, 1) >>> t.rotate(pi/2, (2, 0)) Point2D(2, -1) """ from sympy import cos, sin, Point c = cos(angle) s = sin(angle) rv = self if pt is not None: pt = Point(pt, dim=2) rv -= pt x, y = rv.args rv = Point(c*x - s*y, s*x + c*y) if pt is not None: rv += pt return rv def scale(self, x=1, y=1, pt=None): """Scale the coordinates of the Point by multiplying by ``x`` and ``y`` after subtracting ``pt`` -- default is (0, 0) -- and then adding ``pt`` back again (i.e. ``pt`` is the point of reference for the scaling). See Also ======== rotate, translate Examples ======== >>> from sympy import Point2D >>> t = Point2D(1, 1) >>> t.scale(2) Point2D(2, 1) >>> t.scale(2, 2) Point2D(2, 2) """ if pt: pt = Point(pt, dim=2) return self.translate(*(-pt).args).scale(x, y).translate(*pt.args) return Point(self.x*x, self.y*y) def transform(self, matrix): """Return the point after applying the transformation described by the 3x3 Matrix, ``matrix``. See Also ======== geometry.entity.rotate geometry.entity.scale geometry.entity.translate """ if not (matrix.is_Matrix and matrix.shape == (3, 3)): raise ValueError("matrix must be a 3x3 matrix") col, row = matrix.shape valid_matrix = matrix.is_square and col == 3 x, y = self.args return Point(*(Matrix(1, 3, [x, y, 1])*matrix).tolist()[0][:2]) def translate(self, x=0, y=0): """Shift the Point by adding x and y to the coordinates of the Point. See Also ======== rotate, scale Examples ======== >>> from sympy import Point2D >>> t = Point2D(0, 1) >>> t.translate(2) Point2D(2, 1) >>> t.translate(2, 2) Point2D(2, 3) >>> t + Point2D(2, 2) Point2D(2, 3) """ return Point(self.x + x, self.y + y) @property def x(self): """ Returns the X coordinate of the Point. Examples ======== >>> from sympy import Point2D >>> p = Point2D(0, 1) >>> p.x 0 """ return self.args[0] @property def y(self): """ Returns the Y coordinate of the Point. Examples ======== >>> from sympy import Point2D >>> p = Point2D(0, 1) >>> p.y 1 """ return self.args[1] class Point3D(Point): """A point in a 3-dimensional Euclidean space. Parameters ========== coords : sequence of 3 coordinate values. Attributes ========== x y z length Raises ====== TypeError When trying to add or subtract points with different dimensions. When `intersection` is called with object other than a Point. Examples ======== >>> from sympy import Point3D >>> from sympy.abc import x >>> Point3D(1, 2, 3) Point3D(1, 2, 3) >>> Point3D([1, 2, 3]) Point3D(1, 2, 3) >>> Point3D(0, x, 3) Point3D(0, x, 3) Floats are automatically converted to Rational unless the evaluate flag is False: >>> Point3D(0.5, 0.25, 2) Point3D(1/2, 1/4, 2) >>> Point3D(0.5, 0.25, 3, evaluate=False) Point3D(0.5, 0.25, 3) """ _ambient_dimension = 3 def __new__(cls, *args, **kwargs): if not kwargs.pop('_nocheck', False): kwargs['dim'] = 3 args = Point(*args, **kwargs) return GeometryEntity.__new__(cls, *args) def __contains__(self, item): return item == self @staticmethod def are_collinear(*points): """Is a sequence of points collinear? Test whether or not a set of points are collinear. Returns True if the set of points are collinear, or False otherwise. Parameters ========== points : sequence of Point Returns ======= are_collinear : boolean See Also ======== sympy.geometry.line.Line3D Examples ======== >>> from sympy import Point3D, Matrix >>> from sympy.abc import x >>> p1, p2 = Point3D(0, 0, 0), Point3D(1, 1, 1) >>> p3, p4, p5 = Point3D(2, 2, 2), Point3D(x, x, x), Point3D(1, 2, 6) >>> Point3D.are_collinear(p1, p2, p3, p4) True >>> Point3D.are_collinear(p1, p2, p3, p5) False """ return Point.is_collinear(*points) def direction_cosine(self, point): """ Gives the direction cosine between 2 points Parameters ========== p : Point3D Returns ======= list Examples ======== >>> from sympy import Point3D >>> p1 = Point3D(1, 2, 3) >>> p1.direction_cosine(Point3D(2, 3, 5)) [sqrt(6)/6, sqrt(6)/6, sqrt(6)/3] """ a = self.direction_ratio(point) b = sqrt(Add(*(i**2 for i in a))) return [(point.x - self.x) / b,(point.y - self.y) / b, (point.z - self.z) / b] def direction_ratio(self, point): """ Gives the direction ratio between 2 points Parameters ========== p : Point3D Returns ======= list Examples ======== >>> from sympy import Point3D >>> p1 = Point3D(1, 2, 3) >>> p1.direction_ratio(Point3D(2, 3, 5)) [1, 1, 2] """ return [(point.x - self.x),(point.y - self.y),(point.z - self.z)] def intersection(self, other): """The intersection between this point and another point. Parameters ========== other : Point Returns ======= intersection : list of Points Notes ===== The return value will either be an empty list if there is no intersection, otherwise it will contain this point. Examples ======== >>> from sympy import Point3D >>> p1, p2, p3 = Point3D(0, 0, 0), Point3D(1, 1, 1), Point3D(0, 0, 0) >>> p1.intersection(p2) [] >>> p1.intersection(p3) [Point3D(0, 0, 0)] """ if not isinstance(other, GeometryEntity): other = Point(other, dim=3) if isinstance(other, Point3D): if self == other: return [self] return [] return other.intersection(self) def scale(self, x=1, y=1, z=1, pt=None): """Scale the coordinates of the Point by multiplying by ``x`` and ``y`` after subtracting ``pt`` -- default is (0, 0) -- and then adding ``pt`` back again (i.e. ``pt`` is the point of reference for the scaling). See Also ======== translate Examples ======== >>> from sympy import Point3D >>> t = Point3D(1, 1, 1) >>> t.scale(2) Point3D(2, 1, 1) >>> t.scale(2, 2) Point3D(2, 2, 1) """ if pt: pt = Point3D(pt) return self.translate(*(-pt).args).scale(x, y, z).translate(*pt.args) return Point3D(self.x*x, self.y*y, self.z*z) def transform(self, matrix): """Return the point after applying the transformation described by the 4x4 Matrix, ``matrix``. See Also ======== geometry.entity.rotate geometry.entity.scale geometry.entity.translate """ if not (matrix.is_Matrix and matrix.shape == (4, 4)): raise ValueError("matrix must be a 4x4 matrix") col, row = matrix.shape valid_matrix = matrix.is_square and col == 4 from sympy.matrices.expressions import Transpose x, y, z = self.args m = Transpose(matrix) return Point3D(*(Matrix(1, 4, [x, y, z, 1])*m).tolist()[0][:3]) def translate(self, x=0, y=0, z=0): """Shift the Point by adding x and y to the coordinates of the Point. See Also ======== rotate, scale Examples ======== >>> from sympy import Point3D >>> t = Point3D(0, 1, 1) >>> t.translate(2) Point3D(2, 1, 1) >>> t.translate(2, 2) Point3D(2, 3, 1) >>> t + Point3D(2, 2, 2) Point3D(2, 3, 3) """ return Point3D(self.x + x, self.y + y, self.z + z) @property def x(self): """ Returns the X coordinate of the Point. Examples ======== >>> from sympy import Point3D >>> p = Point3D(0, 1, 3) >>> p.x 0 """ return self.args[0] @property def y(self): """ Returns the Y coordinate of the Point. Examples ======== >>> from sympy import Point3D >>> p = Point3D(0, 1, 2) >>> p.y 1 """ return self.args[1] @property def z(self): """ Returns the Z coordinate of the Point. Examples ======== >>> from sympy import Point3D >>> p = Point3D(0, 1, 1) >>> p.z 1 """ return self.args[2]
2fdd675ab43c016a046dc32040eba93eb975ead136e6db62b4b2ee74d8fcf7d5
"""Elliptical geometrical entities. Contains * Ellipse * Circle """ from __future__ import division, print_function from sympy import Expr, Eq from sympy.core import S, pi, sympify from sympy.core.evaluate import global_evaluate from sympy.core.logic import fuzzy_bool from sympy.core.numbers import Rational, oo from sympy.core.compatibility import ordered from sympy.core.symbol import Dummy, _uniquely_named_symbol, _symbol from sympy.simplify import simplify, trigsimp from sympy.functions.elementary.miscellaneous import sqrt, Max from sympy.functions.elementary.trigonometric import cos, sin from sympy.functions.special.elliptic_integrals import elliptic_e from sympy.geometry.exceptions import GeometryError from sympy.geometry.line import Ray2D, Segment2D, Line2D, LinearEntity3D from sympy.polys import DomainError, Poly, PolynomialError from sympy.polys.polyutils import _not_a_coeff, _nsort from sympy.solvers import solve from sympy.solvers.solveset import linear_coeffs from sympy.utilities.misc import filldedent, func_name from .entity import GeometryEntity, GeometrySet from .point import Point, Point2D, Point3D from .line import Line, Segment from .util import idiff import random class Ellipse(GeometrySet): """An elliptical GeometryEntity. Parameters ========== center : Point, optional Default value is Point(0, 0) hradius : number or SymPy expression, optional vradius : number or SymPy expression, optional eccentricity : number or SymPy expression, optional Two of `hradius`, `vradius` and `eccentricity` must be supplied to create an Ellipse. The third is derived from the two supplied. Attributes ========== center hradius vradius area circumference eccentricity periapsis apoapsis focus_distance foci Raises ====== GeometryError When `hradius`, `vradius` and `eccentricity` are incorrectly supplied as parameters. TypeError When `center` is not a Point. See Also ======== Circle Notes ----- Constructed from a center and two radii, the first being the horizontal radius (along the x-axis) and the second being the vertical radius (along the y-axis). When symbolic value for hradius and vradius are used, any calculation that refers to the foci or the major or minor axis will assume that the ellipse has its major radius on the x-axis. If this is not true then a manual rotation is necessary. Examples ======== >>> from sympy import Ellipse, Point, Rational >>> e1 = Ellipse(Point(0, 0), 5, 1) >>> e1.hradius, e1.vradius (5, 1) >>> e2 = Ellipse(Point(3, 1), hradius=3, eccentricity=Rational(4, 5)) >>> e2 Ellipse(Point2D(3, 1), 3, 9/5) """ def __contains__(self, o): if isinstance(o, Point): x = Dummy('x', real=True) y = Dummy('y', real=True) res = self.equation(x, y).subs({x: o.x, y: o.y}) return trigsimp(simplify(res)) is S.Zero elif isinstance(o, Ellipse): return self == o return False def __eq__(self, o): """Is the other GeometryEntity the same as this ellipse?""" return isinstance(o, Ellipse) and (self.center == o.center and self.hradius == o.hradius and self.vradius == o.vradius) def __hash__(self): return super(Ellipse, self).__hash__() def __new__( cls, center=None, hradius=None, vradius=None, eccentricity=None, **kwargs): hradius = sympify(hradius) vradius = sympify(vradius) eccentricity = sympify(eccentricity) if center is None: center = Point(0, 0) else: center = Point(center, dim=2) if len(center) != 2: raise ValueError('The center of "{0}" must be a two dimensional point'.format(cls)) if len(list(filter(lambda x: x is not None, (hradius, vradius, eccentricity)))) != 2: raise ValueError(filldedent(''' Exactly two arguments of "hradius", "vradius", and "eccentricity" must not be None.''')) if eccentricity is not None: if hradius is None: hradius = vradius / sqrt(1 - eccentricity**2) elif vradius is None: vradius = hradius * sqrt(1 - eccentricity**2) if hradius == vradius: return Circle(center, hradius, **kwargs) if hradius == 0 or vradius == 0: return Segment(Point(center[0] - hradius, center[1] - vradius), Point(center[0] + hradius, center[1] + vradius)) return GeometryEntity.__new__(cls, center, hradius, vradius, **kwargs) def _svg(self, scale_factor=1., fill_color="#66cc99"): """Returns SVG ellipse element for the Ellipse. Parameters ========== scale_factor : float Multiplication factor for the SVG stroke-width. Default is 1. fill_color : str, optional Hex string for fill color. Default is "#66cc99". """ from sympy.core.evalf import N c = N(self.center) h, v = N(self.hradius), N(self.vradius) return ( '<ellipse fill="{1}" stroke="#555555" ' 'stroke-width="{0}" opacity="0.6" cx="{2}" cy="{3}" rx="{4}" ry="{5}"/>' ).format(2. * scale_factor, fill_color, c.x, c.y, h, v) @property def ambient_dimension(self): return 2 @property def apoapsis(self): """The apoapsis of the ellipse. The greatest distance between the focus and the contour. Returns ======= apoapsis : number See Also ======== periapsis : Returns shortest distance between foci and contour Examples ======== >>> from sympy import Point, Ellipse >>> p1 = Point(0, 0) >>> e1 = Ellipse(p1, 3, 1) >>> e1.apoapsis 2*sqrt(2) + 3 """ return self.major * (1 + self.eccentricity) def arbitrary_point(self, parameter='t'): """A parameterized point on the ellipse. Parameters ========== parameter : str, optional Default value is 't'. Returns ======= arbitrary_point : Point Raises ====== ValueError When `parameter` already appears in the functions. See Also ======== sympy.geometry.point.Point Examples ======== >>> from sympy import Point, Ellipse >>> e1 = Ellipse(Point(0, 0), 3, 2) >>> e1.arbitrary_point() Point2D(3*cos(t), 2*sin(t)) """ t = _symbol(parameter, real=True) if t.name in (f.name for f in self.free_symbols): raise ValueError(filldedent('Symbol %s already appears in object ' 'and cannot be used as a parameter.' % t.name)) return Point(self.center.x + self.hradius*cos(t), self.center.y + self.vradius*sin(t)) @property def area(self): """The area of the ellipse. Returns ======= area : number Examples ======== >>> from sympy import Point, Ellipse >>> p1 = Point(0, 0) >>> e1 = Ellipse(p1, 3, 1) >>> e1.area 3*pi """ return simplify(S.Pi * self.hradius * self.vradius) @property def bounds(self): """Return a tuple (xmin, ymin, xmax, ymax) representing the bounding rectangle for the geometric figure. """ h, v = self.hradius, self.vradius return (self.center.x - h, self.center.y - v, self.center.x + h, self.center.y + v) @property def center(self): """The center of the ellipse. Returns ======= center : number See Also ======== sympy.geometry.point.Point Examples ======== >>> from sympy import Point, Ellipse >>> p1 = Point(0, 0) >>> e1 = Ellipse(p1, 3, 1) >>> e1.center Point2D(0, 0) """ return self.args[0] @property def circumference(self): """The circumference of the ellipse. Examples ======== >>> from sympy import Point, Ellipse >>> p1 = Point(0, 0) >>> e1 = Ellipse(p1, 3, 1) >>> e1.circumference 12*elliptic_e(8/9) """ if self.eccentricity == 1: # degenerate return 4*self.major elif self.eccentricity == 0: # circle return 2*pi*self.hradius else: return 4*self.major*elliptic_e(self.eccentricity**2) @property def eccentricity(self): """The eccentricity of the ellipse. Returns ======= eccentricity : number Examples ======== >>> from sympy import Point, Ellipse, sqrt >>> p1 = Point(0, 0) >>> e1 = Ellipse(p1, 3, sqrt(2)) >>> e1.eccentricity sqrt(7)/3 """ return self.focus_distance / self.major def encloses_point(self, p): """ Return True if p is enclosed by (is inside of) self. Notes ----- Being on the border of self is considered False. Parameters ========== p : Point Returns ======= encloses_point : True, False or None See Also ======== sympy.geometry.point.Point Examples ======== >>> from sympy import Ellipse, S >>> from sympy.abc import t >>> e = Ellipse((0, 0), 3, 2) >>> e.encloses_point((0, 0)) True >>> e.encloses_point(e.arbitrary_point(t).subs(t, S.Half)) False >>> e.encloses_point((4, 0)) False """ p = Point(p, dim=2) if p in self: return False if len(self.foci) == 2: # if the combined distance from the foci to p (h1 + h2) is less # than the combined distance from the foci to the minor axis # (which is the same as the major axis length) then p is inside # the ellipse h1, h2 = [f.distance(p) for f in self.foci] test = 2*self.major - (h1 + h2) else: test = self.radius - self.center.distance(p) return fuzzy_bool(test.is_positive) def equation(self, x='x', y='y', _slope=None): """ Returns the equation of an ellipse aligned with the x and y axes; when slope is given, the equation returned corresponds to an ellipse with a major axis having that slope. Parameters ========== x : str, optional Label for the x-axis. Default value is 'x'. y : str, optional Label for the y-axis. Default value is 'y'. _slope : Expr, optional The slope of the major axis. Ignored when 'None'. Returns ======= equation : sympy expression See Also ======== arbitrary_point : Returns parameterized point on ellipse Examples ======== >>> from sympy import Point, Ellipse, pi >>> from sympy.abc import x, y >>> e1 = Ellipse(Point(1, 0), 3, 2) >>> eq1 = e1.equation(x, y); eq1 y**2/4 + (x/3 - 1/3)**2 - 1 >>> eq2 = e1.equation(x, y, _slope=1); eq2 (-x + y + 1)**2/8 + (x + y - 1)**2/18 - 1 A point on e1 satisfies eq1. Let's use one on the x-axis: >>> p1 = e1.center + Point(e1.major, 0) >>> assert eq1.subs(x, p1.x).subs(y, p1.y) == 0 When rotated the same as the rotated ellipse, about the center point of the ellipse, it will satisfy the rotated ellipse's equation, too: >>> r1 = p1.rotate(pi/4, e1.center) >>> assert eq2.subs(x, r1.x).subs(y, r1.y) == 0 References ========== .. [1] https://math.stackexchange.com/questions/108270/what-is-the-equation-of-an-ellipse-that-is-not-aligned-with-the-axis .. [2] https://en.wikipedia.org/wiki/Ellipse#Equation_of_a_shifted_ellipse """ x = _symbol(x, real=True) y = _symbol(y, real=True) dx = x - self.center.x dy = y - self.center.y if _slope is not None: L = (dy - _slope*dx)**2 l = (_slope*dy + dx)**2 h = 1 + _slope**2 b = h*self.major**2 a = h*self.minor**2 return l/b + L/a - 1 else: t1 = (dx/self.hradius)**2 t2 = (dy/self.vradius)**2 return t1 + t2 - 1 def evolute(self, x='x', y='y'): """The equation of evolute of the ellipse. Parameters ========== x : str, optional Label for the x-axis. Default value is 'x'. y : str, optional Label for the y-axis. Default value is 'y'. Returns ======= equation : sympy expression Examples ======== >>> from sympy import Point, Ellipse >>> e1 = Ellipse(Point(1, 0), 3, 2) >>> e1.evolute() 2**(2/3)*y**(2/3) + (3*x - 3)**(2/3) - 5**(2/3) """ if len(self.args) != 3: raise NotImplementedError('Evolute of arbitrary Ellipse is not supported.') x = _symbol(x, real=True) y = _symbol(y, real=True) t1 = (self.hradius*(x - self.center.x))**Rational(2, 3) t2 = (self.vradius*(y - self.center.y))**Rational(2, 3) return t1 + t2 - (self.hradius**2 - self.vradius**2)**Rational(2, 3) @property def foci(self): """The foci of the ellipse. Notes ----- The foci can only be calculated if the major/minor axes are known. Raises ====== ValueError When the major and minor axis cannot be determined. See Also ======== sympy.geometry.point.Point focus_distance : Returns the distance between focus and center Examples ======== >>> from sympy import Point, Ellipse >>> p1 = Point(0, 0) >>> e1 = Ellipse(p1, 3, 1) >>> e1.foci (Point2D(-2*sqrt(2), 0), Point2D(2*sqrt(2), 0)) """ c = self.center hr, vr = self.hradius, self.vradius if hr == vr: return (c, c) # calculate focus distance manually, since focus_distance calls this # routine fd = sqrt(self.major**2 - self.minor**2) if hr == self.minor: # foci on the y-axis return (c + Point(0, -fd), c + Point(0, fd)) elif hr == self.major: # foci on the x-axis return (c + Point(-fd, 0), c + Point(fd, 0)) @property def focus_distance(self): """The focal distance of the ellipse. The distance between the center and one focus. Returns ======= focus_distance : number See Also ======== foci Examples ======== >>> from sympy import Point, Ellipse >>> p1 = Point(0, 0) >>> e1 = Ellipse(p1, 3, 1) >>> e1.focus_distance 2*sqrt(2) """ return Point.distance(self.center, self.foci[0]) @property def hradius(self): """The horizontal radius of the ellipse. Returns ======= hradius : number See Also ======== vradius, major, minor Examples ======== >>> from sympy import Point, Ellipse >>> p1 = Point(0, 0) >>> e1 = Ellipse(p1, 3, 1) >>> e1.hradius 3 """ return self.args[1] def intersection(self, o): """The intersection of this ellipse and another geometrical entity `o`. Parameters ========== o : GeometryEntity Returns ======= intersection : list of GeometryEntity objects Notes ----- Currently supports intersections with Point, Line, Segment, Ray, Circle and Ellipse types. See Also ======== sympy.geometry.entity.GeometryEntity Examples ======== >>> from sympy import Ellipse, Point, Line, sqrt >>> e = Ellipse(Point(0, 0), 5, 7) >>> e.intersection(Point(0, 0)) [] >>> e.intersection(Point(5, 0)) [Point2D(5, 0)] >>> e.intersection(Line(Point(0,0), Point(0, 1))) [Point2D(0, -7), Point2D(0, 7)] >>> e.intersection(Line(Point(5,0), Point(5, 1))) [Point2D(5, 0)] >>> e.intersection(Line(Point(6,0), Point(6, 1))) [] >>> e = Ellipse(Point(-1, 0), 4, 3) >>> e.intersection(Ellipse(Point(1, 0), 4, 3)) [Point2D(0, -3*sqrt(15)/4), Point2D(0, 3*sqrt(15)/4)] >>> e.intersection(Ellipse(Point(5, 0), 4, 3)) [Point2D(2, -3*sqrt(7)/4), Point2D(2, 3*sqrt(7)/4)] >>> e.intersection(Ellipse(Point(100500, 0), 4, 3)) [] >>> e.intersection(Ellipse(Point(0, 0), 3, 4)) [Point2D(3, 0), Point2D(-363/175, -48*sqrt(111)/175), Point2D(-363/175, 48*sqrt(111)/175)] >>> e.intersection(Ellipse(Point(-1, 0), 3, 4)) [Point2D(-17/5, -12/5), Point2D(-17/5, 12/5), Point2D(7/5, -12/5), Point2D(7/5, 12/5)] """ # TODO: Replace solve with nonlinsolve, when nonlinsolve will be able to solve in real domain x = Dummy('x', real=True) y = Dummy('y', real=True) if isinstance(o, Point): if o in self: return [o] else: return [] elif isinstance(o, (Segment2D, Ray2D)): ellipse_equation = self.equation(x, y) result = solve([ellipse_equation, Line(o.points[0], o.points[1]).equation(x, y)], [x, y]) return list(ordered([Point(i) for i in result if i in o])) elif isinstance(o, Polygon): return o.intersection(self) elif isinstance(o, (Ellipse, Line2D)): if o == self: return self else: ellipse_equation = self.equation(x, y) return list(ordered([Point(i) for i in solve([ellipse_equation, o.equation(x, y)], [x, y])])) elif isinstance(o, LinearEntity3D): raise TypeError('Entity must be two dimensional, not three dimensional') else: raise TypeError('Intersection not handled for %s' % func_name(o)) def is_tangent(self, o): """Is `o` tangent to the ellipse? Parameters ========== o : GeometryEntity An Ellipse, LinearEntity or Polygon Raises ====== NotImplementedError When the wrong type of argument is supplied. Returns ======= is_tangent: boolean True if o is tangent to the ellipse, False otherwise. See Also ======== tangent_lines Examples ======== >>> from sympy import Point, Ellipse, Line >>> p0, p1, p2 = Point(0, 0), Point(3, 0), Point(3, 3) >>> e1 = Ellipse(p0, 3, 2) >>> l1 = Line(p1, p2) >>> e1.is_tangent(l1) True """ if isinstance(o, Point2D): return False elif isinstance(o, Ellipse): intersect = self.intersection(o) if isinstance(intersect, Ellipse): return True elif intersect: return all((self.tangent_lines(i)[0]).equals((o.tangent_lines(i)[0])) for i in intersect) else: return False elif isinstance(o, Line2D): return len(self.intersection(o)) == 1 elif isinstance(o, Ray2D): intersect = self.intersection(o) if len(intersect) == 1: return intersect[0] != o.source and not self.encloses_point(o.source) else: return False elif isinstance(o, (Segment2D, Polygon)): all_tangents = False segments = o.sides if isinstance(o, Polygon) else [o] for segment in segments: intersect = self.intersection(segment) if len(intersect) == 1: if not any(intersect[0] in i for i in segment.points) \ and all(not self.encloses_point(i) for i in segment.points): all_tangents = True continue else: return False else: return all_tangents return all_tangents elif isinstance(o, (LinearEntity3D, Point3D)): raise TypeError('Entity must be two dimensional, not three dimensional') else: raise TypeError('Is_tangent not handled for %s' % func_name(o)) @property def major(self): """Longer axis of the ellipse (if it can be determined) else hradius. Returns ======= major : number or expression See Also ======== hradius, vradius, minor Examples ======== >>> from sympy import Point, Ellipse, Symbol >>> p1 = Point(0, 0) >>> e1 = Ellipse(p1, 3, 1) >>> e1.major 3 >>> a = Symbol('a') >>> b = Symbol('b') >>> Ellipse(p1, a, b).major a >>> Ellipse(p1, b, a).major b >>> m = Symbol('m') >>> M = m + 1 >>> Ellipse(p1, m, M).major m + 1 """ ab = self.args[1:3] if len(ab) == 1: return ab[0] a, b = ab o = b - a < 0 if o == True: return a elif o == False: return b return self.hradius @property def minor(self): """Shorter axis of the ellipse (if it can be determined) else vradius. Returns ======= minor : number or expression See Also ======== hradius, vradius, major Examples ======== >>> from sympy import Point, Ellipse, Symbol >>> p1 = Point(0, 0) >>> e1 = Ellipse(p1, 3, 1) >>> e1.minor 1 >>> a = Symbol('a') >>> b = Symbol('b') >>> Ellipse(p1, a, b).minor b >>> Ellipse(p1, b, a).minor a >>> m = Symbol('m') >>> M = m + 1 >>> Ellipse(p1, m, M).minor m """ ab = self.args[1:3] if len(ab) == 1: return ab[0] a, b = ab o = a - b < 0 if o == True: return a elif o == False: return b return self.vradius def normal_lines(self, p, prec=None): """Normal lines between `p` and the ellipse. Parameters ========== p : Point Returns ======= normal_lines : list with 1, 2 or 4 Lines Examples ======== >>> from sympy import Line, Point, Ellipse >>> e = Ellipse((0, 0), 2, 3) >>> c = e.center >>> e.normal_lines(c + Point(1, 0)) [Line2D(Point2D(0, 0), Point2D(1, 0))] >>> e.normal_lines(c) [Line2D(Point2D(0, 0), Point2D(0, 1)), Line2D(Point2D(0, 0), Point2D(1, 0))] Off-axis points require the solution of a quartic equation. This often leads to very large expressions that may be of little practical use. An approximate solution of `prec` digits can be obtained by passing in the desired value: >>> e.normal_lines((3, 3), prec=2) [Line2D(Point2D(-0.81, -2.7), Point2D(0.19, -1.2)), Line2D(Point2D(1.5, -2.0), Point2D(2.5, -2.7))] Whereas the above solution has an operation count of 12, the exact solution has an operation count of 2020. """ p = Point(p, dim=2) # XXX change True to something like self.angle == 0 if the arbitrarily # rotated ellipse is introduced. # https://github.com/sympy/sympy/issues/2815) if True: rv = [] if p.x == self.center.x: rv.append(Line(self.center, slope=oo)) if p.y == self.center.y: rv.append(Line(self.center, slope=0)) if rv: # at these special orientations of p either 1 or 2 normals # exist and we are done return rv # find the 4 normal points and construct lines through them with # the corresponding slope x, y = Dummy('x', real=True), Dummy('y', real=True) eq = self.equation(x, y) dydx = idiff(eq, y, x) norm = -1/dydx slope = Line(p, (x, y)).slope seq = slope - norm # TODO: Replace solve with solveset, when this line is tested yis = solve(seq, y)[0] xeq = eq.subs(y, yis).as_numer_denom()[0].expand() if len(xeq.free_symbols) == 1: try: # this is so much faster, it's worth a try xsol = Poly(xeq, x).real_roots() except (DomainError, PolynomialError, NotImplementedError): # TODO: Replace solve with solveset, when these lines are tested xsol = _nsort(solve(xeq, x), separated=True)[0] points = [Point(i, solve(eq.subs(x, i), y)[0]) for i in xsol] else: raise NotImplementedError( 'intersections for the general ellipse are not supported') slopes = [norm.subs(zip((x, y), pt.args)) for pt in points] if prec is not None: points = [pt.n(prec) for pt in points] slopes = [i if _not_a_coeff(i) else i.n(prec) for i in slopes] return [Line(pt, slope=s) for pt, s in zip(points, slopes)] @property def periapsis(self): """The periapsis of the ellipse. The shortest distance between the focus and the contour. Returns ======= periapsis : number See Also ======== apoapsis : Returns greatest distance between focus and contour Examples ======== >>> from sympy import Point, Ellipse >>> p1 = Point(0, 0) >>> e1 = Ellipse(p1, 3, 1) >>> e1.periapsis 3 - 2*sqrt(2) """ return self.major * (1 - self.eccentricity) @property def semilatus_rectum(self): """ Calculates the semi-latus rectum of the Ellipse. Semi-latus rectum is defined as one half of the the chord through a focus parallel to the conic section directrix of a conic section. Returns ======= semilatus_rectum : number See Also ======== apoapsis : Returns greatest distance between focus and contour periapsis : The shortest distance between the focus and the contour Examples ======== >>> from sympy import Point, Ellipse >>> p1 = Point(0, 0) >>> e1 = Ellipse(p1, 3, 1) >>> e1.semilatus_rectum 1/3 References ========== [1] http://mathworld.wolfram.com/SemilatusRectum.html [2] https://en.wikipedia.org/wiki/Ellipse#Semi-latus_rectum """ return self.major * (1 - self.eccentricity ** 2) def auxiliary_circle(self): """Returns a Circle whose diameter is the major axis of the ellipse. Examples ======== >>> from sympy import Circle, Ellipse, Point, symbols >>> c = Point(1, 2) >>> Ellipse(c, 8, 7).auxiliary_circle() Circle(Point2D(1, 2), 8) >>> a, b = symbols('a b') >>> Ellipse(c, a, b).auxiliary_circle() Circle(Point2D(1, 2), Max(a, b)) """ return Circle(self.center, Max(self.hradius, self.vradius)) def plot_interval(self, parameter='t'): """The plot interval for the default geometric plot of the Ellipse. Parameters ========== parameter : str, optional Default value is 't'. Returns ======= plot_interval : list [parameter, lower_bound, upper_bound] Examples ======== >>> from sympy import Point, Ellipse >>> e1 = Ellipse(Point(0, 0), 3, 2) >>> e1.plot_interval() [t, -pi, pi] """ t = _symbol(parameter, real=True) return [t, -S.Pi, S.Pi] def random_point(self, seed=None): """A random point on the ellipse. Returns ======= point : Point Examples ======== >>> from sympy import Point, Ellipse, Segment >>> e1 = Ellipse(Point(0, 0), 3, 2) >>> e1.random_point() # gives some random point Point2D(...) >>> p1 = e1.random_point(seed=0); p1.n(2) Point2D(2.1, 1.4) Notes ===== When creating a random point, one may simply replace the parameter with a random number. When doing so, however, the random number should be made a Rational or else the point may not test as being in the ellipse: >>> from sympy.abc import t >>> from sympy import Rational >>> arb = e1.arbitrary_point(t); arb Point2D(3*cos(t), 2*sin(t)) >>> arb.subs(t, .1) in e1 False >>> arb.subs(t, Rational(.1)) in e1 True >>> arb.subs(t, Rational('.1')) in e1 True See Also ======== sympy.geometry.point.Point arbitrary_point : Returns parameterized point on ellipse """ from sympy import sin, cos, Rational t = _symbol('t', real=True) x, y = self.arbitrary_point(t).args # get a random value in [-1, 1) corresponding to cos(t) # and confirm that it will test as being in the ellipse if seed is not None: rng = random.Random(seed) else: rng = random # simplify this now or else the Float will turn s into a Float r = Rational(rng.random()) c = 2*r - 1 s = sqrt(1 - c**2) return Point(x.subs(cos(t), c), y.subs(sin(t), s)) def reflect(self, line): """Override GeometryEntity.reflect since the radius is not a GeometryEntity. Examples ======== >>> from sympy import Circle, Line >>> Circle((0, 1), 1).reflect(Line((0, 0), (1, 1))) Circle(Point2D(1, 0), -1) >>> from sympy import Ellipse, Line, Point >>> Ellipse(Point(3, 4), 1, 3).reflect(Line(Point(0, -4), Point(5, 0))) Traceback (most recent call last): ... NotImplementedError: General Ellipse is not supported but the equation of the reflected Ellipse is given by the zeros of: f(x, y) = (9*x/41 + 40*y/41 + 37/41)**2 + (40*x/123 - 3*y/41 - 364/123)**2 - 1 Notes ===== Until the general ellipse (with no axis parallel to the x-axis) is supported a NotImplemented error is raised and the equation whose zeros define the rotated ellipse is given. """ if line.slope in (0, oo): c = self.center c = c.reflect(line) return self.func(c, -self.hradius, self.vradius) else: x, y = [_uniquely_named_symbol( name, (self, line), real=True) for name in 'xy'] expr = self.equation(x, y) p = Point(x, y).reflect(line) result = expr.subs(zip((x, y), p.args ), simultaneous=True) raise NotImplementedError(filldedent( 'General Ellipse is not supported but the equation ' 'of the reflected Ellipse is given by the zeros of: ' + "f(%s, %s) = %s" % (str(x), str(y), str(result)))) def rotate(self, angle=0, pt=None): """Rotate ``angle`` radians counterclockwise about Point ``pt``. Note: since the general ellipse is not supported, only rotations that are integer multiples of pi/2 are allowed. Examples ======== >>> from sympy import Ellipse, pi >>> Ellipse((1, 0), 2, 1).rotate(pi/2) Ellipse(Point2D(0, 1), 1, 2) >>> Ellipse((1, 0), 2, 1).rotate(pi) Ellipse(Point2D(-1, 0), 2, 1) """ if self.hradius == self.vradius: return self.func(self.center.rotate(angle, pt), self.hradius) if (angle/S.Pi).is_integer: return super(Ellipse, self).rotate(angle, pt) if (2*angle/S.Pi).is_integer: return self.func(self.center.rotate(angle, pt), self.vradius, self.hradius) # XXX see https://github.com/sympy/sympy/issues/2815 for general ellipes raise NotImplementedError('Only rotations of pi/2 are currently supported for Ellipse.') def scale(self, x=1, y=1, pt=None): """Override GeometryEntity.scale since it is the major and minor axes which must be scaled and they are not GeometryEntities. Examples ======== >>> from sympy import Ellipse >>> Ellipse((0, 0), 2, 1).scale(2, 4) Circle(Point2D(0, 0), 4) >>> Ellipse((0, 0), 2, 1).scale(2) Ellipse(Point2D(0, 0), 4, 1) """ c = self.center if pt: pt = Point(pt, dim=2) return self.translate(*(-pt).args).scale(x, y).translate(*pt.args) h = self.hradius v = self.vradius return self.func(c.scale(x, y), hradius=h*x, vradius=v*y) def tangent_lines(self, p): """Tangent lines between `p` and the ellipse. If `p` is on the ellipse, returns the tangent line through point `p`. Otherwise, returns the tangent line(s) from `p` to the ellipse, or None if no tangent line is possible (e.g., `p` inside ellipse). Parameters ========== p : Point Returns ======= tangent_lines : list with 1 or 2 Lines Raises ====== NotImplementedError Can only find tangent lines for a point, `p`, on the ellipse. See Also ======== sympy.geometry.point.Point, sympy.geometry.line.Line Examples ======== >>> from sympy import Point, Ellipse >>> e1 = Ellipse(Point(0, 0), 3, 2) >>> e1.tangent_lines(Point(3, 0)) [Line2D(Point2D(3, 0), Point2D(3, -12))] """ p = Point(p, dim=2) if self.encloses_point(p): return [] if p in self: delta = self.center - p rise = (self.vradius**2)*delta.x run = -(self.hradius**2)*delta.y p2 = Point(simplify(p.x + run), simplify(p.y + rise)) return [Line(p, p2)] else: if len(self.foci) == 2: f1, f2 = self.foci maj = self.hradius test = (2*maj - Point.distance(f1, p) - Point.distance(f2, p)) else: test = self.radius - Point.distance(self.center, p) if test.is_number and test.is_positive: return [] # else p is outside the ellipse or we can't tell. In case of the # latter, the solutions returned will only be valid if # the point is not inside the ellipse; if it is, nan will result. x, y = Dummy('x'), Dummy('y') eq = self.equation(x, y) dydx = idiff(eq, y, x) slope = Line(p, Point(x, y)).slope # TODO: Replace solve with solveset, when this line is tested tangent_points = solve([slope - dydx, eq], [x, y]) # handle horizontal and vertical tangent lines if len(tangent_points) == 1: assert tangent_points[0][ 0] == p.x or tangent_points[0][1] == p.y return [Line(p, p + Point(1, 0)), Line(p, p + Point(0, 1))] # others return [Line(p, tangent_points[0]), Line(p, tangent_points[1])] @property def vradius(self): """The vertical radius of the ellipse. Returns ======= vradius : number See Also ======== hradius, major, minor Examples ======== >>> from sympy import Point, Ellipse >>> p1 = Point(0, 0) >>> e1 = Ellipse(p1, 3, 1) >>> e1.vradius 1 """ return self.args[2] def second_moment_of_area(self, point=None): """Returns the second moment and product moment area of an ellipse. Parameters ========== point : Point, two-tuple of sympifiable objects, or None(default=None) point is the point about which second moment of area is to be found. If "point=None" it will be calculated about the axis passing through the centroid of the ellipse. Returns ======= I_xx, I_yy, I_xy : number or sympy expression I_xx, I_yy are second moment of area of an ellise. I_xy is product moment of area of an ellipse. Examples ======== >>> from sympy import Point, Ellipse >>> p1 = Point(0, 0) >>> e1 = Ellipse(p1, 3, 1) >>> e1.second_moment_of_area() (3*pi/4, 27*pi/4, 0) References ========== https://en.wikipedia.org/wiki/List_of_second_moments_of_area """ I_xx = (S.Pi*(self.hradius)*(self.vradius**3))/4 I_yy = (S.Pi*(self.hradius**3)*(self.vradius))/4 I_xy = 0 if point is None: return I_xx, I_yy, I_xy # parallel axis theorem I_xx = I_xx + self.area*((point[1] - self.center.y)**2) I_yy = I_yy + self.area*((point[0] - self.center.x)**2) I_xy = I_xy + self.area*(point[0] - self.center.x)*(point[1] - self.center.y) return I_xx, I_yy, I_xy class Circle(Ellipse): """A circle in space. Constructed simply from a center and a radius, from three non-collinear points, or the equation of a circle. Parameters ========== center : Point radius : number or sympy expression points : sequence of three Points equation : equation of a circle Attributes ========== radius (synonymous with hradius, vradius, major and minor) circumference equation Raises ====== GeometryError When the given equation is not that of a circle. When trying to construct circle from incorrect parameters. See Also ======== Ellipse, sympy.geometry.point.Point Examples ======== >>> from sympy import Eq >>> from sympy.geometry import Point, Circle >>> from sympy.abc import x, y, a, b A circle constructed from a center and radius: >>> c1 = Circle(Point(0, 0), 5) >>> c1.hradius, c1.vradius, c1.radius (5, 5, 5) A circle constructed from three points: >>> c2 = Circle(Point(0, 0), Point(1, 1), Point(1, 0)) >>> c2.hradius, c2.vradius, c2.radius, c2.center (sqrt(2)/2, sqrt(2)/2, sqrt(2)/2, Point2D(1/2, 1/2)) A circle can be constructed from an equation in the form `a*x**2 + by**2 + gx + hy + c = 0`, too: >>> Circle(x**2 + y**2 - 25) Circle(Point2D(0, 0), 5) If the variables corresponding to x and y are named something else, their name or symbol can be supplied: >>> Circle(Eq(a**2 + b**2, 25), x='a', y=b) Circle(Point2D(0, 0), 5) """ def __new__(cls, *args, **kwargs): from sympy.geometry.util import find from .polygon import Triangle evaluate = kwargs.get('evaluate', global_evaluate[0]) if len(args) == 1 and isinstance(args[0], Expr): x = kwargs.get('x', 'x') y = kwargs.get('y', 'y') equation = args[0] if isinstance(equation, Eq): equation = equation.lhs - equation.rhs x = find(x, equation) y = find(y, equation) try: a, b, c, d, e = linear_coeffs(equation, x**2, y**2, x, y) except ValueError: raise GeometryError("The given equation is not that of a circle.") if a == 0 or b == 0 or a != b: raise GeometryError("The given equation is not that of a circle.") center_x = -c/a/2 center_y = -d/b/2 r2 = (center_x**2) + (center_y**2) - e return Circle((center_x, center_y), sqrt(r2), evaluate=evaluate) else: c, r = None, None if len(args) == 3: args = [Point(a, dim=2, evaluate=evaluate) for a in args] t = Triangle(*args) if not isinstance(t, Triangle): return t c = t.circumcenter r = t.circumradius elif len(args) == 2: # Assume (center, radius) pair c = Point(args[0], dim=2, evaluate=evaluate) r = args[1] # this will prohibit imaginary radius try: r = Point(r, 0, evaluate=evaluate).x except: raise GeometryError("Circle with imaginary radius is not permitted") if not (c is None or r is None): if r == 0: return c return GeometryEntity.__new__(cls, c, r, **kwargs) raise GeometryError("Circle.__new__ received unknown arguments") @property def circumference(self): """The circumference of the circle. Returns ======= circumference : number or SymPy expression Examples ======== >>> from sympy import Point, Circle >>> c1 = Circle(Point(3, 4), 6) >>> c1.circumference 12*pi """ return 2 * S.Pi * self.radius def equation(self, x='x', y='y'): """The equation of the circle. Parameters ========== x : str or Symbol, optional Default value is 'x'. y : str or Symbol, optional Default value is 'y'. Returns ======= equation : SymPy expression Examples ======== >>> from sympy import Point, Circle >>> c1 = Circle(Point(0, 0), 5) >>> c1.equation() x**2 + y**2 - 25 """ x = _symbol(x, real=True) y = _symbol(y, real=True) t1 = (x - self.center.x)**2 t2 = (y - self.center.y)**2 return t1 + t2 - self.major**2 def intersection(self, o): """The intersection of this circle with another geometrical entity. Parameters ========== o : GeometryEntity Returns ======= intersection : list of GeometryEntities Examples ======== >>> from sympy import Point, Circle, Line, Ray >>> p1, p2, p3 = Point(0, 0), Point(5, 5), Point(6, 0) >>> p4 = Point(5, 0) >>> c1 = Circle(p1, 5) >>> c1.intersection(p2) [] >>> c1.intersection(p4) [Point2D(5, 0)] >>> c1.intersection(Ray(p1, p2)) [Point2D(5*sqrt(2)/2, 5*sqrt(2)/2)] >>> c1.intersection(Line(p2, p3)) [] """ return Ellipse.intersection(self, o) @property def radius(self): """The radius of the circle. Returns ======= radius : number or sympy expression See Also ======== Ellipse.major, Ellipse.minor, Ellipse.hradius, Ellipse.vradius Examples ======== >>> from sympy import Point, Circle >>> c1 = Circle(Point(3, 4), 6) >>> c1.radius 6 """ return self.args[1] def reflect(self, line): """Override GeometryEntity.reflect since the radius is not a GeometryEntity. Examples ======== >>> from sympy import Circle, Line >>> Circle((0, 1), 1).reflect(Line((0, 0), (1, 1))) Circle(Point2D(1, 0), -1) """ c = self.center c = c.reflect(line) return self.func(c, -self.radius) def scale(self, x=1, y=1, pt=None): """Override GeometryEntity.scale since the radius is not a GeometryEntity. Examples ======== >>> from sympy import Circle >>> Circle((0, 0), 1).scale(2, 2) Circle(Point2D(0, 0), 2) >>> Circle((0, 0), 1).scale(2, 4) Ellipse(Point2D(0, 0), 2, 4) """ c = self.center if pt: pt = Point(pt, dim=2) return self.translate(*(-pt).args).scale(x, y).translate(*pt.args) c = c.scale(x, y) x, y = [abs(i) for i in (x, y)] if x == y: return self.func(c, x*self.radius) h = v = self.radius return Ellipse(c, hradius=h*x, vradius=v*y) @property def vradius(self): """ This Ellipse property is an alias for the Circle's radius. Whereas hradius, major and minor can use Ellipse's conventions, the vradius does not exist for a circle. It is always a positive value in order that the Circle, like Polygons, will have an area that can be positive or negative as determined by the sign of the hradius. Examples ======== >>> from sympy import Point, Circle >>> c1 = Circle(Point(3, 4), 6) >>> c1.vradius 6 """ return abs(self.radius) from .polygon import Polygon
84a9ab00ec8e1c41842537cfde3346330e886a66d4288a2ed47477c6686359d3
"""The definition of the base geometrical entity with attributes common to all derived geometrical entities. Contains ======== GeometryEntity GeometricSet Notes ===== A GeometryEntity is any object that has special geometric properties. A GeometrySet is a superclass of any GeometryEntity that can also be viewed as a sympy.sets.Set. In particular, points are the only GeometryEntity not considered a Set. Rn is a GeometrySet representing n-dimensional Euclidean space. R2 and R3 are currently the only ambient spaces implemented. """ from __future__ import division, print_function from sympy.core.basic import Basic from sympy.core.compatibility import is_sequence from sympy.core.containers import Tuple from sympy.core.sympify import sympify from sympy.functions import cos, sin from sympy.matrices import eye from sympy.multipledispatch import dispatch from sympy.sets import Set from sympy.sets.handlers.intersection import intersection_sets from sympy.sets.handlers.union import union_sets from sympy.utilities.misc import func_name # How entities are ordered; used by __cmp__ in GeometryEntity ordering_of_classes = [ "Point2D", "Point3D", "Point", "Segment2D", "Ray2D", "Line2D", "Segment3D", "Line3D", "Ray3D", "Segment", "Ray", "Line", "Plane", "Triangle", "RegularPolygon", "Polygon", "Circle", "Ellipse", "Curve", "Parabola" ] class GeometryEntity(Basic): """The base class for all geometrical entities. This class doesn't represent any particular geometric entity, it only provides the implementation of some methods common to all subclasses. """ def __cmp__(self, other): """Comparison of two GeometryEntities.""" n1 = self.__class__.__name__ n2 = other.__class__.__name__ c = (n1 > n2) - (n1 < n2) if not c: return 0 i1 = -1 for cls in self.__class__.__mro__: try: i1 = ordering_of_classes.index(cls.__name__) break except ValueError: i1 = -1 if i1 == -1: return c i2 = -1 for cls in other.__class__.__mro__: try: i2 = ordering_of_classes.index(cls.__name__) break except ValueError: i2 = -1 if i2 == -1: return c return (i1 > i2) - (i1 < i2) def __contains__(self, other): """Subclasses should implement this method for anything more complex than equality.""" if type(self) == type(other): return self == other raise NotImplementedError() def __getnewargs__(self): """Returns a tuple that will be passed to __new__ on unpickling.""" return tuple(self.args) def __ne__(self, o): """Test inequality of two geometrical entities.""" return not self == o def __new__(cls, *args, **kwargs): # Points are sequences, but they should not # be converted to Tuples, so use this detection function instead. def is_seq_and_not_point(a): # we cannot use isinstance(a, Point) since we cannot import Point if hasattr(a, 'is_Point') and a.is_Point: return False return is_sequence(a) args = [Tuple(*a) if is_seq_and_not_point(a) else sympify(a) for a in args] return Basic.__new__(cls, *args) def __radd__(self, a): """Implementation of reverse add method.""" return a.__add__(self) def __rdiv__(self, a): """Implementation of reverse division method.""" return a.__div__(self) def __repr__(self): """String representation of a GeometryEntity that can be evaluated by sympy.""" return type(self).__name__ + repr(self.args) def __rmul__(self, a): """Implementation of reverse multiplication method.""" return a.__mul__(self) def __rsub__(self, a): """Implementation of reverse substraction method.""" return a.__sub__(self) def __str__(self): """String representation of a GeometryEntity.""" from sympy.printing import sstr return type(self).__name__ + sstr(self.args) def _eval_subs(self, old, new): from sympy.geometry.point import Point, Point3D if is_sequence(old) or is_sequence(new): if isinstance(self, Point3D): old = Point3D(old) new = Point3D(new) else: old = Point(old) new = Point(new) return self._subs(old, new) def _repr_svg_(self): """SVG representation of a GeometryEntity suitable for IPython""" from sympy.core.evalf import N try: bounds = self.bounds except (NotImplementedError, TypeError): # if we have no SVG representation, return None so IPython # will fall back to the next representation return None svg_top = '''<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="{1}" height="{2}" viewBox="{0}" preserveAspectRatio="xMinYMin meet"> <defs> <marker id="markerCircle" markerWidth="8" markerHeight="8" refx="5" refy="5" markerUnits="strokeWidth"> <circle cx="5" cy="5" r="1.5" style="stroke: none; fill:#000000;"/> </marker> <marker id="markerArrow" markerWidth="13" markerHeight="13" refx="2" refy="4" orient="auto" markerUnits="strokeWidth"> <path d="M2,2 L2,6 L6,4" style="fill: #000000;" /> </marker> <marker id="markerReverseArrow" markerWidth="13" markerHeight="13" refx="6" refy="4" orient="auto" markerUnits="strokeWidth"> <path d="M6,2 L6,6 L2,4" style="fill: #000000;" /> </marker> </defs>''' # Establish SVG canvas that will fit all the data + small space xmin, ymin, xmax, ymax = map(N, bounds) if xmin == xmax and ymin == ymax: # This is a point; buffer using an arbitrary size xmin, ymin, xmax, ymax = xmin - .5, ymin -.5, xmax + .5, ymax + .5 else: # Expand bounds by a fraction of the data ranges expand = 0.1 # or 10%; this keeps arrowheads in view (R plots use 4%) widest_part = max([xmax - xmin, ymax - ymin]) expand_amount = widest_part * expand xmin -= expand_amount ymin -= expand_amount xmax += expand_amount ymax += expand_amount dx = xmax - xmin dy = ymax - ymin width = min([max([100., dx]), 300]) height = min([max([100., dy]), 300]) scale_factor = 1. if max(width, height) == 0 else max(dx, dy) / max(width, height) try: svg = self._svg(scale_factor) except (NotImplementedError, TypeError): # if we have no SVG representation, return None so IPython # will fall back to the next representation return None view_box = "{0} {1} {2} {3}".format(xmin, ymin, dx, dy) transform = "matrix(1,0,0,-1,0,{0})".format(ymax + ymin) svg_top = svg_top.format(view_box, width, height) return svg_top + ( '<g transform="{0}">{1}</g></svg>' ).format(transform, svg) def _svg(self, scale_factor=1., fill_color="#66cc99"): """Returns SVG path element for the GeometryEntity. Parameters ========== scale_factor : float Multiplication factor for the SVG stroke-width. Default is 1. fill_color : str, optional Hex string for fill color. Default is "#66cc99". """ raise NotImplementedError() def _sympy_(self): return self @property def ambient_dimension(self): """What is the dimension of the space that the object is contained in?""" raise NotImplementedError() @property def bounds(self): """Return a tuple (xmin, ymin, xmax, ymax) representing the bounding rectangle for the geometric figure. """ raise NotImplementedError() def encloses(self, o): """ Return True if o is inside (not on or outside) the boundaries of self. The object will be decomposed into Points and individual Entities need only define an encloses_point method for their class. See Also ======== sympy.geometry.ellipse.Ellipse.encloses_point sympy.geometry.polygon.Polygon.encloses_point Examples ======== >>> from sympy import RegularPolygon, Point, Polygon >>> t = Polygon(*RegularPolygon(Point(0, 0), 1, 3).vertices) >>> t2 = Polygon(*RegularPolygon(Point(0, 0), 2, 3).vertices) >>> t2.encloses(t) True >>> t.encloses(t2) False """ from sympy.geometry.point import Point from sympy.geometry.line import Segment, Ray, Line from sympy.geometry.ellipse import Ellipse from sympy.geometry.polygon import Polygon, RegularPolygon if isinstance(o, Point): return self.encloses_point(o) elif isinstance(o, Segment): return all(self.encloses_point(x) for x in o.points) elif isinstance(o, Ray) or isinstance(o, Line): return False elif isinstance(o, Ellipse): return self.encloses_point(o.center) and \ self.encloses_point( Point(o.center.x + o.hradius, o.center.y)) and \ not self.intersection(o) elif isinstance(o, Polygon): if isinstance(o, RegularPolygon): if not self.encloses_point(o.center): return False return all(self.encloses_point(v) for v in o.vertices) raise NotImplementedError() def equals(self, o): return self == o def intersection(self, o): """ Returns a list of all of the intersections of self with o. Notes ===== An entity is not required to implement this method. If two different types of entities can intersect, the item with higher index in ordering_of_classes should implement intersections with anything having a lower index. See Also ======== sympy.geometry.util.intersection """ raise NotImplementedError() def is_similar(self, other): """Is this geometrical entity similar to another geometrical entity? Two entities are similar if a uniform scaling (enlarging or shrinking) of one of the entities will allow one to obtain the other. Notes ===== This method is not intended to be used directly but rather through the `are_similar` function found in util.py. An entity is not required to implement this method. If two different types of entities can be similar, it is only required that one of them be able to determine this. See Also ======== scale """ raise NotImplementedError() def reflect(self, line): """ Reflects an object across a line. Parameters ========== line: Line Examples ======== >>> from sympy import pi, sqrt, Line, RegularPolygon >>> l = Line((0, pi), slope=sqrt(2)) >>> pent = RegularPolygon((1, 2), 1, 5) >>> rpent = pent.reflect(l) >>> rpent RegularPolygon(Point2D(-2*sqrt(2)*pi/3 - 1/3 + 4*sqrt(2)/3, 2/3 + 2*sqrt(2)/3 + 2*pi/3), -1, 5, -atan(2*sqrt(2)) + 3*pi/5) >>> from sympy import pi, Line, Circle, Point >>> l = Line((0, pi), slope=1) >>> circ = Circle(Point(0, 0), 5) >>> rcirc = circ.reflect(l) >>> rcirc Circle(Point2D(-pi, pi), -5) """ from sympy import atan, Point, Dummy, oo g = self l = line o = Point(0, 0) if l.slope == 0: y = l.args[0].y if not y: # x-axis return g.scale(y=-1) reps = [(p, p.translate(y=2*(y - p.y))) for p in g.atoms(Point)] elif l.slope == oo: x = l.args[0].x if not x: # y-axis return g.scale(x=-1) reps = [(p, p.translate(x=2*(x - p.x))) for p in g.atoms(Point)] else: if not hasattr(g, 'reflect') and not all( isinstance(arg, Point) for arg in g.args): raise NotImplementedError( 'reflect undefined or non-Point args in %s' % g) a = atan(l.slope) c = l.coefficients d = -c[-1]/c[1] # y-intercept # apply the transform to a single point x, y = Dummy(), Dummy() xf = Point(x, y) xf = xf.translate(y=-d).rotate(-a, o).scale(y=-1 ).rotate(a, o).translate(y=d) # replace every point using that transform reps = [(p, xf.xreplace({x: p.x, y: p.y})) for p in g.atoms(Point)] return g.xreplace(dict(reps)) def rotate(self, angle, pt=None): """Rotate ``angle`` radians counterclockwise about Point ``pt``. The default pt is the origin, Point(0, 0) See Also ======== scale, translate Examples ======== >>> from sympy import Point, RegularPolygon, Polygon, pi >>> t = Polygon(*RegularPolygon(Point(0, 0), 1, 3).vertices) >>> t # vertex on x axis Triangle(Point2D(1, 0), Point2D(-1/2, sqrt(3)/2), Point2D(-1/2, -sqrt(3)/2)) >>> t.rotate(pi/2) # vertex on y axis now Triangle(Point2D(0, 1), Point2D(-sqrt(3)/2, -1/2), Point2D(sqrt(3)/2, -1/2)) """ newargs = [] for a in self.args: if isinstance(a, GeometryEntity): newargs.append(a.rotate(angle, pt)) else: newargs.append(a) return type(self)(*newargs) def scale(self, x=1, y=1, pt=None): """Scale the object by multiplying the x,y-coordinates by x and y. If pt is given, the scaling is done relative to that point; the object is shifted by -pt, scaled, and shifted by pt. See Also ======== rotate, translate Examples ======== >>> from sympy import RegularPolygon, Point, Polygon >>> t = Polygon(*RegularPolygon(Point(0, 0), 1, 3).vertices) >>> t Triangle(Point2D(1, 0), Point2D(-1/2, sqrt(3)/2), Point2D(-1/2, -sqrt(3)/2)) >>> t.scale(2) Triangle(Point2D(2, 0), Point2D(-1, sqrt(3)/2), Point2D(-1, -sqrt(3)/2)) >>> t.scale(2, 2) Triangle(Point2D(2, 0), Point2D(-1, sqrt(3)), Point2D(-1, -sqrt(3))) """ from sympy.geometry.point import Point if pt: pt = Point(pt, dim=2) return self.translate(*(-pt).args).scale(x, y).translate(*pt.args) return type(self)(*[a.scale(x, y) for a in self.args]) # if this fails, override this class def translate(self, x=0, y=0): """Shift the object by adding to the x,y-coordinates the values x and y. See Also ======== rotate, scale Examples ======== >>> from sympy import RegularPolygon, Point, Polygon >>> t = Polygon(*RegularPolygon(Point(0, 0), 1, 3).vertices) >>> t Triangle(Point2D(1, 0), Point2D(-1/2, sqrt(3)/2), Point2D(-1/2, -sqrt(3)/2)) >>> t.translate(2) Triangle(Point2D(3, 0), Point2D(3/2, sqrt(3)/2), Point2D(3/2, -sqrt(3)/2)) >>> t.translate(2, 2) Triangle(Point2D(3, 2), Point2D(3/2, sqrt(3)/2 + 2), Point2D(3/2, 2 - sqrt(3)/2)) """ newargs = [] for a in self.args: if isinstance(a, GeometryEntity): newargs.append(a.translate(x, y)) else: newargs.append(a) return self.func(*newargs) def parameter_value(self, other, t): """Return the parameter corresponding to the given point. Evaluating an arbitrary point of the entity at this parameter value will return the given point. Examples ======== >>> from sympy import Line, Point >>> from sympy.abc import t >>> a = Point(0, 0) >>> b = Point(2, 2) >>> Line(a, b).parameter_value((1, 1), t) {t: 1/2} >>> Line(a, b).arbitrary_point(t).subs(_) Point2D(1, 1) """ from sympy.geometry.point import Point from sympy.core.symbol import Dummy from sympy.solvers.solvers import solve if not isinstance(other, GeometryEntity): other = Point(other, dim=self.ambient_dimension) if not isinstance(other, Point): raise ValueError("other must be a point") T = Dummy('t', real=True) sol = solve(self.arbitrary_point(T) - other, T, dict=True) if not sol: raise ValueError("Given point is not on %s" % func_name(self)) return {t: sol[0][T]} class GeometrySet(GeometryEntity, Set): """Parent class of all GeometryEntity that are also Sets (compatible with sympy.sets) """ def _contains(self, other): """sympy.sets uses the _contains method, so include it for compatibility.""" if isinstance(other, Set) and other.is_FiniteSet: return all(self.__contains__(i) for i in other) return self.__contains__(other) @dispatch(GeometrySet, Set) def union_sets(self, o): """ Returns the union of self and o for use with sympy.sets.Set, if possible. """ from sympy.sets import Union, FiniteSet # if its a FiniteSet, merge any points # we contain and return a union with the rest if o.is_FiniteSet: other_points = [p for p in o if not self._contains(p)] if len(other_points) == len(o): return None return Union(self, FiniteSet(*other_points)) if self._contains(o): return self return None @dispatch(GeometrySet, Set) def intersection_sets(self, o): """ Returns a sympy.sets.Set of intersection objects, if possible. """ from sympy.sets import Set, FiniteSet, Union from sympy.geometry import Point try: # if o is a FiniteSet, find the intersection directly # to avoid infinite recursion if o.is_FiniteSet: inter = FiniteSet(*(p for p in o if self.contains(p))) else: inter = self.intersection(o) except NotImplementedError: # sympy.sets.Set.reduce expects None if an object # doesn't know how to simplify return None # put the points in a FiniteSet points = FiniteSet(*[p for p in inter if isinstance(p, Point)]) non_points = [p for p in inter if not isinstance(p, Point)] return Union(*(non_points + [points])) def translate(x, y): """Return the matrix to translate a 2-D point by x and y.""" rv = eye(3) rv[2, 0] = x rv[2, 1] = y return rv def scale(x, y, pt=None): """Return the matrix to multiply a 2-D point's coordinates by x and y. If pt is given, the scaling is done relative to that point.""" rv = eye(3) rv[0, 0] = x rv[1, 1] = y if pt: from sympy.geometry.point import Point pt = Point(pt, dim=2) tr1 = translate(*(-pt).args) tr2 = translate(*pt.args) return tr1*rv*tr2 return rv def rotate(th): """Return the matrix to rotate a 2-D point about the origin by ``angle``. The angle is measured in radians. To Point a point about a point other then the origin, translate the Point, do the rotation, and translate it back: >>> from sympy.geometry.entity import rotate, translate >>> from sympy import Point, pi >>> rot_about_11 = translate(-1, -1)*rotate(pi/2)*translate(1, 1) >>> Point(1, 1).transform(rot_about_11) Point2D(1, 1) >>> Point(0, 0).transform(rot_about_11) Point2D(2, 0) """ s = sin(th) rv = eye(3)*cos(th) rv[0, 1] = s rv[1, 0] = -s rv[2, 2] = 1 return rv
e8888bd1e020362be4f55c9f767414c778dcd3945faf6110c7043dbfc3dc1376
"""Line-like geometrical entities. Contains ======== LinearEntity Line Ray Segment LinearEntity2D Line2D Ray2D Segment2D LinearEntity3D Line3D Ray3D Segment3D """ from __future__ import division, print_function from sympy import Expr from sympy.core import S, sympify from sympy.core.compatibility import ordered from sympy.core.numbers import Rational, oo from sympy.core.relational import Eq from sympy.core.symbol import _symbol, Dummy from sympy.functions.elementary.trigonometric import (_pi_coeff as pi_coeff, acos, tan, atan2) from sympy.functions.elementary.piecewise import Piecewise from sympy.logic.boolalg import And from sympy.simplify.simplify import simplify from sympy.geometry.exceptions import GeometryError from sympy.core.containers import Tuple from sympy.core.decorators import deprecated from sympy.sets import Intersection from sympy.matrices import Matrix from sympy.solvers.solveset import linear_coeffs from .entity import GeometryEntity, GeometrySet from .point import Point, Point3D from sympy.utilities.misc import Undecidable, filldedent from sympy.utilities.exceptions import SymPyDeprecationWarning class LinearEntity(GeometrySet): """A base class for all linear entities (Line, Ray and Segment) in n-dimensional Euclidean space. Attributes ========== ambient_dimension direction length p1 p2 points Notes ===== This is an abstract class and is not meant to be instantiated. See Also ======== sympy.geometry.entity.GeometryEntity """ def __new__(cls, p1, p2=None, **kwargs): p1, p2 = Point._normalize_dimension(p1, p2) if p1 == p2: # sometimes we return a single point if we are not given two unique # points. This is done in the specific subclass raise ValueError( "%s.__new__ requires two unique Points." % cls.__name__) if len(p1) != len(p2): raise ValueError( "%s.__new__ requires two Points of equal dimension." % cls.__name__) return GeometryEntity.__new__(cls, p1, p2, **kwargs) def __contains__(self, other): """Return a definitive answer or else raise an error if it cannot be determined that other is on the boundaries of self.""" result = self.contains(other) if result is not None: return result else: raise Undecidable( "can't decide whether '%s' contains '%s'" % (self, other)) def _span_test(self, other): """Test whether the point `other` lies in the positive span of `self`. A point x is 'in front' of a point y if x.dot(y) >= 0. Return -1 if `other` is behind `self.p1`, 0 if `other` is `self.p1` and and 1 if `other` is in front of `self.p1`.""" if self.p1 == other: return 0 rel_pos = other - self.p1 d = self.direction if d.dot(rel_pos) > 0: return 1 return -1 @property def ambient_dimension(self): """A property method that returns the dimension of LinearEntity object. Parameters ========== p1 : LinearEntity Returns ======= dimension : integer Examples ======== >>> from sympy import Point, Line >>> p1, p2 = Point(0, 0), Point(1, 1) >>> l1 = Line(p1, p2) >>> l1.ambient_dimension 2 >>> from sympy import Point, Line >>> p1, p2 = Point(0, 0, 0), Point(1, 1, 1) >>> l1 = Line(p1, p2) >>> l1.ambient_dimension 3 """ return len(self.p1) def angle_between(l1, l2): """Return the non-reflex angle formed by rays emanating from the origin with directions the same as the direction vectors of the linear entities. Parameters ========== l1 : LinearEntity l2 : LinearEntity Returns ======= angle : angle in radians Notes ===== From the dot product of vectors v1 and v2 it is known that: ``dot(v1, v2) = |v1|*|v2|*cos(A)`` where A is the angle formed between the two vectors. We can get the directional vectors of the two lines and readily find the angle between the two using the above formula. See Also ======== is_perpendicular, Ray2D.closing_angle Examples ======== >>> from sympy import Point, Line, pi >>> e = Line((0, 0), (1, 0)) >>> ne = Line((0, 0), (1, 1)) >>> sw = Line((1, 1), (0, 0)) >>> ne.angle_between(e) pi/4 >>> sw.angle_between(e) 3*pi/4 To obtain the non-obtuse angle at the intersection of lines, use the ``smallest_angle_between`` method: >>> sw.smallest_angle_between(e) pi/4 >>> from sympy import Point3D, Line3D >>> p1, p2, p3 = Point3D(0, 0, 0), Point3D(1, 1, 1), Point3D(-1, 2, 0) >>> l1, l2 = Line3D(p1, p2), Line3D(p2, p3) >>> l1.angle_between(l2) acos(-sqrt(2)/3) >>> l1.smallest_angle_between(l2) acos(sqrt(2)/3) """ if not isinstance(l1, LinearEntity) and not isinstance(l2, LinearEntity): raise TypeError('Must pass only LinearEntity objects') v1, v2 = l1.direction, l2.direction return acos(v1.dot(v2)/(abs(v1)*abs(v2))) def smallest_angle_between(l1, l2): """Return the smallest angle formed at the intersection of the lines containing the linear entities. Parameters ========== l1 : LinearEntity l2 : LinearEntity Returns ======= angle : angle in radians See Also ======== angle_between, is_perpendicular, Ray2D.closing_angle Examples ======== >>> from sympy import Point, Line, pi >>> p1, p2, p3 = Point(0, 0), Point(0, 4), Point(2, -2) >>> l1, l2 = Line(p1, p2), Line(p1, p3) >>> l1.smallest_angle_between(l2) pi/4 See Also ======== angle_between, Ray2D.closing_angle """ if not isinstance(l1, LinearEntity) and not isinstance(l2, LinearEntity): raise TypeError('Must pass only LinearEntity objects') v1, v2 = l1.direction, l2.direction return acos(abs(v1.dot(v2))/(abs(v1)*abs(v2))) def arbitrary_point(self, parameter='t'): """A parameterized point on the Line. Parameters ========== parameter : str, optional The name of the parameter which will be used for the parametric point. The default value is 't'. When this parameter is 0, the first point used to define the line will be returned, and when it is 1 the second point will be returned. Returns ======= point : Point Raises ====== ValueError When ``parameter`` already appears in the Line's definition. See Also ======== sympy.geometry.point.Point Examples ======== >>> from sympy import Point, Line >>> p1, p2 = Point(1, 0), Point(5, 3) >>> l1 = Line(p1, p2) >>> l1.arbitrary_point() Point2D(4*t + 1, 3*t) >>> from sympy import Point3D, Line3D >>> p1, p2 = Point3D(1, 0, 0), Point3D(5, 3, 1) >>> l1 = Line3D(p1, p2) >>> l1.arbitrary_point() Point3D(4*t + 1, 3*t, t) """ t = _symbol(parameter, real=True) if t.name in (f.name for f in self.free_symbols): raise ValueError(filldedent(''' Symbol %s already appears in object and cannot be used as a parameter. ''' % t.name)) # multiply on the right so the variable gets # combined with the coordinates of the point return self.p1 + (self.p2 - self.p1)*t @staticmethod def are_concurrent(*lines): """Is a sequence of linear entities concurrent? Two or more linear entities are concurrent if they all intersect at a single point. Parameters ========== lines : a sequence of linear entities. Returns ======= True : if the set of linear entities intersect in one point False : otherwise. See Also ======== sympy.geometry.util.intersection Examples ======== >>> from sympy import Point, Line, Line3D >>> p1, p2 = Point(0, 0), Point(3, 5) >>> p3, p4 = Point(-2, -2), Point(0, 2) >>> l1, l2, l3 = Line(p1, p2), Line(p1, p3), Line(p1, p4) >>> Line.are_concurrent(l1, l2, l3) True >>> l4 = Line(p2, p3) >>> Line.are_concurrent(l2, l3, l4) False >>> from sympy import Point3D, Line3D >>> p1, p2 = Point3D(0, 0, 0), Point3D(3, 5, 2) >>> p3, p4 = Point3D(-2, -2, -2), Point3D(0, 2, 1) >>> l1, l2, l3 = Line3D(p1, p2), Line3D(p1, p3), Line3D(p1, p4) >>> Line3D.are_concurrent(l1, l2, l3) True >>> l4 = Line3D(p2, p3) >>> Line3D.are_concurrent(l2, l3, l4) False """ common_points = Intersection(*lines) if common_points.is_FiniteSet and len(common_points) == 1: return True return False def contains(self, other): """Subclasses should implement this method and should return True if other is on the boundaries of self; False if not on the boundaries of self; None if a determination cannot be made.""" raise NotImplementedError() @property def direction(self): """The direction vector of the LinearEntity. Returns ======= p : a Point; the ray from the origin to this point is the direction of `self` Examples ======== >>> from sympy.geometry import Line >>> a, b = (1, 1), (1, 3) >>> Line(a, b).direction Point2D(0, 2) >>> Line(b, a).direction Point2D(0, -2) This can be reported so the distance from the origin is 1: >>> Line(b, a).direction.unit Point2D(0, -1) See Also ======== sympy.geometry.point.Point.unit """ return self.p2 - self.p1 def intersection(self, other): """The intersection with another geometrical entity. Parameters ========== o : Point or LinearEntity Returns ======= intersection : list of geometrical entities See Also ======== sympy.geometry.point.Point Examples ======== >>> from sympy import Point, Line, Segment >>> p1, p2, p3 = Point(0, 0), Point(1, 1), Point(7, 7) >>> l1 = Line(p1, p2) >>> l1.intersection(p3) [Point2D(7, 7)] >>> p4, p5 = Point(5, 0), Point(0, 3) >>> l2 = Line(p4, p5) >>> l1.intersection(l2) [Point2D(15/8, 15/8)] >>> p6, p7 = Point(0, 5), Point(2, 6) >>> s1 = Segment(p6, p7) >>> l1.intersection(s1) [] >>> from sympy import Point3D, Line3D, Segment3D >>> p1, p2, p3 = Point3D(0, 0, 0), Point3D(1, 1, 1), Point3D(7, 7, 7) >>> l1 = Line3D(p1, p2) >>> l1.intersection(p3) [Point3D(7, 7, 7)] >>> l1 = Line3D(Point3D(4,19,12), Point3D(5,25,17)) >>> l2 = Line3D(Point3D(-3, -15, -19), direction_ratio=[2,8,8]) >>> l1.intersection(l2) [Point3D(1, 1, -3)] >>> p6, p7 = Point3D(0, 5, 2), Point3D(2, 6, 3) >>> s1 = Segment3D(p6, p7) >>> l1.intersection(s1) [] """ def intersect_parallel_rays(ray1, ray2): if ray1.direction.dot(ray2.direction) > 0: # rays point in the same direction # so return the one that is "in front" return [ray2] if ray1._span_test(ray2.p1) >= 0 else [ray1] else: # rays point in opposite directions st = ray1._span_test(ray2.p1) if st < 0: return [] elif st == 0: return [ray2.p1] return [Segment(ray1.p1, ray2.p1)] def intersect_parallel_ray_and_segment(ray, seg): st1, st2 = ray._span_test(seg.p1), ray._span_test(seg.p2) if st1 < 0 and st2 < 0: return [] elif st1 >= 0 and st2 >= 0: return [seg] elif st1 >= 0: # st2 < 0: return [Segment(ray.p1, seg.p1)] elif st2 > 0: # st1 <= 0 return [Segment(ray.p1, seg.p2)] def intersect_parallel_segments(seg1, seg2): if seg1.contains(seg2): return [seg2] if seg2.contains(seg1): return [seg1] # direct the segments so they're oriented the same way if seg1.direction.dot(seg2.direction) < 0: seg2 = Segment(seg2.p2, seg2.p1) # order the segments so seg1 is "behind" seg2 if seg1._span_test(seg2.p1) < 0: seg1, seg2 = seg2, seg1 if seg2._span_test(seg1.p2) < 0: return [] return [Segment(seg2.p1, seg1.p2)] if not isinstance(other, GeometryEntity): other = Point(other, dim=self.ambient_dimension) if other.is_Point: if self.contains(other): return [other] else: return [] elif isinstance(other, LinearEntity): # break into cases based on whether # the lines are parallel, non-parallel intersecting, or skew pts = Point._normalize_dimension(self.p1, self.p2, other.p1, other.p2) rank = Point.affine_rank(*pts) if rank == 1: # we're collinear if isinstance(self, Line): return [other] if isinstance(other, Line): return [self] if isinstance(self, Ray) and isinstance(other, Ray): return intersect_parallel_rays(self, other) if isinstance(self, Ray) and isinstance(other, Segment): return intersect_parallel_ray_and_segment(self, other) if isinstance(self, Segment) and isinstance(other, Ray): return intersect_parallel_ray_and_segment(other, self) if isinstance(self, Segment) and isinstance(other, Segment): return intersect_parallel_segments(self, other) elif rank == 2: # we're in the same plane l1 = Line(*pts[:2]) l2 = Line(*pts[2:]) # check to see if we're parallel. If we are, we can't # be intersecting, since the collinear case was already # handled if l1.direction.is_scalar_multiple(l2.direction): return [] # find the intersection as if everything were lines # by solving the equation t*d + p1 == s*d' + p1' m = Matrix([l1.direction, -l2.direction]).transpose() v = Matrix([l2.p1 - l1.p1]).transpose() # we cannot use m.solve(v) because that only works for square matrices m_rref, pivots = m.col_insert(2, v).rref(simplify=True) # rank == 2 ensures we have 2 pivots, but let's check anyway if len(pivots) != 2: raise GeometryError("Failed when solving Mx=b when M={} and b={}".format(m, v)) coeff = m_rref[0, 2] line_intersection = l1.direction*coeff + self.p1 # if we're both lines, we can skip a containment check if isinstance(self, Line) and isinstance(other, Line): return [line_intersection] if self.contains(line_intersection) and other.contains(line_intersection): return [line_intersection] return [] else: # we're skew return [] return other.intersection(self) def is_parallel(l1, l2): """Are two linear entities parallel? Parameters ========== l1 : LinearEntity l2 : LinearEntity Returns ======= True : if l1 and l2 are parallel, False : otherwise. See Also ======== coefficients Examples ======== >>> from sympy import Point, Line >>> p1, p2 = Point(0, 0), Point(1, 1) >>> p3, p4 = Point(3, 4), Point(6, 7) >>> l1, l2 = Line(p1, p2), Line(p3, p4) >>> Line.is_parallel(l1, l2) True >>> p5 = Point(6, 6) >>> l3 = Line(p3, p5) >>> Line.is_parallel(l1, l3) False >>> from sympy import Point3D, Line3D >>> p1, p2 = Point3D(0, 0, 0), Point3D(3, 4, 5) >>> p3, p4 = Point3D(2, 1, 1), Point3D(8, 9, 11) >>> l1, l2 = Line3D(p1, p2), Line3D(p3, p4) >>> Line3D.is_parallel(l1, l2) True >>> p5 = Point3D(6, 6, 6) >>> l3 = Line3D(p3, p5) >>> Line3D.is_parallel(l1, l3) False """ if not isinstance(l1, LinearEntity) and not isinstance(l2, LinearEntity): raise TypeError('Must pass only LinearEntity objects') return l1.direction.is_scalar_multiple(l2.direction) def is_perpendicular(l1, l2): """Are two linear entities perpendicular? Parameters ========== l1 : LinearEntity l2 : LinearEntity Returns ======= True : if l1 and l2 are perpendicular, False : otherwise. See Also ======== coefficients Examples ======== >>> from sympy import Point, Line >>> p1, p2, p3 = Point(0, 0), Point(1, 1), Point(-1, 1) >>> l1, l2 = Line(p1, p2), Line(p1, p3) >>> l1.is_perpendicular(l2) True >>> p4 = Point(5, 3) >>> l3 = Line(p1, p4) >>> l1.is_perpendicular(l3) False >>> from sympy import Point3D, Line3D >>> p1, p2, p3 = Point3D(0, 0, 0), Point3D(1, 1, 1), Point3D(-1, 2, 0) >>> l1, l2 = Line3D(p1, p2), Line3D(p2, p3) >>> l1.is_perpendicular(l2) False >>> p4 = Point3D(5, 3, 7) >>> l3 = Line3D(p1, p4) >>> l1.is_perpendicular(l3) False """ if not isinstance(l1, LinearEntity) and not isinstance(l2, LinearEntity): raise TypeError('Must pass only LinearEntity objects') return S.Zero.equals(l1.direction.dot(l2.direction)) def is_similar(self, other): """ Return True if self and other are contained in the same line. Examples ======== >>> from sympy import Point, Line >>> p1, p2, p3 = Point(0, 1), Point(3, 4), Point(2, 3) >>> l1 = Line(p1, p2) >>> l2 = Line(p1, p3) >>> l1.is_similar(l2) True """ l = Line(self.p1, self.p2) return l.contains(other) @property def length(self): """ The length of the line. Examples ======== >>> from sympy import Point, Line >>> p1, p2 = Point(0, 0), Point(3, 5) >>> l1 = Line(p1, p2) >>> l1.length oo """ return S.Infinity @property def p1(self): """The first defining point of a linear entity. See Also ======== sympy.geometry.point.Point Examples ======== >>> from sympy import Point, Line >>> p1, p2 = Point(0, 0), Point(5, 3) >>> l = Line(p1, p2) >>> l.p1 Point2D(0, 0) """ return self.args[0] @property def p2(self): """The second defining point of a linear entity. See Also ======== sympy.geometry.point.Point Examples ======== >>> from sympy import Point, Line >>> p1, p2 = Point(0, 0), Point(5, 3) >>> l = Line(p1, p2) >>> l.p2 Point2D(5, 3) """ return self.args[1] def parallel_line(self, p): """Create a new Line parallel to this linear entity which passes through the point `p`. Parameters ========== p : Point Returns ======= line : Line See Also ======== is_parallel Examples ======== >>> from sympy import Point, Line >>> p1, p2, p3 = Point(0, 0), Point(2, 3), Point(-2, 2) >>> l1 = Line(p1, p2) >>> l2 = l1.parallel_line(p3) >>> p3 in l2 True >>> l1.is_parallel(l2) True >>> from sympy import Point3D, Line3D >>> p1, p2, p3 = Point3D(0, 0, 0), Point3D(2, 3, 4), Point3D(-2, 2, 0) >>> l1 = Line3D(p1, p2) >>> l2 = l1.parallel_line(p3) >>> p3 in l2 True >>> l1.is_parallel(l2) True """ p = Point(p, dim=self.ambient_dimension) return Line(p, p + self.direction) def perpendicular_line(self, p): """Create a new Line perpendicular to this linear entity which passes through the point `p`. Parameters ========== p : Point Returns ======= line : Line See Also ======== is_perpendicular, perpendicular_segment Examples ======== >>> from sympy import Point, Line >>> p1, p2, p3 = Point(0, 0), Point(2, 3), Point(-2, 2) >>> l1 = Line(p1, p2) >>> l2 = l1.perpendicular_line(p3) >>> p3 in l2 True >>> l1.is_perpendicular(l2) True >>> from sympy import Point3D, Line3D >>> p1, p2, p3 = Point3D(0, 0, 0), Point3D(2, 3, 4), Point3D(-2, 2, 0) >>> l1 = Line3D(p1, p2) >>> l2 = l1.perpendicular_line(p3) >>> p3 in l2 True >>> l1.is_perpendicular(l2) True """ p = Point(p, dim=self.ambient_dimension) if p in self: p = p + self.direction.orthogonal_direction return Line(p, self.projection(p)) def perpendicular_segment(self, p): """Create a perpendicular line segment from `p` to this line. The enpoints of the segment are ``p`` and the closest point in the line containing self. (If self is not a line, the point might not be in self.) Parameters ========== p : Point Returns ======= segment : Segment Notes ===== Returns `p` itself if `p` is on this linear entity. See Also ======== perpendicular_line Examples ======== >>> from sympy import Point, Line >>> p1, p2, p3 = Point(0, 0), Point(1, 1), Point(0, 2) >>> l1 = Line(p1, p2) >>> s1 = l1.perpendicular_segment(p3) >>> l1.is_perpendicular(s1) True >>> p3 in s1 True >>> l1.perpendicular_segment(Point(4, 0)) Segment2D(Point2D(4, 0), Point2D(2, 2)) >>> from sympy import Point3D, Line3D >>> p1, p2, p3 = Point3D(0, 0, 0), Point3D(1, 1, 1), Point3D(0, 2, 0) >>> l1 = Line3D(p1, p2) >>> s1 = l1.perpendicular_segment(p3) >>> l1.is_perpendicular(s1) True >>> p3 in s1 True >>> l1.perpendicular_segment(Point3D(4, 0, 0)) Segment3D(Point3D(4, 0, 0), Point3D(4/3, 4/3, 4/3)) """ p = Point(p, dim=self.ambient_dimension) if p in self: return p l = self.perpendicular_line(p) # The intersection should be unique, so unpack the singleton p2, = Intersection(Line(self.p1, self.p2), l) return Segment(p, p2) @property def points(self): """The two points used to define this linear entity. Returns ======= points : tuple of Points See Also ======== sympy.geometry.point.Point Examples ======== >>> from sympy import Point, Line >>> p1, p2 = Point(0, 0), Point(5, 11) >>> l1 = Line(p1, p2) >>> l1.points (Point2D(0, 0), Point2D(5, 11)) """ return (self.p1, self.p2) def projection(self, other): """Project a point, line, ray, or segment onto this linear entity. Parameters ========== other : Point or LinearEntity (Line, Ray, Segment) Returns ======= projection : Point or LinearEntity (Line, Ray, Segment) The return type matches the type of the parameter ``other``. Raises ====== GeometryError When method is unable to perform projection. Notes ===== A projection involves taking the two points that define the linear entity and projecting those points onto a Line and then reforming the linear entity using these projections. A point P is projected onto a line L by finding the point on L that is closest to P. This point is the intersection of L and the line perpendicular to L that passes through P. See Also ======== sympy.geometry.point.Point, perpendicular_line Examples ======== >>> from sympy import Point, Line, Segment, Rational >>> p1, p2, p3 = Point(0, 0), Point(1, 1), Point(Rational(1, 2), 0) >>> l1 = Line(p1, p2) >>> l1.projection(p3) Point2D(1/4, 1/4) >>> p4, p5 = Point(10, 0), Point(12, 1) >>> s1 = Segment(p4, p5) >>> l1.projection(s1) Segment2D(Point2D(5, 5), Point2D(13/2, 13/2)) >>> p1, p2, p3 = Point(0, 0, 1), Point(1, 1, 2), Point(2, 0, 1) >>> l1 = Line(p1, p2) >>> l1.projection(p3) Point3D(2/3, 2/3, 5/3) >>> p4, p5 = Point(10, 0, 1), Point(12, 1, 3) >>> s1 = Segment(p4, p5) >>> l1.projection(s1) Segment3D(Point3D(10/3, 10/3, 13/3), Point3D(5, 5, 6)) """ if not isinstance(other, GeometryEntity): other = Point(other, dim=self.ambient_dimension) def proj_point(p): return Point.project(p - self.p1, self.direction) + self.p1 if isinstance(other, Point): return proj_point(other) elif isinstance(other, LinearEntity): p1, p2 = proj_point(other.p1), proj_point(other.p2) # test to see if we're degenerate if p1 == p2: return p1 projected = other.__class__(p1, p2) projected = Intersection(self, projected) # if we happen to have intersected in only a point, return that if projected.is_FiniteSet and len(projected) == 1: # projected is a set of size 1, so unpack it in `a` a, = projected return a # order args so projection is in the same direction as self if self.direction.dot(projected.direction) < 0: p1, p2 = projected.args projected = projected.func(p2, p1) return projected raise GeometryError( "Do not know how to project %s onto %s" % (other, self)) def random_point(self, seed=None): """A random point on a LinearEntity. Returns ======= point : Point See Also ======== sympy.geometry.point.Point Examples ======== >>> from sympy import Point, Line, Ray, Segment >>> p1, p2 = Point(0, 0), Point(5, 3) >>> line = Line(p1, p2) >>> r = line.random_point(seed=42) # seed value is optional >>> r.n(3) Point2D(-0.72, -0.432) >>> r in line True >>> Ray(p1, p2).random_point(seed=42).n(3) Point2D(0.72, 0.432) >>> Segment(p1, p2).random_point(seed=42).n(3) Point2D(3.2, 1.92) """ import random if seed is not None: rng = random.Random(seed) else: rng = random t = Dummy() pt = self.arbitrary_point(t) if isinstance(self, Ray): v = abs(rng.gauss(0, 1)) elif isinstance(self, Segment): v = rng.random() elif isinstance(self, Line): v = rng.gauss(0, 1) else: raise NotImplementedError('unhandled line type') return pt.subs(t, Rational(v)) class Line(LinearEntity): """An infinite line in space. A 2D line is declared with two distinct points, point and slope, or an equation. A 3D line may be defined with a point and a direction ratio. Parameters ========== p1 : Point p2 : Point slope : sympy expression direction_ratio : list equation : equation of a line Notes ===== `Line` will automatically subclass to `Line2D` or `Line3D` based on the dimension of `p1`. The `slope` argument is only relevant for `Line2D` and the `direction_ratio` argument is only relevant for `Line3D`. See Also ======== sympy.geometry.point.Point sympy.geometry.line.Line2D sympy.geometry.line.Line3D Examples ======== >>> from sympy import Point, Eq >>> from sympy.geometry import Line, Segment >>> from sympy.abc import x, y, a, b >>> L = Line(Point(2,3), Point(3,5)) >>> L Line2D(Point2D(2, 3), Point2D(3, 5)) >>> L.points (Point2D(2, 3), Point2D(3, 5)) >>> L.equation() -2*x + y + 1 >>> L.coefficients (-2, 1, 1) Instantiate with keyword ``slope``: >>> Line(Point(0, 0), slope=0) Line2D(Point2D(0, 0), Point2D(1, 0)) Instantiate with another linear object >>> s = Segment((0, 0), (0, 1)) >>> Line(s).equation() x The line corresponding to an equation in the for `ax + by + c = 0`, can be entered: >>> Line(3*x + y + 18) Line2D(Point2D(0, -18), Point2D(1, -21)) If `x` or `y` has a different name, then they can be specified, too, as a string (to match the name) or symbol: >>> Line(Eq(3*a + b, -18), x='a', y=b) Line2D(Point2D(0, -18), Point2D(1, -21)) """ def __new__(cls, *args, **kwargs): from sympy.geometry.util import find if len(args) == 1 and isinstance(args[0], Expr): x = kwargs.get('x', 'x') y = kwargs.get('y', 'y') equation = args[0] if isinstance(equation, Eq): equation = equation.lhs - equation.rhs xin, yin = x, y x = find(x, equation) or Dummy() y = find(y, equation) or Dummy() a, b, c = linear_coeffs(equation, x, y) if b: return Line((0, -c/b), slope=-a/b) if a: return Line((-c/a, 0), slope=oo) raise ValueError('neither %s nor %s were found in the equation' % (xin, yin)) else: if len(args) > 0: p1 = args[0] if len(args) > 1: p2 = args[1] else: p2=None if isinstance(p1, LinearEntity): if p2: raise ValueError('If p1 is a LinearEntity, p2 must be None.') dim = len(p1.p1) else: p1 = Point(p1) dim = len(p1) if p2 is not None or isinstance(p2, Point) and p2.ambient_dimension != dim: p2 = Point(p2) if dim == 2: return Line2D(p1, p2, **kwargs) elif dim == 3: return Line3D(p1, p2, **kwargs) return LinearEntity.__new__(cls, p1, p2, **kwargs) def contains(self, other): """ Return True if `other` is on this Line, or False otherwise. Examples ======== >>> from sympy import Line,Point >>> p1, p2 = Point(0, 1), Point(3, 4) >>> l = Line(p1, p2) >>> l.contains(p1) True >>> l.contains((0, 1)) True >>> l.contains((0, 0)) False >>> a = (0, 0, 0) >>> b = (1, 1, 1) >>> c = (2, 2, 2) >>> l1 = Line(a, b) >>> l2 = Line(b, a) >>> l1 == l2 False >>> l1 in l2 True """ if not isinstance(other, GeometryEntity): other = Point(other, dim=self.ambient_dimension) if isinstance(other, Point): return Point.is_collinear(other, self.p1, self.p2) if isinstance(other, LinearEntity): return Point.is_collinear(self.p1, self.p2, other.p1, other.p2) return False def distance(self, other): """ Finds the shortest distance between a line and a point. Raises ====== NotImplementedError is raised if `other` is not a Point Examples ======== >>> from sympy import Point, Line >>> p1, p2 = Point(0, 0), Point(1, 1) >>> s = Line(p1, p2) >>> s.distance(Point(-1, 1)) sqrt(2) >>> s.distance((-1, 2)) 3*sqrt(2)/2 >>> p1, p2 = Point(0, 0, 0), Point(1, 1, 1) >>> s = Line(p1, p2) >>> s.distance(Point(-1, 1, 1)) 2*sqrt(6)/3 >>> s.distance((-1, 1, 1)) 2*sqrt(6)/3 """ if not isinstance(other, GeometryEntity): other = Point(other, dim=self.ambient_dimension) if self.contains(other): return S.Zero return self.perpendicular_segment(other).length @deprecated(useinstead="equals", issue=12860, deprecated_since_version="1.0") def equal(self, other): return self.equals(other) def equals(self, other): """Returns True if self and other are the same mathematical entities""" if not isinstance(other, Line): return False return Point.is_collinear(self.p1, other.p1, self.p2, other.p2) def plot_interval(self, parameter='t'): """The plot interval for the default geometric plot of line. Gives values that will produce a line that is +/- 5 units long (where a unit is the distance between the two points that define the line). Parameters ========== parameter : str, optional Default value is 't'. Returns ======= plot_interval : list (plot interval) [parameter, lower_bound, upper_bound] Examples ======== >>> from sympy import Point, Line >>> p1, p2 = Point(0, 0), Point(5, 3) >>> l1 = Line(p1, p2) >>> l1.plot_interval() [t, -5, 5] """ t = _symbol(parameter, real=True) return [t, -5, 5] class Ray(LinearEntity): """A Ray is a semi-line in the space with a source point and a direction. Parameters ========== p1 : Point The source of the Ray p2 : Point or radian value This point determines the direction in which the Ray propagates. If given as an angle it is interpreted in radians with the positive direction being ccw. Attributes ========== source See Also ======== sympy.geometry.line.Ray2D sympy.geometry.line.Ray3D sympy.geometry.point.Point sympy.geometry.line.Line Notes ===== `Ray` will automatically subclass to `Ray2D` or `Ray3D` based on the dimension of `p1`. Examples ======== >>> from sympy import Point, pi >>> from sympy.geometry import Ray >>> r = Ray(Point(2, 3), Point(3, 5)) >>> r Ray2D(Point2D(2, 3), Point2D(3, 5)) >>> r.points (Point2D(2, 3), Point2D(3, 5)) >>> r.source Point2D(2, 3) >>> r.xdirection oo >>> r.ydirection oo >>> r.slope 2 >>> Ray(Point(0, 0), angle=pi/4).slope 1 """ def __new__(cls, p1, p2=None, **kwargs): p1 = Point(p1) if p2 is not None: p1, p2 = Point._normalize_dimension(p1, Point(p2)) dim = len(p1) if dim == 2: return Ray2D(p1, p2, **kwargs) elif dim == 3: return Ray3D(p1, p2, **kwargs) return LinearEntity.__new__(cls, p1, *pts, **kwargs) def _svg(self, scale_factor=1., fill_color="#66cc99"): """Returns SVG path element for the LinearEntity. Parameters ========== scale_factor : float Multiplication factor for the SVG stroke-width. Default is 1. fill_color : str, optional Hex string for fill color. Default is "#66cc99". """ from sympy.core.evalf import N verts = (N(self.p1), N(self.p2)) coords = ["{0},{1}".format(p.x, p.y) for p in verts] path = "M {0} L {1}".format(coords[0], " L ".join(coords[1:])) return ( '<path fill-rule="evenodd" fill="{2}" stroke="#555555" ' 'stroke-width="{0}" opacity="0.6" d="{1}" ' 'marker-start="url(#markerCircle)" marker-end="url(#markerArrow)"/>' ).format(2. * scale_factor, path, fill_color) def contains(self, other): """ Is other GeometryEntity contained in this Ray? Examples ======== >>> from sympy import Ray,Point,Segment >>> p1, p2 = Point(0, 0), Point(4, 4) >>> r = Ray(p1, p2) >>> r.contains(p1) True >>> r.contains((1, 1)) True >>> r.contains((1, 3)) False >>> s = Segment((1, 1), (2, 2)) >>> r.contains(s) True >>> s = Segment((1, 2), (2, 5)) >>> r.contains(s) False >>> r1 = Ray((2, 2), (3, 3)) >>> r.contains(r1) True >>> r1 = Ray((2, 2), (3, 5)) >>> r.contains(r1) False """ if not isinstance(other, GeometryEntity): other = Point(other, dim=self.ambient_dimension) if isinstance(other, Point): if Point.is_collinear(self.p1, self.p2, other): # if we're in the direction of the ray, our # direction vector dot the ray's direction vector # should be non-negative return bool((self.p2 - self.p1).dot(other - self.p1) >= S.Zero) return False elif isinstance(other, Ray): if Point.is_collinear(self.p1, self.p2, other.p1, other.p2): return bool((self.p2 - self.p1).dot(other.p2 - other.p1) > S.Zero) return False elif isinstance(other, Segment): return other.p1 in self and other.p2 in self # No other known entity can be contained in a Ray return False def distance(self, other): """ Finds the shortest distance between the ray and a point. Raises ====== NotImplementedError is raised if `other` is not a Point Examples ======== >>> from sympy import Point, Ray >>> p1, p2 = Point(0, 0), Point(1, 1) >>> s = Ray(p1, p2) >>> s.distance(Point(-1, -1)) sqrt(2) >>> s.distance((-1, 2)) 3*sqrt(2)/2 >>> p1, p2 = Point(0, 0, 0), Point(1, 1, 2) >>> s = Ray(p1, p2) >>> s Ray3D(Point3D(0, 0, 0), Point3D(1, 1, 2)) >>> s.distance(Point(-1, -1, 2)) 4*sqrt(3)/3 >>> s.distance((-1, -1, 2)) 4*sqrt(3)/3 """ if not isinstance(other, GeometryEntity): other = Point(other, dim=self.ambient_dimension) if self.contains(other): return S.Zero proj = Line(self.p1, self.p2).projection(other) if self.contains(proj): return abs(other - proj) else: return abs(other - self.source) def equals(self, other): """Returns True if self and other are the same mathematical entities""" if not isinstance(other, Ray): return False return self.source == other.source and other.p2 in self def plot_interval(self, parameter='t'): """The plot interval for the default geometric plot of the Ray. Gives values that will produce a ray that is 10 units long (where a unit is the distance between the two points that define the ray). Parameters ========== parameter : str, optional Default value is 't'. Returns ======= plot_interval : list [parameter, lower_bound, upper_bound] Examples ======== >>> from sympy import Ray, pi >>> r = Ray((0, 0), angle=pi/4) >>> r.plot_interval() [t, 0, 10] """ t = _symbol(parameter, real=True) return [t, 0, 10] @property def source(self): """The point from which the ray emanates. See Also ======== sympy.geometry.point.Point Examples ======== >>> from sympy import Point, Ray >>> p1, p2 = Point(0, 0), Point(4, 1) >>> r1 = Ray(p1, p2) >>> r1.source Point2D(0, 0) >>> p1, p2 = Point(0, 0, 0), Point(4, 1, 5) >>> r1 = Ray(p2, p1) >>> r1.source Point3D(4, 1, 5) """ return self.p1 class Segment(LinearEntity): """A line segment in space. Parameters ========== p1 : Point p2 : Point Attributes ========== length : number or sympy expression midpoint : Point See Also ======== sympy.geometry.line.Segment2D sympy.geometry.line.Segment3D sympy.geometry.point.Point sympy.geometry.line.Line Notes ===== If 2D or 3D points are used to define `Segment`, it will be automatically subclassed to `Segment2D` or `Segment3D`. Examples ======== >>> from sympy import Point >>> from sympy.geometry import Segment >>> Segment((1, 0), (1, 1)) # tuples are interpreted as pts Segment2D(Point2D(1, 0), Point2D(1, 1)) >>> s = Segment(Point(4, 3), Point(1, 1)) >>> s.points (Point2D(4, 3), Point2D(1, 1)) >>> s.slope 2/3 >>> s.length sqrt(13) >>> s.midpoint Point2D(5/2, 2) >>> Segment((1, 0, 0), (1, 1, 1)) # tuples are interpreted as pts Segment3D(Point3D(1, 0, 0), Point3D(1, 1, 1)) >>> s = Segment(Point(4, 3, 9), Point(1, 1, 7)); s Segment3D(Point3D(4, 3, 9), Point3D(1, 1, 7)) >>> s.points (Point3D(4, 3, 9), Point3D(1, 1, 7)) >>> s.length sqrt(17) >>> s.midpoint Point3D(5/2, 2, 8) """ def __new__(cls, p1, p2, **kwargs): p1, p2 = Point._normalize_dimension(Point(p1), Point(p2)) dim = len(p1) if dim == 2: return Segment2D(p1, p2, **kwargs) elif dim == 3: return Segment3D(p1, p2, **kwargs) return LinearEntity.__new__(cls, p1, p2, **kwargs) def contains(self, other): """ Is the other GeometryEntity contained within this Segment? Examples ======== >>> from sympy import Point, Segment >>> p1, p2 = Point(0, 1), Point(3, 4) >>> s = Segment(p1, p2) >>> s2 = Segment(p2, p1) >>> s.contains(s2) True >>> from sympy import Point3D, Segment3D >>> p1, p2 = Point3D(0, 1, 1), Point3D(3, 4, 5) >>> s = Segment3D(p1, p2) >>> s2 = Segment3D(p2, p1) >>> s.contains(s2) True >>> s.contains((p1 + p2) / 2) True """ if not isinstance(other, GeometryEntity): other = Point(other, dim=self.ambient_dimension) if isinstance(other, Point): if Point.is_collinear(other, self.p1, self.p2): d1, d2 = other - self.p1, other - self.p2 d = self.p2 - self.p1 # without the call to simplify, sympy cannot tell that an expression # like (a+b)*(a/2+b/2) is always non-negative. If it cannot be # determined, raise an Undecidable error try: # the triangle inequality says that |d1|+|d2| >= |d| and is strict # only if other lies in the line segment return bool(simplify(Eq(abs(d1) + abs(d2) - abs(d), 0))) except TypeError: raise Undecidable("Cannot determine if {} is in {}".format(other, self)) if isinstance(other, Segment): return other.p1 in self and other.p2 in self return False def equals(self, other): """Returns True if self and other are the same mathematical entities""" return isinstance(other, self.func) and list( ordered(self.args)) == list(ordered(other.args)) def distance(self, other): """ Finds the shortest distance between a line segment and a point. Raises ====== NotImplementedError is raised if `other` is not a Point Examples ======== >>> from sympy import Point, Segment >>> p1, p2 = Point(0, 1), Point(3, 4) >>> s = Segment(p1, p2) >>> s.distance(Point(10, 15)) sqrt(170) >>> s.distance((0, 12)) sqrt(73) >>> from sympy import Point3D, Segment3D >>> p1, p2 = Point3D(0, 0, 3), Point3D(1, 1, 4) >>> s = Segment3D(p1, p2) >>> s.distance(Point3D(10, 15, 12)) sqrt(341) >>> s.distance((10, 15, 12)) sqrt(341) """ if not isinstance(other, GeometryEntity): other = Point(other, dim=self.ambient_dimension) if isinstance(other, Point): vp1 = other - self.p1 vp2 = other - self.p2 dot_prod_sign_1 = self.direction.dot(vp1) >= 0 dot_prod_sign_2 = self.direction.dot(vp2) <= 0 if dot_prod_sign_1 and dot_prod_sign_2: return Line(self.p1, self.p2).distance(other) if dot_prod_sign_1 and not dot_prod_sign_2: return abs(vp2) if not dot_prod_sign_1 and dot_prod_sign_2: return abs(vp1) raise NotImplementedError() @property def length(self): """The length of the line segment. See Also ======== sympy.geometry.point.Point.distance Examples ======== >>> from sympy import Point, Segment >>> p1, p2 = Point(0, 0), Point(4, 3) >>> s1 = Segment(p1, p2) >>> s1.length 5 >>> from sympy import Point3D, Segment3D >>> p1, p2 = Point3D(0, 0, 0), Point3D(4, 3, 3) >>> s1 = Segment3D(p1, p2) >>> s1.length sqrt(34) """ return Point.distance(self.p1, self.p2) @property def midpoint(self): """The midpoint of the line segment. See Also ======== sympy.geometry.point.Point.midpoint Examples ======== >>> from sympy import Point, Segment >>> p1, p2 = Point(0, 0), Point(4, 3) >>> s1 = Segment(p1, p2) >>> s1.midpoint Point2D(2, 3/2) >>> from sympy import Point3D, Segment3D >>> p1, p2 = Point3D(0, 0, 0), Point3D(4, 3, 3) >>> s1 = Segment3D(p1, p2) >>> s1.midpoint Point3D(2, 3/2, 3/2) """ return Point.midpoint(self.p1, self.p2) def perpendicular_bisector(self, p=None): """The perpendicular bisector of this segment. If no point is specified or the point specified is not on the bisector then the bisector is returned as a Line. Otherwise a Segment is returned that joins the point specified and the intersection of the bisector and the segment. Parameters ========== p : Point Returns ======= bisector : Line or Segment See Also ======== LinearEntity.perpendicular_segment Examples ======== >>> from sympy import Point, Segment >>> p1, p2, p3 = Point(0, 0), Point(6, 6), Point(5, 1) >>> s1 = Segment(p1, p2) >>> s1.perpendicular_bisector() Line2D(Point2D(3, 3), Point2D(-3, 9)) >>> s1.perpendicular_bisector(p3) Segment2D(Point2D(5, 1), Point2D(3, 3)) """ l = self.perpendicular_line(self.midpoint) if p is not None: p2 = Point(p, dim=self.ambient_dimension) if p2 in l: return Segment(p2, self.midpoint) return l def plot_interval(self, parameter='t'): """The plot interval for the default geometric plot of the Segment gives values that will produce the full segment in a plot. Parameters ========== parameter : str, optional Default value is 't'. Returns ======= plot_interval : list [parameter, lower_bound, upper_bound] Examples ======== >>> from sympy import Point, Segment >>> p1, p2 = Point(0, 0), Point(5, 3) >>> s1 = Segment(p1, p2) >>> s1.plot_interval() [t, 0, 1] """ t = _symbol(parameter, real=True) return [t, 0, 1] class LinearEntity2D(LinearEntity): """A base class for all linear entities (line, ray and segment) in a 2-dimensional Euclidean space. Attributes ========== p1 p2 coefficients slope points Notes ===== This is an abstract class and is not meant to be instantiated. See Also ======== sympy.geometry.entity.GeometryEntity """ @property def bounds(self): """Return a tuple (xmin, ymin, xmax, ymax) representing the bounding rectangle for the geometric figure. """ verts = self.points xs = [p.x for p in verts] ys = [p.y for p in verts] return (min(xs), min(ys), max(xs), max(ys)) def perpendicular_line(self, p): """Create a new Line perpendicular to this linear entity which passes through the point `p`. Parameters ========== p : Point Returns ======= line : Line See Also ======== is_perpendicular, perpendicular_segment Examples ======== >>> from sympy import Point, Line >>> p1, p2, p3 = Point(0, 0), Point(2, 3), Point(-2, 2) >>> l1 = Line(p1, p2) >>> l2 = l1.perpendicular_line(p3) >>> p3 in l2 True >>> l1.is_perpendicular(l2) True """ p = Point(p, dim=self.ambient_dimension) # any two lines in R^2 intersect, so blindly making # a line through p in an orthogonal direction will work return Line(p, p + self.direction.orthogonal_direction) @property def slope(self): """The slope of this linear entity, or infinity if vertical. Returns ======= slope : number or sympy expression See Also ======== coefficients Examples ======== >>> from sympy import Point, Line >>> p1, p2 = Point(0, 0), Point(3, 5) >>> l1 = Line(p1, p2) >>> l1.slope 5/3 >>> p3 = Point(0, 4) >>> l2 = Line(p1, p3) >>> l2.slope oo """ d1, d2 = (self.p1 - self.p2).args if d1 == 0: return S.Infinity return simplify(d2/d1) class Line2D(LinearEntity2D, Line): """An infinite line in space 2D. A line is declared with two distinct points or a point and slope as defined using keyword `slope`. Parameters ========== p1 : Point pt : Point slope : sympy expression See Also ======== sympy.geometry.point.Point Examples ======== >>> from sympy import Point >>> from sympy.abc import L >>> from sympy.geometry import Line, Segment >>> L = Line(Point(2,3), Point(3,5)) >>> L Line2D(Point2D(2, 3), Point2D(3, 5)) >>> L.points (Point2D(2, 3), Point2D(3, 5)) >>> L.equation() -2*x + y + 1 >>> L.coefficients (-2, 1, 1) Instantiate with keyword ``slope``: >>> Line(Point(0, 0), slope=0) Line2D(Point2D(0, 0), Point2D(1, 0)) Instantiate with another linear object >>> s = Segment((0, 0), (0, 1)) >>> Line(s).equation() x """ def __new__(cls, p1, pt=None, slope=None, **kwargs): if isinstance(p1, LinearEntity): if pt is not None: raise ValueError('When p1 is a LinearEntity, pt should be None') p1, pt = Point._normalize_dimension(*p1.args, dim=2) else: p1 = Point(p1, dim=2) if pt is not None and slope is None: try: p2 = Point(pt, dim=2) except (NotImplementedError, TypeError, ValueError): raise ValueError(filldedent(''' The 2nd argument was not a valid Point. If it was a slope, enter it with keyword "slope". ''')) elif slope is not None and pt is None: slope = sympify(slope) if slope.is_finite is False: # when infinite slope, don't change x dx = 0 dy = 1 else: # go over 1 up slope dx = 1 dy = slope # XXX avoiding simplification by adding to coords directly p2 = Point(p1.x + dx, p1.y + dy, evaluate=False) else: raise ValueError('A 2nd Point or keyword "slope" must be used.') return LinearEntity2D.__new__(cls, p1, p2, **kwargs) def _svg(self, scale_factor=1., fill_color="#66cc99"): """Returns SVG path element for the LinearEntity. Parameters ========== scale_factor : float Multiplication factor for the SVG stroke-width. Default is 1. fill_color : str, optional Hex string for fill color. Default is "#66cc99". """ from sympy.core.evalf import N verts = (N(self.p1), N(self.p2)) coords = ["{0},{1}".format(p.x, p.y) for p in verts] path = "M {0} L {1}".format(coords[0], " L ".join(coords[1:])) return ( '<path fill-rule="evenodd" fill="{2}" stroke="#555555" ' 'stroke-width="{0}" opacity="0.6" d="{1}" ' 'marker-start="url(#markerReverseArrow)" marker-end="url(#markerArrow)"/>' ).format(2. * scale_factor, path, fill_color) @property def coefficients(self): """The coefficients (`a`, `b`, `c`) for `ax + by + c = 0`. See Also ======== sympy.geometry.line.Line.equation Examples ======== >>> from sympy import Point, Line >>> from sympy.abc import x, y >>> p1, p2 = Point(0, 0), Point(5, 3) >>> l = Line(p1, p2) >>> l.coefficients (-3, 5, 0) >>> p3 = Point(x, y) >>> l2 = Line(p1, p3) >>> l2.coefficients (-y, x, 0) """ p1, p2 = self.points if p1.x == p2.x: return (S.One, S.Zero, -p1.x) elif p1.y == p2.y: return (S.Zero, S.One, -p1.y) return tuple([simplify(i) for i in (self.p1.y - self.p2.y, self.p2.x - self.p1.x, self.p1.x*self.p2.y - self.p1.y*self.p2.x)]) def equation(self, x='x', y='y'): """The equation of the line: ax + by + c. Parameters ========== x : str, optional The name to use for the x-axis, default value is 'x'. y : str, optional The name to use for the y-axis, default value is 'y'. Returns ======= equation : sympy expression See Also ======== LinearEntity.coefficients Examples ======== >>> from sympy import Point, Line >>> p1, p2 = Point(1, 0), Point(5, 3) >>> l1 = Line(p1, p2) >>> l1.equation() -3*x + 4*y + 3 """ x = _symbol(x, real=True) y = _symbol(y, real=True) p1, p2 = self.points if p1.x == p2.x: return x - p1.x elif p1.y == p2.y: return y - p1.y a, b, c = self.coefficients return a*x + b*y + c class Ray2D(LinearEntity2D, Ray): """ A Ray is a semi-line in the space with a source point and a direction. Parameters ========== p1 : Point The source of the Ray p2 : Point or radian value This point determines the direction in which the Ray propagates. If given as an angle it is interpreted in radians with the positive direction being ccw. Attributes ========== source xdirection ydirection See Also ======== sympy.geometry.point.Point, Line Examples ======== >>> from sympy import Point, pi >>> from sympy.geometry import Ray >>> r = Ray(Point(2, 3), Point(3, 5)) >>> r Ray2D(Point2D(2, 3), Point2D(3, 5)) >>> r.points (Point2D(2, 3), Point2D(3, 5)) >>> r.source Point2D(2, 3) >>> r.xdirection oo >>> r.ydirection oo >>> r.slope 2 >>> Ray(Point(0, 0), angle=pi/4).slope 1 """ def __new__(cls, p1, pt=None, angle=None, **kwargs): p1 = Point(p1, dim=2) if pt is not None and angle is None: try: p2 = Point(pt, dim=2) except (NotImplementedError, TypeError, ValueError): from sympy.utilities.misc import filldedent raise ValueError(filldedent(''' The 2nd argument was not a valid Point; if it was meant to be an angle it should be given with keyword "angle".''')) if p1 == p2: raise ValueError('A Ray requires two distinct points.') elif angle is not None and pt is None: # we need to know if the angle is an odd multiple of pi/2 c = pi_coeff(sympify(angle)) p2 = None if c is not None: if c.is_Rational: if c.q == 2: if c.p == 1: p2 = p1 + Point(0, 1) elif c.p == 3: p2 = p1 + Point(0, -1) elif c.q == 1: if c.p == 0: p2 = p1 + Point(1, 0) elif c.p == 1: p2 = p1 + Point(-1, 0) if p2 is None: c *= S.Pi else: c = angle % (2*S.Pi) if not p2: m = 2*c/S.Pi left = And(1 < m, m < 3) # is it in quadrant 2 or 3? x = Piecewise((-1, left), (Piecewise((0, Eq(m % 1, 0)), (1, True)), True)) y = Piecewise((-tan(c), left), (Piecewise((1, Eq(m, 1)), (-1, Eq(m, 3)), (tan(c), True)), True)) p2 = p1 + Point(x, y) else: raise ValueError('A 2nd point or keyword "angle" must be used.') return LinearEntity2D.__new__(cls, p1, p2, **kwargs) @property def xdirection(self): """The x direction of the ray. Positive infinity if the ray points in the positive x direction, negative infinity if the ray points in the negative x direction, or 0 if the ray is vertical. See Also ======== ydirection Examples ======== >>> from sympy import Point, Ray >>> p1, p2, p3 = Point(0, 0), Point(1, 1), Point(0, -1) >>> r1, r2 = Ray(p1, p2), Ray(p1, p3) >>> r1.xdirection oo >>> r2.xdirection 0 """ if self.p1.x < self.p2.x: return S.Infinity elif self.p1.x == self.p2.x: return S.Zero else: return S.NegativeInfinity @property def ydirection(self): """The y direction of the ray. Positive infinity if the ray points in the positive y direction, negative infinity if the ray points in the negative y direction, or 0 if the ray is horizontal. See Also ======== xdirection Examples ======== >>> from sympy import Point, Ray >>> p1, p2, p3 = Point(0, 0), Point(-1, -1), Point(-1, 0) >>> r1, r2 = Ray(p1, p2), Ray(p1, p3) >>> r1.ydirection -oo >>> r2.ydirection 0 """ if self.p1.y < self.p2.y: return S.Infinity elif self.p1.y == self.p2.y: return S.Zero else: return S.NegativeInfinity def closing_angle(r1, r2): """Return the angle by which r2 must be rotated so it faces the same direction as r1. Parameters ========== r1 : Ray2D r2 : Ray2D Returns ======= angle : angle in radians (ccw angle is positive) See Also ======== LinearEntity.angle_between Examples ======== >>> from sympy import Ray, pi >>> r1 = Ray((0, 0), (1, 0)) >>> r2 = r1.rotate(-pi/2) >>> angle = r1.closing_angle(r2); angle pi/2 >>> r2.rotate(angle).direction.unit == r1.direction.unit True >>> r2.closing_angle(r1) -pi/2 """ if not all(isinstance(r, Ray2D) for r in (r1, r2)): # although the direction property is defined for # all linear entities, only the Ray is truly a # directed object raise TypeError('Both arguments must be Ray2D objects.') a1 = atan2(*list(reversed(r1.direction.args))) a2 = atan2(*list(reversed(r2.direction.args))) if a1*a2 < 0: a1 = 2*S.Pi + a1 if a1 < 0 else a1 a2 = 2*S.Pi + a2 if a2 < 0 else a2 return a1 - a2 class Segment2D(LinearEntity2D, Segment): """A line segment in 2D space. Parameters ========== p1 : Point p2 : Point Attributes ========== length : number or sympy expression midpoint : Point See Also ======== sympy.geometry.point.Point, Line Examples ======== >>> from sympy import Point >>> from sympy.geometry import Segment >>> Segment((1, 0), (1, 1)) # tuples are interpreted as pts Segment2D(Point2D(1, 0), Point2D(1, 1)) >>> s = Segment(Point(4, 3), Point(1, 1)); s Segment2D(Point2D(4, 3), Point2D(1, 1)) >>> s.points (Point2D(4, 3), Point2D(1, 1)) >>> s.slope 2/3 >>> s.length sqrt(13) >>> s.midpoint Point2D(5/2, 2) """ def __new__(cls, p1, p2, **kwargs): p1 = Point(p1, dim=2) p2 = Point(p2, dim=2) if p1 == p2: return p1 return LinearEntity2D.__new__(cls, p1, p2, **kwargs) def _svg(self, scale_factor=1., fill_color="#66cc99"): """Returns SVG path element for the LinearEntity. Parameters ========== scale_factor : float Multiplication factor for the SVG stroke-width. Default is 1. fill_color : str, optional Hex string for fill color. Default is "#66cc99". """ from sympy.core.evalf import N verts = (N(self.p1), N(self.p2)) coords = ["{0},{1}".format(p.x, p.y) for p in verts] path = "M {0} L {1}".format(coords[0], " L ".join(coords[1:])) return ( '<path fill-rule="evenodd" fill="{2}" stroke="#555555" ' 'stroke-width="{0}" opacity="0.6" d="{1}" />' ).format(2. * scale_factor, path, fill_color) class LinearEntity3D(LinearEntity): """An base class for all linear entities (line, ray and segment) in a 3-dimensional Euclidean space. Attributes ========== p1 p2 direction_ratio direction_cosine points Notes ===== This is a base class and is not meant to be instantiated. """ def __new__(cls, p1, p2, **kwargs): p1 = Point3D(p1, dim=3) p2 = Point3D(p2, dim=3) if p1 == p2: # if it makes sense to return a Point, handle in subclass raise ValueError( "%s.__new__ requires two unique Points." % cls.__name__) return GeometryEntity.__new__(cls, p1, p2, **kwargs) ambient_dimension = 3 @property def direction_ratio(self): """The direction ratio of a given line in 3D. See Also ======== sympy.geometry.line.Line.equation Examples ======== >>> from sympy import Point3D, Line3D >>> p1, p2 = Point3D(0, 0, 0), Point3D(5, 3, 1) >>> l = Line3D(p1, p2) >>> l.direction_ratio [5, 3, 1] """ p1, p2 = self.points return p1.direction_ratio(p2) @property def direction_cosine(self): """The normalized direction ratio of a given line in 3D. See Also ======== sympy.geometry.line.Line.equation Examples ======== >>> from sympy import Point3D, Line3D >>> p1, p2 = Point3D(0, 0, 0), Point3D(5, 3, 1) >>> l = Line3D(p1, p2) >>> l.direction_cosine [sqrt(35)/7, 3*sqrt(35)/35, sqrt(35)/35] >>> sum(i**2 for i in _) 1 """ p1, p2 = self.points return p1.direction_cosine(p2) class Line3D(LinearEntity3D, Line): """An infinite 3D line in space. A line is declared with two distinct points or a point and direction_ratio as defined using keyword `direction_ratio`. Parameters ========== p1 : Point3D pt : Point3D direction_ratio : list See Also ======== sympy.geometry.point.Point3D sympy.geometry.line.Line sympy.geometry.line.Line2D Examples ======== >>> from sympy import Point3D >>> from sympy.geometry import Line3D, Segment3D >>> L = Line3D(Point3D(2, 3, 4), Point3D(3, 5, 1)) >>> L Line3D(Point3D(2, 3, 4), Point3D(3, 5, 1)) >>> L.points (Point3D(2, 3, 4), Point3D(3, 5, 1)) """ def __new__(cls, p1, pt=None, direction_ratio=[], **kwargs): if isinstance(p1, LinearEntity3D): if pt is not None: raise ValueError('if p1 is a LinearEntity, pt must be None.') p1, pt = p1.args else: p1 = Point(p1, dim=3) if pt is not None and len(direction_ratio) == 0: pt = Point(pt, dim=3) elif len(direction_ratio) == 3 and pt is None: pt = Point3D(p1.x + direction_ratio[0], p1.y + direction_ratio[1], p1.z + direction_ratio[2]) else: raise ValueError('A 2nd Point or keyword "direction_ratio" must ' 'be used.') return LinearEntity3D.__new__(cls, p1, pt, **kwargs) def equation(self, x='x', y='y', z='z', k=None): """Return the equations that define the line in 3D. Parameters ========== x : str, optional The name to use for the x-axis, default value is 'x'. y : str, optional The name to use for the y-axis, default value is 'y'. z : str, optional The name to use for the z-axis, default value is 'z'. Returns ======= equation : Tuple of simultaneous equations Examples ======== >>> from sympy import Point3D, Line3D, solve >>> from sympy.abc import x, y, z >>> p1, p2 = Point3D(1, 0, 0), Point3D(5, 3, 0) >>> l1 = Line3D(p1, p2) >>> eq = l1.equation(x, y, z); eq (-3*x + 4*y + 3, z) >>> solve(eq.subs(z, 0), (x, y, z)) {x: 4*y/3 + 1} """ if k is not None: SymPyDeprecationWarning( feature="equation() no longer needs 'k'", issue=13742, deprecated_since_version="1.2").warn() from sympy import solve x, y, z, k = [_symbol(i, real=True) for i in (x, y, z, 'k')] p1, p2 = self.points d1, d2, d3 = p1.direction_ratio(p2) x1, y1, z1 = p1 v = (x, y, z) eqs = [-d1*k + x - x1, -d2*k + y - y1, -d3*k + z - z1] # eliminate k from equations by solving first eq with k for k for i, e in enumerate(eqs): if e.has(k): kk = solve(eqs[i], k)[0] eqs.pop(i) break return Tuple(*[i.subs(k, kk).as_numer_denom()[0] for i in eqs]) class Ray3D(LinearEntity3D, Ray): """ A Ray is a semi-line in the space with a source point and a direction. Parameters ========== p1 : Point3D The source of the Ray p2 : Point or a direction vector direction_ratio: Determines the direction in which the Ray propagates. Attributes ========== source xdirection ydirection zdirection See Also ======== sympy.geometry.point.Point3D, Line3D Examples ======== >>> from sympy import Point3D >>> from sympy.geometry import Ray3D >>> r = Ray3D(Point3D(2, 3, 4), Point3D(3, 5, 0)) >>> r Ray3D(Point3D(2, 3, 4), Point3D(3, 5, 0)) >>> r.points (Point3D(2, 3, 4), Point3D(3, 5, 0)) >>> r.source Point3D(2, 3, 4) >>> r.xdirection oo >>> r.ydirection oo >>> r.direction_ratio [1, 2, -4] """ def __new__(cls, p1, pt=None, direction_ratio=[], **kwargs): from sympy.utilities.misc import filldedent if isinstance(p1, LinearEntity3D): if pt is not None: raise ValueError('If p1 is a LinearEntity, pt must be None') p1, pt = p1.args else: p1 = Point(p1, dim=3) if pt is not None and len(direction_ratio) == 0: pt = Point(pt, dim=3) elif len(direction_ratio) == 3 and pt is None: pt = Point3D(p1.x + direction_ratio[0], p1.y + direction_ratio[1], p1.z + direction_ratio[2]) else: raise ValueError(filldedent(''' A 2nd Point or keyword "direction_ratio" must be used. ''')) return LinearEntity3D.__new__(cls, p1, pt, **kwargs) @property def xdirection(self): """The x direction of the ray. Positive infinity if the ray points in the positive x direction, negative infinity if the ray points in the negative x direction, or 0 if the ray is vertical. See Also ======== ydirection Examples ======== >>> from sympy import Point3D, Ray3D >>> p1, p2, p3 = Point3D(0, 0, 0), Point3D(1, 1, 1), Point3D(0, -1, 0) >>> r1, r2 = Ray3D(p1, p2), Ray3D(p1, p3) >>> r1.xdirection oo >>> r2.xdirection 0 """ if self.p1.x < self.p2.x: return S.Infinity elif self.p1.x == self.p2.x: return S.Zero else: return S.NegativeInfinity @property def ydirection(self): """The y direction of the ray. Positive infinity if the ray points in the positive y direction, negative infinity if the ray points in the negative y direction, or 0 if the ray is horizontal. See Also ======== xdirection Examples ======== >>> from sympy import Point3D, Ray3D >>> p1, p2, p3 = Point3D(0, 0, 0), Point3D(-1, -1, -1), Point3D(-1, 0, 0) >>> r1, r2 = Ray3D(p1, p2), Ray3D(p1, p3) >>> r1.ydirection -oo >>> r2.ydirection 0 """ if self.p1.y < self.p2.y: return S.Infinity elif self.p1.y == self.p2.y: return S.Zero else: return S.NegativeInfinity @property def zdirection(self): """The z direction of the ray. Positive infinity if the ray points in the positive z direction, negative infinity if the ray points in the negative z direction, or 0 if the ray is horizontal. See Also ======== xdirection Examples ======== >>> from sympy import Point3D, Ray3D >>> p1, p2, p3 = Point3D(0, 0, 0), Point3D(-1, -1, -1), Point3D(-1, 0, 0) >>> r1, r2 = Ray3D(p1, p2), Ray3D(p1, p3) >>> r1.ydirection -oo >>> r2.ydirection 0 >>> r2.zdirection 0 """ if self.p1.z < self.p2.z: return S.Infinity elif self.p1.z == self.p2.z: return S.Zero else: return S.NegativeInfinity class Segment3D(LinearEntity3D, Segment): """A line segment in a 3D space. Parameters ========== p1 : Point3D p2 : Point3D Attributes ========== length : number or sympy expression midpoint : Point3D See Also ======== sympy.geometry.point.Point3D, Line3D Examples ======== >>> from sympy import Point3D >>> from sympy.geometry import Segment3D >>> Segment3D((1, 0, 0), (1, 1, 1)) # tuples are interpreted as pts Segment3D(Point3D(1, 0, 0), Point3D(1, 1, 1)) >>> s = Segment3D(Point3D(4, 3, 9), Point3D(1, 1, 7)); s Segment3D(Point3D(4, 3, 9), Point3D(1, 1, 7)) >>> s.points (Point3D(4, 3, 9), Point3D(1, 1, 7)) >>> s.length sqrt(17) >>> s.midpoint Point3D(5/2, 2, 8) """ def __new__(cls, p1, p2, **kwargs): p1 = Point(p1, dim=3) p2 = Point(p2, dim=3) if p1 == p2: return p1 return LinearEntity3D.__new__(cls, p1, p2, **kwargs)
981f100245118b1e78e42e2945ff56f145a85847fa73fc3ca3073f3db14b4c8b
from __future__ import division, print_function from sympy.core import Expr, S, Symbol, oo, pi, sympify from sympy.core.compatibility import as_int, range, ordered from sympy.core.symbol import _symbol, Dummy from sympy.functions.elementary.complexes import sign from sympy.functions.elementary.piecewise import Piecewise from sympy.functions.elementary.trigonometric import cos, sin, tan from sympy.geometry.exceptions import GeometryError from sympy.logic import And from sympy.matrices import Matrix from sympy.simplify import simplify from sympy.utilities import default_sort_key from sympy.utilities.iterables import has_dups, has_variety, uniq, rotate_left, least_rotation from sympy.utilities.misc import func_name from .entity import GeometryEntity, GeometrySet from .point import Point from .ellipse import Circle from .line import Line, Segment, Ray from sympy import sqrt import warnings class Polygon(GeometrySet): """A two-dimensional polygon. A simple polygon in space. Can be constructed from a sequence of points or from a center, radius, number of sides and rotation angle. Parameters ========== vertices : sequence of Points Attributes ========== area angles perimeter vertices centroid sides Raises ====== GeometryError If all parameters are not Points. See Also ======== sympy.geometry.point.Point, sympy.geometry.line.Segment, Triangle Notes ===== Polygons are treated as closed paths rather than 2D areas so some calculations can be be negative or positive (e.g., area) based on the orientation of the points. Any consecutive identical points are reduced to a single point and any points collinear and between two points will be removed unless they are needed to define an explicit intersection (see examples). A Triangle, Segment or Point will be returned when there are 3 or fewer points provided. Examples ======== >>> from sympy import Point, Polygon, pi >>> p1, p2, p3, p4, p5 = [(0, 0), (1, 0), (5, 1), (0, 1), (3, 0)] >>> Polygon(p1, p2, p3, p4) Polygon(Point2D(0, 0), Point2D(1, 0), Point2D(5, 1), Point2D(0, 1)) >>> Polygon(p1, p2) Segment2D(Point2D(0, 0), Point2D(1, 0)) >>> Polygon(p1, p2, p5) Segment2D(Point2D(0, 0), Point2D(3, 0)) The area of a polygon is calculated as positive when vertices are traversed in a ccw direction. When the sides of a polygon cross the area will have positive and negative contributions. The following defines a Z shape where the bottom right connects back to the top left. >>> Polygon((0, 2), (2, 2), (0, 0), (2, 0)).area 0 When the the keyword `n` is used to define the number of sides of the Polygon then a RegularPolygon is created and the other arguments are interpreted as center, radius and rotation. The unrotated RegularPolygon will always have a vertex at Point(r, 0) where `r` is the radius of the circle that circumscribes the RegularPolygon. Its method `spin` can be used to increment that angle. >>> p = Polygon((0,0), 1, n=3) >>> p RegularPolygon(Point2D(0, 0), 1, 3, 0) >>> p.vertices[0] Point2D(1, 0) >>> p.args[0] Point2D(0, 0) >>> p.spin(pi/2) >>> p.vertices[0] Point2D(0, 1) """ def __new__(cls, *args, **kwargs): if kwargs.get('n', 0): n = kwargs.pop('n') args = list(args) # return a virtual polygon with n sides if len(args) == 2: # center, radius args.append(n) elif len(args) == 3: # center, radius, rotation args.insert(2, n) return RegularPolygon(*args, **kwargs) vertices = [Point(a, dim=2, **kwargs) for a in args] # remove consecutive duplicates nodup = [] for p in vertices: if nodup and p == nodup[-1]: continue nodup.append(p) if len(nodup) > 1 and nodup[-1] == nodup[0]: nodup.pop() # last point was same as first # remove collinear points i = -3 while i < len(nodup) - 3 and len(nodup) > 2: a, b, c = nodup[i], nodup[i + 1], nodup[i + 2] if Point.is_collinear(a, b, c): nodup.pop(i + 1) if a == c: nodup.pop(i) else: i += 1 vertices = list(nodup) if len(vertices) > 3: return GeometryEntity.__new__(cls, *vertices, **kwargs) elif len(vertices) == 3: return Triangle(*vertices, **kwargs) elif len(vertices) == 2: return Segment(*vertices, **kwargs) else: return Point(*vertices, **kwargs) @property def area(self): """ The area of the polygon. Notes ===== The area calculation can be positive or negative based on the orientation of the points. If any side of the polygon crosses any other side, there will be areas having opposite signs. See Also ======== sympy.geometry.ellipse.Ellipse.area Examples ======== >>> from sympy import Point, Polygon >>> p1, p2, p3, p4 = map(Point, [(0, 0), (1, 0), (5, 1), (0, 1)]) >>> poly = Polygon(p1, p2, p3, p4) >>> poly.area 3 In the Z shaped polygon (with the lower right connecting back to the upper left) the areas cancel out: >>> Z = Polygon((0, 1), (1, 1), (0, 0), (1, 0)) >>> Z.area 0 In the M shaped polygon, areas do not cancel because no side crosses any other (though there is a point of contact). >>> M = Polygon((0, 0), (0, 1), (2, 0), (3, 1), (3, 0)) >>> M.area -3/2 """ area = 0 args = self.args for i in range(len(args)): x1, y1 = args[i - 1].args x2, y2 = args[i].args area += x1*y2 - x2*y1 return simplify(area) / 2 @staticmethod def _isright(a, b, c): """Return True/False for cw/ccw orientation. Examples ======== >>> from sympy import Point, Polygon >>> a, b, c = [Point(i) for i in [(0, 0), (1, 1), (1, 0)]] >>> Polygon._isright(a, b, c) True >>> Polygon._isright(a, c, b) False """ ba = b - a ca = c - a t_area = simplify(ba.x*ca.y - ca.x*ba.y) res = t_area.is_nonpositive if res is None: raise ValueError("Can't determine orientation") return res @property def angles(self): """The internal angle at each vertex. Returns ======= angles : dict A dictionary where each key is a vertex and each value is the internal angle at that vertex. The vertices are represented as Points. See Also ======== sympy.geometry.point.Point, sympy.geometry.line.LinearEntity.angle_between Examples ======== >>> from sympy import Point, Polygon >>> p1, p2, p3, p4 = map(Point, [(0, 0), (1, 0), (5, 1), (0, 1)]) >>> poly = Polygon(p1, p2, p3, p4) >>> poly.angles[p1] pi/2 >>> poly.angles[p2] acos(-4*sqrt(17)/17) """ # Determine orientation of points args = self.vertices cw = self._isright(args[-1], args[0], args[1]) ret = {} for i in range(len(args)): a, b, c = args[i - 2], args[i - 1], args[i] ang = Ray(b, a).angle_between(Ray(b, c)) if cw ^ self._isright(a, b, c): ret[b] = 2*S.Pi - ang else: ret[b] = ang return ret @property def ambient_dimension(self): return self.vertices[0].ambient_dimension @property def perimeter(self): """The perimeter of the polygon. Returns ======= perimeter : number or Basic instance See Also ======== sympy.geometry.line.Segment.length Examples ======== >>> from sympy import Point, Polygon >>> p1, p2, p3, p4 = map(Point, [(0, 0), (1, 0), (5, 1), (0, 1)]) >>> poly = Polygon(p1, p2, p3, p4) >>> poly.perimeter sqrt(17) + 7 """ p = 0 args = self.vertices for i in range(len(args)): p += args[i - 1].distance(args[i]) return simplify(p) @property def vertices(self): """The vertices of the polygon. Returns ======= vertices : list of Points Notes ===== When iterating over the vertices, it is more efficient to index self rather than to request the vertices and index them. Only use the vertices when you want to process all of them at once. This is even more important with RegularPolygons that calculate each vertex. See Also ======== sympy.geometry.point.Point Examples ======== >>> from sympy import Point, Polygon >>> p1, p2, p3, p4 = map(Point, [(0, 0), (1, 0), (5, 1), (0, 1)]) >>> poly = Polygon(p1, p2, p3, p4) >>> poly.vertices [Point2D(0, 0), Point2D(1, 0), Point2D(5, 1), Point2D(0, 1)] >>> poly.vertices[0] Point2D(0, 0) """ return list(self.args) @property def centroid(self): """The centroid of the polygon. Returns ======= centroid : Point See Also ======== sympy.geometry.point.Point, sympy.geometry.util.centroid Examples ======== >>> from sympy import Point, Polygon >>> p1, p2, p3, p4 = map(Point, [(0, 0), (1, 0), (5, 1), (0, 1)]) >>> poly = Polygon(p1, p2, p3, p4) >>> poly.centroid Point2D(31/18, 11/18) """ A = 1/(6*self.area) cx, cy = 0, 0 args = self.args for i in range(len(args)): x1, y1 = args[i - 1].args x2, y2 = args[i].args v = x1*y2 - x2*y1 cx += v*(x1 + x2) cy += v*(y1 + y2) return Point(simplify(A*cx), simplify(A*cy)) def second_moment_of_area(self, point=None): """Returns the second moment and product moment of area of a two dimensional polygon. Parameters ========== point : Point, two-tuple of sympifiable objects, or None(default=None) point is the point about which second moment of area is to be found. If "point=None" it will be calculated about the axis passing through the centroid of the polygon. Returns ======= I_xx, I_yy, I_xy : number or sympy expression I_xx, I_yy are second moment of area of a two dimensional polygon. I_xy is product moment of area of a two dimensional polygon. Examples ======== >>> from sympy import Point, Polygon, symbols >>> a, b = symbols('a, b') >>> p1, p2, p3, p4, p5 = [(0, 0), (a, 0), (a, b), (0, b), (a/3, b/3)] >>> rectangle = Polygon(p1, p2, p3, p4) >>> rectangle.second_moment_of_area() (a*b**3/12, a**3*b/12, 0) >>> rectangle.second_moment_of_area(p5) (a*b**3/9, a**3*b/9, a**2*b**2/36) References ========== https://en.wikipedia.org/wiki/Second_moment_of_area """ I_xx, I_yy, I_xy = 0, 0, 0 args = self.args for i in range(len(args)): x1, y1 = args[i-1].args x2, y2 = args[i].args v = x1*y2 - x2*y1 I_xx += (y1**2 + y1*y2 + y2**2)*v I_yy += (x1**2 + x1*x2 + x2**2)*v I_xy += (x1*y2 + 2*x1*y1 + 2*x2*y2 + x2*y1)*v A = self.area c_x = self.centroid[0] c_y = self.centroid[1] # parallel axis theorem I_xx_c = (I_xx/12) - (A*(c_y**2)) I_yy_c = (I_yy/12) - (A*(c_x**2)) I_xy_c = (I_xy/24) - (A*(c_x*c_y)) if point is None: return I_xx_c, I_yy_c, I_xy_c I_xx = (I_xx_c + A*((point[1]-c_y)**2)) I_yy = (I_yy_c + A*((point[0]-c_x)**2)) I_xy = (I_xy_c + A*((point[0]-c_x)*(point[1]-c_y))) return I_xx, I_yy, I_xy @property def sides(self): """The directed line segments that form the sides of the polygon. Returns ======= sides : list of sides Each side is a directed Segment. See Also ======== sympy.geometry.point.Point, sympy.geometry.line.Segment Examples ======== >>> from sympy import Point, Polygon >>> p1, p2, p3, p4 = map(Point, [(0, 0), (1, 0), (5, 1), (0, 1)]) >>> poly = Polygon(p1, p2, p3, p4) >>> poly.sides [Segment2D(Point2D(0, 0), Point2D(1, 0)), Segment2D(Point2D(1, 0), Point2D(5, 1)), Segment2D(Point2D(5, 1), Point2D(0, 1)), Segment2D(Point2D(0, 1), Point2D(0, 0))] """ res = [] args = self.vertices for i in range(-len(args), 0): res.append(Segment(args[i], args[i + 1])) return res @property def bounds(self): """Return a tuple (xmin, ymin, xmax, ymax) representing the bounding rectangle for the geometric figure. """ verts = self.vertices xs = [p.x for p in verts] ys = [p.y for p in verts] return (min(xs), min(ys), max(xs), max(ys)) def is_convex(self): """Is the polygon convex? A polygon is convex if all its interior angles are less than 180 degrees and there are no intersections between sides. Returns ======= is_convex : boolean True if this polygon is convex, False otherwise. See Also ======== sympy.geometry.util.convex_hull Examples ======== >>> from sympy import Point, Polygon >>> p1, p2, p3, p4 = map(Point, [(0, 0), (1, 0), (5, 1), (0, 1)]) >>> poly = Polygon(p1, p2, p3, p4) >>> poly.is_convex() True """ # Determine orientation of points args = self.vertices cw = self._isright(args[-2], args[-1], args[0]) for i in range(1, len(args)): if cw ^ self._isright(args[i - 2], args[i - 1], args[i]): return False # check for intersecting sides sides = self.sides for i, si in enumerate(sides): pts = si.args # exclude the sides connected to si for j in range(1 if i == len(sides) - 1 else 0, i - 1): sj = sides[j] if sj.p1 not in pts and sj.p2 not in pts: hit = si.intersection(sj) if hit: return False return True def encloses_point(self, p): """ Return True if p is enclosed by (is inside of) self. Notes ===== Being on the border of self is considered False. Parameters ========== p : Point Returns ======= encloses_point : True, False or None See Also ======== sympy.geometry.point.Point, sympy.geometry.ellipse.Ellipse.encloses_point Examples ======== >>> from sympy import Polygon, Point >>> from sympy.abc import t >>> p = Polygon((0, 0), (4, 0), (4, 4)) >>> p.encloses_point(Point(2, 1)) True >>> p.encloses_point(Point(2, 2)) False >>> p.encloses_point(Point(5, 5)) False References ========== [1] http://paulbourke.net/geometry/polygonmesh/#insidepoly """ p = Point(p, dim=2) if p in self.vertices or any(p in s for s in self.sides): return False # move to p, checking that the result is numeric lit = [] for v in self.vertices: lit.append(v - p) # the difference is simplified if lit[-1].free_symbols: return None poly = Polygon(*lit) # polygon closure is assumed in the following test but Polygon removes duplicate pts so # the last point has to be added so all sides are computed. Using Polygon.sides is # not good since Segments are unordered. args = poly.args indices = list(range(-len(args), 1)) if poly.is_convex(): orientation = None for i in indices: a = args[i] b = args[i + 1] test = ((-a.y)*(b.x - a.x) - (-a.x)*(b.y - a.y)).is_negative if orientation is None: orientation = test elif test is not orientation: return False return True hit_odd = False p1x, p1y = args[0].args for i in indices[1:]: p2x, p2y = args[i].args if 0 > min(p1y, p2y): if 0 <= max(p1y, p2y): if 0 <= max(p1x, p2x): if p1y != p2y: xinters = (-p1y)*(p2x - p1x)/(p2y - p1y) + p1x if p1x == p2x or 0 <= xinters: hit_odd = not hit_odd p1x, p1y = p2x, p2y return hit_odd def arbitrary_point(self, parameter='t'): """A parameterized point on the polygon. The parameter, varying from 0 to 1, assigns points to the position on the perimeter that is that fraction of the total perimeter. So the point evaluated at t=1/2 would return the point from the first vertex that is 1/2 way around the polygon. Parameters ========== parameter : str, optional Default value is 't'. Returns ======= arbitrary_point : Point Raises ====== ValueError When `parameter` already appears in the Polygon's definition. See Also ======== sympy.geometry.point.Point Examples ======== >>> from sympy import Polygon, S, Symbol >>> t = Symbol('t', real=True) >>> tri = Polygon((0, 0), (1, 0), (1, 1)) >>> p = tri.arbitrary_point('t') >>> perimeter = tri.perimeter >>> s1, s2 = [s.length for s in tri.sides[:2]] >>> p.subs(t, (s1 + s2/2)/perimeter) Point2D(1, 1/2) """ t = _symbol(parameter, real=True) if t.name in (f.name for f in self.free_symbols): raise ValueError('Symbol %s already appears in object and cannot be used as a parameter.' % t.name) sides = [] perimeter = self.perimeter perim_fraction_start = 0 for s in self.sides: side_perim_fraction = s.length/perimeter perim_fraction_end = perim_fraction_start + side_perim_fraction pt = s.arbitrary_point(parameter).subs( t, (t - perim_fraction_start)/side_perim_fraction) sides.append( (pt, (And(perim_fraction_start <= t, t < perim_fraction_end)))) perim_fraction_start = perim_fraction_end return Piecewise(*sides) def parameter_value(self, other, t): from sympy.solvers.solvers import solve if not isinstance(other,GeometryEntity): other = Point(other, dim=self.ambient_dimension) if not isinstance(other,Point): raise ValueError("other must be a point") if other.free_symbols: raise NotImplementedError('non-numeric coordinates') unknown = False T = Dummy('t', real=True) p = self.arbitrary_point(T) for pt, cond in p.args: sol = solve(pt - other, T, dict=True) if not sol: continue value = sol[0][T] if simplify(cond.subs(T, value)) == True: return {t: value} unknown = True if unknown: raise ValueError("Given point may not be on %s" % func_name(self)) raise ValueError("Given point is not on %s" % func_name(self)) def plot_interval(self, parameter='t'): """The plot interval for the default geometric plot of the polygon. Parameters ========== parameter : str, optional Default value is 't'. Returns ======= plot_interval : list (plot interval) [parameter, lower_bound, upper_bound] Examples ======== >>> from sympy import Polygon >>> p = Polygon((0, 0), (1, 0), (1, 1)) >>> p.plot_interval() [t, 0, 1] """ t = Symbol(parameter, real=True) return [t, 0, 1] def intersection(self, o): """The intersection of polygon and geometry entity. The intersection may be empty and can contain individual Points and complete Line Segments. Parameters ========== other: GeometryEntity Returns ======= intersection : list The list of Segments and Points See Also ======== sympy.geometry.point.Point, sympy.geometry.line.Segment Examples ======== >>> from sympy import Point, Polygon, Line >>> p1, p2, p3, p4 = map(Point, [(0, 0), (1, 0), (5, 1), (0, 1)]) >>> poly1 = Polygon(p1, p2, p3, p4) >>> p5, p6, p7 = map(Point, [(3, 2), (1, -1), (0, 2)]) >>> poly2 = Polygon(p5, p6, p7) >>> poly1.intersection(poly2) [Point2D(1/3, 1), Point2D(2/3, 0), Point2D(9/5, 1/5), Point2D(7/3, 1)] >>> poly1.intersection(Line(p1, p2)) [Segment2D(Point2D(0, 0), Point2D(1, 0))] >>> poly1.intersection(p1) [Point2D(0, 0)] """ intersection_result = [] k = o.sides if isinstance(o, Polygon) else [o] for side in self.sides: for side1 in k: intersection_result.extend(side.intersection(side1)) intersection_result = list(uniq(intersection_result)) points = [entity for entity in intersection_result if isinstance(entity, Point)] segments = [entity for entity in intersection_result if isinstance(entity, Segment)] if points and segments: points_in_segments = list(uniq([point for point in points for segment in segments if point in segment])) if points_in_segments: for i in points_in_segments: points.remove(i) return list(ordered(segments + points)) else: return list(ordered(intersection_result)) def distance(self, o): """ Returns the shortest distance between self and o. If o is a point, then self does not need to be convex. If o is another polygon self and o must be convex. Examples ======== >>> from sympy import Point, Polygon, RegularPolygon >>> p1, p2 = map(Point, [(0, 0), (7, 5)]) >>> poly = Polygon(*RegularPolygon(p1, 1, 3).vertices) >>> poly.distance(p2) sqrt(61) """ if isinstance(o, Point): dist = oo for side in self.sides: current = side.distance(o) if current == 0: return S.Zero elif current < dist: dist = current return dist elif isinstance(o, Polygon) and self.is_convex() and o.is_convex(): return self._do_poly_distance(o) raise NotImplementedError() def _do_poly_distance(self, e2): """ Calculates the least distance between the exteriors of two convex polygons e1 and e2. Does not check for the convexity of the polygons as this is checked by Polygon.distance. Notes ===== - Prints a warning if the two polygons possibly intersect as the return value will not be valid in such a case. For a more through test of intersection use intersection(). See Also ======== sympy.geometry.point.Point.distance Examples ======== >>> from sympy.geometry import Point, Polygon >>> square = Polygon(Point(0, 0), Point(0, 1), Point(1, 1), Point(1, 0)) >>> triangle = Polygon(Point(1, 2), Point(2, 2), Point(2, 1)) >>> square._do_poly_distance(triangle) sqrt(2)/2 Description of method used ========================== Method: [1] http://cgm.cs.mcgill.ca/~orm/mind2p.html Uses rotating calipers: [2] https://en.wikipedia.org/wiki/Rotating_calipers and antipodal points: [3] https://en.wikipedia.org/wiki/Antipodal_point """ e1 = self '''Tests for a possible intersection between the polygons and outputs a warning''' e1_center = e1.centroid e2_center = e2.centroid e1_max_radius = S.Zero e2_max_radius = S.Zero for vertex in e1.vertices: r = Point.distance(e1_center, vertex) if e1_max_radius < r: e1_max_radius = r for vertex in e2.vertices: r = Point.distance(e2_center, vertex) if e2_max_radius < r: e2_max_radius = r center_dist = Point.distance(e1_center, e2_center) if center_dist <= e1_max_radius + e2_max_radius: warnings.warn("Polygons may intersect producing erroneous output") ''' Find the upper rightmost vertex of e1 and the lowest leftmost vertex of e2 ''' e1_ymax = Point(0, -oo) e2_ymin = Point(0, oo) for vertex in e1.vertices: if vertex.y > e1_ymax.y or (vertex.y == e1_ymax.y and vertex.x > e1_ymax.x): e1_ymax = vertex for vertex in e2.vertices: if vertex.y < e2_ymin.y or (vertex.y == e2_ymin.y and vertex.x < e2_ymin.x): e2_ymin = vertex min_dist = Point.distance(e1_ymax, e2_ymin) ''' Produce a dictionary with vertices of e1 as the keys and, for each vertex, the points to which the vertex is connected as its value. The same is then done for e2. ''' e1_connections = {} e2_connections = {} for side in e1.sides: if side.p1 in e1_connections: e1_connections[side.p1].append(side.p2) else: e1_connections[side.p1] = [side.p2] if side.p2 in e1_connections: e1_connections[side.p2].append(side.p1) else: e1_connections[side.p2] = [side.p1] for side in e2.sides: if side.p1 in e2_connections: e2_connections[side.p1].append(side.p2) else: e2_connections[side.p1] = [side.p2] if side.p2 in e2_connections: e2_connections[side.p2].append(side.p1) else: e2_connections[side.p2] = [side.p1] e1_current = e1_ymax e2_current = e2_ymin support_line = Line(Point(S.Zero, S.Zero), Point(S.One, S.Zero)) ''' Determine which point in e1 and e2 will be selected after e2_ymin and e1_ymax, this information combined with the above produced dictionaries determines the path that will be taken around the polygons ''' point1 = e1_connections[e1_ymax][0] point2 = e1_connections[e1_ymax][1] angle1 = support_line.angle_between(Line(e1_ymax, point1)) angle2 = support_line.angle_between(Line(e1_ymax, point2)) if angle1 < angle2: e1_next = point1 elif angle2 < angle1: e1_next = point2 elif Point.distance(e1_ymax, point1) > Point.distance(e1_ymax, point2): e1_next = point2 else: e1_next = point1 point1 = e2_connections[e2_ymin][0] point2 = e2_connections[e2_ymin][1] angle1 = support_line.angle_between(Line(e2_ymin, point1)) angle2 = support_line.angle_between(Line(e2_ymin, point2)) if angle1 > angle2: e2_next = point1 elif angle2 > angle1: e2_next = point2 elif Point.distance(e2_ymin, point1) > Point.distance(e2_ymin, point2): e2_next = point2 else: e2_next = point1 ''' Loop which determines the distance between anti-podal pairs and updates the minimum distance accordingly. It repeats until it reaches the starting position. ''' while True: e1_angle = support_line.angle_between(Line(e1_current, e1_next)) e2_angle = pi - support_line.angle_between(Line( e2_current, e2_next)) if (e1_angle < e2_angle) is True: support_line = Line(e1_current, e1_next) e1_segment = Segment(e1_current, e1_next) min_dist_current = e1_segment.distance(e2_current) if min_dist_current.evalf() < min_dist.evalf(): min_dist = min_dist_current if e1_connections[e1_next][0] != e1_current: e1_current = e1_next e1_next = e1_connections[e1_next][0] else: e1_current = e1_next e1_next = e1_connections[e1_next][1] elif (e1_angle > e2_angle) is True: support_line = Line(e2_next, e2_current) e2_segment = Segment(e2_current, e2_next) min_dist_current = e2_segment.distance(e1_current) if min_dist_current.evalf() < min_dist.evalf(): min_dist = min_dist_current if e2_connections[e2_next][0] != e2_current: e2_current = e2_next e2_next = e2_connections[e2_next][0] else: e2_current = e2_next e2_next = e2_connections[e2_next][1] else: support_line = Line(e1_current, e1_next) e1_segment = Segment(e1_current, e1_next) e2_segment = Segment(e2_current, e2_next) min1 = e1_segment.distance(e2_next) min2 = e2_segment.distance(e1_next) min_dist_current = min(min1, min2) if min_dist_current.evalf() < min_dist.evalf(): min_dist = min_dist_current if e1_connections[e1_next][0] != e1_current: e1_current = e1_next e1_next = e1_connections[e1_next][0] else: e1_current = e1_next e1_next = e1_connections[e1_next][1] if e2_connections[e2_next][0] != e2_current: e2_current = e2_next e2_next = e2_connections[e2_next][0] else: e2_current = e2_next e2_next = e2_connections[e2_next][1] if e1_current == e1_ymax and e2_current == e2_ymin: break return min_dist def _svg(self, scale_factor=1., fill_color="#66cc99"): """Returns SVG path element for the Polygon. Parameters ========== scale_factor : float Multiplication factor for the SVG stroke-width. Default is 1. fill_color : str, optional Hex string for fill color. Default is "#66cc99". """ from sympy.core.evalf import N verts = map(N, self.vertices) coords = ["{0},{1}".format(p.x, p.y) for p in verts] path = "M {0} L {1} z".format(coords[0], " L ".join(coords[1:])) return ( '<path fill-rule="evenodd" fill="{2}" stroke="#555555" ' 'stroke-width="{0}" opacity="0.6" d="{1}" />' ).format(2. * scale_factor, path, fill_color) def _hashable_content(self): D = {} def ref_list(point_list): kee = {} for i, p in enumerate(ordered(set(point_list))): kee[p] = i D[i] = p return [kee[p] for p in point_list] S1 = ref_list(self.args) r_nor = rotate_left(S1, least_rotation(S1)) S2 = ref_list(list(reversed(self.args))) r_rev = rotate_left(S2, least_rotation(S2)) if r_nor < r_rev: r = r_nor else: r = r_rev canonical_args = [ D[order] for order in r ] return tuple(canonical_args) def __contains__(self, o): """ Return True if o is contained within the boundary lines of self.altitudes Parameters ========== other : GeometryEntity Returns ======= contained in : bool The points (and sides, if applicable) are contained in self. See Also ======== sympy.geometry.entity.GeometryEntity.encloses Examples ======== >>> from sympy import Line, Segment, Point >>> p = Point(0, 0) >>> q = Point(1, 1) >>> s = Segment(p, q*2) >>> l = Line(p, q) >>> p in q False >>> p in s True >>> q*3 in s False >>> s in l True """ if isinstance(o, Polygon): return self == o elif isinstance(o, Segment): return any(o in s for s in self.sides) elif isinstance(o, Point): if o in self.vertices: return True for side in self.sides: if o in side: return True return False class RegularPolygon(Polygon): """ A regular polygon. Such a polygon has all internal angles equal and all sides the same length. Parameters ========== center : Point radius : number or Basic instance The distance from the center to a vertex n : int The number of sides Attributes ========== vertices center radius rotation apothem interior_angle exterior_angle circumcircle incircle angles Raises ====== GeometryError If the `center` is not a Point, or the `radius` is not a number or Basic instance, or the number of sides, `n`, is less than three. Notes ===== A RegularPolygon can be instantiated with Polygon with the kwarg n. Regular polygons are instantiated with a center, radius, number of sides and a rotation angle. Whereas the arguments of a Polygon are vertices, the vertices of the RegularPolygon must be obtained with the vertices method. See Also ======== sympy.geometry.point.Point, Polygon Examples ======== >>> from sympy.geometry import RegularPolygon, Point >>> r = RegularPolygon(Point(0, 0), 5, 3) >>> r RegularPolygon(Point2D(0, 0), 5, 3, 0) >>> r.vertices[0] Point2D(5, 0) """ __slots__ = ['_n', '_center', '_radius', '_rot'] def __new__(self, c, r, n, rot=0, **kwargs): r, n, rot = map(sympify, (r, n, rot)) c = Point(c, dim=2, **kwargs) if not isinstance(r, Expr): raise GeometryError("r must be an Expr object, not %s" % r) if n.is_Number: as_int(n) # let an error raise if necessary if n < 3: raise GeometryError("n must be a >= 3, not %s" % n) obj = GeometryEntity.__new__(self, c, r, n, **kwargs) obj._n = n obj._center = c obj._radius = r obj._rot = rot % (2*S.Pi/n) if rot.is_number else rot return obj @property def args(self): """ Returns the center point, the radius, the number of sides, and the orientation angle. Examples ======== >>> from sympy import RegularPolygon, Point >>> r = RegularPolygon(Point(0, 0), 5, 3) >>> r.args (Point2D(0, 0), 5, 3, 0) """ return self._center, self._radius, self._n, self._rot def __str__(self): return 'RegularPolygon(%s, %s, %s, %s)' % tuple(self.args) def __repr__(self): return 'RegularPolygon(%s, %s, %s, %s)' % tuple(self.args) @property def area(self): """Returns the area. Examples ======== >>> from sympy.geometry import RegularPolygon >>> square = RegularPolygon((0, 0), 1, 4) >>> square.area 2 >>> _ == square.length**2 True """ c, r, n, rot = self.args return sign(r)*n*self.length**2/(4*tan(pi/n)) @property def length(self): """Returns the length of the sides. The half-length of the side and the apothem form two legs of a right triangle whose hypotenuse is the radius of the regular polygon. Examples ======== >>> from sympy.geometry import RegularPolygon >>> from sympy import sqrt >>> s = square_in_unit_circle = RegularPolygon((0, 0), 1, 4) >>> s.length sqrt(2) >>> sqrt((_/2)**2 + s.apothem**2) == s.radius True """ return self.radius*2*sin(pi/self._n) @property def center(self): """The center of the RegularPolygon This is also the center of the circumscribing circle. Returns ======= center : Point See Also ======== sympy.geometry.point.Point, sympy.geometry.ellipse.Ellipse.center Examples ======== >>> from sympy.geometry import RegularPolygon, Point >>> rp = RegularPolygon(Point(0, 0), 5, 4) >>> rp.center Point2D(0, 0) """ return self._center centroid = center @property def circumcenter(self): """ Alias for center. Examples ======== >>> from sympy.geometry import RegularPolygon, Point >>> rp = RegularPolygon(Point(0, 0), 5, 4) >>> rp.circumcenter Point2D(0, 0) """ return self.center @property def radius(self): """Radius of the RegularPolygon This is also the radius of the circumscribing circle. Returns ======= radius : number or instance of Basic See Also ======== sympy.geometry.line.Segment.length, sympy.geometry.ellipse.Circle.radius Examples ======== >>> from sympy import Symbol >>> from sympy.geometry import RegularPolygon, Point >>> radius = Symbol('r') >>> rp = RegularPolygon(Point(0, 0), radius, 4) >>> rp.radius r """ return self._radius @property def circumradius(self): """ Alias for radius. Examples ======== >>> from sympy import Symbol >>> from sympy.geometry import RegularPolygon, Point >>> radius = Symbol('r') >>> rp = RegularPolygon(Point(0, 0), radius, 4) >>> rp.circumradius r """ return self.radius @property def rotation(self): """CCW angle by which the RegularPolygon is rotated Returns ======= rotation : number or instance of Basic Examples ======== >>> from sympy import pi >>> from sympy.abc import a >>> from sympy.geometry import RegularPolygon, Point >>> RegularPolygon(Point(0, 0), 3, 4, pi/4).rotation pi/4 Numerical rotation angles are made canonical: >>> RegularPolygon(Point(0, 0), 3, 4, a).rotation a >>> RegularPolygon(Point(0, 0), 3, 4, pi).rotation 0 """ return self._rot @property def apothem(self): """The inradius of the RegularPolygon. The apothem/inradius is the radius of the inscribed circle. Returns ======= apothem : number or instance of Basic See Also ======== sympy.geometry.line.Segment.length, sympy.geometry.ellipse.Circle.radius Examples ======== >>> from sympy import Symbol >>> from sympy.geometry import RegularPolygon, Point >>> radius = Symbol('r') >>> rp = RegularPolygon(Point(0, 0), radius, 4) >>> rp.apothem sqrt(2)*r/2 """ return self.radius * cos(S.Pi/self._n) @property def inradius(self): """ Alias for apothem. Examples ======== >>> from sympy import Symbol >>> from sympy.geometry import RegularPolygon, Point >>> radius = Symbol('r') >>> rp = RegularPolygon(Point(0, 0), radius, 4) >>> rp.inradius sqrt(2)*r/2 """ return self.apothem @property def interior_angle(self): """Measure of the interior angles. Returns ======= interior_angle : number See Also ======== sympy.geometry.line.LinearEntity.angle_between Examples ======== >>> from sympy.geometry import RegularPolygon, Point >>> rp = RegularPolygon(Point(0, 0), 4, 8) >>> rp.interior_angle 3*pi/4 """ return (self._n - 2)*S.Pi/self._n @property def exterior_angle(self): """Measure of the exterior angles. Returns ======= exterior_angle : number See Also ======== sympy.geometry.line.LinearEntity.angle_between Examples ======== >>> from sympy.geometry import RegularPolygon, Point >>> rp = RegularPolygon(Point(0, 0), 4, 8) >>> rp.exterior_angle pi/4 """ return 2*S.Pi/self._n @property def circumcircle(self): """The circumcircle of the RegularPolygon. Returns ======= circumcircle : Circle See Also ======== circumcenter, sympy.geometry.ellipse.Circle Examples ======== >>> from sympy.geometry import RegularPolygon, Point >>> rp = RegularPolygon(Point(0, 0), 4, 8) >>> rp.circumcircle Circle(Point2D(0, 0), 4) """ return Circle(self.center, self.radius) @property def incircle(self): """The incircle of the RegularPolygon. Returns ======= incircle : Circle See Also ======== inradius, sympy.geometry.ellipse.Circle Examples ======== >>> from sympy.geometry import RegularPolygon, Point >>> rp = RegularPolygon(Point(0, 0), 4, 7) >>> rp.incircle Circle(Point2D(0, 0), 4*cos(pi/7)) """ return Circle(self.center, self.apothem) @property def angles(self): """ Returns a dictionary with keys, the vertices of the Polygon, and values, the interior angle at each vertex. Examples ======== >>> from sympy import RegularPolygon, Point >>> r = RegularPolygon(Point(0, 0), 5, 3) >>> r.angles {Point2D(-5/2, -5*sqrt(3)/2): pi/3, Point2D(-5/2, 5*sqrt(3)/2): pi/3, Point2D(5, 0): pi/3} """ ret = {} ang = self.interior_angle for v in self.vertices: ret[v] = ang return ret def encloses_point(self, p): """ Return True if p is enclosed by (is inside of) self. Notes ===== Being on the border of self is considered False. The general Polygon.encloses_point method is called only if a point is not within or beyond the incircle or circumcircle, respectively. Parameters ========== p : Point Returns ======= encloses_point : True, False or None See Also ======== sympy.geometry.ellipse.Ellipse.encloses_point Examples ======== >>> from sympy import RegularPolygon, S, Point, Symbol >>> p = RegularPolygon((0, 0), 3, 4) >>> p.encloses_point(Point(0, 0)) True >>> r, R = p.inradius, p.circumradius >>> p.encloses_point(Point((r + R)/2, 0)) True >>> p.encloses_point(Point(R/2, R/2 + (R - r)/10)) False >>> t = Symbol('t', real=True) >>> p.encloses_point(p.arbitrary_point().subs(t, S.Half)) False >>> p.encloses_point(Point(5, 5)) False """ c = self.center d = Segment(c, p).length if d >= self.radius: return False elif d < self.inradius: return True else: # now enumerate the RegularPolygon like a general polygon. return Polygon.encloses_point(self, p) def spin(self, angle): """Increment *in place* the virtual Polygon's rotation by ccw angle. See also: rotate method which moves the center. >>> from sympy import Polygon, Point, pi >>> r = Polygon(Point(0,0), 1, n=3) >>> r.vertices[0] Point2D(1, 0) >>> r.spin(pi/6) >>> r.vertices[0] Point2D(sqrt(3)/2, 1/2) See Also ======== rotation rotate : Creates a copy of the RegularPolygon rotated about a Point """ self._rot += angle def rotate(self, angle, pt=None): """Override GeometryEntity.rotate to first rotate the RegularPolygon about its center. >>> from sympy import Point, RegularPolygon, Polygon, pi >>> t = RegularPolygon(Point(1, 0), 1, 3) >>> t.vertices[0] # vertex on x-axis Point2D(2, 0) >>> t.rotate(pi/2).vertices[0] # vertex on y axis now Point2D(0, 2) See Also ======== rotation spin : Rotates a RegularPolygon in place """ r = type(self)(*self.args) # need a copy or else changes are in-place r._rot += angle return GeometryEntity.rotate(r, angle, pt) def scale(self, x=1, y=1, pt=None): """Override GeometryEntity.scale since it is the radius that must be scaled (if x == y) or else a new Polygon must be returned. >>> from sympy import RegularPolygon Symmetric scaling returns a RegularPolygon: >>> RegularPolygon((0, 0), 1, 4).scale(2, 2) RegularPolygon(Point2D(0, 0), 2, 4, 0) Asymmetric scaling returns a kite as a Polygon: >>> RegularPolygon((0, 0), 1, 4).scale(2, 1) Polygon(Point2D(2, 0), Point2D(0, 1), Point2D(-2, 0), Point2D(0, -1)) """ if pt: pt = Point(pt, dim=2) return self.translate(*(-pt).args).scale(x, y).translate(*pt.args) if x != y: return Polygon(*self.vertices).scale(x, y) c, r, n, rot = self.args r *= x return self.func(c, r, n, rot) def reflect(self, line): """Override GeometryEntity.reflect since this is not made of only points. Examples ======== >>> from sympy import RegularPolygon, Line >>> RegularPolygon((0, 0), 1, 4).reflect(Line((0, 1), slope=-2)) RegularPolygon(Point2D(4/5, 2/5), -1, 4, atan(4/3)) """ c, r, n, rot = self.args v = self.vertices[0] d = v - c cc = c.reflect(line) vv = v.reflect(line) dd = vv - cc # calculate rotation about the new center # which will align the vertices l1 = Ray((0, 0), dd) l2 = Ray((0, 0), d) ang = l1.closing_angle(l2) rot += ang # change sign of radius as point traversal is reversed return self.func(cc, -r, n, rot) @property def vertices(self): """The vertices of the RegularPolygon. Returns ======= vertices : list Each vertex is a Point. See Also ======== sympy.geometry.point.Point Examples ======== >>> from sympy.geometry import RegularPolygon, Point >>> rp = RegularPolygon(Point(0, 0), 5, 4) >>> rp.vertices [Point2D(5, 0), Point2D(0, 5), Point2D(-5, 0), Point2D(0, -5)] """ c = self._center r = abs(self._radius) rot = self._rot v = 2*S.Pi/self._n return [Point(c.x + r*cos(k*v + rot), c.y + r*sin(k*v + rot)) for k in range(self._n)] def __eq__(self, o): if not isinstance(o, Polygon): return False elif not isinstance(o, RegularPolygon): return Polygon.__eq__(o, self) return self.args == o.args def __hash__(self): return super(RegularPolygon, self).__hash__() class Triangle(Polygon): """ A polygon with three vertices and three sides. Parameters ========== points : sequence of Points keyword: asa, sas, or sss to specify sides/angles of the triangle Attributes ========== vertices altitudes orthocenter circumcenter circumradius circumcircle inradius incircle exradii medians medial nine_point_circle Raises ====== GeometryError If the number of vertices is not equal to three, or one of the vertices is not a Point, or a valid keyword is not given. See Also ======== sympy.geometry.point.Point, Polygon Examples ======== >>> from sympy.geometry import Triangle, Point >>> Triangle(Point(0, 0), Point(4, 0), Point(4, 3)) Triangle(Point2D(0, 0), Point2D(4, 0), Point2D(4, 3)) Keywords sss, sas, or asa can be used to give the desired side lengths (in order) and interior angles (in degrees) that define the triangle: >>> Triangle(sss=(3, 4, 5)) Triangle(Point2D(0, 0), Point2D(3, 0), Point2D(3, 4)) >>> Triangle(asa=(30, 1, 30)) Triangle(Point2D(0, 0), Point2D(1, 0), Point2D(1/2, sqrt(3)/6)) >>> Triangle(sas=(1, 45, 2)) Triangle(Point2D(0, 0), Point2D(2, 0), Point2D(sqrt(2)/2, sqrt(2)/2)) """ def __new__(cls, *args, **kwargs): if len(args) != 3: if 'sss' in kwargs: return _sss(*[simplify(a) for a in kwargs['sss']]) if 'asa' in kwargs: return _asa(*[simplify(a) for a in kwargs['asa']]) if 'sas' in kwargs: return _sas(*[simplify(a) for a in kwargs['sas']]) msg = "Triangle instantiates with three points or a valid keyword." raise GeometryError(msg) vertices = [Point(a, dim=2, **kwargs) for a in args] # remove consecutive duplicates nodup = [] for p in vertices: if nodup and p == nodup[-1]: continue nodup.append(p) if len(nodup) > 1 and nodup[-1] == nodup[0]: nodup.pop() # last point was same as first # remove collinear points i = -3 while i < len(nodup) - 3 and len(nodup) > 2: a, b, c = sorted( [nodup[i], nodup[i + 1], nodup[i + 2]], key=default_sort_key) if Point.is_collinear(a, b, c): nodup[i] = a nodup[i + 1] = None nodup.pop(i + 1) i += 1 vertices = list(filter(lambda x: x is not None, nodup)) if len(vertices) == 3: return GeometryEntity.__new__(cls, *vertices, **kwargs) elif len(vertices) == 2: return Segment(*vertices, **kwargs) else: return Point(*vertices, **kwargs) @property def vertices(self): """The triangle's vertices Returns ======= vertices : tuple Each element in the tuple is a Point See Also ======== sympy.geometry.point.Point Examples ======== >>> from sympy.geometry import Triangle, Point >>> t = Triangle(Point(0, 0), Point(4, 0), Point(4, 3)) >>> t.vertices (Point2D(0, 0), Point2D(4, 0), Point2D(4, 3)) """ return self.args def is_similar(t1, t2): """Is another triangle similar to this one. Two triangles are similar if one can be uniformly scaled to the other. Parameters ========== other: Triangle Returns ======= is_similar : boolean See Also ======== sympy.geometry.entity.GeometryEntity.is_similar Examples ======== >>> from sympy.geometry import Triangle, Point >>> t1 = Triangle(Point(0, 0), Point(4, 0), Point(4, 3)) >>> t2 = Triangle(Point(0, 0), Point(-4, 0), Point(-4, -3)) >>> t1.is_similar(t2) True >>> t2 = Triangle(Point(0, 0), Point(-4, 0), Point(-4, -4)) >>> t1.is_similar(t2) False """ if not isinstance(t2, Polygon): return False s1_1, s1_2, s1_3 = [side.length for side in t1.sides] s2 = [side.length for side in t2.sides] def _are_similar(u1, u2, u3, v1, v2, v3): e1 = simplify(u1/v1) e2 = simplify(u2/v2) e3 = simplify(u3/v3) return bool(e1 == e2) and bool(e2 == e3) # There's only 6 permutations, so write them out return _are_similar(s1_1, s1_2, s1_3, *s2) or \ _are_similar(s1_1, s1_3, s1_2, *s2) or \ _are_similar(s1_2, s1_1, s1_3, *s2) or \ _are_similar(s1_2, s1_3, s1_1, *s2) or \ _are_similar(s1_3, s1_1, s1_2, *s2) or \ _are_similar(s1_3, s1_2, s1_1, *s2) def is_equilateral(self): """Are all the sides the same length? Returns ======= is_equilateral : boolean See Also ======== sympy.geometry.entity.GeometryEntity.is_similar, RegularPolygon is_isosceles, is_right, is_scalene Examples ======== >>> from sympy.geometry import Triangle, Point >>> t1 = Triangle(Point(0, 0), Point(4, 0), Point(4, 3)) >>> t1.is_equilateral() False >>> from sympy import sqrt >>> t2 = Triangle(Point(0, 0), Point(10, 0), Point(5, 5*sqrt(3))) >>> t2.is_equilateral() True """ return not has_variety(s.length for s in self.sides) def is_isosceles(self): """Are two or more of the sides the same length? Returns ======= is_isosceles : boolean See Also ======== is_equilateral, is_right, is_scalene Examples ======== >>> from sympy.geometry import Triangle, Point >>> t1 = Triangle(Point(0, 0), Point(4, 0), Point(2, 4)) >>> t1.is_isosceles() True """ return has_dups(s.length for s in self.sides) def is_scalene(self): """Are all the sides of the triangle of different lengths? Returns ======= is_scalene : boolean See Also ======== is_equilateral, is_isosceles, is_right Examples ======== >>> from sympy.geometry import Triangle, Point >>> t1 = Triangle(Point(0, 0), Point(4, 0), Point(1, 4)) >>> t1.is_scalene() True """ return not has_dups(s.length for s in self.sides) def is_right(self): """Is the triangle right-angled. Returns ======= is_right : boolean See Also ======== sympy.geometry.line.LinearEntity.is_perpendicular is_equilateral, is_isosceles, is_scalene Examples ======== >>> from sympy.geometry import Triangle, Point >>> t1 = Triangle(Point(0, 0), Point(4, 0), Point(4, 3)) >>> t1.is_right() True """ s = self.sides return Segment.is_perpendicular(s[0], s[1]) or \ Segment.is_perpendicular(s[1], s[2]) or \ Segment.is_perpendicular(s[0], s[2]) @property def altitudes(self): """The altitudes of the triangle. An altitude of a triangle is a segment through a vertex, perpendicular to the opposite side, with length being the height of the vertex measured from the line containing the side. Returns ======= altitudes : dict The dictionary consists of keys which are vertices and values which are Segments. See Also ======== sympy.geometry.point.Point, sympy.geometry.line.Segment.length Examples ======== >>> from sympy.geometry import Point, Triangle >>> p1, p2, p3 = Point(0, 0), Point(1, 0), Point(0, 1) >>> t = Triangle(p1, p2, p3) >>> t.altitudes[p1] Segment2D(Point2D(0, 0), Point2D(1/2, 1/2)) """ s = self.sides v = self.vertices return {v[0]: s[1].perpendicular_segment(v[0]), v[1]: s[2].perpendicular_segment(v[1]), v[2]: s[0].perpendicular_segment(v[2])} @property def orthocenter(self): """The orthocenter of the triangle. The orthocenter is the intersection of the altitudes of a triangle. It may lie inside, outside or on the triangle. Returns ======= orthocenter : Point See Also ======== sympy.geometry.point.Point Examples ======== >>> from sympy.geometry import Point, Triangle >>> p1, p2, p3 = Point(0, 0), Point(1, 0), Point(0, 1) >>> t = Triangle(p1, p2, p3) >>> t.orthocenter Point2D(0, 0) """ a = self.altitudes v = self.vertices return Line(a[v[0]]).intersection(Line(a[v[1]]))[0] @property def circumcenter(self): """The circumcenter of the triangle The circumcenter is the center of the circumcircle. Returns ======= circumcenter : Point See Also ======== sympy.geometry.point.Point Examples ======== >>> from sympy.geometry import Point, Triangle >>> p1, p2, p3 = Point(0, 0), Point(1, 0), Point(0, 1) >>> t = Triangle(p1, p2, p3) >>> t.circumcenter Point2D(1/2, 1/2) """ a, b, c = [x.perpendicular_bisector() for x in self.sides] if not a.intersection(b): print(a,b,a.intersection(b)) return a.intersection(b)[0] @property def circumradius(self): """The radius of the circumcircle of the triangle. Returns ======= circumradius : number of Basic instance See Also ======== sympy.geometry.ellipse.Circle.radius Examples ======== >>> from sympy import Symbol >>> from sympy.geometry import Point, Triangle >>> a = Symbol('a') >>> p1, p2, p3 = Point(0, 0), Point(1, 0), Point(0, a) >>> t = Triangle(p1, p2, p3) >>> t.circumradius sqrt(a**2/4 + 1/4) """ return Point.distance(self.circumcenter, self.vertices[0]) @property def circumcircle(self): """The circle which passes through the three vertices of the triangle. Returns ======= circumcircle : Circle See Also ======== sympy.geometry.ellipse.Circle Examples ======== >>> from sympy.geometry import Point, Triangle >>> p1, p2, p3 = Point(0, 0), Point(1, 0), Point(0, 1) >>> t = Triangle(p1, p2, p3) >>> t.circumcircle Circle(Point2D(1/2, 1/2), sqrt(2)/2) """ return Circle(self.circumcenter, self.circumradius) def bisectors(self): """The angle bisectors of the triangle. An angle bisector of a triangle is a straight line through a vertex which cuts the corresponding angle in half. Returns ======= bisectors : dict Each key is a vertex (Point) and each value is the corresponding bisector (Segment). See Also ======== sympy.geometry.point.Point, sympy.geometry.line.Segment Examples ======== >>> from sympy.geometry import Point, Triangle, Segment >>> p1, p2, p3 = Point(0, 0), Point(1, 0), Point(0, 1) >>> t = Triangle(p1, p2, p3) >>> from sympy import sqrt >>> t.bisectors()[p2] == Segment(Point(1, 0), Point(0, sqrt(2) - 1)) True """ # use lines containing sides so containment check during # intersection calculation can be avoided # This would reduce the processing time for calculating the bisectors s = [Line(l) for l in self.sides] v = self.vertices c = self.incenter l1 = Segment(v[0], Line(v[0], c).intersection(s[1])[0]) l2 = Segment(v[1], Line(v[1], c).intersection(s[2])[0]) l3 = Segment(v[2], Line(v[2], c).intersection(s[0])[0]) return {v[0]: l1, v[1]: l2, v[2]: l3} @property def incenter(self): """The center of the incircle. The incircle is the circle which lies inside the triangle and touches all three sides. Returns ======= incenter : Point See Also ======== incircle, sympy.geometry.point.Point Examples ======== >>> from sympy.geometry import Point, Triangle >>> p1, p2, p3 = Point(0, 0), Point(1, 0), Point(0, 1) >>> t = Triangle(p1, p2, p3) >>> t.incenter Point2D(1 - sqrt(2)/2, 1 - sqrt(2)/2) """ s = self.sides l = Matrix([s[i].length for i in [1, 2, 0]]) p = sum(l) v = self.vertices x = simplify(l.dot(Matrix([vi.x for vi in v]))/p) y = simplify(l.dot(Matrix([vi.y for vi in v]))/p) return Point(x, y) @property def inradius(self): """The radius of the incircle. Returns ======= inradius : number of Basic instance See Also ======== incircle, sympy.geometry.ellipse.Circle.radius Examples ======== >>> from sympy.geometry import Point, Triangle >>> p1, p2, p3 = Point(0, 0), Point(4, 0), Point(0, 3) >>> t = Triangle(p1, p2, p3) >>> t.inradius 1 """ return simplify(2 * self.area / self.perimeter) @property def incircle(self): """The incircle of the triangle. The incircle is the circle which lies inside the triangle and touches all three sides. Returns ======= incircle : Circle See Also ======== sympy.geometry.ellipse.Circle Examples ======== >>> from sympy.geometry import Point, Triangle >>> p1, p2, p3 = Point(0, 0), Point(2, 0), Point(0, 2) >>> t = Triangle(p1, p2, p3) >>> t.incircle Circle(Point2D(2 - sqrt(2), 2 - sqrt(2)), 2 - sqrt(2)) """ return Circle(self.incenter, self.inradius) @property def exradii(self): """The radius of excircles of a triangle. An excircle of the triangle is a circle lying outside the triangle, tangent to one of its sides and tangent to the extensions of the other two. Returns ======= exradii : dict See Also ======== sympy.geometry.polygon.Triangle.inradius Examples ======== The exradius touches the side of the triangle to which it is keyed, e.g. the exradius touching side 2 is: >>> from sympy.geometry import Point, Triangle, Segment2D, Point2D >>> p1, p2, p3 = Point(0, 0), Point(6, 0), Point(0, 2) >>> t = Triangle(p1, p2, p3) >>> t.exradii[t.sides[2]] -2 + sqrt(10) References ========== [1] http://mathworld.wolfram.com/Exradius.html [2] http://mathworld.wolfram.com/Excircles.html """ side = self.sides a = side[0].length b = side[1].length c = side[2].length s = (a+b+c)/2 area = self.area exradii = {self.sides[0]: simplify(area/(s-a)), self.sides[1]: simplify(area/(s-b)), self.sides[2]: simplify(area/(s-c))} return exradii @property def medians(self): """The medians of the triangle. A median of a triangle is a straight line through a vertex and the midpoint of the opposite side, and divides the triangle into two equal areas. Returns ======= medians : dict Each key is a vertex (Point) and each value is the median (Segment) at that point. See Also ======== sympy.geometry.point.Point.midpoint, sympy.geometry.line.Segment.midpoint Examples ======== >>> from sympy.geometry import Point, Triangle >>> p1, p2, p3 = Point(0, 0), Point(1, 0), Point(0, 1) >>> t = Triangle(p1, p2, p3) >>> t.medians[p1] Segment2D(Point2D(0, 0), Point2D(1/2, 1/2)) """ s = self.sides v = self.vertices return {v[0]: Segment(v[0], s[1].midpoint), v[1]: Segment(v[1], s[2].midpoint), v[2]: Segment(v[2], s[0].midpoint)} @property def medial(self): """The medial triangle of the triangle. The triangle which is formed from the midpoints of the three sides. Returns ======= medial : Triangle See Also ======== sympy.geometry.line.Segment.midpoint Examples ======== >>> from sympy.geometry import Point, Triangle >>> p1, p2, p3 = Point(0, 0), Point(1, 0), Point(0, 1) >>> t = Triangle(p1, p2, p3) >>> t.medial Triangle(Point2D(1/2, 0), Point2D(1/2, 1/2), Point2D(0, 1/2)) """ s = self.sides return Triangle(s[0].midpoint, s[1].midpoint, s[2].midpoint) @property def nine_point_circle(self): """The nine-point circle of the triangle. Nine-point circle is the circumcircle of the medial triangle, which passes through the feet of altitudes and the middle points of segments connecting the vertices and the orthocenter. Returns ======= nine_point_circle : Circle See also ======== sympy.geometry.line.Segment.midpoint sympy.geometry.polygon.Triangle.medial sympy.geometry.polygon.Triangle.orthocenter Examples ======== >>> from sympy.geometry import Point, Triangle >>> p1, p2, p3 = Point(0, 0), Point(1, 0), Point(0, 1) >>> t = Triangle(p1, p2, p3) >>> t.nine_point_circle Circle(Point2D(1/4, 1/4), sqrt(2)/4) """ return Circle(*self.medial.vertices) @property def eulerline(self): """The Euler line of the triangle. The line which passes through circumcenter, centroid and orthocenter. Returns ======= eulerline : Line (or Point for equilateral triangles in which case all centers coincide) Examples ======== >>> from sympy.geometry import Point, Triangle >>> p1, p2, p3 = Point(0, 0), Point(1, 0), Point(0, 1) >>> t = Triangle(p1, p2, p3) >>> t.eulerline Line2D(Point2D(0, 0), Point2D(1/2, 1/2)) """ if self.is_equilateral(): return self.orthocenter return Line(self.orthocenter, self.circumcenter) def rad(d): """Return the radian value for the given degrees (pi = 180 degrees).""" return d*pi/180 def deg(r): """Return the degree value for the given radians (pi = 180 degrees).""" return r/pi*180 def _slope(d): rv = tan(rad(d)) return rv def _asa(d1, l, d2): """Return triangle having side with length l on the x-axis.""" xy = Line((0, 0), slope=_slope(d1)).intersection( Line((l, 0), slope=_slope(180 - d2)))[0] return Triangle((0, 0), (l, 0), xy) def _sss(l1, l2, l3): """Return triangle having side of length l1 on the x-axis.""" c1 = Circle((0, 0), l3) c2 = Circle((l1, 0), l2) inter = [a for a in c1.intersection(c2) if a.y.is_nonnegative] if not inter: return None pt = inter[0] return Triangle((0, 0), (l1, 0), pt) def _sas(l1, d, l2): """Return triangle having side with length l2 on the x-axis.""" p1 = Point(0, 0) p2 = Point(l2, 0) p3 = Point(cos(rad(d))*l1, sin(rad(d))*l1) return Triangle(p1, p2, p3)
709c266f504980b21d58df83b6c935185cb2cf26c1dfae0d1d3e4e826aeed871
""" This module defines tensors with abstract index notation. The abstract index notation has been first formalized by Penrose. Tensor indices are formal objects, with a tensor type; there is no notion of index range, it is only possible to assign the dimension, used to trace the Kronecker delta; the dimension can be a Symbol. The Einstein summation convention is used. The covariant indices are indicated with a minus sign in front of the index. For instance the tensor ``t = p(a)*A(b,c)*q(-c)`` has the index ``c`` contracted. A tensor expression ``t`` can be called; called with its indices in sorted order it is equal to itself: in the above example ``t(a, b) == t``; one can call ``t`` with different indices; ``t(c, d) == p(c)*A(d,a)*q(-a)``. The contracted indices are dummy indices, internally they have no name, the indices being represented by a graph-like structure. Tensors are put in canonical form using ``canon_bp``, which uses the Butler-Portugal algorithm for canonicalization using the monoterm symmetries of the tensors. If there is a (anti)symmetric metric, the indices can be raised and lowered when the tensor is put in canonical form. """ from __future__ import print_function, division from collections import defaultdict import operator import itertools from sympy import Rational, prod, Integer from sympy.combinatorics.tensor_can import get_symmetric_group_sgs, \ bsgs_direct_product, canonicalize, riemann_bsgs from sympy.core import Basic, Expr, sympify, Add, Mul, S from sympy.core.compatibility import string_types, reduce, range, SYMPY_INTS from sympy.core.containers import Tuple, Dict from sympy.core.decorators import deprecated from sympy.core.symbol import Symbol, symbols from sympy.core.sympify import CantSympify, _sympify from sympy.core.operations import AssocOp from sympy.matrices import eye from sympy.utilities.exceptions import SymPyDeprecationWarning import warnings @deprecated(useinstead=".replace_with_arrays", issue=15276, deprecated_since_version="1.4") def deprecate_data(): pass class _IndexStructure(CantSympify): """ This class handles the indices (free and dummy ones). It contains the algorithms to manage the dummy indices replacements and contractions of free indices under multiplications of tensor expressions, as well as stuff related to canonicalization sorting, getting the permutation of the expression and so on. It also includes tools to get the ``TensorIndex`` objects corresponding to the given index structure. """ def __init__(self, free, dum, index_types, indices, canon_bp=False): self.free = free self.dum = dum self.index_types = index_types self.indices = indices self._ext_rank = len(self.free) + 2*len(self.dum) self.dum.sort(key=lambda x: x[0]) @staticmethod def from_indices(*indices): """ Create a new ``_IndexStructure`` object from a list of ``indices`` ``indices`` ``TensorIndex`` objects, the indices. Contractions are detected upon construction. Examples ======== >>> from sympy.tensor.tensor import TensorIndexType, tensor_indices, _IndexStructure >>> Lorentz = TensorIndexType('Lorentz', dummy_fmt='L') >>> m0, m1, m2, m3 = tensor_indices('m0,m1,m2,m3', Lorentz) >>> _IndexStructure.from_indices(m0, m1, -m1, m3) _IndexStructure([(m0, 0), (m3, 3)], [(1, 2)], [Lorentz, Lorentz, Lorentz, Lorentz]) In case of many components the same indices have slightly different indexes: >>> _IndexStructure.from_indices(m0, m1, -m1, m3) _IndexStructure([(m0, 0), (m3, 3)], [(1, 2)], [Lorentz, Lorentz, Lorentz, Lorentz]) """ free, dum = _IndexStructure._free_dum_from_indices(*indices) index_types = [i.tensor_index_type for i in indices] indices = _IndexStructure._replace_dummy_names(indices, free, dum) return _IndexStructure(free, dum, index_types, indices) @staticmethod def from_components_free_dum(components, free, dum): index_types = [] for component in components: index_types.extend(component.index_types) indices = _IndexStructure.generate_indices_from_free_dum_index_types(free, dum, index_types) return _IndexStructure(free, dum, index_types, indices) @staticmethod def _free_dum_from_indices(*indices): """ Convert ``indices`` into ``free``, ``dum`` for single component tensor ``free`` list of tuples ``(index, pos, 0)``, where ``pos`` is the position of index in the list of indices formed by the component tensors ``dum`` list of tuples ``(pos_contr, pos_cov, 0, 0)`` Examples ======== >>> from sympy.tensor.tensor import TensorIndexType, tensor_indices, \ _IndexStructure >>> Lorentz = TensorIndexType('Lorentz', dummy_fmt='L') >>> m0, m1, m2, m3 = tensor_indices('m0,m1,m2,m3', Lorentz) >>> _IndexStructure._free_dum_from_indices(m0, m1, -m1, m3) ([(m0, 0), (m3, 3)], [(1, 2)]) """ n = len(indices) if n == 1: return [(indices[0], 0)], [] # find the positions of the free indices and of the dummy indices free = [True]*len(indices) index_dict = {} dum = [] for i, index in enumerate(indices): name = index._name typ = index.tensor_index_type contr = index._is_up if (name, typ) in index_dict: # found a pair of dummy indices is_contr, pos = index_dict[(name, typ)] # check consistency and update free if is_contr: if contr: raise ValueError('two equal contravariant indices in slots %d and %d' %(pos, i)) else: free[pos] = False free[i] = False else: if contr: free[pos] = False free[i] = False else: raise ValueError('two equal covariant indices in slots %d and %d' %(pos, i)) if contr: dum.append((i, pos)) else: dum.append((pos, i)) else: index_dict[(name, typ)] = index._is_up, i free = [(index, i) for i, index in enumerate(indices) if free[i]] free.sort() return free, dum def get_indices(self): """ Get a list of indices, creating new tensor indices to complete dummy indices. """ return self.indices[:] @staticmethod def generate_indices_from_free_dum_index_types(free, dum, index_types): indices = [None]*(len(free)+2*len(dum)) for idx, pos in free: indices[pos] = idx generate_dummy_name = _IndexStructure._get_generator_for_dummy_indices(free) for pos1, pos2 in dum: typ1 = index_types[pos1] indname = generate_dummy_name(typ1) indices[pos1] = TensorIndex(indname, typ1, True) indices[pos2] = TensorIndex(indname, typ1, False) return _IndexStructure._replace_dummy_names(indices, free, dum) @staticmethod def _get_generator_for_dummy_indices(free): cdt = defaultdict(int) # if the free indices have names with dummy_fmt, start with an # index higher than those for the dummy indices # to avoid name collisions for indx, ipos in free: if indx._name.split('_')[0] == indx.tensor_index_type.dummy_fmt[:-3]: cdt[indx.tensor_index_type] = max(cdt[indx.tensor_index_type], int(indx._name.split('_')[1]) + 1) def dummy_fmt_gen(tensor_index_type): fmt = tensor_index_type.dummy_fmt nd = cdt[tensor_index_type] cdt[tensor_index_type] += 1 return fmt % nd return dummy_fmt_gen @staticmethod def _replace_dummy_names(indices, free, dum): dum.sort(key=lambda x: x[0]) new_indices = [ind for ind in indices] assert len(indices) == len(free) + 2*len(dum) generate_dummy_name = _IndexStructure._get_generator_for_dummy_indices(free) for ipos1, ipos2 in dum: typ1 = new_indices[ipos1].tensor_index_type indname = generate_dummy_name(typ1) new_indices[ipos1] = TensorIndex(indname, typ1, True) new_indices[ipos2] = TensorIndex(indname, typ1, False) return new_indices def get_free_indices(self): """ Get a list of free indices. """ # get sorted indices according to their position: free = sorted(self.free, key=lambda x: x[1]) return [i[0] for i in free] def __str__(self): return "_IndexStructure({0}, {1}, {2})".format(self.free, self.dum, self.index_types) def __repr__(self): return self.__str__() def _get_sorted_free_indices_for_canon(self): sorted_free = self.free[:] sorted_free.sort(key=lambda x: x[0]) return sorted_free def _get_sorted_dum_indices_for_canon(self): return sorted(self.dum, key=lambda x: x[0]) def _get_lexicographically_sorted_index_types(self): permutation = self.indices_canon_args()[0] index_types = [None]*self._ext_rank for i, it in enumerate(self.index_types): index_types[permutation(i)] = it return index_types def _get_lexicographically_sorted_indices(self): permutation = self.indices_canon_args()[0] indices = [None]*self._ext_rank for i, it in enumerate(self.indices): indices[permutation(i)] = it return indices def perm2tensor(self, g, is_canon_bp=False): """ Returns a ``_IndexStructure`` instance corresponding to the permutation ``g`` ``g`` permutation corresponding to the tensor in the representation used in canonicalization ``is_canon_bp`` if True, then ``g`` is the permutation corresponding to the canonical form of the tensor """ sorted_free = [i[0] for i in self._get_sorted_free_indices_for_canon()] lex_index_types = self._get_lexicographically_sorted_index_types() lex_indices = self._get_lexicographically_sorted_indices() nfree = len(sorted_free) rank = self._ext_rank dum = [[None]*2 for i in range((rank - nfree)//2)] free = [] index_types = [None]*rank indices = [None]*rank for i in range(rank): gi = g[i] index_types[i] = lex_index_types[gi] indices[i] = lex_indices[gi] if gi < nfree: ind = sorted_free[gi] assert index_types[i] == sorted_free[gi].tensor_index_type free.append((ind, i)) else: j = gi - nfree idum, cov = divmod(j, 2) if cov: dum[idum][1] = i else: dum[idum][0] = i dum = [tuple(x) for x in dum] return _IndexStructure(free, dum, index_types, indices) def indices_canon_args(self): """ Returns ``(g, dummies, msym, v)``, the entries of ``canonicalize`` see ``canonicalize`` in ``tensor_can.py`` """ # to be called after sorted_components from sympy.combinatorics.permutations import _af_new n = self._ext_rank g = [None]*n + [n, n+1] # ordered indices: first the free indices, ordered by types # then the dummy indices, ordered by types and contravariant before # covariant # g[position in tensor] = position in ordered indices for i, (indx, ipos) in enumerate(self._get_sorted_free_indices_for_canon()): g[ipos] = i pos = len(self.free) j = len(self.free) dummies = [] prev = None a = [] msym = [] for ipos1, ipos2 in self._get_sorted_dum_indices_for_canon(): g[ipos1] = j g[ipos2] = j + 1 j += 2 typ = self.index_types[ipos1] if typ != prev: if a: dummies.append(a) a = [pos, pos + 1] prev = typ msym.append(typ.metric_antisym) else: a.extend([pos, pos + 1]) pos += 2 if a: dummies.append(a) return _af_new(g), dummies, msym def components_canon_args(components): numtyp = [] prev = None for t in components: if t == prev: numtyp[-1][1] += 1 else: prev = t numtyp.append([prev, 1]) v = [] for h, n in numtyp: if h._comm == 0 or h._comm == 1: comm = h._comm else: comm = TensorManager.get_comm(h._comm, h._comm) v.append((h._symmetry.base, h._symmetry.generators, n, comm)) return v class _TensorDataLazyEvaluator(CantSympify): """ EXPERIMENTAL: do not rely on this class, it may change without deprecation warnings in future versions of SymPy. This object contains the logic to associate components data to a tensor expression. Components data are set via the ``.data`` property of tensor expressions, is stored inside this class as a mapping between the tensor expression and the ``ndarray``. Computations are executed lazily: whereas the tensor expressions can have contractions, tensor products, and additions, components data are not computed until they are accessed by reading the ``.data`` property associated to the tensor expression. """ _substitutions_dict = dict() _substitutions_dict_tensmul = dict() def __getitem__(self, key): dat = self._get(key) if dat is None: return None from .array import NDimArray if not isinstance(dat, NDimArray): return dat if dat.rank() == 0: return dat[()] elif dat.rank() == 1 and len(dat) == 1: return dat[0] return dat def _get(self, key): """ Retrieve ``data`` associated with ``key``. This algorithm looks into ``self._substitutions_dict`` for all ``TensorHead`` in the ``TensExpr`` (or just ``TensorHead`` if key is a TensorHead instance). It reconstructs the components data that the tensor expression should have by performing on components data the operations that correspond to the abstract tensor operations applied. Metric tensor is handled in a different manner: it is pre-computed in ``self._substitutions_dict_tensmul``. """ if key in self._substitutions_dict: return self._substitutions_dict[key] if isinstance(key, TensorHead): return None if isinstance(key, Tensor): # special case to handle metrics. Metric tensors cannot be # constructed through contraction by the metric, their # components show if they are a matrix or its inverse. signature = tuple([i.is_up for i in key.get_indices()]) srch = (key.component,) + signature if srch in self._substitutions_dict_tensmul: return self._substitutions_dict_tensmul[srch] array_list = [self.data_from_tensor(key)] return self.data_contract_dum(array_list, key.dum, key.ext_rank) if isinstance(key, TensMul): tensmul_args = key.args if len(tensmul_args) == 1 and len(tensmul_args[0].components) == 1: # special case to handle metrics. Metric tensors cannot be # constructed through contraction by the metric, their # components show if they are a matrix or its inverse. signature = tuple([i.is_up for i in tensmul_args[0].get_indices()]) srch = (tensmul_args[0].components[0],) + signature if srch in self._substitutions_dict_tensmul: return self._substitutions_dict_tensmul[srch] #data_list = [self.data_from_tensor(i) for i in tensmul_args if isinstance(i, TensExpr)] data_list = [self.data_from_tensor(i) if isinstance(i, Tensor) else i.data for i in tensmul_args if isinstance(i, TensExpr)] coeff = prod([i for i in tensmul_args if not isinstance(i, TensExpr)]) if all([i is None for i in data_list]): return None if any([i is None for i in data_list]): raise ValueError("Mixing tensors with associated components "\ "data with tensors without components data") data_result = self.data_contract_dum(data_list, key.dum, key.ext_rank) return coeff*data_result if isinstance(key, TensAdd): data_list = [] free_args_list = [] for arg in key.args: if isinstance(arg, TensExpr): data_list.append(arg.data) free_args_list.append([x[0] for x in arg.free]) else: data_list.append(arg) free_args_list.append([]) if all([i is None for i in data_list]): return None if any([i is None for i in data_list]): raise ValueError("Mixing tensors with associated components "\ "data with tensors without components data") sum_list = [] from .array import permutedims for data, free_args in zip(data_list, free_args_list): if len(free_args) < 2: sum_list.append(data) else: free_args_pos = {y: x for x, y in enumerate(free_args)} axes = [free_args_pos[arg] for arg in key.free_args] sum_list.append(permutedims(data, axes)) return reduce(lambda x, y: x+y, sum_list) return None @staticmethod def data_contract_dum(ndarray_list, dum, ext_rank): from .array import tensorproduct, tensorcontraction, MutableDenseNDimArray arrays = list(map(MutableDenseNDimArray, ndarray_list)) prodarr = tensorproduct(*arrays) return tensorcontraction(prodarr, *dum) def data_tensorhead_from_tensmul(self, data, tensmul, tensorhead): """ This method is used when assigning components data to a ``TensMul`` object, it converts components data to a fully contravariant ndarray, which is then stored according to the ``TensorHead`` key. """ if data is None: return None return self._correct_signature_from_indices( data, tensmul.get_indices(), tensmul.free, tensmul.dum, True) def data_from_tensor(self, tensor): """ This method corrects the components data to the right signature (covariant/contravariant) using the metric associated with each ``TensorIndexType``. """ tensorhead = tensor.component if tensorhead.data is None: return None return self._correct_signature_from_indices( tensorhead.data, tensor.get_indices(), tensor.free, tensor.dum) def _assign_data_to_tensor_expr(self, key, data): if isinstance(key, TensAdd): raise ValueError('cannot assign data to TensAdd') # here it is assumed that `key` is a `TensMul` instance. if len(key.components) != 1: raise ValueError('cannot assign data to TensMul with multiple components') tensorhead = key.components[0] newdata = self.data_tensorhead_from_tensmul(data, key, tensorhead) return tensorhead, newdata def _check_permutations_on_data(self, tens, data): from .array import permutedims if isinstance(tens, TensorHead): rank = tens.rank generators = tens.symmetry.generators elif isinstance(tens, Tensor): rank = tens.rank generators = tens.components[0].symmetry.generators elif isinstance(tens, TensorIndexType): rank = tens.metric.rank generators = tens.metric.symmetry.generators # Every generator is a permutation, check that by permuting the array # by that permutation, the array will be the same, except for a # possible sign change if the permutation admits it. for gener in generators: sign_change = +1 if (gener(rank) == rank) else -1 data_swapped = data last_data = data permute_axes = list(map(gener, list(range(rank)))) # the order of a permutation is the number of times to get the # identity by applying that permutation. for i in range(gener.order()-1): data_swapped = permutedims(data_swapped, permute_axes) # if any value in the difference array is non-zero, raise an error: if any(last_data - sign_change*data_swapped): raise ValueError("Component data symmetry structure error") last_data = data_swapped def __setitem__(self, key, value): """ Set the components data of a tensor object/expression. Components data are transformed to the all-contravariant form and stored with the corresponding ``TensorHead`` object. If a ``TensorHead`` object cannot be uniquely identified, it will raise an error. """ data = _TensorDataLazyEvaluator.parse_data(value) self._check_permutations_on_data(key, data) # TensorHead and TensorIndexType can be assigned data directly, while # TensMul must first convert data to a fully contravariant form, and # assign it to its corresponding TensorHead single component. if not isinstance(key, (TensorHead, TensorIndexType)): key, data = self._assign_data_to_tensor_expr(key, data) if isinstance(key, TensorHead): for dim, indextype in zip(data.shape, key.index_types): if indextype.data is None: raise ValueError("index type {} has no components data"\ " associated (needed to raise/lower index)".format(indextype)) if indextype.dim is None: continue if dim != indextype.dim: raise ValueError("wrong dimension of ndarray") self._substitutions_dict[key] = data def __delitem__(self, key): del self._substitutions_dict[key] def __contains__(self, key): return key in self._substitutions_dict def add_metric_data(self, metric, data): """ Assign data to the ``metric`` tensor. The metric tensor behaves in an anomalous way when raising and lowering indices. A fully covariant metric is the inverse transpose of the fully contravariant metric (it is meant matrix inverse). If the metric is symmetric, the transpose is not necessary and mixed covariant/contravariant metrics are Kronecker deltas. """ # hard assignment, data should not be added to `TensorHead` for metric: # the problem with `TensorHead` is that the metric is anomalous, i.e. # raising and lowering the index means considering the metric or its # inverse, this is not the case for other tensors. self._substitutions_dict_tensmul[metric, True, True] = data inverse_transpose = self.inverse_transpose_matrix(data) # in symmetric spaces, the traspose is the same as the original matrix, # the full covariant metric tensor is the inverse transpose, so this # code will be able to handle non-symmetric metrics. self._substitutions_dict_tensmul[metric, False, False] = inverse_transpose # now mixed cases, these are identical to the unit matrix if the metric # is symmetric. m = data.tomatrix() invt = inverse_transpose.tomatrix() self._substitutions_dict_tensmul[metric, True, False] = m * invt self._substitutions_dict_tensmul[metric, False, True] = invt * m @staticmethod def _flip_index_by_metric(data, metric, pos): from .array import tensorproduct, tensorcontraction mdim = metric.rank() ddim = data.rank() if pos == 0: data = tensorcontraction( tensorproduct( metric, data ), (1, mdim+pos) ) else: data = tensorcontraction( tensorproduct( data, metric ), (pos, ddim) ) return data @staticmethod def inverse_matrix(ndarray): m = ndarray.tomatrix().inv() return _TensorDataLazyEvaluator.parse_data(m) @staticmethod def inverse_transpose_matrix(ndarray): m = ndarray.tomatrix().inv().T return _TensorDataLazyEvaluator.parse_data(m) @staticmethod def _correct_signature_from_indices(data, indices, free, dum, inverse=False): """ Utility function to correct the values inside the components data ndarray according to whether indices are covariant or contravariant. It uses the metric matrix to lower values of covariant indices. """ # change the ndarray values according covariantness/contravariantness of the indices # use the metric for i, indx in enumerate(indices): if not indx.is_up and not inverse: data = _TensorDataLazyEvaluator._flip_index_by_metric(data, indx.tensor_index_type.data, i) elif not indx.is_up and inverse: data = _TensorDataLazyEvaluator._flip_index_by_metric( data, _TensorDataLazyEvaluator.inverse_matrix(indx.tensor_index_type.data), i ) return data @staticmethod def _sort_data_axes(old, new): from .array import permutedims new_data = old.data.copy() old_free = [i[0] for i in old.free] new_free = [i[0] for i in new.free] for i in range(len(new_free)): for j in range(i, len(old_free)): if old_free[j] == new_free[i]: old_free[i], old_free[j] = old_free[j], old_free[i] new_data = permutedims(new_data, (i, j)) break return new_data @staticmethod def add_rearrange_tensmul_parts(new_tensmul, old_tensmul): def sorted_compo(): return _TensorDataLazyEvaluator._sort_data_axes(old_tensmul, new_tensmul) _TensorDataLazyEvaluator._substitutions_dict[new_tensmul] = sorted_compo() @staticmethod def parse_data(data): """ Transform ``data`` to array. The parameter ``data`` may contain data in various formats, e.g. nested lists, sympy ``Matrix``, and so on. Examples ======== >>> from sympy.tensor.tensor import _TensorDataLazyEvaluator >>> _TensorDataLazyEvaluator.parse_data([1, 3, -6, 12]) [1, 3, -6, 12] >>> _TensorDataLazyEvaluator.parse_data([[1, 2], [4, 7]]) [[1, 2], [4, 7]] """ from .array import MutableDenseNDimArray if not isinstance(data, MutableDenseNDimArray): if len(data) == 2 and hasattr(data[0], '__call__'): data = MutableDenseNDimArray(data[0], data[1]) else: data = MutableDenseNDimArray(data) return data _tensor_data_substitution_dict = _TensorDataLazyEvaluator() class _TensorManager(object): """ Class to manage tensor properties. Notes ===== Tensors belong to tensor commutation groups; each group has a label ``comm``; there are predefined labels: ``0`` tensors commuting with any other tensor ``1`` tensors anticommuting among themselves ``2`` tensors not commuting, apart with those with ``comm=0`` Other groups can be defined using ``set_comm``; tensors in those groups commute with those with ``comm=0``; by default they do not commute with any other group. """ def __init__(self): self._comm_init() def _comm_init(self): self._comm = [{} for i in range(3)] for i in range(3): self._comm[0][i] = 0 self._comm[i][0] = 0 self._comm[1][1] = 1 self._comm[2][1] = None self._comm[1][2] = None self._comm_symbols2i = {0:0, 1:1, 2:2} self._comm_i2symbol = {0:0, 1:1, 2:2} @property def comm(self): return self._comm def comm_symbols2i(self, i): """ get the commutation group number corresponding to ``i`` ``i`` can be a symbol or a number or a string If ``i`` is not already defined its commutation group number is set. """ if i not in self._comm_symbols2i: n = len(self._comm) self._comm.append({}) self._comm[n][0] = 0 self._comm[0][n] = 0 self._comm_symbols2i[i] = n self._comm_i2symbol[n] = i return n return self._comm_symbols2i[i] def comm_i2symbol(self, i): """ Returns the symbol corresponding to the commutation group number. """ return self._comm_i2symbol[i] def set_comm(self, i, j, c): """ set the commutation parameter ``c`` for commutation groups ``i, j`` Parameters ========== i, j : symbols representing commutation groups c : group commutation number Notes ===== ``i, j`` can be symbols, strings or numbers, apart from ``0, 1`` and ``2`` which are reserved respectively for commuting, anticommuting tensors and tensors not commuting with any other group apart with the commuting tensors. For the remaining cases, use this method to set the commutation rules; by default ``c=None``. The group commutation number ``c`` is assigned in correspondence to the group commutation symbols; it can be 0 commuting 1 anticommuting None no commutation property Examples ======== ``G`` and ``GH`` do not commute with themselves and commute with each other; A is commuting. >>> from sympy.tensor.tensor import TensorIndexType, tensor_indices, tensorhead, TensorManager >>> Lorentz = TensorIndexType('Lorentz') >>> i0,i1,i2,i3,i4 = tensor_indices('i0:5', Lorentz) >>> A = tensorhead('A', [Lorentz], [[1]]) >>> G = tensorhead('G', [Lorentz], [[1]], 'Gcomm') >>> GH = tensorhead('GH', [Lorentz], [[1]], 'GHcomm') >>> TensorManager.set_comm('Gcomm', 'GHcomm', 0) >>> (GH(i1)*G(i0)).canon_bp() G(i0)*GH(i1) >>> (G(i1)*G(i0)).canon_bp() G(i1)*G(i0) >>> (G(i1)*A(i0)).canon_bp() A(i0)*G(i1) """ if c not in (0, 1, None): raise ValueError('`c` can assume only the values 0, 1 or None') if i not in self._comm_symbols2i: n = len(self._comm) self._comm.append({}) self._comm[n][0] = 0 self._comm[0][n] = 0 self._comm_symbols2i[i] = n self._comm_i2symbol[n] = i if j not in self._comm_symbols2i: n = len(self._comm) self._comm.append({}) self._comm[0][n] = 0 self._comm[n][0] = 0 self._comm_symbols2i[j] = n self._comm_i2symbol[n] = j ni = self._comm_symbols2i[i] nj = self._comm_symbols2i[j] self._comm[ni][nj] = c self._comm[nj][ni] = c def set_comms(self, *args): """ set the commutation group numbers ``c`` for symbols ``i, j`` Parameters ========== args : sequence of ``(i, j, c)`` """ for i, j, c in args: self.set_comm(i, j, c) def get_comm(self, i, j): """ Return the commutation parameter for commutation group numbers ``i, j`` see ``_TensorManager.set_comm`` """ return self._comm[i].get(j, 0 if i == 0 or j == 0 else None) def clear(self): """ Clear the TensorManager. """ self._comm_init() TensorManager = _TensorManager() class TensorIndexType(Basic): """ A TensorIndexType is characterized by its name and its metric. Parameters ========== name : name of the tensor type metric : metric symmetry or metric object or ``None`` dim : dimension, it can be a symbol or an integer or ``None`` eps_dim : dimension of the epsilon tensor dummy_fmt : name of the head of dummy indices Attributes ========== ``name`` ``metric_name`` : it is 'metric' or metric.name ``metric_antisym`` ``metric`` : the metric tensor ``delta`` : ``Kronecker delta`` ``epsilon`` : the ``Levi-Civita epsilon`` tensor ``dim`` ``eps_dim`` ``dummy_fmt`` ``data`` : a property to add ``ndarray`` values, to work in a specified basis. Notes ===== The ``metric`` parameter can be: ``metric = False`` symmetric metric (in Riemannian geometry) ``metric = True`` antisymmetric metric (for spinor calculus) ``metric = None`` there is no metric ``metric`` can be an object having ``name`` and ``antisym`` attributes. If there is a metric the metric is used to raise and lower indices. In the case of antisymmetric metric, the following raising and lowering conventions will be adopted: ``psi(a) = g(a, b)*psi(-b); chi(-a) = chi(b)*g(-b, -a)`` ``g(-a, b) = delta(-a, b); g(b, -a) = -delta(a, -b)`` where ``delta(-a, b) = delta(b, -a)`` is the ``Kronecker delta`` (see ``TensorIndex`` for the conventions on indices). If there is no metric it is not possible to raise or lower indices; e.g. the index of the defining representation of ``SU(N)`` is 'covariant' and the conjugate representation is 'contravariant'; for ``N > 2`` they are linearly independent. ``eps_dim`` is by default equal to ``dim``, if the latter is an integer; else it can be assigned (for use in naive dimensional regularization); if ``eps_dim`` is not an integer ``epsilon`` is ``None``. Examples ======== >>> from sympy.tensor.tensor import TensorIndexType >>> Lorentz = TensorIndexType('Lorentz', dummy_fmt='L') >>> Lorentz.metric metric(Lorentz,Lorentz) """ def __new__(cls, name, metric=False, dim=None, eps_dim=None, dummy_fmt=None): if isinstance(name, string_types): name = Symbol(name) obj = Basic.__new__(cls, name, S.One if metric else S.Zero) obj._name = str(name) if not dummy_fmt: obj._dummy_fmt = '%s_%%d' % obj.name else: obj._dummy_fmt = '%s_%%d' % dummy_fmt if metric is None: obj.metric_antisym = None obj.metric = None else: if metric in (True, False, 0, 1): metric_name = 'metric' obj.metric_antisym = metric else: metric_name = metric.name obj.metric_antisym = metric.antisym sym2 = TensorSymmetry(get_symmetric_group_sgs(2, obj.metric_antisym)) S2 = TensorType([obj]*2, sym2) obj.metric = S2(metric_name) obj._dim = dim obj._delta = obj.get_kronecker_delta() obj._eps_dim = eps_dim if eps_dim else dim obj._epsilon = obj.get_epsilon() obj._autogenerated = [] return obj @property @deprecated(useinstead="TensorIndex", issue=12857, deprecated_since_version="1.1") def auto_right(self): if not hasattr(self, '_auto_right'): self._auto_right = TensorIndex("auto_right", self) return self._auto_right @property @deprecated(useinstead="TensorIndex", issue=12857, deprecated_since_version="1.1") def auto_left(self): if not hasattr(self, '_auto_left'): self._auto_left = TensorIndex("auto_left", self) return self._auto_left @property @deprecated(useinstead="TensorIndex", issue=12857, deprecated_since_version="1.1") def auto_index(self): if not hasattr(self, '_auto_index'): self._auto_index = TensorIndex("auto_index", self) return self._auto_index @property def data(self): deprecate_data() return _tensor_data_substitution_dict[self] @data.setter def data(self, data): deprecate_data() # This assignment is a bit controversial, should metric components be assigned # to the metric only or also to the TensorIndexType object? The advantage here # is the ability to assign a 1D array and transform it to a 2D diagonal array. from .array import MutableDenseNDimArray data = _TensorDataLazyEvaluator.parse_data(data) if data.rank() > 2: raise ValueError("data have to be of rank 1 (diagonal metric) or 2.") if data.rank() == 1: if self.dim is not None: nda_dim = data.shape[0] if nda_dim != self.dim: raise ValueError("Dimension mismatch") dim = data.shape[0] newndarray = MutableDenseNDimArray.zeros(dim, dim) for i, val in enumerate(data): newndarray[i, i] = val data = newndarray dim1, dim2 = data.shape if dim1 != dim2: raise ValueError("Non-square matrix tensor.") if self.dim is not None: if self.dim != dim1: raise ValueError("Dimension mismatch") _tensor_data_substitution_dict[self] = data _tensor_data_substitution_dict.add_metric_data(self.metric, data) delta = self.get_kronecker_delta() i1 = TensorIndex('i1', self) i2 = TensorIndex('i2', self) delta(i1, -i2).data = _TensorDataLazyEvaluator.parse_data(eye(dim1)) @data.deleter def data(self): deprecate_data() if self in _tensor_data_substitution_dict: del _tensor_data_substitution_dict[self] if self.metric in _tensor_data_substitution_dict: del _tensor_data_substitution_dict[self.metric] def _get_matrix_fmt(self, number): return ("m" + self.dummy_fmt) % (number) @property def name(self): return self._name @property def dim(self): return self._dim @property def delta(self): return self._delta @property def eps_dim(self): return self._eps_dim @property def epsilon(self): return self._epsilon @property def dummy_fmt(self): return self._dummy_fmt def get_kronecker_delta(self): sym2 = TensorSymmetry(get_symmetric_group_sgs(2)) S2 = TensorType([self]*2, sym2) delta = S2('KD') return delta def get_epsilon(self): if not isinstance(self._eps_dim, (SYMPY_INTS, Integer)): return None sym = TensorSymmetry(get_symmetric_group_sgs(self._eps_dim, 1)) Sdim = TensorType([self]*self._eps_dim, sym) epsilon = Sdim('Eps') return epsilon def __lt__(self, other): return self.name < other.name def __str__(self): return self.name __repr__ = __str__ def _components_data_full_destroy(self): """ EXPERIMENTAL: do not rely on this API method. This destroys components data associated to the ``TensorIndexType``, if any, specifically: * metric tensor data * Kronecker tensor data """ if self in _tensor_data_substitution_dict: del _tensor_data_substitution_dict[self] def delete_tensmul_data(key): if key in _tensor_data_substitution_dict._substitutions_dict_tensmul: del _tensor_data_substitution_dict._substitutions_dict_tensmul[key] # delete metric data: delete_tensmul_data((self.metric, True, True)) delete_tensmul_data((self.metric, True, False)) delete_tensmul_data((self.metric, False, True)) delete_tensmul_data((self.metric, False, False)) # delete delta tensor data: delta = self.get_kronecker_delta() if delta in _tensor_data_substitution_dict: del _tensor_data_substitution_dict[delta] class TensorIndex(Basic): """ Represents an abstract tensor index. Parameters ========== name : name of the index, or ``True`` if you want it to be automatically assigned tensortype : ``TensorIndexType`` of the index is_up : flag for contravariant index Attributes ========== ``name`` ``tensortype`` ``is_up`` Notes ===== Tensor indices are contracted with the Einstein summation convention. An index can be in contravariant or in covariant form; in the latter case it is represented prepending a ``-`` to the index name. Dummy indices have a name with head given by ``tensortype._dummy_fmt`` Examples ======== >>> from sympy.tensor.tensor import TensorIndexType, TensorIndex, TensorSymmetry, TensorType, get_symmetric_group_sgs >>> Lorentz = TensorIndexType('Lorentz', dummy_fmt='L') >>> i = TensorIndex('i', Lorentz); i i >>> sym1 = TensorSymmetry(*get_symmetric_group_sgs(1)) >>> S1 = TensorType([Lorentz], sym1) >>> A, B = S1('A,B') >>> A(i)*B(-i) A(L_0)*B(-L_0) If you want the index name to be automatically assigned, just put ``True`` in the ``name`` field, it will be generated using the reserved character ``_`` in front of its name, in order to avoid conflicts with possible existing indices: >>> i0 = TensorIndex(True, Lorentz) >>> i0 _i0 >>> i1 = TensorIndex(True, Lorentz) >>> i1 _i1 >>> A(i0)*B(-i1) A(_i0)*B(-_i1) >>> A(i0)*B(-i0) A(L_0)*B(-L_0) """ def __new__(cls, name, tensortype, is_up=True): if isinstance(name, string_types): name_symbol = Symbol(name) elif isinstance(name, Symbol): name_symbol = name elif name is True: name = "_i{0}".format(len(tensortype._autogenerated)) name_symbol = Symbol(name) tensortype._autogenerated.append(name_symbol) else: raise ValueError("invalid name") is_up = sympify(is_up) obj = Basic.__new__(cls, name_symbol, tensortype, is_up) obj._name = str(name) obj._tensor_index_type = tensortype obj._is_up = is_up return obj @property def name(self): return self._name @property @deprecated(useinstead="tensor_index_type", issue=12857, deprecated_since_version="1.1") def tensortype(self): return self.tensor_index_type @property def tensor_index_type(self): return self._tensor_index_type @property def is_up(self): return self._is_up def _print(self): s = self._name if not self._is_up: s = '-%s' % s return s def __lt__(self, other): return (self.tensor_index_type, self._name) < (other.tensor_index_type, other._name) def __neg__(self): t1 = TensorIndex(self.name, self.tensor_index_type, (not self.is_up)) return t1 def tensor_indices(s, typ): """ Returns list of tensor indices given their names and their types Parameters ========== s : string of comma separated names of indices typ : ``TensorIndexType`` of the indices Examples ======== >>> from sympy.tensor.tensor import TensorIndexType, tensor_indices >>> Lorentz = TensorIndexType('Lorentz', dummy_fmt='L') >>> a, b, c, d = tensor_indices('a,b,c,d', Lorentz) """ if isinstance(s, string_types): a = [x.name for x in symbols(s, seq=True)] else: raise ValueError('expecting a string') tilist = [TensorIndex(i, typ) for i in a] if len(tilist) == 1: return tilist[0] return tilist class TensorSymmetry(Basic): """ Monoterm symmetry of a tensor Parameters ========== bsgs : tuple ``(base, sgs)`` BSGS of the symmetry of the tensor Attributes ========== ``base`` : base of the BSGS ``generators`` : generators of the BSGS ``rank`` : rank of the tensor Notes ===== A tensor can have an arbitrary monoterm symmetry provided by its BSGS. Multiterm symmetries, like the cyclic symmetry of the Riemann tensor, are not covered. See Also ======== sympy.combinatorics.tensor_can.get_symmetric_group_sgs Examples ======== Define a symmetric tensor >>> from sympy.tensor.tensor import TensorIndexType, TensorSymmetry, TensorType, get_symmetric_group_sgs >>> Lorentz = TensorIndexType('Lorentz', dummy_fmt='L') >>> sym2 = TensorSymmetry(get_symmetric_group_sgs(2)) >>> S2 = TensorType([Lorentz]*2, sym2) >>> V = S2('V') """ def __new__(cls, *args, **kw_args): if len(args) == 1: base, generators = args[0] elif len(args) == 2: base, generators = args else: raise TypeError("bsgs required, either two separate parameters or one tuple") if not isinstance(base, Tuple): base = Tuple(*base) if not isinstance(generators, Tuple): generators = Tuple(*generators) obj = Basic.__new__(cls, base, generators, **kw_args) return obj @property def base(self): return self.args[0] @property def generators(self): return self.args[1] @property def rank(self): return self.args[1][0].size - 2 def tensorsymmetry(*args): """ Return a ``TensorSymmetry`` object. One can represent a tensor with any monoterm slot symmetry group using a BSGS. ``args`` can be a BSGS ``args[0]`` base ``args[1]`` sgs Usually tensors are in (direct products of) representations of the symmetric group; ``args`` can be a list of lists representing the shapes of Young tableaux Notes ===== For instance: ``[[1]]`` vector ``[[1]*n]`` symmetric tensor of rank ``n`` ``[[n]]`` antisymmetric tensor of rank ``n`` ``[[2, 2]]`` monoterm slot symmetry of the Riemann tensor ``[[1],[1]]`` vector*vector ``[[2],[1],[1]`` (antisymmetric tensor)*vector*vector Notice that with the shape ``[2, 2]`` we associate only the monoterm symmetries of the Riemann tensor; this is an abuse of notation, since the shape ``[2, 2]`` corresponds usually to the irreducible representation characterized by the monoterm symmetries and by the cyclic symmetry. Examples ======== Symmetric tensor using a Young tableau >>> from sympy.tensor.tensor import TensorIndexType, TensorType, tensorsymmetry >>> Lorentz = TensorIndexType('Lorentz', dummy_fmt='L') >>> sym2 = tensorsymmetry([1, 1]) >>> S2 = TensorType([Lorentz]*2, sym2) >>> V = S2('V') Symmetric tensor using a ``BSGS`` (base, strong generator set) >>> from sympy.tensor.tensor import get_symmetric_group_sgs >>> sym2 = tensorsymmetry(*get_symmetric_group_sgs(2)) >>> S2 = TensorType([Lorentz]*2, sym2) >>> V = S2('V') """ from sympy.combinatorics import Permutation def tableau2bsgs(a): if len(a) == 1: # antisymmetric vector n = a[0] bsgs = get_symmetric_group_sgs(n, 1) else: if all(x == 1 for x in a): # symmetric vector n = len(a) bsgs = get_symmetric_group_sgs(n) elif a == [2, 2]: bsgs = riemann_bsgs else: raise NotImplementedError return bsgs if not args: return TensorSymmetry(Tuple(), Tuple(Permutation(1))) if len(args) == 2 and isinstance(args[1][0], Permutation): return TensorSymmetry(args) base, sgs = tableau2bsgs(args[0]) for a in args[1:]: basex, sgsx = tableau2bsgs(a) base, sgs = bsgs_direct_product(base, sgs, basex, sgsx) return TensorSymmetry(Tuple(base, sgs)) class TensorType(Basic): """ Class of tensor types. Parameters ========== index_types : list of ``TensorIndexType`` of the tensor indices symmetry : ``TensorSymmetry`` of the tensor Attributes ========== ``index_types`` ``symmetry`` ``types`` : list of ``TensorIndexType`` without repetitions Examples ======== Define a symmetric tensor >>> from sympy.tensor.tensor import TensorIndexType, tensorsymmetry, TensorType >>> Lorentz = TensorIndexType('Lorentz', dummy_fmt='L') >>> sym2 = tensorsymmetry([1, 1]) >>> S2 = TensorType([Lorentz]*2, sym2) >>> V = S2('V') """ is_commutative = False def __new__(cls, index_types, symmetry, **kw_args): assert symmetry.rank == len(index_types) obj = Basic.__new__(cls, Tuple(*index_types), symmetry, **kw_args) return obj @property def index_types(self): return self.args[0] @property def symmetry(self): return self.args[1] @property def types(self): return sorted(set(self.index_types), key=lambda x: x.name) def __str__(self): return 'TensorType(%s)' % ([str(x) for x in self.index_types]) def __call__(self, s, comm=0): """ Return a TensorHead object or a list of TensorHead objects. ``s`` name or string of names ``comm``: commutation group number see ``_TensorManager.set_comm`` Examples ======== Define symmetric tensors ``V``, ``W`` and ``G``, respectively commuting, anticommuting and with no commutation symmetry >>> from sympy.tensor.tensor import TensorIndexType, tensor_indices, tensorsymmetry, TensorType, canon_bp >>> Lorentz = TensorIndexType('Lorentz', dummy_fmt='L') >>> a, b = tensor_indices('a,b', Lorentz) >>> sym2 = tensorsymmetry([1]*2) >>> S2 = TensorType([Lorentz]*2, sym2) >>> V = S2('V') >>> W = S2('W', 1) >>> G = S2('G', 2) >>> canon_bp(V(a, b)*V(-b, -a)) V(L_0, L_1)*V(-L_0, -L_1) >>> canon_bp(W(a, b)*W(-b, -a)) 0 """ if isinstance(s, string_types): names = [x.name for x in symbols(s, seq=True)] else: raise ValueError('expecting a string') if len(names) == 1: return TensorHead(names[0], self, comm) else: return [TensorHead(name, self, comm) for name in names] def tensorhead(name, typ, sym=None, comm=0): """ Function generating tensorhead(s). Parameters ========== name : name or sequence of names (as in ``symbol``) typ : index types sym : same as ``*args`` in ``tensorsymmetry`` comm : commutation group number see ``_TensorManager.set_comm`` Examples ======== >>> from sympy.tensor.tensor import TensorIndexType, tensor_indices, tensorhead >>> Lorentz = TensorIndexType('Lorentz', dummy_fmt='L') >>> a, b = tensor_indices('a,b', Lorentz) >>> A = tensorhead('A', [Lorentz]*2, [[1]*2]) >>> A(a, -b) A(a, -b) If no symmetry parameter is provided, assume there are not index symmetries: >>> B = tensorhead('B', [Lorentz, Lorentz]) >>> B(a, -b) B(a, -b) """ if sym is None: sym = [[1] for i in range(len(typ))] sym = tensorsymmetry(*sym) S = TensorType(typ, sym) th = S(name, comm) return th class TensorHead(Basic): r""" Tensor head of the tensor Parameters ========== name : name of the tensor typ : list of TensorIndexType comm : commutation group number Attributes ========== ``name`` ``index_types`` ``rank`` ``types`` : equal to ``typ.types`` ``symmetry`` : equal to ``typ.symmetry`` ``comm`` : commutation group Notes ===== A ``TensorHead`` belongs to a commutation group, defined by a symbol on number ``comm`` (see ``_TensorManager.set_comm``); tensors in a commutation group have the same commutation properties; by default ``comm`` is ``0``, the group of the commuting tensors. Examples ======== >>> from sympy.tensor.tensor import TensorIndexType, tensorhead, TensorType >>> Lorentz = TensorIndexType('Lorentz', dummy_fmt='L') >>> A = tensorhead('A', [Lorentz, Lorentz], [[1],[1]]) Examples with ndarray values, the components data assigned to the ``TensorHead`` object are assumed to be in a fully-contravariant representation. In case it is necessary to assign components data which represents the values of a non-fully covariant tensor, see the other examples. >>> from sympy.tensor.tensor import tensor_indices, tensorhead >>> from sympy import diag >>> i0, i1 = tensor_indices('i0:2', Lorentz) Specify a replacement dictionary to keep track of the arrays to use for replacements in the tensorial expression. The ``TensorIndexType`` is associated to the metric used for contractions (in fully covariant form): >>> repl = {Lorentz: diag(1, -1, -1, -1)} Let's see some examples of working with components with the electromagnetic tensor: >>> from sympy import symbols >>> Ex, Ey, Ez, Bx, By, Bz = symbols('E_x E_y E_z B_x B_y B_z') >>> c = symbols('c', positive=True) Let's define `F`, an antisymmetric tensor, we have to assign an antisymmetric matrix to it, because `[[2]]` stands for the Young tableau representation of an antisymmetric set of two elements: >>> F = tensorhead('F', [Lorentz, Lorentz], [[2]]) Let's update the dictionary to contain the matrix to use in the replacements: >>> repl.update({F(-i0, -i1): [ ... [0, Ex/c, Ey/c, Ez/c], ... [-Ex/c, 0, -Bz, By], ... [-Ey/c, Bz, 0, -Bx], ... [-Ez/c, -By, Bx, 0]]}) Now it is possible to retrieve the contravariant form of the Electromagnetic tensor: >>> F(i0, i1).replace_with_arrays(repl, [i0, i1]) [[0, -E_x/c, -E_y/c, -E_z/c], [E_x/c, 0, -B_z, B_y], [E_y/c, B_z, 0, -B_x], [E_z/c, -B_y, B_x, 0]] and the mixed contravariant-covariant form: >>> F(i0, -i1).replace_with_arrays(repl, [i0, -i1]) [[0, E_x/c, E_y/c, E_z/c], [E_x/c, 0, B_z, -B_y], [E_y/c, -B_z, 0, B_x], [E_z/c, B_y, -B_x, 0]] Energy-momentum of a particle may be represented as: >>> from sympy import symbols >>> P = tensorhead('P', [Lorentz], [[1]]) >>> E, px, py, pz = symbols('E p_x p_y p_z', positive=True) >>> repl.update({P(i0): [E, px, py, pz]}) The contravariant and covariant components are, respectively: >>> P(i0).replace_with_arrays(repl, [i0]) [E, p_x, p_y, p_z] >>> P(-i0).replace_with_arrays(repl, [-i0]) [E, -p_x, -p_y, -p_z] The contraction of a 1-index tensor by itself: >>> expr = P(i0)*P(-i0) >>> expr.replace_with_arrays(repl, []) E**2 - p_x**2 - p_y**2 - p_z**2 """ is_commutative = False def __new__(cls, name, typ, comm=0, **kw_args): if isinstance(name, string_types): name_symbol = Symbol(name) elif isinstance(name, Symbol): name_symbol = name else: raise ValueError("invalid name") comm2i = TensorManager.comm_symbols2i(comm) obj = Basic.__new__(cls, name_symbol, typ, **kw_args) obj._name = obj.args[0].name obj._rank = len(obj.index_types) obj._symmetry = typ.symmetry obj._comm = comm2i return obj @property def name(self): return self._name @property def rank(self): return self._rank @property def symmetry(self): return self._symmetry @property def typ(self): return self.args[1] @property def comm(self): return self._comm @property def types(self): return self.args[1].types[:] @property def index_types(self): return self.args[1].index_types[:] def __lt__(self, other): return (self.name, self.index_types) < (other.name, other.index_types) def commutes_with(self, other): """ Returns ``0`` if ``self`` and ``other`` commute, ``1`` if they anticommute. Returns ``None`` if ``self`` and ``other`` neither commute nor anticommute. """ r = TensorManager.get_comm(self._comm, other._comm) return r def _print(self): return '%s(%s)' %(self.name, ','.join([str(x) for x in self.index_types])) def __call__(self, *indices, **kw_args): """ Returns a tensor with indices. There is a special behavior in case of indices denoted by ``True``, they are considered auto-matrix indices, their slots are automatically filled, and confer to the tensor the behavior of a matrix or vector upon multiplication with another tensor containing auto-matrix indices of the same ``TensorIndexType``. This means indices get summed over the same way as in matrix multiplication. For matrix behavior, define two auto-matrix indices, for vector behavior define just one. Examples ======== >>> from sympy.tensor.tensor import TensorIndexType, tensor_indices, tensorhead >>> Lorentz = TensorIndexType('Lorentz', dummy_fmt='L') >>> a, b = tensor_indices('a,b', Lorentz) >>> A = tensorhead('A', [Lorentz]*2, [[1]*2]) >>> t = A(a, -b) >>> t A(a, -b) """ tensor = Tensor(self, indices, **kw_args) return tensor.doit() def __pow__(self, other): with warnings.catch_warnings(): warnings.filterwarnings("ignore", category=SymPyDeprecationWarning) if self.data is None: raise ValueError("No power on abstract tensors.") deprecate_data() from .array import tensorproduct, tensorcontraction metrics = [_.data for _ in self.args[1].args[0]] marray = self.data marraydim = marray.rank() for metric in metrics: marray = tensorproduct(marray, metric, marray) marray = tensorcontraction(marray, (0, marraydim), (marraydim+1, marraydim+2)) return marray ** (Rational(1, 2) * other) @property def data(self): deprecate_data() return _tensor_data_substitution_dict[self] @data.setter def data(self, data): deprecate_data() _tensor_data_substitution_dict[self] = data @data.deleter def data(self): deprecate_data() if self in _tensor_data_substitution_dict: del _tensor_data_substitution_dict[self] def __iter__(self): deprecate_data() return self.data.__iter__() def _components_data_full_destroy(self): """ EXPERIMENTAL: do not rely on this API method. Destroy components data associated to the ``TensorHead`` object, this checks for attached components data, and destroys components data too. """ # do not garbage collect Kronecker tensor (it should be done by # ``TensorIndexType`` garbage collection) if self.name == "KD": return # the data attached to a tensor must be deleted only by the TensorHead # destructor. If the TensorHead is deleted, it means that there are no # more instances of that tensor anywhere. if self in _tensor_data_substitution_dict: del _tensor_data_substitution_dict[self] def _get_argtree_pos(expr, pos): for p in pos: expr = expr.args[p] return expr class TensExpr(Expr): """ Abstract base class for tensor expressions Notes ===== A tensor expression is an expression formed by tensors; currently the sums of tensors are distributed. A ``TensExpr`` can be a ``TensAdd`` or a ``TensMul``. ``TensAdd`` objects are put in canonical form using the Butler-Portugal algorithm for canonicalization under monoterm symmetries. ``TensMul`` objects are formed by products of component tensors, and include a coefficient, which is a SymPy expression. In the internal representation contracted indices are represented by ``(ipos1, ipos2, icomp1, icomp2)``, where ``icomp1`` is the position of the component tensor with contravariant index, ``ipos1`` is the slot which the index occupies in that component tensor. Contracted indices are therefore nameless in the internal representation. """ _op_priority = 12.0 is_commutative = False def __neg__(self): return self*S.NegativeOne def __abs__(self): raise NotImplementedError def __add__(self, other): return TensAdd(self, other).doit() def __radd__(self, other): return TensAdd(other, self).doit() def __sub__(self, other): return TensAdd(self, -other).doit() def __rsub__(self, other): return TensAdd(other, -self).doit() def __mul__(self, other): """ Multiply two tensors using Einstein summation convention. If the two tensors have an index in common, one contravariant and the other covariant, in their product the indices are summed Examples ======== >>> from sympy.tensor.tensor import TensorIndexType, tensor_indices, tensorhead >>> Lorentz = TensorIndexType('Lorentz', dummy_fmt='L') >>> m0, m1, m2 = tensor_indices('m0,m1,m2', Lorentz) >>> g = Lorentz.metric >>> p, q = tensorhead('p,q', [Lorentz], [[1]]) >>> t1 = p(m0) >>> t2 = q(-m0) >>> t1*t2 p(L_0)*q(-L_0) """ return TensMul(self, other).doit() def __rmul__(self, other): return TensMul(other, self).doit() def __div__(self, other): other = _sympify(other) if isinstance(other, TensExpr): raise ValueError('cannot divide by a tensor') return TensMul(self, S.One/other).doit() def __rdiv__(self, other): raise ValueError('cannot divide by a tensor') def __pow__(self, other): with warnings.catch_warnings(): warnings.filterwarnings("ignore", category=SymPyDeprecationWarning) if self.data is None: raise ValueError("No power without ndarray data.") deprecate_data() from .array import tensorproduct, tensorcontraction free = self.free marray = self.data mdim = marray.rank() for metric in free: marray = tensorcontraction( tensorproduct( marray, metric[0].tensor_index_type.data, marray), (0, mdim), (mdim+1, mdim+2) ) return marray ** (Rational(1, 2) * other) def __rpow__(self, other): raise NotImplementedError __truediv__ = __div__ __rtruediv__ = __rdiv__ def fun_eval(self, *index_tuples): """ Return a tensor with free indices substituted according to ``index_tuples`` ``index_types`` list of tuples ``(old_index, new_index)`` Examples ======== >>> from sympy.tensor.tensor import TensorIndexType, tensor_indices, tensorhead >>> Lorentz = TensorIndexType('Lorentz', dummy_fmt='L') >>> i, j, k, l = tensor_indices('i,j,k,l', Lorentz) >>> A, B = tensorhead('A,B', [Lorentz]*2, [[1]*2]) >>> t = A(i, k)*B(-k, -j); t A(i, L_0)*B(-L_0, -j) >>> t.fun_eval((i, k),(-j, l)) A(k, L_0)*B(-L_0, l) """ expr = self.xreplace(dict(index_tuples)) expr = expr.replace(lambda x: isinstance(x, Tensor), lambda x: x.args[0](*x.args[1])) # For some reason, `TensMul` gets replaced by `Mul`, correct it: expr = expr.replace(lambda x: isinstance(x, (Mul, TensMul)), lambda x: TensMul(*x.args).doit()) return expr def get_matrix(self): """ DEPRECATED: do not use. Returns ndarray components data as a matrix, if components data are available and ndarray dimension does not exceed 2. """ from sympy import Matrix deprecate_data() if 0 < self.rank <= 2: rows = self.data.shape[0] columns = self.data.shape[1] if self.rank == 2 else 1 if self.rank == 2: mat_list = [] * rows for i in range(rows): mat_list.append([]) for j in range(columns): mat_list[i].append(self[i, j]) else: mat_list = [None] * rows for i in range(rows): mat_list[i] = self[i] return Matrix(mat_list) else: raise NotImplementedError( "missing multidimensional reduction to matrix.") @staticmethod def _get_indices_permutation(indices1, indices2): return [indices1.index(i) for i in indices2] def expand(self, **hints): return _expand(self, **hints).doit() def _expand(self, **kwargs): return self def _get_free_indices_set(self): indset = set([]) for arg in self.args: if isinstance(arg, TensExpr): indset.update(arg._get_free_indices_set()) return indset def _get_dummy_indices_set(self): indset = set([]) for arg in self.args: if isinstance(arg, TensExpr): indset.update(arg._get_dummy_indices_set()) return indset def _get_indices_set(self): indset = set([]) for arg in self.args: if isinstance(arg, TensExpr): indset.update(arg._get_indices_set()) return indset @property def _iterate_dummy_indices(self): dummy_set = self._get_dummy_indices_set() def recursor(expr, pos): if isinstance(expr, TensorIndex): if expr in dummy_set: yield (expr, pos) elif isinstance(expr, (Tuple, TensExpr)): for p, arg in enumerate(expr.args): for i in recursor(arg, pos+(p,)): yield i return recursor(self, ()) @property def _iterate_free_indices(self): free_set = self._get_free_indices_set() def recursor(expr, pos): if isinstance(expr, TensorIndex): if expr in free_set: yield (expr, pos) elif isinstance(expr, (Tuple, TensExpr)): for p, arg in enumerate(expr.args): for i in recursor(arg, pos+(p,)): yield i return recursor(self, ()) @property def _iterate_indices(self): def recursor(expr, pos): if isinstance(expr, TensorIndex): yield (expr, pos) elif isinstance(expr, (Tuple, TensExpr)): for p, arg in enumerate(expr.args): for i in recursor(arg, pos+(p,)): yield i return recursor(self, ()) @staticmethod def _match_indices_with_other_tensor(array, free_ind1, free_ind2, replacement_dict): from .array import tensorcontraction, tensorproduct, permutedims index_types1 = [i.tensor_index_type for i in free_ind1] # Check if variance of indices needs to be fixed: pos2up = [] pos2down = [] free2remaining = free_ind2[:] for pos1, index1 in enumerate(free_ind1): if index1 in free2remaining: pos2 = free2remaining.index(index1) free2remaining[pos2] = None continue if -index1 in free2remaining: pos2 = free2remaining.index(-index1) free2remaining[pos2] = None free_ind2[pos2] = index1 if index1.is_up: pos2up.append(pos2) else: pos2down.append(pos2) else: index2 = free2remaining[pos1] if index2 is None: raise ValueError("incompatible indices: %s and %s" % (free_ind1, free_ind2)) free2remaining[pos1] = None free_ind2[pos1] = index1 if index1.is_up ^ index2.is_up: if index1.is_up: pos2up.append(pos1) else: pos2down.append(pos1) if len(set(free_ind1) & set(free_ind2)) < len(free_ind1): raise ValueError("incompatible indices: %s and %s" % (free_ind1, free_ind2)) # TODO: add possibility of metric after (spinors) def contract_and_permute(metric, array, pos): array = tensorcontraction(tensorproduct(metric, array), (1, 2+pos)) permu = list(range(len(free_ind1))) permu[0], permu[pos] = permu[pos], permu[0] return permutedims(array, permu) # Raise indices: for pos in pos2up: metric = replacement_dict[index_types1[pos]] metric_inverse = _TensorDataLazyEvaluator.inverse_matrix(metric) array = contract_and_permute(metric_inverse, array, pos) # Lower indices: for pos in pos2down: metric = replacement_dict[index_types1[pos]] array = contract_and_permute(metric, array, pos) if free_ind1: permutation = TensExpr._get_indices_permutation(free_ind2, free_ind1) array = permutedims(array, permutation) if hasattr(array, "rank") and array.rank() == 0: array = array[()] return free_ind2, array def replace_with_arrays(self, replacement_dict, indices=None): """ Replace the tensorial expressions with arrays. The final array will correspond to the N-dimensional array with indices arranged according to ``indices``. Parameters ========== replacement_dict dictionary containing the replacement rules for tensors. indices the index order with respect to which the array is read. The original index order will be used if no value is passed. Examples ======== >>> from sympy.tensor.tensor import TensorIndexType, tensor_indices >>> from sympy.tensor.tensor import tensorhead >>> from sympy import symbols, diag >>> L = TensorIndexType("L") >>> i, j = tensor_indices("i j", L) >>> A = tensorhead("A", [L], [[1]]) >>> A(i).replace_with_arrays({A(i): [1, 2]}, [i]) [1, 2] Since 'indices' is optional, we can also call replace_with_arrays by this way if no specific index order is needed: >>> A(i).replace_with_arrays({A(i): [1, 2]}) [1, 2] >>> expr = A(i)*A(j) >>> expr.replace_with_arrays({A(i): [1, 2]}) [[1, 2], [2, 4]] For contractions, specify the metric of the ``TensorIndexType``, which in this case is ``L``, in its covariant form: >>> expr = A(i)*A(-i) >>> expr.replace_with_arrays({A(i): [1, 2], L: diag(1, -1)}) -3 Symmetrization of an array: >>> H = tensorhead("H", [L, L], [[1], [1]]) >>> a, b, c, d = symbols("a b c d") >>> expr = H(i, j)/2 + H(j, i)/2 >>> expr.replace_with_arrays({H(i, j): [[a, b], [c, d]]}) [[a, b/2 + c/2], [b/2 + c/2, d]] Anti-symmetrization of an array: >>> expr = H(i, j)/2 - H(j, i)/2 >>> repl = {H(i, j): [[a, b], [c, d]]} >>> expr.replace_with_arrays(repl) [[0, b/2 - c/2], [-b/2 + c/2, 0]] The same expression can be read as the transpose by inverting ``i`` and ``j``: >>> expr.replace_with_arrays(repl, [j, i]) [[0, -b/2 + c/2], [b/2 - c/2, 0]] """ from .array import Array indices = indices or [] replacement_dict = {tensor: Array(array) for tensor, array in replacement_dict.items()} # Check dimensions of replaced arrays: for tensor, array in replacement_dict.items(): if isinstance(tensor, TensorIndexType): expected_shape = [tensor.dim for i in range(2)] else: expected_shape = [index_type.dim for index_type in tensor.index_types] if len(expected_shape) != array.rank() or (not all([dim1 == dim2 if dim1 is not None else True for dim1, dim2 in zip(expected_shape, array.shape)])): raise ValueError("shapes for tensor %s expected to be %s, "\ "replacement array shape is %s" % (tensor, expected_shape, array.shape)) ret_indices, array = self._extract_data(replacement_dict) last_indices, array = self._match_indices_with_other_tensor(array, indices, ret_indices, replacement_dict) #permutation = self._get_indices_permutation(indices, ret_indices) #if not hasattr(array, "rank"): #return array #if array.rank() == 0: #array = array[()] #return array #array = permutedims(array, permutation) return array def _check_add_Sum(self, expr, index_symbols): from sympy import Sum indices = self.get_indices() dum = self.dum sum_indices = [ (index_symbols[i], 0, indices[i].tensor_index_type.dim-1) for i, j in dum] if sum_indices: expr = Sum(expr, *sum_indices) return expr class TensAdd(TensExpr, AssocOp): """ Sum of tensors Parameters ========== free_args : list of the free indices Attributes ========== ``args`` : tuple of addends ``rank`` : rank of the tensor ``free_args`` : list of the free indices in sorted order Notes ===== Sum of more than one tensor are put automatically in canonical form. Examples ======== >>> from sympy.tensor.tensor import TensorIndexType, tensorhead, tensor_indices >>> Lorentz = TensorIndexType('Lorentz', dummy_fmt='L') >>> a, b = tensor_indices('a,b', Lorentz) >>> p, q = tensorhead('p,q', [Lorentz], [[1]]) >>> t = p(a) + q(a); t p(a) + q(a) >>> t(b) p(b) + q(b) Examples with components data added to the tensor expression: >>> from sympy import symbols, diag >>> x, y, z, t = symbols("x y z t") >>> repl = {} >>> repl[Lorentz] = diag(1, -1, -1, -1) >>> repl[p(a)] = [1, 2, 3, 4] >>> repl[q(a)] = [x, y, z, t] The following are: 2**2 - 3**2 - 2**2 - 7**2 ==> -58 >>> expr = p(a) + q(a) >>> expr.replace_with_arrays(repl, [a]) [x + 1, y + 2, z + 3, t + 4] """ def __new__(cls, *args, **kw_args): args = [_sympify(x) for x in args if x] args = TensAdd._tensAdd_flatten(args) obj = Basic.__new__(cls, *args, **kw_args) return obj def doit(self, **kwargs): deep = kwargs.get('deep', True) if deep: args = [arg.doit(**kwargs) for arg in self.args] else: args = self.args if not args: return S.Zero if len(args) == 1 and not isinstance(args[0], TensExpr): return args[0] # now check that all addends have the same indices: TensAdd._tensAdd_check(args) # if TensAdd has only 1 element in its `args`: if len(args) == 1: # and isinstance(args[0], TensMul): return args[0] # Remove zeros: args = [x for x in args if x] # if there are no more args (i.e. have cancelled out), # just return zero: if not args: return S.Zero if len(args) == 1: return args[0] # Collect terms appearing more than once, differing by their coefficients: args = TensAdd._tensAdd_collect_terms(args) # collect canonicalized terms def sort_key(t): x = get_index_structure(t) if not isinstance(t, TensExpr): return ([], [], []) return (t.components, x.free, x.dum) args.sort(key=sort_key) if not args: return S.Zero # it there is only a component tensor return it if len(args) == 1: return args[0] obj = self.func(*args) return obj @staticmethod def _tensAdd_flatten(args): # flatten TensAdd, coerce terms which are not tensors to tensors a = [] for x in args: if isinstance(x, (Add, TensAdd)): a.extend(list(x.args)) else: a.append(x) args = [x for x in a if x.coeff] return args @staticmethod def _tensAdd_check(args): # check that all addends have the same free indices indices0 = set([x[0] for x in get_index_structure(args[0]).free]) list_indices = [set([y[0] for y in get_index_structure(x).free]) for x in args[1:]] if not all(x == indices0 for x in list_indices): raise ValueError('all tensors must have the same indices') @staticmethod def _tensAdd_collect_terms(args): # collect TensMul terms differing at most by their coefficient terms_dict = defaultdict(list) scalars = S.Zero if isinstance(args[0], TensExpr): free_indices = set(args[0].get_free_indices()) else: free_indices = set([]) for arg in args: if not isinstance(arg, TensExpr): if free_indices != set([]): raise ValueError("wrong valence") scalars += arg continue if free_indices != set(arg.get_free_indices()): raise ValueError("wrong valence") # TODO: what is the part which is not a coeff? # needs an implementation similar to .as_coeff_Mul() terms_dict[arg.nocoeff].append(arg.coeff) new_args = [TensMul(Add(*coeff), t).doit() for t, coeff in terms_dict.items() if Add(*coeff) != 0] if isinstance(scalars, Add): new_args = list(scalars.args) + new_args elif scalars != 0: new_args = [scalars] + new_args return new_args def get_indices(self): indices = [] for arg in self.args: indices.extend([i for i in get_indices(arg) if i not in indices]) return indices @property def rank(self): return self.args[0].rank @property def free_args(self): return self.args[0].free_args def _expand(self, **hints): return TensAdd(*[_expand(i, **hints) for i in self.args]) def __call__(self, *indices): """Returns tensor with ordered free indices replaced by ``indices`` Parameters ========== indices Examples ======== >>> from sympy import Symbol >>> from sympy.tensor.tensor import TensorIndexType, tensor_indices, tensorhead >>> D = Symbol('D') >>> Lorentz = TensorIndexType('Lorentz', dim=D, dummy_fmt='L') >>> i0,i1,i2,i3,i4 = tensor_indices('i0:5', Lorentz) >>> p, q = tensorhead('p,q', [Lorentz], [[1]]) >>> g = Lorentz.metric >>> t = p(i0)*p(i1) + g(i0,i1)*q(i2)*q(-i2) >>> t(i0,i2) metric(i0, i2)*q(L_0)*q(-L_0) + p(i0)*p(i2) >>> from sympy.tensor.tensor import canon_bp >>> canon_bp(t(i0,i1) - t(i1,i0)) 0 """ free_args = self.free_args indices = list(indices) if [x.tensor_index_type for x in indices] != [x.tensor_index_type for x in free_args]: raise ValueError('incompatible types') if indices == free_args: return self index_tuples = list(zip(free_args, indices)) a = [x.func(*x.fun_eval(*index_tuples).args) for x in self.args] res = TensAdd(*a).doit() return res def canon_bp(self): """ canonicalize using the Butler-Portugal algorithm for canonicalization under monoterm symmetries. """ expr = self.expand() args = [canon_bp(x) for x in expr.args] res = TensAdd(*args).doit() return res def equals(self, other): other = _sympify(other) if isinstance(other, TensMul) and other._coeff == 0: return all(x._coeff == 0 for x in self.args) if isinstance(other, TensExpr): if self.rank != other.rank: return False if isinstance(other, TensAdd): if set(self.args) != set(other.args): return False else: return True t = self - other if not isinstance(t, TensExpr): return t == 0 else: if isinstance(t, TensMul): return t._coeff == 0 else: return all(x._coeff == 0 for x in t.args) def __getitem__(self, item): deprecate_data() return self.data[item] def contract_delta(self, delta): args = [x.contract_delta(delta) for x in self.args] t = TensAdd(*args).doit() return canon_bp(t) def contract_metric(self, g): """ Raise or lower indices with the metric ``g`` Parameters ========== g : metric contract_all : if True, eliminate all ``g`` which are contracted Notes ===== see the ``TensorIndexType`` docstring for the contraction conventions """ args = [contract_metric(x, g) for x in self.args] t = TensAdd(*args).doit() return canon_bp(t) def fun_eval(self, *index_tuples): """ Return a tensor with free indices substituted according to ``index_tuples`` Parameters ========== index_types : list of tuples ``(old_index, new_index)`` Examples ======== >>> from sympy.tensor.tensor import TensorIndexType, tensor_indices, tensorhead >>> Lorentz = TensorIndexType('Lorentz', dummy_fmt='L') >>> i, j, k, l = tensor_indices('i,j,k,l', Lorentz) >>> A, B = tensorhead('A,B', [Lorentz]*2, [[1]*2]) >>> t = A(i, k)*B(-k, -j) + A(i, -j) >>> t.fun_eval((i, k),(-j, l)) A(k, L_0)*B(-L_0, l) + A(k, l) """ args = self.args args1 = [] for x in args: y = x.fun_eval(*index_tuples) args1.append(y) return TensAdd(*args1).doit() def substitute_indices(self, *index_tuples): """ Return a tensor with free indices substituted according to ``index_tuples`` Parameters ========== index_types : list of tuples ``(old_index, new_index)`` Examples ======== >>> from sympy.tensor.tensor import TensorIndexType, tensor_indices, tensorhead >>> Lorentz = TensorIndexType('Lorentz', dummy_fmt='L') >>> i, j, k, l = tensor_indices('i,j,k,l', Lorentz) >>> A, B = tensorhead('A,B', [Lorentz]*2, [[1]*2]) >>> t = A(i, k)*B(-k, -j); t A(i, L_0)*B(-L_0, -j) >>> t.substitute_indices((i,j), (j, k)) A(j, L_0)*B(-L_0, -k) """ args = self.args args1 = [] for x in args: y = x.substitute_indices(*index_tuples) args1.append(y) return TensAdd(*args1).doit() def _print(self): a = [] args = self.args for x in args: a.append(str(x)) a.sort() s = ' + '.join(a) s = s.replace('+ -', '- ') return s def _extract_data(self, replacement_dict): from sympy.tensor.array import Array, permutedims args_indices, arrays = zip(*[ arg._extract_data(replacement_dict) if isinstance(arg, TensExpr) else ([], arg) for arg in self.args ]) arrays = [Array(i) for i in arrays] ref_indices = args_indices[0] for i in range(1, len(args_indices)): indices = args_indices[i] array = arrays[i] permutation = TensMul._get_indices_permutation(indices, ref_indices) arrays[i] = permutedims(array, permutation) return ref_indices, sum(arrays, Array.zeros(*array.shape)) @property def data(self): deprecate_data() return _tensor_data_substitution_dict[self.expand()] @data.setter def data(self, data): deprecate_data() _tensor_data_substitution_dict[self] = data @data.deleter def data(self): deprecate_data() if self in _tensor_data_substitution_dict: del _tensor_data_substitution_dict[self] def __iter__(self): deprecate_data() if not self.data: raise ValueError("No iteration on abstract tensors") return self.data.flatten().__iter__() def _eval_rewrite_as_Indexed(self, *args): return Add.fromiter(args) class Tensor(TensExpr): """ Base tensor class, i.e. this represents a tensor, the single unit to be put into an expression. This object is usually created from a ``TensorHead``, by attaching indices to it. Indices preceded by a minus sign are considered contravariant, otherwise covariant. Examples ======== >>> from sympy.tensor.tensor import TensorIndexType, tensor_indices, tensorhead >>> Lorentz = TensorIndexType("Lorentz", dummy_fmt="L") >>> mu, nu = tensor_indices('mu nu', Lorentz) >>> A = tensorhead("A", [Lorentz, Lorentz], [[1], [1]]) >>> A(mu, -nu) A(mu, -nu) >>> A(mu, -mu) A(L_0, -L_0) """ is_commutative = False def __new__(cls, tensor_head, indices, **kw_args): is_canon_bp = kw_args.pop('is_canon_bp', False) indices = cls._parse_indices(tensor_head, indices) obj = Basic.__new__(cls, tensor_head, Tuple(*indices), **kw_args) obj._index_structure = _IndexStructure.from_indices(*indices) obj._free_indices_set = set(obj._index_structure.get_free_indices()) if tensor_head.rank != len(indices): raise ValueError("wrong number of indices") obj._indices = indices obj._is_canon_bp = is_canon_bp obj._index_map = Tensor._build_index_map(indices, obj._index_structure) return obj @staticmethod def _build_index_map(indices, index_structure): index_map = {} for idx in indices: index_map[idx] = (indices.index(idx),) return index_map def doit(self, **kwargs): args, indices, free, dum = TensMul._tensMul_contract_indices([self]) return args[0] @staticmethod def _parse_indices(tensor_head, indices): if not isinstance(indices, (tuple, list, Tuple)): raise TypeError("indices should be an array, got %s" % type(indices)) indices = list(indices) for i, index in enumerate(indices): if isinstance(index, Symbol): indices[i] = TensorIndex(index, tensor_head.index_types[i], True) elif isinstance(index, Mul): c, e = index.as_coeff_Mul() if c == -1 and isinstance(e, Symbol): indices[i] = TensorIndex(e, tensor_head.index_types[i], False) else: raise ValueError("index not understood: %s" % index) elif not isinstance(index, TensorIndex): raise TypeError("wrong type for index: %s is %s" % (index, type(index))) return indices def _set_new_index_structure(self, im, is_canon_bp=False): indices = im.get_indices() return self._set_indices(*indices, is_canon_bp=is_canon_bp) def _set_indices(self, *indices, **kw_args): if len(indices) != self.ext_rank: raise ValueError("indices length mismatch") return self.func(self.args[0], indices, is_canon_bp=kw_args.pop('is_canon_bp', False)).doit() def _get_free_indices_set(self): return set([i[0] for i in self._index_structure.free]) def _get_dummy_indices_set(self): dummy_pos = set(itertools.chain(*self._index_structure.dum)) return set(idx for i, idx in enumerate(self.args[1]) if i in dummy_pos) def _get_indices_set(self): return set(self.args[1].args) @property def is_canon_bp(self): return self._is_canon_bp @property def indices(self): return self._indices @property def free(self): return self._index_structure.free[:] @property def free_in_args(self): return [(ind, pos, 0) for ind, pos in self.free] @property def dum(self): return self._index_structure.dum[:] @property def dum_in_args(self): return [(p1, p2, 0, 0) for p1, p2 in self.dum] @property def rank(self): return len(self.free) @property def ext_rank(self): return self._index_structure._ext_rank @property def free_args(self): return sorted([x[0] for x in self.free]) def commutes_with(self, other): """ :param other: :return: 0 commute 1 anticommute None neither commute nor anticommute """ if not isinstance(other, TensExpr): return 0 elif isinstance(other, Tensor): return self.component.commutes_with(other.component) return NotImplementedError def perm2tensor(self, g, is_canon_bp=False): """ Returns the tensor corresponding to the permutation ``g`` For further details, see the method in ``TIDS`` with the same name. """ return perm2tensor(self, g, is_canon_bp) def canon_bp(self): if self._is_canon_bp: return self expr = self.expand() g, dummies, msym = expr._index_structure.indices_canon_args() v = components_canon_args([expr.component]) can = canonicalize(g, dummies, msym, *v) if can == 0: return S.Zero tensor = self.perm2tensor(can, True) return tensor @property def index_types(self): return list(self.component.index_types) @property def coeff(self): return S.One @property def nocoeff(self): return self @property def component(self): return self.args[0] @property def components(self): return [self.args[0]] def split(self): return [self] def _expand(self, **kwargs): return self def sorted_components(self): return self def get_indices(self): """ Get a list of indices, corresponding to those of the tensor. """ return list(self.args[1]) def get_free_indices(self): """ Get a list of free indices, corresponding to those of the tensor. """ return self._index_structure.get_free_indices() def as_base_exp(self): return self, S.One def substitute_indices(self, *index_tuples): return substitute_indices(self, *index_tuples) def __call__(self, *indices): """Returns tensor with ordered free indices replaced by ``indices`` Examples ======== >>> from sympy.tensor.tensor import TensorIndexType, tensor_indices, tensorhead >>> Lorentz = TensorIndexType('Lorentz', dummy_fmt='L') >>> i0,i1,i2,i3,i4 = tensor_indices('i0:5', Lorentz) >>> A = tensorhead('A', [Lorentz]*5, [[1]*5]) >>> t = A(i2, i1, -i2, -i3, i4) >>> t A(L_0, i1, -L_0, -i3, i4) >>> t(i1, i2, i3) A(L_0, i1, -L_0, i2, i3) """ free_args = self.free_args indices = list(indices) if [x.tensor_index_type for x in indices] != [x.tensor_index_type for x in free_args]: raise ValueError('incompatible types') if indices == free_args: return self t = self.fun_eval(*list(zip(free_args, indices))) # object is rebuilt in order to make sure that all contracted indices # get recognized as dummies, but only if there are contracted indices. if len(set(i if i.is_up else -i for i in indices)) != len(indices): return t.func(*t.args) return t # TODO: put this into TensExpr? def __iter__(self): deprecate_data() return self.data.__iter__() # TODO: put this into TensExpr? def __getitem__(self, item): deprecate_data() return self.data[item] def _extract_data(self, replacement_dict): from .array import Array for k, v in replacement_dict.items(): if isinstance(k, Tensor) and k.args[0] == self.args[0]: other = k array = v break else: raise ValueError("%s not found in %s" % (self, replacement_dict)) # TODO: inefficient, this should be done at root level only: replacement_dict = {k: Array(v) for k, v in replacement_dict.items()} array = Array(array) dum1 = self.dum dum2 = other.dum if len(dum2) > 0: for pair in dum2: # allow `dum2` if the contained values are also in `dum1`. if pair not in dum1: raise NotImplementedError("%s with contractions is not implemented" % other) # Remove elements in `dum2` from `dum1`: dum1 = [pair for pair in dum1 if pair not in dum2] if len(dum1) > 0: indices2 = other.get_indices() repl = {} for p1, p2 in dum1: repl[indices2[p2]] = -indices2[p1] other = other.xreplace(repl).doit() array = _TensorDataLazyEvaluator.data_contract_dum([array], dum1, len(indices2)) free_ind1 = self.get_free_indices() free_ind2 = other.get_free_indices() return self._match_indices_with_other_tensor(array, free_ind1, free_ind2, replacement_dict) @property def data(self): deprecate_data() return _tensor_data_substitution_dict[self] @data.setter def data(self, data): deprecate_data() # TODO: check data compatibility with properties of tensor. _tensor_data_substitution_dict[self] = data @data.deleter def data(self): deprecate_data() if self in _tensor_data_substitution_dict: del _tensor_data_substitution_dict[self] if self.metric in _tensor_data_substitution_dict: del _tensor_data_substitution_dict[self.metric] def _print(self): indices = [str(ind) for ind in self.indices] component = self.component if component.rank > 0: return ('%s(%s)' % (component.name, ', '.join(indices))) else: return ('%s' % component.name) def equals(self, other): if other == 0: return self.coeff == 0 other = _sympify(other) if not isinstance(other, TensExpr): assert not self.components return S.One == other def _get_compar_comp(self): t = self.canon_bp() r = (t.coeff, tuple(t.components), \ tuple(sorted(t.free)), tuple(sorted(t.dum))) return r return _get_compar_comp(self) == _get_compar_comp(other) def contract_metric(self, g): # if metric is not the same, ignore this step: if self.component != g: return self # in case there are free components, do not perform anything: if len(self.free) != 0: return self antisym = g.index_types[0].metric_antisym sign = S.One typ = g.index_types[0] if not antisym: # g(i, -i) if typ._dim is None: raise ValueError('dimension not assigned') sign = sign*typ._dim else: # g(i, -i) if typ._dim is None: raise ValueError('dimension not assigned') sign = sign*typ._dim dp0, dp1 = self.dum[0] if dp0 < dp1: # g(i, -i) = -D with antisymmetric metric sign = -sign return sign def contract_delta(self, metric): return self.contract_metric(metric) def _eval_rewrite_as_Indexed(self, tens, indices): from sympy import Indexed # TODO: replace .args[0] with .name: index_symbols = [i.args[0] for i in self.get_indices()] expr = Indexed(tens.args[0], *index_symbols) return self._check_add_Sum(expr, index_symbols) class TensMul(TensExpr, AssocOp): """ Product of tensors Parameters ========== coeff : SymPy coefficient of the tensor args Attributes ========== ``components`` : list of ``TensorHead`` of the component tensors ``types`` : list of nonrepeated ``TensorIndexType`` ``free`` : list of ``(ind, ipos, icomp)``, see Notes ``dum`` : list of ``(ipos1, ipos2, icomp1, icomp2)``, see Notes ``ext_rank`` : rank of the tensor counting the dummy indices ``rank`` : rank of the tensor ``coeff`` : SymPy coefficient of the tensor ``free_args`` : list of the free indices in sorted order ``is_canon_bp`` : ``True`` if the tensor in in canonical form Notes ===== ``args[0]`` list of ``TensorHead`` of the component tensors. ``args[1]`` list of ``(ind, ipos, icomp)`` where ``ind`` is a free index, ``ipos`` is the slot position of ``ind`` in the ``icomp``-th component tensor. ``args[2]`` list of tuples representing dummy indices. ``(ipos1, ipos2, icomp1, icomp2)`` indicates that the contravariant dummy index is the ``ipos1``-th slot position in the ``icomp1``-th component tensor; the corresponding covariant index is in the ``ipos2`` slot position in the ``icomp2``-th component tensor. """ identity = S.One def __new__(cls, *args, **kw_args): is_canon_bp = kw_args.get('is_canon_bp', False) args = list(map(_sympify, args)) # Flatten: args = [i for arg in args for i in (arg.args if isinstance(arg, (TensMul, Mul)) else [arg])] args, indices, free, dum = TensMul._tensMul_contract_indices(args, replace_indices=False) # Data for indices: index_types = [i.tensor_index_type for i in indices] index_structure = _IndexStructure(free, dum, index_types, indices, canon_bp=is_canon_bp) obj = TensExpr.__new__(cls, *args) obj._indices = indices obj._index_types = index_types obj._index_structure = index_structure obj._ext_rank = len(obj._index_structure.free) + 2*len(obj._index_structure.dum) obj._coeff = S.One obj._is_canon_bp = is_canon_bp return obj @staticmethod def _indices_to_free_dum(args_indices): free2pos1 = {} free2pos2 = {} dummy_data = [] indices = [] # Notation for positions (to better understand the code): # `pos1`: position in the `args`. # `pos2`: position in the indices. # Example: # A(i, j)*B(k, m, n)*C(p) # `pos1` of `n` is 1 because it's in `B` (second `args` of TensMul). # `pos2` of `n` is 4 because it's the fifth overall index. # Counter for the index position wrt the whole expression: pos2 = 0 for pos1, arg_indices in enumerate(args_indices): for index_pos, index in enumerate(arg_indices): if not isinstance(index, TensorIndex): raise TypeError("expected TensorIndex") if -index in free2pos1: # Dummy index detected: other_pos1 = free2pos1.pop(-index) other_pos2 = free2pos2.pop(-index) if index.is_up: dummy_data.append((index, pos1, other_pos1, pos2, other_pos2)) else: dummy_data.append((-index, other_pos1, pos1, other_pos2, pos2)) indices.append(index) elif index in free2pos1: raise ValueError("Repeated index: %s" % index) else: free2pos1[index] = pos1 free2pos2[index] = pos2 indices.append(index) pos2 += 1 free = [(i, p) for (i, p) in free2pos2.items()] free_names = [i.name for i in free2pos2.keys()] dummy_data.sort(key=lambda x: x[3]) return indices, free, free_names, dummy_data @staticmethod def _dummy_data_to_dum(dummy_data): return [(p2a, p2b) for (i, p1a, p1b, p2a, p2b) in dummy_data] @staticmethod def _tensMul_contract_indices(args, replace_indices=True): replacements = [{} for _ in args] #_index_order = all([_has_index_order(arg) for arg in args]) args_indices = [get_indices(arg) for arg in args] indices, free, free_names, dummy_data = TensMul._indices_to_free_dum(args_indices) cdt = defaultdict(int) def dummy_fmt_gen(tensor_index_type): fmt = tensor_index_type.dummy_fmt nd = cdt[tensor_index_type] cdt[tensor_index_type] += 1 return fmt % nd if replace_indices: for old_index, pos1cov, pos1contra, pos2cov, pos2contra in dummy_data: index_type = old_index.tensor_index_type while True: dummy_name = dummy_fmt_gen(index_type) if dummy_name not in free_names: break dummy = TensorIndex(dummy_name, index_type, True) replacements[pos1cov][old_index] = dummy replacements[pos1contra][-old_index] = -dummy indices[pos2cov] = dummy indices[pos2contra] = -dummy args = [arg.xreplace(repl) for arg, repl in zip(args, replacements)] dum = TensMul._dummy_data_to_dum(dummy_data) return args, indices, free, dum @staticmethod def _get_components_from_args(args): """ Get a list of ``Tensor`` objects having the same ``TIDS`` if multiplied by one another. """ components = [] for arg in args: if not isinstance(arg, TensExpr): continue if isinstance(arg, TensAdd): continue components.extend(arg.components) return components @staticmethod def _rebuild_tensors_list(args, index_structure): indices = index_structure.get_indices() #tensors = [None for i in components] # pre-allocate list ind_pos = 0 for i, arg in enumerate(args): if not isinstance(arg, TensExpr): continue prev_pos = ind_pos ind_pos += arg.ext_rank args[i] = Tensor(arg.component, indices[prev_pos:ind_pos]) def doit(self, **kwargs): is_canon_bp = self._is_canon_bp deep = kwargs.get('deep', True) if deep: args = [arg.doit(**kwargs) for arg in self.args] else: args = self.args args = [arg for arg in args if arg != self.identity] # Extract non-tensor coefficients: coeff = reduce(lambda a, b: a*b, [arg for arg in args if not isinstance(arg, TensExpr)], S.One) args = [arg for arg in args if isinstance(arg, TensExpr)] if len(args) == 0: return coeff if coeff != self.identity: args = [coeff] + args if coeff == 0: return S.Zero if len(args) == 1: return args[0] args, indices, free, dum = TensMul._tensMul_contract_indices(args) # Data for indices: index_types = [i.tensor_index_type for i in indices] index_structure = _IndexStructure(free, dum, index_types, indices, canon_bp=is_canon_bp) obj = self.func(*args) obj._index_types = index_types obj._index_structure = index_structure obj._ext_rank = len(obj._index_structure.free) + 2*len(obj._index_structure.dum) obj._coeff = coeff obj._is_canon_bp = is_canon_bp return obj # TODO: this method should be private # TODO: should this method be renamed _from_components_free_dum ? @staticmethod def from_data(coeff, components, free, dum, **kw_args): return TensMul(coeff, *TensMul._get_tensors_from_components_free_dum(components, free, dum), **kw_args).doit() @staticmethod def _get_tensors_from_components_free_dum(components, free, dum): """ Get a list of ``Tensor`` objects by distributing ``free`` and ``dum`` indices on the ``components``. """ index_structure = _IndexStructure.from_components_free_dum(components, free, dum) indices = index_structure.get_indices() tensors = [None for i in components] # pre-allocate list # distribute indices on components to build a list of tensors: ind_pos = 0 for i, component in enumerate(components): prev_pos = ind_pos ind_pos += component.rank tensors[i] = Tensor(component, indices[prev_pos:ind_pos]) return tensors def _get_free_indices_set(self): return set([i[0] for i in self.free]) def _get_dummy_indices_set(self): dummy_pos = set(itertools.chain(*self.dum)) return set(idx for i, idx in enumerate(self._index_structure.get_indices()) if i in dummy_pos) def _get_position_offset_for_indices(self): arg_offset = [None for i in range(self.ext_rank)] counter = 0 for i, arg in enumerate(self.args): if not isinstance(arg, TensExpr): continue for j in range(arg.ext_rank): arg_offset[j + counter] = counter counter += arg.ext_rank return arg_offset @property def free_args(self): return sorted([x[0] for x in self.free]) @property def components(self): return self._get_components_from_args(self.args) @property def free(self): return self._index_structure.free[:] @property def free_in_args(self): arg_offset = self._get_position_offset_for_indices() argpos = self._get_indices_to_args_pos() return [(ind, pos-arg_offset[pos], argpos[pos]) for (ind, pos) in self.free] @property def coeff(self): return self._coeff @property def nocoeff(self): return self.func(*[t for t in self.args if isinstance(t, TensExpr)]).doit() @property def dum(self): return self._index_structure.dum[:] @property def dum_in_args(self): arg_offset = self._get_position_offset_for_indices() argpos = self._get_indices_to_args_pos() return [(p1-arg_offset[p1], p2-arg_offset[p2], argpos[p1], argpos[p2]) for p1, p2 in self.dum] @property def rank(self): return len(self.free) @property def ext_rank(self): return self._ext_rank @property def index_types(self): return self._index_types[:] def equals(self, other): if other == 0: return self.coeff == 0 other = _sympify(other) if not isinstance(other, TensExpr): assert not self.components return self._coeff == other return self.canon_bp() == other.canon_bp() def get_indices(self): """ Returns the list of indices of the tensor The indices are listed in the order in which they appear in the component tensors. The dummy indices are given a name which does not collide with the names of the free indices. Examples ======== >>> from sympy.tensor.tensor import TensorIndexType, tensor_indices, tensorhead >>> Lorentz = TensorIndexType('Lorentz', dummy_fmt='L') >>> m0, m1, m2 = tensor_indices('m0,m1,m2', Lorentz) >>> g = Lorentz.metric >>> p, q = tensorhead('p,q', [Lorentz], [[1]]) >>> t = p(m1)*g(m0,m2) >>> t.get_indices() [m1, m0, m2] >>> t2 = p(m1)*g(-m1, m2) >>> t2.get_indices() [L_0, -L_0, m2] """ return self._indices def get_free_indices(self): """ Returns the list of free indices of the tensor The indices are listed in the order in which they appear in the component tensors. Examples ======== >>> from sympy.tensor.tensor import TensorIndexType, tensor_indices, tensorhead >>> Lorentz = TensorIndexType('Lorentz', dummy_fmt='L') >>> m0, m1, m2 = tensor_indices('m0,m1,m2', Lorentz) >>> g = Lorentz.metric >>> p, q = tensorhead('p,q', [Lorentz], [[1]]) >>> t = p(m1)*g(m0,m2) >>> t.get_free_indices() [m1, m0, m2] >>> t2 = p(m1)*g(-m1, m2) >>> t2.get_free_indices() [m2] """ return self._index_structure.get_free_indices() def split(self): """ Returns a list of tensors, whose product is ``self`` Dummy indices contracted among different tensor components become free indices with the same name as the one used to represent the dummy indices. Examples ======== >>> from sympy.tensor.tensor import TensorIndexType, tensor_indices, tensorhead >>> Lorentz = TensorIndexType('Lorentz', dummy_fmt='L') >>> a, b, c, d = tensor_indices('a,b,c,d', Lorentz) >>> A, B = tensorhead('A,B', [Lorentz]*2, [[1]*2]) >>> t = A(a,b)*B(-b,c) >>> t A(a, L_0)*B(-L_0, c) >>> t.split() [A(a, L_0), B(-L_0, c)] """ if self.args == (): return [self] splitp = [] res = 1 for arg in self.args: if isinstance(arg, Tensor): splitp.append(res*arg) res = 1 else: res *= arg return splitp def _expand(self, **hints): # TODO: temporary solution, in the future this should be linked to # `Expr.expand`. args = [_expand(arg, **hints) for arg in self.args] args1 = [arg.args if isinstance(arg, (Add, TensAdd)) else (arg,) for arg in args] return TensAdd(*[ TensMul(*i) for i in itertools.product(*args1)] ) def __neg__(self): return TensMul(S.NegativeOne, self, is_canon_bp=self._is_canon_bp).doit() def __getitem__(self, item): deprecate_data() return self.data[item] def _get_args_for_traditional_printer(self): args = list(self.args) if (self.coeff < 0) == True: # expressions like "-A(a)" sign = "-" if self.coeff == S.NegativeOne: args = args[1:] else: args[0] = -args[0] else: sign = "" return sign, args def _sort_args_for_sorted_components(self): """ Returns the ``args`` sorted according to the components commutation properties. The sorting is done taking into account the commutation group of the component tensors. """ cv = [arg for arg in self.args if isinstance(arg, TensExpr)] sign = 1 n = len(cv) - 1 for i in range(n): for j in range(n, i, -1): c = cv[j-1].commutes_with(cv[j]) # if `c` is `None`, it does neither commute nor anticommute, skip: if c not in [0, 1]: continue if (cv[j-1].component.types, cv[j-1].component.name) > \ (cv[j].component.types, cv[j].component.name): cv[j-1], cv[j] = cv[j], cv[j-1] # if `c` is 1, the anticommute, so change sign: if c: sign = -sign coeff = sign * self.coeff if coeff != 1: return [coeff] + cv return cv def sorted_components(self): """ Returns a tensor product with sorted components. """ return TensMul(*self._sort_args_for_sorted_components()).doit() def perm2tensor(self, g, is_canon_bp=False): """ Returns the tensor corresponding to the permutation ``g`` For further details, see the method in ``TIDS`` with the same name. """ return perm2tensor(self, g, is_canon_bp=is_canon_bp) def canon_bp(self): """ Canonicalize using the Butler-Portugal algorithm for canonicalization under monoterm symmetries. Examples ======== >>> from sympy.tensor.tensor import TensorIndexType, tensor_indices, tensorhead >>> Lorentz = TensorIndexType('Lorentz', dummy_fmt='L') >>> m0, m1, m2 = tensor_indices('m0,m1,m2', Lorentz) >>> A = tensorhead('A', [Lorentz]*2, [[2]]) >>> t = A(m0,-m1)*A(m1,-m0) >>> t.canon_bp() -A(L_0, L_1)*A(-L_0, -L_1) >>> t = A(m0,-m1)*A(m1,-m2)*A(m2,-m0) >>> t.canon_bp() 0 """ if self._is_canon_bp: return self expr = self.expand() if isinstance(expr, TensAdd): return expr.canon_bp() if not expr.components: return expr t = expr.sorted_components() g, dummies, msym = t._index_structure.indices_canon_args() v = components_canon_args(t.components) can = canonicalize(g, dummies, msym, *v) if can == 0: return S.Zero tmul = t.perm2tensor(can, True) return tmul def contract_delta(self, delta): t = self.contract_metric(delta) return t def _get_indices_to_args_pos(self): """ Get a dict mapping the index position to TensMul's argument number. """ pos_map = dict() pos_counter = 0 for arg_i, arg in enumerate(self.args): if not isinstance(arg, TensExpr): continue assert isinstance(arg, Tensor) for i in range(arg.ext_rank): pos_map[pos_counter] = arg_i pos_counter += 1 return pos_map def contract_metric(self, g): """ Raise or lower indices with the metric ``g`` Parameters ========== g : metric Notes ===== see the ``TensorIndexType`` docstring for the contraction conventions Examples ======== >>> from sympy.tensor.tensor import TensorIndexType, tensor_indices, tensorhead >>> Lorentz = TensorIndexType('Lorentz', dummy_fmt='L') >>> m0, m1, m2 = tensor_indices('m0,m1,m2', Lorentz) >>> g = Lorentz.metric >>> p, q = tensorhead('p,q', [Lorentz], [[1]]) >>> t = p(m0)*q(m1)*g(-m0, -m1) >>> t.canon_bp() metric(L_0, L_1)*p(-L_0)*q(-L_1) >>> t.contract_metric(g).canon_bp() p(L_0)*q(-L_0) """ expr = self.expand() if self != expr: expr = expr.canon_bp() return expr.contract_metric(g) pos_map = self._get_indices_to_args_pos() args = list(self.args) antisym = g.index_types[0].metric_antisym # list of positions of the metric ``g`` inside ``args`` gpos = [i for i, x in enumerate(self.args) if isinstance(x, Tensor) and x.component == g] if not gpos: return self # Sign is either 1 or -1, to correct the sign after metric contraction # (for spinor indices). sign = 1 dum = self.dum[:] free = self.free[:] elim = set() for gposx in gpos: if gposx in elim: continue free1 = [x for x in free if pos_map[x[1]] == gposx] dum1 = [x for x in dum if pos_map[x[0]] == gposx or pos_map[x[1]] == gposx] if not dum1: continue elim.add(gposx) # subs with the multiplication neutral element, that is, remove it: args[gposx] = 1 if len(dum1) == 2: if not antisym: dum10, dum11 = dum1 if pos_map[dum10[1]] == gposx: # the index with pos p0 contravariant p0 = dum10[0] else: # the index with pos p0 is covariant p0 = dum10[1] if pos_map[dum11[1]] == gposx: # the index with pos p1 is contravariant p1 = dum11[0] else: # the index with pos p1 is covariant p1 = dum11[1] dum.append((p0, p1)) else: dum10, dum11 = dum1 # change the sign to bring the indices of the metric to contravariant # form; change the sign if dum10 has the metric index in position 0 if pos_map[dum10[1]] == gposx: # the index with pos p0 is contravariant p0 = dum10[0] if dum10[1] == 1: sign = -sign else: # the index with pos p0 is covariant p0 = dum10[1] if dum10[0] == 0: sign = -sign if pos_map[dum11[1]] == gposx: # the index with pos p1 is contravariant p1 = dum11[0] sign = -sign else: # the index with pos p1 is covariant p1 = dum11[1] dum.append((p0, p1)) elif len(dum1) == 1: if not antisym: dp0, dp1 = dum1[0] if pos_map[dp0] == pos_map[dp1]: # g(i, -i) typ = g.index_types[0] if typ._dim is None: raise ValueError('dimension not assigned') sign = sign*typ._dim else: # g(i0, i1)*p(-i1) if pos_map[dp0] == gposx: p1 = dp1 else: p1 = dp0 ind, p = free1[0] free.append((ind, p1)) else: dp0, dp1 = dum1[0] if pos_map[dp0] == pos_map[dp1]: # g(i, -i) typ = g.index_types[0] if typ._dim is None: raise ValueError('dimension not assigned') sign = sign*typ._dim if dp0 < dp1: # g(i, -i) = -D with antisymmetric metric sign = -sign else: # g(i0, i1)*p(-i1) if pos_map[dp0] == gposx: p1 = dp1 if dp0 == 0: sign = -sign else: p1 = dp0 ind, p = free1[0] free.append((ind, p1)) dum = [x for x in dum if x not in dum1] free = [x for x in free if x not in free1] # shift positions: shift = 0 shifts = [0]*len(args) for i in range(len(args)): if i in elim: shift += 2 continue shifts[i] = shift free = [(ind, p - shifts[pos_map[p]]) for (ind, p) in free if pos_map[p] not in elim] dum = [(p0 - shifts[pos_map[p0]], p1 - shifts[pos_map[p1]]) for i, (p0, p1) in enumerate(dum) if pos_map[p0] not in elim and pos_map[p1] not in elim] res = sign*TensMul(*args).doit() if not isinstance(res, TensExpr): return res im = _IndexStructure.from_components_free_dum(res.components, free, dum) return res._set_new_index_structure(im) def _set_new_index_structure(self, im, is_canon_bp=False): indices = im.get_indices() return self._set_indices(*indices, is_canon_bp=is_canon_bp) def _set_indices(self, *indices, **kw_args): if len(indices) != self.ext_rank: raise ValueError("indices length mismatch") args = list(self.args)[:] pos = 0 is_canon_bp = kw_args.pop('is_canon_bp', False) for i, arg in enumerate(args): if not isinstance(arg, TensExpr): continue assert isinstance(arg, Tensor) ext_rank = arg.ext_rank args[i] = arg._set_indices(*indices[pos:pos+ext_rank]) pos += ext_rank return TensMul(*args, is_canon_bp=is_canon_bp).doit() @staticmethod def _index_replacement_for_contract_metric(args, free, dum): for arg in args: if not isinstance(arg, TensExpr): continue assert isinstance(arg, Tensor) def substitute_indices(self, *index_tuples): return substitute_indices(self, *index_tuples) def __call__(self, *indices): """Returns tensor product with ordered free indices replaced by ``indices`` Examples ======== >>> from sympy import Symbol >>> from sympy.tensor.tensor import TensorIndexType, tensor_indices, tensorhead >>> D = Symbol('D') >>> Lorentz = TensorIndexType('Lorentz', dim=D, dummy_fmt='L') >>> i0,i1,i2,i3,i4 = tensor_indices('i0:5', Lorentz) >>> g = Lorentz.metric >>> p, q = tensorhead('p,q', [Lorentz], [[1]]) >>> t = p(i0)*q(i1)*q(-i1) >>> t(i1) p(i1)*q(L_0)*q(-L_0) """ free_args = self.free_args indices = list(indices) if [x.tensor_index_type for x in indices] != [x.tensor_index_type for x in free_args]: raise ValueError('incompatible types') if indices == free_args: return self t = self.fun_eval(*list(zip(free_args, indices))) # object is rebuilt in order to make sure that all contracted indices # get recognized as dummies, but only if there are contracted indices. if len(set(i if i.is_up else -i for i in indices)) != len(indices): return t.func(*t.args) return t def _extract_data(self, replacement_dict): args_indices, arrays = zip(*[arg._extract_data(replacement_dict) for arg in self.args if isinstance(arg, TensExpr)]) coeff = reduce(operator.mul, [a for a in self.args if not isinstance(a, TensExpr)], S.One) indices, free, free_names, dummy_data = TensMul._indices_to_free_dum(args_indices) dum = TensMul._dummy_data_to_dum(dummy_data) ext_rank = self.ext_rank free.sort(key=lambda x: x[1]) free_indices = [i[0] for i in free] return free_indices, coeff*_TensorDataLazyEvaluator.data_contract_dum(arrays, dum, ext_rank) @property def data(self): deprecate_data() dat = _tensor_data_substitution_dict[self.expand()] return dat @data.setter def data(self, data): deprecate_data() raise ValueError("Not possible to set component data to a tensor expression") @data.deleter def data(self): deprecate_data() raise ValueError("Not possible to delete component data to a tensor expression") def __iter__(self): deprecate_data() if self.data is None: raise ValueError("No iteration on abstract tensors") return self.data.__iter__() def _eval_rewrite_as_Indexed(self, *args): from sympy import Sum index_symbols = [i.args[0] for i in self.get_indices()] args = [arg.args[0] if isinstance(arg, Sum) else arg for arg in args] expr = Mul.fromiter(args) return self._check_add_Sum(expr, index_symbols) class TensorElement(TensExpr): """ Tensor with evaluated components. Examples ======== >>> from sympy.tensor.tensor import TensorIndexType, tensorhead >>> from sympy import symbols >>> L = TensorIndexType("L") >>> i, j, k = symbols("i j k") >>> A = tensorhead("A", [L, L], [[1], [1]]) >>> A(i, j).get_free_indices() [i, j] If we want to set component ``i`` to a specific value, use the ``TensorElement`` class: >>> from sympy.tensor.tensor import TensorElement >>> te = TensorElement(A(i, j), {i: 2}) As index ``i`` has been accessed (``{i: 2}`` is the evaluation of its 3rd element), the free indices will only contain ``j``: >>> te.get_free_indices() [j] """ def __new__(cls, expr, index_map): if not isinstance(expr, Tensor): # remap if not isinstance(expr, TensExpr): raise TypeError("%s is not a tensor expression" % expr) return expr.func(*[TensorElement(arg, index_map) for arg in expr.args]) expr_free_indices = expr.get_free_indices() name_translation = {i.args[0]: i for i in expr_free_indices} index_map = {name_translation.get(index, index): value for index, value in index_map.items()} index_map = {index: value for index, value in index_map.items() if index in expr_free_indices} if len(index_map) == 0: return expr free_indices = [i for i in expr_free_indices if i not in index_map.keys()] index_map = Dict(index_map) obj = TensExpr.__new__(cls, expr, index_map) obj._free_indices = free_indices return obj @property def free(self): return [(index, i) for i, index in enumerate(self.get_free_indices())] @property def dum(self): # TODO: inherit dummies from expr return [] @property def expr(self): return self._args[0] @property def index_map(self): return self._args[1] def get_free_indices(self): return self._free_indices def get_indices(self): return self.get_free_indices() def _extract_data(self, replacement_dict): ret_indices, array = self.expr._extract_data(replacement_dict) index_map = self.index_map slice_tuple = tuple(index_map.get(i, slice(None)) for i in ret_indices) ret_indices = [i for i in ret_indices if i not in index_map] array = array.__getitem__(slice_tuple) return ret_indices, array def canon_bp(p): """ Butler-Portugal canonicalization """ if isinstance(p, TensExpr): return p.canon_bp() return p def tensor_mul(*a): """ product of tensors """ if not a: return TensMul.from_data(S.One, [], [], []) t = a[0] for tx in a[1:]: t = t*tx return t def riemann_cyclic_replace(t_r): """ replace Riemann tensor with an equivalent expression ``R(m,n,p,q) -> 2/3*R(m,n,p,q) - 1/3*R(m,q,n,p) + 1/3*R(m,p,n,q)`` """ free = sorted(t_r.free, key=lambda x: x[1]) m, n, p, q = [x[0] for x in free] t0 = S(2)/3*t_r t1 = - S(1)/3*t_r.substitute_indices((m,m),(n,q),(p,n),(q,p)) t2 = S(1)/3*t_r.substitute_indices((m,m),(n,p),(p,n),(q,q)) t3 = t0 + t1 + t2 return t3 def riemann_cyclic(t2): """ replace each Riemann tensor with an equivalent expression satisfying the cyclic identity. This trick is discussed in the reference guide to Cadabra. Examples ======== >>> from sympy.tensor.tensor import TensorIndexType, tensor_indices, tensorhead, riemann_cyclic >>> Lorentz = TensorIndexType('Lorentz', dummy_fmt='L') >>> i, j, k, l = tensor_indices('i,j,k,l', Lorentz) >>> R = tensorhead('R', [Lorentz]*4, [[2, 2]]) >>> t = R(i,j,k,l)*(R(-i,-j,-k,-l) - 2*R(-i,-k,-j,-l)) >>> riemann_cyclic(t) 0 """ t2 = t2.expand() if isinstance(t2, (TensMul, Tensor)): args = [t2] else: args = t2.args a1 = [x.split() for x in args] a2 = [[riemann_cyclic_replace(tx) for tx in y] for y in a1] a3 = [tensor_mul(*v) for v in a2] t3 = TensAdd(*a3).doit() if not t3: return t3 else: return canon_bp(t3) def get_lines(ex, index_type): """ returns ``(lines, traces, rest)`` for an index type, where ``lines`` is the list of list of positions of a matrix line, ``traces`` is the list of list of traced matrix lines, ``rest`` is the rest of the elements ot the tensor. """ def _join_lines(a): i = 0 while i < len(a): x = a[i] xend = x[-1] xstart = x[0] hit = True while hit: hit = False for j in range(i + 1, len(a)): if j >= len(a): break if a[j][0] == xend: hit = True x.extend(a[j][1:]) xend = x[-1] a.pop(j) continue if a[j][0] == xstart: hit = True a[i] = reversed(a[j][1:]) + x x = a[i] xstart = a[i][0] a.pop(j) continue if a[j][-1] == xend: hit = True x.extend(reversed(a[j][:-1])) xend = x[-1] a.pop(j) continue if a[j][-1] == xstart: hit = True a[i] = a[j][:-1] + x x = a[i] xstart = x[0] a.pop(j) continue i += 1 return a arguments = ex.args dt = {} for c in ex.args: if not isinstance(c, TensExpr): continue if c in dt: continue index_types = c.index_types a = [] for i in range(len(index_types)): if index_types[i] is index_type: a.append(i) if len(a) > 2: raise ValueError('at most two indices of type %s allowed' % index_type) if len(a) == 2: dt[c] = a #dum = ex.dum lines = [] traces = [] traces1 = [] #indices_to_args_pos = ex._get_indices_to_args_pos() # TODO: add a dum_to_components_map ? for p0, p1, c0, c1 in ex.dum_in_args: if arguments[c0] not in dt: continue if c0 == c1: traces.append([c0]) continue ta0 = dt[arguments[c0]] ta1 = dt[arguments[c1]] if p0 not in ta0: continue if ta0.index(p0) == ta1.index(p1): # case gamma(i,s0,-s1) in c0, gamma(j,-s0,s2) in c1; # to deal with this case one could add to the position # a flag for transposition; # one could write [(c0, False), (c1, True)] raise NotImplementedError # if p0 == ta0[1] then G in pos c0 is mult on the right by G in c1 # if p0 == ta0[0] then G in pos c1 is mult on the right by G in c0 ta0 = dt[arguments[c0]] b0, b1 = (c0, c1) if p0 == ta0[1] else (c1, c0) lines1 = lines[:] for line in lines: if line[-1] == b0: if line[0] == b1: n = line.index(min(line)) traces1.append(line) traces.append(line[n:] + line[:n]) else: line.append(b1) break elif line[0] == b1: line.insert(0, b0) break else: lines1.append([b0, b1]) lines = [x for x in lines1 if x not in traces1] lines = _join_lines(lines) rest = [] for line in lines: for y in line: rest.append(y) for line in traces: for y in line: rest.append(y) rest = [x for x in range(len(arguments)) if x not in rest] return lines, traces, rest def get_free_indices(t): if not isinstance(t, TensExpr): return () return t.get_free_indices() def get_indices(t): if not isinstance(t, TensExpr): return () return t.get_indices() def get_index_structure(t): if isinstance(t, TensExpr): return t._index_structure return _IndexStructure([], [], [], []) def get_coeff(t): if isinstance(t, Tensor): return S.One if isinstance(t, TensMul): return t.coeff if isinstance(t, TensExpr): raise ValueError("no coefficient associated to this tensor expression") return t def contract_metric(t, g): if isinstance(t, TensExpr): return t.contract_metric(g) return t def perm2tensor(t, g, is_canon_bp=False): """ Returns the tensor corresponding to the permutation ``g`` For further details, see the method in ``TIDS`` with the same name. """ if not isinstance(t, TensExpr): return t elif isinstance(t, (Tensor, TensMul)): nim = get_index_structure(t).perm2tensor(g, is_canon_bp=is_canon_bp) res = t._set_new_index_structure(nim, is_canon_bp=is_canon_bp) if g[-1] != len(g) - 1: return -res return res raise NotImplementedError() def substitute_indices(t, *index_tuples): """ Return a tensor with free indices substituted according to ``index_tuples`` ``index_types`` list of tuples ``(old_index, new_index)`` Note: this method will neither raise or lower the indices, it will just replace their symbol. Examples ======== >>> from sympy.tensor.tensor import TensorIndexType, tensor_indices, tensorhead >>> Lorentz = TensorIndexType('Lorentz', dummy_fmt='L') >>> i, j, k, l = tensor_indices('i,j,k,l', Lorentz) >>> A, B = tensorhead('A,B', [Lorentz]*2, [[1]*2]) >>> t = A(i, k)*B(-k, -j); t A(i, L_0)*B(-L_0, -j) >>> t.substitute_indices((i,j), (j, k)) A(j, L_0)*B(-L_0, -k) """ if not isinstance(t, TensExpr): return t free = t.free free1 = [] for j, ipos in free: for i, v in index_tuples: if i._name == j._name and i.tensor_index_type == j.tensor_index_type: if i._is_up == j._is_up: free1.append((v, ipos)) else: free1.append((-v, ipos)) break else: free1.append((j, ipos)) t = TensMul.from_data(t.coeff, t.components, free1, t.dum) return t def _expand(expr, **kwargs): if isinstance(expr, TensExpr): return expr._expand(**kwargs) else: return expr.expand(**kwargs)
8cfc02d563afbe6e8b133cab12d91b92936ba243d9d9589eb4a45fc06dbe629d
"""A module that handles matrices. Includes functions for fast creating matrices like zero, one/eye, random matrix, etc. """ from .common import ShapeError, NonSquareMatrixError from .dense import ( GramSchmidt, casoratian, diag, eye, hessian, jordan_cell, list2numpy, matrix2numpy, matrix_multiply_elementwise, ones, randMatrix, rot_axis1, rot_axis2, rot_axis3, symarray, wronskian, zeros) from .dense import MutableDenseMatrix from .matrices import DeferredVector, MatrixBase Matrix = MutableMatrix = MutableDenseMatrix from .sparse import MutableSparseMatrix from .sparsetools import banded from .immutable import ImmutableDenseMatrix, ImmutableSparseMatrix ImmutableMatrix = ImmutableDenseMatrix SparseMatrix = MutableSparseMatrix from .expressions import ( MatrixSlice, BlockDiagMatrix, BlockMatrix, FunctionMatrix, Identity, Inverse, MatAdd, MatMul, MatPow, MatrixExpr, MatrixSymbol, Trace, Transpose, ZeroMatrix, blockcut, block_collapse, matrix_symbols, Adjoint, hadamard_product, HadamardProduct, HadamardPower, Determinant, det, diagonalize_vector, DiagonalizeVector, DiagonalMatrix, DiagonalOf, trace, DotProduct, kronecker_product, KroneckerProduct)
9d6c6c53c62f94b736a6f5c250ba8dd124fd4013a18ebc793b3b5ff0e1c0468b
""" Basic methods common to all matrices to be used when creating more advanced matrices (e.g., matrices over rings, etc.). """ from __future__ import division, print_function from collections import defaultdict from inspect import isfunction from sympy.assumptions.refine import refine from sympy.core.basic import Atom from sympy.core.compatibility import ( Iterable, as_int, is_sequence, range, reduce) from sympy.core.decorators import call_highest_priority from sympy.core.expr import Expr from sympy.core.function import count_ops from sympy.core.singleton import S from sympy.core.symbol import Symbol from sympy.core.sympify import sympify from sympy.functions import Abs from sympy.simplify import simplify as _simplify from sympy.utilities.exceptions import SymPyDeprecationWarning from sympy.utilities.iterables import flatten from sympy.utilities.misc import filldedent class MatrixError(Exception): pass class ShapeError(ValueError, MatrixError): """Wrong matrix shape""" pass class NonSquareMatrixError(ShapeError): pass class MatrixRequired(object): """All subclasses of matrix objects must implement the required matrix properties listed here.""" rows = None cols = None shape = None _simplify = None @classmethod def _new(cls, *args, **kwargs): """`_new` must, at minimum, be callable as `_new(rows, cols, mat) where mat is a flat list of the elements of the matrix.""" raise NotImplementedError("Subclasses must implement this.") def __eq__(self, other): raise NotImplementedError("Subclasses must implement this.") def __getitem__(self, key): """Implementations of __getitem__ should accept ints, in which case the matrix is indexed as a flat list, tuples (i,j) in which case the (i,j) entry is returned, slices, or mixed tuples (a,b) where a and b are any combintion of slices and integers.""" raise NotImplementedError("Subclasses must implement this.") def __len__(self): """The total number of entries in the matrix.""" raise NotImplementedError("Subclasses must implement this.") class MatrixShaping(MatrixRequired): """Provides basic matrix shaping and extracting of submatrices""" def _eval_col_del(self, col): def entry(i, j): return self[i, j] if j < col else self[i, j + 1] return self._new(self.rows, self.cols - 1, entry) def _eval_col_insert(self, pos, other): cols = self.cols def entry(i, j): if j < pos: return self[i, j] elif pos <= j < pos + other.cols: return other[i, j - pos] return self[i, j - other.cols] return self._new(self.rows, self.cols + other.cols, lambda i, j: entry(i, j)) def _eval_col_join(self, other): rows = self.rows def entry(i, j): if i < rows: return self[i, j] return other[i - rows, j] return classof(self, other)._new(self.rows + other.rows, self.cols, lambda i, j: entry(i, j)) def _eval_extract(self, rowsList, colsList): mat = list(self) cols = self.cols indices = (i * cols + j for i in rowsList for j in colsList) return self._new(len(rowsList), len(colsList), list(mat[i] for i in indices)) def _eval_get_diag_blocks(self): sub_blocks = [] def recurse_sub_blocks(M): i = 1 while i <= M.shape[0]: if i == 1: to_the_right = M[0, i:] to_the_bottom = M[i:, 0] else: to_the_right = M[:i, i:] to_the_bottom = M[i:, :i] if any(to_the_right) or any(to_the_bottom): i += 1 continue else: sub_blocks.append(M[:i, :i]) if M.shape == M[:i, :i].shape: return else: recurse_sub_blocks(M[i:, i:]) return recurse_sub_blocks(self) return sub_blocks def _eval_row_del(self, row): def entry(i, j): return self[i, j] if i < row else self[i + 1, j] return self._new(self.rows - 1, self.cols, entry) def _eval_row_insert(self, pos, other): entries = list(self) insert_pos = pos * self.cols entries[insert_pos:insert_pos] = list(other) return self._new(self.rows + other.rows, self.cols, entries) def _eval_row_join(self, other): cols = self.cols def entry(i, j): if j < cols: return self[i, j] return other[i, j - cols] return classof(self, other)._new(self.rows, self.cols + other.cols, lambda i, j: entry(i, j)) def _eval_tolist(self): return [list(self[i,:]) for i in range(self.rows)] def _eval_vec(self): rows = self.rows def entry(n, _): # we want to read off the columns first j = n // rows i = n - j * rows return self[i, j] return self._new(len(self), 1, entry) def col_del(self, col): """Delete the specified column.""" if col < 0: col += self.cols if not 0 <= col < self.cols: raise ValueError("Column {} out of range.".format(col)) return self._eval_col_del(col) def col_insert(self, pos, other): """Insert one or more columns at the given column position. Examples ======== >>> from sympy import zeros, ones >>> M = zeros(3) >>> V = ones(3, 1) >>> M.col_insert(1, V) Matrix([ [0, 1, 0, 0], [0, 1, 0, 0], [0, 1, 0, 0]]) See Also ======== col row_insert """ # Allows you to build a matrix even if it is null matrix if not self: return type(self)(other) pos = as_int(pos) if pos < 0: pos = self.cols + pos if pos < 0: pos = 0 elif pos > self.cols: pos = self.cols if self.rows != other.rows: raise ShapeError( "`self` and `other` must have the same number of rows.") return self._eval_col_insert(pos, other) def col_join(self, other): """Concatenates two matrices along self's last and other's first row. Examples ======== >>> from sympy import zeros, ones >>> M = zeros(3) >>> V = ones(1, 3) >>> M.col_join(V) Matrix([ [0, 0, 0], [0, 0, 0], [0, 0, 0], [1, 1, 1]]) See Also ======== col row_join """ # A null matrix can always be stacked (see #10770) if self.rows == 0 and self.cols != other.cols: return self._new(0, other.cols, []).col_join(other) if self.cols != other.cols: raise ShapeError( "`self` and `other` must have the same number of columns.") return self._eval_col_join(other) def col(self, j): """Elementary column selector. Examples ======== >>> from sympy import eye >>> eye(2).col(0) Matrix([ [1], [0]]) See Also ======== row col_op col_swap col_del col_join col_insert """ return self[:, j] def extract(self, rowsList, colsList): """Return a submatrix by specifying a list of rows and columns. Negative indices can be given. All indices must be in the range -n <= i < n where n is the number of rows or columns. Examples ======== >>> from sympy import Matrix >>> m = Matrix(4, 3, range(12)) >>> m Matrix([ [0, 1, 2], [3, 4, 5], [6, 7, 8], [9, 10, 11]]) >>> m.extract([0, 1, 3], [0, 1]) Matrix([ [0, 1], [3, 4], [9, 10]]) Rows or columns can be repeated: >>> m.extract([0, 0, 1], [-1]) Matrix([ [2], [2], [5]]) Every other row can be taken by using range to provide the indices: >>> m.extract(range(0, m.rows, 2), [-1]) Matrix([ [2], [8]]) RowsList or colsList can also be a list of booleans, in which case the rows or columns corresponding to the True values will be selected: >>> m.extract([0, 1, 2, 3], [True, False, True]) Matrix([ [0, 2], [3, 5], [6, 8], [9, 11]]) """ if not is_sequence(rowsList) or not is_sequence(colsList): raise TypeError("rowsList and colsList must be iterable") # ensure rowsList and colsList are lists of integers if rowsList and all(isinstance(i, bool) for i in rowsList): rowsList = [index for index, item in enumerate(rowsList) if item] if colsList and all(isinstance(i, bool) for i in colsList): colsList = [index for index, item in enumerate(colsList) if item] # ensure everything is in range rowsList = [a2idx(k, self.rows) for k in rowsList] colsList = [a2idx(k, self.cols) for k in colsList] return self._eval_extract(rowsList, colsList) def get_diag_blocks(self): """Obtains the square sub-matrices on the main diagonal of a square matrix. Useful for inverting symbolic matrices or solving systems of linear equations which may be decoupled by having a block diagonal structure. Examples ======== >>> from sympy import Matrix >>> from sympy.abc import x, y, z >>> A = Matrix([[1, 3, 0, 0], [y, z*z, 0, 0], [0, 0, x, 0], [0, 0, 0, 0]]) >>> a1, a2, a3 = A.get_diag_blocks() >>> a1 Matrix([ [1, 3], [y, z**2]]) >>> a2 Matrix([[x]]) >>> a3 Matrix([[0]]) """ return self._eval_get_diag_blocks() @classmethod def hstack(cls, *args): """Return a matrix formed by joining args horizontally (i.e. by repeated application of row_join). Examples ======== >>> from sympy.matrices import Matrix, eye >>> Matrix.hstack(eye(2), 2*eye(2)) Matrix([ [1, 0, 2, 0], [0, 1, 0, 2]]) """ if len(args) == 0: return cls._new() kls = type(args[0]) return reduce(kls.row_join, args) def reshape(self, rows, cols): """Reshape the matrix. Total number of elements must remain the same. Examples ======== >>> from sympy import Matrix >>> m = Matrix(2, 3, lambda i, j: 1) >>> m Matrix([ [1, 1, 1], [1, 1, 1]]) >>> m.reshape(1, 6) Matrix([[1, 1, 1, 1, 1, 1]]) >>> m.reshape(3, 2) Matrix([ [1, 1], [1, 1], [1, 1]]) """ if self.rows * self.cols != rows * cols: raise ValueError("Invalid reshape parameters %d %d" % (rows, cols)) return self._new(rows, cols, lambda i, j: self[i * cols + j]) def row_del(self, row): """Delete the specified row.""" if row < 0: row += self.rows if not 0 <= row < self.rows: raise ValueError("Row {} out of range.".format(row)) return self._eval_row_del(row) def row_insert(self, pos, other): """Insert one or more rows at the given row position. Examples ======== >>> from sympy import zeros, ones >>> M = zeros(3) >>> V = ones(1, 3) >>> M.row_insert(1, V) Matrix([ [0, 0, 0], [1, 1, 1], [0, 0, 0], [0, 0, 0]]) See Also ======== row col_insert """ # Allows you to build a matrix even if it is null matrix if not self: return self._new(other) pos = as_int(pos) if pos < 0: pos = self.rows + pos if pos < 0: pos = 0 elif pos > self.rows: pos = self.rows if self.cols != other.cols: raise ShapeError( "`self` and `other` must have the same number of columns.") return self._eval_row_insert(pos, other) def row_join(self, other): """Concatenates two matrices along self's last and rhs's first column Examples ======== >>> from sympy import zeros, ones >>> M = zeros(3) >>> V = ones(3, 1) >>> M.row_join(V) Matrix([ [0, 0, 0, 1], [0, 0, 0, 1], [0, 0, 0, 1]]) See Also ======== row col_join """ # A null matrix can always be stacked (see #10770) if self.cols == 0 and self.rows != other.rows: return self._new(other.rows, 0, []).row_join(other) if self.rows != other.rows: raise ShapeError( "`self` and `rhs` must have the same number of rows.") return self._eval_row_join(other) def diagonal(self, k=0): """Returns the kth diagonal of self. The main diagonal corresponds to `k=0`; diagonals above and below correspond to `k > 0` and `k < 0`, respectively. The values of `self[i, j]` for which `j - i = k`, are returned in order of increasing `i + j`, starting with `i + j = |k|`. Examples ======== >>> from sympy import Matrix, SparseMatrix >>> m = Matrix(3, 3, lambda i, j: j - i); m Matrix([ [ 0, 1, 2], [-1, 0, 1], [-2, -1, 0]]) >>> _.diagonal() Matrix([[0, 0, 0]]) >>> m.diagonal(1) Matrix([[1, 1]]) >>> m.diagonal(-2) Matrix([[-2]]) Even though the diagonal is returned as a Matrix, the element retrieval can be done with a single index: >>> Matrix.diag(1, 2, 3).diagonal()[1] # instead of [0, 1] 2 See Also ======== diag - to create a diagonal matrix """ rv = [] k = as_int(k) r = 0 if k > 0 else -k c = 0 if r else k for i in range(min(self.shape) - max(r, c)): rv.append(self[r + i, c + i]) if not rv: raise ValueError(filldedent(''' The %s diagonal is out of range [%s, %s]''' % ( k, 1 - self.rows, self.cols - 1))) return self._new(1, len(rv), rv) def row(self, i): """Elementary row selector. Examples ======== >>> from sympy import eye >>> eye(2).row(0) Matrix([[1, 0]]) See Also ======== col row_op row_swap row_del row_join row_insert """ return self[i, :] @property def shape(self): """The shape (dimensions) of the matrix as the 2-tuple (rows, cols). Examples ======== >>> from sympy.matrices import zeros >>> M = zeros(2, 3) >>> M.shape (2, 3) >>> M.rows 2 >>> M.cols 3 """ return (self.rows, self.cols) def tolist(self): """Return the Matrix as a nested Python list. Examples ======== >>> from sympy import Matrix, ones >>> m = Matrix(3, 3, range(9)) >>> m Matrix([ [0, 1, 2], [3, 4, 5], [6, 7, 8]]) >>> m.tolist() [[0, 1, 2], [3, 4, 5], [6, 7, 8]] >>> ones(3, 0).tolist() [[], [], []] When there are no rows then it will not be possible to tell how many columns were in the original matrix: >>> ones(0, 3).tolist() [] """ if not self.rows: return [] if not self.cols: return [[] for i in range(self.rows)] return self._eval_tolist() def vec(self): """Return the Matrix converted into a one column matrix by stacking columns Examples ======== >>> from sympy import Matrix >>> m=Matrix([[1, 3], [2, 4]]) >>> m Matrix([ [1, 3], [2, 4]]) >>> m.vec() Matrix([ [1], [2], [3], [4]]) See Also ======== vech """ return self._eval_vec() @classmethod def vstack(cls, *args): """Return a matrix formed by joining args vertically (i.e. by repeated application of col_join). Examples ======== >>> from sympy.matrices import Matrix, eye >>> Matrix.vstack(eye(2), 2*eye(2)) Matrix([ [1, 0], [0, 1], [2, 0], [0, 2]]) """ if len(args) == 0: return cls._new() kls = type(args[0]) return reduce(kls.col_join, args) class MatrixSpecial(MatrixRequired): """Construction of special matrices""" @classmethod def _eval_diag(cls, rows, cols, diag_dict): """diag_dict is a defaultdict containing all the entries of the diagonal matrix.""" def entry(i, j): return diag_dict[(i, j)] return cls._new(rows, cols, entry) @classmethod def _eval_eye(cls, rows, cols): def entry(i, j): return S.One if i == j else S.Zero return cls._new(rows, cols, entry) @classmethod def _eval_jordan_block(cls, rows, cols, eigenvalue, band='upper'): if band == 'lower': def entry(i, j): if i == j: return eigenvalue elif j + 1 == i: return S.One return S.Zero else: def entry(i, j): if i == j: return eigenvalue elif i + 1 == j: return S.One return S.Zero return cls._new(rows, cols, entry) @classmethod def _eval_ones(cls, rows, cols): def entry(i, j): return S.One return cls._new(rows, cols, entry) @classmethod def _eval_zeros(cls, rows, cols): def entry(i, j): return S.Zero return cls._new(rows, cols, entry) @classmethod def diag(kls, *args, **kwargs): """Returns a matrix with the specified diagonal. If matrices are passed, a block-diagonal matrix is created (i.e. the "direct sum" of the matrices). kwargs ====== rows : rows of the resulting matrix; computed if not given. cols : columns of the resulting matrix; computed if not given. cls : class for the resulting matrix unpack : bool which, when True (default), unpacks a single sequence rather than interpreting it as a Matrix. strict : bool which, when False (default), allows Matrices to have variable-length rows. Examples ======== >>> from sympy.matrices import Matrix >>> Matrix.diag(1, 2, 3) Matrix([ [1, 0, 0], [0, 2, 0], [0, 0, 3]]) The current default is to unpack a single sequence. If this is not desired, set `unpack=False` and it will be interpreted as a matrix. >>> Matrix.diag([1, 2, 3]) == Matrix.diag(1, 2, 3) True When more than one element is passed, each is interpreted as something to put on the diagonal. Lists are converted to matricecs. Filling of the diagonal always continues from the bottom right hand corner of the previous item: this will create a block-diagonal matrix whether the matrices are square or not. >>> col = [1, 2, 3] >>> row = [[4, 5]] >>> Matrix.diag(col, row) Matrix([ [1, 0, 0], [2, 0, 0], [3, 0, 0], [0, 4, 5]]) When `unpack` is False, elements within a list need not all be of the same length. Setting `strict` to True would raise a ValueError for the following: >>> Matrix.diag([[1, 2, 3], [4, 5], [6]], unpack=False) Matrix([ [1, 2, 3], [4, 5, 0], [6, 0, 0]]) The type of the returned matrix can be set with the ``cls`` keyword. >>> from sympy.matrices import ImmutableMatrix >>> from sympy.utilities.misc import func_name >>> func_name(Matrix.diag(1, cls=ImmutableMatrix)) 'ImmutableDenseMatrix' A zero dimension matrix can be used to position the start of the filling at the start of an arbitrary row or column: >>> from sympy import ones >>> r2 = ones(0, 2) >>> Matrix.diag(r2, 1, 2) Matrix([ [0, 0, 1, 0], [0, 0, 0, 2]]) See Also ======== eye diagonal - to extract a diagonal .dense.diag .expressions.blockmatrix.BlockMatrix """ from sympy.matrices.matrices import MatrixBase from sympy.matrices.dense import Matrix from sympy.matrices.sparse import SparseMatrix klass = kwargs.get('cls', kls) strict = kwargs.get('strict', False) # lists -> Matrices unpack = kwargs.get('unpack', True) # unpack single sequence if unpack and len(args) == 1 and is_sequence(args[0]) and \ not isinstance(args[0], MatrixBase): args = args[0] # fill a default dict with the diagonal entries diag_entries = defaultdict(int) rmax = cmax = 0 # keep track of the biggest index seen for m in args: if isinstance(m, list): if strict: # if malformed, Matrix will raise an error _ = Matrix(m) r, c = _.shape m = _.tolist() else: m = SparseMatrix(m) for (i, j), _ in m._smat.items(): diag_entries[(i + rmax, j + cmax)] = _ r, c = m.shape m = [] # to skip process below elif hasattr(m, 'shape'): # a Matrix # convert to list of lists r, c = m.shape m = m.tolist() else: # in this case, we're a single value diag_entries[(rmax, cmax)] = m rmax += 1 cmax += 1 continue # process list of lists for i in range(len(m)): for j, _ in enumerate(m[i]): diag_entries[(i + rmax, j + cmax)] = _ rmax += r cmax += c rows = kwargs.get('rows', None) cols = kwargs.get('cols', None) if rows is None: rows, cols = cols, rows if rows is None: rows, cols = rmax, cmax else: cols = rows if cols is None else cols if rows < rmax or cols < cmax: raise ValueError(filldedent(''' The constructed matrix is {} x {} but a size of {} x {} was specified.'''.format(rmax, cmax, rows, cols))) return klass._eval_diag(rows, cols, diag_entries) @classmethod def eye(kls, rows, cols=None, **kwargs): """Returns an identity matrix. Args ==== rows : rows of the matrix cols : cols of the matrix (if None, cols=rows) kwargs ====== cls : class of the returned matrix """ if cols is None: cols = rows klass = kwargs.get('cls', kls) rows, cols = as_int(rows), as_int(cols) return klass._eval_eye(rows, cols) @classmethod def jordan_block(kls, size=None, eigenvalue=None, **kwargs): """Returns a Jordan block Parameters ========== size : Integer, optional Specifies the shape of the Jordan block matrix. eigenvalue : Number or Symbol Specifies the value for the main diagonal of the matrix. .. note:: The keyword ``eigenval`` is also specified as an alias of this keyword, but it is not recommended to use. We may deprecate the alias in later release. band : 'upper' or 'lower', optional Specifies the position of the off-diagonal to put `1` s on. cls : Matrix, optional Specifies the matrix class of the output form. If it is not specified, the class type where the method is being executed on will be returned. rows, cols : Integer, optional Specifies the shape of the Jordan block matrix. See Notes section for the details of how these key works. .. note:: This feature will be deprecated in the future. Returns ======= Matrix A Jordan block matrix. Raises ====== ValueError If insufficient arguments are given for matrix size specification, or no eigenvalue is given. Examples ======== Creating a default Jordan block: >>> from sympy import Matrix >>> from sympy.abc import x >>> Matrix.jordan_block(4, x) Matrix([ [x, 1, 0, 0], [0, x, 1, 0], [0, 0, x, 1], [0, 0, 0, x]]) Creating an alternative Jordan block matrix where `1` is on lower off-diagonal: >>> Matrix.jordan_block(4, x, band='lower') Matrix([ [x, 0, 0, 0], [1, x, 0, 0], [0, 1, x, 0], [0, 0, 1, x]]) Creating a Jordan block with keyword arguments >>> Matrix.jordan_block(size=4, eigenvalue=x) Matrix([ [x, 1, 0, 0], [0, x, 1, 0], [0, 0, x, 1], [0, 0, 0, x]]) Notes ===== .. note:: This feature will be deprecated in the future. The keyword arguments ``size``, ``rows``, ``cols`` relates to the Jordan block size specifications. If you want to create a square Jordan block, specify either one of the three arguments. If you want to create a rectangular Jordan block, specify ``rows`` and ``cols`` individually. +--------------------------------+---------------------+ | Arguments Given | Matrix Shape | +----------+----------+----------+----------+----------+ | size | rows | cols | rows | cols | +==========+==========+==========+==========+==========+ | size | Any | size | size | +----------+----------+----------+----------+----------+ | | None | ValueError | | +----------+----------+----------+----------+ | None | rows | None | rows | rows | | +----------+----------+----------+----------+ | | None | cols | cols | cols | + +----------+----------+----------+----------+ | | rows | cols | rows | cols | +----------+----------+----------+----------+----------+ References ========== .. [1] https://en.wikipedia.org/wiki/Jordan_matrix """ if 'rows' in kwargs or 'cols' in kwargs: SymPyDeprecationWarning( feature="Keyword arguments 'rows' or 'cols'", issue=16102, useinstead="a more generic banded matrix constructor", deprecated_since_version="1.4" ).warn() klass = kwargs.pop('cls', kls) band = kwargs.pop('band', 'upper') rows = kwargs.pop('rows', None) cols = kwargs.pop('cols', None) eigenval = kwargs.get('eigenval', None) if eigenvalue is None and eigenval is None: raise ValueError("Must supply an eigenvalue") elif eigenvalue != eigenval and None not in (eigenval, eigenvalue): raise ValueError( "Inconsistent values are given: 'eigenval'={}, " "'eigenvalue'={}".format(eigenval, eigenvalue)) else: if eigenval is not None: eigenvalue = eigenval if (size, rows, cols) == (None, None, None): raise ValueError("Must supply a matrix size") if size is not None: rows, cols = size, size elif rows is not None and cols is None: cols = rows elif cols is not None and rows is None: rows = cols rows, cols = as_int(rows), as_int(cols) return klass._eval_jordan_block(rows, cols, eigenvalue, band) @classmethod def ones(kls, rows, cols=None, **kwargs): """Returns a matrix of ones. Args ==== rows : rows of the matrix cols : cols of the matrix (if None, cols=rows) kwargs ====== cls : class of the returned matrix """ if cols is None: cols = rows klass = kwargs.get('cls', kls) rows, cols = as_int(rows), as_int(cols) return klass._eval_ones(rows, cols) @classmethod def zeros(kls, rows, cols=None, **kwargs): """Returns a matrix of zeros. Args ==== rows : rows of the matrix cols : cols of the matrix (if None, cols=rows) kwargs ====== cls : class of the returned matrix """ if cols is None: cols = rows klass = kwargs.get('cls', kls) rows, cols = as_int(rows), as_int(cols) return klass._eval_zeros(rows, cols) class MatrixProperties(MatrixRequired): """Provides basic properties of a matrix.""" def _eval_atoms(self, *types): result = set() for i in self: result.update(i.atoms(*types)) return result def _eval_free_symbols(self): return set().union(*(i.free_symbols for i in self)) def _eval_has(self, *patterns): return any(a.has(*patterns) for a in self) def _eval_is_anti_symmetric(self, simpfunc): if not all(simpfunc(self[i, j] + self[j, i]).is_zero for i in range(self.rows) for j in range(self.cols)): return False return True def _eval_is_diagonal(self): for i in range(self.rows): for j in range(self.cols): if i != j and self[i, j]: return False return True # _eval_is_hermitian is called by some general sympy # routines and has a different *args signature. Make # sure the names don't clash by adding `_matrix_` in name. def _eval_is_matrix_hermitian(self, simpfunc): mat = self._new(self.rows, self.cols, lambda i, j: simpfunc(self[i, j] - self[j, i].conjugate())) return mat.is_zero def _eval_is_Identity(self): def dirac(i, j): if i == j: return 1 return 0 return all(self[i, j] == dirac(i, j) for i in range(self.rows) for j in range(self.cols)) def _eval_is_lower_hessenberg(self): return all(self[i, j].is_zero for i in range(self.rows) for j in range(i + 2, self.cols)) def _eval_is_lower(self): return all(self[i, j].is_zero for i in range(self.rows) for j in range(i + 1, self.cols)) def _eval_is_symbolic(self): return self.has(Symbol) def _eval_is_symmetric(self, simpfunc): mat = self._new(self.rows, self.cols, lambda i, j: simpfunc(self[i, j] - self[j, i])) return mat.is_zero def _eval_is_zero(self): if any(i.is_zero == False for i in self): return False if any(i.is_zero is None for i in self): return None return True def _eval_is_upper_hessenberg(self): return all(self[i, j].is_zero for i in range(2, self.rows) for j in range(min(self.cols, (i - 1)))) def _eval_values(self): return [i for i in self if not i.is_zero] def atoms(self, *types): """Returns the atoms that form the current object. Examples ======== >>> from sympy.abc import x, y >>> from sympy.matrices import Matrix >>> Matrix([[x]]) Matrix([[x]]) >>> _.atoms() {x} """ types = tuple(t if isinstance(t, type) else type(t) for t in types) if not types: types = (Atom,) return self._eval_atoms(*types) @property def free_symbols(self): """Returns the free symbols within the matrix. Examples ======== >>> from sympy.abc import x >>> from sympy.matrices import Matrix >>> Matrix([[x], [1]]).free_symbols {x} """ return self._eval_free_symbols() def has(self, *patterns): """Test whether any subexpression matches any of the patterns. Examples ======== >>> from sympy import Matrix, SparseMatrix, Float >>> from sympy.abc import x, y >>> A = Matrix(((1, x), (0.2, 3))) >>> B = SparseMatrix(((1, x), (0.2, 3))) >>> A.has(x) True >>> A.has(y) False >>> A.has(Float) True >>> B.has(x) True >>> B.has(y) False >>> B.has(Float) True """ return self._eval_has(*patterns) def is_anti_symmetric(self, simplify=True): """Check if matrix M is an antisymmetric matrix, that is, M is a square matrix with all M[i, j] == -M[j, i]. When ``simplify=True`` (default), the sum M[i, j] + M[j, i] is simplified before testing to see if it is zero. By default, the SymPy simplify function is used. To use a custom function set simplify to a function that accepts a single argument which returns a simplified expression. To skip simplification, set simplify to False but note that although this will be faster, it may induce false negatives. Examples ======== >>> from sympy import Matrix, symbols >>> m = Matrix(2, 2, [0, 1, -1, 0]) >>> m Matrix([ [ 0, 1], [-1, 0]]) >>> m.is_anti_symmetric() True >>> x, y = symbols('x y') >>> m = Matrix(2, 3, [0, 0, x, -y, 0, 0]) >>> m Matrix([ [ 0, 0, x], [-y, 0, 0]]) >>> m.is_anti_symmetric() False >>> from sympy.abc import x, y >>> m = Matrix(3, 3, [0, x**2 + 2*x + 1, y, ... -(x + 1)**2 , 0, x*y, ... -y, -x*y, 0]) Simplification of matrix elements is done by default so even though two elements which should be equal and opposite wouldn't pass an equality test, the matrix is still reported as anti-symmetric: >>> m[0, 1] == -m[1, 0] False >>> m.is_anti_symmetric() True If 'simplify=False' is used for the case when a Matrix is already simplified, this will speed things up. Here, we see that without simplification the matrix does not appear anti-symmetric: >>> m.is_anti_symmetric(simplify=False) False But if the matrix were already expanded, then it would appear anti-symmetric and simplification in the is_anti_symmetric routine is not needed: >>> m = m.expand() >>> m.is_anti_symmetric(simplify=False) True """ # accept custom simplification simpfunc = simplify if not isfunction(simplify): simpfunc = _simplify if simplify else lambda x: x if not self.is_square: return False return self._eval_is_anti_symmetric(simpfunc) def is_diagonal(self): """Check if matrix is diagonal, that is matrix in which the entries outside the main diagonal are all zero. Examples ======== >>> from sympy import Matrix, diag >>> m = Matrix(2, 2, [1, 0, 0, 2]) >>> m Matrix([ [1, 0], [0, 2]]) >>> m.is_diagonal() True >>> m = Matrix(2, 2, [1, 1, 0, 2]) >>> m Matrix([ [1, 1], [0, 2]]) >>> m.is_diagonal() False >>> m = diag(1, 2, 3) >>> m Matrix([ [1, 0, 0], [0, 2, 0], [0, 0, 3]]) >>> m.is_diagonal() True See Also ======== is_lower is_upper is_diagonalizable diagonalize """ return self._eval_is_diagonal() @property def is_hermitian(self, simplify=True): """Checks if the matrix is Hermitian. In a Hermitian matrix element i,j is the complex conjugate of element j,i. Examples ======== >>> from sympy.matrices import Matrix >>> from sympy import I >>> from sympy.abc import x >>> a = Matrix([[1, I], [-I, 1]]) >>> a Matrix([ [ 1, I], [-I, 1]]) >>> a.is_hermitian True >>> a[0, 0] = 2*I >>> a.is_hermitian False >>> a[0, 0] = x >>> a.is_hermitian >>> a[0, 1] = a[1, 0]*I >>> a.is_hermitian False """ if not self.is_square: return False simpfunc = simplify if not isfunction(simplify): simpfunc = _simplify if simplify else lambda x: x return self._eval_is_matrix_hermitian(simpfunc) @property def is_Identity(self): if not self.is_square: return False return self._eval_is_Identity() @property def is_lower_hessenberg(self): r"""Checks if the matrix is in the lower-Hessenberg form. The lower hessenberg matrix has zero entries above the first superdiagonal. Examples ======== >>> from sympy.matrices import Matrix >>> a = Matrix([[1, 2, 0, 0], [5, 2, 3, 0], [3, 4, 3, 7], [5, 6, 1, 1]]) >>> a Matrix([ [1, 2, 0, 0], [5, 2, 3, 0], [3, 4, 3, 7], [5, 6, 1, 1]]) >>> a.is_lower_hessenberg True See Also ======== is_upper_hessenberg is_lower """ return self._eval_is_lower_hessenberg() @property def is_lower(self): """Check if matrix is a lower triangular matrix. True can be returned even if the matrix is not square. Examples ======== >>> from sympy import Matrix >>> m = Matrix(2, 2, [1, 0, 0, 1]) >>> m Matrix([ [1, 0], [0, 1]]) >>> m.is_lower True >>> m = Matrix(4, 3, [0, 0, 0, 2, 0, 0, 1, 4 , 0, 6, 6, 5]) >>> m Matrix([ [0, 0, 0], [2, 0, 0], [1, 4, 0], [6, 6, 5]]) >>> m.is_lower True >>> from sympy.abc import x, y >>> m = Matrix(2, 2, [x**2 + y, y**2 + x, 0, x + y]) >>> m Matrix([ [x**2 + y, x + y**2], [ 0, x + y]]) >>> m.is_lower False See Also ======== is_upper is_diagonal is_lower_hessenberg """ return self._eval_is_lower() @property def is_square(self): """Checks if a matrix is square. A matrix is square if the number of rows equals the number of columns. The empty matrix is square by definition, since the number of rows and the number of columns are both zero. Examples ======== >>> from sympy import Matrix >>> a = Matrix([[1, 2, 3], [4, 5, 6]]) >>> b = Matrix([[1, 2, 3], [4, 5, 6], [7, 8, 9]]) >>> c = Matrix([]) >>> a.is_square False >>> b.is_square True >>> c.is_square True """ return self.rows == self.cols def is_symbolic(self): """Checks if any elements contain Symbols. Examples ======== >>> from sympy.matrices import Matrix >>> from sympy.abc import x, y >>> M = Matrix([[x, y], [1, 0]]) >>> M.is_symbolic() True """ return self._eval_is_symbolic() def is_symmetric(self, simplify=True): """Check if matrix is symmetric matrix, that is square matrix and is equal to its transpose. By default, simplifications occur before testing symmetry. They can be skipped using 'simplify=False'; while speeding things a bit, this may however induce false negatives. Examples ======== >>> from sympy import Matrix >>> m = Matrix(2, 2, [0, 1, 1, 2]) >>> m Matrix([ [0, 1], [1, 2]]) >>> m.is_symmetric() True >>> m = Matrix(2, 2, [0, 1, 2, 0]) >>> m Matrix([ [0, 1], [2, 0]]) >>> m.is_symmetric() False >>> m = Matrix(2, 3, [0, 0, 0, 0, 0, 0]) >>> m Matrix([ [0, 0, 0], [0, 0, 0]]) >>> m.is_symmetric() False >>> from sympy.abc import x, y >>> m = Matrix(3, 3, [1, x**2 + 2*x + 1, y, (x + 1)**2 , 2, 0, y, 0, 3]) >>> m Matrix([ [ 1, x**2 + 2*x + 1, y], [(x + 1)**2, 2, 0], [ y, 0, 3]]) >>> m.is_symmetric() True If the matrix is already simplified, you may speed-up is_symmetric() test by using 'simplify=False'. >>> bool(m.is_symmetric(simplify=False)) False >>> m1 = m.expand() >>> m1.is_symmetric(simplify=False) True """ simpfunc = simplify if not isfunction(simplify): simpfunc = _simplify if simplify else lambda x: x if not self.is_square: return False return self._eval_is_symmetric(simpfunc) @property def is_upper_hessenberg(self): """Checks if the matrix is the upper-Hessenberg form. The upper hessenberg matrix has zero entries below the first subdiagonal. Examples ======== >>> from sympy.matrices import Matrix >>> a = Matrix([[1, 4, 2, 3], [3, 4, 1, 7], [0, 2, 3, 4], [0, 0, 1, 3]]) >>> a Matrix([ [1, 4, 2, 3], [3, 4, 1, 7], [0, 2, 3, 4], [0, 0, 1, 3]]) >>> a.is_upper_hessenberg True See Also ======== is_lower_hessenberg is_upper """ return self._eval_is_upper_hessenberg() @property def is_upper(self): """Check if matrix is an upper triangular matrix. True can be returned even if the matrix is not square. Examples ======== >>> from sympy import Matrix >>> m = Matrix(2, 2, [1, 0, 0, 1]) >>> m Matrix([ [1, 0], [0, 1]]) >>> m.is_upper True >>> m = Matrix(4, 3, [5, 1, 9, 0, 4 , 6, 0, 0, 5, 0, 0, 0]) >>> m Matrix([ [5, 1, 9], [0, 4, 6], [0, 0, 5], [0, 0, 0]]) >>> m.is_upper True >>> m = Matrix(2, 3, [4, 2, 5, 6, 1, 1]) >>> m Matrix([ [4, 2, 5], [6, 1, 1]]) >>> m.is_upper False See Also ======== is_lower is_diagonal is_upper_hessenberg """ return all(self[i, j].is_zero for i in range(1, self.rows) for j in range(min(i, self.cols))) @property def is_zero(self): """Checks if a matrix is a zero matrix. A matrix is zero if every element is zero. A matrix need not be square to be considered zero. The empty matrix is zero by the principle of vacuous truth. For a matrix that may or may not be zero (e.g. contains a symbol), this will be None Examples ======== >>> from sympy import Matrix, zeros >>> from sympy.abc import x >>> a = Matrix([[0, 0], [0, 0]]) >>> b = zeros(3, 4) >>> c = Matrix([[0, 1], [0, 0]]) >>> d = Matrix([]) >>> e = Matrix([[x, 0], [0, 0]]) >>> a.is_zero True >>> b.is_zero True >>> c.is_zero False >>> d.is_zero True >>> e.is_zero """ return self._eval_is_zero() def values(self): """Return non-zero values of self.""" return self._eval_values() class MatrixOperations(MatrixRequired): """Provides basic matrix shape and elementwise operations. Should not be instantiated directly.""" def _eval_adjoint(self): return self.transpose().conjugate() def _eval_applyfunc(self, f): out = self._new(self.rows, self.cols, [f(x) for x in self]) return out def _eval_as_real_imag(self): from sympy.functions.elementary.complexes import re, im return (self.applyfunc(re), self.applyfunc(im)) def _eval_conjugate(self): return self.applyfunc(lambda x: x.conjugate()) def _eval_permute_cols(self, perm): # apply the permutation to a list mapping = list(perm) def entry(i, j): return self[i, mapping[j]] return self._new(self.rows, self.cols, entry) def _eval_permute_rows(self, perm): # apply the permutation to a list mapping = list(perm) def entry(i, j): return self[mapping[i], j] return self._new(self.rows, self.cols, entry) def _eval_trace(self): return sum(self[i, i] for i in range(self.rows)) def _eval_transpose(self): return self._new(self.cols, self.rows, lambda i, j: self[j, i]) def adjoint(self): """Conjugate transpose or Hermitian conjugation.""" return self._eval_adjoint() def applyfunc(self, f): """Apply a function to each element of the matrix. Examples ======== >>> from sympy import Matrix >>> m = Matrix(2, 2, lambda i, j: i*2+j) >>> m Matrix([ [0, 1], [2, 3]]) >>> m.applyfunc(lambda i: 2*i) Matrix([ [0, 2], [4, 6]]) """ if not callable(f): raise TypeError("`f` must be callable.") return self._eval_applyfunc(f) def as_real_imag(self): """Returns a tuple containing the (real, imaginary) part of matrix.""" return self._eval_as_real_imag() def conjugate(self): """Return the by-element conjugation. Examples ======== >>> from sympy.matrices import SparseMatrix >>> from sympy import I >>> a = SparseMatrix(((1, 2 + I), (3, 4), (I, -I))) >>> a Matrix([ [1, 2 + I], [3, 4], [I, -I]]) >>> a.C Matrix([ [ 1, 2 - I], [ 3, 4], [-I, I]]) See Also ======== transpose: Matrix transposition H: Hermite conjugation D: Dirac conjugation """ return self._eval_conjugate() def doit(self, **kwargs): return self.applyfunc(lambda x: x.doit()) def evalf(self, prec=None, **options): """Apply evalf() to each element of self.""" return self.applyfunc(lambda i: i.evalf(prec, **options)) def expand(self, deep=True, modulus=None, power_base=True, power_exp=True, mul=True, log=True, multinomial=True, basic=True, **hints): """Apply core.function.expand to each entry of the matrix. Examples ======== >>> from sympy.abc import x >>> from sympy.matrices import Matrix >>> Matrix(1, 1, [x*(x+1)]) Matrix([[x*(x + 1)]]) >>> _.expand() Matrix([[x**2 + x]]) """ return self.applyfunc(lambda x: x.expand( deep, modulus, power_base, power_exp, mul, log, multinomial, basic, **hints)) @property def H(self): """Return Hermite conjugate. Examples ======== >>> from sympy import Matrix, I >>> m = Matrix((0, 1 + I, 2, 3)) >>> m Matrix([ [ 0], [1 + I], [ 2], [ 3]]) >>> m.H Matrix([[0, 1 - I, 2, 3]]) See Also ======== conjugate: By-element conjugation D: Dirac conjugation """ return self.T.C def permute(self, perm, orientation='rows', direction='forward'): """Permute the rows or columns of a matrix by the given list of swaps. Parameters ========== perm : a permutation. This may be a list swaps (e.g., `[[1, 2], [0, 3]]`), or any valid input to the `Permutation` constructor, including a `Permutation()` itself. If `perm` is given explicitly as a list of indices or a `Permutation`, `direction` has no effect. orientation : ('rows' or 'cols') whether to permute the rows or the columns direction : ('forward', 'backward') whether to apply the permutations from the start of the list first, or from the back of the list first Examples ======== >>> from sympy.matrices import eye >>> M = eye(3) >>> M.permute([[0, 1], [0, 2]], orientation='rows', direction='forward') Matrix([ [0, 0, 1], [1, 0, 0], [0, 1, 0]]) >>> from sympy.matrices import eye >>> M = eye(3) >>> M.permute([[0, 1], [0, 2]], orientation='rows', direction='backward') Matrix([ [0, 1, 0], [0, 0, 1], [1, 0, 0]]) """ # allow british variants and `columns` if direction == 'forwards': direction = 'forward' if direction == 'backwards': direction = 'backward' if orientation == 'columns': orientation = 'cols' if direction not in ('forward', 'backward'): raise TypeError("direction='{}' is an invalid kwarg. " "Try 'forward' or 'backward'".format(direction)) if orientation not in ('rows', 'cols'): raise TypeError("orientation='{}' is an invalid kwarg. " "Try 'rows' or 'cols'".format(orientation)) # ensure all swaps are in range max_index = self.rows if orientation == 'rows' else self.cols if not all(0 <= t <= max_index for t in flatten(list(perm))): raise IndexError("`swap` indices out of range.") # see if we are a list of pairs try: assert len(perm[0]) == 2 # we are a list of swaps, so `direction` matters if direction == 'backward': perm = reversed(perm) # since Permutation doesn't let us have non-disjoint cycles, # we'll construct the explicit mapping ourselves XXX Bug #12479 mapping = list(range(max_index)) for (i, j) in perm: mapping[i], mapping[j] = mapping[j], mapping[i] perm = mapping except (TypeError, AssertionError, IndexError): pass from sympy.combinatorics import Permutation perm = Permutation(perm, size=max_index) if orientation == 'rows': return self._eval_permute_rows(perm) if orientation == 'cols': return self._eval_permute_cols(perm) def permute_cols(self, swaps, direction='forward'): """Alias for `self.permute(swaps, orientation='cols', direction=direction)` See Also ======== permute """ return self.permute(swaps, orientation='cols', direction=direction) def permute_rows(self, swaps, direction='forward'): """Alias for `self.permute(swaps, orientation='rows', direction=direction)` See Also ======== permute """ return self.permute(swaps, orientation='rows', direction=direction) def refine(self, assumptions=True): """Apply refine to each element of the matrix. Examples ======== >>> from sympy import Symbol, Matrix, Abs, sqrt, Q >>> x = Symbol('x') >>> Matrix([[Abs(x)**2, sqrt(x**2)],[sqrt(x**2), Abs(x)**2]]) Matrix([ [ Abs(x)**2, sqrt(x**2)], [sqrt(x**2), Abs(x)**2]]) >>> _.refine(Q.real(x)) Matrix([ [ x**2, Abs(x)], [Abs(x), x**2]]) """ return self.applyfunc(lambda x: refine(x, assumptions)) def replace(self, F, G, map=False): """Replaces Function F in Matrix entries with Function G. Examples ======== >>> from sympy import symbols, Function, Matrix >>> F, G = symbols('F, G', cls=Function) >>> M = Matrix(2, 2, lambda i, j: F(i+j)) ; M Matrix([ [F(0), F(1)], [F(1), F(2)]]) >>> N = M.replace(F,G) >>> N Matrix([ [G(0), G(1)], [G(1), G(2)]]) """ return self.applyfunc(lambda x: x.replace(F, G, map)) def simplify(self, ratio=1.7, measure=count_ops, rational=False, inverse=False): """Apply simplify to each element of the matrix. Examples ======== >>> from sympy.abc import x, y >>> from sympy import sin, cos >>> from sympy.matrices import SparseMatrix >>> SparseMatrix(1, 1, [x*sin(y)**2 + x*cos(y)**2]) Matrix([[x*sin(y)**2 + x*cos(y)**2]]) >>> _.simplify() Matrix([[x]]) """ return self.applyfunc(lambda x: x.simplify(ratio=ratio, measure=measure, rational=rational, inverse=inverse)) def subs(self, *args, **kwargs): # should mirror core.basic.subs """Return a new matrix with subs applied to each entry. Examples ======== >>> from sympy.abc import x, y >>> from sympy.matrices import SparseMatrix, Matrix >>> SparseMatrix(1, 1, [x]) Matrix([[x]]) >>> _.subs(x, y) Matrix([[y]]) >>> Matrix(_).subs(y, x) Matrix([[x]]) """ return self.applyfunc(lambda x: x.subs(*args, **kwargs)) def trace(self): """ Returns the trace of a square matrix i.e. the sum of the diagonal elements. Examples ======== >>> from sympy import Matrix >>> A = Matrix(2, 2, [1, 2, 3, 4]) >>> A.trace() 5 """ if self.rows != self.cols: raise NonSquareMatrixError() return self._eval_trace() def transpose(self): """ Returns the transpose of the matrix. Examples ======== >>> from sympy import Matrix >>> A = Matrix(2, 2, [1, 2, 3, 4]) >>> A.transpose() Matrix([ [1, 3], [2, 4]]) >>> from sympy import Matrix, I >>> m=Matrix(((1, 2+I), (3, 4))) >>> m Matrix([ [1, 2 + I], [3, 4]]) >>> m.transpose() Matrix([ [ 1, 3], [2 + I, 4]]) >>> m.T == m.transpose() True See Also ======== conjugate: By-element conjugation """ return self._eval_transpose() T = property(transpose, None, None, "Matrix transposition.") C = property(conjugate, None, None, "By-element conjugation.") n = evalf def xreplace(self, rule): # should mirror core.basic.xreplace """Return a new matrix with xreplace applied to each entry. Examples ======== >>> from sympy.abc import x, y >>> from sympy.matrices import SparseMatrix, Matrix >>> SparseMatrix(1, 1, [x]) Matrix([[x]]) >>> _.xreplace({x: y}) Matrix([[y]]) >>> Matrix(_).xreplace({y: x}) Matrix([[x]]) """ return self.applyfunc(lambda x: x.xreplace(rule)) _eval_simplify = simplify def _eval_trigsimp(self, **opts): from sympy.simplify import trigsimp return self.applyfunc(lambda x: trigsimp(x, **opts)) class MatrixArithmetic(MatrixRequired): """Provides basic matrix arithmetic operations. Should not be instantiated directly.""" _op_priority = 10.01 def _eval_Abs(self): return self._new(self.rows, self.cols, lambda i, j: Abs(self[i, j])) def _eval_add(self, other): return self._new(self.rows, self.cols, lambda i, j: self[i, j] + other[i, j]) def _eval_matrix_mul(self, other): def entry(i, j): try: return sum(self[i,k]*other[k,j] for k in range(self.cols)) except TypeError: # Block matrices don't work with `sum` or `Add` (ISSUE #11599) # They don't work with `sum` because `sum` tries to add `0` # initially, and for a matrix, that is a mix of a scalar and # a matrix, which raises a TypeError. Fall back to a # block-matrix-safe way to multiply if the `sum` fails. ret = self[i, 0]*other[0, j] for k in range(1, self.cols): ret += self[i, k]*other[k, j] return ret return self._new(self.rows, other.cols, entry) def _eval_matrix_mul_elementwise(self, other): return self._new(self.rows, self.cols, lambda i, j: self[i,j]*other[i,j]) def _eval_matrix_rmul(self, other): def entry(i, j): return sum(other[i,k]*self[k,j] for k in range(other.cols)) return self._new(other.rows, self.cols, entry) def _eval_pow_by_recursion(self, num): if num == 1: return self if num % 2 == 1: return self * self._eval_pow_by_recursion(num - 1) ret = self._eval_pow_by_recursion(num // 2) return ret * ret def _eval_scalar_mul(self, other): return self._new(self.rows, self.cols, lambda i, j: self[i,j]*other) def _eval_scalar_rmul(self, other): return self._new(self.rows, self.cols, lambda i, j: other*self[i,j]) def _eval_Mod(self, other): from sympy import Mod return self._new(self.rows, self.cols, lambda i, j: Mod(self[i, j], other)) # python arithmetic functions def __abs__(self): """Returns a new matrix with entry-wise absolute values.""" return self._eval_Abs() @call_highest_priority('__radd__') def __add__(self, other): """Return self + other, raising ShapeError if shapes don't match.""" other = _matrixify(other) # matrix-like objects can have shapes. This is # our first sanity check. if hasattr(other, 'shape'): if self.shape != other.shape: raise ShapeError("Matrix size mismatch: %s + %s" % ( self.shape, other.shape)) # honest sympy matrices defer to their class's routine if getattr(other, 'is_Matrix', False): # call the highest-priority class's _eval_add a, b = self, other if a.__class__ != classof(a, b): b, a = a, b return a._eval_add(b) # Matrix-like objects can be passed to CommonMatrix routines directly. if getattr(other, 'is_MatrixLike', False): return MatrixArithmetic._eval_add(self, other) raise TypeError('cannot add %s and %s' % (type(self), type(other))) @call_highest_priority('__rdiv__') def __div__(self, other): return self * (S.One / other) @call_highest_priority('__rmatmul__') def __matmul__(self, other): other = _matrixify(other) if not getattr(other, 'is_Matrix', False) and not getattr(other, 'is_MatrixLike', False): return NotImplemented return self.__mul__(other) def __mod__(self, other): return self.applyfunc(lambda x: x % other) @call_highest_priority('__rmul__') def __mul__(self, other): """Return self*other where other is either a scalar or a matrix of compatible dimensions. Examples ======== >>> from sympy.matrices import Matrix >>> A = Matrix([[1, 2, 3], [4, 5, 6]]) >>> 2*A == A*2 == Matrix([[2, 4, 6], [8, 10, 12]]) True >>> B = Matrix([[1, 2, 3], [4, 5, 6], [7, 8, 9]]) >>> A*B Matrix([ [30, 36, 42], [66, 81, 96]]) >>> B*A Traceback (most recent call last): ... ShapeError: Matrices size mismatch. >>> See Also ======== matrix_multiply_elementwise """ other = _matrixify(other) # matrix-like objects can have shapes. This is # our first sanity check. if hasattr(other, 'shape') and len(other.shape) == 2: if self.shape[1] != other.shape[0]: raise ShapeError("Matrix size mismatch: %s * %s." % ( self.shape, other.shape)) # honest sympy matrices defer to their class's routine if getattr(other, 'is_Matrix', False): return self._eval_matrix_mul(other) # Matrix-like objects can be passed to CommonMatrix routines directly. if getattr(other, 'is_MatrixLike', False): return MatrixArithmetic._eval_matrix_mul(self, other) # if 'other' is not iterable then scalar multiplication. if not isinstance(other, Iterable): try: return self._eval_scalar_mul(other) except TypeError: pass return NotImplemented def __neg__(self): return self._eval_scalar_mul(-1) @call_highest_priority('__rpow__') def __pow__(self, num): if self.rows != self.cols: raise NonSquareMatrixError() a = self jordan_pow = getattr(a, '_matrix_pow_by_jordan_blocks', None) num = sympify(num) if num.is_Number and num % 1 == 0: if a.rows == 1: return a._new([[a[0]**num]]) if num == 0: return self._new(self.rows, self.cols, lambda i, j: int(i == j)) if num < 0: num = -num a = a.inv() # When certain conditions are met, # Jordan block algorithm is faster than # computation by recursion. elif a.rows == 2 and num > 100000 and jordan_pow is not None: try: return jordan_pow(num) except MatrixError: pass return a._eval_pow_by_recursion(num) elif not num.is_Number and num.is_negative is None and a.det() == 0: from sympy.matrices.expressions import MatPow return MatPow(a, num) elif isinstance(num, (Expr, float)): return jordan_pow(num) else: raise TypeError( "Only SymPy expressions or integers are supported as exponent for matrices") @call_highest_priority('__add__') def __radd__(self, other): return self + other @call_highest_priority('__matmul__') def __rmatmul__(self, other): other = _matrixify(other) if not getattr(other, 'is_Matrix', False) and not getattr(other, 'is_MatrixLike', False): return NotImplemented return self.__rmul__(other) @call_highest_priority('__mul__') def __rmul__(self, other): other = _matrixify(other) # matrix-like objects can have shapes. This is # our first sanity check. if hasattr(other, 'shape') and len(other.shape) == 2: if self.shape[0] != other.shape[1]: raise ShapeError("Matrix size mismatch.") # honest sympy matrices defer to their class's routine if getattr(other, 'is_Matrix', False): return other._new(other.as_mutable() * self) # Matrix-like objects can be passed to CommonMatrix routines directly. if getattr(other, 'is_MatrixLike', False): return MatrixArithmetic._eval_matrix_rmul(self, other) # if 'other' is not iterable then scalar multiplication. if not isinstance(other, Iterable): try: return self._eval_scalar_rmul(other) except TypeError: pass return NotImplemented @call_highest_priority('__sub__') def __rsub__(self, a): return (-self) + a @call_highest_priority('__rsub__') def __sub__(self, a): return self + (-a) @call_highest_priority('__rtruediv__') def __truediv__(self, other): return self.__div__(other) def multiply_elementwise(self, other): """Return the Hadamard product (elementwise product) of A and B Examples ======== >>> from sympy.matrices import Matrix >>> A = Matrix([[0, 1, 2], [3, 4, 5]]) >>> B = Matrix([[1, 10, 100], [100, 10, 1]]) >>> A.multiply_elementwise(B) Matrix([ [ 0, 10, 200], [300, 40, 5]]) See Also ======== cross dot multiply """ if self.shape != other.shape: raise ShapeError("Matrix shapes must agree {} != {}".format(self.shape, other.shape)) return self._eval_matrix_mul_elementwise(other) class MatrixCommon(MatrixArithmetic, MatrixOperations, MatrixProperties, MatrixSpecial, MatrixShaping): """All common matrix operations including basic arithmetic, shaping, and special matrices like `zeros`, and `eye`.""" _diff_wrt = True class _MinimalMatrix(object): """Class providing the minimum functionality for a matrix-like object and implementing every method required for a `MatrixRequired`. This class does not have everything needed to become a full-fledged SymPy object, but it will satisfy the requirements of anything inheriting from `MatrixRequired`. If you wish to make a specialized matrix type, make sure to implement these methods and properties with the exception of `__init__` and `__repr__` which are included for convenience.""" is_MatrixLike = True _sympify = staticmethod(sympify) _class_priority = 3 is_Matrix = True is_MatrixExpr = False @classmethod def _new(cls, *args, **kwargs): return cls(*args, **kwargs) def __init__(self, rows, cols=None, mat=None): if isfunction(mat): # if we passed in a function, use that to populate the indices mat = list(mat(i, j) for i in range(rows) for j in range(cols)) if cols is None and mat is None: mat = rows rows, cols = getattr(mat, 'shape', (rows, cols)) try: # if we passed in a list of lists, flatten it and set the size if cols is None and mat is None: mat = rows cols = len(mat[0]) rows = len(mat) mat = [x for l in mat for x in l] except (IndexError, TypeError): pass self.mat = tuple(self._sympify(x) for x in mat) self.rows, self.cols = rows, cols if self.rows is None or self.cols is None: raise NotImplementedError("Cannot initialize matrix with given parameters") def __getitem__(self, key): def _normalize_slices(row_slice, col_slice): """Ensure that row_slice and col_slice don't have `None` in their arguments. Any integers are converted to slices of length 1""" if not isinstance(row_slice, slice): row_slice = slice(row_slice, row_slice + 1, None) row_slice = slice(*row_slice.indices(self.rows)) if not isinstance(col_slice, slice): col_slice = slice(col_slice, col_slice + 1, None) col_slice = slice(*col_slice.indices(self.cols)) return (row_slice, col_slice) def _coord_to_index(i, j): """Return the index in _mat corresponding to the (i,j) position in the matrix. """ return i * self.cols + j if isinstance(key, tuple): i, j = key if isinstance(i, slice) or isinstance(j, slice): # if the coordinates are not slices, make them so # and expand the slices so they don't contain `None` i, j = _normalize_slices(i, j) rowsList, colsList = list(range(self.rows))[i], \ list(range(self.cols))[j] indices = (i * self.cols + j for i in rowsList for j in colsList) return self._new(len(rowsList), len(colsList), list(self.mat[i] for i in indices)) # if the key is a tuple of ints, change # it to an array index key = _coord_to_index(i, j) return self.mat[key] def __eq__(self, other): try: classof(self, other) except TypeError: return False return ( self.shape == other.shape and list(self) == list(other)) def __len__(self): return self.rows*self.cols def __repr__(self): return "_MinimalMatrix({}, {}, {})".format(self.rows, self.cols, self.mat) @property def shape(self): return (self.rows, self.cols) class _MatrixWrapper(object): """Wrapper class providing the minimum functionality for a matrix-like object: .rows, .cols, .shape, indexability, and iterability. CommonMatrix math operations should work on matrix-like objects. For example, wrapping a numpy matrix in a MatrixWrapper allows it to be passed to CommonMatrix. """ is_MatrixLike = True def __init__(self, mat, shape=None): self.mat = mat self.rows, self.cols = mat.shape if shape is None else shape def __getattr__(self, attr): """Most attribute access is passed straight through to the stored matrix""" return getattr(self.mat, attr) def __getitem__(self, key): return self.mat.__getitem__(key) def _matrixify(mat): """If `mat` is a Matrix or is matrix-like, return a Matrix or MatrixWrapper object. Otherwise `mat` is passed through without modification.""" if getattr(mat, 'is_Matrix', False): return mat if hasattr(mat, 'shape'): if len(mat.shape) == 2: return _MatrixWrapper(mat) return mat def a2idx(j, n=None): """Return integer after making positive and validating against n.""" if type(j) is not int: jindex = getattr(j, '__index__', None) if jindex is not None: j = jindex() else: raise IndexError("Invalid index a[%r]" % (j,)) if n is not None: if j < 0: j += n if not (j >= 0 and j < n): raise IndexError("Index out of range: a[%s]" % (j,)) return int(j) def classof(A, B): """ Get the type of the result when combining matrices of different types. Currently the strategy is that immutability is contagious. Examples ======== >>> from sympy import Matrix, ImmutableMatrix >>> from sympy.matrices.common import classof >>> M = Matrix([[1, 2], [3, 4]]) # a Mutable Matrix >>> IM = ImmutableMatrix([[1, 2], [3, 4]]) >>> classof(M, IM) <class 'sympy.matrices.immutable.ImmutableDenseMatrix'> """ priority_A = getattr(A, '_class_priority', None) priority_B = getattr(B, '_class_priority', None) if None not in (priority_A, priority_B): if A._class_priority > B._class_priority: return A.__class__ else: return B.__class__ try: import numpy except ImportError: pass else: if isinstance(A, numpy.ndarray): return B.__class__ if isinstance(B, numpy.ndarray): return A.__class__ raise TypeError("Incompatible classes %s, %s" % (A.__class__, B.__class__))
ad8d0fd0dcaf33f3ee4809a633e6620ecd32d8c280cd1f8e7ba9361853ef3269
from __future__ import division, print_function import random from sympy.core import SympifyError from sympy.core.basic import Basic from sympy.core.compatibility import is_sequence, range, reduce from sympy.core.expr import Expr from sympy.core.function import count_ops, expand_mul from sympy.core.singleton import S from sympy.core.symbol import Symbol from sympy.core.sympify import sympify from sympy.functions.elementary.miscellaneous import sqrt from sympy.functions.elementary.trigonometric import cos, sin from sympy.matrices.common import a2idx, classof from sympy.matrices.matrices import MatrixBase, ShapeError from sympy.simplify import simplify as _simplify from sympy.utilities.decorator import doctest_depends_on from sympy.utilities.misc import filldedent def _iszero(x): """Returns True if x is zero.""" return x.is_zero def _compare_sequence(a, b): """Compares the elements of a list/tuple `a` and a list/tuple `b`. `_compare_sequence((1,2), [1, 2])` is True, whereas `(1,2) == [1, 2]` is False""" if type(a) is type(b): # if they are the same type, compare directly return a == b # there is no overhead for calling `tuple` on a # tuple return tuple(a) == tuple(b) class DenseMatrix(MatrixBase): is_MatrixExpr = False _op_priority = 10.01 _class_priority = 4 def __eq__(self, other): other = sympify(other) self_shape = getattr(self, 'shape', None) other_shape = getattr(other, 'shape', None) if None in (self_shape, other_shape): return False if self_shape != other_shape: return False if isinstance(other, Matrix): return _compare_sequence(self._mat, other._mat) elif isinstance(other, MatrixBase): return _compare_sequence(self._mat, Matrix(other)._mat) def __getitem__(self, key): """Return portion of self defined by key. If the key involves a slice then a list will be returned (if key is a single slice) or a matrix (if key was a tuple involving a slice). Examples ======== >>> from sympy import Matrix, I >>> m = Matrix([ ... [1, 2 + I], ... [3, 4 ]]) If the key is a tuple that doesn't involve a slice then that element is returned: >>> m[1, 0] 3 When a tuple key involves a slice, a matrix is returned. Here, the first column is selected (all rows, column 0): >>> m[:, 0] Matrix([ [1], [3]]) If the slice is not a tuple then it selects from the underlying list of elements that are arranged in row order and a list is returned if a slice is involved: >>> m[0] 1 >>> m[::2] [1, 3] """ if isinstance(key, tuple): i, j = key try: i, j = self.key2ij(key) return self._mat[i*self.cols + j] except (TypeError, IndexError): if (isinstance(i, Expr) and not i.is_number) or (isinstance(j, Expr) and not j.is_number): if ((j < 0) is True) or ((j >= self.shape[1]) is True) or\ ((i < 0) is True) or ((i >= self.shape[0]) is True): raise ValueError("index out of boundary") from sympy.matrices.expressions.matexpr import MatrixElement return MatrixElement(self, i, j) if isinstance(i, slice): # XXX remove list() when PY2 support is dropped i = list(range(self.rows))[i] elif is_sequence(i): pass else: i = [i] if isinstance(j, slice): # XXX remove list() when PY2 support is dropped j = list(range(self.cols))[j] elif is_sequence(j): pass else: j = [j] return self.extract(i, j) else: # row-wise decomposition of matrix if isinstance(key, slice): return self._mat[key] return self._mat[a2idx(key)] def __setitem__(self, key, value): raise NotImplementedError() def _cholesky(self, hermitian=True): """Helper function of cholesky. Without the error checks. To be used privately. Implements the Cholesky-Banachiewicz algorithm. Returns L such that L*L.H == self if hermitian flag is True, or L*L.T == self if hermitian is False. """ L = zeros(self.rows, self.rows) if hermitian: for i in range(self.rows): for j in range(i): L[i, j] = (1 / L[j, j])*expand_mul(self[i, j] - sum(L[i, k]*L[j, k].conjugate() for k in range(j))) Lii2 = expand_mul(self[i, i] - sum(L[i, k]*L[i, k].conjugate() for k in range(i))) if Lii2.is_positive is False: raise ValueError("Matrix must be positive-definite") L[i, i] = sqrt(Lii2) else: for i in range(self.rows): for j in range(i): L[i, j] = (1 / L[j, j])*(self[i, j] - sum(L[i, k]*L[j, k] for k in range(j))) L[i, i] = sqrt(self[i, i] - sum(L[i, k]**2 for k in range(i))) return self._new(L) def _diagonal_solve(self, rhs): """Helper function of function diagonal_solve, without the error checks, to be used privately. """ return self._new(rhs.rows, rhs.cols, lambda i, j: rhs[i, j] / self[i, i]) def _eval_add(self, other): # we assume both arguments are dense matrices since # sparse matrices have a higher priority mat = [a + b for a,b in zip(self._mat, other._mat)] return classof(self, other)._new(self.rows, self.cols, mat, copy=False) def _eval_extract(self, rowsList, colsList): mat = self._mat cols = self.cols indices = (i * cols + j for i in rowsList for j in colsList) return self._new(len(rowsList), len(colsList), list(mat[i] for i in indices), copy=False) def _eval_matrix_mul(self, other): from sympy import Add # cache attributes for faster access self_rows, self_cols = self.rows, self.cols other_rows, other_cols = other.rows, other.cols other_len = other_rows * other_cols new_mat_rows = self.rows new_mat_cols = other.cols # preallocate the array new_mat = [S.Zero]*new_mat_rows*new_mat_cols # if we multiply an n x 0 with a 0 x m, the # expected behavior is to produce an n x m matrix of zeros if self.cols != 0 and other.rows != 0: # cache self._mat and other._mat for performance mat = self._mat other_mat = other._mat for i in range(len(new_mat)): row, col = i // new_mat_cols, i % new_mat_cols row_indices = range(self_cols*row, self_cols*(row+1)) col_indices = range(col, other_len, other_cols) vec = (mat[a]*other_mat[b] for a,b in zip(row_indices, col_indices)) try: new_mat[i] = Add(*vec) except (TypeError, SympifyError): # Block matrices don't work with `sum` or `Add` (ISSUE #11599) # They don't work with `sum` because `sum` tries to add `0` # initially, and for a matrix, that is a mix of a scalar and # a matrix, which raises a TypeError. Fall back to a # block-matrix-safe way to multiply if the `sum` fails. vec = (mat[a]*other_mat[b] for a,b in zip(row_indices, col_indices)) new_mat[i] = reduce(lambda a,b: a + b, vec) return classof(self, other)._new(new_mat_rows, new_mat_cols, new_mat, copy=False) def _eval_matrix_mul_elementwise(self, other): mat = [a*b for a,b in zip(self._mat, other._mat)] return classof(self, other)._new(self.rows, self.cols, mat, copy=False) def _eval_inverse(self, **kwargs): """Return the matrix inverse using the method indicated (default is Gauss elimination). kwargs ====== method : ('GE', 'LU', or 'ADJ') iszerofunc try_block_diag Notes ===== According to the ``method`` keyword, it calls the appropriate method: GE .... inverse_GE(); default LU .... inverse_LU() ADJ ... inverse_ADJ() According to the ``try_block_diag`` keyword, it will try to form block diagonal matrices using the method get_diag_blocks(), invert these individually, and then reconstruct the full inverse matrix. Note, the GE and LU methods may require the matrix to be simplified before it is inverted in order to properly detect zeros during pivoting. In difficult cases a custom zero detection function can be provided by setting the ``iszerosfunc`` argument to a function that should return True if its argument is zero. The ADJ routine computes the determinant and uses that to detect singular matrices in addition to testing for zeros on the diagonal. See Also ======== inverse_LU inverse_GE inverse_ADJ """ from sympy.matrices import diag method = kwargs.get('method', 'GE') iszerofunc = kwargs.get('iszerofunc', _iszero) if kwargs.get('try_block_diag', False): blocks = self.get_diag_blocks() r = [] for block in blocks: r.append(block.inv(method=method, iszerofunc=iszerofunc)) return diag(*r) M = self.as_mutable() if method == "GE": rv = M.inverse_GE(iszerofunc=iszerofunc) elif method == "LU": rv = M.inverse_LU(iszerofunc=iszerofunc) elif method == "ADJ": rv = M.inverse_ADJ(iszerofunc=iszerofunc) else: # make sure to add an invertibility check (as in inverse_LU) # if a new method is added. raise ValueError("Inversion method unrecognized") return self._new(rv) def _eval_scalar_mul(self, other): mat = [other*a for a in self._mat] return self._new(self.rows, self.cols, mat, copy=False) def _eval_scalar_rmul(self, other): mat = [a*other for a in self._mat] return self._new(self.rows, self.cols, mat, copy=False) def _eval_tolist(self): mat = list(self._mat) cols = self.cols return [mat[i*cols:(i + 1)*cols] for i in range(self.rows)] def _LDLdecomposition(self, hermitian=True): """Helper function of LDLdecomposition. Without the error checks. To be used privately. Returns L and D such that L*D*L.H == self if hermitian flag is True, or L*D*L.T == self if hermitian is False. """ # https://en.wikipedia.org/wiki/Cholesky_decomposition#LDL_decomposition_2 D = zeros(self.rows, self.rows) L = eye(self.rows) if hermitian: for i in range(self.rows): for j in range(i): L[i, j] = (1 / D[j, j])*expand_mul(self[i, j] - sum( L[i, k]*L[j, k].conjugate()*D[k, k] for k in range(j))) D[i, i] = expand_mul(self[i, i] - sum(L[i, k]*L[i, k].conjugate()*D[k, k] for k in range(i))) if D[i, i].is_positive is False: raise ValueError("Matrix must be positive-definite") else: for i in range(self.rows): for j in range(i): L[i, j] = (1 / D[j, j])*(self[i, j] - sum( L[i, k]*L[j, k]*D[k, k] for k in range(j))) D[i, i] = self[i, i] - sum(L[i, k]**2*D[k, k] for k in range(i)) return self._new(L), self._new(D) def _lower_triangular_solve(self, rhs): """Helper function of function lower_triangular_solve. Without the error checks. To be used privately. """ X = zeros(self.rows, rhs.cols) for j in range(rhs.cols): for i in range(self.rows): if self[i, i] == 0: raise TypeError("Matrix must be non-singular.") X[i, j] = (rhs[i, j] - sum(self[i, k]*X[k, j] for k in range(i))) / self[i, i] return self._new(X) def _upper_triangular_solve(self, rhs): """Helper function of function upper_triangular_solve. Without the error checks, to be used privately. """ X = zeros(self.rows, rhs.cols) for j in range(rhs.cols): for i in reversed(range(self.rows)): if self[i, i] == 0: raise ValueError("Matrix must be non-singular.") X[i, j] = (rhs[i, j] - sum(self[i, k]*X[k, j] for k in range(i + 1, self.rows))) / self[i, i] return self._new(X) def as_immutable(self): """Returns an Immutable version of this Matrix """ from .immutable import ImmutableDenseMatrix as cls if self.rows and self.cols: return cls._new(self.tolist()) return cls._new(self.rows, self.cols, []) def as_mutable(self): """Returns a mutable version of this matrix Examples ======== >>> from sympy import ImmutableMatrix >>> X = ImmutableMatrix([[1, 2], [3, 4]]) >>> Y = X.as_mutable() >>> Y[1, 1] = 5 # Can set values in Y >>> Y Matrix([ [1, 2], [3, 5]]) """ return Matrix(self) def equals(self, other, failing_expression=False): """Applies ``equals`` to corresponding elements of the matrices, trying to prove that the elements are equivalent, returning True if they are, False if any pair is not, and None (or the first failing expression if failing_expression is True) if it cannot be decided if the expressions are equivalent or not. This is, in general, an expensive operation. Examples ======== >>> from sympy.matrices import Matrix >>> from sympy.abc import x >>> from sympy import cos >>> A = Matrix([x*(x - 1), 0]) >>> B = Matrix([x**2 - x, 0]) >>> A == B False >>> A.simplify() == B.simplify() True >>> A.equals(B) True >>> A.equals(2) False See Also ======== sympy.core.expr.equals """ self_shape = getattr(self, 'shape', None) other_shape = getattr(other, 'shape', None) if None in (self_shape, other_shape): return False if self_shape != other_shape: return False rv = True for i in range(self.rows): for j in range(self.cols): ans = self[i, j].equals(other[i, j], failing_expression) if ans is False: return False elif ans is not True and rv is True: rv = ans return rv def _force_mutable(x): """Return a matrix as a Matrix, otherwise return x.""" if getattr(x, 'is_Matrix', False): return x.as_mutable() elif isinstance(x, Basic): return x elif hasattr(x, '__array__'): a = x.__array__() if len(a.shape) == 0: return sympify(a) return Matrix(x) return x class MutableDenseMatrix(DenseMatrix, MatrixBase): def __new__(cls, *args, **kwargs): return cls._new(*args, **kwargs) @classmethod def _new(cls, *args, **kwargs): # if the `copy` flag is set to False, the input # was rows, cols, [list]. It should be used directly # without creating a copy. if kwargs.get('copy', True) is False: if len(args) != 3: raise TypeError("'copy=False' requires a matrix be initialized as rows,cols,[list]") rows, cols, flat_list = args else: rows, cols, flat_list = cls._handle_creation_inputs(*args, **kwargs) flat_list = list(flat_list) # create a shallow copy self = object.__new__(cls) self.rows = rows self.cols = cols self._mat = flat_list return self def __setitem__(self, key, value): """ Examples ======== >>> from sympy import Matrix, I, zeros, ones >>> m = Matrix(((1, 2+I), (3, 4))) >>> m Matrix([ [1, 2 + I], [3, 4]]) >>> m[1, 0] = 9 >>> m Matrix([ [1, 2 + I], [9, 4]]) >>> m[1, 0] = [[0, 1]] To replace row r you assign to position r*m where m is the number of columns: >>> M = zeros(4) >>> m = M.cols >>> M[3*m] = ones(1, m)*2; M Matrix([ [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [2, 2, 2, 2]]) And to replace column c you can assign to position c: >>> M[2] = ones(m, 1)*4; M Matrix([ [0, 0, 4, 0], [0, 0, 4, 0], [0, 0, 4, 0], [2, 2, 4, 2]]) """ rv = self._setitem(key, value) if rv is not None: i, j, value = rv self._mat[i*self.cols + j] = value def as_mutable(self): return self.copy() def col_del(self, i): """Delete the given column. Examples ======== >>> from sympy.matrices import eye >>> M = eye(3) >>> M.col_del(1) >>> M Matrix([ [1, 0], [0, 0], [0, 1]]) See Also ======== col row_del """ if i < -self.cols or i >= self.cols: raise IndexError("Index out of range: 'i=%s', valid -%s <= i < %s" % (i, self.cols, self.cols)) for j in range(self.rows - 1, -1, -1): del self._mat[i + j*self.cols] self.cols -= 1 def col_op(self, j, f): """In-place operation on col j using two-arg functor whose args are interpreted as (self[i, j], i). Examples ======== >>> from sympy.matrices import eye >>> M = eye(3) >>> M.col_op(1, lambda v, i: v + 2*M[i, 0]); M Matrix([ [1, 2, 0], [0, 1, 0], [0, 0, 1]]) See Also ======== col row_op """ self._mat[j::self.cols] = [f(*t) for t in list(zip(self._mat[j::self.cols], list(range(self.rows))))] def col_swap(self, i, j): """Swap the two given columns of the matrix in-place. Examples ======== >>> from sympy.matrices import Matrix >>> M = Matrix([[1, 0], [1, 0]]) >>> M Matrix([ [1, 0], [1, 0]]) >>> M.col_swap(0, 1) >>> M Matrix([ [0, 1], [0, 1]]) See Also ======== col row_swap """ for k in range(0, self.rows): self[k, i], self[k, j] = self[k, j], self[k, i] def copyin_list(self, key, value): """Copy in elements from a list. Parameters ========== key : slice The section of this matrix to replace. value : iterable The iterable to copy values from. Examples ======== >>> from sympy.matrices import eye >>> I = eye(3) >>> I[:2, 0] = [1, 2] # col >>> I Matrix([ [1, 0, 0], [2, 1, 0], [0, 0, 1]]) >>> I[1, :2] = [[3, 4]] >>> I Matrix([ [1, 0, 0], [3, 4, 0], [0, 0, 1]]) See Also ======== copyin_matrix """ if not is_sequence(value): raise TypeError("`value` must be an ordered iterable, not %s." % type(value)) return self.copyin_matrix(key, Matrix(value)) def copyin_matrix(self, key, value): """Copy in values from a matrix into the given bounds. Parameters ========== key : slice The section of this matrix to replace. value : Matrix The matrix to copy values from. Examples ======== >>> from sympy.matrices import Matrix, eye >>> M = Matrix([[0, 1], [2, 3], [4, 5]]) >>> I = eye(3) >>> I[:3, :2] = M >>> I Matrix([ [0, 1, 0], [2, 3, 0], [4, 5, 1]]) >>> I[0, 1] = M >>> I Matrix([ [0, 0, 1], [2, 2, 3], [4, 4, 5]]) See Also ======== copyin_list """ rlo, rhi, clo, chi = self.key2bounds(key) shape = value.shape dr, dc = rhi - rlo, chi - clo if shape != (dr, dc): raise ShapeError(filldedent("The Matrix `value` doesn't have the " "same dimensions " "as the in sub-Matrix given by `key`.")) for i in range(value.rows): for j in range(value.cols): self[i + rlo, j + clo] = value[i, j] def fill(self, value): """Fill the matrix with the scalar value. See Also ======== zeros ones """ self._mat = [value]*len(self) def row_del(self, i): """Delete the given row. Examples ======== >>> from sympy.matrices import eye >>> M = eye(3) >>> M.row_del(1) >>> M Matrix([ [1, 0, 0], [0, 0, 1]]) See Also ======== row col_del """ if i < -self.rows or i >= self.rows: raise IndexError("Index out of range: 'i = %s', valid -%s <= i" " < %s" % (i, self.rows, self.rows)) if i < 0: i += self.rows del self._mat[i*self.cols:(i+1)*self.cols] self.rows -= 1 def row_op(self, i, f): """In-place operation on row ``i`` using two-arg functor whose args are interpreted as ``(self[i, j], j)``. Examples ======== >>> from sympy.matrices import eye >>> M = eye(3) >>> M.row_op(1, lambda v, j: v + 2*M[0, j]); M Matrix([ [1, 0, 0], [2, 1, 0], [0, 0, 1]]) See Also ======== row zip_row_op col_op """ i0 = i*self.cols ri = self._mat[i0: i0 + self.cols] self._mat[i0: i0 + self.cols] = [f(x, j) for x, j in zip(ri, list(range(self.cols)))] def row_swap(self, i, j): """Swap the two given rows of the matrix in-place. Examples ======== >>> from sympy.matrices import Matrix >>> M = Matrix([[0, 1], [1, 0]]) >>> M Matrix([ [0, 1], [1, 0]]) >>> M.row_swap(0, 1) >>> M Matrix([ [1, 0], [0, 1]]) See Also ======== row col_swap """ for k in range(0, self.cols): self[i, k], self[j, k] = self[j, k], self[i, k] def simplify(self, ratio=1.7, measure=count_ops, rational=False, inverse=False): """Applies simplify to the elements of a matrix in place. This is a shortcut for M.applyfunc(lambda x: simplify(x, ratio, measure)) See Also ======== sympy.simplify.simplify.simplify """ for i in range(len(self._mat)): self._mat[i] = _simplify(self._mat[i], ratio=ratio, measure=measure, rational=rational, inverse=inverse) def zip_row_op(self, i, k, f): """In-place operation on row ``i`` using two-arg functor whose args are interpreted as ``(self[i, j], self[k, j])``. Examples ======== >>> from sympy.matrices import eye >>> M = eye(3) >>> M.zip_row_op(1, 0, lambda v, u: v + 2*u); M Matrix([ [1, 0, 0], [2, 1, 0], [0, 0, 1]]) See Also ======== row row_op col_op """ i0 = i*self.cols k0 = k*self.cols ri = self._mat[i0: i0 + self.cols] rk = self._mat[k0: k0 + self.cols] self._mat[i0: i0 + self.cols] = [f(x, y) for x, y in zip(ri, rk)] # Utility functions MutableMatrix = Matrix = MutableDenseMatrix ########### # Numpy Utility Functions: # list2numpy, matrix2numpy, symmarray, rot_axis[123] ########### def list2numpy(l, dtype=object): # pragma: no cover """Converts python list of SymPy expressions to a NumPy array. See Also ======== matrix2numpy """ from numpy import empty a = empty(len(l), dtype) for i, s in enumerate(l): a[i] = s return a def matrix2numpy(m, dtype=object): # pragma: no cover """Converts SymPy's matrix to a NumPy array. See Also ======== list2numpy """ from numpy import empty a = empty(m.shape, dtype) for i in range(m.rows): for j in range(m.cols): a[i, j] = m[i, j] return a def rot_axis3(theta): """Returns a rotation matrix for a rotation of theta (in radians) about the 3-axis. Examples ======== >>> from sympy import pi >>> from sympy.matrices import rot_axis3 A rotation of pi/3 (60 degrees): >>> theta = pi/3 >>> rot_axis3(theta) Matrix([ [ 1/2, sqrt(3)/2, 0], [-sqrt(3)/2, 1/2, 0], [ 0, 0, 1]]) If we rotate by pi/2 (90 degrees): >>> rot_axis3(pi/2) Matrix([ [ 0, 1, 0], [-1, 0, 0], [ 0, 0, 1]]) See Also ======== rot_axis1: Returns a rotation matrix for a rotation of theta (in radians) about the 1-axis rot_axis2: Returns a rotation matrix for a rotation of theta (in radians) about the 2-axis """ ct = cos(theta) st = sin(theta) lil = ((ct, st, 0), (-st, ct, 0), (0, 0, 1)) return Matrix(lil) def rot_axis2(theta): """Returns a rotation matrix for a rotation of theta (in radians) about the 2-axis. Examples ======== >>> from sympy import pi >>> from sympy.matrices import rot_axis2 A rotation of pi/3 (60 degrees): >>> theta = pi/3 >>> rot_axis2(theta) Matrix([ [ 1/2, 0, -sqrt(3)/2], [ 0, 1, 0], [sqrt(3)/2, 0, 1/2]]) If we rotate by pi/2 (90 degrees): >>> rot_axis2(pi/2) Matrix([ [0, 0, -1], [0, 1, 0], [1, 0, 0]]) See Also ======== rot_axis1: Returns a rotation matrix for a rotation of theta (in radians) about the 1-axis rot_axis3: Returns a rotation matrix for a rotation of theta (in radians) about the 3-axis """ ct = cos(theta) st = sin(theta) lil = ((ct, 0, -st), (0, 1, 0), (st, 0, ct)) return Matrix(lil) def rot_axis1(theta): """Returns a rotation matrix for a rotation of theta (in radians) about the 1-axis. Examples ======== >>> from sympy import pi >>> from sympy.matrices import rot_axis1 A rotation of pi/3 (60 degrees): >>> theta = pi/3 >>> rot_axis1(theta) Matrix([ [1, 0, 0], [0, 1/2, sqrt(3)/2], [0, -sqrt(3)/2, 1/2]]) If we rotate by pi/2 (90 degrees): >>> rot_axis1(pi/2) Matrix([ [1, 0, 0], [0, 0, 1], [0, -1, 0]]) See Also ======== rot_axis2: Returns a rotation matrix for a rotation of theta (in radians) about the 2-axis rot_axis3: Returns a rotation matrix for a rotation of theta (in radians) about the 3-axis """ ct = cos(theta) st = sin(theta) lil = ((1, 0, 0), (0, ct, st), (0, -st, ct)) return Matrix(lil) @doctest_depends_on(modules=('numpy',)) def symarray(prefix, shape, **kwargs): # pragma: no cover r"""Create a numpy ndarray of symbols (as an object array). The created symbols are named ``prefix_i1_i2_``... You should thus provide a non-empty prefix if you want your symbols to be unique for different output arrays, as SymPy symbols with identical names are the same object. Parameters ---------- prefix : string A prefix prepended to the name of every symbol. shape : int or tuple Shape of the created array. If an int, the array is one-dimensional; for more than one dimension the shape must be a tuple. \*\*kwargs : dict keyword arguments passed on to Symbol Examples ======== These doctests require numpy. >>> from sympy import symarray >>> symarray('', 3) [_0 _1 _2] If you want multiple symarrays to contain distinct symbols, you *must* provide unique prefixes: >>> a = symarray('', 3) >>> b = symarray('', 3) >>> a[0] == b[0] True >>> a = symarray('a', 3) >>> b = symarray('b', 3) >>> a[0] == b[0] False Creating symarrays with a prefix: >>> symarray('a', 3) [a_0 a_1 a_2] For more than one dimension, the shape must be given as a tuple: >>> symarray('a', (2, 3)) [[a_0_0 a_0_1 a_0_2] [a_1_0 a_1_1 a_1_2]] >>> symarray('a', (2, 3, 2)) [[[a_0_0_0 a_0_0_1] [a_0_1_0 a_0_1_1] [a_0_2_0 a_0_2_1]] <BLANKLINE> [[a_1_0_0 a_1_0_1] [a_1_1_0 a_1_1_1] [a_1_2_0 a_1_2_1]]] For setting assumptions of the underlying Symbols: >>> [s.is_real for s in symarray('a', 2, real=True)] [True, True] """ from numpy import empty, ndindex arr = empty(shape, dtype=object) for index in ndindex(shape): arr[index] = Symbol('%s_%s' % (prefix, '_'.join(map(str, index))), **kwargs) return arr ############### # Functions ############### def casoratian(seqs, n, zero=True): """Given linear difference operator L of order 'k' and homogeneous equation Ly = 0 we want to compute kernel of L, which is a set of 'k' sequences: a(n), b(n), ... z(n). Solutions of L are linearly independent iff their Casoratian, denoted as C(a, b, ..., z), do not vanish for n = 0. Casoratian is defined by k x k determinant:: + a(n) b(n) . . . z(n) + | a(n+1) b(n+1) . . . z(n+1) | | . . . . | | . . . . | | . . . . | + a(n+k-1) b(n+k-1) . . . z(n+k-1) + It proves very useful in rsolve_hyper() where it is applied to a generating set of a recurrence to factor out linearly dependent solutions and return a basis: >>> from sympy import Symbol, casoratian, factorial >>> n = Symbol('n', integer=True) Exponential and factorial are linearly independent: >>> casoratian([2**n, factorial(n)], n) != 0 True """ seqs = list(map(sympify, seqs)) if not zero: f = lambda i, j: seqs[j].subs(n, n + i) else: f = lambda i, j: seqs[j].subs(n, i) k = len(seqs) return Matrix(k, k, f).det() def eye(*args, **kwargs): """Create square identity matrix n x n See Also ======== diag zeros ones """ return Matrix.eye(*args, **kwargs) def diag(*values, **kwargs): """Returns a matrix with the provided values placed on the diagonal. If non-square matrices are included, they will produce a block-diagonal matrix. Examples ======== This version of diag is a thin wrapper to Matrix.diag that differs in that it treats all lists like matrices -- even when a single list is given. If this is not desired, either put a `*` before the list or set `unpack=True`. >>> from sympy import diag >>> diag([1, 2, 3], unpack=True) # = diag(1,2,3) or diag(*[1,2,3]) Matrix([ [1, 0, 0], [0, 2, 0], [0, 0, 3]]) >>> diag([1, 2, 3]) # a column vector Matrix([ [1], [2], [3]]) See Also ======== .common.MatrixCommon.eye .common.MatrixCommon.diagonal - to extract a diagonal .common.MatrixCommon.diag .expressions.blockmatrix.BlockMatrix """ # Extract any setting so we don't duplicate keywords sent # as named parameters: kw = kwargs.copy() strict = kw.pop('strict', True) # lists will be converted to Matrices unpack = kw.pop('unpack', False) return Matrix.diag(*values, strict=strict, unpack=unpack, **kw) def GramSchmidt(vlist, orthonormal=False): """Apply the Gram-Schmidt process to a set of vectors. Parameters ========== vlist : List of Matrix Vectors to be orthogonalized for. orthonormal : Bool, optional If true, return an orthonormal basis. Returns ======= vlist : List of Matrix Orthogonalized vectors Notes ===== This routine is mostly duplicate from ``Matrix.orthogonalize``, except for some difference that this always raises error when linearly dependent vectors are found, and the keyword ``normalize`` has been named as ``orthonormal`` in this function. See Also ======== .matrices.MatrixSubspaces.orthogonalize References ========== .. [1] https://en.wikipedia.org/wiki/Gram%E2%80%93Schmidt_process """ return MutableDenseMatrix.orthogonalize( *vlist, normalize=orthonormal, rankcheck=True ) def hessian(f, varlist, constraints=[]): """Compute Hessian matrix for a function f wrt parameters in varlist which may be given as a sequence or a row/column vector. A list of constraints may optionally be given. Examples ======== >>> from sympy import Function, hessian, pprint >>> from sympy.abc import x, y >>> f = Function('f')(x, y) >>> g1 = Function('g')(x, y) >>> g2 = x**2 + 3*y >>> pprint(hessian(f, (x, y), [g1, g2])) [ d d ] [ 0 0 --(g(x, y)) --(g(x, y)) ] [ dx dy ] [ ] [ 0 0 2*x 3 ] [ ] [ 2 2 ] [d d d ] [--(g(x, y)) 2*x ---(f(x, y)) -----(f(x, y))] [dx 2 dy dx ] [ dx ] [ ] [ 2 2 ] [d d d ] [--(g(x, y)) 3 -----(f(x, y)) ---(f(x, y)) ] [dy dy dx 2 ] [ dy ] References ========== https://en.wikipedia.org/wiki/Hessian_matrix See Also ======== sympy.matrices.mutable.Matrix.jacobian wronskian """ # f is the expression representing a function f, return regular matrix if isinstance(varlist, MatrixBase): if 1 not in varlist.shape: raise ShapeError("`varlist` must be a column or row vector.") if varlist.cols == 1: varlist = varlist.T varlist = varlist.tolist()[0] if is_sequence(varlist): n = len(varlist) if not n: raise ShapeError("`len(varlist)` must not be zero.") else: raise ValueError("Improper variable list in hessian function") if not getattr(f, 'diff'): # check differentiability raise ValueError("Function `f` (%s) is not differentiable" % f) m = len(constraints) N = m + n out = zeros(N) for k, g in enumerate(constraints): if not getattr(g, 'diff'): # check differentiability raise ValueError("Function `f` (%s) is not differentiable" % f) for i in range(n): out[k, i + m] = g.diff(varlist[i]) for i in range(n): for j in range(i, n): out[i + m, j + m] = f.diff(varlist[i]).diff(varlist[j]) for i in range(N): for j in range(i + 1, N): out[j, i] = out[i, j] return out def jordan_cell(eigenval, n): """ Create a Jordan block: Examples ======== >>> from sympy.matrices import jordan_cell >>> from sympy.abc import x >>> jordan_cell(x, 4) Matrix([ [x, 1, 0, 0], [0, x, 1, 0], [0, 0, x, 1], [0, 0, 0, x]]) """ return Matrix.jordan_block(size=n, eigenvalue=eigenval) def matrix_multiply_elementwise(A, B): """Return the Hadamard product (elementwise product) of A and B >>> from sympy.matrices import matrix_multiply_elementwise >>> from sympy.matrices import Matrix >>> A = Matrix([[0, 1, 2], [3, 4, 5]]) >>> B = Matrix([[1, 10, 100], [100, 10, 1]]) >>> matrix_multiply_elementwise(A, B) Matrix([ [ 0, 10, 200], [300, 40, 5]]) See Also ======== __mul__ """ return A.multiply_elementwise(B) def ones(*args, **kwargs): """Returns a matrix of ones with ``rows`` rows and ``cols`` columns; if ``cols`` is omitted a square matrix will be returned. See Also ======== zeros eye diag """ if 'c' in kwargs: kwargs['cols'] = kwargs.pop('c') return Matrix.ones(*args, **kwargs) def randMatrix(r, c=None, min=0, max=99, seed=None, symmetric=False, percent=100, prng=None): """Create random matrix with dimensions ``r`` x ``c``. If ``c`` is omitted the matrix will be square. If ``symmetric`` is True the matrix must be square. If ``percent`` is less than 100 then only approximately the given percentage of elements will be non-zero. The pseudo-random number generator used to generate matrix is chosen in the following way. * If ``prng`` is supplied, it will be used as random number generator. It should be an instance of :class:`random.Random`, or at least have ``randint`` and ``shuffle`` methods with same signatures. * if ``prng`` is not supplied but ``seed`` is supplied, then new :class:`random.Random` with given ``seed`` will be created; * otherwise, a new :class:`random.Random` with default seed will be used. Examples ======== >>> from sympy.matrices import randMatrix >>> randMatrix(3) # doctest:+SKIP [25, 45, 27] [44, 54, 9] [23, 96, 46] >>> randMatrix(3, 2) # doctest:+SKIP [87, 29] [23, 37] [90, 26] >>> randMatrix(3, 3, 0, 2) # doctest:+SKIP [0, 2, 0] [2, 0, 1] [0, 0, 1] >>> randMatrix(3, symmetric=True) # doctest:+SKIP [85, 26, 29] [26, 71, 43] [29, 43, 57] >>> A = randMatrix(3, seed=1) >>> B = randMatrix(3, seed=2) >>> A == B # doctest:+SKIP False >>> A == randMatrix(3, seed=1) True >>> randMatrix(3, symmetric=True, percent=50) # doctest:+SKIP [77, 70, 0], [70, 0, 0], [ 0, 0, 88] """ if c is None: c = r # Note that ``Random()`` is equivalent to ``Random(None)`` prng = prng or random.Random(seed) if not symmetric: m = Matrix._new(r, c, lambda i, j: prng.randint(min, max)) if percent == 100: return m z = int(r*c*(100 - percent) // 100) m._mat[:z] = [S.Zero]*z prng.shuffle(m._mat) return m # Symmetric case if r != c: raise ValueError('For symmetric matrices, r must equal c, but %i != %i' % (r, c)) m = zeros(r) ij = [(i, j) for i in range(r) for j in range(i, r)] if percent != 100: ij = prng.sample(ij, int(len(ij)*percent // 100)) for i, j in ij: value = prng.randint(min, max) m[i, j] = m[j, i] = value return m def wronskian(functions, var, method='bareiss'): """ Compute Wronskian for [] of functions :: | f1 f2 ... fn | | f1' f2' ... fn' | | . . . . | W(f1, ..., fn) = | . . . . | | . . . . | | (n) (n) (n) | | D (f1) D (f2) ... D (fn) | see: https://en.wikipedia.org/wiki/Wronskian See Also ======== sympy.matrices.mutable.Matrix.jacobian hessian """ for index in range(0, len(functions)): functions[index] = sympify(functions[index]) n = len(functions) if n == 0: return 1 W = Matrix(n, n, lambda i, j: functions[i].diff(var, j)) return W.det(method) def zeros(*args, **kwargs): """Returns a matrix of zeros with ``rows`` rows and ``cols`` columns; if ``cols`` is omitted a square matrix will be returned. See Also ======== ones eye diag """ if 'c' in kwargs: kwargs['cols'] = kwargs.pop('c') return Matrix.zeros(*args, **kwargs)
854106cb72929cb79e5cac68c05bae797b78807d7fc9991351f03591b08ee4db
from __future__ import division, print_function import copy from collections import defaultdict from sympy.core.compatibility import Callable, as_int, is_sequence, range from sympy.core.containers import Dict from sympy.core.expr import Expr from sympy.core.singleton import S from sympy.functions import Abs from sympy.functions.elementary.miscellaneous import sqrt from sympy.utilities.iterables import uniq from sympy.utilities.misc import filldedent from .common import a2idx from .dense import Matrix from .matrices import MatrixBase, ShapeError class SparseMatrix(MatrixBase): """ A sparse matrix (a matrix with a large number of zero elements). Examples ======== >>> from sympy.matrices import SparseMatrix, ones >>> SparseMatrix(2, 2, range(4)) Matrix([ [0, 1], [2, 3]]) >>> SparseMatrix(2, 2, {(1, 1): 2}) Matrix([ [0, 0], [0, 2]]) A SparseMatrix can be instantiated from a ragged list of lists: >>> SparseMatrix([[1, 2, 3], [1, 2], [1]]) Matrix([ [1, 2, 3], [1, 2, 0], [1, 0, 0]]) For safety, one may include the expected size and then an error will be raised if the indices of any element are out of range or (for a flat list) if the total number of elements does not match the expected shape: >>> SparseMatrix(2, 2, [1, 2]) Traceback (most recent call last): ... ValueError: List length (2) != rows*columns (4) Here, an error is not raised because the list is not flat and no element is out of range: >>> SparseMatrix(2, 2, [[1, 2]]) Matrix([ [1, 2], [0, 0]]) But adding another element to the first (and only) row will cause an error to be raised: >>> SparseMatrix(2, 2, [[1, 2, 3]]) Traceback (most recent call last): ... ValueError: The location (0, 2) is out of designated range: (1, 1) To autosize the matrix, pass None for rows: >>> SparseMatrix(None, [[1, 2, 3]]) Matrix([[1, 2, 3]]) >>> SparseMatrix(None, {(1, 1): 1, (3, 3): 3}) Matrix([ [0, 0, 0, 0], [0, 1, 0, 0], [0, 0, 0, 0], [0, 0, 0, 3]]) Values that are themselves a Matrix are automatically expanded: >>> SparseMatrix(4, 4, {(1, 1): ones(2)}) Matrix([ [0, 0, 0, 0], [0, 1, 1, 0], [0, 1, 1, 0], [0, 0, 0, 0]]) A ValueError is raised if the expanding matrix tries to overwrite a different element already present: >>> SparseMatrix(3, 3, {(0, 0): ones(2), (1, 1): 2}) Traceback (most recent call last): ... ValueError: collision at (1, 1) See Also ======== sympy.matrices.common.diag sympy.matrices.dense.Matrix """ def __new__(cls, *args, **kwargs): self = object.__new__(cls) if len(args) == 1 and isinstance(args[0], SparseMatrix): self.rows = args[0].rows self.cols = args[0].cols self._smat = dict(args[0]._smat) return self self._smat = {} # autosizing if len(args) == 2 and args[0] is None: args = (None,) + args if len(args) == 3: r, c = args[:2] if r is c is None: self.rows = self.cols = None elif None in (r, c): raise ValueError( 'Pass rows=None and no cols for autosizing.') else: self.rows, self.cols = map(as_int, args[:2]) if isinstance(args[2], Callable): op = args[2] for i in range(self.rows): for j in range(self.cols): value = self._sympify( op(self._sympify(i), self._sympify(j))) if value: self._smat[i, j] = value elif isinstance(args[2], (dict, Dict)): def update(i, j, v): # update self._smat and make sure there are # no collisions if v: if (i, j) in self._smat and v != self._smat[i, j]: raise ValueError('collision at %s' % ((i, j),)) self._smat[i, j] = v # manual copy, copy.deepcopy() doesn't work for key, v in args[2].items(): r, c = key if isinstance(v, SparseMatrix): for (i, j), vij in v._smat.items(): update(r + i, c + j, vij) else: if isinstance(v, (Matrix, list, tuple)): v = SparseMatrix(v) for i, j in v._smat: update(r + i, c + j, v[i, j]) else: v = self._sympify(v) update(r, c, self._sympify(v)) elif is_sequence(args[2]): flat = not any(is_sequence(i) for i in args[2]) if not flat: s = SparseMatrix(args[2]) self._smat = s._smat else: if len(args[2]) != self.rows*self.cols: raise ValueError( 'Flat list length (%s) != rows*columns (%s)' % (len(args[2]), self.rows*self.cols)) flat_list = args[2] for i in range(self.rows): for j in range(self.cols): value = self._sympify(flat_list[i*self.cols + j]) if value: self._smat[i, j] = value if self.rows is None: # autosizing k = self._smat.keys() self.rows = max([i[0] for i in k]) + 1 if k else 0 self.cols = max([i[1] for i in k]) + 1 if k else 0 else: for i, j in self._smat.keys(): if i and i >= self.rows or j and j >= self.cols: r, c = self.shape raise ValueError(filldedent(''' The location %s is out of designated range: %s''' % ((i, j), (r - 1, c - 1)))) else: if (len(args) == 1 and isinstance(args[0], (list, tuple))): # list of values or lists v = args[0] c = 0 for i, row in enumerate(v): if not isinstance(row, (list, tuple)): row = [row] for j, vij in enumerate(row): if vij: self._smat[i, j] = self._sympify(vij) c = max(c, len(row)) self.rows = len(v) if c else 0 self.cols = c else: # handle full matrix forms with _handle_creation_inputs r, c, _list = Matrix._handle_creation_inputs(*args) self.rows = r self.cols = c for i in range(self.rows): for j in range(self.cols): value = _list[self.cols*i + j] if value: self._smat[i, j] = value return self def __eq__(self, other): self_shape = getattr(self, 'shape', None) other_shape = getattr(other, 'shape', None) if None in (self_shape, other_shape): return False if self_shape != other_shape: return False if isinstance(other, SparseMatrix): return self._smat == other._smat elif isinstance(other, MatrixBase): return self._smat == MutableSparseMatrix(other)._smat def __getitem__(self, key): if isinstance(key, tuple): i, j = key try: i, j = self.key2ij(key) return self._smat.get((i, j), S.Zero) except (TypeError, IndexError): if isinstance(i, slice): # XXX remove list() when PY2 support is dropped i = list(range(self.rows))[i] elif is_sequence(i): pass elif isinstance(i, Expr) and not i.is_number: from sympy.matrices.expressions.matexpr import MatrixElement return MatrixElement(self, i, j) else: if i >= self.rows: raise IndexError('Row index out of bounds') i = [i] if isinstance(j, slice): # XXX remove list() when PY2 support is dropped j = list(range(self.cols))[j] elif is_sequence(j): pass elif isinstance(j, Expr) and not j.is_number: from sympy.matrices.expressions.matexpr import MatrixElement return MatrixElement(self, i, j) else: if j >= self.cols: raise IndexError('Col index out of bounds') j = [j] return self.extract(i, j) # check for single arg, like M[:] or M[3] if isinstance(key, slice): lo, hi = key.indices(len(self))[:2] L = [] for i in range(lo, hi): m, n = divmod(i, self.cols) L.append(self._smat.get((m, n), S.Zero)) return L i, j = divmod(a2idx(key, len(self)), self.cols) return self._smat.get((i, j), S.Zero) def __setitem__(self, key, value): raise NotImplementedError() def _cholesky_solve(self, rhs): # for speed reasons, this is not uncommented, but if you are # having difficulties, try uncommenting to make sure that the # input matrix is symmetric #assert self.is_symmetric() L = self._cholesky_sparse() Y = L._lower_triangular_solve(rhs) rv = L.T._upper_triangular_solve(Y) return rv def _cholesky_sparse(self): """Algorithm for numeric Cholesky factorization of a sparse matrix.""" Crowstruc = self.row_structure_symbolic_cholesky() C = self.zeros(self.rows) for i in range(len(Crowstruc)): for j in Crowstruc[i]: if i != j: C[i, j] = self[i, j] summ = 0 for p1 in Crowstruc[i]: if p1 < j: for p2 in Crowstruc[j]: if p2 < j: if p1 == p2: summ += C[i, p1]*C[j, p1] else: break else: break C[i, j] -= summ C[i, j] /= C[j, j] else: C[j, j] = self[j, j] summ = 0 for k in Crowstruc[j]: if k < j: summ += C[j, k]**2 else: break C[j, j] -= summ C[j, j] = sqrt(C[j, j]) return C def _diagonal_solve(self, rhs): "Diagonal solve." return self._new(self.rows, 1, lambda i, j: rhs[i, 0] / self[i, i]) def _eval_inverse(self, **kwargs): """Return the matrix inverse using Cholesky or LDL (default) decomposition as selected with the ``method`` keyword: 'CH' or 'LDL', respectively. Examples ======== >>> from sympy import SparseMatrix, Matrix >>> A = SparseMatrix([ ... [ 2, -1, 0], ... [-1, 2, -1], ... [ 0, 0, 2]]) >>> A.inv('CH') Matrix([ [2/3, 1/3, 1/6], [1/3, 2/3, 1/3], [ 0, 0, 1/2]]) >>> A.inv(method='LDL') # use of 'method=' is optional Matrix([ [2/3, 1/3, 1/6], [1/3, 2/3, 1/3], [ 0, 0, 1/2]]) >>> A * _ Matrix([ [1, 0, 0], [0, 1, 0], [0, 0, 1]]) """ sym = self.is_symmetric() M = self.as_mutable() I = M.eye(M.rows) if not sym: t = M.T r1 = M[0, :] M = t*M I = t*I method = kwargs.get('method', 'LDL') if method in "LDL": solve = M._LDL_solve elif method == "CH": solve = M._cholesky_solve else: raise NotImplementedError( 'Method may be "CH" or "LDL", not %s.' % method) rv = M.hstack(*[solve(I[:, i]) for i in range(I.cols)]) if not sym: scale = (r1*rv[:, 0])[0, 0] rv /= scale return self._new(rv) def _eval_Abs(self): return self.applyfunc(lambda x: Abs(x)) def _eval_add(self, other): """If `other` is a SparseMatrix, add efficiently. Otherwise, do standard addition.""" if not isinstance(other, SparseMatrix): return self + self._new(other) smat = {} zero = self._sympify(0) for key in set().union(self._smat.keys(), other._smat.keys()): sum = self._smat.get(key, zero) + other._smat.get(key, zero) if sum != 0: smat[key] = sum return self._new(self.rows, self.cols, smat) def _eval_col_insert(self, icol, other): if not isinstance(other, SparseMatrix): other = SparseMatrix(other) new_smat = {} # make room for the new rows for key, val in self._smat.items(): row, col = key if col >= icol: col += other.cols new_smat[row, col] = val # add other's keys for key, val in other._smat.items(): row, col = key new_smat[row, col + icol] = val return self._new(self.rows, self.cols + other.cols, new_smat) def _eval_conjugate(self): smat = {key: val.conjugate() for key,val in self._smat.items()} return self._new(self.rows, self.cols, smat) def _eval_extract(self, rowsList, colsList): urow = list(uniq(rowsList)) ucol = list(uniq(colsList)) smat = {} if len(urow)*len(ucol) < len(self._smat): # there are fewer elements requested than there are elements in the matrix for i, r in enumerate(urow): for j, c in enumerate(ucol): smat[i, j] = self._smat.get((r, c), 0) else: # most of the request will be zeros so check all of self's entries, # keeping only the ones that are desired for rk, ck in self._smat: if rk in urow and ck in ucol: smat[urow.index(rk), ucol.index(ck)] = self._smat[rk, ck] rv = self._new(len(urow), len(ucol), smat) # rv is nominally correct but there might be rows/cols # which require duplication if len(rowsList) != len(urow): for i, r in enumerate(rowsList): i_previous = rowsList.index(r) if i_previous != i: rv = rv.row_insert(i, rv.row(i_previous)) if len(colsList) != len(ucol): for i, c in enumerate(colsList): i_previous = colsList.index(c) if i_previous != i: rv = rv.col_insert(i, rv.col(i_previous)) return rv @classmethod def _eval_eye(cls, rows, cols): entries = {(i,i): S.One for i in range(min(rows, cols))} return cls._new(rows, cols, entries) def _eval_has(self, *patterns): # if the matrix has any zeros, see if S.Zero # has the pattern. If _smat is full length, # the matrix has no zeros. zhas = S.Zero.has(*patterns) if len(self._smat) == self.rows*self.cols: zhas = False return any(self[key].has(*patterns) for key in self._smat) or zhas def _eval_is_Identity(self): if not all(self[i, i] == 1 for i in range(self.rows)): return False return len(self._smat) == self.rows def _eval_is_symmetric(self, simpfunc): diff = (self - self.T).applyfunc(simpfunc) return len(diff.values()) == 0 def _eval_matrix_mul(self, other): """Fast multiplication exploiting the sparsity of the matrix.""" if not isinstance(other, SparseMatrix): return self*self._new(other) # if we made it here, we're both sparse matrices # create quick lookups for rows and cols row_lookup = defaultdict(dict) for (i,j), val in self._smat.items(): row_lookup[i][j] = val col_lookup = defaultdict(dict) for (i,j), val in other._smat.items(): col_lookup[j][i] = val smat = {} for row in row_lookup.keys(): for col in col_lookup.keys(): # find the common indices of non-zero entries. # these are the only things that need to be multiplied. indices = set(col_lookup[col].keys()) & set(row_lookup[row].keys()) if indices: val = sum(row_lookup[row][k]*col_lookup[col][k] for k in indices) smat[row, col] = val return self._new(self.rows, other.cols, smat) def _eval_row_insert(self, irow, other): if not isinstance(other, SparseMatrix): other = SparseMatrix(other) new_smat = {} # make room for the new rows for key, val in self._smat.items(): row, col = key if row >= irow: row += other.rows new_smat[row, col] = val # add other's keys for key, val in other._smat.items(): row, col = key new_smat[row + irow, col] = val return self._new(self.rows + other.rows, self.cols, new_smat) def _eval_scalar_mul(self, other): return self.applyfunc(lambda x: x*other) def _eval_scalar_rmul(self, other): return self.applyfunc(lambda x: other*x) def _eval_transpose(self): """Returns the transposed SparseMatrix of this SparseMatrix. Examples ======== >>> from sympy.matrices import SparseMatrix >>> a = SparseMatrix(((1, 2), (3, 4))) >>> a Matrix([ [1, 2], [3, 4]]) >>> a.T Matrix([ [1, 3], [2, 4]]) """ smat = {(j,i): val for (i,j),val in self._smat.items()} return self._new(self.cols, self.rows, smat) def _eval_values(self): return [v for k,v in self._smat.items() if not v.is_zero] @classmethod def _eval_zeros(cls, rows, cols): return cls._new(rows, cols, {}) def _LDL_solve(self, rhs): # for speed reasons, this is not uncommented, but if you are # having difficulties, try uncommenting to make sure that the # input matrix is symmetric #assert self.is_symmetric() L, D = self._LDL_sparse() Z = L._lower_triangular_solve(rhs) Y = D._diagonal_solve(Z) return L.T._upper_triangular_solve(Y) def _LDL_sparse(self): """Algorithm for numeric LDL factization, exploiting sparse structure. """ Lrowstruc = self.row_structure_symbolic_cholesky() L = self.eye(self.rows) D = self.zeros(self.rows, self.cols) for i in range(len(Lrowstruc)): for j in Lrowstruc[i]: if i != j: L[i, j] = self[i, j] summ = 0 for p1 in Lrowstruc[i]: if p1 < j: for p2 in Lrowstruc[j]: if p2 < j: if p1 == p2: summ += L[i, p1]*L[j, p1]*D[p1, p1] else: break else: break L[i, j] -= summ L[i, j] /= D[j, j] else: # i == j D[i, i] = self[i, i] summ = 0 for k in Lrowstruc[i]: if k < i: summ += L[i, k]**2*D[k, k] else: break D[i, i] -= summ return L, D def _lower_triangular_solve(self, rhs): """Fast algorithm for solving a lower-triangular system, exploiting the sparsity of the given matrix. """ rows = [[] for i in range(self.rows)] for i, j, v in self.row_list(): if i > j: rows[i].append((j, v)) X = rhs.copy() for i in range(self.rows): for j, v in rows[i]: X[i, 0] -= v*X[j, 0] X[i, 0] /= self[i, i] return self._new(X) @property def _mat(self): """Return a list of matrix elements. Some routines in DenseMatrix use `_mat` directly to speed up operations.""" return list(self) def _upper_triangular_solve(self, rhs): """Fast algorithm for solving an upper-triangular system, exploiting the sparsity of the given matrix. """ rows = [[] for i in range(self.rows)] for i, j, v in self.row_list(): if i < j: rows[i].append((j, v)) X = rhs.copy() for i in range(self.rows - 1, -1, -1): rows[i].reverse() for j, v in rows[i]: X[i, 0] -= v*X[j, 0] X[i, 0] /= self[i, i] return self._new(X) def applyfunc(self, f): """Apply a function to each element of the matrix. Examples ======== >>> from sympy.matrices import SparseMatrix >>> m = SparseMatrix(2, 2, lambda i, j: i*2+j) >>> m Matrix([ [0, 1], [2, 3]]) >>> m.applyfunc(lambda i: 2*i) Matrix([ [0, 2], [4, 6]]) """ if not callable(f): raise TypeError("`f` must be callable.") out = self.copy() for k, v in self._smat.items(): fv = f(v) if fv: out._smat[k] = fv else: out._smat.pop(k, None) return out def as_immutable(self): """Returns an Immutable version of this Matrix.""" from .immutable import ImmutableSparseMatrix return ImmutableSparseMatrix(self) def as_mutable(self): """Returns a mutable version of this matrix. Examples ======== >>> from sympy import ImmutableMatrix >>> X = ImmutableMatrix([[1, 2], [3, 4]]) >>> Y = X.as_mutable() >>> Y[1, 1] = 5 # Can set values in Y >>> Y Matrix([ [1, 2], [3, 5]]) """ return MutableSparseMatrix(self) def cholesky(self): """ Returns the Cholesky decomposition L of a matrix A such that L * L.T = A A must be a square, symmetric, positive-definite and non-singular matrix Examples ======== >>> from sympy.matrices import SparseMatrix >>> A = SparseMatrix(((25,15,-5),(15,18,0),(-5,0,11))) >>> A.cholesky() Matrix([ [ 5, 0, 0], [ 3, 3, 0], [-1, 1, 3]]) >>> A.cholesky() * A.cholesky().T == A True """ from sympy.core.numbers import nan, oo if not self.is_symmetric(): raise ValueError('Cholesky decomposition applies only to ' 'symmetric matrices.') M = self.as_mutable()._cholesky_sparse() if M.has(nan) or M.has(oo): raise ValueError('Cholesky decomposition applies only to ' 'positive-definite matrices') return self._new(M) def col_list(self): """Returns a column-sorted list of non-zero elements of the matrix. Examples ======== >>> from sympy.matrices import SparseMatrix >>> a=SparseMatrix(((1, 2), (3, 4))) >>> a Matrix([ [1, 2], [3, 4]]) >>> a.CL [(0, 0, 1), (1, 0, 3), (0, 1, 2), (1, 1, 4)] See Also ======== col_op row_list """ return [tuple(k + (self[k],)) for k in sorted(list(self._smat.keys()), key=lambda k: list(reversed(k)))] def copy(self): return self._new(self.rows, self.cols, self._smat) def LDLdecomposition(self): """ Returns the LDL Decomposition (matrices ``L`` and ``D``) of matrix ``A``, such that ``L * D * L.T == A``. ``A`` must be a square, symmetric, positive-definite and non-singular. This method eliminates the use of square root and ensures that all the diagonal entries of L are 1. Examples ======== >>> from sympy.matrices import SparseMatrix >>> A = SparseMatrix(((25, 15, -5), (15, 18, 0), (-5, 0, 11))) >>> L, D = A.LDLdecomposition() >>> L Matrix([ [ 1, 0, 0], [ 3/5, 1, 0], [-1/5, 1/3, 1]]) >>> D Matrix([ [25, 0, 0], [ 0, 9, 0], [ 0, 0, 9]]) >>> L * D * L.T == A True """ from sympy.core.numbers import nan, oo if not self.is_symmetric(): raise ValueError('LDL decomposition applies only to ' 'symmetric matrices.') L, D = self.as_mutable()._LDL_sparse() if L.has(nan) or L.has(oo) or D.has(nan) or D.has(oo): raise ValueError('LDL decomposition applies only to ' 'positive-definite matrices') return self._new(L), self._new(D) def liupc(self): """Liu's algorithm, for pre-determination of the Elimination Tree of the given matrix, used in row-based symbolic Cholesky factorization. Examples ======== >>> from sympy.matrices import SparseMatrix >>> S = SparseMatrix([ ... [1, 0, 3, 2], ... [0, 0, 1, 0], ... [4, 0, 0, 5], ... [0, 6, 7, 0]]) >>> S.liupc() ([[0], [], [0], [1, 2]], [4, 3, 4, 4]) References ========== Symbolic Sparse Cholesky Factorization using Elimination Trees, Jeroen Van Grondelle (1999) http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.39.7582 """ # Algorithm 2.4, p 17 of reference # get the indices of the elements that are non-zero on or below diag R = [[] for r in range(self.rows)] for r, c, _ in self.row_list(): if c <= r: R[r].append(c) inf = len(R) # nothing will be this large parent = [inf]*self.rows virtual = [inf]*self.rows for r in range(self.rows): for c in R[r][:-1]: while virtual[c] < r: t = virtual[c] virtual[c] = r c = t if virtual[c] == inf: parent[c] = virtual[c] = r return R, parent def nnz(self): """Returns the number of non-zero elements in Matrix.""" return len(self._smat) def row_list(self): """Returns a row-sorted list of non-zero elements of the matrix. Examples ======== >>> from sympy.matrices import SparseMatrix >>> a = SparseMatrix(((1, 2), (3, 4))) >>> a Matrix([ [1, 2], [3, 4]]) >>> a.RL [(0, 0, 1), (0, 1, 2), (1, 0, 3), (1, 1, 4)] See Also ======== row_op col_list """ return [tuple(k + (self[k],)) for k in sorted(list(self._smat.keys()), key=lambda k: list(k))] def row_structure_symbolic_cholesky(self): """Symbolic cholesky factorization, for pre-determination of the non-zero structure of the Cholesky factororization. Examples ======== >>> from sympy.matrices import SparseMatrix >>> S = SparseMatrix([ ... [1, 0, 3, 2], ... [0, 0, 1, 0], ... [4, 0, 0, 5], ... [0, 6, 7, 0]]) >>> S.row_structure_symbolic_cholesky() [[0], [], [0], [1, 2]] References ========== Symbolic Sparse Cholesky Factorization using Elimination Trees, Jeroen Van Grondelle (1999) http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.39.7582 """ R, parent = self.liupc() inf = len(R) # this acts as infinity Lrow = copy.deepcopy(R) for k in range(self.rows): for j in R[k]: while j != inf and j != k: Lrow[k].append(j) j = parent[j] Lrow[k] = list(sorted(set(Lrow[k]))) return Lrow def scalar_multiply(self, scalar): "Scalar element-wise multiplication" M = self.zeros(*self.shape) if scalar: for i in self._smat: v = scalar*self._smat[i] if v: M._smat[i] = v else: M._smat.pop(i, None) return M def solve_least_squares(self, rhs, method='LDL'): """Return the least-square fit to the data. By default the cholesky_solve routine is used (method='CH'); other methods of matrix inversion can be used. To find out which are available, see the docstring of the .inv() method. Examples ======== >>> from sympy.matrices import SparseMatrix, Matrix, ones >>> A = Matrix([1, 2, 3]) >>> B = Matrix([2, 3, 4]) >>> S = SparseMatrix(A.row_join(B)) >>> S Matrix([ [1, 2], [2, 3], [3, 4]]) If each line of S represent coefficients of Ax + By and x and y are [2, 3] then S*xy is: >>> r = S*Matrix([2, 3]); r Matrix([ [ 8], [13], [18]]) But let's add 1 to the middle value and then solve for the least-squares value of xy: >>> xy = S.solve_least_squares(Matrix([8, 14, 18])); xy Matrix([ [ 5/3], [10/3]]) The error is given by S*xy - r: >>> S*xy - r Matrix([ [1/3], [1/3], [1/3]]) >>> _.norm().n(2) 0.58 If a different xy is used, the norm will be higher: >>> xy += ones(2, 1)/10 >>> (S*xy - r).norm().n(2) 1.5 """ t = self.T return (t*self).inv(method=method)*t*rhs def solve(self, rhs, method='LDL'): """Return solution to self*soln = rhs using given inversion method. For a list of possible inversion methods, see the .inv() docstring. """ if not self.is_square: if self.rows < self.cols: raise ValueError('Under-determined system.') elif self.rows > self.cols: raise ValueError('For over-determined system, M, having ' 'more rows than columns, try M.solve_least_squares(rhs).') else: return self.inv(method=method)*rhs RL = property(row_list, None, None, "Alternate faster representation") CL = property(col_list, None, None, "Alternate faster representation") class MutableSparseMatrix(SparseMatrix, MatrixBase): @classmethod def _new(cls, *args, **kwargs): return cls(*args) def __setitem__(self, key, value): """Assign value to position designated by key. Examples ======== >>> from sympy.matrices import SparseMatrix, ones >>> M = SparseMatrix(2, 2, {}) >>> M[1] = 1; M Matrix([ [0, 1], [0, 0]]) >>> M[1, 1] = 2; M Matrix([ [0, 1], [0, 2]]) >>> M = SparseMatrix(2, 2, {}) >>> M[:, 1] = [1, 1]; M Matrix([ [0, 1], [0, 1]]) >>> M = SparseMatrix(2, 2, {}) >>> M[1, :] = [[1, 1]]; M Matrix([ [0, 0], [1, 1]]) To replace row r you assign to position r*m where m is the number of columns: >>> M = SparseMatrix(4, 4, {}) >>> m = M.cols >>> M[3*m] = ones(1, m)*2; M Matrix([ [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [2, 2, 2, 2]]) And to replace column c you can assign to position c: >>> M[2] = ones(m, 1)*4; M Matrix([ [0, 0, 4, 0], [0, 0, 4, 0], [0, 0, 4, 0], [2, 2, 4, 2]]) """ rv = self._setitem(key, value) if rv is not None: i, j, value = rv if value: self._smat[i, j] = value elif (i, j) in self._smat: del self._smat[i, j] def as_mutable(self): return self.copy() __hash__ = None def col_del(self, k): """Delete the given column of the matrix. Examples ======== >>> from sympy.matrices import SparseMatrix >>> M = SparseMatrix([[0, 0], [0, 1]]) >>> M Matrix([ [0, 0], [0, 1]]) >>> M.col_del(0) >>> M Matrix([ [0], [1]]) See Also ======== row_del """ newD = {} k = a2idx(k, self.cols) for (i, j) in self._smat: if j == k: pass elif j > k: newD[i, j - 1] = self._smat[i, j] else: newD[i, j] = self._smat[i, j] self._smat = newD self.cols -= 1 def col_join(self, other): """Returns B augmented beneath A (row-wise joining):: [A] [B] Examples ======== >>> from sympy import SparseMatrix, Matrix, ones >>> A = SparseMatrix(ones(3)) >>> A Matrix([ [1, 1, 1], [1, 1, 1], [1, 1, 1]]) >>> B = SparseMatrix.eye(3) >>> B Matrix([ [1, 0, 0], [0, 1, 0], [0, 0, 1]]) >>> C = A.col_join(B); C Matrix([ [1, 1, 1], [1, 1, 1], [1, 1, 1], [1, 0, 0], [0, 1, 0], [0, 0, 1]]) >>> C == A.col_join(Matrix(B)) True Joining along columns is the same as appending rows at the end of the matrix: >>> C == A.row_insert(A.rows, Matrix(B)) True """ # A null matrix can always be stacked (see #10770) if self.rows == 0 and self.cols != other.cols: return self._new(0, other.cols, []).col_join(other) A, B = self, other if not A.cols == B.cols: raise ShapeError() A = A.copy() if not isinstance(B, SparseMatrix): k = 0 b = B._mat for i in range(B.rows): for j in range(B.cols): v = b[k] if v: A._smat[i + A.rows, j] = v k += 1 else: for (i, j), v in B._smat.items(): A._smat[i + A.rows, j] = v A.rows += B.rows return A def col_op(self, j, f): """In-place operation on col j using two-arg functor whose args are interpreted as (self[i, j], i) for i in range(self.rows). Examples ======== >>> from sympy.matrices import SparseMatrix >>> M = SparseMatrix.eye(3)*2 >>> M[1, 0] = -1 >>> M.col_op(1, lambda v, i: v + 2*M[i, 0]); M Matrix([ [ 2, 4, 0], [-1, 0, 0], [ 0, 0, 2]]) """ for i in range(self.rows): v = self._smat.get((i, j), S.Zero) fv = f(v, i) if fv: self._smat[i, j] = fv elif v: self._smat.pop((i, j)) def col_swap(self, i, j): """Swap, in place, columns i and j. Examples ======== >>> from sympy.matrices import SparseMatrix >>> S = SparseMatrix.eye(3); S[2, 1] = 2 >>> S.col_swap(1, 0); S Matrix([ [0, 1, 0], [1, 0, 0], [2, 0, 1]]) """ if i > j: i, j = j, i rows = self.col_list() temp = [] for ii, jj, v in rows: if jj == i: self._smat.pop((ii, jj)) temp.append((ii, v)) elif jj == j: self._smat.pop((ii, jj)) self._smat[ii, i] = v elif jj > j: break for k, v in temp: self._smat[k, j] = v def copyin_list(self, key, value): if not is_sequence(value): raise TypeError("`value` must be of type list or tuple.") self.copyin_matrix(key, Matrix(value)) def copyin_matrix(self, key, value): # include this here because it's not part of BaseMatrix rlo, rhi, clo, chi = self.key2bounds(key) shape = value.shape dr, dc = rhi - rlo, chi - clo if shape != (dr, dc): raise ShapeError( "The Matrix `value` doesn't have the same dimensions " "as the in sub-Matrix given by `key`.") if not isinstance(value, SparseMatrix): for i in range(value.rows): for j in range(value.cols): self[i + rlo, j + clo] = value[i, j] else: if (rhi - rlo)*(chi - clo) < len(self): for i in range(rlo, rhi): for j in range(clo, chi): self._smat.pop((i, j), None) else: for i, j, v in self.row_list(): if rlo <= i < rhi and clo <= j < chi: self._smat.pop((i, j), None) for k, v in value._smat.items(): i, j = k self[i + rlo, j + clo] = value[i, j] def fill(self, value): """Fill self with the given value. Notes ===== Unless many values are going to be deleted (i.e. set to zero) this will create a matrix that is slower than a dense matrix in operations. Examples ======== >>> from sympy.matrices import SparseMatrix >>> M = SparseMatrix.zeros(3); M Matrix([ [0, 0, 0], [0, 0, 0], [0, 0, 0]]) >>> M.fill(1); M Matrix([ [1, 1, 1], [1, 1, 1], [1, 1, 1]]) """ if not value: self._smat = {} else: v = self._sympify(value) self._smat = {(i, j): v for i in range(self.rows) for j in range(self.cols)} def row_del(self, k): """Delete the given row of the matrix. Examples ======== >>> from sympy.matrices import SparseMatrix >>> M = SparseMatrix([[0, 0], [0, 1]]) >>> M Matrix([ [0, 0], [0, 1]]) >>> M.row_del(0) >>> M Matrix([[0, 1]]) See Also ======== col_del """ newD = {} k = a2idx(k, self.rows) for (i, j) in self._smat: if i == k: pass elif i > k: newD[i - 1, j] = self._smat[i, j] else: newD[i, j] = self._smat[i, j] self._smat = newD self.rows -= 1 def row_join(self, other): """Returns B appended after A (column-wise augmenting):: [A B] Examples ======== >>> from sympy import SparseMatrix, Matrix >>> A = SparseMatrix(((1, 0, 1), (0, 1, 0), (1, 1, 0))) >>> A Matrix([ [1, 0, 1], [0, 1, 0], [1, 1, 0]]) >>> B = SparseMatrix(((1, 0, 0), (0, 1, 0), (0, 0, 1))) >>> B Matrix([ [1, 0, 0], [0, 1, 0], [0, 0, 1]]) >>> C = A.row_join(B); C Matrix([ [1, 0, 1, 1, 0, 0], [0, 1, 0, 0, 1, 0], [1, 1, 0, 0, 0, 1]]) >>> C == A.row_join(Matrix(B)) True Joining at row ends is the same as appending columns at the end of the matrix: >>> C == A.col_insert(A.cols, B) True """ # A null matrix can always be stacked (see #10770) if self.cols == 0 and self.rows != other.rows: return self._new(other.rows, 0, []).row_join(other) A, B = self, other if not A.rows == B.rows: raise ShapeError() A = A.copy() if not isinstance(B, SparseMatrix): k = 0 b = B._mat for i in range(B.rows): for j in range(B.cols): v = b[k] if v: A._smat[i, j + A.cols] = v k += 1 else: for (i, j), v in B._smat.items(): A._smat[i, j + A.cols] = v A.cols += B.cols return A def row_op(self, i, f): """In-place operation on row ``i`` using two-arg functor whose args are interpreted as ``(self[i, j], j)``. Examples ======== >>> from sympy.matrices import SparseMatrix >>> M = SparseMatrix.eye(3)*2 >>> M[0, 1] = -1 >>> M.row_op(1, lambda v, j: v + 2*M[0, j]); M Matrix([ [2, -1, 0], [4, 0, 0], [0, 0, 2]]) See Also ======== row zip_row_op col_op """ for j in range(self.cols): v = self._smat.get((i, j), S.Zero) fv = f(v, j) if fv: self._smat[i, j] = fv elif v: self._smat.pop((i, j)) def row_swap(self, i, j): """Swap, in place, columns i and j. Examples ======== >>> from sympy.matrices import SparseMatrix >>> S = SparseMatrix.eye(3); S[2, 1] = 2 >>> S.row_swap(1, 0); S Matrix([ [0, 1, 0], [1, 0, 0], [0, 2, 1]]) """ if i > j: i, j = j, i rows = self.row_list() temp = [] for ii, jj, v in rows: if ii == i: self._smat.pop((ii, jj)) temp.append((jj, v)) elif ii == j: self._smat.pop((ii, jj)) self._smat[i, jj] = v elif ii > j: break for k, v in temp: self._smat[j, k] = v def zip_row_op(self, i, k, f): """In-place operation on row ``i`` using two-arg functor whose args are interpreted as ``(self[i, j], self[k, j])``. Examples ======== >>> from sympy.matrices import SparseMatrix >>> M = SparseMatrix.eye(3)*2 >>> M[0, 1] = -1 >>> M.zip_row_op(1, 0, lambda v, u: v + 2*u); M Matrix([ [2, -1, 0], [4, 0, 0], [0, 0, 2]]) See Also ======== row row_op col_op """ self.row_op(i, lambda v, j: f(v, self[k, j]))
9825a62caeba45a5e5907cf1b26040ead4e9c7cd85809b14fbd25e2e83bf16a2
from __future__ import division, print_function from types import FunctionType from mpmath.libmp.libmpf import prec_to_dps from sympy.core.add import Add from sympy.core.basic import Basic from sympy.core.compatibility import ( Callable, NotIterable, as_int, default_sort_key, is_sequence, range, reduce, string_types) from sympy.core.decorators import deprecated from sympy.core.expr import Expr from sympy.core.function import expand_mul from sympy.core.numbers import Float, Integer, mod_inverse from sympy.core.power import Pow from sympy.core.singleton import S from sympy.core.symbol import Dummy, Symbol, _uniquely_named_symbol, symbols from sympy.core.sympify import sympify from sympy.functions import exp, factorial from sympy.functions.elementary.miscellaneous import Max, Min, sqrt from sympy.polys import PurePoly, cancel, roots from sympy.printing import sstr from sympy.simplify import nsimplify from sympy.simplify import simplify as _simplify from sympy.utilities.exceptions import SymPyDeprecationWarning from sympy.utilities.iterables import flatten, numbered_symbols from sympy.utilities.misc import filldedent from .common import ( MatrixCommon, MatrixError, NonSquareMatrixError, ShapeError) def _iszero(x): """Returns True if x is zero.""" return getattr(x, 'is_zero', None) def _is_zero_after_expand_mul(x): """Tests by expand_mul only, suitable for polynomials and rational functions.""" return expand_mul(x) == 0 class DeferredVector(Symbol, NotIterable): """A vector whose components are deferred (e.g. for use with lambdify) Examples ======== >>> from sympy import DeferredVector, lambdify >>> X = DeferredVector( 'X' ) >>> X X >>> expr = (X[0] + 2, X[2] + 3) >>> func = lambdify( X, expr) >>> func( [1, 2, 3] ) (3, 6) """ def __getitem__(self, i): if i == -0: i = 0 if i < 0: raise IndexError('DeferredVector index out of range') component_name = '%s[%d]' % (self.name, i) return Symbol(component_name) def __str__(self): return sstr(self) def __repr__(self): return "DeferredVector('%s')" % self.name class MatrixDeterminant(MatrixCommon): """Provides basic matrix determinant operations. Should not be instantiated directly.""" def _eval_berkowitz_toeplitz_matrix(self): """Return (A,T) where T the Toeplitz matrix used in the Berkowitz algorithm corresponding to ``self`` and A is the first principal submatrix.""" # the 0 x 0 case is trivial if self.rows == 0 and self.cols == 0: return self._new(1,1, [S.One]) # # Partition self = [ a_11 R ] # [ C A ] # a, R = self[0,0], self[0, 1:] C, A = self[1:, 0], self[1:,1:] # # The Toeplitz matrix looks like # # [ 1 ] # [ -a 1 ] # [ -RC -a 1 ] # [ -RAC -RC -a 1 ] # [ -RA**2C -RAC -RC -a 1 ] # etc. # Compute the diagonal entries. # Because multiplying matrix times vector is so much # more efficient than matrix times matrix, recursively # compute -R * A**n * C. diags = [C] for i in range(self.rows - 2): diags.append(A * diags[i]) diags = [(-R*d)[0, 0] for d in diags] diags = [S.One, -a] + diags def entry(i,j): if j > i: return S.Zero return diags[i - j] toeplitz = self._new(self.cols + 1, self.rows, entry) return (A, toeplitz) def _eval_berkowitz_vector(self): """ Run the Berkowitz algorithm and return a vector whose entries are the coefficients of the characteristic polynomial of ``self``. Given N x N matrix, efficiently compute coefficients of characteristic polynomials of ``self`` without division in the ground domain. This method is particularly useful for computing determinant, principal minors and characteristic polynomial when ``self`` has complicated coefficients e.g. polynomials. Semi-direct usage of this algorithm is also important in computing efficiently sub-resultant PRS. Assuming that M is a square matrix of dimension N x N and I is N x N identity matrix, then the Berkowitz vector is an N x 1 vector whose entries are coefficients of the polynomial charpoly(M) = det(t*I - M) As a consequence, all polynomials generated by Berkowitz algorithm are monic. For more information on the implemented algorithm refer to: [1] S.J. Berkowitz, On computing the determinant in small parallel time using a small number of processors, ACM, Information Processing Letters 18, 1984, pp. 147-150 [2] M. Keber, Division-Free computation of sub-resultants using Bezout matrices, Tech. Report MPI-I-2006-1-006, Saarbrucken, 2006 """ # handle the trivial cases if self.rows == 0 and self.cols == 0: return self._new(1, 1, [S.One]) elif self.rows == 1 and self.cols == 1: return self._new(2, 1, [S.One, -self[0,0]]) submat, toeplitz = self._eval_berkowitz_toeplitz_matrix() return toeplitz * submat._eval_berkowitz_vector() def _eval_det_bareiss(self, iszerofunc=_is_zero_after_expand_mul): """Compute matrix determinant using Bareiss' fraction-free algorithm which is an extension of the well known Gaussian elimination method. This approach is best suited for dense symbolic matrices and will result in a determinant with minimal number of fractions. It means that less term rewriting is needed on resulting formulae. TODO: Implement algorithm for sparse matrices (SFF), http://www.eecis.udel.edu/~saunders/papers/sffge/it5.ps. """ # Recursively implemented Bareiss' algorithm as per Deanna Richelle Leggett's # thesis http://www.math.usm.edu/perry/Research/Thesis_DRL.pdf def bareiss(mat, cumm=1): if mat.rows == 0: return S.One elif mat.rows == 1: return mat[0, 0] # find a pivot and extract the remaining matrix # With the default iszerofunc, _find_reasonable_pivot slows down # the computation by the factor of 2.5 in one test. # Relevant issues: #10279 and #13877. pivot_pos, pivot_val, _, _ = _find_reasonable_pivot(mat[:, 0], iszerofunc=iszerofunc) if pivot_pos is None: return S.Zero # if we have a valid pivot, we'll do a "row swap", so keep the # sign of the det sign = (-1) ** (pivot_pos % 2) # we want every row but the pivot row and every column rows = list(i for i in range(mat.rows) if i != pivot_pos) cols = list(range(mat.cols)) tmp_mat = mat.extract(rows, cols) def entry(i, j): ret = (pivot_val*tmp_mat[i, j + 1] - mat[pivot_pos, j + 1]*tmp_mat[i, 0]) / cumm if not ret.is_Atom: return cancel(ret) return ret return sign*bareiss(self._new(mat.rows - 1, mat.cols - 1, entry), pivot_val) return cancel(bareiss(self)) def _eval_det_berkowitz(self): """ Use the Berkowitz algorithm to compute the determinant.""" berk_vector = self._eval_berkowitz_vector() return (-1)**(len(berk_vector) - 1) * berk_vector[-1] def _eval_det_lu(self, iszerofunc=_iszero, simpfunc=None): """ Computes the determinant of a matrix from its LU decomposition. This function uses the LU decomposition computed by LUDecomposition_Simple(). The keyword arguments iszerofunc and simpfunc are passed to LUDecomposition_Simple(). iszerofunc is a callable that returns a boolean indicating if its input is zero, or None if it cannot make the determination. simpfunc is a callable that simplifies its input. The default is simpfunc=None, which indicate that the pivot search algorithm should not attempt to simplify any candidate pivots. If simpfunc fails to simplify its input, then it must return its input instead of a copy.""" if self.rows == 0: return S.One # sympy/matrices/tests/test_matrices.py contains a test that # suggests that the determinant of a 0 x 0 matrix is one, by # convention. lu, row_swaps = self.LUdecomposition_Simple(iszerofunc=iszerofunc, simpfunc=None) # P*A = L*U => det(A) = det(L)*det(U)/det(P) = det(P)*det(U). # Lower triangular factor L encoded in lu has unit diagonal => det(L) = 1. # P is a permutation matrix => det(P) in {-1, 1} => 1/det(P) = det(P). # LUdecomposition_Simple() returns a list of row exchange index pairs, rather # than a permutation matrix, but det(P) = (-1)**len(row_swaps). # Avoid forming the potentially time consuming product of U's diagonal entries # if the product is zero. # Bottom right entry of U is 0 => det(A) = 0. # It may be impossible to determine if this entry of U is zero when it is symbolic. if iszerofunc(lu[lu.rows-1, lu.rows-1]): return S.Zero # Compute det(P) det = -S.One if len(row_swaps)%2 else S.One # Compute det(U) by calculating the product of U's diagonal entries. # The upper triangular portion of lu is the upper triangular portion of the # U factor in the LU decomposition. for k in range(lu.rows): det *= lu[k, k] # return det(P)*det(U) return det def _eval_determinant(self): """Assumed to exist by matrix expressions; If we subclass MatrixDeterminant, we can fully evaluate determinants.""" return self.det() def adjugate(self, method="berkowitz"): """Returns the adjugate, or classical adjoint, of a matrix. That is, the transpose of the matrix of cofactors. https://en.wikipedia.org/wiki/Adjugate See Also ======== cofactor_matrix transpose """ return self.cofactor_matrix(method).transpose() def charpoly(self, x='lambda', simplify=_simplify): """Computes characteristic polynomial det(x*I - self) where I is the identity matrix. A PurePoly is returned, so using different variables for ``x`` does not affect the comparison or the polynomials: Examples ======== >>> from sympy import Matrix >>> from sympy.abc import x, y >>> A = Matrix([[1, 3], [2, 0]]) >>> A.charpoly(x) == A.charpoly(y) True Specifying ``x`` is optional; a symbol named ``lambda`` is used by default (which looks good when pretty-printed in unicode): >>> A.charpoly().as_expr() lambda**2 - lambda - 6 And if ``x`` clashes with an existing symbol, underscores will be preppended to the name to make it unique: >>> A = Matrix([[1, 2], [x, 0]]) >>> A.charpoly(x).as_expr() _x**2 - _x - 2*x Whether you pass a symbol or not, the generator can be obtained with the gen attribute since it may not be the same as the symbol that was passed: >>> A.charpoly(x).gen _x >>> A.charpoly(x).gen == x False Notes ===== The Samuelson-Berkowitz algorithm is used to compute the characteristic polynomial efficiently and without any division operations. Thus the characteristic polynomial over any commutative ring without zero divisors can be computed. See Also ======== det """ if not self.is_square: raise NonSquareMatrixError() berk_vector = self._eval_berkowitz_vector() x = _uniquely_named_symbol(x, berk_vector) return PurePoly([simplify(a) for a in berk_vector], x) def cofactor(self, i, j, method="berkowitz"): """Calculate the cofactor of an element. See Also ======== cofactor_matrix minor minor_submatrix """ if not self.is_square or self.rows < 1: raise NonSquareMatrixError() return (-1)**((i + j) % 2) * self.minor(i, j, method) def cofactor_matrix(self, method="berkowitz"): """Return a matrix containing the cofactor of each element. See Also ======== cofactor minor minor_submatrix adjugate """ if not self.is_square or self.rows < 1: raise NonSquareMatrixError() return self._new(self.rows, self.cols, lambda i, j: self.cofactor(i, j, method)) def det(self, method="bareiss", iszerofunc=None): """Computes the determinant of a matrix. Parameters ========== method : string, optional Specifies the algorithm used for computing the matrix determinant. If the matrix is at most 3x3, a hard-coded formula is used and the specified method is ignored. Otherwise, it defaults to ``'bareiss'``. If it is set to ``'bareiss'``, Bareiss' fraction-free algorithm will be used. If it is set to ``'berkowitz'``, Berkowitz' algorithm will be used. Otherwise, if it is set to ``'lu'``, LU decomposition will be used. .. note:: For backward compatibility, legacy keys like "bareis" and "det_lu" can still be used to indicate the corresponding methods. And the keys are also case-insensitive for now. However, it is suggested to use the precise keys for specifying the method. iszerofunc : FunctionType or None, optional If it is set to ``None``, it will be defaulted to ``_iszero`` if the method is set to ``'bareiss'``, and ``_is_zero_after_expand_mul`` if the method is set to ``'lu'``. It can also accept any user-specified zero testing function, if it is formatted as a function which accepts a single symbolic argument and returns ``True`` if it is tested as zero and ``False`` if it tested as non-zero, and also ``None`` if it is undecidable. Returns ======= det : Basic Result of determinant. Raises ====== ValueError If unrecognized keys are given for ``method`` or ``iszerofunc``. NonSquareMatrixError If attempted to calculate determinant from a non-square matrix. """ # sanitize `method` method = method.lower() if method == "bareis": method = "bareiss" if method == "det_lu": method = "lu" if method not in ("bareiss", "berkowitz", "lu"): raise ValueError("Determinant method '%s' unrecognized" % method) if iszerofunc is None: if method == "bareiss": iszerofunc = _is_zero_after_expand_mul elif method == "lu": iszerofunc = _iszero elif not isinstance(iszerofunc, FunctionType): raise ValueError("Zero testing method '%s' unrecognized" % iszerofunc) # if methods were made internal and all determinant calculations # passed through here, then these lines could be factored out of # the method routines if not self.is_square: raise NonSquareMatrixError() n = self.rows if n == 0: return S.One elif n == 1: return self[0,0] elif n == 2: return self[0, 0] * self[1, 1] - self[0, 1] * self[1, 0] elif n == 3: return (self[0, 0] * self[1, 1] * self[2, 2] + self[0, 1] * self[1, 2] * self[2, 0] + self[0, 2] * self[1, 0] * self[2, 1] - self[0, 2] * self[1, 1] * self[2, 0] - self[0, 0] * self[1, 2] * self[2, 1] - self[0, 1] * self[1, 0] * self[2, 2]) if method == "bareiss": return self._eval_det_bareiss(iszerofunc=iszerofunc) elif method == "berkowitz": return self._eval_det_berkowitz() elif method == "lu": return self._eval_det_lu(iszerofunc=iszerofunc) def minor(self, i, j, method="berkowitz"): """Return the (i,j) minor of ``self``. That is, return the determinant of the matrix obtained by deleting the `i`th row and `j`th column from ``self``. See Also ======== minor_submatrix cofactor det """ if not self.is_square or self.rows < 1: raise NonSquareMatrixError() return self.minor_submatrix(i, j).det(method=method) def minor_submatrix(self, i, j): """Return the submatrix obtained by removing the `i`th row and `j`th column from ``self``. See Also ======== minor cofactor """ if i < 0: i += self.rows if j < 0: j += self.cols if not 0 <= i < self.rows or not 0 <= j < self.cols: raise ValueError("`i` and `j` must satisfy 0 <= i < ``self.rows`` " "(%d)" % self.rows + "and 0 <= j < ``self.cols`` (%d)." % self.cols) rows = [a for a in range(self.rows) if a != i] cols = [a for a in range(self.cols) if a != j] return self.extract(rows, cols) class MatrixReductions(MatrixDeterminant): """Provides basic matrix row/column operations. Should not be instantiated directly.""" def _eval_col_op_swap(self, col1, col2): def entry(i, j): if j == col1: return self[i, col2] elif j == col2: return self[i, col1] return self[i, j] return self._new(self.rows, self.cols, entry) def _eval_col_op_multiply_col_by_const(self, col, k): def entry(i, j): if j == col: return k * self[i, j] return self[i, j] return self._new(self.rows, self.cols, entry) def _eval_col_op_add_multiple_to_other_col(self, col, k, col2): def entry(i, j): if j == col: return self[i, j] + k * self[i, col2] return self[i, j] return self._new(self.rows, self.cols, entry) def _eval_row_op_swap(self, row1, row2): def entry(i, j): if i == row1: return self[row2, j] elif i == row2: return self[row1, j] return self[i, j] return self._new(self.rows, self.cols, entry) def _eval_row_op_multiply_row_by_const(self, row, k): def entry(i, j): if i == row: return k * self[i, j] return self[i, j] return self._new(self.rows, self.cols, entry) def _eval_row_op_add_multiple_to_other_row(self, row, k, row2): def entry(i, j): if i == row: return self[i, j] + k * self[row2, j] return self[i, j] return self._new(self.rows, self.cols, entry) def _eval_echelon_form(self, iszerofunc, simpfunc): """Returns (mat, swaps) where ``mat`` is a row-equivalent matrix in echelon form and ``swaps`` is a list of row-swaps performed.""" reduced, pivot_cols, swaps = self._row_reduce(iszerofunc, simpfunc, normalize_last=True, normalize=False, zero_above=False) return reduced, pivot_cols, swaps def _eval_is_echelon(self, iszerofunc): if self.rows <= 0 or self.cols <= 0: return True zeros_below = all(iszerofunc(t) for t in self[1:, 0]) if iszerofunc(self[0, 0]): return zeros_below and self[:, 1:]._eval_is_echelon(iszerofunc) return zeros_below and self[1:, 1:]._eval_is_echelon(iszerofunc) def _eval_rref(self, iszerofunc, simpfunc, normalize_last=True): reduced, pivot_cols, swaps = self._row_reduce(iszerofunc, simpfunc, normalize_last, normalize=True, zero_above=True) return reduced, pivot_cols def _normalize_op_args(self, op, col, k, col1, col2, error_str="col"): """Validate the arguments for a row/column operation. ``error_str`` can be one of "row" or "col" depending on the arguments being parsed.""" if op not in ["n->kn", "n<->m", "n->n+km"]: raise ValueError("Unknown {} operation '{}'. Valid col operations " "are 'n->kn', 'n<->m', 'n->n+km'".format(error_str, op)) # normalize and validate the arguments if op == "n->kn": col = col if col is not None else col1 if col is None or k is None: raise ValueError("For a {0} operation 'n->kn' you must provide the " "kwargs `{0}` and `k`".format(error_str)) if not 0 <= col <= self.cols: raise ValueError("This matrix doesn't have a {} '{}'".format(error_str, col)) if op == "n<->m": # we need two cols to swap. It doesn't matter # how they were specified, so gather them together and # remove `None` cols = set((col, k, col1, col2)).difference([None]) if len(cols) > 2: # maybe the user left `k` by mistake? cols = set((col, col1, col2)).difference([None]) if len(cols) != 2: raise ValueError("For a {0} operation 'n<->m' you must provide the " "kwargs `{0}1` and `{0}2`".format(error_str)) col1, col2 = cols if not 0 <= col1 <= self.cols: raise ValueError("This matrix doesn't have a {} '{}'".format(error_str, col1)) if not 0 <= col2 <= self.cols: raise ValueError("This matrix doesn't have a {} '{}'".format(error_str, col2)) if op == "n->n+km": col = col1 if col is None else col col2 = col1 if col2 is None else col2 if col is None or col2 is None or k is None: raise ValueError("For a {0} operation 'n->n+km' you must provide the " "kwargs `{0}`, `k`, and `{0}2`".format(error_str)) if col == col2: raise ValueError("For a {0} operation 'n->n+km' `{0}` and `{0}2` must " "be different.".format(error_str)) if not 0 <= col <= self.cols: raise ValueError("This matrix doesn't have a {} '{}'".format(error_str, col)) if not 0 <= col2 <= self.cols: raise ValueError("This matrix doesn't have a {} '{}'".format(error_str, col2)) return op, col, k, col1, col2 def _permute_complexity_right(self, iszerofunc): """Permute columns with complicated elements as far right as they can go. Since the ``sympy`` row reduction algorithms start on the left, having complexity right-shifted speeds things up. Returns a tuple (mat, perm) where perm is a permutation of the columns to perform to shift the complex columns right, and mat is the permuted matrix.""" def complexity(i): # the complexity of a column will be judged by how many # element's zero-ness cannot be determined return sum(1 if iszerofunc(e) is None else 0 for e in self[:, i]) complex = [(complexity(i), i) for i in range(self.cols)] perm = [j for (i, j) in sorted(complex)] return (self.permute(perm, orientation='cols'), perm) def _row_reduce(self, iszerofunc, simpfunc, normalize_last=True, normalize=True, zero_above=True): """Row reduce ``self`` and return a tuple (rref_matrix, pivot_cols, swaps) where pivot_cols are the pivot columns and swaps are any row swaps that were used in the process of row reduction. Parameters ========== iszerofunc : determines if an entry can be used as a pivot simpfunc : used to simplify elements and test if they are zero if ``iszerofunc`` returns `None` normalize_last : indicates where all row reduction should happen in a fraction-free manner and then the rows are normalized (so that the pivots are 1), or whether rows should be normalized along the way (like the naive row reduction algorithm) normalize : whether pivot rows should be normalized so that the pivot value is 1 zero_above : whether entries above the pivot should be zeroed. If ``zero_above=False``, an echelon matrix will be returned. """ rows, cols = self.rows, self.cols mat = list(self) def get_col(i): return mat[i::cols] def row_swap(i, j): mat[i*cols:(i + 1)*cols], mat[j*cols:(j + 1)*cols] = \ mat[j*cols:(j + 1)*cols], mat[i*cols:(i + 1)*cols] def cross_cancel(a, i, b, j): """Does the row op row[i] = a*row[i] - b*row[j]""" q = (j - i)*cols for p in range(i*cols, (i + 1)*cols): mat[p] = a*mat[p] - b*mat[p + q] piv_row, piv_col = 0, 0 pivot_cols = [] swaps = [] # use a fraction free method to zero above and below each pivot while piv_col < cols and piv_row < rows: pivot_offset, pivot_val, \ assumed_nonzero, newly_determined = _find_reasonable_pivot( get_col(piv_col)[piv_row:], iszerofunc, simpfunc) # _find_reasonable_pivot may have simplified some things # in the process. Let's not let them go to waste for (offset, val) in newly_determined: offset += piv_row mat[offset*cols + piv_col] = val if pivot_offset is None: piv_col += 1 continue pivot_cols.append(piv_col) if pivot_offset != 0: row_swap(piv_row, pivot_offset + piv_row) swaps.append((piv_row, pivot_offset + piv_row)) # if we aren't normalizing last, we normalize # before we zero the other rows if normalize_last is False: i, j = piv_row, piv_col mat[i*cols + j] = S.One for p in range(i*cols + j + 1, (i + 1)*cols): mat[p] = mat[p] / pivot_val # after normalizing, the pivot value is 1 pivot_val = S.One # zero above and below the pivot for row in range(rows): # don't zero our current row if row == piv_row: continue # don't zero above the pivot unless we're told. if zero_above is False and row < piv_row: continue # if we're already a zero, don't do anything val = mat[row*cols + piv_col] if iszerofunc(val): continue cross_cancel(pivot_val, row, val, piv_row) piv_row += 1 # normalize each row if normalize_last is True and normalize is True: for piv_i, piv_j in enumerate(pivot_cols): pivot_val = mat[piv_i*cols + piv_j] mat[piv_i*cols + piv_j] = S.One for p in range(piv_i*cols + piv_j + 1, (piv_i + 1)*cols): mat[p] = mat[p] / pivot_val return self._new(self.rows, self.cols, mat), tuple(pivot_cols), tuple(swaps) def echelon_form(self, iszerofunc=_iszero, simplify=False, with_pivots=False): """Returns a matrix row-equivalent to ``self`` that is in echelon form. Note that echelon form of a matrix is *not* unique, however, properties like the row space and the null space are preserved.""" simpfunc = simplify if isinstance( simplify, FunctionType) else _simplify mat, pivots, swaps = self._eval_echelon_form(iszerofunc, simpfunc) if with_pivots: return mat, pivots return mat def elementary_col_op(self, op="n->kn", col=None, k=None, col1=None, col2=None): """Performs the elementary column operation `op`. `op` may be one of * "n->kn" (column n goes to k*n) * "n<->m" (swap column n and column m) * "n->n+km" (column n goes to column n + k*column m) Parameters ========== op : string; the elementary row operation col : the column to apply the column operation k : the multiple to apply in the column operation col1 : one column of a column swap col2 : second column of a column swap or column "m" in the column operation "n->n+km" """ op, col, k, col1, col2 = self._normalize_op_args(op, col, k, col1, col2, "col") # now that we've validated, we're all good to dispatch if op == "n->kn": return self._eval_col_op_multiply_col_by_const(col, k) if op == "n<->m": return self._eval_col_op_swap(col1, col2) if op == "n->n+km": return self._eval_col_op_add_multiple_to_other_col(col, k, col2) def elementary_row_op(self, op="n->kn", row=None, k=None, row1=None, row2=None): """Performs the elementary row operation `op`. `op` may be one of * "n->kn" (row n goes to k*n) * "n<->m" (swap row n and row m) * "n->n+km" (row n goes to row n + k*row m) Parameters ========== op : string; the elementary row operation row : the row to apply the row operation k : the multiple to apply in the row operation row1 : one row of a row swap row2 : second row of a row swap or row "m" in the row operation "n->n+km" """ op, row, k, row1, row2 = self._normalize_op_args(op, row, k, row1, row2, "row") # now that we've validated, we're all good to dispatch if op == "n->kn": return self._eval_row_op_multiply_row_by_const(row, k) if op == "n<->m": return self._eval_row_op_swap(row1, row2) if op == "n->n+km": return self._eval_row_op_add_multiple_to_other_row(row, k, row2) @property def is_echelon(self, iszerofunc=_iszero): """Returns `True` if the matrix is in echelon form. That is, all rows of zeros are at the bottom, and below each leading non-zero in a row are exclusively zeros.""" return self._eval_is_echelon(iszerofunc) def rank(self, iszerofunc=_iszero, simplify=False): """ Returns the rank of a matrix >>> from sympy import Matrix >>> from sympy.abc import x >>> m = Matrix([[1, 2], [x, 1 - 1/x]]) >>> m.rank() 2 >>> n = Matrix(3, 3, range(1, 10)) >>> n.rank() 2 """ simpfunc = simplify if isinstance( simplify, FunctionType) else _simplify # for small matrices, we compute the rank explicitly # if is_zero on elements doesn't answer the question # for small matrices, we fall back to the full routine. if self.rows <= 0 or self.cols <= 0: return 0 if self.rows <= 1 or self.cols <= 1: zeros = [iszerofunc(x) for x in self] if False in zeros: return 1 if self.rows == 2 and self.cols == 2: zeros = [iszerofunc(x) for x in self] if not False in zeros and not None in zeros: return 0 det = self.det() if iszerofunc(det) and False in zeros: return 1 if iszerofunc(det) is False: return 2 mat, _ = self._permute_complexity_right(iszerofunc=iszerofunc) echelon_form, pivots, swaps = mat._eval_echelon_form(iszerofunc=iszerofunc, simpfunc=simpfunc) return len(pivots) def rref(self, iszerofunc=_iszero, simplify=False, pivots=True, normalize_last=True): """Return reduced row-echelon form of matrix and indices of pivot vars. Parameters ========== iszerofunc : Function A function used for detecting whether an element can act as a pivot. ``lambda x: x.is_zero`` is used by default. simplify : Function A function used to simplify elements when looking for a pivot. By default SymPy's ``simplify`` is used. pivots : True or False If ``True``, a tuple containing the row-reduced matrix and a tuple of pivot columns is returned. If ``False`` just the row-reduced matrix is returned. normalize_last : True or False If ``True``, no pivots are normalized to `1` until after all entries above and below each pivot are zeroed. This means the row reduction algorithm is fraction free until the very last step. If ``False``, the naive row reduction procedure is used where each pivot is normalized to be `1` before row operations are used to zero above and below the pivot. Notes ===== The default value of ``normalize_last=True`` can provide significant speedup to row reduction, especially on matrices with symbols. However, if you depend on the form row reduction algorithm leaves entries of the matrix, set ``noramlize_last=False`` Examples ======== >>> from sympy import Matrix >>> from sympy.abc import x >>> m = Matrix([[1, 2], [x, 1 - 1/x]]) >>> m.rref() (Matrix([ [1, 0], [0, 1]]), (0, 1)) >>> rref_matrix, rref_pivots = m.rref() >>> rref_matrix Matrix([ [1, 0], [0, 1]]) >>> rref_pivots (0, 1) """ simpfunc = simplify if isinstance( simplify, FunctionType) else _simplify ret, pivot_cols = self._eval_rref(iszerofunc=iszerofunc, simpfunc=simpfunc, normalize_last=normalize_last) if pivots: ret = (ret, pivot_cols) return ret class MatrixSubspaces(MatrixReductions): """Provides methods relating to the fundamental subspaces of a matrix. Should not be instantiated directly.""" def columnspace(self, simplify=False): """Returns a list of vectors (Matrix objects) that span columnspace of ``self`` Examples ======== >>> from sympy.matrices import Matrix >>> m = Matrix(3, 3, [1, 3, 0, -2, -6, 0, 3, 9, 6]) >>> m Matrix([ [ 1, 3, 0], [-2, -6, 0], [ 3, 9, 6]]) >>> m.columnspace() [Matrix([ [ 1], [-2], [ 3]]), Matrix([ [0], [0], [6]])] See Also ======== nullspace rowspace """ reduced, pivots = self.echelon_form(simplify=simplify, with_pivots=True) return [self.col(i) for i in pivots] def nullspace(self, simplify=False, iszerofunc=_iszero): """Returns list of vectors (Matrix objects) that span nullspace of ``self`` Examples ======== >>> from sympy.matrices import Matrix >>> m = Matrix(3, 3, [1, 3, 0, -2, -6, 0, 3, 9, 6]) >>> m Matrix([ [ 1, 3, 0], [-2, -6, 0], [ 3, 9, 6]]) >>> m.nullspace() [Matrix([ [-3], [ 1], [ 0]])] See Also ======== columnspace rowspace """ reduced, pivots = self.rref(iszerofunc=iszerofunc, simplify=simplify) free_vars = [i for i in range(self.cols) if i not in pivots] basis = [] for free_var in free_vars: # for each free variable, we will set it to 1 and all others # to 0. Then, we will use back substitution to solve the system vec = [S.Zero]*self.cols vec[free_var] = S.One for piv_row, piv_col in enumerate(pivots): vec[piv_col] -= reduced[piv_row, free_var] basis.append(vec) return [self._new(self.cols, 1, b) for b in basis] def rowspace(self, simplify=False): """Returns a list of vectors that span the row space of ``self``.""" reduced, pivots = self.echelon_form(simplify=simplify, with_pivots=True) return [reduced.row(i) for i in range(len(pivots))] @classmethod def orthogonalize(cls, *vecs, **kwargs): """Apply the Gram-Schmidt orthogonalization procedure to vectors supplied in ``vecs``. Parameters ========== vecs vectors to be made orthogonal normalize : bool If ``True``, return an orthonormal basis. rankcheck : bool If ``True``, the computation does not stop when encountering linearly dependent vectors. If ``False``, it will raise ``ValueError`` when any zero or linearly dependent vectors are found. Returns ======= list List of orthogonal (or orthonormal) basis vectors. See Also ======== MatrixBase.QRdecomposition References ========== .. [1] https://en.wikipedia.org/wiki/Gram%E2%80%93Schmidt_process """ normalize = kwargs.get('normalize', False) rankcheck = kwargs.get('rankcheck', False) def project(a, b): return b * (a.dot(b) / b.dot(b)) def perp_to_subspace(vec, basis): """projects vec onto the subspace given by the orthogonal basis ``basis``""" components = [project(vec, b) for b in basis] if len(basis) == 0: return vec return vec - reduce(lambda a, b: a + b, components) ret = [] # make sure we start with a non-zero vector vecs = list(vecs) while len(vecs) > 0 and vecs[0].is_zero: if rankcheck is False: del vecs[0] else: raise ValueError( "GramSchmidt: vector set not linearly independent") for vec in vecs: perp = perp_to_subspace(vec, ret) if not perp.is_zero: ret.append(perp) elif rankcheck is True: raise ValueError( "GramSchmidt: vector set not linearly independent") if normalize: ret = [vec / vec.norm() for vec in ret] return ret class MatrixEigen(MatrixSubspaces): """Provides basic matrix eigenvalue/vector operations. Should not be instantiated directly.""" @property def _cache_is_diagonalizable(self): SymPyDeprecationWarning( feature='_cache_is_diagonalizable', deprecated_since_version="1.4", issue=15887 ).warn() return None @property def _cache_eigenvects(self): SymPyDeprecationWarning( feature='_cache_eigenvects', deprecated_since_version="1.4", issue=15887 ).warn() return None def diagonalize(self, reals_only=False, sort=False, normalize=False): """ Return (P, D), where D is diagonal and D = P^-1 * M * P where M is current matrix. Parameters ========== reals_only : bool. Whether to throw an error if complex numbers are need to diagonalize. (Default: False) sort : bool. Sort the eigenvalues along the diagonal. (Default: False) normalize : bool. If True, normalize the columns of P. (Default: False) Examples ======== >>> from sympy import Matrix >>> m = Matrix(3, 3, [1, 2, 0, 0, 3, 0, 2, -4, 2]) >>> m Matrix([ [1, 2, 0], [0, 3, 0], [2, -4, 2]]) >>> (P, D) = m.diagonalize() >>> D Matrix([ [1, 0, 0], [0, 2, 0], [0, 0, 3]]) >>> P Matrix([ [-1, 0, -1], [ 0, 0, -1], [ 2, 1, 2]]) >>> P.inv() * m * P Matrix([ [1, 0, 0], [0, 2, 0], [0, 0, 3]]) See Also ======== is_diagonal is_diagonalizable """ if not self.is_square: raise NonSquareMatrixError() if not self.is_diagonalizable(reals_only=reals_only): raise MatrixError("Matrix is not diagonalizable") eigenvecs = self.eigenvects(simplify=True) if sort: eigenvecs = sorted(eigenvecs, key=default_sort_key) p_cols, diag = [], [] for val, mult, basis in eigenvecs: diag += [val] * mult p_cols += basis if normalize: p_cols = [v / v.norm() for v in p_cols] return self.hstack(*p_cols), self.diag(*diag) def eigenvals(self, error_when_incomplete=True, **flags): r"""Return eigenvalues using the Berkowitz agorithm to compute the characteristic polynomial. Parameters ========== error_when_incomplete : bool, optional If it is set to ``True``, it will raise an error if not all eigenvalues are computed. This is caused by ``roots`` not returning a full list of eigenvalues. simplify : bool or function, optional If it is set to ``True``, it attempts to return the most simplified form of expressions returned by applying default simplification method in every routine. If it is set to ``False``, it will skip simplification in this particular routine to save computation resources. If a function is passed to, it will attempt to apply the particular function as simplification method. rational : bool, optional If it is set to ``True``, every floating point numbers would be replaced with rationals before computation. It can solve some issues of ``roots`` routine not working well with floats. multiple : bool, optional If it is set to ``True``, the result will be in the form of a list. If it is set to ``False``, the result will be in the form of a dictionary. Returns ======= eigs : list or dict Eigenvalues of a matrix. The return format would be specified by the key ``multiple``. Raises ====== MatrixError If not enough roots had got computed. NonSquareMatrixError If attempted to compute eigenvalues from a non-square matrix. See Also ======== MatrixDeterminant.charpoly eigenvects Notes ===== Eigenvalues of a matrix `A` can be computed by solving a matrix equation `\det(A - \lambda I) = 0` """ simplify = flags.get('simplify', False) # Collect simplify flag before popped up, to reuse later in the routine. multiple = flags.get('multiple', False) # Collect multiple flag to decide whether return as a dict or list. rational = flags.pop('rational', True) mat = self if not mat: return {} if rational: mat = mat.applyfunc( lambda x: nsimplify(x, rational=True) if x.has(Float) else x) if mat.is_upper or mat.is_lower: if not self.is_square: raise NonSquareMatrixError() diagonal_entries = [mat[i, i] for i in range(mat.rows)] if multiple: eigs = diagonal_entries else: eigs = {} for diagonal_entry in diagonal_entries: if diagonal_entry not in eigs: eigs[diagonal_entry] = 0 eigs[diagonal_entry] += 1 else: flags.pop('simplify', None) # pop unsupported flag if isinstance(simplify, FunctionType): eigs = roots(mat.charpoly(x=Dummy('x'), simplify=simplify), **flags) else: eigs = roots(mat.charpoly(x=Dummy('x')), **flags) # make sure the algebraic multiplicty sums to the # size of the matrix if error_when_incomplete and (sum(eigs.values()) if isinstance(eigs, dict) else len(eigs)) != self.cols: raise MatrixError("Could not compute eigenvalues for {}".format(self)) # Since 'simplify' flag is unsupported in roots() # simplify() function will be applied once at the end of the routine. if not simplify: return eigs if not isinstance(simplify, FunctionType): simplify = _simplify # With 'multiple' flag set true, simplify() will be mapped for the list # Otherwise, simplify() will be mapped for the keys of the dictionary if not multiple: return {simplify(key): value for key, value in eigs.items()} else: return [simplify(value) for value in eigs] def eigenvects(self, error_when_incomplete=True, iszerofunc=_iszero, **flags): """Return list of triples (eigenval, multiplicity, eigenspace). Parameters ========== error_when_incomplete : bool, optional Raise an error when not all eigenvalues are computed. This is caused by ``roots`` not returning a full list of eigenvalues. iszerofunc : function, optional Specifies a zero testing function to be used in ``rref``. Default value is ``_iszero``, which uses SymPy's naive and fast default assumption handler. It can also accept any user-specified zero testing function, if it is formatted as a function which accepts a single symbolic argument and returns ``True`` if it is tested as zero and ``False`` if it is tested as non-zero, and ``None`` if it is undecidable. simplify : bool or function, optional If ``True``, ``as_content_primitive()`` will be used to tidy up normalization artifacts. It will also be used by the ``nullspace`` routine. chop : bool or positive number, optional If the matrix contains any Floats, they will be changed to Rationals for computation purposes, but the answers will be returned after being evaluated with evalf. The ``chop`` flag is passed to ``evalf``. When ``chop=True`` a default precision will be used; a number will be interpreted as the desired level of precision. Returns ======= ret : [(eigenval, multiplicity, eigenspace), ...] A ragged list containing tuples of data obtained by ``eigenvals`` and ``nullspace``. ``eigenspace`` is a list containing the ``eigenvector`` for each eigenvalue. ``eigenvector`` is a vector in the form of a ``Matrix``. e.g. a vector of length 3 is returned as ``Matrix([a_1, a_2, a_3])``. Raises ====== NotImplementedError If failed to compute nullspace. See Also ======== eigenvals MatrixSubspaces.nullspace """ from sympy.matrices import eye simplify = flags.get('simplify', True) if not isinstance(simplify, FunctionType): simpfunc = _simplify if simplify else lambda x: x primitive = flags.get('simplify', False) chop = flags.pop('chop', False) flags.pop('multiple', None) # remove this if it's there mat = self # roots doesn't like Floats, so replace them with Rationals has_floats = self.has(Float) if has_floats: mat = mat.applyfunc(lambda x: nsimplify(x, rational=True)) def eigenspace(eigenval): """Get a basis for the eigenspace for a particular eigenvalue""" m = mat - self.eye(mat.rows) * eigenval ret = m.nullspace(iszerofunc=iszerofunc) # the nullspace for a real eigenvalue should be # non-trivial. If we didn't find an eigenvector, try once # more a little harder if len(ret) == 0 and simplify: ret = m.nullspace(iszerofunc=iszerofunc, simplify=True) if len(ret) == 0: raise NotImplementedError( "Can't evaluate eigenvector for eigenvalue %s" % eigenval) return ret eigenvals = mat.eigenvals(rational=False, error_when_incomplete=error_when_incomplete, **flags) ret = [(val, mult, eigenspace(val)) for val, mult in sorted(eigenvals.items(), key=default_sort_key)] if primitive: # if the primitive flag is set, get rid of any common # integer denominators def denom_clean(l): from sympy import gcd return [(v / gcd(list(v))).applyfunc(simpfunc) for v in l] ret = [(val, mult, denom_clean(es)) for val, mult, es in ret] if has_floats: # if we had floats to start with, turn the eigenvectors to floats ret = [(val.evalf(chop=chop), mult, [v.evalf(chop=chop) for v in es]) for val, mult, es in ret] return ret def is_diagonalizable(self, reals_only=False, **kwargs): """Returns true if a matrix is diagonalizable. Parameters ========== reals_only : bool. If reals_only=True, determine whether the matrix can be diagonalized without complex numbers. (Default: False) kwargs ====== clear_cache : bool. If True, clear the result of any computations when finished. (Default: True) Examples ======== >>> from sympy import Matrix >>> m = Matrix(3, 3, [1, 2, 0, 0, 3, 0, 2, -4, 2]) >>> m Matrix([ [1, 2, 0], [0, 3, 0], [2, -4, 2]]) >>> m.is_diagonalizable() True >>> m = Matrix(2, 2, [0, 1, 0, 0]) >>> m Matrix([ [0, 1], [0, 0]]) >>> m.is_diagonalizable() False >>> m = Matrix(2, 2, [0, 1, -1, 0]) >>> m Matrix([ [ 0, 1], [-1, 0]]) >>> m.is_diagonalizable() True >>> m.is_diagonalizable(reals_only=True) False See Also ======== is_diagonal diagonalize """ if 'clear_cache' in kwargs: SymPyDeprecationWarning( feature='clear_cache', deprecated_since_version=1.4, issue=15887 ).warn() if 'clear_subproducts' in kwargs: SymPyDeprecationWarning( feature='clear_subproducts', deprecated_since_version=1.4, issue=15887 ).warn() if not self.is_square: return False if all(e.is_real for e in self) and self.is_symmetric(): # every real symmetric matrix is real diagonalizable return True eigenvecs = self.eigenvects(simplify=True) ret = True for val, mult, basis in eigenvecs: # if we have a complex eigenvalue if reals_only and not val.is_real: ret = False # if the geometric multiplicity doesn't equal the algebraic if mult != len(basis): ret = False return ret def jordan_form(self, calc_transform=True, **kwargs): """Return ``(P, J)`` where `J` is a Jordan block matrix and `P` is a matrix such that ``self == P*J*P**-1`` Parameters ========== calc_transform : bool If ``False``, then only `J` is returned. chop : bool All matrices are convered to exact types when computing eigenvalues and eigenvectors. As a result, there may be approximation errors. If ``chop==True``, these errors will be truncated. Examples ======== >>> from sympy import Matrix >>> m = Matrix([[ 6, 5, -2, -3], [-3, -1, 3, 3], [ 2, 1, -2, -3], [-1, 1, 5, 5]]) >>> P, J = m.jordan_form() >>> J Matrix([ [2, 1, 0, 0], [0, 2, 0, 0], [0, 0, 2, 1], [0, 0, 0, 2]]) See Also ======== jordan_block """ if not self.is_square: raise NonSquareMatrixError("Only square matrices have Jordan forms") chop = kwargs.pop('chop', False) mat = self has_floats = self.has(Float) if has_floats: try: max_prec = max(term._prec for term in self._mat if isinstance(term, Float)) except ValueError: # if no term in the matrix is explicitly a Float calling max() # will throw a error so setting max_prec to default value of 53 max_prec = 53 # setting minimum max_dps to 15 to prevent loss of precision in # matrix containing non evaluated expressions max_dps = max(prec_to_dps(max_prec), 15) def restore_floats(*args): """If ``has_floats`` is `True`, cast all ``args`` as matrices of floats.""" if has_floats: args = [m.evalf(prec=max_dps, chop=chop) for m in args] if len(args) == 1: return args[0] return args # cache calculations for some speedup mat_cache = {} def eig_mat(val, pow): """Cache computations of ``(self - val*I)**pow`` for quick retrieval""" if (val, pow) in mat_cache: return mat_cache[(val, pow)] if (val, pow - 1) in mat_cache: mat_cache[(val, pow)] = mat_cache[(val, pow - 1)] * mat_cache[(val, 1)] else: mat_cache[(val, pow)] = (mat - val*self.eye(self.rows))**pow return mat_cache[(val, pow)] # helper functions def nullity_chain(val, algebraic_multiplicity): """Calculate the sequence [0, nullity(E), nullity(E**2), ...] until it is constant where ``E = self - val*I``""" # mat.rank() is faster than computing the null space, # so use the rank-nullity theorem cols = self.cols ret = [0] nullity = cols - eig_mat(val, 1).rank() i = 2 while nullity != ret[-1]: ret.append(nullity) if nullity == algebraic_multiplicity: break nullity = cols - eig_mat(val, i).rank() i += 1 # Due to issues like #7146 and #15872, SymPy sometimes # gives the wrong rank. In this case, raise an error # instead of returning an incorrect matrix if nullity < ret[-1] or nullity > algebraic_multiplicity: raise MatrixError( "SymPy had encountered an inconsistent " "result while computing Jordan block: " "{}".format(self)) return ret def blocks_from_nullity_chain(d): """Return a list of the size of each Jordan block. If d_n is the nullity of E**n, then the number of Jordan blocks of size n is 2*d_n - d_(n-1) - d_(n+1)""" # d[0] is always the number of columns, so skip past it mid = [2*d[n] - d[n - 1] - d[n + 1] for n in range(1, len(d) - 1)] # d is assumed to plateau with "d[ len(d) ] == d[-1]", so # 2*d_n - d_(n-1) - d_(n+1) == d_n - d_(n-1) end = [d[-1] - d[-2]] if len(d) > 1 else [d[0]] return mid + end def pick_vec(small_basis, big_basis): """Picks a vector from big_basis that isn't in the subspace spanned by small_basis""" if len(small_basis) == 0: return big_basis[0] for v in big_basis: _, pivots = self.hstack(*(small_basis + [v])).echelon_form(with_pivots=True) if pivots[-1] == len(small_basis): return v # roots doesn't like Floats, so replace them with Rationals if has_floats: mat = mat.applyfunc(lambda x: nsimplify(x, rational=True)) # first calculate the jordan block structure eigs = mat.eigenvals() # make sure that we found all the roots by counting # the algebraic multiplicity if sum(m for m in eigs.values()) != mat.cols: raise MatrixError("Could not compute eigenvalues for {}".format(mat)) # most matrices have distinct eigenvalues # and so are diagonalizable. In this case, don't # do extra work! if len(eigs.keys()) == mat.cols: blocks = list(sorted(eigs.keys(), key=default_sort_key)) jordan_mat = mat.diag(*blocks) if not calc_transform: return restore_floats(jordan_mat) jordan_basis = [eig_mat(eig, 1).nullspace()[0] for eig in blocks] basis_mat = mat.hstack(*jordan_basis) return restore_floats(basis_mat, jordan_mat) block_structure = [] for eig in sorted(eigs.keys(), key=default_sort_key): algebraic_multiplicity = eigs[eig] chain = nullity_chain(eig, algebraic_multiplicity) block_sizes = blocks_from_nullity_chain(chain) # if block_sizes == [a, b, c, ...], then the number of # Jordan blocks of size 1 is a, of size 2 is b, etc. # create an array that has (eig, block_size) with one # entry for each block size_nums = [(i+1, num) for i, num in enumerate(block_sizes)] # we expect larger Jordan blocks to come earlier size_nums.reverse() block_structure.extend( (eig, size) for size, num in size_nums for _ in range(num)) jordan_form_size = sum(size for eig, size in block_structure) if jordan_form_size != self.rows: raise MatrixError( "SymPy had encountered an inconsistent result while " "computing Jordan block. : {}".format(self)) blocks = (mat.jordan_block(size=size, eigenvalue=eig) for eig, size in block_structure) jordan_mat = mat.diag(*blocks) if not calc_transform: return restore_floats(jordan_mat) # For each generalized eigenspace, calculate a basis. # We start by looking for a vector in null( (A - eig*I)**n ) # which isn't in null( (A - eig*I)**(n-1) ) where n is # the size of the Jordan block # # Ideally we'd just loop through block_structure and # compute each generalized eigenspace. However, this # causes a lot of unneeded computation. Instead, we # go through the eigenvalues separately, since we know # their generalized eigenspaces must have bases that # are linearly independent. jordan_basis = [] for eig in sorted(eigs.keys(), key=default_sort_key): eig_basis = [] for block_eig, size in block_structure: if block_eig != eig: continue null_big = (eig_mat(eig, size)).nullspace() null_small = (eig_mat(eig, size - 1)).nullspace() # we want to pick something that is in the big basis # and not the small, but also something that is independent # of any other generalized eigenvectors from a different # generalized eigenspace sharing the same eigenvalue. vec = pick_vec(null_small + eig_basis, null_big) new_vecs = [(eig_mat(eig, i))*vec for i in range(size)] eig_basis.extend(new_vecs) jordan_basis.extend(reversed(new_vecs)) basis_mat = mat.hstack(*jordan_basis) return restore_floats(basis_mat, jordan_mat) def left_eigenvects(self, **flags): """Returns left eigenvectors and eigenvalues. This function returns the list of triples (eigenval, multiplicity, basis) for the left eigenvectors. Options are the same as for eigenvects(), i.e. the ``**flags`` arguments gets passed directly to eigenvects(). Examples ======== >>> from sympy import Matrix >>> M = Matrix([[0, 1, 1], [1, 0, 0], [1, 1, 1]]) >>> M.eigenvects() [(-1, 1, [Matrix([ [-1], [ 1], [ 0]])]), (0, 1, [Matrix([ [ 0], [-1], [ 1]])]), (2, 1, [Matrix([ [2/3], [1/3], [ 1]])])] >>> M.left_eigenvects() [(-1, 1, [Matrix([[-2, 1, 1]])]), (0, 1, [Matrix([[-1, -1, 1]])]), (2, 1, [Matrix([[1, 1, 1]])])] """ eigs = self.transpose().eigenvects(**flags) return [(val, mult, [l.transpose() for l in basis]) for val, mult, basis in eigs] def singular_values(self): """Compute the singular values of a Matrix Examples ======== >>> from sympy import Matrix, Symbol >>> x = Symbol('x', real=True) >>> A = Matrix([[0, 1, 0], [0, x, 0], [-1, 0, 0]]) >>> A.singular_values() [sqrt(x**2 + 1), 1, 0] See Also ======== condition_number """ mat = self if self.rows >= self.cols: valmultpairs = (mat.H * mat).eigenvals() else: valmultpairs = (mat * mat.H).eigenvals() # Expands result from eigenvals into a simple list vals = [] for k, v in valmultpairs.items(): vals += [sqrt(k)] * v # dangerous! same k in several spots! # Pad with zeros if singular values are computed in reverse way, # to give consistent format. if len(vals) < self.cols: vals += [S.Zero] * (self.cols - len(vals)) # sort them in descending order vals.sort(reverse=True, key=default_sort_key) return vals class MatrixCalculus(MatrixCommon): """Provides calculus-related matrix operations.""" def diff(self, *args, **kwargs): """Calculate the derivative of each element in the matrix. ``args`` will be passed to the ``integrate`` function. Examples ======== >>> from sympy.matrices import Matrix >>> from sympy.abc import x, y >>> M = Matrix([[x, y], [1, 0]]) >>> M.diff(x) Matrix([ [1, 0], [0, 0]]) See Also ======== integrate limit """ # XXX this should be handled here rather than in Derivative from sympy import Derivative kwargs.setdefault('evaluate', True) deriv = Derivative(self, *args, evaluate=True) if not isinstance(self, Basic): return deriv.as_mutable() else: return deriv def _eval_derivative(self, arg): return self.applyfunc(lambda x: x.diff(arg)) def _accept_eval_derivative(self, s): return s._visit_eval_derivative_array(self) def _visit_eval_derivative_scalar(self, base): # Types are (base: scalar, self: matrix) return self.applyfunc(lambda x: base.diff(x)) def _visit_eval_derivative_array(self, base): # Types are (base: array/matrix, self: matrix) from sympy import derive_by_array return derive_by_array(base, self) def integrate(self, *args): """Integrate each element of the matrix. ``args`` will be passed to the ``integrate`` function. Examples ======== >>> from sympy.matrices import Matrix >>> from sympy.abc import x, y >>> M = Matrix([[x, y], [1, 0]]) >>> M.integrate((x, )) Matrix([ [x**2/2, x*y], [ x, 0]]) >>> M.integrate((x, 0, 2)) Matrix([ [2, 2*y], [2, 0]]) See Also ======== limit diff """ return self.applyfunc(lambda x: x.integrate(*args)) def jacobian(self, X): """Calculates the Jacobian matrix (derivative of a vector-valued function). Parameters ========== ``self`` : vector of expressions representing functions f_i(x_1, ..., x_n). X : set of x_i's in order, it can be a list or a Matrix Both ``self`` and X can be a row or a column matrix in any order (i.e., jacobian() should always work). Examples ======== >>> from sympy import sin, cos, Matrix >>> from sympy.abc import rho, phi >>> X = Matrix([rho*cos(phi), rho*sin(phi), rho**2]) >>> Y = Matrix([rho, phi]) >>> X.jacobian(Y) Matrix([ [cos(phi), -rho*sin(phi)], [sin(phi), rho*cos(phi)], [ 2*rho, 0]]) >>> X = Matrix([rho*cos(phi), rho*sin(phi)]) >>> X.jacobian(Y) Matrix([ [cos(phi), -rho*sin(phi)], [sin(phi), rho*cos(phi)]]) See Also ======== hessian wronskian """ if not isinstance(X, MatrixBase): X = self._new(X) # Both X and ``self`` can be a row or a column matrix, so we need to make # sure all valid combinations work, but everything else fails: if self.shape[0] == 1: m = self.shape[1] elif self.shape[1] == 1: m = self.shape[0] else: raise TypeError("``self`` must be a row or a column matrix") if X.shape[0] == 1: n = X.shape[1] elif X.shape[1] == 1: n = X.shape[0] else: raise TypeError("X must be a row or a column matrix") # m is the number of functions and n is the number of variables # computing the Jacobian is now easy: return self._new(m, n, lambda j, i: self[j].diff(X[i])) def limit(self, *args): """Calculate the limit of each element in the matrix. ``args`` will be passed to the ``limit`` function. Examples ======== >>> from sympy.matrices import Matrix >>> from sympy.abc import x, y >>> M = Matrix([[x, y], [1, 0]]) >>> M.limit(x, 2) Matrix([ [2, y], [1, 0]]) See Also ======== integrate diff """ return self.applyfunc(lambda x: x.limit(*args)) # https://github.com/sympy/sympy/pull/12854 class MatrixDeprecated(MatrixCommon): """A class to house deprecated matrix methods.""" def _legacy_array_dot(self, b): """Compatibility function for deprecated behavior of ``matrix.dot(vector)`` """ from .dense import Matrix if not isinstance(b, MatrixBase): if is_sequence(b): if len(b) != self.cols and len(b) != self.rows: raise ShapeError( "Dimensions incorrect for dot product: %s, %s" % ( self.shape, len(b))) return self.dot(Matrix(b)) else: raise TypeError( "`b` must be an ordered iterable or Matrix, not %s." % type(b)) mat = self if mat.cols == b.rows: if b.cols != 1: mat = mat.T b = b.T prod = flatten((mat * b).tolist()) return prod if mat.cols == b.cols: return mat.dot(b.T) elif mat.rows == b.rows: return mat.T.dot(b) else: raise ShapeError("Dimensions incorrect for dot product: %s, %s" % ( self.shape, b.shape)) def berkowitz_charpoly(self, x=Dummy('lambda'), simplify=_simplify): return self.charpoly(x=x) def berkowitz_det(self): """Computes determinant using Berkowitz method. See Also ======== det berkowitz """ return self.det(method='berkowitz') def berkowitz_eigenvals(self, **flags): """Computes eigenvalues of a Matrix using Berkowitz method. See Also ======== berkowitz """ return self.eigenvals(**flags) def berkowitz_minors(self): """Computes principal minors using Berkowitz method. See Also ======== berkowitz """ sign, minors = S.One, [] for poly in self.berkowitz(): minors.append(sign * poly[-1]) sign = -sign return tuple(minors) def berkowitz(self): from sympy.matrices import zeros berk = ((1,),) if not self: return berk if not self.is_square: raise NonSquareMatrixError() A, N = self, self.rows transforms = [0] * (N - 1) for n in range(N, 1, -1): T, k = zeros(n + 1, n), n - 1 R, C = -A[k, :k], A[:k, k] A, a = A[:k, :k], -A[k, k] items = [C] for i in range(0, n - 2): items.append(A * items[i]) for i, B in enumerate(items): items[i] = (R * B)[0, 0] items = [S.One, a] + items for i in range(n): T[i:, i] = items[:n - i + 1] transforms[k - 1] = T polys = [self._new([S.One, -A[0, 0]])] for i, T in enumerate(transforms): polys.append(T * polys[i]) return berk + tuple(map(tuple, polys)) def cofactorMatrix(self, method="berkowitz"): return self.cofactor_matrix(method=method) def det_bareis(self): return self.det(method='bareiss') def det_bareiss(self): """Compute matrix determinant using Bareiss' fraction-free algorithm which is an extension of the well known Gaussian elimination method. This approach is best suited for dense symbolic matrices and will result in a determinant with minimal number of fractions. It means that less term rewriting is needed on resulting formulae. TODO: Implement algorithm for sparse matrices (SFF), http://www.eecis.udel.edu/~saunders/papers/sffge/it5.ps. See Also ======== det berkowitz_det """ return self.det(method='bareiss') def det_LU_decomposition(self): """Compute matrix determinant using LU decomposition Note that this method fails if the LU decomposition itself fails. In particular, if the matrix has no inverse this method will fail. TODO: Implement algorithm for sparse matrices (SFF), http://www.eecis.udel.edu/~saunders/papers/sffge/it5.ps. See Also ======== det det_bareiss berkowitz_det """ return self.det(method='lu') def jordan_cell(self, eigenval, n): return self.jordan_block(size=n, eigenvalue=eigenval) def jordan_cells(self, calc_transformation=True): P, J = self.jordan_form() return P, J.get_diag_blocks() def minorEntry(self, i, j, method="berkowitz"): return self.minor(i, j, method=method) def minorMatrix(self, i, j): return self.minor_submatrix(i, j) def permuteBkwd(self, perm): """Permute the rows of the matrix with the given permutation in reverse.""" return self.permute_rows(perm, direction='backward') def permuteFwd(self, perm): """Permute the rows of the matrix with the given permutation.""" return self.permute_rows(perm, direction='forward') class MatrixBase(MatrixDeprecated, MatrixCalculus, MatrixEigen, MatrixCommon): """Base class for matrix objects.""" # Added just for numpy compatibility __array_priority__ = 11 is_Matrix = True _class_priority = 3 _sympify = staticmethod(sympify) __hash__ = None # Mutable # Defined here the same as on Basic. # We don't define _repr_png_ here because it would add a large amount of # data to any notebook containing SymPy expressions, without adding # anything useful to the notebook. It can still enabled manually, e.g., # for the qtconsole, with init_printing(). def _repr_latex_(self): """ IPython/Jupyter LaTeX printing To change the behavior of this (e.g., pass in some settings to LaTeX), use init_printing(). init_printing() will also enable LaTeX printing for built in numeric types like ints and container types that contain SymPy objects, like lists and dictionaries of expressions. """ from sympy.printing.latex import latex s = latex(self, mode='plain') return "$\\displaystyle %s$" % s _repr_latex_orig = _repr_latex_ def __array__(self, dtype=object): from .dense import matrix2numpy return matrix2numpy(self, dtype=dtype) def __getattr__(self, attr): if attr in ('diff', 'integrate', 'limit'): def doit(*args): item_doit = lambda item: getattr(item, attr)(*args) return self.applyfunc(item_doit) return doit else: raise AttributeError( "%s has no attribute %s." % (self.__class__.__name__, attr)) def __len__(self): """Return the number of elements of ``self``. Implemented mainly so bool(Matrix()) == False. """ return self.rows * self.cols def __mathml__(self): mml = "" for i in range(self.rows): mml += "<matrixrow>" for j in range(self.cols): mml += self[i, j].__mathml__() mml += "</matrixrow>" return "<matrix>" + mml + "</matrix>" # needed for python 2 compatibility def __ne__(self, other): return not self == other def _matrix_pow_by_jordan_blocks(self, num): from sympy.matrices import diag, MutableMatrix from sympy import binomial def jordan_cell_power(jc, n): N = jc.shape[0] l = jc[0, 0] if l == 0 and (n < N - 1) != False: raise ValueError("Matrix det == 0; not invertible") elif l == 0 and N > 1 and n % 1 != 0: raise ValueError("Non-integer power cannot be evaluated") for i in range(N): for j in range(N-i): bn = binomial(n, i) if isinstance(bn, binomial): bn = bn._eval_expand_func() jc[j, i+j] = l**(n-i)*bn P, J = self.jordan_form() jordan_cells = J.get_diag_blocks() # Make sure jordan_cells matrices are mutable: jordan_cells = [MutableMatrix(j) for j in jordan_cells] for j in jordan_cells: jordan_cell_power(j, num) return self._new(P*diag(*jordan_cells)*P.inv()) def __repr__(self): return sstr(self) def __str__(self): if self.rows == 0 or self.cols == 0: return 'Matrix(%s, %s, [])' % (self.rows, self.cols) return "Matrix(%s)" % str(self.tolist()) def _diagonalize_clear_subproducts(self): del self._is_symbolic del self._is_symmetric del self._eigenvects def _format_str(self, printer=None): if not printer: from sympy.printing.str import StrPrinter printer = StrPrinter() # Handle zero dimensions: if self.rows == 0 or self.cols == 0: return 'Matrix(%s, %s, [])' % (self.rows, self.cols) if self.rows == 1: return "Matrix([%s])" % self.table(printer, rowsep=',\n') return "Matrix([\n%s])" % self.table(printer, rowsep=',\n') @classmethod def irregular(cls, ntop, *matrices, **kwargs): """Return a matrix filled by the given matrices which are listed in order of appearance from left to right, top to bottom as they first appear in the matrix. They must fill the matrix completely. Examples ======== >>> from sympy import ones, Matrix >>> Matrix.irregular(3, ones(2,1), ones(3,3)*2, ones(2,2)*3, ... ones(1,1)*4, ones(2,2)*5, ones(1,2)*6, ones(1,2)*7) Matrix([ [1, 2, 2, 2, 3, 3], [1, 2, 2, 2, 3, 3], [4, 2, 2, 2, 5, 5], [6, 6, 7, 7, 5, 5]]) """ from sympy.core.compatibility import as_int ntop = as_int(ntop) # make sure we are working with explicit matrices b = [i.as_explicit() if hasattr(i, 'as_explicit') else i for i in matrices] q = list(range(len(b))) dat = [i.rows for i in b] active = [q.pop(0) for _ in range(ntop)] cols = sum([b[i].cols for i in active]) rows = [] while any(dat): r = [] for a, j in enumerate(active): r.extend(b[j][-dat[j], :]) dat[j] -= 1 if dat[j] == 0 and q: active[a] = q.pop(0) if len(r) != cols: raise ValueError(filldedent(''' Matrices provided do not appear to fill the space completely.''')) rows.append(r) return cls._new(rows) @classmethod def _handle_creation_inputs(cls, *args, **kwargs): """Return the number of rows, cols and flat matrix elements. Examples ======== >>> from sympy import Matrix, I Matrix can be constructed as follows: * from a nested list of iterables >>> Matrix( ((1, 2+I), (3, 4)) ) Matrix([ [1, 2 + I], [3, 4]]) * from un-nested iterable (interpreted as a column) >>> Matrix( [1, 2] ) Matrix([ [1], [2]]) * from un-nested iterable with dimensions >>> Matrix(1, 2, [1, 2] ) Matrix([[1, 2]]) * from no arguments (a 0 x 0 matrix) >>> Matrix() Matrix(0, 0, []) * from a rule >>> Matrix(2, 2, lambda i, j: i/(j + 1) ) Matrix([ [0, 0], [1, 1/2]]) See Also ======== irregular - filling a matrix with irregular blocks """ from sympy.matrices.sparse import SparseMatrix from sympy.matrices.expressions.matexpr import MatrixSymbol from sympy.matrices.expressions.blockmatrix import BlockMatrix from sympy.utilities.iterables import reshape flat_list = None if len(args) == 1: # Matrix(SparseMatrix(...)) if isinstance(args[0], SparseMatrix): return args[0].rows, args[0].cols, flatten(args[0].tolist()) # Matrix(Matrix(...)) elif isinstance(args[0], MatrixBase): return args[0].rows, args[0].cols, args[0]._mat # Matrix(MatrixSymbol('X', 2, 2)) elif isinstance(args[0], Basic) and args[0].is_Matrix: return args[0].rows, args[0].cols, args[0].as_explicit()._mat # Matrix(numpy.ones((2, 2))) elif hasattr(args[0], "__array__"): # NumPy array or matrix or some other object that implements # __array__. So let's first use this method to get a # numpy.array() and then make a python list out of it. arr = args[0].__array__() if len(arr.shape) == 2: rows, cols = arr.shape[0], arr.shape[1] flat_list = [cls._sympify(i) for i in arr.ravel()] return rows, cols, flat_list elif len(arr.shape) == 1: rows, cols = arr.shape[0], 1 flat_list = [S.Zero] * rows for i in range(len(arr)): flat_list[i] = cls._sympify(arr[i]) return rows, cols, flat_list else: raise NotImplementedError( "SymPy supports just 1D and 2D matrices") # Matrix([1, 2, 3]) or Matrix([[1, 2], [3, 4]]) elif is_sequence(args[0]) \ and not isinstance(args[0], DeferredVector): dat = list(args[0]) ismat = lambda i: isinstance(i, MatrixBase) and ( evaluate or isinstance(i, BlockMatrix) or isinstance(i, MatrixSymbol)) raw = lambda i: is_sequence(i) and not ismat(i) evaluate = kwargs.get('evaluate', True) if evaluate: def do(x): # make Block and Symbol explicit if isinstance(x, (list, tuple)): return type(x)([do(i) for i in x]) if isinstance(x, BlockMatrix) or \ isinstance(x, MatrixSymbol) and \ all(_.is_Integer for _ in x.shape): return x.as_explicit() return x dat = do(dat) if dat == [] or dat == [[]]: rows = cols = 0 flat_list = [] elif not any(raw(i) or ismat(i) for i in dat): # a column as a list of values flat_list = [cls._sympify(i) for i in dat] rows = len(flat_list) cols = 1 if rows else 0 elif evaluate and all(ismat(i) for i in dat): # a column as a list of matrices ncol = set(i.cols for i in dat if any(i.shape)) if ncol: if len(ncol) != 1: raise ValueError('mismatched dimensions') flat_list = [_ for i in dat for r in i.tolist() for _ in r] cols = ncol.pop() rows = len(flat_list)//cols else: rows = cols = 0 flat_list = [] elif evaluate and any(ismat(i) for i in dat): ncol = set() flat_list = [] for i in dat: if ismat(i): flat_list.extend( [k for j in i.tolist() for k in j]) if any(i.shape): ncol.add(i.cols) elif raw(i): if i: ncol.add(len(i)) flat_list.extend(i) else: ncol.add(1) flat_list.append(i) if len(ncol) > 1: raise ValueError('mismatched dimensions') cols = ncol.pop() rows = len(flat_list)//cols else: # list of lists; each sublist is a logical row # which might consist of many rows if the values in # the row are matrices flat_list = [] ncol = set() rows = cols = 0 for row in dat: if not is_sequence(row) and \ not getattr(row, 'is_Matrix', False): raise ValueError('expecting list of lists') if not row: continue if evaluate and all(ismat(i) for i in row): r, c, flatT = cls._handle_creation_inputs( [i.T for i in row]) T = reshape(flatT, [c]) flat = [T[i][j] for j in range(c) for i in range(r)] r, c = c, r else: r = 1 if getattr(row, 'is_Matrix', False): c = 1 flat = [row] else: c = len(row) flat = [cls._sympify(i) for i in row] ncol.add(c) if len(ncol) > 1: raise ValueError('mismatched dimensions') flat_list.extend(flat) rows += r cols = ncol.pop() if ncol else 0 elif len(args) == 3: rows = as_int(args[0]) cols = as_int(args[1]) if rows < 0 or cols < 0: raise ValueError("Cannot create a {} x {} matrix. " "Both dimensions must be positive".format(rows, cols)) # Matrix(2, 2, lambda i, j: i+j) if len(args) == 3 and isinstance(args[2], Callable): op = args[2] flat_list = [] for i in range(rows): flat_list.extend( [cls._sympify(op(cls._sympify(i), cls._sympify(j))) for j in range(cols)]) # Matrix(2, 2, [1, 2, 3, 4]) elif len(args) == 3 and is_sequence(args[2]): flat_list = args[2] if len(flat_list) != rows * cols: raise ValueError( 'List length should be equal to rows*columns') flat_list = [cls._sympify(i) for i in flat_list] # Matrix() elif len(args) == 0: # Empty Matrix rows = cols = 0 flat_list = [] if flat_list is None: raise TypeError(filldedent(''' Data type not understood; expecting list of lists or lists of values.''')) return rows, cols, flat_list def _setitem(self, key, value): """Helper to set value at location given by key. Examples ======== >>> from sympy import Matrix, I, zeros, ones >>> m = Matrix(((1, 2+I), (3, 4))) >>> m Matrix([ [1, 2 + I], [3, 4]]) >>> m[1, 0] = 9 >>> m Matrix([ [1, 2 + I], [9, 4]]) >>> m[1, 0] = [[0, 1]] To replace row r you assign to position r*m where m is the number of columns: >>> M = zeros(4) >>> m = M.cols >>> M[3*m] = ones(1, m)*2; M Matrix([ [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [2, 2, 2, 2]]) And to replace column c you can assign to position c: >>> M[2] = ones(m, 1)*4; M Matrix([ [0, 0, 4, 0], [0, 0, 4, 0], [0, 0, 4, 0], [2, 2, 4, 2]]) """ from .dense import Matrix is_slice = isinstance(key, slice) i, j = key = self.key2ij(key) is_mat = isinstance(value, MatrixBase) if type(i) is slice or type(j) is slice: if is_mat: self.copyin_matrix(key, value) return if not isinstance(value, Expr) and is_sequence(value): self.copyin_list(key, value) return raise ValueError('unexpected value: %s' % value) else: if (not is_mat and not isinstance(value, Basic) and is_sequence(value)): value = Matrix(value) is_mat = True if is_mat: if is_slice: key = (slice(*divmod(i, self.cols)), slice(*divmod(j, self.cols))) else: key = (slice(i, i + value.rows), slice(j, j + value.cols)) self.copyin_matrix(key, value) else: return i, j, self._sympify(value) return def add(self, b): """Return self + b """ return self + b def cholesky_solve(self, rhs): """Solves ``Ax = B`` using Cholesky decomposition, for a general square non-singular matrix. For a non-square matrix with rows > cols, the least squares solution is returned. See Also ======== lower_triangular_solve upper_triangular_solve gauss_jordan_solve diagonal_solve LDLsolve LUsolve QRsolve pinv_solve """ hermitian = True if self.is_symmetric(): hermitian = False L = self._cholesky(hermitian=hermitian) elif self.is_hermitian: L = self._cholesky(hermitian=hermitian) elif self.rows >= self.cols: L = (self.H * self)._cholesky(hermitian=hermitian) rhs = self.H * rhs else: raise NotImplementedError('Under-determined System. ' 'Try M.gauss_jordan_solve(rhs)') Y = L._lower_triangular_solve(rhs) if hermitian: return (L.H)._upper_triangular_solve(Y) else: return (L.T)._upper_triangular_solve(Y) def cholesky(self, hermitian=True): """Returns the Cholesky-type decomposition L of a matrix A such that L * L.H == A if hermitian flag is True, or L * L.T == A if hermitian is False. A must be a Hermitian positive-definite matrix if hermitian is True, or a symmetric matrix if it is False. Examples ======== >>> from sympy.matrices import Matrix >>> A = Matrix(((25, 15, -5), (15, 18, 0), (-5, 0, 11))) >>> A.cholesky() Matrix([ [ 5, 0, 0], [ 3, 3, 0], [-1, 1, 3]]) >>> A.cholesky() * A.cholesky().T Matrix([ [25, 15, -5], [15, 18, 0], [-5, 0, 11]]) The matrix can have complex entries: >>> from sympy import I >>> A = Matrix(((9, 3*I), (-3*I, 5))) >>> A.cholesky() Matrix([ [ 3, 0], [-I, 2]]) >>> A.cholesky() * A.cholesky().H Matrix([ [ 9, 3*I], [-3*I, 5]]) Non-hermitian Cholesky-type decomposition may be useful when the matrix is not positive-definite. >>> A = Matrix([[1, 2], [2, 1]]) >>> L = A.cholesky(hermitian=False) >>> L Matrix([ [1, 0], [2, sqrt(3)*I]]) >>> L*L.T == A True See Also ======== LDLdecomposition LUdecomposition QRdecomposition """ if not self.is_square: raise NonSquareMatrixError("Matrix must be square.") if hermitian and not self.is_hermitian: raise ValueError("Matrix must be Hermitian.") if not hermitian and not self.is_symmetric(): raise ValueError("Matrix must be symmetric.") return self._cholesky(hermitian=hermitian) def condition_number(self): """Returns the condition number of a matrix. This is the maximum singular value divided by the minimum singular value Examples ======== >>> from sympy import Matrix, S >>> A = Matrix([[1, 0, 0], [0, 10, 0], [0, 0, S.One/10]]) >>> A.condition_number() 100 See Also ======== singular_values """ if not self: return S.Zero singularvalues = self.singular_values() return Max(*singularvalues) / Min(*singularvalues) def copy(self): """ Returns the copy of a matrix. Examples ======== >>> from sympy import Matrix >>> A = Matrix(2, 2, [1, 2, 3, 4]) >>> A.copy() Matrix([ [1, 2], [3, 4]]) """ return self._new(self.rows, self.cols, self._mat) def cross(self, b): r""" Return the cross product of ``self`` and ``b`` relaxing the condition of compatible dimensions: if each has 3 elements, a matrix of the same type and shape as ``self`` will be returned. If ``b`` has the same shape as ``self`` then common identities for the cross product (like `a \times b = - b \times a`) will hold. Parameters ========== b : 3x1 or 1x3 Matrix See Also ======== dot multiply multiply_elementwise """ if not is_sequence(b): raise TypeError( "`b` must be an ordered iterable or Matrix, not %s." % type(b)) if not (self.rows * self.cols == b.rows * b.cols == 3): raise ShapeError("Dimensions incorrect for cross product: %s x %s" % ((self.rows, self.cols), (b.rows, b.cols))) else: return self._new(self.rows, self.cols, ( (self[1] * b[2] - self[2] * b[1]), (self[2] * b[0] - self[0] * b[2]), (self[0] * b[1] - self[1] * b[0]))) @property def D(self): """Return Dirac conjugate (if ``self.rows == 4``). Examples ======== >>> from sympy import Matrix, I, eye >>> m = Matrix((0, 1 + I, 2, 3)) >>> m.D Matrix([[0, 1 - I, -2, -3]]) >>> m = (eye(4) + I*eye(4)) >>> m[0, 3] = 2 >>> m.D Matrix([ [1 - I, 0, 0, 0], [ 0, 1 - I, 0, 0], [ 0, 0, -1 + I, 0], [ 2, 0, 0, -1 + I]]) If the matrix does not have 4 rows an AttributeError will be raised because this property is only defined for matrices with 4 rows. >>> Matrix(eye(2)).D Traceback (most recent call last): ... AttributeError: Matrix has no attribute D. See Also ======== conjugate: By-element conjugation H: Hermite conjugation """ from sympy.physics.matrices import mgamma if self.rows != 4: # In Python 3.2, properties can only return an AttributeError # so we can't raise a ShapeError -- see commit which added the # first line of this inline comment. Also, there is no need # for a message since MatrixBase will raise the AttributeError raise AttributeError return self.H * mgamma(0) def diagonal_solve(self, rhs): """Solves ``Ax = B`` efficiently, where A is a diagonal Matrix, with non-zero diagonal entries. Examples ======== >>> from sympy.matrices import Matrix, eye >>> A = eye(2)*2 >>> B = Matrix([[1, 2], [3, 4]]) >>> A.diagonal_solve(B) == B/2 True See Also ======== lower_triangular_solve upper_triangular_solve gauss_jordan_solve cholesky_solve LDLsolve LUsolve QRsolve pinv_solve """ if not self.is_diagonal(): raise TypeError("Matrix should be diagonal") if rhs.rows != self.rows: raise TypeError("Size mis-match") return self._diagonal_solve(rhs) def dot(self, b, hermitian=None, conjugate_convention=None): """Return the dot or inner product of two vectors of equal length. Here ``self`` must be a ``Matrix`` of size 1 x n or n x 1, and ``b`` must be either a matrix of size 1 x n, n x 1, or a list/tuple of length n. A scalar is returned. By default, ``dot`` does not conjugate ``self`` or ``b``, even if there are complex entries. Set ``hermitian=True`` (and optionally a ``conjugate_convention``) to compute the hermitian inner product. Possible kwargs are ``hermitian`` and ``conjugate_convention``. If ``conjugate_convention`` is ``"left"``, ``"math"`` or ``"maths"``, the conjugate of the first vector (``self``) is used. If ``"right"`` or ``"physics"`` is specified, the conjugate of the second vector ``b`` is used. Examples ======== >>> from sympy import Matrix >>> M = Matrix([[1, 2, 3], [4, 5, 6], [7, 8, 9]]) >>> v = Matrix([1, 1, 1]) >>> M.row(0).dot(v) 6 >>> M.col(0).dot(v) 12 >>> v = [3, 2, 1] >>> M.row(0).dot(v) 10 >>> from sympy import I >>> q = Matrix([1*I, 1*I, 1*I]) >>> q.dot(q, hermitian=False) -3 >>> q.dot(q, hermitian=True) 3 >>> q1 = Matrix([1, 1, 1*I]) >>> q.dot(q1, hermitian=True, conjugate_convention="maths") 1 - 2*I >>> q.dot(q1, hermitian=True, conjugate_convention="physics") 1 + 2*I See Also ======== cross multiply multiply_elementwise """ from .dense import Matrix if not isinstance(b, MatrixBase): if is_sequence(b): if len(b) != self.cols and len(b) != self.rows: raise ShapeError( "Dimensions incorrect for dot product: %s, %s" % ( self.shape, len(b))) return self.dot(Matrix(b)) else: raise TypeError( "`b` must be an ordered iterable or Matrix, not %s." % type(b)) mat = self if (1 not in mat.shape) or (1 not in b.shape) : SymPyDeprecationWarning( feature="Dot product of non row/column vectors", issue=13815, deprecated_since_version="1.2", useinstead="* to take matrix products").warn() return mat._legacy_array_dot(b) if len(mat) != len(b): raise ShapeError("Dimensions incorrect for dot product: %s, %s" % (self.shape, b.shape)) n = len(mat) if mat.shape != (1, n): mat = mat.reshape(1, n) if b.shape != (n, 1): b = b.reshape(n, 1) # Now ``mat`` is a row vector and ``b`` is a column vector. # If it so happens that only conjugate_convention is passed # then automatically set hermitian to True. If only hermitian # is true but no conjugate_convention is not passed then # automatically set it to ``"maths"`` if conjugate_convention is not None and hermitian is None: hermitian = True if hermitian and conjugate_convention is None: conjugate_convention = "maths" if hermitian == True: if conjugate_convention in ("maths", "left", "math"): mat = mat.conjugate() elif conjugate_convention in ("physics", "right"): b = b.conjugate() else: raise ValueError("Unknown conjugate_convention was entered." " conjugate_convention must be one of the" " following: math, maths, left, physics or right.") return (mat * b)[0] def dual(self): """Returns the dual of a matrix, which is: ``(1/2)*levicivita(i, j, k, l)*M(k, l)`` summed over indices `k` and `l` Since the levicivita method is anti_symmetric for any pairwise exchange of indices, the dual of a symmetric matrix is the zero matrix. Strictly speaking the dual defined here assumes that the 'matrix' `M` is a contravariant anti_symmetric second rank tensor, so that the dual is a covariant second rank tensor. """ from sympy import LeviCivita from sympy.matrices import zeros M, n = self[:, :], self.rows work = zeros(n) if self.is_symmetric(): return work for i in range(1, n): for j in range(1, n): acum = 0 for k in range(1, n): acum += LeviCivita(i, j, 0, k) * M[0, k] work[i, j] = acum work[j, i] = -acum for l in range(1, n): acum = 0 for a in range(1, n): for b in range(1, n): acum += LeviCivita(0, l, a, b) * M[a, b] acum /= 2 work[0, l] = -acum work[l, 0] = acum return work def exp(self): """Return the exponentiation of a square matrix.""" if not self.is_square: raise NonSquareMatrixError( "Exponentiation is valid only for square matrices") try: P, J = self.jordan_form() cells = J.get_diag_blocks() except MatrixError: raise NotImplementedError( "Exponentiation is implemented only for matrices for which the Jordan normal form can be computed") def _jblock_exponential(b): # This function computes the matrix exponential for one single Jordan block nr = b.rows l = b[0, 0] if nr == 1: res = exp(l) else: from sympy import eye # extract the diagonal part d = b[0, 0] * eye(nr) # and the nilpotent part n = b - d # compute its exponential nex = eye(nr) for i in range(1, nr): nex = nex + n ** i / factorial(i) # combine the two parts res = exp(b[0, 0]) * nex return (res) blocks = list(map(_jblock_exponential, cells)) from sympy.matrices import diag from sympy import re eJ = diag(*blocks) # n = self.rows ret = P * eJ * P.inv() if all(value.is_real for value in self.values()): return type(self)(re(ret)) else: return type(self)(ret) def gauss_jordan_solve(self, B, freevar=False): """ Solves ``Ax = B`` using Gauss Jordan elimination. There may be zero, one, or infinite solutions. If one solution exists, it will be returned. If infinite solutions exist, it will be returned parametrically. If no solutions exist, It will throw ValueError. Parameters ========== B : Matrix The right hand side of the equation to be solved for. Must have the same number of rows as matrix A. freevar : List If the system is underdetermined (e.g. A has more columns than rows), infinite solutions are possible, in terms of arbitrary values of free variables. Then the index of the free variables in the solutions (column Matrix) will be returned by freevar, if the flag `freevar` is set to `True`. Returns ======= x : Matrix The matrix that will satisfy ``Ax = B``. Will have as many rows as matrix A has columns, and as many columns as matrix B. params : Matrix If the system is underdetermined (e.g. A has more columns than rows), infinite solutions are possible, in terms of arbitrary parameters. These arbitrary parameters are returned as params Matrix. Examples ======== >>> from sympy import Matrix >>> A = Matrix([[1, 2, 1, 1], [1, 2, 2, -1], [2, 4, 0, 6]]) >>> B = Matrix([7, 12, 4]) >>> sol, params = A.gauss_jordan_solve(B) >>> sol Matrix([ [-2*tau0 - 3*tau1 + 2], [ tau0], [ 2*tau1 + 5], [ tau1]]) >>> params Matrix([ [tau0], [tau1]]) >>> taus_zeroes = { tau:0 for tau in params } >>> sol_unique = sol.xreplace(taus_zeroes) >>> sol_unique Matrix([ [2], [0], [5], [0]]) >>> A = Matrix([[1, 2, 3], [4, 5, 6], [7, 8, 10]]) >>> B = Matrix([3, 6, 9]) >>> sol, params = A.gauss_jordan_solve(B) >>> sol Matrix([ [-1], [ 2], [ 0]]) >>> params Matrix(0, 1, []) >>> A = Matrix([[2, -7], [-1, 4]]) >>> B = Matrix([[-21, 3], [12, -2]]) >>> sol, params = A.gauss_jordan_solve(B) >>> sol Matrix([ [0, -2], [3, -1]]) >>> params Matrix(0, 2, []) See Also ======== lower_triangular_solve upper_triangular_solve cholesky_solve diagonal_solve LDLsolve LUsolve QRsolve pinv References ========== .. [1] https://en.wikipedia.org/wiki/Gaussian_elimination """ from sympy.matrices import Matrix, zeros aug = self.hstack(self.copy(), B.copy()) B_cols = B.cols row, col = aug[:, :-B_cols].shape # solve by reduced row echelon form A, pivots = aug.rref(simplify=True) A, v = A[:, :-B_cols], A[:, -B_cols:] pivots = list(filter(lambda p: p < col, pivots)) rank = len(pivots) # Bring to block form permutation = Matrix(range(col)).T for i, c in enumerate(pivots): permutation.col_swap(i, c) # check for existence of solutions # rank of aug Matrix should be equal to rank of coefficient matrix if not v[rank:, :].is_zero: raise ValueError("Linear system has no solution") # Get index of free symbols (free parameters) free_var_index = permutation[ len(pivots):] # non-pivots columns are free variables # Free parameters # what are current unnumbered free symbol names? name = _uniquely_named_symbol('tau', aug, compare=lambda i: str(i).rstrip('1234567890')).name gen = numbered_symbols(name) tau = Matrix([next(gen) for k in range((col - rank)*B_cols)]).reshape( col - rank, B_cols) # Full parametric solution V = A[:rank,:] for c in reversed(pivots): V.col_del(c) vt = v[:rank, :] free_sol = tau.vstack(vt - V * tau, tau) # Undo permutation sol = zeros(col, B_cols) for k in range(col): sol[permutation[k], :] = free_sol[k,:] if freevar: return sol, tau, free_var_index else: return sol, tau def inv_mod(self, m): r""" Returns the inverse of the matrix `K` (mod `m`), if it exists. Method to find the matrix inverse of `K` (mod `m`) implemented in this function: * Compute `\mathrm{adj}(K) = \mathrm{cof}(K)^t`, the adjoint matrix of `K`. * Compute `r = 1/\mathrm{det}(K) \pmod m`. * `K^{-1} = r\cdot \mathrm{adj}(K) \pmod m`. Examples ======== >>> from sympy import Matrix >>> A = Matrix(2, 2, [1, 2, 3, 4]) >>> A.inv_mod(5) Matrix([ [3, 1], [4, 2]]) >>> A.inv_mod(3) Matrix([ [1, 1], [0, 1]]) """ if not self.is_square: raise NonSquareMatrixError() N = self.cols det_K = self.det() det_inv = None try: det_inv = mod_inverse(det_K, m) except ValueError: raise ValueError('Matrix is not invertible (mod %d)' % m) K_adj = self.adjugate() K_inv = self.__class__(N, N, [det_inv * K_adj[i, j] % m for i in range(N) for j in range(N)]) return K_inv def inverse_ADJ(self, iszerofunc=_iszero): """Calculates the inverse using the adjugate matrix and a determinant. See Also ======== inv inverse_LU inverse_GE """ if not self.is_square: raise NonSquareMatrixError("A Matrix must be square to invert.") d = self.det(method='berkowitz') zero = d.equals(0) if zero is None: # if equals() can't decide, will rref be able to? ok = self.rref(simplify=True)[0] zero = any(iszerofunc(ok[j, j]) for j in range(ok.rows)) if zero: raise ValueError("Matrix det == 0; not invertible.") return self.adjugate() / d def inverse_GE(self, iszerofunc=_iszero): """Calculates the inverse using Gaussian elimination. See Also ======== inv inverse_LU inverse_ADJ """ from .dense import Matrix if not self.is_square: raise NonSquareMatrixError("A Matrix must be square to invert.") big = Matrix.hstack(self.as_mutable(), Matrix.eye(self.rows)) red = big.rref(iszerofunc=iszerofunc, simplify=True)[0] if any(iszerofunc(red[j, j]) for j in range(red.rows)): raise ValueError("Matrix det == 0; not invertible.") return self._new(red[:, big.rows:]) def inverse_LU(self, iszerofunc=_iszero): """Calculates the inverse using LU decomposition. See Also ======== inv inverse_GE inverse_ADJ """ if not self.is_square: raise NonSquareMatrixError() ok = self.rref(simplify=True)[0] if any(iszerofunc(ok[j, j]) for j in range(ok.rows)): raise ValueError("Matrix det == 0; not invertible.") return self.LUsolve(self.eye(self.rows), iszerofunc=_iszero) def inv(self, method=None, **kwargs): """ Return the inverse of a matrix. CASE 1: If the matrix is a dense matrix. Return the matrix inverse using the method indicated (default is Gauss elimination). Parameters ========== method : ('GE', 'LU', or 'ADJ') Notes ===== According to the ``method`` keyword, it calls the appropriate method: GE .... inverse_GE(); default LU .... inverse_LU() ADJ ... inverse_ADJ() See Also ======== inverse_LU inverse_GE inverse_ADJ Raises ------ ValueError If the determinant of the matrix is zero. CASE 2: If the matrix is a sparse matrix. Return the matrix inverse using Cholesky or LDL (default). kwargs ====== method : ('CH', 'LDL') Notes ===== According to the ``method`` keyword, it calls the appropriate method: LDL ... inverse_LDL(); default CH .... inverse_CH() Raises ------ ValueError If the determinant of the matrix is zero. """ if not self.is_square: raise NonSquareMatrixError() if method is not None: kwargs['method'] = method return self._eval_inverse(**kwargs) def is_nilpotent(self): """Checks if a matrix is nilpotent. A matrix B is nilpotent if for some integer k, B**k is a zero matrix. Examples ======== >>> from sympy import Matrix >>> a = Matrix([[0, 0, 0], [1, 0, 0], [1, 1, 0]]) >>> a.is_nilpotent() True >>> a = Matrix([[1, 0, 1], [1, 0, 0], [1, 1, 0]]) >>> a.is_nilpotent() False """ if not self: return True if not self.is_square: raise NonSquareMatrixError( "Nilpotency is valid only for square matrices") x = _uniquely_named_symbol('x', self) p = self.charpoly(x) if p.args[0] == x ** self.rows: return True return False def key2bounds(self, keys): """Converts a key with potentially mixed types of keys (integer and slice) into a tuple of ranges and raises an error if any index is out of ``self``'s range. See Also ======== key2ij """ from sympy.matrices.common import a2idx as a2idx_ # Remove this line after deprecation of a2idx from matrices.py islice, jslice = [isinstance(k, slice) for k in keys] if islice: if not self.rows: rlo = rhi = 0 else: rlo, rhi = keys[0].indices(self.rows)[:2] else: rlo = a2idx_(keys[0], self.rows) rhi = rlo + 1 if jslice: if not self.cols: clo = chi = 0 else: clo, chi = keys[1].indices(self.cols)[:2] else: clo = a2idx_(keys[1], self.cols) chi = clo + 1 return rlo, rhi, clo, chi def key2ij(self, key): """Converts key into canonical form, converting integers or indexable items into valid integers for ``self``'s range or returning slices unchanged. See Also ======== key2bounds """ from sympy.matrices.common import a2idx as a2idx_ # Remove this line after deprecation of a2idx from matrices.py if is_sequence(key): if not len(key) == 2: raise TypeError('key must be a sequence of length 2') return [a2idx_(i, n) if not isinstance(i, slice) else i for i, n in zip(key, self.shape)] elif isinstance(key, slice): return key.indices(len(self))[:2] else: return divmod(a2idx_(key, len(self)), self.cols) def LDLdecomposition(self, hermitian=True): """Returns the LDL Decomposition (L, D) of matrix A, such that L * D * L.H == A if hermitian flag is True, or L * D * L.T == A if hermitian is False. This method eliminates the use of square root. Further this ensures that all the diagonal entries of L are 1. A must be a Hermitian positive-definite matrix if hermitian is True, or a symmetric matrix otherwise. Examples ======== >>> from sympy.matrices import Matrix, eye >>> A = Matrix(((25, 15, -5), (15, 18, 0), (-5, 0, 11))) >>> L, D = A.LDLdecomposition() >>> L Matrix([ [ 1, 0, 0], [ 3/5, 1, 0], [-1/5, 1/3, 1]]) >>> D Matrix([ [25, 0, 0], [ 0, 9, 0], [ 0, 0, 9]]) >>> L * D * L.T * A.inv() == eye(A.rows) True The matrix can have complex entries: >>> from sympy import I >>> A = Matrix(((9, 3*I), (-3*I, 5))) >>> L, D = A.LDLdecomposition() >>> L Matrix([ [ 1, 0], [-I/3, 1]]) >>> D Matrix([ [9, 0], [0, 4]]) >>> L*D*L.H == A True See Also ======== cholesky LUdecomposition QRdecomposition """ if not self.is_square: raise NonSquareMatrixError("Matrix must be square.") if hermitian and not self.is_hermitian: raise ValueError("Matrix must be Hermitian.") if not hermitian and not self.is_symmetric(): raise ValueError("Matrix must be symmetric.") return self._LDLdecomposition(hermitian=hermitian) def LDLsolve(self, rhs): """Solves ``Ax = B`` using LDL decomposition, for a general square and non-singular matrix. For a non-square matrix with rows > cols, the least squares solution is returned. Examples ======== >>> from sympy.matrices import Matrix, eye >>> A = eye(2)*2 >>> B = Matrix([[1, 2], [3, 4]]) >>> A.LDLsolve(B) == B/2 True See Also ======== LDLdecomposition lower_triangular_solve upper_triangular_solve gauss_jordan_solve cholesky_solve diagonal_solve LUsolve QRsolve pinv_solve """ hermitian = True if self.is_symmetric(): hermitian = False L, D = self.LDLdecomposition(hermitian=hermitian) elif self.is_hermitian: L, D = self.LDLdecomposition(hermitian=hermitian) elif self.rows >= self.cols: L, D = (self.H * self).LDLdecomposition(hermitian=hermitian) rhs = self.H * rhs else: raise NotImplementedError('Under-determined System. ' 'Try M.gauss_jordan_solve(rhs)') Y = L._lower_triangular_solve(rhs) Z = D._diagonal_solve(Y) if hermitian: return (L.H)._upper_triangular_solve(Z) else: return (L.T)._upper_triangular_solve(Z) def lower_triangular_solve(self, rhs): """Solves ``Ax = B``, where A is a lower triangular matrix. See Also ======== upper_triangular_solve gauss_jordan_solve cholesky_solve diagonal_solve LDLsolve LUsolve QRsolve pinv_solve """ if not self.is_square: raise NonSquareMatrixError("Matrix must be square.") if rhs.rows != self.rows: raise ShapeError("Matrices size mismatch.") if not self.is_lower: raise ValueError("Matrix must be lower triangular.") return self._lower_triangular_solve(rhs) def LUdecomposition(self, iszerofunc=_iszero, simpfunc=None, rankcheck=False): """Returns (L, U, perm) where L is a lower triangular matrix with unit diagonal, U is an upper triangular matrix, and perm is a list of row swap index pairs. If A is the original matrix, then A = (L*U).permuteBkwd(perm), and the row permutation matrix P such that P*A = L*U can be computed by P=eye(A.row).permuteFwd(perm). See documentation for LUCombined for details about the keyword argument rankcheck, iszerofunc, and simpfunc. Examples ======== >>> from sympy import Matrix >>> a = Matrix([[4, 3], [6, 3]]) >>> L, U, _ = a.LUdecomposition() >>> L Matrix([ [ 1, 0], [3/2, 1]]) >>> U Matrix([ [4, 3], [0, -3/2]]) See Also ======== cholesky LDLdecomposition QRdecomposition LUdecomposition_Simple LUdecompositionFF LUsolve """ combined, p = self.LUdecomposition_Simple(iszerofunc=iszerofunc, simpfunc=simpfunc, rankcheck=rankcheck) # L is lower triangular ``self.rows x self.rows`` # U is upper triangular ``self.rows x self.cols`` # L has unit diagonal. For each column in combined, the subcolumn # below the diagonal of combined is shared by L. # If L has more columns than combined, then the remaining subcolumns # below the diagonal of L are zero. # The upper triangular portion of L and combined are equal. def entry_L(i, j): if i < j: # Super diagonal entry return S.Zero elif i == j: return S.One elif j < combined.cols: return combined[i, j] # Subdiagonal entry of L with no corresponding # entry in combined return S.Zero def entry_U(i, j): return S.Zero if i > j else combined[i, j] L = self._new(combined.rows, combined.rows, entry_L) U = self._new(combined.rows, combined.cols, entry_U) return L, U, p def LUdecomposition_Simple(self, iszerofunc=_iszero, simpfunc=None, rankcheck=False): """Compute an lu decomposition of m x n matrix A, where P*A = L*U * L is m x m lower triangular with unit diagonal * U is m x n upper triangular * P is an m x m permutation matrix Returns an m x n matrix lu, and an m element list perm where each element of perm is a pair of row exchange indices. The factors L and U are stored in lu as follows: The subdiagonal elements of L are stored in the subdiagonal elements of lu, that is lu[i, j] = L[i, j] whenever i > j. The elements on the diagonal of L are all 1, and are not explicitly stored. U is stored in the upper triangular portion of lu, that is lu[i ,j] = U[i, j] whenever i <= j. The output matrix can be visualized as: Matrix([ [u, u, u, u], [l, u, u, u], [l, l, u, u], [l, l, l, u]]) where l represents a subdiagonal entry of the L factor, and u represents an entry from the upper triangular entry of the U factor. perm is a list row swap index pairs such that if A is the original matrix, then A = (L*U).permuteBkwd(perm), and the row permutation matrix P such that ``P*A = L*U`` can be computed by ``P=eye(A.row).permuteFwd(perm)``. The keyword argument rankcheck determines if this function raises a ValueError when passed a matrix whose rank is strictly less than min(num rows, num cols). The default behavior is to decompose a rank deficient matrix. Pass rankcheck=True to raise a ValueError instead. (This mimics the previous behavior of this function). The keyword arguments iszerofunc and simpfunc are used by the pivot search algorithm. iszerofunc is a callable that returns a boolean indicating if its input is zero, or None if it cannot make the determination. simpfunc is a callable that simplifies its input. The default is simpfunc=None, which indicate that the pivot search algorithm should not attempt to simplify any candidate pivots. If simpfunc fails to simplify its input, then it must return its input instead of a copy. When a matrix contains symbolic entries, the pivot search algorithm differs from the case where every entry can be categorized as zero or nonzero. The algorithm searches column by column through the submatrix whose top left entry coincides with the pivot position. If it exists, the pivot is the first entry in the current search column that iszerofunc guarantees is nonzero. If no such candidate exists, then each candidate pivot is simplified if simpfunc is not None. The search is repeated, with the difference that a candidate may be the pivot if ``iszerofunc()`` cannot guarantee that it is nonzero. In the second search the pivot is the first candidate that iszerofunc can guarantee is nonzero. If no such candidate exists, then the pivot is the first candidate for which iszerofunc returns None. If no such candidate exists, then the search is repeated in the next column to the right. The pivot search algorithm differs from the one in ``rref()``, which relies on ``_find_reasonable_pivot()``. Future versions of ``LUdecomposition_simple()`` may use ``_find_reasonable_pivot()``. See Also ======== LUdecomposition LUdecompositionFF LUsolve """ if rankcheck: # https://github.com/sympy/sympy/issues/9796 pass if self.rows == 0 or self.cols == 0: # Define LU decomposition of a matrix with no entries as a matrix # of the same dimensions with all zero entries. return self.zeros(self.rows, self.cols), [] lu = self.as_mutable() row_swaps = [] pivot_col = 0 for pivot_row in range(0, lu.rows - 1): # Search for pivot. Prefer entry that iszeropivot determines # is nonzero, over entry that iszeropivot cannot guarantee # is zero. # XXX ``_find_reasonable_pivot`` uses slow zero testing. Blocked by bug #10279 # Future versions of LUdecomposition_simple can pass iszerofunc and simpfunc # to _find_reasonable_pivot(). # In pass 3 of _find_reasonable_pivot(), the predicate in ``if x.equals(S.Zero):`` # calls sympy.simplify(), and not the simplification function passed in via # the keyword argument simpfunc. iszeropivot = True while pivot_col != self.cols and iszeropivot: sub_col = (lu[r, pivot_col] for r in range(pivot_row, self.rows)) pivot_row_offset, pivot_value, is_assumed_non_zero, ind_simplified_pairs =\ _find_reasonable_pivot_naive(sub_col, iszerofunc, simpfunc) iszeropivot = pivot_value is None if iszeropivot: # All candidate pivots in this column are zero. # Proceed to next column. pivot_col += 1 if rankcheck and pivot_col != pivot_row: # All entries including and below the pivot position are # zero, which indicates that the rank of the matrix is # strictly less than min(num rows, num cols) # Mimic behavior of previous implementation, by throwing a # ValueError. raise ValueError("Rank of matrix is strictly less than" " number of rows or columns." " Pass keyword argument" " rankcheck=False to compute" " the LU decomposition of this matrix.") candidate_pivot_row = None if pivot_row_offset is None else pivot_row + pivot_row_offset if candidate_pivot_row is None and iszeropivot: # If candidate_pivot_row is None and iszeropivot is True # after pivot search has completed, then the submatrix # below and to the right of (pivot_row, pivot_col) is # all zeros, indicating that Gaussian elimination is # complete. return lu, row_swaps # Update entries simplified during pivot search. for offset, val in ind_simplified_pairs: lu[pivot_row + offset, pivot_col] = val if pivot_row != candidate_pivot_row: # Row swap book keeping: # Record which rows were swapped. # Update stored portion of L factor by multiplying L on the # left and right with the current permutation. # Swap rows of U. row_swaps.append([pivot_row, candidate_pivot_row]) # Update L. lu[pivot_row, 0:pivot_row], lu[candidate_pivot_row, 0:pivot_row] = \ lu[candidate_pivot_row, 0:pivot_row], lu[pivot_row, 0:pivot_row] # Swap pivot row of U with candidate pivot row. lu[pivot_row, pivot_col:lu.cols], lu[candidate_pivot_row, pivot_col:lu.cols] = \ lu[candidate_pivot_row, pivot_col:lu.cols], lu[pivot_row, pivot_col:lu.cols] # Introduce zeros below the pivot by adding a multiple of the # pivot row to a row under it, and store the result in the # row under it. # Only entries in the target row whose index is greater than # start_col may be nonzero. start_col = pivot_col + 1 for row in range(pivot_row + 1, lu.rows): # Store factors of L in the subcolumn below # (pivot_row, pivot_row). lu[row, pivot_row] =\ lu[row, pivot_col]/lu[pivot_row, pivot_col] # Form the linear combination of the pivot row and the current # row below the pivot row that zeros the entries below the pivot. # Employing slicing instead of a loop here raises # NotImplementedError: Cannot add Zero to MutableSparseMatrix # in sympy/matrices/tests/test_sparse.py. # c = pivot_row + 1 if pivot_row == pivot_col else pivot_col for c in range(start_col, lu.cols): lu[row, c] = lu[row, c] - lu[row, pivot_row]*lu[pivot_row, c] if pivot_row != pivot_col: # matrix rank < min(num rows, num cols), # so factors of L are not stored directly below the pivot. # These entries are zero by construction, so don't bother # computing them. for row in range(pivot_row + 1, lu.rows): lu[row, pivot_col] = S.Zero pivot_col += 1 if pivot_col == lu.cols: # All candidate pivots are zero implies that Gaussian # elimination is complete. return lu, row_swaps if rankcheck: if iszerofunc( lu[Min(lu.rows, lu.cols) - 1, Min(lu.rows, lu.cols) - 1]): raise ValueError("Rank of matrix is strictly less than" " number of rows or columns." " Pass keyword argument" " rankcheck=False to compute" " the LU decomposition of this matrix.") return lu, row_swaps def LUdecompositionFF(self): """Compute a fraction-free LU decomposition. Returns 4 matrices P, L, D, U such that PA = L D**-1 U. If the elements of the matrix belong to some integral domain I, then all elements of L, D and U are guaranteed to belong to I. **Reference** - W. Zhou & D.J. Jeffrey, "Fraction-free matrix factors: new forms for LU and QR factors". Frontiers in Computer Science in China, Vol 2, no. 1, pp. 67-80, 2008. See Also ======== LUdecomposition LUdecomposition_Simple LUsolve """ from sympy.matrices import SparseMatrix zeros = SparseMatrix.zeros eye = SparseMatrix.eye n, m = self.rows, self.cols U, L, P = self.as_mutable(), eye(n), eye(n) DD = zeros(n, n) oldpivot = 1 for k in range(n - 1): if U[k, k] == 0: for kpivot in range(k + 1, n): if U[kpivot, k]: break else: raise ValueError("Matrix is not full rank") U[k, k:], U[kpivot, k:] = U[kpivot, k:], U[k, k:] L[k, :k], L[kpivot, :k] = L[kpivot, :k], L[k, :k] P[k, :], P[kpivot, :] = P[kpivot, :], P[k, :] L[k, k] = Ukk = U[k, k] DD[k, k] = oldpivot * Ukk for i in range(k + 1, n): L[i, k] = Uik = U[i, k] for j in range(k + 1, m): U[i, j] = (Ukk * U[i, j] - U[k, j] * Uik) / oldpivot U[i, k] = 0 oldpivot = Ukk DD[n - 1, n - 1] = oldpivot return P, L, DD, U def LUsolve(self, rhs, iszerofunc=_iszero): """Solve the linear system ``Ax = rhs`` for ``x`` where ``A = self``. This is for symbolic matrices, for real or complex ones use mpmath.lu_solve or mpmath.qr_solve. See Also ======== lower_triangular_solve upper_triangular_solve gauss_jordan_solve cholesky_solve diagonal_solve LDLsolve QRsolve pinv_solve LUdecomposition """ if rhs.rows != self.rows: raise ShapeError( "``self`` and ``rhs`` must have the same number of rows.") m = self.rows n = self.cols if m < n: raise NotImplementedError("Underdetermined systems not supported.") try: A, perm = self.LUdecomposition_Simple( iszerofunc=_iszero, rankcheck=True) except ValueError: raise NotImplementedError("Underdetermined systems not supported.") b = rhs.permute_rows(perm).as_mutable() # forward substitution, all diag entries are scaled to 1 for i in range(m): for j in range(min(i, n)): scale = A[i, j] b.zip_row_op(i, j, lambda x, y: x - y * scale) # consistency check for overdetermined systems if m > n: for i in range(n, m): for j in range(b.cols): if not iszerofunc(b[i, j]): raise ValueError("The system is inconsistent.") b = b[0:n, :] # truncate zero rows if consistent # backward substitution for i in range(n - 1, -1, -1): for j in range(i + 1, n): scale = A[i, j] b.zip_row_op(i, j, lambda x, y: x - y * scale) scale = A[i, i] b.row_op(i, lambda x, _: x / scale) return rhs.__class__(b) def multiply(self, b): """Returns ``self*b`` See Also ======== dot cross multiply_elementwise """ return self * b def normalized(self, iszerofunc=_iszero): """Return the normalized version of ``self``. Parameters ========== iszerofunc : Function, optional A function to determine whether ``self`` is a zero vector. The default ``_iszero`` tests to see if each element is exactly zero. Returns ======= Matrix Normalized vector form of ``self``. It has the same length as a unit vector. However, a zero vector will be returned for a vector with norm 0. Raises ====== ShapeError If the matrix is not in a vector form. See Also ======== norm """ if self.rows != 1 and self.cols != 1: raise ShapeError("A Matrix must be a vector to normalize.") norm = self.norm() if iszerofunc(norm): out = self.zeros(self.rows, self.cols) else: out = self.applyfunc(lambda i: i / norm) return out def norm(self, ord=None): """Return the Norm of a Matrix or Vector. In the simplest case this is the geometric size of the vector Other norms can be specified by the ord parameter ===== ============================ ========================== ord norm for matrices norm for vectors ===== ============================ ========================== None Frobenius norm 2-norm 'fro' Frobenius norm - does not exist inf maximum row sum max(abs(x)) -inf -- min(abs(x)) 1 maximum column sum as below -1 -- as below 2 2-norm (largest sing. value) as below -2 smallest singular value as below other - does not exist sum(abs(x)**ord)**(1./ord) ===== ============================ ========================== Examples ======== >>> from sympy import Matrix, Symbol, trigsimp, cos, sin, oo >>> x = Symbol('x', real=True) >>> v = Matrix([cos(x), sin(x)]) >>> trigsimp( v.norm() ) 1 >>> v.norm(10) (sin(x)**10 + cos(x)**10)**(1/10) >>> A = Matrix([[1, 1], [1, 1]]) >>> A.norm(1) # maximum sum of absolute values of A is 2 2 >>> A.norm(2) # Spectral norm (max of |Ax|/|x| under 2-vector-norm) 2 >>> A.norm(-2) # Inverse spectral norm (smallest singular value) 0 >>> A.norm() # Frobenius Norm 2 >>> A.norm(oo) # Infinity Norm 2 >>> Matrix([1, -2]).norm(oo) 2 >>> Matrix([-1, 2]).norm(-oo) 1 See Also ======== normalized """ # Row or Column Vector Norms vals = list(self.values()) or [0] if self.rows == 1 or self.cols == 1: if ord == 2 or ord is None: # Common case sqrt(<x, x>) return sqrt(Add(*(abs(i) ** 2 for i in vals))) elif ord == 1: # sum(abs(x)) return Add(*(abs(i) for i in vals)) elif ord == S.Infinity: # max(abs(x)) return Max(*[abs(i) for i in vals]) elif ord == S.NegativeInfinity: # min(abs(x)) return Min(*[abs(i) for i in vals]) # Otherwise generalize the 2-norm, Sum(x_i**ord)**(1/ord) # Note that while useful this is not mathematically a norm try: return Pow(Add(*(abs(i) ** ord for i in vals)), S(1) / ord) except (NotImplementedError, TypeError): raise ValueError("Expected order to be Number, Symbol, oo") # Matrix Norms else: if ord == 1: # Maximum column sum m = self.applyfunc(abs) return Max(*[sum(m.col(i)) for i in range(m.cols)]) elif ord == 2: # Spectral Norm # Maximum singular value return Max(*self.singular_values()) elif ord == -2: # Minimum singular value return Min(*self.singular_values()) elif ord == S.Infinity: # Infinity Norm - Maximum row sum m = self.applyfunc(abs) return Max(*[sum(m.row(i)) for i in range(m.rows)]) elif (ord is None or isinstance(ord, string_types) and ord.lower() in ['f', 'fro', 'frobenius', 'vector']): # Reshape as vector and send back to norm function return self.vec().norm(ord=2) else: raise NotImplementedError("Matrix Norms under development") def pinv_solve(self, B, arbitrary_matrix=None): """Solve ``Ax = B`` using the Moore-Penrose pseudoinverse. There may be zero, one, or infinite solutions. If one solution exists, it will be returned. If infinite solutions exist, one will be returned based on the value of arbitrary_matrix. If no solutions exist, the least-squares solution is returned. Parameters ========== B : Matrix The right hand side of the equation to be solved for. Must have the same number of rows as matrix A. arbitrary_matrix : Matrix If the system is underdetermined (e.g. A has more columns than rows), infinite solutions are possible, in terms of an arbitrary matrix. This parameter may be set to a specific matrix to use for that purpose; if so, it must be the same shape as x, with as many rows as matrix A has columns, and as many columns as matrix B. If left as None, an appropriate matrix containing dummy symbols in the form of ``wn_m`` will be used, with n and m being row and column position of each symbol. Returns ======= x : Matrix The matrix that will satisfy ``Ax = B``. Will have as many rows as matrix A has columns, and as many columns as matrix B. Examples ======== >>> from sympy import Matrix >>> A = Matrix([[1, 2, 3], [4, 5, 6]]) >>> B = Matrix([7, 8]) >>> A.pinv_solve(B) Matrix([ [ _w0_0/6 - _w1_0/3 + _w2_0/6 - 55/18], [-_w0_0/3 + 2*_w1_0/3 - _w2_0/3 + 1/9], [ _w0_0/6 - _w1_0/3 + _w2_0/6 + 59/18]]) >>> A.pinv_solve(B, arbitrary_matrix=Matrix([0, 0, 0])) Matrix([ [-55/18], [ 1/9], [ 59/18]]) See Also ======== lower_triangular_solve upper_triangular_solve gauss_jordan_solve cholesky_solve diagonal_solve LDLsolve LUsolve QRsolve pinv Notes ===== This may return either exact solutions or least squares solutions. To determine which, check ``A * A.pinv() * B == B``. It will be True if exact solutions exist, and False if only a least-squares solution exists. Be aware that the left hand side of that equation may need to be simplified to correctly compare to the right hand side. References ========== .. [1] https://en.wikipedia.org/wiki/Moore-Penrose_pseudoinverse#Obtaining_all_solutions_of_a_linear_system """ from sympy.matrices import eye A = self A_pinv = self.pinv() if arbitrary_matrix is None: rows, cols = A.cols, B.cols w = symbols('w:{0}_:{1}'.format(rows, cols), cls=Dummy) arbitrary_matrix = self.__class__(cols, rows, w).T return A_pinv * B + (eye(A.cols) - A_pinv * A) * arbitrary_matrix def pinv(self): """Calculate the Moore-Penrose pseudoinverse of the matrix. The Moore-Penrose pseudoinverse exists and is unique for any matrix. If the matrix is invertible, the pseudoinverse is the same as the inverse. Examples ======== >>> from sympy import Matrix >>> Matrix([[1, 2, 3], [4, 5, 6]]).pinv() Matrix([ [-17/18, 4/9], [ -1/9, 1/9], [ 13/18, -2/9]]) See Also ======== inv pinv_solve References ========== .. [1] https://en.wikipedia.org/wiki/Moore-Penrose_pseudoinverse """ A = self AH = self.H # Trivial case: pseudoinverse of all-zero matrix is its transpose. if A.is_zero: return AH try: if self.rows >= self.cols: return (AH * A).inv() * AH else: return AH * (A * AH).inv() except ValueError: # Matrix is not full rank, so A*AH cannot be inverted. pass try: # However, A*AH is Hermitian, so we can diagonalize it. if self.rows >= self.cols: P, D = (AH * A).diagonalize(normalize=True) D_pinv = D.applyfunc(lambda x: 0 if _iszero(x) else 1 / x) return P * D_pinv * P.H * AH else: P, D = (A * AH).diagonalize(normalize=True) D_pinv = D.applyfunc(lambda x: 0 if _iszero(x) else 1 / x) return AH * P * D_pinv * P.H except MatrixError: raise NotImplementedError('pinv for rank-deficient matrices where diagonalization ' 'of A.H*A fails is not supported yet.') def print_nonzero(self, symb="X"): """Shows location of non-zero entries for fast shape lookup. Examples ======== >>> from sympy.matrices import Matrix, eye >>> m = Matrix(2, 3, lambda i, j: i*3+j) >>> m Matrix([ [0, 1, 2], [3, 4, 5]]) >>> m.print_nonzero() [ XX] [XXX] >>> m = eye(4) >>> m.print_nonzero("x") [x ] [ x ] [ x ] [ x] """ s = [] for i in range(self.rows): line = [] for j in range(self.cols): if self[i, j] == 0: line.append(" ") else: line.append(str(symb)) s.append("[%s]" % ''.join(line)) print('\n'.join(s)) def project(self, v): """Return the projection of ``self`` onto the line containing ``v``. Examples ======== >>> from sympy import Matrix, S, sqrt >>> V = Matrix([sqrt(3)/2, S.Half]) >>> x = Matrix([[1, 0]]) >>> V.project(x) Matrix([[sqrt(3)/2, 0]]) >>> V.project(-x) Matrix([[sqrt(3)/2, 0]]) """ return v * (self.dot(v) / v.dot(v)) def QRdecomposition(self): """Return Q, R where A = Q*R, Q is orthogonal and R is upper triangular. Examples ======== This is the example from wikipedia: >>> from sympy import Matrix >>> A = Matrix([[12, -51, 4], [6, 167, -68], [-4, 24, -41]]) >>> Q, R = A.QRdecomposition() >>> Q Matrix([ [ 6/7, -69/175, -58/175], [ 3/7, 158/175, 6/175], [-2/7, 6/35, -33/35]]) >>> R Matrix([ [14, 21, -14], [ 0, 175, -70], [ 0, 0, 35]]) >>> A == Q*R True QR factorization of an identity matrix: >>> A = Matrix([[1, 0, 0], [0, 1, 0], [0, 0, 1]]) >>> Q, R = A.QRdecomposition() >>> Q Matrix([ [1, 0, 0], [0, 1, 0], [0, 0, 1]]) >>> R Matrix([ [1, 0, 0], [0, 1, 0], [0, 0, 1]]) See Also ======== cholesky LDLdecomposition LUdecomposition QRsolve """ cls = self.__class__ mat = self.as_mutable() n = mat.rows m = mat.cols ranked = list() # Pad with additional rows to make wide matrices square # nOrig keeps track of original size so zeros can be trimmed from Q if n < m: nOrig = n n = m mat = mat.col_join(mat.zeros(n - nOrig, m)) else: nOrig = n Q, R = mat.zeros(n, m), mat.zeros(m) for j in range(m): # for each column vector tmp = mat[:, j] # take original v for i in range(j): # subtract the project of mat on new vector R[i, j] = Q[:, i].dot(mat[:, j]) tmp -= Q[:, i] * R[i, j] tmp.expand() # normalize it R[j, j] = tmp.norm() if not R[j, j].is_zero: ranked.append(j) Q[:, j] = tmp / R[j, j] if len(ranked) != 0: return ( cls(Q.extract(range(nOrig), ranked)), cls(R.extract(ranked, range(R.cols))) ) else: # Trivial case handling for zero-rank matrix # Force Q as matrix containing standard basis vectors for i in range(Min(nOrig, m)): Q[i, i] = 1 return ( cls(Q.extract(range(nOrig), range(Min(nOrig, m)))), cls(R.extract(range(Min(nOrig, m)), range(R.cols))) ) def QRsolve(self, b): """Solve the linear system ``Ax = b``. ``self`` is the matrix ``A``, the method argument is the vector ``b``. The method returns the solution vector ``x``. If ``b`` is a matrix, the system is solved for each column of ``b`` and the return value is a matrix of the same shape as ``b``. This method is slower (approximately by a factor of 2) but more stable for floating-point arithmetic than the LUsolve method. However, LUsolve usually uses an exact arithmetic, so you don't need to use QRsolve. This is mainly for educational purposes and symbolic matrices, for real (or complex) matrices use mpmath.qr_solve. See Also ======== lower_triangular_solve upper_triangular_solve gauss_jordan_solve cholesky_solve diagonal_solve LDLsolve LUsolve pinv_solve QRdecomposition """ Q, R = self.as_mutable().QRdecomposition() y = Q.T * b # back substitution to solve R*x = y: # We build up the result "backwards" in the vector 'x' and reverse it # only in the end. x = [] n = R.rows for j in range(n - 1, -1, -1): tmp = y[j, :] for k in range(j + 1, n): tmp -= R[j, k] * x[n - 1 - k] x.append(tmp / R[j, j]) return self._new([row._mat for row in reversed(x)]) def rank_decomposition(self, iszerofunc=_iszero, simplify=False): r"""Returns a pair of matrices (`C`, `F`) with matching rank such that `A = C F`. Parameters ========== iszerofunc : Function, optional A function used for detecting whether an element can act as a pivot. ``lambda x: x.is_zero`` is used by default. simplify : Bool or Function, optional A function used to simplify elements when looking for a pivot. By default SymPy's ``simplify`` is used. Returns ======= (C, F) : Matrices `C` and `F` are full-rank matrices with rank as same as `A`, whose product gives `A`. See Notes for additional mathematical details. Examples ======== >>> from sympy.matrices import Matrix >>> A = Matrix([ ... [1, 3, 1, 4], ... [2, 7, 3, 9], ... [1, 5, 3, 1], ... [1, 2, 0, 8] ... ]) >>> C, F = A.rank_decomposition() >>> C Matrix([ [1, 3, 4], [2, 7, 9], [1, 5, 1], [1, 2, 8]]) >>> F Matrix([ [1, 0, -2, 0], [0, 1, 1, 0], [0, 0, 0, 1]]) >>> C * F == A True Notes ===== Obtaining `F`, an RREF of `A`, is equivalent to creating a product .. math:: E_n E_{n-1} ... E_1 A = F where `E_n, E_{n-1}, ... , E_1` are the elimination matrices or permutation matrices equivalent to each row-reduction step. The inverse of the same product of elimination matrices gives `C`: .. math:: C = (E_n E_{n-1} ... E_1)^{-1} It is not necessary, however, to actually compute the inverse: the columns of `C` are those from the original matrix with the same column indices as the indices of the pivot columns of `F`. References ========== .. [1] https://en.wikipedia.org/wiki/Rank_factorization .. [2] Piziak, R.; Odell, P. L. (1 June 1999). "Full Rank Factorization of Matrices". Mathematics Magazine. 72 (3): 193. doi:10.2307/2690882 See Also ======== rref """ (F, pivot_cols) = self.rref( simplify=simplify, iszerofunc=iszerofunc, pivots=True) rank = len(pivot_cols) C = self.extract(range(self.rows), pivot_cols) F = F[:rank, :] return (C, F) def solve_least_squares(self, rhs, method='CH'): """Return the least-square fit to the data. Parameters ========== rhs : Matrix Vector representing the right hand side of the linear equation. method : string or boolean, optional If set to ``'CH'``, ``cholesky_solve`` routine will be used. If set to ``'LDL'``, ``LDLsolve`` routine will be used. If set to ``'QR'``, ``QRsolve`` routine will be used. If set to ``'PINV'``, ``pinv_solve`` routine will be used. Otherwise, the conjugate of ``self`` will be used to create a system of equations that is passed to ``solve`` along with the hint defined by ``method``. Returns ======= solutions : Matrix Vector representing the solution. Examples ======== >>> from sympy.matrices import Matrix, ones >>> A = Matrix([1, 2, 3]) >>> B = Matrix([2, 3, 4]) >>> S = Matrix(A.row_join(B)) >>> S Matrix([ [1, 2], [2, 3], [3, 4]]) If each line of S represent coefficients of Ax + By and x and y are [2, 3] then S*xy is: >>> r = S*Matrix([2, 3]); r Matrix([ [ 8], [13], [18]]) But let's add 1 to the middle value and then solve for the least-squares value of xy: >>> xy = S.solve_least_squares(Matrix([8, 14, 18])); xy Matrix([ [ 5/3], [10/3]]) The error is given by S*xy - r: >>> S*xy - r Matrix([ [1/3], [1/3], [1/3]]) >>> _.norm().n(2) 0.58 If a different xy is used, the norm will be higher: >>> xy += ones(2, 1)/10 >>> (S*xy - r).norm().n(2) 1.5 """ if method == 'CH': return self.cholesky_solve(rhs) elif method == 'QR': return self.QRsolve(rhs) elif method == 'LDL': return self.LDLsolve(rhs) elif method == 'PINV': return self.pinv_solve(rhs) else: t = self.H return (t * self).solve(t * rhs, method=method) def solve(self, rhs, method='GJ'): """Solves linear equation where the unique solution exists. Parameters ========== rhs : Matrix Vector representing the right hand side of the linear equation. method : string, optional If set to ``'GJ'``, the Gauss-Jordan elimination will be used, which is implemented in the routine ``gauss_jordan_solve``. If set to ``'LU'``, ``LUsolve`` routine will be used. If set to ``'QR'``, ``QRsolve`` routine will be used. If set to ``'PINV'``, ``pinv_solve`` routine will be used. It also supports the methods available for special linear systems For positive definite systems: If set to ``'CH'``, ``cholesky_solve`` routine will be used. If set to ``'LDL'``, ``LDLsolve`` routine will be used. To use a different method and to compute the solution via the inverse, use a method defined in the .inv() docstring. Returns ======= solutions : Matrix Vector representing the solution. Raises ====== ValueError If there is not a unique solution then a ``ValueError`` will be raised. If ``self`` is not square, a ``ValueError`` and a different routine for solving the system will be suggested. """ if method == 'GJ': try: soln, param = self.gauss_jordan_solve(rhs) if param: raise ValueError("Matrix det == 0; not invertible. " "Try ``self.gauss_jordan_solve(rhs)`` to obtain a parametric solution.") except ValueError: # raise same error as in inv: self.zeros(1).inv() return soln elif method == 'LU': return self.LUsolve(rhs) elif method == 'CH': return self.cholesky_solve(rhs) elif method == 'QR': return self.QRsolve(rhs) elif method == 'LDL': return self.LDLsolve(rhs) elif method == 'PINV': return self.pinv_solve(rhs) else: return self.inv(method=method)*rhs def table(self, printer, rowstart='[', rowend=']', rowsep='\n', colsep=', ', align='right'): r""" String form of Matrix as a table. ``printer`` is the printer to use for on the elements (generally something like StrPrinter()) ``rowstart`` is the string used to start each row (by default '['). ``rowend`` is the string used to end each row (by default ']'). ``rowsep`` is the string used to separate rows (by default a newline). ``colsep`` is the string used to separate columns (by default ', '). ``align`` defines how the elements are aligned. Must be one of 'left', 'right', or 'center'. You can also use '<', '>', and '^' to mean the same thing, respectively. This is used by the string printer for Matrix. Examples ======== >>> from sympy import Matrix >>> from sympy.printing.str import StrPrinter >>> M = Matrix([[1, 2], [-33, 4]]) >>> printer = StrPrinter() >>> M.table(printer) '[ 1, 2]\n[-33, 4]' >>> print(M.table(printer)) [ 1, 2] [-33, 4] >>> print(M.table(printer, rowsep=',\n')) [ 1, 2], [-33, 4] >>> print('[%s]' % M.table(printer, rowsep=',\n')) [[ 1, 2], [-33, 4]] >>> print(M.table(printer, colsep=' ')) [ 1 2] [-33 4] >>> print(M.table(printer, align='center')) [ 1 , 2] [-33, 4] >>> print(M.table(printer, rowstart='{', rowend='}')) { 1, 2} {-33, 4} """ # Handle zero dimensions: if self.rows == 0 or self.cols == 0: return '[]' # Build table of string representations of the elements res = [] # Track per-column max lengths for pretty alignment maxlen = [0] * self.cols for i in range(self.rows): res.append([]) for j in range(self.cols): s = printer._print(self[i, j]) res[-1].append(s) maxlen[j] = max(len(s), maxlen[j]) # Patch strings together align = { 'left': 'ljust', 'right': 'rjust', 'center': 'center', '<': 'ljust', '>': 'rjust', '^': 'center', }[align] for i, row in enumerate(res): for j, elem in enumerate(row): row[j] = getattr(elem, align)(maxlen[j]) res[i] = rowstart + colsep.join(row) + rowend return rowsep.join(res) def upper_triangular_solve(self, rhs): """Solves ``Ax = B``, where A is an upper triangular matrix. See Also ======== lower_triangular_solve gauss_jordan_solve cholesky_solve diagonal_solve LDLsolve LUsolve QRsolve pinv_solve """ if not self.is_square: raise NonSquareMatrixError("Matrix must be square.") if rhs.rows != self.rows: raise TypeError("Matrix size mismatch.") if not self.is_upper: raise TypeError("Matrix is not upper triangular.") return self._upper_triangular_solve(rhs) def vech(self, diagonal=True, check_symmetry=True): """Return the unique elements of a symmetric Matrix as a one column matrix by stacking the elements in the lower triangle. Arguments: diagonal -- include the diagonal cells of ``self`` or not check_symmetry -- checks symmetry of ``self`` but not completely reliably Examples ======== >>> from sympy import Matrix >>> m=Matrix([[1, 2], [2, 3]]) >>> m Matrix([ [1, 2], [2, 3]]) >>> m.vech() Matrix([ [1], [2], [3]]) >>> m.vech(diagonal=False) Matrix([[2]]) See Also ======== vec """ from sympy.matrices import zeros c = self.cols if c != self.rows: raise ShapeError("Matrix must be square") if check_symmetry: self.simplify() if self != self.transpose(): raise ValueError( "Matrix appears to be asymmetric; consider check_symmetry=False") count = 0 if diagonal: v = zeros(c * (c + 1) // 2, 1) for j in range(c): for i in range(j, c): v[count] = self[i, j] count += 1 else: v = zeros(c * (c - 1) // 2, 1) for j in range(c): for i in range(j + 1, c): v[count] = self[i, j] count += 1 return v @deprecated( issue=15109, useinstead="from sympy.matrices.common import classof", deprecated_since_version="1.3") def classof(A, B): from sympy.matrices.common import classof as classof_ return classof_(A, B) @deprecated( issue=15109, deprecated_since_version="1.3", useinstead="from sympy.matrices.common import a2idx") def a2idx(j, n=None): from sympy.matrices.common import a2idx as a2idx_ return a2idx_(j, n) def _find_reasonable_pivot(col, iszerofunc=_iszero, simpfunc=_simplify): """ Find the lowest index of an item in ``col`` that is suitable for a pivot. If ``col`` consists only of Floats, the pivot with the largest norm is returned. Otherwise, the first element where ``iszerofunc`` returns False is used. If ``iszerofunc`` doesn't return false, items are simplified and retested until a suitable pivot is found. Returns a 4-tuple (pivot_offset, pivot_val, assumed_nonzero, newly_determined) where pivot_offset is the index of the pivot, pivot_val is the (possibly simplified) value of the pivot, assumed_nonzero is True if an assumption that the pivot was non-zero was made without being proved, and newly_determined are elements that were simplified during the process of pivot finding.""" newly_determined = [] col = list(col) # a column that contains a mix of floats and integers # but at least one float is considered a numerical # column, and so we do partial pivoting if all(isinstance(x, (Float, Integer)) for x in col) and any( isinstance(x, Float) for x in col): col_abs = [abs(x) for x in col] max_value = max(col_abs) if iszerofunc(max_value): # just because iszerofunc returned True, doesn't # mean the value is numerically zero. Make sure # to replace all entries with numerical zeros if max_value != 0: newly_determined = [(i, 0) for i, x in enumerate(col) if x != 0] return (None, None, False, newly_determined) index = col_abs.index(max_value) return (index, col[index], False, newly_determined) # PASS 1 (iszerofunc directly) possible_zeros = [] for i, x in enumerate(col): is_zero = iszerofunc(x) # is someone wrote a custom iszerofunc, it may return # BooleanFalse or BooleanTrue instead of True or False, # so use == for comparison instead of `is` if is_zero == False: # we found something that is definitely not zero return (i, x, False, newly_determined) possible_zeros.append(is_zero) # by this point, we've found no certain non-zeros if all(possible_zeros): # if everything is definitely zero, we have # no pivot return (None, None, False, newly_determined) # PASS 2 (iszerofunc after simplify) # we haven't found any for-sure non-zeros, so # go through the elements iszerofunc couldn't # make a determination about and opportunistically # simplify to see if we find something for i, x in enumerate(col): if possible_zeros[i] is not None: continue simped = simpfunc(x) is_zero = iszerofunc(simped) if is_zero == True or is_zero == False: newly_determined.append((i, simped)) if is_zero == False: return (i, simped, False, newly_determined) possible_zeros[i] = is_zero # after simplifying, some things that were recognized # as zeros might be zeros if all(possible_zeros): # if everything is definitely zero, we have # no pivot return (None, None, False, newly_determined) # PASS 3 (.equals(0)) # some expressions fail to simplify to zero, but # ``.equals(0)`` evaluates to True. As a last-ditch # attempt, apply ``.equals`` to these expressions for i, x in enumerate(col): if possible_zeros[i] is not None: continue if x.equals(S.Zero): # ``.iszero`` may return False with # an implicit assumption (e.g., ``x.equals(0)`` # when ``x`` is a symbol), so only treat it # as proved when ``.equals(0)`` returns True possible_zeros[i] = True newly_determined.append((i, S.Zero)) if all(possible_zeros): return (None, None, False, newly_determined) # at this point there is nothing that could definitely # be a pivot. To maintain compatibility with existing # behavior, we'll assume that an illdetermined thing is # non-zero. We should probably raise a warning in this case i = possible_zeros.index(None) return (i, col[i], True, newly_determined) def _find_reasonable_pivot_naive(col, iszerofunc=_iszero, simpfunc=None): """ Helper that computes the pivot value and location from a sequence of contiguous matrix column elements. As a side effect of the pivot search, this function may simplify some of the elements of the input column. A list of these simplified entries and their indices are also returned. This function mimics the behavior of _find_reasonable_pivot(), but does less work trying to determine if an indeterminate candidate pivot simplifies to zero. This more naive approach can be much faster, with the trade-off that it may erroneously return a pivot that is zero. ``col`` is a sequence of contiguous column entries to be searched for a suitable pivot. ``iszerofunc`` is a callable that returns a Boolean that indicates if its input is zero, or None if no such determination can be made. ``simpfunc`` is a callable that simplifies its input. It must return its input if it does not simplify its input. Passing in ``simpfunc=None`` indicates that the pivot search should not attempt to simplify any candidate pivots. Returns a 4-tuple: (pivot_offset, pivot_val, assumed_nonzero, newly_determined) ``pivot_offset`` is the sequence index of the pivot. ``pivot_val`` is the value of the pivot. pivot_val and col[pivot_index] are equivalent, but will be different when col[pivot_index] was simplified during the pivot search. ``assumed_nonzero`` is a boolean indicating if the pivot cannot be guaranteed to be zero. If assumed_nonzero is true, then the pivot may or may not be non-zero. If assumed_nonzero is false, then the pivot is non-zero. ``newly_determined`` is a list of index-value pairs of pivot candidates that were simplified during the pivot search. """ # indeterminates holds the index-value pairs of each pivot candidate # that is neither zero or non-zero, as determined by iszerofunc(). # If iszerofunc() indicates that a candidate pivot is guaranteed # non-zero, or that every candidate pivot is zero then the contents # of indeterminates are unused. # Otherwise, the only viable candidate pivots are symbolic. # In this case, indeterminates will have at least one entry, # and all but the first entry are ignored when simpfunc is None. indeterminates = [] for i, col_val in enumerate(col): col_val_is_zero = iszerofunc(col_val) if col_val_is_zero == False: # This pivot candidate is non-zero. return i, col_val, False, [] elif col_val_is_zero is None: # The candidate pivot's comparison with zero # is indeterminate. indeterminates.append((i, col_val)) if len(indeterminates) == 0: # All candidate pivots are guaranteed to be zero, i.e. there is # no pivot. return None, None, False, [] if simpfunc is None: # Caller did not pass in a simplification function that might # determine if an indeterminate pivot candidate is guaranteed # to be nonzero, so assume the first indeterminate candidate # is non-zero. return indeterminates[0][0], indeterminates[0][1], True, [] # newly_determined holds index-value pairs of candidate pivots # that were simplified during the search for a non-zero pivot. newly_determined = [] for i, col_val in indeterminates: tmp_col_val = simpfunc(col_val) if id(col_val) != id(tmp_col_val): # simpfunc() simplified this candidate pivot. newly_determined.append((i, tmp_col_val)) if iszerofunc(tmp_col_val) == False: # Candidate pivot simplified to a guaranteed non-zero value. return i, tmp_col_val, False, newly_determined return indeterminates[0][0], indeterminates[0][1], True, newly_determined
b8996c9b47ae25dce5aa6ac7ce8215a06ef88700a0084c248afdf102a4f95bb3
from __future__ import division, print_function from sympy.core.compatibility import range, as_int from sympy.utilities.iterables import is_sequence from sympy.utilities.misc import filldedent from .sparse import SparseMatrix def _doktocsr(dok): """Converts a sparse matrix to Compressed Sparse Row (CSR) format. Parameters ========== A : contains non-zero elements sorted by key (row, column) JA : JA[i] is the column corresponding to A[i] IA : IA[i] contains the index in A for the first non-zero element of row[i]. Thus IA[i+1] - IA[i] gives number of non-zero elements row[i]. The length of IA is always 1 more than the number of rows in the matrix. """ row, JA, A = [list(i) for i in zip(*dok.row_list())] IA = [0]*((row[0] if row else 0) + 1) for i, r in enumerate(row): IA.extend([i]*(r - row[i - 1])) # if i = 0 nothing is extended IA.extend([len(A)]*(dok.rows - len(IA) + 1)) shape = [dok.rows, dok.cols] return [A, JA, IA, shape] def _csrtodok(csr): """Converts a CSR representation to DOK representation""" smat = {} A, JA, IA, shape = csr for i in range(len(IA) - 1): indices = slice(IA[i], IA[i + 1]) for l, m in zip(A[indices], JA[indices]): smat[i, m] = l return SparseMatrix(*(shape + [smat])) def banded(*args, **kwargs): """Returns a SparseMatrix from the given dictionary describing the diagonals of the matrix. The keys are positive for upper diagonals and negative for those below the main diagonal. The values may be: * expressions or single-argument functions, * lists or tuples of values, * matrices Unless dimensions are given, the size of the returned matrix will be large enough to contain the largest non-zero value provided. kwargs ====== rows : rows of the resulting matrix; computed if not given. cols : columns of the resulting matrix; computed if not given. Examples ======== >>> from sympy import banded, ones, Matrix >>> from sympy.abc import x If explicit values are given in tuples, the matrix will autosize to contain all values, otherwise a single value is filled onto the entire diagonal: >>> banded({1: (1, 2, 3), -1: (4, 5, 6), 0: x}) Matrix([ [x, 1, 0, 0], [4, x, 2, 0], [0, 5, x, 3], [0, 0, 6, x]]) A function accepting a single argument can be used to fill the diagonal as a function of diagonal index (which starts at 0). The size (or shape) of the matrix must be given to obtain more than a 1x1 matrix: >>> s = lambda d: (1 + d)**2 >>> banded(5, {0: s, 2: s, -2: 2}) Matrix([ [1, 0, 1, 0, 0], [0, 4, 0, 4, 0], [2, 0, 9, 0, 9], [0, 2, 0, 16, 0], [0, 0, 2, 0, 25]]) The diagonal of matrices placed on a diagonal will coincide with the indicated diagonal: >>> vert = Matrix([1, 2, 3]) >>> banded({0: vert}, cols=3) Matrix([ [1, 0, 0], [2, 1, 0], [3, 2, 1], [0, 3, 2], [0, 0, 3]]) >>> banded(4, {0: ones(2)}) Matrix([ [1, 1, 0, 0], [1, 1, 0, 0], [0, 0, 1, 1], [0, 0, 1, 1]]) Errors are raised if the designated size will not hold all values an integral number of times. Here, the rows are designated as odd (but an even number is required to hold the off-diagonal 2x2 ones): >>> banded({0: 2, 1: ones(2)}, rows=5) Traceback (most recent call last): ... ValueError: sequence does not fit an integral number of times in the matrix And here, an even number of rows is given...but the square matrix has an even number of columns, too. As we saw in the previous example, an odd number is required: >>> banded(4, {0: 2, 1: ones(2)}) # trying to make 4x4 and cols must be odd Traceback (most recent call last): ... ValueError: sequence does not fit an integral number of times in the matrix A way around having to count rows is to enclosing matrix elements in a tuple and indicate the desired number of them to the right: >>> banded({0: 2, 2: (ones(2),)*3}) Matrix([ [2, 0, 1, 1, 0, 0, 0, 0], [0, 2, 1, 1, 0, 0, 0, 0], [0, 0, 2, 0, 1, 1, 0, 0], [0, 0, 0, 2, 1, 1, 0, 0], [0, 0, 0, 0, 2, 0, 1, 1], [0, 0, 0, 0, 0, 2, 1, 1]]) An error will be raised if more than one value is written to a given entry. Here, the ones overlap with the main diagonal if they are placed on the first diagonal: >>> banded({0: (2,)*5, 1: (ones(2),)*3}) Traceback (most recent call last): ... ValueError: collision at (1, 1) By placing a 0 at the bottom left of the 2x2 matrix of ones, the collision is avoided: >>> u2 = Matrix([ ... [1, 1], ... [0, 1]]) >>> banded({0: [2]*5, 1: [u2]*3}) Matrix([ [2, 1, 1, 0, 0, 0, 0], [0, 2, 1, 0, 0, 0, 0], [0, 0, 2, 1, 1, 0, 0], [0, 0, 0, 2, 1, 0, 0], [0, 0, 0, 0, 2, 1, 1], [0, 0, 0, 0, 0, 0, 1]]) """ from sympy import Dict, Dummy, SparseMatrix try: if len(args) not in (1, 2, 3): raise TypeError if not isinstance(args[-1], (dict, Dict)): raise TypeError if len(args) == 1: rows = kwargs.get('rows', None) cols = kwargs.get('cols', None) if rows is not None: rows = as_int(rows) if cols is not None: cols = as_int(cols) elif len(args) == 2: rows = cols = as_int(args[0]) else: rows, cols = map(as_int, args[:2]) # fails with ValueError if any keys are not ints _ = all(as_int(k) for k in args[-1]) except (ValueError, TypeError): raise TypeError(filldedent( '''unrecognized input to banded: expecting [[row,] col,] {int: value}''')) def rc(d): # return row,col coord of diagonal start r = -d if d < 0 else 0 c = 0 if r else d return r, c smat = {} undone = [] tba = Dummy() # first handle objects with size for d, v in args[-1].items(): r, c = rc(d) # note: only list and tuple are recognized since this # will allow other Basic objects like Tuple # into the matrix if so desired if isinstance(v, (list, tuple)): extra = 0 for i, vi in enumerate(v): i += extra if is_sequence(vi): vi = SparseMatrix(vi) smat[r + i, c + i] = vi extra += min(vi.shape) - 1 else: smat[r + i, c + i] = vi elif is_sequence(v): v = SparseMatrix(v) rv, cv = v.shape if rows and cols: nr, xr = divmod(rows - r, rv) nc, xc = divmod(cols - c, cv) x = xr or xc do = min(nr, nc) elif rows: do, x = divmod(rows - r, rv) elif cols: do, x = divmod(cols - c, cv) else: do = 1 x = 0 if x: raise ValueError(filldedent(''' sequence does not fit an integral number of times in the matrix''')) j = min(v.shape) for i in range(do): smat[r, c] = v r += j c += j elif v: smat[r, c] = tba undone.append((d, v)) s = SparseMatrix(None, smat) # to expand matrices smat = s._smat # check for dim errors here if rows is not None and rows < s.rows: raise ValueError('Designated rows %s < needed %s' % (rows, s.rows)) if cols is not None and cols < s.cols: raise ValueError('Designated cols %s < needed %s' % (cols, s.cols)) if rows is cols is None: rows = s.rows cols = s.cols elif rows is not None and cols is None: cols = max(rows, s.cols) elif cols is not None and rows is None: rows = max(cols, s.rows) def update(i, j, v): # update smat and make sure there are # no collisions if v: if (i, j) in smat and smat[i, j] not in (tba, v): raise ValueError('collision at %s' % ((i, j),)) smat[i, j] = v if undone: for d, vi in undone: r, c = rc(d) v = vi if callable(vi) else lambda _: vi i = 0 while r + i < rows and c + i < cols: update(r + i, c + i, v(i)) i += 1 return SparseMatrix(rows, cols, smat)
ca79d859bba5a73c807f89f08b5aac95e6b64d6e8f310bf5734b71d887f0af9e
from .plot import plot_backends from .plot_implicit import plot_implicit from .textplot import textplot from .pygletplot import PygletPlot from .plot import PlotGrid from .plot import (plot, plot_parametric, plot3d, plot3d_parametric_surface, plot3d_parametric_line)
936783de5c2f5df8ceedbcc5c7d8935819bce9ab21ec21974695f463fdc2e721
"""Plotting module for Sympy. A plot is represented by the ``Plot`` class that contains a reference to the backend and a list of the data series to be plotted. The data series are instances of classes meant to simplify getting points and meshes from sympy expressions. ``plot_backends`` is a dictionary with all the backends. This module gives only the essential. For all the fancy stuff use directly the backend. You can get the backend wrapper for every plot from the ``_backend`` attribute. Moreover the data series classes have various useful methods like ``get_points``, ``get_segments``, ``get_meshes``, etc, that may be useful if you wish to use another plotting library. Especially if you need publication ready graphs and this module is not enough for you - just get the ``_backend`` attribute and add whatever you want directly to it. In the case of matplotlib (the common way to graph data in python) just copy ``_backend.fig`` which is the figure and ``_backend.ax`` which is the axis and work on them as you would on any other matplotlib object. Simplicity of code takes much greater importance than performance. Don't use it if you care at all about performance. A new backend instance is initialized every time you call ``show()`` and the old one is left to the garbage collector. """ from __future__ import print_function, division import warnings from sympy import sympify, Expr, Tuple, Dummy, Symbol from sympy.external import import_module from sympy.core.function import arity from sympy.core.compatibility import range, Callable from sympy.utilities.iterables import is_sequence from .experimental_lambdify import (vectorized_lambdify, lambdify) # N.B. # When changing the minimum module version for matplotlib, please change # the same in the `SymPyDocTestFinder`` in `sympy/utilities/runtests.py` # Backend specific imports - textplot from sympy.plotting.textplot import textplot # Global variable # Set to False when running tests / doctests so that the plots don't show. _show = True def unset_show(): """ Disable show(). For use in the tests. """ global _show _show = False ############################################################################## # The public interface ############################################################################## class Plot(object): """The central class of the plotting module. For interactive work the function ``plot`` is better suited. This class permits the plotting of sympy expressions using numerous backends (matplotlib, textplot, the old pyglet module for sympy, Google charts api, etc). The figure can contain an arbitrary number of plots of sympy expressions, lists of coordinates of points, etc. Plot has a private attribute _series that contains all data series to be plotted (expressions for lines or surfaces, lists of points, etc (all subclasses of BaseSeries)). Those data series are instances of classes not imported by ``from sympy import *``. The customization of the figure is on two levels. Global options that concern the figure as a whole (eg title, xlabel, scale, etc) and per-data series options (eg name) and aesthetics (eg. color, point shape, line type, etc.). The difference between options and aesthetics is that an aesthetic can be a function of the coordinates (or parameters in a parametric plot). The supported values for an aesthetic are: - None (the backend uses default values) - a constant - a function of one variable (the first coordinate or parameter) - a function of two variables (the first and second coordinate or parameters) - a function of three variables (only in nonparametric 3D plots) Their implementation depends on the backend so they may not work in some backends. If the plot is parametric and the arity of the aesthetic function permits it the aesthetic is calculated over parameters and not over coordinates. If the arity does not permit calculation over parameters the calculation is done over coordinates. Only cartesian coordinates are supported for the moment, but you can use the parametric plots to plot in polar, spherical and cylindrical coordinates. The arguments for the constructor Plot must be subclasses of BaseSeries. Any global option can be specified as a keyword argument. The global options for a figure are: - title : str - xlabel : str - ylabel : str - legend : bool - xscale : {'linear', 'log'} - yscale : {'linear', 'log'} - axis : bool - axis_center : tuple of two floats or {'center', 'auto'} - xlim : tuple of two floats - ylim : tuple of two floats - aspect_ratio : tuple of two floats or {'auto'} - autoscale : bool - margin : float in [0, 1] The per data series options and aesthetics are: There are none in the base series. See below for options for subclasses. Some data series support additional aesthetics or options: ListSeries, LineOver1DRangeSeries, Parametric2DLineSeries, Parametric3DLineSeries support the following: Aesthetics: - line_color : function which returns a float. options: - label : str - steps : bool - integers_only : bool SurfaceOver2DRangeSeries, ParametricSurfaceSeries support the following: aesthetics: - surface_color : function which returns a float. """ def __init__(self, *args, **kwargs): super(Plot, self).__init__() # Options for the graph as a whole. # The possible values for each option are described in the docstring of # Plot. They are based purely on convention, no checking is done. self.title = None self.xlabel = None self.ylabel = None self.aspect_ratio = 'auto' self.xlim = None self.ylim = None self.axis_center = 'auto' self.axis = True self.xscale = 'linear' self.yscale = 'linear' self.legend = False self.autoscale = True self.margin = 0 # Contains the data objects to be plotted. The backend should be smart # enough to iterate over this list. self._series = [] self._series.extend(args) # The backend type. On every show() a new backend instance is created # in self._backend which is tightly coupled to the Plot instance # (thanks to the parent attribute of the backend). self.backend = DefaultBackend # The keyword arguments should only contain options for the plot. for key, val in kwargs.items(): if hasattr(self, key): setattr(self, key, val) def show(self): # TODO move this to the backend (also for save) if hasattr(self, '_backend'): self._backend.close() self._backend = self.backend(self) self._backend.show() def save(self, path): if hasattr(self, '_backend'): self._backend.close() self._backend = self.backend(self) self._backend.save(path) def __str__(self): series_strs = [('[%d]: ' % i) + str(s) for i, s in enumerate(self._series)] return 'Plot object containing:\n' + '\n'.join(series_strs) def __getitem__(self, index): return self._series[index] def __setitem__(self, index, *args): if len(args) == 1 and isinstance(args[0], BaseSeries): self._series[index] = args def __delitem__(self, index): del self._series[index] def append(self, arg): """Adds an element from a plot's series to an existing plot. Examples ======== Consider two ``Plot`` objects, ``p1`` and ``p2``. To add the second plot's first series object to the first, use the ``append`` method, like so: .. plot:: :format: doctest :include-source: True >>> from sympy import symbols >>> from sympy.plotting import plot >>> x = symbols('x') >>> p1 = plot(x*x, show=False) >>> p2 = plot(x, show=False) >>> p1.append(p2[0]) >>> p1 Plot object containing: [0]: cartesian line: x**2 for x over (-10.0, 10.0) [1]: cartesian line: x for x over (-10.0, 10.0) >>> p1.show() See Also ======== extend """ if isinstance(arg, BaseSeries): self._series.append(arg) else: raise TypeError('Must specify element of plot to append.') def extend(self, arg): """Adds all series from another plot. Examples ======== Consider two ``Plot`` objects, ``p1`` and ``p2``. To add the second plot to the first, use the ``extend`` method, like so: .. plot:: :format: doctest :include-source: True >>> from sympy import symbols >>> from sympy.plotting import plot >>> x = symbols('x') >>> p1 = plot(x**2, show=False) >>> p2 = plot(x, -x, show=False) >>> p1.extend(p2) >>> p1 Plot object containing: [0]: cartesian line: x**2 for x over (-10.0, 10.0) [1]: cartesian line: x for x over (-10.0, 10.0) [2]: cartesian line: -x for x over (-10.0, 10.0) >>> p1.show() """ if isinstance(arg, Plot): self._series.extend(arg._series) elif is_sequence(arg): self._series.extend(arg) else: raise TypeError('Expecting Plot or sequence of BaseSeries') class PlotGrid(object): """This class helps to plot subplots from already created sympy plots in a single figure. Examples ======== .. plot:: :context: close-figs :format: doctest :include-source: True >>> from sympy import symbols >>> from sympy.plotting import plot, plot3d, PlotGrid >>> x, y = symbols('x, y') >>> p1 = plot(x, x**2, x**3, (x, -5, 5)) >>> p2 = plot((x**2, (x, -6, 6)), (x, (x, -5, 5))) >>> p3 = plot(x**3, (x, -5, 5)) >>> p4 = plot3d(x*y, (x, -5, 5), (y, -5, 5)) Plotting vertically in a single line: .. plot:: :context: close-figs :format: doctest :include-source: True >>> PlotGrid(2, 1 , p1, p2) PlotGrid object containing: Plot[0]:Plot object containing: [0]: cartesian line: x for x over (-5.0, 5.0) [1]: cartesian line: x**2 for x over (-5.0, 5.0) [2]: cartesian line: x**3 for x over (-5.0, 5.0) Plot[1]:Plot object containing: [0]: cartesian line: x**2 for x over (-6.0, 6.0) [1]: cartesian line: x for x over (-5.0, 5.0) Plotting horizontally in a single line: .. plot:: :context: close-figs :format: doctest :include-source: True >>> PlotGrid(1, 3 , p2, p3, p4) PlotGrid object containing: Plot[0]:Plot object containing: [0]: cartesian line: x**2 for x over (-6.0, 6.0) [1]: cartesian line: x for x over (-5.0, 5.0) Plot[1]:Plot object containing: [0]: cartesian line: x**3 for x over (-5.0, 5.0) Plot[2]:Plot object containing: [0]: cartesian surface: x*y for x over (-5.0, 5.0) and y over (-5.0, 5.0) Plotting in a grid form: .. plot:: :context: close-figs :format: doctest :include-source: True >>> PlotGrid(2, 2, p1, p2 ,p3, p4) PlotGrid object containing: Plot[0]:Plot object containing: [0]: cartesian line: x for x over (-5.0, 5.0) [1]: cartesian line: x**2 for x over (-5.0, 5.0) [2]: cartesian line: x**3 for x over (-5.0, 5.0) Plot[1]:Plot object containing: [0]: cartesian line: x**2 for x over (-6.0, 6.0) [1]: cartesian line: x for x over (-5.0, 5.0) Plot[2]:Plot object containing: [0]: cartesian line: x**3 for x over (-5.0, 5.0) Plot[3]:Plot object containing: [0]: cartesian surface: x*y for x over (-5.0, 5.0) and y over (-5.0, 5.0) """ def __init__(self, nrows, ncolumns, *args, **kwargs): """ Parameters ========== nrows : The number of rows that should be in the grid of the required subplot ncolumns : The number of columns that should be in the grid of the required subplot nrows and ncolumns together define the required grid Arguments ========= A list of predefined plot objects entered in a row-wise sequence i.e. plot objects which are to be in the top row of the required grid are written first, then the second row objects and so on Keyword arguments ================= show : Boolean The default value is set to ``True``. Set show to ``False`` and the function will not display the subplot. The returned instance of the ``PlotGrid`` class can then be used to save or display the plot by calling the ``save()`` and ``show()`` methods respectively. """ self.nrows = nrows self.ncolumns = ncolumns self._series = [] self.args = args for arg in args: self._series.append(arg._series) self.backend = DefaultBackend show = kwargs.pop('show', True) if show: self.show() def show(self): if hasattr(self, '_backend'): self._backend.close() self._backend = self.backend(self) self._backend.show() def save(self, path): if hasattr(self, '_backend'): self._backend.close() self._backend = self.backend(self) self._backend.save(path) def __str__(self): plot_strs = [('Plot[%d]:' % i) + str(plot) for i, plot in enumerate(self.args)] return 'PlotGrid object containing:\n' + '\n'.join(plot_strs) ############################################################################## # Data Series ############################################################################## #TODO more general way to calculate aesthetics (see get_color_array) ### The base class for all series class BaseSeries(object): """Base class for the data objects containing stuff to be plotted. The backend should check if it supports the data series that it's given. (eg TextBackend supports only LineOver1DRange). It's the backend responsibility to know how to use the class of data series that it's given. Some data series classes are grouped (using a class attribute like is_2Dline) according to the api they present (based only on convention). The backend is not obliged to use that api (eg. The LineOver1DRange belongs to the is_2Dline group and presents the get_points method, but the TextBackend does not use the get_points method). """ # Some flags follow. The rationale for using flags instead of checking base # classes is that setting multiple flags is simpler than multiple # inheritance. is_2Dline = False # Some of the backends expect: # - get_points returning 1D np.arrays list_x, list_y # - get_segments returning np.array (done in Line2DBaseSeries) # - get_color_array returning 1D np.array (done in Line2DBaseSeries) # with the colors calculated at the points from get_points is_3Dline = False # Some of the backends expect: # - get_points returning 1D np.arrays list_x, list_y, list_y # - get_segments returning np.array (done in Line2DBaseSeries) # - get_color_array returning 1D np.array (done in Line2DBaseSeries) # with the colors calculated at the points from get_points is_3Dsurface = False # Some of the backends expect: # - get_meshes returning mesh_x, mesh_y, mesh_z (2D np.arrays) # - get_points an alias for get_meshes is_contour = False # Some of the backends expect: # - get_meshes returning mesh_x, mesh_y, mesh_z (2D np.arrays) # - get_points an alias for get_meshes is_implicit = False # Some of the backends expect: # - get_meshes returning mesh_x (1D array), mesh_y(1D array, # mesh_z (2D np.arrays) # - get_points an alias for get_meshes #Different from is_contour as the colormap in backend will be #different is_parametric = False # The calculation of aesthetics expects: # - get_parameter_points returning one or two np.arrays (1D or 2D) # used for calculation aesthetics def __init__(self): super(BaseSeries, self).__init__() @property def is_3D(self): flags3D = [ self.is_3Dline, self.is_3Dsurface ] return any(flags3D) @property def is_line(self): flagslines = [ self.is_2Dline, self.is_3Dline ] return any(flagslines) ### 2D lines class Line2DBaseSeries(BaseSeries): """A base class for 2D lines. - adding the label, steps and only_integers options - making is_2Dline true - defining get_segments and get_color_array """ is_2Dline = True _dim = 2 def __init__(self): super(Line2DBaseSeries, self).__init__() self.label = None self.steps = False self.only_integers = False self.line_color = None def get_segments(self): np = import_module('numpy') points = self.get_points() if self.steps is True: x = np.array((points[0], points[0])).T.flatten()[1:] y = np.array((points[1], points[1])).T.flatten()[:-1] points = (x, y) points = np.ma.array(points).T.reshape(-1, 1, self._dim) return np.ma.concatenate([points[:-1], points[1:]], axis=1) def get_color_array(self): np = import_module('numpy') c = self.line_color if hasattr(c, '__call__'): f = np.vectorize(c) nargs = arity(c) if nargs == 1 and self.is_parametric: x = self.get_parameter_points() return f(centers_of_segments(x)) else: variables = list(map(centers_of_segments, self.get_points())) if nargs == 1: return f(variables[0]) elif nargs == 2: return f(*variables[:2]) else: # only if the line is 3D (otherwise raises an error) return f(*variables) else: return c*np.ones(self.nb_of_points) class List2DSeries(Line2DBaseSeries): """Representation for a line consisting of list of points.""" def __init__(self, list_x, list_y): np = import_module('numpy') super(List2DSeries, self).__init__() self.list_x = np.array(list_x) self.list_y = np.array(list_y) self.label = 'list' def __str__(self): return 'list plot' def get_points(self): return (self.list_x, self.list_y) class LineOver1DRangeSeries(Line2DBaseSeries): """Representation for a line consisting of a SymPy expression over a range.""" def __init__(self, expr, var_start_end, **kwargs): super(LineOver1DRangeSeries, self).__init__() self.expr = sympify(expr) self.label = str(self.expr) self.var = sympify(var_start_end[0]) self.start = float(var_start_end[1]) self.end = float(var_start_end[2]) self.nb_of_points = kwargs.get('nb_of_points', 300) self.adaptive = kwargs.get('adaptive', True) self.depth = kwargs.get('depth', 12) self.line_color = kwargs.get('line_color', None) self.xscale=kwargs.get('xscale','linear') self.flag=0 def __str__(self): return 'cartesian line: %s for %s over %s' % ( str(self.expr), str(self.var), str((self.start, self.end))) def get_segments(self): """ Adaptively gets segments for plotting. The adaptive sampling is done by recursively checking if three points are almost collinear. If they are not collinear, then more points are added between those points. References ========== [1] Adaptive polygonal approximation of parametric curves, Luiz Henrique de Figueiredo. """ if self.only_integers or not self.adaptive: return super(LineOver1DRangeSeries, self).get_segments() else: f = lambdify([self.var], self.expr) list_segments = [] np=import_module('numpy') def sample(p, q, depth): """ Samples recursively if three points are almost collinear. For depth < 6, points are added irrespective of whether they satisfy the collinearity condition or not. The maximum depth allowed is 12. """ np = import_module('numpy') #Randomly sample to avoid aliasing. random = 0.45 + np.random.rand() * 0.1 xnew = p[0] + random * (q[0] - p[0]) ynew = f(xnew) new_point = np.array([xnew, ynew]) if self.flag==1: return #Maximum depth if depth > self.depth: if p[1] is None or q[1] is None: self.flag=1 return list_segments.append([p, q]) #Sample irrespective of whether the line is flat till the #depth of 6. We are not using linspace to avoid aliasing. elif depth < 6: sample(p, new_point, depth + 1) sample(new_point, q, depth + 1) #Sample ten points if complex values are encountered #at both ends. If there is a real value in between, then #sample those points further. elif p[1] is None and q[1] is None: if self.xscale is 'log': xarray = np.logspace(p[0],q[0], 10) else: xarray = np.linspace(p[0], q[0], 10) yarray = list(map(f, xarray)) if any(y is not None for y in yarray): for i in range(len(yarray) - 1): if yarray[i] is not None or yarray[i + 1] is not None: sample([xarray[i], yarray[i]], [xarray[i + 1], yarray[i + 1]], depth + 1) #Sample further if one of the end points in None( i.e. a complex #value) or the three points are not almost collinear. elif (p[1] is None or q[1] is None or new_point[1] is None or not flat(p, new_point, q)): sample(p, new_point, depth + 1) sample(new_point, q, depth + 1) else: list_segments.append([p, q]) if self.xscale is 'log': self.start=np.log10(self.start) self.end=np.log10(self.end) f_start = f(self.start) f_end = f(self.end) sample([self.start, f_start], [self.end, f_end], 0) return list_segments def get_points(self): np = import_module('numpy') if self.only_integers is True: if self.xscale is 'log': list_x = np.logspace(int(self.start), int(self.end), num=int(self.end) - int(self.start) + 1) else: list_x = np.linspace(int(self.start), int(self.end), num=int(self.end) - int(self.start) + 1) else: if self.xscale is 'log': list_x = np.logspace(self.start, self.end, num=self.nb_of_points) else: list_x = np.linspace(self.start, self.end, num=self.nb_of_points) f = vectorized_lambdify([self.var], self.expr) list_y = f(list_x) return (list_x, list_y) class Parametric2DLineSeries(Line2DBaseSeries): """Representation for a line consisting of two parametric sympy expressions over a range.""" is_parametric = True def __init__(self, expr_x, expr_y, var_start_end, **kwargs): super(Parametric2DLineSeries, self).__init__() self.expr_x = sympify(expr_x) self.expr_y = sympify(expr_y) self.label = "(%s, %s)" % (str(self.expr_x), str(self.expr_y)) self.var = sympify(var_start_end[0]) self.start = float(var_start_end[1]) self.end = float(var_start_end[2]) self.nb_of_points = kwargs.get('nb_of_points', 300) self.adaptive = kwargs.get('adaptive', True) self.depth = kwargs.get('depth', 12) self.line_color = kwargs.get('line_color', None) def __str__(self): return 'parametric cartesian line: (%s, %s) for %s over %s' % ( str(self.expr_x), str(self.expr_y), str(self.var), str((self.start, self.end))) def get_parameter_points(self): np = import_module('numpy') return np.linspace(self.start, self.end, num=self.nb_of_points) def get_points(self): param = self.get_parameter_points() fx = vectorized_lambdify([self.var], self.expr_x) fy = vectorized_lambdify([self.var], self.expr_y) list_x = fx(param) list_y = fy(param) return (list_x, list_y) def get_segments(self): """ Adaptively gets segments for plotting. The adaptive sampling is done by recursively checking if three points are almost collinear. If they are not collinear, then more points are added between those points. References ========== [1] Adaptive polygonal approximation of parametric curves, Luiz Henrique de Figueiredo. """ if not self.adaptive: return super(Parametric2DLineSeries, self).get_segments() f_x = lambdify([self.var], self.expr_x) f_y = lambdify([self.var], self.expr_y) list_segments = [] def sample(param_p, param_q, p, q, depth): """ Samples recursively if three points are almost collinear. For depth < 6, points are added irrespective of whether they satisfy the collinearity condition or not. The maximum depth allowed is 12. """ #Randomly sample to avoid aliasing. np = import_module('numpy') random = 0.45 + np.random.rand() * 0.1 param_new = param_p + random * (param_q - param_p) xnew = f_x(param_new) ynew = f_y(param_new) new_point = np.array([xnew, ynew]) #Maximum depth if depth > self.depth: list_segments.append([p, q]) #Sample irrespective of whether the line is flat till the #depth of 6. We are not using linspace to avoid aliasing. elif depth < 6: sample(param_p, param_new, p, new_point, depth + 1) sample(param_new, param_q, new_point, q, depth + 1) #Sample ten points if complex values are encountered #at both ends. If there is a real value in between, then #sample those points further. elif ((p[0] is None and q[1] is None) or (p[1] is None and q[1] is None)): param_array = np.linspace(param_p, param_q, 10) x_array = list(map(f_x, param_array)) y_array = list(map(f_y, param_array)) if any(x is not None and y is not None for x, y in zip(x_array, y_array)): for i in range(len(y_array) - 1): if ((x_array[i] is not None and y_array[i] is not None) or (x_array[i + 1] is not None and y_array[i + 1] is not None)): point_a = [x_array[i], y_array[i]] point_b = [x_array[i + 1], y_array[i + 1]] sample(param_array[i], param_array[i], point_a, point_b, depth + 1) #Sample further if one of the end points in None( ie a complex #value) or the three points are not almost collinear. elif (p[0] is None or p[1] is None or q[1] is None or q[0] is None or not flat(p, new_point, q)): sample(param_p, param_new, p, new_point, depth + 1) sample(param_new, param_q, new_point, q, depth + 1) else: list_segments.append([p, q]) f_start_x = f_x(self.start) f_start_y = f_y(self.start) start = [f_start_x, f_start_y] f_end_x = f_x(self.end) f_end_y = f_y(self.end) end = [f_end_x, f_end_y] sample(self.start, self.end, start, end, 0) return list_segments ### 3D lines class Line3DBaseSeries(Line2DBaseSeries): """A base class for 3D lines. Most of the stuff is derived from Line2DBaseSeries.""" is_2Dline = False is_3Dline = True _dim = 3 def __init__(self): super(Line3DBaseSeries, self).__init__() class Parametric3DLineSeries(Line3DBaseSeries): """Representation for a 3D line consisting of two parametric sympy expressions and a range.""" def __init__(self, expr_x, expr_y, expr_z, var_start_end, **kwargs): super(Parametric3DLineSeries, self).__init__() self.expr_x = sympify(expr_x) self.expr_y = sympify(expr_y) self.expr_z = sympify(expr_z) self.label = "(%s, %s)" % (str(self.expr_x), str(self.expr_y)) self.var = sympify(var_start_end[0]) self.start = float(var_start_end[1]) self.end = float(var_start_end[2]) self.nb_of_points = kwargs.get('nb_of_points', 300) self.line_color = kwargs.get('line_color', None) def __str__(self): return '3D parametric cartesian line: (%s, %s, %s) for %s over %s' % ( str(self.expr_x), str(self.expr_y), str(self.expr_z), str(self.var), str((self.start, self.end))) def get_parameter_points(self): np = import_module('numpy') return np.linspace(self.start, self.end, num=self.nb_of_points) def get_points(self): param = self.get_parameter_points() fx = vectorized_lambdify([self.var], self.expr_x) fy = vectorized_lambdify([self.var], self.expr_y) fz = vectorized_lambdify([self.var], self.expr_z) list_x = fx(param) list_y = fy(param) list_z = fz(param) return (list_x, list_y, list_z) ### Surfaces class SurfaceBaseSeries(BaseSeries): """A base class for 3D surfaces.""" is_3Dsurface = True def __init__(self): super(SurfaceBaseSeries, self).__init__() self.surface_color = None def get_color_array(self): np = import_module('numpy') c = self.surface_color if isinstance(c, Callable): f = np.vectorize(c) nargs = arity(c) if self.is_parametric: variables = list(map(centers_of_faces, self.get_parameter_meshes())) if nargs == 1: return f(variables[0]) elif nargs == 2: return f(*variables) variables = list(map(centers_of_faces, self.get_meshes())) if nargs == 1: return f(variables[0]) elif nargs == 2: return f(*variables[:2]) else: return f(*variables) else: return c*np.ones(self.nb_of_points) class SurfaceOver2DRangeSeries(SurfaceBaseSeries): """Representation for a 3D surface consisting of a sympy expression and 2D range.""" def __init__(self, expr, var_start_end_x, var_start_end_y, **kwargs): super(SurfaceOver2DRangeSeries, self).__init__() self.expr = sympify(expr) self.var_x = sympify(var_start_end_x[0]) self.start_x = float(var_start_end_x[1]) self.end_x = float(var_start_end_x[2]) self.var_y = sympify(var_start_end_y[0]) self.start_y = float(var_start_end_y[1]) self.end_y = float(var_start_end_y[2]) self.nb_of_points_x = kwargs.get('nb_of_points_x', 50) self.nb_of_points_y = kwargs.get('nb_of_points_y', 50) self.surface_color = kwargs.get('surface_color', None) def __str__(self): return ('cartesian surface: %s for' ' %s over %s and %s over %s') % ( str(self.expr), str(self.var_x), str((self.start_x, self.end_x)), str(self.var_y), str((self.start_y, self.end_y))) def get_meshes(self): np = import_module('numpy') mesh_x, mesh_y = np.meshgrid(np.linspace(self.start_x, self.end_x, num=self.nb_of_points_x), np.linspace(self.start_y, self.end_y, num=self.nb_of_points_y)) f = vectorized_lambdify((self.var_x, self.var_y), self.expr) return (mesh_x, mesh_y, f(mesh_x, mesh_y)) class ParametricSurfaceSeries(SurfaceBaseSeries): """Representation for a 3D surface consisting of three parametric sympy expressions and a range.""" is_parametric = True def __init__( self, expr_x, expr_y, expr_z, var_start_end_u, var_start_end_v, **kwargs): super(ParametricSurfaceSeries, self).__init__() self.expr_x = sympify(expr_x) self.expr_y = sympify(expr_y) self.expr_z = sympify(expr_z) self.var_u = sympify(var_start_end_u[0]) self.start_u = float(var_start_end_u[1]) self.end_u = float(var_start_end_u[2]) self.var_v = sympify(var_start_end_v[0]) self.start_v = float(var_start_end_v[1]) self.end_v = float(var_start_end_v[2]) self.nb_of_points_u = kwargs.get('nb_of_points_u', 50) self.nb_of_points_v = kwargs.get('nb_of_points_v', 50) self.surface_color = kwargs.get('surface_color', None) def __str__(self): return ('parametric cartesian surface: (%s, %s, %s) for' ' %s over %s and %s over %s') % ( str(self.expr_x), str(self.expr_y), str(self.expr_z), str(self.var_u), str((self.start_u, self.end_u)), str(self.var_v), str((self.start_v, self.end_v))) def get_parameter_meshes(self): np = import_module('numpy') return np.meshgrid(np.linspace(self.start_u, self.end_u, num=self.nb_of_points_u), np.linspace(self.start_v, self.end_v, num=self.nb_of_points_v)) def get_meshes(self): mesh_u, mesh_v = self.get_parameter_meshes() fx = vectorized_lambdify((self.var_u, self.var_v), self.expr_x) fy = vectorized_lambdify((self.var_u, self.var_v), self.expr_y) fz = vectorized_lambdify((self.var_u, self.var_v), self.expr_z) return (fx(mesh_u, mesh_v), fy(mesh_u, mesh_v), fz(mesh_u, mesh_v)) ### Contours class ContourSeries(BaseSeries): """Representation for a contour plot.""" # The code is mostly repetition of SurfaceOver2DRange. # Presently used in contour_plot function is_contour = True def __init__(self, expr, var_start_end_x, var_start_end_y): super(ContourSeries, self).__init__() self.nb_of_points_x = 50 self.nb_of_points_y = 50 self.expr = sympify(expr) self.var_x = sympify(var_start_end_x[0]) self.start_x = float(var_start_end_x[1]) self.end_x = float(var_start_end_x[2]) self.var_y = sympify(var_start_end_y[0]) self.start_y = float(var_start_end_y[1]) self.end_y = float(var_start_end_y[2]) self.get_points = self.get_meshes def __str__(self): return ('contour: %s for ' '%s over %s and %s over %s') % ( str(self.expr), str(self.var_x), str((self.start_x, self.end_x)), str(self.var_y), str((self.start_y, self.end_y))) def get_meshes(self): np = import_module('numpy') mesh_x, mesh_y = np.meshgrid(np.linspace(self.start_x, self.end_x, num=self.nb_of_points_x), np.linspace(self.start_y, self.end_y, num=self.nb_of_points_y)) f = vectorized_lambdify((self.var_x, self.var_y), self.expr) return (mesh_x, mesh_y, f(mesh_x, mesh_y)) ############################################################################## # Backends ############################################################################## class BaseBackend(object): def __init__(self, parent): super(BaseBackend, self).__init__() self.parent = parent ## don't have to check for the success of importing matplotlib in each case; ## we will only be using this backend if we can successfully import matploblib class MatplotlibBackend(BaseBackend): def __init__(self, parent): super(MatplotlibBackend, self).__init__(parent) self.matplotlib = import_module('matplotlib', __import__kwargs={'fromlist': ['pyplot', 'cm', 'collections']}, min_module_version='1.1.0', catch=(RuntimeError,)) self.plt = self.matplotlib.pyplot self.cm = self.matplotlib.cm self.LineCollection = self.matplotlib.collections.LineCollection if isinstance(self.parent, Plot): nrows, ncolumns = 1, 1 series_list = [self.parent._series] elif isinstance(self.parent, PlotGrid): nrows, ncolumns = self.parent.nrows, self.parent.ncolumns series_list = self.parent._series self.ax = [] self.fig = self.plt.figure() for i, series in enumerate(series_list): are_3D = [s.is_3D for s in series] if any(are_3D) and not all(are_3D): raise ValueError('The matplotlib backend can not mix 2D and 3D.') elif all(are_3D): # mpl_toolkits.mplot3d is necessary for # projection='3d' mpl_toolkits = import_module('mpl_toolkits', __import__kwargs={'fromlist': ['mplot3d']}) self.ax.append(self.fig.add_subplot(nrows, ncolumns, i + 1, projection='3d')) elif not any(are_3D): self.ax.append(self.fig.add_subplot(nrows, ncolumns, i + 1)) self.ax[i].spines['left'].set_position('zero') self.ax[i].spines['right'].set_color('none') self.ax[i].spines['bottom'].set_position('zero') self.ax[i].spines['top'].set_color('none') self.ax[i].spines['left'].set_smart_bounds(True) self.ax[i].spines['bottom'].set_smart_bounds(False) self.ax[i].xaxis.set_ticks_position('bottom') self.ax[i].yaxis.set_ticks_position('left') def _process_series(self, series, ax, parent): for s in series: # Create the collections if s.is_2Dline: collection = self.LineCollection(s.get_segments()) ax.add_collection(collection) elif s.is_contour: ax.contour(*s.get_meshes()) elif s.is_3Dline: # TODO too complicated, I blame matplotlib mpl_toolkits = import_module('mpl_toolkits', __import__kwargs={'fromlist': ['mplot3d']}) art3d = mpl_toolkits.mplot3d.art3d collection = art3d.Line3DCollection(s.get_segments()) ax.add_collection(collection) x, y, z = s.get_points() ax.set_xlim((min(x), max(x))) ax.set_ylim((min(y), max(y))) ax.set_zlim((min(z), max(z))) elif s.is_3Dsurface: x, y, z = s.get_meshes() collection = ax.plot_surface(x, y, z, cmap=getattr(self.cm, 'viridis', self.cm.jet), rstride=1, cstride=1, linewidth=0.1) elif s.is_implicit: # Smart bounds have to be set to False for implicit plots. ax.spines['left'].set_smart_bounds(False) ax.spines['bottom'].set_smart_bounds(False) points = s.get_raster() if len(points) == 2: # interval math plotting x, y = _matplotlib_list(points[0]) ax.fill(x, y, facecolor=s.line_color, edgecolor='None') else: # use contourf or contour depending on whether it is # an inequality or equality. # XXX: ``contour`` plots multiple lines. Should be fixed. ListedColormap = self.matplotlib.colors.ListedColormap colormap = ListedColormap(["white", s.line_color]) xarray, yarray, zarray, plot_type = points if plot_type == 'contour': ax.contour(xarray, yarray, zarray, cmap=colormap) else: ax.contourf(xarray, yarray, zarray, cmap=colormap) else: raise ValueError('The matplotlib backend supports only ' 'is_2Dline, is_3Dline, is_3Dsurface and ' 'is_contour objects.') # Customise the collections with the corresponding per-series # options. if hasattr(s, 'label'): collection.set_label(s.label) if s.is_line and s.line_color: if isinstance(s.line_color, (float, int)) or isinstance(s.line_color, Callable): color_array = s.get_color_array() collection.set_array(color_array) else: collection.set_color(s.line_color) if s.is_3Dsurface and s.surface_color: if self.matplotlib.__version__ < "1.2.0": # TODO in the distant future remove this check warnings.warn('The version of matplotlib is too old to use surface coloring.') elif isinstance(s.surface_color, (float, int)) or isinstance(s.surface_color, Callable): color_array = s.get_color_array() color_array = color_array.reshape(color_array.size) collection.set_array(color_array) else: collection.set_color(s.surface_color) # Set global options. # TODO The 3D stuff # XXX The order of those is important. mpl_toolkits = import_module('mpl_toolkits', __import__kwargs={'fromlist': ['mplot3d']}) Axes3D = mpl_toolkits.mplot3d.Axes3D if parent.xscale and not isinstance(ax, Axes3D): ax.set_xscale(parent.xscale) if parent.yscale and not isinstance(ax, Axes3D): ax.set_yscale(parent.yscale) if parent.xlim: from sympy.core.basic import Basic xlim = parent.xlim if any(isinstance(i,Basic) and not i.is_real for i in xlim): raise ValueError( "All numbers from xlim={} must be real".format(xlim)) if any(isinstance(i,Basic) and not i.is_finite for i in xlim): raise ValueError( "All numbers from xlim={} must be finite".format(xlim)) xlim = (float(i) for i in xlim) ax.set_xlim(xlim) else: if all(isinstance(s, LineOver1DRangeSeries) for s in parent._series): starts = [s.start for s in parent._series] ends = [s.end for s in parent._series] ax.set_xlim(min(starts), max(ends)) if parent.ylim: from sympy.core.basic import Basic ylim = parent.ylim if any(isinstance(i,Basic) and not i.is_real for i in ylim): raise ValueError( "All numbers from ylim={} must be real".format(ylim)) if any(isinstance(i,Basic) and not i.is_finite for i in ylim): raise ValueError( "All numbers from ylim={} must be finite".format(ylim)) ylim = (float(i) for i in ylim) ax.set_ylim(ylim) if not isinstance(ax, Axes3D) or self.matplotlib.__version__ >= '1.2.0': # XXX in the distant future remove this check ax.set_autoscale_on(parent.autoscale) if parent.axis_center: val = parent.axis_center if isinstance(ax, Axes3D): pass elif val == 'center': ax.spines['left'].set_position('center') ax.spines['bottom'].set_position('center') elif val == 'auto': xl, xh = ax.get_xlim() yl, yh = ax.get_ylim() pos_left = ('data', 0) if xl*xh <= 0 else 'center' pos_bottom = ('data', 0) if yl*yh <= 0 else 'center' ax.spines['left'].set_position(pos_left) ax.spines['bottom'].set_position(pos_bottom) else: ax.spines['left'].set_position(('data', val[0])) ax.spines['bottom'].set_position(('data', val[1])) if not parent.axis: ax.set_axis_off() if parent.legend: if ax.legend(): ax.legend_.set_visible(parent.legend) if parent.margin: ax.set_xmargin(parent.margin) ax.set_ymargin(parent.margin) if parent.title: ax.set_title(parent.title) if parent.xlabel: ax.set_xlabel(parent.xlabel, position=(1, 0)) if parent.ylabel: ax.set_ylabel(parent.ylabel, position=(0, 1)) def process_series(self): """ Iterates over every ``Plot`` object and further calls _process_series() """ parent = self.parent if isinstance(parent, Plot): series_list = [parent._series] else: series_list = parent._series for i, (series, ax) in enumerate(zip(series_list, self.ax)): if isinstance(self.parent, PlotGrid): parent = self.parent.args[i] self._process_series(series, ax, parent) def show(self): self.process_series() #TODO after fixing https://github.com/ipython/ipython/issues/1255 # you can uncomment the next line and remove the pyplot.show() call #self.fig.show() if _show: self.fig.tight_layout() self.plt.show() else: self.close() def save(self, path): self.process_series() self.fig.savefig(path) def close(self): self.plt.close(self.fig) class TextBackend(BaseBackend): def __init__(self, parent): super(TextBackend, self).__init__(parent) def show(self): if not _show: return if len(self.parent._series) != 1: raise ValueError( 'The TextBackend supports only one graph per Plot.') elif not isinstance(self.parent._series[0], LineOver1DRangeSeries): raise ValueError( 'The TextBackend supports only expressions over a 1D range') else: ser = self.parent._series[0] textplot(ser.expr, ser.start, ser.end) def close(self): pass class DefaultBackend(BaseBackend): def __new__(cls, parent): matplotlib = import_module('matplotlib', min_module_version='1.1.0', catch=(RuntimeError,)) if matplotlib: return MatplotlibBackend(parent) else: return TextBackend(parent) plot_backends = { 'matplotlib': MatplotlibBackend, 'text': TextBackend, 'default': DefaultBackend } ############################################################################## # Finding the centers of line segments or mesh faces ############################################################################## def centers_of_segments(array): np = import_module('numpy') return np.mean(np.vstack((array[:-1], array[1:])), 0) def centers_of_faces(array): np = import_module('numpy') return np.mean(np.dstack((array[:-1, :-1], array[1:, :-1], array[:-1, 1: ], array[:-1, :-1], )), 2) def flat(x, y, z, eps=1e-3): """Checks whether three points are almost collinear""" np = import_module('numpy') # Workaround plotting piecewise (#8577): # workaround for `lambdify` in `.experimental_lambdify` fails # to return numerical values in some cases. Lower-level fix # in `lambdify` is possible. vector_a = (x - y).astype(np.float) vector_b = (z - y).astype(np.float) dot_product = np.dot(vector_a, vector_b) vector_a_norm = np.linalg.norm(vector_a) vector_b_norm = np.linalg.norm(vector_b) cos_theta = dot_product / (vector_a_norm * vector_b_norm) return abs(cos_theta + 1) < eps def _matplotlib_list(interval_list): """ Returns lists for matplotlib ``fill`` command from a list of bounding rectangular intervals """ xlist = [] ylist = [] if len(interval_list): for intervals in interval_list: intervalx = intervals[0] intervaly = intervals[1] xlist.extend([intervalx.start, intervalx.start, intervalx.end, intervalx.end, None]) ylist.extend([intervaly.start, intervaly.end, intervaly.end, intervaly.start, None]) else: #XXX Ugly hack. Matplotlib does not accept empty lists for ``fill`` xlist.extend([None, None, None, None]) ylist.extend([None, None, None, None]) return xlist, ylist ####New API for plotting module #### # TODO: Add color arrays for plots. # TODO: Add more plotting options for 3d plots. # TODO: Adaptive sampling for 3D plots. def plot(*args, **kwargs): """ Plots a function of a single variable and returns an instance of the ``Plot`` class (also, see the description of the ``show`` keyword argument below). The plotting uses an adaptive algorithm which samples recursively to accurately plot the plot. The adaptive algorithm uses a random point near the midpoint of two points that has to be further sampled. Hence the same plots can appear slightly different. Usage ===== Single Plot ``plot(expr, range, **kwargs)`` If the range is not specified, then a default range of (-10, 10) is used. Multiple plots with same range. ``plot(expr1, expr2, ..., range, **kwargs)`` If the range is not specified, then a default range of (-10, 10) is used. Multiple plots with different ranges. ``plot((expr1, range), (expr2, range), ..., **kwargs)`` Range has to be specified for every expression. Default range may change in the future if a more advanced default range detection algorithm is implemented. Arguments ========= ``expr`` : Expression representing the function of single variable ``range``: (x, 0, 5), A 3-tuple denoting the range of the free variable. Keyword Arguments ================= Arguments for ``plot`` function: ``show``: Boolean. The default value is set to ``True``. Set show to ``False`` and the function will not display the plot. The returned instance of the ``Plot`` class can then be used to save or display the plot by calling the ``save()`` and ``show()`` methods respectively. Arguments for ``LineOver1DRangeSeries`` class: ``adaptive``: Boolean. The default value is set to True. Set adaptive to False and specify ``nb_of_points`` if uniform sampling is required. ``depth``: int Recursion depth of the adaptive algorithm. A depth of value ``n`` samples a maximum of `2^{n}` points. ``nb_of_points``: int. Used when the ``adaptive`` is set to False. The function is uniformly sampled at ``nb_of_points`` number of points. Aesthetics options: ``line_color``: float. Specifies the color for the plot. See ``Plot`` to see how to set color for the plots. If there are multiple plots, then the same series series are applied to all the plots. If you want to set these options separately, you can index the ``Plot`` object returned and set it. Arguments for ``Plot`` class: ``title`` : str. Title of the plot. It is set to the latex representation of the expression, if the plot has only one expression. ``xlabel`` : str. Label for the x-axis. ``ylabel`` : str. Label for the y-axis. ``xscale``: {'linear', 'log'} Sets the scaling of the x-axis. ``yscale``: {'linear', 'log'} Sets the scaling if the y-axis. ``axis_center``: tuple of two floats denoting the coordinates of the center or {'center', 'auto'} ``xlim`` : tuple of two floats, denoting the x-axis limits. ``ylim`` : tuple of two floats, denoting the y-axis limits. Examples ======== .. plot:: :context: close-figs :format: doctest :include-source: True >>> from sympy import symbols >>> from sympy.plotting import plot >>> x = symbols('x') Single Plot .. plot:: :context: close-figs :format: doctest :include-source: True >>> plot(x**2, (x, -5, 5)) Plot object containing: [0]: cartesian line: x**2 for x over (-5.0, 5.0) Multiple plots with single range. .. plot:: :context: close-figs :format: doctest :include-source: True >>> plot(x, x**2, x**3, (x, -5, 5)) Plot object containing: [0]: cartesian line: x for x over (-5.0, 5.0) [1]: cartesian line: x**2 for x over (-5.0, 5.0) [2]: cartesian line: x**3 for x over (-5.0, 5.0) Multiple plots with different ranges. .. plot:: :context: close-figs :format: doctest :include-source: True >>> plot((x**2, (x, -6, 6)), (x, (x, -5, 5))) Plot object containing: [0]: cartesian line: x**2 for x over (-6.0, 6.0) [1]: cartesian line: x for x over (-5.0, 5.0) No adaptive sampling. .. plot:: :context: close-figs :format: doctest :include-source: True >>> plot(x**2, adaptive=False, nb_of_points=400) Plot object containing: [0]: cartesian line: x**2 for x over (-10.0, 10.0) See Also ======== Plot, LineOver1DRangeSeries. """ args = list(map(sympify, args)) free = set() for a in args: if isinstance(a, Expr): free |= a.free_symbols if len(free) > 1: raise ValueError( 'The same variable should be used in all ' 'univariate expressions being plotted.') x = free.pop() if free else Symbol('x') kwargs.setdefault('xlabel', x.name) kwargs.setdefault('ylabel', 'f(%s)' % x.name) show = kwargs.pop('show', True) series = [] plot_expr = check_arguments(args, 1, 1) series = [LineOver1DRangeSeries(*arg, **kwargs) for arg in plot_expr] plots = Plot(*series, **kwargs) if show: plots.show() return plots def plot_parametric(*args, **kwargs): """ Plots a 2D parametric plot. The plotting uses an adaptive algorithm which samples recursively to accurately plot the plot. The adaptive algorithm uses a random point near the midpoint of two points that has to be further sampled. Hence the same plots can appear slightly different. Usage ===== Single plot. ``plot_parametric(expr_x, expr_y, range, **kwargs)`` If the range is not specified, then a default range of (-10, 10) is used. Multiple plots with same range. ``plot_parametric((expr1_x, expr1_y), (expr2_x, expr2_y), range, **kwargs)`` If the range is not specified, then a default range of (-10, 10) is used. Multiple plots with different ranges. ``plot_parametric((expr_x, expr_y, range), ..., **kwargs)`` Range has to be specified for every expression. Default range may change in the future if a more advanced default range detection algorithm is implemented. Arguments ========= ``expr_x`` : Expression representing the function along x. ``expr_y`` : Expression representing the function along y. ``range``: (u, 0, 5), A 3-tuple denoting the range of the parameter variable. Keyword Arguments ================= Arguments for ``Parametric2DLineSeries`` class: ``adaptive``: Boolean. The default value is set to True. Set adaptive to False and specify ``nb_of_points`` if uniform sampling is required. ``depth``: int Recursion depth of the adaptive algorithm. A depth of value ``n`` samples a maximum of `2^{n}` points. ``nb_of_points``: int. Used when the ``adaptive`` is set to False. The function is uniformly sampled at ``nb_of_points`` number of points. Aesthetics ---------- ``line_color``: function which returns a float. Specifies the color for the plot. See ``sympy.plotting.Plot`` for more details. If there are multiple plots, then the same Series arguments are applied to all the plots. If you want to set these options separately, you can index the returned ``Plot`` object and set it. Arguments for ``Plot`` class: ``xlabel`` : str. Label for the x-axis. ``ylabel`` : str. Label for the y-axis. ``xscale``: {'linear', 'log'} Sets the scaling of the x-axis. ``yscale``: {'linear', 'log'} Sets the scaling if the y-axis. ``axis_center``: tuple of two floats denoting the coordinates of the center or {'center', 'auto'} ``xlim`` : tuple of two floats, denoting the x-axis limits. ``ylim`` : tuple of two floats, denoting the y-axis limits. Examples ======== .. plot:: :context: reset :format: doctest :include-source: True >>> from sympy import symbols, cos, sin >>> from sympy.plotting import plot_parametric >>> u = symbols('u') Single Parametric plot .. plot:: :context: close-figs :format: doctest :include-source: True >>> plot_parametric(cos(u), sin(u), (u, -5, 5)) Plot object containing: [0]: parametric cartesian line: (cos(u), sin(u)) for u over (-5.0, 5.0) Multiple parametric plot with single range. .. plot:: :context: close-figs :format: doctest :include-source: True >>> plot_parametric((cos(u), sin(u)), (u, cos(u))) Plot object containing: [0]: parametric cartesian line: (cos(u), sin(u)) for u over (-10.0, 10.0) [1]: parametric cartesian line: (u, cos(u)) for u over (-10.0, 10.0) Multiple parametric plots. .. plot:: :context: close-figs :format: doctest :include-source: True >>> plot_parametric((cos(u), sin(u), (u, -5, 5)), ... (cos(u), u, (u, -5, 5))) Plot object containing: [0]: parametric cartesian line: (cos(u), sin(u)) for u over (-5.0, 5.0) [1]: parametric cartesian line: (cos(u), u) for u over (-5.0, 5.0) See Also ======== Plot, Parametric2DLineSeries """ args = list(map(sympify, args)) show = kwargs.pop('show', True) series = [] plot_expr = check_arguments(args, 2, 1) series = [Parametric2DLineSeries(*arg, **kwargs) for arg in plot_expr] plots = Plot(*series, **kwargs) if show: plots.show() return plots def plot3d_parametric_line(*args, **kwargs): """ Plots a 3D parametric line plot. Usage ===== Single plot: ``plot3d_parametric_line(expr_x, expr_y, expr_z, range, **kwargs)`` If the range is not specified, then a default range of (-10, 10) is used. Multiple plots. ``plot3d_parametric_line((expr_x, expr_y, expr_z, range), ..., **kwargs)`` Ranges have to be specified for every expression. Default range may change in the future if a more advanced default range detection algorithm is implemented. Arguments ========= ``expr_x`` : Expression representing the function along x. ``expr_y`` : Expression representing the function along y. ``expr_z`` : Expression representing the function along z. ``range``: ``(u, 0, 5)``, A 3-tuple denoting the range of the parameter variable. Keyword Arguments ================= Arguments for ``Parametric3DLineSeries`` class. ``nb_of_points``: The range is uniformly sampled at ``nb_of_points`` number of points. Aesthetics: ``line_color``: function which returns a float. Specifies the color for the plot. See ``sympy.plotting.Plot`` for more details. If there are multiple plots, then the same series arguments are applied to all the plots. If you want to set these options separately, you can index the returned ``Plot`` object and set it. Arguments for ``Plot`` class. ``title`` : str. Title of the plot. Examples ======== .. plot:: :context: reset :format: doctest :include-source: True >>> from sympy import symbols, cos, sin >>> from sympy.plotting import plot3d_parametric_line >>> u = symbols('u') Single plot. .. plot:: :context: close-figs :format: doctest :include-source: True >>> plot3d_parametric_line(cos(u), sin(u), u, (u, -5, 5)) Plot object containing: [0]: 3D parametric cartesian line: (cos(u), sin(u), u) for u over (-5.0, 5.0) Multiple plots. .. plot:: :context: close-figs :format: doctest :include-source: True >>> plot3d_parametric_line((cos(u), sin(u), u, (u, -5, 5)), ... (sin(u), u**2, u, (u, -5, 5))) Plot object containing: [0]: 3D parametric cartesian line: (cos(u), sin(u), u) for u over (-5.0, 5.0) [1]: 3D parametric cartesian line: (sin(u), u**2, u) for u over (-5.0, 5.0) See Also ======== Plot, Parametric3DLineSeries """ args = list(map(sympify, args)) show = kwargs.pop('show', True) series = [] plot_expr = check_arguments(args, 3, 1) series = [Parametric3DLineSeries(*arg, **kwargs) for arg in plot_expr] plots = Plot(*series, **kwargs) if show: plots.show() return plots def plot3d(*args, **kwargs): """ Plots a 3D surface plot. Usage ===== Single plot ``plot3d(expr, range_x, range_y, **kwargs)`` If the ranges are not specified, then a default range of (-10, 10) is used. Multiple plot with the same range. ``plot3d(expr1, expr2, range_x, range_y, **kwargs)`` If the ranges are not specified, then a default range of (-10, 10) is used. Multiple plots with different ranges. ``plot3d((expr1, range_x, range_y), (expr2, range_x, range_y), ..., **kwargs)`` Ranges have to be specified for every expression. Default range may change in the future if a more advanced default range detection algorithm is implemented. Arguments ========= ``expr`` : Expression representing the function along x. ``range_x``: (x, 0, 5), A 3-tuple denoting the range of the x variable. ``range_y``: (y, 0, 5), A 3-tuple denoting the range of the y variable. Keyword Arguments ================= Arguments for ``SurfaceOver2DRangeSeries`` class: ``nb_of_points_x``: int. The x range is sampled uniformly at ``nb_of_points_x`` of points. ``nb_of_points_y``: int. The y range is sampled uniformly at ``nb_of_points_y`` of points. Aesthetics: ``surface_color``: Function which returns a float. Specifies the color for the surface of the plot. See ``sympy.plotting.Plot`` for more details. If there are multiple plots, then the same series arguments are applied to all the plots. If you want to set these options separately, you can index the returned ``Plot`` object and set it. Arguments for ``Plot`` class: ``title`` : str. Title of the plot. Examples ======== .. plot:: :context: reset :format: doctest :include-source: True >>> from sympy import symbols >>> from sympy.plotting import plot3d >>> x, y = symbols('x y') Single plot .. plot:: :context: close-figs :format: doctest :include-source: True >>> plot3d(x*y, (x, -5, 5), (y, -5, 5)) Plot object containing: [0]: cartesian surface: x*y for x over (-5.0, 5.0) and y over (-5.0, 5.0) Multiple plots with same range .. plot:: :context: close-figs :format: doctest :include-source: True >>> plot3d(x*y, -x*y, (x, -5, 5), (y, -5, 5)) Plot object containing: [0]: cartesian surface: x*y for x over (-5.0, 5.0) and y over (-5.0, 5.0) [1]: cartesian surface: -x*y for x over (-5.0, 5.0) and y over (-5.0, 5.0) Multiple plots with different ranges. .. plot:: :context: close-figs :format: doctest :include-source: True >>> plot3d((x**2 + y**2, (x, -5, 5), (y, -5, 5)), ... (x*y, (x, -3, 3), (y, -3, 3))) Plot object containing: [0]: cartesian surface: x**2 + y**2 for x over (-5.0, 5.0) and y over (-5.0, 5.0) [1]: cartesian surface: x*y for x over (-3.0, 3.0) and y over (-3.0, 3.0) See Also ======== Plot, SurfaceOver2DRangeSeries """ args = list(map(sympify, args)) show = kwargs.pop('show', True) series = [] plot_expr = check_arguments(args, 1, 2) series = [SurfaceOver2DRangeSeries(*arg, **kwargs) for arg in plot_expr] plots = Plot(*series, **kwargs) if show: plots.show() return plots def plot3d_parametric_surface(*args, **kwargs): """ Plots a 3D parametric surface plot. Usage ===== Single plot. ``plot3d_parametric_surface(expr_x, expr_y, expr_z, range_u, range_v, **kwargs)`` If the ranges is not specified, then a default range of (-10, 10) is used. Multiple plots. ``plot3d_parametric_surface((expr_x, expr_y, expr_z, range_u, range_v), ..., **kwargs)`` Ranges have to be specified for every expression. Default range may change in the future if a more advanced default range detection algorithm is implemented. Arguments ========= ``expr_x``: Expression representing the function along ``x``. ``expr_y``: Expression representing the function along ``y``. ``expr_z``: Expression representing the function along ``z``. ``range_u``: ``(u, 0, 5)``, A 3-tuple denoting the range of the ``u`` variable. ``range_v``: ``(v, 0, 5)``, A 3-tuple denoting the range of the v variable. Keyword Arguments ================= Arguments for ``ParametricSurfaceSeries`` class: ``nb_of_points_u``: int. The ``u`` range is sampled uniformly at ``nb_of_points_v`` of points ``nb_of_points_y``: int. The ``v`` range is sampled uniformly at ``nb_of_points_y`` of points Aesthetics: ``surface_color``: Function which returns a float. Specifies the color for the surface of the plot. See ``sympy.plotting.Plot`` for more details. If there are multiple plots, then the same series arguments are applied for all the plots. If you want to set these options separately, you can index the returned ``Plot`` object and set it. Arguments for ``Plot`` class: ``title`` : str. Title of the plot. Examples ======== .. plot:: :context: reset :format: doctest :include-source: True >>> from sympy import symbols, cos, sin >>> from sympy.plotting import plot3d_parametric_surface >>> u, v = symbols('u v') Single plot. .. plot:: :context: close-figs :format: doctest :include-source: True >>> plot3d_parametric_surface(cos(u + v), sin(u - v), u - v, ... (u, -5, 5), (v, -5, 5)) Plot object containing: [0]: parametric cartesian surface: (cos(u + v), sin(u - v), u - v) for u over (-5.0, 5.0) and v over (-5.0, 5.0) See Also ======== Plot, ParametricSurfaceSeries """ args = list(map(sympify, args)) show = kwargs.pop('show', True) series = [] plot_expr = check_arguments(args, 3, 2) series = [ParametricSurfaceSeries(*arg, **kwargs) for arg in plot_expr] plots = Plot(*series, **kwargs) if show: plots.show() return plots def plot_contour(*args, **kwargs): """ Draws contour plot of a function Usage ===== Single plot ``plot_contour(expr, range_x, range_y, **kwargs)`` If the ranges are not specified, then a default range of (-10, 10) is used. Multiple plot with the same range. ``plot_contour(expr1, expr2, range_x, range_y, **kwargs)`` If the ranges are not specified, then a default range of (-10, 10) is used. Multiple plots with different ranges. ``plot_contour((expr1, range_x, range_y), (expr2, range_x, range_y), ..., **kwargs)`` Ranges have to be specified for every expression. Default range may change in the future if a more advanced default range detection algorithm is implemented. Arguments ========= ``expr`` : Expression representing the function along x. ``range_x``: (x, 0, 5), A 3-tuple denoting the range of the x variable. ``range_y``: (y, 0, 5), A 3-tuple denoting the range of the y variable. Keyword Arguments ================= Arguments for ``ContourSeries`` class: ``nb_of_points_x``: int. The x range is sampled uniformly at ``nb_of_points_x`` of points. ``nb_of_points_y``: int. The y range is sampled uniformly at ``nb_of_points_y`` of points. Aesthetics: ``surface_color``: Function which returns a float. Specifies the color for the surface of the plot. See ``sympy.plotting.Plot`` for more details. If there are multiple plots, then the same series arguments are applied to all the plots. If you want to set these options separately, you can index the returned ``Plot`` object and set it. Arguments for ``Plot`` class: ``title`` : str. Title of the plot. See Also ======== Plot, ContourSeries """ args = list(map(sympify, args)) show = kwargs.pop('show', True) plot_expr = check_arguments(args, 1, 2) series = [ContourSeries(*arg) for arg in plot_expr] plot_contours = Plot(*series, **kwargs) if len(plot_expr[0].free_symbols) > 2: raise ValueError('Contour Plot cannot Plot for more than two variables.') if show: plot_contours.show() return plot_contours def check_arguments(args, expr_len, nb_of_free_symbols): """ Checks the arguments and converts into tuples of the form (exprs, ranges) Examples ======== .. plot:: :context: reset :format: doctest :include-source: True >>> from sympy import plot, cos, sin, symbols >>> from sympy.plotting.plot import check_arguments >>> x = symbols('x') >>> check_arguments([cos(x), sin(x)], 2, 1) [(cos(x), sin(x), (x, -10, 10))] >>> check_arguments([x, x**2], 1, 1) [(x, (x, -10, 10)), (x**2, (x, -10, 10))] """ if expr_len > 1 and isinstance(args[0], Expr): # Multiple expressions same range. # The arguments are tuples when the expression length is # greater than 1. if len(args) < expr_len: raise ValueError("len(args) should not be less than expr_len") for i in range(len(args)): if isinstance(args[i], Tuple): break else: i = len(args) + 1 exprs = Tuple(*args[:i]) free_symbols = list(set().union(*[e.free_symbols for e in exprs])) if len(args) == expr_len + nb_of_free_symbols: #Ranges given plots = [exprs + Tuple(*args[expr_len:])] else: default_range = Tuple(-10, 10) ranges = [] for symbol in free_symbols: ranges.append(Tuple(symbol) + default_range) for i in range(len(free_symbols) - nb_of_free_symbols): ranges.append(Tuple(Dummy()) + default_range) plots = [exprs + Tuple(*ranges)] return plots if isinstance(args[0], Expr) or (isinstance(args[0], Tuple) and len(args[0]) == expr_len and expr_len != 3): # Cannot handle expressions with number of expression = 3. It is # not possible to differentiate between expressions and ranges. #Series of plots with same range for i in range(len(args)): if isinstance(args[i], Tuple) and len(args[i]) != expr_len: break if not isinstance(args[i], Tuple): args[i] = Tuple(args[i]) else: i = len(args) + 1 exprs = args[:i] assert all(isinstance(e, Expr) for expr in exprs for e in expr) free_symbols = list(set().union(*[e.free_symbols for expr in exprs for e in expr])) if len(free_symbols) > nb_of_free_symbols: raise ValueError("The number of free_symbols in the expression " "is greater than %d" % nb_of_free_symbols) if len(args) == i + nb_of_free_symbols and isinstance(args[i], Tuple): ranges = Tuple(*[range_expr for range_expr in args[ i:i + nb_of_free_symbols]]) plots = [expr + ranges for expr in exprs] return plots else: #Use default ranges. default_range = Tuple(-10, 10) ranges = [] for symbol in free_symbols: ranges.append(Tuple(symbol) + default_range) for i in range(nb_of_free_symbols - len(free_symbols)): ranges.append(Tuple(Dummy()) + default_range) ranges = Tuple(*ranges) plots = [expr + ranges for expr in exprs] return plots elif isinstance(args[0], Tuple) and len(args[0]) == expr_len + nb_of_free_symbols: #Multiple plots with different ranges. for arg in args: for i in range(expr_len): if not isinstance(arg[i], Expr): raise ValueError("Expected an expression, given %s" % str(arg[i])) for i in range(nb_of_free_symbols): if not len(arg[i + expr_len]) == 3: raise ValueError("The ranges should be a tuple of " "length 3, got %s" % str(arg[i + expr_len])) return args
7ac9ef38e7669c7b24f8d47baa616f02c2d48eab524908b882edfef6938ecda8
from sympy import symbols, pi, oo, S, exp, sqrt, besselk, Indexed from sympy.stats import density from sympy.stats.joint_rv import marginal_distribution from sympy.stats.joint_rv_types import JointRV from sympy.stats.crv_types import Normal from sympy.utilities.pytest import raises, XFAIL from sympy.integrals.integrals import integrate from sympy.matrices import Matrix x, y, z, a, b = symbols('x y z a b') def test_Normal(): m = Normal('A', [1, 2], [[1, 0], [0, 1]]) assert density(m)(1, 2) == 1/(2*pi) raises (ValueError, lambda:m[2]) raises (ValueError,\ lambda: Normal('M',[1, 2], [[0, 0], [0, 1]])) n = Normal('B', [1, 2, 3], [[1, 0, 0], [0, 1, 0], [0, 0, 1]]) p = Normal('C', Matrix([1, 2]), Matrix([[1, 0], [0, 1]])) assert density(m)(x, y) == density(p)(x, y) assert marginal_distribution(n, 0, 1)(1, 2) == 1/(2*pi) assert integrate(density(m)(x, y), (x, -oo, oo), (y, -oo, oo)).evalf() == 1 N = Normal('N', [1, 2], [[x, 0], [0, y]]) assert density(N)(0, 0) == exp(-2/y - 1/(2*x))/(2*pi*sqrt(x*y)) raises (ValueError, lambda: Normal('M', [1, 2], [[1, 1], [1, -1]])) def test_MultivariateTDist(): from sympy.stats.joint_rv_types import MultivariateT t1 = MultivariateT('T', [0, 0], [[1, 0], [0, 1]], 2) assert(density(t1))(1, 1) == 1/(8*pi) assert integrate(density(t1)(x, y), (x, -oo, oo), \ (y, -oo, oo)).evalf() == 1 raises(ValueError, lambda: MultivariateT('T', [1, 2], [[1, 1], [1, -1]], 1)) t2 = MultivariateT('t2', [1, 2], [[x, 0], [0, y]], 1) assert density(t2)(1, 2) == 1/(2*pi*sqrt(x*y)) def test_multivariate_laplace(): from sympy.stats.crv_types import Laplace raises(ValueError, lambda: Laplace('T', [1, 2], [[1, 2], [2, 1]])) L = Laplace('L', [1, 0], [[1, 2], [0, 1]]) assert density(L)(2, 3) == exp(2)*besselk(0, sqrt(3))/pi L1 = Laplace('L1', [1, 2], [[x, 0], [0, y]]) assert density(L1)(0, 1) == \ exp(2/y)*besselk(0, sqrt((2 + 4/y + 1/x)/y))/(pi*sqrt(x*y)) def test_NormalGamma(): from sympy.stats.joint_rv_types import NormalGamma from sympy import gamma ng = NormalGamma('G', 1, 2, 3, 4) assert density(ng)(1, 1) == 32*exp(-4)/sqrt(pi) raises(ValueError, lambda:NormalGamma('G', 1, 2, 3, -1)) assert marginal_distribution(ng, 0)(1) == \ 3*sqrt(10)*gamma(S(7)/4)/(10*sqrt(pi)*gamma(S(5)/4)) assert marginal_distribution(ng, y)(1) == exp(-S(1)/4)/128 def test_JointPSpace_margial_distribution(): from sympy.stats.joint_rv_types import MultivariateT from sympy import polar_lift T = MultivariateT('T', [0, 0], [[1, 0], [0, 1]], 2) assert marginal_distribution(T, T[1])(x) == sqrt(2)*(x**2 + 2)/( 8*polar_lift(x**2/2 + 1)**(S(5)/2)) assert integrate(marginal_distribution(T, 1)(x), (x, -oo, oo)) == 1 t = MultivariateT('T', [0, 0, 0], [[1, 0, 0], [0, 1, 0], [0, 0, 1]], 3) assert marginal_distribution(t, 0)(1).evalf().round(1) == 0.2 def test_JointRV(): from sympy.stats.joint_rv import JointDistributionHandmade x1, x2 = (Indexed('x', i) for i in (1, 2)) pdf = exp(-x1**2/2 + x1 - x2**2/2 - S(1)/2)/(2*pi) X = JointRV('x', pdf) assert density(X)(1, 2) == exp(-2)/(2*pi) assert isinstance(X.pspace.distribution, JointDistributionHandmade) assert marginal_distribution(X, 0)(2) == sqrt(2)*exp(-S(1)/2)/(2*sqrt(pi)) def test_expectation(): from sympy import simplify from sympy.stats import E m = Normal('A', [x, y], [[1, 0], [0, 1]]) assert simplify(E(m[1])) == y @XFAIL def test_joint_vector_expectation(): from sympy.stats import E m = Normal('A', [x, y], [[1, 0], [0, 1]]) assert E(m) == (x, y)
9d303d25295d4f41ee329b9464ba2abf2d23d3dc6548bdcc8dbcbf9289a3e518
from sympy import (Symbol, Abs, exp, S, N, pi, simplify, Interval, erf, erfc, Ne, Eq, log, lowergamma, uppergamma, Sum, symbols, sqrt, And, gamma, beta, Piecewise, Integral, sin, cos, atan, besseli, factorial, binomial, floor, expand_func, Rational, I, re, im, lambdify, hyper, diff, Or, Mul) from sympy.core.compatibility import range from sympy.external import import_module from sympy.stats import (P, E, where, density, variance, covariance, skewness, given, pspace, cdf, characteristic_function, ContinuousRV, sample, Arcsin, Benini, Beta, BetaPrime, Cauchy, Chi, ChiSquared, ChiNoncentral, Dagum, Erlang, Exponential, FDistribution, FisherZ, Frechet, Gamma, GammaInverse, Gompertz, Gumbel, Kumaraswamy, Laplace, Logistic, LogNormal, Maxwell, Nakagami, Normal, Pareto, QuadraticU, RaisedCosine, Rayleigh, ShiftedGompertz, StudentT, Trapezoidal, Triangular, Uniform, UniformSum, VonMises, Weibull, WignerSemicircle, correlation, moment, cmoment, smoment) from sympy.stats.crv_types import NormalDistribution from sympy.stats.joint_rv import JointPSpace from sympy.utilities.pytest import raises, XFAIL, slow, skip from sympy.utilities.randtest import verify_numerically as tn oo = S.Infinity x, y, z = map(Symbol, 'xyz') def test_single_normal(): mu = Symbol('mu', real=True, finite=True) sigma = Symbol('sigma', real=True, positive=True, finite=True) X = Normal('x', 0, 1) Y = X*sigma + mu assert simplify(E(Y)) == mu assert simplify(variance(Y)) == sigma**2 pdf = density(Y) x = Symbol('x') assert (pdf(x) == 2**S.Half*exp(-(mu - x)**2/(2*sigma**2))/(2*pi**S.Half*sigma)) assert P(X**2 < 1) == erf(2**S.Half/2) assert E(X, Eq(X, mu)) == mu @XFAIL def test_conditional_1d(): X = Normal('x', 0, 1) Y = given(X, X >= 0) assert density(Y) == 2 * density(X) assert Y.pspace.domain.set == Interval(0, oo) assert E(Y) == sqrt(2) / sqrt(pi) assert E(X**2) == E(Y**2) def test_ContinuousDomain(): X = Normal('x', 0, 1) assert where(X**2 <= 1).set == Interval(-1, 1) assert where(X**2 <= 1).symbol == X.symbol where(And(X**2 <= 1, X >= 0)).set == Interval(0, 1) raises(ValueError, lambda: where(sin(X) > 1)) Y = given(X, X >= 0) assert Y.pspace.domain.set == Interval(0, oo) @slow def test_multiple_normal(): X, Y = Normal('x', 0, 1), Normal('y', 0, 1) assert E(X + Y) == 0 assert variance(X + Y) == 2 assert variance(X + X) == 4 assert covariance(X, Y) == 0 assert covariance(2*X + Y, -X) == -2*variance(X) assert skewness(X) == 0 assert skewness(X + Y) == 0 assert correlation(X, Y) == 0 assert correlation(X, X + Y) == correlation(X, X - Y) assert moment(X, 2) == 1 assert cmoment(X, 3) == 0 assert moment(X + Y, 4) == 12 assert cmoment(X, 2) == variance(X) assert smoment(X*X, 2) == 1 assert smoment(X + Y, 3) == skewness(X + Y) assert E(X, Eq(X + Y, 0)) == 0 assert variance(X, Eq(X + Y, 0)) == S.Half def test_symbolic(): mu1, mu2 = symbols('mu1 mu2', real=True, finite=True) s1, s2 = symbols('sigma1 sigma2', real=True, finite=True, positive=True) rate = Symbol('lambda', real=True, positive=True, finite=True) X = Normal('x', mu1, s1) Y = Normal('y', mu2, s2) Z = Exponential('z', rate) a, b, c = symbols('a b c', real=True, finite=True) assert E(X) == mu1 assert E(X + Y) == mu1 + mu2 assert E(a*X + b) == a*E(X) + b assert variance(X) == s1**2 assert simplify(variance(X + a*Y + b)) == variance(X) + a**2*variance(Y) assert E(Z) == 1/rate assert E(a*Z + b) == a*E(Z) + b assert E(X + a*Z + b) == mu1 + a/rate + b def test_cdf(): X = Normal('x', 0, 1) d = cdf(X) assert P(X < 1) == d(1).rewrite(erfc) assert d(0) == S.Half d = cdf(X, X > 0) # given X>0 assert d(0) == 0 Y = Exponential('y', 10) d = cdf(Y) assert d(-5) == 0 assert P(Y > 3) == 1 - d(3) raises(ValueError, lambda: cdf(X + Y)) Z = Exponential('z', 1) f = cdf(Z) z = Symbol('z') assert f(z) == Piecewise((1 - exp(-z), z >= 0), (0, True)) def test_characteristic_function(): X = Uniform('x', 0, 1) cf = characteristic_function(X) assert cf(1) == -I*(-1 + exp(I)) Y = Normal('y', 1, 1) cf = characteristic_function(Y) assert cf(0) == 1 assert simplify(cf(1)) == exp(I - S(1)/2) Z = Exponential('z', 5) cf = characteristic_function(Z) assert cf(0) == 1 assert simplify(cf(1)) == S(25)/26 + 5*I/26 def test_sample_continuous(): z = Symbol('z') Z = ContinuousRV(z, exp(-z), set=Interval(0, oo)) assert sample(Z) in Z.pspace.domain.set sym, val = list(Z.pspace.sample().items())[0] assert sym == Z and val in Interval(0, oo) assert density(Z)(-1) == 0 def test_ContinuousRV(): x = Symbol('x') pdf = sqrt(2)*exp(-x**2/2)/(2*sqrt(pi)) # Normal distribution # X and Y should be equivalent X = ContinuousRV(x, pdf) Y = Normal('y', 0, 1) assert variance(X) == variance(Y) assert P(X > 0) == P(Y > 0) def test_arcsin(): from sympy import asin a = Symbol("a", real=True) b = Symbol("b", real=True) X = Arcsin('x', a, b) assert density(X)(x) == 1/(pi*sqrt((-x + b)*(x - a))) assert cdf(X)(x) == Piecewise((0, a > x), (2*asin(sqrt((-a + x)/(-a + b)))/pi, b >= x), (1, True)) def test_benini(): alpha = Symbol("alpha", positive=True) beta = Symbol("beta", positive=True) sigma = Symbol("sigma", positive=True) X = Benini('x', alpha, beta, sigma) assert density(X)(x) == ((alpha/x + 2*beta*log(x/sigma)/x) *exp(-alpha*log(x/sigma) - beta*log(x/sigma)**2)) alpha = Symbol("alpha", positive=False) raises(ValueError, lambda: Benini('x', alpha, beta, sigma)) beta = Symbol("beta", positive=False) raises(ValueError, lambda: Benini('x', alpha, beta, sigma)) alpha = Symbol("alpha", positive=True) raises(ValueError, lambda: Benini('x', alpha, beta, sigma)) beta = Symbol("beta", positive=True) sigma = Symbol("sigma", positive=False) raises(ValueError, lambda: Benini('x', alpha, beta, sigma)) def test_beta(): a, b = symbols('alpha beta', positive=True) B = Beta('x', a, b) assert pspace(B).domain.set == Interval(0, 1) dens = density(B) x = Symbol('x') assert dens(x) == x**(a - 1)*(1 - x)**(b - 1) / beta(a, b) assert simplify(E(B)) == a / (a + b) assert simplify(variance(B)) == a*b / (a**3 + 3*a**2*b + a**2 + 3*a*b**2 + 2*a*b + b**3 + b**2) # Full symbolic solution is too much, test with numeric version a, b = 1, 2 B = Beta('x', a, b) assert expand_func(E(B)) == a / S(a + b) assert expand_func(variance(B)) == (a*b) / S((a + b)**2 * (a + b + 1)) def test_betaprime(): alpha = Symbol("alpha", positive=True) betap = Symbol("beta", positive=True) X = BetaPrime('x', alpha, betap) assert density(X)(x) == x**(alpha - 1)*(x + 1)**(-alpha - betap)/beta(alpha, betap) alpha = Symbol("alpha", positive=False) raises(ValueError, lambda: BetaPrime('x', alpha, betap)) alpha = Symbol("alpha", positive=True) betap = Symbol("beta", positive=False) raises(ValueError, lambda: BetaPrime('x', alpha, betap)) def test_cauchy(): x0 = Symbol("x0") gamma = Symbol("gamma", positive=True) X = Cauchy('x', x0, gamma) assert density(X)(x) == 1/(pi*gamma*(1 + (x - x0)**2/gamma**2)) assert cdf(X)(x) == atan((x - x0)/gamma)/pi + S.Half assert diff(cdf(X)(x), x) == density(X)(x) gamma = Symbol("gamma", positive=False) raises(ValueError, lambda: Cauchy('x', x0, gamma)) def test_chi(): k = Symbol("k", integer=True) X = Chi('x', k) assert density(X)(x) == 2**(-k/2 + 1)*x**(k - 1)*exp(-x**2/2)/gamma(k/2) k = Symbol("k", integer=True, positive=False) raises(ValueError, lambda: Chi('x', k)) k = Symbol("k", integer=False, positive=True) raises(ValueError, lambda: Chi('x', k)) def test_chi_noncentral(): k = Symbol("k", integer=True) l = Symbol("l") X = ChiNoncentral("x", k, l) assert density(X)(x) == (x**k*l*(x*l)**(-k/2)* exp(-x**2/2 - l**2/2)*besseli(k/2 - 1, x*l)) k = Symbol("k", integer=True, positive=False) raises(ValueError, lambda: ChiNoncentral('x', k, l)) k = Symbol("k", integer=True, positive=True) l = Symbol("l", positive=False) raises(ValueError, lambda: ChiNoncentral('x', k, l)) k = Symbol("k", integer=False) l = Symbol("l", positive=True) raises(ValueError, lambda: ChiNoncentral('x', k, l)) def test_chi_squared(): k = Symbol("k", integer=True) X = ChiSquared('x', k) assert density(X)(x) == 2**(-k/2)*x**(k/2 - 1)*exp(-x/2)/gamma(k/2) assert cdf(X)(x) == Piecewise((lowergamma(k/2, x/2)/gamma(k/2), x >= 0), (0, True)) assert E(X) == k assert variance(X) == 2*k X = ChiSquared('x', 15) assert cdf(X)(3) == -14873*sqrt(6)*exp(-S(3)/2)/(5005*sqrt(pi)) + erf(sqrt(6)/2) k = Symbol("k", integer=True, positive=False) raises(ValueError, lambda: ChiSquared('x', k)) k = Symbol("k", integer=False, positive=True) raises(ValueError, lambda: ChiSquared('x', k)) def test_dagum(): p = Symbol("p", positive=True) b = Symbol("b", positive=True) a = Symbol("a", positive=True) X = Dagum('x', p, a, b) assert density(X)(x) == a*p*(x/b)**(a*p)*((x/b)**a + 1)**(-p - 1)/x assert cdf(X)(x) == Piecewise(((1 + (x/b)**(-a))**(-p), x >= 0), (0, True)) p = Symbol("p", positive=False) raises(ValueError, lambda: Dagum('x', p, a, b)) p = Symbol("p", positive=True) b = Symbol("b", positive=False) raises(ValueError, lambda: Dagum('x', p, a, b)) b = Symbol("b", positive=True) a = Symbol("a", positive=False) raises(ValueError, lambda: Dagum('x', p, a, b)) def test_erlang(): k = Symbol("k", integer=True, positive=True) l = Symbol("l", positive=True) X = Erlang("x", k, l) assert density(X)(x) == x**(k - 1)*l**k*exp(-x*l)/gamma(k) assert cdf(X)(x) == Piecewise((lowergamma(k, l*x)/gamma(k), x > 0), (0, True)) def test_exponential(): rate = Symbol('lambda', positive=True, real=True, finite=True) X = Exponential('x', rate) assert E(X) == 1/rate assert variance(X) == 1/rate**2 assert skewness(X) == 2 assert skewness(X) == smoment(X, 3) assert smoment(2*X, 4) == smoment(X, 4) assert moment(X, 3) == 3*2*1/rate**3 assert P(X > 0) == S(1) assert P(X > 1) == exp(-rate) assert P(X > 10) == exp(-10*rate) assert where(X <= 1).set == Interval(0, 1) def test_f_distribution(): d1 = Symbol("d1", positive=True) d2 = Symbol("d2", positive=True) X = FDistribution("x", d1, d2) assert density(X)(x) == (d2**(d2/2)*sqrt((d1*x)**d1*(d1*x + d2)**(-d1 - d2)) /(x*beta(d1/2, d2/2))) d1 = Symbol("d1", positive=False) raises(ValueError, lambda: FDistribution('x', d1, d1)) d1 = Symbol("d1", positive=True, integer=False) raises(ValueError, lambda: FDistribution('x', d1, d1)) d1 = Symbol("d1", positive=True) d2 = Symbol("d2", positive=False) raises(ValueError, lambda: FDistribution('x', d1, d2)) d2 = Symbol("d2", positive=True, integer=False) raises(ValueError, lambda: FDistribution('x', d1, d2)) def test_fisher_z(): d1 = Symbol("d1", positive=True) d2 = Symbol("d2", positive=True) X = FisherZ("x", d1, d2) assert density(X)(x) == (2*d1**(d1/2)*d2**(d2/2)*(d1*exp(2*x) + d2) **(-d1/2 - d2/2)*exp(d1*x)/beta(d1/2, d2/2)) def test_frechet(): a = Symbol("a", positive=True) s = Symbol("s", positive=True) m = Symbol("m", real=True) X = Frechet("x", a, s=s, m=m) assert density(X)(x) == a*((x - m)/s)**(-a - 1)*exp(-((x - m)/s)**(-a))/s assert cdf(X)(x) == Piecewise((exp(-((-m + x)/s)**(-a)), m <= x), (0, True)) def test_gamma(): k = Symbol("k", positive=True) theta = Symbol("theta", positive=True) X = Gamma('x', k, theta) assert density(X)(x) == x**(k - 1)*theta**(-k)*exp(-x/theta)/gamma(k) assert cdf(X, meijerg=True)(z) == Piecewise( (-k*lowergamma(k, 0)/gamma(k + 1) + k*lowergamma(k, z/theta)/gamma(k + 1), z >= 0), (0, True)) # assert simplify(variance(X)) == k*theta**2 # handled numerically below assert E(X) == moment(X, 1) k, theta = symbols('k theta', real=True, finite=True, positive=True) X = Gamma('x', k, theta) assert E(X) == k*theta assert variance(X) == k*theta**2 assert simplify(skewness(X)) == 2/sqrt(k) def test_gamma_inverse(): a = Symbol("a", positive=True) b = Symbol("b", positive=True) X = GammaInverse("x", a, b) assert density(X)(x) == x**(-a - 1)*b**a*exp(-b/x)/gamma(a) assert cdf(X)(x) == Piecewise((uppergamma(a, b/x)/gamma(a), x > 0), (0, True)) def test_sampling_gamma_inverse(): scipy = import_module('scipy') if not scipy: skip('Scipy not installed. Abort tests for sampling of gamma inverse.') X = GammaInverse("x", 1, 1) assert sample(X) in X.pspace.domain.set def test_gompertz(): b = Symbol("b", positive=True) eta = Symbol("eta", positive=True) X = Gompertz("x", b, eta) assert density(X)(x) == b*eta*exp(eta)*exp(b*x)*exp(-eta*exp(b*x)) assert cdf(X)(x) == 1 - exp(eta)*exp(-eta*exp(b*x)) assert diff(cdf(X)(x), x) == density(X)(x) def test_gumbel(): beta = Symbol("beta", positive=True) mu = Symbol("mu") x = Symbol("x") X = Gumbel("x", beta, mu) assert str(density(X)(x)) == 'exp(-exp(-(-mu + x)/beta) - (-mu + x)/beta)/beta' assert cdf(X)(x) == exp(-exp((mu - x)/beta)) def test_kumaraswamy(): a = Symbol("a", positive=True) b = Symbol("b", positive=True) X = Kumaraswamy("x", a, b) assert density(X)(x) == x**(a - 1)*a*b*(-x**a + 1)**(b - 1) assert cdf(X)(x) == Piecewise((0, x < 0), (-(-x**a + 1)**b + 1, x <= 1), (1, True)) def test_laplace(): mu = Symbol("mu") b = Symbol("b", positive=True) X = Laplace('x', mu, b) assert density(X)(x) == exp(-Abs(x - mu)/b)/(2*b) assert cdf(X)(x) == Piecewise((exp((-mu + x)/b)/2, mu > x), (-exp((mu - x)/b)/2 + 1, True)) def test_logistic(): mu = Symbol("mu", real=True) s = Symbol("s", positive=True) X = Logistic('x', mu, s) assert density(X)(x) == exp((-x + mu)/s)/(s*(exp((-x + mu)/s) + 1)**2) assert cdf(X)(x) == 1/(exp((mu - x)/s) + 1) def test_lognormal(): mean = Symbol('mu', real=True, finite=True) std = Symbol('sigma', positive=True, real=True, finite=True) X = LogNormal('x', mean, std) # The sympy integrator can't do this too well #assert E(X) == exp(mean+std**2/2) #assert variance(X) == (exp(std**2)-1) * exp(2*mean + std**2) # Right now, only density function and sampling works # Test sampling: Only e^mean in sample std of 0 for i in range(3): X = LogNormal('x', i, 0) assert S(sample(X)) == N(exp(i)) # The sympy integrator can't do this too well #assert E(X) == mu = Symbol("mu", real=True) sigma = Symbol("sigma", positive=True) X = LogNormal('x', mu, sigma) assert density(X)(x) == (sqrt(2)*exp(-(-mu + log(x))**2 /(2*sigma**2))/(2*x*sqrt(pi)*sigma)) X = LogNormal('x', 0, 1) # Mean 0, standard deviation 1 assert density(X)(x) == sqrt(2)*exp(-log(x)**2/2)/(2*x*sqrt(pi)) def test_maxwell(): a = Symbol("a", positive=True) X = Maxwell('x', a) assert density(X)(x) == (sqrt(2)*x**2*exp(-x**2/(2*a**2))/ (sqrt(pi)*a**3)) assert E(X) == 2*sqrt(2)*a/sqrt(pi) assert simplify(variance(X)) == a**2*(-8 + 3*pi)/pi assert cdf(X)(x) == erf(sqrt(2)*x/(2*a)) - sqrt(2)*x*exp(-x**2/(2*a**2))/(sqrt(pi)*a) assert diff(cdf(X)(x), x) == density(X)(x) def test_nakagami(): mu = Symbol("mu", positive=True) omega = Symbol("omega", positive=True) X = Nakagami('x', mu, omega) assert density(X)(x) == (2*x**(2*mu - 1)*mu**mu*omega**(-mu) *exp(-x**2*mu/omega)/gamma(mu)) assert simplify(E(X)) == (sqrt(mu)*sqrt(omega) *gamma(mu + S.Half)/gamma(mu + 1)) assert simplify(variance(X)) == ( omega - omega*gamma(mu + S(1)/2)**2/(gamma(mu)*gamma(mu + 1))) assert cdf(X)(x) == Piecewise( (lowergamma(mu, mu*x**2/omega)/gamma(mu), x > 0), (0, True)) def test_pareto(): xm, beta = symbols('xm beta', positive=True, finite=True) alpha = beta + 5 X = Pareto('x', xm, alpha) dens = density(X) x = Symbol('x') assert dens(x) == x**(-(alpha + 1))*xm**(alpha)*(alpha) assert simplify(E(X)) == alpha*xm/(alpha-1) # computation of taylor series for MGF still too slow #assert simplify(variance(X)) == xm**2*alpha / ((alpha-1)**2*(alpha-2)) def test_pareto_numeric(): xm, beta = 3, 2 alpha = beta + 5 X = Pareto('x', xm, alpha) assert E(X) == alpha*xm/S(alpha - 1) assert variance(X) == xm**2*alpha / S(((alpha - 1)**2*(alpha - 2))) # Skewness tests too slow. Try shortcutting function? def test_raised_cosine(): mu = Symbol("mu", real=True) s = Symbol("s", positive=True) X = RaisedCosine("x", mu, s) assert density(X)(x) == (Piecewise(((cos(pi*(x - mu)/s) + 1)/(2*s), And(x <= mu + s, mu - s <= x)), (0, True))) def test_rayleigh(): sigma = Symbol("sigma", positive=True) X = Rayleigh('x', sigma) assert density(X)(x) == x*exp(-x**2/(2*sigma**2))/sigma**2 assert E(X) == sqrt(2)*sqrt(pi)*sigma/2 assert variance(X) == -pi*sigma**2/2 + 2*sigma**2 assert cdf(X)(x) == 1 - exp(-x**2/(2*sigma**2)) assert diff(cdf(X)(x), x) == density(X)(x) def test_shiftedgompertz(): b = Symbol("b", positive=True) eta = Symbol("eta", positive=True) X = ShiftedGompertz("x", b, eta) assert density(X)(x) == b*(eta*(1 - exp(-b*x)) + 1)*exp(-b*x)*exp(-eta*exp(-b*x)) def test_studentt(): nu = Symbol("nu", positive=True) X = StudentT('x', nu) assert density(X)(x) == (1 + x**2/nu)**(-nu/2 - S(1)/2)/(sqrt(nu)*beta(S(1)/2, nu/2)) assert cdf(X)(x) == S(1)/2 + x*gamma(nu/2 + S(1)/2)*hyper((S(1)/2, nu/2 + S(1)/2), (S(3)/2,), -x**2/nu)/(sqrt(pi)*sqrt(nu)*gamma(nu/2)) def test_trapezoidal(): a = Symbol("a", real=True) b = Symbol("b", real=True) c = Symbol("c", real=True) d = Symbol("d", real=True) X = Trapezoidal('x', a, b, c, d) assert density(X)(x) == Piecewise(((-2*a + 2*x)/((-a + b)*(-a - b + c + d)), (a <= x) & (x < b)), (2/(-a - b + c + d), (b <= x) & (x < c)), ((2*d - 2*x)/((-c + d)*(-a - b + c + d)), (c <= x) & (x <= d)), (0, True)) X = Trapezoidal('x', 0, 1, 2, 3) assert E(X) == S(3)/2 assert variance(X) == S(5)/12 assert P(X < 2) == S(3)/4 @XFAIL def test_triangular(): a = Symbol("a") b = Symbol("b") c = Symbol("c") X = Triangular('x', a, b, c) assert density(X)(x) == Piecewise( ((2*x - 2*a)/((-a + b)*(-a + c)), And(a <= x, x < c)), (2/(-a + b), x == c), ((-2*x + 2*b)/((-a + b)*(b - c)), And(x <= b, c < x)), (0, True)) def test_quadratic_u(): a = Symbol("a", real=True) b = Symbol("b", real=True) X = QuadraticU("x", a, b) assert density(X)(x) == (Piecewise((12*(x - a/2 - b/2)**2/(-a + b)**3, And(x <= b, a <= x)), (0, True))) def test_uniform(): l = Symbol('l', real=True, finite=True) w = Symbol('w', positive=True, finite=True) X = Uniform('x', l, l + w) assert simplify(E(X)) == l + w/2 assert simplify(variance(X)) == w**2/12 # With numbers all is well X = Uniform('x', 3, 5) assert P(X < 3) == 0 and P(X > 5) == 0 assert P(X < 4) == P(X > 4) == S.Half z = Symbol('z') p = density(X)(z) assert p.subs(z, 3.7) == S(1)/2 assert p.subs(z, -1) == 0 assert p.subs(z, 6) == 0 c = cdf(X) assert c(2) == 0 and c(3) == 0 assert c(S(7)/2) == S(1)/4 assert c(5) == 1 and c(6) == 1 def test_uniform_P(): """ This stopped working because SingleContinuousPSpace.compute_density no longer calls integrate on a DiracDelta but rather just solves directly. integrate used to call UniformDistribution.expectation which special-cased subsed out the Min and Max terms that Uniform produces I decided to regress on this class for general cleanliness (and I suspect speed) of the algorithm. """ l = Symbol('l', real=True, finite=True) w = Symbol('w', positive=True, finite=True) X = Uniform('x', l, l + w) assert P(X < l) == 0 and P(X > l + w) == 0 @XFAIL def test_uniformsum(): n = Symbol("n", integer=True) _k = Symbol("k") X = UniformSum('x', n) assert density(X)(x) == (Sum((-1)**_k*(-_k + x)**(n - 1) *binomial(n, _k), (_k, 0, floor(x)))/factorial(n - 1)) def test_von_mises(): mu = Symbol("mu") k = Symbol("k", positive=True) X = VonMises("x", mu, k) assert density(X)(x) == exp(k*cos(x - mu))/(2*pi*besseli(0, k)) def test_weibull(): a, b = symbols('a b', positive=True) X = Weibull('x', a, b) assert simplify(E(X)) == simplify(a * gamma(1 + 1/b)) assert simplify(variance(X)) == simplify(a**2 * gamma(1 + 2/b) - E(X)**2) assert simplify(skewness(X)) == (2*gamma(1 + 1/b)**3 - 3*gamma(1 + 1/b)*gamma(1 + 2/b) + gamma(1 + 3/b))/(-gamma(1 + 1/b)**2 + gamma(1 + 2/b))**(S(3)/2) def test_weibull_numeric(): # Test for integers and rationals a = 1 bvals = [S.Half, 1, S(3)/2, 5] for b in bvals: X = Weibull('x', a, b) assert simplify(E(X)) == expand_func(a * gamma(1 + 1/S(b))) assert simplify(variance(X)) == simplify( a**2 * gamma(1 + 2/S(b)) - E(X)**2) # Not testing Skew... it's slow with int/frac values > 3/2 def test_wignersemicircle(): R = Symbol("R", positive=True) X = WignerSemicircle('x', R) assert density(X)(x) == 2*sqrt(-x**2 + R**2)/(pi*R**2) assert E(X) == 0 def test_prefab_sampling(): N = Normal('X', 0, 1) L = LogNormal('L', 0, 1) E = Exponential('Ex', 1) P = Pareto('P', 1, 3) W = Weibull('W', 1, 1) U = Uniform('U', 0, 1) B = Beta('B', 2, 5) G = Gamma('G', 1, 3) variables = [N, L, E, P, W, U, B, G] niter = 10 for var in variables: for i in range(niter): assert sample(var) in var.pspace.domain.set def test_input_value_assertions(): a, b = symbols('a b') p, q = symbols('p q', positive=True) m, n = symbols('m n', positive=False, real=True) raises(ValueError, lambda: Normal('x', 3, 0)) raises(ValueError, lambda: Normal('x', m, n)) Normal('X', a, p) # No error raised raises(ValueError, lambda: Exponential('x', m)) Exponential('Ex', p) # No error raised for fn in [Pareto, Weibull, Beta, Gamma]: raises(ValueError, lambda: fn('x', m, p)) raises(ValueError, lambda: fn('x', p, n)) fn('x', p, q) # No error raised @XFAIL def test_unevaluated(): X = Normal('x', 0, 1) assert E(X, evaluate=False) == ( Integral(sqrt(2)*x*exp(-x**2/2)/(2*sqrt(pi)), (x, -oo, oo))) assert E(X + 1, evaluate=False) == ( Integral(sqrt(2)*x*exp(-x**2/2)/(2*sqrt(pi)), (x, -oo, oo)) + 1) assert P(X > 0, evaluate=False) == ( Integral(sqrt(2)*exp(-x**2/2)/(2*sqrt(pi)), (x, 0, oo))) assert P(X > 0, X**2 < 1, evaluate=False) == ( Integral(sqrt(2)*exp(-x**2/2)/(2*sqrt(pi)* Integral(sqrt(2)*exp(-x**2/2)/(2*sqrt(pi)), (x, -1, 1))), (x, 0, 1))) def test_probability_unevaluated(): T = Normal('T', 30, 3) assert type(P(T > 33, evaluate=False)) == Integral def test_density_unevaluated(): X = Normal('X', 0, 1) Y = Normal('Y', 0, 2) assert isinstance(density(X+Y, evaluate=False)(z), Integral) def test_NormalDistribution(): nd = NormalDistribution(0, 1) x = Symbol('x') assert nd.cdf(x) == erf(sqrt(2)*x/2)/2 + S.One/2 assert isinstance(nd.sample(), float) or nd.sample().is_Number assert nd.expectation(1, x) == 1 assert nd.expectation(x, x) == 0 assert nd.expectation(x**2, x) == 1 def test_random_parameters(): mu = Normal('mu', 2, 3) meas = Normal('T', mu, 1) assert density(meas, evaluate=False)(z) assert isinstance(pspace(meas), JointPSpace) #assert density(meas, evaluate=False)(z) == Integral(mu.pspace.pdf * # meas.pspace.pdf, (mu.symbol, -oo, oo)).subs(meas.symbol, z) def test_random_parameters_given(): mu = Normal('mu', 2, 3) meas = Normal('T', mu, 1) assert given(meas, Eq(mu, 5)) == Normal('T', 5, 1) def test_conjugate_priors(): mu = Normal('mu', 2, 3) x = Normal('x', mu, 1) assert isinstance(simplify(density(mu, Eq(x, y), evaluate=False)(z)), Mul) def test_difficult_univariate(): """ Since using solve in place of deltaintegrate we're able to perform substantially more complex density computations on single continuous random variables """ x = Normal('x', 0, 1) assert density(x**3) assert density(exp(x**2)) assert density(log(x)) def test_issue_10003(): X = Exponential('x', 3) G = Gamma('g', 1, 2) assert P(X < -1) == S.Zero assert P(G < -1) == S.Zero @slow def test_precomputed_cdf(): x = symbols("x", real=True, finite=True) mu = symbols("mu", real=True, finite=True) sigma, xm, alpha = symbols("sigma xm alpha", positive=True, finite=True) n = symbols("n", integer=True, positive=True, finite=True) distribs = [ Normal("X", mu, sigma), Pareto("P", xm, alpha), ChiSquared("C", n), Exponential("E", sigma), # LogNormal("L", mu, sigma), ] for X in distribs: compdiff = cdf(X)(x) - simplify(X.pspace.density.compute_cdf()(x)) compdiff = simplify(compdiff.rewrite(erfc)) assert compdiff == 0 @slow def test_precomputed_characteristic_functions(): import mpmath def test_cf(dist, support_lower_limit, support_upper_limit): pdf = density(dist) t = Symbol('t') x = Symbol('x') # first function is the hardcoded CF of the distribution cf1 = lambdify([t], characteristic_function(dist)(t), 'mpmath') # second function is the Fourier transform of the density function f = lambdify([x, t], pdf(x)*exp(I*x*t), 'mpmath') cf2 = lambda t: mpmath.quad(lambda x: f(x, t), [support_lower_limit, support_upper_limit], maxdegree=10) # compare the two functions at various points for test_point in [2, 5, 8, 11]: n1 = cf1(test_point) n2 = cf2(test_point) assert abs(re(n1) - re(n2)) < 1e-12 assert abs(im(n1) - im(n2)) < 1e-12 test_cf(Beta('b', 1, 2), 0, 1) test_cf(Chi('c', 3), 0, mpmath.inf) test_cf(ChiSquared('c', 2), 0, mpmath.inf) test_cf(Exponential('e', 6), 0, mpmath.inf) test_cf(Logistic('l', 1, 2), -mpmath.inf, mpmath.inf) test_cf(Normal('n', -1, 5), -mpmath.inf, mpmath.inf) test_cf(RaisedCosine('r', 3, 1), 2, 4) test_cf(Rayleigh('r', 0.5), 0, mpmath.inf) test_cf(Uniform('u', -1, 1), -1, 1) test_cf(WignerSemicircle('w', 3), -3, 3) def test_long_precomputed_cdf(): x = symbols("x", real=True, finite=True) distribs = [ Arcsin("A", -5, 9), Dagum("D", 4, 10, 3), Erlang("E", 14, 5), Frechet("F", 2, 6, -3), Gamma("G", 2, 7), GammaInverse("GI", 3, 5), Kumaraswamy("K", 6, 8), Laplace("LA", -5, 4), Logistic("L", -6, 7), Nakagami("N", 2, 7), StudentT("S", 4) ] for distr in distribs: for _ in range(5): assert tn(diff(cdf(distr)(x), x), density(distr)(x), x, a=0, b=0, c=1, d=0) US = UniformSum("US", 5) pdf01 = density(US)(x).subs(floor(x), 0).doit() # pdf on (0, 1) cdf01 = cdf(US, evaluate=False)(x).subs(floor(x), 0).doit() # cdf on (0, 1) assert tn(diff(cdf01, x), pdf01, x, a=0, b=0, c=1, d=0) def test_issue_13324(): X = Uniform('X', 0, 1) assert E(X, X > Rational(1, 2)) == Rational(3, 4) assert E(X, X > 0) == Rational(1, 2) def test_FiniteSet_prob(): x = symbols('x') E = Exponential('E', 3) N = Normal('N', 5, 7) assert P(Eq(E, 1)) is S.Zero assert P(Eq(N, 2)) is S.Zero assert P(Eq(N, x)) is S.Zero def test_prob_neq(): E = Exponential('E', 4) X = ChiSquared('X', 4) x = symbols('x') assert P(Ne(E, 2)) == 1 assert P(Ne(X, 4)) == 1 assert P(Ne(X, 4)) == 1 assert P(Ne(X, 5)) == 1 assert P(Ne(E, x)) == 1 def test_union(): N = Normal('N', 3, 2) assert simplify(P(N**2 - N > 2)) == \ -erf(sqrt(2))/2 - erfc(sqrt(2)/4)/2 + S(3)/2 assert simplify(P(N**2 - 4 > 0)) == \ -erf(5*sqrt(2)/4)/2 - erfc(sqrt(2)/4)/2 + S(3)/2 def test_Or(): N = Normal('N', 0, 1) assert simplify(P(Or(N > 2, N < 1))) == \ -erf(sqrt(2))/2 - erfc(sqrt(2)/2)/2 + S(3)/2 assert P(Or(N < 0, N < 1)) == P(N < 1) assert P(Or(N > 0, N < 0)) == 1 def test_conditional_eq(): E = Exponential('E', 1) assert P(Eq(E, 1), Eq(E, 1)) == 1 assert P(Eq(E, 1), Eq(E, 2)) == 0 assert P(E > 1, Eq(E, 2)) == 1 assert P(E < 1, Eq(E, 2)) == 0
981498310288bc3ce46bb6b79877daf35e95bc99004ecb325c091187b7385c78
from sympy import S from sympy.combinatorics.fp_groups import (FpGroup, low_index_subgroups, reidemeister_presentation, FpSubgroup, simplify_presentation) from sympy.combinatorics.free_groups import (free_group, FreeGroup) from sympy.utilities.pytest import slow """ References ========== [1] Holt, D., Eick, B., O'Brien, E. "Handbook of Computational Group Theory" [2] John J. Cannon; Lucien A. Dimino; George Havas; Jane M. Watson Mathematics of Computation, Vol. 27, No. 123. (Jul., 1973), pp. 463-490. "Implementation and Analysis of the Todd-Coxeter Algorithm" [3] PROC. SECOND INTERNAT. CONF. THEORY OF GROUPS, CANBERRA 1973, pp. 347-356. "A Reidemeister-Schreier program" by George Havas. http://staff.itee.uq.edu.au/havas/1973cdhw.pdf """ def test_low_index_subgroups(): F, x, y = free_group("x, y") # Example 5.10 from [1] Pg. 194 f = FpGroup(F, [x**2, y**3, (x*y)**4]) L = low_index_subgroups(f, 4) t1 = [[[0, 0, 0, 0]], [[0, 0, 1, 2], [1, 1, 2, 0], [3, 3, 0, 1], [2, 2, 3, 3]], [[0, 0, 1, 2], [2, 2, 2, 0], [1, 1, 0, 1]], [[1, 1, 0, 0], [0, 0, 1, 1]]] for i in range(len(t1)): assert L[i].table == t1[i] f = FpGroup(F, [x**2, y**3, (x*y)**7]) L = low_index_subgroups(f, 15) t2 = [[[0, 0, 0, 0]], [[0, 0, 1, 2], [1, 1, 2, 0], [3, 3, 0, 1], [2, 2, 4, 5], [4, 4, 5, 3], [6, 6, 3, 4], [5, 5, 6, 6]], [[0, 0, 1, 2], [1, 1, 2, 0], [3, 3, 0, 1], [2, 2, 4, 5], [6, 6, 5, 3], [5, 5, 3, 4], [4, 4, 6, 6]], [[0, 0, 1, 2], [1, 1, 2, 0], [3, 3, 0, 1], [2, 2, 4, 5], [6, 6, 5, 3], [7, 7, 3, 4], [4, 4, 8, 9], [5, 5, 10, 11], [11, 11, 9, 6], [9, 9, 6, 8], [12, 12, 11, 7], [8, 8, 7, 10], [10, 10, 13, 14], [14, 14, 14, 12], [13, 13, 12, 13]], [[0, 0, 1, 2], [1, 1, 2, 0], [3, 3, 0, 1], [2, 2, 4, 5], [6, 6, 5, 3], [7, 7, 3, 4], [4, 4, 8, 9], [5, 5, 10, 11], [11, 11, 9, 6], [12, 12, 6, 8], [10, 10, 11, 7], [8, 8, 7, 10], [9, 9, 13, 14], [14, 14, 14, 12], [13, 13, 12, 13]], [[0, 0, 1, 2], [1, 1, 2, 0], [3, 3, 0, 1], [2, 2, 4, 5], [6, 6, 5, 3], [7, 7, 3, 4], [4, 4, 8, 9], [5, 5, 10, 11], [11, 11, 9, 6], [12, 12, 6, 8], [13, 13, 11, 7], [8, 8, 7, 10], [9, 9, 12, 12], [10, 10, 13, 13]], [[0, 0, 1, 2], [3, 3, 2, 0], [4, 4, 0, 1], [1, 1, 3, 3], [2, 2, 5, 6] , [7, 7, 6, 4], [8, 8, 4, 5], [5, 5, 8, 9], [6, 6, 9, 7], [10, 10, 7, 8], [9, 9, 11, 12], [11, 11, 12, 10], [13, 13, 10, 11], [12, 12, 13, 13]], [[0, 0, 1, 2], [3, 3, 2, 0], [4, 4, 0, 1], [1, 1, 3, 3], [2, 2, 5, 6] , [7, 7, 6, 4], [8, 8, 4, 5], [5, 5, 8, 9], [6, 6, 9, 7], [10, 10, 7, 8], [9, 9, 11, 12], [13, 13, 12, 10], [12, 12, 10, 11], [11, 11, 13, 13]], [[0, 0, 1, 2], [3, 3, 2, 0], [4, 4, 0, 1], [1, 1, 5, 6], [2, 2, 4, 4] , [7, 7, 6, 3], [8, 8, 3, 5], [5, 5, 8, 9], [6, 6, 9, 7], [10, 10, 7, 8], [9, 9, 11, 12], [13, 13, 12, 10], [12, 12, 10, 11], [11, 11, 13, 13]], [[0, 0, 1, 2], [3, 3, 2, 0], [4, 4, 0, 1], [1, 1, 5, 6], [2, 2, 7, 8] , [5, 5, 6, 3], [9, 9, 3, 5], [10, 10, 8, 4], [8, 8, 4, 7], [6, 6, 10, 11], [7, 7, 11, 9], [12, 12, 9, 10], [11, 11, 13, 14], [14, 14, 14, 12], [13, 13, 12, 13]], [[0, 0, 1, 2], [3, 3, 2, 0], [4, 4, 0, 1], [1, 1, 5, 6], [2, 2, 7, 8] , [6, 6, 6, 3], [5, 5, 3, 5], [8, 8, 8, 4], [7, 7, 4, 7]], [[0, 0, 1, 2], [3, 3, 2, 0], [4, 4, 0, 1], [1, 1, 5, 6], [2, 2, 7, 8] , [9, 9, 6, 3], [6, 6, 3, 5], [10, 10, 8, 4], [11, 11, 4, 7], [5, 5, 10, 12], [7, 7, 12, 9], [8, 8, 11, 11], [13, 13, 9, 10], [12, 12, 13, 13]], [[0, 0, 1, 2], [3, 3, 2, 0], [4, 4, 0, 1], [1, 1, 5, 6], [2, 2, 7, 8] , [9, 9, 6, 3], [6, 6, 3, 5], [10, 10, 8, 4], [11, 11, 4, 7], [5, 5, 12, 11], [7, 7, 10, 10], [8, 8, 9, 12], [13, 13, 11, 9], [12, 12, 13, 13]], [[0, 0, 1, 2], [3, 3, 2, 0], [4, 4, 0, 1], [1, 1, 5, 6], [2, 2, 7, 8] , [9, 9, 6, 3], [10, 10, 3, 5], [7, 7, 8, 4], [11, 11, 4, 7], [5, 5, 9, 9], [6, 6, 11, 12], [8, 8, 12, 10], [13, 13, 10, 11], [12, 12, 13, 13]], [[0, 0, 1, 2], [3, 3, 2, 0], [4, 4, 0, 1], [1, 1, 5, 6], [2, 2, 7, 8] , [9, 9, 6, 3], [10, 10, 3, 5], [7, 7, 8, 4], [11, 11, 4, 7], [5, 5, 12, 11], [6, 6, 10, 10], [8, 8, 9, 12], [13, 13, 11, 9], [12, 12, 13, 13]], [[0, 0, 1, 2], [3, 3, 2, 0], [4, 4, 0, 1], [1, 1, 5, 6], [2, 2, 7, 8] , [9, 9, 6, 3], [10, 10, 3, 5], [11, 11, 8, 4], [12, 12, 4, 7], [5, 5, 9, 9], [6, 6, 12, 13], [7, 7, 11, 11], [8, 8, 13, 10], [13, 13, 10, 12]], [[1, 1, 0, 0], [0, 0, 2, 3], [4, 4, 3, 1], [5, 5, 1, 2], [2, 2, 4, 4] , [3, 3, 6, 7], [7, 7, 7, 5], [6, 6, 5, 6]]] for i in range(len(t2)): assert L[i].table == t2[i] f = FpGroup(F, [x**2, y**3, (x*y)**7]) L = low_index_subgroups(f, 10, [x]) t3 = [[[0, 0, 0, 0]], [[0, 0, 1, 2], [1, 1, 2, 0], [3, 3, 0, 1], [2, 2, 4, 5], [4, 4, 5, 3], [6, 6, 3, 4], [5, 5, 6, 6]], [[0, 0, 1, 2], [1, 1, 2, 0], [3, 3, 0, 1], [2, 2, 4, 5], [6, 6, 5, 3], [5, 5, 3, 4], [4, 4, 6, 6]], [[0, 0, 1, 2], [3, 3, 2, 0], [4, 4, 0, 1], [1, 1, 5, 6], [2, 2, 7, 8], [6, 6, 6, 3], [5, 5, 3, 5], [8, 8, 8, 4], [7, 7, 4, 7]]] for i in range(len(t3)): assert L[i].table == t3[i] def test_subgroup_presentations(): F, x, y = free_group("x, y") f = FpGroup(F, [x**3, y**5, (x*y)**2]) H = [x*y, x**-1*y**-1*x*y*x] p1 = reidemeister_presentation(f, H) assert str(p1) == "((y_1, y_2), (y_1**2, y_2**3, y_2*y_1*y_2*y_1*y_2*y_1))" H = f.subgroup(H) assert (H.generators, H.relators) == p1 f = FpGroup(F, [x**3, y**3, (x*y)**3]) H = [x*y, x*y**-1] p2 = reidemeister_presentation(f, H) assert str(p2) == "((x_0, y_0), (x_0**3, y_0**3, x_0*y_0*x_0*y_0*x_0*y_0))" f = FpGroup(F, [x**2*y**2, y**-1*x*y*x**-3]) H = [x] p3 = reidemeister_presentation(f, H) assert str(p3) == "((x_0,), (x_0**4,))" f = FpGroup(F, [x**3*y**-3, (x*y)**3, (x*y**-1)**2]) H = [x] p4 = reidemeister_presentation(f, H) assert str(p4) == "((x_0,), (x_0**6,))" # this presentation can be improved, the most simplified form # of presentation is <a, b | a^11, b^2, (a*b)^3, (a^4*b*a^-5*b)^2> # See [2] Pg 474 group PSL_2(11) # This is the group PSL_2(11) F, a, b, c = free_group("a, b, c") f = FpGroup(F, [a**11, b**5, c**4, (b*c**2)**2, (a*b*c)**3, (a**4*c**2)**3, b**2*c**-1*b**-1*c, a**4*b**-1*a**-1*b]) H = [a, b, c**2] gens, rels = reidemeister_presentation(f, H) assert str(gens) == "(b_1, c_3)" assert len(rels) == 18 @slow def test_order(): F, x, y = free_group("x, y") f = FpGroup(F, [x**4, y**2, x*y*x**-1*y]) assert f.order() == 8 f = FpGroup(F, [x*y*x**-1*y**-1, y**2]) assert f.order() == S.Infinity F, a, b, c = free_group("a, b, c") f = FpGroup(F, [a**250, b**2, c*b*c**-1*b, c**4, c**-1*a**-1*c*a, a**-1*b**-1*a*b]) assert f.order() == 2000 F, x = free_group("x") f = FpGroup(F, []) assert f.order() == S.Infinity f = FpGroup(free_group('')[0], []) assert f.order() == 1 def test_fp_subgroup(): def _test_subgroup(K, T, S): _gens = T(K.generators) assert all(elem in S for elem in _gens) assert T.is_injective() assert T.image().order() == S.order() F, x, y = free_group("x, y") f = FpGroup(F, [x**4, y**2, x*y*x**-1*y]) S = FpSubgroup(f, [x*y]) assert (x*y)**-3 in S K, T = f.subgroup([x*y], homomorphism=True) assert T(K.generators) == [y*x**-1] _test_subgroup(K, T, S) S = FpSubgroup(f, [x**-1*y*x]) assert x**-1*y**4*x in S assert x**-1*y**4*x**2 not in S K, T = f.subgroup([x**-1*y*x], homomorphism=True) assert T(K.generators[0]**3) == y**3 _test_subgroup(K, T, S) f = FpGroup(F, [x**3, y**5, (x*y)**2]) H = [x*y, x**-1*y**-1*x*y*x] K, T = f.subgroup(H, homomorphism=True) S = FpSubgroup(f, H) _test_subgroup(K, T, S) def test_permutation_methods(): from sympy.combinatorics.fp_groups import FpSubgroup F, x, y = free_group("x, y") # DihedralGroup(8) G = FpGroup(F, [x**2, y**8, x*y*x**-1*y]) T = G._to_perm_group()[1] assert T.is_isomorphism() assert G.center() == [y**4] # DiheadralGroup(4) G = FpGroup(F, [x**2, y**4, x*y*x**-1*y]) S = FpSubgroup(G, G.normal_closure([x])) assert x in S assert y**-1*x*y in S # Z_5xZ_4 G = FpGroup(F, [x*y*x**-1*y**-1, y**5, x**4]) assert G.is_abelian assert G.is_solvable # AlternatingGroup(5) G = FpGroup(F, [x**3, y**2, (x*y)**5]) assert not G.is_solvable # AlternatingGroup(4) G = FpGroup(F, [x**3, y**2, (x*y)**3]) assert len(G.derived_series()) == 3 S = FpSubgroup(G, G.derived_subgroup()) assert S.order() == 4 def test_simplify_presentation(): # ref #16083 G = simplify_presentation(FpGroup(FreeGroup([]), [])) assert not G.generators assert not G.relators def test_cyclic(): F, x, y = free_group("x, y") f = FpGroup(F, [x*y, x**-1*y**-1*x*y*x]) assert f.is_cyclic f = FpGroup(F, [x*y, x*y**-1]) assert f.is_cyclic f = FpGroup(F, [x**4, y**2, x*y*x**-1*y]) assert not f.is_cyclic
b648081919c7461ee7e43de8d04da79c121b3f0d96a66181099d0ef537bab0ab
from sympy.core.compatibility import range from sympy.combinatorics.perm_groups import (PermutationGroup, _orbit_transversal) from sympy.combinatorics.named_groups import SymmetricGroup, CyclicGroup,\ DihedralGroup, AlternatingGroup, AbelianGroup, RubikGroup from sympy.combinatorics.permutations import Permutation from sympy.utilities.pytest import skip, XFAIL from sympy.combinatorics.generators import rubik_cube_generators from sympy.combinatorics.polyhedron import tetrahedron as Tetra, cube from sympy.combinatorics.testutil import _verify_bsgs, _verify_centralizer,\ _verify_normal_closure from sympy.utilities.pytest import raises, slow rmul = Permutation.rmul def test_has(): a = Permutation([1, 0]) G = PermutationGroup([a]) assert G.is_abelian a = Permutation([2, 0, 1]) b = Permutation([2, 1, 0]) G = PermutationGroup([a, b]) assert not G.is_abelian G = PermutationGroup([a]) assert G.has(a) assert not G.has(b) a = Permutation([2, 0, 1, 3, 4, 5]) b = Permutation([0, 2, 1, 3, 4]) assert PermutationGroup(a, b).degree == \ PermutationGroup(a, b).degree == 6 def test_generate(): a = Permutation([1, 0]) g = list(PermutationGroup([a]).generate()) assert g == [Permutation([0, 1]), Permutation([1, 0])] assert len(list(PermutationGroup(Permutation((0, 1))).generate())) == 1 g = PermutationGroup([a]).generate(method='dimino') assert list(g) == [Permutation([0, 1]), Permutation([1, 0])] a = Permutation([2, 0, 1]) b = Permutation([2, 1, 0]) G = PermutationGroup([a, b]) g = G.generate() v1 = [p.array_form for p in list(g)] v1.sort() assert v1 == [[0, 1, 2], [0, 2, 1], [1, 0, 2], [1, 2, 0], [2, 0, 1], [2, 1, 0]] v2 = list(G.generate(method='dimino', af=True)) assert v1 == sorted(v2) a = Permutation([2, 0, 1, 3, 4, 5]) b = Permutation([2, 1, 3, 4, 5, 0]) g = PermutationGroup([a, b]).generate(af=True) assert len(list(g)) == 360 def test_order(): a = Permutation([2, 0, 1, 3, 4, 5, 6, 7, 8, 9]) b = Permutation([2, 1, 3, 4, 5, 6, 7, 8, 9, 0]) g = PermutationGroup([a, b]) assert g.order() == 1814400 assert PermutationGroup().order() == 1 def test_equality(): p_1 = Permutation(0, 1, 3) p_2 = Permutation(0, 2, 3) p_3 = Permutation(0, 1, 2) p_4 = Permutation(0, 1, 3) g_1 = PermutationGroup(p_1, p_2) g_2 = PermutationGroup(p_3, p_4) g_3 = PermutationGroup(p_2, p_1) assert g_1 == g_2 assert g_1.generators != g_2.generators assert g_1 == g_3 def test_stabilizer(): S = SymmetricGroup(2) H = S.stabilizer(0) assert H.generators == [Permutation(1)] a = Permutation([2, 0, 1, 3, 4, 5]) b = Permutation([2, 1, 3, 4, 5, 0]) G = PermutationGroup([a, b]) G0 = G.stabilizer(0) assert G0.order() == 60 gens_cube = [[1, 3, 5, 7, 0, 2, 4, 6], [1, 3, 0, 2, 5, 7, 4, 6]] gens = [Permutation(p) for p in gens_cube] G = PermutationGroup(gens) G2 = G.stabilizer(2) assert G2.order() == 6 G2_1 = G2.stabilizer(1) v = list(G2_1.generate(af=True)) assert v == [[0, 1, 2, 3, 4, 5, 6, 7], [3, 1, 2, 0, 7, 5, 6, 4]] gens = ( (1, 2, 0, 4, 5, 3, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19), (0, 1, 2, 3, 4, 5, 19, 6, 8, 9, 10, 11, 12, 13, 14, 15, 16, 7, 17, 18), (0, 1, 2, 3, 4, 5, 6, 7, 9, 18, 16, 11, 12, 13, 14, 15, 8, 17, 10, 19)) gens = [Permutation(p) for p in gens] G = PermutationGroup(gens) G2 = G.stabilizer(2) assert G2.order() == 181440 S = SymmetricGroup(3) assert [G.order() for G in S.basic_stabilizers] == [6, 2] def test_center(): # the center of the dihedral group D_n is of order 2 for even n for i in (4, 6, 10): D = DihedralGroup(i) assert (D.center()).order() == 2 # the center of the dihedral group D_n is of order 1 for odd n>2 for i in (3, 5, 7): D = DihedralGroup(i) assert (D.center()).order() == 1 # the center of an abelian group is the group itself for i in (2, 3, 5): for j in (1, 5, 7): for k in (1, 1, 11): G = AbelianGroup(i, j, k) assert G.center().is_subgroup(G) # the center of a nonabelian simple group is trivial for i in(1, 5, 9): A = AlternatingGroup(i) assert (A.center()).order() == 1 # brute-force verifications D = DihedralGroup(5) A = AlternatingGroup(3) C = CyclicGroup(4) G.is_subgroup(D*A*C) assert _verify_centralizer(G, G) def test_centralizer(): # the centralizer of the trivial group is the entire group S = SymmetricGroup(2) assert S.centralizer(Permutation(list(range(2)))).is_subgroup(S) A = AlternatingGroup(5) assert A.centralizer(Permutation(list(range(5)))).is_subgroup(A) # a centralizer in the trivial group is the trivial group itself triv = PermutationGroup([Permutation([0, 1, 2, 3])]) D = DihedralGroup(4) assert triv.centralizer(D).is_subgroup(triv) # brute-force verifications for centralizers of groups for i in (4, 5, 6): S = SymmetricGroup(i) A = AlternatingGroup(i) C = CyclicGroup(i) D = DihedralGroup(i) for gp in (S, A, C, D): for gp2 in (S, A, C, D): if not gp2.is_subgroup(gp): assert _verify_centralizer(gp, gp2) # verify the centralizer for all elements of several groups S = SymmetricGroup(5) elements = list(S.generate_dimino()) for element in elements: assert _verify_centralizer(S, element) A = AlternatingGroup(5) elements = list(A.generate_dimino()) for element in elements: assert _verify_centralizer(A, element) D = DihedralGroup(7) elements = list(D.generate_dimino()) for element in elements: assert _verify_centralizer(D, element) # verify centralizers of small groups within small groups small = [] for i in (1, 2, 3): small.append(SymmetricGroup(i)) small.append(AlternatingGroup(i)) small.append(DihedralGroup(i)) small.append(CyclicGroup(i)) for gp in small: for gp2 in small: if gp.degree == gp2.degree: assert _verify_centralizer(gp, gp2) def test_coset_rank(): gens_cube = [[1, 3, 5, 7, 0, 2, 4, 6], [1, 3, 0, 2, 5, 7, 4, 6]] gens = [Permutation(p) for p in gens_cube] G = PermutationGroup(gens) i = 0 for h in G.generate(af=True): rk = G.coset_rank(h) assert rk == i h1 = G.coset_unrank(rk, af=True) assert h == h1 i += 1 assert G.coset_unrank(48) == None assert G.coset_unrank(G.coset_rank(gens[0])) == gens[0] def test_coset_factor(): a = Permutation([0, 2, 1]) G = PermutationGroup([a]) c = Permutation([2, 1, 0]) assert not G.coset_factor(c) assert G.coset_rank(c) is None a = Permutation([2, 0, 1, 3, 4, 5]) b = Permutation([2, 1, 3, 4, 5, 0]) g = PermutationGroup([a, b]) assert g.order() == 360 d = Permutation([1, 0, 2, 3, 4, 5]) assert not g.coset_factor(d.array_form) assert not g.contains(d) assert Permutation(2) in G c = Permutation([1, 0, 2, 3, 5, 4]) v = g.coset_factor(c, True) tr = g.basic_transversals p = Permutation.rmul(*[tr[i][v[i]] for i in range(len(g.base))]) assert p == c v = g.coset_factor(c) p = Permutation.rmul(*v) assert p == c assert g.contains(c) G = PermutationGroup([Permutation([2, 1, 0])]) p = Permutation([1, 0, 2]) assert G.coset_factor(p) == [] def test_orbits(): a = Permutation([2, 0, 1]) b = Permutation([2, 1, 0]) g = PermutationGroup([a, b]) assert g.orbit(0) == {0, 1, 2} assert g.orbits() == [{0, 1, 2}] assert g.is_transitive() and g.is_transitive(strict=False) assert g.orbit_transversal(0) == \ [Permutation( [0, 1, 2]), Permutation([2, 0, 1]), Permutation([1, 2, 0])] assert g.orbit_transversal(0, True) == \ [(0, Permutation([0, 1, 2])), (2, Permutation([2, 0, 1])), (1, Permutation([1, 2, 0]))] G = DihedralGroup(6) transversal, slps = _orbit_transversal(G.degree, G.generators, 0, True, slp=True) for i, t in transversal: slp = slps[i] w = G.identity for s in slp: w = G.generators[s]*w assert w == t a = Permutation(list(range(1, 100)) + [0]) G = PermutationGroup([a]) assert [min(o) for o in G.orbits()] == [0] G = PermutationGroup(rubik_cube_generators()) assert [min(o) for o in G.orbits()] == [0, 1] assert not G.is_transitive() and not G.is_transitive(strict=False) G = PermutationGroup([Permutation(0, 1, 3), Permutation(3)(0, 1)]) assert not G.is_transitive() and G.is_transitive(strict=False) assert PermutationGroup( Permutation(3)).is_transitive(strict=False) is False def test_is_normal(): gens_s5 = [Permutation(p) for p in [[1, 2, 3, 4, 0], [2, 1, 4, 0, 3]]] G1 = PermutationGroup(gens_s5) assert G1.order() == 120 gens_a5 = [Permutation(p) for p in [[1, 0, 3, 2, 4], [2, 1, 4, 3, 0]]] G2 = PermutationGroup(gens_a5) assert G2.order() == 60 assert G2.is_normal(G1) gens3 = [Permutation(p) for p in [[2, 1, 3, 0, 4], [1, 2, 0, 3, 4]]] G3 = PermutationGroup(gens3) assert not G3.is_normal(G1) assert G3.order() == 12 G4 = G1.normal_closure(G3.generators) assert G4.order() == 60 gens5 = [Permutation(p) for p in [[1, 2, 3, 0, 4], [1, 2, 0, 3, 4]]] G5 = PermutationGroup(gens5) assert G5.order() == 24 G6 = G1.normal_closure(G5.generators) assert G6.order() == 120 assert G1.is_subgroup(G6) assert not G1.is_subgroup(G4) assert G2.is_subgroup(G4) I5 = PermutationGroup(Permutation(4)) assert I5.is_normal(G5) assert I5.is_normal(G6, strict=False) p1 = Permutation([1, 0, 2, 3, 4]) p2 = Permutation([0, 1, 2, 4, 3]) p3 = Permutation([3, 4, 2, 1, 0]) id_ = Permutation([0, 1, 2, 3, 4]) H = PermutationGroup([p1, p3]) H_n1 = PermutationGroup([p1, p2]) H_n2_1 = PermutationGroup(p1) H_n2_2 = PermutationGroup(p2) H_id = PermutationGroup(id_) assert H_n1.is_normal(H) assert H_n2_1.is_normal(H_n1) assert H_n2_2.is_normal(H_n1) assert H_id.is_normal(H_n2_1) assert H_id.is_normal(H_n1) assert H_id.is_normal(H) assert not H_n2_1.is_normal(H) assert not H_n2_2.is_normal(H) def test_eq(): a = [[1, 2, 0, 3, 4, 5], [1, 0, 2, 3, 4, 5], [2, 1, 0, 3, 4, 5], [ 1, 2, 0, 3, 4, 5]] a = [Permutation(p) for p in a + [[1, 2, 3, 4, 5, 0]]] g = Permutation([1, 2, 3, 4, 5, 0]) G1, G2, G3 = [PermutationGroup(x) for x in [a[:2], a[2:4], [g, g**2]]] assert G1.order() == G2.order() == G3.order() == 6 assert G1.is_subgroup(G2) assert not G1.is_subgroup(G3) G4 = PermutationGroup([Permutation([0, 1])]) assert not G1.is_subgroup(G4) assert G4.is_subgroup(G1, 0) assert PermutationGroup(g, g).is_subgroup(PermutationGroup(g)) assert SymmetricGroup(3).is_subgroup(SymmetricGroup(4), 0) assert SymmetricGroup(3).is_subgroup(SymmetricGroup(3)*CyclicGroup(5), 0) assert not CyclicGroup(5).is_subgroup(SymmetricGroup(3)*CyclicGroup(5), 0) assert CyclicGroup(3).is_subgroup(SymmetricGroup(3)*CyclicGroup(5), 0) def test_derived_subgroup(): a = Permutation([1, 0, 2, 4, 3]) b = Permutation([0, 1, 3, 2, 4]) G = PermutationGroup([a, b]) C = G.derived_subgroup() assert C.order() == 3 assert C.is_normal(G) assert C.is_subgroup(G, 0) assert not G.is_subgroup(C, 0) gens_cube = [[1, 3, 5, 7, 0, 2, 4, 6], [1, 3, 0, 2, 5, 7, 4, 6]] gens = [Permutation(p) for p in gens_cube] G = PermutationGroup(gens) C = G.derived_subgroup() assert C.order() == 12 def test_is_solvable(): a = Permutation([1, 2, 0]) b = Permutation([1, 0, 2]) G = PermutationGroup([a, b]) assert G.is_solvable G = PermutationGroup([a]) assert G.is_solvable a = Permutation([1, 2, 3, 4, 0]) b = Permutation([1, 0, 2, 3, 4]) G = PermutationGroup([a, b]) assert not G.is_solvable P = SymmetricGroup(10) S = P.sylow_subgroup(3) assert S.is_solvable def test_rubik1(): gens = rubik_cube_generators() gens1 = [gens[-1]] + [p**2 for p in gens[1:]] G1 = PermutationGroup(gens1) assert G1.order() == 19508428800 gens2 = [p**2 for p in gens] G2 = PermutationGroup(gens2) assert G2.order() == 663552 assert G2.is_subgroup(G1, 0) C1 = G1.derived_subgroup() assert C1.order() == 4877107200 assert C1.is_subgroup(G1, 0) assert not G2.is_subgroup(C1, 0) G = RubikGroup(2) assert G.order() == 3674160 @XFAIL def test_rubik(): skip('takes too much time') G = PermutationGroup(rubik_cube_generators()) assert G.order() == 43252003274489856000 G1 = PermutationGroup(G[:3]) assert G1.order() == 170659735142400 assert not G1.is_normal(G) G2 = G.normal_closure(G1.generators) assert G2.is_subgroup(G) def test_direct_product(): C = CyclicGroup(4) D = DihedralGroup(4) G = C*C*C assert G.order() == 64 assert G.degree == 12 assert len(G.orbits()) == 3 assert G.is_abelian is True H = D*C assert H.order() == 32 assert H.is_abelian is False def test_orbit_rep(): G = DihedralGroup(6) assert G.orbit_rep(1, 3) in [Permutation([2, 3, 4, 5, 0, 1]), Permutation([4, 3, 2, 1, 0, 5])] H = CyclicGroup(4)*G assert H.orbit_rep(1, 5) is False def test_schreier_vector(): G = CyclicGroup(50) v = [0]*50 v[23] = -1 assert G.schreier_vector(23) == v H = DihedralGroup(8) assert H.schreier_vector(2) == [0, 1, -1, 0, 0, 1, 0, 0] L = SymmetricGroup(4) assert L.schreier_vector(1) == [1, -1, 0, 0] def test_random_pr(): D = DihedralGroup(6) r = 11 n = 3 _random_prec_n = {} _random_prec_n[0] = {'s': 7, 't': 3, 'x': 2, 'e': -1} _random_prec_n[1] = {'s': 5, 't': 5, 'x': 1, 'e': -1} _random_prec_n[2] = {'s': 3, 't': 4, 'x': 2, 'e': 1} D._random_pr_init(r, n, _random_prec_n=_random_prec_n) assert D._random_gens[11] == [0, 1, 2, 3, 4, 5] _random_prec = {'s': 2, 't': 9, 'x': 1, 'e': -1} assert D.random_pr(_random_prec=_random_prec) == \ Permutation([0, 5, 4, 3, 2, 1]) def test_is_alt_sym(): G = DihedralGroup(10) assert G.is_alt_sym() is False S = SymmetricGroup(10) N_eps = 10 _random_prec = {'N_eps': N_eps, 0: Permutation([[2], [1, 4], [0, 6, 7, 8, 9, 3, 5]]), 1: Permutation([[1, 8, 7, 6, 3, 5, 2, 9], [0, 4]]), 2: Permutation([[5, 8], [4, 7], [0, 1, 2, 3, 6, 9]]), 3: Permutation([[3], [0, 8, 2, 7, 4, 1, 6, 9, 5]]), 4: Permutation([[8], [4, 7, 9], [3, 6], [0, 5, 1, 2]]), 5: Permutation([[6], [0, 2, 4, 5, 1, 8, 3, 9, 7]]), 6: Permutation([[6, 9, 8], [4, 5], [1, 3, 7], [0, 2]]), 7: Permutation([[4], [0, 2, 9, 1, 3, 8, 6, 5, 7]]), 8: Permutation([[1, 5, 6, 3], [0, 2, 7, 8, 4, 9]]), 9: Permutation([[8], [6, 7], [2, 3, 4, 5], [0, 1, 9]])} assert S.is_alt_sym(_random_prec=_random_prec) is True A = AlternatingGroup(10) _random_prec = {'N_eps': N_eps, 0: Permutation([[1, 6, 4, 2, 7, 8, 5, 9, 3], [0]]), 1: Permutation([[1], [0, 5, 8, 4, 9, 2, 3, 6, 7]]), 2: Permutation([[1, 9, 8, 3, 2, 5], [0, 6, 7, 4]]), 3: Permutation([[6, 8, 9], [4, 5], [1, 3, 7, 2], [0]]), 4: Permutation([[8], [5], [4], [2, 6, 9, 3], [1], [0, 7]]), 5: Permutation([[3, 6], [0, 8, 1, 7, 5, 9, 4, 2]]), 6: Permutation([[5], [2, 9], [1, 8, 3], [0, 4, 7, 6]]), 7: Permutation([[1, 8, 4, 7, 2, 3], [0, 6, 9, 5]]), 8: Permutation([[5, 8, 7], [3], [1, 4, 2, 6], [0, 9]]), 9: Permutation([[4, 9, 6], [3, 8], [1, 2], [0, 5, 7]])} assert A.is_alt_sym(_random_prec=_random_prec) is False def test_minimal_block(): D = DihedralGroup(6) block_system = D.minimal_block([0, 3]) for i in range(3): assert block_system[i] == block_system[i + 3] S = SymmetricGroup(6) assert S.minimal_block([0, 1]) == [0, 0, 0, 0, 0, 0] assert Tetra.pgroup.minimal_block([0, 1]) == [0, 0, 0, 0] P1 = PermutationGroup(Permutation(1, 5)(2, 4), Permutation(0, 1, 2, 3, 4, 5)) P2 = PermutationGroup(Permutation(0, 1, 2, 3, 4, 5), Permutation(1, 5)(2, 4)) assert P1.minimal_block([0, 2]) == [0, 1, 0, 1, 0, 1] assert P2.minimal_block([0, 2]) == [0, 1, 0, 1, 0, 1] def test_minimal_blocks(): P = PermutationGroup(Permutation(1, 5)(2, 4), Permutation(0, 1, 2, 3, 4, 5)) assert P.minimal_blocks() == [[0, 1, 0, 1, 0, 1], [0, 1, 2, 0, 1, 2]] P = SymmetricGroup(5) assert P.minimal_blocks() == [[0]*5] P = PermutationGroup(Permutation(0, 3)) assert P.minimal_blocks() == False def test_max_div(): S = SymmetricGroup(10) assert S.max_div == 5 def test_is_primitive(): S = SymmetricGroup(5) assert S.is_primitive() is True C = CyclicGroup(7) assert C.is_primitive() is True def test_random_stab(): S = SymmetricGroup(5) _random_el = Permutation([1, 3, 2, 0, 4]) _random_prec = {'rand': _random_el} g = S.random_stab(2, _random_prec=_random_prec) assert g == Permutation([1, 3, 2, 0, 4]) h = S.random_stab(1) assert h(1) == 1 def test_transitivity_degree(): perm = Permutation([1, 2, 0]) C = PermutationGroup([perm]) assert C.transitivity_degree == 1 gen1 = Permutation([1, 2, 0, 3, 4]) gen2 = Permutation([1, 2, 3, 4, 0]) # alternating group of degree 5 Alt = PermutationGroup([gen1, gen2]) assert Alt.transitivity_degree == 3 def test_schreier_sims_random(): assert sorted(Tetra.pgroup.base) == [0, 1] S = SymmetricGroup(3) base = [0, 1] strong_gens = [Permutation([1, 2, 0]), Permutation([1, 0, 2]), Permutation([0, 2, 1])] assert S.schreier_sims_random(base, strong_gens, 5) == (base, strong_gens) D = DihedralGroup(3) _random_prec = {'g': [Permutation([2, 0, 1]), Permutation([1, 2, 0]), Permutation([1, 0, 2])]} base = [0, 1] strong_gens = [Permutation([1, 2, 0]), Permutation([2, 1, 0]), Permutation([0, 2, 1])] assert D.schreier_sims_random([], D.generators, 2, _random_prec=_random_prec) == (base, strong_gens) def test_baseswap(): S = SymmetricGroup(4) S.schreier_sims() base = S.base strong_gens = S.strong_gens assert base == [0, 1, 2] deterministic = S.baseswap(base, strong_gens, 1, randomized=False) randomized = S.baseswap(base, strong_gens, 1) assert deterministic[0] == [0, 2, 1] assert _verify_bsgs(S, deterministic[0], deterministic[1]) is True assert randomized[0] == [0, 2, 1] assert _verify_bsgs(S, randomized[0], randomized[1]) is True def test_schreier_sims_incremental(): identity = Permutation([0, 1, 2, 3, 4]) TrivialGroup = PermutationGroup([identity]) base, strong_gens = TrivialGroup.schreier_sims_incremental(base=[0, 1, 2]) assert _verify_bsgs(TrivialGroup, base, strong_gens) is True S = SymmetricGroup(5) base, strong_gens = S.schreier_sims_incremental(base=[0, 1, 2]) assert _verify_bsgs(S, base, strong_gens) is True D = DihedralGroup(2) base, strong_gens = D.schreier_sims_incremental(base=[1]) assert _verify_bsgs(D, base, strong_gens) is True A = AlternatingGroup(7) gens = A.generators[:] gen0 = gens[0] gen1 = gens[1] gen1 = rmul(gen1, ~gen0) gen0 = rmul(gen0, gen1) gen1 = rmul(gen0, gen1) base, strong_gens = A.schreier_sims_incremental(base=[0, 1], gens=gens) assert _verify_bsgs(A, base, strong_gens) is True C = CyclicGroup(11) gen = C.generators[0] base, strong_gens = C.schreier_sims_incremental(gens=[gen**3]) assert _verify_bsgs(C, base, strong_gens) is True def _subgroup_search(i, j, k): prop_true = lambda x: True prop_fix_points = lambda x: [x(point) for point in points] == points prop_comm_g = lambda x: rmul(x, g) == rmul(g, x) prop_even = lambda x: x.is_even for i in range(i, j, k): S = SymmetricGroup(i) A = AlternatingGroup(i) C = CyclicGroup(i) Sym = S.subgroup_search(prop_true) assert Sym.is_subgroup(S) Alt = S.subgroup_search(prop_even) assert Alt.is_subgroup(A) Sym = S.subgroup_search(prop_true, init_subgroup=C) assert Sym.is_subgroup(S) points = [7] assert S.stabilizer(7).is_subgroup(S.subgroup_search(prop_fix_points)) points = [3, 4] assert S.stabilizer(3).stabilizer(4).is_subgroup( S.subgroup_search(prop_fix_points)) points = [3, 5] fix35 = A.subgroup_search(prop_fix_points) points = [5] fix5 = A.subgroup_search(prop_fix_points) assert A.subgroup_search(prop_fix_points, init_subgroup=fix35 ).is_subgroup(fix5) base, strong_gens = A.schreier_sims_incremental() g = A.generators[0] comm_g = \ A.subgroup_search(prop_comm_g, base=base, strong_gens=strong_gens) assert _verify_bsgs(comm_g, base, comm_g.generators) is True assert [prop_comm_g(gen) is True for gen in comm_g.generators] def test_subgroup_search(): _subgroup_search(10, 15, 2) @XFAIL def test_subgroup_search2(): skip('takes too much time') _subgroup_search(16, 17, 1) def test_normal_closure(): # the normal closure of the trivial group is trivial S = SymmetricGroup(3) identity = Permutation([0, 1, 2]) closure = S.normal_closure(identity) assert closure.is_trivial # the normal closure of the entire group is the entire group A = AlternatingGroup(4) assert A.normal_closure(A).is_subgroup(A) # brute-force verifications for subgroups for i in (3, 4, 5): S = SymmetricGroup(i) A = AlternatingGroup(i) D = DihedralGroup(i) C = CyclicGroup(i) for gp in (A, D, C): assert _verify_normal_closure(S, gp) # brute-force verifications for all elements of a group S = SymmetricGroup(5) elements = list(S.generate_dimino()) for element in elements: assert _verify_normal_closure(S, element) # small groups small = [] for i in (1, 2, 3): small.append(SymmetricGroup(i)) small.append(AlternatingGroup(i)) small.append(DihedralGroup(i)) small.append(CyclicGroup(i)) for gp in small: for gp2 in small: if gp2.is_subgroup(gp, 0) and gp2.degree == gp.degree: assert _verify_normal_closure(gp, gp2) def test_derived_series(): # the derived series of the trivial group consists only of the trivial group triv = PermutationGroup([Permutation([0, 1, 2])]) assert triv.derived_series()[0].is_subgroup(triv) # the derived series for a simple group consists only of the group itself for i in (5, 6, 7): A = AlternatingGroup(i) assert A.derived_series()[0].is_subgroup(A) # the derived series for S_4 is S_4 > A_4 > K_4 > triv S = SymmetricGroup(4) series = S.derived_series() assert series[1].is_subgroup(AlternatingGroup(4)) assert series[2].is_subgroup(DihedralGroup(2)) assert series[3].is_trivial def test_lower_central_series(): # the lower central series of the trivial group consists of the trivial # group triv = PermutationGroup([Permutation([0, 1, 2])]) assert triv.lower_central_series()[0].is_subgroup(triv) # the lower central series of a simple group consists of the group itself for i in (5, 6, 7): A = AlternatingGroup(i) assert A.lower_central_series()[0].is_subgroup(A) # GAP-verified example S = SymmetricGroup(6) series = S.lower_central_series() assert len(series) == 2 assert series[1].is_subgroup(AlternatingGroup(6)) def test_commutator(): # the commutator of the trivial group and the trivial group is trivial S = SymmetricGroup(3) triv = PermutationGroup([Permutation([0, 1, 2])]) assert S.commutator(triv, triv).is_subgroup(triv) # the commutator of the trivial group and any other group is again trivial A = AlternatingGroup(3) assert S.commutator(triv, A).is_subgroup(triv) # the commutator is commutative for i in (3, 4, 5): S = SymmetricGroup(i) A = AlternatingGroup(i) D = DihedralGroup(i) assert S.commutator(A, D).is_subgroup(S.commutator(D, A)) # the commutator of an abelian group is trivial S = SymmetricGroup(7) A1 = AbelianGroup(2, 5) A2 = AbelianGroup(3, 4) triv = PermutationGroup([Permutation([0, 1, 2, 3, 4, 5, 6])]) assert S.commutator(A1, A1).is_subgroup(triv) assert S.commutator(A2, A2).is_subgroup(triv) # examples calculated by hand S = SymmetricGroup(3) A = AlternatingGroup(3) assert S.commutator(A, S).is_subgroup(A) def test_is_nilpotent(): # every abelian group is nilpotent for i in (1, 2, 3): C = CyclicGroup(i) Ab = AbelianGroup(i, i + 2) assert C.is_nilpotent assert Ab.is_nilpotent Ab = AbelianGroup(5, 7, 10) assert Ab.is_nilpotent # A_5 is not solvable and thus not nilpotent assert AlternatingGroup(5).is_nilpotent is False def test_is_trivial(): for i in range(5): triv = PermutationGroup([Permutation(list(range(i)))]) assert triv.is_trivial def test_pointwise_stabilizer(): S = SymmetricGroup(2) stab = S.pointwise_stabilizer([0]) assert stab.generators == [Permutation(1)] S = SymmetricGroup(5) points = [] stab = S for point in (2, 0, 3, 4, 1): stab = stab.stabilizer(point) points.append(point) assert S.pointwise_stabilizer(points).is_subgroup(stab) def test_make_perm(): assert cube.pgroup.make_perm(5, seed=list(range(5))) == \ Permutation([4, 7, 6, 5, 0, 3, 2, 1]) assert cube.pgroup.make_perm(7, seed=list(range(7))) == \ Permutation([6, 7, 3, 2, 5, 4, 0, 1]) def test_elements(): p = Permutation(2, 3) assert PermutationGroup(p).elements == {Permutation(3), Permutation(2, 3)} def test_is_group(): assert PermutationGroup(Permutation(1,2), Permutation(2,4)).is_group == True assert SymmetricGroup(4).is_group == True def test_PermutationGroup(): assert PermutationGroup() == PermutationGroup(Permutation()) assert (PermutationGroup() == 0) is False def test_coset_transvesal(): G = AlternatingGroup(5) H = PermutationGroup(Permutation(0,1,2),Permutation(1,2)(3,4)) assert G.coset_transversal(H) == \ [Permutation(4), Permutation(2, 3, 4), Permutation(2, 4, 3), Permutation(1, 2, 4), Permutation(4)(1, 2, 3), Permutation(1, 3)(2, 4), Permutation(0, 1, 2, 3, 4), Permutation(0, 1, 2, 4, 3), Permutation(0, 1, 3, 2, 4), Permutation(0, 2, 4, 1, 3)] def test_coset_table(): G = PermutationGroup(Permutation(0,1,2,3), Permutation(0,1,2), Permutation(0,4,2,7), Permutation(5,6), Permutation(0,7)); H = PermutationGroup(Permutation(0,1,2,3), Permutation(0,7)) assert G.coset_table(H) == \ [[0, 0, 0, 0, 1, 2, 3, 3, 0, 0], [4, 5, 2, 5, 6, 0, 7, 7, 1, 1], [5, 4, 5, 1, 0, 6, 8, 8, 6, 6], [3, 3, 3, 3, 7, 8, 0, 0, 3, 3], [2, 1, 4, 4, 4, 4, 9, 9, 4, 4], [1, 2, 1, 2, 5, 5, 10, 10, 5, 5], [6, 6, 6, 6, 2, 1, 11, 11, 2, 2], [9, 10, 8, 10, 11, 3, 1, 1, 7, 7], [10, 9, 10, 7, 3, 11, 2, 2, 11, 11], [8, 7, 9, 9, 9, 9, 4, 4, 9, 9], [7, 8, 7, 8, 10, 10, 5, 5, 10, 10], [11, 11, 11, 11, 8, 7, 6, 6, 8, 8]] def test_subgroup(): G = PermutationGroup(Permutation(0,1,2), Permutation(0,2,3)) H = G.subgroup([Permutation(0,1,3)]) assert H.is_subgroup(G) def test_generator_product(): G = SymmetricGroup(5) p = Permutation(0, 2, 3)(1, 4) gens = G.generator_product(p) assert all(g in G.strong_gens for g in gens) w = G.identity for g in gens: w = g*w assert w == p def test_sylow_subgroup(): P = PermutationGroup(Permutation(1, 5)(2, 4), Permutation(0, 1, 2, 3, 4, 5)) S = P.sylow_subgroup(2) assert S.order() == 4 P = DihedralGroup(12) S = P.sylow_subgroup(3) assert S.order() == 3 P = PermutationGroup(Permutation(1, 5)(2, 4), Permutation(0, 1, 2, 3, 4, 5), Permutation(0, 2)) S = P.sylow_subgroup(3) assert S.order() == 9 S = P.sylow_subgroup(2) assert S.order() == 8 P = SymmetricGroup(10) S = P.sylow_subgroup(2) assert S.order() == 256 S = P.sylow_subgroup(3) assert S.order() == 81 S = P.sylow_subgroup(5) assert S.order() == 25 # the length of the lower central series # of a p-Sylow subgroup of Sym(n) grows with # the highest exponent exp of p such # that n >= p**exp exp = 1 length = 0 for i in range(2, 9): P = SymmetricGroup(i) S = P.sylow_subgroup(2) ls = S.lower_central_series() if i // 2**exp > 0: # length increases with exponent assert len(ls) > length length = len(ls) exp += 1 else: assert len(ls) == length G = SymmetricGroup(100) S = G.sylow_subgroup(3) assert G.order() % S.order() == 0 assert G.order()/S.order() % 3 > 0 G = AlternatingGroup(100) S = G.sylow_subgroup(2) assert G.order() % S.order() == 0 assert G.order()/S.order() % 2 > 0 @slow def test_presentation(): def _test(P): G = P.presentation() return G.order() == P.order() def _strong_test(P): G = P.strong_presentation() chk = len(G.generators) == len(P.strong_gens) return chk and G.order() == P.order() P = PermutationGroup(Permutation(0,1,5,2)(3,7,4,6), Permutation(0,3,5,4)(1,6,2,7)) assert _test(P) P = AlternatingGroup(5) assert _test(P) P = SymmetricGroup(5) assert _test(P) P = PermutationGroup([Permutation(0,3,1,2), Permutation(3)(0,1), Permutation(0,1)(2,3)]) G = P.strong_presentation() assert _strong_test(P) P = DihedralGroup(6) G = P.strong_presentation() assert _strong_test(P) a = Permutation(0,1)(2,3) b = Permutation(0,2)(3,1) c = Permutation(4,5) P = PermutationGroup(c, a, b) assert _strong_test(P) def test_polycyclic(): a = Permutation([0, 1, 2]) b = Permutation([2, 1, 0]) G = PermutationGroup([a, b]) assert G.is_polycyclic == True a = Permutation([1, 2, 3, 4, 0]) b = Permutation([1, 0, 2, 3, 4]) G = PermutationGroup([a, b]) assert G.is_polycyclic == False def test_elementary(): a = Permutation([1, 5, 2, 0, 3, 6, 4]) G = PermutationGroup([a]) assert G.is_elementary(7) == False a = Permutation(0, 1)(2, 3) b = Permutation(0, 2)(3, 1) G = PermutationGroup([a, b]) assert G.is_elementary(2) == True c = Permutation(4, 5, 6) G = PermutationGroup([a, b, c]) assert G.is_elementary(2) == False G = SymmetricGroup(4).sylow_subgroup(2) assert G.is_elementary(2) == False H = AlternatingGroup(4).sylow_subgroup(2) assert H.is_elementary(2) == True def test_perfect(): G = AlternatingGroup(3) assert G.is_perfect == False G = AlternatingGroup(5) assert G.is_perfect == True def test_index(): G = PermutationGroup(Permutation(0,1,2), Permutation(0,2,3)) H = G.subgroup([Permutation(0,1,3)]) assert G.index(H) == 4 def test_cyclic(): G = SymmetricGroup(2) assert G.is_cyclic G = AbelianGroup(3, 7) assert G.is_cyclic G = AbelianGroup(7, 7) assert not G.is_cyclic G = AlternatingGroup(3) assert G.is_cyclic G = AlternatingGroup(4) assert not G.is_cyclic
befb58cba163d92643a1f87311efb27e7a25fac3323689c082bb2be9298572c3
from sympy.core.compatibility import range, ordered from sympy.combinatorics.partitions import (Partition, IntegerPartition, RGS_enum, RGS_unrank, RGS_rank, random_integer_partition) from sympy.utilities.pytest import raises from sympy.utilities.iterables import default_sort_key, partitions from sympy.sets.sets import Set def test_partition(): from sympy.abc import x raises(ValueError, lambda: Partition(*list(range(3)))) raises(ValueError, lambda: Partition([1, 1, 2])) a = Partition([1, 2, 3], [4]) b = Partition([1, 2], [3, 4]) c = Partition([x]) l = [a, b, c] l.sort(key=default_sort_key) assert l == [c, a, b] l.sort(key=lambda w: default_sort_key(w, order='rev-lex')) assert l == [c, a, b] assert (a == b) is False assert a <= b assert (a > b) is False assert a != b assert a < b assert (a + 2).partition == [[1, 2], [3, 4]] assert (b - 1).partition == [[1, 2, 4], [3]] assert (a - 1).partition == [[1, 2, 3, 4]] assert (a + 1).partition == [[1, 2, 4], [3]] assert (b + 1).partition == [[1, 2], [3], [4]] assert a.rank == 1 assert b.rank == 3 assert a.RGS == (0, 0, 0, 1) assert b.RGS == (0, 0, 1, 1) def test_integer_partition(): # no zeros in partition raises(ValueError, lambda: IntegerPartition(list(range(3)))) # check fails since 1 + 2 != 100 raises(ValueError, lambda: IntegerPartition(100, list(range(1, 3)))) a = IntegerPartition(8, [1, 3, 4]) b = a.next_lex() c = IntegerPartition([1, 3, 4]) d = IntegerPartition(8, {1: 3, 3: 1, 2: 1}) assert a == c assert a.integer == d.integer assert a.conjugate == [3, 2, 2, 1] assert (a == b) is False assert a <= b assert (a > b) is False assert a != b for i in range(1, 11): next = set() prev = set() a = IntegerPartition([i]) ans = {IntegerPartition(p) for p in partitions(i)} n = len(ans) for j in range(n): next.add(a) a = a.next_lex() IntegerPartition(i, a.partition) # check it by giving i for j in range(n): prev.add(a) a = a.prev_lex() IntegerPartition(i, a.partition) # check it by giving i assert next == ans assert prev == ans assert IntegerPartition([1, 2, 3]).as_ferrers() == '###\n##\n#' assert IntegerPartition([1, 1, 3]).as_ferrers('o') == 'ooo\no\no' assert str(IntegerPartition([1, 1, 3])) == '[3, 1, 1]' assert IntegerPartition([1, 1, 3]).partition == [3, 1, 1] raises(ValueError, lambda: random_integer_partition(-1)) assert random_integer_partition(1) == [1] assert random_integer_partition(10, seed=[1, 3, 2, 1, 5, 1] ) == [5, 2, 1, 1, 1] def test_rgs(): raises(ValueError, lambda: RGS_unrank(-1, 3)) raises(ValueError, lambda: RGS_unrank(3, 0)) raises(ValueError, lambda: RGS_unrank(10, 1)) raises(ValueError, lambda: Partition.from_rgs(list(range(3)), list(range(2)))) raises(ValueError, lambda: Partition.from_rgs(list(range(1, 3)), list(range(2)))) assert RGS_enum(-1) == 0 assert RGS_enum(1) == 1 assert RGS_unrank(7, 5) == [0, 0, 1, 0, 2] assert RGS_unrank(23, 14) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 2, 2] assert RGS_rank(RGS_unrank(40, 100)) == 40 def test_ordered_partition_9608(): a = Partition([1, 2, 3], [4]) b = Partition([1, 2], [3, 4]) assert list(ordered([a,b], Set._infimum_key))
b2765295297f70ab91898dc44de7c1a7f116f37465883fed3acc1a954e0a886e
from sympy import ( symbols, powsimp, symbols, MatrixSymbol, sqrt, pi, Mul, gamma, Function, S, I, exp, simplify, sin, E, log, hyper, Symbol, Dummy, powdenest, root, Rational, oo) from sympy.abc import x, y, z, t, a, b, c, d, e, f, g, h, i, k def test_powsimp(): x, y, z, n = symbols('x,y,z,n') f = Function('f') assert powsimp( 4**x * 2**(-x) * 2**(-x) ) == 1 assert powsimp( (-4)**x * (-2)**(-x) * 2**(-x) ) == 1 assert powsimp( f(4**x * 2**(-x) * 2**(-x)) ) == f(4**x * 2**(-x) * 2**(-x)) assert powsimp( f(4**x * 2**(-x) * 2**(-x)), deep=True ) == f(1) assert exp(x)*exp(y) == exp(x)*exp(y) assert powsimp(exp(x)*exp(y)) == exp(x + y) assert powsimp(exp(x)*exp(y)*2**x*2**y) == (2*E)**(x + y) assert powsimp(exp(x)*exp(y)*2**x*2**y, combine='exp') == \ exp(x + y)*2**(x + y) assert powsimp(exp(x)*exp(y)*exp(2)*sin(x) + sin(y) + 2**x*2**y) == \ exp(2 + x + y)*sin(x) + sin(y) + 2**(x + y) assert powsimp(sin(exp(x)*exp(y))) == sin(exp(x)*exp(y)) assert powsimp(sin(exp(x)*exp(y)), deep=True) == sin(exp(x + y)) assert powsimp(x**2*x**y) == x**(2 + y) # This should remain factored, because 'exp' with deep=True is supposed # to act like old automatic exponent combining. assert powsimp((1 + E*exp(E))*exp(-E), combine='exp', deep=True) == \ (1 + exp(1 + E))*exp(-E) assert powsimp((1 + E*exp(E))*exp(-E), deep=True) == \ (1 + exp(1 + E))*exp(-E) assert powsimp((1 + E*exp(E))*exp(-E)) == (1 + exp(1 + E))*exp(-E) assert powsimp((1 + E*exp(E))*exp(-E), combine='exp') == \ (1 + exp(1 + E))*exp(-E) assert powsimp((1 + E*exp(E))*exp(-E), combine='base') == \ (1 + E*exp(E))*exp(-E) x, y = symbols('x,y', nonnegative=True) n = Symbol('n', real=True) assert powsimp(y**n * (y/x)**(-n)) == x**n assert powsimp(x**(x**(x*y)*y**(x*y))*y**(x**(x*y)*y**(x*y)), deep=True) \ == (x*y)**(x*y)**(x*y) assert powsimp(2**(2**(2*x)*x), deep=False) == 2**(2**(2*x)*x) assert powsimp(2**(2**(2*x)*x), deep=True) == 2**(x*4**x) assert powsimp( exp(-x + exp(-x)*exp(-x*log(x))), deep=False, combine='exp') == \ exp(-x + exp(-x)*exp(-x*log(x))) assert powsimp( exp(-x + exp(-x)*exp(-x*log(x))), deep=False, combine='exp') == \ exp(-x + exp(-x)*exp(-x*log(x))) assert powsimp((x + y)/(3*z), deep=False, combine='exp') == (x + y)/(3*z) assert powsimp((x/3 + y/3)/z, deep=True, combine='exp') == (x/3 + y/3)/z assert powsimp(exp(x)/(1 + exp(x)*exp(y)), deep=True) == \ exp(x)/(1 + exp(x + y)) assert powsimp(x*y**(z**x*z**y), deep=True) == x*y**(z**(x + y)) assert powsimp((z**x*z**y)**x, deep=True) == (z**(x + y))**x assert powsimp(x*(z**x*z**y)**x, deep=True) == x*(z**(x + y))**x p = symbols('p', positive=True) assert powsimp((1/x)**log(2)/x) == (1/x)**(1 + log(2)) assert powsimp((1/p)**log(2)/p) == p**(-1 - log(2)) # coefficient of exponent can only be simplified for positive bases assert powsimp(2**(2*x)) == 4**x assert powsimp((-1)**(2*x)) == (-1)**(2*x) i = symbols('i', integer=True) assert powsimp((-1)**(2*i)) == 1 assert powsimp((-1)**(-x)) != (-1)**x # could be 1/((-1)**x), but is not # force=True overrides assumptions assert powsimp((-1)**(2*x), force=True) == 1 # rational exponents allow combining of negative terms w, n, m = symbols('w n m', negative=True) e = i/a # not a rational exponent if `a` is unknown ex = w**e*n**e*m**e assert powsimp(ex) == m**(i/a)*n**(i/a)*w**(i/a) e = i/3 ex = w**e*n**e*m**e assert powsimp(ex) == (-1)**i*(-m*n*w)**(i/3) e = (3 + i)/i ex = w**e*n**e*m**e assert powsimp(ex) == (-1)**(3*e)*(-m*n*w)**e eq = x**(2*a/3) # eq != (x**a)**(2/3) (try x = -1 and a = 3 to see) assert powsimp(eq).exp == eq.exp == 2*a/3 # powdenest goes the other direction assert powsimp(2**(2*x)) == 4**x assert powsimp(exp(p/2)) == exp(p/2) # issue 6368 eq = Mul(*[sqrt(Dummy(imaginary=True)) for i in range(3)]) assert powsimp(eq) == eq and eq.is_Mul assert all(powsimp(e) == e for e in (sqrt(x**a), sqrt(x**2))) # issue 8836 assert str( powsimp(exp(I*pi/3)*root(-1,3)) ) == '(-1)**(2/3)' # issue 9183 assert powsimp(-0.1**x) == -0.1**x # issue 10095 assert powsimp((1/(2*E))**oo) == (exp(-1)/2)**oo # PR 13131 eq = sin(2*x)**2*sin(2.0*x)**2 assert powsimp(eq) == eq # issue 14615 assert powsimp(x**2*y**3*(x*y**2)**(S(3)/2) ) == x*y*(x*y**2)**(S(5)/2) def test_powsimp_negated_base(): assert powsimp((-x + y)/sqrt(x - y)) == -sqrt(x - y) assert powsimp((-x + y)*(-z + y)/sqrt(x - y)/sqrt(z - y)) == sqrt(x - y)*sqrt(z - y) p = symbols('p', positive=True) assert powsimp((-p)**a/p**a) == (-1)**a n = symbols('n', negative=True) assert powsimp((-n)**a/n**a) == (-1)**a # if x is 0 then the lhs is 0**a*oo**a which is not (-1)**a assert powsimp((-x)**a/x**a) != (-1)**a def test_powsimp_nc(): x, y, z = symbols('x,y,z') A, B, C = symbols('A B C', commutative=False) assert powsimp(A**x*A**y, combine='all') == A**(x + y) assert powsimp(A**x*A**y, combine='base') == A**x*A**y assert powsimp(A**x*A**y, combine='exp') == A**(x + y) assert powsimp(A**x*B**x, combine='all') == A**x*B**x assert powsimp(A**x*B**x, combine='base') == A**x*B**x assert powsimp(A**x*B**x, combine='exp') == A**x*B**x assert powsimp(B**x*A**x, combine='all') == B**x*A**x assert powsimp(B**x*A**x, combine='base') == B**x*A**x assert powsimp(B**x*A**x, combine='exp') == B**x*A**x assert powsimp(A**x*A**y*A**z, combine='all') == A**(x + y + z) assert powsimp(A**x*A**y*A**z, combine='base') == A**x*A**y*A**z assert powsimp(A**x*A**y*A**z, combine='exp') == A**(x + y + z) assert powsimp(A**x*B**x*C**x, combine='all') == A**x*B**x*C**x assert powsimp(A**x*B**x*C**x, combine='base') == A**x*B**x*C**x assert powsimp(A**x*B**x*C**x, combine='exp') == A**x*B**x*C**x assert powsimp(B**x*A**x*C**x, combine='all') == B**x*A**x*C**x assert powsimp(B**x*A**x*C**x, combine='base') == B**x*A**x*C**x assert powsimp(B**x*A**x*C**x, combine='exp') == B**x*A**x*C**x def test_issue_6440(): assert powsimp(16*2**a*8**b) == 2**(a + 3*b + 4) def test_powdenest(): from sympy import powdenest from sympy.abc import x, y, z, a, b p, q = symbols('p q', positive=True) i, j = symbols('i,j', integer=True) assert powdenest(x) == x assert powdenest(x + 2*(x**(2*a/3))**(3*x)) == (x + 2*(x**(2*a/3))**(3*x)) assert powdenest((exp(2*a/3))**(3*x)) # -X-> (exp(a/3))**(6*x) assert powdenest((x**(2*a/3))**(3*x)) == ((x**(2*a/3))**(3*x)) assert powdenest(exp(3*x*log(2))) == 2**(3*x) assert powdenest(sqrt(p**2)) == p i, j = symbols('i,j', integer=True) eq = p**(2*i)*q**(4*i) assert powdenest(eq) == (p*q**2)**(2*i) # -X-> (x**x)**i*(x**x)**j == x**(x*(i + j)) assert powdenest((x**x)**(i + j)) assert powdenest(exp(3*y*log(x))) == x**(3*y) assert powdenest(exp(y*(log(a) + log(b)))) == (a*b)**y assert powdenest(exp(3*(log(a) + log(b)))) == a**3*b**3 assert powdenest(((x**(2*i))**(3*y))**x) == ((x**(2*i))**(3*y))**x assert powdenest(((x**(2*i))**(3*y))**x, force=True) == x**(6*i*x*y) assert powdenest(((x**(2*a/3))**(3*y/i))**x) == \ (((x**(2*a/3))**(3*y/i))**x) assert powdenest((x**(2*i)*y**(4*i))**z, force=True) == (x*y**2)**(2*i*z) assert powdenest((p**(2*i)*q**(4*i))**j) == (p*q**2)**(2*i*j) e = ((p**(2*a))**(3*y))**x assert powdenest(e) == e e = ((x**2*y**4)**a)**(x*y) assert powdenest(e) == e e = (((x**2*y**4)**a)**(x*y))**3 assert powdenest(e) == ((x**2*y**4)**a)**(3*x*y) assert powdenest((((x**2*y**4)**a)**(x*y)), force=True) == \ (x*y**2)**(2*a*x*y) assert powdenest((((x**2*y**4)**a)**(x*y))**3, force=True) == \ (x*y**2)**(6*a*x*y) assert powdenest((x**2*y**6)**i) != (x*y**3)**(2*i) x, y = symbols('x,y', positive=True) assert powdenest((x**2*y**6)**i) == (x*y**3)**(2*i) assert powdenest((x**(2*i/3)*y**(i/2))**(2*i)) == (x**(S(4)/3)*y)**(i**2) assert powdenest(sqrt(x**(2*i)*y**(6*i))) == (x*y**3)**i assert powdenest(4**x) == 2**(2*x) assert powdenest((4**x)**y) == 2**(2*x*y) assert powdenest(4**x*y) == 2**(2*x)*y def test_powdenest_polar(): x, y, z = symbols('x y z', polar=True) a, b, c = symbols('a b c') assert powdenest((x*y*z)**a) == x**a*y**a*z**a assert powdenest((x**a*y**b)**c) == x**(a*c)*y**(b*c) assert powdenest(((x**a)**b*y**c)**c) == x**(a*b*c)*y**(c**2) def test_issue_5805(): arg = ((gamma(x)*hyper((), (), x))*pi)**2 assert powdenest(arg) == (pi*gamma(x)*hyper((), (), x))**2 assert arg.is_positive is None def test_issue_9324_powsimp_on_matrix_symbol(): M = MatrixSymbol('M', 10, 10) expr = powsimp(M, deep=True) assert expr == M assert expr.args[0] == Symbol('M') def test_issue_6367(): z = -5*sqrt(2)/(2*sqrt(2*sqrt(29) + 29)) + sqrt(-sqrt(29)/29 + S(1)/2) assert Mul(*[powsimp(a) for a in Mul.make_args(z.normal())]) == 0 assert powsimp(z.normal()) == 0 assert simplify(z) == 0 assert powsimp(sqrt(2 + sqrt(3))*sqrt(2 - sqrt(3)) + 1) == 2 assert powsimp(z) != 0 def test_powsimp_polar(): from sympy import polar_lift, exp_polar x, y, z = symbols('x y z') p, q, r = symbols('p q r', polar=True) assert (polar_lift(-1))**(2*x) == exp_polar(2*pi*I*x) assert powsimp(p**x * q**x) == (p*q)**x assert p**x * (1/p)**x == 1 assert (1/p)**x == p**(-x) assert exp_polar(x)*exp_polar(y) == exp_polar(x)*exp_polar(y) assert powsimp(exp_polar(x)*exp_polar(y)) == exp_polar(x + y) assert powsimp(exp_polar(x)*exp_polar(y)*p**x*p**y) == \ (p*exp_polar(1))**(x + y) assert powsimp(exp_polar(x)*exp_polar(y)*p**x*p**y, combine='exp') == \ exp_polar(x + y)*p**(x + y) assert powsimp( exp_polar(x)*exp_polar(y)*exp_polar(2)*sin(x) + sin(y) + p**x*p**y) \ == p**(x + y) + sin(x)*exp_polar(2 + x + y) + sin(y) assert powsimp(sin(exp_polar(x)*exp_polar(y))) == \ sin(exp_polar(x)*exp_polar(y)) assert powsimp(sin(exp_polar(x)*exp_polar(y)), deep=True) == \ sin(exp_polar(x + y)) def test_issue_5728(): b = x*sqrt(y) a = sqrt(b) c = sqrt(sqrt(x)*y) assert powsimp(a*b) == sqrt(b)**3 assert powsimp(a*b**2*sqrt(y)) == sqrt(y)*a**5 assert powsimp(a*x**2*c**3*y) == c**3*a**5 assert powsimp(a*x*c**3*y**2) == c**7*a assert powsimp(x*c**3*y**2) == c**7 assert powsimp(x*c**3*y) == x*y*c**3 assert powsimp(sqrt(x)*c**3*y) == c**5 assert powsimp(sqrt(x)*a**3*sqrt(y)) == sqrt(x)*sqrt(y)*a**3 assert powsimp(Mul(sqrt(x)*c**3*sqrt(y), y, evaluate=False)) == \ sqrt(x)*sqrt(y)**3*c**3 assert powsimp(a**2*a*x**2*y) == a**7 # symbolic powers work, too b = x**y*y a = b*sqrt(b) assert a.is_Mul is True assert powsimp(a) == sqrt(b)**3 # as does exp a = x*exp(2*y/3) assert powsimp(a*sqrt(a)) == sqrt(a)**3 assert powsimp(a**2*sqrt(a)) == sqrt(a)**5 assert powsimp(a**2*sqrt(sqrt(a))) == sqrt(sqrt(a))**9 def test_issue_from_PR1599(): n1, n2, n3, n4 = symbols('n1 n2 n3 n4', negative=True) assert (powsimp(sqrt(n1)*sqrt(n2)*sqrt(n3)) == -I*sqrt(-n1)*sqrt(-n2)*sqrt(-n3)) assert (powsimp(root(n1, 3)*root(n2, 3)*root(n3, 3)*root(n4, 3)) == -(-1)**(S(1)/3)* (-n1)**(S(1)/3)*(-n2)**(S(1)/3)*(-n3)**(S(1)/3)*(-n4)**(S(1)/3)) def test_issue_10195(): a = Symbol('a', integer=True) l = Symbol('l', even=True, nonzero=True) n = Symbol('n', odd=True) e_x = (-1)**(n/2 - Rational(1, 2)) - (-1)**(3*n/2 - Rational(1, 2)) assert powsimp((-1)**(l/2)) == I**l assert powsimp((-1)**(n/2)) == I**n assert powsimp((-1)**(3*n/2)) == -I**n assert powsimp(e_x) == (-1)**(n/2 - Rational(1, 2)) + (-1)**(3*n/2 + Rational(1,2)) assert powsimp((-1)**(3*a/2)) == (-I)**a def test_issue_15709(): assert powsimp(2*3**x/3) == 2*3**(x-1) def test_issue_11981(): x, y = symbols('x y', commutative=False) assert powsimp((x*y)**2 * (y*x)**2) == (x*y)**2 * (y*x)**2
83c4a92bc6750a726576c53ea05c1a876acdfec9a8c3dfe6e596fb84a10ae8b5
from sympy import ( Abs, acos, Add, asin, atan, Basic, binomial, besselsimp, collect,cos, cosh, cot, coth, count_ops, csch, Derivative, diff, E, Eq, erf, exp, exp_polar, expand, expand_multinomial, factor, factorial, Float, fraction, Function, gamma, GoldenRatio, hyper, hypersimp, I, Integral, integrate, log, logcombine, Lt, Matrix, MatrixSymbol, Mul, nsimplify, O, oo, pi, Piecewise, posify, rad, Rational, root, S, separatevars, signsimp, simplify, sign, sin, sinc, sinh, solve, sqrt, Sum, Symbol, symbols, sympify, tan, tanh, zoo) from sympy.core.mul import _keep_coeff from sympy.simplify.simplify import nthroot, inversecombine from sympy.utilities.pytest import XFAIL, slow from sympy.core.compatibility import range from sympy.abc import x, y, z, t, a, b, c, d, e, f, g, h, i, k def test_issue_7263(): assert abs((simplify(30.8**2 - 82.5**2 * sin(rad(11.6))**2)).evalf() - \ 673.447451402970) < 1e-12 @XFAIL def test_factorial_simplify(): # There are more tests in test_factorials.py. These are just to # ensure that simplify() calls factorial_simplify correctly from sympy.specfun.factorials import factorial x = Symbol('x') assert simplify(factorial(x)/x) == factorial(x - 1) assert simplify(factorial(factorial(x))) == factorial(factorial(x)) def test_simplify_expr(): x, y, z, k, n, m, w, s, A = symbols('x,y,z,k,n,m,w,s,A') f = Function('f') assert all(simplify(tmp) == tmp for tmp in [I, E, oo, x, -x, -oo, -E, -I]) e = 1/x + 1/y assert e != (x + y)/(x*y) assert simplify(e) == (x + y)/(x*y) e = A**2*s**4/(4*pi*k*m**3) assert simplify(e) == e e = (4 + 4*x - 2*(2 + 2*x))/(2 + 2*x) assert simplify(e) == 0 e = (-4*x*y**2 - 2*y**3 - 2*x**2*y)/(x + y)**2 assert simplify(e) == -2*y e = -x - y - (x + y)**(-1)*y**2 + (x + y)**(-1)*x**2 assert simplify(e) == -2*y e = (x + x*y)/x assert simplify(e) == 1 + y e = (f(x) + y*f(x))/f(x) assert simplify(e) == 1 + y e = (2 * (1/n - cos(n * pi)/n))/pi assert simplify(e) == (-cos(pi*n) + 1)/(pi*n)*2 e = integrate(1/(x**3 + 1), x).diff(x) assert simplify(e) == 1/(x**3 + 1) e = integrate(x/(x**2 + 3*x + 1), x).diff(x) assert simplify(e) == x/(x**2 + 3*x + 1) f = Symbol('f') A = Matrix([[2*k - m*w**2, -k], [-k, k - m*w**2]]).inv() assert simplify((A*Matrix([0, f]))[1]) == \ -f*(2*k - m*w**2)/(k**2 - (k - m*w**2)*(2*k - m*w**2)) f = -x + y/(z + t) + z*x/(z + t) + z*a/(z + t) + t*x/(z + t) assert simplify(f) == (y + a*z)/(z + t) # issue 10347 expr = -x*(y**2 - 1)*(2*y**2*(x**2 - 1)/(a*(x**2 - y**2)**2) + (x**2 - 1) /(a*(x**2 - y**2)))/(a*(x**2 - y**2)) + x*(-2*x**2*sqrt(-x**2*y**2 + x**2 + y**2 - 1)*sin(z)/(a*(x**2 - y**2)**2) - x**2*sqrt(-x**2*y**2 + x**2 + y**2 - 1)*sin(z)/(a*(x**2 - 1)*(x**2 - y**2)) + (x**2*sqrt((-x**2 + 1)* (y**2 - 1))*sqrt(-x**2*y**2 + x**2 + y**2 - 1)*sin(z)/(x**2 - 1) + sqrt( (-x**2 + 1)*(y**2 - 1))*(x*(-x*y**2 + x)/sqrt(-x**2*y**2 + x**2 + y**2 - 1) + sqrt(-x**2*y**2 + x**2 + y**2 - 1))*sin(z))/(a*sqrt((-x**2 + 1)*( y**2 - 1))*(x**2 - y**2)))*sqrt(-x**2*y**2 + x**2 + y**2 - 1)*sin(z)/(a* (x**2 - y**2)) + x*(-2*x**2*sqrt(-x**2*y**2 + x**2 + y**2 - 1)*cos(z)/(a* (x**2 - y**2)**2) - x**2*sqrt(-x**2*y**2 + x**2 + y**2 - 1)*cos(z)/(a* (x**2 - 1)*(x**2 - y**2)) + (x**2*sqrt((-x**2 + 1)*(y**2 - 1))*sqrt(-x**2 *y**2 + x**2 + y**2 - 1)*cos(z)/(x**2 - 1) + x*sqrt((-x**2 + 1)*(y**2 - 1))*(-x*y**2 + x)*cos(z)/sqrt(-x**2*y**2 + x**2 + y**2 - 1) + sqrt((-x**2 + 1)*(y**2 - 1))*sqrt(-x**2*y**2 + x**2 + y**2 - 1)*cos(z))/(a*sqrt((-x**2 + 1)*(y**2 - 1))*(x**2 - y**2)))*sqrt(-x**2*y**2 + x**2 + y**2 - 1)*cos( z)/(a*(x**2 - y**2)) - y*sqrt((-x**2 + 1)*(y**2 - 1))*(-x*y*sqrt(-x**2* y**2 + x**2 + y**2 - 1)*sin(z)/(a*(x**2 - y**2)*(y**2 - 1)) + 2*x*y*sqrt( -x**2*y**2 + x**2 + y**2 - 1)*sin(z)/(a*(x**2 - y**2)**2) + (x*y*sqrt(( -x**2 + 1)*(y**2 - 1))*sqrt(-x**2*y**2 + x**2 + y**2 - 1)*sin(z)/(y**2 - 1) + x*sqrt((-x**2 + 1)*(y**2 - 1))*(-x**2*y + y)*sin(z)/sqrt(-x**2*y**2 + x**2 + y**2 - 1))/(a*sqrt((-x**2 + 1)*(y**2 - 1))*(x**2 - y**2)))*sin( z)/(a*(x**2 - y**2)) + y*(x**2 - 1)*(-2*x*y*(x**2 - 1)/(a*(x**2 - y**2) **2) + 2*x*y/(a*(x**2 - y**2)))/(a*(x**2 - y**2)) + y*(x**2 - 1)*(y**2 - 1)*(-x*y*sqrt(-x**2*y**2 + x**2 + y**2 - 1)*cos(z)/(a*(x**2 - y**2)*(y**2 - 1)) + 2*x*y*sqrt(-x**2*y**2 + x**2 + y**2 - 1)*cos(z)/(a*(x**2 - y**2) **2) + (x*y*sqrt((-x**2 + 1)*(y**2 - 1))*sqrt(-x**2*y**2 + x**2 + y**2 - 1)*cos(z)/(y**2 - 1) + x*sqrt((-x**2 + 1)*(y**2 - 1))*(-x**2*y + y)*cos( z)/sqrt(-x**2*y**2 + x**2 + y**2 - 1))/(a*sqrt((-x**2 + 1)*(y**2 - 1) )*(x**2 - y**2)))*cos(z)/(a*sqrt((-x**2 + 1)*(y**2 - 1))*(x**2 - y**2) ) - x*sqrt((-x**2 + 1)*(y**2 - 1))*sqrt(-x**2*y**2 + x**2 + y**2 - 1)*sin( z)**2/(a**2*(x**2 - 1)*(x**2 - y**2)*(y**2 - 1)) - x*sqrt((-x**2 + 1)*( y**2 - 1))*sqrt(-x**2*y**2 + x**2 + y**2 - 1)*cos(z)**2/(a**2*(x**2 - 1)*( x**2 - y**2)*(y**2 - 1)) assert simplify(expr) == 2*x/(a**2*(x**2 - y**2)) A, B = symbols('A,B', commutative=False) assert simplify(A*B - B*A) == A*B - B*A assert simplify(A/(1 + y/x)) == x*A/(x + y) assert simplify(A*(1/x + 1/y)) == A/x + A/y #(x + y)*A/(x*y) assert simplify(log(2) + log(3)) == log(6) assert simplify(log(2*x) - log(2)) == log(x) assert simplify(hyper([], [], x)) == exp(x) def test_issue_3557(): f_1 = x*a + y*b + z*c - 1 f_2 = x*d + y*e + z*f - 1 f_3 = x*g + y*h + z*i - 1 solutions = solve([f_1, f_2, f_3], x, y, z, simplify=False) assert simplify(solutions[y]) == \ (a*i + c*d + f*g - a*f - c*g - d*i)/ \ (a*e*i + b*f*g + c*d*h - a*f*h - b*d*i - c*e*g) def test_simplify_other(): assert simplify(sin(x)**2 + cos(x)**2) == 1 assert simplify(gamma(x + 1)/gamma(x)) == x assert simplify(sin(x)**2 + cos(x)**2 + factorial(x)/gamma(x)) == 1 + x assert simplify( Eq(sin(x)**2 + cos(x)**2, factorial(x)/gamma(x))) == Eq(x, 1) nc = symbols('nc', commutative=False) assert simplify(x + x*nc) == x*(1 + nc) # issue 6123 # f = exp(-I*(k*sqrt(t) + x/(2*sqrt(t)))**2) # ans = integrate(f, (k, -oo, oo), conds='none') ans = I*(-pi*x*exp(-3*I*pi/4 + I*x**2/(4*t))*erf(x*exp(-3*I*pi/4)/ (2*sqrt(t)))/(2*sqrt(t)) + pi*x*exp(-3*I*pi/4 + I*x**2/(4*t))/ (2*sqrt(t)))*exp(-I*x**2/(4*t))/(sqrt(pi)*x) - I*sqrt(pi) * \ (-erf(x*exp(I*pi/4)/(2*sqrt(t))) + 1)*exp(I*pi/4)/(2*sqrt(t)) assert simplify(ans) == -(-1)**(S(3)/4)*sqrt(pi)/sqrt(t) # issue 6370 assert simplify(2**(2 + x)/4) == 2**x def test_simplify_complex(): cosAsExp = cos(x)._eval_rewrite_as_exp(x) tanAsExp = tan(x)._eval_rewrite_as_exp(x) assert simplify(cosAsExp*tanAsExp) == sin(x) # issue 4341 # issue 10124 assert simplify(exp(Matrix([[0, -1], [1, 0]]))) == Matrix([[cos(1), -sin(1)], [sin(1), cos(1)]]) def test_simplify_ratio(): # roots of x**3-3*x+5 roots = ['(1/2 - sqrt(3)*I/2)*(sqrt(21)/2 + 5/2)**(1/3) + 1/((1/2 - ' 'sqrt(3)*I/2)*(sqrt(21)/2 + 5/2)**(1/3))', '1/((1/2 + sqrt(3)*I/2)*(sqrt(21)/2 + 5/2)**(1/3)) + ' '(1/2 + sqrt(3)*I/2)*(sqrt(21)/2 + 5/2)**(1/3)', '-(sqrt(21)/2 + 5/2)**(1/3) - 1/(sqrt(21)/2 + 5/2)**(1/3)'] for r in roots: r = S(r) assert count_ops(simplify(r, ratio=1)) <= count_ops(r) # If ratio=oo, simplify() is always applied: assert simplify(r, ratio=oo) is not r def test_simplify_measure(): measure1 = lambda expr: len(str(expr)) measure2 = lambda expr: -count_ops(expr) # Return the most complicated result expr = (x + 1)/(x + sin(x)**2 + cos(x)**2) assert measure1(simplify(expr, measure=measure1)) <= measure1(expr) assert measure2(simplify(expr, measure=measure2)) <= measure2(expr) expr2 = Eq(sin(x)**2 + cos(x)**2, 1) assert measure1(simplify(expr2, measure=measure1)) <= measure1(expr2) assert measure2(simplify(expr2, measure=measure2)) <= measure2(expr2) def test_simplify_rational(): expr = 2**x*2.**y assert simplify(expr, rational = True) == 2**(x+y) assert simplify(expr, rational = None) == 2.0**(x+y) assert simplify(expr, rational = False) == expr def test_simplify_issue_1308(): assert simplify(exp(-Rational(1, 2)) + exp(-Rational(3, 2))) == \ (1 + E)*exp(-Rational(3, 2)) def test_issue_5652(): assert simplify(E + exp(-E)) == exp(-E) + E n = symbols('n', commutative=False) assert simplify(n + n**(-n)) == n + n**(-n) def test_simplify_fail1(): x = Symbol('x') y = Symbol('y') e = (x + y)**2/(-4*x*y**2 - 2*y**3 - 2*x**2*y) assert simplify(e) == 1 / (-2*y) def test_nthroot(): assert nthroot(90 + 34*sqrt(7), 3) == sqrt(7) + 3 q = 1 + sqrt(2) - 2*sqrt(3) + sqrt(6) + sqrt(7) assert nthroot(expand_multinomial(q**3), 3) == q assert nthroot(41 + 29*sqrt(2), 5) == 1 + sqrt(2) assert nthroot(-41 - 29*sqrt(2), 5) == -1 - sqrt(2) expr = 1320*sqrt(10) + 4216 + 2576*sqrt(6) + 1640*sqrt(15) assert nthroot(expr, 5) == 1 + sqrt(6) + sqrt(15) q = 1 + sqrt(2) + sqrt(3) + sqrt(5) assert expand_multinomial(nthroot(expand_multinomial(q**5), 5)) == q q = 1 + sqrt(2) + 7*sqrt(6) + 2*sqrt(10) assert nthroot(expand_multinomial(q**5), 5, 8) == q q = 1 + sqrt(2) - 2*sqrt(3) + 1171*sqrt(6) assert nthroot(expand_multinomial(q**3), 3) == q assert nthroot(expand_multinomial(q**6), 6) == q def test_nthroot1(): q = 1 + sqrt(2) + sqrt(3) + S(1)/10**20 p = expand_multinomial(q**5) assert nthroot(p, 5) == q q = 1 + sqrt(2) + sqrt(3) + S(1)/10**30 p = expand_multinomial(q**5) assert nthroot(p, 5) == q def test_separatevars(): x, y, z, n = symbols('x,y,z,n') assert separatevars(2*n*x*z + 2*x*y*z) == 2*x*z*(n + y) assert separatevars(x*z + x*y*z) == x*z*(1 + y) assert separatevars(pi*x*z + pi*x*y*z) == pi*x*z*(1 + y) assert separatevars(x*y**2*sin(x) + x*sin(x)*sin(y)) == \ x*(sin(y) + y**2)*sin(x) assert separatevars(x*exp(x + y) + x*exp(x)) == x*(1 + exp(y))*exp(x) assert separatevars((x*(y + 1))**z).is_Pow # != x**z*(1 + y)**z assert separatevars(1 + x + y + x*y) == (x + 1)*(y + 1) assert separatevars(y/pi*exp(-(z - x)/cos(n))) == \ y*exp(x/cos(n))*exp(-z/cos(n))/pi assert separatevars((x + y)*(x - y) + y**2 + 2*x + 1) == (x + 1)**2 # issue 4858 p = Symbol('p', positive=True) assert separatevars(sqrt(p**2 + x*p**2)) == p*sqrt(1 + x) assert separatevars(sqrt(y*(p**2 + x*p**2))) == p*sqrt(y*(1 + x)) assert separatevars(sqrt(y*(p**2 + x*p**2)), force=True) == \ p*sqrt(y)*sqrt(1 + x) # issue 4865 assert separatevars(sqrt(x*y)).is_Pow assert separatevars(sqrt(x*y), force=True) == sqrt(x)*sqrt(y) # issue 4957 # any type sequence for symbols is fine assert separatevars(((2*x + 2)*y), dict=True, symbols=()) == \ {'coeff': 1, x: 2*x + 2, y: y} # separable assert separatevars(((2*x + 2)*y), dict=True, symbols=[x]) == \ {'coeff': y, x: 2*x + 2} assert separatevars(((2*x + 2)*y), dict=True, symbols=[]) == \ {'coeff': 1, x: 2*x + 2, y: y} assert separatevars(((2*x + 2)*y), dict=True) == \ {'coeff': 1, x: 2*x + 2, y: y} assert separatevars(((2*x + 2)*y), dict=True, symbols=None) == \ {'coeff': y*(2*x + 2)} # not separable assert separatevars(3, dict=True) is None assert separatevars(2*x + y, dict=True, symbols=()) is None assert separatevars(2*x + y, dict=True) is None assert separatevars(2*x + y, dict=True, symbols=None) == {'coeff': 2*x + y} # issue 4808 n, m = symbols('n,m', commutative=False) assert separatevars(m + n*m) == (1 + n)*m assert separatevars(x + x*n) == x*(1 + n) # issue 4910 f = Function('f') assert separatevars(f(x) + x*f(x)) == f(x) + x*f(x) # a noncommutable object present eq = x*(1 + hyper((), (), y*z)) assert separatevars(eq) == eq def test_separatevars_advanced_factor(): x, y, z = symbols('x,y,z') assert separatevars(1 + log(x)*log(y) + log(x) + log(y)) == \ (log(x) + 1)*(log(y) + 1) assert separatevars(1 + x - log(z) - x*log(z) - exp(y)*log(z) - x*exp(y)*log(z) + x*exp(y) + exp(y)) == \ -((x + 1)*(log(z) - 1)*(exp(y) + 1)) x, y = symbols('x,y', positive=True) assert separatevars(1 + log(x**log(y)) + log(x*y)) == \ (log(x) + 1)*(log(y) + 1) def test_hypersimp(): n, k = symbols('n,k', integer=True) assert hypersimp(factorial(k), k) == k + 1 assert hypersimp(factorial(k**2), k) is None assert hypersimp(1/factorial(k), k) == 1/(k + 1) assert hypersimp(2**k/factorial(k)**2, k) == 2/(k + 1)**2 assert hypersimp(binomial(n, k), k) == (n - k)/(k + 1) assert hypersimp(binomial(n + 1, k), k) == (n - k + 1)/(k + 1) term = (4*k + 1)*factorial(k)/factorial(2*k + 1) assert hypersimp(term, k) == (S(1)/2)*((4*k + 5)/(3 + 14*k + 8*k**2)) term = 1/((2*k - 1)*factorial(2*k + 1)) assert hypersimp(term, k) == (k - S(1)/2)/((k + 1)*(2*k + 1)*(2*k + 3)) term = binomial(n, k)*(-1)**k/factorial(k) assert hypersimp(term, k) == (k - n)/(k + 1)**2 def test_nsimplify(): x = Symbol("x") assert nsimplify(0) == 0 assert nsimplify(-1) == -1 assert nsimplify(1) == 1 assert nsimplify(1 + x) == 1 + x assert nsimplify(2.7) == Rational(27, 10) assert nsimplify(1 - GoldenRatio) == (1 - sqrt(5))/2 assert nsimplify((1 + sqrt(5))/4, [GoldenRatio]) == GoldenRatio/2 assert nsimplify(2/GoldenRatio, [GoldenRatio]) == 2*GoldenRatio - 2 assert nsimplify(exp(5*pi*I/3, evaluate=False)) == \ sympify('1/2 - sqrt(3)*I/2') assert nsimplify(sin(3*pi/5, evaluate=False)) == \ sympify('sqrt(sqrt(5)/8 + 5/8)') assert nsimplify(sqrt(atan('1', evaluate=False))*(2 + I), [pi]) == \ sqrt(pi) + sqrt(pi)/2*I assert nsimplify(2 + exp(2*atan('1/4')*I)) == sympify('49/17 + 8*I/17') assert nsimplify(pi, tolerance=0.01) == Rational(22, 7) assert nsimplify(pi, tolerance=0.001) == Rational(355, 113) assert nsimplify(0.33333, tolerance=1e-4) == Rational(1, 3) assert nsimplify(2.0**(1/3.), tolerance=0.001) == Rational(635, 504) assert nsimplify(2.0**(1/3.), tolerance=0.001, full=True) == \ 2**Rational(1, 3) assert nsimplify(x + .5, rational=True) == Rational(1, 2) + x assert nsimplify(1/.3 + x, rational=True) == Rational(10, 3) + x assert nsimplify(log(3).n(), rational=True) == \ sympify('109861228866811/100000000000000') assert nsimplify(Float(0.272198261287950), [pi, log(2)]) == pi*log(2)/8 assert nsimplify(Float(0.272198261287950).n(3), [pi, log(2)]) == \ -pi/4 - log(2) + S(7)/4 assert nsimplify(x/7.0) == x/7 assert nsimplify(pi/1e2) == pi/100 assert nsimplify(pi/1e2, rational=False) == pi/100.0 assert nsimplify(pi/1e-7) == 10000000*pi assert not nsimplify( factor(-3.0*z**2*(z**2)**(-2.5) + 3*(z**2)**(-1.5))).atoms(Float) e = x**0.0 assert e.is_Pow and nsimplify(x**0.0) == 1 assert nsimplify(3.333333, tolerance=0.1, rational=True) == Rational(10, 3) assert nsimplify(3.333333, tolerance=0.01, rational=True) == Rational(10, 3) assert nsimplify(3.666666, tolerance=0.1, rational=True) == Rational(11, 3) assert nsimplify(3.666666, tolerance=0.01, rational=True) == Rational(11, 3) assert nsimplify(33, tolerance=10, rational=True) == Rational(33) assert nsimplify(33.33, tolerance=10, rational=True) == Rational(30) assert nsimplify(37.76, tolerance=10, rational=True) == Rational(40) assert nsimplify(-203.1) == -S(2031)/10 assert nsimplify(.2, tolerance=0) == S.One/5 assert nsimplify(-.2, tolerance=0) == -S.One/5 assert nsimplify(.2222, tolerance=0) == S(1111)/5000 assert nsimplify(-.2222, tolerance=0) == -S(1111)/5000 # issue 7211, PR 4112 assert nsimplify(S(2e-8)) == S(1)/50000000 # issue 7322 direct test assert nsimplify(1e-42, rational=True) != 0 # issue 10336 inf = Float('inf') infs = (-oo, oo, inf, -inf) for i in infs: ans = sign(i)*oo assert nsimplify(i) == ans assert nsimplify(i + x) == x + ans assert nsimplify(0.33333333, rational=True, rational_conversion='exact') == Rational(0.33333333) # Make sure nsimplify on expressions uses full precision assert nsimplify(pi.evalf(100)*x, rational_conversion='exact').evalf(100) == pi.evalf(100)*x def test_issue_9448(): tmp = sympify("1/(1 - (-1)**(2/3) - (-1)**(1/3)) + 1/(1 + (-1)**(2/3) + (-1)**(1/3))") assert nsimplify(tmp) == S(1)/2 def test_extract_minus_sign(): x = Symbol("x") y = Symbol("y") a = Symbol("a") b = Symbol("b") assert simplify(-x/-y) == x/y assert simplify(-x/y) == -x/y assert simplify(x/y) == x/y assert simplify(x/-y) == -x/y assert simplify(-x/0) == zoo*x assert simplify(S(-5)/0) == zoo assert simplify(-a*x/(-y - b)) == a*x/(b + y) def test_diff(): x = Symbol("x") y = Symbol("y") f = Function("f") g = Function("g") assert simplify(g(x).diff(x)*f(x).diff(x) - f(x).diff(x)*g(x).diff(x)) == 0 assert simplify(2*f(x)*f(x).diff(x) - diff(f(x)**2, x)) == 0 assert simplify(diff(1/f(x), x) + f(x).diff(x)/f(x)**2) == 0 assert simplify(f(x).diff(x, y) - f(x).diff(y, x)) == 0 def test_logcombine_1(): x, y = symbols("x,y") a = Symbol("a") z, w = symbols("z,w", positive=True) b = Symbol("b", real=True) assert logcombine(log(x) + 2*log(y)) == log(x) + 2*log(y) assert logcombine(log(x) + 2*log(y), force=True) == log(x*y**2) assert logcombine(a*log(w) + log(z)) == a*log(w) + log(z) assert logcombine(b*log(z) + b*log(x)) == log(z**b) + b*log(x) assert logcombine(b*log(z) - log(w)) == log(z**b/w) assert logcombine(log(x)*log(z)) == log(x)*log(z) assert logcombine(log(w)*log(x)) == log(w)*log(x) assert logcombine(cos(-2*log(z) + b*log(w))) in [cos(log(w**b/z**2)), cos(log(z**2/w**b))] assert logcombine(log(log(x) - log(y)) - log(z), force=True) == \ log(log(x/y)/z) assert logcombine((2 + I)*log(x), force=True) == (2 + I)*log(x) assert logcombine((x**2 + log(x) - log(y))/(x*y), force=True) == \ (x**2 + log(x/y))/(x*y) # the following could also give log(z*x**log(y**2)), what we # are testing is that a canonical result is obtained assert logcombine(log(x)*2*log(y) + log(z), force=True) == \ log(z*y**log(x**2)) assert logcombine((x*y + sqrt(x**4 + y**4) + log(x) - log(y))/(pi*x**Rational(2, 3)* sqrt(y)**3), force=True) == ( x*y + sqrt(x**4 + y**4) + log(x/y))/(pi*x**(S(2)/3)*y**(S(3)/2)) assert logcombine(gamma(-log(x/y))*acos(-log(x/y)), force=True) == \ acos(-log(x/y))*gamma(-log(x/y)) assert logcombine(2*log(z)*log(w)*log(x) + log(z) + log(w)) == \ log(z**log(w**2))*log(x) + log(w*z) assert logcombine(3*log(w) + 3*log(z)) == log(w**3*z**3) assert logcombine(x*(y + 1) + log(2) + log(3)) == x*(y + 1) + log(6) assert logcombine((x + y)*log(w) + (-x - y)*log(3)) == (x + y)*log(w/3) # a single unknown can combine assert logcombine(log(x) + log(2)) == log(2*x) eq = log(abs(x)) + log(abs(y)) assert logcombine(eq) == eq reps = {x: 0, y: 0} assert log(abs(x)*abs(y)).subs(reps) != eq.subs(reps) def test_logcombine_complex_coeff(): i = Integral((sin(x**2) + cos(x**3))/x, x) assert logcombine(i, force=True) == i assert logcombine(i + 2*log(x), force=True) == \ i + log(x**2) def test_issue_5950(): x, y = symbols("x,y", positive=True) assert logcombine(log(3) - log(2)) == log(Rational(3,2), evaluate=False) assert logcombine(log(x) - log(y)) == log(x/y) assert logcombine(log(Rational(3,2), evaluate=False) - log(2)) == \ log(Rational(3,4), evaluate=False) def test_posify(): from sympy.abc import x assert str(posify( x + Symbol('p', positive=True) + Symbol('n', negative=True))) == '(_x + n + p, {_x: x})' eq, rep = posify(1/x) assert log(eq).expand().subs(rep) == -log(x) assert str(posify([x, 1 + x])) == '([_x, _x + 1], {_x: x})' x = symbols('x') p = symbols('p', positive=True) n = symbols('n', negative=True) orig = [x, n, p] modified, reps = posify(orig) assert str(modified) == '[_x, n, p]' assert [w.subs(reps) for w in modified] == orig assert str(Integral(posify(1/x + y)[0], (y, 1, 3)).expand()) == \ 'Integral(1/_x, (y, 1, 3)) + Integral(_y, (y, 1, 3))' assert str(Sum(posify(1/x**n)[0], (n,1,3)).expand()) == \ 'Sum(_x**(-n), (n, 1, 3))' # issue 16438 k = Symbol('k', finite=True) eq, rep = posify(k) assert eq.assumptions0 == {'positive': True, 'zero': False, 'imaginary': False, 'nonpositive': False, 'commutative': True, 'hermitian': True, 'real': True, 'nonzero': True, 'nonnegative': True, 'negative': False, 'complex': True, 'finite': True, 'infinite': False} def test_issue_4194(): # simplify should call cancel from sympy.abc import x, y f = Function('f') assert simplify((4*x + 6*f(y))/(2*x + 3*f(y))) == 2 @XFAIL def test_simplify_float_vs_integer(): # Test for issue 4473: # https://github.com/sympy/sympy/issues/4473 assert simplify(x**2.0 - x**2) == 0 assert simplify(x**2 - x**2.0) == 0 def test_as_content_primitive(): assert (x/2 + y).as_content_primitive() == (S.Half, x + 2*y) assert (x/2 + y).as_content_primitive(clear=False) == (S.One, x/2 + y) assert (y*(x/2 + y)).as_content_primitive() == (S.Half, y*(x + 2*y)) assert (y*(x/2 + y)).as_content_primitive(clear=False) == (S.One, y*(x/2 + y)) # although the _as_content_primitive methods do not alter the underlying structure, # the as_content_primitive function will touch up the expression and join # bases that would otherwise have not been joined. assert ((x*(2 + 2*x)*(3*x + 3)**2)).as_content_primitive() == \ (18, x*(x + 1)**3) assert (2 + 2*x + 2*y*(3 + 3*y)).as_content_primitive() == \ (2, x + 3*y*(y + 1) + 1) assert ((2 + 6*x)**2).as_content_primitive() == \ (4, (3*x + 1)**2) assert ((2 + 6*x)**(2*y)).as_content_primitive() == \ (1, (_keep_coeff(S(2), (3*x + 1)))**(2*y)) assert (5 + 10*x + 2*y*(3 + 3*y)).as_content_primitive() == \ (1, 10*x + 6*y*(y + 1) + 5) assert ((5*(x*(1 + y)) + 2*x*(3 + 3*y))).as_content_primitive() == \ (11, x*(y + 1)) assert ((5*(x*(1 + y)) + 2*x*(3 + 3*y))**2).as_content_primitive() == \ (121, x**2*(y + 1)**2) assert (y**2).as_content_primitive() == \ (1, y**2) assert (S.Infinity).as_content_primitive() == (1, oo) eq = x**(2 + y) assert (eq).as_content_primitive() == (1, eq) assert (S.Half**(2 + x)).as_content_primitive() == (S(1)/4, 2**-x) assert ((-S.Half)**(2 + x)).as_content_primitive() == \ (S(1)/4, (-S.Half)**x) assert ((-S.Half)**(2 + x)).as_content_primitive() == \ (S(1)/4, (-S.Half)**x) assert (4**((1 + y)/2)).as_content_primitive() == (2, 4**(y/2)) assert (3**((1 + y)/2)).as_content_primitive() == \ (1, 3**(Mul(S(1)/2, 1 + y, evaluate=False))) assert (5**(S(3)/4)).as_content_primitive() == (1, 5**(S(3)/4)) assert (5**(S(7)/4)).as_content_primitive() == (5, 5**(S(3)/4)) assert Add(5*z/7, 0.5*x, 3*y/2, evaluate=False).as_content_primitive() == \ (S(1)/14, 7.0*x + 21*y + 10*z) assert (2**(S(3)/4) + 2**(S(1)/4)*sqrt(3)).as_content_primitive(radical=True) == \ (1, 2**(S(1)/4)*(sqrt(2) + sqrt(3))) def test_signsimp(): e = x*(-x + 1) + x*(x - 1) assert signsimp(Eq(e, 0)) is S.true assert Abs(x - 1) == Abs(1 - x) assert signsimp(y - x) == y - x assert signsimp(y - x, evaluate=False) == Mul(-1, x - y, evaluate=False) def test_besselsimp(): from sympy import besselj, besseli, exp_polar, cosh, cosine_transform assert besselsimp(exp(-I*pi*y/2)*besseli(y, z*exp_polar(I*pi/2))) == \ besselj(y, z) assert besselsimp(exp(-I*pi*a/2)*besseli(a, 2*sqrt(x)*exp_polar(I*pi/2))) == \ besselj(a, 2*sqrt(x)) assert besselsimp(sqrt(2)*sqrt(pi)*x**(S(1)/4)*exp(I*pi/4)*exp(-I*pi*a/2) * besseli(-S(1)/2, sqrt(x)*exp_polar(I*pi/2)) * besseli(a, sqrt(x)*exp_polar(I*pi/2))/2) == \ besselj(a, sqrt(x)) * cos(sqrt(x)) assert besselsimp(besseli(S(-1)/2, z)) == \ sqrt(2)*cosh(z)/(sqrt(pi)*sqrt(z)) assert besselsimp(besseli(a, z*exp_polar(-I*pi/2))) == \ exp(-I*pi*a/2)*besselj(a, z) assert cosine_transform(1/t*sin(a/t), t, y) == \ sqrt(2)*sqrt(pi)*besselj(0, 2*sqrt(a)*sqrt(y))/2 def test_Piecewise(): e1 = x*(x + y) - y*(x + y) e2 = sin(x)**2 + cos(x)**2 e3 = expand((x + y)*y/x) s1 = simplify(e1) s2 = simplify(e2) s3 = simplify(e3) assert simplify(Piecewise((e1, x < e2), (e3, True))) == \ Piecewise((s1, x < s2), (s3, True)) def test_polymorphism(): class A(Basic): def _eval_simplify(x, **kwargs): return 1 a = A(5, 2) assert simplify(a) == 1 def test_issue_from_PR1599(): n1, n2, n3, n4 = symbols('n1 n2 n3 n4', negative=True) assert simplify(I*sqrt(n1)) == -sqrt(-n1) def test_issue_6811(): eq = (x + 2*y)*(2*x + 2) assert simplify(eq) == (x + 1)*(x + 2*y)*2 # reject the 2-arg Mul -- these are a headache for test writing assert simplify(eq.expand()) == \ 2*x**2 + 4*x*y + 2*x + 4*y def test_issue_6920(): e = [cos(x) + I*sin(x), cos(x) - I*sin(x), cosh(x) - sinh(x), cosh(x) + sinh(x)] ok = [exp(I*x), exp(-I*x), exp(-x), exp(x)] # wrap in f to show that the change happens wherever ei occurs f = Function('f') assert [simplify(f(ei)).args[0] for ei in e] == ok def test_issue_7001(): from sympy.abc import r, R assert simplify(-(r*Piecewise((4*pi/3, r <= R), (-8*pi*R**3/(3*r**3), True)) + 2*Piecewise((4*pi*r/3, r <= R), (4*pi*R**3/(3*r**2), True)))/(4*pi*r)) == \ Piecewise((-1, r <= R), (0, True)) def test_inequality_no_auto_simplify(): # no simplify on creation but can be simplified lhs = cos(x)**2 + sin(x)**2 rhs = 2 e = Lt(lhs, rhs, evaluate=False) assert e is not S.true assert simplify(e) def test_issue_9398(): from sympy import Number, cancel assert cancel(1e-14) != 0 assert cancel(1e-14*I) != 0 assert simplify(1e-14) != 0 assert simplify(1e-14*I) != 0 assert (I*Number(1.)*Number(10)**Number(-14)).simplify() != 0 assert cancel(1e-20) != 0 assert cancel(1e-20*I) != 0 assert simplify(1e-20) != 0 assert simplify(1e-20*I) != 0 assert cancel(1e-100) != 0 assert cancel(1e-100*I) != 0 assert simplify(1e-100) != 0 assert simplify(1e-100*I) != 0 f = Float("1e-1000") assert cancel(f) != 0 assert cancel(f*I) != 0 assert simplify(f) != 0 assert simplify(f*I) != 0 def test_issue_9324_simplify(): M = MatrixSymbol('M', 10, 10) e = M[0, 0] + M[5, 4] + 1304 assert simplify(e) == e def test_issue_13474(): x = Symbol('x') assert simplify(x + csch(sinc(1))) == x + csch(sinc(1)) def test_simplify_function_inverse(): # "inverse" attribute does not guarantee that f(g(x)) is x # so this simplification should not happen automatically. # See issue #12140 x, y = symbols('x, y') g = Function('g') class f(Function): def inverse(self, argindex=1): return g assert simplify(f(g(x))) == f(g(x)) assert inversecombine(f(g(x))) == x assert simplify(f(g(x)), inverse=True) == x assert simplify(f(g(sin(x)**2 + cos(x)**2)), inverse=True) == 1 assert simplify(f(g(x, y)), inverse=True) == f(g(x, y)) assert simplify(2*asin(sin(3*x)), inverse=True) == 6*x assert simplify(log(exp(x))) == log(exp(x)) assert simplify(log(exp(x)), inverse=True) == x assert simplify(log(exp(x), 2), inverse=True) == x/log(2) assert simplify(log(exp(x), 2, evaluate=False), inverse=True) == x/log(2) def test_clear_coefficients(): from sympy.simplify.simplify import clear_coefficients assert clear_coefficients(4*y*(6*x + 3)) == (y*(2*x + 1), 0) assert clear_coefficients(4*y*(6*x + 3) - 2) == (y*(2*x + 1), S(1)/6) assert clear_coefficients(4*y*(6*x + 3) - 2, x) == (y*(2*x + 1), x/12 + S(1)/6) assert clear_coefficients(sqrt(2) - 2) == (sqrt(2), 2) assert clear_coefficients(4*sqrt(2) - 2) == (sqrt(2), S.Half) assert clear_coefficients(S(3), x) == (0, x - 3) assert clear_coefficients(S.Infinity, x) == (S.Infinity, x) assert clear_coefficients(-S.Pi, x) == (S.Pi, -x) assert clear_coefficients(2 - S.Pi/3, x) == (pi, -3*x + 6) def test_nc_simplify(): from sympy.simplify.simplify import nc_simplify from sympy.matrices.expressions import (MatrixExpr, MatAdd, MatMul, MatPow, Identity) from sympy.core import Pow from functools import reduce a, b, c, d = symbols('a b c d', commutative = False) x = Symbol('x') A = MatrixSymbol("A", x, x) B = MatrixSymbol("B", x, x) C = MatrixSymbol("C", x, x) D = MatrixSymbol("D", x, x) subst = {a: A, b: B, c: C, d:D} funcs = {Add: lambda x,y: x+y, Mul: lambda x,y: x*y } def _to_matrix(expr): if expr in subst: return subst[expr] if isinstance(expr, Pow): return MatPow(_to_matrix(expr.args[0]), expr.args[1]) elif isinstance(expr, (Add, Mul)): return reduce(funcs[expr.func],[_to_matrix(a) for a in expr.args]) else: return expr*Identity(x) def _check(expr, simplified, deep=True, matrix=True): assert nc_simplify(expr, deep=deep) == simplified assert expand(expr) == expand(simplified) if matrix: m_simp = _to_matrix(simplified).doit(inv_expand=False) assert nc_simplify(_to_matrix(expr), deep=deep) == m_simp _check(a*b*a*b*a*b*c*(a*b)**3*c, ((a*b)**3*c)**2) _check(a*b*(a*b)**-2*a*b, 1) _check(a**2*b*a*b*a*b*(a*b)**-1, a*(a*b)**2, matrix=False) _check(b*a*b**2*a*b**2*a*b**2, b*(a*b**2)**3) _check(a*b*a**2*b*a**2*b*a**3, (a*b*a)**3*a**2) _check(a**2*b*a**4*b*a**4*b*a**2, (a**2*b*a**2)**3) _check(a**3*b*a**4*b*a**4*b*a, a**3*(b*a**4)**3*a**-3) _check(a*b*a*b + a*b*c*x*a*b*c, (a*b)**2 + x*(a*b*c)**2) _check(a*b*a*b*c*a*b*a*b*c, ((a*b)**2*c)**2) _check(b**-1*a**-1*(a*b)**2, a*b) _check(a**-1*b*c**-1, (c*b**-1*a)**-1) expr = a**3*b*a**4*b*a**4*b*a**2*b*a**2*(b*a**2)**2*b*a**2*b*a**2 for i in range(10): expr *= a*b _check(expr, a**3*(b*a**4)**2*(b*a**2)**6*(a*b)**10) _check((a*b*a*b)**2, (a*b*a*b)**2, deep=False) _check(a*b*(c*d)**2, a*b*(c*d)**2) expr = b**-1*(a**-1*b**-1 - a**-1*c*b**-1)**-1*a**-1 assert nc_simplify(expr) == (1-c)**-1 # commutative expressions should be returned without an error assert nc_simplify(2*x**2) == 2*x**2
1d824f418b2e77d807646a0caa9b7eb1d24b20fb564ea7608fd1d7c1ad86f7b5
from sympy import symbols, IndexedBase, HadamardProduct, Identity, cos from sympy.codegen.array_utils import (CodegenArrayContraction, CodegenArrayTensorProduct, CodegenArrayDiagonal, CodegenArrayPermuteDims, CodegenArrayElementwiseAdd, _codegen_array_parse, _recognize_matrix_expression, _RecognizeMatOp, _RecognizeMatMulLines, _unfold_recognized_expr, parse_indexed_expression, recognize_matrix_expression, _parse_matrix_expression) from sympy import (MatrixSymbol, Sum) from sympy.combinatorics import Permutation from sympy.functions.special.tensor_functions import KroneckerDelta from sympy.matrices.expressions.diagonal import DiagonalizeVector from sympy.matrices.expressions.matexpr import MatrixElement from sympy.matrices import (Trace, MatAdd, MatMul, Transpose) from sympy.utilities.pytest import raises, XFAIL A, B = symbols("A B", cls=IndexedBase) i, j, k, l, m, n = symbols("i j k l m n") M = MatrixSymbol("M", k, k) N = MatrixSymbol("N", k, k) P = MatrixSymbol("P", k, k) Q = MatrixSymbol("Q", k, k) def test_codegen_array_contraction_construction(): cg = CodegenArrayContraction(A) assert cg == A s = Sum(A[i]*B[i], (i, 0, 3)) cg = parse_indexed_expression(s) assert cg == CodegenArrayContraction(CodegenArrayTensorProduct(A, B), (0, 1)) cg = CodegenArrayContraction(CodegenArrayTensorProduct(A, B), (1, 0)) assert cg == CodegenArrayContraction(CodegenArrayTensorProduct(A, B), (0, 1)) expr = M*N result = CodegenArrayContraction(CodegenArrayTensorProduct(M, N), (1, 2)) assert CodegenArrayContraction.from_MatMul(expr) == result elem = expr[i, j] assert parse_indexed_expression(elem) == result expr = M*N*M result = CodegenArrayContraction(CodegenArrayTensorProduct(M, N, M), (1, 2), (3, 4)) assert CodegenArrayContraction.from_MatMul(expr) == result elem = expr[i, j] result = CodegenArrayContraction(CodegenArrayTensorProduct(M, M, N), (1, 4), (2, 5)) cg = parse_indexed_expression(elem) cg = cg.sort_args_by_name() assert cg == result def test_codegen_array_contraction_indices_types(): cg = CodegenArrayContraction(CodegenArrayTensorProduct(M, N), (0, 1)) indtup = cg._get_contraction_tuples() assert indtup == [[(0, 0), (0, 1)]] assert cg._contraction_tuples_to_contraction_indices(cg.expr, indtup) == [(0, 1)] cg = CodegenArrayContraction(CodegenArrayTensorProduct(M, N), (1, 2)) indtup = cg._get_contraction_tuples() assert indtup == [[(0, 1), (1, 0)]] assert cg._contraction_tuples_to_contraction_indices(cg.expr, indtup) == [(1, 2)] cg = CodegenArrayContraction(CodegenArrayTensorProduct(M, M, N), (1, 4), (2, 5)) indtup = cg._get_contraction_tuples() assert indtup == [[(0, 1), (2, 0)], [(1, 0), (2, 1)]] assert cg._contraction_tuples_to_contraction_indices(cg.expr, indtup) == [(1, 4), (2, 5)] def test_codegen_array_recognize_matrix_mul_lines(): cg = CodegenArrayContraction(CodegenArrayTensorProduct(M), (0, 1)) assert recognize_matrix_expression(cg) == Trace(M) cg = CodegenArrayContraction(CodegenArrayTensorProduct(M, N), (0, 1), (2, 3)) assert recognize_matrix_expression(cg) == [Trace(M), Trace(N)] cg = CodegenArrayContraction(CodegenArrayTensorProduct(M, N), (0, 3), (1, 2)) assert recognize_matrix_expression(cg) == Trace(M*N) cg = CodegenArrayContraction(CodegenArrayTensorProduct(M, N), (0, 2), (1, 3)) assert recognize_matrix_expression(cg) == Trace(M*N.T) cg = parse_indexed_expression((M*N*P)[i,j]) assert recognize_matrix_expression(cg) == M*N*P cg = CodegenArrayContraction.from_MatMul(M*N*P) assert recognize_matrix_expression(cg) == M*N*P cg = parse_indexed_expression((M*N.T*P)[i,j]) assert recognize_matrix_expression(cg) == M*N.T*P cg = CodegenArrayContraction.from_MatMul(M*N.T*P) assert recognize_matrix_expression(cg) == M*N.T*P cg = CodegenArrayContraction(CodegenArrayTensorProduct(M,N,P,Q), (1, 2), (5, 6)) assert recognize_matrix_expression(cg) == [M*N, P*Q] expr = -2*M*N elem = expr[i, j] cg = parse_indexed_expression(elem) assert recognize_matrix_expression(cg) == -2*M*N def test_codegen_array_flatten(): # Flatten nested CodegenArrayTensorProduct objects: expr1 = CodegenArrayTensorProduct(M, N) expr2 = CodegenArrayTensorProduct(P, Q) expr = CodegenArrayTensorProduct(expr1, expr2) assert expr == CodegenArrayTensorProduct(M, N, P, Q) assert expr.args == (M, N, P, Q) # Flatten mixed CodegenArrayTensorProduct and CodegenArrayContraction objects: cg1 = CodegenArrayContraction(expr1, (1, 2)) cg2 = CodegenArrayContraction(expr2, (0, 3)) expr = CodegenArrayTensorProduct(cg1, cg2) assert expr == CodegenArrayContraction(CodegenArrayTensorProduct(M, N, P, Q), (1, 2), (4, 7)) expr = CodegenArrayTensorProduct(M, cg1) assert expr == CodegenArrayContraction(CodegenArrayTensorProduct(M, M, N), (3, 4)) # Flatten nested CodegenArrayContraction objects: cgnested = CodegenArrayContraction(cg1, (0, 1)) assert cgnested == CodegenArrayContraction(CodegenArrayTensorProduct(M, N), (0, 3), (1, 2)) cgnested = CodegenArrayContraction(CodegenArrayTensorProduct(cg1, cg2), (0, 3)) assert cgnested == CodegenArrayContraction(CodegenArrayTensorProduct(M, N, P, Q), (0, 6), (1, 2), (4, 7)) cg3 = CodegenArrayContraction(CodegenArrayTensorProduct(M, N, P, Q), (1, 3), (2, 4)) cgnested = CodegenArrayContraction(cg3, (0, 1)) assert cgnested == CodegenArrayContraction(CodegenArrayTensorProduct(M, N, P, Q), (0, 5), (1, 3), (2, 4)) cgnested = CodegenArrayContraction(cg3, (0, 3), (1, 2)) assert cgnested == CodegenArrayContraction(CodegenArrayTensorProduct(M, N, P, Q), (0, 7), (1, 3), (2, 4), (5, 6)) cg4 = CodegenArrayContraction(CodegenArrayTensorProduct(M, N, P, Q), (1, 5), (3, 7)) cgnested = CodegenArrayContraction(cg4, (0, 1)) assert cgnested == CodegenArrayContraction(CodegenArrayTensorProduct(M, N, P, Q), (0, 2), (1, 5), (3, 7)) cgnested = CodegenArrayContraction(cg4, (0, 1), (2, 3)) assert cgnested == CodegenArrayContraction(CodegenArrayTensorProduct(M, N, P, Q), (0, 2), (1, 5), (3, 7), (4, 6)) # Flatten nested CodegenArrayDiagonal objects: cg1 = CodegenArrayDiagonal(expr1, (1, 2)) cg2 = CodegenArrayDiagonal(expr2, (0, 3)) cg3 = CodegenArrayDiagonal(CodegenArrayTensorProduct(M, N, P, Q), (1, 3), (2, 4)) cg4 = CodegenArrayDiagonal(CodegenArrayTensorProduct(M, N, P, Q), (1, 5), (3, 7)) cgnested = CodegenArrayDiagonal(cg1, (0, 1)) assert cgnested == CodegenArrayDiagonal(CodegenArrayTensorProduct(M, N), (1, 2), (0, 3)) cgnested = CodegenArrayDiagonal(cg3, (1, 2)) assert cgnested == CodegenArrayDiagonal(CodegenArrayTensorProduct(M, N, P, Q), (1, 3), (2, 4), (5, 6)) cgnested = CodegenArrayDiagonal(cg4, (1, 2)) assert cgnested == CodegenArrayDiagonal(CodegenArrayTensorProduct(M, N, P, Q), (1, 5), (3, 7), (2, 4)) def test_codegen_array_parse(): expr = M[i, j] assert _codegen_array_parse(expr) == (M, (i, j)) expr = M[i, j]*N[k, l] assert _codegen_array_parse(expr) == (CodegenArrayTensorProduct(M, N), (i, j, k, l)) expr = M[i, j]*N[j, k] assert _codegen_array_parse(expr) == (CodegenArrayDiagonal(CodegenArrayTensorProduct(M, N), (1, 2)), (i, k, j)) expr = Sum(M[i, j]*N[j, k], (j, 0, k-1)) assert _codegen_array_parse(expr) == (CodegenArrayContraction(CodegenArrayTensorProduct(M, N), (1, 2)), (i, k)) expr = M[i, j] + N[i, j] assert _codegen_array_parse(expr) == (CodegenArrayElementwiseAdd(M, N), (i, j)) expr = M[i, j] + N[j, i] assert _codegen_array_parse(expr) == (CodegenArrayElementwiseAdd(M, CodegenArrayPermuteDims(N, Permutation([1,0]))), (i, j)) expr = M[i, j] + M[j, i] assert _codegen_array_parse(expr) == (CodegenArrayElementwiseAdd(M, CodegenArrayPermuteDims(M, Permutation([1,0]))), (i, j)) expr = (M*N*P)[i, j] assert _codegen_array_parse(expr) == (CodegenArrayContraction(CodegenArrayTensorProduct(M, N, P), (1, 2), (3, 4)), (i, j)) expr = expr.function # Disregard summation in previous expression ret1, ret2 = _codegen_array_parse(expr) assert ret1 == CodegenArrayDiagonal(CodegenArrayTensorProduct(M, N, P), (1, 2), (3, 4)) assert str(ret2) == "(i, j, _i_1, _i_2)" expr = KroneckerDelta(i, j)*M[i, k] assert _codegen_array_parse(expr) == (M, ({i, j}, k)) expr = KroneckerDelta(i, j)*KroneckerDelta(j, k)*M[i, l] assert _codegen_array_parse(expr) == (M, ({i, j, k}, l)) expr = KroneckerDelta(j, k)*(M[i, j]*N[k, l] + N[i, j]*M[k, l]) assert _codegen_array_parse(expr) == (CodegenArrayDiagonal(CodegenArrayElementwiseAdd( CodegenArrayTensorProduct(M, N), CodegenArrayPermuteDims(CodegenArrayTensorProduct(M, N), Permutation(0, 2)(1, 3)) ), (1, 2)), (i, l, frozenset({j, k}))) expr = KroneckerDelta(j, m)*KroneckerDelta(m, k)*(M[i, j]*N[k, l] + N[i, j]*M[k, l]) assert _codegen_array_parse(expr) == (CodegenArrayDiagonal(CodegenArrayElementwiseAdd( CodegenArrayTensorProduct(M, N), CodegenArrayPermuteDims(CodegenArrayTensorProduct(M, N), Permutation(0, 2)(1, 3)) ), (1, 2)), (i, l, frozenset({j, m, k}))) expr = KroneckerDelta(i, j)*KroneckerDelta(j, k)*KroneckerDelta(k,m)*M[i, 0]*KroneckerDelta(m, n) assert _codegen_array_parse(expr) == (M, ({i,j,k,m,n}, 0)) expr = M[i, i] assert _codegen_array_parse(expr) == (CodegenArrayDiagonal(M, (0, 1)), (i,)) def test_codegen_array_diagonal(): cg = CodegenArrayDiagonal(M, (1, 0)) assert cg == CodegenArrayDiagonal(M, (0, 1)) cg = CodegenArrayDiagonal(CodegenArrayTensorProduct(M, N, P), (4, 1), (2, 0)) assert cg == CodegenArrayDiagonal(CodegenArrayTensorProduct(M, N, P), (1, 4), (0, 2)) def test_codegen_recognize_matrix_expression(): expr = CodegenArrayElementwiseAdd(M, CodegenArrayPermuteDims(M, [1, 0])) rec = _recognize_matrix_expression(expr) assert rec == _RecognizeMatOp(MatAdd, [M, _RecognizeMatOp(Transpose, [M])]) assert _unfold_recognized_expr(rec) == M + Transpose(M) expr = M[i,j] + N[i,j] p1, p2 = _codegen_array_parse(expr) rec = _recognize_matrix_expression(p1) assert rec == _RecognizeMatOp(MatAdd, [M, N]) assert _unfold_recognized_expr(rec) == M + N expr = M[i,j] + N[j,i] p1, p2 = _codegen_array_parse(expr) rec = _recognize_matrix_expression(p1) assert rec == _RecognizeMatOp(MatAdd, [M, _RecognizeMatOp(Transpose, [N])]) assert _unfold_recognized_expr(rec) == M + N.T expr = M[i,j]*N[k,l] + N[i,j]*M[k,l] p1, p2 = _codegen_array_parse(expr) rec = _recognize_matrix_expression(p1) assert rec == _RecognizeMatOp(MatAdd, [_RecognizeMatMulLines([M, N]), _RecognizeMatMulLines([N, M])]) #assert _unfold_recognized_expr(rec) == TensorProduct(M, N) + TensorProduct(N, M) maybe? expr = (M*N*P)[i, j] p1, p2 = _codegen_array_parse(expr) rec = _recognize_matrix_expression(p1) assert rec == _RecognizeMatMulLines([_RecognizeMatOp(MatMul, [M, N, P])]) assert _unfold_recognized_expr(rec) == M*N*P expr = Sum(M[i,j]*(N*P)[j,m], (j, 0, k-1)) p1, p2 = _codegen_array_parse(expr) rec = _recognize_matrix_expression(p1) assert rec == _RecognizeMatOp(MatMul, [M, N, P]) assert _unfold_recognized_expr(rec) == M*N*P expr = Sum((P[j, m] + P[m, j])*(M[i,j]*N[m,n] + N[i,j]*M[m,n]), (j, 0, k-1), (m, 0, k-1)) p1, p2 = _codegen_array_parse(expr) rec = _recognize_matrix_expression(p1) assert rec == _RecognizeMatOp(MatAdd, [ _RecognizeMatOp(MatMul, [M, _RecognizeMatOp(MatAdd, [P, _RecognizeMatOp(Transpose, [P])]), N]), _RecognizeMatOp(MatMul, [N, _RecognizeMatOp(MatAdd, [P, _RecognizeMatOp(Transpose, [P])]), M]) ]) assert _unfold_recognized_expr(rec) == M*(P + P.T)*N + N*(P + P.T)*M def test_codegen_array_shape(): expr = CodegenArrayTensorProduct(M, N, P, Q) assert expr.shape == (k, k, k, k, k, k, k, k) Z = MatrixSymbol("Z", m, n) expr = CodegenArrayTensorProduct(M, Z) assert expr.shape == (k, k, m, n) expr2 = CodegenArrayContraction(expr, (0, 1)) assert expr2.shape == (m, n) expr2 = CodegenArrayDiagonal(expr, (0, 1)) assert expr2.shape == (m, n, k) exprp = CodegenArrayPermuteDims(expr, [2, 1, 3, 0]) assert exprp.shape == (m, k, n, k) expr3 = CodegenArrayTensorProduct(N, Z) expr2 = CodegenArrayElementwiseAdd(expr, expr3) assert expr2.shape == (k, k, m, n) # Contraction along axes with discordant dimensions: raises(ValueError, lambda: CodegenArrayContraction(expr, (1, 2))) # Also diagonal needs the same dimensions: raises(ValueError, lambda: CodegenArrayDiagonal(expr, (1, 2))) def test_codegen_array_parse_out_of_bounds(): expr = Sum(M[i, i], (i, 0, 4)) raises(ValueError, lambda: parse_indexed_expression(expr)) expr = Sum(M[i, i], (i, 0, k)) raises(ValueError, lambda: parse_indexed_expression(expr)) expr = Sum(M[i, i], (i, 1, k-1)) raises(ValueError, lambda: parse_indexed_expression(expr)) expr = Sum(M[i, j]*N[j,m], (j, 0, 4)) raises(ValueError, lambda: parse_indexed_expression(expr)) expr = Sum(M[i, j]*N[j,m], (j, 0, k)) raises(ValueError, lambda: parse_indexed_expression(expr)) expr = Sum(M[i, j]*N[j,m], (j, 1, k-1)) raises(ValueError, lambda: parse_indexed_expression(expr)) def test_codegen_permutedims_sink(): cg = CodegenArrayPermuteDims(CodegenArrayTensorProduct(M, N), [0, 1, 3, 2]) sunk = cg.nest_permutation() assert sunk == CodegenArrayTensorProduct(M, CodegenArrayPermuteDims(N, [1, 0])) assert recognize_matrix_expression(sunk) == [M, N.T] cg = CodegenArrayPermuteDims(CodegenArrayTensorProduct(M, N), [1, 0, 3, 2]) sunk = cg.nest_permutation() assert sunk == CodegenArrayTensorProduct(CodegenArrayPermuteDims(M, [1, 0]), CodegenArrayPermuteDims(N, [1, 0])) assert recognize_matrix_expression(sunk) == [M.T, N.T] cg = CodegenArrayPermuteDims(CodegenArrayTensorProduct(M, N), [3, 2, 1, 0]) sunk = cg.nest_permutation() assert sunk == CodegenArrayTensorProduct(CodegenArrayPermuteDims(N, [1, 0]), CodegenArrayPermuteDims(M, [1, 0])) assert recognize_matrix_expression(sunk) == [N.T, M.T] cg = CodegenArrayPermuteDims(CodegenArrayContraction(CodegenArrayTensorProduct(M, N), (1, 2)), [1, 0]) sunk = cg.nest_permutation() assert sunk == CodegenArrayContraction(CodegenArrayPermuteDims(CodegenArrayTensorProduct(M, N), [[0, 3]]), (1, 2)) cg = CodegenArrayPermuteDims(CodegenArrayTensorProduct(M, N), [1, 0, 3, 2]) sunk = cg.nest_permutation() assert sunk == CodegenArrayTensorProduct(CodegenArrayPermuteDims(M, [1, 0]), CodegenArrayPermuteDims(N, [1, 0])) cg = CodegenArrayPermuteDims(CodegenArrayContraction(CodegenArrayTensorProduct(M, N, P), (1, 2), (3, 4)), [1, 0]) sunk = cg.nest_permutation() assert sunk == CodegenArrayContraction(CodegenArrayPermuteDims(CodegenArrayTensorProduct(M, N, P), [[0, 5]]), (1, 2), (3, 4)) sunk2 = sunk.expr.nest_permutation() def test_parsing_of_matrix_expressions(): expr = M*N assert _parse_matrix_expression(expr) == CodegenArrayContraction(CodegenArrayTensorProduct(M, N), (1, 2)) expr = Transpose(M) assert _parse_matrix_expression(expr) == CodegenArrayPermuteDims(M, [1, 0]) expr = M*Transpose(N) assert _parse_matrix_expression(expr) == CodegenArrayContraction(CodegenArrayTensorProduct(M, CodegenArrayPermuteDims(N, [1, 0])), (1, 2)) def test_special_matrices(): a = MatrixSymbol("a", k, 1) b = MatrixSymbol("b", k, 1) expr = a.T*b elem = expr[0, 0] cg = parse_indexed_expression(elem) assert cg == CodegenArrayContraction(CodegenArrayTensorProduct(a, b), (0, 2)) assert recognize_matrix_expression(cg) == a.T*b def test_recognize_diagonalized_vectors(): a = MatrixSymbol("a", k, 1) b = MatrixSymbol("b", k, 1) A = MatrixSymbol("A", k, k) B = MatrixSymbol("B", k, k) C = MatrixSymbol("C", k, k) cg = CodegenArrayContraction(CodegenArrayTensorProduct(A, a), (1, 2)) assert cg.split_multiple_contractions() == cg assert recognize_matrix_expression(cg) == A*a cg = CodegenArrayContraction(CodegenArrayTensorProduct(A, a, B), (1, 2, 4)) assert cg.split_multiple_contractions() == CodegenArrayContraction(CodegenArrayTensorProduct(A, DiagonalizeVector(a), B), (1, 2), (3, 4)) assert recognize_matrix_expression(cg) == A*DiagonalizeVector(a)*B cg = CodegenArrayContraction(CodegenArrayTensorProduct(A, a, B), (0, 2, 4)) assert cg.split_multiple_contractions() == CodegenArrayContraction(CodegenArrayTensorProduct(A, DiagonalizeVector(a), B), (0, 2), (3, 4)) assert recognize_matrix_expression(cg) == A.T*DiagonalizeVector(a)*B cg = CodegenArrayContraction(CodegenArrayTensorProduct(A, a, b, a.T, B), (0, 2, 4, 7, 9)) assert cg.split_multiple_contractions() == CodegenArrayContraction(CodegenArrayTensorProduct(A, DiagonalizeVector(a), DiagonalizeVector(b), DiagonalizeVector(a), B), (0, 2), (3, 4), (5, 7), (6, 9)) assert recognize_matrix_expression(cg).doit() == A.T*DiagonalizeVector(a)*DiagonalizeVector(b)*DiagonalizeVector(a)*B.T I1 = Identity(1) cg = CodegenArrayContraction(CodegenArrayTensorProduct(I1, I1, I1), (1, 2, 4)) assert cg.split_multiple_contractions() == CodegenArrayContraction(CodegenArrayTensorProduct(I1, I1, I1), (1, 2), (3, 4)) assert recognize_matrix_expression(cg).doit() == Identity(1) I = Identity(k) cg = CodegenArrayContraction(CodegenArrayTensorProduct(I, I, I, I, A), (1, 2, 8), (5, 6, 9)) assert recognize_matrix_expression(cg.split_multiple_contractions()).doit() == A cg = CodegenArrayContraction(CodegenArrayTensorProduct(A, a, C, a, B), (1, 2, 4), (5, 6, 8)) assert cg.split_multiple_contractions() == CodegenArrayContraction(CodegenArrayTensorProduct(A, DiagonalizeVector(a), C, DiagonalizeVector(a), B), (1, 2), (3, 4), (5, 6), (7, 8)) assert recognize_matrix_expression(cg) == A*DiagonalizeVector(a)*C*DiagonalizeVector(a)*B cg = CodegenArrayContraction(CodegenArrayTensorProduct(a, I1, b, I1, (a.T*b).applyfunc(cos)), (1, 2, 8), (5, 6, 9)) assert cg.split_multiple_contractions() == CodegenArrayContraction(CodegenArrayTensorProduct(a, I1, b, I1, (a.T*b).applyfunc(cos)), (1, 2), (3, 8), (5, 6), (7, 9)) assert recognize_matrix_expression(cg) == MatMul(a, I1, (a.T*b).applyfunc(cos), Transpose(I1), b.T) # Check no overlap of lines: cg = CodegenArrayContraction(CodegenArrayTensorProduct(A, a, C, a, B), (1, 2, 4), (5, 6, 8), (3, 7)) raises(ValueError, lambda: cg.split_multiple_contractions()) cg = CodegenArrayContraction(CodegenArrayTensorProduct(a, b, A), (0, 2, 4), (1, 3)) raises(ValueError, lambda: cg.split_multiple_contractions())
7f50948772ce0ed0efbe511dfd257e4abd9acdbfafedd2d7a5954d467991b892
from sympy.core import symbols from sympy.core.compatibility import range from sympy.crypto.crypto import (cycle_list, encipher_shift, encipher_affine, encipher_substitution, check_and_join, encipher_vigenere, decipher_vigenere, encipher_hill, decipher_hill, encipher_bifid5, encipher_bifid6, bifid5_square, bifid6_square, bifid5, bifid6, bifid10, decipher_bifid5, decipher_bifid6, encipher_kid_rsa, decipher_kid_rsa, kid_rsa_private_key, kid_rsa_public_key, decipher_rsa, rsa_private_key, rsa_public_key, encipher_rsa, lfsr_connection_polynomial, lfsr_autocorrelation, lfsr_sequence, encode_morse, decode_morse, elgamal_private_key, elgamal_public_key, encipher_elgamal, decipher_elgamal, dh_private_key, dh_public_key, dh_shared_key, decipher_shift, decipher_affine, encipher_bifid, decipher_bifid, bifid_square, padded_key, uniq, decipher_gm, encipher_gm, gm_public_key, gm_private_key, encipher_bg, decipher_bg, bg_private_key, bg_public_key, encipher_rot13, decipher_rot13, encipher_atbash, decipher_atbash) from sympy.matrices import Matrix from sympy.ntheory import isprime, is_primitive_root from sympy.polys.domains import FF from sympy.utilities.pytest import raises, slow, warns_deprecated_sympy from random import randrange def test_cycle_list(): assert cycle_list(3, 4) == [3, 0, 1, 2] assert cycle_list(-1, 4) == [3, 0, 1, 2] assert cycle_list(1, 4) == [1, 2, 3, 0] def test_encipher_shift(): assert encipher_shift("ABC", 0) == "ABC" assert encipher_shift("ABC", 1) == "BCD" assert encipher_shift("ABC", -1) == "ZAB" assert decipher_shift("ZAB", -1) == "ABC" def test_encipher_rot13(): assert encipher_rot13("ABC") == "NOP" assert encipher_rot13("NOP") == "ABC" assert decipher_rot13("ABC") == "NOP" assert decipher_rot13("NOP") == "ABC" def test_encipher_affine(): assert encipher_affine("ABC", (1, 0)) == "ABC" assert encipher_affine("ABC", (1, 1)) == "BCD" assert encipher_affine("ABC", (-1, 0)) == "AZY" assert encipher_affine("ABC", (-1, 1), symbols="ABCD") == "BAD" assert encipher_affine("123", (-1, 1), symbols="1234") == "214" assert encipher_affine("ABC", (3, 16)) == "QTW" assert decipher_affine("QTW", (3, 16)) == "ABC" def test_encipher_atbash(): assert encipher_atbash("ABC") == "ZYX" assert encipher_atbash("ZYX") == "ABC" assert decipher_atbash("ABC") == "ZYX" assert decipher_atbash("ZYX") == "ABC" def test_encipher_substitution(): assert encipher_substitution("ABC", "BAC", "ABC") == "BAC" assert encipher_substitution("123", "1243", "1234") == "124" def test_check_and_join(): assert check_and_join("abc") == "abc" assert check_and_join(uniq("aaabc")) == "abc" assert check_and_join("ab c".split()) == "abc" assert check_and_join("abc", "a", filter=True) == "a" raises(ValueError, lambda: check_and_join('ab', 'a')) def test_encipher_vigenere(): assert encipher_vigenere("ABC", "ABC") == "ACE" assert encipher_vigenere("ABC", "ABC", symbols="ABCD") == "ACA" assert encipher_vigenere("ABC", "AB", symbols="ABCD") == "ACC" assert encipher_vigenere("AB", "ABC", symbols="ABCD") == "AC" assert encipher_vigenere("A", "ABC", symbols="ABCD") == "A" def test_decipher_vigenere(): assert decipher_vigenere("ABC", "ABC") == "AAA" assert decipher_vigenere("ABC", "ABC", symbols="ABCD") == "AAA" assert decipher_vigenere("ABC", "AB", symbols="ABCD") == "AAC" assert decipher_vigenere("AB", "ABC", symbols="ABCD") == "AA" assert decipher_vigenere("A", "ABC", symbols="ABCD") == "A" def test_encipher_hill(): A = Matrix(2, 2, [1, 2, 3, 5]) assert encipher_hill("ABCD", A) == "CFIV" A = Matrix(2, 2, [1, 0, 0, 1]) assert encipher_hill("ABCD", A) == "ABCD" assert encipher_hill("ABCD", A, symbols="ABCD") == "ABCD" A = Matrix(2, 2, [1, 2, 3, 5]) assert encipher_hill("ABCD", A, symbols="ABCD") == "CBAB" assert encipher_hill("AB", A, symbols="ABCD") == "CB" # message length, n, does not need to be a multiple of k; # it is padded assert encipher_hill("ABA", A) == "CFGC" assert encipher_hill("ABA", A, pad="Z") == "CFYV" def test_decipher_hill(): A = Matrix(2, 2, [1, 2, 3, 5]) assert decipher_hill("CFIV", A) == "ABCD" A = Matrix(2, 2, [1, 0, 0, 1]) assert decipher_hill("ABCD", A) == "ABCD" assert decipher_hill("ABCD", A, symbols="ABCD") == "ABCD" A = Matrix(2, 2, [1, 2, 3, 5]) assert decipher_hill("CBAB", A, symbols="ABCD") == "ABCD" assert decipher_hill("CB", A, symbols="ABCD") == "AB" # n does not need to be a multiple of k assert decipher_hill("CFA", A) == "ABAA" def test_encipher_bifid5(): assert encipher_bifid5("AB", "AB") == "AB" assert encipher_bifid5("AB", "CD") == "CO" assert encipher_bifid5("ab", "c") == "CH" assert encipher_bifid5("a bc", "b") == "BAC" def test_bifid5_square(): A = bifid5 f = lambda i, j: symbols(A[5*i + j]) M = Matrix(5, 5, f) assert bifid5_square("") == M def test_decipher_bifid5(): assert decipher_bifid5("AB", "AB") == "AB" assert decipher_bifid5("CO", "CD") == "AB" assert decipher_bifid5("ch", "c") == "AB" assert decipher_bifid5("b ac", "b") == "ABC" def test_encipher_bifid6(): assert encipher_bifid6("AB", "AB") == "AB" assert encipher_bifid6("AB", "CD") == "CP" assert encipher_bifid6("ab", "c") == "CI" assert encipher_bifid6("a bc", "b") == "BAC" def test_decipher_bifid6(): assert decipher_bifid6("AB", "AB") == "AB" assert decipher_bifid6("CP", "CD") == "AB" assert decipher_bifid6("ci", "c") == "AB" assert decipher_bifid6("b ac", "b") == "ABC" def test_bifid6_square(): A = bifid6 f = lambda i, j: symbols(A[6*i + j]) M = Matrix(6, 6, f) assert bifid6_square("") == M def test_rsa_public_key(): assert rsa_public_key(2, 3, 1) == (6, 1) assert rsa_public_key(5, 3, 3) == (15, 3) assert rsa_public_key(8, 8, 8) is False with warns_deprecated_sympy(): assert rsa_public_key(2, 2, 1) == (4, 1) def test_rsa_private_key(): assert rsa_private_key(2, 3, 1) == (6, 1) assert rsa_private_key(5, 3, 3) == (15, 3) assert rsa_private_key(23,29,5) == (667,493) assert rsa_private_key(8, 8, 8) is False with warns_deprecated_sympy(): assert rsa_private_key(2, 2, 1) == (4, 1) def test_rsa_large_key(): # Sample from # http://www.herongyang.com/Cryptography/JCE-Public-Key-RSA-Private-Public-Key-Pair-Sample.html p = int('101565610013301240713207239558950144682174355406589305284428666'\ '903702505233009') q = int('894687191887545488935455605955948413812376003053143521429242133'\ '12069293984003') e = int('65537') d = int('893650581832704239530398858744759129594796235440844479456143566'\ '6999402846577625762582824202269399672579058991442587406384754958587'\ '400493169361356902030209') assert rsa_public_key(p, q, e) == (p*q, e) assert rsa_private_key(p, q, e) == (p*q, d) def test_encipher_rsa(): puk = rsa_public_key(2, 3, 1) assert encipher_rsa(2, puk) == 2 puk = rsa_public_key(5, 3, 3) assert encipher_rsa(2, puk) == 8 with warns_deprecated_sympy(): puk = rsa_public_key(2, 2, 1) assert encipher_rsa(2, puk) == 2 def test_decipher_rsa(): prk = rsa_private_key(2, 3, 1) assert decipher_rsa(2, prk) == 2 prk = rsa_private_key(5, 3, 3) assert decipher_rsa(8, prk) == 2 with warns_deprecated_sympy(): prk = rsa_private_key(2, 2, 1) assert decipher_rsa(2, prk) == 2 def test_kid_rsa_public_key(): assert kid_rsa_public_key(1, 2, 1, 1) == (5, 2) assert kid_rsa_public_key(1, 2, 2, 1) == (8, 3) assert kid_rsa_public_key(1, 2, 1, 2) == (7, 2) def test_kid_rsa_private_key(): assert kid_rsa_private_key(1, 2, 1, 1) == (5, 3) assert kid_rsa_private_key(1, 2, 2, 1) == (8, 3) assert kid_rsa_private_key(1, 2, 1, 2) == (7, 4) def test_encipher_kid_rsa(): assert encipher_kid_rsa(1, (5, 2)) == 2 assert encipher_kid_rsa(1, (8, 3)) == 3 assert encipher_kid_rsa(1, (7, 2)) == 2 def test_decipher_kid_rsa(): assert decipher_kid_rsa(2, (5, 3)) == 1 assert decipher_kid_rsa(3, (8, 3)) == 1 assert decipher_kid_rsa(2, (7, 4)) == 1 def test_encode_morse(): assert encode_morse('ABC') == '.-|-...|-.-.' assert encode_morse('SMS ') == '...|--|...||' assert encode_morse('SMS\n') == '...|--|...||' assert encode_morse('') == '' assert encode_morse(' ') == '||' assert encode_morse(' ', sep='`') == '``' assert encode_morse(' ', sep='``') == '````' assert encode_morse('!@#$%^&*()_+') == '-.-.--|.--.-.|...-..-|-.--.|-.--.-|..--.-|.-.-.' def test_decode_morse(): assert decode_morse('-.-|.|-.--') == 'KEY' assert decode_morse('.-.|..-|-.||') == 'RUN' raises(KeyError, lambda: decode_morse('.....----')) def test_lfsr_sequence(): raises(TypeError, lambda: lfsr_sequence(1, [1], 1)) raises(TypeError, lambda: lfsr_sequence([1], 1, 1)) F = FF(2) assert lfsr_sequence([F(1)], [F(1)], 2) == [F(1), F(1)] assert lfsr_sequence([F(0)], [F(1)], 2) == [F(1), F(0)] F = FF(3) assert lfsr_sequence([F(1)], [F(1)], 2) == [F(1), F(1)] assert lfsr_sequence([F(0)], [F(2)], 2) == [F(2), F(0)] assert lfsr_sequence([F(1)], [F(2)], 2) == [F(2), F(2)] def test_lfsr_autocorrelation(): raises(TypeError, lambda: lfsr_autocorrelation(1, 2, 3)) F = FF(2) s = lfsr_sequence([F(1), F(0)], [F(0), F(1)], 5) assert lfsr_autocorrelation(s, 2, 0) == 1 assert lfsr_autocorrelation(s, 2, 1) == -1 def test_lfsr_connection_polynomial(): F = FF(2) x = symbols("x") s = lfsr_sequence([F(1), F(0)], [F(0), F(1)], 5) assert lfsr_connection_polynomial(s) == x**2 + 1 s = lfsr_sequence([F(1), F(1)], [F(0), F(1)], 5) assert lfsr_connection_polynomial(s) == x**2 + x + 1 def test_elgamal_private_key(): a, b, _ = elgamal_private_key(digit=100) assert isprime(a) assert is_primitive_root(b, a) assert len(bin(a)) >= 102 def test_elgamal(): dk = elgamal_private_key(5) ek = elgamal_public_key(dk) P = ek[0] assert P - 1 == decipher_elgamal(encipher_elgamal(P - 1, ek), dk) raises(ValueError, lambda: encipher_elgamal(P, dk)) raises(ValueError, lambda: encipher_elgamal(-1, dk)) def test_dh_private_key(): p, g, _ = dh_private_key(digit = 100) assert isprime(p) assert is_primitive_root(g, p) assert len(bin(p)) >= 102 def test_dh_public_key(): p1, g1, a = dh_private_key(digit = 100) p2, g2, ga = dh_public_key((p1, g1, a)) assert p1 == p2 assert g1 == g2 assert ga == pow(g1, a, p1) def test_dh_shared_key(): prk = dh_private_key(digit = 100) p, _, ga = dh_public_key(prk) b = randrange(2, p) sk = dh_shared_key((p, _, ga), b) assert sk == pow(ga, b, p) raises(ValueError, lambda: dh_shared_key((1031, 14, 565), 2000)) def test_padded_key(): assert padded_key('b', 'ab') == 'ba' raises(ValueError, lambda: padded_key('ab', 'ace')) raises(ValueError, lambda: padded_key('ab', 'abba')) def test_bifid(): raises(ValueError, lambda: encipher_bifid('abc', 'b', 'abcde')) assert encipher_bifid('abc', 'b', 'abcd') == 'bdb' raises(ValueError, lambda: decipher_bifid('bdb', 'b', 'abcde')) assert encipher_bifid('bdb', 'b', 'abcd') == 'abc' raises(ValueError, lambda: bifid_square('abcde')) assert bifid5_square("B") == \ bifid5_square('BACDEFGHIKLMNOPQRSTUVWXYZ') assert bifid6_square('B0') == \ bifid6_square('B0ACDEFGHIJKLMNOPQRSTUVWXYZ123456789') def test_encipher_decipher_gm(): ps = [131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199] qs = [89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 47] messages = [ 0, 32855, 34303, 14805, 1280, 75859, 38368, 724, 60356, 51675, 76697, 61854, 18661, ] for p, q in zip(ps, qs): pri = gm_private_key(p, q) for msg in messages: pub = gm_public_key(p, q) enc = encipher_gm(msg, pub) dec = decipher_gm(enc, pri) assert dec == msg def test_gm_private_key(): raises(ValueError, lambda: gm_public_key(13, 15)) raises(ValueError, lambda: gm_public_key(0, 0)) raises(ValueError, lambda: gm_public_key(0, 5)) assert 17, 19 == gm_public_key(17, 19) def test_gm_public_key(): assert 323 == gm_public_key(17, 19)[1] assert 15 == gm_public_key(3, 5)[1] raises(ValueError, lambda: gm_public_key(15, 19)) def test_encipher_decipher_bg(): ps = [67, 7, 71, 103, 11, 43, 107, 47, 79, 19, 83, 23, 59, 127, 31] qs = qs = [7, 71, 103, 11, 43, 107, 47, 79, 19, 83, 23, 59, 127, 31, 67] messages = [ 0, 328, 343, 148, 1280, 758, 383, 724, 603, 516, 766, 618, 186, ] for p, q in zip(ps, qs): pri = bg_private_key(p, q) for msg in messages: pub = bg_public_key(p, q) enc = encipher_bg(msg, pub) dec = decipher_bg(enc, pri) assert dec == msg def test_bg_private_key(): raises(ValueError, lambda: bg_private_key(8, 16)) raises(ValueError, lambda: bg_private_key(8, 8)) raises(ValueError, lambda: bg_private_key(13, 17)) assert 23, 31 == bg_private_key(23, 31) def test_bg_public_key(): assert 5293 == bg_public_key(67, 79) assert 713 == bg_public_key(23, 31) raises(ValueError, lambda: bg_private_key(13, 17))
c079abd5b4e775b685482931fa19e9601619abb9f7b274b53b853898dacd3d67
""" This module contains query handlers responsible for calculus queries: infinitesimal, bounded, etc. """ from __future__ import print_function, division from sympy.logic.boolalg import conjuncts from sympy.assumptions import Q, ask from sympy.assumptions.handlers import CommonHandler, test_closed_group from sympy.matrices.expressions import MatMul, MatrixExpr from sympy.core.logic import fuzzy_and from sympy.utilities.iterables import sift from sympy.core import Basic from functools import partial def _Factorization(predicate, expr, assumptions): if predicate in expr.predicates: return True class AskSquareHandler(CommonHandler): """ Handler for key 'square' """ @staticmethod def MatrixExpr(expr, assumptions): return expr.shape[0] == expr.shape[1] class AskSymmetricHandler(CommonHandler): """ Handler for key 'symmetric' """ @staticmethod def MatMul(expr, assumptions): factor, mmul = expr.as_coeff_mmul() if all(ask(Q.symmetric(arg), assumptions) for arg in mmul.args): return True # TODO: implement sathandlers system for the matrices. # Now it duplicates the general fact: Implies(Q.diagonal, Q.symmetric). if ask(Q.diagonal(expr), assumptions): return True if len(mmul.args) >= 2 and mmul.args[0] == mmul.args[-1].T: if len(mmul.args) == 2: return True return ask(Q.symmetric(MatMul(*mmul.args[1:-1])), assumptions) @staticmethod def MatPow(expr, assumptions): # only for integer powers base, exp = expr.args int_exp = ask(Q.integer(exp), assumptions) if not int_exp: return None non_negative = ask(~Q.negative(exp), assumptions) if (non_negative or non_negative == False and ask(Q.invertible(base), assumptions)): return ask(Q.symmetric(base), assumptions) return None @staticmethod def MatAdd(expr, assumptions): return all(ask(Q.symmetric(arg), assumptions) for arg in expr.args) @staticmethod def MatrixSymbol(expr, assumptions): if not expr.is_square: return False # TODO: implement sathandlers system for the matrices. # Now it duplicates the general fact: Implies(Q.diagonal, Q.symmetric). if ask(Q.diagonal(expr), assumptions): return True if Q.symmetric(expr) in conjuncts(assumptions): return True @staticmethod def ZeroMatrix(expr, assumptions): return ask(Q.square(expr), assumptions) @staticmethod def Transpose(expr, assumptions): return ask(Q.symmetric(expr.arg), assumptions) Inverse = Transpose @staticmethod def MatrixSlice(expr, assumptions): # TODO: implement sathandlers system for the matrices. # Now it duplicates the general fact: Implies(Q.diagonal, Q.symmetric). if ask(Q.diagonal(expr), assumptions): return True if not expr.on_diag: return None else: return ask(Q.symmetric(expr.parent), assumptions) Identity = staticmethod(CommonHandler.AlwaysTrue) class AskInvertibleHandler(CommonHandler): """ Handler for key 'invertible' """ @staticmethod def MatMul(expr, assumptions): factor, mmul = expr.as_coeff_mmul() if all(ask(Q.invertible(arg), assumptions) for arg in mmul.args): return True if any(ask(Q.invertible(arg), assumptions) is False for arg in mmul.args): return False @staticmethod def MatPow(expr, assumptions): # only for integer powers base, exp = expr.args int_exp = ask(Q.integer(exp), assumptions) if not int_exp: return None if exp.is_negative == False: return ask(Q.invertible(base), assumptions) return None @staticmethod def MatAdd(expr, assumptions): return None @staticmethod def MatrixSymbol(expr, assumptions): if not expr.is_square: return False if Q.invertible(expr) in conjuncts(assumptions): return True Identity, Inverse = [staticmethod(CommonHandler.AlwaysTrue)]*2 ZeroMatrix = staticmethod(CommonHandler.AlwaysFalse) @staticmethod def Transpose(expr, assumptions): return ask(Q.invertible(expr.arg), assumptions) @staticmethod def MatrixSlice(expr, assumptions): if not expr.on_diag: return None else: return ask(Q.invertible(expr.parent), assumptions) class AskOrthogonalHandler(CommonHandler): """ Handler for key 'orthogonal' """ predicate = Q.orthogonal @staticmethod def MatMul(expr, assumptions): factor, mmul = expr.as_coeff_mmul() if (all(ask(Q.orthogonal(arg), assumptions) for arg in mmul.args) and factor == 1): return True if any(ask(Q.invertible(arg), assumptions) is False for arg in mmul.args): return False @staticmethod def MatPow(expr, assumptions): # only for integer powers base, exp = expr.args int_exp = ask(Q.integer(exp), assumptions) if int_exp: return ask(Q.orthogonal(base), assumptions) return None @staticmethod def MatAdd(expr, assumptions): if (len(expr.args) == 1 and ask(Q.orthogonal(expr.args[0]), assumptions)): return True @staticmethod def MatrixSymbol(expr, assumptions): if (not expr.is_square or ask(Q.invertible(expr), assumptions) is False): return False if Q.orthogonal(expr) in conjuncts(assumptions): return True Identity = staticmethod(CommonHandler.AlwaysTrue) ZeroMatrix = staticmethod(CommonHandler.AlwaysFalse) @staticmethod def Transpose(expr, assumptions): return ask(Q.orthogonal(expr.arg), assumptions) Inverse = Transpose @staticmethod def MatrixSlice(expr, assumptions): if not expr.on_diag: return None else: return ask(Q.orthogonal(expr.parent), assumptions) Factorization = staticmethod(partial(_Factorization, Q.orthogonal)) class AskUnitaryHandler(CommonHandler): """ Handler for key 'unitary' """ predicate = Q.unitary @staticmethod def MatMul(expr, assumptions): factor, mmul = expr.as_coeff_mmul() if (all(ask(Q.unitary(arg), assumptions) for arg in mmul.args) and abs(factor) == 1): return True if any(ask(Q.invertible(arg), assumptions) is False for arg in mmul.args): return False @staticmethod def MatPow(expr, assumptions): # only for integer powers base, exp = expr.args int_exp = ask(Q.integer(exp), assumptions) if int_exp: return ask(Q.unitary(base), assumptions) return None @staticmethod def MatrixSymbol(expr, assumptions): if (not expr.is_square or ask(Q.invertible(expr), assumptions) is False): return False if Q.unitary(expr) in conjuncts(assumptions): return True @staticmethod def Transpose(expr, assumptions): return ask(Q.unitary(expr.arg), assumptions) Inverse = Transpose @staticmethod def MatrixSlice(expr, assumptions): if not expr.on_diag: return None else: return ask(Q.unitary(expr.parent), assumptions) @staticmethod def DFT(expr, assumptions): return True Factorization = staticmethod(partial(_Factorization, Q.unitary)) Identity = staticmethod(CommonHandler.AlwaysTrue) ZeroMatrix = staticmethod(CommonHandler.AlwaysFalse) class AskFullRankHandler(CommonHandler): """ Handler for key 'fullrank' """ @staticmethod def MatMul(expr, assumptions): if all(ask(Q.fullrank(arg), assumptions) for arg in expr.args): return True @staticmethod def MatPow(expr, assumptions): # only for integer powers base, exp = expr.args int_exp = ask(Q.integer(exp), assumptions) if int_exp and ask(~Q.negative(exp), assumptions): return ask(Q.fullrank(base), assumptions) return None Identity = staticmethod(CommonHandler.AlwaysTrue) ZeroMatrix = staticmethod(CommonHandler.AlwaysFalse) @staticmethod def Transpose(expr, assumptions): return ask(Q.fullrank(expr.arg), assumptions) Inverse = Transpose @staticmethod def MatrixSlice(expr, assumptions): if ask(Q.orthogonal(expr.parent), assumptions): return True class AskPositiveDefiniteHandler(CommonHandler): """ Handler for key 'positive_definite' """ @staticmethod def MatMul(expr, assumptions): factor, mmul = expr.as_coeff_mmul() if (all(ask(Q.positive_definite(arg), assumptions) for arg in mmul.args) and factor > 0): return True if (len(mmul.args) >= 2 and mmul.args[0] == mmul.args[-1].T and ask(Q.fullrank(mmul.args[0]), assumptions)): return ask(Q.positive_definite( MatMul(*mmul.args[1:-1])), assumptions) @staticmethod def MatPow(expr, assumptions): # a power of a positive definite matrix is positive definite if ask(Q.positive_definite(expr.args[0]), assumptions): return True @staticmethod def MatAdd(expr, assumptions): if all(ask(Q.positive_definite(arg), assumptions) for arg in expr.args): return True @staticmethod def MatrixSymbol(expr, assumptions): if not expr.is_square: return False if Q.positive_definite(expr) in conjuncts(assumptions): return True Identity = staticmethod(CommonHandler.AlwaysTrue) ZeroMatrix = staticmethod(CommonHandler.AlwaysFalse) @staticmethod def Transpose(expr, assumptions): return ask(Q.positive_definite(expr.arg), assumptions) Inverse = Transpose @staticmethod def MatrixSlice(expr, assumptions): if not expr.on_diag: return None else: return ask(Q.positive_definite(expr.parent), assumptions) class AskUpperTriangularHandler(CommonHandler): """ Handler for key 'upper_triangular' """ @staticmethod def MatMul(expr, assumptions): factor, matrices = expr.as_coeff_matrices() if all(ask(Q.upper_triangular(m), assumptions) for m in matrices): return True @staticmethod def MatAdd(expr, assumptions): if all(ask(Q.upper_triangular(arg), assumptions) for arg in expr.args): return True @staticmethod def MatPow(expr, assumptions): # only for integer powers base, exp = expr.args int_exp = ask(Q.integer(exp), assumptions) if not int_exp: return None non_negative = ask(~Q.negative(exp), assumptions) if (non_negative or non_negative == False and ask(Q.invertible(base), assumptions)): return ask(Q.upper_triangular(base), assumptions) return None @staticmethod def MatrixSymbol(expr, assumptions): if Q.upper_triangular(expr) in conjuncts(assumptions): return True Identity, ZeroMatrix = [staticmethod(CommonHandler.AlwaysTrue)]*2 @staticmethod def Transpose(expr, assumptions): return ask(Q.lower_triangular(expr.arg), assumptions) @staticmethod def Inverse(expr, assumptions): return ask(Q.upper_triangular(expr.arg), assumptions) @staticmethod def MatrixSlice(expr, assumptions): if not expr.on_diag: return None else: return ask(Q.upper_triangular(expr.parent), assumptions) Factorization = staticmethod(partial(_Factorization, Q.upper_triangular)) class AskLowerTriangularHandler(CommonHandler): """ Handler for key 'lower_triangular' """ @staticmethod def MatMul(expr, assumptions): factor, matrices = expr.as_coeff_matrices() if all(ask(Q.lower_triangular(m), assumptions) for m in matrices): return True @staticmethod def MatAdd(expr, assumptions): if all(ask(Q.lower_triangular(arg), assumptions) for arg in expr.args): return True @staticmethod def MatPow(expr, assumptions): # only for integer powers base, exp = expr.args int_exp = ask(Q.integer(exp), assumptions) if not int_exp: return None non_negative = ask(~Q.negative(exp), assumptions) if (non_negative or non_negative == False and ask(Q.invertible(base), assumptions)): return ask(Q.lower_triangular(base), assumptions) return None @staticmethod def MatrixSymbol(expr, assumptions): if Q.lower_triangular(expr) in conjuncts(assumptions): return True Identity, ZeroMatrix = [staticmethod(CommonHandler.AlwaysTrue)]*2 @staticmethod def Transpose(expr, assumptions): return ask(Q.upper_triangular(expr.arg), assumptions) @staticmethod def Inverse(expr, assumptions): return ask(Q.lower_triangular(expr.arg), assumptions) @staticmethod def MatrixSlice(expr, assumptions): if not expr.on_diag: return None else: return ask(Q.lower_triangular(expr.parent), assumptions) Factorization = staticmethod(partial(_Factorization, Q.lower_triangular)) class AskDiagonalHandler(CommonHandler): """ Handler for key 'diagonal' """ @staticmethod def _is_empty_or_1x1(expr): return expr.shape == (0, 0) or expr.shape == (1, 1) @staticmethod def MatMul(expr, assumptions): if AskDiagonalHandler._is_empty_or_1x1(expr): return True factor, matrices = expr.as_coeff_matrices() if all(ask(Q.diagonal(m), assumptions) for m in matrices): return True @staticmethod def MatPow(expr, assumptions): # only for integer powers base, exp = expr.args int_exp = ask(Q.integer(exp), assumptions) if not int_exp: return None non_negative = ask(~Q.negative(exp), assumptions) if (non_negative or non_negative == False and ask(Q.invertible(base), assumptions)): return ask(Q.diagonal(base), assumptions) return None @staticmethod def MatAdd(expr, assumptions): if all(ask(Q.diagonal(arg), assumptions) for arg in expr.args): return True @staticmethod def MatrixSymbol(expr, assumptions): if AskDiagonalHandler._is_empty_or_1x1(expr): return True if Q.diagonal(expr) in conjuncts(assumptions): return True Identity, ZeroMatrix = [staticmethod(CommonHandler.AlwaysTrue)]*2 @staticmethod def Transpose(expr, assumptions): return ask(Q.diagonal(expr.arg), assumptions) @staticmethod def Inverse(expr, assumptions): return ask(Q.diagonal(expr.arg), assumptions) @staticmethod def MatrixSlice(expr, assumptions): if AskDiagonalHandler._is_empty_or_1x1(expr): return True if not expr.on_diag: return None else: return ask(Q.diagonal(expr.parent), assumptions) @staticmethod def DiagonalMatrix(expr, assumptions): return True @staticmethod def DiagonalizeVector(expr, assumptions): return True @staticmethod def Identity(expr, assumptions): return True Factorization = staticmethod(partial(_Factorization, Q.diagonal)) def BM_elements(predicate, expr, assumptions): """ Block Matrix elements """ return all(ask(predicate(b), assumptions) for b in expr.blocks) def MS_elements(predicate, expr, assumptions): """ Matrix Slice elements """ return ask(predicate(expr.parent), assumptions) def MatMul_elements(matrix_predicate, scalar_predicate, expr, assumptions): d = sift(expr.args, lambda x: isinstance(x, MatrixExpr)) factors, matrices = d[False], d[True] return fuzzy_and([ test_closed_group(Basic(*factors), assumptions, scalar_predicate), test_closed_group(Basic(*matrices), assumptions, matrix_predicate)]) class AskIntegerElementsHandler(CommonHandler): @staticmethod def MatAdd(expr, assumptions): return test_closed_group(expr, assumptions, Q.integer_elements) @staticmethod def MatPow(expr, assumptions): # only for integer powers base, exp = expr.args int_exp = ask(Q.integer(exp), assumptions) if not int_exp: return None if exp.is_negative == False: return ask(Q.integer_elements(base), assumptions) return None HadamardProduct, Determinant, Trace, Transpose = [MatAdd]*4 ZeroMatrix, Identity = [staticmethod(CommonHandler.AlwaysTrue)]*2 MatMul = staticmethod(partial(MatMul_elements, Q.integer_elements, Q.integer)) MatrixSlice = staticmethod(partial(MS_elements, Q.integer_elements)) BlockMatrix = staticmethod(partial(BM_elements, Q.integer_elements)) class AskRealElementsHandler(CommonHandler): @staticmethod def MatAdd(expr, assumptions): return test_closed_group(expr, assumptions, Q.real_elements) @staticmethod def MatPow(expr, assumptions): # only for integer powers base, exp = expr.args int_exp = ask(Q.integer(exp), assumptions) if not int_exp: return None non_negative = ask(~Q.negative(exp), assumptions) if (non_negative or non_negative == False and ask(Q.invertible(base), assumptions)): return ask(Q.real_elements(base), assumptions) return None HadamardProduct, Determinant, Trace, Transpose, \ Factorization = [MatAdd]*5 MatMul = staticmethod(partial(MatMul_elements, Q.real_elements, Q.real)) MatrixSlice = staticmethod(partial(MS_elements, Q.real_elements)) BlockMatrix = staticmethod(partial(BM_elements, Q.real_elements)) class AskComplexElementsHandler(CommonHandler): @staticmethod def MatAdd(expr, assumptions): return test_closed_group(expr, assumptions, Q.complex_elements) @staticmethod def MatPow(expr, assumptions): # only for integer powers base, exp = expr.args int_exp = ask(Q.integer(exp), assumptions) if not int_exp: return None non_negative = ask(~Q.negative(exp), assumptions) if (non_negative or non_negative == False and ask(Q.invertible(base), assumptions)): return ask(Q.complex_elements(base), assumptions) return None HadamardProduct, Determinant, Trace, Transpose, Inverse, \ Factorization = [MatAdd]*6 MatMul = staticmethod(partial(MatMul_elements, Q.complex_elements, Q.complex)) MatrixSlice = staticmethod(partial(MS_elements, Q.complex_elements)) BlockMatrix = staticmethod(partial(BM_elements, Q.complex_elements)) DFT = staticmethod(CommonHandler.AlwaysTrue)
1ee44f503b1c8a0b05e043d88275f9b22e1c981f41217b50c1cb3bf076782ee7
""" Handlers for predicates related to set membership: integer, rational, etc. """ from __future__ import print_function, division from sympy.assumptions import Q, ask from sympy.assumptions.handlers import CommonHandler, test_closed_group from sympy.core.numbers import pi from sympy.functions.elementary.exponential import exp, log from sympy import I class AskIntegerHandler(CommonHandler): """ Handler for Q.integer Test that an expression belongs to the field of integer numbers """ @staticmethod def Expr(expr, assumptions): return expr.is_integer @staticmethod def _number(expr, assumptions): # helper method try: i = int(expr.round()) if not (expr - i).equals(0): raise TypeError return True except TypeError: return False @staticmethod def Add(expr, assumptions): """ Integer + Integer -> Integer Integer + !Integer -> !Integer !Integer + !Integer -> ? """ if expr.is_number: return AskIntegerHandler._number(expr, assumptions) return test_closed_group(expr, assumptions, Q.integer) @staticmethod def Mul(expr, assumptions): """ Integer*Integer -> Integer Integer*Irrational -> !Integer Odd/Even -> !Integer Integer*Rational -> ? """ if expr.is_number: return AskIntegerHandler._number(expr, assumptions) _output = True for arg in expr.args: if not ask(Q.integer(arg), assumptions): if arg.is_Rational: if arg.q == 2: return ask(Q.even(2*expr), assumptions) if ~(arg.q & 1): return None elif ask(Q.irrational(arg), assumptions): if _output: _output = False else: return else: return return _output Pow = Add int, Integer = [staticmethod(CommonHandler.AlwaysTrue)]*2 Pi, Exp1, GoldenRatio, TribonacciConstant, Infinity, NegativeInfinity, ImaginaryUnit = \ [staticmethod(CommonHandler.AlwaysFalse)]*7 @staticmethod def Rational(expr, assumptions): # rationals with denominator one get # evaluated to Integers return False @staticmethod def Abs(expr, assumptions): return ask(Q.integer(expr.args[0]), assumptions) @staticmethod def MatrixElement(expr, assumptions): return ask(Q.integer_elements(expr.args[0]), assumptions) Determinant = Trace = MatrixElement class AskRationalHandler(CommonHandler): """ Handler for Q.rational Test that an expression belongs to the field of rational numbers """ @staticmethod def Expr(expr, assumptions): return expr.is_rational @staticmethod def Add(expr, assumptions): """ Rational + Rational -> Rational Rational + !Rational -> !Rational !Rational + !Rational -> ? """ if expr.is_number: if expr.as_real_imag()[1]: return False return test_closed_group(expr, assumptions, Q.rational) Mul = Add @staticmethod def Pow(expr, assumptions): """ Rational ** Integer -> Rational Irrational ** Rational -> Irrational Rational ** Irrational -> ? """ if ask(Q.integer(expr.exp), assumptions): return ask(Q.rational(expr.base), assumptions) elif ask(Q.rational(expr.exp), assumptions): if ask(Q.prime(expr.base), assumptions): return False Rational = staticmethod(CommonHandler.AlwaysTrue) Float = staticmethod(CommonHandler.AlwaysNone) ImaginaryUnit, Infinity, NegativeInfinity, Pi, Exp1, GoldenRatio, TribonacciConstant = \ [staticmethod(CommonHandler.AlwaysFalse)]*7 @staticmethod def exp(expr, assumptions): x = expr.args[0] if ask(Q.rational(x), assumptions): return ask(~Q.nonzero(x), assumptions) @staticmethod def cot(expr, assumptions): x = expr.args[0] if ask(Q.rational(x), assumptions): return False @staticmethod def log(expr, assumptions): x = expr.args[0] if ask(Q.rational(x), assumptions): return ask(~Q.nonzero(x - 1), assumptions) sin, cos, tan, asin, atan = [exp]*5 acos, acot = log, cot class AskIrrationalHandler(CommonHandler): @staticmethod def Expr(expr, assumptions): return expr.is_irrational @staticmethod def Basic(expr, assumptions): _real = ask(Q.real(expr), assumptions) if _real: _rational = ask(Q.rational(expr), assumptions) if _rational is None: return None return not _rational else: return _real class AskRealHandler(CommonHandler): """ Handler for Q.real Test that an expression belongs to the field of real numbers """ @staticmethod def Expr(expr, assumptions): return expr.is_real @staticmethod def _number(expr, assumptions): # let as_real_imag() work first since the expression may # be simpler to evaluate i = expr.as_real_imag()[1].evalf(2) if i._prec != 1: return not i # allow None to be returned if we couldn't show for sure # that i was 0 @staticmethod def Add(expr, assumptions): """ Real + Real -> Real Real + (Complex & !Real) -> !Real """ if expr.is_number: return AskRealHandler._number(expr, assumptions) return test_closed_group(expr, assumptions, Q.real) @staticmethod def Mul(expr, assumptions): """ Real*Real -> Real Real*Imaginary -> !Real Imaginary*Imaginary -> Real """ if expr.is_number: return AskRealHandler._number(expr, assumptions) result = True for arg in expr.args: if ask(Q.real(arg), assumptions): pass elif ask(Q.imaginary(arg), assumptions): result = result ^ True else: break else: return result @staticmethod def Pow(expr, assumptions): """ Real**Integer -> Real Positive**Real -> Real Real**(Integer/Even) -> Real if base is nonnegative Real**(Integer/Odd) -> Real Imaginary**(Integer/Even) -> Real Imaginary**(Integer/Odd) -> not Real Imaginary**Real -> ? since Real could be 0 (giving real) or 1 (giving imaginary) b**Imaginary -> Real if log(b) is imaginary and b != 0 and exponent != integer multiple of I*pi/log(b) Real**Real -> ? e.g. sqrt(-1) is imaginary and sqrt(2) is not """ if expr.is_number: return AskRealHandler._number(expr, assumptions) if expr.base.func == exp: if ask(Q.imaginary(expr.base.args[0]), assumptions): if ask(Q.imaginary(expr.exp), assumptions): return True # If the i = (exp's arg)/(I*pi) is an integer or half-integer # multiple of I*pi then 2*i will be an integer. In addition, # exp(i*I*pi) = (-1)**i so the overall realness of the expr # can be determined by replacing exp(i*I*pi) with (-1)**i. i = expr.base.args[0]/I/pi if ask(Q.integer(2*i), assumptions): return ask(Q.real(((-1)**i)**expr.exp), assumptions) return if ask(Q.imaginary(expr.base), assumptions): if ask(Q.integer(expr.exp), assumptions): odd = ask(Q.odd(expr.exp), assumptions) if odd is not None: return not odd return if ask(Q.imaginary(expr.exp), assumptions): imlog = ask(Q.imaginary(log(expr.base)), assumptions) if imlog is not None: # I**i -> real, log(I) is imag; # (2*I)**i -> complex, log(2*I) is not imag return imlog if ask(Q.real(expr.base), assumptions): if ask(Q.real(expr.exp), assumptions): if expr.exp.is_Rational and \ ask(Q.even(expr.exp.q), assumptions): return ask(Q.positive(expr.base), assumptions) elif ask(Q.integer(expr.exp), assumptions): return True elif ask(Q.positive(expr.base), assumptions): return True elif ask(Q.negative(expr.base), assumptions): return False Rational, Float, Pi, Exp1, GoldenRatio, TribonacciConstant, Abs, re, im = \ [staticmethod(CommonHandler.AlwaysTrue)]*9 ImaginaryUnit, Infinity, NegativeInfinity = \ [staticmethod(CommonHandler.AlwaysFalse)]*3 @staticmethod def sin(expr, assumptions): if ask(Q.real(expr.args[0]), assumptions): return True cos = sin @staticmethod def exp(expr, assumptions): return ask(Q.integer(expr.args[0]/I/pi) | Q.real(expr.args[0]), assumptions) @staticmethod def log(expr, assumptions): return ask(Q.positive(expr.args[0]), assumptions) @staticmethod def MatrixElement(expr, assumptions): return ask(Q.real_elements(expr.args[0]), assumptions) Determinant = Trace = MatrixElement class AskExtendedRealHandler(AskRealHandler): """ Handler for Q.extended_real Test that an expression belongs to the field of extended real numbers, that is real numbers union {Infinity, -Infinity} """ @staticmethod def Add(expr, assumptions): return test_closed_group(expr, assumptions, Q.extended_real) Mul, Pow = [Add]*2 Infinity, NegativeInfinity = [staticmethod(CommonHandler.AlwaysTrue)]*2 class AskHermitianHandler(AskRealHandler): """ Handler for Q.hermitian Test that an expression belongs to the field of Hermitian operators """ @staticmethod def Add(expr, assumptions): """ Hermitian + Hermitian -> Hermitian Hermitian + !Hermitian -> !Hermitian """ if expr.is_number: return AskRealHandler._number(expr, assumptions) return test_closed_group(expr, assumptions, Q.hermitian) @staticmethod def Mul(expr, assumptions): """ As long as there is at most only one noncommutative term: Hermitian*Hermitian -> Hermitian Hermitian*Antihermitian -> !Hermitian Antihermitian*Antihermitian -> Hermitian """ if expr.is_number: return AskRealHandler._number(expr, assumptions) nccount = 0 result = True for arg in expr.args: if ask(Q.antihermitian(arg), assumptions): result = result ^ True elif not ask(Q.hermitian(arg), assumptions): break if ask(~Q.commutative(arg), assumptions): nccount += 1 if nccount > 1: break else: return result @staticmethod def Pow(expr, assumptions): """ Hermitian**Integer -> Hermitian """ if expr.is_number: return AskRealHandler._number(expr, assumptions) if ask(Q.hermitian(expr.base), assumptions): if ask(Q.integer(expr.exp), assumptions): return True @staticmethod def sin(expr, assumptions): if ask(Q.hermitian(expr.args[0]), assumptions): return True cos, exp = [sin]*2 class AskComplexHandler(CommonHandler): """ Handler for Q.complex Test that an expression belongs to the field of complex numbers """ @staticmethod def Expr(expr, assumptions): return expr.is_complex @staticmethod def Add(expr, assumptions): return test_closed_group(expr, assumptions, Q.complex) Mul, Pow = [Add]*2 Number, sin, cos, log, exp, re, im, NumberSymbol, Abs, ImaginaryUnit = \ [staticmethod(CommonHandler.AlwaysTrue)]*10 # they are all complex functions or expressions Infinity, NegativeInfinity = [staticmethod(CommonHandler.AlwaysFalse)]*2 @staticmethod def MatrixElement(expr, assumptions): return ask(Q.complex_elements(expr.args[0]), assumptions) Determinant = Trace = MatrixElement class AskImaginaryHandler(CommonHandler): """ Handler for Q.imaginary Test that an expression belongs to the field of imaginary numbers, that is, numbers in the form x*I, where x is real """ @staticmethod def Expr(expr, assumptions): return expr.is_imaginary @staticmethod def _number(expr, assumptions): # let as_real_imag() work first since the expression may # be simpler to evaluate r = expr.as_real_imag()[0].evalf(2) if r._prec != 1: return not r # allow None to be returned if we couldn't show for sure # that r was 0 @staticmethod def Add(expr, assumptions): """ Imaginary + Imaginary -> Imaginary Imaginary + Complex -> ? Imaginary + Real -> !Imaginary """ if expr.is_number: return AskImaginaryHandler._number(expr, assumptions) reals = 0 for arg in expr.args: if ask(Q.imaginary(arg), assumptions): pass elif ask(Q.real(arg), assumptions): reals += 1 else: break else: if reals == 0: return True if reals == 1 or (len(expr.args) == reals): # two reals could sum 0 thus giving an imaginary return False @staticmethod def Mul(expr, assumptions): """ Real*Imaginary -> Imaginary Imaginary*Imaginary -> Real """ if expr.is_number: return AskImaginaryHandler._number(expr, assumptions) result = False reals = 0 for arg in expr.args: if ask(Q.imaginary(arg), assumptions): result = result ^ True elif not ask(Q.real(arg), assumptions): break else: if reals == len(expr.args): return False return result @staticmethod def Pow(expr, assumptions): """ Imaginary**Odd -> Imaginary Imaginary**Even -> Real b**Imaginary -> !Imaginary if exponent is an integer multiple of I*pi/log(b) Imaginary**Real -> ? Positive**Real -> Real Negative**Integer -> Real Negative**(Integer/2) -> Imaginary Negative**Real -> not Imaginary if exponent is not Rational """ if expr.is_number: return AskImaginaryHandler._number(expr, assumptions) if expr.base.func == exp: if ask(Q.imaginary(expr.base.args[0]), assumptions): if ask(Q.imaginary(expr.exp), assumptions): return False i = expr.base.args[0]/I/pi if ask(Q.integer(2*i), assumptions): return ask(Q.imaginary(((-1)**i)**expr.exp), assumptions) if ask(Q.imaginary(expr.base), assumptions): if ask(Q.integer(expr.exp), assumptions): odd = ask(Q.odd(expr.exp), assumptions) if odd is not None: return odd return if ask(Q.imaginary(expr.exp), assumptions): imlog = ask(Q.imaginary(log(expr.base)), assumptions) if imlog is not None: return False # I**i -> real; (2*I)**i -> complex ==> not imaginary if ask(Q.real(expr.base) & Q.real(expr.exp), assumptions): if ask(Q.positive(expr.base), assumptions): return False else: rat = ask(Q.rational(expr.exp), assumptions) if not rat: return rat if ask(Q.integer(expr.exp), assumptions): return False else: half = ask(Q.integer(2*expr.exp), assumptions) if half: return ask(Q.negative(expr.base), assumptions) return half @staticmethod def log(expr, assumptions): if ask(Q.real(expr.args[0]), assumptions): if ask(Q.positive(expr.args[0]), assumptions): return False return # XXX it should be enough to do # return ask(Q.nonpositive(expr.args[0]), assumptions) # but ask(Q.nonpositive(exp(x)), Q.imaginary(x)) -> None; # it should return True since exp(x) will be either 0 or complex if expr.args[0].func == exp: if expr.args[0].args[0] in [I, -I]: return True im = ask(Q.imaginary(expr.args[0]), assumptions) if im is False: return False @staticmethod def exp(expr, assumptions): a = expr.args[0]/I/pi return ask(Q.integer(2*a) & ~Q.integer(a), assumptions) @staticmethod def Number(expr, assumptions): return not (expr.as_real_imag()[1] == 0) NumberSymbol = Number ImaginaryUnit = staticmethod(CommonHandler.AlwaysTrue) class AskAntiHermitianHandler(AskImaginaryHandler): """ Handler for Q.antihermitian Test that an expression belongs to the field of anti-Hermitian operators, that is, operators in the form x*I, where x is Hermitian """ @staticmethod def Add(expr, assumptions): """ Antihermitian + Antihermitian -> Antihermitian Antihermitian + !Antihermitian -> !Antihermitian """ if expr.is_number: return AskImaginaryHandler._number(expr, assumptions) return test_closed_group(expr, assumptions, Q.antihermitian) @staticmethod def Mul(expr, assumptions): """ As long as there is at most only one noncommutative term: Hermitian*Hermitian -> !Antihermitian Hermitian*Antihermitian -> Antihermitian Antihermitian*Antihermitian -> !Antihermitian """ if expr.is_number: return AskImaginaryHandler._number(expr, assumptions) nccount = 0 result = False for arg in expr.args: if ask(Q.antihermitian(arg), assumptions): result = result ^ True elif not ask(Q.hermitian(arg), assumptions): break if ask(~Q.commutative(arg), assumptions): nccount += 1 if nccount > 1: break else: return result @staticmethod def Pow(expr, assumptions): """ Hermitian**Integer -> !Antihermitian Antihermitian**Even -> !Antihermitian Antihermitian**Odd -> Antihermitian """ if expr.is_number: return AskImaginaryHandler._number(expr, assumptions) if ask(Q.hermitian(expr.base), assumptions): if ask(Q.integer(expr.exp), assumptions): return False elif ask(Q.antihermitian(expr.base), assumptions): if ask(Q.even(expr.exp), assumptions): return False elif ask(Q.odd(expr.exp), assumptions): return True class AskAlgebraicHandler(CommonHandler): """Handler for Q.algebraic key. """ @staticmethod def Add(expr, assumptions): return test_closed_group(expr, assumptions, Q.algebraic) @staticmethod def Mul(expr, assumptions): return test_closed_group(expr, assumptions, Q.algebraic) @staticmethod def Pow(expr, assumptions): return expr.exp.is_Rational and ask( Q.algebraic(expr.base), assumptions) @staticmethod def Rational(expr, assumptions): return expr.q != 0 Float, GoldenRatio, TribonacciConstant, ImaginaryUnit, AlgebraicNumber = \ [staticmethod(CommonHandler.AlwaysTrue)]*5 Infinity, NegativeInfinity, ComplexInfinity, Pi, Exp1 = \ [staticmethod(CommonHandler.AlwaysFalse)]*5 @staticmethod def exp(expr, assumptions): x = expr.args[0] if ask(Q.algebraic(x), assumptions): return ask(~Q.nonzero(x), assumptions) @staticmethod def cot(expr, assumptions): x = expr.args[0] if ask(Q.algebraic(x), assumptions): return False @staticmethod def log(expr, assumptions): x = expr.args[0] if ask(Q.algebraic(x), assumptions): return ask(~Q.nonzero(x - 1), assumptions) sin, cos, tan, asin, atan = [exp]*5 acos, acot = log, cot
0dc387c780cb5191fc8d59bd647f75d0da5436cf7ccf40ea4ae35cedea794be1
from sympy.assumptions.satask import satask from sympy import symbols, Q, assuming, Implies, MatrixSymbol, I, pi, Rational from sympy.utilities.pytest import raises, XFAIL, slow x, y, z = symbols('x y z') def test_satask(): # No relevant facts assert satask(Q.real(x), Q.real(x)) is True assert satask(Q.real(x), ~Q.real(x)) is False assert satask(Q.real(x)) is None assert satask(Q.real(x), Q.positive(x)) is True assert satask(Q.positive(x), Q.real(x)) is None assert satask(Q.real(x), ~Q.positive(x)) is None assert satask(Q.positive(x), ~Q.real(x)) is False raises(ValueError, lambda: satask(Q.real(x), Q.real(x) & ~Q.real(x))) with assuming(Q.positive(x)): assert satask(Q.real(x)) is True assert satask(~Q.positive(x)) is False raises(ValueError, lambda: satask(Q.real(x), ~Q.positive(x))) assert satask(Q.zero(x), Q.nonzero(x)) is False assert satask(Q.positive(x), Q.zero(x)) is False assert satask(Q.real(x), Q.zero(x)) is True assert satask(Q.zero(x), Q.zero(x*y)) is None assert satask(Q.zero(x*y), Q.zero(x)) def test_zero(): """ Everything in this test doesn't work with the ask handlers, and most things would be very difficult or impossible to make work under that model. """ assert satask(Q.zero(x) | Q.zero(y), Q.zero(x*y)) is True assert satask(Q.zero(x*y), Q.zero(x) | Q.zero(y)) is True assert satask(Implies(Q.zero(x), Q.zero(x*y))) is True # This one in particular requires computing the fixed-point of the # relevant facts, because going from Q.nonzero(x*y) -> ~Q.zero(x*y) and # Q.zero(x*y) -> Equivalent(Q.zero(x*y), Q.zero(x) | Q.zero(y)) takes two # steps. assert satask(Q.zero(x) | Q.zero(y), Q.nonzero(x*y)) is False assert satask(Q.zero(x), Q.zero(x**2)) is True def test_zero_positive(): assert satask(Q.zero(x + y), Q.positive(x) & Q.positive(y)) is False assert satask(Q.positive(x) & Q.positive(y), Q.zero(x + y)) is False assert satask(Q.nonzero(x + y), Q.positive(x) & Q.positive(y)) is True assert satask(Q.positive(x) & Q.positive(y), Q.nonzero(x + y)) is None # This one requires several levels of forward chaining assert satask(Q.zero(x*(x + y)), Q.positive(x) & Q.positive(y)) is False assert satask(Q.positive(pi*x*y + 1), Q.positive(x) & Q.positive(y)) is True assert satask(Q.positive(pi*x*y - 5), Q.positive(x) & Q.positive(y)) is None def test_zero_pow(): assert satask(Q.zero(x**y), Q.zero(x) & Q.positive(y)) is True assert satask(Q.zero(x**y), Q.nonzero(x) & Q.zero(y)) is False assert satask(Q.zero(x), Q.zero(x**y)) is True assert satask(Q.zero(x**y), Q.zero(x)) is None @XFAIL # Requires correct Q.square calculation first def test_invertible(): A = MatrixSymbol('A', 5, 5) B = MatrixSymbol('B', 5, 5) assert satask(Q.invertible(A*B), Q.invertible(A) & Q.invertible(B)) is True assert satask(Q.invertible(A), Q.invertible(A*B)) is True assert satask(Q.invertible(A) & Q.invertible(B), Q.invertible(A*B)) is True def test_prime(): assert satask(Q.prime(5)) is True assert satask(Q.prime(6)) is False assert satask(Q.prime(-5)) is False assert satask(Q.prime(x*y), Q.integer(x) & Q.integer(y)) is None assert satask(Q.prime(x*y), Q.prime(x) & Q.prime(y)) is False def test_old_assump(): assert satask(Q.positive(1)) is True assert satask(Q.positive(-1)) is False assert satask(Q.positive(0)) is False assert satask(Q.positive(I)) is False assert satask(Q.positive(pi)) is True assert satask(Q.negative(1)) is False assert satask(Q.negative(-1)) is True assert satask(Q.negative(0)) is False assert satask(Q.negative(I)) is False assert satask(Q.negative(pi)) is False assert satask(Q.zero(1)) is False assert satask(Q.zero(-1)) is False assert satask(Q.zero(0)) is True assert satask(Q.zero(I)) is False assert satask(Q.zero(pi)) is False assert satask(Q.nonzero(1)) is True assert satask(Q.nonzero(-1)) is True assert satask(Q.nonzero(0)) is False assert satask(Q.nonzero(I)) is False assert satask(Q.nonzero(pi)) is True assert satask(Q.nonpositive(1)) is False assert satask(Q.nonpositive(-1)) is True assert satask(Q.nonpositive(0)) is True assert satask(Q.nonpositive(I)) is False assert satask(Q.nonpositive(pi)) is False assert satask(Q.nonnegative(1)) is True assert satask(Q.nonnegative(-1)) is False assert satask(Q.nonnegative(0)) is True assert satask(Q.nonnegative(I)) is False assert satask(Q.nonnegative(pi)) is True def test_rational_irrational(): assert satask(Q.irrational(2)) is False assert satask(Q.rational(2)) is True assert satask(Q.irrational(pi)) is True assert satask(Q.rational(pi)) is False assert satask(Q.irrational(I)) is False assert satask(Q.rational(I)) is False assert satask(Q.irrational(x*y*z), Q.irrational(x) & Q.irrational(y) & Q.rational(z)) is None assert satask(Q.irrational(x*y*z), Q.irrational(x) & Q.rational(y) & Q.rational(z)) is True assert satask(Q.irrational(pi*x*y), Q.rational(x) & Q.rational(y)) is True assert satask(Q.irrational(x + y + z), Q.irrational(x) & Q.irrational(y) & Q.rational(z)) is None assert satask(Q.irrational(x + y + z), Q.irrational(x) & Q.rational(y) & Q.rational(z)) is True assert satask(Q.irrational(pi + x + y), Q.rational(x) & Q.rational(y)) is True assert satask(Q.irrational(x*y*z), Q.rational(x) & Q.rational(y) & Q.rational(z)) is False assert satask(Q.rational(x*y*z), Q.rational(x) & Q.rational(y) & Q.rational(z)) is True assert satask(Q.irrational(x + y + z), Q.rational(x) & Q.rational(y) & Q.rational(z)) is False assert satask(Q.rational(x + y + z), Q.rational(x) & Q.rational(y) & Q.rational(z)) is True def test_even_satask(): assert satask(Q.even(2)) is True assert satask(Q.even(3)) is False assert satask(Q.even(x*y), Q.even(x) & Q.odd(y)) is True assert satask(Q.even(x*y), Q.even(x) & Q.integer(y)) is True assert satask(Q.even(x*y), Q.even(x) & Q.even(y)) is True assert satask(Q.even(x*y), Q.odd(x) & Q.odd(y)) is False assert satask(Q.even(x*y), Q.even(x)) is None assert satask(Q.even(x*y), Q.odd(x) & Q.integer(y)) is None assert satask(Q.even(x*y), Q.odd(x) & Q.odd(y)) is False assert satask(Q.even(abs(x)), Q.even(x)) is True assert satask(Q.even(abs(x)), Q.odd(x)) is False assert satask(Q.even(x), Q.even(abs(x))) is None # x could be complex def test_odd_satask(): assert satask(Q.odd(2)) is False assert satask(Q.odd(3)) is True assert satask(Q.odd(x*y), Q.even(x) & Q.odd(y)) is False assert satask(Q.odd(x*y), Q.even(x) & Q.integer(y)) is False assert satask(Q.odd(x*y), Q.even(x) & Q.even(y)) is False assert satask(Q.odd(x*y), Q.odd(x) & Q.odd(y)) is True assert satask(Q.odd(x*y), Q.even(x)) is None assert satask(Q.odd(x*y), Q.odd(x) & Q.integer(y)) is None assert satask(Q.odd(x*y), Q.odd(x) & Q.odd(y)) is True assert satask(Q.odd(abs(x)), Q.even(x)) is False assert satask(Q.odd(abs(x)), Q.odd(x)) is True assert satask(Q.odd(x), Q.odd(abs(x))) is None # x could be complex def test_integer(): assert satask(Q.integer(1)) is True assert satask(Q.integer(Rational(1, 2))) is False assert satask(Q.integer(x + y), Q.integer(x) & Q.integer(y)) is True assert satask(Q.integer(x + y), Q.integer(x)) is None assert satask(Q.integer(x + y), Q.integer(x) & ~Q.integer(y)) is False assert satask(Q.integer(x + y + z), Q.integer(x) & Q.integer(y) & ~Q.integer(z)) is False assert satask(Q.integer(x + y + z), Q.integer(x) & ~Q.integer(y) & ~Q.integer(z)) is None assert satask(Q.integer(x + y + z), Q.integer(x) & ~Q.integer(y)) is None assert satask(Q.integer(x + y), Q.integer(x) & Q.irrational(y)) is False assert satask(Q.integer(x*y), Q.integer(x) & Q.integer(y)) is True assert satask(Q.integer(x*y), Q.integer(x)) is None assert satask(Q.integer(x*y), Q.integer(x) & ~Q.integer(y)) is None assert satask(Q.integer(x*y), Q.integer(x) & ~Q.rational(y)) is False assert satask(Q.integer(x*y*z), Q.integer(x) & Q.integer(y) & ~Q.rational(z)) is False assert satask(Q.integer(x*y*z), Q.integer(x) & ~Q.rational(y) & ~Q.rational(z)) is None assert satask(Q.integer(x*y*z), Q.integer(x) & ~Q.rational(y)) is None assert satask(Q.integer(x*y), Q.integer(x) & Q.irrational(y)) is False def test_abs(): assert satask(Q.nonnegative(abs(x))) is True assert satask(Q.positive(abs(x)), ~Q.zero(x)) is True assert satask(Q.zero(x), ~Q.zero(abs(x))) is False assert satask(Q.zero(x), Q.zero(abs(x))) is True assert satask(Q.nonzero(x), ~Q.zero(abs(x))) is None # x could be complex assert satask(Q.zero(abs(x)), Q.zero(x)) is True def test_imaginary(): assert satask(Q.imaginary(2*I)) is True assert satask(Q.imaginary(x*y), Q.imaginary(x)) is None assert satask(Q.imaginary(x*y), Q.imaginary(x) & Q.real(y)) is True assert satask(Q.imaginary(x), Q.real(x)) is False assert satask(Q.imaginary(1)) is False assert satask(Q.imaginary(x*y), Q.real(x) & Q.real(y)) is False assert satask(Q.imaginary(x + y), Q.real(x) & Q.real(y)) is False def test_real(): assert satask(Q.real(x*y), Q.real(x) & Q.real(y)) is True assert satask(Q.real(x + y), Q.real(x) & Q.real(y)) is True assert satask(Q.real(x*y*z), Q.real(x) & Q.real(y) & Q.real(z)) is True assert satask(Q.real(x*y*z), Q.real(x) & Q.real(y)) is None assert satask(Q.real(x*y*z), Q.real(x) & Q.real(y) & Q.imaginary(z)) is False assert satask(Q.real(x + y + z), Q.real(x) & Q.real(y) & Q.real(z)) is True assert satask(Q.real(x + y + z), Q.real(x) & Q.real(y)) is None def test_pos_neg(): assert satask(~Q.positive(x), Q.negative(x)) is True assert satask(~Q.negative(x), Q.positive(x)) is True assert satask(Q.positive(x + y), Q.positive(x) & Q.positive(y)) is True assert satask(Q.negative(x + y), Q.negative(x) & Q.negative(y)) is True assert satask(Q.positive(x + y), Q.negative(x) & Q.negative(y)) is False assert satask(Q.negative(x + y), Q.positive(x) & Q.positive(y)) is False @slow def test_pow_pos_neg(): assert satask(Q.nonnegative(x**2), Q.positive(x)) is True assert satask(Q.nonpositive(x**2), Q.positive(x)) is False assert satask(Q.positive(x**2), Q.positive(x)) is True assert satask(Q.negative(x**2), Q.positive(x)) is False assert satask(Q.real(x**2), Q.positive(x)) is True assert satask(Q.nonnegative(x**2), Q.negative(x)) is True assert satask(Q.nonpositive(x**2), Q.negative(x)) is False assert satask(Q.positive(x**2), Q.negative(x)) is True assert satask(Q.negative(x**2), Q.negative(x)) is False assert satask(Q.real(x**2), Q.negative(x)) is True assert satask(Q.nonnegative(x**2), Q.nonnegative(x)) is True assert satask(Q.nonpositive(x**2), Q.nonnegative(x)) is None assert satask(Q.positive(x**2), Q.nonnegative(x)) is None assert satask(Q.negative(x**2), Q.nonnegative(x)) is False assert satask(Q.real(x**2), Q.nonnegative(x)) is True assert satask(Q.nonnegative(x**2), Q.nonpositive(x)) is True assert satask(Q.nonpositive(x**2), Q.nonpositive(x)) is None assert satask(Q.positive(x**2), Q.nonpositive(x)) is None assert satask(Q.negative(x**2), Q.nonpositive(x)) is False assert satask(Q.real(x**2), Q.nonpositive(x)) is True assert satask(Q.nonnegative(x**3), Q.positive(x)) is True assert satask(Q.nonpositive(x**3), Q.positive(x)) is False assert satask(Q.positive(x**3), Q.positive(x)) is True assert satask(Q.negative(x**3), Q.positive(x)) is False assert satask(Q.real(x**3), Q.positive(x)) is True assert satask(Q.nonnegative(x**3), Q.negative(x)) is False assert satask(Q.nonpositive(x**3), Q.negative(x)) is True assert satask(Q.positive(x**3), Q.negative(x)) is False assert satask(Q.negative(x**3), Q.negative(x)) is True assert satask(Q.real(x**3), Q.negative(x)) is True assert satask(Q.nonnegative(x**3), Q.nonnegative(x)) is True assert satask(Q.nonpositive(x**3), Q.nonnegative(x)) is None assert satask(Q.positive(x**3), Q.nonnegative(x)) is None assert satask(Q.negative(x**3), Q.nonnegative(x)) is False assert satask(Q.real(x**3), Q.nonnegative(x)) is True assert satask(Q.nonnegative(x**3), Q.nonpositive(x)) is None assert satask(Q.nonpositive(x**3), Q.nonpositive(x)) is True assert satask(Q.positive(x**3), Q.nonpositive(x)) is False assert satask(Q.negative(x**3), Q.nonpositive(x)) is None assert satask(Q.real(x**3), Q.nonpositive(x)) is True # If x is zero, x**negative is not real. assert satask(Q.nonnegative(x**-2), Q.nonpositive(x)) is None assert satask(Q.nonpositive(x**-2), Q.nonpositive(x)) is None assert satask(Q.positive(x**-2), Q.nonpositive(x)) is None assert satask(Q.negative(x**-2), Q.nonpositive(x)) is None assert satask(Q.real(x**-2), Q.nonpositive(x)) is None # We could deduce things for negative powers if x is nonzero, but it # isn't implemented yet.
97cacfb0b168e559fdea6e711e3b6a4324c4cfae22a36f675c1f8d323054cd93
from sympy import Q, ask, Symbol, DiagonalizeVector, DiagonalMatrix from sympy.matrices.expressions import (MatrixSymbol, Identity, ZeroMatrix, Trace, MatrixSlice, Determinant) from sympy.matrices.expressions.factorizations import LofLU from sympy.utilities.pytest import XFAIL X = MatrixSymbol('X', 2, 2) Y = MatrixSymbol('Y', 2, 3) Z = MatrixSymbol('Z', 2, 2) A1x1 = MatrixSymbol('A1x1', 1, 1) B1x1 = MatrixSymbol('B1x1', 1, 1) C0x0 = MatrixSymbol('C0x0', 0, 0) V1 = MatrixSymbol('V1', 2, 1) V2 = MatrixSymbol('V2', 2, 1) def test_square(): assert ask(Q.square(X)) assert not ask(Q.square(Y)) assert ask(Q.square(Y*Y.T)) def test_invertible(): assert ask(Q.invertible(X), Q.invertible(X)) assert ask(Q.invertible(Y)) is False assert ask(Q.invertible(X*Y), Q.invertible(X)) is False assert ask(Q.invertible(X*Z), Q.invertible(X)) is None assert ask(Q.invertible(X*Z), Q.invertible(X) & Q.invertible(Z)) is True assert ask(Q.invertible(X.T)) is None assert ask(Q.invertible(X.T), Q.invertible(X)) is True assert ask(Q.invertible(X.I)) is True assert ask(Q.invertible(Identity(3))) is True assert ask(Q.invertible(ZeroMatrix(3, 3))) is False assert ask(Q.invertible(X), Q.fullrank(X) & Q.square(X)) def test_singular(): assert ask(Q.singular(X)) is None assert ask(Q.singular(X), Q.invertible(X)) is False assert ask(Q.singular(X), ~Q.invertible(X)) is True @XFAIL def test_invertible_fullrank(): assert ask(Q.invertible(X), Q.fullrank(X)) is True def test_symmetric(): assert ask(Q.symmetric(X), Q.symmetric(X)) assert ask(Q.symmetric(X*Z), Q.symmetric(X)) is None assert ask(Q.symmetric(X*Z), Q.symmetric(X) & Q.symmetric(Z)) is True assert ask(Q.symmetric(X + Z), Q.symmetric(X) & Q.symmetric(Z)) is True assert ask(Q.symmetric(Y)) is False assert ask(Q.symmetric(Y*Y.T)) is True assert ask(Q.symmetric(Y.T*X*Y)) is None assert ask(Q.symmetric(Y.T*X*Y), Q.symmetric(X)) is True assert ask(Q.symmetric(X**10), Q.symmetric(X)) is True assert ask(Q.symmetric(A1x1)) is True assert ask(Q.symmetric(A1x1 + B1x1)) is True assert ask(Q.symmetric(A1x1 * B1x1)) is True assert ask(Q.symmetric(V1.T*V1)) is True assert ask(Q.symmetric(V1.T*(V1 + V2))) is True assert ask(Q.symmetric(V1.T*(V1 + V2) + A1x1)) is True assert ask(Q.symmetric(MatrixSlice(Y, (0, 1), (1, 2)))) is True def _test_orthogonal_unitary(predicate): assert ask(predicate(X), predicate(X)) assert ask(predicate(X.T), predicate(X)) is True assert ask(predicate(X.I), predicate(X)) is True assert ask(predicate(X**2), predicate(X)) assert ask(predicate(Y)) is False assert ask(predicate(X)) is None assert ask(predicate(X), ~Q.invertible(X)) is False assert ask(predicate(X*Z*X), predicate(X) & predicate(Z)) is True assert ask(predicate(Identity(3))) is True assert ask(predicate(ZeroMatrix(3, 3))) is False assert ask(Q.invertible(X), predicate(X)) assert not ask(predicate(X + Z), predicate(X) & predicate(Z)) def test_orthogonal(): _test_orthogonal_unitary(Q.orthogonal) def test_unitary(): _test_orthogonal_unitary(Q.unitary) assert ask(Q.unitary(X), Q.orthogonal(X)) def test_fullrank(): assert ask(Q.fullrank(X), Q.fullrank(X)) assert ask(Q.fullrank(X**2), Q.fullrank(X)) assert ask(Q.fullrank(X.T), Q.fullrank(X)) is True assert ask(Q.fullrank(X)) is None assert ask(Q.fullrank(Y)) is None assert ask(Q.fullrank(X*Z), Q.fullrank(X) & Q.fullrank(Z)) is True assert ask(Q.fullrank(Identity(3))) is True assert ask(Q.fullrank(ZeroMatrix(3, 3))) is False assert ask(Q.invertible(X), ~Q.fullrank(X)) == False def test_positive_definite(): assert ask(Q.positive_definite(X), Q.positive_definite(X)) assert ask(Q.positive_definite(X.T), Q.positive_definite(X)) is True assert ask(Q.positive_definite(X.I), Q.positive_definite(X)) is True assert ask(Q.positive_definite(Y)) is False assert ask(Q.positive_definite(X)) is None assert ask(Q.positive_definite(X**3), Q.positive_definite(X)) assert ask(Q.positive_definite(X*Z*X), Q.positive_definite(X) & Q.positive_definite(Z)) is True assert ask(Q.positive_definite(X), Q.orthogonal(X)) assert ask(Q.positive_definite(Y.T*X*Y), Q.positive_definite(X) & Q.fullrank(Y)) is True assert not ask(Q.positive_definite(Y.T*X*Y), Q.positive_definite(X)) assert ask(Q.positive_definite(Identity(3))) is True assert ask(Q.positive_definite(ZeroMatrix(3, 3))) is False assert ask(Q.positive_definite(X + Z), Q.positive_definite(X) & Q.positive_definite(Z)) is True assert not ask(Q.positive_definite(-X), Q.positive_definite(X)) assert ask(Q.positive(X[1, 1]), Q.positive_definite(X)) def test_triangular(): assert ask(Q.upper_triangular(X + Z.T + Identity(2)), Q.upper_triangular(X) & Q.lower_triangular(Z)) is True assert ask(Q.upper_triangular(X*Z.T), Q.upper_triangular(X) & Q.lower_triangular(Z)) is True assert ask(Q.lower_triangular(Identity(3))) is True assert ask(Q.lower_triangular(ZeroMatrix(3, 3))) is True assert ask(Q.triangular(X), Q.unit_triangular(X)) assert ask(Q.upper_triangular(X**3), Q.upper_triangular(X)) assert ask(Q.lower_triangular(X**3), Q.lower_triangular(X)) def test_diagonal(): assert ask(Q.diagonal(X + Z.T + Identity(2)), Q.diagonal(X) & Q.diagonal(Z)) is True assert ask(Q.diagonal(ZeroMatrix(3, 3))) assert ask(Q.lower_triangular(X) & Q.upper_triangular(X), Q.diagonal(X)) assert ask(Q.diagonal(X), Q.lower_triangular(X) & Q.upper_triangular(X)) assert ask(Q.symmetric(X), Q.diagonal(X)) assert ask(Q.triangular(X), Q.diagonal(X)) assert ask(Q.diagonal(C0x0)) assert ask(Q.diagonal(A1x1)) assert ask(Q.diagonal(A1x1 + B1x1)) assert ask(Q.diagonal(A1x1*B1x1)) assert ask(Q.diagonal(V1.T*V2)) assert ask(Q.diagonal(V1.T*(X + Z)*V1)) assert ask(Q.diagonal(MatrixSlice(Y, (0, 1), (1, 2)))) is True assert ask(Q.diagonal(V1.T*(V1 + V2))) is True assert ask(Q.diagonal(X**3), Q.diagonal(X)) assert ask(Q.diagonal(Identity(3))) assert ask(Q.diagonal(DiagonalizeVector(V1))) assert ask(Q.diagonal(DiagonalMatrix(X))) def test_non_atoms(): assert ask(Q.real(Trace(X)), Q.positive(Trace(X))) @XFAIL def test_non_trivial_implies(): X = MatrixSymbol('X', 3, 3) Y = MatrixSymbol('Y', 3, 3) assert ask(Q.lower_triangular(X+Y), Q.lower_triangular(X) & Q.lower_triangular(Y)) is True assert ask(Q.triangular(X), Q.lower_triangular(X)) is True assert ask(Q.triangular(X+Y), Q.lower_triangular(X) & Q.lower_triangular(Y)) is True def test_MatrixSlice(): X = MatrixSymbol('X', 4, 4) B = MatrixSlice(X, (1, 3), (1, 3)) C = MatrixSlice(X, (0, 3), (1, 3)) assert ask(Q.symmetric(B), Q.symmetric(X)) assert ask(Q.invertible(B), Q.invertible(X)) assert ask(Q.diagonal(B), Q.diagonal(X)) assert ask(Q.orthogonal(B), Q.orthogonal(X)) assert ask(Q.upper_triangular(B), Q.upper_triangular(X)) assert not ask(Q.symmetric(C), Q.symmetric(X)) assert not ask(Q.invertible(C), Q.invertible(X)) assert not ask(Q.diagonal(C), Q.diagonal(X)) assert not ask(Q.orthogonal(C), Q.orthogonal(X)) assert not ask(Q.upper_triangular(C), Q.upper_triangular(X)) def test_det_trace_positive(): X = MatrixSymbol('X', 4, 4) assert ask(Q.positive(Trace(X)), Q.positive_definite(X)) assert ask(Q.positive(Determinant(X)), Q.positive_definite(X)) def test_field_assumptions(): X = MatrixSymbol('X', 4, 4) Y = MatrixSymbol('Y', 4, 4) assert ask(Q.real_elements(X), Q.real_elements(X)) assert not ask(Q.integer_elements(X), Q.real_elements(X)) assert ask(Q.complex_elements(X), Q.real_elements(X)) assert ask(Q.complex_elements(X**2), Q.real_elements(X)) assert ask(Q.real_elements(X**2), Q.integer_elements(X)) assert ask(Q.real_elements(X+Y), Q.real_elements(X)) is None assert ask(Q.real_elements(X+Y), Q.real_elements(X) & Q.real_elements(Y)) from sympy.matrices.expressions.hadamard import HadamardProduct assert ask(Q.real_elements(HadamardProduct(X, Y)), Q.real_elements(X) & Q.real_elements(Y)) assert ask(Q.complex_elements(X+Y), Q.real_elements(X) & Q.complex_elements(Y)) assert ask(Q.real_elements(X.T), Q.real_elements(X)) assert ask(Q.real_elements(X.I), Q.real_elements(X) & Q.invertible(X)) assert ask(Q.real_elements(Trace(X)), Q.real_elements(X)) assert ask(Q.integer_elements(Determinant(X)), Q.integer_elements(X)) assert not ask(Q.integer_elements(X.I), Q.integer_elements(X)) alpha = Symbol('alpha') assert ask(Q.real_elements(alpha*X), Q.real_elements(X) & Q.real(alpha)) assert ask(Q.real_elements(LofLU(X)), Q.real_elements(X)) e = Symbol('e', integer=True, negative=True) assert ask(Q.real_elements(X**e), Q.real_elements(X) & Q.invertible(X)) assert ask(Q.real_elements(X**e), Q.real_elements(X)) is None def test_matrix_element_sets(): X = MatrixSymbol('X', 4, 4) assert ask(Q.real(X[1, 2]), Q.real_elements(X)) assert ask(Q.integer(X[1, 2]), Q.integer_elements(X)) assert ask(Q.complex(X[1, 2]), Q.complex_elements(X)) assert ask(Q.integer_elements(Identity(3))) assert ask(Q.integer_elements(ZeroMatrix(3, 3))) from sympy.matrices.expressions.fourier import DFT assert ask(Q.complex_elements(DFT(3))) def test_matrix_element_sets_slices_blocks(): from sympy.matrices.expressions import BlockMatrix X = MatrixSymbol('X', 4, 4) assert ask(Q.integer_elements(X[:, 3]), Q.integer_elements(X)) assert ask(Q.integer_elements(BlockMatrix([[X], [X]])), Q.integer_elements(X)) def test_matrix_element_sets_determinant_trace(): assert ask(Q.integer(Determinant(X)), Q.integer_elements(X)) assert ask(Q.integer(Trace(X)), Q.integer_elements(X))
fadb4128e7b348b7c5390743bc9238814e389e247b43cde6e5715725b060b2f6
""" This module implements some special functions that commonly appear in combinatorial contexts (e.g. in power series); in particular, sequences of rational numbers such as Bernoulli and Fibonacci numbers. Factorials, binomial coefficients and related functions are located in the separate 'factorials' module. """ from __future__ import print_function, division from sympy.core import S, Symbol, Rational, Integer, Add, Dummy from sympy.core.cache import cacheit from sympy.core.compatibility import as_int, SYMPY_INTS, range from sympy.core.function import Function, expand_mul from sympy.core.logic import fuzzy_not from sympy.core.numbers import E, pi from sympy.core.relational import LessThan, StrictGreaterThan from sympy.functions.combinatorial.factorials import binomial, factorial from sympy.functions.elementary.exponential import log from sympy.functions.elementary.integers import floor from sympy.functions.elementary.miscellaneous import sqrt, cbrt from sympy.functions.elementary.trigonometric import sin, cos, cot from sympy.ntheory import isprime from sympy.ntheory.primetest import is_square from sympy.utilities.memoization import recurrence_memo from mpmath import bernfrac, workprec from mpmath.libmp import ifib as _ifib def _product(a, b): p = 1 for k in range(a, b + 1): p *= k return p # Dummy symbol used for computing polynomial sequences _sym = Symbol('x') #----------------------------------------------------------------------------# # # # Carmichael numbers # # # #----------------------------------------------------------------------------# class carmichael(Function): """ Carmichael Numbers: Certain cryptographic algorithms make use of big prime numbers. However, checking whether a big number is prime is not so easy. Randomized prime number checking tests exist that offer a high degree of confidence of accurate determination at low cost, such as the Fermat test. Let 'a' be a random number between 2 and n - 1, where n is the number whose primality we are testing. Then, n is probably prime if it satisfies the modular arithmetic congruence relation : a^(n-1) = 1(mod n). (where mod refers to the modulo operation) If a number passes the Fermat test several times, then it is prime with a high probability. Unfortunately, certain composite numbers (non-primes) still pass the Fermat test with every number smaller than themselves. These numbers are called Carmichael numbers. A Carmichael number will pass a Fermat primality test to every base b relatively prime to the number, even though it is not actually prime. This makes tests based on Fermat's Little Theorem less effective than strong probable prime tests such as the Baillie-PSW primality test and the Miller-Rabin primality test. mr functions given in sympy/sympy/ntheory/primetest.py will produce wrong results for each and every carmichael number. Examples ======== >>> from sympy import carmichael >>> carmichael.find_first_n_carmichaels(5) [561, 1105, 1729, 2465, 2821] >>> carmichael.is_prime(2465) False >>> carmichael.is_prime(1729) False >>> carmichael.find_carmichael_numbers_in_range(0, 562) [561] >>> carmichael.find_carmichael_numbers_in_range(0,1000) [561] >>> carmichael.find_carmichael_numbers_in_range(0,2000) [561, 1105, 1729] References ========== .. [1] https://en.wikipedia.org/wiki/Carmichael_number .. [2] https://en.wikipedia.org/wiki/Fermat_primality_test .. [3] https://www.jstor.org/stable/23248683?seq=1#metadata_info_tab_contents """ @staticmethod def is_perfect_square(n): return is_square(n) @staticmethod def divides(p, n): return n % p == 0 @staticmethod def is_prime(n): return isprime(n) @staticmethod def is_carmichael(n): if n >= 0: if (n == 1) or (carmichael.is_prime(n)) or (n % 2 == 0): return False divisors = list([1, n]) # get divisors for i in range(3, n // 2 + 1, 2): if n % i == 0: divisors.append(i) for i in divisors: if carmichael.is_perfect_square(i) and i != 1: return False if carmichael.is_prime(i): if not carmichael.divides(i - 1, n - 1): return False return True else: raise ValueError('The provided number must be greater than or equal to 0') @staticmethod def find_carmichael_numbers_in_range(x, y): if 0 <= x <= y: if x % 2 == 0: return list([i for i in range(x + 1, y, 2) if carmichael.is_carmichael(i)]) else: return list([i for i in range(x, y, 2) if carmichael.is_carmichael(i)]) else: raise ValueError('The provided range is not valid. x and y must be non-negative integers and x <= y') @staticmethod def find_first_n_carmichaels(n): i = 1 carmichaels = list() while len(carmichaels) < n: if carmichael.is_carmichael(i): carmichaels.append(i) i += 2 return carmichaels #----------------------------------------------------------------------------# # # # Fibonacci numbers # # # #----------------------------------------------------------------------------# class fibonacci(Function): r""" Fibonacci numbers / Fibonacci polynomials The Fibonacci numbers are the integer sequence defined by the initial terms `F_0 = 0`, `F_1 = 1` and the two-term recurrence relation `F_n = F_{n-1} + F_{n-2}`. This definition extended to arbitrary real and complex arguments using the formula .. math :: F_z = \frac{\phi^z - \cos(\pi z) \phi^{-z}}{\sqrt 5} The Fibonacci polynomials are defined by `F_1(x) = 1`, `F_2(x) = x`, and `F_n(x) = x*F_{n-1}(x) + F_{n-2}(x)` for `n > 2`. For all positive integers `n`, `F_n(1) = F_n`. * ``fibonacci(n)`` gives the `n^{th}` Fibonacci number, `F_n` * ``fibonacci(n, x)`` gives the `n^{th}` Fibonacci polynomial in `x`, `F_n(x)` Examples ======== >>> from sympy import fibonacci, Symbol >>> [fibonacci(x) for x in range(11)] [0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55] >>> fibonacci(5, Symbol('t')) t**4 + 3*t**2 + 1 See Also ======== bell, bernoulli, catalan, euler, harmonic, lucas, genocchi, partition, tribonacci References ========== .. [1] https://en.wikipedia.org/wiki/Fibonacci_number .. [2] http://mathworld.wolfram.com/FibonacciNumber.html """ @staticmethod def _fib(n): return _ifib(n) @staticmethod @recurrence_memo([None, S.One, _sym]) def _fibpoly(n, prev): return (prev[-2] + _sym*prev[-1]).expand() @classmethod def eval(cls, n, sym=None): if n is S.Infinity: return S.Infinity if n.is_Integer: n = int(n) if n < 0: return S.NegativeOne**(n + 1) * fibonacci(-n) if sym is None: return Integer(cls._fib(n)) else: if n < 1: raise ValueError("Fibonacci polynomials are defined " "only for positive integer indices.") return cls._fibpoly(n).subs(_sym, sym) def _eval_rewrite_as_sqrt(self, n, **kwargs): return 2**(-n)*sqrt(5)*((1 + sqrt(5))**n - (-sqrt(5) + 1)**n) / 5 def _eval_rewrite_as_GoldenRatio(self,n, **kwargs): return (S.GoldenRatio**n - 1/(-S.GoldenRatio)**n)/(2*S.GoldenRatio-1) #----------------------------------------------------------------------------# # # # Lucas numbers # # # #----------------------------------------------------------------------------# class lucas(Function): """ Lucas numbers Lucas numbers satisfy a recurrence relation similar to that of the Fibonacci sequence, in which each term is the sum of the preceding two. They are generated by choosing the initial values `L_0 = 2` and `L_1 = 1`. * ``lucas(n)`` gives the `n^{th}` Lucas number Examples ======== >>> from sympy import lucas >>> [lucas(x) for x in range(11)] [2, 1, 3, 4, 7, 11, 18, 29, 47, 76, 123] See Also ======== bell, bernoulli, catalan, euler, fibonacci, harmonic, genocchi, partition, tribonacci References ========== .. [1] https://en.wikipedia.org/wiki/Lucas_number .. [2] http://mathworld.wolfram.com/LucasNumber.html """ @classmethod def eval(cls, n): if n is S.Infinity: return S.Infinity if n.is_Integer: return fibonacci(n + 1) + fibonacci(n - 1) def _eval_rewrite_as_sqrt(self, n, **kwargs): return 2**(-n)*((1 + sqrt(5))**n + (-sqrt(5) + 1)**n) #----------------------------------------------------------------------------# # # # Tribonacci numbers # # # #----------------------------------------------------------------------------# class tribonacci(Function): r""" Tribonacci numbers / Tribonacci polynomials The Tribonacci numbers are the integer sequence defined by the initial terms `T_0 = 0`, `T_1 = 1`, `T_2 = 1` and the three-term recurrence relation `T_n = T_{n-1} + T_{n-2} + T_{n-3}`. The Tribonacci polynomials are defined by `T_0(x) = 0`, `T_1(x) = 1`, `T_2(x) = x^2`, and `T_n(x) = x^2 T_{n-1}(x) + x T_{n-2}(x) + T_{n-3}(x)` for `n > 2`. For all positive integers `n`, `T_n(1) = T_n`. * ``tribonacci(n)`` gives the `n^{th}` Tribonacci number, `T_n` * ``tribonacci(n, x)`` gives the `n^{th}` Tribonacci polynomial in `x`, `T_n(x)` Examples ======== >>> from sympy import tribonacci, Symbol >>> [tribonacci(x) for x in range(11)] [0, 1, 1, 2, 4, 7, 13, 24, 44, 81, 149] >>> tribonacci(5, Symbol('t')) t**8 + 3*t**5 + 3*t**2 See Also ======== bell, bernoulli, catalan, euler, fibonacci, harmonic, lucas, genocchi, partition References ========== .. [1] https://en.wikipedia.org/wiki/Generalizations_of_Fibonacci_numbers#Tribonacci_numbers .. [2] http://mathworld.wolfram.com/TribonacciNumber.html .. [3] https://oeis.org/A000073 """ @staticmethod @recurrence_memo([S.Zero, S.One, S.One]) def _trib(n, prev): return (prev[-3] + prev[-2] + prev[-1]) @staticmethod @recurrence_memo([S.Zero, S.One, _sym**2]) def _tribpoly(n, prev): return (prev[-3] + _sym*prev[-2] + _sym**2*prev[-1]).expand() @classmethod def eval(cls, n, sym=None): if n is S.Infinity: return S.Infinity if n.is_Integer: n = int(n) if n < 0: raise ValueError("Tribonacci polynomials are defined " "only for non-negative integer indices.") if sym is None: return Integer(cls._trib(n)) else: return cls._tribpoly(n).subs(_sym, sym) def _eval_rewrite_as_sqrt(self, n, **kwargs): w = (-1 + S.ImaginaryUnit * sqrt(3)) / 2 a = (1 + cbrt(19 + 3*sqrt(33)) + cbrt(19 - 3*sqrt(33))) / 3 b = (1 + w*cbrt(19 + 3*sqrt(33)) + w**2*cbrt(19 - 3*sqrt(33))) / 3 c = (1 + w**2*cbrt(19 + 3*sqrt(33)) + w*cbrt(19 - 3*sqrt(33))) / 3 Tn = (a**(n + 1)/((a - b)*(a - c)) + b**(n + 1)/((b - a)*(b - c)) + c**(n + 1)/((c - a)*(c - b))) return Tn def _eval_rewrite_as_TribonacciConstant(self, n, **kwargs): b = cbrt(586 + 102*sqrt(33)) Tn = 3 * b * S.TribonacciConstant**n / (b**2 - 2*b + 4) return floor(Tn + S.Half) #----------------------------------------------------------------------------# # # # Bernoulli numbers # # # #----------------------------------------------------------------------------# class bernoulli(Function): r""" Bernoulli numbers / Bernoulli polynomials The Bernoulli numbers are a sequence of rational numbers defined by `B_0 = 1` and the recursive relation (`n > 0`): .. math :: 0 = \sum_{k=0}^n \binom{n+1}{k} B_k They are also commonly defined by their exponential generating function, which is `\frac{x}{e^x - 1}`. For odd indices > 1, the Bernoulli numbers are zero. The Bernoulli polynomials satisfy the analogous formula: .. math :: B_n(x) = \sum_{k=0}^n \binom{n}{k} B_k x^{n-k} Bernoulli numbers and Bernoulli polynomials are related as `B_n(0) = B_n`. We compute Bernoulli numbers using Ramanujan's formula: .. math :: B_n = \frac{A(n) - S(n)}{\binom{n+3}{n}} where: .. math :: A(n) = \begin{cases} \frac{n+3}{3} & n \equiv 0\ \text{or}\ 2 \pmod{6} \\ -\frac{n+3}{6} & n \equiv 4 \pmod{6} \end{cases} and: .. math :: S(n) = \sum_{k=1}^{[n/6]} \binom{n+3}{n-6k} B_{n-6k} This formula is similar to the sum given in the definition, but cuts 2/3 of the terms. For Bernoulli polynomials, we use the formula in the definition. * ``bernoulli(n)`` gives the nth Bernoulli number, `B_n` * ``bernoulli(n, x)`` gives the nth Bernoulli polynomial in `x`, `B_n(x)` Examples ======== >>> from sympy import bernoulli >>> [bernoulli(n) for n in range(11)] [1, -1/2, 1/6, 0, -1/30, 0, 1/42, 0, -1/30, 0, 5/66] >>> bernoulli(1000001) 0 See Also ======== bell, catalan, euler, fibonacci, harmonic, lucas, genocchi, partition, tribonacci References ========== .. [1] https://en.wikipedia.org/wiki/Bernoulli_number .. [2] https://en.wikipedia.org/wiki/Bernoulli_polynomial .. [3] http://mathworld.wolfram.com/BernoulliNumber.html .. [4] http://mathworld.wolfram.com/BernoulliPolynomial.html """ # Calculates B_n for positive even n @staticmethod def _calc_bernoulli(n): s = 0 a = int(binomial(n + 3, n - 6)) for j in range(1, n//6 + 1): s += a * bernoulli(n - 6*j) # Avoid computing each binomial coefficient from scratch a *= _product(n - 6 - 6*j + 1, n - 6*j) a //= _product(6*j + 4, 6*j + 9) if n % 6 == 4: s = -Rational(n + 3, 6) - s else: s = Rational(n + 3, 3) - s return s / binomial(n + 3, n) # We implement a specialized memoization scheme to handle each # case modulo 6 separately _cache = {0: S.One, 2: Rational(1, 6), 4: Rational(-1, 30)} _highest = {0: 0, 2: 2, 4: 4} @classmethod def eval(cls, n, sym=None): if n.is_Number: if n.is_Integer and n.is_nonnegative: if n is S.Zero: return S.One elif n is S.One: if sym is None: return -S.Half else: return sym - S.Half # Bernoulli numbers elif sym is None: if n.is_odd: return S.Zero n = int(n) # Use mpmath for enormous Bernoulli numbers if n > 500: p, q = bernfrac(n) return Rational(int(p), int(q)) case = n % 6 highest_cached = cls._highest[case] if n <= highest_cached: return cls._cache[n] # To avoid excessive recursion when, say, bernoulli(1000) is # requested, calculate and cache the entire sequence ... B_988, # B_994, B_1000 in increasing order for i in range(highest_cached + 6, n + 6, 6): b = cls._calc_bernoulli(i) cls._cache[i] = b cls._highest[case] = i return b # Bernoulli polynomials else: n, result = int(n), [] for k in range(n + 1): result.append(binomial(n, k)*cls(k)*sym**(n - k)) return Add(*result) else: raise ValueError("Bernoulli numbers are defined only" " for nonnegative integer indices.") if sym is None: if n.is_odd and (n - 1).is_positive: return S.Zero #----------------------------------------------------------------------------# # # # Bell numbers # # # #----------------------------------------------------------------------------# class bell(Function): r""" Bell numbers / Bell polynomials The Bell numbers satisfy `B_0 = 1` and .. math:: B_n = \sum_{k=0}^{n-1} \binom{n-1}{k} B_k. They are also given by: .. math:: B_n = \frac{1}{e} \sum_{k=0}^{\infty} \frac{k^n}{k!}. The Bell polynomials are given by `B_0(x) = 1` and .. math:: B_n(x) = x \sum_{k=1}^{n-1} \binom{n-1}{k-1} B_{k-1}(x). The second kind of Bell polynomials (are sometimes called "partial" Bell polynomials or incomplete Bell polynomials) are defined as .. math:: B_{n,k}(x_1, x_2,\dotsc x_{n-k+1}) = \sum_{j_1+j_2+j_2+\dotsb=k \atop j_1+2j_2+3j_2+\dotsb=n} \frac{n!}{j_1!j_2!\dotsb j_{n-k+1}!} \left(\frac{x_1}{1!} \right)^{j_1} \left(\frac{x_2}{2!} \right)^{j_2} \dotsb \left(\frac{x_{n-k+1}}{(n-k+1)!} \right) ^{j_{n-k+1}}. * ``bell(n)`` gives the `n^{th}` Bell number, `B_n`. * ``bell(n, x)`` gives the `n^{th}` Bell polynomial, `B_n(x)`. * ``bell(n, k, (x1, x2, ...))`` gives Bell polynomials of the second kind, `B_{n,k}(x_1, x_2, \dotsc, x_{n-k+1})`. Notes ===== Not to be confused with Bernoulli numbers and Bernoulli polynomials, which use the same notation. Examples ======== >>> from sympy import bell, Symbol, symbols >>> [bell(n) for n in range(11)] [1, 1, 2, 5, 15, 52, 203, 877, 4140, 21147, 115975] >>> bell(30) 846749014511809332450147 >>> bell(4, Symbol('t')) t**4 + 6*t**3 + 7*t**2 + t >>> bell(6, 2, symbols('x:6')[1:]) 6*x1*x5 + 15*x2*x4 + 10*x3**2 See Also ======== bernoulli, catalan, euler, fibonacci, harmonic, lucas, genocchi, partition, tribonacci References ========== .. [1] https://en.wikipedia.org/wiki/Bell_number .. [2] http://mathworld.wolfram.com/BellNumber.html .. [3] http://mathworld.wolfram.com/BellPolynomial.html """ @staticmethod @recurrence_memo([1, 1]) def _bell(n, prev): s = 1 a = 1 for k in range(1, n): a = a * (n - k) // k s += a * prev[k] return s @staticmethod @recurrence_memo([S.One, _sym]) def _bell_poly(n, prev): s = 1 a = 1 for k in range(2, n + 1): a = a * (n - k + 1) // (k - 1) s += a * prev[k - 1] return expand_mul(_sym * s) @staticmethod def _bell_incomplete_poly(n, k, symbols): r""" The second kind of Bell polynomials (incomplete Bell polynomials). Calculated by recurrence formula: .. math:: B_{n,k}(x_1, x_2, \dotsc, x_{n-k+1}) = \sum_{m=1}^{n-k+1} \x_m \binom{n-1}{m-1} B_{n-m,k-1}(x_1, x_2, \dotsc, x_{n-m-k}) where `B_{0,0} = 1;` `B_{n,0} = 0; for n \ge 1` `B_{0,k} = 0; for k \ge 1` """ if (n == 0) and (k == 0): return S.One elif (n == 0) or (k == 0): return S.Zero s = S.Zero a = S.One for m in range(1, n - k + 2): s += a * bell._bell_incomplete_poly( n - m, k - 1, symbols) * symbols[m - 1] a = a * (n - m) / m return expand_mul(s) @classmethod def eval(cls, n, k_sym=None, symbols=None): if n is S.Infinity: if k_sym is None: return S.Infinity else: raise ValueError("Bell polynomial is not defined") if n.is_negative or n.is_integer is False: raise ValueError("a non-negative integer expected") if n.is_Integer and n.is_nonnegative: if k_sym is None: return Integer(cls._bell(int(n))) elif symbols is None: return cls._bell_poly(int(n)).subs(_sym, k_sym) else: r = cls._bell_incomplete_poly(int(n), int(k_sym), symbols) return r def _eval_rewrite_as_Sum(self, n, k_sym=None, symbols=None, **kwargs): from sympy import Sum if (k_sym is not None) or (symbols is not None): return self # Dobinski's formula if not n.is_nonnegative: return self k = Dummy('k', integer=True, nonnegative=True) return 1 / E * Sum(k**n / factorial(k), (k, 0, S.Infinity)) #----------------------------------------------------------------------------# # # # Harmonic numbers # # # #----------------------------------------------------------------------------# class harmonic(Function): r""" Harmonic numbers The nth harmonic number is given by `\operatorname{H}_{n} = 1 + \frac{1}{2} + \frac{1}{3} + \ldots + \frac{1}{n}`. More generally: .. math:: \operatorname{H}_{n,m} = \sum_{k=1}^{n} \frac{1}{k^m} As `n \rightarrow \infty`, `\operatorname{H}_{n,m} \rightarrow \zeta(m)`, the Riemann zeta function. * ``harmonic(n)`` gives the nth harmonic number, `\operatorname{H}_n` * ``harmonic(n, m)`` gives the nth generalized harmonic number of order `m`, `\operatorname{H}_{n,m}`, where ``harmonic(n) == harmonic(n, 1)`` Examples ======== >>> from sympy import harmonic, oo >>> [harmonic(n) for n in range(6)] [0, 1, 3/2, 11/6, 25/12, 137/60] >>> [harmonic(n, 2) for n in range(6)] [0, 1, 5/4, 49/36, 205/144, 5269/3600] >>> harmonic(oo, 2) pi**2/6 >>> from sympy import Symbol, Sum >>> n = Symbol("n") >>> harmonic(n).rewrite(Sum) Sum(1/_k, (_k, 1, n)) We can evaluate harmonic numbers for all integral and positive rational arguments: >>> from sympy import S, expand_func, simplify >>> harmonic(8) 761/280 >>> harmonic(11) 83711/27720 >>> H = harmonic(1/S(3)) >>> H harmonic(1/3) >>> He = expand_func(H) >>> He -log(6) - sqrt(3)*pi/6 + 2*Sum(log(sin(_k*pi/3))*cos(2*_k*pi/3), (_k, 1, 1)) + 3*Sum(1/(3*_k + 1), (_k, 0, 0)) >>> He.doit() -log(6) - sqrt(3)*pi/6 - log(sqrt(3)/2) + 3 >>> H = harmonic(25/S(7)) >>> He = simplify(expand_func(H).doit()) >>> He log(sin(pi/7)**(-2*cos(pi/7))*sin(2*pi/7)**(2*cos(16*pi/7))*cos(pi/14)**(-2*sin(pi/14))/14) + pi*tan(pi/14)/2 + 30247/9900 >>> He.n(40) 1.983697455232980674869851942390639915940 >>> harmonic(25/S(7)).n(40) 1.983697455232980674869851942390639915940 We can rewrite harmonic numbers in terms of polygamma functions: >>> from sympy import digamma, polygamma >>> m = Symbol("m") >>> harmonic(n).rewrite(digamma) polygamma(0, n + 1) + EulerGamma >>> harmonic(n).rewrite(polygamma) polygamma(0, n + 1) + EulerGamma >>> harmonic(n,3).rewrite(polygamma) polygamma(2, n + 1)/2 - polygamma(2, 1)/2 >>> harmonic(n,m).rewrite(polygamma) (-1)**m*(polygamma(m - 1, 1) - polygamma(m - 1, n + 1))/factorial(m - 1) Integer offsets in the argument can be pulled out: >>> from sympy import expand_func >>> expand_func(harmonic(n+4)) harmonic(n) + 1/(n + 4) + 1/(n + 3) + 1/(n + 2) + 1/(n + 1) >>> expand_func(harmonic(n-4)) harmonic(n) - 1/(n - 1) - 1/(n - 2) - 1/(n - 3) - 1/n Some limits can be computed as well: >>> from sympy import limit, oo >>> limit(harmonic(n), n, oo) oo >>> limit(harmonic(n, 2), n, oo) pi**2/6 >>> limit(harmonic(n, 3), n, oo) -polygamma(2, 1)/2 However we can not compute the general relation yet: >>> limit(harmonic(n, m), n, oo) harmonic(oo, m) which equals ``zeta(m)`` for ``m > 1``. See Also ======== bell, bernoulli, catalan, euler, fibonacci, lucas, genocchi, partition, tribonacci References ========== .. [1] https://en.wikipedia.org/wiki/Harmonic_number .. [2] http://functions.wolfram.com/GammaBetaErf/HarmonicNumber/ .. [3] http://functions.wolfram.com/GammaBetaErf/HarmonicNumber2/ """ # Generate one memoized Harmonic number-generating function for each # order and store it in a dictionary _functions = {} @classmethod def eval(cls, n, m=None): from sympy import zeta if m is S.One: return cls(n) if m is None: m = S.One if m.is_zero: return n if n is S.Infinity and m.is_Number: # TODO: Fix for symbolic values of m if m.is_negative: return S.NaN elif LessThan(m, S.One): return S.Infinity elif StrictGreaterThan(m, S.One): return zeta(m) else: return cls if n == 0: return S.Zero if n.is_Integer and n.is_nonnegative and m.is_Integer: if not m in cls._functions: @recurrence_memo([0]) def f(n, prev): return prev[-1] + S.One / n**m cls._functions[m] = f return cls._functions[m](int(n)) def _eval_rewrite_as_polygamma(self, n, m=1, **kwargs): from sympy.functions.special.gamma_functions import polygamma return S.NegativeOne**m/factorial(m - 1) * (polygamma(m - 1, 1) - polygamma(m - 1, n + 1)) def _eval_rewrite_as_digamma(self, n, m=1, **kwargs): from sympy.functions.special.gamma_functions import polygamma return self.rewrite(polygamma) def _eval_rewrite_as_trigamma(self, n, m=1, **kwargs): from sympy.functions.special.gamma_functions import polygamma return self.rewrite(polygamma) def _eval_rewrite_as_Sum(self, n, m=None, **kwargs): from sympy import Sum k = Dummy("k", integer=True) if m is None: m = S.One return Sum(k**(-m), (k, 1, n)) def _eval_expand_func(self, **hints): from sympy import Sum n = self.args[0] m = self.args[1] if len(self.args) == 2 else 1 if m == S.One: if n.is_Add: off = n.args[0] nnew = n - off if off.is_Integer and off.is_positive: result = [S.One/(nnew + i) for i in range(off, 0, -1)] + [harmonic(nnew)] return Add(*result) elif off.is_Integer and off.is_negative: result = [-S.One/(nnew + i) for i in range(0, off, -1)] + [harmonic(nnew)] return Add(*result) if n.is_Rational: # Expansions for harmonic numbers at general rational arguments (u + p/q) # Split n as u + p/q with p < q p, q = n.as_numer_denom() u = p // q p = p - u * q if u.is_nonnegative and p.is_positive and q.is_positive and p < q: k = Dummy("k") t1 = q * Sum(1 / (q * k + p), (k, 0, u)) t2 = 2 * Sum(cos((2 * pi * p * k) / S(q)) * log(sin((pi * k) / S(q))), (k, 1, floor((q - 1) / S(2)))) t3 = (pi / 2) * cot((pi * p) / q) + log(2 * q) return t1 + t2 - t3 return self def _eval_rewrite_as_tractable(self, n, m=1, **kwargs): from sympy import polygamma return self.rewrite(polygamma).rewrite("tractable", deep=True) def _eval_evalf(self, prec): from sympy import polygamma if all(i.is_number for i in self.args): return self.rewrite(polygamma)._eval_evalf(prec) #----------------------------------------------------------------------------# # # # Euler numbers # # # #----------------------------------------------------------------------------# class euler(Function): r""" Euler numbers / Euler polynomials The Euler numbers are given by: .. math:: E_{2n} = I \sum_{k=1}^{2n+1} \sum_{j=0}^k \binom{k}{j} \frac{(-1)^j (k-2j)^{2n+1}}{2^k I^k k} .. math:: E_{2n+1} = 0 Euler numbers and Euler polynomials are related by .. math:: E_n = 2^n E_n\left(\frac{1}{2}\right). We compute symbolic Euler polynomials using [5]_ .. math:: E_n(x) = \sum_{k=0}^n \binom{n}{k} \frac{E_k}{2^k} \left(x - \frac{1}{2}\right)^{n-k}. However, numerical evaluation of the Euler polynomial is computed more efficiently (and more accurately) using the mpmath library. * ``euler(n)`` gives the `n^{th}` Euler number, `E_n`. * ``euler(n, x)`` gives the `n^{th}` Euler polynomial, `E_n(x)`. Examples ======== >>> from sympy import Symbol, S >>> from sympy.functions import euler >>> [euler(n) for n in range(10)] [1, 0, -1, 0, 5, 0, -61, 0, 1385, 0] >>> n = Symbol("n") >>> euler(n + 2*n) euler(3*n) >>> x = Symbol("x") >>> euler(n, x) euler(n, x) >>> euler(0, x) 1 >>> euler(1, x) x - 1/2 >>> euler(2, x) x**2 - x >>> euler(3, x) x**3 - 3*x**2/2 + 1/4 >>> euler(4, x) x**4 - 2*x**3 + x >>> euler(12, S.Half) 2702765/4096 >>> euler(12) 2702765 See Also ======== bell, bernoulli, catalan, fibonacci, harmonic, lucas, genocchi, partition, tribonacci References ========== .. [1] https://en.wikipedia.org/wiki/Euler_numbers .. [2] http://mathworld.wolfram.com/EulerNumber.html .. [3] https://en.wikipedia.org/wiki/Alternating_permutation .. [4] http://mathworld.wolfram.com/AlternatingPermutation.html .. [5] http://dlmf.nist.gov/24.2#ii """ @classmethod def eval(cls, m, sym=None): if m.is_Number: if m.is_Integer and m.is_nonnegative: # Euler numbers if sym is None: if m.is_odd: return S.Zero from mpmath import mp m = m._to_mpmath(mp.prec) res = mp.eulernum(m, exact=True) return Integer(res) # Euler polynomial else: from sympy.core.evalf import pure_complex reim = pure_complex(sym, or_real=True) # Evaluate polynomial numerically using mpmath if reim and all(a.is_Float or a.is_Integer for a in reim) \ and any(a.is_Float for a in reim): from mpmath import mp from sympy import Expr m = int(m) # XXX ComplexFloat (#12192) would be nice here, above prec = min([a._prec for a in reim if a.is_Float]) with workprec(prec): res = mp.eulerpoly(m, sym) return Expr._from_mpmath(res, prec) # Construct polynomial symbolically from definition m, result = int(m), [] for k in range(m + 1): result.append(binomial(m, k)*cls(k)/(2**k)*(sym - S.Half)**(m - k)) return Add(*result).expand() else: raise ValueError("Euler numbers are defined only" " for nonnegative integer indices.") if sym is None: if m.is_odd and m.is_positive: return S.Zero def _eval_rewrite_as_Sum(self, n, x=None, **kwargs): from sympy import Sum if x is None and n.is_even: k = Dummy("k", integer=True) j = Dummy("j", integer=True) n = n / 2 Em = (S.ImaginaryUnit * Sum(Sum(binomial(k, j) * ((-1)**j * (k - 2*j)**(2*n + 1)) / (2**k*S.ImaginaryUnit**k * k), (j, 0, k)), (k, 1, 2*n + 1))) return Em if x: k = Dummy("k", integer=True) return Sum(binomial(n, k)*euler(k)/2**k*(x-S.Half)**(n-k), (k, 0, n)) def _eval_evalf(self, prec): m, x = (self.args[0], None) if len(self.args) == 1 else self.args if x is None and m.is_Integer and m.is_nonnegative: from mpmath import mp from sympy import Expr m = m._to_mpmath(prec) with workprec(prec): res = mp.eulernum(m) return Expr._from_mpmath(res, prec) if x and x.is_number and m.is_Integer and m.is_nonnegative: from mpmath import mp from sympy import Expr m = int(m) x = x._to_mpmath(prec) with workprec(prec): res = mp.eulerpoly(m, x) return Expr._from_mpmath(res, prec) #----------------------------------------------------------------------------# # # # Catalan numbers # # # #----------------------------------------------------------------------------# class catalan(Function): r""" Catalan numbers The `n^{th}` catalan number is given by: .. math :: C_n = \frac{1}{n+1} \binom{2n}{n} * ``catalan(n)`` gives the `n^{th}` Catalan number, `C_n` Examples ======== >>> from sympy import (Symbol, binomial, gamma, hyper, polygamma, ... catalan, diff, combsimp, Rational, I) >>> [catalan(i) for i in range(1,10)] [1, 2, 5, 14, 42, 132, 429, 1430, 4862] >>> n = Symbol("n", integer=True) >>> catalan(n) catalan(n) Catalan numbers can be transformed into several other, identical expressions involving other mathematical functions >>> catalan(n).rewrite(binomial) binomial(2*n, n)/(n + 1) >>> catalan(n).rewrite(gamma) 4**n*gamma(n + 1/2)/(sqrt(pi)*gamma(n + 2)) >>> catalan(n).rewrite(hyper) hyper((1 - n, -n), (2,), 1) For some non-integer values of n we can get closed form expressions by rewriting in terms of gamma functions: >>> catalan(Rational(1,2)).rewrite(gamma) 8/(3*pi) We can differentiate the Catalan numbers C(n) interpreted as a continuous real function in n: >>> diff(catalan(n), n) (polygamma(0, n + 1/2) - polygamma(0, n + 2) + log(4))*catalan(n) As a more advanced example consider the following ratio between consecutive numbers: >>> combsimp((catalan(n + 1)/catalan(n)).rewrite(binomial)) 2*(2*n + 1)/(n + 2) The Catalan numbers can be generalized to complex numbers: >>> catalan(I).rewrite(gamma) 4**I*gamma(1/2 + I)/(sqrt(pi)*gamma(2 + I)) and evaluated with arbitrary precision: >>> catalan(I).evalf(20) 0.39764993382373624267 - 0.020884341620842555705*I See Also ======== bell, bernoulli, euler, fibonacci, harmonic, lucas, genocchi, partition, tribonacci sympy.functions.combinatorial.factorials.binomial References ========== .. [1] https://en.wikipedia.org/wiki/Catalan_number .. [2] http://mathworld.wolfram.com/CatalanNumber.html .. [3] http://functions.wolfram.com/GammaBetaErf/CatalanNumber/ .. [4] http://geometer.org/mathcircles/catalan.pdf """ @classmethod def eval(cls, n): from sympy import gamma if (n.is_Integer and n.is_nonnegative) or \ (n.is_noninteger and n.is_negative): return 4**n*gamma(n + S.Half)/(gamma(S.Half)*gamma(n + 2)) if (n.is_integer and n.is_negative): if (n + 1).is_negative: return S.Zero if (n + 1).is_zero: return -S.Half def fdiff(self, argindex=1): from sympy import polygamma, log n = self.args[0] return catalan(n)*(polygamma(0, n + Rational(1, 2)) - polygamma(0, n + 2) + log(4)) def _eval_rewrite_as_binomial(self, n, **kwargs): return binomial(2*n, n)/(n + 1) def _eval_rewrite_as_factorial(self, n, **kwargs): return factorial(2*n) / (factorial(n+1) * factorial(n)) def _eval_rewrite_as_gamma(self, n, **kwargs): from sympy import gamma # The gamma function allows to generalize Catalan numbers to complex n return 4**n*gamma(n + S.Half)/(gamma(S.Half)*gamma(n + 2)) def _eval_rewrite_as_hyper(self, n, **kwargs): from sympy import hyper return hyper([1 - n, -n], [2], 1) def _eval_rewrite_as_Product(self, n, **kwargs): from sympy import Product if not (n.is_integer and n.is_nonnegative): return self k = Dummy('k', integer=True, positive=True) return Product((n + k) / k, (k, 2, n)) def _eval_is_integer(self): if self.args[0].is_integer and self.args[0].is_nonnegative: return True def _eval_is_positive(self): if self.args[0].is_nonnegative: return True def _eval_is_composite(self): if self.args[0].is_integer and (self.args[0] - 3).is_positive: return True def _eval_evalf(self, prec): from sympy import gamma if self.args[0].is_number: return self.rewrite(gamma)._eval_evalf(prec) #----------------------------------------------------------------------------# # # # Genocchi numbers # # # #----------------------------------------------------------------------------# class genocchi(Function): r""" Genocchi numbers The Genocchi numbers are a sequence of integers `G_n` that satisfy the relation: .. math:: \frac{2t}{e^t + 1} = \sum_{n=1}^\infty \frac{G_n t^n}{n!} Examples ======== >>> from sympy import Symbol >>> from sympy.functions import genocchi >>> [genocchi(n) for n in range(1, 9)] [1, -1, 0, 1, 0, -3, 0, 17] >>> n = Symbol('n', integer=True, positive=True) >>> genocchi(2*n + 1) 0 See Also ======== bell, bernoulli, catalan, euler, fibonacci, harmonic, lucas, partition, tribonacci References ========== .. [1] https://en.wikipedia.org/wiki/Genocchi_number .. [2] http://mathworld.wolfram.com/GenocchiNumber.html """ @classmethod def eval(cls, n): if n.is_Number: if (not n.is_Integer) or n.is_nonpositive: raise ValueError("Genocchi numbers are defined only for " + "positive integers") return 2 * (1 - S(2) ** n) * bernoulli(n) if n.is_odd and (n - 1).is_positive: return S.Zero if (n - 1).is_zero: return S.One def _eval_rewrite_as_bernoulli(self, n, **kwargs): if n.is_integer and n.is_nonnegative: return (1 - S(2) ** n) * bernoulli(n) * 2 def _eval_is_integer(self): if self.args[0].is_integer and self.args[0].is_positive: return True def _eval_is_negative(self): n = self.args[0] if n.is_integer and n.is_positive: if n.is_odd: return False return (n / 2).is_odd def _eval_is_positive(self): n = self.args[0] if n.is_integer and n.is_positive: if n.is_odd: return fuzzy_not((n - 1).is_positive) return (n / 2).is_even def _eval_is_even(self): n = self.args[0] if n.is_integer and n.is_positive: if n.is_even: return False return (n - 1).is_positive def _eval_is_odd(self): n = self.args[0] if n.is_integer and n.is_positive: if n.is_even: return True return fuzzy_not((n - 1).is_positive) def _eval_is_prime(self): n = self.args[0] # only G_6 = -3 and G_8 = 17 are prime, # but SymPy does not consider negatives as prime # so only n=8 is tested return (n - 8).is_zero #----------------------------------------------------------------------------# # # # Partition numbers # # # #----------------------------------------------------------------------------# _npartition = [1, 1] class partition(Function): r""" Partition numbers The Partition numbers are a sequence of integers `p_n` that represent the number of distinct ways of representing `n` as a sum of natural numbers (with order irrelevant). The generating function for `p_n` is given by: .. math:: \sum_{n=0}^\infty p_n x^n = \prod_{k=1}^\infty (1 - x^k)^{-1} Examples ======== >>> from sympy import Symbol >>> from sympy.functions import partition >>> [partition(n) for n in range(9)] [1, 1, 2, 3, 5, 7, 11, 15, 22] >>> n = Symbol('n', integer=True, negative=True) >>> partition(n) 0 See Also ======== bell, bernoulli, catalan, euler, fibonacci, harmonic, lucas, genocchi, tribonacci References ========== .. [1] https://en.wikipedia.org/wiki/Partition_(number_theory%29 .. [2] https://en.wikipedia.org/wiki/Pentagonal_number_theorem """ @staticmethod def _partition(n): L = len(_npartition) if n < L: return _npartition[n] # lengthen cache for _n in range(L, n + 1): v, p, i = 0, 0, 0 while 1: s = 0 p += 3*i + 1 # p = pentagonal number: 1, 5, 12, ... if _n >= p: s += _npartition[_n - p] i += 1 gp = p + i # gp = generalized pentagonal: 2, 7, 15, ... if _n >= gp: s += _npartition[_n - gp] if s == 0: break else: v += s if i%2 == 1 else -s _npartition.append(v) return v @classmethod def eval(cls, n): is_int = n.is_integer if is_int == False: raise ValueError("Partition numbers are defined only for " "integers") elif is_int: if n.is_negative: return S.Zero if n.is_zero or (n - 1).is_zero: return S.One if n.is_Integer: return Integer(cls._partition(n)) def _eval_is_integer(self): if self.args[0].is_integer: return True def _eval_is_negative(self): if self.args[0].is_integer: return False def _eval_is_positive(self): n = self.args[0] if n.is_nonnegative and n.is_integer: return True ####################################################################### ### ### Functions for enumerating partitions, permutations and combinations ### ####################################################################### class _MultisetHistogram(tuple): pass _N = -1 _ITEMS = -2 _M = slice(None, _ITEMS) def _multiset_histogram(n): """Return tuple used in permutation and combination counting. Input is a dictionary giving items with counts as values or a sequence of items (which need not be sorted). The data is stored in a class deriving from tuple so it is easily recognized and so it can be converted easily to a list. """ if isinstance(n, dict): # item: count if not all(isinstance(v, int) and v >= 0 for v in n.values()): raise ValueError tot = sum(n.values()) items = sum(1 for k in n if n[k] > 0) return _MultisetHistogram([n[k] for k in n if n[k] > 0] + [items, tot]) else: n = list(n) s = set(n) if len(s) == len(n): n = [1]*len(n) n.extend([len(n), len(n)]) return _MultisetHistogram(n) m = dict(zip(s, range(len(s)))) d = dict(zip(range(len(s)), [0]*len(s))) for i in n: d[m[i]] += 1 return _multiset_histogram(d) def nP(n, k=None, replacement=False): """Return the number of permutations of ``n`` items taken ``k`` at a time. Possible values for ``n``:: integer - set of length ``n`` sequence - converted to a multiset internally multiset - {element: multiplicity} If ``k`` is None then the total of all permutations of length 0 through the number of items represented by ``n`` will be returned. If ``replacement`` is True then a given item can appear more than once in the ``k`` items. (For example, for 'ab' permutations of 2 would include 'aa', 'ab', 'ba' and 'bb'.) The multiplicity of elements in ``n`` is ignored when ``replacement`` is True but the total number of elements is considered since no element can appear more times than the number of elements in ``n``. Examples ======== >>> from sympy.functions.combinatorial.numbers import nP >>> from sympy.utilities.iterables import multiset_permutations, multiset >>> nP(3, 2) 6 >>> nP('abc', 2) == nP(multiset('abc'), 2) == 6 True >>> nP('aab', 2) 3 >>> nP([1, 2, 2], 2) 3 >>> [nP(3, i) for i in range(4)] [1, 3, 6, 6] >>> nP(3) == sum(_) True When ``replacement`` is True, each item can have multiplicity equal to the length represented by ``n``: >>> nP('aabc', replacement=True) 121 >>> [len(list(multiset_permutations('aaaabbbbcccc', i))) for i in range(5)] [1, 3, 9, 27, 81] >>> sum(_) 121 See Also ======== sympy.utilities.iterables.multiset_permutations References ========== .. [1] https://en.wikipedia.org/wiki/Permutation """ try: n = as_int(n) except ValueError: return Integer(_nP(_multiset_histogram(n), k, replacement)) return Integer(_nP(n, k, replacement)) @cacheit def _nP(n, k=None, replacement=False): from sympy.functions.combinatorial.factorials import factorial from sympy.core.mul import prod if k == 0: return 1 if isinstance(n, SYMPY_INTS): # n different items # assert n >= 0 if k is None: return sum(_nP(n, i, replacement) for i in range(n + 1)) elif replacement: return n**k elif k > n: return 0 elif k == n: return factorial(k) elif k == 1: return n else: # assert k >= 0 return _product(n - k + 1, n) elif isinstance(n, _MultisetHistogram): if k is None: return sum(_nP(n, i, replacement) for i in range(n[_N] + 1)) elif replacement: return n[_ITEMS]**k elif k == n[_N]: return factorial(k)/prod([factorial(i) for i in n[_M] if i > 1]) elif k > n[_N]: return 0 elif k == 1: return n[_ITEMS] else: # assert k >= 0 tot = 0 n = list(n) for i in range(len(n[_M])): if not n[i]: continue n[_N] -= 1 if n[i] == 1: n[i] = 0 n[_ITEMS] -= 1 tot += _nP(_MultisetHistogram(n), k - 1) n[_ITEMS] += 1 n[i] = 1 else: n[i] -= 1 tot += _nP(_MultisetHistogram(n), k - 1) n[i] += 1 n[_N] += 1 return tot @cacheit def _AOP_product(n): """for n = (m1, m2, .., mk) return the coefficients of the polynomial, prod(sum(x**i for i in range(nj + 1)) for nj in n); i.e. the coefficients of the product of AOPs (all-one polynomials) or order given in n. The resulting coefficient corresponding to x**r is the number of r-length combinations of sum(n) elements with multiplicities given in n. The coefficients are given as a default dictionary (so if a query is made for a key that is not present, 0 will be returned). Examples ======== >>> from sympy.functions.combinatorial.numbers import _AOP_product >>> from sympy.abc import x >>> n = (2, 2, 3) # e.g. aabbccc >>> prod = ((x**2 + x + 1)*(x**2 + x + 1)*(x**3 + x**2 + x + 1)).expand() >>> c = _AOP_product(n); dict(c) {0: 1, 1: 3, 2: 6, 3: 8, 4: 8, 5: 6, 6: 3, 7: 1} >>> [c[i] for i in range(8)] == [prod.coeff(x, i) for i in range(8)] True The generating poly used here is the same as that listed in http://tinyurl.com/cep849r, but in a refactored form. """ from collections import defaultdict n = list(n) ord = sum(n) need = (ord + 2)//2 rv = [1]*(n.pop() + 1) rv.extend([0]*(need - len(rv))) rv = rv[:need] while n: ni = n.pop() N = ni + 1 was = rv[:] for i in range(1, min(N, len(rv))): rv[i] += rv[i - 1] for i in range(N, need): rv[i] += rv[i - 1] - was[i - N] rev = list(reversed(rv)) if ord % 2: rv = rv + rev else: rv[-1:] = rev d = defaultdict(int) for i in range(len(rv)): d[i] = rv[i] return d def nC(n, k=None, replacement=False): """Return the number of combinations of ``n`` items taken ``k`` at a time. Possible values for ``n``:: integer - set of length ``n`` sequence - converted to a multiset internally multiset - {element: multiplicity} If ``k`` is None then the total of all combinations of length 0 through the number of items represented in ``n`` will be returned. If ``replacement`` is True then a given item can appear more than once in the ``k`` items. (For example, for 'ab' sets of 2 would include 'aa', 'ab', and 'bb'.) The multiplicity of elements in ``n`` is ignored when ``replacement`` is True but the total number of elements is considered since no element can appear more times than the number of elements in ``n``. Examples ======== >>> from sympy.functions.combinatorial.numbers import nC >>> from sympy.utilities.iterables import multiset_combinations >>> nC(3, 2) 3 >>> nC('abc', 2) 3 >>> nC('aab', 2) 2 When ``replacement`` is True, each item can have multiplicity equal to the length represented by ``n``: >>> nC('aabc', replacement=True) 35 >>> [len(list(multiset_combinations('aaaabbbbcccc', i))) for i in range(5)] [1, 3, 6, 10, 15] >>> sum(_) 35 If there are ``k`` items with multiplicities ``m_1, m_2, ..., m_k`` then the total of all combinations of length 0 through ``k`` is the product, ``(m_1 + 1)*(m_2 + 1)*...*(m_k + 1)``. When the multiplicity of each item is 1 (i.e., k unique items) then there are 2**k combinations. For example, if there are 4 unique items, the total number of combinations is 16: >>> sum(nC(4, i) for i in range(5)) 16 See Also ======== sympy.utilities.iterables.multiset_combinations References ========== .. [1] https://en.wikipedia.org/wiki/Combination .. [2] http://tinyurl.com/cep849r """ from sympy.functions.combinatorial.factorials import binomial from sympy.core.mul import prod if isinstance(n, SYMPY_INTS): if k is None: if not replacement: return 2**n return sum(nC(n, i, replacement) for i in range(n + 1)) if k < 0: raise ValueError("k cannot be negative") if replacement: return binomial(n + k - 1, k) return binomial(n, k) if isinstance(n, _MultisetHistogram): N = n[_N] if k is None: if not replacement: return prod(m + 1 for m in n[_M]) return sum(nC(n, i, replacement) for i in range(N + 1)) elif replacement: return nC(n[_ITEMS], k, replacement) # assert k >= 0 elif k in (1, N - 1): return n[_ITEMS] elif k in (0, N): return 1 return _AOP_product(tuple(n[_M]))[k] else: return nC(_multiset_histogram(n), k, replacement) @cacheit def _stirling1(n, k): if n == k == 0: return S.One if 0 in (n, k): return S.Zero n1 = n - 1 # some special values if n == k: return S.One elif k == 1: return factorial(n1) elif k == n1: return binomial(n, 2) elif k == n - 2: return (3*n - 1)*binomial(n, 3)/4 elif k == n - 3: return binomial(n, 2)*binomial(n, 4) # general recurrence return n1*_stirling1(n1, k) + _stirling1(n1, k - 1) @cacheit def _stirling2(n, k): if n == k == 0: return S.One if 0 in (n, k): return S.Zero n1 = n - 1 # some special values if k == n1: return binomial(n, 2) elif k == 2: return 2**n1 - 1 # general recurrence return k*_stirling2(n1, k) + _stirling2(n1, k - 1) def stirling(n, k, d=None, kind=2, signed=False): r"""Return Stirling number `S(n, k)` of the first or second (default) kind. The sum of all Stirling numbers of the second kind for `k = 1` through `n` is ``bell(n)``. The recurrence relationship for these numbers is: .. math :: {0 \brace 0} = 1; {n \brace 0} = {0 \brace k} = 0; .. math :: {{n+1} \brace k} = j {n \brace k} + {n \brace {k-1}} where `j` is: `n` for Stirling numbers of the first kind `-n` for signed Stirling numbers of the first kind `k` for Stirling numbers of the second kind The first kind of Stirling number counts the number of permutations of ``n`` distinct items that have ``k`` cycles; the second kind counts the ways in which ``n`` distinct items can be partitioned into ``k`` parts. If ``d`` is given, the "reduced Stirling number of the second kind" is returned: ``S^{d}(n, k) = S(n - d + 1, k - d + 1)`` with ``n >= k >= d``. (This counts the ways to partition ``n`` consecutive integers into ``k`` groups with no pairwise difference less than ``d``. See example below.) To obtain the signed Stirling numbers of the first kind, use keyword ``signed=True``. Using this keyword automatically sets ``kind`` to 1. Examples ======== >>> from sympy.functions.combinatorial.numbers import stirling, bell >>> from sympy.combinatorics import Permutation >>> from sympy.utilities.iterables import multiset_partitions, permutations First kind (unsigned by default): >>> [stirling(6, i, kind=1) for i in range(7)] [0, 120, 274, 225, 85, 15, 1] >>> perms = list(permutations(range(4))) >>> [sum(Permutation(p).cycles == i for p in perms) for i in range(5)] [0, 6, 11, 6, 1] >>> [stirling(4, i, kind=1) for i in range(5)] [0, 6, 11, 6, 1] First kind (signed): >>> [stirling(4, i, signed=True) for i in range(5)] [0, -6, 11, -6, 1] Second kind: >>> [stirling(10, i) for i in range(12)] [0, 1, 511, 9330, 34105, 42525, 22827, 5880, 750, 45, 1, 0] >>> sum(_) == bell(10) True >>> len(list(multiset_partitions(range(4), 2))) == stirling(4, 2) True Reduced second kind: >>> from sympy import subsets, oo >>> def delta(p): ... if len(p) == 1: ... return oo ... return min(abs(i[0] - i[1]) for i in subsets(p, 2)) >>> parts = multiset_partitions(range(5), 3) >>> d = 2 >>> sum(1 for p in parts if all(delta(i) >= d for i in p)) 7 >>> stirling(5, 3, 2) 7 See Also ======== sympy.utilities.iterables.multiset_partitions References ========== .. [1] https://en.wikipedia.org/wiki/Stirling_numbers_of_the_first_kind .. [2] https://en.wikipedia.org/wiki/Stirling_numbers_of_the_second_kind """ # TODO: make this a class like bell() n = as_int(n) k = as_int(k) if n < 0: raise ValueError('n must be nonnegative') if k > n: return S.Zero if d: # assert k >= d # kind is ignored -- only kind=2 is supported return _stirling2(n - d + 1, k - d + 1) elif signed: # kind is ignored -- only kind=1 is supported return (-1)**(n - k)*_stirling1(n, k) if kind == 1: return _stirling1(n, k) elif kind == 2: return _stirling2(n, k) else: raise ValueError('kind must be 1 or 2, not %s' % k) @cacheit def _nT(n, k): """Return the partitions of ``n`` items into ``k`` parts. This is used by ``nT`` for the case when ``n`` is an integer.""" # really quick exits if k > n or k < 0: return 0 if k == n or k == 1: return 1 if k == 0: return 0 # exits that could be done below but this is quicker if k == 2: return n//2 d = n - k if d <= 3: return d # quick exit if 3*k >= n: # or, equivalently, 2*k >= d # all the information needed in this case # will be in the cache needed to calculate # partition(d), so... # update cache tot = partition._partition(d) # and correct for values not needed if d - k > 0: tot -= sum(_npartition[:d - k]) return tot # regular exit # nT(n, k) = Sum(nT(n - k, m), (m, 1, k)); # calculate needed nT(i, j) values p = [1]*d for i in range(2, k + 1): for m in range(i + 1, d): p[m] += p[m - i] d -= 1 # if p[0] were appended to the end of p then the last # k values of p are the nT(n, j) values for 0 < j < k in reverse # order p[-1] = nT(n, 1), p[-2] = nT(n, 2), etc.... Instead of # putting the 1 from p[0] there, however, it is simply added to # the sum below which is valid for 1 < k <= n//2 return (1 + sum(p[1 - k:])) def nT(n, k=None): """Return the number of ``k``-sized partitions of ``n`` items. Possible values for ``n``:: integer - ``n`` identical items sequence - converted to a multiset internally multiset - {element: multiplicity} Note: the convention for ``nT`` is different than that of ``nC`` and ``nP`` in that here an integer indicates ``n`` *identical* items instead of a set of length ``n``; this is in keeping with the ``partitions`` function which treats its integer-``n`` input like a list of ``n`` 1s. One can use ``range(n)`` for ``n`` to indicate ``n`` distinct items. If ``k`` is None then the total number of ways to partition the elements represented in ``n`` will be returned. Examples ======== >>> from sympy.functions.combinatorial.numbers import nT Partitions of the given multiset: >>> [nT('aabbc', i) for i in range(1, 7)] [1, 8, 11, 5, 1, 0] >>> nT('aabbc') == sum(_) True >>> [nT("mississippi", i) for i in range(1, 12)] [1, 74, 609, 1521, 1768, 1224, 579, 197, 50, 9, 1] Partitions when all items are identical: >>> [nT(5, i) for i in range(1, 6)] [1, 2, 2, 1, 1] >>> nT('1'*5) == sum(_) True When all items are different: >>> [nT(range(5), i) for i in range(1, 6)] [1, 15, 25, 10, 1] >>> nT(range(5)) == sum(_) True Partitions of an integer expressed as a sum of positive integers: >>> from sympy.functions.combinatorial.numbers import partition >>> partition(4) 5 >>> nT(4, 1) + nT(4, 2) + nT(4, 3) + nT(4, 4) 5 >>> nT('1'*4) 5 See Also ======== sympy.utilities.iterables.partitions sympy.utilities.iterables.multiset_partitions sympy.functions.combinatorial.numbers.partition References ========== .. [1] http://undergraduate.csse.uwa.edu.au/units/CITS7209/partition.pdf """ from sympy.utilities.enumerative import MultisetPartitionTraverser if isinstance(n, SYMPY_INTS): # n identical items if k is None: return partition(n) if isinstance(k, SYMPY_INTS): n = as_int(n) k = as_int(k) return Integer(_nT(n, k)) if not isinstance(n, _MultisetHistogram): try: # if n contains hashable items there is some # quick handling that can be done u = len(set(n)) if u <= 1: return nT(len(n), k) elif u == len(n): n = range(u) raise TypeError except TypeError: n = _multiset_histogram(n) N = n[_N] if k is None and N == 1: return 1 if k in (1, N): return 1 if k == 2 or N == 2 and k is None: m, r = divmod(N, 2) rv = sum(nC(n, i) for i in range(1, m + 1)) if not r: rv -= nC(n, m)//2 if k is None: rv += 1 # for k == 1 return rv if N == n[_ITEMS]: # all distinct if k is None: return bell(N) return stirling(N, k) m = MultisetPartitionTraverser() if k is None: return m.count_partitions(n[_M]) # MultisetPartitionTraverser does not have a range-limited count # method, so need to enumerate and count tot = 0 for discard in m.enum_range(n[_M], k-1, k): tot += 1 return tot
3fa6c05137ab3366a565e59130c526690353512076df442ef61a984b241a3f32
from __future__ import print_function, division from sympy.core.add import Add from sympy.core.basic import sympify, cacheit from sympy.core.compatibility import range from sympy.core.function import Function, ArgumentIndexError from sympy.core.logic import fuzzy_not, fuzzy_or from sympy.core.numbers import igcdex, Rational, pi from sympy.core.relational import Ne from sympy.core.singleton import S from sympy.core.symbol import Symbol from sympy.functions.combinatorial.factorials import factorial, RisingFactorial from sympy.functions.elementary.exponential import log, exp from sympy.functions.elementary.integers import floor from sympy.functions.elementary.hyperbolic import (acoth, asinh, atanh, cosh, coth, HyperbolicFunction, sinh, tanh) from sympy.functions.elementary.miscellaneous import sqrt, Min, Max from sympy.functions.elementary.piecewise import Piecewise from sympy.sets.sets import FiniteSet from sympy.utilities.iterables import numbered_symbols ############################################################################### ########################## TRIGONOMETRIC FUNCTIONS ############################ ############################################################################### class TrigonometricFunction(Function): """Base class for trigonometric functions. """ unbranched = True def _eval_is_rational(self): s = self.func(*self.args) if s.func == self.func: if s.args[0].is_rational and fuzzy_not(s.args[0].is_zero): return False else: return s.is_rational def _eval_is_algebraic(self): s = self.func(*self.args) if s.func == self.func: if fuzzy_not(self.args[0].is_zero) and self.args[0].is_algebraic: return False pi_coeff = _pi_coeff(self.args[0]) if pi_coeff is not None and pi_coeff.is_rational: return True else: return s.is_algebraic def _eval_expand_complex(self, deep=True, **hints): re_part, im_part = self.as_real_imag(deep=deep, **hints) return re_part + im_part*S.ImaginaryUnit def _as_real_imag(self, deep=True, **hints): if self.args[0].is_real: if deep: hints['complex'] = False return (self.args[0].expand(deep, **hints), S.Zero) else: return (self.args[0], S.Zero) if deep: re, im = self.args[0].expand(deep, **hints).as_real_imag() else: re, im = self.args[0].as_real_imag() return (re, im) def _period(self, general_period, symbol=None): f = self.args[0] if symbol is None: symbol = tuple(f.free_symbols)[0] if not f.has(symbol): return S.Zero if f == symbol: return general_period if symbol in f.free_symbols: if f.is_Mul: g, h = f.as_independent(symbol) if h == symbol: return general_period/abs(g) if f.is_Add: a, h = f.as_independent(symbol) g, h = h.as_independent(symbol, as_Add=False) if h == symbol: return general_period/abs(g) raise NotImplementedError("Use the periodicity function instead.") def _peeloff_pi(arg): """ Split ARG into two parts, a "rest" and a multiple of pi/2. This assumes ARG to be an Add. The multiple of pi returned in the second position is always a Rational. Examples ======== >>> from sympy.functions.elementary.trigonometric import _peeloff_pi as peel >>> from sympy import pi >>> from sympy.abc import x, y >>> peel(x + pi/2) (x, pi/2) >>> peel(x + 2*pi/3 + pi*y) (x + pi*y + pi/6, pi/2) """ for a in Add.make_args(arg): if a is S.Pi: K = S.One break elif a.is_Mul: K, p = a.as_two_terms() if p is S.Pi and K.is_Rational: break else: return arg, S.Zero m1 = (K % S.Half) * S.Pi m2 = K*S.Pi - m1 return arg - m2, m2 def _pi_coeff(arg, cycles=1): """ When arg is a Number times pi (e.g. 3*pi/2) then return the Number normalized to be in the range [0, 2], else None. When an even multiple of pi is encountered, if it is multiplying something with known parity then the multiple is returned as 0 otherwise as 2. Examples ======== >>> from sympy.functions.elementary.trigonometric import _pi_coeff as coeff >>> from sympy import pi, Dummy >>> from sympy.abc import x, y >>> coeff(3*x*pi) 3*x >>> coeff(11*pi/7) 11/7 >>> coeff(-11*pi/7) 3/7 >>> coeff(4*pi) 0 >>> coeff(5*pi) 1 >>> coeff(5.0*pi) 1 >>> coeff(5.5*pi) 3/2 >>> coeff(2 + pi) >>> coeff(2*Dummy(integer=True)*pi) 2 >>> coeff(2*Dummy(even=True)*pi) 0 """ arg = sympify(arg) if arg is S.Pi: return S.One elif not arg: return S.Zero elif arg.is_Mul: cx = arg.coeff(S.Pi) if cx: c, x = cx.as_coeff_Mul() # pi is not included as coeff if c.is_Float: # recast exact binary fractions to Rationals f = abs(c) % 1 if f != 0: p = -int(round(log(f, 2).evalf())) m = 2**p cm = c*m i = int(cm) if i == cm: c = Rational(i, m) cx = c*x else: c = Rational(int(c)) cx = c*x if x.is_integer: c2 = c % 2 if c2 == 1: return x elif not c2: if x.is_even is not None: # known parity return S.Zero return S(2) else: return c2*x return cx class sin(TrigonometricFunction): """ The sine function. Returns the sine of x (measured in radians). Notes ===== This function will evaluate automatically in the case x/pi is some rational number [4]_. For example, if x is a multiple of pi, pi/2, pi/3, pi/4 and pi/6. Examples ======== >>> from sympy import sin, pi >>> from sympy.abc import x >>> sin(x**2).diff(x) 2*x*cos(x**2) >>> sin(1).diff(x) 0 >>> sin(pi) 0 >>> sin(pi/2) 1 >>> sin(pi/6) 1/2 >>> sin(pi/12) -sqrt(2)/4 + sqrt(6)/4 See Also ======== csc, cos, sec, tan, cot asin, acsc, acos, asec, atan, acot, atan2 References ========== .. [1] https://en.wikipedia.org/wiki/Trigonometric_functions .. [2] http://dlmf.nist.gov/4.14 .. [3] http://functions.wolfram.com/ElementaryFunctions/Sin .. [4] http://mathworld.wolfram.com/TrigonometryAngles.html """ def period(self, symbol=None): return self._period(2*pi, symbol) def fdiff(self, argindex=1): if argindex == 1: return cos(self.args[0]) else: raise ArgumentIndexError(self, argindex) @classmethod def eval(cls, arg): from sympy.calculus import AccumBounds from sympy.sets.setexpr import SetExpr if arg.is_Number: if arg is S.NaN: return S.NaN elif arg is S.Zero: return S.Zero elif arg is S.Infinity or arg is S.NegativeInfinity: return AccumBounds(-1, 1) if arg is S.ComplexInfinity: return S.NaN if isinstance(arg, AccumBounds): min, max = arg.min, arg.max d = floor(min/(2*S.Pi)) if min is not S.NegativeInfinity: min = min - d*2*S.Pi if max is not S.Infinity: max = max - d*2*S.Pi if AccumBounds(min, max).intersection(FiniteSet(S.Pi/2, 5*S.Pi/2)) \ is not S.EmptySet and \ AccumBounds(min, max).intersection(FiniteSet(3*S.Pi/2, 7*S.Pi/2)) is not S.EmptySet: return AccumBounds(-1, 1) elif AccumBounds(min, max).intersection(FiniteSet(S.Pi/2, 5*S.Pi/2)) \ is not S.EmptySet: return AccumBounds(Min(sin(min), sin(max)), 1) elif AccumBounds(min, max).intersection(FiniteSet(3*S.Pi/2, 8*S.Pi/2)) \ is not S.EmptySet: return AccumBounds(-1, Max(sin(min), sin(max))) else: return AccumBounds(Min(sin(min), sin(max)), Max(sin(min), sin(max))) elif isinstance(arg, SetExpr): return arg._eval_func(cls) if arg.could_extract_minus_sign(): return -cls(-arg) i_coeff = arg.as_coefficient(S.ImaginaryUnit) if i_coeff is not None: return S.ImaginaryUnit * sinh(i_coeff) pi_coeff = _pi_coeff(arg) if pi_coeff is not None: if pi_coeff.is_integer: return S.Zero if (2*pi_coeff).is_integer: if pi_coeff.is_even: return S.Zero elif pi_coeff.is_even is False: return S.NegativeOne**(pi_coeff - S.Half) if not pi_coeff.is_Rational: narg = pi_coeff*S.Pi if narg != arg: return cls(narg) return None # https://github.com/sympy/sympy/issues/6048 # transform a sine to a cosine, to avoid redundant code if pi_coeff.is_Rational: x = pi_coeff % 2 if x > 1: return -cls((x % 1)*S.Pi) if 2*x > 1: return cls((1 - x)*S.Pi) narg = ((pi_coeff + Rational(3, 2)) % 2)*S.Pi result = cos(narg) if not isinstance(result, cos): return result if pi_coeff*S.Pi != arg: return cls(pi_coeff*S.Pi) return None if arg.is_Add: x, m = _peeloff_pi(arg) if m: return sin(m)*cos(x) + cos(m)*sin(x) if isinstance(arg, asin): return arg.args[0] if isinstance(arg, atan): x = arg.args[0] return x / sqrt(1 + x**2) if isinstance(arg, atan2): y, x = arg.args return y / sqrt(x**2 + y**2) if isinstance(arg, acos): x = arg.args[0] return sqrt(1 - x**2) if isinstance(arg, acot): x = arg.args[0] return 1 / (sqrt(1 + 1 / x**2) * x) if isinstance(arg, acsc): x = arg.args[0] return 1 / x if isinstance(arg, asec): x = arg.args[0] return sqrt(1 - 1 / x**2) @staticmethod @cacheit def taylor_term(n, x, *previous_terms): if n < 0 or n % 2 == 0: return S.Zero else: x = sympify(x) if len(previous_terms) > 2: p = previous_terms[-2] return -p * x**2 / (n*(n - 1)) else: return (-1)**(n//2) * x**(n)/factorial(n) def _eval_rewrite_as_exp(self, arg, **kwargs): I = S.ImaginaryUnit if isinstance(arg, TrigonometricFunction) or isinstance(arg, HyperbolicFunction): arg = arg.func(arg.args[0]).rewrite(exp) return (exp(arg*I) - exp(-arg*I)) / (2*I) def _eval_rewrite_as_Pow(self, arg, **kwargs): if isinstance(arg, log): I = S.ImaginaryUnit x = arg.args[0] return I*x**-I / 2 - I*x**I /2 def _eval_rewrite_as_cos(self, arg, **kwargs): return cos(arg - S.Pi / 2, evaluate=False) def _eval_rewrite_as_tan(self, arg, **kwargs): tan_half = tan(S.Half*arg) return 2*tan_half/(1 + tan_half**2) def _eval_rewrite_as_sincos(self, arg, **kwargs): return sin(arg)*cos(arg)/cos(arg) def _eval_rewrite_as_cot(self, arg, **kwargs): cot_half = cot(S.Half*arg) return 2*cot_half/(1 + cot_half**2) def _eval_rewrite_as_pow(self, arg, **kwargs): return self.rewrite(cos).rewrite(pow) def _eval_rewrite_as_sqrt(self, arg, **kwargs): return self.rewrite(cos).rewrite(sqrt) def _eval_rewrite_as_csc(self, arg, **kwargs): return 1/csc(arg) def _eval_rewrite_as_sec(self, arg, **kwargs): return 1 / sec(arg - S.Pi / 2, evaluate=False) def _eval_rewrite_as_sinc(self, arg, **kwargs): return arg*sinc(arg) def _eval_conjugate(self): return self.func(self.args[0].conjugate()) def as_real_imag(self, deep=True, **hints): re, im = self._as_real_imag(deep=deep, **hints) return (sin(re)*cosh(im), cos(re)*sinh(im)) def _eval_expand_trig(self, **hints): from sympy import expand_mul from sympy.functions.special.polynomials import chebyshevt, chebyshevu arg = self.args[0] x = None if arg.is_Add: # TODO, implement more if deep stuff here # TODO: Do this more efficiently for more than two terms x, y = arg.as_two_terms() sx = sin(x, evaluate=False)._eval_expand_trig() sy = sin(y, evaluate=False)._eval_expand_trig() cx = cos(x, evaluate=False)._eval_expand_trig() cy = cos(y, evaluate=False)._eval_expand_trig() return sx*cy + sy*cx else: n, x = arg.as_coeff_Mul(rational=True) if n.is_Integer: # n will be positive because of .eval # canonicalization # See http://mathworld.wolfram.com/Multiple-AngleFormulas.html if n.is_odd: return (-1)**((n - 1)/2)*chebyshevt(n, sin(x)) else: return expand_mul((-1)**(n/2 - 1)*cos(x)*chebyshevu(n - 1, sin(x)), deep=False) pi_coeff = _pi_coeff(arg) if pi_coeff is not None: if pi_coeff.is_Rational: return self.rewrite(sqrt) return sin(arg) def _eval_as_leading_term(self, x): from sympy import Order arg = self.args[0].as_leading_term(x) if x in arg.free_symbols and Order(1, x).contains(arg): return arg else: return self.func(arg) def _eval_is_real(self): if self.args[0].is_real: return True def _eval_is_finite(self): arg = self.args[0] if arg.is_real: return True class cos(TrigonometricFunction): """ The cosine function. Returns the cosine of x (measured in radians). Notes ===== See :func:`sin` for notes about automatic evaluation. Examples ======== >>> from sympy import cos, pi >>> from sympy.abc import x >>> cos(x**2).diff(x) -2*x*sin(x**2) >>> cos(1).diff(x) 0 >>> cos(pi) -1 >>> cos(pi/2) 0 >>> cos(2*pi/3) -1/2 >>> cos(pi/12) sqrt(2)/4 + sqrt(6)/4 See Also ======== sin, csc, sec, tan, cot asin, acsc, acos, asec, atan, acot, atan2 References ========== .. [1] https://en.wikipedia.org/wiki/Trigonometric_functions .. [2] http://dlmf.nist.gov/4.14 .. [3] http://functions.wolfram.com/ElementaryFunctions/Cos """ def period(self, symbol=None): return self._period(2*pi, symbol) def fdiff(self, argindex=1): if argindex == 1: return -sin(self.args[0]) else: raise ArgumentIndexError(self, argindex) @classmethod def eval(cls, arg): from sympy.functions.special.polynomials import chebyshevt from sympy.calculus.util import AccumBounds from sympy.sets.setexpr import SetExpr if arg.is_Number: if arg is S.NaN: return S.NaN elif arg is S.Zero: return S.One elif arg is S.Infinity or arg is S.NegativeInfinity: # In this case it is better to return AccumBounds(-1, 1) # rather than returning S.NaN, since AccumBounds(-1, 1) # preserves the information that sin(oo) is between # -1 and 1, where S.NaN does not do that. return AccumBounds(-1, 1) if arg is S.ComplexInfinity: return S.NaN if isinstance(arg, AccumBounds): return sin(arg + S.Pi/2) elif isinstance(arg, SetExpr): return arg._eval_func(cls) if arg.could_extract_minus_sign(): return cls(-arg) i_coeff = arg.as_coefficient(S.ImaginaryUnit) if i_coeff is not None: return cosh(i_coeff) pi_coeff = _pi_coeff(arg) if pi_coeff is not None: if pi_coeff.is_integer: return (S.NegativeOne)**pi_coeff if (2*pi_coeff).is_integer: if pi_coeff.is_even: return (S.NegativeOne)**(pi_coeff/2) elif pi_coeff.is_even is False: return S.Zero if not pi_coeff.is_Rational: narg = pi_coeff*S.Pi if narg != arg: return cls(narg) return None # cosine formula ##################### # https://github.com/sympy/sympy/issues/6048 # explicit calculations are preformed for # cos(k pi/n) for n = 8,10,12,15,20,24,30,40,60,120 # Some other exact values like cos(k pi/240) can be # calculated using a partial-fraction decomposition # by calling cos( X ).rewrite(sqrt) cst_table_some = { 3: S.Half, 5: (sqrt(5) + 1)/4, } if pi_coeff.is_Rational: q = pi_coeff.q p = pi_coeff.p % (2*q) if p > q: narg = (pi_coeff - 1)*S.Pi return -cls(narg) if 2*p > q: narg = (1 - pi_coeff)*S.Pi return -cls(narg) # If nested sqrt's are worse than un-evaluation # you can require q to be in (1, 2, 3, 4, 6, 12) # q <= 12, q=15, q=20, q=24, q=30, q=40, q=60, q=120 return # expressions with 2 or fewer sqrt nestings. table2 = { 12: (3, 4), 20: (4, 5), 30: (5, 6), 15: (6, 10), 24: (6, 8), 40: (8, 10), 60: (20, 30), 120: (40, 60) } if q in table2: a, b = p*S.Pi/table2[q][0], p*S.Pi/table2[q][1] nvala, nvalb = cls(a), cls(b) if None == nvala or None == nvalb: return None return nvala*nvalb + cls(S.Pi/2 - a)*cls(S.Pi/2 - b) if q > 12: return None if q in cst_table_some: cts = cst_table_some[pi_coeff.q] return chebyshevt(pi_coeff.p, cts).expand() if 0 == q % 2: narg = (pi_coeff*2)*S.Pi nval = cls(narg) if None == nval: return None x = (2*pi_coeff + 1)/2 sign_cos = (-1)**((-1 if x < 0 else 1)*int(abs(x))) return sign_cos*sqrt( (1 + nval)/2 ) return None if arg.is_Add: x, m = _peeloff_pi(arg) if m: return cos(m)*cos(x) - sin(m)*sin(x) if isinstance(arg, acos): return arg.args[0] if isinstance(arg, atan): x = arg.args[0] return 1 / sqrt(1 + x**2) if isinstance(arg, atan2): y, x = arg.args return x / sqrt(x**2 + y**2) if isinstance(arg, asin): x = arg.args[0] return sqrt(1 - x ** 2) if isinstance(arg, acot): x = arg.args[0] return 1 / sqrt(1 + 1 / x**2) if isinstance(arg, acsc): x = arg.args[0] return sqrt(1 - 1 / x**2) if isinstance(arg, asec): x = arg.args[0] return 1 / x @staticmethod @cacheit def taylor_term(n, x, *previous_terms): if n < 0 or n % 2 == 1: return S.Zero else: x = sympify(x) if len(previous_terms) > 2: p = previous_terms[-2] return -p * x**2 / (n*(n - 1)) else: return (-1)**(n//2)*x**(n)/factorial(n) def _eval_rewrite_as_exp(self, arg, **kwargs): I = S.ImaginaryUnit if isinstance(arg, TrigonometricFunction) or isinstance(arg, HyperbolicFunction): arg = arg.func(arg.args[0]).rewrite(exp) return (exp(arg*I) + exp(-arg*I)) / 2 def _eval_rewrite_as_Pow(self, arg, **kwargs): if isinstance(arg, log): I = S.ImaginaryUnit x = arg.args[0] return x**I/2 + x**-I/2 def _eval_rewrite_as_sin(self, arg, **kwargs): return sin(arg + S.Pi / 2, evaluate=False) def _eval_rewrite_as_tan(self, arg, **kwargs): tan_half = tan(S.Half*arg)**2 return (1 - tan_half)/(1 + tan_half) def _eval_rewrite_as_sincos(self, arg, **kwargs): return sin(arg)*cos(arg)/sin(arg) def _eval_rewrite_as_cot(self, arg, **kwargs): cot_half = cot(S.Half*arg)**2 return (cot_half - 1)/(cot_half + 1) def _eval_rewrite_as_pow(self, arg, **kwargs): return self._eval_rewrite_as_sqrt(arg) def _eval_rewrite_as_sqrt(self, arg, **kwargs): from sympy.functions.special.polynomials import chebyshevt def migcdex(x): # recursive calcuation of gcd and linear combination # for a sequence of integers. # Given (x1, x2, x3) # Returns (y1, y1, y3, g) # such that g is the gcd and x1*y1+x2*y2+x3*y3 - g = 0 # Note, that this is only one such linear combination. if len(x) == 1: return (1, x[0]) if len(x) == 2: return igcdex(x[0], x[-1]) g = migcdex(x[1:]) u, v, h = igcdex(x[0], g[-1]) return tuple([u] + [v*i for i in g[0:-1] ] + [h]) def ipartfrac(r, factors=None): from sympy.ntheory import factorint if isinstance(r, int): return r if not isinstance(r, Rational): raise TypeError("r is not rational") n = r.q if 2 > r.q*r.q: return r.q if None == factors: a = [n//x**y for x, y in factorint(r.q).items()] else: a = [n//x for x in factors] if len(a) == 1: return [ r ] h = migcdex(a) ans = [ r.p*Rational(i*j, r.q) for i, j in zip(h[:-1], a) ] assert r == sum(ans) return ans pi_coeff = _pi_coeff(arg) if pi_coeff is None: return None if pi_coeff.is_integer: # it was unevaluated return self.func(pi_coeff*S.Pi) if not pi_coeff.is_Rational: return None def _cospi257(): """ Express cos(pi/257) explicitly as a function of radicals Based upon the equations in http://math.stackexchange.com/questions/516142/how-does-cos2-pi-257-look-like-in-real-radicals See also http://www.susqu.edu/brakke/constructions/257-gon.m.txt """ def f1(a, b): return (a + sqrt(a**2 + b))/2, (a - sqrt(a**2 + b))/2 def f2(a, b): return (a - sqrt(a**2 + b))/2 t1, t2 = f1(-1, 256) z1, z3 = f1(t1, 64) z2, z4 = f1(t2, 64) y1, y5 = f1(z1, 4*(5 + t1 + 2*z1)) y6, y2 = f1(z2, 4*(5 + t2 + 2*z2)) y3, y7 = f1(z3, 4*(5 + t1 + 2*z3)) y8, y4 = f1(z4, 4*(5 + t2 + 2*z4)) x1, x9 = f1(y1, -4*(t1 + y1 + y3 + 2*y6)) x2, x10 = f1(y2, -4*(t2 + y2 + y4 + 2*y7)) x3, x11 = f1(y3, -4*(t1 + y3 + y5 + 2*y8)) x4, x12 = f1(y4, -4*(t2 + y4 + y6 + 2*y1)) x5, x13 = f1(y5, -4*(t1 + y5 + y7 + 2*y2)) x6, x14 = f1(y6, -4*(t2 + y6 + y8 + 2*y3)) x15, x7 = f1(y7, -4*(t1 + y7 + y1 + 2*y4)) x8, x16 = f1(y8, -4*(t2 + y8 + y2 + 2*y5)) v1 = f2(x1, -4*(x1 + x2 + x3 + x6)) v2 = f2(x2, -4*(x2 + x3 + x4 + x7)) v3 = f2(x8, -4*(x8 + x9 + x10 + x13)) v4 = f2(x9, -4*(x9 + x10 + x11 + x14)) v5 = f2(x10, -4*(x10 + x11 + x12 + x15)) v6 = f2(x16, -4*(x16 + x1 + x2 + x5)) u1 = -f2(-v1, -4*(v2 + v3)) u2 = -f2(-v4, -4*(v5 + v6)) w1 = -2*f2(-u1, -4*u2) return sqrt(sqrt(2)*sqrt(w1 + 4)/8 + S.Half) cst_table_some = { 3: S.Half, 5: (sqrt(5) + 1)/4, 17: sqrt((15 + sqrt(17))/32 + sqrt(2)*(sqrt(17 - sqrt(17)) + sqrt(sqrt(2)*(-8*sqrt(17 + sqrt(17)) - (1 - sqrt(17)) *sqrt(17 - sqrt(17))) + 6*sqrt(17) + 34))/32), 257: _cospi257() # 65537 is the only other known Fermat prime and the very # large expression is intentionally omitted from SymPy; see # http://www.susqu.edu/brakke/constructions/65537-gon.m.txt } def _fermatCoords(n): # if n can be factored in terms of Fermat primes with # multiplicity of each being 1, return those primes, else # False primes = [] for p_i in cst_table_some: quotient, remainder = divmod(n, p_i) if remainder == 0: n = quotient primes.append(p_i) if n == 1: return tuple(primes) return False if pi_coeff.q in cst_table_some: rv = chebyshevt(pi_coeff.p, cst_table_some[pi_coeff.q]) if pi_coeff.q < 257: rv = rv.expand() return rv if not pi_coeff.q % 2: # recursively remove factors of 2 pico2 = pi_coeff*2 nval = cos(pico2*S.Pi).rewrite(sqrt) x = (pico2 + 1)/2 sign_cos = -1 if int(x) % 2 else 1 return sign_cos*sqrt( (1 + nval)/2 ) FC = _fermatCoords(pi_coeff.q) if FC: decomp = ipartfrac(pi_coeff, FC) X = [(x[1], x[0]*S.Pi) for x in zip(decomp, numbered_symbols('z'))] pcls = cos(sum([x[0] for x in X]))._eval_expand_trig().subs(X) return pcls.rewrite(sqrt) else: decomp = ipartfrac(pi_coeff) X = [(x[1], x[0]*S.Pi) for x in zip(decomp, numbered_symbols('z'))] pcls = cos(sum([x[0] for x in X]))._eval_expand_trig().subs(X) return pcls def _eval_rewrite_as_sec(self, arg, **kwargs): return 1/sec(arg) def _eval_rewrite_as_csc(self, arg, **kwargs): return 1 / sec(arg)._eval_rewrite_as_csc(arg) def _eval_conjugate(self): return self.func(self.args[0].conjugate()) def as_real_imag(self, deep=True, **hints): re, im = self._as_real_imag(deep=deep, **hints) return (cos(re)*cosh(im), -sin(re)*sinh(im)) def _eval_expand_trig(self, **hints): from sympy.functions.special.polynomials import chebyshevt arg = self.args[0] x = None if arg.is_Add: # TODO: Do this more efficiently for more than two terms x, y = arg.as_two_terms() sx = sin(x, evaluate=False)._eval_expand_trig() sy = sin(y, evaluate=False)._eval_expand_trig() cx = cos(x, evaluate=False)._eval_expand_trig() cy = cos(y, evaluate=False)._eval_expand_trig() return cx*cy - sx*sy else: coeff, terms = arg.as_coeff_Mul(rational=True) if coeff.is_Integer: return chebyshevt(coeff, cos(terms)) pi_coeff = _pi_coeff(arg) if pi_coeff is not None: if pi_coeff.is_Rational: return self.rewrite(sqrt) return cos(arg) def _eval_as_leading_term(self, x): from sympy import Order arg = self.args[0].as_leading_term(x) if x in arg.free_symbols and Order(1, x).contains(arg): return S.One else: return self.func(arg) def _eval_is_real(self): if self.args[0].is_real: return True def _eval_is_finite(self): arg = self.args[0] if arg.is_real: return True class tan(TrigonometricFunction): """ The tangent function. Returns the tangent of x (measured in radians). Notes ===== See :func:`sin` for notes about automatic evaluation. Examples ======== >>> from sympy import tan, pi >>> from sympy.abc import x >>> tan(x**2).diff(x) 2*x*(tan(x**2)**2 + 1) >>> tan(1).diff(x) 0 >>> tan(pi/8).expand() -1 + sqrt(2) See Also ======== sin, csc, cos, sec, cot asin, acsc, acos, asec, atan, acot, atan2 References ========== .. [1] https://en.wikipedia.org/wiki/Trigonometric_functions .. [2] http://dlmf.nist.gov/4.14 .. [3] http://functions.wolfram.com/ElementaryFunctions/Tan """ def period(self, symbol=None): return self._period(pi, symbol) def fdiff(self, argindex=1): if argindex == 1: return S.One + self**2 else: raise ArgumentIndexError(self, argindex) def inverse(self, argindex=1): """ Returns the inverse of this function. """ return atan @classmethod def eval(cls, arg): from sympy.calculus.util import AccumBounds if arg.is_Number: if arg is S.NaN: return S.NaN elif arg is S.Zero: return S.Zero elif arg is S.Infinity or arg is S.NegativeInfinity: return AccumBounds(S.NegativeInfinity, S.Infinity) if arg is S.ComplexInfinity: return S.NaN if isinstance(arg, AccumBounds): min, max = arg.min, arg.max d = floor(min/S.Pi) if min is not S.NegativeInfinity: min = min - d*S.Pi if max is not S.Infinity: max = max - d*S.Pi if AccumBounds(min, max).intersection(FiniteSet(S.Pi/2, 3*S.Pi/2)): return AccumBounds(S.NegativeInfinity, S.Infinity) else: return AccumBounds(tan(min), tan(max)) if arg.could_extract_minus_sign(): return -cls(-arg) i_coeff = arg.as_coefficient(S.ImaginaryUnit) if i_coeff is not None: return S.ImaginaryUnit * tanh(i_coeff) pi_coeff = _pi_coeff(arg, 2) if pi_coeff is not None: if pi_coeff.is_integer: return S.Zero if not pi_coeff.is_Rational: narg = pi_coeff*S.Pi if narg != arg: return cls(narg) return None if pi_coeff.is_Rational: if not pi_coeff.q % 2: narg = pi_coeff*S.Pi*2 cresult, sresult = cos(narg), cos(narg - S.Pi/2) if not isinstance(cresult, cos) \ and not isinstance(sresult, cos): if sresult == 0: return S.ComplexInfinity return 1/sresult - cresult/sresult table2 = { 12: (3, 4), 20: (4, 5), 30: (5, 6), 15: (6, 10), 24: (6, 8), 40: (8, 10), 60: (20, 30), 120: (40, 60) } q = pi_coeff.q p = pi_coeff.p % q if q in table2: nvala, nvalb = cls(p*S.Pi/table2[q][0]), cls(p*S.Pi/table2[q][1]) if None == nvala or None == nvalb: return None return (nvala - nvalb)/(1 + nvala*nvalb) narg = ((pi_coeff + S.Half) % 1 - S.Half)*S.Pi # see cos() to specify which expressions should be # expanded automatically in terms of radicals cresult, sresult = cos(narg), cos(narg - S.Pi/2) if not isinstance(cresult, cos) \ and not isinstance(sresult, cos): if cresult == 0: return S.ComplexInfinity return (sresult/cresult) if narg != arg: return cls(narg) if arg.is_Add: x, m = _peeloff_pi(arg) if m: tanm = tan(m) if tanm is S.ComplexInfinity: return -cot(x) else: # tanm == 0 return tan(x) if isinstance(arg, atan): return arg.args[0] if isinstance(arg, atan2): y, x = arg.args return y/x if isinstance(arg, asin): x = arg.args[0] return x / sqrt(1 - x**2) if isinstance(arg, acos): x = arg.args[0] return sqrt(1 - x**2) / x if isinstance(arg, acot): x = arg.args[0] return 1 / x if isinstance(arg, acsc): x = arg.args[0] return 1 / (sqrt(1 - 1 / x**2) * x) if isinstance(arg, asec): x = arg.args[0] return sqrt(1 - 1 / x**2) * x @staticmethod @cacheit def taylor_term(n, x, *previous_terms): from sympy import bernoulli if n < 0 or n % 2 == 0: return S.Zero else: x = sympify(x) a, b = ((n - 1)//2), 2**(n + 1) B = bernoulli(n + 1) F = factorial(n + 1) return (-1)**a * b*(b - 1) * B/F * x**n def _eval_nseries(self, x, n, logx): i = self.args[0].limit(x, 0)*2/S.Pi if i and i.is_Integer: return self.rewrite(cos)._eval_nseries(x, n=n, logx=logx) return Function._eval_nseries(self, x, n=n, logx=logx) def _eval_rewrite_as_Pow(self, arg, **kwargs): if isinstance(arg, log): I = S.ImaginaryUnit x = arg.args[0] return I*(x**-I - x**I)/(x**-I + x**I) def _eval_conjugate(self): return self.func(self.args[0].conjugate()) def as_real_imag(self, deep=True, **hints): re, im = self._as_real_imag(deep=deep, **hints) if im: denom = cos(2*re) + cosh(2*im) return (sin(2*re)/denom, sinh(2*im)/denom) else: return (self.func(re), S.Zero) def _eval_expand_trig(self, **hints): from sympy import im, re arg = self.args[0] x = None if arg.is_Add: from sympy import symmetric_poly n = len(arg.args) TX = [] for x in arg.args: tx = tan(x, evaluate=False)._eval_expand_trig() TX.append(tx) Yg = numbered_symbols('Y') Y = [ next(Yg) for i in range(n) ] p = [0, 0] for i in range(n + 1): p[1 - i % 2] += symmetric_poly(i, Y)*(-1)**((i % 4)//2) return (p[0]/p[1]).subs(list(zip(Y, TX))) else: coeff, terms = arg.as_coeff_Mul(rational=True) if coeff.is_Integer and coeff > 1: I = S.ImaginaryUnit z = Symbol('dummy', real=True) P = ((1 + I*z)**coeff).expand() return (im(P)/re(P)).subs([(z, tan(terms))]) return tan(arg) def _eval_rewrite_as_exp(self, arg, **kwargs): I = S.ImaginaryUnit if isinstance(arg, TrigonometricFunction) or isinstance(arg, HyperbolicFunction): arg = arg.func(arg.args[0]).rewrite(exp) neg_exp, pos_exp = exp(-arg*I), exp(arg*I) return I*(neg_exp - pos_exp)/(neg_exp + pos_exp) def _eval_rewrite_as_sin(self, x, **kwargs): return 2*sin(x)**2/sin(2*x) def _eval_rewrite_as_cos(self, x, **kwargs): return cos(x - S.Pi / 2, evaluate=False) / cos(x) def _eval_rewrite_as_sincos(self, arg, **kwargs): return sin(arg)/cos(arg) def _eval_rewrite_as_cot(self, arg, **kwargs): return 1/cot(arg) def _eval_rewrite_as_sec(self, arg, **kwargs): sin_in_sec_form = sin(arg)._eval_rewrite_as_sec(arg) cos_in_sec_form = cos(arg)._eval_rewrite_as_sec(arg) return sin_in_sec_form / cos_in_sec_form def _eval_rewrite_as_csc(self, arg, **kwargs): sin_in_csc_form = sin(arg)._eval_rewrite_as_csc(arg) cos_in_csc_form = cos(arg)._eval_rewrite_as_csc(arg) return sin_in_csc_form / cos_in_csc_form def _eval_rewrite_as_pow(self, arg, **kwargs): y = self.rewrite(cos).rewrite(pow) if y.has(cos): return None return y def _eval_rewrite_as_sqrt(self, arg, **kwargs): y = self.rewrite(cos).rewrite(sqrt) if y.has(cos): return None return y def _eval_as_leading_term(self, x): from sympy import Order arg = self.args[0].as_leading_term(x) if x in arg.free_symbols and Order(1, x).contains(arg): return arg else: return self.func(arg) def _eval_is_real(self): return self.args[0].is_real def _eval_is_finite(self): arg = self.args[0] if arg.is_imaginary: return True class cot(TrigonometricFunction): """ The cotangent function. Returns the cotangent of x (measured in radians). Notes ===== See :func:`sin` for notes about automatic evaluation. Examples ======== >>> from sympy import cot, pi >>> from sympy.abc import x >>> cot(x**2).diff(x) 2*x*(-cot(x**2)**2 - 1) >>> cot(1).diff(x) 0 >>> cot(pi/12) sqrt(3) + 2 See Also ======== sin, csc, cos, sec, tan asin, acsc, acos, asec, atan, acot, atan2 References ========== .. [1] https://en.wikipedia.org/wiki/Trigonometric_functions .. [2] http://dlmf.nist.gov/4.14 .. [3] http://functions.wolfram.com/ElementaryFunctions/Cot """ def period(self, symbol=None): return self._period(pi, symbol) def fdiff(self, argindex=1): if argindex == 1: return S.NegativeOne - self**2 else: raise ArgumentIndexError(self, argindex) def inverse(self, argindex=1): """ Returns the inverse of this function. """ return acot @classmethod def eval(cls, arg): from sympy.calculus.util import AccumBounds if arg.is_Number: if arg is S.NaN: return S.NaN if arg is S.Zero: return S.ComplexInfinity if arg is S.ComplexInfinity: return S.NaN if isinstance(arg, AccumBounds): return -tan(arg + S.Pi/2) if arg.could_extract_minus_sign(): return -cls(-arg) i_coeff = arg.as_coefficient(S.ImaginaryUnit) if i_coeff is not None: return -S.ImaginaryUnit * coth(i_coeff) pi_coeff = _pi_coeff(arg, 2) if pi_coeff is not None: if pi_coeff.is_integer: return S.ComplexInfinity if not pi_coeff.is_Rational: narg = pi_coeff*S.Pi if narg != arg: return cls(narg) return None if pi_coeff.is_Rational: if pi_coeff.q > 2 and not pi_coeff.q % 2: narg = pi_coeff*S.Pi*2 cresult, sresult = cos(narg), cos(narg - S.Pi/2) if not isinstance(cresult, cos) \ and not isinstance(sresult, cos): return (1 + cresult)/sresult table2 = { 12: (3, 4), 20: (4, 5), 30: (5, 6), 15: (6, 10), 24: (6, 8), 40: (8, 10), 60: (20, 30), 120: (40, 60) } q = pi_coeff.q p = pi_coeff.p % q if q in table2: nvala, nvalb = cls(p*S.Pi/table2[q][0]), cls(p*S.Pi/table2[q][1]) if None == nvala or None == nvalb: return None return (1 + nvala*nvalb)/(nvalb - nvala) narg = (((pi_coeff + S.Half) % 1) - S.Half)*S.Pi # see cos() to specify which expressions should be # expanded automatically in terms of radicals cresult, sresult = cos(narg), cos(narg - S.Pi/2) if not isinstance(cresult, cos) \ and not isinstance(sresult, cos): if sresult == 0: return S.ComplexInfinity return cresult / sresult if narg != arg: return cls(narg) if arg.is_Add: x, m = _peeloff_pi(arg) if m: cotm = cot(m) if cotm is S.ComplexInfinity: return cot(x) else: # cotm == 0 return -tan(x) if isinstance(arg, acot): return arg.args[0] if isinstance(arg, atan): x = arg.args[0] return 1 / x if isinstance(arg, atan2): y, x = arg.args return x/y if isinstance(arg, asin): x = arg.args[0] return sqrt(1 - x**2) / x if isinstance(arg, acos): x = arg.args[0] return x / sqrt(1 - x**2) if isinstance(arg, acsc): x = arg.args[0] return sqrt(1 - 1 / x**2) * x if isinstance(arg, asec): x = arg.args[0] return 1 / (sqrt(1 - 1 / x**2) * x) @staticmethod @cacheit def taylor_term(n, x, *previous_terms): from sympy import bernoulli if n == 0: return 1 / sympify(x) elif n < 0 or n % 2 == 0: return S.Zero else: x = sympify(x) B = bernoulli(n + 1) F = factorial(n + 1) return (-1)**((n + 1)//2) * 2**(n + 1) * B/F * x**n def _eval_nseries(self, x, n, logx): i = self.args[0].limit(x, 0)/S.Pi if i and i.is_Integer: return self.rewrite(cos)._eval_nseries(x, n=n, logx=logx) return self.rewrite(tan)._eval_nseries(x, n=n, logx=logx) def _eval_conjugate(self): return self.func(self.args[0].conjugate()) def as_real_imag(self, deep=True, **hints): re, im = self._as_real_imag(deep=deep, **hints) if im: denom = cos(2*re) - cosh(2*im) return (-sin(2*re)/denom, -sinh(2*im)/denom) else: return (self.func(re), S.Zero) def _eval_rewrite_as_exp(self, arg, **kwargs): I = S.ImaginaryUnit if isinstance(arg, TrigonometricFunction) or isinstance(arg, HyperbolicFunction): arg = arg.func(arg.args[0]).rewrite(exp) neg_exp, pos_exp = exp(-arg*I), exp(arg*I) return I*(pos_exp + neg_exp)/(pos_exp - neg_exp) def _eval_rewrite_as_Pow(self, arg, **kwargs): if isinstance(arg, log): I = S.ImaginaryUnit x = arg.args[0] return -I*(x**-I + x**I)/(x**-I - x**I) def _eval_rewrite_as_sin(self, x, **kwargs): return sin(2*x)/(2*(sin(x)**2)) def _eval_rewrite_as_cos(self, x, **kwargs): return cos(x) / cos(x - S.Pi / 2, evaluate=False) def _eval_rewrite_as_sincos(self, arg, **kwargs): return cos(arg)/sin(arg) def _eval_rewrite_as_tan(self, arg, **kwargs): return 1/tan(arg) def _eval_rewrite_as_sec(self, arg, **kwargs): cos_in_sec_form = cos(arg)._eval_rewrite_as_sec(arg) sin_in_sec_form = sin(arg)._eval_rewrite_as_sec(arg) return cos_in_sec_form / sin_in_sec_form def _eval_rewrite_as_csc(self, arg, **kwargs): cos_in_csc_form = cos(arg)._eval_rewrite_as_csc(arg) sin_in_csc_form = sin(arg)._eval_rewrite_as_csc(arg) return cos_in_csc_form / sin_in_csc_form def _eval_rewrite_as_pow(self, arg, **kwargs): y = self.rewrite(cos).rewrite(pow) if y.has(cos): return None return y def _eval_rewrite_as_sqrt(self, arg, **kwargs): y = self.rewrite(cos).rewrite(sqrt) if y.has(cos): return None return y def _eval_as_leading_term(self, x): from sympy import Order arg = self.args[0].as_leading_term(x) if x in arg.free_symbols and Order(1, x).contains(arg): return 1/arg else: return self.func(arg) def _eval_is_real(self): return self.args[0].is_real def _eval_expand_trig(self, **hints): from sympy import im, re arg = self.args[0] x = None if arg.is_Add: from sympy import symmetric_poly n = len(arg.args) CX = [] for x in arg.args: cx = cot(x, evaluate=False)._eval_expand_trig() CX.append(cx) Yg = numbered_symbols('Y') Y = [ next(Yg) for i in range(n) ] p = [0, 0] for i in range(n, -1, -1): p[(n - i) % 2] += symmetric_poly(i, Y)*(-1)**(((n - i) % 4)//2) return (p[0]/p[1]).subs(list(zip(Y, CX))) else: coeff, terms = arg.as_coeff_Mul(rational=True) if coeff.is_Integer and coeff > 1: I = S.ImaginaryUnit z = Symbol('dummy', real=True) P = ((z + I)**coeff).expand() return (re(P)/im(P)).subs([(z, cot(terms))]) return cot(arg) def _eval_is_finite(self): arg = self.args[0] if arg.is_imaginary: return True def _eval_subs(self, old, new): if self == old: return new arg = self.args[0] argnew = arg.subs(old, new) if arg != argnew and (argnew/S.Pi).is_integer: return S.ComplexInfinity return cot(argnew) class ReciprocalTrigonometricFunction(TrigonometricFunction): """Base class for reciprocal functions of trigonometric functions. """ _reciprocal_of = None # mandatory, to be defined in subclass # _is_even and _is_odd are used for correct evaluation of csc(-x), sec(-x) # TODO refactor into TrigonometricFunction common parts of # trigonometric functions eval() like even/odd, func(x+2*k*pi), etc. _is_even = None # optional, to be defined in subclass _is_odd = None # optional, to be defined in subclass @classmethod def eval(cls, arg): if arg.could_extract_minus_sign(): if cls._is_even: return cls(-arg) if cls._is_odd: return -cls(-arg) pi_coeff = _pi_coeff(arg) if (pi_coeff is not None and not (2*pi_coeff).is_integer and pi_coeff.is_Rational): q = pi_coeff.q p = pi_coeff.p % (2*q) if p > q: narg = (pi_coeff - 1)*S.Pi return -cls(narg) if 2*p > q: narg = (1 - pi_coeff)*S.Pi if cls._is_odd: return cls(narg) elif cls._is_even: return -cls(narg) if hasattr(arg, 'inverse') and arg.inverse() == cls: return arg.args[0] t = cls._reciprocal_of.eval(arg) if t is None: return t elif any(isinstance(i, cos) for i in (t, -t)): return (1/t).rewrite(sec) elif any(isinstance(i, sin) for i in (t, -t)): return (1/t).rewrite(csc) else: return 1/t def _call_reciprocal(self, method_name, *args, **kwargs): # Calls method_name on _reciprocal_of o = self._reciprocal_of(self.args[0]) return getattr(o, method_name)(*args, **kwargs) def _calculate_reciprocal(self, method_name, *args, **kwargs): # If calling method_name on _reciprocal_of returns a value != None # then return the reciprocal of that value t = self._call_reciprocal(method_name, *args, **kwargs) return 1/t if t is not None else t def _rewrite_reciprocal(self, method_name, arg): # Special handling for rewrite functions. If reciprocal rewrite returns # unmodified expression, then return None t = self._call_reciprocal(method_name, arg) if t is not None and t != self._reciprocal_of(arg): return 1/t def _period(self, symbol): f = self.args[0] return self._reciprocal_of(f).period(symbol) def fdiff(self, argindex=1): return -self._calculate_reciprocal("fdiff", argindex)/self**2 def _eval_rewrite_as_exp(self, arg, **kwargs): return self._rewrite_reciprocal("_eval_rewrite_as_exp", arg) def _eval_rewrite_as_Pow(self, arg, **kwargs): return self._rewrite_reciprocal("_eval_rewrite_as_Pow", arg) def _eval_rewrite_as_sin(self, arg, **kwargs): return self._rewrite_reciprocal("_eval_rewrite_as_sin", arg) def _eval_rewrite_as_cos(self, arg, **kwargs): return self._rewrite_reciprocal("_eval_rewrite_as_cos", arg) def _eval_rewrite_as_tan(self, arg, **kwargs): return self._rewrite_reciprocal("_eval_rewrite_as_tan", arg) def _eval_rewrite_as_pow(self, arg, **kwargs): return self._rewrite_reciprocal("_eval_rewrite_as_pow", arg) def _eval_rewrite_as_sqrt(self, arg, **kwargs): return self._rewrite_reciprocal("_eval_rewrite_as_sqrt", arg) def _eval_conjugate(self): return self.func(self.args[0].conjugate()) def as_real_imag(self, deep=True, **hints): return (1/self._reciprocal_of(self.args[0])).as_real_imag(deep, **hints) def _eval_expand_trig(self, **hints): return self._calculate_reciprocal("_eval_expand_trig", **hints) def _eval_is_real(self): return self._reciprocal_of(self.args[0])._eval_is_real() def _eval_as_leading_term(self, x): return (1/self._reciprocal_of(self.args[0]))._eval_as_leading_term(x) def _eval_is_finite(self): return (1/self._reciprocal_of(self.args[0])).is_finite def _eval_nseries(self, x, n, logx): return (1/self._reciprocal_of(self.args[0]))._eval_nseries(x, n, logx) class sec(ReciprocalTrigonometricFunction): """ The secant function. Returns the secant of x (measured in radians). Notes ===== See :func:`sin` for notes about automatic evaluation. Examples ======== >>> from sympy import sec >>> from sympy.abc import x >>> sec(x**2).diff(x) 2*x*tan(x**2)*sec(x**2) >>> sec(1).diff(x) 0 See Also ======== sin, csc, cos, tan, cot asin, acsc, acos, asec, atan, acot, atan2 References ========== .. [1] https://en.wikipedia.org/wiki/Trigonometric_functions .. [2] http://dlmf.nist.gov/4.14 .. [3] http://functions.wolfram.com/ElementaryFunctions/Sec """ _reciprocal_of = cos _is_even = True def period(self, symbol=None): return self._period(symbol) def _eval_rewrite_as_cot(self, arg, **kwargs): cot_half_sq = cot(arg/2)**2 return (cot_half_sq + 1)/(cot_half_sq - 1) def _eval_rewrite_as_cos(self, arg, **kwargs): return (1/cos(arg)) def _eval_rewrite_as_sincos(self, arg, **kwargs): return sin(arg)/(cos(arg)*sin(arg)) def _eval_rewrite_as_sin(self, arg, **kwargs): return (1 / cos(arg)._eval_rewrite_as_sin(arg)) def _eval_rewrite_as_tan(self, arg, **kwargs): return (1 / cos(arg)._eval_rewrite_as_tan(arg)) def _eval_rewrite_as_csc(self, arg, **kwargs): return csc(pi / 2 - arg, evaluate=False) def fdiff(self, argindex=1): if argindex == 1: return tan(self.args[0])*sec(self.args[0]) else: raise ArgumentIndexError(self, argindex) @staticmethod @cacheit def taylor_term(n, x, *previous_terms): # Reference Formula: # http://functions.wolfram.com/ElementaryFunctions/Sec/06/01/02/01/ from sympy.functions.combinatorial.numbers import euler if n < 0 or n % 2 == 1: return S.Zero else: x = sympify(x) k = n//2 return (-1)**k*euler(2*k)/factorial(2*k)*x**(2*k) class csc(ReciprocalTrigonometricFunction): """ The cosecant function. Returns the cosecant of x (measured in radians). Notes ===== See :func:`sin` for notes about automatic evaluation. Examples ======== >>> from sympy import csc >>> from sympy.abc import x >>> csc(x**2).diff(x) -2*x*cot(x**2)*csc(x**2) >>> csc(1).diff(x) 0 See Also ======== sin, cos, sec, tan, cot asin, acsc, acos, asec, atan, acot, atan2 References ========== .. [1] https://en.wikipedia.org/wiki/Trigonometric_functions .. [2] http://dlmf.nist.gov/4.14 .. [3] http://functions.wolfram.com/ElementaryFunctions/Csc """ _reciprocal_of = sin _is_odd = True def period(self, symbol=None): return self._period(symbol) def _eval_rewrite_as_sin(self, arg, **kwargs): return (1/sin(arg)) def _eval_rewrite_as_sincos(self, arg, **kwargs): return cos(arg)/(sin(arg)*cos(arg)) def _eval_rewrite_as_cot(self, arg, **kwargs): cot_half = cot(arg/2) return (1 + cot_half**2)/(2*cot_half) def _eval_rewrite_as_cos(self, arg, **kwargs): return (1 / sin(arg)._eval_rewrite_as_cos(arg)) def _eval_rewrite_as_sec(self, arg, **kwargs): return sec(pi / 2 - arg, evaluate=False) def _eval_rewrite_as_tan(self, arg, **kwargs): return (1 / sin(arg)._eval_rewrite_as_tan(arg)) def fdiff(self, argindex=1): if argindex == 1: return -cot(self.args[0])*csc(self.args[0]) else: raise ArgumentIndexError(self, argindex) @staticmethod @cacheit def taylor_term(n, x, *previous_terms): from sympy import bernoulli if n == 0: return 1/sympify(x) elif n < 0 or n % 2 == 0: return S.Zero else: x = sympify(x) k = n//2 + 1 return ((-1)**(k - 1)*2*(2**(2*k - 1) - 1)* bernoulli(2*k)*x**(2*k - 1)/factorial(2*k)) class sinc(Function): r"""Represents unnormalized sinc function Examples ======== >>> from sympy import sinc, oo, jn, Product, Symbol >>> from sympy.abc import x >>> sinc(x) sinc(x) * Automated Evaluation >>> sinc(0) 1 >>> sinc(oo) 0 * Differentiation >>> sinc(x).diff() (x*cos(x) - sin(x))/x**2 * Series Expansion >>> sinc(x).series() 1 - x**2/6 + x**4/120 + O(x**6) * As zero'th order spherical Bessel Function >>> sinc(x).rewrite(jn) jn(0, x) References ========== .. [1] https://en.wikipedia.org/wiki/Sinc_function """ def fdiff(self, argindex=1): x = self.args[0] if argindex == 1: return (x*cos(x) - sin(x)) / x**2 else: raise ArgumentIndexError(self, argindex) @classmethod def eval(cls, arg): if arg.is_zero: return S.One if arg.is_Number: if arg in [S.Infinity, -S.Infinity]: return S.Zero elif arg is S.NaN: return S.NaN if arg is S.ComplexInfinity: return S.NaN if arg.could_extract_minus_sign(): return cls(-arg) pi_coeff = _pi_coeff(arg) if pi_coeff is not None: if pi_coeff.is_integer: if fuzzy_not(arg.is_zero): return S.Zero elif (2*pi_coeff).is_integer: return S.NegativeOne**(pi_coeff - S.Half) / arg def _eval_nseries(self, x, n, logx): x = self.args[0] return (sin(x)/x)._eval_nseries(x, n, logx) def _eval_rewrite_as_jn(self, arg, **kwargs): from sympy.functions.special.bessel import jn return jn(0, arg) def _eval_rewrite_as_sin(self, arg, **kwargs): return Piecewise((sin(arg)/arg, Ne(arg, 0)), (1, True)) ############################################################################### ########################### TRIGONOMETRIC INVERSES ############################ ############################################################################### class InverseTrigonometricFunction(Function): """Base class for inverse trigonometric functions.""" pass class asin(InverseTrigonometricFunction): """ The inverse sine function. Returns the arcsine of x in radians. Notes ===== asin(x) will evaluate automatically in the cases oo, -oo, 0, 1, -1 and for some instances when the result is a rational multiple of pi (see the eval class method). Examples ======== >>> from sympy import asin, oo, pi >>> asin(1) pi/2 >>> asin(-1) -pi/2 See Also ======== sin, csc, cos, sec, tan, cot acsc, acos, asec, atan, acot, atan2 References ========== .. [1] https://en.wikipedia.org/wiki/Inverse_trigonometric_functions .. [2] http://dlmf.nist.gov/4.23 .. [3] http://functions.wolfram.com/ElementaryFunctions/ArcSin """ def fdiff(self, argindex=1): if argindex == 1: return 1/sqrt(1 - self.args[0]**2) else: raise ArgumentIndexError(self, argindex) def _eval_is_rational(self): s = self.func(*self.args) if s.func == self.func: if s.args[0].is_rational: return False else: return s.is_rational def _eval_is_positive(self): return self._eval_is_real() and self.args[0].is_positive def _eval_is_negative(self): return self._eval_is_real() and self.args[0].is_negative @classmethod def eval(cls, arg): if arg.is_Number: if arg is S.NaN: return S.NaN elif arg is S.Infinity: return S.NegativeInfinity * S.ImaginaryUnit elif arg is S.NegativeInfinity: return S.Infinity * S.ImaginaryUnit elif arg is S.Zero: return S.Zero elif arg is S.One: return S.Pi / 2 elif arg is S.NegativeOne: return -S.Pi / 2 if arg is S.ComplexInfinity: return S.ComplexInfinity if arg.could_extract_minus_sign(): return -cls(-arg) if arg.is_number: cst_table = { sqrt(3)/2: 3, -sqrt(3)/2: -3, sqrt(2)/2: 4, -sqrt(2)/2: -4, 1/sqrt(2): 4, -1/sqrt(2): -4, sqrt((5 - sqrt(5))/8): 5, -sqrt((5 - sqrt(5))/8): -5, S.Half: 6, -S.Half: -6, sqrt(2 - sqrt(2))/2: 8, -sqrt(2 - sqrt(2))/2: -8, (sqrt(5) - 1)/4: 10, (1 - sqrt(5))/4: -10, (sqrt(3) - 1)/sqrt(2**3): 12, (1 - sqrt(3))/sqrt(2**3): -12, (sqrt(5) + 1)/4: S(10)/3, -(sqrt(5) + 1)/4: -S(10)/3 } if arg in cst_table: return S.Pi / cst_table[arg] i_coeff = arg.as_coefficient(S.ImaginaryUnit) if i_coeff is not None: return S.ImaginaryUnit * asinh(i_coeff) if isinstance(arg, sin): ang = arg.args[0] if ang.is_comparable: ang %= 2*pi # restrict to [0,2*pi) if ang > pi: # restrict to (-pi,pi] ang = pi - ang # restrict to [-pi/2,pi/2] if ang > pi/2: ang = pi - ang if ang < -pi/2: ang = -pi - ang return ang if isinstance(arg, cos): # acos(x) + asin(x) = pi/2 ang = arg.args[0] if ang.is_comparable: return pi/2 - acos(arg) @staticmethod @cacheit def taylor_term(n, x, *previous_terms): if n < 0 or n % 2 == 0: return S.Zero else: x = sympify(x) if len(previous_terms) >= 2 and n > 2: p = previous_terms[-2] return p * (n - 2)**2/(n*(n - 1)) * x**2 else: k = (n - 1) // 2 R = RisingFactorial(S.Half, k) F = factorial(k) return R / F * x**n / n def _eval_as_leading_term(self, x): from sympy import Order arg = self.args[0].as_leading_term(x) if x in arg.free_symbols and Order(1, x).contains(arg): return arg else: return self.func(arg) def _eval_rewrite_as_acos(self, x, **kwargs): return S.Pi/2 - acos(x) def _eval_rewrite_as_atan(self, x, **kwargs): return 2*atan(x/(1 + sqrt(1 - x**2))) def _eval_rewrite_as_log(self, x, **kwargs): return -S.ImaginaryUnit*log(S.ImaginaryUnit*x + sqrt(1 - x**2)) def _eval_rewrite_as_acot(self, arg, **kwargs): return 2*acot((1 + sqrt(1 - arg**2))/arg) def _eval_rewrite_as_asec(self, arg, **kwargs): return S.Pi/2 - asec(1/arg) def _eval_rewrite_as_acsc(self, arg, **kwargs): return acsc(1/arg) def _eval_is_real(self): x = self.args[0] return x.is_real and (1 - abs(x)).is_nonnegative def inverse(self, argindex=1): """ Returns the inverse of this function. """ return sin class acos(InverseTrigonometricFunction): """ The inverse cosine function. Returns the arc cosine of x (measured in radians). Notes ===== ``acos(x)`` will evaluate automatically in the cases ``oo``, ``-oo``, ``0``, ``1``, ``-1``. ``acos(zoo)`` evaluates to ``zoo`` (see note in :py:class`sympy.functions.elementary.trigonometric.asec`) Examples ======== >>> from sympy import acos, oo, pi >>> acos(1) 0 >>> acos(0) pi/2 >>> acos(oo) oo*I See Also ======== sin, csc, cos, sec, tan, cot asin, acsc, asec, atan, acot, atan2 References ========== .. [1] https://en.wikipedia.org/wiki/Inverse_trigonometric_functions .. [2] http://dlmf.nist.gov/4.23 .. [3] http://functions.wolfram.com/ElementaryFunctions/ArcCos """ def fdiff(self, argindex=1): if argindex == 1: return -1/sqrt(1 - self.args[0]**2) else: raise ArgumentIndexError(self, argindex) def _eval_is_rational(self): s = self.func(*self.args) if s.func == self.func: if s.args[0].is_rational: return False else: return s.is_rational @classmethod def eval(cls, arg): if arg.is_Number: if arg is S.NaN: return S.NaN elif arg is S.Infinity: return S.Infinity * S.ImaginaryUnit elif arg is S.NegativeInfinity: return S.NegativeInfinity * S.ImaginaryUnit elif arg is S.Zero: return S.Pi / 2 elif arg is S.One: return S.Zero elif arg is S.NegativeOne: return S.Pi if arg is S.ComplexInfinity: return S.ComplexInfinity if arg.is_number: cst_table = { S.Half: S.Pi/3, -S.Half: 2*S.Pi/3, sqrt(2)/2: S.Pi/4, -sqrt(2)/2: 3*S.Pi/4, 1/sqrt(2): S.Pi/4, -1/sqrt(2): 3*S.Pi/4, sqrt(3)/2: S.Pi/6, -sqrt(3)/2: 5*S.Pi/6, } if arg in cst_table: return cst_table[arg] if isinstance(arg, cos): ang = arg.args[0] if ang.is_comparable: ang %= 2*pi # restrict to [0,2*pi) if ang > pi: # restrict to [0,pi] ang = 2*pi - ang return ang if isinstance(arg, sin): # acos(x) + asin(x) = pi/2 ang = arg.args[0] if ang.is_comparable: return pi/2 - asin(arg) @staticmethod @cacheit def taylor_term(n, x, *previous_terms): if n == 0: return S.Pi / 2 elif n < 0 or n % 2 == 0: return S.Zero else: x = sympify(x) if len(previous_terms) >= 2 and n > 2: p = previous_terms[-2] return p * (n - 2)**2/(n*(n - 1)) * x**2 else: k = (n - 1) // 2 R = RisingFactorial(S.Half, k) F = factorial(k) return -R / F * x**n / n def _eval_as_leading_term(self, x): from sympy import Order arg = self.args[0].as_leading_term(x) if x in arg.free_symbols and Order(1, x).contains(arg): return arg else: return self.func(arg) def _eval_is_real(self): x = self.args[0] return x.is_real and (1 - abs(x)).is_nonnegative def _eval_is_nonnegative(self): return self._eval_is_real() def _eval_nseries(self, x, n, logx): return self._eval_rewrite_as_log(self.args[0])._eval_nseries(x, n, logx) def _eval_rewrite_as_log(self, x, **kwargs): return S.Pi/2 + S.ImaginaryUnit * \ log(S.ImaginaryUnit * x + sqrt(1 - x**2)) def _eval_rewrite_as_asin(self, x, **kwargs): return S.Pi/2 - asin(x) def _eval_rewrite_as_atan(self, x, **kwargs): return atan(sqrt(1 - x**2)/x) + (S.Pi/2)*(1 - x*sqrt(1/x**2)) def inverse(self, argindex=1): """ Returns the inverse of this function. """ return cos def _eval_rewrite_as_acot(self, arg, **kwargs): return S.Pi/2 - 2*acot((1 + sqrt(1 - arg**2))/arg) def _eval_rewrite_as_asec(self, arg, **kwargs): return asec(1/arg) def _eval_rewrite_as_acsc(self, arg, **kwargs): return S.Pi/2 - acsc(1/arg) def _eval_conjugate(self): z = self.args[0] r = self.func(self.args[0].conjugate()) if z.is_real is False: return r elif z.is_real and (z + 1).is_nonnegative and (z - 1).is_nonpositive: return r class atan(InverseTrigonometricFunction): """ The inverse tangent function. Returns the arc tangent of x (measured in radians). Notes ===== atan(x) will evaluate automatically in the cases oo, -oo, 0, 1, -1. Examples ======== >>> from sympy import atan, oo, pi >>> atan(0) 0 >>> atan(1) pi/4 >>> atan(oo) pi/2 See Also ======== sin, csc, cos, sec, tan, cot asin, acsc, acos, asec, acot, atan2 References ========== .. [1] https://en.wikipedia.org/wiki/Inverse_trigonometric_functions .. [2] http://dlmf.nist.gov/4.23 .. [3] http://functions.wolfram.com/ElementaryFunctions/ArcTan """ def fdiff(self, argindex=1): if argindex == 1: return 1/(1 + self.args[0]**2) else: raise ArgumentIndexError(self, argindex) def _eval_is_rational(self): s = self.func(*self.args) if s.func == self.func: if s.args[0].is_rational: return False else: return s.is_rational def _eval_is_positive(self): return self.args[0].is_positive def _eval_is_nonnegative(self): return self.args[0].is_nonnegative @classmethod def eval(cls, arg): if arg.is_Number: if arg is S.NaN: return S.NaN elif arg is S.Infinity: return S.Pi / 2 elif arg is S.NegativeInfinity: return -S.Pi / 2 elif arg is S.Zero: return S.Zero elif arg is S.One: return S.Pi / 4 elif arg is S.NegativeOne: return -S.Pi / 4 if arg is S.ComplexInfinity: from sympy.calculus.util import AccumBounds return AccumBounds(-S.Pi/2, S.Pi/2) if arg.could_extract_minus_sign(): return -cls(-arg) if arg.is_number: cst_table = { sqrt(3)/3: 6, -sqrt(3)/3: -6, 1/sqrt(3): 6, -1/sqrt(3): -6, sqrt(3): 3, -sqrt(3): -3, (1 + sqrt(2)): S(8)/3, -(1 + sqrt(2)): S(8)/3, (sqrt(2) - 1): 8, (1 - sqrt(2)): -8, sqrt((5 + 2*sqrt(5))): S(5)/2, -sqrt((5 + 2*sqrt(5))): -S(5)/2, (2 - sqrt(3)): 12, -(2 - sqrt(3)): -12 } if arg in cst_table: return S.Pi / cst_table[arg] i_coeff = arg.as_coefficient(S.ImaginaryUnit) if i_coeff is not None: return S.ImaginaryUnit * atanh(i_coeff) if isinstance(arg, tan): ang = arg.args[0] if ang.is_comparable: ang %= pi # restrict to [0,pi) if ang > pi/2: # restrict to [-pi/2,pi/2] ang -= pi return ang if isinstance(arg, cot): # atan(x) + acot(x) = pi/2 ang = arg.args[0] if ang.is_comparable: ang = pi/2 - acot(arg) if ang > pi/2: # restrict to [-pi/2,pi/2] ang -= pi return ang @staticmethod @cacheit def taylor_term(n, x, *previous_terms): if n < 0 or n % 2 == 0: return S.Zero else: x = sympify(x) return (-1)**((n - 1)//2) * x**n / n def _eval_as_leading_term(self, x): from sympy import Order arg = self.args[0].as_leading_term(x) if x in arg.free_symbols and Order(1, x).contains(arg): return arg else: return self.func(arg) def _eval_is_real(self): return self.args[0].is_real def _eval_rewrite_as_log(self, x, **kwargs): return S.ImaginaryUnit/2 * (log(S(1) - S.ImaginaryUnit * x) - log(S(1) + S.ImaginaryUnit * x)) def _eval_aseries(self, n, args0, x, logx): if args0[0] == S.Infinity: return (S.Pi/2 - atan(1/self.args[0]))._eval_nseries(x, n, logx) elif args0[0] == S.NegativeInfinity: return (-S.Pi/2 - atan(1/self.args[0]))._eval_nseries(x, n, logx) else: return super(atan, self)._eval_aseries(n, args0, x, logx) def inverse(self, argindex=1): """ Returns the inverse of this function. """ return tan def _eval_rewrite_as_asin(self, arg, **kwargs): return sqrt(arg**2)/arg*(S.Pi/2 - asin(1/sqrt(1 + arg**2))) def _eval_rewrite_as_acos(self, arg, **kwargs): return sqrt(arg**2)/arg*acos(1/sqrt(1 + arg**2)) def _eval_rewrite_as_acot(self, arg, **kwargs): return acot(1/arg) def _eval_rewrite_as_asec(self, arg, **kwargs): return sqrt(arg**2)/arg*asec(sqrt(1 + arg**2)) def _eval_rewrite_as_acsc(self, arg, **kwargs): return sqrt(arg**2)/arg*(S.Pi/2 - acsc(sqrt(1 + arg**2))) class acot(InverseTrigonometricFunction): """ The inverse cotangent function. Returns the arc cotangent of x (measured in radians). See Also ======== sin, csc, cos, sec, tan, cot asin, acsc, acos, asec, atan, atan2 References ========== .. [1] https://en.wikipedia.org/wiki/Inverse_trigonometric_functions .. [2] http://dlmf.nist.gov/4.23 .. [3] http://functions.wolfram.com/ElementaryFunctions/ArcCot """ def fdiff(self, argindex=1): if argindex == 1: return -1 / (1 + self.args[0]**2) else: raise ArgumentIndexError(self, argindex) def _eval_is_rational(self): s = self.func(*self.args) if s.func == self.func: if s.args[0].is_rational: return False else: return s.is_rational def _eval_is_positive(self): return self.args[0].is_nonnegative def _eval_is_negative(self): return self.args[0].is_negative def _eval_is_real(self): return self.args[0].is_real @classmethod def eval(cls, arg): if arg.is_Number: if arg is S.NaN: return S.NaN elif arg is S.Infinity: return S.Zero elif arg is S.NegativeInfinity: return S.Zero elif arg is S.Zero: return S.Pi/ 2 elif arg is S.One: return S.Pi / 4 elif arg is S.NegativeOne: return -S.Pi / 4 if arg is S.ComplexInfinity: return S.Zero if arg.could_extract_minus_sign(): return -cls(-arg) if arg.is_number: cst_table = { sqrt(3)/3: 3, -sqrt(3)/3: -3, 1/sqrt(3): 3, -1/sqrt(3): -3, sqrt(3): 6, -sqrt(3): -6, (1 + sqrt(2)): 8, -(1 + sqrt(2)): -8, (1 - sqrt(2)): -S(8)/3, (sqrt(2) - 1): S(8)/3, sqrt(5 + 2*sqrt(5)): 10, -sqrt(5 + 2*sqrt(5)): -10, (2 + sqrt(3)): 12, -(2 + sqrt(3)): -12, (2 - sqrt(3)): S(12)/5, -(2 - sqrt(3)): -S(12)/5, } if arg in cst_table: return S.Pi / cst_table[arg] i_coeff = arg.as_coefficient(S.ImaginaryUnit) if i_coeff is not None: return -S.ImaginaryUnit * acoth(i_coeff) if isinstance(arg, cot): ang = arg.args[0] if ang.is_comparable: ang %= pi # restrict to [0,pi) if ang > pi/2: # restrict to (-pi/2,pi/2] ang -= pi; return ang if isinstance(arg, tan): # atan(x) + acot(x) = pi/2 ang = arg.args[0] if ang.is_comparable: ang = pi/2 - atan(arg) if ang > pi/2: # restrict to (-pi/2,pi/2] ang -= pi return ang @staticmethod @cacheit def taylor_term(n, x, *previous_terms): if n == 0: return S.Pi / 2 # FIX THIS elif n < 0 or n % 2 == 0: return S.Zero else: x = sympify(x) return (-1)**((n + 1)//2) * x**n / n def _eval_as_leading_term(self, x): from sympy import Order arg = self.args[0].as_leading_term(x) if x in arg.free_symbols and Order(1, x).contains(arg): return arg else: return self.func(arg) def _eval_aseries(self, n, args0, x, logx): if args0[0] == S.Infinity: return (S.Pi/2 - acot(1/self.args[0]))._eval_nseries(x, n, logx) elif args0[0] == S.NegativeInfinity: return (3*S.Pi/2 - acot(1/self.args[0]))._eval_nseries(x, n, logx) else: return super(atan, self)._eval_aseries(n, args0, x, logx) def _eval_rewrite_as_log(self, x, **kwargs): return S.ImaginaryUnit/2 * (log(1 - S.ImaginaryUnit/x) - log(1 + S.ImaginaryUnit/x)) def inverse(self, argindex=1): """ Returns the inverse of this function. """ return cot def _eval_rewrite_as_asin(self, arg, **kwargs): return (arg*sqrt(1/arg**2)* (S.Pi/2 - asin(sqrt(-arg**2)/sqrt(-arg**2 - 1)))) def _eval_rewrite_as_acos(self, arg, **kwargs): return arg*sqrt(1/arg**2)*acos(sqrt(-arg**2)/sqrt(-arg**2 - 1)) def _eval_rewrite_as_atan(self, arg, **kwargs): return atan(1/arg) def _eval_rewrite_as_asec(self, arg, **kwargs): return arg*sqrt(1/arg**2)*asec(sqrt((1 + arg**2)/arg**2)) def _eval_rewrite_as_acsc(self, arg, **kwargs): return arg*sqrt(1/arg**2)*(S.Pi/2 - acsc(sqrt((1 + arg**2)/arg**2))) class asec(InverseTrigonometricFunction): r""" The inverse secant function. Returns the arc secant of x (measured in radians). Notes ===== ``asec(x)`` will evaluate automatically in the cases ``oo``, ``-oo``, ``0``, ``1``, ``-1``. ``asec(x)`` has branch cut in the interval [-1, 1]. For complex arguments, it can be defined [4]_ as .. math:: sec^{-1}(z) = -i*(log(\sqrt{1 - z^2} + 1) / z) At ``x = 0``, for positive branch cut, the limit evaluates to ``zoo``. For negative branch cut, the limit .. math:: \lim_{z \to 0}-i*(log(-\sqrt{1 - z^2} + 1) / z) simplifies to :math:`-i*log(z/2 + O(z^3))` which ultimately evaluates to ``zoo``. As ``asex(x)`` = ``asec(1/x)``, a similar argument can be given for ``acos(x)``. Examples ======== >>> from sympy import asec, oo, pi >>> asec(1) 0 >>> asec(-1) pi See Also ======== sin, csc, cos, sec, tan, cot asin, acsc, acos, atan, acot, atan2 References ========== .. [1] https://en.wikipedia.org/wiki/Inverse_trigonometric_functions .. [2] http://dlmf.nist.gov/4.23 .. [3] http://functions.wolfram.com/ElementaryFunctions/ArcSec .. [4] http://reference.wolfram.com/language/ref/ArcSec.html """ @classmethod def eval(cls, arg): if arg.is_zero: return S.ComplexInfinity if arg.is_Number: if arg is S.NaN: return S.NaN elif arg is S.One: return S.Zero elif arg is S.NegativeOne: return S.Pi if arg in [S.Infinity, S.NegativeInfinity, S.ComplexInfinity]: return S.Pi/2 if isinstance(arg, sec): ang = arg.args[0] if ang.is_comparable: ang %= 2*pi # restrict to [0,2*pi) if ang > pi: # restrict to [0,pi] ang = 2*pi - ang return ang if isinstance(arg, csc): # asec(x) + acsc(x) = pi/2 ang = arg.args[0] if ang.is_comparable: return pi/2 - acsc(arg) def fdiff(self, argindex=1): if argindex == 1: return 1/(self.args[0]**2*sqrt(1 - 1/self.args[0]**2)) else: raise ArgumentIndexError(self, argindex) def inverse(self, argindex=1): """ Returns the inverse of this function. """ return sec def _eval_as_leading_term(self, x): from sympy import Order arg = self.args[0].as_leading_term(x) if Order(1,x).contains(arg): return log(arg) else: return self.func(arg) def _eval_is_real(self): x = self.args[0] if x.is_real is False: return False return fuzzy_or(((x - 1).is_nonnegative, (-x - 1).is_nonnegative)) def _eval_rewrite_as_log(self, arg, **kwargs): return S.Pi/2 + S.ImaginaryUnit*log(S.ImaginaryUnit/arg + sqrt(1 - 1/arg**2)) def _eval_rewrite_as_asin(self, arg, **kwargs): return S.Pi/2 - asin(1/arg) def _eval_rewrite_as_acos(self, arg, **kwargs): return acos(1/arg) def _eval_rewrite_as_atan(self, arg, **kwargs): return sqrt(arg**2)/arg*(-S.Pi/2 + 2*atan(arg + sqrt(arg**2 - 1))) def _eval_rewrite_as_acot(self, arg, **kwargs): return sqrt(arg**2)/arg*(-S.Pi/2 + 2*acot(arg - sqrt(arg**2 - 1))) def _eval_rewrite_as_acsc(self, arg, **kwargs): return S.Pi/2 - acsc(arg) class acsc(InverseTrigonometricFunction): """ The inverse cosecant function. Returns the arc cosecant of x (measured in radians). Notes ===== acsc(x) will evaluate automatically in the cases oo, -oo, 0, 1, -1. Examples ======== >>> from sympy import acsc, oo, pi >>> acsc(1) pi/2 >>> acsc(-1) -pi/2 See Also ======== sin, csc, cos, sec, tan, cot asin, acos, asec, atan, acot, atan2 References ========== .. [1] https://en.wikipedia.org/wiki/Inverse_trigonometric_functions .. [2] http://dlmf.nist.gov/4.23 .. [3] http://functions.wolfram.com/ElementaryFunctions/ArcCsc """ @classmethod def eval(cls, arg): if arg.is_Number: if arg is S.NaN: return S.NaN elif arg is S.One: return S.Pi/2 elif arg is S.NegativeOne: return -S.Pi/2 if arg in [S.Infinity, S.NegativeInfinity, S.ComplexInfinity]: return S.Zero if isinstance(arg, csc): ang = arg.args[0] if ang.is_comparable: ang %= 2*pi # restrict to [0,2*pi) if ang > pi: # restrict to (-pi,pi] ang = pi - ang # restrict to [-pi/2,pi/2] if ang > pi/2: ang = pi - ang if ang < -pi/2: ang = -pi - ang return ang if isinstance(arg, sec): # asec(x) + acsc(x) = pi/2 ang = arg.args[0] if ang.is_comparable: return pi/2 - asec(arg) def fdiff(self, argindex=1): if argindex == 1: return -1/(self.args[0]**2*sqrt(1 - 1/self.args[0]**2)) else: raise ArgumentIndexError(self, argindex) def inverse(self, argindex=1): """ Returns the inverse of this function. """ return csc def _eval_as_leading_term(self, x): from sympy import Order arg = self.args[0].as_leading_term(x) if Order(1,x).contains(arg): return log(arg) else: return self.func(arg) def _eval_rewrite_as_log(self, arg, **kwargs): return -S.ImaginaryUnit*log(S.ImaginaryUnit/arg + sqrt(1 - 1/arg**2)) def _eval_rewrite_as_asin(self, arg, **kwargs): return asin(1/arg) def _eval_rewrite_as_acos(self, arg, **kwargs): return S.Pi/2 - acos(1/arg) def _eval_rewrite_as_atan(self, arg, **kwargs): return sqrt(arg**2)/arg*(S.Pi/2 - atan(sqrt(arg**2 - 1))) def _eval_rewrite_as_acot(self, arg, **kwargs): return sqrt(arg**2)/arg*(S.Pi/2 - acot(1/sqrt(arg**2 - 1))) def _eval_rewrite_as_asec(self, arg, **kwargs): return S.Pi/2 - asec(arg) class atan2(InverseTrigonometricFunction): r""" The function ``atan2(y, x)`` computes `\operatorname{atan}(y/x)` taking two arguments `y` and `x`. Signs of both `y` and `x` are considered to determine the appropriate quadrant of `\operatorname{atan}(y/x)`. The range is `(-\pi, \pi]`. The complete definition reads as follows: .. math:: \operatorname{atan2}(y, x) = \begin{cases} \arctan\left(\frac y x\right) & \qquad x > 0 \\ \arctan\left(\frac y x\right) + \pi& \qquad y \ge 0 , x < 0 \\ \arctan\left(\frac y x\right) - \pi& \qquad y < 0 , x < 0 \\ +\frac{\pi}{2} & \qquad y > 0 , x = 0 \\ -\frac{\pi}{2} & \qquad y < 0 , x = 0 \\ \text{undefined} & \qquad y = 0, x = 0 \end{cases} Attention: Note the role reversal of both arguments. The `y`-coordinate is the first argument and the `x`-coordinate the second. Examples ======== Going counter-clock wise around the origin we find the following angles: >>> from sympy import atan2 >>> atan2(0, 1) 0 >>> atan2(1, 1) pi/4 >>> atan2(1, 0) pi/2 >>> atan2(1, -1) 3*pi/4 >>> atan2(0, -1) pi >>> atan2(-1, -1) -3*pi/4 >>> atan2(-1, 0) -pi/2 >>> atan2(-1, 1) -pi/4 which are all correct. Compare this to the results of the ordinary `\operatorname{atan}` function for the point `(x, y) = (-1, 1)` >>> from sympy import atan, S >>> atan(S(1) / -1) -pi/4 >>> atan2(1, -1) 3*pi/4 where only the `\operatorname{atan2}` function reurns what we expect. We can differentiate the function with respect to both arguments: >>> from sympy import diff >>> from sympy.abc import x, y >>> diff(atan2(y, x), x) -y/(x**2 + y**2) >>> diff(atan2(y, x), y) x/(x**2 + y**2) We can express the `\operatorname{atan2}` function in terms of complex logarithms: >>> from sympy import log >>> atan2(y, x).rewrite(log) -I*log((x + I*y)/sqrt(x**2 + y**2)) and in terms of `\operatorname(atan)`: >>> from sympy import atan >>> atan2(y, x).rewrite(atan) Piecewise((2*atan(y/(x + sqrt(x**2 + y**2))), Ne(y, 0)), (pi, x < 0), (0, x > 0), (nan, True)) but note that this form is undefined on the negative real axis. See Also ======== sin, csc, cos, sec, tan, cot asin, acsc, acos, asec, atan, acot References ========== .. [1] https://en.wikipedia.org/wiki/Inverse_trigonometric_functions .. [2] https://en.wikipedia.org/wiki/Atan2 .. [3] http://functions.wolfram.com/ElementaryFunctions/ArcTan2 """ @classmethod def eval(cls, y, x): from sympy import Heaviside, im, re if x is S.NegativeInfinity: if y.is_zero: # Special case y = 0 because we define Heaviside(0) = 1/2 return S.Pi return 2*S.Pi*(Heaviside(re(y))) - S.Pi elif x is S.Infinity: return S.Zero elif x.is_imaginary and y.is_imaginary and x.is_number and y.is_number: x = im(x) y = im(y) if x.is_real and y.is_real: if x.is_positive: return atan(y / x) elif x.is_negative: if y.is_negative: return atan(y / x) - S.Pi elif y.is_nonnegative: return atan(y / x) + S.Pi elif x.is_zero: if y.is_positive: return S.Pi/2 elif y.is_negative: return -S.Pi/2 elif y.is_zero: return S.NaN if y.is_zero and x.is_real and fuzzy_not(x.is_zero): return S.Pi * (S.One - Heaviside(x)) if x.is_number and y.is_number: return -S.ImaginaryUnit*log( (x + S.ImaginaryUnit*y)/sqrt(x**2 + y**2)) def _eval_rewrite_as_log(self, y, x, **kwargs): return -S.ImaginaryUnit*log((x + S.ImaginaryUnit*y) / sqrt(x**2 + y**2)) def _eval_rewrite_as_atan(self, y, x, **kwargs): return Piecewise((2*atan(y/(x + sqrt(x**2 + y**2))), Ne(y, 0)), (pi, x < 0), (0, x > 0), (S.NaN, True)) def _eval_rewrite_as_arg(self, y, x, **kwargs): from sympy import arg if x.is_real and y.is_real: return arg(x + y*S.ImaginaryUnit) I = S.ImaginaryUnit n = x + I*y d = x**2 + y**2 return arg(n/sqrt(d)) - I*log(abs(n)/sqrt(abs(d))) def _eval_is_real(self): return self.args[0].is_real and self.args[1].is_real def _eval_conjugate(self): return self.func(self.args[0].conjugate(), self.args[1].conjugate()) def fdiff(self, argindex): y, x = self.args if argindex == 1: # Diff wrt y return x/(x**2 + y**2) elif argindex == 2: # Diff wrt x return -y/(x**2 + y**2) else: raise ArgumentIndexError(self, argindex) def _eval_evalf(self, prec): y, x = self.args if x.is_real and y.is_real: super(atan2, self)._eval_evalf(prec)
7ae8bfe882a06995a50eff7282b6db42ec585f464541261f5c41ef47d604f8bd
from __future__ import print_function, division from sympy.core import Function, S, sympify from sympy.core.add import Add from sympy.core.containers import Tuple from sympy.core.operations import LatticeOp, ShortCircuit from sympy.core.function import (Application, Lambda, ArgumentIndexError) from sympy.core.expr import Expr from sympy.core.mod import Mod from sympy.core.mul import Mul from sympy.core.numbers import Rational from sympy.core.power import Pow from sympy.core.relational import Eq, Relational from sympy.core.singleton import Singleton from sympy.core.symbol import Dummy from sympy.core.rules import Transform from sympy.core.compatibility import with_metaclass, range from sympy.core.logic import fuzzy_and, fuzzy_or, _torf from sympy.logic.boolalg import And, Or def _minmax_as_Piecewise(op, *args): # helper for Min/Max rewrite as Piecewise from sympy.functions.elementary.piecewise import Piecewise ec = [] for i, a in enumerate(args): c = [] for j in range(i + 1, len(args)): c.append(Relational(a, args[j], op)) ec.append((a, And(*c))) return Piecewise(*ec) class IdentityFunction(with_metaclass(Singleton, Lambda)): """ The identity function Examples ======== >>> from sympy import Id, Symbol >>> x = Symbol('x') >>> Id(x) x """ def __new__(cls): from sympy.sets.sets import FiniteSet x = Dummy('x') #construct "by hand" to avoid infinite loop obj = Expr.__new__(cls, Tuple(x), x) obj.nargs = FiniteSet(1) return obj Id = S.IdentityFunction ############################################################################### ############################# ROOT and SQUARE ROOT FUNCTION ################### ############################################################################### def sqrt(arg, evaluate=None): """The square root function sqrt(x) -> Returns the principal square root of x. The parameter evaluate determines if the expression should be evaluated. If None, its value is taken from global_evaluate Examples ======== >>> from sympy import sqrt, Symbol >>> x = Symbol('x') >>> sqrt(x) sqrt(x) >>> sqrt(x)**2 x Note that sqrt(x**2) does not simplify to x. >>> sqrt(x**2) sqrt(x**2) This is because the two are not equal to each other in general. For example, consider x == -1: >>> from sympy import Eq >>> Eq(sqrt(x**2), x).subs(x, -1) False This is because sqrt computes the principal square root, so the square may put the argument in a different branch. This identity does hold if x is positive: >>> y = Symbol('y', positive=True) >>> sqrt(y**2) y You can force this simplification by using the powdenest() function with the force option set to True: >>> from sympy import powdenest >>> sqrt(x**2) sqrt(x**2) >>> powdenest(sqrt(x**2), force=True) x To get both branches of the square root you can use the rootof function: >>> from sympy import rootof >>> [rootof(x**2-3,i) for i in (0,1)] [-sqrt(3), sqrt(3)] See Also ======== sympy.polys.rootoftools.rootof, root, real_root References ========== .. [1] https://en.wikipedia.org/wiki/Square_root .. [2] https://en.wikipedia.org/wiki/Principal_value """ # arg = sympify(arg) is handled by Pow return Pow(arg, S.Half, evaluate=evaluate) def cbrt(arg, evaluate=None): """This function computes the principal cube root of `arg`, so it's just a shortcut for `arg**Rational(1, 3)`. The parameter evaluate determines if the expression should be evaluated. If None, its value is taken from global_evaluate. Examples ======== >>> from sympy import cbrt, Symbol >>> x = Symbol('x') >>> cbrt(x) x**(1/3) >>> cbrt(x)**3 x Note that cbrt(x**3) does not simplify to x. >>> cbrt(x**3) (x**3)**(1/3) This is because the two are not equal to each other in general. For example, consider `x == -1`: >>> from sympy import Eq >>> Eq(cbrt(x**3), x).subs(x, -1) False This is because cbrt computes the principal cube root, this identity does hold if `x` is positive: >>> y = Symbol('y', positive=True) >>> cbrt(y**3) y See Also ======== sympy.polys.rootoftools.rootof, root, real_root References ========== * https://en.wikipedia.org/wiki/Cube_root * https://en.wikipedia.org/wiki/Principal_value """ return Pow(arg, Rational(1, 3), evaluate=evaluate) def root(arg, n, k=0, evaluate=None): """root(x, n, k) -> Returns the k-th n-th root of x, defaulting to the principal root (k=0). The parameter evaluate determines if the expression should be evaluated. If None, its value is taken from global_evaluate. Examples ======== >>> from sympy import root, Rational >>> from sympy.abc import x, n >>> root(x, 2) sqrt(x) >>> root(x, 3) x**(1/3) >>> root(x, n) x**(1/n) >>> root(x, -Rational(2, 3)) x**(-3/2) To get the k-th n-th root, specify k: >>> root(-2, 3, 2) -(-1)**(2/3)*2**(1/3) To get all n n-th roots you can use the rootof function. The following examples show the roots of unity for n equal 2, 3 and 4: >>> from sympy import rootof, I >>> [rootof(x**2 - 1, i) for i in range(2)] [-1, 1] >>> [rootof(x**3 - 1,i) for i in range(3)] [1, -1/2 - sqrt(3)*I/2, -1/2 + sqrt(3)*I/2] >>> [rootof(x**4 - 1,i) for i in range(4)] [-1, 1, -I, I] SymPy, like other symbolic algebra systems, returns the complex root of negative numbers. This is the principal root and differs from the text-book result that one might be expecting. For example, the cube root of -8 does not come back as -2: >>> root(-8, 3) 2*(-1)**(1/3) The real_root function can be used to either make the principal result real (or simply to return the real root directly): >>> from sympy import real_root >>> real_root(_) -2 >>> real_root(-32, 5) -2 Alternatively, the n//2-th n-th root of a negative number can be computed with root: >>> root(-32, 5, 5//2) -2 See Also ======== sympy.polys.rootoftools.rootof sympy.core.power.integer_nthroot sqrt, real_root References ========== * https://en.wikipedia.org/wiki/Square_root * https://en.wikipedia.org/wiki/Real_root * https://en.wikipedia.org/wiki/Root_of_unity * https://en.wikipedia.org/wiki/Principal_value * http://mathworld.wolfram.com/CubeRoot.html """ n = sympify(n) if k: return Mul(Pow(arg, S.One/n, evaluate=evaluate), S.NegativeOne**(2*k/n), evaluate=evaluate) return Pow(arg, 1/n, evaluate=evaluate) def real_root(arg, n=None, evaluate=None): """Return the real nth-root of arg if possible. If n is omitted then all instances of (-n)**(1/odd) will be changed to -n**(1/odd); this will only create a real root of a principal root -- the presence of other factors may cause the result to not be real. The parameter evaluate determines if the expression should be evaluated. If None, its value is taken from global_evaluate. Examples ======== >>> from sympy import root, real_root, Rational >>> from sympy.abc import x, n >>> real_root(-8, 3) -2 >>> root(-8, 3) 2*(-1)**(1/3) >>> real_root(_) -2 If one creates a non-principal root and applies real_root, the result will not be real (so use with caution): >>> root(-8, 3, 2) -2*(-1)**(2/3) >>> real_root(_) -2*(-1)**(2/3) See Also ======== sympy.polys.rootoftools.rootof sympy.core.power.integer_nthroot root, sqrt """ from sympy.functions.elementary.complexes import Abs, im, sign from sympy.functions.elementary.piecewise import Piecewise if n is not None: return Piecewise( (root(arg, n, evaluate=evaluate), Or(Eq(n, S.One), Eq(n, S.NegativeOne))), (Mul(sign(arg), root(Abs(arg), n, evaluate=evaluate), evaluate=evaluate), And(Eq(im(arg), S.Zero), Eq(Mod(n, 2), S.One))), (root(arg, n, evaluate=evaluate), True)) rv = sympify(arg) n1pow = Transform(lambda x: -(-x.base)**x.exp, lambda x: x.is_Pow and x.base.is_negative and x.exp.is_Rational and x.exp.p == 1 and x.exp.q % 2) return rv.xreplace(n1pow) ############################################################################### ############################# MINIMUM and MAXIMUM ############################# ############################################################################### class MinMaxBase(Expr, LatticeOp): def __new__(cls, *args, **assumptions): evaluate = assumptions.pop('evaluate', True) args = (sympify(arg) for arg in args) # first standard filter, for cls.zero and cls.identity # also reshape Max(a, Max(b, c)) to Max(a, b, c) if evaluate: try: args = frozenset(cls._new_args_filter(args)) except ShortCircuit: return cls.zero else: args = frozenset(args) if evaluate: # remove redundant args that are easily identified args = cls._collapse_arguments(args, **assumptions) # find local zeros args = cls._find_localzeros(args, **assumptions) if not args: return cls.identity if len(args) == 1: return list(args).pop() # base creation _args = frozenset(args) obj = Expr.__new__(cls, _args, **assumptions) obj._argset = _args return obj @classmethod def _collapse_arguments(cls, args, **assumptions): """Remove redundant args. Examples ======== >>> from sympy import Min, Max >>> from sympy.abc import a, b, c, d, e Any arg in parent that appears in any parent-like function in any of the flat args of parent can be removed from that sub-arg: >>> Min(a, Max(b, Min(a, c, d))) Min(a, Max(b, Min(c, d))) If the arg of parent appears in an opposite-than parent function in any of the flat args of parent that function can be replaced with the arg: >>> Min(a, Max(b, Min(c, d, Max(a, e)))) Min(a, Max(b, Min(a, c, d))) """ from sympy.utilities.iterables import ordered from sympy.simplify.simplify import walk if not args: return args args = list(ordered(args)) if cls == Min: other = Max else: other = Min # find global comparable max of Max and min of Min if a new # value is being introduced in these args at position 0 of # the ordered args if args[0].is_number: sifted = mins, maxs = [], [] for i in args: for v in walk(i, Min, Max): if v.args[0].is_comparable: sifted[isinstance(v, Max)].append(v) small = Min.identity for i in mins: v = i.args[0] if v.is_number and (v < small) == True: small = v big = Max.identity for i in maxs: v = i.args[0] if v.is_number and (v > big) == True: big = v # at the point when this function is called from __new__, # there may be more than one numeric arg present since # local zeros have not been handled yet, so look through # more than the first arg if cls == Min: for i in range(len(args)): if not args[i].is_number: break if (args[i] < small) == True: small = args[i] elif cls == Max: for i in range(len(args)): if not args[i].is_number: break if (args[i] > big) == True: big = args[i] T = None if cls == Min: if small != Min.identity: other = Max T = small elif big != Max.identity: other = Min T = big if T is not None: # remove numerical redundancy for i in range(len(args)): a = args[i] if isinstance(a, other): a0 = a.args[0] if ((a0 > T) if other == Max else (a0 < T)) == True: args[i] = cls.identity # remove redundant symbolic args def do(ai, a): if not isinstance(ai, (Min, Max)): return ai cond = a in ai.args if not cond: return ai.func(*[do(i, a) for i in ai.args], evaluate=False) if isinstance(ai, cls): return ai.func(*[do(i, a) for i in ai.args if i != a], evaluate=False) return a for i, a in enumerate(args): args[i + 1:] = [do(ai, a) for ai in args[i + 1:]] # factor out common elements as for # Min(Max(x, y), Max(x, z)) -> Max(x, Min(y, z)) # and vice versa when swapping Min/Max -- do this only for the # easy case where all functions contain something in common; # trying to find some optimal subset of args to modify takes # too long if len(args) > 1: common = None remove = [] sets = [] for i in range(len(args)): a = args[i] if not isinstance(a, other): continue s = set(a.args) common = s if common is None else (common & s) if not common: break sets.append(s) remove.append(i) if common: sets = filter(None, [s - common for s in sets]) sets = [other(*s, evaluate=False) for s in sets] for i in reversed(remove): args.pop(i) oargs = [cls(*sets)] if sets else [] oargs.extend(common) args.append(other(*oargs, evaluate=False)) return args @classmethod def _new_args_filter(cls, arg_sequence): """ Generator filtering args. first standard filter, for cls.zero and cls.identity. Also reshape Max(a, Max(b, c)) to Max(a, b, c), and check arguments for comparability """ for arg in arg_sequence: # pre-filter, checking comparability of arguments if not isinstance(arg, Expr) or arg.is_real is False or ( arg.is_number and not arg.is_comparable): raise ValueError("The argument '%s' is not comparable." % arg) if arg == cls.zero: raise ShortCircuit(arg) elif arg == cls.identity: continue elif arg.func == cls: for x in arg.args: yield x else: yield arg @classmethod def _find_localzeros(cls, values, **options): """ Sequentially allocate values to localzeros. When a value is identified as being more extreme than another member it replaces that member; if this is never true, then the value is simply appended to the localzeros. """ localzeros = set() for v in values: is_newzero = True localzeros_ = list(localzeros) for z in localzeros_: if id(v) == id(z): is_newzero = False else: con = cls._is_connected(v, z) if con: is_newzero = False if con is True or con == cls: localzeros.remove(z) localzeros.update([v]) if is_newzero: localzeros.update([v]) return localzeros @classmethod def _is_connected(cls, x, y): """ Check if x and y are connected somehow. """ from sympy.core.exprtools import factor_terms def hit(v, t, f): if not v.is_Relational: return t if v else f for i in range(2): if x == y: return True r = hit(x >= y, Max, Min) if r is not None: return r r = hit(y <= x, Max, Min) if r is not None: return r r = hit(x <= y, Min, Max) if r is not None: return r r = hit(y >= x, Min, Max) if r is not None: return r # simplification can be expensive, so be conservative # in what is attempted x = factor_terms(x - y) y = S.Zero return False def _eval_derivative(self, s): # f(x).diff(s) -> x.diff(s) * f.fdiff(1)(s) i = 0 l = [] for a in self.args: i += 1 da = a.diff(s) if da is S.Zero: continue try: df = self.fdiff(i) except ArgumentIndexError: df = Function.fdiff(self, i) l.append(df * da) return Add(*l) def _eval_rewrite_as_Abs(self, *args, **kwargs): from sympy.functions.elementary.complexes import Abs s = (args[0] + self.func(*args[1:]))/2 d = abs(args[0] - self.func(*args[1:]))/2 return (s + d if isinstance(self, Max) else s - d).rewrite(Abs) def evalf(self, prec=None, **options): return self.func(*[a.evalf(prec, **options) for a in self.args]) n = evalf _eval_is_algebraic = lambda s: _torf(i.is_algebraic for i in s.args) _eval_is_antihermitian = lambda s: _torf(i.is_antihermitian for i in s.args) _eval_is_commutative = lambda s: _torf(i.is_commutative for i in s.args) _eval_is_complex = lambda s: _torf(i.is_complex for i in s.args) _eval_is_composite = lambda s: _torf(i.is_composite for i in s.args) _eval_is_even = lambda s: _torf(i.is_even for i in s.args) _eval_is_finite = lambda s: _torf(i.is_finite for i in s.args) _eval_is_hermitian = lambda s: _torf(i.is_hermitian for i in s.args) _eval_is_imaginary = lambda s: _torf(i.is_imaginary for i in s.args) _eval_is_infinite = lambda s: _torf(i.is_infinite for i in s.args) _eval_is_integer = lambda s: _torf(i.is_integer for i in s.args) _eval_is_irrational = lambda s: _torf(i.is_irrational for i in s.args) _eval_is_negative = lambda s: _torf(i.is_negative for i in s.args) _eval_is_noninteger = lambda s: _torf(i.is_noninteger for i in s.args) _eval_is_nonnegative = lambda s: _torf(i.is_nonnegative for i in s.args) _eval_is_nonpositive = lambda s: _torf(i.is_nonpositive for i in s.args) _eval_is_nonzero = lambda s: _torf(i.is_nonzero for i in s.args) _eval_is_odd = lambda s: _torf(i.is_odd for i in s.args) _eval_is_polar = lambda s: _torf(i.is_polar for i in s.args) _eval_is_positive = lambda s: _torf(i.is_positive for i in s.args) _eval_is_prime = lambda s: _torf(i.is_prime for i in s.args) _eval_is_rational = lambda s: _torf(i.is_rational for i in s.args) _eval_is_real = lambda s: _torf(i.is_real for i in s.args) _eval_is_transcendental = lambda s: _torf(i.is_transcendental for i in s.args) _eval_is_zero = lambda s: _torf(i.is_zero for i in s.args) class Max(MinMaxBase, Application): """ Return, if possible, the maximum value of the list. When number of arguments is equal one, then return this argument. When number of arguments is equal two, then return, if possible, the value from (a, b) that is >= the other. In common case, when the length of list greater than 2, the task is more complicated. Return only the arguments, which are greater than others, if it is possible to determine directional relation. If is not possible to determine such a relation, return a partially evaluated result. Assumptions are used to make the decision too. Also, only comparable arguments are permitted. It is named ``Max`` and not ``max`` to avoid conflicts with the built-in function ``max``. Examples ======== >>> from sympy import Max, Symbol, oo >>> from sympy.abc import x, y >>> p = Symbol('p', positive=True) >>> n = Symbol('n', negative=True) >>> Max(x, -2) #doctest: +SKIP Max(x, -2) >>> Max(x, -2).subs(x, 3) 3 >>> Max(p, -2) p >>> Max(x, y) Max(x, y) >>> Max(x, y) == Max(y, x) True >>> Max(x, Max(y, z)) #doctest: +SKIP Max(x, y, z) >>> Max(n, 8, p, 7, -oo) #doctest: +SKIP Max(8, p) >>> Max (1, x, oo) oo * Algorithm The task can be considered as searching of supremums in the directed complete partial orders [1]_. The source values are sequentially allocated by the isolated subsets in which supremums are searched and result as Max arguments. If the resulted supremum is single, then it is returned. The isolated subsets are the sets of values which are only the comparable with each other in the current set. E.g. natural numbers are comparable with each other, but not comparable with the `x` symbol. Another example: the symbol `x` with negative assumption is comparable with a natural number. Also there are "least" elements, which are comparable with all others, and have a zero property (maximum or minimum for all elements). E.g. `oo`. In case of it the allocation operation is terminated and only this value is returned. Assumption: - if A > B > C then A > C - if A == B then B can be removed References ========== .. [1] https://en.wikipedia.org/wiki/Directed_complete_partial_order .. [2] https://en.wikipedia.org/wiki/Lattice_%28order%29 See Also ======== Min : find minimum values """ zero = S.Infinity identity = S.NegativeInfinity def fdiff( self, argindex ): from sympy import Heaviside n = len(self.args) if 0 < argindex and argindex <= n: argindex -= 1 if n == 2: return Heaviside(self.args[argindex] - self.args[1 - argindex]) newargs = tuple([self.args[i] for i in range(n) if i != argindex]) return Heaviside(self.args[argindex] - Max(*newargs)) else: raise ArgumentIndexError(self, argindex) def _eval_rewrite_as_Heaviside(self, *args, **kwargs): from sympy import Heaviside return Add(*[j*Mul(*[Heaviside(j - i) for i in args if i!=j]) \ for j in args]) def _eval_rewrite_as_Piecewise(self, *args, **kwargs): return _minmax_as_Piecewise('>=', *args) def _eval_is_positive(self): return fuzzy_or(a.is_positive for a in self.args) def _eval_is_nonnegative(self): return fuzzy_or(a.is_nonnegative for a in self.args) def _eval_is_negative(self): return fuzzy_and(a.is_negative for a in self.args) class Min(MinMaxBase, Application): """ Return, if possible, the minimum value of the list. It is named ``Min`` and not ``min`` to avoid conflicts with the built-in function ``min``. Examples ======== >>> from sympy import Min, Symbol, oo >>> from sympy.abc import x, y >>> p = Symbol('p', positive=True) >>> n = Symbol('n', negative=True) >>> Min(x, -2) #doctest: +SKIP Min(x, -2) >>> Min(x, -2).subs(x, 3) -2 >>> Min(p, -3) -3 >>> Min(x, y) #doctest: +SKIP Min(x, y) >>> Min(n, 8, p, -7, p, oo) #doctest: +SKIP Min(n, -7) See Also ======== Max : find maximum values """ zero = S.NegativeInfinity identity = S.Infinity def fdiff( self, argindex ): from sympy import Heaviside n = len(self.args) if 0 < argindex and argindex <= n: argindex -= 1 if n == 2: return Heaviside( self.args[1-argindex] - self.args[argindex] ) newargs = tuple([ self.args[i] for i in range(n) if i != argindex]) return Heaviside( Min(*newargs) - self.args[argindex] ) else: raise ArgumentIndexError(self, argindex) def _eval_rewrite_as_Heaviside(self, *args, **kwargs): from sympy import Heaviside return Add(*[j*Mul(*[Heaviside(i-j) for i in args if i!=j]) \ for j in args]) def _eval_rewrite_as_Piecewise(self, *args, **kwargs): return _minmax_as_Piecewise('<=', *args) def _eval_is_positive(self): return fuzzy_and(a.is_positive for a in self.args) def _eval_is_nonnegative(self): return fuzzy_and(a.is_nonnegative for a in self.args) def _eval_is_negative(self): return fuzzy_or(a.is_negative for a in self.args)
67851ad069e8f0fd99615fe194a06077f853004eb091b0659c5dfc7d859e9be1
from __future__ import print_function, division from sympy.core import Basic, S, Function, diff, Tuple, Dummy, Symbol from sympy.core.basic import as_Basic from sympy.core.compatibility import range from sympy.core.numbers import Rational, NumberSymbol from sympy.core.relational import (Equality, Unequality, Relational, _canonical) from sympy.functions.elementary.miscellaneous import Max, Min from sympy.logic.boolalg import (And, Boolean, distribute_and_over_or, true, false, Or, ITE, simplify_logic) from sympy.utilities.iterables import uniq, ordered, product, sift from sympy.utilities.misc import filldedent, func_name Undefined = S.NaN # Piecewise() class ExprCondPair(Tuple): """Represents an expression, condition pair.""" def __new__(cls, expr, cond): expr = as_Basic(expr) if cond == True: return Tuple.__new__(cls, expr, true) elif cond == False: return Tuple.__new__(cls, expr, false) elif isinstance(cond, Basic) and cond.has(Piecewise): cond = piecewise_fold(cond) if isinstance(cond, Piecewise): cond = cond.rewrite(ITE) if not isinstance(cond, Boolean): raise TypeError(filldedent(''' Second argument must be a Boolean, not `%s`''' % func_name(cond))) return Tuple.__new__(cls, expr, cond) @property def expr(self): """ Returns the expression of this pair. """ return self.args[0] @property def cond(self): """ Returns the condition of this pair. """ return self.args[1] @property def is_commutative(self): return self.expr.is_commutative def __iter__(self): yield self.expr yield self.cond def _eval_simplify(self, ratio, measure, rational, inverse): return self.func(*[a.simplify( ratio=ratio, measure=measure, rational=rational, inverse=inverse) for a in self.args]) class Piecewise(Function): """ Represents a piecewise function. Usage: Piecewise( (expr,cond), (expr,cond), ... ) - Each argument is a 2-tuple defining an expression and condition - The conds are evaluated in turn returning the first that is True. If any of the evaluated conds are not determined explicitly False, e.g. x < 1, the function is returned in symbolic form. - If the function is evaluated at a place where all conditions are False, nan will be returned. - Pairs where the cond is explicitly False, will be removed. Examples ======== >>> from sympy import Piecewise, log, ITE, piecewise_fold >>> from sympy.abc import x, y >>> f = x**2 >>> g = log(x) >>> p = Piecewise((0, x < -1), (f, x <= 1), (g, True)) >>> p.subs(x,1) 1 >>> p.subs(x,5) log(5) Booleans can contain Piecewise elements: >>> cond = (x < y).subs(x, Piecewise((2, x < 0), (3, True))); cond Piecewise((2, x < 0), (3, True)) < y The folded version of this results in a Piecewise whose expressions are Booleans: >>> folded_cond = piecewise_fold(cond); folded_cond Piecewise((2 < y, x < 0), (3 < y, True)) When a Boolean containing Piecewise (like cond) or a Piecewise with Boolean expressions (like folded_cond) is used as a condition, it is converted to an equivalent ITE object: >>> Piecewise((1, folded_cond)) Piecewise((1, ITE(x < 0, y > 2, y > 3))) When a condition is an ITE, it will be converted to a simplified Boolean expression: >>> piecewise_fold(_) Piecewise((1, ((x >= 0) | (y > 2)) & ((y > 3) | (x < 0)))) See Also ======== piecewise_fold, ITE """ nargs = None is_Piecewise = True def __new__(cls, *args, **options): if len(args) == 0: raise TypeError("At least one (expr, cond) pair expected.") # (Try to) sympify args first newargs = [] for ec in args: # ec could be a ExprCondPair or a tuple pair = ExprCondPair(*getattr(ec, 'args', ec)) cond = pair.cond if cond is false: continue newargs.append(pair) if cond is true: break if options.pop('evaluate', True): r = cls.eval(*newargs) else: r = None if r is None: return Basic.__new__(cls, *newargs, **options) else: return r @classmethod def eval(cls, *_args): """Either return a modified version of the args or, if no modifications were made, return None. Modifications that are made here: 1) relationals are made canonical 2) any False conditions are dropped 3) any repeat of a previous condition is ignored 3) any args past one with a true condition are dropped If there are no args left, nan will be returned. If there is a single arg with a True condition, its corresponding expression will be returned. """ if not _args: return Undefined if len(_args) == 1 and _args[0][-1] == True: return _args[0][0] newargs = [] # the unevaluated conditions current_cond = set() # the conditions up to a given e, c pair # make conditions canonical args = [] for e, c in _args: if not c.is_Atom and not isinstance(c, Relational): free = c.free_symbols if len(free) == 1: funcs = [i for i in c.atoms(Function) if not isinstance(i, Boolean)] if len(funcs) == 1 and len( c.xreplace({list(funcs)[0]: Dummy()} ).free_symbols) == 1: # we can treat function like a symbol free = funcs _c = c x = free.pop() try: c = c.as_set().as_relational(x) except NotImplementedError: pass else: reps = {} for i in c.atoms(Relational): ic = i.canonical if ic.rhs in (S.Infinity, S.NegativeInfinity): if not _c.has(ic.rhs): # don't accept introduction of # new Relationals with +/-oo reps[i] = S.true elif ('=' not in ic.rel_op and c.xreplace({x: i.rhs}) != _c.xreplace({x: i.rhs})): reps[i] = Relational( i.lhs, i.rhs, i.rel_op + '=') c = c.xreplace(reps) args.append((e, _canonical(c))) for expr, cond in args: # Check here if expr is a Piecewise and collapse if one of # the conds in expr matches cond. This allows the collapsing # of Piecewise((Piecewise((x,x<0)),x<0)) to Piecewise((x,x<0)). # This is important when using piecewise_fold to simplify # multiple Piecewise instances having the same conds. # Eventually, this code should be able to collapse Piecewise's # having different intervals, but this will probably require # using the new assumptions. if isinstance(expr, Piecewise): unmatching = [] for i, (e, c) in enumerate(expr.args): if c in current_cond: # this would already have triggered continue if c == cond: if c != True: # nothing past this condition will ever # trigger and only those args before this # that didn't match a previous condition # could possibly trigger if unmatching: expr = Piecewise(*( unmatching + [(e, c)])) else: expr = e break else: unmatching.append((e, c)) # check for condition repeats got = False # -- if an And contains a condition that was # already encountered, then the And will be # False: if the previous condition was False # then the And will be False and if the previous # condition is True then then we wouldn't get to # this point. In either case, we can skip this condition. for i in ([cond] + (list(cond.args) if isinstance(cond, And) else [])): if i in current_cond: got = True break if got: continue # -- if not(c) is already in current_cond then c is # a redundant condition in an And. This does not # apply to Or, however: (e1, c), (e2, Or(~c, d)) # is not (e1, c), (e2, d) because if c and d are # both False this would give no results when the # true answer should be (e2, True) if isinstance(cond, And): nonredundant = [] for c in cond.args: if (isinstance(c, Relational) and c.negated.canonical in current_cond): continue nonredundant.append(c) cond = cond.func(*nonredundant) elif isinstance(cond, Relational): if cond.negated.canonical in current_cond: cond = S.true current_cond.add(cond) # collect successive e,c pairs when exprs or cond match if newargs: if newargs[-1].expr == expr: orcond = Or(cond, newargs[-1].cond) if isinstance(orcond, (And, Or)): orcond = distribute_and_over_or(orcond) newargs[-1] = ExprCondPair(expr, orcond) continue elif newargs[-1].cond == cond: orexpr = Or(expr, newargs[-1].expr) if isinstance(orexpr, (And, Or)): orexpr = distribute_and_over_or(orexpr) newargs[-1] == ExprCondPair(orexpr, cond) continue newargs.append(ExprCondPair(expr, cond)) # some conditions may have been redundant missing = len(newargs) != len(_args) # some conditions may have changed same = all(a == b for a, b in zip(newargs, _args)) # if either change happened we return the expr with the # updated args if not newargs: raise ValueError(filldedent(''' There are no conditions (or none that are not trivially false) to define an expression.''')) if missing or not same: return cls(*newargs) def doit(self, **hints): """ Evaluate this piecewise function. """ newargs = [] for e, c in self.args: if hints.get('deep', True): if isinstance(e, Basic): e = e.doit(**hints) if isinstance(c, Basic): c = c.doit(**hints) newargs.append((e, c)) return self.func(*newargs) def _eval_simplify(self, ratio, measure, rational, inverse): args = [a._eval_simplify(ratio, measure, rational, inverse) for a in self.args] _blessed = lambda e: getattr(e.lhs, '_diff_wrt', False) and ( getattr(e.rhs, '_diff_wrt', None) or isinstance(e.rhs, (Rational, NumberSymbol))) for i, (expr, cond) in enumerate(args): # try to simplify conditions and the expression for # equalities that are part of the condition, e.g. # Piecewise((n, And(Eq(n,0), Eq(n + m, 0))), (1, True)) # -> Piecewise((0, And(Eq(n, 0), Eq(m, 0))), (1, True)) if isinstance(cond, And): eqs, other = sift(cond.args, lambda i: isinstance(i, Equality), binary=True) elif isinstance(cond, Equality): eqs, other = [cond], [] else: eqs = other = [] if eqs: eqs = list(ordered(eqs)) for j, e in enumerate(eqs): # these blessed lhs objects behave like Symbols # and the rhs are simple replacements for the "symbols" if _blessed(e): expr = expr.subs(*e.args) eqs[j + 1:] = [ei.subs(*e.args) for ei in eqs[j + 1:]] other = [ei.subs(*e.args) for ei in other] cond = And(*(eqs + other)) args[i] = args[i].func(expr, cond) # See if expressions valid for an Equal expression happens to evaluate # to the same function as in the next piecewise segment, see: # https://github.com/sympy/sympy/issues/8458 prevexpr = None for i, (expr, cond) in reversed(list(enumerate(args))): if prevexpr is not None: if isinstance(cond, And): eqs, other = sift(cond.args, lambda i: isinstance(i, Equality), binary=True) elif isinstance(cond, Equality): eqs, other = [cond], [] else: eqs = other = [] _prevexpr = prevexpr _expr = expr if eqs and not other: eqs = list(ordered(eqs)) for e in eqs: # these blessed lhs objects behave like Symbols # and the rhs are simple replacements for the "symbols" if _blessed(e): _prevexpr = _prevexpr.subs(*e.args) _expr = _expr.subs(*e.args) # Did it evaluate to the same? if _prevexpr == _expr: # Set the expression for the Not equal section to the same # as the next. These will be merged when creating the new # Piecewise args[i] = args[i].func(args[i+1][0], cond) else: # Update the expression that we compare against prevexpr = expr else: prevexpr = expr return self.func(*args) def _eval_as_leading_term(self, x): for e, c in self.args: if c == True or c.subs(x, 0) == True: return e.as_leading_term(x) def _eval_adjoint(self): return self.func(*[(e.adjoint(), c) for e, c in self.args]) def _eval_conjugate(self): return self.func(*[(e.conjugate(), c) for e, c in self.args]) def _eval_derivative(self, x): return self.func(*[(diff(e, x), c) for e, c in self.args]) def _eval_evalf(self, prec): return self.func(*[(e._evalf(prec), c) for e, c in self.args]) def piecewise_integrate(self, x, **kwargs): """Return the Piecewise with each expression being replaced with its antiderivative. To obtain a continuous antiderivative, use the `integrate` function or method. Examples ======== >>> from sympy import Piecewise >>> from sympy.abc import x >>> p = Piecewise((0, x < 0), (1, x < 1), (2, True)) >>> p.piecewise_integrate(x) Piecewise((0, x < 0), (x, x < 1), (2*x, True)) Note that this does not give a continuous function, e.g. at x = 1 the 3rd condition applies and the antiderivative there is 2*x so the value of the antiderivative is 2: >>> anti = _ >>> anti.subs(x, 1) 2 The continuous derivative accounts for the integral *up to* the point of interest, however: >>> p.integrate(x) Piecewise((0, x < 0), (x, x < 1), (2*x - 1, True)) >>> _.subs(x, 1) 1 See Also ======== Piecewise._eval_integral """ from sympy.integrals import integrate return self.func(*[(integrate(e, x, **kwargs), c) for e, c in self.args]) def _handle_irel(self, x, handler): """Return either None (if the conditions of self depend only on x) else a Piecewise expression whose expressions (handled by the handler that was passed) are paired with the governing x-independent relationals, e.g. Piecewise((A, a(x) & b(y)), (B, c(x) | c(y)) -> Piecewise( (handler(Piecewise((A, a(x) & True), (B, c(x) | True)), b(y) & c(y)), (handler(Piecewise((A, a(x) & True), (B, c(x) | False)), b(y)), (handler(Piecewise((A, a(x) & False), (B, c(x) | True)), c(y)), (handler(Piecewise((A, a(x) & False), (B, c(x) | False)), True)) """ # identify governing relationals rel = self.atoms(Relational) irel = list(ordered([r for r in rel if x not in r.free_symbols and r not in (S.true, S.false)])) if irel: args = {} exprinorder = [] for truth in product((1, 0), repeat=len(irel)): reps = dict(zip(irel, truth)) # only store the true conditions since the false are implied # when they appear lower in the Piecewise args if 1 not in truth: cond = None # flag this one so it doesn't get combined else: andargs = Tuple(*[i for i in reps if reps[i]]) free = list(andargs.free_symbols) if len(free) == 1: from sympy.solvers.inequalities import ( reduce_inequalities, _solve_inequality) try: t = reduce_inequalities(andargs, free[0]) # ValueError when there are potentially # nonvanishing imaginary parts except (ValueError, NotImplementedError): # at least isolate free symbol on left t = And(*[_solve_inequality( a, free[0], linear=True) for a in andargs]) else: t = And(*andargs) if t is S.false: continue # an impossible combination cond = t expr = handler(self.xreplace(reps)) if isinstance(expr, self.func) and len(expr.args) == 1: expr, econd = expr.args[0] cond = And(econd, True if cond is None else cond) # the ec pairs are being collected since all possibilities # are being enumerated, but don't put the last one in since # its expr might match a previous expression and it # must appear last in the args if cond is not None: args.setdefault(expr, []).append(cond) # but since we only store the true conditions we must maintain # the order so that the expression with the most true values # comes first exprinorder.append(expr) # convert collected conditions as args of Or for k in args: args[k] = Or(*args[k]) # take them in the order obtained args = [(e, args[e]) for e in uniq(exprinorder)] # add in the last arg args.append((expr, True)) # if any condition reduced to True, it needs to go last # and there should only be one of them or else the exprs # should agree trues = [i for i in range(len(args)) if args[i][1] is S.true] if not trues: # make the last one True since all cases were enumerated e, c = args[-1] args[-1] = (e, S.true) else: assert len(set([e for e, c in [args[i] for i in trues]])) == 1 args.append(args.pop(trues.pop())) while trues: args.pop(trues.pop()) return Piecewise(*args) def _eval_integral(self, x, _first=True, **kwargs): """Return the indefinite integral of the Piecewise such that subsequent substitution of x with a value will give the value of the integral (not including the constant of integration) up to that point. To only integrate the individual parts of Piecewise, use the `piecewise_integrate` method. Examples ======== >>> from sympy import Piecewise >>> from sympy.abc import x >>> p = Piecewise((0, x < 0), (1, x < 1), (2, True)) >>> p.integrate(x) Piecewise((0, x < 0), (x, x < 1), (2*x - 1, True)) >>> p.piecewise_integrate(x) Piecewise((0, x < 0), (x, x < 1), (2*x, True)) See Also ======== Piecewise.piecewise_integrate """ from sympy.integrals.integrals import integrate if _first: def handler(ipw): if isinstance(ipw, self.func): return ipw._eval_integral(x, _first=False, **kwargs) else: return ipw.integrate(x, **kwargs) irv = self._handle_irel(x, handler) if irv is not None: return irv # handle a Piecewise from -oo to oo with and no x-independent relationals # ----------------------------------------------------------------------- try: abei = self._intervals(x) except NotImplementedError: from sympy import Integral return Integral(self, x) # unevaluated pieces = [(a, b) for a, b, _, _ in abei] oo = S.Infinity done = [(-oo, oo, -1)] for k, p in enumerate(pieces): if p == (-oo, oo): # all undone intervals will get this key for j, (a, b, i) in enumerate(done): if i == -1: done[j] = a, b, k break # nothing else to consider N = len(done) - 1 for j, (a, b, i) in enumerate(reversed(done)): if i == -1: j = N - j done[j: j + 1] = _clip(p, (a, b), k) done = [(a, b, i) for a, b, i in done if a != b] # append an arg if there is a hole so a reference to # argument -1 will give Undefined if any(i == -1 for (a, b, i) in done): abei.append((-oo, oo, Undefined, -1)) # return the sum of the intervals args = [] sum = None for a, b, i in done: anti = integrate(abei[i][-2], x, **kwargs) if sum is None: sum = anti else: sum = sum.subs(x, a) if sum == Undefined: sum = 0 sum += anti._eval_interval(x, a, x) # see if we know whether b is contained in original # condition if b is S.Infinity: cond = True elif self.args[abei[i][-1]].cond.subs(x, b) == False: cond = (x < b) else: cond = (x <= b) args.append((sum, cond)) return Piecewise(*args) def _eval_interval(self, sym, a, b, _first=True): """Evaluates the function along the sym in a given interval [a, b]""" # FIXME: Currently complex intervals are not supported. A possible # replacement algorithm, discussed in issue 5227, can be found in the # following papers; # http://portal.acm.org/citation.cfm?id=281649 # http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.70.4127&rep=rep1&type=pdf from sympy.core.symbol import Dummy if a is None or b is None: # In this case, it is just simple substitution return super(Piecewise, self)._eval_interval(sym, a, b) else: x, lo, hi = map(as_Basic, (sym, a, b)) if _first: # get only x-dependent relationals def handler(ipw): if isinstance(ipw, self.func): return ipw._eval_interval(x, lo, hi, _first=None) else: return ipw._eval_interval(x, lo, hi) irv = self._handle_irel(x, handler) if irv is not None: return irv if (lo < hi) is S.false or ( lo is S.Infinity or hi is S.NegativeInfinity): rv = self._eval_interval(x, hi, lo, _first=False) if isinstance(rv, Piecewise): rv = Piecewise(*[(-e, c) for e, c in rv.args]) else: rv = -rv return rv if (lo < hi) is S.true or ( hi is S.Infinity or lo is S.NegativeInfinity): pass else: _a = Dummy('lo') _b = Dummy('hi') a = lo if lo.is_comparable else _a b = hi if hi.is_comparable else _b pos = self._eval_interval(x, a, b, _first=False) if a == _a and b == _b: # it's purely symbolic so just swap lo and hi and # change the sign to get the value for when lo > hi neg, pos = (-pos.xreplace({_a: hi, _b: lo}), pos.xreplace({_a: lo, _b: hi})) else: # at least one of the bounds was comparable, so allow # _eval_interval to use that information when computing # the interval with lo and hi reversed neg, pos = (-self._eval_interval(x, hi, lo, _first=False), pos.xreplace({_a: lo, _b: hi})) # allow simplification based on ordering of lo and hi p = Dummy('', positive=True) if lo.is_Symbol: pos = pos.xreplace({lo: hi - p}).xreplace({p: hi - lo}) neg = neg.xreplace({lo: hi + p}).xreplace({p: lo - hi}) elif hi.is_Symbol: pos = pos.xreplace({hi: lo + p}).xreplace({p: hi - lo}) neg = neg.xreplace({hi: lo - p}).xreplace({p: lo - hi}) # assemble return expression; make the first condition be Lt # b/c then the first expression will look the same whether # the lo or hi limit is symbolic if a == _a: # the lower limit was symbolic rv = Piecewise( (pos, lo < hi), (neg, True)) else: rv = Piecewise( (neg, hi < lo), (pos, True)) if rv == Undefined: raise ValueError("Can't integrate across undefined region.") if any(isinstance(i, Piecewise) for i in (pos, neg)): rv = piecewise_fold(rv) return rv # handle a Piecewise with lo <= hi and no x-independent relationals # ----------------------------------------------------------------- try: abei = self._intervals(x) except NotImplementedError: from sympy import Integral # not being able to do the interval of f(x) can # be stated as not being able to do the integral # of f'(x) over the same range return Integral(self.diff(x), (x, lo, hi)) # unevaluated pieces = [(a, b) for a, b, _, _ in abei] done = [(lo, hi, -1)] oo = S.Infinity for k, p in enumerate(pieces): if p[:2] == (-oo, oo): # all undone intervals will get this key for j, (a, b, i) in enumerate(done): if i == -1: done[j] = a, b, k break # nothing else to consider N = len(done) - 1 for j, (a, b, i) in enumerate(reversed(done)): if i == -1: j = N - j done[j: j + 1] = _clip(p, (a, b), k) done = [(a, b, i) for a, b, i in done if a != b] # return the sum of the intervals sum = S.Zero upto = None for a, b, i in done: if i == -1: if upto is None: return Undefined # TODO simplify hi <= upto return Piecewise((sum, hi <= upto), (Undefined, True)) sum += abei[i][-2]._eval_interval(x, a, b) upto = b return sum def _intervals(self, sym): """Return a list of unique tuples, (a, b, e, i), where a and b are the lower and upper bounds in which the expression e of argument i in self is defined and a < b (when involving numbers) or a <= b when involving symbols. If there are any relationals not involving sym, or any relational cannot be solved for sym, NotImplementedError is raised. The calling routine should have removed such relationals before calling this routine. The evaluated conditions will be returned as ranges. Discontinuous ranges will be returned separately with identical expressions. The first condition that evaluates to True will be returned as the last tuple with a, b = -oo, oo. """ from sympy.solvers.inequalities import _solve_inequality from sympy.logic.boolalg import to_cnf, distribute_or_over_and assert isinstance(self, Piecewise) def _solve_relational(r): if sym not in r.free_symbols: nonsymfail(r) rv = _solve_inequality(r, sym) if isinstance(rv, Relational): free = rv.args[1].free_symbols if rv.args[0] != sym or sym in free: raise NotImplementedError(filldedent(''' Unable to solve relational %s for %s.''' % (r, sym))) if rv.rel_op == '==': # this equality has been affirmed to have the form # Eq(sym, rhs) where rhs is sym-free; it represents # a zero-width interval which will be ignored # whether it is an isolated condition or contained # within an And or an Or rv = S.false elif rv.rel_op == '!=': try: rv = Or(sym < rv.rhs, sym > rv.rhs) except TypeError: # e.g. x != I ==> all real x satisfy rv = S.true elif rv == (S.NegativeInfinity < sym) & (sym < S.Infinity): rv = S.true return rv def nonsymfail(cond): raise NotImplementedError(filldedent(''' A condition not involving %s appeared: %s''' % (sym, cond))) # make self canonical wrt Relationals reps = dict([ (r, _solve_relational(r)) for r in self.atoms(Relational)]) # process args individually so if any evaluate, their position # in the original Piecewise will be known args = [i.xreplace(reps) for i in self.args] # precondition args expr_cond = [] default = idefault = None for i, (expr, cond) in enumerate(args): if cond is S.false: continue elif cond is S.true: default = expr idefault = i break cond = to_cnf(cond) if isinstance(cond, And): cond = distribute_or_over_and(cond) if isinstance(cond, Or): expr_cond.extend( [(i, expr, o) for o in cond.args if not isinstance(o, Equality)]) elif cond is not S.false: expr_cond.append((i, expr, cond)) # determine intervals represented by conditions int_expr = [] for iarg, expr, cond in expr_cond: if isinstance(cond, And): lower = S.NegativeInfinity upper = S.Infinity for cond2 in cond.args: if isinstance(cond2, Equality): lower = upper # ignore break elif cond2.lts == sym: upper = Min(cond2.gts, upper) elif cond2.gts == sym: lower = Max(cond2.lts, lower) else: nonsymfail(cond2) # should never get here elif isinstance(cond, Relational): lower, upper = cond.lts, cond.gts # part 1: initialize with givens if cond.lts == sym: # part 1a: expand the side ... lower = S.NegativeInfinity # e.g. x <= 0 ---> -oo <= 0 elif cond.gts == sym: # part 1a: ... that can be expanded upper = S.Infinity # e.g. x >= 0 ---> oo >= 0 else: nonsymfail(cond) else: raise NotImplementedError( 'unrecognized condition: %s' % cond) lower, upper = lower, Max(lower, upper) if (lower >= upper) is not S.true: int_expr.append((lower, upper, expr, iarg)) if default is not None: int_expr.append( (S.NegativeInfinity, S.Infinity, default, idefault)) return list(uniq(int_expr)) def _eval_nseries(self, x, n, logx): args = [(ec.expr._eval_nseries(x, n, logx), ec.cond) for ec in self.args] return self.func(*args) def _eval_power(self, s): return self.func(*[(e**s, c) for e, c in self.args]) def _eval_subs(self, old, new): # this is strictly not necessary, but we can keep track # of whether True or False conditions arise and be # somewhat more efficient by avoiding other substitutions # and avoiding invalid conditions that appear after a # True condition args = list(self.args) args_exist = False for i, (e, c) in enumerate(args): c = c._subs(old, new) if c != False: args_exist = True e = e._subs(old, new) args[i] = (e, c) if c == True: break if not args_exist: args = ((Undefined, True),) return self.func(*args) def _eval_transpose(self): return self.func(*[(e.transpose(), c) for e, c in self.args]) def _eval_template_is_attr(self, is_attr): b = None for expr, _ in self.args: a = getattr(expr, is_attr) if a is None: return if b is None: b = a elif b is not a: return return b _eval_is_finite = lambda self: self._eval_template_is_attr( 'is_finite') _eval_is_complex = lambda self: self._eval_template_is_attr('is_complex') _eval_is_even = lambda self: self._eval_template_is_attr('is_even') _eval_is_imaginary = lambda self: self._eval_template_is_attr( 'is_imaginary') _eval_is_integer = lambda self: self._eval_template_is_attr('is_integer') _eval_is_irrational = lambda self: self._eval_template_is_attr( 'is_irrational') _eval_is_negative = lambda self: self._eval_template_is_attr('is_negative') _eval_is_nonnegative = lambda self: self._eval_template_is_attr( 'is_nonnegative') _eval_is_nonpositive = lambda self: self._eval_template_is_attr( 'is_nonpositive') _eval_is_nonzero = lambda self: self._eval_template_is_attr( 'is_nonzero') _eval_is_odd = lambda self: self._eval_template_is_attr('is_odd') _eval_is_polar = lambda self: self._eval_template_is_attr('is_polar') _eval_is_positive = lambda self: self._eval_template_is_attr('is_positive') _eval_is_real = lambda self: self._eval_template_is_attr('is_real') _eval_is_zero = lambda self: self._eval_template_is_attr( 'is_zero') @classmethod def __eval_cond(cls, cond): """Return the truth value of the condition.""" if cond == True: return True if isinstance(cond, Equality): try: diff = cond.lhs - cond.rhs if diff.is_commutative: return diff.is_zero except TypeError: pass def as_expr_set_pairs(self, domain=S.Reals): """Return tuples for each argument of self that give the expression and the interval in which it is valid which is contained within the given domain. If a condition cannot be converted to a set, an error will be raised. The variable of the conditions is assumed to be real; sets of real values are returned. Examples ======== >>> from sympy import Piecewise, Interval >>> from sympy.abc import x >>> p = Piecewise( ... (1, x < 2), ... (2,(x > 0) & (x < 4)), ... (3, True)) >>> p.as_expr_set_pairs() [(1, Interval.open(-oo, 2)), (2, Interval.Ropen(2, 4)), (3, Interval(4, oo))] >>> p.as_expr_set_pairs(Interval(0, 3)) [(1, Interval.Ropen(0, 2)), (2, Interval(2, 3)), (3, EmptySet())] """ exp_sets = [] U = domain complex = not domain.is_subset(S.Reals) for expr, cond in self.args: if complex: for i in cond.atoms(Relational): if not isinstance(i, (Equality, Unequality)): raise ValueError(filldedent(''' Inequalities in the complex domain are not supported. Try the real domain by setting domain=S.Reals''')) cond_int = U.intersect(cond.as_set()) U = U - cond_int exp_sets.append((expr, cond_int)) return exp_sets def _eval_rewrite_as_ITE(self, *args, **kwargs): byfree = {} args = list(args) default = any(c == True for b, c in args) for i, (b, c) in enumerate(args): if not isinstance(b, Boolean) and b != True: raise TypeError(filldedent(''' Expecting Boolean or bool but got `%s` ''' % func_name(b))) if c == True: break # loop over independent conditions for this b for c in c.args if isinstance(c, Or) else [c]: free = c.free_symbols x = free.pop() try: byfree[x] = byfree.setdefault( x, S.EmptySet).union(c.as_set()) except NotImplementedError: if not default: raise NotImplementedError(filldedent(''' A method to determine whether a multivariate conditional is consistent with a complete coverage of all variables has not been implemented so the rewrite is being stopped after encountering `%s`. This error would not occur if a default expression like `(foo, True)` were given. ''' % c)) if byfree[x] in (S.UniversalSet, S.Reals): # collapse the ith condition to True and break args[i] = list(args[i]) c = args[i][1] = True break if c == True: break if c != True: raise ValueError(filldedent(''' Conditions must cover all reals or a final default condition `(foo, True)` must be given. ''')) last, _ = args[i] # ignore all past ith arg for a, c in reversed(args[:i]): last = ITE(c, a, last) return _canonical(last) def piecewise_fold(expr): """ Takes an expression containing a piecewise function and returns the expression in piecewise form. In addition, any ITE conditions are rewritten in negation normal form and simplified. Examples ======== >>> from sympy import Piecewise, piecewise_fold, sympify as S >>> from sympy.abc import x >>> p = Piecewise((x, x < 1), (1, S(1) <= x)) >>> piecewise_fold(x*p) Piecewise((x**2, x < 1), (x, True)) See Also ======== Piecewise """ if not isinstance(expr, Basic) or not expr.has(Piecewise): return expr new_args = [] if isinstance(expr, (ExprCondPair, Piecewise)): for e, c in expr.args: if not isinstance(e, Piecewise): e = piecewise_fold(e) # we don't keep Piecewise in condition because # it has to be checked to see that it's complete # and we convert it to ITE at that time assert not c.has(Piecewise) # pragma: no cover if isinstance(c, ITE): c = c.to_nnf() c = simplify_logic(c, form='cnf') if isinstance(e, Piecewise): new_args.extend([(piecewise_fold(ei), And(ci, c)) for ei, ci in e.args]) else: new_args.append((e, c)) else: from sympy.utilities.iterables import cartes, sift, common_prefix # Given # P1 = Piecewise((e11, c1), (e12, c2), A) # P2 = Piecewise((e21, c1), (e22, c2), B) # ... # the folding of f(P1, P2) is trivially # Piecewise( # (f(e11, e21), c1), # (f(e12, e22), c2), # (f(Piecewise(A), Piecewise(B)), True)) # Certain objects end up rewriting themselves as thus, so # we do that grouping before the more generic folding. # The following applies this idea when f = Add or f = Mul # (and the expression is commutative). if expr.is_Add or expr.is_Mul and expr.is_commutative: p, args = sift(expr.args, lambda x: x.is_Piecewise, binary=True) pc = sift(p, lambda x: tuple([c for e,c in x.args])) for c in list(ordered(pc)): if len(pc[c]) > 1: pargs = [list(i.args) for i in pc[c]] # the first one is the same; there may be more com = common_prefix(*[ [i.cond for i in j] for j in pargs]) n = len(com) collected = [] for i in range(n): collected.append(( expr.func(*[ai[i].expr for ai in pargs]), com[i])) remains = [] for a in pargs: if n == len(a): # no more args continue if a[n].cond == True: # no longer Piecewise remains.append(a[n].expr) else: # restore the remaining Piecewise remains.append( Piecewise(*a[n:], evaluate=False)) if remains: collected.append((expr.func(*remains), True)) args.append(Piecewise(*collected, evaluate=False)) continue args.extend(pc[c]) else: args = expr.args # fold folded = list(map(piecewise_fold, args)) for ec in cartes(*[ (i.args if isinstance(i, Piecewise) else [(i, true)]) for i in folded]): e, c = zip(*ec) new_args.append((expr.func(*e), And(*c))) return Piecewise(*new_args) def _clip(A, B, k): """Return interval B as intervals that are covered by A (keyed to k) and all other intervals of B not covered by A keyed to -1. The reference point of each interval is the rhs; if the lhs is greater than the rhs then an interval of zero width interval will result, e.g. (4, 1) is treated like (1, 1). Examples ======== >>> from sympy.functions.elementary.piecewise import _clip >>> from sympy import Tuple >>> A = Tuple(1, 3) >>> B = Tuple(2, 4) >>> _clip(A, B, 0) [(2, 3, 0), (3, 4, -1)] Interpretation: interval portion (2, 3) of interval (2, 4) is covered by interval (1, 3) and is keyed to 0 as requested; interval (3, 4) was not covered by (1, 3) and is keyed to -1. """ a, b = B c, d = A c, d = Min(Max(c, a), b), Min(Max(d, a), b) a, b = Min(a, b), b p = [] if a != c: p.append((a, c, -1)) else: pass if c != d: p.append((c, d, k)) else: pass if b != d: if d == c and p and p[-1][-1] == -1: p[-1] = p[-1][0], b, -1 else: p.append((d, b, -1)) else: pass return p
ac07bcf7e11fc9145f39465fea9495dcd221434fadd889af982c839af0f88810
import string from sympy import ( Symbol, symbols, Dummy, S, Sum, Rational, oo, pi, I, expand_func, diff, EulerGamma, cancel, re, im, Product, carmichael) from sympy.functions import ( bernoulli, harmonic, bell, fibonacci, tribonacci, lucas, euler, catalan, genocchi, partition, binomial, gamma, sqrt, cbrt, hyper, log, digamma, trigamma, polygamma, factorial, sin, cos, cot, zeta) from sympy.functions.combinatorial.numbers import _nT from sympy.core.compatibility import range from sympy.utilities.pytest import XFAIL, raises from sympy.core.numbers import GoldenRatio x = Symbol('x') def test_carmichael(): assert carmichael.find_carmichael_numbers_in_range(0, 561) == [] assert carmichael.find_carmichael_numbers_in_range(561, 562) == [561] assert carmichael.find_carmichael_numbers_in_range(561, 1105) == carmichael.find_carmichael_numbers_in_range(561, 562) assert carmichael.find_first_n_carmichaels(5) == [561, 1105, 1729, 2465, 2821] assert carmichael.is_prime(2821) == False assert carmichael.is_prime(2465) == False assert carmichael.is_prime(1729) == False assert carmichael.is_prime(1105) == False assert carmichael.is_prime(561) == False def test_bernoulli(): assert bernoulli(0) == 1 assert bernoulli(1) == Rational(-1, 2) assert bernoulli(2) == Rational(1, 6) assert bernoulli(3) == 0 assert bernoulli(4) == Rational(-1, 30) assert bernoulli(5) == 0 assert bernoulli(6) == Rational(1, 42) assert bernoulli(7) == 0 assert bernoulli(8) == Rational(-1, 30) assert bernoulli(10) == Rational(5, 66) assert bernoulli(1000001) == 0 assert bernoulli(0, x) == 1 assert bernoulli(1, x) == x - Rational(1, 2) assert bernoulli(2, x) == x**2 - x + Rational(1, 6) assert bernoulli(3, x) == x**3 - (3*x**2)/2 + x/2 # Should be fast; computed with mpmath b = bernoulli(1000) assert b.p % 10**10 == 7950421099 assert b.q == 342999030 b = bernoulli(10**6, evaluate=False).evalf() assert str(b) == '-2.23799235765713e+4767529' # Issue #8527 l = Symbol('l', integer=True) m = Symbol('m', integer=True, nonnegative=True) n = Symbol('n', integer=True, positive=True) assert isinstance(bernoulli(2 * l + 1), bernoulli) assert isinstance(bernoulli(2 * m + 1), bernoulli) assert bernoulli(2 * n + 1) == 0 def test_fibonacci(): assert [fibonacci(n) for n in range(-3, 5)] == [2, -1, 1, 0, 1, 1, 2, 3] assert fibonacci(100) == 354224848179261915075 assert [lucas(n) for n in range(-3, 5)] == [-4, 3, -1, 2, 1, 3, 4, 7] assert lucas(100) == 792070839848372253127 assert fibonacci(1, x) == 1 assert fibonacci(2, x) == x assert fibonacci(3, x) == x**2 + 1 assert fibonacci(4, x) == x**3 + 2*x # issue #8800 n = Dummy('n') assert fibonacci(n).limit(n, S.Infinity) == S.Infinity assert lucas(n).limit(n, S.Infinity) == S.Infinity assert fibonacci(n).rewrite(sqrt) == \ 2**(-n)*sqrt(5)*((1 + sqrt(5))**n - (-sqrt(5) + 1)**n) / 5 assert fibonacci(n).rewrite(sqrt).subs(n, 10).expand() == fibonacci(10) assert fibonacci(n).rewrite(GoldenRatio).subs(n,10).evalf() == \ fibonacci(10) assert lucas(n).rewrite(sqrt) == \ (fibonacci(n-1).rewrite(sqrt) + fibonacci(n+1).rewrite(sqrt)).simplify() assert lucas(n).rewrite(sqrt).subs(n, 10).expand() == lucas(10) def test_tribonacci(): assert [tribonacci(n) for n in range(8)] == [0, 1, 1, 2, 4, 7, 13, 24] assert tribonacci(100) == 98079530178586034536500564 assert tribonacci(0, x) == 0 assert tribonacci(1, x) == 1 assert tribonacci(2, x) == x**2 assert tribonacci(3, x) == x**4 + x assert tribonacci(4, x) == x**6 + 2*x**3 + 1 assert tribonacci(5, x) == x**8 + 3*x**5 + 3*x**2 n = Dummy('n') assert tribonacci(n).limit(n, S.Infinity) == S.Infinity w = (-1 + S.ImaginaryUnit * sqrt(3)) / 2 a = (1 + cbrt(19 + 3*sqrt(33)) + cbrt(19 - 3*sqrt(33))) / 3 b = (1 + w*cbrt(19 + 3*sqrt(33)) + w**2*cbrt(19 - 3*sqrt(33))) / 3 c = (1 + w**2*cbrt(19 + 3*sqrt(33)) + w*cbrt(19 - 3*sqrt(33))) / 3 assert tribonacci(n).rewrite(sqrt) == \ (a**(n + 1)/((a - b)*(a - c)) + b**(n + 1)/((b - a)*(b - c)) + c**(n + 1)/((c - a)*(c - b))) assert tribonacci(n).rewrite(sqrt).subs(n, 4).simplify() == tribonacci(4) assert tribonacci(n).rewrite(GoldenRatio).subs(n,10).evalf() == \ tribonacci(10) raises(ValueError, lambda: tribonacci(-1, x)) def test_bell(): assert [bell(n) for n in range(8)] == [1, 1, 2, 5, 15, 52, 203, 877] assert bell(0, x) == 1 assert bell(1, x) == x assert bell(2, x) == x**2 + x assert bell(5, x) == x**5 + 10*x**4 + 25*x**3 + 15*x**2 + x assert bell(oo) == S.Infinity raises(ValueError, lambda: bell(oo, x)) raises(ValueError, lambda: bell(-1)) raises(ValueError, lambda: bell(S(1)/2)) X = symbols('x:6') # X = (x0, x1, .. x5) # at the same time: X[1] = x1, X[2] = x2 for standard readablity. # but we must supply zero-based indexed object X[1:] = (x1, .. x5) assert bell(6, 2, X[1:]) == 6*X[5]*X[1] + 15*X[4]*X[2] + 10*X[3]**2 assert bell( 6, 3, X[1:]) == 15*X[4]*X[1]**2 + 60*X[3]*X[2]*X[1] + 15*X[2]**3 X = (1, 10, 100, 1000, 10000) assert bell(6, 2, X) == (6 + 15 + 10)*10000 X = (1, 2, 3, 3, 5) assert bell(6, 2, X) == 6*5 + 15*3*2 + 10*3**2 X = (1, 2, 3, 5) assert bell(6, 3, X) == 15*5 + 60*3*2 + 15*2**3 # Dobinski's formula n = Symbol('n', integer=True, nonnegative=True) # For large numbers, this is too slow # For nonintegers, there are significant precision errors for i in [0, 2, 3, 7, 13, 42, 55]: assert bell(i).evalf() == bell(n).rewrite(Sum).evalf(subs={n: i}) # issue 9184 n = Dummy('n') assert bell(n).limit(n, S.Infinity) == S.Infinity def test_harmonic(): n = Symbol("n") m = Symbol("m") assert harmonic(n, 0) == n assert harmonic(n).evalf() == harmonic(n) assert harmonic(n, 1) == harmonic(n) assert harmonic(1, n).evalf() == harmonic(1, n) assert harmonic(0, 1) == 0 assert harmonic(1, 1) == 1 assert harmonic(2, 1) == Rational(3, 2) assert harmonic(3, 1) == Rational(11, 6) assert harmonic(4, 1) == Rational(25, 12) assert harmonic(0, 2) == 0 assert harmonic(1, 2) == 1 assert harmonic(2, 2) == Rational(5, 4) assert harmonic(3, 2) == Rational(49, 36) assert harmonic(4, 2) == Rational(205, 144) assert harmonic(0, 3) == 0 assert harmonic(1, 3) == 1 assert harmonic(2, 3) == Rational(9, 8) assert harmonic(3, 3) == Rational(251, 216) assert harmonic(4, 3) == Rational(2035, 1728) assert harmonic(oo, -1) == S.NaN assert harmonic(oo, 0) == oo assert harmonic(oo, S.Half) == oo assert harmonic(oo, 1) == oo assert harmonic(oo, 2) == (pi**2)/6 assert harmonic(oo, 3) == zeta(3) assert harmonic(0, m) == 0 def test_harmonic_rational(): ne = S(6) no = S(5) pe = S(8) po = S(9) qe = S(10) qo = S(13) Heee = harmonic(ne + pe/qe) Aeee = (-log(10) + 2*(-1/S(4) + sqrt(5)/4)*log(sqrt(-sqrt(5)/8 + 5/S(8))) + 2*(-sqrt(5)/4 - 1/S(4))*log(sqrt(sqrt(5)/8 + 5/S(8))) + pi*(1/S(4) + sqrt(5)/4)/(2*sqrt(-sqrt(5)/8 + 5/S(8))) + 13944145/S(4720968)) Heeo = harmonic(ne + pe/qo) Aeeo = (-log(26) + 2*log(sin(3*pi/13))*cos(4*pi/13) + 2*log(sin(2*pi/13))*cos(32*pi/13) + 2*log(sin(5*pi/13))*cos(80*pi/13) - 2*log(sin(6*pi/13))*cos(5*pi/13) - 2*log(sin(4*pi/13))*cos(pi/13) + pi*cot(5*pi/13)/2 - 2*log(sin(pi/13))*cos(3*pi/13) + 2422020029/S(702257080)) Heoe = harmonic(ne + po/qe) Aeoe = (-log(20) + 2*(1/S(4) + sqrt(5)/4)*log(-1/S(4) + sqrt(5)/4) + 2*(-1/S(4) + sqrt(5)/4)*log(sqrt(-sqrt(5)/8 + 5/S(8))) + 2*(-sqrt(5)/4 - 1/S(4))*log(sqrt(sqrt(5)/8 + 5/S(8))) + 2*(-sqrt(5)/4 + 1/S(4))*log(1/S(4) + sqrt(5)/4) + 11818877030/S(4286604231) + pi*(sqrt(5)/8 + 5/S(8))/sqrt(-sqrt(5)/8 + 5/S(8))) Heoo = harmonic(ne + po/qo) Aeoo = (-log(26) + 2*log(sin(3*pi/13))*cos(54*pi/13) + 2*log(sin(4*pi/13))*cos(6*pi/13) + 2*log(sin(6*pi/13))*cos(108*pi/13) - 2*log(sin(5*pi/13))*cos(pi/13) - 2*log(sin(pi/13))*cos(5*pi/13) + pi*cot(4*pi/13)/2 - 2*log(sin(2*pi/13))*cos(3*pi/13) + 11669332571/S(3628714320)) Hoee = harmonic(no + pe/qe) Aoee = (-log(10) + 2*(-1/S(4) + sqrt(5)/4)*log(sqrt(-sqrt(5)/8 + 5/S(8))) + 2*(-sqrt(5)/4 - 1/S(4))*log(sqrt(sqrt(5)/8 + 5/S(8))) + pi*(1/S(4) + sqrt(5)/4)/(2*sqrt(-sqrt(5)/8 + 5/S(8))) + 779405/S(277704)) Hoeo = harmonic(no + pe/qo) Aoeo = (-log(26) + 2*log(sin(3*pi/13))*cos(4*pi/13) + 2*log(sin(2*pi/13))*cos(32*pi/13) + 2*log(sin(5*pi/13))*cos(80*pi/13) - 2*log(sin(6*pi/13))*cos(5*pi/13) - 2*log(sin(4*pi/13))*cos(pi/13) + pi*cot(5*pi/13)/2 - 2*log(sin(pi/13))*cos(3*pi/13) + 53857323/S(16331560)) Hooe = harmonic(no + po/qe) Aooe = (-log(20) + 2*(1/S(4) + sqrt(5)/4)*log(-1/S(4) + sqrt(5)/4) + 2*(-1/S(4) + sqrt(5)/4)*log(sqrt(-sqrt(5)/8 + 5/S(8))) + 2*(-sqrt(5)/4 - 1/S(4))*log(sqrt(sqrt(5)/8 + 5/S(8))) + 2*(-sqrt(5)/4 + 1/S(4))*log(1/S(4) + sqrt(5)/4) + 486853480/S(186374097) + pi*(sqrt(5)/8 + 5/S(8))/sqrt(-sqrt(5)/8 + 5/S(8))) Hooo = harmonic(no + po/qo) Aooo = (-log(26) + 2*log(sin(3*pi/13))*cos(54*pi/13) + 2*log(sin(4*pi/13))*cos(6*pi/13) + 2*log(sin(6*pi/13))*cos(108*pi/13) - 2*log(sin(5*pi/13))*cos(pi/13) - 2*log(sin(pi/13))*cos(5*pi/13) + pi*cot(4*pi/13)/2 - 2*log(sin(2*pi/13))*cos(3*pi/13) + 383693479/S(125128080)) H = [Heee, Heeo, Heoe, Heoo, Hoee, Hoeo, Hooe, Hooo] A = [Aeee, Aeeo, Aeoe, Aeoo, Aoee, Aoeo, Aooe, Aooo] for h, a in zip(H, A): e = expand_func(h).doit() assert cancel(e/a) == 1 assert abs(h.n() - a.n()) < 1e-12 def test_harmonic_evalf(): assert str(harmonic(1.5).evalf(n=10)) == '1.280372306' assert str(harmonic(1.5, 2).evalf(n=10)) == '1.154576311' # issue 7443 def test_harmonic_rewrite_polygamma(): n = Symbol("n") m = Symbol("m") assert harmonic(n).rewrite(digamma) == polygamma(0, n + 1) + EulerGamma assert harmonic(n).rewrite(trigamma) == polygamma(0, n + 1) + EulerGamma assert harmonic(n).rewrite(polygamma) == polygamma(0, n + 1) + EulerGamma assert harmonic(n,3).rewrite(polygamma) == polygamma(2, n + 1)/2 - polygamma(2, 1)/2 assert harmonic(n,m).rewrite(polygamma) == (-1)**m*(polygamma(m - 1, 1) - polygamma(m - 1, n + 1))/factorial(m - 1) assert expand_func(harmonic(n+4)) == harmonic(n) + 1/(n + 4) + 1/(n + 3) + 1/(n + 2) + 1/(n + 1) assert expand_func(harmonic(n-4)) == harmonic(n) - 1/(n - 1) - 1/(n - 2) - 1/(n - 3) - 1/n assert harmonic(n, m).rewrite("tractable") == harmonic(n, m).rewrite(polygamma) @XFAIL def test_harmonic_limit_fail(): n = Symbol("n") m = Symbol("m") # For m > 1: assert limit(harmonic(n, m), n, oo) == zeta(m) @XFAIL def test_harmonic_rewrite_sum_fail(): n = Symbol("n") m = Symbol("m") _k = Dummy("k") assert harmonic(n).rewrite(Sum) == Sum(1/_k, (_k, 1, n)) assert harmonic(n, m).rewrite(Sum) == Sum(_k**(-m), (_k, 1, n)) def replace_dummy(expr, sym): dum = expr.atoms(Dummy) if not dum: return expr assert len(dum) == 1 return expr.xreplace({dum.pop(): sym}) def test_harmonic_rewrite_sum(): n = Symbol("n") m = Symbol("m") _k = Dummy("k") assert replace_dummy(harmonic(n).rewrite(Sum), _k) == Sum(1/_k, (_k, 1, n)) assert replace_dummy(harmonic(n, m).rewrite(Sum), _k) == Sum(_k**(-m), (_k, 1, n)) def test_euler(): assert euler(0) == 1 assert euler(1) == 0 assert euler(2) == -1 assert euler(3) == 0 assert euler(4) == 5 assert euler(6) == -61 assert euler(8) == 1385 assert euler(20, evaluate=False) != 370371188237525 n = Symbol('n', integer=True) assert euler(n) != -1 assert euler(n).subs(n, 2) == -1 raises(ValueError, lambda: euler(-2)) raises(ValueError, lambda: euler(-3)) raises(ValueError, lambda: euler(2.3)) assert euler(20).evalf() == 370371188237525.0 assert euler(20, evaluate=False).evalf() == 370371188237525.0 assert euler(n).rewrite(Sum) == euler(n) # XXX: Not sure what the guy who wrote this test was trying to do with the _j and _k stuff n = Symbol('n', integer=True, nonnegative=True) assert euler(2*n + 1).rewrite(Sum) == 0 @XFAIL def test_euler_failing(): # depends on dummy variables being implemented https://github.com/sympy/sympy/issues/5665 assert euler(2*n).rewrite(Sum) == I*Sum(Sum((-1)**_j*2**(-_k)*I**(-_k)*(-2*_j + _k)**(2*n + 1)*binomial(_k, _j)/_k, (_j, 0, _k)), (_k, 1, 2*n + 1)) def test_euler_odd(): n = Symbol('n', odd=True, positive=True) assert euler(n) == 0 n = Symbol('n', odd=True) assert euler(n) != 0 def test_euler_polynomials(): assert euler(0, x) == 1 assert euler(1, x) == x - Rational(1, 2) assert euler(2, x) == x**2 - x assert euler(3, x) == x**3 - (3*x**2)/2 + Rational(1, 4) m = Symbol('m') assert isinstance(euler(m, x), euler) from sympy import Float A = Float('-0.46237208575048694923364757452876131e8') # from Maple B = euler(19, S.Pi.evalf(32)) assert abs((A - B)/A) < 1e-31 # expect low relative error C = euler(19, S.Pi, evaluate=False).evalf(32) assert abs((A - C)/A) < 1e-31 def test_euler_polynomial_rewrite(): m = Symbol('m') A = euler(m, x).rewrite('Sum'); assert A.subs({m:3, x:5}).doit() == euler(3, 5) def test_catalan(): n = Symbol('n', integer=True) m = Symbol('m', integer=True, positive=True) k = Symbol('k', integer=True, nonnegative=True) p = Symbol('p', nonnegative=True) catalans = [1, 1, 2, 5, 14, 42, 132, 429, 1430, 4862, 16796, 58786] for i, c in enumerate(catalans): assert catalan(i) == c assert catalan(n).rewrite(factorial).subs(n, i) == c assert catalan(n).rewrite(Product).subs(n, i).doit() == c assert catalan(x) == catalan(x) assert catalan(2*x).rewrite(binomial) == binomial(4*x, 2*x)/(2*x + 1) assert catalan(Rational(1, 2)).rewrite(gamma) == 8/(3*pi) assert catalan(Rational(1, 2)).rewrite(factorial).rewrite(gamma) ==\ 8 / (3 * pi) assert catalan(3*x).rewrite(gamma) == 4**( 3*x)*gamma(3*x + Rational(1, 2))/(sqrt(pi)*gamma(3*x + 2)) assert catalan(x).rewrite(hyper) == hyper((-x + 1, -x), (2,), 1) assert catalan(n).rewrite(factorial) == factorial(2*n) / (factorial(n + 1) * factorial(n)) assert isinstance(catalan(n).rewrite(Product), catalan) assert isinstance(catalan(m).rewrite(Product), Product) assert diff(catalan(x), x) == (polygamma( 0, x + Rational(1, 2)) - polygamma(0, x + 2) + log(4))*catalan(x) assert catalan(x).evalf() == catalan(x) c = catalan(S.Half).evalf() assert str(c) == '0.848826363156775' c = catalan(I).evalf(3) assert str((re(c), im(c))) == '(0.398, -0.0209)' # Assumptions assert catalan(p).is_positive is True assert catalan(k).is_integer is True assert catalan(m+3).is_composite is True def test_genocchi(): genocchis = [1, -1, 0, 1, 0, -3, 0, 17] for n, g in enumerate(genocchis): assert genocchi(n + 1) == g m = Symbol('m', integer=True) n = Symbol('n', integer=True, positive=True) assert genocchi(m) == genocchi(m) assert genocchi(n).rewrite(bernoulli) == (1 - 2 ** n) * bernoulli(n) * 2 assert genocchi(2 * n).is_odd assert genocchi(4 * n).is_positive # these are the only 2 prime Genocchi numbers assert genocchi(6, evaluate=False).is_prime == S(-3).is_prime assert genocchi(8, evaluate=False).is_prime assert genocchi(4 * n + 2).is_negative assert genocchi(4 * n - 2).is_negative def test_partition(): partition_nums = [1, 1, 2, 3, 5, 7, 11, 15, 22] for n, p in enumerate(partition_nums): assert partition(n) == p x = Symbol('x') y = Symbol('y', real=True) m = Symbol('m', integer=True) n = Symbol('n', integer=True, negative=True) p = Symbol('p', integer=True, nonnegative=True) assert partition(m).is_integer assert not partition(m).is_negative assert partition(m).is_nonnegative assert partition(n).is_zero assert partition(p).is_positive assert partition(x).subs(x, 7) == 15 assert partition(y).subs(y, 8) == 22 raises(ValueError, lambda: partition(S(5)/4)) def test__nT(): assert [_nT(i, j) for i in range(5) for j in range(i + 2)] == [ 1, 0, 0, 1, 0, 0, 1, 1, 0, 0, 1, 1, 1, 0, 0, 1, 2, 1, 1, 0] check = [_nT(10, i) for i in range(11)] assert check == [0, 1, 5, 8, 9, 7, 5, 3, 2, 1, 1] assert all(type(i) is int for i in check) assert _nT(10, 5) == 7 assert _nT(100, 98) == 2 assert _nT(100, 100) == 1 assert _nT(10, 3) == 8 def test_nC_nP_nT(): from sympy.utilities.iterables import ( multiset_permutations, multiset_combinations, multiset_partitions, partitions, subsets, permutations) from sympy.functions.combinatorial.numbers import ( nP, nC, nT, stirling, _multiset_histogram, _AOP_product) from sympy.combinatorics.permutations import Permutation from sympy.core.numbers import oo from random import choice c = string.ascii_lowercase for i in range(100): s = ''.join(choice(c) for i in range(7)) u = len(s) == len(set(s)) try: tot = 0 for i in range(8): check = nP(s, i) tot += check assert len(list(multiset_permutations(s, i))) == check if u: assert nP(len(s), i) == check assert nP(s) == tot except AssertionError: print(s, i, 'failed perm test') raise ValueError() for i in range(100): s = ''.join(choice(c) for i in range(7)) u = len(s) == len(set(s)) try: tot = 0 for i in range(8): check = nC(s, i) tot += check assert len(list(multiset_combinations(s, i))) == check if u: assert nC(len(s), i) == check assert nC(s) == tot if u: assert nC(len(s)) == tot except AssertionError: print(s, i, 'failed combo test') raise ValueError() for i in range(1, 10): tot = 0 for j in range(1, i + 2): check = nT(i, j) assert check.is_Integer tot += check assert sum(1 for p in partitions(i, j, size=True) if p[0] == j) == check assert nT(i) == tot for i in range(1, 10): tot = 0 for j in range(1, i + 2): check = nT(range(i), j) tot += check assert len(list(multiset_partitions(list(range(i)), j))) == check assert nT(range(i)) == tot for i in range(100): s = ''.join(choice(c) for i in range(7)) u = len(s) == len(set(s)) try: tot = 0 for i in range(1, 8): check = nT(s, i) tot += check assert len(list(multiset_partitions(s, i))) == check if u: assert nT(range(len(s)), i) == check if u: assert nT(range(len(s))) == tot assert nT(s) == tot except AssertionError: print(s, i, 'failed partition test') raise ValueError() # tests for Stirling numbers of the first kind that are not tested in the # above assert [stirling(9, i, kind=1) for i in range(11)] == [ 0, 40320, 109584, 118124, 67284, 22449, 4536, 546, 36, 1, 0] perms = list(permutations(range(4))) assert [sum(1 for p in perms if Permutation(p).cycles == i) for i in range(5)] == [0, 6, 11, 6, 1] == [ stirling(4, i, kind=1) for i in range(5)] # http://oeis.org/A008275 assert [stirling(n, k, signed=1) for n in range(10) for k in range(1, n + 1)] == [ 1, -1, 1, 2, -3, 1, -6, 11, -6, 1, 24, -50, 35, -10, 1, -120, 274, -225, 85, -15, 1, 720, -1764, 1624, -735, 175, -21, 1, -5040, 13068, -13132, 6769, -1960, 322, -28, 1, 40320, -109584, 118124, -67284, 22449, -4536, 546, -36, 1] # https://en.wikipedia.org/wiki/Stirling_numbers_of_the_first_kind assert [stirling(n, k, kind=1) for n in range(10) for k in range(n+1)] == [ 1, 0, 1, 0, 1, 1, 0, 2, 3, 1, 0, 6, 11, 6, 1, 0, 24, 50, 35, 10, 1, 0, 120, 274, 225, 85, 15, 1, 0, 720, 1764, 1624, 735, 175, 21, 1, 0, 5040, 13068, 13132, 6769, 1960, 322, 28, 1, 0, 40320, 109584, 118124, 67284, 22449, 4536, 546, 36, 1] # https://en.wikipedia.org/wiki/Stirling_numbers_of_the_second_kind assert [stirling(n, k, kind=2) for n in range(10) for k in range(n+1)] == [ 1, 0, 1, 0, 1, 1, 0, 1, 3, 1, 0, 1, 7, 6, 1, 0, 1, 15, 25, 10, 1, 0, 1, 31, 90, 65, 15, 1, 0, 1, 63, 301, 350, 140, 21, 1, 0, 1, 127, 966, 1701, 1050, 266, 28, 1, 0, 1, 255, 3025, 7770, 6951, 2646, 462, 36, 1] assert stirling(3, 4, kind=1) == stirling(3, 4, kind=1) == 0 raises(ValueError, lambda: stirling(-2, 2)) def delta(p): if len(p) == 1: return oo return min(abs(i[0] - i[1]) for i in subsets(p, 2)) parts = multiset_partitions(range(5), 3) d = 2 assert (sum(1 for p in parts if all(delta(i) >= d for i in p)) == stirling(5, 3, d=d) == 7) # other coverage tests assert nC('abb', 2) == nC('aab', 2) == 2 assert nP(3, 3, replacement=True) == nP('aabc', 3, replacement=True) == 27 assert nP(3, 4) == 0 assert nP('aabc', 5) == 0 assert nC(4, 2, replacement=True) == nC('abcdd', 2, replacement=True) == \ len(list(multiset_combinations('aabbccdd', 2))) == 10 assert nC('abcdd') == sum(nC('abcdd', i) for i in range(6)) == 24 assert nC(list('abcdd'), 4) == 4 assert nT('aaaa') == nT(4) == len(list(partitions(4))) == 5 assert nT('aaab') == len(list(multiset_partitions('aaab'))) == 7 assert nC('aabb'*3, 3) == 4 # aaa, bbb, abb, baa assert dict(_AOP_product((4,1,1,1))) == { 0: 1, 1: 4, 2: 7, 3: 8, 4: 8, 5: 7, 6: 4, 7: 1} # the following was the first t that showed a problem in a previous form of # the function, so it's not as random as it may appear t = (3, 9, 4, 6, 6, 5, 5, 2, 10, 4) assert sum(_AOP_product(t)[i] for i in range(55)) == 58212000 raises(ValueError, lambda: _multiset_histogram({1:'a'})) def test_PR_14617(): from sympy.functions.combinatorial.numbers import nT for n in (0, []): for k in (-1, 0, 1): if k == 0: assert nT(n, k) == 1 else: assert nT(n, k) == 0 def test_issue_8496(): n = Symbol("n") k = Symbol("k") raises(TypeError, lambda: catalan(n, k)) def test_issue_8601(): n = Symbol('n', integer=True, negative=True) assert catalan(n - 1) == S.Zero assert catalan(-S.Half) == S.ComplexInfinity assert catalan(-S.One) == -S.Half c1 = catalan(-5.6).evalf() assert str(c1) == '6.93334070531408e-5' c2 = catalan(-35.4).evalf() assert str(c2) == '-4.14189164517449e-24'
7b9c9162d7e6395b7585ac59ebbcf3fc1cf514974114dfa057f8593c5af94744
from sympy import (symbols, Symbol, nan, oo, zoo, I, sinh, sin, pi, atan, acos, Rational, sqrt, asin, acot, coth, E, S, tan, tanh, cos, cosh, atan2, exp, log, asinh, acoth, atanh, O, cancel, Matrix, re, im, Float, Pow, gcd, sec, csc, cot, diff, simplify, Heaviside, arg, conjugate, series, FiniteSet, asec, acsc, Mul, sinc, jn, Product, AccumBounds) from sympy.core.compatibility import range from sympy.utilities.pytest import XFAIL, slow, raises from sympy.core.relational import Ne, Eq from sympy.functions.elementary.piecewise import Piecewise x, y, z = symbols('x y z') r = Symbol('r', real=True) k = Symbol('k', integer=True) p = Symbol('p', positive=True) n = Symbol('n', negative=True) a = Symbol('a', algebraic=True) na = Symbol('na', nonzero=True, algebraic=True) def test_sin(): x, y = symbols('x y') assert sin.nargs == FiniteSet(1) assert sin(nan) == nan assert sin(zoo) == nan assert sin(oo) == AccumBounds(-1, 1) assert sin(oo) - sin(oo) == AccumBounds(-2, 2) assert sin(oo*I) == oo*I assert sin(-oo*I) == -oo*I assert 0*sin(oo) == S.Zero assert 0/sin(oo) == S.Zero assert 0 + sin(oo) == AccumBounds(-1, 1) assert 5 + sin(oo) == AccumBounds(4, 6) assert sin(0) == 0 assert sin(asin(x)) == x assert sin(atan(x)) == x / sqrt(1 + x**2) assert sin(acos(x)) == sqrt(1 - x**2) assert sin(acot(x)) == 1 / (sqrt(1 + 1 / x**2) * x) assert sin(acsc(x)) == 1 / x assert sin(asec(x)) == sqrt(1 - 1 / x**2) assert sin(atan2(y, x)) == y / sqrt(x**2 + y**2) assert sin(pi*I) == sinh(pi)*I assert sin(-pi*I) == -sinh(pi)*I assert sin(-2*I) == -sinh(2)*I assert sin(pi) == 0 assert sin(-pi) == 0 assert sin(2*pi) == 0 assert sin(-2*pi) == 0 assert sin(-3*10**73*pi) == 0 assert sin(7*10**103*pi) == 0 assert sin(pi/2) == 1 assert sin(-pi/2) == -1 assert sin(5*pi/2) == 1 assert sin(7*pi/2) == -1 ne = symbols('ne', integer=True, even=False) e = symbols('e', even=True) assert sin(pi*ne/2) == (-1)**(ne/2 - S.Half) assert sin(pi*k/2).func == sin assert sin(pi*e/2) == 0 assert sin(pi*k) == 0 assert sin(pi*k).subs(k, 3) == sin(pi*k/2).subs(k, 6) # issue 8298 assert sin(pi/3) == S.Half*sqrt(3) assert sin(-2*pi/3) == -S.Half*sqrt(3) assert sin(pi/4) == S.Half*sqrt(2) assert sin(-pi/4) == -S.Half*sqrt(2) assert sin(17*pi/4) == S.Half*sqrt(2) assert sin(-3*pi/4) == -S.Half*sqrt(2) assert sin(pi/6) == S.Half assert sin(-pi/6) == -S.Half assert sin(7*pi/6) == -S.Half assert sin(-5*pi/6) == -S.Half assert sin(1*pi/5) == sqrt((5 - sqrt(5)) / 8) assert sin(2*pi/5) == sqrt((5 + sqrt(5)) / 8) assert sin(3*pi/5) == sin(2*pi/5) assert sin(4*pi/5) == sin(1*pi/5) assert sin(6*pi/5) == -sin(1*pi/5) assert sin(8*pi/5) == -sin(2*pi/5) assert sin(-1273*pi/5) == -sin(2*pi/5) assert sin(pi/8) == sqrt((2 - sqrt(2))/4) assert sin(pi/10) == -S(1)/4 + sqrt(5)/4 assert sin(pi/12) == -sqrt(2)/4 + sqrt(6)/4 assert sin(5*pi/12) == sqrt(2)/4 + sqrt(6)/4 assert sin(-7*pi/12) == -sqrt(2)/4 - sqrt(6)/4 assert sin(-11*pi/12) == sqrt(2)/4 - sqrt(6)/4 assert sin(104*pi/105) == sin(pi/105) assert sin(106*pi/105) == -sin(pi/105) assert sin(-104*pi/105) == -sin(pi/105) assert sin(-106*pi/105) == sin(pi/105) assert sin(x*I) == sinh(x)*I assert sin(k*pi) == 0 assert sin(17*k*pi) == 0 assert sin(k*pi*I) == sinh(k*pi)*I assert sin(r).is_real is True assert sin(0, evaluate=False).is_algebraic assert sin(a).is_algebraic is None assert sin(na).is_algebraic is False q = Symbol('q', rational=True) assert sin(pi*q).is_algebraic qn = Symbol('qn', rational=True, nonzero=True) assert sin(qn).is_rational is False assert sin(q).is_rational is None # issue 8653 assert isinstance(sin( re(x) - im(y)), sin) is True assert isinstance(sin(-re(x) + im(y)), sin) is False for d in list(range(1, 22)) + [60, 85]: for n in range(0, d*2 + 1): x = n*pi/d e = abs( float(sin(x)) - sin(float(x)) ) assert e < 1e-12 def test_sin_cos(): for d in [1, 2, 3, 4, 5, 6, 10, 12, 15, 20, 24, 30, 40, 60, 120]: # list is not exhaustive... for n in range(-2*d, d*2): x = n*pi/d assert sin(x + pi/2) == cos(x), "fails for %d*pi/%d" % (n, d) assert sin(x - pi/2) == -cos(x), "fails for %d*pi/%d" % (n, d) assert sin(x) == cos(x - pi/2), "fails for %d*pi/%d" % (n, d) assert -sin(x) == cos(x + pi/2), "fails for %d*pi/%d" % (n, d) def test_sin_series(): assert sin(x).series(x, 0, 9) == \ x - x**3/6 + x**5/120 - x**7/5040 + O(x**9) def test_sin_rewrite(): assert sin(x).rewrite(exp) == -I*(exp(I*x) - exp(-I*x))/2 assert sin(x).rewrite(tan) == 2*tan(x/2)/(1 + tan(x/2)**2) assert sin(x).rewrite(cot) == 2*cot(x/2)/(1 + cot(x/2)**2) assert sin(sinh(x)).rewrite( exp).subs(x, 3).n() == sin(x).rewrite(exp).subs(x, sinh(3)).n() assert sin(cosh(x)).rewrite( exp).subs(x, 3).n() == sin(x).rewrite(exp).subs(x, cosh(3)).n() assert sin(tanh(x)).rewrite( exp).subs(x, 3).n() == sin(x).rewrite(exp).subs(x, tanh(3)).n() assert sin(coth(x)).rewrite( exp).subs(x, 3).n() == sin(x).rewrite(exp).subs(x, coth(3)).n() assert sin(sin(x)).rewrite( exp).subs(x, 3).n() == sin(x).rewrite(exp).subs(x, sin(3)).n() assert sin(cos(x)).rewrite( exp).subs(x, 3).n() == sin(x).rewrite(exp).subs(x, cos(3)).n() assert sin(tan(x)).rewrite( exp).subs(x, 3).n() == sin(x).rewrite(exp).subs(x, tan(3)).n() assert sin(cot(x)).rewrite( exp).subs(x, 3).n() == sin(x).rewrite(exp).subs(x, cot(3)).n() assert sin(log(x)).rewrite(Pow) == I*x**-I / 2 - I*x**I /2 assert sin(x).rewrite(csc) == 1/csc(x) assert sin(x).rewrite(cos) == cos(x - pi / 2, evaluate=False) assert sin(x).rewrite(sec) == 1 / sec(x - pi / 2, evaluate=False) def test_sin_expansion(): # Note: these formulas are not unique. The ones here come from the # Chebyshev formulas. assert sin(x + y).expand(trig=True) == sin(x)*cos(y) + cos(x)*sin(y) assert sin(x - y).expand(trig=True) == sin(x)*cos(y) - cos(x)*sin(y) assert sin(y - x).expand(trig=True) == cos(x)*sin(y) - sin(x)*cos(y) assert sin(2*x).expand(trig=True) == 2*sin(x)*cos(x) assert sin(3*x).expand(trig=True) == -4*sin(x)**3 + 3*sin(x) assert sin(4*x).expand(trig=True) == -8*sin(x)**3*cos(x) + 4*sin(x)*cos(x) assert sin(2).expand(trig=True) == 2*sin(1)*cos(1) assert sin(3).expand(trig=True) == -4*sin(1)**3 + 3*sin(1) def test_sin_AccumBounds(): assert sin(AccumBounds(-oo, oo)) == AccumBounds(-1, 1) assert sin(AccumBounds(0, oo)) == AccumBounds(-1, 1) assert sin(AccumBounds(-oo, 0)) == AccumBounds(-1, 1) assert sin(AccumBounds(0, 2*S.Pi)) == AccumBounds(-1, 1) assert sin(AccumBounds(0, 3*S.Pi/4)) == AccumBounds(0, 1) assert sin(AccumBounds(3*S.Pi/4, 7*S.Pi/4)) == AccumBounds(-1, sin(3*S.Pi/4)) assert sin(AccumBounds(S.Pi/4, S.Pi/3)) == AccumBounds(sin(S.Pi/4), sin(S.Pi/3)) assert sin(AccumBounds(3*S.Pi/4, 5*S.Pi/6)) == AccumBounds(sin(5*S.Pi/6), sin(3*S.Pi/4)) def test_trig_symmetry(): assert sin(-x) == -sin(x) assert cos(-x) == cos(x) assert tan(-x) == -tan(x) assert cot(-x) == -cot(x) assert sin(x + pi) == -sin(x) assert sin(x + 2*pi) == sin(x) assert sin(x + 3*pi) == -sin(x) assert sin(x + 4*pi) == sin(x) assert sin(x - 5*pi) == -sin(x) assert cos(x + pi) == -cos(x) assert cos(x + 2*pi) == cos(x) assert cos(x + 3*pi) == -cos(x) assert cos(x + 4*pi) == cos(x) assert cos(x - 5*pi) == -cos(x) assert tan(x + pi) == tan(x) assert tan(x - 3*pi) == tan(x) assert cot(x + pi) == cot(x) assert cot(x - 3*pi) == cot(x) assert sin(pi/2 - x) == cos(x) assert sin(3*pi/2 - x) == -cos(x) assert sin(5*pi/2 - x) == cos(x) assert cos(pi/2 - x) == sin(x) assert cos(3*pi/2 - x) == -sin(x) assert cos(5*pi/2 - x) == sin(x) assert tan(pi/2 - x) == cot(x) assert tan(3*pi/2 - x) == cot(x) assert tan(5*pi/2 - x) == cot(x) assert cot(pi/2 - x) == tan(x) assert cot(3*pi/2 - x) == tan(x) assert cot(5*pi/2 - x) == tan(x) assert sin(pi/2 + x) == cos(x) assert cos(pi/2 + x) == -sin(x) assert tan(pi/2 + x) == -cot(x) assert cot(pi/2 + x) == -tan(x) def test_cos(): x, y = symbols('x y') assert cos.nargs == FiniteSet(1) assert cos(nan) == nan assert cos(oo) == AccumBounds(-1, 1) assert cos(oo) - cos(oo) == AccumBounds(-2, 2) assert cos(oo*I) == oo assert cos(-oo*I) == oo assert cos(zoo) == nan assert cos(0) == 1 assert cos(acos(x)) == x assert cos(atan(x)) == 1 / sqrt(1 + x**2) assert cos(asin(x)) == sqrt(1 - x**2) assert cos(acot(x)) == 1 / sqrt(1 + 1 / x**2) assert cos(acsc(x)) == sqrt(1 - 1 / x**2) assert cos(asec(x)) == 1 / x assert cos(atan2(y, x)) == x / sqrt(x**2 + y**2) assert cos(pi*I) == cosh(pi) assert cos(-pi*I) == cosh(pi) assert cos(-2*I) == cosh(2) assert cos(pi/2) == 0 assert cos(-pi/2) == 0 assert cos(pi/2) == 0 assert cos(-pi/2) == 0 assert cos((-3*10**73 + 1)*pi/2) == 0 assert cos((7*10**103 + 1)*pi/2) == 0 n = symbols('n', integer=True, even=False) e = symbols('e', even=True) assert cos(pi*n/2) == 0 assert cos(pi*e/2) == (-1)**(e/2) assert cos(pi) == -1 assert cos(-pi) == -1 assert cos(2*pi) == 1 assert cos(5*pi) == -1 assert cos(8*pi) == 1 assert cos(pi/3) == S.Half assert cos(-2*pi/3) == -S.Half assert cos(pi/4) == S.Half*sqrt(2) assert cos(-pi/4) == S.Half*sqrt(2) assert cos(11*pi/4) == -S.Half*sqrt(2) assert cos(-3*pi/4) == -S.Half*sqrt(2) assert cos(pi/6) == S.Half*sqrt(3) assert cos(-pi/6) == S.Half*sqrt(3) assert cos(7*pi/6) == -S.Half*sqrt(3) assert cos(-5*pi/6) == -S.Half*sqrt(3) assert cos(1*pi/5) == (sqrt(5) + 1)/4 assert cos(2*pi/5) == (sqrt(5) - 1)/4 assert cos(3*pi/5) == -cos(2*pi/5) assert cos(4*pi/5) == -cos(1*pi/5) assert cos(6*pi/5) == -cos(1*pi/5) assert cos(8*pi/5) == cos(2*pi/5) assert cos(-1273*pi/5) == -cos(2*pi/5) assert cos(pi/8) == sqrt((2 + sqrt(2))/4) assert cos(pi/12) == sqrt(2)/4 + sqrt(6)/4 assert cos(5*pi/12) == -sqrt(2)/4 + sqrt(6)/4 assert cos(7*pi/12) == sqrt(2)/4 - sqrt(6)/4 assert cos(11*pi/12) == -sqrt(2)/4 - sqrt(6)/4 assert cos(104*pi/105) == -cos(pi/105) assert cos(106*pi/105) == -cos(pi/105) assert cos(-104*pi/105) == -cos(pi/105) assert cos(-106*pi/105) == -cos(pi/105) assert cos(x*I) == cosh(x) assert cos(k*pi*I) == cosh(k*pi) assert cos(r).is_real is True assert cos(0, evaluate=False).is_algebraic assert cos(a).is_algebraic is None assert cos(na).is_algebraic is False q = Symbol('q', rational=True) assert cos(pi*q).is_algebraic assert cos(2*pi/7).is_algebraic assert cos(k*pi) == (-1)**k assert cos(2*k*pi) == 1 for d in list(range(1, 22)) + [60, 85]: for n in range(0, 2*d + 1): x = n*pi/d e = abs( float(cos(x)) - cos(float(x)) ) assert e < 1e-12 def test_issue_6190(): c = Float('123456789012345678901234567890.25', '') for cls in [sin, cos, tan, cot]: assert cls(c*pi) == cls(pi/4) assert cls(4.125*pi) == cls(pi/8) assert cls(4.7*pi) == cls((4.7 % 2)*pi) def test_cos_series(): assert cos(x).series(x, 0, 9) == \ 1 - x**2/2 + x**4/24 - x**6/720 + x**8/40320 + O(x**9) def test_cos_rewrite(): assert cos(x).rewrite(exp) == exp(I*x)/2 + exp(-I*x)/2 assert cos(x).rewrite(tan) == (1 - tan(x/2)**2)/(1 + tan(x/2)**2) assert cos(x).rewrite(cot) == -(1 - cot(x/2)**2)/(1 + cot(x/2)**2) assert cos(sinh(x)).rewrite( exp).subs(x, 3).n() == cos(x).rewrite(exp).subs(x, sinh(3)).n() assert cos(cosh(x)).rewrite( exp).subs(x, 3).n() == cos(x).rewrite(exp).subs(x, cosh(3)).n() assert cos(tanh(x)).rewrite( exp).subs(x, 3).n() == cos(x).rewrite(exp).subs(x, tanh(3)).n() assert cos(coth(x)).rewrite( exp).subs(x, 3).n() == cos(x).rewrite(exp).subs(x, coth(3)).n() assert cos(sin(x)).rewrite( exp).subs(x, 3).n() == cos(x).rewrite(exp).subs(x, sin(3)).n() assert cos(cos(x)).rewrite( exp).subs(x, 3).n() == cos(x).rewrite(exp).subs(x, cos(3)).n() assert cos(tan(x)).rewrite( exp).subs(x, 3).n() == cos(x).rewrite(exp).subs(x, tan(3)).n() assert cos(cot(x)).rewrite( exp).subs(x, 3).n() == cos(x).rewrite(exp).subs(x, cot(3)).n() assert cos(log(x)).rewrite(Pow) == x**I/2 + x**-I/2 assert cos(x).rewrite(sec) == 1/sec(x) assert cos(x).rewrite(sin) == sin(x + pi/2, evaluate=False) assert cos(x).rewrite(csc) == 1/csc(-x + pi/2, evaluate=False) def test_cos_expansion(): assert cos(x + y).expand(trig=True) == cos(x)*cos(y) - sin(x)*sin(y) assert cos(x - y).expand(trig=True) == cos(x)*cos(y) + sin(x)*sin(y) assert cos(y - x).expand(trig=True) == cos(x)*cos(y) + sin(x)*sin(y) assert cos(2*x).expand(trig=True) == 2*cos(x)**2 - 1 assert cos(3*x).expand(trig=True) == 4*cos(x)**3 - 3*cos(x) assert cos(4*x).expand(trig=True) == 8*cos(x)**4 - 8*cos(x)**2 + 1 assert cos(2).expand(trig=True) == 2*cos(1)**2 - 1 assert cos(3).expand(trig=True) == 4*cos(1)**3 - 3*cos(1) def test_cos_AccumBounds(): assert cos(AccumBounds(-oo, oo)) == AccumBounds(-1, 1) assert cos(AccumBounds(0, oo)) == AccumBounds(-1, 1) assert cos(AccumBounds(-oo, 0)) == AccumBounds(-1, 1) assert cos(AccumBounds(0, 2*S.Pi)) == AccumBounds(-1, 1) assert cos(AccumBounds(-S.Pi/3, S.Pi/4)) == AccumBounds(cos(-S.Pi/3), 1) assert cos(AccumBounds(3*S.Pi/4, 5*S.Pi/4)) == AccumBounds(-1, cos(3*S.Pi/4)) assert cos(AccumBounds(5*S.Pi/4, 4*S.Pi/3)) == AccumBounds(cos(5*S.Pi/4), cos(4*S.Pi/3)) assert cos(AccumBounds(S.Pi/4, S.Pi/3)) == AccumBounds(cos(S.Pi/3), cos(S.Pi/4)) def test_tan(): assert tan(nan) == nan assert tan(zoo) == nan assert tan(oo) == AccumBounds(-oo, oo) assert tan(oo) - tan(oo) == AccumBounds(-oo, oo) assert tan.nargs == FiniteSet(1) assert tan(oo*I) == I assert tan(-oo*I) == -I assert tan(0) == 0 assert tan(atan(x)) == x assert tan(asin(x)) == x / sqrt(1 - x**2) assert tan(acos(x)) == sqrt(1 - x**2) / x assert tan(acot(x)) == 1 / x assert tan(acsc(x)) == 1 / (sqrt(1 - 1 / x**2) * x) assert tan(asec(x)) == sqrt(1 - 1 / x**2) * x assert tan(atan2(y, x)) == y/x assert tan(pi*I) == tanh(pi)*I assert tan(-pi*I) == -tanh(pi)*I assert tan(-2*I) == -tanh(2)*I assert tan(pi) == 0 assert tan(-pi) == 0 assert tan(2*pi) == 0 assert tan(-2*pi) == 0 assert tan(-3*10**73*pi) == 0 assert tan(pi/2) == zoo assert tan(3*pi/2) == zoo assert tan(pi/3) == sqrt(3) assert tan(-2*pi/3) == sqrt(3) assert tan(pi/4) == S.One assert tan(-pi/4) == -S.One assert tan(17*pi/4) == S.One assert tan(-3*pi/4) == S.One assert tan(pi/6) == 1/sqrt(3) assert tan(-pi/6) == -1/sqrt(3) assert tan(7*pi/6) == 1/sqrt(3) assert tan(-5*pi/6) == 1/sqrt(3) assert tan(pi/8).expand() == -1 + sqrt(2) assert tan(3*pi/8).expand() == 1 + sqrt(2) assert tan(5*pi/8).expand() == -1 - sqrt(2) assert tan(7*pi/8).expand() == 1 - sqrt(2) assert tan(pi/12) == -sqrt(3) + 2 assert tan(5*pi/12) == sqrt(3) + 2 assert tan(7*pi/12) == -sqrt(3) - 2 assert tan(11*pi/12) == sqrt(3) - 2 assert tan(pi/24).radsimp() == -2 - sqrt(3) + sqrt(2) + sqrt(6) assert tan(5*pi/24).radsimp() == -2 + sqrt(3) - sqrt(2) + sqrt(6) assert tan(7*pi/24).radsimp() == 2 - sqrt(3) - sqrt(2) + sqrt(6) assert tan(11*pi/24).radsimp() == 2 + sqrt(3) + sqrt(2) + sqrt(6) assert tan(13*pi/24).radsimp() == -2 - sqrt(3) - sqrt(2) - sqrt(6) assert tan(17*pi/24).radsimp() == -2 + sqrt(3) + sqrt(2) - sqrt(6) assert tan(19*pi/24).radsimp() == 2 - sqrt(3) + sqrt(2) - sqrt(6) assert tan(23*pi/24).radsimp() == 2 + sqrt(3) - sqrt(2) - sqrt(6) assert 1 == (tan(8*pi/15)*cos(8*pi/15)/sin(8*pi/15)).ratsimp() assert tan(x*I) == tanh(x)*I assert tan(k*pi) == 0 assert tan(17*k*pi) == 0 assert tan(k*pi*I) == tanh(k*pi)*I assert tan(r).is_real is True assert tan(0, evaluate=False).is_algebraic assert tan(a).is_algebraic is None assert tan(na).is_algebraic is False assert tan(10*pi/7) == tan(3*pi/7) assert tan(11*pi/7) == -tan(3*pi/7) assert tan(-11*pi/7) == tan(3*pi/7) assert tan(15*pi/14) == tan(pi/14) assert tan(-15*pi/14) == -tan(pi/14) def test_tan_series(): assert tan(x).series(x, 0, 9) == \ x + x**3/3 + 2*x**5/15 + 17*x**7/315 + O(x**9) def test_tan_rewrite(): neg_exp, pos_exp = exp(-x*I), exp(x*I) assert tan(x).rewrite(exp) == I*(neg_exp - pos_exp)/(neg_exp + pos_exp) assert tan(x).rewrite(sin) == 2*sin(x)**2/sin(2*x) assert tan(x).rewrite(cos) == cos(x - S.Pi/2, evaluate=False)/cos(x) assert tan(x).rewrite(cot) == 1/cot(x) assert tan(sinh(x)).rewrite( exp).subs(x, 3).n() == tan(x).rewrite(exp).subs(x, sinh(3)).n() assert tan(cosh(x)).rewrite( exp).subs(x, 3).n() == tan(x).rewrite(exp).subs(x, cosh(3)).n() assert tan(tanh(x)).rewrite( exp).subs(x, 3).n() == tan(x).rewrite(exp).subs(x, tanh(3)).n() assert tan(coth(x)).rewrite( exp).subs(x, 3).n() == tan(x).rewrite(exp).subs(x, coth(3)).n() assert tan(sin(x)).rewrite( exp).subs(x, 3).n() == tan(x).rewrite(exp).subs(x, sin(3)).n() assert tan(cos(x)).rewrite( exp).subs(x, 3).n() == tan(x).rewrite(exp).subs(x, cos(3)).n() assert tan(tan(x)).rewrite( exp).subs(x, 3).n() == tan(x).rewrite(exp).subs(x, tan(3)).n() assert tan(cot(x)).rewrite( exp).subs(x, 3).n() == tan(x).rewrite(exp).subs(x, cot(3)).n() assert tan(log(x)).rewrite(Pow) == I*(x**-I - x**I)/(x**-I + x**I) assert 0 == (cos(pi/34)*tan(pi/34) - sin(pi/34)).rewrite(pow) assert 0 == (cos(pi/17)*tan(pi/17) - sin(pi/17)).rewrite(pow) assert tan(pi/19).rewrite(pow) == tan(pi/19) assert tan(8*pi/19).rewrite(sqrt) == tan(8*pi/19) assert tan(x).rewrite(sec) == sec(x)/sec(x - pi/2, evaluate=False) assert tan(x).rewrite(csc) == csc(-x + pi/2, evaluate=False)/csc(x) def test_tan_subs(): assert tan(x).subs(tan(x), y) == y assert tan(x).subs(x, y) == tan(y) assert tan(x).subs(x, S.Pi/2) == zoo assert tan(x).subs(x, 3*S.Pi/2) == zoo def test_tan_expansion(): assert tan(x + y).expand(trig=True) == ((tan(x) + tan(y))/(1 - tan(x)*tan(y))).expand() assert tan(x - y).expand(trig=True) == ((tan(x) - tan(y))/(1 + tan(x)*tan(y))).expand() assert tan(x + y + z).expand(trig=True) == ( (tan(x) + tan(y) + tan(z) - tan(x)*tan(y)*tan(z))/ (1 - tan(x)*tan(y) - tan(x)*tan(z) - tan(y)*tan(z))).expand() assert 0 == tan(2*x).expand(trig=True).rewrite(tan).subs([(tan(x), Rational(1, 7))])*24 - 7 assert 0 == tan(3*x).expand(trig=True).rewrite(tan).subs([(tan(x), Rational(1, 5))])*55 - 37 assert 0 == tan(4*x - pi/4).expand(trig=True).rewrite(tan).subs([(tan(x), Rational(1, 5))])*239 - 1 def test_tan_AccumBounds(): assert tan(AccumBounds(-oo, oo)) == AccumBounds(-oo, oo) assert tan(AccumBounds(S.Pi/3, 2*S.Pi/3)) == AccumBounds(-oo, oo) assert tan(AccumBounds(S.Pi/6, S.Pi/3)) == AccumBounds(tan(S.Pi/6), tan(S.Pi/3)) def test_cot(): assert cot(nan) == nan assert cot.nargs == FiniteSet(1) assert cot(oo*I) == -I assert cot(-oo*I) == I assert cot(zoo) == nan assert cot(0) == zoo assert cot(2*pi) == zoo assert cot(acot(x)) == x assert cot(atan(x)) == 1 / x assert cot(asin(x)) == sqrt(1 - x**2) / x assert cot(acos(x)) == x / sqrt(1 - x**2) assert cot(acsc(x)) == sqrt(1 - 1 / x**2) * x assert cot(asec(x)) == 1 / (sqrt(1 - 1 / x**2) * x) assert cot(atan2(y, x)) == x/y assert cot(pi*I) == -coth(pi)*I assert cot(-pi*I) == coth(pi)*I assert cot(-2*I) == coth(2)*I assert cot(pi) == cot(2*pi) == cot(3*pi) assert cot(-pi) == cot(-2*pi) == cot(-3*pi) assert cot(pi/2) == 0 assert cot(-pi/2) == 0 assert cot(5*pi/2) == 0 assert cot(7*pi/2) == 0 assert cot(pi/3) == 1/sqrt(3) assert cot(-2*pi/3) == 1/sqrt(3) assert cot(pi/4) == S.One assert cot(-pi/4) == -S.One assert cot(17*pi/4) == S.One assert cot(-3*pi/4) == S.One assert cot(pi/6) == sqrt(3) assert cot(-pi/6) == -sqrt(3) assert cot(7*pi/6) == sqrt(3) assert cot(-5*pi/6) == sqrt(3) assert cot(pi/8).expand() == 1 + sqrt(2) assert cot(3*pi/8).expand() == -1 + sqrt(2) assert cot(5*pi/8).expand() == 1 - sqrt(2) assert cot(7*pi/8).expand() == -1 - sqrt(2) assert cot(pi/12) == sqrt(3) + 2 assert cot(5*pi/12) == -sqrt(3) + 2 assert cot(7*pi/12) == sqrt(3) - 2 assert cot(11*pi/12) == -sqrt(3) - 2 assert cot(pi/24).radsimp() == sqrt(2) + sqrt(3) + 2 + sqrt(6) assert cot(5*pi/24).radsimp() == -sqrt(2) - sqrt(3) + 2 + sqrt(6) assert cot(7*pi/24).radsimp() == -sqrt(2) + sqrt(3) - 2 + sqrt(6) assert cot(11*pi/24).radsimp() == sqrt(2) - sqrt(3) - 2 + sqrt(6) assert cot(13*pi/24).radsimp() == -sqrt(2) + sqrt(3) + 2 - sqrt(6) assert cot(17*pi/24).radsimp() == sqrt(2) - sqrt(3) + 2 - sqrt(6) assert cot(19*pi/24).radsimp() == sqrt(2) + sqrt(3) - 2 - sqrt(6) assert cot(23*pi/24).radsimp() == -sqrt(2) - sqrt(3) - 2 - sqrt(6) assert 1 == (cot(4*pi/15)*sin(4*pi/15)/cos(4*pi/15)).ratsimp() assert cot(x*I) == -coth(x)*I assert cot(k*pi*I) == -coth(k*pi)*I assert cot(r).is_real is True assert cot(a).is_algebraic is None assert cot(na).is_algebraic is False assert cot(10*pi/7) == cot(3*pi/7) assert cot(11*pi/7) == -cot(3*pi/7) assert cot(-11*pi/7) == cot(3*pi/7) assert cot(39*pi/34) == cot(5*pi/34) assert cot(-41*pi/34) == -cot(7*pi/34) assert cot(x).is_finite is None assert cot(r).is_finite is None i = Symbol('i', imaginary=True) assert cot(i).is_finite is True assert cot(x).subs(x, 3*pi) == zoo def test_cot_series(): assert cot(x).series(x, 0, 9) == \ 1/x - x/3 - x**3/45 - 2*x**5/945 - x**7/4725 + O(x**9) # issue 6210 assert cot(x**4 + x**5).series(x, 0, 1) == \ x**(-4) - 1/x**3 + x**(-2) - 1/x + 1 + O(x) def test_cot_rewrite(): neg_exp, pos_exp = exp(-x*I), exp(x*I) assert cot(x).rewrite(exp) == I*(pos_exp + neg_exp)/(pos_exp - neg_exp) assert cot(x).rewrite(sin) == sin(2*x)/(2*(sin(x)**2)) assert cot(x).rewrite(cos) == cos(x)/cos(x - pi/2, evaluate=False) assert cot(x).rewrite(tan) == 1/tan(x) assert cot(sinh(x)).rewrite( exp).subs(x, 3).n() == cot(x).rewrite(exp).subs(x, sinh(3)).n() assert cot(cosh(x)).rewrite( exp).subs(x, 3).n() == cot(x).rewrite(exp).subs(x, cosh(3)).n() assert cot(tanh(x)).rewrite( exp).subs(x, 3).n() == cot(x).rewrite(exp).subs(x, tanh(3)).n() assert cot(coth(x)).rewrite( exp).subs(x, 3).n() == cot(x).rewrite(exp).subs(x, coth(3)).n() assert cot(sin(x)).rewrite( exp).subs(x, 3).n() == cot(x).rewrite(exp).subs(x, sin(3)).n() assert cot(tan(x)).rewrite( exp).subs(x, 3).n() == cot(x).rewrite(exp).subs(x, tan(3)).n() assert cot(log(x)).rewrite(Pow) == -I*(x**-I + x**I)/(x**-I - x**I) assert cot(4*pi/34).rewrite(pow).ratsimp() == (cos(4*pi/34)/sin(4*pi/34)).rewrite(pow).ratsimp() assert cot(4*pi/17).rewrite(pow) == (cos(4*pi/17)/sin(4*pi/17)).rewrite(pow) assert cot(pi/19).rewrite(pow) == cot(pi/19) assert cot(pi/19).rewrite(sqrt) == cot(pi/19) assert cot(x).rewrite(sec) == sec(x - pi / 2, evaluate=False) / sec(x) assert cot(x).rewrite(csc) == csc(x) / csc(- x + pi / 2, evaluate=False) def test_cot_subs(): assert cot(x).subs(cot(x), y) == y assert cot(x).subs(x, y) == cot(y) assert cot(x).subs(x, 0) == zoo assert cot(x).subs(x, S.Pi) == zoo def test_cot_expansion(): assert cot(x + y).expand(trig=True) == ((cot(x)*cot(y) - 1)/(cot(x) + cot(y))).expand() assert cot(x - y).expand(trig=True) == (-(cot(x)*cot(y) + 1)/(cot(x) - cot(y))).expand() assert cot(x + y + z).expand(trig=True) == ( (cot(x)*cot(y)*cot(z) - cot(x) - cot(y) - cot(z))/ (-1 + cot(x)*cot(y) + cot(x)*cot(z) + cot(y)*cot(z))).expand() assert cot(3*x).expand(trig=True) == ((cot(x)**3 - 3*cot(x))/(3*cot(x)**2 - 1)).expand() assert 0 == cot(2*x).expand(trig=True).rewrite(cot).subs([(cot(x), Rational(1, 3))])*3 + 4 assert 0 == cot(3*x).expand(trig=True).rewrite(cot).subs([(cot(x), Rational(1, 5))])*55 - 37 assert 0 == cot(4*x - pi/4).expand(trig=True).rewrite(cot).subs([(cot(x), Rational(1, 7))])*863 + 191 def test_cot_AccumBounds(): assert cot(AccumBounds(-oo, oo)) == AccumBounds(-oo, oo) assert cot(AccumBounds(-S.Pi/3, S.Pi/3)) == AccumBounds(-oo, oo) assert cot(AccumBounds(S.Pi/6, S.Pi/3)) == AccumBounds(cot(S.Pi/3), cot(S.Pi/6)) def test_sinc(): assert isinstance(sinc(x), sinc) s = Symbol('s', zero=True) assert sinc(s) == S.One assert sinc(S.Infinity) == S.Zero assert sinc(-S.Infinity) == S.Zero assert sinc(S.NaN) == S.NaN assert sinc(S.ComplexInfinity) == S.NaN n = Symbol('n', integer=True, nonzero=True) assert sinc(n*pi) == S.Zero assert sinc(-n*pi) == S.Zero assert sinc(pi/2) == 2 / pi assert sinc(-pi/2) == 2 / pi assert sinc(5*pi/2) == 2 / (5*pi) assert sinc(7*pi/2) == -2 / (7*pi) assert sinc(-x) == sinc(x) assert sinc(x).diff() == (x*cos(x) - sin(x)) / x**2 assert sinc(x).series() == 1 - x**2/6 + x**4/120 + O(x**6) assert sinc(x).rewrite(jn) == jn(0, x) assert sinc(x).rewrite(sin) == Piecewise((sin(x)/x, Ne(x, 0)), (1, True)) def test_asin(): assert asin(nan) == nan assert asin.nargs == FiniteSet(1) assert asin(oo) == -I*oo assert asin(-oo) == I*oo assert asin(zoo) == zoo # Note: asin(-x) = - asin(x) assert asin(0) == 0 assert asin(1) == pi/2 assert asin(-1) == -pi/2 assert asin(sqrt(3)/2) == pi/3 assert asin(-sqrt(3)/2) == -pi/3 assert asin(sqrt(2)/2) == pi/4 assert asin(-sqrt(2)/2) == -pi/4 assert asin(sqrt((5 - sqrt(5))/8)) == pi/5 assert asin(-sqrt((5 - sqrt(5))/8)) == -pi/5 assert asin(Rational(1, 2)) == pi/6 assert asin(-Rational(1, 2)) == -pi/6 assert asin((sqrt(2 - sqrt(2)))/2) == pi/8 assert asin(-(sqrt(2 - sqrt(2)))/2) == -pi/8 assert asin((sqrt(5) - 1)/4) == pi/10 assert asin(-(sqrt(5) - 1)/4) == -pi/10 assert asin((sqrt(3) - 1)/sqrt(2**3)) == pi/12 assert asin(-(sqrt(3) - 1)/sqrt(2**3)) == -pi/12 assert asin(x).diff(x) == 1/sqrt(1 - x**2) assert asin(0.2).is_real is True assert asin(-2).is_real is False assert asin(r).is_real is None assert asin(-2*I) == -I*asinh(2) assert asin(Rational(1, 7), evaluate=False).is_positive is True assert asin(Rational(-1, 7), evaluate=False).is_positive is False assert asin(p).is_positive is None def test_asin_series(): assert asin(x).series(x, 0, 9) == \ x + x**3/6 + 3*x**5/40 + 5*x**7/112 + O(x**9) t5 = asin(x).taylor_term(5, x) assert t5 == 3*x**5/40 assert asin(x).taylor_term(7, x, t5, 0) == 5*x**7/112 def test_asin_rewrite(): assert asin(x).rewrite(log) == -I*log(I*x + sqrt(1 - x**2)) assert asin(x).rewrite(atan) == 2*atan(x/(1 + sqrt(1 - x**2))) assert asin(x).rewrite(acos) == S.Pi/2 - acos(x) assert asin(x).rewrite(acot) == 2*acot((sqrt(-x**2 + 1) + 1)/x) assert asin(x).rewrite(asec) == -asec(1/x) + pi/2 assert asin(x).rewrite(acsc) == acsc(1/x) def test_acos(): assert acos(nan) == nan assert acos(zoo) == zoo assert acos.nargs == FiniteSet(1) assert acos(oo) == I*oo assert acos(-oo) == -I*oo # Note: acos(-x) = pi - acos(x) assert acos(0) == pi/2 assert acos(Rational(1, 2)) == pi/3 assert acos(-Rational(1, 2)) == (2*pi)/3 assert acos(1) == 0 assert acos(-1) == pi assert acos(sqrt(2)/2) == pi/4 assert acos(-sqrt(2)/2) == (3*pi)/4 assert acos(x).diff(x) == -1/sqrt(1 - x**2) assert acos(0.2).is_real is True assert acos(-2).is_real is False assert acos(r).is_real is None assert acos(Rational(1, 7), evaluate=False).is_positive is True assert acos(Rational(-1, 7), evaluate=False).is_positive is True assert acos(Rational(3, 2), evaluate=False).is_positive is False assert acos(p).is_positive is None assert acos(2 + p).conjugate() != acos(10 + p) assert acos(-3 + n).conjugate() != acos(-3 + n) assert acos(S.One/3).conjugate() == acos(S.One/3) assert acos(-S.One/3).conjugate() == acos(-S.One/3) assert acos(p + n*I).conjugate() == acos(p - n*I) assert acos(z).conjugate() != acos(conjugate(z)) def test_acos_series(): assert acos(x).series(x, 0, 8) == \ pi/2 - x - x**3/6 - 3*x**5/40 - 5*x**7/112 + O(x**8) assert acos(x).series(x, 0, 8) == pi/2 - asin(x).series(x, 0, 8) t5 = acos(x).taylor_term(5, x) assert t5 == -3*x**5/40 assert acos(x).taylor_term(7, x, t5, 0) == -5*x**7/112 def test_acos_rewrite(): assert acos(x).rewrite(log) == pi/2 + I*log(I*x + sqrt(1 - x**2)) assert acos(x).rewrite(atan) == \ atan(sqrt(1 - x**2)/x) + (pi/2)*(1 - x*sqrt(1/x**2)) assert acos(0).rewrite(atan) == S.Pi/2 assert acos(0.5).rewrite(atan) == acos(0.5).rewrite(log) assert acos(x).rewrite(asin) == S.Pi/2 - asin(x) assert acos(x).rewrite(acot) == -2*acot((sqrt(-x**2 + 1) + 1)/x) + pi/2 assert acos(x).rewrite(asec) == asec(1/x) assert acos(x).rewrite(acsc) == -acsc(1/x) + pi/2 def test_atan(): assert atan(nan) == nan assert atan.nargs == FiniteSet(1) assert atan(oo) == pi/2 assert atan(-oo) == -pi/2 assert atan(zoo) == AccumBounds(-pi/2, pi/2) assert atan(0) == 0 assert atan(1) == pi/4 assert atan(sqrt(3)) == pi/3 assert atan(oo) == pi/2 assert atan(x).diff(x) == 1/(1 + x**2) assert atan(r).is_real is True assert atan(-2*I) == -I*atanh(2) assert atan(p).is_positive is True assert atan(n).is_positive is False assert atan(x).is_positive is None def test_atan_rewrite(): assert atan(x).rewrite(log) == I*(log(1 - I*x)-log(1 + I*x))/2 assert atan(x).rewrite(asin) == (-asin(1/sqrt(x**2 + 1)) + pi/2)*sqrt(x**2)/x assert atan(x).rewrite(acos) == sqrt(x**2)*acos(1/sqrt(x**2 + 1))/x assert atan(x).rewrite(acot) == acot(1/x) assert atan(x).rewrite(asec) == sqrt(x**2)*asec(sqrt(x**2 + 1))/x assert atan(x).rewrite(acsc) == (-acsc(sqrt(x**2 + 1)) + pi/2)*sqrt(x**2)/x assert atan(-5*I).evalf() == atan(x).rewrite(log).evalf(subs={x:-5*I}) assert atan(5*I).evalf() == atan(x).rewrite(log).evalf(subs={x:5*I}) def test_atan2(): assert atan2.nargs == FiniteSet(2) assert atan2(0, 0) == S.NaN assert atan2(0, 1) == 0 assert atan2(1, 1) == pi/4 assert atan2(1, 0) == pi/2 assert atan2(1, -1) == 3*pi/4 assert atan2(0, -1) == pi assert atan2(-1, -1) == -3*pi/4 assert atan2(-1, 0) == -pi/2 assert atan2(-1, 1) == -pi/4 i = symbols('i', imaginary=True) r = symbols('r', real=True) eq = atan2(r, i) ans = -I*log((i + I*r)/sqrt(i**2 + r**2)) reps = ((r, 2), (i, I)) assert eq.subs(reps) == ans.subs(reps) x = Symbol('x', negative=True) y = Symbol('y', negative=True) assert atan2(y, x) == atan(y/x) - pi y = Symbol('y', nonnegative=True) assert atan2(y, x) == atan(y/x) + pi y = Symbol('y') assert atan2(y, x) == atan2(y, x, evaluate=False) u = Symbol("u", positive=True) assert atan2(0, u) == 0 u = Symbol("u", negative=True) assert atan2(0, u) == pi assert atan2(y, oo) == 0 assert atan2(y, -oo)== 2*pi*Heaviside(re(y)) - pi assert atan2(y, x).rewrite(log) == -I*log((x + I*y)/sqrt(x**2 + y**2)) assert atan2(0, 0).rewrite(atan) == S.NaN w = Symbol('w') assert atan2(0, w).rewrite(atan) == Piecewise((pi, w < 0), (0, w > 0), (S.NaN, True)) ex = atan2(y, x) - arg(x + I*y) assert ex.subs({x:2, y:3}).rewrite(arg) == 0 assert ex.subs({x:2, y:3*I}).rewrite(arg) == -pi - I*log(sqrt(5)*I/5) assert ex.subs({x:2*I, y:3}).rewrite(arg) == -pi/2 - I*log(sqrt(5)*I) assert ex.subs({x:2*I, y:3*I}).rewrite(arg) == -pi + atan(2/S(3)) + atan(3/S(2)) i = symbols('i', imaginary=True) r = symbols('r', real=True) e = atan2(i, r) rewrite = e.rewrite(arg) reps = {i: I, r: -2} assert rewrite == -I*log(abs(I*i + r)/sqrt(abs(i**2 + r**2))) + arg((I*i + r)/sqrt(i**2 + r**2)) assert (e - rewrite).subs(reps).equals(0) assert conjugate(atan2(x, y)) == atan2(conjugate(x), conjugate(y)) assert diff(atan2(y, x), x) == -y/(x**2 + y**2) assert diff(atan2(y, x), y) == x/(x**2 + y**2) assert simplify(diff(atan2(y, x).rewrite(log), x)) == -y/(x**2 + y**2) assert simplify(diff(atan2(y, x).rewrite(log), y)) == x/(x**2 + y**2) def test_acot(): assert acot(nan) == nan assert acot.nargs == FiniteSet(1) assert acot(-oo) == 0 assert acot(oo) == 0 assert acot(zoo) == 0 assert acot(1) == pi/4 assert acot(0) == pi/2 assert acot(sqrt(3)/3) == pi/3 assert acot(1/sqrt(3)) == pi/3 assert acot(-1/sqrt(3)) == -pi/3 assert acot(x).diff(x) == -1/(1 + x**2) assert acot(r).is_real is True assert acot(I*pi) == -I*acoth(pi) assert acot(-2*I) == I*acoth(2) assert acot(x).is_positive is None assert acot(n).is_positive is False assert acot(p).is_positive is True assert acot(I).is_positive is False def test_acot_rewrite(): assert acot(x).rewrite(log) == I*(log(1 - I/x)-log(1 + I/x))/2 assert acot(x).rewrite(asin) == x*(-asin(sqrt(-x**2)/sqrt(-x**2 - 1)) + pi/2)*sqrt(x**(-2)) assert acot(x).rewrite(acos) == x*sqrt(x**(-2))*acos(sqrt(-x**2)/sqrt(-x**2 - 1)) assert acot(x).rewrite(atan) == atan(1/x) assert acot(x).rewrite(asec) == x*sqrt(x**(-2))*asec(sqrt((x**2 + 1)/x**2)) assert acot(x).rewrite(acsc) == x*(-acsc(sqrt((x**2 + 1)/x**2)) + pi/2)*sqrt(x**(-2)) assert acot(-I/5).evalf() == acot(x).rewrite(log).evalf(subs={x:-I/5}) assert acot(I/5).evalf() == acot(x).rewrite(log).evalf(subs={x:I/5}) def test_attributes(): assert sin(x).args == (x,) def test_sincos_rewrite(): assert sin(pi/2 - x) == cos(x) assert sin(pi - x) == sin(x) assert cos(pi/2 - x) == sin(x) assert cos(pi - x) == -cos(x) def _check_even_rewrite(func, arg): """Checks that the expr has been rewritten using f(-x) -> f(x) arg : -x """ return func(arg).args[0] == -arg def _check_odd_rewrite(func, arg): """Checks that the expr has been rewritten using f(-x) -> -f(x) arg : -x """ return func(arg).func.is_Mul def _check_no_rewrite(func, arg): """Checks that the expr is not rewritten""" return func(arg).args[0] == arg def test_evenodd_rewrite(): a = cos(2) # negative b = sin(1) # positive even = [cos] odd = [sin, tan, cot, asin, atan, acot] with_minus = [-1, -2**1024 * E, -pi/105, -x*y, -x - y] for func in even: for expr in with_minus: assert _check_even_rewrite(func, expr) assert _check_no_rewrite(func, a*b) assert func( x - y) == func(y - x) # it doesn't matter which form is canonical for func in odd: for expr in with_minus: assert _check_odd_rewrite(func, expr) assert _check_no_rewrite(func, a*b) assert func( x - y) == -func(y - x) # it doesn't matter which form is canonical def test_issue_4547(): assert sin(x).rewrite(cot) == 2*cot(x/2)/(1 + cot(x/2)**2) assert cos(x).rewrite(cot) == -(1 - cot(x/2)**2)/(1 + cot(x/2)**2) assert tan(x).rewrite(cot) == 1/cot(x) assert cot(x).fdiff() == -1 - cot(x)**2 def test_as_leading_term_issue_5272(): assert sin(x).as_leading_term(x) == x assert cos(x).as_leading_term(x) == 1 assert tan(x).as_leading_term(x) == x assert cot(x).as_leading_term(x) == 1/x assert asin(x).as_leading_term(x) == x assert acos(x).as_leading_term(x) == x assert atan(x).as_leading_term(x) == x assert acot(x).as_leading_term(x) == x def test_leading_terms(): for func in [sin, cos, tan, cot, asin, acos, atan, acot]: for arg in (1/x, S.Half): eq = func(arg) assert eq.as_leading_term(x) == eq def test_atan2_expansion(): assert cancel(atan2(x**2, x + 1).diff(x) - atan(x**2/(x + 1)).diff(x)) == 0 assert cancel(atan(y/x).series(y, 0, 5) - atan2(y, x).series(y, 0, 5) + atan2(0, x) - atan(0)) == O(y**5) assert cancel(atan(y/x).series(x, 1, 4) - atan2(y, x).series(x, 1, 4) + atan2(y, 1) - atan(y)) == O((x - 1)**4, (x, 1)) assert cancel(atan((y + x)/x).series(x, 1, 3) - atan2(y + x, x).series(x, 1, 3) + atan2(1 + y, 1) - atan(1 + y)) == O((x - 1)**3, (x, 1)) assert Matrix([atan2(y, x)]).jacobian([y, x]) == \ Matrix([[x/(y**2 + x**2), -y/(y**2 + x**2)]]) def test_aseries(): def t(n, v, d, e): assert abs( n(1/v).evalf() - n(1/x).series(x, dir=d).removeO().subs(x, v)) < e t(atan, 0.1, '+', 1e-5) t(atan, -0.1, '-', 1e-5) t(acot, 0.1, '+', 1e-5) t(acot, -0.1, '-', 1e-5) def test_issue_4420(): i = Symbol('i', integer=True) e = Symbol('e', even=True) o = Symbol('o', odd=True) # unknown parity for variable assert cos(4*i*pi) == 1 assert sin(4*i*pi) == 0 assert tan(4*i*pi) == 0 assert cot(4*i*pi) == zoo assert cos(3*i*pi) == cos(pi*i) # +/-1 assert sin(3*i*pi) == 0 assert tan(3*i*pi) == 0 assert cot(3*i*pi) == zoo assert cos(4.0*i*pi) == 1 assert sin(4.0*i*pi) == 0 assert tan(4.0*i*pi) == 0 assert cot(4.0*i*pi) == zoo assert cos(3.0*i*pi) == cos(pi*i) # +/-1 assert sin(3.0*i*pi) == 0 assert tan(3.0*i*pi) == 0 assert cot(3.0*i*pi) == zoo assert cos(4.5*i*pi) == cos(0.5*pi*i) assert sin(4.5*i*pi) == sin(0.5*pi*i) assert tan(4.5*i*pi) == tan(0.5*pi*i) assert cot(4.5*i*pi) == cot(0.5*pi*i) # parity of variable is known assert cos(4*e*pi) == 1 assert sin(4*e*pi) == 0 assert tan(4*e*pi) == 0 assert cot(4*e*pi) == zoo assert cos(3*e*pi) == 1 assert sin(3*e*pi) == 0 assert tan(3*e*pi) == 0 assert cot(3*e*pi) == zoo assert cos(4.0*e*pi) == 1 assert sin(4.0*e*pi) == 0 assert tan(4.0*e*pi) == 0 assert cot(4.0*e*pi) == zoo assert cos(3.0*e*pi) == 1 assert sin(3.0*e*pi) == 0 assert tan(3.0*e*pi) == 0 assert cot(3.0*e*pi) == zoo assert cos(4.5*e*pi) == cos(0.5*pi*e) assert sin(4.5*e*pi) == sin(0.5*pi*e) assert tan(4.5*e*pi) == tan(0.5*pi*e) assert cot(4.5*e*pi) == cot(0.5*pi*e) assert cos(4*o*pi) == 1 assert sin(4*o*pi) == 0 assert tan(4*o*pi) == 0 assert cot(4*o*pi) == zoo assert cos(3*o*pi) == -1 assert sin(3*o*pi) == 0 assert tan(3*o*pi) == 0 assert cot(3*o*pi) == zoo assert cos(4.0*o*pi) == 1 assert sin(4.0*o*pi) == 0 assert tan(4.0*o*pi) == 0 assert cot(4.0*o*pi) == zoo assert cos(3.0*o*pi) == -1 assert sin(3.0*o*pi) == 0 assert tan(3.0*o*pi) == 0 assert cot(3.0*o*pi) == zoo assert cos(4.5*o*pi) == cos(0.5*pi*o) assert sin(4.5*o*pi) == sin(0.5*pi*o) assert tan(4.5*o*pi) == tan(0.5*pi*o) assert cot(4.5*o*pi) == cot(0.5*pi*o) # x could be imaginary assert cos(4*x*pi) == cos(4*pi*x) assert sin(4*x*pi) == sin(4*pi*x) assert tan(4*x*pi) == tan(4*pi*x) assert cot(4*x*pi) == cot(4*pi*x) assert cos(3*x*pi) == cos(3*pi*x) assert sin(3*x*pi) == sin(3*pi*x) assert tan(3*x*pi) == tan(3*pi*x) assert cot(3*x*pi) == cot(3*pi*x) assert cos(4.0*x*pi) == cos(4.0*pi*x) assert sin(4.0*x*pi) == sin(4.0*pi*x) assert tan(4.0*x*pi) == tan(4.0*pi*x) assert cot(4.0*x*pi) == cot(4.0*pi*x) assert cos(3.0*x*pi) == cos(3.0*pi*x) assert sin(3.0*x*pi) == sin(3.0*pi*x) assert tan(3.0*x*pi) == tan(3.0*pi*x) assert cot(3.0*x*pi) == cot(3.0*pi*x) assert cos(4.5*x*pi) == cos(4.5*pi*x) assert sin(4.5*x*pi) == sin(4.5*pi*x) assert tan(4.5*x*pi) == tan(4.5*pi*x) assert cot(4.5*x*pi) == cot(4.5*pi*x) def test_inverses(): raises(AttributeError, lambda: sin(x).inverse()) raises(AttributeError, lambda: cos(x).inverse()) assert tan(x).inverse() == atan assert cot(x).inverse() == acot raises(AttributeError, lambda: csc(x).inverse()) raises(AttributeError, lambda: sec(x).inverse()) assert asin(x).inverse() == sin assert acos(x).inverse() == cos assert atan(x).inverse() == tan assert acot(x).inverse() == cot def test_real_imag(): a, b = symbols('a b', real=True) z = a + b*I for deep in [True, False]: assert sin( z).as_real_imag(deep=deep) == (sin(a)*cosh(b), cos(a)*sinh(b)) assert cos( z).as_real_imag(deep=deep) == (cos(a)*cosh(b), -sin(a)*sinh(b)) assert tan(z).as_real_imag(deep=deep) == (sin(2*a)/(cos(2*a) + cosh(2*b)), sinh(2*b)/(cos(2*a) + cosh(2*b))) assert cot(z).as_real_imag(deep=deep) == (-sin(2*a)/(cos(2*a) - cosh(2*b)), -sinh(2*b)/(cos(2*a) - cosh(2*b))) assert sin(a).as_real_imag(deep=deep) == (sin(a), 0) assert cos(a).as_real_imag(deep=deep) == (cos(a), 0) assert tan(a).as_real_imag(deep=deep) == (tan(a), 0) assert cot(a).as_real_imag(deep=deep) == (cot(a), 0) @XFAIL def test_sin_cos_with_infinity(): # Test for issue 5196 # https://github.com/sympy/sympy/issues/5196 assert sin(oo) == S.NaN assert cos(oo) == S.NaN @slow def test_sincos_rewrite_sqrt(): # equivalent to testing rewrite(pow) for p in [1, 3, 5, 17]: for t in [1, 8]: n = t*p # The vertices `exp(i*pi/n)` of a regular `n`-gon can # be expressed by means of nested square roots if and # only if `n` is a product of Fermat primes, `p`, and # powers of 2, `t'. The code aims to check all vertices # not belonging to an `m`-gon for `m < n`(`gcd(i, n) == 1`). # For large `n` this makes the test too slow, therefore # the vertices are limited to those of index `i < 10`. for i in range(1, min((n + 1)//2 + 1, 10)): if 1 == gcd(i, n): x = i*pi/n s1 = sin(x).rewrite(sqrt) c1 = cos(x).rewrite(sqrt) assert not s1.has(cos, sin), "fails for %d*pi/%d" % (i, n) assert not c1.has(cos, sin), "fails for %d*pi/%d" % (i, n) assert 1e-3 > abs(sin(x.evalf(5)) - s1.evalf(2)), "fails for %d*pi/%d" % (i, n) assert 1e-3 > abs(cos(x.evalf(5)) - c1.evalf(2)), "fails for %d*pi/%d" % (i, n) assert cos(pi/14).rewrite(sqrt) == sqrt(cos(pi/7)/2 + S.Half) assert cos(pi/257).rewrite(sqrt).evalf(64) == cos(pi/257).evalf(64) assert cos(-15*pi/2/11, evaluate=False).rewrite( sqrt) == -sqrt(-cos(4*pi/11)/2 + S.Half) assert cos(Mul(2, pi, S.Half, evaluate=False), evaluate=False).rewrite( sqrt) == -1 e = cos(pi/3/17) # don't use pi/15 since that is caught at instantiation a = ( -3*sqrt(-sqrt(17) + 17)*sqrt(sqrt(17) + 17)/64 - 3*sqrt(34)*sqrt(sqrt(17) + 17)/128 - sqrt(sqrt(17) + 17)*sqrt(-8*sqrt(2)*sqrt(sqrt(17) + 17) - sqrt(2)*sqrt(-sqrt(17) + 17) + sqrt(34)*sqrt(-sqrt(17) + 17) + 6*sqrt(17) + 34)/64 - sqrt(-sqrt(17) + 17)*sqrt(-8*sqrt(2)*sqrt(sqrt(17) + 17) - sqrt(2)*sqrt(-sqrt(17) + 17) + sqrt(34)*sqrt(-sqrt(17) + 17) + 6*sqrt(17) + 34)/128 - S(1)/32 + sqrt(2)*sqrt(-8*sqrt(2)*sqrt(sqrt(17) + 17) - sqrt(2)*sqrt(-sqrt(17) + 17) + sqrt(34)*sqrt(-sqrt(17) + 17) + 6*sqrt(17) + 34)/64 + 3*sqrt(2)*sqrt(sqrt(17) + 17)/128 + sqrt(34)*sqrt(-sqrt(17) + 17)/128 + 13*sqrt(2)*sqrt(-sqrt(17) + 17)/128 + sqrt(17)*sqrt(-sqrt(17) + 17)*sqrt(-8*sqrt(2)*sqrt(sqrt(17) + 17) - sqrt(2)*sqrt(-sqrt(17) + 17) + sqrt(34)*sqrt(-sqrt(17) + 17) + 6*sqrt(17) + 34)/128 + 5*sqrt(17)/32 + sqrt(3)*sqrt(-sqrt(2)*sqrt(sqrt(17) + 17)*sqrt(sqrt(17)/32 + sqrt(2)*sqrt(-sqrt(17) + 17)/32 + sqrt(2)*sqrt(-8*sqrt(2)*sqrt(sqrt(17) + 17) - sqrt(2)*sqrt(-sqrt(17) + 17) + sqrt(34)*sqrt(-sqrt(17) + 17) + 6*sqrt(17) + 34)/32 + S(15)/32)/8 - 5*sqrt(2)*sqrt(sqrt(17)/32 + sqrt(2)*sqrt(-sqrt(17) + 17)/32 + sqrt(2)*sqrt(-8*sqrt(2)*sqrt(sqrt(17) + 17) - sqrt(2)*sqrt(-sqrt(17) + 17) + sqrt(34)*sqrt(-sqrt(17) + 17) + 6*sqrt(17) + 34)/32 + S(15)/32)*sqrt(-8*sqrt(2)*sqrt(sqrt(17) + 17) - sqrt(2)*sqrt(-sqrt(17) + 17) + sqrt(34)*sqrt(-sqrt(17) + 17) + 6*sqrt(17) + 34)/64 - 3*sqrt(2)*sqrt(-sqrt(17) + 17)*sqrt(sqrt(17)/32 + sqrt(2)*sqrt(-sqrt(17) + 17)/32 + sqrt(2)*sqrt(-8*sqrt(2)*sqrt(sqrt(17) + 17) - sqrt(2)*sqrt(-sqrt(17) + 17) + sqrt(34)*sqrt(-sqrt(17) + 17) + 6*sqrt(17) + 34)/32 + S(15)/32)/32 + sqrt(34)*sqrt(sqrt(17)/32 + sqrt(2)*sqrt(-sqrt(17) + 17)/32 + sqrt(2)*sqrt(-8*sqrt(2)*sqrt(sqrt(17) + 17) - sqrt(2)*sqrt(-sqrt(17) + 17) + sqrt(34)*sqrt(-sqrt(17) + 17) + 6*sqrt(17) + 34)/32 + S(15)/32)*sqrt(-8*sqrt(2)*sqrt(sqrt(17) + 17) - sqrt(2)*sqrt(-sqrt(17) + 17) + sqrt(34)*sqrt(-sqrt(17) + 17) + 6*sqrt(17) + 34)/64 + sqrt(sqrt(17)/32 + sqrt(2)*sqrt(-sqrt(17) + 17)/32 + sqrt(2)*sqrt(-8*sqrt(2)*sqrt(sqrt(17) + 17) - sqrt(2)*sqrt(-sqrt(17) + 17) + sqrt(34)*sqrt(-sqrt(17) + 17) + 6*sqrt(17) + 34)/32 + S(15)/32)/2 + S.Half + sqrt(-sqrt(17) + 17)*sqrt(sqrt(17)/32 + sqrt(2)*sqrt(-sqrt(17) + 17)/32 + sqrt(2)*sqrt(-8*sqrt(2)*sqrt(sqrt(17) + 17) - sqrt(2)*sqrt(-sqrt(17) + 17) + sqrt(34)*sqrt(-sqrt(17) + 17) + 6*sqrt(17) + 34)/32 + S(15)/32)*sqrt(-8*sqrt(2)*sqrt(sqrt(17) + 17) - sqrt(2)*sqrt(-sqrt(17) + 17) + sqrt(34)*sqrt(-sqrt(17) + 17) + 6*sqrt(17) + 34)/32 + sqrt(34)*sqrt(-sqrt(17) + 17)*sqrt(sqrt(17)/32 + sqrt(2)*sqrt(-sqrt(17) + 17)/32 + sqrt(2)*sqrt(-8*sqrt(2)*sqrt(sqrt(17) + 17) - sqrt(2)*sqrt(-sqrt(17) + 17) + sqrt(34)*sqrt(-sqrt(17) + 17) + 6*sqrt(17) + 34)/32 + S(15)/32)/32)/2) assert e.rewrite(sqrt) == a assert e.n() == a.n() # coverage of fermatCoords: multiplicity > 1; the following could be # different but that portion of the code should be tested in some way assert cos(pi/9/17).rewrite(sqrt) == \ sin(pi/9)*sin(2*pi/17) + cos(pi/9)*cos(2*pi/17) @slow def test_tancot_rewrite_sqrt(): # equivalent to testing rewrite(pow) for p in [1, 3, 5, 17]: for t in [1, 8]: n = t*p for i in range(1, min((n + 1)//2 + 1, 10)): if 1 == gcd(i, n): x = i*pi/n if 2*i != n and 3*i != 2*n: t1 = tan(x).rewrite(sqrt) assert not t1.has(cot, tan), "fails for %d*pi/%d" % (i, n) assert 1e-3 > abs( tan(x.evalf(7)) - t1.evalf(4) ), "fails for %d*pi/%d" % (i, n) if i != 0 and i != n: c1 = cot(x).rewrite(sqrt) assert not c1.has(cot, tan), "fails for %d*pi/%d" % (i, n) assert 1e-3 > abs( cot(x.evalf(7)) - c1.evalf(4) ), "fails for %d*pi/%d" % (i, n) def test_sec(): x = symbols('x', real=True) z = symbols('z') assert sec.nargs == FiniteSet(1) assert sec(zoo) == nan assert sec(0) == 1 assert sec(pi) == -1 assert sec(pi/2) == zoo assert sec(-pi/2) == zoo assert sec(pi/6) == 2*sqrt(3)/3 assert sec(pi/3) == 2 assert sec(5*pi/2) == zoo assert sec(9*pi/7) == -sec(2*pi/7) assert sec(3*pi/4) == -sqrt(2) # issue 8421 assert sec(I) == 1/cosh(1) assert sec(x*I) == 1/cosh(x) assert sec(-x) == sec(x) assert sec(asec(x)) == x assert sec(z).conjugate() == sec(conjugate(z)) assert (sec(z).as_real_imag() == (cos(re(z))*cosh(im(z))/(sin(re(z))**2*sinh(im(z))**2 + cos(re(z))**2*cosh(im(z))**2), sin(re(z))*sinh(im(z))/(sin(re(z))**2*sinh(im(z))**2 + cos(re(z))**2*cosh(im(z))**2))) assert sec(x).expand(trig=True) == 1/cos(x) assert sec(2*x).expand(trig=True) == 1/(2*cos(x)**2 - 1) assert sec(x).is_real == True assert sec(z).is_real == None assert sec(a).is_algebraic is None assert sec(na).is_algebraic is False assert sec(x).as_leading_term() == sec(x) assert sec(0).is_finite == True assert sec(x).is_finite == None assert sec(pi/2).is_finite == False assert series(sec(x), x, x0=0, n=6) == 1 + x**2/2 + 5*x**4/24 + O(x**6) # https://github.com/sympy/sympy/issues/7166 assert series(sqrt(sec(x))) == 1 + x**2/4 + 7*x**4/96 + O(x**6) # https://github.com/sympy/sympy/issues/7167 assert (series(sqrt(sec(x)), x, x0=pi*3/2, n=4) == 1/sqrt(x - 3*pi/2) + (x - 3*pi/2)**(S(3)/2)/12 + (x - 3*pi/2)**(S(7)/2)/160 + O((x - 3*pi/2)**4, (x, 3*pi/2))) assert sec(x).diff(x) == tan(x)*sec(x) # Taylor Term checks assert sec(z).taylor_term(4, z) == 5*z**4/24 assert sec(z).taylor_term(6, z) == 61*z**6/720 assert sec(z).taylor_term(5, z) == 0 def test_sec_rewrite(): assert sec(x).rewrite(exp) == 1/(exp(I*x)/2 + exp(-I*x)/2) assert sec(x).rewrite(cos) == 1/cos(x) assert sec(x).rewrite(tan) == (tan(x/2)**2 + 1)/(-tan(x/2)**2 + 1) assert sec(x).rewrite(pow) == sec(x) assert sec(x).rewrite(sqrt) == sec(x) assert sec(z).rewrite(cot) == (cot(z/2)**2 + 1)/(cot(z/2)**2 - 1) assert sec(x).rewrite(sin) == 1 / sin(x + pi / 2, evaluate=False) assert sec(x).rewrite(tan) == (tan(x / 2)**2 + 1) / (-tan(x / 2)**2 + 1) assert sec(x).rewrite(csc) == csc(-x + pi/2, evaluate=False) def test_csc(): x = symbols('x', real=True) z = symbols('z') # https://github.com/sympy/sympy/issues/6707 cosecant = csc('x') alternate = 1/sin('x') assert cosecant.equals(alternate) == True assert alternate.equals(cosecant) == True assert csc.nargs == FiniteSet(1) assert csc(0) == zoo assert csc(pi) == zoo assert csc(zoo) == nan assert csc(pi/2) == 1 assert csc(-pi/2) == -1 assert csc(pi/6) == 2 assert csc(pi/3) == 2*sqrt(3)/3 assert csc(5*pi/2) == 1 assert csc(9*pi/7) == -csc(2*pi/7) assert csc(3*pi/4) == sqrt(2) # issue 8421 assert csc(I) == -I/sinh(1) assert csc(x*I) == -I/sinh(x) assert csc(-x) == -csc(x) assert csc(acsc(x)) == x assert csc(z).conjugate() == csc(conjugate(z)) assert (csc(z).as_real_imag() == (sin(re(z))*cosh(im(z))/(sin(re(z))**2*cosh(im(z))**2 + cos(re(z))**2*sinh(im(z))**2), -cos(re(z))*sinh(im(z))/(sin(re(z))**2*cosh(im(z))**2 + cos(re(z))**2*sinh(im(z))**2))) assert csc(x).expand(trig=True) == 1/sin(x) assert csc(2*x).expand(trig=True) == 1/(2*sin(x)*cos(x)) assert csc(x).is_real == True assert csc(z).is_real == None assert csc(a).is_algebraic is None assert csc(na).is_algebraic is False assert csc(x).as_leading_term() == csc(x) assert csc(0).is_finite == False assert csc(x).is_finite == None assert csc(pi/2).is_finite == True assert series(csc(x), x, x0=pi/2, n=6) == \ 1 + (x - pi/2)**2/2 + 5*(x - pi/2)**4/24 + O((x - pi/2)**6, (x, pi/2)) assert series(csc(x), x, x0=0, n=6) == \ 1/x + x/6 + 7*x**3/360 + 31*x**5/15120 + O(x**6) assert csc(x).diff(x) == -cot(x)*csc(x) assert csc(x).taylor_term(2, x) == 0 assert csc(x).taylor_term(3, x) == 7*x**3/360 assert csc(x).taylor_term(5, x) == 31*x**5/15120 def test_asec(): z = Symbol('z', zero=True) assert asec(z) == zoo assert asec(nan) == nan assert asec(1) == 0 assert asec(-1) == pi assert asec(oo) == pi/2 assert asec(-oo) == pi/2 assert asec(zoo) == pi/2 assert asec(x).diff(x) == 1/(x**2*sqrt(1 - 1/x**2)) assert asec(x).as_leading_term(x) == log(x) assert asec(x).rewrite(log) == I*log(sqrt(1 - 1/x**2) + I/x) + pi/2 assert asec(x).rewrite(asin) == -asin(1/x) + pi/2 assert asec(x).rewrite(acos) == acos(1/x) assert asec(x).rewrite(atan) == (2*atan(x + sqrt(x**2 - 1)) - pi/2)*sqrt(x**2)/x assert asec(x).rewrite(acot) == (2*acot(x - sqrt(x**2 - 1)) - pi/2)*sqrt(x**2)/x assert asec(x).rewrite(acsc) == -acsc(x) + pi/2 def test_asec_is_real(): assert asec(S(1)/2).is_real is False n = Symbol('n', positive=True, integer=True) assert asec(n).is_real is True assert asec(x).is_real is None assert asec(r).is_real is None t = Symbol('t', real=False) assert asec(t).is_real is False def test_acsc(): assert acsc(nan) == nan assert acsc(1) == pi/2 assert acsc(-1) == -pi/2 assert acsc(oo) == 0 assert acsc(-oo) == 0 assert acsc(zoo) == 0 assert acsc(x).diff(x) == -1/(x**2*sqrt(1 - 1/x**2)) assert acsc(x).as_leading_term(x) == log(x) assert acsc(x).rewrite(log) == -I*log(sqrt(1 - 1/x**2) + I/x) assert acsc(x).rewrite(asin) == asin(1/x) assert acsc(x).rewrite(acos) == -acos(1/x) + pi/2 assert acsc(x).rewrite(atan) == (-atan(sqrt(x**2 - 1)) + pi/2)*sqrt(x**2)/x assert acsc(x).rewrite(acot) == (-acot(1/sqrt(x**2 - 1)) + pi/2)*sqrt(x**2)/x assert acsc(x).rewrite(asec) == -asec(x) + pi/2 def test_csc_rewrite(): assert csc(x).rewrite(pow) == csc(x) assert csc(x).rewrite(sqrt) == csc(x) assert csc(x).rewrite(exp) == 2*I/(exp(I*x) - exp(-I*x)) assert csc(x).rewrite(sin) == 1/sin(x) assert csc(x).rewrite(tan) == (tan(x/2)**2 + 1)/(2*tan(x/2)) assert csc(x).rewrite(cot) == (cot(x/2)**2 + 1)/(2*cot(x/2)) assert csc(x).rewrite(cos) == 1/cos(x - pi/2, evaluate=False) assert csc(x).rewrite(sec) == sec(-x + pi/2, evaluate=False) def test_issue_8653(): n = Symbol('n', integer=True) assert sin(n).is_irrational is None assert cos(n).is_irrational is None assert tan(n).is_irrational is None def test_issue_9157(): n = Symbol('n', integer=True, positive=True) atan(n - 1).is_nonnegative is True def test_trig_period(): x, y = symbols('x, y') assert sin(x).period() == 2*pi assert cos(x).period() == 2*pi assert tan(x).period() == pi assert cot(x).period() == pi assert sec(x).period() == 2*pi assert csc(x).period() == 2*pi assert sin(2*x).period() == pi assert cot(4*x - 6).period() == pi/4 assert cos((-3)*x).period() == 2*pi/3 assert cos(x*y).period(x) == 2*pi/abs(y) assert sin(3*x*y + 2*pi).period(y) == 2*pi/abs(3*x) assert tan(3*x).period(y) == S.Zero raises(NotImplementedError, lambda: sin(x**2).period(x)) def test_issue_7171(): assert sin(x).rewrite(sqrt) == sin(x) assert sin(x).rewrite(pow) == sin(x) def test_issue_11864(): w, k = symbols('w, k', real=True) F = Piecewise((1, Eq(2*pi*k, 0)), (sin(pi*k)/(pi*k), True)) soln = Piecewise((1, Eq(2*pi*k, 0)), (sinc(pi*k), True)) assert F.rewrite(sinc) == soln def test_real_assumptions(): z = Symbol('z', real=False) assert sin(z).is_real is None assert cos(z).is_real is None assert tan(z).is_real is False assert sec(z).is_real is None assert csc(z).is_real is None assert cot(z).is_real is False assert asin(p).is_real is None assert asin(n).is_real is None assert asec(p).is_real is None assert asec(n).is_real is None assert acos(p).is_real is None assert acos(n).is_real is None assert acsc(p).is_real is None assert acsc(n).is_real is None assert atan(p).is_positive is True assert atan(n).is_negative is True assert acot(p).is_positive is True assert acot(n).is_negative is True def test_issue_14320(): assert asin(sin(2)) == -2 + pi and (-pi/2 <= -2 + pi <= pi/2) and sin(2) == sin(-2 + pi) assert asin(cos(2)) == -2 + pi/2 and (-pi/2 <= -2 + pi/2 <= pi/2) and cos(2) == sin(-2 + pi/2) assert acos(sin(2)) == -pi/2 + 2 and (0 <= -pi/2 + 2 <= pi) and sin(2) == cos(-pi/2 + 2) assert acos(cos(20)) == -6*pi + 20 and (0 <= -6*pi + 20 <= pi) and cos(20) == cos(-6*pi + 20) assert acos(cos(30)) == -30 + 10*pi and (0 <= -30 + 10*pi <= pi) and cos(30) == cos(-30 + 10*pi) assert atan(tan(17)) == -5*pi + 17 and (-pi/2 < -5*pi + 17 < pi/2) and tan(17) == tan(-5*pi + 17) assert atan(tan(15)) == -5*pi + 15 and (-pi/2 < -5*pi + 15 < pi/2) and tan(15) == tan(-5*pi + 15) assert atan(cot(12)) == -12 + 7*pi/2 and (-pi/2 < -12 + 7*pi/2 < pi/2) and cot(12) == tan(-12 + 7*pi/2) assert acot(cot(15)) == -5*pi + 15 and (-pi/2 < -5*pi + 15 <= pi/2) and cot(15) == cot(-5*pi + 15) assert acot(tan(19)) == -19 + 13*pi/2 and (-pi/2 < -19 + 13*pi/2 <= pi/2) and tan(19) == cot(-19 + 13*pi/2) assert asec(sec(11)) == -11 + 4*pi and (0 <= -11 + 4*pi <= pi) and cos(11) == cos(-11 + 4*pi) assert asec(csc(13)) == -13 + 9*pi/2 and (0 <= -13 + 9*pi/2 <= pi) and sin(13) == cos(-13 + 9*pi/2) assert acsc(csc(14)) == -4*pi + 14 and (-pi/2 <= -4*pi + 14 <= pi/2) and sin(14) == sin(-4*pi + 14) assert acsc(sec(10)) == -7*pi/2 + 10 and (-pi/2 <= -7*pi/2 + 10 <= pi/2) and cos(10) == sin(-7*pi/2 + 10) def test_issue_14543(): assert sec(2*pi + 11) == sec(11) assert sec(2*pi - 11) == sec(11) assert sec(pi + 11) == -sec(11) assert sec(pi - 11) == -sec(11) assert csc(2*pi + 17) == csc(17) assert csc(2*pi - 17) == -csc(17) assert csc(pi + 17) == -csc(17) assert csc(pi - 17) == csc(17) x = Symbol('x') assert csc(pi/2 + x) == sec(x) assert csc(pi/2 - x) == sec(x) assert csc(3*pi/2 + x) == -sec(x) assert csc(3*pi/2 - x) == -sec(x) assert sec(pi/2 - x) == csc(x) assert sec(pi/2 + x) == -csc(x) assert sec(3*pi/2 + x) == csc(x) assert sec(3*pi/2 - x) == -csc(x) def test_issue_15959(): assert tan(3*pi/8) == 1 + sqrt(2)
db6842f4637520d8ae271693f3a06587598ab969103e498010fd104c978d61fb
from sympy import ( adjoint, And, Basic, conjugate, diff, expand, Eq, Function, I, ITE, Integral, integrate, Interval, lambdify, log, Max, Min, oo, Or, pi, Piecewise, piecewise_fold, Rational, solve, symbols, transpose, cos, sin, exp, Abs, Ne, Not, Symbol, S, sqrt, Tuple, zoo, factor_terms, DiracDelta, Heaviside, Add, Mul, factorial, Ge) from sympy.printing import srepr from sympy.utilities.pytest import raises, slow from sympy.functions.elementary.piecewise import Undefined a, b, c, d, x, y = symbols('a:d, x, y') z = symbols('z', nonzero=True) def test_piecewise(): # Test canonicalization assert Piecewise((x, x < 1), (0, True)) == Piecewise((x, x < 1), (0, True)) assert Piecewise((x, x < 1), (0, True), (1, True)) == \ Piecewise((x, x < 1), (0, True)) assert Piecewise((x, x < 1), (0, False), (-1, 1 > 2)) == \ Piecewise((x, x < 1)) assert Piecewise((x, x < 1), (0, x < 1), (0, True)) == \ Piecewise((x, x < 1), (0, True)) assert Piecewise((x, x < 1), (0, x < 2), (0, True)) == \ Piecewise((x, x < 1), (0, True)) assert Piecewise((x, x < 1), (x, x < 2), (0, True)) == \ Piecewise((x, Or(x < 1, x < 2)), (0, True)) assert Piecewise((x, x < 1), (x, x < 2), (x, True)) == x assert Piecewise((x, True)) == x # Explicitly constructed empty Piecewise not accepted raises(TypeError, lambda: Piecewise()) # False condition is never retained assert Piecewise((2*x, x < 0), (x, False)) == \ Piecewise((2*x, x < 0), (x, False), evaluate=False) == \ Piecewise((2*x, x < 0)) assert Piecewise((x, False)) == Undefined raises(TypeError, lambda: Piecewise(x)) assert Piecewise((x, 1)) == x # 1 and 0 are accepted as True/False raises(TypeError, lambda: Piecewise((x, 2))) raises(TypeError, lambda: Piecewise((x, x**2))) raises(TypeError, lambda: Piecewise(([1], True))) assert Piecewise(((1, 2), True)) == Tuple(1, 2) cond = (Piecewise((1, x < 0), (2, True)) < y) assert Piecewise((1, cond) ) == Piecewise((1, ITE(x < 0, y > 1, y > 2))) assert Piecewise((1, x > 0), (2, And(x <= 0, x > -1)) ) == Piecewise((1, x > 0), (2, x > -1)) # Test subs p = Piecewise((-1, x < -1), (x**2, x < 0), (log(x), x >= 0)) p_x2 = Piecewise((-1, x**2 < -1), (x**4, x**2 < 0), (log(x**2), x**2 >= 0)) assert p.subs(x, x**2) == p_x2 assert p.subs(x, -5) == -1 assert p.subs(x, -1) == 1 assert p.subs(x, 1) == log(1) # More subs tests p2 = Piecewise((1, x < pi), (-1, x < 2*pi), (0, x > 2*pi)) p3 = Piecewise((1, Eq(x, 0)), (1/x, True)) p4 = Piecewise((1, Eq(x, 0)), (2, 1/x>2)) assert p2.subs(x, 2) == 1 assert p2.subs(x, 4) == -1 assert p2.subs(x, 10) == 0 assert p3.subs(x, 0.0) == 1 assert p4.subs(x, 0.0) == 1 f, g, h = symbols('f,g,h', cls=Function) pf = Piecewise((f(x), x < -1), (f(x) + h(x) + 2, x <= 1)) pg = Piecewise((g(x), x < -1), (g(x) + h(x) + 2, x <= 1)) assert pg.subs(g, f) == pf assert Piecewise((1, Eq(x, 0)), (0, True)).subs(x, 0) == 1 assert Piecewise((1, Eq(x, 0)), (0, True)).subs(x, 1) == 0 assert Piecewise((1, Eq(x, y)), (0, True)).subs(x, y) == 1 assert Piecewise((1, Eq(x, z)), (0, True)).subs(x, z) == 1 assert Piecewise((1, Eq(exp(x), cos(z))), (0, True)).subs(x, z) == \ Piecewise((1, Eq(exp(z), cos(z))), (0, True)) p5 = Piecewise( (0, Eq(cos(x) + y, 0)), (1, True)) assert p5.subs(y, 0) == Piecewise( (0, Eq(cos(x), 0)), (1, True)) assert Piecewise((-1, y < 1), (0, x < 0), (1, Eq(x, 0)), (2, True) ).subs(x, 1) == Piecewise((-1, y < 1), (2, True)) assert Piecewise((1, Eq(x**2, -1)), (2, x < 0)).subs(x, I) == 1 p6 = Piecewise((x, x > 0)) n = symbols('n', negative=True) assert p6.subs(x, n) == Undefined # Test evalf assert p.evalf() == p assert p.evalf(subs={x: -2}) == -1 assert p.evalf(subs={x: -1}) == 1 assert p.evalf(subs={x: 1}) == log(1) assert p6.evalf(subs={x: -5}) == Undefined # Test doit f_int = Piecewise((Integral(x, (x, 0, 1)), x < 1)) assert f_int.doit() == Piecewise( (S(1)/2, x < 1) ) # Test differentiation f = x fp = x*p dp = Piecewise((0, x < -1), (2*x, x < 0), (1/x, x >= 0)) fp_dx = x*dp + p assert diff(p, x) == dp assert diff(f*p, x) == fp_dx # Test simple arithmetic assert x*p == fp assert x*p + p == p + x*p assert p + f == f + p assert p + dp == dp + p assert p - dp == -(dp - p) # Test power dp2 = Piecewise((0, x < -1), (4*x**2, x < 0), (1/x**2, x >= 0)) assert dp**2 == dp2 # Test _eval_interval f1 = x*y + 2 f2 = x*y**2 + 3 peval = Piecewise((f1, x < 0), (f2, x > 0)) peval_interval = f1.subs( x, 0) - f1.subs(x, -1) + f2.subs(x, 1) - f2.subs(x, 0) assert peval._eval_interval(x, 0, 0) == 0 assert peval._eval_interval(x, -1, 1) == peval_interval peval2 = Piecewise((f1, x < 0), (f2, True)) assert peval2._eval_interval(x, 0, 0) == 0 assert peval2._eval_interval(x, 1, -1) == -peval_interval assert peval2._eval_interval(x, -1, -2) == f1.subs(x, -2) - f1.subs(x, -1) assert peval2._eval_interval(x, -1, 1) == peval_interval assert peval2._eval_interval(x, None, 0) == peval2.subs(x, 0) assert peval2._eval_interval(x, -1, None) == -peval2.subs(x, -1) # Test integration assert p.integrate() == Piecewise( (-x, x < -1), (x**3/3 + S(4)/3, x < 0), (x*log(x) - x + S(4)/3, True)) p = Piecewise((x, x < 1), (x**2, -1 <= x), (x, 3 < x)) assert integrate(p, (x, -2, 2)) == 5/6.0 assert integrate(p, (x, 2, -2)) == -5/6.0 p = Piecewise((0, x < 0), (1, x < 1), (0, x < 2), (1, x < 3), (0, True)) assert integrate(p, (x, -oo, oo)) == 2 p = Piecewise((x, x < -10), (x**2, x <= -1), (x, 1 < x)) assert integrate(p, (x, -2, 2)) == Undefined # Test commutativity assert isinstance(p, Piecewise) and p.is_commutative is True def test_piecewise_free_symbols(): f = Piecewise((x, a < 0), (y, True)) assert f.free_symbols == {x, y, a} def test_piecewise_integrate1(): x, y = symbols('x y', real=True, finite=True) f = Piecewise(((x - 2)**2, x >= 0), (1, True)) assert integrate(f, (x, -2, 2)) == Rational(14, 3) g = Piecewise(((x - 5)**5, x >= 4), (f, True)) assert integrate(g, (x, -2, 2)) == Rational(14, 3) assert integrate(g, (x, -2, 5)) == Rational(43, 6) assert g == Piecewise(((x - 5)**5, x >= 4), (f, x < 4)) g = Piecewise(((x - 5)**5, 2 <= x), (f, x < 2)) assert integrate(g, (x, -2, 2)) == Rational(14, 3) assert integrate(g, (x, -2, 5)) == -Rational(701, 6) assert g == Piecewise(((x - 5)**5, 2 <= x), (f, True)) g = Piecewise(((x - 5)**5, 2 <= x), (2*f, True)) assert integrate(g, (x, -2, 2)) == 2 * Rational(14, 3) assert integrate(g, (x, -2, 5)) == -Rational(673, 6) def test_piecewise_integrate1b(): g = Piecewise((1, x > 0), (0, Eq(x, 0)), (-1, x < 0)) assert integrate(g, (x, -1, 1)) == 0 g = Piecewise((1, x - y < 0), (0, True)) assert integrate(g, (y, -oo, 0)) == -Min(0, x) assert g.subs(x, -3).integrate((y, -oo, 0)) == 3 assert integrate(g, (y, 0, -oo)) == Min(0, x) assert integrate(g, (y, 0, oo)) == -Max(0, x) + oo assert integrate(g, (y, -oo, 42)) == -Min(42, x) + 42 assert integrate(g, (y, -oo, oo)) == -x + oo g = Piecewise((0, x < 0), (x, x <= 1), (1, True)) gy1 = g.integrate((x, y, 1)) g1y = g.integrate((x, 1, y)) for yy in (-1, S.Half, 2): assert g.integrate((x, yy, 1)) == gy1.subs(y, yy) assert g.integrate((x, 1, yy)) == g1y.subs(y, yy) assert gy1 == Piecewise( (-Min(1, Max(0, y))**2/2 + S(1)/2, y < 1), (-y + 1, True)) assert g1y == Piecewise( (Min(1, Max(0, y))**2/2 - S(1)/2, y < 1), (y - 1, True)) @slow def test_piecewise_integrate1ca(): y = symbols('y', real=True) g = Piecewise( (1 - x, Interval(0, 1).contains(x)), (1 + x, Interval(-1, 0).contains(x)), (0, True) ) gy1 = g.integrate((x, y, 1)) g1y = g.integrate((x, 1, y)) assert g.integrate((x, -2, 1)) == gy1.subs(y, -2) assert g.integrate((x, 1, -2)) == g1y.subs(y, -2) assert g.integrate((x, 0, 1)) == gy1.subs(y, 0) assert g.integrate((x, 1, 0)) == g1y.subs(y, 0) # XXX Make test pass without simplify assert g.integrate((x, 2, 1)) == gy1.subs(y, 2).simplify() assert g.integrate((x, 1, 2)) == g1y.subs(y, 2).simplify() assert piecewise_fold(gy1.rewrite(Piecewise)) == \ Piecewise( (1, y <= -1), (-y**2/2 - y + S(1)/2, y <= 0), (y**2/2 - y + S(1)/2, y < 1), (0, True)) assert piecewise_fold(g1y.rewrite(Piecewise)) == \ Piecewise( (-1, y <= -1), (y**2/2 + y - S(1)/2, y <= 0), (-y**2/2 + y - S(1)/2, y < 1), (0, True)) # g1y and gy1 should simplify if the condition that y < 1 # is applied, e.g. Min(1, Max(-1, y)) --> Max(-1, y) # XXX Make test pass without simplify assert gy1.simplify() == Piecewise( ( -Min(1, Max(-1, y))**2/2 - Min(1, Max(-1, y)) + Min(1, Max(0, y))**2 + S(1)/2, y < 1), (0, True) ) assert g1y.simplify() == Piecewise( ( Min(1, Max(-1, y))**2/2 + Min(1, Max(-1, y)) - Min(1, Max(0, y))**2 - S(1)/2, y < 1), (0, True)) @slow def test_piecewise_integrate1cb(): y = symbols('y', real=True) g = Piecewise( (0, Or(x <= -1, x >= 1)), (1 - x, x > 0), (1 + x, True) ) gy1 = g.integrate((x, y, 1)) g1y = g.integrate((x, 1, y)) assert g.integrate((x, -2, 1)) == gy1.subs(y, -2) assert g.integrate((x, 1, -2)) == g1y.subs(y, -2) assert g.integrate((x, 0, 1)) == gy1.subs(y, 0) assert g.integrate((x, 1, 0)) == g1y.subs(y, 0) assert g.integrate((x, 2, 1)) == gy1.subs(y, 2) assert g.integrate((x, 1, 2)) == g1y.subs(y, 2) assert piecewise_fold(gy1.rewrite(Piecewise)) == \ Piecewise( (1, y <= -1), (-y**2/2 - y + S(1)/2, y <= 0), (y**2/2 - y + S(1)/2, y < 1), (0, True)) assert piecewise_fold(g1y.rewrite(Piecewise)) == \ Piecewise( (-1, y <= -1), (y**2/2 + y - S(1)/2, y <= 0), (-y**2/2 + y - S(1)/2, y < 1), (0, True)) # g1y and gy1 should simplify if the condition that y < 1 # is applied, e.g. Min(1, Max(-1, y)) --> Max(-1, y) assert gy1 == Piecewise( ( -Min(1, Max(-1, y))**2/2 - Min(1, Max(-1, y)) + Min(1, Max(0, y))**2 + S(1)/2, y < 1), (0, True) ) assert g1y == Piecewise( ( Min(1, Max(-1, y))**2/2 + Min(1, Max(-1, y)) - Min(1, Max(0, y))**2 - S(1)/2, y < 1), (0, True)) def test_piecewise_integrate2(): from itertools import permutations lim = Tuple(x, c, d) p = Piecewise((1, x < a), (2, x > b), (3, True)) q = p.integrate(lim) assert q == Piecewise( (-c + 2*d - 2*Min(d, Max(a, c)) + Min(d, Max(a, b, c)), c < d), (-2*c + d + 2*Min(c, Max(a, d)) - Min(c, Max(a, b, d)), True)) for v in permutations((1, 2, 3, 4)): r = dict(zip((a, b, c, d), v)) assert p.subs(r).integrate(lim.subs(r)) == q.subs(r) def test_meijer_bypass(): # totally bypass meijerg machinery when dealing # with Piecewise in integrate assert Piecewise((1, x < 4), (0, True)).integrate((x, oo, 1)) == -3 def test_piecewise_integrate3_inequality_conditions(): from sympy.utilities.iterables import cartes lim = (x, 0, 5) # set below includes two pts below range, 2 pts in range, # 2 pts above range, and the boundaries N = (-2, -1, 0, 1, 2, 5, 6, 7) p = Piecewise((1, x > a), (2, x > b), (0, True)) ans = p.integrate(lim) for i, j in cartes(N, repeat=2): reps = dict(zip((a, b), (i, j))) assert ans.subs(reps) == p.subs(reps).integrate(lim) assert ans.subs(a, 4).subs(b, 1) == 0 + 2*3 + 1 p = Piecewise((1, x > a), (2, x < b), (0, True)) ans = p.integrate(lim) for i, j in cartes(N, repeat=2): reps = dict(zip((a, b), (i, j))) assert ans.subs(reps) == p.subs(reps).integrate(lim) # delete old tests that involved c1 and c2 since those # reduce to the above except that a value of 0 was used # for two expressions whereas the above uses 3 different # values @slow def test_piecewise_integrate4_symbolic_conditions(): a = Symbol('a', real=True, finite=True) b = Symbol('b', real=True, finite=True) x = Symbol('x', real=True, finite=True) y = Symbol('y', real=True, finite=True) p0 = Piecewise((0, Or(x < a, x > b)), (1, True)) p1 = Piecewise((0, x < a), (0, x > b), (1, True)) p2 = Piecewise((0, x > b), (0, x < a), (1, True)) p3 = Piecewise((0, x < a), (1, x < b), (0, True)) p4 = Piecewise((0, x > b), (1, x > a), (0, True)) p5 = Piecewise((1, And(a < x, x < b)), (0, True)) # check values of a=1, b=3 (and reversed) with values # of y of 0, 1, 2, 3, 4 lim = Tuple(x, -oo, y) for p in (p0, p1, p2, p3, p4, p5): ans = p.integrate(lim) for i in range(5): reps = {a:1, b:3, y:i} assert ans.subs(reps) == p.subs(reps).integrate(lim.subs(reps)) reps = {a: 3, b:1, y:i} assert ans.subs(reps) == p.subs(reps).integrate(lim.subs(reps)) lim = Tuple(x, y, oo) for p in (p0, p1, p2, p3, p4, p5): ans = p.integrate(lim) for i in range(5): reps = {a:1, b:3, y:i} assert ans.subs(reps) == p.subs(reps).integrate(lim.subs(reps)) reps = {a:3, b:1, y:i} assert ans.subs(reps) == p.subs(reps).integrate(lim.subs(reps)) ans = Piecewise( (0, x <= Min(a, b)), (x - Min(a, b), x <= b), (b - Min(a, b), True)) for i in (p0, p1, p2, p4): assert i.integrate(x) == ans assert p3.integrate(x) == Piecewise( (0, x < a), (-a + x, x <= Max(a, b)), (-a + Max(a, b), True)) assert p5.integrate(x) == Piecewise( (0, x <= a), (-a + x, x <= Max(a, b)), (-a + Max(a, b), True)) p1 = Piecewise((0, x < a), (0.5, x > b), (1, True)) p2 = Piecewise((0.5, x > b), (0, x < a), (1, True)) p3 = Piecewise((0, x < a), (1, x < b), (0.5, True)) p4 = Piecewise((0.5, x > b), (1, x > a), (0, True)) p5 = Piecewise((1, And(a < x, x < b)), (0.5, x > b), (0, True)) # check values of a=1, b=3 (and reversed) with values # of y of 0, 1, 2, 3, 4 lim = Tuple(x, -oo, y) for p in (p1, p2, p3, p4, p5): ans = p.integrate(lim) for i in range(5): reps = {a:1, b:3, y:i} assert ans.subs(reps) == p.subs(reps).integrate(lim.subs(reps)) reps = {a: 3, b:1, y:i} assert ans.subs(reps) == p.subs(reps).integrate(lim.subs(reps)) def test_piecewise_integrate5_independent_conditions(): p = Piecewise((0, Eq(y, 0)), (x*y, True)) assert integrate(p, (x, 1, 3)) == Piecewise((0, Eq(y, 0)), (4*y, True)) def test_piecewise_simplify(): p = Piecewise(((x**2 + 1)/x**2, Eq(x*(1 + x) - x**2, 0)), ((-1)**x*(-1), True)) assert p.simplify() == \ Piecewise((zoo, Eq(x, 0)), ((-1)**(x + 1), True)) # simplify when there are Eq in conditions assert Piecewise( (a, And(Eq(a, 0), Eq(a + b, 0))), (1, True)).simplify( ) == Piecewise( (0, And(Eq(a, 0), Eq(b, 0))), (1, True)) assert Piecewise((2*x*factorial(a)/(factorial(y)*factorial(-y + a)), Eq(y, 0) & Eq(-y + a, 0)), (2*factorial(a)/(factorial(y)*factorial(-y + a)), Eq(y, 0) & Eq(-y + a, 1)), (0, True)).simplify( ) == Piecewise( (2*x, And(Eq(a, 0), Eq(y, 0))), (2, And(Eq(a, 1), Eq(y, 0))), (0, True)) args = (2, And(Eq(x, 2), Ge(y ,0))), (x, True) assert Piecewise(*args).simplify() == Piecewise(*args) args = (1, Eq(x, 0)), (sin(x)/x, True) assert Piecewise(*args).simplify() == Piecewise(*args) assert Piecewise((2 + y, And(Eq(x, 2), Eq(y, 0))), (x, True) ).simplify() == x # check that x or f(x) are recognized as being Symbol-like for lhs args = Tuple((1, Eq(x, 0)), (sin(x) + 1 + x, True)) ans = x + sin(x) + 1 f = Function('f') assert Piecewise(*args).simplify() == ans assert Piecewise(*args.subs(x, f(x))).simplify() == ans.subs(x, f(x)) def test_piecewise_solve(): abs2 = Piecewise((-x, x <= 0), (x, x > 0)) f = abs2.subs(x, x - 2) assert solve(f, x) == [2] assert solve(f - 1, x) == [1, 3] f = Piecewise(((x - 2)**2, x >= 0), (1, True)) assert solve(f, x) == [2] g = Piecewise(((x - 5)**5, x >= 4), (f, True)) assert solve(g, x) == [2, 5] g = Piecewise(((x - 5)**5, x >= 4), (f, x < 4)) assert solve(g, x) == [2, 5] g = Piecewise(((x - 5)**5, x >= 2), (f, x < 2)) assert solve(g, x) == [5] g = Piecewise(((x - 5)**5, x >= 2), (f, True)) assert solve(g, x) == [5] g = Piecewise(((x - 5)**5, x >= 2), (f, True), (10, False)) assert solve(g, x) == [5] g = Piecewise(((x - 5)**5, x >= 2), (-x + 2, x - 2 <= 0), (x - 2, x - 2 > 0)) assert solve(g, x) == [5] # if no symbol is given the piecewise detection must still work assert solve(Piecewise((x - 2, x > 2), (2 - x, True)) - 3) == [-1, 5] f = Piecewise(((x - 2)**2, x >= 0), (0, True)) raises(NotImplementedError, lambda: solve(f, x)) def nona(ans): return list(filter(lambda x: x is not S.NaN, ans)) p = Piecewise((x**2 - 4, x < y), (x - 2, True)) ans = solve(p, x) assert nona([i.subs(y, -2) for i in ans]) == [2] assert nona([i.subs(y, 2) for i in ans]) == [-2, 2] assert nona([i.subs(y, 3) for i in ans]) == [-2, 2] assert ans == [ Piecewise((-2, y > -2), (S.NaN, True)), Piecewise((2, y <= 2), (S.NaN, True)), Piecewise((2, y > 2), (S.NaN, True))] # issue 6060 absxm3 = Piecewise( (x - 3, S(0) <= x - 3), (3 - x, S(0) > x - 3) ) assert solve(absxm3 - y, x) == [ Piecewise((-y + 3, -y < 0), (S.NaN, True)), Piecewise((y + 3, y >= 0), (S.NaN, True))] p = Symbol('p', positive=True) assert solve(absxm3 - p, x) == [-p + 3, p + 3] # issue 6989 f = Function('f') assert solve(Eq(-f(x), Piecewise((1, x > 0), (0, True))), f(x)) == \ [Piecewise((-1, x > 0), (0, True))] # issue 8587 f = Piecewise((2*x**2, And(S(0) < x, x < 1)), (2, True)) assert solve(f - 1) == [1/sqrt(2)] def test_piecewise_fold(): p = Piecewise((x, x < 1), (1, 1 <= x)) assert piecewise_fold(x*p) == Piecewise((x**2, x < 1), (x, 1 <= x)) assert piecewise_fold(p + p) == Piecewise((2*x, x < 1), (2, 1 <= x)) assert piecewise_fold(Piecewise((1, x < 0), (2, True)) + Piecewise((10, x < 0), (-10, True))) == \ Piecewise((11, x < 0), (-8, True)) p1 = Piecewise((0, x < 0), (x, x <= 1), (0, True)) p2 = Piecewise((0, x < 0), (1 - x, x <= 1), (0, True)) p = 4*p1 + 2*p2 assert integrate( piecewise_fold(p), (x, -oo, oo)) == integrate(2*x + 2, (x, 0, 1)) assert piecewise_fold( Piecewise((1, y <= 0), (-Piecewise((2, y >= 0)), True) )) == Piecewise((1, y <= 0), (-2, y >= 0)) assert piecewise_fold(Piecewise((x, ITE(x > 0, y < 1, y > 1))) ) == Piecewise((x, ((x <= 0) | (y < 1)) & ((x > 0) | (y > 1)))) a, b = (Piecewise((2, Eq(x, 0)), (0, True)), Piecewise((x, Eq(-x + y, 0)), (1, Eq(-x + y, 1)), (0, True))) assert piecewise_fold(Mul(a, b, evaluate=False) ) == piecewise_fold(Mul(b, a, evaluate=False)) def test_piecewise_fold_piecewise_in_cond(): p1 = Piecewise((cos(x), x < 0), (0, True)) p2 = Piecewise((0, Eq(p1, 0)), (p1 / Abs(p1), True)) p3 = piecewise_fold(p2) assert(p2.subs(x, -pi/2) == 0.0) assert(p2.subs(x, 1) == 0.0) assert(p2.subs(x, -pi/4) == 1.0) p4 = Piecewise((0, Eq(p1, 0)), (1,True)) ans = piecewise_fold(p4) for i in range(-1, 1): assert ans.subs(x, i) == p4.subs(x, i) r1 = 1 < Piecewise((1, x < 1), (3, True)) ans = piecewise_fold(r1) for i in range(2): assert ans.subs(x, i) == r1.subs(x, i) p5 = Piecewise((1, x < 0), (3, True)) p6 = Piecewise((1, x < 1), (3, True)) p7 = Piecewise((1, p5 < p6), (0, True)) ans = piecewise_fold(p7) for i in range(-1, 2): assert ans.subs(x, i) == p7.subs(x, i) def test_piecewise_fold_piecewise_in_cond_2(): p1 = Piecewise((cos(x), x < 0), (0, True)) p2 = Piecewise((0, Eq(p1, 0)), (1 / p1, True)) p3 = Piecewise( (0, (x >= 0) | Eq(cos(x), 0)), (1/cos(x), x < 0), (zoo, True)) # redundant b/c all x are already covered assert(piecewise_fold(p2) == p3) def test_piecewise_fold_expand(): p1 = Piecewise((1, Interval(0, 1, False, True).contains(x)), (0, True)) p2 = piecewise_fold(expand((1 - x)*p1)) assert p2 == Piecewise((1 - x, (x >= 0) & (x < 1)), (0, True)) assert p2 == expand(piecewise_fold((1 - x)*p1)) def test_piecewise_duplicate(): p = Piecewise((x, x < -10), (x**2, x <= -1), (x, 1 < x)) assert p == Piecewise(*p.args) def test_doit(): p1 = Piecewise((x, x < 1), (x**2, -1 <= x), (x, 3 < x)) p2 = Piecewise((x, x < 1), (Integral(2 * x), -1 <= x), (x, 3 < x)) assert p2.doit() == p1 assert p2.doit(deep=False) == p2 def test_piecewise_interval(): p1 = Piecewise((x, Interval(0, 1).contains(x)), (0, True)) assert p1.subs(x, -0.5) == 0 assert p1.subs(x, 0.5) == 0.5 assert p1.diff(x) == Piecewise((1, Interval(0, 1).contains(x)), (0, True)) assert integrate(p1, x) == Piecewise( (0, x <= 0), (x**2/2, x <= 1), (S(1)/2, True)) def test_piecewise_collapse(): assert Piecewise((x, True)) == x a = x < 1 assert Piecewise((x, a), (x + 1, a)) == Piecewise((x, a)) assert Piecewise((x, a), (x + 1, a.reversed)) == Piecewise((x, a)) b = x < 5 def canonical(i): if isinstance(i, Piecewise): return Piecewise(*i.args) return i for args in [ ((1, a), (Piecewise((2, a), (3, b)), b)), ((1, a), (Piecewise((2, a), (3, b.reversed)), b)), ((1, a), (Piecewise((2, a), (3, b)), b), (4, True)), ((1, a), (Piecewise((2, a), (3, b), (4, True)), b)), ((1, a), (Piecewise((2, a), (3, b), (4, True)), b), (5, True))]: for i in (0, 2, 10): assert canonical( Piecewise(*args, evaluate=False).subs(x, i) ) == canonical(Piecewise(*args).subs(x, i)) r1, r2, r3, r4 = symbols('r1:5') a = x < r1 b = x < r2 c = x < r3 d = x < r4 assert Piecewise((1, a), (Piecewise( (2, a), (3, b), (4, c)), b), (5, c) ) == Piecewise((1, a), (3, b), (5, c)) assert Piecewise((1, a), (Piecewise( (2, a), (3, b), (4, c), (6, True)), c), (5, d) ) == Piecewise((1, a), (Piecewise( (3, b), (4, c)), c), (5, d)) assert Piecewise((1, Or(a, d)), (Piecewise( (2, d), (3, b), (4, c)), b), (5, c) ) == Piecewise((1, Or(a, d)), (Piecewise( (2, d), (3, b)), b), (5, c)) assert Piecewise((1, c), (2, ~c), (3, S.true) ) == Piecewise((1, c), (2, S.true)) assert Piecewise((1, c), (2, And(~c, b)), (3,True) ) == Piecewise((1, c), (2, b), (3, True)) assert Piecewise((1, c), (2, Or(~c, b)), (3,True) ).subs(dict(zip((r1, r2, r3, r4, x), (1, 2, 3, 4, 3.5)))) == 2 assert Piecewise((1, c), (2, ~c)) == Piecewise((1, c), (2, True)) def test_piecewise_lambdify(): p = Piecewise( (x**2, x < 0), (x, Interval(0, 1, False, True).contains(x)), (2 - x, x >= 1), (0, True) ) f = lambdify(x, p) assert f(-2.0) == 4.0 assert f(0.0) == 0.0 assert f(0.5) == 0.5 assert f(2.0) == 0.0 def test_piecewise_series(): from sympy import sin, cos, O p1 = Piecewise((sin(x), x < 0), (cos(x), x > 0)) p2 = Piecewise((x + O(x**2), x < 0), (1 + O(x**2), x > 0)) assert p1.nseries(x, n=2) == p2 def test_piecewise_as_leading_term(): p1 = Piecewise((1/x, x > 1), (0, True)) p2 = Piecewise((x, x > 1), (0, True)) p3 = Piecewise((1/x, x > 1), (x, True)) p4 = Piecewise((x, x > 1), (1/x, True)) p5 = Piecewise((1/x, x > 1), (x, True)) p6 = Piecewise((1/x, x < 1), (x, True)) p7 = Piecewise((x, x < 1), (1/x, True)) p8 = Piecewise((x, x > 1), (1/x, True)) assert p1.as_leading_term(x) == 0 assert p2.as_leading_term(x) == 0 assert p3.as_leading_term(x) == x assert p4.as_leading_term(x) == 1/x assert p5.as_leading_term(x) == x assert p6.as_leading_term(x) == 1/x assert p7.as_leading_term(x) == x assert p8.as_leading_term(x) == 1/x def test_piecewise_complex(): p1 = Piecewise((2, x < 0), (1, 0 <= x)) p2 = Piecewise((2*I, x < 0), (I, 0 <= x)) p3 = Piecewise((I*x, x > 1), (1 + I, True)) p4 = Piecewise((-I*conjugate(x), x > 1), (1 - I, True)) assert conjugate(p1) == p1 assert conjugate(p2) == piecewise_fold(-p2) assert conjugate(p3) == p4 assert p1.is_imaginary is False assert p1.is_real is True assert p2.is_imaginary is True assert p2.is_real is False assert p3.is_imaginary is None assert p3.is_real is None assert p1.as_real_imag() == (p1, 0) assert p2.as_real_imag() == (0, -I*p2) def test_conjugate_transpose(): A, B = symbols("A B", commutative=False) p = Piecewise((A*B**2, x > 0), (A**2*B, True)) assert p.adjoint() == \ Piecewise((adjoint(A*B**2), x > 0), (adjoint(A**2*B), True)) assert p.conjugate() == \ Piecewise((conjugate(A*B**2), x > 0), (conjugate(A**2*B), True)) assert p.transpose() == \ Piecewise((transpose(A*B**2), x > 0), (transpose(A**2*B), True)) def test_piecewise_evaluate(): assert Piecewise((x, True)) == x assert Piecewise((x, True), evaluate=True) == x p = Piecewise((x, True), evaluate=False) assert p != x assert p.is_Piecewise assert all(isinstance(i, Basic) for i in p.args) assert Piecewise((1, Eq(1, x))).args == ((1, Eq(x, 1)),) assert Piecewise((1, Eq(1, x)), evaluate=False).args == ( (1, Eq(1, x)),) def test_as_expr_set_pairs(): assert Piecewise((x, x > 0), (-x, x <= 0)).as_expr_set_pairs() == \ [(x, Interval(0, oo, True, True)), (-x, Interval(-oo, 0))] assert Piecewise(((x - 2)**2, x >= 0), (0, True)).as_expr_set_pairs() == \ [((x - 2)**2, Interval(0, oo)), (0, Interval(-oo, 0, True, True))] def test_S_srepr_is_identity(): p = Piecewise((10, Eq(x, 0)), (12, True)) q = S(srepr(p)) assert p == q def test_issue_12587(): # sort holes into intervals p = Piecewise((1, x > 4), (2, Not((x <= 3) & (x > -1))), (3, True)) assert p.integrate((x, -5, 5)) == 23 p = Piecewise((1, x > 1), (2, x < y), (3, True)) lim = x, -3, 3 ans = p.integrate(lim) for i in range(-1, 3): assert ans.subs(y, i) == p.subs(y, i).integrate(lim) def test_issue_11045(): assert integrate(1/(x*sqrt(x**2 - 1)), (x, 1, 2)) == pi/3 # handle And with Or arguments assert Piecewise((1, And(Or(x < 1, x > 3), x < 2)), (0, True) ).integrate((x, 0, 3)) == 1 # hidden false assert Piecewise((1, x > 1), (2, x > x + 1), (3, True) ).integrate((x, 0, 3)) == 5 # targetcond is Eq assert Piecewise((1, x > 1), (2, Eq(1, x)), (3, True) ).integrate((x, 0, 4)) == 6 # And has Relational needing to be solved assert Piecewise((1, And(2*x > x + 1, x < 2)), (0, True) ).integrate((x, 0, 3)) == 1 # Or has Relational needing to be solved assert Piecewise((1, Or(2*x > x + 2, x < 1)), (0, True) ).integrate((x, 0, 3)) == 2 # ignore hidden false (handled in canonicalization) assert Piecewise((1, x > 1), (2, x > x + 1), (3, True) ).integrate((x, 0, 3)) == 5 # watch for hidden True Piecewise assert Piecewise((2, Eq(1 - x, x*(1/x - 1))), (0, True) ).integrate((x, 0, 3)) == 6 # overlapping conditions of targetcond are recognized and ignored; # the condition x > 3 will be pre-empted by the first condition assert Piecewise((1, Or(x < 1, x > 2)), (2, x > 3), (3, True) ).integrate((x, 0, 4)) == 6 # convert Ne to Or assert Piecewise((1, Ne(x, 0)), (2, True) ).integrate((x, -1, 1)) == 2 # no default but well defined assert Piecewise((x, (x > 1) & (x < 3)), (1, (x < 4)) ).integrate((x, 1, 4)) == 5 p = Piecewise((x, (x > 1) & (x < 3)), (1, (x < 4))) nan = Undefined i = p.integrate((x, 1, y)) assert i == Piecewise( (y - 1, y < 1), (Min(3, y)**2/2 - Min(3, y) + Min(4, y) - S(1)/2, y <= Min(4, y)), (nan, True)) assert p.integrate((x, 1, -1)) == i.subs(y, -1) assert p.integrate((x, 1, 4)) == 5 assert p.integrate((x, 1, 5)) == nan # handle Not p = Piecewise((1, x > 1), (2, Not(And(x > 1, x< 3))), (3, True)) assert p.integrate((x, 0, 3)) == 4 # handle updating of int_expr when there is overlap p = Piecewise( (1, And(5 > x, x > 1)), (2, Or(x < 3, x > 7)), (4, x < 8)) assert p.integrate((x, 0, 10)) == 20 # And with Eq arg handling assert Piecewise((1, x < 1), (2, And(Eq(x, 3), x > 1)) ).integrate((x, 0, 3)) == S.NaN assert Piecewise((1, x < 1), (2, And(Eq(x, 3), x > 1)), (3, True) ).integrate((x, 0, 3)) == 7 assert Piecewise((1, x < 0), (2, And(Eq(x, 3), x < 1)), (3, True) ).integrate((x, -1, 1)) == 4 # middle condition doesn't matter: it's a zero width interval assert Piecewise((1, x < 1), (2, Eq(x, 3) & (y < x)), (3, True) ).integrate((x, 0, 3)) == 7 def test_holes(): nan = Undefined assert Piecewise((1, x < 2)).integrate(x) == Piecewise( (x, x < 2), (nan, True)) assert Piecewise((1, And(x > 1, x < 2))).integrate(x) == Piecewise( (nan, x < 1), (x - 1, x < 2), (nan, True)) assert Piecewise((1, And(x > 1, x < 2))).integrate((x, 0, 3)) == nan assert Piecewise((1, And(x > 0, x < 4))).integrate((x, 1, 3)) == 2 # this also tests that the integrate method is used on non-Piecwise # arguments in _eval_integral A, B = symbols("A B") a, b = symbols('a b', finite=True) assert Piecewise((A, And(x < 0, a < 1)), (B, Or(x < 1, a > 2)) ).integrate(x) == Piecewise( (B*x, a > 2), (Piecewise((A*x, x < 0), (B*x, x < 1), (nan, True)), a < 1), (Piecewise((B*x, x < 1), (nan, True)), True)) def test_issue_11922(): def f(x): return Piecewise((0, x < -1), (1 - x**2, x < 1), (0, True)) autocorr = lambda k: ( f(x) * f(x + k)).integrate((x, -1, 1)) assert autocorr(1.9) > 0 k = symbols('k') good_autocorr = lambda k: ( (1 - x**2) * f(x + k)).integrate((x, -1, 1)) a = good_autocorr(k) assert a.subs(k, 3) == 0 k = symbols('k', positive=True) a = good_autocorr(k) assert a.subs(k, 3) == 0 assert Piecewise((0, x < 1), (10, (x >= 1)) ).integrate() == Piecewise((0, x < 1), (10*x - 10, True)) def test_issue_5227(): f = 0.0032513612725229*Piecewise((0, x < -80.8461538461539), (-0.0160799238820171*x + 1.33215984776403, x < 2), (Piecewise((0.3, x > 123), (0.7, True)) + Piecewise((0.4, x > 2), (0.6, True)), x <= 123), (-0.00817409766454352*x + 2.10541401273885, x < 380.571428571429), (0, True)) i = integrate(f, (x, -oo, oo)) assert i == Integral(f, (x, -oo, oo)).doit() assert str(i) == '1.00195081676351' assert Piecewise((1, x - y < 0), (0, True) ).integrate(y) == Piecewise((0, y <= x), (-x + y, True)) def test_issue_10137(): a = Symbol('a', real=True, finite=True) b = Symbol('b', real=True, finite=True) x = Symbol('x', real=True, finite=True) y = Symbol('y', real=True, finite=True) p0 = Piecewise((0, Or(x < a, x > b)), (1, True)) p1 = Piecewise((0, Or(a > x, b < x)), (1, True)) assert integrate(p0, (x, y, oo)) == integrate(p1, (x, y, oo)) p3 = Piecewise((1, And(0 < x, x < a)), (0, True)) p4 = Piecewise((1, And(a > x, x > 0)), (0, True)) ip3 = integrate(p3, x) assert ip3 == Piecewise( (0, x <= 0), (x, x <= Max(0, a)), (Max(0, a), True)) ip4 = integrate(p4, x) assert ip4 == ip3 assert p3.integrate((x, 2, 4)) == Min(4, Max(2, a)) - 2 assert p4.integrate((x, 2, 4)) == Min(4, Max(2, a)) - 2 def test_stackoverflow_43852159(): f = lambda x: Piecewise((1 , (x >= -1) & (x <= 1)) , (0, True)) Conv = lambda x: integrate(f(x - y)*f(y), (y, -oo, +oo)) cx = Conv(x) assert cx.subs(x, -1.5) == cx.subs(x, 1.5) assert cx.subs(x, 3) == 0 assert piecewise_fold(f(x - y)*f(y)) == Piecewise( (1, (y >= -1) & (y <= 1) & (x - y >= -1) & (x - y <= 1)), (0, True)) def test_issue_12557(): ''' # 3200 seconds to compute the fourier part of issue import sympy as sym x,y,z,t = sym.symbols('x y z t') k = sym.symbols("k", integer=True) fourier = sym.fourier_series(sym.cos(k*x)*sym.sqrt(x**2), (x, -sym.pi, sym.pi)) assert fourier == FourierSeries( sqrt(x**2)*cos(k*x), (x, -pi, pi), (Piecewise((pi**2, Eq(k, 0)), (2*(-1)**k/k**2 - 2/k**2, True))/(2*pi), SeqFormula(Piecewise((pi**2, (Eq(_n, 0) & Eq(k, 0)) | (Eq(_n, 0) & Eq(_n, k) & Eq(k, 0)) | (Eq(_n, 0) & Eq(k, 0) & Eq(_n, -k)) | (Eq(_n, 0) & Eq(_n, k) & Eq(k, 0) & Eq(_n, -k))), (pi**2/2, Eq(_n, k) | Eq(_n, -k) | (Eq(_n, 0) & Eq(_n, k)) | (Eq(_n, k) & Eq(k, 0)) | (Eq(_n, 0) & Eq(_n, -k)) | (Eq(_n, k) & Eq(_n, -k)) | (Eq(k, 0) & Eq(_n, -k)) | (Eq(_n, 0) & Eq(_n, k) & Eq(_n, -k)) | (Eq(_n, k) & Eq(k, 0) & Eq(_n, -k))), ((-1)**k*pi**2*_n**3*sin(pi*_n)/(pi*_n**4 - 2*pi*_n**2*k**2 + pi*k**4) - (-1)**k*pi**2*_n**3*sin(pi*_n)/(-pi*_n**4 + 2*pi*_n**2*k**2 - pi*k**4) + (-1)**k*pi*_n**2*cos(pi*_n)/(pi*_n**4 - 2*pi*_n**2*k**2 + pi*k**4) - (-1)**k*pi*_n**2*cos(pi*_n)/(-pi*_n**4 + 2*pi*_n**2*k**2 - pi*k**4) - (-1)**k*pi**2*_n*k**2*sin(pi*_n)/(pi*_n**4 - 2*pi*_n**2*k**2 + pi*k**4) + (-1)**k*pi**2*_n*k**2*sin(pi*_n)/(-pi*_n**4 + 2*pi*_n**2*k**2 - pi*k**4) + (-1)**k*pi*k**2*cos(pi*_n)/(pi*_n**4 - 2*pi*_n**2*k**2 + pi*k**4) - (-1)**k*pi*k**2*cos(pi*_n)/(-pi*_n**4 + 2*pi*_n**2*k**2 - pi*k**4) - (2*_n**2 + 2*k**2)/(_n**4 - 2*_n**2*k**2 + k**4), True))*cos(_n*x)/pi, (_n, 1, oo)), SeqFormula(0, (_k, 1, oo)))) ''' x = symbols("x", real=True) k = symbols('k', integer=True, finite=True) abs2 = lambda x: Piecewise((-x, x <= 0), (x, x > 0)) assert integrate(abs2(x), (x, -pi, pi)) == pi**2 func = cos(k*x)*sqrt(x**2) assert integrate(func, (x, -pi, pi)) == Piecewise( (2*(-1)**k/k**2 - 2/k**2, Ne(k, 0)), (pi**2, True)) def test_issue_6900(): from itertools import permutations t0, t1, T, t = symbols('t0, t1 T t') f = Piecewise((0, t < t0), (x, And(t0 <= t, t < t1)), (0, t >= t1)) g = f.integrate(t) assert g == Piecewise( (0, t <= t0), (t*x - t0*x, t <= Max(t0, t1)), (-t0*x + x*Max(t0, t1), True)) for i in permutations(range(2)): reps = dict(zip((t0,t1), i)) for tt in range(-1,3): assert (g.xreplace(reps).subs(t,tt) == f.xreplace(reps).integrate(t).subs(t,tt)) lim = Tuple(t, t0, T) g = f.integrate(lim) ans = Piecewise( (-t0*x + x*Min(T, Max(t0, t1)), T > t0), (0, True)) for i in permutations(range(3)): reps = dict(zip((t0,t1,T), i)) tru = f.xreplace(reps).integrate(lim.xreplace(reps)) assert tru == ans.xreplace(reps) assert g == ans def test_issue_10122(): assert solve(abs(x) + abs(x - 1) - 1 > 0, x ) == Or(And(-oo < x, x < 0), And(S.One < x, x < oo)) def test_issue_4313(): u = Piecewise((0, x <= 0), (1, x >= a), (x/a, True)) e = (u - u.subs(x, y))**2/(x - y)**2 M = Max(0, a) assert integrate(e, x).expand() == Piecewise( (Piecewise( (0, x <= 0), (-y**2/(a**2*x - a**2*y) + x/a**2 - 2*y*log(-y)/a**2 + 2*y*log(x - y)/a**2 - y/a**2, x <= M), (-y**2/(-a**2*y + a**2*M) + 1/(-y + M) - 1/(x - y) - 2*y*log(-y)/a**2 + 2*y*log(-y + M)/a**2 - y/a**2 + M/a**2, True)), ((a <= y) & (y <= 0)) | ((y <= 0) & (y > -oo))), (Piecewise( (-1/(x - y), x <= 0), (-a**2/(a**2*x - a**2*y) + 2*a*y/(a**2*x - a**2*y) - y**2/(a**2*x - a**2*y) + 2*log(-y)/a - 2*log(x - y)/a + 2/a + x/a**2 - 2*y*log(-y)/a**2 + 2*y*log(x - y)/a**2 - y/a**2, x <= M), (-a**2/(-a**2*y + a**2*M) + 2*a*y/(-a**2*y + a**2*M) - y**2/(-a**2*y + a**2*M) + 2*log(-y)/a - 2*log(-y + M)/a + 2/a - 2*y*log(-y)/a**2 + 2*y*log(-y + M)/a**2 - y/a**2 + M/a**2, True)), a <= y), (Piecewise( (-y**2/(a**2*x - a**2*y), x <= 0), (x/a**2 + y/a**2, x <= M), (a**2/(-a**2*y + a**2*M) - a**2/(a**2*x - a**2*y) - 2*a*y/(-a**2*y + a**2*M) + 2*a*y/(a**2*x - a**2*y) + y**2/(-a**2*y + a**2*M) - y**2/(a**2*x - a**2*y) + y/a**2 + M/a**2, True)), True)) def test__intervals(): assert Piecewise((x + 2, Eq(x, 3)))._intervals(x) == [] assert Piecewise( (1, x > x + 1), (Piecewise((1, x < x + 1)), 2*x < 2*x + 1), (1, True))._intervals(x) == [(-oo, oo, 1, 1)] assert Piecewise((1, Ne(x, I)), (0, True))._intervals(x) == [ (-oo, oo, 1, 0)] assert Piecewise((-cos(x), sin(x) >= 0), (cos(x), True) )._intervals(x) == [(0, pi, -cos(x), 0), (-oo, oo, cos(x), 1)] # the following tests that duplicates are removed and that non-Eq # generated zero-width intervals are removed assert Piecewise((1, Abs(x**(-2)) > 1), (0, True) )._intervals(x) == [(-1, 0, 1, 0), (0, 1, 1, 0), (-oo, oo, 0, 1)] def test_containment(): a, b, c, d, e = [1, 2, 3, 4, 5] p = (Piecewise((d, x > 1), (e, True))* Piecewise((a, Abs(x - 1) < 1), (b, Abs(x - 2) < 2), (c, True))) assert p.integrate(x).diff(x) == Piecewise( (c*e, x <= 0), (a*e, x <= 1), (a*d, x < 2), # this is what we want to get right (b*d, x < 4), (c*d, True)) def test_piecewise_with_DiracDelta(): d1 = DiracDelta(x - 1) assert integrate(d1, (x, -oo, oo)) == 1 assert integrate(d1, (x, 0, 2)) == 1 assert Piecewise((d1, Eq(x, 2)), (0, True)).integrate(x) == 0 assert Piecewise((d1, x < 2), (0, True)).integrate(x) == Piecewise( (Heaviside(x - 1), x < 2), (1, True)) # TODO raise error if function is discontinuous at limit of # integration, e.g. integrate(d1, (x, -2, 1)) or Piecewise( # (d1, Eq(x ,1) def test_issue_10258(): assert Piecewise((0, x < 1), (1, True)).is_zero is None assert Piecewise((-1, x < 1), (1, True)).is_zero is False a = Symbol('a', zero=True) assert Piecewise((0, x < 1), (a, True)).is_zero assert Piecewise((1, x < 1), (a, x < 3)).is_zero is None a = Symbol('a') assert Piecewise((0, x < 1), (a, True)).is_zero is None assert Piecewise((0, x < 1), (1, True)).is_nonzero is None assert Piecewise((1, x < 1), (2, True)).is_nonzero assert Piecewise((0, x < 1), (oo, True)).is_finite is None assert Piecewise((0, x < 1), (1, True)).is_finite b = Basic() assert Piecewise((b, x < 1)).is_finite is None # 10258 c = Piecewise((1, x < 0), (2, True)) < 3 assert c != True assert piecewise_fold(c) == True def test_issue_10087(): a, b = Piecewise((x, x > 1), (2, True)), Piecewise((x, x > 3), (3, True)) m = a*b f = piecewise_fold(m) for i in (0, 2, 4): assert m.subs(x, i) == f.subs(x, i) m = a + b f = piecewise_fold(m) for i in (0, 2, 4): assert m.subs(x, i) == f.subs(x, i) def test_issue_8919(): c = symbols('c:5') x = symbols("x") f1 = Piecewise((c[1], x < 1), (c[2], True)) f2 = Piecewise((c[3], x < S(1)/3), (c[4], True)) assert integrate(f1*f2, (x, 0, 2) ) == c[1]*c[3]/3 + 2*c[1]*c[4]/3 + c[2]*c[4] f1 = Piecewise((0, x < 1), (2, True)) f2 = Piecewise((3, x < 2), (0, True)) assert integrate(f1*f2, (x, 0, 3)) == 6 y = symbols("y", positive=True) a, b, c, x, z = symbols("a,b,c,x,z", real=True) I = Integral(Piecewise( (0, (x >= y) | (x < 0) | (b > c)), (a, True)), (x, 0, z)) ans = I.doit() assert ans == Piecewise((0, b > c), (a*Min(y, z) - a*Min(0, z), True)) for cond in (True, False): for yy in range(1, 3): for zz in range(-yy, 0, yy): reps = [(b > c, cond), (y, yy), (z, zz)] assert ans.subs(reps) == I.subs(reps).doit() def test_unevaluated_integrals(): f = Function('f') p = Piecewise((1, Eq(f(x) - 1, 0)), (2, x - 10 < 0), (0, True)) assert p.integrate(x) == Integral(p, x) assert p.integrate((x, 0, 5)) == Integral(p, (x, 0, 5)) # test it by replacing f(x) with x%2 which will not # affect the answer: the integrand is essentially 2 over # the domain of integration assert Integral(p, (x, 0, 5)).subs(f(x), x%2).n() == 10 # this is a test of using _solve_inequality when # solve_univariate_inequality fails assert p.integrate(y) == Piecewise( (y, Eq(f(x), 1) | ((x < 10) & Eq(f(x), 1))), (2*y, (x >= -oo) & (x < 10)), (0, True)) def test_conditions_as_alternate_booleans(): a, b, c = symbols('a:c') assert Piecewise((x, Piecewise((y < 1, x > 0), (y > 1, True))) ) == Piecewise((x, ITE(x > 0, y < 1, y > 1))) def test_Piecewise_rewrite_as_ITE(): a, b, c, d = symbols('a:d') def _ITE(*args): return Piecewise(*args).rewrite(ITE) assert _ITE((a, x < 1), (b, x >= 1)) == ITE(x < 1, a, b) assert _ITE((a, x < 1), (b, x < oo)) == ITE(x < 1, a, b) assert _ITE((a, x < 1), (b, Or(y < 1, x < oo)), (c, y > 0) ) == ITE(x < 1, a, b) assert _ITE((a, x < 1), (b, True)) == ITE(x < 1, a, b) assert _ITE((a, x < 1), (b, x < 2), (c, True) ) == ITE(x < 1, a, ITE(x < 2, b, c)) assert _ITE((a, x < 1), (b, y < 2), (c, True) ) == ITE(x < 1, a, ITE(y < 2, b, c)) assert _ITE((a, x < 1), (b, x < oo), (c, y < 1) ) == ITE(x < 1, a, b) assert _ITE((a, x < 1), (c, y < 1), (b, x < oo), (d, True) ) == ITE(x < 1, a, ITE(y < 1, c, b)) assert _ITE((a, x < 0), (b, Or(x < oo, y < 1)) ) == ITE(x < 0, a, b) raises(TypeError, lambda: _ITE((x + 1, x < 1), (x, True))) # if `a` in the following were replaced with y then the coverage # is complete but something other than as_set would need to be # used to detect this raises(NotImplementedError, lambda: _ITE((x, x < y), (y, x >= a))) raises(ValueError, lambda: _ITE((a, x < 2), (b, x > 3))) def test_issue_14052(): assert integrate(abs(sin(x)), (x, 0, 2*pi)) == 4 def test_issue_14240(): assert piecewise_fold( Piecewise((1, a), (2, b), (4, True)) + Piecewise((8, a), (16, True)) ) == Piecewise((9, a), (18, b), (20, True)) assert piecewise_fold( Piecewise((2, a), (3, b), (5, True)) * Piecewise((7, a), (11, True)) ) == Piecewise((14, a), (33, b), (55, True)) # these will hang if naive folding is used assert piecewise_fold(Add(*[ Piecewise((i, a), (0, True)) for i in range(40)]) ) == Piecewise((780, a), (0, True)) assert piecewise_fold(Mul(*[ Piecewise((i, a), (0, True)) for i in range(1, 41)]) ) == Piecewise((factorial(40), a), (0, True)) def test_issue_14787(): x = Symbol('x') f = Piecewise((x, x < 1), ((S(58) / 7), True)) assert str(f.evalf()) == "Piecewise((x, x < 1), (8.28571428571429, True))" def test_issue_8458(): x, y = symbols('x y') # Original issue p1 = Piecewise((0, Eq(x, 0)), (sin(x), True)) assert p1.simplify() == sin(x) # Slightly larger variant p2 = Piecewise((x, Eq(x, 0)), (4*x + (y-2)**4, Eq(x, 0) & Eq(x+y, 2)), (sin(x), True)) assert p2.simplify() == sin(x) # Test for problem highlighted during review p3 = Piecewise((x+1, Eq(x, -1)), (4*x + (y-2)**4, Eq(x, 0) & Eq(x+y, 2)), (sin(x), True)) assert p3.simplify() == Piecewise((0, Eq(x, -1)), (sin(x), True))
6b4ef07f121c8f2e67c5c2fa773fa45d4fcf80f8d697f7ce63ae74a4d11aea2b
import itertools as it from sympy.core.function import Function from sympy.core.numbers import I, oo, Rational from sympy.core.power import Pow from sympy.core.singleton import S from sympy.core.symbol import Symbol from sympy.functions.elementary.miscellaneous import (sqrt, cbrt, root, Min, Max, real_root) from sympy.functions.elementary.trigonometric import cos, sin from sympy.functions.elementary.exponential import log from sympy.functions.elementary.integers import floor, ceiling from sympy.functions.special.delta_functions import Heaviside from sympy.utilities.lambdify import lambdify from sympy.utilities.pytest import raises, skip, ignore_warnings from sympy.external import import_module def test_Min(): from sympy.abc import x, y, z n = Symbol('n', negative=True) n_ = Symbol('n_', negative=True) nn = Symbol('nn', nonnegative=True) nn_ = Symbol('nn_', nonnegative=True) p = Symbol('p', positive=True) p_ = Symbol('p_', positive=True) np = Symbol('np', nonpositive=True) np_ = Symbol('np_', nonpositive=True) r = Symbol('r', real=True) assert Min(5, 4) == 4 assert Min(-oo, -oo) == -oo assert Min(-oo, n) == -oo assert Min(n, -oo) == -oo assert Min(-oo, np) == -oo assert Min(np, -oo) == -oo assert Min(-oo, 0) == -oo assert Min(0, -oo) == -oo assert Min(-oo, nn) == -oo assert Min(nn, -oo) == -oo assert Min(-oo, p) == -oo assert Min(p, -oo) == -oo assert Min(-oo, oo) == -oo assert Min(oo, -oo) == -oo assert Min(n, n) == n assert Min(n, np) == Min(n, np) assert Min(np, n) == Min(np, n) assert Min(n, 0) == n assert Min(0, n) == n assert Min(n, nn) == n assert Min(nn, n) == n assert Min(n, p) == n assert Min(p, n) == n assert Min(n, oo) == n assert Min(oo, n) == n assert Min(np, np) == np assert Min(np, 0) == np assert Min(0, np) == np assert Min(np, nn) == np assert Min(nn, np) == np assert Min(np, p) == np assert Min(p, np) == np assert Min(np, oo) == np assert Min(oo, np) == np assert Min(0, 0) == 0 assert Min(0, nn) == 0 assert Min(nn, 0) == 0 assert Min(0, p) == 0 assert Min(p, 0) == 0 assert Min(0, oo) == 0 assert Min(oo, 0) == 0 assert Min(nn, nn) == nn assert Min(nn, p) == Min(nn, p) assert Min(p, nn) == Min(p, nn) assert Min(nn, oo) == nn assert Min(oo, nn) == nn assert Min(p, p) == p assert Min(p, oo) == p assert Min(oo, p) == p assert Min(oo, oo) == oo assert Min(n, n_).func is Min assert Min(nn, nn_).func is Min assert Min(np, np_).func is Min assert Min(p, p_).func is Min # lists assert Min() == S.Infinity assert Min(x) == x assert Min(x, y) == Min(y, x) assert Min(x, y, z) == Min(z, y, x) assert Min(x, Min(y, z)) == Min(z, y, x) assert Min(x, Max(y, -oo)) == Min(x, y) assert Min(p, oo, n, p, p, p_) == n assert Min(p_, n_, p) == n_ assert Min(n, oo, -7, p, p, 2) == Min(n, -7) assert Min(2, x, p, n, oo, n_, p, 2, -2, -2) == Min(-2, x, n, n_) assert Min(0, x, 1, y) == Min(0, x, y) assert Min(1000, 100, -100, x, p, n) == Min(n, x, -100) assert Min(cos(x), sin(x)) == Min(cos(x), sin(x)) assert Min(cos(x), sin(x)).subs(x, 1) == cos(1) assert Min(cos(x), sin(x)).subs(x, S(1)/2) == sin(S(1)/2) raises(ValueError, lambda: Min(cos(x), sin(x)).subs(x, I)) raises(ValueError, lambda: Min(I)) raises(ValueError, lambda: Min(I, x)) raises(ValueError, lambda: Min(S.ComplexInfinity, x)) assert Min(1, x).diff(x) == Heaviside(1 - x) assert Min(x, 1).diff(x) == Heaviside(1 - x) assert Min(0, -x, 1 - 2*x).diff(x) == -Heaviside(x + Min(0, -2*x + 1)) \ - 2*Heaviside(2*x + Min(0, -x) - 1) # issue 7619 f = Function('f') assert Min(1, 2*Min(f(1), 2)) # doesn't fail # issue 7233 e = Min(0, x) assert e.evalf == e.n assert e.n().args == (0, x) # issue 8643 m = Min(n, p_, n_, r) assert m.is_positive is False assert m.is_nonnegative is False assert m.is_negative is True m = Min(p, p_) assert m.is_positive is True assert m.is_nonnegative is True assert m.is_negative is False m = Min(p, nn_, p_) assert m.is_positive is None assert m.is_nonnegative is True assert m.is_negative is False m = Min(nn, p, r) assert m.is_positive is None assert m.is_nonnegative is None assert m.is_negative is None def test_Max(): from sympy.abc import x, y, z n = Symbol('n', negative=True) n_ = Symbol('n_', negative=True) nn = Symbol('nn', nonnegative=True) nn_ = Symbol('nn_', nonnegative=True) p = Symbol('p', positive=True) p_ = Symbol('p_', positive=True) np = Symbol('np', nonpositive=True) np_ = Symbol('np_', nonpositive=True) r = Symbol('r', real=True) assert Max(5, 4) == 5 # lists assert Max() == S.NegativeInfinity assert Max(x) == x assert Max(x, y) == Max(y, x) assert Max(x, y, z) == Max(z, y, x) assert Max(x, Max(y, z)) == Max(z, y, x) assert Max(x, Min(y, oo)) == Max(x, y) assert Max(n, -oo, n_, p, 2) == Max(p, 2) assert Max(n, -oo, n_, p) == p assert Max(2, x, p, n, -oo, S.NegativeInfinity, n_, p, 2) == Max(2, x, p) assert Max(0, x, 1, y) == Max(1, x, y) assert Max(r, r + 1, r - 1) == 1 + r assert Max(1000, 100, -100, x, p, n) == Max(p, x, 1000) assert Max(cos(x), sin(x)) == Max(sin(x), cos(x)) assert Max(cos(x), sin(x)).subs(x, 1) == sin(1) assert Max(cos(x), sin(x)).subs(x, S(1)/2) == cos(S(1)/2) raises(ValueError, lambda: Max(cos(x), sin(x)).subs(x, I)) raises(ValueError, lambda: Max(I)) raises(ValueError, lambda: Max(I, x)) raises(ValueError, lambda: Max(S.ComplexInfinity, 1)) assert Max(n, -oo, n_, p, 2) == Max(p, 2) assert Max(n, -oo, n_, p, 1000) == Max(p, 1000) assert Max(1, x).diff(x) == Heaviside(x - 1) assert Max(x, 1).diff(x) == Heaviside(x - 1) assert Max(x**2, 1 + x, 1).diff(x) == \ 2*x*Heaviside(x**2 - Max(1, x + 1)) \ + Heaviside(x - Max(1, x**2) + 1) e = Max(0, x) assert e.evalf == e.n assert e.n().args == (0, x) # issue 8643 m = Max(p, p_, n, r) assert m.is_positive is True assert m.is_nonnegative is True assert m.is_negative is False m = Max(n, n_) assert m.is_positive is False assert m.is_nonnegative is False assert m.is_negative is True m = Max(n, n_, r) assert m.is_positive is None assert m.is_nonnegative is None assert m.is_negative is None m = Max(n, nn, r) assert m.is_positive is None assert m.is_nonnegative is True assert m.is_negative is False def test_minmax_assumptions(): r = Symbol('r', real=True) a = Symbol('a', real=True, algebraic=True) t = Symbol('t', real=True, transcendental=True) q = Symbol('q', rational=True) p = Symbol('p', real=True, rational=False) n = Symbol('n', rational=True, integer=False) i = Symbol('i', integer=True) o = Symbol('o', odd=True) e = Symbol('e', even=True) k = Symbol('k', prime=True) reals = [r, a, t, q, p, n, i, o, e, k] for ext in (Max, Min): for x, y in it.product(reals, repeat=2): # Must be real assert ext(x, y).is_real # Algebraic? if x.is_algebraic and y.is_algebraic: assert ext(x, y).is_algebraic elif x.is_transcendental and y.is_transcendental: assert ext(x, y).is_transcendental else: assert ext(x, y).is_algebraic is None # Rational? if x.is_rational and y.is_rational: assert ext(x, y).is_rational elif x.is_irrational and y.is_irrational: assert ext(x, y).is_irrational else: assert ext(x, y).is_rational is None # Integer? if x.is_integer and y.is_integer: assert ext(x, y).is_integer elif x.is_noninteger and y.is_noninteger: assert ext(x, y).is_noninteger else: assert ext(x, y).is_integer is None # Odd? if x.is_odd and y.is_odd: assert ext(x, y).is_odd elif x.is_odd is False and y.is_odd is False: assert ext(x, y).is_odd is False else: assert ext(x, y).is_odd is None # Even? if x.is_even and y.is_even: assert ext(x, y).is_even elif x.is_even is False and y.is_even is False: assert ext(x, y).is_even is False else: assert ext(x, y).is_even is None # Prime? if x.is_prime and y.is_prime: assert ext(x, y).is_prime elif x.is_prime is False and y.is_prime is False: assert ext(x, y).is_prime is False else: assert ext(x, y).is_prime is None def test_issue_8413(): x = Symbol('x', real=True) # we can't evaluate in general because non-reals are not # comparable: Min(floor(3.2 + I), 3.2 + I) -> ValueError assert Min(floor(x), x) == floor(x) assert Min(ceiling(x), x) == x assert Max(floor(x), x) == x assert Max(ceiling(x), x) == ceiling(x) def test_root(): from sympy.abc import x n = Symbol('n', integer=True) k = Symbol('k', integer=True) assert root(2, 2) == sqrt(2) assert root(2, 1) == 2 assert root(2, 3) == 2**Rational(1, 3) assert root(2, 3) == cbrt(2) assert root(2, -5) == 2**Rational(4, 5)/2 assert root(-2, 1) == -2 assert root(-2, 2) == sqrt(2)*I assert root(-2, 1) == -2 assert root(x, 2) == sqrt(x) assert root(x, 1) == x assert root(x, 3) == x**Rational(1, 3) assert root(x, 3) == cbrt(x) assert root(x, -5) == x**Rational(-1, 5) assert root(x, n) == x**(1/n) assert root(x, -n) == x**(-1/n) assert root(x, n, k) == (-1)**(2*k/n)*x**(1/n) def test_real_root(): assert real_root(-8, 3) == -2 assert real_root(-16, 4) == root(-16, 4) r = root(-7, 4) assert real_root(r) == r r1 = root(-1, 3) r2 = r1**2 r3 = root(-1, 4) assert real_root(r1 + r2 + r3) == -1 + r2 + r3 assert real_root(root(-2, 3)) == -root(2, 3) assert real_root(-8., 3) == -2 x = Symbol('x') n = Symbol('n') g = real_root(x, n) assert g.subs(dict(x=-8, n=3)) == -2 assert g.subs(dict(x=8, n=3)) == 2 # give principle root if there is no real root -- if this is not desired # then maybe a Root class is needed to raise an error instead assert g.subs(dict(x=I, n=3)) == cbrt(I) assert g.subs(dict(x=-8, n=2)) == sqrt(-8) assert g.subs(dict(x=I, n=2)) == sqrt(I) def test_issue_11463(): numpy = import_module('numpy') if not numpy: skip("numpy not installed.") x = Symbol('x') f = lambdify(x, real_root((log(x/(x-2))), 3), 'numpy') # numpy.select evaluates all options before considering conditions, # so it raises a warning about root of negative number which does # not affect the outcome. This warning is suppressed here with ignore_warnings(RuntimeWarning): assert f(numpy.array(-1)) < -1 def test_rewrite_MaxMin_as_Heaviside(): from sympy.abc import x assert Max(0, x).rewrite(Heaviside) == x*Heaviside(x) assert Max(3, x).rewrite(Heaviside) == x*Heaviside(x - 3) + \ 3*Heaviside(-x + 3) assert Max(0, x+2, 2*x).rewrite(Heaviside) == \ 2*x*Heaviside(2*x)*Heaviside(x - 2) + \ (x + 2)*Heaviside(-x + 2)*Heaviside(x + 2) assert Min(0, x).rewrite(Heaviside) == x*Heaviside(-x) assert Min(3, x).rewrite(Heaviside) == x*Heaviside(-x + 3) + \ 3*Heaviside(x - 3) assert Min(x, -x, -2).rewrite(Heaviside) == \ x*Heaviside(-2*x)*Heaviside(-x - 2) - \ x*Heaviside(2*x)*Heaviside(x - 2) \ - 2*Heaviside(-x + 2)*Heaviside(x + 2) def test_rewrite_MaxMin_as_Piecewise(): from sympy import symbols, Piecewise x, y, z, a, b = symbols('x y z a b', real=True) vx, vy, va = symbols('vx vy va') assert Max(a, b).rewrite(Piecewise) == Piecewise((a, a >= b), (b, True)) assert Max(x, y, z).rewrite(Piecewise) == Piecewise((x, (x >= y) & (x >= z)), (y, y >= z), (z, True)) assert Max(x, y, a, b).rewrite(Piecewise) == Piecewise((a, (a >= b) & (a >= x) & (a >= y)), (b, (b >= x) & (b >= y)), (x, x >= y), (y, True)) assert Min(a, b).rewrite(Piecewise) == Piecewise((a, a <= b), (b, True)) assert Min(x, y, z).rewrite(Piecewise) == Piecewise((x, (x <= y) & (x <= z)), (y, y <= z), (z, True)) assert Min(x, y, a, b).rewrite(Piecewise) == Piecewise((a, (a <= b) & (a <= x) & (a <= y)), (b, (b <= x) & (b <= y)), (x, x <= y), (y, True)) # Piecewise rewriting of Min/Max does also takes place for not explicitly real arguments assert Max(vx, vy).rewrite(Piecewise) == Piecewise((vx, vx >= vy), (vy, True)) assert Min(va, vx, vy).rewrite(Piecewise) == Piecewise((va, (va <= vx) & (va <= vy)), (vx, vx <= vy), (vy, True)) def test_issue_11099(): from sympy.abc import x, y # some fixed value tests fixed_test_data = {x: -2, y: 3} assert Min(x, y).evalf(subs=fixed_test_data) == \ Min(x, y).subs(fixed_test_data).evalf() assert Max(x, y).evalf(subs=fixed_test_data) == \ Max(x, y).subs(fixed_test_data).evalf() # randomly generate some test data from random import randint for i in range(20): random_test_data = {x: randint(-100, 100), y: randint(-100, 100)} assert Min(x, y).evalf(subs=random_test_data) == \ Min(x, y).subs(random_test_data).evalf() assert Max(x, y).evalf(subs=random_test_data) == \ Max(x, y).subs(random_test_data).evalf() def test_issue_12638(): from sympy.abc import a, b, c, d assert Min(a, b, c, Max(a, b)) == Min(a, b, c) assert Min(a, b, Max(a, b, c)) == Min(a, b) assert Min(a, b, Max(a, c)) == Min(a, b) def test_instantiation_evaluation(): from sympy.abc import v, w, x, y, z assert Min(1, Max(2, x)) == 1 assert Max(3, Min(2, x)) == 3 assert Min(Max(x, y), Max(x, z)) == Max(x, Min(y, z)) assert set(Min(Max(w, x), Max(y, z)).args) == set( [Max(w, x), Max(y, z)]) assert Min(Max(x, y), Max(x, z), w) == Min( w, Max(x, Min(y, z))) A, B = Min, Max for i in range(2): assert A(x, B(x, y)) == x assert A(x, B(y, A(x, w, z))) == A(x, B(y, A(w, z))) A, B = B, A assert Min(w, Max(x, y), Max(v, x, z)) == Min( w, Max(x, Min(y, Max(v, z)))) def test_rewrite_as_Abs(): from itertools import permutations from sympy.functions.elementary.complexes import Abs from sympy.abc import x, y, z, w def test(e): free = e.free_symbols a = e.rewrite(Abs) assert not a.has(Min, Max) for i in permutations(range(len(free))): reps = dict(zip(free, i)) assert a.xreplace(reps) == e.xreplace(reps) test(Min(x, y)) test(Max(x, y)) test(Min(x, y, z)) test(Min(Max(w, x), Max(y, z))) def test_issue_14000(): assert isinstance(sqrt(4, evaluate=False), Pow) == True assert isinstance(cbrt(3.5, evaluate=False), Pow) == True assert isinstance(root(16, 4, evaluate=False), Pow) == True assert sqrt(4, evaluate=False) == Pow(4, S.Half, evaluate=False) assert cbrt(3.5, evaluate=False) == Pow(3.5, Rational(1, 3), evaluate=False) assert root(4, 2, evaluate=False) == Pow(4, Rational(1, 2), evaluate=False) assert root(16, 4, 2, evaluate=False).has(Pow) == True assert real_root(-8, 3, evaluate=False).has(Pow) == True
6421836dc0f995ee4a87199a7d88f497de8e33ee05b83b120d48c7c36f42a871
from sympy.core.containers import Tuple from sympy.core.function import (Function, Lambda, nfloat) from sympy.core.mod import Mod from sympy.core.numbers import (E, I, Rational, oo, pi) from sympy.core.relational import (Eq, Gt, Ne) from sympy.core.singleton import S from sympy.core.symbol import (Dummy, Symbol, symbols) from sympy.functions.elementary.complexes import (Abs, arg, im, re, sign) from sympy.functions.elementary.exponential import (LambertW, exp, log) from sympy.functions.elementary.hyperbolic import (HyperbolicFunction, atanh, sinh, tanh) from sympy.functions.elementary.miscellaneous import sqrt, Min, Max from sympy.functions.elementary.piecewise import Piecewise from sympy.functions.elementary.trigonometric import ( TrigonometricFunction, acos, acot, acsc, asec, asin, atan, atan2, cos, cot, csc, sec, sin, tan) from sympy.functions.special.error_functions import (erf, erfc, erfcinv, erfinv) from sympy.logic.boolalg import And from sympy.matrices.dense import MutableDenseMatrix as Matrix from sympy.polys.polytools import Poly from sympy.polys.rootoftools import CRootOf from sympy.sets.contains import Contains from sympy.sets.conditionset import ConditionSet from sympy.sets.fancysets import ImageSet from sympy.sets.sets import (Complement, EmptySet, FiniteSet, Intersection, Interval, Union, imageset) from sympy.tensor.indexed import Indexed from sympy.utilities.iterables import numbered_symbols from sympy.utilities.pytest import XFAIL, raises, skip, slow, SKIP from sympy.utilities.randtest import verify_numerically as tn from sympy.physics.units import cm from sympy.core.containers import Dict from sympy.solvers.solveset import ( solveset_real, domain_check, solveset_complex, linear_eq_to_matrix, linsolve, _is_function_class_equation, invert_real, invert_complex, solveset, solve_decomposition, substitution, nonlinsolve, solvify, _is_finite_with_finite_vars, _transolve, _is_exponential, _solve_exponential, _is_logarithmic, _solve_logarithm, _term_factors) a = Symbol('a', real=True) b = Symbol('b', real=True) c = Symbol('c', real=True) x = Symbol('x', real=True) y = Symbol('y', real=True) z = Symbol('z', real=True) q = Symbol('q', real=True) m = Symbol('m', real=True) n = Symbol('n', real=True) def test_invert_real(): x = Symbol('x', real=True) y = Symbol('y') n = Symbol('n') def ireal(x, s=S.Reals): return Intersection(s, x) # issue 14223 assert invert_real(x, 0, x, Interval(1, 2)) == (x, S.EmptySet) assert invert_real(exp(x), y, x) == (x, ireal(FiniteSet(log(y)))) y = Symbol('y', positive=True) n = Symbol('n', real=True) assert invert_real(x + 3, y, x) == (x, FiniteSet(y - 3)) assert invert_real(x*3, y, x) == (x, FiniteSet(y / 3)) assert invert_real(exp(x), y, x) == (x, FiniteSet(log(y))) assert invert_real(exp(3*x), y, x) == (x, FiniteSet(log(y) / 3)) assert invert_real(exp(x + 3), y, x) == (x, FiniteSet(log(y) - 3)) assert invert_real(exp(x) + 3, y, x) == (x, ireal(FiniteSet(log(y - 3)))) assert invert_real(exp(x)*3, y, x) == (x, FiniteSet(log(y / 3))) assert invert_real(log(x), y, x) == (x, FiniteSet(exp(y))) assert invert_real(log(3*x), y, x) == (x, FiniteSet(exp(y) / 3)) assert invert_real(log(x + 3), y, x) == (x, FiniteSet(exp(y) - 3)) assert invert_real(Abs(x), y, x) == (x, FiniteSet(y, -y)) assert invert_real(2**x, y, x) == (x, FiniteSet(log(y)/log(2))) assert invert_real(2**exp(x), y, x) == (x, ireal(FiniteSet(log(log(y)/log(2))))) assert invert_real(x**2, y, x) == (x, FiniteSet(sqrt(y), -sqrt(y))) assert invert_real(x**Rational(1, 2), y, x) == (x, FiniteSet(y**2)) raises(ValueError, lambda: invert_real(x, x, x)) raises(ValueError, lambda: invert_real(x**pi, y, x)) raises(ValueError, lambda: invert_real(S.One, y, x)) assert invert_real(x**31 + x, y, x) == (x**31 + x, FiniteSet(y)) lhs = x**31 + x conditions = Contains(y, Interval(0, oo), evaluate=False) base_values = FiniteSet(y - 1, -y - 1) assert invert_real(Abs(x**31 + x + 1), y, x) == (lhs, base_values) assert invert_real(sin(x), y, x) == \ (x, imageset(Lambda(n, n*pi + (-1)**n*asin(y)), S.Integers)) assert invert_real(sin(exp(x)), y, x) == \ (x, imageset(Lambda(n, log((-1)**n*asin(y) + n*pi)), S.Integers)) assert invert_real(csc(x), y, x) == \ (x, imageset(Lambda(n, n*pi + (-1)**n*acsc(y)), S.Integers)) assert invert_real(csc(exp(x)), y, x) == \ (x, imageset(Lambda(n, log((-1)**n*acsc(y) + n*pi)), S.Integers)) assert invert_real(cos(x), y, x) == \ (x, Union(imageset(Lambda(n, 2*n*pi + acos(y)), S.Integers), \ imageset(Lambda(n, 2*n*pi - acos(y)), S.Integers))) assert invert_real(cos(exp(x)), y, x) == \ (x, Union(imageset(Lambda(n, log(2*n*pi + Mod(acos(y), 2*pi))), S.Integers), \ imageset(Lambda(n, log(2*n*pi + Mod(-acos(y), 2*pi))), S.Integers))) assert invert_real(sec(x), y, x) == \ (x, Union(imageset(Lambda(n, 2*n*pi + asec(y)), S.Integers), \ imageset(Lambda(n, 2*n*pi - asec(y)), S.Integers))) assert invert_real(sec(exp(x)), y, x) == \ (x, Union(imageset(Lambda(n, log(2*n*pi + Mod(asec(y), 2*pi))), S.Integers), \ imageset(Lambda(n, log(2*n*pi + Mod(-asec(y), 2*pi))), S.Integers))) assert invert_real(tan(x), y, x) == \ (x, imageset(Lambda(n, n*pi + atan(y) % pi), S.Integers)) assert invert_real(tan(exp(x)), y, x) == \ (x, imageset(Lambda(n, log(n*pi + atan(y) % pi)), S.Integers)) assert invert_real(cot(x), y, x) == \ (x, imageset(Lambda(n, n*pi + acot(y) % pi), S.Integers)) assert invert_real(cot(exp(x)), y, x) == \ (x, imageset(Lambda(n, log(n*pi + acot(y) % pi)), S.Integers)) assert invert_real(tan(tan(x)), y, x) == \ (tan(x), imageset(Lambda(n, n*pi + atan(y) % pi), S.Integers)) x = Symbol('x', positive=True) assert invert_real(x**pi, y, x) == (x, FiniteSet(y**(1/pi))) def test_invert_complex(): assert invert_complex(x + 3, y, x) == (x, FiniteSet(y - 3)) assert invert_complex(x*3, y, x) == (x, FiniteSet(y / 3)) assert invert_complex(exp(x), y, x) == \ (x, imageset(Lambda(n, I*(2*pi*n + arg(y)) + log(Abs(y))), S.Integers)) assert invert_complex(log(x), y, x) == (x, FiniteSet(exp(y))) raises(ValueError, lambda: invert_real(1, y, x)) raises(ValueError, lambda: invert_complex(x, x, x)) raises(ValueError, lambda: invert_complex(x, x, 1)) # https://github.com/skirpichev/omg/issues/16 assert invert_complex(sinh(x), 0, x) != (x, FiniteSet(0)) def test_domain_check(): assert domain_check(1/(1 + (1/(x+1))**2), x, -1) is False assert domain_check(x**2, x, 0) is True assert domain_check(x, x, oo) is False assert domain_check(0, x, oo) is False def test_issue_11536(): assert solveset(0**x - 100, x, S.Reals) == S.EmptySet assert solveset(0**x - 1, x, S.Reals) == FiniteSet(0) def test_is_function_class_equation(): from sympy.abc import x, a assert _is_function_class_equation(TrigonometricFunction, tan(x), x) is True assert _is_function_class_equation(TrigonometricFunction, tan(x) - 1, x) is True assert _is_function_class_equation(TrigonometricFunction, tan(x) + sin(x), x) is True assert _is_function_class_equation(TrigonometricFunction, tan(x) + sin(x) - a, x) is True assert _is_function_class_equation(TrigonometricFunction, sin(x)*tan(x) + sin(x), x) is True assert _is_function_class_equation(TrigonometricFunction, sin(x)*tan(x + a) + sin(x), x) is True assert _is_function_class_equation(TrigonometricFunction, sin(x)*tan(x*a) + sin(x), x) is True assert _is_function_class_equation(TrigonometricFunction, a*tan(x) - 1, x) is True assert _is_function_class_equation(TrigonometricFunction, tan(x)**2 + sin(x) - 1, x) is True assert _is_function_class_equation(TrigonometricFunction, tan(x) + x, x) is False assert _is_function_class_equation(TrigonometricFunction, tan(x**2), x) is False assert _is_function_class_equation(TrigonometricFunction, tan(x**2) + sin(x), x) is False assert _is_function_class_equation(TrigonometricFunction, tan(x)**sin(x), x) is False assert _is_function_class_equation(TrigonometricFunction, tan(sin(x)) + sin(x), x) is False assert _is_function_class_equation(HyperbolicFunction, tanh(x), x) is True assert _is_function_class_equation(HyperbolicFunction, tanh(x) - 1, x) is True assert _is_function_class_equation(HyperbolicFunction, tanh(x) + sinh(x), x) is True assert _is_function_class_equation(HyperbolicFunction, tanh(x) + sinh(x) - a, x) is True assert _is_function_class_equation(HyperbolicFunction, sinh(x)*tanh(x) + sinh(x), x) is True assert _is_function_class_equation(HyperbolicFunction, sinh(x)*tanh(x + a) + sinh(x), x) is True assert _is_function_class_equation(HyperbolicFunction, sinh(x)*tanh(x*a) + sinh(x), x) is True assert _is_function_class_equation(HyperbolicFunction, a*tanh(x) - 1, x) is True assert _is_function_class_equation(HyperbolicFunction, tanh(x)**2 + sinh(x) - 1, x) is True assert _is_function_class_equation(HyperbolicFunction, tanh(x) + x, x) is False assert _is_function_class_equation(HyperbolicFunction, tanh(x**2), x) is False assert _is_function_class_equation(HyperbolicFunction, tanh(x**2) + sinh(x), x) is False assert _is_function_class_equation(HyperbolicFunction, tanh(x)**sinh(x), x) is False assert _is_function_class_equation(HyperbolicFunction, tanh(sinh(x)) + sinh(x), x) is False def test_garbage_input(): raises(ValueError, lambda: solveset_real([x], x)) assert solveset_real(x, 1) == S.EmptySet assert solveset_real(x - 1, 1) == FiniteSet(x) assert solveset_real(x, pi) == S.EmptySet assert solveset_real(x, x**2) == S.EmptySet raises(ValueError, lambda: solveset_complex([x], x)) assert solveset_complex(x, pi) == S.EmptySet raises(ValueError, lambda: solveset((x, y), x)) raises(ValueError, lambda: solveset(x + 1, S.Reals)) raises(ValueError, lambda: solveset(x + 1, x, 2)) def test_solve_mul(): assert solveset_real((a*x + b)*(exp(x) - 3), x) == \ FiniteSet(-b/a, log(3)) assert solveset_real((2*x + 8)*(8 + exp(x)), x) == FiniteSet(S(-4)) assert solveset_real(x/log(x), x) == EmptySet() def test_solve_invert(): assert solveset_real(exp(x) - 3, x) == FiniteSet(log(3)) assert solveset_real(log(x) - 3, x) == FiniteSet(exp(3)) assert solveset_real(3**(x + 2), x) == FiniteSet() assert solveset_real(3**(2 - x), x) == FiniteSet() assert solveset_real(y - b*exp(a/x), x) == Intersection( S.Reals, FiniteSet(a/log(y/b))) # issue 4504 assert solveset_real(2**x - 10, x) == FiniteSet(1 + log(5)/log(2)) def test_errorinverses(): assert solveset_real(erf(x) - S.One/2, x) == \ FiniteSet(erfinv(S.One/2)) assert solveset_real(erfinv(x) - 2, x) == \ FiniteSet(erf(2)) assert solveset_real(erfc(x) - S.One, x) == \ FiniteSet(erfcinv(S.One)) assert solveset_real(erfcinv(x) - 2, x) == FiniteSet(erfc(2)) def test_solve_polynomial(): assert solveset_real(3*x - 2, x) == FiniteSet(Rational(2, 3)) assert solveset_real(x**2 - 1, x) == FiniteSet(-S(1), S(1)) assert solveset_real(x - y**3, x) == FiniteSet(y ** 3) a11, a12, a21, a22, b1, b2 = symbols('a11, a12, a21, a22, b1, b2') assert solveset_real(x**3 - 15*x - 4, x) == FiniteSet( -2 + 3 ** Rational(1, 2), S(4), -2 - 3 ** Rational(1, 2)) assert solveset_real(sqrt(x) - 1, x) == FiniteSet(1) assert solveset_real(sqrt(x) - 2, x) == FiniteSet(4) assert solveset_real(x**Rational(1, 4) - 2, x) == FiniteSet(16) assert solveset_real(x**Rational(1, 3) - 3, x) == FiniteSet(27) assert len(solveset_real(x**5 + x**3 + 1, x)) == 1 assert len(solveset_real(-2*x**3 + 4*x**2 - 2*x + 6, x)) > 0 assert solveset_real(x**6 + x**4 + I, x) == ConditionSet(x, Eq(x**6 + x**4 + I, 0), S.Reals) def test_return_root_of(): f = x**5 - 15*x**3 - 5*x**2 + 10*x + 20 s = list(solveset_complex(f, x)) for root in s: assert root.func == CRootOf # if one uses solve to get the roots of a polynomial that has a CRootOf # solution, make sure that the use of nfloat during the solve process # doesn't fail. Note: if you want numerical solutions to a polynomial # it is *much* faster to use nroots to get them than to solve the # equation only to get CRootOf solutions which are then numerically # evaluated. So for eq = x**5 + 3*x + 7 do Poly(eq).nroots() rather # than [i.n() for i in solve(eq)] to get the numerical roots of eq. assert nfloat(list(solveset_complex(x**5 + 3*x**3 + 7, x))[0], exponent=False) == CRootOf(x**5 + 3*x**3 + 7, 0).n() sol = list(solveset_complex(x**6 - 2*x + 2, x)) assert all(isinstance(i, CRootOf) for i in sol) and len(sol) == 6 f = x**5 - 15*x**3 - 5*x**2 + 10*x + 20 s = list(solveset_complex(f, x)) for root in s: assert root.func == CRootOf s = x**5 + 4*x**3 + 3*x**2 + S(7)/4 assert solveset_complex(s, x) == \ FiniteSet(*Poly(s*4, domain='ZZ').all_roots()) # Refer issue #7876 eq = x*(x - 1)**2*(x + 1)*(x**6 - x + 1) assert solveset_complex(eq, x) == \ FiniteSet(-1, 0, 1, CRootOf(x**6 - x + 1, 0), CRootOf(x**6 - x + 1, 1), CRootOf(x**6 - x + 1, 2), CRootOf(x**6 - x + 1, 3), CRootOf(x**6 - x + 1, 4), CRootOf(x**6 - x + 1, 5)) def test__has_rational_power(): from sympy.solvers.solveset import _has_rational_power assert _has_rational_power(sqrt(2), x)[0] is False assert _has_rational_power(x*sqrt(2), x)[0] is False assert _has_rational_power(x**2*sqrt(x), x) == (True, 2) assert _has_rational_power(sqrt(2)*x**(S(1)/3), x) == (True, 3) assert _has_rational_power(sqrt(x)*x**(S(1)/3), x) == (True, 6) def test_solveset_sqrt_1(): assert solveset_real(sqrt(5*x + 6) - 2 - x, x) == \ FiniteSet(-S(1), S(2)) assert solveset_real(sqrt(x - 1) - x + 7, x) == FiniteSet(10) assert solveset_real(sqrt(x - 2) - 5, x) == FiniteSet(27) assert solveset_real(sqrt(x) - 2 - 5, x) == FiniteSet(49) assert solveset_real(sqrt(x**3), x) == FiniteSet(0) assert solveset_real(sqrt(x - 1), x) == FiniteSet(1) def test_solveset_sqrt_2(): # http://tutorial.math.lamar.edu/Classes/Alg/SolveRadicalEqns.aspx#Solve_Rad_Ex2_a assert solveset_real(sqrt(2*x - 1) - sqrt(x - 4) - 2, x) == \ FiniteSet(S(5), S(13)) assert solveset_real(sqrt(x + 7) + 2 - sqrt(3 - x), x) == \ FiniteSet(-6) # http://www.purplemath.com/modules/solverad.htm assert solveset_real(sqrt(17*x - sqrt(x**2 - 5)) - 7, x) == \ FiniteSet(3) eq = x + 1 - (x**4 + 4*x**3 - x)**Rational(1, 4) assert solveset_real(eq, x) == FiniteSet(-S(1)/2, -S(1)/3) eq = sqrt(2*x + 9) - sqrt(x + 1) - sqrt(x + 4) assert solveset_real(eq, x) == FiniteSet(0) eq = sqrt(x + 4) + sqrt(2*x - 1) - 3*sqrt(x - 1) assert solveset_real(eq, x) == FiniteSet(5) eq = sqrt(x)*sqrt(x - 7) - 12 assert solveset_real(eq, x) == FiniteSet(16) eq = sqrt(x - 3) + sqrt(x) - 3 assert solveset_real(eq, x) == FiniteSet(4) eq = sqrt(2*x**2 - 7) - (3 - x) assert solveset_real(eq, x) == FiniteSet(-S(8), S(2)) # others eq = sqrt(9*x**2 + 4) - (3*x + 2) assert solveset_real(eq, x) == FiniteSet(0) assert solveset_real(sqrt(x - 3) - sqrt(x) - 3, x) == FiniteSet() eq = (2*x - 5)**Rational(1, 3) - 3 assert solveset_real(eq, x) == FiniteSet(16) assert solveset_real(sqrt(x) + sqrt(sqrt(x)) - 4, x) == \ FiniteSet((-S.Half + sqrt(17)/2)**4) eq = sqrt(x) - sqrt(x - 1) + sqrt(sqrt(x)) assert solveset_real(eq, x) == FiniteSet() eq = (sqrt(x) + sqrt(x + 1) + sqrt(1 - x) - 6*sqrt(5)/5) ans = solveset_real(eq, x) ra = S('''-1484/375 - 4*(-1/2 + sqrt(3)*I/2)*(-12459439/52734375 + 114*sqrt(12657)/78125)**(1/3) - 172564/(140625*(-1/2 + sqrt(3)*I/2)*(-12459439/52734375 + 114*sqrt(12657)/78125)**(1/3))''') rb = S(4)/5 assert all(abs(eq.subs(x, i).n()) < 1e-10 for i in (ra, rb)) and \ len(ans) == 2 and \ set([i.n(chop=True) for i in ans]) == \ set([i.n(chop=True) for i in (ra, rb)]) assert solveset_real(sqrt(x) + x**Rational(1, 3) + x**Rational(1, 4), x) == FiniteSet(0) assert solveset_real(x/sqrt(x**2 + 1), x) == FiniteSet(0) eq = (x - y**3)/((y**2)*sqrt(1 - y**2)) assert solveset_real(eq, x) == FiniteSet(y**3) # issue 4497 assert solveset_real(1/(5 + x)**(S(1)/5) - 9, x) == \ FiniteSet(-295244/S(59049)) @XFAIL def test_solve_sqrt_fail(): # this only works if we check real_root(eq.subs(x, S(1)/3)) # but checksol doesn't work like that eq = (x**3 - 3*x**2)**Rational(1, 3) + 1 - x assert solveset_real(eq, x) == FiniteSet(S(1)/3) @slow def test_solve_sqrt_3(): R = Symbol('R') eq = sqrt(2)*R*sqrt(1/(R + 1)) + (R + 1)*(sqrt(2)*sqrt(1/(R + 1)) - 1) sol = solveset_complex(eq, R) fset = [S(5)/3 + 4*sqrt(10)*cos(atan(3*sqrt(111)/251)/3)/3, -sqrt(10)*cos(atan(3*sqrt(111)/251)/3)/3 + 40*re(1/((-S(1)/2 - sqrt(3)*I/2)*(S(251)/27 + sqrt(111)*I/9)**(S(1)/3)))/9 + sqrt(30)*sin(atan(3*sqrt(111)/251)/3)/3 + S(5)/3 + I*(-sqrt(30)*cos(atan(3*sqrt(111)/251)/3)/3 - sqrt(10)*sin(atan(3*sqrt(111)/251)/3)/3 + 40*im(1/((-S(1)/2 - sqrt(3)*I/2)*(S(251)/27 + sqrt(111)*I/9)**(S(1)/3)))/9)] cset = [40*re(1/((-S(1)/2 + sqrt(3)*I/2)*(S(251)/27 + sqrt(111)*I/9)**(S(1)/3)))/9 - sqrt(10)*cos(atan(3*sqrt(111)/251)/3)/3 - sqrt(30)*sin(atan(3*sqrt(111)/251)/3)/3 + S(5)/3 + I*(40*im(1/((-S(1)/2 + sqrt(3)*I/2)*(S(251)/27 + sqrt(111)*I/9)**(S(1)/3)))/9 - sqrt(10)*sin(atan(3*sqrt(111)/251)/3)/3 + sqrt(30)*cos(atan(3*sqrt(111)/251)/3)/3)] assert sol._args[0] == FiniteSet(*fset) assert sol._args[1] == ConditionSet( R, Eq(sqrt(2)*R*sqrt(1/(R + 1)) + (R + 1)*(sqrt(2)*sqrt(1/(R + 1)) - 1), 0), FiniteSet(*cset)) # the number of real roots will depend on the value of m: for m=1 there are 4 # and for m=-1 there are none. eq = -sqrt((m - q)**2 + (-m/(2*q) + S(1)/2)**2) + sqrt((-m**2/2 - sqrt( 4*m**4 - 4*m**2 + 8*m + 1)/4 - S(1)/4)**2 + (m**2/2 - m - sqrt( 4*m**4 - 4*m**2 + 8*m + 1)/4 - S(1)/4)**2) unsolved_object = ConditionSet(q, Eq(sqrt((m - q)**2 + (-m/(2*q) + S(1)/2)**2) - sqrt((-m**2/2 - sqrt(4*m**4 - 4*m**2 + 8*m + 1)/4 - S(1)/4)**2 + (m**2/2 - m - sqrt(4*m**4 - 4*m**2 + 8*m + 1)/4 - S(1)/4)**2), 0), S.Reals) assert solveset_real(eq, q) == unsolved_object def test_solve_polynomial_symbolic_param(): assert solveset_complex((x**2 - 1)**2 - a, x) == \ FiniteSet(sqrt(1 + sqrt(a)), -sqrt(1 + sqrt(a)), sqrt(1 - sqrt(a)), -sqrt(1 - sqrt(a))) # issue 4507 assert solveset_complex(y - b/(1 + a*x), x) == \ FiniteSet((b/y - 1)/a) - FiniteSet(-1/a) # issue 4508 assert solveset_complex(y - b*x/(a + x), x) == \ FiniteSet(-a*y/(y - b)) - FiniteSet(-a) def test_solve_rational(): assert solveset_real(1/x + 1, x) == FiniteSet(-S.One) assert solveset_real(1/exp(x) - 1, x) == FiniteSet(0) assert solveset_real(x*(1 - 5/x), x) == FiniteSet(5) assert solveset_real(2*x/(x + 2) - 1, x) == FiniteSet(2) assert solveset_real((x**2/(7 - x)).diff(x), x) == \ FiniteSet(S(0), S(14)) def test_solveset_real_gen_is_pow(): assert solveset_real(sqrt(1) + 1, x) == EmptySet() def test_no_sol(): assert solveset(1 - oo*x) == EmptySet() assert solveset(oo*x, x) == EmptySet() assert solveset(oo*x - oo, x) == EmptySet() assert solveset_real(4, x) == EmptySet() assert solveset_real(exp(x), x) == EmptySet() assert solveset_real(x**2 + 1, x) == EmptySet() assert solveset_real(-3*a/sqrt(x), x) == EmptySet() assert solveset_real(1/x, x) == EmptySet() assert solveset_real(-(1 + x)/(2 + x)**2 + 1/(2 + x), x) == \ EmptySet() def test_sol_zero_real(): assert solveset_real(0, x) == S.Reals assert solveset(0, x, Interval(1, 2)) == Interval(1, 2) assert solveset_real(-x**2 - 2*x + (x + 1)**2 - 1, x) == S.Reals def test_no_sol_rational_extragenous(): assert solveset_real((x/(x + 1) + 3)**(-2), x) == EmptySet() assert solveset_real((x - 1)/(1 + 1/(x - 1)), x) == EmptySet() def test_solve_polynomial_cv_1a(): """ Test for solving on equations that can be converted to a polynomial equation using the change of variable y -> x**Rational(p, q) """ assert solveset_real(sqrt(x) - 1, x) == FiniteSet(1) assert solveset_real(sqrt(x) - 2, x) == FiniteSet(4) assert solveset_real(x**Rational(1, 4) - 2, x) == FiniteSet(16) assert solveset_real(x**Rational(1, 3) - 3, x) == FiniteSet(27) assert solveset_real(x*(x**(S(1) / 3) - 3), x) == \ FiniteSet(S(0), S(27)) def test_solveset_real_rational(): """Test solveset_real for rational functions""" assert solveset_real((x - y**3) / ((y**2)*sqrt(1 - y**2)), x) \ == FiniteSet(y**3) # issue 4486 assert solveset_real(2*x/(x + 2) - 1, x) == FiniteSet(2) def test_solveset_real_log(): assert solveset_real(log((x-1)*(x+1)), x) == \ FiniteSet(sqrt(2), -sqrt(2)) def test_poly_gens(): assert solveset_real(4**(2*(x**2) + 2*x) - 8, x) == \ FiniteSet(-Rational(3, 2), S.Half) def test_solve_abs(): x = Symbol('x') n = Dummy('n') raises(ValueError, lambda: solveset(Abs(x) - 1, x)) assert solveset(Abs(x) - n, x, S.Reals) == ConditionSet(x, Contains(n, Interval(0, oo)), {-n, n}) assert solveset_real(Abs(x) - 2, x) == FiniteSet(-2, 2) assert solveset_real(Abs(x) + 2, x) is S.EmptySet assert solveset_real(Abs(x + 3) - 2*Abs(x - 3), x) == \ FiniteSet(1, 9) assert solveset_real(2*Abs(x) - Abs(x - 1), x) == \ FiniteSet(-1, Rational(1, 3)) sol = ConditionSet( x, And( Contains(b, Interval(0, oo)), Contains(a + b, Interval(0, oo)), Contains(a - b, Interval(0, oo))), FiniteSet(-a - b - 3, -a + b - 3, a - b - 3, a + b - 3)) eq = Abs(Abs(x + 3) - a) - b assert invert_real(eq, 0, x)[1] == sol reps = {a: 3, b: 1} eqab = eq.subs(reps) for i in sol.subs(reps): assert not eqab.subs(x, i) assert solveset(Eq(sin(Abs(x)), 1), x, domain=S.Reals) == Union( Intersection(Interval(0, oo), ImageSet(Lambda(n, (-1)**n*pi/2 + n*pi), S.Integers)), Intersection(Interval(-oo, 0), ImageSet(Lambda(n, n*pi - (-1)**(-n)*pi/2), S.Integers))) def test_issue_9565(): assert solveset_real(Abs((x - 1)/(x - 5)) <= S(1)/3, x) == Interval(-1, 2) def test_issue_10069(): eq = abs(1/(x - 1)) - 1 > 0 u = Union(Interval.open(0, 1), Interval.open(1, 2)) assert solveset_real(eq, x) == u @XFAIL def test_rewrite_trigh(): # if this import passes then the test below should also pass from sympy import sech assert solveset_real(sinh(x) + sech(x), x) == FiniteSet( 2*atanh(-S.Half + sqrt(5)/2 - sqrt(-2*sqrt(5) + 2)/2), 2*atanh(-S.Half + sqrt(5)/2 + sqrt(-2*sqrt(5) + 2)/2), 2*atanh(-sqrt(5)/2 - S.Half + sqrt(2 + 2*sqrt(5))/2), 2*atanh(-sqrt(2 + 2*sqrt(5))/2 - sqrt(5)/2 - S.Half)) def test_real_imag_splitting(): a, b = symbols('a b', real=True, finite=True) assert solveset_real(sqrt(a**2 - b**2) - 3, a) == \ FiniteSet(-sqrt(b**2 + 9), sqrt(b**2 + 9)) assert solveset_real(sqrt(a**2 + b**2) - 3, a) != \ S.EmptySet def test_units(): assert solveset_real(1/x - 1/(2*cm), x) == FiniteSet(2*cm) def test_solve_only_exp_1(): y = Symbol('y', positive=True, finite=True) assert solveset_real(exp(x) - y, x) == FiniteSet(log(y)) assert solveset_real(exp(x) + exp(-x) - 4, x) == \ FiniteSet(log(-sqrt(3) + 2), log(sqrt(3) + 2)) assert solveset_real(exp(x) + exp(-x) - y, x) != S.EmptySet def test_atan2(): # The .inverse() method on atan2 works only if x.is_real is True and the # second argument is a real constant assert solveset_real(atan2(x, 2) - pi/3, x) == FiniteSet(2*sqrt(3)) def test_piecewise_solveset(): eq = Piecewise((x - 2, Gt(x, 2)), (2 - x, True)) - 3 assert set(solveset_real(eq, x)) == set(FiniteSet(-1, 5)) absxm3 = Piecewise( (x - 3, S(0) <= x - 3), (3 - x, S(0) > x - 3)) y = Symbol('y', positive=True) assert solveset_real(absxm3 - y, x) == FiniteSet(-y + 3, y + 3) f = Piecewise(((x - 2)**2, x >= 0), (0, True)) assert solveset(f, x, domain=S.Reals) == Union(FiniteSet(2), Interval(-oo, 0, True, True)) assert solveset( Piecewise((x + 1, x > 0), (I, True)) - I, x, S.Reals ) == Interval(-oo, 0) assert solveset(Piecewise((x - 1, Ne(x, I)), (x, True)), x) == FiniteSet(1) def test_solveset_complex_polynomial(): from sympy.abc import x, a, b, c assert solveset_complex(a*x**2 + b*x + c, x) == \ FiniteSet(-b/(2*a) - sqrt(-4*a*c + b**2)/(2*a), -b/(2*a) + sqrt(-4*a*c + b**2)/(2*a)) assert solveset_complex(x - y**3, y) == FiniteSet( (-x**Rational(1, 3))/2 + I*sqrt(3)*x**Rational(1, 3)/2, x**Rational(1, 3), (-x**Rational(1, 3))/2 - I*sqrt(3)*x**Rational(1, 3)/2) assert solveset_complex(x + 1/x - 1, x) == \ FiniteSet(Rational(1, 2) + I*sqrt(3)/2, Rational(1, 2) - I*sqrt(3)/2) def test_sol_zero_complex(): assert solveset_complex(0, x) == S.Complexes def test_solveset_complex_rational(): assert solveset_complex((x - 1)*(x - I)/(x - 3), x) == \ FiniteSet(1, I) assert solveset_complex((x - y**3)/((y**2)*sqrt(1 - y**2)), x) == \ FiniteSet(y**3) assert solveset_complex(-x**2 - I, x) == \ FiniteSet(-sqrt(2)/2 + sqrt(2)*I/2, sqrt(2)/2 - sqrt(2)*I/2) def test_solve_quintics(): skip("This test is too slow") f = x**5 - 110*x**3 - 55*x**2 + 2310*x + 979 s = solveset_complex(f, x) for root in s: res = f.subs(x, root.n()).n() assert tn(res, 0) f = x**5 + 15*x + 12 s = solveset_complex(f, x) for root in s: res = f.subs(x, root.n()).n() assert tn(res, 0) def test_solveset_complex_exp(): from sympy.abc import x, n assert solveset_complex(exp(x) - 1, x) == \ imageset(Lambda(n, I*2*n*pi), S.Integers) assert solveset_complex(exp(x) - I, x) == \ imageset(Lambda(n, I*(2*n*pi + pi/2)), S.Integers) assert solveset_complex(1/exp(x), x) == S.EmptySet assert solveset_complex(sinh(x).rewrite(exp), x) == \ imageset(Lambda(n, n*pi*I), S.Integers) def test_solveset_real_exp(): from sympy.abc import x, y assert solveset(Eq((-2)**x, 4), x, S.Reals) == FiniteSet(2) assert solveset(Eq(-2**x, 4), x, S.Reals) == S.EmptySet assert solveset(Eq((-3)**x, 27), x, S.Reals) == S.EmptySet assert solveset(Eq((-5)**(x+1), 625), x, S.Reals) == FiniteSet(3) assert solveset(Eq(2**(x-3), -16), x, S.Reals) == S.EmptySet assert solveset(Eq((-3)**(x - 3), -3**39), x, S.Reals) == FiniteSet(42) assert solveset(Eq(2**x, y), x, S.Reals) == Intersection(S.Reals, FiniteSet(log(y)/log(2))) assert invert_real((-2)**(2*x) - 16, 0, x) == (x, FiniteSet(2)) def test_solve_complex_log(): assert solveset_complex(log(x), x) == FiniteSet(1) assert solveset_complex(1 - log(a + 4*x**2), x) == \ FiniteSet(-sqrt(-a + E)/2, sqrt(-a + E)/2) def test_solve_complex_sqrt(): assert solveset_complex(sqrt(5*x + 6) - 2 - x, x) == \ FiniteSet(-S(1), S(2)) assert solveset_complex(sqrt(5*x + 6) - (2 + 2*I) - x, x) == \ FiniteSet(-S(2), 3 - 4*I) assert solveset_complex(4*x*(1 - a * sqrt(x)), x) == \ FiniteSet(S(0), 1 / a ** 2) def test_solveset_complex_tan(): s = solveset_complex(tan(x).rewrite(exp), x) assert s == imageset(Lambda(n, pi*n), S.Integers) - \ imageset(Lambda(n, pi*n + pi/2), S.Integers) def test_solve_trig(): from sympy.abc import n assert solveset_real(sin(x), x) == \ Union(imageset(Lambda(n, 2*pi*n), S.Integers), imageset(Lambda(n, 2*pi*n + pi), S.Integers)) assert solveset_real(sin(x) - 1, x) == \ imageset(Lambda(n, 2*pi*n + pi/2), S.Integers) assert solveset_real(cos(x), x) == \ Union(imageset(Lambda(n, 2*pi*n + pi/2), S.Integers), imageset(Lambda(n, 2*pi*n + 3*pi/2), S.Integers)) assert solveset_real(sin(x) + cos(x), x) == \ Union(imageset(Lambda(n, 2*n*pi + 3*pi/4), S.Integers), imageset(Lambda(n, 2*n*pi + 7*pi/4), S.Integers)) assert solveset_real(sin(x)**2 + cos(x)**2, x) == S.EmptySet assert solveset_complex(cos(x) - S.Half, x) == \ Union(imageset(Lambda(n, 2*n*pi + 5*pi/3), S.Integers), imageset(Lambda(n, 2*n*pi + pi/3), S.Integers)) y, a = symbols('y,a') assert solveset(sin(y + a) - sin(y), a, domain=S.Reals) == \ imageset(Lambda(n, 2*n*pi), S.Integers) assert solveset_real(sin(2*x)*cos(x) + cos(2*x)*sin(x)-1, x) == \ ImageSet(Lambda(n, 2*n*pi/3 + pi/6), S.Integers) # Tests for _solve_trig2() function assert solveset_real(2*cos(x)*cos(2*x) - 1, x) == \ Union(ImageSet(Lambda(n, 2*n*pi + 2*atan(sqrt(-2*2**(S(1)/3)*(67 + 9*sqrt(57))**(S(2)/3) + 8*2**(S(2)/3) + 11*(67 + 9*sqrt(57))**(S(1)/3))/(3*(67 + 9*sqrt(57))**(S(1)/6)))), S.Integers), ImageSet(Lambda(n, 2*n*pi - 2*atan(sqrt(-2*2**(S(1)/3)*(67 + 9*sqrt(57))**(S(2)/3) + 8*2**(S(2)/3) + 11*(67 + 9*sqrt(57))**(S(1)/3))/(3*(67 + 9*sqrt(57))**(S(1)/6))) + 2*pi), S.Integers)) assert solveset_real(2*tan(x)*sin(x) + 1, x) == Union( ImageSet(Lambda(n, 2*n*pi + atan(sqrt(2)*sqrt(-1 + sqrt(17))/ (-sqrt(17) + 1)) + pi), S.Integers), ImageSet(Lambda(n, 2*n*pi - atan(sqrt(2)*sqrt(-1 + sqrt(17))/ (-sqrt(17) + 1)) + pi), S.Integers)) assert solveset_real(cos(2*x)*cos(4*x) - 1, x) == \ ImageSet(Lambda(n, n*pi), S.Integers) def test_solve_invalid_sol(): assert 0 not in solveset_real(sin(x)/x, x) assert 0 not in solveset_complex((exp(x) - 1)/x, x) @XFAIL def test_solve_trig_simplified(): from sympy.abc import n assert solveset_real(sin(x), x) == \ imageset(Lambda(n, n*pi), S.Integers) assert solveset_real(cos(x), x) == \ imageset(Lambda(n, n*pi + pi/2), S.Integers) assert solveset_real(cos(x) + sin(x), x) == \ imageset(Lambda(n, n*pi - pi/4), S.Integers) @XFAIL def test_solve_lambert(): assert solveset_real(x*exp(x) - 1, x) == FiniteSet(LambertW(1)) assert solveset_real(exp(x) + x, x) == FiniteSet(-LambertW(1)) assert solveset_real(x + 2**x, x) == \ FiniteSet(-LambertW(log(2))/log(2)) # issue 4739 ans = solveset_real(3*x + 5 + 2**(-5*x + 3), x) assert ans == FiniteSet(-Rational(5, 3) + LambertW(-10240*2**(S(1)/3)*log(2)/3)/(5*log(2))) eq = 2*(3*x + 4)**5 - 6*7**(3*x + 9) result = solveset_real(eq, x) ans = FiniteSet((log(2401) + 5*LambertW(-log(7**(7*3**Rational(1, 5)/5))))/(3*log(7))/-1) assert result == ans assert solveset_real(eq.expand(), x) == result assert solveset_real(5*x - 1 + 3*exp(2 - 7*x), x) == \ FiniteSet(Rational(1, 5) + LambertW(-21*exp(Rational(3, 5))/5)/7) assert solveset_real(2*x + 5 + log(3*x - 2), x) == \ FiniteSet(Rational(2, 3) + LambertW(2*exp(-Rational(19, 3))/3)/2) assert solveset_real(3*x + log(4*x), x) == \ FiniteSet(LambertW(Rational(3, 4))/3) assert solveset_real(x**x - 2) == FiniteSet(exp(LambertW(log(2)))) a = Symbol('a') assert solveset_real(-a*x + 2*x*log(x), x) == FiniteSet(exp(a/2)) a = Symbol('a', real=True) assert solveset_real(a/x + exp(x/2), x) == \ FiniteSet(2*LambertW(-a/2)) assert solveset_real((a/x + exp(x/2)).diff(x), x) == \ FiniteSet(4*LambertW(sqrt(2)*sqrt(a)/4)) # coverage test assert solveset_real(tanh(x + 3)*tanh(x - 3) - 1, x) == EmptySet() assert solveset_real((x**2 - 2*x + 1).subs(x, log(x) + 3*x), x) == \ FiniteSet(LambertW(3*S.Exp1)/3) assert solveset_real((x**2 - 2*x + 1).subs(x, (log(x) + 3*x)**2 - 1), x) == \ FiniteSet(LambertW(3*exp(-sqrt(2)))/3, LambertW(3*exp(sqrt(2)))/3) assert solveset_real((x**2 - 2*x - 2).subs(x, log(x) + 3*x), x) == \ FiniteSet(LambertW(3*exp(1 + sqrt(3)))/3, LambertW(3*exp(-sqrt(3) + 1))/3) assert solveset_real(x*log(x) + 3*x + 1, x) == \ FiniteSet(exp(-3 + LambertW(-exp(3)))) eq = (x*exp(x) - 3).subs(x, x*exp(x)) assert solveset_real(eq, x) == \ FiniteSet(LambertW(3*exp(-LambertW(3)))) assert solveset_real(3*log(a**(3*x + 5)) + a**(3*x + 5), x) == \ FiniteSet(-((log(a**5) + LambertW(S(1)/3))/(3*log(a)))) p = symbols('p', positive=True) assert solveset_real(3*log(p**(3*x + 5)) + p**(3*x + 5), x) == \ FiniteSet( log((-3**(S(1)/3) - 3**(S(5)/6)*I)*LambertW(S(1)/3)**(S(1)/3)/(2*p**(S(5)/3)))/log(p), log((-3**(S(1)/3) + 3**(S(5)/6)*I)*LambertW(S(1)/3)**(S(1)/3)/(2*p**(S(5)/3)))/log(p), log((3*LambertW(S(1)/3)/p**5)**(1/(3*log(p)))),) # checked numerically # check collection b = Symbol('b') eq = 3*log(a**(3*x + 5)) + b*log(a**(3*x + 5)) + a**(3*x + 5) assert solveset_real(eq, x) == FiniteSet( -((log(a**5) + LambertW(1/(b + 3)))/(3*log(a)))) # issue 4271 assert solveset_real((a/x + exp(x/2)).diff(x, 2), x) == FiniteSet( 6*LambertW((-1)**(S(1)/3)*a**(S(1)/3)/3)) assert solveset_real(x**3 - 3**x, x) == \ FiniteSet(-3/log(3)*LambertW(-log(3)/3)) assert solveset_real(3**cos(x) - cos(x)**3) == FiniteSet( acos(-3*LambertW(-log(3)/3)/log(3))) assert solveset_real(x**2 - 2**x, x) == \ solveset_real(-x**2 + 2**x, x) assert solveset_real(3*log(x) - x*log(3)) == FiniteSet( -3*LambertW(-log(3)/3)/log(3), -3*LambertW(-log(3)/3, -1)/log(3)) assert solveset_real(LambertW(2*x) - y) == FiniteSet( y*exp(y)/2) @XFAIL def test_other_lambert(): a = S(6)/5 assert solveset_real(x**a - a**x, x) == FiniteSet( a, -a*LambertW(-log(a)/a)/log(a)) def test_solveset(): x = Symbol('x') f = Function('f') raises(ValueError, lambda: solveset(x + y)) assert solveset(x, 1) == S.EmptySet assert solveset(f(1)**2 + y + 1, f(1) ) == FiniteSet(-sqrt(-y - 1), sqrt(-y - 1)) assert solveset(f(1)**2 - 1, f(1), S.Reals) == FiniteSet(-1, 1) assert solveset(f(1)**2 + 1, f(1)) == FiniteSet(-I, I) assert solveset(x - 1, 1) == FiniteSet(x) assert solveset(sin(x) - cos(x), sin(x)) == FiniteSet(cos(x)) assert solveset(0, domain=S.Reals) == S.Reals assert solveset(1) == S.EmptySet assert solveset(True, domain=S.Reals) == S.Reals # issue 10197 assert solveset(False, domain=S.Reals) == S.EmptySet assert solveset(exp(x) - 1, domain=S.Reals) == FiniteSet(0) assert solveset(exp(x) - 1, x, S.Reals) == FiniteSet(0) assert solveset(Eq(exp(x), 1), x, S.Reals) == FiniteSet(0) assert solveset(exp(x) - 1, exp(x), S.Reals) == FiniteSet(1) A = Indexed('A', x) assert solveset(A - 1, A, S.Reals) == FiniteSet(1) assert solveset(x - 1 >= 0, x, S.Reals) == Interval(1, oo) assert solveset(exp(x) - 1 >= 0, x, S.Reals) == Interval(0, oo) assert solveset(exp(x) - 1, x) == imageset(Lambda(n, 2*I*pi*n), S.Integers) assert solveset(Eq(exp(x), 1), x) == imageset(Lambda(n, 2*I*pi*n), S.Integers) # issue 13825 assert solveset(x**2 + f(0) + 1, x) == {-sqrt(-f(0) - 1), sqrt(-f(0) - 1)} def test_conditionset(): assert solveset(Eq(sin(x)**2 + cos(x)**2, 1), x, domain=S.Reals) == \ ConditionSet(x, True, S.Reals) assert solveset(Eq(x**2 + x*sin(x), 1), x, domain=S.Reals ) == ConditionSet(x, Eq(x**2 + x*sin(x) - 1, 0), S.Reals) assert solveset(Eq(-I*(exp(I*x) - exp(-I*x))/2, 1), x ) == imageset(Lambda(n, 2*n*pi + pi/2), S.Integers) assert solveset(x + sin(x) > 1, x, domain=S.Reals ) == ConditionSet(x, x + sin(x) > 1, S.Reals) assert solveset(Eq(sin(Abs(x)), x), x, domain=S.Reals ) == ConditionSet(x, Eq(-x + sin(Abs(x)), 0), S.Reals) assert solveset(y**x-z, x, S.Reals) == \ ConditionSet(x, Eq(y**x - z, 0), S.Reals) @XFAIL def test_conditionset_equality(): ''' Checking equality of different representations of ConditionSet''' assert solveset(Eq(tan(x), y), x) == ConditionSet(x, Eq(tan(x), y), S.Complexes) def test_solveset_domain(): x = Symbol('x') assert solveset(x**2 - x - 6, x, Interval(0, oo)) == FiniteSet(3) assert solveset(x**2 - 1, x, Interval(0, oo)) == FiniteSet(1) assert solveset(x**4 - 16, x, Interval(0, 10)) == FiniteSet(2) def test_improve_coverage(): from sympy.solvers.solveset import _has_rational_power x = Symbol('x') solution = solveset(exp(x) + sin(x), x, S.Reals) unsolved_object = ConditionSet(x, Eq(exp(x) + sin(x), 0), S.Reals) assert solution == unsolved_object assert _has_rational_power(sin(x)*exp(x) + 1, x) == (False, S.One) assert _has_rational_power((sin(x)**2)*(exp(x) + 1)**3, x) == (False, S.One) def test_issue_9522(): x = Symbol('x') expr1 = Eq(1/(x**2 - 4) + x, 1/(x**2 - 4) + 2) expr2 = Eq(1/x + x, 1/x) assert solveset(expr1, x, S.Reals) == EmptySet() assert solveset(expr2, x, S.Reals) == EmptySet() def test_solvify(): x = Symbol('x') assert solvify(x**2 + 10, x, S.Reals) == [] assert solvify(x**3 + 1, x, S.Complexes) == [-1, S(1)/2 - sqrt(3)*I/2, S(1)/2 + sqrt(3)*I/2] assert solvify(log(x), x, S.Reals) == [1] assert solvify(cos(x), x, S.Reals) == [pi/2, 3*pi/2] assert solvify(sin(x) + 1, x, S.Reals) == [3*pi/2] raises(NotImplementedError, lambda: solvify(sin(exp(x)), x, S.Complexes)) def test_abs_invert_solvify(): assert solvify(sin(Abs(x)), x, S.Reals) is None def test_linear_eq_to_matrix(): x, y, z = symbols('x, y, z') a, b, c, d, e, f, g, h, i, j, k, l = symbols('a:l') eqns1 = [2*x + y - 2*z - 3, x - y - z, x + y + 3*z - 12] eqns2 = [Eq(3*x + 2*y - z, 1), Eq(2*x - 2*y + 4*z, -2), -2*x + y - 2*z] A, B = linear_eq_to_matrix(eqns1, x, y, z) assert A == Matrix([[2, 1, -2], [1, -1, -1], [1, 1, 3]]) assert B == Matrix([[3], [0], [12]]) A, B = linear_eq_to_matrix(eqns2, x, y, z) assert A == Matrix([[3, 2, -1], [2, -2, 4], [-2, 1, -2]]) assert B == Matrix([[1], [-2], [0]]) # Pure symbolic coefficients eqns3 = [a*b*x + b*y + c*z - d, e*x + d*x + f*y + g*z - h, i*x + j*y + k*z - l] A, B = linear_eq_to_matrix(eqns3, x, y, z) assert A == Matrix([[a*b, b, c], [d + e, f, g], [i, j, k]]) assert B == Matrix([[d], [h], [l]]) # raise ValueError if # 1) no symbols are given raises(ValueError, lambda: linear_eq_to_matrix(eqns3)) # 2) there are duplicates raises(ValueError, lambda: linear_eq_to_matrix(eqns3, [x, x, y])) # 3) there are non-symbols raises(ValueError, lambda: linear_eq_to_matrix(eqns3, [x, 1/a, y])) # 4) a nonlinear term is detected in the original expression raises(ValueError, lambda: linear_eq_to_matrix(Eq(1/x + x, 1/x))) assert linear_eq_to_matrix(1, x) == (Matrix([[0]]), Matrix([[-1]])) # issue 15195 assert linear_eq_to_matrix(x + y*(z*(3*x + 2) + 3), x) == ( Matrix([[3*y*z + 1]]), Matrix([[-y*(2*z + 3)]])) assert linear_eq_to_matrix(Matrix( [[a*x + b*y - 7], [5*x + 6*y - c]]), x, y) == ( Matrix([[a, b], [5, 6]]), Matrix([[7], [c]])) # issue 15312 assert linear_eq_to_matrix(Eq(x + 2, 1), x) == ( Matrix([[1]]), Matrix([[-1]])) def test_issue_16577(): assert linear_eq_to_matrix(Eq(a*(2*x + 3*y) + 4*y, 5), x, y) == ( Matrix([[2*a, 3*a + 4]]), Matrix([[5]])) def test_linsolve(): x, y, z, u, v, w = symbols("x, y, z, u, v, w") x1, x2, x3, x4 = symbols('x1, x2, x3, x4') # Test for different input forms M = Matrix([[1, 2, 1, 1, 7], [1, 2, 2, -1, 12], [2, 4, 0, 6, 4]]) system1 = A, b = M[:, :-1], M[:, -1] Eqns = [x1 + 2*x2 + x3 + x4 - 7, x1 + 2*x2 + 2*x3 - x4 - 12, 2*x1 + 4*x2 + 6*x4 - 4] sol = FiniteSet((-2*x2 - 3*x4 + 2, x2, 2*x4 + 5, x4)) assert linsolve(Eqns, (x1, x2, x3, x4)) == sol assert linsolve(Eqns, *(x1, x2, x3, x4)) == sol assert linsolve(system1, (x1, x2, x3, x4)) == sol assert linsolve(system1, *(x1, x2, x3, x4)) == sol # issue 9667 - symbols can be Dummy symbols x1, x2, x3, x4 = symbols('x:4', cls=Dummy) assert linsolve(system1, x1, x2, x3, x4) == FiniteSet( (-2*x2 - 3*x4 + 2, x2, 2*x4 + 5, x4)) # raise ValueError for garbage value raises(ValueError, lambda: linsolve(Eqns)) raises(ValueError, lambda: linsolve(x1)) raises(ValueError, lambda: linsolve(x1, x2)) raises(ValueError, lambda: linsolve((A,), x1, x2)) raises(ValueError, lambda: linsolve(A, b, x1, x2)) #raise ValueError if equations are non-linear in given variables raises(ValueError, lambda: linsolve([x + y - 1, x ** 2 + y - 3], [x, y])) raises(ValueError, lambda: linsolve([cos(x) + y, x + y], [x, y])) assert linsolve([x + z - 1, x ** 2 + y - 3], [z, y]) == {(-x + 1, -x**2 + 3)} # Fully symbolic test a, b, c, d, e, f = symbols('a, b, c, d, e, f') A = Matrix([[a, b], [c, d]]) B = Matrix([[e], [f]]) system2 = (A, B) sol = FiniteSet(((-b*f + d*e)/(a*d - b*c), (a*f - c*e)/(a*d - b*c))) assert linsolve(system2, [x, y]) == sol # No solution A = Matrix([[1, 2, 3], [2, 4, 6], [3, 6, 9]]) b = Matrix([0, 0, 1]) assert linsolve((A, b), (x, y, z)) == EmptySet() # Issue #10056 A, B, J1, J2 = symbols('A B J1 J2') Augmatrix = Matrix([ [2*I*J1, 2*I*J2, -2/J1], [-2*I*J2, -2*I*J1, 2/J2], [0, 2, 2*I/(J1*J2)], [2, 0, 0], ]) assert linsolve(Augmatrix, A, B) == FiniteSet((0, I/(J1*J2))) # Issue #10121 - Assignment of free variables a, b, c, d, e = symbols('a, b, c, d, e') Augmatrix = Matrix([[0, 1, 0, 0, 0, 0], [0, 0, 0, 1, 0, 0]]) assert linsolve(Augmatrix, a, b, c, d, e) == FiniteSet((a, 0, c, 0, e)) raises(IndexError, lambda: linsolve(Augmatrix, a, b, c)) x0, x1, x2, _x0 = symbols('tau0 tau1 tau2 _tau0') assert linsolve(Matrix([[0, 1, 0, 0, 0, 0], [0, 0, 0, 1, 0, _x0]]) ) == FiniteSet((x0, 0, x1, _x0, x2)) x0, x1, x2, _x0 = symbols('_tau0 _tau1 _tau2 tau0') assert linsolve(Matrix([[0, 1, 0, 0, 0, 0], [0, 0, 0, 1, 0, _x0]]) ) == FiniteSet((x0, 0, x1, _x0, x2)) x0, x1, x2, _x0 = symbols('_tau0 _tau1 _tau2 tau1') assert linsolve(Matrix([[0, 1, 0, 0, 0, 0], [0, 0, 0, 1, 0, _x0]]) ) == FiniteSet((x0, 0, x1, _x0, x2)) # symbols can be given as generators x0, x2, x4 = symbols('x0, x2, x4') assert linsolve(Augmatrix, numbered_symbols('x') ) == FiniteSet((x0, 0, x2, 0, x4)) Augmatrix[-1, -1] = x0 # use Dummy to avoid clash; the names may clash but the symbols # will not Augmatrix[-1, -1] = symbols('_x0') assert len(linsolve( Augmatrix, numbered_symbols('x', cls=Dummy)).free_symbols) == 4 # Issue #12604 f = Function('f') assert linsolve([f(x) - 5], f(x)) == FiniteSet((5,)) # Issue #14860 from sympy.physics.units import meter, newton, kilo Eqns = [8*kilo*newton + x + y, 28*kilo*newton*meter + 3*x*meter] assert linsolve(Eqns, x, y) == {(-28000*newton/3, 4000*newton/3)} # linsolve fully expands expressions, so removable singularities # and other nonlinearity does not raise an error assert linsolve([Eq(x, x + y)], [x, y]) == {(x, 0)} assert linsolve([Eq(1/x, 1/x + y)], [x, y]) == {(x, 0)} assert linsolve([Eq(y/x, y/x + y)], [x, y]) == {(x, 0)} assert linsolve([Eq(x*(x + 1), x**2 + y)], [x, y]) == {(y, y)} def test_solve_decomposition(): x = Symbol('x') n = Dummy('n') f1 = exp(3*x) - 6*exp(2*x) + 11*exp(x) - 6 f2 = sin(x)**2 - 2*sin(x) + 1 f3 = sin(x)**2 - sin(x) f4 = sin(x + 1) f5 = exp(x + 2) - 1 f6 = 1/log(x) f7 = 1/x s1 = ImageSet(Lambda(n, 2*n*pi), S.Integers) s2 = ImageSet(Lambda(n, 2*n*pi + pi), S.Integers) s3 = ImageSet(Lambda(n, 2*n*pi + pi/2), S.Integers) s4 = ImageSet(Lambda(n, 2*n*pi - 1), S.Integers) s5 = ImageSet(Lambda(n, 2*n*pi - 1 + pi), S.Integers) assert solve_decomposition(f1, x, S.Reals) == FiniteSet(0, log(2), log(3)) assert solve_decomposition(f2, x, S.Reals) == s3 assert solve_decomposition(f3, x, S.Reals) == Union(s1, s2, s3) assert solve_decomposition(f4, x, S.Reals) == Union(s4, s5) assert solve_decomposition(f5, x, S.Reals) == FiniteSet(-2) assert solve_decomposition(f6, x, S.Reals) == S.EmptySet assert solve_decomposition(f7, x, S.Reals) == S.EmptySet assert solve_decomposition(x, x, Interval(1, 2)) == S.EmptySet # nonlinsolve testcases def test_nonlinsolve_basic(): assert nonlinsolve([],[]) == S.EmptySet assert nonlinsolve([],[x, y]) == S.EmptySet system = [x, y - x - 5] assert nonlinsolve([x],[x, y]) == FiniteSet((0, y)) assert nonlinsolve(system, [y]) == FiniteSet((x + 5,)) soln = (ImageSet(Lambda(n, 2*n*pi + pi/2), S.Integers),) assert nonlinsolve([sin(x) - 1], [x]) == FiniteSet(tuple(soln)) assert nonlinsolve([x**2 - 1], [x]) == FiniteSet((-1,), (1,)) soln = FiniteSet((y, y)) assert nonlinsolve([x - y, 0], x, y) == soln assert nonlinsolve([0, x - y], x, y) == soln assert nonlinsolve([x - y, x - y], x, y) == soln assert nonlinsolve([x, 0], x, y) == FiniteSet((0, y)) f = Function('f') assert nonlinsolve([f(x), 0], f(x), y) == FiniteSet((0, y)) assert nonlinsolve([f(x), 0], f(x), f(y)) == FiniteSet((0, f(y))) A = Indexed('A', x) assert nonlinsolve([A, 0], A, y) == FiniteSet((0, y)) assert nonlinsolve([x**2 -1], [sin(x)]) == FiniteSet((S.EmptySet,)) assert nonlinsolve([x**2 -1], sin(x)) == FiniteSet((S.EmptySet,)) assert nonlinsolve([x**2 -1], 1) == FiniteSet((x**2,)) assert nonlinsolve([x**2 -1], x + y) == FiniteSet((S.EmptySet,)) def test_nonlinsolve_abs(): soln = FiniteSet((x, Abs(x))) assert nonlinsolve([Abs(x) - y], x, y) == soln def test_raise_exception_nonlinsolve(): raises(IndexError, lambda: nonlinsolve([x**2 -1], [])) raises(ValueError, lambda: nonlinsolve([x**2 -1])) raises(NotImplementedError, lambda: nonlinsolve([(x+y)**2 - 9, x**2 - y**2 - 0.75], (x, y))) def test_trig_system(): # TODO: add more simple testcases when solveset returns # simplified soln for Trig eq assert nonlinsolve([sin(x) - 1, cos(x) -1 ], x) == S.EmptySet soln1 = (ImageSet(Lambda(n, 2*n*pi + pi/2), S.Integers),) soln = FiniteSet(soln1) assert nonlinsolve([sin(x) - 1, cos(x)], x) == soln @XFAIL def test_trig_system_fail(): # fails because solveset trig solver is not much smart. sys = [x + y - pi/2, sin(x) + sin(y) - 1] # solveset returns conditonset for sin(x) + sin(y) - 1 soln_1 = (ImageSet(Lambda(n, n*pi + pi/2), S.Integers), ImageSet(Lambda(n, n*pi)), S.Integers) soln_1 = FiniteSet(soln_1) soln_2 = (ImageSet(Lambda(n, n*pi), S.Integers), ImageSet(Lambda(n, n*pi+ pi/2), S.Integers)) soln_2 = FiniteSet(soln_2) soln = soln_1 + soln_2 assert nonlinsolve(sys, [x, y]) == soln # Add more cases from here # http://www.vitutor.com/geometry/trigonometry/equations_systems.html#uno sys = [sin(x) + sin(y) - (sqrt(3)+1)/2, sin(x) - sin(y) - (sqrt(3) - 1)/2] soln_x = Union(ImageSet(Lambda(n, 2*n*pi + pi/3), S.Integers), ImageSet(Lambda(n, 2*n*pi + 2*pi/3), S.Integers)) soln_y = Union(ImageSet(Lambda(n, 2*n*pi + pi/6), S.Integers), ImageSet(Lambda(n, 2*n*pi + 5*pi/6), S.Integers)) assert nonlinsolve(sys, [x, y]) ==FiniteSet((soln_x, soln_y)) def test_nonlinsolve_positive_dimensional(): x, y, z, a, b, c, d = symbols('x, y, z, a, b, c, d', real = True) assert nonlinsolve([x*y, x*y - x], [x, y]) == FiniteSet((0, y)) system = [a**2 + a*c, a - b] assert nonlinsolve(system, [a, b]) == FiniteSet((0, 0), (-c, -c)) # here (a= 0, b = 0) is independent soln so both is printed. # if symbols = [a, b, c] then only {a : -c ,b : -c} eq1 = a + b + c + d eq2 = a*b + b*c + c*d + d*a eq3 = a*b*c + b*c*d + c*d*a + d*a*b eq4 = a*b*c*d - 1 system = [eq1, eq2, eq3, eq4] sol1 = (-1/d, -d, 1/d, FiniteSet(d) - FiniteSet(0)) sol2 = (1/d, -d, -1/d, FiniteSet(d) - FiniteSet(0)) soln = FiniteSet(sol1, sol2) assert nonlinsolve(system, [a, b, c, d]) == soln def test_nonlinsolve_polysys(): x, y, z = symbols('x, y, z', real = True) assert nonlinsolve([x**2 + y - 2, x**2 + y], [x, y]) == S.EmptySet s = (-y + 2, y) assert nonlinsolve([(x + y)**2 - 4, x + y - 2], [x, y]) == FiniteSet(s) system = [x**2 - y**2] soln_real = FiniteSet((-y, y), (y, y)) soln_complex = FiniteSet((-Abs(y), y), (Abs(y), y)) soln =soln_real + soln_complex assert nonlinsolve(system, [x, y]) == soln system = [x**2 - y**2] soln_real= FiniteSet((y, -y), (y, y)) soln_complex = FiniteSet((y, -Abs(y)), (y, Abs(y))) soln = soln_real + soln_complex assert nonlinsolve(system, [y, x]) == soln system = [x**2 + y - 3, x - y - 4] assert nonlinsolve(system, (x, y)) != nonlinsolve(system, (y, x)) def test_nonlinsolve_using_substitution(): x, y, z, n = symbols('x, y, z, n', real = True) system = [(x + y)*n - y**2 + 2] s_x = (n*y - y**2 + 2)/n soln = (-s_x, y) assert nonlinsolve(system, [x, y]) == FiniteSet(soln) system = [z**2*x**2 - z**2*y**2/exp(x)] soln_real_1 = (y, x, 0) soln_real_2 = (-exp(x/2)*Abs(x), x, z) soln_real_3 = (exp(x/2)*Abs(x), x, z) soln_complex_1 = (-x*exp(x/2), x, z) soln_complex_2 = (x*exp(x/2), x, z) syms = [y, x, z] soln = FiniteSet(soln_real_1, soln_complex_1, soln_complex_2,\ soln_real_2, soln_real_3) assert nonlinsolve(system,syms) == soln def test_nonlinsolve_complex(): x, y, z = symbols('x, y, z') n = Dummy('n') real_soln = (log(sin(S(1)/3)), S(1)/3) img_lamda = Lambda(n, 2*n*I*pi + Mod(log(sin(S(1)/3)), 2*I*pi)) complex_soln = (ImageSet(img_lamda, S.Integers), S(1)/3) soln = FiniteSet(real_soln, complex_soln) assert nonlinsolve([exp(x) - sin(y), 1/y - 3], [x, y]) == soln system = [exp(x) - sin(y), 1/exp(y) - 3] soln_x = ImageSet(Lambda(n, I*(2*n*pi + pi) + log(sin(log(3)))), S.Integers) soln_real = FiniteSet((soln_x, -log(S(3)))) # Mod(-log(3), 2*I*pi) is equal to -log(3). expr_x = I*(2*n*pi + arg(sin(2*n*I*pi + Mod(-log(3), 2*I*pi)))) + \ log(Abs(sin(2*n*I*pi + Mod(-log(3), 2*I*pi)))) soln_x = ImageSet(Lambda(n, expr_x), S.Integers) expr_y = 2*n*I*pi + Mod(-log(3), 2*I*pi) soln_y = ImageSet(Lambda(n, expr_y), S.Integers) soln_complex = FiniteSet((soln_x, soln_y)) soln = soln_real + soln_complex assert nonlinsolve(system, [x, y]) == soln system = [exp(x) - sin(y), y**2 - 4] s1 = (log(sin(2)), 2) s2 = (ImageSet(Lambda(n, I*(2*n*pi + pi) + log(sin(2))), S.Integers), -2 ) img = ImageSet(Lambda(n, 2*n*I*pi + Mod(log(sin(2)), 2*I*pi)), S.Integers) s3 = (img, 2) assert nonlinsolve(system, [x, y]) == FiniteSet(s1, s2, s3) @XFAIL def test_solve_nonlinear_trans(): # After the transcendental equation solver these will work x, y, z = symbols('x, y, z', real=True) soln1 = FiniteSet((2*LambertW(y/2), y)) soln2 = FiniteSet((-x*sqrt(exp(x)), y), (x*sqrt(exp(x)), y)) soln3 = FiniteSet((x*exp(x/2), x)) soln4 = FiniteSet(2*LambertW(y/2), y) assert nonlinsolve([x**2 - y**2/exp(x)], [x, y]) == soln1 assert nonlinsolve([x**2 - y**2/exp(x)], [y, x]) == soln2 assert nonlinsolve([x**2 - y**2/exp(x)], [y, x]) == soln3 assert nonlinsolve([x**2 - y**2/exp(x)], [x, y]) == soln4 def test_issue_5132_1(): system = [sqrt(x**2 + y**2) - sqrt(10), x + y - 4] assert nonlinsolve(system, [x, y]) == FiniteSet((1, 3), (3, 1)) n = Dummy('n') eqs = [exp(x)**2 - sin(y) + z**2, 1/exp(y) - 3] s_real_y = -log(3) s_real_z = sqrt(-exp(2*x) - sin(log(3))) soln_real = FiniteSet((s_real_y, s_real_z), (s_real_y, -s_real_z)) lam = Lambda(n, 2*n*I*pi + Mod(-log(3), 2*I*pi)) s_complex_y = ImageSet(lam, S.Integers) lam = Lambda(n, sqrt(-exp(2*x) + sin(2*n*I*pi + Mod(-log(3), 2*I*pi)))) s_complex_z_1 = ImageSet(lam, S.Integers) lam = Lambda(n, -sqrt(-exp(2*x) + sin(2*n*I*pi + Mod(-log(3), 2*I*pi)))) s_complex_z_2 = ImageSet(lam, S.Integers) soln_complex = FiniteSet( (s_complex_y, s_complex_z_1), (s_complex_y, s_complex_z_2) ) soln = soln_real + soln_complex assert nonlinsolve(eqs, [y, z]) == soln def test_issue_5132_2(): x, y = symbols('x, y', real=True) eqs = [exp(x)**2 - sin(y) + z**2, 1/exp(y) - 3] n = Dummy('n') soln_real = (log(-z**2 + sin(y))/2, z) lam = Lambda( n, I*(2*n*pi + arg(-z**2 + sin(y)))/2 + log(Abs(z**2 - sin(y)))/2) img = ImageSet(lam, S.Integers) # not sure about the complex soln. But it looks correct. soln_complex = (img, z) soln = FiniteSet(soln_real, soln_complex) assert nonlinsolve(eqs, [x, z]) == soln r, t = symbols('r, t') system = [r - x**2 - y**2, tan(t) - y/x] s_x = sqrt(r/(tan(t)**2 + 1)) s_y = sqrt(r/(tan(t)**2 + 1))*tan(t) soln = FiniteSet((s_x, s_y), (-s_x, -s_y)) assert nonlinsolve(system, [x, y]) == soln def test_issue_6752(): a,b,c,d = symbols('a, b, c, d', real=True) assert nonlinsolve([a**2 + a, a - b], [a, b]) == {(-1, -1), (0, 0)} @SKIP("slow") def test_issue_5114_solveset(): # slow testcase a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r = symbols('a:r') # there is no 'a' in the equation set but this is how the # problem was originally posed syms = [a, b, c, f, h, k, n] eqs = [b + r/d - c/d, c*(1/d + 1/e + 1/g) - f/g - r/d, f*(1/g + 1/i + 1/j) - c/g - h/i, h*(1/i + 1/l + 1/m) - f/i - k/m, k*(1/m + 1/o + 1/p) - h/m - n/p, n*(1/p + 1/q) - k/p] assert len(nonlinsolve(eqs, syms)) == 1 @SKIP("Hangs") def _test_issue_5335(): # Not able to check zero dimensional system. # is_zero_dimensional Hangs lam, a0, conc = symbols('lam a0 conc') eqs = [lam + 2*y - a0*(1 - x/2)*x - 0.005*x/2*x, a0*(1 - x/2)*x - 1*y - 0.743436700916726*y, x + y - conc] sym = [x, y, a0] # there are 4 solutions but only two are valid assert len(nonlinsolve(eqs, sym)) == 2 # float lam, a0, conc = symbols('lam a0 conc') eqs = [lam + 2*y - a0*(1 - x/2)*x - 0.005*x/2*x, a0*(1 - x/2)*x - 1*y - 0.743436700916726*y, x + y - conc] sym = [x, y, a0] assert len(nonlinsolve(eqs, sym)) == 2 def test_issue_2777(): # the equations represent two circles x, y = symbols('x y', real=True) e1, e2 = sqrt(x**2 + y**2) - 10, sqrt(y**2 + (-x + 10)**2) - 3 a, b = 191/S(20), 3*sqrt(391)/20 ans = {(a, -b), (a, b)} assert nonlinsolve((e1, e2), (x, y)) == ans assert nonlinsolve((e1, e2/(x - a)), (x, y)) == S.EmptySet # make the 2nd circle's radius be -3 e2 += 6 assert nonlinsolve((e1, e2), (x, y)) == S.EmptySet def test_issue_8828(): x1 = 0 y1 = -620 r1 = 920 x2 = 126 y2 = 276 x3 = 51 y3 = 205 r3 = 104 v = [x, y, z] f1 = (x - x1)**2 + (y - y1)**2 - (r1 - z)**2 f2 = (x2 - x)**2 + (y2 - y)**2 - z**2 f3 = (x - x3)**2 + (y - y3)**2 - (r3 - z)**2 F = [f1, f2, f3] g1 = sqrt((x - x1)**2 + (y - y1)**2) + z - r1 g2 = f2 g3 = sqrt((x - x3)**2 + (y - y3)**2) + z - r3 G = [g1, g2, g3] # both soln same A = nonlinsolve(F, v) B = nonlinsolve(G, v) assert A == B def test_nonlinsolve_conditionset(): # when solveset failed to solve all the eq # return conditionset f = Function('f') f1 = f(x) - pi/2 f2 = f(y) - 3*pi/2 intermediate_system = FiniteSet(2*f(x) - pi, 2*f(y) - 3*pi) symbols = Tuple(x, y) soln = ConditionSet( symbols, intermediate_system, S.Complexes) assert nonlinsolve([f1, f2], [x, y]) == soln def test_substitution_basic(): assert substitution([], [x, y]) == S.EmptySet assert substitution([], []) == S.EmptySet system = [2*x**2 + 3*y**2 - 30, 3*x**2 - 2*y**2 - 19] soln = FiniteSet((-3, -2), (-3, 2), (3, -2), (3, 2)) assert substitution(system, [x, y]) == soln soln = FiniteSet((-1, 1)) assert substitution([x + y], [x], [{y: 1}], [y], set([]), [x, y]) == soln assert substitution( [x + y], [x], [{y: 1}], [y], set([x + 1]), [y, x]) == S.EmptySet def test_issue_5132_substitution(): x, y, z, r, t = symbols('x, y, z, r, t', real=True) system = [r - x**2 - y**2, tan(t) - y/x] s_x_1 = Complement(FiniteSet(-sqrt(r/(tan(t)**2 + 1))), FiniteSet(0)) s_x_2 = Complement(FiniteSet(sqrt(r/(tan(t)**2 + 1))), FiniteSet(0)) s_y = sqrt(r/(tan(t)**2 + 1))*tan(t) soln = FiniteSet((s_x_2, s_y)) + FiniteSet((s_x_1, -s_y)) assert substitution(system, [x, y]) == soln n = Dummy('n') eqs = [exp(x)**2 - sin(y) + z**2, 1/exp(y) - 3] s_real_y = -log(3) s_real_z = sqrt(-exp(2*x) - sin(log(3))) soln_real = FiniteSet((s_real_y, s_real_z), (s_real_y, -s_real_z)) lam = Lambda(n, 2*n*I*pi + Mod(-log(3), 2*I*pi)) s_complex_y = ImageSet(lam, S.Integers) lam = Lambda(n, sqrt(-exp(2*x) + sin(2*n*I*pi + Mod(-log(3), 2*I*pi)))) s_complex_z_1 = ImageSet(lam, S.Integers) lam = Lambda(n, -sqrt(-exp(2*x) + sin(2*n*I*pi + Mod(-log(3), 2*I*pi)))) s_complex_z_2 = ImageSet(lam, S.Integers) soln_complex = FiniteSet( (s_complex_y, s_complex_z_1), (s_complex_y, s_complex_z_2) ) soln = soln_real + soln_complex assert substitution(eqs, [y, z]) == soln def test_raises_substitution(): raises(ValueError, lambda: substitution([x**2 -1], [])) raises(TypeError, lambda: substitution([x**2 -1])) raises(ValueError, lambda: substitution([x**2 -1], [sin(x)])) raises(TypeError, lambda: substitution([x**2 -1], x)) raises(TypeError, lambda: substitution([x**2 -1], 1)) # end of tests for nonlinsolve def test_issue_9556(): x = Symbol('x') b = Symbol('b', positive=True) assert solveset(Abs(x) + 1, x, S.Reals) == EmptySet() assert solveset(Abs(x) + b, x, S.Reals) == EmptySet() assert solveset(Eq(b, -1), b, S.Reals) == EmptySet() def test_issue_9611(): x = Symbol('x') a = Symbol('a') y = Symbol('y') assert solveset(Eq(x - x + a, a), x, S.Reals) == S.Reals assert solveset(Eq(y - y + a, a), y) == S.Complexes def test_issue_9557(): x = Symbol('x') a = Symbol('a') assert solveset(x**2 + a, x, S.Reals) == Intersection(S.Reals, FiniteSet(-sqrt(-a), sqrt(-a))) def test_issue_9778(): assert solveset(x**3 + 1, x, S.Reals) == FiniteSet(-1) assert solveset(x**(S(3)/5) + 1, x, S.Reals) == S.EmptySet assert solveset(x**3 + y, x, S.Reals) == \ FiniteSet(-Abs(y)**(S(1)/3)*sign(y)) def test_issue_10214(): assert solveset(x**(S(3)/2) + 4, x, S.Reals) == S.EmptySet assert solveset(x**(S(-3)/2) + 4, x, S.Reals) == S.EmptySet ans = FiniteSet(-2**(S(2)/3)) assert solveset(x**(S(3)) + 4, x, S.Reals) == ans assert (x**(S(3)) + 4).subs(x,list(ans)[0]) == 0 # substituting ans and verifying the result. assert (x**(S(3)) + 4).subs(x,-(-2)**(2/S(3))) == 0 def test_issue_9849(): assert solveset(Abs(sin(x)) + 1, x, S.Reals) == S.EmptySet def test_issue_9953(): assert linsolve([ ], x) == S.EmptySet def test_issue_9913(): assert solveset(2*x + 1/(x - 10)**2, x, S.Reals) == \ FiniteSet(-(3*sqrt(24081)/4 + S(4027)/4)**(S(1)/3)/3 - 100/ (3*(3*sqrt(24081)/4 + S(4027)/4)**(S(1)/3)) + S(20)/3) def test_issue_10397(): assert solveset(sqrt(x), x, S.Complexes) == FiniteSet(0) def test_issue_14987(): raises(ValueError, lambda: linear_eq_to_matrix( [x**2], x)) raises(ValueError, lambda: linear_eq_to_matrix( [x*(-3/x + 1) + 2*y - a], [x, y])) raises(ValueError, lambda: linear_eq_to_matrix( [(x**2 - 3*x)/(x - 3) - 3], x)) raises(ValueError, lambda: linear_eq_to_matrix( [(x + 1)**3 - x**3 - 3*x**2 + 7], x)) raises(ValueError, lambda: linear_eq_to_matrix( [x*(1/x + 1) + y], [x, y])) raises(ValueError, lambda: linear_eq_to_matrix( [(x + 1)*y], [x, y])) raises(ValueError, lambda: linear_eq_to_matrix( [Eq(1/x, 1/x + y)], [x, y])) raises(ValueError, lambda: linear_eq_to_matrix( [Eq(y/x, y/x + y)], [x, y])) raises(ValueError, lambda: linear_eq_to_matrix( [Eq(x*(x + 1), x**2 + y)], [x, y])) def test_simplification(): eq = x + (a - b)/(-2*a + 2*b) assert solveset(eq, x) == FiniteSet(S.Half) assert solveset(eq, x, S.Reals) == FiniteSet(S.Half) def test_issue_10555(): f = Function('f') g = Function('g') assert solveset(f(x) - pi/2, x, S.Reals) == \ ConditionSet(x, Eq(f(x) - pi/2, 0), S.Reals) assert solveset(f(g(x)) - pi/2, g(x), S.Reals) == \ ConditionSet(g(x), Eq(f(g(x)) - pi/2, 0), S.Reals) def test_issue_8715(): eq = x + 1/x > -2 + 1/x assert solveset(eq, x, S.Reals) == \ (Interval.open(-2, oo) - FiniteSet(0)) assert solveset(eq.subs(x,log(x)), x, S.Reals) == \ Interval.open(exp(-2), oo) - FiniteSet(1) def test_issue_11174(): r, t = symbols('r t') eq = z**2 + exp(2*x) - sin(y) soln = Intersection(S.Reals, FiniteSet(log(-z**2 + sin(y))/2)) assert solveset(eq, x, S.Reals) == soln eq = sqrt(r)*Abs(tan(t))/sqrt(tan(t)**2 + 1) + x*tan(t) s = -sqrt(r)*Abs(tan(t))/(sqrt(tan(t)**2 + 1)*tan(t)) soln = Intersection(S.Reals, FiniteSet(s)) assert solveset(eq, x, S.Reals) == soln def test_issue_11534(): # eq and eq2 should give the same solution as a Complement eq = -y + x/sqrt(-x**2 + 1) eq2 = -y**2 + x**2/(-x**2 + 1) soln = Complement(FiniteSet(-y/sqrt(y**2 + 1), y/sqrt(y**2 + 1)), FiniteSet(-1, 1)) assert solveset(eq, x, S.Reals) == soln assert solveset(eq2, x, S.Reals) == soln def test_issue_10477(): assert solveset((x**2 + 4*x - 3)/x < 2, x, S.Reals) == \ Union(Interval.open(-oo, -3), Interval.open(0, 1)) def test_issue_10671(): assert solveset(sin(y), y, Interval(0, pi)) == FiniteSet(0, pi) i = Interval(1, 10) assert solveset((1/x).diff(x) < 0, x, i) == i def test_issue_11064(): eq = x + sqrt(x**2 - 5) assert solveset(eq > 0, x, S.Reals) == \ Interval(sqrt(5), oo) assert solveset(eq < 0, x, S.Reals) == \ Interval(-oo, -sqrt(5)) assert solveset(eq > sqrt(5), x, S.Reals) == \ Interval.Lopen(sqrt(5), oo) def test_issue_12478(): eq = sqrt(x - 2) + 2 soln = solveset_real(eq, x) assert soln is S.EmptySet assert solveset(eq < 0, x, S.Reals) is S.EmptySet assert solveset(eq > 0, x, S.Reals) == Interval(2, oo) def test_issue_12429(): eq = solveset(log(x)/x <= 0, x, S.Reals) sol = Interval.Lopen(0, 1) assert eq == sol def test_solveset_arg(): assert solveset(arg(x), x, S.Reals) == Interval.open(0, oo) assert solveset(arg(4*x -3), x) == Interval.open(S(3)/4, oo) def test__is_finite_with_finite_vars(): f = _is_finite_with_finite_vars # issue 12482 assert all(f(1/x) is None for x in ( Dummy(), Dummy(real=True), Dummy(complex=True))) assert f(1/Dummy(real=False)) is True # b/c it's finite but not 0 def test_issue_13550(): assert solveset(x**2 - 2*x - 15, symbol = x, domain = Interval(-oo, 0)) == FiniteSet(-3) def test_issue_13849(): t = symbols('t') assert nonlinsolve((t*(sqrt(5) + sqrt(2)) - sqrt(2), t), t) == EmptySet() def test_issue_14223(): x = Symbol('x') assert solveset((Abs(x + Min(x, 2)) - 2).rewrite(Piecewise), x, S.Reals) == FiniteSet(-1, 1) assert solveset((Abs(x + Min(x, 2)) - 2).rewrite(Piecewise), x, Interval(0, 2)) == FiniteSet(1) def test_issue_10158(): x = Symbol('x') dom = S.Reals assert solveset(x*Max(x, 15) - 10, x, dom) == FiniteSet(2/S(3)) assert solveset(x*Min(x, 15) - 10, x, dom) == FiniteSet(-sqrt(10), sqrt(10)) assert solveset(Max(Abs(x - 3) - 1, x + 2) - 3, x, dom) == FiniteSet(-1, 1) assert solveset(Abs(x - 1) - Abs(y), x, dom) == FiniteSet(-Abs(y) + 1, Abs(y) + 1) assert solveset(Abs(x + 4*Abs(x + 1)), x, dom) == FiniteSet(-4/S(3), -4/S(5)) assert solveset(2*Abs(x + Abs(x + Max(3, x))) - 2, x, S.Reals) == FiniteSet(-1, -2) dom = S.Complexes raises(ValueError, lambda: solveset(x*Max(x, 15) - 10, x, dom)) raises(ValueError, lambda: solveset(x*Min(x, 15) - 10, x, dom)) raises(ValueError, lambda: solveset(Max(Abs(x - 3) - 1, x + 2) - 3, x, dom)) raises(ValueError, lambda: solveset(Abs(x - 1) - Abs(y), x, dom)) raises(ValueError, lambda: solveset(Abs(x + 4*Abs(x + 1)), x, dom)) def test_issue_14300(): x, y, n = symbols('x y n') f = 1 - exp(-18000000*x) - y a1 = FiniteSet(-log(-y + 1)/18000000) assert solveset(f, x, S.Reals) == \ Intersection(S.Reals, a1) assert solveset(f, x) == \ ImageSet(Lambda(n, -I*(2*n*pi + arg(-y + 1))/18000000 - log(Abs(y - 1))/18000000), S.Integers) def test_issue_14454(): x = Symbol('x') number = CRootOf(x**4 + x - 1, 2) raises(ValueError, lambda: invert_real(number, 0, x, S.Reals)) assert invert_real(x**2, number, x, S.Reals) # no error def test_term_factors(): 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 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 ############### def test_transolve(): assert _transolve(3**x, x, S.Reals) == S.EmptySet assert _transolve(3**x - 9**(x + 5), x, S.Reals) == FiniteSet(-10) # exponential tests def test_exponential_real(): from sympy.abc import x, y, z e1 = 3**(2*x) - 2**(x + 3) e2 = 4**(5 - 9*x) - 8**(2 - x) e3 = 2**x + 4**x e4 = exp(log(5)*x) - 2**x e5 = exp(x/y)*exp(-z/y) - 2 e6 = 5**(x/2) - 2**(x/3) e7 = 4**(x + 1) + 4**(x + 2) + 4**(x - 1) - 3**(x + 2) - 3**(x + 3) e8 = -9*exp(-2*x + 5) + 4*exp(3*x + 1) e9 = 2**x + 4**x + 8**x - 84 assert solveset(e1, x, S.Reals) == FiniteSet( -3*log(2)/(-2*log(3) + log(2))) assert solveset(e2, x, S.Reals) == FiniteSet(4/S(15)) assert solveset(e3, x, S.Reals) == S.EmptySet assert solveset(e4, x, S.Reals) == FiniteSet(0) assert solveset(e5, x, S.Reals) == Intersection( S.Reals, FiniteSet(y*log(2*exp(z/y)))) assert solveset(e6, x, S.Reals) == FiniteSet(0) assert solveset(e7, x, S.Reals) == FiniteSet(2) assert solveset(e8, x, S.Reals) == FiniteSet(-2*log(2)/5 + 2*log(3)/5 + S(4)/5) assert solveset(e9, x, S.Reals) == FiniteSet(2) assert solveset_real(-9*exp(-2*x + 5) + 2**(x + 1), x) == FiniteSet( -((-5 - 2*log(3) + log(2))/(log(2) + 2))) assert solveset_real(4**(x/2) - 2**(x/3), x) == FiniteSet(0) b = sqrt(6)*sqrt(log(2))/sqrt(log(5)) assert solveset_real(5**(x/2) - 2**(3/x), x) == FiniteSet(-b, b) # coverage test C1, C2 = symbols('C1 C2') f = Function('f') assert solveset_real(C1 + C2/x**2 - exp(-f(x)), f(x)) == Intersection( S.Reals, FiniteSet(-log(C1 + C2/x**2))) y = symbols('y', positive=True) assert solveset_real(x**2 - y**2/exp(x), y) == Intersection( S.Reals, FiniteSet(-sqrt(x**2*exp(x)), sqrt(x**2*exp(x)))) p = Symbol('p', positive=True) assert solveset_real((1/p + 1)**(p + 1), p) == EmptySet() @XFAIL def test_exponential_complex(): from sympy.abc import x from sympy import Dummy n = Dummy('n') assert solveset_complex(2**x + 4**x, x) == imageset( Lambda(n, I*(2*n*pi + pi)/log(2)), S.Integers) assert solveset_complex(x**z*y**z - 2, z) == FiniteSet( log(2)/(log(x) + log(y))) assert solveset_complex(4**(x/2) - 2**(x/3), x) == imageset( Lambda(n, 3*n*I*pi/log(2)), S.Integers) assert solveset(2**x + 32, x) == imageset( Lambda(n, (I*(2*n*pi + pi) + 5*log(2))/log(2)), S.Integers) eq = (2**exp(y**2/x) + 2)/(x**2 + 15) a = sqrt(x)*sqrt(-log(log(2)) + log(log(2) + 2*n*I*pi)) assert solveset_complex(eq, y) == FiniteSet(-a, a) union1 = imageset(Lambda(n, I*(2*n*pi - 2*pi/3)/log(2)), S.Integers) union2 = imageset(Lambda(n, I*(2*n*pi + 2*pi/3)/log(2)), S.Integers) assert solveset(2**x + 4**x + 8**x, x) == Union(union1, union2) eq = 4**(x + 1) + 4**(x + 2) + 4**(x - 1) - 3**(x + 2) - 3**(x + 3) res = solveset(eq, x) num = 2*n*I*pi - 4*log(2) + 2*log(3) den = -2*log(2) + log(3) ans = imageset(Lambda(n, num/den), S.Integers) assert res == ans def test_expo_conditionset(): from sympy.abc import x, y f1 = (exp(x) + 1)**x - 2 f2 = (x + 2)**y*x - 3 f3 = 2**x - exp(x) - 3 f4 = log(x) - exp(x) f5 = 2**x + 3**x - 5**x assert solveset(f1, x, S.Reals) == ConditionSet( x, Eq((exp(x) + 1)**x - 2, 0), S.Reals) assert solveset(f2, x, S.Reals) == ConditionSet( x, Eq(x*(x + 2)**y - 3, 0), S.Reals) assert solveset(f3, x, S.Reals) == ConditionSet( x, Eq(2**x - exp(x) - 3, 0), S.Reals) assert solveset(f4, x, S.Reals) == ConditionSet( x, Eq(-exp(x) + log(x), 0), S.Reals) assert solveset(f5, x, S.Reals) == ConditionSet( x, Eq(2**x + 3**x - 5**x, 0), S.Reals) def test_exponential_symbols(): x, y, z = symbols('x y z', positive=True) from sympy import simplify assert solveset(z**x - y, x, S.Reals) == Intersection( S.Reals, FiniteSet(log(y)/log(z))) w = symbols('w') f1 = 2*x**w - 4*y**w f2 = (x/y)**w - 2 ans1 = solveset(f1, w, S.Reals) ans2 = solveset(f2, w, S.Reals) assert ans1 == simplify(ans2) assert solveset(x**x, x, S.Reals) == S.EmptySet assert solveset(x**y - 1, y, S.Reals) == FiniteSet(0) assert solveset(exp(x/y)*exp(-z/y) - 2, y, S.Reals) == FiniteSet( (x - z)/log(2)) - FiniteSet(0) a, b, x, y = symbols('a b x y') assert solveset_real(a**x - b**x, x) == ConditionSet( x, (a > 0) & (b > 0), FiniteSet(0)) assert solveset(a**x - b**x, x) == ConditionSet( x, Ne(a, 0) & Ne(b, 0), FiniteSet(0)) @XFAIL def test_issue_10864(): assert solveset(x**(y*z) - x, x, S.Reals) == FiniteSet(1) @XFAIL def test_solve_only_exp_2(): assert solveset_real(sqrt(exp(x)) + sqrt(exp(-x)) - 4, x) == \ FiniteSet(2*log(-sqrt(3) + 2), 2*log(sqrt(3) + 2)) def test_is_exponential(): x, y, z = symbols('x y z') assert _is_exponential(y, x) is False assert _is_exponential(3**x - 2, x) is True assert _is_exponential(5**x - 7**(2 - x), x) is True assert _is_exponential(sin(2**x) - 4*x, x) is False assert _is_exponential(x**y - z, y) is True assert _is_exponential(x**y - z, x) is False assert _is_exponential(2**x + 4**x - 1, x) is True assert _is_exponential(x**(y*z) - x, x) is False assert _is_exponential(x**(2*x) - 3**x, x) is False assert _is_exponential(x**y - y*z, y) is False assert _is_exponential(x**y - x*z, y) is True def test_solve_exponential(): assert _solve_exponential(3**(2*x) - 2**(x + 3), 0, x, S.Reals) == \ FiniteSet(-3*log(2)/(-2*log(3) + log(2))) assert _solve_exponential(2**y + 4**y, 1, y, S.Reals) == \ FiniteSet(log(-S(1)/2 + sqrt(5)/2)/log(2)) assert _solve_exponential(2**y + 4**y, 0, y, S.Reals) == \ S.EmptySet assert _solve_exponential(2**x + 3**x - 5**x, 0, x, S.Reals) == \ ConditionSet(x, Eq(2**x + 3**x - 5**x, 0), S.Reals) # end of exponential tests # logarithmic tests def test_logarithmic(): assert solveset_real(log(x - 3) + log(x + 3), x) == FiniteSet( -sqrt(10), sqrt(10)) assert solveset_real(log(x + 1) - log(2*x - 1), x) == FiniteSet(2) assert solveset_real(log(x + 3) + log(1 + 3/x) - 3, x) == FiniteSet( -3 + sqrt(-12 + exp(3))*exp(S(3)/2)/2 + exp(3)/2, -sqrt(-12 + exp(3))*exp(S(3)/2)/2 - 3 + exp(3)/2) eq = z - log(x) + log(y/(x*(-1 + y**2/x**2))) assert solveset_real(eq, x) == \ Intersection(S.Reals, FiniteSet(-sqrt(y**2 - y*exp(z)), sqrt(y**2 - y*exp(z)))) - \ Intersection(S.Reals, FiniteSet(-sqrt(y**2), sqrt(y**2))) assert solveset_real( log(3*x) - log(-x + 1) - log(4*x + 1), x) == FiniteSet(-S(1)/2, S(1)/2) assert solveset(log(x**y) - y*log(x), x, S.Reals) == S.Reals @XFAIL def test_uselogcombine_2(): eq = log(exp(2*x) + 1) + log(-tanh(x) + 1) - log(2) assert solveset_real(eq, x) == EmptySet() eq = log(8*x) - log(sqrt(x) + 1) - 2 assert solveset_real(eq, x) == EmptySet() def test_is_logarithmic(): assert _is_logarithmic(y, x) is False assert _is_logarithmic(log(x), x) is True assert _is_logarithmic(log(x) - 3, x) is True assert _is_logarithmic(log(x)*log(y), x) is True assert _is_logarithmic(log(x)**2, x) is False assert _is_logarithmic(log(x - 3) + log(x + 3), x) is True assert _is_logarithmic(log(x**y) - y*log(x), x) is True assert _is_logarithmic(sin(log(x)), x) is False assert _is_logarithmic(x + y, x) is False assert _is_logarithmic(log(3*x) - log(1 - x) + 4, x) is True assert _is_logarithmic(log(x) + log(y) + x, x) is False assert _is_logarithmic(log(log(x - 3)) + log(x - 3), x) is True assert _is_logarithmic(log(log(3) + x) + log(x), x) is True assert _is_logarithmic(log(x)*(y + 3) + log(x), y) is False def test_solve_logarithm(): y = Symbol('y') assert _solve_logarithm(log(x**y) - y*log(x), 0, x, S.Reals) == S.Reals y = Symbol('y', positive=True) assert _solve_logarithm(log(x)*log(y), 0, x, S.Reals) == FiniteSet(1) # end of logarithmic tests def test_linear_coeffs(): from sympy.solvers.solveset import linear_coeffs assert linear_coeffs(0, x) == [0, 0] assert all(i is S.Zero for i in linear_coeffs(0, x)) assert linear_coeffs(x + 2*y + 3, x, y) == [1, 2, 3] assert linear_coeffs(x + 2*y + 3, y, x) == [2, 1, 3] assert linear_coeffs(x + 2*x**2 + 3, x, x**2) == [1, 2, 3] raises(ValueError, lambda: linear_coeffs(x + 2*x**2 + x**3, x, x**2)) raises(ValueError, lambda: linear_coeffs(1/x*(x - 1) + 1/x, x)) assert linear_coeffs(a*(x + y), x, y) == [a, a, 0]
4a691aeb2483ea57b17ae33c0cbde0599cfbaa92dbbaca2311676440038a91b4
from sympy import (Eq, Matrix, pi, sin, sqrt, Symbol, Integral, Piecewise, symbols, Float, I, Rational) from mpmath import mnorm, mpf from sympy.solvers import nsolve from sympy.utilities.lambdify import lambdify from sympy.utilities.pytest import raises, XFAIL from sympy.utilities.decorator import conserve_mpmath_dps @XFAIL def test_nsolve_fail(): x = symbols('x') # Sometimes it is better to use the numerator (issue 4829) # but sometimes it is not (issue 11768) so leave this to # the discretion of the user ans = nsolve(x**2/(1 - x)/(1 - 2*x)**2 - 100, x, 0) assert ans > 0.46 and ans < 0.47 def test_nsolve_denominator(): x = symbols('x') # Test that nsolve uses the full expression (numerator and denominator). ans = nsolve((x**2 + 3*x + 2)/(x + 2), -2.1) # The root -2 was divided out, so make sure we don't find it. assert ans == -1.0 def test_nsolve(): # onedimensional x = Symbol('x') assert nsolve(sin(x), 2) - pi.evalf() < 1e-15 assert nsolve(Eq(2*x, 2), x, -10) == nsolve(2*x - 2, -10) # Testing checks on number of inputs raises(TypeError, lambda: nsolve(Eq(2*x, 2))) raises(TypeError, lambda: nsolve(Eq(2*x, 2), x, 1, 2)) # multidimensional x1 = Symbol('x1') x2 = Symbol('x2') f1 = 3 * x1**2 - 2 * x2**2 - 1 f2 = x1**2 - 2 * x1 + x2**2 + 2 * x2 - 8 f = Matrix((f1, f2)).T F = lambdify((x1, x2), f.T, modules='mpmath') for x0 in [(-1, 1), (1, -2), (4, 4), (-4, -4)]: x = nsolve(f, (x1, x2), x0, tol=1.e-8) assert mnorm(F(*x), 1) <= 1.e-10 # The Chinese mathematician Zhu Shijie was the very first to solve this # nonlinear system 700 years ago (z was added to make it 3-dimensional) x = Symbol('x') y = Symbol('y') z = Symbol('z') f1 = -x + 2*y f2 = (x**2 + x*(y**2 - 2) - 4*y) / (x + 4) f3 = sqrt(x**2 + y**2)*z f = Matrix((f1, f2, f3)).T F = lambdify((x, y, z), f.T, modules='mpmath') def getroot(x0): root = nsolve(f, (x, y, z), x0) assert mnorm(F(*root), 1) <= 1.e-8 return root assert list(map(round, getroot((1, 1, 1)))) == [2.0, 1.0, 0.0] assert nsolve([Eq( f1, 0), Eq(f2, 0), Eq(f3, 0)], [x, y, z], (1, 1, 1)) # just see that it works a = Symbol('a') assert abs(nsolve(1/(0.001 + a)**3 - 6/(0.9 - a)**3, a, 0.3) - mpf('0.31883011387318591')) < 1e-15 def test_issue_6408(): x = Symbol('x') assert nsolve(Piecewise((x, x < 1), (x**2, True)), x, 2) == 0.0 @XFAIL def test_issue_6408_fail(): x, y = symbols('x y') assert nsolve(Integral(x*y, (x, 0, 5)), y, 2) == 0.0 @conserve_mpmath_dps def test_increased_dps(): # Issue 8564 import mpmath mpmath.mp.dps = 128 x = Symbol('x') e1 = x**2 - pi q = nsolve(e1, x, 3.0) assert abs(sqrt(pi).evalf(128) - q) < 1e-128 def test_nsolve_precision(): x, y = symbols('x y') sol = nsolve(x**2 - pi, x, 3, prec=128) assert abs(sqrt(pi).evalf(128) - sol) < 1e-128 assert isinstance(sol, Float) sols = nsolve((y**2 - x, x**2 - pi), (x, y), (3, 3), prec=128) assert isinstance(sols, Matrix) assert sols.shape == (2, 1) assert abs(sqrt(pi).evalf(128) - sols[0]) < 1e-128 assert abs(sqrt(sqrt(pi)).evalf(128) - sols[1]) < 1e-128 assert all(isinstance(i, Float) for i in sols) def test_nsolve_complex(): x, y = symbols('x y') assert nsolve(x**2 + 2, 1j) == sqrt(2.)*I assert nsolve(x**2 + 2, I) == sqrt(2.)*I assert nsolve([x**2 + 2, y**2 + 2], [x, y], [I, I]) == Matrix([sqrt(2.)*I, sqrt(2.)*I]) assert nsolve([x**2 + 2, y**2 + 2], [x, y], [I, I]) == Matrix([sqrt(2.)*I, sqrt(2.)*I]) def test_nsolve_dict_kwarg(): x, y = symbols('x y') # one variable assert nsolve(x**2 - 2, 1, dict = True) == \ [{x: sqrt(2.)}] # one variable with complex solution assert nsolve(x**2 + 2, I, dict = True) == \ [{x: sqrt(2.)*I}] # two variables assert nsolve([x**2 + y**2 - 5, x**2 - y**2 + 1], [x, y], [1, 1], dict = True) == \ [{x: sqrt(2.), y: sqrt(3.)}] def test_nsolve_rational(): x = symbols('x') assert nsolve(x - Rational(1, 3), 0, prec=100) == Rational(1, 3).evalf(100) def test_issue_14950(): x = Matrix(symbols('t s')) x0 = Matrix([17, 23]) eqn = x + x0 assert nsolve(eqn, x, x0) == -x0 assert nsolve(eqn.T, x.T, x0.T) == -x0
163d753ea1102817c7eb2ec3e7f5007940b9decbe690094171d9fb516232e2c4
from sympy import (Derivative as D, Eq, exp, sin, Function, Symbol, symbols, cos, log) from sympy.core import S from sympy.solvers.pde import (pde_separate, pde_separate_add, pde_separate_mul, pdsolve, classify_pde, checkpdesol) from sympy.utilities.pytest import raises a, b, c, x, y = symbols('a b c x y') def test_pde_separate_add(): x, y, z, t = symbols("x,y,z,t") F, T, X, Y, Z, u = map(Function, 'FTXYZu') eq = Eq(D(u(x, t), x), D(u(x, t), t)*exp(u(x, t))) res = pde_separate_add(eq, u(x, t), [X(x), T(t)]) assert res == [D(X(x), x)*exp(-X(x)), D(T(t), t)*exp(T(t))] def test_pde_separate(): x, y, z, t = symbols("x,y,z,t") F, T, X, Y, Z, u = map(Function, 'FTXYZu') eq = Eq(D(u(x, t), x), D(u(x, t), t)*exp(u(x, t))) raises(ValueError, lambda: pde_separate(eq, u(x, t), [X(x), T(t)], 'div')) def test_pde_separate_mul(): x, y, z, t = symbols("x,y,z,t") c = Symbol("C", real=True) Phi = Function('Phi') F, R, T, X, Y, Z, u = map(Function, 'FRTXYZu') r, theta, z = symbols('r,theta,z') # Something simple :) eq = Eq(D(F(x, y, z), x) + D(F(x, y, z), y) + D(F(x, y, z), z), 0) # Duplicate arguments in functions raises( ValueError, lambda: pde_separate_mul(eq, F(x, y, z), [X(x), u(z, z)])) # Wrong number of arguments raises(ValueError, lambda: pde_separate_mul(eq, F(x, y, z), [X(x), Y(y)])) # Wrong variables: [x, y] -> [x, z] raises( ValueError, lambda: pde_separate_mul(eq, F(x, y, z), [X(t), Y(x, y)])) assert pde_separate_mul(eq, F(x, y, z), [Y(y), u(x, z)]) == \ [D(Y(y), y)/Y(y), -D(u(x, z), x)/u(x, z) - D(u(x, z), z)/u(x, z)] assert pde_separate_mul(eq, F(x, y, z), [X(x), Y(y), Z(z)]) == \ [D(X(x), x)/X(x), -D(Z(z), z)/Z(z) - D(Y(y), y)/Y(y)] # wave equation wave = Eq(D(u(x, t), t, t), c**2*D(u(x, t), x, x)) res = pde_separate_mul(wave, u(x, t), [X(x), T(t)]) assert res == [D(X(x), x, x)/X(x), D(T(t), t, t)/(c**2*T(t))] # Laplace equation in cylindrical coords eq = Eq(1/r * D(Phi(r, theta, z), r) + D(Phi(r, theta, z), r, 2) + 1/r**2 * D(Phi(r, theta, z), theta, 2) + D(Phi(r, theta, z), z, 2), 0) # Separate z res = pde_separate_mul(eq, Phi(r, theta, z), [Z(z), u(theta, r)]) assert res == [D(Z(z), z, z)/Z(z), -D(u(theta, r), r, r)/u(theta, r) - D(u(theta, r), r)/(r*u(theta, r)) - D(u(theta, r), theta, theta)/(r**2*u(theta, r))] # Lets use the result to create a new equation... eq = Eq(res[1], c) # ...and separate theta... res = pde_separate_mul(eq, u(theta, r), [T(theta), R(r)]) assert res == [D(T(theta), theta, theta)/T(theta), -r*D(R(r), r)/R(r) - r**2*D(R(r), r, r)/R(r) - c*r**2] # ...or r... res = pde_separate_mul(eq, u(theta, r), [R(r), T(theta)]) assert res == [r*D(R(r), r)/R(r) + r**2*D(R(r), r, r)/R(r) + c*r**2, -D(T(theta), theta, theta)/T(theta)] def test_issue_11726(): x, t = symbols("x t") f = symbols("f", cls=Function) X, T = symbols("X T", cls=Function) u = f(x, t) eq = u.diff(x, 2) - u.diff(t, 2) res = pde_separate(eq, u, [T(x), X(t)]) assert res == [D(T(x), x, x)/T(x),D(X(t), t, t)/X(t)] def test_pde_classify(): # When more number of hints are added, add tests for classifying here. f = Function('f') eq1 = a*f(x,y) + b*f(x,y).diff(x) + c*f(x,y).diff(y) eq2 = 3*f(x,y) + 2*f(x,y).diff(x) + f(x,y).diff(y) eq3 = a*f(x,y) + b*f(x,y).diff(x) + 2*f(x,y).diff(y) eq4 = x*f(x,y) + f(x,y).diff(x) + 3*f(x,y).diff(y) eq5 = x**2*f(x,y) + x*f(x,y).diff(x) + x*y*f(x,y).diff(y) eq6 = y*x**2*f(x,y) + y*f(x,y).diff(x) + f(x,y).diff(y) for eq in [eq1, eq2, eq3]: assert classify_pde(eq) == ('1st_linear_constant_coeff_homogeneous',) for eq in [eq4, eq5, eq6]: assert classify_pde(eq) == ('1st_linear_variable_coeff',) def test_checkpdesol(): f, F = map(Function, ['f', 'F']) eq1 = a*f(x,y) + b*f(x,y).diff(x) + c*f(x,y).diff(y) eq2 = 3*f(x,y) + 2*f(x,y).diff(x) + f(x,y).diff(y) eq3 = a*f(x,y) + b*f(x,y).diff(x) + 2*f(x,y).diff(y) for eq in [eq1, eq2, eq3]: assert checkpdesol(eq, pdsolve(eq))[0] eq4 = x*f(x,y) + f(x,y).diff(x) + 3*f(x,y).diff(y) eq5 = 2*f(x,y) + 1*f(x,y).diff(x) + 3*f(x,y).diff(y) eq6 = f(x,y) + 1*f(x,y).diff(x) + 3*f(x,y).diff(y) assert checkpdesol(eq4, [pdsolve(eq5), pdsolve(eq6)]) == [ (False, (x - 2)*F(3*x - y)*exp(-x/S(5) - 3*y/S(5))), (False, (x - 1)*F(3*x - y)*exp(-x/S(10) - 3*y/S(10)))] for eq in [eq4, eq5, eq6]: assert checkpdesol(eq, pdsolve(eq))[0] sol = pdsolve(eq4) sol4 = Eq(sol.lhs - sol.rhs, 0) raises(NotImplementedError, lambda: checkpdesol(eq4, sol4, solve_for_func=False)) def test_solvefun(): f, F, G, H = map(Function, ['f', 'F', 'G', 'H']) eq1 = f(x,y) + f(x,y).diff(x) + f(x,y).diff(y) assert pdsolve(eq1) == Eq(f(x, y), F(x - y)*exp(-x/2 - y/2)) assert pdsolve(eq1, solvefun=G) == Eq(f(x, y), G(x - y)*exp(-x/2 - y/2)) assert pdsolve(eq1, solvefun=H) == Eq(f(x, y), H(x - y)*exp(-x/2 - y/2)) def test_pde_1st_linear_constant_coeff_homogeneous(): f, F = map(Function, ['f', 'F']) u = f(x, y) eq = 2*u + u.diff(x) + u.diff(y) assert classify_pde(eq) == ('1st_linear_constant_coeff_homogeneous',) sol = pdsolve(eq) assert sol == Eq(u, F(x - y)*exp(-x - y)) assert checkpdesol(eq, sol)[0] eq = 4 + (3*u.diff(x)/u) + (2*u.diff(y)/u) assert classify_pde(eq) == ('1st_linear_constant_coeff_homogeneous',) sol = pdsolve(eq) assert sol == Eq(u, F(2*x - 3*y)*exp(-S(12)*x/13 - S(8)*y/13)) assert checkpdesol(eq, sol)[0] eq = u + (6*u.diff(x)) + (7*u.diff(y)) assert classify_pde(eq) == ('1st_linear_constant_coeff_homogeneous',) sol = pdsolve(eq) assert sol == Eq(u, F(7*x - 6*y)*exp(-6*x/S(85) - 7*y/S(85))) assert checkpdesol(eq, sol)[0] eq = a*u + b*u.diff(x) + c*u.diff(y) sol = pdsolve(eq) assert checkpdesol(eq, sol)[0] def test_pde_1st_linear_constant_coeff(): f, F = map(Function, ['f', 'F']) u = f(x,y) eq = -2*u.diff(x) + 4*u.diff(y) + 5*u - exp(x + 3*y) sol = pdsolve(eq) assert sol == Eq(f(x,y), (F(4*x + 2*y) + exp(x/S(2) + 4*y)/S(15))*exp(x/S(2) - y)) assert classify_pde(eq) == ('1st_linear_constant_coeff', '1st_linear_constant_coeff_Integral') assert checkpdesol(eq, sol)[0] eq = (u.diff(x)/u) + (u.diff(y)/u) + 1 - (exp(x + y)/u) sol = pdsolve(eq) assert sol == Eq(f(x, y), F(x - y)*exp(-x/2 - y/2) + exp(x + y)/S(3)) assert classify_pde(eq) == ('1st_linear_constant_coeff', '1st_linear_constant_coeff_Integral') assert checkpdesol(eq, sol)[0] eq = 2*u + -u.diff(x) + 3*u.diff(y) + sin(x) sol = pdsolve(eq) assert sol == Eq(f(x, y), F(3*x + y)*exp(x/S(5) - 3*y/S(5)) - 2*sin(x)/S(5) - cos(x)/S(5)) assert classify_pde(eq) == ('1st_linear_constant_coeff', '1st_linear_constant_coeff_Integral') assert checkpdesol(eq, sol)[0] eq = u + u.diff(x) + u.diff(y) + x*y sol = pdsolve(eq) assert sol == Eq(f(x, y), -x*y + x + y + F(x - y)*exp(-x/S(2) - y/S(2)) - 2) assert classify_pde(eq) == ('1st_linear_constant_coeff', '1st_linear_constant_coeff_Integral') assert checkpdesol(eq, sol)[0] eq = u + u.diff(x) + u.diff(y) + log(x) assert classify_pde(eq) == ('1st_linear_constant_coeff', '1st_linear_constant_coeff_Integral') def test_pdsolve_all(): f, F = map(Function, ['f', 'F']) u = f(x,y) eq = u + u.diff(x) + u.diff(y) + x**2*y sol = pdsolve(eq, hint = 'all') keys = ['1st_linear_constant_coeff', '1st_linear_constant_coeff_Integral', 'default', 'order'] assert sorted(sol.keys()) == keys assert sol['order'] == 1 assert sol['default'] == '1st_linear_constant_coeff' assert sol['1st_linear_constant_coeff'] == Eq(f(x, y), -x**2*y + x**2 + 2*x*y - 4*x - 2*y + F(x - y)*exp(-x/S(2) - y/S(2)) + 6) def test_pdsolve_variable_coeff(): f, F = map(Function, ['f', 'F']) u = f(x, y) eq = x*(u.diff(x)) - y*(u.diff(y)) + y**2*u - y**2 sol = pdsolve(eq, hint="1st_linear_variable_coeff") assert sol == Eq(u, F(x*y)*exp(y**2/2) + 1) assert checkpdesol(eq, sol)[0] eq = x**2*u + x*u.diff(x) + x*y*u.diff(y) sol = pdsolve(eq, hint='1st_linear_variable_coeff') assert sol == Eq(u, F(y*exp(-x))*exp(-x**2/2)) assert checkpdesol(eq, sol)[0] eq = y*x**2*u + y*u.diff(x) + u.diff(y) sol = pdsolve(eq, hint='1st_linear_variable_coeff') assert sol == Eq(u, F(-2*x + y**2)*exp(-x**3/3)) assert checkpdesol(eq, sol)[0] eq = exp(x)**2*(u.diff(x)) + y sol = pdsolve(eq, hint='1st_linear_variable_coeff') assert sol == Eq(u, y*exp(-2*x)/2 + F(y)) assert checkpdesol(eq, sol)[0] eq = exp(2*x)*(u.diff(y)) + y*u - u sol = pdsolve(eq, hint='1st_linear_variable_coeff') assert sol == Eq(u, exp((-y**2 + 2*y + 2*F(x))*exp(-2*x)/2))
4629be4c956fff91d6cc9549875e14fd64e1439d90f22b56b988edb3bd020099
from sympy import (acos, acosh, asinh, atan, cos, Derivative, diff, dsolve, Dummy, Eq, Ne, erf, erfi, exp, Function, I, Integral, LambertW, log, O, pi, Rational, rootof, S, simplify, sin, sqrt, Subs, Symbol, tan, asin, sinh, Piecewise, symbols, Poly, sec, Ei, re, im) from sympy.solvers.ode import (_undetermined_coefficients_match, checkodesol, classify_ode, classify_sysode, constant_renumber, constantsimp, homogeneous_order, infinitesimals, checkinfsol, checksysodesol, solve_ics, dsolve, get_numbered_constants) from sympy.solvers.deutils import ode_order from sympy.utilities.pytest import XFAIL, skip, raises, slow, ON_TRAVIS C0, C1, C2, C3, C4, C5, C6, C7, C8, C9, C10 = symbols('C0:11') u, x, y, z = symbols('u,x:z', real=True) f = Function('f') g = Function('g') h = Function('h') # Note: the tests below may fail (but still be correct) if ODE solver, # the integral engine, solve(), or even simplify() changes. Also, in # differently formatted solutions, the arbitrary constants might not be # equal. Using specific hints in tests can help to avoid this. # Tests of order higher than 1 should run the solutions through # constant_renumber because it will normalize it (constant_renumber causes # dsolve() to return different results on different machines) def test_linear_2eq_order1(): x, y, z = symbols('x, y, z', cls=Function) k, l, m, n = symbols('k, l, m, n', Integer=True) t = Symbol('t') x0, y0 = symbols('x0, y0', cls=Function) eq1 = (Eq(diff(x(t),t), 9*y(t)), Eq(diff(y(t),t), 12*x(t))) sol1 = [Eq(x(t), 9*C1*exp(6*sqrt(3)*t) + 9*C2*exp(-6*sqrt(3)*t)), \ Eq(y(t), 6*sqrt(3)*C1*exp(6*sqrt(3)*t) - 6*sqrt(3)*C2*exp(-6*sqrt(3)*t))] assert checksysodesol(eq1, sol1) == (True, [0, 0]) eq2 = (Eq(diff(x(t),t), 2*x(t) + 4*y(t)), Eq(diff(y(t),t), 12*x(t) + 41*y(t))) sol2 = [Eq(x(t), 4*C1*exp(t*(sqrt(1713)/2 + S(43)/2)) + 4*C2*exp(t*(-sqrt(1713)/2 + S(43)/2))), \ Eq(y(t), C1*(S(39)/2 + sqrt(1713)/2)*exp(t*(sqrt(1713)/2 + S(43)/2)) + \ C2*(-sqrt(1713)/2 + S(39)/2)*exp(t*(-sqrt(1713)/2 + S(43)/2)))] assert checksysodesol(eq2, sol2) == (True, [0, 0]) eq3 = (Eq(diff(x(t),t), x(t) + y(t)), Eq(diff(y(t),t), -2*x(t) + 2*y(t))) sol3 = [Eq(x(t), (C1*cos(sqrt(7)*t/2) + C2*sin(sqrt(7)*t/2))*exp(3*t/2)), \ Eq(y(t), (C1*(-sqrt(7)*sin(sqrt(7)*t/2)/2 + cos(sqrt(7)*t/2)/2) + \ C2*(sin(sqrt(7)*t/2)/2 + sqrt(7)*cos(sqrt(7)*t/2)/2))*exp(3*t/2))] assert checksysodesol(eq3, sol3) == (True, [0, 0]) eq4 = (Eq(diff(x(t),t), x(t) + y(t) + 9), Eq(diff(y(t),t), 2*x(t) + 5*y(t) + 23)) sol4 = [Eq(x(t), C1*exp(t*(sqrt(6) + 3)) + C2*exp(t*(-sqrt(6) + 3)) - S(22)/3), \ Eq(y(t), C1*(2 + sqrt(6))*exp(t*(sqrt(6) + 3)) + C2*(-sqrt(6) + 2)*exp(t*(-sqrt(6) + 3)) - S(5)/3)] assert checksysodesol(eq4, sol4) == (True, [0, 0]) eq5 = (Eq(diff(x(t),t), x(t) + y(t) + 81), Eq(diff(y(t),t), -2*x(t) + y(t) + 23)) sol5 = [Eq(x(t), (C1*cos(sqrt(2)*t) + C2*sin(sqrt(2)*t))*exp(t) - S(58)/3), \ Eq(y(t), (-sqrt(2)*C1*sin(sqrt(2)*t) + sqrt(2)*C2*cos(sqrt(2)*t))*exp(t) - S(185)/3)] assert checksysodesol(eq5, sol5) == (True, [0, 0]) eq6 = (Eq(diff(x(t),t), 5*t*x(t) + 2*y(t)), Eq(diff(y(t),t), 2*x(t) + 5*t*y(t))) sol6 = [Eq(x(t), (C1*exp(2*t) + C2*exp(-2*t))*exp(S(5)/2*t**2)), \ Eq(y(t), (C1*exp(2*t) - C2*exp(-2*t))*exp(S(5)/2*t**2))] s = dsolve(eq6) assert checksysodesol(eq6, sol6) == (True, [0, 0]) eq7 = (Eq(diff(x(t),t), 5*t*x(t) + t**2*y(t)), Eq(diff(y(t),t), -t**2*x(t) + 5*t*y(t))) sol7 = [Eq(x(t), (C1*cos((t**3)/3) + C2*sin((t**3)/3))*exp(S(5)/2*t**2)), \ Eq(y(t), (-C1*sin((t**3)/3) + C2*cos((t**3)/3))*exp(S(5)/2*t**2))] assert checksysodesol(eq7, sol7) == (True, [0, 0]) eq8 = (Eq(diff(x(t),t), 5*t*x(t) + t**2*y(t)), Eq(diff(y(t),t), -t**2*x(t) + (5*t+9*t**2)*y(t))) sol8 = [Eq(x(t), (C1*exp((sqrt(77)/2 + S(9)/2)*(t**3)/3) + \ C2*exp((-sqrt(77)/2 + S(9)/2)*(t**3)/3))*exp(S(5)/2*t**2)), \ Eq(y(t), (C1*(sqrt(77)/2 + S(9)/2)*exp((sqrt(77)/2 + S(9)/2)*(t**3)/3) + \ C2*(-sqrt(77)/2 + S(9)/2)*exp((-sqrt(77)/2 + S(9)/2)*(t**3)/3))*exp(S(5)/2*t**2))] assert checksysodesol(eq8, sol8) == (True, [0, 0]) eq10 = (Eq(diff(x(t),t), 5*t*x(t) + t**2*y(t)), Eq(diff(y(t),t), (1-t**2)*x(t) + (5*t+9*t**2)*y(t))) sol10 = [Eq(x(t), C1*x0(t) + C2*x0(t)*Integral(t**2*exp(Integral(5*t, t))*exp(Integral(9*t**2 + 5*t, t))/x0(t)**2, t)), \ Eq(y(t), C1*y0(t) + C2*(y0(t)*Integral(t**2*exp(Integral(5*t, t))*exp(Integral(9*t**2 + 5*t, t))/x0(t)**2, t) + \ exp(Integral(5*t, t))*exp(Integral(9*t**2 + 5*t, t))/x0(t)))] s = dsolve(eq10) assert s == sol10 # too complicated to test with subs and simplify # assert checksysodesol(eq10, sol10) == (True, [0, 0]) # this one fails def test_linear_2eq_order1_nonhomog_linear(): e = [Eq(diff(f(x), x), f(x) + g(x) + 5*x), Eq(diff(g(x), x), f(x) - g(x))] raises(NotImplementedError, lambda: dsolve(e)) def test_linear_2eq_order1_nonhomog(): # Note: once implemented, add some tests esp. with resonance e = [Eq(diff(f(x), x), f(x) + exp(x)), Eq(diff(g(x), x), f(x) + g(x) + x*exp(x))] raises(NotImplementedError, lambda: dsolve(e)) def test_linear_2eq_order1_type2_degen(): e = [Eq(diff(f(x), x), f(x) + 5), Eq(diff(g(x), x), f(x) + 7)] s1 = [Eq(f(x), C1*exp(x) - 5), Eq(g(x), C1*exp(x) - C2 + 2*x - 5)] assert checksysodesol(e, s1) == (True, [0, 0]) def test_dsolve_linear_2eq_order1_diag_triangular(): e = [Eq(diff(f(x), x), f(x)), Eq(diff(g(x), x), g(x))] s1 = [Eq(f(x), C1*exp(x)), Eq(g(x), C2*exp(x))] assert checksysodesol(e, s1) == (True, [0, 0]) e = [Eq(diff(f(x), x), 2*f(x)), Eq(diff(g(x), x), 3*f(x) + 7*g(x))] s1 = [Eq(f(x), -5*C2*exp(2*x)), Eq(g(x), 5*C1*exp(7*x) + 3*C2*exp(2*x))] assert checksysodesol(e, s1) == (True, [0, 0]) def test_sysode_linear_2eq_order1_type1_D_lt_0(): e = [Eq(diff(f(x), x), -9*I*f(x) - 4*g(x)), Eq(diff(g(x), x), -4*I*g(x))] s1 = [Eq(f(x), -4*C1*exp(-4*I*x) - 4*C2*exp(-9*I*x)), \ Eq(g(x), 5*I*C1*exp(-4*I*x))] assert checksysodesol(e, s1) == (True, [0, 0]) def test_sysode_linear_2eq_order1_type1_D_lt_0_b_eq_0(): e = [Eq(diff(f(x), x), -9*I*f(x)), Eq(diff(g(x), x), -4*I*g(x))] s1 = [Eq(f(x), -5*I*C2*exp(-9*I*x)), Eq(g(x), 5*I*C1*exp(-4*I*x))] assert checksysodesol(e, s1) == (True, [0, 0]) def test_sysode_linear_2eq_order1_many_zeros(): t = Symbol('t') corner_cases = [(0, 0, 0, 0), (1, 0, 0, 0), (0, 1, 0, 0), (0, 0, 1, 0), (0, 0, 0, 1), (1, 0, 0, I), (I, 0, 0, -I), (0, I, 0, 0), (0, I, I, 0)] s1 = [[Eq(f(t), C1), Eq(g(t), C2)], [Eq(f(t), C1*exp(t)), Eq(g(t), -C2)], [Eq(f(t), C1 + C2*t), Eq(g(t), C2)], [Eq(f(t), C2), Eq(g(t), C1 + C2*t)], [Eq(f(t), -C2), Eq(g(t), C1*exp(t))], [Eq(f(t), C1*(1 - I)*exp(t)), Eq(g(t), C2*(-1 + I)*exp(I*t))], [Eq(f(t), 2*I*C1*exp(I*t)), Eq(g(t), -2*I*C2*exp(-I*t))], [Eq(f(t), I*C1 + I*C2*t), Eq(g(t), C2)], [Eq(f(t), I*C1*exp(I*t) + I*C2*exp(-I*t)), \ Eq(g(t), I*C1*exp(I*t) - I*C2*exp(-I*t))] ] for r, sol in zip(corner_cases, s1): eq = [Eq(diff(f(t), t), r[0]*f(t) + r[1]*g(t)), Eq(diff(g(t), t), r[2]*f(t) + r[3]*g(t))] assert checksysodesol(eq, sol) == (True, [0, 0]) def test_dsolve_linsystem_symbol_piecewise(): u = Symbol('u') # XXX it's more complicated with real u eq = (Eq(diff(f(x), x), 2*f(x) + g(x)), Eq(diff(g(x), x), u*f(x))) s1 = [Eq(f(x), Piecewise((C1*exp(x*(sqrt(4*u + 4)/2 + 1)) + C2*exp(x*(-sqrt(4*u + 4)/2 + 1)), Ne(4*u + 4, 0)), ((C1 + C2*(x + Piecewise((0, Eq(sqrt(4*u + 4)/2 + 1, 2)), (1/(-sqrt(4*u + 4)/2 + 1), True))))*exp(x*(sqrt(4*u + 4)/2 + 1)), True))), Eq(g(x), Piecewise((C1*(sqrt(4*u + 4)/2 - 1)*exp(x*(sqrt(4*u + 4)/2 + 1)) + C2*(-sqrt(4*u + 4)/2 - 1)*exp(x*(-sqrt(4*u + 4)/2 + 1)), Ne(4*u + 4, 0)), ((C1*(sqrt(4*u + 4)/2 - 1) + C2*(x*(sqrt(4*u + 4)/2 - 1) + Piecewise((1, Eq(sqrt(4*u + 4)/2 + 1, 2)), (0, True))))*exp(x*(sqrt(4*u + 4)/2 + 1)), True)))] assert dsolve(eq) == s1 # FIXME: assert checksysodesol(eq, s) == (True, [0, 0]) # Remove lines below when checksysodesol works s = [(l.lhs, l.rhs) for l in s1] for v in [0, 7, -42, 5*I, 3 + 4*I]: assert eq[0].subs(s).subs(u, v).doit().simplify() assert eq[1].subs(s).subs(u, v).doit().simplify() # example from https://groups.google.com/d/msg/sympy/xmzoqW6tWaE/sf0bgQrlCgAJ i, r1, c1, r2, c2, t = symbols('i, r1, c1, r2, c2, t') x1 = Function('x1') x2 = Function('x2') eq1 = r1*c1*Derivative(x1(t), t) + x1(t) - x2(t) - r1*i eq2 = r2*c1*Derivative(x1(t), t) + r2*c2*Derivative(x2(t), t) + x2(t) - r2*i sol = dsolve((eq1, eq2)) # FIXME: assert checksysodesol(eq, sol) == (True, [0, 0]) # Remove line below when checksysodesol works assert all(s.has(Piecewise) for s in sol) @slow def test_linear_2eq_order2(): x, y, z = symbols('x, y, z', cls=Function) k, l, m, n = symbols('k, l, m, n', Integer=True) t, l = symbols('t, l') x0, y0 = symbols('x0, y0', cls=Function) eq1 = (Eq(diff(x(t),t,t), 5*x(t) + 43*y(t)), Eq(diff(y(t),t,t), x(t) + 9*y(t))) sol1 = [Eq(x(t), 43*C1*exp(t*rootof(l**4 - 14*l**2 + 2, 0)) + 43*C2*exp(t*rootof(l**4 - 14*l**2 + 2, 1)) + \ 43*C3*exp(t*rootof(l**4 - 14*l**2 + 2, 2)) + 43*C4*exp(t*rootof(l**4 - 14*l**2 + 2, 3))), \ Eq(y(t), C1*(rootof(l**4 - 14*l**2 + 2, 0)**2 - 5)*exp(t*rootof(l**4 - 14*l**2 + 2, 0)) + \ C2*(rootof(l**4 - 14*l**2 + 2, 1)**2 - 5)*exp(t*rootof(l**4 - 14*l**2 + 2, 1)) + \ C3*(rootof(l**4 - 14*l**2 + 2, 2)**2 - 5)*exp(t*rootof(l**4 - 14*l**2 + 2, 2)) + \ C4*(rootof(l**4 - 14*l**2 + 2, 3)**2 - 5)*exp(t*rootof(l**4 - 14*l**2 + 2, 3)))] assert dsolve(eq1) == sol1 # FIXME: assert checksysodesol(eq1, sol1) == (True, [0, 0]) # this one fails eq2 = (Eq(diff(x(t),t,t), 8*x(t)+3*y(t)+31), Eq(diff(y(t),t,t), 9*x(t)+7*y(t)+12)) sol2 = [Eq(x(t), 3*C1*exp(t*rootof(l**4 - 15*l**2 + 29, 0)) + 3*C2*exp(t*rootof(l**4 - 15*l**2 + 29, 1)) + \ 3*C3*exp(t*rootof(l**4 - 15*l**2 + 29, 2)) + 3*C4*exp(t*rootof(l**4 - 15*l**2 + 29, 3)) - S(181)/29), \ Eq(y(t), C1*(rootof(l**4 - 15*l**2 + 29, 0)**2 - 8)*exp(t*rootof(l**4 - 15*l**2 + 29, 0)) + \ C2*(rootof(l**4 - 15*l**2 + 29, 1)**2 - 8)*exp(t*rootof(l**4 - 15*l**2 + 29, 1)) + \ C3*(rootof(l**4 - 15*l**2 + 29, 2)**2 - 8)*exp(t*rootof(l**4 - 15*l**2 + 29, 2)) + \ C4*(rootof(l**4 - 15*l**2 + 29, 3)**2 - 8)*exp(t*rootof(l**4 - 15*l**2 + 29, 3)) + S(183)/29)] assert dsolve(eq2) == sol2 # FIXME: assert checksysodesol(eq2, sol2) == (True, [0, 0]) # this one fails eq3 = (Eq(diff(x(t),t,t) - 9*diff(y(t),t) + 7*x(t),0), Eq(diff(y(t),t,t) + 9*diff(x(t),t) + 7*y(t),0)) sol3 = [Eq(x(t), C1*cos(t*(S(9)/2 + sqrt(109)/2)) + C2*sin(t*(S(9)/2 + sqrt(109)/2)) + C3*cos(t*(-sqrt(109)/2 + S(9)/2)) + \ C4*sin(t*(-sqrt(109)/2 + S(9)/2))), Eq(y(t), -C1*sin(t*(S(9)/2 + sqrt(109)/2)) + C2*cos(t*(S(9)/2 + sqrt(109)/2)) - \ C3*sin(t*(-sqrt(109)/2 + S(9)/2)) + C4*cos(t*(-sqrt(109)/2 + S(9)/2)))] assert dsolve(eq3) == sol3 assert checksysodesol(eq3, sol3) == (True, [0, 0]) eq4 = (Eq(diff(x(t),t,t), 9*t*diff(y(t),t)-9*y(t)), Eq(diff(y(t),t,t),7*t*diff(x(t),t)-7*x(t))) sol4 = [Eq(x(t), C3*t + t*Integral((9*C1*exp(3*sqrt(7)*t**2/2) + 9*C2*exp(-3*sqrt(7)*t**2/2))/t**2, t)), \ Eq(y(t), C4*t + t*Integral((3*sqrt(7)*C1*exp(3*sqrt(7)*t**2/2) - 3*sqrt(7)*C2*exp(-3*sqrt(7)*t**2/2))/t**2, t))] assert dsolve(eq4) == sol4 assert checksysodesol(eq4, sol4) == (True, [0, 0]) eq5 = (Eq(diff(x(t),t,t), (log(t)+t**2)*diff(x(t),t)+(log(t)+t**2)*3*diff(y(t),t)), Eq(diff(y(t),t,t), \ (log(t)+t**2)*2*diff(x(t),t)+(log(t)+t**2)*9*diff(y(t),t))) sol5 = [Eq(x(t), -sqrt(22)*(C1*Integral(exp((-sqrt(22) + 5)*Integral(t**2 + log(t), t)), t) + C2 - \ C3*Integral(exp((sqrt(22) + 5)*Integral(t**2 + log(t), t)), t) - C4 - \ (sqrt(22) + 5)*(C1*Integral(exp((-sqrt(22) + 5)*Integral(t**2 + log(t), t)), t) + C2) + \ (-sqrt(22) + 5)*(C3*Integral(exp((sqrt(22) + 5)*Integral(t**2 + log(t), t)), t) + C4))/88), \ Eq(y(t), -sqrt(22)*(C1*Integral(exp((-sqrt(22) + 5)*Integral(t**2 + log(t), t)), t) + \ C2 - C3*Integral(exp((sqrt(22) + 5)*Integral(t**2 + log(t), t)), t) - C4)/44)] assert dsolve(eq5) == sol5 assert checksysodesol(eq5, sol5) == (True, [0, 0]) eq6 = (Eq(diff(x(t),t,t), log(t)*t*diff(y(t),t) - log(t)*y(t)), Eq(diff(y(t),t,t), log(t)*t*diff(x(t),t) - log(t)*x(t))) sol6 = [Eq(x(t), C3*t + t*Integral((C1*exp(Integral(t*log(t), t)) + \ C2*exp(-Integral(t*log(t), t)))/t**2, t)), Eq(y(t), C4*t + t*Integral((C1*exp(Integral(t*log(t), t)) - \ C2*exp(-Integral(t*log(t), t)))/t**2, t))] assert dsolve(eq6) == sol6 assert checksysodesol(eq6, sol6) == (True, [0, 0]) eq7 = (Eq(diff(x(t),t,t), log(t)*(t*diff(x(t),t) - x(t)) + exp(t)*(t*diff(y(t),t) - y(t))), \ Eq(diff(y(t),t,t), (t**2)*(t*diff(x(t),t) - x(t)) + (t)*(t*diff(y(t),t) - y(t)))) sol7 = [Eq(x(t), C3*t + t*Integral((C1*x0(t) + C2*x0(t)*Integral(t*exp(t)*exp(Integral(t**2, t))*\ exp(Integral(t*log(t), t))/x0(t)**2, t))/t**2, t)), Eq(y(t), C4*t + t*Integral((C1*y0(t) + \ C2*(y0(t)*Integral(t*exp(t)*exp(Integral(t**2, t))*exp(Integral(t*log(t), t))/x0(t)**2, t) + \ exp(Integral(t**2, t))*exp(Integral(t*log(t), t))/x0(t)))/t**2, t))] assert dsolve(eq7) == sol7 # FIXME: assert checksysodesol(eq7, sol7) == (True, [0, 0]) eq8 = (Eq(diff(x(t),t,t), t*(4*x(t) + 9*y(t))), Eq(diff(y(t),t,t), t*(12*x(t) - 6*y(t)))) sol8 = ("[Eq(x(t), -sqrt(133)*((-sqrt(133) - 1)*(C2*(133*t**8/24 - t**3/6 + sqrt(133)*t**3/2 + 1) + " "C1*t*(sqrt(133)*t**4/6 - t**3/12 + 1) + O(t**6)) - (-1 + sqrt(133))*(C2*(-sqrt(133)*t**3/6 - t**3/6 + 1) + " "C1*t*(-sqrt(133)*t**3/12 - t**3/12 + 1) + O(t**6)) - 4*C2*(133*t**8/24 - t**3/6 + sqrt(133)*t**3/2 + 1) + " "4*C2*(-sqrt(133)*t**3/6 - t**3/6 + 1) - 4*C1*t*(sqrt(133)*t**4/6 - t**3/12 + 1) + " "4*C1*t*(-sqrt(133)*t**3/12 - t**3/12 + 1) + O(t**6))/3192), Eq(y(t), -sqrt(133)*(-C2*(133*t**8/24 - t**3/6 + " "sqrt(133)*t**3/2 + 1) + C2*(-sqrt(133)*t**3/6 - t**3/6 + 1) - C1*t*(sqrt(133)*t**4/6 - t**3/12 + 1) + " "C1*t*(-sqrt(133)*t**3/12 - t**3/12 + 1) + O(t**6))/266)]") assert str(dsolve(eq8)) == sol8 # FIXME: assert checksysodesol(eq8, sol8) == (True, [0, 0]) eq9 = (Eq(diff(x(t),t,t), t*(4*diff(x(t),t) + 9*diff(y(t),t))), Eq(diff(y(t),t,t), t*(12*diff(x(t),t) - 6*diff(y(t),t)))) sol9 = [Eq(x(t), -sqrt(133)*(4*C1*Integral(exp((-sqrt(133) - 1)*Integral(t, t)), t) + 4*C2 - \ 4*C3*Integral(exp((-1 + sqrt(133))*Integral(t, t)), t) - 4*C4 - (-1 + sqrt(133))*(C1*Integral(exp((-sqrt(133) - \ 1)*Integral(t, t)), t) + C2) + (-sqrt(133) - 1)*(C3*Integral(exp((-1 + sqrt(133))*Integral(t, t)), t) + \ C4))/3192), Eq(y(t), -sqrt(133)*(C1*Integral(exp((-sqrt(133) - 1)*Integral(t, t)), t) + C2 - \ C3*Integral(exp((-1 + sqrt(133))*Integral(t, t)), t) - C4)/266)] assert dsolve(eq9) == sol9 assert checksysodesol(eq9, sol9) == (True, [0, 0]) eq10 = (t**2*diff(x(t),t,t) + 3*t*diff(x(t),t) + 4*t*diff(y(t),t) + 12*x(t) + 9*y(t), \ t**2*diff(y(t),t,t) + 2*t*diff(x(t),t) - 5*t*diff(y(t),t) + 15*x(t) + 8*y(t)) sol10 = [Eq(x(t), -C1*(-2*sqrt(-346/(3*(S(4333)/4 + 5*sqrt(70771857)/36)**(S(1)/3)) + 4 + 2*(S(4333)/4 + \ 5*sqrt(70771857)/36)**(S(1)/3)) + 13 + 2*sqrt(-284/sqrt(-346/(3*(S(4333)/4 + 5*sqrt(70771857)/36)**(S(1)/3)) + \ 4 + 2*(S(4333)/4 + 5*sqrt(70771857)/36)**(S(1)/3)) - 2*(S(4333)/4 + 5*sqrt(70771857)/36)**(S(1)/3) + 8 + \ 346/(3*(S(4333)/4 + 5*sqrt(70771857)/36)**(S(1)/3))))*exp((-sqrt(-346/(3*(S(4333)/4 + 5*sqrt(70771857)/36)**(S(1)/3)) + \ 4 + 2*(S(4333)/4 + 5*sqrt(70771857)/36)**(S(1)/3))/2 + 1 + sqrt(-284/sqrt(-346/(3*(S(4333)/4 + \ 5*sqrt(70771857)/36)**(S(1)/3)) + 4 + 2*(S(4333)/4 + 5*sqrt(70771857)/36)**(S(1)/3)) - 2*(S(4333)/4 + \ 5*sqrt(70771857)/36)**(S(1)/3) + 8 + 346/(3*(S(4333)/4 + 5*sqrt(70771857)/36)**(S(1)/3)))/2)*log(t)) - \ C2*(-2*sqrt(-346/(3*(S(4333)/4 + 5*sqrt(70771857)/36)**(S(1)/3)) + 4 + 2*(S(4333)/4 + 5*sqrt(70771857)/36)**(S(1)/3)) + \ 13 - 2*sqrt(-284/sqrt(-346/(3*(S(4333)/4 + 5*sqrt(70771857)/36)**(S(1)/3)) + 4 + 2*(S(4333)/4 + \ 5*sqrt(70771857)/36)**(S(1)/3)) - 2*(S(4333)/4 + 5*sqrt(70771857)/36)**(S(1)/3) + 8 + 346/(3*(S(4333)/4 + \ 5*sqrt(70771857)/36)**(S(1)/3))))*exp((-sqrt(-346/(3*(S(4333)/4 + 5*sqrt(70771857)/36)**(S(1)/3)) + 4 + \ 2*(S(4333)/4 + 5*sqrt(70771857)/36)**(S(1)/3))/2 + 1 - sqrt(-284/sqrt(-346/(3*(S(4333)/4 + 5*sqrt(70771857)/36)**(S(1)/3)) + \ 4 + 2*(S(4333)/4 + 5*sqrt(70771857)/36)**(S(1)/3)) - 2*(S(4333)/4 + 5*sqrt(70771857)/36)**(S(1)/3) + 8 + 346/(3*(S(4333)/4 + \ 5*sqrt(70771857)/36)**(S(1)/3)))/2)*log(t)) - C3*t**(1 + sqrt(-346/(3*(S(4333)/4 + 5*sqrt(70771857)/36)**(S(1)/3)) + 4 + \ 2*(S(4333)/4 + 5*sqrt(70771857)/36)**(S(1)/3))/2 + sqrt(-2*(S(4333)/4 + 5*sqrt(70771857)/36)**(S(1)/3) + 8 + 346/(3*(S(4333)/4 + \ 5*sqrt(70771857)/36)**(S(1)/3)) + 284/sqrt(-346/(3*(S(4333)/4 + 5*sqrt(70771857)/36)**(S(1)/3)) + 4 + 2*(S(4333)/4 + \ 5*sqrt(70771857)/36)**(S(1)/3)))/2)*(2*sqrt(-346/(3*(S(4333)/4 + 5*sqrt(70771857)/36)**(S(1)/3)) + 4 + 2*(S(4333)/4 + \ 5*sqrt(70771857)/36)**(S(1)/3)) + 13 + 2*sqrt(-2*(S(4333)/4 + 5*sqrt(70771857)/36)**(S(1)/3) + 8 + 346/(3*(S(4333)/4 + \ 5*sqrt(70771857)/36)**(S(1)/3)) + 284/sqrt(-346/(3*(S(4333)/4 + 5*sqrt(70771857)/36)**(S(1)/3)) + 4 + 2*(S(4333)/4 + \ 5*sqrt(70771857)/36)**(S(1)/3)))) - C4*t**(-sqrt(-2*(S(4333)/4 + 5*sqrt(70771857)/36)**(S(1)/3) + 8 + 346/(3*(S(4333)/4 + \ 5*sqrt(70771857)/36)**(S(1)/3)) + 284/sqrt(-346/(3*(S(4333)/4 + 5*sqrt(70771857)/36)**(S(1)/3)) + 4 + 2*(S(4333)/4 + \ 5*sqrt(70771857)/36)**(S(1)/3)))/2 + 1 + sqrt(-346/(3*(S(4333)/4 + 5*sqrt(70771857)/36)**(S(1)/3)) + 4 + 2*(S(4333)/4 + \ 5*sqrt(70771857)/36)**(S(1)/3))/2)*(-2*sqrt(-2*(S(4333)/4 + 5*sqrt(70771857)/36)**(S(1)/3) + 8 + 346/(3*(S(4333)/4 + \ 5*sqrt(70771857)/36)**(S(1)/3)) + 284/sqrt(-346/(3*(S(4333)/4 + 5*sqrt(70771857)/36)**(S(1)/3)) + 4 + 2*(S(4333)/4 + \ 5*sqrt(70771857)/36)**(S(1)/3))) + 2*sqrt(-346/(3*(S(4333)/4 + 5*sqrt(70771857)/36)**(S(1)/3)) + 4 + 2*(S(4333)/4 + \ 5*sqrt(70771857)/36)**(S(1)/3)) + 13)), Eq(y(t), C1*(-sqrt(-346/(3*(S(4333)/4 + 5*sqrt(70771857)/36)**(S(1)/3)) + 4 + \ 2*(S(4333)/4 + 5*sqrt(70771857)/36)**(S(1)/3)) + 14 + (-sqrt(-346/(3*(S(4333)/4 + 5*sqrt(70771857)/36)**(S(1)/3)) + 4 + \ 2*(S(4333)/4 + 5*sqrt(70771857)/36)**(S(1)/3))/2 + 1 + sqrt(-284/sqrt(-346/(3*(S(4333)/4 + 5*sqrt(70771857)/36)**(S(1)/3)) + \ 4 + 2*(S(4333)/4 + 5*sqrt(70771857)/36)**(S(1)/3)) - 2*(S(4333)/4 + 5*sqrt(70771857)/36)**(S(1)/3) + 8 + 346/(3*(S(4333)/4 + \ 5*sqrt(70771857)/36)**(S(1)/3)))/2)**2 + sqrt(-284/sqrt(-346/(3*(S(4333)/4 + 5*sqrt(70771857)/36)**(S(1)/3)) + 4 + \ 2*(S(4333)/4 + 5*sqrt(70771857)/36)**(S(1)/3)) - 2*(S(4333)/4 + 5*sqrt(70771857)/36)**(S(1)/3) + 8 + 346/(3*(S(4333)/4 + \ 5*sqrt(70771857)/36)**(S(1)/3))))*exp((-sqrt(-346/(3*(S(4333)/4 + 5*sqrt(70771857)/36)**(S(1)/3)) + 4 + 2*(S(4333)/4 + \ 5*sqrt(70771857)/36)**(S(1)/3))/2 + 1 + sqrt(-284/sqrt(-346/(3*(S(4333)/4 + 5*sqrt(70771857)/36)**(S(1)/3)) + 4 + \ 2*(S(4333)/4 + 5*sqrt(70771857)/36)**(S(1)/3)) - 2*(S(4333)/4 + 5*sqrt(70771857)/36)**(S(1)/3) + 8 + 346/(3*(S(4333)/4 + \ 5*sqrt(70771857)/36)**(S(1)/3)))/2)*log(t)) + C2*(-sqrt(-346/(3*(S(4333)/4 + 5*sqrt(70771857)/36)**(S(1)/3)) + 4 + \ 2*(S(4333)/4 + 5*sqrt(70771857)/36)**(S(1)/3)) + 14 - sqrt(-284/sqrt(-346/(3*(S(4333)/4 + 5*sqrt(70771857)/36)**(S(1)/3)) + \ 4 + 2*(S(4333)/4 + 5*sqrt(70771857)/36)**(S(1)/3)) - 2*(S(4333)/4 + 5*sqrt(70771857)/36)**(S(1)/3) + 8 + 346/(3*(S(4333)/4 + \ 5*sqrt(70771857)/36)**(S(1)/3))) + (-sqrt(-346/(3*(S(4333)/4 + 5*sqrt(70771857)/36)**(S(1)/3)) + 4 + 2*(S(4333)/4 + \ 5*sqrt(70771857)/36)**(S(1)/3))/2 + 1 - sqrt(-284/sqrt(-346/(3*(S(4333)/4 + 5*sqrt(70771857)/36)**(S(1)/3)) + 4 + \ 2*(S(4333)/4 + 5*sqrt(70771857)/36)**(S(1)/3)) - 2*(S(4333)/4 + 5*sqrt(70771857)/36)**(S(1)/3) + 8 + 346/(3*(S(4333)/4 + \ 5*sqrt(70771857)/36)**(S(1)/3)))/2)**2)*exp((-sqrt(-346/(3*(S(4333)/4 + 5*sqrt(70771857)/36)**(S(1)/3)) + 4 + 2*(S(4333)/4 + \ 5*sqrt(70771857)/36)**(S(1)/3))/2 + 1 - sqrt(-284/sqrt(-346/(3*(S(4333)/4 + 5*sqrt(70771857)/36)**(S(1)/3)) + 4 + \ 2*(S(4333)/4 + 5*sqrt(70771857)/36)**(S(1)/3)) - 2*(S(4333)/4 + 5*sqrt(70771857)/36)**(S(1)/3) + 8 + 346/(3*(S(4333)/4 + \ 5*sqrt(70771857)/36)**(S(1)/3)))/2)*log(t)) + C3*t**(1 + sqrt(-346/(3*(S(4333)/4 + 5*sqrt(70771857)/36)**(S(1)/3)) + 4 + \ 2*(S(4333)/4 + 5*sqrt(70771857)/36)**(S(1)/3))/2 + sqrt(-2*(S(4333)/4 + 5*sqrt(70771857)/36)**(S(1)/3) + 8 + 346/(3*(S(4333)/4 + \ 5*sqrt(70771857)/36)**(S(1)/3)) + 284/sqrt(-346/(3*(S(4333)/4 + 5*sqrt(70771857)/36)**(S(1)/3)) + 4 + 2*(S(4333)/4 + \ 5*sqrt(70771857)/36)**(S(1)/3)))/2)*(sqrt(-346/(3*(S(4333)/4 + 5*sqrt(70771857)/36)**(S(1)/3)) + 4 + 2*(S(4333)/4 + \ 5*sqrt(70771857)/36)**(S(1)/3)) + sqrt(-2*(S(4333)/4 + 5*sqrt(70771857)/36)**(S(1)/3) + 8 + 346/(3*(S(4333)/4 + \ 5*sqrt(70771857)/36)**(S(1)/3)) + 284/sqrt(-346/(3*(S(4333)/4 + 5*sqrt(70771857)/36)**(S(1)/3)) + 4 + 2*(S(4333)/4 + \ 5*sqrt(70771857)/36)**(S(1)/3))) + 14 + (1 + sqrt(-346/(3*(S(4333)/4 + 5*sqrt(70771857)/36)**(S(1)/3)) + 4 + 2*(S(4333)/4 + \ 5*sqrt(70771857)/36)**(S(1)/3))/2 + sqrt(-2*(S(4333)/4 + 5*sqrt(70771857)/36)**(S(1)/3) + 8 + 346/(3*(S(4333)/4 + \ 5*sqrt(70771857)/36)**(S(1)/3)) + 284/sqrt(-346/(3*(S(4333)/4 + 5*sqrt(70771857)/36)**(S(1)/3)) + 4 + 2*(S(4333)/4 + \ 5*sqrt(70771857)/36)**(S(1)/3)))/2)**2) + C4*t**(-sqrt(-2*(S(4333)/4 + 5*sqrt(70771857)/36)**(S(1)/3) + 8 + \ 346/(3*(S(4333)/4 + 5*sqrt(70771857)/36)**(S(1)/3)) + 284/sqrt(-346/(3*(S(4333)/4 + 5*sqrt(70771857)/36)**(S(1)/3)) + \ 4 + 2*(S(4333)/4 + 5*sqrt(70771857)/36)**(S(1)/3)))/2 + 1 + sqrt(-346/(3*(S(4333)/4 + 5*sqrt(70771857)/36)**(S(1)/3)) + \ 4 + 2*(S(4333)/4 + 5*sqrt(70771857)/36)**(S(1)/3))/2)*(-sqrt(-2*(S(4333)/4 + 5*sqrt(70771857)/36)**(S(1)/3) + \ 8 + 346/(3*(S(4333)/4 + 5*sqrt(70771857)/36)**(S(1)/3)) + 284/sqrt(-346/(3*(S(4333)/4 + 5*sqrt(70771857)/36)**(S(1)/3)) + \ 4 + 2*(S(4333)/4 + 5*sqrt(70771857)/36)**(S(1)/3))) + (-sqrt(-2*(S(4333)/4 + 5*sqrt(70771857)/36)**(S(1)/3) + 8 + \ 346/(3*(S(4333)/4 + 5*sqrt(70771857)/36)**(S(1)/3)) + 284/sqrt(-346/(3*(S(4333)/4 + 5*sqrt(70771857)/36)**(S(1)/3)) + \ 4 + 2*(S(4333)/4 + 5*sqrt(70771857)/36)**(S(1)/3)))/2 + 1 + sqrt(-346/(3*(S(4333)/4 + 5*sqrt(70771857)/36)**(S(1)/3)) + \ 4 + 2*(S(4333)/4 + 5*sqrt(70771857)/36)**(S(1)/3))/2)**2 + sqrt(-346/(3*(S(4333)/4 + \ 5*sqrt(70771857)/36)**(S(1)/3)) + 4 + 2*(S(4333)/4 + 5*sqrt(70771857)/36)**(S(1)/3)) + 14))] assert dsolve(eq10) == sol10 # FIXME: assert checksysodesol(eq10, sol10) == (True, [0, 0]) # this hangs or at least takes a while... def test_linear_3eq_order1(): x, y, z = symbols('x, y, z', cls=Function) t = Symbol('t') eq1 = (Eq(diff(x(t),t), 21*x(t)), Eq(diff(y(t),t), 17*x(t)+3*y(t)), Eq(diff(z(t),t), 5*x(t)+7*y(t)+9*z(t))) sol1 = [Eq(x(t), C1*exp(21*t)), Eq(y(t), 17*C1*exp(21*t)/18 + C2*exp(3*t)), \ Eq(z(t), 209*C1*exp(21*t)/216 - 7*C2*exp(3*t)/6 + C3*exp(9*t))] assert checksysodesol(eq1, sol1) == (True, [0, 0, 0]) eq2 = (Eq(diff(x(t),t),3*y(t)-11*z(t)),Eq(diff(y(t),t),7*z(t)-3*x(t)),Eq(diff(z(t),t),11*x(t)-7*y(t))) sol2 = [Eq(x(t), 7*C0 + sqrt(179)*C1*cos(sqrt(179)*t) + (77*C1/3 + 130*C2/3)*sin(sqrt(179)*t)), \ Eq(y(t), 11*C0 + sqrt(179)*C2*cos(sqrt(179)*t) + (-58*C1/3 - 77*C2/3)*sin(sqrt(179)*t)), \ Eq(z(t), 3*C0 + sqrt(179)*(-7*C1/3 - 11*C2/3)*cos(sqrt(179)*t) + (11*C1 - 7*C2)*sin(sqrt(179)*t))] assert checksysodesol(eq2, sol2) == (True, [0, 0, 0]) eq3 = (Eq(3*diff(x(t),t),4*5*(y(t)-z(t))),Eq(4*diff(y(t),t),3*5*(z(t)-x(t))),Eq(5*diff(z(t),t),3*4*(x(t)-y(t)))) sol3 = [Eq(x(t), C0 + 5*sqrt(2)*C1*cos(5*sqrt(2)*t) + (12*C1/5 + 164*C2/15)*sin(5*sqrt(2)*t)), \ Eq(y(t), C0 + 5*sqrt(2)*C2*cos(5*sqrt(2)*t) + (-51*C1/10 - 12*C2/5)*sin(5*sqrt(2)*t)), \ Eq(z(t), C0 + 5*sqrt(2)*(-9*C1/25 - 16*C2/25)*cos(5*sqrt(2)*t) + (12*C1/5 - 12*C2/5)*sin(5*sqrt(2)*t))] assert checksysodesol(eq3, sol3) == (True, [0, 0, 0]) f = t**3 + log(t) g = t**2 + sin(t) eq4 = (Eq(diff(x(t),t),(4*f+g)*x(t)-f*y(t)-2*f*z(t)), Eq(diff(y(t),t),2*f*x(t)+(f+g)*y(t)-2*f*z(t)), Eq(diff(z(t),t),5*f*x(t)+f*y(t)+(-3*f+g)*z(t))) sol4 = [Eq(x(t), (C1*exp(-2*Integral(t**3 + log(t), t)) + C2*(sqrt(3)*sin(sqrt(3)*Integral(t**3 + log(t), t))/6 \ + cos(sqrt(3)*Integral(t**3 + log(t), t))/2) + C3*(sin(sqrt(3)*Integral(t**3 + log(t), t))/2 - \ sqrt(3)*cos(sqrt(3)*Integral(t**3 + log(t), t))/6))*exp(Integral(-t**2 - sin(t), t))), Eq(y(t), \ (C2*(sqrt(3)*sin(sqrt(3)*Integral(t**3 + log(t), t))/6 + cos(sqrt(3)*Integral(t**3 + log(t), t))/2) + \ C3*(sin(sqrt(3)*Integral(t**3 + log(t), t))/2 - sqrt(3)*cos(sqrt(3)*Integral(t**3 + log(t), t))/6))*\ exp(Integral(-t**2 - sin(t), t))), Eq(z(t), (C1*exp(-2*Integral(t**3 + log(t), t)) + C2*cos(sqrt(3)*\ Integral(t**3 + log(t), t)) + C3*sin(sqrt(3)*Integral(t**3 + log(t), t)))*exp(Integral(-t**2 - sin(t), t)))] assert dsolve(eq4) == sol4 # FIXME: assert checksysodesol(eq4, sol4) == (True, [0, 0, 0]) # this one fails eq5 = (Eq(diff(x(t),t),4*x(t) - z(t)),Eq(diff(y(t),t),2*x(t)+2*y(t)-z(t)),Eq(diff(z(t),t),3*x(t)+y(t))) sol5 = [Eq(x(t), C1*exp(2*t) + C2*t*exp(2*t) + C2*exp(2*t) + C3*t**2*exp(2*t)/2 + C3*t*exp(2*t) + C3*exp(2*t)), \ Eq(y(t), C1*exp(2*t) + C2*t*exp(2*t) + C2*exp(2*t) + C3*t**2*exp(2*t)/2 + C3*t*exp(2*t)), \ Eq(z(t), 2*C1*exp(2*t) + 2*C2*t*exp(2*t) + C2*exp(2*t) + C3*t**2*exp(2*t) + C3*t*exp(2*t) + C3*exp(2*t))] assert checksysodesol(eq5, sol5) == (True, [0, 0, 0]) eq6 = (Eq(diff(x(t),t),4*x(t) - y(t) - 2*z(t)),Eq(diff(y(t),t),2*x(t) + y(t)- 2*z(t)),Eq(diff(z(t),t),5*x(t)-3*z(t))) sol6 = [Eq(x(t), C1*exp(2*t) + C2*(-sin(t)/5 + 3*cos(t)/5) + C3*(3*sin(t)/5 + cos(t)/5)), Eq(y(t), C2*(-sin(t)/5 + 3*cos(t)/5) + C3*(3*sin(t)/5 + cos(t)/5)), Eq(z(t), C1*exp(2*t) + C2*cos(t) + C3*sin(t))] assert checksysodesol(eq5, sol5) == (True, [0, 0, 0]) def test_linear_3eq_order1_nonhomog(): e = [Eq(diff(f(x), x), -9*f(x) - 4*g(x)), Eq(diff(g(x), x), -4*g(x)), Eq(diff(h(x), x), h(x) + exp(x))] raises(NotImplementedError, lambda: dsolve(e)) @XFAIL def test_linear_3eq_order1_diagonal(): # code makes assumptions about coefficients being nonzero, breaks when assumptions are not true e = [Eq(diff(f(x), x), f(x)), Eq(diff(g(x), x), g(x)), Eq(diff(h(x), x), h(x))] s1 = [Eq(f(x), C1*exp(x)), Eq(g(x), C2*exp(x)), Eq(h(x), C3*exp(x))] s = dsolve(e) assert s == s1 assert checksysodesol(e, s1) == (True, [0, 0, 0]) def test_nonlinear_2eq_order1(): x, y, z = symbols('x, y, z', cls=Function) t = Symbol('t') eq1 = (Eq(diff(x(t),t),x(t)*y(t)**3), Eq(diff(y(t),t),y(t)**5)) sol1 = [ Eq(x(t), C1*exp((-1/(4*C2 + 4*t))**(-S(1)/4))), Eq(y(t), -(-1/(4*C2 + 4*t))**(S(1)/4)), Eq(x(t), C1*exp(-1/(-1/(4*C2 + 4*t))**(S(1)/4))), Eq(y(t), (-1/(4*C2 + 4*t))**(S(1)/4)), Eq(x(t), C1*exp(-I/(-1/(4*C2 + 4*t))**(S(1)/4))), Eq(y(t), -I*(-1/(4*C2 + 4*t))**(S(1)/4)), Eq(x(t), C1*exp(I/(-1/(4*C2 + 4*t))**(S(1)/4))), Eq(y(t), I*(-1/(4*C2 + 4*t))**(S(1)/4))] assert dsolve(eq1) == sol1 assert checksysodesol(eq1, sol1) == (True, [0, 0]) eq2 = (Eq(diff(x(t),t), exp(3*x(t))*y(t)**3),Eq(diff(y(t),t), y(t)**5)) sol2 = [ Eq(x(t), -log(C1 - 3/(-1/(4*C2 + 4*t))**(S(1)/4))/3), Eq(y(t), -(-1/(4*C2 + 4*t))**(S(1)/4)), Eq(x(t), -log(C1 + 3/(-1/(4*C2 + 4*t))**(S(1)/4))/3), Eq(y(t), (-1/(4*C2 + 4*t))**(S(1)/4)), Eq(x(t), -log(C1 + 3*I/(-1/(4*C2 + 4*t))**(S(1)/4))/3), Eq(y(t), -I*(-1/(4*C2 + 4*t))**(S(1)/4)), Eq(x(t), -log(C1 - 3*I/(-1/(4*C2 + 4*t))**(S(1)/4))/3), Eq(y(t), I*(-1/(4*C2 + 4*t))**(S(1)/4))] assert dsolve(eq2) == sol2 assert checksysodesol(eq2, sol2) == (True, [0, 0]) eq3 = (Eq(diff(x(t),t), y(t)*x(t)), Eq(diff(y(t),t), x(t)**3)) tt = S(2)/3 sol3 = [ Eq(x(t), 6**tt/(6*(-sinh(sqrt(C1)*(C2 + t)/2)/sqrt(C1))**tt)), Eq(y(t), sqrt(C1 + C1/sinh(sqrt(C1)*(C2 + t)/2)**2)/3)] assert dsolve(eq3) == sol3 # FIXME: assert checksysodesol(eq3, sol3) == (True, [0, 0]) eq4 = (Eq(diff(x(t),t),x(t)*y(t)*sin(t)**2), Eq(diff(y(t),t),y(t)**2*sin(t)**2)) sol4 = set([Eq(x(t), -2*exp(C1)/(C2*exp(C1) + t - sin(2*t)/2)), Eq(y(t), -2/(C1 + t - sin(2*t)/2))]) assert dsolve(eq4) == sol4 # FIXME: assert checksysodesol(eq4, sol4) == (True, [0, 0]) eq5 = (Eq(x(t),t*diff(x(t),t)+diff(x(t),t)*diff(y(t),t)), Eq(y(t),t*diff(y(t),t)+diff(y(t),t)**2)) sol5 = set([Eq(x(t), C1*C2 + C1*t), Eq(y(t), C2**2 + C2*t)]) assert dsolve(eq5) == sol5 assert checksysodesol(eq5, sol5) == (True, [0, 0]) eq6 = (Eq(diff(x(t),t),x(t)**2*y(t)**3), Eq(diff(y(t),t),y(t)**5)) sol6 = [ Eq(x(t), 1/(C1 - 1/(-1/(4*C2 + 4*t))**(S(1)/4))), Eq(y(t), -(-1/(4*C2 + 4*t))**(S(1)/4)), Eq(x(t), 1/(C1 + (-1/(4*C2 + 4*t))**(-S(1)/4))), Eq(y(t), (-1/(4*C2 + 4*t))**(S(1)/4)), Eq(x(t), 1/(C1 + I/(-1/(4*C2 + 4*t))**(S(1)/4))), Eq(y(t), -I*(-1/(4*C2 + 4*t))**(S(1)/4)), Eq(x(t), 1/(C1 - I/(-1/(4*C2 + 4*t))**(S(1)/4))), Eq(y(t), I*(-1/(4*C2 + 4*t))**(S(1)/4))] assert dsolve(eq6) == sol6 assert checksysodesol(eq6, sol6) == (True, [0, 0]) def test_checksysodesol(): x, y, z = symbols('x, y, z', cls=Function) t = Symbol('t') eq = (Eq(diff(x(t),t), 9*y(t)), Eq(diff(y(t),t), 12*x(t))) sol = [Eq(x(t), 9*C1*exp(-6*sqrt(3)*t) + 9*C2*exp(6*sqrt(3)*t)), \ Eq(y(t), -6*sqrt(3)*C1*exp(-6*sqrt(3)*t) + 6*sqrt(3)*C2*exp(6*sqrt(3)*t))] assert checksysodesol(eq, sol) == (True, [0, 0]) eq = (Eq(diff(x(t),t), 2*x(t) + 4*y(t)), Eq(diff(y(t),t), 12*x(t) + 41*y(t))) sol = [Eq(x(t), 4*C1*exp(t*(-sqrt(1713)/2 + S(43)/2)) + 4*C2*exp(t*(sqrt(1713)/2 + \ S(43)/2))), Eq(y(t), C1*(-sqrt(1713)/2 + S(39)/2)*exp(t*(-sqrt(1713)/2 + \ S(43)/2)) + C2*(S(39)/2 + sqrt(1713)/2)*exp(t*(sqrt(1713)/2 + S(43)/2)))] assert checksysodesol(eq, sol) == (True, [0, 0]) eq = (Eq(diff(x(t),t), x(t) + y(t)), Eq(diff(y(t),t), -2*x(t) + 2*y(t))) sol = [Eq(x(t), (C1*sin(sqrt(7)*t/2) + C2*cos(sqrt(7)*t/2))*exp(3*t/2)), \ Eq(y(t), ((C1/2 - sqrt(7)*C2/2)*sin(sqrt(7)*t/2) + (sqrt(7)*C1/2 + \ C2/2)*cos(sqrt(7)*t/2))*exp(3*t/2))] assert checksysodesol(eq, sol) == (True, [0, 0]) eq = (Eq(diff(x(t),t), x(t) + y(t) + 9), Eq(diff(y(t),t), 2*x(t) + 5*y(t) + 23)) sol = [Eq(x(t), C1*exp(t*(-sqrt(6) + 3)) + C2*exp(t*(sqrt(6) + 3)) - \ S(22)/3), Eq(y(t), C1*(-sqrt(6) + 2)*exp(t*(-sqrt(6) + 3)) + C2*(2 + \ sqrt(6))*exp(t*(sqrt(6) + 3)) - S(5)/3)] assert checksysodesol(eq, sol) == (True, [0, 0]) eq = (Eq(diff(x(t),t), x(t) + y(t) + 81), Eq(diff(y(t),t), -2*x(t) + y(t) + 23)) sol = [Eq(x(t), (C1*sin(sqrt(2)*t) + C2*cos(sqrt(2)*t))*exp(t) - S(58)/3), \ Eq(y(t), (sqrt(2)*C1*cos(sqrt(2)*t) - sqrt(2)*C2*sin(sqrt(2)*t))*exp(t) - S(185)/3)] assert checksysodesol(eq, sol) == (True, [0, 0]) eq = (Eq(diff(x(t),t), 5*t*x(t) + 2*y(t)), Eq(diff(y(t),t), 2*x(t) + 5*t*y(t))) sol = [Eq(x(t), (C1*exp((Integral(2, t).doit())) + C2*exp(-(Integral(2, t)).doit()))*\ exp((Integral(5*t, t)).doit())), Eq(y(t), (C1*exp((Integral(2, t)).doit()) - \ C2*exp(-(Integral(2, t)).doit()))*exp((Integral(5*t, t)).doit()))] assert checksysodesol(eq, sol) == (True, [0, 0]) eq = (Eq(diff(x(t),t), 5*t*x(t) + t**2*y(t)), Eq(diff(y(t),t), -t**2*x(t) + 5*t*y(t))) sol = [Eq(x(t), (C1*cos((Integral(t**2, t)).doit()) + C2*sin((Integral(t**2, t)).doit()))*\ exp((Integral(5*t, t)).doit())), Eq(y(t), (-C1*sin((Integral(t**2, t)).doit()) + \ C2*cos((Integral(t**2, t)).doit()))*exp((Integral(5*t, t)).doit()))] assert checksysodesol(eq, sol) == (True, [0, 0]) eq = (Eq(diff(x(t),t), 5*t*x(t) + t**2*y(t)), Eq(diff(y(t),t), -t**2*x(t) + (5*t+9*t**2)*y(t))) sol = [Eq(x(t), (C1*exp((-sqrt(77)/2 + S(9)/2)*(Integral(t**2, t)).doit()) + \ C2*exp((sqrt(77)/2 + S(9)/2)*(Integral(t**2, t)).doit()))*exp((Integral(5*t, t)).doit())), \ Eq(y(t), (C1*(-sqrt(77)/2 + S(9)/2)*exp((-sqrt(77)/2 + S(9)/2)*(Integral(t**2, t)).doit()) + \ C2*(sqrt(77)/2 + S(9)/2)*exp((sqrt(77)/2 + S(9)/2)*(Integral(t**2, t)).doit()))*exp((Integral(5*t, t)).doit()))] assert checksysodesol(eq, sol) == (True, [0, 0]) eq = (Eq(diff(x(t),t,t), 5*x(t) + 43*y(t)), Eq(diff(y(t),t,t), x(t) + 9*y(t))) root0 = -sqrt(-sqrt(47) + 7) root1 = sqrt(-sqrt(47) + 7) root2 = -sqrt(sqrt(47) + 7) root3 = sqrt(sqrt(47) + 7) sol = [Eq(x(t), 43*C1*exp(t*root0) + 43*C2*exp(t*root1) + 43*C3*exp(t*root2) + 43*C4*exp(t*root3)), \ Eq(y(t), C1*(root0**2 - 5)*exp(t*root0) + C2*(root1**2 - 5)*exp(t*root1) + \ C3*(root2**2 - 5)*exp(t*root2) + C4*(root3**2 - 5)*exp(t*root3))] assert checksysodesol(eq, sol) == (True, [0, 0]) eq = (Eq(diff(x(t),t,t), 8*x(t)+3*y(t)+31), Eq(diff(y(t),t,t), 9*x(t)+7*y(t)+12)) root0 = -sqrt(-sqrt(109)/2 + S(15)/2) root1 = sqrt(-sqrt(109)/2 + S(15)/2) root2 = -sqrt(sqrt(109)/2 + S(15)/2) root3 = sqrt(sqrt(109)/2 + S(15)/2) sol = [Eq(x(t), 3*C1*exp(t*root0) + 3*C2*exp(t*root1) + 3*C3*exp(t*root2) + 3*C4*exp(t*root3) - S(181)/29), \ Eq(y(t), C1*(root0**2 - 8)*exp(t*root0) + C2*(root1**2 - 8)*exp(t*root1) + \ C3*(root2**2 - 8)*exp(t*root2) + C4*(root3**2 - 8)*exp(t*root3) + S(183)/29)] assert checksysodesol(eq, sol) == (True, [0, 0]) eq = (Eq(diff(x(t),t,t) - 9*diff(y(t),t) + 7*x(t),0), Eq(diff(y(t),t,t) + 9*diff(x(t),t) + 7*y(t),0)) sol = [Eq(x(t), C1*cos(t*(S(9)/2 + sqrt(109)/2)) + C2*sin(t*(S(9)/2 + sqrt(109)/2)) + \ C3*cos(t*(-sqrt(109)/2 + S(9)/2)) + C4*sin(t*(-sqrt(109)/2 + S(9)/2))), Eq(y(t), -C1*sin(t*(S(9)/2 + sqrt(109)/2)) \ + C2*cos(t*(S(9)/2 + sqrt(109)/2)) - C3*sin(t*(-sqrt(109)/2 + S(9)/2)) + C4*cos(t*(-sqrt(109)/2 + S(9)/2)))] assert checksysodesol(eq, sol) == (True, [0, 0]) eq = (Eq(diff(x(t),t,t), 9*t*diff(y(t),t)-9*y(t)), Eq(diff(y(t),t,t),7*t*diff(x(t),t)-7*x(t))) I1 = sqrt(6)*7**(S(1)/4)*sqrt(pi)*erfi(sqrt(6)*7**(S(1)/4)*t/2)/2 - exp(3*sqrt(7)*t**2/2)/t I2 = -sqrt(6)*7**(S(1)/4)*sqrt(pi)*erf(sqrt(6)*7**(S(1)/4)*t/2)/2 - exp(-3*sqrt(7)*t**2/2)/t sol = [Eq(x(t), C3*t + t*(9*C1*I1 + 9*C2*I2)), Eq(y(t), C4*t + t*(3*sqrt(7)*C1*I1 - 3*sqrt(7)*C2*I2))] assert checksysodesol(eq, sol) == (True, [0, 0]) eq = (Eq(diff(x(t),t), 21*x(t)), Eq(diff(y(t),t), 17*x(t)+3*y(t)), Eq(diff(z(t),t), 5*x(t)+7*y(t)+9*z(t))) sol = [Eq(x(t), C1*exp(21*t)), Eq(y(t), 17*C1*exp(21*t)/18 + C2*exp(3*t)), \ Eq(z(t), 209*C1*exp(21*t)/216 - 7*C2*exp(3*t)/6 + C3*exp(9*t))] assert checksysodesol(eq, sol) == (True, [0, 0, 0]) eq = (Eq(diff(x(t),t),3*y(t)-11*z(t)),Eq(diff(y(t),t),7*z(t)-3*x(t)),Eq(diff(z(t),t),11*x(t)-7*y(t))) sol = [Eq(x(t), 7*C0 + sqrt(179)*C1*cos(sqrt(179)*t) + (77*C1/3 + 130*C2/3)*sin(sqrt(179)*t)), \ Eq(y(t), 11*C0 + sqrt(179)*C2*cos(sqrt(179)*t) + (-58*C1/3 - 77*C2/3)*sin(sqrt(179)*t)), \ Eq(z(t), 3*C0 + sqrt(179)*(-7*C1/3 - 11*C2/3)*cos(sqrt(179)*t) + (11*C1 - 7*C2)*sin(sqrt(179)*t))] assert checksysodesol(eq, sol) == (True, [0, 0, 0]) eq = (Eq(3*diff(x(t),t),4*5*(y(t)-z(t))),Eq(4*diff(y(t),t),3*5*(z(t)-x(t))),Eq(5*diff(z(t),t),3*4*(x(t)-y(t)))) sol = [Eq(x(t), C0 + 5*sqrt(2)*C1*cos(5*sqrt(2)*t) + (12*C1/5 + 164*C2/15)*sin(5*sqrt(2)*t)), \ Eq(y(t), C0 + 5*sqrt(2)*C2*cos(5*sqrt(2)*t) + (-51*C1/10 - 12*C2/5)*sin(5*sqrt(2)*t)), \ Eq(z(t), C0 + 5*sqrt(2)*(-9*C1/25 - 16*C2/25)*cos(5*sqrt(2)*t) + (12*C1/5 - 12*C2/5)*sin(5*sqrt(2)*t))] assert checksysodesol(eq, sol) == (True, [0, 0, 0]) eq = (Eq(diff(x(t),t),4*x(t) - z(t)),Eq(diff(y(t),t),2*x(t)+2*y(t)-z(t)),Eq(diff(z(t),t),3*x(t)+y(t))) sol = [Eq(x(t), C1*exp(2*t) + C2*t*exp(2*t) + C2*exp(2*t) + C3*t**2*exp(2*t)/2 + C3*t*exp(2*t) + C3*exp(2*t)), \ Eq(y(t), C1*exp(2*t) + C2*t*exp(2*t) + C2*exp(2*t) + C3*t**2*exp(2*t)/2 + C3*t*exp(2*t)), \ Eq(z(t), 2*C1*exp(2*t) + 2*C2*t*exp(2*t) + C2*exp(2*t) + C3*t**2*exp(2*t) + C3*t*exp(2*t) + C3*exp(2*t))] assert checksysodesol(eq, sol) == (True, [0, 0, 0]) eq = (Eq(diff(x(t),t),4*x(t) - y(t) - 2*z(t)),Eq(diff(y(t),t),2*x(t) + y(t)- 2*z(t)),Eq(diff(z(t),t),5*x(t)-3*z(t))) sol = [Eq(x(t), C1*exp(2*t) + C2*(-sin(t) + 3*cos(t)) + C3*(3*sin(t) + cos(t))), \ Eq(y(t), C2*(-sin(t) + 3*cos(t)) + C3*(3*sin(t) + cos(t))), Eq(z(t), C1*exp(2*t) + 5*C2*cos(t) + 5*C3*sin(t))] assert checksysodesol(eq, sol) == (True, [0, 0, 0]) eq = (Eq(diff(x(t),t),x(t)*y(t)**3), Eq(diff(y(t),t),y(t)**5)) sol = [Eq(x(t), C1*exp((-1/(4*C2 + 4*t))**(-S(1)/4))), Eq(y(t), -(-1/(4*C2 + 4*t))**(S(1)/4)), \ Eq(x(t), C1*exp(-1/(-1/(4*C2 + 4*t))**(S(1)/4))), Eq(y(t), (-1/(4*C2 + 4*t))**(S(1)/4)), \ Eq(x(t), C1*exp(-I/(-1/(4*C2 + 4*t))**(S(1)/4))), Eq(y(t), -I*(-1/(4*C2 + 4*t))**(S(1)/4)), \ Eq(x(t), C1*exp(I/(-1/(4*C2 + 4*t))**(S(1)/4))), Eq(y(t), I*(-1/(4*C2 + 4*t))**(S(1)/4))] assert checksysodesol(eq, sol) == (True, [0, 0]) eq = (Eq(diff(x(t),t), exp(3*x(t))*y(t)**3),Eq(diff(y(t),t), y(t)**5)) sol = [Eq(x(t), -log(C1 - 3/(-1/(4*C2 + 4*t))**(S(1)/4))/3), Eq(y(t), -(-1/(4*C2 + 4*t))**(S(1)/4)), \ Eq(x(t), -log(C1 + 3/(-1/(4*C2 + 4*t))**(S(1)/4))/3), Eq(y(t), (-1/(4*C2 + 4*t))**(S(1)/4)), \ Eq(x(t), -log(C1 + 3*I/(-1/(4*C2 + 4*t))**(S(1)/4))/3), Eq(y(t), -I*(-1/(4*C2 + 4*t))**(S(1)/4)), \ Eq(x(t), -log(C1 - 3*I/(-1/(4*C2 + 4*t))**(S(1)/4))/3), Eq(y(t), I*(-1/(4*C2 + 4*t))**(S(1)/4))] assert checksysodesol(eq, sol) == (True, [0, 0]) eq = (Eq(x(t),t*diff(x(t),t)+diff(x(t),t)*diff(y(t),t)), Eq(y(t),t*diff(y(t),t)+diff(y(t),t)**2)) sol = set([Eq(x(t), C1*C2 + C1*t), Eq(y(t), C2**2 + C2*t)]) assert checksysodesol(eq, sol) == (True, [0, 0]) @slow def test_nonlinear_3eq_order1(): x, y, z = symbols('x, y, z', cls=Function) t, u = symbols('t u') eq1 = (4*diff(x(t),t) + 2*y(t)*z(t), 3*diff(y(t),t) - z(t)*x(t), 5*diff(z(t),t) - x(t)*y(t)) sol1 = [Eq(4*Integral(1/(sqrt(-4*u**2 - 3*C1 + C2)*sqrt(-4*u**2 + 5*C1 - C2)), (u, x(t))), C3 - sqrt(15)*t/15), Eq(3*Integral(1/(sqrt(-6*u**2 - C1 + 5*C2)*sqrt(3*u**2 + C1 - 4*C2)), (u, y(t))), C3 + sqrt(5)*t/10), Eq(5*Integral(1/(sqrt(-10*u**2 - 3*C1 + C2)* sqrt(5*u**2 + 4*C1 - C2)), (u, z(t))), C3 + sqrt(3)*t/6)] assert [i.dummy_eq(j) for i, j in zip(dsolve(eq1), sol1)] # FIXME: assert checksysodesol(eq1, sol1) == (True, [0, 0, 0]) eq2 = (4*diff(x(t),t) + 2*y(t)*z(t)*sin(t), 3*diff(y(t),t) - z(t)*x(t)*sin(t), 5*diff(z(t),t) - x(t)*y(t)*sin(t)) sol2 = [Eq(3*Integral(1/(sqrt(-6*u**2 - C1 + 5*C2)*sqrt(3*u**2 + C1 - 4*C2)), (u, x(t))), C3 + sqrt(5)*cos(t)/10), Eq(4*Integral(1/(sqrt(-4*u**2 - 3*C1 + C2)*sqrt(-4*u**2 + 5*C1 - C2)), (u, y(t))), C3 - sqrt(15)*cos(t)/15), Eq(5*Integral(1/(sqrt(-10*u**2 - 3*C1 + C2)* sqrt(5*u**2 + 4*C1 - C2)), (u, z(t))), C3 + sqrt(3)*cos(t)/6)] assert [i.dummy_eq(j) for i, j in zip(dsolve(eq2), sol2)] # FIXME: assert checksysodesol(eq2, sol2) == (True, [0, 0, 0]) @slow def test_checkodesol(): from sympy import Ei # For the most part, checkodesol is well tested in the tests below. # These tests only handle cases not checked below. raises(ValueError, lambda: checkodesol(f(x, y).diff(x), Eq(f(x, y), x))) raises(ValueError, lambda: checkodesol(f(x).diff(x), Eq(f(x, y), x), f(x, y))) assert checkodesol(f(x).diff(x), Eq(f(x, y), x)) == \ (False, -f(x).diff(x) + f(x, y).diff(x) - 1) assert checkodesol(f(x).diff(x), Eq(f(x), x)) is not True assert checkodesol(f(x).diff(x), Eq(f(x), x)) == (False, 1) sol1 = Eq(f(x)**5 + 11*f(x) - 2*f(x) + x, 0) assert checkodesol(diff(sol1.lhs, x), sol1) == (True, 0) assert checkodesol(diff(sol1.lhs, x)*exp(f(x)), sol1) == (True, 0) assert checkodesol(diff(sol1.lhs, x, 2), sol1) == (True, 0) assert checkodesol(diff(sol1.lhs, x, 2)*exp(f(x)), sol1) == (True, 0) assert checkodesol(diff(sol1.lhs, x, 3), sol1) == (True, 0) assert checkodesol(diff(sol1.lhs, x, 3)*exp(f(x)), sol1) == (True, 0) assert checkodesol(diff(sol1.lhs, x, 3), Eq(f(x), x*log(x))) == \ (False, 60*x**4*((log(x) + 1)**2 + log(x))*( log(x) + 1)*log(x)**2 - 5*x**4*log(x)**4 - 9) assert checkodesol(diff(exp(f(x)) + x, x)*x, Eq(exp(f(x)) + x, 0)) == \ (True, 0) assert checkodesol(diff(exp(f(x)) + x, x)*x, Eq(exp(f(x)) + x, 0), solve_for_func=False) == (True, 0) assert checkodesol(f(x).diff(x, 2), [Eq(f(x), C1 + C2*x), Eq(f(x), C2 + C1*x), Eq(f(x), C1*x + C2*x**2)]) == \ [(True, 0), (True, 0), (False, C2)] assert checkodesol(f(x).diff(x, 2), set([Eq(f(x), C1 + C2*x), Eq(f(x), C2 + C1*x), Eq(f(x), C1*x + C2*x**2)])) == \ set([(True, 0), (True, 0), (False, C2)]) assert checkodesol(f(x).diff(x) - 1/f(x)/2, Eq(f(x)**2, x)) == \ [(True, 0), (True, 0)] assert checkodesol(f(x).diff(x) - f(x), Eq(C1*exp(x), f(x))) == (True, 0) # Based on test_1st_homogeneous_coeff_ode2_eq3sol. Make sure that # checkodesol tries back substituting f(x) when it can. eq3 = x*exp(f(x)/x) + f(x) - x*f(x).diff(x) sol3 = Eq(f(x), log(log(C1/x)**(-x))) assert not checkodesol(eq3, sol3)[1].has(f(x)) # This case was failing intermittently depending on hash-seed: eqn = Eq(Derivative(x*Derivative(f(x), x), x)/x, exp(x)) sol = Eq(f(x), C1 + C2*log(x) + exp(x) - Ei(x)) assert checkodesol(eqn, sol, order=2, solve_for_func=False)[0] @slow def test_dsolve_options(): eq = x*f(x).diff(x) + f(x) a = dsolve(eq, hint='all') b = dsolve(eq, hint='all', simplify=False) c = dsolve(eq, hint='all_Integral') keys = ['1st_exact', '1st_exact_Integral', '1st_homogeneous_coeff_best', '1st_homogeneous_coeff_subs_dep_div_indep', '1st_homogeneous_coeff_subs_dep_div_indep_Integral', '1st_homogeneous_coeff_subs_indep_div_dep', '1st_homogeneous_coeff_subs_indep_div_dep_Integral', '1st_linear', '1st_linear_Integral', 'almost_linear', 'almost_linear_Integral', 'best', 'best_hint', 'default', 'lie_group', 'nth_linear_euler_eq_homogeneous', 'order', 'separable', 'separable_Integral'] Integral_keys = ['1st_exact_Integral', '1st_homogeneous_coeff_subs_dep_div_indep_Integral', '1st_homogeneous_coeff_subs_indep_div_dep_Integral', '1st_linear_Integral', 'almost_linear_Integral', 'best', 'best_hint', 'default', 'nth_linear_euler_eq_homogeneous', 'order', 'separable_Integral'] assert sorted(a.keys()) == keys assert a['order'] == ode_order(eq, f(x)) assert a['best'] == Eq(f(x), C1/x) assert dsolve(eq, hint='best') == Eq(f(x), C1/x) assert a['default'] == 'separable' assert a['best_hint'] == 'separable' assert not a['1st_exact'].has(Integral) assert not a['separable'].has(Integral) assert not a['1st_homogeneous_coeff_best'].has(Integral) assert not a['1st_homogeneous_coeff_subs_dep_div_indep'].has(Integral) assert not a['1st_homogeneous_coeff_subs_indep_div_dep'].has(Integral) assert not a['1st_linear'].has(Integral) assert a['1st_linear_Integral'].has(Integral) assert a['1st_exact_Integral'].has(Integral) assert a['1st_homogeneous_coeff_subs_dep_div_indep_Integral'].has(Integral) assert a['1st_homogeneous_coeff_subs_indep_div_dep_Integral'].has(Integral) assert a['separable_Integral'].has(Integral) assert sorted(b.keys()) == keys assert b['order'] == ode_order(eq, f(x)) assert b['best'] == Eq(f(x), C1/x) assert dsolve(eq, hint='best', simplify=False) == Eq(f(x), C1/x) assert b['default'] == 'separable' assert b['best_hint'] == '1st_linear' assert a['separable'] != b['separable'] assert a['1st_homogeneous_coeff_subs_dep_div_indep'] != \ b['1st_homogeneous_coeff_subs_dep_div_indep'] assert a['1st_homogeneous_coeff_subs_indep_div_dep'] != \ b['1st_homogeneous_coeff_subs_indep_div_dep'] assert not b['1st_exact'].has(Integral) assert not b['separable'].has(Integral) assert not b['1st_homogeneous_coeff_best'].has(Integral) assert not b['1st_homogeneous_coeff_subs_dep_div_indep'].has(Integral) assert not b['1st_homogeneous_coeff_subs_indep_div_dep'].has(Integral) assert not b['1st_linear'].has(Integral) assert b['1st_linear_Integral'].has(Integral) assert b['1st_exact_Integral'].has(Integral) assert b['1st_homogeneous_coeff_subs_dep_div_indep_Integral'].has(Integral) assert b['1st_homogeneous_coeff_subs_indep_div_dep_Integral'].has(Integral) assert b['separable_Integral'].has(Integral) assert sorted(c.keys()) == Integral_keys raises(ValueError, lambda: dsolve(eq, hint='notarealhint')) raises(ValueError, lambda: dsolve(eq, hint='Liouville')) assert dsolve(f(x).diff(x) - 1/f(x)**2, hint='all')['best'] == \ dsolve(f(x).diff(x) - 1/f(x)**2, hint='best') assert dsolve(f(x) + f(x).diff(x) + sin(x).diff(x) + 1, f(x), hint="1st_linear_Integral") == \ Eq(f(x), (C1 + Integral((-sin(x).diff(x) - 1)* exp(Integral(1, x)), x))*exp(-Integral(1, x))) def test_classify_ode(): assert classify_ode(f(x).diff(x, 2), f(x)) == \ ( 'nth_algebraic', 'nth_linear_constant_coeff_homogeneous', 'nth_linear_euler_eq_homogeneous', 'Liouville', '2nd_power_series_ordinary', 'nth_algebraic_Integral', 'Liouville_Integral', ) assert classify_ode(f(x), f(x)) == () assert classify_ode(Eq(f(x).diff(x), 0), f(x)) == ( 'nth_algebraic', 'separable', '1st_linear', '1st_homogeneous_coeff_best', '1st_homogeneous_coeff_subs_indep_div_dep', '1st_homogeneous_coeff_subs_dep_div_indep', '1st_power_series', 'lie_group', 'nth_linear_constant_coeff_homogeneous', 'nth_linear_euler_eq_homogeneous', 'nth_algebraic_Integral', 'separable_Integral', '1st_linear_Integral', '1st_homogeneous_coeff_subs_indep_div_dep_Integral', '1st_homogeneous_coeff_subs_dep_div_indep_Integral') assert classify_ode(f(x).diff(x)**2, f(x)) == ( 'nth_algebraic', 'lie_group', 'nth_algebraic_Integral') # issue 4749: f(x) should be cleared from highest derivative before classifying a = classify_ode(Eq(f(x).diff(x) + f(x), x), f(x)) b = classify_ode(f(x).diff(x)*f(x) + f(x)*f(x) - x*f(x), f(x)) c = classify_ode(f(x).diff(x)/f(x) + f(x)/f(x) - x/f(x), f(x)) assert a == ('1st_linear', 'Bernoulli', 'almost_linear', '1st_power_series', "lie_group", 'nth_linear_constant_coeff_undetermined_coefficients', 'nth_linear_constant_coeff_variation_of_parameters', '1st_linear_Integral', 'Bernoulli_Integral', 'almost_linear_Integral', 'nth_linear_constant_coeff_variation_of_parameters_Integral') assert b == c != () assert classify_ode( 2*x*f(x)*f(x).diff(x) + (1 + x)*f(x)**2 - exp(x), f(x) ) == ('Bernoulli', 'almost_linear', 'lie_group', 'Bernoulli_Integral', 'almost_linear_Integral') assert 'Riccati_special_minus2' in \ classify_ode(2*f(x).diff(x) + f(x)**2 - f(x)/x + 3*x**(-2), f(x)) raises(ValueError, lambda: classify_ode(x + f(x, y).diff(x).diff( y), f(x, y))) # issue 5176 k = Symbol('k') assert classify_ode(f(x).diff(x)/(k*f(x) + k*x*f(x)) + 2*f(x)/(k*f(x) + k*x*f(x)) + x*f(x).diff(x)/(k*f(x) + k*x*f(x)) + z, f(x)) == \ ('separable', '1st_exact', '1st_power_series', 'lie_group', 'separable_Integral', '1st_exact_Integral') # preprocessing ans = ('nth_algebraic', 'separable', '1st_exact', '1st_linear', 'Bernoulli', '1st_homogeneous_coeff_best', '1st_homogeneous_coeff_subs_indep_div_dep', '1st_homogeneous_coeff_subs_dep_div_indep', '1st_power_series', 'lie_group', 'nth_linear_constant_coeff_undetermined_coefficients', 'nth_linear_euler_eq_nonhomogeneous_undetermined_coefficients', 'nth_linear_constant_coeff_variation_of_parameters', 'nth_linear_euler_eq_nonhomogeneous_variation_of_parameters', 'nth_algebraic_Integral', 'separable_Integral', '1st_exact_Integral', '1st_linear_Integral', 'Bernoulli_Integral', '1st_homogeneous_coeff_subs_indep_div_dep_Integral', '1st_homogeneous_coeff_subs_dep_div_indep_Integral', 'nth_linear_constant_coeff_variation_of_parameters_Integral', 'nth_linear_euler_eq_nonhomogeneous_variation_of_parameters_Integral') # w/o f(x) given assert classify_ode(diff(f(x) + x, x) + diff(f(x), x)) == ans # w/ f(x) and prep=True assert classify_ode(diff(f(x) + x, x) + diff(f(x), x), f(x), prep=True) == ans assert classify_ode(Eq(2*x**3*f(x).diff(x), 0), f(x)) == \ ('nth_algebraic', 'separable', '1st_linear', '1st_power_series', 'lie_group', 'nth_linear_euler_eq_homogeneous', 'nth_algebraic_Integral', 'separable_Integral', '1st_linear_Integral') assert classify_ode(Eq(2*f(x)**3*f(x).diff(x), 0), f(x)) == \ ('nth_algebraic', 'separable', '1st_power_series', 'lie_group', 'nth_algebraic_Integral', 'separable_Integral') # test issue 13864 assert classify_ode(Eq(diff(f(x), x) - f(x)**x, 0), f(x)) == \ ('1st_power_series', 'lie_group') assert isinstance(classify_ode(Eq(f(x), 5), f(x), dict=True), dict) def test_classify_ode_ics(): # Dummy eq = f(x).diff(x, x) - f(x) # Not f(0) or f'(0) ics = {x: 1} raises(ValueError, lambda: classify_ode(eq, f(x), ics=ics)) ############################ # f(0) type (AppliedUndef) # ############################ # Wrong function ics = {g(0): 1} raises(ValueError, lambda: classify_ode(eq, f(x), ics=ics)) # Contains x ics = {f(x): 1} raises(ValueError, lambda: classify_ode(eq, f(x), ics=ics)) # Too many args ics = {f(0, 0): 1} raises(ValueError, lambda: classify_ode(eq, f(x), ics=ics)) # point contains f # XXX: Should be NotImplementedError ics = {f(0): f(1)} raises(ValueError, lambda: classify_ode(eq, f(x), ics=ics)) # Does not raise ics = {f(0): 1} classify_ode(eq, f(x), ics=ics) ##################### # f'(0) type (Subs) # ##################### # Wrong function ics = {g(x).diff(x).subs(x, 0): 1} raises(ValueError, lambda: classify_ode(eq, f(x), ics=ics)) # Contains x ics = {f(y).diff(y).subs(y, x): 1} raises(ValueError, lambda: classify_ode(eq, f(x), ics=ics)) # Wrong variable ics = {f(y).diff(y).subs(y, 0): 1} raises(ValueError, lambda: classify_ode(eq, f(x), ics=ics)) # Too many args ics = {f(x, y).diff(x).subs(x, 0): 1} raises(ValueError, lambda: classify_ode(eq, f(x), ics=ics)) # Derivative wrt wrong vars ics = {Derivative(f(x), x, y).subs(x, 0): 1} raises(ValueError, lambda: classify_ode(eq, f(x), ics=ics)) # point contains f # XXX: Should be NotImplementedError ics = {f(x).diff(x).subs(x, 0): f(0)} raises(ValueError, lambda: classify_ode(eq, f(x), ics=ics)) # Does not raise ics = {f(x).diff(x).subs(x, 0): 1} classify_ode(eq, f(x), ics=ics) ########################### # f'(y) type (Derivative) # ########################### # Wrong function ics = {g(x).diff(x).subs(x, y): 1} raises(ValueError, lambda: classify_ode(eq, f(x), ics=ics)) # Contains x ics = {f(y).diff(y).subs(y, x): 1} raises(ValueError, lambda: classify_ode(eq, f(x), ics=ics)) # Too many args ics = {f(x, y).diff(x).subs(x, y): 1} raises(ValueError, lambda: classify_ode(eq, f(x), ics=ics)) # Derivative wrt wrong vars ics = {Derivative(f(x), x, z).subs(x, y): 1} raises(ValueError, lambda: classify_ode(eq, f(x), ics=ics)) # point contains f # XXX: Should be NotImplementedError ics = {f(x).diff(x).subs(x, y): f(0)} raises(ValueError, lambda: classify_ode(eq, f(x), ics=ics)) # Does not raise ics = {f(x).diff(x).subs(x, y): 1} classify_ode(eq, f(x), ics=ics) def test_classify_sysode(): # Here x is assumed to be x(t) and y as y(t) for simplicity. # Similarly diff(x,t) and diff(y,y) is assumed to be x1 and y1 respectively. k, l, m, n = symbols('k, l, m, n', Integer=True) k1, k2, k3, l1, l2, l3, m1, m2, m3 = symbols('k1, k2, k3, l1, l2, l3, m1, m2, m3', Integer=True) P, Q, R, p, q, r = symbols('P, Q, R, p, q, r', cls=Function) P1, P2, P3, Q1, Q2, R1, R2 = symbols('P1, P2, P3, Q1, Q2, R1, R2', cls=Function) x, y, z = symbols('x, y, z', cls=Function) t = symbols('t') x1 = diff(x(t),t) ; y1 = diff(y(t),t) ; z1 = diff(z(t),t) x2 = diff(x(t),t,t) ; y2 = diff(y(t),t,t) ; z2 = diff(z(t),t,t) eq1 = (Eq(diff(x(t),t), 5*t*x(t) + 2*y(t)), Eq(diff(y(t),t), 2*x(t) + 5*t*y(t))) sol1 = {'no_of_equation': 2, 'func_coeff': {(0, x(t), 0): -5*t, (1, x(t), 1): 0, (0, x(t), 1): 1, \ (1, y(t), 0): -5*t, (1, x(t), 0): -2, (0, y(t), 1): 0, (0, y(t), 0): -2, (1, y(t), 1): 1}, \ 'type_of_equation': 'type3', 'func': [x(t), y(t)], 'is_linear': True, 'eq': [-5*t*x(t) - 2*y(t) + \ Derivative(x(t), t), -5*t*y(t) - 2*x(t) + Derivative(y(t), t)], 'order': {y(t): 1, x(t): 1}} assert classify_sysode(eq1) == sol1 eq2 = (Eq(x2, k*x(t) - l*y1), Eq(y2, l*x1 + k*y(t))) sol2 = {'order': {y(t): 2, x(t): 2}, 'type_of_equation': 'type3', 'is_linear': True, 'eq': \ [-k*x(t) + l*Derivative(y(t), t) + Derivative(x(t), t, t), -k*y(t) - l*Derivative(x(t), t) + \ Derivative(y(t), t, t)], 'no_of_equation': 2, 'func_coeff': {(0, y(t), 0): 0, (0, x(t), 2): 1, \ (1, y(t), 1): 0, (1, y(t), 2): 1, (1, x(t), 2): 0, (0, y(t), 2): 0, (0, x(t), 0): -k, (1, x(t), 1): \ -l, (0, x(t), 1): 0, (0, y(t), 1): l, (1, x(t), 0): 0, (1, y(t), 0): -k}, 'func': [x(t), y(t)]} assert classify_sysode(eq2) == sol2 eq3 = (Eq(x2+4*x1+3*y1+9*x(t)+7*y(t), 11*exp(I*t)), Eq(y2+5*x1+8*y1+3*x(t)+12*y(t), 2*exp(I*t))) sol3 = {'no_of_equation': 2, 'func_coeff': {(1, x(t), 2): 0, (0, y(t), 2): 0, (0, x(t), 0): 9, \ (1, x(t), 1): 5, (0, x(t), 1): 4, (0, y(t), 1): 3, (1, x(t), 0): 3, (1, y(t), 0): 12, (0, y(t), 0): 7, \ (0, x(t), 2): 1, (1, y(t), 2): 1, (1, y(t), 1): 8}, 'type_of_equation': 'type4', 'func': [x(t), y(t)], \ 'is_linear': True, 'eq': [9*x(t) + 7*y(t) - 11*exp(I*t) + 4*Derivative(x(t), t) + 3*Derivative(y(t), t) + \ Derivative(x(t), t, t), 3*x(t) + 12*y(t) - 2*exp(I*t) + 5*Derivative(x(t), t) + 8*Derivative(y(t), t) + \ Derivative(y(t), t, t)], 'order': {y(t): 2, x(t): 2}} assert classify_sysode(eq3) == sol3 eq4 = (Eq((4*t**2 + 7*t + 1)**2*x2, 5*x(t) + 35*y(t)), Eq((4*t**2 + 7*t + 1)**2*y2, x(t) + 9*y(t))) sol4 = {'no_of_equation': 2, 'func_coeff': {(1, x(t), 2): 0, (0, y(t), 2): 0, (0, x(t), 0): -5, \ (1, x(t), 1): 0, (0, x(t), 1): 0, (0, y(t), 1): 0, (1, x(t), 0): -1, (1, y(t), 0): -9, (0, y(t), 0): -35, \ (0, x(t), 2): 16*t**4 + 56*t**3 + 57*t**2 + 14*t + 1, (1, y(t), 2): 16*t**4 + 56*t**3 + 57*t**2 + 14*t + 1, \ (1, y(t), 1): 0}, 'type_of_equation': 'type10', 'func': [x(t), y(t)], 'is_linear': True, \ 'eq': [(4*t**2 + 7*t + 1)**2*Derivative(x(t), t, t) - 5*x(t) - 35*y(t), (4*t**2 + 7*t + 1)**2*Derivative(y(t), t, t)\ - x(t) - 9*y(t)], 'order': {y(t): 2, x(t): 2}} assert classify_sysode(eq4) == sol4 eq5 = (Eq(diff(x(t),t), x(t) + y(t) + 9), Eq(diff(y(t),t), 2*x(t) + 5*y(t) + 23)) sol5 = {'no_of_equation': 2, 'func_coeff': {(0, x(t), 0): -1, (1, x(t), 1): 0, (0, x(t), 1): 1, (1, y(t), 0): -5, \ (1, x(t), 0): -2, (0, y(t), 1): 0, (0, y(t), 0): -1, (1, y(t), 1): 1}, 'type_of_equation': 'type2', \ 'func': [x(t), y(t)], 'is_linear': True, 'eq': [-x(t) - y(t) + Derivative(x(t), t) - 9, -2*x(t) - 5*y(t) + \ Derivative(y(t), t) - 23], 'order': {y(t): 1, x(t): 1}} assert classify_sysode(eq5) == sol5 eq6 = (Eq(x1, exp(k*x(t))*P(x(t),y(t))), Eq(y1,r(y(t))*P(x(t),y(t)))) sol6 = {'no_of_equation': 2, 'func_coeff': {(0, x(t), 0): 0, (1, x(t), 1): 0, (0, x(t), 1): 1, (1, y(t), 0): 0, \ (1, x(t), 0): 0, (0, y(t), 1): 0, (0, y(t), 0): 0, (1, y(t), 1): 1}, 'type_of_equation': 'type2', 'func': \ [x(t), y(t)], 'is_linear': False, 'eq': [-P(x(t), y(t))*exp(k*x(t)) + Derivative(x(t), t), -P(x(t), \ y(t))*r(y(t)) + Derivative(y(t), t)], 'order': {y(t): 1, x(t): 1}} assert classify_sysode(eq6) == sol6 eq7 = (Eq(x1, x(t)**2+y(t)/x(t)), Eq(y1, x(t)/y(t))) sol7 = {'no_of_equation': 2, 'func_coeff': {(0, x(t), 0): 0, (1, x(t), 1): 0, (0, x(t), 1): 1, (1, y(t), 0): 0, \ (1, x(t), 0): -1/y(t), (0, y(t), 1): 0, (0, y(t), 0): -1/x(t), (1, y(t), 1): 1}, 'type_of_equation': 'type3', \ 'func': [x(t), y(t)], 'is_linear': False, 'eq': [-x(t)**2 + Derivative(x(t), t) - y(t)/x(t), -x(t)/y(t) + \ Derivative(y(t), t)], 'order': {y(t): 1, x(t): 1}} assert classify_sysode(eq7) == sol7 eq8 = (Eq(x1, P1(x(t))*Q1(y(t))*R(x(t),y(t),t)), Eq(y1, P1(x(t))*Q1(y(t))*R(x(t),y(t),t))) sol8 = {'func': [x(t), y(t)], 'is_linear': False, 'type_of_equation': 'type4', 'eq': \ [-P1(x(t))*Q1(y(t))*R(x(t), y(t), t) + Derivative(x(t), t), -P1(x(t))*Q1(y(t))*R(x(t), y(t), t) + \ Derivative(y(t), t)], 'func_coeff': {(0, y(t), 1): 0, (1, y(t), 1): 1, (1, x(t), 1): 0, (0, y(t), 0): 0, \ (1, x(t), 0): 0, (0, x(t), 0): 0, (1, y(t), 0): 0, (0, x(t), 1): 1}, 'order': {y(t): 1, x(t): 1}, 'no_of_equation': 2} assert classify_sysode(eq8) == sol8 eq9 = (Eq(x1,3*y(t)-11*z(t)),Eq(y1,7*z(t)-3*x(t)),Eq(z1,11*x(t)-7*y(t))) sol9 = {'no_of_equation': 3, 'func_coeff': {(1, y(t), 0): 0, (2, y(t), 1): 0, (2, z(t), 1): 1, \ (0, x(t), 0): 0, (2, x(t), 1): 0, (1, x(t), 1): 0, (2, y(t), 0): 7, (0, x(t), 1): 1, (1, z(t), 1): 0, \ (0, y(t), 1): 0, (1, x(t), 0): 3, (0, z(t), 0): 11, (0, y(t), 0): -3, (1, z(t), 0): -7, (0, z(t), 1): 0, \ (2, x(t), 0): -11, (2, z(t), 0): 0, (1, y(t), 1): 1}, 'type_of_equation': 'type2', 'func': [x(t), y(t), z(t)], \ 'is_linear': True, 'eq': [-3*y(t) + 11*z(t) + Derivative(x(t), t), 3*x(t) - 7*z(t) + Derivative(y(t), t), \ -11*x(t) + 7*y(t) + Derivative(z(t), t)], 'order': {z(t): 1, y(t): 1, x(t): 1}} assert classify_sysode(eq9) == sol9 eq10 = (x2 + log(t)*(t*x1 - x(t)) + exp(t)*(t*y1 - y(t)), y2 + (t**2)*(t*x1 - x(t)) + (t)*(t*y1 - y(t))) sol10 = {'no_of_equation': 2, 'func_coeff': {(1, x(t), 2): 0, (0, y(t), 2): 0, (0, x(t), 0): -log(t), \ (1, x(t), 1): t**3, (0, x(t), 1): t*log(t), (0, y(t), 1): t*exp(t), (1, x(t), 0): -t**2, (1, y(t), 0): -t, \ (0, y(t), 0): -exp(t), (0, x(t), 2): 1, (1, y(t), 2): 1, (1, y(t), 1): t**2}, 'type_of_equation': 'type11', \ 'func': [x(t), y(t)], 'is_linear': True, 'eq': [(t*Derivative(x(t), t) - x(t))*log(t) + (t*Derivative(y(t), t) - \ y(t))*exp(t) + Derivative(x(t), t, t), t**2*(t*Derivative(x(t), t) - x(t)) + t*(t*Derivative(y(t), t) - y(t)) \ + Derivative(y(t), t, t)], 'order': {y(t): 2, x(t): 2}} assert classify_sysode(eq10) == sol10 eq11 = (Eq(x1,x(t)*y(t)**3), Eq(y1,y(t)**5)) sol11 = {'no_of_equation': 2, 'func_coeff': {(0, x(t), 0): -y(t)**3, (1, x(t), 1): 0, (0, x(t), 1): 1, \ (1, y(t), 0): 0, (1, x(t), 0): 0, (0, y(t), 1): 0, (0, y(t), 0): 0, (1, y(t), 1): 1}, 'type_of_equation': \ 'type1', 'func': [x(t), y(t)], 'is_linear': False, 'eq': [-x(t)*y(t)**3 + Derivative(x(t), t), \ -y(t)**5 + Derivative(y(t), t)], 'order': {y(t): 1, x(t): 1}} assert classify_sysode(eq11) == sol11 eq12 = (Eq(x1, y(t)), Eq(y1, x(t))) sol12 = {'no_of_equation': 2, 'func_coeff': {(0, x(t), 0): 0, (1, x(t), 1): 0, (0, x(t), 1): 1, (1, y(t), 0): 0, \ (1, x(t), 0): -1, (0, y(t), 1): 0, (0, y(t), 0): -1, (1, y(t), 1): 1}, 'type_of_equation': 'type1', 'func': \ [x(t), y(t)], 'is_linear': True, 'eq': [-y(t) + Derivative(x(t), t), -x(t) + Derivative(y(t), t)], 'order': {y(t): 1, x(t): 1}} assert classify_sysode(eq12) == sol12 eq13 = (Eq(x1,x(t)*y(t)*sin(t)**2), Eq(y1,y(t)**2*sin(t)**2)) sol13 = {'no_of_equation': 2, 'func_coeff': {(0, x(t), 0): -y(t)*sin(t)**2, (1, x(t), 1): 0, (0, x(t), 1): 1, \ (1, y(t), 0): 0, (1, x(t), 0): 0, (0, y(t), 1): 0, (0, y(t), 0): -x(t)*sin(t)**2, (1, y(t), 1): 1}, \ 'type_of_equation': 'type4', 'func': [x(t), y(t)], 'is_linear': False, 'eq': [-x(t)*y(t)*sin(t)**2 + \ Derivative(x(t), t), -y(t)**2*sin(t)**2 + Derivative(y(t), t)], 'order': {y(t): 1, x(t): 1}} assert classify_sysode(eq13) == sol13 eq14 = (Eq(x1, 21*x(t)), Eq(y1, 17*x(t)+3*y(t)), Eq(z1, 5*x(t)+7*y(t)+9*z(t))) sol14 = {'no_of_equation': 3, 'func_coeff': {(1, y(t), 0): -3, (2, y(t), 1): 0, (2, z(t), 1): 1, \ (0, x(t), 0): -21, (2, x(t), 1): 0, (1, x(t), 1): 0, (2, y(t), 0): -7, (0, x(t), 1): 1, (1, z(t), 1): 0, \ (0, y(t), 1): 0, (1, x(t), 0): -17, (0, z(t), 0): 0, (0, y(t), 0): 0, (1, z(t), 0): 0, (0, z(t), 1): 0, \ (2, x(t), 0): -5, (2, z(t), 0): -9, (1, y(t), 1): 1}, 'type_of_equation': 'type1', 'func': [x(t), y(t), z(t)], \ 'is_linear': True, 'eq': [-21*x(t) + Derivative(x(t), t), -17*x(t) - 3*y(t) + Derivative(y(t), t), -5*x(t) - \ 7*y(t) - 9*z(t) + Derivative(z(t), t)], 'order': {z(t): 1, y(t): 1, x(t): 1}} assert classify_sysode(eq14) == sol14 eq15 = (Eq(x1,4*x(t)+5*y(t)+2*z(t)),Eq(y1,x(t)+13*y(t)+9*z(t)),Eq(z1,32*x(t)+41*y(t)+11*z(t))) sol15 = {'no_of_equation': 3, 'func_coeff': {(1, y(t), 0): -13, (2, y(t), 1): 0, (2, z(t), 1): 1, \ (0, x(t), 0): -4, (2, x(t), 1): 0, (1, x(t), 1): 0, (2, y(t), 0): -41, (0, x(t), 1): 1, (1, z(t), 1): 0, \ (0, y(t), 1): 0, (1, x(t), 0): -1, (0, z(t), 0): -2, (0, y(t), 0): -5, (1, z(t), 0): -9, (0, z(t), 1): 0, \ (2, x(t), 0): -32, (2, z(t), 0): -11, (1, y(t), 1): 1}, 'type_of_equation': 'type6', 'func': \ [x(t), y(t), z(t)], 'is_linear': True, 'eq': [-4*x(t) - 5*y(t) - 2*z(t) + Derivative(x(t), t), -x(t) - 13*y(t) - \ 9*z(t) + Derivative(y(t), t), -32*x(t) - 41*y(t) - 11*z(t) + Derivative(z(t), t)], 'order': {z(t): 1, y(t): 1, x(t): 1}} assert classify_sysode(eq15) == sol15 eq16 = (Eq(3*x1,4*5*(y(t)-z(t))),Eq(4*y1,3*5*(z(t)-x(t))),Eq(5*z1,3*4*(x(t)-y(t)))) sol16 = {'no_of_equation': 3, 'func_coeff': {(1, y(t), 0): 0, (2, y(t), 1): 0, (2, z(t), 1): 5, \ (0, x(t), 0): 0, (2, x(t), 1): 0, (1, x(t), 1): 0, (2, y(t), 0): 12, (0, x(t), 1): 3, (1, z(t), 1): 0, \ (0, y(t), 1): 0, (1, x(t), 0): 15, (0, z(t), 0): 20, (0, y(t), 0): -20, (1, z(t), 0): -15, (0, z(t), 1): 0, \ (2, x(t), 0): -12, (2, z(t), 0): 0, (1, y(t), 1): 4}, 'type_of_equation': 'type3', 'func': [x(t), y(t), z(t)], \ 'is_linear': True, 'eq': [-20*y(t) + 20*z(t) + 3*Derivative(x(t), t), 15*x(t) - 15*z(t) + 4*Derivative(y(t), t), \ -12*x(t) + 12*y(t) + 5*Derivative(z(t), t)], 'order': {z(t): 1, y(t): 1, x(t): 1}} assert classify_sysode(eq16) == sol16 # issue 8193: funcs parameter for classify_sysode has to actually work assert classify_sysode(eq1, funcs=[x(t), y(t)]) == sol1 def test_solve_ics(): # Basic tests that things work from dsolve. assert dsolve(f(x).diff(x) - 1/f(x), f(x), ics={f(1): 2}) == \ Eq(f(x), sqrt(2 * x + 2)) assert dsolve(f(x).diff(x) - f(x), f(x), ics={f(0): 1}) == Eq(f(x), exp(x)) assert dsolve(f(x).diff(x) - f(x), f(x), ics={f(x).diff(x).subs(x, 0): 1}) == Eq(f(x), exp(x)) assert dsolve(f(x).diff(x, x) + f(x), f(x), ics={f(0): 1, f(x).diff(x).subs(x, 0): 1}) == Eq(f(x), sin(x) + cos(x)) assert dsolve([f(x).diff(x) - f(x) + g(x), g(x).diff(x) - g(x) - f(x)], [f(x), g(x)], ics={f(0): 1, g(0): 0}) == [Eq(f(x), exp(x)*cos(x)), Eq(g(x), exp(x)*sin(x))] # Test cases where dsolve returns two solutions. eq = (x**2*f(x)**2 - x).diff(x) assert dsolve(eq, f(x), ics={f(1): 0}) == [Eq(f(x), -sqrt(x - 1)/x), Eq(f(x), sqrt(x - 1)/x)] assert dsolve(eq, f(x), ics={f(x).diff(x).subs(x, 1): 0}) == [Eq(f(x), -sqrt(x - S(1)/2)/x), Eq(f(x), sqrt(x - S(1)/2)/x)] eq = cos(f(x)) - (x*sin(f(x)) - f(x)**2)*f(x).diff(x) assert dsolve(eq, f(x), ics={f(0):1}, hint='1st_exact', simplify=False) == Eq(x*cos(f(x)) + f(x)**3/3, S(1)/3) assert dsolve(eq, f(x), ics={f(0):1}, hint='1st_exact', simplify=True) == Eq(x*cos(f(x)) + f(x)**3/3, S(1)/3) assert solve_ics([Eq(f(x), C1*exp(x))], [f(x)], [C1], {f(0): 1}) == {C1: 1} assert solve_ics([Eq(f(x), C1*sin(x) + C2*cos(x))], [f(x)], [C1, C2], {f(0): 1, f(pi/2): 1}) == {C1: 1, C2: 1} assert solve_ics([Eq(f(x), C1*sin(x) + C2*cos(x))], [f(x)], [C1, C2], {f(0): 1, f(x).diff(x).subs(x, 0): 1}) == {C1: 1, C2: 1} assert solve_ics([Eq(f(x), C1*sin(x) + C2*cos(x))], [f(x)], [C1, C2], {f(0): 1}) == \ {C2: 1} # Some more complicated tests Refer to PR #16098 assert dsolve(f(x).diff(x)*(f(x).diff(x, 2)-x), ics={f(0):0, f(x).diff(x).subs(x, 1):0}) == \ [Eq(f(x), 0), Eq(f(x), x ** 3 / 6 - x / 2)] assert dsolve(f(x).diff(x)*(f(x).diff(x, 2)-x), ics={f(0):0}) == \ [Eq(f(x), 0), Eq(f(x), C2*x + x**3/6)] K, r, f0 = symbols('K r f0') sol = Eq(f(x), -K*f0*exp(r*x)/((K - f0)*(-f0*exp(r*x)/(K - f0) - 1))) assert (dsolve(Eq(f(x).diff(x), r * f(x) * (1 - f(x) / K)), f(x), ics={f(0): f0})) == sol #Order dependent issues Refer to PR #16098 assert dsolve(f(x).diff(x)*(f(x).diff(x, 2)-x), ics={f(x).diff(x).subs(x,0):0, f(0):0}) == \ [Eq(f(x), 0), Eq(f(x), x ** 3 / 6)] assert dsolve(f(x).diff(x)*(f(x).diff(x, 2)-x), ics={f(0):0, f(x).diff(x).subs(x,0):0}) == \ [Eq(f(x), 0), Eq(f(x), x ** 3 / 6)] # XXX: Ought to be ValueError raises(ValueError, lambda: solve_ics([Eq(f(x), C1*sin(x) + C2*cos(x))], [f(x)], [C1, C2], {f(0): 1, f(pi): 1})) # Degenerate case. f'(0) is identically 0. raises(ValueError, lambda: solve_ics([Eq(f(x), sqrt(C1 - x**2))], [f(x)], [C1], {f(x).diff(x).subs(x, 0): 0})) EI, q, L = symbols('EI q L') # eq = Eq(EI*diff(f(x), x, 4), q) sols = [Eq(f(x), C1 + C2*x + C3*x**2 + C4*x**3 + q*x**4/(24*EI))] funcs = [f(x)] constants = [C1, C2, C3, C4] # Test both cases, Derivative (the default from f(x).diff(x).subs(x, L)), # and Subs ics1 = {f(0): 0, f(x).diff(x).subs(x, 0): 0, f(L).diff(L, 2): 0, f(L).diff(L, 3): 0} ics2 = {f(0): 0, f(x).diff(x).subs(x, 0): 0, Subs(f(x).diff(x, 2), x, L): 0, Subs(f(x).diff(x, 3), x, L): 0} solved_constants1 = solve_ics(sols, funcs, constants, ics1) solved_constants2 = solve_ics(sols, funcs, constants, ics2) assert solved_constants1 == solved_constants2 == { C1: 0, C2: 0, C3: L**2*q/(4*EI), C4: -L*q/(6*EI)} def test_ode_order(): f = Function('f') g = Function('g') x = Symbol('x') assert ode_order(3*x*exp(f(x)), f(x)) == 0 assert ode_order(x*diff(f(x), x) + 3*x*f(x) - sin(x)/x, f(x)) == 1 assert ode_order(x**2*f(x).diff(x, x) + x*diff(f(x), x) - f(x), f(x)) == 2 assert ode_order(diff(x*exp(f(x)), x, x), f(x)) == 2 assert ode_order(diff(x*diff(x*exp(f(x)), x, x), x), f(x)) == 3 assert ode_order(diff(f(x), x, x), g(x)) == 0 assert ode_order(diff(f(x), x, x)*diff(g(x), x), f(x)) == 2 assert ode_order(diff(f(x), x, x)*diff(g(x), x), g(x)) == 1 assert ode_order(diff(x*diff(x*exp(f(x)), x, x), x), g(x)) == 0 # issue 5835: ode_order has to also work for unevaluated derivatives # (ie, without using doit()). assert ode_order(Derivative(x*f(x), x), f(x)) == 1 assert ode_order(x*sin(Derivative(x*f(x)**2, x, x)), f(x)) == 2 assert ode_order(Derivative(x*Derivative(x*exp(f(x)), x, x), x), g(x)) == 0 assert ode_order(Derivative(f(x), x, x), g(x)) == 0 assert ode_order(Derivative(x*exp(f(x)), x, x), f(x)) == 2 assert ode_order(Derivative(f(x), x, x)*Derivative(g(x), x), g(x)) == 1 assert ode_order(Derivative(x*Derivative(f(x), x, x), x), f(x)) == 3 assert ode_order( x*sin(Derivative(x*Derivative(f(x), x)**2, x, x)), f(x)) == 3 # In all tests below, checkodesol has the order option set to prevent # superfluous calls to ode_order(), and the solve_for_func flag set to False # because dsolve() already tries to solve for the function, unless the # simplify=False option is set. def test_old_ode_tests(): # These are simple tests from the old ode module eq1 = Eq(f(x).diff(x), 0) eq2 = Eq(3*f(x).diff(x) - 5, 0) eq3 = Eq(3*f(x).diff(x), 5) eq4 = Eq(9*f(x).diff(x, x) + f(x), 0) eq5 = Eq(9*f(x).diff(x, x), f(x)) # Type: a(x)f'(x)+b(x)*f(x)+c(x)=0 eq6 = Eq(x**2*f(x).diff(x) + 3*x*f(x) - sin(x)/x, 0) eq7 = Eq(f(x).diff(x, x) - 3*diff(f(x), x) + 2*f(x), 0) # Type: 2nd order, constant coefficients (two real different roots) eq8 = Eq(f(x).diff(x, x) - 4*diff(f(x), x) + 4*f(x), 0) # Type: 2nd order, constant coefficients (two real equal roots) eq9 = Eq(f(x).diff(x, x) + 2*diff(f(x), x) + 3*f(x), 0) # Type: 2nd order, constant coefficients (two complex roots) eq10 = Eq(3*f(x).diff(x) - 1, 0) eq11 = Eq(x*f(x).diff(x) - 1, 0) sol1 = Eq(f(x), C1) sol2 = Eq(f(x), C1 + 5*x/3) sol3 = Eq(f(x), C1 + 5*x/3) sol4 = Eq(f(x), C1*sin(x/3) + C2*cos(x/3)) sol5 = Eq(f(x), C1*exp(-x/3) + C2*exp(x/3)) sol6 = Eq(f(x), (C1 - cos(x))/x**3) sol7 = Eq(f(x), (C1 + C2*exp(x))*exp(x)) sol8 = Eq(f(x), (C1 + C2*x)*exp(2*x)) sol9 = Eq(f(x), (C1*sin(x*sqrt(2)) + C2*cos(x*sqrt(2)))*exp(-x)) sol10 = Eq(f(x), C1 + x/3) sol11 = Eq(f(x), C1 + log(x)) assert dsolve(eq1) == sol1 assert dsolve(eq1.lhs) == sol1 assert dsolve(eq2) == sol2 assert dsolve(eq3) == sol3 assert dsolve(eq4) == sol4 assert dsolve(eq5) == sol5 assert dsolve(eq6) == sol6 assert dsolve(eq7) == sol7 assert dsolve(eq8) == sol8 assert dsolve(eq9) == sol9 assert dsolve(eq10) == sol10 assert dsolve(eq11) == sol11 assert checkodesol(eq1, sol1, order=1, solve_for_func=False)[0] assert checkodesol(eq2, sol2, order=1, solve_for_func=False)[0] assert checkodesol(eq3, sol3, order=1, solve_for_func=False)[0] assert checkodesol(eq4, sol4, order=2, solve_for_func=False)[0] assert checkodesol(eq5, sol5, order=2, solve_for_func=False)[0] assert checkodesol(eq6, sol6, order=1, solve_for_func=False)[0] assert checkodesol(eq7, sol7, order=2, solve_for_func=False)[0] assert checkodesol(eq8, sol8, order=2, solve_for_func=False)[0] assert checkodesol(eq9, sol9, order=2, solve_for_func=False)[0] assert checkodesol(eq10, sol10, order=1, solve_for_func=False)[0] assert checkodesol(eq11, sol11, order=1, solve_for_func=False)[0] def test_1st_linear(): # Type: first order linear form f'(x)+p(x)f(x)=q(x) eq = Eq(f(x).diff(x) + x*f(x), x**2) sol = Eq(f(x), (C1 + x*exp(x**2/2) - sqrt(2)*sqrt(pi)*erfi(sqrt(2)*x/2)/2)*exp(-x**2/2)) assert dsolve(eq, hint='1st_linear') == sol assert checkodesol(eq, sol, order=1, solve_for_func=False)[0] def test_Bernoulli(): # Type: Bernoulli, f'(x) + p(x)*f(x) == q(x)*f(x)**n eq = Eq(x*f(x).diff(x) + f(x) - f(x)**2, 0) sol = dsolve(eq, f(x), hint='Bernoulli') assert sol == Eq(f(x), 1/(x*(C1 + 1/x))) assert checkodesol(eq, sol, order=1, solve_for_func=False)[0] def test_Riccati_special_minus2(): # Type: Riccati special alpha = -2, a*dy/dx + b*y**2 + c*y/x +d/x**2 eq = 2*f(x).diff(x) + f(x)**2 - f(x)/x + 3*x**(-2) sol = dsolve(eq, f(x), hint='Riccati_special_minus2') assert checkodesol(eq, sol, order=1, solve_for_func=False)[0] @slow def test_1st_exact1(): # Type: Exact differential equation, p(x,f) + q(x,f)*f' == 0, # where dp/df == dq/dx eq1 = sin(x)*cos(f(x)) + cos(x)*sin(f(x))*f(x).diff(x) eq2 = (2*x*f(x) + 1)/f(x) + (f(x) - x)/f(x)**2*f(x).diff(x) eq3 = 2*x + f(x)*cos(x) + (2*f(x) + sin(x) - sin(f(x)))*f(x).diff(x) eq4 = cos(f(x)) - (x*sin(f(x)) - f(x)**2)*f(x).diff(x) eq5 = 2*x*f(x) + (x**2 + f(x)**2)*f(x).diff(x) sol1 = [Eq(f(x), -acos(C1/cos(x)) + 2*pi), Eq(f(x), acos(C1/cos(x)))] sol2 = Eq(f(x), exp(C1 - x**2 + LambertW(-x*exp(-C1 + x**2)))) sol2b = Eq(log(f(x)) + x/f(x) + x**2, C1) sol3 = Eq(f(x)*sin(x) + cos(f(x)) + x**2 + f(x)**2, C1) sol4 = Eq(x*cos(f(x)) + f(x)**3/3, C1) sol5 = Eq(x**2*f(x) + f(x)**3/3, C1) assert dsolve(eq1, f(x), hint='1st_exact') == sol1 assert dsolve(eq2, f(x), hint='1st_exact') == sol2 assert dsolve(eq3, f(x), hint='1st_exact') == sol3 assert dsolve(eq4, hint='1st_exact') == sol4 assert dsolve(eq5, hint='1st_exact', simplify=False) == sol5 assert checkodesol(eq1, sol1, order=1, solve_for_func=False)[0] # issue 5080 blocks the testing of this solution # FIXME: assert checkodesol(eq2, sol2, order=1, solve_for_func=False)[0] assert checkodesol(eq2, sol2b, order=1, solve_for_func=False)[0] assert checkodesol(eq3, sol3, order=1, solve_for_func=False)[0] assert checkodesol(eq4, sol4, order=1, solve_for_func=False)[0] assert checkodesol(eq5, sol5, order=1, solve_for_func=False)[0] @slow @XFAIL def test_1st_exact2(): """ This is an exact equation that fails under the exact engine. It is caught by first order homogeneous albeit with a much contorted solution. The exact engine fails because of a poorly simplified integral of q(0,y)dy, where q is the function multiplying f'. The solutions should be Eq(sqrt(x**2+f(x)**2)**3+y**3, C1). The equation below is equivalent, but it is so complex that checkodesol fails, and takes a long time to do so. """ if ON_TRAVIS: skip("Too slow for travis.") eq = (x*sqrt(x**2 + f(x)**2) - (x**2*f(x)/(f(x) - sqrt(x**2 + f(x)**2)))*f(x).diff(x)) sol = dsolve(eq) assert sol == Eq(log(x), C1 - 9*sqrt(1 + f(x)**2/x**2)*asinh(f(x)/x)/(-27*f(x)/x + 27*sqrt(1 + f(x)**2/x**2)) - 9*sqrt(1 + f(x)**2/x**2)* log(1 - sqrt(1 + f(x)**2/x**2)*f(x)/x + 2*f(x)**2/x**2)/ (-27*f(x)/x + 27*sqrt(1 + f(x)**2/x**2)) + 9*asinh(f(x)/x)*f(x)/(x*(-27*f(x)/x + 27*sqrt(1 + f(x)**2/x**2))) + 9*f(x)*log(1 - sqrt(1 + f(x)**2/x**2)*f(x)/x + 2*f(x)**2/x**2)/ (x*(-27*f(x)/x + 27*sqrt(1 + f(x)**2/x**2)))) assert checkodesol(eq, sol, order=1, solve_for_func=False)[0] def test_separable1(): # test_separable1-5 are from Ordinary Differential Equations, Tenenbaum and # Pollard, pg. 55 eq1 = f(x).diff(x) - f(x) eq2 = x*f(x).diff(x) - f(x) eq3 = f(x).diff(x) + sin(x) eq4 = f(x)**2 + 1 - (x**2 + 1)*f(x).diff(x) eq5 = f(x).diff(x)/tan(x) - f(x) - 2 eq6 = f(x).diff(x) * (1 - sin(f(x))) - 1 sol1 = Eq(f(x), C1*exp(x)) sol2 = Eq(f(x), C1*x) sol3 = Eq(f(x), C1 + cos(x)) sol4 = Eq(f(x), tan(C1 + atan(x))) sol5 = Eq(f(x), C1/cos(x) - 2) sol6 = Eq(-x + f(x) + cos(f(x)), C1) assert dsolve(eq1, hint='separable') == sol1 assert dsolve(eq2, hint='separable') == sol2 assert dsolve(eq3, hint='separable') == sol3 assert dsolve(eq4, hint='separable') == sol4 assert dsolve(eq5, hint='separable') == sol5 assert dsolve(eq6, hint='separable') == sol6 assert checkodesol(eq1, sol1, order=1, solve_for_func=False)[0] assert checkodesol(eq2, sol2, order=1, solve_for_func=False)[0] assert checkodesol(eq3, sol3, order=1, solve_for_func=False)[0] assert checkodesol(eq4, sol4, order=1, solve_for_func=False)[0] assert checkodesol(eq5, sol5, order=1, solve_for_func=False)[0] assert checkodesol(eq6, sol6, order=1, solve_for_func=False)[0] @slow def test_separable2(): a = Symbol('a') eq6 = f(x)*x**2*f(x).diff(x) - f(x)**3 - 2*x**2*f(x).diff(x) eq7 = f(x)**2 - 1 - (2*f(x) + x*f(x))*f(x).diff(x) eq8 = x*log(x)*f(x).diff(x) + sqrt(1 + f(x)**2) eq9 = exp(x + 1)*tan(f(x)) + cos(f(x))*f(x).diff(x) eq10 = (x*cos(f(x)) + x**2*sin(f(x))*f(x).diff(x) - a**2*sin(f(x))*f(x).diff(x)) sol6 = Eq(Integral((u - 2)/u**3, (u, f(x))), C1 + Integral(x**(-2), x)) sol7 = Eq(-log(-1 + f(x)**2)/2, C1 - log(2 + x)) sol8 = Eq(asinh(f(x)), C1 - log(log(x))) # integrate cannot handle the integral on the lhs (cos/tan) sol9 = Eq(Integral(cos(u)/tan(u), (u, f(x))), C1 + Integral(-exp(1)*exp(x), x)) sol10 = Eq(-log(cos(f(x))), C1 - log(- a**2 + x**2)/2) assert dsolve(eq6, hint='separable_Integral').dummy_eq(sol6) assert dsolve(eq7, hint='separable', simplify=False) == sol7 assert dsolve(eq8, hint='separable', simplify=False) == sol8 assert dsolve(eq9, hint='separable_Integral').dummy_eq(sol9) assert dsolve(eq10, hint='separable', simplify=False) == sol10 assert checkodesol(eq6, sol6, order=1, solve_for_func=False)[0] assert checkodesol(eq7, sol7, order=1, solve_for_func=False)[0] assert checkodesol(eq8, sol8, order=1, solve_for_func=False)[0] assert checkodesol(eq9, sol9, order=1, solve_for_func=False)[0] assert checkodesol(eq10, sol10, order=1, solve_for_func=False)[0] def test_separable3(): eq11 = f(x).diff(x) - f(x)*tan(x) eq12 = (x - 1)*cos(f(x))*f(x).diff(x) - 2*x*sin(f(x)) eq13 = f(x).diff(x) - f(x)*log(f(x))/tan(x) sol11 = Eq(f(x), C1/cos(x)) sol12 = Eq(log(sin(f(x))), C1 + 2*x + 2*log(x - 1)) sol13 = Eq(log(log(f(x))), C1 + log(sin(x))) assert dsolve(eq11, hint='separable') == sol11 assert dsolve(eq12, hint='separable', simplify=False) == sol12 assert dsolve(eq13, hint='separable', simplify=False) == sol13 assert checkodesol(eq11, sol11, order=1, solve_for_func=False)[0] assert checkodesol(eq12, sol12, order=1, solve_for_func=False)[0] assert checkodesol(eq13, sol13, order=1, solve_for_func=False)[0] def test_separable4(): # This has a slow integral (1/((1 + y**2)*atan(y))), so we isolate it. eq14 = x*f(x).diff(x) + (1 + f(x)**2)*atan(f(x)) sol14 = Eq(log(atan(f(x))), C1 - log(x)) assert dsolve(eq14, hint='separable', simplify=False) == sol14 assert checkodesol(eq14, sol14, order=1, solve_for_func=False)[0] def test_separable5(): eq15 = f(x).diff(x) + x*(f(x) + 1) eq16 = exp(f(x)**2)*(x**2 + 2*x + 1) + (x*f(x) + f(x))*f(x).diff(x) eq17 = f(x).diff(x) + f(x) eq18 = sin(x)*cos(2*f(x)) + cos(x)*sin(2*f(x))*f(x).diff(x) eq19 = (1 - x)*f(x).diff(x) - x*(f(x) + 1) eq20 = f(x)*diff(f(x), x) + x - 3*x*f(x)**2 eq21 = f(x).diff(x) - exp(x + f(x)) sol15 = Eq(f(x), -1 + C1*exp(-x**2/2)) sol16 = Eq(-exp(-f(x)**2)/2, C1 - x - x**2/2) sol17 = Eq(f(x), C1*exp(-x)) sol18 = Eq(-log(cos(2*f(x)))/2, C1 + log(cos(x))) sol19 = Eq(f(x), (C1*exp(-x) - x + 1)/(x - 1)) sol20 = Eq(log(-1 + 3*f(x)**2)/6, C1 + x**2/2) sol21 = Eq(-exp(-f(x)), C1 + exp(x)) assert dsolve(eq15, hint='separable') == sol15 assert dsolve(eq16, hint='separable', simplify=False) == sol16 assert dsolve(eq17, hint='separable') == sol17 assert dsolve(eq18, hint='separable', simplify=False) == sol18 assert dsolve(eq19, hint='separable') == sol19 assert dsolve(eq20, hint='separable', simplify=False) == sol20 assert dsolve(eq21, hint='separable', simplify=False) == sol21 assert checkodesol(eq15, sol15, order=1, solve_for_func=False)[0] assert checkodesol(eq16, sol16, order=1, solve_for_func=False)[0] assert checkodesol(eq17, sol17, order=1, solve_for_func=False)[0] assert checkodesol(eq18, sol18, order=1, solve_for_func=False)[0] assert checkodesol(eq19, sol19, order=1, solve_for_func=False)[0] assert checkodesol(eq20, sol20, order=1, solve_for_func=False)[0] assert checkodesol(eq21, sol21, order=1, solve_for_func=False)[0] def test_separable_1_5_checkodesol(): eq12 = (x - 1)*cos(f(x))*f(x).diff(x) - 2*x*sin(f(x)) sol12 = Eq(-log(1 - cos(f(x))**2)/2, C1 - 2*x - 2*log(1 - x)) assert checkodesol(eq12, sol12, order=1, solve_for_func=False)[0] def test_homogeneous_order(): assert homogeneous_order(exp(y/x) + tan(y/x), x, y) == 0 assert homogeneous_order(x**2 + sin(x)*cos(y), x, y) is None assert homogeneous_order(x - y - x*sin(y/x), x, y) == 1 assert homogeneous_order((x*y + sqrt(x**4 + y**4) + x**2*(log(x) - log(y)))/ (pi*x**Rational(2, 3)*sqrt(y)**3), x, y) == Rational(-1, 6) assert homogeneous_order(y/x*cos(y/x) - x/y*sin(y/x) + cos(y/x), x, y) == 0 assert homogeneous_order(f(x), x, f(x)) == 1 assert homogeneous_order(f(x)**2, x, f(x)) == 2 assert homogeneous_order(x*y*z, x, y) == 2 assert homogeneous_order(x*y*z, x, y, z) == 3 assert homogeneous_order(x**2*f(x)/sqrt(x**2 + f(x)**2), f(x)) is None assert homogeneous_order(f(x, y)**2, x, f(x, y), y) == 2 assert homogeneous_order(f(x, y)**2, x, f(x), y) is None assert homogeneous_order(f(x, y)**2, x, f(x, y)) is None assert homogeneous_order(f(y, x)**2, x, y, f(x, y)) is None assert homogeneous_order(f(y), f(x), x) is None assert homogeneous_order(-f(x)/x + 1/sin(f(x)/ x), f(x), x) == 0 assert homogeneous_order(log(1/y) + log(x**2), x, y) is None assert homogeneous_order(log(1/y) + log(x), x, y) == 0 assert homogeneous_order(log(x/y), x, y) == 0 assert homogeneous_order(2*log(1/y) + 2*log(x), x, y) == 0 a = Symbol('a') assert homogeneous_order(a*log(1/y) + a*log(x), x, y) == 0 assert homogeneous_order(f(x).diff(x), x, y) is None assert homogeneous_order(-f(x).diff(x) + x, x, y) is None assert homogeneous_order(O(x), x, y) is None assert homogeneous_order(x + O(x**2), x, y) is None assert homogeneous_order(x**pi, x) == pi assert homogeneous_order(x**x, x) is None raises(ValueError, lambda: homogeneous_order(x*y)) @slow def test_1st_homogeneous_coeff_ode(): # Type: First order homogeneous, y'=f(y/x) eq1 = f(x)/x*cos(f(x)/x) - (x/f(x)*sin(f(x)/x) + cos(f(x)/x))*f(x).diff(x) eq2 = x*f(x).diff(x) - f(x) - x*sin(f(x)/x) eq3 = f(x) + (x*log(f(x)/x) - 2*x)*diff(f(x), x) eq4 = 2*f(x)*exp(x/f(x)) + f(x)*f(x).diff(x) - 2*x*exp(x/f(x))*f(x).diff(x) eq5 = 2*x**2*f(x) + f(x)**3 + (x*f(x)**2 - 2*x**3)*f(x).diff(x) eq6 = x*exp(f(x)/x) - f(x)*sin(f(x)/x) + x*sin(f(x)/x)*f(x).diff(x) eq7 = (x + sqrt(f(x)**2 - x*f(x)))*f(x).diff(x) - f(x) eq8 = x + f(x) - (x - f(x))*f(x).diff(x) sol1 = Eq(log(x), C1 - log(f(x)*sin(f(x)/x)/x)) sol2 = Eq(log(x), log(C1) + log(cos(f(x)/x) - 1)/2 - log(cos(f(x)/x) + 1)/2) sol3 = Eq(f(x), -exp(C1)*LambertW(-x*exp(-C1 + 1))) sol4 = Eq(log(f(x)), C1 - 2*exp(x/f(x))) sol5 = Eq(f(x), exp(2*C1 + LambertW(-2*x**4*exp(-4*C1))/2)/x) sol6 = Eq(log(x), C1 + exp(-f(x)/x)*sin(f(x)/x)/2 + exp(-f(x)/x)*cos(f(x)/x)/2) sol7 = Eq(log(f(x)), C1 - 2*sqrt(-x/f(x) + 1)) sol8 = Eq(log(x), C1 - log(sqrt(1 + f(x)**2/x**2)) + atan(f(x)/x)) # indep_div_dep actually has a simpler solution for eq2, # but it runs too slow assert dsolve(eq1, hint='1st_homogeneous_coeff_subs_dep_div_indep') == sol1 assert dsolve(eq2, hint='1st_homogeneous_coeff_subs_dep_div_indep', simplify=False) == sol2 assert dsolve(eq3, hint='1st_homogeneous_coeff_best') == sol3 assert dsolve(eq4, hint='1st_homogeneous_coeff_best') == sol4 assert dsolve(eq5, hint='1st_homogeneous_coeff_best') == sol5 assert dsolve(eq6, hint='1st_homogeneous_coeff_subs_dep_div_indep') == sol6 assert dsolve(eq7, hint='1st_homogeneous_coeff_best') == sol7 assert dsolve(eq8, hint='1st_homogeneous_coeff_best') == sol8 # FIXME: sol3 and sol5 don't work with checkodesol (because of LambertW?) # previous code was testing with these other solutions: sol3b = Eq(-f(x)/(1 + log(x/f(x))), C1) sol5b = Eq(log(C1*x*sqrt(1/x)*sqrt(f(x))) + x**2/(2*f(x)**2), 0) assert checkodesol(eq1, sol1, order=1, solve_for_func=False)[0] assert checkodesol(eq2, sol2, order=1, solve_for_func=False)[0] assert checkodesol(eq3, sol3b, order=1, solve_for_func=False)[0] assert checkodesol(eq4, sol4, order=1, solve_for_func=False)[0] assert checkodesol(eq5, sol5b, order=1, solve_for_func=False)[0] assert checkodesol(eq6, sol6, order=1, solve_for_func=False)[0] assert checkodesol(eq8, sol8, order=1, solve_for_func=False)[0] def test_1st_homogeneous_coeff_ode_check2(): eq2 = x*f(x).diff(x) - f(x) - x*sin(f(x)/x) sol2 = Eq(x/tan(f(x)/(2*x)), C1) assert checkodesol(eq2, sol2, order=1, solve_for_func=False)[0] @XFAIL def test_1st_homogeneous_coeff_ode_check3(): skip('This is a known issue.') # checker cannot determine that the following expression is zero: # (False, # x*(log(exp(-LambertW(C1*x))) + # LambertW(C1*x))*exp(-LambertW(C1*x) + 1)) # This is blocked by issue 5080. eq3 = f(x) + (x*log(f(x)/x) - 2*x)*diff(f(x), x) sol3a = Eq(f(x), x*exp(1 - LambertW(C1*x))) assert checkodesol(eq3, sol3a, solve_for_func=True)[0] # Checker can't verify this form either # (False, # C1*(log(C1*LambertW(C2*x)/x) + LambertW(C2*x) - 1)*LambertW(C2*x)) # It is because a = W(a)*exp(W(a)), so log(a) == log(W(a)) + W(a) and C2 = # -E/C1 (which can be verified by solving with simplify=False). sol3b = Eq(f(x), C1*LambertW(C2*x)) assert checkodesol(eq3, sol3b, solve_for_func=True)[0] def test_1st_homogeneous_coeff_ode_check7(): eq7 = (x + sqrt(f(x)**2 - x*f(x)))*f(x).diff(x) - f(x) sol7 = Eq(log(C1*f(x)) + 2*sqrt(1 - x/f(x)), 0) assert checkodesol(eq7, sol7, order=1, solve_for_func=False)[0] def test_1st_homogeneous_coeff_ode2(): eq1 = f(x).diff(x) - f(x)/x + 1/sin(f(x)/x) eq2 = x**2 + f(x)**2 - 2*x*f(x)*f(x).diff(x) eq3 = x*exp(f(x)/x) + f(x) - x*f(x).diff(x) sol1 = [Eq(f(x), x*(-acos(C1 + log(x)) + 2*pi)), Eq(f(x), x*acos(C1 + log(x)))] sol2 = Eq(log(f(x)), log(C1) + log(x/f(x)) - log(x**2/f(x)**2 - 1)) sol3 = Eq(f(x), log((1/(C1 - log(x)))**x)) # specific hints are applied for speed reasons assert dsolve(eq1, hint='1st_homogeneous_coeff_subs_dep_div_indep') == sol1 assert dsolve(eq2, hint='1st_homogeneous_coeff_best', simplify=False) == sol2 assert dsolve(eq3, hint='1st_homogeneous_coeff_subs_dep_div_indep') == sol3 # FIXME: sol3 doesn't work with checkodesol (because of **x?) # previous code was testing with this other solution: sol3b = Eq(f(x), log(log(C1/x)**(-x))) assert checkodesol(eq1, sol1, order=1, solve_for_func=False)[0] assert checkodesol(eq2, sol2, order=1, solve_for_func=False)[0] assert checkodesol(eq3, sol3b, order=1, solve_for_func=False)[0] def test_1st_homogeneous_coeff_ode_check9(): _u2 = Dummy('u2') __a = Dummy('a') eq9 = f(x)**2 + (x*sqrt(f(x)**2 - x**2) - x*f(x))*f(x).diff(x) sol9 = Eq(-Integral(-1/(-(1 - sqrt(1 - _u2**2))*_u2 + _u2), (_u2, __a, x/f(x))) + log(C1*f(x)), 0) assert checkodesol(eq9, sol9, order=1, solve_for_func=False)[0] def test_1st_homogeneous_coeff_ode3(): # The standard integration engine cannot handle one of the integrals # involved (see issue 4551). meijerg code comes up with an answer, but in # unconventional form. # checkodesol fails for this equation, so its test is in # test_1st_homogeneous_coeff_ode_check9 above. It has to compare string # expressions because u2 is a dummy variable. eq = f(x)**2 + (x*sqrt(f(x)**2 - x**2) - x*f(x))*f(x).diff(x) sol = Eq(log(f(x)), C1 + Piecewise( (acosh(f(x)/x), abs(f(x)**2)/x**2 > 1), (-I*asin(f(x)/x), True))) assert dsolve(eq, hint='1st_homogeneous_coeff_subs_indep_div_dep') == sol def test_1st_homogeneous_coeff_corner_case(): eq1 = f(x).diff(x) - f(x)/x c1 = classify_ode(eq1, f(x)) eq2 = x*f(x).diff(x) - f(x) c2 = classify_ode(eq2, f(x)) sdi = "1st_homogeneous_coeff_subs_dep_div_indep" sid = "1st_homogeneous_coeff_subs_indep_div_dep" assert sid not in c1 and sdi not in c1 assert sid not in c2 and sdi not in c2 @slow def test_nth_linear_constant_coeff_homogeneous(): # From Exercise 20, in Ordinary Differential Equations, # Tenenbaum and Pollard, pg. 220 a = Symbol('a', positive=True) k = Symbol('k', real=True) eq1 = f(x).diff(x, 2) + 2*f(x).diff(x) eq2 = f(x).diff(x, 2) - 3*f(x).diff(x) + 2*f(x) eq3 = f(x).diff(x, 2) - f(x) eq4 = f(x).diff(x, 3) + f(x).diff(x, 2) - 6*f(x).diff(x) eq5 = 6*f(x).diff(x, 2) - 11*f(x).diff(x) + 4*f(x) eq6 = Eq(f(x).diff(x, 2) + 2*f(x).diff(x) - f(x), 0) eq7 = diff(f(x), x, 3) + diff(f(x), x, 2) - 10*diff(f(x), x) - 6*f(x) eq8 = f(x).diff(x, 4) - f(x).diff(x, 3) - 4*f(x).diff(x, 2) + \ 4*f(x).diff(x) eq9 = f(x).diff(x, 4) + 4*f(x).diff(x, 3) + f(x).diff(x, 2) - \ 4*f(x).diff(x) - 2*f(x) eq10 = f(x).diff(x, 4) - a**2*f(x) eq11 = f(x).diff(x, 2) - 2*k*f(x).diff(x) - 2*f(x) eq12 = f(x).diff(x, 2) + 4*k*f(x).diff(x) - 12*k**2*f(x) eq13 = f(x).diff(x, 4) eq14 = f(x).diff(x, 2) + 4*f(x).diff(x) + 4*f(x) eq15 = 3*f(x).diff(x, 3) + 5*f(x).diff(x, 2) + f(x).diff(x) - f(x) eq16 = f(x).diff(x, 3) - 6*f(x).diff(x, 2) + 12*f(x).diff(x) - 8*f(x) eq17 = f(x).diff(x, 2) - 2*a*f(x).diff(x) + a**2*f(x) eq18 = f(x).diff(x, 4) + 3*f(x).diff(x, 3) eq19 = f(x).diff(x, 4) - 2*f(x).diff(x, 2) eq20 = f(x).diff(x, 4) + 2*f(x).diff(x, 3) - 11*f(x).diff(x, 2) - \ 12*f(x).diff(x) + 36*f(x) eq21 = 36*f(x).diff(x, 4) - 37*f(x).diff(x, 2) + 4*f(x).diff(x) + 5*f(x) eq22 = f(x).diff(x, 4) - 8*f(x).diff(x, 2) + 16*f(x) eq23 = f(x).diff(x, 2) - 2*f(x).diff(x) + 5*f(x) eq24 = f(x).diff(x, 2) - f(x).diff(x) + f(x) eq25 = f(x).diff(x, 4) + 5*f(x).diff(x, 2) + 6*f(x) eq26 = f(x).diff(x, 2) - 4*f(x).diff(x) + 20*f(x) eq27 = f(x).diff(x, 4) + 4*f(x).diff(x, 2) + 4*f(x) eq28 = f(x).diff(x, 3) + 8*f(x) eq29 = f(x).diff(x, 4) + 4*f(x).diff(x, 2) eq30 = f(x).diff(x, 5) + 2*f(x).diff(x, 3) + f(x).diff(x) eq31 = f(x).diff(x, 4) + f(x).diff(x, 2) + f(x) eq32 = f(x).diff(x, 4) + 4*f(x).diff(x, 2) + f(x) sol1 = Eq(f(x), C1 + C2*exp(-2*x)) sol2 = Eq(f(x), (C1 + C2*exp(x))*exp(x)) sol3 = Eq(f(x), C1*exp(x) + C2*exp(-x)) sol4 = Eq(f(x), C1 + C2*exp(-3*x) + C3*exp(2*x)) sol5 = Eq(f(x), C1*exp(x/2) + C2*exp(4*x/3)) sol6 = Eq(f(x), C1*exp(x*(-1 + sqrt(2))) + C2*exp(x*(-sqrt(2) - 1))) sol7 = Eq(f(x), C1*exp(3*x) + C2*exp(x*(-2 - sqrt(2))) + C3*exp(x*(-2 + sqrt(2)))) sol8 = Eq(f(x), C1 + C2*exp(x) + C3*exp(-2*x) + C4*exp(2*x)) sol9 = Eq(f(x), C1*exp(x) + C2*exp(-x) + C3*exp(x*(-2 + sqrt(2))) + C4*exp(x*(-2 - sqrt(2)))) sol10 = Eq(f(x), C1*sin(x*sqrt(a)) + C2*cos(x*sqrt(a)) + C3*exp(x*sqrt(a)) + C4*exp(-x*sqrt(a))) sol11 = Eq(f(x), C1*exp(x*(k - sqrt(k**2 + 2))) + C2*exp(x*(k + sqrt(k**2 + 2)))) sol12 = Eq(f(x), C1*exp(-6*k*x) + C2*exp(2*k*x)) sol13 = Eq(f(x), C1 + C2*x + C3*x**2 + C4*x**3) sol14 = Eq(f(x), (C1 + C2*x)*exp(-2*x)) sol15 = Eq(f(x), (C1 + C2*x)*exp(-x) + C3*exp(x/3)) sol16 = Eq(f(x), (C1 + C2*x + C3*x**2)*exp(2*x)) sol17 = Eq(f(x), (C1 + C2*x)*exp(a*x)) sol18 = Eq(f(x), C1 + C2*x + C3*x**2 + C4*exp(-3*x)) sol19 = Eq(f(x), C1 + C2*x + C3*exp(x*sqrt(2)) + C4*exp(-x*sqrt(2))) sol20 = Eq(f(x), (C1 + C2*x)*exp(-3*x) + (C3 + C4*x)*exp(2*x)) sol21 = Eq(f(x), C1*exp(x/2) + C2*exp(-x) + C3*exp(-x/3) + C4*exp(5*x/6)) sol22 = Eq(f(x), (C1 + C2*x)*exp(-2*x) + (C3 + C4*x)*exp(2*x)) sol23 = Eq(f(x), (C1*sin(2*x) + C2*cos(2*x))*exp(x)) sol24 = Eq(f(x), (C1*sin(x*sqrt(3)/2) + C2*cos(x*sqrt(3)/2))*exp(x/2)) sol25 = Eq(f(x), C1*cos(x*sqrt(3)) + C2*sin(x*sqrt(3)) + C3*sin(x*sqrt(2)) + C4*cos(x*sqrt(2))) sol26 = Eq(f(x), (C1*sin(4*x) + C2*cos(4*x))*exp(2*x)) sol27 = Eq(f(x), (C1 + C2*x)*sin(x*sqrt(2)) + (C3 + C4*x)*cos(x*sqrt(2))) sol28 = Eq(f(x), (C1*sin(x*sqrt(3)) + C2*cos(x*sqrt(3)))*exp(x) + C3*exp(-2*x)) sol29 = Eq(f(x), C1 + C2*sin(2*x) + C3*cos(2*x) + C4*x) sol30 = Eq(f(x), C1 + (C2 + C3*x)*sin(x) + (C4 + C5*x)*cos(x)) sol31 = Eq(f(x), (C1*sin(sqrt(3)*x/2) + C2*cos(sqrt(3)*x/2))/sqrt(exp(x)) + (C3*sin(sqrt(3)*x/2) + C4*cos(sqrt(3)*x/2))*sqrt(exp(x))) sol32 = Eq(f(x), C1*sin(x*sqrt(-sqrt(3) + 2)) + C2*sin(x*sqrt(sqrt(3) + 2)) + C3*cos(x*sqrt(-sqrt(3) + 2)) + C4*cos(x*sqrt(sqrt(3) + 2))) sol1s = constant_renumber(sol1) sol2s = constant_renumber(sol2) sol3s = constant_renumber(sol3) sol4s = constant_renumber(sol4) sol5s = constant_renumber(sol5) sol6s = constant_renumber(sol6) sol7s = constant_renumber(sol7) sol8s = constant_renumber(sol8) sol9s = constant_renumber(sol9) sol10s = constant_renumber(sol10) sol11s = constant_renumber(sol11) sol12s = constant_renumber(sol12) sol13s = constant_renumber(sol13) sol14s = constant_renumber(sol14) sol15s = constant_renumber(sol15) sol16s = constant_renumber(sol16) sol17s = constant_renumber(sol17) sol18s = constant_renumber(sol18) sol19s = constant_renumber(sol19) sol20s = constant_renumber(sol20) sol21s = constant_renumber(sol21) sol22s = constant_renumber(sol22) sol23s = constant_renumber(sol23) sol24s = constant_renumber(sol24) sol25s = constant_renumber(sol25) sol26s = constant_renumber(sol26) sol27s = constant_renumber(sol27) sol28s = constant_renumber(sol28) sol29s = constant_renumber(sol29) sol30s = constant_renumber(sol30) assert dsolve(eq1) in (sol1, sol1s) assert dsolve(eq2) in (sol2, sol2s) assert dsolve(eq3) in (sol3, sol3s) assert dsolve(eq4) in (sol4, sol4s) assert dsolve(eq5) in (sol5, sol5s) assert dsolve(eq6) in (sol6, sol6s) assert dsolve(eq7) in (sol7, sol7s) assert dsolve(eq8) in (sol8, sol8s) assert dsolve(eq9) in (sol9, sol9s) assert dsolve(eq10) in (sol10, sol10s) assert dsolve(eq11) in (sol11, sol11s) assert dsolve(eq12) in (sol12, sol12s) assert dsolve(eq13) in (sol13, sol13s) assert dsolve(eq14) in (sol14, sol14s) assert dsolve(eq15) in (sol15, sol15s) assert dsolve(eq16) in (sol16, sol16s) assert dsolve(eq17) in (sol17, sol17s) assert dsolve(eq18) in (sol18, sol18s) assert dsolve(eq19) in (sol19, sol19s) assert dsolve(eq20) in (sol20, sol20s) assert dsolve(eq21) in (sol21, sol21s) assert dsolve(eq22) in (sol22, sol22s) assert dsolve(eq23) in (sol23, sol23s) assert dsolve(eq24) in (sol24, sol24s) assert dsolve(eq25) in (sol25, sol25s) assert dsolve(eq26) in (sol26, sol26s) assert dsolve(eq27) in (sol27, sol27s) assert dsolve(eq28) in (sol28, sol28s) assert dsolve(eq29) in (sol29, sol29s) assert dsolve(eq30) in (sol30, sol30s) assert dsolve(eq31) in (sol31,) assert dsolve(eq32) in (sol32,) assert checkodesol(eq1, sol1, order=2, solve_for_func=False)[0] assert checkodesol(eq2, sol2, order=2, solve_for_func=False)[0] assert checkodesol(eq3, sol3, order=2, solve_for_func=False)[0] assert checkodesol(eq4, sol4, order=3, solve_for_func=False)[0] assert checkodesol(eq5, sol5, order=2, solve_for_func=False)[0] assert checkodesol(eq6, sol6, order=2, solve_for_func=False)[0] assert checkodesol(eq7, sol7, order=3, solve_for_func=False)[0] assert checkodesol(eq8, sol8, order=4, solve_for_func=False)[0] assert checkodesol(eq9, sol9, order=4, solve_for_func=False)[0] assert checkodesol(eq10, sol10, order=4, solve_for_func=False)[0] assert checkodesol(eq11, sol11, order=2, solve_for_func=False)[0] assert checkodesol(eq12, sol12, order=2, solve_for_func=False)[0] assert checkodesol(eq13, sol13, order=4, solve_for_func=False)[0] assert checkodesol(eq14, sol14, order=2, solve_for_func=False)[0] assert checkodesol(eq15, sol15, order=3, solve_for_func=False)[0] assert checkodesol(eq16, sol16, order=3, solve_for_func=False)[0] assert checkodesol(eq17, sol17, order=2, solve_for_func=False)[0] assert checkodesol(eq18, sol18, order=4, solve_for_func=False)[0] assert checkodesol(eq19, sol19, order=4, solve_for_func=False)[0] assert checkodesol(eq20, sol20, order=4, solve_for_func=False)[0] assert checkodesol(eq21, sol21, order=4, solve_for_func=False)[0] assert checkodesol(eq22, sol22, order=4, solve_for_func=False)[0] assert checkodesol(eq23, sol23, order=2, solve_for_func=False)[0] assert checkodesol(eq24, sol24, order=2, solve_for_func=False)[0] assert checkodesol(eq25, sol25, order=4, solve_for_func=False)[0] assert checkodesol(eq26, sol26, order=2, solve_for_func=False)[0] assert checkodesol(eq27, sol27, order=4, solve_for_func=False)[0] assert checkodesol(eq28, sol28, order=3, solve_for_func=False)[0] assert checkodesol(eq29, sol29, order=4, solve_for_func=False)[0] assert checkodesol(eq30, sol30, order=5, solve_for_func=False)[0] assert checkodesol(eq31, sol31, order=4, solve_for_func=False)[0] assert checkodesol(eq32, sol32, order=4, solve_for_func=False)[0] # Issue #15237 eqn = Derivative(x*f(x), x, x, x) hint = 'nth_linear_constant_coeff_homogeneous' raises(ValueError, lambda: dsolve(eqn, f(x), hint, prep=True)) raises(ValueError, lambda: dsolve(eqn, f(x), hint, prep=False)) def test_nth_linear_constant_coeff_homogeneous_rootof(): # One real root, two complex conjugate pairs eq = f(x).diff(x, 5) + 11*f(x).diff(x) - 2*f(x) r1, r2, r3, r4, r5 = [rootof(x**5 + 11*x - 2, n) for n in range(5)] sol = Eq(f(x), C5*exp(r1*x) + exp(re(r2)*x) * (C1*sin(im(r2)*x) + C2*cos(im(r2)*x)) + exp(re(r4)*x) * (C3*sin(im(r4)*x) + C4*cos(im(r4)*x)) ) assert dsolve(eq) == sol # FIXME: assert checkodesol(eq, sol) == (True, [0]) # Hangs... # Three real roots, one complex conjugate pair eq = f(x).diff(x,5) - 3*f(x).diff(x) + f(x) r1, r2, r3, r4, r5 = [rootof(x**5 - 3*x + 1, n) for n in range(5)] sol = Eq(f(x), C3*exp(r1*x) + C4*exp(r2*x) + C5*exp(r3*x) + exp(re(r4)*x) * (C1*sin(im(r4)*x) + C2*cos(im(r4)*x)) ) assert dsolve(eq) == sol # FIXME: assert checkodesol(eq, sol) == (True, [0]) # Hangs... # Five distinct real roots eq = f(x).diff(x,5) - 100*f(x).diff(x,3) + 1000*f(x).diff(x) + f(x) r1, r2, r3, r4, r5 = [rootof(x**5 - 100*x**3 + 1000*x + 1, n) for n in range(5)] sol = Eq(f(x), C1*exp(r1*x) + C2*exp(r2*x) + C3*exp(r3*x) + C4*exp(r4*x) + C5*exp(r5*x)) assert dsolve(eq) == sol # FIXME: assert checkodesol(eq, sol) == (True, [0]) # Hangs... # Rational root and unsolvable quintic eq = f(x).diff(x, 6) - 6*f(x).diff(x, 5) + 5*f(x).diff(x, 4) + 10*f(x).diff(x) - 50 * f(x) r2, r3, r4, r5, r6 = [rootof(x**5 - x**4 + 10, n) for n in range(5)] sol = Eq(f(x), C5*exp(5*x) + C6*exp(x*r2) + exp(re(r3)*x) * (C1*sin(im(r3)*x) + C2*cos(im(r3)*x)) + exp(re(r5)*x) * (C3*sin(im(r5)*x) + C4*cos(im(r5)*x)) ) assert dsolve(eq) == sol # FIXME: assert checkodesol(eq, sol) == (True, [0]) # Hangs... # Five double roots (this is (x**5 - x + 1)**2) eq = f(x).diff(x, 10) - 2*f(x).diff(x, 6) + 2*f(x).diff(x, 5) + f(x).diff(x, 2) - 2*f(x).diff(x, 1) + f(x) r1, r2, r3, r4, r5 = [rootof(x**5 - x + 1, n) for n in range(5)] sol = Eq(f(x), (C1 + C2 *x)*exp(r1*x) + exp(re(r2)*x) * ((C3 + C4*x)*sin(im(r2)*x) + (C5 + C6 *x)*cos(im(r2)*x)) + exp(re(r4)*x) * ((C7 + C8*x)*sin(im(r4)*x) + (C9 + C10*x)*cos(im(r4)*x)) ) assert dsolve(eq) == sol # FIXME: assert checkodesol(eq, sol) == (True, [0]) # Hangs... def test_nth_linear_constant_coeff_homogeneous_irrational(): our_hint='nth_linear_constant_coeff_homogeneous' eq = Eq(sqrt(2) * f(x).diff(x,x,x) + f(x).diff(x), 0) sol = Eq(f(x), C1 + C2*sin(2**(S(3)/4)*x/2) + C3*cos(2**(S(3)/4)*x/2)) assert our_hint in classify_ode(eq) assert dsolve(eq, f(x), hint=our_hint) == sol assert dsolve(eq, f(x)) == sol assert checkodesol(eq, sol, order=3, solve_for_func=False)[0] E = exp(1) eq = Eq(E * f(x).diff(x,x,x) + f(x).diff(x), 0) sol = Eq(f(x), C1 + C2*sin(x/sqrt(E)) + C3*cos(x/sqrt(E))) assert our_hint in classify_ode(eq) assert dsolve(eq, f(x), hint=our_hint) == sol assert dsolve(eq, f(x)) == sol assert checkodesol(eq, sol, order=3, solve_for_func=False)[0] eq = Eq(pi * f(x).diff(x,x,x) + f(x).diff(x), 0) sol = Eq(f(x), C1 + C2*sin(x/sqrt(pi)) + C3*cos(x/sqrt(pi))) assert our_hint in classify_ode(eq) assert dsolve(eq, f(x), hint=our_hint) == sol assert dsolve(eq, f(x)) == sol assert checkodesol(eq, sol, order=3, solve_for_func=False)[0] eq = Eq(I * f(x).diff(x,x,x) + f(x).diff(x), 0) sol = Eq(f(x), C1 + C2*exp(-sqrt(I)*x) + C3*exp(sqrt(I)*x)) assert our_hint in classify_ode(eq) assert dsolve(eq, f(x), hint=our_hint) == sol assert dsolve(eq, f(x)) == sol assert checkodesol(eq, sol, order=3, solve_for_func=False)[0] @XFAIL @slow def test_nth_linear_constant_coeff_homogeneous_rootof_sol(): if ON_TRAVIS: skip("Too slow for travis.") eq = f(x).diff(x, 5) + 11*f(x).diff(x) - 2*f(x) sol = Eq(f(x), C1*exp(x*rootof(x**5 + 11*x - 2, 0)) + C2*exp(x*rootof(x**5 + 11*x - 2, 1)) + C3*exp(x*rootof(x**5 + 11*x - 2, 2)) + C4*exp(x*rootof(x**5 + 11*x - 2, 3)) + C5*exp(x*rootof(x**5 + 11*x - 2, 4))) assert checkodesol(eq, sol, order=5, solve_for_func=False)[0] @XFAIL def test_noncircularized_real_imaginary_parts(): # If this passes, lines numbered 3878-3882 (at the time of this commit) # of sympy/solvers/ode.py for nth_linear_constant_coeff_homogeneous # should be removed. y = sqrt(1+x) i, r = im(y), re(y) assert not (i.has(atan2) and r.has(atan2)) @XFAIL def test_collect_respecting_exponentials(): # If this test passes, lines 1306-1311 (at the time of this commit) # of sympy/solvers/ode.py should be removed. sol = 1 + exp(x/2) assert sol == collect( sol, exp(x/3)) def test_undetermined_coefficients_match(): assert _undetermined_coefficients_match(g(x), x) == {'test': False} assert _undetermined_coefficients_match(sin(2*x + sqrt(5)), x) == \ {'test': True, 'trialset': set([cos(2*x + sqrt(5)), sin(2*x + sqrt(5))])} assert _undetermined_coefficients_match(sin(x)*cos(x), x) == \ {'test': False} s = set([cos(x), x*cos(x), x**2*cos(x), x**2*sin(x), x*sin(x), sin(x)]) assert _undetermined_coefficients_match(sin(x)*(x**2 + x + 1), x) == \ {'test': True, 'trialset': s} assert _undetermined_coefficients_match( sin(x)*x**2 + sin(x)*x + sin(x), x) == {'test': True, 'trialset': s} assert _undetermined_coefficients_match( exp(2*x)*sin(x)*(x**2 + x + 1), x ) == { 'test': True, 'trialset': set([exp(2*x)*sin(x), x**2*exp(2*x)*sin(x), cos(x)*exp(2*x), x**2*cos(x)*exp(2*x), x*cos(x)*exp(2*x), x*exp(2*x)*sin(x)])} assert _undetermined_coefficients_match(1/sin(x), x) == {'test': False} assert _undetermined_coefficients_match(log(x), x) == {'test': False} assert _undetermined_coefficients_match(2**(x)*(x**2 + x + 1), x) == \ {'test': True, 'trialset': set([2**x, x*2**x, x**2*2**x])} assert _undetermined_coefficients_match(x**y, x) == {'test': False} assert _undetermined_coefficients_match(exp(x)*exp(2*x + 1), x) == \ {'test': True, 'trialset': set([exp(1 + 3*x)])} assert _undetermined_coefficients_match(sin(x)*(x**2 + x + 1), x) == \ {'test': True, 'trialset': set([x*cos(x), x*sin(x), x**2*cos(x), x**2*sin(x), cos(x), sin(x)])} assert _undetermined_coefficients_match(sin(x)*(x + sin(x)), x) == \ {'test': False} assert _undetermined_coefficients_match(sin(x)*(x + sin(2*x)), x) == \ {'test': False} assert _undetermined_coefficients_match(sin(x)*tan(x), x) == \ {'test': False} assert _undetermined_coefficients_match( x**2*sin(x)*exp(x) + x*sin(x) + x, x ) == { 'test': True, 'trialset': set([x**2*cos(x)*exp(x), x, cos(x), S(1), exp(x)*sin(x), sin(x), x*exp(x)*sin(x), x*cos(x), x*cos(x)*exp(x), x*sin(x), cos(x)*exp(x), x**2*exp(x)*sin(x)])} assert _undetermined_coefficients_match(4*x*sin(x - 2), x) == { 'trialset': set([x*cos(x - 2), x*sin(x - 2), cos(x - 2), sin(x - 2)]), 'test': True, } assert _undetermined_coefficients_match(2**x*x, x) == \ {'test': True, 'trialset': set([2**x, x*2**x])} assert _undetermined_coefficients_match(2**x*exp(2*x), x) == \ {'test': True, 'trialset': set([2**x*exp(2*x)])} assert _undetermined_coefficients_match(exp(-x)/x, x) == \ {'test': False} # Below are from Ordinary Differential Equations, # Tenenbaum and Pollard, pg. 231 assert _undetermined_coefficients_match(S(4), x) == \ {'test': True, 'trialset': set([S(1)])} assert _undetermined_coefficients_match(12*exp(x), x) == \ {'test': True, 'trialset': set([exp(x)])} assert _undetermined_coefficients_match(exp(I*x), x) == \ {'test': True, 'trialset': set([exp(I*x)])} assert _undetermined_coefficients_match(sin(x), x) == \ {'test': True, 'trialset': set([cos(x), sin(x)])} assert _undetermined_coefficients_match(cos(x), x) == \ {'test': True, 'trialset': set([cos(x), sin(x)])} assert _undetermined_coefficients_match(8 + 6*exp(x) + 2*sin(x), x) == \ {'test': True, 'trialset': set([S(1), cos(x), sin(x), exp(x)])} assert _undetermined_coefficients_match(x**2, x) == \ {'test': True, 'trialset': set([S(1), x, x**2])} assert _undetermined_coefficients_match(9*x*exp(x) + exp(-x), x) == \ {'test': True, 'trialset': set([x*exp(x), exp(x), exp(-x)])} assert _undetermined_coefficients_match(2*exp(2*x)*sin(x), x) == \ {'test': True, 'trialset': set([exp(2*x)*sin(x), cos(x)*exp(2*x)])} assert _undetermined_coefficients_match(x - sin(x), x) == \ {'test': True, 'trialset': set([S(1), x, cos(x), sin(x)])} assert _undetermined_coefficients_match(x**2 + 2*x, x) == \ {'test': True, 'trialset': set([S(1), x, x**2])} assert _undetermined_coefficients_match(4*x*sin(x), x) == \ {'test': True, 'trialset': set([x*cos(x), x*sin(x), cos(x), sin(x)])} assert _undetermined_coefficients_match(x*sin(2*x), x) == \ {'test': True, 'trialset': set([x*cos(2*x), x*sin(2*x), cos(2*x), sin(2*x)])} assert _undetermined_coefficients_match(x**2*exp(-x), x) == \ {'test': True, 'trialset': set([x*exp(-x), x**2*exp(-x), exp(-x)])} assert _undetermined_coefficients_match(2*exp(-x) - x**2*exp(-x), x) == \ {'test': True, 'trialset': set([x*exp(-x), x**2*exp(-x), exp(-x)])} assert _undetermined_coefficients_match(exp(-2*x) + x**2, x) == \ {'test': True, 'trialset': set([S(1), x, x**2, exp(-2*x)])} assert _undetermined_coefficients_match(x*exp(-x), x) == \ {'test': True, 'trialset': set([x*exp(-x), exp(-x)])} assert _undetermined_coefficients_match(x + exp(2*x), x) == \ {'test': True, 'trialset': set([S(1), x, exp(2*x)])} assert _undetermined_coefficients_match(sin(x) + exp(-x), x) == \ {'test': True, 'trialset': set([cos(x), sin(x), exp(-x)])} assert _undetermined_coefficients_match(exp(x), x) == \ {'test': True, 'trialset': set([exp(x)])} # converted from sin(x)**2 assert _undetermined_coefficients_match(S(1)/2 - cos(2*x)/2, x) == \ {'test': True, 'trialset': set([S(1), cos(2*x), sin(2*x)])} # converted from exp(2*x)*sin(x)**2 assert _undetermined_coefficients_match( exp(2*x)*(S(1)/2 + cos(2*x)/2), x ) == { 'test': True, 'trialset': set([exp(2*x)*sin(2*x), cos(2*x)*exp(2*x), exp(2*x)])} assert _undetermined_coefficients_match(2*x + sin(x) + cos(x), x) == \ {'test': True, 'trialset': set([S(1), x, cos(x), sin(x)])} # converted from sin(2*x)*sin(x) assert _undetermined_coefficients_match(cos(x)/2 - cos(3*x)/2, x) == \ {'test': True, 'trialset': set([cos(x), cos(3*x), sin(x), sin(3*x)])} assert _undetermined_coefficients_match(cos(x**2), x) == {'test': False} assert _undetermined_coefficients_match(2**(x**2), x) == {'test': False} @slow def test_nth_linear_constant_coeff_undetermined_coefficients(): hint = 'nth_linear_constant_coeff_undetermined_coefficients' g = exp(-x) f2 = f(x).diff(x, 2) c = 3*f(x).diff(x, 3) + 5*f2 + f(x).diff(x) - f(x) - x eq1 = c - x*g eq2 = c - g # 3-27 below are from Ordinary Differential Equations, # Tenenbaum and Pollard, pg. 231 eq3 = f2 + 3*f(x).diff(x) + 2*f(x) - 4 eq4 = f2 + 3*f(x).diff(x) + 2*f(x) - 12*exp(x) eq5 = f2 + 3*f(x).diff(x) + 2*f(x) - exp(I*x) eq6 = f2 + 3*f(x).diff(x) + 2*f(x) - sin(x) eq7 = f2 + 3*f(x).diff(x) + 2*f(x) - cos(x) eq8 = f2 + 3*f(x).diff(x) + 2*f(x) - (8 + 6*exp(x) + 2*sin(x)) eq9 = f2 + f(x).diff(x) + f(x) - x**2 eq10 = f2 - 2*f(x).diff(x) - 8*f(x) - 9*x*exp(x) - 10*exp(-x) eq11 = f2 - 3*f(x).diff(x) - 2*exp(2*x)*sin(x) eq12 = f(x).diff(x, 4) - 2*f2 + f(x) - x + sin(x) eq13 = f2 + f(x).diff(x) - x**2 - 2*x eq14 = f2 + f(x).diff(x) - x - sin(2*x) eq15 = f2 + f(x) - 4*x*sin(x) eq16 = f2 + 4*f(x) - x*sin(2*x) eq17 = f2 + 2*f(x).diff(x) + f(x) - x**2*exp(-x) eq18 = f(x).diff(x, 3) + 3*f2 + 3*f(x).diff(x) + f(x) - 2*exp(-x) + \ x**2*exp(-x) eq19 = f2 + 3*f(x).diff(x) + 2*f(x) - exp(-2*x) - x**2 eq20 = f2 - 3*f(x).diff(x) + 2*f(x) - x*exp(-x) eq21 = f2 + f(x).diff(x) - 6*f(x) - x - exp(2*x) eq22 = f2 + f(x) - sin(x) - exp(-x) eq23 = f(x).diff(x, 3) - 3*f2 + 3*f(x).diff(x) - f(x) - exp(x) # sin(x)**2 eq24 = f2 + f(x) - S(1)/2 - cos(2*x)/2 # exp(2*x)*sin(x)**2 eq25 = f(x).diff(x, 3) - f(x).diff(x) - exp(2*x)*(S(1)/2 - cos(2*x)/2) eq26 = (f(x).diff(x, 5) + 2*f(x).diff(x, 3) + f(x).diff(x) - 2*x - sin(x) - cos(x)) # sin(2*x)*sin(x), skip 3127 for now, match bug eq27 = f2 + f(x) - cos(x)/2 + cos(3*x)/2 eq28 = f(x).diff(x) - 1 sol1 = Eq(f(x), -1 - x + (C1 + C2*x - 3*x**2/32 - x**3/24)*exp(-x) + C3*exp(x/3)) sol2 = Eq(f(x), -1 - x + (C1 + C2*x - x**2/8)*exp(-x) + C3*exp(x/3)) sol3 = Eq(f(x), 2 + C1*exp(-x) + C2*exp(-2*x)) sol4 = Eq(f(x), 2*exp(x) + C1*exp(-x) + C2*exp(-2*x)) sol5 = Eq(f(x), C1*exp(-2*x) + C2*exp(-x) + exp(I*x)/10 - 3*I*exp(I*x)/10) sol6 = Eq(f(x), -3*cos(x)/10 + sin(x)/10 + C1*exp(-x) + C2*exp(-2*x)) sol7 = Eq(f(x), cos(x)/10 + 3*sin(x)/10 + C1*exp(-x) + C2*exp(-2*x)) sol8 = Eq(f(x), 4 - 3*cos(x)/5 + sin(x)/5 + exp(x) + C1*exp(-x) + C2*exp(-2*x)) sol9 = Eq(f(x), -2*x + x**2 + (C1*sin(x*sqrt(3)/2) + C2*cos(x*sqrt(3)/2))*exp(-x/2)) sol10 = Eq(f(x), -x*exp(x) - 2*exp(-x) + C1*exp(-2*x) + C2*exp(4*x)) sol11 = Eq(f(x), C1 + C2*exp(3*x) + (-3*sin(x) - cos(x))*exp(2*x)/5) sol12 = Eq(f(x), x - sin(x)/4 + (C1 + C2*x)*exp(-x) + (C3 + C4*x)*exp(x)) sol13 = Eq(f(x), C1 + x**3/3 + C2*exp(-x)) sol14 = Eq(f(x), C1 - x - sin(2*x)/5 - cos(2*x)/10 + x**2/2 + C2*exp(-x)) sol15 = Eq(f(x), (C1 + x)*sin(x) + (C2 - x**2)*cos(x)) sol16 = Eq(f(x), (C1 + x/16)*sin(2*x) + (C2 - x**2/8)*cos(2*x)) sol17 = Eq(f(x), (C1 + C2*x + x**4/12)*exp(-x)) sol18 = Eq(f(x), (C1 + C2*x + C3*x**2 - x**5/60 + x**3/3)*exp(-x)) sol19 = Eq(f(x), S(7)/4 - 3*x/2 + x**2/2 + C1*exp(-x) + (C2 - x)*exp(-2*x)) sol20 = Eq(f(x), C1*exp(x) + C2*exp(2*x) + (6*x + 5)*exp(-x)/36) sol21 = Eq(f(x), -S(1)/36 - x/6 + C1*exp(-3*x) + (C2 + x/5)*exp(2*x)) sol22 = Eq(f(x), C1*sin(x) + (C2 - x/2)*cos(x) + exp(-x)/2) sol23 = Eq(f(x), (C1 + C2*x + C3*x**2 + x**3/6)*exp(x)) sol24 = Eq(f(x), S(1)/2 - cos(2*x)/6 + C1*sin(x) + C2*cos(x)) sol25 = Eq(f(x), C1 + C2*exp(-x) + C3*exp(x) + (-21*sin(2*x) + 27*cos(2*x) + 130)*exp(2*x)/1560) sol26 = Eq(f(x), C1 + (C2 + C3*x - x**2/8)*sin(x) + (C4 + C5*x + x**2/8)*cos(x) + x**2) sol27 = Eq(f(x), cos(3*x)/16 + C1*cos(x) + (C2 + x/4)*sin(x)) sol28 = Eq(f(x), C1 + x) sol1s = constant_renumber(sol1) sol2s = constant_renumber(sol2) sol3s = constant_renumber(sol3) sol4s = constant_renumber(sol4) sol5s = constant_renumber(sol5) sol6s = constant_renumber(sol6) sol7s = constant_renumber(sol7) sol8s = constant_renumber(sol8) sol9s = constant_renumber(sol9) sol10s = constant_renumber(sol10) sol11s = constant_renumber(sol11) sol12s = constant_renumber(sol12) sol13s = constant_renumber(sol13) sol14s = constant_renumber(sol14) sol15s = constant_renumber(sol15) sol16s = constant_renumber(sol16) sol17s = constant_renumber(sol17) sol18s = constant_renumber(sol18) sol19s = constant_renumber(sol19) sol20s = constant_renumber(sol20) sol21s = constant_renumber(sol21) sol22s = constant_renumber(sol22) sol23s = constant_renumber(sol23) sol24s = constant_renumber(sol24) sol25s = constant_renumber(sol25) sol26s = constant_renumber(sol26) sol27s = constant_renumber(sol27) assert dsolve(eq1, hint=hint) in (sol1, sol1s) assert dsolve(eq2, hint=hint) in (sol2, sol2s) assert dsolve(eq3, hint=hint) in (sol3, sol3s) assert dsolve(eq4, hint=hint) in (sol4, sol4s) assert dsolve(eq5, hint=hint) in (sol5, sol5s) assert dsolve(eq6, hint=hint) in (sol6, sol6s) assert dsolve(eq7, hint=hint) in (sol7, sol7s) assert dsolve(eq8, hint=hint) in (sol8, sol8s) assert dsolve(eq9, hint=hint) in (sol9, sol9s) assert dsolve(eq10, hint=hint) in (sol10, sol10s) assert dsolve(eq11, hint=hint) in (sol11, sol11s) assert dsolve(eq12, hint=hint) in (sol12, sol12s) assert dsolve(eq13, hint=hint) in (sol13, sol13s) assert dsolve(eq14, hint=hint) in (sol14, sol14s) assert dsolve(eq15, hint=hint) in (sol15, sol15s) assert dsolve(eq16, hint=hint) in (sol16, sol16s) assert dsolve(eq17, hint=hint) in (sol17, sol17s) assert dsolve(eq18, hint=hint) in (sol18, sol18s) assert dsolve(eq19, hint=hint) in (sol19, sol19s) assert dsolve(eq20, hint=hint) in (sol20, sol20s) assert dsolve(eq21, hint=hint) in (sol21, sol21s) assert dsolve(eq22, hint=hint) in (sol22, sol22s) assert dsolve(eq23, hint=hint) in (sol23, sol23s) assert dsolve(eq24, hint=hint) in (sol24, sol24s) assert dsolve(eq25, hint=hint) in (sol25, sol25s) assert dsolve(eq26, hint=hint) in (sol26, sol26s) assert dsolve(eq27, hint=hint) in (sol27, sol27s) assert dsolve(eq28, hint=hint) == sol28 assert checkodesol(eq1, sol1, order=3, solve_for_func=False)[0] assert checkodesol(eq2, sol2, order=3, solve_for_func=False)[0] assert checkodesol(eq3, sol3, order=2, solve_for_func=False)[0] assert checkodesol(eq4, sol4, order=2, solve_for_func=False)[0] assert checkodesol(eq5, sol5, order=2, solve_for_func=False)[0] assert checkodesol(eq6, sol6, order=2, solve_for_func=False)[0] assert checkodesol(eq7, sol7, order=2, solve_for_func=False)[0] assert checkodesol(eq8, sol8, order=2, solve_for_func=False)[0] assert checkodesol(eq9, sol9, order=2, solve_for_func=False)[0] assert checkodesol(eq10, sol10, order=2, solve_for_func=False)[0] assert checkodesol(eq11, sol11, order=2, solve_for_func=False)[0] assert checkodesol(eq12, sol12, order=4, solve_for_func=False)[0] assert checkodesol(eq13, sol13, order=2, solve_for_func=False)[0] assert checkodesol(eq14, sol14, order=2, solve_for_func=False)[0] assert checkodesol(eq15, sol15, order=2, solve_for_func=False)[0] assert checkodesol(eq16, sol16, order=2, solve_for_func=False)[0] assert checkodesol(eq17, sol17, order=2, solve_for_func=False)[0] assert checkodesol(eq18, sol18, order=3, solve_for_func=False)[0] assert checkodesol(eq19, sol19, order=2, solve_for_func=False)[0] assert checkodesol(eq20, sol20, order=2, solve_for_func=False)[0] assert checkodesol(eq21, sol21, order=2, solve_for_func=False)[0] assert checkodesol(eq22, sol22, order=2, solve_for_func=False)[0] assert checkodesol(eq23, sol23, order=3, solve_for_func=False)[0] assert checkodesol(eq24, sol24, order=2, solve_for_func=False)[0] assert checkodesol(eq25, sol25, order=3, solve_for_func=False)[0] assert checkodesol(eq26, sol26, order=5, solve_for_func=False)[0] assert checkodesol(eq27, sol27, order=2, solve_for_func=False)[0] assert checkodesol(eq28, sol28, order=1, solve_for_func=False)[0] def test_issue_5787(): # This test case is to show the classification of imaginary constants under # nth_linear_constant_coeff_undetermined_coefficients eq = Eq(diff(f(x), x), I*f(x) + S(1)/2 - I) our_hint = 'nth_linear_constant_coeff_undetermined_coefficients' assert our_hint in classify_ode(eq) @XFAIL def test_nth_linear_constant_coeff_undetermined_coefficients_imaginary_exp(): # Equivalent to eq26 in # test_nth_linear_constant_coeff_undetermined_coefficients above. # This fails because the algorithm for undetermined coefficients # doesn't know to multiply exp(I*x) by sufficient x because it is linearly # dependent on sin(x) and cos(x). hint = 'nth_linear_constant_coeff_undetermined_coefficients' eq26a = f(x).diff(x, 5) + 2*f(x).diff(x, 3) + f(x).diff(x) - 2*x - exp(I*x) sol26 = Eq(f(x), C1 + (C2 + C3*x - x**2/8)*sin(x) + (C4 + C5*x + x**2/8)*cos(x) + x**2) assert dsolve(eq26a, hint=hint) == sol26 assert checkodesol(eq26a, sol26, order=5, solve_for_func=False)[0] @slow def test_nth_linear_constant_coeff_variation_of_parameters(): hint = 'nth_linear_constant_coeff_variation_of_parameters' g = exp(-x) f2 = f(x).diff(x, 2) c = 3*f(x).diff(x, 3) + 5*f2 + f(x).diff(x) - f(x) - x eq1 = c - x*g eq2 = c - g eq3 = f(x).diff(x) - 1 eq4 = f2 + 3*f(x).diff(x) + 2*f(x) - 4 eq5 = f2 + 3*f(x).diff(x) + 2*f(x) - 12*exp(x) eq6 = f2 - 2*f(x).diff(x) - 8*f(x) - 9*x*exp(x) - 10*exp(-x) eq7 = f2 + 2*f(x).diff(x) + f(x) - x**2*exp(-x) eq8 = f2 - 3*f(x).diff(x) + 2*f(x) - x*exp(-x) eq9 = f(x).diff(x, 3) - 3*f2 + 3*f(x).diff(x) - f(x) - exp(x) eq10 = f2 + 2*f(x).diff(x) + f(x) - exp(-x)/x eq11 = f2 + f(x) - 1/sin(x)*1/cos(x) eq12 = f(x).diff(x, 4) - 1/x sol1 = Eq(f(x), -1 - x + (C1 + C2*x - 3*x**2/32 - x**3/24)*exp(-x) + C3*exp(x/3)) sol2 = Eq(f(x), -1 - x + (C1 + C2*x - x**2/8)*exp(-x) + C3*exp(x/3)) sol3 = Eq(f(x), C1 + x) sol4 = Eq(f(x), 2 + C1*exp(-x) + C2*exp(-2*x)) sol5 = Eq(f(x), 2*exp(x) + C1*exp(-x) + C2*exp(-2*x)) sol6 = Eq(f(x), -x*exp(x) - 2*exp(-x) + C1*exp(-2*x) + C2*exp(4*x)) sol7 = Eq(f(x), (C1 + C2*x + x**4/12)*exp(-x)) sol8 = Eq(f(x), C1*exp(x) + C2*exp(2*x) + (6*x + 5)*exp(-x)/36) sol9 = Eq(f(x), (C1 + C2*x + C3*x**2 + x**3/6)*exp(x)) sol10 = Eq(f(x), (C1 + x*(C2 + log(x)))*exp(-x)) sol11 = Eq(f(x), cos(x)*(C2 - Integral(1/cos(x), x)) + sin(x)*(C1 + Integral(1/sin(x), x))) sol12 = Eq(f(x), C1 + C2*x + x**3*(C3 + log(x)/6) + C4*x**2) sol1s = constant_renumber(sol1) sol2s = constant_renumber(sol2) sol3s = constant_renumber(sol3) sol4s = constant_renumber(sol4) sol5s = constant_renumber(sol5) sol6s = constant_renumber(sol6) sol7s = constant_renumber(sol7) sol8s = constant_renumber(sol8) sol9s = constant_renumber(sol9) sol10s = constant_renumber(sol10) sol11s = constant_renumber(sol11) sol12s = constant_renumber(sol12) assert dsolve(eq1, hint=hint) in (sol1, sol1s) assert dsolve(eq2, hint=hint) in (sol2, sol2s) assert dsolve(eq3, hint=hint) in (sol3, sol3s) assert dsolve(eq4, hint=hint) in (sol4, sol4s) assert dsolve(eq5, hint=hint) in (sol5, sol5s) assert dsolve(eq6, hint=hint) in (sol6, sol6s) assert dsolve(eq7, hint=hint) in (sol7, sol7s) assert dsolve(eq8, hint=hint) in (sol8, sol8s) assert dsolve(eq9, hint=hint) in (sol9, sol9s) assert dsolve(eq10, hint=hint) in (sol10, sol10s) assert dsolve(eq11, hint=hint + '_Integral') in (sol11, sol11s) assert dsolve(eq12, hint=hint) in (sol12, sol12s) assert checkodesol(eq1, sol1, order=3, solve_for_func=False)[0] assert checkodesol(eq2, sol2, order=3, solve_for_func=False)[0] assert checkodesol(eq3, sol3, order=1, solve_for_func=False)[0] assert checkodesol(eq4, sol4, order=2, solve_for_func=False)[0] assert checkodesol(eq5, sol5, order=2, solve_for_func=False)[0] assert checkodesol(eq6, sol6, order=2, solve_for_func=False)[0] assert checkodesol(eq7, sol7, order=2, solve_for_func=False)[0] assert checkodesol(eq8, sol8, order=2, solve_for_func=False)[0] assert checkodesol(eq9, sol9, order=3, solve_for_func=False)[0] assert checkodesol(eq10, sol10, order=2, solve_for_func=False)[0] assert checkodesol(eq12, sol12, order=4, solve_for_func=False)[0] @slow def test_nth_linear_constant_coeff_variation_of_parameters_simplify_False(): # solve_variation_of_parameters shouldn't attempt to simplify the # Wronskian if simplify=False. If wronskian() ever gets good enough # to simplify the result itself, this test might fail. our_hint = 'nth_linear_constant_coeff_variation_of_parameters_Integral' eq = f(x).diff(x, 5) + 2*f(x).diff(x, 3) + f(x).diff(x) - 2*x - exp(I*x) sol_simp = dsolve(eq, f(x), hint=our_hint, simplify=True) sol_nsimp = dsolve(eq, f(x), hint=our_hint, simplify=False) assert sol_simp != sol_nsimp assert checkodesol(eq, sol_simp, order=5, solve_for_func=False)[0] assert checkodesol(eq, sol_nsimp, order=5, solve_for_func=False)[0] def test_Liouville_ODE(): hint = 'Liouville' # The first part here used to be test_ODE_1() from test_solvers.py eq1 = diff(f(x), x)/x + diff(f(x), x, x)/2 - diff(f(x), x)**2/2 eq1a = diff(x*exp(-f(x)), x, x) # compare to test_unexpanded_Liouville_ODE() below eq2 = (eq1*exp(-f(x))/exp(f(x))).expand() eq3 = diff(f(x), x, x) + 1/f(x)*(diff(f(x), x))**2 + 1/x*diff(f(x), x) eq4 = x*diff(f(x), x, x) + x/f(x)*diff(f(x), x)**2 + x*diff(f(x), x) eq5 = Eq((x*exp(f(x))).diff(x, x), 0) sol1 = Eq(f(x), log(x/(C1 + C2*x))) sol1a = Eq(C1 + C2/x - exp(-f(x)), 0) sol2 = sol1 sol3 = set( [Eq(f(x), -sqrt(C1 + C2*log(x))), Eq(f(x), sqrt(C1 + C2*log(x)))]) sol4 = set([Eq(f(x), sqrt(C1 + C2*exp(x))*exp(-x/2)), Eq(f(x), -sqrt(C1 + C2*exp(x))*exp(-x/2))]) sol5 = Eq(f(x), log(C1 + C2/x)) sol1s = constant_renumber(sol1) sol2s = constant_renumber(sol2) sol3s = constant_renumber(sol3) sol4s = constant_renumber(sol4) sol5s = constant_renumber(sol5) assert dsolve(eq1, hint=hint) in (sol1, sol1s) assert dsolve(eq1a, hint=hint) in (sol1, sol1s) assert dsolve(eq2, hint=hint) in (sol2, sol2s) assert set(dsolve(eq3, hint=hint)) in (sol3, sol3s) assert set(dsolve(eq4, hint=hint)) in (sol4, sol4s) assert dsolve(eq5, hint=hint) in (sol5, sol5s) assert checkodesol(eq1, sol1, order=2, solve_for_func=False)[0] assert checkodesol(eq1a, sol1a, order=2, solve_for_func=False)[0] assert checkodesol(eq2, sol2, order=2, solve_for_func=False)[0] assert checkodesol(eq3, sol3, order=2, solve_for_func=False) == {(True, 0)} assert checkodesol(eq4, sol4, order=2, solve_for_func=False) == {(True, 0)} assert checkodesol(eq5, sol5, order=2, solve_for_func=False)[0] not_Liouville1 = classify_ode(diff(f(x), x)/x + f(x)*diff(f(x), x, x)/2 - diff(f(x), x)**2/2, f(x)) not_Liouville2 = classify_ode(diff(f(x), x)/x + diff(f(x), x, x)/2 - x*diff(f(x), x)**2/2, f(x)) assert hint not in not_Liouville1 assert hint not in not_Liouville2 assert hint + '_Integral' not in not_Liouville1 assert hint + '_Integral' not in not_Liouville2 def test_unexpanded_Liouville_ODE(): # This is the same as eq1 from test_Liouville_ODE() above. eq1 = diff(f(x), x)/x + diff(f(x), x, x)/2 - diff(f(x), x)**2/2 eq2 = eq1*exp(-f(x))/exp(f(x)) sol2 = Eq(f(x), log(x/(C1 + C2*x))) sol2s = constant_renumber(sol2) assert dsolve(eq2) in (sol2, sol2s) assert checkodesol(eq2, sol2, order=2, solve_for_func=False)[0] def test_issue_4785(): from sympy.abc import A eq = x + A*(x + diff(f(x), x) + f(x)) + diff(f(x), x) + f(x) + 2 assert classify_ode(eq, f(x)) == ('1st_linear', 'almost_linear', '1st_power_series', 'lie_group', 'nth_linear_constant_coeff_undetermined_coefficients', 'nth_linear_constant_coeff_variation_of_parameters', '1st_linear_Integral', 'almost_linear_Integral', 'nth_linear_constant_coeff_variation_of_parameters_Integral') # issue 4864 eq = (x**2 + f(x)**2)*f(x).diff(x) - 2*x*f(x) assert classify_ode(eq, f(x)) == ('1st_exact', '1st_homogeneous_coeff_best', '1st_homogeneous_coeff_subs_indep_div_dep', '1st_homogeneous_coeff_subs_dep_div_indep', '1st_power_series', 'lie_group', '1st_exact_Integral', '1st_homogeneous_coeff_subs_indep_div_dep_Integral', '1st_homogeneous_coeff_subs_dep_div_indep_Integral') def test_issue_4825(): raises(ValueError, lambda: dsolve(f(x, y).diff(x) - y*f(x, y), f(x))) assert classify_ode(f(x, y).diff(x) - y*f(x, y), f(x), dict=True) == \ {'default': None, 'order': 0} # See also issue 3793, test Z13. raises(ValueError, lambda: dsolve(f(x).diff(x), f(y))) assert classify_ode(f(x).diff(x), f(y), dict=True) == \ {'default': None, 'order': 0} def test_constant_renumber_order_issue_5308(): from sympy.utilities.iterables import variations eq = f(x).diff(x) - y - x assert constant_renumber(C1*x + C2*y) == \ constant_renumber(C1*y + C2*x) == \ C1*x + C2*y e = C1*(C2 + x)*(C3 + y) for a, b, c in variations([C1, C2, C3], 3): assert constant_renumber(a*(b + x)*(c + y)) == e def test_issue_5770(): k = Symbol("k", real=True) t = Symbol('t') w = Function('w') sol = dsolve(w(t).diff(t, 6) - k**6*w(t), w(t)) assert len([s for s in sol.free_symbols if s.name.startswith('C')]) == 6 assert constantsimp((C1*cos(x) + C2*cos(x))*exp(x), set([C1, C2])) == \ C1*cos(x)*exp(x) assert constantsimp(C1*cos(x) + C2*cos(x) + C3*sin(x), set([C1, C2, C3])) == \ C1*cos(x) + C3*sin(x) assert constantsimp(exp(C1 + x), set([C1])) == C1*exp(x) assert constantsimp(x + C1 + y, set([C1, y])) == C1 + x assert constantsimp(x + C1 + Integral(x, (x, 1, 2)), set([C1])) == C1 + x def test_issue_5112_5430(): assert homogeneous_order(-log(x) + acosh(x), x) is None assert homogeneous_order(y - log(x), x, y) is None def test_nth_order_linear_euler_eq_homogeneous(): x, t, a, b, c = symbols('x t a b c') y = Function('y') our_hint = "nth_linear_euler_eq_homogeneous" eq = diff(f(t), t, 4)*t**4 - 13*diff(f(t), t, 2)*t**2 + 36*f(t) assert our_hint in classify_ode(eq) eq = a*y(t) + b*t*diff(y(t), t) + c*t**2*diff(y(t), t, 2) assert our_hint in classify_ode(eq) eq = Eq(-3*diff(f(x), x)*x + 2*x**2*diff(f(x), x, x), 0) sol = C1 + C2*x**Rational(5, 2) sols = constant_renumber(sol) assert our_hint in classify_ode(eq) assert dsolve(eq, f(x), hint=our_hint).rhs in (sol, sols) assert checkodesol(eq, sol, order=2, solve_for_func=False)[0] eq = Eq(3*f(x) - 5*diff(f(x), x)*x + 2*x**2*diff(f(x), x, x), 0) sol = C1*sqrt(x) + C2*x**3 sols = constant_renumber(sol) assert our_hint in classify_ode(eq) assert dsolve(eq, f(x), hint=our_hint).rhs in (sol, sols) assert checkodesol(eq, sol, order=2, solve_for_func=False)[0] eq = Eq(4*f(x) + 5*diff(f(x), x)*x + x**2*diff(f(x), x, x), 0) sol = (C1 + C2*log(x))/x**2 sols = constant_renumber(sol) assert our_hint in classify_ode(eq) assert dsolve(eq, f(x), hint=our_hint).rhs in (sol, sols) assert checkodesol(eq, sol, order=2, solve_for_func=False)[0] eq = Eq(6*f(x) - 6*diff(f(x), x)*x + 1*x**2*diff(f(x), x, x) + x**3*diff(f(x), x, x, x), 0) sol = dsolve(eq, f(x), hint=our_hint) sol = C1/x**2 + C2*x + C3*x**3 sols = constant_renumber(sol) assert our_hint in classify_ode(eq) assert dsolve(eq, f(x), hint=our_hint).rhs in (sol, sols) assert checkodesol(eq, sol, order=2, solve_for_func=False)[0] eq = Eq(-125*f(x) + 61*diff(f(x), x)*x - 12*x**2*diff(f(x), x, x) + x**3*diff(f(x), x, x, x), 0) sol = x**5*(C1 + C2*log(x) + C3*log(x)**2) sols = [sol, constant_renumber(sol)] sols += [sols[-1].expand()] assert our_hint in classify_ode(eq) assert dsolve(eq, f(x), hint=our_hint).rhs in sols assert checkodesol(eq, sol, order=2, solve_for_func=False)[0] eq = t**2*diff(y(t), t, 2) + t*diff(y(t), t) - 9*y(t) sol = C1*t**3 + C2*t**-3 sols = constant_renumber(sol) assert our_hint in classify_ode(eq) assert dsolve(eq, y(t), hint=our_hint).rhs in (sol, sols) assert checkodesol(eq, sol, order=2, solve_for_func=False)[0] eq = sin(x)*x**2*f(x).diff(x, 2) + sin(x)*x*f(x).diff(x) + sin(x)*f(x) sol = C1*sin(log(x)) + C2*cos(log(x)) sols = constant_renumber(sol) assert our_hint in classify_ode(eq) assert dsolve(eq, f(x), hint=our_hint).rhs in (sol, sols) assert checkodesol(eq, sol, order=2, solve_for_func=False)[0] def test_nth_order_linear_euler_eq_nonhomogeneous_undetermined_coefficients(): x, t = symbols('x t') a, b, c, d = symbols('a b c d', integer=True) our_hint = "nth_linear_euler_eq_nonhomogeneous_undetermined_coefficients" eq = x**4*diff(f(x), x, 4) - 13*x**2*diff(f(x), x, 2) + 36*f(x) + x assert our_hint in classify_ode(eq, f(x)) eq = a*x**2*diff(f(x), x, 2) + b*x*diff(f(x), x) + c*f(x) + d*log(x) assert our_hint in classify_ode(eq, f(x)) eq = Eq(x**2*diff(f(x), x, x) + x*diff(f(x), x), 1) sol = C1 + C2*log(x) + log(x)**2/2 sols = constant_renumber(sol) assert our_hint in classify_ode(eq, f(x)) assert dsolve(eq, f(x), hint=our_hint).rhs in (sol, sols) assert checkodesol(eq, sol, order=2, solve_for_func=False)[0] eq = Eq(x**2*diff(f(x), x, x) - 2*x*diff(f(x), x) + 2*f(x), x**3) sol = x*(C1 + C2*x + Rational(1, 2)*x**2) sols = constant_renumber(sol) assert our_hint in classify_ode(eq, f(x)) assert dsolve(eq, f(x), hint=our_hint).rhs in (sol, sols) assert checkodesol(eq, sol, order=2, solve_for_func=False)[0] eq = Eq(x**2*diff(f(x), x, x) - x*diff(f(x), x) - 3*f(x), log(x)/x) sol = C1/x + C2*x**3 - Rational(1, 16)*log(x)/x - Rational(1, 8)*log(x)**2/x sols = constant_renumber(sol) assert our_hint in classify_ode(eq, f(x)) assert dsolve(eq, f(x), hint=our_hint).rhs.expand() in (sol, sols) assert checkodesol(eq, sol, order=2, solve_for_func=False)[0] eq = Eq(x**2*diff(f(x), x, x) + 3*x*diff(f(x), x) - 8*f(x), log(x)**3 - log(x)) sol = C1/x**4 + C2*x**2 - Rational(1,8)*log(x)**3 - Rational(3,32)*log(x)**2 - Rational(1,64)*log(x) - Rational(7, 256) sols = constant_renumber(sol) assert our_hint in classify_ode(eq) assert dsolve(eq, f(x), hint=our_hint).rhs.expand() in (sol, sols) assert checkodesol(eq, sol, order=2, solve_for_func=False)[0] eq = Eq(x**3*diff(f(x), x, x, x) - 3*x**2*diff(f(x), x, x) + 6*x*diff(f(x), x) - 6*f(x), log(x)) sol = C1*x + C2*x**2 + C3*x**3 - Rational(1, 6)*log(x) - Rational(11, 36) sols = constant_renumber(sol) assert our_hint in classify_ode(eq) assert dsolve(eq, f(x), hint=our_hint).rhs.expand() in (sol, sols) assert checkodesol(eq, sol, order=2, solve_for_func=False)[0] def test_nth_order_linear_euler_eq_nonhomogeneous_variation_of_parameters(): x, t = symbols('x, t') a, b, c, d = symbols('a, b, c, d', integer=True) our_hint = "nth_linear_euler_eq_nonhomogeneous_variation_of_parameters" eq = Eq(x**2*diff(f(x),x,2) - 8*x*diff(f(x),x) + 12*f(x), x**2) assert our_hint in classify_ode(eq, f(x)) eq = Eq(a*x**3*diff(f(x),x,3) + b*x**2*diff(f(x),x,2) + c*x*diff(f(x),x) + d*f(x), x*log(x)) assert our_hint in classify_ode(eq, f(x)) eq = Eq(x**2*Derivative(f(x), x, x) - 2*x*Derivative(f(x), x) + 2*f(x), x**4) sol = C1*x + C2*x**2 + x**4/6 sols = constant_renumber(sol) assert our_hint in classify_ode(eq) assert dsolve(eq, f(x), hint=our_hint).rhs.expand() in (sol, sols) assert checkodesol(eq, sol, order=2, solve_for_func=False)[0] eq = Eq(3*x**2*diff(f(x), x, x) + 6*x*diff(f(x), x) - 6*f(x), x**3*exp(x)) sol = C1/x**2 + C2*x + x*exp(x)/3 - 4*exp(x)/3 + 8*exp(x)/(3*x) - 8*exp(x)/(3*x**2) sols = constant_renumber(sol) assert our_hint in classify_ode(eq) assert dsolve(eq, f(x), hint=our_hint).rhs.expand() in (sol, sols) assert checkodesol(eq, sol, order=2, solve_for_func=False)[0] eq = Eq(x**2*Derivative(f(x), x, x) - 2*x*Derivative(f(x), x) + 2*f(x), x**4*exp(x)) sol = C1*x + C2*x**2 + x**2*exp(x) - 2*x*exp(x) sols = constant_renumber(sol) assert our_hint in classify_ode(eq) assert dsolve(eq, f(x), hint=our_hint).rhs.expand() in (sol, sols) assert checkodesol(eq, sol, order=2, solve_for_func=False)[0] eq = x**2*Derivative(f(x), x, x) - 2*x*Derivative(f(x), x) + 2*f(x) - log(x) sol = C1*x + C2*x**2 + log(x)/2 + S(3)/4 sols = constant_renumber(sol) assert our_hint in classify_ode(eq) assert dsolve(eq, f(x), hint=our_hint).rhs in (sol, sols) assert checkodesol(eq, sol, order=2, solve_for_func=False)[0] eq = -exp(x) + (x*Derivative(f(x), (x, 2)) + Derivative(f(x), x))/x sol = Eq(f(x), C1 + C2*log(x) + exp(x) - Ei(x)) assert our_hint in classify_ode(eq) assert dsolve(eq, f(x), hint=our_hint) == sol assert checkodesol(eq, sol, order=2, solve_for_func=False)[0] def test_issue_5095(): f = Function('f') raises(ValueError, lambda: dsolve(f(x).diff(x)**2, f(x), 'separable')) raises(ValueError, lambda: dsolve(f(x).diff(x)**2, f(x), 'fdsjf')) def test_almost_linear(): from sympy import Ei A = Symbol('A', positive=True) our_hint = 'almost_linear' f = Function('f') d = f(x).diff(x) eq = x**2*f(x)**2*d + f(x)**3 + 1 sol = dsolve(eq, f(x), hint = 'almost_linear') assert sol[0].rhs == (C1*exp(3/x) - 1)**(S(1)/3) assert checkodesol(eq, sol, order=1, solve_for_func=False)[0] eq = x*f(x)*d + 2*x*f(x)**2 + 1 sol = dsolve(eq, f(x), hint = 'almost_linear') assert sol[0].rhs == -sqrt(C1 - 2*Ei(4*x))*exp(-2*x) assert checkodesol(eq, sol, order=1, solve_for_func=False)[0] eq = x*d + x*f(x) + 1 sol = dsolve(eq, f(x), hint = 'almost_linear') assert sol.rhs == (C1 - Ei(x))*exp(-x) assert checkodesol(eq, sol, order=1, solve_for_func=False)[0] assert our_hint in classify_ode(eq, f(x)) eq = x*exp(f(x))*d + exp(f(x)) + 3*x sol = dsolve(eq, f(x), hint = 'almost_linear') assert sol.rhs == log(C1/x - 3*x/2) assert checkodesol(eq, sol, order=1, solve_for_func=False)[0] eq = x + A*(x + diff(f(x), x) + f(x)) + diff(f(x), x) + f(x) + 2 sol = dsolve(eq, f(x), hint = 'almost_linear') assert sol.rhs == (C1 + Piecewise( (x, Eq(A + 1, 0)), ((-A*x + A - x - 1)*exp(x)/(A + 1), True)))*exp(-x) assert checkodesol(eq, sol, order=1, solve_for_func=False)[0] def test_exact_enhancement(): f = Function('f')(x) df = Derivative(f, x) eq = f/x**2 + ((f*x - 1)/x)*df sol = [Eq(f, (i*sqrt(C1*x**2 + 1) + 1)/x) for i in (-1, 1)] assert set(dsolve(eq, f)) == set(sol) assert checkodesol(eq, sol, order=1, solve_for_func=False) == [(True, 0), (True, 0)] eq = (x*f - 1) + df*(x**2 - x*f) sol = [Eq(f, x - sqrt(C1 + x**2 - 2*log(x))), Eq(f, x + sqrt(C1 + x**2 - 2*log(x)))] assert set(dsolve(eq, f)) == set(sol) assert checkodesol(eq, sol, order=1, solve_for_func=False) == [(True, 0), (True, 0)] eq = (x + 2)*sin(f) + df*x*cos(f) sol = [Eq(f, -asin(C1*exp(-x)/x**2) + pi), Eq(f, asin(C1*exp(-x)/x**2))] assert set(dsolve(eq, f)) == set(sol) assert checkodesol(eq, sol, order=1, solve_for_func=False) == [(True, 0), (True, 0)] @slow def test_separable_reduced(): f = Function('f') x = Symbol('x') df = f(x).diff(x) eq = (x / f(x))*df + tan(x**2*f(x) / (x**2*f(x) - 1)) assert classify_ode(eq) == ('separable_reduced', 'lie_group', 'separable_reduced_Integral') eq = x* df + f(x)* (1 / (x**2*f(x) - 1)) assert classify_ode(eq) == ('separable_reduced', 'lie_group', 'separable_reduced_Integral') sol = dsolve(eq, hint = 'separable_reduced', simplify=False) assert sol.lhs == log(x**2*f(x))/3 + log(x**2*f(x) - S(3)/2)/6 assert sol.rhs == C1 + log(x) assert checkodesol(eq, sol, order=1, solve_for_func=False)[0] eq = f(x).diff(x) + (f(x) / (x**4*f(x) - x)) assert classify_ode(eq) == ('separable_reduced', 'lie_group', 'separable_reduced_Integral') sol = dsolve(eq, hint = 'separable_reduced') # FIXME: This one hangs #assert checkodesol(eq, sol, order=1, solve_for_func=False) == [(True, 0)] * 4 assert len(sol) == 4 eq = x*df + f(x)*(x**2*f(x)) sol = dsolve(eq, hint = 'separable_reduced', simplify=False) assert sol == Eq(log(x**2*f(x))/2 - log(x**2*f(x) - 2)/2, C1 + log(x)) assert checkodesol(eq, sol, order=1, solve_for_func=False)[0] def test_homogeneous_function(): f = Function('f') eq1 = tan(x + f(x)) eq2 = sin((3*x)/(4*f(x))) eq3 = cos(3*x/4*f(x)) eq4 = log((3*x + 4*f(x))/(5*f(x) + 7*x)) eq5 = exp((2*x**2)/(3*f(x)**2)) eq6 = log((3*x + 4*f(x))/(5*f(x) + 7*x) + exp((2*x**2)/(3*f(x)**2))) eq7 = sin((3*x)/(5*f(x) + x**2)) assert homogeneous_order(eq1, x, f(x)) == None assert homogeneous_order(eq2, x, f(x)) == 0 assert homogeneous_order(eq3, x, f(x)) == None assert homogeneous_order(eq4, x, f(x)) == 0 assert homogeneous_order(eq5, x, f(x)) == 0 assert homogeneous_order(eq6, x, f(x)) == 0 assert homogeneous_order(eq7, x, f(x)) == None def test_linear_coeff_match(): from sympy.solvers.ode import _linear_coeff_match n, d = z*(2*x + 3*f(x) + 5), z*(7*x + 9*f(x) + 11) rat = n/d eq1 = sin(rat) + cos(rat.expand()) eq2 = rat eq3 = log(sin(rat)) ans = (4, -S(13)/3) assert _linear_coeff_match(eq1, f(x)) == ans assert _linear_coeff_match(eq2, f(x)) == ans assert _linear_coeff_match(eq3, f(x)) == ans # no c eq4 = (3*x)/f(x) # not x and f(x) eq5 = (3*x + 2)/x # denom will be zero eq6 = (3*x + 2*f(x) + 1)/(3*x + 2*f(x) + 5) # not rational coefficient eq7 = (3*x + 2*f(x) + sqrt(2))/(3*x + 2*f(x) + 5) assert _linear_coeff_match(eq4, f(x)) is None assert _linear_coeff_match(eq5, f(x)) is None assert _linear_coeff_match(eq6, f(x)) is None assert _linear_coeff_match(eq7, f(x)) is None def test_linear_coefficients(): f = Function('f') sol = Eq(f(x), C1/(x**2 + 6*x + 9) - S(3)/2) eq = f(x).diff(x) + (3 + 2*f(x))/(x + 3) assert dsolve(eq, hint='linear_coefficients') == sol assert checkodesol(eq, sol, order=1, solve_for_func=False)[0] def test_constantsimp_take_problem(): c = exp(C1) + 2 assert len(Poly(constantsimp(exp(C1) + c + c*x, [C1])).gens) == 2 def test_issue_6879(): f = Function('f') eq = Eq(Derivative(f(x), x, 2) - 2*Derivative(f(x), x) + f(x), sin(x)) sol = (C1 + C2*x)*exp(x) + cos(x)/2 assert dsolve(eq).rhs == sol assert checkodesol(eq, sol, order=1, solve_for_func=False)[0] def test_issue_6989(): f = Function('f') k = Symbol('k') eq = f(x).diff(x) - x*exp(-k*x) sol = Eq(f(x), C1 + Piecewise( ((-k*x - 1)*exp(-k*x)/k**2, Ne(k**2, 0)), (x**2/2, True) )) assert dsolve(eq, f(x)) == sol assert checkodesol(eq, sol, order=1, solve_for_func=False)[0] eq = -f(x).diff(x) + x*exp(-k*x) sol = Eq(f(x), C1 + Piecewise( ((-k*x - 1)*exp(-k*x)/k**2, Ne(k**2, 0)), (+x**2/2, True) )) assert dsolve(eq, f(x)) == sol assert checkodesol(eq, sol, order=1, solve_for_func=False)[0] def test_heuristic1(): y, a, b, c, a4, a3, a2, a1, a0 = symbols("y a b c a4 a3 a2 a1 a0") y = Symbol('y') f = Function('f') xi = Function('xi') eta = Function('eta') df = f(x).diff(x) eq = Eq(df, x**2*f(x)) eq1 = f(x).diff(x) + a*f(x) - c*exp(b*x) eq2 = f(x).diff(x) + 2*x*f(x) - x*exp(-x**2) eq3 = (1 + 2*x)*df + 2 - 4*exp(-f(x)) eq4 = f(x).diff(x) - (a4*x**4 + a3*x**3 + a2*x**2 + a1*x + a0)**(S(-1)/2) eq5 = x**2*df - f(x) + x**2*exp(x - (1/x)) eqlist = [eq, eq1, eq2, eq3, eq4, eq5] i = infinitesimals(eq, hint='abaco1_simple') assert i == [{eta(x, f(x)): exp(x**3/3), xi(x, f(x)): 0}, {eta(x, f(x)): f(x), xi(x, f(x)): 0}, {eta(x, f(x)): 0, xi(x, f(x)): x**(-2)}] i1 = infinitesimals(eq1, hint='abaco1_simple') assert i1 == [{eta(x, f(x)): exp(-a*x), xi(x, f(x)): 0}] i2 = infinitesimals(eq2, hint='abaco1_simple') assert i2 == [{eta(x, f(x)): exp(-x**2), xi(x, f(x)): 0}] i3 = infinitesimals(eq3, hint='abaco1_simple') assert i3 == [{eta(x, f(x)): 0, xi(x, f(x)): 2*x + 1}, {eta(x, f(x)): 0, xi(x, f(x)): 1/(exp(f(x)) - 2)}] i4 = infinitesimals(eq4, hint='abaco1_simple') assert i4 == [{eta(x, f(x)): 1, xi(x, f(x)): 0}, {eta(x, f(x)): 0, xi(x, f(x)): sqrt(a0 + a1*x + a2*x**2 + a3*x**3 + a4*x**4)}] i5 = infinitesimals(eq5, hint='abaco1_simple') assert i5 == [{xi(x, f(x)): 0, eta(x, f(x)): exp(-1/x)}] ilist = [i, i1, i2, i3, i4, i5] for eq, i in (zip(eqlist, ilist)): check = checkinfsol(eq, i) assert check[0] def test_issue_6247(): eq = x**2*f(x)**2 + x*Derivative(f(x), x) sol = Eq(f(x), 2*C1/(C1*x**2 - 1)) assert dsolve(eq, hint = 'separable_reduced') == sol assert checkodesol(eq, sol, order=1)[0] eq = f(x).diff(x, x) + 4*f(x) sol = Eq(f(x), C1*sin(2*x) + C2*cos(2*x)) assert dsolve(eq) == sol assert checkodesol(eq, sol, order=1)[0] def test_heuristic2(): y = Symbol('y') xi = Function('xi') eta = Function('eta') df = f(x).diff(x) # This ODE can be solved by the Lie Group method, when there are # better assumptions eq = df - (f(x)/x)*(x*log(x**2/f(x)) + 2) i = infinitesimals(eq, hint='abaco1_product') assert i == [{eta(x, f(x)): f(x)*exp(-x), xi(x, f(x)): 0}] assert checkinfsol(eq, i)[0] @slow def test_heuristic3(): y = Symbol('y') xi = Function('xi') eta = Function('eta') a, b = symbols("a b") df = f(x).diff(x) eq = x**2*df + x*f(x) + f(x)**2 + x**2 i = infinitesimals(eq, hint='bivariate') assert i == [{eta(x, f(x)): f(x), xi(x, f(x)): x}] assert checkinfsol(eq, i)[0] eq = x**2*(-f(x)**2 + df)- a*x**2*f(x) + 2 - a*x i = infinitesimals(eq, hint='bivariate') assert checkinfsol(eq, i)[0] def test_heuristic_4(): y, a = symbols("y a") xi = Function('xi') eta = Function('eta') eq = x*(f(x).diff(x)) + 1 - f(x)**2 i = infinitesimals(eq, hint='chi') assert checkinfsol(eq, i)[0] def test_heuristic_function_sum(): xi = Function('xi') eta = Function('eta') eq = f(x).diff(x) - (3*(1 + x**2/f(x)**2)*atan(f(x)/x) + (1 - 2*f(x))/x + (1 - 3*f(x))*(x/f(x)**2)) i = infinitesimals(eq, hint='function_sum') assert i == [{eta(x, f(x)): f(x)**(-2) + x**(-2), xi(x, f(x)): 0}] assert checkinfsol(eq, i)[0] def test_heuristic_abaco2_similar(): xi = Function('xi') eta = Function('eta') F = Function('F') a, b = symbols("a b") eq = f(x).diff(x) - F(a*x + b*f(x)) i = infinitesimals(eq, hint='abaco2_similar') assert i == [{eta(x, f(x)): -a/b, xi(x, f(x)): 1}] assert checkinfsol(eq, i)[0] eq = f(x).diff(x) - (f(x)**2 / (sin(f(x) - x) - x**2 + 2*x*f(x))) i = infinitesimals(eq, hint='abaco2_similar') assert i == [{eta(x, f(x)): f(x)**2, xi(x, f(x)): f(x)**2}] assert checkinfsol(eq, i)[0] def test_heuristic_abaco2_unique_unknown(): xi = Function('xi') eta = Function('eta') F = Function('F') a, b = symbols("a b") x = Symbol("x", positive=True) eq = f(x).diff(x) - x**(a - 1)*(f(x)**(1 - b))*F(x**a/a + f(x)**b/b) i = infinitesimals(eq, hint='abaco2_unique_unknown') assert i == [{eta(x, f(x)): -f(x)*f(x)**(-b), xi(x, f(x)): x*x**(-a)}] assert checkinfsol(eq, i)[0] eq = f(x).diff(x) + tan(F(x**2 + f(x)**2) + atan(x/f(x))) i = infinitesimals(eq, hint='abaco2_unique_unknown') assert i == [{eta(x, f(x)): x, xi(x, f(x)): -f(x)}] assert checkinfsol(eq, i)[0] eq = (x*f(x).diff(x) + f(x) + 2*x)**2 -4*x*f(x) -4*x**2 -4*a i = infinitesimals(eq, hint='abaco2_unique_unknown') assert checkinfsol(eq, i)[0] def test_heuristic_linear(): xi = Function('xi') eta = Function('eta') F = Function('F') a, b, m, n = symbols("a b m n") eq = x**(n*(m + 1) - m)*(f(x).diff(x)) - a*f(x)**n -b*x**(n*(m + 1)) i = infinitesimals(eq, hint='linear') assert checkinfsol(eq, i)[0] @XFAIL def test_kamke(): a, b, alpha, c = symbols("a b alpha c") eq = x**2*(a*f(x)**2+(f(x).diff(x))) + b*x**alpha + c i = infinitesimals(eq, hint='sum_function') assert checkinfsol(eq, i)[0] def test_series(): # FIXME: Maybe there should be a way to check series solutions # checkodesol doesn't work with them. C1 = Symbol("C1") eq = f(x).diff(x) - f(x) assert dsolve(eq, hint='1st_power_series') == Eq(f(x), C1 + C1*x + C1*x**2/2 + C1*x**3/6 + C1*x**4/24 + C1*x**5/120 + O(x**6)) eq = f(x).diff(x) - x*f(x) assert dsolve(eq, hint='1st_power_series') == Eq(f(x), C1*x**4/8 + C1*x**2/2 + C1 + O(x**6)) eq = f(x).diff(x) - sin(x*f(x)) sol = Eq(f(x), (x - 2)**2*(1+ sin(4))*cos(4) + (x - 2)*sin(4) + 2 + O(x**3)) assert dsolve(eq, hint='1st_power_series', ics={f(2): 2}, n=3) == sol @slow def test_lie_group(): C1 = Symbol("C1") x = Symbol("x") # assuming x is real generates an error! a, b, c = symbols("a b c") eq = f(x).diff(x)**2 sol = dsolve(eq, f(x), hint='lie_group') assert checkodesol(eq, sol)[0] eq = Eq(f(x).diff(x), x**2*f(x)) sol = dsolve(eq, f(x), hint='lie_group') assert sol == Eq(f(x), C1*exp(x**3)**(S(1)/3)) assert checkodesol(eq, sol)[0] eq = f(x).diff(x) + a*f(x) - c*exp(b*x) sol = dsolve(eq, f(x), hint='lie_group') assert checkodesol(eq, sol)[0] eq = f(x).diff(x) + 2*x*f(x) - x*exp(-x**2) sol = dsolve(eq, f(x), hint='lie_group') actual_sol = Eq(f(x), (C1 + x**2/2)*exp(-x**2)) errstr = str(eq)+' : '+str(sol)+' == '+str(actual_sol) assert sol == actual_sol, errstr assert checkodesol(eq, sol)[0] eq = (1 + 2*x)*(f(x).diff(x)) + 2 - 4*exp(-f(x)) sol = dsolve(eq, f(x), hint='lie_group') assert sol == Eq(f(x), log(C1/(2*x + 1) + 2)) assert checkodesol(eq, sol)[0] eq = x**2*(f(x).diff(x)) - f(x) + x**2*exp(x - (1/x)) sol = dsolve(eq, f(x), hint='lie_group') assert checkodesol(eq, sol)[0] eq = x**2*f(x)**2 + x*Derivative(f(x), x) sol = dsolve(eq, f(x), hint='lie_group') assert sol == Eq(f(x), 2/(C1 + x**2)) assert checkodesol(eq, sol)[0] @XFAIL def test_lie_group_issue15219(): eqn = exp(f(x).diff(x)-f(x)) assert 'lie_group' not in classify_ode(eqn, f(x)) def test_user_infinitesimals(): x = Symbol("x") # assuming x is real generates an error eq = x*(f(x).diff(x)) + 1 - f(x)**2 sol = Eq(f(x), (C1 + x**2)/(C1 - x**2)) infinitesimals = {'xi':sqrt(f(x) - 1)/sqrt(f(x) + 1), 'eta':0} assert dsolve(eq, hint='lie_group', **infinitesimals) == sol assert checkodesol(eq, sol) == (True, 0) raises(ValueError, lambda: dsolve(eq, hint='lie_group', xi=0, eta=f(x))) def test_issue_7081(): eq = x*(f(x).diff(x)) + 1 - f(x)**2 s = Eq(f(x), -1/(-C1 + x**2)*(C1 + x**2)) assert dsolve(eq) == s assert checkodesol(eq, s) == (True, 0) @slow def test_2nd_power_series_ordinary(): # FIXME: Maybe there should be a way to check series solutions # checkodesol doesn't work with them. C1, C2 = symbols("C1 C2") eq = f(x).diff(x, 2) - x*f(x) assert classify_ode(eq) == ('2nd_power_series_ordinary',) assert dsolve(eq) == Eq(f(x), C2*(x**3/6 + 1) + C1*x*(x**3/12 + 1) + O(x**6)) assert dsolve(eq, x0=-2) == Eq(f(x), C2*((x + 2)**4/6 + (x + 2)**3/6 - (x + 2)**2 + 1) + C1*(x + (x + 2)**4/12 - (x + 2)**3/3 + S(2)) + O(x**6)) assert dsolve(eq, n=2) == Eq(f(x), C2*x + C1 + O(x**2)) eq = (1 + x**2)*(f(x).diff(x, 2)) + 2*x*(f(x).diff(x)) -2*f(x) assert classify_ode(eq) == ('2nd_power_series_ordinary',) assert dsolve(eq) == Eq(f(x), C2*(-x**4/3 + x**2 + 1) + C1*x + O(x**6)) eq = f(x).diff(x, 2) + x*(f(x).diff(x)) + f(x) assert classify_ode(eq) == ('2nd_power_series_ordinary',) assert dsolve(eq) == Eq(f(x), C2*( x**4/8 - x**2/2 + 1) + C1*x*(-x**2/3 + 1) + O(x**6)) eq = f(x).diff(x, 2) + f(x).diff(x) - x*f(x) assert classify_ode(eq) == ('2nd_power_series_ordinary',) assert dsolve(eq) == Eq(f(x), C2*( -x**4/24 + x**3/6 + 1) + C1*x*(x**3/24 + x**2/6 - x/2 + 1) + O(x**6)) eq = f(x).diff(x, 2) + x*f(x) assert classify_ode(eq) == ('2nd_power_series_ordinary',) assert dsolve(eq, n=7) == Eq(f(x), C2*( x**6/180 - x**3/6 + 1) + C1*x*(-x**3/12 + 1) + O(x**7)) def test_2nd_power_series_regular(): # FIXME: Maybe there should be a way to check series solutions # checkodesol doesn't work with them. C1, C2 = symbols("C1 C2") eq = x**2*(f(x).diff(x, 2)) - 3*x*(f(x).diff(x)) + (4*x + 4)*f(x) assert dsolve(eq) == Eq(f(x), C1*x**2*(-16*x**3/9 + 4*x**2 - 4*x + 1) + O(x**6)) eq = 4*x**2*(f(x).diff(x, 2)) -8*x**2*(f(x).diff(x)) + (4*x**2 + 1)*f(x) assert dsolve(eq) == Eq(f(x), C1*sqrt(x)*( x**4/24 + x**3/6 + x**2/2 + x + 1) + O(x**6)) eq = x**2*(f(x).diff(x, 2)) - x**2*(f(x).diff(x)) + ( x**2 - 2)*f(x) assert dsolve(eq) == Eq(f(x), C1*(-x**6/720 - 3*x**5/80 - x**4/8 + x**2/2 + x/2 + 1)/x + C2*x**2*(-x**3/60 + x**2/20 + x/2 + 1) + O(x**6)) eq = x**2*(f(x).diff(x, 2)) + x*(f(x).diff(x)) + (x**2 - S(1)/4)*f(x) assert dsolve(eq) == Eq(f(x), C1*(x**4/24 - x**2/2 + 1)/sqrt(x) + C2*sqrt(x)*(x**4/120 - x**2/6 + 1) + O(x**6)) eq = x*(f(x).diff(x, 2)) - f(x).diff(x) + 4*x**3*f(x) assert dsolve(eq) == Eq(f(x), C2*(-x**4/2 + 1) + C1*x**2 + O(x**6)) def test_issue_7093(): x = Symbol("x") # assuming x is real leads to an error sol = [Eq(f(x), C1 - 2*x*sqrt(x**3)/5), Eq(f(x), C1 + 2*x*sqrt(x**3)/5)] eq = Derivative(f(x), x)**2 - x**3 assert set(dsolve(eq)) == set(sol) assert checkodesol(eq, sol) == [(True, 0)] * 2 def test_dsolve_linsystem_symbol(): eps = Symbol('epsilon', positive=True) eq1 = (Eq(diff(f(x), x), -eps*g(x)), Eq(diff(g(x), x), eps*f(x))) sol1 = [Eq(f(x), -C1*eps*cos(eps*x) - C2*eps*sin(eps*x)), Eq(g(x), -C1*eps*sin(eps*x) + C2*eps*cos(eps*x))] assert checksysodesol(eq1, sol1) == (True, [0, 0]) def test_C1_function_9239(): t = Symbol('t') C1 = Function('C1') C2 = Function('C2') C3 = Symbol('C3') C4 = Symbol('C4') eq = (Eq(diff(C1(t), t), 9*C2(t)), Eq(diff(C2(t), t), 12*C1(t))) sol = [Eq(C1(t), 9*C3*exp(6*sqrt(3)*t) + 9*C4*exp(-6*sqrt(3)*t)), Eq(C2(t), 6*sqrt(3)*C3*exp(6*sqrt(3)*t) - 6*sqrt(3)*C4*exp(-6*sqrt(3)*t))] assert checksysodesol(eq, sol) == (True, [0, 0]) def test_issue_15056(): t = Symbol('t') C3 = Symbol('C3') assert get_numbered_constants(Symbol('C1') * Function('C2')(t)) == C3 def test_issue_10379(): t,y = symbols('t,y') eq = f(t).diff(t)-(1-51.05*y*f(t)) sol = Eq(f(t), (0.019588638589618*exp(y*(C1 - 51.05*t)) + 0.019588638589618)/y) dsolve_sol = dsolve(eq, rational=False) assert str(dsolve_sol) == str(sol) assert checkodesol(eq, dsolve_sol)[0] def test_issue_10867(): x = Symbol('x') eq = Eq(g(x).diff(x).diff(x), (x-2)**2 + (x-3)**3) sol = Eq(g(x), C1 + C2*x + x**5/20 - 2*x**4/3 + 23*x**3/6 - 23*x**2/2) assert dsolve(eq, g(x)) == sol assert checkodesol(eq, sol, order=2, solve_for_func=False) == (True, 0) def test_issue_11290(): eq = cos(f(x)) - (x*sin(f(x)) - f(x)**2)*f(x).diff(x) sol_1 = dsolve(eq, f(x), simplify=False, hint='1st_exact_Integral') sol_0 = dsolve(eq, f(x), simplify=False, hint='1st_exact') assert sol_1.dummy_eq(Eq(Subs( Integral(u**2 - x*sin(u) - Integral(-sin(u), x), u) + Integral(cos(u), x), u, f(x)), C1)) assert sol_1.doit() == sol_0 assert checkodesol(eq, sol_0, order=1, solve_for_func=False) assert checkodesol(eq, sol_1, order=1, solve_for_func=False) def test_issue_4838(): # Issue #15999 eq = f(x).diff(x) - C1*f(x) sol = Eq(f(x), C2*exp(C1*x)) assert dsolve(eq, f(x)) == sol assert checkodesol(eq, sol, order=1, solve_for_func=False) == (True, 0) # Issue #13691 eq = f(x).diff(x) - C1*g(x).diff(x) sol = Eq(f(x), C2 + C1*g(x)) assert dsolve(eq, f(x)) == sol assert checkodesol(eq, sol, f(x), order=1, solve_for_func=False) == (True, 0) # Issue #4838 eq = f(x).diff(x) - 3*C1 - 3*x**2 sol = Eq(f(x), C2 + 3*C1*x + x**3) assert dsolve(eq, f(x)) == sol assert checkodesol(eq, sol, order=1, solve_for_func=False) == (True, 0) @slow def test_issue_14395(): eq = Derivative(f(x), x, x) + 9*f(x) - sec(x) sol = Eq(f(x), (C1 - x/3 + sin(2*x)/3)*sin(3*x) + (C2 + log(cos(x)) - 2*log(cos(x)**2)/3 + 2*cos(x)**2/3)*cos(3*x)) assert dsolve(eq, f(x)) == sol # FIXME: assert checkodesol(eq, sol, order=2, solve_for_func=False) == (True, 0) def test_sysode_linear_neq_order1(): from sympy.abc import t Z0 = Function('Z0') Z1 = Function('Z1') Z2 = Function('Z2') Z3 = Function('Z3') k01, k10, k20, k21, k23, k30 = symbols('k01 k10 k20 k21 k23 k30') eq = (Eq(Derivative(Z0(t), t), -k01*Z0(t) + k10*Z1(t) + k20*Z2(t) + k30*Z3(t)), Eq(Derivative(Z1(t), t), k01*Z0(t) - k10*Z1(t) + k21*Z2(t)), Eq(Derivative(Z2(t), t), -(k20 + k21 + k23)*Z2(t)), Eq(Derivative(Z3(t), t), k23*Z2(t) - k30*Z3(t))) sols_eq = [Eq(Z0(t), C1*k10/k01 + C2*(-k10 + k30)*exp(-k30*t)/(k01 + k10 - k30) - C3*exp(t*(- k01 - k10)) + C4*(k10*k20 + k10*k21 - k10*k30 - k20**2 - k20*k21 - k20*k23 + k20*k30 + k23*k30)*exp(t*(-k20 - k21 - k23))/(k23*(k01 + k10 - k20 - k21 - k23))), Eq(Z1(t), C1 - C2*k01*exp(-k30*t)/(k01 + k10 - k30) + C3*exp(t*(-k01 - k10)) + C4*(k01*k20 + k01*k21 - k01*k30 - k20*k21 - k21**2 - k21*k23 + k21*k30)*exp(t*(-k20 - k21 - k23))/(k23*(k01 + k10 - k20 - k21 - k23))), Eq(Z2(t), C4*(-k20 - k21 - k23 + k30)*exp(t*(-k20 - k21 - k23))/k23), Eq(Z3(t), C2*exp(-k30*t) + C4*exp(t*(-k20 - k21 - k23)))] assert dsolve(eq, simplify=False) == sols_eq assert checksysodesol(eq, sols_eq) == (True, [0, 0, 0, 0]) def test_nth_order_reducible(): from sympy.solvers.ode import _nth_order_reducible_match eqn = Eq(x*Derivative(f(x), x)**2 + Derivative(f(x), x, 2), 0) sol = Eq(f(x), C1 - sqrt(-1/C2)*log(-C2*sqrt(-1/C2) + x) + sqrt(-1/C2)*log(C2*sqrt(-1/C2) + x)) assert checkodesol(eqn, sol, order=2, solve_for_func=False) == (True, 0) assert sol == dsolve(eqn, f(x), hint='nth_order_reducible') assert sol == dsolve(eqn, f(x)) F = lambda eq: _nth_order_reducible_match(eq, f(x)) D = Derivative assert F(D(y*f(x), x, y) + D(f(x), x)) is None assert F(D(y*f(y), y, y) + D(f(y), y)) is None assert F(f(x)*D(f(x), x) + D(f(x), x, 2)) is None assert F(D(x*f(y), y, 2) + D(u*y*f(x), x, 3)) is None # no simplification by design assert F(D(f(y), y, 2) + D(f(y), y, 3) + D(f(x), x, 4)) is None assert F(D(f(x), x, 2) + D(f(x), x, 3)) == dict(n=2) eqn = -exp(x) + (x*Derivative(f(x), (x, 2)) + Derivative(f(x), x))/x sol = Eq(f(x), C1 + C2*log(x) + exp(x) - Ei(x)) assert checkodesol(eqn, sol, order=2, solve_for_func=False) == (True, 0) assert sol == dsolve(eqn, f(x)) assert sol == dsolve(eqn, f(x), hint='nth_order_reducible') eqn = Eq(sqrt(2) * f(x).diff(x,x,x) + f(x).diff(x), 0) sol = Eq(f(x), C1 + C2*sin(2**(S(3)/4)*x/2) + C3*cos(2**(S(3)/4)*x/2)) assert checkodesol(eqn, sol, order=2, solve_for_func=False) == (True, 0) assert sol == dsolve(eqn, f(x)) assert sol == dsolve(eqn, f(x), hint='nth_order_reducible') eqn = f(x).diff(x, 2) + 2*f(x).diff(x) sol = Eq(f(x), C1 + C2*exp(-2*x)) sols = constant_renumber(sol) assert checkodesol(eqn, sol, order=2, solve_for_func=False) == (True, 0) assert dsolve(eqn, f(x)) in (sol, sols) assert dsolve(eqn, f(x), hint='nth_order_reducible') in (sol, sols) eqn = f(x).diff(x, 3) + f(x).diff(x, 2) - 6*f(x).diff(x) sol = Eq(f(x), C1 + C2*exp(-3*x) + C3*exp(2*x)) sols = constant_renumber(sol) assert checkodesol(eqn, sol, order=2, solve_for_func=False) == (True, 0) assert dsolve(eqn, f(x)) in (sol, sols) assert dsolve(eqn, f(x), hint='nth_order_reducible') in (sol, sols) eqn = f(x).diff(x, 4) - f(x).diff(x, 3) - 4*f(x).diff(x, 2) + \ 4*f(x).diff(x) sol = Eq(f(x), C1 + C2*exp(x) + C3*exp(-2*x) + C4*exp(2*x)) sols = constant_renumber(sol) assert checkodesol(eqn, sol, order=2, solve_for_func=False) == (True, 0) assert dsolve(eqn, f(x)) in (sol, sols) assert dsolve(eqn, f(x), hint='nth_order_reducible') in (sol, sols) eqn = f(x).diff(x, 4) + 3*f(x).diff(x, 3) sol = Eq(f(x), C1 + C2*x + C3*x**2 + C4*exp(-3*x)) sols = constant_renumber(sol) assert checkodesol(eqn, sol, order=2, solve_for_func=False) == (True, 0) assert dsolve(eqn, f(x)) in (sol, sols) assert dsolve(eqn, f(x), hint='nth_order_reducible') in (sol, sols) eqn = f(x).diff(x, 4) - 2*f(x).diff(x, 2) sol = Eq(f(x), C1 + C2*x + C3*exp(x*sqrt(2)) + C4*exp(-x*sqrt(2))) sols = constant_renumber(sol) assert checkodesol(eqn, sol, order=2, solve_for_func=False) == (True, 0) assert dsolve(eqn, f(x)) in (sol, sols) assert dsolve(eqn, f(x), hint='nth_order_reducible') in (sol, sols) eqn = f(x).diff(x, 4) + 4*f(x).diff(x, 2) sol = Eq(f(x), C1 + C2*sin(2*x) + C3*cos(2*x) + C4*x) sols = constant_renumber(sol) assert checkodesol(eqn, sol, order=2, solve_for_func=False) == (True, 0) assert dsolve(eqn, f(x)) in (sol, sols) assert dsolve(eqn, f(x), hint='nth_order_reducible') in (sol, sols) eqn = f(x).diff(x, 5) + 2*f(x).diff(x, 3) + f(x).diff(x) # These are equivalent: sol1 = Eq(f(x), C1 + (C2 + C3*x)*sin(x) + (C4 + C5*x)*cos(x)) sol2 = Eq(f(x), C1 + C2*(x*sin(x) + cos(x)) + C3*(-x*cos(x) + sin(x)) + C4*sin(x) + C5*cos(x)) sol1s = constant_renumber(sol1) sol2s = constant_renumber(sol2) assert checkodesol(eqn, sol1, order=2, solve_for_func=False) == (True, 0) assert checkodesol(eqn, sol2, order=2, solve_for_func=False) == (True, 0) assert dsolve(eqn, f(x)) in (sol1, sol1s) assert dsolve(eqn, f(x), hint='nth_order_reducible') in (sol2, sol2s) # In this case the reduced ODE has two distinct solutions eqn = f(x).diff(x, 2) - f(x).diff(x)**3 sol = [Eq(f(x), C2 - sqrt(2)*I*(C1 + x)*sqrt(1/(C1 + x))), Eq(f(x), C2 + sqrt(2)*I*(C1 + x)*sqrt(1/(C1 + x)))] sols = constant_renumber(sol) assert checkodesol(eqn, sol, order=2, solve_for_func=False) == [(True, 0), (True, 0)] assert dsolve(eqn, f(x)) in (sol, sols) assert dsolve(eqn, f(x), hint='nth_order_reducible') in (sol, sols) def test_nth_algebraic(): eqn = Eq(Derivative(f(x), x), Derivative(g(x), x)) sol = Eq(f(x), C1 + g(x)) assert checkodesol(eqn, sol, order=1, solve_for_func=False)[0] assert sol == dsolve(eqn, f(x), hint='nth_algebraic') assert sol == dsolve(eqn, f(x)) eqn = (diff(f(x)) - x)*(diff(f(x)) + x) sol = [Eq(f(x), C1 - x**2/2), Eq(f(x), C1 + x**2/2)] assert checkodesol(eqn, sol, order=1, solve_for_func=False)[0] assert sol == dsolve(eqn, f(x), hint='nth_algebraic') assert sol == dsolve(eqn, f(x)) eqn = (1 - sin(f(x))) * f(x).diff(x) sol = Eq(f(x), C1) assert checkodesol(eqn, sol, order=1, solve_for_func=False)[0] assert sol == dsolve(eqn, f(x), hint='nth_algebraic') assert sol == dsolve(eqn, f(x)) M, m, r, t = symbols('M m r t') phi = Function('phi') eqn = Eq(-M * phi(t).diff(t), Rational(3, 2) * m * r**2 * phi(t).diff(t) * phi(t).diff(t,t)) solns = [Eq(phi(t), C1), Eq(phi(t), C1 + C2*t - M*t**2/(3*m*r**2))] assert checkodesol(eqn, solns[0], order=2, solve_for_func=False)[0] assert checkodesol(eqn, solns[1], order=2, solve_for_func=False)[0] assert set(solns) == set(dsolve(eqn, phi(t), hint='nth_algebraic')) assert set(solns) == set(dsolve(eqn, phi(t))) eqn = f(x) * f(x).diff(x) * f(x).diff(x, x) sol = Eq(f(x), C1 + C2*x) assert checkodesol(eqn, sol, order=1, solve_for_func=False)[0] assert sol == dsolve(eqn, f(x), hint='nth_algebraic') assert sol == dsolve(eqn, f(x)) eqn = f(x) * f(x).diff(x) * f(x).diff(x, x) * (f(x) - 1) sol = Eq(f(x), C1 + C2*x) assert checkodesol(eqn, sol, order=1, solve_for_func=False)[0] assert sol == dsolve(eqn, f(x), hint='nth_algebraic') assert sol == dsolve(eqn, f(x)) eqn = f(x) * f(x).diff(x) * f(x).diff(x, x) * (f(x) - 1) * (f(x).diff(x) - x) solns = [Eq(f(x), C1 + x**2/2), Eq(f(x), C1 + C2*x)] assert checkodesol(eqn, solns[0], order=2, solve_for_func=False)[0] assert checkodesol(eqn, solns[1], order=2, solve_for_func=False)[0] assert set(solns) == set(dsolve(eqn, f(x), hint='nth_algebraic')) assert set(solns) == set(dsolve(eqn, f(x))) def test_nth_algebraic_issue15999(): eqn = f(x).diff(x) - C1 sol = Eq(f(x), C1*x + C2) # Correct solution assert checkodesol(eqn, sol, order=1, solve_for_func=False) == (True, 0) assert dsolve(eqn, f(x), hint='nth_algebraic') == sol assert dsolve(eqn, f(x)) == sol def test_nth_algebraic_redundant_solutions(): # This one has a redundant solution that should be removed eqn = f(x)*f(x).diff(x) soln = Eq(f(x), C1) assert checkodesol(eqn, soln, order=1, solve_for_func=False)[0] assert soln == dsolve(eqn, f(x), hint='nth_algebraic') assert soln == dsolve(eqn, f(x)) # This has two integral solutions and no algebraic solutions eqn = (diff(f(x)) - x)*(diff(f(x)) + x) sol = [Eq(f(x), C1 - x**2/2), Eq(f(x), C1 + x**2/2)] assert all(c[0] for c in checkodesol(eqn, sol, order=1, solve_for_func=False)) assert set(sol) == set(dsolve(eqn, f(x), hint='nth_algebraic')) assert set(sol) == set(dsolve(eqn, f(x))) # This one doesn't work with dsolve at the time of writing but the # redundancy checking code should not remove the algebraic solution. from sympy.solvers.ode import _nth_algebraic_remove_redundant_solutions eqn = f(x) + f(x)*f(x).diff(x) solns = [Eq(f(x), 0), Eq(f(x), C1 - x)] solns_final = _nth_algebraic_remove_redundant_solutions(eqn, solns, 1, x) assert all(c[0] for c in checkodesol(eqn, solns, order=1, solve_for_func=False)) assert set(solns) == set(solns_final) solns = [Eq(f(x), exp(x)), Eq(f(x), C1*exp(C2*x))] solns_final = _nth_algebraic_remove_redundant_solutions(eqn, solns, 2, x) assert solns_final == [Eq(f(x), C1*exp(C2*x))] # This one needs a substitution f' = g. eqn = -exp(x) + (x*Derivative(f(x), (x, 2)) + Derivative(f(x), x))/x sol = Eq(f(x), C1 + C2*log(x) + exp(x) - Ei(x)) assert checkodesol(eqn, sol, order=2, solve_for_func=False)[0] assert sol == dsolve(eqn, f(x)) # # These tests can be combined with the above test if they get fixed # so that dsolve actually works in all these cases. # # Fails due to division by f(x) eliminating the solution before nth_algebraic # is called. @XFAIL def test_nth_algebraic_find_multiple1(): eqn = f(x) + f(x)*f(x).diff(x) solns = [Eq(f(x), 0), Eq(f(x), C1 - x)] assert all(c[0] for c in checkodesol(eqn, solns, order=1, solve_for_func=False)) assert set(solns) == set(dsolve(eqn, f(x))) # prep = True breaks this def test_nth_algebraic_noprep1(): eqn = Derivative(x*f(x), x, x, x) sol = Eq(f(x), (C1 + C2*x + C3*x**2) / x) assert checkodesol(eqn, sol, order=3, solve_for_func=False)[0] assert sol == dsolve(eqn, f(x), prep=False, hint='nth_algebraic') @XFAIL def test_nth_algebraic_prep1(): eqn = Derivative(x*f(x), x, x, x) sol = Eq(f(x), (C1 + C2*x + C3*x**2) / x) assert checkodesol(eqn, sol, order=3, solve_for_func=False)[0] assert sol == dsolve(eqn, f(x), prep=True, hint='nth_algebraic') assert sol == dsolve(eqn, f(x)) # prep = True breaks this def test_nth_algebraic_noprep2(): eqn = Eq(Derivative(x*Derivative(f(x), x), x)/x, exp(x)) sol = Eq(f(x), C1 + C2*log(x) + exp(x) - Ei(x)) assert checkodesol(eqn, sol, order=2, solve_for_func=False)[0] assert sol == dsolve(eqn, f(x), prep=False, hint='nth_algebraic') @XFAIL def test_nth_algebraic_prep2(): eqn = Eq(Derivative(x*Derivative(f(x), x), x)/x, exp(x)) sol = Eq(f(x), C1 + C2*log(x) + exp(x) - Ei(x)) assert checkodesol(eqn, sol, order=2, solve_for_func=False)[0] assert sol == dsolve(eqn, f(x), prep=True, hint='nth_algebraic') assert sol == dsolve(eqn, f(x)) # This needs a combination of solutions from nth_algebraic and some other # method from dsolve @XFAIL def test_nth_algebraic_find_multiple2(): eqn = f(x)**2 + f(x)*f(x).diff(x) solns = [Eq(f(x), 0), Eq(f(x), C1*exp(-x))] assert all(c[0] for c in checkodesol(eqn, solns, order=1, solve_for_func=False)) assert set(solns) == dsolve(eqn, f(x)) # Needs to be a way to know how to combine derivatives in the expression @XFAIL def test_factoring_ode(): eqn = Derivative(x*f(x), x, x, x) + Derivative(f(x), x, x, x) soln = Eq(f(x), (C1*x**2/2 + C2*x + C3 - x)/(1 + x)) assert checkodesol(eqn, soln, order=2, solve_for_func=False)[0] assert soln == dsolve(eqn, f(x)) def test_issue_15913(): eq = -C1/x - 2*x*f(x) - f(x) + Derivative(f(x), x) sol = C2*exp(x**2 + x) + exp(x**2 + x)*Integral(C1*exp(-x**2 - x)/x, x) assert checkodesol(eq, sol) == (True, 0) sol = C1 + C2*exp(-x*y) eq = Derivative(y*f(x), x) + f(x).diff(x, 2) assert checkodesol(eq, sol, f(x)) == (True, 0) def test_issue_16146(): raises(ValueError, lambda: dsolve([f(x).diff(x), g(x).diff(x)], [f(x), g(x), h(x)])) raises(ValueError, lambda: dsolve([f(x).diff(x), g(x).diff(x)], [f(x)]))
a60e83217d1ef6b348daf6545b35bc29e0b3f4b663e650acea8fa7f7f48007ea
from sympy import Symbol, Function, Derivative as D, Eq, cos, sin from sympy.utilities.pytest import raises from sympy.calculus.euler import euler_equations as euler def test_euler_interface(): x = Function('x') y = Symbol('y') t = Symbol('t') raises(TypeError, lambda: euler()) raises(TypeError, lambda: euler(D(x(t), t)*y(t), [x(t), y])) raises(ValueError, lambda: euler(D(x(t), t)*x(y), [x(t), x(y)])) raises(TypeError, lambda: euler(D(x(t), t)**2, x(0))) assert euler(D(x(t), t)**2/2, {x(t)}) == [Eq(-D(x(t), t, t), 0)] assert euler(D(x(t), t)**2/2, x(t), {t}) == [Eq(-D(x(t), t, t), 0)] def test_euler_pendulum(): x = Function('x') t = Symbol('t') L = D(x(t), t)**2/2 + cos(x(t)) assert euler(L, x(t), t) == [Eq(-sin(x(t)) - D(x(t), t, t), 0)] def test_euler_henonheiles(): x = Function('x') y = Function('y') t = Symbol('t') L = sum(D(z(t), t)**2/2 - z(t)**2/2 for z in [x, y]) L += -x(t)**2*y(t) + y(t)**3/3 assert euler(L, [x(t), y(t)], t) == [Eq(-2*x(t)*y(t) - x(t) - D(x(t), t, t), 0), Eq(-x(t)**2 + y(t)**2 - y(t) - D(y(t), t, t), 0)] def test_euler_sineg(): psi = Function('psi') t = Symbol('t') x = Symbol('x') L = D(psi(t, x), t)**2/2 - D(psi(t, x), x)**2/2 + cos(psi(t, x)) assert euler(L, psi(t, x), [t, x]) == [Eq(-sin(psi(t, x)) - D(psi(t, x), t, t) + D(psi(t, x), x, x), 0)] def test_euler_high_order(): # an example from hep-th/0309038 m = Symbol('m') k = Symbol('k') x = Function('x') y = Function('y') t = Symbol('t') L = (m*D(x(t), t)**2/2 + m*D(y(t), t)**2/2 - k*D(x(t), t)*D(y(t), t, t) + k*D(y(t), t)*D(x(t), t, t)) assert euler(L, [x(t), y(t)]) == [Eq(2*k*D(y(t), t, t, t) - m*D(x(t), t, t), 0), Eq(-2*k*D(x(t), t, t, t) - m*D(y(t), t, t), 0)] w = Symbol('w') L = D(x(t, w), t, w)**2/2 assert euler(L) == [Eq(D(x(t, w), t, t, w, w), 0)]
5415e6f445c0a15b3366150e8f5dc19aa3580e911168646320ef629488e93403
from __future__ import (absolute_import, division, print_function) import os import shutil import subprocess import sys import tempfile import warnings from distutils.errors import CompileError from distutils.sysconfig import get_config_var from .util import ( get_abspath, make_dirs, copy, Glob, ArbitraryDepthGlob, glob_at_depth, import_module_from_file, pyx_is_cplus, sha256_of_string, sha256_of_file ) from .runners import ( CCompilerRunner, CppCompilerRunner, FortranCompilerRunner ) sharedext = get_config_var('EXT_SUFFIX' if sys.version_info >= (3, 3) else 'SO') if os.name == 'posix': objext = '.o' elif os.name == 'nt': objext = '.obj' else: warnings.warn("Unknown os.name: {}".format(os.name)) objext = '.o' def compile_sources(files, Runner=None, destdir=None, cwd=None, keep_dir_struct=False, per_file_kwargs=None, **kwargs): """ Compile source code files to object files. Parameters ========== files : iterable of str Paths to source files, if ``cwd`` is given, the paths are taken as relative. Runner: CompilerRunner subclass (optional) Could be e.g. ``FortranCompilerRunner``. Will be inferred from filename extensions if missing. destdir: str Output directory, if cwd is given, the path is taken as relative. cwd: str Working directory. Specify to have compiler run in other directory. also used as root of relative paths. keep_dir_struct: bool Reproduce directory structure in `destdir`. default: ``False`` per_file_kwargs: dict Dict mapping instances in ``files`` to keyword arguments. \\*\\*kwargs: dict Default keyword arguments to pass to ``Runner``. """ _per_file_kwargs = {} if per_file_kwargs is not None: for k, v in per_file_kwargs.items(): if isinstance(k, Glob): for path in glob.glob(k.pathname): _per_file_kwargs[path] = v elif isinstance(k, ArbitraryDepthGlob): for path in glob_at_depth(k.filename, cwd): _per_file_kwargs[path] = v else: _per_file_kwargs[k] = v # Set up destination directory destdir = destdir or '.' if not os.path.isdir(destdir): if os.path.exists(destdir): raise IOError("{} is not a directory".format(destdir)) else: make_dirs(destdir) if cwd is None: cwd = '.' for f in files: copy(f, destdir, only_update=True, dest_is_dir=True) # Compile files and return list of paths to the objects dstpaths = [] for f in files: if keep_dir_struct: name, ext = os.path.splitext(f) else: name, ext = os.path.splitext(os.path.basename(f)) file_kwargs = kwargs.copy() file_kwargs.update(_per_file_kwargs.get(f, {})) dstpaths.append(src2obj(f, Runner, cwd=cwd, **file_kwargs)) return dstpaths def get_mixed_fort_c_linker(vendor=None, cplus=False, cwd=None): vendor = vendor or os.environ.get('SYMPY_COMPILER_VENDOR', 'gnu') if vendor.lower() == 'intel': if cplus: return (FortranCompilerRunner, {'flags': ['-nofor_main', '-cxxlib']}, vendor) else: return (FortranCompilerRunner, {'flags': ['-nofor_main']}, vendor) elif vendor.lower() == 'gnu' or 'llvm': if cplus: return (CppCompilerRunner, {'lib_options': ['fortran']}, vendor) else: return (FortranCompilerRunner, {}, vendor) else: raise ValueError("No vendor found.") def link(obj_files, out_file=None, shared=False, Runner=None, cwd=None, cplus=False, fort=False, **kwargs): """ Link object files. Parameters ========== obj_files: iterable of str Paths to object files. out_file: str (optional) Path to executable/shared library, if ``None`` it will be deduced from the last item in obj_files. shared: bool Generate a shared library? Runner: CompilerRunner subclass (optional) If not given the ``cplus`` and ``fort`` flags will be inspected (fallback is the C compiler). cwd: str Path to the root of relative paths and working directory for compiler. cplus: bool C++ objects? default: ``False``. fort: bool Fortran objects? default: ``False``. \\*\\*kwargs: dict Keyword arguments passed to ``Runner``. Returns ======= The absolute path to the generated shared object / executable. """ if out_file is None: out_file, ext = os.path.splitext(os.path.basename(obj_files[-1])) if shared: out_file += sharedext if not Runner: if fort: Runner, extra_kwargs, vendor = \ get_mixed_fort_c_linker( vendor=kwargs.get('vendor', None), cplus=cplus, cwd=cwd, ) for k, v in extra_kwargs.items(): if k in kwargs: kwargs[k].expand(v) else: kwargs[k] = v else: if cplus: Runner = CppCompilerRunner else: Runner = CCompilerRunner flags = kwargs.pop('flags', []) if shared: if '-shared' not in flags: flags.append('-shared') run_linker = kwargs.pop('run_linker', True) if not run_linker: raise ValueError("run_linker was set to False (nonsensical).") out_file = get_abspath(out_file, cwd=cwd) runner = Runner(obj_files, out_file, flags, cwd=cwd, **kwargs) runner.run() return out_file def link_py_so(obj_files, so_file=None, cwd=None, libraries=None, cplus=False, fort=False, **kwargs): """ Link python extension module (shared object) for importing Parameters ========== obj_files: iterable of str Paths to object files to be linked. so_file: str Name (path) of shared object file to create. If not specified it will have the basname of the last object file in `obj_files` but with the extension '.so' (Unix). cwd: path string Root of relative paths and working directory of linker. libraries: iterable of strings Libraries to link against, e.g. ['m']. cplus: bool Any C++ objects? default: ``False``. fort: bool Any Fortran objects? default: ``False``. kwargs**: dict Keyword arguments passed to ``link(...)``. Returns ======= Absolute path to the generate shared object. """ libraries = libraries or [] include_dirs = kwargs.pop('include_dirs', []) library_dirs = kwargs.pop('library_dirs', []) # from distutils/command/build_ext.py: if sys.platform == "win32": warnings.warn("Windows not yet supported.") elif sys.platform == 'darwin': # Don't use the default code below pass elif sys.platform[:3] == 'aix': # Don't use the default code below pass else: from distutils import sysconfig if sysconfig.get_config_var('Py_ENABLE_SHARED'): ABIFLAGS = sysconfig.get_config_var('ABIFLAGS') pythonlib = 'python{}.{}{}'.format( sys.hexversion >> 24, (sys.hexversion >> 16) & 0xff, ABIFLAGS or '') libraries += [pythonlib] else: pass flags = kwargs.pop('flags', []) needed_flags = ('-pthread',) for flag in needed_flags: if flag not in flags: flags.append(flag) return link(obj_files, shared=True, flags=flags, cwd=cwd, cplus=cplus, fort=fort, include_dirs=include_dirs, libraries=libraries, library_dirs=library_dirs, **kwargs) def simple_cythonize(src, destdir=None, cwd=None, **cy_kwargs): """ Generates a C file from a Cython source file. Parameters ========== src: str Path to Cython source. destdir: str (optional) Path to output directory (default: '.'). cwd: path string (optional) Root of relative paths (default: '.'). **cy_kwargs: Second argument passed to cy_compile. Generates a .cpp file if ``cplus=True`` in ``cy_kwargs``, else a .c file. """ from Cython.Compiler.Main import ( default_options, CompilationOptions ) from Cython.Compiler.Main import compile as cy_compile assert src.lower().endswith('.pyx') or src.lower().endswith('.py') cwd = cwd or '.' destdir = destdir or '.' ext = '.cpp' if cy_kwargs.get('cplus', False) else '.c' c_name = os.path.splitext(os.path.basename(src))[0] + ext dstfile = os.path.join(destdir, c_name) if cwd: ori_dir = os.getcwd() else: ori_dir = '.' os.chdir(cwd) try: cy_options = CompilationOptions(default_options) cy_options.__dict__.update(cy_kwargs) cy_result = cy_compile([src], cy_options) if cy_result.num_errors > 0: raise ValueError("Cython compilation failed.") if os.path.abspath(os.path.dirname(src)) != os.path.abspath(destdir): if os.path.exists(dstfile): os.unlink(dstfile) shutil.move(os.path.join(os.path.dirname(src), c_name), destdir) finally: os.chdir(ori_dir) return dstfile extension_mapping = { '.c': (CCompilerRunner, None), '.cpp': (CppCompilerRunner, None), '.cxx': (CppCompilerRunner, None), '.f': (FortranCompilerRunner, None), '.for': (FortranCompilerRunner, None), '.ftn': (FortranCompilerRunner, None), '.f90': (FortranCompilerRunner, None), # ifort only knows about .f90 '.f95': (FortranCompilerRunner, 'f95'), '.f03': (FortranCompilerRunner, 'f2003'), '.f08': (FortranCompilerRunner, 'f2008'), } def src2obj(srcpath, Runner=None, objpath=None, cwd=None, inc_py=False, **kwargs): """ Compiles a source code file to an object file. Files ending with '.pyx' assumed to be cython files and are dispatched to pyx2obj. Parameters ========== srcpath: str Path to source file. Runner: CompilerRunner subclass (optional) If ``None``: deduced from extension of srcpath. objpath : str (optional) Path to generated object. If ``None``: deduced from ``srcpath``. cwd: str (optional) Working directory and root of relative paths. If ``None``: current dir. inc_py: bool Add Python include path to kwarg "include_dirs". Default: False \\*\\*kwargs: dict keyword arguments passed to Runner or pyx2obj """ name, ext = os.path.splitext(os.path.basename(srcpath)) if objpath is None: if os.path.isabs(srcpath): objpath = '.' else: objpath = os.path.dirname(srcpath) objpath = objpath or '.' # avoid objpath == '' if os.path.isdir(objpath): objpath = os.path.join(objpath, name+objext) include_dirs = kwargs.pop('include_dirs', []) if inc_py: from distutils.sysconfig import get_python_inc py_inc_dir = get_python_inc() if py_inc_dir not in include_dirs: include_dirs.append(py_inc_dir) if ext.lower() == '.pyx': return pyx2obj(srcpath, objpath=objpath, include_dirs=include_dirs, cwd=cwd, **kwargs) if Runner is None: Runner, std = extension_mapping[ext.lower()] if 'std' not in kwargs: kwargs['std'] = std flags = kwargs.pop('flags', []) needed_flags = ('-fPIC',) for flag in needed_flags: if flag not in flags: flags.append(flag) # src2obj implies not running the linker... run_linker = kwargs.pop('run_linker', False) if run_linker: raise CompileError("src2obj called with run_linker=True") runner = Runner([srcpath], objpath, include_dirs=include_dirs, run_linker=run_linker, cwd=cwd, flags=flags, **kwargs) runner.run() return objpath def pyx2obj(pyxpath, objpath=None, destdir=None, cwd=None, include_dirs=None, cy_kwargs=None, cplus=None, **kwargs): """ Convenience function If cwd is specified, pyxpath and dst are taken to be relative If only_update is set to `True` the modification time is checked and compilation is only run if the source is newer than the destination Parameters ========== pyxpath: str Path to Cython source file. objpath: str (optional) Path to object file to generate. destdir: str (optional) Directory to put generated C file. When ``None``: directory of ``objpath``. cwd: str (optional) Working directory and root of relative paths. include_dirs: iterable of path strings (optional) Passed onto src2obj and via cy_kwargs['include_path'] to simple_cythonize. cy_kwargs: dict (optional) Keyword arguments passed onto `simple_cythonize` cplus: bool (optional) Indicate whether C++ is used. default: auto-detect using ``.util.pyx_is_cplus``. compile_kwargs: dict keyword arguments passed onto src2obj Returns ======= Absolute path of generated object file. """ assert pyxpath.endswith('.pyx') cwd = cwd or '.' objpath = objpath or '.' destdir = destdir or os.path.dirname(objpath) abs_objpath = get_abspath(objpath, cwd=cwd) if os.path.isdir(abs_objpath): pyx_fname = os.path.basename(pyxpath) name, ext = os.path.splitext(pyx_fname) objpath = os.path.join(objpath, name+objext) cy_kwargs = cy_kwargs or {} cy_kwargs['output_dir'] = cwd if cplus is None: cplus = pyx_is_cplus(pyxpath) cy_kwargs['cplus'] = cplus interm_c_file = simple_cythonize(pyxpath, destdir=destdir, cwd=cwd, **cy_kwargs) include_dirs = include_dirs or [] flags = kwargs.pop('flags', []) needed_flags = ('-fwrapv', '-pthread', '-fPIC') for flag in needed_flags: if flag not in flags: flags.append(flag) options = kwargs.pop('options', []) if kwargs.pop('strict_aliasing', False): raise CompileError("Cython requires strict aliasing to be disabled.") # Let's be explicit about standard if cplus: std = kwargs.pop('std', 'c++98') else: std = kwargs.pop('std', 'c99') return src2obj(interm_c_file, objpath=objpath, cwd=cwd, include_dirs=include_dirs, flags=flags, std=std, options=options, inc_py=True, strict_aliasing=False, **kwargs) def _any_X(srcs, cls): for src in srcs: name, ext = os.path.splitext(src) key = ext.lower() if key in extension_mapping: if extension_mapping[key][0] == cls: return True return False def any_fortran_src(srcs): return _any_X(srcs, FortranCompilerRunner) def any_cplus_src(srcs): return _any_X(srcs, CppCompilerRunner) def compile_link_import_py_ext(sources, extname=None, build_dir='.', compile_kwargs=None, link_kwargs=None): """ Compiles sources to a shared object (python extension) and imports it Sources in ``sources`` which is imported. If shared object is newer than the sources, they are not recompiled but instead it is imported. Parameters ========== sources : string List of paths to sources. extname : string Name of extension (default: ``None``). If ``None``: taken from the last file in ``sources`` without extension. build_dir: str Path to directory in which objects files etc. are generated. compile_kwargs: dict keyword arguments passed to ``compile_sources`` link_kwargs: dict keyword arguments passed to ``link_py_so`` Returns ======= The imported module from of the python extension. Examples ======== >>> mod = compile_link_import_py_ext(['fft.f90', 'conv.cpp', '_fft.pyx']) # doctest: +SKIP >>> Aprim = mod.fft(A) # doctest: +SKIP """ if extname is None: extname = os.path.splitext(os.path.basename(sources[-1]))[0] compile_kwargs = compile_kwargs or {} link_kwargs = link_kwargs or {} try: mod = import_module_from_file(os.path.join(build_dir, extname), sources) except ImportError: objs = compile_sources(list(map(get_abspath, sources)), destdir=build_dir, cwd=build_dir, **compile_kwargs) so = link_py_so(objs, cwd=build_dir, fort=any_fortran_src(sources), cplus=any_cplus_src(sources), **link_kwargs) mod = import_module_from_file(so) return mod def _write_sources_to_build_dir(sources, build_dir): build_dir = build_dir or tempfile.mkdtemp() if not os.path.isdir(build_dir): raise OSError("Non-existent directory: ", build_dir) source_files = [] for name, src in sources: dest = os.path.join(build_dir, name) differs = True sha256_in_mem = sha256_of_string(src.encode('utf-8')).hexdigest() if os.path.exists(dest): if os.path.exists(dest+'.sha256'): sha256_on_disk = open(dest+'.sha256', 'rt').read() else: sha256_on_disk = sha256_of_file(dest).hexdigest() differs = sha256_on_disk != sha256_in_mem if differs: with open(dest, 'wt') as fh: fh.write(src) open(dest+'.sha256', 'wt').write(sha256_in_mem) source_files.append(dest) return source_files, build_dir def compile_link_import_strings(sources, build_dir=None, **kwargs): """ Compiles, links and imports extension module from source. Parameters ========== sources : iterable of name/source pair tuples build_dir : string (default: None) Path. ``None`` implies use a temporary directory. **kwargs: Keyword arguments passed onto `compile_link_import_py_ext`. Returns ======= mod : module The compiled and imported extension module. info : dict Containing ``build_dir`` as 'build_dir'. """ source_files, build_dir = _write_sources_to_build_dir(sources, build_dir) mod = compile_link_import_py_ext(source_files, build_dir=build_dir, **kwargs) info = dict(build_dir=build_dir) return mod, info def compile_run_strings(sources, build_dir=None, clean=False, compile_kwargs=None, link_kwargs=None): """ Compiles, links and runs a program built from sources. Parameters ========== sources : iterable of name/source pair tuples build_dir : string (default: None) Path. ``None`` implies use a temporary directory. clean : bool Whether to remove build_dir after use. This will only have an effect if ``build_dir`` is ``None`` (which creates a temporary directory). Passing ``clean == True`` and ``build_dir != None`` raises a ``ValueError``. This will also set ``build_dir`` in returned info dictionary to ``None``. compile_kwargs: dict Keyword arguments passed onto ``compile_sources`` link_kwargs: dict Keyword arguments passed onto ``link`` Returns ======= (stdout, stderr): pair of strings info: dict Containing exit status as 'exit_status' and ``build_dir`` as 'build_dir' """ if clean and build_dir is not None: raise ValueError("Automatic removal of build_dir is only available for temporary directory.") try: source_files, build_dir = _write_sources_to_build_dir(sources, build_dir) objs = compile_sources(list(map(get_abspath, source_files)), destdir=build_dir, cwd=build_dir, **(compile_kwargs or {})) prog = link(objs, cwd=build_dir, fort=any_fortran_src(source_files), cplus=any_cplus_src(source_files), **(link_kwargs or {})) p = subprocess.Popen([prog], stdout=subprocess.PIPE, stderr=subprocess.PIPE) exit_status = p.wait() stdout, stderr = [txt.decode('utf-8') for txt in p.communicate()] finally: if clean and os.path.isdir(build_dir): shutil.rmtree(build_dir) build_dir = None info = dict(exit_status=exit_status, build_dir=build_dir) return (stdout, stderr), info
f4f8a3ff4846cdf6b07126a0042a1e5a7f30679f8e2e9e947f3c17cb45ca7f17
from __future__ import print_function, division, absolute_import from collections import OrderedDict from distutils.errors import CompileError import os import re import subprocess import sys from .util import ( find_binary_of_command, unique_list ) from sympy.core.compatibility import string_types class CompilerRunner(object): """ CompilerRunner base class. Parameters ========== sources : list of str Paths to sources. out : str flags : iterable of str Compiler flags. run_linker : bool compiler_name_exe : (str, str) tuple Tuple of compiler name & command to call. cwd : str Path of root of relative paths. include_dirs : list of str Include directories. libraries : list of str Libraries to link against. library_dirs : list of str Paths to search for shared libraries. std : str Standard string, e.g. ``'c++11'``, ``'c99'``, ``'f2003'``. define: iterable of strings macros to define undef : iterable of strings macros to undefine preferred_vendor : string name of preferred vendor e.g. 'gnu' or 'intel' Methods ======= run(): Invoke compilation as a subprocess. """ compiler_dict = None # Subclass to vendor/binary dict # Standards should be a tuple of supported standards # (first one will be the default) standards = None std_formater = None # Subclass to dict of binary/formater-callback # subclass to be e.g. {'gcc': 'gnu', ...} compiler_name_vendor_mapping = None def __init__(self, sources, out, flags=None, run_linker=True, compiler=None, cwd='.', include_dirs=None, libraries=None, library_dirs=None, std=None, define=None, undef=None, strict_aliasing=None, preferred_vendor=None, **kwargs): if isinstance(sources, string_types): raise ValueError("Expected argument sources to be a list of strings.") self.sources = list(sources) self.out = out self.flags = flags or [] self.cwd = cwd if compiler: self.compiler_name, self.compiler_binary = compiler else: # Find a compiler if preferred_vendor is None: preferred_vendor = os.environ.get('SYMPY_COMPILER_VENDOR', None) self.compiler_name, self.compiler_binary, self.compiler_vendor = self.find_compiler(preferred_vendor) if self.compiler_binary is None: raise ValueError("No compiler found (searched: {0})".format(', '.join(self.compiler_dict.values()))) self.define = define or [] self.undef = undef or [] self.include_dirs = include_dirs or [] self.libraries = libraries or [] self.library_dirs = library_dirs or [] self.std = std or self.standards[0] self.run_linker = run_linker if self.run_linker: # both gnu and intel compilers use '-c' for disabling linker self.flags = list(filter(lambda x: x != '-c', self.flags)) else: if '-c' not in self.flags: self.flags.append('-c') if self.std: self.flags.append(self.std_formater[ self.compiler_name](self.std)) self.linkline = [] if strict_aliasing is not None: nsa_re = re.compile("no-strict-aliasing$") sa_re = re.compile("strict-aliasing$") if strict_aliasing is True: if any(map(nsa_re.match, flags)): raise CompileError("Strict aliasing cannot be both enforced and disabled") elif any(map(sa_re.match, flags)): pass # already enforced else: flags.append('-fstrict-aliasing') elif strict_aliasing is False: if any(map(nsa_re.match, flags)): pass # already disabled else: if any(map(sa_re.match, flags)): raise CompileError("Strict aliasing cannot be both enforced and disabled") else: flags.append('-fno-strict-aliasing') else: msg = "Expected argument strict_aliasing to be True/False, got {}" raise ValueError(msg.format(strict_aliasing)) @classmethod def find_compiler(cls, preferred_vendor=None): """ Identify a suitable C/fortran/other compiler. """ candidates = list(cls.compiler_dict.keys()) if preferred_vendor: if preferred_vendor in candidates: candidates = [preferred_vendor]+candidates else: raise ValueError("Unknown vendor {}".format(preferred_vendor)) name, path = find_binary_of_command([cls.compiler_dict[x] for x in candidates]) return name, path, cls.compiler_name_vendor_mapping[name] def cmd(self): """ List of arguments (str) to be passed to e.g. ``subprocess.Popen``. """ cmd = ( [self.compiler_binary] + self.flags + ['-U'+x for x in self.undef] + ['-D'+x for x in self.define] + ['-I'+x for x in self.include_dirs] + self.sources ) if self.run_linker: cmd += (['-L'+x for x in self.library_dirs] + ['-l'+x for x in self.libraries] + self.linkline) counted = [] for envvar in re.findall(r'\$\{(\w+)\}', ' '.join(cmd)): if os.getenv(envvar) is None: if envvar not in counted: counted.append(envvar) msg = "Environment variable '{}' undefined.".format(envvar) raise CompileError(msg) return cmd def run(self): self.flags = unique_list(self.flags) # Append output flag and name to tail of flags self.flags.extend(['-o', self.out]) env = os.environ.copy() env['PWD'] = self.cwd # NOTE: intel compilers seems to need shell=True p = subprocess.Popen(' '.join(self.cmd()), shell=True, cwd=self.cwd, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, env=env) comm = p.communicate() if sys.version_info[0] == 2: self.cmd_outerr = comm[0] else: try: self.cmd_outerr = comm[0].decode('utf-8') except UnicodeDecodeError: self.cmd_outerr = comm[0].decode('iso-8859-1') # win32 self.cmd_returncode = p.returncode # Error handling if self.cmd_returncode != 0: msg = "Error executing '{0}' in {1} (exited status {2}):\n {3}\n".format( ' '.join(self.cmd()), self.cwd, str(self.cmd_returncode), self.cmd_outerr ) raise CompileError(msg) return self.cmd_outerr, self.cmd_returncode class CCompilerRunner(CompilerRunner): compiler_dict = OrderedDict([ ('gnu', 'gcc'), ('intel', 'icc'), ('llvm', 'clang'), ]) standards = ('c89', 'c90', 'c99', 'c11') # First is default std_formater = { 'gcc': '-std={}'.format, 'icc': '-std={}'.format, 'clang': '-std={}'.format, } compiler_name_vendor_mapping = { 'gcc': 'gnu', 'icc': 'intel', 'clang': 'llvm' } def _mk_flag_filter(cmplr_name): # helper for class initialization not_welcome = {'g++': ("Wimplicit-interface",)} # "Wstrict-prototypes",)} if cmplr_name in not_welcome: def fltr(x): for nw in not_welcome[cmplr_name]: if nw in x: return False return True else: def fltr(x): return True return fltr class CppCompilerRunner(CompilerRunner): compiler_dict = OrderedDict([ ('gnu', 'g++'), ('intel', 'icpc'), ('llvm', 'clang++'), ]) # First is the default, c++0x == c++11 standards = ('c++98', 'c++0x') std_formater = { 'g++': '-std={}'.format, 'icpc': '-std={}'.format, 'clang++': '-std={}'.format, } compiler_name_vendor_mapping = { 'g++': 'gnu', 'icpc': 'intel', 'clang++': 'llvm' } class FortranCompilerRunner(CompilerRunner): standards = (None, 'f77', 'f95', 'f2003', 'f2008') std_formater = { 'gfortran': lambda x: '-std=gnu' if x is None else '-std=legacy' if x == 'f77' else '-std={}'.format(x), 'ifort': lambda x: '-stand f08' if x is None else '-stand f{}'.format(x[-2:]), # f2008 => f08 } compiler_dict = OrderedDict([ ('gnu', 'gfortran'), ('intel', 'ifort'), ]) compiler_name_vendor_mapping = { 'gfortran': 'gnu', 'ifort': 'intel', }
04c58f3b17649e9e8b38c761d4fb75242c143dba719cfc8ce2bcd89ee4673e43
from __future__ import (absolute_import, division, print_function) from collections import namedtuple from hashlib import sha256 import os import shutil import sys import tempfile from sympy.utilities.pytest import XFAIL def may_xfail(func): if sys.platform.lower() == 'darwin' or os.name == 'nt': # sympy.utilities._compilation needs more testing on Windows and macOS # once those two platforms are reliably supported this xfail decorator # may be removed. return XFAIL(func) else: return func if sys.version_info[0] == 2: class FileNotFoundError(IOError): pass class TemporaryDirectory(object): def __init__(self): self.path = tempfile.mkdtemp() def __enter__(self): return self.path def __exit__(self, exc, value, tb): shutil.rmtree(self.path) else: FileNotFoundError = FileNotFoundError TemporaryDirectory = tempfile.TemporaryDirectory class CompilerNotFoundError(FileNotFoundError): pass def get_abspath(path, cwd='.'): """ Returns the aboslute path. Parameters ========== path : str (relative) path. cwd : str Path to root of relative path. """ if os.path.isabs(path): return path else: if not os.path.isabs(cwd): cwd = os.path.abspath(cwd) return os.path.abspath( os.path.join(cwd, path) ) def make_dirs(path): """ Create directories (equivalent of ``mkdir -p``). """ if path[-1] == '/': parent = os.path.dirname(path[:-1]) else: parent = os.path.dirname(path) if len(parent) > 0: if not os.path.exists(parent): make_dirs(parent) if not os.path.exists(path): os.mkdir(path, 0o777) else: assert os.path.isdir(path) def copy(src, dst, only_update=False, copystat=True, cwd=None, dest_is_dir=False, create_dest_dirs=False): """ Variation of ``shutil.copy`` with extra options. Parameters ========== src : str Path to source file. dst : str Path to destination. only_update : bool Only copy if source is newer than destination (returns None if it was newer), default: ``False``. copystat : bool See ``shutil.copystat``. default: ``True``. cwd : str Path to working directory (root of relative paths). dest_is_dir : bool Ensures that dst is treated as a directory. default: ``False`` create_dest_dirs : bool Creates directories if needed. Returns ======= Path to the copied file. """ if cwd: # Handle working directory if not os.path.isabs(src): src = os.path.join(cwd, src) if not os.path.isabs(dst): dst = os.path.join(cwd, dst) if not os.path.exists(src): # Make sure source file extists raise FileNotFoundError("Source: `{}` does not exist".format(src)) # We accept both (re)naming destination file _or_ # passing a (possible non-existant) destination directory if dest_is_dir: if not dst[-1] == '/': dst = dst+'/' else: if os.path.exists(dst) and os.path.isdir(dst): dest_is_dir = True if dest_is_dir: dest_dir = dst dest_fname = os.path.basename(src) dst = os.path.join(dest_dir, dest_fname) else: dest_dir = os.path.dirname(dst) dest_fname = os.path.basename(dst) if not os.path.exists(dest_dir): if create_dest_dirs: make_dirs(dest_dir) else: raise FileNotFoundError("You must create directory first.") if only_update: if not missing_or_other_newer(dst, src): return if os.path.islink(dst): _cwd = os.path.dirname(dst) dst = os.path.abspath(os.path.realpath(dst), cwd=cwd) shutil.copy(src, dst) if copystat: shutil.copystat(src, dst) return dst Glob = namedtuple('Glob', 'pathname') ArbitraryDepthGlob = namedtuple('ArbitraryDepthGlob', 'filename') def glob_at_depth(filename_glob, cwd=None): if cwd is not None: cwd = '.' globbed = [] for root, dirs, filenames in os.walk(cwd): for fn in filenames: if fnmatch.fnmatch(fn, filename_glob): globbed.append(os.path.join(root, fn)) return globbed def sha256_of_file(path, nblocks=128): """ Computes the SHA256 hash of a file. Parameters ========== path : string Path to file to compute hash of. nblocks : int Number of blocks to read per iteration. Returns ======= hashlib sha256 hash object. Use ``.digest()`` or ``.hexdigest()`` on returned object to get binary or hex encoded string. """ sh = sha256() with open(path, 'rb') as f: for chunk in iter(lambda: f.read(nblocks*sh.block_size), b''): sh.update(chunk) return sh def sha256_of_string(string): """ Computes the SHA256 hash of a string. """ sh = sha256() sh.update(string) return sh def pyx_is_cplus(path): """ Inspect a Cython source file (.pyx) and look for comment line like: # distutils: language = c++ Returns True if such a file is present in the file, else False. """ for line in open(path, 'rt'): if line.startswith('#') and '=' in line: splitted = line.split('=') if len(splitted) != 2: continue lhs, rhs = splitted if lhs.strip().split()[-1].lower() == 'language' and \ rhs.strip().split()[0].lower() == 'c++': return True return False def import_module_from_file(filename, only_if_newer_than=None): """ Imports python extension (from shared object file) Provide a list of paths in `only_if_newer_than` to check timestamps of dependencies. import_ raises an ImportError if any is newer. Word of warning: The OS may cache shared objects which makes reimporting same path of an shared object file very problematic. It will not detect the new time stamp, nor new checksum, but will instead silently use old module. Use unique names for this reason. Parameters ========== filename : str Path to shared object. only_if_newer_than : iterable of strings Paths to dependencies of the shared object. Raises ====== ``ImportError`` if any of the files specified in ``only_if_newer_than`` are newer than the file given by filename. """ path, name = os.path.split(filename) name, ext = os.path.splitext(name) name = name.split('.')[0] if sys.version_info[0] == 2: from imp import find_module, load_module fobj, filename, data = find_module(name, [path]) if only_if_newer_than: for dep in only_if_newer_than: if os.path.getmtime(filename) < os.path.getmtime(dep): raise ImportError("{} is newer than {}".format(dep, filename)) mod = load_module(name, fobj, filename, data) else: import importlib.util spec = importlib.util.spec_from_file_location(name, filename) if spec is None: raise ImportError("Failed to import: '%s'" % filename) mod = importlib.util.module_from_spec(spec) spec.loader.exec_module(mod) return mod def find_binary_of_command(candidates): """ Finds binary first matching name among candidates. Calls `find_executable` from distuils for provided candidates and returns first hit. Parameters ========== candidates : iterable of str Names of candidate commands Raises ====== CompilerNotFoundError if no candidates match. """ from distutils.spawn import find_executable for c in candidates: binary_path = find_executable(c) if c and binary_path: return c, binary_path raise CompilerNotFoundError('No binary located for candidates: {}'.format(candidates)) def unique_list(l): """ Uniquify a list (skip duplicate items). """ result = [] for x in l: if x not in result: result.append(x) return result
46ead10b2c87368b6dc478fe309f313e5a38345ffd1d9b4cd7afce5ce5874647
""" Tests from Michael Wester's 1999 paper "Review of CAS mathematical capabilities". http://www.math.unm.edu/~wester/cas/book/Wester.pdf See also http://math.unm.edu/~wester/cas_review.html for detailed output of each tested system. """ from sympy import (Rational, symbols, Dummy, factorial, sqrt, log, exp, oo, zoo, product, binomial, rf, pi, gamma, igcd, factorint, radsimp, combsimp, npartitions, totient, primerange, factor, simplify, gcd, resultant, expand, I, trigsimp, tan, sin, cos, cot, diff, nan, limit, EulerGamma, polygamma, bernoulli, hyper, hyperexpand, besselj, asin, assoc_legendre, Function, re, im, DiracDelta, chebyshevt, legendre_poly, polylog, series, O, atan, sinh, cosh, tanh, floor, ceiling, solve, asinh, acot, csc, sec, LambertW, N, apart, sqrtdenest, factorial2, powdenest, Mul, S, ZZ, Poly, expand_func, E, Q, And, Or, Ne, Eq, Le, Lt, Min, ask, refine, AlgebraicNumber, continued_fraction_iterator as cf_i, continued_fraction_periodic as cf_p, continued_fraction_convergents as cf_c, continued_fraction_reduce as cf_r, FiniteSet, elliptic_e, elliptic_f, powsimp, hessian, wronskian, fibonacci, sign, Lambda, Piecewise, Subs, residue, Derivative, logcombine, Symbol, Intersection, Union, EmptySet, Interval, Integral, idiff, ImageSet, acos, Max, MatMul) import mpmath from sympy.functions.combinatorial.numbers import stirling from sympy.functions.special.delta_functions import Heaviside from sympy.functions.special.error_functions import Ci, Si, erf from sympy.functions.special.zeta_functions import zeta from sympy.integrals.deltafunctions import deltaintegrate from sympy.utilities.pytest import XFAIL, slow, SKIP, skip, ON_TRAVIS from sympy.utilities.iterables import partitions from mpmath import mpi, mpc from sympy.matrices import Matrix, GramSchmidt, eye from sympy.matrices.expressions.blockmatrix import BlockMatrix, block_collapse from sympy.matrices.expressions import MatrixSymbol, ZeroMatrix from sympy.physics.quantum import Commutator from sympy.assumptions import assuming from sympy.polys.rings import vring from sympy.polys.fields import vfield from sympy.polys.solvers import solve_lin_sys from sympy.concrete import Sum from sympy.concrete.products import Product from sympy.integrals import integrate from sympy.integrals.transforms import laplace_transform,\ inverse_laplace_transform, LaplaceTransform, fourier_transform,\ mellin_transform from sympy.solvers.recurr import rsolve from sympy.solvers.solveset import solveset, solveset_real, linsolve from sympy.solvers.ode import dsolve from sympy.core.relational import Equality from sympy.core.compatibility import range, PY3 from itertools import islice, takewhile from sympy.series.formal import fps from sympy.series.fourier import fourier_series R = Rational x, y, z = symbols('x y z') i, j, k, l, m, n = symbols('i j k l m n', integer=True) f = Function('f') g = Function('g') # A. Boolean Logic and Quantifier Elimination # Not implemented. # B. Set Theory def test_B1(): assert (FiniteSet(i, j, j, k, k, k) | FiniteSet(l, k, j) | FiniteSet(j, m, j)) == FiniteSet(i, j, k, l, m) def test_B2(): a, b, c = FiniteSet(j), FiniteSet(m), FiniteSet(j, k) d, e = FiniteSet(i), FiniteSet(j, k, l) assert (FiniteSet(i, j, j, k, k, k) & FiniteSet(l, k, j) & FiniteSet(j, m, j)) == Union(a, Intersection(b, Union(c, Intersection(d, FiniteSet(l))))) # {j} U Intersection({m}, {j, k} U Intersection({i}, {l})) def test_B3(): assert (FiniteSet(i, j, k, l, m) - FiniteSet(j) == FiniteSet(i, k, l, m)) def test_B4(): assert (FiniteSet(*(FiniteSet(i, j)*FiniteSet(k, l))) == FiniteSet((i, k), (i, l), (j, k), (j, l))) # C. Numbers def test_C1(): assert (factorial(50) == 30414093201713378043612608166064768844377641568960512000000000000) def test_C2(): assert (factorint(factorial(50)) == {2: 47, 3: 22, 5: 12, 7: 8, 11: 4, 13: 3, 17: 2, 19: 2, 23: 2, 29: 1, 31: 1, 37: 1, 41: 1, 43: 1, 47: 1}) def test_C3(): assert (factorial2(10), factorial2(9)) == (3840, 945) # Base conversions; not really implemented by sympy # Whatever. Take credit! def test_C4(): assert 0xABC == 2748 def test_C5(): assert 123 == int('234', 7) def test_C6(): assert int('677', 8) == int('1BF', 16) == 447 def test_C7(): assert log(32768, 8) == 5 def test_C8(): # Modular multiplicative inverse. Would be nice if divmod could do this. assert ZZ.invert(5, 7) == 3 assert ZZ.invert(5, 6) == 5 def test_C9(): assert igcd(igcd(1776, 1554), 5698) == 74 def test_C10(): x = 0 for n in range(2, 11): x += R(1, n) assert x == R(4861, 2520) def test_C11(): assert R(1, 7) == S('0.[142857]') def test_C12(): assert R(7, 11) * R(22, 7) == 2 def test_C13(): test = R(10, 7) * (1 + R(29, 1000)) ** R(1, 3) good = 3 ** R(1, 3) assert test == good def test_C14(): assert sqrtdenest(sqrt(2*sqrt(3) + 4)) == 1 + sqrt(3) def test_C15(): test = sqrtdenest(sqrt(14 + 3*sqrt(3 + 2*sqrt(5 - 12*sqrt(3 - 2*sqrt(2)))))) good = sqrt(2) + 3 assert test == good def test_C16(): test = sqrtdenest(sqrt(10 + 2*sqrt(6) + 2*sqrt(10) + 2*sqrt(15))) good = sqrt(2) + sqrt(3) + sqrt(5) assert test == good def test_C17(): test = radsimp((sqrt(3) + sqrt(2)) / (sqrt(3) - sqrt(2))) good = 5 + 2*sqrt(6) assert test == good def test_C18(): assert simplify((sqrt(-2 + sqrt(-5)) * sqrt(-2 - sqrt(-5))).expand(complex=True)) == 3 @XFAIL def test_C19(): assert radsimp(simplify((90 + 34*sqrt(7)) ** R(1, 3))) == 3 + sqrt(7) def test_C20(): inside = (135 + 78*sqrt(3)) test = AlgebraicNumber((inside**R(2, 3) + 3) * sqrt(3) / inside**R(1, 3)) assert simplify(test) == AlgebraicNumber(12) def test_C21(): assert simplify(AlgebraicNumber((41 + 29*sqrt(2)) ** R(1, 5))) == \ AlgebraicNumber(1 + sqrt(2)) @XFAIL def test_C22(): test = simplify(((6 - 4*sqrt(2))*log(3 - 2*sqrt(2)) + (3 - 2*sqrt(2))*log(17 - 12*sqrt(2)) + 32 - 24*sqrt(2)) / (48*sqrt(2) - 72)) good = sqrt(2)/3 - log(sqrt(2) - 1)/3 assert test == good def test_C23(): assert 2 * oo - 3 == oo @XFAIL def test_C24(): raise NotImplementedError("2**aleph_null == aleph_1") # D. Numerical Analysis def test_D1(): assert 0.0 / sqrt(2) == 0.0 def test_D2(): assert str(exp(-1000000).evalf()) == '3.29683147808856e-434295' def test_D3(): assert exp(pi*sqrt(163)).evalf(50).num.ae(262537412640768744) def test_D4(): assert floor(R(-5, 3)) == -2 assert ceiling(R(-5, 3)) == -1 @XFAIL def test_D5(): raise NotImplementedError("cubic_spline([1, 2, 4, 5], [1, 4, 2, 3], x)(3) == 27/8") @XFAIL def test_D6(): raise NotImplementedError("translate sum(a[i]*x**i, (i,1,n)) to FORTRAN") @XFAIL def test_D7(): raise NotImplementedError("translate sum(a[i]*x**i, (i,1,n)) to C") @XFAIL def test_D8(): # One way is to cheat by converting the sum to a string, # and replacing the '[' and ']' with ''. # E.g., horner(S(str(_).replace('[','').replace(']',''))) raise NotImplementedError("apply Horner's rule to sum(a[i]*x**i, (i,1,5))") @XFAIL def test_D9(): raise NotImplementedError("translate D8 to FORTRAN") @XFAIL def test_D10(): raise NotImplementedError("translate D8 to C") @XFAIL def test_D11(): #Is there a way to use count_ops? raise NotImplementedError("flops(sum(product(f[i][k], (i,1,k)), (k,1,n)))") @XFAIL def test_D12(): assert (mpi(-4, 2) * x + mpi(1, 3)) ** 2 == mpi(-8, 16)*x**2 + mpi(-24, 12)*x + mpi(1, 9) @XFAIL def test_D13(): raise NotImplementedError("discretize a PDE: diff(f(x,t),t) == diff(diff(f(x,t),x),x)") # E. Statistics # See scipy; all of this is numerical. # F. Combinatorial Theory. def test_F1(): assert rf(x, 3) == x*(1 + x)*(2 + x) def test_F2(): assert expand_func(binomial(n, 3)) == n*(n - 1)*(n - 2)/6 @XFAIL def test_F3(): assert combsimp(2**n * factorial(n) * factorial2(2*n - 1)) == factorial(2*n) @XFAIL def test_F4(): assert combsimp((2**n * factorial(n) * product(2*k - 1, (k, 1, n)))) == factorial(2*n) @XFAIL def test_F5(): assert gamma(n + R(1, 2)) / sqrt(pi) / factorial(n) == factorial(2*n)/2**(2*n)/factorial(n)**2 def test_F6(): partTest = [p.copy() for p in partitions(4)] partDesired = [{4: 1}, {1: 1, 3: 1}, {2: 2}, {1: 2, 2:1}, {1: 4}] assert partTest == partDesired def test_F7(): assert npartitions(4) == 5 def test_F8(): assert stirling(5, 2, signed=True) == -50 # if signed, then kind=1 def test_F9(): assert totient(1776) == 576 # G. Number Theory def test_G1(): assert list(primerange(999983, 1000004)) == [999983, 1000003] @XFAIL def test_G2(): raise NotImplementedError("find the primitive root of 191 == 19") @XFAIL def test_G3(): raise NotImplementedError("(a+b)**p mod p == a**p + b**p mod p; p prime") # ... G14 Modular equations are not implemented. def test_G15(): assert Rational(sqrt(3).evalf()).limit_denominator(15) == Rational(26, 15) assert list(takewhile(lambda x: x.q <= 15, cf_c(cf_i(sqrt(3)))))[-1] == \ Rational(26, 15) def test_G16(): assert list(islice(cf_i(pi),10)) == [3, 7, 15, 1, 292, 1, 1, 1, 2, 1] def test_G17(): assert cf_p(0, 1, 23) == [4, [1, 3, 1, 8]] def test_G18(): assert cf_p(1, 2, 5) == [[1]] assert cf_r([[1]]) == S.Half + sqrt(5)/2 @XFAIL def test_G19(): s = symbols('s', integer=True, positive=True) it = cf_i((exp(1/s) - 1)/(exp(1/s) + 1)) assert list(islice(it, 5)) == [0, 2*s, 6*s, 10*s, 14*s] def test_G20(): s = symbols('s', integer=True, positive=True) # Wester erroneously has this as -s + sqrt(s**2 + 1) assert cf_r([[2*s]]) == s + sqrt(s**2 + 1) @XFAIL def test_G20b(): s = symbols('s', integer=True, positive=True) assert cf_p(s, 1, s**2 + 1) == [[2*s]] # H. Algebra def test_H1(): assert simplify(2*2**n) == simplify(2**(n + 1)) assert powdenest(2*2**n) == simplify(2**(n + 1)) def test_H2(): assert powsimp(4 * 2**n) == 2**(n + 2) def test_H3(): assert (-1)**(n*(n + 1)) == 1 def test_H4(): expr = factor(6*x - 10) assert type(expr) is Mul assert expr.args[0] == 2 assert expr.args[1] == 3*x - 5 p1 = 64*x**34 - 21*x**47 - 126*x**8 - 46*x**5 - 16*x**60 - 81 p2 = 72*x**60 - 25*x**25 - 19*x**23 - 22*x**39 - 83*x**52 + 54*x**10 + 81 q = 34*x**19 - 25*x**16 + 70*x**7 + 20*x**3 - 91*x - 86 def test_H5(): assert gcd(p1, p2, x) == 1 def test_H6(): assert gcd(expand(p1 * q), expand(p2 * q)) == q def test_H7(): p1 = 24*x*y**19*z**8 - 47*x**17*y**5*z**8 + 6*x**15*y**9*z**2 - 3*x**22 + 5 p2 = 34*x**5*y**8*z**13 + 20*x**7*y**7*z**7 + 12*x**9*y**16*z**4 + 80*y**14*z assert gcd(p1, p2, x, y, z) == 1 def test_H8(): p1 = 24*x*y**19*z**8 - 47*x**17*y**5*z**8 + 6*x**15*y**9*z**2 - 3*x**22 + 5 p2 = 34*x**5*y**8*z**13 + 20*x**7*y**7*z**7 + 12*x**9*y**16*z**4 + 80*y**14*z q = 11*x**12*y**7*z**13 - 23*x**2*y**8*z**10 + 47*x**17*y**5*z**8 assert gcd(p1 * q, p2 * q, x, y, z) == q def test_H9(): p1 = 2*x**(n + 4) - x**(n + 2) p2 = 4*x**(n + 1) + 3*x**n assert gcd(p1, p2) == x**n def test_H10(): p1 = 3*x**4 + 3*x**3 + x**2 - x - 2 p2 = x**3 - 3*x**2 + x + 5 assert resultant(p1, p2, x) == 0 def test_H11(): assert resultant(p1 * q, p2 * q, x) == 0 def test_H12(): num = x**2 - 4 den = x**2 + 4*x + 4 assert simplify(num/den) == (x - 2)/(x + 2) @XFAIL def test_H13(): assert simplify((exp(x) - 1) / (exp(x/2) + 1)) == exp(x/2) - 1 def test_H14(): p = (x + 1) ** 20 ep = expand(p) assert ep == (1 + 20*x + 190*x**2 + 1140*x**3 + 4845*x**4 + 15504*x**5 + 38760*x**6 + 77520*x**7 + 125970*x**8 + 167960*x**9 + 184756*x**10 + 167960*x**11 + 125970*x**12 + 77520*x**13 + 38760*x**14 + 15504*x**15 + 4845*x**16 + 1140*x**17 + 190*x**18 + 20*x**19 + x**20) dep = diff(ep, x) assert dep == (20 + 380*x + 3420*x**2 + 19380*x**3 + 77520*x**4 + 232560*x**5 + 542640*x**6 + 1007760*x**7 + 1511640*x**8 + 1847560*x**9 + 1847560*x**10 + 1511640*x**11 + 1007760*x**12 + 542640*x**13 + 232560*x**14 + 77520*x**15 + 19380*x**16 + 3420*x**17 + 380*x**18 + 20*x**19) assert factor(dep) == 20*(1 + x)**19 def test_H15(): assert simplify((Mul(*[x - r for r in solveset(x**3 + x**2 - 7)]))) == x**3 + x**2 - 7 def test_H16(): assert factor(x**100 - 1) == ((x - 1)*(x + 1)*(x**2 + 1)*(x**4 - x**3 + x**2 - x + 1)*(x**4 + x**3 + x**2 + x + 1)*(x**8 - x**6 + x**4 - x**2 + 1)*(x**20 - x**15 + x**10 - x**5 + 1)*(x**20 + x**15 + x**10 + x**5 + 1)*(x**40 - x**30 + x**20 - x**10 + 1)) def test_H17(): assert simplify(factor(expand(p1 * p2)) - p1*p2) == 0 @XFAIL def test_H18(): # Factor over complex rationals. test = factor(4*x**4 + 8*x**3 + 77*x**2 + 18*x + 153) good = (2*x + 3*I)*(2*x - 3*I)*(x + 1 - 4*I)*(x + 1 + 4*I) assert test == good def test_H19(): a = symbols('a') # The idea is to let a**2 == 2, then solve 1/(a-1). Answer is a+1") assert Poly(a - 1).invert(Poly(a**2 - 2)) == a + 1 @XFAIL def test_H20(): raise NotImplementedError("let a**2==2; (x**3 + (a-2)*x**2 - " + "(2*a+3)*x - 3*a) / (x**2-2) = (x**2 - 2*x - 3) / (x-a)") @XFAIL def test_H21(): raise NotImplementedError("evaluate (b+c)**4 assuming b**3==2, c**2==3. \ Answer is 2*b + 8*c + 18*b**2 + 12*b*c + 9") def test_H22(): assert factor(x**4 - 3*x**2 + 1, modulus=5) == (x - 2)**2 * (x + 2)**2 def test_H23(): f = x**11 + x + 1 g = (x**2 + x + 1) * (x**9 - x**8 + x**6 - x**5 + x**3 - x**2 + 1) assert factor(f, modulus=65537) == g def test_H24(): phi = AlgebraicNumber(S.GoldenRatio.expand(func=True), alias='phi') assert factor(x**4 - 3*x**2 + 1, extension=phi) == \ (x - phi)*(x + 1 - phi)*(x - 1 + phi)*(x + phi) def test_H25(): e = (x - 2*y**2 + 3*z**3) ** 20 assert factor(expand(e)) == e def test_H26(): g = expand((sin(x) - 2*cos(y)**2 + 3*tan(z)**3)**20) assert factor(g, expand=False) == (-sin(x) + 2*cos(y)**2 - 3*tan(z)**3)**20 def test_H27(): f = 24*x*y**19*z**8 - 47*x**17*y**5*z**8 + 6*x**15*y**9*z**2 - 3*x**22 + 5 g = 34*x**5*y**8*z**13 + 20*x**7*y**7*z**7 + 12*x**9*y**16*z**4 + 80*y**14*z h = -2*z*y**7 \ *(6*x**9*y**9*z**3 + 10*x**7*z**6 + 17*y*x**5*z**12 + 40*y**7) \ *(3*x**22 + 47*x**17*y**5*z**8 - 6*x**15*y**9*z**2 - 24*x*y**19*z**8 - 5) assert factor(expand(f*g)) == h @XFAIL def test_H28(): raise NotImplementedError("expand ((1 - c**2)**5 * (1 - s**2)**5 * " + "(c**2 + s**2)**10) with c**2 + s**2 = 1. Answer is c**10*s**10.") @XFAIL def test_H29(): assert factor(4*x**2 - 21*x*y + 20*y**2, modulus=3) == (x + y)*(x - y) def test_H30(): test = factor(x**3 + y**3, extension=sqrt(-3)) answer = (x + y)*(x + y*(-R(1, 2) - sqrt(3)/2*I))*(x + y*(-R(1, 2) + sqrt(3)/2*I)) assert answer == test def test_H31(): f = (x**2 + 2*x + 3)/(x**3 + 4*x**2 + 5*x + 2) g = 2 / (x + 1)**2 - 2 / (x + 1) + 3 / (x + 2) assert apart(f) == g @XFAIL def test_H32(): # issue 6558 raise NotImplementedError("[A*B*C - (A*B*C)**(-1)]*A*C*B (product \ of a non-commuting product and its inverse)") def test_H33(): A, B, C = symbols('A, B, C', commutative=False) assert (Commutator(A, Commutator(B, C)) + Commutator(B, Commutator(C, A)) + Commutator(C, Commutator(A, B))).doit().expand() == 0 # I. Trigonometry @XFAIL def test_I1(): assert tan(7*pi/10) == -sqrt(1 + 2/sqrt(5)) @XFAIL def test_I2(): assert sqrt((1 + cos(6))/2) == -cos(3) def test_I3(): assert cos(n*pi) + sin((4*n - 1)*pi/2) == (-1)**n - 1 def test_I4(): assert refine(cos(pi*cos(n*pi)) + sin(pi/2*cos(n*pi)), Q.integer(n)) == (-1)**n - 1 @XFAIL def test_I5(): assert sin((n**5/5 + n**4/2 + n**3/3 - n/30) * pi) == 0 @XFAIL def test_I6(): raise NotImplementedError("assuming -3*pi<x<-5*pi/2, abs(cos(x)) == -cos(x), abs(sin(x)) == -sin(x)") @XFAIL def test_I7(): assert cos(3*x)/cos(x) == cos(x)**2 - 3*sin(x)**2 @XFAIL def test_I8(): assert cos(3*x)/cos(x) == 2*cos(2*x) - 1 @XFAIL def test_I9(): # Supposed to do this with rewrite rules. assert cos(3*x)/cos(x) == cos(x)**2 - 3*sin(x)**2 def test_I10(): assert trigsimp((tan(x)**2 + 1 - cos(x)**-2) / (sin(x)**2 + cos(x)**2 - 1)) == nan @SKIP("hangs") @XFAIL def test_I11(): assert limit((tan(x)**2 + 1 - cos(x)**-2) / (sin(x)**2 + cos(x)**2 - 1), x, 0) != 0 @XFAIL def test_I12(): try: # This should fail or return nan or something. diff((tan(x)**2 + 1 - cos(x)**-2) / (sin(x)**2 + cos(x)**2 - 1), x) except: assert True else: assert False, "taking the derivative with a fraction equivalent to 0/0 should fail" # J. Special functions. def test_J1(): assert bernoulli(16) == R(-3617, 510) def test_J2(): assert diff(elliptic_e(x, y**2), y) == (elliptic_e(x, y**2) - elliptic_f(x, y**2))/y @XFAIL def test_J3(): raise NotImplementedError("Jacobi elliptic functions: diff(dn(u,k), u) == -k**2*sn(u,k)*cn(u,k)") def test_J4(): assert gamma(R(-1, 2)) == -2*sqrt(pi) def test_J5(): assert polygamma(0, R(1, 3)) == -log(3) - sqrt(3)*pi/6 - EulerGamma - log(sqrt(3)) def test_J6(): assert mpmath.besselj(2, 1 + 1j).ae(mpc('0.04157988694396212', '0.24739764151330632')) def test_J7(): assert simplify(besselj(R(-5,2), pi/2)) == 12/(pi**2) def test_J8(): p = besselj(R(3,2), z) q = (sin(z)/z - cos(z))/sqrt(pi*z/2) assert simplify(expand_func(p) -q) == 0 def test_J9(): assert besselj(0, z).diff(z) == - besselj(1, z) def test_J10(): mu, nu = symbols('mu, nu', integer=True) assert assoc_legendre(nu, mu, 0) == 2**mu*sqrt(pi)/gamma((nu - mu)/2 + 1)/gamma((-nu - mu + 1)/2) def test_J11(): assert simplify(assoc_legendre(3, 1, x)) == simplify(-R(3, 2)*sqrt(1 - x**2)*(5*x**2 - 1)) @slow def test_J12(): assert simplify(chebyshevt(1008, x) - 2*x*chebyshevt(1007, x) + chebyshevt(1006, x)) == 0 def test_J13(): a = symbols('a', integer=True, negative=False) assert chebyshevt(a, -1) == (-1)**a def test_J14(): p = hyper([S(1)/2, S(1)/2], [S(3)/2], z**2) assert hyperexpand(p) == asin(z)/z @XFAIL def test_J15(): raise NotImplementedError("F((n+2)/2,-(n-2)/2,R(3,2),sin(z)**2) == sin(n*z)/(n*sin(z)*cos(z)); F(.) is hypergeometric function") @XFAIL def test_J16(): raise NotImplementedError("diff(zeta(x), x) @ x=0 == -log(2*pi)/2") def test_J17(): assert integrate(f((x + 2)/5)*DiracDelta((x - 2)/3) - g(x)*diff(DiracDelta(x - 1), x), (x, 0, 3)) == 3*f(S(4)/5) + Subs(Derivative(g(x), x), x, 1) @XFAIL def test_J18(): raise NotImplementedError("define an antisymmetric function") # K. The Complex Domain def test_K1(): z1, z2 = symbols('z1, z2', complex=True) assert re(z1 + I*z2) == -im(z2) + re(z1) assert im(z1 + I*z2) == im(z1) + re(z2) def test_K2(): assert abs(3 - sqrt(7) + I*sqrt(6*sqrt(7) - 15)) == 1 @XFAIL def test_K3(): a, b = symbols('a, b', real=True) assert simplify(abs(1/(a + I/a + I*b))) == 1/sqrt(a**2 + (I/a + b)**2) def test_K4(): assert log(3 + 4*I).expand(complex=True) == log(5) + I*atan(R(4, 3)) def test_K5(): x, y = symbols('x, y', real=True) assert tan(x + I*y).expand(complex=True) == (sin(2*x)/(cos(2*x) + cosh(2*y)) + I*sinh(2*y)/(cos(2*x) + cosh(2*y))) def test_K6(): assert sqrt(x*y*abs(z)**2)/(sqrt(x)*abs(z)) == sqrt(x*y)/sqrt(x) assert sqrt(x*y*abs(z)**2)/(sqrt(x)*abs(z)) != sqrt(y) def test_K7(): y = symbols('y', real=True, negative=False) expr = sqrt(x*y*abs(z)**2)/(sqrt(x)*abs(z)) sexpr = simplify(expr) assert sexpr == sqrt(y) @XFAIL def test_K8(): z = symbols('z', complex=True) assert simplify(sqrt(1/z) - 1/sqrt(z)) != 0 # Passes z = symbols('z', complex=True, negative=False) assert simplify(sqrt(1/z) - 1/sqrt(z)) == 0 # Fails def test_K9(): z = symbols('z', real=True, positive=True) assert simplify(sqrt(1/z) - 1/sqrt(z)) == 0 def test_K10(): z = symbols('z', real=True, negative=True) assert simplify(sqrt(1/z) + 1/sqrt(z)) == 0 # This goes up to K25 # L. Determining Zero Equivalence def test_L1(): assert sqrt(997) - (997**3)**R(1, 6) == 0 def test_L2(): assert sqrt(999983) - (999983**3)**R(1, 6) == 0 def test_L3(): assert simplify((2**R(1, 3) + 4**R(1, 3))**3 - 6*(2**R(1, 3) + 4**R(1, 3)) - 6) == 0 def test_L4(): assert trigsimp(cos(x)**3 + cos(x)*sin(x)**2 - cos(x)) == 0 @XFAIL def test_L5(): assert log(tan(R(1, 2)*x + pi/4)) - asinh(tan(x)) == 0 def test_L6(): assert (log(tan(x/2 + pi/4)) - asinh(tan(x))).diff(x).subs({x: 0}) == 0 @XFAIL def test_L7(): assert simplify(log((2*sqrt(x) + 1)/(sqrt(4*x + 4*sqrt(x) + 1)))) == 0 @XFAIL def test_L8(): assert simplify((4*x + 4*sqrt(x) + 1)**(sqrt(x)/(2*sqrt(x) + 1)) \ *(2*sqrt(x) + 1)**(1/(2*sqrt(x) + 1)) - 2*sqrt(x) - 1) == 0 @XFAIL def test_L9(): z = symbols('z', complex=True) assert simplify(2**(1 - z)*gamma(z)*zeta(z)*cos(z*pi/2) - pi**2*zeta(1 - z)) == 0 # M. Equations @XFAIL def test_M1(): assert Equality(x, 2)/2 + Equality(1, 1) == Equality(x/2 + 1, 2) def test_M2(): # The roots of this equation should all be real. Note that this # doesn't test that they are correct. sol = solveset(3*x**3 - 18*x**2 + 33*x - 19, x) assert all(s.expand(complex=True).is_real for s in sol) @XFAIL def test_M5(): assert solveset(x**6 - 9*x**4 - 4*x**3 + 27*x**2 - 36*x - 23, x) == FiniteSet(2**(1/3) + sqrt(3), 2**(1/3) - sqrt(3), +sqrt(3) - 1/2**(2/3) + I*sqrt(3)/2**(2/3), +sqrt(3) - 1/2**(2/3) - I*sqrt(3)/2**(2/3), -sqrt(3) - 1/2**(2/3) + I*sqrt(3)/2**(2/3), -sqrt(3) - 1/2**(2/3) - I*sqrt(3)/2**(2/3)) def test_M6(): assert set(solveset(x**7 - 1, x)) == \ {cos(n*2*pi/7) + I*sin(n*2*pi/7) for n in range(0, 7)} # The paper asks for exp terms, but sin's and cos's may be acceptable; # if the results are simplified, exp terms appear for all but # -sin(pi/14) - I*cos(pi/14) and -sin(pi/14) + I*cos(pi/14) which # will simplify if you apply the transformation foo.rewrite(exp).expand() def test_M7(): # TODO: Replace solve with solveset, as of now test fails for solveset sol = solve(x**8 - 8*x**7 + 34*x**6 - 92*x**5 + 175*x**4 - 236*x**3 + 226*x**2 - 140*x + 46, x) assert [s.simplify() for s in sol] == [ 1 - sqrt(-6 - 2*I*sqrt(3 + 4*sqrt(3)))/2, 1 + sqrt(-6 - 2*I*sqrt(3 + 4*sqrt(3)))/2, 1 - sqrt(-6 + 2*I*sqrt(3 + 4*sqrt(3)))/2, 1 + sqrt(-6 + 2*I*sqrt(3 + 4*sqrt (3)))/2, 1 - sqrt(-6 + 2*sqrt(-3 + 4*sqrt(3)))/2, 1 + sqrt(-6 + 2*sqrt(-3 + 4*sqrt(3)))/2, 1 - sqrt(-6 - 2*sqrt(-3 + 4*sqrt(3)))/2, 1 + sqrt(-6 - 2*sqrt(-3 + 4*sqrt(3)))/2] @XFAIL # There are an infinite number of solutions. def test_M8(): x = Symbol('x') z = symbols('z', complex=True) assert solveset(exp(2*x) + 2*exp(x) + 1 - z, x, S.Reals) == \ FiniteSet(log(1 + z - 2*sqrt(z))/2, log(1 + z + 2*sqrt(z))/2) # This one could be simplified better (the 1/2 could be pulled into the log # as a sqrt, and the function inside the log can be factored as a square, # giving [log(sqrt(z) - 1), log(sqrt(z) + 1)]). Also, there should be an # infinite number of solutions. # x = {log(sqrt(z) - 1), log(sqrt(z) + 1) + i pi} [+ n 2 pi i, + n 2 pi i] # where n is an arbitrary integer. See url of detailed output above. @XFAIL def test_M9(): x = symbols('x') raise NotImplementedError("solveset(exp(2-x**2)-exp(-x),x) has complex solutions.") def test_M10(): # TODO: Replace solve with solveset, as of now test fails for solveset assert solve(exp(x) - x, x) == [-LambertW(-1)] @XFAIL def test_M11(): assert solveset(x**x - x, x) == FiniteSet(-1, 1) def test_M12(): # TODO: x = [-1, 2*(+/-asinh(1)*I + n*pi}, 3*(pi/6 + n*pi/3)] # TODO: Replace solve with solveset, as of now test fails for solveset assert solve((x + 1)*(sin(x)**2 + 1)**2*cos(3*x)**3, x) == [ -1, pi/6, pi/2, - I*log(1 + sqrt(2)), I*log(1 + sqrt(2)), pi - I*log(1 + sqrt(2)), pi + I*log(1 + sqrt(2)), ] @XFAIL def test_M13(): n = Dummy('n') assert solveset_real(sin(x) - cos(x), x) == ImageSet(Lambda(n, n*pi - 7*pi/4), S.Integers) @XFAIL def test_M14(): n = Dummy('n') assert solveset_real(tan(x) - 1, x) == ImageSet(Lambda(n, n*pi + pi/4), S.Integers) def test_M15(): if PY3: n = Dummy('n') assert solveset(sin(x) - S.Half) in (Union(ImageSet(Lambda(n, 2*n*pi + pi/6), S.Integers), ImageSet(Lambda(n, 2*n*pi + 5*pi/6), S.Integers)), Union(ImageSet(Lambda(n, 2*n*pi + 5*pi/6), S.Integers), ImageSet(Lambda(n, 2*n*pi + pi/6), S.Integers))) @XFAIL def test_M16(): n = Dummy('n') assert solveset(sin(x) - tan(x), x) == ImageSet(Lambda(n, n*pi), S.Integers) @XFAIL def test_M17(): assert solveset_real(asin(x) - atan(x), x) == FiniteSet(0) @XFAIL def test_M18(): assert solveset_real(acos(x) - atan(x), x) == FiniteSet(sqrt((sqrt(5) - 1)/2)) def test_M19(): # TODO: Replace solve with solveset, as of now test fails for solveset assert solve((x - 2)/x**R(1, 3), x) == [2] def test_M20(): assert solveset(sqrt(x**2 + 1) - x + 2, x) == EmptySet() def test_M21(): assert solveset(x + sqrt(x) - 2) == FiniteSet(1) def test_M22(): assert solveset(2*sqrt(x) + 3*x**R(1, 4) - 2) == FiniteSet(R(1, 16)) def test_M23(): x = symbols('x', complex=True) # TODO: Replace solve with solveset, as of now test fails for solveset assert solve(x - 1/sqrt(1 + x**2)) == [ -I*sqrt(S.Half + sqrt(5)/2), sqrt(-S.Half + sqrt(5)/2)] def test_M24(): # TODO: Replace solve with solveset, as of now test fails for solveset solution = solve(1 - binomial(m, 2)*2**k, k) answer = log(2/(m*(m - 1)), 2) assert solution[0].expand() == answer.expand() def test_M25(): a, b, c, d = symbols(':d', positive=True) x = symbols('x') # TODO: Replace solve with solveset, as of now test fails for solveset assert solve(a*b**x - c*d**x, x)[0].expand() == (log(c/a)/log(b/d)).expand() def test_M26(): # TODO: Replace solve with solveset, as of now test fails for solveset assert solve(sqrt(log(x)) - log(sqrt(x))) == [1, exp(4)] @XFAIL def test_M27(): x = symbols('x', real=True) b = symbols('b', real=True) with assuming(Q.is_true(sin(cos(1/E**2) + 1) + b > 0)): # TODO: Replace solve with solveset solve(log(acos(asin(x**R(2, 3) - b) - 1)) + 2, x) == [-b - sin(1 + cos(1/e**2))**R(3/2), b + sin(1 + cos(1/e**2))**R(3/2)] @XFAIL def test_M28(): # TODO: Replace solve with solveset, as of now # solveset doesn't supports assumptions assert solve(5*x + exp((x - 5)/2) - 8*x**3, x, assume=Q.real(x)) == [-0.784966, -0.016291, 0.802557] def test_M29(): x = symbols('x') assert solveset(abs(x - 1) - 2, domain=S.Reals) == FiniteSet(-1, 3) def test_M30(): # TODO: Replace solve with solveset, as of now # solveset doesn't supports assumptions # assert solve(abs(2*x + 5) - abs(x - 2),x, assume=Q.real(x)) == [-1, -7] assert solveset_real(abs(2*x + 5) - abs(x - 2), x) == FiniteSet(-1, -7) def test_M31(): # TODO: Replace solve with solveset, as of now # solveset doesn't supports assumptions # assert solve(1 - abs(x) - max(-x - 2, x - 2),x, assume=Q.real(x)) == [-3/2, 3/2] assert solveset_real(1 - abs(x) - Max(-x - 2, x - 2), x) == FiniteSet(-S(3)/2, S(3)/2) @XFAIL def test_M32(): # TODO: Replace solve with solveset, as of now # solveset doesn't supports assumptions assert solveset_real(Max(2 - x**2, x)- Max(-x, (x**3)/9), x) == FiniteSet(-1, 3) @XFAIL def test_M33(): # TODO: Replace solve with solveset, as of now # solveset doesn't supports assumptions # Second answer can be written in another form. The second answer is the root of x**3 + 9*x**2 - 18 = 0 in the interval (-2, -1). assert solveset_real(Max(2 - x**2, x) - x**3/9, x) == FiniteSet(-3, -1.554894, 3) @XFAIL def test_M34(): z = symbols('z', complex=True) assert solveset((1 + I) * z + (2 - I) * conjugate(z) + 3*I, z) == FiniteSet(2 + 3*I) def test_M35(): x, y = symbols('x y', real=True) assert linsolve((3*x - 2*y - I*y + 3*I).as_real_imag(), y, x) == FiniteSet((3, 2)) def test_M36(): # TODO: Replace solve with solveset, as of now # solveset doesn't supports solving for function # assert solve(f**2 + f - 2, x) == [Eq(f(x), 1), Eq(f(x), -2)] assert solveset(f(x)**2 + f(x) - 2, f(x)) == FiniteSet(-2, 1) def test_M37(): assert linsolve([x + y + z - 6, 2*x + y + 2*z - 10, x + 3*y + z - 10 ], x, y, z) == \ FiniteSet((-z + 4, 2, z)) def test_M38(): variables = vring("k1:50", vfield("a,b,c", ZZ).to_domain()) system = [ -b*k8/a + c*k8/a, -b*k11/a + c*k11/a, -b*k10/a + c*k10/a + k2, -k3 - b*k9/a + c*k9/a, -b*k14/a + c*k14/a, -b*k15/a + c*k15/a, -b*k18/a + c*k18/a - k2, -b*k17/a + c*k17/a, -b*k16/a + c*k16/a + k4, -b*k13/a + c*k13/a - b*k21/a + c*k21/a + b*k5/a - c*k5/a, b*k44/a - c*k44/a, -b*k45/a + c*k45/a, -b*k20/a + c*k20/a, -b*k44/a + c*k44/a, b*k46/a - c*k46/a, b**2*k47/a**2 - 2*b*c*k47/a**2 + c**2*k47/a**2, k3, -k4, -b*k12/a + c*k12/a - a*k6/b + c*k6/b, -b*k19/a + c*k19/a + a*k7/c - b*k7/c, b*k45/a - c*k45/a, -b*k46/a + c*k46/a, -k48 + c*k48/a + c*k48/b - c**2*k48/(a*b), -k49 + b*k49/a + b*k49/c - b**2*k49/(a*c), a*k1/b - c*k1/b, a*k4/b - c*k4/b, a*k3/b - c*k3/b + k9, -k10 + a*k2/b - c*k2/b, a*k7/b - c*k7/b, -k9, k11, b*k12/a - c*k12/a + a*k6/b - c*k6/b, a*k15/b - c*k15/b, k10 + a*k18/b - c*k18/b, -k11 + a*k17/b - c*k17/b, a*k16/b - c*k16/b, -a*k13/b + c*k13/b + a*k21/b - c*k21/b + a*k5/b - c*k5/b, -a*k44/b + c*k44/b, a*k45/b - c*k45/b, a*k14/c - b*k14/c + a*k20/b - c*k20/b, a*k44/b - c*k44/b, -a*k46/b + c*k46/b, -k47 + c*k47/a + c*k47/b - c**2*k47/(a*b), a*k19/b - c*k19/b, -a*k45/b + c*k45/b, a*k46/b - c*k46/b, a**2*k48/b**2 - 2*a*c*k48/b**2 + c**2*k48/b**2, -k49 + a*k49/b + a*k49/c - a**2*k49/(b*c), k16, -k17, -a*k1/c + b*k1/c, -k16 - a*k4/c + b*k4/c, -a*k3/c + b*k3/c, k18 - a*k2/c + b*k2/c, b*k19/a - c*k19/a - a*k7/c + b*k7/c, -a*k6/c + b*k6/c, -a*k8/c + b*k8/c, -a*k11/c + b*k11/c + k17, -a*k10/c + b*k10/c - k18, -a*k9/c + b*k9/c, -a*k14/c + b*k14/c - a*k20/b + c*k20/b, -a*k13/c + b*k13/c + a*k21/c - b*k21/c - a*k5/c + b*k5/c, a*k44/c - b*k44/c, -a*k45/c + b*k45/c, -a*k44/c + b*k44/c, a*k46/c - b*k46/c, -k47 + b*k47/a + b*k47/c - b**2*k47/(a*c), -a*k12/c + b*k12/c, a*k45/c - b*k45/c, -a*k46/c + b*k46/c, -k48 + a*k48/b + a*k48/c - a**2*k48/(b*c), a**2*k49/c**2 - 2*a*b*k49/c**2 + b**2*k49/c**2, k8, k11, -k15, k10 - k18, -k17, k9, -k16, -k29, k14 - k32, -k21 + k23 - k31, -k24 - k30, -k35, k44, -k45, k36, k13 - k23 + k39, -k20 + k38, k25 + k37, b*k26/a - c*k26/a - k34 + k42, -2*k44, k45, k46, b*k47/a - c*k47/a, k41, k44, -k46, -b*k47/a + c*k47/a, k12 + k24, -k19 - k25, -a*k27/b + c*k27/b - k33, k45, -k46, -a*k48/b + c*k48/b, a*k28/c - b*k28/c + k40, -k45, k46, a*k48/b - c*k48/b, a*k49/c - b*k49/c, -a*k49/c + b*k49/c, -k1, -k4, -k3, k15, k18 - k2, k17, k16, k22, k25 - k7, k24 + k30, k21 + k23 - k31, k28, -k44, k45, -k30 - k6, k20 + k32, k27 + b*k33/a - c*k33/a, k44, -k46, -b*k47/a + c*k47/a, -k36, k31 - k39 - k5, -k32 - k38, k19 - k37, k26 - a*k34/b + c*k34/b - k42, k44, -2*k45, k46, a*k48/b - c*k48/b, a*k35/c - b*k35/c - k41, -k44, k46, b*k47/a - c*k47/a, -a*k49/c + b*k49/c, -k40, k45, -k46, -a*k48/b + c*k48/b, a*k49/c - b*k49/c, k1, k4, k3, -k8, -k11, -k10 + k2, -k9, k37 + k7, -k14 - k38, -k22, -k25 - k37, -k24 + k6, -k13 - k23 + k39, -k28 + b*k40/a - c*k40/a, k44, -k45, -k27, -k44, k46, b*k47/a - c*k47/a, k29, k32 + k38, k31 - k39 + k5, -k12 + k30, k35 - a*k41/b + c*k41/b, -k44, k45, -k26 + k34 + a*k42/c - b*k42/c, k44, k45, -2*k46, -b*k47/a + c*k47/a, -a*k48/b + c*k48/b, a*k49/c - b*k49/c, k33, -k45, k46, a*k48/b - c*k48/b, -a*k49/c + b*k49/c ] solution = { k49: 0, k48: 0, k47: 0, k46: 0, k45: 0, k44: 0, k41: 0, k40: 0, k38: 0, k37: 0, k36: 0, k35: 0, k33: 0, k32: 0, k30: 0, k29: 0, k28: 0, k27: 0, k25: 0, k24: 0, k22: 0, k21: 0, k20: 0, k19: 0, k18: 0, k17: 0, k16: 0, k15: 0, k14: 0, k13: 0, k12: 0, k11: 0, k10: 0, k9: 0, k8: 0, k7: 0, k6: 0, k5: 0, k4: 0, k3: 0, k2: 0, k1: 0, k34: b/c*k42, k31: k39, k26: a/c*k42, k23: k39 } assert solve_lin_sys(system, variables) == solution def test_M39(): x, y, z = symbols('x y z', complex=True) # TODO: Replace solve with solveset, as of now # solveset doesn't supports non-linear multivariate assert solve([x**2*y + 3*y*z - 4, -3*x**2*z + 2*y**2 + 1, 2*y*z**2 - z**2 - 1 ]) ==\ [{y: 1, z: 1, x: -1}, {y: 1, z: 1, x: 1},\ {y: sqrt(2)*I, z: R(1,3) - sqrt(2)*I/3, x: -sqrt(-1 - sqrt(2)*I)},\ {y: sqrt(2)*I, z: R(1,3) - sqrt(2)*I/3, x: sqrt(-1 - sqrt(2)*I)},\ {y: -sqrt(2)*I, z: R(1,3) + sqrt(2)*I/3, x: -sqrt(-1 + sqrt(2)*I)},\ {y: -sqrt(2)*I, z: R(1,3) + sqrt(2)*I/3, x: sqrt(-1 + sqrt(2)*I)}] # N. Inequalities def test_N1(): assert ask(Q.is_true(E**pi > pi**E)) @XFAIL def test_N2(): x = symbols('x', real=True) assert ask(Q.is_true(x**4 - x + 1 > 0)) is True assert ask(Q.is_true(x**4 - x + 1 > 1)) is False @XFAIL def test_N3(): x = symbols('x', real=True) assert ask(Q.is_true(And(Lt(-1, x), Lt(x, 1))), Q.is_true(abs(x) < 1 )) @XFAIL def test_N4(): x, y = symbols('x y', real=True) assert ask(Q.is_true(2*x**2 > 2*y**2), Q.is_true((x > y) & (y > 0))) is True @XFAIL def test_N5(): x, y, k = symbols('x y k', real=True) assert ask(Q.is_true(k*x**2 > k*y**2), Q.is_true((x > y) & (y > 0) & (k > 0))) is True @XFAIL def test_N6(): x, y, k, n = symbols('x y k n', real=True) assert ask(Q.is_true(k*x**n > k*y**n), Q.is_true((x > y) & (y > 0) & (k > 0) & (n > 0))) is True @XFAIL def test_N7(): x, y = symbols('x y', real=True) assert ask(Q.is_true(y > 0), Q.is_true((x > 1) & (y >= x - 1))) is True @XFAIL def test_N8(): x, y, z = symbols('x y z', real=True) assert ask(Q.is_true((x == y) & (y == z)), Q.is_true((x >= y) & (y >= z) & (z >= x))) def test_N9(): x = Symbol('x') assert solveset(abs(x - 1) > 2, domain=S.Reals) == Union(Interval(-oo, -1, False, True), Interval(3, oo, True)) def test_N10(): x = Symbol('x') p = (x - 1)*(x - 2)*(x - 3)*(x - 4)*(x - 5) assert solveset(expand(p) < 0, domain=S.Reals) == Union(Interval(-oo, 1, True, True), Interval(2, 3, True, True), Interval(4, 5, True, True)) def test_N11(): x = Symbol('x') assert solveset(6/(x - 3) <= 3, domain=S.Reals) == Union(Interval(-oo, 3, True, True), Interval(5, oo)) def test_N12(): x = Symbol('x') assert solveset(sqrt(x) < 2, domain=S.Reals) == Interval(0, 4, False, True) def test_N13(): x = Symbol('x') assert solveset(sin(x) < 2, domain=S.Reals) == S.Reals @XFAIL def test_N14(): x = Symbol('x') # Gives 'Union(Interval(Integer(0), Mul(Rational(1, 2), pi), false, true), # Interval(Mul(Rational(1, 2), pi), Mul(Integer(2), pi), true, false))' # which is not the correct answer, but the provided also seems wrong. assert solveset(sin(x) < 1, x, domain=S.Reals) == Union(Interval(-oo, pi/2, True, True), Interval(pi/2, oo, True, True)) def test_N15(): r, t = symbols('r t') # raises NotImplementedError: only univariate inequalities are supported solveset(abs(2*r*(cos(t) - 1) + 1) <= 1, r, S.Reals) def test_N16(): r, t = symbols('r t') solveset((r**2)*((cos(t) - 4)**2)*sin(t)**2 < 9, r, S.Reals) @XFAIL def test_N17(): # currently only univariate inequalities are supported assert solveset((x + y > 0, x - y < 0), (x, y)) == (abs(x) < y) def test_O1(): M = Matrix((1 + I, -2, 3*I)) assert sqrt(expand(M.dot(M.H))) == sqrt(15) def test_O2(): assert Matrix((2, 2, -3)).cross(Matrix((1, 3, 1))) == Matrix([[11], [-5], [4]]) # The vector module has no way of representing vectors symbolically (without # respect to a basis) @XFAIL def test_O3(): assert (va ^ vb) | (vc ^ vd) == -(va | vc)*(vb | vd) + (va | vd)*(vb | vc) def test_O4(): from sympy.vector import CoordSys3D, Del N = CoordSys3D("N") delop = Del() i, j, k = N.base_vectors() x, y, z = N.base_scalars() F = i*(x*y*z) + j*((x*y*z)**2) + k*((y**2)*(z**3)) assert delop.cross(F).doit() == (-2*x**2*y**2*z + 2*y*z**3)*i + x*y*j + (2*x*y**2*z**2 - x*z)*k # The vector module has no way of representing vectors symbolically (without # respect to a basis) @XFAIL def test_O5(): assert grad|(f^g)-g|(grad^f)+f|(grad^g) == 0 #testO8-O9 MISSING!! def test_O10(): L = [Matrix([2, 3, 5]), Matrix([3, 6, 2]), Matrix([8, 3, 6])] assert GramSchmidt(L) == [Matrix([ [2], [3], [5]]), Matrix([ [S(23)/19], [S(63)/19], [S(-47)/19]]), Matrix([ [S(1692)/353], [S(-1551)/706], [S(-423)/706]])] def test_P1(): assert Matrix(3, 3, lambda i, j: j - i).diagonal(-1) == Matrix( 1, 2, [-1, -1]) def test_P2(): M = Matrix([[1, 2, 3], [4, 5, 6], [7, 8, 9]]) M.row_del(1) M.col_del(2) assert M == Matrix([[1, 2], [7, 8]]) def test_P3(): A = Matrix([ [11, 12, 13, 14], [21, 22, 23, 24], [31, 32, 33, 34], [41, 42, 43, 44]]) A11 = A[0:3, 1:4] A12 = A[(0, 1, 3), (2, 0, 3)] A21 = A A221 = -A[0:2, 2:4] A222 = -A[(3, 0), (2, 1)] A22 = BlockMatrix([[A221, A222]]).T rows = [[-A11, A12], [A21, A22]] from sympy.utilities.pytest import raises raises(ValueError, lambda: BlockMatrix(rows)) B = Matrix(rows) assert B == Matrix([ [-12, -13, -14, 13, 11, 14], [-22, -23, -24, 23, 21, 24], [-32, -33, -34, 43, 41, 44], [11, 12, 13, 14, -13, -23], [21, 22, 23, 24, -14, -24], [31, 32, 33, 34, -43, -13], [41, 42, 43, 44, -42, -12]]) @XFAIL def test_P4(): raise NotImplementedError("Block matrix diagonalization not supported") def test_P5(): M = Matrix([[7, 11], [3, 8]]) assert M % 2 == Matrix([[1, 1], [1, 0]]) def test_P6(): M = Matrix([[cos(x), sin(x)], [-sin(x), cos(x)]]) assert M.diff(x, 2) == Matrix([[-cos(x), -sin(x)], [sin(x), -cos(x)]]) def test_P7(): M = Matrix([[x, y]])*( z*Matrix([[1, 3, 5], [2, 4, 6]]) + Matrix([[7, -9, 11], [-8, 10, -12]])) assert M == Matrix([[x*(z + 7) + y*(2*z - 8), x*(3*z - 9) + y*(4*z + 10), x*(5*z + 11) + y*(6*z - 12)]]) def test_P8(): M = Matrix([[1, -2*I], [-3*I, 4]]) assert M.norm(ord=S.Infinity) == 7 def test_P9(): a, b, c = symbols('a b c', real=True) M = Matrix([[a/(b*c), 1/c, 1/b], [1/c, b/(a*c), 1/a], [1/b, 1/a, c/(a*b)]]) assert factor(M.norm('fro')) == (a**2 + b**2 + c**2)/(abs(a)*abs(b)*abs(c)) @XFAIL def test_P10(): M = Matrix([[1, 2 + 3*I], [f(4 - 5*I), 6]]) # conjugate(f(4 - 5*i)) is not simplified to f(4+5*I) assert M.H == Matrix([[1, f(4 + 5*I)], [2 + 3*I, 6]]) @XFAIL def test_P11(): # raises NotImplementedError("Matrix([[x,y],[1,x*y]]).inv() # not simplifying to extract common factor") assert Matrix([[x, y], [1, x*y]]).inv() == (1/(x**2 - 1))*Matrix([[x, -1], [-1/y, x/y]]) def test_P11_workaround(): M = Matrix([[x, y], [1, x*y]]).inv() c = gcd(tuple(M)) assert MatMul(c, M/c, evaluate=False) == MatMul(c, Matrix([ [-x*y, y], [ 1, -x]]), evaluate=False) def test_P12(): A11 = MatrixSymbol('A11', n, n) A12 = MatrixSymbol('A12', n, n) A22 = MatrixSymbol('A22', n, n) B = BlockMatrix([[A11, A12], [ZeroMatrix(n, n), A22]]) assert block_collapse(B.I) == BlockMatrix([[A11.I, (-1)*A11.I*A12*A22.I], [ZeroMatrix(n, n), A22.I]]) def test_P13(): M = Matrix([[1, x - 2, x - 3], [x - 1, x**2 - 3*x + 6, x**2 - 3*x - 2], [x - 2, x**2 - 8, 2*(x**2) - 12*x + 14]]) L, U, _ = M.LUdecomposition() assert simplify(L) == Matrix([[1, 0, 0], [x - 1, 1, 0], [x - 2, x - 3, 1]]) assert simplify(U) == Matrix([[1, x - 2, x - 3], [0, 4, x - 5], [0, 0, x - 7]]) def test_P14(): M = Matrix([[1, 2, 3, 1, 3], [3, 2, 1, 1, 7], [0, 2, 4, 1, 1], [1, 1, 1, 1, 4]]) R, _ = M.rref() assert R == Matrix([[1, 0, -1, 0, 2], [0, 1, 2, 0, -1], [0, 0, 0, 1, 3], [0, 0, 0, 0, 0]]) def test_P15(): M = Matrix([[-1, 3, 7, -5], [4, -2, 1, 3], [2, 4, 15, -7]]) assert M.rank() == 2 def test_P16(): M = Matrix([[2*sqrt(2), 8], [6*sqrt(6), 24*sqrt(3)]]) assert M.rank() == 1 def test_P17(): t = symbols('t', real=True) M=Matrix([ [sin(2*t), cos(2*t)], [2*(1 - (cos(t)**2))*cos(t), (1 - 2*(sin(t)**2))*sin(t)]]) assert M.rank() == 1 def test_P18(): M = Matrix([[1, 0, -2, 0], [-2, 1, 0, 3], [-1, 2, -6, 6]]) assert M.nullspace() == [Matrix([[2], [4], [1], [0]]), Matrix([[0], [-3], [0], [1]])] def test_P19(): w = symbols('w') M = Matrix([[1, 1, 1, 1], [w, x, y, z], [w**2, x**2, y**2, z**2], [w**3, x**3, y**3, z**3]]) assert M.det() == (w**3*x**2*y - w**3*x**2*z - w**3*x*y**2 + w**3*x*z**2 + w**3*y**2*z - w**3*y*z**2 - w**2*x**3*y + w**2*x**3*z + w**2*x*y**3 - w**2*x*z**3 - w**2*y**3*z + w**2*y*z**3 + w*x**3*y**2 - w*x**3*z**2 - w*x**2*y**3 + w*x**2*z**3 + w*y**3*z**2 - w*y**2*z**3 - x**3*y**2*z + x**3*y*z**2 + x**2*y**3*z - x**2*y*z**3 - x*y**3*z**2 + x*y**2*z**3 ) @XFAIL def test_P20(): raise NotImplementedError("Matrix minimal polynomial not supported") def test_P21(): M = Matrix([[5, -3, -7], [-2, 1, 2], [2, -3, -4]]) assert M.charpoly(x).as_expr() == x**3 - 2*x**2 - 5*x + 6 def test_P22(): d = 100 M = (2 - x)*eye(d) assert M.eigenvals() == {-x + 2: d} def test_P23(): M = Matrix([ [2, 1, 0, 0, 0], [1, 2, 1, 0, 0], [0, 1, 2, 1, 0], [0, 0, 1, 2, 1], [0, 0, 0, 1, 2]]) assert M.eigenvals() == { S('1'): 1, S('2'): 1, S('3'): 1, S('sqrt(3) + 2'): 1, S('-sqrt(3) + 2'): 1} def test_P24(): M = Matrix([[611, 196, -192, 407, -8, -52, -49, 29], [196, 899, 113, -192, -71, -43, -8, -44], [-192, 113, 899, 196, 61, 49, 8, 52], [ 407, -192, 196, 611, 8, 44, 59, -23], [ -8, -71, 61, 8, 411, -599, 208, 208], [ -52, -43, 49, 44, -599, 411, 208, 208], [ -49, -8, 8, 59, 208, 208, 99, -911], [ 29, -44, 52, -23, 208, 208, -911, 99]]) assert M.eigenvals() == { S('0'): 1, S('10*sqrt(10405)'): 1, S('100*sqrt(26) + 510'): 1, S('1000'): 2, S('-100*sqrt(26) + 510'): 1, S('-10*sqrt(10405)'): 1, S('1020'): 1} def test_P25(): MF = N(Matrix([[ 611, 196, -192, 407, -8, -52, -49, 29], [ 196, 899, 113, -192, -71, -43, -8, -44], [-192, 113, 899, 196, 61, 49, 8, 52], [ 407, -192, 196, 611, 8, 44, 59, -23], [ -8, -71, 61, 8, 411, -599, 208, 208], [ -52, -43, 49, 44, -599, 411, 208, 208], [ -49, -8, 8, 59, 208, 208, 99, -911], [ 29, -44, 52, -23, 208, 208, -911, 99]])) assert (Matrix(sorted(MF.eigenvals())) - Matrix( [-1020.0490184299969, 0.0, 0.09804864072151699, 1000.0, 1019.9019513592784, 1020.0, 1020.0490184299969])).norm() < 1e-13 def test_P26(): a0, a1, a2, a3, a4 = symbols('a0 a1 a2 a3 a4') M = Matrix([[-a4, -a3, -a2, -a1, -a0, 0, 0, 0, 0], [ 1, 0, 0, 0, 0, 0, 0, 0, 0], [ 0, 1, 0, 0, 0, 0, 0, 0, 0], [ 0, 0, 1, 0, 0, 0, 0, 0, 0], [ 0, 0, 0, 1, 0, 0, 0, 0, 0], [ 0, 0, 0, 0, 0, -1, -1, 0, 0], [ 0, 0, 0, 0, 0, 1, 0, 0, 0], [ 0, 0, 0, 0, 0, 0, 1, -1, -1], [ 0, 0, 0, 0, 0, 0, 0, 1, 0]]) assert M.eigenvals(error_when_incomplete=False) == { S('-1/2 - sqrt(3)*I/2'): 2, S('-1/2 + sqrt(3)*I/2'): 2} def test_P27(): a = symbols('a') M = Matrix([[a, 0, 0, 0, 0], [0, 0, 0, 0, 1], [0, 0, a, 0, 0], [0, 0, 0, a, 0], [0, -2, 0, 0, 2]]) assert M.eigenvects() == [(a, 3, [Matrix([[1], [0], [0], [0], [0]]), Matrix([[0], [0], [1], [0], [0]]), Matrix([[0], [0], [0], [1], [0]])]), (1 - I, 1, [Matrix([[ 0], [-1/(-1 + I)], [ 0], [ 0], [ 1]])]), (1 + I, 1, [Matrix([[ 0], [-1/(-1 - I)], [ 0], [ 0], [ 1]])])] @XFAIL def test_P28(): raise NotImplementedError("Generalized eigenvectors not supported \ https://github.com/sympy/sympy/issues/5293") @XFAIL def test_P29(): raise NotImplementedError("Generalized eigenvectors not supported \ https://github.com/sympy/sympy/issues/5293") def test_P30(): M = Matrix([[1, 0, 0, 1, -1], [0, 1, -2, 3, -3], [0, 0, -1, 2, -2], [1, -1, 1, 0, 1], [1, -1, 1, -1, 2]]) _, J = M.jordan_form() assert J == Matrix([[-1, 0, 0, 0, 0], [0, 1, 1, 0, 0], [0, 0, 1, 0, 0], [0, 0, 0, 1, 1], [0, 0, 0, 0, 1]]) @XFAIL def test_P31(): raise NotImplementedError("Smith normal form not implemented") def test_P32(): M = Matrix([[1, -2], [2, 1]]) assert exp(M).rewrite(cos).simplify() == Matrix([[E*cos(2), -E*sin(2)], [E*sin(2), E*cos(2)]]) def test_P33(): w, t = symbols('w t') M = Matrix([[0, 1, 0, 0], [0, 0, 0, 2*w], [0, 0, 0, 1], [0, -2*w, 3*w**2, 0]]) assert exp(M*t).rewrite(cos).expand() == Matrix([ [1, -3*t + 4*sin(t*w)/w, 6*t*w - 6*sin(t*w), -2*cos(t*w)/w + 2/w], [0, 4*cos(t*w) - 3, -6*w*cos(t*w) + 6*w, 2*sin(t*w)], [0, 2*cos(t*w)/w - 2/w, -3*cos(t*w) + 4, sin(t*w)/w], [0, -2*sin(t*w), 3*w*sin(t*w), cos(t*w)]]) @XFAIL def test_P34(): a, b, c = symbols('a b c', real=True) M = Matrix([[a, 1, 0, 0, 0, 0], [0, a, 0, 0, 0, 0], [0, 0, b, 0, 0, 0], [0, 0, 0, c, 1, 0], [0, 0, 0, 0, c, 1], [0, 0, 0, 0, 0, c]]) # raises exception, sin(M) not supported. exp(M*I) also not supported # https://github.com/sympy/sympy/issues/6218 assert sin(M) == Matrix([[sin(a), cos(a), 0, 0, 0, 0], [0, sin(a), 0, 0, 0, 0], [0, 0, sin(b), 0, 0, 0], [0, 0, 0, sin(c), cos(c), -sin(c)/2], [0, 0, 0, 0, sin(c), cos(c)], [0, 0, 0, 0, 0, sin(c)]]) @XFAIL def test_P35(): M = pi/2*Matrix([[2, 1, 1], [2, 3, 2], [1, 1, 2]]) # raises exception, sin(M) not supported. exp(M*I) also not supported # https://github.com/sympy/sympy/issues/6218 assert sin(M) == eye(3) @XFAIL def test_P36(): M = Matrix([[10, 7], [7, 17]]) assert sqrt(M) == Matrix([[3, 1], [1, 4]]) def test_P37(): M = Matrix([[1, 1, 0], [0, 1, 0], [0, 0, 1]]) assert M**Rational(1, 2) == Matrix([[1, R(1, 2), 0], [0, 1, 0], [0, 0, 1]]) @XFAIL def test_P38(): M=Matrix([[0, 1, 0], [0, 0, 0], [0, 0, 0]]) #raises ValueError: Matrix det == 0; not invertible M**Rational(1,2) @XFAIL def test_P39(): """ M=Matrix([ [1, 1], [2, 2], [3, 3]]) M.SVD() """ raise NotImplementedError("Singular value decomposition not implemented") def test_P40(): r, t = symbols('r t', real=True) M = Matrix([r*cos(t), r*sin(t)]) assert M.jacobian(Matrix([r, t])) == Matrix([[cos(t), -r*sin(t)], [sin(t), r*cos(t)]]) def test_P41(): r, t = symbols('r t', real=True) assert hessian(r**2*sin(t),(r,t)) == Matrix([[ 2*sin(t), 2*r*cos(t)], [2*r*cos(t), -r**2*sin(t)]]) def test_P42(): assert wronskian([cos(x), sin(x)], x).simplify() == 1 def test_P43(): def __my_jacobian(M, Y): return Matrix([M.diff(v).T for v in Y]).T r, t = symbols('r t', real=True) M = Matrix([r*cos(t), r*sin(t)]) assert __my_jacobian(M,[r,t]) == Matrix([[cos(t), -r*sin(t)], [sin(t), r*cos(t)]]) def test_P44(): def __my_hessian(f, Y): V = Matrix([diff(f, v) for v in Y]) return Matrix([V.T.diff(v) for v in Y]) r, t = symbols('r t', real=True) assert __my_hessian(r**2*sin(t), (r, t)) == Matrix([ [ 2*sin(t), 2*r*cos(t)], [2*r*cos(t), -r**2*sin(t)]]) def test_P45(): def __my_wronskian(Y, v): M = Matrix([Matrix(Y).T.diff(x, n) for n in range(0, len(Y))]) return M.det() assert __my_wronskian([cos(x), sin(x)], x).simplify() == 1 # Q1-Q6 Tensor tests missing @XFAIL def test_R1(): i, j, n = symbols('i j n', integer=True, positive=True) xn = MatrixSymbol('xn', n, 1) Sm = Sum((xn[i, 0] - Sum(xn[j, 0], (j, 0, n - 1))/n)**2, (i, 0, n - 1)) # sum does not calculate # Unknown result Sm.doit() raise NotImplementedError('Unknown result') @XFAIL def test_R2(): m, b = symbols('m b') i, n = symbols('i n', integer=True, positive=True) xn = MatrixSymbol('xn', n, 1) yn = MatrixSymbol('yn', n, 1) f = Sum((yn[i, 0] - m*xn[i, 0] - b)**2, (i, 0, n - 1)) f1 = diff(f, m) f2 = diff(f, b) # raises TypeError: solveset() takes at most 2 arguments (3 given) solveset((f1, f2), (m, b), domain=S.Reals) @XFAIL def test_R3(): n, k = symbols('n k', integer=True, positive=True) sk = ((-1)**k) * (binomial(2*n, k))**2 Sm = Sum(sk, (k, 1, oo)) T = Sm.doit() T2 = T.combsimp() # returns -((-1)**n*factorial(2*n) # - (factorial(n))**2)*exp_polar(-I*pi)/(factorial(n))**2 assert T2 == (-1)**n*binomial(2*n, n) @XFAIL def test_R4(): # Macsyma indefinite sum test case: #(c15) /* Check whether the full Gosper algorithm is implemented # => 1/2^(n + 1) binomial(n, k - 1) */ #closedform(indefsum(binomial(n, k)/2^n - binomial(n + 1, k)/2^(n + 1), k)); #Time= 2690 msecs # (- n + k - 1) binomial(n + 1, k) #(d15) - -------------------------------- # n # 2 2 (n + 1) # #(c16) factcomb(makefact(%)); #Time= 220 msecs # n! #(d16) ---------------- # n # 2 k! 2 (n - k)! # Might be possible after fixing https://github.com/sympy/sympy/pull/1879 raise NotImplementedError("Indefinite sum not supported") @XFAIL def test_R5(): a, b, c, n, k = symbols('a b c n k', integer=True, positive=True) sk = ((-1)**k)*(binomial(a + b, a + k) *binomial(b + c, b + k)*binomial(c + a, c + k)) Sm = Sum(sk, (k, 1, oo)) T = Sm.doit() # hypergeometric series not calculated assert T == factorial(a+b+c)/(factorial(a)*factorial(b)*factorial(c)) def test_R6(): n, k = symbols('n k', integer=True, positive=True) gn = MatrixSymbol('gn', n + 2, 1) Sm = Sum(gn[k, 0] - gn[k - 1, 0], (k, 1, n + 1)) assert Sm.doit() == -gn[0, 0] + gn[n + 1, 0] def test_R7(): n, k = symbols('n k', integer=True, positive=True) T = Sum(k**3,(k,1,n)).doit() assert T.factor() == n**2*(n + 1)**2/4 @XFAIL def test_R8(): n, k = symbols('n k', integer=True, positive=True) Sm = Sum(k**2*binomial(n, k), (k, 1, n)) T = Sm.doit() #returns Piecewise function assert T.combsimp() == n*(n + 1)*2**(n - 2) def test_R9(): n, k = symbols('n k', integer=True, positive=True) Sm = Sum(binomial(n, k - 1)/k, (k, 1, n + 1)) assert Sm.doit().simplify() == (2**(n + 1) - 1)/(n + 1) @XFAIL def test_R10(): n, m, r, k = symbols('n m r k', integer=True, positive=True) Sm = Sum(binomial(n, k)*binomial(m, r - k), (k, 0, r)) T = Sm.doit() T2 = T.combsimp().rewrite(factorial) assert T2 == factorial(m + n)/(factorial(r)*factorial(m + n - r)) assert T2 == binomial(m + n, r).rewrite(factorial) # rewrite(binomial) is not working. # https://github.com/sympy/sympy/issues/7135 T3 = T2.rewrite(binomial) assert T3 == binomial(m + n, r) @XFAIL def test_R11(): n, k = symbols('n k', integer=True, positive=True) sk = binomial(n, k)*fibonacci(k) Sm = Sum(sk, (k, 0, n)) T = Sm.doit() # Fibonacci simplification not implemented # https://github.com/sympy/sympy/issues/7134 assert T == fibonacci(2*n) @XFAIL def test_R12(): n, k = symbols('n k', integer=True, positive=True) Sm = Sum(fibonacci(k)**2, (k, 0, n)) T = Sm.doit() assert T == fibonacci(n)*fibonacci(n + 1) @XFAIL def test_R13(): n, k = symbols('n k', integer=True, positive=True) Sm = Sum(sin(k*x), (k, 1, n)) T = Sm.doit() # Sum is not calculated assert T.simplify() == cot(x/2)/2 - cos(x*(2*n + 1)/2)/(2*sin(x/2)) @XFAIL def test_R14(): n, k = symbols('n k', integer=True, positive=True) Sm = Sum(sin((2*k - 1)*x), (k, 1, n)) T = Sm.doit() # Sum is not calculated assert T.simplify() == sin(n*x)**2/sin(x) @XFAIL def test_R15(): n, k = symbols('n k', integer=True, positive=True) Sm = Sum(binomial(n - k, k), (k, 0, floor(n/2))) T = Sm.doit() # Sum is not calculated assert T.simplify() == fibonacci(n + 1) def test_R16(): k = symbols('k', integer=True, positive=True) Sm = Sum(1/k**2 + 1/k**3, (k, 1, oo)) assert Sm.doit() == zeta(3) + pi**2/6 def test_R17(): k = symbols('k', integer=True, positive=True) assert abs(float(Sum(1/k**2 + 1/k**3, (k, 1, oo))) - 2.8469909700078206) < 1e-15 def test_R18(): k = symbols('k', integer=True, positive=True) Sm = Sum(1/(2**k*k**2), (k, 1, oo)) T = Sm.doit() assert T.simplify() == -log(2)**2/2 + pi**2/12 @slow @XFAIL def test_R19(): k = symbols('k', integer=True, positive=True) Sm = Sum(1/((3*k + 1)*(3*k + 2)*(3*k + 3)), (k, 0, oo)) T = Sm.doit() # assert fails, T not simplified assert T.simplify() == -log(3)/4 + sqrt(3)*pi/12 @XFAIL def test_R20(): n, k = symbols('n k', integer=True, positive=True) Sm = Sum(binomial(n, 4*k), (k, 0, oo)) T = Sm.doit() # assert fails, T not simplified assert T.simplify() == 2**(n/2)*cos(pi*n/4)/2 + 2**(n - 1)/2 @XFAIL def test_R21(): k = symbols('k', integer=True, positive=True) Sm = Sum(1/(sqrt(k*(k + 1)) * (sqrt(k) + sqrt(k + 1))), (k, 1, oo)) T = Sm.doit() # Sum not calculated assert T.simplify() == 1 # test_R22 answer not available in Wester samples # Sum(Sum(binomial(n, k)*binomial(n - k, n - 2*k)*x**n*y**(n - 2*k), # (k, 0, floor(n/2))), (n, 0, oo)) with abs(x*y)<1? @XFAIL def test_R23(): n, k = symbols('n k', integer=True, positive=True) Sm = Sum(Sum((factorial(n)/(factorial(k)**2*factorial(n - 2*k)))* (x/y)**k*(x*y)**(n - k), (n, 2*k, oo)), (k, 0, oo)) # Missing how to express constraint abs(x*y)<1? T = Sm.doit() # Sum not calculated assert T == -1/sqrt(x**2*y**2 - 4*x**2 - 2*x*y + 1) def test_R24(): m, k = symbols('m k', integer=True, positive=True) Sm = Sum(Product(k/(2*k - 1), (k, 1, m)), (m, 2, oo)) assert Sm.doit() == pi/2 def test_S1(): k = symbols('k', integer=True, positive=True) Pr = Product(gamma(k/3), (k, 1, 8)) assert Pr.doit().simplify() == 640*sqrt(3)*pi**3/6561 def test_S2(): n, k = symbols('n k', integer=True, positive=True) assert Product(k, (k, 1, n)).doit() == factorial(n) def test_S3(): n, k = symbols('n k', integer=True, positive=True) assert Product(x**k, (k, 1, n)).doit().simplify() == x**(n*(n + 1)/2) def test_S4(): n, k = symbols('n k', integer=True, positive=True) assert Product(1 + 1/k, (k, 1, n -1)).doit().simplify() == n def test_S5(): n, k = symbols('n k', integer=True, positive=True) assert (Product((2*k - 1)/(2*k), (k, 1, n)).doit().gammasimp() == gamma(n + Rational(1, 2))/(sqrt(pi)*gamma(n + 1))) @XFAIL def test_S6(): n, k = symbols('n k', integer=True, positive=True) # Product does not evaluate assert (Product(x**2 -2*x*cos(k*pi/n) + 1, (k, 1, n - 1)).doit().simplify() == (x**(2*n) - 1)/(x**2 - 1)) @XFAIL def test_S7(): k = symbols('k', integer=True, positive=True) Pr = Product((k**3 - 1)/(k**3 + 1), (k, 2, oo)) T = Pr.doit() # Product does not evaluate assert T.simplify() == Rational(2, 3) @XFAIL def test_S8(): k = symbols('k', integer=True, positive=True) Pr = Product(1 - 1/(2*k)**2, (k, 1, oo)) T = Pr.doit() # Product does not evaluate assert T.simplify() == 2/pi @XFAIL def test_S9(): k = symbols('k', integer=True, positive=True) Pr = Product(1 + (-1)**(k + 1)/(2*k - 1), (k, 1, oo)) T = Pr.doit() # Product produces 0 # https://github.com/sympy/sympy/issues/7133 assert T.simplify() == sqrt(2) @XFAIL def test_S10(): k = symbols('k', integer=True, positive=True) Pr = Product((k*(k + 1) + 1 + I)/(k*(k + 1) + 1 - I), (k, 0, oo)) T = Pr.doit() # Product does not evaluate assert T.simplify() == -1 def test_T1(): assert limit((1 + 1/n)**n, n, oo) == E assert limit((1 - cos(x))/x**2, x, 0) == Rational(1, 2) def test_T2(): assert limit((3**x + 5**x)**(1/x), x, oo) == 5 def test_T3(): assert limit(log(x)/(log(x) + sin(x)), x, oo) == 1 def test_T4(): assert limit((exp(x*exp(-x)/(exp(-x) + exp(-2*x**2/(x + 1)))) - exp(x))/x, x, oo) == -exp(2) def test_T5(): assert limit(x*log(x)*log(x*exp(x) - x**2)**2/log(log(x**2 + 2*exp(exp(3*x**3*log(x))))), x, oo) == Rational(1, 3) def test_T6(): assert limit(1/n * factorial(n)**(1/n), n, oo) == exp(-1) def test_T7(): limit(1/n * gamma(n + 1)**(1/n), n, oo) def test_T8(): a, z = symbols('a z', real=True, positive=True) assert limit(gamma(z + a)/gamma(z)*exp(-a*log(z)), z, oo) == 1 @XFAIL def test_T9(): z, k = symbols('z k', real=True, positive=True) # raises NotImplementedError: # Don't know how to calculate the mrv of '(1, k)' assert limit(hyper((1, k), (1,), z/k), k, oo) == exp(z) @XFAIL def test_T10(): # No longer raises PoleError, but should return euler-mascheroni constant assert limit(zeta(x) - 1/(x - 1), x, 1) == integrate(-1/x + 1/floor(x), (x, 1, oo)) @XFAIL def test_T11(): n, k = symbols('n k', integer=True, positive=True) # evaluates to 0 assert limit(n**x/(x*product((1 + x/k), (k, 1, n))), n, oo) == gamma(x) @XFAIL def test_T12(): x, t = symbols('x t', real=True) # Does not evaluate the limit but returns an expression with erf assert limit(x * integrate(exp(-t**2), (t, 0, x))/(1 - exp(-x**2)), x, 0) == 1 def test_T13(): x = symbols('x', real=True) assert [limit(x/abs(x), x, 0, dir='-'), limit(x/abs(x), x, 0, dir='+')] == [-1, 1] def test_T14(): x = symbols('x', real=True) assert limit(atan(-log(x)), x, 0, dir='+') == pi/2 def test_U1(): x = symbols('x', real=True) assert diff(abs(x), x) == sign(x) def test_U2(): f = Lambda(x, Piecewise((-x, x < 0), (x, x >= 0))) assert diff(f(x), x) == Piecewise((-1, x < 0), (1, x >= 0)) def test_U3(): f = Lambda(x, Piecewise((x**2 - 1, x == 1), (x**3, x != 1))) f1 = Lambda(x, diff(f(x), x)) assert f1(x) == 3*x**2 assert f1(1) == 3 @XFAIL def test_U4(): n = symbols('n', integer=True, positive=True) x = symbols('x', real=True) d = diff(x**n, x, n) assert d.rewrite(factorial) == factorial(n) def test_U5(): # issue 6681 t = symbols('t') ans = ( Derivative(f(g(t)), g(t))*Derivative(g(t), (t, 2)) + Derivative(f(g(t)), (g(t), 2))*Derivative(g(t), t)**2) assert f(g(t)).diff(t, 2) == ans assert ans.doit() == ans def test_U6(): h = Function('h') T = integrate(f(y), (y, h(x), g(x))) assert T.diff(x) == ( f(g(x))*Derivative(g(x), x) - f(h(x))*Derivative(h(x), x)) @XFAIL def test_U7(): p, t = symbols('p t', real=True) # Exact differential => d(V(P, T)) => dV/dP DP + dV/dT DT # raises ValueError: Since there is more than one variable in the # expression, the variable(s) of differentiation must be supplied to # differentiate f(p,t) diff(f(p, t)) def test_U8(): x, y = symbols('x y', real=True) eq = cos(x*y) + x # If SymPy had implicit_diff() function this hack could be avoided # TODO: Replace solve with solveset, current test fails for solveset assert idiff(y - eq, y, x) == (-y*sin(x*y) + 1)/(x*sin(x*y) + 1) def test_U9(): # Wester sample case for Maple: # O29 := diff(f(x, y), x) + diff(f(x, y), y); # /d \ /d \ # |-- f(x, y)| + |-- f(x, y)| # \dx / \dy / # # O30 := factor(subs(f(x, y) = g(x^2 + y^2), %)); # 2 2 # 2 D(g)(x + y ) (x + y) x, y = symbols('x y', real=True) su = diff(f(x, y), x) + diff(f(x, y), y) s2 = su.subs(f(x, y), g(x**2 + y**2)) s3 = s2.doit().factor() # Subs not performed, s3 = 2*(x + y)*Subs(Derivative( # g(_xi_1), _xi_1), _xi_1, x**2 + y**2) # Derivative(g(x*2 + y**2), x**2 + y**2) is not valid in SymPy, # and probably will remain that way. You can take derivatives with respect # to other expressions only if they are atomic, like a symbol or a # function. # D operator should be added to SymPy # See https://github.com/sympy/sympy/issues/4719. assert s3 == (x + y)*Subs(Derivative(g(x), x), x, x**2 + y**2)*2 def test_U10(): # see issue 2519: assert residue((z**3 + 5)/((z**4 - 1)*(z + 1)), z, -1) == Rational(-9, 4) @XFAIL def test_U11(): assert (2*dx + dz) ^ (3*dx + dy + dz) ^ (dx + dy + 4*dz) == 8*dx ^ dy ^dz @XFAIL def test_U12(): # Wester sample case: # (c41) /* d(3 x^5 dy /\ dz + 5 x y^2 dz /\ dx + 8 z dx /\ dy) # => (15 x^4 + 10 x y + 8) dx /\ dy /\ dz */ # factor(ext_diff(3*x^5 * dy ~ dz + 5*x*y^2 * dz ~ dx + 8*z * dx ~ dy)); # 4 # (d41) (10 x y + 15 x + 8) dx dy dz raise NotImplementedError( "External diff of differential form not supported") @XFAIL def test_U13(): #assert minimize(x**4 - x + 1, x)== -3*2**Rational(1,3)/8 + 1 raise NotImplementedError("minimize() not supported") @XFAIL def test_U14(): #f = 1/(x**2 + y**2 + 1) #assert [minimize(f), maximize(f)] == [0,1] raise NotImplementedError("minimize(), maximize() not supported") @XFAIL def test_U15(): raise NotImplementedError("minimize() not supported and also solve does \ not support multivariate inequalities") @XFAIL def test_U16(): raise NotImplementedError("minimize() not supported in SymPy and also \ solve does not support multivariate inequalities") @XFAIL def test_U17(): raise NotImplementedError("Linear programming, symbolic simplex not \ supported in SymPy") def test_V1(): x = symbols('x', real=True) assert integrate(abs(x), x) == Piecewise((-x**2/2, x <= 0), (x**2/2, True)) def test_V2(): assert integrate(Piecewise((-x, x < 0), (x, x >= 0)), x ) == Piecewise((-x**2/2, x < 0), (x**2/2, True)) def test_V3(): assert integrate(1/(x**3 + 2),x).diff().simplify() == 1/(x**3 + 2) def test_V4(): assert integrate(2**x/sqrt(1 + 4**x), x) == asinh(2**x)/log(2) @XFAIL def test_V5(): # Returns (-45*x**2 + 80*x - 41)/(5*sqrt(2*x - 1)*(4*x**2 - 4*x + 1)) assert (integrate((3*x - 5)**2/(2*x - 1)**(Rational(7, 2)), x).simplify() == (-41 + 80*x - 45*x**2)/(5*(2*x - 1)**Rational(5, 2))) @XFAIL def test_V6(): # returns RootSum(40*_z**2 - 1, Lambda(_i, _i*log(-4*_i + exp(-m*x))))/m assert (integrate(1/(2*exp(m*x) - 5*exp(-m*x)), x) == sqrt(10)*( log(2*exp(m*x) - sqrt(10)) - log(2*exp(m*x) + sqrt(10)))/(20*m)) def test_V7(): r1 = integrate(sinh(x)**4/cosh(x)**2) assert r1.simplify() == -3*x/2 + sinh(x)**3/(2*cosh(x)) + 3*tanh(x)/2 @XFAIL def test_V8_V9(): #Macsyma test case: #(c27) /* This example involves several symbolic parameters # => 1/sqrt(b^2 - a^2) log([sqrt(b^2 - a^2) tan(x/2) + a + b]/ # [sqrt(b^2 - a^2) tan(x/2) - a - b]) (a^2 < b^2) # [Gradshteyn and Ryzhik 2.553(3)] */ #assume(b^2 > a^2)$ #(c28) integrate(1/(a + b*cos(x)), x); #(c29) trigsimp(ratsimp(diff(%, x))); # 1 #(d29) ------------ # b cos(x) + a raise NotImplementedError( "Integrate with assumption not supported") def test_V10(): assert integrate(1/(3 + 3*cos(x) + 4*sin(x)), x) == log(tan(x/2) + Rational(3, 4))/4 def test_V11(): r1 = integrate(1/(4 + 3*cos(x) + 4*sin(x)), x) r2 = factor(r1) assert (logcombine(r2, force=True) == log(((tan(x/2) + 1)/(tan(x/2) + 7))**Rational(1, 3))) @XFAIL def test_V12(): r1 = integrate(1/(5 + 3*cos(x) + 4*sin(x)), x) # Correct result in python2.7.4, wrong result in python3.5 # https://github.com/sympy/sympy/issues/7157 assert r1 == -1/(tan(x/2) + 2) @XFAIL def test_V13(): r1 = integrate(1/(6 + 3*cos(x) + 4*sin(x)), x) # expression not simplified, returns: -sqrt(11)*I*log(tan(x/2) + 4/3 # - sqrt(11)*I/3)/11 + sqrt(11)*I*log(tan(x/2) + 4/3 + sqrt(11)*I/3)/11 assert r1.simplify() == 2*sqrt(11)*atan(sqrt(11)*(3*tan(x/2) + 4)/11)/11 @slow @XFAIL def test_V14(): r1 = integrate(log(abs(x**2 - y**2)), x) # Piecewise result does not simplify to the desired result. assert (r1.simplify() == x*log(abs(x**2 - y**2)) + y*log(x + y) - y*log(x - y) - 2*x) def test_V15(): r1 = integrate(x*acot(x/y), x) assert simplify(r1 - (x*y + (x**2 + y**2)*acot(x/y))/2) == 0 @XFAIL def test_V16(): # Integral not calculated assert integrate(cos(5*x)*Ci(2*x), x) == Ci(2*x)*sin(5*x)/5 - (Si(3*x) + Si(7*x))/10 @XFAIL def test_V17(): r1 = integrate((diff(f(x), x)*g(x) - f(x)*diff(g(x), x))/(f(x)**2 - g(x)**2), x) # integral not calculated assert simplify(r1 - (f(x) - g(x))/(f(x) + g(x))/2) == 0 @XFAIL def test_W1(): # The function has a pole at y. # The integral has a Cauchy principal value of zero but SymPy returns -I*pi # https://github.com/sympy/sympy/issues/7159 assert integrate(1/(x - y), (x, y - 1, y + 1)) == 0 @XFAIL def test_W2(): # The function has a pole at y. # The integral is divergent but SymPy returns -2 # https://github.com/sympy/sympy/issues/7160 # Test case in Macsyma: # (c6) errcatch(integrate(1/(x - a)^2, x, a - 1, a + 1)); # Integral is divergent assert integrate(1/(x - y)**2, (x, y - 1, y + 1)) == zoo @XFAIL def test_W3(): # integral is not calculated # https://github.com/sympy/sympy/issues/7161 assert integrate(sqrt(x + 1/x - 2), (x, 0, 1)) == S(4)/3 @XFAIL def test_W4(): # integral is not calculated assert integrate(sqrt(x + 1/x - 2), (x, 1, 2)) == -2*sqrt(2)/3 + S(4)/3 @XFAIL def test_W5(): # integral is not calculated assert integrate(sqrt(x + 1/x - 2), (x, 0, 2)) == -2*sqrt(2)/3 + S(8)/3 @XFAIL @slow def test_W6(): # integral is not calculated assert integrate(sqrt(2 - 2*cos(2*x))/2, (x, -3*pi/4, -pi/4)) == sqrt(2) def test_W7(): a = symbols('a', real=True, positive=True) r1 = integrate(cos(x)/(x**2 + a**2), (x, -oo, oo)) assert r1.simplify() == pi*exp(-a)/a @XFAIL def test_W8(): # Test case in Mathematica: # In[19]:= Integrate[t^(a - 1)/(1 + t), {t, 0, Infinity}, # Assumptions -> 0 < a < 1] # Out[19]= Pi Csc[a Pi] raise NotImplementedError( "Integrate with assumption 0 < a < 1 not supported") @XFAIL def test_W9(): # Integrand with a residue at infinity => -2 pi [sin(pi/5) + sin(2pi/5)] # (principal value) [Levinson and Redheffer, p. 234] *) r1 = integrate(5*x**3/(1 + x + x**2 + x**3 + x**4), (x, -oo, oo)) r2 = r1.doit() assert r2 == -2*pi*(sqrt(-sqrt(5)/8 + 5/8) + sqrt(sqrt(5)/8 + 5/8)) @XFAIL def test_W10(): # integrate(1/[1 + x + x^2 + ... + x^(2 n)], x = -infinity..infinity) = # 2 pi/(2 n + 1) [1 + cos(pi/[2 n + 1])] csc(2 pi/[2 n + 1]) # [Levinson and Redheffer, p. 255] => 2 pi/5 [1 + cos(pi/5)] csc(2 pi/5) */ r1 = integrate(x/(1 + x + x**2 + x**4), (x, -oo, oo)) r2 = r1.doit() assert r2 == 2*pi*(sqrt(5)/4 + 5/4)*csc(2*pi/5)/5 @XFAIL def test_W11(): # integral not calculated assert (integrate(sqrt(1 - x**2)/(1 + x**2), (x, -1, 1)) == pi*(-1 + sqrt(2))) def test_W12(): p = symbols('p', real=True, positive=True) q = symbols('q', real=True) r1 = integrate(x*exp(-p*x**2 + 2*q*x), (x, -oo, oo)) assert r1.simplify() == sqrt(pi)*q*exp(q**2/p)/p**Rational(3, 2) @XFAIL def test_W13(): # Integral not calculated. Expected result is 2*(Euler_mascheroni_constant) r1 = integrate(1/log(x) + 1/(1 - x) - log(log(1/x)), (x, 0, 1)) assert r1 == 2*EulerGamma def test_W14(): assert integrate(sin(x)/x*exp(2*I*x), (x, -oo, oo)) == 0 @XFAIL def test_W15(): # integral not calculated assert integrate(log(gamma(x))*cos(6*pi*x), (x, 0, 1)) == S(1)/12 def test_W16(): assert integrate((1 + x)**3*legendre_poly(1, x)*legendre_poly(2, x), (x, -1, 1)) == S(36)/35 def test_W17(): a, b = symbols('a b', real=True, positive=True) assert integrate(exp(-a*x)*besselj(0, b*x), (x, 0, oo)) == 1/(b*sqrt(a**2/b**2 + 1)) def test_W18(): assert integrate((besselj(1, x)/x)**2, (x, 0, oo)) == 4/(3*pi) @XFAIL def test_W19(): # Integral not calculated # Expected result is (cos 7 - 1)/7 [Gradshteyn and Ryzhik 6.782(3)] assert integrate(Ci(x)*besselj(0, 2*sqrt(7*x)), (x, 0, oo)) == (cos(7) - 1)/7 @XFAIL def test_W20(): # integral not calculated assert (integrate(x**2*polylog(3, 1/(x + 1)), (x, 0, 1)) == -pi**2/36 - S(17)/108 + zeta(3)/4 + (-pi**2/2 - 4*log(2) + log(2)**2 + 35/3)*log(2)/9) def test_W21(): assert abs(N(integrate(x**2*polylog(3, 1/(x + 1)), (x, 0, 1))) - 0.210882859565594) < 1e-15 def test_W22(): t, u = symbols('t u', real=True) s = Lambda(x, Piecewise((1, And(x >= 1, x <= 2)), (0, True))) assert integrate(s(t)*cos(t), (t, 0, u)) == Piecewise( (0, u < 0), (-sin(Min(1, u)) + sin(Min(2, u)), True)) @slow def test_W23(): a, b = symbols('a b', real=True, positive=True) r1 = integrate(integrate(x/(x**2 + y**2), (x, a, b)), (y, -oo, oo)) assert r1.collect(pi) == pi*(-a + b) def test_W23b(): # like W23 but limits are reversed x = symbols('x', real=True, positive=True) y = symbols('y', real=True) a, b = symbols('a b', real=True, positive=True) r2 = integrate(integrate(x/(x**2 + y**2), (y, -oo, oo)), (x, a, b)) assert r2.collect(pi) == pi*(-a + b) @XFAIL @slow def test_W24(): if ON_TRAVIS: skip("Too slow for travis.") # Not that slow, but does not fully evaluate so simplify is slow. # Maybe also require doit() x, y = symbols('x y', real=True) r1 = integrate(integrate(sqrt(x**2 + y**2), (x, 0, 1)), (y, 0, 1)) assert (r1 - (sqrt(2) + asinh(1))/3).simplify() == 0 @XFAIL @slow def test_W25(): if ON_TRAVIS: skip("Too slow for travis.") a, x, y = symbols('a x y', real=True) i1 = integrate( sin(a)*sin(y)/sqrt(1 - sin(a)**2*sin(x)**2*sin(y)**2), (x, 0, pi/2)) i2 = integrate(i1, (y, 0, pi/2)) assert (i2 - pi*a/2).simplify() == 0 def test_W26(): x, y = symbols('x y', real=True) assert integrate(integrate(abs(y - x**2), (y, 0, 2)), (x, -1, 1)) == S(46)/15 def test_W27(): a, b, c = symbols('a b c') assert integrate(integrate(integrate(1, (z, 0, c*(1 - x/a - y/b))), (y, 0, b*(1 - x/a))), (x, 0, a)) == a*b*c/6 def test_X1(): v, c = symbols('v c', real=True) assert (series(1/sqrt(1 - (v/c)**2), v, x0=0, n=8) == 5*v**6/(16*c**6) + 3*v**4/(8*c**4) + v**2/(2*c**2) + 1 + O(v**8)) def test_X2(): v, c = symbols('v c', real=True) s1 = series(1/sqrt(1 - (v/c)**2), v, x0=0, n=8) assert (1/s1**2).series(v, x0=0, n=8) == -v**2/c**2 + 1 + O(v**8) def test_X3(): s1 = (sin(x).series()/cos(x).series()).series() s2 = tan(x).series() assert s2 == x + x**3/3 + 2*x**5/15 + O(x**6) assert s1 == s2 def test_X4(): s1 = log(sin(x)/x).series() assert s1 == -x**2/6 - x**4/180 + O(x**6) assert log(series(sin(x)/x)).series() == s1 @XFAIL def test_X5(): # test case in Mathematica syntax: # In[21]:= (* => [a f'(a d) + g(b d) + integrate(h(c y), y = 0..d)] # + [a^2 f''(a d) + b g'(b d) + h(c d)] (x - d) *) # In[22]:= D[f[a*x], x] + g[b*x] + Integrate[h[c*y], {y, 0, x}] # Out[22]= g[b x] + Integrate[h[c y], {y, 0, x}] + a f'[a x] # In[23]:= Series[%, {x, d, 1}] # Out[23]= (g[b d] + Integrate[h[c y], {y, 0, d}] + a f'[a d]) + # 2 2 # (h[c d] + b g'[b d] + a f''[a d]) (-d + x) + O[-d + x] h = Function('h') a, b, c, d = symbols('a b c d', real=True) # series() raises NotImplementedError: # The _eval_nseries method should be added to <class # 'sympy.core.function.Subs'> to give terms up to O(x**n) at x=0 series(diff(f(a*x), x) + g(b*x) + integrate(h(c*y), (y, 0, x)), x, x0=d, n=2) # assert missing, until exception is removed def test_X6(): # Taylor series of nonscalar objects (noncommutative multiplication) # expected result => (B A - A B) t^2/2 + O(t^3) [Stanly Steinberg] a, b = symbols('a b', commutative=False, scalar=False) assert (series(exp((a + b)*x) - exp(a*x) * exp(b*x), x, x0=0, n=3) == x**2*(-a*b/2 + b*a/2) + O(x**3)) def test_X7(): # => sum( Bernoulli[k]/k! x^(k - 2), k = 1..infinity ) # = 1/x^2 - 1/(2 x) + 1/12 - x^2/720 + x^4/30240 + O(x^6) # [Levinson and Redheffer, p. 173] assert (series(1/(x*(exp(x) - 1)), x, 0, 7) == x**(-2) - 1/(2*x) + S(1)/12 - x**2/720 + x**4/30240 - x**6/1209600 + O(x**7)) def test_X8(): # Puiseux series (terms with fractional degree): # => 1/sqrt(x - 3/2 pi) + (x - 3/2 pi)^(3/2) / 12 + O([x - 3/2 pi]^(7/2)) # see issue 7167: x = symbols('x', real=True) assert (series(sqrt(sec(x)), x, x0=pi*3/2, n=4) == 1/sqrt(x - 3*pi/2) + (x - 3*pi/2)**(S(3)/2)/12 + (x - 3*pi/2)**(S(7)/2)/160 + O((x - 3*pi/2)**4, (x, 3*pi/2))) def test_X9(): assert (series(x**x, x, x0=0, n=4) == 1 + x*log(x) + x**2*log(x)**2/2 + x**3*log(x)**3/6 + O(x**4*log(x)**4)) def test_X10(): z, w = symbols('z w') assert (series(log(sinh(z)) + log(cosh(z + w)), z, x0=0, n=2) == log(cosh(w)) + log(z) + z*sinh(w)/cosh(w) + O(z**2)) def test_X11(): z, w = symbols('z w') assert (series(log(sinh(z) * cosh(z + w)), z, x0=0, n=2) == log(cosh(w)) + log(z) + z*sinh(w)/cosh(w) + O(z**2)) @XFAIL def test_X12(): # Look at the generalized Taylor series around x = 1 # Result => (x - 1)^a/e^b [1 - (a + 2 b) (x - 1) / 2 + O((x - 1)^2)] a, b, x = symbols('a b x', real=True) # series returns O(log(x-1)**2) # https://github.com/sympy/sympy/issues/7168 assert (series(log(x)**a*exp(-b*x), x, x0=1, n=2) == (x - 1)**a/exp(b)*(1 - (a + 2*b)*(x - 1)/2 + O((x - 1)**2))) def test_X13(): assert series(sqrt(2*x**2 + 1), x, x0=oo, n=1) == sqrt(2)*x + O(1/x, (x, oo)) @XFAIL def test_X14(): # Wallis' product => 1/sqrt(pi n) + ... [Knopp, p. 385] assert series(1/2**(2*n)*binomial(2*n, n), n, x==oo, n=1) == 1/(sqrt(pi)*sqrt(n)) + O(1/x, (x, oo)) @SKIP("https://github.com/sympy/sympy/issues/7164") def test_X15(): # => 0!/x - 1!/x^2 + 2!/x^3 - 3!/x^4 + O(1/x^5) [Knopp, p. 544] x, t = symbols('x t', real=True) # raises RuntimeError: maximum recursion depth exceeded # https://github.com/sympy/sympy/issues/7164 # 2019-02-17: Raises # PoleError: # Asymptotic expansion of Ei around [-oo] is not implemented. e1 = integrate(exp(-t)/t, (t, x, oo)) assert (series(e1, x, x0=oo, n=5) == 6/x**4 + 2/x**3 - 1/x**2 + 1/x + O(x**(-5), (x, oo))) def test_X16(): # Multivariate Taylor series expansion => 1 - (x^2 + 2 x y + y^2)/2 + O(x^4) assert (series(cos(x + y), x + y, x0=0, n=4) == 1 - (x + y)**2/2 + O(x**4 + x**3*y + x**2*y**2 + x*y**3 + y**4, x, y)) @XFAIL def test_X17(): # Power series (compute the general formula) # (c41) powerseries(log(sin(x)/x), x, 0); # /aquarius/data2/opt/local/macsyma_422/library1/trgred.so being loaded. # inf # ==== i1 2 i1 2 i1 # \ (- 1) 2 bern(2 i1) x # (d41) > ------------------------------ # / 2 i1 (2 i1)! # ==== # i1 = 1 # fps does not calculate assert fps(log(sin(x)/x)) == \ Sum((-1)**k*2**(2*k - 1)*bernoulli(2*k)*x**(2*k)/(k*factorial(2*k)), (k, 1, oo)) @XFAIL def test_X18(): # Power series (compute the general formula). Maple FPS: # > FormalPowerSeries(exp(-x)*sin(x), x = 0); # infinity # ----- (1/2 k) k # \ 2 sin(3/4 k Pi) x # ) ------------------------- # / k! # ----- # # Now, sympy returns # oo # _____ # \ ` # \ / k k\ # \ k |I*(-1 - I) I*(-1 + I) | # \ x *|----------- - -----------| # / \ 2 2 / # / ------------------------------ # / k! # /____, # k = 0 k = Dummy('k') assert fps(exp(-x)*sin(x)) == \ Sum(2**(S(1)/2*k)*sin(S(3)/4*k*pi)*x**k/factorial(k), (k, 0, oo)) @XFAIL def test_X19(): # (c45) /* Derive an explicit Taylor series solution of y as a function of # x from the following implicit relation: # y = x - 1 + (x - 1)^2/2 + 2/3 (x - 1)^3 + (x - 1)^4 + # 17/10 (x - 1)^5 + ... # */ # x = sin(y) + cos(y); # Time= 0 msecs # (d45) x = sin(y) + cos(y) # # (c46) taylor_revert(%, y, 7); raise NotImplementedError("Solve using series not supported. \ Inverse Taylor series expansion also not supported") @XFAIL def test_X20(): # Pade (rational function) approximation => (2 - x)/(2 + x) # > numapprox[pade](exp(-x), x = 0, [1, 1]); # bytes used=9019816, alloc=3669344, time=13.12 # 1 - 1/2 x # --------- # 1 + 1/2 x # mpmath support numeric Pade approximant but there is # no symbolic implementation in SymPy # https://en.wikipedia.org/wiki/Pad%C3%A9_approximant raise NotImplementedError("Symbolic Pade approximant not supported") def test_X21(): """ Test whether `fourier_series` of x periodical on the [-p, p] interval equals `- (2 p / pi) sum( (-1)^n / n sin(n pi x / p), n = 1..infinity )`. """ p = symbols('p', positive=True) n = symbols('n', positive=True, integer=True) s = fourier_series(x, (x, -p, p)) # All cosine coefficients are equal to 0 assert s.an.formula == 0 # Check for sine coefficients assert s.bn.formula.subs(s.bn.variables[0], 0) == 0 assert s.bn.formula.subs(s.bn.variables[0], n) == \ -2*p/pi * (-1)**n / n * sin(n*pi*x/p) @XFAIL def test_X22(): # (c52) /* => p / 2 # - (2 p / pi^2) sum( [1 - (-1)^n] cos(n pi x / p) / n^2, # n = 1..infinity ) */ # fourier_series(abs(x), x, p); # p # (e52) a = - # 0 2 # # %nn # (2 (- 1) - 2) p # (e53) a = ------------------ # %nn 2 2 # %pi %nn # # (e54) b = 0 # %nn # # Time= 5290 msecs # inf %nn %pi %nn x # ==== (2 (- 1) - 2) cos(---------) # \ p # p > ------------------------------- # / 2 # ==== %nn # %nn = 1 p # (d54) ----------------------------------------- + - # 2 2 # %pi raise NotImplementedError("Fourier series not supported") def test_Y1(): t = symbols('t', real=True, positive=True) w = symbols('w', real=True) s = symbols('s') F, _, _ = laplace_transform(cos((w - 1)*t), t, s) assert F == s/(s**2 + (w - 1)**2) def test_Y2(): t = symbols('t', real=True, positive=True) w = symbols('w', real=True) s = symbols('s') f = inverse_laplace_transform(s/(s**2 + (w - 1)**2), s, t) assert f == cos(t*w - t) def test_Y3(): t = symbols('t', real=True, positive=True) w = symbols('w', real=True) s = symbols('s') F, _, _ = laplace_transform(sinh(w*t)*cosh(w*t), t, s) assert F == w/(s**2 - 4*w**2) def test_Y4(): t = symbols('t', real=True, positive=True) s = symbols('s') F, _, _ = laplace_transform(erf(3/sqrt(t)), t, s) assert F == (1 - exp(-6*sqrt(s)))/s @XFAIL def test_Y5_Y6(): # Solve y'' + y = 4 [H(t - 1) - H(t - 2)], y(0) = 1, y'(0) = 0 where H is the # Heaviside (unit step) function (the RHS describes a pulse of magnitude 4 and # duration 1). See David A. Sanchez, Richard C. Allen, Jr. and Walter T. # Kyner, _Differential Equations: An Introduction_, Addison-Wesley Publishing # Company, 1983, p. 211. First, take the Laplace transform of the ODE # => s^2 Y(s) - s + Y(s) = 4/s [e^(-s) - e^(-2 s)] # where Y(s) is the Laplace transform of y(t) t = symbols('t', real=True, positive=True) s = symbols('s') y = Function('y') F, _, _ = laplace_transform(diff(y(t), t, 2) + y(t) - 4*(Heaviside(t - 1) - Heaviside(t - 2)), t, s) # Laplace transform for diff() not calculated # https://github.com/sympy/sympy/issues/7176 assert (F == s**2*LaplaceTransform(y(t), t, s) - s + LaplaceTransform(y(t), t, s) - 4*exp(-s)/s + 4*exp(-2*s)/s) # TODO implement second part of test case # Now, solve for Y(s) and then take the inverse Laplace transform # => Y(s) = s/(s^2 + 1) + 4 [1/s - s/(s^2 + 1)] [e^(-s) - e^(-2 s)] # => y(t) = cos t + 4 {[1 - cos(t - 1)] H(t - 1) - [1 - cos(t - 2)] H(t - 2)} @XFAIL def test_Y7(): # What is the Laplace transform of an infinite square wave? # => 1/s + 2 sum( (-1)^n e^(- s n a)/s, n = 1..infinity ) # [Sanchez, Allen and Kyner, p. 213] t = symbols('t', real=True, positive=True) a = symbols('a', real=True) s = symbols('s') F, _, _ = laplace_transform(1 + 2*Sum((-1)**n*Heaviside(t - n*a), (n, 1, oo)), t, s) # returns 2*LaplaceTransform(Sum((-1)**n*Heaviside(-a*n + t), # (n, 1, oo)), t, s) + 1/s # https://github.com/sympy/sympy/issues/7177 assert F == 2*Sum((-1)**n*exp(-a*n*s)/s, (n, 1, oo)) + 1/s @XFAIL def test_Y8(): assert fourier_transform(1, x, z) == DiracDelta(z) def test_Y9(): assert (fourier_transform(exp(-9*x**2), x, z) == sqrt(pi)*exp(-pi**2*z**2/9)/3) def test_Y10(): assert (fourier_transform(abs(x)*exp(-3*abs(x)), x, z) == (-8*pi**2*z**2 + 18)/(16*pi**4*z**4 + 72*pi**2*z**2 + 81)) @SKIP("https://github.com/sympy/sympy/issues/7181") @slow def test_Y11(): # => pi cot(pi s) (0 < Re s < 1) [Gradshteyn and Ryzhik 17.43(5)] x, s = symbols('x s') # raises RuntimeError: maximum recursion depth exceeded # https://github.com/sympy/sympy/issues/7181 # Update 2019-02-17 raises: # TypeError: cannot unpack non-iterable MellinTransform object F, _, _ = mellin_transform(1/(1 - x), x, s) assert F == pi*cot(pi*s) @XFAIL def test_Y12(): # => 2^(s - 4) gamma(s/2)/gamma(4 - s/2) (0 < Re s < 1) # [Gradshteyn and Ryzhik 17.43(16)] x, s = symbols('x s') # returns Wrong value -2**(s - 4)*gamma(s/2 - 3)/gamma(-s/2 + 1) # https://github.com/sympy/sympy/issues/7182 F, _, _ = mellin_transform(besselj(3, x)/x**3, x, s) assert F == -2**(s - 4)*gamma(s/2)/gamma(-s/2 + 4) @XFAIL def test_Y13(): # Z[H(t - m T)] => z/[z^m (z - 1)] (H is the Heaviside (unit step) function) z raise NotImplementedError("z-transform not supported") @XFAIL def test_Y14(): # Z[H(t - m T)] => z/[z^m (z - 1)] (H is the Heaviside (unit step) function) raise NotImplementedError("z-transform not supported") def test_Z1(): r = Function('r') assert (rsolve(r(n + 2) - 2*r(n + 1) + r(n) - 2, r(n), {r(0): 1, r(1): m}).simplify() == n**2 + n*(m - 2) + 1) def test_Z2(): r = Function('r') assert (rsolve(r(n) - (5*r(n - 1) - 6*r(n - 2)), r(n), {r(0): 0, r(1): 1}) == -2**n + 3**n) def test_Z3(): # => r(n) = Fibonacci[n + 1] [Cohen, p. 83] r = Function('r') # recurrence solution is correct, Wester expects it to be simplified to # fibonacci(n+1), but that is quite hard assert (rsolve(r(n) - (r(n - 1) + r(n - 2)), r(n), {r(1): 1, r(2): 2}).simplify() == 2**(-n)*((1 + sqrt(5))**n*(sqrt(5) + 5) + (-sqrt(5) + 1)**n*(-sqrt(5) + 5))/10) @XFAIL def test_Z4(): # => [c^(n+1) [c^(n+1) - 2 c - 2] + (n+1) c^2 + 2 c - n] / [(c-1)^3 (c+1)] # [Joan Z. Yu and Robert Israel in sci.math.symbolic] r = Function('r') c = symbols('c') # raises ValueError: Polynomial or rational function expected, # got '(c**2 - c**n)/(c - c**n) s = rsolve(r(n) - ((1 + c - c**(n-1) - c**(n+1))/(1 - c**n)*r(n - 1) - c*(1 - c**(n-2))/(1 - c**(n-1))*r(n - 2) + 1), r(n), {r(1): 1, r(2): (2 + 2*c + c**2)/(1 + c)}) assert (s - (c*(n + 1)*(c*(n + 1) - 2*c - 2) + (n + 1)*c**2 + 2*c - n)/((c-1)**3*(c+1)) == 0) @XFAIL def test_Z5(): # Second order ODE with initial conditions---solve directly # transform: f(t) = sin(2 t)/8 - t cos(2 t)/4 C1, C2 = symbols('C1 C2') # initial conditions not supported, this is a manual workaround # https://github.com/sympy/sympy/issues/4720 eq = Derivative(f(x), x, 2) + 4*f(x) - sin(2*x) sol = dsolve(eq, f(x)) f0 = Lambda(x, sol.rhs) assert f0(x) == C2*sin(2*x) + (C1 - x/4)*cos(2*x) f1 = Lambda(x, diff(f0(x), x)) # TODO: Replace solve with solveset, when it works for solveset const_dict = solve((f0(0), f1(0))) result = f0(x).subs(C1, const_dict[C1]).subs(C2, const_dict[C2]) assert result == -x*cos(2*x)/4 + sin(2*x)/8 # Result is OK, but ODE solving with initial conditions should be # supported without all this manual work raise NotImplementedError('ODE solving with initial conditions \ not supported') @XFAIL def test_Z6(): # Second order ODE with initial conditions---solve using Laplace # transform: f(t) = sin(2 t)/8 - t cos(2 t)/4 t = symbols('t', real=True, positive=True) s = symbols('s') eq = Derivative(f(t), t, 2) + 4*f(t) - sin(2*t) F, _, _ = laplace_transform(eq, t, s) # Laplace transform for diff() not calculated # https://github.com/sympy/sympy/issues/7176 assert (F == s**2*LaplaceTransform(f(t), t, s) + 4*LaplaceTransform(f(t), t, s) - 2/(s**2 + 4)) # rest of test case not implemented
3afe870777daa5ee0e212abd2581ecaa5925d4ad6004ab0db75930c5aedf2d8d
from __future__ import print_function, division import itertools from sympy.core import S from sympy.core.compatibility import range, string_types from sympy.core.containers import Tuple from sympy.core.function import _coeff_isneg from sympy.core.mul import Mul from sympy.core.numbers import Rational from sympy.core.power import Pow from sympy.core.relational import Equality from sympy.core.symbol import Symbol from sympy.core.sympify import SympifyError from sympy.printing.conventions import requires_partial from sympy.printing.precedence import PRECEDENCE, precedence, precedence_traditional from sympy.printing.printer import Printer from sympy.printing.str import sstr from sympy.utilities import default_sort_key from sympy.utilities.iterables import has_variety from sympy.printing.pretty.stringpict import prettyForm, stringPict from sympy.printing.pretty.pretty_symbology import xstr, hobj, vobj, xobj, \ xsym, pretty_symbol, pretty_atom, pretty_use_unicode, greek_unicode, U, \ pretty_try_use_unicode, annotated # rename for usage from outside pprint_use_unicode = pretty_use_unicode pprint_try_use_unicode = pretty_try_use_unicode class PrettyPrinter(Printer): """Printer, which converts an expression into 2D ASCII-art figure.""" printmethod = "_pretty" _default_settings = { "order": None, "full_prec": "auto", "use_unicode": None, "wrap_line": True, "num_columns": None, "use_unicode_sqrt_char": True, "root_notation": True, "mat_symbol_style": "plain", "imaginary_unit": "i", } def __init__(self, settings=None): Printer.__init__(self, settings) if not isinstance(self._settings['imaginary_unit'], string_types): raise TypeError("'imaginary_unit' must a string, not {}".format(self._settings['imaginary_unit'])) elif self._settings['imaginary_unit'] not in ["i", "j"]: raise ValueError("'imaginary_unit' must be either 'i' or 'j', not '{}'".format(self._settings['imaginary_unit'])) self.emptyPrinter = lambda x: prettyForm(xstr(x)) @property def _use_unicode(self): if self._settings['use_unicode']: return True else: return pretty_use_unicode() def doprint(self, expr): return self._print(expr).render(**self._settings) # empty op so _print(stringPict) returns the same def _print_stringPict(self, e): return e def _print_basestring(self, e): return prettyForm(e) def _print_atan2(self, e): pform = prettyForm(*self._print_seq(e.args).parens()) pform = prettyForm(*pform.left('atan2')) return pform def _print_Symbol(self, e, bold_name=False): symb = pretty_symbol(e.name, bold_name) return prettyForm(symb) _print_RandomSymbol = _print_Symbol def _print_MatrixSymbol(self, e): return self._print_Symbol(e, self._settings['mat_symbol_style'] == "bold") def _print_Float(self, e): # we will use StrPrinter's Float printer, but we need to handle the # full_prec ourselves, according to the self._print_level full_prec = self._settings["full_prec"] if full_prec == "auto": full_prec = self._print_level == 1 return prettyForm(sstr(e, full_prec=full_prec)) def _print_Cross(self, e): vec1 = e._expr1 vec2 = e._expr2 pform = self._print(vec2) pform = prettyForm(*pform.left('(')) pform = prettyForm(*pform.right(')')) pform = prettyForm(*pform.left(self._print(U('MULTIPLICATION SIGN')))) pform = prettyForm(*pform.left(')')) pform = prettyForm(*pform.left(self._print(vec1))) pform = prettyForm(*pform.left('(')) return pform def _print_Curl(self, e): vec = e._expr pform = self._print(vec) pform = prettyForm(*pform.left('(')) pform = prettyForm(*pform.right(')')) pform = prettyForm(*pform.left(self._print(U('MULTIPLICATION SIGN')))) pform = prettyForm(*pform.left(self._print(U('NABLA')))) return pform def _print_Divergence(self, e): vec = e._expr pform = self._print(vec) pform = prettyForm(*pform.left('(')) pform = prettyForm(*pform.right(')')) pform = prettyForm(*pform.left(self._print(U('DOT OPERATOR')))) pform = prettyForm(*pform.left(self._print(U('NABLA')))) return pform def _print_Dot(self, e): vec1 = e._expr1 vec2 = e._expr2 pform = self._print(vec2) pform = prettyForm(*pform.left('(')) pform = prettyForm(*pform.right(')')) pform = prettyForm(*pform.left(self._print(U('DOT OPERATOR')))) pform = prettyForm(*pform.left(')')) pform = prettyForm(*pform.left(self._print(vec1))) pform = prettyForm(*pform.left('(')) return pform def _print_Gradient(self, e): func = e._expr pform = self._print(func) pform = prettyForm(*pform.left('(')) pform = prettyForm(*pform.right(')')) pform = prettyForm(*pform.left(self._print(U('NABLA')))) return pform def _print_Laplacian(self, e): func = e._expr pform = self._print(func) pform = prettyForm(*pform.left('(')) pform = prettyForm(*pform.right(')')) pform = prettyForm(*pform.left(self._print(U('INCREMENT')))) return pform def _print_Atom(self, e): try: # print atoms like Exp1 or Pi return prettyForm(pretty_atom(e.__class__.__name__, printer=self)) except KeyError: return self.emptyPrinter(e) # Infinity inherits from Number, so we have to override _print_XXX order _print_Infinity = _print_Atom _print_NegativeInfinity = _print_Atom _print_EmptySet = _print_Atom _print_Naturals = _print_Atom _print_Naturals0 = _print_Atom _print_Integers = _print_Atom _print_Complexes = _print_Atom def _print_Reals(self, e): if self._use_unicode: return self._print_Atom(e) else: inf_list = ['-oo', 'oo'] return self._print_seq(inf_list, '(', ')') def _print_subfactorial(self, e): x = e.args[0] pform = self._print(x) # Add parentheses if needed if not ((x.is_Integer and x.is_nonnegative) or x.is_Symbol): pform = prettyForm(*pform.parens()) pform = prettyForm(*pform.left('!')) return pform def _print_factorial(self, e): x = e.args[0] pform = self._print(x) # Add parentheses if needed if not ((x.is_Integer and x.is_nonnegative) or x.is_Symbol): pform = prettyForm(*pform.parens()) pform = prettyForm(*pform.right('!')) return pform def _print_factorial2(self, e): x = e.args[0] pform = self._print(x) # Add parentheses if needed if not ((x.is_Integer and x.is_nonnegative) or x.is_Symbol): pform = prettyForm(*pform.parens()) pform = prettyForm(*pform.right('!!')) return pform def _print_binomial(self, e): n, k = e.args n_pform = self._print(n) k_pform = self._print(k) bar = ' '*max(n_pform.width(), k_pform.width()) pform = prettyForm(*k_pform.above(bar)) pform = prettyForm(*pform.above(n_pform)) pform = prettyForm(*pform.parens('(', ')')) pform.baseline = (pform.baseline + 1)//2 return pform def _print_Relational(self, e): op = prettyForm(' ' + xsym(e.rel_op) + ' ') l = self._print(e.lhs) r = self._print(e.rhs) pform = prettyForm(*stringPict.next(l, op, r)) return pform def _print_Not(self, e): from sympy import Equivalent, Implies if self._use_unicode: arg = e.args[0] pform = self._print(arg) if isinstance(arg, Equivalent): return self._print_Equivalent(arg, altchar=u"\N{LEFT RIGHT DOUBLE ARROW WITH STROKE}") if isinstance(arg, Implies): return self._print_Implies(arg, altchar=u"\N{RIGHTWARDS ARROW WITH STROKE}") if arg.is_Boolean and not arg.is_Not: pform = prettyForm(*pform.parens()) return prettyForm(*pform.left(u"\N{NOT SIGN}")) else: return self._print_Function(e) def __print_Boolean(self, e, char, sort=True): args = e.args if sort: args = sorted(e.args, key=default_sort_key) arg = args[0] pform = self._print(arg) if arg.is_Boolean and not arg.is_Not: pform = prettyForm(*pform.parens()) for arg in args[1:]: pform_arg = self._print(arg) if arg.is_Boolean and not arg.is_Not: pform_arg = prettyForm(*pform_arg.parens()) pform = prettyForm(*pform.right(u' %s ' % char)) pform = prettyForm(*pform.right(pform_arg)) return pform def _print_And(self, e): if self._use_unicode: return self.__print_Boolean(e, u"\N{LOGICAL AND}") else: return self._print_Function(e, sort=True) def _print_Or(self, e): if self._use_unicode: return self.__print_Boolean(e, u"\N{LOGICAL OR}") else: return self._print_Function(e, sort=True) def _print_Xor(self, e): if self._use_unicode: return self.__print_Boolean(e, u"\N{XOR}") else: return self._print_Function(e, sort=True) def _print_Nand(self, e): if self._use_unicode: return self.__print_Boolean(e, u"\N{NAND}") else: return self._print_Function(e, sort=True) def _print_Nor(self, e): if self._use_unicode: return self.__print_Boolean(e, u"\N{NOR}") else: return self._print_Function(e, sort=True) def _print_Implies(self, e, altchar=None): if self._use_unicode: return self.__print_Boolean(e, altchar or u"\N{RIGHTWARDS ARROW}", sort=False) else: return self._print_Function(e) def _print_Equivalent(self, e, altchar=None): if self._use_unicode: return self.__print_Boolean(e, altchar or u"\N{LEFT RIGHT DOUBLE ARROW}") else: return self._print_Function(e, sort=True) def _print_conjugate(self, e): pform = self._print(e.args[0]) return prettyForm( *pform.above( hobj('_', pform.width())) ) def _print_Abs(self, e): pform = self._print(e.args[0]) pform = prettyForm(*pform.parens('|', '|')) return pform _print_Determinant = _print_Abs def _print_floor(self, e): if self._use_unicode: pform = self._print(e.args[0]) pform = prettyForm(*pform.parens('lfloor', 'rfloor')) return pform else: return self._print_Function(e) def _print_ceiling(self, e): if self._use_unicode: pform = self._print(e.args[0]) pform = prettyForm(*pform.parens('lceil', 'rceil')) return pform else: return self._print_Function(e) def _print_Derivative(self, deriv): if requires_partial(deriv) and self._use_unicode: deriv_symbol = U('PARTIAL DIFFERENTIAL') else: deriv_symbol = r'd' x = None count_total_deriv = 0 for sym, num in reversed(deriv.variable_count): s = self._print(sym) ds = prettyForm(*s.left(deriv_symbol)) count_total_deriv += num if (not num.is_Integer) or (num > 1): ds = ds**prettyForm(str(num)) if x is None: x = ds else: x = prettyForm(*x.right(' ')) x = prettyForm(*x.right(ds)) f = prettyForm( binding=prettyForm.FUNC, *self._print(deriv.expr).parens()) pform = prettyForm(deriv_symbol) if (count_total_deriv > 1) != False: pform = pform**prettyForm(str(count_total_deriv)) pform = prettyForm(*pform.below(stringPict.LINE, x)) pform.baseline = pform.baseline + 1 pform = prettyForm(*stringPict.next(pform, f)) pform.binding = prettyForm.MUL return pform def _print_Cycle(self, dc): from sympy.combinatorics.permutations import Permutation, Cycle # for Empty Cycle if dc == Cycle(): cyc = stringPict('') return prettyForm(*cyc.parens()) dc_list = Permutation(dc.list()).cyclic_form # for Identity Cycle if dc_list == []: cyc = self._print(dc.size - 1) return prettyForm(*cyc.parens()) cyc = stringPict('') for i in dc_list: l = self._print(str(tuple(i)).replace(',', '')) cyc = prettyForm(*cyc.right(l)) return cyc def _print_PDF(self, pdf): lim = self._print(pdf.pdf.args[0]) lim = prettyForm(*lim.right(', ')) lim = prettyForm(*lim.right(self._print(pdf.domain[0]))) lim = prettyForm(*lim.right(', ')) lim = prettyForm(*lim.right(self._print(pdf.domain[1]))) lim = prettyForm(*lim.parens()) f = self._print(pdf.pdf.args[1]) f = prettyForm(*f.right(', ')) f = prettyForm(*f.right(lim)) f = prettyForm(*f.parens()) pform = prettyForm('PDF') pform = prettyForm(*pform.right(f)) return pform def _print_Integral(self, integral): f = integral.function # Add parentheses if arg involves addition of terms and # create a pretty form for the argument prettyF = self._print(f) # XXX generalize parens if f.is_Add: prettyF = prettyForm(*prettyF.parens()) # dx dy dz ... arg = prettyF for x in integral.limits: prettyArg = self._print(x[0]) # XXX qparens (parens if needs-parens) if prettyArg.width() > 1: prettyArg = prettyForm(*prettyArg.parens()) arg = prettyForm(*arg.right(' d', prettyArg)) # \int \int \int ... firstterm = True s = None for lim in integral.limits: x = lim[0] # Create bar based on the height of the argument h = arg.height() H = h + 2 # XXX hack! ascii_mode = not self._use_unicode if ascii_mode: H += 2 vint = vobj('int', H) # Construct the pretty form with the integral sign and the argument pform = prettyForm(vint) pform.baseline = arg.baseline + ( H - h)//2 # covering the whole argument if len(lim) > 1: # Create pretty forms for endpoints, if definite integral. # Do not print empty endpoints. if len(lim) == 2: prettyA = prettyForm("") prettyB = self._print(lim[1]) if len(lim) == 3: prettyA = self._print(lim[1]) prettyB = self._print(lim[2]) if ascii_mode: # XXX hack # Add spacing so that endpoint can more easily be # identified with the correct integral sign spc = max(1, 3 - prettyB.width()) prettyB = prettyForm(*prettyB.left(' ' * spc)) spc = max(1, 4 - prettyA.width()) prettyA = prettyForm(*prettyA.right(' ' * spc)) pform = prettyForm(*pform.above(prettyB)) pform = prettyForm(*pform.below(prettyA)) if not ascii_mode: # XXX hack pform = prettyForm(*pform.right(' ')) if firstterm: s = pform # first term firstterm = False else: s = prettyForm(*s.left(pform)) pform = prettyForm(*arg.left(s)) pform.binding = prettyForm.MUL return pform def _print_Product(self, expr): func = expr.term pretty_func = self._print(func) horizontal_chr = xobj('_', 1) corner_chr = xobj('_', 1) vertical_chr = xobj('|', 1) if self._use_unicode: # use unicode corners horizontal_chr = xobj('-', 1) corner_chr = u'\N{BOX DRAWINGS LIGHT DOWN AND HORIZONTAL}' func_height = pretty_func.height() first = True max_upper = 0 sign_height = 0 for lim in expr.limits: width = (func_height + 2) * 5 // 3 - 2 sign_lines = [horizontal_chr + corner_chr + (horizontal_chr * (width-2)) + corner_chr + horizontal_chr] for _ in range(func_height + 1): sign_lines.append(' ' + vertical_chr + (' ' * (width-2)) + vertical_chr + ' ') pretty_sign = stringPict('') pretty_sign = prettyForm(*pretty_sign.stack(*sign_lines)) pretty_upper = self._print(lim[2]) pretty_lower = self._print(Equality(lim[0], lim[1])) max_upper = max(max_upper, pretty_upper.height()) if first: sign_height = pretty_sign.height() pretty_sign = prettyForm(*pretty_sign.above(pretty_upper)) pretty_sign = prettyForm(*pretty_sign.below(pretty_lower)) if first: pretty_func.baseline = 0 first = False height = pretty_sign.height() padding = stringPict('') padding = prettyForm(*padding.stack(*[' ']*(height - 1))) pretty_sign = prettyForm(*pretty_sign.right(padding)) pretty_func = prettyForm(*pretty_sign.right(pretty_func)) pretty_func.baseline = max_upper + sign_height//2 pretty_func.binding = prettyForm.MUL return pretty_func def _print_Sum(self, expr): ascii_mode = not self._use_unicode def asum(hrequired, lower, upper, use_ascii): def adjust(s, wid=None, how='<^>'): if not wid or len(s) > wid: return s need = wid - len(s) if how == '<^>' or how == "<" or how not in list('<^>'): return s + ' '*need half = need//2 lead = ' '*half if how == ">": return " "*need + s return lead + s + ' '*(need - len(lead)) h = max(hrequired, 2) d = h//2 w = d + 1 more = hrequired % 2 lines = [] if use_ascii: lines.append("_"*(w) + ' ') lines.append(r"\%s`" % (' '*(w - 1))) for i in range(1, d): lines.append('%s\\%s' % (' '*i, ' '*(w - i))) if more: lines.append('%s)%s' % (' '*(d), ' '*(w - d))) for i in reversed(range(1, d)): lines.append('%s/%s' % (' '*i, ' '*(w - i))) lines.append("/" + "_"*(w - 1) + ',') return d, h + more, lines, more else: w = w + more d = d + more vsum = vobj('sum', 4) lines.append("_"*(w)) for i in range(0, d): lines.append('%s%s%s' % (' '*i, vsum[2], ' '*(w - i - 1))) for i in reversed(range(0, d)): lines.append('%s%s%s' % (' '*i, vsum[4], ' '*(w - i - 1))) lines.append(vsum[8]*(w)) return d, h + 2*more, lines, more f = expr.function prettyF = self._print(f) if f.is_Add: # add parens prettyF = prettyForm(*prettyF.parens()) H = prettyF.height() + 2 # \sum \sum \sum ... first = True max_upper = 0 sign_height = 0 for lim in expr.limits: if len(lim) == 3: prettyUpper = self._print(lim[2]) prettyLower = self._print(Equality(lim[0], lim[1])) elif len(lim) == 2: prettyUpper = self._print("") prettyLower = self._print(Equality(lim[0], lim[1])) elif len(lim) == 1: prettyUpper = self._print("") prettyLower = self._print(lim[0]) max_upper = max(max_upper, prettyUpper.height()) # Create sum sign based on the height of the argument d, h, slines, adjustment = asum( H, prettyLower.width(), prettyUpper.width(), ascii_mode) prettySign = stringPict('') prettySign = prettyForm(*prettySign.stack(*slines)) if first: sign_height = prettySign.height() prettySign = prettyForm(*prettySign.above(prettyUpper)) prettySign = prettyForm(*prettySign.below(prettyLower)) if first: # change F baseline so it centers on the sign prettyF.baseline -= d - (prettyF.height()//2 - prettyF.baseline) first = False # put padding to the right pad = stringPict('') pad = prettyForm(*pad.stack(*[' ']*h)) prettySign = prettyForm(*prettySign.right(pad)) # put the present prettyF to the right prettyF = prettyForm(*prettySign.right(prettyF)) # adjust baseline of ascii mode sigma with an odd height so that it is # exactly through the center ascii_adjustment = ascii_mode if not adjustment else 0 prettyF.baseline = max_upper + sign_height//2 + ascii_adjustment prettyF.binding = prettyForm.MUL return prettyF def _print_Limit(self, l): e, z, z0, dir = l.args E = self._print(e) if precedence(e) <= PRECEDENCE["Mul"]: E = prettyForm(*E.parens('(', ')')) Lim = prettyForm('lim') LimArg = self._print(z) if self._use_unicode: LimArg = prettyForm(*LimArg.right(u'\N{BOX DRAWINGS LIGHT HORIZONTAL}\N{RIGHTWARDS ARROW}')) else: LimArg = prettyForm(*LimArg.right('->')) LimArg = prettyForm(*LimArg.right(self._print(z0))) if str(dir) == '+-' or z0 in (S.Infinity, S.NegativeInfinity): dir = "" else: if self._use_unicode: dir = u'\N{SUPERSCRIPT PLUS SIGN}' if str(dir) == "+" else u'\N{SUPERSCRIPT MINUS}' LimArg = prettyForm(*LimArg.right(self._print(dir))) Lim = prettyForm(*Lim.below(LimArg)) Lim = prettyForm(*Lim.right(E), binding=prettyForm.MUL) return Lim def _print_matrix_contents(self, e): """ This method factors out what is essentially grid printing. """ M = e # matrix Ms = {} # i,j -> pretty(M[i,j]) for i in range(M.rows): for j in range(M.cols): Ms[i, j] = self._print(M[i, j]) # h- and v- spacers hsep = 2 vsep = 1 # max width for columns maxw = [-1] * M.cols for j in range(M.cols): maxw[j] = max([Ms[i, j].width() for i in range(M.rows)] or [0]) # drawing result D = None for i in range(M.rows): D_row = None for j in range(M.cols): s = Ms[i, j] # reshape s to maxw # XXX this should be generalized, and go to stringPict.reshape ? assert s.width() <= maxw[j] # hcenter it, +0.5 to the right 2 # ( it's better to align formula starts for say 0 and r ) # XXX this is not good in all cases -- maybe introduce vbaseline? wdelta = maxw[j] - s.width() wleft = wdelta // 2 wright = wdelta - wleft s = prettyForm(*s.right(' '*wright)) s = prettyForm(*s.left(' '*wleft)) # we don't need vcenter cells -- this is automatically done in # a pretty way because when their baselines are taking into # account in .right() if D_row is None: D_row = s # first box in a row continue D_row = prettyForm(*D_row.right(' '*hsep)) # h-spacer D_row = prettyForm(*D_row.right(s)) if D is None: D = D_row # first row in a picture continue # v-spacer for _ in range(vsep): D = prettyForm(*D.below(' ')) D = prettyForm(*D.below(D_row)) if D is None: D = prettyForm('') # Empty Matrix return D def _print_MatrixBase(self, e): D = self._print_matrix_contents(e) D.baseline = D.height()//2 D = prettyForm(*D.parens('[', ']')) return D _print_ImmutableMatrix = _print_MatrixBase _print_Matrix = _print_MatrixBase def _print_TensorProduct(self, expr): # This should somehow share the code with _print_WedgeProduct: circled_times = "\u2297" return self._print_seq(expr.args, None, None, circled_times, parenthesize=lambda x: precedence_traditional(x) <= PRECEDENCE["Mul"]) def _print_WedgeProduct(self, expr): # This should somehow share the code with _print_TensorProduct: wedge_symbol = u"\u2227" return self._print_seq(expr.args, None, None, wedge_symbol, parenthesize=lambda x: precedence_traditional(x) <= PRECEDENCE["Mul"]) def _print_Trace(self, e): D = self._print(e.arg) D = prettyForm(*D.parens('(',')')) D.baseline = D.height()//2 D = prettyForm(*D.left('\n'*(0) + 'tr')) return D def _print_MatrixElement(self, expr): from sympy.matrices import MatrixSymbol from sympy import Symbol if (isinstance(expr.parent, MatrixSymbol) and expr.i.is_number and expr.j.is_number): return self._print( Symbol(expr.parent.name + '_%d%d' % (expr.i, expr.j))) else: prettyFunc = self._print(expr.parent) prettyFunc = prettyForm(*prettyFunc.parens()) prettyIndices = self._print_seq((expr.i, expr.j), delimiter=', ' ).parens(left='[', right=']')[0] pform = prettyForm(binding=prettyForm.FUNC, *stringPict.next(prettyFunc, prettyIndices)) # store pform parts so it can be reassembled e.g. when powered pform.prettyFunc = prettyFunc pform.prettyArgs = prettyIndices return pform def _print_MatrixSlice(self, m): # XXX works only for applied functions prettyFunc = self._print(m.parent) def ppslice(x): x = list(x) if x[2] == 1: del x[2] if x[1] == x[0] + 1: del x[1] if x[0] == 0: x[0] = '' return prettyForm(*self._print_seq(x, delimiter=':')) prettyArgs = self._print_seq((ppslice(m.rowslice), ppslice(m.colslice)), delimiter=', ').parens(left='[', right=']')[0] pform = prettyForm( binding=prettyForm.FUNC, *stringPict.next(prettyFunc, prettyArgs)) # store pform parts so it can be reassembled e.g. when powered pform.prettyFunc = prettyFunc pform.prettyArgs = prettyArgs return pform def _print_Transpose(self, expr): pform = self._print(expr.arg) from sympy.matrices import MatrixSymbol if not isinstance(expr.arg, MatrixSymbol): pform = prettyForm(*pform.parens()) pform = pform**(prettyForm('T')) return pform def _print_Adjoint(self, expr): pform = self._print(expr.arg) if self._use_unicode: dag = prettyForm(u'\N{DAGGER}') else: dag = prettyForm('+') from sympy.matrices import MatrixSymbol if not isinstance(expr.arg, MatrixSymbol): pform = prettyForm(*pform.parens()) pform = pform**dag return pform def _print_BlockMatrix(self, B): if B.blocks.shape == (1, 1): return self._print(B.blocks[0, 0]) return self._print(B.blocks) def _print_MatAdd(self, expr): s = None for item in expr.args: pform = self._print(item) if s is None: s = pform # First element else: coeff = item.as_coeff_mmul()[0] if _coeff_isneg(S(coeff)): s = prettyForm(*stringPict.next(s, ' ')) pform = self._print(item) else: s = prettyForm(*stringPict.next(s, ' + ')) s = prettyForm(*stringPict.next(s, pform)) return s def _print_MatMul(self, expr): args = list(expr.args) from sympy import Add, MatAdd, HadamardProduct, KroneckerProduct for i, a in enumerate(args): if (isinstance(a, (Add, MatAdd, HadamardProduct, KroneckerProduct)) and len(expr.args) > 1): args[i] = prettyForm(*self._print(a).parens()) else: args[i] = self._print(a) return prettyForm.__mul__(*args) def _print_DotProduct(self, expr): args = list(expr.args) for i, a in enumerate(args): args[i] = self._print(a) return prettyForm.__mul__(*args) def _print_MatPow(self, expr): pform = self._print(expr.base) from sympy.matrices import MatrixSymbol if not isinstance(expr.base, MatrixSymbol): pform = prettyForm(*pform.parens()) pform = pform**(self._print(expr.exp)) return pform def _print_HadamardProduct(self, expr): from sympy import MatAdd, MatMul if self._use_unicode: delim = pretty_atom('Ring') else: delim = '.*' return self._print_seq(expr.args, None, None, delim, parenthesize=lambda x: isinstance(x, (MatAdd, MatMul))) def _print_KroneckerProduct(self, expr): from sympy import MatAdd, MatMul if self._use_unicode: delim = u' \N{N-ARY CIRCLED TIMES OPERATOR} ' else: delim = ' x ' return self._print_seq(expr.args, None, None, delim, parenthesize=lambda x: isinstance(x, (MatAdd, MatMul))) def _print_FunctionMatrix(self, X): D = self._print(X.lamda.expr) D = prettyForm(*D.parens('[', ']')) return D def _print_BasisDependent(self, expr): from sympy.vector import Vector if not self._use_unicode: raise NotImplementedError("ASCII pretty printing of BasisDependent is not implemented") if expr == expr.zero: return prettyForm(expr.zero._pretty_form) o1 = [] vectstrs = [] if isinstance(expr, Vector): items = expr.separate().items() else: items = [(0, expr)] for system, vect in items: inneritems = list(vect.components.items()) inneritems.sort(key = lambda x: x[0].__str__()) for k, v in inneritems: #if the coef of the basis vector is 1 #we skip the 1 if v == 1: o1.append(u"" + k._pretty_form) #Same for -1 elif v == -1: o1.append(u"(-1) " + k._pretty_form) #For a general expr else: #We always wrap the measure numbers in #parentheses arg_str = self._print( v).parens()[0] o1.append(arg_str + ' ' + k._pretty_form) vectstrs.append(k._pretty_form) #outstr = u("").join(o1) if o1[0].startswith(u" + "): o1[0] = o1[0][3:] elif o1[0].startswith(" "): o1[0] = o1[0][1:] #Fixing the newlines lengths = [] strs = [''] flag = [] for i, partstr in enumerate(o1): flag.append(0) # XXX: What is this hack? if '\n' in partstr: tempstr = partstr tempstr = tempstr.replace(vectstrs[i], '') if u'\N{right parenthesis extension}' in tempstr: # If scalar is a fraction for paren in range(len(tempstr)): flag[i] = 1 if tempstr[paren] == u'\N{right parenthesis extension}': tempstr = tempstr[:paren] + u'\N{right parenthesis extension}'\ + ' ' + vectstrs[i] + tempstr[paren + 1:] break elif u'\N{RIGHT PARENTHESIS LOWER HOOK}' in tempstr: flag[i] = 1 tempstr = tempstr.replace(u'\N{RIGHT PARENTHESIS LOWER HOOK}', u'\N{RIGHT PARENTHESIS LOWER HOOK}' + ' ' + vectstrs[i]) else: tempstr = tempstr.replace(u'\N{RIGHT PARENTHESIS UPPER HOOK}', u'\N{RIGHT PARENTHESIS UPPER HOOK}' + ' ' + vectstrs[i]) o1[i] = tempstr o1 = [x.split('\n') for x in o1] n_newlines = max([len(x) for x in o1]) # Width of part in its pretty form if 1 in flag: # If there was a fractional scalar for i, parts in enumerate(o1): if len(parts) == 1: # If part has no newline parts.insert(0, ' ' * (len(parts[0]))) flag[i] = 1 for i, parts in enumerate(o1): lengths.append(len(parts[flag[i]])) for j in range(n_newlines): if j+1 <= len(parts): if j >= len(strs): strs.append(' ' * (sum(lengths[:-1]) + 3*(len(lengths)-1))) if j == flag[i]: strs[flag[i]] += parts[flag[i]] + ' + ' else: strs[j] += parts[j] + ' '*(lengths[-1] - len(parts[j])+ 3) else: if j >= len(strs): strs.append(' ' * (sum(lengths[:-1]) + 3*(len(lengths)-1))) strs[j] += ' '*(lengths[-1]+3) return prettyForm(u'\n'.join([s[:-3] for s in strs])) def _print_NDimArray(self, expr): from sympy import ImmutableMatrix if expr.rank() == 0: return self._print(expr[()]) level_str = [[]] + [[] for i in range(expr.rank())] shape_ranges = [list(range(i)) for i in expr.shape] # leave eventual matrix elements unflattened mat = lambda x: ImmutableMatrix(x, evaluate=False) for outer_i in itertools.product(*shape_ranges): level_str[-1].append(expr[outer_i]) even = True for back_outer_i in range(expr.rank()-1, -1, -1): if len(level_str[back_outer_i+1]) < expr.shape[back_outer_i]: break if even: level_str[back_outer_i].append(level_str[back_outer_i+1]) else: level_str[back_outer_i].append(mat( level_str[back_outer_i+1])) if len(level_str[back_outer_i + 1]) == 1: level_str[back_outer_i][-1] = mat( [[level_str[back_outer_i][-1]]]) even = not even level_str[back_outer_i+1] = [] out_expr = level_str[0][0] if expr.rank() % 2 == 1: out_expr = mat([out_expr]) return self._print(out_expr) _print_ImmutableDenseNDimArray = _print_NDimArray _print_ImmutableSparseNDimArray = _print_NDimArray _print_MutableDenseNDimArray = _print_NDimArray _print_MutableSparseNDimArray = _print_NDimArray def _printer_tensor_indices(self, name, indices, index_map={}): center = stringPict(name) top = stringPict(" "*center.width()) bot = stringPict(" "*center.width()) last_valence = None prev_map = None for i, index in enumerate(indices): indpic = self._print(index.args[0]) if ((index in index_map) or prev_map) and last_valence == index.is_up: if index.is_up: top = prettyForm(*stringPict.next(top, ",")) else: bot = prettyForm(*stringPict.next(bot, ",")) if index in index_map: indpic = prettyForm(*stringPict.next(indpic, "=")) indpic = prettyForm(*stringPict.next(indpic, self._print(index_map[index]))) prev_map = True else: prev_map = False if index.is_up: top = stringPict(*top.right(indpic)) center = stringPict(*center.right(" "*indpic.width())) bot = stringPict(*bot.right(" "*indpic.width())) else: bot = stringPict(*bot.right(indpic)) center = stringPict(*center.right(" "*indpic.width())) top = stringPict(*top.right(" "*indpic.width())) last_valence = index.is_up pict = prettyForm(*center.above(top)) pict = prettyForm(*pict.below(bot)) return pict def _print_Tensor(self, expr): name = expr.args[0].name indices = expr.get_indices() return self._printer_tensor_indices(name, indices) def _print_TensorElement(self, expr): name = expr.expr.args[0].name indices = expr.expr.get_indices() index_map = expr.index_map return self._printer_tensor_indices(name, indices, index_map) def _print_TensMul(self, expr): sign, args = expr._get_args_for_traditional_printer() args = [ prettyForm(*self._print(i).parens()) if precedence_traditional(i) < PRECEDENCE["Mul"] else self._print(i) for i in args ] pform = prettyForm.__mul__(*args) if sign: return prettyForm(*pform.left(sign)) else: return pform def _print_TensAdd(self, expr): args = [ prettyForm(*self._print(i).parens()) if precedence_traditional(i) < PRECEDENCE["Mul"] else self._print(i) for i in expr.args ] return prettyForm.__add__(*args) def _print_TensorIndex(self, expr): sym = expr.args[0] if not expr.is_up: sym = -sym return self._print(sym) def _print_PartialDerivative(self, deriv): if self._use_unicode: deriv_symbol = U('PARTIAL DIFFERENTIAL') else: deriv_symbol = r'd' x = None for variable in reversed(deriv.variables): s = self._print(variable) ds = prettyForm(*s.left(deriv_symbol)) if x is None: x = ds else: x = prettyForm(*x.right(' ')) x = prettyForm(*x.right(ds)) f = prettyForm( binding=prettyForm.FUNC, *self._print(deriv.expr).parens()) pform = prettyForm(deriv_symbol) pform = prettyForm(*pform.below(stringPict.LINE, x)) pform.baseline = pform.baseline + 1 pform = prettyForm(*stringPict.next(pform, f)) pform.binding = prettyForm.MUL return pform def _print_Piecewise(self, pexpr): P = {} for n, ec in enumerate(pexpr.args): P[n, 0] = self._print(ec.expr) if ec.cond == True: P[n, 1] = prettyForm('otherwise') else: P[n, 1] = prettyForm( *prettyForm('for ').right(self._print(ec.cond))) hsep = 2 vsep = 1 len_args = len(pexpr.args) # max widths maxw = [max([P[i, j].width() for i in range(len_args)]) for j in range(2)] # FIXME: Refactor this code and matrix into some tabular environment. # drawing result D = None for i in range(len_args): D_row = None for j in range(2): p = P[i, j] assert p.width() <= maxw[j] wdelta = maxw[j] - p.width() wleft = wdelta // 2 wright = wdelta - wleft p = prettyForm(*p.right(' '*wright)) p = prettyForm(*p.left(' '*wleft)) if D_row is None: D_row = p continue D_row = prettyForm(*D_row.right(' '*hsep)) # h-spacer D_row = prettyForm(*D_row.right(p)) if D is None: D = D_row # first row in a picture continue # v-spacer for _ in range(vsep): D = prettyForm(*D.below(' ')) D = prettyForm(*D.below(D_row)) D = prettyForm(*D.parens('{', '')) D.baseline = D.height()//2 D.binding = prettyForm.OPEN return D def _print_ITE(self, ite): from sympy.functions.elementary.piecewise import Piecewise return self._print(ite.rewrite(Piecewise)) def _hprint_vec(self, v): D = None for a in v: p = a if D is None: D = p else: D = prettyForm(*D.right(', ')) D = prettyForm(*D.right(p)) if D is None: D = stringPict(' ') return D def _hprint_vseparator(self, p1, p2): tmp = prettyForm(*p1.right(p2)) sep = stringPict(vobj('|', tmp.height()), baseline=tmp.baseline) return prettyForm(*p1.right(sep, p2)) def _print_hyper(self, e): # FIXME refactor Matrix, Piecewise, and this into a tabular environment ap = [self._print(a) for a in e.ap] bq = [self._print(b) for b in e.bq] P = self._print(e.argument) P.baseline = P.height()//2 # Drawing result - first create the ap, bq vectors D = None for v in [ap, bq]: D_row = self._hprint_vec(v) if D is None: D = D_row # first row in a picture else: D = prettyForm(*D.below(' ')) D = prettyForm(*D.below(D_row)) # make sure that the argument `z' is centred vertically D.baseline = D.height()//2 # insert horizontal separator P = prettyForm(*P.left(' ')) D = prettyForm(*D.right(' ')) # insert separating `|` D = self._hprint_vseparator(D, P) # add parens D = prettyForm(*D.parens('(', ')')) # create the F symbol above = D.height()//2 - 1 below = D.height() - above - 1 sz, t, b, add, img = annotated('F') F = prettyForm('\n' * (above - t) + img + '\n' * (below - b), baseline=above + sz) add = (sz + 1)//2 F = prettyForm(*F.left(self._print(len(e.ap)))) F = prettyForm(*F.right(self._print(len(e.bq)))) F.baseline = above + add D = prettyForm(*F.right(' ', D)) return D def _print_meijerg(self, e): # FIXME refactor Matrix, Piecewise, and this into a tabular environment v = {} v[(0, 0)] = [self._print(a) for a in e.an] v[(0, 1)] = [self._print(a) for a in e.aother] v[(1, 0)] = [self._print(b) for b in e.bm] v[(1, 1)] = [self._print(b) for b in e.bother] P = self._print(e.argument) P.baseline = P.height()//2 vp = {} for idx in v: vp[idx] = self._hprint_vec(v[idx]) for i in range(2): maxw = max(vp[(0, i)].width(), vp[(1, i)].width()) for j in range(2): s = vp[(j, i)] left = (maxw - s.width()) // 2 right = maxw - left - s.width() s = prettyForm(*s.left(' ' * left)) s = prettyForm(*s.right(' ' * right)) vp[(j, i)] = s D1 = prettyForm(*vp[(0, 0)].right(' ', vp[(0, 1)])) D1 = prettyForm(*D1.below(' ')) D2 = prettyForm(*vp[(1, 0)].right(' ', vp[(1, 1)])) D = prettyForm(*D1.below(D2)) # make sure that the argument `z' is centred vertically D.baseline = D.height()//2 # insert horizontal separator P = prettyForm(*P.left(' ')) D = prettyForm(*D.right(' ')) # insert separating `|` D = self._hprint_vseparator(D, P) # add parens D = prettyForm(*D.parens('(', ')')) # create the G symbol above = D.height()//2 - 1 below = D.height() - above - 1 sz, t, b, add, img = annotated('G') F = prettyForm('\n' * (above - t) + img + '\n' * (below - b), baseline=above + sz) pp = self._print(len(e.ap)) pq = self._print(len(e.bq)) pm = self._print(len(e.bm)) pn = self._print(len(e.an)) def adjust(p1, p2): diff = p1.width() - p2.width() if diff == 0: return p1, p2 elif diff > 0: return p1, prettyForm(*p2.left(' '*diff)) else: return prettyForm(*p1.left(' '*-diff)), p2 pp, pm = adjust(pp, pm) pq, pn = adjust(pq, pn) pu = prettyForm(*pm.right(', ', pn)) pl = prettyForm(*pp.right(', ', pq)) ht = F.baseline - above - 2 if ht > 0: pu = prettyForm(*pu.below('\n'*ht)) p = prettyForm(*pu.below(pl)) F.baseline = above F = prettyForm(*F.right(p)) F.baseline = above + add D = prettyForm(*F.right(' ', D)) return D def _print_ExpBase(self, e): # TODO should exp_polar be printed differently? # what about exp_polar(0), exp_polar(1)? base = prettyForm(pretty_atom('Exp1', 'e')) return base ** self._print(e.args[0]) def _print_Function(self, e, sort=False, func_name=None): # optional argument func_name for supplying custom names # XXX works only for applied functions func = e.func args = e.args if sort: args = sorted(args, key=default_sort_key) if not func_name: func_name = func.__name__ prettyFunc = self._print(Symbol(func_name)) prettyArgs = prettyForm(*self._print_seq(args).parens()) pform = prettyForm( binding=prettyForm.FUNC, *stringPict.next(prettyFunc, prettyArgs)) # store pform parts so it can be reassembled e.g. when powered pform.prettyFunc = prettyFunc pform.prettyArgs = prettyArgs return pform @property def _special_function_classes(self): from sympy.functions.special.tensor_functions import KroneckerDelta from sympy.functions.special.gamma_functions import gamma, lowergamma from sympy.functions.special.zeta_functions import lerchphi from sympy.functions.special.beta_functions import beta from sympy.functions.special.delta_functions import DiracDelta from sympy.functions.special.error_functions import Chi return {KroneckerDelta: [greek_unicode['delta'], 'delta'], gamma: [greek_unicode['Gamma'], 'Gamma'], lerchphi: [greek_unicode['Phi'], 'lerchphi'], lowergamma: [greek_unicode['gamma'], 'gamma'], beta: [greek_unicode['Beta'], 'B'], DiracDelta: [greek_unicode['delta'], 'delta'], Chi: ['Chi', 'Chi']} def _print_FunctionClass(self, expr): for cls in self._special_function_classes: if issubclass(expr, cls) and expr.__name__ == cls.__name__: if self._use_unicode: return prettyForm(self._special_function_classes[cls][0]) else: return prettyForm(self._special_function_classes[cls][1]) func_name = expr.__name__ return prettyForm(pretty_symbol(func_name)) def _print_GeometryEntity(self, expr): # GeometryEntity is based on Tuple but should not print like a Tuple return self.emptyPrinter(expr) def _print_lerchphi(self, e): func_name = greek_unicode['Phi'] if self._use_unicode else 'lerchphi' return self._print_Function(e, func_name=func_name) def _print_Lambda(self, e): vars, expr = e.args if self._use_unicode: arrow = u" \N{RIGHTWARDS ARROW FROM BAR} " else: arrow = " -> " if len(vars) == 1: var_form = self._print(vars[0]) else: var_form = self._print(tuple(vars)) return prettyForm(*stringPict.next(var_form, arrow, self._print(expr)), binding=8) def _print_Order(self, expr): pform = self._print(expr.expr) if (expr.point and any(p != S.Zero for p in expr.point)) or \ len(expr.variables) > 1: pform = prettyForm(*pform.right("; ")) if len(expr.variables) > 1: pform = prettyForm(*pform.right(self._print(expr.variables))) elif len(expr.variables): pform = prettyForm(*pform.right(self._print(expr.variables[0]))) if self._use_unicode: pform = prettyForm(*pform.right(u" \N{RIGHTWARDS ARROW} ")) else: pform = prettyForm(*pform.right(" -> ")) if len(expr.point) > 1: pform = prettyForm(*pform.right(self._print(expr.point))) else: pform = prettyForm(*pform.right(self._print(expr.point[0]))) pform = prettyForm(*pform.parens()) pform = prettyForm(*pform.left("O")) return pform def _print_SingularityFunction(self, e): if self._use_unicode: shift = self._print(e.args[0]-e.args[1]) n = self._print(e.args[2]) base = prettyForm("<") base = prettyForm(*base.right(shift)) base = prettyForm(*base.right(">")) pform = base**n return pform else: n = self._print(e.args[2]) shift = self._print(e.args[0]-e.args[1]) base = self._print_seq(shift, "<", ">", ' ') return base**n def _print_beta(self, e): func_name = greek_unicode['Beta'] if self._use_unicode else 'B' return self._print_Function(e, func_name=func_name) def _print_gamma(self, e): func_name = greek_unicode['Gamma'] if self._use_unicode else 'Gamma' return self._print_Function(e, func_name=func_name) def _print_uppergamma(self, e): func_name = greek_unicode['Gamma'] if self._use_unicode else 'Gamma' return self._print_Function(e, func_name=func_name) def _print_lowergamma(self, e): func_name = greek_unicode['gamma'] if self._use_unicode else 'lowergamma' return self._print_Function(e, func_name=func_name) def _print_DiracDelta(self, e): if self._use_unicode: if len(e.args) == 2: a = prettyForm(greek_unicode['delta']) b = self._print(e.args[1]) b = prettyForm(*b.parens()) c = self._print(e.args[0]) c = prettyForm(*c.parens()) pform = a**b pform = prettyForm(*pform.right(' ')) pform = prettyForm(*pform.right(c)) return pform pform = self._print(e.args[0]) pform = prettyForm(*pform.parens()) pform = prettyForm(*pform.left(greek_unicode['delta'])) return pform else: return self._print_Function(e) def _print_expint(self, e): from sympy import Function if e.args[0].is_Integer and self._use_unicode: return self._print_Function(Function('E_%s' % e.args[0])(e.args[1])) return self._print_Function(e) def _print_Chi(self, e): # This needs a special case since otherwise it comes out as greek # letter chi... prettyFunc = prettyForm("Chi") prettyArgs = prettyForm(*self._print_seq(e.args).parens()) pform = prettyForm( binding=prettyForm.FUNC, *stringPict.next(prettyFunc, prettyArgs)) # store pform parts so it can be reassembled e.g. when powered pform.prettyFunc = prettyFunc pform.prettyArgs = prettyArgs return pform def _print_elliptic_e(self, e): pforma0 = self._print(e.args[0]) if len(e.args) == 1: pform = pforma0 else: pforma1 = self._print(e.args[1]) pform = self._hprint_vseparator(pforma0, pforma1) pform = prettyForm(*pform.parens()) pform = prettyForm(*pform.left('E')) return pform def _print_elliptic_k(self, e): pform = self._print(e.args[0]) pform = prettyForm(*pform.parens()) pform = prettyForm(*pform.left('K')) return pform def _print_elliptic_f(self, e): pforma0 = self._print(e.args[0]) pforma1 = self._print(e.args[1]) pform = self._hprint_vseparator(pforma0, pforma1) pform = prettyForm(*pform.parens()) pform = prettyForm(*pform.left('F')) return pform def _print_elliptic_pi(self, e): name = greek_unicode['Pi'] if self._use_unicode else 'Pi' pforma0 = self._print(e.args[0]) pforma1 = self._print(e.args[1]) if len(e.args) == 2: pform = self._hprint_vseparator(pforma0, pforma1) else: pforma2 = self._print(e.args[2]) pforma = self._hprint_vseparator(pforma1, pforma2) pforma = prettyForm(*pforma.left('; ')) pform = prettyForm(*pforma.left(pforma0)) pform = prettyForm(*pform.parens()) pform = prettyForm(*pform.left(name)) return pform def _print_GoldenRatio(self, expr): if self._use_unicode: return prettyForm(pretty_symbol('phi')) return self._print(Symbol("GoldenRatio")) def _print_EulerGamma(self, expr): if self._use_unicode: return prettyForm(pretty_symbol('gamma')) return self._print(Symbol("EulerGamma")) def _print_Mod(self, expr): pform = self._print(expr.args[0]) if pform.binding > prettyForm.MUL: pform = prettyForm(*pform.parens()) pform = prettyForm(*pform.right(' mod ')) pform = prettyForm(*pform.right(self._print(expr.args[1]))) pform.binding = prettyForm.OPEN return pform def _print_Add(self, expr, order=None): if self.order == 'none': terms = list(expr.args) else: terms = self._as_ordered_terms(expr, order=order) pforms, indices = [], [] def pretty_negative(pform, index): """Prepend a minus sign to a pretty form. """ #TODO: Move this code to prettyForm if index == 0: if pform.height() > 1: pform_neg = '- ' else: pform_neg = '-' else: pform_neg = ' - ' if (pform.binding > prettyForm.NEG or pform.binding == prettyForm.ADD): p = stringPict(*pform.parens()) else: p = pform p = stringPict.next(pform_neg, p) # Lower the binding to NEG, even if it was higher. Otherwise, it # will print as a + ( - (b)), instead of a - (b). return prettyForm(binding=prettyForm.NEG, *p) for i, term in enumerate(terms): if term.is_Mul and _coeff_isneg(term): coeff, other = term.as_coeff_mul(rational=False) pform = self._print(Mul(-coeff, *other, evaluate=False)) pforms.append(pretty_negative(pform, i)) elif term.is_Rational and term.q > 1: pforms.append(None) indices.append(i) elif term.is_Number and term < 0: pform = self._print(-term) pforms.append(pretty_negative(pform, i)) elif term.is_Relational: pforms.append(prettyForm(*self._print(term).parens())) else: pforms.append(self._print(term)) if indices: large = True for pform in pforms: if pform is not None and pform.height() > 1: break else: large = False for i in indices: term, negative = terms[i], False if term < 0: term, negative = -term, True if large: pform = prettyForm(str(term.p))/prettyForm(str(term.q)) else: pform = self._print(term) if negative: pform = pretty_negative(pform, i) pforms[i] = pform return prettyForm.__add__(*pforms) def _print_Mul(self, product): from sympy.physics.units import Quantity a = [] # items in the numerator b = [] # items that are in the denominator (if any) if self.order not in ('old', 'none'): args = product.as_ordered_factors() else: args = list(product.args) # If quantities are present append them at the back args = sorted(args, key=lambda x: isinstance(x, Quantity) or (isinstance(x, Pow) and isinstance(x.base, Quantity))) # Gather terms for numerator/denominator for item in args: if item.is_commutative and item.is_Pow and item.exp.is_Rational and item.exp.is_negative: if item.exp != -1: b.append(Pow(item.base, -item.exp, evaluate=False)) else: b.append(Pow(item.base, -item.exp)) elif item.is_Rational and item is not S.Infinity: if item.p != 1: a.append( Rational(item.p) ) if item.q != 1: b.append( Rational(item.q) ) else: a.append(item) from sympy import Integral, Piecewise, Product, Sum # Convert to pretty forms. Add parens to Add instances if there # is more than one term in the numer/denom for i in range(0, len(a)): if (a[i].is_Add and len(a) > 1) or (i != len(a) - 1 and isinstance(a[i], (Integral, Piecewise, Product, Sum))): a[i] = prettyForm(*self._print(a[i]).parens()) elif a[i].is_Relational: a[i] = prettyForm(*self._print(a[i]).parens()) else: a[i] = self._print(a[i]) for i in range(0, len(b)): if (b[i].is_Add and len(b) > 1) or (i != len(b) - 1 and isinstance(b[i], (Integral, Piecewise, Product, Sum))): b[i] = prettyForm(*self._print(b[i]).parens()) else: b[i] = self._print(b[i]) # Construct a pretty form if len(b) == 0: return prettyForm.__mul__(*a) else: if len(a) == 0: a.append( self._print(S.One) ) return prettyForm.__mul__(*a)/prettyForm.__mul__(*b) # A helper function for _print_Pow to print x**(1/n) def _print_nth_root(self, base, expt): bpretty = self._print(base) # In very simple cases, use a single-char root sign if (self._settings['use_unicode_sqrt_char'] and self._use_unicode and expt is S.Half and bpretty.height() == 1 and (bpretty.width() == 1 or (base.is_Integer and base.is_nonnegative))): return prettyForm(*bpretty.left(u'\N{SQUARE ROOT}')) # Construct root sign, start with the \/ shape _zZ = xobj('/', 1) rootsign = xobj('\\', 1) + _zZ # Make exponent number to put above it if isinstance(expt, Rational): exp = str(expt.q) if exp == '2': exp = '' else: exp = str(expt.args[0]) exp = exp.ljust(2) if len(exp) > 2: rootsign = ' '*(len(exp) - 2) + rootsign # Stack the exponent rootsign = stringPict(exp + '\n' + rootsign) rootsign.baseline = 0 # Diagonal: length is one less than height of base linelength = bpretty.height() - 1 diagonal = stringPict('\n'.join( ' '*(linelength - i - 1) + _zZ + ' '*i for i in range(linelength) )) # Put baseline just below lowest line: next to exp diagonal.baseline = linelength - 1 # Make the root symbol rootsign = prettyForm(*rootsign.right(diagonal)) # Det the baseline to match contents to fix the height # but if the height of bpretty is one, the rootsign must be one higher rootsign.baseline = max(1, bpretty.baseline) #build result s = prettyForm(hobj('_', 2 + bpretty.width())) s = prettyForm(*bpretty.above(s)) s = prettyForm(*s.left(rootsign)) return s def _print_Pow(self, power): from sympy.simplify.simplify import fraction b, e = power.as_base_exp() if power.is_commutative: if e is S.NegativeOne: return prettyForm("1")/self._print(b) n, d = fraction(e) if n is S.One and d.is_Atom and not e.is_Integer and self._settings['root_notation']: return self._print_nth_root(b, e) if e.is_Rational and e < 0: return prettyForm("1")/self._print(Pow(b, -e, evaluate=False)) if b.is_Relational: return prettyForm(*self._print(b).parens()).__pow__(self._print(e)) return self._print(b)**self._print(e) def _print_UnevaluatedExpr(self, expr): return self._print(expr.args[0]) def __print_numer_denom(self, p, q): if q == 1: if p < 0: return prettyForm(str(p), binding=prettyForm.NEG) else: return prettyForm(str(p)) elif abs(p) >= 10 and abs(q) >= 10: # If more than one digit in numer and denom, print larger fraction if p < 0: return prettyForm(str(p), binding=prettyForm.NEG)/prettyForm(str(q)) # Old printing method: #pform = prettyForm(str(-p))/prettyForm(str(q)) #return prettyForm(binding=prettyForm.NEG, *pform.left('- ')) else: return prettyForm(str(p))/prettyForm(str(q)) else: return None def _print_Rational(self, expr): result = self.__print_numer_denom(expr.p, expr.q) if result is not None: return result else: return self.emptyPrinter(expr) def _print_Fraction(self, expr): result = self.__print_numer_denom(expr.numerator, expr.denominator) if result is not None: return result else: return self.emptyPrinter(expr) def _print_ProductSet(self, p): if len(p.sets) > 1 and not has_variety(p.sets): from sympy import Pow return self._print(Pow(p.sets[0], len(p.sets), evaluate=False)) else: prod_char = u"\N{MULTIPLICATION SIGN}" if self._use_unicode else 'x' return self._print_seq(p.sets, None, None, ' %s ' % prod_char, parenthesize=lambda set: set.is_Union or set.is_Intersection or set.is_ProductSet) def _print_FiniteSet(self, s): items = sorted(s.args, key=default_sort_key) return self._print_seq(items, '{', '}', ', ' ) def _print_Range(self, s): if self._use_unicode: dots = u"\N{HORIZONTAL ELLIPSIS}" else: dots = '...' if s.start.is_infinite: printset = dots, s[-1] - s.step, s[-1] elif s.stop.is_infinite: it = iter(s) printset = next(it), next(it), dots elif len(s) > 4: it = iter(s) printset = next(it), next(it), dots, s[-1] else: printset = tuple(s) return self._print_seq(printset, '{', '}', ', ' ) def _print_Interval(self, i): if i.start == i.end: return self._print_seq(i.args[:1], '{', '}') else: if i.left_open: left = '(' else: left = '[' if i.right_open: right = ')' else: right = ']' return self._print_seq(i.args[:2], left, right) def _print_AccumulationBounds(self, i): left = '<' right = '>' return self._print_seq(i.args[:2], left, right) def _print_Intersection(self, u): delimiter = ' %s ' % pretty_atom('Intersection', 'n') return self._print_seq(u.args, None, None, delimiter, parenthesize=lambda set: set.is_ProductSet or set.is_Union or set.is_Complement) def _print_Union(self, u): union_delimiter = ' %s ' % pretty_atom('Union', 'U') return self._print_seq(u.args, None, None, union_delimiter, parenthesize=lambda set: set.is_ProductSet or set.is_Intersection or set.is_Complement) def _print_SymmetricDifference(self, u): if not self._use_unicode: raise NotImplementedError("ASCII pretty printing of SymmetricDifference is not implemented") sym_delimeter = ' %s ' % pretty_atom('SymmetricDifference') return self._print_seq(u.args, None, None, sym_delimeter) def _print_Complement(self, u): delimiter = r' \ ' return self._print_seq(u.args, None, None, delimiter, parenthesize=lambda set: set.is_ProductSet or set.is_Intersection or set.is_Union) def _print_ImageSet(self, ts): if self._use_unicode: inn = u"\N{SMALL ELEMENT OF}" else: inn = 'in' variables = ts.lamda.variables expr = self._print(ts.lamda.expr) bar = self._print("|") sets = [self._print(i) for i in ts.args[1:]] if len(sets) == 1: return self._print_seq((expr, bar, variables[0], inn, sets[0]), "{", "}", ' ') else: pargs = tuple(j for var, setv in zip(variables, sets) for j in (var, inn, setv, ",")) return self._print_seq((expr, bar) + pargs[:-1], "{", "}", ' ') def _print_ConditionSet(self, ts): if self._use_unicode: inn = u"\N{SMALL ELEMENT OF}" # using _and because and is a keyword and it is bad practice to # overwrite them _and = u"\N{LOGICAL AND}" else: inn = 'in' _and = 'and' variables = self._print_seq(Tuple(ts.sym)) as_expr = getattr(ts.condition, 'as_expr', None) if as_expr is not None: cond = self._print(ts.condition.as_expr()) else: cond = self._print(ts.condition) if self._use_unicode: cond = self._print_seq(cond, "(", ")") bar = self._print("|") if ts.base_set is S.UniversalSet: return self._print_seq((variables, bar, cond), "{", "}", ' ') base = self._print(ts.base_set) return self._print_seq((variables, bar, variables, inn, base, _and, cond), "{", "}", ' ') def _print_ComplexRegion(self, ts): if self._use_unicode: inn = u"\N{SMALL ELEMENT OF}" else: inn = 'in' variables = self._print_seq(ts.variables) expr = self._print(ts.expr) bar = self._print("|") prodsets = self._print(ts.sets) return self._print_seq((expr, bar, variables, inn, prodsets), "{", "}", ' ') def _print_Contains(self, e): var, set = e.args if self._use_unicode: el = u" \N{ELEMENT OF} " return prettyForm(*stringPict.next(self._print(var), el, self._print(set)), binding=8) else: return prettyForm(sstr(e)) def _print_FourierSeries(self, s): if self._use_unicode: dots = u"\N{HORIZONTAL ELLIPSIS}" else: dots = '...' return self._print_Add(s.truncate()) + self._print(dots) def _print_FormalPowerSeries(self, s): return self._print_Add(s.infinite) def _print_SetExpr(self, se): pretty_set = prettyForm(*self._print(se.set).parens()) pretty_name = self._print(Symbol("SetExpr")) return prettyForm(*pretty_name.right(pretty_set)) def _print_SeqFormula(self, s): if self._use_unicode: dots = u"\N{HORIZONTAL ELLIPSIS}" else: dots = '...' if len(s.start.free_symbols) > 0 or len(s.stop.free_symbols) > 0: raise NotImplementedError("Pretty printing of sequences with symbolic bound not implemented") if s.start is S.NegativeInfinity: stop = s.stop printset = (dots, s.coeff(stop - 3), s.coeff(stop - 2), s.coeff(stop - 1), s.coeff(stop)) elif s.stop is S.Infinity or s.length > 4: printset = s[:4] printset.append(dots) printset = tuple(printset) else: printset = tuple(s) return self._print_list(printset) _print_SeqPer = _print_SeqFormula _print_SeqAdd = _print_SeqFormula _print_SeqMul = _print_SeqFormula def _print_seq(self, seq, left=None, right=None, delimiter=', ', parenthesize=lambda x: False): s = None try: for item in seq: pform = self._print(item) if parenthesize(item): pform = prettyForm(*pform.parens()) if s is None: # first element s = pform else: # XXX: Under the tests from #15686 this raises: # AttributeError: 'Fake' object has no attribute 'baseline' # This is caught below but that is not the right way to # fix it. s = prettyForm(*stringPict.next(s, delimiter)) s = prettyForm(*stringPict.next(s, pform)) if s is None: s = stringPict('') except AttributeError: s = None for item in seq: pform = self.doprint(item) if parenthesize(item): pform = prettyForm(*pform.parens()) if s is None: # first element s = pform else : s = prettyForm(*stringPict.next(s, delimiter)) s = prettyForm(*stringPict.next(s, pform)) if s is None: s = stringPict('') s = prettyForm(*s.parens(left, right, ifascii_nougly=True)) return s def join(self, delimiter, args): pform = None for arg in args: if pform is None: pform = arg else: pform = prettyForm(*pform.right(delimiter)) pform = prettyForm(*pform.right(arg)) if pform is None: return prettyForm("") else: return pform def _print_list(self, l): return self._print_seq(l, '[', ']') def _print_tuple(self, t): if len(t) == 1: ptuple = prettyForm(*stringPict.next(self._print(t[0]), ',')) return prettyForm(*ptuple.parens('(', ')', ifascii_nougly=True)) else: return self._print_seq(t, '(', ')') def _print_Tuple(self, expr): return self._print_tuple(expr) def _print_dict(self, d): keys = sorted(d.keys(), key=default_sort_key) items = [] for k in keys: K = self._print(k) V = self._print(d[k]) s = prettyForm(*stringPict.next(K, ': ', V)) items.append(s) return self._print_seq(items, '{', '}') def _print_Dict(self, d): return self._print_dict(d) def _print_set(self, s): if not s: return prettyForm('set()') items = sorted(s, key=default_sort_key) pretty = self._print_seq(items) pretty = prettyForm(*pretty.parens('{', '}', ifascii_nougly=True)) return pretty def _print_frozenset(self, s): if not s: return prettyForm('frozenset()') items = sorted(s, key=default_sort_key) pretty = self._print_seq(items) pretty = prettyForm(*pretty.parens('{', '}', ifascii_nougly=True)) pretty = prettyForm(*pretty.parens('(', ')', ifascii_nougly=True)) pretty = prettyForm(*stringPict.next(type(s).__name__, pretty)) return pretty def _print_PolyRing(self, ring): return prettyForm(sstr(ring)) def _print_FracField(self, field): return prettyForm(sstr(field)) def _print_FreeGroupElement(self, elm): return prettyForm(str(elm)) def _print_PolyElement(self, poly): return prettyForm(sstr(poly)) def _print_FracElement(self, frac): return prettyForm(sstr(frac)) def _print_AlgebraicNumber(self, expr): if expr.is_aliased: return self._print(expr.as_poly().as_expr()) else: return self._print(expr.as_expr()) def _print_ComplexRootOf(self, expr): args = [self._print_Add(expr.expr, order='lex'), expr.index] pform = prettyForm(*self._print_seq(args).parens()) pform = prettyForm(*pform.left('CRootOf')) return pform def _print_RootSum(self, expr): args = [self._print_Add(expr.expr, order='lex')] if expr.fun is not S.IdentityFunction: args.append(self._print(expr.fun)) pform = prettyForm(*self._print_seq(args).parens()) pform = prettyForm(*pform.left('RootSum')) return pform def _print_FiniteField(self, expr): if self._use_unicode: form = u'\N{DOUBLE-STRUCK CAPITAL Z}_%d' else: form = 'GF(%d)' return prettyForm(pretty_symbol(form % expr.mod)) def _print_IntegerRing(self, expr): if self._use_unicode: return prettyForm(u'\N{DOUBLE-STRUCK CAPITAL Z}') else: return prettyForm('ZZ') def _print_RationalField(self, expr): if self._use_unicode: return prettyForm(u'\N{DOUBLE-STRUCK CAPITAL Q}') else: return prettyForm('QQ') def _print_RealField(self, domain): if self._use_unicode: prefix = u'\N{DOUBLE-STRUCK CAPITAL R}' else: prefix = 'RR' if domain.has_default_precision: return prettyForm(prefix) else: return self._print(pretty_symbol(prefix + "_" + str(domain.precision))) def _print_ComplexField(self, domain): if self._use_unicode: prefix = u'\N{DOUBLE-STRUCK CAPITAL C}' else: prefix = 'CC' if domain.has_default_precision: return prettyForm(prefix) else: return self._print(pretty_symbol(prefix + "_" + str(domain.precision))) def _print_PolynomialRing(self, expr): args = list(expr.symbols) if not expr.order.is_default: order = prettyForm(*prettyForm("order=").right(self._print(expr.order))) args.append(order) pform = self._print_seq(args, '[', ']') pform = prettyForm(*pform.left(self._print(expr.domain))) return pform def _print_FractionField(self, expr): args = list(expr.symbols) if not expr.order.is_default: order = prettyForm(*prettyForm("order=").right(self._print(expr.order))) args.append(order) pform = self._print_seq(args, '(', ')') pform = prettyForm(*pform.left(self._print(expr.domain))) return pform def _print_PolynomialRingBase(self, expr): g = expr.symbols if str(expr.order) != str(expr.default_order): g = g + ("order=" + str(expr.order),) pform = self._print_seq(g, '[', ']') pform = prettyForm(*pform.left(self._print(expr.domain))) return pform def _print_GroebnerBasis(self, basis): exprs = [ self._print_Add(arg, order=basis.order) for arg in basis.exprs ] exprs = prettyForm(*self.join(", ", exprs).parens(left="[", right="]")) gens = [ self._print(gen) for gen in basis.gens ] domain = prettyForm( *prettyForm("domain=").right(self._print(basis.domain))) order = prettyForm( *prettyForm("order=").right(self._print(basis.order))) pform = self.join(", ", [exprs] + gens + [domain, order]) pform = prettyForm(*pform.parens()) pform = prettyForm(*pform.left(basis.__class__.__name__)) return pform def _print_Subs(self, e): pform = self._print(e.expr) pform = prettyForm(*pform.parens()) h = pform.height() if pform.height() > 1 else 2 rvert = stringPict(vobj('|', h), baseline=pform.baseline) pform = prettyForm(*pform.right(rvert)) b = pform.baseline pform.baseline = pform.height() - 1 pform = prettyForm(*pform.right(self._print_seq([ self._print_seq((self._print(v[0]), xsym('=='), self._print(v[1])), delimiter='') for v in zip(e.variables, e.point) ]))) pform.baseline = b return pform def _print_euler(self, e): pform = prettyForm("E") arg = self._print(e.args[0]) pform_arg = prettyForm(" "*arg.width()) pform_arg = prettyForm(*pform_arg.below(arg)) pform = prettyForm(*pform.right(pform_arg)) if len(e.args) == 1: return pform m, x = e.args # TODO: copy-pasted from _print_Function: can we do better? prettyFunc = pform prettyArgs = prettyForm(*self._print_seq([x]).parens()) pform = prettyForm( binding=prettyForm.FUNC, *stringPict.next(prettyFunc, prettyArgs)) pform.prettyFunc = prettyFunc pform.prettyArgs = prettyArgs return pform def _print_catalan(self, e): pform = prettyForm("C") arg = self._print(e.args[0]) pform_arg = prettyForm(" "*arg.width()) pform_arg = prettyForm(*pform_arg.below(arg)) pform = prettyForm(*pform.right(pform_arg)) return pform def _print_bernoulli(self, e): pform = prettyForm("B") arg = self._print(e.args[0]) pform_arg = prettyForm(" "*arg.width()) pform_arg = prettyForm(*pform_arg.below(arg)) pform = prettyForm(*pform.right(pform_arg)) return pform _print_bell = _print_bernoulli def _print_lucas(self, e): pform = prettyForm("L") arg = self._print(e.args[0]) pform_arg = prettyForm(" "*arg.width()) pform_arg = prettyForm(*pform_arg.below(arg)) pform = prettyForm(*pform.right(pform_arg)) return pform def _print_fibonacci(self, e): pform = prettyForm("F") arg = self._print(e.args[0]) pform_arg = prettyForm(" "*arg.width()) pform_arg = prettyForm(*pform_arg.below(arg)) pform = prettyForm(*pform.right(pform_arg)) return pform def _print_tribonacci(self, e): pform = prettyForm("T") arg = self._print(e.args[0]) pform_arg = prettyForm(" "*arg.width()) pform_arg = prettyForm(*pform_arg.below(arg)) pform = prettyForm(*pform.right(pform_arg)) return pform def _print_KroneckerDelta(self, e): pform = self._print(e.args[0]) pform = prettyForm(*pform.right((prettyForm(',')))) pform = prettyForm(*pform.right((self._print(e.args[1])))) if self._use_unicode: a = stringPict(pretty_symbol('delta')) else: a = stringPict('d') b = pform top = stringPict(*b.left(' '*a.width())) bot = stringPict(*a.right(' '*b.width())) return prettyForm(binding=prettyForm.POW, *bot.below(top)) def _print_RandomDomain(self, d): if hasattr(d, 'as_boolean'): pform = self._print('Domain: ') pform = prettyForm(*pform.right(self._print(d.as_boolean()))) return pform elif hasattr(d, 'set'): pform = self._print('Domain: ') pform = prettyForm(*pform.right(self._print(d.symbols))) pform = prettyForm(*pform.right(self._print(' in '))) pform = prettyForm(*pform.right(self._print(d.set))) return pform elif hasattr(d, 'symbols'): pform = self._print('Domain on ') pform = prettyForm(*pform.right(self._print(d.symbols))) return pform else: return self._print(None) def _print_DMP(self, p): try: if p.ring is not None: # TODO incorporate order return self._print(p.ring.to_sympy(p)) except SympifyError: pass return self._print(repr(p)) def _print_DMF(self, p): return self._print_DMP(p) def _print_Object(self, object): return self._print(pretty_symbol(object.name)) def _print_Morphism(self, morphism): arrow = xsym("-->") domain = self._print(morphism.domain) codomain = self._print(morphism.codomain) tail = domain.right(arrow, codomain)[0] return prettyForm(tail) def _print_NamedMorphism(self, morphism): pretty_name = self._print(pretty_symbol(morphism.name)) pretty_morphism = self._print_Morphism(morphism) return prettyForm(pretty_name.right(":", pretty_morphism)[0]) def _print_IdentityMorphism(self, morphism): from sympy.categories import NamedMorphism return self._print_NamedMorphism( NamedMorphism(morphism.domain, morphism.codomain, "id")) def _print_CompositeMorphism(self, morphism): circle = xsym(".") # All components of the morphism have names and it is thus # possible to build the name of the composite. component_names_list = [pretty_symbol(component.name) for component in morphism.components] component_names_list.reverse() component_names = circle.join(component_names_list) + ":" pretty_name = self._print(component_names) pretty_morphism = self._print_Morphism(morphism) return prettyForm(pretty_name.right(pretty_morphism)[0]) def _print_Category(self, category): return self._print(pretty_symbol(category.name)) def _print_Diagram(self, diagram): if not diagram.premises: # This is an empty diagram. return self._print(S.EmptySet) pretty_result = self._print(diagram.premises) if diagram.conclusions: results_arrow = " %s " % xsym("==>") pretty_conclusions = self._print(diagram.conclusions)[0] pretty_result = pretty_result.right( results_arrow, pretty_conclusions) return prettyForm(pretty_result[0]) def _print_DiagramGrid(self, grid): from sympy.matrices import Matrix from sympy import Symbol matrix = Matrix([[grid[i, j] if grid[i, j] else Symbol(" ") for j in range(grid.width)] for i in range(grid.height)]) return self._print_matrix_contents(matrix) def _print_FreeModuleElement(self, m): # Print as row vector for convenience, for now. return self._print_seq(m, '[', ']') def _print_SubModule(self, M): return self._print_seq(M.gens, '<', '>') def _print_FreeModule(self, M): return self._print(M.ring)**self._print(M.rank) def _print_ModuleImplementedIdeal(self, M): return self._print_seq([x for [x] in M._module.gens], '<', '>') def _print_QuotientRing(self, R): return self._print(R.ring) / self._print(R.base_ideal) def _print_QuotientRingElement(self, R): return self._print(R.data) + self._print(R.ring.base_ideal) def _print_QuotientModuleElement(self, m): return self._print(m.data) + self._print(m.module.killed_module) def _print_QuotientModule(self, M): return self._print(M.base) / self._print(M.killed_module) def _print_MatrixHomomorphism(self, h): matrix = self._print(h._sympy_matrix()) matrix.baseline = matrix.height() // 2 pform = prettyForm(*matrix.right(' : ', self._print(h.domain), ' %s> ' % hobj('-', 2), self._print(h.codomain))) return pform def _print_BaseScalarField(self, field): string = field._coord_sys._names[field._index] return self._print(pretty_symbol(string)) def _print_BaseVectorField(self, field): s = U('PARTIAL DIFFERENTIAL') + '_' + field._coord_sys._names[field._index] return self._print(pretty_symbol(s)) def _print_Differential(self, diff): field = diff._form_field if hasattr(field, '_coord_sys'): string = field._coord_sys._names[field._index] return self._print(u'\N{DOUBLE-STRUCK ITALIC SMALL D} ' + pretty_symbol(string)) else: pform = self._print(field) pform = prettyForm(*pform.parens()) return prettyForm(*pform.left(u"\N{DOUBLE-STRUCK ITALIC SMALL D}")) def _print_Tr(self, p): #TODO: Handle indices pform = self._print(p.args[0]) pform = prettyForm(*pform.left('%s(' % (p.__class__.__name__))) pform = prettyForm(*pform.right(')')) return pform def _print_primenu(self, e): pform = self._print(e.args[0]) pform = prettyForm(*pform.parens()) if self._use_unicode: pform = prettyForm(*pform.left(greek_unicode['nu'])) else: pform = prettyForm(*pform.left('nu')) return pform def _print_primeomega(self, e): pform = self._print(e.args[0]) pform = prettyForm(*pform.parens()) if self._use_unicode: pform = prettyForm(*pform.left(greek_unicode['Omega'])) else: pform = prettyForm(*pform.left('Omega')) return pform def _print_Quantity(self, e): if e.name.name == 'degree': pform = self._print(u"\N{DEGREE SIGN}") return pform else: return self.emptyPrinter(e) def _print_AssignmentBase(self, e): op = prettyForm(' ' + xsym(e.op) + ' ') l = self._print(e.lhs) r = self._print(e.rhs) pform = prettyForm(*stringPict.next(l, op, r)) return pform def pretty(expr, **settings): """Returns a string containing the prettified form of expr. For information on keyword arguments see pretty_print function. """ pp = PrettyPrinter(settings) # XXX: this is an ugly hack, but at least it works use_unicode = pp._settings['use_unicode'] uflag = pretty_use_unicode(use_unicode) try: return pp.doprint(expr) finally: pretty_use_unicode(uflag) def pretty_print(expr, wrap_line=True, num_columns=None, use_unicode=None, full_prec="auto", order=None, use_unicode_sqrt_char=True, root_notation = True, mat_symbol_style="plain", imaginary_unit="i"): """Prints expr in pretty form. pprint is just a shortcut for this function. Parameters ========== expr : expression The expression to print. wrap_line : bool, optional (default=True) Line wrapping enabled/disabled. num_columns : int or None, optional (default=None) Number of columns before line breaking (default to None which reads the terminal width), useful when using SymPy without terminal. use_unicode : bool or None, optional (default=None) Use unicode characters, such as the Greek letter pi instead of the string pi. full_prec : bool or string, optional (default="auto") Use full precision. order : bool or string, optional (default=None) Set to 'none' for long expressions if slow; default is None. use_unicode_sqrt_char : bool, optional (default=True) Use compact single-character square root symbol (when unambiguous). root_notation : bool, optional (default=True) Set to 'False' for printing exponents of the form 1/n in fractional form. By default exponent is printed in root form. mat_symbol_style : string, optional (default="plain") Set to "bold" for printing MatrixSymbols using a bold mathematical symbol face. By default the standard face is used. imaginary_unit : string, optional (default="i") Letter to use for imaginary unit when use_unicode is True. Can be "i" (default) or "j". """ print(pretty(expr, wrap_line=wrap_line, num_columns=num_columns, use_unicode=use_unicode, full_prec=full_prec, order=order, use_unicode_sqrt_char=use_unicode_sqrt_char, root_notation=root_notation, mat_symbol_style=mat_symbol_style, imaginary_unit=imaginary_unit)) pprint = pretty_print def pager_print(expr, **settings): """Prints expr using the pager, in pretty form. This invokes a pager command using pydoc. Lines are not wrapped automatically. This routine is meant to be used with a pager that allows sideways scrolling, like ``less -S``. Parameters are the same as for ``pretty_print``. If you wish to wrap lines, pass ``num_columns=None`` to auto-detect the width of the terminal. """ from pydoc import pager from locale import getpreferredencoding if 'num_columns' not in settings: settings['num_columns'] = 500000 # disable line wrap pager(pretty(expr, **settings).encode(getpreferredencoding()))
95e10bcdf9a58962404635b441a54842a4c21cf72cc1855fbdee5792d4002378
from sympy.utilities.pytest import raises from sympy import (symbols, Function, Integer, Matrix, Abs, Rational, Float, S, WildFunction, ImmutableDenseMatrix, sin, true, false, ones, sqrt, root, AlgebraicNumber, Symbol, Dummy, Wild, MatrixSymbol) from sympy.core.compatibility import exec_ from sympy.geometry import Point, Ellipse from sympy.printing import srepr from sympy.polys import ring, field, ZZ, QQ, lex, grlex, Poly from sympy.polys.polyclasses import DMP from sympy.polys.agca.extensions import FiniteExtension x, y = symbols('x,y') # eval(srepr(expr)) == expr has to succeed in the right environment. The right # environment is the scope of "from sympy import *" for most cases. ENV = {} exec_("from sympy import *", ENV) def sT(expr, string): """ sT := sreprTest Tests that srepr delivers the expected string and that the condition eval(srepr(expr))==expr holds. """ assert srepr(expr) == string assert eval(string, ENV) == expr def test_printmethod(): class R(Abs): def _sympyrepr(self, printer): return "foo(%s)" % printer._print(self.args[0]) assert srepr(R(x)) == "foo(Symbol('x'))" def test_Add(): sT(x + y, "Add(Symbol('x'), Symbol('y'))") assert srepr(x**2 + 1, order='lex') == "Add(Pow(Symbol('x'), Integer(2)), Integer(1))" assert srepr(x**2 + 1, order='old') == "Add(Integer(1), Pow(Symbol('x'), Integer(2)))" def test_more_than_255_args_issue_10259(): from sympy import Add, Mul for op in (Add, Mul): expr = op(*symbols('x:256')) assert eval(srepr(expr)) == expr def test_Function(): sT(Function("f")(x), "Function('f')(Symbol('x'))") # test unapplied Function sT(Function('f'), "Function('f')") sT(sin(x), "sin(Symbol('x'))") sT(sin, "sin") def test_Geometry(): sT(Point(0, 0), "Point2D(Integer(0), Integer(0))") sT(Ellipse(Point(0, 0), 5, 1), "Ellipse(Point2D(Integer(0), Integer(0)), Integer(5), Integer(1))") # TODO more tests def test_Singletons(): sT(S.Catalan, 'Catalan') sT(S.ComplexInfinity, 'zoo') sT(S.EulerGamma, 'EulerGamma') sT(S.Exp1, 'E') sT(S.GoldenRatio, 'GoldenRatio') sT(S.TribonacciConstant, 'TribonacciConstant') sT(S.Half, 'Rational(1, 2)') sT(S.ImaginaryUnit, 'I') sT(S.Infinity, 'oo') sT(S.NaN, 'nan') sT(S.NegativeInfinity, '-oo') sT(S.NegativeOne, 'Integer(-1)') sT(S.One, 'Integer(1)') sT(S.Pi, 'pi') sT(S.Zero, 'Integer(0)') def test_Integer(): sT(Integer(4), "Integer(4)") def test_list(): sT([x, Integer(4)], "[Symbol('x'), Integer(4)]") def test_Matrix(): for cls, name in [(Matrix, "MutableDenseMatrix"), (ImmutableDenseMatrix, "ImmutableDenseMatrix")]: sT(cls([[x**+1, 1], [y, x + y]]), "%s([[Symbol('x'), Integer(1)], [Symbol('y'), Add(Symbol('x'), Symbol('y'))]])" % name) sT(cls(), "%s([])" % name) sT(cls([[x**+1, 1], [y, x + y]]), "%s([[Symbol('x'), Integer(1)], [Symbol('y'), Add(Symbol('x'), Symbol('y'))]])" % name) def test_empty_Matrix(): sT(ones(0, 3), "MutableDenseMatrix(0, 3, [])") sT(ones(4, 0), "MutableDenseMatrix(4, 0, [])") sT(ones(0, 0), "MutableDenseMatrix([])") def test_Rational(): sT(Rational(1, 3), "Rational(1, 3)") sT(Rational(-1, 3), "Rational(-1, 3)") def test_Float(): sT(Float('1.23', dps=3), "Float('1.22998', precision=13)") sT(Float('1.23456789', dps=9), "Float('1.23456788994', precision=33)") sT(Float('1.234567890123456789', dps=19), "Float('1.234567890123456789013', precision=66)") sT(Float('0.60038617995049726', dps=15), "Float('0.60038617995049726', precision=53)") sT(Float('1.23', precision=13), "Float('1.22998', precision=13)") sT(Float('1.23456789', precision=33), "Float('1.23456788994', precision=33)") sT(Float('1.234567890123456789', precision=66), "Float('1.234567890123456789013', precision=66)") sT(Float('0.60038617995049726', precision=53), "Float('0.60038617995049726', precision=53)") sT(Float('0.60038617995049726', 15), "Float('0.60038617995049726', precision=53)") def test_Symbol(): sT(x, "Symbol('x')") sT(y, "Symbol('y')") sT(Symbol('x', negative=True), "Symbol('x', negative=True)") def test_Symbol_two_assumptions(): x = Symbol('x', negative=0, integer=1) # order could vary s1 = "Symbol('x', integer=True, negative=False)" s2 = "Symbol('x', negative=False, integer=True)" assert srepr(x) in (s1, s2) assert eval(srepr(x), ENV) == x def test_Symbol_no_special_commutative_treatment(): sT(Symbol('x'), "Symbol('x')") sT(Symbol('x', commutative=False), "Symbol('x', commutative=False)") sT(Symbol('x', commutative=0), "Symbol('x', commutative=False)") sT(Symbol('x', commutative=True), "Symbol('x', commutative=True)") sT(Symbol('x', commutative=1), "Symbol('x', commutative=True)") def test_Wild(): sT(Wild('x', even=True), "Wild('x', even=True)") def test_Dummy(): d = Dummy('d') sT(d, "Dummy('d', dummy_index=%s)" % str(d.dummy_index)) def test_Dummy_assumption(): d = Dummy('d', nonzero=True) assert d == eval(srepr(d)) s1 = "Dummy('d', dummy_index=%s, nonzero=True)" % str(d.dummy_index) s2 = "Dummy('d', nonzero=True, dummy_index=%s)" % str(d.dummy_index) assert srepr(d) in (s1, s2) def test_Dummy_from_Symbol(): # should not get the full dictionary of assumptions n = Symbol('n', integer=True) d = n.as_dummy() assert srepr(d ) == "Dummy('n', dummy_index=%s)" % str(d.dummy_index) def test_tuple(): sT((x,), "(Symbol('x'),)") sT((x, y), "(Symbol('x'), Symbol('y'))") def test_WildFunction(): sT(WildFunction('w'), "WildFunction('w')") def test_settins(): raises(TypeError, lambda: srepr(x, method="garbage")) def test_Mul(): sT(3*x**3*y, "Mul(Integer(3), Pow(Symbol('x'), Integer(3)), Symbol('y'))") assert srepr(3*x**3*y, order='old') == "Mul(Integer(3), Symbol('y'), Pow(Symbol('x'), Integer(3)))" def test_AlgebraicNumber(): a = AlgebraicNumber(sqrt(2)) sT(a, "AlgebraicNumber(Pow(Integer(2), Rational(1, 2)), [Integer(1), Integer(0)])") a = AlgebraicNumber(root(-2, 3)) sT(a, "AlgebraicNumber(Pow(Integer(-2), Rational(1, 3)), [Integer(1), Integer(0)])") def test_PolyRing(): assert srepr(ring("x", ZZ, lex)[0]) == "PolyRing((Symbol('x'),), ZZ, lex)" assert srepr(ring("x,y", QQ, grlex)[0]) == "PolyRing((Symbol('x'), Symbol('y')), QQ, grlex)" assert srepr(ring("x,y,z", ZZ["t"], lex)[0]) == "PolyRing((Symbol('x'), Symbol('y'), Symbol('z')), ZZ[t], lex)" def test_FracField(): assert srepr(field("x", ZZ, lex)[0]) == "FracField((Symbol('x'),), ZZ, lex)" assert srepr(field("x,y", QQ, grlex)[0]) == "FracField((Symbol('x'), Symbol('y')), QQ, grlex)" assert srepr(field("x,y,z", ZZ["t"], lex)[0]) == "FracField((Symbol('x'), Symbol('y'), Symbol('z')), ZZ[t], lex)" def test_PolyElement(): R, x, y = ring("x,y", ZZ) assert srepr(3*x**2*y + 1) == "PolyElement(PolyRing((Symbol('x'), Symbol('y')), ZZ, lex), [((2, 1), 3), ((0, 0), 1)])" def test_FracElement(): F, x, y = field("x,y", ZZ) assert srepr((3*x**2*y + 1)/(x - y**2)) == "FracElement(FracField((Symbol('x'), Symbol('y')), ZZ, lex), [((2, 1), 3), ((0, 0), 1)], [((1, 0), 1), ((0, 2), -1)])" def test_FractionField(): assert srepr(QQ.frac_field(x)) == \ "FractionField(FracField((Symbol('x'),), QQ, lex))" assert srepr(QQ.frac_field(x, y, order=grlex)) == \ "FractionField(FracField((Symbol('x'), Symbol('y')), QQ, grlex))" def test_PolynomialRingBase(): assert srepr(ZZ.old_poly_ring(x)) == \ "GlobalPolynomialRing(ZZ, Symbol('x'))" assert srepr(ZZ[x].old_poly_ring(y)) == \ "GlobalPolynomialRing(ZZ[x], Symbol('y'))" assert srepr(QQ.frac_field(x).old_poly_ring(y)) == \ "GlobalPolynomialRing(FractionField(FracField((Symbol('x'),), QQ, lex)), Symbol('y'))" def test_DMP(): assert srepr(DMP([1, 2], ZZ)) == 'DMP([1, 2], ZZ)' assert srepr(ZZ.old_poly_ring(x)([1, 2])) == \ "DMP([1, 2], ZZ, ring=GlobalPolynomialRing(ZZ, Symbol('x')))" def test_FiniteExtension(): assert srepr(FiniteExtension(Poly(x**2 + 1, x))) == \ "FiniteExtension(Poly(x**2 + 1, x, domain='ZZ'))" def test_ExtensionElement(): A = FiniteExtension(Poly(x**2 + 1, x)) assert srepr(A.generator) == \ "ExtElem(DMP([1, 0], ZZ, ring=GlobalPolynomialRing(ZZ, Symbol('x'))), FiniteExtension(Poly(x**2 + 1, x, domain='ZZ')))" def test_BooleanAtom(): assert srepr(true) == "true" assert srepr(false) == "false" def test_Integers(): sT(S.Integers, "Integers") def test_Naturals(): sT(S.Naturals, "Naturals") def test_Naturals0(): sT(S.Naturals0, "Naturals0") def test_Reals(): sT(S.Reals, "Reals") def test_matrix_expressions(): n = symbols('n', integer=True) A = MatrixSymbol("A", n, n) B = MatrixSymbol("B", n, n) sT(A, "MatrixSymbol(Symbol('A'), Symbol('n', integer=True), Symbol('n', integer=True))") sT(A*B, "MatMul(MatrixSymbol(Symbol('A'), Symbol('n', integer=True), Symbol('n', integer=True)), MatrixSymbol(Symbol('B'), Symbol('n', integer=True), Symbol('n', integer=True)))") sT(A + B, "MatAdd(MatrixSymbol(Symbol('A'), Symbol('n', integer=True), Symbol('n', integer=True)), MatrixSymbol(Symbol('B'), Symbol('n', integer=True), Symbol('n', integer=True)))")
a3746b244791e1cad9bea3ed47da2060f6d8539094717cc461aa31f2dc206e4b
from sympy import ( Add, Abs, Chi, Ci, CosineTransform, Dict, Ei, Eq, FallingFactorial, FiniteSet, Float, FourierTransform, Function, Indexed, IndexedBase, Integral, Interval, InverseCosineTransform, InverseFourierTransform, InverseLaplaceTransform, InverseMellinTransform, InverseSineTransform, Lambda, LaplaceTransform, Limit, Matrix, Max, MellinTransform, Min, Mul, Order, Piecewise, Poly, ring, field, ZZ, Pow, Product, Range, Rational, RisingFactorial, rootof, RootSum, S, Shi, Si, SineTransform, Subs, Sum, Symbol, ImageSet, Tuple, Union, Ynm, Znm, arg, asin, acsc, Mod, assoc_laguerre, assoc_legendre, beta, binomial, catalan, ceiling, Complement, chebyshevt, chebyshevu, conjugate, cot, coth, diff, dirichlet_eta, euler, exp, expint, factorial, factorial2, floor, gamma, gegenbauer, hermite, hyper, im, jacobi, laguerre, legendre, lerchphi, log, meijerg, oo, polar_lift, polylog, re, root, sin, sqrt, symbols, uppergamma, zeta, subfactorial, totient, elliptic_k, elliptic_f, elliptic_e, elliptic_pi, cos, tan, Wild, true, false, Equivalent, Not, Contains, divisor_sigma, SymmetricDifference, SeqPer, SeqFormula, SeqAdd, SeqMul, fourier_series, pi, ConditionSet, ComplexRegion, fps, AccumBounds, reduced_totient, primenu, primeomega, SingularityFunction, UnevaluatedExpr, Quaternion, I, KroneckerProduct, Intersection) from sympy.ntheory.factor_ import udivisor_sigma from sympy.abc import mu, tau from sympy.printing.latex import (latex, translate, greek_letters_set, tex_greek_dictionary) from sympy.tensor.array import (ImmutableDenseNDimArray, ImmutableSparseNDimArray, MutableSparseNDimArray, MutableDenseNDimArray) from sympy.tensor.array import tensorproduct from sympy.utilities.pytest import XFAIL, raises from sympy.functions import DiracDelta, Heaviside, KroneckerDelta, LeviCivita from sympy.functions.combinatorial.numbers import bernoulli, bell, lucas, \ fibonacci, tribonacci from sympy.logic import Implies from sympy.logic.boolalg import And, Or, Xor from sympy.physics.quantum import Commutator, Operator from sympy.physics.units import degree, radian, kg, meter, gibibyte, microgram, second from sympy.core.trace import Tr from sympy.core.compatibility import range from sympy.combinatorics.permutations import Cycle, Permutation from sympy import MatrixSymbol, ln from sympy.vector import CoordSys3D, Cross, Curl, Dot, Divergence, Gradient, Laplacian from sympy.sets.setexpr import SetExpr import sympy as sym class lowergamma(sym.lowergamma): pass # testing notation inheritance by a subclass with same name x, y, z, t, a, b, c = symbols('x y z t a b c') k, m, n = symbols('k m n', integer=True) def test_printmethod(): class R(Abs): def _latex(self, printer): return "foo(%s)" % printer._print(self.args[0]) assert latex(R(x)) == "foo(x)" class R(Abs): def _latex(self, printer): return "foo" assert latex(R(x)) == "foo" def test_latex_basic(): assert latex(1 + x) == "x + 1" assert latex(x**2) == "x^{2}" assert latex(x**(1 + x)) == "x^{x + 1}" assert latex(x**3 + x + 1 + x**2) == "x^{3} + x^{2} + x + 1" assert latex(2*x*y) == "2 x y" assert latex(2*x*y, mul_symbol='dot') == r"2 \cdot x \cdot y" assert latex(3*x**2*y, mul_symbol='\\,') == r"3\,x^{2}\,y" assert latex(1.5*3**x, mul_symbol='\\,') == r"1.5 \cdot 3^{x}" assert latex(1/x) == r"\frac{1}{x}" assert latex(1/x, fold_short_frac=True) == "1 / x" assert latex(-S(3)/2) == r"- \frac{3}{2}" assert latex(-S(3)/2, fold_short_frac=True) == r"- 3 / 2" assert latex(1/x**2) == r"\frac{1}{x^{2}}" assert latex(1/(x + y)/2) == r"\frac{1}{2 \left(x + y\right)}" assert latex(x/2) == r"\frac{x}{2}" assert latex(x/2, fold_short_frac=True) == "x / 2" assert latex((x + y)/(2*x)) == r"\frac{x + y}{2 x}" assert latex((x + y)/(2*x), fold_short_frac=True) == \ r"\left(x + y\right) / 2 x" assert latex((x + y)/(2*x), long_frac_ratio=0) == \ r"\frac{1}{2 x} \left(x + y\right)" assert latex((x + y)/x) == r"\frac{x + y}{x}" assert latex((x + y)/x, long_frac_ratio=3) == r"\frac{x + y}{x}" assert latex((2*sqrt(2)*x)/3) == r"\frac{2 \sqrt{2} x}{3}" assert latex((2*sqrt(2)*x)/3, long_frac_ratio=2) == \ r"\frac{2 x}{3} \sqrt{2}" assert latex(2*Integral(x, x)/3) == r"\frac{2 \int x\, dx}{3}" assert latex(2*Integral(x, x)/3, fold_short_frac=True) == \ r"\left(2 \int x\, dx\right) / 3" assert latex(sqrt(x)) == r"\sqrt{x}" assert latex(x**Rational(1, 3)) == r"\sqrt[3]{x}" assert latex(x**Rational(1, 3), root_notation=False) == r"x^{\frac{1}{3}}" assert latex(sqrt(x)**3) == r"x^{\frac{3}{2}}" assert latex(sqrt(x), itex=True) == r"\sqrt{x}" assert latex(x**Rational(1, 3), itex=True) == r"\root{3}{x}" assert latex(sqrt(x)**3, itex=True) == r"x^{\frac{3}{2}}" assert latex(x**Rational(3, 4)) == r"x^{\frac{3}{4}}" assert latex(x**Rational(3, 4), fold_frac_powers=True) == "x^{3/4}" assert latex((x + 1)**Rational(3, 4)) == \ r"\left(x + 1\right)^{\frac{3}{4}}" assert latex((x + 1)**Rational(3, 4), fold_frac_powers=True) == \ r"\left(x + 1\right)^{3/4}" assert latex(1.5e20*x) == r"1.5 \cdot 10^{20} x" assert latex(1.5e20*x, mul_symbol='dot') == r"1.5 \cdot 10^{20} \cdot x" assert latex(1.5e20*x, mul_symbol='times') == \ r"1.5 \times 10^{20} \times x" assert latex(1/sin(x)) == r"\frac{1}{\sin{\left(x \right)}}" assert latex(sin(x)**-1) == r"\frac{1}{\sin{\left(x \right)}}" assert latex(sin(x)**Rational(3, 2)) == \ r"\sin^{\frac{3}{2}}{\left(x \right)}" assert latex(sin(x)**Rational(3, 2), fold_frac_powers=True) == \ r"\sin^{3/2}{\left(x \right)}" assert latex(~x) == r"\neg x" assert latex(x & y) == r"x \wedge y" assert latex(x & y & z) == r"x \wedge y \wedge z" assert latex(x | y) == r"x \vee y" assert latex(x | y | z) == r"x \vee y \vee z" assert latex((x & y) | z) == r"z \vee \left(x \wedge y\right)" assert latex(Implies(x, y)) == r"x \Rightarrow y" assert latex(~(x >> ~y)) == r"x \not\Rightarrow \neg y" assert latex(Implies(Or(x,y), z)) == r"\left(x \vee y\right) \Rightarrow z" assert latex(Implies(z, Or(x,y))) == r"z \Rightarrow \left(x \vee y\right)" assert latex(~x, symbol_names={x: "x_i"}) == r"\neg x_i" assert latex(x & y, symbol_names={x: "x_i", y: "y_i"}) == \ r"x_i \wedge y_i" assert latex(x & y & z, symbol_names={x: "x_i", y: "y_i", z: "z_i"}) == \ r"x_i \wedge y_i \wedge z_i" assert latex(x | y, symbol_names={x: "x_i", y: "y_i"}) == r"x_i \vee y_i" assert latex(x | y | z, symbol_names={x: "x_i", y: "y_i", z: "z_i"}) == \ r"x_i \vee y_i \vee z_i" assert latex((x & y) | z, symbol_names={x: "x_i", y: "y_i", z: "z_i"}) == \ r"z_i \vee \left(x_i \wedge y_i\right)" assert latex(Implies(x, y), symbol_names={x: "x_i", y: "y_i"}) == \ r"x_i \Rightarrow y_i" p = Symbol('p', positive=True) assert latex(exp(-p)*log(p)) == r"e^{- p} \log{\left(p \right)}" def test_latex_builtins(): assert latex(True) == r"\text{True}" assert latex(False) == r"\text{False}" assert latex(None) == r"\text{None}" assert latex(true) == r"\text{True}" assert latex(false) == r'\text{False}' def test_latex_SingularityFunction(): assert latex(SingularityFunction(x, 4, 5)) == \ r"{\left\langle x - 4 \right\rangle}^{5}" assert latex(SingularityFunction(x, -3, 4)) == \ r"{\left\langle x + 3 \right\rangle}^{4}" assert latex(SingularityFunction(x, 0, 4)) == \ r"{\left\langle x \right\rangle}^{4}" assert latex(SingularityFunction(x, a, n)) == \ r"{\left\langle - a + x \right\rangle}^{n}" assert latex(SingularityFunction(x, 4, -2)) == \ r"{\left\langle x - 4 \right\rangle}^{-2}" assert latex(SingularityFunction(x, 4, -1)) == \ r"{\left\langle x - 4 \right\rangle}^{-1}" def test_latex_cycle(): assert latex(Cycle(1, 2, 4)) == r"\left( 1\; 2\; 4\right)" assert latex(Cycle(1, 2)(4, 5, 6)) == \ r"\left( 1\; 2\right)\left( 4\; 5\; 6\right)" assert latex(Cycle()) == r"\left( \right)" def test_latex_permutation(): assert latex(Permutation(1, 2, 4)) == r"\left( 1\; 2\; 4\right)" assert latex(Permutation(1, 2)(4, 5, 6)) == \ r"\left( 1\; 2\right)\left( 4\; 5\; 6\right)" assert latex(Permutation()) == r"\left( \right)" assert latex(Permutation(2, 4)*Permutation(5)) == \ r"\left( 2\; 4\right)\left( 5\right)" assert latex(Permutation(5)) == r"\left( 5\right)" def test_latex_Float(): assert latex(Float(1.0e100)) == r"1.0 \cdot 10^{100}" assert latex(Float(1.0e-100)) == r"1.0 \cdot 10^{-100}" assert latex(Float(1.0e-100), mul_symbol="times") == \ r"1.0 \times 10^{-100}" assert latex(1.0*oo) == r"\infty" assert latex(-1.0*oo) == r"- \infty" def test_latex_vector_expressions(): A = CoordSys3D('A') assert latex(Cross(A.i, A.j*A.x*3+A.k)) == \ r"\mathbf{\hat{i}_{A}} \times \left((3 \mathbf{{x}_{A}})\mathbf{\hat{j}_{A}} + \mathbf{\hat{k}_{A}}\right)" assert latex(Cross(A.i, A.j)) == \ r"\mathbf{\hat{i}_{A}} \times \mathbf{\hat{j}_{A}}" assert latex(x*Cross(A.i, A.j)) == \ r"x \left(\mathbf{\hat{i}_{A}} \times \mathbf{\hat{j}_{A}}\right)" assert latex(Cross(x*A.i, A.j)) == \ r'- \mathbf{\hat{j}_{A}} \times \left((x)\mathbf{\hat{i}_{A}}\right)' assert latex(Curl(3*A.x*A.j)) == \ r"\nabla\times \left((3 \mathbf{{x}_{A}})\mathbf{\hat{j}_{A}}\right)" assert latex(Curl(3*A.x*A.j+A.i)) == \ r"\nabla\times \left(\mathbf{\hat{i}_{A}} + (3 \mathbf{{x}_{A}})\mathbf{\hat{j}_{A}}\right)" assert latex(Curl(3*x*A.x*A.j)) == \ r"\nabla\times \left((3 \mathbf{{x}_{A}} x)\mathbf{\hat{j}_{A}}\right)" assert latex(x*Curl(3*A.x*A.j)) == \ r"x \left(\nabla\times \left((3 \mathbf{{x}_{A}})\mathbf{\hat{j}_{A}}\right)\right)" assert latex(Divergence(3*A.x*A.j+A.i)) == \ r"\nabla\cdot \left(\mathbf{\hat{i}_{A}} + (3 \mathbf{{x}_{A}})\mathbf{\hat{j}_{A}}\right)" assert latex(Divergence(3*A.x*A.j)) == \ r"\nabla\cdot \left((3 \mathbf{{x}_{A}})\mathbf{\hat{j}_{A}}\right)" assert latex(x*Divergence(3*A.x*A.j)) == \ r"x \left(\nabla\cdot \left((3 \mathbf{{x}_{A}})\mathbf{\hat{j}_{A}}\right)\right)" assert latex(Dot(A.i, A.j*A.x*3+A.k)) == \ r"\mathbf{\hat{i}_{A}} \cdot \left((3 \mathbf{{x}_{A}})\mathbf{\hat{j}_{A}} + \mathbf{\hat{k}_{A}}\right)" assert latex(Dot(A.i, A.j)) == \ r"\mathbf{\hat{i}_{A}} \cdot \mathbf{\hat{j}_{A}}" assert latex(Dot(x*A.i, A.j)) == \ r"\mathbf{\hat{j}_{A}} \cdot \left((x)\mathbf{\hat{i}_{A}}\right)" assert latex(x*Dot(A.i, A.j)) == \ r"x \left(\mathbf{\hat{i}_{A}} \cdot \mathbf{\hat{j}_{A}}\right)" assert latex(Gradient(A.x)) == r"\nabla \mathbf{{x}_{A}}" assert latex(Gradient(A.x + 3*A.y)) == \ r"\nabla \left(\mathbf{{x}_{A}} + 3 \mathbf{{y}_{A}}\right)" assert latex(x*Gradient(A.x)) == r"x \left(\nabla \mathbf{{x}_{A}}\right)" assert latex(Gradient(x*A.x)) == r"\nabla \left(\mathbf{{x}_{A}} x\right)" assert latex(Laplacian(A.x)) == r"\triangle \mathbf{{x}_{A}}" assert latex(Laplacian(A.x + 3*A.y)) == \ r"\triangle \left(\mathbf{{x}_{A}} + 3 \mathbf{{y}_{A}}\right)" assert latex(x*Laplacian(A.x)) == r"x \left(\triangle \mathbf{{x}_{A}}\right)" assert latex(Laplacian(x*A.x)) == r"\triangle \left(\mathbf{{x}_{A}} x\right)" def test_latex_symbols(): Gamma, lmbda, rho = symbols('Gamma, lambda, rho') tau, Tau, TAU, taU = symbols('tau, Tau, TAU, taU') assert latex(tau) == r"\tau" assert latex(Tau) == "T" assert latex(TAU) == r"\tau" assert latex(taU) == r"\tau" # Check that all capitalized greek letters are handled explicitly capitalized_letters = set(l.capitalize() for l in greek_letters_set) assert len(capitalized_letters - set(tex_greek_dictionary.keys())) == 0 assert latex(Gamma + lmbda) == r"\Gamma + \lambda" assert latex(Gamma * lmbda) == r"\Gamma \lambda" assert latex(Symbol('q1')) == r"q_{1}" assert latex(Symbol('q21')) == r"q_{21}" assert latex(Symbol('epsilon0')) == r"\epsilon_{0}" assert latex(Symbol('omega1')) == r"\omega_{1}" assert latex(Symbol('91')) == r"91" assert latex(Symbol('alpha_new')) == r"\alpha_{new}" assert latex(Symbol('C^orig')) == r"C^{orig}" assert latex(Symbol('x^alpha')) == r"x^{\alpha}" assert latex(Symbol('beta^alpha')) == r"\beta^{\alpha}" assert latex(Symbol('e^Alpha')) == r"e^{A}" assert latex(Symbol('omega_alpha^beta')) == r"\omega^{\beta}_{\alpha}" assert latex(Symbol('omega') ** Symbol('beta')) == r"\omega^{\beta}" @XFAIL def test_latex_symbols_failing(): rho, mass, volume = symbols('rho, mass, volume') assert latex( volume * rho == mass) == r"\rho \mathrm{volume} = \mathrm{mass}" assert latex(volume / mass * rho == 1) == \ r"\rho \mathrm{volume} {\mathrm{mass}}^{(-1)} = 1" assert latex(mass**3 * volume**3) == \ r"{\mathrm{mass}}^{3} \cdot {\mathrm{volume}}^{3}" def test_latex_functions(): assert latex(exp(x)) == "e^{x}" assert latex(exp(1) + exp(2)) == "e + e^{2}" f = Function('f') assert latex(f(x)) == r'f{\left(x \right)}' assert latex(f) == r'f' g = Function('g') assert latex(g(x, y)) == r'g{\left(x,y \right)}' assert latex(g) == r'g' h = Function('h') assert latex(h(x, y, z)) == r'h{\left(x,y,z \right)}' assert latex(h) == r'h' Li = Function('Li') assert latex(Li) == r'\operatorname{Li}' assert latex(Li(x)) == r'\operatorname{Li}{\left(x \right)}' mybeta = Function('beta') # not to be confused with the beta function assert latex(mybeta(x, y, z)) == r"\beta{\left(x,y,z \right)}" assert latex(beta(x, y)) == r'\operatorname{B}\left(x, y\right)' assert latex(beta(x, y)**2) == r'\operatorname{B}^{2}\left(x, y\right)' assert latex(mybeta(x)) == r"\beta{\left(x \right)}" assert latex(mybeta) == r"\beta" g = Function('gamma') # not to be confused with the gamma function assert latex(g(x, y, z)) == r"\gamma{\left(x,y,z \right)}" assert latex(g(x)) == r"\gamma{\left(x \right)}" assert latex(g) == r"\gamma" a1 = Function('a_1') assert latex(a1) == r"\operatorname{a_{1}}" assert latex(a1(x)) == r"\operatorname{a_{1}}{\left(x \right)}" # issue 5868 omega1 = Function('omega1') assert latex(omega1) == r"\omega_{1}" assert latex(omega1(x)) == r"\omega_{1}{\left(x \right)}" assert latex(sin(x)) == r"\sin{\left(x \right)}" assert latex(sin(x), fold_func_brackets=True) == r"\sin {x}" assert latex(sin(2*x**2), fold_func_brackets=True) == \ r"\sin {2 x^{2}}" assert latex(sin(x**2), fold_func_brackets=True) == \ r"\sin {x^{2}}" assert latex(asin(x)**2) == r"\operatorname{asin}^{2}{\left(x \right)}" assert latex(asin(x)**2, inv_trig_style="full") == \ r"\arcsin^{2}{\left(x \right)}" assert latex(asin(x)**2, inv_trig_style="power") == \ r"\sin^{-1}{\left(x \right)}^{2}" assert latex(asin(x**2), inv_trig_style="power", fold_func_brackets=True) == \ r"\sin^{-1} {x^{2}}" assert latex(acsc(x), inv_trig_style="full") == \ r"\operatorname{arccsc}{\left(x \right)}" assert latex(factorial(k)) == r"k!" assert latex(factorial(-k)) == r"\left(- k\right)!" assert latex(factorial(k)**2) == r"k!^{2}" assert latex(subfactorial(k)) == r"!k" assert latex(subfactorial(-k)) == r"!\left(- k\right)" assert latex(subfactorial(k)**2) == r"\left(!k\right)^{2}" assert latex(factorial2(k)) == r"k!!" assert latex(factorial2(-k)) == r"\left(- k\right)!!" assert latex(factorial2(k)**2) == r"k!!^{2}" assert latex(binomial(2, k)) == r"{\binom{2}{k}}" assert latex(binomial(2, k)**2) == r"{\binom{2}{k}}^{2}" assert latex(FallingFactorial(3, k)) == r"{\left(3\right)}_{k}" assert latex(RisingFactorial(3, k)) == r"{3}^{\left(k\right)}" assert latex(floor(x)) == r"\left\lfloor{x}\right\rfloor" assert latex(ceiling(x)) == r"\left\lceil{x}\right\rceil" assert latex(floor(x)**2) == r"\left\lfloor{x}\right\rfloor^{2}" assert latex(ceiling(x)**2) == r"\left\lceil{x}\right\rceil^{2}" assert latex(Min(x, 2, x**3)) == r"\min\left(2, x, x^{3}\right)" assert latex(Min(x, y)**2) == r"\min\left(x, y\right)^{2}" assert latex(Max(x, 2, x**3)) == r"\max\left(2, x, x^{3}\right)" assert latex(Max(x, y)**2) == r"\max\left(x, y\right)^{2}" assert latex(Abs(x)) == r"\left|{x}\right|" assert latex(Abs(x)**2) == r"\left|{x}\right|^{2}" assert latex(re(x)) == r"\operatorname{re}{\left(x\right)}" assert latex(re(x + y)) == \ r"\operatorname{re}{\left(x\right)} + \operatorname{re}{\left(y\right)}" assert latex(im(x)) == r"\operatorname{im}{\left(x\right)}" assert latex(conjugate(x)) == r"\overline{x}" assert latex(conjugate(x)**2) == r"\overline{x}^{2}" assert latex(conjugate(x**2)) == r"\overline{x}^{2}" assert latex(gamma(x)) == r"\Gamma\left(x\right)" w = Wild('w') assert latex(gamma(w)) == r"\Gamma\left(w\right)" assert latex(Order(x)) == r"O\left(x\right)" assert latex(Order(x, x)) == r"O\left(x\right)" assert latex(Order(x, (x, 0))) == r"O\left(x\right)" assert latex(Order(x, (x, oo))) == r"O\left(x; x\rightarrow \infty\right)" assert latex(Order(x - y, (x, y))) == \ r"O\left(x - y; x\rightarrow y\right)" assert latex(Order(x, x, y)) == \ r"O\left(x; \left( x, \ y\right)\rightarrow \left( 0, \ 0\right)\right)" assert latex(Order(x, x, y)) == \ r"O\left(x; \left( x, \ y\right)\rightarrow \left( 0, \ 0\right)\right)" assert latex(Order(x, (x, oo), (y, oo))) == \ r"O\left(x; \left( x, \ y\right)\rightarrow \left( \infty, \ \infty\right)\right)" assert latex(lowergamma(x, y)) == r'\gamma\left(x, y\right)' assert latex(lowergamma(x, y)**2) == r'\gamma^{2}\left(x, y\right)' assert latex(uppergamma(x, y)) == r'\Gamma\left(x, y\right)' assert latex(uppergamma(x, y)**2) == r'\Gamma^{2}\left(x, y\right)' assert latex(cot(x)) == r'\cot{\left(x \right)}' assert latex(coth(x)) == r'\coth{\left(x \right)}' assert latex(re(x)) == r'\operatorname{re}{\left(x\right)}' assert latex(im(x)) == r'\operatorname{im}{\left(x\right)}' assert latex(root(x, y)) == r'x^{\frac{1}{y}}' assert latex(arg(x)) == r'\arg{\left(x \right)}' assert latex(zeta(x)) == r'\zeta\left(x\right)' assert latex(zeta(x)) == r"\zeta\left(x\right)" assert latex(zeta(x)**2) == r"\zeta^{2}\left(x\right)" assert latex(zeta(x, y)) == r"\zeta\left(x, y\right)" assert latex(zeta(x, y)**2) == r"\zeta^{2}\left(x, y\right)" assert latex(dirichlet_eta(x)) == r"\eta\left(x\right)" assert latex(dirichlet_eta(x)**2) == r"\eta^{2}\left(x\right)" assert latex(polylog(x, y)) == r"\operatorname{Li}_{x}\left(y\right)" assert latex( polylog(x, y)**2) == r"\operatorname{Li}_{x}^{2}\left(y\right)" assert latex(lerchphi(x, y, n)) == r"\Phi\left(x, y, n\right)" assert latex(lerchphi(x, y, n)**2) == r"\Phi^{2}\left(x, y, n\right)" assert latex(elliptic_k(z)) == r"K\left(z\right)" assert latex(elliptic_k(z)**2) == r"K^{2}\left(z\right)" assert latex(elliptic_f(x, y)) == r"F\left(x\middle| y\right)" assert latex(elliptic_f(x, y)**2) == r"F^{2}\left(x\middle| y\right)" assert latex(elliptic_e(x, y)) == r"E\left(x\middle| y\right)" assert latex(elliptic_e(x, y)**2) == r"E^{2}\left(x\middle| y\right)" assert latex(elliptic_e(z)) == r"E\left(z\right)" assert latex(elliptic_e(z)**2) == r"E^{2}\left(z\right)" assert latex(elliptic_pi(x, y, z)) == r"\Pi\left(x; y\middle| z\right)" assert latex(elliptic_pi(x, y, z)**2) == \ r"\Pi^{2}\left(x; y\middle| z\right)" assert latex(elliptic_pi(x, y)) == r"\Pi\left(x\middle| y\right)" assert latex(elliptic_pi(x, y)**2) == r"\Pi^{2}\left(x\middle| y\right)" assert latex(Ei(x)) == r'\operatorname{Ei}{\left(x \right)}' assert latex(Ei(x)**2) == r'\operatorname{Ei}^{2}{\left(x \right)}' assert latex(expint(x, y)) == r'\operatorname{E}_{x}\left(y\right)' assert latex(expint(x, y)**2) == r'\operatorname{E}_{x}^{2}\left(y\right)' assert latex(Shi(x)**2) == r'\operatorname{Shi}^{2}{\left(x \right)}' assert latex(Si(x)**2) == r'\operatorname{Si}^{2}{\left(x \right)}' assert latex(Ci(x)**2) == r'\operatorname{Ci}^{2}{\left(x \right)}' assert latex(Chi(x)**2) == r'\operatorname{Chi}^{2}\left(x\right)' assert latex(Chi(x)) == r'\operatorname{Chi}\left(x\right)' assert latex(jacobi(n, a, b, x)) == \ r'P_{n}^{\left(a,b\right)}\left(x\right)' assert latex(jacobi(n, a, b, x)**2) == \ r'\left(P_{n}^{\left(a,b\right)}\left(x\right)\right)^{2}' assert latex(gegenbauer(n, a, x)) == \ r'C_{n}^{\left(a\right)}\left(x\right)' assert latex(gegenbauer(n, a, x)**2) == \ r'\left(C_{n}^{\left(a\right)}\left(x\right)\right)^{2}' assert latex(chebyshevt(n, x)) == r'T_{n}\left(x\right)' assert latex(chebyshevt(n, x)**2) == \ r'\left(T_{n}\left(x\right)\right)^{2}' assert latex(chebyshevu(n, x)) == r'U_{n}\left(x\right)' assert latex(chebyshevu(n, x)**2) == \ r'\left(U_{n}\left(x\right)\right)^{2}' assert latex(legendre(n, x)) == r'P_{n}\left(x\right)' assert latex(legendre(n, x)**2) == r'\left(P_{n}\left(x\right)\right)^{2}' assert latex(assoc_legendre(n, a, x)) == \ r'P_{n}^{\left(a\right)}\left(x\right)' assert latex(assoc_legendre(n, a, x)**2) == \ r'\left(P_{n}^{\left(a\right)}\left(x\right)\right)^{2}' assert latex(laguerre(n, x)) == r'L_{n}\left(x\right)' assert latex(laguerre(n, x)**2) == r'\left(L_{n}\left(x\right)\right)^{2}' assert latex(assoc_laguerre(n, a, x)) == \ r'L_{n}^{\left(a\right)}\left(x\right)' assert latex(assoc_laguerre(n, a, x)**2) == \ r'\left(L_{n}^{\left(a\right)}\left(x\right)\right)^{2}' assert latex(hermite(n, x)) == r'H_{n}\left(x\right)' assert latex(hermite(n, x)**2) == r'\left(H_{n}\left(x\right)\right)^{2}' theta = Symbol("theta", real=True) phi = Symbol("phi", real=True) assert latex(Ynm(n, m, theta, phi)) == r'Y_{n}^{m}\left(\theta,\phi\right)' assert latex(Ynm(n, m, theta, phi)**3) == \ r'\left(Y_{n}^{m}\left(\theta,\phi\right)\right)^{3}' assert latex(Znm(n, m, theta, phi)) == r'Z_{n}^{m}\left(\theta,\phi\right)' assert latex(Znm(n, m, theta, phi)**3) == \ r'\left(Z_{n}^{m}\left(\theta,\phi\right)\right)^{3}' # Test latex printing of function names with "_" assert latex(polar_lift(0)) == \ r"\operatorname{polar\_lift}{\left(0 \right)}" assert latex(polar_lift(0)**3) == \ r"\operatorname{polar\_lift}^{3}{\left(0 \right)}" assert latex(totient(n)) == r'\phi\left(n\right)' assert latex(totient(n) ** 2) == r'\left(\phi\left(n\right)\right)^{2}' assert latex(reduced_totient(n)) == r'\lambda\left(n\right)' assert latex(reduced_totient(n) ** 2) == \ r'\left(\lambda\left(n\right)\right)^{2}' assert latex(divisor_sigma(x)) == r"\sigma\left(x\right)" assert latex(divisor_sigma(x)**2) == r"\sigma^{2}\left(x\right)" assert latex(divisor_sigma(x, y)) == r"\sigma_y\left(x\right)" assert latex(divisor_sigma(x, y)**2) == r"\sigma^{2}_y\left(x\right)" assert latex(udivisor_sigma(x)) == r"\sigma^*\left(x\right)" assert latex(udivisor_sigma(x)**2) == r"\sigma^*^{2}\left(x\right)" assert latex(udivisor_sigma(x, y)) == r"\sigma^*_y\left(x\right)" assert latex(udivisor_sigma(x, y)**2) == r"\sigma^*^{2}_y\left(x\right)" assert latex(primenu(n)) == r'\nu\left(n\right)' assert latex(primenu(n) ** 2) == r'\left(\nu\left(n\right)\right)^{2}' assert latex(primeomega(n)) == r'\Omega\left(n\right)' assert latex(primeomega(n) ** 2) == \ r'\left(\Omega\left(n\right)\right)^{2}' assert latex(Mod(x, 7)) == r'x\bmod{7}' assert latex(Mod(x + 1, 7)) == r'\left(x + 1\right)\bmod{7}' assert latex(Mod(2 * x, 7)) == r'2 x\bmod{7}' assert latex(Mod(x, 7) + 1) == r'\left(x\bmod{7}\right) + 1' assert latex(2 * Mod(x, 7)) == r'2 \left(x\bmod{7}\right)' # some unknown function name should get rendered with \operatorname fjlkd = Function('fjlkd') assert latex(fjlkd(x)) == r'\operatorname{fjlkd}{\left(x \right)}' # even when it is referred to without an argument assert latex(fjlkd) == r'\operatorname{fjlkd}' # test that notation passes to subclasses of the same name only def test_function_subclass_different_name(): class mygamma(gamma): pass assert latex(mygamma) == r"\operatorname{mygamma}" assert latex(mygamma(x)) == r"\operatorname{mygamma}{\left(x \right)}" def test_hyper_printing(): from sympy import pi from sympy.abc import x, z assert latex(meijerg(Tuple(pi, pi, x), Tuple(1), (0, 1), Tuple(1, 2, 3/pi), z)) == \ r'{G_{4, 5}^{2, 3}\left(\begin{matrix} \pi, \pi, x & 1 \\0, 1 & 1, 2, '\ r'\frac{3}{\pi} \end{matrix} \middle| {z} \right)}' assert latex(meijerg(Tuple(), Tuple(1), (0,), Tuple(), z)) == \ r'{G_{1, 1}^{1, 0}\left(\begin{matrix} & 1 \\0 & \end{matrix} \middle| {z} \right)}' assert latex(hyper((x, 2), (3,), z)) == \ r'{{}_{2}F_{1}\left(\begin{matrix} x, 2 ' \ r'\\ 3 \end{matrix}\middle| {z} \right)}' assert latex(hyper(Tuple(), Tuple(1), z)) == \ r'{{}_{0}F_{1}\left(\begin{matrix} ' \ r'\\ 1 \end{matrix}\middle| {z} \right)}' def test_latex_bessel(): from sympy.functions.special.bessel import (besselj, bessely, besseli, besselk, hankel1, hankel2, jn, yn, hn1, hn2) from sympy.abc import z assert latex(besselj(n, z**2)**k) == r'J^{k}_{n}\left(z^{2}\right)' assert latex(bessely(n, z)) == r'Y_{n}\left(z\right)' assert latex(besseli(n, z)) == r'I_{n}\left(z\right)' assert latex(besselk(n, z)) == r'K_{n}\left(z\right)' assert latex(hankel1(n, z**2)**2) == \ r'\left(H^{(1)}_{n}\left(z^{2}\right)\right)^{2}' assert latex(hankel2(n, z)) == r'H^{(2)}_{n}\left(z\right)' assert latex(jn(n, z)) == r'j_{n}\left(z\right)' assert latex(yn(n, z)) == r'y_{n}\left(z\right)' assert latex(hn1(n, z)) == r'h^{(1)}_{n}\left(z\right)' assert latex(hn2(n, z)) == r'h^{(2)}_{n}\left(z\right)' def test_latex_fresnel(): from sympy.functions.special.error_functions import (fresnels, fresnelc) from sympy.abc import z assert latex(fresnels(z)) == r'S\left(z\right)' assert latex(fresnelc(z)) == r'C\left(z\right)' assert latex(fresnels(z)**2) == r'S^{2}\left(z\right)' assert latex(fresnelc(z)**2) == r'C^{2}\left(z\right)' def test_latex_brackets(): assert latex((-1)**x) == r"\left(-1\right)^{x}" def test_latex_indexed(): Psi_symbol = Symbol('Psi_0', complex=True, real=False) Psi_indexed = IndexedBase(Symbol('Psi', complex=True, real=False)) symbol_latex = latex(Psi_symbol * conjugate(Psi_symbol)) indexed_latex = latex(Psi_indexed[0] * conjugate(Psi_indexed[0])) # \\overline{{\\Psi}_{0}} {\\Psi}_{0} vs. \\Psi_{0} \\overline{\\Psi_{0}} assert symbol_latex == '\\Psi_{0} \\overline{\\Psi_{0}}' assert indexed_latex == '\\overline{{\\Psi}_{0}} {\\Psi}_{0}' # Symbol('gamma') gives r'\gamma' assert latex(Indexed('x1', Symbol('i'))) == '{x_{1}}_{i}' assert latex(IndexedBase('gamma')) == r'\gamma' assert latex(IndexedBase('a b')) == 'a b' assert latex(IndexedBase('a_b')) == 'a_{b}' def test_latex_derivatives(): # regular "d" for ordinary derivatives assert latex(diff(x**3, x, evaluate=False)) == \ r"\frac{d}{d x} x^{3}" assert latex(diff(sin(x) + x**2, x, evaluate=False)) == \ r"\frac{d}{d x} \left(x^{2} + \sin{\left(x \right)}\right)" assert latex(diff(diff(sin(x) + x**2, x, evaluate=False), evaluate=False))\ == \ r"\frac{d^{2}}{d x^{2}} \left(x^{2} + \sin{\left(x \right)}\right)" assert latex(diff(diff(diff(sin(x) + x**2, x, evaluate=False), evaluate=False), evaluate=False)) == \ r"\frac{d^{3}}{d x^{3}} \left(x^{2} + \sin{\left(x \right)}\right)" # \partial for partial derivatives assert latex(diff(sin(x * y), x, evaluate=False)) == \ r"\frac{\partial}{\partial x} \sin{\left(x y \right)}" assert latex(diff(sin(x * y) + x**2, x, evaluate=False)) == \ r"\frac{\partial}{\partial x} \left(x^{2} + \sin{\left(x y \right)}\right)" assert latex(diff(diff(sin(x*y) + x**2, x, evaluate=False), x, evaluate=False)) == \ r"\frac{\partial^{2}}{\partial x^{2}} \left(x^{2} + \sin{\left(x y \right)}\right)" assert latex(diff(diff(diff(sin(x*y) + x**2, x, evaluate=False), x, evaluate=False), x, evaluate=False)) == \ r"\frac{\partial^{3}}{\partial x^{3}} \left(x^{2} + \sin{\left(x y \right)}\right)" # mixed partial derivatives f = Function("f") assert latex(diff(diff(f(x, y), x, evaluate=False), y, evaluate=False)) == \ r"\frac{\partial^{2}}{\partial y\partial x} " + latex(f(x, y)) assert latex(diff(diff(diff(f(x, y), x, evaluate=False), x, evaluate=False), y, evaluate=False)) == \ r"\frac{\partial^{3}}{\partial y\partial x^{2}} " + latex(f(x, y)) # use ordinary d when one of the variables has been integrated out assert latex(diff(Integral(exp(-x*y), (x, 0, oo)), y, evaluate=False)) == \ r"\frac{d}{d y} \int\limits_{0}^{\infty} e^{- x y}\, dx" # Derivative wrapped in power: assert latex(diff(x, x, evaluate=False)**2) == \ r"\left(\frac{d}{d x} x\right)^{2}" assert latex(diff(f(x), x)**2) == \ r"\left(\frac{d}{d x} f{\left(x \right)}\right)^{2}" assert latex(diff(f(x), (x, n))) == \ r"\frac{d^{n}}{d x^{n}} f{\left(x \right)}" def test_latex_subs(): assert latex(Subs(x*y, ( x, y), (1, 2))) == r'\left. x y \right|_{\substack{ x=1\\ y=2 }}' def test_latex_integrals(): assert latex(Integral(log(x), x)) == r"\int \log{\left(x \right)}\, dx" assert latex(Integral(x**2, (x, 0, 1))) == \ r"\int\limits_{0}^{1} x^{2}\, dx" assert latex(Integral(x**2, (x, 10, 20))) == \ r"\int\limits_{10}^{20} x^{2}\, dx" assert latex(Integral(y*x**2, (x, 0, 1), y)) == \ r"\int\int\limits_{0}^{1} x^{2} y\, dx\, dy" assert latex(Integral(y*x**2, (x, 0, 1), y), mode='equation*') == \ r"\begin{equation*}\int\int\limits_{0}^{1} x^{2} y\, dx\, dy\end{equation*}" assert latex(Integral(y*x**2, (x, 0, 1), y), mode='equation*', itex=True) \ == r"$$\int\int_{0}^{1} x^{2} y\, dx\, dy$$" assert latex(Integral(x, (x, 0))) == r"\int\limits^{0} x\, dx" assert latex(Integral(x*y, x, y)) == r"\iint x y\, dx\, dy" assert latex(Integral(x*y*z, x, y, z)) == r"\iiint x y z\, dx\, dy\, dz" assert latex(Integral(x*y*z*t, x, y, z, t)) == \ r"\iiiint t x y z\, dx\, dy\, dz\, dt" assert latex(Integral(x, x, x, x, x, x, x)) == \ r"\int\int\int\int\int\int x\, dx\, dx\, dx\, dx\, dx\, dx" assert latex(Integral(x, x, y, (z, 0, 1))) == \ r"\int\limits_{0}^{1}\int\int x\, dx\, dy\, dz" # fix issue #10806 assert latex(Integral(z, z)**2) == r"\left(\int z\, dz\right)^{2}" assert latex(Integral(x + z, z)) == r"\int \left(x + z\right)\, dz" assert latex(Integral(x+z/2, z)) == \ r"\int \left(x + \frac{z}{2}\right)\, dz" assert latex(Integral(x**y, z)) == r"\int x^{y}\, dz" def test_latex_sets(): for s in (frozenset, set): assert latex(s([x*y, x**2])) == r"\left\{x^{2}, x y\right\}" assert latex(s(range(1, 6))) == r"\left\{1, 2, 3, 4, 5\right\}" assert latex(s(range(1, 13))) == \ r"\left\{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12\right\}" s = FiniteSet assert latex(s(*[x*y, x**2])) == r"\left\{x^{2}, x y\right\}" assert latex(s(*range(1, 6))) == r"\left\{1, 2, 3, 4, 5\right\}" assert latex(s(*range(1, 13))) == \ r"\left\{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12\right\}" def test_latex_SetExpr(): iv = Interval(1, 3) se = SetExpr(iv) assert latex(se) == r"SetExpr\left(\left[1, 3\right]\right)" def test_latex_Range(): assert latex(Range(1, 51)) == \ r'\left\{1, 2, \ldots, 50\right\}' assert latex(Range(1, 4)) == r'\left\{1, 2, 3\right\}' assert latex(Range(0, 3, 1)) == r'\left\{0, 1, 2\right\}' assert latex(Range(0, 30, 1)) == r'\left\{0, 1, \ldots, 29\right\}' assert latex(Range(30, 1, -1)) == r'\left\{30, 29, \ldots, 2\right\}' assert latex(Range(0, oo, 2)) == r'\left\{0, 2, \ldots\right\}' assert latex(Range(oo, -2, -2)) == r'\left\{\ldots, 2, 0\right\}' assert latex(Range(-2, -oo, -1)) == \ r'\left\{-2, -3, \ldots\right\}' def test_latex_sequences(): s1 = SeqFormula(a**2, (0, oo)) s2 = SeqPer((1, 2)) latex_str = r'\left[0, 1, 4, 9, \ldots\right]' assert latex(s1) == latex_str latex_str = r'\left[1, 2, 1, 2, \ldots\right]' assert latex(s2) == latex_str s3 = SeqFormula(a**2, (0, 2)) s4 = SeqPer((1, 2), (0, 2)) latex_str = r'\left[0, 1, 4\right]' assert latex(s3) == latex_str latex_str = r'\left[1, 2, 1\right]' assert latex(s4) == latex_str s5 = SeqFormula(a**2, (-oo, 0)) s6 = SeqPer((1, 2), (-oo, 0)) latex_str = r'\left[\ldots, 9, 4, 1, 0\right]' assert latex(s5) == latex_str latex_str = r'\left[\ldots, 2, 1, 2, 1\right]' assert latex(s6) == latex_str latex_str = r'\left[1, 3, 5, 11, \ldots\right]' assert latex(SeqAdd(s1, s2)) == latex_str latex_str = r'\left[1, 3, 5\right]' assert latex(SeqAdd(s3, s4)) == latex_str latex_str = r'\left[\ldots, 11, 5, 3, 1\right]' assert latex(SeqAdd(s5, s6)) == latex_str latex_str = r'\left[0, 2, 4, 18, \ldots\right]' assert latex(SeqMul(s1, s2)) == latex_str latex_str = r'\left[0, 2, 4\right]' assert latex(SeqMul(s3, s4)) == latex_str latex_str = r'\left[\ldots, 18, 4, 2, 0\right]' assert latex(SeqMul(s5, s6)) == latex_str # Sequences with symbolic limits, issue 12629 s7 = SeqFormula(a**2, (a, 0, x)) latex_str = r'\left\{a^{2}\right\}_{a=0}^{x}' assert latex(s7) == latex_str b = Symbol('b') s8 = SeqFormula(b*a**2, (a, 0, 2)) latex_str = r'\left[0, b, 4 b\right]' assert latex(s8) == latex_str def test_latex_FourierSeries(): latex_str = \ r'2 \sin{\left(x \right)} - \sin{\left(2 x \right)} + \frac{2 \sin{\left(3 x \right)}}{3} + \ldots' assert latex(fourier_series(x, (x, -pi, pi))) == latex_str def test_latex_FormalPowerSeries(): latex_str = r'\sum_{k=1}^{\infty} - \frac{\left(-1\right)^{- k} x^{k}}{k}' assert latex(fps(log(1 + x))) == latex_str def test_latex_intervals(): a = Symbol('a', real=True) assert latex(Interval(0, 0)) == r"\left\{0\right\}" assert latex(Interval(0, a)) == r"\left[0, a\right]" assert latex(Interval(0, a, False, False)) == r"\left[0, a\right]" assert latex(Interval(0, a, True, False)) == r"\left(0, a\right]" assert latex(Interval(0, a, False, True)) == r"\left[0, a\right)" assert latex(Interval(0, a, True, True)) == r"\left(0, a\right)" def test_latex_AccumuBounds(): a = Symbol('a', real=True) assert latex(AccumBounds(0, 1)) == r"\left\langle 0, 1\right\rangle" assert latex(AccumBounds(0, a)) == r"\left\langle 0, a\right\rangle" assert latex(AccumBounds(a + 1, a + 2)) == \ r"\left\langle a + 1, a + 2\right\rangle" def test_latex_emptyset(): assert latex(S.EmptySet) == r"\emptyset" def test_latex_commutator(): A = Operator('A') B = Operator('B') comm = Commutator(B, A) assert latex(comm.doit()) == r"- (A B - B A)" def test_latex_union(): assert latex(Union(Interval(0, 1), Interval(2, 3))) == \ r"\left[0, 1\right] \cup \left[2, 3\right]" assert latex(Union(Interval(1, 1), Interval(2, 2), Interval(3, 4))) == \ r"\left\{1, 2\right\} \cup \left[3, 4\right]" def test_latex_intersection(): assert latex(Intersection(Interval(0, 1), Interval(x, y))) == \ r"\left[0, 1\right] \cap \left[x, y\right]" def test_latex_symmetric_difference(): assert latex(SymmetricDifference(Interval(2, 5), Interval(4, 7), evaluate=False)) == \ r'\left[2, 5\right] \triangle \left[4, 7\right]' def test_latex_Complement(): assert latex(Complement(S.Reals, S.Naturals)) == \ r"\mathbb{R} \setminus \mathbb{N}" def test_latex_Complexes(): assert latex(S.Complexes) == r"\mathbb{C}" def test_latex_productset(): line = Interval(0, 1) bigline = Interval(0, 10) fset = FiniteSet(1, 2, 3) assert latex(line**2) == r"%s^{2}" % latex(line) assert latex(line**10) == r"%s^{10}" % latex(line) assert latex(line * bigline * fset) == r"%s \times %s \times %s" % ( latex(line), latex(bigline), latex(fset)) def test_latex_Naturals(): assert latex(S.Naturals) == r"\mathbb{N}" def test_latex_Naturals0(): assert latex(S.Naturals0) == r"\mathbb{N}_0" def test_latex_Integers(): assert latex(S.Integers) == r"\mathbb{Z}" def test_latex_ImageSet(): x = Symbol('x') assert latex(ImageSet(Lambda(x, x**2), S.Naturals)) == \ r"\left\{x^{2}\; |\; x \in \mathbb{N}\right\}" y = Symbol('y') imgset = ImageSet(Lambda((x, y), x + y), {1, 2, 3}, {3, 4}) assert latex(imgset) == \ r"\left\{x + y\; |\; x \in \left\{1, 2, 3\right\}, y \in \left\{3, 4\right\}\right\}" def test_latex_ConditionSet(): x = Symbol('x') assert latex(ConditionSet(x, Eq(x**2, 1), S.Reals)) == \ r"\left\{x \mid x \in \mathbb{R} \wedge x^{2} = 1 \right\}" assert latex(ConditionSet(x, Eq(x**2, 1), S.UniversalSet)) == \ r"\left\{x \mid x^{2} = 1 \right\}" def test_latex_ComplexRegion(): assert latex(ComplexRegion(Interval(3, 5)*Interval(4, 6))) == \ r"\left\{x + y i\; |\; x, y \in \left[3, 5\right] \times \left[4, 6\right] \right\}" assert latex(ComplexRegion(Interval(0, 1)*Interval(0, 2*pi), polar=True)) == \ r"\left\{r \left(i \sin{\left(\theta \right)} + \cos{\left(\theta "\ r"\right)}\right)\; |\; r, \theta \in \left[0, 1\right] \times \left[0, 2 \pi\right) \right\}" def test_latex_Contains(): x = Symbol('x') assert latex(Contains(x, S.Naturals)) == r"x \in \mathbb{N}" def test_latex_sum(): assert latex(Sum(x*y**2, (x, -2, 2), (y, -5, 5))) == \ r"\sum_{\substack{-2 \leq x \leq 2\\-5 \leq y \leq 5}} x y^{2}" assert latex(Sum(x**2, (x, -2, 2))) == \ r"\sum_{x=-2}^{2} x^{2}" assert latex(Sum(x**2 + y, (x, -2, 2))) == \ r"\sum_{x=-2}^{2} \left(x^{2} + y\right)" assert latex(Sum(x**2 + y, (x, -2, 2))**2) == \ r"\left(\sum_{x=-2}^{2} \left(x^{2} + y\right)\right)^{2}" def test_latex_product(): assert latex(Product(x*y**2, (x, -2, 2), (y, -5, 5))) == \ r"\prod_{\substack{-2 \leq x \leq 2\\-5 \leq y \leq 5}} x y^{2}" assert latex(Product(x**2, (x, -2, 2))) == \ r"\prod_{x=-2}^{2} x^{2}" assert latex(Product(x**2 + y, (x, -2, 2))) == \ r"\prod_{x=-2}^{2} \left(x^{2} + y\right)" assert latex(Product(x, (x, -2, 2))**2) == \ r"\left(\prod_{x=-2}^{2} x\right)^{2}" def test_latex_limits(): assert latex(Limit(x, x, oo)) == r"\lim_{x \to \infty} x" # issue 8175 f = Function('f') assert latex(Limit(f(x), x, 0)) == r"\lim_{x \to 0^+} f{\left(x \right)}" assert latex(Limit(f(x), x, 0, "-")) == \ r"\lim_{x \to 0^-} f{\left(x \right)}" # issue #10806 assert latex(Limit(f(x), x, 0)**2) == \ r"\left(\lim_{x \to 0^+} f{\left(x \right)}\right)^{2}" # bi-directional limit assert latex(Limit(f(x), x, 0, dir='+-')) == \ r"\lim_{x \to 0} f{\left(x \right)}" def test_latex_log(): assert latex(log(x)) == r"\log{\left(x \right)}" assert latex(ln(x)) == r"\log{\left(x \right)}" assert latex(log(x), ln_notation=True) == r"\ln{\left(x \right)}" assert latex(log(x)+log(y)) == \ r"\log{\left(x \right)} + \log{\left(y \right)}" assert latex(log(x)+log(y), ln_notation=True) == \ r"\ln{\left(x \right)} + \ln{\left(y \right)}" assert latex(pow(log(x), x)) == r"\log{\left(x \right)}^{x}" assert latex(pow(log(x), x), ln_notation=True) == \ r"\ln{\left(x \right)}^{x}" def test_issue_3568(): beta = Symbol(r'\beta') y = beta + x assert latex(y) in [r'\beta + x', r'x + \beta'] beta = Symbol(r'beta') y = beta + x assert latex(y) in [r'\beta + x', r'x + \beta'] def test_latex(): assert latex((2*tau)**Rational(7, 2)) == "8 \\sqrt{2} \\tau^{\\frac{7}{2}}" assert latex((2*mu)**Rational(7, 2), mode='equation*') == \ "\\begin{equation*}8 \\sqrt{2} \\mu^{\\frac{7}{2}}\\end{equation*}" assert latex((2*mu)**Rational(7, 2), mode='equation', itex=True) == \ "$$8 \\sqrt{2} \\mu^{\\frac{7}{2}}$$" assert latex([2/x, y]) == r"\left[ \frac{2}{x}, \ y\right]" def test_latex_dict(): d = {Rational(1): 1, x**2: 2, x: 3, x**3: 4} assert latex(d) == \ r'\left\{ 1 : 1, \ x : 3, \ x^{2} : 2, \ x^{3} : 4\right\}' D = Dict(d) assert latex(D) == \ r'\left\{ 1 : 1, \ x : 3, \ x^{2} : 2, \ x^{3} : 4\right\}' def test_latex_list(): ll = [Symbol('omega1'), Symbol('a'), Symbol('alpha')] assert latex(ll) == r'\left[ \omega_{1}, \ a, \ \alpha\right]' def test_latex_rational(): # tests issue 3973 assert latex(-Rational(1, 2)) == "- \\frac{1}{2}" assert latex(Rational(-1, 2)) == "- \\frac{1}{2}" assert latex(Rational(1, -2)) == "- \\frac{1}{2}" assert latex(-Rational(-1, 2)) == "\\frac{1}{2}" assert latex(-Rational(1, 2)*x) == "- \\frac{x}{2}" assert latex(-Rational(1, 2)*x + Rational(-2, 3)*y) == \ "- \\frac{x}{2} - \\frac{2 y}{3}" def test_latex_inverse(): # tests issue 4129 assert latex(1/x) == "\\frac{1}{x}" assert latex(1/(x + y)) == "\\frac{1}{x + y}" def test_latex_DiracDelta(): assert latex(DiracDelta(x)) == r"\delta\left(x\right)" assert latex(DiracDelta(x)**2) == r"\left(\delta\left(x\right)\right)^{2}" assert latex(DiracDelta(x, 0)) == r"\delta\left(x\right)" assert latex(DiracDelta(x, 5)) == \ r"\delta^{\left( 5 \right)}\left( x \right)" assert latex(DiracDelta(x, 5)**2) == \ r"\left(\delta^{\left( 5 \right)}\left( x \right)\right)^{2}" def test_latex_Heaviside(): assert latex(Heaviside(x)) == r"\theta\left(x\right)" assert latex(Heaviside(x)**2) == r"\left(\theta\left(x\right)\right)^{2}" def test_latex_KroneckerDelta(): assert latex(KroneckerDelta(x, y)) == r"\delta_{x y}" assert latex(KroneckerDelta(x, y + 1)) == r"\delta_{x, y + 1}" # issue 6578 assert latex(KroneckerDelta(x + 1, y)) == r"\delta_{y, x + 1}" assert latex(Pow(KroneckerDelta(x, y), 2, evaluate=False)) == \ r"\left(\delta_{x y}\right)^{2}" def test_latex_LeviCivita(): assert latex(LeviCivita(x, y, z)) == r"\varepsilon_{x y z}" assert latex(LeviCivita(x, y, z)**2) == \ r"\left(\varepsilon_{x y z}\right)^{2}" assert latex(LeviCivita(x, y, z + 1)) == r"\varepsilon_{x, y, z + 1}" assert latex(LeviCivita(x, y + 1, z)) == r"\varepsilon_{x, y + 1, z}" assert latex(LeviCivita(x + 1, y, z)) == r"\varepsilon_{x + 1, y, z}" def test_mode(): expr = x + y assert latex(expr) == 'x + y' assert latex(expr, mode='plain') == 'x + y' assert latex(expr, mode='inline') == '$x + y$' assert latex( expr, mode='equation*') == '\\begin{equation*}x + y\\end{equation*}' assert latex( expr, mode='equation') == '\\begin{equation}x + y\\end{equation}' raises(ValueError, lambda: latex(expr, mode='foo')) def test_latex_Piecewise(): p = Piecewise((x, x < 1), (x**2, True)) assert latex(p) == "\\begin{cases} x & \\text{for}\\: x < 1 \\\\x^{2} &" \ " \\text{otherwise} \\end{cases}" assert latex(p, itex=True) == \ "\\begin{cases} x & \\text{for}\\: x \\lt 1 \\\\x^{2} &" \ " \\text{otherwise} \\end{cases}" p = Piecewise((x, x < 0), (0, x >= 0)) assert latex(p) == '\\begin{cases} x & \\text{for}\\: x < 0 \\\\0 &' \ ' \\text{otherwise} \\end{cases}' A, B = symbols("A B", commutative=False) p = Piecewise((A**2, Eq(A, B)), (A*B, True)) s = r"\begin{cases} A^{2} & \text{for}\: A = B \\A B & \text{otherwise} \end{cases}" assert latex(p) == s assert latex(A*p) == r"A \left(%s\right)" % s assert latex(p*A) == r"\left(%s\right) A" % s assert latex(Piecewise((x, x < 1), (x**2, x < 2))) == \ '\\begin{cases} x & ' \ '\\text{for}\\: x < 1 \\\\x^{2} & \\text{for}\\: x < 2 \\end{cases}' def test_latex_Matrix(): M = Matrix([[1 + x, y], [y, x - 1]]) assert latex(M) == \ r'\left[\begin{matrix}x + 1 & y\\y & x - 1\end{matrix}\right]' assert latex(M, mode='inline') == \ r'$\left[\begin{smallmatrix}x + 1 & y\\' \ r'y & x - 1\end{smallmatrix}\right]$' assert latex(M, mat_str='array') == \ r'\left[\begin{array}{cc}x + 1 & y\\y & x - 1\end{array}\right]' assert latex(M, mat_str='bmatrix') == \ r'\left[\begin{bmatrix}x + 1 & y\\y & x - 1\end{bmatrix}\right]' assert latex(M, mat_delim=None, mat_str='bmatrix') == \ r'\begin{bmatrix}x + 1 & y\\y & x - 1\end{bmatrix}' M2 = Matrix(1, 11, range(11)) assert latex(M2) == \ r'\left[\begin{array}{ccccccccccc}' \ r'0 & 1 & 2 & 3 & 4 & 5 & 6 & 7 & 8 & 9 & 10\end{array}\right]' def test_latex_matrix_with_functions(): t = symbols('t') theta1 = symbols('theta1', cls=Function) M = Matrix([[sin(theta1(t)), cos(theta1(t))], [cos(theta1(t).diff(t)), sin(theta1(t).diff(t))]]) expected = (r'\left[\begin{matrix}\sin{\left(' r'\theta_{1}{\left(t \right)} \right)} & ' r'\cos{\left(\theta_{1}{\left(t \right)} \right)' r'}\\\cos{\left(\frac{d}{d t} \theta_{1}{\left(t ' r'\right)} \right)} & \sin{\left(\frac{d}{d t} ' r'\theta_{1}{\left(t \right)} \right' r')}\end{matrix}\right]') assert latex(M) == expected def test_latex_NDimArray(): x, y, z, w = symbols("x y z w") for ArrayType in (ImmutableDenseNDimArray, ImmutableSparseNDimArray, MutableDenseNDimArray, MutableSparseNDimArray): # Basic: scalar array M = ArrayType(x) assert latex(M) == "x" M = ArrayType([[1 / x, y], [z, w]]) M1 = ArrayType([1 / x, y, z]) M2 = tensorproduct(M1, M) M3 = tensorproduct(M, M) assert latex(M) == \ '\\left[\\begin{matrix}\\frac{1}{x} & y\\\\z & w\\end{matrix}\\right]' assert latex(M1) == \ "\\left[\\begin{matrix}\\frac{1}{x} & y & z\\end{matrix}\\right]" assert latex(M2) == \ r"\left[\begin{matrix}" \ r"\left[\begin{matrix}\frac{1}{x^{2}} & \frac{y}{x}\\\frac{z}{x} & \frac{w}{x}\end{matrix}\right] & " \ r"\left[\begin{matrix}\frac{y}{x} & y^{2}\\y z & w y\end{matrix}\right] & " \ r"\left[\begin{matrix}\frac{z}{x} & y z\\z^{2} & w z\end{matrix}\right]" \ r"\end{matrix}\right]" assert latex(M3) == \ r"""\left[\begin{matrix}"""\ r"""\left[\begin{matrix}\frac{1}{x^{2}} & \frac{y}{x}\\\frac{z}{x} & \frac{w}{x}\end{matrix}\right] & """\ r"""\left[\begin{matrix}\frac{y}{x} & y^{2}\\y z & w y\end{matrix}\right]\\"""\ r"""\left[\begin{matrix}\frac{z}{x} & y z\\z^{2} & w z\end{matrix}\right] & """\ r"""\left[\begin{matrix}\frac{w}{x} & w y\\w z & w^{2}\end{matrix}\right]"""\ r"""\end{matrix}\right]""" Mrow = ArrayType([[x, y, 1/z]]) Mcolumn = ArrayType([[x], [y], [1/z]]) Mcol2 = ArrayType([Mcolumn.tolist()]) assert latex(Mrow) == \ r"\left[\left[\begin{matrix}x & y & \frac{1}{z}\end{matrix}\right]\right]" assert latex(Mcolumn) == \ r"\left[\begin{matrix}x\\y\\\frac{1}{z}\end{matrix}\right]" assert latex(Mcol2) == \ r'\left[\begin{matrix}\left[\begin{matrix}x\\y\\\frac{1}{z}\end{matrix}\right]\end{matrix}\right]' def test_latex_mul_symbol(): assert latex(4*4**x, mul_symbol='times') == "4 \\times 4^{x}" assert latex(4*4**x, mul_symbol='dot') == "4 \\cdot 4^{x}" assert latex(4*4**x, mul_symbol='ldot') == r"4 \,.\, 4^{x}" assert latex(4*x, mul_symbol='times') == "4 \\times x" assert latex(4*x, mul_symbol='dot') == "4 \\cdot x" assert latex(4*x, mul_symbol='ldot') == r"4 \,.\, x" def test_latex_issue_4381(): y = 4*4**log(2) assert latex(y) == r'4 \cdot 4^{\log{\left(2 \right)}}' assert latex(1/y) == r'\frac{1}{4 \cdot 4^{\log{\left(2 \right)}}}' def test_latex_issue_4576(): assert latex(Symbol("beta_13_2")) == r"\beta_{13 2}" assert latex(Symbol("beta_132_20")) == r"\beta_{132 20}" assert latex(Symbol("beta_13")) == r"\beta_{13}" assert latex(Symbol("x_a_b")) == r"x_{a b}" assert latex(Symbol("x_1_2_3")) == r"x_{1 2 3}" assert latex(Symbol("x_a_b1")) == r"x_{a b1}" assert latex(Symbol("x_a_1")) == r"x_{a 1}" assert latex(Symbol("x_1_a")) == r"x_{1 a}" assert latex(Symbol("x_1^aa")) == r"x^{aa}_{1}" assert latex(Symbol("x_1__aa")) == r"x^{aa}_{1}" assert latex(Symbol("x_11^a")) == r"x^{a}_{11}" assert latex(Symbol("x_11__a")) == r"x^{a}_{11}" assert latex(Symbol("x_a_a_a_a")) == r"x_{a a a a}" assert latex(Symbol("x_a_a^a^a")) == r"x^{a a}_{a a}" assert latex(Symbol("x_a_a__a__a")) == r"x^{a a}_{a a}" assert latex(Symbol("alpha_11")) == r"\alpha_{11}" assert latex(Symbol("alpha_11_11")) == r"\alpha_{11 11}" assert latex(Symbol("alpha_alpha")) == r"\alpha_{\alpha}" assert latex(Symbol("alpha^aleph")) == r"\alpha^{\aleph}" assert latex(Symbol("alpha__aleph")) == r"\alpha^{\aleph}" def test_latex_pow_fraction(): x = Symbol('x') # Testing exp assert 'e^{-x}' in latex(exp(-x)/2).replace(' ', '') # Remove Whitespace # Testing e^{-x} in case future changes alter behavior of muls or fracs # In particular current output is \frac{1}{2}e^{- x} but perhaps this will # change to \frac{e^{-x}}{2} # Testing general, non-exp, power assert '3^{-x}' in latex(3**-x/2).replace(' ', '') def test_noncommutative(): A, B, C = symbols('A,B,C', commutative=False) assert latex(A*B*C**-1) == "A B C^{-1}" assert latex(C**-1*A*B) == "C^{-1} A B" assert latex(A*C**-1*B) == "A C^{-1} B" def test_latex_order(): expr = x**3 + x**2*y + y**4 + 3*x*y**3 assert latex(expr, order='lex') == "x^{3} + x^{2} y + 3 x y^{3} + y^{4}" assert latex( expr, order='rev-lex') == "y^{4} + 3 x y^{3} + x^{2} y + x^{3}" assert latex(expr, order='none') == "x^{3} + y^{4} + y x^{2} + 3 x y^{3}" def test_latex_Lambda(): assert latex(Lambda(x, x + 1)) == \ r"\left( x \mapsto x + 1 \right)" assert latex(Lambda((x, y), x + 1)) == \ r"\left( \left( x, \ y\right) \mapsto x + 1 \right)" def test_latex_PolyElement(): Ruv, u, v = ring("u,v", ZZ) Rxyz, x, y, z = ring("x,y,z", Ruv) assert latex(x - x) == r"0" assert latex(x - 1) == r"x - 1" assert latex(x + 1) == r"x + 1" assert latex((u**2 + 3*u*v + 1)*x**2*y + u + 1) == \ r"\left({u}^{2} + 3 u v + 1\right) {x}^{2} y + u + 1" assert latex((u**2 + 3*u*v + 1)*x**2*y + (u + 1)*x) == \ r"\left({u}^{2} + 3 u v + 1\right) {x}^{2} y + \left(u + 1\right) x" assert latex((u**2 + 3*u*v + 1)*x**2*y + (u + 1)*x + 1) == \ r"\left({u}^{2} + 3 u v + 1\right) {x}^{2} y + \left(u + 1\right) x + 1" assert latex((-u**2 + 3*u*v - 1)*x**2*y - (u + 1)*x - 1) == \ r"-\left({u}^{2} - 3 u v + 1\right) {x}^{2} y - \left(u + 1\right) x - 1" assert latex(-(v**2 + v + 1)*x + 3*u*v + 1) == \ r"-\left({v}^{2} + v + 1\right) x + 3 u v + 1" assert latex(-(v**2 + v + 1)*x - 3*u*v + 1) == \ r"-\left({v}^{2} + v + 1\right) x - 3 u v + 1" def test_latex_FracElement(): Fuv, u, v = field("u,v", ZZ) Fxyzt, x, y, z, t = field("x,y,z,t", Fuv) assert latex(x - x) == r"0" assert latex(x - 1) == r"x - 1" assert latex(x + 1) == r"x + 1" assert latex(x/3) == r"\frac{x}{3}" assert latex(x/z) == r"\frac{x}{z}" assert latex(x*y/z) == r"\frac{x y}{z}" assert latex(x/(z*t)) == r"\frac{x}{z t}" assert latex(x*y/(z*t)) == r"\frac{x y}{z t}" assert latex((x - 1)/y) == r"\frac{x - 1}{y}" assert latex((x + 1)/y) == r"\frac{x + 1}{y}" assert latex((-x - 1)/y) == r"\frac{-x - 1}{y}" assert latex((x + 1)/(y*z)) == r"\frac{x + 1}{y z}" assert latex(-y/(x + 1)) == r"\frac{-y}{x + 1}" assert latex(y*z/(x + 1)) == r"\frac{y z}{x + 1}" assert latex(((u + 1)*x*y + 1)/((v - 1)*z - 1)) == \ r"\frac{\left(u + 1\right) x y + 1}{\left(v - 1\right) z - 1}" assert latex(((u + 1)*x*y + 1)/((v - 1)*z - t*u*v - 1)) == \ r"\frac{\left(u + 1\right) x y + 1}{\left(v - 1\right) z - u v t - 1}" def test_latex_Poly(): assert latex(Poly(x**2 + 2 * x, x)) == \ r"\operatorname{Poly}{\left( x^{2} + 2 x, x, domain=\mathbb{Z} \right)}" assert latex(Poly(x/y, x)) == \ r"\operatorname{Poly}{\left( \frac{1}{y} x, x, domain=\mathbb{Z}\left(y\right) \right)}" assert latex(Poly(2.0*x + y)) == \ r"\operatorname{Poly}{\left( 2.0 x + 1.0 y, x, y, domain=\mathbb{R} \right)}" def test_latex_Poly_order(): assert latex(Poly([a, 1, b, 2, c, 3], x)) == \ '\\operatorname{Poly}{\\left( a x^{5} + x^{4} + b x^{3} + 2 x^{2} + c'\ ' x + 3, x, domain=\\mathbb{Z}\\left[a, b, c\\right] \\right)}' assert latex(Poly([a, 1, b+c, 2, 3], x)) == \ '\\operatorname{Poly}{\\left( a x^{4} + x^{3} + \\left(b + c\\right) '\ 'x^{2} + 2 x + 3, x, domain=\\mathbb{Z}\\left[a, b, c\\right] \\right)}' assert latex(Poly(a*x**3 + x**2*y - x*y - c*y**3 - b*x*y**2 + y - a*x + b, (x, y))) == \ '\\operatorname{Poly}{\\left( a x^{3} + x^{2}y - b xy^{2} - xy - '\ 'a x - c y^{3} + y + b, x, y, domain=\\mathbb{Z}\\left[a, b, c\\right] \\right)}' def test_latex_ComplexRootOf(): assert latex(rootof(x**5 + x + 3, 0)) == \ r"\operatorname{CRootOf} {\left(x^{5} + x + 3, 0\right)}" def test_latex_RootSum(): assert latex(RootSum(x**5 + x + 3, sin)) == \ r"\operatorname{RootSum} {\left(x^{5} + x + 3, \left( x \mapsto \sin{\left(x \right)} \right)\right)}" def test_settings(): raises(TypeError, lambda: latex(x*y, method="garbage")) def test_latex_numbers(): assert latex(catalan(n)) == r"C_{n}" assert latex(catalan(n)**2) == r"C_{n}^{2}" assert latex(bernoulli(n)) == r"B_{n}" assert latex(bernoulli(n)**2) == r"B_{n}^{2}" assert latex(bell(n)) == r"B_{n}" assert latex(bell(n)**2) == r"B_{n}^{2}" assert latex(fibonacci(n)) == r"F_{n}" assert latex(fibonacci(n)**2) == r"F_{n}^{2}" assert latex(lucas(n)) == r"L_{n}" assert latex(lucas(n)**2) == r"L_{n}^{2}" assert latex(tribonacci(n)) == r"T_{n}" assert latex(tribonacci(n)**2) == r"T_{n}^{2}" def test_latex_euler(): assert latex(euler(n)) == r"E_{n}" assert latex(euler(n, x)) == r"E_{n}\left(x\right)" assert latex(euler(n, x)**2) == r"E_{n}^{2}\left(x\right)" def test_lamda(): assert latex(Symbol('lamda')) == r"\lambda" assert latex(Symbol('Lamda')) == r"\Lambda" def test_custom_symbol_names(): x = Symbol('x') y = Symbol('y') assert latex(x) == "x" assert latex(x, symbol_names={x: "x_i"}) == "x_i" assert latex(x + y, symbol_names={x: "x_i"}) == "x_i + y" assert latex(x**2, symbol_names={x: "x_i"}) == "x_i^{2}" assert latex(x + y, symbol_names={x: "x_i", y: "y_j"}) == "x_i + y_j" def test_matAdd(): from sympy import MatrixSymbol from sympy.printing.latex import LatexPrinter C = MatrixSymbol('C', 5, 5) B = MatrixSymbol('B', 5, 5) l = LatexPrinter() assert l._print(C - 2*B) in ['- 2 B + C', 'C -2 B'] assert l._print(C + 2*B) in ['2 B + C', 'C + 2 B'] assert l._print(B - 2*C) in ['B - 2 C', '- 2 C + B'] assert l._print(B + 2*C) in ['B + 2 C', '2 C + B'] def test_matMul(): from sympy import MatrixSymbol from sympy.printing.latex import LatexPrinter A = MatrixSymbol('A', 5, 5) B = MatrixSymbol('B', 5, 5) x = Symbol('x') lp = LatexPrinter() assert lp._print_MatMul(2*A) == '2 A' assert lp._print_MatMul(2*x*A) == '2 x A' assert lp._print_MatMul(-2*A) == '- 2 A' assert lp._print_MatMul(1.5*A) == '1.5 A' assert lp._print_MatMul(sqrt(2)*A) == r'\sqrt{2} A' assert lp._print_MatMul(-sqrt(2)*A) == r'- \sqrt{2} A' assert lp._print_MatMul(2*sqrt(2)*x*A) == r'2 \sqrt{2} x A' assert lp._print_MatMul(-2*A*(A + 2*B)) in [r'- 2 A \left(A + 2 B\right)', r'- 2 A \left(2 B + A\right)'] def test_latex_MatrixSlice(): from sympy.matrices.expressions import MatrixSymbol assert latex(MatrixSymbol('X', 10, 10)[:5, 1:9:2]) == \ r'X\left[:5, 1:9:2\right]' assert latex(MatrixSymbol('X', 10, 10)[5, :5:2]) == \ r'X\left[5, :5:2\right]' def test_latex_RandomDomain(): from sympy.stats import Normal, Die, Exponential, pspace, where from sympy.stats.rv import RandomDomain X = Normal('x1', 0, 1) assert latex(where(X > 0)) == r"\text{Domain: }0 < x_{1} \wedge x_{1} < \infty" D = Die('d1', 6) assert latex(where(D > 4)) == r"\text{Domain: }d_{1} = 5 \vee d_{1} = 6" A = Exponential('a', 1) B = Exponential('b', 1) assert latex( pspace(Tuple(A, B)).domain) == \ r"\text{Domain: }0 \leq a \wedge 0 \leq b \wedge a < \infty \wedge b < \infty" assert latex(RandomDomain(FiniteSet(x), FiniteSet(1, 2))) == \ r'\text{Domain: }\left\{x\right\}\text{ in }\left\{1, 2\right\}' def test_PrettyPoly(): from sympy.polys.domains import QQ F = QQ.frac_field(x, y) R = QQ[x, y] assert latex(F.convert(x/(x + y))) == latex(x/(x + y)) assert latex(R.convert(x + y)) == latex(x + y) def test_integral_transforms(): x = Symbol("x") k = Symbol("k") f = Function("f") a = Symbol("a") b = Symbol("b") assert latex(MellinTransform(f(x), x, k)) == \ r"\mathcal{M}_{x}\left[f{\left(x \right)}\right]\left(k\right)" assert latex(InverseMellinTransform(f(k), k, x, a, b)) == \ r"\mathcal{M}^{-1}_{k}\left[f{\left(k \right)}\right]\left(x\right)" assert latex(LaplaceTransform(f(x), x, k)) == \ r"\mathcal{L}_{x}\left[f{\left(x \right)}\right]\left(k\right)" assert latex(InverseLaplaceTransform(f(k), k, x, (a, b))) == \ r"\mathcal{L}^{-1}_{k}\left[f{\left(k \right)}\right]\left(x\right)" assert latex(FourierTransform(f(x), x, k)) == \ r"\mathcal{F}_{x}\left[f{\left(x \right)}\right]\left(k\right)" assert latex(InverseFourierTransform(f(k), k, x)) == \ r"\mathcal{F}^{-1}_{k}\left[f{\left(k \right)}\right]\left(x\right)" assert latex(CosineTransform(f(x), x, k)) == \ r"\mathcal{COS}_{x}\left[f{\left(x \right)}\right]\left(k\right)" assert latex(InverseCosineTransform(f(k), k, x)) == \ r"\mathcal{COS}^{-1}_{k}\left[f{\left(k \right)}\right]\left(x\right)" assert latex(SineTransform(f(x), x, k)) == \ r"\mathcal{SIN}_{x}\left[f{\left(x \right)}\right]\left(k\right)" assert latex(InverseSineTransform(f(k), k, x)) == \ r"\mathcal{SIN}^{-1}_{k}\left[f{\left(k \right)}\right]\left(x\right)" def test_PolynomialRingBase(): from sympy.polys.domains import QQ assert latex(QQ.old_poly_ring(x, y)) == r"\mathbb{Q}\left[x, y\right]" assert latex(QQ.old_poly_ring(x, y, order="ilex")) == \ r"S_<^{-1}\mathbb{Q}\left[x, y\right]" def test_categories(): from sympy.categories import (Object, IdentityMorphism, NamedMorphism, Category, Diagram, DiagramGrid) A1 = Object("A1") A2 = Object("A2") A3 = Object("A3") f1 = NamedMorphism(A1, A2, "f1") f2 = NamedMorphism(A2, A3, "f2") id_A1 = IdentityMorphism(A1) K1 = Category("K1") assert latex(A1) == "A_{1}" assert latex(f1) == "f_{1}:A_{1}\\rightarrow A_{2}" assert latex(id_A1) == "id:A_{1}\\rightarrow A_{1}" assert latex(f2*f1) == "f_{2}\\circ f_{1}:A_{1}\\rightarrow A_{3}" assert latex(K1) == r"\mathbf{K_{1}}" d = Diagram() assert latex(d) == r"\emptyset" d = Diagram({f1: "unique", f2: S.EmptySet}) assert latex(d) == r"\left\{ f_{2}\circ f_{1}:A_{1}" \ r"\rightarrow A_{3} : \emptyset, \ id:A_{1}\rightarrow " \ r"A_{1} : \emptyset, \ id:A_{2}\rightarrow A_{2} : " \ r"\emptyset, \ id:A_{3}\rightarrow A_{3} : \emptyset, " \ r"\ f_{1}:A_{1}\rightarrow A_{2} : \left\{unique\right\}, " \ r"\ f_{2}:A_{2}\rightarrow A_{3} : \emptyset\right\}" d = Diagram({f1: "unique", f2: S.EmptySet}, {f2 * f1: "unique"}) assert latex(d) == r"\left\{ f_{2}\circ f_{1}:A_{1}" \ r"\rightarrow A_{3} : \emptyset, \ id:A_{1}\rightarrow " \ r"A_{1} : \emptyset, \ id:A_{2}\rightarrow A_{2} : " \ r"\emptyset, \ id:A_{3}\rightarrow A_{3} : \emptyset, " \ r"\ f_{1}:A_{1}\rightarrow A_{2} : \left\{unique\right\}," \ r" \ f_{2}:A_{2}\rightarrow A_{3} : \emptyset\right\}" \ r"\Longrightarrow \left\{ f_{2}\circ f_{1}:A_{1}" \ r"\rightarrow A_{3} : \left\{unique\right\}\right\}" # A linear diagram. A = Object("A") B = Object("B") C = Object("C") f = NamedMorphism(A, B, "f") g = NamedMorphism(B, C, "g") d = Diagram([f, g]) grid = DiagramGrid(d) assert latex(grid) == "\\begin{array}{cc}\n" \ "A & B \\\\\n" \ " & C \n" \ "\\end{array}\n" def test_Modules(): from sympy.polys.domains import QQ from sympy.polys.agca import homomorphism R = QQ.old_poly_ring(x, y) F = R.free_module(2) M = F.submodule([x, y], [1, x**2]) assert latex(F) == r"{\mathbb{Q}\left[x, y\right]}^{2}" assert latex(M) == \ r"\left\langle {\left[ {x},{y} \right]},{\left[ {1},{x^{2}} \right]} \right\rangle" I = R.ideal(x**2, y) assert latex(I) == r"\left\langle {x^{2}},{y} \right\rangle" Q = F / M assert latex(Q) == \ r"\frac{{\mathbb{Q}\left[x, y\right]}^{2}}{\left\langle {\left[ {x},"\ r"{y} \right]},{\left[ {1},{x^{2}} \right]} \right\rangle}" assert latex(Q.submodule([1, x**3/2], [2, y])) == \ r"\left\langle {{\left[ {1},{\frac{x^{3}}{2}} \right]} + {\left"\ r"\langle {\left[ {x},{y} \right]},{\left[ {1},{x^{2}} \right]} "\ r"\right\rangle}},{{\left[ {2},{y} \right]} + {\left\langle {\left[ "\ r"{x},{y} \right]},{\left[ {1},{x^{2}} \right]} \right\rangle}} \right\rangle" h = homomorphism(QQ.old_poly_ring(x).free_module(2), QQ.old_poly_ring(x).free_module(2), [0, 0]) assert latex(h) == \ r"{\left[\begin{matrix}0 & 0\\0 & 0\end{matrix}\right]} : "\ r"{{\mathbb{Q}\left[x\right]}^{2}} \to {{\mathbb{Q}\left[x\right]}^{2}}" def test_QuotientRing(): from sympy.polys.domains import QQ R = QQ.old_poly_ring(x)/[x**2 + 1] assert latex(R) == \ r"\frac{\mathbb{Q}\left[x\right]}{\left\langle {x^{2} + 1} \right\rangle}" assert latex(R.one) == r"{1} + {\left\langle {x^{2} + 1} \right\rangle}" def test_Tr(): #TODO: Handle indices A, B = symbols('A B', commutative=False) t = Tr(A*B) assert latex(t) == r'\operatorname{tr}\left(A B\right)' def test_Adjoint(): from sympy.matrices import MatrixSymbol, Adjoint, Inverse, Transpose X = MatrixSymbol('X', 2, 2) Y = MatrixSymbol('Y', 2, 2) assert latex(Adjoint(X)) == r'X^{\dagger}' assert latex(Adjoint(X + Y)) == r'\left(X + Y\right)^{\dagger}' assert latex(Adjoint(X) + Adjoint(Y)) == r'X^{\dagger} + Y^{\dagger}' assert latex(Adjoint(X*Y)) == r'\left(X Y\right)^{\dagger}' assert latex(Adjoint(Y)*Adjoint(X)) == r'Y^{\dagger} X^{\dagger}' assert latex(Adjoint(X**2)) == r'\left(X^{2}\right)^{\dagger}' assert latex(Adjoint(X)**2) == r'\left(X^{\dagger}\right)^{2}' assert latex(Adjoint(Inverse(X))) == r'\left(X^{-1}\right)^{\dagger}' assert latex(Inverse(Adjoint(X))) == r'\left(X^{\dagger}\right)^{-1}' assert latex(Adjoint(Transpose(X))) == r'\left(X^{T}\right)^{\dagger}' assert latex(Transpose(Adjoint(X))) == r'\left(X^{\dagger}\right)^{T}' assert latex(Transpose(Adjoint(X) + Y)) == r'\left(X^{\dagger} + Y\right)^{T}' assert latex(Transpose(X)) == r'X^{T}' assert latex(Transpose(X + Y)) == r'\left(X + Y\right)^{T}' def test_Hadamard(): from sympy.matrices import MatrixSymbol, HadamardProduct X = MatrixSymbol('X', 2, 2) Y = MatrixSymbol('Y', 2, 2) assert latex(HadamardProduct(X, Y*Y)) == r'X \circ Y^{2}' assert latex(HadamardProduct(X, Y)*Y) == r'\left(X \circ Y\right) Y' def test_ZeroMatrix(): from sympy import ZeroMatrix assert latex(ZeroMatrix(1, 1)) == r"\mathbb{0}" def test_Identity(): from sympy import Identity assert latex(Identity(1)) == r"\mathbb{I}" def test_boolean_args_order(): syms = symbols('a:f') expr = And(*syms) assert latex(expr) == 'a \\wedge b \\wedge c \\wedge d \\wedge e \\wedge f' expr = Or(*syms) assert latex(expr) == 'a \\vee b \\vee c \\vee d \\vee e \\vee f' expr = Equivalent(*syms) assert latex(expr) == \ 'a \\Leftrightarrow b \\Leftrightarrow c \\Leftrightarrow d \\Leftrightarrow e \\Leftrightarrow f' expr = Xor(*syms) assert latex(expr) == \ 'a \\veebar b \\veebar c \\veebar d \\veebar e \\veebar f' def test_imaginary(): i = sqrt(-1) assert latex(i) == r'i' def test_builtins_without_args(): assert latex(sin) == r'\sin' assert latex(cos) == r'\cos' assert latex(tan) == r'\tan' assert latex(log) == r'\log' assert latex(Ei) == r'\operatorname{Ei}' assert latex(zeta) == r'\zeta' def test_latex_greek_functions(): # bug because capital greeks that have roman equivalents should not use # \Alpha, \Beta, \Eta, etc. s = Function('Alpha') assert latex(s) == r'A' assert latex(s(x)) == r'A{\left(x \right)}' s = Function('Beta') assert latex(s) == r'B' s = Function('Eta') assert latex(s) == r'H' assert latex(s(x)) == r'H{\left(x \right)}' # bug because sympy.core.numbers.Pi is special p = Function('Pi') # assert latex(p(x)) == r'\Pi{\left(x \right)}' assert latex(p) == r'\Pi' # bug because not all greeks are included c = Function('chi') assert latex(c(x)) == r'\chi{\left(x \right)}' assert latex(c) == r'\chi' def test_translate(): s = 'Alpha' assert translate(s) == 'A' s = 'Beta' assert translate(s) == 'B' s = 'Eta' assert translate(s) == 'H' s = 'omicron' assert translate(s) == 'o' s = 'Pi' assert translate(s) == r'\Pi' s = 'pi' assert translate(s) == r'\pi' s = 'LamdaHatDOT' assert translate(s) == r'\dot{\hat{\Lambda}}' def test_other_symbols(): from sympy.printing.latex import other_symbols for s in other_symbols: assert latex(symbols(s)) == "\\"+s def test_modifiers(): # Test each modifier individually in the simplest case # (with funny capitalizations) assert latex(symbols("xMathring")) == r"\mathring{x}" assert latex(symbols("xCheck")) == r"\check{x}" assert latex(symbols("xBreve")) == r"\breve{x}" assert latex(symbols("xAcute")) == r"\acute{x}" assert latex(symbols("xGrave")) == r"\grave{x}" assert latex(symbols("xTilde")) == r"\tilde{x}" assert latex(symbols("xPrime")) == r"{x}'" assert latex(symbols("xddDDot")) == r"\ddddot{x}" assert latex(symbols("xDdDot")) == r"\dddot{x}" assert latex(symbols("xDDot")) == r"\ddot{x}" assert latex(symbols("xBold")) == r"\boldsymbol{x}" assert latex(symbols("xnOrM")) == r"\left\|{x}\right\|" assert latex(symbols("xAVG")) == r"\left\langle{x}\right\rangle" assert latex(symbols("xHat")) == r"\hat{x}" assert latex(symbols("xDot")) == r"\dot{x}" assert latex(symbols("xBar")) == r"\bar{x}" assert latex(symbols("xVec")) == r"\vec{x}" assert latex(symbols("xAbs")) == r"\left|{x}\right|" assert latex(symbols("xMag")) == r"\left|{x}\right|" assert latex(symbols("xPrM")) == r"{x}'" assert latex(symbols("xBM")) == r"\boldsymbol{x}" # Test strings that are *only* the names of modifiers assert latex(symbols("Mathring")) == r"Mathring" assert latex(symbols("Check")) == r"Check" assert latex(symbols("Breve")) == r"Breve" assert latex(symbols("Acute")) == r"Acute" assert latex(symbols("Grave")) == r"Grave" assert latex(symbols("Tilde")) == r"Tilde" assert latex(symbols("Prime")) == r"Prime" assert latex(symbols("DDot")) == r"\dot{D}" assert latex(symbols("Bold")) == r"Bold" assert latex(symbols("NORm")) == r"NORm" assert latex(symbols("AVG")) == r"AVG" assert latex(symbols("Hat")) == r"Hat" assert latex(symbols("Dot")) == r"Dot" assert latex(symbols("Bar")) == r"Bar" assert latex(symbols("Vec")) == r"Vec" assert latex(symbols("Abs")) == r"Abs" assert latex(symbols("Mag")) == r"Mag" assert latex(symbols("PrM")) == r"PrM" assert latex(symbols("BM")) == r"BM" assert latex(symbols("hbar")) == r"\hbar" # Check a few combinations assert latex(symbols("xvecdot")) == r"\dot{\vec{x}}" assert latex(symbols("xDotVec")) == r"\vec{\dot{x}}" assert latex(symbols("xHATNorm")) == r"\left\|{\hat{x}}\right\|" # Check a couple big, ugly combinations assert latex(symbols('xMathringBm_yCheckPRM__zbreveAbs')) == \ r"\boldsymbol{\mathring{x}}^{\left|{\breve{z}}\right|}_{{\check{y}}'}" assert latex(symbols('alphadothat_nVECDOT__tTildePrime')) == \ r"\hat{\dot{\alpha}}^{{\tilde{t}}'}_{\dot{\vec{n}}}" def test_greek_symbols(): assert latex(Symbol('alpha')) == r'\alpha' assert latex(Symbol('beta')) == r'\beta' assert latex(Symbol('gamma')) == r'\gamma' assert latex(Symbol('delta')) == r'\delta' assert latex(Symbol('epsilon')) == r'\epsilon' assert latex(Symbol('zeta')) == r'\zeta' assert latex(Symbol('eta')) == r'\eta' assert latex(Symbol('theta')) == r'\theta' assert latex(Symbol('iota')) == r'\iota' assert latex(Symbol('kappa')) == r'\kappa' assert latex(Symbol('lambda')) == r'\lambda' assert latex(Symbol('mu')) == r'\mu' assert latex(Symbol('nu')) == r'\nu' assert latex(Symbol('xi')) == r'\xi' assert latex(Symbol('omicron')) == r'o' assert latex(Symbol('pi')) == r'\pi' assert latex(Symbol('rho')) == r'\rho' assert latex(Symbol('sigma')) == r'\sigma' assert latex(Symbol('tau')) == r'\tau' assert latex(Symbol('upsilon')) == r'\upsilon' assert latex(Symbol('phi')) == r'\phi' assert latex(Symbol('chi')) == r'\chi' assert latex(Symbol('psi')) == r'\psi' assert latex(Symbol('omega')) == r'\omega' assert latex(Symbol('Alpha')) == r'A' assert latex(Symbol('Beta')) == r'B' assert latex(Symbol('Gamma')) == r'\Gamma' assert latex(Symbol('Delta')) == r'\Delta' assert latex(Symbol('Epsilon')) == r'E' assert latex(Symbol('Zeta')) == r'Z' assert latex(Symbol('Eta')) == r'H' assert latex(Symbol('Theta')) == r'\Theta' assert latex(Symbol('Iota')) == r'I' assert latex(Symbol('Kappa')) == r'K' assert latex(Symbol('Lambda')) == r'\Lambda' assert latex(Symbol('Mu')) == r'M' assert latex(Symbol('Nu')) == r'N' assert latex(Symbol('Xi')) == r'\Xi' assert latex(Symbol('Omicron')) == r'O' assert latex(Symbol('Pi')) == r'\Pi' assert latex(Symbol('Rho')) == r'P' assert latex(Symbol('Sigma')) == r'\Sigma' assert latex(Symbol('Tau')) == r'T' assert latex(Symbol('Upsilon')) == r'\Upsilon' assert latex(Symbol('Phi')) == r'\Phi' assert latex(Symbol('Chi')) == r'X' assert latex(Symbol('Psi')) == r'\Psi' assert latex(Symbol('Omega')) == r'\Omega' assert latex(Symbol('varepsilon')) == r'\varepsilon' assert latex(Symbol('varkappa')) == r'\varkappa' assert latex(Symbol('varphi')) == r'\varphi' assert latex(Symbol('varpi')) == r'\varpi' assert latex(Symbol('varrho')) == r'\varrho' assert latex(Symbol('varsigma')) == r'\varsigma' assert latex(Symbol('vartheta')) == r'\vartheta' @XFAIL def test_builtin_without_args_mismatched_names(): assert latex(CosineTransform) == r'\mathcal{COS}' def test_builtin_no_args(): assert latex(Chi) == r'\operatorname{Chi}' assert latex(beta) == r'\operatorname{B}' assert latex(gamma) == r'\Gamma' assert latex(KroneckerDelta) == r'\delta' assert latex(DiracDelta) == r'\delta' assert latex(lowergamma) == r'\gamma' def test_issue_6853(): p = Function('Pi') assert latex(p(x)) == r"\Pi{\left(x \right)}" def test_Mul(): e = Mul(-2, x + 1, evaluate=False) assert latex(e) == r'- 2 \left(x + 1\right)' e = Mul(2, x + 1, evaluate=False) assert latex(e) == r'2 \left(x + 1\right)' e = Mul(S.One/2, x + 1, evaluate=False) assert latex(e) == r'\frac{x + 1}{2}' e = Mul(y, x + 1, evaluate=False) assert latex(e) == r'y \left(x + 1\right)' e = Mul(-y, x + 1, evaluate=False) assert latex(e) == r'- y \left(x + 1\right)' e = Mul(-2, x + 1) assert latex(e) == r'- 2 x - 2' e = Mul(2, x + 1) assert latex(e) == r'2 x + 2' def test_Pow(): e = Pow(2, 2, evaluate=False) assert latex(e) == r'2^{2}' assert latex(x**(Rational(-1, 3))) == r'\frac{1}{\sqrt[3]{x}}' x2 = Symbol(r'x^2') assert latex(x2**2) == r'\left(x^{2}\right)^{2}' def test_issue_7180(): assert latex(Equivalent(x, y)) == r"x \Leftrightarrow y" assert latex(Not(Equivalent(x, y))) == r"x \not\Leftrightarrow y" def test_issue_8409(): assert latex(S.Half**n) == r"\left(\frac{1}{2}\right)^{n}" def test_issue_8470(): from sympy.parsing.sympy_parser import parse_expr e = parse_expr("-B*A", evaluate=False) assert latex(e) == r"A \left(- B\right)" def test_issue_7117(): # See also issue #5031 (hence the evaluate=False in these). e = Eq(x + 1, 2*x) q = Mul(2, e, evaluate=False) assert latex(q) == r"2 \left(x + 1 = 2 x\right)" q = Add(6, e, evaluate=False) assert latex(q) == r"6 + \left(x + 1 = 2 x\right)" q = Pow(e, 2, evaluate=False) assert latex(q) == r"\left(x + 1 = 2 x\right)^{2}" def test_issue_15439(): x = MatrixSymbol('x', 2, 2) y = MatrixSymbol('y', 2, 2) assert latex((x * y).subs(y, -y)) == r"x \left(- y\right)" assert latex((x * y).subs(y, -2*y)) == r"x \left(- 2 y\right)" assert latex((x * y).subs(x, -x)) == r"- x y" def test_issue_2934(): assert latex(Symbol(r'\frac{a_1}{b_1}')) == '\\frac{a_1}{b_1}' def test_issue_10489(): latexSymbolWithBrace = 'C_{x_{0}}' s = Symbol(latexSymbolWithBrace) assert latex(s) == latexSymbolWithBrace assert latex(cos(s)) == r'\cos{\left(C_{x_{0}} \right)}' def test_issue_12886(): m__1, l__1 = symbols('m__1, l__1') assert latex(m__1**2 + l__1**2) == \ r'\left(l^{1}\right)^{2} + \left(m^{1}\right)^{2}' def test_issue_13559(): from sympy.parsing.sympy_parser import parse_expr expr = parse_expr('5/1', evaluate=False) assert latex(expr) == r"\frac{5}{1}" def test_issue_13651(): expr = c + Mul(-1, a + b, evaluate=False) assert latex(expr) == r"c - \left(a + b\right)" def test_latex_UnevaluatedExpr(): x = symbols("x") he = UnevaluatedExpr(1/x) assert latex(he) == latex(1/x) == r"\frac{1}{x}" assert latex(he**2) == r"\left(\frac{1}{x}\right)^{2}" assert latex(he + 1) == r"1 + \frac{1}{x}" assert latex(x*he) == r"x \frac{1}{x}" def test_MatrixElement_printing(): # test cases for issue #11821 A = MatrixSymbol("A", 1, 3) B = MatrixSymbol("B", 1, 3) C = MatrixSymbol("C", 1, 3) assert latex(A[0, 0]) == r"A_{0, 0}" assert latex(3 * A[0, 0]) == r"3 A_{0, 0}" F = C[0, 0].subs(C, A - B) assert latex(F) == r"\left(A - B\right)_{0, 0}" i, j, k = symbols("i j k") M = MatrixSymbol("M", k, k) N = MatrixSymbol("N", k, k) assert latex((M*N)[i, j]) == \ r'\sum_{i_{1}=0}^{k - 1} M_{i, i_{1}} N_{i_{1}, j}' def test_MatrixSymbol_printing(): # test cases for issue #14237 A = MatrixSymbol("A", 3, 3) B = MatrixSymbol("B", 3, 3) C = MatrixSymbol("C", 3, 3) assert latex(-A) == r"- A" assert latex(A - A*B - B) == r"A - A B - B" assert latex(-A*B - A*B*C - B) == r"- A B - A B C - B" def test_KroneckerProduct_printing(): A = MatrixSymbol('A', 3, 3) B = MatrixSymbol('B', 2, 2) assert latex(KroneckerProduct(A, B)) == r'A \otimes B' def test_Quaternion_latex_printing(): q = Quaternion(x, y, z, t) assert latex(q) == "x + y i + z j + t k" q = Quaternion(x, y, z, x*t) assert latex(q) == "x + y i + z j + t x k" q = Quaternion(x, y, z, x + t) assert latex(q) == r"x + y i + z j + \left(t + x\right) k" def test_TensorProduct_printing(): from sympy.tensor.functions import TensorProduct A = MatrixSymbol("A", 3, 3) B = MatrixSymbol("B", 3, 3) assert latex(TensorProduct(A, B)) == r"A \otimes B" def test_WedgeProduct_printing(): from sympy.diffgeom.rn import R2 from sympy.diffgeom import WedgeProduct wp = WedgeProduct(R2.dx, R2.dy) assert latex(wp) == r"\operatorname{d}x \wedge \operatorname{d}y" def test_issue_14041(): import sympy.physics.mechanics as me A_frame = me.ReferenceFrame('A') thetad, phid = me.dynamicsymbols('theta, phi', 1) L = Symbol('L') assert latex(L*(phid + thetad)**2*A_frame.x) == \ r"L \left(\dot{\phi} + \dot{\theta}\right)^{2}\mathbf{\hat{a}_x}" assert latex((phid + thetad)**2*A_frame.x) == \ r"\left(\dot{\phi} + \dot{\theta}\right)^{2}\mathbf{\hat{a}_x}" assert latex((phid*thetad)**a*A_frame.x) == \ r"\left(\dot{\phi} \dot{\theta}\right)^{a}\mathbf{\hat{a}_x}" def test_issue_9216(): expr_1 = Pow(1, -1, evaluate=False) assert latex(expr_1) == r"1^{-1}" expr_2 = Pow(1, Pow(1, -1, evaluate=False), evaluate=False) assert latex(expr_2) == r"1^{1^{-1}}" expr_3 = Pow(3, -2, evaluate=False) assert latex(expr_3) == r"\frac{1}{9}" expr_4 = Pow(1, -2, evaluate=False) assert latex(expr_4) == r"1^{-2}" def test_latex_printer_tensor(): from sympy.tensor.tensor import TensorIndexType, tensor_indices, tensorhead L = TensorIndexType("L") i, j, k, l = tensor_indices("i j k l", L) i0 = tensor_indices("i_0", L) A, B, C, D = tensorhead("A B C D", [L], [[1]]) H = tensorhead("H", [L, L], [[1], [1]]) K = tensorhead("K", [L, L, L, L], [[1], [1], [1], [1]]) assert latex(i) == "{}^{i}" assert latex(-i) == "{}_{i}" expr = A(i) assert latex(expr) == "A{}^{i}" expr = A(i0) assert latex(expr) == "A{}^{i_{0}}" expr = A(-i) assert latex(expr) == "A{}_{i}" expr = -3*A(i) assert latex(expr) == r"-3A{}^{i}" expr = K(i, j, -k, -i0) assert latex(expr) == "K{}^{ij}{}_{ki_{0}}" expr = K(i, -j, -k, i0) assert latex(expr) == "K{}^{i}{}_{jk}{}^{i_{0}}" expr = K(i, -j, k, -i0) assert latex(expr) == "K{}^{i}{}_{j}{}^{k}{}_{i_{0}}" expr = H(i, -j) assert latex(expr) == "H{}^{i}{}_{j}" expr = H(i, j) assert latex(expr) == "H{}^{ij}" expr = H(-i, -j) assert latex(expr) == "H{}_{ij}" expr = (1+x)*A(i) assert latex(expr) == r"\left(x + 1\right)A{}^{i}" expr = H(i, -i) assert latex(expr) == "H{}^{L_{0}}{}_{L_{0}}" expr = H(i, -j)*A(j)*B(k) assert latex(expr) == "H{}^{i}{}_{L_{0}}A{}^{L_{0}}B{}^{k}" expr = A(i) + 3*B(i) assert latex(expr) == "3B{}^{i} + A{}^{i}" # Test ``TensorElement``: from sympy.tensor.tensor import TensorElement expr = TensorElement(K(i, j, k, l), {i: 3, k: 2}) assert latex(expr) == 'K{}^{i=3,j,k=2,l}' expr = TensorElement(K(i, j, k, l), {i: 3}) assert latex(expr) == 'K{}^{i=3,jkl}' expr = TensorElement(K(i, -j, k, l), {i: 3, k: 2}) assert latex(expr) == 'K{}^{i=3}{}_{j}{}^{k=2,l}' expr = TensorElement(K(i, -j, k, -l), {i: 3, k: 2}) assert latex(expr) == 'K{}^{i=3}{}_{j}{}^{k=2}{}_{l}' expr = TensorElement(K(i, j, -k, -l), {i: 3, -k: 2}) assert latex(expr) == 'K{}^{i=3,j}{}_{k=2,l}' expr = TensorElement(K(i, j, -k, -l), {i: 3}) assert latex(expr) == 'K{}^{i=3,j}{}_{kl}' def test_issue_15353(): from sympy import ConditionSet, Tuple, FiniteSet, S, sin, cos a, x = symbols('a x') # Obtained from nonlinsolve([(sin(a*x)),cos(a*x)],[x,a]) sol = ConditionSet(Tuple(x, a), FiniteSet(sin(a*x), cos(a*x)), S.Complexes) assert latex(sol) == \ r'\left\{\left( x, \ a\right) \mid \left( x, \ a\right) \in '\ r'\mathbb{C} \wedge \left\{\sin{\left(a x \right)}, \cos{\left(a x '\ r'\right)}\right\} \right\}' def test_trace(): # Issue 15303 from sympy import trace A = MatrixSymbol("A", 2, 2) assert latex(trace(A)) == r"\operatorname{tr}\left(A \right)" assert latex(trace(A**2)) == r"\operatorname{tr}\left(A^{2} \right)" def test_print_basic(): # Issue 15303 from sympy import Basic, Expr # dummy class for testing printing where the function is not # implemented in latex.py class UnimplementedExpr(Expr): def __new__(cls, e): return Basic.__new__(cls, e) # dummy function for testing def unimplemented_expr(expr): return UnimplementedExpr(expr).doit() # override class name to use superscript / subscript def unimplemented_expr_sup_sub(expr): result = UnimplementedExpr(expr) result.__class__.__name__ = 'UnimplementedExpr_x^1' return result assert latex(unimplemented_expr(x)) == r'UnimplementedExpr\left(x\right)' assert latex(unimplemented_expr(x**2)) == \ r'UnimplementedExpr\left(x^{2}\right)' assert latex(unimplemented_expr_sup_sub(x)) == \ r'UnimplementedExpr^{1}_{x}\left(x\right)' def test_MatrixSymbol_bold(): # Issue #15871 from sympy import trace A = MatrixSymbol("A", 2, 2) assert latex(trace(A), mat_symbol_style='bold') == \ r"\operatorname{tr}\left(\mathbf{A} \right)" assert latex(trace(A), mat_symbol_style='plain') == \ r"\operatorname{tr}\left(A \right)" A = MatrixSymbol("A", 3, 3) B = MatrixSymbol("B", 3, 3) C = MatrixSymbol("C", 3, 3) assert latex(-A, mat_symbol_style='bold') == r"- \mathbf{A}" assert latex(A - A*B - B, mat_symbol_style='bold') == \ r"\mathbf{A} - \mathbf{A} \mathbf{B} - \mathbf{B}" assert latex(-A*B - A*B*C - B, mat_symbol_style='bold') == \ r"- \mathbf{A} \mathbf{B} - \mathbf{A} \mathbf{B} \mathbf{C} - \mathbf{B}" A = MatrixSymbol("A_k", 3, 3) assert latex(A, mat_symbol_style='bold') == r"\mathbf{A_{k}}" def test_imaginary_unit(): assert latex(1 + I) == '1 + i' assert latex(1 + I, imaginary_unit='i') == '1 + i' assert latex(1 + I, imaginary_unit='j') == '1 + j' assert latex(1 + I, imaginary_unit='foo') == '1 + foo' assert latex(I, imaginary_unit="ti") == '\\text{i}' assert latex(I, imaginary_unit="tj") == '\\text{j}' def test_text_re_im(): assert latex(im(x), gothic_re_im=True) == r'\Im{\left(x\right)}' assert latex(im(x), gothic_re_im=False) == r'\operatorname{im}{\left(x\right)}' assert latex(re(x), gothic_re_im=True) == r'\Re{\left(x\right)}' assert latex(re(x), gothic_re_im=False) == r'\operatorname{re}{\left(x\right)}' def test_DiffGeomMethods(): from sympy.diffgeom import Manifold, Patch, CoordSystem, BaseScalarField, Differential from sympy.diffgeom.rn import R2 m = Manifold('M', 2) assert latex(m) == r'\text{M}' p = Patch('P', m) assert latex(p) == r'\text{P}_{\text{M}}' rect = CoordSystem('rect', p) assert latex(rect) == r'\text{rect}^{\text{P}}_{\text{M}}' b = BaseScalarField(rect, 0) assert latex(b) == r'\mathbf{rect_{0}}' g = Function('g') s_field = g(R2.x, R2.y) assert latex(Differential(s_field)) == \ r'\operatorname{d}\left(g{\left(\mathbf{x},\mathbf{y} \right)}\right)' def test_unit_ptinting(): assert latex(5*meter) == r'5 \text{m}' assert latex(3*gibibyte) == r'3 \text{gibibyte}' assert latex(4*microgram/second) == r'\frac{4 \mu\text{g}}{\text{s}}'
d196d8ca15adcce6d0346ded79f264bef39d712ff1999fde8683155fe1a56695
from sympy import diff, Integral, Limit, sin, Symbol, Integer, Rational, cos, \ tan, asin, acos, atan, sinh, cosh, tanh, asinh, acosh, atanh, E, I, oo, \ pi, GoldenRatio, EulerGamma, Sum, Eq, Ne, Ge, Lt, Float, Matrix, Basic, \ S, MatrixSymbol, Function, Derivative, log, true, false, Range, Min, Max, \ Lambda, IndexedBase, symbols, zoo, elliptic_f, elliptic_e, elliptic_pi, Ei, \ expint, jacobi, gegenbauer, chebyshevt, chebyshevu, legendre, assoc_legendre, \ laguerre, assoc_laguerre, hermite from sympy import elliptic_k, totient, reduced_totient, primenu, primeomega, \ fresnelc, fresnels, Heaviside from sympy.calculus.util import AccumBounds from sympy.core.containers import Tuple from sympy.functions.combinatorial.factorials import factorial, factorial2, \ binomial from sympy.functions.combinatorial.numbers import bernoulli, bell, lucas, \ fibonacci, tribonacci, catalan from sympy.functions.elementary.complexes import re, im, Abs, conjugate from sympy.functions.elementary.exponential import exp from sympy.functions.elementary.integers import floor, ceiling from sympy.functions.special.gamma_functions import gamma, lowergamma, uppergamma from sympy.functions.special.singularity_functions import SingularityFunction from sympy.functions.special.zeta_functions import polylog, lerchphi, zeta, dirichlet_eta from sympy.logic.boolalg import And, Or, Implies, Equivalent, Xor, Not from sympy.matrices.expressions.determinant import Determinant from sympy.printing.mathml import mathml, MathMLContentPrinter, \ MathMLPresentationPrinter, MathMLPrinter from sympy.sets.sets import FiniteSet, Union, Intersection, Complement, \ SymmetricDifference, Interval, EmptySet from sympy.stats.rv import RandomSymbol from sympy.utilities.pytest import raises from sympy.vector import CoordSys3D, Cross, Curl, Dot, Divergence, Gradient, Laplacian x, y, z, a, b, c, d, e, n = symbols('x:z a:e n') mp = MathMLContentPrinter() mpp = MathMLPresentationPrinter() def test_mathml_printer(): m = MathMLPrinter() assert m.doprint(1+x) == mp.doprint(1+x) def test_content_printmethod(): assert mp.doprint(1 + x) == '<apply><plus/><ci>x</ci><cn>1</cn></apply>' def test_content_mathml_core(): mml_1 = mp._print(1 + x) assert mml_1.nodeName == 'apply' nodes = mml_1.childNodes assert len(nodes) == 3 assert nodes[0].nodeName == 'plus' assert nodes[0].hasChildNodes() is False assert nodes[0].nodeValue is None assert nodes[1].nodeName in ['cn', 'ci'] if nodes[1].nodeName == 'cn': assert nodes[1].childNodes[0].nodeValue == '1' assert nodes[2].childNodes[0].nodeValue == 'x' else: assert nodes[1].childNodes[0].nodeValue == 'x' assert nodes[2].childNodes[0].nodeValue == '1' mml_2 = mp._print(x**2) assert mml_2.nodeName == 'apply' nodes = mml_2.childNodes assert nodes[1].childNodes[0].nodeValue == 'x' assert nodes[2].childNodes[0].nodeValue == '2' mml_3 = mp._print(2*x) assert mml_3.nodeName == 'apply' nodes = mml_3.childNodes assert nodes[0].nodeName == 'times' assert nodes[1].childNodes[0].nodeValue == '2' assert nodes[2].childNodes[0].nodeValue == 'x' mml = mp._print(Float(1.0, 2)*x) assert mml.nodeName == 'apply' nodes = mml.childNodes assert nodes[0].nodeName == 'times' assert nodes[1].childNodes[0].nodeValue == '1.0' assert nodes[2].childNodes[0].nodeValue == 'x' def test_content_mathml_functions(): mml_1 = mp._print(sin(x)) assert mml_1.nodeName == 'apply' assert mml_1.childNodes[0].nodeName == 'sin' assert mml_1.childNodes[1].nodeName == 'ci' mml_2 = mp._print(diff(sin(x), x, evaluate=False)) assert mml_2.nodeName == 'apply' assert mml_2.childNodes[0].nodeName == 'diff' assert mml_2.childNodes[1].nodeName == 'bvar' assert mml_2.childNodes[1].childNodes[ 0].nodeName == 'ci' # below bvar there's <ci>x/ci> mml_3 = mp._print(diff(cos(x*y), x, evaluate=False)) assert mml_3.nodeName == 'apply' assert mml_3.childNodes[0].nodeName == 'partialdiff' assert mml_3.childNodes[1].nodeName == 'bvar' assert mml_3.childNodes[1].childNodes[ 0].nodeName == 'ci' # below bvar there's <ci>x/ci> def test_content_mathml_limits(): # XXX No unevaluated limits lim_fun = sin(x)/x mml_1 = mp._print(Limit(lim_fun, x, 0)) assert mml_1.childNodes[0].nodeName == 'limit' assert mml_1.childNodes[1].nodeName == 'bvar' assert mml_1.childNodes[2].nodeName == 'lowlimit' assert mml_1.childNodes[3].toxml() == mp._print(lim_fun).toxml() def test_content_mathml_integrals(): integrand = x mml_1 = mp._print(Integral(integrand, (x, 0, 1))) assert mml_1.childNodes[0].nodeName == 'int' assert mml_1.childNodes[1].nodeName == 'bvar' assert mml_1.childNodes[2].nodeName == 'lowlimit' assert mml_1.childNodes[3].nodeName == 'uplimit' assert mml_1.childNodes[4].toxml() == mp._print(integrand).toxml() def test_content_mathml_matrices(): A = Matrix([1, 2, 3]) B = Matrix([[0, 5, 4], [2, 3, 1], [9, 7, 9]]) mll_1 = mp._print(A) assert mll_1.childNodes[0].nodeName == 'matrixrow' assert mll_1.childNodes[0].childNodes[0].nodeName == 'cn' assert mll_1.childNodes[0].childNodes[0].childNodes[0].nodeValue == '1' assert mll_1.childNodes[1].nodeName == 'matrixrow' assert mll_1.childNodes[1].childNodes[0].nodeName == 'cn' assert mll_1.childNodes[1].childNodes[0].childNodes[0].nodeValue == '2' assert mll_1.childNodes[2].nodeName == 'matrixrow' assert mll_1.childNodes[2].childNodes[0].nodeName == 'cn' assert mll_1.childNodes[2].childNodes[0].childNodes[0].nodeValue == '3' mll_2 = mp._print(B) assert mll_2.childNodes[0].nodeName == 'matrixrow' assert mll_2.childNodes[0].childNodes[0].nodeName == 'cn' assert mll_2.childNodes[0].childNodes[0].childNodes[0].nodeValue == '0' assert mll_2.childNodes[0].childNodes[1].nodeName == 'cn' assert mll_2.childNodes[0].childNodes[1].childNodes[0].nodeValue == '5' assert mll_2.childNodes[0].childNodes[2].nodeName == 'cn' assert mll_2.childNodes[0].childNodes[2].childNodes[0].nodeValue == '4' assert mll_2.childNodes[1].nodeName == 'matrixrow' assert mll_2.childNodes[1].childNodes[0].nodeName == 'cn' assert mll_2.childNodes[1].childNodes[0].childNodes[0].nodeValue == '2' assert mll_2.childNodes[1].childNodes[1].nodeName == 'cn' assert mll_2.childNodes[1].childNodes[1].childNodes[0].nodeValue == '3' assert mll_2.childNodes[1].childNodes[2].nodeName == 'cn' assert mll_2.childNodes[1].childNodes[2].childNodes[0].nodeValue == '1' assert mll_2.childNodes[2].nodeName == 'matrixrow' assert mll_2.childNodes[2].childNodes[0].nodeName == 'cn' assert mll_2.childNodes[2].childNodes[0].childNodes[0].nodeValue == '9' assert mll_2.childNodes[2].childNodes[1].nodeName == 'cn' assert mll_2.childNodes[2].childNodes[1].childNodes[0].nodeValue == '7' assert mll_2.childNodes[2].childNodes[2].nodeName == 'cn' assert mll_2.childNodes[2].childNodes[2].childNodes[0].nodeValue == '9' def test_content_mathml_sums(): summand = x mml_1 = mp._print(Sum(summand, (x, 1, 10))) assert mml_1.childNodes[0].nodeName == 'sum' assert mml_1.childNodes[1].nodeName == 'bvar' assert mml_1.childNodes[2].nodeName == 'lowlimit' assert mml_1.childNodes[3].nodeName == 'uplimit' assert mml_1.childNodes[4].toxml() == mp._print(summand).toxml() def test_content_mathml_tuples(): mml_1 = mp._print([2]) assert mml_1.nodeName == 'list' assert mml_1.childNodes[0].nodeName == 'cn' assert len(mml_1.childNodes) == 1 mml_2 = mp._print([2, Integer(1)]) assert mml_2.nodeName == 'list' assert mml_2.childNodes[0].nodeName == 'cn' assert mml_2.childNodes[1].nodeName == 'cn' assert len(mml_2.childNodes) == 2 def test_content_mathml_add(): mml = mp._print(x**5 - x**4 + x) assert mml.childNodes[0].nodeName == 'plus' assert mml.childNodes[1].childNodes[0].nodeName == 'minus' assert mml.childNodes[1].childNodes[1].nodeName == 'apply' def test_content_mathml_Rational(): mml_1 = mp._print(Rational(1, 1)) """should just return a number""" assert mml_1.nodeName == 'cn' mml_2 = mp._print(Rational(2, 5)) assert mml_2.childNodes[0].nodeName == 'divide' def test_content_mathml_constants(): mml = mp._print(I) assert mml.nodeName == 'imaginaryi' mml = mp._print(E) assert mml.nodeName == 'exponentiale' mml = mp._print(oo) assert mml.nodeName == 'infinity' mml = mp._print(pi) assert mml.nodeName == 'pi' assert mathml(GoldenRatio) == '<cn>&#966;</cn>' mml = mathml(EulerGamma) assert mml == '<eulergamma/>' def test_content_mathml_trig(): mml = mp._print(sin(x)) assert mml.childNodes[0].nodeName == 'sin' mml = mp._print(cos(x)) assert mml.childNodes[0].nodeName == 'cos' mml = mp._print(tan(x)) assert mml.childNodes[0].nodeName == 'tan' mml = mp._print(asin(x)) assert mml.childNodes[0].nodeName == 'arcsin' mml = mp._print(acos(x)) assert mml.childNodes[0].nodeName == 'arccos' mml = mp._print(atan(x)) assert mml.childNodes[0].nodeName == 'arctan' mml = mp._print(sinh(x)) assert mml.childNodes[0].nodeName == 'sinh' mml = mp._print(cosh(x)) assert mml.childNodes[0].nodeName == 'cosh' mml = mp._print(tanh(x)) assert mml.childNodes[0].nodeName == 'tanh' mml = mp._print(asinh(x)) assert mml.childNodes[0].nodeName == 'arcsinh' mml = mp._print(atanh(x)) assert mml.childNodes[0].nodeName == 'arctanh' mml = mp._print(acosh(x)) assert mml.childNodes[0].nodeName == 'arccosh' def test_content_mathml_relational(): mml_1 = mp._print(Eq(x, 1)) assert mml_1.nodeName == 'apply' assert mml_1.childNodes[0].nodeName == 'eq' assert mml_1.childNodes[1].nodeName == 'ci' assert mml_1.childNodes[1].childNodes[0].nodeValue == 'x' assert mml_1.childNodes[2].nodeName == 'cn' assert mml_1.childNodes[2].childNodes[0].nodeValue == '1' mml_2 = mp._print(Ne(1, x)) assert mml_2.nodeName == 'apply' assert mml_2.childNodes[0].nodeName == 'neq' assert mml_2.childNodes[1].nodeName == 'cn' assert mml_2.childNodes[1].childNodes[0].nodeValue == '1' assert mml_2.childNodes[2].nodeName == 'ci' assert mml_2.childNodes[2].childNodes[0].nodeValue == 'x' mml_3 = mp._print(Ge(1, x)) assert mml_3.nodeName == 'apply' assert mml_3.childNodes[0].nodeName == 'geq' assert mml_3.childNodes[1].nodeName == 'cn' assert mml_3.childNodes[1].childNodes[0].nodeValue == '1' assert mml_3.childNodes[2].nodeName == 'ci' assert mml_3.childNodes[2].childNodes[0].nodeValue == 'x' mml_4 = mp._print(Lt(1, x)) assert mml_4.nodeName == 'apply' assert mml_4.childNodes[0].nodeName == 'lt' assert mml_4.childNodes[1].nodeName == 'cn' assert mml_4.childNodes[1].childNodes[0].nodeValue == '1' assert mml_4.childNodes[2].nodeName == 'ci' assert mml_4.childNodes[2].childNodes[0].nodeValue == 'x' def test_content_symbol(): mml = mp._print(x) assert mml.nodeName == 'ci' assert mml.childNodes[0].nodeValue == 'x' del mml mml = mp._print(Symbol("x^2")) assert mml.nodeName == 'ci' assert mml.childNodes[0].nodeName == 'mml:msup' assert mml.childNodes[0].childNodes[0].nodeName == 'mml:mi' assert mml.childNodes[0].childNodes[0].childNodes[0].nodeValue == 'x' assert mml.childNodes[0].childNodes[1].nodeName == 'mml:mi' assert mml.childNodes[0].childNodes[1].childNodes[0].nodeValue == '2' del mml mml = mp._print(Symbol("x__2")) assert mml.nodeName == 'ci' assert mml.childNodes[0].nodeName == 'mml:msup' assert mml.childNodes[0].childNodes[0].nodeName == 'mml:mi' assert mml.childNodes[0].childNodes[0].childNodes[0].nodeValue == 'x' assert mml.childNodes[0].childNodes[1].nodeName == 'mml:mi' assert mml.childNodes[0].childNodes[1].childNodes[0].nodeValue == '2' del mml mml = mp._print(Symbol("x_2")) assert mml.nodeName == 'ci' assert mml.childNodes[0].nodeName == 'mml:msub' assert mml.childNodes[0].childNodes[0].nodeName == 'mml:mi' assert mml.childNodes[0].childNodes[0].childNodes[0].nodeValue == 'x' assert mml.childNodes[0].childNodes[1].nodeName == 'mml:mi' assert mml.childNodes[0].childNodes[1].childNodes[0].nodeValue == '2' del mml mml = mp._print(Symbol("x^3_2")) assert mml.nodeName == 'ci' assert mml.childNodes[0].nodeName == 'mml:msubsup' assert mml.childNodes[0].childNodes[0].nodeName == 'mml:mi' assert mml.childNodes[0].childNodes[0].childNodes[0].nodeValue == 'x' assert mml.childNodes[0].childNodes[1].nodeName == 'mml:mi' assert mml.childNodes[0].childNodes[1].childNodes[0].nodeValue == '2' assert mml.childNodes[0].childNodes[2].nodeName == 'mml:mi' assert mml.childNodes[0].childNodes[2].childNodes[0].nodeValue == '3' del mml mml = mp._print(Symbol("x__3_2")) assert mml.nodeName == 'ci' assert mml.childNodes[0].nodeName == 'mml:msubsup' assert mml.childNodes[0].childNodes[0].nodeName == 'mml:mi' assert mml.childNodes[0].childNodes[0].childNodes[0].nodeValue == 'x' assert mml.childNodes[0].childNodes[1].nodeName == 'mml:mi' assert mml.childNodes[0].childNodes[1].childNodes[0].nodeValue == '2' assert mml.childNodes[0].childNodes[2].nodeName == 'mml:mi' assert mml.childNodes[0].childNodes[2].childNodes[0].nodeValue == '3' del mml mml = mp._print(Symbol("x_2_a")) assert mml.nodeName == 'ci' assert mml.childNodes[0].nodeName == 'mml:msub' assert mml.childNodes[0].childNodes[0].nodeName == 'mml:mi' assert mml.childNodes[0].childNodes[0].childNodes[0].nodeValue == 'x' assert mml.childNodes[0].childNodes[1].nodeName == 'mml:mrow' assert mml.childNodes[0].childNodes[1].childNodes[0].nodeName == 'mml:mi' assert mml.childNodes[0].childNodes[1].childNodes[0].childNodes[ 0].nodeValue == '2' assert mml.childNodes[0].childNodes[1].childNodes[1].nodeName == 'mml:mo' assert mml.childNodes[0].childNodes[1].childNodes[1].childNodes[ 0].nodeValue == ' ' assert mml.childNodes[0].childNodes[1].childNodes[2].nodeName == 'mml:mi' assert mml.childNodes[0].childNodes[1].childNodes[2].childNodes[ 0].nodeValue == 'a' del mml mml = mp._print(Symbol("x^2^a")) assert mml.nodeName == 'ci' assert mml.childNodes[0].nodeName == 'mml:msup' assert mml.childNodes[0].childNodes[0].nodeName == 'mml:mi' assert mml.childNodes[0].childNodes[0].childNodes[0].nodeValue == 'x' assert mml.childNodes[0].childNodes[1].nodeName == 'mml:mrow' assert mml.childNodes[0].childNodes[1].childNodes[0].nodeName == 'mml:mi' assert mml.childNodes[0].childNodes[1].childNodes[0].childNodes[ 0].nodeValue == '2' assert mml.childNodes[0].childNodes[1].childNodes[1].nodeName == 'mml:mo' assert mml.childNodes[0].childNodes[1].childNodes[1].childNodes[ 0].nodeValue == ' ' assert mml.childNodes[0].childNodes[1].childNodes[2].nodeName == 'mml:mi' assert mml.childNodes[0].childNodes[1].childNodes[2].childNodes[ 0].nodeValue == 'a' del mml mml = mp._print(Symbol("x__2__a")) assert mml.nodeName == 'ci' assert mml.childNodes[0].nodeName == 'mml:msup' assert mml.childNodes[0].childNodes[0].nodeName == 'mml:mi' assert mml.childNodes[0].childNodes[0].childNodes[0].nodeValue == 'x' assert mml.childNodes[0].childNodes[1].nodeName == 'mml:mrow' assert mml.childNodes[0].childNodes[1].childNodes[0].nodeName == 'mml:mi' assert mml.childNodes[0].childNodes[1].childNodes[0].childNodes[ 0].nodeValue == '2' assert mml.childNodes[0].childNodes[1].childNodes[1].nodeName == 'mml:mo' assert mml.childNodes[0].childNodes[1].childNodes[1].childNodes[ 0].nodeValue == ' ' assert mml.childNodes[0].childNodes[1].childNodes[2].nodeName == 'mml:mi' assert mml.childNodes[0].childNodes[1].childNodes[2].childNodes[ 0].nodeValue == 'a' del mml def test_content_mathml_greek(): mml = mp._print(Symbol('alpha')) assert mml.nodeName == 'ci' assert mml.childNodes[0].nodeValue == u'\N{GREEK SMALL LETTER ALPHA}' assert mp.doprint(Symbol('alpha')) == '<ci>&#945;</ci>' assert mp.doprint(Symbol('beta')) == '<ci>&#946;</ci>' assert mp.doprint(Symbol('gamma')) == '<ci>&#947;</ci>' assert mp.doprint(Symbol('delta')) == '<ci>&#948;</ci>' assert mp.doprint(Symbol('epsilon')) == '<ci>&#949;</ci>' assert mp.doprint(Symbol('zeta')) == '<ci>&#950;</ci>' assert mp.doprint(Symbol('eta')) == '<ci>&#951;</ci>' assert mp.doprint(Symbol('theta')) == '<ci>&#952;</ci>' assert mp.doprint(Symbol('iota')) == '<ci>&#953;</ci>' assert mp.doprint(Symbol('kappa')) == '<ci>&#954;</ci>' assert mp.doprint(Symbol('lambda')) == '<ci>&#955;</ci>' assert mp.doprint(Symbol('mu')) == '<ci>&#956;</ci>' assert mp.doprint(Symbol('nu')) == '<ci>&#957;</ci>' assert mp.doprint(Symbol('xi')) == '<ci>&#958;</ci>' assert mp.doprint(Symbol('omicron')) == '<ci>&#959;</ci>' assert mp.doprint(Symbol('pi')) == '<ci>&#960;</ci>' assert mp.doprint(Symbol('rho')) == '<ci>&#961;</ci>' assert mp.doprint(Symbol('varsigma')) == '<ci>&#962;</ci>' assert mp.doprint(Symbol('sigma')) == '<ci>&#963;</ci>' assert mp.doprint(Symbol('tau')) == '<ci>&#964;</ci>' assert mp.doprint(Symbol('upsilon')) == '<ci>&#965;</ci>' assert mp.doprint(Symbol('phi')) == '<ci>&#966;</ci>' assert mp.doprint(Symbol('chi')) == '<ci>&#967;</ci>' assert mp.doprint(Symbol('psi')) == '<ci>&#968;</ci>' assert mp.doprint(Symbol('omega')) == '<ci>&#969;</ci>' assert mp.doprint(Symbol('Alpha')) == '<ci>&#913;</ci>' assert mp.doprint(Symbol('Beta')) == '<ci>&#914;</ci>' assert mp.doprint(Symbol('Gamma')) == '<ci>&#915;</ci>' assert mp.doprint(Symbol('Delta')) == '<ci>&#916;</ci>' assert mp.doprint(Symbol('Epsilon')) == '<ci>&#917;</ci>' assert mp.doprint(Symbol('Zeta')) == '<ci>&#918;</ci>' assert mp.doprint(Symbol('Eta')) == '<ci>&#919;</ci>' assert mp.doprint(Symbol('Theta')) == '<ci>&#920;</ci>' assert mp.doprint(Symbol('Iota')) == '<ci>&#921;</ci>' assert mp.doprint(Symbol('Kappa')) == '<ci>&#922;</ci>' assert mp.doprint(Symbol('Lambda')) == '<ci>&#923;</ci>' assert mp.doprint(Symbol('Mu')) == '<ci>&#924;</ci>' assert mp.doprint(Symbol('Nu')) == '<ci>&#925;</ci>' assert mp.doprint(Symbol('Xi')) == '<ci>&#926;</ci>' assert mp.doprint(Symbol('Omicron')) == '<ci>&#927;</ci>' assert mp.doprint(Symbol('Pi')) == '<ci>&#928;</ci>' assert mp.doprint(Symbol('Rho')) == '<ci>&#929;</ci>' assert mp.doprint(Symbol('Sigma')) == '<ci>&#931;</ci>' assert mp.doprint(Symbol('Tau')) == '<ci>&#932;</ci>' assert mp.doprint(Symbol('Upsilon')) == '<ci>&#933;</ci>' assert mp.doprint(Symbol('Phi')) == '<ci>&#934;</ci>' assert mp.doprint(Symbol('Chi')) == '<ci>&#935;</ci>' assert mp.doprint(Symbol('Psi')) == '<ci>&#936;</ci>' assert mp.doprint(Symbol('Omega')) == '<ci>&#937;</ci>' def test_content_mathml_order(): expr = x**3 + x**2*y + 3*x*y**3 + y**4 mp = MathMLContentPrinter({'order': 'lex'}) mml = mp._print(expr) assert mml.childNodes[1].childNodes[0].nodeName == 'power' assert mml.childNodes[1].childNodes[1].childNodes[0].data == 'x' assert mml.childNodes[1].childNodes[2].childNodes[0].data == '3' assert mml.childNodes[4].childNodes[0].nodeName == 'power' assert mml.childNodes[4].childNodes[1].childNodes[0].data == 'y' assert mml.childNodes[4].childNodes[2].childNodes[0].data == '4' mp = MathMLContentPrinter({'order': 'rev-lex'}) mml = mp._print(expr) assert mml.childNodes[1].childNodes[0].nodeName == 'power' assert mml.childNodes[1].childNodes[1].childNodes[0].data == 'y' assert mml.childNodes[1].childNodes[2].childNodes[0].data == '4' assert mml.childNodes[4].childNodes[0].nodeName == 'power' assert mml.childNodes[4].childNodes[1].childNodes[0].data == 'x' assert mml.childNodes[4].childNodes[2].childNodes[0].data == '3' def test_content_settings(): raises(TypeError, lambda: mathml(x, method="garbage")) def test_presentation_printmethod(): assert mpp.doprint(1 + x) == '<mrow><mi>x</mi><mo>+</mo><mn>1</mn></mrow>' assert mpp.doprint(x**2) == '<msup><mi>x</mi><mn>2</mn></msup>' assert mpp.doprint(x**-1) == '<mfrac><mn>1</mn><mi>x</mi></mfrac>' assert mpp.doprint(x**-2) == \ '<mfrac><mn>1</mn><msup><mi>x</mi><mn>2</mn></msup></mfrac>' assert mpp.doprint(2*x) == \ '<mrow><mn>2</mn><mo>&InvisibleTimes;</mo><mi>x</mi></mrow>' def test_presentation_mathml_core(): mml_1 = mpp._print(1 + x) assert mml_1.nodeName == 'mrow' nodes = mml_1.childNodes assert len(nodes) == 3 assert nodes[0].nodeName in ['mi', 'mn'] assert nodes[1].nodeName == 'mo' if nodes[0].nodeName == 'mn': assert nodes[0].childNodes[0].nodeValue == '1' assert nodes[2].childNodes[0].nodeValue == 'x' else: assert nodes[0].childNodes[0].nodeValue == 'x' assert nodes[2].childNodes[0].nodeValue == '1' mml_2 = mpp._print(x**2) assert mml_2.nodeName == 'msup' nodes = mml_2.childNodes assert nodes[0].childNodes[0].nodeValue == 'x' assert nodes[1].childNodes[0].nodeValue == '2' mml_3 = mpp._print(2*x) assert mml_3.nodeName == 'mrow' nodes = mml_3.childNodes assert nodes[0].childNodes[0].nodeValue == '2' assert nodes[1].childNodes[0].nodeValue == '&InvisibleTimes;' assert nodes[2].childNodes[0].nodeValue == 'x' mml = mpp._print(Float(1.0, 2)*x) assert mml.nodeName == 'mrow' nodes = mml.childNodes assert nodes[0].childNodes[0].nodeValue == '1.0' assert nodes[1].childNodes[0].nodeValue == '&InvisibleTimes;' assert nodes[2].childNodes[0].nodeValue == 'x' def test_presentation_mathml_functions(): mml_1 = mpp._print(sin(x)) assert mml_1.childNodes[0].childNodes[0 ].nodeValue == 'sin' assert mml_1.childNodes[1].childNodes[0 ].childNodes[0].nodeValue == 'x' mml_2 = mpp._print(diff(sin(x), x, evaluate=False)) assert mml_2.nodeName == 'mrow' assert mml_2.childNodes[0].childNodes[0 ].childNodes[0].childNodes[0].nodeValue == '&dd;' assert mml_2.childNodes[1].childNodes[1 ].nodeName == 'mfenced' assert mml_2.childNodes[0].childNodes[1 ].childNodes[0].childNodes[0].nodeValue == '&dd;' mml_3 = mpp._print(diff(cos(x*y), x, evaluate=False)) assert mml_3.childNodes[0].nodeName == 'mfrac' assert mml_3.childNodes[0].childNodes[0 ].childNodes[0].childNodes[0].nodeValue == '&#x2202;' assert mml_3.childNodes[1].childNodes[0 ].childNodes[0].nodeValue == 'cos' def test_print_derivative(): f = Function('f') d = Derivative(f(x, y, z), x, z, x, z, z, y) assert mathml(d) == \ '<apply><partialdiff/><bvar><ci>y</ci><ci>z</ci><degree><cn>2</cn></degree><ci>x</ci><ci>z</ci><ci>x</ci></bvar><apply><f/><ci>x</ci><ci>y</ci><ci>z</ci></apply></apply>' assert mathml(d, printer='presentation') == \ '<mrow><mfrac><mrow><msup><mo>&#x2202;</mo><mn>6</mn></msup></mrow><mrow><mo>&#x2202;</mo><mi>y</mi><msup><mo>&#x2202;</mo><mn>2</mn></msup><mi>z</mi><mo>&#x2202;</mo><mi>x</mi><mo>&#x2202;</mo><mi>z</mi><mo>&#x2202;</mo><mi>x</mi></mrow></mfrac><mrow><mi>f</mi><mfenced><mi>x</mi><mi>y</mi><mi>z</mi></mfenced></mrow></mrow>' def test_presentation_mathml_limits(): lim_fun = sin(x)/x mml_1 = mpp._print(Limit(lim_fun, x, 0)) assert mml_1.childNodes[0].nodeName == 'munder' assert mml_1.childNodes[0].childNodes[0 ].childNodes[0].nodeValue == 'lim' assert mml_1.childNodes[0].childNodes[1 ].childNodes[0].childNodes[0 ].nodeValue == 'x' assert mml_1.childNodes[0].childNodes[1 ].childNodes[1].childNodes[0 ].nodeValue == '&#x2192;' assert mml_1.childNodes[0].childNodes[1 ].childNodes[2].childNodes[0 ].nodeValue == '0' def test_presentation_mathml_integrals(): assert mpp.doprint(Integral(x, (x, 0, 1))) == \ '<mrow><msubsup><mo>&#x222B;</mo><mn>0</mn><mn>1</mn></msubsup>'\ '<mi>x</mi><mo>&dd;</mo><mi>x</mi></mrow>' assert mpp.doprint(Integral(log(x), x)) == \ '<mrow><mo>&#x222B;</mo><mrow><mi>log</mi><mfenced><mi>x</mi>'\ '</mfenced></mrow><mo>&dd;</mo><mi>x</mi></mrow>' assert mpp.doprint(Integral(x*y, x, y)) == \ '<mrow><mo>&#x222C;</mo><mrow><mi>x</mi><mo>&InvisibleTimes;</mo>'\ '<mi>y</mi></mrow><mo>&dd;</mo><mi>y</mi><mo>&dd;</mo><mi>x</mi></mrow>' z, w = symbols('z w') assert mpp.doprint(Integral(x*y*z, x, y, z)) == \ '<mrow><mo>&#x222D;</mo><mrow><mi>x</mi><mo>&InvisibleTimes;</mo>'\ '<mi>y</mi><mo>&InvisibleTimes;</mo><mi>z</mi></mrow><mo>&dd;</mo>'\ '<mi>z</mi><mo>&dd;</mo><mi>y</mi><mo>&dd;</mo><mi>x</mi></mrow>' assert mpp.doprint(Integral(x*y*z*w, x, y, z, w)) == \ '<mrow><mo>&#x222B;</mo><mo>&#x222B;</mo><mo>&#x222B;</mo>'\ '<mo>&#x222B;</mo><mrow><mi>w</mi><mo>&InvisibleTimes;</mo>'\ '<mi>x</mi><mo>&InvisibleTimes;</mo><mi>y</mi>'\ '<mo>&InvisibleTimes;</mo><mi>z</mi></mrow><mo>&dd;</mo><mi>w</mi>'\ '<mo>&dd;</mo><mi>z</mi><mo>&dd;</mo><mi>y</mi><mo>&dd;</mo><mi>x</mi></mrow>' assert mpp.doprint(Integral(x, x, y, (z, 0, 1))) == \ '<mrow><msubsup><mo>&#x222B;</mo><mn>0</mn><mn>1</mn></msubsup>'\ '<mo>&#x222B;</mo><mo>&#x222B;</mo><mi>x</mi><mo>&dd;</mo><mi>z</mi>'\ '<mo>&dd;</mo><mi>y</mi><mo>&dd;</mo><mi>x</mi></mrow>' assert mpp.doprint(Integral(x, (x, 0))) == \ '<mrow><msup><mo>&#x222B;</mo><mn>0</mn></msup><mi>x</mi><mo>&dd;</mo>'\ '<mi>x</mi></mrow>' def test_presentation_mathml_matrices(): A = Matrix([1, 2, 3]) B = Matrix([[0, 5, 4], [2, 3, 1], [9, 7, 9]]) mll_1 = mpp._print(A) assert mll_1.childNodes[0].nodeName == 'mtable' assert mll_1.childNodes[0].childNodes[0].nodeName == 'mtr' assert len(mll_1.childNodes[0].childNodes) == 3 assert mll_1.childNodes[0].childNodes[0].childNodes[0].nodeName == 'mtd' assert len(mll_1.childNodes[0].childNodes[0].childNodes) == 1 assert mll_1.childNodes[0].childNodes[0].childNodes[0 ].childNodes[0].childNodes[0].nodeValue == '1' assert mll_1.childNodes[0].childNodes[1].childNodes[0 ].childNodes[0].childNodes[0].nodeValue == '2' assert mll_1.childNodes[0].childNodes[2].childNodes[0 ].childNodes[0].childNodes[0].nodeValue == '3' mll_2 = mpp._print(B) assert mll_2.childNodes[0].nodeName == 'mtable' assert mll_2.childNodes[0].childNodes[0].nodeName == 'mtr' assert len(mll_2.childNodes[0].childNodes) == 3 assert mll_2.childNodes[0].childNodes[0].childNodes[0].nodeName == 'mtd' assert len(mll_2.childNodes[0].childNodes[0].childNodes) == 3 assert mll_2.childNodes[0].childNodes[0].childNodes[0 ].childNodes[0].childNodes[0].nodeValue == '0' assert mll_2.childNodes[0].childNodes[0].childNodes[1 ].childNodes[0].childNodes[0].nodeValue == '5' assert mll_2.childNodes[0].childNodes[0].childNodes[2 ].childNodes[0].childNodes[0].nodeValue == '4' assert mll_2.childNodes[0].childNodes[1].childNodes[0 ].childNodes[0].childNodes[0].nodeValue == '2' assert mll_2.childNodes[0].childNodes[1].childNodes[1 ].childNodes[0].childNodes[0].nodeValue == '3' assert mll_2.childNodes[0].childNodes[1].childNodes[2 ].childNodes[0].childNodes[0].nodeValue == '1' assert mll_2.childNodes[0].childNodes[2].childNodes[0 ].childNodes[0].childNodes[0].nodeValue == '9' assert mll_2.childNodes[0].childNodes[2].childNodes[1 ].childNodes[0].childNodes[0].nodeValue == '7' assert mll_2.childNodes[0].childNodes[2].childNodes[2 ].childNodes[0].childNodes[0].nodeValue == '9' def test_presentation_mathml_sums(): summand = x mml_1 = mpp._print(Sum(summand, (x, 1, 10))) assert mml_1.childNodes[0].nodeName == 'munderover' assert len(mml_1.childNodes[0].childNodes) == 3 assert mml_1.childNodes[0].childNodes[0].childNodes[0 ].nodeValue == '&#x2211;' assert len(mml_1.childNodes[0].childNodes[1].childNodes) == 3 assert mml_1.childNodes[0].childNodes[2].childNodes[0 ].nodeValue == '10' assert mml_1.childNodes[1].childNodes[0].nodeValue == 'x' def test_presentation_mathml_add(): mml = mpp._print(x**5 - x**4 + x) assert len(mml.childNodes) == 5 assert mml.childNodes[0].childNodes[0].childNodes[0 ].nodeValue == 'x' assert mml.childNodes[0].childNodes[1].childNodes[0 ].nodeValue == '5' assert mml.childNodes[1].childNodes[0].nodeValue == '-' assert mml.childNodes[2].childNodes[0].childNodes[0 ].nodeValue == 'x' assert mml.childNodes[2].childNodes[1].childNodes[0 ].nodeValue == '4' assert mml.childNodes[3].childNodes[0].nodeValue == '+' assert mml.childNodes[4].childNodes[0].nodeValue == 'x' def test_presentation_mathml_Rational(): mml_1 = mpp._print(Rational(1, 1)) assert mml_1.nodeName == 'mn' mml_2 = mpp._print(Rational(2, 5)) assert mml_2.nodeName == 'mfrac' assert mml_2.childNodes[0].childNodes[0].nodeValue == '2' assert mml_2.childNodes[1].childNodes[0].nodeValue == '5' def test_presentation_mathml_constants(): mml = mpp._print(I) assert mml.childNodes[0].nodeValue == '&ImaginaryI;' mml = mpp._print(E) assert mml.childNodes[0].nodeValue == '&ExponentialE;' mml = mpp._print(oo) assert mml.childNodes[0].nodeValue == '&#x221E;' mml = mpp._print(pi) assert mml.childNodes[0].nodeValue == '&pi;' assert mathml(GoldenRatio, printer='presentation') == '<mi>&#x3A6;</mi>' assert mathml(zoo, printer='presentation') == \ '<mover><mo>&#x221E;</mo><mo>~</mo></mover>' assert mathml(S.NaN, printer='presentation') == '<mi>NaN</mi>' def test_presentation_mathml_trig(): mml = mpp._print(sin(x)) assert mml.childNodes[0].childNodes[0].nodeValue == 'sin' mml = mpp._print(cos(x)) assert mml.childNodes[0].childNodes[0].nodeValue == 'cos' mml = mpp._print(tan(x)) assert mml.childNodes[0].childNodes[0].nodeValue == 'tan' mml = mpp._print(asin(x)) assert mml.childNodes[0].childNodes[0].nodeValue == 'arcsin' mml = mpp._print(acos(x)) assert mml.childNodes[0].childNodes[0].nodeValue == 'arccos' mml = mpp._print(atan(x)) assert mml.childNodes[0].childNodes[0].nodeValue == 'arctan' mml = mpp._print(sinh(x)) assert mml.childNodes[0].childNodes[0].nodeValue == 'sinh' mml = mpp._print(cosh(x)) assert mml.childNodes[0].childNodes[0].nodeValue == 'cosh' mml = mpp._print(tanh(x)) assert mml.childNodes[0].childNodes[0].nodeValue == 'tanh' mml = mpp._print(asinh(x)) assert mml.childNodes[0].childNodes[0].nodeValue == 'arcsinh' mml = mpp._print(atanh(x)) assert mml.childNodes[0].childNodes[0].nodeValue == 'arctanh' mml = mpp._print(acosh(x)) assert mml.childNodes[0].childNodes[0].nodeValue == 'arccosh' def test_presentation_mathml_relational(): mml_1 = mpp._print(Eq(x, 1)) assert len(mml_1.childNodes) == 3 assert mml_1.childNodes[0].nodeName == 'mi' assert mml_1.childNodes[0].childNodes[0].nodeValue == 'x' assert mml_1.childNodes[1].nodeName == 'mo' assert mml_1.childNodes[1].childNodes[0].nodeValue == '=' assert mml_1.childNodes[2].nodeName == 'mn' assert mml_1.childNodes[2].childNodes[0].nodeValue == '1' mml_2 = mpp._print(Ne(1, x)) assert len(mml_2.childNodes) == 3 assert mml_2.childNodes[0].nodeName == 'mn' assert mml_2.childNodes[0].childNodes[0].nodeValue == '1' assert mml_2.childNodes[1].nodeName == 'mo' assert mml_2.childNodes[1].childNodes[0].nodeValue == '&#x2260;' assert mml_2.childNodes[2].nodeName == 'mi' assert mml_2.childNodes[2].childNodes[0].nodeValue == 'x' mml_3 = mpp._print(Ge(1, x)) assert len(mml_3.childNodes) == 3 assert mml_3.childNodes[0].nodeName == 'mn' assert mml_3.childNodes[0].childNodes[0].nodeValue == '1' assert mml_3.childNodes[1].nodeName == 'mo' assert mml_3.childNodes[1].childNodes[0].nodeValue == '&#x2265;' assert mml_3.childNodes[2].nodeName == 'mi' assert mml_3.childNodes[2].childNodes[0].nodeValue == 'x' mml_4 = mpp._print(Lt(1, x)) assert len(mml_4.childNodes) == 3 assert mml_4.childNodes[0].nodeName == 'mn' assert mml_4.childNodes[0].childNodes[0].nodeValue == '1' assert mml_4.childNodes[1].nodeName == 'mo' assert mml_4.childNodes[1].childNodes[0].nodeValue == '<' assert mml_4.childNodes[2].nodeName == 'mi' assert mml_4.childNodes[2].childNodes[0].nodeValue == 'x' def test_presentation_symbol(): mml = mpp._print(x) assert mml.nodeName == 'mi' assert mml.childNodes[0].nodeValue == 'x' del mml mml = mpp._print(Symbol("x^2")) assert mml.nodeName == 'msup' assert mml.childNodes[0].nodeName == 'mi' assert mml.childNodes[0].childNodes[0].nodeValue == 'x' assert mml.childNodes[1].nodeName == 'mi' assert mml.childNodes[1].childNodes[0].nodeValue == '2' del mml mml = mpp._print(Symbol("x__2")) assert mml.nodeName == 'msup' assert mml.childNodes[0].nodeName == 'mi' assert mml.childNodes[0].childNodes[0].nodeValue == 'x' assert mml.childNodes[1].nodeName == 'mi' assert mml.childNodes[1].childNodes[0].nodeValue == '2' del mml mml = mpp._print(Symbol("x_2")) assert mml.nodeName == 'msub' assert mml.childNodes[0].nodeName == 'mi' assert mml.childNodes[0].childNodes[0].nodeValue == 'x' assert mml.childNodes[1].nodeName == 'mi' assert mml.childNodes[1].childNodes[0].nodeValue == '2' del mml mml = mpp._print(Symbol("x^3_2")) assert mml.nodeName == 'msubsup' assert mml.childNodes[0].nodeName == 'mi' assert mml.childNodes[0].childNodes[0].nodeValue == 'x' assert mml.childNodes[1].nodeName == 'mi' assert mml.childNodes[1].childNodes[0].nodeValue == '2' assert mml.childNodes[2].nodeName == 'mi' assert mml.childNodes[2].childNodes[0].nodeValue == '3' del mml mml = mpp._print(Symbol("x__3_2")) assert mml.nodeName == 'msubsup' assert mml.childNodes[0].nodeName == 'mi' assert mml.childNodes[0].childNodes[0].nodeValue == 'x' assert mml.childNodes[1].nodeName == 'mi' assert mml.childNodes[1].childNodes[0].nodeValue == '2' assert mml.childNodes[2].nodeName == 'mi' assert mml.childNodes[2].childNodes[0].nodeValue == '3' del mml mml = mpp._print(Symbol("x_2_a")) assert mml.nodeName == 'msub' assert mml.childNodes[0].nodeName == 'mi' assert mml.childNodes[0].childNodes[0].nodeValue == 'x' assert mml.childNodes[1].nodeName == 'mrow' assert mml.childNodes[1].childNodes[0].nodeName == 'mi' assert mml.childNodes[1].childNodes[0].childNodes[0].nodeValue == '2' assert mml.childNodes[1].childNodes[1].nodeName == 'mo' assert mml.childNodes[1].childNodes[1].childNodes[0].nodeValue == ' ' assert mml.childNodes[1].childNodes[2].nodeName == 'mi' assert mml.childNodes[1].childNodes[2].childNodes[0].nodeValue == 'a' del mml mml = mpp._print(Symbol("x^2^a")) assert mml.nodeName == 'msup' assert mml.childNodes[0].nodeName == 'mi' assert mml.childNodes[0].childNodes[0].nodeValue == 'x' assert mml.childNodes[1].nodeName == 'mrow' assert mml.childNodes[1].childNodes[0].nodeName == 'mi' assert mml.childNodes[1].childNodes[0].childNodes[0].nodeValue == '2' assert mml.childNodes[1].childNodes[1].nodeName == 'mo' assert mml.childNodes[1].childNodes[1].childNodes[0].nodeValue == ' ' assert mml.childNodes[1].childNodes[2].nodeName == 'mi' assert mml.childNodes[1].childNodes[2].childNodes[0].nodeValue == 'a' del mml mml = mpp._print(Symbol("x__2__a")) assert mml.nodeName == 'msup' assert mml.childNodes[0].nodeName == 'mi' assert mml.childNodes[0].childNodes[0].nodeValue == 'x' assert mml.childNodes[1].nodeName == 'mrow' assert mml.childNodes[1].childNodes[0].nodeName == 'mi' assert mml.childNodes[1].childNodes[0].childNodes[0].nodeValue == '2' assert mml.childNodes[1].childNodes[1].nodeName == 'mo' assert mml.childNodes[1].childNodes[1].childNodes[0].nodeValue == ' ' assert mml.childNodes[1].childNodes[2].nodeName == 'mi' assert mml.childNodes[1].childNodes[2].childNodes[0].nodeValue == 'a' del mml def test_presentation_mathml_greek(): mml = mpp._print(Symbol('alpha')) assert mml.nodeName == 'mi' assert mml.childNodes[0].nodeValue == u'\N{GREEK SMALL LETTER ALPHA}' assert mpp.doprint(Symbol('alpha')) == '<mi>&#945;</mi>' assert mpp.doprint(Symbol('beta')) == '<mi>&#946;</mi>' assert mpp.doprint(Symbol('gamma')) == '<mi>&#947;</mi>' assert mpp.doprint(Symbol('delta')) == '<mi>&#948;</mi>' assert mpp.doprint(Symbol('epsilon')) == '<mi>&#949;</mi>' assert mpp.doprint(Symbol('zeta')) == '<mi>&#950;</mi>' assert mpp.doprint(Symbol('eta')) == '<mi>&#951;</mi>' assert mpp.doprint(Symbol('theta')) == '<mi>&#952;</mi>' assert mpp.doprint(Symbol('iota')) == '<mi>&#953;</mi>' assert mpp.doprint(Symbol('kappa')) == '<mi>&#954;</mi>' assert mpp.doprint(Symbol('lambda')) == '<mi>&#955;</mi>' assert mpp.doprint(Symbol('mu')) == '<mi>&#956;</mi>' assert mpp.doprint(Symbol('nu')) == '<mi>&#957;</mi>' assert mpp.doprint(Symbol('xi')) == '<mi>&#958;</mi>' assert mpp.doprint(Symbol('omicron')) == '<mi>&#959;</mi>' assert mpp.doprint(Symbol('pi')) == '<mi>&#960;</mi>' assert mpp.doprint(Symbol('rho')) == '<mi>&#961;</mi>' assert mpp.doprint(Symbol('varsigma')) == '<mi>&#962;</mi>' assert mpp.doprint(Symbol('sigma')) == '<mi>&#963;</mi>' assert mpp.doprint(Symbol('tau')) == '<mi>&#964;</mi>' assert mpp.doprint(Symbol('upsilon')) == '<mi>&#965;</mi>' assert mpp.doprint(Symbol('phi')) == '<mi>&#966;</mi>' assert mpp.doprint(Symbol('chi')) == '<mi>&#967;</mi>' assert mpp.doprint(Symbol('psi')) == '<mi>&#968;</mi>' assert mpp.doprint(Symbol('omega')) == '<mi>&#969;</mi>' assert mpp.doprint(Symbol('Alpha')) == '<mi>&#913;</mi>' assert mpp.doprint(Symbol('Beta')) == '<mi>&#914;</mi>' assert mpp.doprint(Symbol('Gamma')) == '<mi>&#915;</mi>' assert mpp.doprint(Symbol('Delta')) == '<mi>&#916;</mi>' assert mpp.doprint(Symbol('Epsilon')) == '<mi>&#917;</mi>' assert mpp.doprint(Symbol('Zeta')) == '<mi>&#918;</mi>' assert mpp.doprint(Symbol('Eta')) == '<mi>&#919;</mi>' assert mpp.doprint(Symbol('Theta')) == '<mi>&#920;</mi>' assert mpp.doprint(Symbol('Iota')) == '<mi>&#921;</mi>' assert mpp.doprint(Symbol('Kappa')) == '<mi>&#922;</mi>' assert mpp.doprint(Symbol('Lambda')) == '<mi>&#923;</mi>' assert mpp.doprint(Symbol('Mu')) == '<mi>&#924;</mi>' assert mpp.doprint(Symbol('Nu')) == '<mi>&#925;</mi>' assert mpp.doprint(Symbol('Xi')) == '<mi>&#926;</mi>' assert mpp.doprint(Symbol('Omicron')) == '<mi>&#927;</mi>' assert mpp.doprint(Symbol('Pi')) == '<mi>&#928;</mi>' assert mpp.doprint(Symbol('Rho')) == '<mi>&#929;</mi>' assert mpp.doprint(Symbol('Sigma')) == '<mi>&#931;</mi>' assert mpp.doprint(Symbol('Tau')) == '<mi>&#932;</mi>' assert mpp.doprint(Symbol('Upsilon')) == '<mi>&#933;</mi>' assert mpp.doprint(Symbol('Phi')) == '<mi>&#934;</mi>' assert mpp.doprint(Symbol('Chi')) == '<mi>&#935;</mi>' assert mpp.doprint(Symbol('Psi')) == '<mi>&#936;</mi>' assert mpp.doprint(Symbol('Omega')) == '<mi>&#937;</mi>' def test_presentation_mathml_order(): expr = x**3 + x**2*y + 3*x*y**3 + y**4 mp = MathMLPresentationPrinter({'order': 'lex'}) mml = mp._print(expr) assert mml.childNodes[0].nodeName == 'msup' assert mml.childNodes[0].childNodes[0].childNodes[0].nodeValue == 'x' assert mml.childNodes[0].childNodes[1].childNodes[0].nodeValue == '3' assert mml.childNodes[6].nodeName == 'msup' assert mml.childNodes[6].childNodes[0].childNodes[0].nodeValue == 'y' assert mml.childNodes[6].childNodes[1].childNodes[0].nodeValue == '4' mp = MathMLPresentationPrinter({'order': 'rev-lex'}) mml = mp._print(expr) assert mml.childNodes[0].nodeName == 'msup' assert mml.childNodes[0].childNodes[0].childNodes[0].nodeValue == 'y' assert mml.childNodes[0].childNodes[1].childNodes[0].nodeValue == '4' assert mml.childNodes[6].nodeName == 'msup' assert mml.childNodes[6].childNodes[0].childNodes[0].nodeValue == 'x' assert mml.childNodes[6].childNodes[1].childNodes[0].nodeValue == '3' def test_print_intervals(): a = Symbol('a', real=True) assert mpp.doprint(Interval(0, a)) == \ '<mrow><mfenced close="]" open="["><mn>0</mn><mi>a</mi></mfenced></mrow>' assert mpp.doprint(Interval(0, a, False, False)) == \ '<mrow><mfenced close="]" open="["><mn>0</mn><mi>a</mi></mfenced></mrow>' assert mpp.doprint(Interval(0, a, True, False)) == \ '<mrow><mfenced close="]" open="("><mn>0</mn><mi>a</mi></mfenced></mrow>' assert mpp.doprint(Interval(0, a, False, True)) == \ '<mrow><mfenced close=")" open="["><mn>0</mn><mi>a</mi></mfenced></mrow>' assert mpp.doprint(Interval(0, a, True, True)) == \ '<mrow><mfenced close=")" open="("><mn>0</mn><mi>a</mi></mfenced></mrow>' def test_print_tuples(): assert mpp.doprint(Tuple(0,)) == \ '<mrow><mfenced><mn>0</mn></mfenced></mrow>' assert mpp.doprint(Tuple(0, a)) == \ '<mrow><mfenced><mn>0</mn><mi>a</mi></mfenced></mrow>' assert mpp.doprint(Tuple(0, a, a)) == \ '<mrow><mfenced><mn>0</mn><mi>a</mi><mi>a</mi></mfenced></mrow>' assert mpp.doprint(Tuple(0, 1, 2, 3, 4)) == \ '<mrow><mfenced><mn>0</mn><mn>1</mn><mn>2</mn><mn>3</mn><mn>4</mn></mfenced></mrow>' assert mpp.doprint(Tuple(0, 1, Tuple(2, 3, 4))) == \ '<mrow><mfenced><mn>0</mn><mn>1</mn><mrow><mfenced><mn>2</mn><mn>3'\ '</mn><mn>4</mn></mfenced></mrow></mfenced></mrow>' def test_print_re_im(): assert mpp.doprint(re(x)) == \ '<mrow><mi mathvariant="fraktur">R</mi><mfenced><mi>x</mi></mfenced></mrow>' assert mpp.doprint(im(x)) == \ '<mrow><mi mathvariant="fraktur">I</mi><mfenced><mi>x</mi></mfenced></mrow>' assert mpp.doprint(re(x + 1)) == \ '<mrow><mrow><mi mathvariant="fraktur">R</mi><mfenced><mi>x</mi>'\ '</mfenced></mrow><mo>+</mo><mn>1</mn></mrow>' assert mpp.doprint(im(x + 1)) == \ '<mrow><mi mathvariant="fraktur">I</mi><mfenced><mi>x</mi></mfenced></mrow>' def test_print_Abs(): assert mpp.doprint(Abs(x)) == \ '<mrow><mfenced close="|" open="|"><mi>x</mi></mfenced></mrow>' assert mpp.doprint(Abs(x + 1)) == \ '<mrow><mfenced close="|" open="|"><mrow><mi>x</mi><mo>+</mo><mn>1</mn></mrow></mfenced></mrow>' def test_print_Determinant(): assert mpp.doprint(Determinant(Matrix([[1, 2], [3, 4]]))) == \ '<mrow><mfenced close="|" open="|"><mfenced close="]" open="["><mtable><mtr><mtd><mn>1</mn></mtd><mtd><mn>2</mn></mtd></mtr><mtr><mtd><mn>3</mn></mtd><mtd><mn>4</mn></mtd></mtr></mtable></mfenced></mfenced></mrow>' def test_presentation_settings(): raises(TypeError, lambda: mathml(x, printer='presentation', method="garbage")) def test_toprettyxml_hooking(): # test that the patch doesn't influence the behavior of the standard # library import xml.dom.minidom doc1 = xml.dom.minidom.parseString( "<apply><plus/><ci>x</ci><cn>1</cn></apply>") doc2 = xml.dom.minidom.parseString( "<mrow><mi>x</mi><mo>+</mo><mn>1</mn></mrow>") prettyxml_old1 = doc1.toprettyxml() prettyxml_old2 = doc2.toprettyxml() mp.apply_patch() mp.restore_patch() assert prettyxml_old1 == doc1.toprettyxml() assert prettyxml_old2 == doc2.toprettyxml() def test_print_domains(): from sympy import Complexes, Integers, Naturals, Naturals0, Reals assert mpp.doprint(Complexes) == '<mi mathvariant="normal">&#x2102;</mi>' assert mpp.doprint(Integers) == '<mi mathvariant="normal">&#x2124;</mi>' assert mpp.doprint(Naturals) == '<mi mathvariant="normal">&#x2115;</mi>' assert mpp.doprint(Naturals0) == \ '<msub><mi mathvariant="normal">&#x2115;</mi><mn>0</mn></msub>' assert mpp.doprint(Reals) == '<mi mathvariant="normal">&#x211D;</mi>' def test_print_expression_with_minus(): assert mpp.doprint(-x) == '<mrow><mo>-</mo><mi>x</mi></mrow>' assert mpp.doprint(-x/y) == \ '<mrow><mo>-</mo><mfrac><mi>x</mi><mi>y</mi></mfrac></mrow>' assert mpp.doprint(-Rational(1, 2)) == \ '<mrow><mo>-</mo><mfrac><mn>1</mn><mn>2</mn></mfrac></mrow>' def test_print_AssocOp(): from sympy.core.operations import AssocOp class TestAssocOp(AssocOp): identity = 0 expr = TestAssocOp(1, 2) mpp.doprint(expr) == \ '<mrow><mi>testassocop</mi><mn>2</mn><mn>1</mn></mrow>' def test_print_basic(): expr = Basic(1, 2) assert mpp.doprint(expr) == \ '<mrow><mi>basic</mi><mfenced><mn>1</mn><mn>2</mn></mfenced></mrow>' assert mp.doprint(expr) == '<basic><cn>1</cn><cn>2</cn></basic>' def test_mat_delim_print(): expr = Matrix([[1, 2], [3, 4]]) assert mathml(expr, printer='presentation', mat_delim='[') == \ '<mfenced close="]" open="["><mtable><mtr><mtd><mn>1</mn></mtd><mtd>'\ '<mn>2</mn></mtd></mtr><mtr><mtd><mn>3</mn></mtd><mtd><mn>4</mn>'\ '</mtd></mtr></mtable></mfenced>' assert mathml(expr, printer='presentation', mat_delim='(') == \ '<mfenced><mtable><mtr><mtd><mn>1</mn></mtd><mtd><mn>2</mn></mtd>'\ '</mtr><mtr><mtd><mn>3</mn></mtd><mtd><mn>4</mn></mtd></mtr></mtable></mfenced>' assert mathml(expr, printer='presentation', mat_delim='') == \ '<mtable><mtr><mtd><mn>1</mn></mtd><mtd><mn>2</mn></mtd></mtr><mtr>'\ '<mtd><mn>3</mn></mtd><mtd><mn>4</mn></mtd></mtr></mtable>' def test_ln_notation_print(): expr = log(x) assert mathml(expr, printer='presentation') == \ '<mrow><mi>log</mi><mfenced><mi>x</mi></mfenced></mrow>' assert mathml(expr, printer='presentation', ln_notation=False) == \ '<mrow><mi>log</mi><mfenced><mi>x</mi></mfenced></mrow>' assert mathml(expr, printer='presentation', ln_notation=True) == \ '<mrow><mi>ln</mi><mfenced><mi>x</mi></mfenced></mrow>' def test_mul_symbol_print(): expr = x * y assert mathml(expr, printer='presentation') == \ '<mrow><mi>x</mi><mo>&InvisibleTimes;</mo><mi>y</mi></mrow>' assert mathml(expr, printer='presentation', mul_symbol=None) == \ '<mrow><mi>x</mi><mo>&InvisibleTimes;</mo><mi>y</mi></mrow>' assert mathml(expr, printer='presentation', mul_symbol='dot') == \ '<mrow><mi>x</mi><mo>&#xB7;</mo><mi>y</mi></mrow>' assert mathml(expr, printer='presentation', mul_symbol='ldot') == \ '<mrow><mi>x</mi><mo>&#x2024;</mo><mi>y</mi></mrow>' assert mathml(expr, printer='presentation', mul_symbol='times') == \ '<mrow><mi>x</mi><mo>&#xD7;</mo><mi>y</mi></mrow>' def test_print_lerchphi(): assert mpp.doprint(lerchphi(1, 2, 3)) == \ '<mrow><mi>&#x3A6;</mi><mfenced><mn>1</mn><mn>2</mn><mn>3</mn></mfenced></mrow>' def test_print_polylog(): assert mp.doprint(polylog(x, y)) == \ '<apply><polylog/><ci>x</ci><ci>y</ci></apply>' assert mpp.doprint(polylog(x, y)) == \ '<mrow><msub><mi>Li</mi><mi>x</mi></msub><mfenced><mi>y</mi></mfenced></mrow>' def test_print_set_frozenset(): f = frozenset({1, 5, 3}) assert mpp.doprint(f) == \ '<mfenced close="}" open="{"><mn>1</mn><mn>3</mn><mn>5</mn></mfenced>' s = set({1, 2, 3}) assert mpp.doprint(s) == \ '<mfenced close="}" open="{"><mn>1</mn><mn>2</mn><mn>3</mn></mfenced>' def test_print_FiniteSet(): f1 = FiniteSet(x, 1, 3) assert mpp.doprint(f1) == \ '<mfenced close="}" open="{"><mn>1</mn><mn>3</mn><mi>x</mi></mfenced>' def test_print_EmptySet(): assert mpp.doprint(EmptySet()) == '<mo>&#x2205;</mo>' def test_print_SetOp(): f1 = FiniteSet(x, 1, 3) f2 = FiniteSet(y, 2, 4) assert mpp.doprint(Union(f1, f2, evaluate=False)) == \ '<mrow><mfenced close="}" open="{"><mn>1</mn><mn>3</mn><mi>x</mi>'\ '</mfenced><mo>&#x222A;</mo><mfenced close="}" open="{"><mn>2</mn>'\ '<mn>4</mn><mi>y</mi></mfenced></mrow>' assert mpp.doprint(Intersection(f1, f2, evaluate=False)) == \ '<mrow><mfenced close="}" open="{"><mn>1</mn><mn>3</mn><mi>x</mi>'\ '</mfenced><mo>&#x2229;</mo><mfenced close="}" open="{"><mn>2</mn>'\ '<mn>4</mn><mi>y</mi></mfenced></mrow>' assert mpp.doprint(Complement(f1, f2, evaluate=False)) == \ '<mrow><mfenced close="}" open="{"><mn>1</mn><mn>3</mn><mi>x</mi>'\ '</mfenced><mo>&#x2216;</mo><mfenced close="}" open="{"><mn>2</mn>'\ '<mn>4</mn><mi>y</mi></mfenced></mrow>' assert mpp.doprint(SymmetricDifference(f1, f2, evaluate=False)) == \ '<mrow><mfenced close="}" open="{"><mn>1</mn><mn>3</mn><mi>x</mi>'\ '</mfenced><mo>&#x2206;</mo><mfenced close="}" open="{"><mn>2</mn>'\ '<mn>4</mn><mi>y</mi></mfenced></mrow>' def test_print_logic(): assert mpp.doprint(And(x, y)) == \ '<mrow><mi>x</mi><mo>&#x2227;</mo><mi>y</mi></mrow>' assert mpp.doprint(Or(x, y)) == \ '<mrow><mi>x</mi><mo>&#x2228;</mo><mi>y</mi></mrow>' assert mpp.doprint(Xor(x, y)) == \ '<mrow><mi>x</mi><mo>&#x22BB;</mo><mi>y</mi></mrow>' assert mpp.doprint(Implies(x, y)) == \ '<mrow><mi>x</mi><mo>&#x21D2;</mo><mi>y</mi></mrow>' assert mpp.doprint(Equivalent(x, y)) == \ '<mrow><mi>x</mi><mo>&#x21D4;</mo><mi>y</mi></mrow>' assert mpp.doprint(And(Eq(x, y), x > 4)) == \ '<mrow><mrow><mi>x</mi><mo>=</mo><mi>y</mi></mrow><mo>&#x2227;</mo>'\ '<mrow><mi>x</mi><mo>></mo><mn>4</mn></mrow></mrow>' assert mpp.doprint(And(Eq(x, 3), y < 3, x > y + 1)) == \ '<mrow><mrow><mi>x</mi><mo>=</mo><mn>3</mn></mrow><mo>&#x2227;</mo>'\ '<mrow><mi>x</mi><mo>></mo><mrow><mi>y</mi><mo>+</mo><mn>1</mn></mrow>'\ '</mrow><mo>&#x2227;</mo><mrow><mi>y</mi><mo><</mo><mn>3</mn></mrow></mrow>' assert mpp.doprint(Or(Eq(x, y), x > 4)) == \ '<mrow><mrow><mi>x</mi><mo>=</mo><mi>y</mi></mrow><mo>&#x2228;</mo>'\ '<mrow><mi>x</mi><mo>></mo><mn>4</mn></mrow></mrow>' assert mpp.doprint(And(Eq(x, 3), Or(y < 3, x > y + 1))) == \ '<mrow><mrow><mi>x</mi><mo>=</mo><mn>3</mn></mrow><mo>&#x2227;</mo>'\ '<mfenced><mrow><mrow><mi>x</mi><mo>></mo><mrow><mi>y</mi><mo>+</mo>'\ '<mn>1</mn></mrow></mrow><mo>&#x2228;</mo><mrow><mi>y</mi><mo><</mo>'\ '<mn>3</mn></mrow></mrow></mfenced></mrow>' assert mpp.doprint(Not(x)) == '<mrow><mo>&#xAC;</mo><mi>x</mi></mrow>' assert mpp.doprint(Not(And(x, y))) == \ '<mrow><mo>&#xAC;</mo><mfenced><mrow><mi>x</mi><mo>&#x2227;</mo>'\ '<mi>y</mi></mrow></mfenced></mrow>' def test_root_notation_print(): assert mathml(x**(S(1)/3), printer='presentation') == \ '<mroot><mi>x</mi><mn>3</mn></mroot>' assert mathml(x**(S(1)/3), printer='presentation', root_notation=False) ==\ '<msup><mi>x</mi><mfrac><mn>1</mn><mn>3</mn></mfrac></msup>' assert mathml(x**(S(1)/3), printer='content') == \ '<apply><root/><degree><ci>3</ci></degree><ci>x</ci></apply>' assert mathml(x**(S(1)/3), printer='content', root_notation=False) == \ '<apply><power/><ci>x</ci><apply><divide/><cn>1</cn><cn>3</cn></apply></apply>' assert mathml(x**(-S(1)/3), printer='presentation') == \ '<mfrac><mn>1</mn><mroot><mi>x</mi><mn>3</mn></mroot></mfrac>' assert mathml(x**(-S(1)/3), printer='presentation', root_notation=False) \ == '<mfrac><mn>1</mn><msup><mi>x</mi><mfrac><mn>1</mn><mn>3</mn></mfrac></msup></mfrac>' def test_fold_frac_powers_print(): expr = x ** Rational(5, 2) assert mathml(expr, printer='presentation') == \ '<msup><mi>x</mi><mfrac><mn>5</mn><mn>2</mn></mfrac></msup>' assert mathml(expr, printer='presentation', fold_frac_powers=True) == \ '<msup><mi>x</mi><mfrac bevelled="true"><mn>5</mn><mn>2</mn></mfrac></msup>' assert mathml(expr, printer='presentation', fold_frac_powers=False) == \ '<msup><mi>x</mi><mfrac><mn>5</mn><mn>2</mn></mfrac></msup>' def test_fold_short_frac_print(): expr = Rational(2, 5) assert mathml(expr, printer='presentation') == \ '<mfrac><mn>2</mn><mn>5</mn></mfrac>' assert mathml(expr, printer='presentation', fold_short_frac=True) == \ '<mfrac bevelled="true"><mn>2</mn><mn>5</mn></mfrac>' assert mathml(expr, printer='presentation', fold_short_frac=False) == \ '<mfrac><mn>2</mn><mn>5</mn></mfrac>' def test_print_factorials(): assert mpp.doprint(factorial(x)) == '<mrow><mi>x</mi><mo>!</mo></mrow>' assert mpp.doprint(factorial(x + 1)) == \ '<mrow><mfenced><mrow><mi>x</mi><mo>+</mo><mn>1</mn></mrow></mfenced><mo>!</mo></mrow>' assert mpp.doprint(factorial2(x)) == '<mrow><mi>x</mi><mo>!!</mo></mrow>' assert mpp.doprint(factorial2(x + 1)) == \ '<mrow><mfenced><mrow><mi>x</mi><mo>+</mo><mn>1</mn></mrow></mfenced><mo>!!</mo></mrow>' assert mpp.doprint(binomial(x, y)) == \ '<mfenced><mfrac linethickness="0"><mi>x</mi><mi>y</mi></mfrac></mfenced>' assert mpp.doprint(binomial(4, x + y)) == \ '<mfenced><mfrac linethickness="0"><mn>4</mn><mrow><mi>x</mi>'\ '<mo>+</mo><mi>y</mi></mrow></mfrac></mfenced>' def test_print_floor(): expr = floor(x) assert mathml(expr, printer='presentation') == \ '<mrow><mfenced close="&#8971;" open="&#8970;"><mi>x</mi></mfenced></mrow>' def test_print_ceiling(): expr = ceiling(x) assert mathml(expr, printer='presentation') == \ '<mrow><mfenced close="&#8969;" open="&#8968;"><mi>x</mi></mfenced></mrow>' def test_print_Lambda(): expr = Lambda(x, x+1) assert mathml(expr, printer='presentation') == \ '<mfenced><mrow><mi>x</mi><mo>&#x21A6;</mo><mrow><mi>x</mi><mo>+</mo>'\ '<mn>1</mn></mrow></mrow></mfenced>' expr = Lambda((x, y), x + y) assert mathml(expr, printer='presentation') == \ '<mfenced><mrow><mrow><mfenced><mi>x</mi><mi>y</mi></mfenced></mrow>'\ '<mo>&#x21A6;</mo><mrow><mi>x</mi><mo>+</mo><mi>y</mi></mrow></mrow></mfenced>' def test_print_conjugate(): assert mpp.doprint(conjugate(x)) == \ '<menclose notation="top"><mi>x</mi></menclose>' assert mpp.doprint(conjugate(x + 1)) == \ '<mrow><menclose notation="top"><mi>x</mi></menclose><mo>+</mo><mn>1</mn></mrow>' def test_print_AccumBounds(): a = Symbol('a', real=True) assert mpp.doprint(AccumBounds(0, 1)) == '<mfenced close="&#10217;" open="&#10216;"><mn>0</mn><mn>1</mn></mfenced>' assert mpp.doprint(AccumBounds(0, a)) == '<mfenced close="&#10217;" open="&#10216;"><mn>0</mn><mi>a</mi></mfenced>' assert mpp.doprint(AccumBounds(a + 1, a + 2)) == '<mfenced close="&#10217;" open="&#10216;"><mrow><mi>a</mi><mo>+</mo><mn>1</mn></mrow><mrow><mi>a</mi><mo>+</mo><mn>2</mn></mrow></mfenced>' def test_print_Float(): assert mpp.doprint(Float(1e100)) == '<mrow><mn>1.0</mn><mo>&#xB7;</mo><msup><mn>10</mn><mn>100</mn></msup></mrow>' assert mpp.doprint(Float(1e-100)) == '<mrow><mn>1.0</mn><mo>&#xB7;</mo><msup><mn>10</mn><mn>-100</mn></msup></mrow>' assert mpp.doprint(Float(-1e100)) == '<mrow><mn>-1.0</mn><mo>&#xB7;</mo><msup><mn>10</mn><mn>100</mn></msup></mrow>' assert mpp.doprint(Float(1.0*oo)) == '<mi>&#x221E;</mi>' assert mpp.doprint(Float(-1.0*oo)) == '<mrow><mo>-</mo><mi>&#x221E;</mi></mrow>' def test_print_different_functions(): assert mpp.doprint(gamma(x)) == '<mrow><mi>&#x393;</mi><mfenced><mi>x</mi></mfenced></mrow>' assert mpp.doprint(lowergamma(x, y)) == '<mrow><mi>&#x3B3;</mi><mfenced><mi>x</mi><mi>y</mi></mfenced></mrow>' assert mpp.doprint(uppergamma(x, y)) == '<mrow><mi>&#x393;</mi><mfenced><mi>x</mi><mi>y</mi></mfenced></mrow>' assert mpp.doprint(zeta(x)) == '<mrow><mi>&#x3B6;</mi><mfenced><mi>x</mi></mfenced></mrow>' assert mpp.doprint(zeta(x, y)) == '<mrow><mi>&#x3B6;</mi><mfenced><mi>x</mi><mi>y</mi></mfenced></mrow>' assert mpp.doprint(dirichlet_eta(x)) == '<mrow><mi>&#x3B7;</mi><mfenced><mi>x</mi></mfenced></mrow>' assert mpp.doprint(elliptic_k(x)) == '<mrow><mi>&#x39A;</mi><mfenced><mi>x</mi></mfenced></mrow>' assert mpp.doprint(totient(x)) == '<mrow><mi>&#x3D5;</mi><mfenced><mi>x</mi></mfenced></mrow>' assert mpp.doprint(reduced_totient(x)) == '<mrow><mi>&#x3BB;</mi><mfenced><mi>x</mi></mfenced></mrow>' assert mpp.doprint(primenu(x)) == '<mrow><mi>&#x3BD;</mi><mfenced><mi>x</mi></mfenced></mrow>' assert mpp.doprint(primeomega(x)) == '<mrow><mi>&#x3A9;</mi><mfenced><mi>x</mi></mfenced></mrow>' assert mpp.doprint(fresnels(x)) == '<mrow><mi>S</mi><mfenced><mi>x</mi></mfenced></mrow>' assert mpp.doprint(fresnelc(x)) == '<mrow><mi>C</mi><mfenced><mi>x</mi></mfenced></mrow>' assert mpp.doprint(Heaviside(x)) == '<mrow><mi>&#x398;</mi><mfenced><mi>x</mi></mfenced></mrow>' def test_mathml_builtins(): assert mpp.doprint(None) == '<mi>None</mi>' assert mpp.doprint(true) == '<mi>True</mi>' assert mpp.doprint(false) == '<mi>False</mi>' def test_mathml_Range(): assert mpp.doprint(Range(1, 51)) == \ '<mfenced close="}" open="{"><mn>1</mn><mn>2</mn><mi>&#8230;</mi><mn>50</mn></mfenced>' assert mpp.doprint(Range(1, 4)) == \ '<mfenced close="}" open="{"><mn>1</mn><mn>2</mn><mn>3</mn></mfenced>' assert mpp.doprint(Range(0, 3, 1)) == \ '<mfenced close="}" open="{"><mn>0</mn><mn>1</mn><mn>2</mn></mfenced>' assert mpp.doprint(Range(0, 30, 1)) == \ '<mfenced close="}" open="{"><mn>0</mn><mn>1</mn><mi>&#8230;</mi><mn>29</mn></mfenced>' assert mpp.doprint(Range(30, 1, -1)) == \ '<mfenced close="}" open="{"><mn>30</mn><mn>29</mn><mi>&#8230;</mi>'\ '<mn>2</mn></mfenced>' assert mpp.doprint(Range(0, oo, 2)) == \ '<mfenced close="}" open="{"><mn>0</mn><mn>2</mn><mi>&#8230;</mi></mfenced>' assert mpp.doprint(Range(oo, -2, -2)) == \ '<mfenced close="}" open="{"><mi>&#8230;</mi><mn>2</mn><mn>0</mn></mfenced>' assert mpp.doprint(Range(-2, -oo, -1)) == \ '<mfenced close="}" open="{"><mn>-2</mn><mn>-3</mn><mi>&#8230;</mi></mfenced>' def test_print_exp(): assert mpp.doprint(exp(x)) == \ '<msup><mi>&ExponentialE;</mi><mi>x</mi></msup>' assert mpp.doprint(exp(1) + exp(2)) == \ '<mrow><mi>&ExponentialE;</mi><mo>+</mo><msup><mi>&ExponentialE;</mi><mn>2</mn></msup></mrow>' def test_print_MinMax(): assert mpp.doprint(Min(x, y)) == \ '<mrow><mo>min</mo><mfenced><mi>x</mi><mi>y</mi></mfenced></mrow>' assert mpp.doprint(Min(x, 2, x**3)) == \ '<mrow><mo>min</mo><mfenced><mn>2</mn><mi>x</mi><msup><mi>x</mi>'\ '<mn>3</mn></msup></mfenced></mrow>' assert mpp.doprint(Max(x, y)) == \ '<mrow><mo>max</mo><mfenced><mi>x</mi><mi>y</mi></mfenced></mrow>' assert mpp.doprint(Max(x, 2, x**3)) == \ '<mrow><mo>max</mo><mfenced><mn>2</mn><mi>x</mi><msup><mi>x</mi>'\ '<mn>3</mn></msup></mfenced></mrow>' def test_mathml_presentation_numbers(): n = Symbol('n') assert mathml(catalan(n), printer='presentation') == \ '<msub><mi>C</mi><mi>n</mi></msub>' assert mathml(bernoulli(n), printer='presentation') == \ '<msub><mi>B</mi><mi>n</mi></msub>' assert mathml(bell(n), printer='presentation') == \ '<msub><mi>B</mi><mi>n</mi></msub>' assert mathml(fibonacci(n), printer='presentation') == \ '<msub><mi>F</mi><mi>n</mi></msub>' assert mathml(lucas(n), printer='presentation') == \ '<msub><mi>L</mi><mi>n</mi></msub>' assert mathml(tribonacci(n), printer='presentation') == \ '<msub><mi>T</mi><mi>n</mi></msub>' def test_print_matrix_symbol(): A = MatrixSymbol('A', 1, 2) assert mpp.doprint(A) == '<mi>A</mi>' assert mp.doprint(A) == '<ci>A</ci>' assert mathml(A, printer='presentation', mat_symbol_style="bold") == \ '<mi mathvariant="bold">A</mi>' # No effect in content printer assert mathml(A, mat_symbol_style="bold") == '<ci>A</ci>' def test_print_hadamard(): from sympy.matrices.expressions import HadamardProduct from sympy.matrices.expressions import Transpose X = MatrixSymbol('X', 2, 2) Y = MatrixSymbol('Y', 2, 2) assert mathml(HadamardProduct(X, Y*Y), printer="presentation") == \ '<mrow>' \ '<mi>X</mi>' \ '<mo>&#x2218;</mo>' \ '<msup><mi>Y</mi><mn>2</mn></msup>' \ '</mrow>' assert mathml(HadamardProduct(X, Y)*Y, printer="presentation") == \ '<mrow>' \ '<mfenced>' \ '<mrow><mi>X</mi><mo>&#x2218;</mo><mi>Y</mi></mrow>' \ '</mfenced>' \ '<mo>&InvisibleTimes;</mo><mi>Y</mi>' \ '</mrow>' assert mathml(HadamardProduct(X, Y, Y), printer="presentation") == \ '<mrow>' \ '<mi>X</mi><mo>&#x2218;</mo>' \ '<mi>Y</mi><mo>&#x2218;</mo>' \ '<mi>Y</mi>' \ '</mrow>' assert mathml( Transpose(HadamardProduct(X, Y)), printer="presentation") == \ '<msup>' \ '<mfenced>' \ '<mrow><mi>X</mi><mo>&#x2218;</mo><mi>Y</mi></mrow>' \ '</mfenced>' \ '<mo>T</mo>' \ '</msup>' def test_print_random_symbol(): R = RandomSymbol(Symbol('R')) assert mpp.doprint(R) == '<mi>R</mi>' assert mp.doprint(R) == '<ci>R</ci>' def test_print_IndexedBase(): assert mathml(IndexedBase(a)[b], printer='presentation') == \ '<msub><mi>a</mi><mi>b</mi></msub>' assert mathml(IndexedBase(a)[b, c, d], printer='presentation') == \ '<msub><mi>a</mi><mfenced><mi>b</mi><mi>c</mi><mi>d</mi></mfenced></msub>' assert mathml(IndexedBase(a)[b]*IndexedBase(c)[d]*IndexedBase(e), printer='presentation') == \ '<mrow><msub><mi>a</mi><mi>b</mi></msub><mo>&InvisibleTimes;'\ '</mo><msub><mi>c</mi><mi>d</mi></msub><mo>&InvisibleTimes;</mo><mi>e</mi></mrow>' def test_print_Indexed(): assert mathml(IndexedBase(a), printer='presentation') == '<mi>a</mi>' assert mathml(IndexedBase(a/b), printer='presentation') == \ '<mrow><mfrac><mi>a</mi><mi>b</mi></mfrac></mrow>' assert mathml(IndexedBase((a, b)), printer='presentation') == \ '<mrow><mfenced><mi>a</mi><mi>b</mi></mfenced></mrow>' def test_print_MatrixElement(): i, j = symbols('i j') A = MatrixSymbol('A', i, j) assert mathml(A[0,0],printer = 'presentation') == \ '<msub><mi>A</mi><mfenced close="" open=""><mn>0</mn><mn>0</mn></mfenced></msub>' assert mathml(A[i,j], printer = 'presentation') == \ '<msub><mi>A</mi><mfenced close="" open=""><mi>i</mi><mi>j</mi></mfenced></msub>' assert mathml(A[i*j,0], printer = 'presentation') == \ '<msub><mi>A</mi><mfenced close="" open=""><mrow><mi>i</mi><mo>&InvisibleTimes;</mo><mi>j</mi></mrow><mn>0</mn></mfenced></msub>' def test_print_Vector(): ACS = CoordSys3D('A') assert mathml(Cross(ACS.i, ACS.j*ACS.x*3 + ACS.k), printer='presentation') == \ '<mrow><msub><mover><mi mathvariant="bold">i</mi><mo>^</mo></mover>'\ '<mi mathvariant="bold">A</mi></msub><mo>&#xD7;</mo><mfenced><mrow>'\ '<mfenced><mrow><mn>3</mn><mo>&InvisibleTimes;</mo><msub>'\ '<mi mathvariant="bold">x</mi><mi mathvariant="bold">A</mi></msub>'\ '</mrow></mfenced><mo>&InvisibleTimes;</mo><msub><mover>'\ '<mi mathvariant="bold">j</mi><mo>^</mo></mover>'\ '<mi mathvariant="bold">A</mi></msub><mo>+</mo><msub><mover>'\ '<mi mathvariant="bold">k</mi><mo>^</mo></mover><mi mathvariant="bold">'\ 'A</mi></msub></mrow></mfenced></mrow>' assert mathml(Cross(ACS.i, ACS.j), printer='presentation') == \ '<mrow><msub><mover><mi mathvariant="bold">i</mi><mo>^</mo></mover>'\ '<mi mathvariant="bold">A</mi></msub><mo>&#xD7;</mo><msub><mover>'\ '<mi mathvariant="bold">j</mi><mo>^</mo></mover>'\ '<mi mathvariant="bold">A</mi></msub></mrow>' assert mathml(x*Cross(ACS.i, ACS.j), printer='presentation') == \ '<mrow><mi>x</mi><mo>&InvisibleTimes;</mo><mrow><msub><mover>'\ '<mi mathvariant="bold">i</mi><mo>^</mo></mover>'\ '<mi mathvariant="bold">A</mi></msub><mo>&#xD7;</mo><msub><mover>'\ '<mi mathvariant="bold">j</mi><mo>^</mo></mover>'\ '<mi mathvariant="bold">A</mi></msub></mrow></mrow>' assert mathml(Cross(x*ACS.i, ACS.j), printer='presentation') == \ '<mrow><mo>-</mo><mrow><msub><mover><mi mathvariant="bold">j</mi>'\ '<mo>^</mo></mover><mi mathvariant="bold">A</mi></msub>'\ '<mo>&#xD7;</mo><mfenced><mrow><mfenced><mi>x</mi></mfenced>'\ '<mo>&InvisibleTimes;</mo><msub><mover><mi mathvariant="bold">i</mi>'\ '<mo>^</mo></mover><mi mathvariant="bold">A</mi></msub></mrow>'\ '</mfenced></mrow></mrow>' assert mathml(Curl(3*ACS.x*ACS.j), printer='presentation') == \ '<mrow><mo>&#x2207;</mo><mo>&#xD7;</mo><mfenced><mrow><mfenced><mrow>'\ '<mn>3</mn><mo>&InvisibleTimes;</mo><msub>'\ '<mi mathvariant="bold">x</mi><mi mathvariant="bold">A</mi></msub>'\ '</mrow></mfenced><mo>&InvisibleTimes;</mo><msub><mover>'\ '<mi mathvariant="bold">j</mi><mo>^</mo></mover>'\ '<mi mathvariant="bold">A</mi></msub></mrow></mfenced></mrow>' assert mathml(Curl(3*x*ACS.x*ACS.j), printer='presentation') == \ '<mrow><mo>&#x2207;</mo><mo>&#xD7;</mo><mfenced><mrow><mfenced><mrow>'\ '<mn>3</mn><mo>&InvisibleTimes;</mo><msub><mi mathvariant="bold">x'\ '</mi><mi mathvariant="bold">A</mi></msub><mo>&InvisibleTimes;</mo>'\ '<mi>x</mi></mrow></mfenced><mo>&InvisibleTimes;</mo><msub><mover>'\ '<mi mathvariant="bold">j</mi><mo>^</mo></mover>'\ '<mi mathvariant="bold">A</mi></msub></mrow></mfenced></mrow>' assert mathml(x*Curl(3*ACS.x*ACS.j), printer='presentation') == \ '<mrow><mi>x</mi><mo>&InvisibleTimes;</mo><mrow><mo>&#x2207;</mo>'\ '<mo>&#xD7;</mo><mfenced><mrow><mfenced><mrow><mn>3</mn>'\ '<mo>&InvisibleTimes;</mo><msub><mi mathvariant="bold">x</mi>'\ '<mi mathvariant="bold">A</mi></msub></mrow></mfenced>'\ '<mo>&InvisibleTimes;</mo><msub><mover><mi mathvariant="bold">j</mi>'\ '<mo>^</mo></mover><mi mathvariant="bold">A</mi></msub></mrow>'\ '</mfenced></mrow></mrow>' assert mathml(Curl(3*x*ACS.x*ACS.j + ACS.i), printer='presentation') == \ '<mrow><mo>&#x2207;</mo><mo>&#xD7;</mo><mfenced><mrow><msub><mover>'\ '<mi mathvariant="bold">i</mi><mo>^</mo></mover>'\ '<mi mathvariant="bold">A</mi></msub><mo>+</mo><mfenced><mrow>'\ '<mn>3</mn><mo>&InvisibleTimes;</mo><msub><mi mathvariant="bold">x'\ '</mi><mi mathvariant="bold">A</mi></msub><mo>&InvisibleTimes;</mo>'\ '<mi>x</mi></mrow></mfenced><mo>&InvisibleTimes;</mo><msub><mover>'\ '<mi mathvariant="bold">j</mi><mo>^</mo></mover>'\ '<mi mathvariant="bold">A</mi></msub></mrow></mfenced></mrow>' assert mathml(Divergence(3*ACS.x*ACS.j), printer='presentation') == \ '<mrow><mo>&#x2207;</mo><mo>&#xB7;</mo><mfenced><mrow><mfenced><mrow>'\ '<mn>3</mn><mo>&InvisibleTimes;</mo><msub><mi mathvariant="bold">x'\ '</mi><mi mathvariant="bold">A</mi></msub></mrow></mfenced>'\ '<mo>&InvisibleTimes;</mo><msub><mover><mi mathvariant="bold">j</mi>'\ '<mo>^</mo></mover><mi mathvariant="bold">A</mi></msub></mrow></mfenced></mrow>' assert mathml(x*Divergence(3*ACS.x*ACS.j), printer='presentation') == \ '<mrow><mi>x</mi><mo>&InvisibleTimes;</mo><mrow><mo>&#x2207;</mo>'\ '<mo>&#xB7;</mo><mfenced><mrow><mfenced><mrow><mn>3</mn>'\ '<mo>&InvisibleTimes;</mo><msub><mi mathvariant="bold">x</mi>'\ '<mi mathvariant="bold">A</mi></msub></mrow></mfenced>'\ '<mo>&InvisibleTimes;</mo><msub><mover><mi mathvariant="bold">j</mi>'\ '<mo>^</mo></mover><mi mathvariant="bold">A</mi></msub></mrow>'\ '</mfenced></mrow></mrow>' assert mathml(Divergence(3*x*ACS.x*ACS.j + ACS.i), printer='presentation') == \ '<mrow><mo>&#x2207;</mo><mo>&#xB7;</mo><mfenced><mrow><msub><mover>'\ '<mi mathvariant="bold">i</mi><mo>^</mo></mover>'\ '<mi mathvariant="bold">A</mi></msub><mo>+</mo><mfenced><mrow>'\ '<mn>3</mn><mo>&InvisibleTimes;</mo><msub>'\ '<mi mathvariant="bold">x</mi><mi mathvariant="bold">A</mi></msub>'\ '<mo>&InvisibleTimes;</mo><mi>x</mi></mrow></mfenced>'\ '<mo>&InvisibleTimes;</mo><msub><mover><mi mathvariant="bold">j</mi>'\ '<mo>^</mo></mover><mi mathvariant="bold">A</mi></msub></mrow></mfenced></mrow>' assert mathml(Dot(ACS.i, ACS.j*ACS.x*3+ACS.k), printer='presentation') == \ '<mrow><msub><mover><mi mathvariant="bold">i</mi><mo>^</mo></mover>'\ '<mi mathvariant="bold">A</mi></msub><mo>&#xB7;</mo><mfenced><mrow>'\ '<mfenced><mrow><mn>3</mn><mo>&InvisibleTimes;</mo><msub>'\ '<mi mathvariant="bold">x</mi><mi mathvariant="bold">A</mi></msub>'\ '</mrow></mfenced><mo>&InvisibleTimes;</mo><msub><mover>'\ '<mi mathvariant="bold">j</mi><mo>^</mo></mover>'\ '<mi mathvariant="bold">A</mi></msub><mo>+</mo><msub><mover>'\ '<mi mathvariant="bold">k</mi><mo>^</mo></mover>'\ '<mi mathvariant="bold">A</mi></msub></mrow></mfenced></mrow>' assert mathml(Dot(ACS.i, ACS.j), printer='presentation') == \ '<mrow><msub><mover><mi mathvariant="bold">i</mi><mo>^</mo></mover>'\ '<mi mathvariant="bold">A</mi></msub><mo>&#xB7;</mo><msub><mover>'\ '<mi mathvariant="bold">j</mi><mo>^</mo></mover>'\ '<mi mathvariant="bold">A</mi></msub></mrow>' assert mathml(Dot(x*ACS.i, ACS.j), printer='presentation') == \ '<mrow><msub><mover><mi mathvariant="bold">j</mi><mo>^</mo></mover>'\ '<mi mathvariant="bold">A</mi></msub><mo>&#xB7;</mo><mfenced><mrow>'\ '<mfenced><mi>x</mi></mfenced><mo>&InvisibleTimes;</mo><msub><mover>'\ '<mi mathvariant="bold">i</mi><mo>^</mo></mover>'\ '<mi mathvariant="bold">A</mi></msub></mrow></mfenced></mrow>' assert mathml(x*Dot(ACS.i, ACS.j), printer='presentation') == \ '<mrow><mi>x</mi><mo>&InvisibleTimes;</mo><mrow><msub><mover>'\ '<mi mathvariant="bold">i</mi><mo>^</mo></mover>'\ '<mi mathvariant="bold">A</mi></msub><mo>&#xB7;</mo><msub><mover>'\ '<mi mathvariant="bold">j</mi><mo>^</mo></mover>'\ '<mi mathvariant="bold">A</mi></msub></mrow></mrow>' assert mathml(Gradient(ACS.x), printer='presentation') == \ '<mrow><mo>&#x2207;</mo><msub><mi mathvariant="bold">x</mi>'\ '<mi mathvariant="bold">A</mi></msub></mrow>' assert mathml(Gradient(ACS.x + 3*ACS.y), printer='presentation') == \ '<mrow><mo>&#x2207;</mo><mfenced><mrow><msub><mi mathvariant="bold">'\ 'x</mi><mi mathvariant="bold">A</mi></msub><mo>+</mo><mrow><mn>3</mn>'\ '<mo>&InvisibleTimes;</mo><msub><mi mathvariant="bold">y</mi>'\ '<mi mathvariant="bold">A</mi></msub></mrow></mrow></mfenced></mrow>' assert mathml(x*Gradient(ACS.x), printer='presentation') == \ '<mrow><mi>x</mi><mo>&InvisibleTimes;</mo><mrow><mo>&#x2207;</mo>'\ '<msub><mi mathvariant="bold">x</mi><mi mathvariant="bold">A</mi>'\ '</msub></mrow></mrow>' assert mathml(Gradient(x*ACS.x), printer='presentation') == \ '<mrow><mo>&#x2207;</mo><mfenced><mrow><msub><mi mathvariant="bold">'\ 'x</mi><mi mathvariant="bold">A</mi></msub><mo>&InvisibleTimes;</mo>'\ '<mi>x</mi></mrow></mfenced></mrow>' assert mathml(Cross(ACS.x, ACS.z) + Cross(ACS.z, ACS.x), printer='presentation') == \ '<mover><mi mathvariant="bold">0</mi><mo>^</mo></mover>' assert mathml(Cross(ACS.z, ACS.x), printer='presentation') == \ '<mrow><mo>-</mo><mrow><msub><mi mathvariant="bold">x</mi>'\ '<mi mathvariant="bold">A</mi></msub><mo>&#xD7;</mo><msub>'\ '<mi mathvariant="bold">z</mi><mi mathvariant="bold">A</mi></msub></mrow></mrow>' assert mathml(Laplacian(ACS.x), printer='presentation') == \ '<mrow><mo>&#x2206;</mo><msub><mi mathvariant="bold">x</mi>'\ '<mi mathvariant="bold">A</mi></msub></mrow>' assert mathml(Laplacian(ACS.x + 3*ACS.y), printer='presentation') == \ '<mrow><mo>&#x2206;</mo><mfenced><mrow><msub><mi mathvariant="bold">'\ 'x</mi><mi mathvariant="bold">A</mi></msub><mo>+</mo><mrow><mn>3</mn>'\ '<mo>&InvisibleTimes;</mo><msub><mi mathvariant="bold">y</mi>'\ '<mi mathvariant="bold">A</mi></msub></mrow></mrow></mfenced></mrow>' assert mathml(x*Laplacian(ACS.x), printer='presentation') == \ '<mrow><mi>x</mi><mo>&InvisibleTimes;</mo><mrow><mo>&#x2206;</mo>'\ '<msub><mi mathvariant="bold">x</mi><mi mathvariant="bold">A</mi>'\ '</msub></mrow></mrow>' assert mathml(Laplacian(x*ACS.x), printer='presentation') == \ '<mrow><mo>&#x2206;</mo><mfenced><mrow><msub><mi mathvariant="bold">'\ 'x</mi><mi mathvariant="bold">A</mi></msub><mo>&InvisibleTimes;</mo>'\ '<mi>x</mi></mrow></mfenced></mrow>' def test_print_elliptic_f(): assert mathml(elliptic_f(x, y), printer = 'presentation') == \ '<mrow><mi>&#x1d5a5;</mi><mfenced separators="|"><mi>x</mi><mi>y</mi></mfenced></mrow>' assert mathml(elliptic_f(x/y, y), printer = 'presentation') == \ '<mrow><mi>&#x1d5a5;</mi><mfenced separators="|"><mrow><mfrac><mi>x</mi><mi>y</mi></mfrac></mrow><mi>y</mi></mfenced></mrow>' def test_print_elliptic_e(): assert mathml(elliptic_e(x), printer = 'presentation') == \ '<mrow><mi>&#x1d5a4;</mi><mfenced separators="|"><mi>x</mi></mfenced></mrow>' assert mathml(elliptic_e(x, y), printer = 'presentation') == \ '<mrow><mi>&#x1d5a4;</mi><mfenced separators="|"><mi>x</mi><mi>y</mi></mfenced></mrow>' def test_print_elliptic_pi(): assert mathml(elliptic_pi(x, y), printer = 'presentation') == \ '<mrow><mi>&#x1d6f1;</mi><mfenced separators="|"><mi>x</mi><mi>y</mi></mfenced></mrow>' assert mathml(elliptic_pi(x, y, z), printer = 'presentation') == \ '<mrow><mi>&#x1d6f1;</mi><mfenced separators=";|"><mi>x</mi><mi>y</mi><mi>z</mi></mfenced></mrow>' def test_print_Ei(): assert mathml(Ei(x), printer = 'presentation') == \ '<mrow><mi>Ei</mi><mfenced><mi>x</mi></mfenced></mrow>' assert mathml(Ei(x**y), printer = 'presentation') == \ '<mrow><mi>Ei</mi><mfenced><msup><mi>x</mi><mi>y</mi></msup></mfenced></mrow>' def test_print_expint(): assert mathml(expint(x, y), printer = 'presentation') == \ '<mrow><msub><mo>E</mo><mi>x</mi></msub><mfenced><mi>y</mi></mfenced></mrow>' assert mathml(expint(IndexedBase(x)[1], IndexedBase(x)[2]), printer = 'presentation') == \ '<mrow><msub><mo>E</mo><msub><mi>x</mi><mn>1</mn></msub></msub><mfenced><msub><mi>x</mi><mn>2</mn></msub></mfenced></mrow>' def test_print_jacobi(): assert mathml(jacobi(n, a, b, x), printer = 'presentation') == \ '<mrow><msubsup><mo>P</mo><mi>n</mi><mfenced><mi>a</mi><mi>b</mi></mfenced></msubsup><mfenced><mi>x</mi></mfenced></mrow>' def test_print_gegenbauer(): assert mathml(gegenbauer(n, a, x), printer = 'presentation') == \ '<mrow><msubsup><mo>C</mo><mi>n</mi><mfenced><mi>a</mi></mfenced></msubsup><mfenced><mi>x</mi></mfenced></mrow>' def test_print_chebyshevt(): assert mathml(chebyshevt(n, x), printer = 'presentation') == \ '<mrow><msub><mo>T</mo><mi>n</mi></msub><mfenced><mi>x</mi></mfenced></mrow>' def test_print_chebyshevu(): assert mathml(chebyshevu(n, x), printer = 'presentation') == \ '<mrow><msub><mo>U</mo><mi>n</mi></msub><mfenced><mi>x</mi></mfenced></mrow>' def test_print_legendre(): assert mathml(legendre(n, x), printer = 'presentation') == \ '<mrow><msub><mo>P</mo><mi>n</mi></msub><mfenced><mi>x</mi></mfenced></mrow>' def test_print_assoc_legendre(): assert mathml(assoc_legendre(n, a, x), printer = 'presentation') == \ '<mrow><msubsup><mo>P</mo><mi>n</mi><mfenced><mi>a</mi></mfenced></msubsup><mfenced><mi>x</mi></mfenced></mrow>' def test_print_laguerre(): assert mathml(laguerre(n, x), printer = 'presentation') == \ '<mrow><msub><mo>L</mo><mi>n</mi></msub><mfenced><mi>x</mi></mfenced></mrow>' def test_print_assoc_laguerre(): assert mathml(assoc_laguerre(n, a, x), printer = 'presentation') == \ '<mrow><msubsup><mo>L</mo><mi>n</mi><mfenced><mi>a</mi></mfenced></msubsup><mfenced><mi>x</mi></mfenced></mrow>' def test_print_hermite(): assert mathml(hermite(n, x), printer = 'presentation') == \ '<mrow><msub><mo>H</mo><mi>n</mi></msub><mfenced><mi>x</mi></mfenced></mrow>' def test_mathml_SingularityFunction(): assert mathml(SingularityFunction(x, 4, 5), printer='presentation') == \ '<msup><mfenced close="&#10217;" open="&#10216;"><mrow><mi>x</mi>' \ '<mo>-</mo><mn>4</mn></mrow></mfenced><mn>5</mn></msup>' assert mathml(SingularityFunction(x, -3, 4), printer='presentation') == \ '<msup><mfenced close="&#10217;" open="&#10216;"><mrow><mi>x</mi>' \ '<mo>+</mo><mn>3</mn></mrow></mfenced><mn>4</mn></msup>' assert mathml(SingularityFunction(x, 0, 4), printer='presentation') == \ '<msup><mfenced close="&#10217;" open="&#10216;"><mi>x</mi></mfenced>' \ '<mn>4</mn></msup>' assert mathml(SingularityFunction(x, a, n), printer='presentation') == \ '<msup><mfenced close="&#10217;" open="&#10216;"><mrow><mrow>' \ '<mo>-</mo><mi>a</mi></mrow><mo>+</mo><mi>x</mi></mrow></mfenced>' \ '<mi>n</mi></msup>' assert mathml(SingularityFunction(x, 4, -2), printer='presentation') == \ '<msup><mfenced close="&#10217;" open="&#10216;"><mrow><mi>x</mi>' \ '<mo>-</mo><mn>4</mn></mrow></mfenced><mn>-2</mn></msup>' assert mathml(SingularityFunction(x, 4, -1), printer='presentation') == \ '<msup><mfenced close="&#10217;" open="&#10216;"><mrow><mi>x</mi>' \ '<mo>-</mo><mn>4</mn></mrow></mfenced><mn>-1</mn></msup>' def test_mathml_matrix_functions(): from sympy.matrices import MatrixSymbol, Adjoint, Inverse, Transpose X = MatrixSymbol('X', 2, 2) Y = MatrixSymbol('Y', 2, 2) assert mathml(Adjoint(X), printer='presentation') == \ '<msup><mi>X</mi><mo>&#x2020;</mo></msup>' assert mathml(Adjoint(X + Y), printer='presentation') == \ '<msup><mfenced><mrow><mi>X</mi><mo>+</mo><mi>Y</mi></mrow></mfenced><mo>&#x2020;</mo></msup>' assert mathml(Adjoint(X) + Adjoint(Y), printer='presentation') == \ '<mrow><msup><mi>X</mi><mo>&#x2020;</mo></msup><mo>+</mo><msup>' \ '<mi>Y</mi><mo>&#x2020;</mo></msup></mrow>' assert mathml(Adjoint(X*Y), printer='presentation') == \ '<msup><mfenced><mrow><mi>X</mi><mo>&InvisibleTimes;</mo>' \ '<mi>Y</mi></mrow></mfenced><mo>&#x2020;</mo></msup>' assert mathml(Adjoint(Y)*Adjoint(X), printer='presentation') == \ '<mrow><msup><mi>Y</mi><mo>&#x2020;</mo></msup><mo>&InvisibleTimes;' \ '</mo><msup><mi>X</mi><mo>&#x2020;</mo></msup></mrow>' assert mathml(Adjoint(X**2), printer='presentation') == \ '<msup><mfenced><msup><mi>X</mi><mn>2</mn></msup></mfenced><mo>&#x2020;</mo></msup>' assert mathml(Adjoint(X)**2, printer='presentation') == \ '<msup><mfenced><msup><mi>X</mi><mo>&#x2020;</mo></msup></mfenced><mn>2</mn></msup>' assert mathml(Adjoint(Inverse(X)), printer='presentation') == \ '<msup><mfenced><msup><mi>X</mi><mn>-1</mn></msup></mfenced><mo>&#x2020;</mo></msup>' assert mathml(Inverse(Adjoint(X)), printer='presentation') == \ '<msup><mfenced><msup><mi>X</mi><mo>&#x2020;</mo></msup></mfenced><mn>-1</mn></msup>' assert mathml(Adjoint(Transpose(X)), printer='presentation') == \ '<msup><mfenced><msup><mi>X</mi><mo>T</mo></msup></mfenced><mo>&#x2020;</mo></msup>' assert mathml(Transpose(Adjoint(X)), printer='presentation') == \ '<msup><mfenced><msup><mi>X</mi><mo>&#x2020;</mo></msup></mfenced><mo>T</mo></msup>' assert mathml(Transpose(Adjoint(X) + Y), printer='presentation') == \ '<msup><mfenced><mrow><msup><mi>X</mi><mo>&#x2020;</mo></msup>' \ '<mo>+</mo><mi>Y</mi></mrow></mfenced><mo>T</mo></msup>' assert mathml(Transpose(X), printer='presentation') == \ '<msup><mi>X</mi><mo>T</mo></msup>' assert mathml(Transpose(X + Y), printer='presentation') == \ '<msup><mfenced><mrow><mi>X</mi><mo>+</mo><mi>Y</mi></mrow></mfenced><mo>T</mo></msup>' def test_mathml_special_matrices(): from sympy.matrices import Identity, ZeroMatrix assert mathml(Identity(4), printer='presentation') == '<mi>&#x1D540;</mi>' assert mathml(ZeroMatrix(2, 2), printer='presentation') == '<mn>&#x1D7D8</mn>'
79af259b5388f5efb7ea138ac2f6589d8cd4a676db9ef75a20b9a0a5d24359c9
from sympy.core import (S, pi, oo, symbols, Function, Rational, Integer, Tuple, Symbol) from sympy.core import EulerGamma, GoldenRatio, Catalan, Lambda, Mul, Pow from sympy.functions import (arg, atan2, bernoulli, beta, ceiling, chebyshevu, chebyshevt, conjugate, DiracDelta, exp, expint, factorial, floor, harmonic, Heaviside, im, laguerre, LambertW, log, Max, Min, Piecewise, polylog, re, RisingFactorial, sign, sinc, sqrt, zeta) from sympy.functions import (sin, cos, tan, cot, sec, csc, asin, acos, acot, atan, asec, acsc, sinh, cosh, tanh, coth, csch, sech, asinh, acosh, atanh, acoth, asech, acsch) from sympy.utilities.pytest import raises from sympy.utilities.lambdify import implemented_function from sympy.matrices import (eye, Matrix, MatrixSymbol, Identity, HadamardProduct, SparseMatrix) from sympy.functions.special.bessel import (jn, yn, besselj, bessely, besseli, besselk, hankel1, hankel2, airyai, airybi, airyaiprime, airybiprime) from sympy.functions.special.gamma_functions import (gamma, lowergamma, uppergamma, loggamma, polygamma) from sympy.functions.special.error_functions import (Chi, Ci, erf, erfc, erfi, erfcinv, erfinv, fresnelc, fresnels, li, Shi, Si) from sympy.utilities.pytest import XFAIL from sympy.core.compatibility import range from sympy import octave_code from sympy import octave_code as mcode x, y, z = symbols('x,y,z') def test_Integer(): assert mcode(Integer(67)) == "67" assert mcode(Integer(-1)) == "-1" def test_Rational(): assert mcode(Rational(3, 7)) == "3/7" assert mcode(Rational(18, 9)) == "2" assert mcode(Rational(3, -7)) == "-3/7" assert mcode(Rational(-3, -7)) == "3/7" assert mcode(x + Rational(3, 7)) == "x + 3/7" assert mcode(Rational(3, 7)*x) == "3*x/7" def test_Function(): assert mcode(sin(x) ** cos(x)) == "sin(x).^cos(x)" assert mcode(sign(x)) == "sign(x)" assert mcode(exp(x)) == "exp(x)" assert mcode(log(x)) == "log(x)" assert mcode(factorial(x)) == "factorial(x)" assert mcode(floor(x)) == "floor(x)" assert mcode(atan2(y, x)) == "atan2(y, x)" assert mcode(beta(x, y)) == 'beta(x, y)' assert mcode(polylog(x, y)) == 'polylog(x, y)' assert mcode(harmonic(x)) == 'harmonic(x)' assert mcode(bernoulli(x)) == "bernoulli(x)" assert mcode(bernoulli(x, y)) == "bernoulli(x, y)" def test_Function_change_name(): assert mcode(abs(x)) == "abs(x)" assert mcode(ceiling(x)) == "ceil(x)" assert mcode(arg(x)) == "angle(x)" assert mcode(im(x)) == "imag(x)" assert mcode(re(x)) == "real(x)" assert mcode(conjugate(x)) == "conj(x)" assert mcode(chebyshevt(y, x)) == "chebyshevT(y, x)" assert mcode(chebyshevu(y, x)) == "chebyshevU(y, x)" assert mcode(laguerre(x, y)) == "laguerreL(x, y)" assert mcode(Chi(x)) == "coshint(x)" assert mcode(Shi(x)) == "sinhint(x)" assert mcode(Ci(x)) == "cosint(x)" assert mcode(Si(x)) == "sinint(x)" assert mcode(li(x)) == "logint(x)" assert mcode(loggamma(x)) == "gammaln(x)" assert mcode(polygamma(x, y)) == "psi(x, y)" assert mcode(RisingFactorial(x, y)) == "pochhammer(x, y)" assert mcode(DiracDelta(x)) == "dirac(x)" assert mcode(DiracDelta(x, 3)) == "dirac(3, x)" assert mcode(Heaviside(x)) == "heaviside(x)" assert mcode(Heaviside(x, y)) == "heaviside(x, y)" def test_minmax(): assert mcode(Max(x, y) + Min(x, y)) == "max(x, y) + min(x, y)" assert mcode(Max(x, y, z)) == "max(x, max(y, z))" assert mcode(Min(x, y, z)) == "min(x, min(y, z))" def test_Pow(): assert mcode(x**3) == "x.^3" assert mcode(x**(y**3)) == "x.^(y.^3)" assert mcode(x**Rational(2, 3)) == 'x.^(2/3)' g = implemented_function('g', Lambda(x, 2*x)) assert mcode(1/(g(x)*3.5)**(x - y**x)/(x**2 + y)) == \ "(3.5*2*x).^(-x + y.^x)./(x.^2 + y)" # For issue 14160 assert mcode(Mul(-2, x, Pow(Mul(y,y,evaluate=False), -1, evaluate=False), evaluate=False)) == '-2*x./(y.*y)' def test_basic_ops(): assert mcode(x*y) == "x.*y" assert mcode(x + y) == "x + y" assert mcode(x - y) == "x - y" assert mcode(-x) == "-x" def test_1_over_x_and_sqrt(): # 1.0 and 0.5 would do something different in regular StrPrinter, # but these are exact in IEEE floating point so no different here. assert mcode(1/x) == '1./x' assert mcode(x**-1) == mcode(x**-1.0) == '1./x' assert mcode(1/sqrt(x)) == '1./sqrt(x)' assert mcode(x**-S.Half) == mcode(x**-0.5) == '1./sqrt(x)' assert mcode(sqrt(x)) == 'sqrt(x)' assert mcode(x**S.Half) == mcode(x**0.5) == 'sqrt(x)' assert mcode(1/pi) == '1/pi' assert mcode(pi**-1) == mcode(pi**-1.0) == '1/pi' assert mcode(pi**-0.5) == '1/sqrt(pi)' def test_mix_number_mult_symbols(): assert mcode(3*x) == "3*x" assert mcode(pi*x) == "pi*x" assert mcode(3/x) == "3./x" assert mcode(pi/x) == "pi./x" assert mcode(x/3) == "x/3" assert mcode(x/pi) == "x/pi" assert mcode(x*y) == "x.*y" assert mcode(3*x*y) == "3*x.*y" assert mcode(3*pi*x*y) == "3*pi*x.*y" assert mcode(x/y) == "x./y" assert mcode(3*x/y) == "3*x./y" assert mcode(x*y/z) == "x.*y./z" assert mcode(x/y*z) == "x.*z./y" assert mcode(1/x/y) == "1./(x.*y)" assert mcode(2*pi*x/y/z) == "2*pi*x./(y.*z)" assert mcode(3*pi/x) == "3*pi./x" assert mcode(S(3)/5) == "3/5" assert mcode(S(3)/5*x) == "3*x/5" assert mcode(x/y/z) == "x./(y.*z)" assert mcode((x+y)/z) == "(x + y)./z" assert mcode((x+y)/(z+x)) == "(x + y)./(x + z)" assert mcode((x+y)/EulerGamma) == "(x + y)/%s" % EulerGamma.evalf(17) assert mcode(x/3/pi) == "x/(3*pi)" assert mcode(S(3)/5*x*y/pi) == "3*x.*y/(5*pi)" def test_mix_number_pow_symbols(): assert mcode(pi**3) == 'pi^3' assert mcode(x**2) == 'x.^2' assert mcode(x**(pi**3)) == 'x.^(pi^3)' assert mcode(x**y) == 'x.^y' assert mcode(x**(y**z)) == 'x.^(y.^z)' assert mcode((x**y)**z) == '(x.^y).^z' def test_imag(): I = S('I') assert mcode(I) == "1i" assert mcode(5*I) == "5i" assert mcode((S(3)/2)*I) == "3*1i/2" assert mcode(3+4*I) == "3 + 4i" assert mcode(sqrt(3)*I) == "sqrt(3)*1i" def test_constants(): assert mcode(pi) == "pi" assert mcode(oo) == "inf" assert mcode(-oo) == "-inf" assert mcode(S.NegativeInfinity) == "-inf" assert mcode(S.NaN) == "NaN" assert mcode(S.Exp1) == "exp(1)" assert mcode(exp(1)) == "exp(1)" def test_constants_other(): assert mcode(2*GoldenRatio) == "2*(1+sqrt(5))/2" assert mcode(2*Catalan) == "2*%s" % Catalan.evalf(17) assert mcode(2*EulerGamma) == "2*%s" % EulerGamma.evalf(17) def test_boolean(): assert mcode(x & y) == "x & y" assert mcode(x | y) == "x | y" assert mcode(~x) == "~x" assert mcode(x & y & z) == "x & y & z" assert mcode(x | y | z) == "x | y | z" assert mcode((x & y) | z) == "z | x & y" assert mcode((x | y) & z) == "z & (x | y)" def test_KroneckerDelta(): from sympy.functions import KroneckerDelta assert mcode(KroneckerDelta(x, y)) == "double(x == y)" assert mcode(KroneckerDelta(x, y + 1)) == "double(x == (y + 1))" assert mcode(KroneckerDelta(2**x, y)) == "double((2.^x) == y)" def test_Matrices(): assert mcode(Matrix(1, 1, [10])) == "10" A = Matrix([[1, sin(x/2), abs(x)], [0, 1, pi], [0, exp(1), ceiling(x)]]); expected = "[1 sin(x/2) abs(x); 0 1 pi; 0 exp(1) ceil(x)]" assert mcode(A) == expected # row and columns assert mcode(A[:,0]) == "[1; 0; 0]" assert mcode(A[0,:]) == "[1 sin(x/2) abs(x)]" # empty matrices assert mcode(Matrix(0, 0, [])) == '[]' assert mcode(Matrix(0, 3, [])) == 'zeros(0, 3)' # annoying to read but correct assert mcode(Matrix([[x, x - y, -y]])) == "[x x - y -y]" def test_vector_entries_hadamard(): # For a row or column, user might to use the other dimension A = Matrix([[1, sin(2/x), 3*pi/x/5]]) assert mcode(A) == "[1 sin(2./x) 3*pi./(5*x)]" assert mcode(A.T) == "[1; sin(2./x); 3*pi./(5*x)]" @XFAIL def test_Matrices_entries_not_hadamard(): # For Matrix with col >= 2, row >= 2, they need to be scalars # FIXME: is it worth worrying about this? Its not wrong, just # leave it user's responsibility to put scalar data for x. A = Matrix([[1, sin(2/x), 3*pi/x/5], [1, 2, x*y]]) expected = ("[1 sin(2/x) 3*pi/(5*x);\n" "1 2 x*y]") # <- we give x.*y assert mcode(A) == expected def test_MatrixSymbol(): n = Symbol('n', integer=True) A = MatrixSymbol('A', n, n) B = MatrixSymbol('B', n, n) assert mcode(A*B) == "A*B" assert mcode(B*A) == "B*A" assert mcode(2*A*B) == "2*A*B" assert mcode(B*2*A) == "2*B*A" assert mcode(A*(B + 3*Identity(n))) == "A*(3*eye(n) + B)" assert mcode(A**(x**2)) == "A^(x.^2)" assert mcode(A**3) == "A^3" assert mcode(A**(S.Half)) == "A^(1/2)" def test_special_matrices(): assert mcode(6*Identity(3)) == "6*eye(3)" def test_containers(): assert mcode([1, 2, 3, [4, 5, [6, 7]], 8, [9, 10], 11]) == \ "{1, 2, 3, {4, 5, {6, 7}}, 8, {9, 10}, 11}" assert mcode((1, 2, (3, 4))) == "{1, 2, {3, 4}}" assert mcode([1]) == "{1}" assert mcode((1,)) == "{1}" assert mcode(Tuple(*[1, 2, 3])) == "{1, 2, 3}" assert mcode((1, x*y, (3, x**2))) == "{1, x.*y, {3, x.^2}}" # scalar, matrix, empty matrix and empty list assert mcode((1, eye(3), Matrix(0, 0, []), [])) == "{1, [1 0 0; 0 1 0; 0 0 1], [], {}}" def test_octave_noninline(): source = mcode((x+y)/Catalan, assign_to='me', inline=False) expected = ( "Catalan = %s;\n" "me = (x + y)/Catalan;" ) % Catalan.evalf(17) assert source == expected def test_octave_piecewise(): expr = Piecewise((x, x < 1), (x**2, True)) assert mcode(expr) == "((x < 1).*(x) + (~(x < 1)).*(x.^2))" assert mcode(expr, assign_to="r") == ( "r = ((x < 1).*(x) + (~(x < 1)).*(x.^2));") assert mcode(expr, assign_to="r", inline=False) == ( "if (x < 1)\n" " r = x;\n" "else\n" " r = x.^2;\n" "end") expr = Piecewise((x**2, x < 1), (x**3, x < 2), (x**4, x < 3), (x**5, True)) expected = ("((x < 1).*(x.^2) + (~(x < 1)).*( ...\n" "(x < 2).*(x.^3) + (~(x < 2)).*( ...\n" "(x < 3).*(x.^4) + (~(x < 3)).*(x.^5))))") assert mcode(expr) == expected assert mcode(expr, assign_to="r") == "r = " + expected + ";" assert mcode(expr, assign_to="r", inline=False) == ( "if (x < 1)\n" " r = x.^2;\n" "elseif (x < 2)\n" " r = x.^3;\n" "elseif (x < 3)\n" " r = x.^4;\n" "else\n" " r = x.^5;\n" "end") # Check that Piecewise without a True (default) condition error expr = Piecewise((x, x < 1), (x**2, x > 1), (sin(x), x > 0)) raises(ValueError, lambda: mcode(expr)) def test_octave_piecewise_times_const(): pw = Piecewise((x, x < 1), (x**2, True)) assert mcode(2*pw) == "2*((x < 1).*(x) + (~(x < 1)).*(x.^2))" assert mcode(pw/x) == "((x < 1).*(x) + (~(x < 1)).*(x.^2))./x" assert mcode(pw/(x*y)) == "((x < 1).*(x) + (~(x < 1)).*(x.^2))./(x.*y)" assert mcode(pw/3) == "((x < 1).*(x) + (~(x < 1)).*(x.^2))/3" def test_octave_matrix_assign_to(): A = Matrix([[1, 2, 3]]) assert mcode(A, assign_to='a') == "a = [1 2 3];" A = Matrix([[1, 2], [3, 4]]) assert mcode(A, assign_to='A') == "A = [1 2; 3 4];" def test_octave_matrix_assign_to_more(): # assigning to Symbol or MatrixSymbol requires lhs/rhs match A = Matrix([[1, 2, 3]]) B = MatrixSymbol('B', 1, 3) C = MatrixSymbol('C', 2, 3) assert mcode(A, assign_to=B) == "B = [1 2 3];" raises(ValueError, lambda: mcode(A, assign_to=x)) raises(ValueError, lambda: mcode(A, assign_to=C)) def test_octave_matrix_1x1(): A = Matrix([[3]]) B = MatrixSymbol('B', 1, 1) C = MatrixSymbol('C', 1, 2) assert mcode(A, assign_to=B) == "B = 3;" # FIXME? #assert mcode(A, assign_to=x) == "x = 3;" raises(ValueError, lambda: mcode(A, assign_to=C)) def test_octave_matrix_elements(): A = Matrix([[x, 2, x*y]]) assert mcode(A[0, 0]**2 + A[0, 1] + A[0, 2]) == "x.^2 + x.*y + 2" A = MatrixSymbol('AA', 1, 3) assert mcode(A) == "AA" assert mcode(A[0, 0]**2 + sin(A[0,1]) + A[0,2]) == \ "sin(AA(1, 2)) + AA(1, 1).^2 + AA(1, 3)" assert mcode(sum(A)) == "AA(1, 1) + AA(1, 2) + AA(1, 3)" def test_octave_boolean(): assert mcode(True) == "true" assert mcode(S.true) == "true" assert mcode(False) == "false" assert mcode(S.false) == "false" def test_octave_not_supported(): assert mcode(S.ComplexInfinity) == ( "% Not supported in Octave:\n" "% ComplexInfinity\n" "zoo" ) f = Function('f') assert mcode(f(x).diff(x)) == ( "% Not supported in Octave:\n" "% Derivative\n" "Derivative(f(x), x)" ) def test_octave_not_supported_not_on_whitelist(): from sympy import assoc_laguerre assert mcode(assoc_laguerre(x, y, z)) == ( "% Not supported in Octave:\n" "% assoc_laguerre\n" "assoc_laguerre(x, y, z)" ) def test_octave_expint(): assert mcode(expint(1, x)) == "expint(x)" assert mcode(expint(2, x)) == ( "% Not supported in Octave:\n" "% expint\n" "expint(2, x)" ) assert mcode(expint(y, x)) == ( "% Not supported in Octave:\n" "% expint\n" "expint(y, x)" ) def test_trick_indent_with_end_else_words(): # words starting with "end" or "else" do not confuse the indenter t1 = S('endless'); t2 = S('elsewhere'); pw = Piecewise((t1, x < 0), (t2, x <= 1), (1, True)) assert mcode(pw, inline=False) == ( "if (x < 0)\n" " endless\n" "elseif (x <= 1)\n" " elsewhere\n" "else\n" " 1\n" "end") def test_haramard(): A = MatrixSymbol('A', 3, 3) B = MatrixSymbol('B', 3, 3) v = MatrixSymbol('v', 3, 1) h = MatrixSymbol('h', 1, 3) C = HadamardProduct(A, B) assert mcode(C) == "A.*B" assert mcode(C*v) == "(A.*B)*v" assert mcode(h*C*v) == "h*(A.*B)*v" assert mcode(C*A) == "(A.*B)*A" # mixing Hadamard and scalar strange b/c we vectorize scalars assert mcode(C*x*y) == "(x.*y)*(A.*B)" def test_sparse(): M = SparseMatrix(5, 6, {}) M[2, 2] = 10; M[1, 2] = 20; M[1, 3] = 22; M[0, 3] = 30; M[3, 0] = x*y; assert mcode(M) == ( "sparse([4 2 3 1 2], [1 3 3 4 4], [x.*y 20 10 30 22], 5, 6)" ) def test_sinc(): assert mcode(sinc(x)) == 'sinc(x/pi)' assert mcode(sinc((x + 3))) == 'sinc((x + 3)/pi)' assert mcode(sinc(pi*(x + 3))) == 'sinc(x + 3)' def test_trigfun(): for f in (sin, cos, tan, cot, sec, csc, asin, acos, acot, atan, asec, acsc, sinh, cosh, tanh, coth, csch, sech, asinh, acosh, atanh, acoth, asech, acsch): assert octave_code(f(x) == f.__name__ + '(x)') def test_specfun(): n = Symbol('n') for f in [besselj, bessely, besseli, besselk]: assert octave_code(f(n, x)) == f.__name__ + '(n, x)' for f in (erfc, erfi, erf, erfinv, erfcinv, fresnelc, fresnels, gamma): assert octave_code(f(x)) == f.__name__ + '(x)' assert octave_code(hankel1(n, x)) == 'besselh(n, 1, x)' assert octave_code(hankel2(n, x)) == 'besselh(n, 2, x)' assert octave_code(airyai(x)) == 'airy(0, x)' assert octave_code(airyaiprime(x)) == 'airy(1, x)' assert octave_code(airybi(x)) == 'airy(2, x)' assert octave_code(airybiprime(x)) == 'airy(3, x)' assert octave_code(uppergamma(n, x)) == '(gammainc(x, n, \'upper\').*gamma(n))' assert octave_code(lowergamma(n, x)) == '(gammainc(x, n).*gamma(n))' assert octave_code(z**lowergamma(n, x)) == 'z.^(gammainc(x, n).*gamma(n))' assert octave_code(jn(n, x)) == 'sqrt(2)*sqrt(pi)*sqrt(1./x).*besselj(n + 1/2, x)/2' assert octave_code(yn(n, x)) == 'sqrt(2)*sqrt(pi)*sqrt(1./x).*bessely(n + 1/2, x)/2' assert octave_code(LambertW(x)) == 'lambertw(x)' assert octave_code(LambertW(x, n)) == 'lambertw(n, x)' def test_MatrixElement_printing(): # test cases for issue #11821 A = MatrixSymbol("A", 1, 3) B = MatrixSymbol("B", 1, 3) C = MatrixSymbol("C", 1, 3) assert mcode(A[0, 0]) == "A(1, 1)" assert mcode(3 * A[0, 0]) == "3*A(1, 1)" F = C[0, 0].subs(C, A - B) assert mcode(F) == "(A - B)(1, 1)" def test_zeta_printing_issue_14820(): assert octave_code(zeta(x)) == 'zeta(x)' assert octave_code(zeta(x, y)) == '% Not supported in Octave:\n% zeta\nzeta(x, y)'
07b6ccdd54ed5e77d0f1134b85d7e81974514cab07c4accb1c19ca21932649f7
# -*- coding: utf-8 -*- from sympy import ( Add, And, Basic, Derivative, Dict, Eq, Equivalent, FF, FiniteSet, Function, Ge, Gt, I, Implies, Integral, SingularityFunction, Lambda, Le, Limit, Lt, Matrix, Mul, Nand, Ne, Nor, Not, O, Or, Pow, Product, QQ, RR, Rational, Ray, rootof, RootSum, S, Segment, Subs, Sum, Symbol, Tuple, Trace, Xor, ZZ, conjugate, groebner, oo, pi, symbols, ilex, grlex, Range, Contains, SeqPer, SeqFormula, SeqAdd, SeqMul, fourier_series, fps, ITE, Complement, Interval, Intersection, Union, EulerGamma, GoldenRatio) from sympy.codegen.ast import (Assignment, AddAugmentedAssignment, SubAugmentedAssignment, MulAugmentedAssignment, DivAugmentedAssignment, ModAugmentedAssignment) from sympy.core.compatibility import range, u_decode as u, PY3 from sympy.core.expr import UnevaluatedExpr from sympy.core.trace import Tr from sympy.functions import (Abs, Chi, Ci, Ei, KroneckerDelta, Piecewise, Shi, Si, atan2, beta, binomial, catalan, ceiling, cos, euler, exp, expint, factorial, factorial2, floor, gamma, hyper, log, meijerg, sin, sqrt, subfactorial, tan, uppergamma, lerchphi, elliptic_k, elliptic_f, elliptic_e, elliptic_pi, DiracDelta, bell, bernoulli, fibonacci, tribonacci, lucas) from sympy.matrices import Adjoint, Inverse, MatrixSymbol, Transpose, KroneckerProduct from sympy.physics import mechanics from sympy.physics.units import joule, degree from sympy.printing.pretty import pprint, pretty as xpretty from sympy.printing.pretty.pretty_symbology import center_accent from sympy.sets import ImageSet from sympy.sets.setexpr import SetExpr from sympy.tensor.array import (ImmutableDenseNDimArray, ImmutableSparseNDimArray, MutableDenseNDimArray, MutableSparseNDimArray, tensorproduct) from sympy.tensor.functions import TensorProduct from sympy.tensor.tensor import (TensorIndexType, tensor_indices, tensorhead, TensorElement) from sympy.utilities.pytest import raises, XFAIL from sympy.vector import CoordSys3D, Gradient, Curl, Divergence, Dot, Cross, Laplacian import sympy as sym class lowergamma(sym.lowergamma): pass # testing notation inheritance by a subclass with same name a, b, c, d, x, y, z, k, n = symbols('a,b,c,d,x,y,z,k,n') f = Function("f") th = Symbol('theta') ph = Symbol('phi') """ Expressions whose pretty-printing is tested here: (A '#' to the right of an expression indicates that its various acceptable orderings are accounted for by the tests.) BASIC EXPRESSIONS: oo (x**2) 1/x y*x**-2 x**Rational(-5,2) (-2)**x Pow(3, 1, evaluate=False) (x**2 + x + 1) # 1-x # 1-2*x # x/y -x/y (x+2)/y # (1+x)*y #3 -5*x/(x+10) # correct placement of negative sign 1 - Rational(3,2)*(x+1) -(-x + 5)*(-x - 2*sqrt(2) + 5) - (-y + 5)*(-y + 5) # issue 5524 ORDERING: x**2 + x + 1 1 - x 1 - 2*x 2*x**4 + y**2 - x**2 + y**3 RELATIONAL: Eq(x, y) Lt(x, y) Gt(x, y) Le(x, y) Ge(x, y) Ne(x/(y+1), y**2) # RATIONAL NUMBERS: y*x**-2 y**Rational(3,2) * x**Rational(-5,2) sin(x)**3/tan(x)**2 FUNCTIONS (ABS, CONJ, EXP, FUNCTION BRACES, FACTORIAL, FLOOR, CEILING): (2*x + exp(x)) # Abs(x) Abs(x/(x**2+1)) # Abs(1 / (y - Abs(x))) factorial(n) factorial(2*n) subfactorial(n) subfactorial(2*n) factorial(factorial(factorial(n))) factorial(n+1) # conjugate(x) conjugate(f(x+1)) # f(x) f(x, y) f(x/(y+1), y) # f(x**x**x**x**x**x) sin(x)**2 conjugate(a+b*I) conjugate(exp(a+b*I)) conjugate( f(1 + conjugate(f(x))) ) # f(x/(y+1), y) # denom of first arg floor(1 / (y - floor(x))) ceiling(1 / (y - ceiling(x))) SQRT: sqrt(2) 2**Rational(1,3) 2**Rational(1,1000) sqrt(x**2 + 1) (1 + sqrt(5))**Rational(1,3) 2**(1/x) sqrt(2+pi) (2+(1+x**2)/(2+x))**Rational(1,4)+(1+x**Rational(1,1000))/sqrt(3+x**2) DERIVATIVES: Derivative(log(x), x, evaluate=False) Derivative(log(x), x, evaluate=False) + x # Derivative(log(x) + x**2, x, y, evaluate=False) Derivative(2*x*y, y, x, evaluate=False) + x**2 # beta(alpha).diff(alpha) INTEGRALS: Integral(log(x), x) Integral(x**2, x) Integral((sin(x))**2 / (tan(x))**2) Integral(x**(2**x), x) Integral(x**2, (x,1,2)) Integral(x**2, (x,Rational(1,2),10)) Integral(x**2*y**2, x,y) Integral(x**2, (x, None, 1)) Integral(x**2, (x, 1, None)) Integral(sin(th)/cos(ph), (th,0,pi), (ph, 0, 2*pi)) MATRICES: Matrix([[x**2+1, 1], [y, x+y]]) # Matrix([[x/y, y, th], [0, exp(I*k*ph), 1]]) PIECEWISE: Piecewise((x,x<1),(x**2,True)) ITE: ITE(x, y, z) SEQUENCES (TUPLES, LISTS, DICTIONARIES): () [] {} (1/x,) [x**2, 1/x, x, y, sin(th)**2/cos(ph)**2] (x**2, 1/x, x, y, sin(th)**2/cos(ph)**2) {x: sin(x)} {1/x: 1/y, x: sin(x)**2} # [x**2] (x**2,) {x**2: 1} LIMITS: Limit(x, x, oo) Limit(x**2, x, 0) Limit(1/x, x, 0) Limit(sin(x)/x, x, 0) UNITS: joule => kg*m**2/s SUBS: Subs(f(x), x, ph**2) Subs(f(x).diff(x), x, 0) Subs(f(x).diff(x)/y, (x, y), (0, Rational(1, 2))) ORDER: O(1) O(1/x) O(x**2 + y**2) """ def pretty(expr, order=None): """ASCII pretty-printing""" return xpretty(expr, order=order, use_unicode=False, wrap_line=False) def upretty(expr, order=None): """Unicode pretty-printing""" return xpretty(expr, order=order, use_unicode=True, wrap_line=False) def test_pretty_ascii_str(): assert pretty( 'xxx' ) == 'xxx' assert pretty( "xxx" ) == 'xxx' assert pretty( 'xxx\'xxx' ) == 'xxx\'xxx' assert pretty( 'xxx"xxx' ) == 'xxx\"xxx' assert pretty( 'xxx\"xxx' ) == 'xxx\"xxx' assert pretty( "xxx'xxx" ) == 'xxx\'xxx' assert pretty( "xxx\'xxx" ) == 'xxx\'xxx' assert pretty( "xxx\"xxx" ) == 'xxx\"xxx' assert pretty( "xxx\"xxx\'xxx" ) == 'xxx"xxx\'xxx' assert pretty( "xxx\nxxx" ) == 'xxx\nxxx' def test_pretty_unicode_str(): assert pretty( u'xxx' ) == u'xxx' assert pretty( u'xxx' ) == u'xxx' assert pretty( u'xxx\'xxx' ) == u'xxx\'xxx' assert pretty( u'xxx"xxx' ) == u'xxx\"xxx' assert pretty( u'xxx\"xxx' ) == u'xxx\"xxx' assert pretty( u"xxx'xxx" ) == u'xxx\'xxx' assert pretty( u"xxx\'xxx" ) == u'xxx\'xxx' assert pretty( u"xxx\"xxx" ) == u'xxx\"xxx' assert pretty( u"xxx\"xxx\'xxx" ) == u'xxx"xxx\'xxx' assert pretty( u"xxx\nxxx" ) == u'xxx\nxxx' def test_upretty_greek(): assert upretty( oo ) == u'∞' assert upretty( Symbol('alpha^+_1') ) == u'α⁺₁' assert upretty( Symbol('beta') ) == u'β' assert upretty(Symbol('lambda')) == u'λ' def test_upretty_multiindex(): assert upretty( Symbol('beta12') ) == u'β₁₂' assert upretty( Symbol('Y00') ) == u'Y₀₀' assert upretty( Symbol('Y_00') ) == u'Y₀₀' assert upretty( Symbol('F^+-') ) == u'F⁺⁻' def test_upretty_sub_super(): assert upretty( Symbol('beta_1_2') ) == u'β₁ ₂' assert upretty( Symbol('beta^1^2') ) == u'β¹ ²' assert upretty( Symbol('beta_1^2') ) == u'β²₁' assert upretty( Symbol('beta_10_20') ) == u'β₁₀ ₂₀' assert upretty( Symbol('beta_ax_gamma^i') ) == u'βⁱₐₓ ᵧ' assert upretty( Symbol("F^1^2_3_4") ) == u'F¹ ²₃ ₄' assert upretty( Symbol("F_1_2^3^4") ) == u'F³ ⁴₁ ₂' assert upretty( Symbol("F_1_2_3_4") ) == u'F₁ ₂ ₃ ₄' assert upretty( Symbol("F^1^2^3^4") ) == u'F¹ ² ³ ⁴' def test_upretty_subs_missing_in_24(): assert upretty( Symbol('F_beta') ) == u'Fᵦ' assert upretty( Symbol('F_gamma') ) == u'Fᵧ' assert upretty( Symbol('F_rho') ) == u'Fᵨ' assert upretty( Symbol('F_phi') ) == u'Fᵩ' assert upretty( Symbol('F_chi') ) == u'Fᵪ' assert upretty( Symbol('F_a') ) == u'Fₐ' assert upretty( Symbol('F_e') ) == u'Fₑ' assert upretty( Symbol('F_i') ) == u'Fᵢ' assert upretty( Symbol('F_o') ) == u'Fₒ' assert upretty( Symbol('F_u') ) == u'Fᵤ' assert upretty( Symbol('F_r') ) == u'Fᵣ' assert upretty( Symbol('F_v') ) == u'Fᵥ' assert upretty( Symbol('F_x') ) == u'Fₓ' def test_missing_in_2X_issue_9047(): if PY3: assert upretty( Symbol('F_h') ) == u'Fₕ' assert upretty( Symbol('F_k') ) == u'Fₖ' assert upretty( Symbol('F_l') ) == u'Fₗ' assert upretty( Symbol('F_m') ) == u'Fₘ' assert upretty( Symbol('F_n') ) == u'Fₙ' assert upretty( Symbol('F_p') ) == u'Fₚ' assert upretty( Symbol('F_s') ) == u'Fₛ' assert upretty( Symbol('F_t') ) == u'Fₜ' def test_upretty_modifiers(): # Accents assert upretty( Symbol('Fmathring') ) == u'F̊' assert upretty( Symbol('Fddddot') ) == u'F⃜' assert upretty( Symbol('Fdddot') ) == u'F⃛' assert upretty( Symbol('Fddot') ) == u'F̈' assert upretty( Symbol('Fdot') ) == u'Ḟ' assert upretty( Symbol('Fcheck') ) == u'F̌' assert upretty( Symbol('Fbreve') ) == u'F̆' assert upretty( Symbol('Facute') ) == u'F́' assert upretty( Symbol('Fgrave') ) == u'F̀' assert upretty( Symbol('Ftilde') ) == u'F̃' assert upretty( Symbol('Fhat') ) == u'F̂' assert upretty( Symbol('Fbar') ) == u'F̅' assert upretty( Symbol('Fvec') ) == u'F⃗' assert upretty( Symbol('Fprime') ) == u'F′' assert upretty( Symbol('Fprm') ) == u'F′' # No faces are actually implemented, but test to make sure the modifiers are stripped assert upretty( Symbol('Fbold') ) == u'Fbold' assert upretty( Symbol('Fbm') ) == u'Fbm' assert upretty( Symbol('Fcal') ) == u'Fcal' assert upretty( Symbol('Fscr') ) == u'Fscr' assert upretty( Symbol('Ffrak') ) == u'Ffrak' # Brackets assert upretty( Symbol('Fnorm') ) == u'‖F‖' assert upretty( Symbol('Favg') ) == u'⟨F⟩' assert upretty( Symbol('Fabs') ) == u'|F|' assert upretty( Symbol('Fmag') ) == u'|F|' # Combinations assert upretty( Symbol('xvecdot') ) == u'x⃗̇' assert upretty( Symbol('xDotVec') ) == u'ẋ⃗' assert upretty( Symbol('xHATNorm') ) == u'‖x̂‖' assert upretty( Symbol('xMathring_yCheckPRM__zbreveAbs') ) == u'x̊_y̌′__|z̆|' assert upretty( Symbol('alphadothat_nVECDOT__tTildePrime') ) == u'α̇̂_n⃗̇__t̃′' assert upretty( Symbol('x_dot') ) == u'x_dot' assert upretty( Symbol('x__dot') ) == u'x__dot' def test_pretty_Cycle(): from sympy.combinatorics.permutations import Cycle assert pretty(Cycle(1, 2)) == '(1 2)' assert pretty(Cycle(2)) == '(2)' assert pretty(Cycle(1, 3)(4, 5)) == '(1 3)(4 5)' assert pretty(Cycle()) == '()' def test_pretty_basic(): assert pretty( -Rational(1)/2 ) == '-1/2' assert pretty( -Rational(13)/22 ) == \ """\ -13 \n\ ----\n\ 22 \ """ expr = oo ascii_str = \ """\ oo\ """ ucode_str = \ u("""\ ∞\ """) assert pretty(expr) == ascii_str assert upretty(expr) == ucode_str expr = (x**2) ascii_str = \ """\ 2\n\ x \ """ ucode_str = \ u("""\ 2\n\ x \ """) assert pretty(expr) == ascii_str assert upretty(expr) == ucode_str expr = 1/x ascii_str = \ """\ 1\n\ -\n\ x\ """ ucode_str = \ u("""\ 1\n\ ─\n\ x\ """) assert pretty(expr) == ascii_str assert upretty(expr) == ucode_str # not the same as 1/x expr = x**-1.0 ascii_str = \ """\ -1.0\n\ x \ """ ucode_str = \ ("""\ -1.0\n\ x \ """) assert pretty(expr) == ascii_str assert upretty(expr) == ucode_str # see issue #2860 expr = Pow(S(2), -1.0, evaluate=False) ascii_str = \ """\ -1.0\n\ 2 \ """ ucode_str = \ ("""\ -1.0\n\ 2 \ """) assert pretty(expr) == ascii_str assert upretty(expr) == ucode_str expr = y*x**-2 ascii_str = \ """\ y \n\ --\n\ 2\n\ x \ """ ucode_str = \ u("""\ y \n\ ──\n\ 2\n\ x \ """) assert pretty(expr) == ascii_str assert upretty(expr) == ucode_str #see issue #14033 expr = x**Rational(1, 3) ascii_str = \ """\ 1/3\n\ x \ """ ucode_str = \ u("""\ 1/3\n\ x \ """) assert xpretty(expr, use_unicode=False, wrap_line=False,\ root_notation = False) == ascii_str assert xpretty(expr, use_unicode=True, wrap_line=False,\ root_notation = False) == ucode_str expr = x**Rational(-5, 2) ascii_str = \ """\ 1 \n\ ----\n\ 5/2\n\ x \ """ ucode_str = \ u("""\ 1 \n\ ────\n\ 5/2\n\ x \ """) assert pretty(expr) == ascii_str assert upretty(expr) == ucode_str expr = (-2)**x ascii_str = \ """\ x\n\ (-2) \ """ ucode_str = \ u("""\ x\n\ (-2) \ """) assert pretty(expr) == ascii_str assert upretty(expr) == ucode_str # See issue 4923 expr = Pow(3, 1, evaluate=False) ascii_str = \ """\ 1\n\ 3 \ """ ucode_str = \ u("""\ 1\n\ 3 \ """) assert pretty(expr) == ascii_str assert upretty(expr) == ucode_str expr = (x**2 + x + 1) ascii_str_1 = \ """\ 2\n\ 1 + x + x \ """ ascii_str_2 = \ """\ 2 \n\ x + x + 1\ """ ascii_str_3 = \ """\ 2 \n\ x + 1 + x\ """ ucode_str_1 = \ u("""\ 2\n\ 1 + x + x \ """) ucode_str_2 = \ u("""\ 2 \n\ x + x + 1\ """) ucode_str_3 = \ u("""\ 2 \n\ x + 1 + x\ """) assert pretty(expr) in [ascii_str_1, ascii_str_2, ascii_str_3] assert upretty(expr) in [ucode_str_1, ucode_str_2, ucode_str_3] expr = 1 - x ascii_str_1 = \ """\ 1 - x\ """ ascii_str_2 = \ """\ -x + 1\ """ ucode_str_1 = \ u("""\ 1 - x\ """) ucode_str_2 = \ u("""\ -x + 1\ """) assert pretty(expr) in [ascii_str_1, ascii_str_2] assert upretty(expr) in [ucode_str_1, ucode_str_2] expr = 1 - 2*x ascii_str_1 = \ """\ 1 - 2*x\ """ ascii_str_2 = \ """\ -2*x + 1\ """ ucode_str_1 = \ u("""\ 1 - 2⋅x\ """) ucode_str_2 = \ u("""\ -2⋅x + 1\ """) assert pretty(expr) in [ascii_str_1, ascii_str_2] assert upretty(expr) in [ucode_str_1, ucode_str_2] expr = x/y ascii_str = \ """\ x\n\ -\n\ y\ """ ucode_str = \ u("""\ x\n\ ─\n\ y\ """) assert pretty(expr) == ascii_str assert upretty(expr) == ucode_str expr = -x/y ascii_str = \ """\ -x \n\ ---\n\ y \ """ ucode_str = \ u("""\ -x \n\ ───\n\ y \ """) assert pretty(expr) == ascii_str assert upretty(expr) == ucode_str expr = (x + 2)/y ascii_str_1 = \ """\ 2 + x\n\ -----\n\ y \ """ ascii_str_2 = \ """\ x + 2\n\ -----\n\ y \ """ ucode_str_1 = \ u("""\ 2 + x\n\ ─────\n\ y \ """) ucode_str_2 = \ u("""\ x + 2\n\ ─────\n\ y \ """) assert pretty(expr) in [ascii_str_1, ascii_str_2] assert upretty(expr) in [ucode_str_1, ucode_str_2] expr = (1 + x)*y ascii_str_1 = \ """\ y*(1 + x)\ """ ascii_str_2 = \ """\ (1 + x)*y\ """ ascii_str_3 = \ """\ y*(x + 1)\ """ ucode_str_1 = \ u("""\ y⋅(1 + x)\ """) ucode_str_2 = \ u("""\ (1 + x)⋅y\ """) ucode_str_3 = \ u("""\ y⋅(x + 1)\ """) assert pretty(expr) in [ascii_str_1, ascii_str_2, ascii_str_3] assert upretty(expr) in [ucode_str_1, ucode_str_2, ucode_str_3] # Test for correct placement of the negative sign expr = -5*x/(x + 10) ascii_str_1 = \ """\ -5*x \n\ ------\n\ 10 + x\ """ ascii_str_2 = \ """\ -5*x \n\ ------\n\ x + 10\ """ ucode_str_1 = \ u("""\ -5⋅x \n\ ──────\n\ 10 + x\ """) ucode_str_2 = \ u("""\ -5⋅x \n\ ──────\n\ x + 10\ """) assert pretty(expr) in [ascii_str_1, ascii_str_2] assert upretty(expr) in [ucode_str_1, ucode_str_2] expr = -S(1)/2 - 3*x ascii_str = \ """\ -3*x - 1/2\ """ ucode_str = \ u("""\ -3⋅x - 1/2\ """) assert pretty(expr) == ascii_str assert upretty(expr) == ucode_str expr = S(1)/2 - 3*x ascii_str = \ """\ 1/2 - 3*x\ """ ucode_str = \ u("""\ 1/2 - 3⋅x\ """) assert pretty(expr) == ascii_str assert upretty(expr) == ucode_str expr = -S(1)/2 - 3*x/2 ascii_str = \ """\ 3*x 1\n\ - --- - -\n\ 2 2\ """ ucode_str = \ u("""\ 3⋅x 1\n\ - ─── - ─\n\ 2 2\ """) assert pretty(expr) == ascii_str assert upretty(expr) == ucode_str expr = S(1)/2 - 3*x/2 ascii_str = \ """\ 1 3*x\n\ - - ---\n\ 2 2 \ """ ucode_str = \ u("""\ 1 3⋅x\n\ ─ - ───\n\ 2 2 \ """) assert pretty(expr) == ascii_str assert upretty(expr) == ucode_str def test_negative_fractions(): expr = -x/y ascii_str =\ """\ -x \n\ ---\n\ y \ """ ucode_str =\ u("""\ -x \n\ ───\n\ y \ """) assert pretty(expr) == ascii_str assert upretty(expr) == ucode_str expr = -x*z/y ascii_str =\ """\ -x*z \n\ -----\n\ y \ """ ucode_str =\ u("""\ -x⋅z \n\ ─────\n\ y \ """) assert pretty(expr) == ascii_str assert upretty(expr) == ucode_str expr = x**2/y ascii_str =\ """\ 2\n\ x \n\ --\n\ y \ """ ucode_str =\ u("""\ 2\n\ x \n\ ──\n\ y \ """) assert pretty(expr) == ascii_str assert upretty(expr) == ucode_str expr = -x**2/y ascii_str =\ """\ 2 \n\ -x \n\ ----\n\ y \ """ ucode_str =\ u("""\ 2 \n\ -x \n\ ────\n\ y \ """) assert pretty(expr) == ascii_str assert upretty(expr) == ucode_str expr = -x/(y*z) ascii_str =\ """\ -x \n\ ---\n\ y*z\ """ ucode_str =\ u("""\ -x \n\ ───\n\ y⋅z\ """) assert pretty(expr) == ascii_str assert upretty(expr) == ucode_str expr = -a/y**2 ascii_str =\ """\ -a \n\ ---\n\ 2\n\ y \ """ ucode_str =\ u("""\ -a \n\ ───\n\ 2\n\ y \ """) assert pretty(expr) == ascii_str assert upretty(expr) == ucode_str expr = y**(-a/b) ascii_str =\ """\ -a \n\ ---\n\ b \n\ y \ """ ucode_str =\ u("""\ -a \n\ ───\n\ b \n\ y \ """) assert pretty(expr) == ascii_str assert upretty(expr) == ucode_str expr = -1/y**2 ascii_str =\ """\ -1 \n\ ---\n\ 2\n\ y \ """ ucode_str =\ u("""\ -1 \n\ ───\n\ 2\n\ y \ """) assert pretty(expr) == ascii_str assert upretty(expr) == ucode_str expr = -10/b**2 ascii_str =\ """\ -10 \n\ ----\n\ 2 \n\ b \ """ ucode_str =\ u("""\ -10 \n\ ────\n\ 2 \n\ b \ """) assert pretty(expr) == ascii_str assert upretty(expr) == ucode_str expr = Rational(-200, 37) ascii_str =\ """\ -200 \n\ -----\n\ 37 \ """ ucode_str =\ u("""\ -200 \n\ ─────\n\ 37 \ """) assert pretty(expr) == ascii_str assert upretty(expr) == ucode_str def test_issue_5524(): assert pretty(-(-x + 5)*(-x - 2*sqrt(2) + 5) - (-y + 5)*(-y + 5)) == \ """\ 2 / ___ \\\n\ - (5 - y) + (x - 5)*\\-x - 2*\\/ 2 + 5/\ """ assert upretty(-(-x + 5)*(-x - 2*sqrt(2) + 5) - (-y + 5)*(-y + 5)) == \ u("""\ 2 \n\ - (5 - y) + (x - 5)⋅(-x - 2⋅√2 + 5)\ """) def test_pretty_ordering(): assert pretty(x**2 + x + 1, order='lex') == \ """\ 2 \n\ x + x + 1\ """ assert pretty(x**2 + x + 1, order='rev-lex') == \ """\ 2\n\ 1 + x + x \ """ assert pretty(1 - x, order='lex') == '-x + 1' assert pretty(1 - x, order='rev-lex') == '1 - x' assert pretty(1 - 2*x, order='lex') == '-2*x + 1' assert pretty(1 - 2*x, order='rev-lex') == '1 - 2*x' f = 2*x**4 + y**2 - x**2 + y**3 assert pretty(f, order=None) == \ """\ 4 2 3 2\n\ 2*x - x + y + y \ """ assert pretty(f, order='lex') == \ """\ 4 2 3 2\n\ 2*x - x + y + y \ """ assert pretty(f, order='rev-lex') == \ """\ 2 3 2 4\n\ y + y - x + 2*x \ """ expr = x - x**3/6 + x**5/120 + O(x**6) ascii_str = \ """\ 3 5 \n\ x x / 6\\\n\ x - -- + --- + O\\x /\n\ 6 120 \ """ ucode_str = \ u("""\ 3 5 \n\ x x ⎛ 6⎞\n\ x - ── + ─── + O⎝x ⎠\n\ 6 120 \ """) assert pretty(expr, order=None) == ascii_str assert upretty(expr, order=None) == ucode_str assert pretty(expr, order='lex') == ascii_str assert upretty(expr, order='lex') == ucode_str assert pretty(expr, order='rev-lex') == ascii_str assert upretty(expr, order='rev-lex') == ucode_str def test_EulerGamma(): assert pretty(EulerGamma) == str(EulerGamma) == "EulerGamma" assert upretty(EulerGamma) == u"γ" def test_GoldenRatio(): assert pretty(GoldenRatio) == str(GoldenRatio) == "GoldenRatio" assert upretty(GoldenRatio) == u"φ" def test_pretty_relational(): expr = Eq(x, y) ascii_str = \ """\ x = y\ """ ucode_str = \ u("""\ x = y\ """) assert pretty(expr) == ascii_str assert upretty(expr) == ucode_str expr = Lt(x, y) ascii_str = \ """\ x < y\ """ ucode_str = \ u("""\ x < y\ """) assert pretty(expr) == ascii_str assert upretty(expr) == ucode_str expr = Gt(x, y) ascii_str = \ """\ x > y\ """ ucode_str = \ u("""\ x > y\ """) assert pretty(expr) == ascii_str assert upretty(expr) == ucode_str expr = Le(x, y) ascii_str = \ """\ x <= y\ """ ucode_str = \ u("""\ x ≤ y\ """) assert pretty(expr) == ascii_str assert upretty(expr) == ucode_str expr = Ge(x, y) ascii_str = \ """\ x >= y\ """ ucode_str = \ u("""\ x ≥ y\ """) assert pretty(expr) == ascii_str assert upretty(expr) == ucode_str expr = Ne(x/(y + 1), y**2) ascii_str_1 = \ """\ x 2\n\ ----- != y \n\ 1 + y \ """ ascii_str_2 = \ """\ x 2\n\ ----- != y \n\ y + 1 \ """ ucode_str_1 = \ u("""\ x 2\n\ ───── ≠ y \n\ 1 + y \ """) ucode_str_2 = \ u("""\ x 2\n\ ───── ≠ y \n\ y + 1 \ """) assert pretty(expr) in [ascii_str_1, ascii_str_2] assert upretty(expr) in [ucode_str_1, ucode_str_2] def test_Assignment(): expr = Assignment(x, y) ascii_str = \ """\ x := y\ """ ucode_str = \ u("""\ x := y\ """) assert pretty(expr) == ascii_str assert upretty(expr) == ucode_str def test_AugmentedAssignment(): expr = AddAugmentedAssignment(x, y) ascii_str = \ """\ x += y\ """ ucode_str = \ u("""\ x += y\ """) assert pretty(expr) == ascii_str assert upretty(expr) == ucode_str expr = SubAugmentedAssignment(x, y) ascii_str = \ """\ x -= y\ """ ucode_str = \ u("""\ x -= y\ """) assert pretty(expr) == ascii_str assert upretty(expr) == ucode_str expr = MulAugmentedAssignment(x, y) ascii_str = \ """\ x *= y\ """ ucode_str = \ u("""\ x *= y\ """) assert pretty(expr) == ascii_str assert upretty(expr) == ucode_str expr = DivAugmentedAssignment(x, y) ascii_str = \ """\ x /= y\ """ ucode_str = \ u("""\ x /= y\ """) assert pretty(expr) == ascii_str assert upretty(expr) == ucode_str expr = ModAugmentedAssignment(x, y) ascii_str = \ """\ x %= y\ """ ucode_str = \ u("""\ x %= y\ """) assert pretty(expr) == ascii_str assert upretty(expr) == ucode_str def test_issue_7117(): # See also issue #5031 (hence the evaluate=False in these). e = Eq(x + 1, x/2) q = Mul(2, e, evaluate=False) assert upretty(q) == u("""\ ⎛ x⎞\n\ 2⋅⎜x + 1 = ─⎟\n\ ⎝ 2⎠\ """) q = Add(e, 6, evaluate=False) assert upretty(q) == u("""\ ⎛ x⎞\n\ 6 + ⎜x + 1 = ─⎟\n\ ⎝ 2⎠\ """) q = Pow(e, 2, evaluate=False) assert upretty(q) == u("""\ 2\n\ ⎛ x⎞ \n\ ⎜x + 1 = ─⎟ \n\ ⎝ 2⎠ \ """) e2 = Eq(x, 2) q = Mul(e, e2, evaluate=False) assert upretty(q) == u("""\ ⎛ x⎞ \n\ ⎜x + 1 = ─⎟⋅(x = 2)\n\ ⎝ 2⎠ \ """) def test_pretty_rational(): expr = y*x**-2 ascii_str = \ """\ y \n\ --\n\ 2\n\ x \ """ ucode_str = \ u("""\ y \n\ ──\n\ 2\n\ x \ """) assert pretty(expr) == ascii_str assert upretty(expr) == ucode_str expr = y**Rational(3, 2) * x**Rational(-5, 2) ascii_str = \ """\ 3/2\n\ y \n\ ----\n\ 5/2\n\ x \ """ ucode_str = \ u("""\ 3/2\n\ y \n\ ────\n\ 5/2\n\ x \ """) assert pretty(expr) == ascii_str assert upretty(expr) == ucode_str expr = sin(x)**3/tan(x)**2 ascii_str = \ """\ 3 \n\ sin (x)\n\ -------\n\ 2 \n\ tan (x)\ """ ucode_str = \ u("""\ 3 \n\ sin (x)\n\ ───────\n\ 2 \n\ tan (x)\ """) assert pretty(expr) == ascii_str assert upretty(expr) == ucode_str def test_pretty_functions(): """Tests for Abs, conjugate, exp, function braces, and factorial.""" expr = (2*x + exp(x)) ascii_str_1 = \ """\ x\n\ 2*x + e \ """ ascii_str_2 = \ """\ x \n\ e + 2*x\ """ ucode_str_1 = \ u("""\ x\n\ 2⋅x + ℯ \ """) ucode_str_2 = \ u("""\ x \n\ ℯ + 2⋅x\ """) assert pretty(expr) in [ascii_str_1, ascii_str_2] assert upretty(expr) in [ucode_str_1, ucode_str_2] expr = Abs(x) ascii_str = \ """\ |x|\ """ ucode_str = \ u("""\ │x│\ """) assert pretty(expr) == ascii_str assert upretty(expr) == ucode_str expr = Abs(x/(x**2 + 1)) ascii_str_1 = \ """\ | x |\n\ |------|\n\ | 2|\n\ |1 + x |\ """ ascii_str_2 = \ """\ | x |\n\ |------|\n\ | 2 |\n\ |x + 1|\ """ ucode_str_1 = \ u("""\ │ x │\n\ │──────│\n\ │ 2│\n\ │1 + x │\ """) ucode_str_2 = \ u("""\ │ x │\n\ │──────│\n\ │ 2 │\n\ │x + 1│\ """) assert pretty(expr) in [ascii_str_1, ascii_str_2] assert upretty(expr) in [ucode_str_1, ucode_str_2] expr = Abs(1 / (y - Abs(x))) ascii_str = \ """\ | 1 |\n\ |-------|\n\ |y - |x||\ """ ucode_str = \ u("""\ │ 1 │\n\ │───────│\n\ │y - │x││\ """) assert pretty(expr) == ascii_str assert upretty(expr) == ucode_str n = Symbol('n', integer=True) expr = factorial(n) ascii_str = \ """\ n!\ """ ucode_str = \ u("""\ n!\ """) assert pretty(expr) == ascii_str assert upretty(expr) == ucode_str expr = factorial(2*n) ascii_str = \ """\ (2*n)!\ """ ucode_str = \ u("""\ (2⋅n)!\ """) assert pretty(expr) == ascii_str assert upretty(expr) == ucode_str expr = factorial(factorial(factorial(n))) ascii_str = \ """\ ((n!)!)!\ """ ucode_str = \ u("""\ ((n!)!)!\ """) assert pretty(expr) == ascii_str assert upretty(expr) == ucode_str expr = factorial(n + 1) ascii_str_1 = \ """\ (1 + n)!\ """ ascii_str_2 = \ """\ (n + 1)!\ """ ucode_str_1 = \ u("""\ (1 + n)!\ """) ucode_str_2 = \ u("""\ (n + 1)!\ """) assert pretty(expr) in [ascii_str_1, ascii_str_2] assert upretty(expr) in [ucode_str_1, ucode_str_2] expr = subfactorial(n) ascii_str = \ """\ !n\ """ ucode_str = \ u("""\ !n\ """) assert pretty(expr) == ascii_str assert upretty(expr) == ucode_str expr = subfactorial(2*n) ascii_str = \ """\ !(2*n)\ """ ucode_str = \ u("""\ !(2⋅n)\ """) assert pretty(expr) == ascii_str assert upretty(expr) == ucode_str n = Symbol('n', integer=True) expr = factorial2(n) ascii_str = \ """\ n!!\ """ ucode_str = \ u("""\ n!!\ """) assert pretty(expr) == ascii_str assert upretty(expr) == ucode_str expr = factorial2(2*n) ascii_str = \ """\ (2*n)!!\ """ ucode_str = \ u("""\ (2⋅n)!!\ """) assert pretty(expr) == ascii_str assert upretty(expr) == ucode_str expr = factorial2(factorial2(factorial2(n))) ascii_str = \ """\ ((n!!)!!)!!\ """ ucode_str = \ u("""\ ((n!!)!!)!!\ """) assert pretty(expr) == ascii_str assert upretty(expr) == ucode_str expr = factorial2(n + 1) ascii_str_1 = \ """\ (1 + n)!!\ """ ascii_str_2 = \ """\ (n + 1)!!\ """ ucode_str_1 = \ u("""\ (1 + n)!!\ """) ucode_str_2 = \ u("""\ (n + 1)!!\ """) assert pretty(expr) in [ascii_str_1, ascii_str_2] assert upretty(expr) in [ucode_str_1, ucode_str_2] expr = 2*binomial(n, k) ascii_str = \ """\ /n\\\n\ 2*| |\n\ \\k/\ """ ucode_str = \ u("""\ ⎛n⎞\n\ 2⋅⎜ ⎟\n\ ⎝k⎠\ """) assert pretty(expr) == ascii_str assert upretty(expr) == ucode_str expr = 2*binomial(2*n, k) ascii_str = \ """\ /2*n\\\n\ 2*| |\n\ \\ k /\ """ ucode_str = \ u("""\ ⎛2⋅n⎞\n\ 2⋅⎜ ⎟\n\ ⎝ k ⎠\ """) assert pretty(expr) == ascii_str assert upretty(expr) == ucode_str expr = 2*binomial(n**2, k) ascii_str = \ """\ / 2\\\n\ |n |\n\ 2*| |\n\ \\k /\ """ ucode_str = \ u("""\ ⎛ 2⎞\n\ ⎜n ⎟\n\ 2⋅⎜ ⎟\n\ ⎝k ⎠\ """) assert pretty(expr) == ascii_str assert upretty(expr) == ucode_str expr = catalan(n) ascii_str = \ """\ C \n\ n\ """ ucode_str = \ u("""\ C \n\ n\ """) assert pretty(expr) == ascii_str assert upretty(expr) == ucode_str expr = catalan(n) ascii_str = \ """\ C \n\ n\ """ ucode_str = \ u("""\ C \n\ n\ """) assert pretty(expr) == ascii_str assert upretty(expr) == ucode_str expr = bell(n) ascii_str = \ """\ B \n\ n\ """ ucode_str = \ u("""\ B \n\ n\ """) assert pretty(expr) == ascii_str assert upretty(expr) == ucode_str expr = bernoulli(n) ascii_str = \ """\ B \n\ n\ """ ucode_str = \ u("""\ B \n\ n\ """) assert pretty(expr) == ascii_str assert upretty(expr) == ucode_str expr = fibonacci(n) ascii_str = \ """\ F \n\ n\ """ ucode_str = \ u("""\ F \n\ n\ """) assert pretty(expr) == ascii_str assert upretty(expr) == ucode_str expr = lucas(n) ascii_str = \ """\ L \n\ n\ """ ucode_str = \ u("""\ L \n\ n\ """) assert pretty(expr) == ascii_str assert upretty(expr) == ucode_str expr = tribonacci(n) ascii_str = \ """\ T \n\ n\ """ ucode_str = \ u("""\ T \n\ n\ """) assert pretty(expr) == ascii_str assert upretty(expr) == ucode_str expr = conjugate(x) ascii_str = \ """\ _\n\ x\ """ ucode_str = \ u("""\ _\n\ x\ """) assert pretty(expr) == ascii_str assert upretty(expr) == ucode_str f = Function('f') expr = conjugate(f(x + 1)) ascii_str_1 = \ """\ ________\n\ f(1 + x)\ """ ascii_str_2 = \ """\ ________\n\ f(x + 1)\ """ ucode_str_1 = \ u("""\ ________\n\ f(1 + x)\ """) ucode_str_2 = \ u("""\ ________\n\ f(x + 1)\ """) assert pretty(expr) in [ascii_str_1, ascii_str_2] assert upretty(expr) in [ucode_str_1, ucode_str_2] expr = f(x) ascii_str = \ """\ f(x)\ """ ucode_str = \ u("""\ f(x)\ """) assert pretty(expr) == ascii_str assert upretty(expr) == ucode_str expr = f(x, y) ascii_str = \ """\ f(x, y)\ """ ucode_str = \ u("""\ f(x, y)\ """) assert pretty(expr) == ascii_str assert upretty(expr) == ucode_str expr = f(x/(y + 1), y) ascii_str_1 = \ """\ / x \\\n\ f|-----, y|\n\ \\1 + y /\ """ ascii_str_2 = \ """\ / x \\\n\ f|-----, y|\n\ \\y + 1 /\ """ ucode_str_1 = \ u("""\ ⎛ x ⎞\n\ f⎜─────, y⎟\n\ ⎝1 + y ⎠\ """) ucode_str_2 = \ u("""\ ⎛ x ⎞\n\ f⎜─────, y⎟\n\ ⎝y + 1 ⎠\ """) assert pretty(expr) in [ascii_str_1, ascii_str_2] assert upretty(expr) in [ucode_str_1, ucode_str_2] expr = f(x**x**x**x**x**x) ascii_str = \ """\ / / / / / x\\\\\\\\\\ | | | | \\x /|||| | | | \\x /||| | | \\x /|| | \\x /| f\\x /\ """ ucode_str = \ u("""\ ⎛ ⎛ ⎛ ⎛ ⎛ x⎞⎞⎞⎞⎞ ⎜ ⎜ ⎜ ⎜ ⎝x ⎠⎟⎟⎟⎟ ⎜ ⎜ ⎜ ⎝x ⎠⎟⎟⎟ ⎜ ⎜ ⎝x ⎠⎟⎟ ⎜ ⎝x ⎠⎟ f⎝x ⎠\ """) assert pretty(expr) == ascii_str assert upretty(expr) == ucode_str expr = sin(x)**2 ascii_str = \ """\ 2 \n\ sin (x)\ """ ucode_str = \ u("""\ 2 \n\ sin (x)\ """) assert pretty(expr) == ascii_str assert upretty(expr) == ucode_str expr = conjugate(a + b*I) ascii_str = \ """\ _ _\n\ a - I*b\ """ ucode_str = \ u("""\ _ _\n\ a - ⅈ⋅b\ """) assert pretty(expr) == ascii_str assert upretty(expr) == ucode_str expr = conjugate(exp(a + b*I)) ascii_str = \ """\ _ _\n\ a - I*b\n\ e \ """ ucode_str = \ u("""\ _ _\n\ a - ⅈ⋅b\n\ ℯ \ """) assert pretty(expr) == ascii_str assert upretty(expr) == ucode_str expr = conjugate( f(1 + conjugate(f(x))) ) ascii_str_1 = \ """\ ___________\n\ / ____\\\n\ f\\1 + f(x)/\ """ ascii_str_2 = \ """\ ___________\n\ /____ \\\n\ f\\f(x) + 1/\ """ ucode_str_1 = \ u("""\ ___________\n\ ⎛ ____⎞\n\ f⎝1 + f(x)⎠\ """) ucode_str_2 = \ u("""\ ___________\n\ ⎛____ ⎞\n\ f⎝f(x) + 1⎠\ """) assert pretty(expr) in [ascii_str_1, ascii_str_2] assert upretty(expr) in [ucode_str_1, ucode_str_2] expr = f(x/(y + 1), y) ascii_str_1 = \ """\ / x \\\n\ f|-----, y|\n\ \\1 + y /\ """ ascii_str_2 = \ """\ / x \\\n\ f|-----, y|\n\ \\y + 1 /\ """ ucode_str_1 = \ u("""\ ⎛ x ⎞\n\ f⎜─────, y⎟\n\ ⎝1 + y ⎠\ """) ucode_str_2 = \ u("""\ ⎛ x ⎞\n\ f⎜─────, y⎟\n\ ⎝y + 1 ⎠\ """) assert pretty(expr) in [ascii_str_1, ascii_str_2] assert upretty(expr) in [ucode_str_1, ucode_str_2] expr = floor(1 / (y - floor(x))) ascii_str = \ """\ / 1 \\\n\ floor|------------|\n\ \\y - floor(x)/\ """ ucode_str = \ u("""\ ⎢ 1 ⎥\n\ ⎢───────⎥\n\ ⎣y - ⌊x⌋⎦\ """) assert pretty(expr) == ascii_str assert upretty(expr) == ucode_str expr = ceiling(1 / (y - ceiling(x))) ascii_str = \ """\ / 1 \\\n\ ceiling|--------------|\n\ \\y - ceiling(x)/\ """ ucode_str = \ u("""\ ⎡ 1 ⎤\n\ ⎢───────⎥\n\ ⎢y - ⌈x⌉⎥\ """) assert pretty(expr) == ascii_str assert upretty(expr) == ucode_str expr = euler(n) ascii_str = \ """\ E \n\ n\ """ ucode_str = \ u("""\ E \n\ n\ """) assert pretty(expr) == ascii_str assert upretty(expr) == ucode_str expr = euler(1/(1 + 1/(1 + 1/n))) ascii_str = \ """\ E \n\ 1 \n\ ---------\n\ 1 \n\ 1 + -----\n\ 1\n\ 1 + -\n\ n\ """ ucode_str = \ u("""\ E \n\ 1 \n\ ─────────\n\ 1 \n\ 1 + ─────\n\ 1\n\ 1 + ─\n\ n\ """) assert pretty(expr) == ascii_str assert upretty(expr) == ucode_str expr = euler(n, x) ascii_str = \ """\ E (x)\n\ n \ """ ucode_str = \ u("""\ E (x)\n\ n \ """) assert pretty(expr) == ascii_str assert upretty(expr) == ucode_str expr = euler(n, x/2) ascii_str = \ """\ /x\\\n\ E |-|\n\ n\\2/\ """ ucode_str = \ u("""\ ⎛x⎞\n\ E ⎜─⎟\n\ n⎝2⎠\ """) assert pretty(expr) == ascii_str assert upretty(expr) == ucode_str def test_pretty_sqrt(): expr = sqrt(2) ascii_str = \ """\ ___\n\ \\/ 2 \ """ ucode_str = \ u"√2" assert pretty(expr) == ascii_str assert upretty(expr) == ucode_str expr = 2**Rational(1, 3) ascii_str = \ """\ 3 ___\n\ \\/ 2 \ """ ucode_str = \ u("""\ 3 ___\n\ ╲╱ 2 \ """) assert pretty(expr) == ascii_str assert upretty(expr) == ucode_str expr = 2**Rational(1, 1000) ascii_str = \ """\ 1000___\n\ \\/ 2 \ """ ucode_str = \ u("""\ 1000___\n\ ╲╱ 2 \ """) assert pretty(expr) == ascii_str assert upretty(expr) == ucode_str expr = sqrt(x**2 + 1) ascii_str = \ """\ ________\n\ / 2 \n\ \\/ x + 1 \ """ ucode_str = \ u("""\ ________\n\ ╱ 2 \n\ ╲╱ x + 1 \ """) assert pretty(expr) == ascii_str assert upretty(expr) == ucode_str expr = (1 + sqrt(5))**Rational(1, 3) ascii_str = \ """\ ___________\n\ 3 / ___ \n\ \\/ 1 + \\/ 5 \ """ ucode_str = \ u("""\ 3 ________\n\ ╲╱ 1 + √5 \ """) assert pretty(expr) == ascii_str assert upretty(expr) == ucode_str expr = 2**(1/x) ascii_str = \ """\ x ___\n\ \\/ 2 \ """ ucode_str = \ u("""\ x ___\n\ ╲╱ 2 \ """) assert pretty(expr) == ascii_str assert upretty(expr) == ucode_str expr = sqrt(2 + pi) ascii_str = \ """\ ________\n\ \\/ 2 + pi \ """ ucode_str = \ u("""\ _______\n\ ╲╱ 2 + π \ """) assert pretty(expr) == ascii_str assert upretty(expr) == ucode_str expr = (2 + ( 1 + x**2)/(2 + x))**Rational(1, 4) + (1 + x**Rational(1, 1000))/sqrt(3 + x**2) ascii_str = \ """\ ____________ \n\ / 2 1000___ \n\ / x + 1 \\/ x + 1\n\ 4 / 2 + ------ + -----------\n\ \\/ x + 2 ________\n\ / 2 \n\ \\/ x + 3 \ """ ucode_str = \ u("""\ ____________ \n\ ╱ 2 1000___ \n\ ╱ x + 1 ╲╱ x + 1\n\ 4 ╱ 2 + ────── + ───────────\n\ ╲╱ x + 2 ________\n\ ╱ 2 \n\ ╲╱ x + 3 \ """) assert pretty(expr) == ascii_str assert upretty(expr) == ucode_str def test_pretty_sqrt_char_knob(): # See PR #9234. expr = sqrt(2) ucode_str1 = \ u("""\ ___\n\ ╲╱ 2 \ """) ucode_str2 = \ u"√2" assert xpretty(expr, use_unicode=True, use_unicode_sqrt_char=False) == ucode_str1 assert xpretty(expr, use_unicode=True, use_unicode_sqrt_char=True) == ucode_str2 def test_pretty_sqrt_longsymbol_no_sqrt_char(): # Do not use unicode sqrt char for long symbols (see PR #9234). expr = sqrt(Symbol('C1')) ucode_str = \ u("""\ ____\n\ ╲╱ C₁ \ """) assert upretty(expr) == ucode_str def test_pretty_KroneckerDelta(): x, y = symbols("x, y") expr = KroneckerDelta(x, y) ascii_str = \ """\ d \n\ x,y\ """ ucode_str = \ u("""\ δ \n\ x,y\ """) assert pretty(expr) == ascii_str assert upretty(expr) == ucode_str def test_pretty_product(): n, m, k, l = symbols('n m k l') f = symbols('f', cls=Function) expr = Product(f((n/3)**2), (n, k**2, l)) unicode_str = \ u("""\ l \n\ ─┬──────┬─ \n\ │ │ ⎛ 2⎞\n\ │ │ ⎜n ⎟\n\ │ │ f⎜──⎟\n\ │ │ ⎝9 ⎠\n\ │ │ \n\ 2 \n\ n = k """) ascii_str = \ """\ l \n\ __________ \n\ | | / 2\\\n\ | | |n |\n\ | | f|--|\n\ | | \\9 /\n\ | | \n\ 2 \n\ n = k """ expr = Product(f((n/3)**2), (n, k**2, l), (l, 1, m)) unicode_str = \ u("""\ m l \n\ ─┬──────┬─ ─┬──────┬─ \n\ │ │ │ │ ⎛ 2⎞\n\ │ │ │ │ ⎜n ⎟\n\ │ │ │ │ f⎜──⎟\n\ │ │ │ │ ⎝9 ⎠\n\ │ │ │ │ \n\ l = 1 2 \n\ n = k """) ascii_str = \ """\ m l \n\ __________ __________ \n\ | | | | / 2\\\n\ | | | | |n |\n\ | | | | f|--|\n\ | | | | \\9 /\n\ | | | | \n\ l = 1 2 \n\ n = k """ assert pretty(expr) == ascii_str assert upretty(expr) == unicode_str def test_pretty_lambda(): # S.IdentityFunction is a special case expr = Lambda(y, y) assert pretty(expr) == "x -> x" assert upretty(expr) == u"x ↦ x" expr = Lambda(x, x+1) assert pretty(expr) == "x -> x + 1" assert upretty(expr) == u"x ↦ x + 1" expr = Lambda(x, x**2) ascii_str = \ """\ 2\n\ x -> x \ """ ucode_str = \ u("""\ 2\n\ x ↦ x \ """) assert pretty(expr) == ascii_str assert upretty(expr) == ucode_str expr = Lambda(x, x**2)**2 ascii_str = \ """\ 2 / 2\\ \n\ \\x -> x / \ """ ucode_str = \ u("""\ 2 ⎛ 2⎞ \n\ ⎝x ↦ x ⎠ \ """) assert pretty(expr) == ascii_str assert upretty(expr) == ucode_str expr = Lambda((x, y), x) ascii_str = "(x, y) -> x" ucode_str = u"(x, y) ↦ x" assert pretty(expr) == ascii_str assert upretty(expr) == ucode_str expr = Lambda((x, y), x**2) ascii_str = \ """\ 2\n\ (x, y) -> x \ """ ucode_str = \ u("""\ 2\n\ (x, y) ↦ x \ """) assert pretty(expr) == ascii_str assert upretty(expr) == ucode_str def test_pretty_order(): expr = O(1) ascii_str = \ """\ O(1)\ """ ucode_str = \ u("""\ O(1)\ """) assert pretty(expr) == ascii_str assert upretty(expr) == ucode_str expr = O(1/x) ascii_str = \ """\ /1\\\n\ O|-|\n\ \\x/\ """ ucode_str = \ u("""\ ⎛1⎞\n\ O⎜─⎟\n\ ⎝x⎠\ """) assert pretty(expr) == ascii_str assert upretty(expr) == ucode_str expr = O(x**2 + y**2) ascii_str = \ """\ / 2 2 \\\n\ O\\x + y ; (x, y) -> (0, 0)/\ """ ucode_str = \ u("""\ ⎛ 2 2 ⎞\n\ O⎝x + y ; (x, y) → (0, 0)⎠\ """) assert pretty(expr) == ascii_str assert upretty(expr) == ucode_str expr = O(1, (x, oo)) ascii_str = \ """\ O(1; x -> oo)\ """ ucode_str = \ u("""\ O(1; x → ∞)\ """) assert pretty(expr) == ascii_str assert upretty(expr) == ucode_str expr = O(1/x, (x, oo)) ascii_str = \ """\ /1 \\\n\ O|-; x -> oo|\n\ \\x /\ """ ucode_str = \ u("""\ ⎛1 ⎞\n\ O⎜─; x → ∞⎟\n\ ⎝x ⎠\ """) assert pretty(expr) == ascii_str assert upretty(expr) == ucode_str expr = O(x**2 + y**2, (x, oo), (y, oo)) ascii_str = \ """\ / 2 2 \\\n\ O\\x + y ; (x, y) -> (oo, oo)/\ """ ucode_str = \ u("""\ ⎛ 2 2 ⎞\n\ O⎝x + y ; (x, y) → (∞, ∞)⎠\ """) assert pretty(expr) == ascii_str assert upretty(expr) == ucode_str def test_pretty_derivatives(): # Simple expr = Derivative(log(x), x, evaluate=False) ascii_str = \ """\ d \n\ --(log(x))\n\ dx \ """ ucode_str = \ u("""\ d \n\ ──(log(x))\n\ dx \ """) assert pretty(expr) == ascii_str assert upretty(expr) == ucode_str expr = Derivative(log(x), x, evaluate=False) + x ascii_str_1 = \ """\ d \n\ x + --(log(x))\n\ dx \ """ ascii_str_2 = \ """\ d \n\ --(log(x)) + x\n\ dx \ """ ucode_str_1 = \ u("""\ d \n\ x + ──(log(x))\n\ dx \ """) ucode_str_2 = \ u("""\ d \n\ ──(log(x)) + x\n\ dx \ """) assert pretty(expr) in [ascii_str_1, ascii_str_2] assert upretty(expr) in [ucode_str_1, ucode_str_2] # basic partial derivatives expr = Derivative(log(x + y) + x, x) ascii_str_1 = \ """\ d \n\ --(log(x + y) + x)\n\ dx \ """ ascii_str_2 = \ """\ d \n\ --(x + log(x + y))\n\ dx \ """ ucode_str_1 = \ u("""\ ∂ \n\ ──(log(x + y) + x)\n\ ∂x \ """) ucode_str_2 = \ u("""\ ∂ \n\ ──(x + log(x + y))\n\ ∂x \ """) assert pretty(expr) in [ascii_str_1, ascii_str_2] assert upretty(expr) in [ucode_str_1, ucode_str_2], upretty(expr) # Multiple symbols expr = Derivative(log(x) + x**2, x, y) ascii_str_1 = \ """\ 2 \n\ d / 2\\\n\ -----\\log(x) + x /\n\ dy dx \ """ ascii_str_2 = \ """\ 2 \n\ d / 2 \\\n\ -----\\x + log(x)/\n\ dy dx \ """ ucode_str_1 = \ u("""\ 2 \n\ d ⎛ 2⎞\n\ ─────⎝log(x) + x ⎠\n\ dy dx \ """) ucode_str_2 = \ u("""\ 2 \n\ d ⎛ 2 ⎞\n\ ─────⎝x + log(x)⎠\n\ dy dx \ """) assert pretty(expr) in [ascii_str_1, ascii_str_2] assert upretty(expr) in [ucode_str_1, ucode_str_2] expr = Derivative(2*x*y, y, x) + x**2 ascii_str_1 = \ """\ 2 \n\ d 2\n\ -----(2*x*y) + x \n\ dx dy \ """ ascii_str_2 = \ """\ 2 \n\ 2 d \n\ x + -----(2*x*y)\n\ dx dy \ """ ucode_str_1 = \ u("""\ 2 \n\ ∂ 2\n\ ─────(2⋅x⋅y) + x \n\ ∂x ∂y \ """) ucode_str_2 = \ u("""\ 2 \n\ 2 ∂ \n\ x + ─────(2⋅x⋅y)\n\ ∂x ∂y \ """) assert pretty(expr) in [ascii_str_1, ascii_str_2] assert upretty(expr) in [ucode_str_1, ucode_str_2] expr = Derivative(2*x*y, x, x) ascii_str = \ """\ 2 \n\ d \n\ ---(2*x*y)\n\ 2 \n\ dx \ """ ucode_str = \ u("""\ 2 \n\ ∂ \n\ ───(2⋅x⋅y)\n\ 2 \n\ ∂x \ """) assert pretty(expr) == ascii_str assert upretty(expr) == ucode_str expr = Derivative(2*x*y, x, 17) ascii_str = \ """\ 17 \n\ d \n\ ----(2*x*y)\n\ 17 \n\ dx \ """ ucode_str = \ u("""\ 17 \n\ ∂ \n\ ────(2⋅x⋅y)\n\ 17 \n\ ∂x \ """) assert pretty(expr) == ascii_str assert upretty(expr) == ucode_str expr = Derivative(2*x*y, x, x, y) ascii_str = \ """\ 3 \n\ d \n\ ------(2*x*y)\n\ 2 \n\ dy dx \ """ ucode_str = \ u("""\ 3 \n\ ∂ \n\ ──────(2⋅x⋅y)\n\ 2 \n\ ∂y ∂x \ """) assert pretty(expr) == ascii_str assert upretty(expr) == ucode_str # Greek letters alpha = Symbol('alpha') beta = Function('beta') expr = beta(alpha).diff(alpha) ascii_str = \ """\ d \n\ ------(beta(alpha))\n\ dalpha \ """ ucode_str = \ u("""\ d \n\ ──(β(α))\n\ dα \ """) assert pretty(expr) == ascii_str assert upretty(expr) == ucode_str expr = Derivative(f(x), (x, n)) ascii_str = \ """\ n \n\ d \n\ ---(f(x))\n\ n \n\ dx \ """ ucode_str = \ u("""\ n \n\ d \n\ ───(f(x))\n\ n \n\ dx \ """) assert pretty(expr) == ascii_str assert upretty(expr) == ucode_str def test_pretty_integrals(): expr = Integral(log(x), x) ascii_str = \ """\ / \n\ | \n\ | log(x) dx\n\ | \n\ / \ """ ucode_str = \ u("""\ ⌠ \n\ ⎮ log(x) dx\n\ ⌡ \ """) assert pretty(expr) == ascii_str assert upretty(expr) == ucode_str expr = Integral(x**2, x) ascii_str = \ """\ / \n\ | \n\ | 2 \n\ | x dx\n\ | \n\ / \ """ ucode_str = \ u("""\ ⌠ \n\ ⎮ 2 \n\ ⎮ x dx\n\ ⌡ \ """) assert pretty(expr) == ascii_str assert upretty(expr) == ucode_str expr = Integral((sin(x))**2 / (tan(x))**2) ascii_str = \ """\ / \n\ | \n\ | 2 \n\ | sin (x) \n\ | ------- dx\n\ | 2 \n\ | tan (x) \n\ | \n\ / \ """ ucode_str = \ u("""\ ⌠ \n\ ⎮ 2 \n\ ⎮ sin (x) \n\ ⎮ ─────── dx\n\ ⎮ 2 \n\ ⎮ tan (x) \n\ ⌡ \ """) assert pretty(expr) == ascii_str assert upretty(expr) == ucode_str expr = Integral(x**(2**x), x) ascii_str = \ """\ / \n\ | \n\ | / x\\ \n\ | \\2 / \n\ | x dx\n\ | \n\ / \ """ ucode_str = \ u("""\ ⌠ \n\ ⎮ ⎛ x⎞ \n\ ⎮ ⎝2 ⎠ \n\ ⎮ x dx\n\ ⌡ \ """) assert pretty(expr) == ascii_str assert upretty(expr) == ucode_str expr = Integral(x**2, (x, 1, 2)) ascii_str = \ """\ 2 \n\ / \n\ | \n\ | 2 \n\ | x dx\n\ | \n\ / \n\ 1 \ """ ucode_str = \ u("""\ 2 \n\ ⌠ \n\ ⎮ 2 \n\ ⎮ x dx\n\ ⌡ \n\ 1 \ """) assert pretty(expr) == ascii_str assert upretty(expr) == ucode_str expr = Integral(x**2, (x, Rational(1, 2), 10)) ascii_str = \ """\ 10 \n\ / \n\ | \n\ | 2 \n\ | x dx\n\ | \n\ / \n\ 1/2 \ """ ucode_str = \ u("""\ 10 \n\ ⌠ \n\ ⎮ 2 \n\ ⎮ x dx\n\ ⌡ \n\ 1/2 \ """) assert pretty(expr) == ascii_str assert upretty(expr) == ucode_str expr = Integral(x**2*y**2, x, y) ascii_str = \ """\ / / \n\ | | \n\ | | 2 2 \n\ | | x *y dx dy\n\ | | \n\ / / \ """ ucode_str = \ u("""\ ⌠ ⌠ \n\ ⎮ ⎮ 2 2 \n\ ⎮ ⎮ x ⋅y dx dy\n\ ⌡ ⌡ \ """) assert pretty(expr) == ascii_str assert upretty(expr) == ucode_str expr = Integral(sin(th)/cos(ph), (th, 0, pi), (ph, 0, 2*pi)) ascii_str = \ """\ 2*pi pi \n\ / / \n\ | | \n\ | | sin(theta) \n\ | | ---------- d(theta) d(phi)\n\ | | cos(phi) \n\ | | \n\ / / \n\ 0 0 \ """ ucode_str = \ u("""\ 2⋅π π \n\ ⌠ ⌠ \n\ ⎮ ⎮ sin(θ) \n\ ⎮ ⎮ ────── dθ dφ\n\ ⎮ ⎮ cos(φ) \n\ ⌡ ⌡ \n\ 0 0 \ """) assert pretty(expr) == ascii_str assert upretty(expr) == ucode_str def test_pretty_matrix(): # Empty Matrix expr = Matrix() ascii_str = "[]" unicode_str = "[]" assert pretty(expr) == ascii_str assert upretty(expr) == unicode_str expr = Matrix(2, 0, lambda i, j: 0) ascii_str = "[]" unicode_str = "[]" assert pretty(expr) == ascii_str assert upretty(expr) == unicode_str expr = Matrix(0, 2, lambda i, j: 0) ascii_str = "[]" unicode_str = "[]" assert pretty(expr) == ascii_str assert upretty(expr) == unicode_str expr = Matrix([[x**2 + 1, 1], [y, x + y]]) ascii_str_1 = \ """\ [ 2 ] [1 + x 1 ] [ ] [ y x + y]\ """ ascii_str_2 = \ """\ [ 2 ] [x + 1 1 ] [ ] [ y x + y]\ """ ucode_str_1 = \ u("""\ ⎡ 2 ⎤ ⎢1 + x 1 ⎥ ⎢ ⎥ ⎣ y x + y⎦\ """) ucode_str_2 = \ u("""\ ⎡ 2 ⎤ ⎢x + 1 1 ⎥ ⎢ ⎥ ⎣ y x + y⎦\ """) assert pretty(expr) in [ascii_str_1, ascii_str_2] assert upretty(expr) in [ucode_str_1, ucode_str_2] expr = Matrix([[x/y, y, th], [0, exp(I*k*ph), 1]]) ascii_str = \ """\ [x ] [- y theta] [y ] [ ] [ I*k*phi ] [0 e 1 ]\ """ ucode_str = \ u("""\ ⎡x ⎤ ⎢─ y θ⎥ ⎢y ⎥ ⎢ ⎥ ⎢ ⅈ⋅k⋅φ ⎥ ⎣0 ℯ 1⎦\ """) assert pretty(expr) == ascii_str assert upretty(expr) == ucode_str def test_pretty_ndim_arrays(): x, y, z, w = symbols("x y z w") for ArrayType in (ImmutableDenseNDimArray, ImmutableSparseNDimArray, MutableDenseNDimArray, MutableSparseNDimArray): # Basic: scalar array M = ArrayType(x) assert pretty(M) == "x" assert upretty(M) == "x" M = ArrayType([[1/x, y], [z, w]]) M1 = ArrayType([1/x, y, z]) M2 = tensorproduct(M1, M) M3 = tensorproduct(M, M) ascii_str = \ """\ [1 ]\n\ [- y]\n\ [x ]\n\ [ ]\n\ [z w]\ """ ucode_str = \ u("""\ ⎡1 ⎤\n\ ⎢─ y⎥\n\ ⎢x ⎥\n\ ⎢ ⎥\n\ ⎣z w⎦\ """) assert pretty(M) == ascii_str assert upretty(M) == ucode_str ascii_str = \ """\ [1 ]\n\ [- y z]\n\ [x ]\ """ ucode_str = \ u("""\ ⎡1 ⎤\n\ ⎢─ y z⎥\n\ ⎣x ⎦\ """) assert pretty(M1) == ascii_str assert upretty(M1) == ucode_str ascii_str = \ """\ [[1 y] ]\n\ [[-- -] [z ]]\n\ [[ 2 x] [ y 2 ] [- y*z]]\n\ [[x ] [ - y ] [x ]]\n\ [[ ] [ x ] [ ]]\n\ [[z w] [ ] [ 2 ]]\n\ [[- -] [y*z w*y] [z w*z]]\n\ [[x x] ]\ """ ucode_str = \ u("""\ ⎡⎡1 y⎤ ⎤\n\ ⎢⎢── ─⎥ ⎡z ⎤⎥\n\ ⎢⎢ 2 x⎥ ⎡ y 2 ⎤ ⎢─ y⋅z⎥⎥\n\ ⎢⎢x ⎥ ⎢ ─ y ⎥ ⎢x ⎥⎥\n\ ⎢⎢ ⎥ ⎢ x ⎥ ⎢ ⎥⎥\n\ ⎢⎢z w⎥ ⎢ ⎥ ⎢ 2 ⎥⎥\n\ ⎢⎢─ ─⎥ ⎣y⋅z w⋅y⎦ ⎣z w⋅z⎦⎥\n\ ⎣⎣x x⎦ ⎦\ """) assert pretty(M2) == ascii_str assert upretty(M2) == ucode_str ascii_str = \ """\ [ [1 y] ]\n\ [ [-- -] ]\n\ [ [ 2 x] [ y 2 ]]\n\ [ [x ] [ - y ]]\n\ [ [ ] [ x ]]\n\ [ [z w] [ ]]\n\ [ [- -] [y*z w*y]]\n\ [ [x x] ]\n\ [ ]\n\ [[z ] [ w ]]\n\ [[- y*z] [ - w*y]]\n\ [[x ] [ x ]]\n\ [[ ] [ ]]\n\ [[ 2 ] [ 2 ]]\n\ [[z w*z] [w*z w ]]\ """ ucode_str = \ u("""\ ⎡ ⎡1 y⎤ ⎤\n\ ⎢ ⎢── ─⎥ ⎥\n\ ⎢ ⎢ 2 x⎥ ⎡ y 2 ⎤⎥\n\ ⎢ ⎢x ⎥ ⎢ ─ y ⎥⎥\n\ ⎢ ⎢ ⎥ ⎢ x ⎥⎥\n\ ⎢ ⎢z w⎥ ⎢ ⎥⎥\n\ ⎢ ⎢─ ─⎥ ⎣y⋅z w⋅y⎦⎥\n\ ⎢ ⎣x x⎦ ⎥\n\ ⎢ ⎥\n\ ⎢⎡z ⎤ ⎡ w ⎤⎥\n\ ⎢⎢─ y⋅z⎥ ⎢ ─ w⋅y⎥⎥\n\ ⎢⎢x ⎥ ⎢ x ⎥⎥\n\ ⎢⎢ ⎥ ⎢ ⎥⎥\n\ ⎢⎢ 2 ⎥ ⎢ 2 ⎥⎥\n\ ⎣⎣z w⋅z⎦ ⎣w⋅z w ⎦⎦\ """) assert pretty(M3) == ascii_str assert upretty(M3) == ucode_str Mrow = ArrayType([[x, y, 1 / z]]) Mcolumn = ArrayType([[x], [y], [1 / z]]) Mcol2 = ArrayType([Mcolumn.tolist()]) ascii_str = \ """\ [[ 1]]\n\ [[x y -]]\n\ [[ z]]\ """ ucode_str = \ u("""\ ⎡⎡ 1⎤⎤\n\ ⎢⎢x y ─⎥⎥\n\ ⎣⎣ z⎦⎦\ """) assert pretty(Mrow) == ascii_str assert upretty(Mrow) == ucode_str ascii_str = \ """\ [x]\n\ [ ]\n\ [y]\n\ [ ]\n\ [1]\n\ [-]\n\ [z]\ """ ucode_str = \ u("""\ ⎡x⎤\n\ ⎢ ⎥\n\ ⎢y⎥\n\ ⎢ ⎥\n\ ⎢1⎥\n\ ⎢─⎥\n\ ⎣z⎦\ """) assert pretty(Mcolumn) == ascii_str assert upretty(Mcolumn) == ucode_str ascii_str = \ """\ [[x]]\n\ [[ ]]\n\ [[y]]\n\ [[ ]]\n\ [[1]]\n\ [[-]]\n\ [[z]]\ """ ucode_str = \ u("""\ ⎡⎡x⎤⎤\n\ ⎢⎢ ⎥⎥\n\ ⎢⎢y⎥⎥\n\ ⎢⎢ ⎥⎥\n\ ⎢⎢1⎥⎥\n\ ⎢⎢─⎥⎥\n\ ⎣⎣z⎦⎦\ """) assert pretty(Mcol2) == ascii_str assert upretty(Mcol2) == ucode_str def test_tensor_TensorProduct(): A = MatrixSymbol("A", 3, 3) B = MatrixSymbol("B", 3, 3) assert upretty(TensorProduct(A, B)) == "A\u2297B" assert upretty(TensorProduct(A, B, A)) == "A\u2297B\u2297A" def test_diffgeom_print_WedgeProduct(): from sympy.diffgeom.rn import R2 from sympy.diffgeom import WedgeProduct wp = WedgeProduct(R2.dx, R2.dy) assert upretty(wp) == u("ⅆ x∧ⅆ y") def test_Adjoint(): X = MatrixSymbol('X', 2, 2) Y = MatrixSymbol('Y', 2, 2) assert pretty(Adjoint(X)) == " +\nX " assert pretty(Adjoint(X + Y)) == " +\n(X + Y) " assert pretty(Adjoint(X) + Adjoint(Y)) == " + +\nX + Y " assert pretty(Adjoint(X*Y)) == " +\n(X*Y) " assert pretty(Adjoint(Y)*Adjoint(X)) == " + +\nY *X " assert pretty(Adjoint(X**2)) == " +\n/ 2\\ \n\\X / " assert pretty(Adjoint(X)**2) == " 2\n/ +\\ \n\\X / " assert pretty(Adjoint(Inverse(X))) == " +\n/ -1\\ \n\\X / " assert pretty(Inverse(Adjoint(X))) == " -1\n/ +\\ \n\\X / " assert pretty(Adjoint(Transpose(X))) == " +\n/ T\\ \n\\X / " assert pretty(Transpose(Adjoint(X))) == " T\n/ +\\ \n\\X / " assert upretty(Adjoint(X)) == u" †\nX " assert upretty(Adjoint(X + Y)) == u" †\n(X + Y) " assert upretty(Adjoint(X) + Adjoint(Y)) == u" † †\nX + Y " assert upretty(Adjoint(X*Y)) == u" †\n(X⋅Y) " assert upretty(Adjoint(Y)*Adjoint(X)) == u" † †\nY ⋅X " assert upretty(Adjoint(X**2)) == \ u" †\n⎛ 2⎞ \n⎝X ⎠ " assert upretty(Adjoint(X)**2) == \ u" 2\n⎛ †⎞ \n⎝X ⎠ " assert upretty(Adjoint(Inverse(X))) == \ u" †\n⎛ -1⎞ \n⎝X ⎠ " assert upretty(Inverse(Adjoint(X))) == \ u" -1\n⎛ †⎞ \n⎝X ⎠ " assert upretty(Adjoint(Transpose(X))) == \ u" †\n⎛ T⎞ \n⎝X ⎠ " assert upretty(Transpose(Adjoint(X))) == \ u" T\n⎛ †⎞ \n⎝X ⎠ " def test_pretty_Trace_issue_9044(): X = Matrix([[1, 2], [3, 4]]) Y = Matrix([[2, 4], [6, 8]]) ascii_str_1 = \ """\ /[1 2]\\ tr|[ ]| \\[3 4]/\ """ ucode_str_1 = \ u("""\ ⎛⎡1 2⎤⎞ tr⎜⎢ ⎥⎟ ⎝⎣3 4⎦⎠\ """) ascii_str_2 = \ """\ /[1 2]\\ /[2 4]\\ tr|[ ]| + tr|[ ]| \\[3 4]/ \\[6 8]/\ """ ucode_str_2 = \ u("""\ ⎛⎡1 2⎤⎞ ⎛⎡2 4⎤⎞ tr⎜⎢ ⎥⎟ + tr⎜⎢ ⎥⎟ ⎝⎣3 4⎦⎠ ⎝⎣6 8⎦⎠\ """) assert pretty(Trace(X)) == ascii_str_1 assert upretty(Trace(X)) == ucode_str_1 assert pretty(Trace(X) + Trace(Y)) == ascii_str_2 assert upretty(Trace(X) + Trace(Y)) == ucode_str_2 def test_MatrixExpressions(): n = Symbol('n', integer=True) X = MatrixSymbol('X', n, n) assert pretty(X) == upretty(X) == "X" Y = X[1:2:3, 4:5:6] ascii_str = ucode_str = "X[1:3, 4:6]" assert pretty(Y) == ascii_str assert upretty(Y) == ucode_str Z = X[1:10:2] ascii_str = ucode_str = "X[1:10:2, :n]" assert pretty(Z) == ascii_str assert upretty(Z) == ucode_str def test_pretty_dotproduct(): from sympy.matrices import Matrix, MatrixSymbol from sympy.matrices.expressions.dotproduct import DotProduct n = symbols("n", integer=True) A = MatrixSymbol('A', n, 1) B = MatrixSymbol('B', n, 1) C = Matrix(1, 3, [1, 2, 3]) D = Matrix(1, 3, [1, 3, 4]) assert pretty(DotProduct(A, B)) == u"A*B" assert pretty(DotProduct(C, D)) == u"[1 2 3]*[1 3 4]" assert upretty(DotProduct(A, B)) == u"A⋅B" assert upretty(DotProduct(C, D)) == u"[1 2 3]⋅[1 3 4]" def test_pretty_piecewise(): expr = Piecewise((x, x < 1), (x**2, True)) ascii_str = \ """\ /x for x < 1\n\ | \n\ < 2 \n\ |x otherwise\n\ \\ \ """ ucode_str = \ u("""\ ⎧x for x < 1\n\ ⎪ \n\ ⎨ 2 \n\ ⎪x otherwise\n\ ⎩ \ """) assert pretty(expr) == ascii_str assert upretty(expr) == ucode_str expr = -Piecewise((x, x < 1), (x**2, True)) ascii_str = \ """\ //x for x < 1\\\n\ || |\n\ -|< 2 |\n\ ||x otherwise|\n\ \\\\ /\ """ ucode_str = \ u("""\ ⎛⎧x for x < 1⎞\n\ ⎜⎪ ⎟\n\ -⎜⎨ 2 ⎟\n\ ⎜⎪x otherwise⎟\n\ ⎝⎩ ⎠\ """) assert pretty(expr) == ascii_str assert upretty(expr) == ucode_str expr = x + Piecewise((x, x > 0), (y, True)) + Piecewise((x/y, x < 2), (y**2, x > 2), (1, True)) + 1 ascii_str = \ """\ //x \\ \n\ ||- for x < 2| \n\ ||y | \n\ //x for x > 0\\ || | \n\ x + |< | + |< 2 | + 1\n\ \\\\y otherwise/ ||y for x > 2| \n\ || | \n\ ||1 otherwise| \n\ \\\\ / \ """ ucode_str = \ u("""\ ⎛⎧x ⎞ \n\ ⎜⎪─ for x < 2⎟ \n\ ⎜⎪y ⎟ \n\ ⎛⎧x for x > 0⎞ ⎜⎪ ⎟ \n\ x + ⎜⎨ ⎟ + ⎜⎨ 2 ⎟ + 1\n\ ⎝⎩y otherwise⎠ ⎜⎪y for x > 2⎟ \n\ ⎜⎪ ⎟ \n\ ⎜⎪1 otherwise⎟ \n\ ⎝⎩ ⎠ \ """) assert pretty(expr) == ascii_str assert upretty(expr) == ucode_str expr = x - Piecewise((x, x > 0), (y, True)) + Piecewise((x/y, x < 2), (y**2, x > 2), (1, True)) + 1 ascii_str = \ """\ //x \\ \n\ ||- for x < 2| \n\ ||y | \n\ //x for x > 0\\ || | \n\ x - |< | + |< 2 | + 1\n\ \\\\y otherwise/ ||y for x > 2| \n\ || | \n\ ||1 otherwise| \n\ \\\\ / \ """ ucode_str = \ u("""\ ⎛⎧x ⎞ \n\ ⎜⎪─ for x < 2⎟ \n\ ⎜⎪y ⎟ \n\ ⎛⎧x for x > 0⎞ ⎜⎪ ⎟ \n\ x - ⎜⎨ ⎟ + ⎜⎨ 2 ⎟ + 1\n\ ⎝⎩y otherwise⎠ ⎜⎪y for x > 2⎟ \n\ ⎜⎪ ⎟ \n\ ⎜⎪1 otherwise⎟ \n\ ⎝⎩ ⎠ \ """) assert pretty(expr) == ascii_str assert upretty(expr) == ucode_str expr = x*Piecewise((x, x > 0), (y, True)) ascii_str = \ """\ //x for x > 0\\\n\ x*|< |\n\ \\\\y otherwise/\ """ ucode_str = \ u("""\ ⎛⎧x for x > 0⎞\n\ x⋅⎜⎨ ⎟\n\ ⎝⎩y otherwise⎠\ """) assert pretty(expr) == ascii_str assert upretty(expr) == ucode_str expr = Piecewise((x, x > 0), (y, True))*Piecewise((x/y, x < 2), (y**2, x > 2), (1, True)) ascii_str = \ """\ //x \\\n\ ||- for x < 2|\n\ ||y |\n\ //x for x > 0\\ || |\n\ |< |*|< 2 |\n\ \\\\y otherwise/ ||y for x > 2|\n\ || |\n\ ||1 otherwise|\n\ \\\\ /\ """ ucode_str = \ u("""\ ⎛⎧x ⎞\n\ ⎜⎪─ for x < 2⎟\n\ ⎜⎪y ⎟\n\ ⎛⎧x for x > 0⎞ ⎜⎪ ⎟\n\ ⎜⎨ ⎟⋅⎜⎨ 2 ⎟\n\ ⎝⎩y otherwise⎠ ⎜⎪y for x > 2⎟\n\ ⎜⎪ ⎟\n\ ⎜⎪1 otherwise⎟\n\ ⎝⎩ ⎠\ """) assert pretty(expr) == ascii_str assert upretty(expr) == ucode_str expr = -Piecewise((x, x > 0), (y, True))*Piecewise((x/y, x < 2), (y**2, x > 2), (1, True)) ascii_str = \ """\ //x \\\n\ ||- for x < 2|\n\ ||y |\n\ //x for x > 0\\ || |\n\ -|< |*|< 2 |\n\ \\\\y otherwise/ ||y for x > 2|\n\ || |\n\ ||1 otherwise|\n\ \\\\ /\ """ ucode_str = \ u("""\ ⎛⎧x ⎞\n\ ⎜⎪─ for x < 2⎟\n\ ⎜⎪y ⎟\n\ ⎛⎧x for x > 0⎞ ⎜⎪ ⎟\n\ -⎜⎨ ⎟⋅⎜⎨ 2 ⎟\n\ ⎝⎩y otherwise⎠ ⎜⎪y for x > 2⎟\n\ ⎜⎪ ⎟\n\ ⎜⎪1 otherwise⎟\n\ ⎝⎩ ⎠\ """) assert pretty(expr) == ascii_str assert upretty(expr) == ucode_str expr = Piecewise((0, Abs(1/y) < 1), (1, Abs(y) < 1), (y*meijerg(((2, 1), ()), ((), (1, 0)), 1/y), True)) ascii_str = \ """\ / |1| \n\ | 0 for |-| < 1\n\ | |y| \n\ | \n\ < 1 for |y| < 1\n\ | \n\ | __0, 2 /2, 1 | 1\\ \n\ |y*/__ | | -| otherwise \n\ \\ \\_|2, 2 \\ 1, 0 | y/ \ """ ucode_str = \ u("""\ ⎧ │1│ \n\ ⎪ 0 for │─│ < 1\n\ ⎪ │y│ \n\ ⎪ \n\ ⎨ 1 for │y│ < 1\n\ ⎪ \n\ ⎪ ╭─╮0, 2 ⎛2, 1 │ 1⎞ \n\ ⎪y⋅│╶┐ ⎜ │ ─⎟ otherwise \n\ ⎩ ╰─╯2, 2 ⎝ 1, 0 │ y⎠ \ """) assert pretty(expr) == ascii_str assert upretty(expr) == ucode_str # XXX: We have to use evaluate=False here because Piecewise._eval_power # denests the power. expr = Pow(Piecewise((x, x > 0), (y, True)), 2, evaluate=False) ascii_str = \ """\ 2\n\ //x for x > 0\\ \n\ |< | \n\ \\\\y otherwise/ \ """ ucode_str = \ u("""\ 2\n\ ⎛⎧x for x > 0⎞ \n\ ⎜⎨ ⎟ \n\ ⎝⎩y otherwise⎠ \ """) assert pretty(expr) == ascii_str assert upretty(expr) == ucode_str def test_pretty_ITE(): expr = ITE(x, y, z) assert pretty(expr) == ( '/y for x \n' '< \n' '\\z otherwise' ) assert upretty(expr) == u("""\ ⎧y for x \n\ ⎨ \n\ ⎩z otherwise\ """) def test_pretty_seq(): expr = () ascii_str = \ """\ ()\ """ ucode_str = \ u("""\ ()\ """) assert pretty(expr) == ascii_str assert upretty(expr) == ucode_str expr = [] ascii_str = \ """\ []\ """ ucode_str = \ u("""\ []\ """) assert pretty(expr) == ascii_str assert upretty(expr) == ucode_str expr = {} expr_2 = {} ascii_str = \ """\ {}\ """ ucode_str = \ u("""\ {}\ """) assert pretty(expr) == ascii_str assert pretty(expr_2) == ascii_str assert upretty(expr) == ucode_str assert upretty(expr_2) == ucode_str expr = (1/x,) ascii_str = \ """\ 1 \n\ (-,)\n\ x \ """ ucode_str = \ u("""\ ⎛1 ⎞\n\ ⎜─,⎟\n\ ⎝x ⎠\ """) assert pretty(expr) == ascii_str assert upretty(expr) == ucode_str expr = [x**2, 1/x, x, y, sin(th)**2/cos(ph)**2] ascii_str = \ """\ 2 \n\ 2 1 sin (theta) \n\ [x , -, x, y, -----------]\n\ x 2 \n\ cos (phi) \ """ ucode_str = \ u("""\ ⎡ 2 ⎤\n\ ⎢ 2 1 sin (θ)⎥\n\ ⎢x , ─, x, y, ───────⎥\n\ ⎢ x 2 ⎥\n\ ⎣ cos (φ)⎦\ """) assert pretty(expr) == ascii_str assert upretty(expr) == ucode_str expr = (x**2, 1/x, x, y, sin(th)**2/cos(ph)**2) ascii_str = \ """\ 2 \n\ 2 1 sin (theta) \n\ (x , -, x, y, -----------)\n\ x 2 \n\ cos (phi) \ """ ucode_str = \ u("""\ ⎛ 2 ⎞\n\ ⎜ 2 1 sin (θ)⎟\n\ ⎜x , ─, x, y, ───────⎟\n\ ⎜ x 2 ⎟\n\ ⎝ cos (φ)⎠\ """) assert pretty(expr) == ascii_str assert upretty(expr) == ucode_str expr = Tuple(x**2, 1/x, x, y, sin(th)**2/cos(ph)**2) ascii_str = \ """\ 2 \n\ 2 1 sin (theta) \n\ (x , -, x, y, -----------)\n\ x 2 \n\ cos (phi) \ """ ucode_str = \ u("""\ ⎛ 2 ⎞\n\ ⎜ 2 1 sin (θ)⎟\n\ ⎜x , ─, x, y, ───────⎟\n\ ⎜ x 2 ⎟\n\ ⎝ cos (φ)⎠\ """) assert pretty(expr) == ascii_str assert upretty(expr) == ucode_str expr = {x: sin(x)} expr_2 = Dict({x: sin(x)}) ascii_str = \ """\ {x: sin(x)}\ """ ucode_str = \ u("""\ {x: sin(x)}\ """) assert pretty(expr) == ascii_str assert pretty(expr_2) == ascii_str assert upretty(expr) == ucode_str assert upretty(expr_2) == ucode_str expr = {1/x: 1/y, x: sin(x)**2} expr_2 = Dict({1/x: 1/y, x: sin(x)**2}) ascii_str = \ """\ 1 1 2 \n\ {-: -, x: sin (x)}\n\ x y \ """ ucode_str = \ u("""\ ⎧1 1 2 ⎫\n\ ⎨─: ─, x: sin (x)⎬\n\ ⎩x y ⎭\ """) assert pretty(expr) == ascii_str assert pretty(expr_2) == ascii_str assert upretty(expr) == ucode_str assert upretty(expr_2) == ucode_str # There used to be a bug with pretty-printing sequences of even height. expr = [x**2] ascii_str = \ """\ 2 \n\ [x ]\ """ ucode_str = \ u("""\ ⎡ 2⎤\n\ ⎣x ⎦\ """) assert pretty(expr) == ascii_str assert upretty(expr) == ucode_str expr = (x**2,) ascii_str = \ """\ 2 \n\ (x ,)\ """ ucode_str = \ u("""\ ⎛ 2 ⎞\n\ ⎝x ,⎠\ """) assert pretty(expr) == ascii_str assert upretty(expr) == ucode_str expr = Tuple(x**2) ascii_str = \ """\ 2 \n\ (x ,)\ """ ucode_str = \ u("""\ ⎛ 2 ⎞\n\ ⎝x ,⎠\ """) assert pretty(expr) == ascii_str assert upretty(expr) == ucode_str expr = {x**2: 1} expr_2 = Dict({x**2: 1}) ascii_str = \ """\ 2 \n\ {x : 1}\ """ ucode_str = \ u("""\ ⎧ 2 ⎫\n\ ⎨x : 1⎬\n\ ⎩ ⎭\ """) assert pretty(expr) == ascii_str assert pretty(expr_2) == ascii_str assert upretty(expr) == ucode_str assert upretty(expr_2) == ucode_str def test_any_object_in_sequence(): # Cf. issue 5306 b1 = Basic() b2 = Basic(Basic()) expr = [b2, b1] assert pretty(expr) == "[Basic(Basic()), Basic()]" assert upretty(expr) == u"[Basic(Basic()), Basic()]" expr = {b2, b1} assert pretty(expr) == "{Basic(), Basic(Basic())}" assert upretty(expr) == u"{Basic(), Basic(Basic())}" expr = {b2: b1, b1: b2} expr2 = Dict({b2: b1, b1: b2}) assert pretty(expr) == "{Basic(): Basic(Basic()), Basic(Basic()): Basic()}" assert pretty( expr2) == "{Basic(): Basic(Basic()), Basic(Basic()): Basic()}" assert upretty( expr) == u"{Basic(): Basic(Basic()), Basic(Basic()): Basic()}" assert upretty( expr2) == u"{Basic(): Basic(Basic()), Basic(Basic()): Basic()}" def test_print_builtin_set(): assert pretty(set()) == 'set()' assert upretty(set()) == u'set()' assert pretty(frozenset()) == 'frozenset()' assert upretty(frozenset()) == u'frozenset()' s1 = {1/x, x} s2 = frozenset(s1) assert pretty(s1) == \ """\ 1 \n\ {-, x} x \ """ assert upretty(s1) == \ u"""\ ⎧1 ⎫ ⎨─, x⎬ ⎩x ⎭\ """ assert pretty(s2) == \ """\ 1 \n\ frozenset({-, x}) x \ """ assert upretty(s2) == \ u"""\ ⎛⎧1 ⎫⎞ frozenset⎜⎨─, x⎬⎟ ⎝⎩x ⎭⎠\ """ def test_pretty_sets(): s = FiniteSet assert pretty(s(*[x*y, x**2])) == \ """\ 2 \n\ {x , x*y}\ """ assert pretty(s(*range(1, 6))) == "{1, 2, 3, 4, 5}" assert pretty(s(*range(1, 13))) == "{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12}" assert pretty(set([x*y, x**2])) == \ """\ 2 \n\ {x , x*y}\ """ assert pretty(set(range(1, 6))) == "{1, 2, 3, 4, 5}" assert pretty(set(range(1, 13))) == \ "{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12}" assert pretty(frozenset([x*y, x**2])) == \ """\ 2 \n\ frozenset({x , x*y})\ """ assert pretty(frozenset(range(1, 6))) == "frozenset({1, 2, 3, 4, 5})" assert pretty(frozenset(range(1, 13))) == \ "frozenset({1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12})" assert pretty(Range(0, 3, 1)) == '{0, 1, 2}' ascii_str = '{0, 1, ..., 29}' ucode_str = u'{0, 1, …, 29}' assert pretty(Range(0, 30, 1)) == ascii_str assert upretty(Range(0, 30, 1)) == ucode_str ascii_str = '{30, 29, ..., 2}' ucode_str = u('{30, 29, …, 2}') assert pretty(Range(30, 1, -1)) == ascii_str assert upretty(Range(30, 1, -1)) == ucode_str ascii_str = '{0, 2, ...}' ucode_str = u'{0, 2, …}' assert pretty(Range(0, oo, 2)) == ascii_str assert upretty(Range(0, oo, 2)) == ucode_str ascii_str = '{..., 2, 0}' ucode_str = u('{…, 2, 0}') assert pretty(Range(oo, -2, -2)) == ascii_str assert upretty(Range(oo, -2, -2)) == ucode_str ascii_str = '{-2, -3, ...}' ucode_str = u('{-2, -3, …}') assert pretty(Range(-2, -oo, -1)) == ascii_str assert upretty(Range(-2, -oo, -1)) == ucode_str def test_pretty_SetExpr(): iv = Interval(1, 3) se = SetExpr(iv) ascii_str = "SetExpr([1, 3])" ucode_str = u("SetExpr([1, 3])") assert pretty(se) == ascii_str assert upretty(se) == ucode_str def test_pretty_ImageSet(): imgset = ImageSet(Lambda((x, y), x + y), {1, 2, 3}, {3, 4}) ascii_str = '{x + y | x in {1, 2, 3} , y in {3, 4}}' ucode_str = u('{x + y | x ∊ {1, 2, 3} , y ∊ {3, 4}}') assert pretty(imgset) == ascii_str assert upretty(imgset) == ucode_str imgset = ImageSet(Lambda(x, x**2), S.Naturals) ascii_str = \ ' 2 \n'\ '{x | x in Naturals}' ucode_str = u('''\ ⎧ 2 ⎫\n\ ⎨x | x ∊ ℕ⎬\n\ ⎩ ⎭''') assert pretty(imgset) == ascii_str assert upretty(imgset) == ucode_str def test_pretty_ConditionSet(): from sympy import ConditionSet ascii_str = '{x | x in (-oo, oo) and sin(x) = 0}' ucode_str = u'{x | x ∊ ℝ ∧ sin(x) = 0}' assert pretty(ConditionSet(x, Eq(sin(x), 0), S.Reals)) == ascii_str assert upretty(ConditionSet(x, Eq(sin(x), 0), S.Reals)) == ucode_str assert pretty(ConditionSet(x, Contains(x, S.Reals, evaluate=False), FiniteSet(1))) == '{1}' assert upretty(ConditionSet(x, Contains(x, S.Reals, evaluate=False), FiniteSet(1))) == u'{1}' assert pretty(ConditionSet(x, And(x > 1, x < -1), FiniteSet(1, 2, 3))) == "EmptySet()" assert upretty(ConditionSet(x, And(x > 1, x < -1), FiniteSet(1, 2, 3))) == u"∅" assert pretty(ConditionSet(x, Or(x > 1, x < -1), FiniteSet(1, 2))) == '{2}' assert upretty(ConditionSet(x, Or(x > 1, x < -1), FiniteSet(1, 2))) == u'{2}' def test_pretty_ComplexRegion(): from sympy import ComplexRegion ucode_str = u'{x + y⋅ⅈ | x, y ∊ [3, 5] × [4, 6]}' assert upretty(ComplexRegion(Interval(3, 5)*Interval(4, 6))) == ucode_str ucode_str = u'{r⋅(ⅈ⋅sin(θ) + cos(θ)) | r, θ ∊ [0, 1] × [0, 2⋅π)}' assert upretty(ComplexRegion(Interval(0, 1)*Interval(0, 2*pi), polar=True)) == ucode_str def test_pretty_Union_issue_10414(): a, b = Interval(2, 3), Interval(4, 7) ucode_str = u'[2, 3] ∪ [4, 7]' ascii_str = '[2, 3] U [4, 7]' assert upretty(Union(a, b)) == ucode_str assert pretty(Union(a, b)) == ascii_str def test_pretty_Intersection_issue_10414(): x, y, z, w = symbols('x, y, z, w') a, b = Interval(x, y), Interval(z, w) ucode_str = u'[x, y] ∩ [z, w]' ascii_str = '[x, y] n [z, w]' assert upretty(Intersection(a, b)) == ucode_str assert pretty(Intersection(a, b)) == ascii_str def test_ProductSet_paranthesis(): ucode_str = u'([4, 7] × {1, 2}) ∪ ([2, 3] × [4, 7])' a, b, c = Interval(2, 3), Interval(4, 7), Interval(1, 9) assert upretty(Union(a*b, b*FiniteSet(1, 2))) == ucode_str def test_ProductSet_prod_char_issue_10413(): ascii_str = '[2, 3] x [4, 7]' ucode_str = u'[2, 3] × [4, 7]' a, b = Interval(2, 3), Interval(4, 7) assert pretty(a*b) == ascii_str assert upretty(a*b) == ucode_str def test_pretty_sequences(): s1 = SeqFormula(a**2, (0, oo)) s2 = SeqPer((1, 2)) ascii_str = '[0, 1, 4, 9, ...]' ucode_str = u'[0, 1, 4, 9, …]' assert pretty(s1) == ascii_str assert upretty(s1) == ucode_str ascii_str = '[1, 2, 1, 2, ...]' ucode_str = u'[1, 2, 1, 2, …]' assert pretty(s2) == ascii_str assert upretty(s2) == ucode_str s3 = SeqFormula(a**2, (0, 2)) s4 = SeqPer((1, 2), (0, 2)) ascii_str = '[0, 1, 4]' ucode_str = u'[0, 1, 4]' assert pretty(s3) == ascii_str assert upretty(s3) == ucode_str ascii_str = '[1, 2, 1]' ucode_str = u'[1, 2, 1]' assert pretty(s4) == ascii_str assert upretty(s4) == ucode_str s5 = SeqFormula(a**2, (-oo, 0)) s6 = SeqPer((1, 2), (-oo, 0)) ascii_str = '[..., 9, 4, 1, 0]' ucode_str = u'[…, 9, 4, 1, 0]' assert pretty(s5) == ascii_str assert upretty(s5) == ucode_str ascii_str = '[..., 2, 1, 2, 1]' ucode_str = u'[…, 2, 1, 2, 1]' assert pretty(s6) == ascii_str assert upretty(s6) == ucode_str ascii_str = '[1, 3, 5, 11, ...]' ucode_str = u'[1, 3, 5, 11, …]' assert pretty(SeqAdd(s1, s2)) == ascii_str assert upretty(SeqAdd(s1, s2)) == ucode_str ascii_str = '[1, 3, 5]' ucode_str = u'[1, 3, 5]' assert pretty(SeqAdd(s3, s4)) == ascii_str assert upretty(SeqAdd(s3, s4)) == ucode_str ascii_str = '[..., 11, 5, 3, 1]' ucode_str = u'[…, 11, 5, 3, 1]' assert pretty(SeqAdd(s5, s6)) == ascii_str assert upretty(SeqAdd(s5, s6)) == ucode_str ascii_str = '[0, 2, 4, 18, ...]' ucode_str = u'[0, 2, 4, 18, …]' assert pretty(SeqMul(s1, s2)) == ascii_str assert upretty(SeqMul(s1, s2)) == ucode_str ascii_str = '[0, 2, 4]' ucode_str = u'[0, 2, 4]' assert pretty(SeqMul(s3, s4)) == ascii_str assert upretty(SeqMul(s3, s4)) == ucode_str ascii_str = '[..., 18, 4, 2, 0]' ucode_str = u'[…, 18, 4, 2, 0]' assert pretty(SeqMul(s5, s6)) == ascii_str assert upretty(SeqMul(s5, s6)) == ucode_str # Sequences with symbolic limits, issue 12629 s7 = SeqFormula(a**2, (a, 0, x)) raises(NotImplementedError, lambda: pretty(s7)) raises(NotImplementedError, lambda: upretty(s7)) b = Symbol('b') s8 = SeqFormula(b*a**2, (a, 0, 2)) ascii_str = u'[0, b, 4*b]' ucode_str = u'[0, b, 4⋅b]' assert pretty(s8) == ascii_str assert upretty(s8) == ucode_str def test_pretty_FourierSeries(): f = fourier_series(x, (x, -pi, pi)) ascii_str = \ """\ 2*sin(3*x) \n\ 2*sin(x) - sin(2*x) + ---------- + ...\n\ 3 \ """ ucode_str = \ u("""\ 2⋅sin(3⋅x) \n\ 2⋅sin(x) - sin(2⋅x) + ────────── + …\n\ 3 \ """) assert pretty(f) == ascii_str assert upretty(f) == ucode_str def test_pretty_FormalPowerSeries(): f = fps(log(1 + x)) ascii_str = \ """\ oo \n\ ____ \n\ \\ ` \n\ \\ -k k \n\ \\ -(-1) *x \n\ / -----------\n\ / k \n\ /___, \n\ k = 1 \ """ ucode_str = \ u("""\ ∞ \n\ ____ \n\ ╲ \n\ ╲ -k k \n\ ╲ -(-1) ⋅x \n\ ╱ ───────────\n\ ╱ k \n\ ╱ \n\ ‾‾‾‾ \n\ k = 1 \ """) assert pretty(f) == ascii_str assert upretty(f) == ucode_str def test_pretty_limits(): expr = Limit(x, x, oo) ascii_str = \ """\ lim x\n\ x->oo \ """ ucode_str = \ u("""\ lim x\n\ x─→∞ \ """) assert pretty(expr) == ascii_str assert upretty(expr) == ucode_str expr = Limit(x**2, x, 0) ascii_str = \ """\ 2\n\ lim x \n\ x->0+ \ """ ucode_str = \ u("""\ 2\n\ lim x \n\ x─→0⁺ \ """) assert pretty(expr) == ascii_str assert upretty(expr) == ucode_str expr = Limit(1/x, x, 0) ascii_str = \ """\ 1\n\ lim -\n\ x->0+x\ """ ucode_str = \ u("""\ 1\n\ lim ─\n\ x─→0⁺x\ """) assert pretty(expr) == ascii_str assert upretty(expr) == ucode_str expr = Limit(sin(x)/x, x, 0) ascii_str = \ """\ /sin(x)\\\n\ lim |------|\n\ x->0+\\ x /\ """ ucode_str = \ u("""\ ⎛sin(x)⎞\n\ lim ⎜──────⎟\n\ x─→0⁺⎝ x ⎠\ """) assert pretty(expr) == ascii_str assert upretty(expr) == ucode_str expr = Limit(sin(x)/x, x, 0, "-") ascii_str = \ """\ /sin(x)\\\n\ lim |------|\n\ x->0-\\ x /\ """ ucode_str = \ u("""\ ⎛sin(x)⎞\n\ lim ⎜──────⎟\n\ x─→0⁻⎝ x ⎠\ """) assert pretty(expr) == ascii_str assert upretty(expr) == ucode_str expr = Limit(x + sin(x), x, 0) ascii_str = \ """\ lim (x + sin(x))\n\ x->0+ \ """ ucode_str = \ u("""\ lim (x + sin(x))\n\ x─→0⁺ \ """) assert pretty(expr) == ascii_str assert upretty(expr) == ucode_str expr = Limit(x, x, 0)**2 ascii_str = \ """\ 2\n\ / lim x\\ \n\ \\x->0+ / \ """ ucode_str = \ u("""\ 2\n\ ⎛ lim x⎞ \n\ ⎝x─→0⁺ ⎠ \ """) assert pretty(expr) == ascii_str assert upretty(expr) == ucode_str expr = Limit(x*Limit(y/2,y,0), x, 0) ascii_str = \ """\ / /y\\\\\n\ lim |x* lim |-||\n\ x->0+\\ y->0+\\2//\ """ ucode_str = \ u("""\ ⎛ ⎛y⎞⎞\n\ lim ⎜x⋅ lim ⎜─⎟⎟\n\ x─→0⁺⎝ y─→0⁺⎝2⎠⎠\ """) assert pretty(expr) == ascii_str assert upretty(expr) == ucode_str expr = 2*Limit(x*Limit(y/2,y,0), x, 0) ascii_str = \ """\ / /y\\\\\n\ 2* lim |x* lim |-||\n\ x->0+\\ y->0+\\2//\ """ ucode_str = \ u("""\ ⎛ ⎛y⎞⎞\n\ 2⋅ lim ⎜x⋅ lim ⎜─⎟⎟\n\ x─→0⁺⎝ y─→0⁺⎝2⎠⎠\ """) assert pretty(expr) == ascii_str assert upretty(expr) == ucode_str expr = Limit(sin(x), x, 0, dir='+-') ascii_str = \ """\ lim sin(x)\n\ x->0 \ """ ucode_str = \ u("""\ lim sin(x)\n\ x─→0 \ """) assert pretty(expr) == ascii_str assert upretty(expr) == ucode_str def test_pretty_ComplexRootOf(): expr = rootof(x**5 + 11*x - 2, 0) ascii_str = \ """\ / 5 \\\n\ CRootOf\\x + 11*x - 2, 0/\ """ ucode_str = \ u("""\ ⎛ 5 ⎞\n\ CRootOf⎝x + 11⋅x - 2, 0⎠\ """) assert pretty(expr) == ascii_str assert upretty(expr) == ucode_str def test_pretty_RootSum(): expr = RootSum(x**5 + 11*x - 2, auto=False) ascii_str = \ """\ / 5 \\\n\ RootSum\\x + 11*x - 2/\ """ ucode_str = \ u("""\ ⎛ 5 ⎞\n\ RootSum⎝x + 11⋅x - 2⎠\ """) assert pretty(expr) == ascii_str assert upretty(expr) == ucode_str expr = RootSum(x**5 + 11*x - 2, Lambda(z, exp(z))) ascii_str = \ """\ / 5 z\\\n\ RootSum\\x + 11*x - 2, z -> e /\ """ ucode_str = \ u("""\ ⎛ 5 z⎞\n\ RootSum⎝x + 11⋅x - 2, z ↦ ℯ ⎠\ """) assert pretty(expr) == ascii_str assert upretty(expr) == ucode_str def test_GroebnerBasis(): expr = groebner([], x, y) ascii_str = \ """\ GroebnerBasis([], x, y, domain=ZZ, order=lex)\ """ ucode_str = \ u("""\ GroebnerBasis([], x, y, domain=ℤ, order=lex)\ """) assert pretty(expr) == ascii_str assert upretty(expr) == ucode_str F = [x**2 - 3*y - x + 1, y**2 - 2*x + y - 1] expr = groebner(F, x, y, order='grlex') ascii_str = \ """\ /[ 2 2 ] \\\n\ GroebnerBasis\\[x - x - 3*y + 1, y - 2*x + y - 1], x, y, domain=ZZ, order=grlex/\ """ ucode_str = \ u("""\ ⎛⎡ 2 2 ⎤ ⎞\n\ GroebnerBasis⎝⎣x - x - 3⋅y + 1, y - 2⋅x + y - 1⎦, x, y, domain=ℤ, order=grlex⎠\ """) assert pretty(expr) == ascii_str assert upretty(expr) == ucode_str expr = expr.fglm('lex') ascii_str = \ """\ /[ 2 4 3 2 ] \\\n\ GroebnerBasis\\[2*x - y - y + 1, y + 2*y - 3*y - 16*y + 7], x, y, domain=ZZ, order=lex/\ """ ucode_str = \ u("""\ ⎛⎡ 2 4 3 2 ⎤ ⎞\n\ GroebnerBasis⎝⎣2⋅x - y - y + 1, y + 2⋅y - 3⋅y - 16⋅y + 7⎦, x, y, domain=ℤ, order=lex⎠\ """) assert pretty(expr) == ascii_str assert upretty(expr) == ucode_str def test_pretty_Boolean(): expr = Not(x, evaluate=False) assert pretty(expr) == "Not(x)" assert upretty(expr) == u"¬x" expr = And(x, y) assert pretty(expr) == "And(x, y)" assert upretty(expr) == u"x ∧ y" expr = Or(x, y) assert pretty(expr) == "Or(x, y)" assert upretty(expr) == u"x ∨ y" syms = symbols('a:f') expr = And(*syms) assert pretty(expr) == "And(a, b, c, d, e, f)" assert upretty(expr) == u"a ∧ b ∧ c ∧ d ∧ e ∧ f" expr = Or(*syms) assert pretty(expr) == "Or(a, b, c, d, e, f)" assert upretty(expr) == u"a ∨ b ∨ c ∨ d ∨ e ∨ f" expr = Xor(x, y, evaluate=False) assert pretty(expr) == "Xor(x, y)" assert upretty(expr) == u"x ⊻ y" expr = Nand(x, y, evaluate=False) assert pretty(expr) == "Nand(x, y)" assert upretty(expr) == u"x ⊼ y" expr = Nor(x, y, evaluate=False) assert pretty(expr) == "Nor(x, y)" assert upretty(expr) == u"x ⊽ y" expr = Implies(x, y, evaluate=False) assert pretty(expr) == "Implies(x, y)" assert upretty(expr) == u"x → y" # don't sort args expr = Implies(y, x, evaluate=False) assert pretty(expr) == "Implies(y, x)" assert upretty(expr) == u"y → x" expr = Equivalent(x, y, evaluate=False) assert pretty(expr) == "Equivalent(x, y)" assert upretty(expr) == u"x ⇔ y" expr = Equivalent(y, x, evaluate=False) assert pretty(expr) == "Equivalent(x, y)" assert upretty(expr) == u"x ⇔ y" def test_pretty_Domain(): expr = FF(23) assert pretty(expr) == "GF(23)" assert upretty(expr) == u"ℤ₂₃" expr = ZZ assert pretty(expr) == "ZZ" assert upretty(expr) == u"ℤ" expr = QQ assert pretty(expr) == "QQ" assert upretty(expr) == u"ℚ" expr = RR assert pretty(expr) == "RR" assert upretty(expr) == u"ℝ" expr = QQ[x] assert pretty(expr) == "QQ[x]" assert upretty(expr) == u"ℚ[x]" expr = QQ[x, y] assert pretty(expr) == "QQ[x, y]" assert upretty(expr) == u"ℚ[x, y]" expr = ZZ.frac_field(x) assert pretty(expr) == "ZZ(x)" assert upretty(expr) == u"ℤ(x)" expr = ZZ.frac_field(x, y) assert pretty(expr) == "ZZ(x, y)" assert upretty(expr) == u"ℤ(x, y)" expr = QQ.poly_ring(x, y, order=grlex) assert pretty(expr) == "QQ[x, y, order=grlex]" assert upretty(expr) == u"ℚ[x, y, order=grlex]" expr = QQ.poly_ring(x, y, order=ilex) assert pretty(expr) == "QQ[x, y, order=ilex]" assert upretty(expr) == u"ℚ[x, y, order=ilex]" def test_pretty_prec(): assert xpretty(S("0.3"), full_prec=True, wrap_line=False) == "0.300000000000000" assert xpretty(S("0.3"), full_prec="auto", wrap_line=False) == "0.300000000000000" assert xpretty(S("0.3"), full_prec=False, wrap_line=False) == "0.3" assert xpretty(S("0.3")*x, full_prec=True, use_unicode=False, wrap_line=False) in [ "0.300000000000000*x", "x*0.300000000000000" ] assert xpretty(S("0.3")*x, full_prec="auto", use_unicode=False, wrap_line=False) in [ "0.3*x", "x*0.3" ] assert xpretty(S("0.3")*x, full_prec=False, use_unicode=False, wrap_line=False) in [ "0.3*x", "x*0.3" ] def test_pprint(): import sys from sympy.core.compatibility import StringIO fd = StringIO() sso = sys.stdout sys.stdout = fd try: pprint(pi, use_unicode=False, wrap_line=False) finally: sys.stdout = sso assert fd.getvalue() == 'pi\n' def test_pretty_class(): """Test that the printer dispatcher correctly handles classes.""" class C: pass # C has no .__class__ and this was causing problems class D(object): pass assert pretty( C ) == str( C ) assert pretty( D ) == str( D ) def test_pretty_no_wrap_line(): huge_expr = 0 for i in range(20): huge_expr += i*sin(i + x) assert xpretty(huge_expr ).find('\n') != -1 assert xpretty(huge_expr, wrap_line=False).find('\n') == -1 def test_settings(): raises(TypeError, lambda: pretty(S(4), method="garbage")) def test_pretty_sum(): from sympy.abc import x, a, b, k, m, n expr = Sum(k**k, (k, 0, n)) ascii_str = \ """\ n \n\ ___ \n\ \\ ` \n\ \\ k\n\ / k \n\ /__, \n\ k = 0 \ """ ucode_str = \ u("""\ n \n\ ___ \n\ ╲ \n\ ╲ k\n\ ╱ k \n\ ╱ \n\ ‾‾‾ \n\ k = 0 \ """) assert pretty(expr) == ascii_str assert upretty(expr) == ucode_str expr = Sum(k**k, (k, oo, n)) ascii_str = \ """\ n \n\ ___ \n\ \\ ` \n\ \\ k\n\ / k \n\ /__, \n\ k = oo \ """ ucode_str = \ u("""\ n \n\ ___ \n\ ╲ \n\ ╲ k\n\ ╱ k \n\ ╱ \n\ ‾‾‾ \n\ k = ∞ \ """) assert pretty(expr) == ascii_str assert upretty(expr) == ucode_str expr = Sum(k**(Integral(x**n, (x, -oo, oo))), (k, 0, n**n)) ascii_str = \ """\ n \n\ n \n\ ______ \n\ \\ ` \n\ \\ oo \n\ \\ / \n\ \\ | \n\ \\ | n \n\ ) | x dx\n\ / | \n\ / / \n\ / -oo \n\ / k \n\ /_____, \n\ k = 0 \ """ ucode_str = \ u("""\ n \n\ n \n\ ______ \n\ ╲ \n\ ╲ \n\ ╲ ∞ \n\ ╲ ⌠ \n\ ╲ ⎮ n \n\ ╱ ⎮ x dx\n\ ╱ ⌡ \n\ ╱ -∞ \n\ ╱ k \n\ ╱ \n\ ‾‾‾‾‾‾ \n\ k = 0 \ """) assert pretty(expr) == ascii_str assert upretty(expr) == ucode_str expr = Sum(k**( Integral(x**n, (x, -oo, oo))), (k, 0, Integral(x**x, (x, -oo, oo)))) ascii_str = \ """\ oo \n\ / \n\ | \n\ | x \n\ | x dx \n\ | \n\ / \n\ -oo \n\ ______ \n\ \\ ` \n\ \\ oo \n\ \\ / \n\ \\ | \n\ \\ | n \n\ ) | x dx\n\ / | \n\ / / \n\ / -oo \n\ / k \n\ /_____, \n\ k = 0 \ """ ucode_str = \ u("""\ ∞ \n\ ⌠ \n\ ⎮ x \n\ ⎮ x dx \n\ ⌡ \n\ -∞ \n\ ______ \n\ ╲ \n\ ╲ \n\ ╲ ∞ \n\ ╲ ⌠ \n\ ╲ ⎮ n \n\ ╱ ⎮ x dx\n\ ╱ ⌡ \n\ ╱ -∞ \n\ ╱ k \n\ ╱ \n\ ‾‾‾‾‾‾ \n\ k = 0 \ """) assert pretty(expr) == ascii_str assert upretty(expr) == ucode_str expr = Sum(k**(Integral(x**n, (x, -oo, oo))), ( k, x + n + x**2 + n**2 + (x/n) + (1/x), Integral(x**x, (x, -oo, oo)))) ascii_str = \ """\ oo \n\ / \n\ | \n\ | x \n\ | x dx \n\ | \n\ / \n\ -oo \n\ ______ \n\ \\ ` \n\ \\ oo \n\ \\ / \n\ \\ | \n\ \\ | n \n\ ) | x dx\n\ / | \n\ / / \n\ / -oo \n\ / k \n\ /_____, \n\ 2 2 1 x \n\ k = n + n + x + x + - + - \n\ x n \ """ ucode_str = \ u("""\ ∞ \n\ ⌠ \n\ ⎮ x \n\ ⎮ x dx \n\ ⌡ \n\ -∞ \n\ ______ \n\ ╲ \n\ ╲ \n\ ╲ ∞ \n\ ╲ ⌠ \n\ ╲ ⎮ n \n\ ╱ ⎮ x dx\n\ ╱ ⌡ \n\ ╱ -∞ \n\ ╱ k \n\ ╱ \n\ ‾‾‾‾‾‾ \n\ 2 2 1 x \n\ k = n + n + x + x + ─ + ─ \n\ x n \ """) assert pretty(expr) == ascii_str assert upretty(expr) == ucode_str expr = Sum(k**( Integral(x**n, (x, -oo, oo))), (k, 0, x + n + x**2 + n**2 + (x/n) + (1/x))) ascii_str = \ """\ 2 2 1 x \n\ n + n + x + x + - + - \n\ x n \n\ ______ \n\ \\ ` \n\ \\ oo \n\ \\ / \n\ \\ | \n\ \\ | n \n\ ) | x dx\n\ / | \n\ / / \n\ / -oo \n\ / k \n\ /_____, \n\ k = 0 \ """ ucode_str = \ u("""\ 2 2 1 x \n\ n + n + x + x + ─ + ─ \n\ x n \n\ ______ \n\ ╲ \n\ ╲ \n\ ╲ ∞ \n\ ╲ ⌠ \n\ ╲ ⎮ n \n\ ╱ ⎮ x dx\n\ ╱ ⌡ \n\ ╱ -∞ \n\ ╱ k \n\ ╱ \n\ ‾‾‾‾‾‾ \n\ k = 0 \ """) assert pretty(expr) == ascii_str assert upretty(expr) == ucode_str expr = Sum(x, (x, 0, oo)) ascii_str = \ """\ oo \n\ __ \n\ \\ ` \n\ ) x\n\ /_, \n\ x = 0 \ """ ucode_str = \ u("""\ ∞ \n\ ___ \n\ ╲ \n\ ╲ \n\ ╱ x\n\ ╱ \n\ ‾‾‾ \n\ x = 0 \ """) assert pretty(expr) == ascii_str assert upretty(expr) == ucode_str expr = Sum(x**2, (x, 0, oo)) ascii_str = \ u("""\ oo \n\ ___ \n\ \\ ` \n\ \\ 2\n\ / x \n\ /__, \n\ x = 0 \ """) ucode_str = \ u("""\ ∞ \n\ ___ \n\ ╲ \n\ ╲ 2\n\ ╱ x \n\ ╱ \n\ ‾‾‾ \n\ x = 0 \ """) assert pretty(expr) == ascii_str assert upretty(expr) == ucode_str expr = Sum(x/2, (x, 0, oo)) ascii_str = \ """\ oo \n\ ___ \n\ \\ ` \n\ \\ x\n\ ) -\n\ / 2\n\ /__, \n\ x = 0 \ """ ucode_str = \ u("""\ ∞ \n\ ____ \n\ ╲ \n\ ╲ \n\ ╲ x\n\ ╱ ─\n\ ╱ 2\n\ ╱ \n\ ‾‾‾‾ \n\ x = 0 \ """) assert pretty(expr) == ascii_str assert upretty(expr) == ucode_str expr = Sum(x**3/2, (x, 0, oo)) ascii_str = \ """\ oo \n\ ____ \n\ \\ ` \n\ \\ 3\n\ \\ x \n\ / --\n\ / 2 \n\ /___, \n\ x = 0 \ """ ucode_str = \ u("""\ ∞ \n\ ____ \n\ ╲ \n\ ╲ 3\n\ ╲ x \n\ ╱ ──\n\ ╱ 2 \n\ ╱ \n\ ‾‾‾‾ \n\ x = 0 \ """) assert pretty(expr) == ascii_str assert upretty(expr) == ucode_str expr = Sum((x**3*y**(x/2))**n, (x, 0, oo)) ascii_str = \ """\ oo \n\ ____ \n\ \\ ` \n\ \\ n\n\ \\ / x\\ \n\ ) | -| \n\ / | 3 2| \n\ / \\x *y / \n\ /___, \n\ x = 0 \ """ ucode_str = \ u("""\ ∞ \n\ _____ \n\ ╲ \n\ ╲ \n\ ╲ n\n\ ╲ ⎛ x⎞ \n\ ╱ ⎜ ─⎟ \n\ ╱ ⎜ 3 2⎟ \n\ ╱ ⎝x ⋅y ⎠ \n\ ╱ \n\ ‾‾‾‾‾ \n\ x = 0 \ """) assert pretty(expr) == ascii_str assert upretty(expr) == ucode_str expr = Sum(1/x**2, (x, 0, oo)) ascii_str = \ """\ oo \n\ ____ \n\ \\ ` \n\ \\ 1 \n\ \\ --\n\ / 2\n\ / x \n\ /___, \n\ x = 0 \ """ ucode_str = \ u("""\ ∞ \n\ ____ \n\ ╲ \n\ ╲ 1 \n\ ╲ ──\n\ ╱ 2\n\ ╱ x \n\ ╱ \n\ ‾‾‾‾ \n\ x = 0 \ """) assert pretty(expr) == ascii_str assert upretty(expr) == ucode_str expr = Sum(1/y**(a/b), (x, 0, oo)) ascii_str = \ """\ oo \n\ ____ \n\ \\ ` \n\ \\ -a \n\ \\ ---\n\ / b \n\ / y \n\ /___, \n\ x = 0 \ """ ucode_str = \ u("""\ ∞ \n\ ____ \n\ ╲ \n\ ╲ -a \n\ ╲ ───\n\ ╱ b \n\ ╱ y \n\ ╱ \n\ ‾‾‾‾ \n\ x = 0 \ """) assert pretty(expr) == ascii_str assert upretty(expr) == ucode_str expr = Sum(1/y**(a/b), (x, 0, oo), (y, 1, 2)) ascii_str = \ """\ 2 oo \n\ ____ ____ \n\ \\ ` \\ ` \n\ \\ \\ -a\n\ \\ \\ --\n\ / / b \n\ / / y \n\ /___, /___, \n\ y = 1 x = 0 \ """ ucode_str = \ u("""\ 2 ∞ \n\ ____ ____ \n\ ╲ ╲ \n\ ╲ ╲ -a\n\ ╲ ╲ ──\n\ ╱ ╱ b \n\ ╱ ╱ y \n\ ╱ ╱ \n\ ‾‾‾‾ ‾‾‾‾ \n\ y = 1 x = 0 \ """) expr = Sum(1/(1 + 1/( 1 + 1/k)) + 1, (k, 111, 1 + 1/n), (k, 1/(1 + m), oo)) + 1/(1 + 1/k) ascii_str = \ """\ 1 \n\ 1 + - \n\ oo n \n\ _____ _____ \n\ \\ ` \\ ` \n\ \\ \\ / 1 \\ \n\ \\ \\ |1 + ---------| \n\ \\ \\ | 1 | 1 \n\ ) ) | 1 + -----| + -----\n\ / / | 1| 1\n\ / / | 1 + -| 1 + -\n\ / / \\ k/ k\n\ /____, /____, \n\ 1 k = 111 \n\ k = ----- \n\ m + 1 \ """ ucode_str = \ u("""\ 1 \n\ 1 + ─ \n\ ∞ n \n\ ______ ______ \n\ ╲ ╲ \n\ ╲ ╲ \n\ ╲ ╲ ⎛ 1 ⎞ \n\ ╲ ╲ ⎜1 + ─────────⎟ \n\ ╲ ╲ ⎜ 1 ⎟ 1 \n\ ╱ ╱ ⎜ 1 + ─────⎟ + ─────\n\ ╱ ╱ ⎜ 1⎟ 1\n\ ╱ ╱ ⎜ 1 + ─⎟ 1 + ─\n\ ╱ ╱ ⎝ k⎠ k\n\ ╱ ╱ \n\ ‾‾‾‾‾‾ ‾‾‾‾‾‾ \n\ 1 k = 111 \n\ k = ───── \n\ m + 1 \ """) assert pretty(expr) == ascii_str assert upretty(expr) == ucode_str def test_units(): expr = joule ascii_str1 = \ """\ 2\n\ kilogram*meter \n\ ---------------\n\ 2 \n\ second \ """ unicode_str1 = \ u("""\ 2\n\ kilogram⋅meter \n\ ───────────────\n\ 2 \n\ second \ """) ascii_str2 = \ """\ 2\n\ 3*x*y*kilogram*meter \n\ ---------------------\n\ 2 \n\ second \ """ unicode_str2 = \ u("""\ 2\n\ 3⋅x⋅y⋅kilogram⋅meter \n\ ─────────────────────\n\ 2 \n\ second \ """) from sympy.physics.units import kg, m, s assert upretty(expr) == u("joule") assert pretty(expr) == "joule" assert upretty(expr.convert_to(kg*m**2/s**2)) == unicode_str1 assert pretty(expr.convert_to(kg*m**2/s**2)) == ascii_str1 assert upretty(3*kg*x*m**2*y/s**2) == unicode_str2 assert pretty(3*kg*x*m**2*y/s**2) == ascii_str2 def test_pretty_Subs(): f = Function('f') expr = Subs(f(x), x, ph**2) ascii_str = \ """\ (f(x))| 2\n\ |x=phi \ """ unicode_str = \ u("""\ (f(x))│ 2\n\ │x=φ \ """) assert pretty(expr) == ascii_str assert upretty(expr) == unicode_str expr = Subs(f(x).diff(x), x, 0) ascii_str = \ """\ /d \\| \n\ |--(f(x))|| \n\ \\dx /|x=0\ """ unicode_str = \ u("""\ ⎛d ⎞│ \n\ ⎜──(f(x))⎟│ \n\ ⎝dx ⎠│x=0\ """) assert pretty(expr) == ascii_str assert upretty(expr) == unicode_str expr = Subs(f(x).diff(x)/y, (x, y), (0, Rational(1, 2))) ascii_str = \ """\ /d \\| \n\ |--(f(x))|| \n\ |dx || \n\ |--------|| \n\ \\ y /|x=0, y=1/2\ """ unicode_str = \ u("""\ ⎛d ⎞│ \n\ ⎜──(f(x))⎟│ \n\ ⎜dx ⎟│ \n\ ⎜────────⎟│ \n\ ⎝ y ⎠│x=0, y=1/2\ """) assert pretty(expr) == ascii_str assert upretty(expr) == unicode_str def test_gammas(): assert upretty(lowergamma(x, y)) == u"γ(x, y)" assert upretty(uppergamma(x, y)) == u"Γ(x, y)" assert xpretty(gamma(x), use_unicode=True) == u'Γ(x)' assert xpretty(gamma, use_unicode=True) == u'Γ' assert xpretty(symbols('gamma', cls=Function)(x), use_unicode=True) == u'γ(x)' assert xpretty(symbols('gamma', cls=Function), use_unicode=True) == u'γ' def test_beta(): assert xpretty(beta(x,y), use_unicode=True) == u'Β(x, y)' assert xpretty(beta(x,y), use_unicode=False) == u'B(x, y)' assert xpretty(beta, use_unicode=True) == u'Β' assert xpretty(beta, use_unicode=False) == u'B' mybeta = Function('beta') assert xpretty(mybeta(x), use_unicode=True) == u'β(x)' assert xpretty(mybeta(x, y, z), use_unicode=False) == u'beta(x, y, z)' assert xpretty(mybeta, use_unicode=True) == u'β' # test that notation passes to subclasses of the same name only def test_function_subclass_different_name(): class mygamma(gamma): pass assert xpretty(mygamma, use_unicode=True) == r"mygamma" assert xpretty(mygamma(x), use_unicode=True) == r"mygamma(x)" def test_SingularityFunction(): assert xpretty(SingularityFunction(x, 0, n), use_unicode=True) == ( """\ n\n\ <x> \ """) assert xpretty(SingularityFunction(x, 1, n), use_unicode=True) == ( """\ n\n\ <x - 1> \ """) assert xpretty(SingularityFunction(x, -1, n), use_unicode=True) == ( """\ n\n\ <x + 1> \ """) assert xpretty(SingularityFunction(x, a, n), use_unicode=True) == ( """\ n\n\ <-a + x> \ """) assert xpretty(SingularityFunction(x, y, n), use_unicode=True) == ( """\ n\n\ <x - y> \ """) assert xpretty(SingularityFunction(x, 0, n), use_unicode=False) == ( """\ n\n\ <x> \ """) assert xpretty(SingularityFunction(x, 1, n), use_unicode=False) == ( """\ n\n\ <x - 1> \ """) assert xpretty(SingularityFunction(x, -1, n), use_unicode=False) == ( """\ n\n\ <x + 1> \ """) assert xpretty(SingularityFunction(x, a, n), use_unicode=False) == ( """\ n\n\ <-a + x> \ """) assert xpretty(SingularityFunction(x, y, n), use_unicode=False) == ( """\ n\n\ <x - y> \ """) def test_deltas(): assert xpretty(DiracDelta(x), use_unicode=True) == u'δ(x)' assert xpretty(DiracDelta(x, 1), use_unicode=True) == \ u("""\ (1) \n\ δ (x)\ """) assert xpretty(x*DiracDelta(x, 1), use_unicode=True) == \ u("""\ (1) \n\ x⋅δ (x)\ """) def test_hyper(): expr = hyper((), (), z) ucode_str = \ u("""\ ┌─ ⎛ │ ⎞\n\ ├─ ⎜ │ z⎟\n\ 0╵ 0 ⎝ │ ⎠\ """) ascii_str = \ """\ _ \n\ |_ / | \\\n\ | | | z|\n\ 0 0 \\ | /\ """ assert pretty(expr) == ascii_str assert upretty(expr) == ucode_str expr = hyper((), (1,), x) ucode_str = \ u("""\ ┌─ ⎛ │ ⎞\n\ ├─ ⎜ │ x⎟\n\ 0╵ 1 ⎝1 │ ⎠\ """) ascii_str = \ """\ _ \n\ |_ / | \\\n\ | | | x|\n\ 0 1 \\1 | /\ """ assert pretty(expr) == ascii_str assert upretty(expr) == ucode_str expr = hyper([2], [1], x) ucode_str = \ u("""\ ┌─ ⎛2 │ ⎞\n\ ├─ ⎜ │ x⎟\n\ 1╵ 1 ⎝1 │ ⎠\ """) ascii_str = \ """\ _ \n\ |_ /2 | \\\n\ | | | x|\n\ 1 1 \\1 | /\ """ assert pretty(expr) == ascii_str assert upretty(expr) == ucode_str expr = hyper((pi/3, -2*k), (3, 4, 5, -3), x) ucode_str = \ u("""\ ⎛ π │ ⎞\n\ ┌─ ⎜ ─, -2⋅k │ ⎟\n\ ├─ ⎜ 3 │ x⎟\n\ 2╵ 4 ⎜ │ ⎟\n\ ⎝3, 4, 5, -3 │ ⎠\ """) ascii_str = \ """\ \n\ _ / pi | \\\n\ |_ | --, -2*k | |\n\ | | 3 | x|\n\ 2 4 | | |\n\ \\3, 4, 5, -3 | /\ """ assert pretty(expr) == ascii_str assert upretty(expr) == ucode_str expr = hyper((pi, S('2/3'), -2*k), (3, 4, 5, -3), x**2) ucode_str = \ u("""\ ┌─ ⎛π, 2/3, -2⋅k │ 2⎞\n\ ├─ ⎜ │ x ⎟\n\ 3╵ 4 ⎝3, 4, 5, -3 │ ⎠\ """) ascii_str = \ """\ _ \n\ |_ /pi, 2/3, -2*k | 2\\\n\ | | | x |\n\ 3 4 \\ 3, 4, 5, -3 | /\ """ assert pretty(expr) == ascii_str assert upretty(expr) == ucode_str expr = hyper([1, 2], [3, 4], 1/(1/(1/(1/x + 1) + 1) + 1)) ucode_str = \ u("""\ ⎛ │ 1 ⎞\n\ ⎜ │ ─────────────⎟\n\ ⎜ │ 1 ⎟\n\ ┌─ ⎜1, 2 │ 1 + ─────────⎟\n\ ├─ ⎜ │ 1 ⎟\n\ 2╵ 2 ⎜3, 4 │ 1 + ─────⎟\n\ ⎜ │ 1⎟\n\ ⎜ │ 1 + ─⎟\n\ ⎝ │ x⎠\ """) ascii_str = \ """\ \n\ / | 1 \\\n\ | | -------------|\n\ _ | | 1 |\n\ |_ |1, 2 | 1 + ---------|\n\ | | | 1 |\n\ 2 2 |3, 4 | 1 + -----|\n\ | | 1|\n\ | | 1 + -|\n\ \\ | x/\ """ assert pretty(expr) == ascii_str assert upretty(expr) == ucode_str def test_meijerg(): expr = meijerg([pi, pi, x], [1], [0, 1], [1, 2, 3], z) ucode_str = \ u("""\ ╭─╮2, 3 ⎛π, π, x 1 │ ⎞\n\ │╶┐ ⎜ │ z⎟\n\ ╰─╯4, 5 ⎝ 0, 1 1, 2, 3 │ ⎠\ """) ascii_str = \ """\ __2, 3 /pi, pi, x 1 | \\\n\ /__ | | z|\n\ \\_|4, 5 \\ 0, 1 1, 2, 3 | /\ """ assert pretty(expr) == ascii_str assert upretty(expr) == ucode_str expr = meijerg([1, pi/7], [2, pi, 5], [], [], z**2) ucode_str = \ u("""\ ⎛ π │ ⎞\n\ ╭─╮0, 2 ⎜1, ─ 2, π, 5 │ 2⎟\n\ │╶┐ ⎜ 7 │ z ⎟\n\ ╰─╯5, 0 ⎜ │ ⎟\n\ ⎝ │ ⎠\ """) ascii_str = \ """\ / pi | \\\n\ __0, 2 |1, -- 2, pi, 5 | 2|\n\ /__ | 7 | z |\n\ \\_|5, 0 | | |\n\ \\ | /\ """ assert pretty(expr) == ascii_str assert upretty(expr) == ucode_str ucode_str = \ u("""\ ╭─╮ 1, 10 ⎛1, 1, 1, 1, 1, 1, 1, 1, 1, 1 1 │ ⎞\n\ │╶┐ ⎜ │ z⎟\n\ ╰─╯11, 2 ⎝ 1 1 │ ⎠\ """) ascii_str = \ """\ __ 1, 10 /1, 1, 1, 1, 1, 1, 1, 1, 1, 1 1 | \\\n\ /__ | | z|\n\ \\_|11, 2 \\ 1 1 | /\ """ expr = meijerg([1]*10, [1], [1], [1], z) assert pretty(expr) == ascii_str assert upretty(expr) == ucode_str expr = meijerg([1, 2, ], [4, 3], [3], [4, 5], 1/(1/(1/(1/x + 1) + 1) + 1)) ucode_str = \ u("""\ ⎛ │ 1 ⎞\n\ ⎜ │ ─────────────⎟\n\ ⎜ │ 1 ⎟\n\ ╭─╮1, 2 ⎜1, 2 4, 3 │ 1 + ─────────⎟\n\ │╶┐ ⎜ │ 1 ⎟\n\ ╰─╯4, 3 ⎜ 3 4, 5 │ 1 + ─────⎟\n\ ⎜ │ 1⎟\n\ ⎜ │ 1 + ─⎟\n\ ⎝ │ x⎠\ """) ascii_str = \ """\ / | 1 \\\n\ | | -------------|\n\ | | 1 |\n\ __1, 2 |1, 2 4, 3 | 1 + ---------|\n\ /__ | | 1 |\n\ \\_|4, 3 | 3 4, 5 | 1 + -----|\n\ | | 1|\n\ | | 1 + -|\n\ \\ | x/\ """ assert pretty(expr) == ascii_str assert upretty(expr) == ucode_str expr = Integral(expr, x) ucode_str = \ u("""\ ⌠ \n\ ⎮ ⎛ │ 1 ⎞ \n\ ⎮ ⎜ │ ─────────────⎟ \n\ ⎮ ⎜ │ 1 ⎟ \n\ ⎮ ╭─╮1, 2 ⎜1, 2 4, 3 │ 1 + ─────────⎟ \n\ ⎮ │╶┐ ⎜ │ 1 ⎟ dx\n\ ⎮ ╰─╯4, 3 ⎜ 3 4, 5 │ 1 + ─────⎟ \n\ ⎮ ⎜ │ 1⎟ \n\ ⎮ ⎜ │ 1 + ─⎟ \n\ ⎮ ⎝ │ x⎠ \n\ ⌡ \ """) ascii_str = \ """\ / \n\ | \n\ | / | 1 \\ \n\ | | | -------------| \n\ | | | 1 | \n\ | __1, 2 |1, 2 4, 3 | 1 + ---------| \n\ | /__ | | 1 | dx\n\ | \\_|4, 3 | 3 4, 5 | 1 + -----| \n\ | | | 1| \n\ | | | 1 + -| \n\ | \\ | x/ \n\ | \n\ / \ """ assert pretty(expr) == ascii_str assert upretty(expr) == ucode_str def test_noncommutative(): A, B, C = symbols('A,B,C', commutative=False) expr = A*B*C**-1 ascii_str = \ """\ -1\n\ A*B*C \ """ ucode_str = \ u("""\ -1\n\ A⋅B⋅C \ """) assert pretty(expr) == ascii_str assert upretty(expr) == ucode_str expr = C**-1*A*B ascii_str = \ """\ -1 \n\ C *A*B\ """ ucode_str = \ u("""\ -1 \n\ C ⋅A⋅B\ """) assert pretty(expr) == ascii_str assert upretty(expr) == ucode_str expr = A*C**-1*B ascii_str = \ """\ -1 \n\ A*C *B\ """ ucode_str = \ u("""\ -1 \n\ A⋅C ⋅B\ """) assert pretty(expr) == ascii_str assert upretty(expr) == ucode_str expr = A*C**-1*B/x ascii_str = \ """\ -1 \n\ A*C *B\n\ -------\n\ x \ """ ucode_str = \ u("""\ -1 \n\ A⋅C ⋅B\n\ ───────\n\ x \ """) assert pretty(expr) == ascii_str assert upretty(expr) == ucode_str def test_pretty_special_functions(): x, y = symbols("x y") # atan2 expr = atan2(y/sqrt(200), sqrt(x)) ascii_str = \ """\ / ___ \\\n\ |\\/ 2 *y ___|\n\ atan2|-------, \\/ x |\n\ \\ 20 /\ """ ucode_str = \ u("""\ ⎛√2⋅y ⎞\n\ atan2⎜────, √x⎟\n\ ⎝ 20 ⎠\ """) assert pretty(expr) == ascii_str assert upretty(expr) == ucode_str def test_pretty_geometry(): e = Segment((0, 1), (0, 2)) assert pretty(e) == 'Segment2D(Point2D(0, 1), Point2D(0, 2))' e = Ray((1, 1), angle=4.02*pi) assert pretty(e) == 'Ray2D(Point2D(1, 1), Point2D(2, tan(pi/50) + 1))' def test_expint(): expr = Ei(x) string = 'Ei(x)' assert pretty(expr) == string assert upretty(expr) == string expr = expint(1, z) ucode_str = u"E₁(z)" ascii_str = "expint(1, z)" assert pretty(expr) == ascii_str assert upretty(expr) == ucode_str assert pretty(Shi(x)) == 'Shi(x)' assert pretty(Si(x)) == 'Si(x)' assert pretty(Ci(x)) == 'Ci(x)' assert pretty(Chi(x)) == 'Chi(x)' assert upretty(Shi(x)) == 'Shi(x)' assert upretty(Si(x)) == 'Si(x)' assert upretty(Ci(x)) == 'Ci(x)' assert upretty(Chi(x)) == 'Chi(x)' def test_elliptic_functions(): ascii_str = \ """\ / 1 \\\n\ K|-----|\n\ \\z + 1/\ """ ucode_str = \ u("""\ ⎛ 1 ⎞\n\ K⎜─────⎟\n\ ⎝z + 1⎠\ """) expr = elliptic_k(1/(z + 1)) assert pretty(expr) == ascii_str assert upretty(expr) == ucode_str ascii_str = \ """\ / | 1 \\\n\ F|1|-----|\n\ \\ |z + 1/\ """ ucode_str = \ u("""\ ⎛ │ 1 ⎞\n\ F⎜1│─────⎟\n\ ⎝ │z + 1⎠\ """) expr = elliptic_f(1, 1/(1 + z)) assert pretty(expr) == ascii_str assert upretty(expr) == ucode_str ascii_str = \ """\ / 1 \\\n\ E|-----|\n\ \\z + 1/\ """ ucode_str = \ u("""\ ⎛ 1 ⎞\n\ E⎜─────⎟\n\ ⎝z + 1⎠\ """) expr = elliptic_e(1/(z + 1)) assert pretty(expr) == ascii_str assert upretty(expr) == ucode_str ascii_str = \ """\ / | 1 \\\n\ E|1|-----|\n\ \\ |z + 1/\ """ ucode_str = \ u("""\ ⎛ │ 1 ⎞\n\ E⎜1│─────⎟\n\ ⎝ │z + 1⎠\ """) expr = elliptic_e(1, 1/(1 + z)) assert pretty(expr) == ascii_str assert upretty(expr) == ucode_str ascii_str = \ """\ / |4\\\n\ Pi|3|-|\n\ \\ |x/\ """ ucode_str = \ u("""\ ⎛ │4⎞\n\ Π⎜3│─⎟\n\ ⎝ │x⎠\ """) expr = elliptic_pi(3, 4/x) assert pretty(expr) == ascii_str assert upretty(expr) == ucode_str ascii_str = \ """\ / 4| \\\n\ Pi|3; -|6|\n\ \\ x| /\ """ ucode_str = \ u("""\ ⎛ 4│ ⎞\n\ Π⎜3; ─│6⎟\n\ ⎝ x│ ⎠\ """) expr = elliptic_pi(3, 4/x, 6) assert pretty(expr) == ascii_str assert upretty(expr) == ucode_str def test_RandomDomain(): from sympy.stats import Normal, Die, Exponential, pspace, where X = Normal('x1', 0, 1) assert upretty(where(X > 0)) == u"Domain: 0 < x₁ ∧ x₁ < ∞" D = Die('d1', 6) assert upretty(where(D > 4)) == u'Domain: d₁ = 5 ∨ d₁ = 6' A = Exponential('a', 1) B = Exponential('b', 1) assert upretty(pspace(Tuple(A, B)).domain) == \ u'Domain: 0 ≤ a ∧ 0 ≤ b ∧ a < ∞ ∧ b < ∞' def test_PrettyPoly(): F = QQ.frac_field(x, y) R = QQ.poly_ring(x, y) expr = F.convert(x/(x + y)) assert pretty(expr) == "x/(x + y)" assert upretty(expr) == u"x/(x + y)" expr = R.convert(x + y) assert pretty(expr) == "x + y" assert upretty(expr) == u"x + y" def test_issue_6285(): assert pretty(Pow(2, -5, evaluate=False)) == '1 \n--\n 5\n2 ' assert pretty(Pow(x, (1/pi))) == 'pi___\n\\/ x ' def test_issue_6359(): assert pretty(Integral(x**2, x)**2) == \ """\ 2 / / \\ \n\ | | | \n\ | | 2 | \n\ | | x dx| \n\ | | | \n\ \\/ / \ """ assert upretty(Integral(x**2, x)**2) == \ u("""\ 2 ⎛⌠ ⎞ \n\ ⎜⎮ 2 ⎟ \n\ ⎜⎮ x dx⎟ \n\ ⎝⌡ ⎠ \ """) assert pretty(Sum(x**2, (x, 0, 1))**2) == \ """\ 2 / 1 \\ \n\ | ___ | \n\ | \\ ` | \n\ | \\ 2| \n\ | / x | \n\ | /__, | \n\ \\x = 0 / \ """ assert upretty(Sum(x**2, (x, 0, 1))**2) == \ u("""\ 2 ⎛ 1 ⎞ \n\ ⎜ ___ ⎟ \n\ ⎜ ╲ ⎟ \n\ ⎜ ╲ 2⎟ \n\ ⎜ ╱ x ⎟ \n\ ⎜ ╱ ⎟ \n\ ⎜ ‾‾‾ ⎟ \n\ ⎝x = 0 ⎠ \ """) assert pretty(Product(x**2, (x, 1, 2))**2) == \ """\ 2 / 2 \\ \n\ |______ | \n\ | | | 2| \n\ | | | x | \n\ | | | | \n\ \\x = 1 / \ """ assert upretty(Product(x**2, (x, 1, 2))**2) == \ u("""\ 2 ⎛ 2 ⎞ \n\ ⎜─┬──┬─ ⎟ \n\ ⎜ │ │ 2⎟ \n\ ⎜ │ │ x ⎟ \n\ ⎜ │ │ ⎟ \n\ ⎝x = 1 ⎠ \ """) f = Function('f') assert pretty(Derivative(f(x), x)**2) == \ """\ 2 /d \\ \n\ |--(f(x))| \n\ \\dx / \ """ assert upretty(Derivative(f(x), x)**2) == \ u("""\ 2 ⎛d ⎞ \n\ ⎜──(f(x))⎟ \n\ ⎝dx ⎠ \ """) def test_issue_6739(): ascii_str = \ """\ 1 \n\ -----\n\ ___\n\ \\/ x \ """ ucode_str = \ u("""\ 1 \n\ ──\n\ √x\ """) assert pretty(1/sqrt(x)) == ascii_str assert upretty(1/sqrt(x)) == ucode_str def test_complicated_symbol_unchanged(): for symb_name in ["dexpr2_d1tau", "dexpr2^d1tau"]: assert pretty(Symbol(symb_name)) == symb_name def test_categories(): from sympy.categories import (Object, IdentityMorphism, NamedMorphism, Category, Diagram, DiagramGrid) A1 = Object("A1") A2 = Object("A2") A3 = Object("A3") f1 = NamedMorphism(A1, A2, "f1") f2 = NamedMorphism(A2, A3, "f2") id_A1 = IdentityMorphism(A1) K1 = Category("K1") assert pretty(A1) == "A1" assert upretty(A1) == u"A₁" assert pretty(f1) == "f1:A1-->A2" assert upretty(f1) == u"f₁:A₁——▶A₂" assert pretty(id_A1) == "id:A1-->A1" assert upretty(id_A1) == u"id:A₁——▶A₁" assert pretty(f2*f1) == "f2*f1:A1-->A3" assert upretty(f2*f1) == u"f₂∘f₁:A₁——▶A₃" assert pretty(K1) == "K1" assert upretty(K1) == u"K₁" # Test how diagrams are printed. d = Diagram() assert pretty(d) == "EmptySet()" assert upretty(d) == u"∅" d = Diagram({f1: "unique", f2: S.EmptySet}) assert pretty(d) == "{f2*f1:A1-->A3: EmptySet(), id:A1-->A1: " \ "EmptySet(), id:A2-->A2: EmptySet(), id:A3-->A3: " \ "EmptySet(), f1:A1-->A2: {unique}, f2:A2-->A3: EmptySet()}" assert upretty(d) == u("{f₂∘f₁:A₁——▶A₃: ∅, id:A₁——▶A₁: ∅, " \ "id:A₂——▶A₂: ∅, id:A₃——▶A₃: ∅, f₁:A₁——▶A₂: {unique}, f₂:A₂——▶A₃: ∅}") d = Diagram({f1: "unique", f2: S.EmptySet}, {f2 * f1: "unique"}) assert pretty(d) == "{f2*f1:A1-->A3: EmptySet(), id:A1-->A1: " \ "EmptySet(), id:A2-->A2: EmptySet(), id:A3-->A3: " \ "EmptySet(), f1:A1-->A2: {unique}, f2:A2-->A3: EmptySet()}" \ " ==> {f2*f1:A1-->A3: {unique}}" assert upretty(d) == u("{f₂∘f₁:A₁——▶A₃: ∅, id:A₁——▶A₁: ∅, id:A₂——▶A₂: " \ "∅, id:A₃——▶A₃: ∅, f₁:A₁——▶A₂: {unique}, f₂:A₂——▶A₃: ∅}" \ " ══▶ {f₂∘f₁:A₁——▶A₃: {unique}}") grid = DiagramGrid(d) assert pretty(grid) == "A1 A2\n \nA3 " assert upretty(grid) == u"A₁ A₂\n \nA₃ " def test_PrettyModules(): R = QQ.old_poly_ring(x, y) F = R.free_module(2) M = F.submodule([x, y], [1, x**2]) ucode_str = \ u("""\ 2\n\ ℚ[x, y] \ """) ascii_str = \ """\ 2\n\ QQ[x, y] \ """ assert upretty(F) == ucode_str assert pretty(F) == ascii_str ucode_str = \ u("""\ ╱ ⎡ 2⎤╲\n\ ╲[x, y], ⎣1, x ⎦╱\ """) ascii_str = \ """\ 2 \n\ <[x, y], [1, x ]>\ """ assert upretty(M) == ucode_str assert pretty(M) == ascii_str I = R.ideal(x**2, y) ucode_str = \ u("""\ ╱ 2 ╲\n\ ╲x , y╱\ """) ascii_str = \ """\ 2 \n\ <x , y>\ """ assert upretty(I) == ucode_str assert pretty(I) == ascii_str Q = F / M ucode_str = \ u("""\ 2 \n\ ℚ[x, y] \n\ ─────────────────\n\ ╱ ⎡ 2⎤╲\n\ ╲[x, y], ⎣1, x ⎦╱\ """) ascii_str = \ """\ 2 \n\ QQ[x, y] \n\ -----------------\n\ 2 \n\ <[x, y], [1, x ]>\ """ assert upretty(Q) == ucode_str assert pretty(Q) == ascii_str ucode_str = \ u("""\ ╱⎡ 3⎤ ╲\n\ │⎢ x ⎥ ╱ ⎡ 2⎤╲ ╱ ⎡ 2⎤╲│\n\ │⎢1, ──⎥ + ╲[x, y], ⎣1, x ⎦╱, [2, y] + ╲[x, y], ⎣1, x ⎦╱│\n\ ╲⎣ 2 ⎦ ╱\ """) ascii_str = \ """\ 3 \n\ x 2 2 \n\ <[1, --] + <[x, y], [1, x ]>, [2, y] + <[x, y], [1, x ]>>\n\ 2 \ """ def test_QuotientRing(): R = QQ.old_poly_ring(x)/[x**2 + 1] ucode_str = \ u("""\ ℚ[x] \n\ ────────\n\ ╱ 2 ╲\n\ ╲x + 1╱\ """) ascii_str = \ """\ QQ[x] \n\ --------\n\ 2 \n\ <x + 1>\ """ assert upretty(R) == ucode_str assert pretty(R) == ascii_str ucode_str = \ u("""\ ╱ 2 ╲\n\ 1 + ╲x + 1╱\ """) ascii_str = \ """\ 2 \n\ 1 + <x + 1>\ """ assert upretty(R.one) == ucode_str assert pretty(R.one) == ascii_str def test_Homomorphism(): from sympy.polys.agca import homomorphism R = QQ.old_poly_ring(x) expr = homomorphism(R.free_module(1), R.free_module(1), [0]) ucode_str = \ u("""\ 1 1\n\ [0] : ℚ[x] ──> ℚ[x] \ """) ascii_str = \ """\ 1 1\n\ [0] : QQ[x] --> QQ[x] \ """ assert upretty(expr) == ucode_str assert pretty(expr) == ascii_str expr = homomorphism(R.free_module(2), R.free_module(2), [0, 0]) ucode_str = \ u("""\ ⎡0 0⎤ 2 2\n\ ⎢ ⎥ : ℚ[x] ──> ℚ[x] \n\ ⎣0 0⎦ \ """) ascii_str = \ """\ [0 0] 2 2\n\ [ ] : QQ[x] --> QQ[x] \n\ [0 0] \ """ assert upretty(expr) == ucode_str assert pretty(expr) == ascii_str expr = homomorphism(R.free_module(1), R.free_module(1) / [[x]], [0]) ucode_str = \ u("""\ 1\n\ 1 ℚ[x] \n\ [0] : ℚ[x] ──> ─────\n\ <[x]>\ """) ascii_str = \ """\ 1\n\ 1 QQ[x] \n\ [0] : QQ[x] --> ------\n\ <[x]> \ """ assert upretty(expr) == ucode_str assert pretty(expr) == ascii_str def test_Tr(): A, B = symbols('A B', commutative=False) t = Tr(A*B) assert pretty(t) == r'Tr(A*B)' assert upretty(t) == u'Tr(A⋅B)' def test_pretty_Add(): eq = Mul(-2, x - 2, evaluate=False) + 5 assert pretty(eq) == '5 - 2*(x - 2)' def test_issue_7179(): assert upretty(Not(Equivalent(x, y))) == u'x ⇎ y' assert upretty(Not(Implies(x, y))) == u'x ↛ y' def test_issue_7180(): assert upretty(Equivalent(x, y)) == u'x ⇔ y' def test_pretty_Complement(): assert pretty(S.Reals - S.Naturals) == '(-oo, oo) \\ Naturals' assert upretty(S.Reals - S.Naturals) == u'ℝ \\ ℕ' assert pretty(S.Reals - S.Naturals0) == '(-oo, oo) \\ Naturals0' assert upretty(S.Reals - S.Naturals0) == u'ℝ \\ ℕ₀' def test_pretty_SymmetricDifference(): from sympy import SymmetricDifference, Interval from sympy.utilities.pytest import raises assert upretty(SymmetricDifference(Interval(2,3), Interval(3,5), \ evaluate = False)) == u'[2, 3] ∆ [3, 5]' with raises(NotImplementedError): pretty(SymmetricDifference(Interval(2,3), Interval(3,5), evaluate = False)) def test_pretty_Contains(): assert pretty(Contains(x, S.Integers)) == 'Contains(x, Integers)' assert upretty(Contains(x, S.Integers)) == u'x ∈ ℤ' def test_issue_8292(): from sympy.core import sympify e = sympify('((x+x**4)/(x-1))-(2*(x-1)**4/(x-1)**4)', evaluate=False) ucode_str = \ u("""\ 4 4 \n\ 2⋅(x - 1) x + x\n\ - ────────── + ──────\n\ 4 x - 1 \n\ (x - 1) \ """) ascii_str = \ """\ 4 4 \n\ 2*(x - 1) x + x\n\ - ---------- + ------\n\ 4 x - 1 \n\ (x - 1) \ """ assert pretty(e) == ascii_str assert upretty(e) == ucode_str def test_issue_4335(): y = Function('y') expr = -y(x).diff(x) ucode_str = \ u("""\ d \n\ -──(y(x))\n\ dx \ """) ascii_str = \ """\ d \n\ - --(y(x))\n\ dx \ """ assert pretty(expr) == ascii_str assert upretty(expr) == ucode_str def test_issue_8344(): from sympy.core import sympify e = sympify('2*x*y**2/1**2 + 1', evaluate=False) ucode_str = \ u("""\ 2 \n\ 2⋅x⋅y \n\ ────── + 1\n\ 2 \n\ 1 \ """) assert upretty(e) == ucode_str def test_issue_6324(): x = Pow(2, 3, evaluate=False) y = Pow(10, -2, evaluate=False) e = Mul(x, y, evaluate=False) ucode_str = \ u("""\ 3\n\ 2 \n\ ───\n\ 2\n\ 10 \ """) assert upretty(e) == ucode_str def test_issue_7927(): e = sin(x/2)**cos(x/2) ucode_str = \ u("""\ ⎛x⎞\n\ cos⎜─⎟\n\ ⎝2⎠\n\ ⎛ ⎛x⎞⎞ \n\ ⎜sin⎜─⎟⎟ \n\ ⎝ ⎝2⎠⎠ \ """) assert upretty(e) == ucode_str e = sin(x)**(S(11)/13) ucode_str = \ u("""\ 11\n\ ──\n\ 13\n\ (sin(x)) \ """) assert upretty(e) == ucode_str def test_issue_6134(): from sympy.abc import lamda, t phi = Function('phi') e = lamda*x*Integral(phi(t)*pi*sin(pi*t), (t, 0, 1)) + lamda*x**2*Integral(phi(t)*2*pi*sin(2*pi*t), (t, 0, 1)) ucode_str = \ u("""\ 1 1 \n\ 2 ⌠ ⌠ \n\ λ⋅x ⋅⎮ 2⋅π⋅φ(t)⋅sin(2⋅π⋅t) dt + λ⋅x⋅⎮ π⋅φ(t)⋅sin(π⋅t) dt\n\ ⌡ ⌡ \n\ 0 0 \ """) assert upretty(e) == ucode_str def test_issue_9877(): ucode_str1 = u'(2, 3) ∪ ([1, 2] \\ {x})' a, b, c = Interval(2, 3, True, True), Interval(1, 2), FiniteSet(x) assert upretty(Union(a, Complement(b, c))) == ucode_str1 ucode_str2 = u'{x} ∩ {y} ∩ ({z} \\ [1, 2])' d, e, f, g = FiniteSet(x), FiniteSet(y), FiniteSet(z), Interval(1, 2) assert upretty(Intersection(d, e, Complement(f, g))) == ucode_str2 def test_issue_13651(): expr1 = c + Mul(-1, a + b, evaluate=False) assert pretty(expr1) == 'c - (a + b)' expr2 = c + Mul(-1, a - b + d, evaluate=False) assert pretty(expr2) == 'c - (a - b + d)' def test_pretty_primenu(): from sympy.ntheory.factor_ import primenu ascii_str1 = "nu(n)" ucode_str1 = u("ν(n)") n = symbols('n', integer=True) assert pretty(primenu(n)) == ascii_str1 assert upretty(primenu(n)) == ucode_str1 def test_pretty_primeomega(): from sympy.ntheory.factor_ import primeomega ascii_str1 = "Omega(n)" ucode_str1 = u("Ω(n)") n = symbols('n', integer=True) assert pretty(primeomega(n)) == ascii_str1 assert upretty(primeomega(n)) == ucode_str1 def test_pretty_Mod(): from sympy.core import Mod ascii_str1 = "x mod 7" ucode_str1 = u("x mod 7") ascii_str2 = "(x + 1) mod 7" ucode_str2 = u("(x + 1) mod 7") ascii_str3 = "2*x mod 7" ucode_str3 = u("2⋅x mod 7") ascii_str4 = "(x mod 7) + 1" ucode_str4 = u("(x mod 7) + 1") ascii_str5 = "2*(x mod 7)" ucode_str5 = u("2⋅(x mod 7)") x = symbols('x', integer=True) assert pretty(Mod(x, 7)) == ascii_str1 assert upretty(Mod(x, 7)) == ucode_str1 assert pretty(Mod(x + 1, 7)) == ascii_str2 assert upretty(Mod(x + 1, 7)) == ucode_str2 assert pretty(Mod(2 * x, 7)) == ascii_str3 assert upretty(Mod(2 * x, 7)) == ucode_str3 assert pretty(Mod(x, 7) + 1) == ascii_str4 assert upretty(Mod(x, 7) + 1) == ucode_str4 assert pretty(2 * Mod(x, 7)) == ascii_str5 assert upretty(2 * Mod(x, 7)) == ucode_str5 def test_issue_11801(): assert pretty(Symbol("")) == "" assert upretty(Symbol("")) == "" def test_pretty_UnevaluatedExpr(): x = symbols('x') he = UnevaluatedExpr(1/x) ucode_str = \ u("""\ 1\n\ ─\n\ x\ """) assert upretty(he) == ucode_str ucode_str = \ u("""\ 2\n\ ⎛1⎞ \n\ ⎜─⎟ \n\ ⎝x⎠ \ """) assert upretty(he**2) == ucode_str ucode_str = \ u("""\ 1\n\ 1 + ─\n\ x\ """) assert upretty(he + 1) == ucode_str ucode_str = \ u('''\ 1\n\ x⋅─\n\ x\ ''') assert upretty(x*he) == ucode_str def test_issue_10472(): M = (Matrix([[0, 0], [0, 0]]), Matrix([0, 0])) ucode_str = \ u("""\ ⎛⎡0 0⎤ ⎡0⎤⎞ ⎜⎢ ⎥, ⎢ ⎥⎟ ⎝⎣0 0⎦ ⎣0⎦⎠\ """) assert upretty(M) == ucode_str def test_MatrixElement_printing(): # test cases for issue #11821 A = MatrixSymbol("A", 1, 3) B = MatrixSymbol("B", 1, 3) C = MatrixSymbol("C", 1, 3) ascii_str1 = "A_00" ucode_str1 = u("A₀₀") assert pretty(A[0, 0]) == ascii_str1 assert upretty(A[0, 0]) == ucode_str1 ascii_str1 = "3*A_00" ucode_str1 = u("3⋅A₀₀") assert pretty(3*A[0, 0]) == ascii_str1 assert upretty(3*A[0, 0]) == ucode_str1 ascii_str1 = "(-B + A)[0, 0]" ucode_str1 = u("(-B + A)[0, 0]") F = C[0, 0].subs(C, A - B) assert pretty(F) == ascii_str1 assert upretty(F) == ucode_str1 def test_issue_12675(): from sympy.vector import CoordSys3D x, y, t, j = symbols('x y t j') e = CoordSys3D('e') ucode_str = \ u("""\ ⎛ t⎞ \n\ ⎜⎛x⎞ ⎟ j_e\n\ ⎜⎜─⎟ ⎟ \n\ ⎝⎝y⎠ ⎠ \ """) assert upretty((x/y)**t*e.j) == ucode_str ucode_str = \ u("""\ ⎛1⎞ \n\ ⎜─⎟ j_e\n\ ⎝y⎠ \ """) assert upretty((1/y)*e.j) == ucode_str def test_MatrixSymbol_printing(): # test cases for issue #14237 A = MatrixSymbol("A", 3, 3) B = MatrixSymbol("B", 3, 3) C = MatrixSymbol("C", 3, 3) assert pretty(-A*B*C) == "-A*B*C" assert pretty(A - B) == "-B + A" assert pretty(A*B*C - A*B - B*C) == "-A*B -B*C + A*B*C" # issue #14814 x = MatrixSymbol('x', n, n) y = MatrixSymbol('y*', n, n) assert pretty(x + y) == "x + y*" ascii_str = \ """\ 2 \n\ -2*y* -a*x\ """ assert pretty(-a*x + -2*y*y) == ascii_str def test_degree_printing(): expr1 = 90*degree assert pretty(expr1) == u'90°' expr2 = x*degree assert pretty(expr2) == u'x°' expr3 = cos(x*degree + 90*degree) assert pretty(expr3) == u'cos(x° + 90°)' def test_vector_expr_pretty_printing(): A = CoordSys3D('A') assert upretty(Cross(A.i, A.x*A.i+3*A.y*A.j)) == u("(i_A)×((x_A) i_A + (3⋅y_A) j_A)") assert upretty(x*Cross(A.i, A.j)) == u('x⋅(i_A)×(j_A)') assert upretty(Curl(A.x*A.i + 3*A.y*A.j)) == u("∇×((x_A) i_A + (3⋅y_A) j_A)") assert upretty(Divergence(A.x*A.i + 3*A.y*A.j)) == u("∇⋅((x_A) i_A + (3⋅y_A) j_A)") assert upretty(Dot(A.i, A.x*A.i+3*A.y*A.j)) == u("(i_A)⋅((x_A) i_A + (3⋅y_A) j_A)") assert upretty(Gradient(A.x+3*A.y)) == u("∇(x_A + 3⋅y_A)") assert upretty(Laplacian(A.x+3*A.y)) == u("∆(x_A + 3⋅y_A)") # TODO: add support for ASCII pretty. def test_pretty_print_tensor_expr(): L = TensorIndexType("L") i, j, k = tensor_indices("i j k", L) i0 = tensor_indices("i_0", L) A, B, C, D = tensorhead("A B C D", [L], [[1]]) H = tensorhead("H", [L, L], [[1], [1]]) expr = -i ascii_str = \ """\ -i\ """ ucode_str = \ u("""\ -i\ """) assert pretty(expr) == ascii_str assert upretty(expr) == ucode_str expr = A(i) ascii_str = \ """\ i\n\ A \n\ \ """ ucode_str = \ u("""\ i\n\ A \n\ \ """) assert pretty(expr) == ascii_str assert upretty(expr) == ucode_str expr = A(i0) ascii_str = \ """\ i_0\n\ A \n\ \ """ ucode_str = \ u("""\ i₀\n\ A \n\ \ """) assert pretty(expr) == ascii_str assert upretty(expr) == ucode_str expr = A(-i) ascii_str = \ """\ \n\ A \n\ i\ """ ucode_str = \ u("""\ \n\ A \n\ i\ """) assert pretty(expr) == ascii_str assert upretty(expr) == ucode_str expr = -3*A(-i) ascii_str = \ """\ \n\ -3*A \n\ i\ """ ucode_str = \ u("""\ \n\ -3⋅A \n\ i\ """) assert pretty(expr) == ascii_str assert upretty(expr) == ucode_str expr = H(i, -j) ascii_str = \ """\ i \n\ H \n\ j\ """ ucode_str = \ u("""\ i \n\ H \n\ j\ """) assert pretty(expr) == ascii_str assert upretty(expr) == ucode_str expr = H(i, -i) ascii_str = \ """\ L_0 \n\ H \n\ L_0\ """ ucode_str = \ u("""\ L₀ \n\ H \n\ L₀\ """) assert pretty(expr) == ascii_str assert upretty(expr) == ucode_str expr = H(i, -j)*A(j)*B(k) ascii_str = \ """\ i L_0 k\n\ H *A *B \n\ L_0 \ """ ucode_str = \ u("""\ i L₀ k\n\ H ⋅A ⋅B \n\ L₀ \ """) assert pretty(expr) == ascii_str assert upretty(expr) == ucode_str expr = (1+x)*A(i) ascii_str = \ """\ i\n\ (x + 1)*A \n\ \ """ ucode_str = \ u("""\ i\n\ (x + 1)⋅A \n\ \ """) assert pretty(expr) == ascii_str assert upretty(expr) == ucode_str expr = A(i) + 3*B(i) ascii_str = \ """\ i i\n\ A + 3*B \n\ \ """ ucode_str = \ u("""\ i i\n\ A + 3⋅B \n\ \ """) assert pretty(expr) == ascii_str assert upretty(expr) == ucode_str def test_pretty_print_tensor_partial_deriv(): from sympy.tensor.toperators import PartialDerivative from sympy.tensor.tensor import TensorIndexType, tensor_indices, tensorhead L = TensorIndexType("L") i, j, k = tensor_indices("i j k", L) i0 = tensor_indices("i0", L) A, B, C, D = tensorhead("A B C D", [L], [[1]]) H = tensorhead("H", [L, L], [[1], [1]]) expr = PartialDerivative(A(i), A(j)) ascii_str = \ """\ d / i\\\n\ ---|A |\n\ j\\ /\n\ dA \n\ \ """ ucode_str = \ u("""\ ∂ ⎛ i⎞\n\ ───⎜A ⎟\n\ j⎝ ⎠\n\ ∂A \n\ \ """) assert pretty(expr) == ascii_str assert upretty(expr) == ucode_str expr = A(i)*PartialDerivative(H(k, -i), A(j)) ascii_str = \ """\ L_0 d / k \\\n\ A *---|H |\n\ j\\ L_0/\n\ dA \n\ \ """ ucode_str = \ u("""\ L₀ ∂ ⎛ k ⎞\n\ A ⋅───⎜H ⎟\n\ j⎝ L₀⎠\n\ ∂A \n\ \ """) assert pretty(expr) == ascii_str assert upretty(expr) == ucode_str expr = A(i)*PartialDerivative(B(k)*C(-i) + 3*H(k, -i), A(j)) ascii_str = \ """\ L_0 d / k k \\\n\ A *---|B *C + 3*H |\n\ j\\ L_0 L_0/\n\ dA \n\ \ """ ucode_str = \ u("""\ L₀ ∂ ⎛ k k ⎞\n\ A ⋅───⎜B ⋅C + 3⋅H ⎟\n\ j⎝ L₀ L₀⎠\n\ ∂A \n\ \ """) assert pretty(expr) == ascii_str assert upretty(expr) == ucode_str expr = (A(i) + B(i))*PartialDerivative(C(-j), D(j)) ascii_str = \ """\ / i i\\ d / \\\n\ |A + B |*-----|C |\n\ \\ / L_0\\ L_0/\n\ dD \n\ \ """ ucode_str = \ u("""\ ⎛ i i⎞ ∂ ⎛ ⎞\n\ ⎜A + B ⎟⋅────⎜C ⎟\n\ ⎝ ⎠ L₀⎝ L₀⎠\n\ ∂D \n\ \ """) assert pretty(expr) == ascii_str assert upretty(expr) == ucode_str expr = (A(i) + B(i))*PartialDerivative(C(-i), D(j)) ascii_str = \ """\ / L_0 L_0\\ d / \\\n\ |A + B |*---|C |\n\ \\ / j\\ L_0/\n\ dD \n\ \ """ ucode_str = \ u("""\ ⎛ L₀ L₀⎞ ∂ ⎛ ⎞\n\ ⎜A + B ⎟⋅───⎜C ⎟\n\ ⎝ ⎠ j⎝ L₀⎠\n\ ∂D \n\ \ """) assert pretty(expr) == ascii_str assert upretty(expr) == ucode_str expr = TensorElement(H(i, j), {i:1}) ascii_str = \ """\ i=1,j\n\ H \n\ \ """ ucode_str = ascii_str assert pretty(expr) == ascii_str assert upretty(expr) == ucode_str expr = TensorElement(H(i, j), {i:1, j:1}) ascii_str = \ """\ i=1,j=1\n\ H \n\ \ """ ucode_str = ascii_str assert pretty(expr) == ascii_str assert upretty(expr) == ucode_str expr = TensorElement(H(i, j), {j:1}) ascii_str = \ """\ i,j=1\n\ H \n\ \ """ ucode_str = ascii_str expr = TensorElement(H(-i, j), {-i:1}) ascii_str = \ """\ j\n\ H \n\ i=1 \ """ ucode_str = ascii_str assert pretty(expr) == ascii_str assert upretty(expr) == ucode_str def test_issue_15560(): a = MatrixSymbol('a', 1, 1) e = pretty(a*(KroneckerProduct(a, a))) result = 'a*(a x a)' assert e == result def test_print_lerchphi(): # Part of issue 6013 a = Symbol('a') pretty(lerchphi(a, 1, 2)) uresult = u'Φ(a, 1, 2)' aresult = 'lerchphi(a, 1, 2)' assert pretty(lerchphi(a, 1, 2)) == aresult assert upretty(lerchphi(a, 1, 2)) == uresult def test_issue_15583(): N = mechanics.ReferenceFrame('N') result = '(n_x, n_y, n_z)' e = pretty((N.x, N.y, N.z)) assert e == result def test_matrixSymbolBold(): # Issue 15871 def boldpretty(expr): return xpretty(expr, use_unicode=True, wrap_line=False, mat_symbol_style="bold") from sympy import trace A = MatrixSymbol("A", 2, 2) assert boldpretty(trace(A)) == u'tr(𝐀)' A = MatrixSymbol("A", 3, 3) B = MatrixSymbol("B", 3, 3) C = MatrixSymbol("C", 3, 3) assert boldpretty(-A) == u'-𝐀' assert boldpretty(A - A*B - B) == u'-𝐁 -𝐀⋅𝐁 + 𝐀' assert boldpretty(-A*B - A*B*C - B) == u'-𝐁 -𝐀⋅𝐁 -𝐀⋅𝐁⋅𝐂' A = MatrixSymbol("Addot", 3, 3) assert boldpretty(A) == u'𝐀̈' omega = MatrixSymbol("omega", 3, 3) assert boldpretty(omega) == u'ω' omega = MatrixSymbol("omeganorm", 3, 3) assert boldpretty(omega) == u'‖ω‖' a = Symbol('alpha') b = Symbol('b') c = MatrixSymbol("c", 3, 1) d = MatrixSymbol("d", 3, 1) assert boldpretty(a*B*c+b*d) == u'b⋅𝐝 + α⋅𝐁⋅𝐜' d = MatrixSymbol("delta", 3, 1) B = MatrixSymbol("Beta", 3, 3) assert boldpretty(a*B*c+b*d) == u'b⋅δ + α⋅Β⋅𝐜' A = MatrixSymbol("A_2", 3, 3) assert boldpretty(A) == u'𝐀₂' def test_center_accent(): assert center_accent('a', u'\N{COMBINING TILDE}') == u'ã' assert center_accent('aa', u'\N{COMBINING TILDE}') == u'aã' assert center_accent('aaa', u'\N{COMBINING TILDE}') == u'aãa' assert center_accent('aaaa', u'\N{COMBINING TILDE}') == u'aaãa' assert center_accent('aaaaa', u'\N{COMBINING TILDE}') == u'aaãaa' assert center_accent('abcdefg', u'\N{COMBINING FOUR DOTS ABOVE}') == u'abcd⃜efg' def test_imaginary_unit(): from sympy import pretty # As it is redefined above assert pretty(1 + I, use_unicode=False) == '1 + I' assert pretty(1 + I, use_unicode=True) == u'1 + ⅈ' assert pretty(1 + I, use_unicode=False, imaginary_unit='j') == '1 + I' assert pretty(1 + I, use_unicode=True, imaginary_unit='j') == u'1 + ⅉ' raises(TypeError, lambda: pretty(I, imaginary_unit=I)) raises(ValueError, lambda: pretty(I, imaginary_unit="kkk"))
a6f24f64c88dee4e2f813de75df4dd4b322e82cadebc935de599298fe8f3e7da
from sympy.external import import_module matchpy = import_module("matchpy") from sympy.utilities.decorator import doctest_depends_on from sympy.core import Integer, Float import inspect, re from sympy import powsimp if matchpy: from matchpy import (Operation, CommutativeOperation, AssociativeOperation, ManyToOneReplacer, OneIdentityOperation, CustomConstraint) from sympy import Pow, Add, Integral, Basic, Mul, S, Function, E from sympy.functions import (log, sin, cos, tan, cot, csc, sec, sqrt, erf, exp as sym_exp, gamma, acosh, asinh, atanh, acoth, acsch, asech, cosh, sinh, tanh, coth, sech, csch, atan, acsc, asin, acot, acos, asec, fresnels, fresnelc, erfc, erfi, Ei, uppergamma, polylog, zeta, factorial, polygamma, digamma, li, expint, LambertW, loggamma) from sympy.integrals.rubi.utility_function import (Gamma, rubi_exp, rubi_log, ProductLog, PolyGamma, rubi_unevaluated_expr, process_trig) from sympy.utilities.matchpy_connector import op_iter, op_len @doctest_depends_on(modules=('matchpy',)) def rubi_object(): ''' Returns rubi ManyToOneReplacer by adding all rules from different modules. Uncomment the lines to add integration capabilities of that module. Currently, there are parsing issues with special_function, derivative and miscellaneous_integration. Hence they are commented. ''' from sympy.integrals.rubi.rules.integrand_simplification import integrand_simplification from sympy.integrals.rubi.rules.linear_products import linear_products from sympy.integrals.rubi.rules.quadratic_products import quadratic_products from sympy.integrals.rubi.rules.binomial_products import binomial_products from sympy.integrals.rubi.rules.trinomial_products import trinomial_products from sympy.integrals.rubi.rules.miscellaneous_algebraic import miscellaneous_algebraic from sympy.integrals.rubi.rules.exponential import exponential from sympy.integrals.rubi.rules.logarithms import logarithms from sympy.integrals.rubi.rules.sine import sine from sympy.integrals.rubi.rules.tangent import tangent from sympy.integrals.rubi.rules.secant import secant from sympy.integrals.rubi.rules.miscellaneous_trig import miscellaneous_trig from sympy.integrals.rubi.rules.inverse_trig import inverse_trig from sympy.integrals.rubi.rules.hyperbolic import hyperbolic from sympy.integrals.rubi.rules.inverse_hyperbolic import inverse_hyperbolic from sympy.integrals.rubi.rules.special_functions import special_functions #from sympy.integrals.rubi.rules.derivative import derivative #from sympy.integrals.rubi.rules.piecewise_linear import piecewise_linear from sympy.integrals.rubi.rules.miscellaneous_integration import miscellaneous_integration rules = [] rules_applied = [] rules += integrand_simplification(rules_applied) rules += linear_products(rules_applied) rules += quadratic_products(rules_applied) rules += binomial_products(rules_applied) rules += trinomial_products(rules_applied) rules += miscellaneous_algebraic(rules_applied) rules += exponential(rules_applied) rules += logarithms(rules_applied) rules += special_functions(rules_applied) rules += sine(rules_applied) rules += tangent(rules_applied) rules += secant(rules_applied) rules += miscellaneous_trig(rules_applied) rules += inverse_trig(rules_applied) rules += hyperbolic(rules_applied) rules += inverse_hyperbolic(rules_applied) #rubi = piecewise_linear(rubi) rules += miscellaneous_integration(rules_applied) rubi = ManyToOneReplacer(*rules) return rubi, rules_applied, rules _E = rubi_unevaluated_expr(E) Integrate = Function('Integrate') rubi, rules_applied, rules = rubi_object() def _has_cycle(): if rules_applied.count(rules_applied[-1]) == 1: return False if rules_applied[-1] == rules_applied[-2] == rules_applied[-3] == rules_applied[-4] == rules_applied[-5]: return True def process_final_integral(expr): ''' When there is recursion for more than 10 rules or in total 20 rules have been applied rubi returns `Integrate` in order to stop any further matching. After complete integration, Integrate needs to be replaced back to Integral. Also rubi's `exp` need to be replaced back to sympy's general `exp`. Examples ======== >>> from sympy import Function, E >>> from sympy.integrals.rubi.rubi import process_final_integral >>> from sympy.integrals.rubi.utility_function import rubi_unevaluated_expr >>> Integrate = Function("Integrate") >>> from sympy.abc import a, x >>> _E = rubi_unevaluated_expr(E) >>> process_final_integral(Integrate(a, x)) Integral(a, x) >>> process_final_integral(_E**5) exp(5) ''' if expr.has(Integrate): expr = expr.replace(Integrate, Integral) if expr.has(_E): expr = expr.replace(_E, E) return expr def rubi_powsimp(expr): ''' This function is needed to preprocess an expression as done in matchpy `x^a*x^b` in matchpy auotmatically transforms to `x^(a+b)` Examples ======== >>> from sympy.integrals.rubi.rubi import rubi_powsimp >>> from sympy.abc import a, b, x >>> rubi_powsimp(x**a*x**b) x**(a+b) ''' lst_pow =[] lst_non_pow = [] if isinstance(expr, Mul): for i in expr.args: if isinstance(i, (Pow, exp, sym_exp)): lst_pow.append(i) else: lst_non_pow.append(i) return powsimp(Mul(*lst_pow))*Mul(*lst_non_pow) return expr @doctest_depends_on(modules=('matchpy',)) def rubi_integrate(expr, var, showsteps=False): ''' Rule based algorithm for integration. Integrates the expression by applying transformation rules to the expression. Returns `Integrate` if an expression cannot be integrated. Parameters ========== expr : integrand expression var : variable of integration Returns Integral object if unable to integrate. ''' expr = expr.replace(sym_exp, exp) rules_applied[:] = [] expr = process_trig(expr) expr = rubi_powsimp(expr) if isinstance(expr, (int, Integer)) or isinstance(expr, (float, Float)): return S(expr)*var if isinstance(expr, Add): results = 0 for ex in expr.args: rules_applied[:] = [] results += rubi.replace(Integral(ex, var)) rules_applied[:] = [] return process_final_integral(results) results = rubi.replace(Integral(expr, var), max_count = 10) return process_final_integral(results) @doctest_depends_on(modules=('matchpy',)) def util_rubi_integrate(expr, var, showsteps=False): expr = process_trig(expr) expr = expr.replace(sym_exp, exp) if isinstance(expr, (int, Integer)) or isinstance(expr, (float, Float)): return S(expr)*var if isinstance(expr, Add): return rubi_integrate(expr, var) if len(rules_applied) > 10: if _has_cycle() or len(rules_applied) > 20: return Integrate(expr, var) results = rubi.replace(Integral(expr, var), max_count = 10) rules_applied[:] = [] return results @doctest_depends_on(modules=('matchpy',)) def get_matching_rule_definition(expr, var): ''' Prints the list or rules which match to `expr`. Parameters ========== expr : integrand expression var : variable of integration ''' matcher = rubi.matcher miter = matcher.match(Integral(expr, var)) for fun, e in miter: print("Rule matching: ") print(inspect.getsourcefile(fun)) code, lineno = inspect.getsourcelines(fun) print("On line: ", lineno) print("\n".join(code)) print("Pattern matching: ") pattno = int(re.match(r"^\s*rule(\d+)", code[0]).group(1)) print(matcher.patterns[pattno-1]) print(e) print()
d14fbd2bc4771f9c092029be447a341be9cc1db0aa269246464561614bf90b17
''' Utility functions for Rubi integration. See: http://www.apmaths.uwo.ca/~arich/IntegrationRules/PortableDocumentFiles/Integration%20utility%20functions.pdf ''' from sympy.external import import_module matchpy = import_module("matchpy") from sympy.utilities.decorator import doctest_depends_on from sympy.functions.elementary.integers import floor, frac from sympy.functions import (log as sym_log , sin, cos, tan, cot, csc, sec, sqrt, erf, gamma, uppergamma, polygamma, digamma, loggamma, factorial, zeta, LambertW) from sympy.functions.elementary.hyperbolic import acosh, asinh, atanh, acoth, acsch, asech, cosh, sinh, tanh, coth, sech, csch from sympy.functions.elementary.trigonometric import atan, acsc, asin, acot, acos, asec, atan2 from sympy.polys.polytools import Poly, quo, rem, total_degree, degree from sympy.simplify.simplify import fraction, simplify, cancel, powsimp from sympy.core.sympify import sympify from sympy.utilities.iterables import postorder_traversal from sympy.functions.special.error_functions import fresnelc, fresnels, erfc, erfi, Ei, expint, li, Si, Ci, Shi, Chi from sympy.functions.elementary.complexes import im, re, Abs from sympy.core.exprtools import factor_terms from sympy import (Basic, E, polylog, N, Wild, WildFunction, factor, gcd, Sum, S, I, Mul, Integer, Float, Dict, Symbol, Rational, Add, hyper, symbols, sqf_list, sqf, Max, factorint, factorrat, Min, sign, E, Function, collect, FiniteSet, nsimplify, expand_trig, expand, poly, apart, lcm, And, Pow, pi, zoo, oo, Integral, UnevaluatedExpr, PolynomialError, Dummy, exp as sym_exp, powdenest, PolynomialDivisionFailed, discriminant, UnificationFailed, appellf1) from sympy.functions.special.hyper import TupleArg from sympy.functions.special.elliptic_integrals import elliptic_f, elliptic_e, elliptic_pi from sympy.utilities.iterables import flatten from random import randint from sympy.logic.boolalg import Or class rubi_unevaluated_expr(UnevaluatedExpr): ''' This is needed to convert `exp` as `Pow`. sympy's UnevaluatedExpr has an issue with `is_commutative`. ''' @property def is_commutative(self): from sympy.core.logic import fuzzy_and return fuzzy_and(a.is_commutative for a in self.args) _E = rubi_unevaluated_expr(E) class rubi_exp(Function): ''' sympy's exp is not identified as `Pow`. So it is not matched with `Pow`. Like `a = exp(2)` is not identified as `Pow(E, 2)`. Rubi rules need it. So, another exp has been created only for rubi module. Examples ======== >>> from sympy import Pow, exp as sym_exp >>> isinstance(sym_exp(2), Pow) False >>> from sympy.integrals.rubi.utility_function import rubi_exp >>> isinstance(rubi_exp(2), Pow) True ''' @classmethod def eval(cls, *args): return Pow(_E, args[0]) class rubi_log(Function): ''' For rule matching different `exp` has been used. So for proper results, `log` is modified little only for case when it encounters rubi's `exp`. For other cases it is same. Examples ======== >>> from sympy.integrals.rubi.utility_function import rubi_exp, rubi_log >>> a = rubi_exp(2) >>> rubi_log(a) 2 ''' @classmethod def eval(cls, *args): if args[0].has(_E): return sym_log(args[0]).doit() else: return sym_log(args[0]) if matchpy: from matchpy import Arity, Operation, CommutativeOperation, AssociativeOperation, OneIdentityOperation, CustomConstraint, Pattern, ReplacementRule, ManyToOneReplacer from matchpy.expressions.functions import op_iter, create_operation_expression, op_len from sympy.integrals.rubi.symbol import WC from matchpy import is_match, replace_all from sympy.utilities.matchpy_connector import Operation class UtilityOperator(Operation): name = 'UtilityOperator' arity = Arity.variadic commutative=False associative=True Operation.register(rubi_log) Operation.register(rubi_exp) A_, B_, C_, F_, G_, a_, b_, c_, d_, e_, f_, g_, h_, i_, j_, k_, l_, m_, n_, p_, q_, r_, t_, u_, v_, s_, w_, x_, z_ = [WC(i) for i in 'ABCFGabcdefghijklmnpqrtuvswxz'] a, b, c, d, e = symbols('a b c d e') class Int(Function): ''' Integrates given `expr` by matching rubi rules. ''' @classmethod def eval(cls, expr, var): if isinstance(expr, (int, Integer, float, Float)): return S(expr)*var from sympy.integrals.rubi.rubi import util_rubi_integrate return util_rubi_integrate(expr, var) def replace_pow_exp(z): ''' This function converts back rubi's `exp` to general sympy's `exp`. Examples ======== >>> from sympy.integrals.rubi.utility_function import rubi_exp, replace_pow_exp >>> expr = rubi_exp(5) >>> expr E**5 >>> replace_pow_exp(expr) exp(5) ''' z = S(z) if z.has(_E): z = z.replace(_E, E) return z def Simplify(expr): expr = simplify(expr) return expr def Set(expr, value): return {expr: value} def With(subs, expr): if isinstance(subs, dict): k = list(subs.keys())[0] expr = expr.xreplace({k: subs[k]}) else: for i in subs: k = list(i.keys())[0] expr = expr.xreplace({k: i[k]}) return expr def Module(subs, expr): return With(subs, expr) def Scan(f, expr): # evaluates f applied to each element of expr in turn. for i in expr: yield f(i) def MapAnd(f, l, x=None): # MapAnd[f,l] applies f to the elements of list l until False is returned; else returns True if x: for i in l: if f(i, x) == False: return False return True else: for i in l: if f(i) == False: return False return True def FalseQ(u): if isinstance(u, (Dict, dict)): return FalseQ(*list(u.values())) return u == False def ZeroQ(*expr): if len(expr) == 1: if isinstance(expr[0], list): return list(ZeroQ(i) for i in expr[0]) else: return Simplify(expr[0]) == 0 else: return all(ZeroQ(i) for i in expr) def OneQ(a): if a == S(1): return True return False def NegativeQ(u): u = Simplify(u) if u in (zoo, oo): return False if u.is_comparable: res = u < 0 if not res.is_Relational: return res return False def NonzeroQ(expr): return Simplify(expr) != 0 def FreeQ(nodes, var): if var == Int: return FreeQ(nodes, Integral) if isinstance(nodes, list): return not any(S(expr).has(var) for expr in nodes) else: nodes = S(nodes) return not nodes.has(var) def NFreeQ(nodes, var): ''' Note that in rubi 4.10.8 this function was not defined in `Integration Utility Functions.m`, but was used in rules. So explicitly its returning `False` ''' return False # return not FreeQ(nodes, var) def List(*var): return list(var) def PositiveQ(var): var = Simplify(var) if var in (zoo, oo): return False if var.is_comparable: res = var > 0 if not res.is_Relational: return res return False def PositiveIntegerQ(*args): return all(var.is_Integer and PositiveQ(var) for var in args) def NegativeIntegerQ(*args): return all(var.is_Integer and NegativeQ(var) for var in args) def IntegerQ(var): var = Simplify(var) if isinstance(var, (int, Integer)): return True else: return var.is_Integer def IntegersQ(*var): return all(IntegerQ(i) for i in var) def _ComplexNumberQ(var): i = S(im(var)) if isinstance(i, (Integer, Float)): return i != 0 else: return False def ComplexNumberQ(*var): """ ComplexNumberQ(m, n,...) returns True if m, n, ... are all explicit complex numbers, else it returns False. Examples ======== >>> from sympy.integrals.rubi.utility_function import ComplexNumberQ >>> from sympy import I >>> ComplexNumberQ(1 + I*2, I) True >>> ComplexNumberQ(2, I) False """ return all(_ComplexNumberQ(i) for i in var) def PureComplexNumberQ(*var): return all((_ComplexNumberQ(i) and re(i)==0) for i in var) def RealNumericQ(u): return u.is_real def PositiveOrZeroQ(u): return u.is_real and u >= 0 def NegativeOrZeroQ(u): return u.is_real and u <= 0 def FractionOrNegativeQ(u): return FractionQ(u) or NegativeQ(u) def NegQ(var): return Not(PosQ(var)) and NonzeroQ(var) def Equal(a, b): return a == b def Unequal(a, b): return a != b def IntPart(u): # IntPart[u] returns the sum of the integer terms of u. if ProductQ(u): if IntegerQ(First(u)): return First(u)*IntPart(Rest(u)) elif IntegerQ(u): return u elif FractionQ(u): return IntegerPart(u) elif SumQ(u): res = 0 for i in u.args: res += IntPart(i) return res return 0 def FracPart(u): # FracPart[u] returns the sum of the non-integer terms of u. if ProductQ(u): if IntegerQ(First(u)): return First(u)*FracPart(Rest(u)) if IntegerQ(u): return 0 elif FractionQ(u): return FractionalPart(u) elif SumQ(u): res = 0 for i in u.args: res += FracPart(i) return res else: return u def RationalQ(*nodes): return all(var.is_Rational for var in nodes) def ProductQ(expr): return S(expr).is_Mul def SumQ(expr): return expr.is_Add def NonsumQ(expr): return not SumQ(expr) def Subst(a, x, y): if None in [a, x, y]: return None if a.has(Function('Integrate')): # substituting in `Function(Integrate)` won't take care of properties of Integral a = a.replace(Function('Integrate'), Integral) return a.subs(x, y) # return a.xreplace({x: y}) def First(expr, d=None): """ Gives the first element if it exists, or d otherwise. Examples ======== >>> from sympy.integrals.rubi.utility_function import First >>> from sympy.abc import a, b, c >>> First(a + b + c) a >>> First(a*b*c) a """ if isinstance(expr, list): return expr[0] if isinstance(expr, Symbol): return expr else: if SumQ(expr) or ProductQ(expr): l = Sort(expr.args) return l[0] else: return expr.args[0] def Rest(expr): """ Gives rest of the elements if it exists Examples ======== >>> from sympy.integrals.rubi.utility_function import Rest >>> from sympy.abc import a, b, c >>> Rest(a + b + c) b + c >>> Rest(a*b*c) b*c """ if isinstance(expr, list): return expr[1:] else: if SumQ(expr) or ProductQ(expr): l = Sort(expr.args) return expr.func(*l[1:]) else: return expr.args[1] def SqrtNumberQ(expr): # SqrtNumberQ[u] returns True if u^2 is a rational number; else it returns False. if PowerQ(expr): m = expr.base n = expr.exp return (IntegerQ(n) and SqrtNumberQ(m)) or (IntegerQ(n-S(1)/2) and RationalQ(m)) elif expr.is_Mul: return all(SqrtNumberQ(i) for i in expr.args) else: return RationalQ(expr) or expr == I def SqrtNumberSumQ(u): return SumQ(u) and SqrtNumberQ(First(u)) and SqrtNumberQ(Rest(u)) or ProductQ(u) and SqrtNumberQ(First(u)) and SqrtNumberSumQ(Rest(u)) def LinearQ(expr, x): """ LinearQ(expr, x) returns True iff u is a polynomial of degree 1. Examples ======== >>> from sympy.integrals.rubi.utility_function import LinearQ >>> from sympy.abc import x, y, a >>> LinearQ(a, x) False >>> LinearQ(3*x + y**2, x) True >>> LinearQ(3*x + y**2, y) False """ if isinstance(expr, list): return all(LinearQ(i, x) for i in expr) elif expr.is_polynomial(x): if degree(Poly(expr, x), gen=x) == 1: return True return False def Sqrt(a): return sqrt(a) def ArcCosh(a): return acosh(a) class Util_Coefficient(Function): def doit(self): if len(self.args) == 2: n = 1 else: n = Simplify(self.args[2]) if NumericQ(n): expr = expand(self.args[0]) if isinstance(n, (int, Integer)): return expr.coeff(self.args[1], n) else: return expr.coeff(self.args[1]**n) else: return self def Coefficient(expr, var, n=1): """ Coefficient(expr, var) gives the coefficient of form in the polynomial expr. Coefficient(expr, var, n) gives the coefficient of var**n in expr. Examples ======== >>> from sympy.integrals.rubi.utility_function import Coefficient >>> from sympy.abc import x, a, b, c >>> Coefficient(7 + 2*x + 4*x**3, x, 1) 2 >>> Coefficient(a + b*x + c*x**3, x, 0) a >>> Coefficient(a + b*x + c*x**3, x, 4) 0 >>> Coefficient(b*x + c*x**3, x, 3) c """ if NumericQ(n): if expr == 0 or n in (zoo, oo): return 0 expr = expand(expr) if isinstance(n, (int, Integer)): return expr.coeff(var, n) else: return expr.coeff(var**n) return Util_Coefficient(expr, var, n) def Denominator(var): var = Simplify(var) if isinstance(var, Pow): if isinstance(var.exp, Integer): if var.exp > 0: return Pow(Denominator(var.base), var.exp) elif var.exp < 0: return Pow(Numerator(var.base), -1*var.exp) elif isinstance(var, Add): var = factor(var) return fraction(var)[1] def Hypergeometric2F1(a, b, c, z): return hyper([a, b], [c], z) def Not(var): if isinstance(var, bool): return not var elif var.is_Relational: var = False return not var def FractionalPart(a): return frac(a) def IntegerPart(a): return floor(a) def AppellF1(a, b1, b2, c, x, y): return appellf1(a, b1, b2, c, x, y) def EllipticPi(*args): return elliptic_pi(*args) def EllipticE(*args): return elliptic_e(*args) def EllipticF(Phi, m): return elliptic_f(Phi, m) def ArcTan(a, b = None): if b is None: return atan(a) else: return atan2(a, b) def ArcCot(a): return acot(a) def ArcCoth(a): return acoth(a) def ArcTanh(a): return atanh(a) def ArcSin(a): return asin(a) def ArcSinh(a): return asinh(a) def ArcCos(a): return acos(a) def ArcCsc(a): return acsc(a) def ArcSec(a): return asec(a) def ArcCsch(a): return acsch(a) def ArcSech(a): return asech(a) def Sinh(u): return sinh(u) def Tanh(u): return tanh(u) def Cosh(u): return cosh(u) def Sech(u): return sech(u) def Csch(u): return csch(u) def Coth(u): return coth(u) def LessEqual(*args): for i in range(0, len(args) - 1): try: if args[i] > args[i + 1]: return False except: return False return True def Less(*args): for i in range(0, len(args) - 1): try: if args[i] >= args[i + 1]: return False except: return False return True def Greater(*args): for i in range(0, len(args) - 1): try: if args[i] <= args[i + 1]: return False except: return False return True def GreaterEqual(*args): for i in range(0, len(args) - 1): try: if args[i] < args[i + 1]: return False except: return False return True def FractionQ(*args): """ FractionQ(m, n,...) returns True if m, n, ... are all explicit fractions, else it returns False. Examples ======== >>> from sympy import S >>> from sympy.integrals.rubi.utility_function import FractionQ >>> FractionQ(S('3')) False >>> FractionQ(S('3')/S('2')) True """ return all(i.is_Rational for i in args) and all(Denominator(i)!= S(1) for i in args) def IntLinearcQ(a, b, c, d, m, n, x): # returns True iff (a+b*x)^m*(c+d*x)^n is integrable wrt x in terms of non-hypergeometric functions. return IntegerQ(m) or IntegerQ(n) or IntegersQ(S(3)*m, S(3)*n) or IntegersQ(S(4)*m, S(4)*n) or IntegersQ(S(2)*m, S(6)*n) or IntegersQ(S(6)*m, S(2)*n) or IntegerQ(m + n) Defer = UnevaluatedExpr def Expand(expr): return expr.expand() def IndependentQ(u, x): """ If u is free from x IndependentQ(u, x) returns True else False. Examples ======== >>> from sympy.integrals.rubi.utility_function import IndependentQ >>> from sympy.abc import x, a, b >>> IndependentQ(a + b*x, x) False >>> IndependentQ(a + b, x) True """ return FreeQ(u, x) def PowerQ(expr): return expr.is_Pow or ExpQ(expr) def IntegerPowerQ(u): if isinstance(u, sym_exp): #special case for exp return IntegerQ(u.args[0]) return PowerQ(u) and IntegerQ(u.args[1]) def PositiveIntegerPowerQ(u): if isinstance(u, sym_exp): return IntegerQ(u.args[0]) and PositiveQ(u.args[0]) return PowerQ(u) and IntegerQ(u.args[1]) and PositiveQ(u.args[1]) def FractionalPowerQ(u): if isinstance(u, sym_exp): return FractionQ(u.args[0]) return PowerQ(u) and FractionQ(u.args[1]) def AtomQ(expr): expr = sympify(expr) if isinstance(expr, list): return False if expr in [None, True, False, _E]: # [None, True, False] are atoms in mathematica and _E is also an atom return True # elif isinstance(expr, list): # return all(AtomQ(i) for i in expr) else: return expr.is_Atom def ExpQ(u): u = replace_pow_exp(u) return Head(u) in (sym_exp, rubi_exp) def LogQ(u): return u.func in (sym_log, Log) def Head(u): return u.func def MemberQ(l, u): if isinstance(l, list): return u in l else: return u in l.args def TrigQ(u): if AtomQ(u): x = u else: x = Head(u) return MemberQ([sin, cos, tan, cot, sec, csc], x) def SinQ(u): return Head(u) == sin def CosQ(u): return Head(u) == cos def TanQ(u): return Head(u) == tan def CotQ(u): return Head(u) == cot def SecQ(u): return Head(u) == sec def CscQ(u): return Head(u) == csc def Sin(u): return sin(u) def Cos(u): return cos(u) def Tan(u): return tan(u) def Cot(u): return cot(u) def Sec(u): return sec(u) def Csc(u): return csc(u) def HyperbolicQ(u): if AtomQ(u): x = u else: x = Head(u) return MemberQ([sinh, cosh, tanh, coth, sech, csch], x) def SinhQ(u): return Head(u) == sinh def CoshQ(u): return Head(u) == cosh def TanhQ(u): return Head(u) == tanh def CothQ(u): return Head(u) == coth def SechQ(u): return Head(u) == sech def CschQ(u): return Head(u) == csch def InverseTrigQ(u): if AtomQ(u): x = u else: x = Head(u) return MemberQ([asin, acos, atan, acot, asec, acsc], x) def SinCosQ(f): return MemberQ([sin, cos, sec, csc], Head(f)) def SinhCoshQ(f): return MemberQ([sinh, cosh, sech, csch], Head(f)) def LeafCount(expr): return len(list(postorder_traversal(expr))) def Numerator(u): u = Simplify(u) if isinstance(u, Pow): if isinstance(u.exp, Integer): if u.exp > 0: return Pow(Numerator(u.base), u.exp) elif u.exp < 0: return Pow(Denominator(u.base), -1*u.exp) elif isinstance(u, Add): u = factor(u) return fraction(u)[0] def NumberQ(u): if isinstance(u, (int, float)): return True return u.is_number def NumericQ(u): return N(u).is_number def Length(expr): """ Returns number of elements in the experssion just as sympy's len. Examples ======== >>> from sympy.integrals.rubi.utility_function import Length >>> from sympy.abc import x, a, b >>> from sympy import cos, sin >>> Length(a + b) 2 >>> Length(sin(a)*cos(a)) 2 """ if isinstance(expr, list): return len(expr) return len(expr.args) def ListQ(u): return isinstance(u, list) def Im(u): u = S(u) return im(u.doit()) def Re(u): u = S(u) return re(u.doit()) def InverseHyperbolicQ(u): if not u.is_Atom: u = Head(u) return u in [acosh, asinh, atanh, acoth, acsch, acsch] def InverseFunctionQ(u): # returns True if u is a call on an inverse function; else returns False. return LogQ(u) or InverseTrigQ(u) and Length(u) <= 1 or InverseHyperbolicQ(u) or u.func == polylog def TrigHyperbolicFreeQ(u, x): # If u is free of trig, hyperbolic and calculus functions involving x, TrigHyperbolicFreeQ[u,x] returns true; else it returns False. if AtomQ(u): return True else: if TrigQ(u) | HyperbolicQ(u) | CalculusQ(u): return FreeQ(u, x) else: for i in u.args: if not TrigHyperbolicFreeQ(i, x): return False return True def InverseFunctionFreeQ(u, x): # If u is free of inverse, calculus and hypergeometric functions involving x, InverseFunctionFreeQ[u,x] returns true; else it returns False. if AtomQ(u): return True else: if InverseFunctionQ(u) or CalculusQ(u) or u.func == hyper or u.func == appellf1: return FreeQ(u, x) else: for i in u.args: if not ElementaryFunctionQ(i): return False return True def RealQ(u): if ListQ(u): return MapAnd(RealQ, u) elif NumericQ(u): return ZeroQ(Im(N(u))) elif PowerQ(u): u = u.base v = u.exp return RealQ(u) & RealQ(v) & (IntegerQ(v) | PositiveOrZeroQ(u)) elif u.is_Mul: return all(RealQ(i) for i in u.args) elif u.is_Add: return all(RealQ(i) for i in u.args) elif u.is_Function: f = u.func u = u.args[0] if f in [sin, cos, tan, cot, sec, csc, atan, acot, erf]: return RealQ(u) else: if f in [asin, acos]: return LE(-1, u, 1) else: if f == sym_log: return PositiveOrZeroQ(u) else: return False else: return False def EqQ(u, v): return ZeroQ(u - v) def FractionalPowerFreeQ(u): if AtomQ(u): return True elif FractionalPowerQ(u): return False def ComplexFreeQ(u): if AtomQ(u) and Not(ComplexNumberQ(u)): return True else: return False def PolynomialQ(u, x = None): if x is None : return u.is_polynomial() if isinstance(x, Pow): if isinstance(x.exp, Integer): deg = degree(u, x.base) if u.is_polynomial(x): if deg % x.exp !=0 : return False try: p = Poly(u, x.base) except PolynomialError: return False c_list = p.all_coeffs() coeff_list = c_list[:-1:x.exp] coeff_list += [c_list[-1]] for i in coeff_list: if not i == 0: index = c_list.index(i) c_list[index] = 0 if all(i == 0 for i in c_list): return True else: return False return u.is_polynomial(x) else: return False elif isinstance(x.exp, (Float, Rational)): #not full - proof if FreeQ(simplify(u), x.base) and Exponent(u, x.base) == 0: if not all(FreeQ(u, i) for i in x.base.free_symbols): return False if isinstance(x, Mul): return all(PolynomialQ(u, i) for i in x.args) return u.is_polynomial(x) def FactorSquareFree(u): return sqf(u) def PowerOfLinearQ(expr, x): u = Wild('u') w = Wild('w') m = Wild('m') n = Wild('n') Match = expr.match(u**m) if PolynomialQ(Match[u], x) and FreeQ(Match[m], x): if IntegerQ(Match[m]): e = FactorSquareFree(Match[u]).match(w**n) if FreeQ(e[n], x) and LinearQ(e[w], x): return True else: return False else: return LinearQ(Match[u], x) else: return False def Exponent(expr, x, h = None): expr = Expand(S(expr)) if h is None: if S(expr).is_number or (not expr.has(x)): return 0 if PolynomialQ(expr, x): if isinstance(x, Rational): return degree(Poly(expr, x), x) return degree(expr, gen = x) else: return 0 else: if S(expr).is_number or (not expr.has(x)): res = [0] if expr.is_Add: expr = collect(expr, x) lst = [] k = 1 for t in expr.args: if t.has(x): if isinstance(x, Rational): lst += [degree(Poly(t, x), x)] else: lst += [degree(t, gen = x)] else: if k == 1: lst += [0] k += 1 lst.sort() res = lst else: if isinstance(x, Rational): res = [degree(Poly(expr, x), x)] else: res = [degree(expr, gen = x)] return h(*res) def QuadraticQ(u, x): # QuadraticQ(u, x) returns True iff u is a polynomial of degree 2 and not a monomial of the form a x^2 if ListQ(u): for expr in u: if Not(PolyQ(expr, x, 2) and Not(Coefficient(expr, x, 0) == 0 and Coefficient(expr, x, 1) == 0)): return False return True else: return PolyQ(u, x, 2) and Not(Coefficient(u, x, 0) == 0 and Coefficient(u, x, 1) == 0) def LinearPairQ(u, v, x): # LinearPairQ(u, v, x) returns True iff u and v are linear not equal x but u/v is a constant wrt x return LinearQ(u, x) and LinearQ(v, x) and NonzeroQ(u-x) and ZeroQ(Coefficient(u, x, 0)*Coefficient(v, x, 1)-Coefficient(u, x, 1)*Coefficient(v, x, 0)) def BinomialParts(u, x): if PolynomialQ(u, x): if Exponent(u, x) > 0: lst = Exponent(u, x, List) if len(lst)==1: return [0, Coefficient(u, x, Exponent(u, x)), Exponent(u,x)] elif len(lst) == 2 and lst[0] == 0: return [Coefficient(u, x, 0), Coefficient(u, x, Exponent(u, x)), Exponent(u, x)] else: return False else: return False elif PowerQ(u): if u.base == x and FreeQ(u.exp, x): return [0, 1, u.exp] else: return False elif ProductQ(u): if FreeQ(First(u), x): lst2 = BinomialParts(Rest(u), x) if AtomQ(lst2): return False else: return [First(u)*lst2[0], First(u)*lst2[1], lst2[2]] elif FreeQ(Rest(u), x): lst1 = BinomialParts(First(u), x) if AtomQ(lst1): return False else: return [Rest(u)*lst1[0], Rest(u)*lst1[1], lst1[2]] lst1 = BinomialParts(First(u), x) if AtomQ(lst1): return False lst2 = BinomialParts(Rest(u), x) if AtomQ(lst2): return False a = lst1[0] b = lst1[1] m = lst1[2] c = lst2[0] d = lst2[1] n = lst2[2] if ZeroQ(a): if ZeroQ(c): return [0, b*d, m + n] elif ZeroQ(m + n): return [b*d, b*c, m] else: return False if ZeroQ(c): if ZeroQ(m + n): return [b*d, a*d, n] else: return False if EqQ(m, n) and ZeroQ(a*d + b*c): return [a*c, b*d, 2*m] else: return False elif SumQ(u): if FreeQ(First(u),x): lst2 = BinomialParts(Rest(u), x) if AtomQ(lst2): return False else: return [First(u) + lst2[0], lst2[1], lst2[2]] elif FreeQ(Rest(u), x): lst1 = BinomialParts(First(u), x) if AtomQ(lst1): return False else: return[Rest(u) + lst1[0], lst1[1], lst1[2]] lst1 = BinomialParts(First(u), x) if AtomQ(lst1): return False lst2 = BinomialParts(Rest(u),x) if AtomQ(lst2): return False if EqQ(lst1[2], lst2[2]): return [lst1[0] + lst2[0], lst1[1] + lst2[1], lst1[2]] else: return False else: return False def TrinomialParts(u, x): # If u is equivalent to a trinomial of the form a + b*x^n + c*x^(2*n) where n!=0, b!=0 and c!=0, TrinomialParts[u,x] returns the list {a,b,c,n}; else it returns False. u = sympify(u) if PolynomialQ(u, x): lst = CoefficientList(u, x) if len(lst)<3 or EvenQ(sympify(len(lst))) or ZeroQ((len(lst)+1)/2): return False #Catch( # Scan(Function(if ZeroQ(lst), Null, Throw(False), Drop(Drop(Drop(lst, [(len(lst)+1)/2]), 1), -1]; # [First(lst), lst[(len(lst)+1)/2], Last(lst), (len(lst)-1)/2]): if PowerQ(u): if EqQ(u.exp, 2): lst = BinomialParts(u.base, x) if not lst or ZeroQ(lst[0]): return False else: return [lst[0]**2, 2*lst[0]*lst[1], lst[1]**2, lst[2]] else: return False if ProductQ(u): if FreeQ(First(u), x): lst2 = TrinomialParts(Rest(u), x) if not lst2: return False else: return [First(u)*lst2[0], First(u)*lst2[1], First(u)*lst2[2], lst2[3]] if FreeQ(Rest(u), x): lst1 = TrinomialParts(First(u), x) if not lst1: return False else: return [Rest(u)*lst1[0], Rest(u)*lst1[1], Rest(u)*lst1[2], lst1[3]] lst1 = BinomialParts(First(u), x) if not lst1: return False lst2 = BinomialParts(Rest(u), x) if not lst2: return False a = lst1[0] b = lst1[1] m = lst1[2] c = lst2[0] d = lst2[1] n = lst2[2] if EqQ(m, n) and NonzeroQ(a*d+b*c): return [a*c, a*d + b*c, b*d, m] else: return False if SumQ(u): if FreeQ(First(u), x): lst2 = TrinomialParts(Rest(u), x) if not lst2: return False else: return [First(u)+lst2[0], lst2[1], lst2[2], lst2[3]] if FreeQ(Rest(u), x): lst1 = TrinomialParts(First(u), x) if not lst1: return False else: return [Rest(u)+lst1[0], lst1[1], lst1[2], lst1[3]] lst1 = TrinomialParts(First(u), x) if not lst1: lst3 = BinomialParts(First(u), x) if not lst3: return False lst2 = TrinomialParts(Rest(u), x) if not lst2: lst4 = BinomialParts(Rest(u), x) if not lst4: return False if EqQ(lst3[2], 2*lst4[2]): return [lst3[0]+lst4[0], lst4[1], lst3[1], lst4[2]] if EqQ(lst4[2], 2*lst3[2]): return [lst3[0]+lst4[0], lst3[1], lst4[1], lst3[2]] else: return False if EqQ(lst3[2], lst2[3]) and NonzeroQ(lst3[1]+lst2[1]): return [lst3[0]+lst2[0], lst3[1]+lst2[1], lst2[2], lst2[3]] if EqQ(lst3[2], 2*lst2[3]) and NonzeroQ(lst3[1]+lst2[2]): return [lst3[0]+lst2[0], lst2[1], lst3[1]+lst2[2], lst2[3]] else: return False lst2 = TrinomialParts(Rest(u), x) if AtomQ(lst2): lst4 = BinomialParts(Rest(u), x) if not lst4: return False if EqQ(lst4[2], lst1[3]) and NonzeroQ(lst1[1]+lst4[0]): return [lst1[0]+lst4[0], lst1[1]+lst4[1], lst1[2], lst1[3]] if EqQ(lst4[2], 2*lst1[3]) and NonzeroQ(lst1[2]+lst4[1]): return [lst1[0]+lst4[0], lst1[1], lst1[2]+lst4[1], lst1[3]] else: return False if EqQ(lst1[3], lst2[3]) and NonzeroQ(lst1[1]+lst2[1]) and NonzeroQ(lst1[2]+lst2[2]): return [lst1[0]+lst2[0], lst1[1]+lst2[1], lst1[2]+lst2[2], lst1[3]] else: return False else: return False def PolyQ(u, x, n=None): # returns True iff u is a polynomial of degree n. if ListQ(u): return all(PolyQ(i, x) for i in u) if n==None: if u == x: return False elif isinstance(x, Pow): n = x.exp x_base = x.base if FreeQ(n, x_base): if PositiveIntegerQ(n): return PolyQ(u, x_base) and (PolynomialQ(u, x) or PolynomialQ(Together(u), x)) elif AtomQ(n): return PolynomialQ(u, x) and FreeQ(CoefficientList(u, x), x_base) else: return False return PolynomialQ(u, x) or PolynomialQ(u, Together(x)) else: return PolynomialQ(u, x) and Coefficient(u, x, n) != 0 and Exponent(u, x) == n def EvenQ(u): # gives True if expr is an even integer, and False otherwise. return isinstance(u, (Integer, int)) and u%2 == 0 def OddQ(u): # gives True if expr is an odd integer, and False otherwise. return isinstance(u, (Integer, int)) and u%2 == 1 def PerfectSquareQ(u): # (* If u is a rational number whose squareroot is rational or if u is of the form u1^n1 u2^n2 ... # and n1, n2, ... are even, PerfectSquareQ[u] returns True; else it returns False. *) if RationalQ(u): return Greater(u, 0) and RationalQ(Sqrt(u)) elif PowerQ(u): return EvenQ(u.exp) elif ProductQ(u): return PerfectSquareQ(First(u)) and PerfectSquareQ(Rest(u)) elif SumQ(u): s = Simplify(u) if NonsumQ(s): return PerfectSquareQ(s) return False else: return False def NiceSqrtAuxQ(u): if RationalQ(u): return u > 0 elif PowerQ(u): return EvenQ(u.exp) elif ProductQ(u): return NiceSqrtAuxQ(First(u)) and NiceSqrtAuxQ(Rest(u)) elif SumQ(u): s = Simplify(u) return NonsumQ(s) and NiceSqrtAuxQ(s) else: return False def NiceSqrtQ(u): return Not(NegativeQ(u)) and NiceSqrtAuxQ(u) def Together(u): return factor(u) def PosAux(u): if RationalQ(u): return u>0 elif NumberQ(u): if ZeroQ(Re(u)): return Im(u) > 0 else: return Re(u) > 0 elif NumericQ(u): v = N(u) if ZeroQ(Re(v)): return Im(v) > 0 else: return Re(v) > 0 elif PowerQ(u): if OddQ(u.exp): return PosAux(u.base) else: return True elif ProductQ(u): if PosAux(First(u)): return PosAux(Rest(u)) else: return not PosAux(Rest(u)) elif SumQ(u): return PosAux(First(u)) else: res = u > 0 if res in(True, False): return res return True def PosQ(u): # If u is not 0 and has a positive form, PosQ[u] returns True, else it returns False. return PosAux(TogetherSimplify(u)) def CoefficientList(u, x): if PolynomialQ(u, x): return list(reversed(Poly(u, x).all_coeffs())) else: return [] def ReplaceAll(expr, args): if isinstance(args, list): n_args = {} for i in args: n_args.update(i) return expr.subs(n_args) return expr.subs(args) def ExpandLinearProduct(v, u, a, b, x): # If u is a polynomial in x, ExpandLinearProduct[v,u,a,b,x] expands v*u into a sum of terms of the form c*v*(a+b*x)^n. if FreeQ([a, b], x) and PolynomialQ(u, x): lst = CoefficientList(ReplaceAll(u, {x: (x - a)/b}), x) lst = [SimplifyTerm(i, x) for i in lst] res = 0 for k in range(1, len(lst)+1): res = res + Simplify(v*lst[k-1]*(a + b*x)**(k - 1)) return res return u*v def GCD(*args): args = S(args) if len(args) == 1: if isinstance(args[0], (int, Integer)): return args[0] else: return S(1) return gcd(*args) def ContentFactor(expn): return factor_terms(expn) def NumericFactor(u): # returns the real numeric factor of u. if NumberQ(u): if ZeroQ(Im(u)): return u elif ZeroQ(Re(u)): return Im(u) else: return S(1) elif PowerQ(u): if RationalQ(u.base) and RationalQ(u.exp): if u.exp > 0: return 1/Denominator(u.base) else: return 1/(1/Denominator(u.base)) else: return S(1) elif ProductQ(u): return Mul(*[NumericFactor(i) for i in u.args]) elif SumQ(u): if LeafCount(u) < 50: c = ContentFactor(u) if SumQ(c): return S(1) else: return NumericFactor(c) else: m = NumericFactor(First(u)) n = NumericFactor(Rest(u)) if m < 0 and n < 0: return -GCD(-m, -n) else: return GCD(m, n) return S(1) def NonnumericFactors(u): if NumberQ(u): if ZeroQ(Im(u)): return S(1) elif ZeroQ(Re(u)): return I return u elif PowerQ(u): if RationalQ(u.base) and FractionQ(u.exp): return u/NumericFactor(u) return u elif ProductQ(u): result = 1 for i in u.args: result *= NonnumericFactors(i) return result elif SumQ(u): if LeafCount(u) < 50: i = ContentFactor(u) if SumQ(i): return u else: return NonnumericFactors(i) n = NumericFactor(u) result = 0 for i in u.args: result += i/n return result return u def MakeAssocList(u, x, alst=None): # (* MakeAssocList[u,x,alst] returns an association list of gensymed symbols with the nonatomic # parameters of a u that are not integer powers, products or sums. *) if alst is None: alst = [] u = replace_pow_exp(u) x = replace_pow_exp(x) if AtomQ(u): return alst elif IntegerPowerQ(u): return MakeAssocList(u.base, x, alst) elif ProductQ(u) or SumQ(u): return MakeAssocList(Rest(u), x, MakeAssocList(First(u), x, alst)) elif FreeQ(u, x): tmp = [] for i in alst: if PowerQ(i): if i.exp == u: tmp.append(i) break elif len(i.args) > 1: # make sure args has length > 1, else causes index error some times if i.args[1] == u: tmp.append(i) break if tmp == []: alst.append(u) return alst return alst def GensymSubst(u, x, alst=None): # (* GensymSubst[u,x,alst] returns u with the kernels in alst free of x replaced by gensymed names. *) if alst is None: alst =[] u = replace_pow_exp(u) x = replace_pow_exp(x) if AtomQ(u): return u elif IntegerPowerQ(u): return GensymSubst(u.base, x, alst)**u.exp elif ProductQ(u) or SumQ(u): return u.func(*[GensymSubst(i, x, alst) for i in u.args]) elif FreeQ(u, x): tmp = [] for i in alst: if PowerQ(i): if i.exp == u: tmp.append(i) break elif len(i.args) > 1: # make sure args has length > 1, else causes index error some times if i.args[1] == u: tmp.append(i) break if tmp == []: return u return tmp[0][0] return u def KernelSubst(u, x, alst): # (* KernelSubst[u,x,alst] returns u with the gensymed names in alst replaced by kernels free of x. *) if AtomQ(u): tmp = [] for i in alst: if i.args[0] == u: tmp.append(i) break if tmp == []: return u elif len(tmp[0].args) > 1: # make sure args has length > 1, else causes index error some times return tmp[0].args[1] elif IntegerPowerQ(u): tmp = KernelSubst(u.base, x, alst) if u.exp < 0 and ZeroQ(tmp): return 'Indeterminate' return tmp**u.exp elif ProductQ(u) or SumQ(u): return u.func(*[KernelSubst(i, x, alst) for i in u.args]) return u def ExpandExpression(u, x): if AlgebraicFunctionQ(u, x) and Not(RationalFunctionQ(u, x)): v = ExpandAlgebraicFunction(u, x) else: v = S(0) if SumQ(v): return ExpandCleanup(v, x) v = SmartApart(u, x) if SumQ(v): return ExpandCleanup(v, x) v = SmartApart(RationalFunctionFactors(u, x), x, x) if SumQ(v): w = NonrationalFunctionFactors(u, x) return ExpandCleanup(v.func(*[i*w for i in v.args]), x) v = Expand(u) if SumQ(v): return ExpandCleanup(v, x) v = Expand(u) if SumQ(v): return ExpandCleanup(v, x) return SimplifyTerm(u, x) def Apart(u, x): if RationalFunctionQ(u, x): return apart(u, x) return u def SmartApart(*args): if len(args) == 2: u, x = args alst = MakeAssocList(u, x) tmp = KernelSubst(Apart(GensymSubst(u, x, alst), x), x, alst) if tmp == 'Indeterminate': return u return tmp u, v, x = args alst = MakeAssocList(u, x) tmp = KernelSubst(Apart(GensymSubst(u, x, alst), x), x, alst) if tmp == 'Indeterminate': return u return tmp def MatchQ(expr, pattern, *var): # returns the matched arguments after matching pattern with expression match = expr.match(pattern) if match: return tuple(match[i] for i in var) else: return None def PolynomialQuotientRemainder(p, q, x): return [PolynomialQuotient(p, q, x), PolynomialRemainder(p, q, x)] def FreeFactors(u, x): # returns the product of the factors of u free of x. if ProductQ(u): result = 1 for i in u.args: if FreeQ(i, x): result *= i return result elif FreeQ(u, x): return u else: return S(1) def NonfreeFactors(u, x): """ Returns the product of the factors of u not free of x. Examples ======== >>> from sympy.integrals.rubi.utility_function import NonfreeFactors >>> from sympy.abc import x, a, b >>> NonfreeFactors(a, x) 1 >>> NonfreeFactors(x + a, x) a + x >>> NonfreeFactors(a*b*x, x) x """ if ProductQ(u): result = 1 for i in u.args: if not FreeQ(i, x): result *= i return result elif FreeQ(u, x): return 1 else: return u def RemoveContentAux(expr, x): return RemoveContentAux_replacer.replace(UtilityOperator(expr, x)) def RemoveContent(u, x): v = NonfreeFactors(u, x) w = Together(v) if EqQ(FreeFactors(w, x), 1): return RemoveContentAux(v, x) else: return RemoveContentAux(NonfreeFactors(w, x), x) def FreeTerms(u, x): """ Returns the sum of the terms of u free of x. Examples ======== >>> from sympy.integrals.rubi.utility_function import FreeTerms >>> from sympy.abc import x, a, b >>> FreeTerms(a, x) a >>> FreeTerms(x*a, x) 0 >>> FreeTerms(a*x + b, x) b """ if SumQ(u): result = 0 for i in u.args: if FreeQ(i, x): result += i return result elif FreeQ(u, x): return u else: return 0 def NonfreeTerms(u, x): # returns the sum of the terms of u free of x. if SumQ(u): result = S(0) for i in u.args: if not FreeQ(i, x): result += i return result elif not FreeQ(u, x): return u else: return S(0) def ExpandAlgebraicFunction(expr, x): if ProductQ(expr): u_ = Wild('u', exclude=[x]) n_ = Wild('n', exclude=[x]) v_ = Wild('v') pattern = u_*v_ match = expr.match(pattern) if match: keys = [u_, v_] if len(keys) == len(match): u, v = tuple([match[i] for i in keys]) if SumQ(v): u, v = v, u if not FreeQ(u, x) and SumQ(u): result = 0 for i in u.args: result += i*v return result pattern = u_**n_*v_ match = expr.match(pattern) if match: keys = [u_, n_, v_] if len(keys) == len(match): u, n, v = tuple([match[i] for i in keys]) if PositiveIntegerQ(n) and SumQ(u): w = Expand(u**n) result = 0 for i in w.args: result += i*v return result return expr def CollectReciprocals(expr, x): # Basis: e/(a+b x)+f/(c+d x)==(c e+a f+(d e+b f) x)/(a c+(b c+a d) x+b d x^2) if SumQ(expr): u_ = Wild('u') a_ = Wild('a', exclude=[x]) b_ = Wild('b', exclude=[x]) c_ = Wild('c', exclude=[x]) d_ = Wild('d', exclude=[x]) e_ = Wild('e', exclude=[x]) f_ = Wild('f', exclude=[x]) pattern = u_ + e_/(a_ + b_*x) + f_/(c_+d_*x) match = expr.match(pattern) if match: try: # .match() does not work peoperly always keys = [u_, a_, b_, c_, d_, e_, f_] u, a, b, c, d, e, f = tuple([match[i] for i in keys]) if ZeroQ(b*c + a*d) & ZeroQ(d*e + b*f): return CollectReciprocals(u + (c*e + a*f)/(a*c + b*d*x**2),x) elif ZeroQ(b*c + a*d) & ZeroQ(c*e + a*f): return CollectReciprocals(u + (d*e + b*f)*x/(a*c + b*d*x**2),x) except: pass return expr def ExpandCleanup(u, x): v = CollectReciprocals(u, x) if SumQ(v): res = 0 for i in v.args: res += SimplifyTerm(i, x) v = res if SumQ(v): return UnifySum(v, x) else: return v else: return v def AlgebraicFunctionQ(u, x, flag=False): if ListQ(u): if u == []: return True elif AlgebraicFunctionQ(First(u), x, flag): return AlgebraicFunctionQ(Rest(u), x, flag) else: return False elif AtomQ(u) or FreeQ(u, x): return True elif PowerQ(u): if RationalQ(u.exp) | flag & FreeQ(u.exp, x): return AlgebraicFunctionQ(u.base, x, flag) elif ProductQ(u) | SumQ(u): for i in u.args: if not AlgebraicFunctionQ(i, x, flag): return False return True return False def Coeff(expr, form, n=1): if n == 1: return Coefficient(Together(expr), form, n) else: coef1 = Coefficient(expr, form, n) coef2 = Coefficient(Together(expr), form, n) if Simplify(coef1 - coef2) == 0: return coef1 else: return coef2 def LeadTerm(u): if SumQ(u): return First(u) return u def RemainingTerms(u): if SumQ(u): return Rest(u) return u def LeadFactor(u): # returns the leading factor of u. if ComplexNumberQ(u) and Re(u) == 0: if Im(u) == S(1): return u else: return LeadFactor(Im(u)) elif ProductQ(u): return LeadFactor(First(u)) return u def RemainingFactors(u): # returns the remaining factors of u. if ComplexNumberQ(u) and Re(u) == 0: if Im(u) == 1: return S(1) else: return I*RemainingFactors(Im(u)) elif ProductQ(u): return RemainingFactors(First(u))*Rest(u) return S(1) def LeadBase(u): """ returns the base of the leading factor of u. Examples ======== >>> from sympy.integrals.rubi.utility_function import LeadBase >>> from sympy.abc import a, b, c >>> LeadBase(a**b) a >>> LeadBase(a**b*c) a """ v = LeadFactor(u) if PowerQ(v): return v.base return v def LeadDegree(u): # returns the degree of the leading factor of u. v = LeadFactor(u) if PowerQ(v): return v.exp return v def Numer(expr): # returns the numerator of u. if PowerQ(expr): if expr.exp < 0: return 1 if ProductQ(expr): return Mul(*[Numer(i) for i in expr.args]) return Numerator(expr) def Denom(u): # returns the denominator of u if PowerQ(u): if u.exp < 0: return u.args[0]**(-u.args[1]) elif ProductQ(u): return Mul(*[Denom(i) for i in u.args]) return Denominator(u) def hypergeom(n, d, z): return hyper(n, d, z) def Expon(expr, form, h=None): if h: return Exponent(Together(expr), form, h) else: return Exponent(Together(expr), form) def MergeMonomials(expr, x): u_ = Wild('u') p_ = Wild('p', exclude=[x, 1, 0]) a_ = Wild('a', exclude=[x]) b_ = Wild('b', exclude=[x, 0]) c_ = Wild('c', exclude=[x]) d_ = Wild('d', exclude=[x, 0]) n_ = Wild('n', exclude=[x]) m_ = Wild('m', exclude=[x]) # Basis: If m/n\[Element]\[DoubleStruckCapitalZ], then z^m (c z^n)^p==(c z^n)^(m/n+p)/c^(m/n) pattern = u_*(a_ + b_*x)**m_*(c_*(a_ + b_*x)**n_)**p_ match = expr.match(pattern) if match: keys = [u_, a_, b_, m_, c_, n_, p_] if len(keys) == len(match): u, a, b, m, c, n, p = tuple([match[i] for i in keys]) if IntegerQ(m/n): if u*(c*(a + b*x)**n)**(m/n + p)/c**(m/n) == S.NaN: return expr else: return u*(c*(a + b*x)**n)**(m/n + p)/c**(m/n) # Basis: If m\[Element]\[DoubleStruckCapitalZ] \[And] b c-a d==0, then (a+b z)^m==b^m/d^m (c+d z)^m pattern = u_*(a_ + b_*x)**m_*(c_ + d_*x)**n_ match = expr.match(pattern) if match: keys = [u_, a_, b_, m_, c_, d_, n_] if len(keys) == len(match): u, a, b, m, c, d, n = tuple([match[i] for i in keys]) if IntegerQ(m) and ZeroQ(b*c - a*d): if u*b**m/d**m*(c + d*x)**(m + n) == S.NaN: return expr else: return u*b**m/d**m*(c + d*x)**(m + n) return expr def PolynomialDivide(u, v, x): quo = PolynomialQuotient(u, v, x) rem = PolynomialRemainder(u, v, x) s = 0 for i in Exponent(quo, x, List): s += Simp(Together(Coefficient(quo, x, i)*x**i), x) quo = s rem = Together(rem) free = FreeFactors(rem, x) rem = NonfreeFactors(rem, x) monomial = x**Exponent(rem, x, Min) if NegQ(Coefficient(rem, x, 0)): monomial = -monomial s = 0 for i in Exponent(rem, x, List): s += Simp(Together(Coefficient(rem, x, i)*x**i/monomial), x) rem = s if BinomialQ(v, x): return quo + free*monomial*rem/ExpandToSum(v, x) else: return quo + free*monomial*rem/v def BinomialQ(u, x, n=None): """ If u is equivalent to an expression of the form a + b*x**n, BinomialQ(u, x, n) returns True, else it returns False. Examples ======== >>> from sympy.integrals.rubi.utility_function import BinomialQ >>> from sympy.abc import x >>> BinomialQ(x**9, x) True >>> BinomialQ((1 + x)**3, x) False """ if ListQ(u): for i in u: if Not(BinomialQ(i, x, n)): return False return True elif NumberQ(x): return False return ListQ(BinomialParts(u, x)) def TrinomialQ(u, x): """ If u is equivalent to an expression of the form a + b*x**n + c*x**(2*n) where n, b and c are not 0, TrinomialQ(u, x) returns True, else it returns False. Examples ======== >>> from sympy.integrals.rubi.utility_function import TrinomialQ >>> from sympy.abc import x >>> TrinomialQ((7 + 2*x**6 + 3*x**12), x) True >>> TrinomialQ(x**2, x) False """ if ListQ(u): for i in u.args: if Not(TrinomialQ(i, x)): return False return True check = False u = replace_pow_exp(u) if PowerQ(u): if u.exp == 2 and BinomialQ(u.base, x): check = True return ListQ(TrinomialParts(u,x)) and Not(QuadraticQ(u, x)) and Not(check) def GeneralizedBinomialQ(u, x): """ If u is equivalent to an expression of the form a*x**q+b*x**n where n, q and b are not 0, GeneralizedBinomialQ(u, x) returns True, else it returns False. Examples ======== >>> from sympy.integrals.rubi.utility_function import GeneralizedBinomialQ >>> from sympy.abc import a, x, q, b, n >>> GeneralizedBinomialQ(a*x**q, x) False """ if ListQ(u): return all(GeneralizedBinomialQ(i, x) for i in u) return ListQ(GeneralizedBinomialParts(u, x)) def GeneralizedTrinomialQ(u, x): """ If u is equivalent to an expression of the form a*x**q+b*x**n+c*x**(2*n-q) where n, q, b and c are not 0, GeneralizedTrinomialQ(u, x) returns True, else it returns False. Examples ======== >>> from sympy.integrals.rubi.utility_function import GeneralizedTrinomialQ >>> from sympy.abc import x >>> GeneralizedTrinomialQ(7 + 2*x**6 + 3*x**12, x) False """ if ListQ(u): return all(GeneralizedTrinomialQ(i, x) for i in u) return ListQ(GeneralizedTrinomialParts(u, x)) def FactorSquareFreeList(poly): r = sqf_list(poly) result = [[1, 1]] for i in r[1]: result.append(list(i)) return result def PerfectPowerTest(u, x): # If u (x) is equivalent to a polynomial raised to an integer power greater than 1, # PerfectPowerTest[u,x] returns u (x) as an expanded polynomial raised to the power; # else it returns False. if PolynomialQ(u, x): lst = FactorSquareFreeList(u) gcd = 0 v = 1 if lst[0] == [1, 1]: lst = Rest(lst) for i in lst: gcd = GCD(gcd, i[1]) if gcd > 1: for i in lst: v = v*i[0]**(i[1]/gcd) return Expand(v)**gcd else: return False return False def SquareFreeFactorTest(u, x): # If u (x) can be square free factored, SquareFreeFactorTest[u,x] returns u (x) in # factored form; else it returns False. if PolynomialQ(u, x): v = FactorSquareFree(u) if PowerQ(v) or ProductQ(v): return v return False return False def RationalFunctionQ(u, x): # If u is a rational function of x, RationalFunctionQ[u,x] returns True; else it returns False. if AtomQ(u) or FreeQ(u, x): return True elif IntegerPowerQ(u): return RationalFunctionQ(u.base, x) elif ProductQ(u) or SumQ(u): for i in u.args: if Not(RationalFunctionQ(i, x)): return False return True return False def RationalFunctionFactors(u, x): # RationalFunctionFactors[u,x] returns the product of the factors of u that are rational functions of x. if ProductQ(u): res = 1 for i in u.args: if RationalFunctionQ(i, x): res *= i return res elif RationalFunctionQ(u, x): return u return S(1) def NonrationalFunctionFactors(u, x): if ProductQ(u): res = 1 for i in u.args: if not RationalFunctionQ(i, x): res *= i return res elif RationalFunctionQ(u, x): return S(1) return u def Reverse(u): if isinstance(u, list): return list(reversed(u)) else: l = list(u.args) return u.func(*list(reversed(l))) def RationalFunctionExponents(u, x): """ u is a polynomial or rational function of x. RationalFunctionExponents(u, x) returns a list of the exponent of the numerator of u and the exponent of the denominator of u. Examples ======== >>> from sympy.integrals.rubi.utility_function import RationalFunctionExponents >>> from sympy.abc import x, a >>> RationalFunctionExponents(x, x) [1, 0] >>> RationalFunctionExponents(x**(-1), x) [0, 1] >>> RationalFunctionExponents(x**(-1)*a, x) [0, 1] """ if PolynomialQ(u, x): return [Exponent(u, x), 0] elif IntegerPowerQ(u): if PositiveQ(u.exp): return u.exp*RationalFunctionExponents(u.base, x) return (-u.exp)*Reverse(RationalFunctionExponents(u.base, x)) elif ProductQ(u): lst1 = RationalFunctionExponents(First(u), x) lst2 = RationalFunctionExponents(Rest(u), x) return [lst1[0] + lst2[0], lst1[1] + lst2[1]] elif SumQ(u): v = Together(u) if SumQ(v): lst1 = RationalFunctionExponents(First(u), x) lst2 = RationalFunctionExponents(Rest(u), x) return [Max(lst1[0] + lst2[1], lst2[0] + lst1[1]), lst1[1] + lst2[1]] else: return RationalFunctionExponents(v, x) return [0, 0] def RationalFunctionExpand(expr, x): # expr is a polynomial or rational function of x. # RationalFunctionExpand[u,x] returns the expansion of the factors of u that are rational functions times the other factors. def cons_f1(n): return FractionQ(n) cons1 = CustomConstraint(cons_f1) def cons_f2(x, v): if not isinstance(x, Symbol): return False return UnsameQ(v, x) cons2 = CustomConstraint(cons_f2) def With1(n, u, x, v): w = RationalFunctionExpand(u, x) return If(SumQ(w), Add(*[i*v**n for i in w.args]), v**n*w) pattern1 = Pattern(UtilityOperator(u_*v_**n_, x_), cons1, cons2) rule1 = ReplacementRule(pattern1, With1) def With2(u, x): v = ExpandIntegrand(u, x) def _consf_u(a, b, c, d, p, m, n, x): return And(FreeQ(List(a, b, c, d, p), x), IntegersQ(m, n), Equal(m, Add(n, S(-1)))) cons_u = CustomConstraint(_consf_u) pat = Pattern(UtilityOperator(x_**WC('m', S(1))*(x_*WC('d', S(1)) + c_)**p_/(x_**n_*WC('b', S(1)) + a_), x_), cons_u) result_matchq = is_match(UtilityOperator(u, x), pat) if UnsameQ(v, u) and not result_matchq: return v else: v = ExpandIntegrand(RationalFunctionFactors(u, x), x) w = NonrationalFunctionFactors(u, x) if SumQ(v): return Add(*[i*w for i in v.args]) else: return v*w pattern2 = Pattern(UtilityOperator(u_, x_)) rule2 = ReplacementRule(pattern2, With2) expr = expr.replace(sym_exp, rubi_exp) res = replace_all(UtilityOperator(expr, x), [rule1, rule2]) return replace_pow_exp(res) def ExpandIntegrand(expr, x, extra=None): expr = replace_pow_exp(expr) if not extra is None: extra, x = x, extra w = ExpandIntegrand(extra, x) r = NonfreeTerms(w, x) if SumQ(r): result = [expr*FreeTerms(w, x)] for i in r.args: result.append(MergeMonomials(expr*i, x)) return r.func(*result) else: return expr*FreeTerms(w, x) + MergeMonomials(expr*r, x) else: u_ = Wild('u', exclude=[0, 1]) a_ = Wild('a', exclude=[x]) b_ = Wild('b', exclude=[x, 0]) F_ = Wild('F', exclude=[0]) c_ = Wild('c', exclude=[x]) d_ = Wild('d', exclude=[x, 0]) n_ = Wild('n', exclude=[0, 1]) pattern = u_*(a_ + b_*F_)**n_ match = expr.match(pattern) if match: if MemberQ([asin, acos, asinh, acosh], match[F_].func): keys = [u_, a_, b_, F_, n_] if len(match) == len(keys): u, a, b, F, n = tuple([match[i] for i in keys]) match = F.args[0].match(c_ + d_*x) if match: keys = c_, d_ if len(keys) == len(match): c, d = tuple([match[i] for i in keys]) if PolynomialQ(u, x): F = F.func return ExpandLinearProduct((a + b*F(c + d*x))**n, u, c, d, x) expr = expr.replace(sym_exp, rubi_exp) res = replace_all(UtilityOperator(expr, x), ExpandIntegrand_rules, max_count = 1) return replace_pow_exp(res) def SimplerQ(u, v): # If u is simpler than v, SimplerQ(u, v) returns True, else it returns False. SimplerQ(u, u) returns False if IntegerQ(u): if IntegerQ(v): if Abs(u)==Abs(v): return v<0 else: return Abs(u)<Abs(v) else: return True elif IntegerQ(v): return False elif FractionQ(u): if FractionQ(v): if Denominator(u) == Denominator(v): return SimplerQ(Numerator(u), Numerator(v)) else: return Denominator(u)<Denominator(v) else: return True elif FractionQ(v): return False elif (Re(u)==0 or Re(u) == 0) and (Re(v)==0 or Re(v) == 0): return SimplerQ(Im(u), Im(v)) elif ComplexNumberQ(u): if ComplexNumberQ(v): if Re(u) == Re(v): return SimplerQ(Im(u), Im(v)) else: return SimplerQ(Re(u),Re(v)) else: return False elif NumberQ(u): if NumberQ(v): return OrderedQ([u,v]) else: return True elif NumberQ(v): return False elif AtomQ(u) or (Head(u) == re) or (Head(u) == im): if AtomQ(v) or (Head(u) == re) or (Head(u) == im): return OrderedQ([u,v]) else: return True elif AtomQ(v) or (Head(u) == re) or (Head(u) == im): return False elif Head(u) == Head(v): if Length(u) == Length(v): for i in range(len(u.args)): if not u.args[i] == v.args[i]: return SimplerQ(u.args[i], v.args[i]) return False return Length(u) < Length(v) elif LeafCount(u) < LeafCount(v): return True elif LeafCount(v) < LeafCount(u): return False return Not(OrderedQ([v,u])) def SimplerSqrtQ(u, v): # If Rt(u, 2) is simpler than Rt(v, 2), SimplerSqrtQ(u, v) returns True, else it returns False. SimplerSqrtQ(u, u) returns False if NegativeQ(v) and Not(NegativeQ(u)): return True if NegativeQ(u) and Not(NegativeQ(v)): return False sqrtu = Rt(u, S(2)) sqrtv = Rt(v, S(2)) if IntegerQ(sqrtu): if IntegerQ(sqrtv): return sqrtu<sqrtv else: return True if IntegerQ(sqrtv): return False if RationalQ(sqrtu): if RationalQ(sqrtv): return sqrtu<sqrtv else: return True if RationalQ(sqrtv): return False if PosQ(u): if PosQ(v): return LeafCount(sqrtu)<LeafCount(sqrtv) else: return True if PosQ(v): return False if LeafCount(sqrtu)<LeafCount(sqrtv): return True if LeafCount(sqrtv)<LeafCount(sqrtu): return False else: return Not(OrderedQ([v, u])) def SumSimplerQ(u, v): """ If u + v is simpler than u, SumSimplerQ(u, v) returns True, else it returns False. If for every term w of v there is a term of u equal to n*w where n<-1/2, u + v will be simpler than u. Examples ======== >>> from sympy.integrals.rubi.utility_function import SumSimplerQ >>> from sympy.abc import x >>> from sympy import S >>> SumSimplerQ(S(4 + x),S(3 + x**3)) False """ if RationalQ(u, v): if v == S(0): return False elif v > S(0): return u < -S(1) else: return u >= -v else: return SumSimplerAuxQ(Expand(u), Expand(v)) def BinomialDegree(u, x): # if u is a binomial. BinomialDegree[u,x] returns the degree of x in u. bp = BinomialParts(u, x) if bp == False: return bp return bp[2] def TrinomialDegree(u, x): # If u is equivalent to a trinomial of the form a + b*x^n + c*x^(2*n) where n!=0, b!=0 and c!=0, TrinomialDegree[u,x] returns n t = TrinomialParts(u, x) if t: return t[3] return t def CancelCommonFactors(u, v): def _delete_cases(a, b): # only for CancelCommonFactors lst = [] deleted = False for i in a.args: if i == b and not deleted: deleted = True continue lst.append(i) return a.func(*lst) # CancelCommonFactors[u,v] returns {u',v'} are the noncommon factors of u and v respectively. if ProductQ(u): if ProductQ(v): if MemberQ(v, First(u)): return CancelCommonFactors(Rest(u), _delete_cases(v, First(u))) else: lst = CancelCommonFactors(Rest(u), v) return [First(u)*lst[0], lst[1]] else: if MemberQ(u, v): return [_delete_cases(u, v), 1] else: return[u, v] elif ProductQ(v): if MemberQ(v, u): return [1, _delete_cases(v, u)] else: return [u, v] return[u, v] def SimplerIntegrandQ(u, v, x): lst = CancelCommonFactors(u, v) u1 = lst[0] v1 = lst[1] if Head(u1) == Head(v1) and Length(u1) == 1 and Length(v1) == 1: return SimplerIntegrandQ(u1.args[0], v1.args[0], x) if 4*LeafCount(u1) < 3*LeafCount(v1): return True if RationalFunctionQ(u1, x): if RationalFunctionQ(v1, x): t1 = 0 t2 = 0 for i in RationalFunctionExponents(u1, x): t1 += i for i in RationalFunctionExponents(v1, x): t2 += i return t1 < t2 else: return True else: return False def GeneralizedBinomialDegree(u, x): b = GeneralizedBinomialParts(u, x) if b: return b[2] - b[3] def GeneralizedBinomialParts(expr, x): expr = Expand(expr) if GeneralizedBinomialMatchQ(expr, x): a = Wild('a', exclude=[x]) b = Wild('b', exclude=[x]) n = Wild('n', exclude=[x]) q = Wild('q', exclude=[x]) Match = expr.match(a*x**q + b*x**n) if Match and PosQ(Match[q] - Match[n]): return [Match[b], Match[a], Match[q], Match[n]] else: return False def GeneralizedTrinomialDegree(u, x): t = GeneralizedTrinomialParts(u, x) if t: return t[3] - t[4] def GeneralizedTrinomialParts(expr, x): expr = Expand(expr) if GeneralizedTrinomialMatchQ(expr, x): a = Wild('a', exclude=[x, 0]) b = Wild('b', exclude=[x, 0]) c = Wild('c', exclude=[x]) n = Wild('n', exclude=[x, 0]) q = Wild('q', exclude=[x]) Match = expr.match(a*x**q + b*x**n+c*x**(2*n-q)) if Match and expr.is_Add: return [Match[c], Match[b], Match[a], Match[n], 2*Match[n]-Match[q]] else: return False def MonomialQ(u, x): # If u is of the form a*x^n where n!=0 and a!=0, MonomialQ[u,x] returns True; else False if isinstance(u, list): return all(MonomialQ(i, x) for i in u) else: a = Wild('a', exclude=[x]) b = Wild('b', exclude=[x]) re = u.match(a*x**b) if re: return True return False def MonomialSumQ(u, x): # if u(x) is a sum and each term is free of x or an expression of the form a*x^n, MonomialSumQ(u, x) returns True; else it returns False if SumQ(u): for i in u.args: if Not(FreeQ(i, x) or MonomialQ(i, x)): return False return True @doctest_depends_on(modules=('matchpy',)) def MinimumMonomialExponent(u, x): """ u is sum whose terms are monomials. MinimumMonomialExponent(u, x) returns the exponent of the term having the smallest exponent Examples ======== >>> from sympy.integrals.rubi.utility_function import MinimumMonomialExponent >>> from sympy.abc import x >>> MinimumMonomialExponent(x**2 + 5*x**2 + 3*x**5, x) 2 >>> MinimumMonomialExponent(x**2 + 5*x**2 + 1, x) 0 """ n =MonomialExponent(First(u), x) for i in u.args: if PosQ(n - MonomialExponent(i, x)): n = MonomialExponent(i, x) return n def MonomialExponent(u, x): # u is a monomial. MonomialExponent(u, x) returns the exponent of x in u a = Wild('a', exclude=[x]) b = Wild('b', exclude=[x]) re = u.match(a*x**b) if re: return re[b] def LinearMatchQ(u, x): # LinearMatchQ(u, x) returns True iff u matches patterns of the form a+b*x where a and b are free of x if isinstance(u, list): return all(LinearMatchQ(i, x) for i in u) else: a = Wild('a', exclude=[x]) b = Wild('b', exclude=[x]) re = u.match(a + b*x) if re: return True return False def PowerOfLinearMatchQ(u, x): if isinstance(u, list): for i in u: if not PowerOfLinearMatchQ(i, x): return False return True else: a = Wild('a', exclude=[x]) b = Wild('b', exclude=[x, 0]) m = Wild('m', exclude=[x, 0]) Match = u.match((a + b*x)**m) if Match: return True else: return False def QuadraticMatchQ(u, x): if ListQ(u): return all(QuadraticMatchQ(i, x) for i in u) pattern1 = Pattern(UtilityOperator(x_**2*WC('c', 1) + x_*WC('b', 1) + WC('a', 0), x_), CustomConstraint(lambda a, b, c, x: FreeQ([a, b, c], x))) pattern2 = Pattern(UtilityOperator(x_**2*WC('c', 1) + WC('a', 0), x_), CustomConstraint(lambda a, c, x: FreeQ([a, c], x))) u1 = UtilityOperator(u, x) return is_match(u1, pattern1) or is_match(u1, pattern2) def CubicMatchQ(u, x): if isinstance(u, list): return all(CubicMatchQ(i, x) for i in u) else: pattern1 = Pattern(UtilityOperator(x_**3*WC('d', 1) + x_**2*WC('c', 1) + x_*WC('b', 1) + WC('a', 0), x_), CustomConstraint(lambda a, b, c, d, x: FreeQ([a, b, c, d], x))) pattern2 = Pattern(UtilityOperator(x_**3*WC('d', 1) + x_*WC('b', 1) + WC('a', 0), x_), CustomConstraint(lambda a, b, d, x: FreeQ([a, b, d], x))) pattern3 = Pattern(UtilityOperator(x_**3*WC('d', 1) + x_**2*WC('c', 1) + WC('a', 0), x_), CustomConstraint(lambda a, c, d, x: FreeQ([a, c, d], x))) pattern4 = Pattern(UtilityOperator(x_**3*WC('d', 1) + WC('a', 0), x_), CustomConstraint(lambda a, d, x: FreeQ([a, d], x))) u1 = UtilityOperator(u, x) if is_match(u1, pattern1) or is_match(u1, pattern2) or is_match(u1, pattern3) or is_match(u1, pattern4): return True else: return False def BinomialMatchQ(u, x): if isinstance(u, list): return all(BinomialMatchQ(i, x) for i in u) else: pattern = Pattern(UtilityOperator(x_**WC('n', S(1))*WC('b', S(1)) + WC('a', S(0)), x_) , CustomConstraint(lambda a, b, n, x: FreeQ([a,b,n],x))) u = UtilityOperator(u, x) return is_match(u, pattern) def TrinomialMatchQ(u, x): if isinstance(u, list): return all(TrinomialMatchQ(i, x) for i in u) else: pattern = Pattern(UtilityOperator(x_**WC('j', S(1))*WC('c', S(1)) + x_**WC('n', S(1))*WC('b', S(1)) + WC('a', S(0)), x_) , CustomConstraint(lambda a, b, c, n, x: FreeQ([a, b, c, n], x)), CustomConstraint(lambda j, n: ZeroQ(j-2*n) )) u = UtilityOperator(u, x) return is_match(u, pattern) def GeneralizedBinomialMatchQ(u, x): if isinstance(u, list): return all(GeneralizedBinomialMatchQ(i, x) for i in u) else: a = Wild('a', exclude=[x, 0]) b = Wild('b', exclude=[x, 0]) n = Wild('n', exclude=[x, 0]) q = Wild('q', exclude=[x, 0]) Match = u.match(a*x**q + b*x**n) if Match and len(Match) == 4 and Match[q] != 0 and Match[n] != 0: return True else: return False def GeneralizedTrinomialMatchQ(u, x): if isinstance(u, list): return all(GeneralizedTrinomialMatchQ(i, x) for i in u) else: a = Wild('a', exclude=[x, 0]) b = Wild('b', exclude=[x, 0]) n = Wild('n', exclude=[x, 0]) c = Wild('c', exclude=[x, 0]) q = Wild('q', exclude=[x, 0]) Match = u.match(a*x**q + b*x**n + c*x**(2*n - q)) if Match and len(Match) == 5 and 2*Match[n] - Match[q] != 0 and Match[n] != 0: return True else: return False def QuotientOfLinearsMatchQ(u, x): if isinstance(u, list): return all(QuotientOfLinearsMatchQ(i, x) for i in u) else: a = Wild('a', exclude=[x]) b = Wild('b', exclude=[x]) d = Wild('d', exclude=[x]) c = Wild('c', exclude=[x]) e = Wild('e') Match = u.match(e*(a + b*x)/(c + d*x)) if Match and len(Match) == 5: return True else: return False def PolynomialTermQ(u, x): a = Wild('a', exclude=[x]) n = Wild('n', exclude=[x]) Match = u.match(a*x**n) if Match and IntegerQ(Match[n]) and Greater(Match[n], S(0)): return True else: return False def PolynomialTerms(u, x): s = 0 for i in u.args: if PolynomialTermQ(i, x): s = s + i return s def NonpolynomialTerms(u, x): s = 0 for i in u.args: if not PolynomialTermQ(i, x): s = s + i return s def PseudoBinomialParts(u, x): if PolynomialQ(u, x) and Greater(Expon(u, x), S(2)): n = Expon(u, x) d = Rt(Coefficient(u, x, n), n) c = d**(-n + S(1))*Coefficient(u, x, n + S(-1))/n a = Simplify(u - (c + d*x)**n) if NonzeroQ(a) and FreeQ(a, x): return [a, S(1), c, d, n] else: return False else: return False def NormalizePseudoBinomial(u, x): lst = PseudoBinomialParts(u, x) if lst: return (lst[0] + lst[1]*(lst[2] + lst[3]*x)**lst[4]) def PseudoBinomialPairQ(u, v, x): lst1 = PseudoBinomialParts(u, x) if AtomQ(lst1): return False else: lst2 = PseudoBinomialParts(v, x) if AtomQ(lst2): return False else: return Drop(lst1, 2) == Drop(lst2, 2) def PseudoBinomialQ(u, x): lst = PseudoBinomialParts(u, x) if lst: return True else: return False def PolynomialGCD(f, g): return gcd(f, g) def PolyGCD(u, v, x): # (* u and v are polynomials in x. *) # (* PolyGCD[u,v,x] returns the factors of the gcd of u and v dependent on x. *) return NonfreeFactors(PolynomialGCD(u, v), x) def AlgebraicFunctionFactors(u, x, flag=False): # (* AlgebraicFunctionFactors[u,x] returns the product of the factors of u that are algebraic functions of x. *) if ProductQ(u): result = 1 for i in u.args: if AlgebraicFunctionQ(i, x, flag): result *= i return result if AlgebraicFunctionQ(u, x, flag): return u return 1 def NonalgebraicFunctionFactors(u, x): """ NonalgebraicFunctionFactors[u,x] returns the product of the factors of u that are not algebraic functions of x. Examples ======== >>> from sympy.integrals.rubi.utility_function import NonalgebraicFunctionFactors >>> from sympy.abc import x >>> from sympy import sin >>> NonalgebraicFunctionFactors(sin(x), x) sin(x) >>> NonalgebraicFunctionFactors(x, x) 1 """ if ProductQ(u): result = 1 for i in u.args: if not AlgebraicFunctionQ(i, x): result *= i return result if AlgebraicFunctionQ(u, x): return 1 return u def QuotientOfLinearsP(u, x): if LinearQ(u, x): return True elif SumQ(u): if FreeQ(u.args[0], x): return QuotientOfLinearsP(Rest(u), x) elif LinearQ(Numerator(u), x) and LinearQ(Denominator(u), x): return True elif ProductQ(u): if FreeQ(First(u), x): return QuotientOfLinearsP(Rest(u), x) elif Numerator(u) == 1 and PowerQ(u): return QuotientOfLinearsP(Denominator(u), x) return u == x or FreeQ(u, x) def QuotientOfLinearsParts(u, x): # If u is equivalent to an expression of the form (a+b*x)/(c+d*x), QuotientOfLinearsParts[u,x] # returns the list {a, b, c, d}. if LinearQ(u, x): return [Coefficient(u, x, 0), Coefficient(u, x, 1), 1, 0] elif PowerQ(u): if Numerator(u) == 1: u = Denominator(u) r = QuotientOfLinearsParts(u, x) return [r[2], r[3], r[0], r[1]] elif SumQ(u): a = First(u) if FreeQ(a, x): u = Rest(u) r = QuotientOfLinearsParts(u, x) return [r[0] + a*r[2], r[1] + a*r[3], r[2], r[3]] elif ProductQ(u): a = First(u) if FreeQ(a, x): r = QuotientOfLinearsParts(Rest(u), x) return [a*r[0], a*r[1], r[2], r[3]] a = Numerator(u) d = Denominator(u) if LinearQ(a, x) and LinearQ(d, x): return [Coefficient(a, x, 0), Coefficient(a, x, 1), Coefficient(d, x, 0), Coefficient(d, x, 1)] elif u == x: return [0, 1, 1, 0] elif FreeQ(u, x): return [u, 0, 1, 0] return [u, 0, 1, 0] def QuotientOfLinearsQ(u, x): # (*QuotientOfLinearsQ[u,x] returns True iff u is equivalent to an expression of the form (a+b x)/(c+d x) where b!=0 and d!=0.*) if ListQ(u): for i in u: if not QuotientOfLinearsQ(i, x): return False return True q = QuotientOfLinearsParts(u, x) return QuotientOfLinearsP(u, x) and NonzeroQ(q[1]) and NonzeroQ(q[3]) def Flatten(l): return flatten(l) def Sort(u, r=False): return sorted(u, key=lambda x: x.sort_key(), reverse=r) # (*Definition: A number is absurd if it is a rational number, a positive rational number raised to a fractional power, or a product of absurd numbers.*) def AbsurdNumberQ(u): # (* AbsurdNumberQ[u] returns True if u is an absurd number, else it returns False. *) if PowerQ(u): v = u.exp u = u.base return RationalQ(u) and u > 0 and FractionQ(v) elif ProductQ(u): return all(AbsurdNumberQ(i) for i in u.args) return RationalQ(u) def AbsurdNumberFactors(u): # (* AbsurdNumberFactors[u] returns the product of the factors of u that are absurd numbers. *) if AbsurdNumberQ(u): return u elif ProductQ(u): result = S(1) for i in u.args: if AbsurdNumberQ(i): result *= i return result return NumericFactor(u) def NonabsurdNumberFactors(u): # (* NonabsurdNumberFactors[u] returns the product of the factors of u that are not absurd numbers. *) if AbsurdNumberQ(u): return S(1) elif ProductQ(u): result = 1 for i in u.args: result *= NonabsurdNumberFactors(i) return result return NonnumericFactors(u) def SumSimplerAuxQ(u, v): if SumQ(v): return (RationalQ(First(v)) or SumSimplerAuxQ(u,First(v))) and (RationalQ(Rest(v)) or SumSimplerAuxQ(u,Rest(v))) elif SumQ(u): return SumSimplerAuxQ(First(u), v) or SumSimplerAuxQ(Rest(u), v) else: return v!=0 and NonnumericFactors(u)==NonnumericFactors(v) and (NumericFactor(u)/NumericFactor(v)<-1/2 or NumericFactor(u)/NumericFactor(v)==-1/2 and NumericFactor(u)<0) def Prepend(l1, l2): if not isinstance(l2, list): return [l2] + l1 return l2 + l1 def Drop(lst, n): if isinstance(lst, list): if isinstance(n, list): lst = lst[:(n[0]-1)] + lst[n[1]:] elif n > 0: lst = lst[n:] elif n < 0: lst = lst[:-n] else: return lst return lst return lst.func(*[i for i in Drop(list(lst.args), n)]) def CombineExponents(lst): if Length(lst) < 2: return lst elif lst[0][0] == lst[1][0]: return CombineExponents(Prepend(Drop(lst,2),[lst[0][0], lst[0][1] + lst[1][1]])) return Prepend(CombineExponents(Rest(lst)), First(lst)) def FactorInteger(n, l=None): if isinstance(n, (int, Integer)): return sorted(factorint(n, limit=l).items()) else: return sorted(factorrat(n, limit=l).items()) def FactorAbsurdNumber(m): # (* m must be an absurd number. FactorAbsurdNumber[m] returns the prime factorization of m *) # (* as list of base-degree pairs where the bases are prime numbers and the degrees are rational. *) if RationalQ(m): return FactorInteger(m) elif PowerQ(m): r = FactorInteger(m.base) return [r[0], r[1]*m.exp] # CombineExponents[Sort[Flatten[Map[FactorAbsurdNumber,Apply[List,m]],1], Function[i1[[1]]<i2[[1]]]]] return list((m.as_base_exp(),)) def SubstForInverseFunction(*args): """ SubstForInverseFunction(u, v, w, x) returns u with subexpressions equal to v replaced by x and x replaced by w. Examples ======== >>> from sympy.integrals.rubi.utility_function import SubstForInverseFunction >>> from sympy.abc import x, a, b >>> SubstForInverseFunction(a, a, b, x) a >>> SubstForInverseFunction(x**a, x**a, b, x) x >>> SubstForInverseFunction(a*x**a, a, b, x) a*b**a """ if len(args) == 3: u, v, x = args[0], args[1], args[2] return SubstForInverseFunction(u, v, (-Coefficient(v.args[0], x, 0) + InverseFunction(Head(v))(x))/Coefficient(v.args[0], x, 1), x) elif len(args) == 4: u, v, w, x = args[0], args[1], args[2], args[3] if AtomQ(u): if u == x: return w return u elif Head(u) == Head(v) and ZeroQ(u.args[0] - v.args[0]): return x res = [SubstForInverseFunction(i, v, w, x) for i in u.args] return u.func(*res) def SubstForFractionalPower(u, v, n, w, x): # (* SubstForFractionalPower[u,v,n,w,x] returns u with subexpressions equal to v^(m/n) replaced # by x^m and x replaced by w. *) if AtomQ(u): if u == x: return w return u elif FractionalPowerQ(u): if ZeroQ(u.base - v): return x**(n*u.exp) res = [SubstForFractionalPower(i, v, n, w, x) for i in u.args] return u.func(*res) def SubstForFractionalPowerOfQuotientOfLinears(u, x): # (* If u has a subexpression of the form ((a+b*x)/(c+d*x))^(m/n) where m and n>1 are integers, # SubstForFractionalPowerOfQuotientOfLinears[u,x] returns the list {v,n,(a+b*x)/(c+d*x),b*c-a*d} where v is u # with subexpressions of the form ((a+b*x)/(c+d*x))^(m/n) replaced by x^m and x replaced lst = FractionalPowerOfQuotientOfLinears(u, 1, False, x) if AtomQ(lst) or AtomQ(lst[1]): return False n = lst[0] tmp = lst[1] lst = QuotientOfLinearsParts(tmp, x) a, b, c, d = lst[0], lst[1], lst[2], lst[3] if ZeroQ(d): return False lst = Simplify(x**(n - 1)*SubstForFractionalPower(u, tmp, n, (-a + c*x**n)/(b - d*x**n), x)/(b - d*x**n)**2) return [NonfreeFactors(lst, x), n, tmp, FreeFactors(lst, x)*(b*c - a*d)] def FractionalPowerOfQuotientOfLinears(u, n, v, x): # (* If u has a subexpression of the form ((a+b*x)/(c+d*x))^(m/n), # FractionalPowerOfQuotientOfLinears[u,1,False,x] returns {n,(a+b*x)/(c+d*x)}; else it returns False. *) if AtomQ(u) or FreeQ(u, x): return [n, v] elif CalculusQ(u): return False elif FractionalPowerQ(u): if QuotientOfLinearsQ(u.base, x) and Not(LinearQ(u.base, x)) and (FalseQ(v) or ZeroQ(u.base - v)): return [LCM(Denominator(u.exp), n), u.base] lst = [n, v] for i in u.args: lst = FractionalPowerOfQuotientOfLinears(i, lst[0], lst[1],x) if AtomQ(lst): return False return lst def SubstForFractionalPowerQ(u, v, x): # (* If the substitution x=v^(1/n) will not complicate algebraic subexpressions of u, # SubstForFractionalPowerQ[u,v,x] returns True; else it returns False. *) if AtomQ(u) or FreeQ(u, x): return True elif FractionalPowerQ(u): return SubstForFractionalPowerAuxQ(u, v, x) return all(SubstForFractionalPowerQ(i, v, x) for i in u.args) def SubstForFractionalPowerAuxQ(u, v, x): if AtomQ(u): return False elif FractionalPowerQ(u): if ZeroQ(u.base - v): return True return any(SubstForFractionalPowerAuxQ(i, v, x) for i in u.args) def FractionalPowerOfSquareQ(u): # (* If a subexpression of u is of the form ((v+w)^2)^n where n is a fraction, *) # (* FractionalPowerOfSquareQ[u] returns (v+w)^2; else it returns False. *) if AtomQ(u): return False elif FractionalPowerQ(u): a_ = Wild('a', exclude=[0]) b_ = Wild('b', exclude=[0]) c_ = Wild('c', exclude=[0]) match = u.base.match(a_*(b_ + c_)**(S(2))) if match: keys = [a_, b_, c_] if len(keys) == len(match): a, b, c = tuple(match[i] for i in keys) if NonsumQ(a): return (b + c)**S(2) for i in u.args: tmp = FractionalPowerOfSquareQ(i) if Not(FalseQ(tmp)): return tmp return False def FractionalPowerSubexpressionQ(u, v, w): # (* If a subexpression of u is of the form w^n where n is a fraction but not equal to v, *) # (* FractionalPowerSubexpressionQ[u,v,w] returns True; else it returns False. *) if AtomQ(u): return False elif FractionalPowerQ(u): if PositiveQ(u.base/w): return Not(u.base == v) and LeafCount(w) < 3*LeafCount(v) for i in u.args: if FractionalPowerSubexpressionQ(i, v, w): return True return False def Apply(f, lst): return f(*lst) def FactorNumericGcd(u): # (* FactorNumericGcd[u] returns u with the gcd of the numeric coefficients of terms of sums factored out. *) if PowerQ(u): if RationalQ(u.exp): return FactorNumericGcd(u.base)**u.exp elif ProductQ(u): res = [FactorNumericGcd(i) for i in u.args] return Mul(*res) elif SumQ(u): g = GCD([NumericFactor(i) for i in u.args]) r = Add(*[i/g for i in u.args]) return g*r return u def MergeableFactorQ(bas, deg, v): # (* MergeableFactorQ[bas,deg,v] returns True iff bas equals the base of a factor of v or bas is a factor of every term of v. *) if bas == v: return RationalQ(deg + S(1)) and (deg + 1>=0 or RationalQ(deg) and deg>0) elif PowerQ(v): if bas == v.base: return RationalQ(deg+v.exp) and (deg+v.exp>=0 or RationalQ(deg) and deg>0) return SumQ(v.base) and IntegerQ(v.exp) and (Not(IntegerQ(deg) or IntegerQ(deg/v.exp))) and MergeableFactorQ(bas, deg/v.exp, v.base) elif ProductQ(v): return MergeableFactorQ(bas, deg, First(v)) or MergeableFactorQ(bas, deg, Rest(v)) return SumQ(v) and MergeableFactorQ(bas, deg, First(v)) and MergeableFactorQ(bas, deg, Rest(v)) def MergeFactor(bas, deg, v): # (* If MergeableFactorQ[bas,deg,v], MergeFactor[bas,deg,v] return the product of bas^deg and v, # but with bas^deg merged into the factor of v whose base equals bas. *) if bas == v: return bas**(deg + 1) elif PowerQ(v): if bas == v.base: return bas**(deg + v.exp) return MergeFactor(bas, deg/v.exp, v.base**v.exp) elif ProductQ(v): if MergeableFactorQ(bas, deg, First(v)): return MergeFactor(bas, deg, First(v))*Rest(v) return First(v)*MergeFactor(bas, deg, Rest(v)) return MergeFactor(bas, deg, First(v)) + MergeFactor(bas, deg, Rest(v)) def MergeFactors(u, v): # (* MergeFactors[u,v] returns the product of u and v, but with the mergeable factors of u merged into v. *) if ProductQ(u): return MergeFactors(Rest(u), MergeFactors(First(u), v)) elif PowerQ(u): if MergeableFactorQ(u.base, u.exp, v): return MergeFactor(u.base, u.exp, v) elif RationalQ(u.exp) and u.exp < -1 and MergeableFactorQ(u.base, -S(1), v): return MergeFactors(u.base**(u.exp + 1), MergeFactor(u.base, -S(1), v)) return u*v elif MergeableFactorQ(u, S(1), v): return MergeFactor(u, S(1), v) return u*v def TrigSimplifyQ(u): # (* TrigSimplifyQ[u] returns True if TrigSimplify[u] actually simplifies u; else False. *) return ActivateTrig(u) != TrigSimplify(u) def TrigSimplify(u): # (* TrigSimplify[u] returns a bottom-up trig simplification of u. *) return ActivateTrig(TrigSimplifyRecur(u)) def TrigSimplifyRecur(u): if AtomQ(u): return u return TrigSimplifyAux(u.func(*[TrigSimplifyRecur(i) for i in u.args])) def Order(expr1, expr2): if expr1 == expr2: return 0 elif expr1.sort_key() > expr2.sort_key(): return -1 return 1 def FactorOrder(u, v): if u == 1: if v == 1: return 0 return -1 elif v == 1: return 1 return Order(u, v) def Smallest(num1, num2=None): if num2 is None: lst = num1 num = lst[0] for i in Rest(lst): num = Smallest(num, i) return num return Min(num1, num2) def OrderedQ(l): return l == Sort(l) def MinimumDegree(deg1, deg2): if RationalQ(deg1): if RationalQ(deg2): return Min(deg1, deg2) return deg1 elif RationalQ(deg2): return deg2 deg = Simplify(deg1- deg2) if RationalQ(deg): if deg > 0: return deg2 return deg1 elif OrderedQ([deg1, deg2]): return deg1 return deg2 def PositiveFactors(u): # (* PositiveFactors[u] returns the positive factors of u *) if ZeroQ(u): return S(1) elif RationalQ(u): return Abs(u) elif PositiveQ(u): return u elif ProductQ(u): res = 1 for i in u.args: res *= PositiveFactors(i) return res return 1 def Sign(u): return sign(u) def NonpositiveFactors(u): # (* NonpositiveFactors[u] returns the nonpositive factors of u *) if ZeroQ(u): return u elif RationalQ(u): return Sign(u) elif PositiveQ(u): return S(1) elif ProductQ(u): res = S(1) for i in u.args: res *= NonpositiveFactors(i) return res return u def PolynomialInAuxQ(u, v, x): if u == v: return True elif AtomQ(u): return u != x elif PowerQ(u): if PowerQ(v): if u.base == v.base: return PositiveIntegerQ(u.exp/v.exp) return PositiveIntegerQ(u.exp) and PolynomialInAuxQ(u.base, v, x) elif SumQ(u) or ProductQ(u): for i in u.args: if Not(PolynomialInAuxQ(i, v, x)): return False return True return False def PolynomialInQ(u, v, x): """ If u is a polynomial in v(x), PolynomialInQ(u, v, x) returns True, else it returns False. Examples ======== >>> from sympy.integrals.rubi.utility_function import PolynomialInQ >>> from sympy.abc import x >>> from sympy import log, S >>> PolynomialInQ(S(1), log(x), x) True >>> PolynomialInQ(log(x), log(x), x) True >>> PolynomialInQ(1 + log(x)**2, log(x), x) True """ return PolynomialInAuxQ(u, NonfreeFactors(NonfreeTerms(v, x), x), x) def ExponentInAux(u, v, x): if u == v: return S(1) elif AtomQ(u): return S(0) elif PowerQ(u): if PowerQ(v): if u.base == v.base: return u.exp/v.exp return u.exp*ExponentInAux(u.base, v, x) elif ProductQ(u): return Add(*[ExponentInAux(i, v, x) for i in u.args]) return Max(*[ExponentInAux(i, v, x) for i in u.args]) def ExponentIn(u, v, x): return ExponentInAux(u, NonfreeFactors(NonfreeTerms(v, x), x), x) def PolynomialInSubstAux(u, v, x): if u == v: return x elif AtomQ(u): return u elif PowerQ(u): if PowerQ(v): if u.base == v.base: return x**(u.exp/v.exp) return PolynomialInSubstAux(u.base, v, x)**u.exp return u.func(*[PolynomialInSubstAux(i, v, x) for i in u.args]) def PolynomialInSubst(u, v, x): # If u is a polynomial in v[x], PolynomialInSubst[u,v,x] returns the polynomial u in x. w = NonfreeTerms(v, x) return ReplaceAll(PolynomialInSubstAux(u, NonfreeFactors(w, x), x), {x: x - FreeTerms(v, x)/FreeFactors(w, x)}) def Distrib(u, v): # Distrib[u,v] returns the sum of u times each term of v. if SumQ(v): return Add(*[u*i for i in v.args]) return u*v def DistributeDegree(u, m): # DistributeDegree[u,m] returns the product of the factors of u each raised to the mth degree. if AtomQ(u): return u**m elif PowerQ(u): return u.base**(u.exp*m) elif ProductQ(u): return Mul(*[DistributeDegree(i, m) for i in u.args]) return u**m def FunctionOfPower(*args): """ FunctionOfPower[u,x] returns the gcd of the integer degrees of x in u. Examples ======== >>> from sympy.integrals.rubi.utility_function import FunctionOfPower >>> from sympy.abc import x >>> FunctionOfPower(x, x) 1 >>> FunctionOfPower(x**3, x) 3 """ if len(args) == 2: return FunctionOfPower(args[0], None, args[1]) u, n, x = args if FreeQ(u, x): return n elif u == x: return S(1) elif PowerQ(u): if u.base == x and IntegerQ(u.exp): if n is None: return u.exp return GCD(n, u.exp) tmp = n for i in u.args: tmp = FunctionOfPower(i, tmp, x) return tmp def DivideDegreesOfFactors(u, n): """ DivideDegreesOfFactors[u,n] returns the product of the base of the factors of u raised to the degree of the factors divided by n. Examples ======== >>> from sympy import S >>> from sympy.integrals.rubi.utility_function import DivideDegreesOfFactors >>> from sympy.abc import a, b >>> DivideDegreesOfFactors(a**b, S(3)) a**(b/3) """ if ProductQ(u): return Mul(*[LeadBase(i)**(LeadDegree(i)/n) for i in u.args]) return LeadBase(u)**(LeadDegree(u)/n) def MonomialFactor(u, x): # MonomialFactor[u,x] returns the list {n,v} where x^n*v==u and n is free of x. if AtomQ(u): if u == x: return [S(1), S(1)] return [S(0), u] elif PowerQ(u): if IntegerQ(u.exp): lst = MonomialFactor(u.base, x) return [lst[0]*u.exp, lst[1]**u.exp] elif u.base == x and FreeQ(u.exp, x): return [u.exp, S(1)] return [S(0), u] elif ProductQ(u): lst1 = MonomialFactor(First(u), x) lst2 = MonomialFactor(Rest(u), x) return [lst1[0] + lst2[0], lst1[1]*lst2[1]] elif SumQ(u): lst = [MonomialFactor(i, x) for i in u.args] deg = lst[0][0] for i in Rest(lst): deg = MinimumDegree(deg, i[0]) if ZeroQ(deg) or RationalQ(deg) and deg < 0: return [S(0), u] return [deg, Add(*[x**(i[0] - deg)*i[1] for i in lst])] return [S(0), u] def FullSimplify(expr): return Simplify(expr) def FunctionOfLinearSubst(u, a, b, x): if FreeQ(u, x): return u elif LinearQ(u, x): tmp = Coefficient(u, x, 1) if tmp == b: tmp = S(1) else: tmp = tmp/b return Coefficient(u, x, S(0)) - a*tmp + tmp*x elif PowerQ(u): if FreeQ(u.base, x): return E**(FullSimplify(FunctionOfLinearSubst(Log(u.base)*u.exp, a, b, x))) lst = MonomialFactor(u, x) if ProductQ(u) and NonzeroQ(lst[0]): if RationalQ(LeadFactor(lst[1])) and LeadFactor(lst[1]) < 0: return -FunctionOfLinearSubst(DivideDegreesOfFactors(-lst[1], lst[0])*x, a, b, x)**lst[0] return FunctionOfLinearSubst(DivideDegreesOfFactors(lst[1], lst[0])*x, a, b, x)**lst[0] return u.func(*[FunctionOfLinearSubst(i, a, b, x) for i in u.args]) def FunctionOfLinear(*args): # (* If u (x) is equivalent to an expression of the form f (a+b*x) and not the case that a==0 and # b==1, FunctionOfLinear[u,x] returns the list {f (x),a,b}; else it returns False. *) if len(args) == 2: u, x = args lst = FunctionOfLinear(u, False, False, x, False) if AtomQ(lst) or FalseQ(lst[0]) or (lst[0] == 0 and lst[1] == 1): return False return [FunctionOfLinearSubst(u, lst[0], lst[1], x), lst[0], lst[1]] u, a, b, x, flag = args if FreeQ(u, x): return [a, b] elif CalculusQ(u): return False elif LinearQ(u, x): if FalseQ(a): return [Coefficient(u, x, 0), Coefficient(u, x, 1)] lst = CommonFactors([b, Coefficient(u, x, 1)]) if ZeroQ(Coefficient(u, x, 0)) and Not(flag): return [0, lst[0]] elif ZeroQ(b*Coefficient(u, x, 0) - a*Coefficient(u, x, 1)): return [a/lst[1], lst[0]] return [0, 1] elif PowerQ(u): if FreeQ(u.base, x): return FunctionOfLinear(Log(u.base)*u.exp, a, b, x, False) lst = MonomialFactor(u, x) if ProductQ(u) and NonzeroQ(lst[0]): if False and IntegerQ(lst[0]) and lst[0] != -1 and FreeQ(lst[1], x): if RationalQ(LeadFactor(lst[1])) and LeadFactor(lst[1]) < 0: return FunctionOfLinear(DivideDegreesOfFactors(-lst[1], lst[0])*x, a, b, x, False) return FunctionOfLinear(DivideDegreesOfFactors(lst[1], lst[0])*x, a, b, x, False) return False lst = [a, b] for i in u.args: lst = FunctionOfLinear(i, lst[0], lst[1], x, SumQ(u)) if AtomQ(lst): return False return lst def NormalizeIntegrand(u, x): v = NormalizeLeadTermSigns(NormalizeIntegrandAux(u, x)) if v == NormalizeLeadTermSigns(u): return u else: return v def NormalizeIntegrandAux(u, x): if SumQ(u): l = 0 for i in u.args: l += NormalizeIntegrandAux(i, x) return l if ProductQ(MergeMonomials(u, x)): l = 1 for i in MergeMonomials(u, x).args: l *= NormalizeIntegrandFactor(i, x) return l else: return NormalizeIntegrandFactor(MergeMonomials(u, x), x) def NormalizeIntegrandFactor(u, x): if PowerQ(u): if FreeQ(u.exp, x): bas = NormalizeIntegrandFactorBase(u.base, x) deg = u.exp if IntegerQ(deg) and SumQ(bas): if all(MonomialQ(i, x) for i in bas.args): mi = MinimumMonomialExponent(bas, x) q = 0 for i in bas.args: q += Simplify(i/x**mi) return x**(mi*deg)*q**deg else: return bas**deg else: return bas**deg if PowerQ(u): if FreeQ(u.base, x): return u.base**NormalizeIntegrandFactorBase(u.exp, x) bas = NormalizeIntegrandFactorBase(u, x) if SumQ(bas): if all(MonomialQ(i, x) for i in bas.args): mi = MinimumMonomialExponent(bas, x) z = 0 for j in bas.args: z += j/x**mi return x**mi*z else: return bas else: return bas def NormalizeIntegrandFactorBase(expr, x): m = Wild('m', exclude=[x]) u = Wild('u') match = expr.match(x**m*u) if match and SumQ(u): l = 0 for i in u.args: l += NormalizeIntegrandFactorBase((x**m*i), x) return l if BinomialQ(expr, x): if BinomialMatchQ(expr, x): return expr else: return ExpandToSum(expr, x) elif TrinomialQ(expr, x): if TrinomialMatchQ(expr, x): return expr else: return ExpandToSum(expr, x) elif ProductQ(expr): l = 1 for i in expr.args: l *= NormalizeIntegrandFactor(i, x) return l elif PolynomialQ(expr, x) and Exponent(expr, x)<=4: return ExpandToSum(expr, x) elif SumQ(expr): w = Wild('w') m = Wild('m', exclude=[x]) v = TogetherSimplify(expr) if SumQ(v) or v.match(x**m*w) and SumQ(w) or LeafCount(v)>LeafCount(expr)+2: return UnifySum(expr, x) else: return NormalizeIntegrandFactorBase(v, x) else: return expr def NormalizeTogether(u): return NormalizeLeadTermSigns(Together(u)) def NormalizeLeadTermSigns(u): if ProductQ(u): t = 1 for i in u.args: lst = SignOfFactor(i) if lst[0] == 1: t *= lst[1] else: t *= AbsorbMinusSign(lst[1]) return t else: lst = SignOfFactor(u) if lst[0] == 1: return lst[1] else: return AbsorbMinusSign(lst[1]) def AbsorbMinusSign(expr, *x): m = Wild('m', exclude=[x]) u = Wild('u') v = Wild('v') match = expr.match(u*v**m) if match: if len(match) == 3: if SumQ(match[v]) and OddQ(match[m]): return match[u]*(-match[v])**match[m] return -expr def NormalizeSumFactors(u): if AtomQ(u): return u elif ProductQ(u): k = 1 for i in u.args: k *= NormalizeSumFactors(i) return SignOfFactor(k)[0]*SignOfFactor(k)[1] elif SumQ(u): k = 0 for i in u.args: k += NormalizeSumFactors(i) return k else: return u def SignOfFactor(u): if RationalQ(u) and u < 0 or SumQ(u) and NumericFactor(First(u)) < 0: return [-1, -u] elif IntegerPowerQ(u): if SumQ(u.base) and NumericFactor(First(u.base)) < 0: return [(-1)**u.exp, (-u.base)**u.exp] elif ProductQ(u): k = 1 h = 1 for i in u.args: k *= SignOfFactor(i)[0] h *= SignOfFactor(i)[1] return [k, h] return [1, u] def NormalizePowerOfLinear(u, x): v = FactorSquareFree(u) if PowerQ(v): if LinearQ(v.base, x) and FreeQ(v.exp, x): return ExpandToSum(v.base, x)**v.exp return ExpandToSum(v, x) def SimplifyIntegrand(u, x): v = NormalizeLeadTermSigns(NormalizeIntegrandAux(Simplify(u), x)) if 5*LeafCount(v) < 4*LeafCount(u): return v if v != NormalizeLeadTermSigns(u): return v else: return u def SimplifyTerm(u, x): v = Simplify(u) w = Together(v) if LeafCount(v) < LeafCount(w): return NormalizeIntegrand(v, x) else: return NormalizeIntegrand(w, x) def TogetherSimplify(u): v = Together(Simplify(Together(u))) return FixSimplify(v) def SmartSimplify(u): v = Simplify(u) w = factor(v) if LeafCount(w) < LeafCount(v): v = w if Not(FalseQ(w == FractionalPowerOfSquareQ(v))) and FractionalPowerSubexpressionQ(u, w, Expand(w)): v = SubstForExpn(v, w, Expand(w)) else: v = FactorNumericGcd(v) return FixSimplify(v) def SubstForExpn(u, v, w): if u == v: return w if AtomQ(u): return u else: k = 0 for i in u.args: k += SubstForExpn(i, v, w) return k def ExpandToSum(u, *x): if len(x) == 1: x = x[0] expr = 0 if PolyQ(S(u), x): for t in Exponent(u, x, List): expr += Coeff(u, x, t)*x**t return expr if BinomialQ(u, x): i = BinomialParts(u, x) expr += i[0] + i[1]*x**i[2] return expr if TrinomialQ(u, x): i = TrinomialParts(u, x) expr += i[0] + i[1]*x**i[3] + i[2]*x**(2*i[3]) return expr if GeneralizedBinomialMatchQ(u, x): i = GeneralizedBinomialParts(u, x) expr += i[0]*x**i[3] + i[1]*x**i[2] return expr if GeneralizedTrinomialMatchQ(u, x): i = GeneralizedTrinomialParts(u, x) expr += i[0]*x**i[4] + i[1]*x**i[3] + i[2]*x**(2*i[3]-i[4]) return expr else: return Expand(u) else: v = x[0] x = x[1] w = ExpandToSum(v, x) r = NonfreeTerms(w, x) if SumQ(r): k = u*FreeTerms(w, x) for i in r.args: k += MergeMonomials(u*i, x) return k else: return u*FreeTerms(w, x) + MergeMonomials(u*r, x) def UnifySum(u, x): if SumQ(u): t = 0 lst = [] for i in u.args: lst += [i] for j in UnifyTerms(lst, x): t += j return t else: return SimplifyTerm(u, x) def UnifyTerms(lst, x): if lst==[]: return lst else: return UnifyTerm(First(lst), UnifyTerms(Rest(lst), x), x) def UnifyTerm(term, lst, x): if lst==[]: return [term] tmp = Simplify(First(lst)/term) if FreeQ(tmp, x): return Prepend(Rest(lst), [(1+tmp)*term]) else: return Prepend(UnifyTerm(term, Rest(lst), x), [First(lst)]) def CalculusQ(u): return False def FunctionOfInverseLinear(*args): # (* If u is a function of an inverse linear binomial of the form 1/(a+b*x), # FunctionOfInverseLinear[u,x] returns the list {a,b}; else it returns False. *) if len(args) == 2: u, x = args return FunctionOfInverseLinear(u, None, x) u, lst, x = args if FreeQ(u, x): return lst elif u == x: return False elif QuotientOfLinearsQ(u, x): tmp = Drop(QuotientOfLinearsParts(u, x), 2) if tmp[1] == 0: return False elif lst is None: return tmp elif ZeroQ(lst[0]*tmp[1] - lst[1]*tmp[0]): return lst return False elif CalculusQ(u): return False tmp = lst for i in u.args: tmp = FunctionOfInverseLinear(i, tmp, x) if AtomQ(tmp): return False return tmp def PureFunctionOfSinhQ(u, v, x): # (* If u is a pure function of Sinh[v] and/or Csch[v], PureFunctionOfSinhQ[u,v,x] returns True; # else it returns False. *) if AtomQ(u): return u != x elif CalculusQ(u): return False elif HyperbolicQ(u) and ZeroQ(u.args[0] - v): return SinhQ(u) or CschQ(u) for i in u.args: if Not(PureFunctionOfSinhQ(i, v, x)): return False return True def PureFunctionOfTanhQ(u, v , x): # (* If u is a pure function of Tanh[v] and/or Coth[v], PureFunctionOfTanhQ[u,v,x] returns True; # else it returns False. *) if AtomQ(u): return u != x elif CalculusQ(u): return False elif HyperbolicQ(u) and ZeroQ(u.args[0] - v): return TanhQ(u) or CothQ(u) for i in u.args: if Not(PureFunctionOfTanhQ(i, v, x)): return False return True def PureFunctionOfCoshQ(u, v, x): # (* If u is a pure function of Cosh[v] and/or Sech[v], PureFunctionOfCoshQ[u,v,x] returns True; # else it returns False. *) if AtomQ(u): return u != x elif CalculusQ(u): return False elif HyperbolicQ(u) and ZeroQ(u.args[0] - v): return CoshQ(u) or SechQ(u) for i in u.args: if Not(PureFunctionOfCoshQ(i, v, x)): return False return True def IntegerQuotientQ(u, v): # (* If u/v is an integer, IntegerQuotientQ[u,v] returns True; else it returns False. *) return IntegerQ(Simplify(u/v)) def OddQuotientQ(u, v): # (* If u/v is odd, OddQuotientQ[u,v] returns True; else it returns False. *) return OddQ(Simplify(u/v)) def EvenQuotientQ(u, v): # (* If u/v is even, EvenQuotientQ[u,v] returns True; else it returns False. *) return EvenQ(Simplify(u/v)) def FindTrigFactor(func1, func2, u, v, flag): # (* If func[w]^m is a factor of u where m is odd and w is an integer multiple of v, # FindTrigFactor[func1,func2,u,v,True] returns the list {w,u/func[w]^n}; else it returns False. *) # (* If func[w]^m is a factor of u where m is odd and w is an integer multiple of v not equal to v, # FindTrigFactor[func1,func2,u,v,False] returns the list {w,u/func[w]^n}; else it returns False. *) if u == 1: return False elif (Head(LeadBase(u)) == func1 or Head(LeadBase(u)) == func2) and OddQ(LeadDegree(u)) and IntegerQuotientQ(LeadBase(u).args[0], v) and (flag or NonzeroQ(LeadBase(u).args[0] - v)): return [LeadBase[u].args[0], RemainingFactors(u)] lst = FindTrigFactor(func1, func2, RemainingFactors(u), v, flag) if AtomQ(lst): return False return [lst[0], LeadFactor(u)*lst[1]] def FunctionOfSinhQ(u, v, x): # (* If u is a function of Sinh[v], FunctionOfSinhQ[u,v,x] returns True; else it returns False. *) if AtomQ(u): return u != x elif CalculusQ(u): return False elif HyperbolicQ(u) and IntegerQuotientQ(u.args[0], v): if OddQuotientQ(u.args[0], v): # (* Basis: If m odd, Sinh[m*v]^n is a function of Sinh[v]. *) return SinhQ(u) or CschQ(u) # (* Basis: If m even, Cos[m*v]^n is a function of Sinh[v]. *) return CoshQ(u) or SechQ(u) elif IntegerPowerQ(u): if HyperbolicQ(u.base) and IntegerQuotientQ(u.base.args[0], v): if EvenQ(u.exp): # (* Basis: If m integer and n even, Hyper[m*v]^n is a function of Sinh[v]. *) return True return FunctionOfSinhQ(u.base, v, x) elif ProductQ(u): if CoshQ(u.args[0]) and SinhQ(u.args[1]) and ZeroQ(u.args[0].args[0] - v/2) and ZeroQ(u.args[1].args[0] - v/2): return FunctionOfSinhQ(Drop(u, 2), v, x) lst = FindTrigFactor(Sinh, Csch, u, v, False) if ListQ(lst) and EvenQuotientQ(lst[0], v): # (* Basis: If m even and n odd, Sinh[m*v]^n == Cosh[v]*u where u is a function of Sinh[v]. *) return FunctionOfSinhQ(Cosh(v)*lst[1], v, x) lst = FindTrigFactor(Cosh, Sech, u, v, False) if ListQ(lst) and OddQuotientQ(lst[0], v): # (* Basis: If m odd and n odd, Cosh[m*v]^n == Cosh[v]*u where u is a function of Sinh[v]. *) return FunctionOfSinhQ(Cosh(v)*lst[1], v, x) lst = FindTrigFactor(Tanh, Coth, u, v, True) if ListQ(lst): # (* Basis: If m integer and n odd, Tanh[m*v]^n == Cosh[v]*u where u is a function of Sinh[v]. *) return FunctionOfSinhQ(Cosh(v)*lst[1], v, x) return all(FunctionOfSinhQ(i, v, x) for i in u.args) return all(FunctionOfSinhQ(i, v, x) for i in u.args) def FunctionOfCoshQ(u, v, x): #(* If u is a function of Cosh[v], FunctionOfCoshQ[u,v,x] returns True; else it returns False. *) if AtomQ(u): return u != x elif CalculusQ(u): return False elif HyperbolicQ(u) and IntegerQuotientQ(u.args[0], v): # (* Basis: If m integer, Cosh[m*v]^n is a function of Cosh[v]. *) return CoshQ(u) or SechQ(u) elif IntegerPowerQ(u): if HyperbolicQ(u.base) and IntegerQuotientQ(u.base.args[0], v): if EvenQ(u.exp): # (* Basis: If m integer and n even, Hyper[m*v]^n is a function of Cosh[v]. *) return True return FunctionOfCoshQ(u.base, v, x) elif ProductQ(u): lst = FindTrigFactor(Sinh, Csch, u, v, False) if ListQ(lst): # (* Basis: If m integer and n odd, Sinh[m*v]^n == Sinh[v]*u where u is a function of Cosh[v]. *) return FunctionOfCoshQ(Sinh(v)*lst[1], v, x) lst = FindTrigFactor(Tanh, Coth, u, v, True) if ListQ(lst): # (* Basis: If m integer and n odd, Tanh[m*v]^n == Sinh[v]*u where u is a function of Cosh[v]. *) return FunctionOfCoshQ(Sinh(v)*lst[1], v, x) return all(FunctionOfCoshQ(i, v, x) for i in u.args) return all(FunctionOfCoshQ(i, v, x) for i in u.args) def OddHyperbolicPowerQ(u, v, x): if SinhQ(u) or CoshQ(u) or SechQ(u) or CschQ(u): return OddQuotientQ(u.args[0], v) if PowerQ(u): return OddQ(u.exp) and OddHyperbolicPowerQ(u.base, v, x) if ProductQ(u): if Not(EqQ(FreeFactors(u, x), 1)): return OddHyperbolicPowerQ(NonfreeFactors(u, x), v, x) lst = [] for i in u.args: if Not(FunctionOfTanhQ(i, v, x)): lst.append(i) if lst == []: return True return Length(lst)==1 and OddHyperbolicPowerQ(lst[0], v, x) if SumQ(u): return all(OddHyperbolicPowerQ(i, v, x) for i in u.args) return False def FunctionOfTanhQ(u, v, x): #(* If u is a function of the form f[Tanh[v],Coth[v]] where f is independent of x, # FunctionOfTanhQ[u,v,x] returns True; else it returns False. *) if AtomQ(u): return u != x elif CalculusQ(u): return False elif HyperbolicQ(u) and IntegerQuotientQ(u.args[0], v): return TanhQ(u) or CothQ(u) or EvenQuotientQ(u.args[0], v) elif PowerQ(u): if EvenQ(u.exp) and HyperbolicQ(u.base) and IntegerQuotientQ(u.base.args[0], v): return True elif EvenQ(u.args[1]) and SumQ(u.args[0]): return FunctionOfTanhQ(Expand(u.args[0]**2, v, x)) if ProductQ(u): lst = [] for i in u.args: if Not(FunctionOfTanhQ(i, v, x)): lst.append(i) if lst == []: return True return Length(lst)==2 and OddHyperbolicPowerQ(lst[0], v, x) and OddHyperbolicPowerQ(lst[1], v, x) return all(FunctionOfTanhQ(i, v, x) for i in u.args) def FunctionOfTanhWeight(u, v, x): """ u is a function of the form f(tanh(v), coth(v)) where f is independent of x. FunctionOfTanhWeight(u, v, x) returns a nonnegative number if u is best considered a function of tanh(v), else it returns a negative number. Examples ======== >>> from sympy import sinh, log, tanh >>> from sympy.abc import x >>> from sympy.integrals.rubi.utility_function import FunctionOfTanhWeight >>> FunctionOfTanhWeight(x, log(x), x) 0 >>> FunctionOfTanhWeight(sinh(log(x)), log(x), x) 0 >>> FunctionOfTanhWeight(tanh(log(x)), log(x), x) 1 """ if AtomQ(u): return S(0) elif CalculusQ(u): return S(0) elif HyperbolicQ(u) and IntegerQuotientQ(u.args[0], v): if TanhQ(u) and ZeroQ(u.args[0] - v): return S(1) elif CothQ(u) and ZeroQ(u.args[0] - v): return S(-1) return S(0) elif PowerQ(u): if EvenQ(u.exp) and HyperbolicQ(u.base) and IntegerQuotientQ(u.base.args[0], v): if TanhQ(u.base) or CoshQ(u.base) or SechQ(u.base): return S(1) return S(-1) if ProductQ(u): if all(FunctionOfTanhQ(i, v, x) for i in u.args): return Add(*[FunctionOfTanhWeight(i, v, x) for i in u.args]) return S(0) return Add(*[FunctionOfTanhWeight(i, v, x) for i in u.args]) def FunctionOfHyperbolicQ(u, v, x): # (* If u (x) is equivalent to a function of the form f (Sinh[v],Cosh[v],Tanh[v],Coth[v],Sech[v],Csch[v]) # where f is independent of x, FunctionOfHyperbolicQ[u,v,x] returns True; else it returns False. *) if AtomQ(u): return u != x elif CalculusQ(u): return False elif HyperbolicQ(u) and IntegerQuotientQ(u.args[0], v): return True return all(FunctionOfHyperbolicQ(i, v, x) for i in u.args) def SmartNumerator(expr): if PowerQ(expr): n = expr.exp u = expr.base if RationalQ(n) and n < 0: return SmartDenominator(u**(-n)) elif ProductQ(expr): return Mul(*[SmartNumerator(i) for i in expr.args]) return Numerator(expr) def SmartDenominator(expr): if PowerQ(expr): u = expr.base n = expr.exp if RationalQ(n) and n < 0: return SmartNumerator(u**(-n)) elif ProductQ(expr): return Mul(*[SmartDenominator(i) for i in expr.args]) return Denominator(expr) def ActivateTrig(u): return u def ExpandTrig(*args): if len(args) == 2: u, x = args return ActivateTrig(ExpandIntegrand(u, x)) u, v, x = args w = ExpandTrig(v, x) z = ActivateTrig(u) if SumQ(w): return w.func(*[z*i for i in w.args]) return z*w def TrigExpand(u): return expand_trig(u) # SubstForTrig[u_,sin_,cos_,v_,x_] := # If[AtomQ[u], # u, # If[TrigQ[u] && IntegerQuotientQ[u[[1]],v], # If[u[[1]]===v || ZeroQ[u[[1]]-v], # If[SinQ[u], # sin, # If[CosQ[u], # cos, # If[TanQ[u], # sin/cos, # If[CotQ[u], # cos/sin, # If[SecQ[u], # 1/cos, # 1/sin]]]]], # Map[Function[SubstForTrig[#,sin,cos,v,x]], # ReplaceAll[TrigExpand[Head[u][Simplify[u[[1]]/v]*x]],x->v]]], # If[ProductQ[u] && CosQ[u[[1]]] && SinQ[u[[2]]] && ZeroQ[u[[1,1]]-v/2] && ZeroQ[u[[2,1]]-v/2], # sin/2*SubstForTrig[Drop[u,2],sin,cos,v,x], # Map[Function[SubstForTrig[#,sin,cos,v,x]],u]]]] def SubstForTrig(u, sin_ , cos_, v, x): # (* u (v) is an expression of the form f (Sin[v],Cos[v],Tan[v],Cot[v],Sec[v],Csc[v]). *) # (* SubstForTrig[u,sin,cos,v,x] returns the expression f (sin,cos,sin/cos,cos/sin,1/cos,1/sin). *) if AtomQ(u): return u elif TrigQ(u) and IntegerQuotientQ(u.args[0], v): if u.args[0] == v or ZeroQ(u.args[0] - v): if SinQ(u): return sin_ elif CosQ(u): return cos_ elif TanQ(u): return sin_/cos_ elif CotQ(u): return cos_/sin_ elif SecQ(u): return 1/cos_ return 1/sin_ r = ReplaceAll(TrigExpand(Head(u)(Simplify(u.args[0]/v*x))), {x: v}) return r.func(*[SubstForTrig(i, sin_, cos_, v, x) for i in r.args]) if ProductQ(u) and CosQ(u.args[0]) and SinQ(u.args[1]) and ZeroQ(u.args[0].args[0] - v/2) and ZeroQ(u.args[1].args[0] - v/2): return sin(x)/2*SubstForTrig(Drop(u, 2), sin_, cos_, v, x) return u.func(*[SubstForTrig(i, sin_, cos_, v, x) for i in u.args]) def SubstForHyperbolic(u, sinh_, cosh_, v, x): # (* u (v) is an expression of the form f (Sinh[v],Cosh[v],Tanh[v],Coth[v],Sech[v],Csch[v]). *) # (* SubstForHyperbolic[u,sinh,cosh,v,x] returns the expression # f (sinh,cosh,sinh/cosh,cosh/sinh,1/cosh,1/sinh). *) if AtomQ(u): return u elif HyperbolicQ(u) and IntegerQuotientQ(u.args[0], v): if u.args[0] == v or ZeroQ(u.args[0] - v): if SinhQ(u): return sinh_ elif CoshQ(u): return cosh_ elif TanhQ(u): return sinh_/cosh_ elif CothQ(u): return cosh_/sinh_ if SechQ(u): return 1/cosh_ return 1/sinh_ r = ReplaceAll(TrigExpand(Head(u)(Simplify(u.args[0]/v)*x)), {x: v}) return r.func(*[SubstForHyperbolic(i, sinh_, cosh_, v, x) for i in r.args]) elif ProductQ(u) and CoshQ(u.args[0]) and SinhQ(u.args[1]) and ZeroQ(u.args[0].args[0] - v/2) and ZeroQ(u.args[1].args[0] - v/2): return sinh(x)/2*SubstForHyperbolic(Drop(u, 2), sinh_, cosh_, v, x) return u.func(*[SubstForHyperbolic(i, sinh_, cosh_, v, x) for i in u.args]) def InertTrigFreeQ(u): return FreeQ(u, sin) and FreeQ(u, cos) and FreeQ(u, tan) and FreeQ(u, cot) and FreeQ(u, sec) and FreeQ(u, csc) def LCM(a, b): return lcm(a, b) def SubstForFractionalPowerOfLinear(u, x): # (* If u has a subexpression of the form (a+b*x)^(m/n) where m and n>1 are integers, # SubstForFractionalPowerOfLinear[u,x] returns the list {v,n,a+b*x,1/b} where v is u # with subexpressions of the form (a+b*x)^(m/n) replaced by x^m and x replaced # by -a/b+x^n/b, and all times x^(n-1); else it returns False. *) lst = FractionalPowerOfLinear(u, S(1), False, x) if AtomQ(lst) or FalseQ(lst[1]): return False n = lst[0] a = Coefficient(lst[1], x, 0) b = Coefficient(lst[1], x, 1) tmp = Simplify(x**(n-1)*SubstForFractionalPower(u, lst[1], n, -a/b + x**n/b, x)) return [NonfreeFactors(tmp, x), n, lst[1], FreeFactors(tmp, x)/b] def FractionalPowerOfLinear(u, n, v, x): # If u has a subexpression of the form (a + b*x)**(m/n), FractionalPowerOfLinear(u, 1, False, x) returns [n, a + b*x], else it returns False. if AtomQ(u) or FreeQ(u, x): return [n, v] elif CalculusQ(u): return False elif FractionalPowerQ(u): if LinearQ(u.base, x) and (FalseQ(v) or ZeroQ(u.base - v)): return [LCM(Denominator(u.exp), n), u.base] lst = [n, v] for i in u.args: lst = FractionalPowerOfLinear(i, lst[0], lst[1], x) if AtomQ(lst): return False return lst def InverseFunctionOfLinear(u, x): # (* If u has a subexpression of the form g[a+b*x] where g is an inverse function, # InverseFunctionOfLinear[u,x] returns g[a+b*x]; else it returns False. *) if AtomQ(u) or CalculusQ(u) or FreeQ(u, x): return False elif InverseFunctionQ(u) and LinearQ(u.args[0], x): return u for i in u.args: tmp = InverseFunctionOfLinear(i, x) if Not(AtomQ(tmp)): return tmp return False def InertTrigQ(*args): if len(args) == 1: f = args[0] l = [sin,cos,tan,cot,sec,csc] return any(Head(f) == i for i in l) elif len(args) == 2: f, g = args if f == g: return InertTrigQ(f) return InertReciprocalQ(f, g) or InertReciprocalQ(g, f) else: f, g, h = args return InertTrigQ(g, f) and InertTrigQ(g, h) def InertReciprocalQ(f, g): return (f.func == sin and g.func == csc) or (f.func == cos and g.func == sec) or (f.func == tan and g.func == cot) def DeactivateTrig(u, x): # (* u is a function of trig functions of a linear function of x. *) # (* DeactivateTrig[u,x] returns u with the trig functions replaced with inert trig functions. *) return FixInertTrigFunction(DeactivateTrigAux(u, x), x) def FixInertTrigFunction(u, x): return u def DeactivateTrigAux(u, x): if AtomQ(u): return u elif TrigQ(u) and LinearQ(u.args[0], x): v = ExpandToSum(u.args[0], x) if SinQ(u): return sin(v) elif CosQ(u): return cos(v) elif TanQ(u): return tan(u) elif CotQ(u): return cot(v) elif SecQ(u): return sec(v) return csc(v) elif HyperbolicQ(u) and LinearQ(u.args[0], x): v = ExpandToSum(I*u.args[0], x) if SinhQ(u): return -I*sin(v) elif CoshQ(u): return cos(v) elif TanhQ(u): return -I*tan(v) elif CothQ(u): I*cot(v) elif SechQ(u): return sec(v) return I*csc(v) return u.func(*[DeactivateTrigAux(i, x) for i in u.args]) def PowerOfInertTrigSumQ(u, func, x): p_ = Wild('p', exclude=[x]) q_ = Wild('q', exclude=[x]) a_ = Wild('a', exclude=[x]) b_ = Wild('b', exclude=[x]) c_ = Wild('c', exclude=[x]) d_ = Wild('d', exclude=[x]) n_ = Wild('n', exclude=[x]) w_ = Wild('w') pattern = (a_ + b_*(c_*func(w_))**p_)**n_ match = u.match(pattern) if match: keys = [a_, b_, c_, n_, p_, w_] if len(keys) == len(match): return True pattern = (a_ + b_*(d_*func(w_))**p_ + c_*(d_*func(w_))**q_)**n_ match = u.match(pattern) if match: keys = [a_, b_, c_, d_, n_, p_, q_, w_] if len(keys) == len(match): return True return False def PiecewiseLinearQ(*args): # (* If the derivative of u wrt x is a constant wrt x, PiecewiseLinearQ[u,x] returns True; # else it returns False. *) if len(args) == 3: u, v, x = args return PiecewiseLinearQ(u, x) and PiecewiseLinearQ(v, x) u, x = args if LinearQ(u, x): return True c_ = Wild('c', exclude=[x]) F_ = Wild('F', exclude=[x]) v_ = Wild('v') match = u.match(Log(c_*F_**v_)) if match: if len(match) == 3: if LinearQ(match[v_], x): return True try: F = type(u) G = type(u.args[0]) v = u.args[0].args[0] if LinearQ(v, x): if MemberQ([[atanh, tanh], [atanh, coth], [acoth, coth], [acoth, tanh], [atan, tan], [atan, cot], [acot, cot], [acot, tan]], [F, G]): return True except: pass return False def KnownTrigIntegrandQ(lst, u, x): if u == 1: return True a_ = Wild('a', exclude=[x]) b_ = Wild('b', exclude=[x, 0]) func_ = WildFunction('func') m_ = Wild('m', exclude=[x]) A_ = Wild('A', exclude=[x]) B_ = Wild('B', exclude=[x, 0]) C_ = Wild('C', exclude=[x, 0]) match = u.match((a_ + b_*func_)**m_) if match: func = match[func_] if LinearQ(func.args[0], x) and MemberQ(lst, func.func): return True match = u.match((a_ + b_*func_)**m_*(A_ + B_*func_)) if match: func = match[func_] if LinearQ(func.args[0], x) and MemberQ(lst, func.func): return True match = u.match(A_ + C_*func_**2) if match: func = match[func_] if LinearQ(func.args[0], x) and MemberQ(lst, func.func): return True match = u.match(A_ + B_*func_ + C_*func_**2) if match: func = match[func_] if LinearQ(func.args[0], x) and MemberQ(lst, func.func): return True match = u.match((a_ + b_*func_)**m_*(A_ + C_*func_**2)) if match: func = match[func_] if LinearQ(func.args[0], x) and MemberQ(lst, func.func): return True match = u.match((a_ + b_*func_)**m_*(A_ + B_*func_ + C_*func_**2)) if match: func = match[func_] if LinearQ(func.args[0], x) and MemberQ(lst, func.func): return True return False def KnownSineIntegrandQ(u, x): return KnownTrigIntegrandQ([sin, cos], u, x) def KnownTangentIntegrandQ(u, x): return KnownTrigIntegrandQ([tan], u, x) def KnownCotangentIntegrandQ(u, x): return KnownTrigIntegrandQ([cot], u, x) def KnownSecantIntegrandQ(u, x): return KnownTrigIntegrandQ([sec, csc], u, x) def TryPureTanSubst(u, x): a_ = Wild('a', exclude=[x]) b_ = Wild('b', exclude=[x]) c_ = Wild('c', exclude=[x]) G_ = Wild('G') F = u.func try: if MemberQ([atan, acot, atanh, acoth], F): match = u.args[0].match(c_*(a_ + b_*G_)) if match: if len(match) == 4: G = match[G_] if MemberQ([tan, cot, tanh, coth], G.func): if LinearQ(G.args[0], x): return True except: pass return False def TryTanhSubst(u, x): if LogQ(u): return False elif not FalseQ(FunctionOfLinear(u, x)): return False a_ = Wild('a', exclude=[x]) m_ = Wild('m', exclude=[x]) p_ = Wild('p', exclude=[x]) r_, s_, t_, n_, b_, f_, g_ = map(Wild, 'rstnbfg') match = u.match(r_*(s_ + t_)**n_) if match: if len(match) == 4: r, s, t, n = [match[i] for i in [r_, s_, t_, n_]] if IntegerQ(n) and PositiveQ(n): return False match = u.match(1/(a_ + b_*f_**n_)) if match: if len(match) == 4: a, b, f, n = [match[i] for i in [a_, b_, f_, n_]] if SinhCoshQ(f) and IntegerQ(n) and n > 2: return False match = u.match(f_*g_) if match: if len(match) == 2: f, g = match[f_], match[g_] if SinhCoshQ(f) and SinhCoshQ(g): if IntegersQ(f.args[0]/x, g.args[0]/x): return False match = u.match(r_*(a_*s_**m_)**p_) if match: if len(match) == 5: r, a, s, m, p = [match[i] for i in [r_, a_, s_, m_, p_]] if Not(m==2 and (s == Sech(x) or s == Csch(x))): return False if u != ExpandIntegrand(u, x): return False return True def TryPureTanhSubst(u, x): F = u.func a_ = Wild('a', exclude=[x]) G_ = Wild('G') if F == sym_log: return False match = u.args[0].match(a_*G_) if match and len(match) == 2: G = match[G_].func if MemberQ([atanh, acoth], F) and MemberQ([tanh, coth], G): return False if u != ExpandIntegrand(u, x): return False return True def AbsurdNumberGCD(*seq): # (* m, n, ... must be absurd numbers. AbsurdNumberGCD[m,n,...] returns the gcd of m, n, ... *) lst = list(seq) if Length(lst) == 1: return First(lst) return AbsurdNumberGCDList(FactorAbsurdNumber(First(lst)), FactorAbsurdNumber(AbsurdNumberGCD(*Rest(lst)))) def AbsurdNumberGCDList(lst1, lst2): # (* lst1 and lst2 must be absurd number prime factorization lists. *) # (* AbsurdNumberGCDList[lst1,lst2] returns the gcd of the absurd numbers represented by lst1 and lst2. *) if lst1 == []: return Mul(*[i[0]**Min(i[1],0) for i in lst2]) elif lst2 == []: return Mul(*[i[0]**Min(i[1],0) for i in lst1]) elif lst1[0][0] == lst2[0][0]: if lst1[0][1] <= lst2[0][1]: return lst1[0][0]**lst1[0][1]*AbsurdNumberGCDList(Rest(lst1), Rest(lst2)) return lst1[0][0]**lst2[0][1]*AbsurdNumberGCDList(Rest(lst1), Rest(lst2)) elif lst1[0][0] < lst2[0][0]: if lst1[0][1] < 0: return lst1[0][0]**lst1[0][1]*AbsurdNumberGCDList(Rest(lst1), lst2) return AbsurdNumberGCDList(Rest(lst1), lst2) elif lst2[0][1] < 0: return lst2[0][0]**lst2[0][1]*AbsurdNumberGCDList(lst1, Rest(lst2)) return AbsurdNumberGCDList(lst1, Rest(lst2)) def ExpandTrigExpand(u, F, v, m, n, x): w = Expand(TrigExpand(F.xreplace({x: n*x}))**m).xreplace({x: v}) if SumQ(w): t = 0 for i in w.args: t += u*i return t else: return u*w def ExpandTrigReduce(*args): if len(args) == 3: u = args[0] v = args[1] x = args[2] w = ExpandTrigReduce(v, x) if SumQ(w): t = 0 for i in w.args: t += u*i return t else: return u*w else: u = args[0] x = args[1] return ExpandTrigReduceAux(u, x) def ExpandTrigReduceAux(u, x): v = TrigReduce(u).expand() if SumQ(v): t = 0 for i in v.args: t += NormalizeTrig(i, x) return t return NormalizeTrig(v, x) def NormalizeTrig(v, x): a = Wild('a', exclude=[x]) n = Wild('n', exclude=[x, 0]) F = Wild('F') expr = a*F**n M = v.match(expr) if M and len(M[F].args) == 1 and PolynomialQ(M[F].args[0], x) and Exponent(M[F].args[0], x)>0: u = M[F].args[0] return M[a]*M[F].xreplace({u: ExpandToSum(u, x)})**M[n] else: return v #================================= def TrigToExp(expr): ex = expr.rewrite(sin, sym_exp).rewrite(cos, sym_exp).rewrite(tan, sym_exp).rewrite(sec, sym_exp).rewrite(csc, sym_exp).rewrite(cot, sym_exp) return ex.replace(sym_exp, rubi_exp) def ExpandTrigToExp(u, *args): if len(args) == 1: x = args[0] return ExpandTrigToExp(1, u, x) else: v = args[0] x = args[1] w = TrigToExp(v) k = 0 if SumQ(w): for i in w.args: k += SimplifyIntegrand(u*i, x) w = k else: w = SimplifyIntegrand(u*w, x) return ExpandIntegrand(FreeFactors(w, x), NonfreeFactors(w, x),x) #====================================== def TrigReduce(i): """ TrigReduce(expr) rewrites products and powers of trigonometric functions in expr in terms of trigonometric functions with combined arguments. Examples ======== >>> from sympy import sin, cos >>> from sympy.integrals.rubi.utility_function import TrigReduce >>> from sympy.abc import x >>> TrigReduce(cos(x)**2) cos(2*x)/2 + 1/2 >>> TrigReduce(cos(x)**2*sin(x)) sin(x)/4 + sin(3*x)/4 >>> TrigReduce(cos(x)**2+sin(x)) sin(x) + cos(2*x)/2 + 1/2 """ if SumQ(i): t = 0 for k in i.args: t += TrigReduce(k) return t if ProductQ(i): if any(PowerQ(k) for k in i.args): if (i.rewrite((sin, sinh), sym_exp).rewrite((cos, cosh), sym_exp).expand().rewrite(sym_exp, sin)).has(I, cosh, sinh): return i.rewrite((sin, sinh), sym_exp).rewrite((cos, cosh), sym_exp).expand().rewrite(sym_exp, sin).simplify() else: return i.rewrite((sin, sinh), sym_exp).rewrite((cos, cosh), sym_exp).expand().rewrite(sym_exp, sin) else: a = Wild('a') b = Wild('b') v = Wild('v') Match = i.match(v*sin(a)*cos(b)) if Match: a = Match[a] b = Match[b] v = Match[v] return i.subs(v*sin(a)*cos(b), v*S(1)/2*(sin(a + b) + sin(a - b))) Match = i.match(v*sin(a)*sin(b)) if Match: a = Match[a] b = Match[b] v = Match[v] return i.subs(v*sin(a)*sin(b), v*S(1)/2*cos(a - b) - cos(a + b)) Match = i.match(v*cos(a)*cos(b)) if Match: a = Match[a] b = Match[b] v = Match[v] return i.subs(v*cos(a)*cos(b), v*S(1)/2*cos(a + b) + cos(a - b)) Match = i.match(v*sinh(a)*cosh(b)) if Match: a = Match[a] b = Match[b] v = Match[v] return i.subs(v*sinh(a)*cosh(b), v*S(1)/2*(sinh(a + b) + sinh(a - b))) Match = i.match(v*sinh(a)*sinh(b)) if Match: a = Match[a] b = Match[b] v = Match[v] return i.subs(v*sinh(a)*sinh(b), v*S(1)/2*cosh(a - b) - cosh(a + b)) Match = i.match(v*cosh(a)*cosh(b)) if Match: a = Match[a] b = Match[b] v = Match[v] return i.subs(v*cosh(a)*cosh(b), v*S(1)/2*cosh(a + b) + cosh(a - b)) if PowerQ(i): if i.has(sin, sinh): if (i.rewrite((sin, sinh), sym_exp).expand().rewrite(sym_exp, sin)).has(I, cosh, sinh): return i.rewrite((sin, sinh), sym_exp).expand().rewrite(sym_exp, sin).simplify() else: return i.rewrite((sin, sinh), sym_exp).expand().rewrite(sym_exp, sin) if i.has(cos, cosh): if (i.rewrite((cos, cosh), sym_exp).expand().rewrite(sym_exp, cos)).has(I, cosh, sinh): return i.rewrite((cos, cosh), sym_exp).expand().rewrite(sym_exp, cos).simplify() else: return i.rewrite((cos, cosh), sym_exp).expand().rewrite(sym_exp, cos) return i def FunctionOfTrig(u, *args): # If u is a function of trig functions of v where v is a linear function of x, # FunctionOfTrig[u,x] returns v; else it returns False. if len(args) == 1: x = args[0] v = FunctionOfTrig(u, None, x) if v: return v else: return False else: v, x = args if AtomQ(u): if u == x: return False else: return v if TrigQ(u) and LinearQ(u.args[0], x): if v is None: return u.args[0] else: a = Coefficient(v, x, 0) b = Coefficient(v, x, 1) c = Coefficient(u.args[0], x, 0) d = Coefficient(u.args[0], x, 1) if ZeroQ(a*d - b*c) and RationalQ(b/d): return a/Numerator(b/d) + b*x/Numerator(b/d) else: return False if HyperbolicQ(u) and LinearQ(u.args[0], x): if v is None: return I*u.args[0] a = Coefficient(v, x, 0) b = Coefficient(v, x, 1) c = I*Coefficient(u.args[0], x, 0) d = I*Coefficient(u.args[0], x, 1) if ZeroQ(a*d - b*c) and RationalQ(b/d): return a/Numerator(b/d) + b*x/Numerator(b/d) else: return False if CalculusQ(u): return False else: w = v for i in u.args: w = FunctionOfTrig(i, w, x) if FalseQ(w): return False return w def AlgebraicTrigFunctionQ(u, x): # If u is algebraic function of trig functions, AlgebraicTrigFunctionQ(u,x) returns True; else it returns False. if AtomQ(u): return True elif TrigQ(u) and LinearQ(u.args[0], x): return True elif HyperbolicQ(u) and LinearQ(u.args[0], x): return True elif PowerQ(u): if FreeQ(u.exp, x): return AlgebraicTrigFunctionQ(u.base, x) elif ProductQ(u) or SumQ(u): for i in u.args: if not AlgebraicTrigFunctionQ(i, x): return False return True return False def FunctionOfHyperbolic(u, *x): # If u is a function of hyperbolic trig functions of v where v is linear in x, # FunctionOfHyperbolic(u,x) returns v; else it returns False. if len(x) == 1: x = x[0] v = FunctionOfHyperbolic(u, None, x) if v==None: return False else: return v else: v = x[0] x = x[1] if AtomQ(u): if u == x: return False return v if HyperbolicQ(u) and LinearQ(u.args[0], x): if v is None: return u.args[0] a = Coefficient(v, x, 0) b = Coefficient(v, x, 1) c = Coefficient(u.args[0], x, 0) d = Coefficient(u.args[0], x, 1) if ZeroQ(a*d - b*c) and RationalQ(b/d): return a/Numerator(b/d) + b*x/Numerator(b/d) else: return False if CalculusQ(u): return False w = v for i in u.args: if w == FunctionOfHyperbolic(i, w, x): return False return w def FunctionOfQ(v, u, x, PureFlag=False): # v is a function of x. If u is a function of v, FunctionOfQ(v, u, x) returns True; else it returns False. *) if FreeQ(u, x): return False elif AtomQ(v): return True elif ProductQ(v) and Not(EqQ(FreeFactors(v, x), 1)): return FunctionOfQ(NonfreeFactors(v, x), u, x, PureFlag) elif PureFlag: if SinQ(v) or CscQ(v): return PureFunctionOfSinQ(u, v.args[0], x) elif CosQ(v) or SecQ(v): return PureFunctionOfCosQ(u, v.args[0], x) elif TanQ(v): return PureFunctionOfTanQ(u, v.args[0], x) elif CotQ(v): return PureFunctionOfCotQ(u, v.args[0], x) elif SinhQ(v) or CschQ(v): return PureFunctionOfSinhQ(u, v.args[0], x) elif CoshQ(v) or SechQ(v): return PureFunctionOfCoshQ(u, v.args[0], x) elif TanhQ(v): return PureFunctionOfTanhQ(u, v.args[0], x) elif CothQ(v): return PureFunctionOfCothQ(u, v.args[0], x) else: return FunctionOfExpnQ(u, v, x) != False elif SinQ(v) or CscQ(v): return FunctionOfSinQ(u, v.args[0], x) elif CosQ(v) or SecQ(v): return FunctionOfCosQ(u, v.args[0], x) elif TanQ(v) or CotQ(v): FunctionOfTanQ(u, v.args[0], x) elif SinhQ(v) or CschQ(v): return FunctionOfSinhQ(u, v.args[0], x) elif CoshQ(v) or SechQ(v): return FunctionOfCoshQ(u, v.args[0], x) elif TanhQ(v) or CothQ(v): return FunctionOfTanhQ(u, v.args[0], x) return FunctionOfExpnQ(u, v, x) != False def FunctionOfExpnQ(u, v, x): if u == v: return 1 if AtomQ(u): if u == x: return False else: return 0 if CalculusQ(u): return False if PowerQ(u): if FreeQ(u.exp, x): if ZeroQ(u.base - v): if IntegerQ(u.exp): return u.exp else: return 1 if PowerQ(v): if FreeQ(v.exp, x) and ZeroQ(u.base-v.base): if RationalQ(v.exp): if RationalQ(u.exp) and IntegerQ(u.exp/v.exp) and (v.exp>0 or u.exp<0): return u.exp/v.exp else: return False if IntegerQ(Simplify(u.exp/v.exp)): return Simplify(u.exp/v.exp) else: return False return FunctionOfExpnQ(u.base, v, x) if ProductQ(u) and Not(EqQ(FreeFactors(u, x), 1)): return FunctionOfExpnQ(NonfreeFactors(u, x), v, x) if ProductQ(u) and ProductQ(v): deg1 = FunctionOfExpnQ(First(u), First(v), x) if deg1==False: return False deg2 = FunctionOfExpnQ(Rest(u), Rest(v), x); if deg1==deg2 and FreeQ(Simplify(u/v^deg1), x): return deg1 else: return False lst = [] for i in u.args: if FunctionOfExpnQ(i, v, x) is False: return False lst.append(FunctionOfExpnQ(i, v, x)) return Apply(GCD, lst) def PureFunctionOfSinQ(u, v, x): # If u is a pure function of Sin(v) and/or Csc(v), PureFunctionOfSinQ(u, v, x) returns True; else it returns False. if AtomQ(u): return u!=x if CalculusQ(u): return False if TrigQ(u) and ZeroQ(u.args[0]-v): return SinQ(u) or CscQ(u) for i in u.args: if Not(PureFunctionOfSinQ(i, v, x)): return False return True def PureFunctionOfCosQ(u, v, x): # If u is a pure function of Cos(v) and/or Sec(v), PureFunctionOfCosQ(u, v, x) returns True; else it returns False. if AtomQ(u): return u!=x if CalculusQ(u): return False if TrigQ(u) and ZeroQ(u.args[0]-v): return CosQ(u) or SecQ(u) for i in u.args: if Not(PureFunctionOfCosQ(i, v, x)): return False return True def PureFunctionOfTanQ(u, v, x): # If u is a pure function of Tan(v) and/or Cot(v), PureFunctionOfTanQ(u, v, x) returns True; else it returns False. if AtomQ(u): return u!=x if CalculusQ(u): return False if TrigQ(u) and ZeroQ(u.args[0]-v): return TanQ(u) or CotQ(u) for i in u.args: if Not(PureFunctionOfTanQ(i, v, x)): return False return True def PureFunctionOfCotQ(u, v, x): # If u is a pure function of Cot(v), PureFunctionOfCotQ(u, v, x) returns True; else it returns False. if AtomQ(u): return u!=x if CalculusQ(u): return False if TrigQ(u) and ZeroQ(u.args[0]-v): return CotQ(u) for i in u.args: if Not(PureFunctionOfCotQ(i, v, x)): return False return True def FunctionOfCosQ(u, v, x): # If u is a function of Cos[v], FunctionOfCosQ[u,v,x] returns True; else it returns False. if AtomQ(u): return u != x elif CalculusQ(u): return False elif TrigQ(u) and IntegerQuotientQ(u.args[0], v): # Basis: If m integer, Cos[m*v]^n is a function of Cos[v]. *) return CosQ(u) or SecQ(u) elif IntegerPowerQ(u): if TrigQ(u.base) and IntegerQuotientQ(u.base.args[0], v): if EvenQ(u.exp): # Basis: If m integer and n even, Trig[m*v]^n is a function of Cos[v]. *) return True return FunctionOfCosQ(u.base, v, x) elif ProductQ(u): lst = FindTrigFactor(sin, csc, u, v, False) if ListQ(lst): # (* Basis: If m integer and n odd, Sin[m*v]^n == Sin[v]*u where u is a function of Cos[v]. *) return FunctionOfCosQ(Sin(v)*lst[1], v, x) lst = FindTrigFactor(tan, cot, u, v, True) if ListQ(lst): # (* Basis: If m integer and n odd, Tan[m*v]^n == Sin[v]*u where u is a function of Cos[v]. *) return FunctionOfCosQ(Sin(v)*lst[1], v, x) return all(FunctionOfCosQ(i, v, x) for i in u.args) return all(FunctionOfCosQ(i, v, x) for i in u.args) def FunctionOfSinQ(u, v, x): # If u is a function of Sin[v], FunctionOfSinQ[u,v,x] returns True; else it returns False. if AtomQ(u): return u != x elif CalculusQ(u): return False elif TrigQ(u) and IntegerQuotientQ(u.args[0], v): if OddQuotientQ(u.args[0], v): # Basis: If m odd, Sin[m*v]^n is a function of Sin[v]. return SinQ(u) or CscQ(u) # Basis: If m even, Cos[m*v]^n is a function of Sin[v]. return CosQ(u) or SecQ(u) elif IntegerPowerQ(u): if TrigQ(u.base) and IntegerQuotientQ(u.base.args[0], v): if EvenQ(u.exp): # Basis: If m integer and n even, Hyper[m*v]^n is a function of Sin[v]. return True return FunctionOfSinQ(u.base, v, x) elif ProductQ(u): if CosQ(u.args[0]) and SinQ(u.args[1]) and ZeroQ(u.args[0].args[0] - v/2) and ZeroQ(u.args[1].args[0] - v/2): return FunctionOfSinQ(Drop(u, 2), v, x) lst = FindTrigFactor(sin, csch, u, v, False) if ListQ(lst) and EvenQuotientQ(lst[0], v): # Basis: If m even and n odd, Sin[m*v]^n == Cos[v]*u where u is a function of Sin[v]. return FunctionOfSinQ(Cos(v)*lst[1], v, x) lst = FindTrigFactor(cos, sec, u, v, False) if ListQ(lst) and OddQuotientQ(lst[0], v): # Basis: If m odd and n odd, Cos[m*v]^n == Cos[v]*u where u is a function of Sin[v]. return FunctionOfSinQ(Cos(v)*lst[1], v, x) lst = FindTrigFactor(tan, cot, u, v, True) if ListQ(lst): # Basis: If m integer and n odd, Tan[m*v]^n == Cos[v]*u where u is a function of Sin[v]. return FunctionOfSinQ(Cos(v)*lst[1], v, x) return all(FunctionOfSinQ(i, v, x) for i in u.args) return all(FunctionOfSinQ(i, v, x) for i in u.args) def OddTrigPowerQ(u, v, x): if SinQ(u) or CosQ(u) or SecQ(u) or CscQ(u): return OddQuotientQ(u.args[0], v) if PowerQ(u): return OddQ(u.exp) and OddTrigPowerQ(u.base, v, x) if ProductQ(u): if not FreeFactors(u, x) == 1: return OddTrigPowerQ(NonfreeFactors(u, x), v, x) lst = [] for i in u.args: if Not(FunctionOfTanQ(i, v, x)): lst.append(i) if lst == []: return True return Length(lst)==1 and OddTrigPowerQ(lst[0], v, x) if SumQ(u): return all(OddTrigPowerQ(i, v, x) for i in u.args) return False def FunctionOfTanQ(u, v, x): # If u is a function of the form f[Tan[v],Cot[v]] where f is independent of x, # FunctionOfTanQ[u,v,x] returns True; else it returns False. if AtomQ(u): return u != x elif CalculusQ(u): return False elif TrigQ(u) and IntegerQuotientQ(u.args[0], v): return TanQ(u) or CotQ(u) or EvenQuotientQ(u.args[0], v) elif PowerQ(u): if EvenQ(u.exp) and TrigQ(u.base) and IntegerQuotientQ(u.base.args[0], v): return True elif EvenQ(u.exp) and SumQ(u.base): return FunctionOfTanQ(Expand(u.base**2, v, x)) if ProductQ(u): lst = [] for i in u.args: if Not(FunctionOfTanQ(i, v, x)): lst.append(i) if lst == []: return True return Length(lst)==2 and OddTrigPowerQ(lst[0], v, x) and OddTrigPowerQ(lst[1], v, x) return all(FunctionOfTanQ(i, v, x) for i in u.args) def FunctionOfTanWeight(u, v, x): # (* u is a function of the form f[Tan[v],Cot[v]] where f is independent of x. # FunctionOfTanWeight[u,v,x] returns a nonnegative number if u is best considered a function # of Tan[v]; else it returns a negative number. *) if AtomQ(u): return S(0) elif CalculusQ(u): return S(0) elif TrigQ(u) and IntegerQuotientQ(u.args[0], v): if TanQ(u) and ZeroQ(u.args[0] - v): return S(1) elif CotQ(u) and ZeroQ(u.args[0] - v): return S(-1) return S(0) elif PowerQ(u): if EvenQ(u.exp) and TrigQ(u.base) and IntegerQuotientQ(u.base.args[0], v): if TanQ(u.base) or CosQ(u.base) or SecQ(u.base): return S(1) return S(-1) if ProductQ(u): if all(FunctionOfTanQ(i, v, x) for i in u.args): return Add(*[FunctionOfTanWeight(i, v, x) for i in u.args]) return S(0) return Add(*[FunctionOfTanWeight(i, v, x) for i in u.args]) def FunctionOfTrigQ(u, v, x): # If u (x) is equivalent to a function of the form f (Sin[v],Cos[v],Tan[v],Cot[v],Sec[v],Csc[v]) where f is independent of x, FunctionOfTrigQ[u,v,x] returns True; else it returns False. if AtomQ(u): return u != x elif CalculusQ(u): return False elif TrigQ(u) and IntegerQuotientQ(u.args[0], v): return True return all(FunctionOfTrigQ(i, v, x) for i in u.args) def FunctionOfDensePolynomialsQ(u, x): # If all occurrences of x in u (x) are in dense polynomials, FunctionOfDensePolynomialsQ[u,x] returns True; else it returns False. if FreeQ(u, x): return True if PolynomialQ(u, x): return Length(Exponent(u,x,List))>1 return all(FunctionOfDensePolynomialsQ(i, x) for i in u.args) def FunctionOfLog(u, *args): # If u (x) is equivalent to an expression of the form f (Log[a*x^n]), FunctionOfLog[u,x] returns # the list {f (x),a*x^n,n}; else it returns False. if len(args) == 1: x = args[0] lst = FunctionOfLog(u, False, False, x) if AtomQ(lst) or FalseQ(lst[1]) or not isinstance(x, Symbol): return False else: return lst else: v = args[0] n = args[1] x = args[2] if AtomQ(u): if u==x: return False else: return [u, v, n] if CalculusQ(u): return False lst = BinomialParts(u.args[0], x) if LogQ(u) and ListQ(lst) and ZeroQ(lst[0]): if FalseQ(v) or u.args[0] == v: return [x, u.args[0], lst[2]] else: return False lst = [0, v, n] l = [] for i in u.args: lst = FunctionOfLog(i, lst[1], lst[2], x) if AtomQ(lst): return False else: l.append(lst[0]) return [u.func(*l), lst[1], lst[2]] def PowerVariableExpn(u, m, x): # If m is an integer, u is an expression of the form f((c*x)**n) and g=GCD(m,n)>1, # PowerVariableExpn(u,m,x) returns the list {x**(m/g)*f((c*x)**(n/g)),g,c}; else it returns False. if IntegerQ(m): lst = PowerVariableDegree(u, m, 1, x) if not lst: return False else: return [x**(m/lst[0])*PowerVariableSubst(u, lst[0], x), lst[0], lst[1]] else: return False def PowerVariableDegree(u, m, c, x): if FreeQ(u, x): return [m, c] if AtomQ(u) or CalculusQ(u): return False if PowerQ(u): if FreeQ(u.base/x, x): if ZeroQ(m) or m == u.exp and c == u.base/x: return [u.exp, u.base/x] if IntegerQ(u.exp) and IntegerQ(m) and GCD(m, u.exp)>1 and c==u.base/x: return [GCD(m, u.exp), c] else: return False lst = [m, c] for i in u.args: if PowerVariableDegree(i, lst[0], lst[1], x) == False: return False lst1 = PowerVariableDegree(i, lst[0], lst[1], x) if not lst1: return False else: return lst1 def PowerVariableSubst(u, m, x): if FreeQ(u, x) or AtomQ(u) or CalculusQ(u): return u if PowerQ(u): if FreeQ(u.base/x, x): return x**(u.exp/m) if ProductQ(u): l = 1 for i in u.args: l *= (PowerVariableSubst(i, m, x)) return l if SumQ(u): l = 0 for i in u.args: l += (PowerVariableSubst(i, m, x)) return l return u def EulerIntegrandQ(expr, x): a = Wild('a', exclude=[x]) b = Wild('b', exclude=[x]) n = Wild('n', exclude=[x, 0]) m = Wild('m', exclude=[x, 0]) p = Wild('p', exclude=[x, 0]) u = Wild('u') v = Wild('v') # Pattern 1 M = expr.match((a*x + b*u**n)**p) if M: if len(M) == 5 and FreeQ([M[a], M[b]], x) and IntegerQ(M[n] + 1/2) and QuadraticQ(M[u], x) and Not(RationalQ(M[p])) or NegativeIntegerQ(M[p]) and Not(BinomialQ(M[u], x)): return True # Pattern 2 M = expr.match(v**m*(a*x + b*u**n)**p) if M: if len(M) == 6 and FreeQ([M[a], M[b]], x) and ZeroQ(M[u] - M[v]) and IntegersQ(2*M[m], M[n] + 1/2) and QuadraticQ(M[u], x) and Not(RationalQ(M[p])) or NegativeIntegerQ(M[p]) and Not(BinomialQ(M[u], x)): return True # Pattern 3 M = expr.match(u**n*v**p) if M: if len(M) == 3 and NegativeIntegerQ(M[p]) and IntegerQ(M[n] + 1/2) and QuadraticQ(M[u], x) and QuadraticQ(M[v], x) and Not(BinomialQ(M[v], x)): return True else: return False def FunctionOfSquareRootOfQuadratic(u, *args): if len(args) == 1: x = args[0] pattern = Pattern(UtilityOperator(x_**WC('m', 1)*(a_ + x**WC('n', 1)*WC('b', 1))**p_, x), CustomConstraint(lambda a, b, m, n, p, x: FreeQ([a, b, m, n, p], x))) M = is_match(UtilityOperator(u, args[0]), pattern) if M: return False tmp = FunctionOfSquareRootOfQuadratic(u, False, x) if AtomQ(tmp) or FalseQ(tmp[0]): return False tmp = tmp[0] a = Coefficient(tmp, x, 0) b = Coefficient(tmp, x, 1) c = Coefficient(tmp, x, 2) if ZeroQ(a) and ZeroQ(b) or ZeroQ(b**2-4*a*c): return False if PosQ(c): sqrt = Rt(c, S(2)); q = a*sqrt + b*x + sqrt*x**2 r = b + 2*sqrt*x return [Simplify(SquareRootOfQuadraticSubst(u, q/r, (-a+x**2)/r, x)*q/r**2), Simplify(sqrt*x + Sqrt(tmp)), 2] if PosQ(a): sqrt = Rt(a, S(2)) q = c*sqrt - b*x + sqrt*x**2 r = c - x**2 return [Simplify(SquareRootOfQuadraticSubst(u, q/r, (-b+2*sqrt*x)/r, x)*q/r**2), Simplify((-sqrt+Sqrt(tmp))/x), 1] sqrt = Rt(b**2 - 4*a*c, S(2)) r = c - x**2 return[Simplify(-sqrt*SquareRootOfQuadraticSubst(u, -sqrt*x/r, -(b*c+c*sqrt+(-b+sqrt)*x**2)/(2*c*r), x)*x/r**2), FullSimplify(2*c*Sqrt(tmp)/(b-sqrt+2*c*x)), 3] else: v = args[0] x = args[1] if AtomQ(u) or FreeQ(u, x): return [v] if PowerQ(u): if FreeQ(u.exp, x): if FractionQ(u.exp) and Denominator(u.exp)==2 and PolynomialQ(u.base, x) and Exponent(u.base, x)==2: if FalseQ(v) or u.base == v: return [u.base] else: return False return FunctionOfSquareRootOfQuadratic(u.base, v, x) if ProductQ(u) or SumQ(u): lst = [v] lst1 = [] for i in u.args: if FunctionOfSquareRootOfQuadratic(i, lst[0], x) == False: return False lst1 = FunctionOfSquareRootOfQuadratic(i, lst[0], x) return lst1 else: return False def SquareRootOfQuadraticSubst(u, vv, xx, x): # SquareRootOfQuadraticSubst(u, vv, xx, x) returns u with fractional powers replaced by vv raised to the power and x replaced by xx. if AtomQ(u) or FreeQ(u, x): if u==x: return xx return u if PowerQ(u): if FreeQ(u.exp, x): if FractionQ(u.exp) and Denominator(u.exp)==2 and PolynomialQ(u.base, x) and Exponent(u.base, x)==2: return vv**Numerator(u.exp) return SquareRootOfQuadraticSubst(u.base, vv, xx, x)**u.exp elif SumQ(u): t = 0 for i in u.args: t += SquareRootOfQuadraticSubst(i, vv, xx, x) return t elif ProductQ(u): t = 1 for i in u.args: t *= SquareRootOfQuadraticSubst(i, vv, xx, x) return t def Divides(y, u, x): # If u divided by y is free of x, Divides[y,u,x] returns the quotient; else it returns False. v = Simplify(u/y) if FreeQ(v, x): return v else: return False def DerivativeDivides(y, u, x): ''' If y not equal to x, y is easy to differentiate wrt x, and u divided by the derivative of y is free of x, DerivativeDivides[y,u,x] returns the quotient; else it returns False. ''' from matchpy import is_match pattern0 = Pattern(Mul(a , b_), CustomConstraint(lambda a, b : FreeQ(a, b))) def f1(y, u, x): if PolynomialQ(y, x): return PolynomialQ(u, x) and Exponent(u, x)==Exponent(y, x)-1 else: return EasyDQ(y, x) if is_match(y, pattern0): return False elif f1(y, u, x): v = D(y ,x) if EqQ(v, 0): return False else: v = Simplify(u/v) if FreeQ(v, x): return v else: return False else: return False def EasyDQ(expr, x): # If u is easy to differentiate wrt x, EasyDQ(u, x) returns True; else it returns False *) u = Wild('u',exclude=[1]) m = Wild('m',exclude=[x, 0]) M = expr.match(u*x**m) if M: return EasyDQ(M[u], x) if AtomQ(expr) or FreeQ(expr, x) or Length(expr)==0: return True elif CalculusQ(expr): return False elif Length(expr)==1: return EasyDQ(expr.args[0], x) elif BinomialQ(expr, x) or ProductOfLinearPowersQ(expr, x): return True elif RationalFunctionQ(expr, x) and RationalFunctionExponents(expr, x)==[1, 1]: return True elif ProductQ(expr): if FreeQ(First(expr), x): return EasyDQ(Rest(expr), x) elif FreeQ(Rest(expr), x): return EasyDQ(First(expr), x) else: return False elif SumQ(expr): return EasyDQ(First(expr), x) and EasyDQ(Rest(expr), x) elif Length(expr)==2: if FreeQ(expr.args[0], x): EasyDQ(expr.args[1], x) elif FreeQ(expr.args[1], x): return EasyDQ(expr.args[0], x) else: return False return False def ProductOfLinearPowersQ(u, x): # ProductOfLinearPowersQ(u, x) returns True iff u is a product of factors of the form v^n where v is linear in x v = Wild('v') n = Wild('n', exclude=[x]) M = u.match(v**n) return FreeQ(u, x) or M and LinearQ(M[v], x) or ProductQ(u) and ProductOfLinearPowersQ(First(u), x) and ProductOfLinearPowersQ(Rest(u), x) def Rt(u, n): return RtAux(TogetherSimplify(u), n) def NthRoot(u, n): return nsimplify(u**(S(1)/n)) def AtomBaseQ(u): # If u is an atom or an atom raised to an odd degree, AtomBaseQ(u) returns True; else it returns False return AtomQ(u) or PowerQ(u) and OddQ(u.args[1]) and AtomBaseQ(u.args[0]) def SumBaseQ(u): # If u is a sum or a sum raised to an odd degree, SumBaseQ(u) returns True; else it returns False return SumQ(u) or PowerQ(u) and OddQ(u.args[1]) and SumBaseQ(u.args[0]) def NegSumBaseQ(u): # If u is a sum or a sum raised to an odd degree whose lead term has a negative form, NegSumBaseQ(u) returns True; else it returns False return SumQ(u) and NegQ(First(u)) or PowerQ(u) and OddQ(u.args[1]) and NegSumBaseQ(u.args[0]) def AllNegTermQ(u): # If all terms of u have a negative form, AllNegTermQ(u) returns True; else it returns False if PowerQ(u): if OddQ(u.exp): return AllNegTermQ(u.base) if SumQ(u): return NegQ(First(u)) and AllNegTermQ(Rest(u)) return NegQ(u) def SomeNegTermQ(u): # If some term of u has a negative form, SomeNegTermQ(u) returns True; else it returns False if PowerQ(u): if OddQ(u.exp): return SomeNegTermQ(u.base) if SumQ(u): return NegQ(First(u)) or SomeNegTermQ(Rest(u)) return NegQ(u) def TrigSquareQ(u): # If u is an expression of the form Sin(z)^2 or Cos(z)^2, TrigSquareQ(u) returns True, else it returns False return PowerQ(u) and EqQ(u.args[1], 2) and MemberQ([sin, cos], Head(u.args[0])) def RtAux(u, n): if PowerQ(u): return u.base**(u.exp/n) if ComplexNumberQ(u): a = Re(u) b = Im(u) if Not(IntegerQ(a) and IntegerQ(b)) and IntegerQ(a/(a**2 + b**2)) and IntegerQ(b/(a**2 + b**2)): # Basis: a+b*I==1/(a/(a^2+b^2)-b/(a^2+b^2)*I) return S(1)/RtAux(a/(a**2 + b**2) - b/(a**2 + b**2)*I, n) else: return NthRoot(u, n) if ProductQ(u): lst = SplitProduct(PositiveQ, u) if ListQ(lst): return RtAux(lst[0], n)*RtAux(lst[1], n) lst = SplitProduct(NegativeQ, u) if ListQ(lst): if EqQ(lst[0], -1): v = lst[1] if PowerQ(v): if NegativeQ(v.exp): return 1/RtAux(-v.base**(-v.exp), n) if ProductQ(v): if ListQ(SplitProduct(SumBaseQ, v)): lst = SplitProduct(AllNegTermQ, v) if ListQ(lst): return RtAux(-lst[0], n)*RtAux(lst[1], n) lst = SplitProduct(NegSumBaseQ, v) if ListQ(lst): return RtAux(-lst[0], n)*RtAux(lst[1], n) lst = SplitProduct(SomeNegTermQ, v) if ListQ(lst): return RtAux(-lst[0], n)*RtAux(lst[1], n) lst = SplitProduct(SumBaseQ, v) return RtAux(-lst[0], n)*RtAux(lst[1], n) lst = SplitProduct(AtomBaseQ, v) if ListQ(lst): return RtAux(-lst[0], n)*RtAux(lst[1], n) else: return RtAux(-First(v), n)*RtAux(Rest(v), n) if OddQ(n): return -RtAux(v, n) else: return NthRoot(u, n) else: return RtAux(-lst[0], n)*RtAux(-lst[1], n) lst = SplitProduct(AllNegTermQ, u) if ListQ(lst) and ListQ(SplitProduct(SumBaseQ, lst[1])): return RtAux(-lst[0], n)*RtAux(-lst[1], n) lst = SplitProduct(NegSumBaseQ, u) if ListQ(lst) and ListQ(SplitProduct(NegSumBaseQ, lst[1])): return RtAux(-lst[0], n)*RtAux(-lst[1], n) return u.func(*[RtAux(i, n) for i in u.args]) v = TrigSquare(u) if Not(AtomQ(v)): return RtAux(v, n) if OddQ(n) and NegativeQ(u): return -RtAux(-u, n) if OddQ(n) and NegQ(u) and PosQ(-u): return -RtAux(-u, n) else: return NthRoot(u, n) def TrigSquare(u): # If u is an expression of the form a-a*Sin(z)^2 or a-a*Cos(z)^2, TrigSquare(u) returns Cos(z)^2 or Sin(z)^2 respectively, # else it returns False. if SumQ(u): for i in u.args: v = SplitProduct(TrigSquareQ, i) if v == False or SplitSum(v, u) == False: return False lst = SplitSum(SplitProduct(TrigSquareQ, i)) if lst and ZeroQ(lst[1][2] + lst[1]): if Head(lst[0][0].args[0]) == sin: return lst[1]*cos(lst[1][1][1][1])**2 return lst[1]*sin(lst[1][1][1][1])**2 else: return False else: return False def IntSum(u, x): # If u is free of x or of the form c*(a+b*x)^m, IntSum[u,x] returns the antiderivative of u wrt x; # else it returns d*Int[v,x] where d*v=u and d is free of x. return Add(*[Integral(i, x) for i in u.args]) return Simp(FreeTerms(u, x)*x, x) + IntTerm(NonfreeTerms(u, x), x) def IntTerm(expr, x): # If u is of the form c*(a+b*x)**m, IntTerm(u,x) returns the antiderivative of u wrt x; # else it returns d*Int(v,x) where d*v=u and d is free of x. c = Wild('c', exclude=[x]) m = Wild('m', exclude=[x, 0]) v = Wild('v') M = expr.match(c/v) if M and len(M) == 2 and FreeQ(M[c], x) and LinearQ(M[v], x): return Simp(M[c]*Log(RemoveContent(M[v], x))/Coefficient(M[v], x, 1), x) M = expr.match(c*v**m) if M and len(M) == 3 and NonzeroQ(M[m] + 1) and LinearQ(M[v], x): return Simp(M[c]*M[v]**(M[m] + 1)/(Coefficient(M[v], x, 1)*(M[m] + 1)), x) if SumQ(expr): t = 0 for i in expr.args: t += IntTerm(i, x) return t else: u = expr return Dist(FreeFactors(u,x), Integral(NonfreeFactors(u, x), x), x) def Map2(f, lst1, lst2): result = [] for i in range(0, len(lst1)): result.append(f(lst1[i], lst2[i])) return result def ConstantFactor(u, x): # (* ConstantFactor[u,x] returns a 2-element list of the factors of u[x] free of x and the # factors not free of u[x]. Common constant factors of the terms of sums are also collected. *) if FreeQ(u, x): return [u, S(1)] elif AtomQ(u): return [S(1), u] elif PowerQ(u): if FreeQ(u.exp, x): lst = ConstantFactor(u.base, x) if IntegerQ(u.exp): return [lst[0]**u.exp, lst[1]**u.exp] tmp = PositiveFactors(lst[0]) if tmp == 1: return [S(1), u] return [tmp**u.exp, (NonpositiveFactors(lst[0])*lst[1])**u.exp] elif ProductQ(u): lst = [ConstantFactor(i, x) for i in u.args] return [Mul(*[First(i) for i in lst]), Mul(*[i[1] for i in lst])] elif SumQ(u): lst1 = [ConstantFactor(i, x) for i in u.args] if SameQ(*[i[1] for i in lst1]): return [Add(*[i[0] for i in lst]), lst1[0][1]] lst2 = CommonFactors([First(i) for i in lst1]) return [First(lst2), Add(*Map2(Mul, Rest(lst2), [i[1] for i in lst1]))] return [S(1), u] def SameQ(*args): for i in range(0, len(args) - 1): if args[i] != args[i+1]: return False return True def ReplacePart(lst, a, b): lst[b] = a return lst def CommonFactors(lst): # (* If lst is a list of n terms, CommonFactors[lst] returns a n+1-element list whose first # element is the product of the factors common to all terms of lst, and whose remaining # elements are quotients of each term divided by the common factor. *) lst1 = [NonabsurdNumberFactors(i) for i in lst] lst2 = [AbsurdNumberFactors(i) for i in lst] num = AbsurdNumberGCD(*lst2) common = num lst2 = [i/num for i in lst2] while (True): lst3 = [LeadFactor(i) for i in lst1] if SameQ(*lst3): common = common*lst3[0] lst1 = [RemainingFactors(i) for i in lst1] elif (all((LogQ(i) and IntegerQ(First(i)) and First(i) > 0) for i in lst3) and all(RationalQ(i) for i in [FullSimplify(j/First(lst3)) for j in lst3])): lst4 = [FullSimplify(j/First(lst3)) for j in lst3] num = GCD(*lst4) common = common*Log((First(lst3)[0])**num) lst2 = [lst2[i]*lst4[i]/num for i in range(0, len(lst2))] lst1 = [RemainingFactors(i) for i in lst1] lst4 = [LeadDegree(i) for i in lst1] if SameQ(*[LeadBase(i) for i in lst1]) and RationalQ(*lst4): num = Smallest(lst4) base = LeadBase(lst1[0]) if num != 0: common = common*base**num lst2 = [lst2[i]*base**(lst4[i] - num) for i in range(0, len(lst2))] lst1 = [RemainingFactors(i) for i in lst1] elif (Length(lst1) == 2 and ZeroQ(LeadBase(lst1[0]) + LeadBase(lst1[1])) and NonzeroQ(lst1[0] - 1) and IntegerQ(lst4[0]) and FractionQ(lst4[1])): num = Min(lst4) base = LeadBase(lst1[1]) if num != 0: common = common*base**num lst2 = [lst2[0]*(-1)**lst4[0], lst2[1]] lst2 = [lst2[i]*base**(lst4[i] - num) for i in range(0, len(lst2))] lst1 = [RemainingFactors(i) for i in lst1] elif (Length(lst1) == 2 and ZeroQ(lst1[0] + LeadBase(lst1[1])) and NonzeroQ(lst1[1] - 1) and IntegerQ(lst1[1]) and FractionQ(lst4[0])): num = Min(lst4) base = LeadBase(lst1[0]) if num != 0: common = common*base**num lst2 = [lst2[0], lst2[1]*(-1)**lst4[1]] lst2 = [lst2[i]*base**(lst4[i] - num) for i in range(0, len(lst2))] lst1 = [RemainingFactors(i) for i in lst1] else: num = MostMainFactorPosition(lst3) lst2 = ReplacePart(lst2, lst3[num]*lst2[num], num) lst1 = ReplacePart(lst1, RemainingFactors(lst1[num]), num) if all(i==1 for i in lst1): return Prepend(lst2, common) def MostMainFactorPosition(lst): factor = S(1) num = 0 for i in range(0, Length(lst)): if FactorOrder(lst[i], factor) > 0: factor = lst[i] num = i return num SbaseS, SexponS = None, None SexponFlagS = False def FunctionOfExponentialQ(u, x): # (* FunctionOfExponentialQ[u,x] returns True iff u is a function of F^v where F is a constant and v is linear in x, *) # (* and such an exponential explicitly occurs in u (i.e. not just implicitly in hyperbolic functions). *) global SbaseS, SexponS, SexponFlagS SbaseS, SexponS = None, None SexponFlagS = False res = FunctionOfExponentialTest(u, x) return res and SexponFlagS def FunctionOfExponential(u, x): global SbaseS, SexponS, SexponFlagS # (* u is a function of F^v where v is linear in x. FunctionOfExponential[u,x] returns F^v. *) SbaseS, SexponS = None, None SexponFlagS = False FunctionOfExponentialTest(u, x) return SbaseS**SexponS def FunctionOfExponentialFunction(u, x): global SbaseS, SexponS, SexponFlagS # (* u is a function of F^v where v is linear in x. FunctionOfExponentialFunction[u,x] returns u with F^v replaced by x. *) SbaseS, SexponS = None, None SexponFlagS = False FunctionOfExponentialTest(u, x) return SimplifyIntegrand(FunctionOfExponentialFunctionAux(u, x), x) def FunctionOfExponentialFunctionAux(u, x): # (* u is a function of F^v where v is linear in x, and the fluid variables $base$=F and $expon$=v. *) # (* FunctionOfExponentialFunctionAux[u,x] returns u with F^v replaced by x. *) global SbaseS, SexponS, SexponFlagS if AtomQ(u): return u elif PowerQ(u): if FreeQ(u.base, x) and LinearQ(u.exp, x): if ZeroQ(Coefficient(SexponS, x, 0)): return u.base**Coefficient(u.exp, x, 0)*x**FullSimplify(Log(u.base)*Coefficient(u.exp, x, 1)/(Log(SbaseS)*Coefficient(SexponS, x, 1))) return x**FullSimplify(Log(u.base)*Coefficient(u.exp, x, 1)/(Log(SbaseS)*Coefficient(SexponS, x, 1))) elif HyperbolicQ(u) and LinearQ(u.args[0], x): tmp = x**FullSimplify(Coefficient(u.args[0], x, 1)/(Log(SbaseS)*Coefficient(SexponS, x, 1))) if SinhQ(u): return tmp/2 - 1/(2*tmp) elif CoshQ(u): return tmp/2 + 1/(2*tmp) elif TanhQ(u): return (tmp - 1/tmp)/(tmp + 1/tmp) elif CothQ(u): return (tmp + 1/tmp)/(tmp - 1/tmp) elif SechQ(u): return 2/(tmp + 1/tmp) return 2/(tmp - 1/tmp) if PowerQ(u): if FreeQ(u.base, x) and SumQ(u.exp): return FunctionOfExponentialFunctionAux(u.base**First(u.exp), x)*FunctionOfExponentialFunctionAux(u.base**Rest(u.exp), x) return u.func(*[FunctionOfExponentialFunctionAux(i, x) for i in u.args]) def FunctionOfExponentialTest(u, x): # (* FunctionOfExponentialTest[u,x] returns True iff u is a function of F^v where F is a constant and v is linear in x. *) # (* Before it is called, the fluid variables $base$ and $expon$ should be set to Null and $exponFlag$ to False. *) # (* If u is a function of F^v, $base$ and $expon$ are set to F and v, respectively. *) # (* If an explicit exponential occurs in u, $exponFlag$ is set to True. *) global SbaseS, SexponS, SexponFlagS if FreeQ(u, x): return True elif u == x or CalculusQ(u): return False elif PowerQ(u): if FreeQ(u.base, x) and LinearQ(u.exp, x): SexponFlagS = True return FunctionOfExponentialTestAux(u.base, u.exp, x) elif HyperbolicQ(u) and LinearQ(u.args[0], x): return FunctionOfExponentialTestAux(E, u.args[0], x) if PowerQ(u): if FreeQ(u.base, x) and SumQ(u.exp): return FunctionOfExponentialTest(u.base**First(u.exp), x) and FunctionOfExponentialTest(u.base**Rest(u.exp), x) return all(FunctionOfExponentialTest(i, x) for i in u.args) def FunctionOfExponentialTestAux(base, expon, x): global SbaseS, SexponS, SexponFlagS if SbaseS is None: SbaseS = base SexponS = expon return True tmp = FullSimplify(Log(base)*Coefficient(expon, x, 1)/(Log(SbaseS)*Coefficient(SexponS, x, 1))) if Not(RationalQ(tmp)): return False elif ZeroQ(Coefficient(SexponS, x, 0)) or NonzeroQ(tmp - FullSimplify(Log(base)*Coefficient(expon, x, 0)/(Log(SbaseS)*Coefficient(SexponS, x, 0)))): if PositiveIntegerQ(base, SbaseS) and base<SbaseS: SbaseS = base SexponS = expon tmp = 1/tmp SexponS = Coefficient(SexponS, x, 1)*x/Denominator(tmp) if tmp < 0 and NegQ(Coefficient(SexponS, x, 1)): SexponS = -SexponS return True else: return True if PositiveIntegerQ(base, SbaseS) and base < SbaseS: SbaseS = base SexponS = expon tmp = 1/tmp SexponS = SexponS/Denominator(tmp) if tmp < 0 and NegQ(Coefficient(SexponS, x, 1)): SexponS = -SexponS return True return True def stdev(lst): """Calculates the standard deviation for a list of numbers.""" num_items = len(lst) mean = sum(lst) / num_items differences = [x - mean for x in lst] sq_differences = [d ** 2 for d in differences] ssd = sum(sq_differences) variance = ssd / num_items sd = sqrt(variance) return sd def rubi_test(expr, x, optimal_output, expand=False, _hyper_check=False, _diff=False, _numerical=False): #Returns True if (expr - optimal_output) is equal to 0 or a constant #expr: integrated expression #x: integration variable #expand=True equates `expr` with `optimal_output` in expanded form #_hyper_check=True evaluates numerically #_diff=True differentiates the expressions before equating #_numerical=True equates the expressions at random `x`. Normally used for large expressions. from sympy import nsimplify if not expr.has(csc, sec, cot, csch, sech, coth): optimal_output = process_trig(optimal_output) if expr == optimal_output: return True if simplify(expr) == simplify(optimal_output): return True if nsimplify(expr) == nsimplify(optimal_output): return True if expr.has(sym_exp): expr = powsimp(powdenest(expr), force=True) if simplify(expr) == simplify(powsimp(optimal_output, force=True)): return True res = expr - optimal_output if _numerical: args = res.free_symbols rand_val = [] try: for i in range(0, 5): # check at 5 random points rand_x = randint(1, 40) substitutions = dict((s, rand_x) for s in args) rand_val.append(float(abs(res.subs(substitutions).n()))) if stdev(rand_val) < Pow(10, -3): return True except: pass # return False dres = res.diff(x) if _numerical: args = dres.free_symbols rand_val = [] try: for i in range(0, 5): # check at 5 random points rand_x = randint(1, 40) substitutions = dict((s, rand_x) for s in args) rand_val.append(float(abs(dres.subs(substitutions).n()))) if stdev(rand_val) < Pow(10, -3): return True # return False except: pass # return False r = Simplify(nsimplify(res)) if r == 0 or (not r.has(x)): return True if _diff: if dres == 0: return True elif Simplify(dres) == 0: return True if expand: # expands the expression and equates e = res.expand() if Simplify(e) == 0 or (not e.has(x)): return True return False def If(cond, t, f): # returns t if condition is true else f if cond: return t return f def IntQuadraticQ(a, b, c, d, e, m, p, x): # (* IntQuadraticQ[a,b,c,d,e,m,p,x] returns True iff (d+e*x)^m*(a+b*x+c*x^2)^p is integrable wrt x in terms of non-Appell functions. *) return IntegerQ(p) or PositiveIntegerQ(m) or IntegersQ(2*m, 2*p) or IntegersQ(m, 4*p) or IntegersQ(m, p + S(1)/3) and (ZeroQ(c**2*d**2 - b*c*d*e + b**2*e**2 - 3*a*c*e**2) or ZeroQ(c**2*d**2 - b*c*d*e - 2*b**2*e**2 + 9*a*c*e**2)) def IntBinomialQ(*args): #(* IntBinomialQ(a,b,c,n,m,p,x) returns True iff (c*x)^m*(a+b*x^n)^p is integrable wrt x in terms of non-hypergeometric functions. *) if len(args) == 8: a, b, c, d, n, p, q, x = args return IntegersQ(p,q) or PositiveIntegerQ(p) or PositiveIntegerQ(q) or (ZeroQ(n-2) or ZeroQ(n-4)) and (IntegersQ(p,4*q) or IntegersQ(4*p,q)) or ZeroQ(n-2) and (IntegersQ(2*p,2*q) or IntegersQ(3*p,q) and ZeroQ(b*c+3*a*d) or IntegersQ(p,3*q) and ZeroQ(3*b*c+a*d)) elif len(args) == 7: a, b, c, n, m, p, x = args return IntegerQ(2*p) or IntegerQ((m+1)/n + p) or (ZeroQ(n - 2) or ZeroQ(n - 4)) and IntegersQ(2*m, 4*p) or ZeroQ(n - 2) and IntegerQ(6*p) and (IntegerQ(m) or IntegerQ(m - p)) elif len(args) == 10: a, b, c, d, e, m, n, p, q, x = args return IntegersQ(p,q) or PositiveIntegerQ(p) or PositiveIntegerQ(q) or ZeroQ(n-2) and IntegerQ(m) and IntegersQ(2*p,2*q) or ZeroQ(n-4) and (IntegersQ(m,p,2*q) or IntegersQ(m,2*p,q)) def RectifyTangent(*args): # (* RectifyTangent(u,a,b,r,x) returns an expression whose derivative equals the derivative of r*ArcTan(a+b*Tan(u)) wrt x. *) if len(args) == 5: u, a, b, r, x = args t1 = Together(a) t2 = Together(b) if (PureComplexNumberQ(t1) or (ProductQ(t1) and any(PureComplexNumberQ(i) for i in t1.args))) and (PureComplexNumberQ(t2) or ProductQ(t2) and any(PureComplexNumberQ(i) for i in t2.args)): c = a/I d = b/I if NegativeQ(d): return RectifyTangent(u, -a, -b, -r, x) e = SmartDenominator(Together(c + d*x)) c = c*e d = d*e if EvenQ(Denominator(NumericFactor(Together(u)))): return I*r*Log(RemoveContent(Simplify((c+e)**2+d**2)+Simplify((c+e)**2-d**2)*Cos(2*u)+Simplify(2*(c+e)*d)*Sin(2*u),x))/4 - I*r*Log(RemoveContent(Simplify((c-e)**2+d**2)+Simplify((c-e)**2-d**2)*Cos(2*u)+Simplify(2*(c-e)*d)*Sin(2*u),x))/4 return I*r*Log(RemoveContent(Simplify((c+e)**2)+Simplify(2*(c+e)*d)*Cos(u)*Sin(u)-Simplify((c+e)**2-d**2)*Sin(u)**2,x))/4 - I*r*Log(RemoveContent(Simplify((c-e)**2)+Simplify(2*(c-e)*d)*Cos(u)*Sin(u)-Simplify((c-e)**2-d**2)*Sin(u)**2,x))/4 elif NegativeQ(b): return RectifyTangent(u, -a, -b, -r, x) elif EvenQ(Denominator(NumericFactor(Together(u)))): return r*SimplifyAntiderivative(u,x) + r*ArcTan(Simplify((2*a*b*Cos(2*u)-(1+a**2-b**2)*Sin(2*u))/(a**2+(1+b)**2+(1+a**2-b**2)*Cos(2*u)+2*a*b*Sin(2*u)))) return r*SimplifyAntiderivative(u,x) - r*ArcTan(ActivateTrig(Simplify((a*b-2*a*b*cos(u)**2+(1+a**2-b**2)*cos(u)*sin(u))/(b*(1+b)+(1+a**2-b**2)*cos(u)**2+2*a*b*cos(u)*sin(u))))) u, a, b, x = args t = Together(a) if PureComplexNumberQ(t) or (ProductQ(t) and any(PureComplexNumberQ(i) for i in t.args)): c = a/I if NegativeQ(c): return RectifyTangent(u, -a, -b, x) if ZeroQ(c - 1): if EvenQ(Denominator(NumericFactor(Together(u)))): return I*b*ArcTanh(Sin(2*u))/2 return I*b*ArcTanh(2*cos(u)*sin(u))/2 e = SmartDenominator(c) c = c*e return I*b*Log(RemoveContent(e*Cos(u)+c*Sin(u),x))/2 - I*b*Log(RemoveContent(e*Cos(u)-c*Sin(u),x))/2 elif NegativeQ(a): return RectifyTangent(u, -a, -b, x) elif ZeroQ(a - 1): return b*SimplifyAntiderivative(u, x) elif EvenQ(Denominator(NumericFactor(Together(u)))): c = Simplify((1 + a)/(1 - a)) numr = SmartNumerator(c) denr = SmartDenominator(c) return b*SimplifyAntiderivative(u,x) - b*ArcTan(NormalizeLeadTermSigns(denr*Sin(2*u)/(numr+denr*Cos(2*u)))), elif PositiveQ(a - 1): c = Simplify(1/(a - 1)) numr = SmartNumerator(c) denr = SmartDenominator(c) return b*SimplifyAntiderivative(u,x) + b*ArcTan(NormalizeLeadTermSigns(denr*Cos(u)*Sin(u)/(numr+denr*Sin(u)**2))), c = Simplify(a/(1 - a)) numr = SmartNumerator(c) denr = SmartDenominator(c) return b*SimplifyAntiderivative(u,x) - b*ArcTan(NormalizeLeadTermSigns(denr*Cos(u)*Sin(u)/(numr+denr*Cos(u)**2))) def RectifyCotangent(*args): #(* RectifyCotangent[u,a,b,r,x] returns an expression whose derivative equals the derivative of r*ArcTan[a+b*Cot[u]] wrt x. *) if len(args) == 5: u, a, b, r, x = args t1 = Together(a) t2 = Together(b) if (PureComplexNumberQ(t1) or (ProductQ(t1) and any(PureComplexNumberQ(i) for i in t1.args))) and (PureComplexNumberQ(t2) or ProductQ(t2) and any(PureComplexNumberQ(i) for i in t2.args)): c = a/I d = b/I if NegativeQ(d): return RectifyTangent(u,-a,-b,-r,x) e = SmartDenominator(Together(c + d*x)) c = c*e d = d*e if EvenQ(Denominator(NumericFactor(Together(u)))): return I*r*Log(RemoveContent(Simplify((c+e)**2+d**2)-Simplify((c+e)**2-d**2)*Cos(2*u)+Simplify(2*(c+e)*d)*Sin(2*u),x))/4 - I*r*Log(RemoveContent(Simplify((c-e)**2+d**2)-Simplify((c-e)**2-d**2)*Cos(2*u)+Simplify(2*(c-e)*d)*Sin(2*u),x))/4 return I*r*Log(RemoveContent(Simplify((c+e)**2)-Simplify((c+e)**2-d**2)*Cos(u)**2+Simplify(2*(c+e)*d)*Cos(u)*Sin(u),x))/4 - I*r*Log(RemoveContent(Simplify((c-e)**2)-Simplify((c-e)**2-d**2)*Cos(u)**2+Simplify(2*(c-e)*d)*Cos(u)*Sin(u),x))/4 elif NegativeQ(b): return RectifyCotangent(u,-a,-b,-r,x) elif EvenQ(Denominator(NumericFactor(Together(u)))): return -r*SimplifyAntiderivative(u,x) - r*ArcTan(Simplify((2*a*b*Cos(2*u)+(1+a**2-b**2)*Sin(2*u))/(a**2+(1+b)**2-(1+a**2-b**2)*Cos(2*u)+2*a*b*Sin(2*u)))) return -r*SimplifyAntiderivative(u,x) - r*ArcTan(ActivateTrig(Simplify((a*b-2*a*b*sin(u)**2+(1+a**2-b**2)*cos(u)*sin(u))/(b*(1+b)+(1+a**2-b**2)*sin(u)**2+2*a*b*cos(u)*sin(u))))) u, a, b, x = args t = Together(a) if PureComplexNumberQ(t) or (ProductQ(t) and any(PureComplexNumberQ(i) for i in t.args)): c = a/I if NegativeQ(c): return RectifyCotangent(u,-a,-b,x) elif ZeroQ(c - 1): if EvenQ(Denominator(NumericFactor(Together(u)))): return -I*b*ArcTanh(Sin(2*u))/2 return -I*b*ArcTanh(2*Cos(u)*Sin(u))/2 e = SmartDenominator(c) c = c*e return -I*b*Log(RemoveContent(c*Cos(u)+e*Sin(u),x))/2 + I*b*Log(RemoveContent(c*Cos(u)-e*Sin(u),x))/2 elif NegativeQ(a): return RectifyCotangent(u,-a,-b,x) elif ZeroQ(a-1): return b*SimplifyAntiderivative(u,x) elif EvenQ(Denominator(NumericFactor(Together(u)))): c = Simplify(a - 1) numr = SmartNumerator(c) denr = SmartDenominator(c) return b*SimplifyAntiderivative(u,x) - b*ArcTan(NormalizeLeadTermSigns(denr*Cos(u)*Sin(u)/(numr+denr*Cos(u)**2))) c = Simplify(a/(1-a)) numr = SmartNumerator(c) denr = SmartDenominator(c) return b*SimplifyAntiderivative(u,x) + b*ArcTan(NormalizeLeadTermSigns(denr*Cos(u)*Sin(u)/(numr+denr*Sin(u)**2))) def Inequality(*args): f = args[1::2] e = args[0::2] r = [] for i in range(0, len(f)): r.append(f[i](e[i], e[i + 1])) return all(r) def Condition(r, c): # returns r if c is True if c: return r else: raise NotImplementedError('In Condition()') def Simp(u, x): u = replace_pow_exp(u) return NormalizeSumFactors(SimpHelp(u, x)) def SimpHelp(u, x): if AtomQ(u): return u elif FreeQ(u, x): v = SmartSimplify(u) if LeafCount(v) <= LeafCount(u): return v return u elif ProductQ(u): #m = MatchQ[Rest[u],a_.+n_*Pi+b_.*v_ /; FreeQ[{a,b},x] && Not[FreeQ[v,x]] && EqQ[n^2,1/4]] #if EqQ(First(u), S(1)/2) and m: # if #If[EqQ[First[u],1/2] && MatchQ[Rest[u],a_.+n_*Pi+b_.*v_ /; FreeQ[{a,b},x] && Not[FreeQ[v,x]] && EqQ[n^2,1/4]], # If[MatchQ[Rest[u],n_*Pi+b_.*v_ /; FreeQ[b,x] && Not[FreeQ[v,x]] && EqQ[n^2,1/4]], # Map[Function[1/2*#],Rest[u]], # If[MatchQ[Rest[u],m_*a_.+n_*Pi+p_*b_.*v_ /; FreeQ[{a,b},x] && Not[FreeQ[v,x]] && IntegersQ[m/2,p/2]], # Map[Function[1/2*#],Rest[u]], # u]], v = FreeFactors(u, x) w = NonfreeFactors(u, x) v = NumericFactor(v)*SmartSimplify(NonnumericFactors(v)*x**2)/x**2 if ProductQ(w): w = Mul(*[SimpHelp(i,x) for i in w.args]) else: w = SimpHelp(w, x) w = FactorNumericGcd(w) v = MergeFactors(v, w) if ProductQ(v): return Mul(*[SimpFixFactor(i, x) for i in v.args]) return v elif SumQ(u): Pi = pi a_ = Wild('a', exclude=[x]) b_ = Wild('b', exclude=[x, 0]) n_ = Wild('n', exclude=[x, 0, 0]) pattern = a_ + n_*Pi + b_*x match = u.match(pattern) m = False if match: if EqQ(match[n_]**3, S(1)/16): m = True if m: return u elif PolynomialQ(u, x) and Exponent(u, x)<=0: return SimpHelp(Coefficient(u, x, 0), x) elif PolynomialQ(u, x) and Exponent(u, x) == 1 and Coefficient(u, x, 0) == 0: return SimpHelp(Coefficient(u, x, 1), x)*x v = 0 w = 0 for i in u.args: if FreeQ(i, x): v = i + v else: w = i + w v = SmartSimplify(v) if SumQ(w): w = Add(*[SimpHelp(i, x) for i in w.args]) else: w = SimpHelp(w, x) return v + w return u.func(*[SimpHelp(i, x) for i in u.args]) def SplitProduct(func, u): #(* If func[v] is True for a factor v of u, SplitProduct[func,u] returns {v, u/v} where v is the first such factor; else it returns False. *) if ProductQ(u): if func(First(u)): return [First(u), Rest(u)] lst = SplitProduct(func, Rest(u)) if AtomQ(lst): return False return [lst[0], First(u)*lst[1]] if func(u): return [u, 1] return False def SplitSum(func, u): # (* If func[v] is nonatomic for a term v of u, SplitSum[func,u] returns {func[v], u-v} where v is the first such term; else it returns False. *) if SumQ(u): if Not(AtomQ(func(First(u)))): return [func(First(u)), Rest(u)] lst = SplitSum(func, Rest(u)) if AtomQ(lst): return False return [lst[0], First(u) + lst[1]] elif Not(AtomQ(func(u))): return [func(u), 0] return False def SubstFor(*args): if len(args) == 4: w, v, u, x = args # u is a function of v. SubstFor(w,v,u,x) returns w times u with v replaced by x. return SimplifyIntegrand(w*SubstFor(v, u, x), x) v, u, x = args # u is a function of v. SubstFor(v, u, x) returns u with v replaced by x. if AtomQ(v): return Subst(u, v, x) elif Not(EqQ(FreeFactors(v, x), 1)): return SubstFor(NonfreeFactors(v, x), u, x/FreeFactors(v, x)) elif SinQ(v): return SubstForTrig(u, x, Sqrt(1 - x**2), v.args[0], x) elif CosQ(v): return SubstForTrig(u, Sqrt(1 - x**2), x, v.args[0], x) elif TanQ(v): return SubstForTrig(u, x/Sqrt(1 + x**2), 1/Sqrt(1 + x**2), v.args[0], x) elif CotQ(v): return SubstForTrig(u, 1/Sqrt(1 + x**2), x/Sqrt(1 + x**2), v.args[0], x) elif SecQ(v): return SubstForTrig(u, 1/Sqrt(1 - x**2), 1/x, v.args[0], x) elif CscQ(v): return SubstForTrig(u, 1/x, 1/Sqrt(1 - x**2), v.args[0], x) elif SinhQ(v): return SubstForHyperbolic(u, x, Sqrt(1 + x**2), v.args[0], x) elif CoshQ(v): return SubstForHyperbolic(u, Sqrt( - 1 + x**2), x, v.args[0], x) elif TanhQ(v): return SubstForHyperbolic(u, x/Sqrt(1 - x**2), 1/Sqrt(1 - x**2), v.args[0], x) elif CothQ(v): return SubstForHyperbolic(u, 1/Sqrt( - 1 + x**2), x/Sqrt( - 1 + x**2), v.args[0], x) elif SechQ(v): return SubstForHyperbolic(u, 1/Sqrt( - 1 + x**2), 1/x, v.args[0], x) elif CschQ(v): return SubstForHyperbolic(u, 1/x, 1/Sqrt(1 + x**2), v.args[0], x) else: return SubstForAux(u, v, x) def SubstForAux(u, v, x): # u is a function of v. SubstForAux(u, v, x) returns u with v replaced by x. if u==v: return x elif AtomQ(u): if PowerQ(v): if FreeQ(v.exp, x) and ZeroQ(u - v.base): return x**Simplify(1/v.exp) return u elif PowerQ(u): if FreeQ(u.exp, x): if ZeroQ(u.base - v): return x**u.exp if PowerQ(v): if FreeQ(v.exp, x) and ZeroQ(u.base - v.base): return x**Simplify(u.exp/v.exp) return SubstForAux(u.base, v, x)**u.exp elif ProductQ(u) and Not(EqQ(FreeFactors(u, x), 1)): return FreeFactors(u, x)*SubstForAux(NonfreeFactors(u, x), v, x) elif ProductQ(u) and ProductQ(v): return SubstForAux(First(u), First(v), x) return u.func(*[SubstForAux(i, v, x) for i in u.args]) def FresnelS(x): return fresnels(x) def FresnelC(x): return fresnelc(x) def Erf(x): return erf(x) def Erfc(x): return erfc(x) def Erfi(x): return erfi(x) class Gamma(Function): @classmethod def eval(cls,*args): a = args[0] if len(args) == 1: return gamma(a) else: b = args[1] if (NumericQ(a) and NumericQ(b)) or a == 1: return uppergamma(a, b) def FunctionOfTrigOfLinearQ(u, x): # If u is an algebraic function of trig functions of a linear function of x, # FunctionOfTrigOfLinearQ[u,x] returns True; else it returns False. if FunctionOfTrig(u, None, x) and AlgebraicTrigFunctionQ(u, x) and FunctionOfLinear(FunctionOfTrig(u, None, x), x): return True else: return False def ElementaryFunctionQ(u): # ElementaryExpressionQ[u] returns True if u is a sum, product, or power and all the operands # are elementary expressions; or if u is a call on a trig, hyperbolic, or inverse function # and all the arguments are elementary expressions; else it returns False. if AtomQ(u): return True elif SumQ(u) or ProductQ(u) or PowerQ(u) or TrigQ(u) or HyperbolicQ(u) or InverseFunctionQ(u): for i in u.args: if not ElementaryFunctionQ(i): return False return True return False def Complex(a, b): return a + I*b def UnsameQ(a, b): return a != b @doctest_depends_on(modules=('matchpy',)) def _SimpFixFactor(): replacer = ManyToOneReplacer() pattern1 = Pattern(UtilityOperator(Pow(Add(Mul(Complex(S(0), c_), WC('a', S(1))), Mul(Complex(S(0), d_), WC('b', S(1)))), WC('p', S(1))), x_), CustomConstraint(lambda p: IntegerQ(p))) rule1 = ReplacementRule(pattern1, lambda b, c, x, a, p, d : Mul(Pow(I, p), SimpFixFactor(Pow(Add(Mul(a, c), Mul(b, d)), p), x))) replacer.add(rule1) pattern2 = Pattern(UtilityOperator(Pow(Add(Mul(Complex(S(0), d_), WC('a', S(1))), Mul(Complex(S(0), e_), WC('b', S(1))), Mul(Complex(S(0), f_), WC('c', S(1)))), WC('p', S(1))), x_), CustomConstraint(lambda p: IntegerQ(p))) rule2 = ReplacementRule(pattern2, lambda b, c, x, f, a, p, e, d : Mul(Pow(I, p), SimpFixFactor(Pow(Add(Mul(a, d), Mul(b, e), Mul(c, f)), p), x))) replacer.add(rule2) pattern3 = Pattern(UtilityOperator(Pow(Add(Mul(WC('a', S(1)), Pow(c_, r_)), Mul(WC('b', S(1)), Pow(x_, WC('n', S(1))))), WC('p', S(1))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda n, p: IntegersQ(n, p)), CustomConstraint(lambda c: AtomQ(c)), CustomConstraint(lambda r: RationalQ(r)), CustomConstraint(lambda r: Less(r, S(0)))) rule3 = ReplacementRule(pattern3, lambda b, c, r, n, x, a, p : Mul(Pow(c, Mul(r, p)), SimpFixFactor(Pow(Add(a, Mul(Mul(b, Pow(Pow(c, r), S(-1))), Pow(x, n))), p), x))) replacer.add(rule3) pattern4 = Pattern(UtilityOperator(Pow(Add(WC('a', S(0)), Mul(WC('b', S(1)), Pow(c_, r_), Pow(x_, WC('n', S(1))))), WC('p', S(1))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda n, p: IntegersQ(n, p)), CustomConstraint(lambda c: AtomQ(c)), CustomConstraint(lambda r: RationalQ(r)), CustomConstraint(lambda r: Less(r, S(0)))) rule4 = ReplacementRule(pattern4, lambda b, c, r, n, x, a, p : Mul(Pow(c, Mul(r, p)), SimpFixFactor(Pow(Add(Mul(a, Pow(Pow(c, r), S(-1))), Mul(b, Pow(x, n))), p), x))) replacer.add(rule4) pattern5 = Pattern(UtilityOperator(Pow(Add(Mul(WC('a', S(1)), Pow(c_, WC('s', S(1)))), Mul(WC('b', S(1)), Pow(c_, WC('r', S(1))), Pow(x_, WC('n', S(1))))), WC('p', S(1))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda n, p: IntegersQ(n, p)), CustomConstraint(lambda r, s: RationalQ(s, r)), CustomConstraint(lambda r, s: Inequality(S(0), Less, s, LessEqual, r)), CustomConstraint(lambda p, c, s: UnsameQ(Pow(c, Mul(s, p)), S(-1)))) rule5 = ReplacementRule(pattern5, lambda b, c, r, n, x, a, p, s : Mul(Pow(c, Mul(s, p)), SimpFixFactor(Pow(Add(a, Mul(b, Pow(c, Add(r, Mul(S(-1), s))), Pow(x, n))), p), x))) replacer.add(rule5) pattern6 = Pattern(UtilityOperator(Pow(Add(Mul(WC('a', S(1)), Pow(c_, WC('s', S(1)))), Mul(WC('b', S(1)), Pow(c_, WC('r', S(1))), Pow(x_, WC('n', S(1))))), WC('p', S(1))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda n, p: IntegersQ(n, p)), CustomConstraint(lambda r, s: RationalQ(s, r)), CustomConstraint(lambda s, r: Less(S(0), r, s)), CustomConstraint(lambda p, c, r: UnsameQ(Pow(c, Mul(r, p)), S(-1)))) rule6 = ReplacementRule(pattern6, lambda b, c, r, n, x, a, p, s : Mul(Pow(c, Mul(r, p)), SimpFixFactor(Pow(Add(Mul(a, Pow(c, Add(s, Mul(S(-1), r)))), Mul(b, Pow(x, n))), p), x))) replacer.add(rule6) return replacer @doctest_depends_on(modules=('matchpy',)) def SimpFixFactor(expr, x): r = SimpFixFactor_replacer.replace(UtilityOperator(expr, x)) if isinstance(r, UtilityOperator): return expr return r @doctest_depends_on(modules=('matchpy',)) def _FixSimplify(): Plus = Add def cons_f1(n): return OddQ(n) cons1 = CustomConstraint(cons_f1) def cons_f2(m): return RationalQ(m) cons2 = CustomConstraint(cons_f2) def cons_f3(n): return FractionQ(n) cons3 = CustomConstraint(cons_f3) def cons_f4(u): return SqrtNumberSumQ(u) cons4 = CustomConstraint(cons_f4) def cons_f5(v): return SqrtNumberSumQ(v) cons5 = CustomConstraint(cons_f5) def cons_f6(u): return PositiveQ(u) cons6 = CustomConstraint(cons_f6) def cons_f7(v): return PositiveQ(v) cons7 = CustomConstraint(cons_f7) def cons_f8(v): return SqrtNumberSumQ(S(1)/v) cons8 = CustomConstraint(cons_f8) def cons_f9(m): return IntegerQ(m) cons9 = CustomConstraint(cons_f9) def cons_f10(u): return NegativeQ(u) cons10 = CustomConstraint(cons_f10) def cons_f11(n, m, a, b): return RationalQ(a, b, m, n) cons11 = CustomConstraint(cons_f11) def cons_f12(a): return Greater(a, S(0)) cons12 = CustomConstraint(cons_f12) def cons_f13(b): return Greater(b, S(0)) cons13 = CustomConstraint(cons_f13) def cons_f14(p): return PositiveIntegerQ(p) cons14 = CustomConstraint(cons_f14) def cons_f15(p): return IntegerQ(p) cons15 = CustomConstraint(cons_f15) def cons_f16(p, n): return Greater(-n + p, S(0)) cons16 = CustomConstraint(cons_f16) def cons_f17(a, b): return SameQ(a + b, S(0)) cons17 = CustomConstraint(cons_f17) def cons_f18(n): return Not(IntegerQ(n)) cons18 = CustomConstraint(cons_f18) def cons_f19(c, a, b, d): return ZeroQ(-a*d + b*c) cons19 = CustomConstraint(cons_f19) def cons_f20(a): return Not(RationalQ(a)) cons20 = CustomConstraint(cons_f20) def cons_f21(t): return IntegerQ(t) cons21 = CustomConstraint(cons_f21) def cons_f22(n, m): return RationalQ(m, n) cons22 = CustomConstraint(cons_f22) def cons_f23(n, m): return Inequality(S(0), Less, m, LessEqual, n) cons23 = CustomConstraint(cons_f23) def cons_f24(p, n, m): return RationalQ(m, n, p) cons24 = CustomConstraint(cons_f24) def cons_f25(p, n, m): return Inequality(S(0), Less, m, LessEqual, n, LessEqual, p) cons25 = CustomConstraint(cons_f25) def cons_f26(p, n, m, q): return Inequality(S(0), Less, m, LessEqual, n, LessEqual, p, LessEqual, q) cons26 = CustomConstraint(cons_f26) def cons_f27(w): return Not(RationalQ(w)) cons27 = CustomConstraint(cons_f27) def cons_f28(n): return Less(n, S(0)) cons28 = CustomConstraint(cons_f28) def cons_f29(n, w, v): return ZeroQ(v + w**(-n)) cons29 = CustomConstraint(cons_f29) def cons_f30(n): return IntegerQ(n) cons30 = CustomConstraint(cons_f30) def cons_f31(w, v): return ZeroQ(v + w) cons31 = CustomConstraint(cons_f31) def cons_f32(p, n): return IntegerQ(n/p) cons32 = CustomConstraint(cons_f32) def cons_f33(w, v): return ZeroQ(v - w) cons33 = CustomConstraint(cons_f33) def cons_f34(p, n): return IntegersQ(n, n/p) cons34 = CustomConstraint(cons_f34) def cons_f35(a): return AtomQ(a) cons35 = CustomConstraint(cons_f35) def cons_f36(b): return AtomQ(b) cons36 = CustomConstraint(cons_f36) pattern1 = Pattern(UtilityOperator((w_ + Complex(S(0), b_)*WC('v', S(1)))**WC('n', S(1))*Complex(S(0), a_)*WC('u', S(1))), cons1) def replacement1(n, u, w, v, a, b): return (S(-1))**(n/S(2) + S(1)/2)*a*u*FixSimplify((b*v - w*Complex(S(0), S(1)))**n) rule1 = ReplacementRule(pattern1, replacement1) def With2(m, n, u, w, v): z = u**(m/GCD(m, n))*v**(n/GCD(m, n)) if Or(AbsurdNumberQ(z), SqrtNumberSumQ(z)): return True return False pattern2 = Pattern(UtilityOperator(u_**WC('m', S(1))*v_**n_*WC('w', S(1))), cons2, cons3, cons4, cons5, cons6, cons7, CustomConstraint(With2)) def replacement2(m, n, u, w, v): z = u**(m/GCD(m, n))*v**(n/GCD(m, n)) return FixSimplify(w*z**GCD(m, n)) rule2 = ReplacementRule(pattern2, replacement2) def With3(m, n, u, w, v): z = u**(m/GCD(m, -n))*v**(n/GCD(m, -n)) if Or(AbsurdNumberQ(z), SqrtNumberSumQ(z)): return True return False pattern3 = Pattern(UtilityOperator(u_**WC('m', S(1))*v_**n_*WC('w', S(1))), cons2, cons3, cons4, cons8, cons6, cons7, CustomConstraint(With3)) def replacement3(m, n, u, w, v): z = u**(m/GCD(m, -n))*v**(n/GCD(m, -n)) return FixSimplify(w*z**GCD(m, -n)) rule3 = ReplacementRule(pattern3, replacement3) def With4(m, n, u, w, v): z = v**(n/GCD(m, n))*(-u)**(m/GCD(m, n)) if Or(AbsurdNumberQ(z), SqrtNumberSumQ(z)): return True return False pattern4 = Pattern(UtilityOperator(u_**WC('m', S(1))*v_**n_*WC('w', S(1))), cons9, cons3, cons4, cons5, cons10, cons7, CustomConstraint(With4)) def replacement4(m, n, u, w, v): z = v**(n/GCD(m, n))*(-u)**(m/GCD(m, n)) return FixSimplify(-w*z**GCD(m, n)) rule4 = ReplacementRule(pattern4, replacement4) def With5(m, n, u, w, v): z = v**(n/GCD(m, -n))*(-u)**(m/GCD(m, -n)) if Or(AbsurdNumberQ(z), SqrtNumberSumQ(z)): return True return False pattern5 = Pattern(UtilityOperator(u_**WC('m', S(1))*v_**n_*WC('w', S(1))), cons9, cons3, cons4, cons8, cons10, cons7, CustomConstraint(With5)) def replacement5(m, n, u, w, v): z = v**(n/GCD(m, -n))*(-u)**(m/GCD(m, -n)) return FixSimplify(-w*z**GCD(m, -n)) rule5 = ReplacementRule(pattern5, replacement5) def With6(p, m, n, u, w, v, a, b): c = a**(m/p)*b**n if RationalQ(c): return True return False pattern6 = Pattern(UtilityOperator(a_**m_*(b_**n_*WC('v', S(1)) + u_)**WC('p', S(1))*WC('w', S(1))), cons11, cons12, cons13, cons14, CustomConstraint(With6)) def replacement6(p, m, n, u, w, v, a, b): c = a**(m/p)*b**n return FixSimplify(w*(a**(m/p)*u + c*v)**p) rule6 = ReplacementRule(pattern6, replacement6) pattern7 = Pattern(UtilityOperator(a_**WC('m', S(1))*(a_**n_*WC('u', S(1)) + b_**WC('p', S(1))*WC('v', S(1)))*WC('w', S(1))), cons2, cons3, cons15, cons16, cons17) def replacement7(p, m, n, u, w, v, a, b): return FixSimplify(a**(m + n)*w*((S(-1))**p*a**(-n + p)*v + u)) rule7 = ReplacementRule(pattern7, replacement7) def With8(m, d, n, w, c, a, b): q = b/d if FreeQ(q, Plus): return True return False pattern8 = Pattern(UtilityOperator((a_ + b_)**WC('m', S(1))*(c_ + d_)**n_*WC('w', S(1))), cons9, cons18, cons19, CustomConstraint(With8)) def replacement8(m, d, n, w, c, a, b): q = b/d return FixSimplify(q**m*w*(c + d)**(m + n)) rule8 = ReplacementRule(pattern8, replacement8) pattern9 = Pattern(UtilityOperator((a_**WC('m', S(1))*WC('u', S(1)) + a_**WC('n', S(1))*WC('v', S(1)))**WC('t', S(1))*WC('w', S(1))), cons20, cons21, cons22, cons23) def replacement9(m, n, u, w, v, a, t): return FixSimplify(a**(m*t)*w*(a**(-m + n)*v + u)**t) rule9 = ReplacementRule(pattern9, replacement9) pattern10 = Pattern(UtilityOperator((a_**WC('m', S(1))*WC('u', S(1)) + a_**WC('n', S(1))*WC('v', S(1)) + a_**WC('p', S(1))*WC('z', S(1)))**WC('t', S(1))*WC('w', S(1))), cons20, cons21, cons24, cons25) def replacement10(p, m, n, u, w, v, a, z, t): return FixSimplify(a**(m*t)*w*(a**(-m + n)*v + a**(-m + p)*z + u)**t) rule10 = ReplacementRule(pattern10, replacement10) pattern11 = Pattern(UtilityOperator((a_**WC('m', S(1))*WC('u', S(1)) + a_**WC('n', S(1))*WC('v', S(1)) + a_**WC('p', S(1))*WC('z', S(1)) + a_**WC('q', S(1))*WC('y', S(1)))**WC('t', S(1))*WC('w', S(1))), cons20, cons21, cons24, cons26) def replacement11(p, m, n, u, q, w, v, a, z, y, t): return FixSimplify(a**(m*t)*w*(a**(-m + n)*v + a**(-m + p)*z + a**(-m + q)*y + u)**t) rule11 = ReplacementRule(pattern11, replacement11) pattern12 = Pattern(UtilityOperator((sqrt(v_)*WC('b', S(1)) + sqrt(v_)*WC('c', S(1)) + sqrt(v_)*WC('d', S(1)) + sqrt(v_)*WC('a', S(1)) + WC('u', S(0)))*WC('w', S(1)))) def replacement12(d, u, w, v, c, a, b): return FixSimplify(w*(u + sqrt(v)*FixSimplify(a + b + c + d))) rule12 = ReplacementRule(pattern12, replacement12) pattern13 = Pattern(UtilityOperator((sqrt(v_)*WC('b', S(1)) + sqrt(v_)*WC('c', S(1)) + sqrt(v_)*WC('a', S(1)) + WC('u', S(0)))*WC('w', S(1)))) def replacement13(u, w, v, c, a, b): return FixSimplify(w*(u + sqrt(v)*FixSimplify(a + b + c))) rule13 = ReplacementRule(pattern13, replacement13) pattern14 = Pattern(UtilityOperator((sqrt(v_)*WC('b', S(1)) + sqrt(v_)*WC('a', S(1)) + WC('u', S(0)))*WC('w', S(1)))) def replacement14(u, w, v, a, b): return FixSimplify(w*(u + sqrt(v)*FixSimplify(a + b))) rule14 = ReplacementRule(pattern14, replacement14) pattern15 = Pattern(UtilityOperator(v_**m_*w_**n_*WC('u', S(1))), cons2, cons27, cons3, cons28, cons29) def replacement15(m, n, u, w, v): return -FixSimplify(u*v**(m + S(-1))) rule15 = ReplacementRule(pattern15, replacement15) pattern16 = Pattern(UtilityOperator(v_**m_*w_**WC('n', S(1))*WC('u', S(1))), cons2, cons27, cons30, cons31) def replacement16(m, n, u, w, v): return (S(-1))**n*FixSimplify(u*v**(m + n)) rule16 = ReplacementRule(pattern16, replacement16) pattern17 = Pattern(UtilityOperator(w_**WC('n', S(1))*(-v_**WC('p', S(1)))**m_*WC('u', S(1))), cons2, cons27, cons32, cons33) def replacement17(p, m, n, u, w, v): return (S(-1))**(n/p)*FixSimplify(u*(-v**p)**(m + n/p)) rule17 = ReplacementRule(pattern17, replacement17) pattern18 = Pattern(UtilityOperator(w_**WC('n', S(1))*(-v_**WC('p', S(1)))**m_*WC('u', S(1))), cons2, cons27, cons34, cons31) def replacement18(p, m, n, u, w, v): return (S(-1))**(n + n/p)*FixSimplify(u*(-v**p)**(m + n/p)) rule18 = ReplacementRule(pattern18, replacement18) pattern19 = Pattern(UtilityOperator((a_ - b_)**WC('m', S(1))*(a_ + b_)**WC('m', S(1))*WC('u', S(1))), cons9, cons35, cons36) def replacement19(m, u, a, b): return u*(a**S(2) - b**S(2))**m rule19 = ReplacementRule(pattern19, replacement19) pattern20 = Pattern(UtilityOperator((S(729)*c - e*(-S(20)*e + S(540)))**WC('m', S(1))*WC('u', S(1))), cons2) def replacement20(m, u): return u*(a*e**S(2) - b*d*e + c*d**S(2))**m rule20 = ReplacementRule(pattern20, replacement20) pattern21 = Pattern(UtilityOperator((S(729)*c + e*(S(20)*e + S(-540)))**WC('m', S(1))*WC('u', S(1))), cons2) def replacement21(m, u): return u*(a*e**S(2) - b*d*e + c*d**S(2))**m rule21 = ReplacementRule(pattern21, replacement21) pattern22 = Pattern(UtilityOperator(u_)) def replacement22(u): return u rule22 = ReplacementRule(pattern22, replacement22) return [rule1, rule2, rule3, rule4, rule5, rule6, rule7, rule8, rule9, rule10, rule11, rule12, rule13, rule14, rule15, rule16, rule17, rule18, rule19, rule20, rule21, rule22, ] @doctest_depends_on(modules=('matchpy',)) def FixSimplify(expr): if isinstance(expr, (list, tuple, TupleArg)): return [replace_all(UtilityOperator(i), FixSimplify_rules) for i in expr] return replace_all(UtilityOperator(expr), FixSimplify_rules) @doctest_depends_on(modules=('matchpy',)) def _SimplifyAntiderivativeSum(): replacer = ManyToOneReplacer() pattern1 = Pattern(UtilityOperator(Add(Mul(Log(Add(a_, Mul(WC('b', S(1)), Pow(Tan(u_), WC('n', S(1)))))), WC('A', S(1))), Mul(Log(Cos(u_)), WC('B', S(1))), WC('v', S(0))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda A, x: FreeQ(A, x)), CustomConstraint(lambda B, x: FreeQ(B, x)), CustomConstraint(lambda n: IntegerQ(n)), CustomConstraint(lambda B, A, n: ZeroQ(Add(Mul(n, A), Mul(S(1), B))))) rule1 = ReplacementRule(pattern1, lambda n, x, v, b, B, A, u, a : Add(SimplifyAntiderivativeSum(v, x), Mul(A, Log(RemoveContent(Add(Mul(a, Pow(Cos(u), n)), Mul(b, Pow(Sin(u), n))), x))))) replacer.add(rule1) pattern2 = Pattern(UtilityOperator(Add(Mul(Log(Add(Mul(Pow(Cot(u_), WC('n', S(1))), WC('b', S(1))), a_)), WC('A', S(1))), Mul(Log(Sin(u_)), WC('B', S(1))), WC('v', S(0))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda A, x: FreeQ(A, x)), CustomConstraint(lambda B, x: FreeQ(B, x)), CustomConstraint(lambda n: IntegerQ(n)), CustomConstraint(lambda B, A, n: ZeroQ(Add(Mul(n, A), Mul(S(1), B))))) rule2 = ReplacementRule(pattern2, lambda n, x, v, b, B, A, a, u : Add(SimplifyAntiderivativeSum(v, x), Mul(A, Log(RemoveContent(Add(Mul(a, Pow(Sin(u), n)), Mul(b, Pow(Cos(u), n))), x))))) replacer.add(rule2) pattern3 = Pattern(UtilityOperator(Add(Mul(Log(Add(a_, Mul(WC('b', S(1)), Pow(Tan(u_), WC('n', S(1)))))), WC('A', S(1))), Mul(Log(Add(c_, Mul(WC('d', S(1)), Pow(Tan(u_), WC('n', S(1)))))), WC('B', S(1))), WC('v', S(0))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda A, x: FreeQ(A, x)), CustomConstraint(lambda B, x: FreeQ(B, x)), CustomConstraint(lambda n: IntegerQ(n)), CustomConstraint(lambda B, A: ZeroQ(Add(A, B)))) rule3 = ReplacementRule(pattern3, lambda n, x, v, b, A, B, u, c, d, a : Add(SimplifyAntiderivativeSum(v, x), Mul(A, Log(RemoveContent(Add(Mul(a, Pow(Cos(u), n)), Mul(b, Pow(Sin(u), n))), x))), Mul(B, Log(RemoveContent(Add(Mul(c, Pow(Cos(u), n)), Mul(d, Pow(Sin(u), n))), x))))) replacer.add(rule3) pattern4 = Pattern(UtilityOperator(Add(Mul(Log(Add(Mul(Pow(Cot(u_), WC('n', S(1))), WC('b', S(1))), a_)), WC('A', S(1))), Mul(Log(Add(Mul(Pow(Cot(u_), WC('n', S(1))), WC('d', S(1))), c_)), WC('B', S(1))), WC('v', S(0))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda A, x: FreeQ(A, x)), CustomConstraint(lambda B, x: FreeQ(B, x)), CustomConstraint(lambda n: IntegerQ(n)), CustomConstraint(lambda B, A: ZeroQ(Add(A, B)))) rule4 = ReplacementRule(pattern4, lambda n, x, v, b, A, B, c, a, d, u : Add(SimplifyAntiderivativeSum(v, x), Mul(A, Log(RemoveContent(Add(Mul(b, Pow(Cos(u), n)), Mul(a, Pow(Sin(u), n))), x))), Mul(B, Log(RemoveContent(Add(Mul(d, Pow(Cos(u), n)), Mul(c, Pow(Sin(u), n))), x))))) replacer.add(rule4) pattern5 = Pattern(UtilityOperator(Add(Mul(Log(Add(a_, Mul(WC('b', S(1)), Pow(Tan(u_), WC('n', S(1)))))), WC('A', S(1))), Mul(Log(Add(c_, Mul(WC('d', S(1)), Pow(Tan(u_), WC('n', S(1)))))), WC('B', S(1))), Mul(Log(Add(e_, Mul(WC('f', S(1)), Pow(Tan(u_), WC('n', S(1)))))), WC('C', S(1))), WC('v', S(0))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda f, x: FreeQ(f, x)), CustomConstraint(lambda A, x: FreeQ(A, x)), CustomConstraint(lambda B, x: FreeQ(B, x)), CustomConstraint(lambda C, x: FreeQ(C, x)), CustomConstraint(lambda n: IntegerQ(n)), CustomConstraint(lambda B, A, C: ZeroQ(Add(A, B, C)))) rule5 = ReplacementRule(pattern5, lambda n, e, x, v, b, A, B, u, c, f, d, a, C : Add(SimplifyAntiderivativeSum(v, x), Mul(A, Log(RemoveContent(Add(Mul(a, Pow(Cos(u), n)), Mul(b, Pow(Sin(u), n))), x))), Mul(B, Log(RemoveContent(Add(Mul(c, Pow(Cos(u), n)), Mul(d, Pow(Sin(u), n))), x))), Mul(C, Log(RemoveContent(Add(Mul(e, Pow(Cos(u), n)), Mul(f, Pow(Sin(u), n))), x))))) replacer.add(rule5) pattern6 = Pattern(UtilityOperator(Add(Mul(Log(Add(Mul(Pow(Cot(u_), WC('n', S(1))), WC('b', S(1))), a_)), WC('A', S(1))), Mul(Log(Add(Mul(Pow(Cot(u_), WC('n', S(1))), WC('d', S(1))), c_)), WC('B', S(1))), Mul(Log(Add(Mul(Pow(Cot(u_), WC('n', S(1))), WC('f', S(1))), e_)), WC('C', S(1))), WC('v', S(0))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda f, x: FreeQ(f, x)), CustomConstraint(lambda A, x: FreeQ(A, x)), CustomConstraint(lambda B, x: FreeQ(B, x)), CustomConstraint(lambda C, x: FreeQ(C, x)), CustomConstraint(lambda n: IntegerQ(n)), CustomConstraint(lambda B, A, C: ZeroQ(Add(A, B, C)))) rule6 = ReplacementRule(pattern6, lambda n, e, x, v, b, A, B, c, a, f, d, u, C : Add(SimplifyAntiderivativeSum(v, x), Mul(A, Log(RemoveContent(Add(Mul(b, Pow(Cos(u), n)), Mul(a, Pow(Sin(u), n))), x))), Mul(B, Log(RemoveContent(Add(Mul(d, Pow(Cos(u), n)), Mul(c, Pow(Sin(u), n))), x))), Mul(C, Log(RemoveContent(Add(Mul(f, Pow(Cos(u), n)), Mul(e, Pow(Sin(u), n))), x))))) replacer.add(rule6) return replacer @doctest_depends_on(modules=('matchpy',)) def SimplifyAntiderivativeSum(expr, x): r = SimplifyAntiderivativeSum_replacer.replace(UtilityOperator(expr, x)) if isinstance(r, UtilityOperator): return expr return r @doctest_depends_on(modules=('matchpy',)) def _SimplifyAntiderivative(): replacer = ManyToOneReplacer() pattern2 = Pattern(UtilityOperator(Log(Mul(c_, u_)), x_), CustomConstraint(lambda c, x: FreeQ(c, x))) rule2 = ReplacementRule(pattern2, lambda x, c, u : SimplifyAntiderivative(Log(u), x)) replacer.add(rule2) pattern3 = Pattern(UtilityOperator(Log(Pow(u_, n_)), x_), CustomConstraint(lambda n, x: FreeQ(n, x))) rule3 = ReplacementRule(pattern3, lambda x, n, u : Mul(n, SimplifyAntiderivative(Log(u), x))) replacer.add(rule3) pattern7 = Pattern(UtilityOperator(Log(Pow(f_, u_)), x_), CustomConstraint(lambda f, x: FreeQ(f, x))) rule7 = ReplacementRule(pattern7, lambda x, f, u : Mul(Log(f), SimplifyAntiderivative(u, x))) replacer.add(rule7) pattern8 = Pattern(UtilityOperator(Log(Add(a_, Mul(WC('b', S(1)), Tan(u_)))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda b, a: ZeroQ(Add(Pow(a, S(2)), Pow(b, S(2)))))) rule8 = ReplacementRule(pattern8, lambda x, b, u, a : Add(Mul(Mul(b, Pow(a, S(1))), SimplifyAntiderivative(u, x)), Mul(S(1), SimplifyAntiderivative(Log(Cos(u)), x)))) replacer.add(rule8) pattern9 = Pattern(UtilityOperator(Log(Add(Mul(Cot(u_), WC('b', S(1))), a_)), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda b, a: ZeroQ(Add(Pow(a, S(2)), Pow(b, S(2)))))) rule9 = ReplacementRule(pattern9, lambda x, b, u, a : Add(Mul(Mul(Mul(S(1), b), Pow(a, S(1))), SimplifyAntiderivative(u, x)), Mul(S(1), SimplifyAntiderivative(Log(Sin(u)), x)))) replacer.add(rule9) pattern10 = Pattern(UtilityOperator(ArcTan(Mul(WC('a', S(1)), Tan(u_))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda a: PositiveQ(Pow(a, S(2)))), CustomConstraint(lambda u: ComplexFreeQ(u))) rule10 = ReplacementRule(pattern10, lambda x, u, a : RectifyTangent(u, a, S(1), x)) replacer.add(rule10) pattern11 = Pattern(UtilityOperator(ArcCot(Mul(WC('a', S(1)), Tan(u_))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda a: PositiveQ(Pow(a, S(2)))), CustomConstraint(lambda u: ComplexFreeQ(u))) rule11 = ReplacementRule(pattern11, lambda x, u, a : RectifyTangent(u, a, S(1), x)) replacer.add(rule11) pattern12 = Pattern(UtilityOperator(ArcCot(Mul(WC('a', S(1)), Tanh(u_))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda u: ComplexFreeQ(u))) rule12 = ReplacementRule(pattern12, lambda x, u, a : Mul(S(1), SimplifyAntiderivative(ArcTan(Mul(a, Tanh(u))), x))) replacer.add(rule12) pattern13 = Pattern(UtilityOperator(ArcTanh(Mul(WC('a', S(1)), Tan(u_))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda a: PositiveQ(Pow(a, S(2)))), CustomConstraint(lambda u: ComplexFreeQ(u))) rule13 = ReplacementRule(pattern13, lambda x, u, a : RectifyTangent(u, Mul(I, a), Mul(S(1), I), x)) replacer.add(rule13) pattern14 = Pattern(UtilityOperator(ArcCoth(Mul(WC('a', S(1)), Tan(u_))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda a: PositiveQ(Pow(a, S(2)))), CustomConstraint(lambda u: ComplexFreeQ(u))) rule14 = ReplacementRule(pattern14, lambda x, u, a : RectifyTangent(u, Mul(I, a), Mul(S(1), I), x)) replacer.add(rule14) pattern15 = Pattern(UtilityOperator(ArcTanh(Tanh(u_)), x_)) rule15 = ReplacementRule(pattern15, lambda x, u : SimplifyAntiderivative(u, x)) replacer.add(rule15) pattern16 = Pattern(UtilityOperator(ArcCoth(Tanh(u_)), x_)) rule16 = ReplacementRule(pattern16, lambda x, u : SimplifyAntiderivative(u, x)) replacer.add(rule16) pattern17 = Pattern(UtilityOperator(ArcCot(Mul(Cot(u_), WC('a', S(1)))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda a: PositiveQ(Pow(a, S(2)))), CustomConstraint(lambda u: ComplexFreeQ(u))) rule17 = ReplacementRule(pattern17, lambda x, u, a : RectifyCotangent(u, a, S(1), x)) replacer.add(rule17) pattern18 = Pattern(UtilityOperator(ArcTan(Mul(Cot(u_), WC('a', S(1)))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda a: PositiveQ(Pow(a, S(2)))), CustomConstraint(lambda u: ComplexFreeQ(u))) rule18 = ReplacementRule(pattern18, lambda x, u, a : RectifyCotangent(u, a, S(1), x)) replacer.add(rule18) pattern19 = Pattern(UtilityOperator(ArcTan(Mul(Coth(u_), WC('a', S(1)))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda u: ComplexFreeQ(u))) rule19 = ReplacementRule(pattern19, lambda x, u, a : Mul(S(1), SimplifyAntiderivative(ArcTan(Mul(Tanh(u), Pow(a, S(1)))), x))) replacer.add(rule19) pattern20 = Pattern(UtilityOperator(ArcCoth(Mul(Cot(u_), WC('a', S(1)))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda a: PositiveQ(Pow(a, S(2)))), CustomConstraint(lambda u: ComplexFreeQ(u))) rule20 = ReplacementRule(pattern20, lambda x, u, a : RectifyCotangent(u, Mul(I, a), I, x)) replacer.add(rule20) pattern21 = Pattern(UtilityOperator(ArcTanh(Mul(Cot(u_), WC('a', S(1)))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda a: PositiveQ(Pow(a, S(2)))), CustomConstraint(lambda u: ComplexFreeQ(u))) rule21 = ReplacementRule(pattern21, lambda x, u, a : RectifyCotangent(u, Mul(I, a), I, x)) replacer.add(rule21) pattern22 = Pattern(UtilityOperator(ArcCoth(Coth(u_)), x_)) rule22 = ReplacementRule(pattern22, lambda x, u : SimplifyAntiderivative(u, x)) replacer.add(rule22) pattern23 = Pattern(UtilityOperator(ArcTanh(Mul(Coth(u_), WC('a', S(1)))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda u: ComplexFreeQ(u))) rule23 = ReplacementRule(pattern23, lambda x, u, a : SimplifyAntiderivative(ArcTanh(Mul(Tanh(u), Pow(a, S(1)))), x)) replacer.add(rule23) pattern24 = Pattern(UtilityOperator(ArcTanh(Coth(u_)), x_)) rule24 = ReplacementRule(pattern24, lambda x, u : SimplifyAntiderivative(u, x)) replacer.add(rule24) pattern25 = Pattern(UtilityOperator(ArcTan(Mul(WC('c', S(1)), Add(a_, Mul(WC('b', S(1)), Tan(u_))))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda c, a: PositiveQ(Mul(Pow(a, S(2)), Pow(c, S(2))))), CustomConstraint(lambda c, b: PositiveQ(Mul(Pow(b, S(2)), Pow(c, S(2))))), CustomConstraint(lambda u: ComplexFreeQ(u))) rule25 = ReplacementRule(pattern25, lambda x, a, b, u, c : RectifyTangent(u, Mul(a, c), Mul(b, c), S(1), x)) replacer.add(rule25) pattern26 = Pattern(UtilityOperator(ArcTanh(Mul(WC('c', S(1)), Add(a_, Mul(WC('b', S(1)), Tan(u_))))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda c, a: PositiveQ(Mul(Pow(a, S(2)), Pow(c, S(2))))), CustomConstraint(lambda c, b: PositiveQ(Mul(Pow(b, S(2)), Pow(c, S(2))))), CustomConstraint(lambda u: ComplexFreeQ(u))) rule26 = ReplacementRule(pattern26, lambda x, a, b, u, c : RectifyTangent(u, Mul(I, a, c), Mul(I, b, c), Mul(S(1), I), x)) replacer.add(rule26) pattern27 = Pattern(UtilityOperator(ArcTan(Mul(WC('c', S(1)), Add(Mul(Cot(u_), WC('b', S(1))), a_))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda c, a: PositiveQ(Mul(Pow(a, S(2)), Pow(c, S(2))))), CustomConstraint(lambda c, b: PositiveQ(Mul(Pow(b, S(2)), Pow(c, S(2))))), CustomConstraint(lambda u: ComplexFreeQ(u))) rule27 = ReplacementRule(pattern27, lambda x, a, b, u, c : RectifyCotangent(u, Mul(a, c), Mul(b, c), S(1), x)) replacer.add(rule27) pattern28 = Pattern(UtilityOperator(ArcTanh(Mul(WC('c', S(1)), Add(Mul(Cot(u_), WC('b', S(1))), a_))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda c, a: PositiveQ(Mul(Pow(a, S(2)), Pow(c, S(2))))), CustomConstraint(lambda c, b: PositiveQ(Mul(Pow(b, S(2)), Pow(c, S(2))))), CustomConstraint(lambda u: ComplexFreeQ(u))) rule28 = ReplacementRule(pattern28, lambda x, a, b, u, c : RectifyCotangent(u, Mul(I, a, c), Mul(I, b, c), Mul(S(1), I), x)) replacer.add(rule28) pattern29 = Pattern(UtilityOperator(ArcTan(Add(WC('a', S(0)), Mul(WC('b', S(1)), Tan(u_)), Mul(WC('c', S(1)), Pow(Tan(u_), S(2))))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda u: ComplexFreeQ(u))) rule29 = ReplacementRule(pattern29, lambda x, a, b, u, c : If(EvenQ(Denominator(NumericFactor(Together(u)))), ArcTan(NormalizeTogether(Mul(Add(a, c, S(1), Mul(Add(a, Mul(S(1), c), S(1)), Cos(Mul(S(2), u))), Mul(b, Sin(Mul(S(2), u)))), Pow(Add(a, c, S(1), Mul(Add(a, Mul(S(1), c), S(1)), Cos(Mul(S(2), u))), Mul(b, Sin(Mul(S(2), u)))), S(1))))), ArcTan(NormalizeTogether(Mul(Add(c, Mul(Add(a, Mul(S(1), c), S(1)), Pow(Cos(u), S(2))), Mul(b, Cos(u), Sin(u))), Pow(Add(c, Mul(Add(a, Mul(S(1), c), S(1)), Pow(Cos(u), S(2))), Mul(b, Cos(u), Sin(u))), S(1))))))) replacer.add(rule29) pattern30 = Pattern(UtilityOperator(ArcTan(Add(WC('a', S(0)), Mul(WC('b', S(1)), Add(WC('d', S(0)), Mul(WC('e', S(1)), Tan(u_)))), Mul(WC('c', S(1)), Pow(Add(WC('f', S(0)), Mul(WC('g', S(1)), Tan(u_))), S(2))))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda u: ComplexFreeQ(u))) rule30 = ReplacementRule(pattern30, lambda x, d, a, e, f, b, u, c, g : SimplifyAntiderivative(ArcTan(Add(a, Mul(b, d), Mul(c, Pow(f, S(2))), Mul(Add(Mul(b, e), Mul(S(2), c, f, g)), Tan(u)), Mul(c, Pow(g, S(2)), Pow(Tan(u), S(2))))), x)) replacer.add(rule30) pattern31 = Pattern(UtilityOperator(ArcTan(Add(WC('a', S(0)), Mul(WC('c', S(1)), Pow(Tan(u_), S(2))))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda u: ComplexFreeQ(u))) rule31 = ReplacementRule(pattern31, lambda x, c, u, a : If(EvenQ(Denominator(NumericFactor(Together(u)))), ArcTan(NormalizeTogether(Mul(Add(a, c, S(1), Mul(Add(a, Mul(S(1), c), S(1)), Cos(Mul(S(2), u)))), Pow(Add(a, c, S(1), Mul(Add(a, Mul(S(1), c), S(1)), Cos(Mul(S(2), u)))), S(1))))), ArcTan(NormalizeTogether(Mul(Add(c, Mul(Add(a, Mul(S(1), c), S(1)), Pow(Cos(u), S(2)))), Pow(Add(c, Mul(Add(a, Mul(S(1), c), S(1)), Pow(Cos(u), S(2)))), S(1))))))) replacer.add(rule31) pattern32 = Pattern(UtilityOperator(ArcTan(Add(WC('a', S(0)), Mul(WC('c', S(1)), Pow(Add(WC('f', S(0)), Mul(WC('g', S(1)), Tan(u_))), S(2))))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda u: ComplexFreeQ(u))) rule32 = ReplacementRule(pattern32, lambda x, a, f, u, c, g : SimplifyAntiderivative(ArcTan(Add(a, Mul(c, Pow(f, S(2))), Mul(Mul(S(2), c, f, g), Tan(u)), Mul(c, Pow(g, S(2)), Pow(Tan(u), S(2))))), x)) replacer.add(rule32) return replacer @doctest_depends_on(modules=('matchpy',)) def SimplifyAntiderivative(expr, x): r = SimplifyAntiderivative_replacer.replace(UtilityOperator(expr, x)) if isinstance(r, UtilityOperator): if ProductQ(expr): u, c = S(1), S(1) for i in expr.args: if FreeQ(i, x): c *= i else: u *= i if FreeQ(c, x) and c != S(1): v = SimplifyAntiderivative(u, x) if SumQ(v) and NonsumQ(u): return Add(*[c*i for i in v.args]) return c*v elif LogQ(expr): F = expr.args[0] if MemberQ([cot, sec, csc, coth, sech, csch], Head(F)): return -SimplifyAntiderivative(Log(1/F), x) if MemberQ([Log, atan, acot], Head(expr)): F = Head(expr) G = expr.args[0] if MemberQ([cot, sec, csc, coth, sech, csch], Head(G)): return -SimplifyAntiderivative(F(1/G), x) if MemberQ([atanh, acoth], Head(expr)): F = Head(expr) G = expr.args[0] if MemberQ([cot, sec, csc, coth, sech, csch], Head(G)): return SimplifyAntiderivative(F(1/G), x) u = expr if FreeQ(u, x): return S(0) elif LogQ(u): return Log(RemoveContent(u.args[0], x)) elif SumQ(u): return SimplifyAntiderivativeSum(Add(*[SimplifyAntiderivative(i, x) for i in u.args]), x) return u else: return r @doctest_depends_on(modules=('matchpy',)) def _TrigSimplifyAux(): replacer = ManyToOneReplacer() pattern1 = Pattern(UtilityOperator(Mul(WC('u', S(1)), Pow(Add(Mul(WC('a', S(1)), Pow(v_, WC('m', S(1)))), Mul(WC('b', S(1)), Pow(v_, WC('n', S(1))))), p_))), CustomConstraint(lambda v: InertTrigQ(v)), CustomConstraint(lambda p: IntegerQ(p)), CustomConstraint(lambda n, m: RationalQ(m, n)), CustomConstraint(lambda n, m: Less(m, n))) rule1 = ReplacementRule(pattern1, lambda n, a, p, m, u, v, b : Mul(u, Pow(v, Mul(m, p)), Pow(TrigSimplifyAux(Add(a, Mul(b, Pow(v, Add(n, Mul(S(-1), m)))))), p))) replacer.add(rule1) pattern2 = Pattern(UtilityOperator(Add(Mul(Pow(cos(u_), S('2')), WC('a', S(1))), WC('v', S(0)), Mul(WC('b', S(1)), Pow(sin(u_), S('2'))))), CustomConstraint(lambda b, a: SameQ(a, b))) rule2 = ReplacementRule(pattern2, lambda u, v, b, a : Add(a, v)) replacer.add(rule2) pattern3 = Pattern(UtilityOperator(Add(WC('v', S(0)), Mul(WC('a', S(1)), Pow(sec(u_), S('2'))), Mul(WC('b', S(1)), Pow(tan(u_), S('2'))))), CustomConstraint(lambda b, a: SameQ(a, Mul(S(-1), b)))) rule3 = ReplacementRule(pattern3, lambda u, v, b, a : Add(a, v)) replacer.add(rule3) pattern4 = Pattern(UtilityOperator(Add(Mul(Pow(csc(u_), S('2')), WC('a', S(1))), Mul(Pow(cot(u_), S('2')), WC('b', S(1))), WC('v', S(0)))), CustomConstraint(lambda b, a: SameQ(a, Mul(S(-1), b)))) rule4 = ReplacementRule(pattern4, lambda u, v, b, a : Add(a, v)) replacer.add(rule4) pattern5 = Pattern(UtilityOperator(Pow(Add(Mul(Pow(cos(u_), S('2')), WC('a', S(1))), WC('v', S(0)), Mul(WC('b', S(1)), Pow(sin(u_), S('2')))), n_))) rule5 = ReplacementRule(pattern5, lambda n, a, u, v, b : Pow(Add(Mul(Add(b, Mul(S(-1), a)), Pow(Sin(u), S('2'))), a, v), n)) replacer.add(rule5) pattern6 = Pattern(UtilityOperator(Add(WC('w', S(0)), u_, Mul(WC('v', S(1)), Pow(sin(z_), S('2'))))), CustomConstraint(lambda u, v: SameQ(u, Mul(S(-1), v)))) rule6 = ReplacementRule(pattern6, lambda u, w, z, v : Add(Mul(u, Pow(Cos(z), S('2'))), w)) replacer.add(rule6) pattern7 = Pattern(UtilityOperator(Add(Mul(Pow(cos(z_), S('2')), WC('v', S(1))), WC('w', S(0)), u_)), CustomConstraint(lambda u, v: SameQ(u, Mul(S(-1), v)))) rule7 = ReplacementRule(pattern7, lambda z, w, v, u : Add(Mul(u, Pow(Sin(z), S('2'))), w)) replacer.add(rule7) pattern8 = Pattern(UtilityOperator(Add(WC('w', S(0)), u_, Mul(WC('v', S(1)), Pow(tan(z_), S('2'))))), CustomConstraint(lambda u, v: SameQ(u, v))) rule8 = ReplacementRule(pattern8, lambda u, w, z, v : Add(Mul(u, Pow(Sec(z), S('2'))), w)) replacer.add(rule8) pattern9 = Pattern(UtilityOperator(Add(Mul(Pow(cot(z_), S('2')), WC('v', S(1))), WC('w', S(0)), u_)), CustomConstraint(lambda u, v: SameQ(u, v))) rule9 = ReplacementRule(pattern9, lambda z, w, v, u : Add(Mul(u, Pow(Csc(z), S('2'))), w)) replacer.add(rule9) pattern10 = Pattern(UtilityOperator(Add(WC('w', S(0)), u_, Mul(WC('v', S(1)), Pow(sec(z_), S('2'))))), CustomConstraint(lambda u, v: SameQ(u, Mul(S(-1), v)))) rule10 = ReplacementRule(pattern10, lambda u, w, z, v : Add(Mul(v, Pow(Tan(z), S('2'))), w)) replacer.add(rule10) pattern11 = Pattern(UtilityOperator(Add(Mul(Pow(csc(z_), S('2')), WC('v', S(1))), WC('w', S(0)), u_)), CustomConstraint(lambda u, v: SameQ(u, Mul(S(-1), v)))) rule11 = ReplacementRule(pattern11, lambda z, w, v, u : Add(Mul(v, Pow(Cot(z), S('2'))), w)) replacer.add(rule11) pattern12 = Pattern(UtilityOperator(Mul(WC('u', S(1)), Pow(Add(Mul(cos(v_), WC('b', S(1))), a_), S(-1)), Pow(sin(v_), S('2')))), CustomConstraint(lambda b, a: ZeroQ(Add(Pow(a, S('2')), Mul(S(-1), Pow(b, S('2'))))))) rule12 = ReplacementRule(pattern12, lambda u, v, b, a : Mul(u, Add(Mul(S(1), Pow(a, S(-1))), Mul(S(-1), Mul(Cos(v), Pow(b, S(-1))))))) replacer.add(rule12) pattern13 = Pattern(UtilityOperator(Mul(Pow(cos(v_), S('2')), WC('u', S(1)), Pow(Add(a_, Mul(WC('b', S(1)), sin(v_))), S(-1)))), CustomConstraint(lambda b, a: ZeroQ(Add(Pow(a, S('2')), Mul(S(-1), Pow(b, S('2'))))))) rule13 = ReplacementRule(pattern13, lambda u, v, b, a : Mul(u, Add(Mul(S(1), Pow(a, S(-1))), Mul(S(-1), Mul(Sin(v), Pow(b, S(-1))))))) replacer.add(rule13) pattern14 = Pattern(UtilityOperator(Mul(WC('u', S(1)), Pow(tan(v_), WC('n', S(1))), Pow(Add(a_, Mul(WC('b', S(1)), Pow(tan(v_), WC('n', S(1))))), S(-1)))), CustomConstraint(lambda n: PositiveIntegerQ(n)), CustomConstraint(lambda a: NonsumQ(a))) rule14 = ReplacementRule(pattern14, lambda n, a, u, v, b : Mul(u, Pow(Add(b, Mul(a, Pow(Cot(v), n))), S(-1)))) replacer.add(rule14) pattern15 = Pattern(UtilityOperator(Mul(Pow(cot(v_), WC('n', S(1))), WC('u', S(1)), Pow(Add(Mul(Pow(cot(v_), WC('n', S(1))), WC('b', S(1))), a_), S(-1)))), CustomConstraint(lambda n: PositiveIntegerQ(n)), CustomConstraint(lambda a: NonsumQ(a))) rule15 = ReplacementRule(pattern15, lambda n, a, u, v, b : Mul(u, Pow(Add(b, Mul(a, Pow(Tan(v), n))), S(-1)))) replacer.add(rule15) pattern16 = Pattern(UtilityOperator(Mul(WC('u', S(1)), Pow(sec(v_), WC('n', S(1))), Pow(Add(a_, Mul(WC('b', S(1)), Pow(sec(v_), WC('n', S(1))))), S(-1)))), CustomConstraint(lambda n: PositiveIntegerQ(n)), CustomConstraint(lambda a: NonsumQ(a))) rule16 = ReplacementRule(pattern16, lambda n, a, u, v, b : Mul(u, Pow(Add(b, Mul(a, Pow(Cos(v), n))), S(-1)))) replacer.add(rule16) pattern17 = Pattern(UtilityOperator(Mul(Pow(csc(v_), WC('n', S(1))), WC('u', S(1)), Pow(Add(Mul(Pow(csc(v_), WC('n', S(1))), WC('b', S(1))), a_), S(-1)))), CustomConstraint(lambda n: PositiveIntegerQ(n)), CustomConstraint(lambda a: NonsumQ(a))) rule17 = ReplacementRule(pattern17, lambda n, a, u, v, b : Mul(u, Pow(Add(b, Mul(a, Pow(Sin(v), n))), S(-1)))) replacer.add(rule17) pattern18 = Pattern(UtilityOperator(Mul(WC('u', S(1)), Pow(Add(a_, Mul(WC('b', S(1)), Pow(sec(v_), WC('n', S(1))))), S(-1)), Pow(tan(v_), WC('n', S(1))))), CustomConstraint(lambda n: PositiveIntegerQ(n)), CustomConstraint(lambda a: NonsumQ(a))) rule18 = ReplacementRule(pattern18, lambda n, a, u, v, b : Mul(u, Mul(Pow(Sin(v), n), Pow(Add(b, Mul(a, Pow(Cos(v), n))), S(-1))))) replacer.add(rule18) pattern19 = Pattern(UtilityOperator(Mul(Pow(cot(v_), WC('n', S(1))), WC('u', S(1)), Pow(Add(Mul(Pow(csc(v_), WC('n', S(1))), WC('b', S(1))), a_), S(-1)))), CustomConstraint(lambda n: PositiveIntegerQ(n)), CustomConstraint(lambda a: NonsumQ(a))) rule19 = ReplacementRule(pattern19, lambda n, a, u, v, b : Mul(u, Mul(Pow(Cos(v), n), Pow(Add(b, Mul(a, Pow(Sin(v), n))), S(-1))))) replacer.add(rule19) pattern20 = Pattern(UtilityOperator(Mul(WC('u', S(1)), Pow(Add(Mul(WC('a', S(1)), Pow(sec(v_), WC('n', S(1)))), Mul(WC('b', S(1)), Pow(tan(v_), WC('n', S(1))))), WC('p', S(1))))), CustomConstraint(lambda n, p: IntegersQ(n, p))) rule20 = ReplacementRule(pattern20, lambda n, a, p, u, v, b : Mul(u, Pow(Sec(v), Mul(n, p)), Pow(Add(a, Mul(b, Pow(Sin(v), n))), p))) replacer.add(rule20) pattern21 = Pattern(UtilityOperator(Mul(Pow(Add(Mul(Pow(csc(v_), WC('n', S(1))), WC('a', S(1))), Mul(Pow(cot(v_), WC('n', S(1))), WC('b', S(1)))), WC('p', S(1))), WC('u', S(1)))), CustomConstraint(lambda n, p: IntegersQ(n, p))) rule21 = ReplacementRule(pattern21, lambda n, a, p, u, v, b : Mul(u, Pow(Csc(v), Mul(n, p)), Pow(Add(a, Mul(b, Pow(Cos(v), n))), p))) replacer.add(rule21) pattern22 = Pattern(UtilityOperator(Mul(WC('u', S(1)), Pow(Add(Mul(WC('b', S(1)), Pow(sin(v_), WC('n', S(1)))), Mul(WC('a', S(1)), Pow(tan(v_), WC('n', S(1))))), WC('p', S(1))))), CustomConstraint(lambda n, p: IntegersQ(n, p))) rule22 = ReplacementRule(pattern22, lambda n, a, p, u, v, b : Mul(u, Pow(Tan(v), Mul(n, p)), Pow(Add(a, Mul(b, Pow(Cos(v), n))), p))) replacer.add(rule22) pattern23 = Pattern(UtilityOperator(Mul(Pow(Add(Mul(Pow(cot(v_), WC('n', S(1))), WC('a', S(1))), Mul(Pow(cos(v_), WC('n', S(1))), WC('b', S(1)))), WC('p', S(1))), WC('u', S(1)))), CustomConstraint(lambda n, p: IntegersQ(n, p))) rule23 = ReplacementRule(pattern23, lambda n, a, p, u, v, b : Mul(u, Pow(Cot(v), Mul(n, p)), Pow(Add(a, Mul(b, Pow(Sin(v), n))), p))) replacer.add(rule23) pattern24 = Pattern(UtilityOperator(Mul(Pow(cos(v_), WC('m', S(1))), WC('u', S(1)), Pow(Add(WC('a', S(0)), Mul(WC('c', S(1)), Pow(sec(v_), WC('n', S(1)))), Mul(WC('b', S(1)), Pow(tan(v_), WC('n', S(1))))), WC('p', S(1))))), CustomConstraint(lambda n, p, m: IntegersQ(m, n, p))) rule24 = ReplacementRule(pattern24, lambda n, a, c, p, m, u, v, b : Mul(u, Pow(Cos(v), Add(m, Mul(S(-1), Mul(n, p)))), Pow(Add(c, Mul(b, Pow(Sin(v), n)), Mul(a, Pow(Cos(v), n))), p))) replacer.add(rule24) pattern25 = Pattern(UtilityOperator(Mul(WC('u', S(1)), Pow(sec(v_), WC('m', S(1))), Pow(Add(WC('a', S(0)), Mul(WC('c', S(1)), Pow(sec(v_), WC('n', S(1)))), Mul(WC('b', S(1)), Pow(tan(v_), WC('n', S(1))))), WC('p', S(1))))), CustomConstraint(lambda n, p, m: IntegersQ(m, n, p))) rule25 = ReplacementRule(pattern25, lambda n, a, c, p, m, u, v, b : Mul(u, Pow(Sec(v), Add(m, Mul(n, p))), Pow(Add(c, Mul(b, Pow(Sin(v), n)), Mul(a, Pow(Cos(v), n))), p))) replacer.add(rule25) pattern26 = Pattern(UtilityOperator(Mul(Pow(Add(WC('a', S(0)), Mul(Pow(cot(v_), WC('n', S(1))), WC('b', S(1))), Mul(Pow(csc(v_), WC('n', S(1))), WC('c', S(1)))), WC('p', S(1))), WC('u', S(1)), Pow(sin(v_), WC('m', S(1))))), CustomConstraint(lambda n, p, m: IntegersQ(m, n, p))) rule26 = ReplacementRule(pattern26, lambda n, a, c, p, m, u, v, b : Mul(u, Pow(Sin(v), Add(m, Mul(S(-1), Mul(n, p)))), Pow(Add(c, Mul(b, Pow(Cos(v), n)), Mul(a, Pow(Sin(v), n))), p))) replacer.add(rule26) pattern27 = Pattern(UtilityOperator(Mul(Pow(csc(v_), WC('m', S(1))), Pow(Add(WC('a', S(0)), Mul(Pow(cot(v_), WC('n', S(1))), WC('b', S(1))), Mul(Pow(csc(v_), WC('n', S(1))), WC('c', S(1)))), WC('p', S(1))), WC('u', S(1)))), CustomConstraint(lambda n, p, m: IntegersQ(m, n, p))) rule27 = ReplacementRule(pattern27, lambda n, a, c, p, m, u, v, b : Mul(u, Pow(Csc(v), Add(m, Mul(n, p))), Pow(Add(c, Mul(b, Pow(Cos(v), n)), Mul(a, Pow(Sin(v), n))), p))) replacer.add(rule27) pattern28 = Pattern(UtilityOperator(Mul(WC('u', S(1)), Pow(Add(Mul(Pow(csc(v_), WC('m', S(1))), WC('a', S(1))), Mul(WC('b', S(1)), Pow(sin(v_), WC('n', S(1))))), WC('p', S(1))))), CustomConstraint(lambda n, m: IntegersQ(m, n))) rule28 = ReplacementRule(pattern28, lambda n, a, p, m, u, v, b : If(And(ZeroQ(Add(m, n, S(-2))), ZeroQ(Add(a, b))), Mul(u, Pow(Mul(a, Mul(Pow(Cos(v), S('2')), Pow(Pow(Sin(v), m), S(-1)))), p)), Mul(u, Pow(Mul(Add(a, Mul(b, Pow(Sin(v), Add(m, n)))), Pow(Pow(Sin(v), m), S(-1))), p)))) replacer.add(rule28) pattern29 = Pattern(UtilityOperator(Mul(WC('u', S(1)), Pow(Add(Mul(Pow(cos(v_), WC('n', S(1))), WC('b', S(1))), Mul(WC('a', S(1)), Pow(sec(v_), WC('m', S(1))))), WC('p', S(1))))), CustomConstraint(lambda n, m: IntegersQ(m, n))) rule29 = ReplacementRule(pattern29, lambda n, a, p, m, u, v, b : If(And(ZeroQ(Add(m, n, S(-2))), ZeroQ(Add(a, b))), Mul(u, Pow(Mul(a, Mul(Pow(Sin(v), S('2')), Pow(Pow(Cos(v), m), S(-1)))), p)), Mul(u, Pow(Mul(Add(a, Mul(b, Pow(Cos(v), Add(m, n)))), Pow(Pow(Cos(v), m), S(-1))), p)))) replacer.add(rule29) pattern30 = Pattern(UtilityOperator(u_)) rule30 = ReplacementRule(pattern30, lambda u : u) replacer.add(rule30) return replacer @doctest_depends_on(modules=('matchpy',)) def TrigSimplifyAux(expr): return TrigSimplifyAux_replacer.replace(UtilityOperator(expr)) def Cancel(expr): return cancel(expr) class Util_Part(Function): def doit(self): i = Simplify(self.args[0]) if len(self.args) > 2 : lst = list(self.args[1:]) else: lst = self.args[1] if isinstance(i, (int, Integer)): if isinstance(lst, list): return lst[i - 1] elif AtomQ(lst): return lst return lst.args[i - 1] else: return self def Part(lst, i): #see i = -1 if isinstance(lst, list): return Util_Part(i, *lst).doit() return Util_Part(i, lst).doit() def PolyLog(n, p, z=None): return polylog(n, p) def D(f, x): try: return f.diff(x) except ValueError: return Function('D')(f, x) def IntegralFreeQ(u): return FreeQ(u, Integral) def Dist(u, v, x): #Dist(u,v) returns the sum of u times each term of v, provided v is free of Int u = replace_pow_exp(u) # to replace back to sympy's exp v = replace_pow_exp(v) w = Simp(u*x**2, x)/x**2 if u == 1: return v elif u == 0: return 0 elif NumericFactor(u) < 0 and NumericFactor(-u) > 0: return -Dist(-u, v, x) elif SumQ(v): return Add(*[Dist(u, i, x) for i in v.args]) elif IntegralFreeQ(v): return Simp(u*v, x) elif w != u and FreeQ(w, x) and w == Simp(w, x) and w == Simp(w*x**2, x)/x**2: return Dist(w, v, x) else: return Simp(u*v, x) def PureFunctionOfCothQ(u, v, x): # If u is a pure function of Coth[v], PureFunctionOfCothQ[u,v,x] returns True; if AtomQ(u): return u != x elif CalculusQ(u): return False elif HyperbolicQ(u) and ZeroQ(u.args[0] - v): return CothQ(u) return all(PureFunctionOfCothQ(i, v, x) for i in u.args) def LogIntegral(z): return li(z) def ExpIntegralEi(z): return Ei(z) def ExpIntegralE(a, b): return expint(a, b).evalf() def SinIntegral(z): return Si(z) def CosIntegral(z): return Ci(z) def SinhIntegral(z): return Shi(z) def CoshIntegral(z): return Chi(z) class PolyGamma(Function): @classmethod def eval(cls, *args): if len(args) == 2: return polygamma(args[0], args[1]) return digamma(args[0]) def LogGamma(z): return loggamma(z) class ProductLog(Function): @classmethod def eval(cls, *args): if len(args) == 2: return LambertW(args[1], args[0]).evalf() return LambertW(args[0]).evalf() def Factorial(a): return factorial(a) def Zeta(*args): return zeta(*args) def HypergeometricPFQ(a, b, c): return hyper(a, b, c) def Sum_doit(exp, args): ''' This function perform summation using sympy's `Sum`. Examples ======== >>> from sympy.integrals.rubi.utility_function import Sum_doit >>> from sympy.abc import x >>> Sum_doit(2*x + 2, [x, 0, 1.7]) 6 ''' exp = replace_pow_exp(exp) if not isinstance(args[2], (int, Integer)): new_args = [args[0], args[1], Floor(args[2])] return Sum(exp, new_args).doit() return Sum(exp, args).doit() def PolynomialQuotient(p, q, x): try: p = poly(p, x) q = poly(q, x) except: p = poly(p) q = poly(q) try: return quo(p, q).as_expr() except (PolynomialDivisionFailed, UnificationFailed): return p/q def PolynomialRemainder(p, q, x): try: p = poly(p, x) q = poly(q, x) except: p = poly(p) q = poly(q) try: return rem(p, q).as_expr() except (PolynomialDivisionFailed, UnificationFailed): return S(0) def Floor(x, a = None): if a is None: return floor(x) return a*floor(x/a) def Factor(var): return factor(var) def Rule(a, b): return {a: b} def Distribute(expr, *args): if len(args) == 1: if isinstance(expr, args[0]): return expr else: return expr.expand() if len(args) == 2: if isinstance(expr, args[1]): return expr.expand() else: return expr return expr.expand() def CoprimeQ(*args): args = S(args) g = gcd(*args) if g == 1: return True return False def Discriminant(a, b): try: return discriminant(a, b) except PolynomialError: return Function('Discriminant')(a, b) def Negative(x): return x < S(0) def Quotient(m, n): return Floor(m/n) def process_trig(expr): ''' This function processes trigonometric expressions such that all `cot` is rewritten in terms of `tan`, `sec` in terms of `cos`, `csc` in terms of `sin` and similarly for `coth`, `sech` and `csch`. Examples ======== >>> from sympy.integrals.rubi.utility_function import process_trig >>> from sympy.abc import x >>> from sympy import coth, cot, csc >>> process_trig(x*cot(x)) x/tan(x) >>> process_trig(coth(x)*csc(x)) 1/(sin(x)*tanh(x)) ''' expr = expr.replace(lambda x: isinstance(x, cot), lambda x: 1/tan(x.args[0])) expr = expr.replace(lambda x: isinstance(x, sec), lambda x: 1/cos(x.args[0])) expr = expr.replace(lambda x: isinstance(x, csc), lambda x: 1/sin(x.args[0])) expr = expr.replace(lambda x: isinstance(x, coth), lambda x: 1/tanh(x.args[0])) expr = expr.replace(lambda x: isinstance(x, sech), lambda x: 1/cosh(x.args[0])) expr = expr.replace(lambda x: isinstance(x, csch), lambda x: 1/sinh(x.args[0])) return expr def _ExpandIntegrand(): Plus = Add Times = Mul def cons_f1(m): return PositiveIntegerQ(m) cons1 = CustomConstraint(cons_f1) def cons_f2(d, c, b, a): return ZeroQ(-a*d + b*c) cons2 = CustomConstraint(cons_f2) def cons_f3(a, x): return FreeQ(a, x) cons3 = CustomConstraint(cons_f3) def cons_f4(b, x): return FreeQ(b, x) cons4 = CustomConstraint(cons_f4) def cons_f5(c, x): return FreeQ(c, x) cons5 = CustomConstraint(cons_f5) def cons_f6(d, x): return FreeQ(d, x) cons6 = CustomConstraint(cons_f6) def cons_f7(e, x): return FreeQ(e, x) cons7 = CustomConstraint(cons_f7) def cons_f8(f, x): return FreeQ(f, x) cons8 = CustomConstraint(cons_f8) def cons_f9(g, x): return FreeQ(g, x) cons9 = CustomConstraint(cons_f9) def cons_f10(h, x): return FreeQ(h, x) cons10 = CustomConstraint(cons_f10) def cons_f11(e, b, c, f, n, p, F, x, d, m): if not isinstance(x, Symbol): return False return FreeQ(List(F, b, c, d, e, f, m, n, p), x) cons11 = CustomConstraint(cons_f11) def cons_f12(F, x): return FreeQ(F, x) cons12 = CustomConstraint(cons_f12) def cons_f13(m, x): return FreeQ(m, x) cons13 = CustomConstraint(cons_f13) def cons_f14(n, x): return FreeQ(n, x) cons14 = CustomConstraint(cons_f14) def cons_f15(p, x): return FreeQ(p, x) cons15 = CustomConstraint(cons_f15) def cons_f16(e, b, c, f, n, a, p, F, x, d, m): if not isinstance(x, Symbol): return False return FreeQ(List(F, a, b, c, d, e, f, m, n, p), x) cons16 = CustomConstraint(cons_f16) def cons_f17(n, m): return IntegersQ(m, n) cons17 = CustomConstraint(cons_f17) def cons_f18(n): return Less(n, S(0)) cons18 = CustomConstraint(cons_f18) def cons_f19(x, u): if not isinstance(x, Symbol): return False return PolynomialQ(u, x) cons19 = CustomConstraint(cons_f19) def cons_f20(G, F, u): return SameQ(F(u)*G(u), S(1)) cons20 = CustomConstraint(cons_f20) def cons_f21(q, x): return FreeQ(q, x) cons21 = CustomConstraint(cons_f21) def cons_f22(F): return MemberQ(List(ArcSin, ArcCos, ArcSinh, ArcCosh), F) cons22 = CustomConstraint(cons_f22) def cons_f23(j, n): return ZeroQ(j - S(2)*n) cons23 = CustomConstraint(cons_f23) def cons_f24(A, x): return FreeQ(A, x) cons24 = CustomConstraint(cons_f24) def cons_f25(B, x): return FreeQ(B, x) cons25 = CustomConstraint(cons_f25) def cons_f26(m, u, x): if not isinstance(x, Symbol): return False def _cons_f_u(d, w, c, p, x): return And(FreeQ(List(c, d), x), IntegerQ(p), Greater(p, m)) cons_u = CustomConstraint(_cons_f_u) pat = Pattern(UtilityOperator((c_ + x_*WC('d', S(1)))**p_*WC('w', S(1)), x_), cons_u) result_matchq = is_match(UtilityOperator(u, x), pat) return Not(And(PositiveIntegerQ(m), result_matchq)) cons26 = CustomConstraint(cons_f26) def cons_f27(b, v, n, a, x, u, m): if not isinstance(x, Symbol): return False return And(FreeQ(List(a, b, m), x), NegativeIntegerQ(n), Not(IntegerQ(m)), PolynomialQ(u, x), PolynomialQ(v, x),\ RationalQ(m), Less(m, -1), GreaterEqual(Exponent(u, x), (-n - IntegerPart(m))*Exponent(v, x))) cons27 = CustomConstraint(cons_f27) def cons_f28(v, n, x, u, m): if not isinstance(x, Symbol): return False return And(FreeQ(List(a, b, m), x), NegativeIntegerQ(n), Not(IntegerQ(m)), PolynomialQ(u, x),\ PolynomialQ(v, x), GreaterEqual(Exponent(u, x), -n*Exponent(v, x))) cons28 = CustomConstraint(cons_f28) def cons_f29(n): return PositiveIntegerQ(n/S(4)) cons29 = CustomConstraint(cons_f29) def cons_f30(n): return IntegerQ(n) cons30 = CustomConstraint(cons_f30) def cons_f31(n): return Greater(n, S(1)) cons31 = CustomConstraint(cons_f31) def cons_f32(n, m): return Less(S(0), m, n) cons32 = CustomConstraint(cons_f32) def cons_f33(n, m): return OddQ(n/GCD(m, n)) cons33 = CustomConstraint(cons_f33) def cons_f34(a, b): return PosQ(a/b) cons34 = CustomConstraint(cons_f34) def cons_f35(n, m, p): return IntegersQ(m, n, p) cons35 = CustomConstraint(cons_f35) def cons_f36(n, m, p): return Less(S(0), m, p, n) cons36 = CustomConstraint(cons_f36) def cons_f37(q, n, m, p): return IntegersQ(m, n, p, q) cons37 = CustomConstraint(cons_f37) def cons_f38(n, q, m, p): return Less(S(0), m, p, q, n) cons38 = CustomConstraint(cons_f38) def cons_f39(n): return IntegerQ(n/S(2)) cons39 = CustomConstraint(cons_f39) def cons_f40(p): return NegativeIntegerQ(p) cons40 = CustomConstraint(cons_f40) def cons_f41(n, m): return IntegersQ(m, n/S(2)) cons41 = CustomConstraint(cons_f41) def cons_f42(n, m): return Unequal(m, n/S(2)) cons42 = CustomConstraint(cons_f42) def cons_f43(c, b, a): return NonzeroQ(-S(4)*a*c + b**S(2)) cons43 = CustomConstraint(cons_f43) def cons_f44(j, n, m): return IntegersQ(m, n, j) cons44 = CustomConstraint(cons_f44) def cons_f45(n, m): return Less(S(0), m, S(2)*n) cons45 = CustomConstraint(cons_f45) def cons_f46(n, m, p): return Not(And(Equal(m, n), Equal(p, S(-1)))) cons46 = CustomConstraint(cons_f46) def cons_f47(v, x): if not isinstance(x, Symbol): return False return PolynomialQ(v, x) cons47 = CustomConstraint(cons_f47) def cons_f48(v, x): if not isinstance(x, Symbol): return False return BinomialQ(v, x) cons48 = CustomConstraint(cons_f48) def cons_f49(v, x, u): if not isinstance(x, Symbol): return False return Inequality(Exponent(u, x), Equal, Exponent(v, x) + S(-1), GreaterEqual, S(2)) cons49 = CustomConstraint(cons_f49) def cons_f50(v, x, u): if not isinstance(x, Symbol): return False return GreaterEqual(Exponent(u, x), Exponent(v, x)) cons50 = CustomConstraint(cons_f50) def cons_f51(p): return Not(IntegerQ(p)) cons51 = CustomConstraint(cons_f51) def With2(e, b, c, f, n, a, g, h, x, d, m): tmp = a*h - b*g k = Symbol('k') return f**(e*(c + d*x)**n)*SimplifyTerm(h**(-m)*tmp**m, x)/(g + h*x) + Sum_doit(f**(e*(c + d*x)**n)*(a + b*x)**(-k + m)*SimplifyTerm(b*h**(-k)*tmp**(k - 1), x), List(k, 1, m)) pattern2 = Pattern(UtilityOperator(f_**((x_*WC('d', S(1)) + WC('c', S(0)))**WC('n', S(1))*WC('e', S(1)))*(x_*WC('b', S(1)) + WC('a', S(0)))**WC('m', S(1))/(x_*WC('h', S(1)) + WC('g', S(0))), x_), cons3, cons4, cons5, cons6, cons7, cons8, cons9, cons10, cons1, cons2) rule2 = ReplacementRule(pattern2, With2) pattern3 = Pattern(UtilityOperator(F_**((x_*WC('d', S(1)) + WC('c', S(0)))**WC('n', S(1))*WC('b', S(1)))*x_**WC('m', S(1))*(e_ + x_*WC('f', S(1)))**WC('p', S(1)), x_), cons12, cons4, cons5, cons6, cons7, cons8, cons13, cons14, cons15, cons11) def replacement3(e, b, c, f, n, p, F, x, d, m): return If(And(PositiveIntegerQ(m, p), LessEqual(m, p), Or(EqQ(n, S(1)), ZeroQ(-c*f + d*e))), ExpandLinearProduct(F**(b*(c + d*x)**n)*(e + f*x)**p, x**m, e, f, x), If(PositiveIntegerQ(p), Distribute(F**(b*(c + d*x)**n)*x**m*(e + f*x)**p, Plus, Times), ExpandIntegrand(F**(b*(c + d*x)**n), x**m*(e + f*x)**p, x))) rule3 = ReplacementRule(pattern3, replacement3) pattern4 = Pattern(UtilityOperator(F_**((x_*WC('d', S(1)) + WC('c', S(0)))**WC('n', S(1))*WC('b', S(1)) + WC('a', S(0)))*x_**WC('m', S(1))*(e_ + x_*WC('f', S(1)))**WC('p', S(1)), x_), cons12, cons3, cons4, cons5, cons6, cons7, cons8, cons13, cons14, cons15, cons16) def replacement4(e, b, c, f, n, a, p, F, x, d, m): return If(And(PositiveIntegerQ(m, p), LessEqual(m, p), Or(EqQ(n, S(1)), ZeroQ(-c*f + d*e))), ExpandLinearProduct(F**(a + b*(c + d*x)**n)*(e + f*x)**p, x**m, e, f, x), If(PositiveIntegerQ(p), Distribute(F**(a + b*(c + d*x)**n)*x**m*(e + f*x)**p, Plus, Times), ExpandIntegrand(F**(a + b*(c + d*x)**n), x**m*(e + f*x)**p, x))) rule4 = ReplacementRule(pattern4, replacement4) def With5(b, v, c, n, a, F, u, x, d, m): if not isinstance(x, Symbol) or not (FreeQ([F, a, b, c, d], x) and IntegersQ(m, n) and n < 0): return False w = ExpandIntegrand((a + b*x)**m*(c + d*x)**n, x) w = ReplaceAll(w, Rule(x, F**v)) if SumQ(w): return True return False pattern5 = Pattern(UtilityOperator((F_**v_*WC('b', S(1)) + a_)**WC('m', S(1))*(F_**v_*WC('d', S(1)) + c_)**n_*WC('u', S(1)), x_), cons12, cons3, cons4, cons5, cons6, cons17, cons18, CustomConstraint(With5)) def replacement5(b, v, c, n, a, F, u, x, d, m): w = ReplaceAll(ExpandIntegrand((a + b*x)**m*(c + d*x)**n, x), Rule(x, F**v)) return w.func(*[u*i for i in w.args]) rule5 = ReplacementRule(pattern5, replacement5) def With6(e, b, c, f, n, a, x, u, d, m): if not isinstance(x, Symbol) or not (FreeQ([a, b, c, d, e, f, m, n], x) and PolynomialQ(u,x)): return False v = ExpandIntegrand(u*(a + b*x)**m, x) if SumQ(v): return True return False pattern6 = Pattern(UtilityOperator(f_**((x_*WC('d', S(1)) + WC('c', S(0)))**WC('n', S(1))*WC('e', S(1)))*u_*(x_*WC('b', S(1)) + WC('a', S(0)))**WC('m', S(1)), x_), cons3, cons4, cons5, cons6, cons7, cons8, cons13, cons14, cons19, CustomConstraint(With6)) def replacement6(e, b, c, f, n, a, x, u, d, m): v = ExpandIntegrand(u*(a + b*x)**m, x) return Distribute(f**(e*(c + d*x)**n)*v, Plus, Times) rule6 = ReplacementRule(pattern6, replacement6) pattern7 = Pattern(UtilityOperator(u_*(x_*WC('b', S(1)) + WC('a', S(0)))**WC('m', S(1))*Log((x_**WC('n', S(1))*WC('e', S(1)) + WC('d', S(0)))**WC('p', S(1))*WC('c', S(1))), x_), cons3, cons4, cons5, cons6, cons7, cons13, cons14, cons15, cons19) def replacement7(e, b, c, n, a, p, x, u, d, m): return ExpandIntegrand(Log(c*(d + e*x**n)**p), u*(a + b*x)**m, x) rule7 = ReplacementRule(pattern7, replacement7) pattern8 = Pattern(UtilityOperator(f_**((x_*WC('d', S(1)) + WC('c', S(0)))**WC('n', S(1))*WC('e', S(1)))*u_, x_), cons5, cons6, cons7, cons8, cons14, cons19) def replacement8(e, c, f, n, x, u, d): return If(EqQ(n, S(1)), ExpandIntegrand(f**(e*(c + d*x)**n), u, x), ExpandLinearProduct(f**(e*(c + d*x)**n), u, c, d, x)) rule8 = ReplacementRule(pattern8, replacement8) # pattern9 = Pattern(UtilityOperator(F_**u_*(G_*u_*WC('b', S(1)) + a_)**WC('n', S(1)), x_), cons3, cons4, cons17, cons20) # def replacement9(b, G, n, a, F, u, x, m): # return ReplaceAll(ExpandIntegrand(x**(-m)*(a + b*x)**n, x), Rule(x, G(u))) # rule9 = ReplacementRule(pattern9, replacement9) pattern10 = Pattern(UtilityOperator(u_*(WC('a', S(0)) + WC('b', S(1))*Log(((x_*WC('f', S(1)) + WC('e', S(0)))**WC('p', S(1))*WC('d', S(1)))**WC('q', S(1))*WC('c', S(1))))**n_, x_), cons3, cons4, cons5, cons6, cons7, cons8, cons14, cons15, cons21, cons19) def replacement10(e, b, c, f, n, a, p, x, u, d, q): return ExpandLinearProduct((a + b*Log(c*(d*(e + f*x)**p)**q))**n, u, e, f, x) rule10 = ReplacementRule(pattern10, replacement10) # pattern11 = Pattern(UtilityOperator(u_*(F_*(x_*WC('d', S(1)) + WC('c', S(0)))*WC('b', S(1)) + WC('a', S(0)))**n_, x_), cons3, cons4, cons5, cons6, cons14, cons19, cons22) # def replacement11(b, c, n, a, F, u, x, d): # return ExpandLinearProduct((a + b*F(c + d*x))**n, u, c, d, x) # rule11 = ReplacementRule(pattern11, replacement11) pattern12 = Pattern(UtilityOperator(WC('u', S(1))/(x_**n_*WC('a', S(1)) + sqrt(c_ + x_**j_*WC('d', S(1)))*WC('b', S(1))), x_), cons3, cons4, cons5, cons6, cons14, cons23) def replacement12(b, c, n, a, x, u, d, j): return ExpandIntegrand(u*(a*x**n - b*sqrt(c + d*x**(S(2)*n)))/(-b**S(2)*c + x**(S(2)*n)*(a**S(2) - b**S(2)*d)), x) rule12 = ReplacementRule(pattern12, replacement12) pattern13 = Pattern(UtilityOperator((a_ + x_*WC('b', S(1)))**m_/(c_ + x_*WC('d', S(1))), x_), cons3, cons4, cons5, cons6, cons1) def replacement13(b, c, a, x, d, m): if RationalQ(a, b, c, d): return ExpandExpression((a + b*x)**m/(c + d*x), x) else: tmp = a*d - b*c k = Symbol("k") return Sum_doit((a + b*x)**(-k + m)*SimplifyTerm(b*d**(-k)*tmp**(k + S(-1)), x), List(k, S(1), m)) + SimplifyTerm(d**(-m)*tmp**m, x)/(c + d*x) rule13 = ReplacementRule(pattern13, replacement13) pattern14 = Pattern(UtilityOperator((A_ + x_*WC('B', S(1)))*(a_ + x_*WC('b', S(1)))**WC('m', S(1))/(c_ + x_*WC('d', S(1))), x_), cons3, cons4, cons5, cons6, cons24, cons25, cons1) def replacement14(b, B, A, c, a, x, d, m): if RationalQ(a, b, c, d, A, B): return ExpandExpression((A + B*x)*(a + b*x)**m/(c + d*x), x) else: tmp1 = (A*d - B*c)/d tmp2 = ExpandIntegrand((a + b*x)**m/(c + d*x), x) tmp2 = If(SumQ(tmp2), tmp2.func(*[SimplifyTerm(tmp1*i, x) for i in tmp2.args]), SimplifyTerm(tmp1*tmp2, x)) return SimplifyTerm(B/d, x)*(a + b*x)**m + tmp2 rule14 = ReplacementRule(pattern14, replacement14) def With15(b, a, x, u, m): tmp1 = Symbol('tmp1') tmp2 = Symbol('tmp2') tmp1 = ExpandLinearProduct((a + b*x)**m, u, a, b, x) if not IntegerQ(m): return tmp1 else: tmp2 = ExpandExpression(u*(a + b*x)**m, x) if SumQ(tmp2) and LessEqual(LeafCount(tmp2), LeafCount(tmp1) + S(2)): return tmp2 else: return tmp1 pattern15 = Pattern(UtilityOperator(u_*(a_ + x_*WC('b', S(1)))**m_, x_), cons3, cons4, cons13, cons19, cons26) rule15 = ReplacementRule(pattern15, With15) pattern16 = Pattern(UtilityOperator(u_*v_**n_*(a_ + x_*WC('b', S(1)))**m_, x_), cons27) def replacement16(b, v, n, a, x, u, m): s = PolynomialQuotientRemainder(u, v**(-n)*(a+b*x)**(-IntegerPart(m)), x) return ExpandIntegrand((a + b*x)**FractionalPart(m)*s[0], x) + ExpandIntegrand(v**n*(a + b*x)**m*s[1], x) rule16 = ReplacementRule(pattern16, replacement16) pattern17 = Pattern(UtilityOperator(u_*v_**n_*(a_ + x_*WC('b', S(1)))**m_, x_), cons28) def replacement17(b, v, n, a, x, u, m): s = PolynomialQuotientRemainder(u, v**(-n),x) return ExpandIntegrand((a + b*x)**(m)*s[0], x) + ExpandIntegrand(v**n*(a + b*x)**m*s[1], x) rule17 = ReplacementRule(pattern17, replacement17) def With18(b, n, a, x, u): r = Numerator(Rt(-a/b, S(2))) s = Denominator(Rt(-a/b, S(2))) return r/(S(2)*a*(r + s*u**(n/S(2)))) + r/(S(2)*a*(r - s*u**(n/S(2)))) pattern18 = Pattern(UtilityOperator(S(1)/(a_ + u_**n_*WC('b', S(1))), x_), cons3, cons4, cons29) rule18 = ReplacementRule(pattern18, With18) def With19(b, n, a, x, u): k = Symbol("k") r = Numerator(Rt(-a/b, n)) s = Denominator(Rt(-a/b, n)) return Sum_doit(r/(a*n*(-(-1)**(2*k/n)*s*u + r)), List(k, 1, n)) pattern19 = Pattern(UtilityOperator(S(1)/(a_ + u_**n_*WC('b', S(1))), x_), cons3, cons4, cons30, cons31) rule19 = ReplacementRule(pattern19, With19) def With20(b, n, a, x, u, m): k = Symbol("k") g = GCD(m, n) r = Numerator(Rt(a/b, n/GCD(m, n))) s = Denominator(Rt(a/b, n/GCD(m, n))) return If(CoprimeQ(g + m, n), Sum_doit((-1)**(-2*k*m/n)*r*(-r/s)**(m/g)/(a*n*((-1)**(2*g*k/n)*s*u**g + r)), List(k, 1, n/g)), Sum_doit((-1)**(2*k*(g + m)/n)*r*(-r/s)**(m/g)/(a*n*((-1)**(2*g*k/n)*r + s*u**g)), List(k, 1, n/g))) pattern20 = Pattern(UtilityOperator(u_**WC('m', S(1))/(a_ + u_**n_*WC('b', S(1))), x_), cons3, cons4, cons17, cons32, cons33, cons34) rule20 = ReplacementRule(pattern20, With20) def With21(b, n, a, x, u, m): k = Symbol("k") g = GCD(m, n) r = Numerator(Rt(-a/b, n/GCD(m, n))) s = Denominator(Rt(-a/b, n/GCD(m, n))) return If(Equal(n/g, S(2)), s/(S(2)*b*(r + s*u**g)) - s/(S(2)*b*(r - s*u**g)), If(CoprimeQ(g + m, n), Sum_doit((S(-1))**(-S(2)*k*m/n)*r*(r/s)**(m/g)/(a*n*(-(S(-1))**(S(2)*g*k/n)*s*u**g + r)), List(k, S(1), n/g)), Sum_doit((S(-1))**(S(2)*k*(g + m)/n)*r*(r/s)**(m/g)/(a*n*((S(-1))**(S(2)*g*k/n)*r - s*u**g)), List(k, S(1), n/g)))) pattern21 = Pattern(UtilityOperator(u_**WC('m', S(1))/(a_ + u_**n_*WC('b', S(1))), x_), cons3, cons4, cons17, cons32) rule21 = ReplacementRule(pattern21, With21) def With22(b, c, n, a, x, u, d, m): k = Symbol("k") r = Numerator(Rt(-a/b, n)) s = Denominator(Rt(-a/b, n)) return Sum_doit((c*r + (-1)**(-2*k*m/n)*d*r*(r/s)**m)/(a*n*(-(-1)**(2*k/n)*s*u + r)), List(k, 1, n)) pattern22 = Pattern(UtilityOperator((c_ + u_**WC('m', S(1))*WC('d', S(1)))/(a_ + u_**n_*WC('b', S(1))), x_), cons3, cons4, cons5, cons6, cons17, cons32) rule22 = ReplacementRule(pattern22, With22) def With23(e, b, c, n, a, p, x, u, d, m): k = Symbol("k") r = Numerator(Rt(-a/b, n)) s = Denominator(Rt(-a/b, n)) return Sum_doit((c*r + (-1)**(-2*k*p/n)*e*r*(r/s)**p + (-1)**(-2*k*m/n)*d*r*(r/s)**m)/(a*n*(-(-1)**(2*k/n)*s*u + r)), List(k, 1, n)) pattern23 = Pattern(UtilityOperator((u_**p_*WC('e', S(1)) + u_**WC('m', S(1))*WC('d', S(1)) + WC('c', S(0)))/(a_ + u_**n_*WC('b', S(1))), x_), cons3, cons4, cons5, cons6, cons7, cons35, cons36) rule23 = ReplacementRule(pattern23, With23) def With24(e, b, c, f, n, a, p, x, u, d, q, m): k = Symbol("k") r = Numerator(Rt(-a/b, n)) s = Denominator(Rt(-a/b, n)) return Sum_doit((c*r + (-1)**(-2*k*q/n)*f*r*(r/s)**q + (-1)**(-2*k*p/n)*e*r*(r/s)**p + (-1)**(-2*k*m/n)*d*r*(r/s)**m)/(a*n*(-(-1)**(2*k/n)*s*u + r)), List(k, 1, n)) pattern24 = Pattern(UtilityOperator((u_**p_*WC('e', S(1)) + u_**q_*WC('f', S(1)) + u_**WC('m', S(1))*WC('d', S(1)) + WC('c', S(0)))/(a_ + u_**n_*WC('b', S(1))), x_), cons3, cons4, cons5, cons6, cons7, cons8, cons37, cons38) rule24 = ReplacementRule(pattern24, With24) def With25(c, n, a, p, x, u): q = Symbol('q') return ReplaceAll(ExpandIntegrand(c**(-p), (c*x - q)**p*(c*x + q)**p, x), List(Rule(q, Rt(-a*c, S(2))), Rule(x, u**(n/S(2))))) pattern25 = Pattern(UtilityOperator((a_ + u_**WC('n', S(1))*WC('c', S(1)))**p_, x_), cons3, cons5, cons39, cons40) rule25 = ReplacementRule(pattern25, With25) def With26(c, n, a, p, x, u, m): q = Symbol('q') return ReplaceAll(ExpandIntegrand(c**(-p), x**m*(c*x**(n/S(2)) - q)**p*(c*x**(n/S(2)) + q)**p, x), List(Rule(q, Rt(-a*c, S(2))), Rule(x, u))) pattern26 = Pattern(UtilityOperator(u_**WC('m', S(1))*(u_**WC('n', S(1))*WC('c', S(1)) + WC('a', S(0)))**p_, x_), cons3, cons5, cons41, cons40, cons32, cons42) rule26 = ReplacementRule(pattern26, With26) def With27(b, c, n, a, p, x, u, j): q = Symbol('q') return ReplaceAll(ExpandIntegrand(S(4)**(-p)*c**(-p), (b + S(2)*c*x - q)**p*(b + S(2)*c*x + q)**p, x), List(Rule(q, Rt(-S(4)*a*c + b**S(2), S(2))), Rule(x, u**n))) pattern27 = Pattern(UtilityOperator((u_**WC('j', S(1))*WC('c', S(1)) + u_**WC('n', S(1))*WC('b', S(1)) + WC('a', S(0)))**p_, x_), cons3, cons4, cons5, cons30, cons23, cons40, cons43) rule27 = ReplacementRule(pattern27, With27) def With28(b, c, n, a, p, x, u, j, m): q = Symbol('q') return ReplaceAll(ExpandIntegrand(S(4)**(-p)*c**(-p), x**m*(b + S(2)*c*x**n - q)**p*(b + S(2)*c*x**n + q)**p, x), List(Rule(q, Rt(-S(4)*a*c + b**S(2), S(2))), Rule(x, u))) pattern28 = Pattern(UtilityOperator(u_**WC('m', S(1))*(u_**WC('j', S(1))*WC('c', S(1)) + u_**WC('n', S(1))*WC('b', S(1)) + WC('a', S(0)))**p_, x_), cons3, cons4, cons5, cons44, cons23, cons40, cons45, cons46, cons43) rule28 = ReplacementRule(pattern28, With28) def With29(b, c, n, a, x, u, d, j): q = Rt(-a/b, S(2)) return -(c - d*q)/(S(2)*b*q*(q + u**n)) - (c + d*q)/(S(2)*b*q*(q - u**n)) pattern29 = Pattern(UtilityOperator((u_**WC('n', S(1))*WC('d', S(1)) + WC('c', S(0)))/(a_ + u_**WC('j', S(1))*WC('b', S(1))), x_), cons3, cons4, cons5, cons6, cons14, cons23) rule29 = ReplacementRule(pattern29, With29) def With30(e, b, c, f, n, a, g, x, u, d, j): q = Rt(-S(4)*a*c + b**S(2), S(2)) r = TogetherSimplify((-b*e*g + S(2)*c*(d + e*f))/q) return (e*g - r)/(b + 2*c*u**n + q) + (e*g + r)/(b + 2*c*u**n - q) pattern30 = Pattern(UtilityOperator(((u_**WC('n', S(1))*WC('g', S(1)) + WC('f', S(0)))*WC('e', S(1)) + WC('d', S(0)))/(u_**WC('j', S(1))*WC('c', S(1)) + u_**WC('n', S(1))*WC('b', S(1)) + WC('a', S(0))), x_), cons3, cons4, cons5, cons6, cons7, cons8, cons9, cons14, cons23, cons43) rule30 = ReplacementRule(pattern30, With30) def With31(v, x, u): lst = CoefficientList(u, x) i = Symbol('i') return x**Exponent(u, x)*lst[-1]/v + Sum_doit(x**(i - 1)*Part(lst, i), List(i, 1, Exponent(u, x)))/v pattern31 = Pattern(UtilityOperator(u_/v_, x_), cons19, cons47, cons48, cons49) rule31 = ReplacementRule(pattern31, With31) pattern32 = Pattern(UtilityOperator(u_/v_, x_), cons19, cons47, cons50) def replacement32(v, x, u): return PolynomialDivide(u, v, x) rule32 = ReplacementRule(pattern32, replacement32) pattern33 = Pattern(UtilityOperator(u_*(x_*WC('a', S(1)))**p_, x_), cons51, cons19) def replacement33(x, a, u, p): return ExpandToSum((a*x)**p, u, x) rule33 = ReplacementRule(pattern33, replacement33) pattern34 = Pattern(UtilityOperator(v_**p_*WC('u', S(1)), x_), cons51) def replacement34(v, x, u, p): return ExpandIntegrand(NormalizeIntegrand(v**p, x), u, x) rule34 = ReplacementRule(pattern34, replacement34) pattern35 = Pattern(UtilityOperator(u_, x_)) def replacement35(x, u): return ExpandExpression(u, x) rule35 = ReplacementRule(pattern35, replacement35) return [ rule2,rule3, rule4, rule5, rule6, rule7, rule8, rule10, rule12, rule13, rule14, rule15, rule16, rule17, rule18, rule19, rule20, rule21, rule22, rule23, rule24, rule25, rule26, rule27, rule28, rule29, rule30, rule31, rule32, rule33, rule34, rule35] def _RemoveContentAux(): def cons_f1(b, a): return IntegersQ(a, b) cons1 = CustomConstraint(cons_f1) def cons_f2(b, a): return Equal(a + b, S(0)) cons2 = CustomConstraint(cons_f2) def cons_f3(m): return RationalQ(m) cons3 = CustomConstraint(cons_f3) def cons_f4(m, n): return RationalQ(m, n) cons4 = CustomConstraint(cons_f4) def cons_f5(m, n): return GreaterEqual(-m + n, S(0)) cons5 = CustomConstraint(cons_f5) def cons_f6(a, x): return FreeQ(a, x) cons6 = CustomConstraint(cons_f6) def cons_f7(m, n, p): return RationalQ(m, n, p) cons7 = CustomConstraint(cons_f7) def cons_f8(m, p): return GreaterEqual(-m + p, S(0)) cons8 = CustomConstraint(cons_f8) pattern1 = Pattern(UtilityOperator(a_**m_*WC('u', S(1)) + b_*WC('v', S(1)), x_), cons1, cons2, cons3) def replacement1(v, x, a, u, m, b): return If(Greater(m, S(1)), RemoveContentAux(a**(m + S(-1))*u - v, x), RemoveContentAux(-a**(-m + S(1))*v + u, x)) rule1 = ReplacementRule(pattern1, replacement1) pattern2 = Pattern(UtilityOperator(a_**WC('m', S(1))*WC('u', S(1)) + a_**WC('n', S(1))*WC('v', S(1)), x_), cons6, cons4, cons5) def replacement2(n, v, x, u, m, a): return RemoveContentAux(a**(-m + n)*v + u, x) rule2 = ReplacementRule(pattern2, replacement2) pattern3 = Pattern(UtilityOperator(a_**WC('m', S(1))*WC('u', S(1)) + a_**WC('n', S(1))*WC('v', S(1)) + a_**WC('p', S(1))*WC('w', S(1)), x_), cons6, cons7, cons5, cons8) def replacement3(n, v, x, p, u, w, m, a): return RemoveContentAux(a**(-m + n)*v + a**(-m + p)*w + u, x) rule3 = ReplacementRule(pattern3, replacement3) pattern4 = Pattern(UtilityOperator(u_, x_)) def replacement4(u, x): return If(And(SumQ(u), NegQ(First(u))), -u, u) rule4 = ReplacementRule(pattern4, replacement4) return [rule1, rule2, rule3, rule4, ] IntHide = Int Log = rubi_log Null = None if matchpy: RemoveContentAux_replacer = ManyToOneReplacer(* _RemoveContentAux()) ExpandIntegrand_rules = _ExpandIntegrand() TrigSimplifyAux_replacer = _TrigSimplifyAux() SimplifyAntiderivative_replacer = _SimplifyAntiderivative() SimplifyAntiderivativeSum_replacer = _SimplifyAntiderivativeSum() FixSimplify_rules = _FixSimplify() SimpFixFactor_replacer = _SimpFixFactor()
5b89447f63d8ab0d5102c48f2d5ba16b99a6cee37182178dfff0b4cc77664110
''' This code is automatically generated. Never edit it manually. For details of generating the code see `rubi_parsing_guide.md` in `parsetools`. ''' from sympy.external import import_module matchpy = import_module("matchpy") from sympy.utilities.decorator import doctest_depends_on if matchpy: from matchpy import Pattern, ReplacementRule, CustomConstraint, is_match from sympy.integrals.rubi.utility_function import ( Int, Sum, Set, With, Module, Scan, MapAnd, FalseQ, ZeroQ, NegativeQ, NonzeroQ, FreeQ, NFreeQ, List, Log, PositiveQ, PositiveIntegerQ, NegativeIntegerQ, IntegerQ, IntegersQ, ComplexNumberQ, PureComplexNumberQ, RealNumericQ, PositiveOrZeroQ, NegativeOrZeroQ, FractionOrNegativeQ, NegQ, Equal, Unequal, IntPart, FracPart, RationalQ, ProductQ, SumQ, NonsumQ, Subst, First, Rest, SqrtNumberQ, SqrtNumberSumQ, LinearQ, Sqrt, ArcCosh, Coefficient, Denominator, Hypergeometric2F1, Not, Simplify, FractionalPart, IntegerPart, AppellF1, EllipticPi, EllipticE, EllipticF, ArcTan, ArcCot, ArcCoth, ArcTanh, ArcSin, ArcSinh, ArcCos, ArcCsc, ArcSec, ArcCsch, ArcSech, Sinh, Tanh, Cosh, Sech, Csch, Coth, LessEqual, Less, Greater, GreaterEqual, FractionQ, IntLinearcQ, Expand, IndependentQ, PowerQ, IntegerPowerQ, PositiveIntegerPowerQ, FractionalPowerQ, AtomQ, ExpQ, LogQ, Head, MemberQ, TrigQ, SinQ, CosQ, TanQ, CotQ, SecQ, CscQ, Sin, Cos, Tan, Cot, Sec, Csc, HyperbolicQ, SinhQ, CoshQ, TanhQ, CothQ, SechQ, CschQ, InverseTrigQ, SinCosQ, SinhCoshQ, LeafCount, Numerator, NumberQ, NumericQ, Length, ListQ, Im, Re, InverseHyperbolicQ, InverseFunctionQ, TrigHyperbolicFreeQ, InverseFunctionFreeQ, RealQ, EqQ, FractionalPowerFreeQ, ComplexFreeQ, PolynomialQ, FactorSquareFree, PowerOfLinearQ, Exponent, QuadraticQ, LinearPairQ, BinomialParts, TrinomialParts, PolyQ, EvenQ, OddQ, PerfectSquareQ, NiceSqrtAuxQ, NiceSqrtQ, Together, PosAux, PosQ, CoefficientList, ReplaceAll, ExpandLinearProduct, GCD, ContentFactor, NumericFactor, NonnumericFactors, MakeAssocList, GensymSubst, KernelSubst, ExpandExpression, Apart, SmartApart, MatchQ, PolynomialQuotientRemainder, FreeFactors, NonfreeFactors, RemoveContentAux, RemoveContent, FreeTerms, NonfreeTerms, ExpandAlgebraicFunction, CollectReciprocals, ExpandCleanup, AlgebraicFunctionQ, Coeff, LeadTerm, RemainingTerms, LeadFactor, RemainingFactors, LeadBase, LeadDegree, Numer, Denom, hypergeom, Expon, MergeMonomials, PolynomialDivide, BinomialQ, TrinomialQ, GeneralizedBinomialQ, GeneralizedTrinomialQ, FactorSquareFreeList, PerfectPowerTest, SquareFreeFactorTest, RationalFunctionQ, RationalFunctionFactors, NonrationalFunctionFactors, Reverse, RationalFunctionExponents, RationalFunctionExpand, ExpandIntegrand, SimplerQ, SimplerSqrtQ, SumSimplerQ, BinomialDegree, TrinomialDegree, CancelCommonFactors, SimplerIntegrandQ, GeneralizedBinomialDegree, GeneralizedBinomialParts, GeneralizedTrinomialDegree, GeneralizedTrinomialParts, MonomialQ, MonomialSumQ, MinimumMonomialExponent, MonomialExponent, LinearMatchQ, PowerOfLinearMatchQ, QuadraticMatchQ, CubicMatchQ, BinomialMatchQ, TrinomialMatchQ, GeneralizedBinomialMatchQ, GeneralizedTrinomialMatchQ, QuotientOfLinearsMatchQ, PolynomialTermQ, PolynomialTerms, NonpolynomialTerms, PseudoBinomialParts, NormalizePseudoBinomial, PseudoBinomialPairQ, PseudoBinomialQ, PolynomialGCD, PolyGCD, AlgebraicFunctionFactors, NonalgebraicFunctionFactors, QuotientOfLinearsP, QuotientOfLinearsParts, QuotientOfLinearsQ, Flatten, Sort, AbsurdNumberQ, AbsurdNumberFactors, NonabsurdNumberFactors, SumSimplerAuxQ, Prepend, Drop, CombineExponents, FactorInteger, FactorAbsurdNumber, SubstForInverseFunction, SubstForFractionalPower, SubstForFractionalPowerOfQuotientOfLinears, FractionalPowerOfQuotientOfLinears, SubstForFractionalPowerQ, SubstForFractionalPowerAuxQ, FractionalPowerOfSquareQ, FractionalPowerSubexpressionQ, Apply, FactorNumericGcd, MergeableFactorQ, MergeFactor, MergeFactors, TrigSimplifyQ, TrigSimplify, TrigSimplifyRecur, Order, FactorOrder, Smallest, OrderedQ, MinimumDegree, PositiveFactors, Sign, NonpositiveFactors, PolynomialInAuxQ, PolynomialInQ, ExponentInAux, ExponentIn, PolynomialInSubstAux, PolynomialInSubst, Distrib, DistributeDegree, FunctionOfPower, DivideDegreesOfFactors, MonomialFactor, FullSimplify, FunctionOfLinearSubst, FunctionOfLinear, NormalizeIntegrand, NormalizeIntegrandAux, NormalizeIntegrandFactor, NormalizeIntegrandFactorBase, NormalizeTogether, NormalizeLeadTermSigns, AbsorbMinusSign, NormalizeSumFactors, SignOfFactor, NormalizePowerOfLinear, SimplifyIntegrand, SimplifyTerm, TogetherSimplify, SmartSimplify, SubstForExpn, ExpandToSum, UnifySum, UnifyTerms, UnifyTerm, CalculusQ, FunctionOfInverseLinear, PureFunctionOfSinhQ, PureFunctionOfTanhQ, PureFunctionOfCoshQ, IntegerQuotientQ, OddQuotientQ, EvenQuotientQ, FindTrigFactor, FunctionOfSinhQ, FunctionOfCoshQ, OddHyperbolicPowerQ, FunctionOfTanhQ, FunctionOfTanhWeight, FunctionOfHyperbolicQ, SmartNumerator, SmartDenominator, SubstForAux, ActivateTrig, ExpandTrig, TrigExpand, SubstForTrig, SubstForHyperbolic, InertTrigFreeQ, LCM, SubstForFractionalPowerOfLinear, FractionalPowerOfLinear, InverseFunctionOfLinear, InertTrigQ, InertReciprocalQ, DeactivateTrig, FixInertTrigFunction, DeactivateTrigAux, PowerOfInertTrigSumQ, PiecewiseLinearQ, KnownTrigIntegrandQ, KnownSineIntegrandQ, KnownTangentIntegrandQ, KnownCotangentIntegrandQ, KnownSecantIntegrandQ, TryPureTanSubst, TryTanhSubst, TryPureTanhSubst, AbsurdNumberGCD, AbsurdNumberGCDList, ExpandTrigExpand, ExpandTrigReduce, ExpandTrigReduceAux, NormalizeTrig, TrigToExp, ExpandTrigToExp, TrigReduce, FunctionOfTrig, AlgebraicTrigFunctionQ, FunctionOfHyperbolic, FunctionOfQ, FunctionOfExpnQ, PureFunctionOfSinQ, PureFunctionOfCosQ, PureFunctionOfTanQ, PureFunctionOfCotQ, FunctionOfCosQ, FunctionOfSinQ, OddTrigPowerQ, FunctionOfTanQ, FunctionOfTanWeight, FunctionOfTrigQ, FunctionOfDensePolynomialsQ, FunctionOfLog, PowerVariableExpn, PowerVariableDegree, PowerVariableSubst, EulerIntegrandQ, FunctionOfSquareRootOfQuadratic, SquareRootOfQuadraticSubst, Divides, EasyDQ, ProductOfLinearPowersQ, Rt, NthRoot, AtomBaseQ, SumBaseQ, NegSumBaseQ, AllNegTermQ, SomeNegTermQ, TrigSquareQ, RtAux, TrigSquare, IntSum, IntTerm, Map2, ConstantFactor, SameQ, ReplacePart, CommonFactors, MostMainFactorPosition, FunctionOfExponentialQ, FunctionOfExponential, FunctionOfExponentialFunction, FunctionOfExponentialFunctionAux, FunctionOfExponentialTest, FunctionOfExponentialTestAux, stdev, rubi_test, If, IntQuadraticQ, IntBinomialQ, RectifyTangent, RectifyCotangent, Inequality, Condition, Simp, SimpHelp, SplitProduct, SplitSum, SubstFor, SubstForAux, FresnelS, FresnelC, Erfc, Erfi, Gamma, FunctionOfTrigOfLinearQ, ElementaryFunctionQ, Complex, UnsameQ, _SimpFixFactor, SimpFixFactor, _FixSimplify, FixSimplify, _SimplifyAntiderivativeSum, SimplifyAntiderivativeSum, _SimplifyAntiderivative, SimplifyAntiderivative, _TrigSimplifyAux, TrigSimplifyAux, Cancel, Part, PolyLog, D, Dist, Sum_doit, PolynomialQuotient, Floor, PolynomialRemainder, Factor, PolyLog, CosIntegral, SinIntegral, LogIntegral, SinhIntegral, CoshIntegral, Rule, Erf, PolyGamma, ExpIntegralEi, ExpIntegralE, LogGamma , UtilityOperator, Factorial, Zeta, ProductLog, DerivativeDivides, HypergeometricPFQ, IntHide, OneQ, Null, rubi_exp as exp, rubi_log as log, Discriminant, Negative, Quotient ) from sympy import (Integral, S, sqrt, And, Or, Integer, Float, Mod, I, Abs, simplify, Mul, Add, Pow, sign, EulerGamma) from sympy.integrals.rubi.symbol import WC from sympy.core.symbol import symbols, Symbol from sympy.functions import (sin, cos, tan, cot, csc, sec, sqrt, erf) from sympy.functions.elementary.hyperbolic import (acosh, asinh, atanh, acoth, acsch, asech, cosh, sinh, tanh, coth, sech, csch) from sympy.functions.elementary.trigonometric import (atan, acsc, asin, acot, acos, asec, atan2) from sympy import pi as Pi A_, B_, C_, F_, G_, H_, a_, b_, c_, d_, e_, f_, g_, h_, i_, j_, k_, l_, m_, n_, p_, q_, r_, t_, u_, v_, s_, w_, x_, y_, z_ = [WC(i) for i in 'ABCFGHabcdefghijklmnpqrtuvswxyz'] a1_, a2_, b1_, b2_, c1_, c2_, d1_, d2_, n1_, n2_, e1_, e2_, f1_, f2_, g1_, g2_, n1_, n2_, n3_, Pq_, Pm_, Px_, Qm_, Qr_, Qx_, jn_, mn_, non2_, RFx_, RGx_ = [WC(i) for i in ['a1', 'a2', 'b1', 'b2', 'c1', 'c2', 'd1', 'd2', 'n1', 'n2', 'e1', 'e2', 'f1', 'f2', 'g1', 'g2', 'n1', 'n2', 'n3', 'Pq', 'Pm', 'Px', 'Qm', 'Qr', 'Qx', 'jn', 'mn', 'non2', 'RFx', 'RGx']] i, ii , Pqq, Q, R, r, C, k, u = symbols('i ii Pqq Q R r C k u') _UseGamma = False ShowSteps = False StepCounter = None def cons_f1(a): return ZeroQ(a) cons1 = CustomConstraint(cons_f1) def cons_f2(a, x): return FreeQ(a, x) cons2 = CustomConstraint(cons_f2) def cons_f3(b, x): return FreeQ(b, x) cons3 = CustomConstraint(cons_f3) def cons_f4(n, x): return FreeQ(n, x) cons4 = CustomConstraint(cons_f4) def cons_f5(p, x): return FreeQ(p, x) cons5 = CustomConstraint(cons_f5) def cons_f6(n, j): return ZeroQ(j - S(2)*n) cons6 = CustomConstraint(cons_f6) def cons_f7(c, x): return FreeQ(c, x) cons7 = CustomConstraint(cons_f7) def cons_f8(b): return ZeroQ(b) cons8 = CustomConstraint(cons_f8) def cons_f9(c): return ZeroQ(c) cons9 = CustomConstraint(cons_f9) def cons_f10(v, x): if isinstance(x, (int, Integer, float, Float)): return False return NFreeQ(v, x) cons10 = CustomConstraint(cons_f10) def cons_f11(x, Pm): if isinstance(x, (int, Integer, float, Float)): return False return PolyQ(Pm, x) cons11 = CustomConstraint(cons_f11) def cons_f12(p): return Not(RationalQ(p)) cons12 = CustomConstraint(cons_f12) def cons_f13(p): return RationalQ(p) cons13 = CustomConstraint(cons_f13) def cons_f14(x, c, a, b): if isinstance(x, (int, Integer, float, Float)): return False return FreeQ(List(a, b, c), x) cons14 = CustomConstraint(cons_f14) def cons_f15(a): return EqQ(a**S(2), S(1)) cons15 = CustomConstraint(cons_f15) def cons_f16(u): return SumQ(u) cons16 = CustomConstraint(cons_f16) def cons_f17(m): return IntegerQ(m) cons17 = CustomConstraint(cons_f17) def cons_f18(m): return Not(IntegerQ(m)) cons18 = CustomConstraint(cons_f18) def cons_f19(n): return PositiveIntegerQ(n + S(1)/2) cons19 = CustomConstraint(cons_f19) def cons_f20(m, n): return IntegerQ(m + n) cons20 = CustomConstraint(cons_f20) def cons_f21(m, x): return FreeQ(m, x) cons21 = CustomConstraint(cons_f21) def cons_f22(n): return NegativeIntegerQ(n + S(-1)/2) cons22 = CustomConstraint(cons_f22) def cons_f23(n): return Not(IntegerQ(n)) cons23 = CustomConstraint(cons_f23) def cons_f24(m, n): return Not(IntegerQ(m + n)) cons24 = CustomConstraint(cons_f24) def cons_f25(d, c, b, a): return ZeroQ(-a*d + b*c) cons25 = CustomConstraint(cons_f25) def cons_f26(b, d, c, n, a, x): if isinstance(x, (int, Integer, float, Float)): return False return Or(Not(IntegerQ(n)), SimplerQ(c + d*x, a + b*x)) cons26 = CustomConstraint(cons_f26) def cons_f27(d, x): return FreeQ(d, x) cons27 = CustomConstraint(cons_f27) def cons_f28(d, b): return PositiveQ(b/d) cons28 = CustomConstraint(cons_f28) def cons_f29(m, n): return Not(Or(IntegerQ(m), IntegerQ(n))) cons29 = CustomConstraint(cons_f29) def cons_f30(d, m, n, b): return Not(Or(IntegerQ(m), IntegerQ(n), PositiveQ(b/d))) cons30 = CustomConstraint(cons_f30) def cons_f31(m): return RationalQ(m) cons31 = CustomConstraint(cons_f31) def cons_f32(m): return LessEqual(m, S(-1)) cons32 = CustomConstraint(cons_f32) def cons_f33(B, C, b, a, A): return ZeroQ(A*b**S(2) - B*a*b + C*a**S(2)) cons33 = CustomConstraint(cons_f33) def cons_f34(A, x): return FreeQ(A, x) cons34 = CustomConstraint(cons_f34) def cons_f35(B, x): return FreeQ(B, x) cons35 = CustomConstraint(cons_f35) def cons_f36(C, x): return FreeQ(C, x) cons36 = CustomConstraint(cons_f36) def cons_f37(n, q): return ZeroQ(n + q) cons37 = CustomConstraint(cons_f37) def cons_f38(p): return IntegerQ(p) cons38 = CustomConstraint(cons_f38) def cons_f39(d, a, c, b): return ZeroQ(a*c - b*d) cons39 = CustomConstraint(cons_f39) def cons_f40(m, n): return Not(And(IntegerQ(m), NegQ(n))) cons40 = CustomConstraint(cons_f40) def cons_f41(m, p): return ZeroQ(m + p) cons41 = CustomConstraint(cons_f41) def cons_f42(d, c, b, a): return ZeroQ(a**S(2)*d + b**S(2)*c) cons42 = CustomConstraint(cons_f42) def cons_f43(a): return PositiveQ(a) cons43 = CustomConstraint(cons_f43) def cons_f44(d): return NegativeQ(d) cons44 = CustomConstraint(cons_f44) def cons_f45(c, a, b): return ZeroQ(-S(4)*a*c + b**S(2)) cons45 = CustomConstraint(cons_f45) def cons_f46(n, n2): return ZeroQ(-S(2)*n + n2) cons46 = CustomConstraint(cons_f46) def cons_f47(d, c, b, e): return ZeroQ(-b*e + S(2)*c*d) cons47 = CustomConstraint(cons_f47) def cons_f48(e, x): return FreeQ(e, x) cons48 = CustomConstraint(cons_f48) def cons_f49(p, q): return PosQ(-p + q) cons49 = CustomConstraint(cons_f49) def cons_f50(q, x): return FreeQ(q, x) cons50 = CustomConstraint(cons_f50) def cons_f51(p, r): return PosQ(-p + r) cons51 = CustomConstraint(cons_f51) def cons_f52(r, x): return FreeQ(r, x) cons52 = CustomConstraint(cons_f52) def cons_f53(m, n): return ZeroQ(m - n + S(1)) cons53 = CustomConstraint(cons_f53) def cons_f54(p): return NonzeroQ(p + S(1)) cons54 = CustomConstraint(cons_f54) def cons_f55(b2, a2, a1, b1): return ZeroQ(a1*b2 + a2*b1) cons55 = CustomConstraint(cons_f55) def cons_f56(m, n): return ZeroQ(m - S(2)*n + S(1)) cons56 = CustomConstraint(cons_f56) def cons_f57(a1, x): return FreeQ(a1, x) cons57 = CustomConstraint(cons_f57) def cons_f58(b1, x): return FreeQ(b1, x) cons58 = CustomConstraint(cons_f58) def cons_f59(a2, x): return FreeQ(a2, x) cons59 = CustomConstraint(cons_f59) def cons_f60(b2, x): return FreeQ(b2, x) cons60 = CustomConstraint(cons_f60) def cons_f61(x, Qm): if isinstance(x, (int, Integer, float, Float)): return False return PolyQ(Qm, x) cons61 = CustomConstraint(cons_f61) def cons_f62(m): return PositiveIntegerQ(m) cons62 = CustomConstraint(cons_f62) def cons_f63(p): return NegativeIntegerQ(p) cons63 = CustomConstraint(cons_f63) def cons_f64(x, Pq): if isinstance(x, (int, Integer, float, Float)): return False return PolyQ(Pq, x) cons64 = CustomConstraint(cons_f64) def cons_f65(x, Qr): if isinstance(x, (int, Integer, float, Float)): return False return PolyQ(Qr, x) cons65 = CustomConstraint(cons_f65) def cons_f66(m): return NonzeroQ(m + S(1)) cons66 = CustomConstraint(cons_f66) def cons_f67(x, a, b): if isinstance(x, (int, Integer, float, Float)): return False return FreeQ(List(a, b), x) cons67 = CustomConstraint(cons_f67) def cons_f68(x, u): if isinstance(x, (int, Integer, float, Float)): return False return LinearQ(u, x) cons68 = CustomConstraint(cons_f68) def cons_f69(x, u): if isinstance(x, (int, Integer, float, Float)): return False return NonzeroQ(u - x) cons69 = CustomConstraint(cons_f69) def cons_f70(d, c, b, a): return ZeroQ(a*d + b*c) cons70 = CustomConstraint(cons_f70) def cons_f71(d, c, b, a): return NonzeroQ(-a*d + b*c) cons71 = CustomConstraint(cons_f71) def cons_f72(m, n): return ZeroQ(m + n + S(2)) cons72 = CustomConstraint(cons_f72) def cons_f73(m): return PositiveIntegerQ(m + S(1)/2) cons73 = CustomConstraint(cons_f73) def cons_f74(m): return NegativeIntegerQ(m + S(3)/2) cons74 = CustomConstraint(cons_f74) def cons_f75(m, c, a): return Or(IntegerQ(m), And(PositiveQ(a), PositiveQ(c))) cons75 = CustomConstraint(cons_f75) def cons_f76(a, c): return ZeroQ(a + c) cons76 = CustomConstraint(cons_f76) def cons_f77(m): return Not(IntegerQ(S(2)*m)) cons77 = CustomConstraint(cons_f77) def cons_f78(d, c, a, b): return PosQ(b*d/(a*c)) cons78 = CustomConstraint(cons_f78) def cons_f79(m): return IntegerQ(m + S(1)/2) cons79 = CustomConstraint(cons_f79) def cons_f80(n): return IntegerQ(n + S(1)/2) cons80 = CustomConstraint(cons_f80) def cons_f81(m, n): return Less(S(0), m, n) cons81 = CustomConstraint(cons_f81) def cons_f82(m, n): return Less(m, n, S(0)) cons82 = CustomConstraint(cons_f82) def cons_f83(m, c, n): return Or(Not(IntegerQ(n)), And(ZeroQ(c), LessEqual(S(7)*m + S(4)*n, S(0))), Less(S(9)*m + S(5)*n + S(5), S(0)), Greater(m + n + S(2), S(0))) cons83 = CustomConstraint(cons_f83) def cons_f84(m): return NegativeIntegerQ(m) cons84 = CustomConstraint(cons_f84) def cons_f85(n): return IntegerQ(n) cons85 = CustomConstraint(cons_f85) def cons_f86(m, n): return Not(And(PositiveIntegerQ(n), Less(m + n + S(2), S(0)))) cons86 = CustomConstraint(cons_f86) def cons_f87(n): return RationalQ(n) cons87 = CustomConstraint(cons_f87) def cons_f88(n): return Greater(n, S(0)) cons88 = CustomConstraint(cons_f88) def cons_f89(n): return Less(n, S(-1)) cons89 = CustomConstraint(cons_f89) def cons_f90(d, c, b, a): return PosQ((-a*d + b*c)/b) cons90 = CustomConstraint(cons_f90) def cons_f91(d, c, b, a): return NegQ((-a*d + b*c)/b) cons91 = CustomConstraint(cons_f91) def cons_f92(n): return Less(S(-1), n, S(0)) cons92 = CustomConstraint(cons_f92) def cons_f93(m, n): return RationalQ(m, n) cons93 = CustomConstraint(cons_f93) def cons_f94(m): return Less(m, S(-1)) cons94 = CustomConstraint(cons_f94) def cons_f95(m, n): return Not(And(IntegerQ(n), Not(IntegerQ(m)))) cons95 = CustomConstraint(cons_f95) def cons_f96(m, n): return Not(And(IntegerQ(m + n), LessEqual(m + n + S(2), S(0)), Or(FractionQ(m), GreaterEqual(m + S(2)*n + S(1), S(0))))) cons96 = CustomConstraint(cons_f96) def cons_f97(m, b, d, c, a, n, x): if isinstance(x, (int, Integer, float, Float)): return False return IntLinearcQ(a, b, c, d, m, n, x) cons97 = CustomConstraint(cons_f97) def cons_f98(m, a, n, c): return Not(And(Less(n, S(-1)), Or(ZeroQ(a), And(NonzeroQ(c), Less(m, n), IntegerQ(n))))) cons98 = CustomConstraint(cons_f98) def cons_f99(m, n): return Unequal(m + n + S(1), S(0)) cons99 = CustomConstraint(cons_f99) def cons_f100(m, n): return Not(And(PositiveIntegerQ(m), Or(Not(IntegerQ(n)), Less(S(0), m, n)))) cons100 = CustomConstraint(cons_f100) def cons_f101(m, n): return Not(And(IntegerQ(m + n), Less(m + n + S(2), S(0)))) cons101 = CustomConstraint(cons_f101) def cons_f102(d, b): return ZeroQ(b + d) cons102 = CustomConstraint(cons_f102) def cons_f103(a, c): return PositiveQ(a + c) cons103 = CustomConstraint(cons_f103) def cons_f104(d, c, b, a): return PositiveQ(-a*d + b*c) cons104 = CustomConstraint(cons_f104) def cons_f105(b): return PositiveQ(b) cons105 = CustomConstraint(cons_f105) def cons_f106(d, b): return ZeroQ(b - d) cons106 = CustomConstraint(cons_f106) def cons_f107(m): return Less(S(-1), m, S(0)) cons107 = CustomConstraint(cons_f107) def cons_f108(m): return LessEqual(S(3), Denominator(m), S(4)) cons108 = CustomConstraint(cons_f108) def cons_f109(d, b): return PosQ(d/b) cons109 = CustomConstraint(cons_f109) def cons_f110(d, b): return NegQ(d/b) cons110 = CustomConstraint(cons_f110) def cons_f111(m, n): return Equal(m + n + S(1), S(0)) cons111 = CustomConstraint(cons_f111) def cons_f112(m, n): return LessEqual(Denominator(n), Denominator(m)) cons112 = CustomConstraint(cons_f112) def cons_f113(m, n): return NegativeIntegerQ(m + n + S(2)) cons113 = CustomConstraint(cons_f113) def cons_f114(m, n): return Or(SumSimplerQ(m, S(1)), Not(SumSimplerQ(n, S(1)))) cons114 = CustomConstraint(cons_f114) def cons_f115(d, c, n, b): return Or(IntegerQ(n), And(PositiveQ(c), Not(And(ZeroQ(n + S(1)/2), ZeroQ(c**S(2) - d**S(2)), PositiveQ(-d/(b*c)))))) cons115 = CustomConstraint(cons_f115) def cons_f116(d, c, m, b): return Or(IntegerQ(m), PositiveQ(-d/(b*c))) cons116 = CustomConstraint(cons_f116) def cons_f117(c): return Not(PositiveQ(c)) cons117 = CustomConstraint(cons_f117) def cons_f118(d, c, b): return Not(PositiveQ(-d/(b*c))) cons118 = CustomConstraint(cons_f118) def cons_f119(d, m, n, c): return Or(And(RationalQ(m), Not(And(ZeroQ(n + S(1)/2), ZeroQ(c**S(2) - d**S(2))))), Not(RationalQ(n))) cons119 = CustomConstraint(cons_f119) def cons_f120(d, c, b, a): return PositiveQ(b/(-a*d + b*c)) cons120 = CustomConstraint(cons_f120) def cons_f121(m, b, d, c, n, a): return Or(RationalQ(m), Not(And(RationalQ(n), PositiveQ(-d/(-a*d + b*c))))) cons121 = CustomConstraint(cons_f121) def cons_f122(m, n): return Or(RationalQ(m), Not(SimplerQ(n + S(1), m + S(1)))) cons122 = CustomConstraint(cons_f122) def cons_f123(x, u): if isinstance(x, (int, Integer, float, Float)): return False return NonzeroQ(Coefficient(u, x, S(0))) cons123 = CustomConstraint(cons_f123) def cons_f124(m, n): return ZeroQ(m - n) cons124 = CustomConstraint(cons_f124) def cons_f125(f, x): return FreeQ(f, x) cons125 = CustomConstraint(cons_f125) def cons_f126(p, n): return NonzeroQ(n + p + S(2)) cons126 = CustomConstraint(cons_f126) def cons_f127(p, f, b, d, a, n, c, e): return ZeroQ(a*d*f*(n + p + S(2)) - b*(c*f*(p + S(1)) + d*e*(n + S(1)))) cons127 = CustomConstraint(cons_f127) def cons_f128(p): return PositiveIntegerQ(p) cons128 = CustomConstraint(cons_f128) def cons_f129(a, f, b, e): return ZeroQ(a*f + b*e) cons129 = CustomConstraint(cons_f129) def cons_f130(p, n): return Not(And(NegativeIntegerQ(n + p + S(2)), Greater(n + S(2)*p, S(0)))) cons130 = CustomConstraint(cons_f130) def cons_f131(p, n): return Or(NonzeroQ(n + S(1)), Equal(p, S(1))) cons131 = CustomConstraint(cons_f131) def cons_f132(a, f, b, e): return NonzeroQ(a*f + b*e) cons132 = CustomConstraint(cons_f132) def cons_f133(p, f, b, d, a, n, e): return Or(Not(IntegerQ(n)), Less(S(5)*n + S(9)*p, S(0)), GreaterEqual(n + p + S(1), S(0)), And(GreaterEqual(n + p + S(2), S(0)), RationalQ(a, b, d, e, f))) cons133 = CustomConstraint(cons_f133) def cons_f134(p, f, b, d, c, n, a, e): return Or(NegativeIntegerQ(n, p), ZeroQ(p + S(-1)), And(PositiveIntegerQ(p), Or(Not(IntegerQ(n)), LessEqual(S(5)*n + S(9)*p + S(10), S(0)), GreaterEqual(n + p + S(1), S(0)), And(GreaterEqual(n + p + S(2), S(0)), RationalQ(a, b, c, d, e, f))))) cons134 = CustomConstraint(cons_f134) def cons_f135(p, n): return ZeroQ(n + p + S(2)) cons135 = CustomConstraint(cons_f135) def cons_f136(p, n): return Not(And(SumSimplerQ(n, S(1)), Not(SumSimplerQ(p, S(1))))) cons136 = CustomConstraint(cons_f136) def cons_f137(p): return Less(p, S(-1)) cons137 = CustomConstraint(cons_f137) def cons_f138(p, n, c, e): return Or(Not(And(RationalQ(n), Less(n, S(-1)))), IntegerQ(p), Not(Or(IntegerQ(n), Not(Or(ZeroQ(e), Not(Or(ZeroQ(c), Less(p, n)))))))) cons138 = CustomConstraint(cons_f138) def cons_f139(p): return SumSimplerQ(p, S(1)) cons139 = CustomConstraint(cons_f139) def cons_f140(p, n): return NonzeroQ(n + p + S(3)) cons140 = CustomConstraint(cons_f140) def cons_f141(p, f, b, d, a, n, c, e): return ZeroQ(-b*(c*f*(p + S(1)) + d*e*(n + S(1)))*(a*d*f*(n + p + S(4)) - b*(c*f*(p + S(2)) + d*e*(n + S(2)))) + d*f*(a**S(2)*d*f*(n + p + S(3)) - b*(a*(c*f*(p + S(1)) + d*e*(n + S(1))) + b*c*e))*(n + p + S(2))) cons141 = CustomConstraint(cons_f141) def cons_f142(m, n): return ZeroQ(m - n + S(-1)) cons142 = CustomConstraint(cons_f142) def cons_f143(m): return Not(PositiveIntegerQ(m)) cons143 = CustomConstraint(cons_f143) def cons_f144(m, n, p): return NonzeroQ(m + n + p + S(2)) cons144 = CustomConstraint(cons_f144) def cons_f145(p): return Less(S(0), p, S(1)) cons145 = CustomConstraint(cons_f145) def cons_f146(p): return Greater(p, S(1)) cons146 = CustomConstraint(cons_f146) def cons_f147(p): return Not(IntegerQ(p)) cons147 = CustomConstraint(cons_f147) def cons_f148(n): return PositiveIntegerQ(n) cons148 = CustomConstraint(cons_f148) def cons_f149(p): return FractionQ(p) cons149 = CustomConstraint(cons_f149) def cons_f150(m, n): return IntegersQ(m, n) cons150 = CustomConstraint(cons_f150) def cons_f151(m, p, n): return Or(IntegerQ(p), And(Greater(m, S(0)), GreaterEqual(n, S(-1)))) cons151 = CustomConstraint(cons_f151) def cons_f152(p, n): return Or(And(RationalQ(n), Less(n, S(-1))), And(ZeroQ(n + p + S(3)), NonzeroQ(n + S(1)), Or(SumSimplerQ(n, S(1)), Not(SumSimplerQ(p, S(1)))))) cons152 = CustomConstraint(cons_f152) def cons_f153(f, b, d, c, a, x, e): if isinstance(x, (int, Integer, float, Float)): return False return FreeQ(List(a, b, c, d, e, f), x) cons153 = CustomConstraint(cons_f153) def cons_f154(f, b, d, c, a, e): return ZeroQ(S(2)*b*d*e - f*(a*d + b*c)) cons154 = CustomConstraint(cons_f154) def cons_f155(m, n): return ZeroQ(m + n + S(1)) cons155 = CustomConstraint(cons_f155) def cons_f156(b, d, c, a, x): if isinstance(x, (int, Integer, float, Float)): return False return SimplerQ(a + b*x, c + d*x) cons156 = CustomConstraint(cons_f156) def cons_f157(m, n, p): return ZeroQ(m + n + p + S(2)) cons157 = CustomConstraint(cons_f157) def cons_f158(m, p): return Not(And(SumSimplerQ(p, S(1)), Not(SumSimplerQ(m, S(1))))) cons158 = CustomConstraint(cons_f158) def cons_f159(m, n, p): return ZeroQ(m + n + p + S(3)) cons159 = CustomConstraint(cons_f159) def cons_f160(p, m, f, b, d, a, c, n, e): return ZeroQ(a*d*f*(m + S(1)) + b*c*f*(n + S(1)) + b*d*e*(p + S(1))) cons160 = CustomConstraint(cons_f160) def cons_f161(m): return Or(And(RationalQ(m), Less(m, S(-1))), SumSimplerQ(m, S(1))) cons161 = CustomConstraint(cons_f161) def cons_f162(m, n, p): return RationalQ(m, n, p) cons162 = CustomConstraint(cons_f162) def cons_f163(p): return Greater(p, S(0)) cons163 = CustomConstraint(cons_f163) def cons_f164(m, n, p): return Or(IntegersQ(S(2)*m, S(2)*n, S(2)*p), IntegersQ(m, n + p), IntegersQ(p, m + n)) cons164 = CustomConstraint(cons_f164) def cons_f165(n): return Greater(n, S(1)) cons165 = CustomConstraint(cons_f165) def cons_f166(m): return Greater(m, S(1)) cons166 = CustomConstraint(cons_f166) def cons_f167(m, n, p): return NonzeroQ(m + n + p + S(1)) cons167 = CustomConstraint(cons_f167) def cons_f168(m): return Greater(m, S(0)) cons168 = CustomConstraint(cons_f168) def cons_f169(m, n, p): return Or(IntegersQ(S(2)*m, S(2)*n, S(2)*p), Or(IntegersQ(m, n + p), IntegersQ(p, m + n))) cons169 = CustomConstraint(cons_f169) def cons_f170(m, n, p): return IntegersQ(S(2)*m, S(2)*n, S(2)*p) cons170 = CustomConstraint(cons_f170) def cons_f171(p, n): return Or(IntegerQ(n), IntegersQ(S(2)*n, S(2)*p)) cons171 = CustomConstraint(cons_f171) def cons_f172(m, n): return PositiveIntegerQ(m + n + S(1)) cons172 = CustomConstraint(cons_f172) def cons_f173(m, n): return Or(And(RationalQ(m), Greater(m, S(0))), And(Not(RationalQ(m)), Or(SumSimplerQ(m, S(-1)), Not(SumSimplerQ(n, S(-1)))))) cons173 = CustomConstraint(cons_f173) def cons_f174(d, c, f, e): return PositiveQ(-f/(-c*f + d*e)) cons174 = CustomConstraint(cons_f174) def cons_f175(d, c, f, e): return Not(PositiveQ(-f/(-c*f + d*e))) cons175 = CustomConstraint(cons_f175) def cons_f176(d, c, f, e): return NonzeroQ(-c*f + d*e) cons176 = CustomConstraint(cons_f176) def cons_f177(c): return PositiveQ(c) cons177 = CustomConstraint(cons_f177) def cons_f178(e): return PositiveQ(e) cons178 = CustomConstraint(cons_f178) def cons_f179(d, b): return Not(NegativeQ(-b/d)) cons179 = CustomConstraint(cons_f179) def cons_f180(d, b): return NegativeQ(-b/d) cons180 = CustomConstraint(cons_f180) def cons_f181(c, e): return Not(And(PositiveQ(c), PositiveQ(e))) cons181 = CustomConstraint(cons_f181) def cons_f182(a, f, b, e): return PositiveQ(b/(-a*f + b*e)) cons182 = CustomConstraint(cons_f182) def cons_f183(d, c, b, a): return Not(NegativeQ(-(-a*d + b*c)/d)) cons183 = CustomConstraint(cons_f183) def cons_f184(f, b, d, c, a, x, e): if isinstance(x, (int, Integer, float, Float)): return False return Not(And(SimplerQ(c + d*x, a + b*x), PositiveQ(-d/(-a*d + b*c)), PositiveQ(d/(-c*f + d*e)), Not(NegativeQ((-a*d + b*c)/b)))) cons184 = CustomConstraint(cons_f184) def cons_f185(f, b, d, c, a, e): return Not(And(PositiveQ(b/(-a*d + b*c)), PositiveQ(b/(-a*f + b*e)))) cons185 = CustomConstraint(cons_f185) def cons_f186(d, f, b): return Or(PositiveQ(-b/d), NegativeQ(-b/f)) cons186 = CustomConstraint(cons_f186) def cons_f187(d, f, b): return Or(PosQ(-b/d), NegQ(-b/f)) cons187 = CustomConstraint(cons_f187) def cons_f188(f, b, a, x, e): if isinstance(x, (int, Integer, float, Float)): return False return SimplerQ(a + b*x, e + f*x) cons188 = CustomConstraint(cons_f188) def cons_f189(f, b, d, c, a, e): return Or(PositiveQ(-(-a*d + b*c)/d), NegativeQ(-(-a*f + b*e)/f)) cons189 = CustomConstraint(cons_f189) def cons_f190(f, b, d, c, a, e): return Or(PosQ(-(-a*d + b*c)/d), NegQ(-(-a*f + b*e)/f)) cons190 = CustomConstraint(cons_f190) def cons_f191(f, b, d, c, a, e): return ZeroQ(-a*d*f - b*c*f + S(2)*b*d*e) cons191 = CustomConstraint(cons_f191) def cons_f192(m, n): return PositiveIntegerQ(m - n) cons192 = CustomConstraint(cons_f192) def cons_f193(m, n): return Or(PositiveIntegerQ(m), NegativeIntegerQ(m, n)) cons193 = CustomConstraint(cons_f193) def cons_f194(m, n, p): return NegativeIntegerQ(m + n + p + S(2)) cons194 = CustomConstraint(cons_f194) def cons_f195(m, n, p): return Or(SumSimplerQ(m, S(1)), And(Not(And(NonzeroQ(n + S(1)), SumSimplerQ(n, S(1)))), Not(And(NonzeroQ(p + S(1)), SumSimplerQ(p, S(1)))))) cons195 = CustomConstraint(cons_f195) def cons_f196(n): return NegativeIntegerQ(n) cons196 = CustomConstraint(cons_f196) def cons_f197(p, e): return Or(IntegerQ(p), PositiveQ(e)) cons197 = CustomConstraint(cons_f197) def cons_f198(d, c, b): return PositiveQ(-d/(b*c)) cons198 = CustomConstraint(cons_f198) def cons_f199(p, f, d, c, e): return Or(IntegerQ(p), PositiveQ(d/(-c*f + d*e))) cons199 = CustomConstraint(cons_f199) def cons_f200(b, d, a, c, x): if isinstance(x, (int, Integer, float, Float)): return False return Not(And(PositiveQ(d/(a*d - b*c)), SimplerQ(c + d*x, a + b*x))) cons200 = CustomConstraint(cons_f200) def cons_f201(d, c, b, a): return Not(PositiveQ(b/(-a*d + b*c))) cons201 = CustomConstraint(cons_f201) def cons_f202(b, d, c, a, x): if isinstance(x, (int, Integer, float, Float)): return False return Not(SimplerQ(c + d*x, a + b*x)) cons202 = CustomConstraint(cons_f202) def cons_f203(f, b, d, a, c, x, e): if isinstance(x, (int, Integer, float, Float)): return False return Not(And(PositiveQ(d/(a*d - b*c)), PositiveQ(d/(-c*f + d*e)), SimplerQ(c + d*x, a + b*x))) cons203 = CustomConstraint(cons_f203) def cons_f204(f, b, d, c, a, x, e): if isinstance(x, (int, Integer, float, Float)): return False return Not(And(PositiveQ(f/(a*f - b*e)), PositiveQ(f/(c*f - d*e)), SimplerQ(e + f*x, a + b*x))) cons204 = CustomConstraint(cons_f204) def cons_f205(a, f, b, e): return Not(PositiveQ(b/(-a*f + b*e))) cons205 = CustomConstraint(cons_f205) def cons_f206(f, b, a, x, e): if isinstance(x, (int, Integer, float, Float)): return False return Not(SimplerQ(e + f*x, a + b*x)) cons206 = CustomConstraint(cons_f206) def cons_f207(m, n): return Or(PositiveIntegerQ(m), IntegersQ(m, n)) cons207 = CustomConstraint(cons_f207) def cons_f208(g, x): return FreeQ(g, x) cons208 = CustomConstraint(cons_f208) def cons_f209(h, x): return FreeQ(h, x) cons209 = CustomConstraint(cons_f209) def cons_f210(m, n): return Not(And(SumSimplerQ(n, S(1)), Not(SumSimplerQ(m, S(1))))) cons210 = CustomConstraint(cons_f210) def cons_f211(m, n): return Or(And(RationalQ(m), Less(m, S(-2))), And(ZeroQ(m + n + S(3)), Not(And(RationalQ(n), Less(n, S(-2)))))) cons211 = CustomConstraint(cons_f211) def cons_f212(m): return Or(And(RationalQ(m), Inequality(S(-2), LessEqual, m, Less, S(-1))), SumSimplerQ(m, S(1))) cons212 = CustomConstraint(cons_f212) def cons_f213(m, n): return NonzeroQ(m + n + S(3)) cons213 = CustomConstraint(cons_f213) def cons_f214(m, n): return NonzeroQ(m + n + S(2)) cons214 = CustomConstraint(cons_f214) def cons_f215(m, n, p): return Or(IntegersQ(m, n, p), PositiveIntegerQ(n, p)) cons215 = CustomConstraint(cons_f215) def cons_f216(f, b, g, d, c, a, x, h, e): if isinstance(x, (int, Integer, float, Float)): return False return FreeQ(List(a, b, c, d, e, f, g, h), x) cons216 = CustomConstraint(cons_f216) def cons_f217(p, f, b, g, d, c, a, n, x, h, e): if isinstance(x, (int, Integer, float, Float)): return False return FreeQ(List(a, b, c, d, e, f, g, h, n, p), x) cons217 = CustomConstraint(cons_f217) def cons_f218(f, d, c, x, e): if isinstance(x, (int, Integer, float, Float)): return False return SimplerQ(c + d*x, e + f*x) cons218 = CustomConstraint(cons_f218) def cons_f219(m, n, p): return Or(SumSimplerQ(m, S(1)), And(Not(SumSimplerQ(n, S(1))), Not(SumSimplerQ(p, S(1))))) cons219 = CustomConstraint(cons_f219) def cons_f220(p, q): return IntegersQ(p, q) cons220 = CustomConstraint(cons_f220) def cons_f221(q): return PositiveIntegerQ(q) cons221 = CustomConstraint(cons_f221) def cons_f222(p, m, f, b, g, d, c, a, n, x, h, q, e): if isinstance(x, (int, Integer, float, Float)): return False return FreeQ(List(a, b, c, d, e, f, g, h, m, n, p, q), x) cons222 = CustomConstraint(cons_f222) def cons_f223(p, m, f, b, g, r, i, d, c, a, n, x, h, q, e): if isinstance(x, (int, Integer, float, Float)): return False return FreeQ(List(a, b, c, d, e, f, g, h, i, m, n, p, q, r), x) cons223 = CustomConstraint(cons_f223) def cons_f224(i, x): return FreeQ(i, x) cons224 = CustomConstraint(cons_f224) def cons_f225(p): return NonzeroQ(S(2)*p + S(1)) cons225 = CustomConstraint(cons_f225) def cons_f226(c, a, b): return NonzeroQ(-S(4)*a*c + b**S(2)) cons226 = CustomConstraint(cons_f226) def cons_f227(c, a, b): return PerfectSquareQ(-S(4)*a*c + b**S(2)) cons227 = CustomConstraint(cons_f227) def cons_f228(c, a, b): return Not(PerfectSquareQ(-S(4)*a*c + b**S(2))) cons228 = CustomConstraint(cons_f228) def cons_f229(p): return IntegerQ(S(4)*p) cons229 = CustomConstraint(cons_f229) def cons_f230(p): return Unequal(p, S(-3)/2) cons230 = CustomConstraint(cons_f230) def cons_f231(c, a, b): return PosQ(-S(4)*a*c + b**S(2)) cons231 = CustomConstraint(cons_f231) def cons_f232(c, a, b): return PositiveQ(S(4)*a - b**S(2)/c) cons232 = CustomConstraint(cons_f232) def cons_f233(x, c, b): if isinstance(x, (int, Integer, float, Float)): return False return FreeQ(List(b, c), x) cons233 = CustomConstraint(cons_f233) def cons_f234(p): return LessEqual(S(3), Denominator(p), S(4)) cons234 = CustomConstraint(cons_f234) def cons_f235(p): return Not(IntegerQ(S(4)*p)) cons235 = CustomConstraint(cons_f235) def cons_f236(m): return IntegerQ(m/S(2) + S(1)/2) cons236 = CustomConstraint(cons_f236) def cons_f237(m, p): return ZeroQ(m + S(2)*p + S(1)) cons237 = CustomConstraint(cons_f237) def cons_f238(m, p): return NonzeroQ(m + S(2)*p + S(1)) cons238 = CustomConstraint(cons_f238) def cons_f239(d, c, b, e): return NonzeroQ(-b*e + S(2)*c*d) cons239 = CustomConstraint(cons_f239) def cons_f240(m, p): return ZeroQ(m + S(2)*p + S(2)) cons240 = CustomConstraint(cons_f240) def cons_f241(m): return NonzeroQ(m + S(2)) cons241 = CustomConstraint(cons_f241) def cons_f242(m, p): return ZeroQ(m + S(2)*p + S(3)) cons242 = CustomConstraint(cons_f242) def cons_f243(p): return NonzeroQ(p + S(3)/2) cons243 = CustomConstraint(cons_f243) def cons_f244(m, p): return RationalQ(m, p) cons244 = CustomConstraint(cons_f244) def cons_f245(m): return Inequality(S(-2), LessEqual, m, Less, S(-1)) cons245 = CustomConstraint(cons_f245) def cons_f246(p): return IntegerQ(S(2)*p) cons246 = CustomConstraint(cons_f246) def cons_f247(m): return Less(m, S(-2)) cons247 = CustomConstraint(cons_f247) def cons_f248(m, p): return Not(And(NegativeIntegerQ(m + S(2)*p + S(3)), Greater(m + S(3)*p + S(3), S(0)))) cons248 = CustomConstraint(cons_f248) def cons_f249(m, p): return NonzeroQ(m + S(2)*p) cons249 = CustomConstraint(cons_f249) def cons_f250(m): return Not(And(RationalQ(m), Less(m, S(-2)))) cons250 = CustomConstraint(cons_f250) def cons_f251(m, p): return Not(And(IntegerQ(m), Less(S(0), m, S(2)*p))) cons251 = CustomConstraint(cons_f251) def cons_f252(m): return Inequality(S(0), Less, m, LessEqual, S(1)) cons252 = CustomConstraint(cons_f252) def cons_f253(m, p): return NonzeroQ(m + p + S(1)) cons253 = CustomConstraint(cons_f253) def cons_f254(m, p): return Or(Not(RationalQ(p)), Inequality(S(-1), LessEqual, p, Less, S(0)), And(IntegerQ(m), Less(S(0), m, S(2)*p)), And(Equal(m, S(1)/2), Less(p, S(0)))) cons254 = CustomConstraint(cons_f254) def cons_f255(m, p): return Or(IntegerQ(m), IntegerQ(S(2)*p)) cons255 = CustomConstraint(cons_f255) def cons_f256(b, d, c, a, e): return ZeroQ(a*e**S(2) - b*d*e + c*d**S(2)) cons256 = CustomConstraint(cons_f256) def cons_f257(d, c, e, a): return ZeroQ(a*e**S(2) + c*d**S(2)) cons257 = CustomConstraint(cons_f257) def cons_f258(d, m, a, p): return Or(IntegerQ(p), And(PositiveQ(a), PositiveQ(d), IntegerQ(m + p))) cons258 = CustomConstraint(cons_f258) def cons_f259(m, p): return Or(Less(S(0), -m, p), Less(p, -m, S(0))) cons259 = CustomConstraint(cons_f259) def cons_f260(m): return Unequal(m, S(2)) cons260 = CustomConstraint(cons_f260) def cons_f261(m): return Unequal(m, S(-1)) cons261 = CustomConstraint(cons_f261) def cons_f262(m, p): return PositiveIntegerQ(m + p) cons262 = CustomConstraint(cons_f262) def cons_f263(m, p): return NegativeIntegerQ(m + S(2)*p + S(2)) cons263 = CustomConstraint(cons_f263) def cons_f264(m, p): return Or(Less(m, S(-2)), ZeroQ(m + S(2)*p + S(1))) cons264 = CustomConstraint(cons_f264) def cons_f265(m, p): return Or(Inequality(S(-2), LessEqual, m, Less, S(0)), Equal(m + p + S(1), S(0))) cons265 = CustomConstraint(cons_f265) def cons_f266(m): return GreaterEqual(m, S(1)) cons266 = CustomConstraint(cons_f266) def cons_f267(m): return Less(m, S(0)) cons267 = CustomConstraint(cons_f267) def cons_f268(d): return PositiveQ(d) cons268 = CustomConstraint(cons_f268) def cons_f269(m, p): return Not(And(ZeroQ(m + S(-3)), Unequal(p, S(1)))) cons269 = CustomConstraint(cons_f269) def cons_f270(m, p): return NonzeroQ(m + S(2)*p + S(3)) cons270 = CustomConstraint(cons_f270) def cons_f271(m, p): return Not(And(EvenQ(m), Less(m + S(2)*p + S(3), S(0)))) cons271 = CustomConstraint(cons_f271) def cons_f272(m): return Not(And(RationalQ(m), Less(m, S(-1)))) cons272 = CustomConstraint(cons_f272) def cons_f273(m, p): return Not(And(PositiveIntegerQ(m/S(2) + S(-1)/2), Or(Not(IntegerQ(p)), Less(m, S(2)*p)))) cons273 = CustomConstraint(cons_f273) def cons_f274(m): return Not(And(RationalQ(m), Greater(m, S(1)))) cons274 = CustomConstraint(cons_f274) def cons_f275(c, b, a): return NegativeQ(c/(-S(4)*a*c + b**S(2))) cons275 = CustomConstraint(cons_f275) def cons_f276(m): return EqQ(m**S(2), S(1)/4) cons276 = CustomConstraint(cons_f276) def cons_f277(m, p): return Or(IntegerQ(S(2)*p), And(IntegerQ(m), RationalQ(p)), OddQ(m)) cons277 = CustomConstraint(cons_f277) def cons_f278(m, p): return Or(IntegerQ(S(2)*p), And(IntegerQ(m), RationalQ(p)), IntegerQ(m/S(2) + p + S(3)/2)) cons278 = CustomConstraint(cons_f278) def cons_f279(b, d, c, a, e): return NonzeroQ(a*e**S(2) - b*d*e + c*d**S(2)) cons279 = CustomConstraint(cons_f279) def cons_f280(d, c, e, a): return NonzeroQ(a*e**S(2) + c*d**S(2)) cons280 = CustomConstraint(cons_f280) def cons_f281(m, p): return Not(And(ZeroQ(m + S(-1)), Greater(p, S(1)))) cons281 = CustomConstraint(cons_f281) def cons_f282(c, a, b): return NiceSqrtQ(-S(4)*a*c + b**S(2)) cons282 = CustomConstraint(cons_f282) def cons_f283(a, c): return NiceSqrtQ(-a*c) cons283 = CustomConstraint(cons_f283) def cons_f284(c, a, b): return Not(NiceSqrtQ(-S(4)*a*c + b**S(2))) cons284 = CustomConstraint(cons_f284) def cons_f285(a, c): return Not(NiceSqrtQ(-a*c)) cons285 = CustomConstraint(cons_f285) def cons_f286(d, m): return Or(NonzeroQ(d), Greater(m, S(2))) cons286 = CustomConstraint(cons_f286) def cons_f287(p): return Not(And(RationalQ(p), LessEqual(p, S(-1)))) cons287 = CustomConstraint(cons_f287) def cons_f288(d, a, b, e): return ZeroQ(a*e + b*d) cons288 = CustomConstraint(cons_f288) def cons_f289(d, c, b, e): return ZeroQ(b*e + c*d) cons289 = CustomConstraint(cons_f289) def cons_f290(m, p): return PositiveIntegerQ(m - p + S(1)) cons290 = CustomConstraint(cons_f290) def cons_f291(d, c, b, e): return NonzeroQ(-b*e + c*d) cons291 = CustomConstraint(cons_f291) def cons_f292(m): return Equal(m**S(2), S(1)/4) cons292 = CustomConstraint(cons_f292) def cons_f293(c): return NegativeQ(c) cons293 = CustomConstraint(cons_f293) def cons_f294(b): return RationalQ(b) cons294 = CustomConstraint(cons_f294) def cons_f295(m): return ZeroQ(m**S(2) + S(-1)/4) cons295 = CustomConstraint(cons_f295) def cons_f296(m, p): return Equal(m + S(2)*p + S(2), S(0)) cons296 = CustomConstraint(cons_f296) def cons_f297(d, a, c, x, e): if isinstance(x, (int, Integer, float, Float)): return False return FreeQ(List(a, c, d, e), x) cons297 = CustomConstraint(cons_f297) def cons_f298(m, p): return Or(IntegerQ(p), And(RationalQ(m), Less(m, S(-1)))) cons298 = CustomConstraint(cons_f298) def cons_f299(m, p): return Not(NegativeIntegerQ(m + S(2)*p + S(1))) cons299 = CustomConstraint(cons_f299) def cons_f300(p, m, b, d, c, a, x, e): if isinstance(x, (int, Integer, float, Float)): return False return IntQuadraticQ(a, b, c, d, e, m, p, x) cons300 = CustomConstraint(cons_f300) def cons_f301(p, m, d, a, c, x, e): if isinstance(x, (int, Integer, float, Float)): return False return IntQuadraticQ(a, S(0), c, d, e, m, p, x) cons301 = CustomConstraint(cons_f301) def cons_f302(m): return Or(Not(RationalQ(m)), Less(m, S(1))) cons302 = CustomConstraint(cons_f302) def cons_f303(m, p): return Not(NegativeIntegerQ(m + S(2)*p)) cons303 = CustomConstraint(cons_f303) def cons_f304(m, p): return Or(Less(m, S(1)), And(NegativeIntegerQ(m + S(2)*p + S(3)), Unequal(m, S(2)))) cons304 = CustomConstraint(cons_f304) def cons_f305(m): return If(RationalQ(m), Greater(m, S(1)), SumSimplerQ(m, S(-2))) cons305 = CustomConstraint(cons_f305) def cons_f306(p, m, b, d, c, a, x, e): if isinstance(x, (int, Integer, float, Float)): return False return Or(And(RationalQ(m), Less(m, S(-1)), IntQuadraticQ(a, b, c, d, e, m, p, x)), And(SumSimplerQ(m, S(1)), IntegerQ(p), NonzeroQ(m + S(1))), And(NegativeIntegerQ(m + S(2)*p + S(3)), NonzeroQ(m + S(1)))) cons306 = CustomConstraint(cons_f306) def cons_f307(p, m, d, c, a, x, e): if isinstance(x, (int, Integer, float, Float)): return False return Or(And(RationalQ(m), Less(m, S(-1)), IntQuadraticQ(a, S(0), c, d, e, m, p, x)), And(SumSimplerQ(m, S(1)), IntegerQ(p), NonzeroQ(m + S(1))), And(NegativeIntegerQ(m + S(2)*p + S(3)), NonzeroQ(m + S(1)))) cons307 = CustomConstraint(cons_f307) def cons_f308(b, d, c, a, e): return ZeroQ(-S(3)*a*c*e**S(2) + b**S(2)*e**S(2) - b*c*d*e + c**S(2)*d**S(2)) cons308 = CustomConstraint(cons_f308) def cons_f309(d, c, b, e): return PosQ(c*e**S(2)*(-b*e + S(2)*c*d)) cons309 = CustomConstraint(cons_f309) def cons_f310(d, c, e, a): return ZeroQ(-S(3)*a*e**S(2) + c*d**S(2)) cons310 = CustomConstraint(cons_f310) def cons_f311(d, c, b, e): return NegQ(c*e**S(2)*(-b*e + S(2)*c*d)) cons311 = CustomConstraint(cons_f311) def cons_f312(b, d, c, a, e): return ZeroQ(S(9)*a*c*e**S(2) - S(2)*b**S(2)*e**S(2) - b*c*d*e + c**S(2)*d**S(2)) cons312 = CustomConstraint(cons_f312) def cons_f313(c, a, b): return Not(PositiveQ(S(4)*a - b**S(2)/c)) cons313 = CustomConstraint(cons_f313) def cons_f314(p): return Not(IntegerQ(S(2)*p)) cons314 = CustomConstraint(cons_f314) def cons_f315(d, f, e, g): return NonzeroQ(-d*g + e*f) cons315 = CustomConstraint(cons_f315) def cons_f316(c, f, b, g): return ZeroQ(-b*g + S(2)*c*f) cons316 = CustomConstraint(cons_f316) def cons_f317(m): return Not(And(RationalQ(m), Greater(m, S(0)))) cons317 = CustomConstraint(cons_f317) def cons_f318(m, p): return Or(Not(RationalQ(p)), And(Greater(p, S(0)), Or(Not(IntegerQ(m)), GreaterEqual(m, -S(2)*p + S(-2)), Less(m, -S(4)*p + S(-4))))) cons318 = CustomConstraint(cons_f318) def cons_f319(m, p): return NonzeroQ(m + S(2)*p + S(2)) cons319 = CustomConstraint(cons_f319) def cons_f320(m, p): return Or(Not(RationalQ(p)), Less(m, S(2)*p + S(2))) cons320 = CustomConstraint(cons_f320) def cons_f321(c, f, b, g): return NonzeroQ(-b*g + S(2)*c*f) cons321 = CustomConstraint(cons_f321) def cons_f322(p): return Less(p, S(0)) cons322 = CustomConstraint(cons_f322) def cons_f323(p, m, b, d, c, e): return Or(And(ZeroQ(m + S(2)*p + S(2)), NonzeroQ(m + S(1))), And(ZeroQ(-b*e + S(2)*c*d), NonzeroQ(m + S(-1)))) cons323 = CustomConstraint(cons_f323) def cons_f324(m, f, g, d, x, e): if isinstance(x, (int, Integer, float, Float)): return False return Not(And(ZeroQ(m + S(-1)), SimplerQ(f + g*x, d + e*x))) cons324 = CustomConstraint(cons_f324) def cons_f325(d, m, a, p): return Or(IntegerQ(p), And(PositiveQ(a), PositiveQ(d), ZeroQ(m + p))) cons325 = CustomConstraint(cons_f325) def cons_f326(p, m, g, b, f, d, c, e): return ZeroQ(e*(p + S(1))*(-b*g + S(2)*c*f) + m*(c*e*f + g*(-b*e + c*d))) cons326 = CustomConstraint(cons_f326) def cons_f327(p, m, f, g, d, e): return ZeroQ(S(2)*e*f*(p + S(1)) + m*(d*g + e*f)) cons327 = CustomConstraint(cons_f327) def cons_f328(m): return SumSimplerQ(m, S(-1)) cons328 = CustomConstraint(cons_f328) def cons_f329(m, p): return Or(And(RationalQ(m), Less(m, S(-1)), Not(PositiveIntegerQ(m + p + S(1)))), And(RationalQ(m, p), Less(m, S(0)), Less(p, S(-1))), ZeroQ(m + S(2)*p + S(2))) cons329 = CustomConstraint(cons_f329) def cons_f330(f, a, g, c): return ZeroQ(a*g**S(2) + c*f**S(2)) cons330 = CustomConstraint(cons_f330) def cons_f331(p): return Less(p, S(-2)) cons331 = CustomConstraint(cons_f331) def cons_f332(m, p): return Or(Less(S(0), -m, p + S(1)), Less(p, -m, S(0))) cons332 = CustomConstraint(cons_f332) def cons_f333(p, n): return NegativeIntegerQ(n + S(2)*p) cons333 = CustomConstraint(cons_f333) def cons_f334(f, g, b, d, c, e): return ZeroQ(-b*e*g + c*d*g + c*e*f) cons334 = CustomConstraint(cons_f334) def cons_f335(m, n): return NonzeroQ(m - n + S(-1)) cons335 = CustomConstraint(cons_f335) def cons_f336(d, f, e, g): return ZeroQ(d*g + e*f) cons336 = CustomConstraint(cons_f336) def cons_f337(m, n): return ZeroQ(m - n + S(-2)) cons337 = CustomConstraint(cons_f337) def cons_f338(p, n): return RationalQ(n, p) cons338 = CustomConstraint(cons_f338) def cons_f339(p, n): return Not(And(IntegerQ(n + p), LessEqual(n + p + S(2), S(0)))) cons339 = CustomConstraint(cons_f339) def cons_f340(n): return Not(PositiveIntegerQ(n)) cons340 = CustomConstraint(cons_f340) def cons_f341(p, n): return Not(And(IntegerQ(n + p), Less(n + p + S(2), S(0)))) cons341 = CustomConstraint(cons_f341) def cons_f342(p, n): return Or(IntegerQ(S(2)*p), IntegerQ(n)) cons342 = CustomConstraint(cons_f342) def cons_f343(m, p): return ZeroQ(m + p + S(-1)) cons343 = CustomConstraint(cons_f343) def cons_f344(p, g, b, f, d, c, n, e): return ZeroQ(b*e*g*(n + S(1)) - c*d*g*(S(2)*n + p + S(3)) + c*e*f*(p + S(1))) cons344 = CustomConstraint(cons_f344) def cons_f345(p, f, g, d, n, e): return ZeroQ(-d*g*(S(2)*n + p + S(3)) + e*f*(p + S(1))) cons345 = CustomConstraint(cons_f345) def cons_f346(n): return Not(And(RationalQ(n), Less(n, S(-1)))) cons346 = CustomConstraint(cons_f346) def cons_f347(p): return IntegerQ(p + S(-1)/2) cons347 = CustomConstraint(cons_f347) def cons_f348(m, p): return Not(And(Less(m, S(0)), Less(p, S(0)))) cons348 = CustomConstraint(cons_f348) def cons_f349(p): return Unequal(p, S(1)/2) cons349 = CustomConstraint(cons_f349) def cons_f350(f, b, g, d, c, a, e): return ZeroQ(-S(2)*a*e*g + b*(d*g + e*f) - S(2)*c*d*f) cons350 = CustomConstraint(cons_f350) def cons_f351(f, g, d, c, a, e): return ZeroQ(a*e*g + c*d*f) cons351 = CustomConstraint(cons_f351) def cons_f352(m, b, d, c, e): return Not(And(Equal(m, S(1)), Or(ZeroQ(d), ZeroQ(-b*e + S(2)*c*d)))) cons352 = CustomConstraint(cons_f352) def cons_f353(d, m): return Not(And(Equal(m, S(1)), ZeroQ(d))) cons353 = CustomConstraint(cons_f353) def cons_f354(p, g, b, f, d, a, c, e): return ZeroQ(-S(2)*a*c*e*g + b**S(2)*e*g*(p + S(2)) + c*(S(2)*p + S(3))*(-b*(d*g + e*f) + S(2)*c*d*f)) cons354 = CustomConstraint(cons_f354) def cons_f355(p, g, f, d, a, c, e): return ZeroQ(a*e*g - c*d*f*(S(2)*p + S(3))) cons355 = CustomConstraint(cons_f355) def cons_f356(m): return Not(RationalQ(m)) cons356 = CustomConstraint(cons_f356) def cons_f357(p): return Not(PositiveIntegerQ(p)) cons357 = CustomConstraint(cons_f357) def cons_f358(m, p): return ZeroQ(m - p) cons358 = CustomConstraint(cons_f358) def cons_f359(m, p): return Less(m + S(2)*p, S(0)) cons359 = CustomConstraint(cons_f359) def cons_f360(m, p): return Not(NegativeIntegerQ(m + S(2)*p + S(3))) cons360 = CustomConstraint(cons_f360) def cons_f361(m, p): return Or(And(RationalQ(m), Less(m, S(-1))), Equal(p, S(1)), And(IntegerQ(p), Not(RationalQ(m)))) cons361 = CustomConstraint(cons_f361) def cons_f362(m, p): return Or(IntegerQ(m), IntegerQ(p), IntegersQ(S(2)*m, S(2)*p)) cons362 = CustomConstraint(cons_f362) def cons_f363(m, p): return Or(IntegerQ(p), Not(RationalQ(m)), Inequality(S(-1), LessEqual, m, Less, S(0))) cons363 = CustomConstraint(cons_f363) def cons_f364(p, m, f, b, g, d, c, a, e): return Or(And(Equal(m, S(2)), Equal(p, S(-3)), RationalQ(a, b, c, d, e, f, g)), Not(NegativeIntegerQ(m + S(2)*p + S(3)))) cons364 = CustomConstraint(cons_f364) def cons_f365(p, m, f, g, d, c, a, e): return Or(And(Equal(m, S(2)), Equal(p, S(-3)), RationalQ(a, c, d, e, f, g)), Not(NegativeIntegerQ(m + S(2)*p + S(3)))) cons365 = CustomConstraint(cons_f365) def cons_f366(m, f, g, d, x, e): if isinstance(x, (int, Integer, float, Float)): return False return Not(And(Equal(m, S(1)), SimplerQ(d + e*x, f + g*x))) cons366 = CustomConstraint(cons_f366) def cons_f367(m): return FractionQ(m) cons367 = CustomConstraint(cons_f367) def cons_f368(m, f, g, d, x, e): if isinstance(x, (int, Integer, float, Float)): return False return Not(And(Equal(m, S(1)), SimplerQ(f + g*x, d + e*x))) cons368 = CustomConstraint(cons_f368) def cons_f369(m, p): return NegativeIntegerQ(m + S(2)*p + S(3)) cons369 = CustomConstraint(cons_f369) def cons_f370(b, d, c, a, e): return ZeroQ(S(4)*c*(a - d) - (b - e)**S(2)) cons370 = CustomConstraint(cons_f370) def cons_f371(f, b, g, d, a, e): return ZeroQ(e*f*(b - e) - S(2)*g*(-a*e + b*d)) cons371 = CustomConstraint(cons_f371) def cons_f372(d, a, b, e): return NonzeroQ(-a*e + b*d) cons372 = CustomConstraint(cons_f372) def cons_f373(f, g, a, c, x): if isinstance(x, (int, Integer, float, Float)): return False return FreeQ(List(a, c, f, g), x) cons373 = CustomConstraint(cons_f373) def cons_f374(f, g, a, c, x, e): if isinstance(x, (int, Integer, float, Float)): return False return FreeQ(List(a, c, e, f, g), x) cons374 = CustomConstraint(cons_f374) def cons_f375(m, n, p): return IntegersQ(m, n, p) cons375 = CustomConstraint(cons_f375) def cons_f376(p, n): return IntegersQ(n, p) cons376 = CustomConstraint(cons_f376) def cons_f377(d, m, f): return Or(IntegerQ(m), And(PositiveQ(d), PositiveQ(f))) cons377 = CustomConstraint(cons_f377) def cons_f378(m, p, n): return Or(IntegerQ(p), IntegersQ(m, n)) cons378 = CustomConstraint(cons_f378) def cons_f379(p, m, f, g, a, c, x, e): if isinstance(x, (int, Integer, float, Float)): return False return FreeQ(List(a, c, e, f, g, m, p), x) cons379 = CustomConstraint(cons_f379) def cons_f380(p, m, f, b, g, d, c, a, n, x, e): if isinstance(x, (int, Integer, float, Float)): return False return FreeQ(List(a, b, c, d, e, f, g, m, n, p), x) cons380 = CustomConstraint(cons_f380) def cons_f381(p, m, f, g, d, a, c, n, x, e): if isinstance(x, (int, Integer, float, Float)): return False return FreeQ(List(a, c, d, e, f, g, m, n, p), x) cons381 = CustomConstraint(cons_f381) def cons_f382(d, c, f, a): return ZeroQ(-a*f + c*d) cons382 = CustomConstraint(cons_f382) def cons_f383(d, a, b, e): return ZeroQ(-a*e + b*d) cons383 = CustomConstraint(cons_f383) def cons_f384(f, c, p): return Or(IntegerQ(p), PositiveQ(c/f)) cons384 = CustomConstraint(cons_f384) def cons_f385(f, b, d, a, c, x, q, e): if isinstance(x, (int, Integer, float, Float)): return False return Or(Not(IntegerQ(q)), LessEqual(LeafCount(d + e*x + f*x**S(2)), LeafCount(a + b*x + c*x**S(2)))) cons385 = CustomConstraint(cons_f385) def cons_f386(q): return Not(IntegerQ(q)) cons386 = CustomConstraint(cons_f386) def cons_f387(c, f): return Not(PositiveQ(c/f)) cons387 = CustomConstraint(cons_f387) def cons_f388(f, b, d, a, c, q, e): return ZeroQ(c*(-S(2)*d*f + e**S(2)*(q + S(2))) + f*(S(2)*q + S(3))*(S(2)*a*f - b*e)) cons388 = CustomConstraint(cons_f388) def cons_f389(q): return NonzeroQ(q + S(1)) cons389 = CustomConstraint(cons_f389) def cons_f390(q): return NonzeroQ(S(2)*q + S(3)) cons390 = CustomConstraint(cons_f390) def cons_f391(f, d, a, c, q, e): return ZeroQ(S(2)*a*f**S(2)*(S(2)*q + S(3)) + c*(-S(2)*d*f + e**S(2)*(q + S(2)))) cons391 = CustomConstraint(cons_f391) def cons_f392(f, d, a, c, q): return ZeroQ(S(2)*a*f*q + S(3)*a*f - c*d) cons392 = CustomConstraint(cons_f392) def cons_f393(q): return PositiveIntegerQ(q + S(2)) cons393 = CustomConstraint(cons_f393) def cons_f394(d, f, e): return NonzeroQ(-S(4)*d*f + e**S(2)) cons394 = CustomConstraint(cons_f394) def cons_f395(q): return RationalQ(q) cons395 = CustomConstraint(cons_f395) def cons_f396(q): return Less(q, S(-1)) cons396 = CustomConstraint(cons_f396) def cons_f397(f, b, d, a, c, q, e): return NonzeroQ(c*(-S(2)*d*f + e**S(2)*(q + S(2))) + f*(S(2)*q + S(3))*(S(2)*a*f - b*e)) cons397 = CustomConstraint(cons_f397) def cons_f398(f, d, a, c, q, e): return NonzeroQ(S(2)*a*f**S(2)*(S(2)*q + S(3)) + c*(-S(2)*d*f + e**S(2)*(q + S(2)))) cons398 = CustomConstraint(cons_f398) def cons_f399(f, d, a, c, q): return NonzeroQ(S(2)*a*f*q + S(3)*a*f - c*d) cons399 = CustomConstraint(cons_f399) def cons_f400(q): return Not(PositiveIntegerQ(q)) cons400 = CustomConstraint(cons_f400) def cons_f401(q): return Not(And(RationalQ(q), LessEqual(q, S(-1)))) cons401 = CustomConstraint(cons_f401) def cons_f402(p, q): return RationalQ(p, q) cons402 = CustomConstraint(cons_f402) def cons_f403(q): return Greater(q, S(0)) cons403 = CustomConstraint(cons_f403) def cons_f404(f, b, d, c, a, e): return NonzeroQ(-(-a*e + b*d)*(-b*f + c*e) + (-a*f + c*d)**S(2)) cons404 = CustomConstraint(cons_f404) def cons_f405(p, q): return Not(And(Not(IntegerQ(p)), IntegerQ(q), Less(q, S(-1)))) cons405 = CustomConstraint(cons_f405) def cons_f406(f, b, d, c, a): return NonzeroQ(b**S(2)*d*f + (-a*f + c*d)**S(2)) cons406 = CustomConstraint(cons_f406) def cons_f407(f, d, a, c, e): return NonzeroQ(a*c*e**S(2) + (-a*f + c*d)**S(2)) cons407 = CustomConstraint(cons_f407) def cons_f408(p, q): return NonzeroQ(p + q) cons408 = CustomConstraint(cons_f408) def cons_f409(p, q): return NonzeroQ(S(2)*p + S(2)*q + S(1)) cons409 = CustomConstraint(cons_f409) def cons_f410(c, f, b, e): return ZeroQ(-b*f + c*e) cons410 = CustomConstraint(cons_f410) def cons_f411(c, f, b, e): return NonzeroQ(-b*f + c*e) cons411 = CustomConstraint(cons_f411) def cons_f412(a, c): return PosQ(-a*c) cons412 = CustomConstraint(cons_f412) def cons_f413(c, a, b): return NegQ(-S(4)*a*c + b**S(2)) cons413 = CustomConstraint(cons_f413) def cons_f414(a, c): return NegQ(-a*c) cons414 = CustomConstraint(cons_f414) def cons_f415(p, f, b, d, c, a, x, q, e): if isinstance(x, (int, Integer, float, Float)): return False return FreeQ(List(a, b, c, d, e, f, p, q), x) cons415 = CustomConstraint(cons_f415) def cons_f416(p, f, d, a, c, x, q, e): if isinstance(x, (int, Integer, float, Float)): return False return FreeQ(List(a, c, d, e, f, p, q), x) cons416 = CustomConstraint(cons_f416) def cons_f417(g, b, c, a, h): return ZeroQ(a*h**S(2) - b*g*h + c*g**S(2)) cons417 = CustomConstraint(cons_f417) def cons_f418(g, f, d, c, a, h, e): return ZeroQ(a**S(2)*f*h**S(2) - a*c*e*g*h + c**S(2)*d*g**S(2)) cons418 = CustomConstraint(cons_f418) def cons_f419(h, c, g, a): return ZeroQ(a*h**S(2) + c*g**S(2)) cons419 = CustomConstraint(cons_f419) def cons_f420(f, g, d, c, a, h): return ZeroQ(a**S(2)*f*h**S(2) + c**S(2)*d*g**S(2)) cons420 = CustomConstraint(cons_f420) def cons_f421(f, b, c, a, e): return ZeroQ(a*f**S(2) - b*e*f + c*e**S(2)) cons421 = CustomConstraint(cons_f421) def cons_f422(c, f, e, a): return ZeroQ(a*f**S(2) + c*e**S(2)) cons422 = CustomConstraint(cons_f422) def cons_f423(p, m, f, b, g, c, h, e): return ZeroQ(b*f*h*(m + p + S(2)) + c*(-e*h*(m + S(2)*p + S(3)) + S(2)*f*g*(p + S(1)))) cons423 = CustomConstraint(cons_f423) def cons_f424(p, m, f, b, g, d, a, c, h): return ZeroQ(b*f*g*(p + S(1)) + h*(a*f*(m + S(1)) - c*d*(m + S(2)*p + S(3)))) cons424 = CustomConstraint(cons_f424) def cons_f425(p, m, f, g, c, h, e): return ZeroQ(c*(-e*h*(m + S(2)*p + S(3)) + S(2)*f*g*(p + S(1)))) cons425 = CustomConstraint(cons_f425) def cons_f426(p, m, f, d, a, c, h): return ZeroQ(h*(a*f*(m + S(1)) - c*d*(m + S(2)*p + S(3)))) cons426 = CustomConstraint(cons_f426) def cons_f427(p, m, f, b, g, c, h): return ZeroQ(b*f*h*(m + p + S(2)) + S(2)*c*f*g*(p + S(1))) cons427 = CustomConstraint(cons_f427) def cons_f428(m, p): return Or(IntegersQ(m, p), PositiveIntegerQ(p)) cons428 = CustomConstraint(cons_f428) def cons_f429(g, b, c, a, h): return NonzeroQ(a*h**S(2) - b*g*h + c*g**S(2)) cons429 = CustomConstraint(cons_f429) def cons_f430(h, c, g, a): return NonzeroQ(a*h**S(2) + c*g**S(2)) cons430 = CustomConstraint(cons_f430) def cons_f431(g, b, c, a, h): return NonzeroQ(c*g**S(2) - h*(-a*h + b*g)) cons431 = CustomConstraint(cons_f431) def cons_f432(p, q): return Or(Greater(p, S(0)), Greater(q, S(0))) cons432 = CustomConstraint(cons_f432) def cons_f433(p, q): return NonzeroQ(p + q + S(1)) cons433 = CustomConstraint(cons_f433) def cons_f434(a, c): return PositiveQ(a*c) cons434 = CustomConstraint(cons_f434) def cons_f435(a, c): return Not(PositiveQ(a*c)) cons435 = CustomConstraint(cons_f435) def cons_f436(f, h, e, g): return ZeroQ(e*h - S(2)*f*g) cons436 = CustomConstraint(cons_f436) def cons_f437(f, h, e, g): return NonzeroQ(e*h - S(2)*f*g) cons437 = CustomConstraint(cons_f437) def cons_f438(d, h, e, g): return ZeroQ(S(2)*d*h - e*g) cons438 = CustomConstraint(cons_f438) def cons_f439(d, h, e, g): return NonzeroQ(S(2)*d*h - e*g) cons439 = CustomConstraint(cons_f439) def cons_f440(g, b, f, d, a, c, h, e): return ZeroQ(g**S(2)*(-b*f + c*e) - S(2)*g*h*(-a*f + c*d) + h**S(2)*(-a*e + b*d)) cons440 = CustomConstraint(cons_f440) def cons_f441(g, f, d, a, c, h, e): return ZeroQ(a*e*h**S(2) - c*e*g**S(2) + S(2)*g*h*(-a*f + c*d)) cons441 = CustomConstraint(cons_f441) def cons_f442(g, b, f, d, c, a, h): return ZeroQ(b*d*h**S(2) - b*f*g**S(2) - S(2)*g*h*(-a*f + c*d)) cons442 = CustomConstraint(cons_f442) def cons_f443(f, b, d, c, a): return ZeroQ(c**S(2)*d - f*(-S(3)*a*c + b**S(2))) cons443 = CustomConstraint(cons_f443) def cons_f444(g, b, c, a, h): return ZeroQ(S(9)*a*c*h**S(2) - S(2)*b**S(2)*h**S(2) - b*c*g*h + c**S(2)*g**S(2)) cons444 = CustomConstraint(cons_f444) def cons_f445(c, h, b, g): return PositiveQ(-S(9)*c*h**S(2)/(-b*h + S(2)*c*g)**S(2)) cons445 = CustomConstraint(cons_f445) def cons_f446(d, c, f, a): return ZeroQ(S(3)*a*f + c*d) cons446 = CustomConstraint(cons_f446) def cons_f447(h, c, g, a): return ZeroQ(S(9)*a*h**S(2) + c*g**S(2)) cons447 = CustomConstraint(cons_f447) def cons_f448(a): return Not(PositiveQ(a)) cons448 = CustomConstraint(cons_f448) def cons_f449(p, f, b, g, d, c, a, x, h, q, e): if isinstance(x, (int, Integer, float, Float)): return False return FreeQ(List(a, b, c, d, e, f, g, h, p, q), x) cons449 = CustomConstraint(cons_f449) def cons_f450(p, f, g, d, a, c, x, h, q, e): if isinstance(x, (int, Integer, float, Float)): return False return FreeQ(List(a, c, d, e, f, g, h, p, q), x) cons450 = CustomConstraint(cons_f450) def cons_f451(x, z): if isinstance(x, (int, Integer, float, Float)): return False return LinearQ(z, x) cons451 = CustomConstraint(cons_f451) def cons_f452(v, x, u): if isinstance(x, (int, Integer, float, Float)): return False return QuadraticQ(List(u, v), x) cons452 = CustomConstraint(cons_f452) def cons_f453(x, z, u, v): if isinstance(x, (int, Integer, float, Float)): return False return Not(And(LinearMatchQ(z, x), QuadraticMatchQ(List(u, v), x))) cons453 = CustomConstraint(cons_f453) def cons_f454(p, q): return NonzeroQ(S(2)*p + S(2)*q + S(3)) cons454 = CustomConstraint(cons_f454) def cons_f455(B, C, p, f, b, d, c, a, A, x, q, e): if isinstance(x, (int, Integer, float, Float)): return False return FreeQ(List(a, b, c, d, e, f, A, B, C, p, q), x) cons455 = CustomConstraint(cons_f455) def cons_f456(C, p, f, b, d, c, a, A, x, q, e): if isinstance(x, (int, Integer, float, Float)): return False return FreeQ(List(a, b, c, d, e, f, A, C, p, q), x) cons456 = CustomConstraint(cons_f456) def cons_f457(B, C, p, f, d, a, c, A, x, q, e): if isinstance(x, (int, Integer, float, Float)): return False return FreeQ(List(a, c, d, e, f, A, B, C, p, q), x) cons457 = CustomConstraint(cons_f457) def cons_f458(C, p, f, d, a, c, A, x, q, e): if isinstance(x, (int, Integer, float, Float)): return False return FreeQ(List(a, c, d, e, f, A, C, p, q), x) cons458 = CustomConstraint(cons_f458) def cons_f459(x, p, n, b): if isinstance(x, (int, Integer, float, Float)): return False return FreeQ(List(b, n, p), x) cons459 = CustomConstraint(cons_f459) def cons_f460(p, n): return ZeroQ(p + S(1) + S(1)/n) cons460 = CustomConstraint(cons_f460) def cons_f461(p, n): return NegativeIntegerQ(p + S(1) + S(1)/n) cons461 = CustomConstraint(cons_f461) def cons_f462(n): return NonzeroQ(S(3)*n + S(1)) cons462 = CustomConstraint(cons_f462) def cons_f463(n): return Less(n, S(0)) cons463 = CustomConstraint(cons_f463) def cons_f464(p, n): return PositiveIntegerQ(n, p) cons464 = CustomConstraint(cons_f464) def cons_f465(p, n): return Or(IntegerQ(S(2)*p), And(Equal(n, S(2)), IntegerQ(S(4)*p)), And(Equal(n, S(2)), IntegerQ(S(3)*p)), Less(Denominator(p + S(1)/n), Denominator(p))) cons465 = CustomConstraint(cons_f465) def cons_f466(a, b): return PosQ(b/a) cons466 = CustomConstraint(cons_f466) def cons_f467(n): return PositiveIntegerQ(n/S(2) + S(-3)/2) cons467 = CustomConstraint(cons_f467) def cons_f468(a, b): return PosQ(a/b) cons468 = CustomConstraint(cons_f468) def cons_f469(a, b): return NegQ(a/b) cons469 = CustomConstraint(cons_f469) def cons_f470(a, b): return Or(PositiveQ(a), PositiveQ(b)) cons470 = CustomConstraint(cons_f470) def cons_f471(a, b): return Or(NegativeQ(a), NegativeQ(b)) cons471 = CustomConstraint(cons_f471) def cons_f472(a, b): return Or(PositiveQ(a), NegativeQ(b)) cons472 = CustomConstraint(cons_f472) def cons_f473(a, b): return Or(NegativeQ(a), PositiveQ(b)) cons473 = CustomConstraint(cons_f473) def cons_f474(n): return PositiveIntegerQ(n/S(4) + S(-1)/2) cons474 = CustomConstraint(cons_f474) def cons_f475(a, b): try: return Or(PositiveQ(a/b), And(PosQ(a/b), AtomQ(SplitProduct(SumBaseQ, a)), AtomQ(SplitProduct(SumBaseQ, b)))) except (TypeError, AttributeError): return False cons475 = CustomConstraint(cons_f475) def cons_f476(a, b): return Not(PositiveQ(a/b)) cons476 = CustomConstraint(cons_f476) def cons_f477(n): return PositiveIntegerQ(n/S(4) + S(-1)) cons477 = CustomConstraint(cons_f477) def cons_f478(a, b): return PositiveQ(a/b) cons478 = CustomConstraint(cons_f478) def cons_f479(b): return PosQ(b) cons479 = CustomConstraint(cons_f479) def cons_f480(b): return NegQ(b) cons480 = CustomConstraint(cons_f480) def cons_f481(a): return PosQ(a) cons481 = CustomConstraint(cons_f481) def cons_f482(a): return NegQ(a) cons482 = CustomConstraint(cons_f482) def cons_f483(a, b): return NegQ(b/a) cons483 = CustomConstraint(cons_f483) def cons_f484(a): return NegativeQ(a) cons484 = CustomConstraint(cons_f484) def cons_f485(p): return Less(S(-1), p, S(0)) cons485 = CustomConstraint(cons_f485) def cons_f486(p): return Unequal(p, S(-1)/2) cons486 = CustomConstraint(cons_f486) def cons_f487(p, n): return IntegerQ(p + S(1)/n) cons487 = CustomConstraint(cons_f487) def cons_f488(p, n): return Less(Denominator(p + S(1)/n), Denominator(p)) cons488 = CustomConstraint(cons_f488) def cons_f489(n): return FractionQ(n) cons489 = CustomConstraint(cons_f489) def cons_f490(n): return Not(IntegerQ(S(1)/n)) cons490 = CustomConstraint(cons_f490) def cons_f491(p, n): return Not(NegativeIntegerQ(p + S(1)/n)) cons491 = CustomConstraint(cons_f491) def cons_f492(a, p): return Or(IntegerQ(p), PositiveQ(a)) cons492 = CustomConstraint(cons_f492) def cons_f493(a, p): return Not(Or(IntegerQ(p), PositiveQ(a))) cons493 = CustomConstraint(cons_f493) def cons_f494(a2, p, a1): return Or(IntegerQ(p), And(PositiveQ(a1), PositiveQ(a2))) cons494 = CustomConstraint(cons_f494) def cons_f495(n): return PositiveIntegerQ(S(2)*n) cons495 = CustomConstraint(cons_f495) def cons_f496(p, n): return Or(IntegerQ(S(2)*p), Less(Denominator(p + S(1)/n), Denominator(p))) cons496 = CustomConstraint(cons_f496) def cons_f497(n): return NegativeIntegerQ(S(2)*n) cons497 = CustomConstraint(cons_f497) def cons_f498(n): return FractionQ(S(2)*n) cons498 = CustomConstraint(cons_f498) def cons_f499(m, c): return Or(IntegerQ(m), PositiveQ(c)) cons499 = CustomConstraint(cons_f499) def cons_f500(m, n): return IntegerQ((m + S(1))/n) cons500 = CustomConstraint(cons_f500) def cons_f501(m, n): return Not(IntegerQ((m + S(1))/n)) cons501 = CustomConstraint(cons_f501) def cons_f502(n): return NegQ(n) cons502 = CustomConstraint(cons_f502) def cons_f503(m, n, p): return ZeroQ(p + S(1) + (m + S(1))/n) cons503 = CustomConstraint(cons_f503) def cons_f504(m, n, p): return ZeroQ(p + S(1) + (m + S(1))/(S(2)*n)) cons504 = CustomConstraint(cons_f504) def cons_f505(m, n): return IntegerQ((m + S(1))/(S(2)*n)) cons505 = CustomConstraint(cons_f505) def cons_f506(m, n, p): return NegativeIntegerQ((m + n*(p + S(1)) + S(1))/n) cons506 = CustomConstraint(cons_f506) def cons_f507(m, n, p): return NegativeIntegerQ((m + S(2)*n*(p + S(1)) + S(1))/(S(2)*n)) cons507 = CustomConstraint(cons_f507) def cons_f508(m, n, p): return Not(NegativeIntegerQ((m + n*p + n + S(1))/n)) cons508 = CustomConstraint(cons_f508) def cons_f509(p, m, b, c, a, n, x): if isinstance(x, (int, Integer, float, Float)): return False return IntBinomialQ(a, b, c, n, m, p, x) cons509 = CustomConstraint(cons_f509) def cons_f510(m, n, p): return NonzeroQ(m + S(2)*n*p + S(1)) cons510 = CustomConstraint(cons_f510) def cons_f511(a2, p, b2, m, b1, c, n, x, a1): if isinstance(x, (int, Integer, float, Float)): return False return IntBinomialQ(a1*a2, b1*b2, c, n, m, p, x) cons511 = CustomConstraint(cons_f511) def cons_f512(m, n, p): return NonzeroQ(m + n*p + S(1)) cons512 = CustomConstraint(cons_f512) def cons_f513(m): return PositiveIntegerQ(m/S(4) + S(-1)/2) cons513 = CustomConstraint(cons_f513) def cons_f514(m): return NegativeIntegerQ(m/S(4) + S(-1)/2) cons514 = CustomConstraint(cons_f514) def cons_f515(m): return IntegerQ(S(2)*m) cons515 = CustomConstraint(cons_f515) def cons_f516(m): return Greater(m, S(3)/2) cons516 = CustomConstraint(cons_f516) def cons_f517(m, n): return Greater(m + S(1), n) cons517 = CustomConstraint(cons_f517) def cons_f518(m, n, p): return Not(NegativeIntegerQ((m + n*(p + S(1)) + S(1))/n)) cons518 = CustomConstraint(cons_f518) def cons_f519(m, n): return Greater(m + S(1), S(2)*n) cons519 = CustomConstraint(cons_f519) def cons_f520(m, n, p): return Not(NegativeIntegerQ((m + S(2)*n*(p + S(1)) + S(1))/(S(2)*n))) cons520 = CustomConstraint(cons_f520) def cons_f521(n): return PositiveIntegerQ(n/S(2) + S(-1)/2) cons521 = CustomConstraint(cons_f521) def cons_f522(m, n): return Less(m, n + S(-1)) cons522 = CustomConstraint(cons_f522) def cons_f523(m, n): return PositiveIntegerQ(m, n/S(2) + S(-1)/2) cons523 = CustomConstraint(cons_f523) def cons_f524(m, n): return PositiveIntegerQ(m, n/S(4) + S(-1)/2) cons524 = CustomConstraint(cons_f524) def cons_f525(m, n): return PositiveIntegerQ(m, n/S(4)) cons525 = CustomConstraint(cons_f525) def cons_f526(m, n): return Less(m, n/S(2)) cons526 = CustomConstraint(cons_f526) def cons_f527(m, n): return Inequality(n/S(2), LessEqual, m, Less, n) cons527 = CustomConstraint(cons_f527) def cons_f528(m, n): return PositiveIntegerQ(m, n) cons528 = CustomConstraint(cons_f528) def cons_f529(m, n): return Greater(m, S(2)*n + S(-1)) cons529 = CustomConstraint(cons_f529) def cons_f530(m, n): return Greater(m, n + S(-1)) cons530 = CustomConstraint(cons_f530) def cons_f531(m, n): return SumSimplerQ(m, -n) cons531 = CustomConstraint(cons_f531) def cons_f532(m, n, p): return NegativeIntegerQ((m + n*p + S(1))/n) cons532 = CustomConstraint(cons_f532) def cons_f533(m, n): return SumSimplerQ(m, -S(2)*n) cons533 = CustomConstraint(cons_f533) def cons_f534(m, n, p): return NegativeIntegerQ((m + S(2)*n*p + S(1))/(S(2)*n)) cons534 = CustomConstraint(cons_f534) def cons_f535(m, n): return SumSimplerQ(m, n) cons535 = CustomConstraint(cons_f535) def cons_f536(m, n): return SumSimplerQ(m, S(2)*n) cons536 = CustomConstraint(cons_f536) def cons_f537(m, p, n): return IntegersQ(m, p + (m + S(1))/n) cons537 = CustomConstraint(cons_f537) def cons_f538(m, p, n): return IntegersQ(m, p + (m + S(1))/(S(2)*n)) cons538 = CustomConstraint(cons_f538) def cons_f539(m, p, n): return Less(Denominator(p + (m + S(1))/n), Denominator(p)) cons539 = CustomConstraint(cons_f539) def cons_f540(m, p, n): return Less(Denominator(p + (m + S(1))/(S(2)*n)), Denominator(p)) cons540 = CustomConstraint(cons_f540) def cons_f541(m, n): return IntegerQ(n/(m + S(1))) cons541 = CustomConstraint(cons_f541) def cons_f542(m, n): return IntegerQ(S(2)*n/(m + S(1))) cons542 = CustomConstraint(cons_f542) def cons_f543(n): return Not(IntegerQ(S(2)*n)) cons543 = CustomConstraint(cons_f543) def cons_f544(m, n, p): return ZeroQ(p + (m + S(1))/n) cons544 = CustomConstraint(cons_f544) def cons_f545(m, n, p): return ZeroQ(p + (m + S(1))/(S(2)*n)) cons545 = CustomConstraint(cons_f545) def cons_f546(m, p, n): return IntegerQ(p + (m + S(1))/n) cons546 = CustomConstraint(cons_f546) def cons_f547(m, p, n): return IntegerQ(p + (m + S(1))/(S(2)*n)) cons547 = CustomConstraint(cons_f547) def cons_f548(m, n): return FractionQ((m + S(1))/n) cons548 = CustomConstraint(cons_f548) def cons_f549(m, n): return Or(SumSimplerQ(m, n), SumSimplerQ(m, -n)) cons549 = CustomConstraint(cons_f549) def cons_f550(a, p): return Or(NegativeIntegerQ(p), PositiveQ(a)) cons550 = CustomConstraint(cons_f550) def cons_f551(a, p): return Not(Or(NegativeIntegerQ(p), PositiveQ(a))) cons551 = CustomConstraint(cons_f551) def cons_f552(v, x): if isinstance(x, (int, Integer, float, Float)): return False return LinearQ(v, x) cons552 = CustomConstraint(cons_f552) def cons_f553(v, x): if isinstance(x, (int, Integer, float, Float)): return False return NonzeroQ(v - x) cons553 = CustomConstraint(cons_f553) def cons_f554(v, x, u): if isinstance(x, (int, Integer, float, Float)): return False return LinearPairQ(u, v, x) cons554 = CustomConstraint(cons_f554) def cons_f555(p, q): return PositiveIntegerQ(p, q) cons555 = CustomConstraint(cons_f555) def cons_f556(p, n): return ZeroQ(n*p + S(1)) cons556 = CustomConstraint(cons_f556) def cons_f557(p, n, q): return ZeroQ(n*(p + q + S(1)) + S(1)) cons557 = CustomConstraint(cons_f557) def cons_f558(p, n, q): return ZeroQ(n*(p + q + S(2)) + S(1)) cons558 = CustomConstraint(cons_f558) def cons_f559(p, b, d, c, a, q): return ZeroQ(a*d*(p + S(1)) + b*c*(q + S(1))) cons559 = CustomConstraint(cons_f559) def cons_f560(p, q): return Or(And(RationalQ(p), Less(p, S(-1))), Not(And(RationalQ(q), Less(q, S(-1))))) cons560 = CustomConstraint(cons_f560) def cons_f561(p, b, d, c, a, n): return ZeroQ(a*d - b*c*(n*(p + S(1)) + S(1))) cons561 = CustomConstraint(cons_f561) def cons_f562(p, n): return Or(And(RationalQ(p), Less(p, S(-1))), NegativeIntegerQ(p + S(1)/n)) cons562 = CustomConstraint(cons_f562) def cons_f563(p, n): return NonzeroQ(n*(p + S(1)) + S(1)) cons563 = CustomConstraint(cons_f563) def cons_f564(q): return NegativeIntegerQ(q) cons564 = CustomConstraint(cons_f564) def cons_f565(p, q): return GreaterEqual(p, -q) cons565 = CustomConstraint(cons_f565) def cons_f566(d, c, b, a): return ZeroQ(S(3)*a*d + b*c) cons566 = CustomConstraint(cons_f566) def cons_f567(p): return Or(Equal(p, S(1)/2), Equal(Denominator(p), S(4))) cons567 = CustomConstraint(cons_f567) def cons_f568(p): return Equal(Denominator(p), S(4)) cons568 = CustomConstraint(cons_f568) def cons_f569(p): return Or(Equal(p, S(-5)/4), Equal(p, S(-7)/4)) cons569 = CustomConstraint(cons_f569) def cons_f570(a, b): return PosQ(a*b) cons570 = CustomConstraint(cons_f570) def cons_f571(a, b): return NegQ(a*b) cons571 = CustomConstraint(cons_f571) def cons_f572(p): return Or(Equal(p, S(3)/4), Equal(p, S(5)/4)) cons572 = CustomConstraint(cons_f572) def cons_f573(d, c): return PosQ(d/c) cons573 = CustomConstraint(cons_f573) def cons_f574(q): return Less(S(0), q, S(1)) cons574 = CustomConstraint(cons_f574) def cons_f575(p, b, d, c, a, n, x, q): if isinstance(x, (int, Integer, float, Float)): return False return IntBinomialQ(a, b, c, d, n, p, q, x) cons575 = CustomConstraint(cons_f575) def cons_f576(q): return Greater(q, S(1)) cons576 = CustomConstraint(cons_f576) def cons_f577(p, q): return Greater(p + q, S(0)) cons577 = CustomConstraint(cons_f577) def cons_f578(p, n, q): return NonzeroQ(n*(p + q) + S(1)) cons578 = CustomConstraint(cons_f578) def cons_f579(p): return Not(And(IntegerQ(p), Greater(p, S(1)))) cons579 = CustomConstraint(cons_f579) def cons_f580(d, c, a, b): return Not(SimplerSqrtQ(b/a, d/c)) cons580 = CustomConstraint(cons_f580) def cons_f581(d, c): return NegQ(d/c) cons581 = CustomConstraint(cons_f581) def cons_f582(d, c, a, b): return Not(And(NegQ(b/a), SimplerSqrtQ(-b/a, -d/c))) cons582 = CustomConstraint(cons_f582) def cons_f583(d, c, a, b): return PositiveQ(a - b*c/d) cons583 = CustomConstraint(cons_f583) def cons_f584(n): return NonzeroQ(n + S(1)) cons584 = CustomConstraint(cons_f584) def cons_f585(mn, n): return EqQ(mn, -n) cons585 = CustomConstraint(cons_f585) def cons_f586(q): return IntegerQ(q) cons586 = CustomConstraint(cons_f586) def cons_f587(p, n): return Or(PosQ(n), Not(IntegerQ(p))) cons587 = CustomConstraint(cons_f587) def cons_f588(v, x, u): if isinstance(x, (int, Integer, float, Float)): return False return PseudoBinomialPairQ(u, v, x) cons588 = CustomConstraint(cons_f588) def cons_f589(m, p): return IntegersQ(p, m/p) cons589 = CustomConstraint(cons_f589) def cons_f590(v, p, u, m, x): if isinstance(x, (int, Integer, float, Float)): return False return PseudoBinomialPairQ(u*x**(m/p), v, x) cons590 = CustomConstraint(cons_f590) def cons_f591(m, e): return Or(IntegerQ(m), PositiveQ(e)) cons591 = CustomConstraint(cons_f591) def cons_f592(p, m, b, d, a, c, n): return ZeroQ(a*d*(m + S(1)) - b*c*(m + n*(p + S(1)) + S(1))) cons592 = CustomConstraint(cons_f592) def cons_f593(n, non2): return ZeroQ(-n/S(2) + non2) cons593 = CustomConstraint(cons_f593) def cons_f594(a2, p, m, b2, b1, d, c, n, a1): return ZeroQ(a1*a2*d*(m + S(1)) - b1*b2*c*(m + n*(p + S(1)) + S(1))) cons594 = CustomConstraint(cons_f594) def cons_f595(m, n, p): return ZeroQ(m + n*(p + S(1)) + S(1)) cons595 = CustomConstraint(cons_f595) def cons_f596(n, e): return Or(IntegerQ(n), PositiveQ(e)) cons596 = CustomConstraint(cons_f596) def cons_f597(m, n): return Or(And(Greater(n, S(0)), Less(m, S(-1))), And(Less(n, S(0)), Greater(m + n, S(-1)))) cons597 = CustomConstraint(cons_f597) def cons_f598(p): return Not(And(IntegerQ(p), Less(p, S(-1)))) cons598 = CustomConstraint(cons_f598) def cons_f599(m): return PositiveIntegerQ(m/S(2)) cons599 = CustomConstraint(cons_f599) def cons_f600(m, p): return Or(IntegerQ(p), Equal(m + S(2)*p + S(1), S(0))) cons600 = CustomConstraint(cons_f600) def cons_f601(m): return NegativeIntegerQ(m/S(2)) cons601 = CustomConstraint(cons_f601) def cons_f602(m, p, n): return Or(IntegerQ(p), Not(RationalQ(m)), And(PositiveIntegerQ(n), NegativeIntegerQ(p + S(1)/2), LessEqual(S(-1), m, -n*(p + S(1))))) cons602 = CustomConstraint(cons_f602) def cons_f603(m, n, p): return NonzeroQ(m + n*(p + S(1)) + S(1)) cons603 = CustomConstraint(cons_f603) def cons_f604(m): return Or(IntegerQ(m), PositiveIntegerQ(S(2)*m + S(2)), Not(RationalQ(m))) cons604 = CustomConstraint(cons_f604) def cons_f605(m, n, p): return NonzeroQ(m + n*(p + S(2)) + S(1)) cons605 = CustomConstraint(cons_f605) def cons_f606(m, p, q): return RationalQ(m, p, q) cons606 = CustomConstraint(cons_f606) def cons_f607(m, n): return Greater(m - n + S(1), S(0)) cons607 = CustomConstraint(cons_f607) def cons_f608(p, m, b, d, c, a, n, x, q, e): if isinstance(x, (int, Integer, float, Float)): return False return IntBinomialQ(a, b, c, d, e, m, n, p, q, x) cons608 = CustomConstraint(cons_f608) def cons_f609(m, n): return Greater(m - n + S(1), n) cons609 = CustomConstraint(cons_f609) def cons_f610(m, n): return Inequality(n, GreaterEqual, m - n + S(1), Greater, S(0)) cons610 = CustomConstraint(cons_f610) def cons_f611(m, q): return RationalQ(m, q) cons611 = CustomConstraint(cons_f611) def cons_f612(m, n): return LessEqual(n, m, S(2)*n + S(-1)) cons612 = CustomConstraint(cons_f612) def cons_f613(m, n): return IntegersQ(m/S(2), n/S(2)) cons613 = CustomConstraint(cons_f613) def cons_f614(m, n): return Less(S(0), m - n + S(1), n) cons614 = CustomConstraint(cons_f614) def cons_f615(n): return LessEqual(n, S(4)) cons615 = CustomConstraint(cons_f615) def cons_f616(d, c, b, a): return ZeroQ(-a*d + S(4)*b*c) cons616 = CustomConstraint(cons_f616) def cons_f617(m): return PositiveIntegerQ(m/S(3) + S(-1)/3) cons617 = CustomConstraint(cons_f617) def cons_f618(m): return NegativeIntegerQ(m/S(3) + S(-1)/3) cons618 = CustomConstraint(cons_f618) def cons_f619(m): return IntegerQ(m/S(3) + S(-1)/3) cons619 = CustomConstraint(cons_f619) def cons_f620(n): return Or(EqQ(n, S(2)), EqQ(n, S(4))) cons620 = CustomConstraint(cons_f620) def cons_f621(b, d, c, a, n): return Not(And(EqQ(n, S(2)), SimplerSqrtQ(-b/a, -d/c))) cons621 = CustomConstraint(cons_f621) def cons_f622(m, p, q, n): return IntegersQ(p + (m + S(1))/n, q) cons622 = CustomConstraint(cons_f622) def cons_f623(m, n): return Or(ZeroQ(m - n), ZeroQ(m - S(2)*n + S(1))) cons623 = CustomConstraint(cons_f623) def cons_f624(m, p, q): return IntegersQ(m, p, q) cons624 = CustomConstraint(cons_f624) def cons_f625(p): return GreaterEqual(p, S(-2)) cons625 = CustomConstraint(cons_f625) def cons_f626(m, q): return Or(GreaterEqual(q, S(-2)), And(Equal(q, S(-3)), IntegerQ(m/S(2) + S(-1)/2))) cons626 = CustomConstraint(cons_f626) def cons_f627(m, n): return NonzeroQ(m - n + S(1)) cons627 = CustomConstraint(cons_f627) def cons_f628(r, p, q): return PositiveIntegerQ(p, q, r) cons628 = CustomConstraint(cons_f628) def cons_f629(f, b, d, c, a, n, x, e): if isinstance(x, (int, Integer, float, Float)): return False return FreeQ(List(a, b, c, d, e, f, n), x) cons629 = CustomConstraint(cons_f629) def cons_f630(b, d, c, a, n): return Not(And(ZeroQ(n + S(-2)), Or(And(PosQ(b/a), PosQ(d/c)), And(NegQ(b/a), Or(PosQ(d/c), And(PositiveQ(a), Or(Not(PositiveQ(c)), SimplerSqrtQ(-b/a, -d/c)))))))) cons630 = CustomConstraint(cons_f630) def cons_f631(p, n, q): return NonzeroQ(n*(p + q + S(1)) + S(1)) cons631 = CustomConstraint(cons_f631) def cons_f632(p, f, b, d, c, a, n, x, e): if isinstance(x, (int, Integer, float, Float)): return False return FreeQ(List(a, b, c, d, e, f, p, n), x) cons632 = CustomConstraint(cons_f632) def cons_f633(p, f, b, d, c, a, n, x, q, e): if isinstance(x, (int, Integer, float, Float)): return False return FreeQ(List(a, b, c, d, e, f, n, p, q), x) cons633 = CustomConstraint(cons_f633) def cons_f634(d, c): return PositiveQ(d/c) cons634 = CustomConstraint(cons_f634) def cons_f635(f, e): return PositiveQ(f/e) cons635 = CustomConstraint(cons_f635) def cons_f636(d, c, f, e): return Not(SimplerSqrtQ(d/c, f/e)) cons636 = CustomConstraint(cons_f636) def cons_f637(d, c, f, e): return Not(SimplerSqrtQ(-f/e, -d/c)) cons637 = CustomConstraint(cons_f637) def cons_f638(f, e): return PosQ(f/e) cons638 = CustomConstraint(cons_f638) def cons_f639(d, c, f, e): return Not(And(NegQ(f/e), SimplerSqrtQ(-f/e, -d/c))) cons639 = CustomConstraint(cons_f639) def cons_f640(r, q): return RationalQ(q, r) cons640 = CustomConstraint(cons_f640) def cons_f641(r): return Greater(r, S(1)) cons641 = CustomConstraint(cons_f641) def cons_f642(q): return LessEqual(q, S(-1)) cons642 = CustomConstraint(cons_f642) def cons_f643(d, c, f, e): return PosQ((-c*f + d*e)/c) cons643 = CustomConstraint(cons_f643) def cons_f644(d, c, f, e): return NegQ((-c*f + d*e)/c) cons644 = CustomConstraint(cons_f644) def cons_f645(p, f, b, r, d, c, a, n, x, q, e): if isinstance(x, (int, Integer, float, Float)): return False return FreeQ(List(a, b, c, d, e, f, n, p, q, r), x) cons645 = CustomConstraint(cons_f645) def cons_f646(v, u): return ZeroQ(u - v) cons646 = CustomConstraint(cons_f646) def cons_f647(w, u): return ZeroQ(u - w) cons647 = CustomConstraint(cons_f647) def cons_f648(r): return IntegerQ(r) cons648 = CustomConstraint(cons_f648) def cons_f649(n, n2): return ZeroQ(-n/S(2) + n2) cons649 = CustomConstraint(cons_f649) def cons_f650(e2, f1, f2, e1): return ZeroQ(e1*f2 + e2*f1) cons650 = CustomConstraint(cons_f650) def cons_f651(e2, r, e1): return Or(IntegerQ(r), And(PositiveQ(e1), PositiveQ(e2))) cons651 = CustomConstraint(cons_f651) def cons_f652(e1, x): return FreeQ(e1, x) cons652 = CustomConstraint(cons_f652) def cons_f653(f1, x): return FreeQ(f1, x) cons653 = CustomConstraint(cons_f653) def cons_f654(e2, x): return FreeQ(e2, x) cons654 = CustomConstraint(cons_f654) def cons_f655(f2, x): return FreeQ(f2, x) cons655 = CustomConstraint(cons_f655) def cons_f656(m, g): return Or(IntegerQ(m), PositiveQ(g)) cons656 = CustomConstraint(cons_f656) def cons_f657(r, p, q): return PositiveIntegerQ(p + S(2), q, r) cons657 = CustomConstraint(cons_f657) def cons_f658(r, p, q): return IntegersQ(p, q, r) cons658 = CustomConstraint(cons_f658) def cons_f659(f, b, d, c, a, q, e): return Not(And(Equal(q, S(1)), SimplerQ(-a*d + b*c, -a*f + b*e))) cons659 = CustomConstraint(cons_f659) def cons_f660(f, d, c, n, x, q, e): if isinstance(x, (int, Integer, float, Float)): return False return Not(And(Equal(q, S(1)), SimplerQ(e + f*x**n, c + d*x**n))) cons660 = CustomConstraint(cons_f660) def cons_f661(r): return PositiveIntegerQ(r) cons661 = CustomConstraint(cons_f661) def cons_f662(p, m, f, b, g, d, c, a, n, x, q, e): if isinstance(x, (int, Integer, float, Float)): return False return FreeQ(List(a, b, c, d, e, f, g, m, n, p, q), x) cons662 = CustomConstraint(cons_f662) def cons_f663(p, m, f, b, g, r, d, c, a, n, x, q, e): if isinstance(x, (int, Integer, float, Float)): return False return FreeQ(List(a, b, c, d, e, f, g, m, n, p, q, r), x) cons663 = CustomConstraint(cons_f663) def cons_f664(p, n): return ZeroQ(n*(S(2)*p + S(1)) + S(1)) cons664 = CustomConstraint(cons_f664) def cons_f665(p, n): return ZeroQ(S(2)*n*(p + S(1)) + S(1)) cons665 = CustomConstraint(cons_f665) def cons_f666(p, n): return Or(ZeroQ(S(2)*n*p + S(1)), ZeroQ(n*(S(2)*p + S(-1)) + S(1))) cons666 = CustomConstraint(cons_f666) def cons_f667(p): return IntegerQ(p + S(1)/2) cons667 = CustomConstraint(cons_f667) def cons_f668(n): return NonzeroQ(S(2)*n + S(1)) cons668 = CustomConstraint(cons_f668) def cons_f669(p, n): return NonzeroQ(S(2)*n*p + S(1)) cons669 = CustomConstraint(cons_f669) def cons_f670(p, n): return NonzeroQ(n*(S(2)*p + S(-1)) + S(1)) cons670 = CustomConstraint(cons_f670) def cons_f671(p, n): return NonzeroQ(n*(S(2)*p + S(1)) + S(1)) cons671 = CustomConstraint(cons_f671) def cons_f672(p, n): return NonzeroQ(S(2)*n*(p + S(1)) + S(1)) cons672 = CustomConstraint(cons_f672) def cons_f673(p, n): return Or(IntegerQ(p), ZeroQ(n + S(-2))) cons673 = CustomConstraint(cons_f673) def cons_f674(n): return PositiveIntegerQ(n/S(2)) cons674 = CustomConstraint(cons_f674) def cons_f675(c, a, b): return PositiveQ(-S(4)*a*c + b**S(2)) cons675 = CustomConstraint(cons_f675) def cons_f676(c, a): return PositiveQ(c/a) cons676 = CustomConstraint(cons_f676) def cons_f677(a, b): return NegativeQ(b/a) cons677 = CustomConstraint(cons_f677) def cons_f678(c, a): return PosQ(c/a) cons678 = CustomConstraint(cons_f678) def cons_f679(c, a): return NegQ(c/a) cons679 = CustomConstraint(cons_f679) def cons_f680(n, n2): return EqQ(n2, S(2)*n) cons680 = CustomConstraint(cons_f680) def cons_f681(n): return PosQ(n) cons681 = CustomConstraint(cons_f681) def cons_f682(m, n, p): return ZeroQ(m + n*(S(2)*p + S(1)) + S(1)) cons682 = CustomConstraint(cons_f682) def cons_f683(m, n): return NonzeroQ(m + n + S(1)) cons683 = CustomConstraint(cons_f683) def cons_f684(m, n, p): return ZeroQ(m + S(2)*n*(p + S(1)) + S(1)) cons684 = CustomConstraint(cons_f684) def cons_f685(m, n): return Inequality(S(-1), LessEqual, m + n, Less, S(0)) cons685 = CustomConstraint(cons_f685) def cons_f686(m, n): return Less(m + n, S(-1)) cons686 = CustomConstraint(cons_f686) def cons_f687(m, n, p): return Not(And(NegativeIntegerQ((m + S(2)*n*(p + S(1)) + S(1))/n), Greater(p + (m + S(2)*n*(p + S(1)) + S(1))/n, S(0)))) cons687 = CustomConstraint(cons_f687) def cons_f688(m, n, p): return NonzeroQ(m + n*(S(2)*p + S(-1)) + S(1)) cons688 = CustomConstraint(cons_f688) def cons_f689(m, n, p): return Not(And(PositiveIntegerQ(m), IntegerQ((m + S(1))/n), Less(S(-1) + (m + S(1))/n, S(2)*p))) cons689 = CustomConstraint(cons_f689) def cons_f690(m, n): return Inequality(n + S(-1), Less, m, LessEqual, S(2)*n + S(-1)) cons690 = CustomConstraint(cons_f690) def cons_f691(m, p, n): return Or(IntegerQ(S(2)*p), PositiveIntegerQ((m + S(1))/n)) cons691 = CustomConstraint(cons_f691) def cons_f692(m, n, p): return Unequal(m + S(2)*n*p + S(1), S(0)) cons692 = CustomConstraint(cons_f692) def cons_f693(m, n, p): return Unequal(m + n*(S(2)*p + S(-1)) + S(1), S(0)) cons693 = CustomConstraint(cons_f693) def cons_f694(m, p, n): return Or(IntegerQ(p), And(IntegerQ(S(2)*p), IntegerQ(m), Equal(n, S(2)))) cons694 = CustomConstraint(cons_f694) def cons_f695(m, n): return Greater(m, S(3)*n + S(-1)) cons695 = CustomConstraint(cons_f695) def cons_f696(c, a, b): return NegativeQ(-S(4)*a*c + b**S(2)) cons696 = CustomConstraint(cons_f696) def cons_f697(a, c): return PosQ(a*c) cons697 = CustomConstraint(cons_f697) def cons_f698(m, n): return PositiveIntegerQ(n/S(2), m) cons698 = CustomConstraint(cons_f698) def cons_f699(m, n): return Inequality(S(3)*n/S(2), LessEqual, m, Less, S(2)*n) cons699 = CustomConstraint(cons_f699) def cons_f700(m, n): return Inequality(n/S(2), LessEqual, m, Less, S(3)*n/S(2)) cons700 = CustomConstraint(cons_f700) def cons_f701(m, n): return GreaterEqual(m, n) cons701 = CustomConstraint(cons_f701) def cons_f702(p): return NegativeIntegerQ(p + S(1)) cons702 = CustomConstraint(cons_f702) def cons_f703(p, b, d, c, n, e): return ZeroQ(b*e*(n*p + S(1)) - c*d*(n*(S(2)*p + S(1)) + S(1))) cons703 = CustomConstraint(cons_f703) def cons_f704(p, b, d, c, n, e): return NonzeroQ(b*e*(n*p + S(1)) - c*d*(n*(S(2)*p + S(1)) + S(1))) cons704 = CustomConstraint(cons_f704) def cons_f705(d, c, e, a): return ZeroQ(-a*e**S(2) + c*d**S(2)) cons705 = CustomConstraint(cons_f705) def cons_f706(d, e): return PosQ(d*e) cons706 = CustomConstraint(cons_f706) def cons_f707(d, e): return NegQ(d*e) cons707 = CustomConstraint(cons_f707) def cons_f708(d, c, e, a): return NonzeroQ(-a*e**S(2) + c*d**S(2)) cons708 = CustomConstraint(cons_f708) def cons_f709(a, c): return NegQ(a*c) cons709 = CustomConstraint(cons_f709) def cons_f710(a, n, c): return Or(PosQ(a*c), Not(IntegerQ(n))) cons710 = CustomConstraint(cons_f710) def cons_f711(b, d, c, a, e): return Or(PositiveQ(-b/c + S(2)*d/e), And(Not(NegativeQ(-b/c + S(2)*d/e)), ZeroQ(d - e*Rt(a/c, S(2))))) cons711 = CustomConstraint(cons_f711) def cons_f712(c, a, b): return Not(PositiveQ(-S(4)*a*c + b**S(2))) cons712 = CustomConstraint(cons_f712) def cons_f713(c, a, n, b): return Or(PosQ(-S(4)*a*c + b**S(2)), Not(PositiveIntegerQ(n/S(2)))) cons713 = CustomConstraint(cons_f713) def cons_f714(p, n): return NonzeroQ(S(2)*n*p + n + S(1)) cons714 = CustomConstraint(cons_f714) def cons_f715(a, c): return PositiveQ(-a*c) cons715 = CustomConstraint(cons_f715) def cons_f716(p, n, q): return NonzeroQ(S(2)*n*p + n*q + S(1)) cons716 = CustomConstraint(cons_f716) def cons_f717(p): return PositiveIntegerQ(p + S(-1)/2) cons717 = CustomConstraint(cons_f717) def cons_f718(c): return Not(NegativeQ(c)) cons718 = CustomConstraint(cons_f718) def cons_f719(p): return NegativeIntegerQ(p + S(1)/2) cons719 = CustomConstraint(cons_f719) def cons_f720(d, c, b, e): return ZeroQ(-b*e + c*d) cons720 = CustomConstraint(cons_f720) def cons_f721(d, a): return Not(And(PositiveQ(a), PositiveQ(d))) cons721 = CustomConstraint(cons_f721) def cons_f722(p, q, n): return Or(And(IntegersQ(p, q), Not(IntegerQ(n))), PositiveIntegerQ(p), And(PositiveIntegerQ(q), Not(IntegerQ(n)))) cons722 = CustomConstraint(cons_f722) def cons_f723(p, n): return Not(IntegersQ(n, S(2)*p)) cons723 = CustomConstraint(cons_f723) def cons_f724(n, q): return Not(IntegersQ(n, q)) cons724 = CustomConstraint(cons_f724) def cons_f725(mn, n2): return EqQ(n2, -S(2)*mn) cons725 = CustomConstraint(cons_f725) def cons_f726(mn, x): return FreeQ(mn, x) cons726 = CustomConstraint(cons_f726) def cons_f727(n2): return PosQ(n2) cons727 = CustomConstraint(cons_f727) def cons_f728(n2): return NegQ(n2) cons728 = CustomConstraint(cons_f728) def cons_f729(e2, d2, d1, e1): return ZeroQ(d1*e2 + d2*e1) cons729 = CustomConstraint(cons_f729) def cons_f730(d2, q, d1): return Or(IntegerQ(q), And(PositiveQ(d1), PositiveQ(d2))) cons730 = CustomConstraint(cons_f730) def cons_f731(d1, x): return FreeQ(d1, x) cons731 = CustomConstraint(cons_f731) def cons_f732(d2, x): return FreeQ(d2, x) cons732 = CustomConstraint(cons_f732) def cons_f733(m, f): return Or(IntegerQ(m), PositiveQ(f)) cons733 = CustomConstraint(cons_f733) def cons_f734(m, n): return PositiveIntegerQ(m, n, (m + S(1))/n) cons734 = CustomConstraint(cons_f734) def cons_f735(m, q): return IntegersQ(m, q) cons735 = CustomConstraint(cons_f735) def cons_f736(p, n): return Greater(S(2)*n*p, n + S(-1)) cons736 = CustomConstraint(cons_f736) def cons_f737(m, n, p, q): return NonzeroQ(m + S(2)*n*p + n*q + S(1)) cons737 = CustomConstraint(cons_f737) def cons_f738(m, n, p): return Unequal(m + n*(S(2)*p + S(1)) + S(1), S(0)) cons738 = CustomConstraint(cons_f738) def cons_f739(m, n, p): return NonzeroQ(m + n*(S(2)*p + S(1)) + S(1)) cons739 = CustomConstraint(cons_f739) def cons_f740(m, n): return IntegersQ(m, n/S(2)) cons740 = CustomConstraint(cons_f740) def cons_f741(d, e): return PositiveQ(d/e) cons741 = CustomConstraint(cons_f741) def cons_f742(d, c, b, e): return PosQ(c*(-b*e + S(2)*c*d)/e) cons742 = CustomConstraint(cons_f742) def cons_f743(n): return IntegerQ(n/S(2)) cons743 = CustomConstraint(cons_f743) def cons_f744(n): return Greater(n, S(2)) cons744 = CustomConstraint(cons_f744) def cons_f745(m, n): return Less(m, -n) cons745 = CustomConstraint(cons_f745) def cons_f746(m, n): return Greater(m, n) cons746 = CustomConstraint(cons_f746) def cons_f747(m, q): return Or(PositiveIntegerQ(q), IntegersQ(m, q)) cons747 = CustomConstraint(cons_f747) def cons_f748(p, q): return Or(PositiveIntegerQ(p), PositiveIntegerQ(q)) cons748 = CustomConstraint(cons_f748) def cons_f749(m, f): return Not(Or(IntegerQ(m), PositiveQ(f))) cons749 = CustomConstraint(cons_f749) def cons_f750(n, q): return ZeroQ(n - q) cons750 = CustomConstraint(cons_f750) def cons_f751(n, r): return ZeroQ(-n + r) cons751 = CustomConstraint(cons_f751) def cons_f752(n, r, q): return ZeroQ(-S(2)*n + q + r) cons752 = CustomConstraint(cons_f752) def cons_f753(n, q): return PosQ(n - q) cons753 = CustomConstraint(cons_f753) def cons_f754(p, q, n): return NonzeroQ(p*(S(2)*n - q) + S(1)) cons754 = CustomConstraint(cons_f754) def cons_f755(n, q): return ZeroQ(-n + q) cons755 = CustomConstraint(cons_f755) def cons_f756(m, n, q): return Or(And(ZeroQ(m + S(-1)), ZeroQ(n + S(-3)), ZeroQ(q + S(-2))), And(Or(ZeroQ(m + S(1)/2), ZeroQ(m + S(-3)/2), ZeroQ(m + S(-1)/2), ZeroQ(m + S(-5)/2)), ZeroQ(n + S(-3)), ZeroQ(q + S(-1)))) cons756 = CustomConstraint(cons_f756) def cons_f757(m, n): return ZeroQ(m - S(3)*n/S(2) + S(3)/2) cons757 = CustomConstraint(cons_f757) def cons_f758(n, q): return ZeroQ(-n + q + S(1)) cons758 = CustomConstraint(cons_f758) def cons_f759(n, r): return ZeroQ(-n + r + S(-1)) cons759 = CustomConstraint(cons_f759) def cons_f760(m, n): return ZeroQ(m - S(3)*n/S(2) + S(1)/2) cons760 = CustomConstraint(cons_f760) def cons_f761(m, p, n): return Equal(m + p*(n + S(-1)) + S(-1), S(0)) cons761 = CustomConstraint(cons_f761) def cons_f762(m, p, q, n): return Equal(m + p*q + S(1), n - q) cons762 = CustomConstraint(cons_f762) def cons_f763(m, p, q, n): return Greater(m + p*q + S(1), n - q) cons763 = CustomConstraint(cons_f763) def cons_f764(m, p, q, n): return Unequal(m + p*(S(2)*n - q) + S(1), S(0)) cons764 = CustomConstraint(cons_f764) def cons_f765(m, p, q, n): return Unequal(m + p*q + (n - q)*(S(2)*p + S(-1)) + S(1), S(0)) cons765 = CustomConstraint(cons_f765) def cons_f766(m, p, q, n): return LessEqual(m + p*q + S(1), -n + q + S(1)) cons766 = CustomConstraint(cons_f766) def cons_f767(m, p, q): return NonzeroQ(m + p*q + S(1)) cons767 = CustomConstraint(cons_f767) def cons_f768(m, p, q, n): return Greater(m + p*q + S(1), -n + q) cons768 = CustomConstraint(cons_f768) def cons_f769(m, p, q, n): return Equal(m + p*q + S(1), -(n - q)*(S(2)*p + S(3))) cons769 = CustomConstraint(cons_f769) def cons_f770(m, p, q, n): return Greater(m + p*q + S(1), S(2)*n - S(2)*q) cons770 = CustomConstraint(cons_f770) def cons_f771(m, p, q, n): return Less(m + p*q + S(1), n - q) cons771 = CustomConstraint(cons_f771) def cons_f772(m, n, p, q): return Less(n - q, m + p*q + S(1), S(2)*n - S(2)*q) cons772 = CustomConstraint(cons_f772) def cons_f773(p): return Inequality(S(-1), LessEqual, p, Less, S(0)) cons773 = CustomConstraint(cons_f773) def cons_f774(m, p, q, n): return Equal(m + p*q + S(1), S(2)*n - S(2)*q) cons774 = CustomConstraint(cons_f774) def cons_f775(m, p, q, n): return Equal(m + p*q + S(1), -S(2)*(n - q)*(p + S(1))) cons775 = CustomConstraint(cons_f775) def cons_f776(m, p, q): return Less(m + p*q + S(1), S(0)) cons776 = CustomConstraint(cons_f776) def cons_f777(n, r, q): return ZeroQ(-n + q + r) cons777 = CustomConstraint(cons_f777) def cons_f778(n, q, j): return ZeroQ(j - S(2)*n + q) cons778 = CustomConstraint(cons_f778) def cons_f779(n, q, j): return ZeroQ(j - n + q) cons779 = CustomConstraint(cons_f779) def cons_f780(n): return ZeroQ(n + S(-3)) cons780 = CustomConstraint(cons_f780) def cons_f781(q): return ZeroQ(q + S(-2)) cons781 = CustomConstraint(cons_f781) def cons_f782(p, q, n): return NonzeroQ(p*q + (n - q)*(S(2)*p + S(1)) + S(1)) cons782 = CustomConstraint(cons_f782) def cons_f783(m, p, q, n): return LessEqual(m + p*q, -n + q) cons783 = CustomConstraint(cons_f783) def cons_f784(m, p, q): return Unequal(m + p*q + S(1), S(0)) cons784 = CustomConstraint(cons_f784) def cons_f785(m, p, q, n): return Unequal(m + p*q + (n - q)*(S(2)*p + S(1)) + S(1), S(0)) cons785 = CustomConstraint(cons_f785) def cons_f786(m, p, q, n): return Greater(m + p*q, n - q + S(-1)) cons786 = CustomConstraint(cons_f786) def cons_f787(m, p, q, n): return Greater(m + p*q, -n + q + S(-1)) cons787 = CustomConstraint(cons_f787) def cons_f788(m, p, q, n): return Less(m + p*q, n - q + S(-1)) cons788 = CustomConstraint(cons_f788) def cons_f789(m, p, q, n): return GreaterEqual(m + p*q, n - q + S(-1)) cons789 = CustomConstraint(cons_f789) def cons_f790(m, p, q, n): return Or(Inequality(S(-1), LessEqual, p, Less, S(0)), Equal(m + p*q + (n - q)*(S(2)*p + S(1)) + S(1), S(0))) cons790 = CustomConstraint(cons_f790) def cons_f791(m): return Or(ZeroQ(m + S(-1)/2), ZeroQ(m + S(1)/2)) cons791 = CustomConstraint(cons_f791) def cons_f792(q): return ZeroQ(q + S(-1)) cons792 = CustomConstraint(cons_f792) def cons_f793(q, j, k): return ZeroQ(j - k + q) cons793 = CustomConstraint(cons_f793) def cons_f794(n, j, k): return ZeroQ(j - S(2)*k + n) cons794 = CustomConstraint(cons_f794) def cons_f795(j, k): return PosQ(-j + k) cons795 = CustomConstraint(cons_f795) def cons_f796(j, x): return FreeQ(j, x) cons796 = CustomConstraint(cons_f796) def cons_f797(k, x): return FreeQ(k, x) cons797 = CustomConstraint(cons_f797) def cons_f798(n, q): return IntegerQ(n*q) cons798 = CustomConstraint(cons_f798) def cons_f799(p, m, f, b, r, d, c, a, n, x, s, q, e): if isinstance(x, (int, Integer, float, Float)): return False return FreeQ(List(a, b, c, d, e, f, m, n, p, q, r, s), x) cons799 = CustomConstraint(cons_f799) def cons_f800(s, x): return FreeQ(s, x) cons800 = CustomConstraint(cons_f800) def cons_f801(d, b, e): return PositiveQ(b*d*e) cons801 = CustomConstraint(cons_f801) def cons_f802(d, c, b, a): return PositiveQ(-a*d/b + c) cons802 = CustomConstraint(cons_f802) def cons_f803(n): return IntegerQ(S(1)/n) cons803 = CustomConstraint(cons_f803) def cons_f804(x, u): if isinstance(x, (int, Integer, float, Float)): return False return PolynomialQ(u, x) cons804 = CustomConstraint(cons_f804) def cons_f805(m, r): return IntegersQ(m, r) cons805 = CustomConstraint(cons_f805) def cons_f806(p, b, c, a, n, x): if isinstance(x, (int, Integer, float, Float)): return False return FreeQ(List(a, b, c, n, p), x) cons806 = CustomConstraint(cons_f806) def cons_f807(n, n2): return ZeroQ(S(2)*n + n2) cons807 = CustomConstraint(cons_f807) def cons_f808(n): return IntegerQ(S(2)*n) cons808 = CustomConstraint(cons_f808) def cons_f809(x, u): if isinstance(x, (int, Integer, float, Float)): return False return Not(LinearMatchQ(u, x)) cons809 = CustomConstraint(cons_f809) def cons_f810(v, x, u): if isinstance(x, (int, Integer, float, Float)): return False return LinearQ(List(u, v), x) cons810 = CustomConstraint(cons_f810) def cons_f811(v, x, u): if isinstance(x, (int, Integer, float, Float)): return False return Not(LinearMatchQ(List(u, v), x)) cons811 = CustomConstraint(cons_f811) def cons_f812(v, w, u, x): if isinstance(x, (int, Integer, float, Float)): return False return LinearQ(List(u, v, w), x) cons812 = CustomConstraint(cons_f812) def cons_f813(v, w, u, x): if isinstance(x, (int, Integer, float, Float)): return False return Not(LinearMatchQ(List(u, v, w), x)) cons813 = CustomConstraint(cons_f813) def cons_f814(v, z, w, u, x): if isinstance(x, (int, Integer, float, Float)): return False return LinearQ(List(u, v, w, z), x) cons814 = CustomConstraint(cons_f814) def cons_f815(v, z, w, u, x): if isinstance(x, (int, Integer, float, Float)): return False return Not(LinearMatchQ(List(u, v, w, z), x)) cons815 = CustomConstraint(cons_f815) def cons_f816(x, u): if isinstance(x, (int, Integer, float, Float)): return False return QuadraticQ(u, x) cons816 = CustomConstraint(cons_f816) def cons_f817(x, u): if isinstance(x, (int, Integer, float, Float)): return False return Not(QuadraticMatchQ(u, x)) cons817 = CustomConstraint(cons_f817) def cons_f818(v, x): if isinstance(x, (int, Integer, float, Float)): return False return QuadraticQ(v, x) cons818 = CustomConstraint(cons_f818) def cons_f819(x, u, v): if isinstance(x, (int, Integer, float, Float)): return False return Not(And(LinearMatchQ(u, x), QuadraticMatchQ(v, x))) cons819 = CustomConstraint(cons_f819) def cons_f820(x, w): if isinstance(x, (int, Integer, float, Float)): return False return QuadraticQ(w, x) cons820 = CustomConstraint(cons_f820) def cons_f821(v, x, w, u): if isinstance(x, (int, Integer, float, Float)): return False return Not(And(LinearMatchQ(List(u, v), x), QuadraticMatchQ(w, x))) cons821 = CustomConstraint(cons_f821) def cons_f822(v, x, u): if isinstance(x, (int, Integer, float, Float)): return False return Not(QuadraticMatchQ(List(u, v), x)) cons822 = CustomConstraint(cons_f822) def cons_f823(x, u): if isinstance(x, (int, Integer, float, Float)): return False return BinomialQ(u, x) cons823 = CustomConstraint(cons_f823) def cons_f824(x, u): if isinstance(x, (int, Integer, float, Float)): return False return Not(BinomialMatchQ(u, x)) cons824 = CustomConstraint(cons_f824) def cons_f825(v, x, u): if isinstance(x, (int, Integer, float, Float)): return False return BinomialQ(List(u, v), x) cons825 = CustomConstraint(cons_f825) def cons_f826(x, u, v): if isinstance(x, (int, Integer, float, Float)): return False try: return ZeroQ(BinomialDegree(u, x) - BinomialDegree(v, x)) except (TypeError, AttributeError): return False cons826 = CustomConstraint(cons_f826) def cons_f827(v, x, u): if isinstance(x, (int, Integer, float, Float)): return False return Not(BinomialMatchQ(List(u, v), x)) cons827 = CustomConstraint(cons_f827) def cons_f828(v, w, u, x): if isinstance(x, (int, Integer, float, Float)): return False return BinomialQ(List(u, v, w), x) cons828 = CustomConstraint(cons_f828) def cons_f829(x, w, u): if isinstance(x, (int, Integer, float, Float)): return False try: return ZeroQ(BinomialDegree(u, x) - BinomialDegree(w, x)) except (TypeError, AttributeError): return False cons829 = CustomConstraint(cons_f829) def cons_f830(v, w, u, x): if isinstance(x, (int, Integer, float, Float)): return False return Not(BinomialMatchQ(List(u, v, w), x)) cons830 = CustomConstraint(cons_f830) def cons_f831(v, z, x, u): if isinstance(x, (int, Integer, float, Float)): return False return BinomialQ(List(u, v, z), x) cons831 = CustomConstraint(cons_f831) def cons_f832(x, z, u): if isinstance(x, (int, Integer, float, Float)): return False try: return ZeroQ(BinomialDegree(u, x) - BinomialDegree(z, x)) except (TypeError, AttributeError): return False cons832 = CustomConstraint(cons_f832) def cons_f833(v, z, x, u): if isinstance(x, (int, Integer, float, Float)): return False return Not(BinomialMatchQ(List(u, v, z), x)) cons833 = CustomConstraint(cons_f833) def cons_f834(x, u): if isinstance(x, (int, Integer, float, Float)): return False return GeneralizedBinomialQ(u, x) cons834 = CustomConstraint(cons_f834) def cons_f835(x, u): if isinstance(x, (int, Integer, float, Float)): return False return Not(GeneralizedBinomialMatchQ(u, x)) cons835 = CustomConstraint(cons_f835) def cons_f836(x, u): if isinstance(x, (int, Integer, float, Float)): return False return TrinomialQ(u, x) cons836 = CustomConstraint(cons_f836) def cons_f837(x, u): if isinstance(x, (int, Integer, float, Float)): return False return Not(TrinomialMatchQ(u, x)) cons837 = CustomConstraint(cons_f837) def cons_f838(v, x): if isinstance(x, (int, Integer, float, Float)): return False return TrinomialQ(v, x) cons838 = CustomConstraint(cons_f838) def cons_f839(x, u, v): if isinstance(x, (int, Integer, float, Float)): return False return Not(And(BinomialMatchQ(u, x), TrinomialMatchQ(v, x))) cons839 = CustomConstraint(cons_f839) def cons_f840(v, x): if isinstance(x, (int, Integer, float, Float)): return False return BinomialQ(v, x) cons840 = CustomConstraint(cons_f840) def cons_f841(x, u, v): if isinstance(x, (int, Integer, float, Float)): return False return Not(And(BinomialMatchQ(u, x), BinomialMatchQ(v, x))) cons841 = CustomConstraint(cons_f841) def cons_f842(x, z): if isinstance(x, (int, Integer, float, Float)): return False return BinomialQ(z, x) cons842 = CustomConstraint(cons_f842) def cons_f843(x, z, u): if isinstance(x, (int, Integer, float, Float)): return False return Not(And(BinomialMatchQ(z, x), TrinomialMatchQ(u, x))) cons843 = CustomConstraint(cons_f843) def cons_f844(x, z, u): if isinstance(x, (int, Integer, float, Float)): return False return Not(And(BinomialMatchQ(z, x), BinomialMatchQ(u, x))) cons844 = CustomConstraint(cons_f844) def cons_f845(x, u): if isinstance(x, (int, Integer, float, Float)): return False return GeneralizedTrinomialQ(u, x) cons845 = CustomConstraint(cons_f845) def cons_f846(x, u): if isinstance(x, (int, Integer, float, Float)): return False return Not(GeneralizedTrinomialMatchQ(u, x)) cons846 = CustomConstraint(cons_f846) def cons_f847(x, z, u): if isinstance(x, (int, Integer, float, Float)): return False try: return ZeroQ(BinomialDegree(z, x) - GeneralizedTrinomialDegree(u, x)) except (TypeError, AttributeError): return False cons847 = CustomConstraint(cons_f847) def cons_f848(x, z, u): if isinstance(x, (int, Integer, float, Float)): return False return Not(And(BinomialMatchQ(z, x), GeneralizedTrinomialMatchQ(u, x))) cons848 = CustomConstraint(cons_f848) def cons_f849(n, q): return ZeroQ(-n/S(4) + q) cons849 = CustomConstraint(cons_f849) def cons_f850(n, r): return ZeroQ(-S(3)*n/S(4) + r) cons850 = CustomConstraint(cons_f850) def cons_f851(m, n): return ZeroQ(S(4)*m - n + S(4)) cons851 = CustomConstraint(cons_f851) def cons_f852(c, h, e, a): return ZeroQ(a*h + c*e) cons852 = CustomConstraint(cons_f852) def cons_f853(m): return NegativeIntegerQ(m + S(1)) cons853 = CustomConstraint(cons_f853) def cons_f854(m, n): return PositiveIntegerQ(n/(m + S(1))) cons854 = CustomConstraint(cons_f854) def cons_f855(x, m, Pq): if isinstance(x, (int, Integer, float, Float)): return False return PolyQ(Pq, x**(m + S(1))) cons855 = CustomConstraint(cons_f855) def cons_f856(x, n, Pq): if isinstance(x, (int, Integer, float, Float)): return False return NonzeroQ(Coeff(Pq, x, n + S(-1))) cons856 = CustomConstraint(cons_f856) def cons_f857(p, n): return Or(PositiveIntegerQ(p), ZeroQ(n + S(-1))) cons857 = CustomConstraint(cons_f857) def cons_f858(x, n, Pq): if isinstance(x, (int, Integer, float, Float)): return False return PolyQ(Pq, x**n) cons858 = CustomConstraint(cons_f858) def cons_f859(x, Pq): if isinstance(x, (int, Integer, float, Float)): return False return ZeroQ(Coeff(Pq, x, S(0))) cons859 = CustomConstraint(cons_f859) def cons_f860(Pq): return SumQ(Pq) cons860 = CustomConstraint(cons_f860) def cons_f861(x, m, Pq): if isinstance(x, (int, Integer, float, Float)): return False return Less(m + Expon(Pq, x) + S(1), S(0)) cons861 = CustomConstraint(cons_f861) def cons_f862(x, n, Pq): if isinstance(x, (int, Integer, float, Float)): return False return Less(Expon(Pq, x), n + S(-1)) cons862 = CustomConstraint(cons_f862) def cons_f863(d, a, g, b): return ZeroQ(a*g + b*d) cons863 = CustomConstraint(cons_f863) def cons_f864(a, h, b, e): return ZeroQ(-S(3)*a*h + b*e) cons864 = CustomConstraint(cons_f864) def cons_f865(B, a, b, A): return ZeroQ(-A**S(3)*b + B**S(3)*a) cons865 = CustomConstraint(cons_f865) def cons_f866(B, a, b, A): return NonzeroQ(-A**S(3)*b + B**S(3)*a) cons866 = CustomConstraint(cons_f866) def cons_f867(B, C, A): return ZeroQ(-A*C + B**S(2)) cons867 = CustomConstraint(cons_f867) def cons_f868(B, a, C, b): return ZeroQ(B**S(3)*b + C**S(3)*a) cons868 = CustomConstraint(cons_f868) def cons_f869(B, C, b, a, A): return ZeroQ(A*b**(S(2)/3) - B*a**(S(1)/3)*b**(S(1)/3) - S(2)*C*a**(S(2)/3)) cons869 = CustomConstraint(cons_f869) def cons_f870(B, a, C, b): return ZeroQ(B*a**(S(1)/3)*b**(S(1)/3) + S(2)*C*a**(S(2)/3)) cons870 = CustomConstraint(cons_f870) def cons_f871(a, C, b, A): return ZeroQ(A*b**(S(2)/3) - S(2)*C*a**(S(2)/3)) cons871 = CustomConstraint(cons_f871) def cons_f872(B, C, b, a, A): return ZeroQ(A*(-b)**(S(2)/3) - B*(-a)**(S(1)/3)*(-b)**(S(1)/3) - S(2)*C*(-a)**(S(2)/3)) cons872 = CustomConstraint(cons_f872) def cons_f873(B, a, C, b): return ZeroQ(B*(-a)**(S(1)/3)*(-b)**(S(1)/3) + S(2)*C*(-a)**(S(2)/3)) cons873 = CustomConstraint(cons_f873) def cons_f874(a, C, b, A): return ZeroQ(A*(-b)**(S(2)/3) - S(2)*C*(-a)**(S(2)/3)) cons874 = CustomConstraint(cons_f874) def cons_f875(B, C, b, a, A): return ZeroQ(A*b**(S(2)/3) + B*b**(S(1)/3)*(-a)**(S(1)/3) - S(2)*C*(-a)**(S(2)/3)) cons875 = CustomConstraint(cons_f875) def cons_f876(B, a, C, b): return ZeroQ(B*b**(S(1)/3)*(-a)**(S(1)/3) - S(2)*C*(-a)**(S(2)/3)) cons876 = CustomConstraint(cons_f876) def cons_f877(a, C, b, A): return ZeroQ(A*b**(S(2)/3) - S(2)*C*(-a)**(S(2)/3)) cons877 = CustomConstraint(cons_f877) def cons_f878(B, C, b, a, A): return ZeroQ(A*(-b)**(S(2)/3) + B*a**(S(1)/3)*(-b)**(S(1)/3) - S(2)*C*a**(S(2)/3)) cons878 = CustomConstraint(cons_f878) def cons_f879(B, a, C, b): return ZeroQ(B*a**(S(1)/3)*(-b)**(S(1)/3) - S(2)*C*a**(S(2)/3)) cons879 = CustomConstraint(cons_f879) def cons_f880(a, C, b, A): return ZeroQ(A*(-b)**(S(2)/3) - S(2)*C*a**(S(2)/3)) cons880 = CustomConstraint(cons_f880) def cons_f881(B, C, b, a, A): return ZeroQ(A - B*(a/b)**(S(1)/3) - S(2)*C*(a/b)**(S(2)/3)) cons881 = CustomConstraint(cons_f881) def cons_f882(B, a, C, b): return ZeroQ(B*(a/b)**(S(1)/3) + S(2)*C*(a/b)**(S(2)/3)) cons882 = CustomConstraint(cons_f882) def cons_f883(a, C, b, A): return ZeroQ(A - S(2)*C*(a/b)**(S(2)/3)) cons883 = CustomConstraint(cons_f883) def cons_f884(B, C, b, a, A): return ZeroQ(A - B*Rt(a/b, S(3)) - S(2)*C*Rt(a/b, S(3))**S(2)) cons884 = CustomConstraint(cons_f884) def cons_f885(B, a, C, b): return ZeroQ(B*Rt(a/b, S(3)) + S(2)*C*Rt(a/b, S(3))**S(2)) cons885 = CustomConstraint(cons_f885) def cons_f886(a, C, b, A): return ZeroQ(A - S(2)*C*Rt(a/b, S(3))**S(2)) cons886 = CustomConstraint(cons_f886) def cons_f887(B, C, b, a, A): return ZeroQ(A + B*(-a/b)**(S(1)/3) - S(2)*C*(-a/b)**(S(2)/3)) cons887 = CustomConstraint(cons_f887) def cons_f888(B, a, C, b): return ZeroQ(B*(-a/b)**(S(1)/3) - S(2)*C*(-a/b)**(S(2)/3)) cons888 = CustomConstraint(cons_f888) def cons_f889(a, C, b, A): return ZeroQ(A - S(2)*C*(-a/b)**(S(2)/3)) cons889 = CustomConstraint(cons_f889) def cons_f890(B, C, b, a, A): return ZeroQ(A + B*Rt(-a/b, S(3)) - S(2)*C*Rt(-a/b, S(3))**S(2)) cons890 = CustomConstraint(cons_f890) def cons_f891(B, a, C, b): return ZeroQ(B*Rt(-a/b, S(3)) - S(2)*C*Rt(-a/b, S(3))**S(2)) cons891 = CustomConstraint(cons_f891) def cons_f892(a, C, b, A): return ZeroQ(A - S(2)*C*Rt(-a/b, S(3))**S(2)) cons892 = CustomConstraint(cons_f892) def cons_f893(B, a, b, A): return Or(ZeroQ(-A**S(3)*b + B**S(3)*a), Not(RationalQ(a/b))) cons893 = CustomConstraint(cons_f893) def cons_f894(a, b): return Not(RationalQ(a/b)) cons894 = CustomConstraint(cons_f894) def cons_f895(a, C, b, A): return Not(RationalQ(a, b, A, C)) cons895 = CustomConstraint(cons_f895) def cons_f896(B, C, b, a, A): return ZeroQ(A - B*(a/b)**(S(1)/3) + C*(a/b)**(S(2)/3)) cons896 = CustomConstraint(cons_f896) def cons_f897(B, a, C, b): return ZeroQ(B*(a/b)**(S(1)/3) - C*(a/b)**(S(2)/3)) cons897 = CustomConstraint(cons_f897) def cons_f898(a, C, b, A): return ZeroQ(A + C*(a/b)**(S(2)/3)) cons898 = CustomConstraint(cons_f898) def cons_f899(B, C, b, a, A): return ZeroQ(A + B*(-a/b)**(S(1)/3) + C*(-a/b)**(S(2)/3)) cons899 = CustomConstraint(cons_f899) def cons_f900(B, a, C, b): return ZeroQ(B*(-a/b)**(S(1)/3) + C*(-a/b)**(S(2)/3)) cons900 = CustomConstraint(cons_f900) def cons_f901(a, C, b, A): return ZeroQ(A + C*(-a/b)**(S(2)/3)) cons901 = CustomConstraint(cons_f901) def cons_f902(a, b): return RationalQ(a/b) cons902 = CustomConstraint(cons_f902) def cons_f903(a, b): return Greater(a/b, S(0)) cons903 = CustomConstraint(cons_f903) def cons_f904(a, b): return Less(a/b, S(0)) cons904 = CustomConstraint(cons_f904) def cons_f905(x, n, Pq): if isinstance(x, (int, Integer, float, Float)): return False return Less(Expon(Pq, x), n) cons905 = CustomConstraint(cons_f905) def cons_f906(d, c, b, a): return ZeroQ(c*Rt(b/a, S(3)) - d*(-sqrt(S(3)) + S(1))) cons906 = CustomConstraint(cons_f906) def cons_f907(d, c, b, a): return NonzeroQ(c*Rt(b/a, S(3)) - d*(-sqrt(S(3)) + S(1))) cons907 = CustomConstraint(cons_f907) def cons_f908(d, c, b, a): return ZeroQ(c*Rt(b/a, S(3)) - d*(S(1) + sqrt(S(3)))) cons908 = CustomConstraint(cons_f908) def cons_f909(d, c, b, a): return NonzeroQ(c*Rt(b/a, S(3)) - d*(S(1) + sqrt(S(3)))) cons909 = CustomConstraint(cons_f909) def cons_f910(d, c, a, b): return ZeroQ(S(2)*c*Rt(b/a, S(3))**S(2) - d*(-sqrt(S(3)) + S(1))) cons910 = CustomConstraint(cons_f910) def cons_f911(d, c, a, b): return NonzeroQ(S(2)*c*Rt(b/a, S(3))**S(2) - d*(-sqrt(S(3)) + S(1))) cons911 = CustomConstraint(cons_f911) def cons_f912(d, c, b, a): return ZeroQ(-a*d**S(4) + b*c**S(4)) cons912 = CustomConstraint(cons_f912) def cons_f913(d, c, b, a): return NonzeroQ(-a*d**S(4) + b*c**S(4)) cons913 = CustomConstraint(cons_f913) def cons_f914(x, Pq): if isinstance(x, (int, Integer, float, Float)): return False return NonzeroQ(Coeff(Pq, x, S(0))) cons914 = CustomConstraint(cons_f914) def cons_f915(x, n, Pq): if isinstance(x, (int, Integer, float, Float)): return False return Not(PolyQ(Pq, x**(n/S(2)))) cons915 = CustomConstraint(cons_f915) def cons_f916(x, n, Pq): if isinstance(x, (int, Integer, float, Float)): return False return Equal(Expon(Pq, x), n + S(-1)) cons916 = CustomConstraint(cons_f916) def cons_f917(x, n, Pq): if isinstance(x, (int, Integer, float, Float)): return False return LessEqual(n + S(-1), Expon(Pq, x)) cons917 = CustomConstraint(cons_f917) def cons_f918(x, n, Pq): if isinstance(x, (int, Integer, float, Float)): return False return Or(PolyQ(Pq, x), PolyQ(Pq, x**n)) cons918 = CustomConstraint(cons_f918) def cons_f919(v, n, Pq): return PolyQ(Pq, v**n) cons919 = CustomConstraint(cons_f919) def cons_f920(p, f, b, d, a, c, n, e): return ZeroQ(a*c*f - e*(a*d + b*c)*(n*(p + S(1)) + S(1))) cons920 = CustomConstraint(cons_f920) def cons_f921(p, g, b, d, a, c, n, e): return ZeroQ(a*c*g - b*d*e*(S(2)*n*(p + S(1)) + S(1))) cons921 = CustomConstraint(cons_f921) def cons_f922(p, n): return ZeroQ(n*(p + S(1)) + S(1)) cons922 = CustomConstraint(cons_f922) def cons_f923(p, m, f, b, d, a, c, n, e): return ZeroQ(a*c*f*(m + S(1)) - e*(a*d + b*c)*(m + n*(p + S(1)) + S(1))) cons923 = CustomConstraint(cons_f923) def cons_f924(p, m, g, b, d, a, c, n, e): return ZeroQ(a*c*g*(m + S(1)) - b*d*e*(m + S(2)*n*(p + S(1)) + S(1))) cons924 = CustomConstraint(cons_f924) def cons_f925(x, Px): if isinstance(x, (int, Integer, float, Float)): return False return PolynomialQ(Px, x) cons925 = CustomConstraint(cons_f925) def cons_f926(p, b, d, a, n, e): return ZeroQ(a*e - b*d*(n*(p + S(1)) + S(1))) cons926 = CustomConstraint(cons_f926) def cons_f927(p, f, d, a, c, n): return ZeroQ(a*f - c*d*(S(2)*n*(p + S(1)) + S(1))) cons927 = CustomConstraint(cons_f927) def cons_f928(d, c, f, a): return ZeroQ(a*f + c*d) cons928 = CustomConstraint(cons_f928) def cons_f929(p, m, b, d, a, n, e): return ZeroQ(a*e*(m + S(1)) - b*d*(m + n*(p + S(1)) + S(1))) cons929 = CustomConstraint(cons_f929) def cons_f930(p, m, f, d, a, c, n): return ZeroQ(a*f*(m + S(1)) - c*d*(m + S(2)*n*(p + S(1)) + S(1))) cons930 = CustomConstraint(cons_f930) def cons_f931(n3, n): return ZeroQ(-S(3)*n + n3) cons931 = CustomConstraint(cons_f931) def cons_f932(p, g, b, d, a, c, n, e): return ZeroQ(a**S(2)*g*(n + S(1)) - c*(a*e - b*d*(n*(p + S(1)) + S(1)))*(n*(S(2)*p + S(3)) + S(1))) cons932 = CustomConstraint(cons_f932) def cons_f933(p, f, b, d, a, c, n, e): return ZeroQ(a**S(2)*f*(n + S(1)) - a*c*d*(n + S(1))*(S(2)*n*(p + S(1)) + S(1)) - b*(a*e - b*d*(n*(p + S(1)) + S(1)))*(n*(p + S(2)) + S(1))) cons933 = CustomConstraint(cons_f933) def cons_f934(p, g, b, d, a, c, n): return ZeroQ(a**S(2)*g*(n + S(1)) + b*c*d*(n*(p + S(1)) + S(1))*(n*(S(2)*p + S(3)) + S(1))) cons934 = CustomConstraint(cons_f934) def cons_f935(p, f, b, d, a, c, n): return ZeroQ(a**S(2)*f*(n + S(1)) - a*c*d*(n + S(1))*(S(2)*n*(p + S(1)) + S(1)) + b**S(2)*d*(n*(p + S(1)) + S(1))*(n*(p + S(2)) + S(1))) cons935 = CustomConstraint(cons_f935) def cons_f936(p, b, d, a, n, c, e): return ZeroQ(a*c*d*(n + S(1))*(S(2)*n*(p + S(1)) + S(1)) + b*(a*e - b*d*(n*(p + S(1)) + S(1)))*(n*(p + S(2)) + S(1))) cons936 = CustomConstraint(cons_f936) def cons_f937(p, b, d, a, n, c): return ZeroQ(a*c*d*(n + S(1))*(S(2)*n*(p + S(1)) + S(1)) - b**S(2)*d*(n*(p + S(1)) + S(1))*(n*(p + S(2)) + S(1))) cons937 = CustomConstraint(cons_f937) def cons_f938(n, q): return ZeroQ(-n/S(2) + q) cons938 = CustomConstraint(cons_f938) def cons_f939(n, r): return ZeroQ(-S(3)*n/S(2) + r) cons939 = CustomConstraint(cons_f939) def cons_f940(n, s): return ZeroQ(-S(2)*n + s) cons940 = CustomConstraint(cons_f940) def cons_f941(m, n): return ZeroQ(S(2)*m - n + S(2)) cons941 = CustomConstraint(cons_f941) def cons_f942(d, c, g, a): return ZeroQ(a*g + c*d) cons942 = CustomConstraint(cons_f942) def cons_f943(c, h, e, a): return ZeroQ(-S(3)*a*h + c*e) cons943 = CustomConstraint(cons_f943) def cons_f944(h, c, g, b): return ZeroQ(-S(2)*b*h + c*g) cons944 = CustomConstraint(cons_f944) def cons_f945(g, b, d, c, a, e): return ZeroQ(S(3)*a*g - S(2)*b*e + S(3)*c*d) cons945 = CustomConstraint(cons_f945) def cons_f946(d, c, b, e): return ZeroQ(-S(2)*b*e + S(3)*c*d) cons946 = CustomConstraint(cons_f946) def cons_f947(b, Pq, c, a, n, x): if isinstance(x, (int, Integer, float, Float)): return False return Or(NiceSqrtQ(-S(4)*a*c + b**S(2)), Less(Expon(Pq, x), n)) cons947 = CustomConstraint(cons_f947) def cons_f948(c): return PosQ(c) cons948 = CustomConstraint(cons_f948) def cons_f949(c): return NegQ(c) cons949 = CustomConstraint(cons_f949) def cons_f950(x, n, Pq): if isinstance(x, (int, Integer, float, Float)): return False return Not(PolyQ(Pq, x**n)) cons950 = CustomConstraint(cons_f950) def cons_f951(m): return NegativeIntegerQ(m + S(-1)/2) cons951 = CustomConstraint(cons_f951) def cons_f952(n, j): return NonzeroQ(-j + n) cons952 = CustomConstraint(cons_f952) def cons_f953(p, j, n): return ZeroQ(j*p + j - n + S(1)) cons953 = CustomConstraint(cons_f953) def cons_f954(p, n, j): return NegativeIntegerQ((j - n*p - n + S(-1))/(j - n)) cons954 = CustomConstraint(cons_f954) def cons_f955(p, j): return NonzeroQ(j*p + S(1)) cons955 = CustomConstraint(cons_f955) def cons_f956(p, n, j): return RationalQ(j, n, p) cons956 = CustomConstraint(cons_f956) def cons_f957(n, j): return Less(S(0), j, n) cons957 = CustomConstraint(cons_f957) def cons_f958(p, j): return Less(j*p + S(1), S(0)) cons958 = CustomConstraint(cons_f958) def cons_f959(p, n): return NonzeroQ(n*p + S(1)) cons959 = CustomConstraint(cons_f959) def cons_f960(p, j, n): return Greater(j*p + S(1), -j + n) cons960 = CustomConstraint(cons_f960) def cons_f961(p): return PositiveIntegerQ(p + S(1)/2) cons961 = CustomConstraint(cons_f961) def cons_f962(p, j): return ZeroQ(j*p + S(1)) cons962 = CustomConstraint(cons_f962) def cons_f963(n): return NonzeroQ(n + S(-2)) cons963 = CustomConstraint(cons_f963) def cons_f964(n, j): return RationalQ(j, n) cons964 = CustomConstraint(cons_f964) def cons_f965(n, j): return Less(S(2)*n + S(-2), j, n) cons965 = CustomConstraint(cons_f965) def cons_f966(n, j): return PosQ(-j + n) cons966 = CustomConstraint(cons_f966) def cons_f967(n, j): return IntegerQ(j/n) cons967 = CustomConstraint(cons_f967) def cons_f968(m, n, p, j): return ZeroQ(-j + m + n*p + n + S(1)) cons968 = CustomConstraint(cons_f968) def cons_f969(c, j): return Or(IntegerQ(j), PositiveQ(c)) cons969 = CustomConstraint(cons_f969) def cons_f970(m, n, p, j): return NegativeIntegerQ((j - m - n*p - n + S(-1))/(j - n)) cons970 = CustomConstraint(cons_f970) def cons_f971(m, p, j): return NonzeroQ(j*p + m + S(1)) cons971 = CustomConstraint(cons_f971) def cons_f972(c, n, j): return Or(IntegersQ(j, n), PositiveQ(c)) cons972 = CustomConstraint(cons_f972) def cons_f973(n): return NonzeroQ(n**S(2) + S(-1)) cons973 = CustomConstraint(cons_f973) def cons_f974(m, n, p, j): return RationalQ(j, m, n, p) cons974 = CustomConstraint(cons_f974) def cons_f975(m, p, j): return Less(j*p + m + S(1), S(0)) cons975 = CustomConstraint(cons_f975) def cons_f976(m, p, j, n): return Greater(j*p + m + S(1), -j + n) cons976 = CustomConstraint(cons_f976) def cons_f977(m, p, j, n): return PositiveQ(j*p + j + m - n + S(1)) cons977 = CustomConstraint(cons_f977) def cons_f978(m, p, j): return NegativeQ(j*p + m + S(1)) cons978 = CustomConstraint(cons_f978) def cons_f979(m, p, j): return ZeroQ(j*p + m + S(1)) cons979 = CustomConstraint(cons_f979) def cons_f980(m, j): return ZeroQ(-j/S(2) + m + S(1)) cons980 = CustomConstraint(cons_f980) def cons_f981(j, k): return NonzeroQ(-j + k) cons981 = CustomConstraint(cons_f981) def cons_f982(n, k): return IntegerQ(k/n) cons982 = CustomConstraint(cons_f982) def cons_f983(n, jn, j): return ZeroQ(jn - j - n) cons983 = CustomConstraint(cons_f983) def cons_f984(p, j, m, b, d, a, c, n): return ZeroQ(a*d*(j*p + m + S(1)) - b*c*(m + n + p*(j + n) + S(1))) cons984 = CustomConstraint(cons_f984) def cons_f985(j, e): return Or(PositiveQ(e), IntegersQ(j)) cons985 = CustomConstraint(cons_f985) def cons_f986(m, p, j): return RationalQ(j, m, p) cons986 = CustomConstraint(cons_f986) def cons_f987(m, j): return Inequality(S(0), Less, j, LessEqual, m) cons987 = CustomConstraint(cons_f987) def cons_f988(j, e): return Or(PositiveQ(e), IntegerQ(j)) cons988 = CustomConstraint(cons_f988) def cons_f989(m, p, j, n): return Or(Less(j*p + m, S(-1)), And(IntegersQ(m + S(-1)/2, p + S(-1)/2), Less(p, S(0)), Less(m, -n*p + S(-1)))) cons989 = CustomConstraint(cons_f989) def cons_f990(n, j, e): return Or(PositiveQ(e), IntegersQ(j, n)) cons990 = CustomConstraint(cons_f990) def cons_f991(m, n, p, j): return NonzeroQ(j*p + m - n + S(1)) cons991 = CustomConstraint(cons_f991) def cons_f992(m, n, p, j): return NonzeroQ(m + n + p*(j + n) + S(1)) cons992 = CustomConstraint(cons_f992) def cons_f993(n, j): return Not(And(ZeroQ(n + S(-1)), ZeroQ(j + S(-1)))) cons993 = CustomConstraint(cons_f993) def cons_f994(n): return Less(S(-1), n, S(1)) cons994 = CustomConstraint(cons_f994) def cons_f995(m): return Greater(m**S(2), S(1)) cons995 = CustomConstraint(cons_f995) def cons_f996(n, j): return PositiveIntegerQ(j, n, j/n) cons996 = CustomConstraint(cons_f996) def cons_f997(n, j): return PositiveIntegerQ(j, n) cons997 = CustomConstraint(cons_f997) def cons_f998(n, j): return Less(j, n) cons998 = CustomConstraint(cons_f998) def cons_f999(d, a, b): return ZeroQ(S(27)*a**S(2)*d + S(4)*b**S(3)) cons999 = CustomConstraint(cons_f999) def cons_f1000(d, a, b): return NonzeroQ(S(27)*a**S(2)*d + S(4)*b**S(3)) cons1000 = CustomConstraint(cons_f1000) def cons_f1001(d, c, a): return ZeroQ(S(27)*a*d**S(2) + S(4)*c**S(3)) cons1001 = CustomConstraint(cons_f1001) def cons_f1002(d, c, a): return NonzeroQ(S(27)*a*d**S(2) + S(4)*c**S(3)) cons1002 = CustomConstraint(cons_f1002) def cons_f1003(d, c, b): return ZeroQ(-S(3)*b*d + c**S(2)) cons1003 = CustomConstraint(cons_f1003) def cons_f1004(c, a, b): return ZeroQ(-S(3)*a*c + b**S(2)) cons1004 = CustomConstraint(cons_f1004) def cons_f1005(c, a, b): return NonzeroQ(-S(3)*a*c + b**S(2)) cons1005 = CustomConstraint(cons_f1005) def cons_f1006(d, c, b): return NonzeroQ(-S(3)*b*d + c**S(2)) cons1006 = CustomConstraint(cons_f1006) def cons_f1007(x, u): if isinstance(x, (int, Integer, float, Float)): return False return PolyQ(u, x, S(3)) cons1007 = CustomConstraint(cons_f1007) def cons_f1008(x, u): if isinstance(x, (int, Integer, float, Float)): return False return Not(CubicMatchQ(u, x)) cons1008 = CustomConstraint(cons_f1008) def cons_f1009(v, x): if isinstance(x, (int, Integer, float, Float)): return False return PolyQ(v, x, S(3)) cons1009 = CustomConstraint(cons_f1009) def cons_f1010(x, u, v): if isinstance(x, (int, Integer, float, Float)): return False return Not(And(LinearMatchQ(u, x), CubicMatchQ(v, x))) cons1010 = CustomConstraint(cons_f1010) def cons_f1011(f, g): return ZeroQ(f + g) cons1011 = CustomConstraint(cons_f1011) def cons_f1012(a, c): return PosQ(a**S(2)*(S(2)*a - c)) cons1012 = CustomConstraint(cons_f1012) def cons_f1013(a, c): return NegQ(a**S(2)*(S(2)*a - c)) cons1013 = CustomConstraint(cons_f1013) def cons_f1014(d, c, b, e): return ZeroQ(S(8)*b*e**S(2) - S(4)*c*d*e + d**S(3)) cons1014 = CustomConstraint(cons_f1014) def cons_f1015(p): return UnsameQ(p, S(2)) cons1015 = CustomConstraint(cons_f1015) def cons_f1016(p): return UnsameQ(p, S(3)) cons1016 = CustomConstraint(cons_f1016) def cons_f1017(v, x): if isinstance(x, (int, Integer, float, Float)): return False return PolynomialQ(v, x) cons1017 = CustomConstraint(cons_f1017) def cons_f1018(v, x): if isinstance(x, (int, Integer, float, Float)): return False return Equal(Exponent(v, x), S(4)) cons1018 = CustomConstraint(cons_f1018) def cons_f1019(d, c, a, b): return ZeroQ(S(8)*a**S(2)*d - S(4)*a*b*c + b**S(3)) cons1019 = CustomConstraint(cons_f1019) def cons_f1020(d, b): return ZeroQ(-b + d) cons1020 = CustomConstraint(cons_f1020) def cons_f1021(a, e): return ZeroQ(-a + e) cons1021 = CustomConstraint(cons_f1021) def cons_f1022(x, c, a, b): if isinstance(x, (int, Integer, float, Float)): return False return SumQ(Factor(a*x**S(4) + a + b*x**S(3) + b*x + c*x**S(2))) cons1022 = CustomConstraint(cons_f1022) def cons_f1023(D, x): return FreeQ(D, x) cons1023 = CustomConstraint(cons_f1023) def cons_f1024(B, C, e, b, d, c, A): return ZeroQ(B**S(2)*d - S(2)*B*(S(2)*A*e + C*c) + S(2)*C*(A*d + C*b)) cons1024 = CustomConstraint(cons_f1024) def cons_f1025(B, C, e, d, c, a, A): return ZeroQ(-S(4)*A*B*C*d + S(4)*A*e*(S(2)*A*C + B**S(2)) - B**S(3)*d + S(2)*B**S(2)*C*c - S(8)*C**S(3)*a) cons1025 = CustomConstraint(cons_f1025) def cons_f1026(B, C, e, d, c, A): return PosQ(C*(C*(-S(4)*c*e + d**S(2)) + S(2)*e*(-S(4)*A*e + B*d))) cons1026 = CustomConstraint(cons_f1026) def cons_f1027(d, C, b, A): return ZeroQ(A*d + C*b) cons1027 = CustomConstraint(cons_f1027) def cons_f1028(a, C, e, A): return ZeroQ(-A**S(2)*e + C**S(2)*a) cons1028 = CustomConstraint(cons_f1028) def cons_f1029(C, d, c, A, e): return PosQ(C*(-S(8)*A*e**S(2) + C*(-S(4)*c*e + d**S(2)))) cons1029 = CustomConstraint(cons_f1029) def cons_f1030(B, C, e, d, c, A): return NegQ(C*(C*(-S(4)*c*e + d**S(2)) + S(2)*e*(-S(4)*A*e + B*d))) cons1030 = CustomConstraint(cons_f1030) def cons_f1031(C, d, c, A, e): return NegQ(C*(-S(8)*A*e**S(2) + C*(-S(4)*c*e + d**S(2)))) cons1031 = CustomConstraint(cons_f1031) def cons_f1032(B, C, b, D, d, c, A, e): return ZeroQ(S(4)*d*(-S(2)*B*e + D*c)**S(2) - S(4)*(-S(2)*B*e + D*c)*(-S(8)*A*e**S(2) - S(4)*C*c*e + S(2)*D*b*e + S(3)*D*c*d) + S(8)*(-S(4)*C*e + S(3)*D*d)*(-A*d*e - C*b*e + D*b*d)) cons1032 = CustomConstraint(cons_f1032) def cons_f1033(B, C, b, D, d, c, a, A, e): return ZeroQ(S(8)*a*(-S(4)*C*e + S(3)*D*d)**S(3) - S(8)*c*(-S(2)*B*e + D*c)**S(2)*(-S(4)*C*e + S(3)*D*d) + S(8)*d*(-S(4)*A*e + D*b)*(-S(2)*B*e + D*c)*(-S(4)*C*e + S(3)*D*d) + S(8)*d*(-S(2)*B*e + D*c)**S(3) - S(4)*e*(-S(4)*A*e + D*b)*(S(2)*(-S(4)*A*e + D*b)*(-S(4)*C*e + S(3)*D*d) + S(4)*(-S(2)*B*e + D*c)**S(2))) cons1033 = CustomConstraint(cons_f1033) def cons_f1034(b, D, d, c, A, e): return ZeroQ(D**S(2)*c**S(2)*d - D*c*(-S(8)*A*e**S(2) - S(4)*C*c*e + S(2)*D*b*e + S(3)*D*c*d) + S(2)*(-S(4)*C*e + S(3)*D*d)*(-A*d*e - C*b*e + D*b*d)) cons1034 = CustomConstraint(cons_f1034) def cons_f1035(B, e, b, D, d, a, c, A): return ZeroQ(S(54)*D**S(3)*a*d**S(3) - S(6)*D*c*d*(-S(2)*B*e + D*c)**S(2) + S(6)*D*d**S(2)*(-S(4)*A*e + D*b)*(-S(2)*B*e + D*c) + S(2)*d*(-S(2)*B*e + D*c)**S(3) - e*(-S(4)*A*e + D*b)*(S(6)*D*d*(-S(4)*A*e + D*b) + S(4)*(-S(2)*B*e + D*c)**S(2))) cons1035 = CustomConstraint(cons_f1035) def cons_f1036(a, f, c, e): return ZeroQ(a*e**S(2) - c*f**S(2)) cons1036 = CustomConstraint(cons_f1036) def cons_f1037(d, f, b, e): return ZeroQ(b*e**S(2) - d*f**S(2)) cons1037 = CustomConstraint(cons_f1037) def cons_f1038(a, f, c, e): return NonzeroQ(a*e**S(2) - c*f**S(2)) cons1038 = CustomConstraint(cons_f1038) def cons_f1039(d, f, b, e): return NonzeroQ(b*e**S(2) - d*f**S(2)) cons1039 = CustomConstraint(cons_f1039) def cons_f1040(p, n): return ZeroQ(-S(2)*n + p) cons1040 = CustomConstraint(cons_f1040) def cons_f1041(d, c, b): return ZeroQ(b*c**S(2) - d**S(2)) cons1041 = CustomConstraint(cons_f1041) def cons_f1042(d, c, b): return NonzeroQ(b*c**S(2) - d**S(2)) cons1042 = CustomConstraint(cons_f1042) def cons_f1043(b, d, c, a, x, e): if isinstance(x, (int, Integer, float, Float)): return False return FreeQ(List(a, b, c, d, e), x) cons1043 = CustomConstraint(cons_f1043) def cons_f1044(b, d, c, a, e): return NonzeroQ(a*e**S(4) + b*d**S(2)*e**S(2) + c*d**S(4)) cons1044 = CustomConstraint(cons_f1044) def cons_f1045(d, c, b, e): return ZeroQ(b*d*e**S(2) + S(2)*c*d**S(3)) cons1045 = CustomConstraint(cons_f1045) def cons_f1046(d, c, b, e): return NonzeroQ(b*d*e**S(2) + S(2)*c*d**S(3)) cons1046 = CustomConstraint(cons_f1046) def cons_f1047(d, c, e, a): return NonzeroQ(a*e**S(4) + c*d**S(4)) cons1047 = CustomConstraint(cons_f1047) def cons_f1048(B, d, e, A): return ZeroQ(A*e + B*d) cons1048 = CustomConstraint(cons_f1048) def cons_f1049(B, a, c, A): return ZeroQ(A*c + B*a) cons1049 = CustomConstraint(cons_f1049) def cons_f1050(d, c, e, a): return ZeroQ(a*e + c*d) cons1050 = CustomConstraint(cons_f1050) def cons_f1051(g, f, b, d, c, a, h, e): return ZeroQ(-f**S(2)*(a*h**S(2) - b*g*h + c*g**S(2)) + (-d*h + e*g)**S(2)) cons1051 = CustomConstraint(cons_f1051) def cons_f1052(g, f, b, d, c, h, e): return ZeroQ(-S(2)*d*e*h + S(2)*e**S(2)*g - f**S(2)*(-b*h + S(2)*c*g)) cons1052 = CustomConstraint(cons_f1052) def cons_f1053(v, u, j, f, x): if isinstance(x, (int, Integer, float, Float)): return False return Not(And(LinearMatchQ(u, x), QuadraticMatchQ(v, x), Or(ZeroQ(j), ZeroQ(f + S(-1))))) cons1053 = CustomConstraint(cons_f1053) def cons_f1054(v, u, j, k, g, f, x, h): if isinstance(x, (int, Integer, float, Float)): return False return ZeroQ(-f**S(2)*k**S(2)*(g**S(2)*Coefficient(v, x, S(2)) - g*h*Coefficient(v, x, S(1)) + h**S(2)*Coefficient(v, x, S(0))) + (g*Coefficient(u, x, S(1)) - h*(f*j + Coefficient(u, x, S(0))))**S(2)) cons1054 = CustomConstraint(cons_f1054) def cons_f1055(c, f, e): return ZeroQ(-c*f**S(2) + e**S(2)) cons1055 = CustomConstraint(cons_f1055) def cons_f1056(x, f, u, v): if isinstance(x, (int, Integer, float, Float)): return False return ZeroQ(-f**S(2)*Coefficient(v, x, S(2)) + Coefficient(u, x, S(1))**S(2)) cons1056 = CustomConstraint(cons_f1056) def cons_f1057(c, g, a, i): return ZeroQ(-a*i + c*g) cons1057 = CustomConstraint(cons_f1057) def cons_f1058(m, p): return IntegersQ(p, S(2)*m) cons1058 = CustomConstraint(cons_f1058) def cons_f1059(m, c, i): return Or(IntegerQ(m), PositiveQ(i/c)) cons1059 = CustomConstraint(cons_f1059) def cons_f1060(c, h, b, i): return ZeroQ(-b*i + c*h) cons1060 = CustomConstraint(cons_f1060) def cons_f1061(c, i): return Not(PositiveQ(i/c)) cons1061 = CustomConstraint(cons_f1061) def cons_f1062(v, w, x): if isinstance(x, (int, Integer, float, Float)): return False return QuadraticQ(List(v, w), x) cons1062 = CustomConstraint(cons_f1062) def cons_f1063(v, w, u, j, f, x): if isinstance(x, (int, Integer, float, Float)): return False return Not(And(LinearMatchQ(u, x), QuadraticMatchQ(List(v, w), x), Or(ZeroQ(j), ZeroQ(f + S(-1))))) cons1063 = CustomConstraint(cons_f1063) def cons_f1064(v, u, k, f, x): if isinstance(x, (int, Integer, float, Float)): return False return ZeroQ(-f**S(2)*k**S(2)*Coefficient(v, x, S(2)) + Coefficient(u, x, S(1))**S(2)) cons1064 = CustomConstraint(cons_f1064) def cons_f1065(p, n): return ZeroQ(p - S(2)/n) cons1065 = CustomConstraint(cons_f1065) def cons_f1066(c, a, b): return ZeroQ(a**S(2) - b**S(2)*c) cons1066 = CustomConstraint(cons_f1066) def cons_f1067(d, a, b): return ZeroQ(a**S(2) - b**S(2)*d) cons1067 = CustomConstraint(cons_f1067) def cons_f1068(c, b, a): return ZeroQ(a + b**S(2)*c) cons1068 = CustomConstraint(cons_f1068) def cons_f1069(c, b, e, a): return ZeroQ(a + b**S(2)*c*e) cons1069 = CustomConstraint(cons_f1069) def cons_f1070(d, c, b): return ZeroQ(-b*d**S(2) + c**S(2)) cons1070 = CustomConstraint(cons_f1070) def cons_f1071(b, e): return ZeroQ(-b**S(2) + e) cons1071 = CustomConstraint(cons_f1071) def cons_f1072(d, c, b, a): return ZeroQ(-a*d + b*c, S(0)) cons1072 = CustomConstraint(cons_f1072) def cons_f1073(B, d, a, n, A): return ZeroQ(-A**S(2)*d*(n + S(-1))**S(2) + B**S(2)*a) cons1073 = CustomConstraint(cons_f1073) def cons_f1074(B, d, c, n, A): return ZeroQ(S(2)*A*d*(n + S(-1)) + B*c) cons1074 = CustomConstraint(cons_f1074) def cons_f1075(m, k): return ZeroQ(k - S(2)*m + S(-2)) cons1075 = CustomConstraint(cons_f1075) def cons_f1076(B, m, d, a, n, A): return ZeroQ(-A**S(2)*d*(m - n + S(1))**S(2) + B**S(2)*a*(m + S(1))**S(2)) cons1076 = CustomConstraint(cons_f1076) def cons_f1077(B, m, d, c, n, A): return ZeroQ(-S(2)*A*d*(m - n + S(1)) + B*c*(m + S(1))) cons1077 = CustomConstraint(cons_f1077) def cons_f1078(f, b, g, d, c, a): return ZeroQ(-S(12)*a**S(3)*g**S(2) + a**S(2)*c*f**S(2) + S(2)*a*b*g*(a*f + S(3)*c*d) + S(9)*c**S(3)*d**S(2) - c*d*f*(S(6)*a*c + b**S(2))) cons1078 = CustomConstraint(cons_f1078) def cons_f1079(f, g, b, d, c, a, e): return ZeroQ(a**S(3)*c*f**S(2)*g + S(2)*a**S(3)*g**S(2)*(-S(6)*a*g + b*f) - S(3)*a**S(2)*c**S(2)*d*f*g + S(3)*c**S(4)*d**S(2)*e - c**S(3)*d*(-S(12)*a*d*g + a*e*f + S(2)*b*d*f)) cons1079 = CustomConstraint(cons_f1079) def cons_f1080(d, c, f, a): return NonzeroQ(-a*f + S(3)*c*d) cons1080 = CustomConstraint(cons_f1080) def cons_f1081(g, b, d, c, a): return NonzeroQ(-S(2)*a**S(2)*g + b*c*d) cons1081 = CustomConstraint(cons_f1081) def cons_f1082(f, b, g, d, c, a): return NonzeroQ(S(4)*a**S(2)*g - a*b*f + b*c*d) cons1082 = CustomConstraint(cons_f1082) def cons_f1083(f, g, b, d, a, c): return PosQ((S(12)*a**S(2)*g**S(2) - a*c*f**S(2) + f*(-S(2)*a*b*g + S(3)*c**S(2)*d))/(c*g*(-a*f + S(3)*c*d))) cons1083 = CustomConstraint(cons_f1083) def cons_f1084(f, g, d, c, a): return ZeroQ(-S(12)*a**S(3)*g**S(2) + a**S(2)*c*f**S(2) - S(6)*a*c**S(2)*d*f + S(9)*c**S(3)*d**S(2)) cons1084 = CustomConstraint(cons_f1084) def cons_f1085(f, g, d, c, a, e): return ZeroQ(-S(12)*a**S(4)*g**S(3) + a**S(3)*c*f**S(2)*g - S(3)*a**S(2)*c**S(2)*d*f*g - a*c**S(3)*d*(-S(12)*d*g + e*f) + S(3)*c**S(4)*d**S(2)*e) cons1085 = CustomConstraint(cons_f1085) def cons_f1086(f, g, d, a, c): return PosQ((S(12)*a**S(2)*g**S(2) - a*c*f**S(2) + S(3)*c**S(2)*d*f)/(c*g*(-a*f + S(3)*c*d))) cons1086 = CustomConstraint(cons_f1086) def cons_f1087(v): return SumQ(v) cons1087 = CustomConstraint(cons_f1087) def cons_f1088(x, u, v): if isinstance(x, (int, Integer, float, Float)): return False return Not(And(MonomialQ(u, x), BinomialQ(v, x))) cons1088 = CustomConstraint(cons_f1088) def cons_f1089(x, u, v): if isinstance(x, (int, Integer, float, Float)): return False return Not(And(ZeroQ(Coefficient(u, x, S(0))), ZeroQ(Coefficient(v, x, S(0))))) cons1089 = CustomConstraint(cons_f1089) def cons_f1090(x, u): if isinstance(x, (int, Integer, float, Float)): return False return PiecewiseLinearQ(u, x) cons1090 = CustomConstraint(cons_f1090) def cons_f1091(v, x, u): if isinstance(x, (int, Integer, float, Float)): return False return PiecewiseLinearQ(u, v, x) cons1091 = CustomConstraint(cons_f1091) def cons_f1092(n): return Unequal(n, S(1)) cons1092 = CustomConstraint(cons_f1092) def cons_f1093(m, n): return Or(And(RationalQ(m, n), Less(m, S(-1)), Greater(n, S(0)), Not(And(IntegerQ(m + n), Less(m + n + S(2), S(0)), Or(FractionQ(m), GreaterEqual(m + S(2)*n + S(1), S(0)))))), And(PositiveIntegerQ(n, m), LessEqual(n, m)), And(PositiveIntegerQ(n), Not(IntegerQ(m))), And(NegativeIntegerQ(m), Not(IntegerQ(n)))) cons1093 = CustomConstraint(cons_f1093) def cons_f1094(n): return Not(RationalQ(n)) cons1094 = CustomConstraint(cons_f1094) def cons_f1095(n): return SumSimplerQ(n, S(-1)) cons1095 = CustomConstraint(cons_f1095) def cons_f1096(m): return SumSimplerQ(m, S(1)) cons1096 = CustomConstraint(cons_f1096) def cons_f1097(x, u): if isinstance(x, (int, Integer, float, Float)): return False return Not(LinearQ(u, x)) cons1097 = CustomConstraint(cons_f1097) def cons_f1098(): return Not(SameQ(_UseGamma, True)) cons1098 = CustomConstraint(cons_f1098) def cons_f1099(F, x): return FreeQ(F, x) cons1099 = CustomConstraint(cons_f1099) def cons_f1100(m, f, b, g, d, c, n, x, F, e): if isinstance(x, (int, Integer, float, Float)): return False return FreeQ(List(F, b, c, d, e, f, g, m, n), x) cons1100 = CustomConstraint(cons_f1100) def cons_f1101(x, u): if isinstance(x, (int, Integer, float, Float)): return False return PowerOfLinearQ(u, x) cons1101 = CustomConstraint(cons_f1101) def cons_f1102(v, x, u): if isinstance(x, (int, Integer, float, Float)): return False return Not(And(LinearMatchQ(v, x), PowerOfLinearMatchQ(u, x))) cons1102 = CustomConstraint(cons_f1102) def cons_f1103(p, m, f, b, g, d, c, a, n, x, F, e): if isinstance(x, (int, Integer, float, Float)): return False return FreeQ(List(F, a, b, c, d, e, f, g, m, n, p), x) cons1103 = CustomConstraint(cons_f1103) def cons_f1104(j, f, g, i, G, n, F, q): return ZeroQ(f*g*n*log(F) - i*j*q*log(G)) cons1104 = CustomConstraint(cons_f1104) def cons_f1105(e, j, k, g, f, i, G, n, x, h, q, F): if isinstance(x, (int, Integer, float, Float)): return False return NonzeroQ((G**(j*(h + i*x))*k)**q - (F**(g*(e + f*x)))**n) cons1105 = CustomConstraint(cons_f1105) def cons_f1106(b, c, a, n, x, F): if isinstance(x, (int, Integer, float, Float)): return False return FreeQ(List(F, a, b, c, n), x) cons1106 = CustomConstraint(cons_f1106) def cons_f1107(): return SameQ(_UseGamma, True) cons1107 = CustomConstraint(cons_f1107) def cons_f1108(v, w, u, m, c, x, F): if isinstance(x, (int, Integer, float, Float)): return False return ZeroQ(-c*(-Coefficient(u, x, S(0))*Coefficient(w, x, S(1)) + Coefficient(u, x, S(1))*Coefficient(w, x, S(0)))*Coefficient(v, x, S(1))*log(F) + (m + S(1))*Coefficient(u, x, S(1))*Coefficient(w, x, S(1))) cons1108 = CustomConstraint(cons_f1108) def cons_f1109(x, w): if isinstance(x, (int, Integer, float, Float)): return False return PolynomialQ(w, x) cons1109 = CustomConstraint(cons_f1109) def cons_f1110(h, f, e, n): return ZeroQ(e - f*h*(n + S(1))) cons1110 = CustomConstraint(cons_f1110) def cons_f1111(g, b, c, n, h, F, e): return ZeroQ(-b*c*e*log(F) + g*h*(n + S(1))) cons1111 = CustomConstraint(cons_f1111) def cons_f1112(m, f, n, h, e): return ZeroQ(e*(m + S(1)) - f*h*(n + S(1))) cons1112 = CustomConstraint(cons_f1112) def cons_f1113(b, d, c, a, x, F): if isinstance(x, (int, Integer, float, Float)): return False return FreeQ(List(F, a, b, c, d), x) cons1113 = CustomConstraint(cons_f1113) def cons_f1114(n): return IntegerQ(S(2)/n) cons1114 = CustomConstraint(cons_f1114) def cons_f1115(n): return Not(IntegerQ(S(2)/n)) cons1115 = CustomConstraint(cons_f1115) def cons_f1116(d, c, f, e): return ZeroQ(-c*f + d*e) cons1116 = CustomConstraint(cons_f1116) def cons_f1117(m, n): return ZeroQ(-S(2)*m + n + S(-2)) cons1117 = CustomConstraint(cons_f1117) def cons_f1118(m, n): return IntegerQ(S(2)*(m + S(1))/n) cons1118 = CustomConstraint(cons_f1118) def cons_f1119(m, n): return Less(S(0), (m + S(1))/n, S(5)) cons1119 = CustomConstraint(cons_f1119) def cons_f1120(m, n): return Or(Less(S(0), n, m + S(1)), Less(m, n, S(0))) cons1120 = CustomConstraint(cons_f1120) def cons_f1121(m, n): return Less(S(-4), (m + S(1))/n, S(5)) cons1121 = CustomConstraint(cons_f1121) def cons_f1122(m, n): return Or(And(Greater(n, S(0)), Less(m, S(-1))), Inequality(S(0), Less, -n, LessEqual, m + S(1))) cons1122 = CustomConstraint(cons_f1122) def cons_f1123(d, f): return NonzeroQ(-d + f) cons1123 = CustomConstraint(cons_f1123) def cons_f1124(c, e): return NonzeroQ(c*e) cons1124 = CustomConstraint(cons_f1124) def cons_f1125(x, u, v): if isinstance(x, (int, Integer, float, Float)): return False return Not(And(LinearMatchQ(u, x), BinomialMatchQ(v, x))) cons1125 = CustomConstraint(cons_f1125) def cons_f1126(v, x): if isinstance(x, (int, Integer, float, Float)): return False return PowerOfLinearQ(v, x) cons1126 = CustomConstraint(cons_f1126) def cons_f1127(v, x): if isinstance(x, (int, Integer, float, Float)): return False return Not(PowerOfLinearMatchQ(v, x)) cons1127 = CustomConstraint(cons_f1127) def cons_f1128(d, h, c, g): return ZeroQ(-c*h + d*g) cons1128 = CustomConstraint(cons_f1128) def cons_f1129(d, h, c, g): return NonzeroQ(-c*h + d*g) cons1129 = CustomConstraint(cons_f1129) def cons_f1130(b, c, a, x, F): if isinstance(x, (int, Integer, float, Float)): return False return FreeQ(List(F, a, b, c), x) cons1130 = CustomConstraint(cons_f1130) def cons_f1131(v, x): if isinstance(x, (int, Integer, float, Float)): return False return Not(QuadraticMatchQ(v, x)) cons1131 = CustomConstraint(cons_f1131) def cons_f1132(d, c, b, e): return ZeroQ(b*e - S(2)*c*d) cons1132 = CustomConstraint(cons_f1132) def cons_f1133(d, c, b, e): return NonzeroQ(b*e - S(2)*c*d) cons1133 = CustomConstraint(cons_f1133) def cons_f1134(m, b, d, c, a, x, F, e): if isinstance(x, (int, Integer, float, Float)): return False return FreeQ(List(F, a, b, c, d, e, m), x) cons1134 = CustomConstraint(cons_f1134) def cons_f1135(v, d, c, x, e): if isinstance(x, (int, Integer, float, Float)): return False return ZeroQ(S(2)*e*(c + d*x) - v) cons1135 = CustomConstraint(cons_f1135) def cons_f1136(f, b, g, G, d, c, a, n, x, h, F, e): if isinstance(x, (int, Integer, float, Float)): return False return FreeQ(List(F, G, a, b, c, d, e, f, g, h, n), x) cons1136 = CustomConstraint(cons_f1136) def cons_f1137(G, x): return FreeQ(G, x) cons1137 = CustomConstraint(cons_f1137) def cons_f1138(g, G, d, h, F, e): return Not(RationalQ(FullSimplify(g*h*log(G)/(d*e*log(F))))) cons1138 = CustomConstraint(cons_f1138) def cons_f1139(s, t, f, b, g, r, G, d, H, a, c, n, x, h, F, e): if isinstance(x, (int, Integer, float, Float)): return False return FreeQ(List(F, G, H, a, b, c, d, e, f, g, h, r, s, t, n), x) cons1139 = CustomConstraint(cons_f1139) def cons_f1140(H, x): return FreeQ(H, x) cons1140 = CustomConstraint(cons_f1140) def cons_f1141(t, x): return FreeQ(t, x) cons1141 = CustomConstraint(cons_f1141) def cons_f1142(g, G, d, n, h, F, e): return ZeroQ(d*e*n*log(F) + g*h*log(G)) cons1142 = CustomConstraint(cons_f1142) def cons_f1143(t, g, G, d, H, h, s, e, F): return Not(RationalQ(FullSimplify((g*h*log(G) + s*t*log(H))/(d*e*log(F))))) cons1143 = CustomConstraint(cons_f1143) def cons_f1144(v, u): return ZeroQ(-S(2)*u + v) cons1144 = CustomConstraint(cons_f1144) def cons_f1145(d, c, v, x): if isinstance(x, (int, Integer, float, Float)): return False return ZeroQ(c + d*x + v) cons1145 = CustomConstraint(cons_f1145) def cons_f1146(x, w): if isinstance(x, (int, Integer, float, Float)): return False return LinearQ(w, x) cons1146 = CustomConstraint(cons_f1146) def cons_f1147(v, w): return ZeroQ(v + w) cons1147 = CustomConstraint(cons_f1147) def cons_f1148(v, x, w): if isinstance(x, (int, Integer, float, Float)): return False return If(RationalQ(Coefficient(v, x, S(1))), Greater(Coefficient(v, x, S(1)), S(0)), Less(LeafCount(v), LeafCount(w))) cons1148 = CustomConstraint(cons_f1148) def cons_f1149(g, b, d, c, a, n, x, F, e): if isinstance(x, (int, Integer, float, Float)): return False return FreeQ(List(F, a, b, c, d, e, g, n), x) cons1149 = CustomConstraint(cons_f1149) def cons_f1150(g, d, a, c, n, x, F, e): if isinstance(x, (int, Integer, float, Float)): return False return FreeQ(List(F, a, c, d, e, g, n), x) cons1150 = CustomConstraint(cons_f1150) def cons_f1151(x, a, b, F): if isinstance(x, (int, Integer, float, Float)): return False return FreeQ(List(F, a, b), x) cons1151 = CustomConstraint(cons_f1151) def cons_f1152(n): return Unequal(n, S(-1)) cons1152 = CustomConstraint(cons_f1152) def cons_f1153(x, u): if isinstance(x, (int, Integer, float, Float)): return False return FunctionOfExponentialQ(u, x) cons1153 = CustomConstraint(cons_f1153) def cons_f1154(v, w, x): if isinstance(x, (int, Integer, float, Float)): return False return LinearQ(List(v, w), x) cons1154 = CustomConstraint(cons_f1154) def cons_f1155(v, w, x): if isinstance(x, (int, Integer, float, Float)): return False return Or(BinomialQ(v + w, x), And(PolynomialQ(v + w, x), LessEqual(Exponent(v + w, x), S(2)))) cons1155 = CustomConstraint(cons_f1155) def cons_f1156(p, f, d, c, x, q, e): if isinstance(x, (int, Integer, float, Float)): return False return FreeQ(List(c, d, e, f, p, q), x) cons1156 = CustomConstraint(cons_f1156) def cons_f1157(d, x, f, e): if isinstance(x, (int, Integer, float, Float)): return False return FreeQ(List(d, e, f), x) cons1157 = CustomConstraint(cons_f1157) def cons_f1158(p, b, q): return PosQ(b*p*q) cons1158 = CustomConstraint(cons_f1158) def cons_f1159(p, b, q): return NegQ(b*p*q) cons1159 = CustomConstraint(cons_f1159) def cons_f1160(h, f, e, g): return ZeroQ(-e*h + f*g) cons1160 = CustomConstraint(cons_f1160) def cons_f1161(m, p): return ZeroQ(m - p + S(1)) cons1161 = CustomConstraint(cons_f1161) def cons_f1162(h, p, f): return Or(IntegerQ(p), PositiveQ(h/f)) cons1162 = CustomConstraint(cons_f1162) def cons_f1163(h, p, f): return Not(Or(IntegerQ(p), PositiveQ(h/f))) cons1163 = CustomConstraint(cons_f1163) def cons_f1164(m, p, b, q): return PosQ((m + S(1))/(b*p*q)) cons1164 = CustomConstraint(cons_f1164) def cons_f1165(m, p, b, q): return NegQ((m + S(1))/(b*p*q)) cons1165 = CustomConstraint(cons_f1165) def cons_f1166(f, g, c, h, e): return ZeroQ(c*(-e*h + f*g) + h) cons1166 = CustomConstraint(cons_f1166) def cons_f1167(f, g, c, h, e): return NonzeroQ(c*(-e*h + f*g) + h) cons1167 = CustomConstraint(cons_f1167) def cons_f1168(f, g, c, h, e): return PositiveQ(c*(e - f*g/h)) cons1168 = CustomConstraint(cons_f1168) def cons_f1169(h, f, e, g): return NonzeroQ(-e*h + f*g) cons1169 = CustomConstraint(cons_f1169) def cons_f1170(m, n): return IntegersQ(S(2)*m, S(2)*n) cons1170 = CustomConstraint(cons_f1170) def cons_f1171(m, n): return Or(Equal(n, S(1)), Not(PositiveIntegerQ(m)), And(Equal(n, S(2)), NonzeroQ(m + S(-1)))) cons1171 = CustomConstraint(cons_f1171) def cons_f1172(j, f, i, c, e): return ZeroQ(f*i + j*(c - e)) cons1172 = CustomConstraint(cons_f1172) def cons_f1173(m, n): return Or(IntegerQ(n), Greater(m, S(0))) cons1173 = CustomConstraint(cons_f1173) def cons_f1174(p, j, m, f, b, g, i, d, c, a, n, x, h, q, e): if isinstance(x, (int, Integer, float, Float)): return False return FreeQ(List(a, b, c, d, e, f, g, h, i, j, m, n, p, q), x) cons1174 = CustomConstraint(cons_f1174) def cons_f1175(h, f, e, g): return ZeroQ(e**S(2)*h + f**S(2)*g) cons1175 = CustomConstraint(cons_f1175) def cons_f1176(c, e): return ZeroQ(c - S(2)*e) cons1176 = CustomConstraint(cons_f1176) def cons_f1177(c, e): return PositiveQ(c/(S(2)*e)) cons1177 = CustomConstraint(cons_f1177) def cons_f1178(c, e, a): return Or(NonzeroQ(c - S(2)*e), NonzeroQ(a)) cons1178 = CustomConstraint(cons_f1178) def cons_f1179(f, g, i, h, e): return ZeroQ(e**S(2)*i - e*f*h + f**S(2)*g) cons1179 = CustomConstraint(cons_f1179) def cons_f1180(i, f, e, g): return ZeroQ(e**S(2)*i + f**S(2)*g) cons1180 = CustomConstraint(cons_f1180) def cons_f1181(g): return PositiveQ(g) cons1181 = CustomConstraint(cons_f1181) def cons_f1182(h2, h1, g1, g2): return ZeroQ(g1*h2 + g2*h1) cons1182 = CustomConstraint(cons_f1182) def cons_f1183(g1): return PositiveQ(g1) cons1183 = CustomConstraint(cons_f1183) def cons_f1184(g2): return PositiveQ(g2) cons1184 = CustomConstraint(cons_f1184) def cons_f1185(g1, x): return FreeQ(g1, x) cons1185 = CustomConstraint(cons_f1185) def cons_f1186(h1, x): return FreeQ(h1, x) cons1186 = CustomConstraint(cons_f1186) def cons_f1187(g2, x): return FreeQ(g2, x) cons1187 = CustomConstraint(cons_f1187) def cons_f1188(h2, x): return FreeQ(h2, x) cons1188 = CustomConstraint(cons_f1188) def cons_f1189(g): return Not(PositiveQ(g)) cons1189 = CustomConstraint(cons_f1189) def cons_f1190(j, k, g, i, h): return ZeroQ(h - i*(-g*k + h*j)) cons1190 = CustomConstraint(cons_f1190) def cons_f1191(h, k, j, g): return ZeroQ(-g*k + h*j) cons1191 = CustomConstraint(cons_f1191) def cons_f1192(F): return MemberQ(List(Log, ArcSin, ArcCos, ArcTan, ArcCot, ArcSinh, ArcCosh, ArcTanh, ArcCoth), F) cons1192 = CustomConstraint(cons_f1192) def cons_f1193(m, r): return ZeroQ(m + r) cons1193 = CustomConstraint(cons_f1193) def cons_f1194(r1, r): return ZeroQ(-r + r1 + S(1)) cons1194 = CustomConstraint(cons_f1194) def cons_f1195(b, d, c, a, n, x, e): if isinstance(x, (int, Integer, float, Float)): return False return FreeQ(List(a, b, c, d, e, n), x) cons1195 = CustomConstraint(cons_f1195) def cons_f1196(mn, n): return ZeroQ(mn + n) cons1196 = CustomConstraint(cons_f1196) def cons_f1197(b, d, a, c, e): return ZeroQ(-a*c*d + b*c*e + d) cons1197 = CustomConstraint(cons_f1197) def cons_f1198(x, RFx): if isinstance(x, (int, Integer, float, Float)): return False return RationalFunctionQ(RFx, x) cons1198 = CustomConstraint(cons_f1198) def cons_f1199(f, e, g): return ZeroQ(-S(4)*e*g + f**S(2)) cons1199 = CustomConstraint(cons_f1199) def cons_f1200(v, p, d, c, x, q): if isinstance(x, (int, Integer, float, Float)): return False def _cons_f_1199(pp, qq, f, cc, dd, e): return FreeQ(List(cc, dd, e, f, pp, qq), x) _cons_1199 = CustomConstraint(_cons_f_1199) pat = Pattern(UtilityOperator(((x*WC('f', S(1)) + WC('e', S(0)))**WC('pp', S(1))*WC('dd', S(1)))**WC('qq', S(1))*WC('cc', S(1)), x), _cons_1199) result_matchq = is_match(UtilityOperator(c*(d*v**p)**q, x), pat) return Not(result_matchq) cons1200 = CustomConstraint(cons_f1200) def cons_f1201(p, b, r, c, a, n, x, q): if isinstance(x, (int, Integer, float, Float)): return False return FreeQ(List(a, b, c, n, p, q, r), x) cons1201 = CustomConstraint(cons_f1201) def cons_f1202(p, b, a, n, c, x, q): if isinstance(x, (int, Integer, float, Float)): return False return Not(SameQ(x**(n*p*q), a*(b*(c*x**n)**p)**q)) cons1202 = CustomConstraint(cons_f1202) def cons_f1203(n1, n2): return ZeroQ(n1 + n2) cons1203 = CustomConstraint(cons_f1203) def cons_f1204(n1, x): return FreeQ(n1, x) cons1204 = CustomConstraint(cons_f1204) def cons_f1205(d, c, f, g): return ZeroQ(-c*g + d*f) cons1205 = CustomConstraint(cons_f1205) def cons_f1206(d, b, e): return ZeroQ(-b*e + d) cons1206 = CustomConstraint(cons_f1206) def cons_f1207(a, f, b, g): return ZeroQ(-a*g + b*f) cons1207 = CustomConstraint(cons_f1207) def cons_f1208(d, c, f, g): return NonzeroQ(-c*g + d*f) cons1208 = CustomConstraint(cons_f1208) def cons_f1209(a, f, b, g): return NonzeroQ(-a*g + b*f) cons1209 = CustomConstraint(cons_f1209) def cons_f1210(m, m2): return ZeroQ(m + m2 + S(2)) cons1210 = CustomConstraint(cons_f1210) def cons_f1211(u, b, d, c, a, x): return FreeQ(simplify(Mul(u, Add(c, Mul(d, x)), Pow(Add(a, Mul(b, x)), S(-1)))), x) cons1211 = CustomConstraint(cons_f1211) def cons_f1212(f, g, b, d, c, a, e): return ZeroQ(-c*g + d*f - e*(-a*g + b*f)) cons1212 = CustomConstraint(cons_f1212) def cons_f1213(d, c, f, g): return ZeroQ(c**S(2)*g + d**S(2)*f) cons1213 = CustomConstraint(cons_f1213) def cons_f1214(b, d, c, a, e): return ZeroQ(-a*d*e - b*c*e + S(2)*c*d) cons1214 = CustomConstraint(cons_f1214) def cons_f1215(f, g, d, c, h): return ZeroQ(c**S(2)*h - c*d*g + d**S(2)*f) cons1215 = CustomConstraint(cons_f1215) def cons_f1216(d, h, c, f): return ZeroQ(c**S(2)*h + d**S(2)*f) cons1216 = CustomConstraint(cons_f1216) def cons_f1217(v, u, b, d, c, a, x): return FreeQ(simplify(Mul(u, Pow(Add(S(1), Mul(S(-1), v)), S(-1)))), x) cons1217 = CustomConstraint(cons_f1217) def cons_f1218(v, u, b, d, c, a, x): return FreeQ(simplify(Mul(u, Add(S(1), Mul(S(-1), v)))), x) cons1218 = CustomConstraint(cons_f1218) def cons_f1219(v, u, b, d, c, a, x): return FreeQ(simplify(Mul(u, Pow(v, S(-1)))), x) cons1219 = CustomConstraint(cons_f1219) def cons_f1220(v, u, b, d, c, a, x): return FreeQ(simplify(Mul(u, v)), x) cons1220 = CustomConstraint(cons_f1220) def cons_f1221(f, b, d, c, a, h): return ZeroQ(-a*c*h + b*d*f) cons1221 = CustomConstraint(cons_f1221) def cons_f1222(g, b, d, c, a, h): return ZeroQ(-a*d*h - b*c*h + b*d*g) cons1222 = CustomConstraint(cons_f1222) def cons_f1223(v, x): if isinstance(x, (int, Integer, float, Float)): return False return QuotientOfLinearsQ(v, x) cons1223 = CustomConstraint(cons_f1223) def cons_f1224(v, x): if isinstance(x, (int, Integer, float, Float)): return False return Not(QuotientOfLinearsMatchQ(v, x)) cons1224 = CustomConstraint(cons_f1224) def cons_f1225(v, x): if isinstance(x, (int, Integer, float, Float)): return False return Not(BinomialMatchQ(v, x)) cons1225 = CustomConstraint(cons_f1225) def cons_f1226(p, f, b, g, d, c, a, n, x, e): if isinstance(x, (int, Integer, float, Float)): return False return FreeQ(List(a, b, c, d, e, f, g, n, p), x) cons1226 = CustomConstraint(cons_f1226) def cons_f1227(p, f, b, g, d, c, a, x, e): if isinstance(x, (int, Integer, float, Float)): return False return FreeQ(List(a, b, c, d, e, f, g, p), x) cons1227 = CustomConstraint(cons_f1227) def cons_f1228(m): return IntegerQ(m/S(2) + S(-1)/2) cons1228 = CustomConstraint(cons_f1228) def cons_f1229(m): return Not(IntegerQ(m/S(2) + S(-1)/2)) cons1229 = CustomConstraint(cons_f1229) def cons_f1230(x, u): if isinstance(x, (int, Integer, float, Float)): return False return InverseFunctionFreeQ(u, x) cons1230 = CustomConstraint(cons_f1230) def cons_f1231(n): return Not(And(RationalQ(n), Less(n, S(0)))) cons1231 = CustomConstraint(cons_f1231) def cons_f1232(m, n): return Or(Equal(n, S(1)), IntegerQ(m)) cons1232 = CustomConstraint(cons_f1232) def cons_f1233(x, RFx): if isinstance(x, (int, Integer, float, Float)): return False return Not(PolynomialQ(RFx, x)) cons1233 = CustomConstraint(cons_f1233) def cons_f1234(x, Qx, Px): if isinstance(x, (int, Integer, float, Float)): return False return QuadraticQ(List(Qx, Px), x) cons1234 = CustomConstraint(cons_f1234) def cons_f1235(x, Qx, Px): if isinstance(x, (int, Integer, float, Float)): return False return ZeroQ(D(Px/Qx, x)) cons1235 = CustomConstraint(cons_f1235) def cons_f1236(x, RGx): if isinstance(x, (int, Integer, float, Float)): return False return RationalFunctionQ(RGx, x) cons1236 = CustomConstraint(cons_f1236) def cons_f1237(d): return NonzeroQ(d + S(-1)) cons1237 = CustomConstraint(cons_f1237) def cons_f1238(v, x): if isinstance(x, (int, Integer, float, Float)): return False def _cons_f_1237(m, g): return FreeQ(List(g, m), x) _cons_1237 = CustomConstraint(_cons_f_1237) pat = Pattern(UtilityOperator((x*WC('g', S(1)))**WC('m', S(1)), x), _cons_1237) result_matchq = is_match(UtilityOperator(v, x), pat) return Or(ZeroQ(v + S(-1)), result_matchq) cons1238 = CustomConstraint(cons_f1238) def cons_f1239(x, u): if isinstance(x, (int, Integer, float, Float)): return False return RationalFunctionQ(D(u, x)/u, x) cons1239 = CustomConstraint(cons_f1239) def cons_f1240(x, a, u): if isinstance(x, (int, Integer, float, Float)): return False try: return Or(NonzeroQ(a), Not(And(BinomialQ(u, x), ZeroQ(BinomialDegree(u, x)**S(2) + S(-1))))) except (TypeError, AttributeError): return False cons1240 = CustomConstraint(cons_f1240) def cons_f1241(x, Qx): if isinstance(x, (int, Integer, float, Float)): return False return QuadraticQ(Qx, x) cons1241 = CustomConstraint(cons_f1241) def cons_f1242(v, x): if isinstance(x, (int, Integer, float, Float)): return False return InverseFunctionFreeQ(v, x) cons1242 = CustomConstraint(cons_f1242) def cons_f1243(x, w): if isinstance(x, (int, Integer, float, Float)): return False return InverseFunctionFreeQ(w, x) cons1243 = CustomConstraint(cons_f1243) def cons_f1244(p, b, a, n, x): if isinstance(x, (int, Integer, float, Float)): return False return FreeQ(List(a, b, n, p), x) cons1244 = CustomConstraint(cons_f1244) def cons_f1245(B, a, b, A): return NonzeroQ(A*b - B*a) cons1245 = CustomConstraint(cons_f1245) def cons_f1246(x, a, f): if isinstance(x, (int, Integer, float, Float)): return False return FreeQ(List(a, f), x) cons1246 = CustomConstraint(cons_f1246) def cons_f1247(u): return NonsumQ(u) cons1247 = CustomConstraint(cons_f1247) def cons_f1248(x, u): if isinstance(x, (int, Integer, float, Float)): return False return AlgebraicFunctionQ(u, x) cons1248 = CustomConstraint(cons_f1248) def cons_f1249(x, u): if isinstance(x, (int, Integer, float, Float)): return False return FunctionOfTrigOfLinearQ(u, x) cons1249 = CustomConstraint(cons_f1249) def cons_f1250(n): return IntegerQ(n/S(2) + S(-1)/2) cons1250 = CustomConstraint(cons_f1250) def cons_f1251(m, n): return Not(And(IntegerQ(m/S(2) + S(-1)/2), Less(S(0), m, n))) cons1251 = CustomConstraint(cons_f1251) def cons_f1252(m, n): return Not(And(IntegerQ(m/S(2) + S(-1)/2), Inequality(S(0), Less, m, LessEqual, n))) cons1252 = CustomConstraint(cons_f1252) def cons_f1253(m, n): return Or(IntegersQ(S(2)*m, S(2)*n), ZeroQ(m + n)) cons1253 = CustomConstraint(cons_f1253) def cons_f1254(f, b, a, x, e): if isinstance(x, (int, Integer, float, Float)): return False return FreeQ(List(a, b, e, f), x) cons1254 = CustomConstraint(cons_f1254) def cons_f1255(m, n): return ZeroQ(m + n) cons1255 = CustomConstraint(cons_f1255) def cons_f1256(m): return Less(S(0), m, S(1)) cons1256 = CustomConstraint(cons_f1256) def cons_f1257(m, n, b, a): return Or(RationalQ(n), And(Not(RationalQ(m)), Or(ZeroQ(b + S(-1)), NonzeroQ(a + S(-1))))) cons1257 = CustomConstraint(cons_f1257) def cons_f1258(m, f, b, a, n, x, e): if isinstance(x, (int, Integer, float, Float)): return False return FreeQ(List(a, b, e, f, m, n), x) cons1258 = CustomConstraint(cons_f1258) def cons_f1259(m, n): return ZeroQ(m - n + S(2)) cons1259 = CustomConstraint(cons_f1259) def cons_f1260(m, n): return NonzeroQ(m - n) cons1260 = CustomConstraint(cons_f1260) def cons_f1261(d, c, x): if isinstance(x, (int, Integer, float, Float)): return False return FreeQ(List(c, d), x) cons1261 = CustomConstraint(cons_f1261) def cons_f1262(x, c): if isinstance(x, (int, Integer, float, Float)): return False return FreeQ(List(c, c), x) cons1262 = CustomConstraint(cons_f1262) def cons_f1263(d, c, b, x): if isinstance(x, (int, Integer, float, Float)): return False return FreeQ(List(b, c, d), x) cons1263 = CustomConstraint(cons_f1263) def cons_f1264(b, d, c, a, x): if isinstance(x, (int, Integer, float, Float)): return False return FreeQ(List(a, b, c, d), x) cons1264 = CustomConstraint(cons_f1264) def cons_f1265(a, b): return ZeroQ(a**S(2) - b**S(2)) cons1265 = CustomConstraint(cons_f1265) def cons_f1266(n): return PositiveIntegerQ(n + S(-1)/2) cons1266 = CustomConstraint(cons_f1266) def cons_f1267(a, b): return NonzeroQ(a**S(2) - b**S(2)) cons1267 = CustomConstraint(cons_f1267) def cons_f1268(a, b): return PositiveQ(a + b) cons1268 = CustomConstraint(cons_f1268) def cons_f1269(a, b): return PositiveQ(a - b) cons1269 = CustomConstraint(cons_f1269) def cons_f1270(a, b): return Not(PositiveQ(a + b)) cons1270 = CustomConstraint(cons_f1270) def cons_f1271(a, b): return PositiveQ(a**S(2) - b**S(2)) cons1271 = CustomConstraint(cons_f1271) def cons_f1272(c): return SimplerQ(-Pi/S(2) + c, c) cons1272 = CustomConstraint(cons_f1272) def cons_f1273(b, d, c, a, n, x): if isinstance(x, (int, Integer, float, Float)): return False return FreeQ(List(a, b, c, d, n), x) cons1273 = CustomConstraint(cons_f1273) def cons_f1274(p): return IntegerQ(p/S(2) + S(-1)/2) cons1274 = CustomConstraint(cons_f1274) def cons_f1275(m, p, b, a): return Or(GreaterEqual(p, S(-1)), Not(And(IntegerQ(m + S(1)/2), ZeroQ(a**S(2) - b**S(2))))) cons1275 = CustomConstraint(cons_f1275) def cons_f1276(a, p, b): return Or(IntegerQ(S(2)*p), NonzeroQ(a**S(2) - b**S(2))) cons1276 = CustomConstraint(cons_f1276) def cons_f1277(m, p): return GreaterEqual(S(2)*m + p, S(0)) cons1277 = CustomConstraint(cons_f1277) def cons_f1278(m, p): return ZeroQ(m + p + S(1)) cons1278 = CustomConstraint(cons_f1278) def cons_f1279(p): return Not(NegativeIntegerQ(p)) cons1279 = CustomConstraint(cons_f1279) def cons_f1280(m, p): return NegativeIntegerQ(m + p + S(1)) cons1280 = CustomConstraint(cons_f1280) def cons_f1281(m, p): return NonzeroQ(S(2)*m + p + S(1)) cons1281 = CustomConstraint(cons_f1281) def cons_f1282(m, p): return ZeroQ(S(2)*m + p + S(-1)) cons1282 = CustomConstraint(cons_f1282) def cons_f1283(m): return NonzeroQ(m + S(-1)) cons1283 = CustomConstraint(cons_f1283) def cons_f1284(m, p): return PositiveIntegerQ(m + p/S(2) + S(-1)/2) cons1284 = CustomConstraint(cons_f1284) def cons_f1285(m, p): return NonzeroQ(m + p) cons1285 = CustomConstraint(cons_f1285) def cons_f1286(m, p): return LessEqual(p, -S(2)*m) cons1286 = CustomConstraint(cons_f1286) def cons_f1287(m, p): return IntegersQ(m + S(1)/2, S(2)*p) cons1287 = CustomConstraint(cons_f1287) def cons_f1288(m, p): return IntegersQ(S(2)*m, S(2)*p) cons1288 = CustomConstraint(cons_f1288) def cons_f1289(m, p): return Or(Greater(m, S(-2)), ZeroQ(S(2)*m + p + S(1)), And(Equal(m, S(-2)), IntegerQ(p))) cons1289 = CustomConstraint(cons_f1289) def cons_f1290(m): return LessEqual(m, S(-2)) cons1290 = CustomConstraint(cons_f1290) def cons_f1291(m, p): return Not(NegativeIntegerQ(m + p + S(1))) cons1291 = CustomConstraint(cons_f1291) def cons_f1292(p): return Not(And(RationalQ(p), GreaterEqual(p, S(1)))) cons1292 = CustomConstraint(cons_f1292) def cons_f1293(p): return Greater(p, S(2)) cons1293 = CustomConstraint(cons_f1293) def cons_f1294(m, p): return Or(IntegersQ(S(2)*m, S(2)*p), IntegerQ(m)) cons1294 = CustomConstraint(cons_f1294) def cons_f1295(m, p): return ZeroQ(m + p + S(2)) cons1295 = CustomConstraint(cons_f1295) def cons_f1296(m, p): return NegativeIntegerQ(m + p + S(2)) cons1296 = CustomConstraint(cons_f1296) def cons_f1297(m, p): return Not(PositiveIntegerQ(m + p + S(1))) cons1297 = CustomConstraint(cons_f1297) def cons_f1298(p): return IntegerQ(p/S(2) + S(1)/2) cons1298 = CustomConstraint(cons_f1298) def cons_f1299(m, p): return IntegersQ(m, p) cons1299 = CustomConstraint(cons_f1299) def cons_f1300(m, p): return Equal(p, S(2)*m) cons1300 = CustomConstraint(cons_f1300) def cons_f1301(m, p): return IntegersQ(m, p/S(2)) cons1301 = CustomConstraint(cons_f1301) def cons_f1302(m, p): return Or(Less(p, S(0)), Greater(m - p/S(2), S(0))) cons1302 = CustomConstraint(cons_f1302) def cons_f1303(m): return Not(And(RationalQ(m), Less(m, S(0)))) cons1303 = CustomConstraint(cons_f1303) def cons_f1304(m): return IntegerQ(m + S(-1)/2) cons1304 = CustomConstraint(cons_f1304) def cons_f1305(m): return Not(Less(m, S(-1))) cons1305 = CustomConstraint(cons_f1305) def cons_f1306(p): return IntegerQ(p/S(2)) cons1306 = CustomConstraint(cons_f1306) def cons_f1307(p): return IntegersQ(S(2)*p) cons1307 = CustomConstraint(cons_f1307) def cons_f1308(p, m, f, b, g, a, x, e): if isinstance(x, (int, Integer, float, Float)): return False return FreeQ(List(a, b, e, f, g, m, p), x) cons1308 = CustomConstraint(cons_f1308) def cons_f1309(m, n): return Not(And(IntegerQ(n), Or(And(Less(m, S(0)), Greater(n, S(0))), Less(S(0), n, m), Less(m, n, S(0))))) cons1309 = CustomConstraint(cons_f1309) def cons_f1310(n): return NonzeroQ(n + S(1)/2) cons1310 = CustomConstraint(cons_f1310) def cons_f1311(m): return PositiveIntegerQ(m + S(-1)/2) cons1311 = CustomConstraint(cons_f1311) def cons_f1312(m, n): return Not(And(NegativeIntegerQ(m + n), Greater(S(2)*m + n + S(1), S(0)))) cons1312 = CustomConstraint(cons_f1312) def cons_f1313(m, n): return Not(And(PositiveIntegerQ(n + S(-1)/2), Less(n, m))) cons1313 = CustomConstraint(cons_f1313) def cons_f1314(m): return NonzeroQ(m + S(1)/2) cons1314 = CustomConstraint(cons_f1314) def cons_f1315(m, n): return NegativeIntegerQ(m + n + S(1)) cons1315 = CustomConstraint(cons_f1315) def cons_f1316(m, n): return Not(And(RationalQ(n), Less(m, n, S(-1)))) cons1316 = CustomConstraint(cons_f1316) def cons_f1317(m, n): return Or(FractionQ(m), Not(FractionQ(n))) cons1317 = CustomConstraint(cons_f1317) def cons_f1318(m, f, b, d, c, x, e): if isinstance(x, (int, Integer, float, Float)): return False return FreeQ(List(b, c, d, e, f, m), x) cons1318 = CustomConstraint(cons_f1318) def cons_f1319(m, b, d, a, c): return ZeroQ(a*d*m + b*c*(m + S(1))) cons1319 = CustomConstraint(cons_f1319) def cons_f1320(m): return Less(m, S(-1)/2) cons1320 = CustomConstraint(cons_f1320) def cons_f1321(m): return Not(And(RationalQ(m), Less(m, S(-1)/2))) cons1321 = CustomConstraint(cons_f1321) def cons_f1322(d, c): return ZeroQ(c**S(2) - d**S(2)) cons1322 = CustomConstraint(cons_f1322) def cons_f1323(d, c): return NonzeroQ(c**S(2) - d**S(2)) cons1323 = CustomConstraint(cons_f1323) def cons_f1324(m, n, c): return Or(IntegersQ(S(2)*m, S(2)*n), IntegerQ(m + S(1)/2), And(IntegerQ(m), ZeroQ(c))) cons1324 = CustomConstraint(cons_f1324) def cons_f1325(n): return Less(S(0), n, S(1)) cons1325 = CustomConstraint(cons_f1325) def cons_f1326(m, n, c): return Or(IntegersQ(S(2)*m, S(2)*n), And(IntegerQ(m), ZeroQ(c))) cons1326 = CustomConstraint(cons_f1326) def cons_f1327(n): return Not(And(RationalQ(n), Greater(n, S(0)))) cons1327 = CustomConstraint(cons_f1327) def cons_f1328(c, n): return Or(IntegerQ(S(2)*n), ZeroQ(c)) cons1328 = CustomConstraint(cons_f1328) def cons_f1329(n): return NonzeroQ(S(2)*n + S(3)) cons1329 = CustomConstraint(cons_f1329) def cons_f1330(d, a, b): return ZeroQ(-a/b + d) cons1330 = CustomConstraint(cons_f1330) def cons_f1331(d, b): return PositiveQ(d/b) cons1331 = CustomConstraint(cons_f1331) def cons_f1332(d, b): return Not(PositiveQ(d/b)) cons1332 = CustomConstraint(cons_f1332) def cons_f1333(m): return Greater(m, S(2)) cons1333 = CustomConstraint(cons_f1333) def cons_f1334(m, n): return Or(IntegerQ(m), IntegersQ(S(2)*m, S(2)*n)) cons1334 = CustomConstraint(cons_f1334) def cons_f1335(m, n, c, a): return Not(And(IntegerQ(n), Greater(n, S(2)), Or(Not(IntegerQ(m)), And(ZeroQ(a), NonzeroQ(c))))) cons1335 = CustomConstraint(cons_f1335) def cons_f1336(n): return Less(S(1), n, S(2)) cons1336 = CustomConstraint(cons_f1336) def cons_f1337(m, a, n): return Or(And(ZeroQ(a), IntegerQ(m), Not(IntegerQ(n))), Not(And(IntegerQ(S(2)*n), Less(n, S(-1)), Or(And(IntegerQ(n), Not(IntegerQ(m))), ZeroQ(a))))) cons1337 = CustomConstraint(cons_f1337) def cons_f1338(d, c): return PositiveQ(c + d) cons1338 = CustomConstraint(cons_f1338) def cons_f1339(d, c): return PositiveQ(c - d) cons1339 = CustomConstraint(cons_f1339) def cons_f1340(d, c): return Not(PositiveQ(c + d)) cons1340 = CustomConstraint(cons_f1340) def cons_f1341(d, c): return PositiveQ(c**S(2) - d**S(2)) cons1341 = CustomConstraint(cons_f1341) def cons_f1342(d, c, b): return PosQ((c + d)/b) cons1342 = CustomConstraint(cons_f1342) def cons_f1343(c): return PositiveQ(c**S(2)) cons1343 = CustomConstraint(cons_f1343) def cons_f1344(d, c, b): return NegQ((c + d)/b) cons1344 = CustomConstraint(cons_f1344) def cons_f1345(d, c, a, b): return PosQ((a + b)/(c + d)) cons1345 = CustomConstraint(cons_f1345) def cons_f1346(d, c, a, b): return NegQ((a + b)/(c + d)) cons1346 = CustomConstraint(cons_f1346) def cons_f1347(a, b): return NegativeQ(a**S(2) - b**S(2)) cons1347 = CustomConstraint(cons_f1347) def cons_f1348(d): return ZeroQ(d**S(2) + S(-1)) cons1348 = CustomConstraint(cons_f1348) def cons_f1349(d, b): return PositiveQ(b*d) cons1349 = CustomConstraint(cons_f1349) def cons_f1350(b): return PositiveQ(b**S(2)) cons1350 = CustomConstraint(cons_f1350) def cons_f1351(d, b): return Not(And(ZeroQ(d**S(2) + S(-1)), PositiveQ(b*d))) cons1351 = CustomConstraint(cons_f1351) def cons_f1352(d, a, b): return PosQ((a + b)/d) cons1352 = CustomConstraint(cons_f1352) def cons_f1353(a): return PositiveQ(a**S(2)) cons1353 = CustomConstraint(cons_f1353) def cons_f1354(d, a, b): return NegQ((a + b)/d) cons1354 = CustomConstraint(cons_f1354) def cons_f1355(d, c, b, a): return PosQ((c + d)/(a + b)) cons1355 = CustomConstraint(cons_f1355) def cons_f1356(d, c, b, a): return NegQ((c + d)/(a + b)) cons1356 = CustomConstraint(cons_f1356) def cons_f1357(m): return Less(S(0), m, S(2)) cons1357 = CustomConstraint(cons_f1357) def cons_f1358(n): return Less(S(-1), n, S(2)) cons1358 = CustomConstraint(cons_f1358) def cons_f1359(m, n): return NonzeroQ(m + n) cons1359 = CustomConstraint(cons_f1359) def cons_f1360(m, f, b, d, c, a, n, x, e): if isinstance(x, (int, Integer, float, Float)): return False return FreeQ(List(a, b, c, d, e, f, m, n), x) cons1360 = CustomConstraint(cons_f1360) def cons_f1361(a, p, b, n): return Or(And(Less(p, S(0)), NonzeroQ(a**S(2) - b**S(2))), Less(S(0), n, p + S(-1)), Less(p + S(1), -n, S(2)*p + S(1))) cons1361 = CustomConstraint(cons_f1361) def cons_f1362(p, n): return Or(Less(S(0), n, p/S(2) + S(1)/2), Inequality(p, LessEqual, -n, Less, S(2)*p + S(-3)), Inequality(S(0), Less, n, LessEqual, -p)) cons1362 = CustomConstraint(cons_f1362) def cons_f1363(p, f, b, g, d, a, n, x, e): if isinstance(x, (int, Integer, float, Float)): return False return FreeQ(List(a, b, d, e, f, g, n, p), x) cons1363 = CustomConstraint(cons_f1363) def cons_f1364(m, n): return Not(And(IntegerQ(n), Less(n**S(2), m**S(2)))) cons1364 = CustomConstraint(cons_f1364) def cons_f1365(p, n): return NonzeroQ(S(2)*n + p + S(1)) cons1365 = CustomConstraint(cons_f1365) def cons_f1366(m, n, p): return Not(And(NegativeIntegerQ(m + n + p), Greater(S(2)*m + n + S(3)*p/S(2) + S(1), S(0)))) cons1366 = CustomConstraint(cons_f1366) def cons_f1367(m, p, n): return Not(And(PositiveIntegerQ(n + p/S(2) + S(-1)/2), Greater(m - n, S(0)))) cons1367 = CustomConstraint(cons_f1367) def cons_f1368(m, p): return ZeroQ(S(2)*m + p + S(1)) cons1368 = CustomConstraint(cons_f1368) def cons_f1369(m, n, p): return ZeroQ(m + n + p + S(1)) cons1369 = CustomConstraint(cons_f1369) def cons_f1370(m, n, p): return NegativeIntegerQ(m + n + p + S(1)) cons1370 = CustomConstraint(cons_f1370) def cons_f1371(m, n, p): return NonzeroQ(m + n + p) cons1371 = CustomConstraint(cons_f1371) def cons_f1372(m, n): return Not(And(RationalQ(n), Less(S(0), n, m))) cons1372 = CustomConstraint(cons_f1372) def cons_f1373(p, m, b, d, a, c): return ZeroQ(a*d*m + b*c*(m + p + S(1))) cons1373 = CustomConstraint(cons_f1373) def cons_f1374(m): return Greater(m, S(-1)) cons1374 = CustomConstraint(cons_f1374) def cons_f1375(m, p): return PositiveIntegerQ(m + p/S(2) + S(1)/2) cons1375 = CustomConstraint(cons_f1375) def cons_f1376(m): return Less(m, S(-3)/2) cons1376 = CustomConstraint(cons_f1376) def cons_f1377(m): return Inequality(S(-3)/2, LessEqual, m, Less, S(0)) cons1377 = CustomConstraint(cons_f1377) def cons_f1378(m, p): return Or(And(RationalQ(m), Less(m, S(-1))), NegativeIntegerQ(m + p)) cons1378 = CustomConstraint(cons_f1378) def cons_f1379(p): return Not(And(RationalQ(p), Less(p, S(-1)))) cons1379 = CustomConstraint(cons_f1379) def cons_f1380(m, p): return Equal(S(2)*m + p, S(0)) cons1380 = CustomConstraint(cons_f1380) def cons_f1381(m, n, p): return IntegersQ(m, n, p/S(2)) cons1381 = CustomConstraint(cons_f1381) def cons_f1382(m, p, n): return Or(And(Greater(m, S(0)), Greater(p, S(0)), Less(-m - p, n, S(-1))), And(Greater(m, S(2)), Less(p, S(0)), Greater(m + p/S(2), S(0)))) cons1382 = CustomConstraint(cons_f1382) def cons_f1383(m, n): return Or(NegativeIntegerQ(m), Not(PositiveIntegerQ(n))) cons1383 = CustomConstraint(cons_f1383) def cons_f1384(m, p): return Or(Equal(S(2)*m + p, S(0)), And(Greater(S(2)*m + p, S(0)), Less(p, S(-1)))) cons1384 = CustomConstraint(cons_f1384) def cons_f1385(m): return LessEqual(m, S(-1)/2) cons1385 = CustomConstraint(cons_f1385) def cons_f1386(m, p): return NonzeroQ(m + p + S(2)) cons1386 = CustomConstraint(cons_f1386) def cons_f1387(p, n): return Or(IntegerQ(p), PositiveIntegerQ(n)) cons1387 = CustomConstraint(cons_f1387) def cons_f1388(m, p): return ZeroQ(m + p + S(1)/2) cons1388 = CustomConstraint(cons_f1388) def cons_f1389(m, p): return ZeroQ(m + p + S(3)/2) cons1389 = CustomConstraint(cons_f1389) def cons_f1390(m, n): return Or(PositiveIntegerQ(m), IntegersQ(S(2)*m, S(2)*n)) cons1390 = CustomConstraint(cons_f1390) def cons_f1391(n): return Not(Less(n, S(-1))) cons1391 = CustomConstraint(cons_f1391) def cons_f1392(m, n): return Or(Less(m, S(-2)), ZeroQ(m + n + S(4))) cons1392 = CustomConstraint(cons_f1392) def cons_f1393(m, n): return NonzeroQ(m + n + S(4)) cons1393 = CustomConstraint(cons_f1393) def cons_f1394(m, n): return Or(Less(n, S(-2)), ZeroQ(m + n + S(4))) cons1394 = CustomConstraint(cons_f1394) def cons_f1395(n): return NonzeroQ(n + S(2)) cons1395 = CustomConstraint(cons_f1395) def cons_f1396(m, n): return NonzeroQ(m + n + S(5)) cons1396 = CustomConstraint(cons_f1396) def cons_f1397(m, n): return NonzeroQ(m + n + S(6)) cons1397 = CustomConstraint(cons_f1397) def cons_f1398(m, n, p): return IntegersQ(m, S(2)*n, p/S(2)) cons1398 = CustomConstraint(cons_f1398) def cons_f1399(m, p): return Or(Less(m, S(-1)), And(Equal(m, S(-1)), Greater(p, S(0)))) cons1399 = CustomConstraint(cons_f1399) def cons_f1400(p, n): return Or(Less(n, S(0)), PositiveIntegerQ(p + S(1)/2)) cons1400 = CustomConstraint(cons_f1400) def cons_f1401(p, n): return IntegersQ(S(2)*n, S(2)*p) cons1401 = CustomConstraint(cons_f1401) def cons_f1402(p, n): return Or(LessEqual(n, S(-2)), And(Equal(n, S(-3)/2), Equal(p, S(3)/2))) cons1402 = CustomConstraint(cons_f1402) def cons_f1403(p, n): return Or(Less(n, S(-1)), And(Equal(p, S(3)/2), Equal(n, S(-1)/2))) cons1403 = CustomConstraint(cons_f1403) def cons_f1404(p): return Less(S(-1), p, S(1)) cons1404 = CustomConstraint(cons_f1404) def cons_f1405(m, n): return Or(Greater(m, S(0)), IntegerQ(n)) cons1405 = CustomConstraint(cons_f1405) def cons_f1406(m, n, p): return IntegersQ(m, S(2)*n, S(2)*p) cons1406 = CustomConstraint(cons_f1406) def cons_f1407(m, n, p): return Or(LessEqual(n, S(-2)), And(Equal(m, S(-1)), Equal(n, S(-3)/2), Equal(p, S(3)/2))) cons1407 = CustomConstraint(cons_f1407) def cons_f1408(p): return PositiveIntegerQ(p/S(2)) cons1408 = CustomConstraint(cons_f1408) def cons_f1409(d, c, a, b): return Or(ZeroQ(a**S(2) - b**S(2)), ZeroQ(c**S(2) - d**S(2))) cons1409 = CustomConstraint(cons_f1409) def cons_f1410(d, c): return ZeroQ(-c + d) cons1410 = CustomConstraint(cons_f1410) def cons_f1411(a, b): return PositiveQ(-a**S(2) + b**S(2)) cons1411 = CustomConstraint(cons_f1411) def cons_f1412(d, c, b, a): return NonzeroQ(a*d + b*c) cons1412 = CustomConstraint(cons_f1412) def cons_f1413(d, c, a, b): return Or(NonzeroQ(a**S(2) - b**S(2)), NonzeroQ(c**S(2) - d**S(2))) cons1413 = CustomConstraint(cons_f1413) def cons_f1414(p, n): return ZeroQ(S(2)*n + p) cons1414 = CustomConstraint(cons_f1414) def cons_f1415(m, n, p): return Or(IntegersQ(m, n), IntegersQ(m, p), IntegersQ(n, p)) cons1415 = CustomConstraint(cons_f1415) def cons_f1416(p): return NonzeroQ(p + S(-2)) cons1416 = CustomConstraint(cons_f1416) def cons_f1417(m, n): return Not(And(IntegerQ(m), IntegerQ(n))) cons1417 = CustomConstraint(cons_f1417) def cons_f1418(B, a, b, A): return ZeroQ(A*b + B*a) cons1418 = CustomConstraint(cons_f1418) def cons_f1419(B, m, b, a, n, A): return ZeroQ(A*b*(m + n + S(1)) + B*a*(m - n)) cons1419 = CustomConstraint(cons_f1419) def cons_f1420(m, n): return Or(And(RationalQ(m), Less(m, S(-1)/2)), And(NegativeIntegerQ(m + n), Not(SumSimplerQ(n, S(1))))) cons1420 = CustomConstraint(cons_f1420) def cons_f1421(m): return NonzeroQ(S(2)*m + S(1)) cons1421 = CustomConstraint(cons_f1421) def cons_f1422(B, m, b, d, a, c, n, A): return ZeroQ(A*(a*d*m + b*c*(n + S(1))) - B*(a*c*m + b*d*(n + S(1)))) cons1422 = CustomConstraint(cons_f1422) def cons_f1423(m): return Greater(m, S(1)/2) cons1423 = CustomConstraint(cons_f1423) def cons_f1424(B, b, d, c, n, a, A): return ZeroQ(A*b*d*(S(2)*n + S(3)) - B*(-S(2)*a*d*(n + S(1)) + b*c)) cons1424 = CustomConstraint(cons_f1424) def cons_f1425(m, n): return Or(IntegerQ(n), ZeroQ(m + S(1)/2)) cons1425 = CustomConstraint(cons_f1425) def cons_f1426(B, a, b, A): return NonzeroQ(A*b + B*a) cons1426 = CustomConstraint(cons_f1426) def cons_f1427(m, n, c, a): return Not(And(IntegerQ(n), Greater(n, S(1)), Or(Not(IntegerQ(m)), And(ZeroQ(a), NonzeroQ(c))))) cons1427 = CustomConstraint(cons_f1427) def cons_f1428(B, A): return ZeroQ(A - B) cons1428 = CustomConstraint(cons_f1428) def cons_f1429(B, A): return NonzeroQ(A - B) cons1429 = CustomConstraint(cons_f1429) def cons_f1430(n): return Equal(n**S(2), S(1)/4) cons1430 = CustomConstraint(cons_f1430) def cons_f1431(B, C, m, f, b, x, e): if isinstance(x, (int, Integer, float, Float)): return False return FreeQ(List(b, e, f, B, C, m), x) cons1431 = CustomConstraint(cons_f1431) def cons_f1432(m, C, A): return ZeroQ(A*(m + S(2)) + C*(m + S(1))) cons1432 = CustomConstraint(cons_f1432) def cons_f1433(a, C, b, A): return ZeroQ(A*b**S(2) + C*a**S(2)) cons1433 = CustomConstraint(cons_f1433) def cons_f1434(B, C, A): return ZeroQ(A - B + C) cons1434 = CustomConstraint(cons_f1434) def cons_f1435(C, A): return ZeroQ(A + C) cons1435 = CustomConstraint(cons_f1435) def cons_f1436(m, n): return Or(And(RationalQ(m), Less(m, S(-1)/2)), And(ZeroQ(m + n + S(2)), NonzeroQ(S(2)*m + S(1)))) cons1436 = CustomConstraint(cons_f1436) def cons_f1437(m, n): return Or(And(RationalQ(n), Less(n, S(-1))), ZeroQ(m + n + S(2))) cons1437 = CustomConstraint(cons_f1437) def cons_f1438(m, n, c, a): return Not(And(IntegerQ(n), Greater(n, S(0)), Or(Not(IntegerQ(m)), And(ZeroQ(a), NonzeroQ(c))))) cons1438 = CustomConstraint(cons_f1438) def cons_f1439(a, b): return ZeroQ(a**S(2) + b**S(2)) cons1439 = CustomConstraint(cons_f1439) def cons_f1440(a, b): return NonzeroQ(a**S(2) + b**S(2)) cons1440 = CustomConstraint(cons_f1440) def cons_f1441(n): return Not(OddQ(n)) cons1441 = CustomConstraint(cons_f1441) def cons_f1442(n): return Unequal(n, S(-2)) cons1442 = CustomConstraint(cons_f1442) def cons_f1443(n): return Not(And(RationalQ(n), Or(GreaterEqual(n, S(1)), LessEqual(n, S(-1))))) cons1443 = CustomConstraint(cons_f1443) def cons_f1444(a, b): return PositiveQ(a**S(2) + b**S(2)) cons1444 = CustomConstraint(cons_f1444) def cons_f1445(a, b): return Not(Or(PositiveQ(a**S(2) + b**S(2)), ZeroQ(a**S(2) + b**S(2)))) cons1445 = CustomConstraint(cons_f1445) def cons_f1446(m, n): return IntegerQ(m/S(2) + n/S(2)) cons1446 = CustomConstraint(cons_f1446) def cons_f1447(m, n): return Not(And(Greater(n, S(0)), Greater(m, S(1)))) cons1447 = CustomConstraint(cons_f1447) def cons_f1448(c, a, b): return ZeroQ(a**S(2) - b**S(2) - c**S(2)) cons1448 = CustomConstraint(cons_f1448) def cons_f1449(c, b): return ZeroQ(b**S(2) + c**S(2)) cons1449 = CustomConstraint(cons_f1449) def cons_f1450(c, b): return NonzeroQ(b**S(2) + c**S(2)) cons1450 = CustomConstraint(cons_f1450) def cons_f1451(c, a, b): return PositiveQ(a + sqrt(b**S(2) + c**S(2))) cons1451 = CustomConstraint(cons_f1451) def cons_f1452(c, a, b): return NonzeroQ(a**S(2) - b**S(2) - c**S(2)) cons1452 = CustomConstraint(cons_f1452) def cons_f1453(c, a, b): return Not(PositiveQ(a + sqrt(b**S(2) + c**S(2)))) cons1453 = CustomConstraint(cons_f1453) def cons_f1454(a, b): return ZeroQ(a + b) cons1454 = CustomConstraint(cons_f1454) def cons_f1455(a, c): return ZeroQ(a - c) cons1455 = CustomConstraint(cons_f1455) def cons_f1456(a, b): return NonzeroQ(a - b) cons1456 = CustomConstraint(cons_f1456) def cons_f1457(n): return Unequal(n, S(-3)/2) cons1457 = CustomConstraint(cons_f1457) def cons_f1458(B, C, b, c, a, A): return ZeroQ(A*(b**S(2) + c**S(2)) - a*(B*b + C*c)) cons1458 = CustomConstraint(cons_f1458) def cons_f1459(C, b, c, a, A): return ZeroQ(A*(b**S(2) + c**S(2)) - C*a*c) cons1459 = CustomConstraint(cons_f1459) def cons_f1460(B, b, c, a, A): return ZeroQ(A*(b**S(2) + c**S(2)) - B*a*b) cons1460 = CustomConstraint(cons_f1460) def cons_f1461(B, C, b, c, a, A): return NonzeroQ(A*(b**S(2) + c**S(2)) - a*(B*b + C*c)) cons1461 = CustomConstraint(cons_f1461) def cons_f1462(C, b, c, a, A): return NonzeroQ(A*(b**S(2) + c**S(2)) - C*a*c) cons1462 = CustomConstraint(cons_f1462) def cons_f1463(B, b, c, a, A): return NonzeroQ(A*(b**S(2) + c**S(2)) - B*a*b) cons1463 = CustomConstraint(cons_f1463) def cons_f1464(B, C, b, c, n, a, A): return ZeroQ(A*a*(n + S(1)) + n*(B*b + C*c)) cons1464 = CustomConstraint(cons_f1464) def cons_f1465(C, c, a, n, A): return ZeroQ(A*a*(n + S(1)) + C*c*n) cons1465 = CustomConstraint(cons_f1465) def cons_f1466(B, b, a, n, A): return ZeroQ(A*a*(n + S(1)) + B*b*n) cons1466 = CustomConstraint(cons_f1466) def cons_f1467(B, C, b, c, n, a, A): return NonzeroQ(A*a*(n + S(1)) + n*(B*b + C*c)) cons1467 = CustomConstraint(cons_f1467) def cons_f1468(C, c, a, n, A): return NonzeroQ(A*a*(n + S(1)) + C*c*n) cons1468 = CustomConstraint(cons_f1468) def cons_f1469(B, b, a, n, A): return NonzeroQ(A*a*(n + S(1)) + B*b*n) cons1469 = CustomConstraint(cons_f1469) def cons_f1470(B, c, C, b): return ZeroQ(B*b + C*c) cons1470 = CustomConstraint(cons_f1470) def cons_f1471(B, c, C, b): return ZeroQ(B*c - C*b) cons1471 = CustomConstraint(cons_f1471) def cons_f1472(B, C, b, c, a, A): return ZeroQ(A*a - B*b - C*c) cons1472 = CustomConstraint(cons_f1472) def cons_f1473(a, C, c, A): return ZeroQ(A*a - C*c) cons1473 = CustomConstraint(cons_f1473) def cons_f1474(B, a, b, A): return ZeroQ(A*a - B*b) cons1474 = CustomConstraint(cons_f1474) def cons_f1475(B, C, b, c, a, A): return NonzeroQ(A*a - B*b - C*c) cons1475 = CustomConstraint(cons_f1475) def cons_f1476(a, C, c, A): return NonzeroQ(A*a - C*c) cons1476 = CustomConstraint(cons_f1476) def cons_f1477(B, a, b, A): return NonzeroQ(A*a - B*b) cons1477 = CustomConstraint(cons_f1477) def cons_f1478(a, b): return NonzeroQ(a + b) cons1478 = CustomConstraint(cons_f1478) def cons_f1479(n): return EvenQ(n) cons1479 = CustomConstraint(cons_f1479) def cons_f1480(m): return EvenQ(m) cons1480 = CustomConstraint(cons_f1480) def cons_f1481(m): return OddQ(m) cons1481 = CustomConstraint(cons_f1481) def cons_f1482(n): return OddQ(n) cons1482 = CustomConstraint(cons_f1482) def cons_f1483(m): return Not(OddQ(m)) cons1483 = CustomConstraint(cons_f1483) def cons_f1484(p): return EvenQ(p) cons1484 = CustomConstraint(cons_f1484) def cons_f1485(q): return EvenQ(q) cons1485 = CustomConstraint(cons_f1485) def cons_f1486(p, q): return Inequality(S(0), Less, p, LessEqual, q) cons1486 = CustomConstraint(cons_f1486) def cons_f1487(p, q): return Less(S(0), q, p) cons1487 = CustomConstraint(cons_f1487) def cons_f1488(m, f, d, c, x, e): if isinstance(x, (int, Integer, float, Float)): return False return FreeQ(List(c, d, e, f, m), x) cons1488 = CustomConstraint(cons_f1488) def cons_f1489(m): return Or(Not(RationalQ(m)), Inequality(S(-1), LessEqual, m, Less, S(1))) cons1489 = CustomConstraint(cons_f1489) def cons_f1490(m, n, b, a): return Or(Equal(n, S(1)), PositiveIntegerQ(m), NonzeroQ(a**S(2) - b**S(2))) cons1490 = CustomConstraint(cons_f1490) def cons_f1491(m, n): return Or(Greater(n, S(0)), PositiveIntegerQ(m)) cons1491 = CustomConstraint(cons_f1491) def cons_f1492(a, b): return ZeroQ(a - b) cons1492 = CustomConstraint(cons_f1492) def cons_f1493(n): return NegativeIntegerQ(n + S(2)) cons1493 = CustomConstraint(cons_f1493) def cons_f1494(p, n): return Or(Equal(n, S(2)), Equal(p, S(-1))) cons1494 = CustomConstraint(cons_f1494) def cons_f1495(p, b, d, c, a, n, x): if isinstance(x, (int, Integer, float, Float)): return False return FreeQ(List(a, b, c, d, n, p), x) cons1495 = CustomConstraint(cons_f1495) def cons_f1496(m, n): return Or(Greater(m - n + S(1), S(0)), Greater(n, S(2))) cons1496 = CustomConstraint(cons_f1496) def cons_f1497(p, m, b, d, c, a, n, x, e): if isinstance(x, (int, Integer, float, Float)): return False return FreeQ(List(a, b, c, d, e, m, n, p), x) cons1497 = CustomConstraint(cons_f1497) def cons_f1498(d, c, n, x): if isinstance(x, (int, Integer, float, Float)): return False return FreeQ(List(c, d, n), x) cons1498 = CustomConstraint(cons_f1498) def cons_f1499(d, x, n): if isinstance(x, (int, Integer, float, Float)): return False return FreeQ(List(d, n), x) cons1499 = CustomConstraint(cons_f1499) def cons_f1500(m, n): return ZeroQ(m - n/S(2) + S(1)) cons1500 = CustomConstraint(cons_f1500) def cons_f1501(m, n): return Less(S(0), n, m + S(1)) cons1501 = CustomConstraint(cons_f1501) def cons_f1502(n): return NonzeroQ(n + S(-1)) cons1502 = CustomConstraint(cons_f1502) def cons_f1503(m, n): return Less(S(0), S(2)*n, m + S(1)) cons1503 = CustomConstraint(cons_f1503) def cons_f1504(m, n): return Less(S(0), S(2)*n, -m + S(1)) cons1504 = CustomConstraint(cons_f1504) def cons_f1505(p): return Unequal(p, S(-2)) cons1505 = CustomConstraint(cons_f1505) def cons_f1506(m, d, c, n, x, e): if isinstance(x, (int, Integer, float, Float)): return False return FreeQ(List(c, d, e, m, n), x) cons1506 = CustomConstraint(cons_f1506) def cons_f1507(m, b, d, c, a, x, e): if isinstance(x, (int, Integer, float, Float)): return False return FreeQ(List(a, b, c, d, e, m), x) cons1507 = CustomConstraint(cons_f1507) def cons_f1508(m, n): return ZeroQ(m + n + S(-1)) cons1508 = CustomConstraint(cons_f1508) def cons_f1509(m, n): return IntegersQ(m, n, m/S(2) + n/S(2) + S(-1)/2) cons1509 = CustomConstraint(cons_f1509) def cons_f1510(m): return Unequal(m, S(-2)) cons1510 = CustomConstraint(cons_f1510) def cons_f1511(m): return Not(And(RationalQ(m), Greater(m, S(1)), Not(IntegerQ(m/S(2) + S(-1)/2)))) cons1511 = CustomConstraint(cons_f1511) def cons_f1512(n): return IntegerQ(n/S(2) + S(1)/2) cons1512 = CustomConstraint(cons_f1512) def cons_f1513(m, n): return Not(IntegersQ(S(2)*m, S(2)*n)) cons1513 = CustomConstraint(cons_f1513) def cons_f1514(m, n): return Not(And(IntegerQ(m/S(2)), Less(S(0), m, n + S(1)))) cons1514 = CustomConstraint(cons_f1514) def cons_f1515(m): return IntegerQ(m/S(2)) cons1515 = CustomConstraint(cons_f1515) def cons_f1516(m, n): return Not(And(IntegerQ(n/S(2) + S(-1)/2), Less(S(0), n, m + S(-1)))) cons1516 = CustomConstraint(cons_f1516) def cons_f1517(m, n): return Or(Greater(m, S(1)), And(Equal(m, S(1)), Equal(n, S(-3)/2))) cons1517 = CustomConstraint(cons_f1517) def cons_f1518(m, n): return Or(Less(m, S(-1)), And(Equal(m, S(-1)), Equal(n, S(3)/2))) cons1518 = CustomConstraint(cons_f1518) def cons_f1519(m, n): return NonzeroQ(m + n + S(-1)) cons1519 = CustomConstraint(cons_f1519) def cons_f1520(m, n): return Or(Less(m, S(-1)), And(Equal(m, S(-1)), RationalQ(n), Equal(n, S(-1)/2))) cons1520 = CustomConstraint(cons_f1520) def cons_f1521(m, n): return Or(Greater(m, S(1)), And(Equal(m, S(1)), RationalQ(n), Equal(n, S(1)/2))) cons1521 = CustomConstraint(cons_f1521) def cons_f1522(x, f, b, e): if isinstance(x, (int, Integer, float, Float)): return False return FreeQ(List(b, e, f), x) cons1522 = CustomConstraint(cons_f1522) def cons_f1523(n): return Not(IntegerQ(n/S(2) + S(-1)/2)) cons1523 = CustomConstraint(cons_f1523) def cons_f1524(m): return Not(IntegerQ(m/S(2))) cons1524 = CustomConstraint(cons_f1524) def cons_f1525(m, p, n): return NonzeroQ(m*p + n + S(-1)) cons1525 = CustomConstraint(cons_f1525) def cons_f1526(m, p, n): return IntegersQ(S(2)*m*p, S(2)*n) cons1526 = CustomConstraint(cons_f1526) def cons_f1527(m, p, n): return NonzeroQ(m*p + n + S(1)) cons1527 = CustomConstraint(cons_f1527) def cons_f1528(m, b, a): return Or(IntegerQ(S(2)*m), NonzeroQ(a**S(2) + b**S(2))) cons1528 = CustomConstraint(cons_f1528) def cons_f1529(m, n): return ZeroQ(m/S(2) + n) cons1529 = CustomConstraint(cons_f1529) def cons_f1530(m, n): return ZeroQ(m/S(2) + n + S(-1)) cons1530 = CustomConstraint(cons_f1530) def cons_f1531(m, n): return PositiveIntegerQ(m/S(2) + n + S(-1)) cons1531 = CustomConstraint(cons_f1531) def cons_f1532(m, n): return Or(And(PositiveIntegerQ(n/S(2)), NegativeIntegerQ(m + S(-1)/2)), And(Equal(n, S(2)), Less(m, S(0))), And(LessEqual(m, S(-1)), Greater(m + n, S(0))), And(NegativeIntegerQ(m), Less(m/S(2) + n + S(-1), S(0)), IntegerQ(n)), And(Equal(n, S(3)/2), Equal(m, S(-1)/2))) cons1532 = CustomConstraint(cons_f1532) def cons_f1533(m, n): return Or(And(PositiveIntegerQ(n/S(2)), NegativeIntegerQ(m + S(-1)/2)), And(Equal(n, S(2)), Less(m, S(0))), And(LessEqual(m, S(-1)), Greater(m + n, S(0))), And(NegativeIntegerQ(m), Less(m/S(2) + n + S(-1), S(0))), And(Equal(n, S(3)/2), Equal(m, S(-1)/2))) cons1533 = CustomConstraint(cons_f1533) def cons_f1534(m, n): return Or(And(NegativeIntegerQ(n/S(2)), PositiveIntegerQ(m + S(-1)/2)), Equal(n, S(-2)), PositiveIntegerQ(m + n), And(IntegersQ(n, m + S(1)/2), Greater(S(2)*m + n + S(1), S(0)))) cons1534 = CustomConstraint(cons_f1534) def cons_f1535(m, n): return Not(NegativeIntegerQ(m + n)) cons1535 = CustomConstraint(cons_f1535) def cons_f1536(m, n): return NonzeroQ(m + S(2)*n) cons1536 = CustomConstraint(cons_f1536) def cons_f1537(m, n): return PositiveIntegerQ(m + n + S(-1)) cons1537 = CustomConstraint(cons_f1537) def cons_f1538(m, n): return NegativeIntegerQ(m + n) cons1538 = CustomConstraint(cons_f1538) def cons_f1539(m): return PositiveIntegerQ(m + S(-1)) cons1539 = CustomConstraint(cons_f1539) def cons_f1540(m, n): return Or(And(Less(m, S(5)), Greater(n, S(-4))), And(Equal(m, S(5)), Equal(n, S(-1)))) cons1540 = CustomConstraint(cons_f1540) def cons_f1541(m, n): return Not(And(IntegerQ(n), Greater(n, S(0)), Or(Less(m, S(0)), Less(n, m)))) cons1541 = CustomConstraint(cons_f1541) def cons_f1542(d, a, c, b): return ZeroQ(a*c + b*d) cons1542 = CustomConstraint(cons_f1542) def cons_f1543(d, a, c, b): return NonzeroQ(a*c + b*d) cons1543 = CustomConstraint(cons_f1543) def cons_f1544(d, c): return ZeroQ(c**S(2) + d**S(2)) cons1544 = CustomConstraint(cons_f1544) def cons_f1545(d, c): return NonzeroQ(c**S(2) + d**S(2)) cons1545 = CustomConstraint(cons_f1545) def cons_f1546(d, a, c, b): return ZeroQ(S(2)*a*c*d - b*(c**S(2) - d**S(2))) cons1546 = CustomConstraint(cons_f1546) def cons_f1547(d, a, c, b): return NonzeroQ(S(2)*a*c*d - b*(c**S(2) - d**S(2))) cons1547 = CustomConstraint(cons_f1547) def cons_f1548(d, c, a, b): return Or(PerfectSquareQ(a**S(2) + b**S(2)), RationalQ(a, b, c, d)) cons1548 = CustomConstraint(cons_f1548) def cons_f1549(m): return Not(And(RationalQ(m), LessEqual(m, S(-1)))) cons1549 = CustomConstraint(cons_f1549) def cons_f1550(m, a): return Not(And(ZeroQ(m + S(-2)), ZeroQ(a))) cons1550 = CustomConstraint(cons_f1550) def cons_f1551(m, n): return Equal(m + n, S(0)) cons1551 = CustomConstraint(cons_f1551) def cons_f1552(m): return IntegersQ(S(2)*m) cons1552 = CustomConstraint(cons_f1552) def cons_f1553(m, n): return Or(IntegerQ(n), IntegersQ(S(2)*m, S(2)*n)) cons1553 = CustomConstraint(cons_f1553) def cons_f1554(m, n): return Or(And(RationalQ(n), GreaterEqual(n, S(-1))), IntegerQ(m)) cons1554 = CustomConstraint(cons_f1554) def cons_f1555(m, n, c, a): return Not(And(IntegerQ(n), Greater(n, S(2)), Or(Not(IntegerQ(m)), And(ZeroQ(c), NonzeroQ(a))))) cons1555 = CustomConstraint(cons_f1555) def cons_f1556(m, n): return Or(And(RationalQ(n), Less(n, S(0))), IntegerQ(m)) cons1556 = CustomConstraint(cons_f1556) def cons_f1557(m, n, c, a): return Not(And(IntegerQ(n), Less(n, S(-1)), Or(Not(IntegerQ(m)), And(ZeroQ(c), NonzeroQ(a))))) cons1557 = CustomConstraint(cons_f1557) def cons_f1558(B, A): return ZeroQ(A**S(2) + B**S(2)) cons1558 = CustomConstraint(cons_f1558) def cons_f1559(B, A): return NonzeroQ(A**S(2) + B**S(2)) cons1559 = CustomConstraint(cons_f1559) def cons_f1560(m, n, c, a): return Not(And(IntegerQ(n), Greater(n, S(1)), Or(Not(IntegerQ(m)), And(ZeroQ(c), NonzeroQ(a))))) cons1560 = CustomConstraint(cons_f1560) def cons_f1561(C, A): return ZeroQ(A - C) cons1561 = CustomConstraint(cons_f1561) def cons_f1562(B, C, b, a, A): return NonzeroQ(A*b**S(2) - B*a*b + C*a**S(2)) cons1562 = CustomConstraint(cons_f1562) def cons_f1563(a, C, b, A): return NonzeroQ(A*b**S(2) + C*a**S(2)) cons1563 = CustomConstraint(cons_f1563) def cons_f1564(B, C, b, a, A): return ZeroQ(A*b - B*a - C*b) cons1564 = CustomConstraint(cons_f1564) def cons_f1565(C, A): return NonzeroQ(A - C) cons1565 = CustomConstraint(cons_f1565) def cons_f1566(B, C, b, a, A): return NonzeroQ(A*b - B*a - C*b) cons1566 = CustomConstraint(cons_f1566) def cons_f1567(m, n): return Or(And(RationalQ(m), Less(m, S(0))), ZeroQ(m + n + S(1))) cons1567 = CustomConstraint(cons_f1567) def cons_f1568(m, n, c, a): return Not(And(IntegerQ(n), Greater(n, S(0)), Or(Not(IntegerQ(m)), And(ZeroQ(c), NonzeroQ(a))))) cons1568 = CustomConstraint(cons_f1568) def cons_f1569(n): return Not(And(RationalQ(n), LessEqual(n, S(-1)))) cons1569 = CustomConstraint(cons_f1569) def cons_f1570(p, b, d, c, a, n, x, e): if isinstance(x, (int, Integer, float, Float)): return False return FreeQ(List(a, b, c, d, e, n, p), x) cons1570 = CustomConstraint(cons_f1570) def cons_f1571(m, n): return NegativeIntegerQ(m, n) cons1571 = CustomConstraint(cons_f1571) def cons_f1572(n): return NegativeIntegerQ(n + S(1)) cons1572 = CustomConstraint(cons_f1572) def cons_f1573(n): return PositiveIntegerQ(S(1)/n) cons1573 = CustomConstraint(cons_f1573) def cons_f1574(m, n): return PositiveIntegerQ((m + S(1))/n) cons1574 = CustomConstraint(cons_f1574) def cons_f1575(m, d, c, n, x): if isinstance(x, (int, Integer, float, Float)): return False return FreeQ(List(c, d, m, n), x) cons1575 = CustomConstraint(cons_f1575) def cons_f1576(p, m, b, d, c, a, n, x): if isinstance(x, (int, Integer, float, Float)): return False return FreeQ(List(a, b, c, d, m, n, p), x) cons1576 = CustomConstraint(cons_f1576) def cons_f1577(m, n): return GreaterEqual(m - n, S(0)) cons1577 = CustomConstraint(cons_f1577) def cons_f1578(q): return SameQ(q, S(1)) cons1578 = CustomConstraint(cons_f1578) def cons_f1579(b, c, a, n, x): if isinstance(x, (int, Integer, float, Float)): return False return FreeQ(List(a, b, c, n), x) cons1579 = CustomConstraint(cons_f1579) def cons_f1580(m, b, d, c, a, n, x, e): if isinstance(x, (int, Integer, float, Float)): return False return FreeQ(List(a, b, c, d, e, m, n), x) cons1580 = CustomConstraint(cons_f1580) def cons_f1581(m, n): return ZeroQ(m + n + S(-2)) cons1581 = CustomConstraint(cons_f1581) def cons_f1582(m, n): return IntegersQ(m, n, m/S(2) + n/S(2)) cons1582 = CustomConstraint(cons_f1582) def cons_f1583(m, n): return Not(And(IntegerQ(m/S(2) + S(1)/2), Less(S(0), m, n))) cons1583 = CustomConstraint(cons_f1583) def cons_f1584(m, n): return Not(PositiveIntegerQ(m/S(2), n/S(2) + S(-1)/2)) cons1584 = CustomConstraint(cons_f1584) def cons_f1585(n): return ZeroQ(n**S(2) + S(-1)/4) cons1585 = CustomConstraint(cons_f1585) def cons_f1586(n): return LessEqual(n, S(-1)) cons1586 = CustomConstraint(cons_f1586) def cons_f1587(f, b, d, a, n, x, e): if isinstance(x, (int, Integer, float, Float)): return False return FreeQ(List(a, b, d, e, f, n), x) cons1587 = CustomConstraint(cons_f1587) def cons_f1588(d, a, b): return PositiveQ(a*d/b) cons1588 = CustomConstraint(cons_f1588) def cons_f1589(d, a, b): return Not(PositiveQ(a*d/b)) cons1589 = CustomConstraint(cons_f1589) def cons_f1590(n): return Less(n, S(-1)/2) cons1590 = CustomConstraint(cons_f1590) def cons_f1591(m, n): return Or(Less(n, S(-1)), And(Equal(m, S(3)/2), Equal(n, S(-1)/2))) cons1591 = CustomConstraint(cons_f1591) def cons_f1592(m, n): return Or(IntegersQ(S(2)*m, S(2)*n), IntegerQ(m)) cons1592 = CustomConstraint(cons_f1592) def cons_f1593(d, a, b): return NegativeQ(a*d/b) cons1593 = CustomConstraint(cons_f1593) def cons_f1594(m, n): return Or(And(IntegerQ(m), Less(n, S(-1))), And(IntegersQ(m + S(1)/2, S(2)*n), LessEqual(n, S(-1)))) cons1594 = CustomConstraint(cons_f1594) def cons_f1595(m, n): return Not(And(IntegerQ(n), Greater(n, S(2)), Not(IntegerQ(m)))) cons1595 = CustomConstraint(cons_f1595) def cons_f1596(m, n): return Or(And(IntegerQ(n), Greater(n, S(3))), And(IntegersQ(n + S(1)/2, S(2)*m), Greater(n, S(2)))) cons1596 = CustomConstraint(cons_f1596) def cons_f1597(m, n): return NegativeIntegerQ(m + S(1)/2, n) cons1597 = CustomConstraint(cons_f1597) def cons_f1598(n): return Greater(n, S(3)) cons1598 = CustomConstraint(cons_f1598) def cons_f1599(n): return IntegersQ(S(2)*n) cons1599 = CustomConstraint(cons_f1599) def cons_f1600(m): return Not(And(IntegerQ(m), Greater(m, S(2)))) cons1600 = CustomConstraint(cons_f1600) def cons_f1601(n): return Less(S(0), n, S(3)) cons1601 = CustomConstraint(cons_f1601) def cons_f1602(m): return Less(S(-1), m, S(2)) cons1602 = CustomConstraint(cons_f1602) def cons_f1603(n): return Less(S(1), n, S(3)) cons1603 = CustomConstraint(cons_f1603) def cons_f1604(m, f, b, d, a, n, x, e): if isinstance(x, (int, Integer, float, Float)): return False return FreeQ(List(a, b, d, e, f, m, n), x) cons1604 = CustomConstraint(cons_f1604) def cons_f1605(m, f, b, a, x, e): if isinstance(x, (int, Integer, float, Float)): return False return FreeQ(List(a, b, e, f, m), x) cons1605 = CustomConstraint(cons_f1605) def cons_f1606(m, a, p, b): return Or(ZeroQ(a**S(2) - b**S(2)), IntegersQ(S(2)*m, p)) cons1606 = CustomConstraint(cons_f1606) def cons_f1607(n): return IntegerQ(n + S(-1)/2) cons1607 = CustomConstraint(cons_f1607) def cons_f1608(m): return NegativeIntegerQ(m + S(1)/2) cons1608 = CustomConstraint(cons_f1608) def cons_f1609(m): return Or(IntegerQ(m/S(2)), LessEqual(m, S(1))) cons1609 = CustomConstraint(cons_f1609) def cons_f1610(m, n): return Less(m + n, S(2)) cons1610 = CustomConstraint(cons_f1610) def cons_f1611(m, n): return Not(And(IntegerQ(n), Greater(m - n, S(0)))) cons1611 = CustomConstraint(cons_f1611) def cons_f1612(n): return Greater(n, S(1)/2) cons1612 = CustomConstraint(cons_f1612) def cons_f1613(n): return Not(And(RationalQ(n), LessEqual(n, S(-1)/2))) cons1613 = CustomConstraint(cons_f1613) def cons_f1614(m, n): return MemberQ(List(S(0), S(-1), S(-2)), m + n) cons1614 = CustomConstraint(cons_f1614) def cons_f1615(m, n): return Not(And(PositiveIntegerQ(n + S(1)/2), Less(n + S(1)/2, -m - n))) cons1615 = CustomConstraint(cons_f1615) def cons_f1616(m, n): return Not(And(PositiveIntegerQ(m + S(-1)/2), Less(m, n))) cons1616 = CustomConstraint(cons_f1616) def cons_f1617(m, n): return GreaterEqual(-m + n, S(0)) cons1617 = CustomConstraint(cons_f1617) def cons_f1618(m, n): return Greater(m*n, S(0)) cons1618 = CustomConstraint(cons_f1618) def cons_f1619(m, n): return Or(NegativeIntegerQ(m, n + S(-1)/2), And(NegativeIntegerQ(m + S(-1)/2, n + S(-1)/2), Less(m, n))) cons1619 = CustomConstraint(cons_f1619) def cons_f1620(m, p): return Or(ZeroQ(p + S(-1)), IntegerQ(m + S(-1)/2)) cons1620 = CustomConstraint(cons_f1620) def cons_f1621(m, n, p): return ZeroQ(m + n + p) cons1621 = CustomConstraint(cons_f1621) def cons_f1622(m, n, p): return MemberQ(List(S(-1), S(-2)), m + n + p) cons1622 = CustomConstraint(cons_f1622) def cons_f1623(B, m, b, a, A): return ZeroQ(A*b*(m + S(1)) + B*a*m) cons1623 = CustomConstraint(cons_f1623) def cons_f1624(B, m, b, a, A): return NonzeroQ(A*b*(m + S(1)) + B*a*m) cons1624 = CustomConstraint(cons_f1624) def cons_f1625(B, A): return ZeroQ(A**S(2) - B**S(2)) cons1625 = CustomConstraint(cons_f1625) def cons_f1626(B, A): return NonzeroQ(A**S(2) - B**S(2)) cons1626 = CustomConstraint(cons_f1626) def cons_f1627(B, m, b, a, n, A): return ZeroQ(A*a*m - B*b*n) cons1627 = CustomConstraint(cons_f1627) def cons_f1628(B, b, a, n, A): return ZeroQ(A*b*(S(2)*n + S(1)) + S(2)*B*a*n) cons1628 = CustomConstraint(cons_f1628) def cons_f1629(B, b, a, n, A): return NonzeroQ(A*b*(S(2)*n + S(1)) + S(2)*B*a*n) cons1629 = CustomConstraint(cons_f1629) def cons_f1630(m, n): return Not(And(IntegerQ(n), Greater(n, S(1)), Not(IntegerQ(m)))) cons1630 = CustomConstraint(cons_f1630) def cons_f1631(m, n): return Not(NegativeIntegerQ(m + S(1)/2, n)) cons1631 = CustomConstraint(cons_f1631) def cons_f1632(m): return Not(And(IntegerQ(m), Greater(m, S(1)))) cons1632 = CustomConstraint(cons_f1632) def cons_f1633(m, C, A): return ZeroQ(A*(m + S(1)) + C*m) cons1633 = CustomConstraint(cons_f1633) def cons_f1634(m, C, A): return NonzeroQ(A*(m + S(1)) + C*m) cons1634 = CustomConstraint(cons_f1634) def cons_f1635(B, C, e, m, f, b, x, A): if isinstance(x, (int, Integer, float, Float)): return False return FreeQ(List(b, e, f, A, B, C, m), x) cons1635 = CustomConstraint(cons_f1635) def cons_f1636(B, C, e, f, b, a, x, A): if isinstance(x, (int, Integer, float, Float)): return False return FreeQ(List(a, b, e, f, A, B, C), x) cons1636 = CustomConstraint(cons_f1636) def cons_f1637(C, e, f, b, a, x, A): if isinstance(x, (int, Integer, float, Float)): return False return FreeQ(List(a, b, e, f, A, C), x) cons1637 = CustomConstraint(cons_f1637) def cons_f1638(m): return PositiveIntegerQ(S(2)*m) cons1638 = CustomConstraint(cons_f1638) def cons_f1639(m, n): return Or(And(RationalQ(n), Less(n, S(-1)/2)), ZeroQ(m + n + S(1))) cons1639 = CustomConstraint(cons_f1639) def cons_f1640(n): return Not(And(RationalQ(n), Less(n, S(-1)/2))) cons1640 = CustomConstraint(cons_f1640) def cons_f1641(B, C, m, f, b, d, a, n, A, x, e): if isinstance(x, (int, Integer, float, Float)): return False return FreeQ(List(a, b, d, e, f, A, B, C, m, n), x) cons1641 = CustomConstraint(cons_f1641) def cons_f1642(C, m, f, b, d, a, n, A, x, e): if isinstance(x, (int, Integer, float, Float)): return False return FreeQ(List(a, b, d, e, f, A, C, m, n), x) cons1642 = CustomConstraint(cons_f1642) def cons_f1643(b, d, c, n, x): if isinstance(x, (int, Integer, float, Float)): return False return FreeQ(List(b, c, d, n), x) cons1643 = CustomConstraint(cons_f1643) def cons_f1644(n): return Unequal(n, S(2)) cons1644 = CustomConstraint(cons_f1644) def cons_f1645(p): return NonzeroQ(p + S(-1)) cons1645 = CustomConstraint(cons_f1645) def cons_f1646(x, u): if isinstance(x, (int, Integer, float, Float)): return False return KnownSineIntegrandQ(u, x) cons1646 = CustomConstraint(cons_f1646) def cons_f1647(B, C, b, a, x, A): if isinstance(x, (int, Integer, float, Float)): return False return FreeQ(List(a, b, A, B, C), x) cons1647 = CustomConstraint(cons_f1647) def cons_f1648(n1, n): return ZeroQ(-n + n1 + S(-1)) cons1648 = CustomConstraint(cons_f1648) def cons_f1649(n, n2): return ZeroQ(-n + n2 + S(-2)) cons1649 = CustomConstraint(cons_f1649) def cons_f1650(x, u): if isinstance(x, (int, Integer, float, Float)): return False return KnownTangentIntegrandQ(u, x) cons1650 = CustomConstraint(cons_f1650) def cons_f1651(x, u): if isinstance(x, (int, Integer, float, Float)): return False return KnownCotangentIntegrandQ(u, x) cons1651 = CustomConstraint(cons_f1651) def cons_f1652(x, u): if isinstance(x, (int, Integer, float, Float)): return False return KnownSecantIntegrandQ(u, x) cons1652 = CustomConstraint(cons_f1652) def cons_f1653(d, b): return NonzeroQ(b**S(2) - d**S(2)) cons1653 = CustomConstraint(cons_f1653) def cons_f1654(d, b): return ZeroQ(S(-2) + d/b) cons1654 = CustomConstraint(cons_f1654) def cons_f1655(m, p): return Or(Greater(m, S(3)), Equal(p, S(-3)/2)) cons1655 = CustomConstraint(cons_f1655) def cons_f1656(m, p): return Or(Less(p, S(-2)), Equal(m, S(2))) cons1656 = CustomConstraint(cons_f1656) def cons_f1657(m, n, p): return ZeroQ(m + n + S(2)*p + S(2)) cons1657 = CustomConstraint(cons_f1657) def cons_f1658(m): return Greater(m, S(3)) cons1658 = CustomConstraint(cons_f1658) def cons_f1659(p, n): return NonzeroQ(n + p + S(1)) cons1659 = CustomConstraint(cons_f1659) def cons_f1660(m, n, p): return NonzeroQ(m + n + S(2)*p + S(2)) cons1660 = CustomConstraint(cons_f1660) def cons_f1661(m, p): return Or(Less(p, S(-2)), Equal(m, S(2)), Equal(m, S(3))) cons1661 = CustomConstraint(cons_f1661) def cons_f1662(m, n, p): return NonzeroQ(m + n + S(2)*p) cons1662 = CustomConstraint(cons_f1662) def cons_f1663(d, m, b): return ZeroQ(-Abs(m + S(2)) + d/b) cons1663 = CustomConstraint(cons_f1663) def cons_f1664(F): return InertTrigQ(F) cons1664 = CustomConstraint(cons_f1664) def cons_f1665(F, G): return InertTrigQ(F, G) cons1665 = CustomConstraint(cons_f1665) def cons_f1666(F): return Or(SameQ(F, Cos), SameQ(F, cos)) cons1666 = CustomConstraint(cons_f1666) def cons_f1667(F): return Or(SameQ(F, Sin), SameQ(F, sin)) cons1667 = CustomConstraint(cons_f1667) def cons_f1668(F): return Or(SameQ(F, Cot), SameQ(F, cot)) cons1668 = CustomConstraint(cons_f1668) def cons_f1669(F): return Or(SameQ(F, Tan), SameQ(F, tan)) cons1669 = CustomConstraint(cons_f1669) def cons_f1670(F): return Or(SameQ(F, Sec), SameQ(F, sec)) cons1670 = CustomConstraint(cons_f1670) def cons_f1671(F): return Or(SameQ(F, Csc), SameQ(F, csc)) cons1671 = CustomConstraint(cons_f1671) def cons_f1672(F): return Or(SameQ(F, sin), SameQ(F, cos)) cons1672 = CustomConstraint(cons_f1672) def cons_f1673(G): return Or(SameQ(G, sin), SameQ(G, cos)) cons1673 = CustomConstraint(cons_f1673) def cons_f1674(H): return Or(SameQ(H, sin), SameQ(H, cos)) cons1674 = CustomConstraint(cons_f1674) def cons_f1675(c, b): return ZeroQ(b - c) cons1675 = CustomConstraint(cons_f1675) def cons_f1676(c, b): return ZeroQ(b + c) cons1676 = CustomConstraint(cons_f1676) def cons_f1677(u): return Not(InertTrigFreeQ(u)) cons1677 = CustomConstraint(cons_f1677) def cons_f1678(p): return NegQ(p) cons1678 = CustomConstraint(cons_f1678) def cons_f1679(u): return TrigSimplifyQ(u) cons1679 = CustomConstraint(cons_f1679) def cons_f1680(v): return Not(InertTrigFreeQ(v)) cons1680 = CustomConstraint(cons_f1680) def cons_f1681(v, w): return Or(Not(InertTrigFreeQ(v)), Not(InertTrigFreeQ(w))) cons1681 = CustomConstraint(cons_f1681) def cons_f1682(x, u): if isinstance(x, (int, Integer, float, Float)): return False try: return Not(FalseQ(FunctionOfTrig(u, x))) except (TypeError, AttributeError): return False cons1682 = CustomConstraint(cons_f1682) def cons_f1683(p): return SameQ(p, S(1)) cons1683 = CustomConstraint(cons_f1683) def cons_f1684(p, n): return Or(EvenQ(n), OddQ(p)) cons1684 = CustomConstraint(cons_f1684) def cons_f1685(p, n): return Unequal(n, p) cons1685 = CustomConstraint(cons_f1685) def cons_f1686(F): return TrigQ(F) cons1686 = CustomConstraint(cons_f1686) def cons_f1687(G): return TrigQ(G) cons1687 = CustomConstraint(cons_f1687) def cons_f1688(v, w): return ZeroQ(v - w) cons1688 = CustomConstraint(cons_f1688) def cons_f1689(F): return MemberQ(List(Sin, Cos), F) cons1689 = CustomConstraint(cons_f1689) def cons_f1690(G): return MemberQ(List(Sec, Csc), G) cons1690 = CustomConstraint(cons_f1690) def cons_f1691(d, b): return PositiveIntegerQ(b/d + S(-1)) cons1691 = CustomConstraint(cons_f1691) def cons_f1692(c, b, F, e): return NonzeroQ(b**S(2)*c**S(2)*log(F)**S(2) + e**S(2)) cons1692 = CustomConstraint(cons_f1692) def cons_f1693(b, c, n, F, e): return NonzeroQ(b**S(2)*c**S(2)*log(F)**S(2) + e**S(2)*n**S(2)) cons1693 = CustomConstraint(cons_f1693) def cons_f1694(m, b, c, F, e): return NonzeroQ(b**S(2)*c**S(2)*log(F)**S(2) + e**S(2)*m**S(2)) cons1694 = CustomConstraint(cons_f1694) def cons_f1695(b, c, n, F, e): return ZeroQ(b**S(2)*c**S(2)*log(F)**S(2) + e**S(2)*(n + S(2))**S(2)) cons1695 = CustomConstraint(cons_f1695) def cons_f1696(b, c, n, F, e): return NonzeroQ(b**S(2)*c**S(2)*log(F)**S(2) + e**S(2)*(n + S(2))**S(2)) cons1696 = CustomConstraint(cons_f1696) def cons_f1697(b, c, n, F, e): return ZeroQ(b**S(2)*c**S(2)*log(F)**S(2) + e**S(2)*(n + S(-2))**S(2)) cons1697 = CustomConstraint(cons_f1697) def cons_f1698(b, c, n, F, e): return NonzeroQ(b**S(2)*c**S(2)*log(F)**S(2) + e**S(2)*(n + S(-2))**S(2)) cons1698 = CustomConstraint(cons_f1698) def cons_f1699(f, g): return ZeroQ(f**S(2) - g**S(2)) cons1699 = CustomConstraint(cons_f1699) def cons_f1700(f, g): return ZeroQ(f - g) cons1700 = CustomConstraint(cons_f1700) def cons_f1701(h, i): return ZeroQ(h**S(2) - i**S(2)) cons1701 = CustomConstraint(cons_f1701) def cons_f1702(h, g, f, i): return ZeroQ(-f*i + g*h) cons1702 = CustomConstraint(cons_f1702) def cons_f1703(h, g, f, i): return ZeroQ(f*i + g*h) cons1703 = CustomConstraint(cons_f1703) def cons_f1704(m, n, p): return PositiveIntegerQ(m, n, p) cons1704 = CustomConstraint(cons_f1704) def cons_f1705(H): return TrigQ(H) cons1705 = CustomConstraint(cons_f1705) def cons_f1706(x, u): if isinstance(x, (int, Integer, float, Float)): return False return Or(LinearQ(u, x), PolyQ(u, x, S(2))) cons1706 = CustomConstraint(cons_f1706) def cons_f1707(v, x): if isinstance(x, (int, Integer, float, Float)): return False return Or(LinearQ(v, x), PolyQ(v, x, S(2))) cons1707 = CustomConstraint(cons_f1707) def cons_f1708(p, n, b): return ZeroQ(b**S(2)*n**S(2)*(p + S(2))**S(2) + S(1)) cons1708 = CustomConstraint(cons_f1708) def cons_f1709(p, n, b): return ZeroQ(b**S(2)*n**S(2)*p**S(2) + S(1)) cons1709 = CustomConstraint(cons_f1709) def cons_f1710(n, b): return NonzeroQ(b**S(2)*n**S(2) + S(1)) cons1710 = CustomConstraint(cons_f1710) def cons_f1711(p, n, b): return NonzeroQ(b**S(2)*n**S(2)*p**S(2) + S(1)) cons1711 = CustomConstraint(cons_f1711) def cons_f1712(p, n, b): return NonzeroQ(b**S(2)*n**S(2)*(p + S(2))**S(2) + S(1)) cons1712 = CustomConstraint(cons_f1712) def cons_f1713(m, p, n, b): return ZeroQ(b**S(2)*n**S(2)*(p + S(2))**S(2) + (m + S(1))**S(2)) cons1713 = CustomConstraint(cons_f1713) def cons_f1714(m, p, n, b): return ZeroQ(b**S(2)*n**S(2)*p**S(2) + (m + S(1))**S(2)) cons1714 = CustomConstraint(cons_f1714) def cons_f1715(m, n, b): return NonzeroQ(b**S(2)*n**S(2) + (m + S(1))**S(2)) cons1715 = CustomConstraint(cons_f1715) def cons_f1716(m, p, n, b): return NonzeroQ(b**S(2)*n**S(2)*p**S(2) + (m + S(1))**S(2)) cons1716 = CustomConstraint(cons_f1716) def cons_f1717(m, p, n, b): return NonzeroQ(b**S(2)*n**S(2)*(p + S(2))**S(2) + (m + S(1))**S(2)) cons1717 = CustomConstraint(cons_f1717) def cons_f1718(n, b): return ZeroQ(b**S(2)*n**S(2) + S(1)) cons1718 = CustomConstraint(cons_f1718) def cons_f1719(p, n, b): return ZeroQ(b**S(2)*n**S(2)*(p + S(-2))**S(2) + S(1)) cons1719 = CustomConstraint(cons_f1719) def cons_f1720(p): return Unequal(p, S(2)) cons1720 = CustomConstraint(cons_f1720) def cons_f1721(p, n, b): return NonzeroQ(b**S(2)*n**S(2)*(p + S(-2))**S(2) + S(1)) cons1721 = CustomConstraint(cons_f1721) def cons_f1722(m, n, b): return ZeroQ(b**S(2)*n**S(2) + (m + S(1))**S(2)) cons1722 = CustomConstraint(cons_f1722) def cons_f1723(m, p, n, b): return ZeroQ(b**S(2)*n**S(2)*(p + S(-2))**S(2) + (m + S(1))**S(2)) cons1723 = CustomConstraint(cons_f1723) def cons_f1724(m, p, n, b): return NonzeroQ(b**S(2)*n**S(2)*(p + S(-2))**S(2) + (m + S(1))**S(2)) cons1724 = CustomConstraint(cons_f1724) def cons_f1725(x, u): if isinstance(x, (int, Integer, float, Float)): return False return QuotientOfLinearsQ(u, x) cons1725 = CustomConstraint(cons_f1725) def cons_f1726(v, x, w): if isinstance(x, (int, Integer, float, Float)): return False return Or(And(PolynomialQ(v, x), PolynomialQ(w, x)), And(BinomialQ(List(v, w), x), IndependentQ(v/w, x))) cons1726 = CustomConstraint(cons_f1726) def cons_f1727(m, p, q): return PositiveIntegerQ(m, p, q) cons1727 = CustomConstraint(cons_f1727) def cons_f1728(v, w): return NonzeroQ(v - w) cons1728 = CustomConstraint(cons_f1728) def cons_f1729(m, n): return Or(Equal(n, S(-1)), And(Equal(m, S(1)), Equal(n, S(-2)))) cons1729 = CustomConstraint(cons_f1729) def cons_f1730(a, c): return NonzeroQ(a + c) cons1730 = CustomConstraint(cons_f1730) def cons_f1731(a, b): return PosQ(a**S(2) - b**S(2)) cons1731 = CustomConstraint(cons_f1731) def cons_f1732(a, b): return NegQ(a**S(2) - b**S(2)) cons1732 = CustomConstraint(cons_f1732) def cons_f1733(d, b): return ZeroQ(b**S(2) - d**S(2)) cons1733 = CustomConstraint(cons_f1733) def cons_f1734(n): return Inequality(S(-2), LessEqual, n, Less, S(-1)) cons1734 = CustomConstraint(cons_f1734) def cons_f1735(n): return Less(n, S(-2)) cons1735 = CustomConstraint(cons_f1735) def cons_f1736(m, b, d, c, a, n, x): if isinstance(x, (int, Integer, float, Float)): return False return FreeQ(List(a, b, c, d, m, n), x) cons1736 = CustomConstraint(cons_f1736) def cons_f1737(d, c, e): return ZeroQ(c**S(2)*d + e) cons1737 = CustomConstraint(cons_f1737) def cons_f1738(d): return Not(PositiveQ(d)) cons1738 = CustomConstraint(cons_f1738) def cons_f1739(p): return PositiveIntegerQ(S(2)*p) cons1739 = CustomConstraint(cons_f1739) def cons_f1740(d, p): return Or(IntegerQ(p), PositiveQ(d)) cons1740 = CustomConstraint(cons_f1740) def cons_f1741(d, p): return Not(Or(IntegerQ(p), PositiveQ(d))) cons1741 = CustomConstraint(cons_f1741) def cons_f1742(d, c, e): return NonzeroQ(c**S(2)*d + e) cons1742 = CustomConstraint(cons_f1742) def cons_f1743(p): return Or(PositiveIntegerQ(p), NegativeIntegerQ(p + S(1)/2)) cons1743 = CustomConstraint(cons_f1743) def cons_f1744(p, n): return Or(Greater(p, S(0)), PositiveIntegerQ(n)) cons1744 = CustomConstraint(cons_f1744) def cons_f1745(c, f, g): return ZeroQ(c**S(2)*f**S(2) - g**S(2)) cons1745 = CustomConstraint(cons_f1745) def cons_f1746(m): return NegativeIntegerQ(m/S(2) + S(1)/2) cons1746 = CustomConstraint(cons_f1746) def cons_f1747(m, p): return Or(PositiveIntegerQ(m/S(2) + S(1)/2), NegativeIntegerQ(m/S(2) + p + S(3)/2)) cons1747 = CustomConstraint(cons_f1747) def cons_f1748(m, n): return Or(RationalQ(m), ZeroQ(n + S(-1))) cons1748 = CustomConstraint(cons_f1748) def cons_f1749(m, p, n): return Or(IntegerQ(m), IntegerQ(p), Equal(n, S(1))) cons1749 = CustomConstraint(cons_f1749) def cons_f1750(m, n): return Or(IntegerQ(m), Equal(n, S(1))) cons1750 = CustomConstraint(cons_f1750) def cons_f1751(m): return Greater(m, S(-3)) cons1751 = CustomConstraint(cons_f1751) def cons_f1752(p): return Greater(p, S(-1)) cons1752 = CustomConstraint(cons_f1752) def cons_f1753(m): return Not(PositiveIntegerQ(m/S(2) + S(1)/2)) cons1753 = CustomConstraint(cons_f1753) def cons_f1754(m): return Less(S(-3), m, S(0)) cons1754 = CustomConstraint(cons_f1754) def cons_f1755(m, p): return Or(Greater(p, S(0)), And(PositiveIntegerQ(m/S(2) + S(-1)/2), LessEqual(m + p, S(0)))) cons1755 = CustomConstraint(cons_f1755) def cons_f1756(p, m, f, b, d, c, a, n, x, e): if isinstance(x, (int, Integer, float, Float)): return False return FreeQ(List(a, b, c, d, e, f, m, n, p), x) cons1756 = CustomConstraint(cons_f1756) def cons_f1757(m, p): return Less(m + p + S(1), S(0)) cons1757 = CustomConstraint(cons_f1757) def cons_f1758(d, h, g, e): return ZeroQ(-S(2)*d*h + e*g) cons1758 = CustomConstraint(cons_f1758) def cons_f1759(m, p): return Or(Less(m, -S(2)*p + S(-1)), Greater(m, S(3))) cons1759 = CustomConstraint(cons_f1759) def cons_f1760(m, p, n): return Or(And(Equal(n, S(1)), Greater(p, S(-1))), Greater(p, S(0)), Equal(m, S(1)), And(Equal(m, S(2)), Less(p, S(-2)))) cons1760 = CustomConstraint(cons_f1760) def cons_f1761(m, n): return Or(Greater(m, S(0)), PositiveIntegerQ(n)) cons1761 = CustomConstraint(cons_f1761) def cons_f1762(B, d, c, A): return ZeroQ(S(2)*A*c*d + B*(-c**S(2) + S(1))) cons1762 = CustomConstraint(cons_f1762) def cons_f1763(B, d, c, C): return ZeroQ(-B*d + S(2)*C*c) cons1763 = CustomConstraint(cons_f1763) def cons_f1764(c): return ZeroQ(c**S(2) + S(-1)) cons1764 = CustomConstraint(cons_f1764) def cons_f1765(d, a, b, x): if isinstance(x, (int, Integer, float, Float)): return False return FreeQ(List(a, b, d), x) cons1765 = CustomConstraint(cons_f1765) def cons_f1766(m, b, c, a, n, x): if isinstance(x, (int, Integer, float, Float)): return False return FreeQ(List(a, b, c, n, m), x) cons1766 = CustomConstraint(cons_f1766) def cons_f1767(x, n, b): if isinstance(x, (int, Integer, float, Float)): return False return FreeQ(List(b, n), x) cons1767 = CustomConstraint(cons_f1767) def cons_f1768(c, b): return EqQ(b**S(2)*c, S(1)) cons1768 = CustomConstraint(cons_f1768) def cons_f1769(x, u): if isinstance(x, (int, Integer, float, Float)): return False return Not(FunctionOfExponentialQ(u, x)) cons1769 = CustomConstraint(cons_f1769) def cons_f1770(u, m, d, c, x): if isinstance(x, (int, Integer, float, Float)): return False return Not(FunctionOfQ((c + d*x)**(m + S(1)), u, x)) cons1770 = CustomConstraint(cons_f1770) def cons_f1771(v, x): if isinstance(x, (int, Integer, float, Float)): return False def _cons_f_1770(d, m, c): return FreeQ(List(c, d, m), x) _cons_1770 = CustomConstraint(_cons_f_1770) pat = Pattern(UtilityOperator((x*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1)), x), _cons_1770) result_matchq = is_match(UtilityOperator(v, x), pat) return Not(result_matchq) cons1771 = CustomConstraint(cons_f1771) def cons_f1772(v, x): if isinstance(x, (int, Integer, float, Float)): return False def _cons_f_1771(d, m, c): return FreeQ(List(c, d, m), x) _cons_1771 = CustomConstraint(_cons_f_1771) pat = Pattern(UtilityOperator((x*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1)), x), _cons_1771) result_matchq = is_match(UtilityOperator(v, x), pat) return Not(result_matchq) cons1772 = CustomConstraint(cons_f1772) def cons_f1773(d, c, e): return ZeroQ(c**S(2)*d**S(2) + e**S(2)) cons1773 = CustomConstraint(cons_f1773) def cons_f1774(d, c, e): return PositiveQ(I*c*d/e + S(1)) cons1774 = CustomConstraint(cons_f1774) def cons_f1775(d, c, e): return NegativeQ(I*c*d/e + S(-1)) cons1775 = CustomConstraint(cons_f1775) def cons_f1776(d, c, x, e): if isinstance(x, (int, Integer, float, Float)): return False return FreeQ(List(c, d, e), x) cons1776 = CustomConstraint(cons_f1776) def cons_f1777(m, a, p): return Or(Greater(p, S(0)), NonzeroQ(a), IntegerQ(m)) cons1777 = CustomConstraint(cons_f1777) def cons_f1778(d, c, e): return ZeroQ(-c**S(2)*d + e) cons1778 = CustomConstraint(cons_f1778) def cons_f1779(p): return NegativeIntegerQ(S(2)*p + S(2)) cons1779 = CustomConstraint(cons_f1779) def cons_f1780(p): return Or(IntegerQ(p), NegativeIntegerQ(p + S(1)/2)) cons1780 = CustomConstraint(cons_f1780) def cons_f1781(m, a): return Not(And(Equal(m, S(1)), NonzeroQ(a))) cons1781 = CustomConstraint(cons_f1781) def cons_f1782(p): return Unequal(p, S(-5)/2) cons1782 = CustomConstraint(cons_f1782) def cons_f1783(m, n, p): return Or(RationalQ(m), And(EqQ(n, S(1)), IntegerQ(p))) cons1783 = CustomConstraint(cons_f1783) def cons_f1784(m, n, p): return IntegersQ(m, n, S(2)*p) cons1784 = CustomConstraint(cons_f1784) def cons_f1785(m, p): return NegativeIntegerQ(m + S(2)*p + S(1)) cons1785 = CustomConstraint(cons_f1785) def cons_f1786(m, p): return Or(And(PositiveIntegerQ(p), Not(And(NegativeIntegerQ(m/S(2) + S(-1)/2), Greater(m + S(2)*p + S(3), S(0))))), And(PositiveIntegerQ(m/S(2) + S(1)/2), Not(And(NegativeIntegerQ(p), Greater(m + S(2)*p + S(3), S(0))))), And(NegativeIntegerQ(m/S(2) + p + S(1)/2), Not(NegativeIntegerQ(m/S(2) + S(-1)/2)))) cons1786 = CustomConstraint(cons_f1786) def cons_f1787(m, p): return Or(Greater(p, S(0)), And(Less(p, S(-1)), IntegerQ(m), Unequal(m, S(1)))) cons1787 = CustomConstraint(cons_f1787) def cons_f1788(p, m, b, d, c, a, x, e): if isinstance(x, (int, Integer, float, Float)): return False return FreeQ(List(a, b, c, d, e, m, p), x) cons1788 = CustomConstraint(cons_f1788) def cons_f1789(x, c, u): if isinstance(x, (int, Integer, float, Float)): return False return ZeroQ(u**S(2) - (S(1) - S(2)*I/(c*x + I))**S(2)) cons1789 = CustomConstraint(cons_f1789) def cons_f1790(x, c, u): if isinstance(x, (int, Integer, float, Float)): return False return ZeroQ(u**S(2) - (S(1) - S(2)*I/(-c*x + I))**S(2)) cons1790 = CustomConstraint(cons_f1790) def cons_f1791(x, c, u): if isinstance(x, (int, Integer, float, Float)): return False return ZeroQ(-(S(1) - S(2)*I/(c*x + I))**S(2) + (-u + S(1))**S(2)) cons1791 = CustomConstraint(cons_f1791) def cons_f1792(x, c, u): if isinstance(x, (int, Integer, float, Float)): return False return ZeroQ(-(S(1) - S(2)*I/(-c*x + I))**S(2) + (-u + S(1))**S(2)) cons1792 = CustomConstraint(cons_f1792) def cons_f1793(m, n): return Inequality(S(0), Less, n, LessEqual, m) cons1793 = CustomConstraint(cons_f1793) def cons_f1794(m, n): return Less(S(0), n, m) cons1794 = CustomConstraint(cons_f1794) def cons_f1795(d, a, n, c): return Not(And(Equal(n, S(2)), ZeroQ(-a**S(2)*c + d))) cons1795 = CustomConstraint(cons_f1795) def cons_f1796(f, b, g, d, c, a, x, e): if isinstance(x, (int, Integer, float, Float)): return False return FreeQ(List(a, b, c, d, e, f, g), x) cons1796 = CustomConstraint(cons_f1796) def cons_f1797(m): return PositiveIntegerQ(m/S(2) + S(1)/2) cons1797 = CustomConstraint(cons_f1797) def cons_f1798(f, c, g): return ZeroQ(-c**S(2)*f + g) cons1798 = CustomConstraint(cons_f1798) def cons_f1799(n): return OddQ(I*n) cons1799 = CustomConstraint(cons_f1799) def cons_f1800(n): return Not(OddQ(I*n)) cons1800 = CustomConstraint(cons_f1800) def cons_f1801(d, a, c): return ZeroQ(a**S(2)*c**S(2) + d**S(2)) cons1801 = CustomConstraint(cons_f1801) def cons_f1802(c, p): return Or(IntegerQ(p), PositiveQ(c)) cons1802 = CustomConstraint(cons_f1802) def cons_f1803(c, p): return Not(Or(IntegerQ(p), PositiveQ(c))) cons1803 = CustomConstraint(cons_f1803) def cons_f1804(d, c, a): return ZeroQ(a**S(2)*d**S(2) + c**S(2)) cons1804 = CustomConstraint(cons_f1804) def cons_f1805(n): return IntegerQ(I*n/S(2)) cons1805 = CustomConstraint(cons_f1805) def cons_f1806(d, a, c): return ZeroQ(-a**S(2)*c + d) cons1806 = CustomConstraint(cons_f1806) def cons_f1807(n): return Not(IntegerQ(I*n)) cons1807 = CustomConstraint(cons_f1807) def cons_f1808(p, n): return NonzeroQ(n**S(2) + S(4)*(p + S(1))**S(2)) cons1808 = CustomConstraint(cons_f1808) def cons_f1809(n): return IntegerQ(I*n/S(2) + S(1)/2) cons1809 = CustomConstraint(cons_f1809) def cons_f1810(p, n): return Not(IntegerQ(-I*n/S(2) + p)) cons1810 = CustomConstraint(cons_f1810) def cons_f1811(n): return PositiveIntegerQ(I*n/S(2)) cons1811 = CustomConstraint(cons_f1811) def cons_f1812(n): return NegativeIntegerQ(I*n/S(2)) cons1812 = CustomConstraint(cons_f1812) def cons_f1813(p, n): return ZeroQ(n**S(2) - S(2)*p + S(-2)) cons1813 = CustomConstraint(cons_f1813) def cons_f1814(n): return Not(IntegerQ(I*n/S(2))) cons1814 = CustomConstraint(cons_f1814) def cons_f1815(d, c, a): return ZeroQ(-a**S(2)*d + c) cons1815 = CustomConstraint(cons_f1815) def cons_f1816(n): return RationalQ(I*n) cons1816 = CustomConstraint(cons_f1816) def cons_f1817(n): return Less(S(-1), I*n, S(1)) cons1817 = CustomConstraint(cons_f1817) def cons_f1818(d, a, b, e): return ZeroQ(-S(2)*a*e + b*d) cons1818 = CustomConstraint(cons_f1818) def cons_f1819(c, b, e, a): return ZeroQ(b**S(2)*c - e*(a**S(2) + S(1))) cons1819 = CustomConstraint(cons_f1819) def cons_f1820(c, p, a): return Or(IntegerQ(p), PositiveQ(c/(a**S(2) + S(1)))) cons1820 = CustomConstraint(cons_f1820) def cons_f1821(c, p, a): return Not(Or(IntegerQ(p), PositiveQ(c/(a**S(2) + S(1))))) cons1821 = CustomConstraint(cons_f1821) def cons_f1822(p, n): return Not(And(IntegerQ(p), EvenQ(I*n))) cons1822 = CustomConstraint(cons_f1822) def cons_f1823(p, n): return Not(And(Not(IntegerQ(p)), OddQ(I*n))) cons1823 = CustomConstraint(cons_f1823) def cons_f1824(p): return LessEqual(p, S(-1)) cons1824 = CustomConstraint(cons_f1824) def cons_f1825(n): return NonzeroQ(n**S(2) + S(1)) cons1825 = CustomConstraint(cons_f1825) def cons_f1826(p, n): return NonzeroQ(n**S(2) - S(2)*p + S(-2)) cons1826 = CustomConstraint(cons_f1826) def cons_f1827(m, p): return LessEqual(S(3), m, -S(2)*p + S(-2)) cons1827 = CustomConstraint(cons_f1827) def cons_f1828(p, n): return IntegersQ(S(2)*p, I*n/S(2) + p) cons1828 = CustomConstraint(cons_f1828) def cons_f1829(p, n): return Not(IntegersQ(S(2)*p, I*n/S(2) + p)) cons1829 = CustomConstraint(cons_f1829) def cons_f1830(B, d, c, A): return ZeroQ(-S(2)*A*c*d + B*(c**S(2) + S(1))) cons1830 = CustomConstraint(cons_f1830) def cons_f1831(x, a, n, b): if isinstance(x, (int, Integer, float, Float)): return False return FreeQ(List(a, b, n), x) cons1831 = CustomConstraint(cons_f1831) def cons_f1832(m): return Unequal(m + S(1), S(0)) cons1832 = CustomConstraint(cons_f1832) def cons_f1833(m, n): return Unequal(m + S(1), n) cons1833 = CustomConstraint(cons_f1833) def cons_f1834(f, b, d, c, a, x): if isinstance(x, (int, Integer, float, Float)): return False return FreeQ(List(a, b, c, d, f), x) cons1834 = CustomConstraint(cons_f1834) def cons_f1835(c, b): return ZeroQ(b + c**S(2)) cons1835 = CustomConstraint(cons_f1835) def cons_f1836(s): return ZeroQ(s**S(2) + S(-1)) cons1836 = CustomConstraint(cons_f1836) def cons_f1837(v, w): return ZeroQ(-v**S(2) + w + S(-1)) cons1837 = CustomConstraint(cons_f1837) def cons_f1838(v, x): if isinstance(x, (int, Integer, float, Float)): return False return NegQ(Discriminant(v, x)) cons1838 = CustomConstraint(cons_f1838) def cons_f1839(x, u): if isinstance(x, (int, Integer, float, Float)): return False def _cons_f_1838(w, f, r): return FreeQ(f, x) _cons_1838 = CustomConstraint(_cons_f_1838) pat = Pattern(UtilityOperator(f_**w_*WC('r', S(1)), x), _cons_1838) result_matchq = is_match(UtilityOperator(u, x), pat) return result_matchq cons1839 = CustomConstraint(cons_f1839) def cons_f1840(x, u): if isinstance(x, (int, Integer, float, Float)): return False def _cons_f_1839(w, f, r): return FreeQ(f, x) _cons_1839 = CustomConstraint(_cons_f_1839) pat = Pattern(UtilityOperator(f_**w_*WC('r', S(1)), x), _cons_1839) result_matchq = is_match(UtilityOperator(u, x), pat) return result_matchq cons1840 = CustomConstraint(cons_f1840) def cons_f1841(d, c): return ZeroQ((c + I*d)**S(2) + S(1)) cons1841 = CustomConstraint(cons_f1841) def cons_f1842(d, c): return ZeroQ((c - I*d)**S(2) + S(1)) cons1842 = CustomConstraint(cons_f1842) def cons_f1843(d, c): return NonzeroQ((c + I*d)**S(2) + S(1)) cons1843 = CustomConstraint(cons_f1843) def cons_f1844(d, c): return NonzeroQ((c - I*d)**S(2) + S(1)) cons1844 = CustomConstraint(cons_f1844) def cons_f1845(d, c): return ZeroQ((c - d)**S(2) + S(1)) cons1845 = CustomConstraint(cons_f1845) def cons_f1846(d, c): return NonzeroQ((c - d)**S(2) + S(1)) cons1846 = CustomConstraint(cons_f1846) def cons_f1847(x, m, u): if isinstance(x, (int, Integer, float, Float)): return False try: return FalseQ(PowerVariableExpn(u, m + S(1), x)) except (TypeError, AttributeError): return False cons1847 = CustomConstraint(cons_f1847) def cons_f1848(v, x): if isinstance(x, (int, Integer, float, Float)): return False def _cons_f_1847(d, m, c): return FreeQ(List(c, d, m), x) _cons_1847 = CustomConstraint(_cons_f_1847) pat = Pattern(UtilityOperator((x*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1)), x), _cons_1847) result_matchq = is_match(UtilityOperator(v, x), pat) return Not(result_matchq) cons1848 = CustomConstraint(cons_f1848) def cons_f1849(v, u, b, a, x): if isinstance(x, (int, Integer, float, Float)): return False try: return FalseQ(FunctionOfLinear(v*(a + b*ArcTan(u)), x)) except (TypeError, AttributeError): return False cons1849 = CustomConstraint(cons_f1849) def cons_f1850(v, x): if isinstance(x, (int, Integer, float, Float)): return False def _cons_f_1849(d, m, c): return FreeQ(List(c, d, m), x) _cons_1849 = CustomConstraint(_cons_f_1849) pat = Pattern(UtilityOperator((x*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1)), x), _cons_1849) result_matchq = is_match(UtilityOperator(v, x), pat) return Not(result_matchq) cons1850 = CustomConstraint(cons_f1850) def cons_f1851(v, u, b, a, x): if isinstance(x, (int, Integer, float, Float)): return False try: return FalseQ(FunctionOfLinear(v*(a + b*acot(u)), x)) except (TypeError, AttributeError): return False cons1851 = CustomConstraint(cons_f1851) def cons_f1852(v, a, b, x): if isinstance(x, (int, Integer, float, Float)): return False return ZeroQ(D(v/(a + b*x), x)) cons1852 = CustomConstraint(cons_f1852) def cons_f1853(x, w, b, a): if isinstance(x, (int, Integer, float, Float)): return False return ZeroQ(D(w/(a + b*x), x)) cons1853 = CustomConstraint(cons_f1853) def cons_f1854(m, b, c, a, n, x): if isinstance(x, (int, Integer, float, Float)): return False return FreeQ(List(a, b, c, m, n), x) cons1854 = CustomConstraint(cons_f1854) def cons_f1855(d): return Negative(d) cons1855 = CustomConstraint(cons_f1855) def cons_f1856(d, e): return Not(And(PositiveQ(e), Negative(d))) cons1856 = CustomConstraint(cons_f1856) def cons_f1857(v, x): if isinstance(x, (int, Integer, float, Float)): return False def _cons_f_1856(d, m, c): return FreeQ(List(c, d, m), x) _cons_1856 = CustomConstraint(_cons_f_1856) pat = Pattern(UtilityOperator((x*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1)), x), _cons_1856) result_matchq = is_match(UtilityOperator(v, x), pat) return Not(result_matchq) cons1857 = CustomConstraint(cons_f1857) def cons_f1858(v, x): if isinstance(x, (int, Integer, float, Float)): return False def _cons_f_1857(d, m, c): return FreeQ(List(c, d, m), x) _cons_1857 = CustomConstraint(_cons_f_1857) pat = Pattern(UtilityOperator((x*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1)), x), _cons_1857) result_matchq = is_match(UtilityOperator(v, x), pat) return Not(result_matchq) cons1858 = CustomConstraint(cons_f1858) def cons_f1859(m, n, b, a): return Or(Equal(n, S(1)), PositiveIntegerQ(m), NonzeroQ(a**S(2) + b**S(2))) cons1859 = CustomConstraint(cons_f1859) def cons_f1860(F): return HyperbolicQ(F) cons1860 = CustomConstraint(cons_f1860) def cons_f1861(G): return HyperbolicQ(G) cons1861 = CustomConstraint(cons_f1861) def cons_f1862(F): return MemberQ(List(Sinh, Cosh), F) cons1862 = CustomConstraint(cons_f1862) def cons_f1863(G): return MemberQ(List(Sech, Csch), G) cons1863 = CustomConstraint(cons_f1863) def cons_f1864(c, b, F, e): return NonzeroQ(-b**S(2)*c**S(2)*log(F)**S(2) + e**S(2)) cons1864 = CustomConstraint(cons_f1864) def cons_f1865(b, c, n, F, e): return NonzeroQ(-b**S(2)*c**S(2)*log(F)**S(2) + e**S(2)*n**S(2)) cons1865 = CustomConstraint(cons_f1865) def cons_f1866(b, c, n, F, e): return ZeroQ(-b**S(2)*c**S(2)*log(F)**S(2) + e**S(2)*(n + S(2))**S(2)) cons1866 = CustomConstraint(cons_f1866) def cons_f1867(b, c, n, F, e): return NonzeroQ(-b**S(2)*c**S(2)*log(F)**S(2) + e**S(2)*(n + S(2))**S(2)) cons1867 = CustomConstraint(cons_f1867) def cons_f1868(b, c, n, F, e): return ZeroQ(-b**S(2)*c**S(2)*log(F)**S(2) + e**S(2)*(n + S(-2))**S(2)) cons1868 = CustomConstraint(cons_f1868) def cons_f1869(b, c, n, F, e): return NonzeroQ(-b**S(2)*c**S(2)*log(F)**S(2) + e**S(2)*(n + S(-2))**S(2)) cons1869 = CustomConstraint(cons_f1869) def cons_f1870(f, g): return ZeroQ(f**S(2) + g**S(2)) cons1870 = CustomConstraint(cons_f1870) def cons_f1871(h, i): return ZeroQ(h**S(2) + i**S(2)) cons1871 = CustomConstraint(cons_f1871) def cons_f1872(H): return HyperbolicQ(H) cons1872 = CustomConstraint(cons_f1872) def cons_f1873(p, n, b): return RationalQ(b, n, p) cons1873 = CustomConstraint(cons_f1873) def cons_f1874(p, n, b): return ZeroQ(b**S(2)*n**S(2)*(p + S(2))**S(2) + S(-1)) cons1874 = CustomConstraint(cons_f1874) def cons_f1875(n, b): return ZeroQ(b*n + S(-2)) cons1875 = CustomConstraint(cons_f1875) def cons_f1876(p, n, b): return ZeroQ(b**S(2)*n**S(2)*p**S(2) + S(-1)) cons1876 = CustomConstraint(cons_f1876) def cons_f1877(n, b): return NonzeroQ(b**S(2)*n**S(2) + S(-1)) cons1877 = CustomConstraint(cons_f1877) def cons_f1878(p, n, b): return NonzeroQ(b**S(2)*n**S(2)*p**S(2) + S(-1)) cons1878 = CustomConstraint(cons_f1878) def cons_f1879(p, n, b): return NonzeroQ(b**S(2)*n**S(2)*(p + S(2))**S(2) + S(-1)) cons1879 = CustomConstraint(cons_f1879) def cons_f1880(m, p, n, b): return ZeroQ(b**S(2)*n**S(2)*(p + S(2))**S(2) - (m + S(1))**S(2)) cons1880 = CustomConstraint(cons_f1880) def cons_f1881(m, p, n, b): return ZeroQ(b**S(2)*n**S(2)*p**S(2) - (m + S(1))**S(2)) cons1881 = CustomConstraint(cons_f1881) def cons_f1882(m, n, b): return NonzeroQ(b**S(2)*n**S(2) - (m + S(1))**S(2)) cons1882 = CustomConstraint(cons_f1882) def cons_f1883(m, p, n, b): return NonzeroQ(b**S(2)*n**S(2)*p**S(2) - (m + S(1))**S(2)) cons1883 = CustomConstraint(cons_f1883) def cons_f1884(m, p, n, b): return NonzeroQ(b**S(2)*n**S(2)*(p + S(2))**S(2) - (m + S(1))**S(2)) cons1884 = CustomConstraint(cons_f1884) def cons_f1885(n, b): return ZeroQ(b**S(2)*n**S(2) + S(-1)) cons1885 = CustomConstraint(cons_f1885) def cons_f1886(p, n, b): return ZeroQ(b**S(2)*n**S(2)*(p + S(-2))**S(2) + S(-1)) cons1886 = CustomConstraint(cons_f1886) def cons_f1887(p, n, b): return NonzeroQ(b**S(2)*n**S(2)*(p + S(-2))**S(2) + S(-1)) cons1887 = CustomConstraint(cons_f1887) def cons_f1888(p, m, n, b): return RationalQ(b, m, n, p) cons1888 = CustomConstraint(cons_f1888) def cons_f1889(m, n, b): return ZeroQ(b**S(2)*n**S(2) - (m + S(1))**S(2)) cons1889 = CustomConstraint(cons_f1889) def cons_f1890(m, p, n, b): return NonzeroQ(b**S(2)*n**S(2)*(p + S(-2))**S(2) - (m + S(1))**S(2)) cons1890 = CustomConstraint(cons_f1890) def cons_f1891(B, a, b, A): return ZeroQ(A*a + B*b) cons1891 = CustomConstraint(cons_f1891) def cons_f1892(c, d1, e1): return ZeroQ(-c*d1 + e1) cons1892 = CustomConstraint(cons_f1892) def cons_f1893(e2, c, d2): return ZeroQ(c*d2 + e2) cons1893 = CustomConstraint(cons_f1893) def cons_f1894(d1): return PositiveQ(d1) cons1894 = CustomConstraint(cons_f1894) def cons_f1895(d2): return NegativeQ(d2) cons1895 = CustomConstraint(cons_f1895) def cons_f1896(d2, d1): return Not(And(PositiveQ(d1), NegativeQ(d2))) cons1896 = CustomConstraint(cons_f1896) def cons_f1897(d2, d1): return And(PositiveQ(d1), NegativeQ(d2)) cons1897 = CustomConstraint(cons_f1897) def cons_f1898(d, c, e): return NonzeroQ(-c**S(2)*d + e) cons1898 = CustomConstraint(cons_f1898) def cons_f1899(d2, p, b, e2, c, a, n, d1, e1, x): if isinstance(x, (int, Integer, float, Float)): return False return FreeQ(List(a, b, c, d1, e1, d2, e2, n, p), x) cons1899 = CustomConstraint(cons_f1899) def cons_f1900(c, f, g): return ZeroQ(c**S(2)*f**S(2) + g**S(2)) cons1900 = CustomConstraint(cons_f1900) def cons_f1901(p, d1, d2): return Not(Or(IntegerQ(p), And(PositiveQ(d1), NegativeQ(d2)))) cons1901 = CustomConstraint(cons_f1901) def cons_f1902(m): return NonzeroQ(m + S(3)) cons1902 = CustomConstraint(cons_f1902) def cons_f1903(d2, p, m, f, b, e2, c, a, n, d1, e1, x): if isinstance(x, (int, Integer, float, Float)): return False return FreeQ(List(a, b, c, d1, e1, d2, e2, f, m, n, p), x) cons1903 = CustomConstraint(cons_f1903) def cons_f1904(c): return ZeroQ(c**S(2) + S(1)) cons1904 = CustomConstraint(cons_f1904) def cons_f1905(v, x): if isinstance(x, (int, Integer, float, Float)): return False def _cons_f_1904(d, m, c): return FreeQ(List(c, d, m), x) _cons_1904 = CustomConstraint(_cons_f_1904) pat = Pattern(UtilityOperator((x*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1)), x), _cons_1904) result_matchq = is_match(UtilityOperator(v, x), pat) return Not(result_matchq) cons1905 = CustomConstraint(cons_f1905) def cons_f1906(v, x): if isinstance(x, (int, Integer, float, Float)): return False def _cons_f_1905(d, m, c): return FreeQ(List(c, d, m), x) _cons_1905 = CustomConstraint(_cons_f_1905) pat = Pattern(UtilityOperator((x*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1)), x), _cons_1905) result_matchq = is_match(UtilityOperator(v, x), pat) return Not(result_matchq) cons1906 = CustomConstraint(cons_f1906) def cons_f1907(d, c, e): return ZeroQ(c**S(2)*d**S(2) - e**S(2)) cons1907 = CustomConstraint(cons_f1907) def cons_f1908(d, c, e): return PositiveQ(c*d/e + S(1)) cons1908 = CustomConstraint(cons_f1908) def cons_f1909(d, c, e): return NegativeQ(c*d/e + S(-1)) cons1909 = CustomConstraint(cons_f1909) def cons_f1910(x, c, u): if isinstance(x, (int, Integer, float, Float)): return False return ZeroQ(u**S(2) - (S(1) - S(2)/(c*x + S(1)))**S(2)) cons1910 = CustomConstraint(cons_f1910) def cons_f1911(x, c, u): if isinstance(x, (int, Integer, float, Float)): return False return ZeroQ(u**S(2) - (S(1) - S(2)/(-c*x + S(1)))**S(2)) cons1911 = CustomConstraint(cons_f1911) def cons_f1912(x, c, u): if isinstance(x, (int, Integer, float, Float)): return False return ZeroQ(-(S(1) - S(2)/(c*x + S(1)))**S(2) + (-u + S(1))**S(2)) cons1912 = CustomConstraint(cons_f1912) def cons_f1913(x, c, u): if isinstance(x, (int, Integer, float, Float)): return False return ZeroQ(-(S(1) - S(2)/(-c*x + S(1)))**S(2) + (-u + S(1))**S(2)) cons1913 = CustomConstraint(cons_f1913) def cons_f1914(d, a, n, c): return Not(And(Equal(n, S(2)), ZeroQ(a**S(2)*c + d))) cons1914 = CustomConstraint(cons_f1914) def cons_f1915(c, f, g): return ZeroQ(c**S(2)*f + g) cons1915 = CustomConstraint(cons_f1915) def cons_f1916(d, a, c): return ZeroQ(a*c + d) cons1916 = CustomConstraint(cons_f1916) def cons_f1917(p, n): return Or(IntegerQ(p), ZeroQ(-n/S(2) + p), ZeroQ(-n/S(2) + p + S(-1))) cons1917 = CustomConstraint(cons_f1917) def cons_f1918(d, a, c): return ZeroQ(a**S(2)*c**S(2) - d**S(2)) cons1918 = CustomConstraint(cons_f1918) def cons_f1919(d, c, a): return ZeroQ(-a**S(2)*d**S(2) + c**S(2)) cons1919 = CustomConstraint(cons_f1919) def cons_f1920(d, a, c): return ZeroQ(a**S(2)*c + d) cons1920 = CustomConstraint(cons_f1920) def cons_f1921(p, n): return NonzeroQ(n**S(2) - S(4)*(p + S(1))**S(2)) cons1921 = CustomConstraint(cons_f1921) def cons_f1922(n): return Not(IntegerQ(n/S(2))) cons1922 = CustomConstraint(cons_f1922) def cons_f1923(n): return PositiveIntegerQ(n/S(2) + S(1)/2) cons1923 = CustomConstraint(cons_f1923) def cons_f1924(p, n): return Not(IntegerQ(-n/S(2) + p)) cons1924 = CustomConstraint(cons_f1924) def cons_f1925(n): return NegativeIntegerQ(n/S(2) + S(-1)/2) cons1925 = CustomConstraint(cons_f1925) def cons_f1926(n): return NegativeIntegerQ(n/S(2)) cons1926 = CustomConstraint(cons_f1926) def cons_f1927(p, n): return ZeroQ(n**S(2) + S(2)*p + S(2)) cons1927 = CustomConstraint(cons_f1927) def cons_f1928(d, c, a): return ZeroQ(a**S(2)*d + c) cons1928 = CustomConstraint(cons_f1928) def cons_f1929(c, b, e, a): return ZeroQ(b**S(2)*c + e*(-a**S(2) + S(1))) cons1929 = CustomConstraint(cons_f1929) def cons_f1930(c, p, a): return Or(IntegerQ(p), PositiveQ(c/(-a**S(2) + S(1)))) cons1930 = CustomConstraint(cons_f1930) def cons_f1931(c, p, a): return Not(Or(IntegerQ(p), PositiveQ(c/(-a**S(2) + S(1))))) cons1931 = CustomConstraint(cons_f1931) def cons_f1932(p, n): return ZeroQ(-n/S(2) + p) cons1932 = CustomConstraint(cons_f1932) def cons_f1933(d, c, a): return ZeroQ(a*d + c) cons1933 = CustomConstraint(cons_f1933) def cons_f1934(m, p, n): return Or(IntegerQ(p), ZeroQ(-n/S(2) + p), ZeroQ(-n/S(2) + p + S(-1)), Less(S(-5), m, S(-1))) cons1934 = CustomConstraint(cons_f1934) def cons_f1935(p, n): return Or(IntegerQ(p), Not(IntegerQ(n))) cons1935 = CustomConstraint(cons_f1935) def cons_f1936(p, n): return NonzeroQ(n**S(2) + S(2)*p + S(2)) cons1936 = CustomConstraint(cons_f1936) def cons_f1937(p, n): return IntegersQ(S(2)*p, n/S(2) + p) cons1937 = CustomConstraint(cons_f1937) def cons_f1938(p, n): return Not(IntegersQ(S(2)*p, n/S(2) + p)) cons1938 = CustomConstraint(cons_f1938) def cons_f1939(c, b): return ZeroQ(b - c**S(2)) cons1939 = CustomConstraint(cons_f1939) def cons_f1940(v, x): if isinstance(x, (int, Integer, float, Float)): return False return PosQ(Discriminant(v, x)) cons1940 = CustomConstraint(cons_f1940) def cons_f1941(x, u): if isinstance(x, (int, Integer, float, Float)): return False def _cons_f_1940(w, f, r): return FreeQ(f, x) _cons_1940 = CustomConstraint(_cons_f_1940) pat = Pattern(UtilityOperator(f_**w_*WC('r', S(1)), x), _cons_1940) result_matchq = is_match(UtilityOperator(u, x), pat) return result_matchq cons1941 = CustomConstraint(cons_f1941) def cons_f1942(x, u): if isinstance(x, (int, Integer, float, Float)): return False def _cons_f_1941(w, f, r): return FreeQ(f, x) _cons_1941 = CustomConstraint(_cons_f_1941) pat = Pattern(UtilityOperator(f_**w_*WC('r', S(1)), x), _cons_1941) result_matchq = is_match(UtilityOperator(u, x), pat) return result_matchq cons1942 = CustomConstraint(cons_f1942) def cons_f1943(d, c): return ZeroQ((c - d)**S(2) + S(-1)) cons1943 = CustomConstraint(cons_f1943) def cons_f1944(d, c): return NonzeroQ((c - d)**S(2) + S(-1)) cons1944 = CustomConstraint(cons_f1944) def cons_f1945(d, c): return ZeroQ((c + I*d)**S(2) + S(-1)) cons1945 = CustomConstraint(cons_f1945) def cons_f1946(d, c): return ZeroQ((c - I*d)**S(2) + S(-1)) cons1946 = CustomConstraint(cons_f1946) def cons_f1947(d, c): return NonzeroQ((c + I*d)**S(2) + S(-1)) cons1947 = CustomConstraint(cons_f1947) def cons_f1948(d, c): return NonzeroQ((c - I*d)**S(2) + S(-1)) cons1948 = CustomConstraint(cons_f1948) def cons_f1949(v, x): if isinstance(x, (int, Integer, float, Float)): return False def _cons_f_1948(d, m, c): return FreeQ(List(c, d, m), x) _cons_1948 = CustomConstraint(_cons_f_1948) pat = Pattern(UtilityOperator((x*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1)), x), _cons_1948) result_matchq = is_match(UtilityOperator(v, x), pat) return Not(result_matchq) cons1949 = CustomConstraint(cons_f1949) def cons_f1950(v, u, b, a, x): if isinstance(x, (int, Integer, float, Float)): return False try: return FalseQ(FunctionOfLinear(v*(a + b*atanh(u)), x)) except (TypeError, AttributeError): return False cons1950 = CustomConstraint(cons_f1950) def cons_f1951(v, x): if isinstance(x, (int, Integer, float, Float)): return False def _cons_f_1950(d, m, c): return FreeQ(List(c, d, m), x) _cons_1950 = CustomConstraint(_cons_f_1950) pat = Pattern(UtilityOperator((x*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1)), x), _cons_1950) result_matchq = is_match(UtilityOperator(v, x), pat) return Not(result_matchq) cons1951 = CustomConstraint(cons_f1951) def cons_f1952(v, u, b, a, x): if isinstance(x, (int, Integer, float, Float)): return False try: return FalseQ(FunctionOfLinear(v*(a + b*acoth(u)), x)) except (TypeError, AttributeError): return False cons1952 = CustomConstraint(cons_f1952) def cons_f1953(x, a, p): if isinstance(x, (int, Integer, float, Float)): return False return FreeQ(List(a, p), x) cons1953 = CustomConstraint(cons_f1953) def cons_f1954(x, m, a, p): if isinstance(x, (int, Integer, float, Float)): return False return FreeQ(List(a, m, p), x) cons1954 = CustomConstraint(cons_f1954) def cons_f1955(v, x): if isinstance(x, (int, Integer, float, Float)): return False def _cons_f_1954(d, m, c): return FreeQ(List(c, d, m), x) _cons_1954 = CustomConstraint(_cons_f_1954) pat = Pattern(UtilityOperator((x*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1)), x), _cons_1954) result_matchq = is_match(UtilityOperator(v, x), pat) return Not(result_matchq) cons1955 = CustomConstraint(cons_f1955) def cons_f1956(v, x): if isinstance(x, (int, Integer, float, Float)): return False def _cons_f_1955(d, m, c): return FreeQ(List(c, d, m), x) _cons_1955 = CustomConstraint(_cons_f_1955) pat = Pattern(UtilityOperator((x*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1)), x), _cons_1955) result_matchq = is_match(UtilityOperator(v, x), pat) return Not(result_matchq) cons1956 = CustomConstraint(cons_f1956) def cons_f1957(d, b): return ZeroQ(-b**S(2) + d) cons1957 = CustomConstraint(cons_f1957) def cons_f1958(d, b): return ZeroQ(b**S(2) + d) cons1958 = CustomConstraint(cons_f1958) def cons_f1959(m): return Or(Greater(m, S(0)), OddQ(m)) cons1959 = CustomConstraint(cons_f1959) def cons_f1960(m): return Or(And(Greater(m, S(0)), EvenQ(m)), Equal(Mod(m, S(4)), S(3))) cons1960 = CustomConstraint(cons_f1960) def cons_f1961(c, b): return ZeroQ(-Pi*b**S(2)/S(2) + c) cons1961 = CustomConstraint(cons_f1961) def cons_f1962(m): return Not(Equal(Mod(m, S(4)), S(2))) cons1962 = CustomConstraint(cons_f1962) def cons_f1963(m): return Equal(Mod(m, S(4)), S(0)) cons1963 = CustomConstraint(cons_f1963) def cons_f1964(m): return Not(Equal(Mod(m, S(4)), S(0))) cons1964 = CustomConstraint(cons_f1964) def cons_f1965(m): return Equal(Mod(m, S(4)), S(2)) cons1965 = CustomConstraint(cons_f1965) def cons_f1966(m, n): return Or(PositiveIntegerQ(m), NegativeIntegerQ(n), And(RationalQ(m, n), Greater(m, S(0)), Less(n, S(-1)))) cons1966 = CustomConstraint(cons_f1966) def cons_f1967(m, n): return Or(PositiveIntegerQ(n), And(RationalQ(m, n), Less(m, S(-1)), Greater(n, S(0)))) cons1967 = CustomConstraint(cons_f1967) def cons_f1968(n): return Not(And(IntegerQ(n), LessEqual(n, S(0)))) cons1968 = CustomConstraint(cons_f1968) def cons_f1969(m, n): return Or(PositiveIntegerQ(m), PositiveIntegerQ(n), IntegersQ(m, n)) cons1969 = CustomConstraint(cons_f1969) def cons_f1970(a, c): return ZeroQ(a - c + S(1)) cons1970 = CustomConstraint(cons_f1970) def cons_f1971(s): return NonzeroQ(s + S(-1)) cons1971 = CustomConstraint(cons_f1971) def cons_f1972(s): return NonzeroQ(s + S(-2)) cons1972 = CustomConstraint(cons_f1972) def cons_f1973(p, b, a, n, x, q): if isinstance(x, (int, Integer, float, Float)): return False return FreeQ(List(a, b, n, p, q), x) cons1973 = CustomConstraint(cons_f1973) def cons_f1974(r): return RationalQ(r) cons1974 = CustomConstraint(cons_f1974) def cons_f1975(r): return Greater(r, S(0)) cons1975 = CustomConstraint(cons_f1975) def cons_f1976(p, b, d, c, a, n, x, F): if isinstance(x, (int, Integer, float, Float)): return False return FreeQ(List(F, a, b, c, d, n, p), x) cons1976 = CustomConstraint(cons_f1976) def cons_f1977(p, n): return Or(ZeroQ(n*(p + S(-1)) + S(1)), And(IntegerQ(p + S(-1)/2), ZeroQ(n*(p + S(-1)/2) + S(1)))) cons1977 = CustomConstraint(cons_f1977) def cons_f1978(p, n): return Or(And(IntegerQ(p), ZeroQ(n*(p + S(1)) + S(1))), And(IntegerQ(p + S(-1)/2), ZeroQ(n*(p + S(1)/2) + S(1)))) cons1978 = CustomConstraint(cons_f1978) def cons_f1979(m, p, n): return Or(And(IntegerQ(p + S(-1)/2), IntegerQ(S(2)*(m + n*p + S(1))/n), Greater((m + n*p + S(1))/n, S(0))), And(Not(IntegerQ(p + S(-1)/2)), IntegerQ((m + n*p + S(1))/n), GreaterEqual((m + n*p + S(1))/n, S(0)))) cons1979 = CustomConstraint(cons_f1979) def cons_f1980(m, p, n): return Or(ZeroQ(m + S(1)), And(IntegerQ(p + S(-1)/2), IntegerQ(S(-1)/2 + (m + n*p + S(1))/n), Less((m + n*p + S(1))/n, S(0))), And(Not(IntegerQ(p + S(-1)/2)), IntegerQ((m + n*p + S(1))/n), Less((m + n*p + S(1))/n, S(0)))) cons1980 = CustomConstraint(cons_f1980) def cons_f1981(x, m, a, c): if isinstance(x, (int, Integer, float, Float)): return False return FreeQ(List(a, c, m), x) cons1981 = CustomConstraint(cons_f1981) def cons_f1982(p, b, d, c, a, x): if isinstance(x, (int, Integer, float, Float)): return False return FreeQ(List(a, b, c, d, p), x) cons1982 = CustomConstraint(cons_f1982) def cons_f1983(p, n): return ZeroQ(n*(p + S(-1)) + S(1)) cons1983 = CustomConstraint(cons_f1983) def cons_f1984(p, n): return ZeroQ(p + S(1)/n) cons1984 = CustomConstraint(cons_f1984) def cons_f1985(p, n): return ZeroQ(p + S(-1)/2 + S(1)/n) cons1985 = CustomConstraint(cons_f1985) def cons_f1986(c, n): return PosQ(c*n) cons1986 = CustomConstraint(cons_f1986) def cons_f1987(c, n): return NegQ(c*n) cons1987 = CustomConstraint(cons_f1987) def cons_f1988(p, n): return Greater(n*(p + S(-1)) + S(1), S(0)) cons1988 = CustomConstraint(cons_f1988) def cons_f1989(p, n): return Less(n*p + S(1), S(0)) cons1989 = CustomConstraint(cons_f1989) def cons_f1990(d, a, x): if isinstance(x, (int, Integer, float, Float)): return False return FreeQ(List(a, d), x) cons1990 = CustomConstraint(cons_f1990) def cons_f1991(d, a, n, x): if isinstance(x, (int, Integer, float, Float)): return False return FreeQ(List(a, d, n), x) cons1991 = CustomConstraint(cons_f1991) def cons_f1992(p, d, a, n, c, x): if isinstance(x, (int, Integer, float, Float)): return False return FreeQ(List(a, c, d, n, p), x) cons1992 = CustomConstraint(cons_f1992) def cons_f1993(m, n, p): return ZeroQ(m + n*(p + S(-1)) + S(1)) cons1993 = CustomConstraint(cons_f1993) def cons_f1994(m, n, p): return ZeroQ(m + n*p + S(1)) cons1994 = CustomConstraint(cons_f1994) def cons_f1995(m, n, p): return ZeroQ(m + n*(p + S(-1)/2) + S(1)) cons1995 = CustomConstraint(cons_f1995) def cons_f1996(c, p): return PosQ(c/(p + S(-1)/2)) cons1996 = CustomConstraint(cons_f1996) def cons_f1997(c, p): return NegQ(c/(p + S(-1)/2)) cons1997 = CustomConstraint(cons_f1997) def cons_f1998(m, p, n): return RationalQ((m + n*p + S(1))/n) cons1998 = CustomConstraint(cons_f1998) def cons_f1999(m, p, n): return Greater((m + n*p + S(1))/n, S(1)) cons1999 = CustomConstraint(cons_f1999) def cons_f2000(m, p, n): return Less((m + n*p + S(1))/n, S(0)) cons2000 = CustomConstraint(cons_f2000) def cons_f2001(x, u): if isinstance(x, (int, Integer, float, Float)): return False return FunctionOfQ(ProductLog(x), u, x) cons2001 = CustomConstraint(cons_f2001) def cons_f2002(x, n, u): if isinstance(x, (int, Integer, float, Float)): return False def _cons_f_2001(v, n1): return ZeroQ(n - n1 - 1) _cons_2001 = CustomConstraint(_cons_f_2001) pat = Pattern(UtilityOperator(x**WC('n1', S(1))*WC('v', S(1)), x), _cons_2001) result_matchq = is_match(UtilityOperator(u, x), pat) return Not(result_matchq) cons2002 = CustomConstraint(cons_f2002) def cons_f2003(g, e): return ZeroQ(e + g) cons2003 = CustomConstraint(cons_f2003) def cons_f2004(d, f): return ZeroQ(d + f + S(-2)) cons2004 = CustomConstraint(cons_f2004) def cons_f2005(C, f, d, A, e): return ZeroQ(A*e**S(2) + C*d*f) cons2005 = CustomConstraint(cons_f2005) def cons_f2006(d, B, C, e): return ZeroQ(-B*e + S(2)*C*(d + S(-1))) cons2006 = CustomConstraint(cons_f2006) def cons_f2007(C, e, A): return ZeroQ(A*e**S(2) + C) cons2007 = CustomConstraint(cons_f2007) def cons_f2008(n): return Not(PositiveQ(n)) cons2008 = CustomConstraint(cons_f2008) def cons_f2009(v, y): return ZeroQ(-v + y) cons2009 = CustomConstraint(cons_f2009) def cons_f2010(w, y): return ZeroQ(-w + y) cons2010 = CustomConstraint(cons_f2010) def cons_f2011(z, y): return ZeroQ(y - z) cons2011 = CustomConstraint(cons_f2011) def cons_f2012(p, m, b, a, n, x): if isinstance(x, (int, Integer, float, Float)): return False return FreeQ(List(a, b, m, n, p), x) cons2012 = CustomConstraint(cons_f2012) def cons_f2013(v, w): return ZeroQ(-v + w) cons2013 = CustomConstraint(cons_f2013) def cons_f2014(r, p, q): return ZeroQ(p - q*(r + S(1))) cons2014 = CustomConstraint(cons_f2014) def cons_f2015(r): return NonzeroQ(r + S(1)) cons2015 = CustomConstraint(cons_f2015) def cons_f2016(p, r): return IntegerQ(p/(r + S(1))) cons2016 = CustomConstraint(cons_f2016) def cons_f2017(r, p, s, q): return ZeroQ(p*(s + S(1)) - q*(r + S(1))) cons2017 = CustomConstraint(cons_f2017) def cons_f2018(m, p, q): return ZeroQ(p + q*(m*p + S(1))) cons2018 = CustomConstraint(cons_f2018) def cons_f2019(m, p, q, r): return ZeroQ(p + q*(m*p + r + S(1))) cons2019 = CustomConstraint(cons_f2019) def cons_f2020(m, p, s, q): return ZeroQ(p*(s + S(1)) + q*(m*p + S(1))) cons2020 = CustomConstraint(cons_f2020) def cons_f2021(s): return NonzeroQ(s + S(1)) cons2021 = CustomConstraint(cons_f2021) def cons_f2022(s, q): return IntegerQ(q/(s + S(1))) cons2022 = CustomConstraint(cons_f2022) def cons_f2023(p, m, r, s, q): return ZeroQ(p*(s + S(1)) + q*(m*p + r + S(1))) cons2023 = CustomConstraint(cons_f2023) def cons_f2024(x, m, u): if isinstance(x, (int, Integer, float, Float)): return False return FunctionOfQ(x**(m + S(1)), u, x) cons2024 = CustomConstraint(cons_f2024) def cons_f2025(x, w): if isinstance(x, (int, Integer, float, Float)): return False return NFreeQ(w, x) cons2025 = CustomConstraint(cons_f2025) def cons_f2026(x, z): if isinstance(x, (int, Integer, float, Float)): return False return NFreeQ(z, x) cons2026 = CustomConstraint(cons_f2026) def cons_f2027(m, a): return Not(And(EqQ(a, S(1)), EqQ(m, S(1)))) cons2027 = CustomConstraint(cons_f2027) def cons_f2028(v, m, x): if isinstance(x, (int, Integer, float, Float)): return False return Not(And(EqQ(v, x), EqQ(m, S(1)))) cons2028 = CustomConstraint(cons_f2028) def cons_f2029(x, u): if isinstance(x, (int, Integer, float, Float)): return False return Not(RationalFunctionQ(u, x)) cons2029 = CustomConstraint(cons_f2029) def cons_f2030(v, x): if isinstance(x, (int, Integer, float, Float)): return False return Not(LinearQ(v, x)) cons2030 = CustomConstraint(cons_f2030) def cons_f2031(r, s): return PosQ(-r + s) cons2031 = CustomConstraint(cons_f2031) def cons_f2032(x, u): if isinstance(x, (int, Integer, float, Float)): return False return Not(AlgebraicFunctionQ(u, x)) cons2032 = CustomConstraint(cons_f2032) def cons_f2033(x, m, u): if isinstance(x, (int, Integer, float, Float)): return False return Or(Greater(m, S(0)), Not(AlgebraicFunctionQ(u, x))) cons2033 = CustomConstraint(cons_f2033) def cons_f2034(x, u): if isinstance(x, (int, Integer, float, Float)): return False return EulerIntegrandQ(u, x) cons2034 = CustomConstraint(cons_f2034) def cons_f2035(v, x, u): if isinstance(x, (int, Integer, float, Float)): return False return PolynomialInQ(v, u, x) cons2035 = CustomConstraint(cons_f2035) def cons_f2036(d, a): return ZeroQ(a + d) cons2036 = CustomConstraint(cons_f2036) def cons_f2037(p, q): return ZeroQ(p + q) cons2037 = CustomConstraint(cons_f2037)
ac9e3d33c8572a7426444dedf2bea110eec756afadb2c1164279c9d808324daf
''' This code is automatically generated. Never edit it manually. For details of generating the code see `rubi_parsing_guide.md` in `parsetools`. ''' from sympy.external import import_module matchpy = import_module("matchpy") from sympy.utilities.decorator import doctest_depends_on if matchpy: from matchpy import Pattern, ReplacementRule, CustomConstraint, is_match from sympy.integrals.rubi.utility_function import ( Int, Sum, Set, With, Module, Scan, MapAnd, FalseQ, ZeroQ, NegativeQ, NonzeroQ, FreeQ, NFreeQ, List, Log, PositiveQ, PositiveIntegerQ, NegativeIntegerQ, IntegerQ, IntegersQ, ComplexNumberQ, PureComplexNumberQ, RealNumericQ, PositiveOrZeroQ, NegativeOrZeroQ, FractionOrNegativeQ, NegQ, Equal, Unequal, IntPart, FracPart, RationalQ, ProductQ, SumQ, NonsumQ, Subst, First, Rest, SqrtNumberQ, SqrtNumberSumQ, LinearQ, Sqrt, ArcCosh, Coefficient, Denominator, Hypergeometric2F1, Not, Simplify, FractionalPart, IntegerPart, AppellF1, EllipticPi, EllipticE, EllipticF, ArcTan, ArcCot, ArcCoth, ArcTanh, ArcSin, ArcSinh, ArcCos, ArcCsc, ArcSec, ArcCsch, ArcSech, Sinh, Tanh, Cosh, Sech, Csch, Coth, LessEqual, Less, Greater, GreaterEqual, FractionQ, IntLinearcQ, Expand, IndependentQ, PowerQ, IntegerPowerQ, PositiveIntegerPowerQ, FractionalPowerQ, AtomQ, ExpQ, LogQ, Head, MemberQ, TrigQ, SinQ, CosQ, TanQ, CotQ, SecQ, CscQ, Sin, Cos, Tan, Cot, Sec, Csc, HyperbolicQ, SinhQ, CoshQ, TanhQ, CothQ, SechQ, CschQ, InverseTrigQ, SinCosQ, SinhCoshQ, LeafCount, Numerator, NumberQ, NumericQ, Length, ListQ, Im, Re, InverseHyperbolicQ, InverseFunctionQ, TrigHyperbolicFreeQ, InverseFunctionFreeQ, RealQ, EqQ, FractionalPowerFreeQ, ComplexFreeQ, PolynomialQ, FactorSquareFree, PowerOfLinearQ, Exponent, QuadraticQ, LinearPairQ, BinomialParts, TrinomialParts, PolyQ, EvenQ, OddQ, PerfectSquareQ, NiceSqrtAuxQ, NiceSqrtQ, Together, PosAux, PosQ, CoefficientList, ReplaceAll, ExpandLinearProduct, GCD, ContentFactor, NumericFactor, NonnumericFactors, MakeAssocList, GensymSubst, KernelSubst, ExpandExpression, Apart, SmartApart, MatchQ, PolynomialQuotientRemainder, FreeFactors, NonfreeFactors, RemoveContentAux, RemoveContent, FreeTerms, NonfreeTerms, ExpandAlgebraicFunction, CollectReciprocals, ExpandCleanup, AlgebraicFunctionQ, Coeff, LeadTerm, RemainingTerms, LeadFactor, RemainingFactors, LeadBase, LeadDegree, Numer, Denom, hypergeom, Expon, MergeMonomials, PolynomialDivide, BinomialQ, TrinomialQ, GeneralizedBinomialQ, GeneralizedTrinomialQ, FactorSquareFreeList, PerfectPowerTest, SquareFreeFactorTest, RationalFunctionQ, RationalFunctionFactors, NonrationalFunctionFactors, Reverse, RationalFunctionExponents, RationalFunctionExpand, ExpandIntegrand, SimplerQ, SimplerSqrtQ, SumSimplerQ, BinomialDegree, TrinomialDegree, CancelCommonFactors, SimplerIntegrandQ, GeneralizedBinomialDegree, GeneralizedBinomialParts, GeneralizedTrinomialDegree, GeneralizedTrinomialParts, MonomialQ, MonomialSumQ, MinimumMonomialExponent, MonomialExponent, LinearMatchQ, PowerOfLinearMatchQ, QuadraticMatchQ, CubicMatchQ, BinomialMatchQ, TrinomialMatchQ, GeneralizedBinomialMatchQ, GeneralizedTrinomialMatchQ, QuotientOfLinearsMatchQ, PolynomialTermQ, PolynomialTerms, NonpolynomialTerms, PseudoBinomialParts, NormalizePseudoBinomial, PseudoBinomialPairQ, PseudoBinomialQ, PolynomialGCD, PolyGCD, AlgebraicFunctionFactors, NonalgebraicFunctionFactors, QuotientOfLinearsP, QuotientOfLinearsParts, QuotientOfLinearsQ, Flatten, Sort, AbsurdNumberQ, AbsurdNumberFactors, NonabsurdNumberFactors, SumSimplerAuxQ, Prepend, Drop, CombineExponents, FactorInteger, FactorAbsurdNumber, SubstForInverseFunction, SubstForFractionalPower, SubstForFractionalPowerOfQuotientOfLinears, FractionalPowerOfQuotientOfLinears, SubstForFractionalPowerQ, SubstForFractionalPowerAuxQ, FractionalPowerOfSquareQ, FractionalPowerSubexpressionQ, Apply, FactorNumericGcd, MergeableFactorQ, MergeFactor, MergeFactors, TrigSimplifyQ, TrigSimplify, TrigSimplifyRecur, Order, FactorOrder, Smallest, OrderedQ, MinimumDegree, PositiveFactors, Sign, NonpositiveFactors, PolynomialInAuxQ, PolynomialInQ, ExponentInAux, ExponentIn, PolynomialInSubstAux, PolynomialInSubst, Distrib, DistributeDegree, FunctionOfPower, DivideDegreesOfFactors, MonomialFactor, FullSimplify, FunctionOfLinearSubst, FunctionOfLinear, NormalizeIntegrand, NormalizeIntegrandAux, NormalizeIntegrandFactor, NormalizeIntegrandFactorBase, NormalizeTogether, NormalizeLeadTermSigns, AbsorbMinusSign, NormalizeSumFactors, SignOfFactor, NormalizePowerOfLinear, SimplifyIntegrand, SimplifyTerm, TogetherSimplify, SmartSimplify, SubstForExpn, ExpandToSum, UnifySum, UnifyTerms, UnifyTerm, CalculusQ, FunctionOfInverseLinear, PureFunctionOfSinhQ, PureFunctionOfTanhQ, PureFunctionOfCoshQ, IntegerQuotientQ, OddQuotientQ, EvenQuotientQ, FindTrigFactor, FunctionOfSinhQ, FunctionOfCoshQ, OddHyperbolicPowerQ, FunctionOfTanhQ, FunctionOfTanhWeight, FunctionOfHyperbolicQ, SmartNumerator, SmartDenominator, SubstForAux, ActivateTrig, ExpandTrig, TrigExpand, SubstForTrig, SubstForHyperbolic, InertTrigFreeQ, LCM, SubstForFractionalPowerOfLinear, FractionalPowerOfLinear, InverseFunctionOfLinear, InertTrigQ, InertReciprocalQ, DeactivateTrig, FixInertTrigFunction, DeactivateTrigAux, PowerOfInertTrigSumQ, PiecewiseLinearQ, KnownTrigIntegrandQ, KnownSineIntegrandQ, KnownTangentIntegrandQ, KnownCotangentIntegrandQ, KnownSecantIntegrandQ, TryPureTanSubst, TryTanhSubst, TryPureTanhSubst, AbsurdNumberGCD, AbsurdNumberGCDList, ExpandTrigExpand, ExpandTrigReduce, ExpandTrigReduceAux, NormalizeTrig, TrigToExp, ExpandTrigToExp, TrigReduce, FunctionOfTrig, AlgebraicTrigFunctionQ, FunctionOfHyperbolic, FunctionOfQ, FunctionOfExpnQ, PureFunctionOfSinQ, PureFunctionOfCosQ, PureFunctionOfTanQ, PureFunctionOfCotQ, FunctionOfCosQ, FunctionOfSinQ, OddTrigPowerQ, FunctionOfTanQ, FunctionOfTanWeight, FunctionOfTrigQ, FunctionOfDensePolynomialsQ, FunctionOfLog, PowerVariableExpn, PowerVariableDegree, PowerVariableSubst, EulerIntegrandQ, FunctionOfSquareRootOfQuadratic, SquareRootOfQuadraticSubst, Divides, EasyDQ, ProductOfLinearPowersQ, Rt, NthRoot, AtomBaseQ, SumBaseQ, NegSumBaseQ, AllNegTermQ, SomeNegTermQ, TrigSquareQ, RtAux, TrigSquare, IntSum, IntTerm, Map2, ConstantFactor, SameQ, ReplacePart, CommonFactors, MostMainFactorPosition, FunctionOfExponentialQ, FunctionOfExponential, FunctionOfExponentialFunction, FunctionOfExponentialFunctionAux, FunctionOfExponentialTest, FunctionOfExponentialTestAux, stdev, rubi_test, If, IntQuadraticQ, IntBinomialQ, RectifyTangent, RectifyCotangent, Inequality, Condition, Simp, SimpHelp, SplitProduct, SplitSum, SubstFor, SubstForAux, FresnelS, FresnelC, Erfc, Erfi, Gamma, FunctionOfTrigOfLinearQ, ElementaryFunctionQ, Complex, UnsameQ, _SimpFixFactor, SimpFixFactor, _FixSimplify, FixSimplify, _SimplifyAntiderivativeSum, SimplifyAntiderivativeSum, _SimplifyAntiderivative, SimplifyAntiderivative, _TrigSimplifyAux, TrigSimplifyAux, Cancel, Part, PolyLog, D, Dist, Sum_doit, PolynomialQuotient, Floor, PolynomialRemainder, Factor, PolyLog, CosIntegral, SinIntegral, LogIntegral, SinhIntegral, CoshIntegral, Rule, Erf, PolyGamma, ExpIntegralEi, ExpIntegralE, LogGamma , UtilityOperator, Factorial, Zeta, ProductLog, DerivativeDivides, HypergeometricPFQ, IntHide, OneQ, Null, rubi_exp as exp, rubi_log as log, Discriminant, Negative, Quotient ) from sympy import (Integral, S, sqrt, And, Or, Integer, Float, Mod, I, Abs, simplify, Mul, Add, Pow, sign, EulerGamma) from sympy.integrals.rubi.symbol import WC from sympy.core.symbol import symbols, Symbol from sympy.functions import (sin, cos, tan, cot, csc, sec, sqrt, erf) from sympy.functions.elementary.hyperbolic import (acosh, asinh, atanh, acoth, acsch, asech, cosh, sinh, tanh, coth, sech, csch) from sympy.functions.elementary.trigonometric import (atan, acsc, asin, acot, acos, asec, atan2) from sympy import pi as Pi A_, B_, C_, F_, G_, H_, a_, b_, c_, d_, e_, f_, g_, h_, i_, j_, k_, l_, m_, n_, p_, q_, r_, t_, u_, v_, s_, w_, x_, y_, z_ = [WC(i) for i in 'ABCFGHabcdefghijklmnpqrtuvswxyz'] a1_, a2_, b1_, b2_, c1_, c2_, d1_, d2_, n1_, n2_, e1_, e2_, f1_, f2_, g1_, g2_, n1_, n2_, n3_, Pq_, Pm_, Px_, Qm_, Qr_, Qx_, jn_, mn_, non2_, RFx_, RGx_ = [WC(i) for i in ['a1', 'a2', 'b1', 'b2', 'c1', 'c2', 'd1', 'd2', 'n1', 'n2', 'e1', 'e2', 'f1', 'f2', 'g1', 'g2', 'n1', 'n2', 'n3', 'Pq', 'Pm', 'Px', 'Qm', 'Qr', 'Qx', 'jn', 'mn', 'non2', 'RFx', 'RGx']] i, ii , Pqq, Q, R, r, C, k, u = symbols('i ii Pqq Q R r C k u') _UseGamma = False ShowSteps = False StepCounter = None def quadratic_products(rubi): from sympy.integrals.rubi.constraints import cons45, cons2, cons3, cons7, cons225, cons5, cons226, cons128, cons227, cons228, cons13, cons163, cons229, cons137, cons230, cons231, cons232, cons233, cons234, cons235, cons68, cons69, cons47, cons236, cons27, cons48, cons21, cons237, cons238, cons239, cons240, cons66, cons241, cons242, cons243, cons244, cons146, cons245, cons246, cons247, cons248, cons249, cons250, cons251, cons252, cons166, cons253, cons31, cons168, cons254, cons255, cons94, cons147, cons256, cons38, cons257, cons258, cons41, cons17, cons259, cons260, cons261, cons262, cons263, cons264, cons265, cons266, cons267, cons43, cons268, cons54, cons269, cons270, cons271, cons272, cons273, cons274, cons275, cons276, cons277, cons278, cons279, cons280, cons281, cons282, cons283, cons284, cons285, cons286, cons18, cons287, cons288, cons289, cons290, cons291, cons292, cons293, cons294, cons295, cons296, cons297, cons298, cons299, cons300, cons301, cons302, cons303, cons304, cons305, cons306, cons307, cons308, cons309, cons310, cons311, cons312, cons313, cons84, cons85, cons314, cons315, cons316, cons125, cons208, cons317, cons318, cons319, cons62, cons320, cons321, cons322, cons323, cons324, cons4, cons325, cons326, cons327, cons139, cons328, cons329, cons330, cons331, cons150, cons332, cons148, cons333, cons196, cons334, cons335, cons336, cons337, cons338, cons89, cons339, cons340, cons341, cons88, cons87, cons342, cons343, cons344, cons126, cons345, cons346, cons207, cons347, cons348, cons349, cons350, cons351, cons352, cons353, cons354, cons355, cons356, cons357, cons358, cons359, cons360, cons361, cons362, cons363, cons364, cons365, cons366, cons367, cons368, cons369, cons370, cons371, cons372, cons373, cons374, cons375, cons149, cons376, cons124, cons377, cons93, cons23, cons165, cons73, cons378, cons80, cons379, cons380, cons381, cons382, cons383, cons384, cons385, cons50, cons386, cons387, cons388, cons389, cons390, cons391, cons392, cons393, cons394, cons395, cons396, cons397, cons398, cons399, cons400, cons401, cons402, cons403, cons404, cons405, cons406, cons407, cons408, cons409, cons410, cons411, cons412, cons413, cons414, cons415, cons416, cons209, cons417, cons418, cons419, cons420, cons421, cons422, cons423, cons424, cons425, cons426, cons427, cons428, cons429, cons430, cons431, cons220, cons432, cons433, cons434, cons435, cons436, cons437, cons438, cons439, cons440, cons441, cons442, cons443, cons444, cons445, cons446, cons447, cons448, cons449, cons450, cons451, cons452, cons453, cons224, cons34, cons35, cons36, cons454, cons455, cons456, cons457, cons458 pattern189 = Pattern(Integral(S(1)/sqrt(a_ + x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1))), x_), cons2, cons3, cons7, cons45) def replacement189(x, c, b, a): rubi.append(189) return Dist((b/S(2) + c*x)/sqrt(a + b*x + c*x**S(2)), Int(S(1)/(b/S(2) + c*x), x), x) rule189 = ReplacementRule(pattern189, replacement189) pattern190 = Pattern(Integral((a_ + x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)))**p_, x_), cons2, cons3, cons7, cons5, cons45, cons225) def replacement190(p, b, c, a, x): rubi.append(190) return Simp((b + S(2)*c*x)*(a + b*x + c*x**S(2))**p/(S(2)*c*(S(2)*p + S(1))), x) rule190 = ReplacementRule(pattern190, replacement190) def With191(p, b, c, a, x): q = Rt(-S(4)*a*c + b**S(2), S(2)) rubi.append(191) return Dist(c**(-p), Int(Simp(b/S(2) + c*x - q/S(2), x)**p*Simp(b/S(2) + c*x + q/S(2), x)**p, x), x) pattern191 = Pattern(Integral((a_ + x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)))**p_, x_), cons2, cons3, cons7, cons226, cons128, cons227) rule191 = ReplacementRule(pattern191, With191) pattern192 = Pattern(Integral((a_ + x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)))**p_, x_), cons2, cons3, cons7, cons226, cons128, cons228) def replacement192(p, b, c, a, x): rubi.append(192) return Int(ExpandIntegrand((a + b*x + c*x**S(2))**p, x), x) rule192 = ReplacementRule(pattern192, replacement192) pattern193 = Pattern(Integral((x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0)))**p_, x_), cons2, cons3, cons7, cons226, cons13, cons163, cons229) def replacement193(p, b, c, a, x): rubi.append(193) return -Dist(p*(-S(4)*a*c + b**S(2))/(S(2)*c*(S(2)*p + S(1))), Int((a + b*x + c*x**S(2))**(p + S(-1)), x), x) + Simp((b + S(2)*c*x)*(a + b*x + c*x**S(2))**p/(S(2)*c*(S(2)*p + S(1))), x) rule193 = ReplacementRule(pattern193, replacement193) pattern194 = Pattern(Integral((x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0)))**(S(-3)/2), x_), cons2, cons3, cons7, cons226) def replacement194(x, c, a, b): rubi.append(194) return Simp(-S(2)*(b + S(2)*c*x)/((-S(4)*a*c + b**S(2))*sqrt(a + b*x + c*x**S(2))), x) rule194 = ReplacementRule(pattern194, replacement194) pattern195 = Pattern(Integral((x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0)))**p_, x_), cons2, cons3, cons7, cons226, cons13, cons137, cons230, cons229) def replacement195(p, b, c, a, x): rubi.append(195) return -Dist(S(2)*c*(S(2)*p + S(3))/((p + S(1))*(-S(4)*a*c + b**S(2))), Int((a + b*x + c*x**S(2))**(p + S(1)), x), x) + Simp((b + S(2)*c*x)*(a + b*x + c*x**S(2))**(p + S(1))/((p + S(1))*(-S(4)*a*c + b**S(2))), x) rule195 = ReplacementRule(pattern195, replacement195) def With196(x, c, b, a): q = Rt(-S(4)*a*c + b**S(2), S(2)) rubi.append(196) return Dist(c/q, Int(S(1)/Simp(b/S(2) + c*x - q/S(2), x), x), x) - Dist(c/q, Int(S(1)/Simp(b/S(2) + c*x + q/S(2), x), x), x) pattern196 = Pattern(Integral(S(1)/(a_ + x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1))), x_), cons2, cons3, cons7, cons226, cons231, cons227) rule196 = ReplacementRule(pattern196, With196) def With197(x, c, b, a): if isinstance(x, (int, Integer, float, Float)): return False q = -S(4)*a*c/b**S(2) + S(1) if And(RationalQ(q), Or(EqQ(q**S(2), S(1)), Not(RationalQ(-S(4)*a*c + b**S(2))))): return True return False pattern197 = Pattern(Integral(S(1)/(a_ + x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1))), x_), cons2, cons3, cons7, cons226, CustomConstraint(With197)) def replacement197(x, c, b, a): q = -S(4)*a*c/b**S(2) + S(1) rubi.append(197) return Dist(-S(2)/b, Subst(Int(S(1)/(q - x**S(2)), x), x, S(1) + S(2)*c*x/b), x) rule197 = ReplacementRule(pattern197, replacement197) pattern198 = Pattern(Integral(S(1)/(a_ + x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1))), x_), cons2, cons3, cons7, cons226) def replacement198(x, c, b, a): rubi.append(198) return Dist(S(-2), Subst(Int(S(1)/Simp(-S(4)*a*c + b**S(2) - x**S(2), x), x), x, b + S(2)*c*x), x) rule198 = ReplacementRule(pattern198, replacement198) pattern199 = Pattern(Integral((x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0)))**p_, x_), cons2, cons3, cons7, cons5, cons232) def replacement199(p, b, c, a, x): rubi.append(199) return Dist((-S(4)*c/(-S(4)*a*c + b**S(2)))**(-p)/(S(2)*c), Subst(Int(Simp(-x**S(2)/(-S(4)*a*c + b**S(2)) + S(1), x)**p, x), x, b + S(2)*c*x), x) rule199 = ReplacementRule(pattern199, replacement199) pattern200 = Pattern(Integral(S(1)/sqrt(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1))), x_), cons3, cons7, cons233) def replacement200(x, c, b): rubi.append(200) return Dist(S(2), Subst(Int(S(1)/(-c*x**S(2) + S(1)), x), x, x/sqrt(b*x + c*x**S(2))), x) rule200 = ReplacementRule(pattern200, replacement200) pattern201 = Pattern(Integral(S(1)/sqrt(a_ + x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1))), x_), cons2, cons3, cons7, cons226) def replacement201(x, c, b, a): rubi.append(201) return Dist(S(2), Subst(Int(S(1)/(S(4)*c - x**S(2)), x), x, (b + S(2)*c*x)/sqrt(a + b*x + c*x**S(2))), x) rule201 = ReplacementRule(pattern201, replacement201) pattern202 = Pattern(Integral((x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)))**p_, x_), cons3, cons7, cons13, cons234) def replacement202(x, c, p, b): rubi.append(202) return Dist((-c*(b*x + c*x**S(2))/b**S(2))**(-p)*(b*x + c*x**S(2))**p, Int((-c*x/b - c**S(2)*x**S(2)/b**S(2))**p, x), x) rule202 = ReplacementRule(pattern202, replacement202) def With203(p, b, c, a, x): if isinstance(x, (int, Integer, float, Float)): return False d = Denominator(p) if LessEqual(S(3), d, S(4)): return True return False pattern203 = Pattern(Integral((x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0)))**p_, x_), cons2, cons3, cons7, cons226, cons13, CustomConstraint(With203)) def replacement203(p, b, c, a, x): d = Denominator(p) rubi.append(203) return Dist(d*sqrt((b + S(2)*c*x)**S(2))/(b + S(2)*c*x), Subst(Int(x**(d*(p + S(1)) + S(-1))/sqrt(-S(4)*a*c + b**S(2) + S(4)*c*x**d), x), x, (a + b*x + c*x**S(2))**(S(1)/d)), x) rule203 = ReplacementRule(pattern203, replacement203) def With204(p, b, c, a, x): q = Rt(-S(4)*a*c + b**S(2), S(2)) rubi.append(204) return -Simp(((-b - S(2)*c*x + q)/(S(2)*q))**(-p + S(-1))*(a + b*x + c*x**S(2))**(p + S(1))*Hypergeometric2F1(-p, p + S(1), p + S(2), (b + S(2)*c*x + q)/(S(2)*q))/(q*(p + S(1))), x) pattern204 = Pattern(Integral((x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0)))**p_, x_), cons2, cons3, cons7, cons5, cons226, cons235) rule204 = ReplacementRule(pattern204, With204) pattern205 = Pattern(Integral((u_**S(2)*WC('c', S(1)) + u_*WC('b', S(1)) + WC('a', S(0)))**p_, x_), cons2, cons3, cons7, cons5, cons68, cons69) def replacement205(p, u, b, c, a, x): rubi.append(205) return Dist(S(1)/Coefficient(u, x, S(1)), Subst(Int((a + b*x + c*x**S(2))**p, x), x, u), x) rule205 = ReplacementRule(pattern205, replacement205) pattern206 = Pattern(Integral((d_ + x_*WC('e', S(1)))**WC('m', S(1))*(a_ + x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)))**p_, x_), cons2, cons3, cons7, cons27, cons48, cons21, cons5, cons45, cons47, cons236) def replacement206(p, m, b, d, c, a, x, e): rubi.append(206) return Simp(c**(-m/S(2) + S(-1)/2)*e**m*(a + b*x + c*x**S(2))**(m/S(2) + p + S(1)/2)/(m + S(2)*p + S(1)), x) rule206 = ReplacementRule(pattern206, replacement206) pattern207 = Pattern(Integral((d_ + x_*WC('e', S(1)))**m_*(a_ + x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)))**p_, x_), cons2, cons3, cons7, cons27, cons48, cons21, cons5, cons45, cons47, cons237) def replacement207(p, m, b, d, c, a, x, e): rubi.append(207) return Simp((d + e*x)**(m + S(1))*(a + b*x + c*x**S(2))**p*log(RemoveContent(d + e*x, x))/e, x) rule207 = ReplacementRule(pattern207, replacement207) pattern208 = Pattern(Integral((d_ + x_*WC('e', S(1)))**WC('m', S(1))*(a_ + x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)))**p_, x_), cons2, cons3, cons7, cons27, cons48, cons21, cons5, cons45, cons47, cons238) def replacement208(p, m, b, d, c, a, x, e): rubi.append(208) return Simp((d + e*x)**(m + S(1))*(a + b*x + c*x**S(2))**p/(e*(m + S(2)*p + S(1))), x) rule208 = ReplacementRule(pattern208, replacement208) pattern209 = Pattern(Integral((x_*WC('e', S(1)) + WC('d', S(0)))**WC('m', S(1))*(a_ + x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)))**p_, x_), cons2, cons3, cons7, cons27, cons48, cons21, cons5, cons45, cons239, cons240, cons66) def replacement209(p, m, b, d, c, a, x, e): rubi.append(209) return -Simp((b + S(2)*c*x)*(d + e*x)**(m + S(1))*(a + b*x + c*x**S(2))**p/((m + S(1))*(-b*e + S(2)*c*d)), x) rule209 = ReplacementRule(pattern209, replacement209) pattern210 = Pattern(Integral(sqrt(a_ + x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)))/(x_*WC('e', S(1)) + WC('d', S(0)))**S(2), x_), cons2, cons3, cons7, cons27, cons48, cons45, cons239) def replacement210(b, d, c, a, x, e): rubi.append(210) return Dist(sqrt(a + b*x + c*x**S(2))/(b + S(2)*c*x), Int((b + S(2)*c*x)/(d + e*x)**S(2), x), x) rule210 = ReplacementRule(pattern210, replacement210) pattern211 = Pattern(Integral((x_*WC('e', S(1)) + WC('d', S(0)))**m_*sqrt(a_ + x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons21, cons45, cons239, cons241) def replacement211(m, b, d, c, a, x, e): rubi.append(211) return -Dist((-b*e + S(2)*c*d)*sqrt(a + b*x + c*x**S(2))/(e*(b + S(2)*c*x)*(m + S(2))), Int((d + e*x)**m, x), x) + Simp((d + e*x)**(m + S(1))*sqrt(a + b*x + c*x**S(2))/(e*(m + S(2))), x) rule211 = ReplacementRule(pattern211, replacement211) pattern212 = Pattern(Integral(S(1)/((x_*WC('e', S(1)) + WC('d', S(0)))**S(2)*sqrt(a_ + x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)))), x_), cons2, cons3, cons7, cons27, cons48, cons45, cons239) def replacement212(b, d, c, a, x, e): rubi.append(212) return Dist(S(2)*c/(-b*e + S(2)*c*d), Int(S(1)/((d + e*x)*sqrt(a + b*x + c*x**S(2))), x), x) + Simp(-S(4)*c*e*sqrt(a + b*x + c*x**S(2))/((d + e*x)*(-b*e + S(2)*c*d)**S(2)), x) rule212 = ReplacementRule(pattern212, replacement212) pattern213 = Pattern(Integral((x_*WC('e', S(1)) + WC('d', S(0)))**m_*(a_ + x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)))**p_, x_), cons2, cons3, cons7, cons27, cons48, cons21, cons5, cons45, cons239, cons242, cons241) def replacement213(p, m, b, d, c, a, x, e): rubi.append(213) return -Simp((b + S(2)*c*x)*(d + e*x)**(m + S(1))*(a + b*x + c*x**S(2))**p/((m + S(2))*(-b*e + S(2)*c*d)), x) + Simp(-S(2)*c*e*(d + e*x)**(m + S(1))*(a + b*x + c*x**S(2))**(p + S(1))/((-b*e + S(2)*c*d)**S(2)*(m*p + S(-1))), x) rule213 = ReplacementRule(pattern213, replacement213) pattern214 = Pattern(Integral((x_*WC('e', S(1)) + WC('d', S(0)))*(a_ + x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)))**p_, x_), cons2, cons3, cons7, cons27, cons48, cons5, cons45, cons239, cons243) def replacement214(p, b, d, c, a, x, e): rubi.append(214) return Dist((-b*e + S(2)*c*d)/(S(2)*c), Int((a + b*x + c*x**S(2))**p, x), x) + Simp(e*(a + b*x + c*x**S(2))**(p + S(1))/(S(2)*c*(p + S(1))), x) rule214 = ReplacementRule(pattern214, replacement214) pattern215 = Pattern(Integral((x_*WC('e', S(1)) + WC('d', S(0)))**m_*(a_ + x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)))**p_, x_), cons2, cons3, cons7, cons27, cons48, cons45, cons239, cons244, cons146, cons245, cons246) def replacement215(p, m, b, d, c, a, x, e): rubi.append(215) return Dist(p*(S(2)*p + S(-1))*(-b*e + S(2)*c*d)/(e**S(2)*(m + S(1))*(m + S(2)*p + S(1))), Int((d + e*x)**(m + S(1))*(a + b*x + c*x**S(2))**(p + S(-1)), x), x) + Simp((d + e*x)**(m + S(1))*(a + b*x + c*x**S(2))**p/(e*(m + S(1))), x) - Simp(p*(b + S(2)*c*x)*(d + e*x)**(m + S(2))*(a + b*x + c*x**S(2))**(p + S(-1))/(e**S(2)*(m + S(1))*(m + S(2)*p + S(1))), x) rule215 = ReplacementRule(pattern215, replacement215) pattern216 = Pattern(Integral((x_*WC('e', S(1)) + WC('d', S(0)))**m_*(a_ + x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)))**p_, x_), cons2, cons3, cons7, cons27, cons48, cons45, cons239, cons244, cons146, cons247, cons246, cons248) def replacement216(p, m, b, d, c, a, x, e): rubi.append(216) return Dist(S(2)*c*p*(S(2)*p + S(-1))/(e**S(2)*(m + S(1))*(m + S(2))), Int((d + e*x)**(m + S(2))*(a + b*x + c*x**S(2))**(p + S(-1)), x), x) + Simp((d + e*x)**(m + S(1))*(a + b*x + c*x**S(2))**p/(e*(m + S(1))), x) - Simp(p*(b + S(2)*c*x)*(d + e*x)**(m + S(2))*(a + b*x + c*x**S(2))**(p + S(-1))/(e**S(2)*(m + S(1))*(m + S(2))), x) rule216 = ReplacementRule(pattern216, replacement216) pattern217 = Pattern(Integral((x_*WC('e', S(1)) + WC('d', S(0)))**m_*(a_ + x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)))**p_, x_), cons2, cons3, cons7, cons27, cons48, cons21, cons45, cons239, cons13, cons163, cons249, cons238, cons248, cons250, cons251, cons246) def replacement217(p, m, b, d, c, a, x, e): rubi.append(217) return Dist(p*(S(2)*p + S(-1))*(-b*e + S(2)*c*d)**S(2)/(S(2)*c*e**S(2)*(m + S(2)*p)*(m + S(2)*p + S(1))), Int((d + e*x)**m*(a + b*x + c*x**S(2))**(p + S(-1)), x), x) + Simp((d + e*x)**(m + S(1))*(a + b*x + c*x**S(2))**p/(e*(m + S(2)*p + S(1))), x) - Simp(p*(b + S(2)*c*x)*(d + e*x)**(m + S(1))*(-b*e + S(2)*c*d)*(a + b*x + c*x**S(2))**(p + S(-1))/(S(2)*c*e**S(2)*(m + S(2)*p)*(m + S(2)*p + S(1))), x) rule217 = ReplacementRule(pattern217, replacement217) pattern218 = Pattern(Integral((x_*WC('e', S(1)) + WC('d', S(0)))**WC('m', S(1))*(a_ + x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)))**p_, x_), cons2, cons3, cons7, cons27, cons48, cons45, cons239, cons244, cons137, cons252, cons246) def replacement218(p, m, b, d, c, a, x, e): rubi.append(218) return Dist(e**S(2)*m*(m + S(2)*p + S(2))/((p + S(1))*(S(2)*p + S(1))*(-b*e + S(2)*c*d)), Int((d + e*x)**(m + S(-1))*(a + b*x + c*x**S(2))**(p + S(1)), x), x) + Simp((b + S(2)*c*x)*(d + e*x)**(m + S(1))*(a + b*x + c*x**S(2))**p/((S(2)*p + S(1))*(-b*e + S(2)*c*d)), x) - Simp(e*(d + e*x)**m*(a + b*x + c*x**S(2))**(p + S(1))*(m + S(2)*p + S(2))/((p + S(1))*(S(2)*p + S(1))*(-b*e + S(2)*c*d)), x) rule218 = ReplacementRule(pattern218, replacement218) pattern219 = Pattern(Integral((x_*WC('e', S(1)) + WC('d', S(0)))**m_*(a_ + x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)))**p_, x_), cons2, cons3, cons7, cons27, cons48, cons45, cons239, cons244, cons137, cons166, cons246) def replacement219(p, m, b, d, c, a, x, e): rubi.append(219) return Dist(e**S(2)*m*(m + S(-1))/(S(2)*c*(p + S(1))*(S(2)*p + S(1))), Int((d + e*x)**(m + S(-2))*(a + b*x + c*x**S(2))**(p + S(1)), x), x) + Simp((b + S(2)*c*x)*(d + e*x)**m*(a + b*x + c*x**S(2))**p/(S(2)*c*(S(2)*p + S(1))), x) - Simp(e*m*(d + e*x)**(m + S(-1))*(a + b*x + c*x**S(2))**(p + S(1))/(S(2)*c*(p + S(1))*(S(2)*p + S(1))), x) rule219 = ReplacementRule(pattern219, replacement219) pattern220 = Pattern(Integral((x_*WC('e', S(1)) + WC('d', S(0)))**m_*(a_ + x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)))**p_, x_), cons2, cons3, cons7, cons27, cons48, cons21, cons45, cons239, cons244, cons137, cons253, cons246) def replacement220(p, m, b, d, c, a, x, e): rubi.append(220) return Dist(S(2)*c*e**S(2)*(m + S(2)*p + S(2))*(m + S(2)*p + S(3))/((p + S(1))*(S(2)*p + S(1))*(-b*e + S(2)*c*d)**S(2)), Int((d + e*x)**m*(a + b*x + c*x**S(2))**(p + S(1)), x), x) + Simp((b + S(2)*c*x)*(d + e*x)**(m + S(1))*(a + b*x + c*x**S(2))**p/((S(2)*p + S(1))*(-b*e + S(2)*c*d)), x) + Simp(-S(2)*c*e*(d + e*x)**(m + S(1))*(a + b*x + c*x**S(2))**(p + S(1))*(m + S(2)*p + S(2))/((p + S(1))*(S(2)*p + S(1))*(-b*e + S(2)*c*d)**S(2)), x) rule220 = ReplacementRule(pattern220, replacement220) pattern221 = Pattern(Integral((x_*WC('e', S(1)) + WC('d', S(0)))**WC('m', S(1))*(a_ + x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)))**p_, x_), cons2, cons3, cons7, cons27, cons48, cons5, cons45, cons239, cons31, cons168, cons238, cons254, cons255) def replacement221(p, m, b, d, c, a, x, e): rubi.append(221) return Dist(m*(-b*e + S(2)*c*d)/(S(2)*c*(m + S(2)*p + S(1))), Int((d + e*x)**(m + S(-1))*(a + b*x + c*x**S(2))**p, x), x) + Simp((b + S(2)*c*x)*(d + e*x)**m*(a + b*x + c*x**S(2))**p/(S(2)*c*(m + S(2)*p + S(1))), x) rule221 = ReplacementRule(pattern221, replacement221) pattern222 = Pattern(Integral((x_*WC('e', S(1)) + WC('d', S(0)))**m_*(a_ + x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)))**p_, x_), cons2, cons3, cons7, cons27, cons48, cons5, cons45, cons239, cons31, cons94, cons246) def replacement222(p, m, b, d, c, a, x, e): rubi.append(222) return Dist(S(2)*c*(m + S(2)*p + S(2))/((m + S(1))*(-b*e + S(2)*c*d)), Int((d + e*x)**(m + S(1))*(a + b*x + c*x**S(2))**p, x), x) - Simp((b + S(2)*c*x)*(d + e*x)**(m + S(1))*(a + b*x + c*x**S(2))**p/((m + S(1))*(-b*e + S(2)*c*d)), x) rule222 = ReplacementRule(pattern222, replacement222) pattern223 = Pattern(Integral((x_*WC('e', S(1)) + WC('d', S(0)))**WC('m', S(1))*(a_ + x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)))**p_, x_), cons2, cons3, cons7, cons27, cons48, cons21, cons5, cons45, cons147, cons239) def replacement223(p, m, b, d, c, a, x, e): rubi.append(223) return Dist(c**(-IntPart(p))*(b/S(2) + c*x)**(-S(2)*FracPart(p))*(a + b*x + c*x**S(2))**FracPart(p), Int((b/S(2) + c*x)**(S(2)*p)*(d + e*x)**m, x), x) rule223 = ReplacementRule(pattern223, replacement223) pattern224 = Pattern(Integral((d_ + x_*WC('e', S(1)))**WC('m', S(1))*(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons21, cons226, cons256, cons38) def replacement224(p, m, b, d, c, a, x, e): rubi.append(224) return Int((d + e*x)**(m + p)*(a/d + c*x/e)**p, x) rule224 = ReplacementRule(pattern224, replacement224) pattern225 = Pattern(Integral((a_ + x_**S(2)*WC('c', S(1)))**WC('p', S(1))*(d_ + x_*WC('e', S(1)))**WC('m', S(1)), x_), cons2, cons7, cons27, cons48, cons21, cons5, cons257, cons258) def replacement225(p, m, d, c, a, x, e): rubi.append(225) return Int((d + e*x)**(m + p)*(a/d + c*x/e)**p, x) rule225 = ReplacementRule(pattern225, replacement225) pattern226 = Pattern(Integral((x_*WC('e', S(1)) + WC('d', S(0)))**m_*(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0)))**p_, x_), cons2, cons3, cons7, cons27, cons48, cons21, cons5, cons226, cons256, cons147, cons41) def replacement226(p, m, b, d, c, a, x, e): rubi.append(226) return Simp(e*(d + e*x)**(m + S(-1))*(a + b*x + c*x**S(2))**(p + S(1))/(c*(p + S(1))), x) rule226 = ReplacementRule(pattern226, replacement226) pattern227 = Pattern(Integral((a_ + x_**S(2)*WC('c', S(1)))**p_*(d_ + x_*WC('e', S(1)))**m_, x_), cons2, cons7, cons27, cons48, cons21, cons5, cons257, cons147, cons41) def replacement227(p, m, d, c, a, x, e): rubi.append(227) return Simp(e*(a + c*x**S(2))**(p + S(1))*(d + e*x)**(m + S(-1))/(c*(p + S(1))), x) rule227 = ReplacementRule(pattern227, replacement227) pattern228 = Pattern(Integral((x_*WC('e', S(1)) + WC('d', S(0)))**WC('m', S(1))*(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0)))**p_, x_), cons2, cons3, cons7, cons27, cons48, cons21, cons5, cons226, cons256, cons147, cons240) def replacement228(p, m, b, d, a, c, x, e): rubi.append(228) return Simp(e*(d + e*x)**m*(a + b*x + c*x**S(2))**(p + S(1))/((p + S(1))*(-b*e + S(2)*c*d)), x) rule228 = ReplacementRule(pattern228, replacement228) pattern229 = Pattern(Integral((a_ + x_**S(2)*WC('c', S(1)))**p_*(d_ + x_*WC('e', S(1)))**WC('m', S(1)), x_), cons2, cons7, cons27, cons48, cons21, cons5, cons257, cons147, cons240) def replacement229(p, m, d, c, a, x, e): rubi.append(229) return Simp(e*(a + c*x**S(2))**(p + S(1))*(d + e*x)**m/(S(2)*c*d*(p + S(1))), x) rule229 = ReplacementRule(pattern229, replacement229) pattern230 = Pattern(Integral((x_*WC('e', S(1)) + WC('d', S(0)))**S(2)*(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0)))**p_, x_), cons2, cons3, cons7, cons27, cons48, cons5, cons226, cons256, cons147, cons13, cons137) def replacement230(p, b, d, c, a, x, e): rubi.append(230) return -Dist(e**S(2)*(p + S(2))/(c*(p + S(1))), Int((a + b*x + c*x**S(2))**(p + S(1)), x), x) + Simp(e*(d + e*x)*(a + b*x + c*x**S(2))**(p + S(1))/(c*(p + S(1))), x) rule230 = ReplacementRule(pattern230, replacement230) pattern231 = Pattern(Integral((a_ + x_**S(2)*WC('c', S(1)))**p_*(d_ + x_*WC('e', S(1)))**S(2), x_), cons2, cons7, cons27, cons48, cons5, cons257, cons147, cons13, cons137) def replacement231(p, d, c, a, x, e): rubi.append(231) return -Dist(e**S(2)*(p + S(2))/(c*(p + S(1))), Int((a + c*x**S(2))**(p + S(1)), x), x) + Simp(e*(a + c*x**S(2))**(p + S(1))*(d + e*x)/(c*(p + S(1))), x) rule231 = ReplacementRule(pattern231, replacement231) pattern232 = Pattern(Integral((d_ + x_*WC('e', S(1)))**m_*(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0)))**p_, x_), cons2, cons3, cons7, cons27, cons48, cons226, cons256, cons147, cons17, cons13, cons259, cons260, cons261) def replacement232(p, m, b, d, c, a, x, e): rubi.append(232) return Int((a/d + c*x/e)**(-m)*(a + b*x + c*x**S(2))**(m + p), x) rule232 = ReplacementRule(pattern232, replacement232) pattern233 = Pattern(Integral((a_ + x_**S(2)*WC('c', S(1)))**p_*(d_ + x_*WC('e', S(1)))**m_, x_), cons2, cons7, cons27, cons48, cons21, cons5, cons257, cons147, cons17, cons13, cons259, cons260, cons261) def replacement233(p, m, d, c, a, x, e): rubi.append(233) return Dist(a**(-m)*d**(S(2)*m), Int((a + c*x**S(2))**(m + p)*(d - e*x)**(-m), x), x) rule233 = ReplacementRule(pattern233, replacement233) pattern234 = Pattern(Integral((x_*WC('e', S(1)) + WC('d', S(0)))**WC('m', S(1))*(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0)))**p_, x_), cons2, cons3, cons7, cons27, cons48, cons21, cons5, cons226, cons256, cons147, cons262) def replacement234(p, m, b, d, a, c, x, e): rubi.append(234) return Dist((m + p)*(-b*e + S(2)*c*d)/(c*(m + S(2)*p + S(1))), Int((d + e*x)**(m + S(-1))*(a + b*x + c*x**S(2))**p, x), x) + Simp(e*(d + e*x)**(m + S(-1))*(a + b*x + c*x**S(2))**(p + S(1))/(c*(m + S(2)*p + S(1))), x) rule234 = ReplacementRule(pattern234, replacement234) pattern235 = Pattern(Integral((a_ + x_**S(2)*WC('c', S(1)))**p_*(d_ + x_*WC('e', S(1)))**WC('m', S(1)), x_), cons2, cons7, cons27, cons48, cons21, cons5, cons257, cons147, cons262) def replacement235(p, m, d, c, a, x, e): rubi.append(235) return Dist(S(2)*d*(m + p)/(m + S(2)*p + S(1)), Int((a + c*x**S(2))**p*(d + e*x)**(m + S(-1)), x), x) + Simp(e*(a + c*x**S(2))**(p + S(1))*(d + e*x)**(m + S(-1))/(c*(m + S(2)*p + S(1))), x) rule235 = ReplacementRule(pattern235, replacement235) pattern236 = Pattern(Integral((x_*WC('e', S(1)) + WC('d', S(0)))**m_*(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0)))**p_, x_), cons2, cons3, cons7, cons27, cons48, cons21, cons5, cons226, cons256, cons147, cons263) def replacement236(p, m, b, d, c, a, x, e): rubi.append(236) return Dist(c*(m + S(2)*p + S(2))/((-b*e + S(2)*c*d)*(m + p + S(1))), Int((d + e*x)**(m + S(1))*(a + b*x + c*x**S(2))**p, x), x) - Simp(e*(d + e*x)**m*(a + b*x + c*x**S(2))**(p + S(1))/((-b*e + S(2)*c*d)*(m + p + S(1))), x) rule236 = ReplacementRule(pattern236, replacement236) pattern237 = Pattern(Integral((a_ + x_**S(2)*WC('c', S(1)))**p_*(d_ + x_*WC('e', S(1)))**m_, x_), cons2, cons7, cons27, cons48, cons21, cons5, cons257, cons147, cons263) def replacement237(p, m, d, c, a, x, e): rubi.append(237) return Dist((m + S(2)*p + S(2))/(S(2)*d*(m + p + S(1))), Int((a + c*x**S(2))**p*(d + e*x)**(m + S(1)), x), x) - Simp(e*(a + c*x**S(2))**(p + S(1))*(d + e*x)**m/(S(2)*c*d*(m + p + S(1))), x) rule237 = ReplacementRule(pattern237, replacement237) pattern238 = Pattern(Integral(S(1)/(sqrt(x_*WC('e', S(1)) + WC('d', S(0)))*sqrt(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons226, cons256) def replacement238(b, d, c, a, x, e): rubi.append(238) return Dist(S(2)*e, Subst(Int(S(1)/(-b*e + S(2)*c*d + e**S(2)*x**S(2)), x), x, sqrt(a + b*x + c*x**S(2))/sqrt(d + e*x)), x) rule238 = ReplacementRule(pattern238, replacement238) pattern239 = Pattern(Integral(S(1)/(sqrt(a_ + x_**S(2)*WC('c', S(1)))*sqrt(d_ + x_*WC('e', S(1)))), x_), cons2, cons7, cons27, cons48, cons257) def replacement239(d, c, a, x, e): rubi.append(239) return Dist(S(2)*e, Subst(Int(S(1)/(S(2)*c*d + e**S(2)*x**S(2)), x), x, sqrt(a + c*x**S(2))/sqrt(d + e*x)), x) rule239 = ReplacementRule(pattern239, replacement239) pattern240 = Pattern(Integral((x_*WC('e', S(1)) + WC('d', S(0)))**m_*(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0)))**p_, x_), cons2, cons3, cons7, cons27, cons48, cons226, cons256, cons244, cons163, cons264, cons253, cons246) def replacement240(p, m, b, d, c, a, x, e): rubi.append(240) return -Dist(c*p/(e**S(2)*(m + p + S(1))), Int((d + e*x)**(m + S(2))*(a + b*x + c*x**S(2))**(p + S(-1)), x), x) + Simp((d + e*x)**(m + S(1))*(a + b*x + c*x**S(2))**p/(e*(m + p + S(1))), x) rule240 = ReplacementRule(pattern240, replacement240) pattern241 = Pattern(Integral((a_ + x_**S(2)*WC('c', S(1)))**p_*(d_ + x_*WC('e', S(1)))**m_, x_), cons2, cons7, cons27, cons48, cons257, cons244, cons163, cons264, cons253, cons246) def replacement241(p, m, d, c, a, x, e): rubi.append(241) return -Dist(c*p/(e**S(2)*(m + p + S(1))), Int((a + c*x**S(2))**(p + S(-1))*(d + e*x)**(m + S(2)), x), x) + Simp((a + c*x**S(2))**p*(d + e*x)**(m + S(1))/(e*(m + p + S(1))), x) rule241 = ReplacementRule(pattern241, replacement241) pattern242 = Pattern(Integral((x_*WC('e', S(1)) + WC('d', S(0)))**m_*(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0)))**p_, x_), cons2, cons3, cons7, cons27, cons48, cons226, cons256, cons244, cons163, cons265, cons238, cons246) def replacement242(p, m, b, d, c, a, x, e): rubi.append(242) return -Dist(p*(-b*e + S(2)*c*d)/(e**S(2)*(m + S(2)*p + S(1))), Int((d + e*x)**(m + S(1))*(a + b*x + c*x**S(2))**(p + S(-1)), x), x) + Simp((d + e*x)**(m + S(1))*(a + b*x + c*x**S(2))**p/(e*(m + S(2)*p + S(1))), x) rule242 = ReplacementRule(pattern242, replacement242) pattern243 = Pattern(Integral((a_ + x_**S(2)*WC('c', S(1)))**p_*(d_ + x_*WC('e', S(1)))**m_, x_), cons2, cons7, cons27, cons48, cons257, cons244, cons163, cons265, cons238, cons246) def replacement243(p, m, d, c, a, x, e): rubi.append(243) return -Dist(S(2)*c*d*p/(e**S(2)*(m + S(2)*p + S(1))), Int((a + c*x**S(2))**(p + S(-1))*(d + e*x)**(m + S(1)), x), x) + Simp((a + c*x**S(2))**p*(d + e*x)**(m + S(1))/(e*(m + S(2)*p + S(1))), x) rule243 = ReplacementRule(pattern243, replacement243) pattern244 = Pattern(Integral((x_*WC('e', S(1)) + WC('d', S(0)))**WC('m', S(1))*(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0)))**p_, x_), cons2, cons3, cons7, cons27, cons48, cons226, cons256, cons244, cons137, cons252, cons246) def replacement244(p, m, b, d, a, c, x, e): rubi.append(244) return -Dist((-b*e + S(2)*c*d)*(m + S(2)*p + S(2))/((p + S(1))*(-S(4)*a*c + b**S(2))), Int((d + e*x)**(m + S(-1))*(a + b*x + c*x**S(2))**(p + S(1)), x), x) + Simp((d + e*x)**m*(-b*e + S(2)*c*d)*(a + b*x + c*x**S(2))**(p + S(1))/(e*(p + S(1))*(-S(4)*a*c + b**S(2))), x) rule244 = ReplacementRule(pattern244, replacement244) pattern245 = Pattern(Integral((a_ + x_**S(2)*WC('c', S(1)))**p_*(d_ + x_*WC('e', S(1)))**WC('m', S(1)), x_), cons2, cons7, cons27, cons48, cons257, cons244, cons137, cons252, cons246) def replacement245(p, m, d, c, a, x, e): rubi.append(245) return Dist(d*(m + S(2)*p + S(2))/(S(2)*a*(p + S(1))), Int((a + c*x**S(2))**(p + S(1))*(d + e*x)**(m + S(-1)), x), x) - Simp(d*(a + c*x**S(2))**(p + S(1))*(d + e*x)**m/(S(2)*a*e*(p + S(1))), x) rule245 = ReplacementRule(pattern245, replacement245) pattern246 = Pattern(Integral((x_*WC('e', S(1)) + WC('d', S(0)))**m_*(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0)))**p_, x_), cons2, cons3, cons7, cons27, cons48, cons226, cons256, cons244, cons137, cons166, cons246) def replacement246(p, m, b, d, c, a, x, e): rubi.append(246) return -Dist(e**S(2)*(m + p)/(c*(p + S(1))), Int((d + e*x)**(m + S(-2))*(a + b*x + c*x**S(2))**(p + S(1)), x), x) + Simp(e*(d + e*x)**(m + S(-1))*(a + b*x + c*x**S(2))**(p + S(1))/(c*(p + S(1))), x) rule246 = ReplacementRule(pattern246, replacement246) pattern247 = Pattern(Integral((a_ + x_**S(2)*WC('c', S(1)))**p_*(d_ + x_*WC('e', S(1)))**m_, x_), cons2, cons7, cons27, cons48, cons257, cons244, cons137, cons166, cons246) def replacement247(p, m, d, c, a, x, e): rubi.append(247) return -Dist(e**S(2)*(m + p)/(c*(p + S(1))), Int((a + c*x**S(2))**(p + S(1))*(d + e*x)**(m + S(-2)), x), x) + Simp(e*(a + c*x**S(2))**(p + S(1))*(d + e*x)**(m + S(-1))/(c*(p + S(1))), x) rule247 = ReplacementRule(pattern247, replacement247) pattern248 = Pattern(Integral((x_*WC('e', S(1)) + WC('d', S(0)))**WC('m', S(1))*(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0)))**p_, x_), cons2, cons3, cons7, cons27, cons48, cons5, cons226, cons256, cons31, cons266, cons238, cons246) def replacement248(p, m, b, d, a, c, x, e): rubi.append(248) return Dist((m + p)*(-b*e + S(2)*c*d)/(c*(m + S(2)*p + S(1))), Int((d + e*x)**(m + S(-1))*(a + b*x + c*x**S(2))**p, x), x) + Simp(e*(d + e*x)**(m + S(-1))*(a + b*x + c*x**S(2))**(p + S(1))/(c*(m + S(2)*p + S(1))), x) rule248 = ReplacementRule(pattern248, replacement248) pattern249 = Pattern(Integral((a_ + x_**S(2)*WC('c', S(1)))**p_*(d_ + x_*WC('e', S(1)))**WC('m', S(1)), x_), cons2, cons7, cons27, cons48, cons5, cons257, cons31, cons266, cons238, cons246) def replacement249(p, m, d, c, a, x, e): rubi.append(249) return Dist(S(2)*d*(m + p)/(m + S(2)*p + S(1)), Int((a + c*x**S(2))**p*(d + e*x)**(m + S(-1)), x), x) + Simp(e*(a + c*x**S(2))**(p + S(1))*(d + e*x)**(m + S(-1))/(c*(m + S(2)*p + S(1))), x) rule249 = ReplacementRule(pattern249, replacement249) pattern250 = Pattern(Integral((x_*WC('e', S(1)) + WC('d', S(0)))**m_*(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0)))**p_, x_), cons2, cons3, cons7, cons27, cons48, cons5, cons226, cons256, cons31, cons267, cons253, cons246) def replacement250(p, m, b, d, c, a, x, e): rubi.append(250) return Dist(c*(m + S(2)*p + S(2))/((-b*e + S(2)*c*d)*(m + p + S(1))), Int((d + e*x)**(m + S(1))*(a + b*x + c*x**S(2))**p, x), x) - Simp(e*(d + e*x)**m*(a + b*x + c*x**S(2))**(p + S(1))/((-b*e + S(2)*c*d)*(m + p + S(1))), x) rule250 = ReplacementRule(pattern250, replacement250) pattern251 = Pattern(Integral((a_ + x_**S(2)*WC('c', S(1)))**p_*(d_ + x_*WC('e', S(1)))**m_, x_), cons2, cons7, cons27, cons48, cons5, cons257, cons31, cons267, cons253, cons246) def replacement251(p, m, d, c, a, x, e): rubi.append(251) return Dist((m + S(2)*p + S(2))/(S(2)*d*(m + p + S(1))), Int((a + c*x**S(2))**p*(d + e*x)**(m + S(1)), x), x) - Simp(e*(a + c*x**S(2))**(p + S(1))*(d + e*x)**m/(S(2)*c*d*(m + p + S(1))), x) rule251 = ReplacementRule(pattern251, replacement251) pattern252 = Pattern(Integral((x_*WC('e', S(1)))**WC('m', S(1))*(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)))**p_, x_), cons3, cons7, cons48, cons21, cons147) def replacement252(p, m, b, c, x, e): rubi.append(252) return Dist(x**(-m - p)*(e*x)**m*(b + c*x)**(-p)*(b*x + c*x**S(2))**p, Int(x**(m + p)*(b + c*x)**p, x), x) rule252 = ReplacementRule(pattern252, replacement252) pattern253 = Pattern(Integral((a_ + x_**S(2)*WC('c', S(1)))**p_*(d_ + x_*WC('e', S(1)))**WC('m', S(1)), x_), cons2, cons7, cons27, cons48, cons21, cons5, cons257, cons147, cons43, cons268) def replacement253(p, m, d, c, a, x, e): rubi.append(253) return Int((d + e*x)**(m + p)*(a/d + c*x/e)**p, x) rule253 = ReplacementRule(pattern253, replacement253) pattern254 = Pattern(Integral((d_ + x_*WC('e', S(1)))**WC('m', S(1))*(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0)))**p_, x_), cons2, cons3, cons7, cons27, cons48, cons21, cons226, cons256, cons147) def replacement254(p, m, b, d, c, a, x, e): rubi.append(254) return Dist((d + e*x)**(-FracPart(p))*(a/d + c*x/e)**(-FracPart(p))*(a + b*x + c*x**S(2))**FracPart(p), Int((d + e*x)**(m + p)*(a/d + c*x/e)**p, x), x) rule254 = ReplacementRule(pattern254, replacement254) pattern255 = Pattern(Integral((a_ + x_**S(2)*WC('c', S(1)))**p_*(d_ + x_*WC('e', S(1)))**WC('m', S(1)), x_), cons2, cons7, cons27, cons48, cons21, cons257, cons147) def replacement255(p, m, d, c, a, x, e): rubi.append(255) return Dist((a + c*x**S(2))**FracPart(p)*(d + e*x)**(-FracPart(p))*(a/d + c*x/e)**(-FracPart(p)), Int((d + e*x)**(m + p)*(a/d + c*x/e)**p, x), x) rule255 = ReplacementRule(pattern255, replacement255) pattern256 = Pattern(Integral(S(1)/((d_ + x_*WC('e', S(1)))*(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons226, cons47) def replacement256(b, d, c, a, x, e): rubi.append(256) return Dist(b**S(2)/(d**S(2)*(-S(4)*a*c + b**S(2))), Int((d + e*x)/(a + b*x + c*x**S(2)), x), x) + Dist(-S(4)*b*c/(d*(-S(4)*a*c + b**S(2))), Int(S(1)/(b + S(2)*c*x), x), x) rule256 = ReplacementRule(pattern256, replacement256) pattern257 = Pattern(Integral((d_ + x_*WC('e', S(1)))**m_*(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons21, cons5, cons226, cons47, cons242, cons54) def replacement257(p, m, b, d, c, a, x, e): rubi.append(257) return Simp(S(2)*c*(d + e*x)**(m + S(1))*(a + b*x + c*x**S(2))**(p + S(1))/(e*(p + S(1))*(-S(4)*a*c + b**S(2))), x) rule257 = ReplacementRule(pattern257, replacement257) pattern258 = Pattern(Integral((x_*WC('e', S(1)) + WC('d', S(0)))**m_*(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons21, cons226, cons47, cons128, cons269) def replacement258(p, m, b, d, c, a, x, e): rubi.append(258) return Int(ExpandIntegrand((d + e*x)**m*(a + b*x + c*x**S(2))**p, x), x) rule258 = ReplacementRule(pattern258, replacement258) pattern259 = Pattern(Integral((d_ + x_*WC('e', S(1)))**m_*(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons226, cons47, cons270, cons244, cons163, cons94, cons271, cons246) def replacement259(p, m, b, d, c, a, x, e): rubi.append(259) return -Dist(b*p/(d*e*(m + S(1))), Int((d + e*x)**(m + S(2))*(a + b*x + c*x**S(2))**(p + S(-1)), x), x) + Simp((d + e*x)**(m + S(1))*(a + b*x + c*x**S(2))**p/(e*(m + S(1))), x) rule259 = ReplacementRule(pattern259, replacement259) pattern260 = Pattern(Integral((d_ + x_*WC('e', S(1)))**m_*(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons21, cons226, cons47, cons270, cons13, cons163, cons272, cons273, cons31, cons246) def replacement260(p, m, b, d, c, a, x, e): rubi.append(260) return -Dist(d*p*(-S(4)*a*c + b**S(2))/(b*e*(m + S(2)*p + S(1))), Int((d + e*x)**m*(a + b*x + c*x**S(2))**(p + S(-1)), x), x) + Simp((d + e*x)**(m + S(1))*(a + b*x + c*x**S(2))**p/(e*(m + S(2)*p + S(1))), x) rule260 = ReplacementRule(pattern260, replacement260) pattern261 = Pattern(Integral((d_ + x_*WC('e', S(1)))**m_*(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0)))**p_, x_), cons2, cons3, cons7, cons27, cons48, cons226, cons47, cons270, cons244, cons137, cons166, cons246) def replacement261(p, m, b, d, c, a, x, e): rubi.append(261) return -Dist(d*e*(m + S(-1))/(b*(p + S(1))), Int((d + e*x)**(m + S(-2))*(a + b*x + c*x**S(2))**(p + S(1)), x), x) + Simp(d*(d + e*x)**(m + S(-1))*(a + b*x + c*x**S(2))**(p + S(1))/(b*(p + S(1))), x) rule261 = ReplacementRule(pattern261, replacement261) pattern262 = Pattern(Integral((d_ + x_*WC('e', S(1)))**m_*(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons21, cons226, cons47, cons270, cons13, cons137, cons274, cons31, cons246) def replacement262(p, m, b, d, c, a, x, e): rubi.append(262) return -Dist(S(2)*c*(m + S(2)*p + S(3))/((p + S(1))*(-S(4)*a*c + b**S(2))), Int((d + e*x)**m*(a + b*x + c*x**S(2))**(p + S(1)), x), x) + Simp(S(2)*c*(d + e*x)**(m + S(1))*(a + b*x + c*x**S(2))**(p + S(1))/(e*(p + S(1))*(-S(4)*a*c + b**S(2))), x) rule262 = ReplacementRule(pattern262, replacement262) pattern263 = Pattern(Integral(S(1)/((d_ + x_*WC('e', S(1)))*sqrt(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons226, cons47) def replacement263(b, d, c, a, x, e): rubi.append(263) return Dist(S(4)*c, Subst(Int(S(1)/(-S(4)*a*c*e + b**S(2)*e + S(4)*c*e*x**S(2)), x), x, sqrt(a + b*x + c*x**S(2))), x) rule263 = ReplacementRule(pattern263, replacement263) pattern264 = Pattern(Integral(S(1)/(sqrt(d_ + x_*WC('e', S(1)))*sqrt(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons226, cons47, cons275) def replacement264(b, d, c, a, x, e): rubi.append(264) return Dist(S(4)*sqrt(-c/(-S(4)*a*c + b**S(2)))/e, Subst(Int(S(1)/sqrt(Simp(-b**S(2)*x**S(4)/(d**S(2)*(-S(4)*a*c + b**S(2))) + S(1), x)), x), x, sqrt(d + e*x)), x) rule264 = ReplacementRule(pattern264, replacement264) pattern265 = Pattern(Integral(sqrt(d_ + x_*WC('e', S(1)))/sqrt(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0))), x_), cons2, cons3, cons7, cons27, cons48, cons226, cons47, cons275) def replacement265(b, d, c, a, x, e): rubi.append(265) return Dist(S(4)*sqrt(-c/(-S(4)*a*c + b**S(2)))/e, Subst(Int(x**S(2)/sqrt(Simp(-b**S(2)*x**S(4)/(d**S(2)*(-S(4)*a*c + b**S(2))) + S(1), x)), x), x, sqrt(d + e*x)), x) rule265 = ReplacementRule(pattern265, replacement265) pattern266 = Pattern(Integral((d_ + x_*WC('e', S(1)))**m_/sqrt(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0))), x_), cons2, cons3, cons7, cons27, cons48, cons226, cons47, cons276) def replacement266(m, b, d, c, a, x, e): rubi.append(266) return Dist(sqrt(-c*(a + b*x + c*x**S(2))/(-S(4)*a*c + b**S(2)))/sqrt(a + b*x + c*x**S(2)), Int((d + e*x)**m/sqrt(-a*c/(-S(4)*a*c + b**S(2)) - b*c*x/(-S(4)*a*c + b**S(2)) - c**S(2)*x**S(2)/(-S(4)*a*c + b**S(2))), x), x) rule266 = ReplacementRule(pattern266, replacement266) pattern267 = Pattern(Integral((d_ + x_*WC('e', S(1)))**m_*(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons5, cons226, cons47, cons270, cons31, cons166, cons238, cons277) def replacement267(p, m, b, d, c, a, x, e): rubi.append(267) return Dist(d**S(2)*(m + S(-1))*(-S(4)*a*c + b**S(2))/(b**S(2)*(m + S(2)*p + S(1))), Int((d + e*x)**(m + S(-2))*(a + b*x + c*x**S(2))**p, x), x) + Simp(S(2)*d*(d + e*x)**(m + S(-1))*(a + b*x + c*x**S(2))**(p + S(1))/(b*(m + S(2)*p + S(1))), x) rule267 = ReplacementRule(pattern267, replacement267) pattern268 = Pattern(Integral((d_ + x_*WC('e', S(1)))**m_*(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons5, cons226, cons47, cons270, cons31, cons94, cons278) def replacement268(p, m, b, d, c, a, x, e): rubi.append(268) return Dist(b**S(2)*(m + S(2)*p + S(3))/(d**S(2)*(m + S(1))*(-S(4)*a*c + b**S(2))), Int((d + e*x)**(m + S(2))*(a + b*x + c*x**S(2))**p, x), x) + Simp(-S(2)*b*(d + e*x)**(m + S(1))*(a + b*x + c*x**S(2))**(p + S(1))/(d*(m + S(1))*(-S(4)*a*c + b**S(2))), x) rule268 = ReplacementRule(pattern268, replacement268) pattern269 = Pattern(Integral((d_ + x_*WC('e', S(1)))**WC('m', S(1))*(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons21, cons5, cons226, cons47) def replacement269(p, m, b, d, c, a, x, e): rubi.append(269) return Dist(S(1)/e, Subst(Int(x**m*(a - b**S(2)/(S(4)*c) + c*x**S(2)/e**S(2))**p, x), x, d + e*x), x) rule269 = ReplacementRule(pattern269, replacement269) pattern270 = Pattern(Integral((x_*WC('e', S(1)) + WC('d', S(0)))**WC('m', S(1))*(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons21, cons226, cons279, cons239, cons128) def replacement270(p, m, b, d, a, c, x, e): rubi.append(270) return Int(ExpandIntegrand((d + e*x)**m*(a + b*x + c*x**S(2))**p, x), x) rule270 = ReplacementRule(pattern270, replacement270) pattern271 = Pattern(Integral((a_ + x_**S(2)*WC('c', S(1)))**WC('p', S(1))*(d_ + x_*WC('e', S(1)))**WC('m', S(1)), x_), cons2, cons7, cons27, cons48, cons21, cons280, cons128, cons281) def replacement271(p, m, d, c, a, x, e): rubi.append(271) return Int(ExpandIntegrand((a + c*x**S(2))**p*(d + e*x)**m, x), x) rule271 = ReplacementRule(pattern271, replacement271) def With272(b, d, c, a, x, e): q = Rt(-S(4)*a*c + b**S(2), S(2)) rubi.append(272) return Dist((c*d - e*(b/S(2) - q/S(2)))/q, Int(S(1)/(b/S(2) + c*x - q/S(2)), x), x) - Dist((c*d - e*(b/S(2) + q/S(2)))/q, Int(S(1)/(b/S(2) + c*x + q/S(2)), x), x) pattern272 = Pattern(Integral((x_*WC('e', S(1)) + WC('d', S(0)))/(a_ + x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons226, cons279, cons239, cons282) rule272 = ReplacementRule(pattern272, With272) def With273(d, c, a, x, e): q = Rt(-a*c, S(2)) rubi.append(273) return Dist(-c*d/(S(2)*q) + e/S(2), Int(S(1)/(c*x + q), x), x) + Dist(c*d/(S(2)*q) + e/S(2), Int(S(1)/(c*x - q), x), x) pattern273 = Pattern(Integral((d_ + x_*WC('e', S(1)))/(a_ + x_**S(2)*WC('c', S(1))), x_), cons2, cons7, cons27, cons48, cons280, cons283) rule273 = ReplacementRule(pattern273, With273) pattern274 = Pattern(Integral((x_*WC('e', S(1)) + WC('d', S(0)))/(a_ + x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons226, cons279, cons239, cons284) def replacement274(b, d, c, a, x, e): rubi.append(274) return Dist(e/(S(2)*c), Int((b + S(2)*c*x)/(a + b*x + c*x**S(2)), x), x) + Dist((-b*e + S(2)*c*d)/(S(2)*c), Int(S(1)/(a + b*x + c*x**S(2)), x), x) rule274 = ReplacementRule(pattern274, replacement274) pattern275 = Pattern(Integral((d_ + x_*WC('e', S(1)))/(a_ + x_**S(2)*WC('c', S(1))), x_), cons2, cons7, cons27, cons48, cons280, cons285) def replacement275(d, c, a, x, e): rubi.append(275) return Dist(d, Int(S(1)/(a + c*x**S(2)), x), x) + Dist(e, Int(x/(a + c*x**S(2)), x), x) rule275 = ReplacementRule(pattern275, replacement275) pattern276 = Pattern(Integral(sqrt(x_*WC('e', S(1)) + WC('d', S(0)))/(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0))), x_), cons2, cons3, cons7, cons27, cons48, cons226, cons279, cons239) def replacement276(b, d, c, a, x, e): rubi.append(276) return Dist(S(2)*e, Subst(Int(x**S(2)/(a*e**S(2) - b*d*e + c*d**S(2) + c*x**S(4) - x**S(2)*(-b*e + S(2)*c*d)), x), x, sqrt(d + e*x)), x) rule276 = ReplacementRule(pattern276, replacement276) pattern277 = Pattern(Integral(sqrt(d_ + x_*WC('e', S(1)))/(a_ + x_**S(2)*WC('c', S(1))), x_), cons2, cons7, cons27, cons48, cons280) def replacement277(d, c, a, x, e): rubi.append(277) return Dist(S(2)*e, Subst(Int(x**S(2)/(a*e**S(2) + c*d**S(2) - S(2)*c*d*x**S(2) + c*x**S(4)), x), x, sqrt(d + e*x)), x) rule277 = ReplacementRule(pattern277, replacement277) pattern278 = Pattern(Integral((x_*WC('e', S(1)) + WC('d', S(0)))**m_/(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0))), x_), cons2, cons3, cons7, cons27, cons48, cons226, cons279, cons239, cons17, cons166, cons286) def replacement278(m, b, d, c, a, x, e): rubi.append(278) return Int(PolynomialDivide((d + e*x)**m, a + b*x + c*x**S(2), x), x) rule278 = ReplacementRule(pattern278, replacement278) pattern279 = Pattern(Integral((d_ + x_*WC('e', S(1)))**m_/(a_ + x_**S(2)*WC('c', S(1))), x_), cons2, cons7, cons27, cons48, cons280, cons17, cons166, cons286) def replacement279(m, d, c, a, x, e): rubi.append(279) return Int(PolynomialDivide((d + e*x)**m, a + c*x**S(2), x), x) rule279 = ReplacementRule(pattern279, replacement279) pattern280 = Pattern(Integral((x_*WC('e', S(1)) + WC('d', S(0)))**m_/(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0))), x_), cons2, cons3, cons7, cons27, cons48, cons226, cons279, cons239, cons31, cons166) def replacement280(m, b, d, c, a, x, e): rubi.append(280) return Dist(S(1)/c, Int((d + e*x)**(m + S(-2))*Simp(-a*e**S(2) + c*d**S(2) + e*x*(-b*e + S(2)*c*d), x)/(a + b*x + c*x**S(2)), x), x) + Simp(e*(d + e*x)**(m + S(-1))/(c*(m + S(-1))), x) rule280 = ReplacementRule(pattern280, replacement280) pattern281 = Pattern(Integral((d_ + x_*WC('e', S(1)))**m_/(a_ + x_**S(2)*WC('c', S(1))), x_), cons2, cons7, cons27, cons48, cons280, cons31, cons166) def replacement281(m, d, c, a, x, e): rubi.append(281) return Dist(S(1)/c, Int((d + e*x)**(m + S(-2))*Simp(-a*e**S(2) + c*d**S(2) + S(2)*c*d*e*x, x)/(a + c*x**S(2)), x), x) + Simp(e*(d + e*x)**(m + S(-1))/(c*(m + S(-1))), x) rule281 = ReplacementRule(pattern281, replacement281) pattern282 = Pattern(Integral(S(1)/((x_*WC('e', S(1)) + WC('d', S(0)))*(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons226, cons279, cons239) def replacement282(b, d, c, a, x, e): rubi.append(282) return Dist(e**S(2)/(a*e**S(2) - b*d*e + c*d**S(2)), Int(S(1)/(d + e*x), x), x) + Dist(S(1)/(a*e**S(2) - b*d*e + c*d**S(2)), Int((-b*e + c*d - c*e*x)/(a + b*x + c*x**S(2)), x), x) rule282 = ReplacementRule(pattern282, replacement282) pattern283 = Pattern(Integral(S(1)/((a_ + x_**S(2)*WC('c', S(1)))*(d_ + x_*WC('e', S(1)))), x_), cons2, cons7, cons27, cons48, cons280) def replacement283(d, c, a, x, e): rubi.append(283) return Dist(e**S(2)/(a*e**S(2) + c*d**S(2)), Int(S(1)/(d + e*x), x), x) + Dist(S(1)/(a*e**S(2) + c*d**S(2)), Int((c*d - c*e*x)/(a + c*x**S(2)), x), x) rule283 = ReplacementRule(pattern283, replacement283) pattern284 = Pattern(Integral(S(1)/(sqrt(x_*WC('e', S(1)) + WC('d', S(0)))*(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons226, cons279, cons239) def replacement284(b, d, c, a, x, e): rubi.append(284) return Dist(S(2)*e, Subst(Int(S(1)/(a*e**S(2) - b*d*e + c*d**S(2) + c*x**S(4) - x**S(2)*(-b*e + S(2)*c*d)), x), x, sqrt(d + e*x)), x) rule284 = ReplacementRule(pattern284, replacement284) pattern285 = Pattern(Integral(S(1)/((a_ + x_**S(2)*WC('c', S(1)))*sqrt(d_ + x_*WC('e', S(1)))), x_), cons2, cons7, cons27, cons48, cons280) def replacement285(d, c, a, x, e): rubi.append(285) return Dist(S(2)*e, Subst(Int(S(1)/(a*e**S(2) + c*d**S(2) - S(2)*c*d*x**S(2) + c*x**S(4)), x), x, sqrt(d + e*x)), x) rule285 = ReplacementRule(pattern285, replacement285) pattern286 = Pattern(Integral((x_*WC('e', S(1)) + WC('d', S(0)))**m_/(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0))), x_), cons2, cons3, cons7, cons27, cons48, cons21, cons226, cons279, cons239, cons31, cons94) def replacement286(m, b, d, c, a, x, e): rubi.append(286) return Dist(S(1)/(a*e**S(2) - b*d*e + c*d**S(2)), Int((d + e*x)**(m + S(1))*Simp(-b*e + c*d - c*e*x, x)/(a + b*x + c*x**S(2)), x), x) + Simp(e*(d + e*x)**(m + S(1))/((m + S(1))*(a*e**S(2) - b*d*e + c*d**S(2))), x) rule286 = ReplacementRule(pattern286, replacement286) pattern287 = Pattern(Integral((d_ + x_*WC('e', S(1)))**m_/(a_ + x_**S(2)*WC('c', S(1))), x_), cons2, cons7, cons27, cons48, cons21, cons280, cons31, cons94) def replacement287(m, d, c, a, x, e): rubi.append(287) return Dist(c/(a*e**S(2) + c*d**S(2)), Int((d - e*x)*(d + e*x)**(m + S(1))/(a + c*x**S(2)), x), x) + Simp(e*(d + e*x)**(m + S(1))/((m + S(1))*(a*e**S(2) + c*d**S(2))), x) rule287 = ReplacementRule(pattern287, replacement287) pattern288 = Pattern(Integral((x_*WC('e', S(1)) + WC('d', S(0)))**m_/(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0))), x_), cons2, cons3, cons7, cons27, cons48, cons21, cons226, cons279, cons239, cons18) def replacement288(m, b, d, c, a, x, e): rubi.append(288) return Int(ExpandIntegrand((d + e*x)**m, S(1)/(a + b*x + c*x**S(2)), x), x) rule288 = ReplacementRule(pattern288, replacement288) pattern289 = Pattern(Integral((d_ + x_*WC('e', S(1)))**m_/(a_ + x_**S(2)*WC('c', S(1))), x_), cons2, cons7, cons27, cons48, cons21, cons280, cons18) def replacement289(m, d, c, a, x, e): rubi.append(289) return Int(ExpandIntegrand((d + e*x)**m, S(1)/(a + c*x**S(2)), x), x) rule289 = ReplacementRule(pattern289, replacement289) pattern290 = Pattern(Integral((x_*WC('e', S(1)) + WC('d', S(0)))/(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0)))**(S(3)/2), x_), cons2, cons3, cons7, cons27, cons48, cons226, cons279, cons239) def replacement290(b, d, c, a, x, e): rubi.append(290) return Simp(-S(2)*(-S(2)*a*e + b*d + x*(-b*e + S(2)*c*d))/((-S(4)*a*c + b**S(2))*sqrt(a + b*x + c*x**S(2))), x) rule290 = ReplacementRule(pattern290, replacement290) pattern291 = Pattern(Integral((d_ + x_*WC('e', S(1)))/(a_ + x_**S(2)*WC('c', S(1)))**(S(3)/2), x_), cons2, cons7, cons27, cons48, cons280) def replacement291(d, c, a, x, e): rubi.append(291) return Simp((-a*e + c*d*x)/(a*c*sqrt(a + c*x**S(2))), x) rule291 = ReplacementRule(pattern291, replacement291) pattern292 = Pattern(Integral((x_*WC('e', S(1)) + WC('d', S(0)))*(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0)))**p_, x_), cons2, cons3, cons7, cons27, cons48, cons226, cons279, cons239, cons13, cons137, cons230) def replacement292(p, b, d, c, a, x, e): rubi.append(292) return -Dist((S(2)*p + S(3))*(-b*e + S(2)*c*d)/((p + S(1))*(-S(4)*a*c + b**S(2))), Int((a + b*x + c*x**S(2))**(p + S(1)), x), x) + Simp((a + b*x + c*x**S(2))**(p + S(1))*(-S(2)*a*e + b*d + x*(-b*e + S(2)*c*d))/((p + S(1))*(-S(4)*a*c + b**S(2))), x) rule292 = ReplacementRule(pattern292, replacement292) pattern293 = Pattern(Integral((a_ + x_**S(2)*WC('c', S(1)))**p_*(d_ + x_*WC('e', S(1))), x_), cons2, cons7, cons27, cons48, cons280, cons13, cons137, cons230) def replacement293(p, d, c, a, x, e): rubi.append(293) return Dist(d*(S(2)*p + S(3))/(S(2)*a*(p + S(1))), Int((a + c*x**S(2))**(p + S(1)), x), x) + Simp((a + c*x**S(2))**(p + S(1))*(a*e - c*d*x)/(S(2)*a*c*(p + S(1))), x) rule293 = ReplacementRule(pattern293, replacement293) pattern294 = Pattern(Integral((x_*WC('e', S(1)) + WC('d', S(0)))*(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0)))**p_, x_), cons2, cons3, cons7, cons27, cons48, cons5, cons226, cons279, cons239, cons287) def replacement294(p, b, d, c, a, x, e): rubi.append(294) return Dist((-b*e + S(2)*c*d)/(S(2)*c), Int((a + b*x + c*x**S(2))**p, x), x) + Simp(e*(a + b*x + c*x**S(2))**(p + S(1))/(S(2)*c*(p + S(1))), x) rule294 = ReplacementRule(pattern294, replacement294) pattern295 = Pattern(Integral((a_ + x_**S(2)*WC('c', S(1)))**p_*(d_ + x_*WC('e', S(1))), x_), cons2, cons7, cons27, cons48, cons5, cons280, cons287) def replacement295(p, d, c, a, x, e): rubi.append(295) return Dist(d, Int((a + c*x**S(2))**p, x), x) + Simp(e*(a + c*x**S(2))**(p + S(1))/(S(2)*c*(p + S(1))), x) rule295 = ReplacementRule(pattern295, replacement295) pattern296 = Pattern(Integral((x_*WC('e', S(1)) + WC('d', S(0)))**m_*(a_ + x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)))**p_, x_), cons2, cons3, cons7, cons27, cons48, cons21, cons5, cons288, cons289, cons290, cons147) def replacement296(p, m, b, d, c, a, x, e): rubi.append(296) return Dist((d + e*x)**FracPart(p)*(a*d + c*e*x**S(3))**(-FracPart(p))*(a + b*x + c*x**S(2))**FracPart(p), Int((d + e*x)**(m - p)*(a*d + c*e*x**S(3))**p, x), x) rule296 = ReplacementRule(pattern296, replacement296) pattern297 = Pattern(Integral((x_*WC('e', S(1)) + WC('d', S(0)))**m_/sqrt(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1))), x_), cons3, cons7, cons27, cons48, cons291, cons239, cons31, cons292, cons293, cons294) def replacement297(m, b, d, c, x, e): rubi.append(297) return Int((d + e*x)**m/(sqrt(b*x)*sqrt(S(1) + c*x/b)), x) rule297 = ReplacementRule(pattern297, replacement297) pattern298 = Pattern(Integral((x_*WC('e', S(1)) + WC('d', S(0)))**m_/sqrt(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1))), x_), cons3, cons7, cons27, cons48, cons291, cons239, cons31, cons292) def replacement298(m, b, d, c, x, e): rubi.append(298) return Dist(sqrt(x)*sqrt(b + c*x)/sqrt(b*x + c*x**S(2)), Int((d + e*x)**m/(sqrt(x)*sqrt(b + c*x)), x), x) rule298 = ReplacementRule(pattern298, replacement298) pattern299 = Pattern(Integral(x_**m_/sqrt(a_ + x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1))), x_), cons2, cons3, cons7, cons226, cons295) def replacement299(m, b, c, a, x): rubi.append(299) return Dist(S(2), Subst(Int(x**(S(2)*m + S(1))/sqrt(a + b*x**S(2) + c*x**S(4)), x), x, sqrt(x)), x) rule299 = ReplacementRule(pattern299, replacement299) pattern300 = Pattern(Integral((e_*x_)**m_/sqrt(a_ + x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1))), x_), cons2, cons3, cons7, cons48, cons226, cons295) def replacement300(m, b, c, a, x, e): rubi.append(300) return Dist(x**(-m)*(e*x)**m, Int(x**m/sqrt(a + b*x + c*x**S(2)), x), x) rule300 = ReplacementRule(pattern300, replacement300) pattern301 = Pattern(Integral((x_*WC('e', S(1)) + WC('d', S(0)))**m_/sqrt(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0))), x_), cons2, cons3, cons7, cons27, cons48, cons226, cons279, cons239, cons295) def replacement301(m, b, d, c, a, x, e): rubi.append(301) return Dist(S(2)*sqrt(-c*(a + b*x + c*x**S(2))/(-S(4)*a*c + b**S(2)))*(S(2)*c*(d + e*x)/(-b*e + S(2)*c*d - e*Rt(-S(4)*a*c + b**S(2), S(2))))**(-m)*(d + e*x)**m*Rt(-S(4)*a*c + b**S(2), S(2))/(c*sqrt(a + b*x + c*x**S(2))), Subst(Int((S(2)*e*x**S(2)*Rt(-S(4)*a*c + b**S(2), S(2))/(-b*e + S(2)*c*d - e*Rt(-S(4)*a*c + b**S(2), S(2))) + S(1))**m/sqrt(-x**S(2) + S(1)), x), x, sqrt(S(2))*sqrt((b + S(2)*c*x + Rt(-S(4)*a*c + b**S(2), S(2)))/Rt(-S(4)*a*c + b**S(2), S(2)))/S(2)), x) rule301 = ReplacementRule(pattern301, replacement301) pattern302 = Pattern(Integral((d_ + x_*WC('e', S(1)))**m_/sqrt(a_ + x_**S(2)*WC('c', S(1))), x_), cons2, cons7, cons27, cons48, cons280, cons295) def replacement302(m, d, c, a, x, e): rubi.append(302) return Dist(S(2)*a*(c*(d + e*x)/(-a*e*Rt(-c/a, S(2)) + c*d))**(-m)*sqrt(S(1) + c*x**S(2)/a)*(d + e*x)**m*Rt(-c/a, S(2))/(c*sqrt(a + c*x**S(2))), Subst(Int((S(2)*a*e*x**S(2)*Rt(-c/a, S(2))/(-a*e*Rt(-c/a, S(2)) + c*d) + S(1))**m/sqrt(-x**S(2) + S(1)), x), x, sqrt(-x*Rt(-c/a, S(2))/S(2) + S(1)/2)), x) rule302 = ReplacementRule(pattern302, replacement302) pattern303 = Pattern(Integral((x_*WC('e', S(1)) + WC('d', S(0)))**m_*(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0)))**p_, x_), cons2, cons3, cons7, cons27, cons48, cons226, cons279, cons239, cons244, cons296, cons163) def replacement303(p, m, b, d, c, a, x, e): rubi.append(303) return Dist(p*(-S(4)*a*c + b**S(2))/(S(2)*(m + S(1))*(a*e**S(2) - b*d*e + c*d**S(2))), Int((d + e*x)**(m + S(2))*(a + b*x + c*x**S(2))**(p + S(-1)), x), x) - Simp((d + e*x)**(m + S(1))*(a + b*x + c*x**S(2))**p*(-S(2)*a*e + b*d + x*(-b*e + S(2)*c*d))/(S(2)*(m + S(1))*(a*e**S(2) - b*d*e + c*d**S(2))), x) rule303 = ReplacementRule(pattern303, replacement303) pattern304 = Pattern(Integral((a_ + x_**S(2)*WC('c', S(1)))**p_*(d_ + x_*WC('e', S(1)))**m_, x_), cons2, cons7, cons27, cons48, cons280, cons244, cons296, cons163) def replacement304(p, m, d, c, a, x, e): rubi.append(304) return -Dist(S(2)*a*c*p/((m + S(1))*(a*e**S(2) + c*d**S(2))), Int((a + c*x**S(2))**(p + S(-1))*(d + e*x)**(m + S(2)), x), x) - Simp((a + c*x**S(2))**p*(d + e*x)**(m + S(1))*(-S(2)*a*e + S(2)*c*d*x)/(S(2)*(m + S(1))*(a*e**S(2) + c*d**S(2))), x) rule304 = ReplacementRule(pattern304, replacement304) pattern305 = Pattern(Integral((x_*WC('e', S(1)) + WC('d', S(0)))**m_*(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0)))**p_, x_), cons2, cons3, cons7, cons27, cons48, cons226, cons279, cons239, cons244, cons296, cons137) def replacement305(p, m, b, d, c, a, x, e): rubi.append(305) return -Dist(S(2)*(S(2)*p + S(3))*(a*e**S(2) - b*d*e + c*d**S(2))/((p + S(1))*(-S(4)*a*c + b**S(2))), Int((d + e*x)**(m + S(-2))*(a + b*x + c*x**S(2))**(p + S(1)), x), x) + Simp((d + e*x)**(m + S(-1))*(a + b*x + c*x**S(2))**(p + S(1))*(-S(2)*a*e + b*d + x*(-b*e + S(2)*c*d))/((p + S(1))*(-S(4)*a*c + b**S(2))), x) rule305 = ReplacementRule(pattern305, replacement305) pattern306 = Pattern(Integral((a_ + x_**S(2)*WC('c', S(1)))**p_*(d_ + x_*WC('e', S(1)))**m_, x_), cons2, cons7, cons27, cons48, cons280, cons244, cons296, cons137) def replacement306(p, m, d, c, a, x, e): rubi.append(306) return Dist((S(2)*p + S(3))*(a*e**S(2) + c*d**S(2))/(S(2)*a*c*(p + S(1))), Int((a + c*x**S(2))**(p + S(1))*(d + e*x)**(m + S(-2)), x), x) + Simp((a + c*x**S(2))**(p + S(1))*(d + e*x)**(m + S(-1))*(a*e - c*d*x)/(S(2)*a*c*(p + S(1))), x) rule306 = ReplacementRule(pattern306, replacement306) pattern307 = Pattern(Integral(S(1)/((x_*WC('e', S(1)) + WC('d', S(0)))*sqrt(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons226, cons239) def replacement307(b, d, c, a, x, e): rubi.append(307) return Dist(S(-2), Subst(Int(S(1)/(S(4)*a*e**S(2) - S(4)*b*d*e + S(4)*c*d**S(2) - x**S(2)), x), x, (S(2)*a*e - b*d - x*(-b*e + S(2)*c*d))/sqrt(a + b*x + c*x**S(2))), x) rule307 = ReplacementRule(pattern307, replacement307) pattern308 = Pattern(Integral(S(1)/(sqrt(a_ + x_**S(2)*WC('c', S(1)))*(d_ + x_*WC('e', S(1)))), x_), cons2, cons7, cons27, cons48, cons297) def replacement308(d, c, a, x, e): rubi.append(308) return -Subst(Int(S(1)/(a*e**S(2) + c*d**S(2) - x**S(2)), x), x, (a*e - c*d*x)/sqrt(a + c*x**S(2))) rule308 = ReplacementRule(pattern308, replacement308) pattern309 = Pattern(Integral((x_*WC('e', S(1)) + WC('d', S(0)))**WC('m', S(1))*(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0)))**p_, x_), cons2, cons3, cons7, cons27, cons48, cons21, cons5, cons226, cons279, cons239, cons147, cons240) def replacement309(p, m, b, d, a, c, x, e): rubi.append(309) return -Simp(((b + S(2)*c*x + Rt(-S(4)*a*c + b**S(2), S(2)))*(-b*e + S(2)*c*d + e*Rt(-S(4)*a*c + b**S(2), S(2)))/((b + S(2)*c*x - Rt(-S(4)*a*c + b**S(2), S(2)))*(-b*e + S(2)*c*d - e*Rt(-S(4)*a*c + b**S(2), S(2)))))**(-p)*(d + e*x)**(m + S(1))*(a + b*x + c*x**S(2))**p*(b + S(2)*c*x - Rt(-S(4)*a*c + b**S(2), S(2)))*Hypergeometric2F1(m + S(1), -p, m + S(2), -S(4)*c*(d + e*x)*Rt(-S(4)*a*c + b**S(2), S(2))/((b + S(2)*c*x - Rt(-S(4)*a*c + b**S(2), S(2)))*(-b*e + S(2)*c*d - e*Rt(-S(4)*a*c + b**S(2), S(2)))))/((m + S(1))*(-b*e + S(2)*c*d + e*Rt(-S(4)*a*c + b**S(2), S(2)))), x) rule309 = ReplacementRule(pattern309, replacement309) pattern310 = Pattern(Integral((a_ + x_**S(2)*WC('c', S(1)))**p_*(d_ + x_*WC('e', S(1)))**WC('m', S(1)), x_), cons2, cons7, cons27, cons48, cons21, cons5, cons280, cons147, cons240) def replacement310(p, m, d, c, a, x, e): rubi.append(310) return Simp(((c*d + e*Rt(-a*c, S(2)))*(c*x + Rt(-a*c, S(2)))/((c*d - e*Rt(-a*c, S(2)))*(c*x - Rt(-a*c, S(2)))))**(-p)*(a + c*x**S(2))**p*(d + e*x)**(m + S(1))*(-c*x + Rt(-a*c, S(2)))*Hypergeometric2F1(m + S(1), -p, m + S(2), S(2)*c*(d + e*x)*Rt(-a*c, S(2))/((c*d - e*Rt(-a*c, S(2)))*(-c*x + Rt(-a*c, S(2)))))/((m + S(1))*(c*d + e*Rt(-a*c, S(2)))), x) rule310 = ReplacementRule(pattern310, replacement310) pattern311 = Pattern(Integral((x_*WC('e', S(1)) + WC('d', S(0)))**m_*(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0)))**p_, x_), cons2, cons3, cons7, cons27, cons48, cons21, cons5, cons226, cons279, cons239, cons242, cons13, cons137) def replacement311(p, m, b, d, c, a, x, e): rubi.append(311) return Dist(m*(-b*e + S(2)*c*d)/((p + S(1))*(-S(4)*a*c + b**S(2))), Int((d + e*x)**(m + S(-1))*(a + b*x + c*x**S(2))**(p + S(1)), x), x) + Simp((b + S(2)*c*x)*(d + e*x)**m*(a + b*x + c*x**S(2))**(p + S(1))/((p + S(1))*(-S(4)*a*c + b**S(2))), x) rule311 = ReplacementRule(pattern311, replacement311) pattern312 = Pattern(Integral((a_ + x_**S(2)*WC('c', S(1)))**p_*(d_ + x_*WC('e', S(1)))**m_, x_), cons2, cons7, cons27, cons48, cons21, cons5, cons280, cons242, cons13, cons137) def replacement312(p, m, d, c, a, x, e): rubi.append(312) return -Dist(d*m/(S(2)*a*(p + S(1))), Int((a + c*x**S(2))**(p + S(1))*(d + e*x)**(m + S(-1)), x), x) - Simp(x*(a + c*x**S(2))**(p + S(1))*(d + e*x)**m/(S(2)*a*(p + S(1))), x) rule312 = ReplacementRule(pattern312, replacement312) pattern313 = Pattern(Integral((x_*WC('e', S(1)) + WC('d', S(0)))**m_*(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0)))**p_, x_), cons2, cons3, cons7, cons27, cons48, cons21, cons5, cons226, cons279, cons239, cons242) def replacement313(p, m, b, d, c, a, x, e): rubi.append(313) return Dist((-b*e + S(2)*c*d)/(S(2)*a*e**S(2) - S(2)*b*d*e + S(2)*c*d**S(2)), Int((d + e*x)**(m + S(1))*(a + b*x + c*x**S(2))**p, x), x) + Simp(e*(d + e*x)**(m + S(1))*(a + b*x + c*x**S(2))**(p + S(1))/((m + S(1))*(a*e**S(2) - b*d*e + c*d**S(2))), x) rule313 = ReplacementRule(pattern313, replacement313) pattern314 = Pattern(Integral((a_ + x_**S(2)*WC('c', S(1)))**p_*(d_ + x_*WC('e', S(1)))**m_, x_), cons2, cons7, cons27, cons48, cons21, cons5, cons280, cons242) def replacement314(p, m, d, c, a, x, e): rubi.append(314) return Dist(c*d/(a*e**S(2) + c*d**S(2)), Int((a + c*x**S(2))**p*(d + e*x)**(m + S(1)), x), x) + Simp(e*(a + c*x**S(2))**(p + S(1))*(d + e*x)**(m + S(1))/((m + S(1))*(a*e**S(2) + c*d**S(2))), x) rule314 = ReplacementRule(pattern314, replacement314) pattern315 = Pattern(Integral((x_*WC('e', S(1)) + WC('d', S(0)))**m_*(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0)))**p_, x_), cons2, cons3, cons7, cons27, cons48, cons21, cons226, cons279, cons239, cons13, cons163, cons298, cons66, cons299, cons300) def replacement315(p, m, b, d, c, a, x, e): rubi.append(315) return -Dist(p/(e*(m + S(1))), Int((b + S(2)*c*x)*(d + e*x)**(m + S(1))*(a + b*x + c*x**S(2))**(p + S(-1)), x), x) + Simp((d + e*x)**(m + S(1))*(a + b*x + c*x**S(2))**p/(e*(m + S(1))), x) rule315 = ReplacementRule(pattern315, replacement315) pattern316 = Pattern(Integral((a_ + x_**S(2)*WC('c', S(1)))**p_*(d_ + x_*WC('e', S(1)))**m_, x_), cons2, cons7, cons27, cons48, cons21, cons280, cons13, cons163, cons298, cons66, cons299, cons301) def replacement316(p, m, d, c, a, x, e): rubi.append(316) return -Dist(S(2)*c*p/(e*(m + S(1))), Int(x*(a + c*x**S(2))**(p + S(-1))*(d + e*x)**(m + S(1)), x), x) + Simp((a + c*x**S(2))**p*(d + e*x)**(m + S(1))/(e*(m + S(1))), x) rule316 = ReplacementRule(pattern316, replacement316) pattern317 = Pattern(Integral((x_*WC('e', S(1)) + WC('d', S(0)))**m_*(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0)))**p_, x_), cons2, cons3, cons7, cons27, cons48, cons21, cons226, cons279, cons239, cons13, cons163, cons238, cons302, cons303, cons300) def replacement317(p, m, b, d, c, a, x, e): rubi.append(317) return -Dist(p/(e*(m + S(2)*p + S(1))), Int((d + e*x)**m*(a + b*x + c*x**S(2))**(p + S(-1))*Simp(-S(2)*a*e + b*d + x*(-b*e + S(2)*c*d), x), x), x) + Simp((d + e*x)**(m + S(1))*(a + b*x + c*x**S(2))**p/(e*(m + S(2)*p + S(1))), x) rule317 = ReplacementRule(pattern317, replacement317) pattern318 = Pattern(Integral((a_ + x_**S(2)*WC('c', S(1)))**p_*(d_ + x_*WC('e', S(1)))**m_, x_), cons2, cons7, cons27, cons48, cons21, cons280, cons13, cons163, cons238, cons302, cons303, cons301) def replacement318(p, m, d, c, a, x, e): rubi.append(318) return Dist(S(2)*p/(e*(m + S(2)*p + S(1))), Int((a + c*x**S(2))**(p + S(-1))*(d + e*x)**m*Simp(a*e - c*d*x, x), x), x) + Simp((a + c*x**S(2))**p*(d + e*x)**(m + S(1))/(e*(m + S(2)*p + S(1))), x) rule318 = ReplacementRule(pattern318, replacement318) pattern319 = Pattern(Integral((x_*WC('e', S(1)) + WC('d', S(0)))**m_*(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0)))**p_, x_), cons2, cons3, cons7, cons27, cons48, cons226, cons279, cons239, cons244, cons137, cons168, cons304, cons300) def replacement319(p, m, b, d, c, a, x, e): rubi.append(319) return -Dist(S(1)/((p + S(1))*(-S(4)*a*c + b**S(2))), Int((d + e*x)**(m + S(-1))*(a + b*x + c*x**S(2))**(p + S(1))*(b*e*m + S(2)*c*d*(S(2)*p + S(3)) + S(2)*c*e*x*(m + S(2)*p + S(3))), x), x) + Simp((b + S(2)*c*x)*(d + e*x)**m*(a + b*x + c*x**S(2))**(p + S(1))/((p + S(1))*(-S(4)*a*c + b**S(2))), x) rule319 = ReplacementRule(pattern319, replacement319) pattern320 = Pattern(Integral((a_ + x_**S(2)*WC('c', S(1)))**p_*(d_ + x_*WC('e', S(1)))**m_, x_), cons2, cons7, cons27, cons48, cons280, cons244, cons137, cons168, cons304, cons301) def replacement320(p, m, d, c, a, x, e): rubi.append(320) return Dist(S(1)/(S(2)*a*(p + S(1))), Int((a + c*x**S(2))**(p + S(1))*(d + e*x)**(m + S(-1))*(d*(S(2)*p + S(3)) + e*x*(m + S(2)*p + S(3))), x), x) - Simp(x*(a + c*x**S(2))**(p + S(1))*(d + e*x)**m/(S(2)*a*(p + S(1))), x) rule320 = ReplacementRule(pattern320, replacement320) pattern321 = Pattern(Integral((x_*WC('e', S(1)) + WC('d', S(0)))**m_*(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0)))**p_, x_), cons2, cons3, cons7, cons27, cons48, cons226, cons279, cons239, cons244, cons137, cons166, cons300) def replacement321(p, m, b, d, c, a, x, e): rubi.append(321) return Dist(S(1)/((p + S(1))*(-S(4)*a*c + b**S(2))), Int((d + e*x)**(m + S(-2))*(a + b*x + c*x**S(2))**(p + S(1))*Simp(-S(2)*c*d**S(2)*(S(2)*p + S(3)) + e*x*(b*e - S(2)*c*d)*(m + S(2)*p + S(2)) + e*(S(2)*a*e*(m + S(-1)) + b*d*(-m + S(2)*p + S(4))), x), x), x) + Simp((d + e*x)**(m + S(-1))*(a + b*x + c*x**S(2))**(p + S(1))*(-S(2)*a*e + b*d + x*(-b*e + S(2)*c*d))/((p + S(1))*(-S(4)*a*c + b**S(2))), x) rule321 = ReplacementRule(pattern321, replacement321) pattern322 = Pattern(Integral((a_ + x_**S(2)*WC('c', S(1)))**p_*(d_ + x_*WC('e', S(1)))**m_, x_), cons2, cons7, cons27, cons48, cons280, cons244, cons137, cons166, cons301) def replacement322(p, m, d, c, a, x, e): rubi.append(322) return Dist(-S(1)/(S(2)*a*c*(p + S(1))), Int((a + c*x**S(2))**(p + S(1))*(d + e*x)**(m + S(-2))*Simp(a*e**S(2)*(m + S(-1)) - c*d**S(2)*(S(2)*p + S(3)) - c*d*e*x*(m + S(2)*p + S(2)), x), x), x) + Simp((a + c*x**S(2))**(p + S(1))*(d + e*x)**(m + S(-1))*(a*e - c*d*x)/(S(2)*a*c*(p + S(1))), x) rule322 = ReplacementRule(pattern322, replacement322) pattern323 = Pattern(Integral((x_*WC('e', S(1)) + WC('d', S(0)))**m_*(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0)))**p_, x_), cons2, cons3, cons7, cons27, cons48, cons21, cons226, cons279, cons239, cons13, cons137, cons300) def replacement323(p, m, b, d, c, a, x, e): rubi.append(323) return Dist(S(1)/((p + S(1))*(-S(4)*a*c + b**S(2))*(a*e**S(2) - b*d*e + c*d**S(2))), Int((d + e*x)**m*(a + b*x + c*x**S(2))**(p + S(1))*Simp(-S(2)*a*c*e**S(2)*(m + S(2)*p + S(3)) + b**S(2)*e**S(2)*(m + p + S(2)) + b*c*d*e*(-m + S(2)*p + S(2)) - S(2)*c**S(2)*d**S(2)*(S(2)*p + S(3)) - c*e*x*(-b*e + S(2)*c*d)*(m + S(2)*p + S(4)), x), x), x) + Simp((d + e*x)**(m + S(1))*(a + b*x + c*x**S(2))**(p + S(1))*(S(2)*a*c*e - b**S(2)*e + b*c*d + c*x*(-b*e + S(2)*c*d))/((p + S(1))*(-S(4)*a*c + b**S(2))*(a*e**S(2) - b*d*e + c*d**S(2))), x) rule323 = ReplacementRule(pattern323, replacement323) pattern324 = Pattern(Integral((a_ + x_**S(2)*WC('c', S(1)))**p_*(d_ + x_*WC('e', S(1)))**m_, x_), cons2, cons7, cons27, cons48, cons21, cons280, cons13, cons137, cons301) def replacement324(p, m, d, c, a, x, e): rubi.append(324) return Dist(S(1)/(S(2)*a*(p + S(1))*(a*e**S(2) + c*d**S(2))), Int((a + c*x**S(2))**(p + S(1))*(d + e*x)**m*Simp(a*e**S(2)*(m + S(2)*p + S(3)) + c*d**S(2)*(S(2)*p + S(3)) + c*d*e*x*(m + S(2)*p + S(4)), x), x), x) - Simp((a + c*x**S(2))**(p + S(1))*(d + e*x)**(m + S(1))*(a*e + c*d*x)/(S(2)*a*(p + S(1))*(a*e**S(2) + c*d**S(2))), x) rule324 = ReplacementRule(pattern324, replacement324) pattern325 = Pattern(Integral((x_*WC('e', S(1)) + WC('d', S(0)))**m_*(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0)))**p_, x_), cons2, cons3, cons7, cons27, cons48, cons21, cons5, cons226, cons279, cons239, cons305, cons238, cons300) def replacement325(p, m, b, d, c, a, x, e): rubi.append(325) return Dist(S(1)/(c*(m + S(2)*p + S(1))), Int((d + e*x)**(m + S(-2))*(a + b*x + c*x**S(2))**p*Simp(c*d**S(2)*(m + S(2)*p + S(1)) + e*x*(m + p)*(-b*e + S(2)*c*d) - e*(a*e*(m + S(-1)) + b*d*(p + S(1))), x), x), x) + Simp(e*(d + e*x)**(m + S(-1))*(a + b*x + c*x**S(2))**(p + S(1))/(c*(m + S(2)*p + S(1))), x) rule325 = ReplacementRule(pattern325, replacement325) pattern326 = Pattern(Integral((a_ + x_**S(2)*WC('c', S(1)))**p_*(d_ + x_*WC('e', S(1)))**m_, x_), cons2, cons7, cons27, cons48, cons21, cons5, cons280, cons305, cons238, cons301) def replacement326(p, m, d, c, a, x, e): rubi.append(326) return Dist(S(1)/(c*(m + S(2)*p + S(1))), Int((a + c*x**S(2))**p*(d + e*x)**(m + S(-2))*Simp(-a*e**S(2)*(m + S(-1)) + c*d**S(2)*(m + S(2)*p + S(1)) + S(2)*c*d*e*x*(m + p), x), x), x) + Simp(e*(a + c*x**S(2))**(p + S(1))*(d + e*x)**(m + S(-1))/(c*(m + S(2)*p + S(1))), x) rule326 = ReplacementRule(pattern326, replacement326) pattern327 = Pattern(Integral((x_*WC('e', S(1)) + WC('d', S(0)))**m_*(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0)))**p_, x_), cons2, cons3, cons7, cons27, cons48, cons21, cons5, cons226, cons279, cons239, cons306) def replacement327(p, m, b, d, c, a, x, e): rubi.append(327) return Dist(S(1)/((m + S(1))*(a*e**S(2) - b*d*e + c*d**S(2))), Int((d + e*x)**(m + S(1))*(a + b*x + c*x**S(2))**p*Simp(-b*e*(m + p + S(2)) + c*d*(m + S(1)) - c*e*x*(m + S(2)*p + S(3)), x), x), x) + Simp(e*(d + e*x)**(m + S(1))*(a + b*x + c*x**S(2))**(p + S(1))/((m + S(1))*(a*e**S(2) - b*d*e + c*d**S(2))), x) rule327 = ReplacementRule(pattern327, replacement327) pattern328 = Pattern(Integral((a_ + x_**S(2)*WC('c', S(1)))**p_*(d_ + x_*WC('e', S(1)))**m_, x_), cons2, cons7, cons27, cons48, cons21, cons5, cons280, cons307) def replacement328(p, m, d, c, a, x, e): rubi.append(328) return Dist(c/((m + S(1))*(a*e**S(2) + c*d**S(2))), Int((a + c*x**S(2))**p*(d + e*x)**(m + S(1))*Simp(d*(m + S(1)) - e*x*(m + S(2)*p + S(3)), x), x), x) + Simp(e*(a + c*x**S(2))**(p + S(1))*(d + e*x)**(m + S(1))/((m + S(1))*(a*e**S(2) + c*d**S(2))), x) rule328 = ReplacementRule(pattern328, replacement328) def With329(b, d, c, a, x, e): q = Rt(S(3)*c*e**S(2)*(-b*e + S(2)*c*d), S(3)) rubi.append(329) return -Simp(S(3)*c*e*log(d + e*x)/(S(2)*q**S(2)), x) + Simp(S(3)*c*e*log(-b*e + c*d - c*e*x - q*(a + b*x + c*x**S(2))**(S(1)/3))/(S(2)*q**S(2)), x) - Simp(sqrt(S(3))*c*e*ArcTan(sqrt(S(3))/S(3) + S(2)*sqrt(S(3))*(-b*e + c*d - c*e*x)/(S(3)*q*(a + b*x + c*x**S(2))**(S(1)/3)))/q**S(2), x) pattern329 = Pattern(Integral(S(1)/((x_*WC('e', S(1)) + WC('d', S(0)))*(a_ + x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)))**(S(1)/3)), x_), cons2, cons3, cons7, cons27, cons48, cons239, cons308, cons309) rule329 = ReplacementRule(pattern329, With329) def With330(d, c, a, x, e): q = Rt(S(6)*c**S(2)*e**S(2)/d**S(2), S(3)) rubi.append(330) return -Simp(S(3)*c*e*log(d + e*x)/(S(2)*d**S(2)*q**S(2)), x) + Simp(S(3)*c*e*log(c*d - c*e*x - d*q*(a + c*x**S(2))**(S(1)/3))/(S(2)*d**S(2)*q**S(2)), x) - Simp(sqrt(S(3))*c*e*ArcTan(S(2)*sqrt(S(3))*c*(d - e*x)/(S(3)*d*q*(a + c*x**S(2))**(S(1)/3)) + sqrt(S(3))/S(3))/(d**S(2)*q**S(2)), x) pattern330 = Pattern(Integral(S(1)/((a_ + x_**S(2)*WC('c', S(1)))**(S(1)/3)*(d_ + x_*WC('e', S(1)))), x_), cons2, cons7, cons27, cons48, cons310) rule330 = ReplacementRule(pattern330, With330) def With331(b, d, c, a, x, e): q = Rt(-S(3)*c*e**S(2)*(-b*e + S(2)*c*d), S(3)) rubi.append(331) return -Simp(S(3)*c*e*log(d + e*x)/(S(2)*q**S(2)), x) + Simp(S(3)*c*e*log(-b*e + c*d - c*e*x + q*(a + b*x + c*x**S(2))**(S(1)/3))/(S(2)*q**S(2)), x) - Simp(sqrt(S(3))*c*e*ArcTan(sqrt(S(3))/S(3) - S(2)*sqrt(S(3))*(-b*e + c*d - c*e*x)/(S(3)*q*(a + b*x + c*x**S(2))**(S(1)/3)))/q**S(2), x) pattern331 = Pattern(Integral(S(1)/((x_*WC('e', S(1)) + WC('d', S(0)))*(a_ + x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)))**(S(1)/3)), x_), cons2, cons3, cons7, cons27, cons48, cons239, cons308, cons311) rule331 = ReplacementRule(pattern331, With331) def With332(b, d, c, a, x, e): q = Rt(-S(4)*a*c + b**S(2), S(2)) rubi.append(332) return Dist((b + S(2)*c*x - q)**(S(1)/3)*(b + S(2)*c*x + q)**(S(1)/3)/(a + b*x + c*x**S(2))**(S(1)/3), Int(S(1)/((d + e*x)*(b + S(2)*c*x - q)**(S(1)/3)*(b + S(2)*c*x + q)**(S(1)/3)), x), x) pattern332 = Pattern(Integral(S(1)/((x_*WC('e', S(1)) + WC('d', S(0)))*(a_ + x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)))**(S(1)/3)), x_), cons2, cons3, cons7, cons27, cons48, cons226, cons312) rule332 = ReplacementRule(pattern332, With332) pattern333 = Pattern(Integral(S(1)/((a_ + x_**S(2)*WC('c', S(1)))**(S(1)/4)*(d_ + x_*WC('e', S(1)))), x_), cons2, cons7, cons27, cons48, cons280) def replacement333(d, c, a, x, e): rubi.append(333) return Dist(d, Int(S(1)/((a + c*x**S(2))**(S(1)/4)*(d**S(2) - e**S(2)*x**S(2))), x), x) - Dist(e, Int(x/((a + c*x**S(2))**(S(1)/4)*(d**S(2) - e**S(2)*x**S(2))), x), x) rule333 = ReplacementRule(pattern333, replacement333) pattern334 = Pattern(Integral(S(1)/((a_ + x_**S(2)*WC('c', S(1)))**(S(3)/4)*(d_ + x_*WC('e', S(1)))), x_), cons2, cons7, cons27, cons48, cons280) def replacement334(d, c, a, x, e): rubi.append(334) return Dist(d, Int(S(1)/((a + c*x**S(2))**(S(3)/4)*(d**S(2) - e**S(2)*x**S(2))), x), x) - Dist(e, Int(x/((a + c*x**S(2))**(S(3)/4)*(d**S(2) - e**S(2)*x**S(2))), x), x) rule334 = ReplacementRule(pattern334, replacement334) pattern335 = Pattern(Integral((x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0)))**p_/(x_*WC('e', S(1)) + WC('d', S(0))), x_), cons2, cons3, cons7, cons27, cons48, cons5, cons232, cons229) def replacement335(p, b, d, c, a, x, e): rubi.append(335) return Dist((-S(4)*c/(-S(4)*a*c + b**S(2)))**(-p), Subst(Int(Simp(-x**S(2)/(-S(4)*a*c + b**S(2)) + S(1), x)**p/Simp(-b*e + S(2)*c*d + e*x, x), x), x, b + S(2)*c*x), x) rule335 = ReplacementRule(pattern335, replacement335) pattern336 = Pattern(Integral((x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0)))**p_/(x_*WC('e', S(1)) + WC('d', S(0))), x_), cons2, cons3, cons7, cons27, cons48, cons5, cons313, cons229) def replacement336(p, b, d, c, a, x, e): rubi.append(336) return Dist((-c*(a + b*x + c*x**S(2))/(-S(4)*a*c + b**S(2)))**(-p)*(a + b*x + c*x**S(2))**p, Int((-a*c/(-S(4)*a*c + b**S(2)) - b*c*x/(-S(4)*a*c + b**S(2)) - c**S(2)*x**S(2)/(-S(4)*a*c + b**S(2)))**p/(d + e*x), x), x) rule336 = ReplacementRule(pattern336, replacement336) pattern337 = Pattern(Integral((a_ + x_**S(2)*WC('c', S(1)))**p_*(d_ + x_*WC('e', S(1)))**WC('m', S(1)), x_), cons2, cons7, cons27, cons48, cons21, cons5, cons280, cons147, cons43, cons293) def replacement337(p, m, d, c, a, x, e): rubi.append(337) return Int((d + e*x)**m*(-x*Rt(-c, S(2)) + Rt(a, S(2)))**p*(x*Rt(-c, S(2)) + Rt(a, S(2)))**p, x) rule337 = ReplacementRule(pattern337, replacement337) def With338(p, m, b, d, a, c, x, e): q = Rt(-S(4)*a*c + b**S(2), S(2)) rubi.append(338) return -Dist((e*(b + S(2)*c*x - q)/(S(2)*c*(d + e*x)))**(-p)*(e*(b + S(2)*c*x + q)/(S(2)*c*(d + e*x)))**(-p)*(a + b*x + c*x**S(2))**p*(S(1)/(d + e*x))**(S(2)*p)/e, Subst(Int(x**(-m - S(2)*p + S(-2))*Simp(-x*(d - e*(b - q)/(S(2)*c)) + S(1), x)**p*Simp(-x*(d - e*(b + q)/(S(2)*c)) + S(1), x)**p, x), x, S(1)/(d + e*x)), x) pattern338 = Pattern(Integral((x_*WC('e', S(1)) + WC('d', S(0)))**WC('m', S(1))*(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0)))**p_, x_), cons2, cons3, cons7, cons27, cons48, cons5, cons226, cons279, cons239, cons147, cons84) rule338 = ReplacementRule(pattern338, With338) def With339(p, m, d, c, a, x, e): q = Rt(-a*c, S(2)) rubi.append(339) return -Dist((e*(c*x + q)/(c*(d + e*x)))**(-p)*(-e*(-c*x + q)/(c*(d + e*x)))**(-p)*(a + c*x**S(2))**p*(S(1)/(d + e*x))**(S(2)*p)/e, Subst(Int(x**(-m - S(2)*p + S(-2))*Simp(-x*(d - e*q/c) + S(1), x)**p*Simp(-x*(d + e*q/c) + S(1), x)**p, x), x, S(1)/(d + e*x)), x) pattern339 = Pattern(Integral((a_ + x_**S(2)*WC('c', S(1)))**p_*(d_ + x_*WC('e', S(1)))**WC('m', S(1)), x_), cons2, cons7, cons27, cons48, cons5, cons280, cons147, cons84) rule339 = ReplacementRule(pattern339, With339) def With340(p, m, b, d, a, c, x, e): q = Rt(-S(4)*a*c + b**S(2), S(2)) rubi.append(340) return Dist((-(d + e*x)/(d - e*(b - q)/(S(2)*c)) + S(1))**(-p)*(-(d + e*x)/(d - e*(b + q)/(S(2)*c)) + S(1))**(-p)*(a + b*x + c*x**S(2))**p/e, Subst(Int(x**m*Simp(-x/(d - e*(b - q)/(S(2)*c)) + S(1), x)**p*Simp(-x/(d - e*(b + q)/(S(2)*c)) + S(1), x)**p, x), x, d + e*x), x) pattern340 = Pattern(Integral((x_*WC('e', S(1)) + WC('d', S(0)))**WC('m', S(1))*(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0)))**p_, x_), cons2, cons3, cons7, cons27, cons48, cons21, cons5, cons226, cons279, cons239, cons147) rule340 = ReplacementRule(pattern340, With340) def With341(p, m, d, c, a, x, e): q = Rt(-a*c, S(2)) rubi.append(341) return Dist((a + c*x**S(2))**p*(-(d + e*x)/(d - e*q/c) + S(1))**(-p)*(-(d + e*x)/(d + e*q/c) + S(1))**(-p)/e, Subst(Int(x**m*Simp(-x/(d - e*q/c) + S(1), x)**p*Simp(-x/(d + e*q/c) + S(1), x)**p, x), x, d + e*x), x) pattern341 = Pattern(Integral((a_ + x_**S(2)*WC('c', S(1)))**p_*(d_ + x_*WC('e', S(1)))**WC('m', S(1)), x_), cons2, cons7, cons27, cons48, cons21, cons5, cons280, cons147) rule341 = ReplacementRule(pattern341, With341) pattern342 = Pattern(Integral((u_*WC('e', S(1)) + WC('d', S(0)))**WC('m', S(1))*(a_ + u_**S(2)*WC('c', S(1)) + u_*WC('b', S(1)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons21, cons5, cons68, cons69) def replacement342(p, u, m, b, d, c, a, x, e): rubi.append(342) return Dist(S(1)/Coefficient(u, x, S(1)), Subst(Int((d + e*x)**m*(a + b*x + c*x**S(2))**p, x), x, u), x) rule342 = ReplacementRule(pattern342, replacement342) pattern343 = Pattern(Integral((a_ + u_**S(2)*WC('c', S(1)))**WC('p', S(1))*(u_*WC('e', S(1)) + WC('d', S(0)))**WC('m', S(1)), x_), cons2, cons7, cons27, cons48, cons21, cons5, cons68, cons69) def replacement343(p, u, m, d, c, a, x, e): rubi.append(343) return Dist(S(1)/Coefficient(u, x, S(1)), Subst(Int((a + c*x**S(2))**p*(d + e*x)**m, x), x, u), x) rule343 = ReplacementRule(pattern343, replacement343) pattern344 = Pattern(Integral(x_**WC('n', S(1))*(a_ + x_**S(2)*WC('c', S(1)))**WC('p', S(1))*(x_*WC('e', S(1)) + WC('d', S(0))), x_), cons2, cons7, cons27, cons48, cons5, cons85, cons314) def replacement344(p, d, c, n, a, x, e): rubi.append(344) return Dist(d, Int(x**n*(a + c*x**S(2))**p, x), x) + Dist(e, Int(x**(n + S(1))*(a + c*x**S(2))**p, x), x) rule344 = ReplacementRule(pattern344, replacement344) pattern345 = Pattern(Integral((f_ + x_*WC('g', S(1)))*(x_*WC('e', S(1)) + WC('d', S(0)))**WC('m', S(1))/sqrt(a_ + x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons21, cons315, cons45, cons316) def replacement345(m, g, b, f, d, c, a, x, e): rubi.append(345) return Dist((f + g*x)/sqrt(a + b*x + c*x**S(2)), Int((d + e*x)**m, x), x) rule345 = ReplacementRule(pattern345, replacement345) pattern346 = Pattern(Integral((f_ + x_*WC('g', S(1)))*(x_*WC('e', S(1)) + WC('d', S(0)))**WC('m', S(1))*(a_ + x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons21, cons5, cons315, cons45, cons316, cons147, cons242) def replacement346(p, m, g, b, f, d, c, a, x, e): rubi.append(346) return -Simp(f*g*(d + e*x)**(m + S(1))*(a + b*x + c*x**S(2))**(p + S(1))/(b*(p + S(1))*(-d*g + e*f)), x) rule346 = ReplacementRule(pattern346, replacement346) pattern347 = Pattern(Integral((f_ + x_*WC('g', S(1)))*(x_*WC('e', S(1)) + WC('d', S(0)))**WC('m', S(1))*(a_ + x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)))**p_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons315, cons45, cons316, cons147, cons244, cons137, cons168) def replacement347(p, m, g, b, f, d, c, a, x, e): rubi.append(347) return -Dist(e*g*m/(S(2)*c*(p + S(1))), Int((d + e*x)**(m + S(-1))*(a + b*x + c*x**S(2))**(p + S(1)), x), x) + Simp(g*(d + e*x)**m*(a + b*x + c*x**S(2))**(p + S(1))/(S(2)*c*(p + S(1))), x) rule347 = ReplacementRule(pattern347, replacement347) pattern348 = Pattern(Integral((f_ + x_*WC('g', S(1)))*(x_*WC('e', S(1)) + WC('d', S(0)))**WC('m', S(1))*(a_ + x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)))**p_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons21, cons315, cons45, cons316, cons147, cons13, cons137, cons317) def replacement348(p, m, g, b, f, d, c, a, x, e): rubi.append(348) return Dist(e*f*g*(m + S(2)*p + S(3))/(b*(p + S(1))*(-d*g + e*f)), Int((d + e*x)**m*(a + b*x + c*x**S(2))**(p + S(1)), x), x) - Simp(f*g*(d + e*x)**(m + S(1))*(a + b*x + c*x**S(2))**(p + S(1))/(b*(p + S(1))*(-d*g + e*f)), x) rule348 = ReplacementRule(pattern348, replacement348) pattern349 = Pattern(Integral((f_ + x_*WC('g', S(1)))*(x_*WC('e', S(1)) + WC('d', S(0)))**WC('m', S(1))*(a_ + x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)))**p_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons5, cons315, cons45, cons316, cons147, cons31, cons94, cons225, cons318) def replacement349(p, m, g, b, f, d, c, a, x, e): rubi.append(349) return -Dist(g*(S(2)*p + S(1))/(e*(m + S(1))), Int((d + e*x)**(m + S(1))*(a + b*x + c*x**S(2))**p, x), x) + Simp((d + e*x)**(m + S(1))*(f + g*x)*(a + b*x + c*x**S(2))**p/(e*(m + S(1))), x) rule349 = ReplacementRule(pattern349, replacement349) pattern350 = Pattern(Integral((f_ + x_*WC('g', S(1)))*(x_*WC('e', S(1)) + WC('d', S(0)))**m_*(a_ + x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)))**p_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons5, cons315, cons45, cons316, cons147, cons31, cons94, cons319) def replacement350(p, m, g, b, f, d, c, a, x, e): rubi.append(350) return -Dist(g*(m + S(2)*p + S(3))/((m + S(1))*(-d*g + e*f)), Int((d + e*x)**(m + S(1))*(f + g*x)*(a + b*x + c*x**S(2))**p, x), x) + Simp(S(2)*f*g*(d + e*x)**(m + S(1))*(a + b*x + c*x**S(2))**(p + S(1))/(b*(m + S(1))*(-d*g + e*f)), x) rule350 = ReplacementRule(pattern350, replacement350) pattern351 = Pattern(Integral((f_ + x_*WC('g', S(1)))*(x_*WC('e', S(1)) + WC('d', S(0)))**WC('m', S(1))*(a_ + x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)))**p_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons5, cons315, cons45, cons316, cons147, cons62, cons319, cons320) def replacement351(p, m, g, b, f, d, c, a, x, e): rubi.append(351) return -Dist(b*m*(-d*g + e*f)/(S(2)*c*f*(m + S(2)*p + S(2))), Int((d + e*x)**(m + S(-1))*(f + g*x)*(a + b*x + c*x**S(2))**p, x), x) + Simp(g*(d + e*x)**m*(a + b*x + c*x**S(2))**(p + S(1))/(c*(m + S(2)*p + S(2))), x) rule351 = ReplacementRule(pattern351, replacement351) pattern352 = Pattern(Integral((f_ + x_*WC('g', S(1)))*(x_*WC('e', S(1)) + WC('d', S(0)))**WC('m', S(1))*(a_ + x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons21, cons5, cons315, cons45, cons316, cons147, cons319) def replacement352(p, m, g, b, f, d, c, a, x, e): rubi.append(352) return Dist((S(2)*p + S(1))*(-d*g + e*f)/(e*(m + S(2)*p + S(2))), Int((d + e*x)**m*(a + b*x + c*x**S(2))**p, x), x) + Simp((d + e*x)**(m + S(1))*(f + g*x)*(a + b*x + c*x**S(2))**p/(e*(m + S(2)*p + S(2))), x) rule352 = ReplacementRule(pattern352, replacement352) pattern353 = Pattern(Integral((x_*WC('g', S(1)) + WC('f', S(0)))*(a_ + x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)))**p_/(x_*WC('e', S(1)) + WC('d', S(0))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons315, cons45, cons321, cons147, cons239, cons13, cons322) def replacement353(p, f, b, g, d, c, a, x, e): rubi.append(353) return Dist((-b*g + S(2)*c*f)/(-b*e + S(2)*c*d), Int((a + b*x + c*x**S(2))**p, x), x) - Dist((-d*g + e*f)/(-b*e + S(2)*c*d), Int((b + S(2)*c*x)*(a + b*x + c*x**S(2))**p/(d + e*x), x), x) rule353 = ReplacementRule(pattern353, replacement353) pattern354 = Pattern(Integral((f_ + x_*WC('g', S(1)))*(x_*WC('e', S(1)) + WC('d', S(0)))**WC('m', S(1))*(a_ + x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)))**p_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons21, cons5, cons315, cons45, cons321, cons147, cons323) def replacement354(p, m, g, b, f, d, c, a, x, e): rubi.append(354) return Dist(g/e, Int((d + e*x)**(m + S(1))*(a + b*x + c*x**S(2))**p, x), x) + Dist((-d*g + e*f)/e, Int((d + e*x)**m*(a + b*x + c*x**S(2))**p, x), x) rule354 = ReplacementRule(pattern354, replacement354) pattern355 = Pattern(Integral((x_*WC('e', S(1)) + WC('d', S(0)))**WC('m', S(1))*(x_*WC('g', S(1)) + WC('f', S(0)))*(a_ + x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)))**p_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons21, cons5, cons315, cons45, cons321, cons147, cons239, cons242) def replacement355(p, m, f, g, b, d, c, a, x, e): rubi.append(355) return Dist((-b*g + S(2)*c*f)/(-b*e + S(2)*c*d), Int((d + e*x)**(m + S(1))*(a + b*x + c*x**S(2))**p, x), x) - Dist((-d*g + e*f)/(-b*e + S(2)*c*d), Int((b + S(2)*c*x)*(d + e*x)**m*(a + b*x + c*x**S(2))**p, x), x) rule355 = ReplacementRule(pattern355, replacement355) pattern356 = Pattern(Integral((f_ + x_*WC('g', S(1)))*(x_*WC('e', S(1)) + WC('d', S(0)))**m_*(a_ + x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)))**p_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons5, cons315, cons45, cons321, cons147, cons239, cons319, cons270, cons31, cons94) def replacement356(p, m, g, b, f, d, c, a, x, e): rubi.append(356) return Dist((S(2)*c*e*f*(m + S(2)*p + S(2)) - g*(b*e*(m + S(1)) + S(2)*c*d*(S(2)*p + S(1))))/(e*(m + S(1))*(-b*e + S(2)*c*d)), Int((d + e*x)**(m + S(1))*(a + b*x + c*x**S(2))**p, x), x) - Simp((b + S(2)*c*x)*(d + e*x)**(m + S(1))*(-d*g + e*f)*(a + b*x + c*x**S(2))**p/(e*(m + S(1))*(-b*e + S(2)*c*d)), x) rule356 = ReplacementRule(pattern356, replacement356) pattern357 = Pattern(Integral((x_*WC('e', S(1)) + WC('d', S(0)))**WC('m', S(1))*(x_*WC('g', S(1)) + WC('f', S(0)))*(a_ + x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)))**p_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons21, cons5, cons315, cons45, cons321, cons147, cons239, cons319, cons270, cons272, cons324) def replacement357(p, m, f, g, b, d, c, a, x, e): rubi.append(357) return Dist((S(2)*c*e*f*(m + S(2)*p + S(2)) - g*(b*e*(m + S(1)) + S(2)*c*(S(2)*d*p + d)))/(S(2)*c*e*(m + S(2)*p + S(2))), Int((d + e*x)**m*(a + b*x + c*x**S(2))**p, x), x) + Simp(g*(b + S(2)*c*x)*(d + e*x)**(m + S(1))*(a + b*x + c*x**S(2))**p/(S(2)*c*e*(m + S(2)*p + S(2))), x) rule357 = ReplacementRule(pattern357, replacement357) pattern358 = Pattern(Integral((x_*WC('e', S(1)) + WC('d', S(0)))**m_*(x_*WC('g', S(1)) + WC('f', S(0)))**n_*(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0)))**p_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons21, cons4, cons315, cons45, cons147) def replacement358(p, m, f, g, b, d, a, c, n, x, e): rubi.append(358) return Dist(c**(-IntPart(p))*(b/S(2) + c*x)**(-S(2)*FracPart(p))*(a + b*x + c*x**S(2))**FracPart(p), Int((b/S(2) + c*x)**(S(2)*p)*(d + e*x)**m*(f + g*x)**n, x), x) rule358 = ReplacementRule(pattern358, replacement358) pattern359 = Pattern(Integral((d_ + x_*WC('e', S(1)))**WC('m', S(1))*(x_*WC('g', S(1)) + WC('f', S(0)))**WC('n', S(1))*(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons21, cons4, cons315, cons226, cons256, cons38) def replacement359(p, m, f, g, b, d, a, n, c, x, e): rubi.append(359) return Int((d + e*x)**(m + p)*(f + g*x)**n*(a/d + c*x/e)**p, x) rule359 = ReplacementRule(pattern359, replacement359) pattern360 = Pattern(Integral((a_ + x_**S(2)*WC('c', S(1)))**WC('p', S(1))*(d_ + x_*WC('e', S(1)))**WC('m', S(1))*(x_*WC('g', S(1)) + WC('f', S(0)))**WC('n', S(1)), x_), cons2, cons7, cons27, cons48, cons125, cons208, cons21, cons4, cons315, cons257, cons325) def replacement360(p, m, f, g, d, c, n, a, x, e): rubi.append(360) return Int((d + e*x)**(m + p)*(f + g*x)**n*(a/d + c*x/e)**p, x) rule360 = ReplacementRule(pattern360, replacement360) pattern361 = Pattern(Integral((d_ + x_*WC('e', S(1)))**m_*(x_*WC('g', S(1)) + WC('f', S(0)))**WC('n', S(1))*(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0)))**p_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons4, cons5, cons256, cons84, cons314) def replacement361(p, m, f, g, b, d, a, n, c, x, e): rubi.append(361) return Dist(d**m*e**m, Int((f + g*x)**n*(a*e + c*d*x)**(-m)*(a + b*x + c*x**S(2))**(m + p), x), x) rule361 = ReplacementRule(pattern361, replacement361) pattern362 = Pattern(Integral((a_ + x_**S(2)*WC('c', S(1)))**p_*(d_ + x_*WC('e', S(1)))**m_*(x_*WC('g', S(1)) + WC('f', S(0)))**WC('n', S(1)), x_), cons2, cons7, cons27, cons48, cons125, cons208, cons4, cons5, cons257, cons84, cons314) def replacement362(p, m, f, g, d, c, n, a, x, e): rubi.append(362) return Dist(d**m*e**m, Int((a + c*x**S(2))**(m + p)*(f + g*x)**n*(a*e + c*d*x)**(-m), x), x) rule362 = ReplacementRule(pattern362, replacement362) pattern363 = Pattern(Integral((x_*WC('e', S(1)) + WC('d', S(0)))**WC('m', S(1))*(x_*WC('g', S(1)) + WC('f', S(0)))*(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0)))**p_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons21, cons5, cons315, cons226, cons256, cons326) def replacement363(p, m, f, g, b, d, a, c, x, e): rubi.append(363) return Simp(g*(d + e*x)**m*(a + b*x + c*x**S(2))**(p + S(1))/(c*(m + S(2)*p + S(2))), x) rule363 = ReplacementRule(pattern363, replacement363) pattern364 = Pattern(Integral((a_ + x_**S(2)*WC('c', S(1)))**p_*(d_ + x_*WC('e', S(1)))**WC('m', S(1))*(x_*WC('g', S(1)) + WC('f', S(0))), x_), cons2, cons7, cons27, cons48, cons125, cons208, cons21, cons5, cons315, cons257, cons327) def replacement364(p, m, f, g, d, c, a, x, e): rubi.append(364) return Simp(g*(a + c*x**S(2))**(p + S(1))*(d + e*x)**m/(c*(m + S(2)*p + S(2))), x) rule364 = ReplacementRule(pattern364, replacement364) pattern365 = Pattern(Integral((x_*WC('e', S(1)) + WC('d', S(0)))**WC('m', S(1))*(x_*WC('g', S(1)) + WC('f', S(0)))*(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0)))**p_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons315, cons226, cons256, cons244, cons137, cons168) def replacement365(p, m, f, g, b, d, a, c, x, e): rubi.append(365) return -Dist(e*(e*(p + S(1))*(-b*g + S(2)*c*f) + m*(c*e*f + g*(-b*e + c*d)))/(c*(p + S(1))*(-b*e + S(2)*c*d)), Int((d + e*x)**(m + S(-1))*(a + b*x + c*x**S(2))**(p + S(1)), x), x) + Simp((d + e*x)**m*(c*e*f + g*(-b*e + c*d))*(a + b*x + c*x**S(2))**(p + S(1))/(c*(p + S(1))*(-b*e + S(2)*c*d)), x) rule365 = ReplacementRule(pattern365, replacement365) pattern366 = Pattern(Integral((a_ + x_**S(2)*WC('c', S(1)))**p_*(x_*WC('e', S(1)) + WC('d', S(0)))**WC('m', S(1))*(x_*WC('g', S(1)) + WC('f', S(0))), x_), cons2, cons7, cons27, cons48, cons125, cons208, cons315, cons257, cons244, cons137, cons168) def replacement366(p, m, f, g, d, c, a, x, e): rubi.append(366) return -Dist(e*(S(2)*e*f*(p + S(1)) + m*(d*g + e*f))/(S(2)*c*d*(p + S(1))), Int((a + c*x**S(2))**(p + S(1))*(d + e*x)**(m + S(-1)), x), x) + Simp((a + c*x**S(2))**(p + S(1))*(d + e*x)**m*(d*g + e*f)/(S(2)*c*d*(p + S(1))), x) rule366 = ReplacementRule(pattern366, replacement366) pattern367 = Pattern(Integral((x_*WC('e', S(1)) + WC('d', S(0)))**WC('m', S(1))*(x_*WC('g', S(1)) + WC('f', S(0)))*(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0)))**p_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons21, cons5, cons315, cons226, cons256, cons139, cons328, cons54) def replacement367(p, m, f, g, b, d, a, c, x, e): rubi.append(367) return -Dist(e*(e*(p + S(1))*(-b*g + S(2)*c*f) + m*(c*e*f + g*(-b*e + c*d)))/(c*(p + S(1))*(-b*e + S(2)*c*d)), Int((d + e*x)**(m + S(-1))*(a + b*x + c*x**S(2))**(p + S(1)), x), x) + Simp((d + e*x)**m*(c*e*f + g*(-b*e + c*d))*(a + b*x + c*x**S(2))**(p + S(1))/(c*(p + S(1))*(-b*e + S(2)*c*d)), x) rule367 = ReplacementRule(pattern367, replacement367) pattern368 = Pattern(Integral((a_ + x_**S(2)*WC('c', S(1)))**p_*(d_ + x_*WC('e', S(1)))**WC('m', S(1))*(x_*WC('g', S(1)) + WC('f', S(0))), x_), cons2, cons7, cons27, cons48, cons125, cons208, cons21, cons5, cons315, cons257, cons139, cons328, cons54) def replacement368(p, m, f, g, d, c, a, x, e): rubi.append(368) return -Dist(e*(S(2)*e*f*(p + S(1)) + m*(d*g + e*f))/(S(2)*c*d*(p + S(1))), Int((a + c*x**S(2))**(p + S(1))*(d + e*x)**(m + S(-1)), x), x) + Simp((a + c*x**S(2))**(p + S(1))*(d + e*x)**m*(d*g + e*f)/(S(2)*c*d*(p + S(1))), x) rule368 = ReplacementRule(pattern368, replacement368) pattern369 = Pattern(Integral((x_*WC('e', S(1)) + WC('d', S(0)))**WC('m', S(1))*(x_*WC('g', S(1)) + WC('f', S(0)))*(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0)))**p_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons21, cons5, cons315, cons226, cons256, cons329, cons253) def replacement369(p, m, f, g, b, d, a, c, x, e): rubi.append(369) return Dist((e*(p + S(1))*(-b*g + S(2)*c*f) + m*(c*e*f + g*(-b*e + c*d)))/(e*(-b*e + S(2)*c*d)*(m + p + S(1))), Int((d + e*x)**(m + S(1))*(a + b*x + c*x**S(2))**p, x), x) + Simp((d + e*x)**m*(d*g - e*f)*(a + b*x + c*x**S(2))**(p + S(1))/((-b*e + S(2)*c*d)*(m + p + S(1))), x) rule369 = ReplacementRule(pattern369, replacement369) pattern370 = Pattern(Integral((a_ + x_**S(2)*WC('c', S(1)))**p_*(d_ + x_*WC('e', S(1)))**WC('m', S(1))*(x_*WC('g', S(1)) + WC('f', S(0))), x_), cons2, cons7, cons27, cons48, cons125, cons208, cons21, cons5, cons315, cons257, cons329, cons253) def replacement370(p, m, f, g, d, c, a, x, e): rubi.append(370) return Dist((S(2)*c*e*f*(p + S(1)) + m*(c*d*g + c*e*f))/(S(2)*c*d*e*(m + p + S(1))), Int((a + c*x**S(2))**p*(d + e*x)**(m + S(1)), x), x) + Simp((a + c*x**S(2))**(p + S(1))*(d + e*x)**m*(d*g - e*f)/(S(2)*c*d*(m + p + S(1))), x) rule370 = ReplacementRule(pattern370, replacement370) pattern371 = Pattern(Integral((x_*WC('e', S(1)) + WC('d', S(0)))**WC('m', S(1))*(x_*WC('g', S(1)) + WC('f', S(0)))*(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0)))**p_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons21, cons5, cons315, cons226, cons256, cons319) def replacement371(p, m, f, g, b, d, a, c, x, e): rubi.append(371) return Dist((e*(p + S(1))*(-b*g + S(2)*c*f) + m*(c*e*f + g*(-b*e + c*d)))/(c*e*(m + S(2)*p + S(2))), Int((d + e*x)**m*(a + b*x + c*x**S(2))**p, x), x) + Simp(g*(d + e*x)**m*(a + b*x + c*x**S(2))**(p + S(1))/(c*(m + S(2)*p + S(2))), x) rule371 = ReplacementRule(pattern371, replacement371) pattern372 = Pattern(Integral((a_ + x_**S(2)*WC('c', S(1)))**p_*(d_ + x_*WC('e', S(1)))**WC('m', S(1))*(x_*WC('g', S(1)) + WC('f', S(0))), x_), cons2, cons7, cons27, cons48, cons125, cons208, cons21, cons5, cons315, cons257, cons319) def replacement372(p, m, f, g, d, c, a, x, e): rubi.append(372) return Dist((S(2)*e*f*(p + S(1)) + m*(d*g + e*f))/(e*(m + S(2)*p + S(2))), Int((a + c*x**S(2))**p*(d + e*x)**m, x), x) + Simp(g*(a + c*x**S(2))**(p + S(1))*(d + e*x)**m/(c*(m + S(2)*p + S(2))), x) rule372 = ReplacementRule(pattern372, replacement372) pattern373 = Pattern(Integral(x_**S(2)*(a_ + x_**S(2)*WC('c', S(1)))**p_*(f_ + x_*WC('g', S(1))), x_), cons2, cons7, cons125, cons208, cons330, cons13, cons331) def replacement373(p, f, g, c, a, x): rubi.append(373) return -Dist(S(1)/(S(2)*a*c*(p + S(1))), Int(x*(a + c*x**S(2))**(p + S(1))*Simp(S(2)*a*g - c*f*x*(S(2)*p + S(5)), x), x), x) + Simp(x**S(2)*(a + c*x**S(2))**(p + S(1))*(a*g - c*f*x)/(S(2)*a*c*(p + S(1))), x) rule373 = ReplacementRule(pattern373, replacement373) pattern374 = Pattern(Integral(x_**S(2)*(a_ + x_**S(2)*WC('c', S(1)))**p_*(f_ + x_*WC('g', S(1))), x_), cons2, cons7, cons125, cons208, cons5, cons330) def replacement374(p, f, g, c, a, x): rubi.append(374) return Dist(S(1)/c, Int((a + c*x**S(2))**(p + S(1))*(f + g*x), x), x) - Dist(f**S(2)/c, Int((a + c*x**S(2))**(p + S(1))/(f - g*x), x), x) rule374 = ReplacementRule(pattern374, replacement374) pattern375 = Pattern(Integral((d_ + x_*WC('e', S(1)))**m_*(x_*WC('g', S(1)) + WC('f', S(0)))**WC('n', S(1))*(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0)))**p_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons315, cons226, cons256, cons147, cons150, cons13, cons332) def replacement375(p, m, f, g, b, d, a, n, c, x, e): rubi.append(375) return Int((f + g*x)**n*(a/d + c*x/e)**(-m)*(a + b*x + c*x**S(2))**(m + p), x) rule375 = ReplacementRule(pattern375, replacement375) pattern376 = Pattern(Integral((a_ + x_**S(2)*WC('c', S(1)))**p_*(d_ + x_*WC('e', S(1)))**m_*(x_*WC('g', S(1)) + WC('f', S(0)))**WC('n', S(1)), x_), cons2, cons7, cons27, cons48, cons125, cons208, cons315, cons257, cons147, cons150, cons13, cons332) def replacement376(p, m, f, g, d, c, n, a, x, e): rubi.append(376) return Dist(a**(-m)*d**(S(2)*m), Int((a + c*x**S(2))**(m + p)*(d - e*x)**(-m)*(f + g*x)**n, x), x) rule376 = ReplacementRule(pattern376, replacement376) pattern377 = Pattern(Integral((x_*WC('g', S(1)) + WC('f', S(0)))**WC('n', S(1))*(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0)))**p_/(d_ + x_*WC('e', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons315, cons226, cons256, cons147, cons148, cons333) def replacement377(p, f, g, b, d, a, n, c, x, e): rubi.append(377) return -Dist(S(1)/(d*e*p*(-S(4)*a*c + b**S(2))), Int((f + g*x)**(n + S(-1))*(a + b*x + c*x**S(2))**p*Simp(-S(2)*a*c*(d*g*n - e*f*(S(2)*p + S(1))) + b*(a*e*g*n - c*d*f*(S(2)*p + S(1))) - c*g*x*(-S(2)*a*e + b*d)*(n + S(2)*p + S(1)), x), x), x) - Simp((f + g*x)**n*(a*(-b*e + S(2)*c*d) + c*x*(-S(2)*a*e + b*d))*(a + b*x + c*x**S(2))**p/(d*e*p*(-S(4)*a*c + b**S(2))), x) rule377 = ReplacementRule(pattern377, replacement377) pattern378 = Pattern(Integral((a_ + x_**S(2)*WC('c', S(1)))**p_*(x_*WC('g', S(1)) + WC('f', S(0)))**WC('n', S(1))/(d_ + x_*WC('e', S(1))), x_), cons2, cons7, cons27, cons48, cons125, cons208, cons315, cons257, cons147, cons148, cons333) def replacement378(p, f, g, d, c, n, a, x, e): rubi.append(378) return -Dist(S(1)/(S(2)*d*e*p), Int((a + c*x**S(2))**p*(f + g*x)**(n + S(-1))*Simp(d*g*n - e*f*(S(2)*p + S(1)) - e*g*x*(n + S(2)*p + S(1)), x), x), x) + Simp((a + c*x**S(2))**p*(d - e*x)*(f + g*x)**n/(S(2)*d*e*p), x) rule378 = ReplacementRule(pattern378, replacement378) pattern379 = Pattern(Integral((x_*WC('g', S(1)) + WC('f', S(0)))**WC('n', S(1))*(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0)))**p_/(d_ + x_*WC('e', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons315, cons226, cons256, cons147, cons196, cons333) def replacement379(p, f, g, b, d, a, n, c, x, e): rubi.append(379) return -Dist(S(1)/(d*e*p*(-S(4)*a*c + b**S(2))*(a*g**S(2) - b*f*g + c*f**S(2))), Int((f + g*x)**n*(a + b*x + c*x**S(2))**p*Simp(S(2)*a*c*(a*e*g**S(2)*(n + S(2)*p + S(1)) + c*f*(-d*g*n + S(2)*e*f*p + e*f)) + b**S(2)*g*(-a*e*g*(n + p + S(1)) + c*d*f*p) + b*c*(a*g*(d*g*(n + S(1)) + e*f*(n - S(2)*p)) - c*d*f**S(2)*(S(2)*p + S(1))) + c*g*x*(S(2)*a*c*(d*g + e*f) - b*(a*e*g + c*d*f))*(n + S(2)*p + S(2)), x), x), x) - Simp((f + g*x)**(n + S(1))*(a + b*x + c*x**S(2))**p*(a*c*d*(-b*g + S(2)*c*f) - a*e*(S(2)*a*c*g - b**S(2)*g + b*c*f) + c*x*(-a*e*(-b*g + S(2)*c*f) + c*d*(-S(2)*a*g + b*f)))/(d*e*p*(-S(4)*a*c + b**S(2))*(a*g**S(2) - b*f*g + c*f**S(2))), x) rule379 = ReplacementRule(pattern379, replacement379) pattern380 = Pattern(Integral((a_ + x_**S(2)*WC('c', S(1)))**p_*(x_*WC('g', S(1)) + WC('f', S(0)))**WC('n', S(1))/(d_ + x_*WC('e', S(1))), x_), cons2, cons7, cons27, cons48, cons125, cons208, cons315, cons257, cons147, cons196, cons333) def replacement380(p, f, g, d, c, n, a, x, e): rubi.append(380) return Dist(S(1)/(S(2)*d*e*p*(a*g**S(2) + c*f**S(2))), Int((a + c*x**S(2))**p*(f + g*x)**n*Simp(a*e*g**S(2)*(n + S(2)*p + S(1)) - c*f*(d*g*n - e*(S(2)*f*p + f)) + c*g*x*(d*g + e*f)*(n + S(2)*p + S(2)), x), x), x) + Simp((a + c*x**S(2))**p*(f + g*x)**(n + S(1))*(-a*e*g + c*d*f - c*x*(d*g + e*f))/(S(2)*d*e*p*(a*g**S(2) + c*f**S(2))), x) rule380 = ReplacementRule(pattern380, replacement380) pattern381 = Pattern(Integral((d_ + x_*WC('e', S(1)))**m_*(x_*WC('g', S(1)) + WC('f', S(0)))**WC('n', S(1))*(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0)))**p_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons21, cons4, cons5, cons315, cons226, cons256, cons147, cons41, cons334, cons335) def replacement381(p, m, f, g, b, d, a, n, c, x, e): rubi.append(381) return -Simp(e*(d + e*x)**(m + S(-1))*(f + g*x)**n*(a + b*x + c*x**S(2))**(p + S(1))/(c*(m - n + S(-1))), x) rule381 = ReplacementRule(pattern381, replacement381) pattern382 = Pattern(Integral((a_ + x_**S(2)*WC('c', S(1)))**p_*(d_ + x_*WC('e', S(1)))**m_*(x_*WC('g', S(1)) + WC('f', S(0)))**WC('n', S(1)), x_), cons2, cons7, cons27, cons48, cons125, cons208, cons21, cons4, cons5, cons315, cons257, cons147, cons41, cons336, cons335) def replacement382(p, m, f, g, d, c, n, a, x, e): rubi.append(382) return -Simp(e*(a + c*x**S(2))**(p + S(1))*(d + e*x)**(m + S(-1))*(f + g*x)**n/(c*(m - n + S(-1))), x) rule382 = ReplacementRule(pattern382, replacement382) pattern383 = Pattern(Integral((d_ + x_*WC('e', S(1)))**m_*(x_*WC('g', S(1)) + WC('f', S(0)))**n_*(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0)))**p_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons21, cons4, cons5, cons315, cons226, cons256, cons147, cons41, cons337) def replacement383(p, m, f, b, g, d, a, c, n, x, e): rubi.append(383) return -Simp(e**S(2)*(d + e*x)**(m + S(-1))*(f + g*x)**(n + S(1))*(a + b*x + c*x**S(2))**(p + S(1))/((n + S(1))*(-b*e*g + c*d*g + c*e*f)), x) rule383 = ReplacementRule(pattern383, replacement383) pattern384 = Pattern(Integral((a_ + x_**S(2)*WC('c', S(1)))**p_*(d_ + x_*WC('e', S(1)))**m_*(x_*WC('g', S(1)) + WC('f', S(0)))**n_, x_), cons2, cons7, cons27, cons48, cons125, cons208, cons21, cons4, cons5, cons315, cons257, cons147, cons41, cons337) def replacement384(p, m, f, g, d, c, n, a, x, e): rubi.append(384) return -Simp(e**S(2)*(a + c*x**S(2))**(p + S(1))*(d + e*x)**(m + S(-1))*(f + g*x)**(n + S(1))/(c*(n + S(1))*(d*g + e*f)), x) rule384 = ReplacementRule(pattern384, replacement384) pattern385 = Pattern(Integral((d_ + x_*WC('e', S(1)))**m_*(x_*WC('g', S(1)) + WC('f', S(0)))**n_*(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0)))**p_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons315, cons226, cons256, cons147, cons41, cons338, cons163, cons89, cons339) def replacement385(p, m, f, b, g, d, a, c, n, x, e): rubi.append(385) return Dist(c*m/(e*g*(n + S(1))), Int((d + e*x)**(m + S(1))*(f + g*x)**(n + S(1))*(a + b*x + c*x**S(2))**(p + S(-1)), x), x) + Simp((d + e*x)**m*(f + g*x)**(n + S(1))*(a + b*x + c*x**S(2))**p/(g*(n + S(1))), x) rule385 = ReplacementRule(pattern385, replacement385) pattern386 = Pattern(Integral((a_ + x_**S(2)*WC('c', S(1)))**p_*(d_ + x_*WC('e', S(1)))**m_*(x_*WC('g', S(1)) + WC('f', S(0)))**n_, x_), cons2, cons7, cons27, cons48, cons125, cons208, cons315, cons257, cons147, cons41, cons338, cons163, cons89, cons339) def replacement386(p, m, f, g, d, c, n, a, x, e): rubi.append(386) return Dist(c*m/(e*g*(n + S(1))), Int((a + c*x**S(2))**(p + S(-1))*(d + e*x)**(m + S(1))*(f + g*x)**(n + S(1)), x), x) + Simp((a + c*x**S(2))**p*(d + e*x)**m*(f + g*x)**(n + S(1))/(g*(n + S(1))), x) rule386 = ReplacementRule(pattern386, replacement386) pattern387 = Pattern(Integral((d_ + x_*WC('e', S(1)))**m_*(x_*WC('g', S(1)) + WC('f', S(0)))**WC('n', S(1))*(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0)))**p_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons4, cons315, cons226, cons256, cons147, cons41, cons338, cons163, cons335, cons340, cons341) def replacement387(p, m, f, g, b, d, a, n, c, x, e): rubi.append(387) return -Dist(m*(-b*e*g + c*d*g + c*e*f)/(e**S(2)*g*(m - n + S(-1))), Int((d + e*x)**(m + S(1))*(f + g*x)**n*(a + b*x + c*x**S(2))**(p + S(-1)), x), x) - Simp((d + e*x)**m*(f + g*x)**(n + S(1))*(a + b*x + c*x**S(2))**p/(g*(m - n + S(-1))), x) rule387 = ReplacementRule(pattern387, replacement387) pattern388 = Pattern(Integral((a_ + x_**S(2)*WC('c', S(1)))**p_*(d_ + x_*WC('e', S(1)))**m_*(x_*WC('g', S(1)) + WC('f', S(0)))**WC('n', S(1)), x_), cons2, cons7, cons27, cons48, cons125, cons208, cons4, cons315, cons257, cons147, cons41, cons338, cons163, cons335, cons340, cons341) def replacement388(p, m, f, g, d, c, n, a, x, e): rubi.append(388) return -Dist(c*m*(d*g + e*f)/(e**S(2)*g*(m - n + S(-1))), Int((a + c*x**S(2))**(p + S(-1))*(d + e*x)**(m + S(1))*(f + g*x)**n, x), x) - Simp((a + c*x**S(2))**p*(d + e*x)**m*(f + g*x)**(n + S(1))/(g*(m - n + S(-1))), x) rule388 = ReplacementRule(pattern388, replacement388) pattern389 = Pattern(Integral((d_ + x_*WC('e', S(1)))**m_*(x_*WC('g', S(1)) + WC('f', S(0)))**WC('n', S(1))*(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0)))**p_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons315, cons226, cons256, cons147, cons41, cons338, cons137, cons88) def replacement389(p, m, f, g, b, d, a, n, c, x, e): rubi.append(389) return -Dist(e*g*n/(c*(p + S(1))), Int((d + e*x)**(m + S(-1))*(f + g*x)**(n + S(-1))*(a + b*x + c*x**S(2))**(p + S(1)), x), x) + Simp(e*(d + e*x)**(m + S(-1))*(f + g*x)**n*(a + b*x + c*x**S(2))**(p + S(1))/(c*(p + S(1))), x) rule389 = ReplacementRule(pattern389, replacement389) pattern390 = Pattern(Integral((a_ + x_**S(2)*WC('c', S(1)))**p_*(d_ + x_*WC('e', S(1)))**m_*(x_*WC('g', S(1)) + WC('f', S(0)))**WC('n', S(1)), x_), cons2, cons7, cons27, cons48, cons125, cons208, cons315, cons257, cons147, cons41, cons338, cons137, cons88) def replacement390(p, m, f, g, d, c, n, a, x, e): rubi.append(390) return -Dist(e*g*n/(c*(p + S(1))), Int((a + c*x**S(2))**(p + S(1))*(d + e*x)**(m + S(-1))*(f + g*x)**(n + S(-1)), x), x) + Simp(e*(a + c*x**S(2))**(p + S(1))*(d + e*x)**(m + S(-1))*(f + g*x)**n/(c*(p + S(1))), x) rule390 = ReplacementRule(pattern390, replacement390) pattern391 = Pattern(Integral((d_ + x_*WC('e', S(1)))**m_*(x_*WC('g', S(1)) + WC('f', S(0)))**WC('n', S(1))*(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0)))**p_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons4, cons315, cons226, cons256, cons147, cons41, cons338, cons137) def replacement391(p, m, f, g, b, d, a, n, c, x, e): rubi.append(391) return Dist(e**S(2)*g*(m - n + S(-2))/((p + S(1))*(-b*e*g + c*d*g + c*e*f)), Int((d + e*x)**(m + S(-1))*(f + g*x)**n*(a + b*x + c*x**S(2))**(p + S(1)), x), x) + Simp(e**S(2)*(d + e*x)**(m + S(-1))*(f + g*x)**(n + S(1))*(a + b*x + c*x**S(2))**(p + S(1))/((p + S(1))*(-b*e*g + c*d*g + c*e*f)), x) rule391 = ReplacementRule(pattern391, replacement391) pattern392 = Pattern(Integral((a_ + x_**S(2)*WC('c', S(1)))**p_*(d_ + x_*WC('e', S(1)))**m_*(x_*WC('g', S(1)) + WC('f', S(0)))**WC('n', S(1)), x_), cons2, cons7, cons27, cons48, cons125, cons208, cons4, cons315, cons257, cons147, cons41, cons338, cons137) def replacement392(p, m, f, g, d, c, n, a, x, e): rubi.append(392) return Dist(e**S(2)*g*(m - n + S(-2))/(c*(p + S(1))*(d*g + e*f)), Int((a + c*x**S(2))**(p + S(1))*(d + e*x)**(m + S(-1))*(f + g*x)**n, x), x) + Simp(e**S(2)*(a + c*x**S(2))**(p + S(1))*(d + e*x)**(m + S(-1))*(f + g*x)**(n + S(1))/(c*(p + S(1))*(d*g + e*f)), x) rule392 = ReplacementRule(pattern392, replacement392) pattern393 = Pattern(Integral((d_ + x_*WC('e', S(1)))**m_*(x_*WC('g', S(1)) + WC('f', S(0)))**WC('n', S(1))*(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0)))**p_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons21, cons5, cons315, cons226, cons256, cons147, cons41, cons87, cons88, cons335, cons342) def replacement393(p, m, f, g, b, d, a, n, c, x, e): rubi.append(393) return -Dist(n*(-b*e*g + c*d*g + c*e*f)/(c*e*(m - n + S(-1))), Int((d + e*x)**m*(f + g*x)**(n + S(-1))*(a + b*x + c*x**S(2))**p, x), x) - Simp(e*(d + e*x)**(m + S(-1))*(f + g*x)**n*(a + b*x + c*x**S(2))**(p + S(1))/(c*(m - n + S(-1))), x) rule393 = ReplacementRule(pattern393, replacement393) pattern394 = Pattern(Integral((a_ + x_**S(2)*WC('c', S(1)))**p_*(d_ + x_*WC('e', S(1)))**m_*(x_*WC('g', S(1)) + WC('f', S(0)))**WC('n', S(1)), x_), cons2, cons7, cons27, cons48, cons125, cons208, cons21, cons5, cons315, cons257, cons147, cons41, cons87, cons88, cons335, cons342) def replacement394(p, m, f, g, d, c, n, a, x, e): rubi.append(394) return -Dist(n*(d*g + e*f)/(e*(m - n + S(-1))), Int((a + c*x**S(2))**p*(d + e*x)**m*(f + g*x)**(n + S(-1)), x), x) - Simp(e*(a + c*x**S(2))**(p + S(1))*(d + e*x)**(m + S(-1))*(f + g*x)**n/(c*(m - n + S(-1))), x) rule394 = ReplacementRule(pattern394, replacement394) pattern395 = Pattern(Integral((d_ + x_*WC('e', S(1)))**m_*(x_*WC('g', S(1)) + WC('f', S(0)))**n_*(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0)))**p_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons21, cons5, cons315, cons226, cons256, cons147, cons41, cons87, cons89, cons246) def replacement395(p, m, f, b, g, d, a, c, n, x, e): rubi.append(395) return -Dist(c*e*(m - n + S(-2))/((n + S(1))*(-b*e*g + c*d*g + c*e*f)), Int((d + e*x)**m*(f + g*x)**(n + S(1))*(a + b*x + c*x**S(2))**p, x), x) - Simp(e**S(2)*(d + e*x)**(m + S(-1))*(f + g*x)**(n + S(1))*(a + b*x + c*x**S(2))**(p + S(1))/((n + S(1))*(-b*e*g + c*d*g + c*e*f)), x) rule395 = ReplacementRule(pattern395, replacement395) pattern396 = Pattern(Integral((a_ + x_**S(2)*WC('c', S(1)))**p_*(d_ + x_*WC('e', S(1)))**m_*(x_*WC('g', S(1)) + WC('f', S(0)))**n_, x_), cons2, cons7, cons27, cons48, cons125, cons208, cons21, cons5, cons315, cons257, cons147, cons41, cons87, cons89, cons246) def replacement396(p, m, f, g, d, c, n, a, x, e): rubi.append(396) return -Dist(e*(m - n + S(-2))/((n + S(1))*(d*g + e*f)), Int((a + c*x**S(2))**p*(d + e*x)**m*(f + g*x)**(n + S(1)), x), x) - Simp(e**S(2)*(a + c*x**S(2))**(p + S(1))*(d + e*x)**(m + S(-1))*(f + g*x)**(n + S(1))/((n + S(1))*(c*d*g + c*e*f)), x) rule396 = ReplacementRule(pattern396, replacement396) pattern397 = Pattern(Integral(sqrt(d_ + x_*WC('e', S(1)))/((x_*WC('g', S(1)) + WC('f', S(0)))*sqrt(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons315, cons226, cons256) def replacement397(f, b, g, d, a, c, x, e): rubi.append(397) return Dist(S(2)*e**S(2), Subst(Int(S(1)/(-b*e*g + c*(d*g + e*f) + e**S(2)*g*x**S(2)), x), x, sqrt(a + b*x + c*x**S(2))/sqrt(d + e*x)), x) rule397 = ReplacementRule(pattern397, replacement397) pattern398 = Pattern(Integral(sqrt(d_ + x_*WC('e', S(1)))/(sqrt(a_ + x_**S(2)*WC('c', S(1)))*(x_*WC('g', S(1)) + WC('f', S(0)))), x_), cons2, cons7, cons27, cons48, cons125, cons208, cons315, cons257) def replacement398(f, g, d, c, a, x, e): rubi.append(398) return Dist(S(2)*e**S(2), Subst(Int(S(1)/(c*(d*g + e*f) + e**S(2)*g*x**S(2)), x), x, sqrt(a + c*x**S(2))/sqrt(d + e*x)), x) rule398 = ReplacementRule(pattern398, replacement398) pattern399 = Pattern(Integral((d_ + x_*WC('e', S(1)))**m_*(x_*WC('g', S(1)) + WC('f', S(0)))**WC('n', S(1))*(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0)))**p_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons21, cons4, cons5, cons315, cons226, cons256, cons147, cons343, cons344, cons126) def replacement399(p, m, f, g, b, d, a, n, c, x, e): rubi.append(399) return Simp(e**S(2)*(d + e*x)**(m + S(-2))*(f + g*x)**(n + S(1))*(a + b*x + c*x**S(2))**(p + S(1))/(c*g*(n + p + S(2))), x) rule399 = ReplacementRule(pattern399, replacement399) pattern400 = Pattern(Integral((a_ + x_**S(2)*WC('c', S(1)))**p_*(d_ + x_*WC('e', S(1)))**m_*(x_*WC('g', S(1)) + WC('f', S(0)))**WC('n', S(1)), x_), cons2, cons7, cons27, cons48, cons125, cons208, cons21, cons4, cons5, cons315, cons257, cons147, cons343, cons345, cons126) def replacement400(p, m, f, g, d, c, n, a, x, e): rubi.append(400) return Simp(e**S(2)*(a + c*x**S(2))**(p + S(1))*(d + e*x)**(m + S(-2))*(f + g*x)**(n + S(1))/(c*g*(n + p + S(2))), x) rule400 = ReplacementRule(pattern400, replacement400) pattern401 = Pattern(Integral((d_ + x_*WC('e', S(1)))**m_*(x_*WC('g', S(1)) + WC('f', S(0)))**n_*(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0)))**p_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons21, cons5, cons315, cons226, cons256, cons147, cons343, cons87, cons89, cons246) def replacement401(p, m, f, b, g, d, a, c, n, x, e): rubi.append(401) return -Dist(e*(b*e*g*(n + S(1)) - c*d*g*(S(2)*n + p + S(3)) + c*e*f*(p + S(1)))/(g*(n + S(1))*(-b*e*g + c*d*g + c*e*f)), Int((d + e*x)**(m + S(-1))*(f + g*x)**(n + S(1))*(a + b*x + c*x**S(2))**p, x), x) + Simp(e**S(2)*(d + e*x)**(m + S(-2))*(f + g*x)**(n + S(1))*(-d*g + e*f)*(a + b*x + c*x**S(2))**(p + S(1))/(g*(n + S(1))*(-b*e*g + c*d*g + c*e*f)), x) rule401 = ReplacementRule(pattern401, replacement401) pattern402 = Pattern(Integral((a_ + x_**S(2)*WC('c', S(1)))**p_*(d_ + x_*WC('e', S(1)))**m_*(x_*WC('g', S(1)) + WC('f', S(0)))**n_, x_), cons2, cons7, cons27, cons48, cons125, cons208, cons21, cons5, cons315, cons257, cons147, cons343, cons87, cons89, cons246) def replacement402(p, m, f, g, d, c, n, a, x, e): rubi.append(402) return -Dist(e*(-d*g*(S(2)*n + p + S(3)) + e*f*(p + S(1)))/(g*(n + S(1))*(d*g + e*f)), Int((a + c*x**S(2))**p*(d + e*x)**(m + S(-1))*(f + g*x)**(n + S(1)), x), x) + Simp(e**S(2)*(a + c*x**S(2))**(p + S(1))*(d + e*x)**(m + S(-2))*(f + g*x)**(n + S(1))*(-d*g + e*f)/(c*g*(n + S(1))*(d*g + e*f)), x) rule402 = ReplacementRule(pattern402, replacement402) pattern403 = Pattern(Integral((d_ + x_*WC('e', S(1)))**m_*(x_*WC('g', S(1)) + WC('f', S(0)))**WC('n', S(1))*(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0)))**p_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons21, cons4, cons5, cons315, cons226, cons256, cons147, cons343, cons346, cons246) def replacement403(p, m, f, g, b, d, a, n, c, x, e): rubi.append(403) return -Dist((b*e*g*(n + S(1)) - c*d*g*(S(2)*n + p + S(3)) + c*e*f*(p + S(1)))/(c*g*(n + p + S(2))), Int((d + e*x)**(m + S(-1))*(f + g*x)**n*(a + b*x + c*x**S(2))**p, x), x) + Simp(e**S(2)*(d + e*x)**(m + S(-2))*(f + g*x)**(n + S(1))*(a + b*x + c*x**S(2))**(p + S(1))/(c*g*(n + p + S(2))), x) rule403 = ReplacementRule(pattern403, replacement403) pattern404 = Pattern(Integral((a_ + x_**S(2)*WC('c', S(1)))**p_*(d_ + x_*WC('e', S(1)))**m_*(x_*WC('g', S(1)) + WC('f', S(0)))**WC('n', S(1)), x_), cons2, cons7, cons27, cons48, cons125, cons208, cons21, cons4, cons5, cons315, cons257, cons147, cons343, cons346, cons246) def replacement404(p, m, f, g, d, c, n, a, x, e): rubi.append(404) return -Dist((-d*g*(S(2)*n + p + S(3)) + e*f*(p + S(1)))/(g*(n + p + S(2))), Int((a + c*x**S(2))**p*(d + e*x)**(m + S(-1))*(f + g*x)**n, x), x) + Simp(e**S(2)*(a + c*x**S(2))**(p + S(1))*(d + e*x)**(m + S(-2))*(f + g*x)**(n + S(1))/(c*g*(n + p + S(2))), x) rule404 = ReplacementRule(pattern404, replacement404) pattern405 = Pattern(Integral((d_ + x_*WC('e', S(1)))**m_*(x_*WC('g', S(1)) + WC('f', S(0)))**WC('n', S(1))*(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0)))**p_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons4, cons5, cons315, cons226, cons256, cons147, cons207) def replacement405(p, m, f, g, b, d, a, n, c, x, e): rubi.append(405) return Int(ExpandIntegrand((d + e*x)**m*(f + g*x)**n*(a + b*x + c*x**S(2))**p, x), x) rule405 = ReplacementRule(pattern405, replacement405) pattern406 = Pattern(Integral((a_ + x_**S(2)*WC('c', S(1)))**p_*(d_ + x_*WC('e', S(1)))**m_*(x_*WC('g', S(1)) + WC('f', S(0)))**WC('n', S(1)), x_), cons2, cons7, cons27, cons48, cons125, cons208, cons4, cons5, cons315, cons257, cons347, cons150, cons348, cons349) def replacement406(p, m, f, g, d, c, n, a, x, e): rubi.append(406) return Int(ExpandIntegrand(S(1)/sqrt(a + c*x**S(2)), (a + c*x**S(2))**(p + S(1)/2)*(d + e*x)**m*(f + g*x)**n, x), x) rule406 = ReplacementRule(pattern406, replacement406) pattern407 = Pattern(Integral((a_ + x_**S(2)*WC('c', S(1)))**p_*(d_ + x_*WC('e', S(1)))**m_*(x_*WC('g', S(1)) + WC('f', S(0)))**WC('n', S(1)), x_), cons2, cons7, cons27, cons48, cons125, cons208, cons4, cons5, cons315, cons257, cons147, cons207) def replacement407(p, m, f, g, d, c, n, a, x, e): rubi.append(407) return Int(ExpandIntegrand((a + c*x**S(2))**p*(d + e*x)**m*(f + g*x)**n, x), x) rule407 = ReplacementRule(pattern407, replacement407) pattern408 = Pattern(Integral(x_**S(2)*(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0)))**p_/(d_ + x_*WC('e', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons5, cons226, cons256) def replacement408(p, b, d, c, a, x, e): rubi.append(408) return -Dist(e**(S(-2)), Int((d - e*x)*(a + b*x + c*x**S(2))**p, x), x) + Dist(d**S(2)/e**S(2), Int((a + b*x + c*x**S(2))**p/(d + e*x), x), x) rule408 = ReplacementRule(pattern408, replacement408) pattern409 = Pattern(Integral(x_**S(2)*(a_ + x_**S(2)*WC('c', S(1)))**p_/(d_ + x_*WC('e', S(1))), x_), cons2, cons7, cons27, cons48, cons5, cons257) def replacement409(p, d, c, a, x, e): rubi.append(409) return -Dist(e**(S(-2)), Int((a + c*x**S(2))**p*(d - e*x), x), x) + Dist(d**S(2)/e**S(2), Int((a + c*x**S(2))**p/(d + e*x), x), x) rule409 = ReplacementRule(pattern409, replacement409) pattern410 = Pattern(Integral((d_ + x_*WC('e', S(1)))**m_*(x_*WC('g', S(1)) + WC('f', S(0)))**S(2)*(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0)))**p_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons21, cons5, cons315, cons226, cons256, cons147, cons270) def replacement410(p, m, f, b, g, d, a, c, x, e): rubi.append(410) return -Dist(S(1)/(c*e**S(2)*(m + S(2)*p + S(3))), Int((d + e*x)**m*(a + b*x + c*x**S(2))**p*Simp(b*e*g*(d*g + e*f*(m + p + S(1))) - c*(d**S(2)*g**S(2) + d*e*f*g*m + e**S(2)*f**S(2)*(m + S(2)*p + S(3))) + e*g*x*(b*e*g*(m + p + S(2)) - c*(d*g*m + e*f*(m + S(2)*p + S(4)))), x), x), x) + Simp(g*(d + e*x)**m*(f + g*x)*(a + b*x + c*x**S(2))**(p + S(1))/(c*(m + S(2)*p + S(3))), x) rule410 = ReplacementRule(pattern410, replacement410) pattern411 = Pattern(Integral((a_ + x_**S(2)*WC('c', S(1)))**p_*(d_ + x_*WC('e', S(1)))**m_*(x_*WC('g', S(1)) + WC('f', S(0)))**S(2), x_), cons2, cons7, cons27, cons48, cons125, cons208, cons21, cons5, cons315, cons257, cons147, cons270) def replacement411(p, m, f, g, d, c, a, x, e): rubi.append(411) return -Dist(S(1)/(c*e**S(2)*(m + S(2)*p + S(3))), Int((a + c*x**S(2))**p*(d + e*x)**m*Simp(-c*e*g*x*(d*g*m + e*f*(m + S(2)*p + S(4))) - c*(d**S(2)*g**S(2) + d*e*f*g*m + e**S(2)*f**S(2)*(m + S(2)*p + S(3))), x), x), x) + Simp(g*(a + c*x**S(2))**(p + S(1))*(d + e*x)**m*(f + g*x)/(c*(m + S(2)*p + S(3))), x) rule411 = ReplacementRule(pattern411, replacement411) pattern412 = Pattern(Integral((x_*WC('e', S(1)))**m_*(x_*WC('g', S(1)) + WC('f', S(0)))**WC('n', S(1))*(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)))**p_, x_), cons3, cons7, cons48, cons125, cons208, cons21, cons4, cons147) def replacement412(p, m, f, b, g, c, n, x, e): rubi.append(412) return Dist(x**(-m - p)*(e*x)**m*(b + c*x)**(-p)*(b*x + c*x**S(2))**p, Int(x**(m + p)*(b + c*x)**p*(f + g*x)**n, x), x) rule412 = ReplacementRule(pattern412, replacement412) pattern413 = Pattern(Integral((a_ + x_**S(2)*WC('c', S(1)))**p_*(d_ + x_*WC('e', S(1)))**m_*(x_*WC('g', S(1)) + WC('f', S(0)))**WC('n', S(1)), x_), cons2, cons7, cons27, cons48, cons125, cons208, cons21, cons4, cons315, cons257, cons147, cons43, cons268) def replacement413(p, m, f, g, d, c, n, a, x, e): rubi.append(413) return Int((d + e*x)**(m + p)*(f + g*x)**n*(a/d + c*x/e)**p, x) rule413 = ReplacementRule(pattern413, replacement413) pattern414 = Pattern(Integral((d_ + x_*WC('e', S(1)))**m_*(x_*WC('g', S(1)) + WC('f', S(0)))**WC('n', S(1))*(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0)))**p_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons21, cons4, cons315, cons226, cons256, cons147) def replacement414(p, m, f, g, b, d, a, n, c, x, e): rubi.append(414) return Dist((d + e*x)**(-FracPart(p))*(a/d + c*x/e)**(-FracPart(p))*(a + b*x + c*x**S(2))**FracPart(p), Int((d + e*x)**(m + p)*(f + g*x)**n*(a/d + c*x/e)**p, x), x) rule414 = ReplacementRule(pattern414, replacement414) pattern415 = Pattern(Integral((a_ + x_**S(2)*WC('c', S(1)))**p_*(d_ + x_*WC('e', S(1)))**m_*(x_*WC('g', S(1)) + WC('f', S(0)))**WC('n', S(1)), x_), cons2, cons7, cons27, cons48, cons125, cons208, cons21, cons4, cons315, cons257, cons147) def replacement415(p, m, f, g, d, c, n, a, x, e): rubi.append(415) return Dist((a + c*x**S(2))**FracPart(p)*(d + e*x)**(-FracPart(p))*(a/d + c*x/e)**(-FracPart(p)), Int((d + e*x)**(m + p)*(f + g*x)**n*(a/d + c*x/e)**p, x), x) rule415 = ReplacementRule(pattern415, replacement415) pattern416 = Pattern(Integral((x_*WC('e', S(1)) + WC('d', S(0)))**WC('m', S(1))*(x_*WC('g', S(1)) + WC('f', S(0)))*(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons21, cons315, cons226, cons279, cons128) def replacement416(p, m, f, g, b, d, a, c, x, e): rubi.append(416) return Int(ExpandIntegrand((d + e*x)**m*(f + g*x)*(a + b*x + c*x**S(2))**p, x), x) rule416 = ReplacementRule(pattern416, replacement416) pattern417 = Pattern(Integral((a_ + x_**S(2)*WC('c', S(1)))**WC('p', S(1))*(x_*WC('e', S(1)) + WC('d', S(0)))**WC('m', S(1))*(x_*WC('g', S(1)) + WC('f', S(0))), x_), cons2, cons7, cons27, cons48, cons125, cons208, cons21, cons280, cons128) def replacement417(p, m, f, g, d, c, a, x, e): rubi.append(417) return Int(ExpandIntegrand((a + c*x**S(2))**p*(d + e*x)**m*(f + g*x), x), x) rule417 = ReplacementRule(pattern417, replacement417) pattern418 = Pattern(Integral((x_*WC('g', S(1)) + WC('f', S(0)))/((x_*WC('e', S(1)) + WC('d', S(0)))*(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons315, cons226, cons279) def replacement418(f, g, b, d, a, c, x, e): rubi.append(418) return Dist(e*(-d*g + e*f)/(a*e**S(2) - b*d*e + c*d**S(2)), Int(S(1)/(d + e*x), x), x) + Dist(S(1)/(a*e**S(2) - b*d*e + c*d**S(2)), Int(Simp(a*e*g - b*e*f + c*d*f - c*x*(-d*g + e*f), x)/(a + b*x + c*x**S(2)), x), x) rule418 = ReplacementRule(pattern418, replacement418) pattern419 = Pattern(Integral((x_*WC('g', S(1)) + WC('f', S(0)))/((a_ + x_**S(2)*WC('c', S(1)))*(x_*WC('e', S(1)) + WC('d', S(0)))), x_), cons2, cons7, cons27, cons48, cons125, cons208, cons315, cons280) def replacement419(f, g, d, c, a, x, e): rubi.append(419) return Dist(e*(-d*g + e*f)/(a*e**S(2) + c*d**S(2)), Int(S(1)/(d + e*x), x), x) + Dist(S(1)/(a*e**S(2) + c*d**S(2)), Int(Simp(a*e*g + c*d*f - c*x*(-d*g + e*f), x)/(a + c*x**S(2)), x), x) rule419 = ReplacementRule(pattern419, replacement419) pattern420 = Pattern(Integral((x_*WC('e', S(1)) + WC('d', S(0)))**m_*(x_*WC('g', S(1)) + WC('f', S(0)))*(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons21, cons5, cons315, cons226, cons279, cons242, cons350) def replacement420(p, m, f, g, b, d, a, c, x, e): rubi.append(420) return -Simp((d + e*x)**(m + S(1))*(-d*g + e*f)*(a + b*x + c*x**S(2))**(p + S(1))/(S(2)*(p + S(1))*(a*e**S(2) - b*d*e + c*d**S(2))), x) rule420 = ReplacementRule(pattern420, replacement420) pattern421 = Pattern(Integral((a_ + x_**S(2)*WC('c', S(1)))**WC('p', S(1))*(x_*WC('e', S(1)) + WC('d', S(0)))**m_*(x_*WC('g', S(1)) + WC('f', S(0))), x_), cons2, cons7, cons27, cons48, cons125, cons208, cons21, cons5, cons315, cons280, cons242, cons351) def replacement421(p, m, f, g, d, c, a, x, e): rubi.append(421) return -Simp((a + c*x**S(2))**(p + S(1))*(d + e*x)**(m + S(1))*(-d*g + e*f)/(S(2)*(p + S(1))*(a*e**S(2) + c*d**S(2))), x) rule421 = ReplacementRule(pattern421, replacement421) pattern422 = Pattern(Integral((x_*WC('e', S(1)) + WC('d', S(0)))**WC('m', S(1))*(x_*WC('g', S(1)) + WC('f', S(0)))*(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0)))**p_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons315, cons226, cons279, cons242, cons13, cons137, cons352) def replacement422(p, m, f, g, b, d, a, c, x, e): rubi.append(422) return -Dist(m*(-S(2)*a*e*g + b*(d*g + e*f) - S(2)*c*d*f)/((p + S(1))*(-S(4)*a*c + b**S(2))), Int((d + e*x)**(m + S(-1))*(a + b*x + c*x**S(2))**(p + S(1)), x), x) + Simp((d + e*x)**m*(a + b*x + c*x**S(2))**(p + S(1))*(-S(2)*a*g + b*f + x*(-b*g + S(2)*c*f))/((p + S(1))*(-S(4)*a*c + b**S(2))), x) rule422 = ReplacementRule(pattern422, replacement422) pattern423 = Pattern(Integral((a_ + x_**S(2)*WC('c', S(1)))**p_*(x_*WC('e', S(1)) + WC('d', S(0)))**WC('m', S(1))*(x_*WC('g', S(1)) + WC('f', S(0))), x_), cons2, cons7, cons27, cons48, cons125, cons208, cons315, cons280, cons242, cons13, cons137, cons353) def replacement423(p, m, f, g, d, c, a, x, e): rubi.append(423) return -Dist(m*(a*e*g + c*d*f)/(S(2)*a*c*(p + S(1))), Int((a + c*x**S(2))**(p + S(1))*(d + e*x)**(m + S(-1)), x), x) + Simp((a + c*x**S(2))**(p + S(1))*(d + e*x)**m*(a*g - c*f*x)/(S(2)*a*c*(p + S(1))), x) rule423 = ReplacementRule(pattern423, replacement423) pattern424 = Pattern(Integral((x_*WC('e', S(1)) + WC('d', S(0)))**m_*(x_*WC('g', S(1)) + WC('f', S(0)))*(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons21, cons5, cons315, cons226, cons279, cons242) def replacement424(p, m, f, g, b, d, a, c, x, e): rubi.append(424) return -Dist((-S(2)*a*e*g + b*(d*g + e*f) - S(2)*c*d*f)/(S(2)*a*e**S(2) - S(2)*b*d*e + S(2)*c*d**S(2)), Int((d + e*x)**(m + S(1))*(a + b*x + c*x**S(2))**p, x), x) - Simp((d + e*x)**(m + S(1))*(-d*g + e*f)*(a + b*x + c*x**S(2))**(p + S(1))/(S(2)*(p + S(1))*(a*e**S(2) - b*d*e + c*d**S(2))), x) rule424 = ReplacementRule(pattern424, replacement424) pattern425 = Pattern(Integral((a_ + x_**S(2)*WC('c', S(1)))**WC('p', S(1))*(x_*WC('e', S(1)) + WC('d', S(0)))**m_*(x_*WC('g', S(1)) + WC('f', S(0))), x_), cons2, cons7, cons27, cons48, cons125, cons208, cons21, cons5, cons315, cons280, cons242) def replacement425(p, m, f, g, d, c, a, x, e): rubi.append(425) return Dist((a*e*g + c*d*f)/(a*e**S(2) + c*d**S(2)), Int((a + c*x**S(2))**p*(d + e*x)**(m + S(1)), x), x) - Simp((a + c*x**S(2))**(p + S(1))*(d + e*x)**(m + S(1))*(-d*g + e*f)/(S(2)*(p + S(1))*(a*e**S(2) + c*d**S(2))), x) rule425 = ReplacementRule(pattern425, replacement425) pattern426 = Pattern(Integral((x_*WC('e', S(1)) + WC('d', S(0)))*(x_*WC('g', S(1)) + WC('f', S(0)))*(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0)))**p_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons5, cons315, cons226, cons279, cons354) def replacement426(p, f, g, b, d, a, c, x, e): rubi.append(426) return -Simp((a + b*x + c*x**S(2))**(p + S(1))*(b*e*g*(p + S(2)) - S(2)*c*e*g*x*(p + S(1)) - c*(S(2)*p + S(3))*(d*g + e*f))/(S(2)*c**S(2)*(p + S(1))*(S(2)*p + S(3))), x) rule426 = ReplacementRule(pattern426, replacement426) pattern427 = Pattern(Integral((a_ + x_**S(2)*WC('c', S(1)))**p_*(x_*WC('e', S(1)) + WC('d', S(0)))*(x_*WC('g', S(1)) + WC('f', S(0))), x_), cons2, cons7, cons27, cons48, cons125, cons208, cons5, cons315, cons280, cons355) def replacement427(p, f, g, d, c, a, x, e): rubi.append(427) return Simp((a + c*x**S(2))**(p + S(1))*(S(2)*e*g*x*(p + S(1)) + (S(2)*p + S(3))*(d*g + e*f))/(S(2)*c*(p + S(1))*(S(2)*p + S(3))), x) rule427 = ReplacementRule(pattern427, replacement427) pattern428 = Pattern(Integral((x_*WC('e', S(1)) + WC('d', S(0)))*(x_*WC('g', S(1)) + WC('f', S(0)))*(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0)))**p_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons315, cons226, cons279, cons13, cons137) def replacement428(p, f, g, b, d, a, c, x, e): rubi.append(428) return -Dist((-S(2)*a*c*e*g + b**S(2)*e*g*(p + S(2)) + c*(S(2)*p + S(3))*(-b*(d*g + e*f) + S(2)*c*d*f))/(c*(p + S(1))*(-S(4)*a*c + b**S(2))), Int((a + b*x + c*x**S(2))**(p + S(1)), x), x) - Simp((a + b*x + c*x**S(2))**(p + S(1))*(S(2)*a*c*(d*g + e*f) - b*(a*e*g + c*d*f) - x*(b**S(2)*e*g - b*c*(d*g + e*f) + S(2)*c*(-a*e*g + c*d*f)))/(c*(p + S(1))*(-S(4)*a*c + b**S(2))), x) rule428 = ReplacementRule(pattern428, replacement428) pattern429 = Pattern(Integral((a_ + x_**S(2)*WC('c', S(1)))**p_*(x_*WC('e', S(1)) + WC('d', S(0)))*(x_*WC('g', S(1)) + WC('f', S(0))), x_), cons2, cons7, cons27, cons48, cons125, cons208, cons315, cons280, cons13, cons137) def replacement429(p, f, g, d, c, a, x, e): rubi.append(429) return -Dist((a*e*g - c*d*f*(S(2)*p + S(3)))/(S(2)*a*c*(p + S(1))), Int((a + c*x**S(2))**(p + S(1)), x), x) - Simp((a + c*x**S(2))**(p + S(1))*(-a*(d*g + e*(f + g*x)) + c*d*f*x)/(S(2)*a*c*(p + S(1))), x) rule429 = ReplacementRule(pattern429, replacement429) pattern430 = Pattern(Integral((x_*WC('e', S(1)) + WC('d', S(0)))*(x_*WC('g', S(1)) + WC('f', S(0)))*(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0)))**p_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons5, cons315, cons226, cons279, cons287) def replacement430(p, f, g, b, d, a, c, x, e): rubi.append(430) return Dist((-S(2)*a*c*e*g + b**S(2)*e*g*(p + S(2)) + c*(S(2)*p + S(3))*(-b*(d*g + e*f) + S(2)*c*d*f))/(S(2)*c**S(2)*(S(2)*p + S(3))), Int((a + b*x + c*x**S(2))**p, x), x) - Simp((a + b*x + c*x**S(2))**(p + S(1))*(b*e*g*(p + S(2)) - S(2)*c*e*g*x*(p + S(1)) - c*(S(2)*p + S(3))*(d*g + e*f))/(S(2)*c**S(2)*(p + S(1))*(S(2)*p + S(3))), x) rule430 = ReplacementRule(pattern430, replacement430) pattern431 = Pattern(Integral((a_ + x_**S(2)*WC('c', S(1)))**p_*(x_*WC('e', S(1)) + WC('d', S(0)))*(x_*WC('g', S(1)) + WC('f', S(0))), x_), cons2, cons7, cons27, cons48, cons125, cons208, cons5, cons315, cons280, cons287) def replacement431(p, f, g, d, c, a, x, e): rubi.append(431) return -Dist((a*e*g - c*d*f*(S(2)*p + S(3)))/(c*(S(2)*p + S(3))), Int((a + c*x**S(2))**p, x), x) + Simp((a + c*x**S(2))**(p + S(1))*(S(2)*e*g*x*(p + S(1)) + (S(2)*p + S(3))*(d*g + e*f))/(S(2)*c*(p + S(1))*(S(2)*p + S(3))), x) rule431 = ReplacementRule(pattern431, replacement431) pattern432 = Pattern(Integral((x_*WC('e', S(1)))**m_*(a_ + x_**S(2)*WC('c', S(1)))**p_*(f_ + x_*WC('g', S(1))), x_), cons2, cons7, cons48, cons125, cons208, cons5, cons356, cons357) def replacement432(p, m, g, f, c, a, x, e): rubi.append(432) return Dist(f, Int((e*x)**m*(a + c*x**S(2))**p, x), x) + Dist(g/e, Int((e*x)**(m + S(1))*(a + c*x**S(2))**p, x), x) rule432 = ReplacementRule(pattern432, replacement432) pattern433 = Pattern(Integral((x_*WC('e', S(1)) + WC('d', S(0)))**m_*(x_*WC('g', S(1)) + WC('f', S(0)))*(a_ + x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)))**p_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons21, cons5, cons358, cons288, cons289) def replacement433(p, m, f, b, g, d, c, a, x, e): rubi.append(433) return Dist((d + e*x)**FracPart(p)*(a*d + c*e*x**S(3))**(-FracPart(p))*(a + b*x + c*x**S(2))**FracPart(p), Int((f + g*x)*(a*d + c*e*x**S(3))**p, x), x) rule433 = ReplacementRule(pattern433, replacement433) pattern434 = Pattern(Integral((x_*WC('e', S(1)) + WC('d', S(0)))**m_*(x_*WC('g', S(1)) + WC('f', S(0)))*(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons315, cons226, cons279, cons244, cons163, cons247, cons359, cons360) def replacement434(p, m, f, g, b, d, a, c, x, e): rubi.append(434) return -Dist(p/(e**S(2)*(m + S(1))*(m + S(2))*(a*e**S(2) - b*d*e + c*d**S(2))), Int((d + e*x)**(m + S(2))*(a + b*x + c*x**S(2))**(p + S(-1))*Simp(S(2)*a*c*e*(m + S(2))*(-d*g + e*f) + b**S(2)*e*(d*g*(p + S(1)) - e*f*(m + p + S(2))) + b*(a*e**S(2)*g*(m + S(1)) - c*d*(d*g*(S(2)*p + S(1)) - e*f*(m + S(2)*p + S(2)))) - c*x*(S(2)*c*d*(d*g*(S(2)*p + S(1)) - e*f*(m + S(2)*p + S(2))) - e*(S(2)*a*e*g*(m + S(1)) - b*(d*g*(m - S(2)*p) + e*f*(m + S(2)*p + S(2))))), x), x), x) - Simp((d + e*x)**(m + S(1))*(a + b*x + c*x**S(2))**p*(-d*p*(-b*e + S(2)*c*d)*(-d*g + e*f) - e*x*(g*(m + S(1))*(a*e**S(2) - b*d*e + c*d**S(2)) + p*(-b*e + S(2)*c*d)*(-d*g + e*f)) + (d*g - e*f*(m + S(2)))*(a*e**S(2) - b*d*e + c*d**S(2)))/(e**S(2)*(m + S(1))*(m + S(2))*(a*e**S(2) - b*d*e + c*d**S(2))), x) rule434 = ReplacementRule(pattern434, replacement434) pattern435 = Pattern(Integral((a_ + x_**S(2)*WC('c', S(1)))**WC('p', S(1))*(x_*WC('e', S(1)) + WC('d', S(0)))**m_*(x_*WC('g', S(1)) + WC('f', S(0))), x_), cons2, cons7, cons27, cons48, cons125, cons208, cons315, cons280, cons244, cons163, cons247, cons359, cons360) def replacement435(p, m, f, g, d, c, a, x, e): rubi.append(435) return -Dist(p/(e**S(2)*(m + S(1))*(m + S(2))*(a*e**S(2) + c*d**S(2))), Int((a + c*x**S(2))**(p + S(-1))*(d + e*x)**(m + S(2))*Simp(S(2)*a*c*e*(m + S(2))*(-d*g + e*f) - c*x*(-S(2)*a*e**S(2)*g*(m + S(1)) + S(2)*c*d*(d*g*(S(2)*p + S(1)) - e*f*(m + S(2)*p + S(2)))), x), x), x) - Simp((a + c*x**S(2))**p*(d + e*x)**(m + S(1))*(-S(2)*c*d**S(2)*p*(-d*g + e*f) - e*x*(S(2)*c*d*p*(-d*g + e*f) + g*(m + S(1))*(a*e**S(2) + c*d**S(2))) + (a*e**S(2) + c*d**S(2))*(d*g - e*f*(m + S(2))))/(e**S(2)*(m + S(1))*(m + S(2))*(a*e**S(2) + c*d**S(2))), x) rule435 = ReplacementRule(pattern435, replacement435) pattern436 = Pattern(Integral((x_*WC('e', S(1)) + WC('d', S(0)))**m_*(x_*WC('g', S(1)) + WC('f', S(0)))*(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons21, cons315, cons226, cons279, cons13, cons163, cons361, cons66, cons299, cons362) def replacement436(p, m, f, g, b, d, a, c, x, e): rubi.append(436) return Dist(p/(e**S(2)*(m + S(1))*(m + S(2)*p + S(2))), Int((d + e*x)**(m + S(1))*(a + b*x + c*x**S(2))**(p + S(-1))*Simp(-b*e*f*(m + S(2)*p + S(2)) + g*(S(2)*a*e*m + S(2)*a*e + S(2)*b*d*p + b*d) + x*(-S(2)*c*e*f*(m + S(2)*p + S(2)) + g*(b*e*m + b*e + S(4)*c*d*p + S(2)*c*d)), x), x), x) + Simp((d + e*x)**(m + S(1))*(a + b*x + c*x**S(2))**p*(-d*g*(S(2)*p + S(1)) + e*f*(m + S(2)*p + S(2)) + e*g*x*(m + S(1)))/(e**S(2)*(m + S(1))*(m + S(2)*p + S(2))), x) rule436 = ReplacementRule(pattern436, replacement436) pattern437 = Pattern(Integral((a_ + x_**S(2)*WC('c', S(1)))**WC('p', S(1))*(x_*WC('e', S(1)) + WC('d', S(0)))**m_*(x_*WC('g', S(1)) + WC('f', S(0))), x_), cons2, cons7, cons27, cons48, cons125, cons208, cons21, cons315, cons280, cons13, cons163, cons361, cons66, cons299, cons362) def replacement437(p, m, f, g, d, c, a, x, e): rubi.append(437) return Dist(p/(e**S(2)*(m + S(1))*(m + S(2)*p + S(2))), Int((a + c*x**S(2))**(p + S(-1))*(d + e*x)**(m + S(1))*Simp(g*(S(2)*a*e*m + S(2)*a*e) + x*(-S(2)*c*e*f*(m + S(2)*p + S(2)) + g*(S(4)*c*d*p + S(2)*c*d)), x), x), x) + Simp((a + c*x**S(2))**p*(d + e*x)**(m + S(1))*(-d*g*(S(2)*p + S(1)) + e*f*(m + S(2)*p + S(2)) + e*g*x*(m + S(1)))/(e**S(2)*(m + S(1))*(m + S(2)*p + S(2))), x) rule437 = ReplacementRule(pattern437, replacement437) pattern438 = Pattern(Integral((x_*WC('e', S(1)) + WC('d', S(0)))**m_*(x_*WC('g', S(1)) + WC('f', S(0)))*(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons21, cons315, cons226, cons279, cons13, cons163, cons363, cons303, cons362) def replacement438(p, m, f, g, b, d, a, c, x, e): rubi.append(438) return -Dist(p/(c*e**S(2)*(m + S(2)*p + S(1))*(m + S(2)*p + S(2))), Int((d + e*x)**m*(a + b*x + c*x**S(2))**(p + S(-1))*Simp(c*e*f*(-S(2)*a*e + b*d)*(m + S(2)*p + S(2)) + g*(a*e*(b*e*m + b*e - S(2)*c*d*m) + b*d*(b*e*p - S(2)*c*d*p - c*d)) + x*(c*e*f*(-b*e + S(2)*c*d)*(m + S(2)*p + S(2)) + g*(b**S(2)*e**S(2)*(m + p + S(1)) - S(2)*c**S(2)*d**S(2)*(S(2)*p + S(1)) - c*e*(S(2)*a*e*(m + S(2)*p + S(1)) + b*d*(m - S(2)*p)))), x), x), x) + Simp((d + e*x)**(m + S(1))*(a + b*x + c*x**S(2))**p*(c*e*f*(m + S(2)*p + S(2)) + c*e*g*x*(m + S(2)*p + S(1)) - g*(-b*e*p + S(2)*c*d*p + c*d))/(c*e**S(2)*(m + S(2)*p + S(1))*(m + S(2)*p + S(2))), x) rule438 = ReplacementRule(pattern438, replacement438) pattern439 = Pattern(Integral((a_ + x_**S(2)*WC('c', S(1)))**WC('p', S(1))*(x_*WC('e', S(1)) + WC('d', S(0)))**m_*(x_*WC('g', S(1)) + WC('f', S(0))), x_), cons2, cons7, cons27, cons48, cons125, cons208, cons21, cons315, cons280, cons13, cons163, cons363, cons303, cons362) def replacement439(p, m, f, g, d, c, a, x, e): rubi.append(439) return Dist(S(2)*p/(c*e**S(2)*(m + S(2)*p + S(1))*(m + S(2)*p + S(2))), Int((a + c*x**S(2))**(p + S(-1))*(d + e*x)**m*Simp(a*c*d*e*g*m + a*c*e**S(2)*f*(m + S(2)*p + S(2)) - x*(c**S(2)*d*e*f*(m + S(2)*p + S(2)) - g*(a*c*e**S(2)*(m + S(2)*p + S(1)) + c**S(2)*d**S(2)*(S(2)*p + S(1)))), x), x), x) + Simp((a + c*x**S(2))**p*(d + e*x)**(m + S(1))*(-c*d*g*(S(2)*p + S(1)) + c*e*f*(m + S(2)*p + S(2)) + c*e*g*x*(m + S(2)*p + S(1)))/(c*e**S(2)*(m + S(2)*p + S(1))*(m + S(2)*p + S(2))), x) rule439 = ReplacementRule(pattern439, replacement439) pattern440 = Pattern(Integral((x_*WC('e', S(1)) + WC('d', S(0)))**m_*(x_*WC('g', S(1)) + WC('f', S(0)))*(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons315, cons226, cons279, cons244, cons137, cons166, cons364) def replacement440(p, m, f, g, b, d, a, c, x, e): rubi.append(440) return -Dist(S(1)/(c*(p + S(1))*(-S(4)*a*c + b**S(2))), Int((d + e*x)**(m + S(-2))*(a + b*x + c*x**S(2))**(p + S(1))*Simp(b*e*g*(a*e*(m + S(-1)) + b*d*(p + S(2))) + S(2)*c**S(2)*d**S(2)*f*(S(2)*p + S(3)) - c*(S(2)*a*e*(d*g*m + e*f*(m + S(-1))) + b*d*(d*g*(S(2)*p + S(3)) - e*f*(m - S(2)*p + S(-4)))) + e*x*(b**S(2)*e*g*(m + p + S(1)) + S(2)*c**S(2)*d*f*(m + S(2)*p + S(2)) - c*(S(2)*a*e*g*m + b*(d*g + e*f)*(m + S(2)*p + S(2)))), x), x), x) - Simp((d + e*x)**(m + S(-1))*(a + b*x + c*x**S(2))**(p + S(1))*(S(2)*a*c*(d*g + e*f) - b*(a*e*g + c*d*f) - x*(b**S(2)*e*g + S(2)*c**S(2)*d*f - c*(S(2)*a*e*g + b*d*g + b*e*f)))/(c*(p + S(1))*(-S(4)*a*c + b**S(2))), x) rule440 = ReplacementRule(pattern440, replacement440) pattern441 = Pattern(Integral((a_ + x_**S(2)*WC('c', S(1)))**WC('p', S(1))*(x_*WC('e', S(1)) + WC('d', S(0)))**m_*(x_*WC('g', S(1)) + WC('f', S(0))), x_), cons2, cons7, cons27, cons48, cons125, cons208, cons315, cons280, cons244, cons137, cons166, cons365) def replacement441(p, m, f, g, d, c, a, x, e): rubi.append(441) return -Dist(S(1)/(S(4)*a*c*(p + S(1))), Int((a + c*x**S(2))**(p + S(1))*(d + e*x)**(m + S(-2))*Simp(S(2)*a*e*(d*g*m + e*f*(m + S(-1))) - S(2)*c*d**S(2)*f*(S(2)*p + S(3)) + e*x*(S(2)*a*e*g*m - S(2)*c*d*f*(m + S(2)*p + S(2))), x), x), x) + Simp((a + c*x**S(2))**(p + S(1))*(d + e*x)**(m + S(-1))*(S(2)*a*(d*g + e*f) - x*(-S(2)*a*e*g + S(2)*c*d*f))/(S(4)*a*c*(p + S(1))), x) rule441 = ReplacementRule(pattern441, replacement441) pattern442 = Pattern(Integral((x_*WC('e', S(1)) + WC('d', S(0)))**WC('m', S(1))*(x_*WC('g', S(1)) + WC('f', S(0)))*(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0)))**p_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons315, cons226, cons279, cons244, cons137, cons168, cons366, cons362) def replacement442(p, m, f, g, b, d, a, c, x, e): rubi.append(442) return Dist(S(1)/((p + S(1))*(-S(4)*a*c + b**S(2))), Int((d + e*x)**(m + S(-1))*(a + b*x + c*x**S(2))**(p + S(1))*Simp(-e*x*(-b*g + S(2)*c*f)*(m + S(2)*p + S(3)) - f*(b*e*m + S(2)*c*d*(S(2)*p + S(3))) + g*(S(2)*a*e*m + b*d*(S(2)*p + S(3))), x), x), x) + Simp((d + e*x)**m*(a + b*x + c*x**S(2))**(p + S(1))*(-S(2)*a*g + b*f + x*(-b*g + S(2)*c*f))/((p + S(1))*(-S(4)*a*c + b**S(2))), x) rule442 = ReplacementRule(pattern442, replacement442) pattern443 = Pattern(Integral((a_ + x_**S(2)*WC('c', S(1)))**p_*(x_*WC('e', S(1)) + WC('d', S(0)))**WC('m', S(1))*(x_*WC('g', S(1)) + WC('f', S(0))), x_), cons2, cons7, cons27, cons48, cons125, cons208, cons315, cons280, cons244, cons137, cons168, cons366, cons362) def replacement443(p, m, f, g, d, c, a, x, e): rubi.append(443) return -Dist(S(1)/(S(2)*a*c*(p + S(1))), Int((a + c*x**S(2))**(p + S(1))*(d + e*x)**(m + S(-1))*Simp(a*e*g*m - c*d*f*(S(2)*p + S(3)) - c*e*f*x*(m + S(2)*p + S(3)), x), x), x) + Simp((a + c*x**S(2))**(p + S(1))*(d + e*x)**m*(a*g - c*f*x)/(S(2)*a*c*(p + S(1))), x) rule443 = ReplacementRule(pattern443, replacement443) pattern444 = Pattern(Integral((x_*WC('e', S(1)) + WC('d', S(0)))**m_*(x_*WC('g', S(1)) + WC('f', S(0)))*(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0)))**p_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons21, cons315, cons226, cons279, cons13, cons137, cons362) def replacement444(p, m, f, g, b, d, a, c, x, e): rubi.append(444) return Dist(S(1)/((p + S(1))*(-S(4)*a*c + b**S(2))*(a*e**S(2) - b*d*e + c*d**S(2))), Int((d + e*x)**m*(a + b*x + c*x**S(2))**(p + S(1))*Simp(c*e*x*(-f*(-b*e + S(2)*c*d) + g*(-S(2)*a*e + b*d))*(m + S(2)*p + S(4)) + f*(-S(2)*a*c*e**S(2)*(m + S(2)*p + S(3)) + b**S(2)*e**S(2)*(m + p + S(2)) + b*c*d*e*(-m + S(2)*p + S(2)) - S(2)*c**S(2)*d**S(2)*(S(2)*p + S(3))) - g*(a*e*(b*e*m + b*e - S(2)*c*d*m) - b*d*(-b*e*p - b*e + S(2)*c*d*p + S(3)*c*d)), x), x), x) + Simp((d + e*x)**(m + S(1))*(a + b*x + c*x**S(2))**(p + S(1))*(-a*g*(-b*e + S(2)*c*d) + c*x*(f*(-b*e + S(2)*c*d) - g*(-S(2)*a*e + b*d)) + f*(S(2)*a*c*e - b**S(2)*e + b*c*d))/((p + S(1))*(-S(4)*a*c + b**S(2))*(a*e**S(2) - b*d*e + c*d**S(2))), x) rule444 = ReplacementRule(pattern444, replacement444) pattern445 = Pattern(Integral((a_ + x_**S(2)*WC('c', S(1)))**p_*(x_*WC('e', S(1)) + WC('d', S(0)))**m_*(x_*WC('g', S(1)) + WC('f', S(0))), x_), cons2, cons7, cons27, cons48, cons125, cons208, cons315, cons280, cons13, cons137, cons362) def replacement445(p, m, f, g, d, c, a, x, e): rubi.append(445) return Dist(S(1)/(S(2)*a*c*(p + S(1))*(a*e**S(2) + c*d**S(2))), Int((a + c*x**S(2))**(p + S(1))*(d + e*x)**m*Simp(-a*c*d*e*g*m + c*e*x*(a*e*g + c*d*f)*(m + S(2)*p + S(4)) + f*(a*c*e**S(2)*(m + S(2)*p + S(3)) + c**S(2)*d**S(2)*(S(2)*p + S(3))), x), x), x) - Simp((a + c*x**S(2))**(p + S(1))*(d + e*x)**(m + S(1))*(-a*c*d*g + a*c*e*f + c*x*(a*e*g + c*d*f))/(S(2)*a*c*(p + S(1))*(a*e**S(2) + c*d**S(2))), x) rule445 = ReplacementRule(pattern445, replacement445) pattern446 = Pattern(Integral((x_*WC('e', S(1)) + WC('d', S(0)))**WC('m', S(1))*(x_*WC('g', S(1)) + WC('f', S(0)))/(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons315, cons226, cons279, cons17) def replacement446(m, f, g, b, d, a, c, x, e): rubi.append(446) return Int(ExpandIntegrand((d + e*x)**m*(f + g*x)/(a + b*x + c*x**S(2)), x), x) rule446 = ReplacementRule(pattern446, replacement446) pattern447 = Pattern(Integral((x_*WC('e', S(1)) + WC('d', S(0)))**WC('m', S(1))*(x_*WC('g', S(1)) + WC('f', S(0)))/(a_ + x_**S(2)*WC('c', S(1))), x_), cons2, cons7, cons27, cons48, cons125, cons208, cons315, cons280, cons17) def replacement447(m, f, g, d, c, a, x, e): rubi.append(447) return Int(ExpandIntegrand((d + e*x)**m*(f + g*x)/(a + c*x**S(2)), x), x) rule447 = ReplacementRule(pattern447, replacement447) pattern448 = Pattern(Integral((x_*WC('e', S(1)) + WC('d', S(0)))**m_*(x_*WC('g', S(1)) + WC('f', S(0)))/(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons315, cons226, cons279, cons367, cons168) def replacement448(m, f, g, b, d, a, c, x, e): rubi.append(448) return Dist(S(1)/c, Int((d + e*x)**(m + S(-1))*Simp(-a*e*g + c*d*f + x*(-b*e*g + c*d*g + c*e*f), x)/(a + b*x + c*x**S(2)), x), x) + Simp(g*(d + e*x)**m/(c*m), x) rule448 = ReplacementRule(pattern448, replacement448) pattern449 = Pattern(Integral((x_*WC('e', S(1)) + WC('d', S(0)))**m_*(x_*WC('g', S(1)) + WC('f', S(0)))/(a_ + x_**S(2)*WC('c', S(1))), x_), cons2, cons7, cons27, cons48, cons125, cons208, cons315, cons280, cons367, cons168) def replacement449(m, f, g, d, c, a, x, e): rubi.append(449) return Dist(S(1)/c, Int((d + e*x)**(m + S(-1))*Simp(-a*e*g + c*d*f + x*(c*d*g + c*e*f), x)/(a + c*x**S(2)), x), x) + Simp(g*(d + e*x)**m/(c*m), x) rule449 = ReplacementRule(pattern449, replacement449) pattern450 = Pattern(Integral((x_*WC('g', S(1)) + WC('f', S(0)))/(sqrt(x_*WC('e', S(1)) + WC('d', S(0)))*(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons315, cons226, cons279) def replacement450(f, g, b, d, a, c, x, e): rubi.append(450) return Dist(S(2), Subst(Int((-d*g + e*f + g*x**S(2))/(a*e**S(2) - b*d*e + c*d**S(2) + c*x**S(4) - x**S(2)*(-b*e + S(2)*c*d)), x), x, sqrt(d + e*x)), x) rule450 = ReplacementRule(pattern450, replacement450) pattern451 = Pattern(Integral((x_*WC('g', S(1)) + WC('f', S(0)))/((a_ + x_**S(2)*WC('c', S(1)))*sqrt(x_*WC('e', S(1)) + WC('d', S(0)))), x_), cons2, cons7, cons27, cons48, cons125, cons208, cons315, cons280) def replacement451(f, g, d, c, a, x, e): rubi.append(451) return Dist(S(2), Subst(Int((-d*g + e*f + g*x**S(2))/(a*e**S(2) + c*d**S(2) - S(2)*c*d*x**S(2) + c*x**S(4)), x), x, sqrt(d + e*x)), x) rule451 = ReplacementRule(pattern451, replacement451) pattern452 = Pattern(Integral((x_*WC('e', S(1)) + WC('d', S(0)))**m_*(x_*WC('g', S(1)) + WC('f', S(0)))/(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons21, cons315, cons226, cons279, cons367, cons94) def replacement452(m, f, g, b, d, a, c, x, e): rubi.append(452) return Dist(S(1)/(a*e**S(2) - b*d*e + c*d**S(2)), Int((d + e*x)**(m + S(1))*Simp(a*e*g - b*e*f + c*d*f - c*x*(-d*g + e*f), x)/(a + b*x + c*x**S(2)), x), x) + Simp((d + e*x)**(m + S(1))*(-d*g + e*f)/((m + S(1))*(a*e**S(2) - b*d*e + c*d**S(2))), x) rule452 = ReplacementRule(pattern452, replacement452) pattern453 = Pattern(Integral((x_*WC('e', S(1)) + WC('d', S(0)))**m_*(x_*WC('g', S(1)) + WC('f', S(0)))/(a_ + x_**S(2)*WC('c', S(1))), x_), cons2, cons7, cons27, cons48, cons125, cons208, cons21, cons315, cons280, cons367, cons94) def replacement453(m, f, g, d, c, a, x, e): rubi.append(453) return Dist(S(1)/(a*e**S(2) + c*d**S(2)), Int((d + e*x)**(m + S(1))*Simp(a*e*g + c*d*f - c*x*(-d*g + e*f), x)/(a + c*x**S(2)), x), x) + Simp((d + e*x)**(m + S(1))*(-d*g + e*f)/((m + S(1))*(a*e**S(2) + c*d**S(2))), x) rule453 = ReplacementRule(pattern453, replacement453) pattern454 = Pattern(Integral((x_*WC('e', S(1)) + WC('d', S(0)))**m_*(x_*WC('g', S(1)) + WC('f', S(0)))/(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons315, cons226, cons279, cons356) def replacement454(m, f, g, b, d, a, c, x, e): rubi.append(454) return Int(ExpandIntegrand((d + e*x)**m, (f + g*x)/(a + b*x + c*x**S(2)), x), x) rule454 = ReplacementRule(pattern454, replacement454) pattern455 = Pattern(Integral((x_*WC('e', S(1)) + WC('d', S(0)))**m_*(x_*WC('g', S(1)) + WC('f', S(0)))/(a_ + x_**S(2)*WC('c', S(1))), x_), cons2, cons7, cons27, cons48, cons125, cons208, cons315, cons280, cons356) def replacement455(m, f, g, d, c, a, x, e): rubi.append(455) return Int(ExpandIntegrand((d + e*x)**m, (f + g*x)/(a + c*x**S(2)), x), x) rule455 = ReplacementRule(pattern455, replacement455) pattern456 = Pattern(Integral((x_*WC('e', S(1)) + WC('d', S(0)))**WC('m', S(1))*(x_*WC('g', S(1)) + WC('f', S(0)))*(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons5, cons315, cons226, cons279, cons31, cons168, cons319, cons368, cons362) def replacement456(p, m, f, g, b, d, a, c, x, e): rubi.append(456) return Dist(S(1)/(c*(m + S(2)*p + S(2))), Int((d + e*x)**(m + S(-1))*(a + b*x + c*x**S(2))**p*Simp(d*(p + S(1))*(-b*g + S(2)*c*f) + m*(-a*e*g + c*d*f) + x*(e*(p + S(1))*(-b*g + S(2)*c*f) + m*(-b*e*g + c*d*g + c*e*f)), x), x), x) + Simp(g*(d + e*x)**m*(a + b*x + c*x**S(2))**(p + S(1))/(c*(m + S(2)*p + S(2))), x) rule456 = ReplacementRule(pattern456, replacement456) pattern457 = Pattern(Integral((a_ + x_**S(2)*WC('c', S(1)))**WC('p', S(1))*(x_*WC('e', S(1)) + WC('d', S(0)))**WC('m', S(1))*(x_*WC('g', S(1)) + WC('f', S(0))), x_), cons2, cons7, cons27, cons48, cons125, cons208, cons5, cons315, cons280, cons31, cons168, cons319, cons368, cons362) def replacement457(p, m, f, g, d, c, a, x, e): rubi.append(457) return Dist(S(1)/(c*(m + S(2)*p + S(2))), Int((a + c*x**S(2))**p*(d + e*x)**(m + S(-1))*Simp(-a*e*g*m + c*d*f*(m + S(2)*p + S(2)) + c*x*(d*g*m + e*f*(m + S(2)*p + S(2))), x), x), x) + Simp(g*(a + c*x**S(2))**(p + S(1))*(d + e*x)**m/(c*(m + S(2)*p + S(2))), x) rule457 = ReplacementRule(pattern457, replacement457) pattern458 = Pattern(Integral((x_*WC('e', S(1)) + WC('d', S(0)))**m_*(x_*WC('g', S(1)) + WC('f', S(0)))*(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons5, cons315, cons226, cons279, cons31, cons94, cons362) def replacement458(p, m, f, g, b, d, a, c, x, e): rubi.append(458) return Dist(S(1)/((m + S(1))*(a*e**S(2) - b*d*e + c*d**S(2))), Int((d + e*x)**(m + S(1))*(a + b*x + c*x**S(2))**p*Simp(b*(p + S(1))*(d*g - e*f) - c*x*(-d*g + e*f)*(m + S(2)*p + S(3)) + (m + S(1))*(a*e*g - b*e*f + c*d*f), x), x), x) + Simp((d + e*x)**(m + S(1))*(-d*g + e*f)*(a + b*x + c*x**S(2))**(p + S(1))/((m + S(1))*(a*e**S(2) - b*d*e + c*d**S(2))), x) rule458 = ReplacementRule(pattern458, replacement458) pattern459 = Pattern(Integral((a_ + x_**S(2)*WC('c', S(1)))**WC('p', S(1))*(x_*WC('e', S(1)) + WC('d', S(0)))**m_*(x_*WC('g', S(1)) + WC('f', S(0))), x_), cons2, cons7, cons27, cons48, cons125, cons208, cons5, cons315, cons280, cons31, cons94, cons362) def replacement459(p, m, f, g, d, c, a, x, e): rubi.append(459) return Dist(S(1)/((m + S(1))*(a*e**S(2) + c*d**S(2))), Int((a + c*x**S(2))**p*(d + e*x)**(m + S(1))*Simp(-c*x*(-d*g + e*f)*(m + S(2)*p + S(3)) + (m + S(1))*(a*e*g + c*d*f), x), x), x) + Simp((a + c*x**S(2))**(p + S(1))*(d + e*x)**(m + S(1))*(-d*g + e*f)/((m + S(1))*(a*e**S(2) + c*d**S(2))), x) rule459 = ReplacementRule(pattern459, replacement459) pattern460 = Pattern(Integral((x_*WC('e', S(1)) + WC('d', S(0)))**m_*(x_*WC('g', S(1)) + WC('f', S(0)))*(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons21, cons5, cons315, cons226, cons279, cons369, cons66) def replacement460(p, m, f, g, b, d, a, c, x, e): rubi.append(460) return Dist(S(1)/((m + S(1))*(a*e**S(2) - b*d*e + c*d**S(2))), Int((d + e*x)**(m + S(1))*(a + b*x + c*x**S(2))**p*Simp(b*(p + S(1))*(d*g - e*f) - c*x*(-d*g + e*f)*(m + S(2)*p + S(3)) + (m + S(1))*(a*e*g - b*e*f + c*d*f), x), x), x) + Simp((d + e*x)**(m + S(1))*(-d*g + e*f)*(a + b*x + c*x**S(2))**(p + S(1))/((m + S(1))*(a*e**S(2) - b*d*e + c*d**S(2))), x) rule460 = ReplacementRule(pattern460, replacement460) pattern461 = Pattern(Integral((a_ + x_**S(2)*WC('c', S(1)))**WC('p', S(1))*(x_*WC('e', S(1)) + WC('d', S(0)))**m_*(x_*WC('g', S(1)) + WC('f', S(0))), x_), cons2, cons7, cons27, cons48, cons125, cons208, cons21, cons5, cons315, cons280, cons369, cons66) def replacement461(p, m, f, g, d, c, a, x, e): rubi.append(461) return Dist(S(1)/((m + S(1))*(a*e**S(2) + c*d**S(2))), Int((a + c*x**S(2))**p*(d + e*x)**(m + S(1))*Simp(-c*x*(-d*g + e*f)*(m + S(2)*p + S(3)) + (m + S(1))*(a*e*g + c*d*f), x), x), x) + Simp((a + c*x**S(2))**(p + S(1))*(d + e*x)**(m + S(1))*(-d*g + e*f)/((m + S(1))*(a*e**S(2) + c*d**S(2))), x) rule461 = ReplacementRule(pattern461, replacement461) pattern462 = Pattern(Integral((f_ + x_*WC('g', S(1)))/((x_*WC('e', S(1)) + WC('d', S(0)))*sqrt(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons370, cons371, cons372) def replacement462(g, b, f, d, a, c, x, e): rubi.append(462) return Dist(S(4)*f*(a - d)/(-a*e + b*d), Subst(Int(S(1)/(S(4)*a - S(4)*d - x**S(2)), x), x, (S(2)*a - S(2)*d + x*(b - e))/sqrt(a + b*x + c*x**S(2))), x) rule462 = ReplacementRule(pattern462, replacement462) pattern463 = Pattern(Integral((f_ + x_*WC('g', S(1)))/(sqrt(x_)*sqrt(a_ + x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)))), x_), cons2, cons3, cons7, cons125, cons208, cons226) def replacement463(f, g, b, c, a, x): rubi.append(463) return Dist(S(2), Subst(Int((f + g*x**S(2))/sqrt(a + b*x**S(2) + c*x**S(4)), x), x, sqrt(x)), x) rule463 = ReplacementRule(pattern463, replacement463) pattern464 = Pattern(Integral((f_ + x_*WC('g', S(1)))/(sqrt(x_)*sqrt(a_ + x_**S(2)*WC('c', S(1)))), x_), cons2, cons7, cons125, cons208, cons373) def replacement464(f, g, c, a, x): rubi.append(464) return Dist(S(2), Subst(Int((f + g*x**S(2))/sqrt(a + c*x**S(4)), x), x, sqrt(x)), x) rule464 = ReplacementRule(pattern464, replacement464) pattern465 = Pattern(Integral((f_ + x_*WC('g', S(1)))/(sqrt(e_*x_)*sqrt(a_ + x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)))), x_), cons2, cons3, cons7, cons48, cons125, cons208, cons226) def replacement465(g, b, f, c, a, x, e): rubi.append(465) return Dist(sqrt(x)/sqrt(e*x), Int((f + g*x)/(sqrt(x)*sqrt(a + b*x + c*x**S(2))), x), x) rule465 = ReplacementRule(pattern465, replacement465) pattern466 = Pattern(Integral((f_ + x_*WC('g', S(1)))/(sqrt(e_*x_)*sqrt(a_ + x_**S(2)*WC('c', S(1)))), x_), cons2, cons7, cons48, cons125, cons208, cons374) def replacement466(f, g, c, a, x, e): rubi.append(466) return Dist(sqrt(x)/sqrt(e*x), Int((f + g*x)/(sqrt(x)*sqrt(a + c*x**S(2))), x), x) rule466 = ReplacementRule(pattern466, replacement466) pattern467 = Pattern(Integral((x_*WC('e', S(1)) + WC('d', S(0)))**m_*(x_*WC('g', S(1)) + WC('f', S(0)))*(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons21, cons5, cons315, cons226, cons279) def replacement467(p, m, f, g, b, d, a, c, x, e): rubi.append(467) return Dist(g/e, Int((d + e*x)**(m + S(1))*(a + b*x + c*x**S(2))**p, x), x) + Dist((-d*g + e*f)/e, Int((d + e*x)**m*(a + b*x + c*x**S(2))**p, x), x) rule467 = ReplacementRule(pattern467, replacement467) pattern468 = Pattern(Integral((a_ + x_**S(2)*WC('c', S(1)))**WC('p', S(1))*(x_*WC('e', S(1)) + WC('d', S(0)))**m_*(x_*WC('g', S(1)) + WC('f', S(0))), x_), cons2, cons7, cons27, cons48, cons125, cons208, cons21, cons5, cons315, cons280) def replacement468(p, m, f, g, d, c, a, x, e): rubi.append(468) return Dist(g/e, Int((a + c*x**S(2))**p*(d + e*x)**(m + S(1)), x), x) + Dist((-d*g + e*f)/e, Int((a + c*x**S(2))**p*(d + e*x)**m, x), x) rule468 = ReplacementRule(pattern468, replacement468) pattern469 = Pattern(Integral((x_*WC('e', S(1)) + WC('d', S(0)))**m_*(x_*WC('g', S(1)) + WC('f', S(0)))**n_*(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons226, cons279, cons375) def replacement469(p, m, f, g, b, d, a, c, n, x, e): rubi.append(469) return Int(ExpandIntegrand((d + e*x)**m*(f + g*x)**n*(a + b*x + c*x**S(2))**p, x), x) rule469 = ReplacementRule(pattern469, replacement469) pattern470 = Pattern(Integral((a_ + x_**S(2)*WC('c', S(1)))**WC('p', S(1))*(x_*WC('e', S(1)) + WC('d', S(0)))**m_*(x_*WC('g', S(1)) + WC('f', S(0)))**n_, x_), cons2, cons7, cons27, cons48, cons125, cons208, cons280, cons375) def replacement470(p, m, f, g, d, c, n, a, x, e): rubi.append(470) return Int(ExpandIntegrand((a + c*x**S(2))**p*(d + e*x)**m*(f + g*x)**n, x), x) rule470 = ReplacementRule(pattern470, replacement470) pattern471 = Pattern(Integral((x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0)))**p_/((x_*WC('e', S(1)) + WC('d', S(0)))*(x_*WC('g', S(1)) + WC('f', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons315, cons226, cons279, cons149, cons163) def replacement471(p, f, g, b, d, a, c, x, e): rubi.append(471) return -Dist(S(1)/(e*(-d*g + e*f)), Int((a + b*x + c*x**S(2))**(p + S(-1))*Simp(a*e*g - b*e*f + c*d*f - c*x*(-d*g + e*f), x)/(f + g*x), x), x) + Dist((a*e**S(2) - b*d*e + c*d**S(2))/(e*(-d*g + e*f)), Int((a + b*x + c*x**S(2))**(p + S(-1))/(d + e*x), x), x) rule471 = ReplacementRule(pattern471, replacement471) pattern472 = Pattern(Integral((a_ + x_**S(2)*WC('c', S(1)))**p_/((x_*WC('e', S(1)) + WC('d', S(0)))*(x_*WC('g', S(1)) + WC('f', S(0)))), x_), cons2, cons7, cons27, cons48, cons125, cons208, cons315, cons280, cons149, cons163) def replacement472(p, f, g, d, c, a, x, e): rubi.append(472) return -Dist(S(1)/(e*(-d*g + e*f)), Int((a + c*x**S(2))**(p + S(-1))*Simp(a*e*g + c*d*f - c*x*(-d*g + e*f), x)/(f + g*x), x), x) + Dist((a*e**S(2) + c*d**S(2))/(e*(-d*g + e*f)), Int((a + c*x**S(2))**(p + S(-1))/(d + e*x), x), x) rule472 = ReplacementRule(pattern472, replacement472) def With473(p, m, f, g, b, d, a, c, n, x, e): q = Denominator(m) rubi.append(473) return Dist(q/e, Subst(Int(x**(q*(m + S(1)) + S(-1))*(g*x**q/e + (-d*g + e*f)/e)**n*(c*x**(S(2)*q)/e**S(2) - x**q*(-b*e + S(2)*c*d)/e**S(2) + (a*e**S(2) - b*d*e + c*d**S(2))/e**S(2))**p, x), x, (d + e*x)**(S(1)/q)), x) pattern473 = Pattern(Integral((x_*WC('e', S(1)) + WC('d', S(0)))**m_*(x_*WC('g', S(1)) + WC('f', S(0)))**n_*(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons315, cons226, cons279, cons376, cons367) rule473 = ReplacementRule(pattern473, With473) def With474(p, m, f, g, d, c, n, a, x, e): q = Denominator(m) rubi.append(474) return Dist(q/e, Subst(Int(x**(q*(m + S(1)) + S(-1))*(g*x**q/e + (-d*g + e*f)/e)**n*(-S(2)*c*d*x**q/e**S(2) + c*x**(S(2)*q)/e**S(2) + (a*e**S(2) + c*d**S(2))/e**S(2))**p, x), x, (d + e*x)**(S(1)/q)), x) pattern474 = Pattern(Integral((a_ + x_**S(2)*WC('c', S(1)))**WC('p', S(1))*(x_*WC('e', S(1)) + WC('d', S(0)))**m_*(x_*WC('g', S(1)) + WC('f', S(0)))**n_, x_), cons2, cons7, cons27, cons48, cons125, cons208, cons315, cons280, cons376, cons367) rule474 = ReplacementRule(pattern474, With474) pattern475 = Pattern(Integral((d_ + x_*WC('e', S(1)))**WC('m', S(1))*(f_ + x_*WC('g', S(1)))**WC('n', S(1))*(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons21, cons4, cons5, cons124, cons336, cons377) def replacement475(p, m, g, b, f, d, a, n, c, x, e): rubi.append(475) return Int((d*f + e*g*x**S(2))**m*(a + b*x + c*x**S(2))**p, x) rule475 = ReplacementRule(pattern475, replacement475) pattern476 = Pattern(Integral((d_ + x_*WC('e', S(1)))**WC('m', S(1))*(f_ + x_*WC('g', S(1)))**WC('n', S(1))*(x_**S(2)*WC('c', S(1)) + WC('a', S(0)))**WC('p', S(1)), x_), cons2, cons7, cons27, cons48, cons125, cons208, cons21, cons4, cons5, cons124, cons336, cons377) def replacement476(p, m, g, f, d, a, n, c, x, e): rubi.append(476) return Int((a + c*x**S(2))**p*(d*f + e*g*x**S(2))**m, x) rule476 = ReplacementRule(pattern476, replacement476) pattern477 = Pattern(Integral((d_ + x_*WC('e', S(1)))**m_*(f_ + x_*WC('g', S(1)))**n_*(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons21, cons4, cons5, cons124, cons336) def replacement477(p, m, g, b, f, d, c, a, n, x, e): rubi.append(477) return Dist((d + e*x)**FracPart(m)*(f + g*x)**FracPart(m)*(d*f + e*g*x**S(2))**(-FracPart(m)), Int((d*f + e*g*x**S(2))**m*(a + b*x + c*x**S(2))**p, x), x) rule477 = ReplacementRule(pattern477, replacement477) pattern478 = Pattern(Integral((d_ + x_*WC('e', S(1)))**m_*(f_ + x_*WC('g', S(1)))**n_*(x_**S(2)*WC('c', S(1)) + WC('a', S(0)))**p_, x_), cons2, cons7, cons27, cons48, cons125, cons208, cons21, cons4, cons5, cons124, cons336) def replacement478(p, m, g, f, d, a, c, n, x, e): rubi.append(478) return Dist((d + e*x)**FracPart(m)*(f + g*x)**FracPart(m)*(d*f + e*g*x**S(2))**(-FracPart(m)), Int((a + c*x**S(2))**p*(d*f + e*g*x**S(2))**m, x), x) rule478 = ReplacementRule(pattern478, replacement478) pattern479 = Pattern(Integral((x_*WC('e', S(1)) + WC('d', S(0)))**m_*(x_*WC('g', S(1)) + WC('f', S(0)))**n_*(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons226, cons279, cons93) def replacement479(m, f, g, b, d, a, c, n, x, e): rubi.append(479) return Dist(c, Int(x**S(2)*(d + e*x)**m*(f + g*x)**n, x), x) + Int((a + b*x)*(d + e*x)**m*(f + g*x)**n, x) rule479 = ReplacementRule(pattern479, replacement479) pattern480 = Pattern(Integral((a_ + x_**S(2)*WC('c', S(1)))*(x_*WC('e', S(1)) + WC('d', S(0)))**m_*(x_*WC('g', S(1)) + WC('f', S(0)))**n_, x_), cons2, cons7, cons27, cons48, cons125, cons208, cons280, cons93) def replacement480(m, f, g, d, c, n, a, x, e): rubi.append(480) return Dist(a, Int((d + e*x)**m*(f + g*x)**n, x), x) + Dist(c, Int(x**S(2)*(d + e*x)**m*(f + g*x)**n, x), x) rule480 = ReplacementRule(pattern480, replacement480) pattern481 = Pattern(Integral((x_*WC('e', S(1)) + WC('d', S(0)))**m_*(x_*WC('g', S(1)) + WC('f', S(0)))**n_/(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons226, cons279, cons18, cons23, cons93, cons168, cons165) def replacement481(m, f, g, b, d, a, c, n, x, e): rubi.append(481) return Dist(c**(S(-2)), Int((d + e*x)**(m + S(-1))*(f + g*x)**(n + S(-2))*Simp(a*b*e*g**S(2) - a*c*d*g**S(2) - S(2)*a*c*e*f*g + c**S(2)*d*f**S(2) + x*(-a*c*e*g**S(2) + b**S(2)*e*g**S(2) - b*c*d*g**S(2) - S(2)*b*c*e*f*g + S(2)*c**S(2)*d*f*g + c**S(2)*e*f**S(2)), x)/(a + b*x + c*x**S(2)), x), x) + Dist(g/c**S(2), Int((d + e*x)**(m + S(-1))*(f + g*x)**(n + S(-2))*Simp(-b*e*g + c*d*g + S(2)*c*e*f + c*e*g*x, x), x), x) rule481 = ReplacementRule(pattern481, replacement481) pattern482 = Pattern(Integral((x_*WC('e', S(1)) + WC('d', S(0)))**m_*(x_*WC('g', S(1)) + WC('f', S(0)))**n_/(a_ + x_**S(2)*WC('c', S(1))), x_), cons2, cons7, cons27, cons48, cons125, cons208, cons280, cons18, cons23, cons93, cons168, cons165) def replacement482(m, f, g, d, c, n, a, x, e): rubi.append(482) return Dist(S(1)/c, Int((d + e*x)**(m + S(-1))*(f + g*x)**(n + S(-2))*Simp(-a*d*g**S(2) - S(2)*a*e*f*g + c*d*f**S(2) + x*(-a*e*g**S(2) + S(2)*c*d*f*g + c*e*f**S(2)), x)/(a + c*x**S(2)), x), x) + Dist(g/c, Int((d + e*x)**(m + S(-1))*(f + g*x)**(n + S(-2))*Simp(d*g + S(2)*e*f + e*g*x, x), x), x) rule482 = ReplacementRule(pattern482, replacement482) pattern483 = Pattern(Integral((x_*WC('e', S(1)) + WC('d', S(0)))**m_*(x_*WC('g', S(1)) + WC('f', S(0)))**n_/(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons226, cons279, cons18, cons23, cons93, cons168, cons88) def replacement483(m, f, g, b, d, a, c, n, x, e): rubi.append(483) return Dist(S(1)/c, Int((d + e*x)**(m + S(-1))*(f + g*x)**(n + S(-1))*Simp(-a*e*g + c*d*f + x*(-b*e*g + c*d*g + c*e*f), x)/(a + b*x + c*x**S(2)), x), x) + Dist(e*g/c, Int((d + e*x)**(m + S(-1))*(f + g*x)**(n + S(-1)), x), x) rule483 = ReplacementRule(pattern483, replacement483) pattern484 = Pattern(Integral((x_*WC('e', S(1)) + WC('d', S(0)))**m_*(x_*WC('g', S(1)) + WC('f', S(0)))**n_/(a_ + x_**S(2)*WC('c', S(1))), x_), cons2, cons7, cons27, cons48, cons125, cons208, cons280, cons18, cons23, cons93, cons168, cons88) def replacement484(m, f, g, d, c, n, a, x, e): rubi.append(484) return Dist(S(1)/c, Int((d + e*x)**(m + S(-1))*(f + g*x)**(n + S(-1))*Simp(-a*e*g + c*d*f + x*(c*d*g + c*e*f), x)/(a + c*x**S(2)), x), x) + Dist(e*g/c, Int((d + e*x)**(m + S(-1))*(f + g*x)**(n + S(-1)), x), x) rule484 = ReplacementRule(pattern484, replacement484) pattern485 = Pattern(Integral((x_*WC('e', S(1)) + WC('d', S(0)))**m_*(x_*WC('g', S(1)) + WC('f', S(0)))**n_/(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons226, cons279, cons18, cons23, cons93, cons168, cons89) def replacement485(m, f, g, b, d, a, c, n, x, e): rubi.append(485) return -Dist(g*(-d*g + e*f)/(a*g**S(2) - b*f*g + c*f**S(2)), Int((d + e*x)**(m + S(-1))*(f + g*x)**n, x), x) + Dist(S(1)/(a*g**S(2) - b*f*g + c*f**S(2)), Int((d + e*x)**(m + S(-1))*(f + g*x)**(n + S(1))*Simp(a*e*g - b*d*g + c*d*f + c*x*(-d*g + e*f), x)/(a + b*x + c*x**S(2)), x), x) rule485 = ReplacementRule(pattern485, replacement485) pattern486 = Pattern(Integral((x_*WC('e', S(1)) + WC('d', S(0)))**m_*(x_*WC('g', S(1)) + WC('f', S(0)))**n_/(a_ + x_**S(2)*WC('c', S(1))), x_), cons2, cons7, cons27, cons48, cons125, cons208, cons280, cons18, cons23, cons93, cons168, cons89) def replacement486(m, f, g, d, c, n, a, x, e): rubi.append(486) return -Dist(g*(-d*g + e*f)/(a*g**S(2) + c*f**S(2)), Int((d + e*x)**(m + S(-1))*(f + g*x)**n, x), x) + Dist(S(1)/(a*g**S(2) + c*f**S(2)), Int((d + e*x)**(m + S(-1))*(f + g*x)**(n + S(1))*Simp(a*e*g + c*d*f + c*x*(-d*g + e*f), x)/(a + c*x**S(2)), x), x) rule486 = ReplacementRule(pattern486, replacement486) pattern487 = Pattern(Integral((x_*WC('e', S(1)) + WC('d', S(0)))**m_/(sqrt(x_*WC('g', S(1)) + WC('f', S(0)))*(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons226, cons279, cons73) def replacement487(m, f, g, b, d, a, c, x, e): rubi.append(487) return Int(ExpandIntegrand(S(1)/(sqrt(d + e*x)*sqrt(f + g*x)), (d + e*x)**(m + S(1)/2)/(a + b*x + c*x**S(2)), x), x) rule487 = ReplacementRule(pattern487, replacement487) pattern488 = Pattern(Integral((x_*WC('e', S(1)) + WC('d', S(0)))**m_/(sqrt(x_*WC('g', S(1)) + WC('f', S(0)))*(x_**S(2)*WC('c', S(1)) + WC('a', S(0)))), x_), cons2, cons7, cons27, cons48, cons125, cons208, cons280, cons73) def replacement488(m, f, g, d, a, c, x, e): rubi.append(488) return Int(ExpandIntegrand(S(1)/(sqrt(d + e*x)*sqrt(f + g*x)), (d + e*x)**(m + S(1)/2)/(a + c*x**S(2)), x), x) rule488 = ReplacementRule(pattern488, replacement488) pattern489 = Pattern(Integral((x_*WC('e', S(1)) + WC('d', S(0)))**m_*(x_*WC('g', S(1)) + WC('f', S(0)))**n_/(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons21, cons4, cons226, cons279, cons18, cons23) def replacement489(m, f, g, b, d, a, c, n, x, e): rubi.append(489) return Int(ExpandIntegrand((d + e*x)**m*(f + g*x)**n, S(1)/(a + b*x + c*x**S(2)), x), x) rule489 = ReplacementRule(pattern489, replacement489) pattern490 = Pattern(Integral((x_*WC('e', S(1)) + WC('d', S(0)))**m_*(x_*WC('g', S(1)) + WC('f', S(0)))**n_/(a_ + x_**S(2)*WC('c', S(1))), x_), cons2, cons7, cons27, cons48, cons125, cons208, cons21, cons4, cons280, cons18, cons23) def replacement490(m, f, g, d, c, n, a, x, e): rubi.append(490) return Int(ExpandIntegrand((d + e*x)**m*(f + g*x)**n, S(1)/(a + c*x**S(2)), x), x) rule490 = ReplacementRule(pattern490, replacement490) pattern491 = Pattern(Integral((x_*WC('e', S(1)) + WC('d', S(0)))**m_*(x_*WC('g', S(1)) + WC('f', S(0)))**n_*(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons315, cons226, cons279, cons378) def replacement491(p, m, f, g, b, d, a, c, n, x, e): rubi.append(491) return Int(ExpandIntegrand((d + e*x)**m*(f + g*x)**n*(a + b*x + c*x**S(2))**p, x), x) rule491 = ReplacementRule(pattern491, replacement491) pattern492 = Pattern(Integral((a_ + x_**S(2)*WC('c', S(1)))**WC('p', S(1))*(x_*WC('e', S(1)) + WC('d', S(0)))**m_*(x_*WC('g', S(1)) + WC('f', S(0)))**n_, x_), cons2, cons7, cons27, cons48, cons125, cons208, cons315, cons280, cons378) def replacement492(p, m, f, g, d, c, n, a, x, e): rubi.append(492) return Int(ExpandIntegrand((a + c*x**S(2))**p*(d + e*x)**m*(f + g*x)**n, x), x) rule492 = ReplacementRule(pattern492, replacement492) pattern493 = Pattern(Integral((x_*WC('g', S(1)))**WC('n', S(1))*(x_*WC('e', S(1)) + WC('d', S(0)))**m_*(a_ + x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)))**p_, x_), cons2, cons3, cons7, cons27, cons48, cons208, cons21, cons4, cons5, cons358, cons288, cons289) def replacement493(p, m, g, b, d, c, n, a, x, e): rubi.append(493) return Dist((d + e*x)**FracPart(p)*(a*d + c*e*x**S(3))**(-FracPart(p))*(a + b*x + c*x**S(2))**FracPart(p), Int((g*x)**n*(a*d + c*e*x**S(3))**p, x), x) rule493 = ReplacementRule(pattern493, replacement493) pattern494 = Pattern(Integral((x_*WC('g', S(1)) + WC('f', S(0)))**n_*(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0)))**p_/(x_*WC('e', S(1)) + WC('d', S(0))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons315, cons226, cons279, cons23, cons147, cons338, cons163, cons89) def replacement494(p, f, g, b, d, a, c, n, x, e): rubi.append(494) return -Dist(S(1)/(e*(-d*g + e*f)), Int((f + g*x)**n*(a + b*x + c*x**S(2))**(p + S(-1))*(a*e*g - b*e*f + c*d*f - c*x*(-d*g + e*f)), x), x) + Dist((a*e**S(2) - b*d*e + c*d**S(2))/(e*(-d*g + e*f)), Int((f + g*x)**(n + S(1))*(a + b*x + c*x**S(2))**(p + S(-1))/(d + e*x), x), x) rule494 = ReplacementRule(pattern494, replacement494) pattern495 = Pattern(Integral((a_ + x_**S(2)*WC('c', S(1)))**p_*(x_*WC('g', S(1)) + WC('f', S(0)))**n_/(x_*WC('e', S(1)) + WC('d', S(0))), x_), cons2, cons7, cons27, cons48, cons125, cons208, cons315, cons280, cons23, cons147, cons338, cons163, cons89) def replacement495(p, f, g, d, c, n, a, x, e): rubi.append(495) return -Dist(S(1)/(e*(-d*g + e*f)), Int((a + c*x**S(2))**(p + S(-1))*(f + g*x)**n*(a*e*g + c*d*f - c*x*(-d*g + e*f)), x), x) + Dist((a*e**S(2) + c*d**S(2))/(e*(-d*g + e*f)), Int((a + c*x**S(2))**(p + S(-1))*(f + g*x)**(n + S(1))/(d + e*x), x), x) rule495 = ReplacementRule(pattern495, replacement495) pattern496 = Pattern(Integral((x_*WC('g', S(1)) + WC('f', S(0)))**n_*(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0)))**p_/(x_*WC('e', S(1)) + WC('d', S(0))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons315, cons226, cons279, cons23, cons147, cons338, cons137, cons88) def replacement496(p, f, g, b, d, a, c, n, x, e): rubi.append(496) return Dist(e*(-d*g + e*f)/(a*e**S(2) - b*d*e + c*d**S(2)), Int((f + g*x)**(n + S(-1))*(a + b*x + c*x**S(2))**(p + S(1))/(d + e*x), x), x) + Dist(S(1)/(a*e**S(2) - b*d*e + c*d**S(2)), Int((f + g*x)**(n + S(-1))*(a + b*x + c*x**S(2))**p*(a*e*g - b*e*f + c*d*f - c*x*(-d*g + e*f)), x), x) rule496 = ReplacementRule(pattern496, replacement496) pattern497 = Pattern(Integral((a_ + x_**S(2)*WC('c', S(1)))**p_*(x_*WC('g', S(1)) + WC('f', S(0)))**n_/(x_*WC('e', S(1)) + WC('d', S(0))), x_), cons2, cons7, cons27, cons48, cons125, cons208, cons315, cons280, cons23, cons147, cons338, cons137, cons88) def replacement497(p, f, g, d, c, n, a, x, e): rubi.append(497) return Dist(e*(-d*g + e*f)/(a*e**S(2) + c*d**S(2)), Int((a + c*x**S(2))**(p + S(1))*(f + g*x)**(n + S(-1))/(d + e*x), x), x) + Dist(S(1)/(a*e**S(2) + c*d**S(2)), Int((a + c*x**S(2))**p*(f + g*x)**(n + S(-1))*(a*e*g + c*d*f - c*x*(-d*g + e*f)), x), x) rule497 = ReplacementRule(pattern497, replacement497) def With498(f, g, b, d, a, c, x, e): q = Rt(-S(4)*a*c + b**S(2), S(2)) rubi.append(498) return Simp(-sqrt(S(2))*sqrt(-g*(b + S(2)*c*x - q)/(-b*g + S(2)*c*f + g*q))*sqrt(-g*(b + S(2)*c*x + q)/(-b*g + S(2)*c*f - g*q))*EllipticPi(e*(-b*g + S(2)*c*f + g*q)/(S(2)*c*(-d*g + e*f)), asin(sqrt(S(2))*sqrt(c/(-b*g + S(2)*c*f + g*q))*sqrt(f + g*x)), (-b*g + S(2)*c*f + g*q)/(-b*g + S(2)*c*f - g*q))/(sqrt(c/(-b*g + S(2)*c*f + g*q))*(-d*g + e*f)*sqrt(a + b*x + c*x**S(2))), x) pattern498 = Pattern(Integral(S(1)/((x_*WC('e', S(1)) + WC('d', S(0)))*sqrt(x_*WC('g', S(1)) + WC('f', S(0)))*sqrt(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons315, cons226, cons279) rule498 = ReplacementRule(pattern498, With498) def With499(f, g, d, c, a, x, e): q = Rt(-a*c, S(2)) rubi.append(499) return Simp(-S(2)*sqrt(g*(-c*x + q)/(c*f + g*q))*sqrt(-g*(c*x + q)/(c*f - g*q))*EllipticPi(e*(c*f + g*q)/(c*(-d*g + e*f)), asin(sqrt(c/(c*f + g*q))*sqrt(f + g*x)), (c*f + g*q)/(c*f - g*q))/(sqrt(c/(c*f + g*q))*sqrt(a + c*x**S(2))*(-d*g + e*f)), x) pattern499 = Pattern(Integral(S(1)/(sqrt(a_ + x_**S(2)*WC('c', S(1)))*(x_*WC('e', S(1)) + WC('d', S(0)))*sqrt(x_*WC('g', S(1)) + WC('f', S(0)))), x_), cons2, cons7, cons27, cons48, cons125, cons208, cons315, cons280) rule499 = ReplacementRule(pattern499, With499) pattern500 = Pattern(Integral((x_*WC('g', S(1)) + WC('f', S(0)))**n_/((x_*WC('e', S(1)) + WC('d', S(0)))*sqrt(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons315, cons226, cons279, cons80) def replacement500(f, g, b, d, a, c, n, x, e): rubi.append(500) return Int(ExpandIntegrand(S(1)/(sqrt(f + g*x)*sqrt(a + b*x + c*x**S(2))), (f + g*x)**(n + S(1)/2)/(d + e*x), x), x) rule500 = ReplacementRule(pattern500, replacement500) pattern501 = Pattern(Integral((x_*WC('g', S(1)) + WC('f', S(0)))**n_/(sqrt(a_ + x_**S(2)*WC('c', S(1)))*(x_*WC('e', S(1)) + WC('d', S(0)))), x_), cons2, cons7, cons27, cons48, cons125, cons208, cons315, cons280, cons80) def replacement501(f, g, d, c, n, a, x, e): rubi.append(501) return Int(ExpandIntegrand(S(1)/(sqrt(a + c*x**S(2))*sqrt(f + g*x)), (f + g*x)**(n + S(1)/2)/(d + e*x), x), x) rule501 = ReplacementRule(pattern501, replacement501) pattern502 = Pattern(Integral(S(1)/(sqrt(x_*WC('e', S(1)) + WC('d', S(0)))*sqrt(x_*WC('g', S(1)) + WC('f', S(0)))*sqrt(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons315, cons226, cons279) def replacement502(f, g, b, d, a, c, x, e): rubi.append(502) return Dist(-S(2)*sqrt((-d*g + e*f)**S(2)*(a + b*x + c*x**S(2))/((d + e*x)**S(2)*(a*g**S(2) - b*f*g + c*f**S(2))))*(d + e*x)/((-d*g + e*f)*sqrt(a + b*x + c*x**S(2))), Subst(Int(S(1)/sqrt(x**S(4)*(a*e**S(2) - b*d*e + c*d**S(2))/(a*g**S(2) - b*f*g + c*f**S(2)) - x**S(2)*(S(2)*a*e*g - b*d*g - b*e*f + S(2)*c*d*f)/(a*g**S(2) - b*f*g + c*f**S(2)) + S(1)), x), x, sqrt(f + g*x)/sqrt(d + e*x)), x) rule502 = ReplacementRule(pattern502, replacement502) pattern503 = Pattern(Integral(S(1)/(sqrt(a_ + x_**S(2)*WC('c', S(1)))*sqrt(x_*WC('e', S(1)) + WC('d', S(0)))*sqrt(x_*WC('g', S(1)) + WC('f', S(0)))), x_), cons2, cons7, cons27, cons48, cons125, cons208, cons315, cons280) def replacement503(f, g, d, c, a, x, e): rubi.append(503) return Dist(-S(2)*sqrt((a + c*x**S(2))*(-d*g + e*f)**S(2)/((d + e*x)**S(2)*(a*g**S(2) + c*f**S(2))))*(d + e*x)/(sqrt(a + c*x**S(2))*(-d*g + e*f)), Subst(Int(S(1)/sqrt(x**S(4)*(a*e**S(2) + c*d**S(2))/(a*g**S(2) + c*f**S(2)) - x**S(2)*(S(2)*a*e*g + S(2)*c*d*f)/(a*g**S(2) + c*f**S(2)) + S(1)), x), x, sqrt(f + g*x)/sqrt(d + e*x)), x) rule503 = ReplacementRule(pattern503, replacement503) pattern504 = Pattern(Integral((x_*WC('e', S(1)))**WC('m', S(1))*(a_ + x_**S(2)*WC('c', S(1)))**WC('p', S(1))*(f_ + x_*WC('g', S(1)))**S(2), x_), cons2, cons7, cons48, cons125, cons208, cons21, cons5, cons379) def replacement504(p, m, g, f, c, a, x, e): rubi.append(504) return Dist(S(2)*f*g/e, Int((e*x)**(m + S(1))*(a + c*x**S(2))**p, x), x) + Int((e*x)**m*(a + c*x**S(2))**p*(f**S(2) + g**S(2)*x**S(2)), x) rule504 = ReplacementRule(pattern504, replacement504) pattern505 = Pattern(Integral((x_*WC('e', S(1)))**WC('m', S(1))*(a_ + x_**S(2)*WC('c', S(1)))**WC('p', S(1))*(f_ + x_*WC('g', S(1)))**S(3), x_), cons2, cons7, cons48, cons125, cons208, cons21, cons5, cons379) def replacement505(p, m, g, f, c, a, x, e): rubi.append(505) return Dist(f, Int((e*x)**m*(a + c*x**S(2))**p*(f**S(2) + S(3)*g**S(2)*x**S(2)), x), x) + Dist(g/e, Int((e*x)**(m + S(1))*(a + c*x**S(2))**p*(S(3)*f**S(2) + g**S(2)*x**S(2)), x), x) rule505 = ReplacementRule(pattern505, replacement505) pattern506 = Pattern(Integral((x_*WC('e', S(1)) + WC('d', S(0)))**m_*(x_*WC('g', S(1)) + WC('f', S(0)))**n_*(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons21, cons5, cons315, cons226, cons279, cons148) def replacement506(p, m, f, g, b, d, a, c, n, x, e): rubi.append(506) return Dist(g/e, Int((d + e*x)**(m + S(1))*(f + g*x)**(n + S(-1))*(a + b*x + c*x**S(2))**p, x), x) + Dist((-d*g + e*f)/e, Int((d + e*x)**m*(f + g*x)**(n + S(-1))*(a + b*x + c*x**S(2))**p, x), x) rule506 = ReplacementRule(pattern506, replacement506) pattern507 = Pattern(Integral((a_ + x_**S(2)*WC('c', S(1)))**WC('p', S(1))*(x_*WC('e', S(1)) + WC('d', S(0)))**m_*(x_*WC('g', S(1)) + WC('f', S(0)))**n_, x_), cons2, cons7, cons27, cons48, cons125, cons208, cons21, cons5, cons315, cons280, cons148) def replacement507(p, m, f, g, d, c, n, a, x, e): rubi.append(507) return Dist(g/e, Int((a + c*x**S(2))**p*(d + e*x)**(m + S(1))*(f + g*x)**(n + S(-1)), x), x) + Dist((-d*g + e*f)/e, Int((a + c*x**S(2))**p*(d + e*x)**m*(f + g*x)**(n + S(-1)), x), x) rule507 = ReplacementRule(pattern507, replacement507) pattern508 = Pattern(Integral((x_*WC('e', S(1)) + WC('d', S(0)))**WC('m', S(1))*(x_*WC('g', S(1)) + WC('f', S(0)))**WC('n', S(1))*(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons21, cons4, cons5, cons380) def replacement508(p, m, f, g, b, d, a, n, c, x, e): rubi.append(508) return Int((d + e*x)**m*(f + g*x)**n*(a + b*x + c*x**S(2))**p, x) rule508 = ReplacementRule(pattern508, replacement508) pattern509 = Pattern(Integral((a_ + x_**S(2)*WC('c', S(1)))**WC('p', S(1))*(x_*WC('e', S(1)) + WC('d', S(0)))**WC('m', S(1))*(x_*WC('g', S(1)) + WC('f', S(0)))**WC('n', S(1)), x_), cons2, cons7, cons27, cons48, cons125, cons208, cons21, cons4, cons5, cons381) def replacement509(p, m, f, g, d, c, n, a, x, e): rubi.append(509) return Int((a + c*x**S(2))**p*(d + e*x)**m*(f + g*x)**n, x) rule509 = ReplacementRule(pattern509, replacement509) pattern510 = Pattern(Integral((u_*WC('e', S(1)) + WC('d', S(0)))**WC('m', S(1))*(u_*WC('g', S(1)) + WC('f', S(0)))**WC('n', S(1))*(a_ + u_**S(2)*WC('c', S(1)) + u_*WC('b', S(1)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons21, cons4, cons5, cons68, cons69) def replacement510(p, u, m, f, g, b, d, c, n, a, x, e): rubi.append(510) return Dist(S(1)/Coefficient(u, x, S(1)), Subst(Int((d + e*x)**m*(f + g*x)**n*(a + b*x + c*x**S(2))**p, x), x, u), x) rule510 = ReplacementRule(pattern510, replacement510) pattern511 = Pattern(Integral((a_ + u_**S(2)*WC('c', S(1)))**WC('p', S(1))*(u_*WC('e', S(1)) + WC('d', S(0)))**WC('m', S(1))*(u_*WC('g', S(1)) + WC('f', S(0)))**WC('n', S(1)), x_), cons2, cons7, cons27, cons48, cons125, cons208, cons21, cons4, cons5, cons68, cons69) def replacement511(p, u, m, f, g, d, c, n, a, x, e): rubi.append(511) return Dist(S(1)/Coefficient(u, x, S(1)), Subst(Int((a + c*x**S(2))**p*(d + e*x)**m*(f + g*x)**n, x), x, u), x) rule511 = ReplacementRule(pattern511, replacement511) pattern512 = Pattern(Integral((a_ + x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)))**WC('p', S(1))*(d_ + x_**S(2)*WC('f', S(1)) + x_*WC('e', S(1)))**WC('q', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons5, cons50, cons382, cons383, cons384, cons385) def replacement512(p, f, b, d, c, a, x, q, e): rubi.append(512) return Dist((c/f)**p, Int((d + e*x + f*x**S(2))**(p + q), x), x) rule512 = ReplacementRule(pattern512, replacement512) pattern513 = Pattern(Integral((a_ + x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)))**WC('p', S(1))*(d_ + x_**S(2)*WC('f', S(1)) + x_*WC('e', S(1)))**WC('q', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons5, cons50, cons382, cons383, cons147, cons386, cons387) def replacement513(p, f, b, d, c, a, x, q, e): rubi.append(513) return Dist(a**IntPart(p)*d**(-IntPart(p))*(a + b*x + c*x**S(2))**FracPart(p)*(d + e*x + f*x**S(2))**(-FracPart(p)), Int((d + e*x + f*x**S(2))**(p + q), x), x) rule513 = ReplacementRule(pattern513, replacement513) pattern514 = Pattern(Integral((a_ + x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)))**p_*(d_ + x_**S(2)*WC('f', S(1)) + x_*WC('e', S(1)))**WC('q', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons5, cons50, cons45, cons147) def replacement514(p, f, b, d, c, a, x, q, e): rubi.append(514) return Dist((S(4)*c)**(-IntPart(p))*(b + S(2)*c*x)**(-S(2)*FracPart(p))*(a + b*x + c*x**S(2))**FracPart(p), Int((b + S(2)*c*x)**(S(2)*p)*(d + e*x + f*x**S(2))**q, x), x) rule514 = ReplacementRule(pattern514, replacement514) pattern515 = Pattern(Integral((d_ + x_**S(2)*WC('f', S(1)))**WC('q', S(1))*(a_ + x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)))**p_, x_), cons2, cons3, cons7, cons27, cons125, cons5, cons50, cons45, cons147) def replacement515(p, f, b, d, c, a, x, q): rubi.append(515) return Dist((S(4)*c)**(-IntPart(p))*(b + S(2)*c*x)**(-S(2)*FracPart(p))*(a + b*x + c*x**S(2))**FracPart(p), Int((b + S(2)*c*x)**(S(2)*p)*(d + f*x**S(2))**q, x), x) rule515 = ReplacementRule(pattern515, replacement515) pattern516 = Pattern(Integral((a_ + x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)))*(x_**S(2)*WC('f', S(1)) + x_*WC('e', S(1)) + WC('d', S(0)))**q_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons50, cons388, cons389, cons390) def replacement516(f, b, d, c, a, x, q, e): rubi.append(516) return Simp((d + e*x + f*x**S(2))**(q + S(1))*(b*f*(S(2)*q + S(3)) - c*e*(q + S(2)) + S(2)*c*f*x*(q + S(1)))/(S(2)*f**S(2)*(q + S(1))*(S(2)*q + S(3))), x) rule516 = ReplacementRule(pattern516, replacement516) pattern517 = Pattern(Integral((a_ + x_**S(2)*WC('c', S(1)))*(x_**S(2)*WC('f', S(1)) + x_*WC('e', S(1)) + WC('d', S(0)))**q_, x_), cons2, cons7, cons27, cons48, cons125, cons50, cons391, cons389, cons390) def replacement517(f, d, c, a, x, q, e): rubi.append(517) return Simp((-c*e*(q + S(2)) + S(2)*c*f*x*(q + S(1)))*(d + e*x + f*x**S(2))**(q + S(1))/(S(2)*f**S(2)*(q + S(1))*(S(2)*q + S(3))), x) rule517 = ReplacementRule(pattern517, replacement517) pattern518 = Pattern(Integral((d_ + x_**S(2)*WC('f', S(1)))**q_*(a_ + x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1))), x_), cons2, cons3, cons7, cons27, cons125, cons50, cons389, cons392) def replacement518(f, b, d, c, a, x, q): rubi.append(518) return Simp((d + f*x**S(2))**(q + S(1))*(S(2)*a*f*x*(q + S(1)) + b*d)/(S(2)*d*f*(q + S(1))), x) rule518 = ReplacementRule(pattern518, replacement518) pattern519 = Pattern(Integral((d_ + x_**S(2)*WC('f', S(1)))**q_*(a_ + x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1))), x_), cons2, cons3, cons7, cons27, cons125, cons50, cons393) def replacement519(f, b, d, c, a, x, q): rubi.append(519) return Dist(b, Int(x*(d + f*x**S(2))**q, x), x) + Int((a + c*x**S(2))*(d + f*x**S(2))**q, x) rule519 = ReplacementRule(pattern519, replacement519) pattern520 = Pattern(Integral((a_ + x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)))*(x_**S(2)*WC('f', S(1)) + x_*WC('e', S(1)) + WC('d', S(0)))**WC('q', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons394, cons393) def replacement520(f, b, d, c, a, x, q, e): rubi.append(520) return Int(ExpandIntegrand((a + b*x + c*x**S(2))*(d + e*x + f*x**S(2))**q, x), x) rule520 = ReplacementRule(pattern520, replacement520) pattern521 = Pattern(Integral((a_ + x_**S(2)*WC('c', S(1)))*(x_**S(2)*WC('f', S(1)) + x_*WC('e', S(1)) + WC('d', S(0)))**WC('q', S(1)), x_), cons2, cons7, cons27, cons48, cons125, cons394, cons393) def replacement521(f, d, c, a, x, q, e): rubi.append(521) return Int(ExpandIntegrand((a + c*x**S(2))*(d + e*x + f*x**S(2))**q, x), x) rule521 = ReplacementRule(pattern521, replacement521) pattern522 = Pattern(Integral((a_ + x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)))*(x_**S(2)*WC('f', S(1)) + x_*WC('e', S(1)) + WC('d', S(0)))**q_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons394, cons395, cons396, cons397) def replacement522(f, b, d, c, a, x, q, e): rubi.append(522) return -Dist((c*(-S(2)*d*f + e**S(2)*(q + S(2))) + f*(S(2)*q + S(3))*(S(2)*a*f - b*e))/(f*(q + S(1))*(-S(4)*d*f + e**S(2))), Int((d + e*x + f*x**S(2))**(q + S(1)), x), x) + Simp((d + e*x + f*x**S(2))**(q + S(1))*(a*e*f - S(2)*b*d*f + c*d*e + x*(c*(-S(2)*d*f + e**S(2)) + f*(S(2)*a*f - b*e)))/(f*(q + S(1))*(-S(4)*d*f + e**S(2))), x) rule522 = ReplacementRule(pattern522, replacement522) pattern523 = Pattern(Integral((a_ + x_**S(2)*WC('c', S(1)))*(x_**S(2)*WC('f', S(1)) + x_*WC('e', S(1)) + WC('d', S(0)))**q_, x_), cons2, cons7, cons27, cons48, cons125, cons394, cons395, cons396, cons398) def replacement523(f, d, c, a, x, q, e): rubi.append(523) return -Dist((S(2)*a*f**S(2)*(S(2)*q + S(3)) + c*(-S(2)*d*f + e**S(2)*(q + S(2))))/(f*(q + S(1))*(-S(4)*d*f + e**S(2))), Int((d + e*x + f*x**S(2))**(q + S(1)), x), x) + Simp((d + e*x + f*x**S(2))**(q + S(1))*(a*e*f + c*d*e + x*(S(2)*a*f**S(2) + c*(-S(2)*d*f + e**S(2))))/(f*(q + S(1))*(-S(4)*d*f + e**S(2))), x) rule523 = ReplacementRule(pattern523, replacement523) pattern524 = Pattern(Integral((d_ + x_**S(2)*WC('f', S(1)))**q_*(a_ + x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1))), x_), cons2, cons3, cons7, cons27, cons125, cons395, cons396, cons399) def replacement524(f, b, d, c, a, x, q): rubi.append(524) return Dist((S(2)*a*f*q + S(3)*a*f - c*d)/(S(2)*d*f*(q + S(1))), Int((d + f*x**S(2))**(q + S(1)), x), x) + Simp((d + f*x**S(2))**(q + S(1))*(b*d - x*(a*f - c*d))/(S(2)*d*f*(q + S(1))), x) rule524 = ReplacementRule(pattern524, replacement524) pattern525 = Pattern(Integral((a_ + x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)))*(x_**S(2)*WC('f', S(1)) + x_*WC('e', S(1)) + WC('d', S(0)))**q_, x_), cons27, cons48, cons125, cons2, cons3, cons7, cons50, cons394, cons400, cons401, cons397) def replacement525(f, b, d, c, a, x, q, e): rubi.append(525) return Dist((c*(-S(2)*d*f + e**S(2)*(q + S(2))) + f*(S(2)*q + S(3))*(S(2)*a*f - b*e))/(S(2)*f**S(2)*(S(2)*q + S(3))), Int((d + e*x + f*x**S(2))**q, x), x) + Simp((d + e*x + f*x**S(2))**(q + S(1))*(b*f*(S(2)*q + S(3)) - c*e*(q + S(2)) + S(2)*c*f*x*(q + S(1)))/(S(2)*f**S(2)*(q + S(1))*(S(2)*q + S(3))), x) rule525 = ReplacementRule(pattern525, replacement525) pattern526 = Pattern(Integral((a_ + x_**S(2)*WC('c', S(1)))*(x_**S(2)*WC('f', S(1)) + x_*WC('e', S(1)) + WC('d', S(0)))**q_, x_), cons27, cons48, cons125, cons2, cons7, cons50, cons394, cons400, cons401, cons398) def replacement526(f, d, c, a, x, q, e): rubi.append(526) return Dist((S(2)*a*f**S(2)*(S(2)*q + S(3)) + c*(-S(2)*d*f + e**S(2)*(q + S(2))))/(S(2)*f**S(2)*(S(2)*q + S(3))), Int((d + e*x + f*x**S(2))**q, x), x) + Simp((-c*e*(q + S(2)) + S(2)*c*f*x*(q + S(1)))*(d + e*x + f*x**S(2))**(q + S(1))/(S(2)*f**S(2)*(q + S(1))*(S(2)*q + S(3))), x) rule526 = ReplacementRule(pattern526, replacement526) pattern527 = Pattern(Integral((d_ + x_**S(2)*WC('f', S(1)))**q_*(a_ + x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1))), x_), cons27, cons125, cons2, cons3, cons7, cons50, cons400, cons401, cons399) def replacement527(f, b, d, c, a, x, q): rubi.append(527) return Dist((S(2)*a*f*q + S(3)*a*f - c*d)/(f*(S(2)*q + S(3))), Int((d + f*x**S(2))**q, x), x) + Simp((d + f*x**S(2))**(q + S(1))*(b*f*(S(2)*q + S(3)) + S(2)*c*f*x*(q + S(1)))/(S(2)*f**S(2)*(q + S(1))*(S(2)*q + S(3))), x) rule527 = ReplacementRule(pattern527, replacement527) pattern528 = Pattern(Integral((x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0)))**p_*(x_**S(2)*WC('f', S(1)) + x_*WC('e', S(1)) + WC('d', S(0)))**WC('q', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons226, cons394, cons402, cons137, cons403) def replacement528(p, f, b, d, c, a, x, q, e): rubi.append(528) return -Dist(S(1)/((p + S(1))*(-S(4)*a*c + b**S(2))), Int((a + b*x + c*x**S(2))**(p + S(1))*(d + e*x + f*x**S(2))**(q + S(-1))*Simp(b*e*q + S(2)*c*d*(S(2)*p + S(3)) + S(2)*c*f*x**S(2)*(S(2)*p + S(2)*q + S(3)) + x*(S(2)*b*f*q + S(2)*c*e*(S(2)*p + q + S(3))), x), x), x) + Simp((b + S(2)*c*x)*(a + b*x + c*x**S(2))**(p + S(1))*(d + e*x + f*x**S(2))**q/((p + S(1))*(-S(4)*a*c + b**S(2))), x) rule528 = ReplacementRule(pattern528, replacement528) pattern529 = Pattern(Integral((x_**S(2)*WC('f', S(1)) + WC('d', S(0)))**WC('q', S(1))*(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0)))**p_, x_), cons2, cons3, cons7, cons27, cons125, cons226, cons402, cons137, cons403) def replacement529(p, f, b, d, c, a, x, q): rubi.append(529) return -Dist(S(1)/((p + S(1))*(-S(4)*a*c + b**S(2))), Int((d + f*x**S(2))**(q + S(-1))*(a + b*x + c*x**S(2))**(p + S(1))*Simp(S(2)*b*f*q*x + S(2)*c*d*(S(2)*p + S(3)) + S(2)*c*f*x**S(2)*(S(2)*p + S(2)*q + S(3)), x), x), x) + Simp((b + S(2)*c*x)*(d + f*x**S(2))**q*(a + b*x + c*x**S(2))**(p + S(1))/((p + S(1))*(-S(4)*a*c + b**S(2))), x) rule529 = ReplacementRule(pattern529, replacement529) pattern530 = Pattern(Integral((x_**S(2)*WC('c', S(1)) + WC('a', S(0)))**p_*(x_**S(2)*WC('f', S(1)) + x_*WC('e', S(1)) + WC('d', S(0)))**WC('q', S(1)), x_), cons2, cons7, cons27, cons48, cons125, cons394, cons402, cons137, cons403) def replacement530(p, f, d, a, c, x, q, e): rubi.append(530) return -Dist(-S(1)/(S(4)*a*c*(p + S(1))), Int((a + c*x**S(2))**(p + S(1))*(d + e*x + f*x**S(2))**(q + S(-1))*Simp(S(2)*c*d*(S(2)*p + S(3)) + S(2)*c*e*x*(S(2)*p + q + S(3)) + S(2)*c*f*x**S(2)*(S(2)*p + S(2)*q + S(3)), x), x), x) + Simp(-x*(a + c*x**S(2))**(p + S(1))*(d + e*x + f*x**S(2))**q/(S(2)*a*(p + S(1))), x) rule530 = ReplacementRule(pattern530, replacement530) pattern531 = Pattern(Integral((x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0)))**p_*(x_**S(2)*WC('f', S(1)) + x_*WC('e', S(1)) + WC('d', S(0)))**WC('q', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons50, cons226, cons394, cons13, cons137, cons404, cons405) def replacement531(p, f, b, d, c, a, x, q, e): rubi.append(531) return -Dist(S(1)/((p + S(1))*(-S(4)*a*c + b**S(2))*(-(-a*e + b*d)*(-b*f + c*e) + (-a*f + c*d)**S(2))), Int((a + b*x + c*x**S(2))**(p + S(1))*(d + e*x + f*x**S(2))**q*Simp(c*f*x**S(2)*(S(2)*p + S(2)*q + S(5))*(b**S(2)*f + S(2)*c**S(2)*d - c*(S(2)*a*f + b*e)) + S(2)*c*(p + S(1))*(-(-a*e + b*d)*(-b*f + c*e) + (-a*f + c*d)**S(2)) - e*(p + q + S(2))*(-S(2)*a*c**S(2)*e - b**S(3)*f + b**S(2)*c*e - b*c*(-S(3)*a*f + c*d)) + x*(S(2)*f*(p + q + S(2))*(S(2)*a*c**S(2)*e + b**S(3)*f - b**S(2)*c*e + b*c*(-S(3)*a*f + c*d)) - (b*f*(p + S(1)) - c*e*(S(2)*p + q + S(4)))*(b**S(2)*f + S(2)*c**S(2)*d - c*(S(2)*a*f + b*e))) - (a*f*(p + S(1)) - c*d*(p + S(2)))*(b**S(2)*f + S(2)*c**S(2)*d - c*(S(2)*a*f + b*e)), x), x), x) + Simp((a + b*x + c*x**S(2))**(p + S(1))*(d + e*x + f*x**S(2))**(q + S(1))*(S(2)*a*c**S(2)*e + b**S(3)*f - b**S(2)*c*e + b*c*(-S(3)*a*f + c*d) + c*x*(b**S(2)*f + S(2)*c**S(2)*d - c*(S(2)*a*f + b*e)))/((p + S(1))*(-S(4)*a*c + b**S(2))*(-(-a*e + b*d)*(-b*f + c*e) + (-a*f + c*d)**S(2))), x) rule531 = ReplacementRule(pattern531, replacement531) pattern532 = Pattern(Integral((x_**S(2)*WC('f', S(1)) + WC('d', S(0)))**WC('q', S(1))*(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0)))**p_, x_), cons2, cons3, cons7, cons27, cons125, cons50, cons226, cons13, cons137, cons406, cons405) def replacement532(p, f, b, d, c, a, x, q): rubi.append(532) return -Dist(S(1)/((p + S(1))*(-S(4)*a*c + b**S(2))*(b**S(2)*d*f + (-a*f + c*d)**S(2))), Int((d + f*x**S(2))**q*(a + b*x + c*x**S(2))**(p + S(1))*Simp(c*f*x**S(2)*(S(2)*p + S(2)*q + S(5))*(-S(2)*a*c*f + b**S(2)*f + S(2)*c**S(2)*d) + S(2)*c*(p + S(1))*(b**S(2)*d*f + (-a*f + c*d)**S(2)) + x*(-b*f*(p + S(1))*(-S(2)*a*c*f + b**S(2)*f + S(2)*c**S(2)*d) + S(2)*f*(b**S(3)*f + b*c*(-S(3)*a*f + c*d))*(p + q + S(2))) - (a*f*(p + S(1)) - c*d*(p + S(2)))*(-S(2)*a*c*f + b**S(2)*f + S(2)*c**S(2)*d), x), x), x) + Simp((d + f*x**S(2))**(q + S(1))*(a + b*x + c*x**S(2))**(p + S(1))*(b**S(3)*f + b*c*(-S(3)*a*f + c*d) + c*x*(-S(2)*a*c*f + b**S(2)*f + S(2)*c**S(2)*d))/((p + S(1))*(-S(4)*a*c + b**S(2))*(b**S(2)*d*f + (-a*f + c*d)**S(2))), x) rule532 = ReplacementRule(pattern532, replacement532) pattern533 = Pattern(Integral((x_**S(2)*WC('c', S(1)) + WC('a', S(0)))**p_*(x_**S(2)*WC('f', S(1)) + x_*WC('e', S(1)) + WC('d', S(0)))**WC('q', S(1)), x_), cons2, cons7, cons27, cons48, cons125, cons50, cons394, cons13, cons137, cons407, cons405) def replacement533(p, f, d, a, c, x, q, e): rubi.append(533) return -Dist(-S(1)/(S(4)*a*c*(p + S(1))*(a*c*e**S(2) + (-a*f + c*d)**S(2))), Int((a + c*x**S(2))**(p + S(1))*(d + e*x + f*x**S(2))**q*Simp(S(2)*a*c**S(2)*e**S(2)*(p + q + S(2)) + c*f*x**S(2)*(-S(2)*a*c*f + S(2)*c**S(2)*d)*(S(2)*p + S(2)*q + S(5)) + S(2)*c*(p + S(1))*(a*c*e**S(2) + (-a*f + c*d)**S(2)) + x*(S(4)*a*c**S(2)*e*f*(p + q + S(2)) + c*e*(-S(2)*a*c*f + S(2)*c**S(2)*d)*(S(2)*p + q + S(4))) - (-S(2)*a*c*f + S(2)*c**S(2)*d)*(a*f*(p + S(1)) - c*d*(p + S(2))), x), x), x) + Simp(-(a + c*x**S(2))**(p + S(1))*(S(2)*a*c**S(2)*e + c*x*(-S(2)*a*c*f + S(2)*c**S(2)*d))*(d + e*x + f*x**S(2))**(q + S(1))/(S(4)*a*c*(p + S(1))*(a*c*e**S(2) + (-a*f + c*d)**S(2))), x) rule533 = ReplacementRule(pattern533, replacement533) pattern534 = Pattern(Integral((x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0)))**p_*(x_**S(2)*WC('f', S(1)) + x_*WC('e', S(1)) + WC('d', S(0)))**WC('q', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons50, cons226, cons394, cons13, cons146, cons408, cons409) def replacement534(p, f, b, d, c, a, x, q, e): rubi.append(534) return -Dist(S(1)/(S(2)*f**S(2)*(p + q)*(S(2)*p + S(2)*q + S(1))), Int((a + b*x + c*x**S(2))**(p + S(-2))*(d + e*x + f*x**S(2))**q*Simp(x**S(2)*(c*(p + q)*(-c*(S(2)*d*f*(-S(2)*p + S(1)) + e**S(2)*(S(3)*p + q + S(-1))) + f*(-S(2)*a*f + b*e)*(S(4)*p + S(2)*q + S(-1))) + p*(-p + S(1))*(-b*f + c*e)**S(2)) + x*(S(2)*(-p + S(1))*(S(2)*p + q)*(-a*f + c*d)*(-b*f + c*e) - (p + q)*(b*(c*(S(2)*p + q)*(-S(4)*d*f + e**S(2)) + f*(S(2)*p + S(2)*q + S(1))*(S(2)*a*f - b*e + S(2)*c*d)) + e*f*(-p + S(1))*(-S(4)*a*c + b**S(2)))) + (-p + S(1))*(S(2)*p + q)*(-a*e + b*d)*(-b*f + c*e) - (p + q)*(-a*(c*(S(2)*d*f - e**S(2)*(S(2)*p + q)) + f*(-S(2)*a*f + b*e)*(S(2)*p + S(2)*q + S(1))) + b**S(2)*d*f*(-p + S(1))), x), x), x) + Simp((a + b*x + c*x**S(2))**(p + S(-1))*(d + e*x + f*x**S(2))**(q + S(1))*(b*f*(S(3)*p + S(2)*q) - c*e*(S(2)*p + q) + S(2)*c*f*x*(p + q))/(S(2)*f**S(2)*(p + q)*(S(2)*p + S(2)*q + S(1))), x) rule534 = ReplacementRule(pattern534, replacement534) pattern535 = Pattern(Integral((x_**S(2)*WC('f', S(1)) + WC('d', S(0)))**WC('q', S(1))*(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0)))**p_, x_), cons2, cons3, cons7, cons27, cons125, cons50, cons226, cons13, cons146, cons408, cons409) def replacement535(p, f, b, d, c, a, x, q): rubi.append(535) return -Dist(S(1)/(S(2)*f*(p + q)*(S(2)*p + S(2)*q + S(1))), Int((d + f*x**S(2))**q*(a + b*x + c*x**S(2))**(p + S(-2))*Simp(b**S(2)*d*(p + S(-1))*(S(2)*p + q) + x**S(2)*(b**S(2)*f*p*(-p + S(1)) + S(2)*c*(p + q)*(-a*f*(S(4)*p + S(2)*q + S(-1)) + c*d*(S(2)*p + S(-1)))) - x*(S(2)*b*(-p + S(1))*(S(2)*p + q)*(-a*f + c*d) - S(2)*b*(p + q)*(S(2)*c*d*(S(2)*p + q) - (a*f + c*d)*(S(2)*p + S(2)*q + S(1)))) - (p + q)*(-S(2)*a*(-a*f*(S(2)*p + S(2)*q + S(1)) + c*d) + b**S(2)*d*(-p + S(1))), x), x), x) + Simp((d + f*x**S(2))**(q + S(1))*(b*(S(3)*p + S(2)*q) + S(2)*c*x*(p + q))*(a + b*x + c*x**S(2))**(p + S(-1))/(S(2)*f*(p + q)*(S(2)*p + S(2)*q + S(1))), x) rule535 = ReplacementRule(pattern535, replacement535) pattern536 = Pattern(Integral((x_**S(2)*WC('c', S(1)) + WC('a', S(0)))**p_*(x_**S(2)*WC('f', S(1)) + x_*WC('e', S(1)) + WC('d', S(0)))**WC('q', S(1)), x_), cons2, cons7, cons27, cons48, cons125, cons50, cons394, cons13, cons146, cons408, cons409) def replacement536(p, f, d, a, c, x, q, e): rubi.append(536) return -Dist(S(1)/(S(2)*f**S(2)*(p + q)*(S(2)*p + S(2)*q + S(1))), Int((a + c*x**S(2))**(p + S(-2))*(d + e*x + f*x**S(2))**q*Simp(-a*c*e**S(2)*(-p + S(1))*(S(2)*p + q) + a*(p + q)*(-S(2)*a*f**S(2)*(S(2)*p + S(2)*q + S(1)) + c*(S(2)*d*f - e**S(2)*(S(2)*p + q))) + x**S(2)*(c**S(2)*e**S(2)*p*(-p + S(1)) - c*(p + q)*(S(2)*a*f**S(2)*(S(4)*p + S(2)*q + S(-1)) + c*(S(2)*d*f*(-S(2)*p + S(1)) + e**S(2)*(S(3)*p + q + S(-1))))) + x*(S(4)*a*c*e*f*(-p + S(1))*(p + q) + S(2)*c*e*(-p + S(1))*(S(2)*p + q)*(-a*f + c*d)), x), x), x) - Simp(c*(a + c*x**S(2))**(p + S(-1))*(e*(S(2)*p + q) - S(2)*f*x*(p + q))*(d + e*x + f*x**S(2))**(q + S(1))/(S(2)*f**S(2)*(p + q)*(S(2)*p + S(2)*q + S(1))), x) rule536 = ReplacementRule(pattern536, replacement536) def With537(f, b, d, c, a, x, e): if isinstance(x, (int, Integer, float, Float)): return False q = a**S(2)*f**S(2) - a*b*e*f - S(2)*a*c*d*f + a*c*e**S(2) + b**S(2)*d*f - b*c*d*e + c**S(2)*d**S(2) if NonzeroQ(q): return True return False pattern537 = Pattern(Integral(S(1)/((a_ + x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)))*(d_ + x_**S(2)*WC('f', S(1)) + x_*WC('e', S(1)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons226, cons394, CustomConstraint(With537)) def replacement537(f, b, d, c, a, x, e): q = a**S(2)*f**S(2) - a*b*e*f - S(2)*a*c*d*f + a*c*e**S(2) + b**S(2)*d*f - b*c*d*e + c**S(2)*d**S(2) rubi.append(537) return Dist(S(1)/q, Int((-a*c*f + b**S(2)*f - b*c*e + c**S(2)*d - x*(-b*c*f + c**S(2)*e))/(a + b*x + c*x**S(2)), x), x) + Dist(S(1)/q, Int((a*f**S(2) - b*e*f - c*d*f + c*e**S(2) + x*(-b*f**S(2) + c*e*f))/(d + e*x + f*x**S(2)), x), x) rule537 = ReplacementRule(pattern537, replacement537) def With538(f, b, d, c, a, x): if isinstance(x, (int, Integer, float, Float)): return False q = a**S(2)*f**S(2) - S(2)*a*c*d*f + b**S(2)*d*f + c**S(2)*d**S(2) if NonzeroQ(q): return True return False pattern538 = Pattern(Integral(S(1)/((d_ + x_**S(2)*WC('f', S(1)))*(a_ + x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)))), x_), cons2, cons3, cons7, cons27, cons125, cons226, CustomConstraint(With538)) def replacement538(f, b, d, c, a, x): q = a**S(2)*f**S(2) - S(2)*a*c*d*f + b**S(2)*d*f + c**S(2)*d**S(2) rubi.append(538) return -Dist(S(1)/q, Int((-a*f**S(2) + b*f**S(2)*x + c*d*f)/(d + f*x**S(2)), x), x) + Dist(S(1)/q, Int((-a*c*f + b**S(2)*f + b*c*f*x + c**S(2)*d)/(a + b*x + c*x**S(2)), x), x) rule538 = ReplacementRule(pattern538, replacement538) pattern539 = Pattern(Integral(S(1)/((a_ + x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)))*sqrt(x_**S(2)*WC('f', S(1)) + x_*WC('e', S(1)) + WC('d', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons226, cons394, cons410) def replacement539(f, b, d, c, a, x, e): rubi.append(539) return Dist(-S(2)*e, Subst(Int(S(1)/(e*(-S(4)*a*f + b*e) - x**S(2)*(-a*e + b*d)), x), x, (e + S(2)*f*x)/sqrt(d + e*x + f*x**S(2))), x) rule539 = ReplacementRule(pattern539, replacement539) def With540(f, b, d, c, a, x, e): q = Rt(-S(4)*a*c + b**S(2), S(2)) rubi.append(540) return Dist(S(2)*c/q, Int(S(1)/((b + S(2)*c*x - q)*sqrt(d + e*x + f*x**S(2))), x), x) - Dist(S(2)*c/q, Int(S(1)/((b + S(2)*c*x + q)*sqrt(d + e*x + f*x**S(2))), x), x) pattern540 = Pattern(Integral(S(1)/((a_ + x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)))*sqrt(x_**S(2)*WC('f', S(1)) + x_*WC('e', S(1)) + WC('d', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons226, cons394, cons411, cons231) rule540 = ReplacementRule(pattern540, With540) pattern541 = Pattern(Integral(S(1)/((a_ + x_**S(2)*WC('c', S(1)))*sqrt(x_**S(2)*WC('f', S(1)) + x_*WC('e', S(1)) + WC('d', S(0)))), x_), cons2, cons7, cons27, cons48, cons125, cons394, cons412) def replacement541(f, d, c, a, x, e): rubi.append(541) return Dist(S(1)/2, Int(S(1)/((a - x*Rt(-a*c, S(2)))*sqrt(d + e*x + f*x**S(2))), x), x) + Dist(S(1)/2, Int(S(1)/((a + x*Rt(-a*c, S(2)))*sqrt(d + e*x + f*x**S(2))), x), x) rule541 = ReplacementRule(pattern541, replacement541) def With542(f, b, d, c, a, x): q = Rt(-S(4)*a*c + b**S(2), S(2)) rubi.append(542) return Dist(S(2)*c/q, Int(S(1)/(sqrt(d + f*x**S(2))*(b + S(2)*c*x - q)), x), x) - Dist(S(2)*c/q, Int(S(1)/(sqrt(d + f*x**S(2))*(b + S(2)*c*x + q)), x), x) pattern542 = Pattern(Integral(S(1)/(sqrt(d_ + x_**S(2)*WC('f', S(1)))*(a_ + x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)))), x_), cons2, cons3, cons7, cons27, cons125, cons226, cons231) rule542 = ReplacementRule(pattern542, With542) def With543(f, b, d, c, a, x, e): q = Rt(-(-a*e + b*d)*(-b*f + c*e) + (-a*f + c*d)**S(2), S(2)) rubi.append(543) return -Dist(S(1)/(S(2)*q), Int((-a*f + c*d - q + x*(-b*f + c*e))/((a + b*x + c*x**S(2))*sqrt(d + e*x + f*x**S(2))), x), x) + Dist(S(1)/(S(2)*q), Int((-a*f + c*d + q + x*(-b*f + c*e))/((a + b*x + c*x**S(2))*sqrt(d + e*x + f*x**S(2))), x), x) pattern543 = Pattern(Integral(S(1)/((x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0)))*sqrt(x_**S(2)*WC('f', S(1)) + x_*WC('e', S(1)) + WC('d', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons226, cons394, cons411, cons413) rule543 = ReplacementRule(pattern543, With543) def With544(f, d, a, c, x, e): q = Rt(a*c*e**S(2) + (-a*f + c*d)**S(2), S(2)) rubi.append(544) return -Dist(S(1)/(S(2)*q), Int((-a*f + c*d + c*e*x - q)/((a + c*x**S(2))*sqrt(d + e*x + f*x**S(2))), x), x) + Dist(S(1)/(S(2)*q), Int((-a*f + c*d + c*e*x + q)/((a + c*x**S(2))*sqrt(d + e*x + f*x**S(2))), x), x) pattern544 = Pattern(Integral(S(1)/((x_**S(2)*WC('c', S(1)) + WC('a', S(0)))*sqrt(x_**S(2)*WC('f', S(1)) + x_*WC('e', S(1)) + WC('d', S(0)))), x_), cons2, cons7, cons27, cons48, cons125, cons394, cons414) rule544 = ReplacementRule(pattern544, With544) def With545(f, b, d, c, a, x): q = Rt(b**S(2)*d*f + (-a*f + c*d)**S(2), S(2)) rubi.append(545) return -Dist(S(1)/(S(2)*q), Int((-a*f - b*f*x + c*d - q)/(sqrt(d + f*x**S(2))*(a + b*x + c*x**S(2))), x), x) + Dist(S(1)/(S(2)*q), Int((-a*f - b*f*x + c*d + q)/(sqrt(d + f*x**S(2))*(a + b*x + c*x**S(2))), x), x) pattern545 = Pattern(Integral(S(1)/(sqrt(x_**S(2)*WC('f', S(1)) + WC('d', S(0)))*(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0)))), x_), cons2, cons3, cons7, cons27, cons125, cons226, cons413) rule545 = ReplacementRule(pattern545, With545) pattern546 = Pattern(Integral(sqrt(a_ + x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)))/(d_ + x_**S(2)*WC('f', S(1)) + x_*WC('e', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons226, cons394) def replacement546(f, b, d, c, a, x, e): rubi.append(546) return -Dist(S(1)/f, Int((-a*f + c*d + x*(-b*f + c*e))/(sqrt(a + b*x + c*x**S(2))*(d + e*x + f*x**S(2))), x), x) + Dist(c/f, Int(S(1)/sqrt(a + b*x + c*x**S(2)), x), x) rule546 = ReplacementRule(pattern546, replacement546) pattern547 = Pattern(Integral(sqrt(a_ + x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)))/(d_ + x_**S(2)*WC('f', S(1))), x_), cons2, cons3, cons7, cons27, cons125, cons226) def replacement547(f, b, d, c, a, x): rubi.append(547) return -Dist(S(1)/f, Int((-a*f - b*f*x + c*d)/((d + f*x**S(2))*sqrt(a + b*x + c*x**S(2))), x), x) + Dist(c/f, Int(S(1)/sqrt(a + b*x + c*x**S(2)), x), x) rule547 = ReplacementRule(pattern547, replacement547) pattern548 = Pattern(Integral(sqrt(a_ + x_**S(2)*WC('c', S(1)))/(d_ + x_**S(2)*WC('f', S(1)) + x_*WC('e', S(1))), x_), cons2, cons7, cons27, cons48, cons125, cons394) def replacement548(f, d, c, a, x, e): rubi.append(548) return -Dist(S(1)/f, Int((-a*f + c*d + c*e*x)/(sqrt(a + c*x**S(2))*(d + e*x + f*x**S(2))), x), x) + Dist(c/f, Int(S(1)/sqrt(a + c*x**S(2)), x), x) rule548 = ReplacementRule(pattern548, replacement548) def With549(f, b, d, c, a, x, e): r = Rt(-S(4)*a*c + b**S(2), S(2)) rubi.append(549) return Dist(sqrt(S(2)*a + x*(b + r))*sqrt(b + S(2)*c*x + r)/sqrt(a + b*x + c*x**S(2)), Int(S(1)/(sqrt(S(2)*a + x*(b + r))*sqrt(b + S(2)*c*x + r)*sqrt(d + e*x + f*x**S(2))), x), x) pattern549 = Pattern(Integral(S(1)/(sqrt(a_ + x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)))*sqrt(d_ + x_**S(2)*WC('f', S(1)) + x_*WC('e', S(1)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons226, cons394) rule549 = ReplacementRule(pattern549, With549) def With550(f, b, d, c, a, x): r = Rt(-S(4)*a*c + b**S(2), S(2)) rubi.append(550) return Dist(sqrt(S(2)*a + x*(b + r))*sqrt(b + S(2)*c*x + r)/sqrt(a + b*x + c*x**S(2)), Int(S(1)/(sqrt(S(2)*a + x*(b + r))*sqrt(d + f*x**S(2))*sqrt(b + S(2)*c*x + r)), x), x) pattern550 = Pattern(Integral(S(1)/(sqrt(d_ + x_**S(2)*WC('f', S(1)))*sqrt(a_ + x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)))), x_), cons2, cons3, cons7, cons27, cons125, cons226) rule550 = ReplacementRule(pattern550, With550) pattern551 = Pattern(Integral((x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0)))**p_*(x_**S(2)*WC('f', S(1)) + x_*WC('e', S(1)) + WC('d', S(0)))**q_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons5, cons50, cons415) def replacement551(p, f, b, d, c, a, x, q, e): rubi.append(551) return Int((a + b*x + c*x**S(2))**p*(d + e*x + f*x**S(2))**q, x) rule551 = ReplacementRule(pattern551, replacement551) pattern552 = Pattern(Integral((a_ + x_**S(2)*WC('c', S(1)))**p_*(x_**S(2)*WC('f', S(1)) + x_*WC('e', S(1)) + WC('d', S(0)))**q_, x_), cons2, cons7, cons27, cons48, cons125, cons5, cons50, cons416) def replacement552(p, f, d, c, a, x, q, e): rubi.append(552) return Int((a + c*x**S(2))**p*(d + e*x + f*x**S(2))**q, x) rule552 = ReplacementRule(pattern552, replacement552) pattern553 = Pattern(Integral((u_**S(2)*WC('c', S(1)) + u_*WC('b', S(1)) + WC('a', S(0)))**WC('p', S(1))*(u_**S(2)*WC('f', S(1)) + u_*WC('e', S(1)) + WC('d', S(0)))**WC('q', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons5, cons50, cons68, cons69) def replacement553(p, u, f, b, d, c, a, x, q, e): rubi.append(553) return Dist(S(1)/Coefficient(u, x, S(1)), Subst(Int((a + b*x + c*x**S(2))**p*(d + e*x + f*x**S(2))**q, x), x, u), x) rule553 = ReplacementRule(pattern553, replacement553) pattern554 = Pattern(Integral((u_**S(2)*WC('c', S(1)) + WC('a', S(0)))**WC('p', S(1))*(u_**S(2)*WC('f', S(1)) + u_*WC('e', S(1)) + WC('d', S(0)))**WC('q', S(1)), x_), cons2, cons7, cons27, cons48, cons125, cons5, cons50, cons68, cons69) def replacement554(p, u, f, d, a, c, x, q, e): rubi.append(554) return Dist(S(1)/Coefficient(u, x, S(1)), Subst(Int((a + c*x**S(2))**p*(d + e*x + f*x**S(2))**q, x), x, u), x) rule554 = ReplacementRule(pattern554, replacement554) pattern555 = Pattern(Integral((x_*WC('h', S(1)) + WC('g', S(0)))**WC('m', S(1))*(a_ + x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)))**WC('p', S(1))*(d_ + x_**S(2)*WC('f', S(1)) + x_*WC('e', S(1)))**WC('q', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons209, cons5, cons50, cons382, cons383, cons384, cons385) def replacement555(p, m, g, b, f, d, c, a, x, h, q, e): rubi.append(555) return Dist((c/f)**p, Int((g + h*x)**m*(d + e*x + f*x**S(2))**(p + q), x), x) rule555 = ReplacementRule(pattern555, replacement555) pattern556 = Pattern(Integral((x_*WC('h', S(1)) + WC('g', S(0)))**WC('m', S(1))*(a_ + x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)))**WC('p', S(1))*(d_ + x_**S(2)*WC('f', S(1)) + x_*WC('e', S(1)))**WC('q', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons209, cons5, cons50, cons382, cons383, cons147, cons386, cons387) def replacement556(p, m, g, b, f, d, c, a, x, h, q, e): rubi.append(556) return Dist(a**IntPart(p)*d**(-IntPart(p))*(a + b*x + c*x**S(2))**FracPart(p)*(d + e*x + f*x**S(2))**(-FracPart(p)), Int((g + h*x)**m*(d + e*x + f*x**S(2))**(p + q), x), x) rule556 = ReplacementRule(pattern556, replacement556) pattern557 = Pattern(Integral((x_*WC('h', S(1)) + WC('g', S(0)))**WC('m', S(1))*(a_ + x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)))**p_*(d_ + x_**S(2)*WC('f', S(1)) + x_*WC('e', S(1)))**WC('q', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons209, cons21, cons5, cons50, cons45) def replacement557(p, m, g, b, f, d, c, a, x, h, q, e): rubi.append(557) return Dist((S(4)*c)**(-IntPart(p))*(b + S(2)*c*x)**(-S(2)*FracPart(p))*(a + b*x + c*x**S(2))**FracPart(p), Int((b + S(2)*c*x)**(S(2)*p)*(g + h*x)**m*(d + e*x + f*x**S(2))**q, x), x) rule557 = ReplacementRule(pattern557, replacement557) pattern558 = Pattern(Integral((d_ + x_**S(2)*WC('f', S(1)))**WC('q', S(1))*(x_*WC('h', S(1)) + WC('g', S(0)))**WC('m', S(1))*(a_ + x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)))**p_, x_), cons2, cons3, cons7, cons27, cons125, cons208, cons209, cons21, cons5, cons50, cons45) def replacement558(p, m, g, b, f, d, c, a, x, h, q): rubi.append(558) return Dist((S(4)*c)**(-IntPart(p))*(b + S(2)*c*x)**(-S(2)*FracPart(p))*(a + b*x + c*x**S(2))**FracPart(p), Int((b + S(2)*c*x)**(S(2)*p)*(d + f*x**S(2))**q*(g + h*x)**m, x), x) rule558 = ReplacementRule(pattern558, replacement558) pattern559 = Pattern(Integral((g_ + x_*WC('h', S(1)))**WC('m', S(1))*(a_ + x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)))**WC('p', S(1))*(x_**S(2)*WC('f', S(1)) + x_*WC('e', S(1)) + WC('d', S(0)))**WC('m', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons209, cons5, cons417, cons418, cons17) def replacement559(p, m, f, b, g, d, c, a, x, h, e): rubi.append(559) return Int((f*h*x/c + d*g/a)**m*(a + b*x + c*x**S(2))**(m + p), x) rule559 = ReplacementRule(pattern559, replacement559) pattern560 = Pattern(Integral((a_ + x_**S(2)*WC('c', S(1)))**WC('p', S(1))*(g_ + x_*WC('h', S(1)))**WC('m', S(1))*(x_**S(2)*WC('f', S(1)) + x_*WC('e', S(1)) + WC('d', S(0)))**WC('m', S(1)), x_), cons2, cons7, cons27, cons48, cons125, cons208, cons209, cons5, cons419, cons418, cons17) def replacement560(p, m, f, g, d, c, a, x, h, e): rubi.append(560) return Int((a + c*x**S(2))**(m + p)*(f*h*x/c + d*g/a)**m, x) rule560 = ReplacementRule(pattern560, replacement560) pattern561 = Pattern(Integral((g_ + x_*WC('h', S(1)))**WC('m', S(1))*(x_**S(2)*WC('f', S(1)) + WC('d', S(0)))**WC('m', S(1))*(a_ + x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons125, cons208, cons209, cons5, cons417, cons420, cons17) def replacement561(p, m, f, b, g, d, c, a, x, h): rubi.append(561) return Int((f*h*x/c + d*g/a)**m*(a + b*x + c*x**S(2))**(m + p), x) rule561 = ReplacementRule(pattern561, replacement561) pattern562 = Pattern(Integral((a_ + x_**S(2)*WC('c', S(1)))**WC('p', S(1))*(g_ + x_*WC('h', S(1)))**WC('m', S(1))*(x_**S(2)*WC('f', S(1)) + WC('d', S(0)))**WC('m', S(1)), x_), cons2, cons7, cons27, cons125, cons208, cons209, cons5, cons419, cons420, cons17) def replacement562(p, m, f, g, d, c, a, x, h): rubi.append(562) return Int((a + c*x**S(2))**(m + p)*(f*h*x/c + d*g/a)**m, x) rule562 = ReplacementRule(pattern562, replacement562) pattern563 = Pattern(Integral(x_**WC('p', S(1))*(x_**S(2)*WC('f', S(1)) + x_*WC('e', S(1)))**WC('q', S(1))*(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons48, cons125, cons50, cons226, cons421, cons38) def replacement563(p, f, b, c, a, x, q, e): rubi.append(563) return Int((a/e + c*x/f)**p*(e*x + f*x**S(2))**(p + q), x) rule563 = ReplacementRule(pattern563, replacement563) pattern564 = Pattern(Integral(x_**WC('p', S(1))*(a_ + x_**S(2)*WC('c', S(1)))**WC('p', S(1))*(x_**S(2)*WC('f', S(1)) + x_*WC('e', S(1)))**WC('q', S(1)), x_), cons2, cons7, cons48, cons125, cons50, cons422, cons38) def replacement564(p, f, c, a, x, q, e): rubi.append(564) return Int((a/e + c*x/f)**p*(e*x + f*x**S(2))**(p + q), x) rule564 = ReplacementRule(pattern564, replacement564) pattern565 = Pattern(Integral((x_*WC('h', S(1)) + WC('g', S(0)))**WC('m', S(1))*(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0)))**WC('p', S(1))*(x_**S(2)*WC('f', S(1)) + x_*WC('e', S(1)) + WC('d', S(0))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons209, cons21, cons5, cons423, cons424, cons270) def replacement565(p, m, g, b, f, d, a, c, x, h, e): rubi.append(565) return Simp(f*(g + h*x)**(m + S(1))*(a + b*x + c*x**S(2))**(p + S(1))/(c*h*(m + S(2)*p + S(3))), x) rule565 = ReplacementRule(pattern565, replacement565) pattern566 = Pattern(Integral((a_ + x_**S(2)*WC('c', S(1)))**WC('p', S(1))*(x_*WC('h', S(1)) + WC('g', S(0)))**WC('m', S(1))*(x_**S(2)*WC('f', S(1)) + x_*WC('e', S(1)) + WC('d', S(0))), x_), cons2, cons7, cons27, cons48, cons125, cons208, cons209, cons21, cons5, cons425, cons426, cons270) def replacement566(p, m, g, f, d, c, a, x, h, e): rubi.append(566) return Simp(f*(a + c*x**S(2))**(p + S(1))*(g + h*x)**(m + S(1))/(c*h*(m + S(2)*p + S(3))), x) rule566 = ReplacementRule(pattern566, replacement566) pattern567 = Pattern(Integral((d_ + x_**S(2)*WC('f', S(1)))*(x_*WC('h', S(1)) + WC('g', S(0)))**WC('m', S(1))*(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons125, cons208, cons209, cons21, cons5, cons427, cons424, cons270) def replacement567(p, m, g, b, f, d, a, c, x, h): rubi.append(567) return Simp(f*(g + h*x)**(m + S(1))*(a + b*x + c*x**S(2))**(p + S(1))/(c*h*(m + S(2)*p + S(3))), x) rule567 = ReplacementRule(pattern567, replacement567) pattern568 = Pattern(Integral((x_*WC('h', S(1)) + WC('g', S(0)))**WC('m', S(1))*(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0)))**WC('p', S(1))*(x_**S(2)*WC('f', S(1)) + x_*WC('e', S(1)) + WC('d', S(0))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons209, cons21, cons226, cons394, cons428) def replacement568(p, m, g, b, f, d, a, c, x, h, e): rubi.append(568) return Int(ExpandIntegrand((g + h*x)**m*(a + b*x + c*x**S(2))**p*(d + e*x + f*x**S(2)), x), x) rule568 = ReplacementRule(pattern568, replacement568) pattern569 = Pattern(Integral((a_ + x_**S(2)*WC('c', S(1)))**WC('p', S(1))*(x_*WC('h', S(1)) + WC('g', S(0)))**WC('m', S(1))*(x_**S(2)*WC('f', S(1)) + x_*WC('e', S(1)) + WC('d', S(0))), x_), cons2, cons7, cons27, cons48, cons125, cons208, cons209, cons21, cons394, cons428) def replacement569(p, m, g, f, d, c, a, x, h, e): rubi.append(569) return Int(ExpandIntegrand((a + c*x**S(2))**p*(g + h*x)**m*(d + e*x + f*x**S(2)), x), x) rule569 = ReplacementRule(pattern569, replacement569) pattern570 = Pattern(Integral((d_ + x_**S(2)*WC('f', S(1)))*(x_*WC('h', S(1)) + WC('g', S(0)))**WC('m', S(1))*(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons125, cons208, cons209, cons21, cons226, cons428) def replacement570(p, m, g, b, f, d, a, c, x, h): rubi.append(570) return Int(ExpandIntegrand((d + f*x**S(2))*(g + h*x)**m*(a + b*x + c*x**S(2))**p, x), x) rule570 = ReplacementRule(pattern570, replacement570) pattern571 = Pattern(Integral((a_ + x_**S(2)*WC('c', S(1)))**WC('p', S(1))*(g_ + x_*WC('h', S(1)))**WC('m', S(1))*(x_**S(2)*WC('f', S(1)) + WC('d', S(0))), x_), cons2, cons7, cons27, cons125, cons208, cons209, cons21, cons428) def replacement571(p, m, f, g, d, c, a, x, h): rubi.append(571) return Int(ExpandIntegrand((a + c*x**S(2))**p*(d + f*x**S(2))*(g + h*x)**m, x), x) rule571 = ReplacementRule(pattern571, replacement571) pattern572 = Pattern(Integral((x_*WC('h', S(1)) + WC('g', S(0)))**m_*(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0)))**WC('p', S(1))*(x_**S(2)*WC('f', S(1)) + x_*WC('e', S(1)) + WC('d', S(0))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons209, cons5, cons226, cons394, cons31, cons94, cons429) def replacement572(p, m, g, b, f, d, a, c, x, h, e): rubi.append(572) return Dist(S(1)/(h*(m + S(1))*(a*h**S(2) - b*g*h + c*g**S(2))), Int((g + h*x)**(m + S(1))*(a + b*x + c*x**S(2))**p*Simp(-b*(f*g**S(2)*(p + S(1)) - h*(-d*h*(m + p + S(2)) + e*g*(p + S(1)))) + h*(m + S(1))*(a*e*h - a*f*g + c*d*g) - x*(c*(S(2)*f*g**S(2)*(p + S(1)) - h*(-d*h + e*g)*(m + S(2)*p + S(3))) + f*h*(m + S(1))*(-a*h + b*g)), x), x), x) + Simp((g + h*x)**(m + S(1))*(a + b*x + c*x**S(2))**(p + S(1))*(d*h**S(2) - e*g*h + f*g**S(2))/(h*(m + S(1))*(a*h**S(2) - b*g*h + c*g**S(2))), x) rule572 = ReplacementRule(pattern572, replacement572) pattern573 = Pattern(Integral((a_ + x_**S(2)*WC('c', S(1)))**WC('p', S(1))*(x_*WC('h', S(1)) + WC('g', S(0)))**m_*(x_**S(2)*WC('f', S(1)) + x_*WC('e', S(1)) + WC('d', S(0))), x_), cons2, cons7, cons27, cons48, cons125, cons208, cons209, cons5, cons394, cons31, cons94, cons430) def replacement573(p, m, g, f, d, c, a, x, h, e): rubi.append(573) return Dist(S(1)/(h*(m + S(1))*(a*h**S(2) + c*g**S(2))), Int((a + c*x**S(2))**p*(g + h*x)**(m + S(1))*Simp(h*(m + S(1))*(a*e*h - a*f*g + c*d*g) + x*(a*f*h**S(2)*(m + S(1)) - c*(S(2)*f*g**S(2)*(p + S(1)) - h*(-d*h + e*g)*(m + S(2)*p + S(3)))), x), x), x) + Simp((a + c*x**S(2))**(p + S(1))*(g + h*x)**(m + S(1))*(d*h**S(2) - e*g*h + f*g**S(2))/(h*(m + S(1))*(a*h**S(2) + c*g**S(2))), x) rule573 = ReplacementRule(pattern573, replacement573) pattern574 = Pattern(Integral((x_*WC('h', S(1)) + WC('g', S(0)))**m_*(x_**S(2)*WC('f', S(1)) + WC('d', S(0)))*(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons125, cons208, cons209, cons5, cons226, cons31, cons94, cons429) def replacement574(p, m, g, b, f, d, a, c, x, h): rubi.append(574) return Dist(S(1)/(h*(m + S(1))*(a*h**S(2) - b*g*h + c*g**S(2))), Int((g + h*x)**(m + S(1))*(a + b*x + c*x**S(2))**p*Simp(-b*(d*h**S(2)*(m + p + S(2)) + f*g**S(2)*(p + S(1))) + h*(m + S(1))*(-a*f*g + c*d*g) - x*(c*(d*h**S(2)*(m + S(2)*p + S(3)) + S(2)*f*g**S(2)*(p + S(1))) + f*h*(m + S(1))*(-a*h + b*g)), x), x), x) + Simp((g + h*x)**(m + S(1))*(d*h**S(2) + f*g**S(2))*(a + b*x + c*x**S(2))**(p + S(1))/(h*(m + S(1))*(a*h**S(2) - b*g*h + c*g**S(2))), x) rule574 = ReplacementRule(pattern574, replacement574) pattern575 = Pattern(Integral((a_ + x_**S(2)*WC('c', S(1)))**WC('p', S(1))*(g_ + x_*WC('h', S(1)))**m_*(x_**S(2)*WC('f', S(1)) + WC('d', S(0))), x_), cons2, cons7, cons27, cons125, cons208, cons209, cons5, cons31, cons94, cons430) def replacement575(p, m, f, g, d, c, a, x, h): rubi.append(575) return Dist(S(1)/(h*(m + S(1))*(a*h**S(2) + c*g**S(2))), Int((a + c*x**S(2))**p*(g + h*x)**(m + S(1))*Simp(h*(m + S(1))*(-a*f*g + c*d*g) + x*(a*f*h**S(2)*(m + S(1)) - c*(d*h**S(2)*(m + S(2)*p + S(3)) + S(2)*f*g**S(2)*(p + S(1)))), x), x), x) + Simp((a + c*x**S(2))**(p + S(1))*(g + h*x)**(m + S(1))*(d*h**S(2) + f*g**S(2))/(h*(m + S(1))*(a*h**S(2) + c*g**S(2))), x) rule575 = ReplacementRule(pattern575, replacement575) pattern576 = Pattern(Integral((x_**S(2)*WC('f', S(1)) + x_*WC('e', S(1)) + WC('d', S(0)))/((x_*WC('h', S(1)) + WC('g', S(0)))*(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0)))**(S(3)/2)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons209, cons226, cons394, cons429) def replacement576(g, b, f, d, a, c, x, h, e): rubi.append(576) return Dist((d*h**S(2) - e*g*h + f*g**S(2))/(a*h**S(2) - b*g*h + c*g**S(2)), Int(S(1)/((g + h*x)*sqrt(a + b*x + c*x**S(2))), x), x) + Dist(S(1)/(a*h**S(2) - b*g*h + c*g**S(2)), Int((a*e*h - a*f*g - b*d*h + c*d*g + x*(a*f*h - b*f*g - c*d*h + c*e*g))/(a + b*x + c*x**S(2))**(S(3)/2), x), x) rule576 = ReplacementRule(pattern576, replacement576) pattern577 = Pattern(Integral((x_**S(2)*WC('f', S(1)) + x_*WC('e', S(1)) + WC('d', S(0)))/((a_ + x_**S(2)*WC('c', S(1)))**(S(3)/2)*(x_*WC('h', S(1)) + WC('g', S(0)))), x_), cons2, cons7, cons27, cons48, cons125, cons208, cons209, cons394, cons430) def replacement577(g, f, d, c, a, x, h, e): rubi.append(577) return Dist((d*h**S(2) - e*g*h + f*g**S(2))/(a*h**S(2) + c*g**S(2)), Int(S(1)/(sqrt(a + c*x**S(2))*(g + h*x)), x), x) + Dist(S(1)/(a*h**S(2) + c*g**S(2)), Int((a*e*h - a*f*g + c*d*g + x*(a*f*h - c*d*h + c*e*g))/(a + c*x**S(2))**(S(3)/2), x), x) rule577 = ReplacementRule(pattern577, replacement577) pattern578 = Pattern(Integral((x_**S(2)*WC('f', S(1)) + WC('d', S(0)))/((x_*WC('h', S(1)) + WC('g', S(0)))*(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0)))**(S(3)/2)), x_), cons2, cons3, cons7, cons27, cons125, cons208, cons209, cons226, cons429) def replacement578(g, b, f, d, a, c, x, h): rubi.append(578) return Dist((d*h**S(2) + f*g**S(2))/(a*h**S(2) - b*g*h + c*g**S(2)), Int(S(1)/((g + h*x)*sqrt(a + b*x + c*x**S(2))), x), x) + Dist(S(1)/(a*h**S(2) - b*g*h + c*g**S(2)), Int((-a*f*g - b*d*h + c*d*g - x*(-a*f*h + b*f*g + c*d*h))/(a + b*x + c*x**S(2))**(S(3)/2), x), x) rule578 = ReplacementRule(pattern578, replacement578) pattern579 = Pattern(Integral((x_**S(2)*WC('f', S(1)) + WC('d', S(0)))/((a_ + x_**S(2)*WC('c', S(1)))**(S(3)/2)*(g_ + x_*WC('h', S(1)))), x_), cons2, cons7, cons27, cons125, cons208, cons209, cons430) def replacement579(f, g, d, c, a, x, h): rubi.append(579) return Dist((d*h**S(2) + f*g**S(2))/(a*h**S(2) + c*g**S(2)), Int(S(1)/(sqrt(a + c*x**S(2))*(g + h*x)), x), x) + Dist(S(1)/(a*h**S(2) + c*g**S(2)), Int((-a*f*g + c*d*g - x*(-a*f*h + c*d*h))/(a + c*x**S(2))**(S(3)/2), x), x) rule579 = ReplacementRule(pattern579, replacement579) pattern580 = Pattern(Integral((x_*WC('h', S(1)) + WC('g', S(0)))**m_*(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0)))**p_*(x_**S(2)*WC('f', S(1)) + x_*WC('e', S(1)) + WC('d', S(0))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons209, cons226, cons394, cons244, cons137, cons166) def replacement580(p, m, g, b, f, d, a, c, x, h, e): rubi.append(580) return -Dist(S(1)/(c*(p + S(1))*(-S(4)*a*c + b**S(2))), Int((g + h*x)**(m + S(-1))*(a + b*x + c*x**S(2))**(p + S(1))*Simp(g*(c*(S(2)*p + S(3))*(-b*e + S(2)*c*d) - f*(S(2)*a*c - b**S(2)*(p + S(2)))) + h*m*(a*b*f - S(2)*a*c*e + b*c*d) + h*x*(c*(-b*e + S(2)*c*d)*(m + S(2)*p + S(3)) - f*(S(2)*a*c*(m + S(1)) - b**S(2)*(m + p + S(2)))), x), x), x) + Simp((g + h*x)**m*(a + b*x + c*x**S(2))**(p + S(1))*(a*b*f - S(2)*a*c*e + b*c*d + x*(c*(-b*e + S(2)*c*d) + f*(-S(2)*a*c + b**S(2))))/(c*(p + S(1))*(-S(4)*a*c + b**S(2))), x) rule580 = ReplacementRule(pattern580, replacement580) pattern581 = Pattern(Integral((a_ + x_**S(2)*WC('c', S(1)))**p_*(x_*WC('h', S(1)) + WC('g', S(0)))**m_*(x_**S(2)*WC('f', S(1)) + x_*WC('e', S(1)) + WC('d', S(0))), x_), cons2, cons7, cons27, cons48, cons125, cons208, cons209, cons394, cons244, cons137, cons166) def replacement581(p, m, g, f, d, c, a, x, h, e): rubi.append(581) return -Dist(S(1)/(S(2)*a*c*(p + S(1))), Int((a + c*x**S(2))**(p + S(1))*(g + h*x)**(m + S(-1))*Simp(a*(e*h*m + f*g) - c*d*g*(S(2)*p + S(3)) + h*x*(a*f*(m + S(1)) - c*d*(m + S(2)*p + S(3))), x), x), x) + Simp((a + c*x**S(2))**(p + S(1))*(g + h*x)**m*(a*e - x*(-a*f + c*d))/(S(2)*a*c*(p + S(1))), x) rule581 = ReplacementRule(pattern581, replacement581) pattern582 = Pattern(Integral((x_*WC('h', S(1)) + WC('g', S(0)))**m_*(x_**S(2)*WC('f', S(1)) + WC('d', S(0)))*(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0)))**p_, x_), cons2, cons3, cons7, cons27, cons125, cons208, cons209, cons226, cons244, cons137, cons166) def replacement582(p, m, g, b, f, d, a, c, x, h): rubi.append(582) return -Dist(S(1)/(c*(p + S(1))*(-S(4)*a*c + b**S(2))), Int((g + h*x)**(m + S(-1))*(a + b*x + c*x**S(2))**(p + S(1))*Simp(g*(S(2)*c**S(2)*d*(S(2)*p + S(3)) - f*(S(2)*a*c - b**S(2)*(p + S(2)))) + h*m*(a*b*f + b*c*d) + h*x*(S(2)*c**S(2)*d*(m + S(2)*p + S(3)) - f*(S(2)*a*c*(m + S(1)) - b**S(2)*(m + p + S(2)))), x), x), x) + Simp((g + h*x)**m*(a + b*x + c*x**S(2))**(p + S(1))*(a*b*f + b*c*d + x*(S(2)*c**S(2)*d + f*(-S(2)*a*c + b**S(2))))/(c*(p + S(1))*(-S(4)*a*c + b**S(2))), x) rule582 = ReplacementRule(pattern582, replacement582) pattern583 = Pattern(Integral((a_ + x_**S(2)*WC('c', S(1)))**p_*(g_ + x_*WC('h', S(1)))**m_*(x_**S(2)*WC('f', S(1)) + WC('d', S(0))), x_), cons2, cons7, cons27, cons125, cons208, cons209, cons244, cons137, cons166) def replacement583(p, m, f, g, d, c, a, x, h): rubi.append(583) return -Dist(S(1)/(S(2)*a*c*(p + S(1))), Int((a + c*x**S(2))**(p + S(1))*(g + h*x)**(m + S(-1))*Simp(a*f*g - c*d*g*(S(2)*p + S(3)) + h*x*(a*f*(m + S(1)) - c*d*(m + S(2)*p + S(3))), x), x), x) - Simp(x*(a + c*x**S(2))**(p + S(1))*(g + h*x)**m*(-a*f + c*d)/(S(2)*a*c*(p + S(1))), x) rule583 = ReplacementRule(pattern583, replacement583) pattern584 = Pattern(Integral((x_*WC('h', S(1)) + WC('g', S(0)))**WC('m', S(1))*(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0)))**p_*(x_**S(2)*WC('f', S(1)) + x_*WC('e', S(1)) + WC('d', S(0))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons209, cons21, cons226, cons394, cons13, cons137, cons431) def replacement584(p, m, g, b, f, d, a, c, x, h, e): rubi.append(584) return -Dist(S(1)/((p + S(1))*(-S(4)*a*c + b**S(2))*(c*g**S(2) - h*(-a*h + b*g))), Int((g + h*x)**m*(a + b*x + c*x**S(2))**(p + S(1))*Simp(g*(p + S(2))*(-S(2)*a*(-c*e*h + c*f*g) + b**S(2)*f*g - b*(a*f*h + c*d*h + c*e*g) + S(2)*c**S(2)*d*g) + h*x*(m + S(2)*p + S(4))*(-S(2)*a*(-c*e*h + c*f*g) + b**S(2)*f*g - b*(a*f*h + c*d*h + c*e*g) + S(2)*c**S(2)*d*g) - h*(-(-a*e + b*d)*(-b*h + S(2)*c*g) + (-a*f + c*d)*(-S(2)*a*h + b*g))*(m + p + S(2)) + (p + S(1))*(c*g**S(2) - h*(-a*h + b*g))*(S(2)*a*f - b*e + S(2)*c*d), x), x), x) - Simp((g + h*x)**(m + S(1))*(a + b*x + c*x**S(2))**(p + S(1))*(-x*(b*f*(-a*h + b*g) + S(2)*c**S(2)*d*g - c*(-S(2)*a*e*h + S(2)*a*f*g + b*d*h + b*e*g)) - (-a*e + b*d)*(-b*h + S(2)*c*g) + (-a*f + c*d)*(-S(2)*a*h + b*g))/((p + S(1))*(-S(4)*a*c + b**S(2))*(c*g**S(2) - h*(-a*h + b*g))), x) rule584 = ReplacementRule(pattern584, replacement584) pattern585 = Pattern(Integral((a_ + x_**S(2)*WC('c', S(1)))**p_*(x_*WC('h', S(1)) + WC('g', S(0)))**WC('m', S(1))*(x_**S(2)*WC('f', S(1)) + x_*WC('e', S(1)) + WC('d', S(0))), x_), cons2, cons7, cons27, cons48, cons125, cons208, cons209, cons21, cons394, cons13, cons137, cons430) def replacement585(p, m, g, f, d, c, a, x, h, e): rubi.append(585) return Dist(S(1)/(S(2)*a*c*(p + S(1))*(a*h**S(2) + c*g**S(2))), Int((a + c*x**S(2))**(p + S(1))*(g + h*x)**m*Simp(g*(p + S(2))*(-a*(-c*e*h + c*f*g) + c**S(2)*d*g) + h*x*(-a*(-c*e*h + c*f*g) + c**S(2)*d*g)*(m + S(2)*p + S(4)) - h*(a*c*e*g - a*h*(-a*f + c*d))*(m + p + S(2)) + (p + S(1))*(a*f + c*d)*(a*h**S(2) + c*g**S(2)), x), x), x) + Simp((a + c*x**S(2))**(p + S(1))*(g + h*x)**(m + S(1))*(a*c*e*g - a*h*(-a*f + c*d) - c*x*(a*e*h - a*f*g + c*d*g))/(S(2)*a*c*(p + S(1))*(a*h**S(2) + c*g**S(2))), x) rule585 = ReplacementRule(pattern585, replacement585) pattern586 = Pattern(Integral((x_*WC('h', S(1)) + WC('g', S(0)))**WC('m', S(1))*(x_**S(2)*WC('f', S(1)) + WC('d', S(0)))*(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0)))**p_, x_), cons2, cons3, cons7, cons27, cons125, cons208, cons209, cons21, cons226, cons13, cons137, cons431) def replacement586(p, m, g, b, f, d, a, c, x, h): rubi.append(586) return -Dist(S(1)/((p + S(1))*(-S(4)*a*c + b**S(2))*(c*g**S(2) - h*(-a*h + b*g))), Int((g + h*x)**m*(a + b*x + c*x**S(2))**(p + S(1))*Simp(g*(p + S(2))*(-S(2)*a*c*f*g + b**S(2)*f*g - b*(a*f*h + c*d*h) + S(2)*c**S(2)*d*g) + h*x*(m + S(2)*p + S(4))*(-S(2)*a*c*f*g + b**S(2)*f*g - b*(a*f*h + c*d*h) + S(2)*c**S(2)*d*g) - h*(-b*d*(-b*h + S(2)*c*g) + (-a*f + c*d)*(-S(2)*a*h + b*g))*(m + p + S(2)) + S(2)*(p + S(1))*(a*f + c*d)*(c*g**S(2) - h*(-a*h + b*g)), x), x), x) - Simp((g + h*x)**(m + S(1))*(a + b*x + c*x**S(2))**(p + S(1))*(-b*d*(-b*h + S(2)*c*g) - x*(b*f*(-a*h + b*g) + S(2)*c**S(2)*d*g - c*(S(2)*a*f*g + b*d*h)) + (-a*f + c*d)*(-S(2)*a*h + b*g))/((p + S(1))*(-S(4)*a*c + b**S(2))*(c*g**S(2) - h*(-a*h + b*g))), x) rule586 = ReplacementRule(pattern586, replacement586) pattern587 = Pattern(Integral((a_ + x_**S(2)*WC('c', S(1)))**p_*(g_ + x_*WC('h', S(1)))**WC('m', S(1))*(x_**S(2)*WC('f', S(1)) + WC('d', S(0))), x_), cons2, cons7, cons27, cons125, cons208, cons209, cons21, cons13, cons137, cons430) def replacement587(p, m, f, g, d, c, a, x, h): rubi.append(587) return Dist(S(1)/(S(2)*a*c*(p + S(1))*(a*h**S(2) + c*g**S(2))), Int((a + c*x**S(2))**(p + S(1))*(g + h*x)**m*Simp(a*h**S(2)*(-a*f + c*d)*(m + p + S(2)) + g*(p + S(2))*(-a*c*f*g + c**S(2)*d*g) + h*x*(-a*c*f*g + c**S(2)*d*g)*(m + S(2)*p + S(4)) + (p + S(1))*(a*f + c*d)*(a*h**S(2) + c*g**S(2)), x), x), x) - Simp((a + c*x**S(2))**(p + S(1))*(g + h*x)**(m + S(1))*(a*h*(-a*f + c*d) + c*x*(-a*f*g + c*d*g))/(S(2)*a*c*(p + S(1))*(a*h**S(2) + c*g**S(2))), x) rule587 = ReplacementRule(pattern587, replacement587) pattern588 = Pattern(Integral((x_*WC('h', S(1)) + WC('g', S(0)))**WC('m', S(1))*(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0)))**WC('p', S(1))*(x_**S(2)*WC('f', S(1)) + x_*WC('e', S(1)) + WC('d', S(0))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons209, cons21, cons5, cons226, cons394, cons242) def replacement588(p, m, g, b, f, d, a, c, x, h, e): rubi.append(588) return -Dist(h**(S(-2)), Int((g + h*x)**m*(a + b*x + c*x**S(2))**p*(-d*h**S(2) + f*g**S(2) + h*x*(-e*h + S(2)*f*g)), x), x) + Dist(f/h**S(2), Int((g + h*x)**(m + S(2))*(a + b*x + c*x**S(2))**p, x), x) rule588 = ReplacementRule(pattern588, replacement588) pattern589 = Pattern(Integral((a_ + x_**S(2)*WC('c', S(1)))**WC('p', S(1))*(x_*WC('h', S(1)) + WC('g', S(0)))**WC('m', S(1))*(x_**S(2)*WC('f', S(1)) + x_*WC('e', S(1)) + WC('d', S(0))), x_), cons2, cons7, cons27, cons48, cons125, cons208, cons209, cons21, cons5, cons394, cons242) def replacement589(p, m, g, f, d, c, a, x, h, e): rubi.append(589) return -Dist(h**(S(-2)), Int((a + c*x**S(2))**p*(g + h*x)**m*(-d*h**S(2) + f*g**S(2) + h*x*(-e*h + S(2)*f*g)), x), x) + Dist(f/h**S(2), Int((a + c*x**S(2))**p*(g + h*x)**(m + S(2)), x), x) rule589 = ReplacementRule(pattern589, replacement589) pattern590 = Pattern(Integral((x_*WC('h', S(1)) + WC('g', S(0)))**WC('m', S(1))*(x_**S(2)*WC('f', S(1)) + WC('d', S(0)))*(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons125, cons208, cons209, cons21, cons5, cons226, cons242) def replacement590(p, m, g, b, f, d, a, c, x, h): rubi.append(590) return -Dist(h**(S(-2)), Int((g + h*x)**m*(a + b*x + c*x**S(2))**p*(-d*h**S(2) + f*g**S(2) + S(2)*f*g*h*x), x), x) + Dist(f/h**S(2), Int((g + h*x)**(m + S(2))*(a + b*x + c*x**S(2))**p, x), x) rule590 = ReplacementRule(pattern590, replacement590) pattern591 = Pattern(Integral((a_ + x_**S(2)*WC('c', S(1)))**WC('p', S(1))*(g_ + x_*WC('h', S(1)))**WC('m', S(1))*(x_**S(2)*WC('f', S(1)) + WC('d', S(0))), x_), cons2, cons7, cons27, cons125, cons208, cons209, cons21, cons5, cons242) def replacement591(p, m, f, g, d, c, a, x, h): rubi.append(591) return -Dist(h**(S(-2)), Int((a + c*x**S(2))**p*(g + h*x)**m*(-d*h**S(2) + f*g**S(2) + S(2)*f*g*h*x), x), x) + Dist(f/h**S(2), Int((a + c*x**S(2))**p*(g + h*x)**(m + S(2)), x), x) rule591 = ReplacementRule(pattern591, replacement591) pattern592 = Pattern(Integral((x_*WC('h', S(1)) + WC('g', S(0)))**WC('m', S(1))*(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0)))**WC('p', S(1))*(x_**S(2)*WC('f', S(1)) + x_*WC('e', S(1)) + WC('d', S(0))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons209, cons21, cons5, cons226, cons394, cons270) def replacement592(p, m, g, b, f, d, a, c, x, h, e): rubi.append(592) return -Dist(S(1)/(c*h*(m + S(2)*p + S(3))), Int((g + h*x)**m*(a + b*x + c*x**S(2))**p*Simp(b*f*g*(p + S(1)) + h*(a*f*(m + S(1)) - c*d*(m + S(2)*p + S(3))) + x*(b*f*h*(m + p + S(2)) + c*(-e*h*(m + S(2)*p + S(3)) + S(2)*f*g*(p + S(1)))), x), x), x) + Simp(f*(g + h*x)**(m + S(1))*(a + b*x + c*x**S(2))**(p + S(1))/(c*h*(m + S(2)*p + S(3))), x) rule592 = ReplacementRule(pattern592, replacement592) pattern593 = Pattern(Integral((a_ + x_**S(2)*WC('c', S(1)))**WC('p', S(1))*(x_*WC('h', S(1)) + WC('g', S(0)))**WC('m', S(1))*(x_**S(2)*WC('f', S(1)) + x_*WC('e', S(1)) + WC('d', S(0))), x_), cons2, cons7, cons27, cons48, cons125, cons208, cons209, cons21, cons5, cons394, cons270) def replacement593(p, m, g, f, d, c, a, x, h, e): rubi.append(593) return -Dist(S(1)/(c*h*(m + S(2)*p + S(3))), Int((a + c*x**S(2))**p*(g + h*x)**m*Simp(c*x*(-e*h*(m + S(2)*p + S(3)) + S(2)*f*g*(p + S(1))) + h*(a*f*(m + S(1)) - c*d*(m + S(2)*p + S(3))), x), x), x) + Simp(f*(a + c*x**S(2))**(p + S(1))*(g + h*x)**(m + S(1))/(c*h*(m + S(2)*p + S(3))), x) rule593 = ReplacementRule(pattern593, replacement593) pattern594 = Pattern(Integral((d_ + x_**S(2)*WC('f', S(1)))*(x_*WC('h', S(1)) + WC('g', S(0)))**WC('m', S(1))*(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons125, cons208, cons209, cons21, cons5, cons226, cons270) def replacement594(p, m, g, b, f, d, a, c, x, h): rubi.append(594) return -Dist(S(1)/(c*h*(m + S(2)*p + S(3))), Int((g + h*x)**m*(a + b*x + c*x**S(2))**p*Simp(b*f*g*(p + S(1)) + f*x*(b*h*(m + p + S(2)) + S(2)*c*g*(p + S(1))) + h*(a*f*(m + S(1)) - c*d*(m + S(2)*p + S(3))), x), x), x) + Simp(f*(g + h*x)**(m + S(1))*(a + b*x + c*x**S(2))**(p + S(1))/(c*h*(m + S(2)*p + S(3))), x) rule594 = ReplacementRule(pattern594, replacement594) pattern595 = Pattern(Integral((a_ + x_**S(2)*WC('c', S(1)))**WC('p', S(1))*(d_ + x_**S(2)*WC('f', S(1)))*(g_ + x_*WC('h', S(1)))**WC('m', S(1)), x_), cons2, cons7, cons27, cons125, cons208, cons209, cons21, cons5, cons270) def replacement595(p, m, f, g, d, c, a, x, h): rubi.append(595) return -Dist(S(1)/(c*h*(m + S(2)*p + S(3))), Int((a + c*x**S(2))**p*(g + h*x)**m*Simp(S(2)*c*f*g*x*(p + S(1)) + h*(a*f*(m + S(1)) - c*d*(m + S(2)*p + S(3))), x), x), x) + Simp(f*(a + c*x**S(2))**(p + S(1))*(g + h*x)**(m + S(1))/(c*h*(m + S(2)*p + S(3))), x) rule595 = ReplacementRule(pattern595, replacement595) pattern596 = Pattern(Integral((x_*WC('h', S(1)) + WC('g', S(0)))*(a_ + x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)))**WC('p', S(1))*(d_ + x_**S(2)*WC('f', S(1)) + x_*WC('e', S(1)))**WC('q', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons209, cons226, cons394, cons220, cons163) def replacement596(p, g, b, f, d, c, a, x, h, q, e): rubi.append(596) return Int(ExpandIntegrand((g + h*x)*(a + b*x + c*x**S(2))**p*(d + e*x + f*x**S(2))**q, x), x) rule596 = ReplacementRule(pattern596, replacement596) pattern597 = Pattern(Integral((a_ + x_**S(2)*WC('c', S(1)))**WC('p', S(1))*(x_*WC('h', S(1)) + WC('g', S(0)))*(d_ + x_**S(2)*WC('f', S(1)) + x_*WC('e', S(1)))**WC('q', S(1)), x_), cons2, cons7, cons27, cons48, cons125, cons208, cons209, cons394, cons220, cons432) def replacement597(p, g, f, d, c, a, x, h, q, e): rubi.append(597) return Int(ExpandIntegrand((a + c*x**S(2))**p*(g + h*x)*(d + e*x + f*x**S(2))**q, x), x) rule597 = ReplacementRule(pattern597, replacement597) pattern598 = Pattern(Integral((x_*WC('h', S(1)) + WC('g', S(0)))*(a_ + x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)))**WC('p', S(1))*(d_ + x_**S(2)*WC('f', S(1)) + x_*WC('e', S(1)))**WC('q', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons209, cons226, cons394, cons402, cons137, cons403) def replacement598(p, g, b, f, d, c, a, x, h, q, e): rubi.append(598) return -Dist(S(1)/((p + S(1))*(-S(4)*a*c + b**S(2))), Int((a + b*x + c*x**S(2))**(p + S(1))*(d + e*x + f*x**S(2))**(q + S(-1))*Simp(-d*(S(2)*p + S(3))*(b*h - S(2)*c*g) + e*q*(-S(2)*a*h + b*g) - f*x**S(2)*(b*h - S(2)*c*g)*(S(2)*p + S(2)*q + S(3)) + x*(-e*(b*h - S(2)*c*g)*(S(2)*p + q + S(3)) + S(2)*f*q*(-S(2)*a*h + b*g)), x), x), x) + Simp((a + b*x + c*x**S(2))**(p + S(1))*(d + e*x + f*x**S(2))**q*(-S(2)*a*h + b*g - x*(b*h - S(2)*c*g))/((p + S(1))*(-S(4)*a*c + b**S(2))), x) rule598 = ReplacementRule(pattern598, replacement598) pattern599 = Pattern(Integral((a_ + x_**S(2)*WC('c', S(1)))**WC('p', S(1))*(x_*WC('h', S(1)) + WC('g', S(0)))*(d_ + x_**S(2)*WC('f', S(1)) + x_*WC('e', S(1)))**WC('q', S(1)), x_), cons2, cons7, cons27, cons48, cons125, cons208, cons209, cons394, cons402, cons137, cons403) def replacement599(p, g, f, d, c, a, x, h, q, e): rubi.append(599) return Dist(S(1)/(S(2)*a*c*(p + S(1))), Int((a + c*x**S(2))**(p + S(1))*(d + e*x + f*x**S(2))**(q + S(-1))*Simp(-a*e*h*q + c*d*g*(S(2)*p + S(3)) + c*f*g*x**S(2)*(S(2)*p + S(2)*q + S(3)) + x*(-S(2)*a*f*h*q + c*e*g*(S(2)*p + q + S(3))), x), x), x) + Simp((a + c*x**S(2))**(p + S(1))*(a*h - c*g*x)*(d + e*x + f*x**S(2))**q/(S(2)*a*c*(p + S(1))), x) rule599 = ReplacementRule(pattern599, replacement599) pattern600 = Pattern(Integral((d_ + x_**S(2)*WC('f', S(1)))**WC('q', S(1))*(x_*WC('h', S(1)) + WC('g', S(0)))*(a_ + x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons125, cons208, cons209, cons226, cons402, cons137, cons403) def replacement600(p, g, b, f, d, c, a, x, h, q): rubi.append(600) return -Dist(S(1)/((p + S(1))*(-S(4)*a*c + b**S(2))), Int((d + f*x**S(2))**(q + S(-1))*(a + b*x + c*x**S(2))**(p + S(1))*Simp(-d*(S(2)*p + S(3))*(b*h - S(2)*c*g) + S(2)*f*q*x*(-S(2)*a*h + b*g) - f*x**S(2)*(b*h - S(2)*c*g)*(S(2)*p + S(2)*q + S(3)), x), x), x) + Simp((d + f*x**S(2))**q*(a + b*x + c*x**S(2))**(p + S(1))*(-S(2)*a*h + b*g - x*(b*h - S(2)*c*g))/((p + S(1))*(-S(4)*a*c + b**S(2))), x) rule600 = ReplacementRule(pattern600, replacement600) pattern601 = Pattern(Integral((x_*WC('h', S(1)) + WC('g', S(0)))*(a_ + x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)))**WC('p', S(1))*(d_ + x_**S(2)*WC('f', S(1)) + x_*WC('e', S(1)))**WC('q', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons209, cons50, cons226, cons394, cons13, cons137, cons404, cons405) def replacement601(p, g, b, f, d, c, a, x, h, q, e): rubi.append(601) return Dist(S(1)/((p + S(1))*(-S(4)*a*c + b**S(2))*(-(-a*e + b*d)*(-b*f + c*e) + (-a*f + c*d)**S(2))), Int((a + b*x + c*x**S(2))**(p + S(1))*(d + e*x + f*x**S(2))**q*Simp(-c*f*x**S(2)*(S(2)*p + S(2)*q + S(5))*(S(2)*a*c*e*h + b**S(2)*f*g - b*(a*f*h + c*d*h + c*e*g) + S(2)*c*g*(-a*f + c*d)) - e*(c*g*(S(2)*a*c*e - b*(a*f + c*d)) + (-a*h + b*g)*(b**S(2)*f + S(2)*c**S(2)*d - c*(S(2)*a*f + b*e)))*(p + q + S(2)) - x*(S(2)*f*(c*g*(S(2)*a*c*e - b*(a*f + c*d)) + (-a*h + b*g)*(b**S(2)*f + S(2)*c**S(2)*d - c*(S(2)*a*f + b*e)))*(p + q + S(2)) - (b*f*(p + S(1)) - c*e*(S(2)*p + q + S(4)))*(S(2)*a*c*e*h + b**S(2)*f*g - b*(a*f*h + c*d*h + c*e*g) + S(2)*c*g*(-a*f + c*d))) + (p + S(1))*(b*h - S(2)*c*g)*(-(-a*e + b*d)*(-b*f + c*e) + (-a*f + c*d)**S(2)) + (a*f*(p + S(1)) - c*d*(p + S(2)))*(S(2)*a*c*e*h + b**S(2)*f*g - b*(a*f*h + c*d*h + c*e*g) + S(2)*c*g*(-a*f + c*d)), x), x), x) + Simp((a + b*x + c*x**S(2))**(p + S(1))*(d + e*x + f*x**S(2))**(q + S(1))*(c*g*(S(2)*a*c*e - b*(a*f + c*d)) + c*x*(g*(b**S(2)*f + S(2)*c**S(2)*d - c*(S(2)*a*f + b*e)) - h*(a*b*f - S(2)*a*c*e + b*c*d)) + (-a*h + b*g)*(b**S(2)*f + S(2)*c**S(2)*d - c*(S(2)*a*f + b*e)))/((p + S(1))*(-S(4)*a*c + b**S(2))*(-(-a*e + b*d)*(-b*f + c*e) + (-a*f + c*d)**S(2))), x) rule601 = ReplacementRule(pattern601, replacement601) pattern602 = Pattern(Integral((a_ + x_**S(2)*WC('c', S(1)))**WC('p', S(1))*(x_*WC('h', S(1)) + WC('g', S(0)))*(d_ + x_**S(2)*WC('f', S(1)) + x_*WC('e', S(1)))**WC('q', S(1)), x_), cons2, cons7, cons27, cons48, cons125, cons208, cons209, cons50, cons394, cons13, cons137, cons407, cons405) def replacement602(p, g, f, d, c, a, x, h, q, e): rubi.append(602) return Dist(-S(1)/(S(4)*a*c*(p + S(1))*(a*c*e**S(2) + (-a*f + c*d)**S(2))), Int((a + c*x**S(2))**(p + S(1))*(d + e*x + f*x**S(2))**q*Simp(-c*f*x**S(2)*(S(2)*a*c*e*h + S(2)*c*g*(-a*f + c*d))*(S(2)*p + S(2)*q + S(5)) - S(2)*c*g*(p + S(1))*(a*c*e**S(2) + (-a*f + c*d)**S(2)) - e*(S(2)*a*c**S(2)*e*g - a*h*(-S(2)*a*c*f + S(2)*c**S(2)*d))*(p + q + S(2)) - x*(c*e*(S(2)*a*c*e*h + S(2)*c*g*(-a*f + c*d))*(S(2)*p + q + S(4)) + S(2)*f*(S(2)*a*c**S(2)*e*g - a*h*(-S(2)*a*c*f + S(2)*c**S(2)*d))*(p + q + S(2))) + (a*f*(p + S(1)) - c*d*(p + S(2)))*(S(2)*a*c*e*h + S(2)*c*g*(-a*f + c*d)), x), x), x) + Simp(-(a + c*x**S(2))**(p + S(1))*(d + e*x + f*x**S(2))**(q + S(1))*(S(2)*a*c**S(2)*e*g - a*h*(-S(2)*a*c*f + S(2)*c**S(2)*d) + c*x*(S(2)*a*c*e*h + g*(-S(2)*a*c*f + S(2)*c**S(2)*d)))/(S(4)*a*c*(p + S(1))*(a*c*e**S(2) + (-a*f + c*d)**S(2))), x) rule602 = ReplacementRule(pattern602, replacement602) pattern603 = Pattern(Integral((d_ + x_**S(2)*WC('f', S(1)))**WC('q', S(1))*(x_*WC('h', S(1)) + WC('g', S(0)))*(a_ + x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons125, cons208, cons209, cons50, cons226, cons13, cons137, cons406, cons405) def replacement603(p, g, b, f, d, c, a, x, h, q): rubi.append(603) return Dist(S(1)/((p + S(1))*(-S(4)*a*c + b**S(2))*(b**S(2)*d*f + (-a*f + c*d)**S(2))), Int((d + f*x**S(2))**q*(a + b*x + c*x**S(2))**(p + S(1))*Simp(-c*f*x**S(2)*(S(2)*p + S(2)*q + S(5))*(b**S(2)*f*g - b*(a*f*h + c*d*h) + S(2)*c*g*(-a*f + c*d)) - x*(-b*f*(p + S(1))*(b**S(2)*f*g - b*(a*f*h + c*d*h) + S(2)*c*g*(-a*f + c*d)) + S(2)*f*(-b*c*g*(a*f + c*d) + (-a*h + b*g)*(-S(2)*a*c*f + b**S(2)*f + S(2)*c**S(2)*d))*(p + q + S(2))) + (p + S(1))*(b*h - S(2)*c*g)*(b**S(2)*d*f + (-a*f + c*d)**S(2)) + (a*f*(p + S(1)) - c*d*(p + S(2)))*(b**S(2)*f*g - b*(a*f*h + c*d*h) + S(2)*c*g*(-a*f + c*d)), x), x), x) + Simp((d + f*x**S(2))**(q + S(1))*(a + b*x + c*x**S(2))**(p + S(1))*(-b*c*g*(a*f + c*d) + c*x*(g*(-S(2)*a*c*f + b**S(2)*f + S(2)*c**S(2)*d) - h*(a*b*f + b*c*d)) + (-a*h + b*g)*(-S(2)*a*c*f + b**S(2)*f + S(2)*c**S(2)*d))/((p + S(1))*(-S(4)*a*c + b**S(2))*(b**S(2)*d*f + (-a*f + c*d)**S(2))), x) rule603 = ReplacementRule(pattern603, replacement603) pattern604 = Pattern(Integral((x_*WC('h', S(1)) + WC('g', S(0)))*(a_ + x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)))**WC('p', S(1))*(d_ + x_**S(2)*WC('f', S(1)) + x_*WC('e', S(1)))**WC('q', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons209, cons50, cons226, cons394, cons13, cons163, cons433) def replacement604(p, g, b, f, d, c, a, x, h, q, e): rubi.append(604) return -Dist(S(1)/(S(2)*f*(p + q + S(1))), Int((a + b*x + c*x**S(2))**(p + S(-1))*(d + e*x + f*x**S(2))**q*Simp(a*(e*h - S(2)*f*g)*(p + q + S(1)) + h*p*(-a*e + b*d) + x**S(2)*(c*(e*h - S(2)*f*g)*(p + q + S(1)) + h*p*(-b*f + c*e)) + x*(b*(e*h - S(2)*f*g)*(p + q + S(1)) + S(2)*h*p*(-a*f + c*d)), x), x), x) + Simp(h*(a + b*x + c*x**S(2))**p*(d + e*x + f*x**S(2))**(q + S(1))/(S(2)*f*(p + q + S(1))), x) rule604 = ReplacementRule(pattern604, replacement604) pattern605 = Pattern(Integral((a_ + x_**S(2)*WC('c', S(1)))**WC('p', S(1))*(x_*WC('h', S(1)) + WC('g', S(0)))*(d_ + x_**S(2)*WC('f', S(1)) + x_*WC('e', S(1)))**WC('q', S(1)), x_), cons2, cons7, cons27, cons48, cons125, cons208, cons209, cons50, cons394, cons13, cons163, cons433) def replacement605(p, g, f, d, c, a, x, h, q, e): rubi.append(605) return Dist(S(1)/(S(2)*f*(p + q + S(1))), Int((a + c*x**S(2))**(p + S(-1))*(d + e*x + f*x**S(2))**q*Simp(a*e*h*p - a*(e*h - S(2)*f*g)*(p + q + S(1)) - S(2)*h*p*x*(-a*f + c*d) - x**S(2)*(c*e*h*p + c*(e*h - S(2)*f*g)*(p + q + S(1))), x), x), x) + Simp(h*(a + c*x**S(2))**p*(d + e*x + f*x**S(2))**(q + S(1))/(S(2)*f*(p + q + S(1))), x) rule605 = ReplacementRule(pattern605, replacement605) pattern606 = Pattern(Integral((d_ + x_**S(2)*WC('f', S(1)))**WC('q', S(1))*(x_*WC('h', S(1)) + WC('g', S(0)))*(a_ + x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons125, cons208, cons209, cons50, cons226, cons13, cons163, cons433) def replacement606(p, g, b, f, d, c, a, x, h, q): rubi.append(606) return -Dist(S(1)/(S(2)*f*(p + q + S(1))), Int((d + f*x**S(2))**q*(a + b*x + c*x**S(2))**(p + S(-1))*Simp(-S(2)*a*f*g*(p + q + S(1)) + b*d*h*p + x**S(2)*(-b*f*h*p - S(2)*c*f*g*(p + q + S(1))) + x*(-S(2)*b*f*g*(p + q + S(1)) + S(2)*h*p*(-a*f + c*d)), x), x), x) + Simp(h*(d + f*x**S(2))**(q + S(1))*(a + b*x + c*x**S(2))**p/(S(2)*f*(p + q + S(1))), x) rule606 = ReplacementRule(pattern606, replacement606) def With607(g, b, f, d, c, a, x, h, e): if isinstance(x, (int, Integer, float, Float)): return False q = a**S(2)*f**S(2) - a*b*e*f - S(2)*a*c*d*f + a*c*e**S(2) + b**S(2)*d*f - b*c*d*e + c**S(2)*d**S(2) if NonzeroQ(q): return True return False pattern607 = Pattern(Integral((x_*WC('h', S(1)) + WC('g', S(0)))/((a_ + x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)))*(d_ + x_**S(2)*WC('f', S(1)) + x_*WC('e', S(1)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons209, cons226, cons394, CustomConstraint(With607)) def replacement607(g, b, f, d, c, a, x, h, e): q = a**S(2)*f**S(2) - a*b*e*f - S(2)*a*c*d*f + a*c*e**S(2) + b**S(2)*d*f - b*c*d*e + c**S(2)*d**S(2) rubi.append(607) return Dist(S(1)/q, Int(Simp(-a*b*f*h + a*c*e*h - a*c*f*g + b**S(2)*f*g - b*c*e*g + c**S(2)*d*g + c*x*(-a*f*h + b*f*g + c*d*h - c*e*g), x)/(a + b*x + c*x**S(2)), x), x) + Dist(S(1)/q, Int(Simp(a*f**S(2)*g + b*d*f*h - b*e*f*g - c*d*e*h - c*d*f*g + c*e**S(2)*g - f*x*(-a*f*h + b*f*g + c*d*h - c*e*g), x)/(d + e*x + f*x**S(2)), x), x) rule607 = ReplacementRule(pattern607, replacement607) def With608(g, b, f, d, c, a, x, h): if isinstance(x, (int, Integer, float, Float)): return False q = a**S(2)*f**S(2) - S(2)*a*c*d*f + b**S(2)*d*f + c**S(2)*d**S(2) if NonzeroQ(q): return True return False pattern608 = Pattern(Integral((x_*WC('h', S(1)) + WC('g', S(0)))/((d_ + x_**S(2)*WC('f', S(1)))*(a_ + x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)))), x_), cons2, cons3, cons7, cons27, cons125, cons208, cons209, cons226, CustomConstraint(With608)) def replacement608(g, b, f, d, c, a, x, h): q = a**S(2)*f**S(2) - S(2)*a*c*d*f + b**S(2)*d*f + c**S(2)*d**S(2) rubi.append(608) return Dist(S(1)/q, Int(Simp(a*f**S(2)*g + b*d*f*h - c*d*f*g - f*x*(-a*f*h + b*f*g + c*d*h), x)/(d + f*x**S(2)), x), x) + Dist(S(1)/q, Int(Simp(-a*b*f*h - a*c*f*g + b**S(2)*f*g + c**S(2)*d*g + c*x*(-a*f*h + b*f*g + c*d*h), x)/(a + b*x + c*x**S(2)), x), x) rule608 = ReplacementRule(pattern608, replacement608) pattern609 = Pattern(Integral((g_ + x_*WC('h', S(1)))/((a_ + x_**S(2)*WC('c', S(1)))*sqrt(d_ + x_**S(2)*WC('f', S(1)))), x_), cons2, cons7, cons27, cons125, cons208, cons209, cons434) def replacement609(f, g, d, c, a, x, h): rubi.append(609) return Dist(g, Int(S(1)/((a + c*x**S(2))*sqrt(d + f*x**S(2))), x), x) + Dist(h, Int(x/((a + c*x**S(2))*sqrt(d + f*x**S(2))), x), x) rule609 = ReplacementRule(pattern609, replacement609) def With610(f, g, d, c, a, x, h): q = Rt(-a*c, S(2)) rubi.append(610) return -Dist((c*g - h*q)/(S(2)*q), Int(S(1)/(sqrt(d + f*x**S(2))*(c*x + q)), x), x) - Dist((c*g + h*q)/(S(2)*q), Int(S(1)/(sqrt(d + f*x**S(2))*(-c*x + q)), x), x) pattern610 = Pattern(Integral((g_ + x_*WC('h', S(1)))/((a_ + x_**S(2)*WC('c', S(1)))*sqrt(d_ + x_**S(2)*WC('f', S(1)))), x_), cons2, cons7, cons27, cons125, cons208, cons209, cons435) rule610 = ReplacementRule(pattern610, With610) pattern611 = Pattern(Integral((g_ + x_*WC('h', S(1)))/((a_ + x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)))*sqrt(x_**S(2)*WC('f', S(1)) + x_*WC('e', S(1)) + WC('d', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons209, cons226, cons394, cons410, cons436) def replacement611(f, b, g, d, c, a, x, h, e): rubi.append(611) return Dist(-S(2)*g, Subst(Int(S(1)/(-a*e + b*d - b*x**S(2)), x), x, sqrt(d + e*x + f*x**S(2))), x) rule611 = ReplacementRule(pattern611, replacement611) pattern612 = Pattern(Integral((x_*WC('h', S(1)) + WC('g', S(0)))/((a_ + x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)))*sqrt(x_**S(2)*WC('f', S(1)) + x_*WC('e', S(1)) + WC('d', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons209, cons226, cons394, cons410, cons437) def replacement612(g, b, f, d, c, a, x, h, e): rubi.append(612) return Dist(h/(S(2)*f), Int((e + S(2)*f*x)/((a + b*x + c*x**S(2))*sqrt(d + e*x + f*x**S(2))), x), x) - Dist((e*h - S(2)*f*g)/(S(2)*f), Int(S(1)/((a + b*x + c*x**S(2))*sqrt(d + e*x + f*x**S(2))), x), x) rule612 = ReplacementRule(pattern612, replacement612) pattern613 = Pattern(Integral(x_/((a_ + x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)))*sqrt(d_ + x_**S(2)*WC('f', S(1)) + x_*WC('e', S(1)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons226, cons394, cons383) def replacement613(f, b, d, c, a, x, e): rubi.append(613) return Dist(-S(2)*e, Subst(Int((-d*x**S(2) + S(1))/(-b*f + c*e + d**S(2)*x**S(4)*(-b*f + c*e) - e*x**S(2)*(S(2)*a*f - b*e + S(2)*c*d)), x), x, (S(1) + x*(e + sqrt(-S(4)*d*f + e**S(2)))/(S(2)*d))/sqrt(d + e*x + f*x**S(2))), x) rule613 = ReplacementRule(pattern613, replacement613) pattern614 = Pattern(Integral((g_ + x_*WC('h', S(1)))/((a_ + x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)))*sqrt(d_ + x_**S(2)*WC('f', S(1)) + x_*WC('e', S(1)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons209, cons226, cons394, cons383, cons438) def replacement614(f, b, g, d, c, a, x, h, e): rubi.append(614) return Dist(g, Subst(Int(S(1)/(a + x**S(2)*(-a*f + c*d)), x), x, x/sqrt(d + e*x + f*x**S(2))), x) rule614 = ReplacementRule(pattern614, replacement614) pattern615 = Pattern(Integral((g_ + x_*WC('h', S(1)))/((a_ + x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)))*sqrt(d_ + x_**S(2)*WC('f', S(1)) + x_*WC('e', S(1)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons209, cons226, cons394, cons383, cons439) def replacement615(f, b, g, d, c, a, x, h, e): rubi.append(615) return Dist(h/e, Int((S(2)*d + e*x)/((a + b*x + c*x**S(2))*sqrt(d + e*x + f*x**S(2))), x), x) - Dist((S(2)*d*h - e*g)/e, Int(S(1)/((a + b*x + c*x**S(2))*sqrt(d + e*x + f*x**S(2))), x), x) rule615 = ReplacementRule(pattern615, replacement615) pattern616 = Pattern(Integral((x_*WC('h', S(1)) + WC('g', S(0)))/((x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0)))*sqrt(x_**S(2)*WC('f', S(1)) + x_*WC('e', S(1)) + WC('d', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons209, cons226, cons394, cons372, cons440) def replacement616(g, b, f, d, a, c, x, h, e): rubi.append(616) return Dist(-S(2)*g*(-S(2)*a*h + b*g), Subst(Int(S(1)/Simp(g*(-S(4)*a*c + b**S(2))*(-S(2)*a*h + b*g) - x**S(2)*(-a*e + b*d), x), x), x, Simp(-S(2)*a*h + b*g - x*(b*h - S(2)*c*g), x)/sqrt(d + e*x + f*x**S(2))), x) rule616 = ReplacementRule(pattern616, replacement616) pattern617 = Pattern(Integral((g_ + x_*WC('h', S(1)))/((a_ + x_**S(2)*WC('c', S(1)))*sqrt(x_**S(2)*WC('f', S(1)) + x_*WC('e', S(1)) + WC('d', S(0)))), x_), cons2, cons7, cons27, cons48, cons125, cons208, cons209, cons441) def replacement617(f, g, d, c, a, x, h, e): rubi.append(617) return Dist(-S(2)*a*g*h, Subst(Int(S(1)/Simp(S(2)*a**S(2)*c*g*h + a*e*x**S(2), x), x), x, Simp(a*h - c*g*x, x)/sqrt(d + e*x + f*x**S(2))), x) rule617 = ReplacementRule(pattern617, replacement617) pattern618 = Pattern(Integral((g_ + x_*WC('h', S(1)))/(sqrt(d_ + x_**S(2)*WC('f', S(1)))*(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0)))), x_), cons2, cons3, cons7, cons27, cons125, cons208, cons209, cons226, cons442) def replacement618(f, b, g, d, c, a, x, h): rubi.append(618) return Dist(-S(2)*g*(-S(2)*a*h + b*g), Subst(Int(S(1)/Simp(-b*d*x**S(2) + g*(-S(4)*a*c + b**S(2))*(-S(2)*a*h + b*g), x), x), x, Simp(-S(2)*a*h + b*g - x*(b*h - S(2)*c*g), x)/sqrt(d + f*x**S(2))), x) rule618 = ReplacementRule(pattern618, replacement618) def With619(g, b, f, d, c, a, x, h, e): q = Rt(-S(4)*a*c + b**S(2), S(2)) rubi.append(619) return Dist((S(2)*c*g - h*(b - q))/q, Int(S(1)/((b + S(2)*c*x - q)*sqrt(d + e*x + f*x**S(2))), x), x) - Dist((S(2)*c*g - h*(b + q))/q, Int(S(1)/((b + S(2)*c*x + q)*sqrt(d + e*x + f*x**S(2))), x), x) pattern619 = Pattern(Integral((x_*WC('h', S(1)) + WC('g', S(0)))/((a_ + x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)))*sqrt(x_**S(2)*WC('f', S(1)) + x_*WC('e', S(1)) + WC('d', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons209, cons226, cons394, cons231) rule619 = ReplacementRule(pattern619, With619) def With620(g, f, d, c, a, x, h, e): q = Rt(-a*c, S(2)) rubi.append(620) return Dist(-c*g/(S(2)*q) + h/S(2), Int(S(1)/((c*x + q)*sqrt(d + e*x + f*x**S(2))), x), x) + Dist(c*g/(S(2)*q) + h/S(2), Int(S(1)/((c*x - q)*sqrt(d + e*x + f*x**S(2))), x), x) pattern620 = Pattern(Integral((x_*WC('h', S(1)) + WC('g', S(0)))/((a_ + x_**S(2)*WC('c', S(1)))*sqrt(x_**S(2)*WC('f', S(1)) + x_*WC('e', S(1)) + WC('d', S(0)))), x_), cons2, cons7, cons27, cons48, cons125, cons208, cons209, cons394, cons412) rule620 = ReplacementRule(pattern620, With620) def With621(g, b, f, d, c, a, x, h): q = Rt(-S(4)*a*c + b**S(2), S(2)) rubi.append(621) return Dist((S(2)*c*g - h*(b - q))/q, Int(S(1)/(sqrt(d + f*x**S(2))*(b + S(2)*c*x - q)), x), x) - Dist((S(2)*c*g - h*(b + q))/q, Int(S(1)/(sqrt(d + f*x**S(2))*(b + S(2)*c*x + q)), x), x) pattern621 = Pattern(Integral((x_*WC('h', S(1)) + WC('g', S(0)))/(sqrt(d_ + x_**S(2)*WC('f', S(1)))*(a_ + x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)))), x_), cons2, cons3, cons7, cons27, cons125, cons208, cons209, cons226, cons231) rule621 = ReplacementRule(pattern621, With621) def With622(g, b, f, d, a, c, x, h, e): q = Rt(-(-a*e + b*d)*(-b*f + c*e) + (-a*f + c*d)**S(2), S(2)) rubi.append(622) return Dist(S(1)/(S(2)*q), Int(Simp(-g*(-a*f + c*d - q) + h*(-a*e + b*d) - x*(g*(-b*f + c*e) - h*(-a*f + c*d + q)), x)/((a + b*x + c*x**S(2))*sqrt(d + e*x + f*x**S(2))), x), x) - Dist(S(1)/(S(2)*q), Int(Simp(-g*(-a*f + c*d + q) + h*(-a*e + b*d) - x*(g*(-b*f + c*e) - h*(-a*f + c*d - q)), x)/((a + b*x + c*x**S(2))*sqrt(d + e*x + f*x**S(2))), x), x) pattern622 = Pattern(Integral((x_*WC('h', S(1)) + WC('g', S(0)))/((x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0)))*sqrt(x_**S(2)*WC('f', S(1)) + x_*WC('e', S(1)) + WC('d', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons209, cons226, cons394, cons372, cons413) rule622 = ReplacementRule(pattern622, With622) def With623(g, f, d, c, a, x, h, e): q = Rt(a*c*e**S(2) + (-a*f + c*d)**S(2), S(2)) rubi.append(623) return Dist(S(1)/(S(2)*q), Int(Simp(-a*e*h - g*(-a*f + c*d - q) + x*(-c*e*g + h*(-a*f + c*d + q)), x)/((a + c*x**S(2))*sqrt(d + e*x + f*x**S(2))), x), x) - Dist(S(1)/(S(2)*q), Int(Simp(-a*e*h - g*(-a*f + c*d + q) + x*(-c*e*g + h*(-a*f + c*d - q)), x)/((a + c*x**S(2))*sqrt(d + e*x + f*x**S(2))), x), x) pattern623 = Pattern(Integral((x_*WC('h', S(1)) + WC('g', S(0)))/((a_ + x_**S(2)*WC('c', S(1)))*sqrt(x_**S(2)*WC('f', S(1)) + x_*WC('e', S(1)) + WC('d', S(0)))), x_), cons2, cons7, cons27, cons48, cons125, cons208, cons209, cons394, cons414) rule623 = ReplacementRule(pattern623, With623) def With624(g, b, f, d, a, c, x, h): q = Rt(b**S(2)*d*f + (-a*f + c*d)**S(2), S(2)) rubi.append(624) return Dist(S(1)/(S(2)*q), Int(Simp(b*d*h - g*(-a*f + c*d - q) + x*(b*f*g + h*(-a*f + c*d + q)), x)/(sqrt(d + f*x**S(2))*(a + b*x + c*x**S(2))), x), x) - Dist(S(1)/(S(2)*q), Int(Simp(b*d*h - g*(-a*f + c*d + q) + x*(b*f*g + h*(-a*f + c*d - q)), x)/(sqrt(d + f*x**S(2))*(a + b*x + c*x**S(2))), x), x) pattern624 = Pattern(Integral((x_*WC('h', S(1)) + WC('g', S(0)))/(sqrt(d_ + x_**S(2)*WC('f', S(1)))*(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0)))), x_), cons2, cons3, cons7, cons27, cons125, cons208, cons209, cons226, cons413) rule624 = ReplacementRule(pattern624, With624) def With625(g, b, f, d, c, a, x, h, e): s = Rt(-S(4)*a*c + b**S(2), S(2)) t = Rt(-S(4)*d*f + e**S(2), S(2)) rubi.append(625) return Dist(sqrt(S(2)*a + x*(b + s))*sqrt(S(2)*d + x*(e + t))*sqrt(b + S(2)*c*x + s)*sqrt(e + S(2)*f*x + t)/(sqrt(a + b*x + c*x**S(2))*sqrt(d + e*x + f*x**S(2))), Int((g + h*x)/(sqrt(S(2)*a + x*(b + s))*sqrt(S(2)*d + x*(e + t))*sqrt(b + S(2)*c*x + s)*sqrt(e + S(2)*f*x + t)), x), x) pattern625 = Pattern(Integral((x_*WC('h', S(1)) + WC('g', S(0)))/(sqrt(a_ + x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)))*sqrt(d_ + x_**S(2)*WC('f', S(1)) + x_*WC('e', S(1)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons209, cons226, cons394) rule625 = ReplacementRule(pattern625, With625) def With626(g, b, f, d, c, a, x, h): s = Rt(-S(4)*a*c + b**S(2), S(2)) t = Rt(-S(4)*d*f, S(2)) rubi.append(626) return Dist(sqrt(S(2)*a + x*(b + s))*sqrt(S(2)*d + t*x)*sqrt(S(2)*f*x + t)*sqrt(b + S(2)*c*x + s)/(sqrt(d + f*x**S(2))*sqrt(a + b*x + c*x**S(2))), Int((g + h*x)/(sqrt(S(2)*a + x*(b + s))*sqrt(S(2)*d + t*x)*sqrt(S(2)*f*x + t)*sqrt(b + S(2)*c*x + s)), x), x) pattern626 = Pattern(Integral((x_*WC('h', S(1)) + WC('g', S(0)))/(sqrt(d_ + x_**S(2)*WC('f', S(1)))*sqrt(a_ + x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)))), x_), cons2, cons3, cons7, cons27, cons125, cons208, cons209, cons226) rule626 = ReplacementRule(pattern626, With626) def With627(g, b, f, d, a, c, x, h, e): q = S(3)**(S(2)/3)*(-c*h**S(2)/(-b*h + S(2)*c*g)**S(2))**(S(1)/3) rubi.append(627) return -Simp(S(3)*h*q*log((-S(3)*h*(b + S(2)*c*x)/(-b*h + S(2)*c*g) + S(1))**(S(2)/3) + S(2)**(S(1)/3)*(S(3)*h*(b + S(2)*c*x)/(-b*h + S(2)*c*g) + S(1))**(S(1)/3))/(S(2)*f), x) + Simp(h*q*log(d + e*x + f*x**S(2))/(S(2)*f), x) + Simp(sqrt(S(3))*h*q*ArcTan(-S(2)**(S(2)/3)*sqrt(S(3))*(-S(3)*h*(b + S(2)*c*x)/(-b*h + S(2)*c*g) + S(1))**(S(2)/3)/(S(3)*(S(3)*h*(b + S(2)*c*x)/(-b*h + S(2)*c*g) + S(1))**(S(1)/3)) + sqrt(S(3))/S(3))/f, x) pattern627 = Pattern(Integral((x_*WC('h', S(1)) + WC('g', S(0)))/((x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0)))**(S(1)/3)*(x_**S(2)*WC('f', S(1)) + x_*WC('e', S(1)) + WC('d', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons209, cons410, cons443, cons444, cons445) rule627 = ReplacementRule(pattern627, With627) pattern628 = Pattern(Integral((g_ + x_*WC('h', S(1)))/((a_ + x_**S(2)*WC('c', S(1)))**(S(1)/3)*(d_ + x_**S(2)*WC('f', S(1)))), x_), cons2, cons7, cons27, cons125, cons208, cons209, cons446, cons447, cons43) def replacement628(f, g, d, c, a, x, h): rubi.append(628) return Simp(S(2)**(S(1)/3)*h*log(d + f*x**S(2))/(S(4)*a**(S(1)/3)*f), x) - Simp(S(3)*S(2)**(S(1)/3)*h*log((S(1) - S(3)*h*x/g)**(S(2)/3) + S(2)**(S(1)/3)*(S(1) + S(3)*h*x/g)**(S(1)/3))/(S(4)*a**(S(1)/3)*f), x) + Simp(S(2)**(S(1)/3)*sqrt(S(3))*h*ArcTan(-S(2)**(S(2)/3)*sqrt(S(3))*(S(1) - S(3)*h*x/g)**(S(2)/3)/(S(3)*(S(1) + S(3)*h*x/g)**(S(1)/3)) + sqrt(S(3))/S(3))/(S(2)*a**(S(1)/3)*f), x) rule628 = ReplacementRule(pattern628, replacement628) def With629(g, b, f, d, a, c, x, h, e): q = -c/(-S(4)*a*c + b**S(2)) rubi.append(629) return Dist((q*(a + b*x + c*x**S(2)))**(S(1)/3)/(a + b*x + c*x**S(2))**(S(1)/3), Int((g + h*x)/((d + e*x + f*x**S(2))*(a*q + b*q*x + c*q*x**S(2))**(S(1)/3)), x), x) pattern629 = Pattern(Integral((x_*WC('h', S(1)) + WC('g', S(0)))/((x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0)))**(S(1)/3)*(x_**S(2)*WC('f', S(1)) + x_*WC('e', S(1)) + WC('d', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons209, cons410, cons443, cons444, cons313) rule629 = ReplacementRule(pattern629, With629) pattern630 = Pattern(Integral((g_ + x_*WC('h', S(1)))/((a_ + x_**S(2)*WC('c', S(1)))**(S(1)/3)*(d_ + x_**S(2)*WC('f', S(1)))), x_), cons2, cons7, cons27, cons125, cons208, cons209, cons446, cons447, cons448) def replacement630(f, g, d, c, a, x, h): rubi.append(630) return Dist((S(1) + c*x**S(2)/a)**(S(1)/3)/(a + c*x**S(2))**(S(1)/3), Int((g + h*x)/((S(1) + c*x**S(2)/a)**(S(1)/3)*(d + f*x**S(2))), x), x) rule630 = ReplacementRule(pattern630, replacement630) pattern631 = Pattern(Integral((x_*WC('h', S(1)) + WC('g', S(0)))*(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0)))**p_*(x_**S(2)*WC('f', S(1)) + x_*WC('e', S(1)) + WC('d', S(0)))**q_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons209, cons5, cons50, cons449) def replacement631(p, g, b, f, d, a, c, x, h, q, e): rubi.append(631) return Int((g + h*x)*(a + b*x + c*x**S(2))**p*(d + e*x + f*x**S(2))**q, x) rule631 = ReplacementRule(pattern631, replacement631) pattern632 = Pattern(Integral((x_*WC('h', S(1)) + WC('g', S(0)))*(x_**S(2)*WC('c', S(1)) + WC('a', S(0)))**p_*(x_**S(2)*WC('f', S(1)) + x_*WC('e', S(1)) + WC('d', S(0)))**q_, x_), cons2, cons7, cons27, cons48, cons125, cons208, cons209, cons5, cons50, cons450) def replacement632(p, g, f, d, a, c, x, h, q, e): rubi.append(632) return Int((a + c*x**S(2))**p*(g + h*x)*(d + e*x + f*x**S(2))**q, x) rule632 = ReplacementRule(pattern632, replacement632) pattern633 = Pattern(Integral((u_*WC('h', S(1)) + WC('g', S(0)))**WC('m', S(1))*(u_**S(2)*WC('c', S(1)) + u_*WC('b', S(1)) + WC('a', S(0)))**WC('p', S(1))*(u_**S(2)*WC('f', S(1)) + u_*WC('e', S(1)) + WC('d', S(0)))**WC('q', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons209, cons21, cons5, cons50, cons68, cons69) def replacement633(p, u, m, g, b, f, d, a, c, x, h, q, e): rubi.append(633) return Dist(S(1)/Coefficient(u, x, S(1)), Subst(Int((g + h*x)**m*(a + b*x + c*x**S(2))**p*(d + e*x + f*x**S(2))**q, x), x, u), x) rule633 = ReplacementRule(pattern633, replacement633) pattern634 = Pattern(Integral((u_*WC('h', S(1)) + WC('g', S(0)))**WC('m', S(1))*(u_**S(2)*WC('c', S(1)) + WC('a', S(0)))**WC('p', S(1))*(u_**S(2)*WC('f', S(1)) + u_*WC('e', S(1)) + WC('d', S(0)))**WC('q', S(1)), x_), cons2, cons7, cons27, cons48, cons125, cons208, cons209, cons21, cons5, cons50, cons68, cons69) def replacement634(p, u, m, g, f, d, c, a, x, h, q, e): rubi.append(634) return Dist(S(1)/Coefficient(u, x, S(1)), Subst(Int((a + c*x**S(2))**p*(g + h*x)**m*(d + e*x + f*x**S(2))**q, x), x, u), x) rule634 = ReplacementRule(pattern634, replacement634) pattern635 = Pattern(Integral(u_**WC('p', S(1))*v_**WC('q', S(1))*z_**WC('m', S(1)), x_), cons21, cons5, cons50, cons451, cons452, cons453) def replacement635(v, z, p, u, m, x, q): rubi.append(635) return Int(ExpandToSum(u, x)**p*ExpandToSum(v, x)**q*ExpandToSum(z, x)**m, x) rule635 = ReplacementRule(pattern635, replacement635) pattern636 = Pattern(Integral((d_ + x_*WC('e', S(1)))**WC('m', S(1))*(f_ + x_*WC('g', S(1)))**WC('n', S(1))*(x_*WC('i', S(1)) + WC('h', S(0)))**WC('q', S(1))*(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons209, cons224, cons21, cons4, cons5, cons50, cons336, cons124, cons377) def replacement636(p, m, g, b, f, i, d, a, n, c, x, h, q, e): rubi.append(636) return Int((h + i*x)**q*(d*f + e*g*x**S(2))**m*(a + b*x + c*x**S(2))**p, x) rule636 = ReplacementRule(pattern636, replacement636) pattern637 = Pattern(Integral((x_*WC('e', S(1)) + WC('d', S(0)))**WC('m', S(1))*(x_*WC('g', S(1)) + WC('f', S(0)))**WC('n', S(1))*(x_*WC('i', S(1)) + WC('h', S(0)))**WC('q', S(1))*(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons209, cons224, cons21, cons4, cons5, cons50, cons128, cons84) def replacement637(p, m, f, g, b, i, d, a, n, c, x, h, q, e): rubi.append(637) return Int(ExpandIntegrand((d + e*x)**m*(f + g*x)**n*(h + i*x)**q*(a + b*x + c*x**S(2))**p, x), x) rule637 = ReplacementRule(pattern637, replacement637) pattern638 = Pattern(Integral((d_ + x_*WC('e', S(1)))**m_*(f_ + x_*WC('g', S(1)))**n_*(x_*WC('i', S(1)) + WC('h', S(0)))**WC('q', S(1))*(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons209, cons224, cons21, cons4, cons5, cons50, cons336, cons124) def replacement638(p, m, g, b, f, i, d, a, c, n, x, h, q, e): rubi.append(638) return Dist((d + e*x)**FracPart(m)*(f + g*x)**FracPart(m)*(d*f + e*g*x**S(2))**(-FracPart(m)), Int((h + i*x)**q*(d*f + e*g*x**S(2))**m*(a + b*x + c*x**S(2))**p, x), x) rule638 = ReplacementRule(pattern638, replacement638) pattern639 = Pattern(Integral((a_ + x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)))**WC('p', S(1))*(d_ + x_**S(2)*WC('f', S(1)) + x_*WC('e', S(1)))**WC('q', S(1))*(x_**S(2)*WC('C', S(1)) + x_*WC('B', S(1)) + WC('A', S(0))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons36, cons5, cons50, cons382, cons383, cons384, cons385) def replacement639(B, p, C, e, f, b, d, c, a, x, q, A): rubi.append(639) return Dist((c/f)**p, Int((A + B*x + C*x**S(2))*(d + e*x + f*x**S(2))**(p + q), x), x) rule639 = ReplacementRule(pattern639, replacement639) pattern640 = Pattern(Integral((x_**S(2)*WC('C', S(1)) + WC('A', S(0)))*(a_ + x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)))**WC('p', S(1))*(d_ + x_**S(2)*WC('f', S(1)) + x_*WC('e', S(1)))**WC('q', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons36, cons5, cons50, cons382, cons383, cons384, cons385) def replacement640(C, p, e, f, b, d, c, a, x, q, A): rubi.append(640) return Dist((c/f)**p, Int((A + C*x**S(2))*(d + e*x + f*x**S(2))**(p + q), x), x) rule640 = ReplacementRule(pattern640, replacement640) pattern641 = Pattern(Integral((a_ + x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)))**WC('p', S(1))*(d_ + x_**S(2)*WC('f', S(1)) + x_*WC('e', S(1)))**WC('q', S(1))*(x_**S(2)*WC('C', S(1)) + x_*WC('B', S(1)) + WC('A', S(0))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons36, cons5, cons50, cons382, cons383, cons147, cons386, cons387) def replacement641(B, p, C, e, f, b, d, c, a, x, q, A): rubi.append(641) return Dist(a**IntPart(p)*d**(-IntPart(p))*(a + b*x + c*x**S(2))**FracPart(p)*(d + e*x + f*x**S(2))**(-FracPart(p)), Int((A + B*x + C*x**S(2))*(d + e*x + f*x**S(2))**(p + q), x), x) rule641 = ReplacementRule(pattern641, replacement641) pattern642 = Pattern(Integral((x_**S(2)*WC('C', S(1)) + WC('A', S(0)))*(a_ + x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)))**WC('p', S(1))*(d_ + x_**S(2)*WC('f', S(1)) + x_*WC('e', S(1)))**WC('q', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons36, cons5, cons50, cons382, cons383, cons147, cons386, cons387) def replacement642(C, p, e, f, b, d, c, a, x, q, A): rubi.append(642) return Dist(a**IntPart(p)*d**(-IntPart(p))*(a + b*x + c*x**S(2))**FracPart(p)*(d + e*x + f*x**S(2))**(-FracPart(p)), Int((A + C*x**S(2))*(d + e*x + f*x**S(2))**(p + q), x), x) rule642 = ReplacementRule(pattern642, replacement642) pattern643 = Pattern(Integral((a_ + x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)))**WC('p', S(1))*(x_**S(2)*WC('C', S(1)) + x_*WC('B', S(1)) + WC('A', S(0)))*(x_**S(2)*WC('f', S(1)) + x_*WC('e', S(1)) + WC('d', S(0)))**WC('q', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons36, cons5, cons50, cons45) def replacement643(B, p, C, e, f, b, d, c, a, x, q, A): rubi.append(643) return Dist((S(4)*c)**(-IntPart(p))*(b + S(2)*c*x)**(-S(2)*FracPart(p))*(a + b*x + c*x**S(2))**FracPart(p), Int((b + S(2)*c*x)**(S(2)*p)*(A + B*x + C*x**S(2))*(d + e*x + f*x**S(2))**q, x), x) rule643 = ReplacementRule(pattern643, replacement643) pattern644 = Pattern(Integral((x_**S(2)*WC('C', S(1)) + WC('A', S(0)))*(a_ + x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)))**WC('p', S(1))*(x_**S(2)*WC('f', S(1)) + x_*WC('e', S(1)) + WC('d', S(0)))**WC('q', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons36, cons5, cons50, cons45) def replacement644(C, p, e, f, b, d, c, a, x, q, A): rubi.append(644) return Dist((S(4)*c)**(-IntPart(p))*(b + S(2)*c*x)**(-S(2)*FracPart(p))*(a + b*x + c*x**S(2))**FracPart(p), Int((A + C*x**S(2))*(b + S(2)*c*x)**(S(2)*p)*(d + e*x + f*x**S(2))**q, x), x) rule644 = ReplacementRule(pattern644, replacement644) pattern645 = Pattern(Integral((x_**S(2)*WC('f', S(1)) + WC('d', S(0)))**WC('q', S(1))*(a_ + x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)))**WC('p', S(1))*(x_**S(2)*WC('C', S(1)) + x_*WC('B', S(1)) + WC('A', S(0))), x_), cons2, cons3, cons7, cons27, cons125, cons34, cons35, cons36, cons5, cons50, cons45) def replacement645(B, p, C, f, b, d, c, a, x, q, A): rubi.append(645) return Dist((S(4)*c)**(-IntPart(p))*(b + S(2)*c*x)**(-S(2)*FracPart(p))*(a + b*x + c*x**S(2))**FracPart(p), Int((b + S(2)*c*x)**(S(2)*p)*(d + f*x**S(2))**q*(A + B*x + C*x**S(2)), x), x) rule645 = ReplacementRule(pattern645, replacement645) pattern646 = Pattern(Integral((x_**S(2)*WC('C', S(1)) + WC('A', S(0)))*(x_**S(2)*WC('f', S(1)) + WC('d', S(0)))**WC('q', S(1))*(a_ + x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons125, cons34, cons36, cons5, cons50, cons45) def replacement646(C, p, f, b, d, c, a, x, q, A): rubi.append(646) return Dist((S(4)*c)**(-IntPart(p))*(b + S(2)*c*x)**(-S(2)*FracPart(p))*(a + b*x + c*x**S(2))**FracPart(p), Int((A + C*x**S(2))*(b + S(2)*c*x)**(S(2)*p)*(d + f*x**S(2))**q, x), x) rule646 = ReplacementRule(pattern646, replacement646) pattern647 = Pattern(Integral((a_ + x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)))**WC('p', S(1))*(d_ + x_**S(2)*WC('f', S(1)) + x_*WC('e', S(1)))**WC('q', S(1))*(x_**S(2)*WC('C', S(1)) + x_*WC('B', S(1)) + WC('A', S(0))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons36, cons226, cons394, cons220, cons163) def replacement647(B, p, C, e, f, b, d, c, a, x, q, A): rubi.append(647) return Int(ExpandIntegrand((A + B*x + C*x**S(2))*(a + b*x + c*x**S(2))**p*(d + e*x + f*x**S(2))**q, x), x) rule647 = ReplacementRule(pattern647, replacement647) pattern648 = Pattern(Integral((x_**S(2)*WC('C', S(1)) + WC('A', S(0)))*(a_ + x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)))**WC('p', S(1))*(d_ + x_**S(2)*WC('f', S(1)) + x_*WC('e', S(1)))**WC('q', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons36, cons226, cons394, cons220, cons163) def replacement648(C, p, e, f, b, d, c, a, x, q, A): rubi.append(648) return Int(ExpandIntegrand((A + C*x**S(2))*(a + b*x + c*x**S(2))**p*(d + e*x + f*x**S(2))**q, x), x) rule648 = ReplacementRule(pattern648, replacement648) pattern649 = Pattern(Integral((a_ + x_**S(2)*WC('c', S(1)))**WC('p', S(1))*(d_ + x_**S(2)*WC('f', S(1)) + x_*WC('e', S(1)))**WC('q', S(1))*(x_**S(2)*WC('C', S(1)) + x_*WC('B', S(1)) + WC('A', S(0))), x_), cons2, cons7, cons27, cons48, cons125, cons34, cons35, cons36, cons394, cons220, cons432) def replacement649(B, C, p, e, f, d, c, a, x, q, A): rubi.append(649) return Int(ExpandIntegrand((a + c*x**S(2))**p*(A + B*x + C*x**S(2))*(d + e*x + f*x**S(2))**q, x), x) rule649 = ReplacementRule(pattern649, replacement649) pattern650 = Pattern(Integral((a_ + x_**S(2)*WC('c', S(1)))**WC('p', S(1))*(x_**S(2)*WC('C', S(1)) + WC('A', S(0)))*(d_ + x_**S(2)*WC('f', S(1)) + x_*WC('e', S(1)))**WC('q', S(1)), x_), cons2, cons7, cons27, cons48, cons125, cons34, cons36, cons394, cons220, cons432) def replacement650(C, p, f, d, c, a, A, x, q, e): rubi.append(650) return Int(ExpandIntegrand((A + C*x**S(2))*(a + c*x**S(2))**p*(d + e*x + f*x**S(2))**q, x), x) rule650 = ReplacementRule(pattern650, replacement650) pattern651 = Pattern(Integral((a_ + x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)))**WC('p', S(1))*(d_ + x_**S(2)*WC('f', S(1)) + x_*WC('e', S(1)))**WC('q', S(1))*(x_**S(2)*WC('C', S(1)) + x_*WC('B', S(1)) + WC('A', S(0))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons36, cons226, cons394, cons402, cons137, cons403) def replacement651(B, p, C, e, f, b, d, c, a, x, q, A): rubi.append(651) return -Dist(S(1)/(c*(p + S(1))*(-S(4)*a*c + b**S(2))), Int((a + b*x + c*x**S(2))**(p + S(1))*(d + e*x + f*x**S(2))**(q + S(-1))*Simp(-d*(C*(S(2)*a*c - b**S(2)*(p + S(2))) + c*(S(2)*p + S(3))*(-S(2)*A*c + B*b)) + e*q*(A*b*c - S(2)*B*a*c + C*a*b) - f*x**S(2)*(C*(S(2)*a*c*(S(2)*q + S(1)) - b**S(2)*(p + S(2)*q + S(2))) + c*(-S(2)*A*c + B*b)*(S(2)*p + S(2)*q + S(3))) + x*(-e*(C*(S(2)*a*c*(q + S(1)) - b**S(2)*(p + q + S(2))) + c*(-S(2)*A*c + B*b)*(S(2)*p + q + S(3))) + S(2)*f*q*(A*b*c - S(2)*B*a*c + C*a*b)), x), x), x) + Simp((a + b*x + c*x**S(2))**(p + S(1))*(d + e*x + f*x**S(2))**q*(A*b*c - S(2)*B*a*c + C*a*b - x*(-C*(-S(2)*a*c + b**S(2)) + c*(-S(2)*A*c + B*b)))/(c*(p + S(1))*(-S(4)*a*c + b**S(2))), x) rule651 = ReplacementRule(pattern651, replacement651) pattern652 = Pattern(Integral((x_**S(2)*WC('C', S(1)) + WC('A', S(0)))*(a_ + x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)))**WC('p', S(1))*(d_ + x_**S(2)*WC('f', S(1)) + x_*WC('e', S(1)))**WC('q', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons36, cons226, cons394, cons402, cons137, cons403) def replacement652(C, p, e, f, b, d, c, a, x, q, A): rubi.append(652) return -Dist(S(1)/(c*(p + S(1))*(-S(4)*a*c + b**S(2))), Int((a + b*x + c*x**S(2))**(p + S(1))*(d + e*x + f*x**S(2))**(q + S(-1))*Simp(A*c*(b*e*q + S(2)*c*d*(S(2)*p + S(3))) - C*(-a*b*e*q + S(2)*a*c*d - b**S(2)*d*(p + S(2))) - f*x**S(2)*(-S(2)*A*c**S(2)*(S(2)*p + S(2)*q + S(3)) + C*(S(2)*a*c*(S(2)*q + S(1)) - b**S(2)*(p + S(2)*q + S(2)))) + x*(S(2)*A*c*(b*f*q + c*e*(S(2)*p + q + S(3))) + C*(S(2)*a*b*f*q - S(2)*a*c*e*(q + S(1)) + b**S(2)*e*(p + q + S(2)))), x), x), x) + Simp((a + b*x + c*x**S(2))**(p + S(1))*(d + e*x + f*x**S(2))**q*(A*b*c + C*a*b + x*(S(2)*A*c**S(2) + C*(-S(2)*a*c + b**S(2))))/(c*(p + S(1))*(-S(4)*a*c + b**S(2))), x) rule652 = ReplacementRule(pattern652, replacement652) pattern653 = Pattern(Integral((a_ + x_**S(2)*WC('c', S(1)))**WC('p', S(1))*(d_ + x_**S(2)*WC('f', S(1)) + x_*WC('e', S(1)))**WC('q', S(1))*(x_**S(2)*WC('C', S(1)) + x_*WC('B', S(1)) + WC('A', S(0))), x_), cons2, cons7, cons27, cons48, cons125, cons34, cons35, cons36, cons394, cons402, cons137, cons403) def replacement653(B, C, p, e, f, d, c, a, x, q, A): rubi.append(653) return -Dist(-S(1)/(S(2)*a*c*(p + S(1))), Int((a + c*x**S(2))**(p + S(1))*(d + e*x + f*x**S(2))**(q + S(-1))*Simp(A*c*d*(S(2)*p + S(3)) - a*(B*e*q + C*d) - f*x**S(2)*(-A*c*(S(2)*p + S(2)*q + S(3)) + C*a*(S(2)*q + S(1))) + x*(A*c*e*(S(2)*p + q + S(3)) - a*(S(2)*B*f*q + C*e*(q + S(1)))), x), x), x) + Simp((a + c*x**S(2))**(p + S(1))*(B*a - x*(A*c - C*a))*(d + e*x + f*x**S(2))**q/(S(2)*a*c*(p + S(1))), x) rule653 = ReplacementRule(pattern653, replacement653) pattern654 = Pattern(Integral((a_ + x_**S(2)*WC('c', S(1)))**WC('p', S(1))*(x_**S(2)*WC('C', S(1)) + WC('A', S(0)))*(d_ + x_**S(2)*WC('f', S(1)) + x_*WC('e', S(1)))**WC('q', S(1)), x_), cons2, cons7, cons27, cons48, cons125, cons34, cons36, cons394, cons402, cons137, cons403) def replacement654(C, p, f, d, c, a, A, x, q, e): rubi.append(654) return Dist(S(1)/(S(2)*a*c*(p + S(1))), Int((a + c*x**S(2))**(p + S(1))*(d + e*x + f*x**S(2))**(q + S(-1))*Simp(A*c*d*(S(2)*p + S(3)) - C*a*d - f*x**S(2)*(-A*c*(S(2)*p + S(2)*q + S(3)) + C*a*(S(2)*q + S(1))) + x*(A*c*e*(S(2)*p + q + S(3)) - C*a*e*(q + S(1))), x), x), x) - Simp(x*(a + c*x**S(2))**(p + S(1))*(A*c - C*a)*(d + e*x + f*x**S(2))**q/(S(2)*a*c*(p + S(1))), x) rule654 = ReplacementRule(pattern654, replacement654) pattern655 = Pattern(Integral((d_ + x_**S(2)*WC('f', S(1)))**WC('q', S(1))*(a_ + x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)))**WC('p', S(1))*(x_**S(2)*WC('C', S(1)) + x_*WC('B', S(1)) + WC('A', S(0))), x_), cons2, cons3, cons7, cons27, cons125, cons34, cons35, cons36, cons226, cons402, cons137, cons403) def replacement655(B, p, C, f, b, d, c, a, x, q, A): rubi.append(655) return -Dist(S(1)/(c*(p + S(1))*(-S(4)*a*c + b**S(2))), Int((d + f*x**S(2))**(q + S(-1))*(a + b*x + c*x**S(2))**(p + S(1))*Simp(-d*(C*(S(2)*a*c - b**S(2)*(p + S(2))) + c*(S(2)*p + S(3))*(-S(2)*A*c + B*b)) + S(2)*f*q*x*(A*b*c - S(2)*B*a*c + C*a*b) - f*x**S(2)*(C*(S(2)*a*c*(S(2)*q + S(1)) - b**S(2)*(p + S(2)*q + S(2))) + c*(-S(2)*A*c + B*b)*(S(2)*p + S(2)*q + S(3))), x), x), x) + Simp((d + f*x**S(2))**q*(a + b*x + c*x**S(2))**(p + S(1))*(A*b*c - S(2)*B*a*c + C*a*b - x*(-C*(-S(2)*a*c + b**S(2)) + c*(-S(2)*A*c + B*b)))/(c*(p + S(1))*(-S(4)*a*c + b**S(2))), x) rule655 = ReplacementRule(pattern655, replacement655) pattern656 = Pattern(Integral((d_ + x_**S(2)*WC('f', S(1)))**WC('q', S(1))*(x_**S(2)*WC('C', S(1)) + WC('A', S(0)))*(a_ + x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons125, cons34, cons36, cons226, cons402, cons137, cons403) def replacement656(C, p, f, b, d, c, a, x, q, A): rubi.append(656) return -Dist(S(1)/(c*(p + S(1))*(-S(4)*a*c + b**S(2))), Int((d + f*x**S(2))**(q + S(-1))*(a + b*x + c*x**S(2))**(p + S(1))*Simp(S(2)*A*c**S(2)*d*(S(2)*p + S(3)) - C*(S(2)*a*c*d - b**S(2)*d*(p + S(2))) - f*x**S(2)*(-S(2)*A*c**S(2)*(S(2)*p + S(2)*q + S(3)) + C*(S(2)*a*c*(S(2)*q + S(1)) - b**S(2)*(p + S(2)*q + S(2)))) + x*(S(2)*A*b*c*f*q + S(2)*C*a*b*f*q), x), x), x) + Simp((d + f*x**S(2))**q*(a + b*x + c*x**S(2))**(p + S(1))*(A*b*c + C*a*b + x*(S(2)*A*c**S(2) + C*(-S(2)*a*c + b**S(2))))/(c*(p + S(1))*(-S(4)*a*c + b**S(2))), x) rule656 = ReplacementRule(pattern656, replacement656) pattern657 = Pattern(Integral((a_ + x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)))**WC('p', S(1))*(d_ + x_**S(2)*WC('f', S(1)) + x_*WC('e', S(1)))**WC('q', S(1))*(x_**S(2)*WC('C', S(1)) + x_*WC('B', S(1)) + WC('A', S(0))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons36, cons50, cons226, cons394, cons13, cons137, cons404, cons405) def replacement657(B, p, C, e, f, b, d, c, a, x, q, A): rubi.append(657) return Dist(S(1)/((p + S(1))*(-S(4)*a*c + b**S(2))*(-(-a*e + b*d)*(-b*f + c*e) + (-a*f + c*d)**S(2))), Int((a + b*x + c*x**S(2))**(p + S(1))*(d + e*x + f*x**S(2))**q*Simp(-c*f*x**S(2)*(S(2)*p + S(2)*q + S(5))*(S(2)*A*c*(-a*f + c*d) - S(2)*a*(-B*c*e - C*a*f + C*c*d) + b**S(2)*(A*f + C*d) - b*(A*c*e + B*a*f + B*c*d + C*a*e)) - e*((A*b - B*a)*(b**S(2)*f + S(2)*c**S(2)*d - c*(S(2)*a*f + b*e)) + (A*c - C*a)*(S(2)*a*c*e - b*(a*f + c*d)))*(p + q + S(2)) - x*(S(2)*f*((A*b - B*a)*(b**S(2)*f + S(2)*c**S(2)*d - c*(S(2)*a*f + b*e)) + (A*c - C*a)*(S(2)*a*c*e - b*(a*f + c*d)))*(p + q + S(2)) - (b*f*(p + S(1)) - c*e*(S(2)*p + q + S(4)))*(S(2)*A*c*(-a*f + c*d) - S(2)*a*(-B*c*e - C*a*f + C*c*d) + b**S(2)*(A*f + C*d) - b*(A*c*e + B*a*f + B*c*d + C*a*e))) + (p + S(1))*(-(-a*e + b*d)*(-b*f + c*e) + (-a*f + c*d)**S(2))*(-S(2)*A*c + B*b - S(2)*C*a) + (a*f*(p + S(1)) - c*d*(p + S(2)))*(S(2)*A*c*(-a*f + c*d) - S(2)*a*(-B*c*e - C*a*f + C*c*d) + b**S(2)*(A*f + C*d) - b*(A*c*e + B*a*f + B*c*d + C*a*e)), x), x), x) + Simp((a + b*x + c*x**S(2))**(p + S(1))*(d + e*x + f*x**S(2))**(q + S(1))*(c*x*(A*(b**S(2)*f + S(2)*c**S(2)*d - c*(S(2)*a*f + b*e)) - B*(a*b*f - S(2)*a*c*e + b*c*d) + C*(-a*b*e - S(2)*a*(-a*f + c*d) + b**S(2)*d)) + (A*b - B*a)*(b**S(2)*f + S(2)*c**S(2)*d - c*(S(2)*a*f + b*e)) + (A*c - C*a)*(S(2)*a*c*e - b*(a*f + c*d)))/((p + S(1))*(-S(4)*a*c + b**S(2))*(-(-a*e + b*d)*(-b*f + c*e) + (-a*f + c*d)**S(2))), x) rule657 = ReplacementRule(pattern657, replacement657) pattern658 = Pattern(Integral((x_**S(2)*WC('C', S(1)) + WC('A', S(0)))*(a_ + x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)))**WC('p', S(1))*(d_ + x_**S(2)*WC('f', S(1)) + x_*WC('e', S(1)))**WC('q', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons36, cons50, cons226, cons394, cons13, cons137, cons404, cons405) def replacement658(C, p, e, f, b, d, c, a, x, q, A): rubi.append(658) return Dist(S(1)/((p + S(1))*(-S(4)*a*c + b**S(2))*(-(-a*e + b*d)*(-b*f + c*e) + (-a*f + c*d)**S(2))), Int((a + b*x + c*x**S(2))**(p + S(1))*(d + e*x + f*x**S(2))**q*Simp(-c*f*x**S(2)*(S(2)*p + S(2)*q + S(5))*(S(2)*A*c*(-a*f + c*d) - S(2)*a*(-C*a*f + C*c*d) + b**S(2)*(A*f + C*d) - b*(A*c*e + C*a*e)) - e*(A*b*(b**S(2)*f + S(2)*c**S(2)*d - c*(S(2)*a*f + b*e)) + (A*c - C*a)*(S(2)*a*c*e - b*(a*f + c*d)))*(p + q + S(2)) - x*(S(2)*f*(A*b*(b**S(2)*f + S(2)*c**S(2)*d - c*(S(2)*a*f + b*e)) + (A*c - C*a)*(S(2)*a*c*e - b*(a*f + c*d)))*(p + q + S(2)) - (b*f*(p + S(1)) - c*e*(S(2)*p + q + S(4)))*(S(2)*A*c*(-a*f + c*d) - S(2)*a*(-C*a*f + C*c*d) + b**S(2)*(A*f + C*d) - b*(A*c*e + C*a*e))) + (p + S(1))*(-S(2)*A*c - S(2)*C*a)*(-(-a*e + b*d)*(-b*f + c*e) + (-a*f + c*d)**S(2)) + (a*f*(p + S(1)) - c*d*(p + S(2)))*(S(2)*A*c*(-a*f + c*d) - S(2)*a*(-C*a*f + C*c*d) + b**S(2)*(A*f + C*d) - b*(A*c*e + C*a*e)), x), x), x) + Simp((a + b*x + c*x**S(2))**(p + S(1))*(d + e*x + f*x**S(2))**(q + S(1))*(A*b*(b**S(2)*f + S(2)*c**S(2)*d - c*(S(2)*a*f + b*e)) + c*x*(A*(b**S(2)*f + S(2)*c**S(2)*d - c*(S(2)*a*f + b*e)) + C*(-a*b*e - S(2)*a*(-a*f + c*d) + b**S(2)*d)) + (A*c - C*a)*(S(2)*a*c*e - b*(a*f + c*d)))/((p + S(1))*(-S(4)*a*c + b**S(2))*(-(-a*e + b*d)*(-b*f + c*e) + (-a*f + c*d)**S(2))), x) rule658 = ReplacementRule(pattern658, replacement658) pattern659 = Pattern(Integral((a_ + x_**S(2)*WC('c', S(1)))**WC('p', S(1))*(d_ + x_**S(2)*WC('f', S(1)) + x_*WC('e', S(1)))**WC('q', S(1))*(x_**S(2)*WC('C', S(1)) + x_*WC('B', S(1)) + WC('A', S(0))), x_), cons2, cons7, cons27, cons48, cons125, cons34, cons35, cons36, cons50, cons394, cons13, cons137, cons407, cons405) def replacement659(B, C, p, e, f, d, c, a, x, q, A): rubi.append(659) return Dist(-S(1)/(S(4)*a*c*(p + S(1))*(a*c*e**S(2) + (-a*f + c*d)**S(2))), Int((a + c*x**S(2))**(p + S(1))*(d + e*x + f*x**S(2))**q*Simp(-c*f*x**S(2)*(S(2)*A*c*(-a*f + c*d) - S(2)*a*(-B*c*e - C*a*f + C*c*d))*(S(2)*p + S(2)*q + S(5)) - e*(-B*a*(-S(2)*a*c*f + S(2)*c**S(2)*d) + S(2)*a*c*e*(A*c - C*a))*(p + q + S(2)) - x*(c*e*(S(2)*A*c*(-a*f + c*d) - S(2)*a*(-B*c*e - C*a*f + C*c*d))*(S(2)*p + q + S(4)) + S(2)*f*(-B*a*(-S(2)*a*c*f + S(2)*c**S(2)*d) + S(2)*a*c*e*(A*c - C*a))*(p + q + S(2))) + (p + S(1))*(-S(2)*A*c - S(2)*C*a)*(a*c*e**S(2) + (-a*f + c*d)**S(2)) + (S(2)*A*c*(-a*f + c*d) - S(2)*a*(-B*c*e - C*a*f + C*c*d))*(a*f*(p + S(1)) - c*d*(p + S(2))), x), x), x) + Simp(-(a + c*x**S(2))**(p + S(1))*(d + e*x + f*x**S(2))**(q + S(1))*(-B*a*(-S(2)*a*c*f + S(2)*c**S(2)*d) + S(2)*a*c*e*(A*c - C*a) + c*x*(A*(-S(2)*a*c*f + S(2)*c**S(2)*d) + S(2)*B*a*c*e - S(2)*C*a*(-a*f + c*d)))/(S(4)*a*c*(p + S(1))*(a*c*e**S(2) + (-a*f + c*d)**S(2))), x) rule659 = ReplacementRule(pattern659, replacement659) pattern660 = Pattern(Integral((a_ + x_**S(2)*WC('c', S(1)))**WC('p', S(1))*(x_**S(2)*WC('C', S(1)) + WC('A', S(0)))*(d_ + x_**S(2)*WC('f', S(1)) + x_*WC('e', S(1)))**WC('q', S(1)), x_), cons2, cons7, cons27, cons48, cons125, cons34, cons36, cons50, cons394, cons13, cons137, cons407, cons405) def replacement660(C, p, f, d, c, a, A, x, q, e): rubi.append(660) return Dist(-S(1)/(S(4)*a*c*(p + S(1))*(a*c*e**S(2) + (-a*f + c*d)**S(2))), Int((a + c*x**S(2))**(p + S(1))*(d + e*x + f*x**S(2))**q*Simp(-S(2)*a*c*e**S(2)*(A*c - C*a)*(p + q + S(2)) - c*f*x**S(2)*(S(2)*A*c*(-a*f + c*d) - S(2)*a*(-C*a*f + C*c*d))*(S(2)*p + S(2)*q + S(5)) - x*(S(4)*a*c*e*f*(A*c - C*a)*(p + q + S(2)) + c*e*(S(2)*A*c*(-a*f + c*d) - S(2)*a*(-C*a*f + C*c*d))*(S(2)*p + q + S(4))) + (p + S(1))*(-S(2)*A*c - S(2)*C*a)*(a*c*e**S(2) + (-a*f + c*d)**S(2)) + (S(2)*A*c*(-a*f + c*d) - S(2)*a*(-C*a*f + C*c*d))*(a*f*(p + S(1)) - c*d*(p + S(2))), x), x), x) + Simp(-(a + c*x**S(2))**(p + S(1))*(S(2)*a*c*e*(A*c - C*a) + c*x*(A*(-S(2)*a*c*f + S(2)*c**S(2)*d) - S(2)*C*a*(-a*f + c*d)))*(d + e*x + f*x**S(2))**(q + S(1))/(S(4)*a*c*(p + S(1))*(a*c*e**S(2) + (-a*f + c*d)**S(2))), x) rule660 = ReplacementRule(pattern660, replacement660) pattern661 = Pattern(Integral((d_ + x_**S(2)*WC('f', S(1)))**WC('q', S(1))*(a_ + x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)))**WC('p', S(1))*(x_**S(2)*WC('C', S(1)) + x_*WC('B', S(1)) + WC('A', S(0))), x_), cons2, cons3, cons7, cons27, cons125, cons34, cons35, cons36, cons50, cons226, cons13, cons137, cons406, cons405) def replacement661(B, p, C, f, b, d, c, a, x, q, A): rubi.append(661) return Dist(S(1)/((p + S(1))*(-S(4)*a*c + b**S(2))*(b**S(2)*d*f + (-a*f + c*d)**S(2))), Int((d + f*x**S(2))**q*(a + b*x + c*x**S(2))**(p + S(1))*Simp(-c*f*x**S(2)*(S(2)*p + S(2)*q + S(5))*(S(2)*A*c*(-a*f + c*d) - S(2)*a*(-C*a*f + C*c*d) + b**S(2)*(A*f + C*d) - b*(B*a*f + B*c*d)) - x*(-b*f*(p + S(1))*(S(2)*A*c*(-a*f + c*d) - S(2)*a*(-C*a*f + C*c*d) + b**S(2)*(A*f + C*d) - b*(B*a*f + B*c*d)) + S(2)*f*(-b*(A*c - C*a)*(a*f + c*d) + (A*b - B*a)*(-S(2)*a*c*f + b**S(2)*f + S(2)*c**S(2)*d))*(p + q + S(2))) + (p + S(1))*(b**S(2)*d*f + (-a*f + c*d)**S(2))*(-S(2)*A*c + B*b - S(2)*C*a) + (a*f*(p + S(1)) - c*d*(p + S(2)))*(S(2)*A*c*(-a*f + c*d) - S(2)*a*(-C*a*f + C*c*d) + b**S(2)*(A*f + C*d) - b*(B*a*f + B*c*d)), x), x), x) + Simp((d + f*x**S(2))**(q + S(1))*(a + b*x + c*x**S(2))**(p + S(1))*(-b*(A*c - C*a)*(a*f + c*d) + c*x*(A*(-S(2)*a*c*f + b**S(2)*f + S(2)*c**S(2)*d) - B*(a*b*f + b*c*d) + C*(-S(2)*a*(-a*f + c*d) + b**S(2)*d)) + (A*b - B*a)*(-S(2)*a*c*f + b**S(2)*f + S(2)*c**S(2)*d))/((p + S(1))*(-S(4)*a*c + b**S(2))*(b**S(2)*d*f + (-a*f + c*d)**S(2))), x) rule661 = ReplacementRule(pattern661, replacement661) pattern662 = Pattern(Integral((d_ + x_**S(2)*WC('f', S(1)))**WC('q', S(1))*(x_**S(2)*WC('C', S(1)) + WC('A', S(0)))*(a_ + x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons125, cons34, cons36, cons50, cons226, cons13, cons137, cons406, cons405) def replacement662(C, p, f, b, d, c, a, x, q, A): rubi.append(662) return Dist(S(1)/((p + S(1))*(-S(4)*a*c + b**S(2))*(b**S(2)*d*f + (-a*f + c*d)**S(2))), Int((d + f*x**S(2))**q*(a + b*x + c*x**S(2))**(p + S(1))*Simp(-c*f*x**S(2)*(S(2)*p + S(2)*q + S(5))*(S(2)*A*c*(-a*f + c*d) - S(2)*a*(-C*a*f + C*c*d) + b**S(2)*(A*f + C*d)) - x*(-b*f*(p + S(1))*(S(2)*A*c*(-a*f + c*d) - S(2)*a*(-C*a*f + C*c*d) + b**S(2)*(A*f + C*d)) + S(2)*f*(A*b*(-S(2)*a*c*f + b**S(2)*f + S(2)*c**S(2)*d) - b*(A*c - C*a)*(a*f + c*d))*(p + q + S(2))) + (p + S(1))*(-S(2)*A*c - S(2)*C*a)*(b**S(2)*d*f + (-a*f + c*d)**S(2)) + (a*f*(p + S(1)) - c*d*(p + S(2)))*(S(2)*A*c*(-a*f + c*d) - S(2)*a*(-C*a*f + C*c*d) + b**S(2)*(A*f + C*d)), x), x), x) + Simp((d + f*x**S(2))**(q + S(1))*(a + b*x + c*x**S(2))**(p + S(1))*(A*b*(-S(2)*a*c*f + b**S(2)*f + S(2)*c**S(2)*d) - b*(A*c - C*a)*(a*f + c*d) + c*x*(A*(-S(2)*a*c*f + b**S(2)*f + S(2)*c**S(2)*d) + C*(-S(2)*a*(-a*f + c*d) + b**S(2)*d)))/((p + S(1))*(-S(4)*a*c + b**S(2))*(b**S(2)*d*f + (-a*f + c*d)**S(2))), x) rule662 = ReplacementRule(pattern662, replacement662) pattern663 = Pattern(Integral((a_ + x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)))**WC('p', S(1))*(d_ + x_**S(2)*WC('f', S(1)) + x_*WC('e', S(1)))**WC('q', S(1))*(x_**S(2)*WC('C', S(1)) + x_*WC('B', S(1)) + WC('A', S(0))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons36, cons50, cons226, cons394, cons13, cons163, cons433, cons454) def replacement663(B, p, C, e, f, b, d, c, a, x, q, A): rubi.append(663) return -Dist(S(1)/(S(2)*c*f**S(2)*(p + q + S(1))*(S(2)*p + S(2)*q + S(3))), Int((a + b*x + c*x**S(2))**(p + S(-1))*(d + e*x + f*x**S(2))**q*Simp(p*(-a*e + b*d)*(C*(q + S(1))*(-b*f + c*e) - c*(-B*f + C*e)*(S(2)*p + S(2)*q + S(3))) + x**S(2)*(p*(-b*f + c*e)*(C*(q + S(1))*(-b*f + c*e) - c*(-B*f + C*e)*(S(2)*p + S(2)*q + S(3))) + (C*f**S(2)*p*(-S(4)*a*c + b**S(2)) - c**S(2)*(C*(-S(4)*d*f + e**S(2))*(S(2)*p + q + S(2)) + f*(S(2)*p + S(2)*q + S(3))*(S(2)*A*f - B*e + S(2)*C*d)))*(p + q + S(1))) + x*(S(2)*p*(-a*f + c*d)*(C*(q + S(1))*(-b*f + c*e) - c*(-B*f + C*e)*(S(2)*p + S(2)*q + S(3))) + (C*e*f*p*(-S(4)*a*c + b**S(2)) - b*c*(C*(-S(4)*d*f + e**S(2))*(S(2)*p + q + S(2)) + f*(S(2)*p + S(2)*q + S(3))*(S(2)*A*f - B*e + S(2)*C*d)))*(p + q + S(1))) + (C*b**S(2)*d*f*p + a*c*(C*(S(2)*d*f - e**S(2)*(S(2)*p + q + S(2))) + f*(-S(2)*A*f + B*e)*(S(2)*p + S(2)*q + S(3))))*(p + q + S(1)), x), x), x) + Simp((a + b*x + c*x**S(2))**p*(d + e*x + f*x**S(2))**(q + S(1))*(B*c*f*(S(2)*p + S(2)*q + S(3)) + S(2)*C*c*f*x*(p + q + S(1)) + C*(b*f*p - c*e*(S(2)*p + q + S(2))))/(S(2)*c*f**S(2)*(p + q + S(1))*(S(2)*p + S(2)*q + S(3))), x) rule663 = ReplacementRule(pattern663, replacement663) pattern664 = Pattern(Integral((x_**S(2)*WC('C', S(1)) + WC('A', S(0)))*(a_ + x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)))**WC('p', S(1))*(d_ + x_**S(2)*WC('f', S(1)) + x_*WC('e', S(1)))**WC('q', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons36, cons50, cons226, cons394, cons13, cons163, cons433, cons454) def replacement664(C, p, e, f, b, d, c, a, x, q, A): rubi.append(664) return -Dist(S(1)/(S(2)*c*f**S(2)*(p + q + S(1))*(S(2)*p + S(2)*q + S(3))), Int((a + b*x + c*x**S(2))**(p + S(-1))*(d + e*x + f*x**S(2))**q*Simp(p*(-a*e + b*d)*(-C*c*e*(S(2)*p + S(2)*q + S(3)) + C*(q + S(1))*(-b*f + c*e)) + x**S(2)*(p*(-b*f + c*e)*(-C*c*e*(S(2)*p + S(2)*q + S(3)) + C*(q + S(1))*(-b*f + c*e)) + (C*f**S(2)*p*(-S(4)*a*c + b**S(2)) - c**S(2)*(C*(-S(4)*d*f + e**S(2))*(S(2)*p + q + S(2)) + f*(S(2)*A*f + S(2)*C*d)*(S(2)*p + S(2)*q + S(3))))*(p + q + S(1))) + x*(S(2)*p*(-a*f + c*d)*(-C*c*e*(S(2)*p + S(2)*q + S(3)) + C*(q + S(1))*(-b*f + c*e)) + (C*e*f*p*(-S(4)*a*c + b**S(2)) - b*c*(C*(-S(4)*d*f + e**S(2))*(S(2)*p + q + S(2)) + f*(S(2)*A*f + S(2)*C*d)*(S(2)*p + S(2)*q + S(3))))*(p + q + S(1))) + (C*b**S(2)*d*f*p + a*c*(-S(2)*A*f**S(2)*(S(2)*p + S(2)*q + S(3)) + C*(S(2)*d*f - e**S(2)*(S(2)*p + q + S(2)))))*(p + q + S(1)), x), x), x) + Simp((S(2)*C*c*f*x*(p + q + S(1)) + C*(b*f*p - c*e*(S(2)*p + q + S(2))))*(a + b*x + c*x**S(2))**p*(d + e*x + f*x**S(2))**(q + S(1))/(S(2)*c*f**S(2)*(p + q + S(1))*(S(2)*p + S(2)*q + S(3))), x) rule664 = ReplacementRule(pattern664, replacement664) pattern665 = Pattern(Integral((a_ + x_**S(2)*WC('c', S(1)))**WC('p', S(1))*(d_ + x_**S(2)*WC('f', S(1)) + x_*WC('e', S(1)))**WC('q', S(1))*(x_**S(2)*WC('C', S(1)) + x_*WC('B', S(1)) + WC('A', S(0))), x_), cons2, cons7, cons27, cons48, cons125, cons34, cons35, cons36, cons50, cons394, cons13, cons163, cons433, cons454) def replacement665(B, C, p, e, f, d, c, a, x, q, A): rubi.append(665) return -Dist(S(1)/(S(2)*c*f**S(2)*(p + q + S(1))*(S(2)*p + S(2)*q + S(3))), Int((a + c*x**S(2))**(p + S(-1))*(d + e*x + f*x**S(2))**q*Simp(a*c*(C*(S(2)*d*f - e**S(2)*(S(2)*p + q + S(2))) + f*(-S(2)*A*f + B*e)*(S(2)*p + S(2)*q + S(3)))*(p + q + S(1)) - a*e*p*(C*c*e*(q + S(1)) - c*(-B*f + C*e)*(S(2)*p + S(2)*q + S(3))) + x**S(2)*(c*e*p*(C*c*e*(q + S(1)) - c*(-B*f + C*e)*(S(2)*p + S(2)*q + S(3))) + (-S(4)*C*a*c*f**S(2)*p - c**S(2)*(C*(-S(4)*d*f + e**S(2))*(S(2)*p + q + S(2)) + f*(S(2)*p + S(2)*q + S(3))*(S(2)*A*f - B*e + S(2)*C*d)))*(p + q + S(1))) + x*(-S(4)*C*a*c*e*f*p*(p + q + S(1)) + S(2)*p*(-a*f + c*d)*(C*c*e*(q + S(1)) - c*(-B*f + C*e)*(S(2)*p + S(2)*q + S(3)))), x), x), x) + Simp((a + c*x**S(2))**p*(d + e*x + f*x**S(2))**(q + S(1))*(B*c*f*(S(2)*p + S(2)*q + S(3)) - C*c*e*(S(2)*p + q + S(2)) + S(2)*C*c*f*x*(p + q + S(1)))/(S(2)*c*f**S(2)*(p + q + S(1))*(S(2)*p + S(2)*q + S(3))), x) rule665 = ReplacementRule(pattern665, replacement665) pattern666 = Pattern(Integral((a_ + x_**S(2)*WC('c', S(1)))**WC('p', S(1))*(x_**S(2)*WC('C', S(1)) + WC('A', S(0)))*(d_ + x_**S(2)*WC('f', S(1)) + x_*WC('e', S(1)))**WC('q', S(1)), x_), cons2, cons7, cons27, cons48, cons125, cons34, cons36, cons50, cons394, cons13, cons163, cons433, cons454) def replacement666(C, p, f, d, c, a, A, x, q, e): rubi.append(666) return -Dist(S(1)/(S(2)*c*f**S(2)*(p + q + S(1))*(S(2)*p + S(2)*q + S(3))), Int((a + c*x**S(2))**(p + S(-1))*(d + e*x + f*x**S(2))**q*Simp(a*c*(-S(2)*A*f**S(2)*(S(2)*p + S(2)*q + S(3)) + C*(S(2)*d*f - e**S(2)*(S(2)*p + q + S(2))))*(p + q + S(1)) - a*e*p*(C*c*e*(q + S(1)) - C*c*e*(S(2)*p + S(2)*q + S(3))) + x**S(2)*(c*e*p*(C*c*e*(q + S(1)) - C*c*e*(S(2)*p + S(2)*q + S(3))) + (-S(4)*C*a*c*f**S(2)*p - c**S(2)*(C*(-S(4)*d*f + e**S(2))*(S(2)*p + q + S(2)) + f*(S(2)*A*f + S(2)*C*d)*(S(2)*p + S(2)*q + S(3))))*(p + q + S(1))) + x*(-S(4)*C*a*c*e*f*p*(p + q + S(1)) + S(2)*p*(-a*f + c*d)*(C*c*e*(q + S(1)) - C*c*e*(S(2)*p + S(2)*q + S(3)))), x), x), x) + Simp((a + c*x**S(2))**p*(-C*c*e*(S(2)*p + q + S(2)) + S(2)*C*c*f*x*(p + q + S(1)))*(d + e*x + f*x**S(2))**(q + S(1))/(S(2)*c*f**S(2)*(p + q + S(1))*(S(2)*p + S(2)*q + S(3))), x) rule666 = ReplacementRule(pattern666, replacement666) pattern667 = Pattern(Integral((d_ + x_**S(2)*WC('f', S(1)))**WC('q', S(1))*(a_ + x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)))**WC('p', S(1))*(x_**S(2)*WC('C', S(1)) + x_*WC('B', S(1)) + WC('A', S(0))), x_), cons2, cons3, cons7, cons27, cons125, cons34, cons35, cons36, cons50, cons226, cons13, cons163, cons433, cons454) def replacement667(B, p, C, f, b, d, c, a, x, q, A): rubi.append(667) return -Dist(S(1)/(S(2)*c*f**S(2)*(p + q + S(1))*(S(2)*p + S(2)*q + S(3))), Int((d + f*x**S(2))**q*(a + b*x + c*x**S(2))**(p + S(-1))*Simp(b*d*p*(B*c*f*(S(2)*p + S(2)*q + S(3)) - C*b*f*(q + S(1))) + x**S(2)*(-b*f*p*(B*c*f*(S(2)*p + S(2)*q + S(3)) - C*b*f*(q + S(1))) + (C*f**S(2)*p*(-S(4)*a*c + b**S(2)) - c**S(2)*(-S(4)*C*d*f*(S(2)*p + q + S(2)) + f*(S(2)*A*f + S(2)*C*d)*(S(2)*p + S(2)*q + S(3))))*(p + q + S(1))) + x*(-b*c*(-S(4)*C*d*f*(S(2)*p + q + S(2)) + f*(S(2)*A*f + S(2)*C*d)*(S(2)*p + S(2)*q + S(3)))*(p + q + S(1)) + S(2)*p*(-a*f + c*d)*(B*c*f*(S(2)*p + S(2)*q + S(3)) - C*b*f*(q + S(1)))) + (C*b**S(2)*d*f*p + a*c*(-S(2)*A*f**S(2)*(S(2)*p + S(2)*q + S(3)) + S(2)*C*d*f))*(p + q + S(1)), x), x), x) + Simp((d + f*x**S(2))**(q + S(1))*(a + b*x + c*x**S(2))**p*(B*c*f*(S(2)*p + S(2)*q + S(3)) + C*b*f*p + S(2)*C*c*f*x*(p + q + S(1)))/(S(2)*c*f**S(2)*(p + q + S(1))*(S(2)*p + S(2)*q + S(3))), x) rule667 = ReplacementRule(pattern667, replacement667) pattern668 = Pattern(Integral((d_ + x_**S(2)*WC('f', S(1)))**WC('q', S(1))*(x_**S(2)*WC('C', S(1)) + WC('A', S(0)))*(a_ + x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons125, cons34, cons36, cons50, cons226, cons13, cons163, cons433, cons454) def replacement668(C, p, f, b, d, c, a, x, q, A): rubi.append(668) return -Dist(S(1)/(S(2)*c*f**S(2)*(p + q + S(1))*(S(2)*p + S(2)*q + S(3))), Int((d + f*x**S(2))**q*(a + b*x + c*x**S(2))**(p + S(-1))*Simp(-C*b**S(2)*d*f*p*(q + S(1)) + x**S(2)*(C*b**S(2)*f**S(2)*p*(q + S(1)) + (C*f**S(2)*p*(-S(4)*a*c + b**S(2)) - c**S(2)*(-S(4)*C*d*f*(S(2)*p + q + S(2)) + f*(S(2)*A*f + S(2)*C*d)*(S(2)*p + S(2)*q + S(3))))*(p + q + S(1))) + x*(-S(2)*C*b*f*p*(q + S(1))*(-a*f + c*d) - b*c*(-S(4)*C*d*f*(S(2)*p + q + S(2)) + f*(S(2)*A*f + S(2)*C*d)*(S(2)*p + S(2)*q + S(3)))*(p + q + S(1))) + (C*b**S(2)*d*f*p + a*c*(-S(2)*A*f**S(2)*(S(2)*p + S(2)*q + S(3)) + S(2)*C*d*f))*(p + q + S(1)), x), x), x) + Simp((d + f*x**S(2))**(q + S(1))*(C*b*f*p + S(2)*C*c*f*x*(p + q + S(1)))*(a + b*x + c*x**S(2))**p/(S(2)*c*f**S(2)*(p + q + S(1))*(S(2)*p + S(2)*q + S(3))), x) rule668 = ReplacementRule(pattern668, replacement668) def With669(B, C, e, f, b, d, c, a, x, A): if isinstance(x, (int, Integer, float, Float)): return False q = a**S(2)*f**S(2) - a*b*e*f - S(2)*a*c*d*f + a*c*e**S(2) + b**S(2)*d*f - b*c*d*e + c**S(2)*d**S(2) if NonzeroQ(q): return True return False pattern669 = Pattern(Integral((x_**S(2)*WC('C', S(1)) + x_*WC('B', S(1)) + WC('A', S(0)))/((a_ + x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)))*(d_ + x_**S(2)*WC('f', S(1)) + x_*WC('e', S(1)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons36, cons226, cons394, CustomConstraint(With669)) def replacement669(B, C, e, f, b, d, c, a, x, A): q = a**S(2)*f**S(2) - a*b*e*f - S(2)*a*c*d*f + a*c*e**S(2) + b**S(2)*d*f - b*c*d*e + c**S(2)*d**S(2) rubi.append(669) return Dist(S(1)/q, Int((-A*a*c*f + A*b**S(2)*f - A*b*c*e + A*c**S(2)*d - B*a*b*f + B*a*c*e + C*a**S(2)*f - C*a*c*d + c*x*(A*b*f - A*c*e - B*a*f + B*c*d + C*a*e - C*b*d))/(a + b*x + c*x**S(2)), x), x) + Dist(S(1)/q, Int((A*a*f**S(2) - A*b*e*f - A*c*d*f + A*c*e**S(2) + B*b*d*f - B*c*d*e - C*a*d*f + C*c*d**S(2) - f*x*(A*b*f - A*c*e - B*a*f + B*c*d + C*a*e - C*b*d))/(d + e*x + f*x**S(2)), x), x) rule669 = ReplacementRule(pattern669, replacement669) def With670(C, f, b, d, c, a, A, x, e): if isinstance(x, (int, Integer, float, Float)): return False q = a**S(2)*f**S(2) - a*b*e*f - S(2)*a*c*d*f + a*c*e**S(2) + b**S(2)*d*f - b*c*d*e + c**S(2)*d**S(2) if NonzeroQ(q): return True return False pattern670 = Pattern(Integral((x_**S(2)*WC('C', S(1)) + WC('A', S(0)))/((a_ + x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)))*(d_ + x_**S(2)*WC('f', S(1)) + x_*WC('e', S(1)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons36, cons226, cons394, CustomConstraint(With670)) def replacement670(C, f, b, d, c, a, A, x, e): q = a**S(2)*f**S(2) - a*b*e*f - S(2)*a*c*d*f + a*c*e**S(2) + b**S(2)*d*f - b*c*d*e + c**S(2)*d**S(2) rubi.append(670) return Dist(S(1)/q, Int((-A*a*c*f + A*b**S(2)*f - A*b*c*e + A*c**S(2)*d + C*a**S(2)*f - C*a*c*d + c*x*(A*b*f - A*c*e + C*a*e - C*b*d))/(a + b*x + c*x**S(2)), x), x) + Dist(S(1)/q, Int((A*a*f**S(2) - A*b*e*f - A*c*d*f + A*c*e**S(2) - C*a*d*f + C*c*d**S(2) - f*x*(A*b*f - A*c*e + C*a*e - C*b*d))/(d + e*x + f*x**S(2)), x), x) rule670 = ReplacementRule(pattern670, replacement670) def With671(B, C, f, b, d, c, a, x, A): if isinstance(x, (int, Integer, float, Float)): return False q = a**S(2)*f**S(2) - S(2)*a*c*d*f + b**S(2)*d*f + c**S(2)*d**S(2) if NonzeroQ(q): return True return False pattern671 = Pattern(Integral((x_**S(2)*WC('C', S(1)) + x_*WC('B', S(1)) + WC('A', S(0)))/((d_ + x_**S(2)*WC('f', S(1)))*(a_ + x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)))), x_), cons2, cons3, cons7, cons27, cons125, cons34, cons35, cons36, cons226, CustomConstraint(With671)) def replacement671(B, C, f, b, d, c, a, x, A): q = a**S(2)*f**S(2) - S(2)*a*c*d*f + b**S(2)*d*f + c**S(2)*d**S(2) rubi.append(671) return Dist(S(1)/q, Int((A*a*f**S(2) - A*c*d*f + B*b*d*f - C*a*d*f + C*c*d**S(2) - f*x*(A*b*f - B*a*f + B*c*d - C*b*d))/(d + f*x**S(2)), x), x) + Dist(S(1)/q, Int((-A*a*c*f + A*b**S(2)*f + A*c**S(2)*d - B*a*b*f + C*a**S(2)*f - C*a*c*d + c*x*(A*b*f - B*a*f + B*c*d - C*b*d))/(a + b*x + c*x**S(2)), x), x) rule671 = ReplacementRule(pattern671, replacement671) def With672(C, f, b, d, c, a, x, A): if isinstance(x, (int, Integer, float, Float)): return False q = a**S(2)*f**S(2) - S(2)*a*c*d*f + b**S(2)*d*f + c**S(2)*d**S(2) if NonzeroQ(q): return True return False pattern672 = Pattern(Integral((x_**S(2)*WC('C', S(1)) + WC('A', S(0)))/((d_ + x_**S(2)*WC('f', S(1)))*(a_ + x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)))), x_), cons2, cons3, cons7, cons27, cons125, cons34, cons36, cons226, CustomConstraint(With672)) def replacement672(C, f, b, d, c, a, x, A): q = a**S(2)*f**S(2) - S(2)*a*c*d*f + b**S(2)*d*f + c**S(2)*d**S(2) rubi.append(672) return Dist(S(1)/q, Int((A*a*f**S(2) - A*c*d*f - C*a*d*f + C*c*d**S(2) - f*x*(A*b*f - C*b*d))/(d + f*x**S(2)), x), x) + Dist(S(1)/q, Int((-A*a*c*f + A*b**S(2)*f + A*c**S(2)*d + C*a**S(2)*f - C*a*c*d + c*x*(A*b*f - C*b*d))/(a + b*x + c*x**S(2)), x), x) rule672 = ReplacementRule(pattern672, replacement672) pattern673 = Pattern(Integral((x_**S(2)*WC('C', S(1)) + x_*WC('B', S(1)) + WC('A', S(0)))/((a_ + x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)))*sqrt(x_**S(2)*WC('f', S(1)) + x_*WC('e', S(1)) + WC('d', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons36, cons226, cons394) def replacement673(B, C, e, f, b, d, c, a, x, A): rubi.append(673) return Dist(S(1)/c, Int((A*c - C*a + x*(B*c - C*b))/((a + b*x + c*x**S(2))*sqrt(d + e*x + f*x**S(2))), x), x) + Dist(C/c, Int(S(1)/sqrt(d + e*x + f*x**S(2)), x), x) rule673 = ReplacementRule(pattern673, replacement673) pattern674 = Pattern(Integral((x_**S(2)*WC('C', S(1)) + WC('A', S(0)))/((a_ + x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)))*sqrt(x_**S(2)*WC('f', S(1)) + x_*WC('e', S(1)) + WC('d', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons36, cons226, cons394) def replacement674(C, e, f, b, d, c, a, x, A): rubi.append(674) return Dist(S(1)/c, Int((A*c - C*a - C*b*x)/((a + b*x + c*x**S(2))*sqrt(d + e*x + f*x**S(2))), x), x) + Dist(C/c, Int(S(1)/sqrt(d + e*x + f*x**S(2)), x), x) rule674 = ReplacementRule(pattern674, replacement674) pattern675 = Pattern(Integral((x_**S(2)*WC('C', S(1)) + x_*WC('B', S(1)) + WC('A', S(0)))/((a_ + x_**S(2)*WC('c', S(1)))*sqrt(x_**S(2)*WC('f', S(1)) + x_*WC('e', S(1)) + WC('d', S(0)))), x_), cons2, cons7, cons27, cons48, cons125, cons34, cons35, cons36, cons394) def replacement675(B, C, e, f, d, c, a, x, A): rubi.append(675) return Dist(S(1)/c, Int((A*c + B*c*x - C*a)/((a + c*x**S(2))*sqrt(d + e*x + f*x**S(2))), x), x) + Dist(C/c, Int(S(1)/sqrt(d + e*x + f*x**S(2)), x), x) rule675 = ReplacementRule(pattern675, replacement675) pattern676 = Pattern(Integral((x_**S(2)*WC('C', S(1)) + WC('A', S(0)))/((a_ + x_**S(2)*WC('c', S(1)))*sqrt(x_**S(2)*WC('f', S(1)) + x_*WC('e', S(1)) + WC('d', S(0)))), x_), cons2, cons7, cons27, cons48, cons125, cons34, cons36, cons394) def replacement676(C, f, d, c, a, A, x, e): rubi.append(676) return Dist(C/c, Int(S(1)/sqrt(d + e*x + f*x**S(2)), x), x) + Dist((A*c - C*a)/c, Int(S(1)/((a + c*x**S(2))*sqrt(d + e*x + f*x**S(2))), x), x) rule676 = ReplacementRule(pattern676, replacement676) pattern677 = Pattern(Integral((x_**S(2)*WC('C', S(1)) + x_*WC('B', S(1)) + WC('A', S(0)))/(sqrt(x_**S(2)*WC('f', S(1)) + WC('d', S(0)))*(a_ + x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)))), x_), cons2, cons3, cons7, cons27, cons125, cons34, cons35, cons36, cons226) def replacement677(B, C, f, b, d, c, a, x, A): rubi.append(677) return Dist(S(1)/c, Int((A*c - C*a + x*(B*c - C*b))/(sqrt(d + f*x**S(2))*(a + b*x + c*x**S(2))), x), x) + Dist(C/c, Int(S(1)/sqrt(d + f*x**S(2)), x), x) rule677 = ReplacementRule(pattern677, replacement677) pattern678 = Pattern(Integral((x_**S(2)*WC('C', S(1)) + WC('A', S(0)))/(sqrt(x_**S(2)*WC('f', S(1)) + WC('d', S(0)))*(a_ + x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)))), x_), cons2, cons3, cons7, cons27, cons125, cons34, cons36, cons226) def replacement678(C, f, b, d, c, a, x, A): rubi.append(678) return Dist(S(1)/c, Int((A*c - C*a - C*b*x)/(sqrt(d + f*x**S(2))*(a + b*x + c*x**S(2))), x), x) + Dist(C/c, Int(S(1)/sqrt(d + f*x**S(2)), x), x) rule678 = ReplacementRule(pattern678, replacement678) pattern679 = Pattern(Integral((x_**S(2)*WC('C', S(1)) + x_*WC('B', S(1)) + WC('A', S(0)))*(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0)))**p_*(x_**S(2)*WC('f', S(1)) + x_*WC('e', S(1)) + WC('d', S(0)))**q_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons36, cons5, cons50, cons455) def replacement679(B, C, e, p, f, b, d, c, a, x, q, A): rubi.append(679) return Int((A + B*x + C*x**S(2))*(a + b*x + c*x**S(2))**p*(d + e*x + f*x**S(2))**q, x) rule679 = ReplacementRule(pattern679, replacement679) pattern680 = Pattern(Integral((x_**S(2)*WC('C', S(1)) + WC('A', S(0)))*(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0)))**p_*(x_**S(2)*WC('f', S(1)) + x_*WC('e', S(1)) + WC('d', S(0)))**q_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons36, cons5, cons50, cons456) def replacement680(C, e, p, f, b, d, c, a, x, q, A): rubi.append(680) return Int((A + C*x**S(2))*(a + b*x + c*x**S(2))**p*(d + e*x + f*x**S(2))**q, x) rule680 = ReplacementRule(pattern680, replacement680) pattern681 = Pattern(Integral((x_**S(2)*WC('c', S(1)) + WC('a', S(0)))**p_*(x_**S(2)*WC('C', S(1)) + x_*WC('B', S(1)) + WC('A', S(0)))*(x_**S(2)*WC('f', S(1)) + x_*WC('e', S(1)) + WC('d', S(0)))**q_, x_), cons2, cons7, cons27, cons48, cons125, cons34, cons35, cons36, cons5, cons50, cons457) def replacement681(B, C, e, p, f, d, a, c, x, q, A): rubi.append(681) return Int((a + c*x**S(2))**p*(A + B*x + C*x**S(2))*(d + e*x + f*x**S(2))**q, x) rule681 = ReplacementRule(pattern681, replacement681) pattern682 = Pattern(Integral((x_**S(2)*WC('C', S(1)) + WC('A', S(0)))*(x_**S(2)*WC('c', S(1)) + WC('a', S(0)))**p_*(x_**S(2)*WC('f', S(1)) + x_*WC('e', S(1)) + WC('d', S(0)))**q_, x_), cons2, cons7, cons27, cons48, cons125, cons34, cons36, cons5, cons50, cons458) def replacement682(C, e, p, f, d, a, c, x, q, A): rubi.append(682) return Int((A + C*x**S(2))*(a + c*x**S(2))**p*(d + e*x + f*x**S(2))**q, x) rule682 = ReplacementRule(pattern682, replacement682) pattern683 = Pattern(Integral((u_**S(2)*WC('C', S(1)) + u_*WC('B', S(1)) + WC('A', S(0)))*(u_**S(2)*WC('c', S(1)) + u_*WC('b', S(1)) + WC('a', S(0)))**WC('p', S(1))*(u_**S(2)*WC('f', S(1)) + u_*WC('e', S(1)) + WC('d', S(0)))**WC('q', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons36, cons5, cons50, cons68, cons69) def replacement683(B, p, C, e, u, f, b, d, c, a, x, q, A): rubi.append(683) return Dist(S(1)/Coefficient(u, x, S(1)), Subst(Int((A + B*x + C*x**S(2))*(a + b*x + c*x**S(2))**p*(d + e*x + f*x**S(2))**q, x), x, u), x) rule683 = ReplacementRule(pattern683, replacement683) pattern684 = Pattern(Integral((u_*WC('B', S(1)) + WC('A', S(0)))*(u_**S(2)*WC('c', S(1)) + u_*WC('b', S(1)) + WC('a', S(0)))**WC('p', S(1))*(u_**S(2)*WC('f', S(1)) + u_*WC('e', S(1)) + WC('d', S(0)))**WC('q', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons36, cons5, cons50, cons68, cons69) def replacement684(B, p, e, u, f, b, d, c, a, x, q, A): rubi.append(684) return Dist(S(1)/Coefficient(u, x, S(1)), Subst(Int((A + B*x)*(a + b*x + c*x**S(2))**p*(d + e*x + f*x**S(2))**q, x), x, u), x) rule684 = ReplacementRule(pattern684, replacement684) pattern685 = Pattern(Integral((u_**S(2)*WC('C', S(1)) + WC('A', S(0)))*(u_**S(2)*WC('c', S(1)) + u_*WC('b', S(1)) + WC('a', S(0)))**WC('p', S(1))*(u_**S(2)*WC('f', S(1)) + u_*WC('e', S(1)) + WC('d', S(0)))**WC('q', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons36, cons5, cons50, cons68, cons69) def replacement685(p, C, e, u, f, b, d, c, a, x, q, A): rubi.append(685) return Dist(S(1)/Coefficient(u, x, S(1)), Subst(Int((A + C*x**S(2))*(a + b*x + c*x**S(2))**p*(d + e*x + f*x**S(2))**q, x), x, u), x) rule685 = ReplacementRule(pattern685, replacement685) pattern686 = Pattern(Integral((u_**S(2)*WC('c', S(1)) + WC('a', S(0)))**WC('p', S(1))*(u_**S(2)*WC('C', S(1)) + u_*WC('B', S(1)) + WC('A', S(0)))*(u_**S(2)*WC('f', S(1)) + u_*WC('e', S(1)) + WC('d', S(0)))**WC('q', S(1)), x_), cons2, cons7, cons27, cons48, cons125, cons34, cons35, cons36, cons5, cons50, cons68, cons69) def replacement686(B, p, C, e, u, f, d, a, c, x, q, A): rubi.append(686) return Dist(S(1)/Coefficient(u, x, S(1)), Subst(Int((a + c*x**S(2))**p*(A + B*x + C*x**S(2))*(d + e*x + f*x**S(2))**q, x), x, u), x) rule686 = ReplacementRule(pattern686, replacement686) pattern687 = Pattern(Integral((u_*WC('B', S(1)) + WC('A', S(0)))*(u_**S(2)*WC('c', S(1)) + WC('a', S(0)))**WC('p', S(1))*(u_**S(2)*WC('f', S(1)) + u_*WC('e', S(1)) + WC('d', S(0)))**WC('q', S(1)), x_), cons2, cons7, cons27, cons48, cons125, cons34, cons35, cons36, cons5, cons50, cons68, cons69) def replacement687(B, p, e, u, f, d, a, c, x, q, A): rubi.append(687) return Dist(S(1)/Coefficient(u, x, S(1)), Subst(Int((A + B*x)*(a + c*x**S(2))**p*(d + e*x + f*x**S(2))**q, x), x, u), x) rule687 = ReplacementRule(pattern687, replacement687) pattern688 = Pattern(Integral((u_**S(2)*WC('C', S(1)) + WC('A', S(0)))*(u_**S(2)*WC('c', S(1)) + WC('a', S(0)))**WC('p', S(1))*(u_**S(2)*WC('f', S(1)) + u_*WC('e', S(1)) + WC('d', S(0)))**WC('q', S(1)), x_), cons2, cons7, cons27, cons48, cons125, cons34, cons36, cons5, cons50, cons68, cons69) def replacement688(C, p, e, u, f, d, a, c, x, q, A): rubi.append(688) return Dist(S(1)/Coefficient(u, x, S(1)), Subst(Int((A + C*x**S(2))*(a + c*x**S(2))**p*(d + e*x + f*x**S(2))**q, x), x, u), x) rule688 = ReplacementRule(pattern688, replacement688) return [rule189, rule190, rule191, rule192, rule193, rule194, rule195, rule196, rule197, rule198, rule199, rule200, rule201, rule202, rule203, rule204, rule205, rule206, rule207, rule208, rule209, rule210, rule211, rule212, rule213, rule214, rule215, rule216, rule217, rule218, rule219, rule220, rule221, rule222, rule223, rule224, rule225, rule226, rule227, rule228, rule229, rule230, rule231, rule232, rule233, rule234, rule235, rule236, rule237, rule238, rule239, rule240, rule241, rule242, rule243, rule244, rule245, rule246, rule247, rule248, rule249, rule250, rule251, rule252, rule253, rule254, rule255, rule256, rule257, rule258, rule259, rule260, rule261, rule262, rule263, rule264, rule265, rule266, rule267, rule268, rule269, rule270, rule271, rule272, rule273, rule274, rule275, rule276, rule277, rule278, rule279, rule280, rule281, rule282, rule283, rule284, rule285, rule286, rule287, rule288, rule289, rule290, rule291, rule292, rule293, rule294, rule295, rule296, rule297, rule298, rule299, rule300, rule301, rule302, rule303, rule304, rule305, rule306, rule307, rule308, rule309, rule310, rule311, rule312, rule313, rule314, rule315, rule316, rule317, rule318, rule319, rule320, rule321, rule322, rule323, rule324, rule325, rule326, rule327, rule328, rule329, rule330, rule331, rule332, rule333, rule334, rule335, rule336, rule337, rule338, rule339, rule340, rule341, rule342, rule343, rule344, rule345, rule346, rule347, rule348, rule349, rule350, rule351, rule352, rule353, rule354, rule355, rule356, rule357, rule358, rule359, rule360, rule361, rule362, rule363, rule364, rule365, rule366, rule367, rule368, rule369, rule370, rule371, rule372, rule373, rule374, rule375, rule376, rule377, rule378, rule379, rule380, rule381, rule382, rule383, rule384, rule385, rule386, rule387, rule388, rule389, rule390, rule391, rule392, rule393, rule394, rule395, rule396, rule397, rule398, rule399, rule400, rule401, rule402, rule403, rule404, rule405, rule406, rule407, rule408, rule409, rule410, rule411, rule412, rule413, rule414, rule415, rule416, rule417, rule418, rule419, rule420, rule421, rule422, rule423, rule424, rule425, rule426, rule427, rule428, rule429, rule430, rule431, rule432, rule433, rule434, rule435, rule436, rule437, rule438, rule439, rule440, rule441, rule442, rule443, rule444, rule445, rule446, rule447, rule448, rule449, rule450, rule451, rule452, rule453, rule454, rule455, rule456, rule457, rule458, rule459, rule460, rule461, rule462, rule463, rule464, rule465, rule466, rule467, rule468, rule469, rule470, rule471, rule472, rule473, rule474, rule475, rule476, rule477, rule478, rule479, rule480, rule481, rule482, rule483, rule484, rule485, rule486, rule487, rule488, rule489, rule490, rule491, rule492, rule493, rule494, rule495, rule496, rule497, rule498, rule499, rule500, rule501, rule502, rule503, rule504, rule505, rule506, rule507, rule508, rule509, rule510, rule511, rule512, rule513, rule514, rule515, rule516, rule517, rule518, rule519, rule520, rule521, rule522, rule523, rule524, rule525, rule526, rule527, rule528, rule529, rule530, rule531, rule532, rule533, rule534, rule535, rule536, rule537, rule538, rule539, rule540, rule541, rule542, rule543, rule544, rule545, rule546, rule547, rule548, rule549, rule550, rule551, rule552, rule553, rule554, rule555, rule556, rule557, rule558, rule559, rule560, rule561, rule562, rule563, rule564, rule565, rule566, rule567, rule568, rule569, rule570, rule571, rule572, rule573, rule574, rule575, rule576, rule577, rule578, rule579, rule580, rule581, rule582, rule583, rule584, rule585, rule586, rule587, rule588, rule589, rule590, rule591, rule592, rule593, rule594, rule595, rule596, rule597, rule598, rule599, rule600, rule601, rule602, rule603, rule604, rule605, rule606, rule607, rule608, rule609, rule610, rule611, rule612, rule613, rule614, rule615, rule616, rule617, rule618, rule619, rule620, rule621, rule622, rule623, rule624, rule625, rule626, rule627, rule628, rule629, rule630, rule631, rule632, rule633, rule634, rule635, rule636, rule637, rule638, rule639, rule640, rule641, rule642, rule643, rule644, rule645, rule646, rule647, rule648, rule649, rule650, rule651, rule652, rule653, rule654, rule655, rule656, rule657, rule658, rule659, rule660, rule661, rule662, rule663, rule664, rule665, rule666, rule667, rule668, rule669, rule670, rule671, rule672, rule673, rule674, rule675, rule676, rule677, rule678, rule679, rule680, rule681, rule682, rule683, rule684, rule685, rule686, rule687, rule688, ]
2f0bd455a0d58585368fe3458138860ad0a8a3a787af1e5d88e41c270e18c4b6
''' This code is automatically generated. Never edit it manually. For details of generating the code see `rubi_parsing_guide.md` in `parsetools`. ''' from sympy.external import import_module matchpy = import_module("matchpy") from sympy.utilities.decorator import doctest_depends_on if matchpy: from matchpy import Pattern, ReplacementRule, CustomConstraint, is_match from sympy.integrals.rubi.utility_function import ( Int, Sum, Set, With, Module, Scan, MapAnd, FalseQ, ZeroQ, NegativeQ, NonzeroQ, FreeQ, NFreeQ, List, Log, PositiveQ, PositiveIntegerQ, NegativeIntegerQ, IntegerQ, IntegersQ, ComplexNumberQ, PureComplexNumberQ, RealNumericQ, PositiveOrZeroQ, NegativeOrZeroQ, FractionOrNegativeQ, NegQ, Equal, Unequal, IntPart, FracPart, RationalQ, ProductQ, SumQ, NonsumQ, Subst, First, Rest, SqrtNumberQ, SqrtNumberSumQ, LinearQ, Sqrt, ArcCosh, Coefficient, Denominator, Hypergeometric2F1, Not, Simplify, FractionalPart, IntegerPart, AppellF1, EllipticPi, EllipticE, EllipticF, ArcTan, ArcCot, ArcCoth, ArcTanh, ArcSin, ArcSinh, ArcCos, ArcCsc, ArcSec, ArcCsch, ArcSech, Sinh, Tanh, Cosh, Sech, Csch, Coth, LessEqual, Less, Greater, GreaterEqual, FractionQ, IntLinearcQ, Expand, IndependentQ, PowerQ, IntegerPowerQ, PositiveIntegerPowerQ, FractionalPowerQ, AtomQ, ExpQ, LogQ, Head, MemberQ, TrigQ, SinQ, CosQ, TanQ, CotQ, SecQ, CscQ, Sin, Cos, Tan, Cot, Sec, Csc, HyperbolicQ, SinhQ, CoshQ, TanhQ, CothQ, SechQ, CschQ, InverseTrigQ, SinCosQ, SinhCoshQ, LeafCount, Numerator, NumberQ, NumericQ, Length, ListQ, Im, Re, InverseHyperbolicQ, InverseFunctionQ, TrigHyperbolicFreeQ, InverseFunctionFreeQ, RealQ, EqQ, FractionalPowerFreeQ, ComplexFreeQ, PolynomialQ, FactorSquareFree, PowerOfLinearQ, Exponent, QuadraticQ, LinearPairQ, BinomialParts, TrinomialParts, PolyQ, EvenQ, OddQ, PerfectSquareQ, NiceSqrtAuxQ, NiceSqrtQ, Together, PosAux, PosQ, CoefficientList, ReplaceAll, ExpandLinearProduct, GCD, ContentFactor, NumericFactor, NonnumericFactors, MakeAssocList, GensymSubst, KernelSubst, ExpandExpression, Apart, SmartApart, MatchQ, PolynomialQuotientRemainder, FreeFactors, NonfreeFactors, RemoveContentAux, RemoveContent, FreeTerms, NonfreeTerms, ExpandAlgebraicFunction, CollectReciprocals, ExpandCleanup, AlgebraicFunctionQ, Coeff, LeadTerm, RemainingTerms, LeadFactor, RemainingFactors, LeadBase, LeadDegree, Numer, Denom, hypergeom, Expon, MergeMonomials, PolynomialDivide, BinomialQ, TrinomialQ, GeneralizedBinomialQ, GeneralizedTrinomialQ, FactorSquareFreeList, PerfectPowerTest, SquareFreeFactorTest, RationalFunctionQ, RationalFunctionFactors, NonrationalFunctionFactors, Reverse, RationalFunctionExponents, RationalFunctionExpand, ExpandIntegrand, SimplerQ, SimplerSqrtQ, SumSimplerQ, BinomialDegree, TrinomialDegree, CancelCommonFactors, SimplerIntegrandQ, GeneralizedBinomialDegree, GeneralizedBinomialParts, GeneralizedTrinomialDegree, GeneralizedTrinomialParts, MonomialQ, MonomialSumQ, MinimumMonomialExponent, MonomialExponent, LinearMatchQ, PowerOfLinearMatchQ, QuadraticMatchQ, CubicMatchQ, BinomialMatchQ, TrinomialMatchQ, GeneralizedBinomialMatchQ, GeneralizedTrinomialMatchQ, QuotientOfLinearsMatchQ, PolynomialTermQ, PolynomialTerms, NonpolynomialTerms, PseudoBinomialParts, NormalizePseudoBinomial, PseudoBinomialPairQ, PseudoBinomialQ, PolynomialGCD, PolyGCD, AlgebraicFunctionFactors, NonalgebraicFunctionFactors, QuotientOfLinearsP, QuotientOfLinearsParts, QuotientOfLinearsQ, Flatten, Sort, AbsurdNumberQ, AbsurdNumberFactors, NonabsurdNumberFactors, SumSimplerAuxQ, Prepend, Drop, CombineExponents, FactorInteger, FactorAbsurdNumber, SubstForInverseFunction, SubstForFractionalPower, SubstForFractionalPowerOfQuotientOfLinears, FractionalPowerOfQuotientOfLinears, SubstForFractionalPowerQ, SubstForFractionalPowerAuxQ, FractionalPowerOfSquareQ, FractionalPowerSubexpressionQ, Apply, FactorNumericGcd, MergeableFactorQ, MergeFactor, MergeFactors, TrigSimplifyQ, TrigSimplify, TrigSimplifyRecur, Order, FactorOrder, Smallest, OrderedQ, MinimumDegree, PositiveFactors, Sign, NonpositiveFactors, PolynomialInAuxQ, PolynomialInQ, ExponentInAux, ExponentIn, PolynomialInSubstAux, PolynomialInSubst, Distrib, DistributeDegree, FunctionOfPower, DivideDegreesOfFactors, MonomialFactor, FullSimplify, FunctionOfLinearSubst, FunctionOfLinear, NormalizeIntegrand, NormalizeIntegrandAux, NormalizeIntegrandFactor, NormalizeIntegrandFactorBase, NormalizeTogether, NormalizeLeadTermSigns, AbsorbMinusSign, NormalizeSumFactors, SignOfFactor, NormalizePowerOfLinear, SimplifyIntegrand, SimplifyTerm, TogetherSimplify, SmartSimplify, SubstForExpn, ExpandToSum, UnifySum, UnifyTerms, UnifyTerm, CalculusQ, FunctionOfInverseLinear, PureFunctionOfSinhQ, PureFunctionOfTanhQ, PureFunctionOfCoshQ, IntegerQuotientQ, OddQuotientQ, EvenQuotientQ, FindTrigFactor, FunctionOfSinhQ, FunctionOfCoshQ, OddHyperbolicPowerQ, FunctionOfTanhQ, FunctionOfTanhWeight, FunctionOfHyperbolicQ, SmartNumerator, SmartDenominator, SubstForAux, ActivateTrig, ExpandTrig, TrigExpand, SubstForTrig, SubstForHyperbolic, InertTrigFreeQ, LCM, SubstForFractionalPowerOfLinear, FractionalPowerOfLinear, InverseFunctionOfLinear, InertTrigQ, InertReciprocalQ, DeactivateTrig, FixInertTrigFunction, DeactivateTrigAux, PowerOfInertTrigSumQ, PiecewiseLinearQ, KnownTrigIntegrandQ, KnownSineIntegrandQ, KnownTangentIntegrandQ, KnownCotangentIntegrandQ, KnownSecantIntegrandQ, TryPureTanSubst, TryTanhSubst, TryPureTanhSubst, AbsurdNumberGCD, AbsurdNumberGCDList, ExpandTrigExpand, ExpandTrigReduce, ExpandTrigReduceAux, NormalizeTrig, TrigToExp, ExpandTrigToExp, TrigReduce, FunctionOfTrig, AlgebraicTrigFunctionQ, FunctionOfHyperbolic, FunctionOfQ, FunctionOfExpnQ, PureFunctionOfSinQ, PureFunctionOfCosQ, PureFunctionOfTanQ, PureFunctionOfCotQ, FunctionOfCosQ, FunctionOfSinQ, OddTrigPowerQ, FunctionOfTanQ, FunctionOfTanWeight, FunctionOfTrigQ, FunctionOfDensePolynomialsQ, FunctionOfLog, PowerVariableExpn, PowerVariableDegree, PowerVariableSubst, EulerIntegrandQ, FunctionOfSquareRootOfQuadratic, SquareRootOfQuadraticSubst, Divides, EasyDQ, ProductOfLinearPowersQ, Rt, NthRoot, AtomBaseQ, SumBaseQ, NegSumBaseQ, AllNegTermQ, SomeNegTermQ, TrigSquareQ, RtAux, TrigSquare, IntSum, IntTerm, Map2, ConstantFactor, SameQ, ReplacePart, CommonFactors, MostMainFactorPosition, FunctionOfExponentialQ, FunctionOfExponential, FunctionOfExponentialFunction, FunctionOfExponentialFunctionAux, FunctionOfExponentialTest, FunctionOfExponentialTestAux, stdev, rubi_test, If, IntQuadraticQ, IntBinomialQ, RectifyTangent, RectifyCotangent, Inequality, Condition, Simp, SimpHelp, SplitProduct, SplitSum, SubstFor, SubstForAux, FresnelS, FresnelC, Erfc, Erfi, Gamma, FunctionOfTrigOfLinearQ, ElementaryFunctionQ, Complex, UnsameQ, _SimpFixFactor, SimpFixFactor, _FixSimplify, FixSimplify, _SimplifyAntiderivativeSum, SimplifyAntiderivativeSum, _SimplifyAntiderivative, SimplifyAntiderivative, _TrigSimplifyAux, TrigSimplifyAux, Cancel, Part, PolyLog, D, Dist, Sum_doit, PolynomialQuotient, Floor, PolynomialRemainder, Factor, PolyLog, CosIntegral, SinIntegral, LogIntegral, SinhIntegral, CoshIntegral, Rule, Erf, PolyGamma, ExpIntegralEi, ExpIntegralE, LogGamma , UtilityOperator, Factorial, Zeta, ProductLog, DerivativeDivides, HypergeometricPFQ, IntHide, OneQ, Null, rubi_exp as exp, rubi_log as log, Discriminant, Negative, Quotient ) from sympy import (Integral, S, sqrt, And, Or, Integer, Float, Mod, I, Abs, simplify, Mul, Add, Pow, sign, EulerGamma) from sympy.integrals.rubi.symbol import WC from sympy.core.symbol import symbols, Symbol from sympy.functions import (sin, cos, tan, cot, csc, sec, sqrt, erf) from sympy.functions.elementary.hyperbolic import (acosh, asinh, atanh, acoth, acsch, asech, cosh, sinh, tanh, coth, sech, csch) from sympy.functions.elementary.trigonometric import (atan, acsc, asin, acot, acos, asec, atan2) from sympy import pi as Pi A_, B_, C_, F_, G_, H_, a_, b_, c_, d_, e_, f_, g_, h_, i_, j_, k_, l_, m_, n_, p_, q_, r_, t_, u_, v_, s_, w_, x_, y_, z_ = [WC(i) for i in 'ABCFGHabcdefghijklmnpqrtuvswxyz'] a1_, a2_, b1_, b2_, c1_, c2_, d1_, d2_, n1_, n2_, e1_, e2_, f1_, f2_, g1_, g2_, n1_, n2_, n3_, Pq_, Pm_, Px_, Qm_, Qr_, Qx_, jn_, mn_, non2_, RFx_, RGx_ = [WC(i) for i in ['a1', 'a2', 'b1', 'b2', 'c1', 'c2', 'd1', 'd2', 'n1', 'n2', 'e1', 'e2', 'f1', 'f2', 'g1', 'g2', 'n1', 'n2', 'n3', 'Pq', 'Pm', 'Px', 'Qm', 'Qr', 'Qx', 'jn', 'mn', 'non2', 'RFx', 'RGx']] i, ii , Pqq, Q, R, r, C, k, u = symbols('i ii Pqq Q R r C k u') _UseGamma = False ShowSteps = False StepCounter = None def binomial_products(rubi): from sympy.integrals.rubi.constraints import cons459, cons3, cons4, cons5, cons460, cons2, cons461, cons54, cons462, cons87, cons463, cons38, cons464, cons148, cons13, cons163, cons465, cons466, cons43, cons448, cons67, cons137, cons467, cons468, cons469, cons470, cons471, cons472, cons473, cons474, cons475, cons476, cons477, cons478, cons479, cons480, cons481, cons482, cons483, cons484, cons105, cons485, cons486, cons487, cons488, cons196, cons489, cons128, cons357, cons490, cons491, cons492, cons493, cons68, cons69, cons55, cons494, cons57, cons58, cons59, cons60, cons495, cons496, cons497, cons498, cons147, cons7, cons21, cons499, cons500, cons501, cons18, cons502, cons503, cons66, cons504, cons505, cons506, cons507, cons17, cons244, cons94, cons508, cons509, cons510, cons511, cons512, cons513, cons514, cons515, cons516, cons517, cons518, cons519, cons520, cons521, cons62, cons522, cons523, cons524, cons525, cons526, cons527, cons528, cons529, cons31, cons530, cons531, cons532, cons533, cons534, cons535, cons536, cons367, cons537, cons538, cons539, cons540, cons356, cons541, cons23, cons542, cons543, cons544, cons545, cons546, cons547, cons548, cons549, cons550, cons551, cons552, cons553, cons554, cons71, cons555, cons27, cons220, cons50, cons556, cons85, cons557, cons395, cons403, cons63, cons558, cons559, cons560, cons561, cons562, cons563, cons564, cons565, cons566, cons567, cons568, cons569, cons70, cons570, cons571, cons572, cons573, cons402, cons574, cons575, cons576, cons405, cons577, cons578, cons579, cons580, cons581, cons177, cons582, cons583, cons117, cons584, cons585, cons586, cons587, cons386, cons588, cons589, cons590, cons591, cons48, cons53, cons592, cons593, cons594, cons595, cons596, cons93, cons597, cons598, cons599, cons600, cons601, cons602, cons603, cons604, cons88, cons605, cons606, cons607, cons608, cons609, cons610, cons611, cons612, cons613, cons614, cons615, cons616, cons617, cons618, cons619, cons620, cons621, cons622, cons623, cons624, cons625, cons626, cons627, cons46, cons628, cons125, cons629, cons630, cons631, cons153, cons632, cons633, cons176, cons634, cons635, cons636, cons637, cons638, cons178, cons639, cons640, cons396, cons641, cons52, cons642, cons643, cons644, cons645, cons646, cons647, cons648, cons649, cons650, cons651, cons652, cons653, cons654, cons655, cons656, cons208, cons657, cons658, cons659, cons660, cons661, cons380, cons662, cons663 pattern689 = Pattern(Integral((x_**n_*WC('b', S(1)))**p_, x_), cons3, cons4, cons5, cons459) def replacement689(x, p, n, b): rubi.append(689) return Dist(b**IntPart(p)*x**(-n*FracPart(p))*(b*x**n)**FracPart(p), Int(x**(n*p), x), x) rule689 = ReplacementRule(pattern689, replacement689) pattern690 = Pattern(Integral((a_ + x_**n_*WC('b', S(1)))**p_, x_), cons2, cons3, cons4, cons5, cons460) def replacement690(p, b, a, n, x): rubi.append(690) return Simp(x*(a + b*x**n)**(p + S(1))/a, x) rule690 = ReplacementRule(pattern690, replacement690) pattern691 = Pattern(Integral((a_ + x_**n_*WC('b', S(1)))**p_, x_), cons2, cons3, cons4, cons5, cons461, cons54) def replacement691(p, b, a, n, x): rubi.append(691) return Dist((n*(p + S(1)) + S(1))/(a*n*(p + S(1))), Int((a + b*x**n)**(p + S(1)), x), x) - Simp(x*(a + b*x**n)**(p + S(1))/(a*n*(p + S(1))), x) rule691 = ReplacementRule(pattern691, replacement691) pattern692 = Pattern(Integral((a_ + x_**n_*WC('b', S(1)))**S(2), x_), cons2, cons3, cons4, cons462) def replacement692(x, a, n, b): rubi.append(692) return Int(a**S(2) + S(2)*a*b*x**n + b**S(2)*x**(S(2)*n), x) rule692 = ReplacementRule(pattern692, replacement692) pattern693 = Pattern(Integral((a_ + x_**n_*WC('b', S(1)))**p_, x_), cons2, cons3, cons87, cons463, cons38) def replacement693(p, b, a, n, x): rubi.append(693) return Int(x**(n*p)*(a*x**(-n) + b)**p, x) rule693 = ReplacementRule(pattern693, replacement693) pattern694 = Pattern(Integral((a_ + x_**n_*WC('b', S(1)))**p_, x_), cons2, cons3, cons464) def replacement694(p, b, a, n, x): rubi.append(694) return Int(ExpandIntegrand((a + b*x**n)**p, x), x) rule694 = ReplacementRule(pattern694, replacement694) pattern695 = Pattern(Integral((a_ + x_**n_*WC('b', S(1)))**p_, x_), cons2, cons3, cons148, cons13, cons163, cons465) def replacement695(p, b, a, n, x): rubi.append(695) return Dist(a*n*p/(n*p + S(1)), Int((a + b*x**n)**(p + S(-1)), x), x) + Simp(x*(a + b*x**n)**p/(n*p + S(1)), x) rule695 = ReplacementRule(pattern695, replacement695) pattern696 = Pattern(Integral((a_ + x_**S(2)*WC('b', S(1)))**(S(-5)/4), x_), cons2, cons3, cons466, cons43) def replacement696(x, a, b): rubi.append(696) return Simp(S(2)*EllipticE(ArcTan(x*Rt(b/a, S(2)))/S(2), S(2))/(a**(S(5)/4)*Rt(b/a, S(2))), x) rule696 = ReplacementRule(pattern696, replacement696) pattern697 = Pattern(Integral((a_ + x_**S(2)*WC('b', S(1)))**(S(-5)/4), x_), cons2, cons3, cons466, cons448) def replacement697(x, a, b): rubi.append(697) return Dist((S(1) + b*x**S(2)/a)**(S(1)/4)/(a*(a + b*x**S(2))**(S(1)/4)), Int((S(1) + b*x**S(2)/a)**(S(-5)/4), x), x) rule697 = ReplacementRule(pattern697, replacement697) pattern698 = Pattern(Integral((a_ + x_**S(2)*WC('b', S(1)))**(S(-7)/6), x_), cons2, cons3, cons67) def replacement698(x, a, b): rubi.append(698) return Dist(S(1)/((a/(a + b*x**S(2)))**(S(2)/3)*(a + b*x**S(2))**(S(2)/3)), Subst(Int((-b*x**S(2) + S(1))**(S(-1)/3), x), x, x/sqrt(a + b*x**S(2))), x) rule698 = ReplacementRule(pattern698, replacement698) pattern699 = Pattern(Integral((a_ + x_**n_*WC('b', S(1)))**p_, x_), cons2, cons3, cons148, cons13, cons137, cons465) def replacement699(p, b, a, n, x): rubi.append(699) return Dist((n*(p + S(1)) + S(1))/(a*n*(p + S(1))), Int((a + b*x**n)**(p + S(1)), x), x) - Simp(x*(a + b*x**n)**(p + S(1))/(a*n*(p + S(1))), x) rule699 = ReplacementRule(pattern699, replacement699) pattern700 = Pattern(Integral(S(1)/(a_ + x_**S(3)*WC('b', S(1))), x_), cons2, cons3, cons67) def replacement700(x, a, b): rubi.append(700) return Dist(S(1)/(S(3)*Rt(a, S(3))**S(2)), Int((-x*Rt(b, S(3)) + S(2)*Rt(a, S(3)))/(x**S(2)*Rt(b, S(3))**S(2) - x*Rt(a, S(3))*Rt(b, S(3)) + Rt(a, S(3))**S(2)), x), x) + Dist(S(1)/(S(3)*Rt(a, S(3))**S(2)), Int(S(1)/(x*Rt(b, S(3)) + Rt(a, S(3))), x), x) rule700 = ReplacementRule(pattern700, replacement700) def With701(x, a, n, b): r = Numerator(Rt(a/b, n)) s = Denominator(Rt(a/b, n)) k = Symbol('k') u = Symbol('u') u = Int((r - s*x*cos(Pi*(S(2)*k + S(-1))/n))/(r**S(2) - S(2)*r*s*x*cos(Pi*(S(2)*k + S(-1))/n) + s**S(2)*x**S(2)), x) u = Int((r - s*x*cos(Pi*(2*k - 1)/n))/(r**2 - 2*r*s*x*cos(Pi*(2*k - 1)/n) + s**2*x**2), x) return Simp(Dist(2*r/(a*n), Sum_doit(u, List(k, 1, n/2 - S.Half)), x) + r*Int(1/(r + s*x), x)/(a*n), x) pattern701 = Pattern(Integral(S(1)/(a_ + x_**n_*WC('b', S(1))), x_), cons2, cons3, cons467, cons468) rule701 = ReplacementRule(pattern701, With701) def With702(x, a, n, b): r = Numerator(Rt(-a/b, n)) s = Denominator(Rt(-a/b, n)) k = Symbol('k') u = Symbol('u') u = Int((r + s*x*cos(Pi*(S(2)*k + S(-1))/n))/(r**S(2) + S(2)*r*s*x*cos(Pi*(S(2)*k + S(-1))/n) + s**S(2)*x**S(2)), x) u = Int((r + s*x*cos(Pi*(2*k - 1)/n))/(r**2 + 2*r*s*x*cos(Pi*(2*k - 1)/n) + s**2*x**2), x) return Simp(Dist(2*r/(a*n), Sum_doit(u, List(k, 1, n/2 - S.Half)), x) + r*Int(1/(r - s*x), x)/(a*n), x) pattern702 = Pattern(Integral(S(1)/(a_ + x_**n_*WC('b', S(1))), x_), cons2, cons3, cons467, cons469) rule702 = ReplacementRule(pattern702, With702) pattern703 = Pattern(Integral(S(1)/(a_ + x_**S(2)*WC('b', S(1))), x_), cons2, cons3, cons468, cons470) def replacement703(x, a, b): rubi.append(703) return Simp(ArcTan(x*Rt(b, S(2))/Rt(a, S(2)))/(Rt(a, S(2))*Rt(b, S(2))), x) rule703 = ReplacementRule(pattern703, replacement703) pattern704 = Pattern(Integral(S(1)/(a_ + x_**S(2)*WC('b', S(1))), x_), cons2, cons3, cons468, cons471) def replacement704(x, a, b): rubi.append(704) return -Simp(ArcTan(x*Rt(-b, S(2))/Rt(-a, S(2)))/(Rt(-a, S(2))*Rt(-b, S(2))), x) rule704 = ReplacementRule(pattern704, replacement704) pattern705 = Pattern(Integral(S(1)/(a_ + x_**S(2)*WC('b', S(1))), x_), cons2, cons3, cons468) def replacement705(x, a, b): rubi.append(705) return Simp(ArcTan(x/Rt(a/b, S(2)))*Rt(a/b, S(2))/a, x) rule705 = ReplacementRule(pattern705, replacement705) pattern706 = Pattern(Integral(S(1)/(a_ + x_**S(2)*WC('b', S(1))), x_), cons2, cons3, cons469, cons472) def replacement706(x, a, b): rubi.append(706) return Simp(atanh(x*Rt(-b, S(2))/Rt(a, S(2)))/(Rt(a, S(2))*Rt(-b, S(2))), x) rule706 = ReplacementRule(pattern706, replacement706) pattern707 = Pattern(Integral(S(1)/(a_ + x_**S(2)*WC('b', S(1))), x_), cons2, cons3, cons469, cons473) def replacement707(x, a, b): rubi.append(707) return -Simp(atanh(x*Rt(b, S(2))/Rt(-a, S(2)))/(Rt(-a, S(2))*Rt(b, S(2))), x) rule707 = ReplacementRule(pattern707, replacement707) pattern708 = Pattern(Integral(S(1)/(a_ + x_**S(2)*WC('b', S(1))), x_), cons2, cons3, cons469) def replacement708(x, a, b): rubi.append(708) return Simp(Rt(-a/b, S(2))*atanh(x/Rt(-a/b, S(2)))/a, x) rule708 = ReplacementRule(pattern708, replacement708) def With709(x, a, n, b): r = Numerator(Rt(a/b, n)) s = Denominator(Rt(a/b, n)) k = Symbol('k') u = Symbol('u') v = Symbol('v') u = Int((r - s*x*cos(Pi*(S(2)*k + S(-1))/n))/(r**S(2) - S(2)*r*s*x*cos(Pi*(S(2)*k + S(-1))/n) + s**S(2)*x**S(2)), x) + Int((r + s*x*cos(Pi*(S(2)*k + S(-1))/n))/(r**S(2) + S(2)*r*s*x*cos(Pi*(S(2)*k + S(-1))/n) + s**S(2)*x**S(2)), x) u = Int((r - s*x*cos(Pi*(2*k - 1)/n))/(r**2 - 2*r*s*x*cos(Pi*(2*k - 1)/n) + s**2*x**2), x) + Int((r + s*x*cos(Pi*(2*k - 1)/n))/(r**2 + 2*r*s*x*cos(Pi*(2*k - 1)/n) + s**2*x**2), x) return Simp(Dist(2*r/(a*n), Sum_doit(u, List(k, 1, n/4 - S.Half)), x) + 2*r**2*Int(1/(r**2 + s**2*x**2), x)/(a*n), x) pattern709 = Pattern(Integral(S(1)/(a_ + x_**n_*WC('b', S(1))), x_), cons2, cons3, cons474, cons468) rule709 = ReplacementRule(pattern709, With709) def With710(x, a, n, b): r = Numerator(Rt(-a/b, n)) s = Denominator(Rt(-a/b, n)) k = Symbol('k') u = Symbol('u') u = Int((r - s*x*cos(S(2)*Pi*k/n))/(r**S(2) - S(2)*r*s*x*cos(S(2)*Pi*k/n) + s**S(2)*x**S(2)), x) + Int((r + s*x*cos(S(2)*Pi*k/n))/(r**S(2) + S(2)*r*s*x*cos(S(2)*Pi*k/n) + s**S(2)*x**S(2)), x) u = Int((r - s*x*cos(2*Pi*k/n))/(r**2 - 2*r*s*x*cos(2*Pi*k/n) + s**2*x**2), x) + Int((r + s*x*cos(2*Pi*k/n))/(r**2 + 2*r*s*x*cos(2*Pi*k/n) + s**2*x**2), x) return Simp(Dist(2*r/(a*n), Sum_doit(u, List(k, 1, n/4 - S.Half)), x) + 2*r**2*Int(1/(r**2 - s**2*x**2), x)/(a*n), x) pattern710 = Pattern(Integral(S(1)/(a_ + x_**n_*WC('b', S(1))), x_), cons2, cons3, cons474, cons469) rule710 = ReplacementRule(pattern710, With710) def With711(x, a, b): r = Numerator(Rt(a/b, S(2))) s = Denominator(Rt(a/b, S(2))) rubi.append(711) return Dist(S(1)/(S(2)*r), Int((r - s*x**S(2))/(a + b*x**S(4)), x), x) + Dist(S(1)/(S(2)*r), Int((r + s*x**S(2))/(a + b*x**S(4)), x), x) pattern711 = Pattern(Integral(S(1)/(a_ + x_**S(4)*WC('b', S(1))), x_), cons2, cons3, cons475) rule711 = ReplacementRule(pattern711, With711) def With712(x, a, b): r = Numerator(Rt(-a/b, S(2))) s = Denominator(Rt(-a/b, S(2))) rubi.append(712) return Dist(r/(S(2)*a), Int(S(1)/(r - s*x**S(2)), x), x) + Dist(r/(S(2)*a), Int(S(1)/(r + s*x**S(2)), x), x) pattern712 = Pattern(Integral(S(1)/(a_ + x_**S(4)*WC('b', S(1))), x_), cons2, cons3, cons476) rule712 = ReplacementRule(pattern712, With712) def With713(x, a, n, b): r = Numerator(Rt(a/b, S(4))) s = Denominator(Rt(a/b, S(4))) rubi.append(713) return Dist(sqrt(S(2))*r/(S(4)*a), Int((sqrt(S(2))*r - s*x**(n/S(4)))/(r**S(2) - sqrt(S(2))*r*s*x**(n/S(4)) + s**S(2)*x**(n/S(2))), x), x) + Dist(sqrt(S(2))*r/(S(4)*a), Int((sqrt(S(2))*r + s*x**(n/S(4)))/(r**S(2) + sqrt(S(2))*r*s*x**(n/S(4)) + s**S(2)*x**(n/S(2))), x), x) pattern713 = Pattern(Integral(S(1)/(a_ + x_**n_*WC('b', S(1))), x_), cons2, cons3, cons477, cons478) rule713 = ReplacementRule(pattern713, With713) def With714(x, a, n, b): r = Numerator(Rt(-a/b, S(2))) s = Denominator(Rt(-a/b, S(2))) rubi.append(714) return Dist(r/(S(2)*a), Int(S(1)/(r - s*x**(n/S(2))), x), x) + Dist(r/(S(2)*a), Int(S(1)/(r + s*x**(n/S(2))), x), x) pattern714 = Pattern(Integral(S(1)/(a_ + x_**n_*WC('b', S(1))), x_), cons2, cons3, cons477, cons476) rule714 = ReplacementRule(pattern714, With714) pattern715 = Pattern(Integral(S(1)/sqrt(a_ + x_**S(2)*WC('b', S(1))), x_), cons2, cons3, cons43, cons479) def replacement715(x, a, b): rubi.append(715) return Simp(asinh(x*Rt(b, S(2))/sqrt(a))/Rt(b, S(2)), x) rule715 = ReplacementRule(pattern715, replacement715) pattern716 = Pattern(Integral(S(1)/sqrt(a_ + x_**S(2)*WC('b', S(1))), x_), cons2, cons3, cons43, cons480) def replacement716(x, a, b): rubi.append(716) return Simp(asin(x*Rt(-b, S(2))/sqrt(a))/Rt(-b, S(2)), x) rule716 = ReplacementRule(pattern716, replacement716) pattern717 = Pattern(Integral(S(1)/sqrt(a_ + x_**S(2)*WC('b', S(1))), x_), cons2, cons3, cons448) def replacement717(x, a, b): rubi.append(717) return Subst(Int(S(1)/(-b*x**S(2) + S(1)), x), x, x/sqrt(a + b*x**S(2))) rule717 = ReplacementRule(pattern717, replacement717) def With718(x, a, b): r = Numer(Rt(b/a, S(3))) s = Denom(Rt(b/a, S(3))) rubi.append(718) return Simp(S(2)*S(3)**(S(3)/4)*sqrt((r**S(2)*x**S(2) - r*s*x + s**S(2))/(r*x + s*(S(1) + sqrt(S(3))))**S(2))*sqrt(sqrt(S(3)) + S(2))*(r*x + s)*EllipticF(asin((r*x + s*(-sqrt(S(3)) + S(1)))/(r*x + s*(S(1) + sqrt(S(3))))), S(-7) - S(4)*sqrt(S(3)))/(S(3)*r*sqrt(s*(r*x + s)/(r*x + s*(S(1) + sqrt(S(3))))**S(2))*sqrt(a + b*x**S(3))), x) pattern718 = Pattern(Integral(S(1)/sqrt(a_ + x_**S(3)*WC('b', S(1))), x_), cons2, cons3, cons481) rule718 = ReplacementRule(pattern718, With718) def With719(x, a, b): r = Numer(Rt(b/a, S(3))) s = Denom(Rt(b/a, S(3))) rubi.append(719) return Simp(S(2)*S(3)**(S(3)/4)*sqrt((r**S(2)*x**S(2) - r*s*x + s**S(2))/(r*x + s*(-sqrt(S(3)) + S(1)))**S(2))*sqrt(-sqrt(S(3)) + S(2))*(r*x + s)*EllipticF(asin((r*x + s*(S(1) + sqrt(S(3))))/(r*x + s*(-sqrt(S(3)) + S(1)))), S(-7) + S(4)*sqrt(S(3)))/(S(3)*r*sqrt(-s*(r*x + s)/(r*x + s*(-sqrt(S(3)) + S(1)))**S(2))*sqrt(a + b*x**S(3))), x) pattern719 = Pattern(Integral(S(1)/sqrt(a_ + x_**S(3)*WC('b', S(1))), x_), cons2, cons3, cons482) rule719 = ReplacementRule(pattern719, With719) def With720(x, a, b): q = Rt(b/a, S(4)) rubi.append(720) return Simp(sqrt((a + b*x**S(4))/(a*(q**S(2)*x**S(2) + S(1))**S(2)))*(q**S(2)*x**S(2) + S(1))*EllipticF(S(2)*ArcTan(q*x), S(1)/2)/(S(2)*q*sqrt(a + b*x**S(4))), x) pattern720 = Pattern(Integral(S(1)/sqrt(a_ + x_**S(4)*WC('b', S(1))), x_), cons2, cons3, cons466) rule720 = ReplacementRule(pattern720, With720) pattern721 = Pattern(Integral(S(1)/sqrt(a_ + x_**S(4)*WC('b', S(1))), x_), cons2, cons3, cons483, cons43) def replacement721(x, a, b): rubi.append(721) return Simp(EllipticF(asin(x*Rt(-b, S(4))/Rt(a, S(4))), S(-1))/(Rt(a, S(4))*Rt(-b, S(4))), x) rule721 = ReplacementRule(pattern721, replacement721) def With722(x, a, b): if isinstance(x, (int, Integer, float, Float)): return False q = Rt(-a*b, S(2)) if IntegerQ(q): return True return False pattern722 = Pattern(Integral(S(1)/sqrt(a_ + x_**S(4)*WC('b', S(1))), x_), cons2, cons3, cons484, cons105, CustomConstraint(With722)) def replacement722(x, a, b): q = Rt(-a*b, S(2)) rubi.append(722) return Simp(sqrt(S(2))*sqrt((a + q*x**S(2))/q)*sqrt(-a + q*x**S(2))*EllipticF(asin(sqrt(S(2))*x/sqrt((a + q*x**S(2))/q)), S(1)/2)/(S(2)*sqrt(-a)*sqrt(a + b*x**S(4))), x) rule722 = ReplacementRule(pattern722, replacement722) def With723(x, a, b): q = Rt(-a*b, S(2)) rubi.append(723) return Simp(sqrt(S(2))*sqrt((a + q*x**S(2))/q)*sqrt((a - q*x**S(2))/(a + q*x**S(2)))*EllipticF(asin(sqrt(S(2))*x/sqrt((a + q*x**S(2))/q)), S(1)/2)/(S(2)*sqrt(a/(a + q*x**S(2)))*sqrt(a + b*x**S(4))), x) pattern723 = Pattern(Integral(S(1)/sqrt(a_ + x_**S(4)*WC('b', S(1))), x_), cons2, cons3, cons484, cons105) rule723 = ReplacementRule(pattern723, With723) pattern724 = Pattern(Integral(S(1)/sqrt(a_ + x_**S(4)*WC('b', S(1))), x_), cons2, cons3, cons483, cons448) def replacement724(x, a, b): rubi.append(724) return Dist(sqrt(S(1) + b*x**S(4)/a)/sqrt(a + b*x**S(4)), Int(S(1)/sqrt(S(1) + b*x**S(4)/a), x), x) rule724 = ReplacementRule(pattern724, replacement724) def With725(x, a, b): r = Numer(Rt(b/a, S(3))) s = Denom(Rt(b/a, S(3))) rubi.append(725) return Simp(S(3)**(S(3)/4)*x*sqrt((r**S(2)*x**S(4) - r*s*x**S(2) + s**S(2))/(r*x**S(2)*(S(1) + sqrt(S(3))) + s)**S(2))*(r*x**S(2) + s)*EllipticF(acos((r*x**S(2)*(-sqrt(S(3)) + S(1)) + s)/(r*x**S(2)*(S(1) + sqrt(S(3))) + s)), sqrt(S(3))/S(4) + S(1)/2)/(S(6)*s*sqrt(r*x**S(2)*(r*x**S(2) + s)/(r*x**S(2)*(S(1) + sqrt(S(3))) + s)**S(2))*sqrt(a + b*x**S(6))), x) pattern725 = Pattern(Integral(S(1)/sqrt(a_ + x_**S(6)*WC('b', S(1))), x_), cons2, cons3, cons67) rule725 = ReplacementRule(pattern725, With725) pattern726 = Pattern(Integral(S(1)/sqrt(a_ + x_**S(8)*WC('b', S(1))), x_), cons2, cons3, cons67) def replacement726(x, a, b): rubi.append(726) return Dist(S(1)/2, Int((-x**S(2)*Rt(b/a, S(4)) + S(1))/sqrt(a + b*x**S(8)), x), x) + Dist(S(1)/2, Int((x**S(2)*Rt(b/a, S(4)) + S(1))/sqrt(a + b*x**S(8)), x), x) rule726 = ReplacementRule(pattern726, replacement726) pattern727 = Pattern(Integral((a_ + x_**S(2)*WC('b', S(1)))**(S(-1)/4), x_), cons2, cons3, cons466) def replacement727(x, a, b): rubi.append(727) return -Dist(a, Int((a + b*x**S(2))**(S(-5)/4), x), x) + Simp(S(2)*x/(a + b*x**S(2))**(S(1)/4), x) rule727 = ReplacementRule(pattern727, replacement727) pattern728 = Pattern(Integral((a_ + x_**S(2)*WC('b', S(1)))**(S(-1)/4), x_), cons2, cons3, cons483, cons43) def replacement728(x, a, b): rubi.append(728) return Simp(S(2)*EllipticE(asin(x*Rt(-b/a, S(2)))/S(2), S(2))/(a**(S(1)/4)*Rt(-b/a, S(2))), x) rule728 = ReplacementRule(pattern728, replacement728) pattern729 = Pattern(Integral((a_ + x_**S(2)*WC('b', S(1)))**(S(-1)/4), x_), cons2, cons3, cons483, cons448) def replacement729(x, a, b): rubi.append(729) return Dist((S(1) + b*x**S(2)/a)**(S(1)/4)/(a + b*x**S(2))**(S(1)/4), Int((S(1) + b*x**S(2)/a)**(S(-1)/4), x), x) rule729 = ReplacementRule(pattern729, replacement729) pattern730 = Pattern(Integral((a_ + x_**S(2)*WC('b', S(1)))**(S(-3)/4), x_), cons2, cons3, cons43, cons466) def replacement730(x, a, b): rubi.append(730) return Simp(S(2)*EllipticF(ArcTan(x*Rt(b/a, S(2)))/S(2), S(2))/(a**(S(3)/4)*Rt(b/a, S(2))), x) rule730 = ReplacementRule(pattern730, replacement730) pattern731 = Pattern(Integral((a_ + x_**S(2)*WC('b', S(1)))**(S(-3)/4), x_), cons2, cons3, cons43, cons483) def replacement731(x, a, b): rubi.append(731) return Simp(S(2)*EllipticF(asin(x*Rt(-b/a, S(2)))/S(2), S(2))/(a**(S(3)/4)*Rt(-b/a, S(2))), x) rule731 = ReplacementRule(pattern731, replacement731) pattern732 = Pattern(Integral((a_ + x_**S(2)*WC('b', S(1)))**(S(-3)/4), x_), cons2, cons3, cons448) def replacement732(x, a, b): rubi.append(732) return Dist((S(1) + b*x**S(2)/a)**(S(3)/4)/(a + b*x**S(2))**(S(3)/4), Int((S(1) + b*x**S(2)/a)**(S(-3)/4), x), x) rule732 = ReplacementRule(pattern732, replacement732) pattern733 = Pattern(Integral((a_ + x_**S(2)*WC('b', S(1)))**(S(-1)/3), x_), cons2, cons3, cons67) def replacement733(x, a, b): rubi.append(733) return Dist(S(3)*sqrt(b*x**S(2))/(S(2)*b*x), Subst(Int(x/sqrt(-a + x**S(3)), x), x, (a + b*x**S(2))**(S(1)/3)), x) rule733 = ReplacementRule(pattern733, replacement733) pattern734 = Pattern(Integral((a_ + x_**S(2)*WC('b', S(1)))**(S(-2)/3), x_), cons2, cons3, cons67) def replacement734(x, a, b): rubi.append(734) return Dist(S(3)*sqrt(b*x**S(2))/(S(2)*b*x), Subst(Int(S(1)/sqrt(-a + x**S(3)), x), x, (a + b*x**S(2))**(S(1)/3)), x) rule734 = ReplacementRule(pattern734, replacement734) pattern735 = Pattern(Integral((a_ + x_**S(4)*WC('b', S(1)))**(S(-3)/4), x_), cons2, cons3, cons67) def replacement735(x, a, b): rubi.append(735) return Dist(x**S(3)*(a/(b*x**S(4)) + S(1))**(S(3)/4)/(a + b*x**S(4))**(S(3)/4), Int(S(1)/(x**S(3)*(a/(b*x**S(4)) + S(1))**(S(3)/4)), x), x) rule735 = ReplacementRule(pattern735, replacement735) pattern736 = Pattern(Integral((a_ + x_**S(2)*WC('b', S(1)))**(S(-1)/6), x_), cons2, cons3, cons67) def replacement736(x, a, b): rubi.append(736) return -Dist(a/S(2), Int((a + b*x**S(2))**(S(-7)/6), x), x) + Simp(S(3)*x/(S(2)*(a + b*x**S(2))**(S(1)/6)), x) rule736 = ReplacementRule(pattern736, replacement736) pattern737 = Pattern(Integral((a_ + x_**n_*WC('b', S(1)))**p_, x_), cons2, cons3, cons148, cons13, cons485, cons486, cons487) def replacement737(p, b, a, n, x): rubi.append(737) return Dist(a**(p + S(1)/n), Subst(Int((-b*x**n + S(1))**(-p + S(-1) - S(1)/n), x), x, x*(a + b*x**n)**(-S(1)/n)), x) rule737 = ReplacementRule(pattern737, replacement737) pattern738 = Pattern(Integral((a_ + x_**n_*WC('b', S(1)))**p_, x_), cons2, cons3, cons148, cons13, cons485, cons486, cons488) def replacement738(p, b, a, n, x): rubi.append(738) return Dist((a/(a + b*x**n))**(p + S(1)/n)*(a + b*x**n)**(p + S(1)/n), Subst(Int((-b*x**n + S(1))**(-p + S(-1) - S(1)/n), x), x, x*(a + b*x**n)**(-S(1)/n)), x) rule738 = ReplacementRule(pattern738, replacement738) pattern739 = Pattern(Integral((a_ + x_**n_*WC('b', S(1)))**p_, x_), cons2, cons3, cons5, cons196) def replacement739(p, b, a, n, x): rubi.append(739) return -Subst(Int((a + b*x**(-n))**p/x**S(2), x), x, S(1)/x) rule739 = ReplacementRule(pattern739, replacement739) def With740(p, b, a, n, x): k = Denominator(n) rubi.append(740) return Dist(k, Subst(Int(x**(k + S(-1))*(a + b*x**(k*n))**p, x), x, x**(S(1)/k)), x) pattern740 = Pattern(Integral((a_ + x_**n_*WC('b', S(1)))**p_, x_), cons2, cons3, cons5, cons489) rule740 = ReplacementRule(pattern740, With740) pattern741 = Pattern(Integral((a_ + x_**n_*WC('b', S(1)))**p_, x_), cons2, cons3, cons4, cons128) def replacement741(p, b, a, n, x): rubi.append(741) return Int(ExpandIntegrand((a + b*x**n)**p, x), x) rule741 = ReplacementRule(pattern741, replacement741) pattern742 = Pattern(Integral((a_ + x_**n_*WC('b', S(1)))**p_, x_), cons2, cons3, cons4, cons5, cons357, cons490, cons491, cons492) def replacement742(p, b, a, n, x): rubi.append(742) return Simp(a**p*x*Hypergeometric2F1(-p, S(1)/n, S(1) + S(1)/n, -b*x**n/a), x) rule742 = ReplacementRule(pattern742, replacement742) pattern743 = Pattern(Integral((a_ + x_**n_*WC('b', S(1)))**p_, x_), cons2, cons3, cons4, cons5, cons357, cons490, cons491, cons493) def replacement743(p, b, a, n, x): rubi.append(743) return Dist(a**IntPart(p)*(S(1) + b*x**n/a)**(-FracPart(p))*(a + b*x**n)**FracPart(p), Int((S(1) + b*x**n/a)**p, x), x) rule743 = ReplacementRule(pattern743, replacement743) pattern744 = Pattern(Integral((u_**n_*WC('b', S(1)) + WC('a', S(0)))**p_, x_), cons2, cons3, cons4, cons5, cons68, cons69) def replacement744(p, u, b, a, n, x): rubi.append(744) return Dist(S(1)/Coefficient(u, x, S(1)), Subst(Int((a + b*x**n)**p, x), x, u), x) rule744 = ReplacementRule(pattern744, replacement744) pattern745 = Pattern(Integral((x_**n_*WC('b1', S(1)) + WC('a1', S(0)))**WC('p', S(1))*(x_**n_*WC('b2', S(1)) + WC('a2', S(0)))**WC('p', S(1)), x_), cons57, cons58, cons59, cons60, cons4, cons5, cons55, cons494) def replacement745(a2, p, b2, b1, n, x, a1): rubi.append(745) return Int((a1*a2 + b1*b2*x**(S(2)*n))**p, x) rule745 = ReplacementRule(pattern745, replacement745) pattern746 = Pattern(Integral((a1_ + x_**WC('n', S(1))*WC('b1', S(1)))**WC('p', S(1))*(a2_ + x_**WC('n', S(1))*WC('b2', S(1)))**WC('p', S(1)), x_), cons57, cons58, cons59, cons60, cons55, cons495, cons13, cons163, cons496) def replacement746(p, a2, b2, b1, n, x, a1): rubi.append(746) return Dist(S(2)*a1*a2*n*p/(S(2)*n*p + S(1)), Int((a1 + b1*x**n)**(p + S(-1))*(a2 + b2*x**n)**(p + S(-1)), x), x) + Simp(x*(a1 + b1*x**n)**p*(a2 + b2*x**n)**p/(S(2)*n*p + S(1)), x) rule746 = ReplacementRule(pattern746, replacement746) pattern747 = Pattern(Integral((a1_ + x_**WC('n', S(1))*WC('b1', S(1)))**p_*(a2_ + x_**WC('n', S(1))*WC('b2', S(1)))**p_, x_), cons57, cons58, cons59, cons60, cons55, cons495, cons13, cons137, cons496) def replacement747(p, a2, b2, b1, n, x, a1): rubi.append(747) return Dist((S(2)*n*(p + S(1)) + S(1))/(S(2)*a1*a2*n*(p + S(1))), Int((a1 + b1*x**n)**(p + S(1))*(a2 + b2*x**n)**(p + S(1)), x), x) - Simp(x*(a1 + b1*x**n)**(p + S(1))*(a2 + b2*x**n)**(p + S(1))/(S(2)*a1*a2*n*(p + S(1))), x) rule747 = ReplacementRule(pattern747, replacement747) pattern748 = Pattern(Integral((a1_ + x_**n_*WC('b1', S(1)))**p_*(a2_ + x_**n_*WC('b2', S(1)))**p_, x_), cons57, cons58, cons59, cons60, cons5, cons55, cons497) def replacement748(p, a2, b2, b1, n, x, a1): rubi.append(748) return -Subst(Int((a1 + b1*x**(-n))**p*(a2 + b2*x**(-n))**p/x**S(2), x), x, S(1)/x) rule748 = ReplacementRule(pattern748, replacement748) def With749(p, a2, b2, b1, n, x, a1): k = Denominator(S(2)*n) rubi.append(749) return Dist(k, Subst(Int(x**(k + S(-1))*(a1 + b1*x**(k*n))**p*(a2 + b2*x**(k*n))**p, x), x, x**(S(1)/k)), x) pattern749 = Pattern(Integral((a1_ + x_**n_*WC('b1', S(1)))**p_*(a2_ + x_**n_*WC('b2', S(1)))**p_, x_), cons57, cons58, cons59, cons60, cons5, cons55, cons498) rule749 = ReplacementRule(pattern749, With749) pattern750 = Pattern(Integral((x_**n_*WC('b1', S(1)) + WC('a1', S(0)))**p_*(x_**n_*WC('b2', S(1)) + WC('a2', S(0)))**p_, x_), cons57, cons58, cons59, cons60, cons4, cons5, cons55, cons147) def replacement750(a2, p, b2, b1, n, x, a1): rubi.append(750) return Dist((a1 + b1*x**n)**FracPart(p)*(a2 + b2*x**n)**FracPart(p)*(a1*a2 + b1*b2*x**(S(2)*n))**(-FracPart(p)), Int((a1*a2 + b1*b2*x**(S(2)*n))**p, x), x) rule750 = ReplacementRule(pattern750, replacement750) pattern751 = Pattern(Integral((x_*WC('c', S(1)))**WC('m', S(1))*(a1_ + x_**n_*WC('b1', S(1)))**p_*(a2_ + x_**n_*WC('b2', S(1)))**p_, x_), cons57, cons58, cons59, cons60, cons7, cons21, cons4, cons5, cons55, cons494) def replacement751(p, a2, m, b2, b1, c, n, x, a1): rubi.append(751) return Int((c*x)**m*(a1*a2 + b1*b2*x**(S(2)*n))**p, x) rule751 = ReplacementRule(pattern751, replacement751) pattern752 = Pattern(Integral((x_*WC('c', S(1)))**WC('m', S(1))*(x_**n_*WC('b', S(1)))**p_, x_), cons3, cons7, cons21, cons4, cons5, cons499, cons500) def replacement752(p, m, b, c, n, x): rubi.append(752) return Dist(b**(S(1) - (m + S(1))/n)*c**m/n, Subst(Int((b*x)**(p + S(-1) + (m + S(1))/n), x), x, x**n), x) rule752 = ReplacementRule(pattern752, replacement752) pattern753 = Pattern(Integral((x_*WC('c', S(1)))**WC('m', S(1))*(x_**WC('n', S(1))*WC('b', S(1)))**p_, x_), cons3, cons7, cons21, cons4, cons5, cons499, cons501) def replacement753(p, m, b, c, n, x): rubi.append(753) return Dist(b**IntPart(p)*c**m*x**(-n*FracPart(p))*(b*x**n)**FracPart(p), Int(x**(m + n*p), x), x) rule753 = ReplacementRule(pattern753, replacement753) pattern754 = Pattern(Integral((c_*x_)**m_*(x_**WC('n', S(1))*WC('b', S(1)))**p_, x_), cons3, cons7, cons21, cons4, cons5, cons18) def replacement754(p, m, b, c, n, x): rubi.append(754) return Dist(c**IntPart(m)*x**(-FracPart(m))*(c*x)**FracPart(m), Int(x**m*(b*x**n)**p, x), x) rule754 = ReplacementRule(pattern754, replacement754) pattern755 = Pattern(Integral(x_**WC('m', S(1))*(a_ + x_**n_*WC('b', S(1)))**p_, x_), cons2, cons3, cons21, cons4, cons38, cons502) def replacement755(p, m, b, a, n, x): rubi.append(755) return Int(x**(m + n*p)*(a*x**(-n) + b)**p, x) rule755 = ReplacementRule(pattern755, replacement755) pattern756 = Pattern(Integral((x_*WC('c', S(1)))**WC('m', S(1))*(a_ + x_**n_*WC('b', S(1)))**p_, x_), cons2, cons3, cons7, cons21, cons4, cons5, cons503, cons66) def replacement756(p, m, b, c, a, n, x): rubi.append(756) return Simp((c*x)**(m + S(1))*(a + b*x**n)**(p + S(1))/(a*c*(m + S(1))), x) rule756 = ReplacementRule(pattern756, replacement756) pattern757 = Pattern(Integral((x_*WC('c', S(1)))**WC('m', S(1))*(a1_ + x_**n_*WC('b1', S(1)))**p_*(a2_ + x_**n_*WC('b2', S(1)))**p_, x_), cons57, cons58, cons59, cons60, cons7, cons21, cons4, cons5, cons55, cons504, cons66) def replacement757(p, a2, m, b2, b1, c, n, x, a1): rubi.append(757) return Simp((c*x)**(m + S(1))*(a1 + b1*x**n)**(p + S(1))*(a2 + b2*x**n)**(p + S(1))/(a1*a2*c*(m + S(1))), x) rule757 = ReplacementRule(pattern757, replacement757) pattern758 = Pattern(Integral(x_**WC('m', S(1))*(x_**n_*WC('b', S(1)) + WC('a', S(0)))**p_, x_), cons2, cons3, cons21, cons4, cons5, cons500) def replacement758(p, m, b, a, n, x): rubi.append(758) return Dist(S(1)/n, Subst(Int(x**(S(-1) + (m + S(1))/n)*(a + b*x)**p, x), x, x**n), x) rule758 = ReplacementRule(pattern758, replacement758) pattern759 = Pattern(Integral(x_**WC('m', S(1))*(a1_ + x_**n_*WC('b1', S(1)))**p_*(a2_ + x_**n_*WC('b2', S(1)))**p_, x_), cons57, cons58, cons59, cons60, cons21, cons4, cons5, cons55, cons505) def replacement759(p, a2, m, b2, b1, n, x, a1): rubi.append(759) return Dist(S(1)/n, Subst(Int(x**(S(-1) + (m + S(1))/n)*(a1 + b1*x)**p*(a2 + b2*x)**p, x), x, x**n), x) rule759 = ReplacementRule(pattern759, replacement759) pattern760 = Pattern(Integral((c_*x_)**m_*(a_ + x_**n_*WC('b', S(1)))**p_, x_), cons2, cons3, cons7, cons21, cons4, cons5, cons500) def replacement760(p, m, b, c, a, n, x): rubi.append(760) return Dist(c**IntPart(m)*x**(-FracPart(m))*(c*x)**FracPart(m), Int(x**m*(a + b*x**n)**p, x), x) rule760 = ReplacementRule(pattern760, replacement760) pattern761 = Pattern(Integral((c_*x_)**m_*(a1_ + x_**n_*WC('b1', S(1)))**p_*(a2_ + x_**n_*WC('b2', S(1)))**p_, x_), cons57, cons58, cons59, cons60, cons7, cons21, cons4, cons5, cons55, cons505) def replacement761(p, a2, m, b2, b1, c, n, x, a1): rubi.append(761) return Dist(c**IntPart(m)*x**(-FracPart(m))*(c*x)**FracPart(m), Int(x**m*(a1 + b1*x**n)**p*(a2 + b2*x**n)**p, x), x) rule761 = ReplacementRule(pattern761, replacement761) pattern762 = Pattern(Integral((x_*WC('c', S(1)))**WC('m', S(1))*(a_ + x_**n_*WC('b', S(1)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons21, cons4, cons128) def replacement762(p, m, b, c, a, n, x): rubi.append(762) return Int(ExpandIntegrand((c*x)**m*(a + b*x**n)**p, x), x) rule762 = ReplacementRule(pattern762, replacement762) pattern763 = Pattern(Integral(x_**m_*(a_ + x_**n_*WC('b', S(1)))**p_, x_), cons2, cons3, cons21, cons4, cons5, cons506, cons66) def replacement763(p, m, b, a, n, x): rubi.append(763) return -Dist(b*(m + n*(p + S(1)) + S(1))/(a*(m + S(1))), Int(x**(m + n)*(a + b*x**n)**p, x), x) + Simp(x**(m + S(1))*(a + b*x**n)**(p + S(1))/(a*(m + S(1))), x) rule763 = ReplacementRule(pattern763, replacement763) pattern764 = Pattern(Integral(x_**m_*(a1_ + x_**n_*WC('b1', S(1)))**p_*(a2_ + x_**n_*WC('b2', S(1)))**p_, x_), cons57, cons58, cons59, cons60, cons21, cons4, cons5, cons55, cons507, cons66) def replacement764(p, a2, m, b2, b1, n, x, a1): rubi.append(764) return -Dist(b1*b2*(m + S(2)*n*(p + S(1)) + S(1))/(a1*a2*(m + S(1))), Int(x**(m + S(2)*n)*(a1 + b1*x**n)**p*(a2 + b2*x**n)**p, x), x) + Simp(x**(m + S(1))*(a1 + b1*x**n)**(p + S(1))*(a2 + b2*x**n)**(p + S(1))/(a1*a2*(m + S(1))), x) rule764 = ReplacementRule(pattern764, replacement764) pattern765 = Pattern(Integral((x_*WC('c', S(1)))**WC('m', S(1))*(a_ + x_**n_*WC('b', S(1)))**p_, x_), cons2, cons3, cons7, cons21, cons4, cons5, cons506, cons54) def replacement765(p, m, b, c, a, n, x): rubi.append(765) return Dist((m + n*(p + S(1)) + S(1))/(a*n*(p + S(1))), Int((c*x)**m*(a + b*x**n)**(p + S(1)), x), x) - Simp((c*x)**(m + S(1))*(a + b*x**n)**(p + S(1))/(a*c*n*(p + S(1))), x) rule765 = ReplacementRule(pattern765, replacement765) pattern766 = Pattern(Integral((x_*WC('c', S(1)))**WC('m', S(1))*(a1_ + x_**n_*WC('b1', S(1)))**p_*(a2_ + x_**n_*WC('b2', S(1)))**p_, x_), cons57, cons58, cons59, cons60, cons7, cons21, cons4, cons5, cons55, cons507, cons54) def replacement766(p, a2, m, b2, b1, c, n, x, a1): rubi.append(766) return Dist((m + S(2)*n*(p + S(1)) + S(1))/(S(2)*a1*a2*n*(p + S(1))), Int((c*x)**m*(a1 + b1*x**n)**(p + S(1))*(a2 + b2*x**n)**(p + S(1)), x), x) - Simp((c*x)**(m + S(1))*(a1 + b1*x**n)**(p + S(1))*(a2 + b2*x**n)**(p + S(1))/(S(2)*a1*a2*c*n*(p + S(1))), x) rule766 = ReplacementRule(pattern766, replacement766) def With767(p, m, b, a, n, x): if isinstance(x, (int, Integer, float, Float)): return False k = GCD(m + S(1), n) if Unequal(k, S(1)): return True return False pattern767 = Pattern(Integral(x_**WC('m', S(1))*(a_ + x_**n_*WC('b', S(1)))**p_, x_), cons2, cons3, cons5, cons148, cons17, CustomConstraint(With767)) def replacement767(p, m, b, a, n, x): k = GCD(m + S(1), n) rubi.append(767) return Dist(S(1)/k, Subst(Int(x**(S(-1) + (m + S(1))/k)*(a + b*x**(n/k))**p, x), x, x**k), x) rule767 = ReplacementRule(pattern767, replacement767) def With768(p, a2, m, b2, b1, n, x, a1): if isinstance(x, (int, Integer, float, Float)): return False k = GCD(m + S(1), S(2)*n) if Unequal(k, S(1)): return True return False pattern768 = Pattern(Integral(x_**WC('m', S(1))*(a1_ + x_**n_*WC('b1', S(1)))**p_*(a2_ + x_**n_*WC('b2', S(1)))**p_, x_), cons57, cons58, cons59, cons60, cons5, cons55, cons495, cons17, CustomConstraint(With768)) def replacement768(p, a2, m, b2, b1, n, x, a1): k = GCD(m + S(1), S(2)*n) rubi.append(768) return Dist(S(1)/k, Subst(Int(x**(S(-1) + (m + S(1))/k)*(a1 + b1*x**(n/k))**p*(a2 + b2*x**(n/k))**p, x), x, x**k), x) rule768 = ReplacementRule(pattern768, replacement768) pattern769 = Pattern(Integral((x_*WC('c', S(1)))**WC('m', S(1))*(a_ + x_**n_*WC('b', S(1)))**p_, x_), cons2, cons3, cons7, cons148, cons244, cons163, cons94, cons508, cons509) def replacement769(p, m, b, c, a, n, x): rubi.append(769) return -Dist(b*c**(-n)*n*p/(m + S(1)), Int((c*x)**(m + n)*(a + b*x**n)**(p + S(-1)), x), x) + Simp((c*x)**(m + S(1))*(a + b*x**n)**p/(c*(m + S(1))), x) rule769 = ReplacementRule(pattern769, replacement769) pattern770 = Pattern(Integral((x_*WC('c', S(1)))**WC('m', S(1))*(a1_ + x_**n_*WC('b1', S(1)))**p_*(a2_ + x_**n_*WC('b2', S(1)))**p_, x_), cons57, cons58, cons59, cons60, cons7, cons21, cons55, cons495, cons244, cons163, cons510, cons511) def replacement770(p, a2, m, b2, b1, c, n, x, a1): rubi.append(770) return Dist(S(2)*a1*a2*n*p/(m + S(2)*n*p + S(1)), Int((c*x)**m*(a1 + b1*x**n)**(p + S(-1))*(a2 + b2*x**n)**(p + S(-1)), x), x) + Simp((c*x)**(m + S(1))*(a1 + b1*x**n)**p*(a2 + b2*x**n)**p/(c*(m + S(2)*n*p + S(1))), x) rule770 = ReplacementRule(pattern770, replacement770) pattern771 = Pattern(Integral((x_*WC('c', S(1)))**WC('m', S(1))*(a_ + x_**n_*WC('b', S(1)))**p_, x_), cons2, cons3, cons7, cons21, cons148, cons244, cons163, cons512, cons509) def replacement771(p, m, b, c, a, n, x): rubi.append(771) return Dist(a*n*p/(m + n*p + S(1)), Int((c*x)**m*(a + b*x**n)**(p + S(-1)), x), x) + Simp((c*x)**(m + S(1))*(a + b*x**n)**p/(c*(m + n*p + S(1))), x) rule771 = ReplacementRule(pattern771, replacement771) pattern772 = Pattern(Integral(x_**S(2)/(a_ + x_**S(4)*WC('b', S(1)))**(S(5)/4), x_), cons2, cons3, cons466) def replacement772(x, a, b): rubi.append(772) return Dist(x*(a/(b*x**S(4)) + S(1))**(S(1)/4)/(b*(a + b*x**S(4))**(S(1)/4)), Int(S(1)/(x**S(3)*(a/(b*x**S(4)) + S(1))**(S(5)/4)), x), x) rule772 = ReplacementRule(pattern772, replacement772) pattern773 = Pattern(Integral(x_**m_/(a_ + x_**S(4)*WC('b', S(1)))**(S(5)/4), x_), cons2, cons3, cons466, cons513) def replacement773(x, m, b, a): rubi.append(773) return -Dist(a*(m + S(-3))/(b*(m + S(-4))), Int(x**(m + S(-4))/(a + b*x**S(4))**(S(5)/4), x), x) + Simp(x**(m + S(-3))/(b*(a + b*x**S(4))**(S(1)/4)*(m + S(-4))), x) rule773 = ReplacementRule(pattern773, replacement773) pattern774 = Pattern(Integral(x_**m_/(a_ + x_**S(4)*WC('b', S(1)))**(S(5)/4), x_), cons2, cons3, cons466, cons514) def replacement774(x, m, b, a): rubi.append(774) return -Dist(b*m/(a*(m + S(1))), Int(x**(m + S(4))/(a + b*x**S(4))**(S(5)/4), x), x) + Simp(x**(m + S(1))/(a*(a + b*x**S(4))**(S(1)/4)*(m + S(1))), x) rule774 = ReplacementRule(pattern774, replacement774) pattern775 = Pattern(Integral(sqrt(x_*WC('c', S(1)))/(a_ + x_**S(2)*WC('b', S(1)))**(S(5)/4), x_), cons2, cons3, cons7, cons466) def replacement775(x, c, b, a): rubi.append(775) return Dist(sqrt(c*x)*(a/(b*x**S(2)) + S(1))**(S(1)/4)/(b*(a + b*x**S(2))**(S(1)/4)), Int(S(1)/(x**S(2)*(a/(b*x**S(2)) + S(1))**(S(5)/4)), x), x) rule775 = ReplacementRule(pattern775, replacement775) pattern776 = Pattern(Integral((x_*WC('c', S(1)))**m_/(a_ + x_**S(2)*WC('b', S(1)))**(S(5)/4), x_), cons2, cons3, cons7, cons466, cons515, cons516) def replacement776(m, b, c, a, x): rubi.append(776) return -Dist(S(2)*a*c**S(2)*(m + S(-1))/(b*(S(2)*m + S(-3))), Int((c*x)**(m + S(-2))/(a + b*x**S(2))**(S(5)/4), x), x) + Simp(S(2)*c*(c*x)**(m + S(-1))/(b*(a + b*x**S(2))**(S(1)/4)*(S(2)*m + S(-3))), x) rule776 = ReplacementRule(pattern776, replacement776) pattern777 = Pattern(Integral((x_*WC('c', S(1)))**m_/(a_ + x_**S(2)*WC('b', S(1)))**(S(5)/4), x_), cons2, cons3, cons7, cons466, cons515, cons94) def replacement777(m, b, c, a, x): rubi.append(777) return -Dist(b*(S(2)*m + S(1))/(S(2)*a*c**S(2)*(m + S(1))), Int((c*x)**(m + S(2))/(a + b*x**S(2))**(S(5)/4), x), x) + Simp((c*x)**(m + S(1))/(a*c*(a + b*x**S(2))**(S(1)/4)*(m + S(1))), x) rule777 = ReplacementRule(pattern777, replacement777) pattern778 = Pattern(Integral(x_**S(2)/(a_ + x_**S(4)*WC('b', S(1)))**(S(5)/4), x_), cons2, cons3, cons483) def replacement778(x, a, b): rubi.append(778) return -Dist(S(1)/b, Int(S(1)/(x**S(2)*(a + b*x**S(4))**(S(1)/4)), x), x) - Simp(S(1)/(b*x*(a + b*x**S(4))**(S(1)/4)), x) rule778 = ReplacementRule(pattern778, replacement778) pattern779 = Pattern(Integral((x_*WC('c', S(1)))**WC('m', S(1))*(a_ + x_**n_*WC('b', S(1)))**p_, x_), cons2, cons3, cons7, cons148, cons244, cons137, cons517, cons518, cons509) def replacement779(p, m, b, c, a, n, x): rubi.append(779) return -Dist(c**n*(m - n + S(1))/(b*n*(p + S(1))), Int((c*x)**(m - n)*(a + b*x**n)**(p + S(1)), x), x) + Simp(c**(n + S(-1))*(c*x)**(m - n + S(1))*(a + b*x**n)**(p + S(1))/(b*n*(p + S(1))), x) rule779 = ReplacementRule(pattern779, replacement779) pattern780 = Pattern(Integral((x_*WC('c', S(1)))**WC('m', S(1))*(a1_ + x_**n_*WC('b1', S(1)))**p_*(a2_ + x_**n_*WC('b2', S(1)))**p_, x_), cons57, cons58, cons59, cons60, cons7, cons55, cons495, cons244, cons137, cons519, cons520, cons511) def replacement780(p, a2, m, b2, b1, c, n, x, a1): rubi.append(780) return -Dist(c**(S(2)*n)*(m - S(2)*n + S(1))/(S(2)*b1*b2*n*(p + S(1))), Int((c*x)**(m - S(2)*n)*(a1 + b1*x**n)**(p + S(1))*(a2 + b2*x**n)**(p + S(1)), x), x) + Simp(c**(S(2)*n + S(-1))*(c*x)**(m - S(2)*n + S(1))*(a1 + b1*x**n)**(p + S(1))*(a2 + b2*x**n)**(p + S(1))/(S(2)*b1*b2*n*(p + S(1))), x) rule780 = ReplacementRule(pattern780, replacement780) pattern781 = Pattern(Integral((x_*WC('c', S(1)))**WC('m', S(1))*(a_ + x_**n_*WC('b', S(1)))**p_, x_), cons2, cons3, cons7, cons21, cons148, cons244, cons137, cons509) def replacement781(p, m, b, c, a, n, x): rubi.append(781) return Dist((m + n*(p + S(1)) + S(1))/(a*n*(p + S(1))), Int((c*x)**m*(a + b*x**n)**(p + S(1)), x), x) - Simp((c*x)**(m + S(1))*(a + b*x**n)**(p + S(1))/(a*c*n*(p + S(1))), x) rule781 = ReplacementRule(pattern781, replacement781) pattern782 = Pattern(Integral((x_*WC('c', S(1)))**WC('m', S(1))*(a1_ + x_**n_*WC('b1', S(1)))**p_*(a2_ + x_**n_*WC('b2', S(1)))**p_, x_), cons57, cons58, cons59, cons60, cons7, cons21, cons55, cons495, cons244, cons137, cons511) def replacement782(p, a2, m, b2, b1, c, n, x, a1): rubi.append(782) return Dist((m + S(2)*n*(p + S(1)) + S(1))/(S(2)*a1*a2*n*(p + S(1))), Int((c*x)**m*(a1 + b1*x**n)**(p + S(1))*(a2 + b2*x**n)**(p + S(1)), x), x) - Simp((c*x)**(m + S(1))*(a1 + b1*x**n)**(p + S(1))*(a2 + b2*x**n)**(p + S(1))/(S(2)*a1*a2*c*n*(p + S(1))), x) rule782 = ReplacementRule(pattern782, replacement782) pattern783 = Pattern(Integral(x_/(a_ + x_**S(3)*WC('b', S(1))), x_), cons2, cons3, cons67) def replacement783(x, a, b): rubi.append(783) return Dist(S(1)/(S(3)*Rt(a, S(3))*Rt(b, S(3))), Int((x*Rt(b, S(3)) + Rt(a, S(3)))/(x**S(2)*Rt(b, S(3))**S(2) - x*Rt(a, S(3))*Rt(b, S(3)) + Rt(a, S(3))**S(2)), x), x) - Dist(S(1)/(S(3)*Rt(a, S(3))*Rt(b, S(3))), Int(S(1)/(x*Rt(b, S(3)) + Rt(a, S(3))), x), x) rule783 = ReplacementRule(pattern783, replacement783) def With784(m, b, a, n, x): r = Numerator(Rt(a/b, n)) s = Denominator(Rt(a/b, n)) k = Symbol('k') u = Symbol('u') u = Int((r*cos(Pi*m*(S(2)*k + S(-1))/n) - s*x*cos(Pi*(S(2)*k + S(-1))*(m + S(1))/n))/(r**S(2) - S(2)*r*s*x*cos(Pi*(S(2)*k + S(-1))/n) + s**S(2)*x**S(2)), x) u = Int((r*cos(Pi*m*(2*k - 1)/n) - s*x*cos(Pi*(2*k - 1)*(m + 1)/n))/(r**2 - 2*r*s*x*cos(Pi*(2*k - 1)/n) + s**2*x**2), x) return Simp(Dist(2*r**(m + 1)*s**(-m)/(a*n), Sum_doit(u, List(k, 1, n/2 - S.Half)), x) - s**(-m)*(-r)**(m + 1)*Int(1/(r + s*x), x)/(a*n), x) pattern784 = Pattern(Integral(x_**WC('m', S(1))/(a_ + x_**n_*WC('b', S(1))), x_), cons2, cons3, cons521, cons62, cons522, cons468) rule784 = ReplacementRule(pattern784, With784) def With785(m, b, a, n, x): r = Numerator(Rt(-a/b, n)) s = Denominator(Rt(-a/b, n)) k = Symbol('k') u = Symbol('u') u = Int((r*cos(Pi*m*(S(2)*k + S(-1))/n) + s*x*cos(Pi*(S(2)*k + S(-1))*(m + S(1))/n))/(r**S(2) + S(2)*r*s*x*cos(Pi*(S(2)*k + S(-1))/n) + s**S(2)*x**S(2)), x) u = Int((r*cos(Pi*m*(2*k - 1)/n) + s*x*cos(Pi*(2*k - 1)*(m + 1)/n))/(r**2 + 2*r*s*x*cos(Pi*(2*k - 1)/n) + s**2*x**2), x) return Simp(-Dist(2*s**(-m)*(-r)**(m + 1)/(a*n), Sum_doit(u, List(k, 1, n/2 - S.Half)), x) + r**(m + 1)*s**(-m)*Int(1/(r - s*x), x)/(a*n), x) pattern785 = Pattern(Integral(x_**WC('m', S(1))/(a_ + x_**n_*WC('b', S(1))), x_), cons2, cons3, cons523, cons62, cons522, cons469) rule785 = ReplacementRule(pattern785, With785) def With786(m, b, a, n, x): r = Numerator(Rt(a/b, n)) s = Denominator(Rt(a/b, n)) k = Symbol('k') u = Symbol('u') u = Int((r*cos(Pi*m*(S(2)*k + S(-1))/n) - s*x*cos(Pi*(S(2)*k + S(-1))*(m + S(1))/n))/(r**S(2) - S(2)*r*s*x*cos(Pi*(S(2)*k + S(-1))/n) + s**S(2)*x**S(2)), x) + Int((r*cos(Pi*m*(S(2)*k + S(-1))/n) + s*x*cos(Pi*(S(2)*k + S(-1))*(m + S(1))/n))/(r**S(2) + S(2)*r*s*x*cos(Pi*(S(2)*k + S(-1))/n) + s**S(2)*x**S(2)), x) u = Int((r*cos(Pi*m*(2*k - 1)/n) - s*x*cos(Pi*(2*k - 1)*(m + 1)/n))/(r**2 - 2*r*s*x*cos(Pi*(2*k - 1)/n) + s**2*x**2), x) + Int((r*cos(Pi*m*(2*k - 1)/n) + s*x*cos(Pi*(2*k - 1)*(m + 1)/n))/(r**2 + 2*r*s*x*cos(Pi*(2*k - 1)/n) + s**2*x**2), x) return Simp(2*(-1)**(m/2)*r**(m + 2)*s**(-m)*Int(1/(r**2 + s**2*x**2), x)/(a*n) + Dist(2*r**(m + 1)*s**(-m)/(a*n), Sum_doit(u, List(k, 1, n/4 - S.Half)), x), x) pattern786 = Pattern(Integral(x_**WC('m', S(1))/(a_ + x_**n_*WC('b', S(1))), x_), cons2, cons3, cons524, cons62, cons522, cons468) rule786 = ReplacementRule(pattern786, With786) def With787(m, b, a, n, x): r = Numerator(Rt(-a/b, n)) s = Denominator(Rt(-a/b, n)) k = Symbol('k') u = Symbol('u') u = Int((r*cos(S(2)*Pi*k*m/n) - s*x*cos(S(2)*Pi*k*(m + S(1))/n))/(r**S(2) - S(2)*r*s*x*cos(S(2)*Pi*k/n) + s**S(2)*x**S(2)), x) + Int((r*cos(S(2)*Pi*k*m/n) + s*x*cos(S(2)*Pi*k*(m + S(1))/n))/(r**S(2) + S(2)*r*s*x*cos(S(2)*Pi*k/n) + s**S(2)*x**S(2)), x) u = Int((r*cos(2*Pi*k*m/n) - s*x*cos(2*Pi*k*(m + 1)/n))/(r**2 - 2*r*s*x*cos(2*Pi*k/n) + s**2*x**2), x) + Int((r*cos(2*Pi*k*m/n) + s*x*cos(2*Pi*k*(m + 1)/n))/(r**2 + 2*r*s*x*cos(2*Pi*k/n) + s**2*x**2), x) return Simp(Dist(2*r**(m + 1)*s**(-m)/(a*n), Sum_doit(u, List(k, 1, n/4 - S.Half)), x) + 2*r**(m + 2)*s**(-m)*Int(1/(r**2 - s**2*x**2), x)/(a*n), x) pattern787 = Pattern(Integral(x_**WC('m', S(1))/(a_ + x_**n_*WC('b', S(1))), x_), cons2, cons3, cons524, cons62, cons522, cons469) rule787 = ReplacementRule(pattern787, With787) def With788(x, a, b): r = Numerator(Rt(a/b, S(2))) s = Denominator(Rt(a/b, S(2))) rubi.append(788) return -Dist(S(1)/(S(2)*s), Int((r - s*x**S(2))/(a + b*x**S(4)), x), x) + Dist(S(1)/(S(2)*s), Int((r + s*x**S(2))/(a + b*x**S(4)), x), x) pattern788 = Pattern(Integral(x_**S(2)/(a_ + x_**S(4)*WC('b', S(1))), x_), cons2, cons3, cons475) rule788 = ReplacementRule(pattern788, With788) def With789(x, a, b): r = Numerator(Rt(-a/b, S(2))) s = Denominator(Rt(-a/b, S(2))) rubi.append(789) return -Dist(s/(S(2)*b), Int(S(1)/(r - s*x**S(2)), x), x) + Dist(s/(S(2)*b), Int(S(1)/(r + s*x**S(2)), x), x) pattern789 = Pattern(Integral(x_**S(2)/(a_ + x_**S(4)*WC('b', S(1))), x_), cons2, cons3, cons476) rule789 = ReplacementRule(pattern789, With789) def With790(m, b, a, n, x): r = Numerator(Rt(a/b, S(4))) s = Denominator(Rt(a/b, S(4))) rubi.append(790) return Dist(sqrt(S(2))*s**S(3)/(S(4)*b*r), Int(x**(m - n/S(4))/(r**S(2) - sqrt(S(2))*r*s*x**(n/S(4)) + s**S(2)*x**(n/S(2))), x), x) - Dist(sqrt(S(2))*s**S(3)/(S(4)*b*r), Int(x**(m - n/S(4))/(r**S(2) + sqrt(S(2))*r*s*x**(n/S(4)) + s**S(2)*x**(n/S(2))), x), x) pattern790 = Pattern(Integral(x_**WC('m', S(1))/(a_ + x_**n_*WC('b', S(1))), x_), cons2, cons3, cons525, cons62, cons522, cons478) rule790 = ReplacementRule(pattern790, With790) def With791(m, b, a, n, x): r = Numerator(Rt(-a/b, S(2))) s = Denominator(Rt(-a/b, S(2))) rubi.append(791) return Dist(r/(S(2)*a), Int(x**m/(r - s*x**(n/S(2))), x), x) + Dist(r/(S(2)*a), Int(x**m/(r + s*x**(n/S(2))), x), x) pattern791 = Pattern(Integral(x_**m_/(a_ + x_**n_*WC('b', S(1))), x_), cons2, cons3, cons525, cons62, cons526, cons476) rule791 = ReplacementRule(pattern791, With791) def With792(m, b, a, n, x): r = Numerator(Rt(-a/b, S(2))) s = Denominator(Rt(-a/b, S(2))) rubi.append(792) return -Dist(s/(S(2)*b), Int(x**(m - n/S(2))/(r - s*x**(n/S(2))), x), x) + Dist(s/(S(2)*b), Int(x**(m - n/S(2))/(r + s*x**(n/S(2))), x), x) pattern792 = Pattern(Integral(x_**m_/(a_ + x_**n_*WC('b', S(1))), x_), cons2, cons3, cons525, cons62, cons527, cons476) rule792 = ReplacementRule(pattern792, With792) pattern793 = Pattern(Integral(x_**m_/(a_ + x_**n_*WC('b', S(1))), x_), cons2, cons3, cons528, cons529) def replacement793(m, b, a, n, x): rubi.append(793) return Int(PolynomialDivide(x**m, a + b*x**n, x), x) rule793 = ReplacementRule(pattern793, replacement793) def With794(x, a, b): r = Numer(Rt(b/a, S(3))) s = Denom(Rt(b/a, S(3))) rubi.append(794) return Dist(S(1)/r, Int((r*x + s*(-sqrt(S(3)) + S(1)))/sqrt(a + b*x**S(3)), x), x) + Dist(sqrt(S(2))*s/(r*sqrt(sqrt(S(3)) + S(2))), Int(S(1)/sqrt(a + b*x**S(3)), x), x) pattern794 = Pattern(Integral(x_/sqrt(a_ + x_**S(3)*WC('b', S(1))), x_), cons2, cons3, cons481) rule794 = ReplacementRule(pattern794, With794) def With795(x, a, b): r = Numer(Rt(b/a, S(3))) s = Denom(Rt(b/a, S(3))) rubi.append(795) return Dist(S(1)/r, Int((r*x + s*(S(1) + sqrt(S(3))))/sqrt(a + b*x**S(3)), x), x) - Dist(sqrt(S(2))*s/(r*sqrt(-sqrt(S(3)) + S(2))), Int(S(1)/sqrt(a + b*x**S(3)), x), x) pattern795 = Pattern(Integral(x_/sqrt(a_ + x_**S(3)*WC('b', S(1))), x_), cons2, cons3, cons482) rule795 = ReplacementRule(pattern795, With795) def With796(x, a, b): q = Rt(b/a, S(2)) rubi.append(796) return -Dist(S(1)/q, Int((-q*x**S(2) + S(1))/sqrt(a + b*x**S(4)), x), x) + Dist(S(1)/q, Int(S(1)/sqrt(a + b*x**S(4)), x), x) pattern796 = Pattern(Integral(x_**S(2)/sqrt(a_ + x_**S(4)*WC('b', S(1))), x_), cons2, cons3, cons466) rule796 = ReplacementRule(pattern796, With796) def With797(x, a, b): q = Rt(-b/a, S(2)) rubi.append(797) return -Dist(S(1)/q, Int((-q*x**S(2) + S(1))/sqrt(a + b*x**S(4)), x), x) + Dist(S(1)/q, Int(S(1)/sqrt(a + b*x**S(4)), x), x) pattern797 = Pattern(Integral(x_**S(2)/sqrt(a_ + x_**S(4)*WC('b', S(1))), x_), cons2, cons3, cons484, cons105) rule797 = ReplacementRule(pattern797, With797) def With798(x, a, b): q = Rt(-b/a, S(2)) rubi.append(798) return Dist(S(1)/q, Int((q*x**S(2) + S(1))/sqrt(a + b*x**S(4)), x), x) - Dist(S(1)/q, Int(S(1)/sqrt(a + b*x**S(4)), x), x) pattern798 = Pattern(Integral(x_**S(2)/sqrt(a_ + x_**S(4)*WC('b', S(1))), x_), cons2, cons3, cons483) rule798 = ReplacementRule(pattern798, With798) def With799(x, a, b): r = Numer(Rt(b/a, S(3))) s = Denom(Rt(b/a, S(3))) rubi.append(799) return -Dist(S(1)/(S(2)*r**S(2)), Int((-S(2)*r**S(2)*x**S(4) + s**S(2)*(S(-1) + sqrt(S(3))))/sqrt(a + b*x**S(6)), x), x) + Dist(s**S(2)*(S(-1) + sqrt(S(3)))/(S(2)*r**S(2)), Int(S(1)/sqrt(a + b*x**S(6)), x), x) pattern799 = Pattern(Integral(x_**S(4)/sqrt(a_ + x_**S(6)*WC('b', S(1))), x_), cons2, cons3, cons67) rule799 = ReplacementRule(pattern799, With799) pattern800 = Pattern(Integral(x_**S(2)/sqrt(a_ + x_**S(8)*WC('b', S(1))), x_), cons2, cons3, cons67) def replacement800(x, a, b): rubi.append(800) return -Dist(S(1)/(S(2)*Rt(b/a, S(4))), Int((-x**S(2)*Rt(b/a, S(4)) + S(1))/sqrt(a + b*x**S(8)), x), x) + Dist(S(1)/(S(2)*Rt(b/a, S(4))), Int((x**S(2)*Rt(b/a, S(4)) + S(1))/sqrt(a + b*x**S(8)), x), x) rule800 = ReplacementRule(pattern800, replacement800) pattern801 = Pattern(Integral(x_**S(2)/(a_ + x_**S(4)*WC('b', S(1)))**(S(1)/4), x_), cons2, cons3, cons466) def replacement801(x, a, b): rubi.append(801) return -Dist(a/S(2), Int(x**S(2)/(a + b*x**S(4))**(S(5)/4), x), x) + Simp(x**S(3)/(S(2)*(a + b*x**S(4))**(S(1)/4)), x) rule801 = ReplacementRule(pattern801, replacement801) pattern802 = Pattern(Integral(x_**S(2)/(a_ + x_**S(4)*WC('b', S(1)))**(S(1)/4), x_), cons2, cons3, cons483) def replacement802(x, a, b): rubi.append(802) return Dist(a/(S(2)*b), Int(S(1)/(x**S(2)*(a + b*x**S(4))**(S(1)/4)), x), x) + Simp((a + b*x**S(4))**(S(3)/4)/(S(2)*b*x), x) rule802 = ReplacementRule(pattern802, replacement802) pattern803 = Pattern(Integral(S(1)/(x_**S(2)*(a_ + x_**S(4)*WC('b', S(1)))**(S(1)/4)), x_), cons2, cons3, cons466) def replacement803(x, a, b): rubi.append(803) return -Dist(b, Int(x**S(2)/(a + b*x**S(4))**(S(5)/4), x), x) - Simp(S(1)/(x*(a + b*x**S(4))**(S(1)/4)), x) rule803 = ReplacementRule(pattern803, replacement803) pattern804 = Pattern(Integral(S(1)/(x_**S(2)*(a_ + x_**S(4)*WC('b', S(1)))**(S(1)/4)), x_), cons2, cons3, cons483) def replacement804(x, a, b): rubi.append(804) return Dist(x*(a/(b*x**S(4)) + S(1))**(S(1)/4)/(a + b*x**S(4))**(S(1)/4), Int(S(1)/(x**S(3)*(a/(b*x**S(4)) + S(1))**(S(1)/4)), x), x) rule804 = ReplacementRule(pattern804, replacement804) pattern805 = Pattern(Integral(sqrt(c_*x_)/(a_ + x_**S(2)*WC('b', S(1)))**(S(1)/4), x_), cons2, cons3, cons7, cons466) def replacement805(x, c, b, a): rubi.append(805) return -Dist(a/S(2), Int(sqrt(c*x)/(a + b*x**S(2))**(S(5)/4), x), x) + Simp(x*sqrt(c*x)/(a + b*x**S(2))**(S(1)/4), x) rule805 = ReplacementRule(pattern805, replacement805) pattern806 = Pattern(Integral(sqrt(c_*x_)/(a_ + x_**S(2)*WC('b', S(1)))**(S(1)/4), x_), cons2, cons3, cons7, cons483) def replacement806(x, c, b, a): rubi.append(806) return Dist(a*c**S(2)/(S(2)*b), Int(S(1)/((c*x)**(S(3)/2)*(a + b*x**S(2))**(S(1)/4)), x), x) + Simp(c*(a + b*x**S(2))**(S(3)/4)/(b*sqrt(c*x)), x) rule806 = ReplacementRule(pattern806, replacement806) pattern807 = Pattern(Integral(S(1)/((x_*WC('c', S(1)))**(S(3)/2)*(a_ + x_**S(2)*WC('b', S(1)))**(S(1)/4)), x_), cons2, cons3, cons7, cons466) def replacement807(x, c, b, a): rubi.append(807) return -Dist(b/c**S(2), Int(sqrt(c*x)/(a + b*x**S(2))**(S(5)/4), x), x) + Simp(-S(2)/(c*sqrt(c*x)*(a + b*x**S(2))**(S(1)/4)), x) rule807 = ReplacementRule(pattern807, replacement807) pattern808 = Pattern(Integral(S(1)/((x_*WC('c', S(1)))**(S(3)/2)*(a_ + x_**S(2)*WC('b', S(1)))**(S(1)/4)), x_), cons2, cons3, cons7, cons483) def replacement808(x, c, b, a): rubi.append(808) return Dist(sqrt(c*x)*(a/(b*x**S(2)) + S(1))**(S(1)/4)/(c**S(2)*(a + b*x**S(2))**(S(1)/4)), Int(S(1)/(x**S(2)*(a/(b*x**S(2)) + S(1))**(S(1)/4)), x), x) rule808 = ReplacementRule(pattern808, replacement808) pattern809 = Pattern(Integral((x_*WC('c', S(1)))**m_*(a_ + x_**n_*WC('b', S(1)))**p_, x_), cons2, cons3, cons7, cons5, cons148, cons31, cons530, cons512, cons509) def replacement809(p, m, b, c, a, n, x): rubi.append(809) return -Dist(a*c**n*(m - n + S(1))/(b*(m + n*p + S(1))), Int((c*x)**(m - n)*(a + b*x**n)**p, x), x) + Simp(c**(n + S(-1))*(c*x)**(m - n + S(1))*(a + b*x**n)**(p + S(1))/(b*(m + n*p + S(1))), x) rule809 = ReplacementRule(pattern809, replacement809) pattern810 = Pattern(Integral((x_*WC('c', S(1)))**m_*(a_ + x_**n_*WC('b', S(1)))**p_, x_), cons2, cons3, cons7, cons21, cons5, cons148, cons531, cons512, cons532) def replacement810(p, m, b, c, a, n, x): rubi.append(810) return -Dist(a*c**n*(m - n + S(1))/(b*(m + n*p + S(1))), Int((c*x)**(m - n)*(a + b*x**n)**p, x), x) + Simp(c**(n + S(-1))*(c*x)**(m - n + S(1))*(a + b*x**n)**(p + S(1))/(b*(m + n*p + S(1))), x) rule810 = ReplacementRule(pattern810, replacement810) pattern811 = Pattern(Integral((x_*WC('c', S(1)))**m_*(a1_ + x_**n_*WC('b1', S(1)))**p_*(a2_ + x_**n_*WC('b2', S(1)))**p_, x_), cons57, cons58, cons59, cons60, cons7, cons5, cons55, cons495, cons31, cons529, cons510, cons511) def replacement811(p, a2, m, b2, b1, c, n, x, a1): rubi.append(811) return -Dist(a1*a2*c**(S(2)*n)*(m - S(2)*n + S(1))/(b1*b2*(m + S(2)*n*p + S(1))), Int((c*x)**(m - S(2)*n)*(a1 + b1*x**n)**p*(a2 + b2*x**n)**p, x), x) + Simp(c**(S(2)*n + S(-1))*(c*x)**(m - S(2)*n + S(1))*(a1 + b1*x**n)**(p + S(1))*(a2 + b2*x**n)**(p + S(1))/(b1*b2*(m + S(2)*n*p + S(1))), x) rule811 = ReplacementRule(pattern811, replacement811) pattern812 = Pattern(Integral((x_*WC('c', S(1)))**m_*(a1_ + x_**n_*WC('b1', S(1)))**p_*(a2_ + x_**n_*WC('b2', S(1)))**p_, x_), cons57, cons58, cons59, cons60, cons7, cons21, cons5, cons55, cons495, cons533, cons510, cons534) def replacement812(p, a2, m, b2, b1, c, n, x, a1): rubi.append(812) return -Dist(a1*a2*c**(S(2)*n)*(m - S(2)*n + S(1))/(b1*b2*(m + S(2)*n*p + S(1))), Int((c*x)**(m - S(2)*n)*(a1 + b1*x**n)**p*(a2 + b2*x**n)**p, x), x) + Simp(c**(S(2)*n + S(-1))*(c*x)**(m - S(2)*n + S(1))*(a1 + b1*x**n)**(p + S(1))*(a2 + b2*x**n)**(p + S(1))/(b1*b2*(m + S(2)*n*p + S(1))), x) rule812 = ReplacementRule(pattern812, replacement812) pattern813 = Pattern(Integral((x_*WC('c', S(1)))**m_*(a_ + x_**n_*WC('b', S(1)))**p_, x_), cons2, cons3, cons7, cons5, cons148, cons31, cons94, cons509) def replacement813(p, m, b, c, a, n, x): rubi.append(813) return -Dist(b*c**(-n)*(m + n*(p + S(1)) + S(1))/(a*(m + S(1))), Int((c*x)**(m + n)*(a + b*x**n)**p, x), x) + Simp((c*x)**(m + S(1))*(a + b*x**n)**(p + S(1))/(a*c*(m + S(1))), x) rule813 = ReplacementRule(pattern813, replacement813) pattern814 = Pattern(Integral((x_*WC('c', S(1)))**m_*(a_ + x_**n_*WC('b', S(1)))**p_, x_), cons2, cons3, cons7, cons21, cons5, cons148, cons535, cons532) def replacement814(p, m, b, c, a, n, x): rubi.append(814) return -Dist(b*c**(-n)*(m + n*(p + S(1)) + S(1))/(a*(m + S(1))), Int((c*x)**(m + n)*(a + b*x**n)**p, x), x) + Simp((c*x)**(m + S(1))*(a + b*x**n)**(p + S(1))/(a*c*(m + S(1))), x) rule814 = ReplacementRule(pattern814, replacement814) pattern815 = Pattern(Integral((x_*WC('c', S(1)))**m_*(a1_ + x_**n_*WC('b1', S(1)))**p_*(a2_ + x_**n_*WC('b2', S(1)))**p_, x_), cons57, cons58, cons59, cons60, cons7, cons5, cons55, cons495, cons31, cons94, cons511) def replacement815(p, a2, m, b2, b1, c, n, x, a1): rubi.append(815) return -Dist(b1*b2*c**(-S(2)*n)*(m + S(2)*n*(p + S(1)) + S(1))/(a1*a2*(m + S(1))), Int((c*x)**(m + S(2)*n)*(a1 + b1*x**n)**p*(a2 + b2*x**n)**p, x), x) + Simp((c*x)**(m + S(1))*(a1 + b1*x**n)**(p + S(1))*(a2 + b2*x**n)**(p + S(1))/(a1*a2*c*(m + S(1))), x) rule815 = ReplacementRule(pattern815, replacement815) pattern816 = Pattern(Integral((x_*WC('c', S(1)))**m_*(a1_ + x_**n_*WC('b1', S(1)))**p_*(a2_ + x_**n_*WC('b2', S(1)))**p_, x_), cons57, cons58, cons59, cons60, cons7, cons21, cons5, cons55, cons495, cons536, cons534) def replacement816(p, a2, m, b2, b1, c, n, x, a1): rubi.append(816) return -Dist(b1*b2*c**(-S(2)*n)*(m + S(2)*n*(p + S(1)) + S(1))/(a1*a2*(m + S(1))), Int((c*x)**(m + S(2)*n)*(a1 + b1*x**n)**p*(a2 + b2*x**n)**p, x), x) + Simp((c*x)**(m + S(1))*(a1 + b1*x**n)**(p + S(1))*(a2 + b2*x**n)**(p + S(1))/(a1*a2*c*(m + S(1))), x) rule816 = ReplacementRule(pattern816, replacement816) def With817(p, m, b, c, a, n, x): k = Denominator(m) rubi.append(817) return Dist(k/c, Subst(Int(x**(k*(m + S(1)) + S(-1))*(a + b*c**(-n)*x**(k*n))**p, x), x, (c*x)**(S(1)/k)), x) pattern817 = Pattern(Integral((x_*WC('c', S(1)))**m_*(a_ + x_**n_*WC('b', S(1)))**p_, x_), cons2, cons3, cons7, cons5, cons148, cons367, cons509) rule817 = ReplacementRule(pattern817, With817) def With818(p, a2, m, b2, b1, c, n, x, a1): k = Denominator(m) rubi.append(818) return Dist(k/c, Subst(Int(x**(k*(m + S(1)) + S(-1))*(a1 + b1*c**(-n)*x**(k*n))**p*(a2 + b2*c**(-n)*x**(k*n))**p, x), x, (c*x)**(S(1)/k)), x) pattern818 = Pattern(Integral((x_*WC('c', S(1)))**m_*(a1_ + x_**n_*WC('b1', S(1)))**p_*(a2_ + x_**n_*WC('b2', S(1)))**p_, x_), cons57, cons58, cons59, cons60, cons7, cons5, cons55, cons495, cons367, cons511) rule818 = ReplacementRule(pattern818, With818) pattern819 = Pattern(Integral(x_**WC('m', S(1))*(a_ + x_**n_*WC('b', S(1)))**p_, x_), cons2, cons3, cons148, cons13, cons485, cons486, cons537) def replacement819(p, m, b, a, n, x): rubi.append(819) return Dist(a**(p + (m + S(1))/n), Subst(Int(x**m*(-b*x**n + S(1))**(-p + S(-1) - (m + S(1))/n), x), x, x*(a + b*x**n)**(-S(1)/n)), x) rule819 = ReplacementRule(pattern819, replacement819) pattern820 = Pattern(Integral(x_**WC('m', S(1))*(a1_ + x_**n_*WC('b1', S(1)))**p_*(a2_ + x_**n_*WC('b2', S(1)))**p_, x_), cons57, cons58, cons59, cons60, cons55, cons495, cons13, cons485, cons486, cons538) def replacement820(p, a2, m, b2, b1, n, x, a1): rubi.append(820) return Dist((a1*a2)**(p + (m + S(1))/(S(2)*n)), Subst(Int(x**m*(-b1*x**n + S(1))**(-p + S(-1) - (m + S(1))/(S(2)*n))*(-b2*x**n + S(1))**(-p + S(-1) - (m + S(1))/(S(2)*n)), x), x, x*(a1 + b1*x**n)**(-S(1)/(S(2)*n))*(a2 + b2*x**n)**(-S(1)/(S(2)*n))), x) rule820 = ReplacementRule(pattern820, replacement820) pattern821 = Pattern(Integral(x_**WC('m', S(1))*(a_ + x_**n_*WC('b', S(1)))**p_, x_), cons2, cons3, cons148, cons13, cons485, cons486, cons17, cons539) def replacement821(p, m, b, a, n, x): rubi.append(821) return Dist((a/(a + b*x**n))**(p + (m + S(1))/n)*(a + b*x**n)**(p + (m + S(1))/n), Subst(Int(x**m*(-b*x**n + S(1))**(-p + S(-1) - (m + S(1))/n), x), x, x*(a + b*x**n)**(-S(1)/n)), x) rule821 = ReplacementRule(pattern821, replacement821) pattern822 = Pattern(Integral(x_**WC('m', S(1))*(a1_ + x_**n_*WC('b1', S(1)))**p_*(a2_ + x_**n_*WC('b2', S(1)))**p_, x_), cons57, cons58, cons59, cons60, cons55, cons495, cons13, cons485, cons486, cons17, cons540) def replacement822(p, a2, m, b2, b1, n, x, a1): rubi.append(822) return Dist((a1/(a1 + b1*x**n))**(p + (m + S(1))/(S(2)*n))*(a2/(a2 + b2*x**n))**(p + (m + S(1))/(S(2)*n))*(a1 + b1*x**n)**(p + (m + S(1))/(S(2)*n))*(a2 + b2*x**n)**(p + (m + S(1))/(S(2)*n)), Subst(Int(x**m*(-b1*x**n + S(1))**(-p + S(-1) - (m + S(1))/(S(2)*n))*(-b2*x**n + S(1))**(-p + S(-1) - (m + S(1))/(S(2)*n)), x), x, x*(a1 + b1*x**n)**(-S(1)/(S(2)*n))*(a2 + b2*x**n)**(-S(1)/(S(2)*n))), x) rule822 = ReplacementRule(pattern822, replacement822) pattern823 = Pattern(Integral(x_**WC('m', S(1))*(a_ + x_**n_*WC('b', S(1)))**p_, x_), cons2, cons3, cons5, cons196, cons17) def replacement823(p, m, b, a, n, x): rubi.append(823) return -Subst(Int(x**(-m + S(-2))*(a + b*x**(-n))**p, x), x, S(1)/x) rule823 = ReplacementRule(pattern823, replacement823) pattern824 = Pattern(Integral(x_**WC('m', S(1))*(a1_ + x_**n_*WC('b1', S(1)))**p_*(a2_ + x_**n_*WC('b2', S(1)))**p_, x_), cons57, cons58, cons59, cons60, cons5, cons55, cons497, cons17) def replacement824(p, a2, m, b2, b1, n, x, a1): rubi.append(824) return -Subst(Int(x**(-m + S(-2))*(a1 + b1*x**(-n))**p*(a2 + b2*x**(-n))**p, x), x, S(1)/x) rule824 = ReplacementRule(pattern824, replacement824) def With825(p, m, b, c, a, n, x): k = Denominator(m) rubi.append(825) return -Dist(k/c, Subst(Int(x**(-k*(m + S(1)) + S(-1))*(a + b*c**(-n)*x**(-k*n))**p, x), x, (c*x)**(-S(1)/k)), x) pattern825 = Pattern(Integral((x_*WC('c', S(1)))**m_*(a_ + x_**n_*WC('b', S(1)))**p_, x_), cons2, cons3, cons7, cons5, cons196, cons367) rule825 = ReplacementRule(pattern825, With825) def With826(p, a2, m, b2, b1, c, n, x, a1): k = Denominator(m) rubi.append(826) return -Dist(k/c, Subst(Int(x**(-k*(m + S(1)) + S(-1))*(a1 + b1*c**(-n)*x**(-k*n))**p*(a2 + b2*c**(-n)*x**(-k*n))**p, x), x, (c*x)**(-S(1)/k)), x) pattern826 = Pattern(Integral((x_*WC('c', S(1)))**m_*(a1_ + x_**n_*WC('b1', S(1)))**p_*(a2_ + x_**n_*WC('b2', S(1)))**p_, x_), cons57, cons58, cons59, cons60, cons7, cons5, cons55, cons497, cons367) rule826 = ReplacementRule(pattern826, With826) pattern827 = Pattern(Integral((x_*WC('c', S(1)))**m_*(a_ + x_**n_*WC('b', S(1)))**p_, x_), cons2, cons3, cons7, cons21, cons5, cons196, cons356) def replacement827(p, m, b, c, a, n, x): rubi.append(827) return -Dist((c*x)**m*(S(1)/x)**m, Subst(Int(x**(-m + S(-2))*(a + b*x**(-n))**p, x), x, S(1)/x), x) rule827 = ReplacementRule(pattern827, replacement827) pattern828 = Pattern(Integral((x_*WC('c', S(1)))**m_*(a1_ + x_**n_*WC('b1', S(1)))**p_*(a2_ + x_**n_*WC('b2', S(1)))**p_, x_), cons57, cons58, cons59, cons60, cons7, cons21, cons5, cons55, cons497, cons356) def replacement828(p, a2, m, b2, b1, c, n, x, a1): rubi.append(828) return -Dist((c*x)**m*(S(1)/x)**m, Subst(Int(x**(-m + S(-2))*(a1 + b1*x**(-n))**p*(a2 + b2*x**(-n))**p, x), x, S(1)/x), x) rule828 = ReplacementRule(pattern828, replacement828) def With829(p, m, b, a, n, x): k = Denominator(n) rubi.append(829) return Dist(k, Subst(Int(x**(k*(m + S(1)) + S(-1))*(a + b*x**(k*n))**p, x), x, x**(S(1)/k)), x) pattern829 = Pattern(Integral(x_**WC('m', S(1))*(a_ + x_**n_*WC('b', S(1)))**p_, x_), cons2, cons3, cons21, cons5, cons489) rule829 = ReplacementRule(pattern829, With829) def With830(p, a2, m, b2, b1, n, x, a1): k = Denominator(S(2)*n) rubi.append(830) return Dist(k, Subst(Int(x**(k*(m + S(1)) + S(-1))*(a1 + b1*x**(k*n))**p*(a2 + b2*x**(k*n))**p, x), x, x**(S(1)/k)), x) pattern830 = Pattern(Integral(x_**WC('m', S(1))*(a1_ + x_**n_*WC('b1', S(1)))**p_*(a2_ + x_**n_*WC('b2', S(1)))**p_, x_), cons57, cons58, cons59, cons60, cons21, cons5, cons55, cons498) rule830 = ReplacementRule(pattern830, With830) pattern831 = Pattern(Integral((c_*x_)**m_*(a_ + x_**n_*WC('b', S(1)))**p_, x_), cons2, cons3, cons7, cons21, cons5, cons489) def replacement831(p, m, b, c, a, n, x): rubi.append(831) return Dist(c**IntPart(m)*x**(-FracPart(m))*(c*x)**FracPart(m), Int(x**m*(a + b*x**n)**p, x), x) rule831 = ReplacementRule(pattern831, replacement831) pattern832 = Pattern(Integral((c_*x_)**m_*(a1_ + x_**n_*WC('b1', S(1)))**p_*(a2_ + x_**n_*WC('b2', S(1)))**p_, x_), cons57, cons58, cons59, cons60, cons7, cons21, cons5, cons55, cons498) def replacement832(p, a2, m, b2, b1, c, n, x, a1): rubi.append(832) return Dist(c**IntPart(m)*x**(-FracPart(m))*(c*x)**FracPart(m), Int(x**m*(a1 + b1*x**n)**p*(a2 + b2*x**n)**p, x), x) rule832 = ReplacementRule(pattern832, replacement832) pattern833 = Pattern(Integral(x_**WC('m', S(1))*(a_ + x_**n_*WC('b', S(1)))**p_, x_), cons2, cons3, cons21, cons4, cons5, cons541, cons23) def replacement833(p, m, b, a, n, x): rubi.append(833) return Dist(S(1)/(m + S(1)), Subst(Int((a + b*x**(n/(m + S(1))))**p, x), x, x**(m + S(1))), x) rule833 = ReplacementRule(pattern833, replacement833) pattern834 = Pattern(Integral(x_**WC('m', S(1))*(a1_ + x_**n_*WC('b1', S(1)))**p_*(a2_ + x_**n_*WC('b2', S(1)))**p_, x_), cons57, cons58, cons59, cons60, cons21, cons4, cons5, cons55, cons542, cons543) def replacement834(p, a2, m, b2, b1, n, x, a1): rubi.append(834) return Dist(S(1)/(m + S(1)), Subst(Int((a1 + b1*x**(n/(m + S(1))))**p*(a2 + b2*x**(n/(m + S(1))))**p, x), x, x**(m + S(1))), x) rule834 = ReplacementRule(pattern834, replacement834) pattern835 = Pattern(Integral((c_*x_)**m_*(a_ + x_**n_*WC('b', S(1)))**p_, x_), cons2, cons3, cons7, cons21, cons4, cons5, cons541, cons23) def replacement835(p, m, b, c, a, n, x): rubi.append(835) return Dist(c**IntPart(m)*x**(-FracPart(m))*(c*x)**FracPart(m), Int(x**m*(a + b*x**n)**p, x), x) rule835 = ReplacementRule(pattern835, replacement835) pattern836 = Pattern(Integral((c_*x_)**m_*(a1_ + x_**n_*WC('b1', S(1)))**p_*(a2_ + x_**n_*WC('b2', S(1)))**p_, x_), cons57, cons58, cons59, cons60, cons7, cons21, cons4, cons5, cons55, cons542, cons543) def replacement836(p, a2, m, b2, b1, c, n, x, a1): rubi.append(836) return Dist(c**IntPart(m)*x**(-FracPart(m))*(c*x)**FracPart(m), Int(x**m*(a1 + b1*x**n)**p*(a2 + b2*x**n)**p, x), x) rule836 = ReplacementRule(pattern836, replacement836) pattern837 = Pattern(Integral(x_**WC('m', S(1))*(a_ + x_**n_*WC('b', S(1)))**p_, x_), cons2, cons3, cons21, cons4, cons544, cons13, cons163) def replacement837(p, m, b, a, n, x): rubi.append(837) return -Dist(b*n*p/(m + S(1)), Int(x**(m + n)*(a + b*x**n)**(p + S(-1)), x), x) + Simp(x**(m + S(1))*(a + b*x**n)**p/(m + S(1)), x) rule837 = ReplacementRule(pattern837, replacement837) pattern838 = Pattern(Integral(x_**WC('m', S(1))*(a1_ + x_**n_*WC('b1', S(1)))**p_*(a2_ + x_**n_*WC('b2', S(1)))**p_, x_), cons57, cons58, cons59, cons60, cons21, cons4, cons55, cons545, cons13, cons163) def replacement838(p, a2, m, b2, b1, n, x, a1): rubi.append(838) return -Dist(S(2)*b1*b2*n*p/(m + S(1)), Int(x**(m + n)*(a1 + b1*x**n)**(p + S(-1))*(a2 + b2*x**n)**(p + S(-1)), x), x) + Simp(x**(m + S(1))*(a1 + b1*x**n)**p*(a2 + b2*x**n)**p/(m + S(1)), x) rule838 = ReplacementRule(pattern838, replacement838) pattern839 = Pattern(Integral((c_*x_)**m_*(a_ + x_**n_*WC('b', S(1)))**p_, x_), cons2, cons3, cons7, cons21, cons4, cons544, cons13, cons163) def replacement839(p, m, b, c, a, n, x): rubi.append(839) return Dist(c**IntPart(m)*x**(-FracPart(m))*(c*x)**FracPart(m), Int(x**m*(a + b*x**n)**p, x), x) rule839 = ReplacementRule(pattern839, replacement839) pattern840 = Pattern(Integral((c_*x_)**m_*(a1_ + x_**n_*WC('b1', S(1)))**p_*(a2_ + x_**n_*WC('b2', S(1)))**p_, x_), cons57, cons58, cons59, cons60, cons7, cons21, cons4, cons55, cons545, cons13, cons163) def replacement840(p, a2, m, b2, b1, c, n, x, a1): rubi.append(840) return Dist(c**IntPart(m)*x**(-FracPart(m))*(c*x)**FracPart(m), Int(x**m*(a1 + b1*x**n)**p*(a2 + b2*x**n)**p, x), x) rule840 = ReplacementRule(pattern840, replacement840) pattern841 = Pattern(Integral((x_*WC('c', S(1)))**WC('m', S(1))*(a_ + x_**n_*WC('b', S(1)))**p_, x_), cons2, cons3, cons7, cons21, cons4, cons546, cons13, cons163, cons512) def replacement841(p, m, b, c, a, n, x): rubi.append(841) return Dist(a*n*p/(m + n*p + S(1)), Int((c*x)**m*(a + b*x**n)**(p + S(-1)), x), x) + Simp((c*x)**(m + S(1))*(a + b*x**n)**p/(c*(m + n*p + S(1))), x) rule841 = ReplacementRule(pattern841, replacement841) pattern842 = Pattern(Integral((x_*WC('c', S(1)))**WC('m', S(1))*(a1_ + x_**n_*WC('b1', S(1)))**p_*(a2_ + x_**n_*WC('b2', S(1)))**p_, x_), cons57, cons58, cons59, cons60, cons7, cons21, cons4, cons55, cons547, cons13, cons163, cons510) def replacement842(p, a2, m, b2, b1, c, n, x, a1): rubi.append(842) return Dist(S(2)*a1*a2*n*p/(m + S(2)*n*p + S(1)), Int((c*x)**m*(a1 + b1*x**n)**(p + S(-1))*(a2 + b2*x**n)**(p + S(-1)), x), x) + Simp((c*x)**(m + S(1))*(a1 + b1*x**n)**p*(a2 + b2*x**n)**p/(c*(m + S(2)*n*p + S(1))), x) rule842 = ReplacementRule(pattern842, replacement842) def With843(p, m, b, a, n, x): k = Denominator(p) rubi.append(843) return Dist(a**(p + (m + S(1))/n)*k/n, Subst(Int(x**(k*(m + S(1))/n + S(-1))*(-b*x**k + S(1))**(-p + S(-1) - (m + S(1))/n), x), x, x**(n/k)*(a + b*x**n)**(-S(1)/k)), x) pattern843 = Pattern(Integral(x_**WC('m', S(1))*(a_ + x_**n_*WC('b', S(1)))**p_, x_), cons2, cons3, cons21, cons4, cons546, cons13, cons485) rule843 = ReplacementRule(pattern843, With843) def With844(p, a2, m, b2, b1, n, x, a1): k = Denominator(p) rubi.append(844) return Dist(k*(a1*a2)**(p + (m + S(1))/(S(2)*n))/(S(2)*n), Subst(Int(x**(k*(m + S(1))/(S(2)*n) + S(-1))*(-b1*x**k + S(1))**(-p + S(-1) - (m + S(1))/(S(2)*n))*(-b2*x**k + S(1))**(-p + S(-1) - (m + S(1))/(S(2)*n)), x), x, x**(S(2)*n/k)*(a1 + b1*x**n)**(-S(1)/k)*(a2 + b2*x**n)**(-S(1)/k)), x) pattern844 = Pattern(Integral(x_**WC('m', S(1))*(a1_ + x_**n_*WC('b1', S(1)))**p_*(a2_ + x_**n_*WC('b2', S(1)))**p_, x_), cons57, cons58, cons59, cons60, cons21, cons4, cons55, cons547, cons13, cons485) rule844 = ReplacementRule(pattern844, With844) pattern845 = Pattern(Integral((c_*x_)**m_*(a_ + x_**n_*WC('b', S(1)))**p_, x_), cons2, cons3, cons7, cons21, cons4, cons546, cons13, cons485) def replacement845(p, m, b, c, a, n, x): rubi.append(845) return Dist(c**IntPart(m)*x**(-FracPart(m))*(c*x)**FracPart(m), Int(x**m*(a + b*x**n)**p, x), x) rule845 = ReplacementRule(pattern845, replacement845) pattern846 = Pattern(Integral((c_*x_)**m_*(a1_ + x_**n_*WC('b1', S(1)))**p_*(a2_ + x_**n_*WC('b2', S(1)))**p_, x_), cons57, cons58, cons59, cons60, cons7, cons21, cons4, cons55, cons547, cons13, cons485) def replacement846(p, a2, m, b2, b1, c, n, x, a1): rubi.append(846) return Dist(c**IntPart(m)*x**(-FracPart(m))*(c*x)**FracPart(m), Int(x**m*(a1 + b1*x**n)**p*(a2 + b2*x**n)**p, x), x) rule846 = ReplacementRule(pattern846, replacement846) pattern847 = Pattern(Integral((x_*WC('c', S(1)))**WC('m', S(1))*(a_ + x_**n_*WC('b', S(1)))**p_, x_), cons2, cons3, cons7, cons21, cons4, cons546, cons13, cons137) def replacement847(p, m, b, c, a, n, x): rubi.append(847) return Dist((m + n*(p + S(1)) + S(1))/(a*n*(p + S(1))), Int((c*x)**m*(a + b*x**n)**(p + S(1)), x), x) - Simp((c*x)**(m + S(1))*(a + b*x**n)**(p + S(1))/(a*c*n*(p + S(1))), x) rule847 = ReplacementRule(pattern847, replacement847) pattern848 = Pattern(Integral((x_*WC('c', S(1)))**WC('m', S(1))*(a1_ + x_**n_*WC('b1', S(1)))**p_*(a2_ + x_**n_*WC('b2', S(1)))**p_, x_), cons57, cons58, cons59, cons60, cons7, cons21, cons4, cons55, cons546, cons13, cons137) def replacement848(p, a2, m, b2, b1, c, n, x, a1): rubi.append(848) return Dist((m + S(2)*n*(p + S(1)) + S(1))/(S(2)*a1*a2*n*(p + S(1))), Int((c*x)**m*(a1 + b1*x**n)**(p + S(1))*(a2 + b2*x**n)**(p + S(1)), x), x) - Simp((c*x)**(m + S(1))*(a1 + b1*x**n)**(p + S(1))*(a2 + b2*x**n)**(p + S(1))/(S(2)*a1*a2*c*n*(p + S(1))), x) rule848 = ReplacementRule(pattern848, replacement848) def With849(m, b, a, n, x): mn = m - n rubi.append(849) return -Dist(a/b, Int(x**mn/(a + b*x**n), x), x) + Simp(x**(mn + S(1))/(b*(mn + S(1))), x) pattern849 = Pattern(Integral(x_**WC('m', S(1))/(a_ + x_**n_*WC('b', S(1))), x_), cons2, cons3, cons21, cons4, cons548, cons531) rule849 = ReplacementRule(pattern849, With849) pattern850 = Pattern(Integral(x_**m_/(a_ + x_**n_*WC('b', S(1))), x_), cons2, cons3, cons21, cons4, cons548, cons535) def replacement850(m, b, a, n, x): rubi.append(850) return -Dist(b/a, Int(x**(m + n)/(a + b*x**n), x), x) + Simp(x**(m + S(1))/(a*(m + S(1))), x) rule850 = ReplacementRule(pattern850, replacement850) pattern851 = Pattern(Integral((c_*x_)**m_/(a_ + x_**n_*WC('b', S(1))), x_), cons2, cons3, cons7, cons21, cons4, cons548, cons549) def replacement851(m, b, c, a, n, x): rubi.append(851) return Dist(c**IntPart(m)*x**(-FracPart(m))*(c*x)**FracPart(m), Int(x**m/(a + b*x**n), x), x) rule851 = ReplacementRule(pattern851, replacement851) pattern852 = Pattern(Integral((x_*WC('c', S(1)))**WC('m', S(1))*(a_ + x_**n_*WC('b', S(1)))**p_, x_), cons2, cons3, cons7, cons21, cons4, cons5, cons357, cons550) def replacement852(p, m, b, c, a, n, x): rubi.append(852) return Simp(a**p*(c*x)**(m + S(1))*Hypergeometric2F1(-p, (m + S(1))/n, S(1) + (m + S(1))/n, -b*x**n/a)/(c*(m + S(1))), x) rule852 = ReplacementRule(pattern852, replacement852) pattern853 = Pattern(Integral((x_*WC('c', S(1)))**WC('m', S(1))*(a_ + x_**n_*WC('b', S(1)))**p_, x_), cons2, cons3, cons7, cons21, cons4, cons5, cons357, cons551) def replacement853(p, m, b, c, a, n, x): rubi.append(853) return Dist(a**IntPart(p)*(S(1) + b*x**n/a)**(-FracPart(p))*(a + b*x**n)**FracPart(p), Int((c*x)**m*(S(1) + b*x**n/a)**p, x), x) rule853 = ReplacementRule(pattern853, replacement853) pattern854 = Pattern(Integral(x_**WC('m', S(1))*(a_ + v_**n_*WC('b', S(1)))**WC('p', S(1)), x_), cons2, cons3, cons4, cons5, cons552, cons17, cons553) def replacement854(v, p, m, b, a, n, x): rubi.append(854) return Dist(Coefficient(v, x, S(1))**(-m + S(-1)), Subst(Int(SimplifyIntegrand((a + b*x**n)**p*(x - Coefficient(v, x, S(0)))**m, x), x), x, v), x) rule854 = ReplacementRule(pattern854, replacement854) pattern855 = Pattern(Integral(u_**WC('m', S(1))*(a_ + v_**n_*WC('b', S(1)))**WC('p', S(1)), x_), cons2, cons3, cons21, cons4, cons5, cons554) def replacement855(v, p, u, m, b, a, n, x): rubi.append(855) return Dist(u**m*v**(-m)/Coefficient(v, x, S(1)), Subst(Int(x**m*(a + b*x**n)**p, x), x, v), x) rule855 = ReplacementRule(pattern855, replacement855) pattern856 = Pattern(Integral((x_*WC('c', S(1)))**WC('m', S(1))*(a1_ + x_**n_*WC('b1', S(1)))**p_*(a2_ + x_**n_*WC('b2', S(1)))**p_, x_), cons57, cons58, cons59, cons60, cons7, cons21, cons4, cons5, cons55, cons147) def replacement856(p, a2, m, b2, b1, c, n, x, a1): rubi.append(856) return Dist((a1 + b1*x**n)**FracPart(p)*(a2 + b2*x**n)**FracPart(p)*(a1*a2 + b1*b2*x**(S(2)*n))**(-FracPart(p)), Int((c*x)**m*(a1*a2 + b1*b2*x**(S(2)*n))**p, x), x) rule856 = ReplacementRule(pattern856, replacement856) pattern857 = Pattern(Integral((a_ + x_**n_*WC('b', S(1)))**WC('p', S(1))*(c_ + x_**n_*WC('d', S(1)))**WC('q', S(1)), x_), cons2, cons3, cons7, cons27, cons4, cons71, cons555) def replacement857(p, b, d, a, n, c, x, q): rubi.append(857) return Int(ExpandIntegrand((a + b*x**n)**p*(c + d*x**n)**q, x), x) rule857 = ReplacementRule(pattern857, replacement857) pattern858 = Pattern(Integral((a_ + x_**n_*WC('b', S(1)))**WC('p', S(1))*(c_ + x_**n_*WC('d', S(1)))**WC('q', S(1)), x_), cons2, cons3, cons7, cons27, cons4, cons71, cons220, cons502) def replacement858(p, b, d, a, n, c, x, q): rubi.append(858) return Int(x**(n*(p + q))*(a*x**(-n) + b)**p*(c*x**(-n) + d)**q, x) rule858 = ReplacementRule(pattern858, replacement858) pattern859 = Pattern(Integral((a_ + x_**n_*WC('b', S(1)))**WC('p', S(1))*(c_ + x_**n_*WC('d', S(1)))**WC('q', S(1)), x_), cons2, cons3, cons7, cons27, cons5, cons50, cons71, cons196) def replacement859(p, b, d, a, n, c, x, q): rubi.append(859) return -Subst(Int((a + b*x**(-n))**p*(c + d*x**(-n))**q/x**S(2), x), x, S(1)/x) rule859 = ReplacementRule(pattern859, replacement859) def With860(p, b, d, a, n, c, x, q): g = Denominator(n) rubi.append(860) return Dist(g, Subst(Int(x**(g + S(-1))*(a + b*x**(g*n))**p*(c + d*x**(g*n))**q, x), x, x**(S(1)/g)), x) pattern860 = Pattern(Integral((a_ + x_**n_*WC('b', S(1)))**WC('p', S(1))*(c_ + x_**n_*WC('d', S(1)))**WC('q', S(1)), x_), cons2, cons3, cons7, cons27, cons5, cons50, cons71, cons489) rule860 = ReplacementRule(pattern860, With860) pattern861 = Pattern(Integral((a_ + x_**n_*WC('b', S(1)))**p_/(c_ + x_**n_*WC('d', S(1))), x_), cons2, cons3, cons7, cons27, cons71, cons556, cons85) def replacement861(p, b, d, a, n, c, x): rubi.append(861) return Subst(Int(S(1)/(c - x**n*(-a*d + b*c)), x), x, x*(a + b*x**n)**(-S(1)/n)) rule861 = ReplacementRule(pattern861, replacement861) pattern862 = Pattern(Integral((a_ + x_**n_*WC('b', S(1)))**p_*(c_ + x_**n_*WC('d', S(1)))**WC('q', S(1)), x_), cons2, cons3, cons7, cons27, cons4, cons5, cons71, cons557, cons395, cons403, cons54) def replacement862(p, b, d, a, n, c, x, q): rubi.append(862) return -Dist(c*q/(a*(p + S(1))), Int((a + b*x**n)**(p + S(1))*(c + d*x**n)**(q + S(-1)), x), x) - Simp(x*(a + b*x**n)**(p + S(1))*(c + d*x**n)**q/(a*n*(p + S(1))), x) rule862 = ReplacementRule(pattern862, replacement862) pattern863 = Pattern(Integral((a_ + x_**n_*WC('b', S(1)))**p_*(c_ + x_**n_*WC('d', S(1)))**q_, x_), cons2, cons3, cons7, cons27, cons4, cons50, cons71, cons557, cons63) def replacement863(p, b, d, a, n, c, x, q): rubi.append(863) return Simp(a**p*c**(-p + S(-1))*x*(c + d*x**n)**(-S(1)/n)*Hypergeometric2F1(S(1)/n, -p, S(1) + S(1)/n, -x**n*(-a*d + b*c)/(a*(c + d*x**n))), x) rule863 = ReplacementRule(pattern863, replacement863) pattern864 = Pattern(Integral((a_ + x_**n_*WC('b', S(1)))**p_*(c_ + x_**n_*WC('d', S(1)))**q_, x_), cons2, cons3, cons7, cons27, cons4, cons5, cons50, cons71, cons557) def replacement864(p, b, d, a, n, c, x, q): rubi.append(864) return Simp(x*(c*(a + b*x**n)/(a*(c + d*x**n)))**(-p)*(a + b*x**n)**p*(c + d*x**n)**(-p - S(1)/n)*Hypergeometric2F1(S(1)/n, -p, S(1) + S(1)/n, -x**n*(-a*d + b*c)/(a*(c + d*x**n)))/c, x) rule864 = ReplacementRule(pattern864, replacement864) pattern865 = Pattern(Integral((a_ + x_**n_*WC('b', S(1)))**p_*(c_ + x_**n_*WC('d', S(1)))**q_, x_), cons2, cons3, cons7, cons27, cons4, cons5, cons50, cons71, cons558, cons559) def replacement865(p, b, d, a, n, c, x, q): rubi.append(865) return Simp(x*(a + b*x**n)**(p + S(1))*(c + d*x**n)**(q + S(1))/(a*c), x) rule865 = ReplacementRule(pattern865, replacement865) pattern866 = Pattern(Integral((a_ + x_**n_*WC('b', S(1)))**p_*(c_ + x_**n_*WC('d', S(1)))**q_, x_), cons2, cons3, cons7, cons27, cons4, cons50, cons71, cons558, cons560, cons54) def replacement866(p, b, d, a, n, c, x, q): rubi.append(866) return Dist((b*c + n*(p + S(1))*(-a*d + b*c))/(a*n*(p + S(1))*(-a*d + b*c)), Int((a + b*x**n)**(p + S(1))*(c + d*x**n)**q, x), x) - Simp(b*x*(a + b*x**n)**(p + S(1))*(c + d*x**n)**(q + S(1))/(a*n*(p + S(1))*(-a*d + b*c)), x) rule866 = ReplacementRule(pattern866, replacement866) pattern867 = Pattern(Integral((a_ + x_**n_*WC('b', S(1)))**WC('p', S(1))*(c_ + x_**n_*WC('d', S(1))), x_), cons2, cons3, cons7, cons27, cons4, cons5, cons71, cons561) def replacement867(p, b, d, a, n, c, x): rubi.append(867) return Simp(c*x*(a + b*x**n)**(p + S(1))/a, x) rule867 = ReplacementRule(pattern867, replacement867) pattern868 = Pattern(Integral((a_ + x_**n_*WC('b', S(1)))**p_*(c_ + x_**n_*WC('d', S(1))), x_), cons2, cons3, cons7, cons27, cons4, cons5, cons71, cons562) def replacement868(p, b, d, a, n, c, x): rubi.append(868) return -Dist((a*d - b*c*(n*(p + S(1)) + S(1)))/(a*b*n*(p + S(1))), Int((a + b*x**n)**(p + S(1)), x), x) - Simp(x*(a + b*x**n)**(p + S(1))*(-a*d + b*c)/(a*b*n*(p + S(1))), x) rule868 = ReplacementRule(pattern868, replacement868) pattern869 = Pattern(Integral((c_ + x_**n_*WC('d', S(1)))/(a_ + x_**n_*WC('b', S(1))), x_), cons2, cons3, cons7, cons27, cons4, cons71, cons87, cons463) def replacement869(b, d, a, n, c, x): rubi.append(869) return -Dist((-a*d + b*c)/a, Int(S(1)/(a*x**(-n) + b), x), x) + Simp(c*x/a, x) rule869 = ReplacementRule(pattern869, replacement869) pattern870 = Pattern(Integral((a_ + x_**n_*WC('b', S(1)))**p_*(c_ + x_**n_*WC('d', S(1))), x_), cons2, cons3, cons7, cons27, cons4, cons71, cons563) def replacement870(p, b, d, a, n, c, x): rubi.append(870) return -Dist((a*d - b*c*(n*(p + S(1)) + S(1)))/(b*(n*(p + S(1)) + S(1))), Int((a + b*x**n)**p, x), x) + Simp(d*x*(a + b*x**n)**(p + S(1))/(b*(n*(p + S(1)) + S(1))), x) rule870 = ReplacementRule(pattern870, replacement870) pattern871 = Pattern(Integral((a_ + x_**n_*WC('b', S(1)))**p_*(c_ + x_**n_*WC('d', S(1)))**q_, x_), cons2, cons3, cons7, cons27, cons71, cons464, cons564, cons565) def replacement871(p, b, d, a, n, c, x, q): rubi.append(871) return Int(PolynomialDivide((a + b*x**n)**p, (c + d*x**n)**(-q), x), x) rule871 = ReplacementRule(pattern871, replacement871) pattern872 = Pattern(Integral(S(1)/((a_ + x_**n_*WC('b', S(1)))*(c_ + x_**n_*WC('d', S(1)))), x_), cons2, cons3, cons7, cons27, cons4, cons71) def replacement872(b, d, a, n, c, x): rubi.append(872) return Dist(b/(-a*d + b*c), Int(S(1)/(a + b*x**n), x), x) - Dist(d/(-a*d + b*c), Int(S(1)/(c + d*x**n), x), x) rule872 = ReplacementRule(pattern872, replacement872) pattern873 = Pattern(Integral(S(1)/((a_ + x_**S(2)*WC('b', S(1)))**(S(1)/3)*(c_ + x_**S(2)*WC('d', S(1)))), x_), cons2, cons3, cons7, cons27, cons71, cons566, cons466) def replacement873(b, d, c, a, x): rubi.append(873) return Dist(sqrt(S(3))/(S(2)*c), Int(S(1)/((a + b*x**S(2))**(S(1)/3)*(-x*Rt(b/a, S(2)) + sqrt(S(3)))), x), x) + Dist(sqrt(S(3))/(S(2)*c), Int(S(1)/((a + b*x**S(2))**(S(1)/3)*(x*Rt(b/a, S(2)) + sqrt(S(3)))), x), x) rule873 = ReplacementRule(pattern873, replacement873) pattern874 = Pattern(Integral(S(1)/((a_ + x_**S(2)*WC('b', S(1)))**(S(1)/3)*(c_ + x_**S(2)*WC('d', S(1)))), x_), cons2, cons3, cons7, cons27, cons71, cons566, cons483) def replacement874(b, d, c, a, x): rubi.append(874) return Dist(S(1)/6, Int((-x*Rt(-b/a, S(2)) + S(3))/((a + b*x**S(2))**(S(1)/3)*(c + d*x**S(2))), x), x) + Dist(S(1)/6, Int((x*Rt(-b/a, S(2)) + S(3))/((a + b*x**S(2))**(S(1)/3)*(c + d*x**S(2))), x), x) rule874 = ReplacementRule(pattern874, replacement874) pattern875 = Pattern(Integral((a_ + x_**S(2)*WC('b', S(1)))**(S(2)/3)/(c_ + x_**S(2)*WC('d', S(1))), x_), cons2, cons3, cons7, cons27, cons71, cons566) def replacement875(b, d, c, a, x): rubi.append(875) return Dist(b/d, Int((a + b*x**S(2))**(S(-1)/3), x), x) - Dist((-a*d + b*c)/d, Int(S(1)/((a + b*x**S(2))**(S(1)/3)*(c + d*x**S(2))), x), x) rule875 = ReplacementRule(pattern875, replacement875) pattern876 = Pattern(Integral(S(1)/((a_ + x_**S(2)*WC('b', S(1)))**(S(1)/4)*(c_ + x_**S(2)*WC('d', S(1)))), x_), cons2, cons3, cons7, cons27, cons71) def replacement876(b, d, c, a, x): rubi.append(876) return Dist(sqrt(-b*x**S(2)/a)/(S(2)*x), Subst(Int(S(1)/(sqrt(-b*x/a)*(a + b*x)**(S(1)/4)*(c + d*x)), x), x, x**S(2)), x) rule876 = ReplacementRule(pattern876, replacement876) pattern877 = Pattern(Integral(S(1)/((a_ + x_**S(2)*WC('b', S(1)))**(S(3)/4)*(c_ + x_**S(2)*WC('d', S(1)))), x_), cons2, cons3, cons7, cons27, cons71) def replacement877(b, d, c, a, x): rubi.append(877) return Dist(sqrt(-b*x**S(2)/a)/(S(2)*x), Subst(Int(S(1)/(sqrt(-b*x/a)*(a + b*x)**(S(3)/4)*(c + d*x)), x), x, x**S(2)), x) rule877 = ReplacementRule(pattern877, replacement877) pattern878 = Pattern(Integral((a_ + x_**S(2)*WC('b', S(1)))**WC('p', S(1))/(c_ + x_**S(2)*WC('d', S(1))), x_), cons2, cons3, cons7, cons27, cons71, cons13, cons163, cons567) def replacement878(p, b, d, a, c, x): rubi.append(878) return Dist(b/d, Int((a + b*x**S(2))**(p + S(-1)), x), x) - Dist((-a*d + b*c)/d, Int((a + b*x**S(2))**(p + S(-1))/(c + d*x**S(2)), x), x) rule878 = ReplacementRule(pattern878, replacement878) pattern879 = Pattern(Integral((a_ + x_**S(2)*WC('b', S(1)))**p_/(c_ + x_**S(2)*WC('d', S(1))), x_), cons2, cons3, cons7, cons27, cons71, cons13, cons137, cons568, cons569) def replacement879(p, b, d, a, c, x): rubi.append(879) return Dist(b/(-a*d + b*c), Int((a + b*x**S(2))**p, x), x) - Dist(d/(-a*d + b*c), Int((a + b*x**S(2))**(p + S(1))/(c + d*x**S(2)), x), x) rule879 = ReplacementRule(pattern879, replacement879) pattern880 = Pattern(Integral(sqrt(a_ + x_**S(4)*WC('b', S(1)))/(c_ + x_**S(4)*WC('d', S(1))), x_), cons2, cons3, cons7, cons27, cons70, cons570) def replacement880(b, d, c, a, x): rubi.append(880) return Dist(a/c, Subst(Int(S(1)/(-S(4)*a*b*x**S(4) + S(1)), x), x, x/sqrt(a + b*x**S(4))), x) rule880 = ReplacementRule(pattern880, replacement880) def With881(b, d, c, a, x): q = Rt(-a*b, S(4)) rubi.append(881) return Simp(a*ArcTan(q*x*(a + q**S(2)*x**S(2))/(a*sqrt(a + b*x**S(4))))/(S(2)*c*q), x) + Simp(a*atanh(q*x*(a - q**S(2)*x**S(2))/(a*sqrt(a + b*x**S(4))))/(S(2)*c*q), x) pattern881 = Pattern(Integral(sqrt(a_ + x_**S(4)*WC('b', S(1)))/(c_ + x_**S(4)*WC('d', S(1))), x_), cons2, cons3, cons7, cons27, cons70, cons571) rule881 = ReplacementRule(pattern881, With881) pattern882 = Pattern(Integral(sqrt(a_ + x_**S(4)*WC('b', S(1)))/(c_ + x_**S(4)*WC('d', S(1))), x_), cons2, cons3, cons7, cons27, cons71) def replacement882(b, d, c, a, x): rubi.append(882) return Dist(b/d, Int(S(1)/sqrt(a + b*x**S(4)), x), x) - Dist((-a*d + b*c)/d, Int(S(1)/(sqrt(a + b*x**S(4))*(c + d*x**S(4))), x), x) rule882 = ReplacementRule(pattern882, replacement882) pattern883 = Pattern(Integral((a_ + x_**S(4)*WC('b', S(1)))**(S(1)/4)/(c_ + x_**S(4)*WC('d', S(1))), x_), cons2, cons3, cons7, cons27, cons71) def replacement883(b, d, c, a, x): rubi.append(883) return Dist(sqrt(a/(a + b*x**S(4)))*sqrt(a + b*x**S(4)), Subst(Int(S(1)/((c - x**S(4)*(-a*d + b*c))*sqrt(-b*x**S(4) + S(1))), x), x, x/(a + b*x**S(4))**(S(1)/4)), x) rule883 = ReplacementRule(pattern883, replacement883) pattern884 = Pattern(Integral((a_ + x_**S(4)*WC('b', S(1)))**p_/(c_ + x_**S(4)*WC('d', S(1))), x_), cons2, cons3, cons7, cons27, cons71, cons13, cons572) def replacement884(p, b, d, a, c, x): rubi.append(884) return Dist(b/d, Int((a + b*x**S(4))**(p + S(-1)), x), x) - Dist((-a*d + b*c)/d, Int((a + b*x**S(4))**(p + S(-1))/(c + d*x**S(4)), x), x) rule884 = ReplacementRule(pattern884, replacement884) pattern885 = Pattern(Integral(S(1)/(sqrt(a_ + x_**S(4)*WC('b', S(1)))*(c_ + x_**S(4)*WC('d', S(1)))), x_), cons2, cons3, cons7, cons27, cons71) def replacement885(b, d, c, a, x): rubi.append(885) return Dist(S(1)/(S(2)*c), Int(S(1)/(sqrt(a + b*x**S(4))*(-x**S(2)*Rt(-d/c, S(2)) + S(1))), x), x) + Dist(S(1)/(S(2)*c), Int(S(1)/(sqrt(a + b*x**S(4))*(x**S(2)*Rt(-d/c, S(2)) + S(1))), x), x) rule885 = ReplacementRule(pattern885, replacement885) pattern886 = Pattern(Integral(S(1)/((a_ + x_**S(4)*WC('b', S(1)))**(S(3)/4)*(c_ + x_**S(4)*WC('d', S(1)))), x_), cons2, cons3, cons7, cons27, cons71) def replacement886(b, d, c, a, x): rubi.append(886) return Dist(b/(-a*d + b*c), Int((a + b*x**S(4))**(S(-3)/4), x), x) - Dist(d/(-a*d + b*c), Int((a + b*x**S(4))**(S(1)/4)/(c + d*x**S(4)), x), x) rule886 = ReplacementRule(pattern886, replacement886) pattern887 = Pattern(Integral(sqrt(a_ + x_**S(2)*WC('b', S(1)))/(c_ + x_**S(2)*WC('d', S(1)))**(S(3)/2), x_), cons2, cons3, cons7, cons27, cons466, cons573) def replacement887(b, d, c, a, x): rubi.append(887) return Simp(sqrt(a + b*x**S(2))*EllipticE(ArcTan(x*Rt(d/c, S(2))), S(1) - b*c/(a*d))/(c*sqrt(c*(a + b*x**S(2))/(a*(c + d*x**S(2))))*sqrt(c + d*x**S(2))*Rt(d/c, S(2))), x) rule887 = ReplacementRule(pattern887, replacement887) pattern888 = Pattern(Integral((a_ + x_**n_*WC('b', S(1)))**p_*(c_ + x_**n_*WC('d', S(1)))**q_, x_), cons2, cons3, cons7, cons27, cons4, cons71, cons402, cons137, cons574, cons575) def replacement888(p, b, d, a, n, c, x, q): rubi.append(888) return Dist(S(1)/(a*n*(p + S(1))), Int((a + b*x**n)**(p + S(1))*(c + d*x**n)**(q + S(-1))*Simp(c*(n*(p + S(1)) + S(1)) + d*x**n*(n*(p + q + S(1)) + S(1)), x), x), x) - Simp(x*(a + b*x**n)**(p + S(1))*(c + d*x**n)**q/(a*n*(p + S(1))), x) rule888 = ReplacementRule(pattern888, replacement888) pattern889 = Pattern(Integral((a_ + x_**n_*WC('b', S(1)))**p_*(c_ + x_**n_*WC('d', S(1)))**q_, x_), cons2, cons3, cons7, cons27, cons4, cons71, cons402, cons137, cons576, cons575) def replacement889(p, b, d, a, n, c, x, q): rubi.append(889) return -Dist(S(1)/(a*b*n*(p + S(1))), Int((a + b*x**n)**(p + S(1))*(c + d*x**n)**(q + S(-2))*Simp(c*(a*d - b*c*(n*(p + S(1)) + S(1))) + d*x**n*(a*d*(n*(q + S(-1)) + S(1)) - b*c*(n*(p + q) + S(1))), x), x), x) + Simp(x*(a + b*x**n)**(p + S(1))*(c + d*x**n)**(q + S(-1))*(a*d - b*c)/(a*b*n*(p + S(1))), x) rule889 = ReplacementRule(pattern889, replacement889) pattern890 = Pattern(Integral((a_ + x_**n_*WC('b', S(1)))**p_*(c_ + x_**n_*WC('d', S(1)))**q_, x_), cons2, cons3, cons7, cons27, cons4, cons50, cons71, cons13, cons137, cons405, cons575) def replacement890(p, b, d, a, n, c, x, q): rubi.append(890) return Dist(S(1)/(a*n*(p + S(1))*(-a*d + b*c)), Int((a + b*x**n)**(p + S(1))*(c + d*x**n)**q*Simp(b*c + b*d*x**n*(n*(p + q + S(2)) + S(1)) + n*(p + S(1))*(-a*d + b*c), x), x), x) - Simp(b*x*(a + b*x**n)**(p + S(1))*(c + d*x**n)**(q + S(1))/(a*n*(p + S(1))*(-a*d + b*c)), x) rule890 = ReplacementRule(pattern890, replacement890) pattern891 = Pattern(Integral((a_ + x_**n_*WC('b', S(1)))**p_*(c_ + x_**n_*WC('d', S(1)))**q_, x_), cons2, cons3, cons7, cons27, cons71, cons148, cons220, cons577) def replacement891(p, b, d, a, n, c, x, q): rubi.append(891) return Int(ExpandIntegrand((a + b*x**n)**p*(c + d*x**n)**q, x), x) rule891 = ReplacementRule(pattern891, replacement891) pattern892 = Pattern(Integral((a_ + x_**n_*WC('b', S(1)))**p_*(c_ + x_**n_*WC('d', S(1)))**q_, x_), cons2, cons3, cons7, cons27, cons4, cons5, cons71, cons395, cons576, cons578, cons579, cons575) def replacement892(p, b, d, a, n, c, x, q): rubi.append(892) return Dist(S(1)/(b*(n*(p + q) + S(1))), Int((a + b*x**n)**p*(c + d*x**n)**(q + S(-2))*Simp(c*(-a*d + b*c*(n*(p + q) + S(1))) + d*x**n*(-a*d*(n*(q + S(-1)) + S(1)) + b*c*(n*(p + S(2)*q + S(-1)) + S(1))), x), x), x) + Simp(d*x*(a + b*x**n)**(p + S(1))*(c + d*x**n)**(q + S(-1))/(b*(n*(p + q) + S(1))), x) rule892 = ReplacementRule(pattern892, replacement892) pattern893 = Pattern(Integral((a_ + x_**n_*WC('b', S(1)))**p_*(c_ + x_**n_*WC('d', S(1)))**q_, x_), cons2, cons3, cons7, cons27, cons4, cons71, cons402, cons403, cons163, cons575) def replacement893(p, b, d, a, n, c, x, q): rubi.append(893) return Dist(n/(n*(p + q) + S(1)), Int((a + b*x**n)**(p + S(-1))*(c + d*x**n)**(q + S(-1))*Simp(a*c*(p + q) + x**n*(a*d*(p + q) + q*(-a*d + b*c)), x), x), x) + Simp(x*(a + b*x**n)**p*(c + d*x**n)**q/(n*(p + q) + S(1)), x) rule893 = ReplacementRule(pattern893, replacement893) pattern894 = Pattern(Integral(S(1)/(sqrt(a_ + x_**S(2)*WC('b', S(1)))*sqrt(c_ + x_**S(2)*WC('d', S(1)))), x_), cons2, cons3, cons7, cons27, cons573, cons466, cons580) def replacement894(b, d, c, a, x): rubi.append(894) return Simp(sqrt(a + b*x**S(2))*EllipticF(ArcTan(x*Rt(d/c, S(2))), S(1) - b*c/(a*d))/(a*sqrt(c*(a + b*x**S(2))/(a*(c + d*x**S(2))))*sqrt(c + d*x**S(2))*Rt(d/c, S(2))), x) rule894 = ReplacementRule(pattern894, replacement894) pattern895 = Pattern(Integral(S(1)/(sqrt(a_ + x_**S(2)*WC('b', S(1)))*sqrt(c_ + x_**S(2)*WC('d', S(1)))), x_), cons2, cons3, cons7, cons27, cons581, cons177, cons43, cons582) def replacement895(b, d, c, a, x): rubi.append(895) return Simp(EllipticF(asin(x*Rt(-d/c, S(2))), b*c/(a*d))/(sqrt(a)*sqrt(c)*Rt(-d/c, S(2))), x) rule895 = ReplacementRule(pattern895, replacement895) pattern896 = Pattern(Integral(S(1)/(sqrt(a_ + x_**S(2)*WC('b', S(1)))*sqrt(c_ + x_**S(2)*WC('d', S(1)))), x_), cons2, cons3, cons7, cons27, cons581, cons177, cons583) def replacement896(b, d, c, a, x): rubi.append(896) return -Simp(EllipticF(acos(x*Rt(-d/c, S(2))), b*c/(-a*d + b*c))/(sqrt(c)*sqrt(a - b*c/d)*Rt(-d/c, S(2))), x) rule896 = ReplacementRule(pattern896, replacement896) pattern897 = Pattern(Integral(S(1)/(sqrt(a_ + x_**S(2)*WC('b', S(1)))*sqrt(c_ + x_**S(2)*WC('d', S(1)))), x_), cons2, cons3, cons7, cons27, cons117) def replacement897(b, d, c, a, x): rubi.append(897) return Dist(sqrt(S(1) + d*x**S(2)/c)/sqrt(c + d*x**S(2)), Int(S(1)/(sqrt(S(1) + d*x**S(2)/c)*sqrt(a + b*x**S(2))), x), x) rule897 = ReplacementRule(pattern897, replacement897) pattern898 = Pattern(Integral(sqrt(a_ + x_**S(2)*WC('b', S(1)))/sqrt(c_ + x_**S(2)*WC('d', S(1))), x_), cons2, cons3, cons7, cons27, cons573, cons466) def replacement898(b, d, c, a, x): rubi.append(898) return Dist(a, Int(S(1)/(sqrt(a + b*x**S(2))*sqrt(c + d*x**S(2))), x), x) + Dist(b, Int(x**S(2)/(sqrt(a + b*x**S(2))*sqrt(c + d*x**S(2))), x), x) rule898 = ReplacementRule(pattern898, replacement898) pattern899 = Pattern(Integral(sqrt(a_ + x_**S(2)*WC('b', S(1)))/sqrt(c_ + x_**S(2)*WC('d', S(1))), x_), cons2, cons3, cons7, cons27, cons573, cons483) def replacement899(b, d, c, a, x): rubi.append(899) return Dist(b/d, Int(sqrt(c + d*x**S(2))/sqrt(a + b*x**S(2)), x), x) - Dist((-a*d + b*c)/d, Int(S(1)/(sqrt(a + b*x**S(2))*sqrt(c + d*x**S(2))), x), x) rule899 = ReplacementRule(pattern899, replacement899) pattern900 = Pattern(Integral(sqrt(a_ + x_**S(2)*WC('b', S(1)))/sqrt(c_ + x_**S(2)*WC('d', S(1))), x_), cons2, cons3, cons7, cons27, cons581, cons177, cons43) def replacement900(b, d, c, a, x): rubi.append(900) return Simp(sqrt(a)*EllipticE(asin(x*Rt(-d/c, S(2))), b*c/(a*d))/(sqrt(c)*Rt(-d/c, S(2))), x) rule900 = ReplacementRule(pattern900, replacement900) pattern901 = Pattern(Integral(sqrt(a_ + x_**S(2)*WC('b', S(1)))/sqrt(c_ + x_**S(2)*WC('d', S(1))), x_), cons2, cons3, cons7, cons27, cons581, cons177, cons583) def replacement901(b, d, c, a, x): rubi.append(901) return -Simp(sqrt(a - b*c/d)*EllipticE(acos(x*Rt(-d/c, S(2))), b*c/(-a*d + b*c))/(sqrt(c)*Rt(-d/c, S(2))), x) rule901 = ReplacementRule(pattern901, replacement901) pattern902 = Pattern(Integral(sqrt(a_ + x_**S(2)*WC('b', S(1)))/sqrt(c_ + x_**S(2)*WC('d', S(1))), x_), cons2, cons3, cons7, cons27, cons581, cons177, cons448) def replacement902(b, d, c, a, x): rubi.append(902) return Dist(sqrt(a + b*x**S(2))/sqrt(S(1) + b*x**S(2)/a), Int(sqrt(S(1) + b*x**S(2)/a)/sqrt(c + d*x**S(2)), x), x) rule902 = ReplacementRule(pattern902, replacement902) pattern903 = Pattern(Integral(sqrt(a_ + x_**S(2)*WC('b', S(1)))/sqrt(c_ + x_**S(2)*WC('d', S(1))), x_), cons2, cons3, cons7, cons27, cons581, cons117) def replacement903(b, d, c, a, x): rubi.append(903) return Dist(sqrt(S(1) + d*x**S(2)/c)/sqrt(c + d*x**S(2)), Int(sqrt(a + b*x**S(2))/sqrt(S(1) + d*x**S(2)/c), x), x) rule903 = ReplacementRule(pattern903, replacement903) pattern904 = Pattern(Integral((a_ + x_**n_*WC('b', S(1)))**p_*(c_ + x_**n_*WC('d', S(1)))**q_, x_), cons2, cons3, cons7, cons27, cons4, cons50, cons71, cons128) def replacement904(p, b, d, a, n, c, x, q): rubi.append(904) return Int(ExpandIntegrand((a + b*x**n)**p*(c + d*x**n)**q, x), x) rule904 = ReplacementRule(pattern904, replacement904) pattern905 = Pattern(Integral((a_ + x_**n_*WC('b', S(1)))**p_*(c_ + x_**n_*WC('d', S(1)))**q_, x_), cons2, cons3, cons7, cons27, cons4, cons5, cons50, cons71, cons584, cons43, cons177) def replacement905(p, b, d, a, n, c, x, q): rubi.append(905) return Simp(a**p*c**q*x*AppellF1(S(1)/n, -p, -q, S(1) + S(1)/n, -b*x**n/a, -d*x**n/c), x) rule905 = ReplacementRule(pattern905, replacement905) pattern906 = Pattern(Integral((a_ + x_**n_*WC('b', S(1)))**p_*(c_ + x_**n_*WC('d', S(1)))**q_, x_), cons2, cons3, cons7, cons27, cons4, cons5, cons50, cons71, cons584, cons448) def replacement906(p, b, d, a, n, c, x, q): rubi.append(906) return Dist(a**IntPart(p)*(S(1) + b*x**n/a)**(-FracPart(p))*(a + b*x**n)**FracPart(p), Int((S(1) + b*x**n/a)**p*(c + d*x**n)**q, x), x) rule906 = ReplacementRule(pattern906, replacement906) pattern907 = Pattern(Integral((a_ + x_**WC('n', S(1))*WC('b', S(1)))**WC('p', S(1))*(c_ + x_**WC('mn', S(1))*WC('d', S(1)))**WC('q', S(1)), x_), cons2, cons3, cons7, cons27, cons4, cons5, cons585, cons586, cons587) def replacement907(mn, p, b, d, c, n, a, x, q): rubi.append(907) return Int(x**(-n*q)*(a + b*x**n)**p*(c*x**n + d)**q, x) rule907 = ReplacementRule(pattern907, replacement907) pattern908 = Pattern(Integral((a_ + x_**WC('n', S(1))*WC('b', S(1)))**p_*(c_ + x_**WC('mn', S(1))*WC('d', S(1)))**q_, x_), cons2, cons3, cons7, cons27, cons4, cons5, cons50, cons585, cons386, cons147) def replacement908(mn, p, b, d, c, n, a, x, q): rubi.append(908) return Dist(x**(n*FracPart(q))*(c + d*x**(-n))**FracPart(q)*(c*x**n + d)**(-FracPart(q)), Int(x**(-n*q)*(a + b*x**n)**p*(c*x**n + d)**q, x), x) rule908 = ReplacementRule(pattern908, replacement908) pattern909 = Pattern(Integral((u_**n_*WC('b', S(1)) + WC('a', S(0)))**WC('p', S(1))*(u_**n_*WC('d', S(1)) + WC('c', S(0)))**WC('q', S(1)), x_), cons2, cons3, cons7, cons27, cons4, cons5, cons50, cons68, cons69) def replacement909(p, u, b, d, c, a, n, x, q): rubi.append(909) return Dist(S(1)/Coefficient(u, x, S(1)), Subst(Int((a + b*x**n)**p*(c + d*x**n)**q, x), x, u), x) rule909 = ReplacementRule(pattern909, replacement909) pattern910 = Pattern(Integral(u_**WC('p', S(1))*v_**WC('q', S(1)), x_), cons5, cons50, cons588) def replacement910(v, p, u, x, q): rubi.append(910) return Int(NormalizePseudoBinomial(u, x)**p*NormalizePseudoBinomial(v, x)**q, x) rule910 = ReplacementRule(pattern910, replacement910) pattern911 = Pattern(Integral(u_**WC('p', S(1))*v_**WC('q', S(1))*x_**WC('m', S(1)), x_), cons5, cons50, cons589, cons590) def replacement911(v, p, u, m, x, q): rubi.append(911) return Int(NormalizePseudoBinomial(v, x)**q*NormalizePseudoBinomial(u*x**(m/p), x)**p, x) rule911 = ReplacementRule(pattern911, replacement911) pattern912 = Pattern(Integral((x_*WC('e', S(1)))**WC('m', S(1))*(x_**n_*WC('b', S(1)))**p_*(c_ + x_**n_*WC('d', S(1)))**WC('q', S(1)), x_), cons3, cons7, cons27, cons48, cons21, cons4, cons5, cons50, cons591, cons500) def replacement912(p, m, b, d, c, n, x, q, e): rubi.append(912) return Dist(b**(S(1) - (m + S(1))/n)*e**m/n, Subst(Int((b*x)**(p + S(-1) + (m + S(1))/n)*(c + d*x)**q, x), x, x**n), x) rule912 = ReplacementRule(pattern912, replacement912) pattern913 = Pattern(Integral((x_*WC('e', S(1)))**WC('m', S(1))*(x_**WC('n', S(1))*WC('b', S(1)))**p_*(c_ + x_**n_*WC('d', S(1)))**WC('q', S(1)), x_), cons3, cons7, cons27, cons48, cons21, cons4, cons5, cons50, cons591, cons501) def replacement913(p, m, b, d, c, n, x, q, e): rubi.append(913) return Dist(b**IntPart(p)*e**m*x**(-n*FracPart(p))*(b*x**n)**FracPart(p), Int(x**(m + n*p)*(c + d*x**n)**q, x), x) rule913 = ReplacementRule(pattern913, replacement913) pattern914 = Pattern(Integral((e_*x_)**m_*(x_**WC('n', S(1))*WC('b', S(1)))**p_*(c_ + x_**n_*WC('d', S(1)))**WC('q', S(1)), x_), cons3, cons7, cons27, cons48, cons21, cons4, cons5, cons50, cons18) def replacement914(p, m, b, d, c, n, x, q, e): rubi.append(914) return Dist(e**IntPart(m)*x**(-FracPart(m))*(e*x)**FracPart(m), Int(x**m*(b*x**n)**p*(c + d*x**n)**q, x), x) rule914 = ReplacementRule(pattern914, replacement914) pattern915 = Pattern(Integral(x_**WC('m', S(1))*(a_ + x_**n_*WC('b', S(1)))**WC('p', S(1))*(c_ + x_**n_*WC('d', S(1)))**WC('q', S(1)), x_), cons2, cons3, cons7, cons27, cons21, cons4, cons5, cons50, cons71, cons53) def replacement915(p, m, b, d, a, n, c, x, q): rubi.append(915) return Dist(S(1)/n, Subst(Int((a + b*x)**p*(c + d*x)**q, x), x, x**n), x) rule915 = ReplacementRule(pattern915, replacement915) pattern916 = Pattern(Integral(x_**WC('m', S(1))*(a_ + x_**n_*WC('b', S(1)))**WC('p', S(1))*(c_ + x_**n_*WC('d', S(1)))**WC('q', S(1)), x_), cons2, cons3, cons7, cons27, cons21, cons4, cons71, cons220, cons502) def replacement916(p, m, b, d, a, n, c, x, q): rubi.append(916) return Int(x**(m + n*(p + q))*(a*x**(-n) + b)**p*(c*x**(-n) + d)**q, x) rule916 = ReplacementRule(pattern916, replacement916) pattern917 = Pattern(Integral(x_**WC('m', S(1))*(a_ + x_**n_*WC('b', S(1)))**WC('p', S(1))*(c_ + x_**n_*WC('d', S(1)))**WC('q', S(1)), x_), cons2, cons3, cons7, cons27, cons21, cons4, cons5, cons50, cons71, cons500) def replacement917(p, m, b, d, a, n, c, x, q): rubi.append(917) return Dist(S(1)/n, Subst(Int(x**(S(-1) + (m + S(1))/n)*(a + b*x)**p*(c + d*x)**q, x), x, x**n), x) rule917 = ReplacementRule(pattern917, replacement917) pattern918 = Pattern(Integral((e_*x_)**WC('m', S(1))*(a_ + x_**n_*WC('b', S(1)))**WC('p', S(1))*(c_ + x_**n_*WC('d', S(1)))**WC('q', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons21, cons4, cons5, cons50, cons71, cons500) def replacement918(p, m, b, d, a, n, c, x, q, e): rubi.append(918) return Dist(e**IntPart(m)*x**(-FracPart(m))*(e*x)**FracPart(m), Int(x**m*(a + b*x**n)**p*(c + d*x**n)**q, x), x) rule918 = ReplacementRule(pattern918, replacement918) pattern919 = Pattern(Integral((x_*WC('e', S(1)))**WC('m', S(1))*(a_ + x_**n_*WC('b', S(1)))**WC('p', S(1))*(c_ + x_**n_*WC('d', S(1)))**WC('q', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons21, cons4, cons71, cons555) def replacement919(p, m, b, d, a, n, c, x, q, e): rubi.append(919) return Int(ExpandIntegrand((e*x)**m*(a + b*x**n)**p*(c + d*x**n)**q, x), x) rule919 = ReplacementRule(pattern919, replacement919) pattern920 = Pattern(Integral((x_*WC('e', S(1)))**WC('m', S(1))*(a_ + x_**n_*WC('b', S(1)))**WC('p', S(1))*(c_ + x_**n_*WC('d', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons21, cons4, cons5, cons71, cons592, cons66) def replacement920(p, m, b, d, a, n, c, x, e): rubi.append(920) return Simp(c*(e*x)**(m + S(1))*(a + b*x**n)**(p + S(1))/(a*e*(m + S(1))), x) rule920 = ReplacementRule(pattern920, replacement920) pattern921 = Pattern(Integral((x_*WC('e', S(1)))**WC('m', S(1))*(a1_ + x_**WC('non2', S(1))*WC('b1', S(1)))**WC('p', S(1))*(a2_ + x_**WC('non2', S(1))*WC('b2', S(1)))**WC('p', S(1))*(c_ + x_**n_*WC('d', S(1))), x_), cons57, cons58, cons59, cons60, cons7, cons27, cons48, cons21, cons4, cons5, cons593, cons55, cons594, cons66) def replacement921(p, a2, m, b2, b1, d, c, n, non2, x, a1, e): rubi.append(921) return Simp(c*(e*x)**(m + S(1))*(a1 + b1*x**(n/S(2)))**(p + S(1))*(a2 + b2*x**(n/S(2)))**(p + S(1))/(a1*a2*e*(m + S(1))), x) rule921 = ReplacementRule(pattern921, replacement921) pattern922 = Pattern(Integral((x_*WC('e', S(1)))**WC('m', S(1))*(a_ + x_**n_*WC('b', S(1)))**WC('p', S(1))*(c_ + x_**n_*WC('d', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons5, cons71, cons595, cons596, cons93, cons597) def replacement922(p, m, b, d, a, n, c, x, e): rubi.append(922) return Dist(d*e**(-n), Int((e*x)**(m + n)*(a + b*x**n)**p, x), x) + Simp(c*(e*x)**(m + S(1))*(a + b*x**n)**(p + S(1))/(a*e*(m + S(1))), x) rule922 = ReplacementRule(pattern922, replacement922) pattern923 = Pattern(Integral((x_*WC('e', S(1)))**WC('m', S(1))*(a_ + x_**n_*WC('b', S(1)))**WC('p', S(1))*(c_ + x_**n_*WC('d', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons21, cons4, cons5, cons71, cons595, cons66) def replacement923(p, m, b, d, a, n, c, x, e): rubi.append(923) return Dist(d/b, Int((e*x)**m*(a + b*x**n)**(p + S(1)), x), x) + Simp((e*x)**(m + S(1))*(a + b*x**n)**(p + S(1))*(-a*d + b*c)/(a*b*e*(m + S(1))), x) rule923 = ReplacementRule(pattern923, replacement923) pattern924 = Pattern(Integral((x_*WC('e', S(1)))**WC('m', S(1))*(a_ + x_**n_*WC('b', S(1)))**WC('p', S(1))*(c_ + x_**n_*WC('d', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons5, cons71, cons596, cons93, cons597, cons598) def replacement924(p, m, b, d, a, n, c, x, e): rubi.append(924) return Dist(e**(-n)*(a*d*(m + S(1)) - b*c*(m + n*(p + S(1)) + S(1)))/(a*(m + S(1))), Int((e*x)**(m + n)*(a + b*x**n)**p, x), x) + Simp(c*(e*x)**(m + S(1))*(a + b*x**n)**(p + S(1))/(a*e*(m + S(1))), x) rule924 = ReplacementRule(pattern924, replacement924) pattern925 = Pattern(Integral((x_*WC('e', S(1)))**WC('m', S(1))*(a1_ + x_**WC('non2', S(1))*WC('b1', S(1)))**WC('p', S(1))*(a2_ + x_**WC('non2', S(1))*WC('b2', S(1)))**WC('p', S(1))*(c_ + x_**n_*WC('d', S(1))), x_), cons57, cons58, cons59, cons60, cons7, cons27, cons48, cons5, cons593, cons55, cons596, cons93, cons597, cons598) def replacement925(p, a2, m, b2, b1, d, c, n, non2, x, a1, e): rubi.append(925) return Dist(e**(-n)*(a1*a2*d*(m + S(1)) - b1*b2*c*(m + n*(p + S(1)) + S(1)))/(a1*a2*(m + S(1))), Int((e*x)**(m + n)*(a1 + b1*x**(n/S(2)))**p*(a2 + b2*x**(n/S(2)))**p, x), x) + Simp(c*(e*x)**(m + S(1))*(a1 + b1*x**(n/S(2)))**(p + S(1))*(a2 + b2*x**(n/S(2)))**(p + S(1))/(a1*a2*e*(m + S(1))), x) rule925 = ReplacementRule(pattern925, replacement925) pattern926 = Pattern(Integral(x_**m_*(a_ + x_**S(2)*WC('b', S(1)))**p_*(c_ + x_**S(2)*WC('d', S(1))), x_), cons2, cons3, cons7, cons27, cons71, cons13, cons137, cons599, cons600) def replacement926(p, m, b, d, a, c, x): rubi.append(926) return Dist(b**(-m/S(2) + S(-1))/(S(2)*(p + S(1))), Int((a + b*x**S(2))**(p + S(1))*ExpandToSum(S(2)*b*x**S(2)*(p + S(1))*Together((b**(m/S(2))*x**(m + S(-2))*(c + d*x**S(2)) - (-a)**(m/S(2) + S(-1))*(-a*d + b*c))/(a + b*x**S(2))) - (-a)**(m/S(2) + S(-1))*(-a*d + b*c), x), x), x) + Simp(b**(-m/S(2) + S(-1))*x*(-a)**(m/S(2) + S(-1))*(a + b*x**S(2))**(p + S(1))*(-a*d + b*c)/(S(2)*(p + S(1))), x) rule926 = ReplacementRule(pattern926, replacement926) pattern927 = Pattern(Integral(x_**m_*(a_ + x_**S(2)*WC('b', S(1)))**p_*(c_ + x_**S(2)*WC('d', S(1))), x_), cons2, cons3, cons7, cons27, cons71, cons13, cons137, cons601, cons600) def replacement927(p, m, b, d, a, c, x): rubi.append(927) return Dist(b**(-m/S(2) + S(-1))/(S(2)*(p + S(1))), Int(x**m*(a + b*x**S(2))**(p + S(1))*ExpandToSum(S(2)*b*(p + S(1))*Together((b**(m/S(2))*(c + d*x**S(2)) - x**(-m + S(2))*(-a)**(m/S(2) + S(-1))*(-a*d + b*c))/(a + b*x**S(2))) - x**(-m)*(-a)**(m/S(2) + S(-1))*(-a*d + b*c), x), x), x) + Simp(b**(-m/S(2) + S(-1))*x*(-a)**(m/S(2) + S(-1))*(a + b*x**S(2))**(p + S(1))*(-a*d + b*c)/(S(2)*(p + S(1))), x) rule927 = ReplacementRule(pattern927, replacement927) pattern928 = Pattern(Integral((x_*WC('e', S(1)))**WC('m', S(1))*(a_ + x_**n_*WC('b', S(1)))**WC('p', S(1))*(c_ + x_**n_*WC('d', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons21, cons4, cons71, cons13, cons137, cons602) def replacement928(p, m, b, d, a, n, c, x, e): rubi.append(928) return -Dist((a*d*(m + S(1)) - b*c*(m + n*(p + S(1)) + S(1)))/(a*b*n*(p + S(1))), Int((e*x)**m*(a + b*x**n)**(p + S(1)), x), x) - Simp((e*x)**(m + S(1))*(a + b*x**n)**(p + S(1))*(-a*d + b*c)/(a*b*e*n*(p + S(1))), x) rule928 = ReplacementRule(pattern928, replacement928) pattern929 = Pattern(Integral((x_*WC('e', S(1)))**WC('m', S(1))*(a1_ + x_**WC('non2', S(1))*WC('b1', S(1)))**WC('p', S(1))*(a2_ + x_**WC('non2', S(1))*WC('b2', S(1)))**WC('p', S(1))*(c_ + x_**n_*WC('d', S(1))), x_), cons57, cons58, cons59, cons60, cons7, cons27, cons48, cons21, cons4, cons593, cons55, cons13, cons137, cons602) def replacement929(p, a2, m, b2, b1, d, c, n, non2, x, a1, e): rubi.append(929) return -Dist((a1*a2*d*(m + S(1)) - b1*b2*c*(m + n*(p + S(1)) + S(1)))/(a1*a2*b1*b2*n*(p + S(1))), Int((e*x)**m*(a1 + b1*x**(n/S(2)))**(p + S(1))*(a2 + b2*x**(n/S(2)))**(p + S(1)), x), x) - Simp((e*x)**(m + S(1))*(a1 + b1*x**(n/S(2)))**(p + S(1))*(a2 + b2*x**(n/S(2)))**(p + S(1))*(-a1*a2*d + b1*b2*c)/(a1*a2*b1*b2*e*n*(p + S(1))), x) rule929 = ReplacementRule(pattern929, replacement929) pattern930 = Pattern(Integral((x_*WC('e', S(1)))**WC('m', S(1))*(a_ + x_**n_*WC('b', S(1)))**WC('p', S(1))*(c_ + x_**n_*WC('d', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons21, cons4, cons5, cons71, cons603) def replacement930(p, m, b, d, a, n, c, x, e): rubi.append(930) return -Dist((a*d*(m + S(1)) - b*c*(m + n*(p + S(1)) + S(1)))/(b*(m + n*(p + S(1)) + S(1))), Int((e*x)**m*(a + b*x**n)**p, x), x) + Simp(d*(e*x)**(m + S(1))*(a + b*x**n)**(p + S(1))/(b*e*(m + n*(p + S(1)) + S(1))), x) rule930 = ReplacementRule(pattern930, replacement930) pattern931 = Pattern(Integral((x_*WC('e', S(1)))**WC('m', S(1))*(a1_ + x_**WC('non2', S(1))*WC('b1', S(1)))**WC('p', S(1))*(a2_ + x_**WC('non2', S(1))*WC('b2', S(1)))**WC('p', S(1))*(c_ + x_**n_*WC('d', S(1))), x_), cons57, cons58, cons59, cons60, cons7, cons27, cons48, cons21, cons4, cons5, cons593, cons55, cons603) def replacement931(p, a2, m, b2, b1, d, c, n, non2, x, a1, e): rubi.append(931) return -Dist((a1*a2*d*(m + S(1)) - b1*b2*c*(m + n*(p + S(1)) + S(1)))/(b1*b2*(m + n*(p + S(1)) + S(1))), Int((e*x)**m*(a1 + b1*x**(n/S(2)))**p*(a2 + b2*x**(n/S(2)))**p, x), x) + Simp(d*(e*x)**(m + S(1))*(a1 + b1*x**(n/S(2)))**(p + S(1))*(a2 + b2*x**(n/S(2)))**(p + S(1))/(b1*b2*e*(m + n*(p + S(1)) + S(1))), x) rule931 = ReplacementRule(pattern931, replacement931) pattern932 = Pattern(Integral((x_*WC('e', S(1)))**WC('m', S(1))*(a_ + x_**n_*WC('b', S(1)))**p_/(c_ + x_**n_*WC('d', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons21, cons71, cons148, cons128, cons604) def replacement932(p, m, b, d, a, n, c, x, e): rubi.append(932) return Int(ExpandIntegrand((e*x)**m*(a + b*x**n)**p/(c + d*x**n), x), x) rule932 = ReplacementRule(pattern932, replacement932) pattern933 = Pattern(Integral((x_*WC('e', S(1)))**m_*(a_ + x_**n_*WC('b', S(1)))**p_*(c_ + x_**n_*WC('d', S(1)))**S(2), x_), cons2, cons3, cons7, cons27, cons48, cons5, cons71, cons148, cons93, cons94, cons88) def replacement933(p, m, b, d, a, n, c, x, e): rubi.append(933) return -Dist(e**(-n)/(a*(m + S(1))), Int((e*x)**(m + n)*(a + b*x**n)**p*Simp(-a*d**S(2)*x**n*(m + S(1)) + b*c**S(2)*n*(p + S(1)) + c*(m + S(1))*(-S(2)*a*d + b*c), x), x), x) + Simp(c**S(2)*(e*x)**(m + S(1))*(a + b*x**n)**(p + S(1))/(a*e*(m + S(1))), x) rule933 = ReplacementRule(pattern933, replacement933) pattern934 = Pattern(Integral((x_*WC('e', S(1)))**WC('m', S(1))*(a_ + x_**n_*WC('b', S(1)))**p_*(c_ + x_**n_*WC('d', S(1)))**S(2), x_), cons2, cons3, cons7, cons27, cons48, cons21, cons4, cons71, cons148, cons13, cons137) def replacement934(p, m, b, d, a, n, c, x, e): rubi.append(934) return Dist(S(1)/(a*b**S(2)*n*(p + S(1))), Int((e*x)**m*(a + b*x**n)**(p + S(1))*Simp(a*b*d**S(2)*n*x**n*(p + S(1)) + b**S(2)*c**S(2)*n*(p + S(1)) + (m + S(1))*(-a*d + b*c)**S(2), x), x), x) - Simp((e*x)**(m + S(1))*(a + b*x**n)**(p + S(1))*(-a*d + b*c)**S(2)/(a*b**S(2)*e*n*(p + S(1))), x) rule934 = ReplacementRule(pattern934, replacement934) pattern935 = Pattern(Integral((x_*WC('e', S(1)))**WC('m', S(1))*(a_ + x_**n_*WC('b', S(1)))**p_*(c_ + x_**n_*WC('d', S(1)))**S(2), x_), cons2, cons3, cons7, cons27, cons48, cons21, cons4, cons5, cons71, cons148, cons605) def replacement935(p, m, b, d, a, n, c, x, e): rubi.append(935) return Dist(S(1)/(b*(m + n*(p + S(2)) + S(1))), Int((e*x)**m*(a + b*x**n)**p*Simp(b*c**S(2)*(m + n*(p + S(2)) + S(1)) + d*x**n*(S(2)*b*c*n*(p + S(1)) + (-a*d + S(2)*b*c)*(m + n + S(1))), x), x), x) + Simp(d**S(2)*e**(-n + S(-1))*(e*x)**(m + n + S(1))*(a + b*x**n)**(p + S(1))/(b*(m + n*(p + S(2)) + S(1))), x) rule935 = ReplacementRule(pattern935, replacement935) def With936(p, m, b, d, a, n, c, x, q): if isinstance(x, (int, Integer, float, Float)): return False k = GCD(m + S(1), n) if Unequal(k, S(1)): return True return False pattern936 = Pattern(Integral(x_**WC('m', S(1))*(a_ + x_**n_*WC('b', S(1)))**p_*(c_ + x_**n_*WC('d', S(1)))**q_, x_), cons2, cons3, cons7, cons27, cons5, cons50, cons71, cons148, cons17, CustomConstraint(With936)) def replacement936(p, m, b, d, a, n, c, x, q): k = GCD(m + S(1), n) rubi.append(936) return Dist(S(1)/k, Subst(Int(x**(S(-1) + (m + S(1))/k)*(a + b*x**(n/k))**p*(c + d*x**(n/k))**q, x), x, x**k), x) rule936 = ReplacementRule(pattern936, replacement936) def With937(p, m, b, d, a, n, c, x, q, e): k = Denominator(m) rubi.append(937) return Dist(k/e, Subst(Int(x**(k*(m + S(1)) + S(-1))*(a + b*e**(-n)*x**(k*n))**p*(c + d*e**(-n)*x**(k*n))**q, x), x, (e*x)**(S(1)/k)), x) pattern937 = Pattern(Integral((x_*WC('e', S(1)))**m_*(a_ + x_**n_*WC('b', S(1)))**p_*(c_ + x_**n_*WC('d', S(1)))**q_, x_), cons2, cons3, cons7, cons27, cons48, cons5, cons50, cons71, cons148, cons367, cons38) rule937 = ReplacementRule(pattern937, With937) pattern938 = Pattern(Integral((x_*WC('e', S(1)))**WC('m', S(1))*(a_ + x_**n_*WC('b', S(1)))**p_*(c_ + x_**n_*WC('d', S(1)))**q_, x_), cons2, cons3, cons7, cons27, cons48, cons71, cons148, cons606, cons137, cons403, cons607, cons608) def replacement938(p, m, b, d, a, n, c, x, q, e): rubi.append(938) return -Dist(e**n/(b*n*(p + S(1))), Int((e*x)**(m - n)*(a + b*x**n)**(p + S(1))*(c + d*x**n)**(q + S(-1))*Simp(c*(m - n + S(1)) + d*x**n*(m + n*(q + S(-1)) + S(1)), x), x), x) + Simp(e**(n + S(-1))*(e*x)**(m - n + S(1))*(a + b*x**n)**(p + S(1))*(c + d*x**n)**q/(b*n*(p + S(1))), x) rule938 = ReplacementRule(pattern938, replacement938) pattern939 = Pattern(Integral((x_*WC('e', S(1)))**WC('m', S(1))*(a_ + x_**n_*WC('b', S(1)))**p_*(c_ + x_**n_*WC('d', S(1)))**q_, x_), cons2, cons3, cons7, cons27, cons48, cons21, cons71, cons148, cons402, cons137, cons576, cons608) def replacement939(p, m, b, d, a, n, c, x, q, e): rubi.append(939) return Dist(S(1)/(a*b*n*(p + S(1))), Int((e*x)**m*(a + b*x**n)**(p + S(1))*(c + d*x**n)**(q + S(-2))*Simp(c*(b*c*n*(p + S(1)) + (m + S(1))*(-a*d + b*c)) + d*x**n*(b*c*n*(p + S(1)) + (-a*d + b*c)*(m + n*(q + S(-1)) + S(1))), x), x), x) - Simp((e*x)**(m + S(1))*(a + b*x**n)**(p + S(1))*(c + d*x**n)**(q + S(-1))*(-a*d + b*c)/(a*b*e*n*(p + S(1))), x) rule939 = ReplacementRule(pattern939, replacement939) pattern940 = Pattern(Integral((x_*WC('e', S(1)))**WC('m', S(1))*(a_ + x_**n_*WC('b', S(1)))**p_*(c_ + x_**n_*WC('d', S(1)))**q_, x_), cons2, cons3, cons7, cons27, cons48, cons21, cons71, cons148, cons402, cons137, cons574, cons608) def replacement940(p, m, b, d, a, n, c, x, q, e): rubi.append(940) return Dist(S(1)/(a*n*(p + S(1))), Int((e*x)**m*(a + b*x**n)**(p + S(1))*(c + d*x**n)**(q + S(-1))*Simp(c*(m + n*(p + S(1)) + S(1)) + d*x**n*(m + n*(p + q + S(1)) + S(1)), x), x), x) - Simp((e*x)**(m + S(1))*(a + b*x**n)**(p + S(1))*(c + d*x**n)**q/(a*e*n*(p + S(1))), x) rule940 = ReplacementRule(pattern940, replacement940) pattern941 = Pattern(Integral((x_*WC('e', S(1)))**WC('m', S(1))*(a_ + x_**n_*WC('b', S(1)))**p_*(c_ + x_**n_*WC('d', S(1)))**q_, x_), cons2, cons3, cons7, cons27, cons48, cons50, cons71, cons148, cons244, cons137, cons609, cons608) def replacement941(p, m, b, d, a, n, c, x, q, e): rubi.append(941) return Dist(e**(S(2)*n)/(b*n*(p + S(1))*(-a*d + b*c)), Int((e*x)**(m - S(2)*n)*(a + b*x**n)**(p + S(1))*(c + d*x**n)**q*Simp(a*c*(m - S(2)*n + S(1)) + x**n*(a*d*(m + n*q - n + S(1)) + b*c*n*(p + S(1))), x), x), x) - Simp(a*e**(S(2)*n + S(-1))*(e*x)**(m - S(2)*n + S(1))*(a + b*x**n)**(p + S(1))*(c + d*x**n)**(q + S(1))/(b*n*(p + S(1))*(-a*d + b*c)), x) rule941 = ReplacementRule(pattern941, replacement941) pattern942 = Pattern(Integral((x_*WC('e', S(1)))**WC('m', S(1))*(a_ + x_**n_*WC('b', S(1)))**p_*(c_ + x_**n_*WC('d', S(1)))**q_, x_), cons2, cons3, cons7, cons27, cons48, cons50, cons71, cons148, cons244, cons137, cons610, cons608) def replacement942(p, m, b, d, a, n, c, x, q, e): rubi.append(942) return -Dist(e**n/(n*(p + S(1))*(-a*d + b*c)), Int((e*x)**(m - n)*(a + b*x**n)**(p + S(1))*(c + d*x**n)**q*Simp(c*(m - n + S(1)) + d*x**n*(m + n*(p + q + S(1)) + S(1)), x), x), x) + Simp(e**(n + S(-1))*(e*x)**(m - n + S(1))*(a + b*x**n)**(p + S(1))*(c + d*x**n)**(q + S(1))/(n*(p + S(1))*(-a*d + b*c)), x) rule942 = ReplacementRule(pattern942, replacement942) pattern943 = Pattern(Integral((x_*WC('e', S(1)))**WC('m', S(1))*(a_ + x_**n_*WC('b', S(1)))**p_*(c_ + x_**n_*WC('d', S(1)))**q_, x_), cons2, cons3, cons7, cons27, cons48, cons21, cons50, cons71, cons148, cons13, cons137, cons608) def replacement943(p, m, b, d, a, n, c, x, q, e): rubi.append(943) return Dist(S(1)/(a*n*(p + S(1))*(-a*d + b*c)), Int((e*x)**m*(a + b*x**n)**(p + S(1))*(c + d*x**n)**q*Simp(b*c*(m + S(1)) + b*d*x**n*(m + n*(p + q + S(2)) + S(1)) + n*(p + S(1))*(-a*d + b*c), x), x), x) - Simp(b*(e*x)**(m + S(1))*(a + b*x**n)**(p + S(1))*(c + d*x**n)**(q + S(1))/(a*e*n*(p + S(1))*(-a*d + b*c)), x) rule943 = ReplacementRule(pattern943, replacement943) pattern944 = Pattern(Integral((x_*WC('e', S(1)))**m_*(a_ + x_**n_*WC('b', S(1)))**p_*(c_ + x_**n_*WC('d', S(1)))**q_, x_), cons2, cons3, cons7, cons27, cons48, cons71, cons148, cons606, cons403, cons94, cons163, cons608) def replacement944(p, m, b, d, a, n, c, x, q, e): rubi.append(944) return -Dist(e**(-n)*n/(m + S(1)), Int((e*x)**(m + n)*(a + b*x**n)**(p + S(-1))*(c + d*x**n)**(q + S(-1))*Simp(a*d*q + b*c*p + b*d*x**n*(p + q), x), x), x) + Simp((e*x)**(m + S(1))*(a + b*x**n)**p*(c + d*x**n)**q/(e*(m + S(1))), x) rule944 = ReplacementRule(pattern944, replacement944) pattern945 = Pattern(Integral((x_*WC('e', S(1)))**m_*(a_ + x_**n_*WC('b', S(1)))**p_*(c_ + x_**n_*WC('d', S(1)))**q_, x_), cons2, cons3, cons7, cons27, cons48, cons5, cons71, cons148, cons611, cons576, cons94, cons608) def replacement945(p, m, b, d, a, n, c, x, q, e): rubi.append(945) return -Dist(e**(-n)/(a*(m + S(1))), Int((e*x)**(m + n)*(a + b*x**n)**p*(c + d*x**n)**(q + S(-2))*Simp(c*n*(a*d*(q + S(-1)) + b*c*(p + S(1))) + c*(m + S(1))*(-a*d + b*c) + d*x**n*(b*c*n*(p + q) + (m + S(1))*(-a*d + b*c)), x), x), x) + Simp(c*(e*x)**(m + S(1))*(a + b*x**n)**(p + S(1))*(c + d*x**n)**(q + S(-1))/(a*e*(m + S(1))), x) rule945 = ReplacementRule(pattern945, replacement945) pattern946 = Pattern(Integral((x_*WC('e', S(1)))**m_*(a_ + x_**n_*WC('b', S(1)))**p_*(c_ + x_**n_*WC('d', S(1)))**q_, x_), cons2, cons3, cons7, cons27, cons48, cons5, cons71, cons148, cons611, cons574, cons94, cons608) def replacement946(p, m, b, d, a, n, c, x, q, e): rubi.append(946) return -Dist(e**(-n)/(a*(m + S(1))), Int((e*x)**(m + n)*(a + b*x**n)**p*(c + d*x**n)**(q + S(-1))*Simp(b*c*(m + S(1)) + d*x**n*(b*n*(p + q + S(1)) + b*(m + S(1))) + n*(a*d*q + b*c*(p + S(1))), x), x), x) + Simp((e*x)**(m + S(1))*(a + b*x**n)**(p + S(1))*(c + d*x**n)**q/(a*e*(m + S(1))), x) rule946 = ReplacementRule(pattern946, replacement946) pattern947 = Pattern(Integral((x_*WC('e', S(1)))**WC('m', S(1))*(a_ + x_**n_*WC('b', S(1)))**p_*(c_ + x_**n_*WC('d', S(1)))**q_, x_), cons2, cons3, cons7, cons27, cons48, cons21, cons71, cons148, cons402, cons403, cons163, cons608) def replacement947(p, m, b, d, a, n, c, x, q, e): rubi.append(947) return Dist(n/(m + n*(p + q) + S(1)), Int((e*x)**m*(a + b*x**n)**(p + S(-1))*(c + d*x**n)**(q + S(-1))*Simp(a*c*(p + q) + x**n*(a*d*(p + q) + q*(-a*d + b*c)), x), x), x) + Simp((e*x)**(m + S(1))*(a + b*x**n)**p*(c + d*x**n)**q/(e*(m + n*(p + q) + S(1))), x) rule947 = ReplacementRule(pattern947, replacement947) pattern948 = Pattern(Integral((x_*WC('e', S(1)))**WC('m', S(1))*(a_ + x_**n_*WC('b', S(1)))**p_*(c_ + x_**n_*WC('d', S(1)))**q_, x_), cons2, cons3, cons7, cons27, cons48, cons21, cons5, cons71, cons148, cons395, cons576, cons608) def replacement948(p, m, b, d, a, n, c, x, q, e): rubi.append(948) return Dist(S(1)/(b*(m + n*(p + q) + S(1))), Int((e*x)**m*(a + b*x**n)**p*(c + d*x**n)**(q + S(-2))*Simp(c*(b*c*n*(p + q) + (m + S(1))*(-a*d + b*c)) + x**n*(b*c*d*n*(p + q) + d*n*(q + S(-1))*(-a*d + b*c) + d*(m + S(1))*(-a*d + b*c)), x), x), x) + Simp(d*(e*x)**(m + S(1))*(a + b*x**n)**(p + S(1))*(c + d*x**n)**(q + S(-1))/(b*e*(m + n*(p + q) + S(1))), x) rule948 = ReplacementRule(pattern948, replacement948) pattern949 = Pattern(Integral((x_*WC('e', S(1)))**WC('m', S(1))*(a_ + x_**n_*WC('b', S(1)))**p_*(c_ + x_**n_*WC('d', S(1)))**q_, x_), cons2, cons3, cons7, cons27, cons48, cons5, cons71, cons148, cons611, cons403, cons607, cons608) def replacement949(p, m, b, d, a, n, c, x, q, e): rubi.append(949) return -Dist(e**n/(b*(m + n*(p + q) + S(1))), Int((e*x)**(m - n)*(a + b*x**n)**p*(c + d*x**n)**(q + S(-1))*Simp(a*c*(m - n + S(1)) + x**n*(a*d*(m - n + S(1)) - n*q*(-a*d + b*c)), x), x), x) + Simp(e**(n + S(-1))*(e*x)**(m - n + S(1))*(a + b*x**n)**(p + S(1))*(c + d*x**n)**q/(b*(m + n*(p + q) + S(1))), x) rule949 = ReplacementRule(pattern949, replacement949) pattern950 = Pattern(Integral((x_*WC('e', S(1)))**WC('m', S(1))*(a_ + x_**n_*WC('b', S(1)))**p_*(c_ + x_**n_*WC('d', S(1)))**q_, x_), cons2, cons3, cons7, cons27, cons48, cons5, cons50, cons71, cons148, cons31, cons609, cons608) def replacement950(p, m, b, d, a, n, c, x, q, e): rubi.append(950) return -Dist(e**(S(2)*n)/(b*d*(m + n*(p + q) + S(1))), Int((e*x)**(m - S(2)*n)*(a + b*x**n)**p*(c + d*x**n)**q*Simp(a*c*(m - S(2)*n + S(1)) + x**n*(a*d*(m + n*(q + S(-1)) + S(1)) + b*c*(m + n*(p + S(-1)) + S(1))), x), x), x) + Simp(e**(S(2)*n + S(-1))*(e*x)**(m - S(2)*n + S(1))*(a + b*x**n)**(p + S(1))*(c + d*x**n)**(q + S(1))/(b*d*(m + n*(p + q) + S(1))), x) rule950 = ReplacementRule(pattern950, replacement950) pattern951 = Pattern(Integral((x_*WC('e', S(1)))**m_*(a_ + x_**n_*WC('b', S(1)))**p_*(c_ + x_**n_*WC('d', S(1)))**q_, x_), cons2, cons3, cons7, cons27, cons48, cons5, cons50, cons71, cons148, cons31, cons94, cons608) def replacement951(p, m, b, d, a, n, c, x, q, e): rubi.append(951) return -Dist(e**(-n)/(a*c*(m + S(1))), Int((e*x)**(m + n)*(a + b*x**n)**p*(c + d*x**n)**q*Simp(b*d*x**n*(m + n*(p + q + S(2)) + S(1)) + n*(a*d*q + b*c*p) + (a*d + b*c)*(m + n + S(1)), x), x), x) + Simp((e*x)**(m + S(1))*(a + b*x**n)**(p + S(1))*(c + d*x**n)**(q + S(1))/(a*c*e*(m + S(1))), x) rule951 = ReplacementRule(pattern951, replacement951) pattern952 = Pattern(Integral((x_*WC('e', S(1)))**WC('m', S(1))/((a_ + x_**n_*WC('b', S(1)))*(c_ + x_**n_*WC('d', S(1)))), x_), cons2, cons3, cons7, cons27, cons21, cons4, cons71, cons148, cons31, cons612) def replacement952(m, b, d, a, n, c, x, e): rubi.append(952) return -Dist(a*e**n/(-a*d + b*c), Int((e*x)**(m - n)/(a + b*x**n), x), x) + Dist(c*e**n/(-a*d + b*c), Int((e*x)**(m - n)/(c + d*x**n), x), x) rule952 = ReplacementRule(pattern952, replacement952) pattern953 = Pattern(Integral((x_*WC('e', S(1)))**WC('m', S(1))/((a_ + x_**n_*WC('b', S(1)))*(c_ + x_**n_*WC('d', S(1)))), x_), cons2, cons3, cons7, cons27, cons48, cons21, cons71, cons148) def replacement953(m, b, d, a, n, c, x, e): rubi.append(953) return Dist(b/(-a*d + b*c), Int((e*x)**m/(a + b*x**n), x), x) - Dist(d/(-a*d + b*c), Int((e*x)**m/(c + d*x**n), x), x) rule953 = ReplacementRule(pattern953, replacement953) pattern954 = Pattern(Integral(x_**m_/((a_ + x_**n_*WC('b', S(1)))*sqrt(c_ + x_**n_*WC('d', S(1)))), x_), cons2, cons3, cons7, cons27, cons71, cons613, cons614, cons615) def replacement954(m, b, d, a, n, c, x): rubi.append(954) return Dist(S(1)/b, Int(x**(m - n)/sqrt(c + d*x**n), x), x) - Dist(a/b, Int(x**(m - n)/((a + b*x**n)*sqrt(c + d*x**n)), x), x) rule954 = ReplacementRule(pattern954, replacement954) def With955(b, d, c, a, x): r = Numerator(Rt(-a/b, S(2))) s = Denominator(Rt(-a/b, S(2))) rubi.append(955) return -Dist(s/(S(2)*b), Int(S(1)/(sqrt(c + d*x**S(4))*(r - s*x**S(2))), x), x) + Dist(s/(S(2)*b), Int(S(1)/(sqrt(c + d*x**S(4))*(r + s*x**S(2))), x), x) pattern955 = Pattern(Integral(x_**S(2)/((a_ + x_**S(4)*WC('b', S(1)))*sqrt(c_ + x_**S(4)*WC('d', S(1)))), x_), cons2, cons3, cons7, cons27, cons71) rule955 = ReplacementRule(pattern955, With955) def With956(b, d, c, a, x): q = Rt(d/c, S(3)) rubi.append(956) return Simp(S(2)**(S(1)/3)*q*log(-S(2)**(S(1)/3)*q*x + S(1) - sqrt(c + d*x**S(3))/sqrt(c))/(S(12)*b*sqrt(c)), x) - Simp(S(2)**(S(1)/3)*q*log(-S(2)**(S(1)/3)*q*x + S(1) + sqrt(c + d*x**S(3))/sqrt(c))/(S(12)*b*sqrt(c)), x) + Simp(S(2)**(S(1)/3)*q*atanh(sqrt(c + d*x**S(3))/sqrt(c))/(S(18)*b*sqrt(c)), x) - Simp(S(2)**(S(1)/3)*sqrt(S(3))*q*ArcTan(sqrt(S(3))/S(3) + S(2)**(S(2)/3)*sqrt(S(3))*(sqrt(c) - sqrt(c + d*x**S(3)))/(S(3)*sqrt(c)*q*x))/(S(18)*b*sqrt(c)), x) + Simp(S(2)**(S(1)/3)*sqrt(S(3))*q*ArcTan(sqrt(S(3))/S(3) + S(2)**(S(2)/3)*sqrt(S(3))*(sqrt(c) + sqrt(c + d*x**S(3)))/(S(3)*sqrt(c)*q*x))/(S(18)*b*sqrt(c)), x) pattern956 = Pattern(Integral(x_/((a_ + x_**S(3)*WC('b', S(1)))*sqrt(c_ + x_**S(3)*WC('d', S(1)))), x_), cons2, cons3, cons7, cons27, cons71, cons616) rule956 = ReplacementRule(pattern956, With956) pattern957 = Pattern(Integral(x_**m_/((a_ + x_**S(3)*WC('b', S(1)))*sqrt(c_ + x_**S(3)*WC('d', S(1)))), x_), cons2, cons3, cons7, cons27, cons71, cons616, cons617) def replacement957(m, b, d, a, c, x): rubi.append(957) return Dist(S(1)/b, Int(x**(m + S(-3))/sqrt(c + d*x**S(3)), x), x) - Dist(a/b, Int(x**(m + S(-3))/((a + b*x**S(3))*sqrt(c + d*x**S(3))), x), x) rule957 = ReplacementRule(pattern957, replacement957) pattern958 = Pattern(Integral(x_**m_/((a_ + x_**S(3)*WC('b', S(1)))*sqrt(c_ + x_**S(3)*WC('d', S(1)))), x_), cons2, cons3, cons7, cons27, cons71, cons616, cons618) def replacement958(m, b, d, a, c, x): rubi.append(958) return Dist(S(1)/a, Int(x**m/sqrt(c + d*x**S(3)), x), x) - Dist(b/a, Int(x**(m + S(3))/((a + b*x**S(3))*sqrt(c + d*x**S(3))), x), x) rule958 = ReplacementRule(pattern958, replacement958) pattern959 = Pattern(Integral(x_**S(2)*sqrt(c_ + x_**S(4)*WC('d', S(1)))/(a_ + x_**S(4)*WC('b', S(1))), x_), cons2, cons3, cons7, cons27, cons71) def replacement959(b, d, c, a, x): rubi.append(959) return Dist(d/b, Int(x**S(2)/sqrt(c + d*x**S(4)), x), x) + Dist((-a*d + b*c)/b, Int(x**S(2)/((a + b*x**S(4))*sqrt(c + d*x**S(4))), x), x) rule959 = ReplacementRule(pattern959, replacement959) pattern960 = Pattern(Integral(x_**WC('m', S(1))*sqrt(c_ + x_**S(3)*WC('d', S(1)))/(a_ + x_**S(3)*WC('b', S(1))), x_), cons2, cons3, cons7, cons27, cons71, cons616, cons619) def replacement960(m, b, d, a, c, x): rubi.append(960) return Dist(d/b, Int(x**m/sqrt(c + d*x**S(3)), x), x) + Dist((-a*d + b*c)/b, Int(x**m/((a + b*x**S(3))*sqrt(c + d*x**S(3))), x), x) rule960 = ReplacementRule(pattern960, replacement960) pattern961 = Pattern(Integral(x_**S(2)/(sqrt(a_ + x_**S(2)*WC('b', S(1)))*sqrt(c_ + x_**S(2)*WC('d', S(1)))), x_), cons2, cons3, cons7, cons27, cons71, cons466, cons573, cons580) def replacement961(b, d, c, a, x): rubi.append(961) return -Dist(c/b, Int(sqrt(a + b*x**S(2))/(c + d*x**S(2))**(S(3)/2), x), x) + Simp(x*sqrt(a + b*x**S(2))/(b*sqrt(c + d*x**S(2))), x) rule961 = ReplacementRule(pattern961, replacement961) pattern962 = Pattern(Integral(x_**n_/(sqrt(a_ + x_**n_*WC('b', S(1)))*sqrt(c_ + x_**n_*WC('d', S(1)))), x_), cons2, cons3, cons7, cons27, cons71, cons620, cons621) def replacement962(b, d, a, n, c, x): rubi.append(962) return Dist(S(1)/b, Int(sqrt(a + b*x**n)/sqrt(c + d*x**n), x), x) - Dist(a/b, Int(S(1)/(sqrt(a + b*x**n)*sqrt(c + d*x**n)), x), x) rule962 = ReplacementRule(pattern962, replacement962) def With963(p, m, b, d, a, n, c, x, q): k = Denominator(p) rubi.append(963) return Dist(a**(p + (m + S(1))/n)*k/n, Subst(Int(x**(k*(m + S(1))/n + S(-1))*(c - x**k*(-a*d + b*c))**q*(-b*x**k + S(1))**(-p - q + S(-1) - (m + S(1))/n), x), x, x**(n/k)*(a + b*x**n)**(-S(1)/k)), x) pattern963 = Pattern(Integral(x_**WC('m', S(1))*(a_ + x_**n_*WC('b', S(1)))**p_*(c_ + x_**n_*WC('d', S(1)))**WC('q', S(1)), x_), cons2, cons3, cons7, cons27, cons148, cons244, cons622, cons485) rule963 = ReplacementRule(pattern963, With963) pattern964 = Pattern(Integral(x_**WC('m', S(1))*(a_ + x_**n_*WC('b', S(1)))**p_*(c_ + x_**n_*WC('d', S(1)))**q_, x_), cons2, cons3, cons7, cons27, cons5, cons50, cons71, cons196, cons17) def replacement964(p, m, b, d, a, n, c, x, q): rubi.append(964) return -Subst(Int(x**(-m + S(-2))*(a + b*x**(-n))**p*(c + d*x**(-n))**q, x), x, S(1)/x) rule964 = ReplacementRule(pattern964, replacement964) def With965(p, m, b, d, a, n, c, x, q, e): g = Denominator(m) rubi.append(965) return -Dist(g/e, Subst(Int(x**(-g*(m + S(1)) + S(-1))*(a + b*e**(-n)*x**(-g*n))**p*(c + d*e**(-n)*x**(-g*n))**q, x), x, (e*x)**(-S(1)/g)), x) pattern965 = Pattern(Integral((x_*WC('e', S(1)))**m_*(a_ + x_**n_*WC('b', S(1)))**p_*(c_ + x_**n_*WC('d', S(1)))**q_, x_), cons2, cons3, cons7, cons27, cons48, cons5, cons50, cons196, cons367) rule965 = ReplacementRule(pattern965, With965) pattern966 = Pattern(Integral((x_*WC('e', S(1)))**m_*(a_ + x_**n_*WC('b', S(1)))**p_*(c_ + x_**n_*WC('d', S(1)))**q_, x_), cons2, cons3, cons7, cons27, cons48, cons21, cons5, cons50, cons71, cons196, cons356) def replacement966(p, m, b, d, a, n, c, x, q, e): rubi.append(966) return -Dist((e*x)**m*(S(1)/x)**m, Subst(Int(x**(-m + S(-2))*(a + b*x**(-n))**p*(c + d*x**(-n))**q, x), x, S(1)/x), x) rule966 = ReplacementRule(pattern966, replacement966) def With967(p, m, b, d, a, n, c, x, q): g = Denominator(n) rubi.append(967) return Dist(g, Subst(Int(x**(g*(m + S(1)) + S(-1))*(a + b*x**(g*n))**p*(c + d*x**(g*n))**q, x), x, x**(S(1)/g)), x) pattern967 = Pattern(Integral(x_**WC('m', S(1))*(a_ + x_**n_*WC('b', S(1)))**p_*(c_ + x_**n_*WC('d', S(1)))**q_, x_), cons2, cons3, cons7, cons27, cons21, cons5, cons50, cons71, cons489) rule967 = ReplacementRule(pattern967, With967) pattern968 = Pattern(Integral((e_*x_)**m_*(a_ + x_**n_*WC('b', S(1)))**p_*(c_ + x_**n_*WC('d', S(1)))**q_, x_), cons2, cons3, cons7, cons27, cons48, cons21, cons5, cons50, cons71, cons489) def replacement968(p, m, b, d, a, n, c, x, q, e): rubi.append(968) return Dist(e**IntPart(m)*x**(-FracPart(m))*(e*x)**FracPart(m), Int(x**m*(a + b*x**n)**p*(c + d*x**n)**q, x), x) rule968 = ReplacementRule(pattern968, replacement968) pattern969 = Pattern(Integral(x_**WC('m', S(1))*(a_ + x_**n_*WC('b', S(1)))**p_*(c_ + x_**n_*WC('d', S(1)))**q_, x_), cons2, cons3, cons7, cons27, cons21, cons4, cons5, cons50, cons71, cons541, cons23) def replacement969(p, m, b, d, a, n, c, x, q): rubi.append(969) return Dist(S(1)/(m + S(1)), Subst(Int((a + b*x**(n/(m + S(1))))**p*(c + d*x**(n/(m + S(1))))**q, x), x, x**(m + S(1))), x) rule969 = ReplacementRule(pattern969, replacement969) pattern970 = Pattern(Integral((e_*x_)**WC('m', S(1))*(a_ + x_**n_*WC('b', S(1)))**p_*(c_ + x_**n_*WC('d', S(1)))**q_, x_), cons2, cons3, cons7, cons27, cons48, cons21, cons4, cons5, cons50, cons71, cons541, cons23) def replacement970(p, m, b, d, a, n, c, x, q, e): rubi.append(970) return Dist(e**IntPart(m)*x**(-FracPart(m))*(e*x)**FracPart(m), Int(x**m*(a + b*x**n)**p*(c + d*x**n)**q, x), x) rule970 = ReplacementRule(pattern970, replacement970) pattern971 = Pattern(Integral((x_*WC('e', S(1)))**WC('m', S(1))*(a_ + x_**n_*WC('b', S(1)))**p_*(c_ + x_**n_*WC('d', S(1)))**q_, x_), cons2, cons3, cons7, cons27, cons48, cons21, cons4, cons71, cons402, cons137, cons576, cons608) def replacement971(p, m, b, d, a, n, c, x, q, e): rubi.append(971) return Dist(S(1)/(a*b*n*(p + S(1))), Int((e*x)**m*(a + b*x**n)**(p + S(1))*(c + d*x**n)**(q + S(-2))*Simp(c*(b*c*n*(p + S(1)) + (m + S(1))*(-a*d + b*c)) + d*x**n*(b*c*n*(p + S(1)) + (-a*d + b*c)*(m + n*(q + S(-1)) + S(1))), x), x), x) - Simp((e*x)**(m + S(1))*(a + b*x**n)**(p + S(1))*(c + d*x**n)**(q + S(-1))*(-a*d + b*c)/(a*b*e*n*(p + S(1))), x) rule971 = ReplacementRule(pattern971, replacement971) pattern972 = Pattern(Integral((x_*WC('e', S(1)))**WC('m', S(1))*(a_ + x_**n_*WC('b', S(1)))**p_*(c_ + x_**n_*WC('d', S(1)))**q_, x_), cons2, cons3, cons7, cons27, cons48, cons21, cons4, cons71, cons402, cons137, cons574, cons608) def replacement972(p, m, b, d, a, n, c, x, q, e): rubi.append(972) return Dist(S(1)/(a*n*(p + S(1))), Int((e*x)**m*(a + b*x**n)**(p + S(1))*(c + d*x**n)**(q + S(-1))*Simp(c*(m + n*(p + S(1)) + S(1)) + d*x**n*(m + n*(p + q + S(1)) + S(1)), x), x), x) - Simp((e*x)**(m + S(1))*(a + b*x**n)**(p + S(1))*(c + d*x**n)**q/(a*e*n*(p + S(1))), x) rule972 = ReplacementRule(pattern972, replacement972) pattern973 = Pattern(Integral((x_*WC('e', S(1)))**WC('m', S(1))*(a_ + x_**n_*WC('b', S(1)))**p_*(c_ + x_**n_*WC('d', S(1)))**q_, x_), cons2, cons3, cons7, cons27, cons48, cons21, cons4, cons50, cons71, cons13, cons137, cons608) def replacement973(p, m, b, d, a, n, c, x, q, e): rubi.append(973) return Dist(S(1)/(a*n*(p + S(1))*(-a*d + b*c)), Int((e*x)**m*(a + b*x**n)**(p + S(1))*(c + d*x**n)**q*Simp(b*c*(m + S(1)) + b*d*x**n*(m + n*(p + q + S(2)) + S(1)) + n*(p + S(1))*(-a*d + b*c), x), x), x) - Simp(b*(e*x)**(m + S(1))*(a + b*x**n)**(p + S(1))*(c + d*x**n)**(q + S(1))/(a*e*n*(p + S(1))*(-a*d + b*c)), x) rule973 = ReplacementRule(pattern973, replacement973) pattern974 = Pattern(Integral((x_*WC('e', S(1)))**WC('m', S(1))*(a_ + x_**n_*WC('b', S(1)))**p_*(c_ + x_**n_*WC('d', S(1)))**q_, x_), cons2, cons3, cons7, cons27, cons48, cons21, cons4, cons71, cons402, cons403, cons163, cons608) def replacement974(p, m, b, d, a, n, c, x, q, e): rubi.append(974) return Dist(n/(m + n*(p + q) + S(1)), Int((e*x)**m*(a + b*x**n)**(p + S(-1))*(c + d*x**n)**(q + S(-1))*Simp(a*c*(p + q) + x**n*(a*d*(p + q) + q*(-a*d + b*c)), x), x), x) + Simp((e*x)**(m + S(1))*(a + b*x**n)**p*(c + d*x**n)**q/(e*(m + n*(p + q) + S(1))), x) rule974 = ReplacementRule(pattern974, replacement974) pattern975 = Pattern(Integral((x_*WC('e', S(1)))**WC('m', S(1))*(a_ + x_**n_*WC('b', S(1)))**p_*(c_ + x_**n_*WC('d', S(1)))**q_, x_), cons2, cons3, cons7, cons27, cons48, cons21, cons4, cons5, cons71, cons395, cons576, cons608) def replacement975(p, m, b, d, a, n, c, x, q, e): rubi.append(975) return Dist(S(1)/(b*(m + n*(p + q) + S(1))), Int((e*x)**m*(a + b*x**n)**p*(c + d*x**n)**(q + S(-2))*Simp(c*(b*c*n*(p + q) + (m + S(1))*(-a*d + b*c)) + x**n*(b*c*d*n*(p + q) + d*n*(q + S(-1))*(-a*d + b*c) + d*(m + S(1))*(-a*d + b*c)), x), x), x) + Simp(d*(e*x)**(m + S(1))*(a + b*x**n)**(p + S(1))*(c + d*x**n)**(q + S(-1))/(b*e*(m + n*(p + q) + S(1))), x) rule975 = ReplacementRule(pattern975, replacement975) pattern976 = Pattern(Integral(x_**m_/((a_ + x_**n_*WC('b', S(1)))*(c_ + x_**n_*WC('d', S(1)))), x_), cons2, cons3, cons7, cons27, cons21, cons4, cons71, cons623) def replacement976(m, b, d, a, n, c, x): rubi.append(976) return -Dist(a/(-a*d + b*c), Int(x**(m - n)/(a + b*x**n), x), x) + Dist(c/(-a*d + b*c), Int(x**(m - n)/(c + d*x**n), x), x) rule976 = ReplacementRule(pattern976, replacement976) pattern977 = Pattern(Integral((x_*WC('e', S(1)))**WC('m', S(1))/((a_ + x_**n_*WC('b', S(1)))*(c_ + x_**n_*WC('d', S(1)))), x_), cons2, cons3, cons7, cons27, cons48, cons4, cons21, cons71) def replacement977(m, b, d, a, n, c, x, e): rubi.append(977) return Dist(b/(-a*d + b*c), Int((e*x)**m/(a + b*x**n), x), x) - Dist(d/(-a*d + b*c), Int((e*x)**m/(c + d*x**n), x), x) rule977 = ReplacementRule(pattern977, replacement977) pattern978 = Pattern(Integral((x_*WC('e', S(1)))**WC('m', S(1))*(a_ + x_**n_*WC('b', S(1)))**p_*(c_ + x_**n_*WC('d', S(1)))**q_, x_), cons2, cons3, cons7, cons27, cons48, cons21, cons4, cons71, cons624, cons625, cons626) def replacement978(p, m, b, d, a, n, c, x, q, e): rubi.append(978) return Int(ExpandIntegrand((e*x)**m*(a + b*x**n)**p*(c + d*x**n)**q, x), x) rule978 = ReplacementRule(pattern978, replacement978) pattern979 = Pattern(Integral(x_**WC('m', S(1))*(a_ + x_**WC('n', S(1))*WC('b', S(1)))**WC('p', S(1))*(c_ + x_**WC('mn', S(1))*WC('d', S(1)))**WC('q', S(1)), x_), cons2, cons3, cons7, cons27, cons21, cons4, cons5, cons585, cons586, cons587) def replacement979(mn, p, m, b, d, c, n, a, x, q): rubi.append(979) return Int(x**(m - n*q)*(a + b*x**n)**p*(c*x**n + d)**q, x) rule979 = ReplacementRule(pattern979, replacement979) pattern980 = Pattern(Integral(x_**WC('m', S(1))*(a_ + x_**WC('n', S(1))*WC('b', S(1)))**WC('p', S(1))*(c_ + x_**WC('mn', S(1))*WC('d', S(1)))**q_, x_), cons2, cons3, cons7, cons27, cons21, cons4, cons5, cons50, cons585, cons386, cons147) def replacement980(mn, p, m, b, d, c, n, a, x, q): rubi.append(980) return Dist(x**(n*FracPart(q))*(c + d*x**(-n))**FracPart(q)*(c*x**n + d)**(-FracPart(q)), Int(x**(m - n*q)*(a + b*x**n)**p*(c*x**n + d)**q, x), x) rule980 = ReplacementRule(pattern980, replacement980) pattern981 = Pattern(Integral((e_*x_)**m_*(c_ + x_**WC('mn', S(1))*WC('d', S(1)))**WC('q', S(1))*(x_**WC('n', S(1))*WC('b', S(1)) + WC('a', S(0)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons21, cons4, cons5, cons50, cons585) def replacement981(mn, p, m, b, d, a, n, c, x, q, e): rubi.append(981) return Dist(e**IntPart(m)*x**(-FracPart(m))*(e*x)**FracPart(m), Int(x**m*(a + b*x**n)**p*(c + d*x**(-n))**q, x), x) rule981 = ReplacementRule(pattern981, replacement981) pattern982 = Pattern(Integral((x_*WC('e', S(1)))**WC('m', S(1))*(a_ + x_**n_*WC('b', S(1)))**p_*(c_ + x_**n_*WC('d', S(1)))**q_, x_), cons2, cons3, cons7, cons27, cons48, cons21, cons4, cons5, cons50, cons71, cons66, cons627, cons43, cons177) def replacement982(p, m, b, d, a, n, c, x, q, e): rubi.append(982) return Simp(a**p*c**q*(e*x)**(m + S(1))*AppellF1((m + S(1))/n, -p, -q, S(1) + (m + S(1))/n, -b*x**n/a, -d*x**n/c)/(e*(m + S(1))), x) rule982 = ReplacementRule(pattern982, replacement982) pattern983 = Pattern(Integral((x_*WC('e', S(1)))**WC('m', S(1))*(a_ + x_**n_*WC('b', S(1)))**p_*(c_ + x_**n_*WC('d', S(1)))**q_, x_), cons2, cons3, cons7, cons27, cons48, cons21, cons4, cons5, cons50, cons71, cons66, cons627, cons448) def replacement983(p, m, b, d, a, n, c, x, q, e): rubi.append(983) return Dist(a**IntPart(p)*(S(1) + b*x**n/a)**(-FracPart(p))*(a + b*x**n)**FracPart(p), Int((e*x)**m*(S(1) + b*x**n/a)**p*(c + d*x**n)**q, x), x) rule983 = ReplacementRule(pattern983, replacement983) pattern984 = Pattern(Integral(x_**WC('m', S(1))*(v_**n_*WC('b', S(1)) + WC('a', S(0)))**WC('p', S(1))*(v_**n_*WC('d', S(1)) + WC('c', S(0)))**WC('q', S(1)), x_), cons2, cons3, cons7, cons27, cons4, cons5, cons50, cons552, cons17, cons553) def replacement984(v, p, m, b, d, c, a, n, x, q): rubi.append(984) return Dist(Coefficient(v, x, S(1))**(-m + S(-1)), Subst(Int(SimplifyIntegrand((a + b*x**n)**p*(c + d*x**n)**q*(x - Coefficient(v, x, S(0)))**m, x), x), x, v), x) rule984 = ReplacementRule(pattern984, replacement984) pattern985 = Pattern(Integral(u_**WC('m', S(1))*(v_**n_*WC('b', S(1)) + WC('a', S(0)))**WC('p', S(1))*(v_**n_*WC('d', S(1)) + WC('c', S(0)))**WC('q', S(1)), x_), cons2, cons3, cons7, cons27, cons21, cons4, cons5, cons50, cons554) def replacement985(v, p, u, m, b, d, c, a, n, x, q): rubi.append(985) return Dist(u**m*v**(-m)/Coefficient(v, x, S(1)), Subst(Int(x**m*(a + b*x**n)**p*(c + d*x**n)**q, x), x, v), x) rule985 = ReplacementRule(pattern985, replacement985) pattern986 = Pattern(Integral((a1_ + x_**WC('non2', S(1))*WC('b1', S(1)))**WC('p', S(1))*(a2_ + x_**WC('non2', S(1))*WC('b2', S(1)))**WC('p', S(1))*(c_ + x_**WC('n', S(1))*WC('d', S(1)))**WC('q', S(1))*WC('u', S(1)), x_), cons57, cons58, cons59, cons60, cons7, cons27, cons4, cons5, cons50, cons593, cons55, cons494) def replacement986(p, a2, u, b2, b1, d, c, n, non2, x, a1, q): rubi.append(986) return Int(u*(c + d*x**n)**q*(a1*a2 + b1*b2*x**n)**p, x) rule986 = ReplacementRule(pattern986, replacement986) pattern987 = Pattern(Integral((a1_ + x_**WC('non2', S(1))*WC('b1', S(1)))**WC('p', S(1))*(a2_ + x_**WC('non2', S(1))*WC('b2', S(1)))**WC('p', S(1))*(c_ + x_**WC('n', S(1))*WC('d', S(1)) + x_**WC('n2', S(1))*WC('e', S(1)))**WC('q', S(1))*WC('u', S(1)), x_), cons57, cons58, cons59, cons60, cons7, cons27, cons48, cons4, cons5, cons50, cons593, cons46, cons55, cons494) def replacement987(p, a2, u, b2, n2, b1, d, c, n, non2, x, a1, q, e): rubi.append(987) return Int(u*(a1*a2 + b1*b2*x**n)**p*(c + d*x**n + e*x**(S(2)*n))**q, x) rule987 = ReplacementRule(pattern987, replacement987) pattern988 = Pattern(Integral((a1_ + x_**WC('non2', S(1))*WC('b1', S(1)))**p_*(a2_ + x_**WC('non2', S(1))*WC('b2', S(1)))**p_*(c_ + x_**WC('n', S(1))*WC('d', S(1)))**WC('q', S(1))*WC('u', S(1)), x_), cons57, cons58, cons59, cons60, cons7, cons27, cons4, cons5, cons50, cons593, cons55) def replacement988(p, a2, u, b2, b1, d, c, n, non2, x, a1, q): rubi.append(988) return Dist((a1 + b1*x**(n/S(2)))**FracPart(p)*(a2 + b2*x**(n/S(2)))**FracPart(p)*(a1*a2 + b1*b2*x**n)**(-FracPart(p)), Int(u*(c + d*x**n)**q*(a1*a2 + b1*b2*x**n)**p, x), x) rule988 = ReplacementRule(pattern988, replacement988) pattern989 = Pattern(Integral((a1_ + x_**WC('non2', S(1))*WC('b1', S(1)))**WC('p', S(1))*(a2_ + x_**WC('non2', S(1))*WC('b2', S(1)))**WC('p', S(1))*(c_ + x_**WC('n', S(1))*WC('d', S(1)) + x_**WC('n2', S(1))*WC('e', S(1)))**WC('q', S(1))*WC('u', S(1)), x_), cons57, cons58, cons59, cons60, cons7, cons27, cons48, cons4, cons5, cons50, cons593, cons46, cons55) def replacement989(p, a2, u, b2, n2, b1, d, c, n, non2, x, a1, q, e): rubi.append(989) return Dist((a1 + b1*x**(n/S(2)))**FracPart(p)*(a2 + b2*x**(n/S(2)))**FracPart(p)*(a1*a2 + b1*b2*x**n)**(-FracPart(p)), Int(u*(a1*a2 + b1*b2*x**n)**p*(c + d*x**n + e*x**(S(2)*n))**q, x), x) rule989 = ReplacementRule(pattern989, replacement989) pattern990 = Pattern(Integral((a_ + x_**n_*WC('b', S(1)))**WC('p', S(1))*(c_ + x_**n_*WC('d', S(1)))**WC('q', S(1))*(e_ + x_**n_*WC('f', S(1)))**WC('r', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons4, cons628) def replacement990(p, f, b, r, d, a, n, c, x, q, e): rubi.append(990) return Int(ExpandIntegrand((a + b*x**n)**p*(c + d*x**n)**q*(e + f*x**n)**r, x), x) rule990 = ReplacementRule(pattern990, replacement990) pattern991 = Pattern(Integral((e_ + x_**n_*WC('f', S(1)))/((a_ + x_**n_*WC('b', S(1)))*(c_ + x_**n_*WC('d', S(1)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons4, cons629) def replacement991(f, b, d, a, n, c, x, e): rubi.append(991) return Dist((-a*f + b*e)/(-a*d + b*c), Int(S(1)/(a + b*x**n), x), x) - Dist((-c*f + d*e)/(-a*d + b*c), Int(S(1)/(c + d*x**n), x), x) rule991 = ReplacementRule(pattern991, replacement991) pattern992 = Pattern(Integral((e_ + x_**n_*WC('f', S(1)))/((a_ + x_**n_*WC('b', S(1)))*sqrt(c_ + x_**n_*WC('d', S(1)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons4, cons629) def replacement992(f, b, d, a, n, c, x, e): rubi.append(992) return Dist(f/b, Int(S(1)/sqrt(c + d*x**n), x), x) + Dist((-a*f + b*e)/b, Int(S(1)/((a + b*x**n)*sqrt(c + d*x**n)), x), x) rule992 = ReplacementRule(pattern992, replacement992) pattern993 = Pattern(Integral((e_ + x_**n_*WC('f', S(1)))/(sqrt(a_ + x_**n_*WC('b', S(1)))*sqrt(c_ + x_**n_*WC('d', S(1)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons4, cons630) def replacement993(f, b, d, a, n, c, x, e): rubi.append(993) return Dist(f/b, Int(sqrt(a + b*x**n)/sqrt(c + d*x**n), x), x) + Dist((-a*f + b*e)/b, Int(S(1)/(sqrt(a + b*x**n)*sqrt(c + d*x**n)), x), x) rule993 = ReplacementRule(pattern993, replacement993) pattern994 = Pattern(Integral((e_ + x_**S(2)*WC('f', S(1)))/(sqrt(a_ + x_**S(2)*WC('b', S(1)))*(c_ + x_**S(2)*WC('d', S(1)))**(S(3)/2)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons466, cons573) def replacement994(f, b, d, a, c, x, e): rubi.append(994) return Dist((-a*f + b*e)/(-a*d + b*c), Int(S(1)/(sqrt(a + b*x**S(2))*sqrt(c + d*x**S(2))), x), x) - Dist((-c*f + d*e)/(-a*d + b*c), Int(sqrt(a + b*x**S(2))/(c + d*x**S(2))**(S(3)/2), x), x) rule994 = ReplacementRule(pattern994, replacement994) pattern995 = Pattern(Integral((a_ + x_**n_*WC('b', S(1)))**p_*(c_ + x_**n_*WC('d', S(1)))**WC('q', S(1))*(e_ + x_**n_*WC('f', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons4, cons402, cons137, cons403) def replacement995(p, f, b, d, a, n, c, x, q, e): rubi.append(995) return Dist(S(1)/(a*b*n*(p + S(1))), Int((a + b*x**n)**(p + S(1))*(c + d*x**n)**(q + S(-1))*Simp(c*(-a*f + b*e*n*(p + S(1)) + b*e) + d*x**n*(b*e*n*(p + S(1)) + (-a*f + b*e)*(n*q + S(1))), x), x), x) - Simp(x*(a + b*x**n)**(p + S(1))*(c + d*x**n)**q*(-a*f + b*e)/(a*b*n*(p + S(1))), x) rule995 = ReplacementRule(pattern995, replacement995) pattern996 = Pattern(Integral((a_ + x_**n_*WC('b', S(1)))**p_*(c_ + x_**n_*WC('d', S(1)))**WC('q', S(1))*(e_ + x_**n_*WC('f', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons4, cons50, cons13, cons137) def replacement996(p, f, b, d, a, n, c, x, q, e): rubi.append(996) return Dist(S(1)/(a*n*(p + S(1))*(-a*d + b*c)), Int((a + b*x**n)**(p + S(1))*(c + d*x**n)**q*Simp(c*(-a*f + b*e) + d*x**n*(-a*f + b*e)*(n*(p + q + S(2)) + S(1)) + e*n*(p + S(1))*(-a*d + b*c), x), x), x) - Simp(x*(a + b*x**n)**(p + S(1))*(c + d*x**n)**(q + S(1))*(-a*f + b*e)/(a*n*(p + S(1))*(-a*d + b*c)), x) rule996 = ReplacementRule(pattern996, replacement996) pattern997 = Pattern(Integral((a_ + x_**n_*WC('b', S(1)))**WC('p', S(1))*(c_ + x_**n_*WC('d', S(1)))**WC('q', S(1))*(e_ + x_**n_*WC('f', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons4, cons5, cons395, cons403, cons631) def replacement997(p, f, b, d, a, n, c, x, q, e): rubi.append(997) return Dist(S(1)/(b*(n*(p + q + S(1)) + S(1))), Int((a + b*x**n)**p*(c + d*x**n)**(q + S(-1))*Simp(c*(-a*f + b*e*n*(p + q + S(1)) + b*e) + x**n*(b*d*e*n*(p + q + S(1)) + d*(-a*f + b*e) + f*n*q*(-a*d + b*c)), x), x), x) + Simp(f*x*(a + b*x**n)**(p + S(1))*(c + d*x**n)**q/(b*(n*(p + q + S(1)) + S(1))), x) rule997 = ReplacementRule(pattern997, replacement997) pattern998 = Pattern(Integral((e_ + x_**S(4)*WC('f', S(1)))/((a_ + x_**S(4)*WC('b', S(1)))**(S(3)/4)*(c_ + x_**S(4)*WC('d', S(1)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons153) def replacement998(f, b, d, a, c, x, e): rubi.append(998) return Dist((-a*f + b*e)/(-a*d + b*c), Int((a + b*x**S(4))**(S(-3)/4), x), x) - Dist((-c*f + d*e)/(-a*d + b*c), Int((a + b*x**S(4))**(S(1)/4)/(c + d*x**S(4)), x), x) rule998 = ReplacementRule(pattern998, replacement998) pattern999 = Pattern(Integral((a_ + x_**n_*WC('b', S(1)))**p_*(e_ + x_**n_*WC('f', S(1)))/(c_ + x_**n_*WC('d', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons5, cons4, cons632) def replacement999(p, f, b, d, a, n, c, x, e): rubi.append(999) return Dist(f/d, Int((a + b*x**n)**p, x), x) + Dist((-c*f + d*e)/d, Int((a + b*x**n)**p/(c + d*x**n), x), x) rule999 = ReplacementRule(pattern999, replacement999) pattern1000 = Pattern(Integral((a_ + x_**n_*WC('b', S(1)))**WC('p', S(1))*(c_ + x_**n_*WC('d', S(1)))**WC('q', S(1))*(e_ + x_**n_*WC('f', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons4, cons5, cons50, cons633) def replacement1000(p, f, b, d, a, n, c, x, q, e): rubi.append(1000) return Dist(e, Int((a + b*x**n)**p*(c + d*x**n)**q, x), x) + Dist(f, Int(x**n*(a + b*x**n)**p*(c + d*x**n)**q, x), x) rule1000 = ReplacementRule(pattern1000, replacement1000) pattern1001 = Pattern(Integral(S(1)/((a_ + x_**S(2)*WC('b', S(1)))*(c_ + x_**S(2)*WC('d', S(1)))*sqrt(e_ + x_**S(2)*WC('f', S(1)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons153) def replacement1001(f, b, d, a, c, x, e): rubi.append(1001) return Dist(b/(-a*d + b*c), Int(S(1)/((a + b*x**S(2))*sqrt(e + f*x**S(2))), x), x) - Dist(d/(-a*d + b*c), Int(S(1)/((c + d*x**S(2))*sqrt(e + f*x**S(2))), x), x) rule1001 = ReplacementRule(pattern1001, replacement1001) pattern1002 = Pattern(Integral(S(1)/(x_**S(2)*(c_ + x_**S(2)*WC('d', S(1)))*sqrt(e_ + x_**S(2)*WC('f', S(1)))), x_), cons7, cons27, cons48, cons125, cons176) def replacement1002(f, d, c, x, e): rubi.append(1002) return Dist(S(1)/c, Int(S(1)/(x**S(2)*sqrt(e + f*x**S(2))), x), x) - Dist(d/c, Int(S(1)/((c + d*x**S(2))*sqrt(e + f*x**S(2))), x), x) rule1002 = ReplacementRule(pattern1002, replacement1002) pattern1003 = Pattern(Integral(sqrt(c_ + x_**S(2)*WC('d', S(1)))*sqrt(e_ + x_**S(2)*WC('f', S(1)))/(a_ + x_**S(2)*WC('b', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons634, cons635, cons636) def replacement1003(f, b, d, a, c, x, e): rubi.append(1003) return Dist(d/b, Int(sqrt(e + f*x**S(2))/sqrt(c + d*x**S(2)), x), x) + Dist((-a*d + b*c)/b, Int(sqrt(e + f*x**S(2))/((a + b*x**S(2))*sqrt(c + d*x**S(2))), x), x) rule1003 = ReplacementRule(pattern1003, replacement1003) pattern1004 = Pattern(Integral(sqrt(c_ + x_**S(2)*WC('d', S(1)))*sqrt(e_ + x_**S(2)*WC('f', S(1)))/(a_ + x_**S(2)*WC('b', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons637) def replacement1004(f, b, d, a, c, x, e): rubi.append(1004) return Dist(d/b, Int(sqrt(e + f*x**S(2))/sqrt(c + d*x**S(2)), x), x) + Dist((-a*d + b*c)/b, Int(sqrt(e + f*x**S(2))/((a + b*x**S(2))*sqrt(c + d*x**S(2))), x), x) rule1004 = ReplacementRule(pattern1004, replacement1004) pattern1005 = Pattern(Integral(S(1)/((a_ + x_**S(2)*WC('b', S(1)))*sqrt(c_ + x_**S(2)*WC('d', S(1)))*sqrt(e_ + x_**S(2)*WC('f', S(1)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons573, cons638, cons636) def replacement1005(f, b, d, a, c, x, e): rubi.append(1005) return Dist(b/(-a*f + b*e), Int(sqrt(e + f*x**S(2))/((a + b*x**S(2))*sqrt(c + d*x**S(2))), x), x) - Dist(f/(-a*f + b*e), Int(S(1)/(sqrt(c + d*x**S(2))*sqrt(e + f*x**S(2))), x), x) rule1005 = ReplacementRule(pattern1005, replacement1005) pattern1006 = Pattern(Integral(S(1)/((a_ + x_**S(2)*WC('b', S(1)))*sqrt(c_ + x_**S(2)*WC('d', S(1)))*sqrt(e_ + x_**S(2)*WC('f', S(1)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons581, cons177, cons178, cons639) def replacement1006(f, b, d, a, c, x, e): rubi.append(1006) return Simp(EllipticPi(b*c/(a*d), asin(x*Rt(-d/c, S(2))), c*f/(d*e))/(a*sqrt(c)*sqrt(e)*Rt(-d/c, S(2))), x) rule1006 = ReplacementRule(pattern1006, replacement1006) pattern1007 = Pattern(Integral(S(1)/((a_ + x_**S(2)*WC('b', S(1)))*sqrt(c_ + x_**S(2)*WC('d', S(1)))*sqrt(e_ + x_**S(2)*WC('f', S(1)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons117) def replacement1007(f, b, d, a, c, x, e): rubi.append(1007) return Dist(sqrt(S(1) + d*x**S(2)/c)/sqrt(c + d*x**S(2)), Int(S(1)/(sqrt(S(1) + d*x**S(2)/c)*(a + b*x**S(2))*sqrt(e + f*x**S(2))), x), x) rule1007 = ReplacementRule(pattern1007, replacement1007) pattern1008 = Pattern(Integral(sqrt(c_ + x_**S(2)*WC('d', S(1)))/((a_ + x_**S(2)*WC('b', S(1)))*sqrt(e_ + x_**S(2)*WC('f', S(1)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons573) def replacement1008(f, b, d, a, c, x, e): rubi.append(1008) return Simp(c*sqrt(e + f*x**S(2))*EllipticPi(S(1) - b*c/(a*d), ArcTan(x*Rt(d/c, S(2))), -c*f/(d*e) + S(1))/(a*e*sqrt(c*(e + f*x**S(2))/(e*(c + d*x**S(2))))*sqrt(c + d*x**S(2))*Rt(d/c, S(2))), x) rule1008 = ReplacementRule(pattern1008, replacement1008) pattern1009 = Pattern(Integral(sqrt(c_ + x_**S(2)*WC('d', S(1)))/((a_ + x_**S(2)*WC('b', S(1)))*sqrt(e_ + x_**S(2)*WC('f', S(1)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons581) def replacement1009(f, b, d, a, c, x, e): rubi.append(1009) return Dist(d/b, Int(S(1)/(sqrt(c + d*x**S(2))*sqrt(e + f*x**S(2))), x), x) + Dist((-a*d + b*c)/b, Int(S(1)/((a + b*x**S(2))*sqrt(c + d*x**S(2))*sqrt(e + f*x**S(2))), x), x) rule1009 = ReplacementRule(pattern1009, replacement1009) pattern1010 = Pattern(Integral(sqrt(e_ + x_**S(2)*WC('f', S(1)))/((a_ + x_**S(2)*WC('b', S(1)))*(c_ + x_**S(2)*WC('d', S(1)))**(S(3)/2)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons573, cons638) def replacement1010(f, b, d, a, c, x, e): rubi.append(1010) return Dist(b/(-a*d + b*c), Int(sqrt(e + f*x**S(2))/((a + b*x**S(2))*sqrt(c + d*x**S(2))), x), x) - Dist(d/(-a*d + b*c), Int(sqrt(e + f*x**S(2))/(c + d*x**S(2))**(S(3)/2), x), x) rule1010 = ReplacementRule(pattern1010, replacement1010) pattern1011 = Pattern(Integral((e_ + x_**S(2)*WC('f', S(1)))**(S(3)/2)/((a_ + x_**S(2)*WC('b', S(1)))*(c_ + x_**S(2)*WC('d', S(1)))**(S(3)/2)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons573, cons638) def replacement1011(f, b, d, a, c, x, e): rubi.append(1011) return Dist((-a*f + b*e)/(-a*d + b*c), Int(sqrt(e + f*x**S(2))/((a + b*x**S(2))*sqrt(c + d*x**S(2))), x), x) - Dist((-c*f + d*e)/(-a*d + b*c), Int(sqrt(e + f*x**S(2))/(c + d*x**S(2))**(S(3)/2), x), x) rule1011 = ReplacementRule(pattern1011, replacement1011) pattern1012 = Pattern(Integral((c_ + x_**S(2)*WC('d', S(1)))**(S(3)/2)*sqrt(e_ + x_**S(2)*WC('f', S(1)))/(a_ + x_**S(2)*WC('b', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons573, cons638) def replacement1012(f, b, d, a, c, x, e): rubi.append(1012) return Dist(d/b**S(2), Int(sqrt(e + f*x**S(2))*(-a*d + S(2)*b*c + b*d*x**S(2))/sqrt(c + d*x**S(2)), x), x) + Dist((-a*d + b*c)**S(2)/b**S(2), Int(sqrt(e + f*x**S(2))/((a + b*x**S(2))*sqrt(c + d*x**S(2))), x), x) rule1012 = ReplacementRule(pattern1012, replacement1012) pattern1013 = Pattern(Integral((c_ + x_**S(2)*WC('d', S(1)))**q_*(e_ + x_**S(2)*WC('f', S(1)))**r_/(a_ + x_**S(2)*WC('b', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons640, cons396, cons641) def replacement1013(f, b, r, d, a, c, x, q, e): rubi.append(1013) return Dist(b*(-a*f + b*e)/(-a*d + b*c)**S(2), Int((c + d*x**S(2))**(q + S(2))*(e + f*x**S(2))**(r + S(-1))/(a + b*x**S(2)), x), x) - Dist((-a*d + b*c)**(S(-2)), Int((c + d*x**S(2))**q*(e + f*x**S(2))**(r + S(-1))*(-a*d**S(2)*e - b*c**S(2)*f + S(2)*b*c*d*e + d**S(2)*x**S(2)*(-a*f + b*e)), x), x) rule1013 = ReplacementRule(pattern1013, replacement1013) pattern1014 = Pattern(Integral((c_ + x_**S(2)*WC('d', S(1)))**q_*(e_ + x_**S(2)*WC('f', S(1)))**r_/(a_ + x_**S(2)*WC('b', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons52, cons395, cons576) def replacement1014(f, b, r, d, a, c, x, q, e): rubi.append(1014) return Dist(d/b, Int((c + d*x**S(2))**(q + S(-1))*(e + f*x**S(2))**r, x), x) + Dist((-a*d + b*c)/b, Int((c + d*x**S(2))**(q + S(-1))*(e + f*x**S(2))**r/(a + b*x**S(2)), x), x) rule1014 = ReplacementRule(pattern1014, replacement1014) pattern1015 = Pattern(Integral((c_ + x_**S(2)*WC('d', S(1)))**q_*(e_ + x_**S(2)*WC('f', S(1)))**r_/(a_ + x_**S(2)*WC('b', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons52, cons395, cons396) def replacement1015(f, b, r, d, a, c, x, q, e): rubi.append(1015) return Dist(b**S(2)/(-a*d + b*c)**S(2), Int((c + d*x**S(2))**(q + S(2))*(e + f*x**S(2))**r/(a + b*x**S(2)), x), x) - Dist(d/(-a*d + b*c)**S(2), Int((c + d*x**S(2))**q*(e + f*x**S(2))**r*(-a*d + S(2)*b*c + b*d*x**S(2)), x), x) rule1015 = ReplacementRule(pattern1015, replacement1015) pattern1016 = Pattern(Integral((c_ + x_**S(2)*WC('d', S(1)))**q_*(e_ + x_**S(2)*WC('f', S(1)))**r_/(a_ + x_**S(2)*WC('b', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons52, cons395, cons642) def replacement1016(f, b, r, d, a, c, x, q, e): rubi.append(1016) return Dist(b/(-a*d + b*c), Int((c + d*x**S(2))**(q + S(1))*(e + f*x**S(2))**r/(a + b*x**S(2)), x), x) - Dist(d/(-a*d + b*c), Int((c + d*x**S(2))**q*(e + f*x**S(2))**r, x), x) rule1016 = ReplacementRule(pattern1016, replacement1016) pattern1017 = Pattern(Integral(sqrt(c_ + x_**S(2)*WC('d', S(1)))*sqrt(e_ + x_**S(2)*WC('f', S(1)))/(a_ + x_**S(2)*WC('b', S(1)))**S(2), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons153) def replacement1017(f, b, d, a, c, x, e): rubi.append(1017) return Dist((-a**S(2)*d*f + b**S(2)*c*e)/(S(2)*a*b**S(2)), Int(S(1)/((a + b*x**S(2))*sqrt(c + d*x**S(2))*sqrt(e + f*x**S(2))), x), x) + Dist(d*f/(S(2)*a*b**S(2)), Int((a - b*x**S(2))/(sqrt(c + d*x**S(2))*sqrt(e + f*x**S(2))), x), x) + Simp(x*sqrt(c + d*x**S(2))*sqrt(e + f*x**S(2))/(S(2)*a*(a + b*x**S(2))), x) rule1017 = ReplacementRule(pattern1017, replacement1017) pattern1018 = Pattern(Integral(S(1)/((a_ + x_**S(2)*WC('b', S(1)))**S(2)*sqrt(c_ + x_**S(2)*WC('d', S(1)))*sqrt(e_ + x_**S(2)*WC('f', S(1)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons153) def replacement1018(f, b, d, a, c, x, e): rubi.append(1018) return Dist((S(3)*a**S(2)*d*f - S(2)*a*b*(c*f + d*e) + b**S(2)*c*e)/(S(2)*a*(-a*d + b*c)*(-a*f + b*e)), Int(S(1)/((a + b*x**S(2))*sqrt(c + d*x**S(2))*sqrt(e + f*x**S(2))), x), x) - Dist(d*f/(S(2)*a*(-a*d + b*c)*(-a*f + b*e)), Int((a + b*x**S(2))/(sqrt(c + d*x**S(2))*sqrt(e + f*x**S(2))), x), x) + Simp(b**S(2)*x*sqrt(c + d*x**S(2))*sqrt(e + f*x**S(2))/(S(2)*a*(a + b*x**S(2))*(-a*d + b*c)*(-a*f + b*e)), x) rule1018 = ReplacementRule(pattern1018, replacement1018) pattern1019 = Pattern(Integral((a_ + x_**n_*WC('b', S(1)))**p_*(c_ + x_**n_*WC('d', S(1)))**q_*(e_ + x_**n_*WC('f', S(1)))**r_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons4, cons52, cons63, cons395, cons403) def replacement1019(p, f, b, r, d, a, n, c, x, q, e): rubi.append(1019) return Dist(d/b, Int((a + b*x**n)**(p + S(1))*(c + d*x**n)**(q + S(-1))*(e + f*x**n)**r, x), x) + Dist((-a*d + b*c)/b, Int((a + b*x**n)**p*(c + d*x**n)**(q + S(-1))*(e + f*x**n)**r, x), x) rule1019 = ReplacementRule(pattern1019, replacement1019) pattern1020 = Pattern(Integral((a_ + x_**n_*WC('b', S(1)))**p_*(c_ + x_**n_*WC('d', S(1)))**q_*(e_ + x_**n_*WC('f', S(1)))**r_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons4, cons50, cons63, cons395, cons642) def replacement1020(p, f, b, r, d, a, n, c, x, q, e): rubi.append(1020) return Dist(b/(-a*d + b*c), Int((a + b*x**n)**p*(c + d*x**n)**(q + S(1))*(e + f*x**n)**r, x), x) - Dist(d/(-a*d + b*c), Int((a + b*x**n)**(p + S(1))*(c + d*x**n)**q*(e + f*x**n)**r, x), x) rule1020 = ReplacementRule(pattern1020, replacement1020) pattern1021 = Pattern(Integral(S(1)/(sqrt(a_ + x_**S(2)*WC('b', S(1)))*sqrt(c_ + x_**S(2)*WC('d', S(1)))*sqrt(e_ + x_**S(2)*WC('f', S(1)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons153) def replacement1021(f, b, d, a, c, x, e): rubi.append(1021) return Dist(sqrt(a*(e + f*x**S(2))/(e*(a + b*x**S(2))))*sqrt(c + d*x**S(2))/(c*sqrt(a*(c + d*x**S(2))/(c*(a + b*x**S(2))))*sqrt(e + f*x**S(2))), Subst(Int(S(1)/(sqrt(S(1) - x**S(2)*(-a*d + b*c)/c)*sqrt(S(1) - x**S(2)*(-a*f + b*e)/e)), x), x, x/sqrt(a + b*x**S(2))), x) rule1021 = ReplacementRule(pattern1021, replacement1021) pattern1022 = Pattern(Integral(sqrt(a_ + x_**S(2)*WC('b', S(1)))/(sqrt(c_ + x_**S(2)*WC('d', S(1)))*sqrt(e_ + x_**S(2)*WC('f', S(1)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons153) def replacement1022(f, b, d, a, c, x, e): rubi.append(1022) return Dist(a*sqrt(a*(e + f*x**S(2))/(e*(a + b*x**S(2))))*sqrt(c + d*x**S(2))/(c*sqrt(a*(c + d*x**S(2))/(c*(a + b*x**S(2))))*sqrt(e + f*x**S(2))), Subst(Int(S(1)/(sqrt(S(1) - x**S(2)*(-a*d + b*c)/c)*sqrt(S(1) - x**S(2)*(-a*f + b*e)/e)*(-b*x**S(2) + S(1))), x), x, x/sqrt(a + b*x**S(2))), x) rule1022 = ReplacementRule(pattern1022, replacement1022) pattern1023 = Pattern(Integral(sqrt(c_ + x_**S(2)*WC('d', S(1)))/((a_ + x_**S(2)*WC('b', S(1)))**(S(3)/2)*sqrt(e_ + x_**S(2)*WC('f', S(1)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons153) def replacement1023(f, b, d, a, c, x, e): rubi.append(1023) return Dist(sqrt(a*(e + f*x**S(2))/(e*(a + b*x**S(2))))*sqrt(c + d*x**S(2))/(a*sqrt(a*(c + d*x**S(2))/(c*(a + b*x**S(2))))*sqrt(e + f*x**S(2))), Subst(Int(sqrt(S(1) - x**S(2)*(-a*d + b*c)/c)/sqrt(S(1) - x**S(2)*(-a*f + b*e)/e), x), x, x/sqrt(a + b*x**S(2))), x) rule1023 = ReplacementRule(pattern1023, replacement1023) pattern1024 = Pattern(Integral(sqrt(a_ + x_**S(2)*WC('b', S(1)))*sqrt(c_ + x_**S(2)*WC('d', S(1)))/sqrt(e_ + x_**S(2)*WC('f', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons643) def replacement1024(f, b, d, a, c, x, e): rubi.append(1024) return -Dist(c*(-c*f + d*e)/(S(2)*f), Int(sqrt(a + b*x**S(2))/((c + d*x**S(2))**(S(3)/2)*sqrt(e + f*x**S(2))), x), x) - Dist((-a*d*f - b*c*f + b*d*e)/(S(2)*d*f), Int(sqrt(c + d*x**S(2))/(sqrt(a + b*x**S(2))*sqrt(e + f*x**S(2))), x), x) + Dist(b*c*(-c*f + d*e)/(S(2)*d*f), Int(S(1)/(sqrt(a + b*x**S(2))*sqrt(c + d*x**S(2))*sqrt(e + f*x**S(2))), x), x) + Simp(d*x*sqrt(a + b*x**S(2))*sqrt(e + f*x**S(2))/(S(2)*f*sqrt(c + d*x**S(2))), x) rule1024 = ReplacementRule(pattern1024, replacement1024) pattern1025 = Pattern(Integral(sqrt(a_ + x_**S(2)*WC('b', S(1)))*sqrt(c_ + x_**S(2)*WC('d', S(1)))/sqrt(e_ + x_**S(2)*WC('f', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons644) def replacement1025(f, b, d, a, c, x, e): rubi.append(1025) return -Dist((-a*d*f - b*c*f + b*d*e)/(S(2)*f**S(2)), Int(sqrt(e + f*x**S(2))/(sqrt(a + b*x**S(2))*sqrt(c + d*x**S(2))), x), x) + Dist(e*(-a*f + b*e)/(S(2)*f), Int(sqrt(c + d*x**S(2))/(sqrt(a + b*x**S(2))*(e + f*x**S(2))**(S(3)/2)), x), x) + Dist((-a*f + b*e)*(-S(2)*c*f + d*e)/(S(2)*f**S(2)), Int(S(1)/(sqrt(a + b*x**S(2))*sqrt(c + d*x**S(2))*sqrt(e + f*x**S(2))), x), x) + Simp(x*sqrt(a + b*x**S(2))*sqrt(c + d*x**S(2))/(S(2)*sqrt(e + f*x**S(2))), x) rule1025 = ReplacementRule(pattern1025, replacement1025) pattern1026 = Pattern(Integral(sqrt(a_ + x_**S(2)*WC('b', S(1)))*sqrt(c_ + x_**S(2)*WC('d', S(1)))/(e_ + x_**S(2)*WC('f', S(1)))**(S(3)/2), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons153) def replacement1026(f, b, d, a, c, x, e): rubi.append(1026) return Dist(b/f, Int(sqrt(c + d*x**S(2))/(sqrt(a + b*x**S(2))*sqrt(e + f*x**S(2))), x), x) - Dist((-a*f + b*e)/f, Int(sqrt(c + d*x**S(2))/(sqrt(a + b*x**S(2))*(e + f*x**S(2))**(S(3)/2)), x), x) rule1026 = ReplacementRule(pattern1026, replacement1026) def With1027(p, f, b, r, d, a, n, c, x, q, e): if isinstance(x, (int, Integer, float, Float)): return False u = ExpandIntegrand((a + b*x**n)**p*(c + d*x**n)**q*(e + f*x**n)**r, x) if SumQ(u): return True return False pattern1027 = Pattern(Integral((a_ + x_**n_*WC('b', S(1)))**p_*(c_ + x_**n_*WC('d', S(1)))**q_*(e_ + x_**n_*WC('f', S(1)))**r_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons5, cons50, cons52, cons148, CustomConstraint(With1027)) def replacement1027(p, f, b, r, d, a, n, c, x, q, e): u = ExpandIntegrand((a + b*x**n)**p*(c + d*x**n)**q*(e + f*x**n)**r, x) rubi.append(1027) return Int(u, x) rule1027 = ReplacementRule(pattern1027, replacement1027) pattern1028 = Pattern(Integral((a_ + x_**n_*WC('b', S(1)))**p_*(c_ + x_**n_*WC('d', S(1)))**q_*(e_ + x_**n_*WC('f', S(1)))**r_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons5, cons50, cons52, cons196) def replacement1028(p, f, b, r, d, a, n, c, x, q, e): rubi.append(1028) return -Subst(Int((a + b*x**(-n))**p*(c + d*x**(-n))**q*(e + f*x**(-n))**r/x**S(2), x), x, S(1)/x) rule1028 = ReplacementRule(pattern1028, replacement1028) pattern1029 = Pattern(Integral((a_ + x_**n_*WC('b', S(1)))**WC('p', S(1))*(c_ + x_**n_*WC('d', S(1)))**WC('q', S(1))*(e_ + x_**n_*WC('f', S(1)))**WC('r', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons4, cons5, cons50, cons52, cons645) def replacement1029(p, f, b, r, d, a, n, c, x, q, e): rubi.append(1029) return Int((a + b*x**n)**p*(c + d*x**n)**q*(e + f*x**n)**r, x) rule1029 = ReplacementRule(pattern1029, replacement1029) pattern1030 = Pattern(Integral((u_**n_*WC('b', S(1)) + WC('a', S(0)))**WC('p', S(1))*(v_**n_*WC('d', S(1)) + WC('c', S(0)))**WC('q', S(1))*(w_**n_*WC('f', S(1)) + WC('e', S(0)))**WC('r', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons5, cons4, cons50, cons52, cons646, cons647, cons68, cons69) def replacement1030(v, w, p, u, f, b, r, d, c, a, n, x, q, e): rubi.append(1030) return Dist(S(1)/Coefficient(u, x, S(1)), Subst(Int((a + b*x**n)**p*(c + d*x**n)**q*(e + f*x**n)**r, x), x, u), x) rule1030 = ReplacementRule(pattern1030, replacement1030) pattern1031 = Pattern(Integral((c_ + x_**WC('mn', S(1))*WC('d', S(1)))**WC('q', S(1))*(e_ + x_**WC('n', S(1))*WC('f', S(1)))**WC('r', S(1))*(x_**WC('n', S(1))*WC('b', S(1)) + WC('a', S(0)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons4, cons5, cons52, cons585, cons586) def replacement1031(mn, p, f, b, r, d, a, n, c, x, q, e): rubi.append(1031) return Int(x**(-n*q)*(a + b*x**n)**p*(e + f*x**n)**r*(c*x**n + d)**q, x) rule1031 = ReplacementRule(pattern1031, replacement1031) pattern1032 = Pattern(Integral((c_ + x_**WC('mn', S(1))*WC('d', S(1)))**WC('q', S(1))*(e_ + x_**WC('n', S(1))*WC('f', S(1)))**WC('r', S(1))*(x_**WC('n', S(1))*WC('b', S(1)) + WC('a', S(0)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons4, cons50, cons585, cons38, cons648) def replacement1032(mn, p, f, b, r, d, a, n, c, x, q, e): rubi.append(1032) return Int(x**(n*(p + r))*(c + d*x**(-n))**q*(a*x**(-n) + b)**p*(e*x**(-n) + f)**r, x) rule1032 = ReplacementRule(pattern1032, replacement1032) pattern1033 = Pattern(Integral((c_ + x_**WC('mn', S(1))*WC('d', S(1)))**q_*(e_ + x_**WC('n', S(1))*WC('f', S(1)))**WC('r', S(1))*(x_**WC('n', S(1))*WC('b', S(1)) + WC('a', S(0)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons4, cons5, cons50, cons52, cons585, cons386) def replacement1033(mn, p, f, b, r, d, a, n, c, x, q, e): rubi.append(1033) return Dist(x**(n*FracPart(q))*(c + d*x**(-n))**FracPart(q)*(c*x**n + d)**(-FracPart(q)), Int(x**(-n*q)*(a + b*x**n)**p*(e + f*x**n)**r*(c*x**n + d)**q, x), x) rule1033 = ReplacementRule(pattern1033, replacement1033) pattern1034 = Pattern(Integral((a_ + x_**n_*WC('b', S(1)))**WC('p', S(1))*(c_ + x_**n_*WC('d', S(1)))**WC('q', S(1))*(e1_ + x_**WC('n2', S(1))*WC('f1', S(1)))**WC('r', S(1))*(e2_ + x_**WC('n2', S(1))*WC('f2', S(1)))**WC('r', S(1)), x_), cons2, cons3, cons7, cons27, cons652, cons653, cons654, cons655, cons4, cons5, cons50, cons52, cons649, cons650, cons651) def replacement1034(p, f2, b, n2, r, d, e2, f1, a, n, c, e1, x, q): rubi.append(1034) return Int((a + b*x**n)**p*(c + d*x**n)**q*(e1*e2 + f1*f2*x**n)**r, x) rule1034 = ReplacementRule(pattern1034, replacement1034) pattern1035 = Pattern(Integral((a_ + x_**n_*WC('b', S(1)))**WC('p', S(1))*(c_ + x_**n_*WC('d', S(1)))**WC('q', S(1))*(e1_ + x_**WC('n2', S(1))*WC('f1', S(1)))**WC('r', S(1))*(e2_ + x_**WC('n2', S(1))*WC('f2', S(1)))**WC('r', S(1)), x_), cons2, cons3, cons7, cons27, cons652, cons653, cons654, cons655, cons4, cons5, cons50, cons52, cons649, cons650) def replacement1035(p, f2, b, n2, r, d, e2, f1, a, n, c, e1, x, q): rubi.append(1035) return Dist((e1 + f1*x**(n/S(2)))**FracPart(r)*(e2 + f2*x**(n/S(2)))**FracPart(r)*(e1*e2 + f1*f2*x**n)**(-FracPart(r)), Int((a + b*x**n)**p*(c + d*x**n)**q*(e1*e2 + f1*f2*x**n)**r, x), x) rule1035 = ReplacementRule(pattern1035, replacement1035) pattern1036 = Pattern(Integral((x_*WC('g', S(1)))**WC('m', S(1))*(x_**n_*WC('b', S(1)))**p_*(c_ + x_**n_*WC('d', S(1)))**WC('q', S(1))*(e_ + x_**n_*WC('f', S(1)))**WC('r', S(1)), x_), cons3, cons7, cons27, cons48, cons125, cons208, cons21, cons4, cons5, cons50, cons52, cons656, cons500) def replacement1036(p, m, g, b, f, r, d, c, n, x, q, e): rubi.append(1036) return Dist(b**(S(1) - (m + S(1))/n)*g**m/n, Subst(Int((b*x)**(p + S(-1) + (m + S(1))/n)*(c + d*x)**q*(e + f*x)**r, x), x, x**n), x) rule1036 = ReplacementRule(pattern1036, replacement1036) pattern1037 = Pattern(Integral((x_*WC('g', S(1)))**WC('m', S(1))*(x_**WC('n', S(1))*WC('b', S(1)))**p_*(c_ + x_**n_*WC('d', S(1)))**WC('q', S(1))*(e_ + x_**n_*WC('f', S(1)))**WC('r', S(1)), x_), cons3, cons7, cons27, cons48, cons125, cons208, cons21, cons4, cons5, cons50, cons52, cons656, cons501) def replacement1037(p, m, g, b, f, r, d, c, n, x, q, e): rubi.append(1037) return Dist(b**IntPart(p)*g**m*x**(-n*FracPart(p))*(b*x**n)**FracPart(p), Int(x**(m + n*p)*(c + d*x**n)**q*(e + f*x**n)**r, x), x) rule1037 = ReplacementRule(pattern1037, replacement1037) pattern1038 = Pattern(Integral((g_*x_)**m_*(x_**WC('n', S(1))*WC('b', S(1)))**p_*(c_ + x_**n_*WC('d', S(1)))**WC('q', S(1))*(e_ + x_**n_*WC('f', S(1)))**WC('r', S(1)), x_), cons3, cons7, cons27, cons48, cons125, cons208, cons21, cons4, cons5, cons50, cons52, cons18) def replacement1038(p, m, f, b, r, g, d, c, n, x, q, e): rubi.append(1038) return Dist(g**IntPart(m)*x**(-FracPart(m))*(g*x)**FracPart(m), Int(x**m*(b*x**n)**p*(c + d*x**n)**q*(e + f*x**n)**r, x), x) rule1038 = ReplacementRule(pattern1038, replacement1038) pattern1039 = Pattern(Integral((x_*WC('g', S(1)))**WC('m', S(1))*(a_ + x_**n_*WC('b', S(1)))**WC('p', S(1))*(c_ + x_**n_*WC('d', S(1)))**WC('q', S(1))*(e_ + x_**n_*WC('f', S(1)))**WC('r', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons21, cons4, cons657) def replacement1039(p, m, g, b, f, r, d, a, n, c, x, q, e): rubi.append(1039) return Int(ExpandIntegrand((g*x)**m*(a + b*x**n)**p*(c + d*x**n)**q*(e + f*x**n)**r, x), x) rule1039 = ReplacementRule(pattern1039, replacement1039) pattern1040 = Pattern(Integral(x_**WC('m', S(1))*(a_ + x_**n_*WC('b', S(1)))**WC('p', S(1))*(c_ + x_**n_*WC('d', S(1)))**WC('q', S(1))*(e_ + x_**n_*WC('f', S(1)))**WC('r', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons4, cons5, cons50, cons52, cons53) def replacement1040(p, m, f, b, r, d, a, n, c, x, q, e): rubi.append(1040) return Dist(S(1)/n, Subst(Int((a + b*x)**p*(c + d*x)**q*(e + f*x)**r, x), x, x**n), x) rule1040 = ReplacementRule(pattern1040, replacement1040) pattern1041 = Pattern(Integral(x_**WC('m', S(1))*(a_ + x_**n_*WC('b', S(1)))**WC('p', S(1))*(c_ + x_**n_*WC('d', S(1)))**WC('q', S(1))*(e_ + x_**n_*WC('f', S(1)))**WC('r', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons4, cons658, cons502) def replacement1041(p, m, f, b, r, d, a, n, c, x, q, e): rubi.append(1041) return Int(x**(m + n*(p + q + r))*(a*x**(-n) + b)**p*(c*x**(-n) + d)**q*(e*x**(-n) + f)**r, x) rule1041 = ReplacementRule(pattern1041, replacement1041) pattern1042 = Pattern(Integral(x_**WC('m', S(1))*(a_ + x_**n_*WC('b', S(1)))**WC('p', S(1))*(c_ + x_**n_*WC('d', S(1)))**WC('q', S(1))*(e_ + x_**n_*WC('f', S(1)))**WC('r', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons4, cons5, cons50, cons52, cons500) def replacement1042(p, m, f, b, r, d, a, n, c, x, q, e): rubi.append(1042) return Dist(S(1)/n, Subst(Int(x**(S(-1) + (m + S(1))/n)*(a + b*x)**p*(c + d*x)**q*(e + f*x)**r, x), x, x**n), x) rule1042 = ReplacementRule(pattern1042, replacement1042) pattern1043 = Pattern(Integral((g_*x_)**WC('m', S(1))*(a_ + x_**n_*WC('b', S(1)))**WC('p', S(1))*(c_ + x_**n_*WC('d', S(1)))**WC('q', S(1))*(e_ + x_**n_*WC('f', S(1)))**WC('r', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons21, cons4, cons5, cons50, cons52, cons500) def replacement1043(p, m, f, b, r, g, d, a, n, c, x, q, e): rubi.append(1043) return Dist(g**IntPart(m)*x**(-FracPart(m))*(g*x)**FracPart(m), Int(x**m*(a + b*x**n)**p*(c + d*x**n)**q*(e + f*x**n)**r, x), x) rule1043 = ReplacementRule(pattern1043, replacement1043) def With1044(p, m, f, b, r, d, a, n, c, x, q, e): if isinstance(x, (int, Integer, float, Float)): return False k = GCD(m + S(1), n) if Unequal(k, S(1)): return True return False pattern1044 = Pattern(Integral(x_**WC('m', S(1))*(a_ + x_**n_*WC('b', S(1)))**WC('p', S(1))*(c_ + x_**n_*WC('d', S(1)))**WC('q', S(1))*(e_ + x_**n_*WC('f', S(1)))**WC('r', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons5, cons50, cons52, cons148, cons17, CustomConstraint(With1044)) def replacement1044(p, m, f, b, r, d, a, n, c, x, q, e): k = GCD(m + S(1), n) rubi.append(1044) return Dist(S(1)/k, Subst(Int(x**(S(-1) + (m + S(1))/k)*(a + b*x**(n/k))**p*(c + d*x**(n/k))**q*(e + f*x**(n/k))**r, x), x, x**k), x) rule1044 = ReplacementRule(pattern1044, replacement1044) def With1045(p, m, f, g, b, r, d, a, n, c, x, q, e): k = Denominator(m) rubi.append(1045) return Dist(k/g, Subst(Int(x**(k*(m + S(1)) + S(-1))*(a + b*g**(-n)*x**(k*n))**p*(c + d*g**(-n)*x**(k*n))**q*(e + f*g**(-n)*x**(k*n))**r, x), x, (g*x)**(S(1)/k)), x) pattern1045 = Pattern(Integral((x_*WC('g', S(1)))**m_*(a_ + x_**n_*WC('b', S(1)))**p_*(c_ + x_**n_*WC('d', S(1)))**q_*(e_ + x_**n_*WC('f', S(1)))**r_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons5, cons50, cons52, cons148, cons367) rule1045 = ReplacementRule(pattern1045, With1045) pattern1046 = Pattern(Integral((x_*WC('g', S(1)))**WC('m', S(1))*(a_ + x_**n_*WC('b', S(1)))**p_*(c_ + x_**n_*WC('d', S(1)))**WC('q', S(1))*(e_ + x_**n_*WC('f', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons21, cons148, cons402, cons137, cons403, cons659) def replacement1046(p, m, g, b, f, d, a, n, c, x, q, e): rubi.append(1046) return Dist(S(1)/(a*b*n*(p + S(1))), Int((g*x)**m*(a + b*x**n)**(p + S(1))*(c + d*x**n)**(q + S(-1))*Simp(c*(b*e*n*(p + S(1)) + (m + S(1))*(-a*f + b*e)) + d*x**n*(b*e*n*(p + S(1)) + (-a*f + b*e)*(m + n*q + S(1))), x), x), x) - Simp((g*x)**(m + S(1))*(a + b*x**n)**(p + S(1))*(c + d*x**n)**q*(-a*f + b*e)/(a*b*g*n*(p + S(1))), x) rule1046 = ReplacementRule(pattern1046, replacement1046) pattern1047 = Pattern(Integral((x_*WC('g', S(1)))**WC('m', S(1))*(a_ + x_**n_*WC('b', S(1)))**p_*(c_ + x_**n_*WC('d', S(1)))**q_*(e_ + x_**n_*WC('f', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons50, cons148, cons244, cons137, cons607) def replacement1047(p, m, f, g, b, d, a, n, c, x, q, e): rubi.append(1047) return -Dist(g**n/(b*n*(p + S(1))*(-a*d + b*c)), Int((g*x)**(m - n)*(a + b*x**n)**(p + S(1))*(c + d*x**n)**q*Simp(c*(-a*f + b*e)*(m - n + S(1)) + x**n*(-b*n*(p + S(1))*(c*f - d*e) + d*(-a*f + b*e)*(m + n*q + S(1))), x), x), x) + Simp(g**(n + S(-1))*(g*x)**(m - n + S(1))*(a + b*x**n)**(p + S(1))*(c + d*x**n)**(q + S(1))*(-a*f + b*e)/(b*n*(p + S(1))*(-a*d + b*c)), x) rule1047 = ReplacementRule(pattern1047, replacement1047) pattern1048 = Pattern(Integral((x_*WC('g', S(1)))**WC('m', S(1))*(a_ + x_**n_*WC('b', S(1)))**p_*(c_ + x_**n_*WC('d', S(1)))**q_*(e_ + x_**n_*WC('f', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons21, cons50, cons148, cons13, cons137) def replacement1048(p, m, f, g, b, d, a, n, c, x, q, e): rubi.append(1048) return Dist(S(1)/(a*n*(p + S(1))*(-a*d + b*c)), Int((g*x)**m*(a + b*x**n)**(p + S(1))*(c + d*x**n)**q*Simp(c*(m + S(1))*(-a*f + b*e) + d*x**n*(-a*f + b*e)*(m + n*(p + q + S(2)) + S(1)) + e*n*(p + S(1))*(-a*d + b*c), x), x), x) - Simp((g*x)**(m + S(1))*(a + b*x**n)**(p + S(1))*(c + d*x**n)**(q + S(1))*(-a*f + b*e)/(a*g*n*(p + S(1))*(-a*d + b*c)), x) rule1048 = ReplacementRule(pattern1048, replacement1048) pattern1049 = Pattern(Integral((x_*WC('g', S(1)))**m_*(a_ + x_**n_*WC('b', S(1)))**WC('p', S(1))*(c_ + x_**n_*WC('d', S(1)))**WC('q', S(1))*(e_ + x_**n_*WC('f', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons5, cons148, cons611, cons403, cons94, cons660) def replacement1049(p, m, g, b, f, d, a, n, c, x, q, e): rubi.append(1049) return -Dist(g**(-n)/(a*(m + S(1))), Int((g*x)**(m + n)*(a + b*x**n)**p*(c + d*x**n)**(q + S(-1))*Simp(c*(m + S(1))*(-a*f + b*e) + d*x**n*(b*e*n*(p + q + S(1)) + (m + S(1))*(-a*f + b*e)) + e*n*(a*d*q + b*c*(p + S(1))), x), x), x) + Simp(e*(g*x)**(m + S(1))*(a + b*x**n)**(p + S(1))*(c + d*x**n)**q/(a*g*(m + S(1))), x) rule1049 = ReplacementRule(pattern1049, replacement1049) pattern1050 = Pattern(Integral((x_*WC('g', S(1)))**WC('m', S(1))*(a_ + x_**n_*WC('b', S(1)))**WC('p', S(1))*(c_ + x_**n_*WC('d', S(1)))**WC('q', S(1))*(e_ + x_**n_*WC('f', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons21, cons5, cons148, cons395, cons403, cons660) def replacement1050(p, m, g, b, f, d, a, n, c, x, q, e): rubi.append(1050) return Dist(S(1)/(b*(m + n*(p + q + S(1)) + S(1))), Int((g*x)**m*(a + b*x**n)**p*(c + d*x**n)**(q + S(-1))*Simp(c*(b*e*n*(p + q + S(1)) + (m + S(1))*(-a*f + b*e)) + x**n*(b*d*e*n*(p + q + S(1)) + d*(m + S(1))*(-a*f + b*e) + f*n*q*(-a*d + b*c)), x), x), x) + Simp(f*(g*x)**(m + S(1))*(a + b*x**n)**(p + S(1))*(c + d*x**n)**q/(b*g*(m + n*(p + q + S(1)) + S(1))), x) rule1050 = ReplacementRule(pattern1050, replacement1050) pattern1051 = Pattern(Integral((x_*WC('g', S(1)))**WC('m', S(1))*(a_ + x_**n_*WC('b', S(1)))**WC('p', S(1))*(c_ + x_**n_*WC('d', S(1)))**WC('q', S(1))*(e_ + x_**n_*WC('f', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons5, cons50, cons148, cons31, cons530) def replacement1051(p, m, g, b, f, d, a, n, c, x, q, e): rubi.append(1051) return -Dist(g**n/(b*d*(m + n*(p + q + S(1)) + S(1))), Int((g*x)**(m - n)*(a + b*x**n)**p*(c + d*x**n)**q*Simp(a*c*f*(m - n + S(1)) + x**n*(a*d*f*(m + n*q + S(1)) + b*(c*f*(m + n*p + S(1)) - d*e*(m + n*(p + q + S(1)) + S(1)))), x), x), x) + Simp(f*g**(n + S(-1))*(g*x)**(m - n + S(1))*(a + b*x**n)**(p + S(1))*(c + d*x**n)**(q + S(1))/(b*d*(m + n*(p + q + S(1)) + S(1))), x) rule1051 = ReplacementRule(pattern1051, replacement1051) pattern1052 = Pattern(Integral((x_*WC('g', S(1)))**m_*(a_ + x_**n_*WC('b', S(1)))**WC('p', S(1))*(c_ + x_**n_*WC('d', S(1)))**WC('q', S(1))*(e_ + x_**n_*WC('f', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons5, cons50, cons148, cons31, cons94) def replacement1052(p, m, g, b, f, d, a, n, c, x, q, e): rubi.append(1052) return Dist(g**(-n)/(a*c*(m + S(1))), Int((g*x)**(m + n)*(a + b*x**n)**p*(c + d*x**n)**q*Simp(a*c*f*(m + S(1)) - b*d*e*x**n*(m + n*(p + q + S(2)) + S(1)) - e*n*(a*d*q + b*c*p) - e*(a*d + b*c)*(m + n + S(1)), x), x), x) + Simp(e*(g*x)**(m + S(1))*(a + b*x**n)**(p + S(1))*(c + d*x**n)**(q + S(1))/(a*c*g*(m + S(1))), x) rule1052 = ReplacementRule(pattern1052, replacement1052) pattern1053 = Pattern(Integral((x_*WC('g', S(1)))**WC('m', S(1))*(a_ + x_**n_*WC('b', S(1)))**p_*(e_ + x_**n_*WC('f', S(1)))/(c_ + x_**n_*WC('d', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons21, cons5, cons148) def replacement1053(p, m, f, g, b, d, a, n, c, x, e): rubi.append(1053) return Int(ExpandIntegrand((g*x)**m*(a + b*x**n)**p*(e + f*x**n)/(c + d*x**n), x), x) rule1053 = ReplacementRule(pattern1053, replacement1053) pattern1054 = Pattern(Integral((x_*WC('g', S(1)))**WC('m', S(1))*(a_ + x_**n_*WC('b', S(1)))**WC('p', S(1))*(c_ + x_**n_*WC('d', S(1)))**WC('q', S(1))*(e_ + x_**n_*WC('f', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons21, cons5, cons50, cons148) def replacement1054(p, m, g, b, f, d, a, n, c, x, q, e): rubi.append(1054) return Dist(e, Int((g*x)**m*(a + b*x**n)**p*(c + d*x**n)**q, x), x) + Dist(e**(-n)*f, Int((g*x)**(m + n)*(a + b*x**n)**p*(c + d*x**n)**q, x), x) rule1054 = ReplacementRule(pattern1054, replacement1054) pattern1055 = Pattern(Integral((x_*WC('g', S(1)))**WC('m', S(1))*(a_ + x_**n_*WC('b', S(1)))**WC('p', S(1))*(c_ + x_**n_*WC('d', S(1)))**WC('q', S(1))*(e_ + x_**n_*WC('f', S(1)))**WC('r', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons21, cons5, cons50, cons148, cons661) def replacement1055(p, m, g, b, f, r, d, a, n, c, x, q, e): rubi.append(1055) return Dist(e, Int((g*x)**m*(a + b*x**n)**p*(c + d*x**n)**q*(e + f*x**n)**(r + S(-1)), x), x) + Dist(e**(-n)*f, Int((g*x)**(m + n)*(a + b*x**n)**p*(c + d*x**n)**q*(e + f*x**n)**(r + S(-1)), x), x) rule1055 = ReplacementRule(pattern1055, replacement1055) pattern1056 = Pattern(Integral(x_**WC('m', S(1))*(a_ + x_**n_*WC('b', S(1)))**WC('p', S(1))*(c_ + x_**n_*WC('d', S(1)))**WC('q', S(1))*(e_ + x_**n_*WC('f', S(1)))**WC('r', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons5, cons50, cons52, cons196, cons17) def replacement1056(p, m, f, b, r, d, a, n, c, x, q, e): rubi.append(1056) return -Subst(Int(x**(-m + S(-2))*(a + b*x**(-n))**p*(c + d*x**(-n))**q*(e + f*x**(-n))**r, x), x, S(1)/x) rule1056 = ReplacementRule(pattern1056, replacement1056) def With1057(p, m, g, b, f, r, d, a, n, c, x, q, e): k = Denominator(m) rubi.append(1057) return -Dist(k/g, Subst(Int(x**(-k*(m + S(1)) + S(-1))*(a + b*g**(-n)*x**(-k*n))**p*(c + d*g**(-n)*x**(-k*n))**q*(e + f*g**(-n)*x**(-k*n))**r, x), x, (g*x)**(-S(1)/k)), x) pattern1057 = Pattern(Integral((x_*WC('g', S(1)))**m_*(a_ + x_**n_*WC('b', S(1)))**WC('p', S(1))*(c_ + x_**n_*WC('d', S(1)))**WC('q', S(1))*(e_ + x_**n_*WC('f', S(1)))**WC('r', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons5, cons50, cons52, cons196, cons367) rule1057 = ReplacementRule(pattern1057, With1057) pattern1058 = Pattern(Integral((x_*WC('g', S(1)))**m_*(a_ + x_**n_*WC('b', S(1)))**WC('p', S(1))*(c_ + x_**n_*WC('d', S(1)))**WC('q', S(1))*(e_ + x_**n_*WC('f', S(1)))**WC('r', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons21, cons5, cons50, cons52, cons196, cons356) def replacement1058(p, m, g, b, f, r, d, a, n, c, x, q, e): rubi.append(1058) return -Dist((g*x)**m*(S(1)/x)**m, Subst(Int(x**(-m + S(-2))*(a + b*x**(-n))**p*(c + d*x**(-n))**q*(e + f*x**(-n))**r, x), x, S(1)/x), x) rule1058 = ReplacementRule(pattern1058, replacement1058) def With1059(p, m, f, b, r, d, a, n, c, x, q, e): k = Denominator(n) rubi.append(1059) return Dist(k, Subst(Int(x**(k*(m + S(1)) + S(-1))*(a + b*x**(k*n))**p*(c + d*x**(k*n))**q*(e + f*x**(k*n))**r, x), x, x**(S(1)/k)), x) pattern1059 = Pattern(Integral(x_**WC('m', S(1))*(a_ + x_**n_*WC('b', S(1)))**WC('p', S(1))*(c_ + x_**n_*WC('d', S(1)))**WC('q', S(1))*(e_ + x_**n_*WC('f', S(1)))**WC('r', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons5, cons50, cons52, cons489) rule1059 = ReplacementRule(pattern1059, With1059) pattern1060 = Pattern(Integral((g_*x_)**m_*(a_ + x_**n_*WC('b', S(1)))**WC('p', S(1))*(c_ + x_**n_*WC('d', S(1)))**WC('q', S(1))*(e_ + x_**n_*WC('f', S(1)))**WC('r', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons21, cons5, cons50, cons52, cons489) def replacement1060(p, m, f, b, r, g, d, a, n, c, x, q, e): rubi.append(1060) return Dist(g**IntPart(m)*x**(-FracPart(m))*(g*x)**FracPart(m), Int(x**m*(a + b*x**n)**p*(c + d*x**n)**q*(e + f*x**n)**r, x), x) rule1060 = ReplacementRule(pattern1060, replacement1060) pattern1061 = Pattern(Integral(x_**WC('m', S(1))*(a_ + x_**n_*WC('b', S(1)))**WC('p', S(1))*(c_ + x_**n_*WC('d', S(1)))**WC('q', S(1))*(e_ + x_**n_*WC('f', S(1)))**WC('r', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons4, cons5, cons50, cons52, cons541) def replacement1061(p, m, f, b, r, d, a, n, c, x, q, e): rubi.append(1061) return Dist(S(1)/(m + S(1)), Subst(Int((a + b*x**(n/(m + S(1))))**p*(c + d*x**(n/(m + S(1))))**q*(e + f*x**(n/(m + S(1))))**r, x), x, x**(m + S(1))), x) rule1061 = ReplacementRule(pattern1061, replacement1061) pattern1062 = Pattern(Integral((g_*x_)**WC('m', S(1))*(a_ + x_**n_*WC('b', S(1)))**WC('p', S(1))*(c_ + x_**n_*WC('d', S(1)))**WC('q', S(1))*(e_ + x_**n_*WC('f', S(1)))**WC('r', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons21, cons4, cons5, cons50, cons52, cons541) def replacement1062(p, m, f, b, r, g, d, a, n, c, x, q, e): rubi.append(1062) return Dist(g**IntPart(m)*x**(-FracPart(m))*(g*x)**FracPart(m), Int(x**m*(a + b*x**n)**p*(c + d*x**n)**q*(e + f*x**n)**r, x), x) rule1062 = ReplacementRule(pattern1062, replacement1062) pattern1063 = Pattern(Integral((x_*WC('g', S(1)))**WC('m', S(1))*(a_ + x_**n_*WC('b', S(1)))**p_*(c_ + x_**n_*WC('d', S(1)))**WC('q', S(1))*(e_ + x_**n_*WC('f', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons21, cons4, cons402, cons137, cons403, cons659) def replacement1063(p, m, g, b, f, d, a, n, c, x, q, e): rubi.append(1063) return Dist(S(1)/(a*b*n*(p + S(1))), Int((g*x)**m*(a + b*x**n)**(p + S(1))*(c + d*x**n)**(q + S(-1))*Simp(c*(b*e*n*(p + S(1)) + (m + S(1))*(-a*f + b*e)) + d*x**n*(b*e*n*(p + S(1)) + (-a*f + b*e)*(m + n*q + S(1))), x), x), x) - Simp((g*x)**(m + S(1))*(a + b*x**n)**(p + S(1))*(c + d*x**n)**q*(-a*f + b*e)/(a*b*g*n*(p + S(1))), x) rule1063 = ReplacementRule(pattern1063, replacement1063) pattern1064 = Pattern(Integral((x_*WC('g', S(1)))**WC('m', S(1))*(a_ + x_**n_*WC('b', S(1)))**p_*(c_ + x_**n_*WC('d', S(1)))**q_*(e_ + x_**n_*WC('f', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons21, cons4, cons50, cons13, cons137) def replacement1064(p, m, f, g, b, d, a, n, c, x, q, e): rubi.append(1064) return Dist(S(1)/(a*n*(p + S(1))*(-a*d + b*c)), Int((g*x)**m*(a + b*x**n)**(p + S(1))*(c + d*x**n)**q*Simp(c*(m + S(1))*(-a*f + b*e) + d*x**n*(-a*f + b*e)*(m + n*(p + q + S(2)) + S(1)) + e*n*(p + S(1))*(-a*d + b*c), x), x), x) - Simp((g*x)**(m + S(1))*(a + b*x**n)**(p + S(1))*(c + d*x**n)**(q + S(1))*(-a*f + b*e)/(a*g*n*(p + S(1))*(-a*d + b*c)), x) rule1064 = ReplacementRule(pattern1064, replacement1064) pattern1065 = Pattern(Integral((x_*WC('g', S(1)))**WC('m', S(1))*(a_ + x_**n_*WC('b', S(1)))**WC('p', S(1))*(c_ + x_**n_*WC('d', S(1)))**WC('q', S(1))*(e_ + x_**n_*WC('f', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons21, cons4, cons5, cons395, cons403, cons660) def replacement1065(p, m, g, b, f, d, a, n, c, x, q, e): rubi.append(1065) return Dist(S(1)/(b*(m + n*(p + q + S(1)) + S(1))), Int((g*x)**m*(a + b*x**n)**p*(c + d*x**n)**(q + S(-1))*Simp(c*(b*e*n*(p + q + S(1)) + (m + S(1))*(-a*f + b*e)) + x**n*(b*d*e*n*(p + q + S(1)) + d*(m + S(1))*(-a*f + b*e) + f*n*q*(-a*d + b*c)), x), x), x) + Simp(f*(g*x)**(m + S(1))*(a + b*x**n)**(p + S(1))*(c + d*x**n)**q/(b*g*(m + n*(p + q + S(1)) + S(1))), x) rule1065 = ReplacementRule(pattern1065, replacement1065) pattern1066 = Pattern(Integral((x_*WC('g', S(1)))**WC('m', S(1))*(a_ + x_**n_*WC('b', S(1)))**p_*(e_ + x_**n_*WC('f', S(1)))/(c_ + x_**n_*WC('d', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons21, cons4, cons5, cons380) def replacement1066(p, m, f, g, b, d, a, n, c, x, e): rubi.append(1066) return Int(ExpandIntegrand((g*x)**m*(a + b*x**n)**p*(e + f*x**n)/(c + d*x**n), x), x) rule1066 = ReplacementRule(pattern1066, replacement1066) pattern1067 = Pattern(Integral((x_*WC('g', S(1)))**WC('m', S(1))*(a_ + x_**n_*WC('b', S(1)))**p_*(c_ + x_**n_*WC('d', S(1)))**q_*(e_ + x_**n_*WC('f', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons21, cons4, cons5, cons50, cons662) def replacement1067(p, m, f, g, b, d, a, n, c, x, q, e): rubi.append(1067) return Dist(e, Int((g*x)**m*(a + b*x**n)**p*(c + d*x**n)**q, x), x) + Dist(f*x**(-m)*(g*x)**m, Int(x**(m + n)*(a + b*x**n)**p*(c + d*x**n)**q, x), x) rule1067 = ReplacementRule(pattern1067, replacement1067) pattern1068 = Pattern(Integral(x_**WC('m', S(1))*(a_ + x_**WC('n', S(1))*WC('b', S(1)))**WC('p', S(1))*(c_ + x_**WC('mn', S(1))*WC('d', S(1)))**WC('q', S(1))*(e_ + x_**WC('n', S(1))*WC('f', S(1)))**WC('r', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons4, cons5, cons52, cons585, cons586) def replacement1068(mn, p, m, f, b, r, d, c, n, a, x, q, e): rubi.append(1068) return Int(x**(m - n*q)*(a + b*x**n)**p*(e + f*x**n)**r*(c*x**n + d)**q, x) rule1068 = ReplacementRule(pattern1068, replacement1068) pattern1069 = Pattern(Integral(x_**WC('m', S(1))*(c_ + x_**WC('mn', S(1))*WC('d', S(1)))**WC('q', S(1))*(e_ + x_**WC('n', S(1))*WC('f', S(1)))**WC('r', S(1))*(x_**WC('n', S(1))*WC('b', S(1)) + WC('a', S(0)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons4, cons50, cons585, cons38, cons648) def replacement1069(mn, p, m, f, b, r, d, a, n, c, x, q, e): rubi.append(1069) return Int(x**(m + n*(p + r))*(c + d*x**(-n))**q*(a*x**(-n) + b)**p*(e*x**(-n) + f)**r, x) rule1069 = ReplacementRule(pattern1069, replacement1069) pattern1070 = Pattern(Integral(x_**WC('m', S(1))*(c_ + x_**WC('mn', S(1))*WC('d', S(1)))**q_*(e_ + x_**WC('n', S(1))*WC('f', S(1)))**WC('r', S(1))*(x_**WC('n', S(1))*WC('b', S(1)) + WC('a', S(0)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons4, cons5, cons50, cons52, cons585, cons386) def replacement1070(mn, p, m, f, b, r, d, a, n, c, x, q, e): rubi.append(1070) return Dist(x**(n*FracPart(q))*(c + d*x**(-n))**FracPart(q)*(c*x**n + d)**(-FracPart(q)), Int(x**(m - n*q)*(a + b*x**n)**p*(e + f*x**n)**r*(c*x**n + d)**q, x), x) rule1070 = ReplacementRule(pattern1070, replacement1070) pattern1071 = Pattern(Integral((g_*x_)**m_*(a_ + x_**WC('n', S(1))*WC('b', S(1)))**WC('p', S(1))*(c_ + x_**WC('mn', S(1))*WC('d', S(1)))**WC('q', S(1))*(e_ + x_**WC('n', S(1))*WC('f', S(1)))**WC('r', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons21, cons4, cons5, cons50, cons52, cons585) def replacement1071(mn, p, m, f, b, r, g, d, c, n, a, x, q, e): rubi.append(1071) return Dist(g**IntPart(m)*x**(-FracPart(m))*(g*x)**FracPart(m), Int(x**m*(a + b*x**n)**p*(c + d*x**(-n))**q*(e + f*x**n)**r, x), x) rule1071 = ReplacementRule(pattern1071, replacement1071) pattern1072 = Pattern(Integral((x_*WC('g', S(1)))**WC('m', S(1))*(a_ + x_**n_*WC('b', S(1)))**WC('p', S(1))*(c_ + x_**n_*WC('d', S(1)))**WC('q', S(1))*(e_ + x_**n_*WC('f', S(1)))**WC('r', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons21, cons4, cons5, cons50, cons52, cons663) def replacement1072(p, m, g, b, f, r, d, a, n, c, x, q, e): rubi.append(1072) return Int((g*x)**m*(a + b*x**n)**p*(c + d*x**n)**q*(e + f*x**n)**r, x) rule1072 = ReplacementRule(pattern1072, replacement1072) pattern1073 = Pattern(Integral(u_**WC('m', S(1))*(e_ + v_**n_*WC('f', S(1)))**WC('r', S(1))*(v_**n_*WC('b', S(1)) + WC('a', S(0)))**WC('p', S(1))*(v_**n_*WC('d', S(1)) + WC('c', S(0)))**WC('q', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons4, cons5, cons50, cons52, cons554) def replacement1073(v, p, u, m, f, b, r, d, c, a, n, x, q, e): rubi.append(1073) return Dist(u**m*v**(-m)/Coefficient(v, x, S(1)), Subst(Int(x**m*(a + b*x**n)**p*(c + d*x**n)**q*(e + f*x**n)**r, x), x, v), x) rule1073 = ReplacementRule(pattern1073, replacement1073) pattern1074 = Pattern(Integral((x_*WC('g', S(1)))**WC('m', S(1))*(a_ + x_**n_*WC('b', S(1)))**WC('p', S(1))*(c_ + x_**n_*WC('d', S(1)))**WC('q', S(1))*(e1_ + x_**WC('n2', S(1))*WC('f1', S(1)))**WC('r', S(1))*(e2_ + x_**WC('n2', S(1))*WC('f2', S(1)))**WC('r', S(1)), x_), cons2, cons3, cons7, cons27, cons652, cons653, cons654, cons655, cons208, cons21, cons4, cons5, cons50, cons52, cons649, cons650, cons651) def replacement1074(p, m, g, f2, n2, r, b, d, e2, f1, a, n, c, e1, x, q): rubi.append(1074) return Int((g*x)**m*(a + b*x**n)**p*(c + d*x**n)**q*(e1*e2 + f1*f2*x**n)**r, x) rule1074 = ReplacementRule(pattern1074, replacement1074) pattern1075 = Pattern(Integral((x_*WC('g', S(1)))**WC('m', S(1))*(a_ + x_**n_*WC('b', S(1)))**WC('p', S(1))*(c_ + x_**n_*WC('d', S(1)))**WC('q', S(1))*(e1_ + x_**WC('n2', S(1))*WC('f1', S(1)))**WC('r', S(1))*(e2_ + x_**WC('n2', S(1))*WC('f2', S(1)))**WC('r', S(1)), x_), cons2, cons3, cons7, cons27, cons652, cons653, cons654, cons655, cons208, cons21, cons4, cons5, cons50, cons52, cons649, cons650) def replacement1075(p, m, g, f2, n2, r, b, d, e2, f1, a, n, c, e1, x, q): rubi.append(1075) return Dist((e1 + f1*x**(n/S(2)))**FracPart(r)*(e2 + f2*x**(n/S(2)))**FracPart(r)*(e1*e2 + f1*f2*x**n)**(-FracPart(r)), Int((g*x)**m*(a + b*x**n)**p*(c + d*x**n)**q*(e1*e2 + f1*f2*x**n)**r, x), x) rule1075 = ReplacementRule(pattern1075, replacement1075) return [rule689, rule690, rule691, rule692, rule693, rule694, rule695, rule696, rule697, rule698, rule699, rule700, rule701, rule702, rule703, rule704, rule705, rule706, rule707, rule708, rule709, rule710, rule711, rule712, rule713, rule714, rule715, rule716, rule717, rule718, rule719, rule720, rule721, rule722, rule723, rule724, rule725, rule726, rule727, rule728, rule729, rule730, rule731, rule732, rule733, rule734, rule735, rule736, rule737, rule738, rule739, rule740, rule741, rule742, rule743, rule744, rule745, rule746, rule747, rule748, rule749, rule750, rule751, rule752, rule753, rule754, rule755, rule756, rule757, rule758, rule759, rule760, rule761, rule762, rule763, rule764, rule765, rule766, rule767, rule768, rule769, rule770, rule771, rule772, rule773, rule774, rule775, rule776, rule777, rule778, rule779, rule780, rule781, rule782, rule783, rule784, rule785, rule786, rule787, rule788, rule789, rule790, rule791, rule792, rule793, rule794, rule795, rule796, rule797, rule798, rule799, rule800, rule801, rule802, rule803, rule804, rule805, rule806, rule807, rule808, rule809, rule810, rule811, rule812, rule813, rule814, rule815, rule816, rule817, rule818, rule819, rule820, rule821, rule822, rule823, rule824, rule825, rule826, rule827, rule828, rule829, rule830, rule831, rule832, rule833, rule834, rule835, rule836, rule837, rule838, rule839, rule840, rule841, rule842, rule843, rule844, rule845, rule846, rule847, rule848, rule849, rule850, rule851, rule852, rule853, rule854, rule855, rule856, rule857, rule858, rule859, rule860, rule861, rule862, rule863, rule864, rule865, rule866, rule867, rule868, rule869, rule870, rule871, rule872, rule873, rule874, rule875, rule876, rule877, rule878, rule879, rule880, rule881, rule882, rule883, rule884, rule885, rule886, rule887, rule888, rule889, rule890, rule891, rule892, rule893, rule894, rule895, rule896, rule897, rule898, rule899, rule900, rule901, rule902, rule903, rule904, rule905, rule906, rule907, rule908, rule909, rule910, rule911, rule912, rule913, rule914, rule915, rule916, rule917, rule918, rule919, rule920, rule921, rule922, rule923, rule924, rule925, rule926, rule927, rule928, rule929, rule930, rule931, rule932, rule933, rule934, rule935, rule936, rule937, rule938, rule939, rule940, rule941, rule942, rule943, rule944, rule945, rule946, rule947, rule948, rule949, rule950, rule951, rule952, rule953, rule954, rule955, rule956, rule957, rule958, rule959, rule960, rule961, rule962, rule963, rule964, rule965, rule966, rule967, rule968, rule969, rule970, rule971, rule972, rule973, rule974, rule975, rule976, rule977, rule978, rule979, rule980, rule981, rule982, rule983, rule984, rule985, rule986, rule987, rule988, rule989, rule990, rule991, rule992, rule993, rule994, rule995, rule996, rule997, rule998, rule999, rule1000, rule1001, rule1002, rule1003, rule1004, rule1005, rule1006, rule1007, rule1008, rule1009, rule1010, rule1011, rule1012, rule1013, rule1014, rule1015, rule1016, rule1017, rule1018, rule1019, rule1020, rule1021, rule1022, rule1023, rule1024, rule1025, rule1026, rule1027, rule1028, rule1029, rule1030, rule1031, rule1032, rule1033, rule1034, rule1035, rule1036, rule1037, rule1038, rule1039, rule1040, rule1041, rule1042, rule1043, rule1044, rule1045, rule1046, rule1047, rule1048, rule1049, rule1050, rule1051, rule1052, rule1053, rule1054, rule1055, rule1056, rule1057, rule1058, rule1059, rule1060, rule1061, rule1062, rule1063, rule1064, rule1065, rule1066, rule1067, rule1068, rule1069, rule1070, rule1071, rule1072, rule1073, rule1074, rule1075, ]
aea41bd101c18a89d2efb038934b8d2bb7301f6054efb49e9f4882f71b6da0ec
''' This code is automatically generated. Never edit it manually. For details of generating the code see `rubi_parsing_guide.md` in `parsetools`. ''' from sympy.external import import_module matchpy = import_module("matchpy") from sympy.utilities.decorator import doctest_depends_on if matchpy: from matchpy import Pattern, ReplacementRule, CustomConstraint, is_match from sympy.integrals.rubi.utility_function import ( Int, Sum, Set, With, Module, Scan, MapAnd, FalseQ, ZeroQ, NegativeQ, NonzeroQ, FreeQ, NFreeQ, List, Log, PositiveQ, PositiveIntegerQ, NegativeIntegerQ, IntegerQ, IntegersQ, ComplexNumberQ, PureComplexNumberQ, RealNumericQ, PositiveOrZeroQ, NegativeOrZeroQ, FractionOrNegativeQ, NegQ, Equal, Unequal, IntPart, FracPart, RationalQ, ProductQ, SumQ, NonsumQ, Subst, First, Rest, SqrtNumberQ, SqrtNumberSumQ, LinearQ, Sqrt, ArcCosh, Coefficient, Denominator, Hypergeometric2F1, Not, Simplify, FractionalPart, IntegerPart, AppellF1, EllipticPi, EllipticE, EllipticF, ArcTan, ArcCot, ArcCoth, ArcTanh, ArcSin, ArcSinh, ArcCos, ArcCsc, ArcSec, ArcCsch, ArcSech, Sinh, Tanh, Cosh, Sech, Csch, Coth, LessEqual, Less, Greater, GreaterEqual, FractionQ, IntLinearcQ, Expand, IndependentQ, PowerQ, IntegerPowerQ, PositiveIntegerPowerQ, FractionalPowerQ, AtomQ, ExpQ, LogQ, Head, MemberQ, TrigQ, SinQ, CosQ, TanQ, CotQ, SecQ, CscQ, Sin, Cos, Tan, Cot, Sec, Csc, HyperbolicQ, SinhQ, CoshQ, TanhQ, CothQ, SechQ, CschQ, InverseTrigQ, SinCosQ, SinhCoshQ, LeafCount, Numerator, NumberQ, NumericQ, Length, ListQ, Im, Re, InverseHyperbolicQ, InverseFunctionQ, TrigHyperbolicFreeQ, InverseFunctionFreeQ, RealQ, EqQ, FractionalPowerFreeQ, ComplexFreeQ, PolynomialQ, FactorSquareFree, PowerOfLinearQ, Exponent, QuadraticQ, LinearPairQ, BinomialParts, TrinomialParts, PolyQ, EvenQ, OddQ, PerfectSquareQ, NiceSqrtAuxQ, NiceSqrtQ, Together, PosAux, PosQ, CoefficientList, ReplaceAll, ExpandLinearProduct, GCD, ContentFactor, NumericFactor, NonnumericFactors, MakeAssocList, GensymSubst, KernelSubst, ExpandExpression, Apart, SmartApart, MatchQ, PolynomialQuotientRemainder, FreeFactors, NonfreeFactors, RemoveContentAux, RemoveContent, FreeTerms, NonfreeTerms, ExpandAlgebraicFunction, CollectReciprocals, ExpandCleanup, AlgebraicFunctionQ, Coeff, LeadTerm, RemainingTerms, LeadFactor, RemainingFactors, LeadBase, LeadDegree, Numer, Denom, hypergeom, Expon, MergeMonomials, PolynomialDivide, BinomialQ, TrinomialQ, GeneralizedBinomialQ, GeneralizedTrinomialQ, FactorSquareFreeList, PerfectPowerTest, SquareFreeFactorTest, RationalFunctionQ, RationalFunctionFactors, NonrationalFunctionFactors, Reverse, RationalFunctionExponents, RationalFunctionExpand, ExpandIntegrand, SimplerQ, SimplerSqrtQ, SumSimplerQ, BinomialDegree, TrinomialDegree, CancelCommonFactors, SimplerIntegrandQ, GeneralizedBinomialDegree, GeneralizedBinomialParts, GeneralizedTrinomialDegree, GeneralizedTrinomialParts, MonomialQ, MonomialSumQ, MinimumMonomialExponent, MonomialExponent, LinearMatchQ, PowerOfLinearMatchQ, QuadraticMatchQ, CubicMatchQ, BinomialMatchQ, TrinomialMatchQ, GeneralizedBinomialMatchQ, GeneralizedTrinomialMatchQ, QuotientOfLinearsMatchQ, PolynomialTermQ, PolynomialTerms, NonpolynomialTerms, PseudoBinomialParts, NormalizePseudoBinomial, PseudoBinomialPairQ, PseudoBinomialQ, PolynomialGCD, PolyGCD, AlgebraicFunctionFactors, NonalgebraicFunctionFactors, QuotientOfLinearsP, QuotientOfLinearsParts, QuotientOfLinearsQ, Flatten, Sort, AbsurdNumberQ, AbsurdNumberFactors, NonabsurdNumberFactors, SumSimplerAuxQ, Prepend, Drop, CombineExponents, FactorInteger, FactorAbsurdNumber, SubstForInverseFunction, SubstForFractionalPower, SubstForFractionalPowerOfQuotientOfLinears, FractionalPowerOfQuotientOfLinears, SubstForFractionalPowerQ, SubstForFractionalPowerAuxQ, FractionalPowerOfSquareQ, FractionalPowerSubexpressionQ, Apply, FactorNumericGcd, MergeableFactorQ, MergeFactor, MergeFactors, TrigSimplifyQ, TrigSimplify, TrigSimplifyRecur, Order, FactorOrder, Smallest, OrderedQ, MinimumDegree, PositiveFactors, Sign, NonpositiveFactors, PolynomialInAuxQ, PolynomialInQ, ExponentInAux, ExponentIn, PolynomialInSubstAux, PolynomialInSubst, Distrib, DistributeDegree, FunctionOfPower, DivideDegreesOfFactors, MonomialFactor, FullSimplify, FunctionOfLinearSubst, FunctionOfLinear, NormalizeIntegrand, NormalizeIntegrandAux, NormalizeIntegrandFactor, NormalizeIntegrandFactorBase, NormalizeTogether, NormalizeLeadTermSigns, AbsorbMinusSign, NormalizeSumFactors, SignOfFactor, NormalizePowerOfLinear, SimplifyIntegrand, SimplifyTerm, TogetherSimplify, SmartSimplify, SubstForExpn, ExpandToSum, UnifySum, UnifyTerms, UnifyTerm, CalculusQ, FunctionOfInverseLinear, PureFunctionOfSinhQ, PureFunctionOfTanhQ, PureFunctionOfCoshQ, IntegerQuotientQ, OddQuotientQ, EvenQuotientQ, FindTrigFactor, FunctionOfSinhQ, FunctionOfCoshQ, OddHyperbolicPowerQ, FunctionOfTanhQ, FunctionOfTanhWeight, FunctionOfHyperbolicQ, SmartNumerator, SmartDenominator, SubstForAux, ActivateTrig, ExpandTrig, TrigExpand, SubstForTrig, SubstForHyperbolic, InertTrigFreeQ, LCM, SubstForFractionalPowerOfLinear, FractionalPowerOfLinear, InverseFunctionOfLinear, InertTrigQ, InertReciprocalQ, DeactivateTrig, FixInertTrigFunction, DeactivateTrigAux, PowerOfInertTrigSumQ, PiecewiseLinearQ, KnownTrigIntegrandQ, KnownSineIntegrandQ, KnownTangentIntegrandQ, KnownCotangentIntegrandQ, KnownSecantIntegrandQ, TryPureTanSubst, TryTanhSubst, TryPureTanhSubst, AbsurdNumberGCD, AbsurdNumberGCDList, ExpandTrigExpand, ExpandTrigReduce, ExpandTrigReduceAux, NormalizeTrig, TrigToExp, ExpandTrigToExp, TrigReduce, FunctionOfTrig, AlgebraicTrigFunctionQ, FunctionOfHyperbolic, FunctionOfQ, FunctionOfExpnQ, PureFunctionOfSinQ, PureFunctionOfCosQ, PureFunctionOfTanQ, PureFunctionOfCotQ, FunctionOfCosQ, FunctionOfSinQ, OddTrigPowerQ, FunctionOfTanQ, FunctionOfTanWeight, FunctionOfTrigQ, FunctionOfDensePolynomialsQ, FunctionOfLog, PowerVariableExpn, PowerVariableDegree, PowerVariableSubst, EulerIntegrandQ, FunctionOfSquareRootOfQuadratic, SquareRootOfQuadraticSubst, Divides, EasyDQ, ProductOfLinearPowersQ, Rt, NthRoot, AtomBaseQ, SumBaseQ, NegSumBaseQ, AllNegTermQ, SomeNegTermQ, TrigSquareQ, RtAux, TrigSquare, IntSum, IntTerm, Map2, ConstantFactor, SameQ, ReplacePart, CommonFactors, MostMainFactorPosition, FunctionOfExponentialQ, FunctionOfExponential, FunctionOfExponentialFunction, FunctionOfExponentialFunctionAux, FunctionOfExponentialTest, FunctionOfExponentialTestAux, stdev, rubi_test, If, IntQuadraticQ, IntBinomialQ, RectifyTangent, RectifyCotangent, Inequality, Condition, Simp, SimpHelp, SplitProduct, SplitSum, SubstFor, SubstForAux, FresnelS, FresnelC, Erfc, Erfi, Gamma, FunctionOfTrigOfLinearQ, ElementaryFunctionQ, Complex, UnsameQ, _SimpFixFactor, SimpFixFactor, _FixSimplify, FixSimplify, _SimplifyAntiderivativeSum, SimplifyAntiderivativeSum, _SimplifyAntiderivative, SimplifyAntiderivative, _TrigSimplifyAux, TrigSimplifyAux, Cancel, Part, PolyLog, D, Dist, Sum_doit, PolynomialQuotient, Floor, PolynomialRemainder, Factor, PolyLog, CosIntegral, SinIntegral, LogIntegral, SinhIntegral, CoshIntegral, Rule, Erf, PolyGamma, ExpIntegralEi, ExpIntegralE, LogGamma , UtilityOperator, Factorial, Zeta, ProductLog, DerivativeDivides, HypergeometricPFQ, IntHide, OneQ, Null, rubi_exp as exp, rubi_log as log, Discriminant, Negative, Quotient ) from sympy import (Integral, S, sqrt, And, Or, Integer, Float, Mod, I, Abs, simplify, Mul, Add, Pow, sign, EulerGamma) from sympy.integrals.rubi.symbol import WC from sympy.core.symbol import symbols, Symbol from sympy.functions import (sin, cos, tan, cot, csc, sec, sqrt, erf) from sympy.functions.elementary.hyperbolic import (acosh, asinh, atanh, acoth, acsch, asech, cosh, sinh, tanh, coth, sech, csch) from sympy.functions.elementary.trigonometric import (atan, acsc, asin, acot, acos, asec, atan2) from sympy import pi as Pi A_, B_, C_, F_, G_, H_, a_, b_, c_, d_, e_, f_, g_, h_, i_, j_, k_, l_, m_, n_, p_, q_, r_, t_, u_, v_, s_, w_, x_, y_, z_ = [WC(i) for i in 'ABCFGHabcdefghijklmnpqrtuvswxyz'] a1_, a2_, b1_, b2_, c1_, c2_, d1_, d2_, n1_, n2_, e1_, e2_, f1_, f2_, g1_, g2_, n1_, n2_, n3_, Pq_, Pm_, Px_, Qm_, Qr_, Qx_, jn_, mn_, non2_, RFx_, RGx_ = [WC(i) for i in ['a1', 'a2', 'b1', 'b2', 'c1', 'c2', 'd1', 'd2', 'n1', 'n2', 'e1', 'e2', 'f1', 'f2', 'g1', 'g2', 'n1', 'n2', 'n3', 'Pq', 'Pm', 'Px', 'Qm', 'Qr', 'Qx', 'jn', 'mn', 'non2', 'RFx', 'RGx']] i, ii , Pqq, Q, R, r, C, k, u = symbols('i ii Pqq Q R r C k u') _UseGamma = False ShowSteps = False StepCounter = None def inverse_hyperbolic(rubi): from sympy.integrals.rubi.constraints import cons87, cons88, cons2, cons3, cons7, cons89, cons1579, cons4, cons148, cons66, cons27, cons21, cons62, cons1734, cons1735, cons1736, cons1778, cons268, cons48, cons1892, cons1893, cons1894, cons1895, cons731, cons652, cons732, cons654, cons584, cons1738, cons1896, cons128, cons1737, cons338, cons163, cons38, cons347, cons137, cons230, cons667, cons5, cons1739, cons1740, cons961, cons1897, cons1741, cons1898, cons1743, cons1742, cons1744, cons1570, cons1899, cons336, cons1900, cons147, cons125, cons208, cons54, cons242, cons1746, cons1747, cons486, cons162, cons94, cons93, cons272, cons1748, cons17, cons166, cons274, cons1749, cons1750, cons18, cons238, cons237, cons1751, cons246, cons1752, cons1901, cons1753, cons1754, cons1902, cons1755, cons1756, cons1903, cons209, cons925, cons464, cons84, cons1757, cons1758, cons719, cons168, cons1759, cons1760, cons267, cons717, cons1761, cons1608, cons14, cons150, cons1198, cons1273, cons1360, cons1830, cons1763, cons34, cons35, cons36, cons1762, cons1904, cons165, cons1442, cons1765, cons1764, cons1766, cons1767, cons528, cons1230, cons1769, cons1770, cons1905, cons1906, cons85, cons804, cons31, cons340, cons1907, cons1908, cons1909, cons1776, cons1043, cons1777, cons1497, cons13, cons1779, cons1780, cons1781, cons1782, cons240, cons241, cons146, cons1783, cons1510, cons1784, cons1152, cons319, cons1785, cons1786, cons1787, cons1788, cons1910, cons1911, cons1912, cons1913, cons1793, cons1794, cons1914, cons1796, cons601, cons1797, cons261, cons1915, cons1482, cons1441, cons1916, cons1250, cons1917, cons1918, cons1802, cons1803, cons1919, cons743, cons177, cons117, cons1920, cons23, cons1921, cons1922, cons1923, cons1924, cons1925, cons674, cons1926, cons1927, cons1928, cons994, cons1580, cons1818, cons1929, cons1930, cons1931, cons1932, cons1933, cons1934, cons1935, cons1824, cons973, cons1936, cons1827, cons1937, cons1938, cons1094, cons1831, cons1832, cons1833, cons1834, cons1939, cons383, cons808, cons1586, cons818, cons463, cons1940, cons1941, cons1942, cons1943, cons1944, cons67, cons1945, cons1946, cons1947, cons1948, cons1847, cons1949, cons1950, cons1951, cons1952, cons1854, cons178, cons1855, cons1856, cons1299, cons1953, cons1954, cons1955, cons1956 pattern6084 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*asinh(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons87, cons88) def replacement6084(b, a, n, c, x): rubi.append(6084) return -Dist(b*c*n, Int(x*(a + b*asinh(c*x))**(n + S(-1))/sqrt(c**S(2)*x**S(2) + S(1)), x), x) + Simp(x*(a + b*asinh(c*x))**n, x) rule6084 = ReplacementRule(pattern6084, replacement6084) pattern6085 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons87, cons88) def replacement6085(b, a, n, c, x): rubi.append(6085) return -Dist(b*c*n, Int(x*(a + b*acosh(c*x))**(n + S(-1))/(sqrt(c*x + S(-1))*sqrt(c*x + S(1))), x), x) + Simp(x*(a + b*acosh(c*x))**n, x) rule6085 = ReplacementRule(pattern6085, replacement6085) pattern6086 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*asinh(x_*WC('c', S(1))))**n_, x_), cons2, cons3, cons7, cons87, cons89) def replacement6086(b, a, n, c, x): rubi.append(6086) return -Dist(c/(b*(n + S(1))), Int(x*(a + b*asinh(c*x))**(n + S(1))/sqrt(c**S(2)*x**S(2) + S(1)), x), x) + Simp((a + b*asinh(c*x))**(n + S(1))*sqrt(c**S(2)*x**S(2) + S(1))/(b*c*(n + S(1))), x) rule6086 = ReplacementRule(pattern6086, replacement6086) pattern6087 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1))))**n_, x_), cons2, cons3, cons7, cons87, cons89) def replacement6087(b, a, n, c, x): rubi.append(6087) return -Dist(c/(b*(n + S(1))), Int(x*(a + b*acosh(c*x))**(n + S(1))/(sqrt(c*x + S(-1))*sqrt(c*x + S(1))), x), x) + Simp((a + b*acosh(c*x))**(n + S(1))*sqrt(c*x + S(-1))*sqrt(c*x + S(1))/(b*c*(n + S(1))), x) rule6087 = ReplacementRule(pattern6087, replacement6087) pattern6088 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*asinh(x_*WC('c', S(1))))**n_, x_), cons2, cons3, cons7, cons4, cons1579) def replacement6088(b, a, n, c, x): rubi.append(6088) return Dist(S(1)/(b*c), Subst(Int(x**n*cosh(a/b - x/b), x), x, a + b*asinh(c*x)), x) rule6088 = ReplacementRule(pattern6088, replacement6088) pattern6089 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1))))**n_, x_), cons2, cons3, cons7, cons4, cons1579) def replacement6089(b, a, n, c, x): rubi.append(6089) return -Dist(S(1)/(b*c), Subst(Int(x**n*sinh(a/b - x/b), x), x, a + b*acosh(c*x)), x) rule6089 = ReplacementRule(pattern6089, replacement6089) pattern6090 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*asinh(x_*WC('c', S(1))))**WC('n', S(1))/x_, x_), cons2, cons3, cons7, cons148) def replacement6090(b, a, n, c, x): rubi.append(6090) return Subst(Int((a + b*x)**n/tanh(x), x), x, asinh(c*x)) rule6090 = ReplacementRule(pattern6090, replacement6090) pattern6091 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1))))**WC('n', S(1))/x_, x_), cons2, cons3, cons7, cons148) def replacement6091(b, a, n, c, x): rubi.append(6091) return Subst(Int((a + b*x)**n*tanh(x), x), x, acosh(c*x)) rule6091 = ReplacementRule(pattern6091, replacement6091) pattern6092 = Pattern(Integral((x_*WC('d', S(1)))**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*asinh(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons21, cons148, cons66) def replacement6092(m, b, d, a, n, c, x): rubi.append(6092) return -Dist(b*c*n/(d*(m + S(1))), Int((d*x)**(m + S(1))*(a + b*asinh(c*x))**(n + S(-1))/sqrt(c**S(2)*x**S(2) + S(1)), x), x) + Simp((d*x)**(m + S(1))*(a + b*asinh(c*x))**n/(d*(m + S(1))), x) rule6092 = ReplacementRule(pattern6092, replacement6092) pattern6093 = Pattern(Integral((x_*WC('d', S(1)))**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons21, cons148, cons66) def replacement6093(m, b, d, a, n, c, x): rubi.append(6093) return -Dist(b*c*n/(d*(m + S(1))), Int((d*x)**(m + S(1))*(a + b*acosh(c*x))**(n + S(-1))/(sqrt(c*x + S(-1))*sqrt(c*x + S(1))), x), x) + Simp((d*x)**(m + S(1))*(a + b*acosh(c*x))**n/(d*(m + S(1))), x) rule6093 = ReplacementRule(pattern6093, replacement6093) pattern6094 = Pattern(Integral(x_**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*asinh(x_*WC('c', S(1))))**n_, x_), cons2, cons3, cons7, cons62, cons87, cons88) def replacement6094(m, b, a, c, n, x): rubi.append(6094) return -Dist(b*c*n/(m + S(1)), Int(x**(m + S(1))*(a + b*asinh(c*x))**(n + S(-1))/sqrt(c**S(2)*x**S(2) + S(1)), x), x) + Simp(x**(m + S(1))*(a + b*asinh(c*x))**n/(m + S(1)), x) rule6094 = ReplacementRule(pattern6094, replacement6094) pattern6095 = Pattern(Integral(x_**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1))))**n_, x_), cons2, cons3, cons7, cons62, cons87, cons88) def replacement6095(m, b, a, c, n, x): rubi.append(6095) return -Dist(b*c*n/(m + S(1)), Int(x**(m + S(1))*(a + b*acosh(c*x))**(n + S(-1))/(sqrt(c*x + S(-1))*sqrt(c*x + S(1))), x), x) + Simp(x**(m + S(1))*(a + b*acosh(c*x))**n/(m + S(1)), x) rule6095 = ReplacementRule(pattern6095, replacement6095) pattern6096 = Pattern(Integral(x_**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*asinh(x_*WC('c', S(1))))**n_, x_), cons2, cons3, cons7, cons62, cons87, cons1734) def replacement6096(m, b, a, c, n, x): rubi.append(6096) return -Dist(c**(-m + S(-1))/(b*(n + S(1))), Subst(Int(ExpandTrigReduce((a + b*x)**(n + S(1)), (m + (m + S(1))*sinh(x)**S(2))*sinh(x)**(m + S(-1)), x), x), x, asinh(c*x)), x) + Simp(x**m*(a + b*asinh(c*x))**(n + S(1))*sqrt(c**S(2)*x**S(2) + S(1))/(b*c*(n + S(1))), x) rule6096 = ReplacementRule(pattern6096, replacement6096) pattern6097 = Pattern(Integral(x_**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1))))**n_, x_), cons2, cons3, cons7, cons62, cons87, cons1734) def replacement6097(m, b, a, c, n, x): rubi.append(6097) return Dist(c**(-m + S(-1))/(b*(n + S(1))), Subst(Int(ExpandTrigReduce((a + b*x)**(n + S(1))*(m - (m + S(1))*cosh(x)**S(2))*cosh(x)**(m + S(-1)), x), x), x, acosh(c*x)), x) + Simp(x**m*(a + b*acosh(c*x))**(n + S(1))*sqrt(c*x + S(-1))*sqrt(c*x + S(1))/(b*c*(n + S(1))), x) rule6097 = ReplacementRule(pattern6097, replacement6097) pattern6098 = Pattern(Integral(x_**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*asinh(x_*WC('c', S(1))))**n_, x_), cons2, cons3, cons7, cons62, cons87, cons1735) def replacement6098(m, b, a, c, n, x): rubi.append(6098) return -Dist(m/(b*c*(n + S(1))), Int(x**(m + S(-1))*(a + b*asinh(c*x))**(n + S(1))/sqrt(c**S(2)*x**S(2) + S(1)), x), x) - Dist(c*(m + S(1))/(b*(n + S(1))), Int(x**(m + S(1))*(a + b*asinh(c*x))**(n + S(1))/sqrt(c**S(2)*x**S(2) + S(1)), x), x) + Simp(x**m*(a + b*asinh(c*x))**(n + S(1))*sqrt(c**S(2)*x**S(2) + S(1))/(b*c*(n + S(1))), x) rule6098 = ReplacementRule(pattern6098, replacement6098) pattern6099 = Pattern(Integral(x_**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1))))**n_, x_), cons2, cons3, cons7, cons62, cons87, cons1735) def replacement6099(m, b, a, c, n, x): rubi.append(6099) return Dist(m/(b*c*(n + S(1))), Int(x**(m + S(-1))*(a + b*acosh(c*x))**(n + S(1))/(sqrt(c*x + S(-1))*sqrt(c*x + S(1))), x), x) - Dist(c*(m + S(1))/(b*(n + S(1))), Int(x**(m + S(1))*(a + b*acosh(c*x))**(n + S(1))/(sqrt(c*x + S(-1))*sqrt(c*x + S(1))), x), x) + Simp(x**m*(a + b*acosh(c*x))**(n + S(1))*sqrt(c*x + S(-1))*sqrt(c*x + S(1))/(b*c*(n + S(1))), x) rule6099 = ReplacementRule(pattern6099, replacement6099) pattern6100 = Pattern(Integral(x_**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*asinh(x_*WC('c', S(1))))**n_, x_), cons2, cons3, cons7, cons4, cons62) def replacement6100(m, b, a, c, n, x): rubi.append(6100) return Dist(c**(-m + S(-1)), Subst(Int((a + b*x)**n*sinh(x)**m*cosh(x), x), x, asinh(c*x)), x) rule6100 = ReplacementRule(pattern6100, replacement6100) pattern6101 = Pattern(Integral(x_**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1))))**n_, x_), cons2, cons3, cons7, cons4, cons62) def replacement6101(m, b, a, c, n, x): rubi.append(6101) return Dist(c**(-m + S(-1)), Subst(Int((a + b*x)**n*sinh(x)*cosh(x)**m, x), x, acosh(c*x)), x) rule6101 = ReplacementRule(pattern6101, replacement6101) pattern6102 = Pattern(Integral((x_*WC('d', S(1)))**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*asinh(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons21, cons4, cons1736) def replacement6102(m, b, d, a, n, c, x): rubi.append(6102) return Int((d*x)**m*(a + b*asinh(c*x))**n, x) rule6102 = ReplacementRule(pattern6102, replacement6102) pattern6103 = Pattern(Integral((x_*WC('d', S(1)))**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons21, cons4, cons1736) def replacement6103(m, b, d, a, n, c, x): rubi.append(6103) return Int((d*x)**m*(a + b*acosh(c*x))**n, x) rule6103 = ReplacementRule(pattern6103, replacement6103) pattern6104 = Pattern(Integral(S(1)/(sqrt(d_ + x_**S(2)*WC('e', S(1)))*(WC('a', S(0)) + WC('b', S(1))*asinh(x_*WC('c', S(1))))), x_), cons2, cons3, cons7, cons27, cons48, cons1778, cons268) def replacement6104(b, d, a, c, x, e): rubi.append(6104) return Simp(log(a + b*asinh(c*x))/(b*c*sqrt(d)), x) rule6104 = ReplacementRule(pattern6104, replacement6104) pattern6105 = Pattern(Integral(S(1)/(sqrt(d1_ + x_*WC('e1', S(1)))*sqrt(d2_ + x_*WC('e2', S(1)))*(WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1))))), x_), cons2, cons3, cons7, cons731, cons652, cons732, cons654, cons1892, cons1893, cons1894, cons1895) def replacement6105(d2, b, e2, a, c, d1, e1, x): rubi.append(6105) return Simp(log(a + b*acosh(c*x))/(b*c*sqrt(-d1*d2)), x) rule6105 = ReplacementRule(pattern6105, replacement6105) pattern6106 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*asinh(x_*WC('c', S(1))))**WC('n', S(1))/sqrt(d_ + x_**S(2)*WC('e', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons4, cons1778, cons268, cons584) def replacement6106(b, d, a, n, c, x, e): rubi.append(6106) return Simp((a + b*asinh(c*x))**(n + S(1))/(b*c*sqrt(d)*(n + S(1))), x) rule6106 = ReplacementRule(pattern6106, replacement6106) pattern6107 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1))))**WC('n', S(1))/(sqrt(d1_ + x_*WC('e1', S(1)))*sqrt(d2_ + x_*WC('e2', S(1)))), x_), cons2, cons3, cons7, cons731, cons652, cons732, cons654, cons4, cons1892, cons1893, cons1894, cons1895, cons584) def replacement6107(d2, b, e2, a, n, c, d1, e1, x): rubi.append(6107) return Simp((a + b*acosh(c*x))**(n + S(1))/(b*c*sqrt(-d1*d2)*(n + S(1))), x) rule6107 = ReplacementRule(pattern6107, replacement6107) pattern6108 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*asinh(x_*WC('c', S(1))))**WC('n', S(1))/sqrt(d_ + x_**S(2)*WC('e', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons4, cons1778, cons1738) def replacement6108(b, d, a, n, c, x, e): rubi.append(6108) return Dist(sqrt(c**S(2)*x**S(2) + S(1))/sqrt(d + e*x**S(2)), Int((a + b*asinh(c*x))**n/sqrt(c**S(2)*x**S(2) + S(1)), x), x) rule6108 = ReplacementRule(pattern6108, replacement6108) pattern6109 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1))))**WC('n', S(1))/(sqrt(d1_ + x_*WC('e1', S(1)))*sqrt(d2_ + x_*WC('e2', S(1)))), x_), cons2, cons3, cons7, cons731, cons652, cons732, cons654, cons4, cons1892, cons1893, cons1896) def replacement6109(d2, b, e2, a, n, c, d1, e1, x): rubi.append(6109) return Dist(sqrt(c*x + S(-1))*sqrt(c*x + S(1))/(sqrt(d1 + e1*x)*sqrt(d2 + e2*x)), Int((a + b*acosh(c*x))**n/(sqrt(c*x + S(-1))*sqrt(c*x + S(1))), x), x) rule6109 = ReplacementRule(pattern6109, replacement6109) def With6110(p, b, d, a, c, x, e): u = IntHide((d + e*x**S(2))**p, x) rubi.append(6110) return -Dist(b*c, Int(SimplifyIntegrand(u/sqrt(c**S(2)*x**S(2) + S(1)), x), x), x) + Dist(a + b*asinh(c*x), u, x) pattern6110 = Pattern(Integral((d_ + x_**S(2)*WC('e', S(1)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*asinh(x_*WC('c', S(1)))), x_), cons2, cons3, cons7, cons27, cons48, cons1778, cons128) rule6110 = ReplacementRule(pattern6110, With6110) def With6111(p, b, d, a, c, x, e): u = IntHide((d + e*x**S(2))**p, x) rubi.append(6111) return -Dist(b*c, Int(SimplifyIntegrand(u/(sqrt(c*x + S(-1))*sqrt(c*x + S(1))), x), x), x) + Dist(a + b*acosh(c*x), u, x) pattern6111 = Pattern(Integral((d_ + x_**S(2)*WC('e', S(1)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1)))), x_), cons2, cons3, cons7, cons27, cons48, cons1737, cons128) rule6111 = ReplacementRule(pattern6111, With6111) pattern6112 = Pattern(Integral((d_ + x_**S(2)*WC('e', S(1)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons1737, cons338, cons88, cons163, cons38) def replacement6112(p, b, d, a, n, c, x, e): rubi.append(6112) return Dist(S(2)*d*p/(S(2)*p + S(1)), Int((a + b*acosh(c*x))**n*(d + e*x**S(2))**(p + S(-1)), x), x) - Dist(b*c*n*(-d)**p/(S(2)*p + S(1)), Int(x*(a + b*acosh(c*x))**(n + S(-1))*(c*x + S(-1))**(p + S(-1)/2)*(c*x + S(1))**(p + S(-1)/2), x), x) + Simp(x*(a + b*acosh(c*x))**n*(d + e*x**S(2))**p/(S(2)*p + S(1)), x) rule6112 = ReplacementRule(pattern6112, replacement6112) pattern6113 = Pattern(Integral(sqrt(d_ + x_**S(2)*WC('e', S(1)))*(WC('a', S(0)) + WC('b', S(1))*asinh(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons1778, cons87, cons88) def replacement6113(b, d, a, n, c, x, e): rubi.append(6113) return Dist(sqrt(d + e*x**S(2))/(S(2)*sqrt(c**S(2)*x**S(2) + S(1))), Int((a + b*asinh(c*x))**n/sqrt(c**S(2)*x**S(2) + S(1)), x), x) - Dist(b*c*n*sqrt(d + e*x**S(2))/(S(2)*sqrt(c**S(2)*x**S(2) + S(1))), Int(x*(a + b*asinh(c*x))**(n + S(-1)), x), x) + Simp(x*(a + b*asinh(c*x))**n*sqrt(d + e*x**S(2))/S(2), x) rule6113 = ReplacementRule(pattern6113, replacement6113) pattern6114 = Pattern(Integral(sqrt(d1_ + x_*WC('e1', S(1)))*sqrt(d2_ + x_*WC('e2', S(1)))*(WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons731, cons652, cons732, cons654, cons1892, cons1893, cons87, cons88) def replacement6114(d2, b, e2, a, n, c, d1, e1, x): rubi.append(6114) return -Dist(sqrt(d1 + e1*x)*sqrt(d2 + e2*x)/(S(2)*sqrt(c*x + S(-1))*sqrt(c*x + S(1))), Int((a + b*acosh(c*x))**n/(sqrt(c*x + S(-1))*sqrt(c*x + S(1))), x), x) - Dist(b*c*n*sqrt(d1 + e1*x)*sqrt(d2 + e2*x)/(S(2)*sqrt(c*x + S(-1))*sqrt(c*x + S(1))), Int(x*(a + b*acosh(c*x))**(n + S(-1)), x), x) + Simp(x*(a + b*acosh(c*x))**n*sqrt(d1 + e1*x)*sqrt(d2 + e2*x)/S(2), x) rule6114 = ReplacementRule(pattern6114, replacement6114) pattern6115 = Pattern(Integral((d_ + x_**S(2)*WC('e', S(1)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*asinh(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons1778, cons338, cons88, cons163) def replacement6115(p, b, d, a, n, c, x, e): rubi.append(6115) return Dist(S(2)*d*p/(S(2)*p + S(1)), Int((a + b*asinh(c*x))**n*(d + e*x**S(2))**(p + S(-1)), x), x) - Dist(b*c*d**IntPart(p)*n*(d + e*x**S(2))**FracPart(p)*(c**S(2)*x**S(2) + S(1))**(-FracPart(p))/(S(2)*p + S(1)), Int(x*(a + b*asinh(c*x))**(n + S(-1))*(c**S(2)*x**S(2) + S(1))**(p + S(-1)/2), x), x) + Simp(x*(a + b*asinh(c*x))**n*(d + e*x**S(2))**p/(S(2)*p + S(1)), x) rule6115 = ReplacementRule(pattern6115, replacement6115) pattern6116 = Pattern(Integral((d1_ + x_*WC('e1', S(1)))**WC('p', S(1))*(d2_ + x_*WC('e2', S(1)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons731, cons652, cons732, cons654, cons1892, cons1893, cons338, cons88, cons163, cons347) def replacement6116(p, d2, b, e2, a, n, c, d1, e1, x): rubi.append(6116) return Dist(S(2)*d1*d2*p/(S(2)*p + S(1)), Int((a + b*acosh(c*x))**n*(d1 + e1*x)**(p + S(-1))*(d2 + e2*x)**(p + S(-1)), x), x) - Dist(b*c*n*(-d1*d2)**(p + S(-1)/2)*sqrt(d1 + e1*x)*sqrt(d2 + e2*x)/((S(2)*p + S(1))*sqrt(c*x + S(-1))*sqrt(c*x + S(1))), Int(x*(a + b*acosh(c*x))**(n + S(-1))*(c**S(2)*x**S(2) + S(-1))**(p + S(-1)/2), x), x) + Simp(x*(a + b*acosh(c*x))**n*(d1 + e1*x)**p*(d2 + e2*x)**p/(S(2)*p + S(1)), x) rule6116 = ReplacementRule(pattern6116, replacement6116) pattern6117 = Pattern(Integral((d1_ + x_*WC('e1', S(1)))**WC('p', S(1))*(d2_ + x_*WC('e2', S(1)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons731, cons652, cons732, cons654, cons1892, cons1893, cons338, cons88, cons163) def replacement6117(p, d2, b, e2, a, n, c, d1, e1, x): rubi.append(6117) return Dist(S(2)*d1*d2*p/(S(2)*p + S(1)), Int((a + b*acosh(c*x))**n*(d1 + e1*x)**(p + S(-1))*(d2 + e2*x)**(p + S(-1)), x), x) - Dist(b*c*n*(-d1*d2)**IntPart(p)*(d1 + e1*x)**FracPart(p)*(d2 + e2*x)**FracPart(p)*(c*x + S(-1))**(-FracPart(p))*(c*x + S(1))**(-FracPart(p))/(S(2)*p + S(1)), Int(x*(a + b*acosh(c*x))**(n + S(-1))*(c*x + S(-1))**(p + S(-1)/2)*(c*x + S(1))**(p + S(-1)/2), x), x) + Simp(x*(a + b*acosh(c*x))**n*(d1 + e1*x)**p*(d2 + e2*x)**p/(S(2)*p + S(1)), x) rule6117 = ReplacementRule(pattern6117, replacement6117) pattern6118 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*asinh(x_*WC('c', S(1))))**WC('n', S(1))/(d_ + x_**S(2)*WC('e', S(1)))**(S(3)/2), x_), cons2, cons3, cons7, cons27, cons48, cons1778, cons87, cons88) def replacement6118(b, d, a, n, c, x, e): rubi.append(6118) return -Dist(b*c*n*sqrt(c**S(2)*x**S(2) + S(1))/(d*sqrt(d + e*x**S(2))), Int(x*(a + b*asinh(c*x))**(n + S(-1))/(c**S(2)*x**S(2) + S(1)), x), x) + Simp(x*(a + b*asinh(c*x))**n/(d*sqrt(d + e*x**S(2))), x) rule6118 = ReplacementRule(pattern6118, replacement6118) pattern6119 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1))))**WC('n', S(1))/((d1_ + x_*WC('e1', S(1)))**(S(3)/2)*(d2_ + x_*WC('e2', S(1)))**(S(3)/2)), x_), cons2, cons3, cons7, cons731, cons652, cons732, cons654, cons1892, cons1893, cons87, cons88) def replacement6119(d2, b, e2, a, n, c, d1, e1, x): rubi.append(6119) return Dist(b*c*n*sqrt(c*x + S(-1))*sqrt(c*x + S(1))/(d1*d2*sqrt(d1 + e1*x)*sqrt(d2 + e2*x)), Int(x*(a + b*acosh(c*x))**(n + S(-1))/(-c**S(2)*x**S(2) + S(1)), x), x) + Simp(x*(a + b*acosh(c*x))**n/(d1*d2*sqrt(d1 + e1*x)*sqrt(d2 + e2*x)), x) rule6119 = ReplacementRule(pattern6119, replacement6119) pattern6120 = Pattern(Integral((d_ + x_**S(2)*WC('e', S(1)))**p_*(WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons1737, cons338, cons88, cons137, cons38) def replacement6120(p, b, d, a, n, c, x, e): rubi.append(6120) return Dist((S(2)*p + S(3))/(S(2)*d*(p + S(1))), Int((a + b*acosh(c*x))**n*(d + e*x**S(2))**(p + S(1)), x), x) - Dist(b*c*n*(-d)**p/(S(2)*p + S(2)), Int(x*(a + b*acosh(c*x))**(n + S(-1))*(c*x + S(-1))**(p + S(1)/2)*(c*x + S(1))**(p + S(1)/2), x), x) - Simp(x*(a + b*acosh(c*x))**n*(d + e*x**S(2))**(p + S(1))/(S(2)*d*(p + S(1))), x) rule6120 = ReplacementRule(pattern6120, replacement6120) pattern6121 = Pattern(Integral((d_ + x_**S(2)*WC('e', S(1)))**p_*(WC('a', S(0)) + WC('b', S(1))*asinh(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons1778, cons338, cons88, cons137, cons230) def replacement6121(p, b, d, a, n, c, x, e): rubi.append(6121) return Dist((S(2)*p + S(3))/(S(2)*d*(p + S(1))), Int((a + b*asinh(c*x))**n*(d + e*x**S(2))**(p + S(1)), x), x) + Dist(b*c*d**IntPart(p)*n*(d + e*x**S(2))**FracPart(p)*(c**S(2)*x**S(2) + S(1))**(-FracPart(p))/(S(2)*(p + S(1))), Int(x*(a + b*asinh(c*x))**(n + S(-1))*(c**S(2)*x**S(2) + S(1))**(p + S(1)/2), x), x) - Simp(x*(a + b*asinh(c*x))**n*(d + e*x**S(2))**(p + S(1))/(S(2)*d*(p + S(1))), x) rule6121 = ReplacementRule(pattern6121, replacement6121) pattern6122 = Pattern(Integral((d1_ + x_*WC('e1', S(1)))**p_*(d2_ + x_*WC('e2', S(1)))**p_*(WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons731, cons652, cons732, cons654, cons1892, cons1893, cons338, cons88, cons137, cons230, cons667) def replacement6122(p, d2, b, e2, a, n, c, d1, e1, x): rubi.append(6122) return Dist((S(2)*p + S(3))/(S(2)*d1*d2*(p + S(1))), Int((a + b*acosh(c*x))**n*(d1 + e1*x)**(p + S(1))*(d2 + e2*x)**(p + S(1)), x), x) - Dist(b*c*n*(-d1*d2)**(p + S(1)/2)*sqrt(c*x + S(-1))*sqrt(c*x + S(1))/(S(2)*sqrt(d1 + e1*x)*sqrt(d2 + e2*x)*(p + S(1))), Int(x*(a + b*acosh(c*x))**(n + S(-1))*(c**S(2)*x**S(2) + S(-1))**(p + S(1)/2), x), x) - Simp(x*(a + b*acosh(c*x))**n*(d1 + e1*x)**(p + S(1))*(d2 + e2*x)**(p + S(1))/(S(2)*d1*d2*(p + S(1))), x) rule6122 = ReplacementRule(pattern6122, replacement6122) pattern6123 = Pattern(Integral((d1_ + x_*WC('e1', S(1)))**p_*(d2_ + x_*WC('e2', S(1)))**p_*(WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons731, cons652, cons732, cons654, cons1892, cons1893, cons338, cons88, cons137, cons230) def replacement6123(p, d2, b, e2, a, n, c, d1, e1, x): rubi.append(6123) return Dist((S(2)*p + S(3))/(S(2)*d1*d2*(p + S(1))), Int((a + b*acosh(c*x))**n*(d1 + e1*x)**(p + S(1))*(d2 + e2*x)**(p + S(1)), x), x) - Dist(b*c*n*(-d1*d2)**IntPart(p)*(d1 + e1*x)**FracPart(p)*(d2 + e2*x)**FracPart(p)*(c*x + S(-1))**(-FracPart(p))*(c*x + S(1))**(-FracPart(p))/(S(2)*(p + S(1))), Int(x*(a + b*acosh(c*x))**(n + S(-1))*(c*x + S(-1))**(p + S(1)/2)*(c*x + S(1))**(p + S(1)/2), x), x) - Simp(x*(a + b*acosh(c*x))**n*(d1 + e1*x)**(p + S(1))*(d2 + e2*x)**(p + S(1))/(S(2)*d1*d2*(p + S(1))), x) rule6123 = ReplacementRule(pattern6123, replacement6123) pattern6124 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*asinh(x_*WC('c', S(1))))**WC('n', S(1))/(d_ + x_**S(2)*WC('e', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons1778, cons148) def replacement6124(b, d, a, n, c, x, e): rubi.append(6124) return Dist(S(1)/(c*d), Subst(Int((a + b*x)**n/cosh(x), x), x, asinh(c*x)), x) rule6124 = ReplacementRule(pattern6124, replacement6124) pattern6125 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1))))**WC('n', S(1))/(d_ + x_**S(2)*WC('e', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons1737, cons148) def replacement6125(b, d, a, n, c, x, e): rubi.append(6125) return -Dist(S(1)/(c*d), Subst(Int((a + b*x)**n/sinh(x), x), x, acosh(c*x)), x) rule6125 = ReplacementRule(pattern6125, replacement6125) pattern6126 = Pattern(Integral((d_ + x_**S(2)*WC('e', S(1)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons5, cons1737, cons87, cons89, cons38) def replacement6126(p, b, d, a, c, n, x, e): rubi.append(6126) return -Dist(c*(-d)**p*(S(2)*p + S(1))/(b*(n + S(1))), Int(x*(a + b*acosh(c*x))**(n + S(1))*(c*x + S(-1))**(p + S(-1)/2)*(c*x + S(1))**(p + S(-1)/2), x), x) + Simp((-d)**p*(a + b*acosh(c*x))**(n + S(1))*(c*x + S(-1))**(p + S(1)/2)*(c*x + S(1))**(p + S(1)/2)/(b*c*(n + S(1))), x) rule6126 = ReplacementRule(pattern6126, replacement6126) pattern6127 = Pattern(Integral((d_ + x_**S(2)*WC('e', S(1)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*asinh(x_*WC('c', S(1))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons5, cons1778, cons87, cons89) def replacement6127(p, b, d, a, c, n, x, e): rubi.append(6127) return -Dist(c*d**IntPart(p)*(d + e*x**S(2))**FracPart(p)*(S(2)*p + S(1))*(c**S(2)*x**S(2) + S(1))**(-FracPart(p))/(b*(n + S(1))), Int(x*(a + b*asinh(c*x))**(n + S(1))*(c**S(2)*x**S(2) + S(1))**(p + S(-1)/2), x), x) + Simp((a + b*asinh(c*x))**(n + S(1))*(d + e*x**S(2))**p*sqrt(c**S(2)*x**S(2) + S(1))/(b*c*(n + S(1))), x) rule6127 = ReplacementRule(pattern6127, replacement6127) pattern6128 = Pattern(Integral((d1_ + x_*WC('e1', S(1)))**WC('p', S(1))*(d2_ + x_*WC('e2', S(1)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1))))**n_, x_), cons2, cons3, cons7, cons731, cons652, cons732, cons654, cons5, cons1892, cons1893, cons87, cons89, cons347) def replacement6128(p, d2, b, e2, a, c, n, d1, e1, x): rubi.append(6128) return -Dist(c*(-d1*d2)**(p + S(-1)/2)*sqrt(d1 + e1*x)*sqrt(d2 + e2*x)*(S(2)*p + S(1))/(b*(n + S(1))*sqrt(c*x + S(-1))*sqrt(c*x + S(1))), Int(x*(a + b*acosh(c*x))**(n + S(1))*(c**S(2)*x**S(2) + S(-1))**(p + S(-1)/2), x), x) + Simp((a + b*acosh(c*x))**(n + S(1))*(d1 + e1*x)**p*(d2 + e2*x)**p*sqrt(c*x + S(-1))*sqrt(c*x + S(1))/(b*c*(n + S(1))), x) rule6128 = ReplacementRule(pattern6128, replacement6128) pattern6129 = Pattern(Integral((d1_ + x_*WC('e1', S(1)))**WC('p', S(1))*(d2_ + x_*WC('e2', S(1)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1))))**n_, x_), cons2, cons3, cons7, cons731, cons652, cons732, cons654, cons5, cons1892, cons1893, cons87, cons89) def replacement6129(p, d2, b, e2, a, c, n, d1, e1, x): rubi.append(6129) return -Dist(c*(-d1*d2)**IntPart(p)*(d1 + e1*x)**FracPart(p)*(d2 + e2*x)**FracPart(p)*(S(2)*p + S(1))*(c*x + S(-1))**(-FracPart(p))*(c*x + S(1))**(-FracPart(p))/(b*(n + S(1))), Int(x*(a + b*acosh(c*x))**(n + S(1))*(c*x + S(-1))**(p + S(-1)/2)*(c*x + S(1))**(p + S(-1)/2), x), x) + Simp((a + b*acosh(c*x))**(n + S(1))*(d1 + e1*x)**p*(d2 + e2*x)**p*sqrt(c*x + S(-1))*sqrt(c*x + S(1))/(b*c*(n + S(1))), x) rule6129 = ReplacementRule(pattern6129, replacement6129) pattern6130 = Pattern(Integral((d_ + x_**S(2)*WC('e', S(1)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*asinh(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons4, cons1778, cons1739, cons1740) def replacement6130(p, b, d, a, n, c, x, e): rubi.append(6130) return Dist(d**p/c, Subst(Int((a + b*x)**n*cosh(x)**(S(2)*p + S(1)), x), x, asinh(c*x)), x) rule6130 = ReplacementRule(pattern6130, replacement6130) pattern6131 = Pattern(Integral((d_ + x_**S(2)*WC('e', S(1)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons4, cons1737, cons128) def replacement6131(p, b, d, a, n, c, x, e): rubi.append(6131) return Dist((-d)**p/c, Subst(Int((a + b*x)**n*sinh(x)**(S(2)*p + S(1)), x), x, acosh(c*x)), x) rule6131 = ReplacementRule(pattern6131, replacement6131) pattern6132 = Pattern(Integral((d1_ + x_*WC('e1', S(1)))**WC('p', S(1))*(d2_ + x_*WC('e2', S(1)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons731, cons652, cons732, cons654, cons4, cons1892, cons1893, cons961, cons1897) def replacement6132(p, d2, b, e2, a, n, c, d1, e1, x): rubi.append(6132) return Dist((-d1*d2)**p/c, Subst(Int((a + b*x)**n*sinh(x)**(S(2)*p + S(1)), x), x, acosh(c*x)), x) rule6132 = ReplacementRule(pattern6132, replacement6132) pattern6133 = Pattern(Integral((d_ + x_**S(2)*WC('e', S(1)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*asinh(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons4, cons1778, cons1739, cons1741) def replacement6133(p, b, d, a, n, c, x, e): rubi.append(6133) return Dist(d**(p + S(-1)/2)*sqrt(d + e*x**S(2))/sqrt(c**S(2)*x**S(2) + S(1)), Int((a + b*asinh(c*x))**n*(c**S(2)*x**S(2) + S(1))**p, x), x) rule6133 = ReplacementRule(pattern6133, replacement6133) pattern6134 = Pattern(Integral((d1_ + x_*WC('e1', S(1)))**WC('p', S(1))*(d2_ + x_*WC('e2', S(1)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons731, cons652, cons732, cons654, cons4, cons1892, cons1893, cons1739, cons1896) def replacement6134(p, d2, b, e2, a, n, c, d1, e1, x): rubi.append(6134) return Dist((-d1*d2)**(p + S(-1)/2)*sqrt(d1 + e1*x)*sqrt(d2 + e2*x)/(sqrt(c*x + S(-1))*sqrt(c*x + S(1))), Int((a + b*acosh(c*x))**n*(c*x + S(-1))**p*(c*x + S(1))**p, x), x) rule6134 = ReplacementRule(pattern6134, replacement6134) def With6135(p, b, d, a, c, x, e): u = IntHide((d + e*x**S(2))**p, x) rubi.append(6135) return -Dist(b*c, Int(SimplifyIntegrand(u/sqrt(c**S(2)*x**S(2) + S(1)), x), x), x) + Dist(a + b*asinh(c*x), u, x) pattern6135 = Pattern(Integral((d_ + x_**S(2)*WC('e', S(1)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*asinh(x_*WC('c', S(1)))), x_), cons2, cons3, cons7, cons27, cons48, cons1898, cons1743) rule6135 = ReplacementRule(pattern6135, With6135) def With6136(p, b, d, a, c, x, e): u = IntHide((d + e*x**S(2))**p, x) rubi.append(6136) return -Dist(b*c, Int(SimplifyIntegrand(u/(sqrt(c*x + S(-1))*sqrt(c*x + S(1))), x), x), x) + Dist(a + b*acosh(c*x), u, x) pattern6136 = Pattern(Integral((d_ + x_**S(2)*WC('e', S(1)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1)))), x_), cons2, cons3, cons7, cons27, cons48, cons1742, cons1743) rule6136 = ReplacementRule(pattern6136, With6136) pattern6137 = Pattern(Integral((d_ + x_**S(2)*WC('e', S(1)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*asinh(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons4, cons1898, cons38, cons1744) def replacement6137(p, b, d, a, n, c, x, e): rubi.append(6137) return Int(ExpandIntegrand((a + b*asinh(c*x))**n, (d + e*x**S(2))**p, x), x) rule6137 = ReplacementRule(pattern6137, replacement6137) pattern6138 = Pattern(Integral((d_ + x_**S(2)*WC('e', S(1)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons4, cons1742, cons38, cons1744) def replacement6138(p, b, d, a, n, c, x, e): rubi.append(6138) return Int(ExpandIntegrand((a + b*acosh(c*x))**n, (d + e*x**S(2))**p, x), x) rule6138 = ReplacementRule(pattern6138, replacement6138) pattern6139 = Pattern(Integral((d_ + x_**S(2)*WC('e', S(1)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*asinh(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons4, cons5, cons1570) def replacement6139(p, b, d, a, n, c, x, e): rubi.append(6139) return Int((a + b*asinh(c*x))**n*(d + e*x**S(2))**p, x) rule6139 = ReplacementRule(pattern6139, replacement6139) pattern6140 = Pattern(Integral((d_ + x_**S(2)*WC('e', S(1)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons4, cons5, cons38) def replacement6140(p, b, d, a, n, c, x, e): rubi.append(6140) return Int((a + b*acosh(c*x))**n*(d + e*x**S(2))**p, x) rule6140 = ReplacementRule(pattern6140, replacement6140) pattern6141 = Pattern(Integral((d1_ + x_*WC('e1', S(1)))**WC('p', S(1))*(d2_ + x_*WC('e2', S(1)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons731, cons652, cons732, cons654, cons4, cons5, cons1899) def replacement6141(p, d2, b, e2, a, n, c, d1, e1, x): rubi.append(6141) return Int((a + b*acosh(c*x))**n*(d1 + e1*x)**p*(d2 + e2*x)**p, x) rule6141 = ReplacementRule(pattern6141, replacement6141) pattern6142 = Pattern(Integral((d_ + x_*WC('e', S(1)))**p_*(f_ + x_*WC('g', S(1)))**p_*(WC('a', S(0)) + WC('b', S(1))*asinh(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons4, cons5, cons336, cons1900, cons147) def replacement6142(p, g, b, f, d, a, n, c, x, e): rubi.append(6142) return Dist((d + e*x)**FracPart(p)*(f + g*x)**FracPart(p)*(d*f + e*g*x**S(2))**(-FracPart(p)), Int((a + b*asinh(c*x))**n*(d*f + e*g*x**S(2))**p, x), x) rule6142 = ReplacementRule(pattern6142, replacement6142) pattern6143 = Pattern(Integral((d_ + x_**S(2)*WC('e', S(1)))**p_*(WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons4, cons5, cons1737, cons147) def replacement6143(p, b, d, a, n, c, x, e): rubi.append(6143) return Dist((-d)**IntPart(p)*(d + e*x**S(2))**FracPart(p)*(c*x + S(-1))**(-FracPart(p))*(c*x + S(1))**(-FracPart(p)), Int((a + b*acosh(c*x))**n*(c*x + S(-1))**p*(c*x + S(1))**p, x), x) rule6143 = ReplacementRule(pattern6143, replacement6143) pattern6144 = Pattern(Integral(x_*(WC('a', S(0)) + WC('b', S(1))*asinh(x_*WC('c', S(1))))**WC('n', S(1))/(d_ + x_**S(2)*WC('e', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons1778, cons148) def replacement6144(b, d, a, n, c, x, e): rubi.append(6144) return Dist(S(1)/e, Subst(Int((a + b*x)**n*tanh(x), x), x, asinh(c*x)), x) rule6144 = ReplacementRule(pattern6144, replacement6144) pattern6145 = Pattern(Integral(x_*(WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1))))**WC('n', S(1))/(d_ + x_**S(2)*WC('e', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons1737, cons148) def replacement6145(b, d, a, n, c, x, e): rubi.append(6145) return Dist(S(1)/e, Subst(Int((a + b*x)**n/tanh(x), x), x, acosh(c*x)), x) rule6145 = ReplacementRule(pattern6145, replacement6145) pattern6146 = Pattern(Integral(x_*(d_ + x_**S(2)*WC('e', S(1)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons5, cons1737, cons87, cons88, cons54, cons38) def replacement6146(p, b, d, a, n, c, x, e): rubi.append(6146) return -Dist(b*n*(-d)**p/(S(2)*c*(p + S(1))), Int((a + b*acosh(c*x))**(n + S(-1))*(c*x + S(-1))**(p + S(1)/2)*(c*x + S(1))**(p + S(1)/2), x), x) + Simp((a + b*acosh(c*x))**n*(d + e*x**S(2))**(p + S(1))/(S(2)*e*(p + S(1))), x) rule6146 = ReplacementRule(pattern6146, replacement6146) pattern6147 = Pattern(Integral(x_*(d_ + x_**S(2)*WC('e', S(1)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*asinh(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons5, cons1778, cons87, cons88, cons54) def replacement6147(p, b, d, a, n, c, x, e): rubi.append(6147) return -Dist(b*d**IntPart(p)*n*(d + e*x**S(2))**FracPart(p)*(c**S(2)*x**S(2) + S(1))**(-FracPart(p))/(S(2)*c*(p + S(1))), Int((a + b*asinh(c*x))**(n + S(-1))*(c**S(2)*x**S(2) + S(1))**(p + S(1)/2), x), x) + Simp((a + b*asinh(c*x))**n*(d + e*x**S(2))**(p + S(1))/(S(2)*e*(p + S(1))), x) rule6147 = ReplacementRule(pattern6147, replacement6147) pattern6148 = Pattern(Integral(x_*(d1_ + x_*WC('e1', S(1)))**WC('p', S(1))*(d2_ + x_*WC('e2', S(1)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons731, cons652, cons732, cons654, cons5, cons1892, cons1893, cons87, cons88, cons54, cons667) def replacement6148(p, d2, b, e2, a, n, c, d1, e1, x): rubi.append(6148) return -Dist(b*n*(-d1*d2)**IntPart(p)*(d1 + e1*x)**FracPart(p)*(d2 + e2*x)**FracPart(p)*(c*x + S(-1))**(-FracPart(p))*(c*x + S(1))**(-FracPart(p))/(S(2)*c*(p + S(1))), Int((a + b*acosh(c*x))**(n + S(-1))*(c**S(2)*x**S(2) + S(-1))**(p + S(1)/2), x), x) + Simp((a + b*acosh(c*x))**n*(d1 + e1*x)**(p + S(1))*(d2 + e2*x)**(p + S(1))/(S(2)*e1*e2*(p + S(1))), x) rule6148 = ReplacementRule(pattern6148, replacement6148) pattern6149 = Pattern(Integral(x_*(d1_ + x_*WC('e1', S(1)))**WC('p', S(1))*(d2_ + x_*WC('e2', S(1)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons731, cons652, cons732, cons654, cons5, cons1892, cons1893, cons87, cons88, cons54) def replacement6149(p, d2, b, e2, a, n, c, d1, e1, x): rubi.append(6149) return -Dist(b*n*(-d1*d2)**IntPart(p)*(d1 + e1*x)**FracPart(p)*(d2 + e2*x)**FracPart(p)*(c*x + S(-1))**(-FracPart(p))*(c*x + S(1))**(-FracPart(p))/(S(2)*c*(p + S(1))), Int((a + b*acosh(c*x))**(n + S(-1))*(c*x + S(-1))**(p + S(1)/2)*(c*x + S(1))**(p + S(1)/2), x), x) + Simp((a + b*acosh(c*x))**n*(d1 + e1*x)**(p + S(1))*(d2 + e2*x)**(p + S(1))/(S(2)*e1*e2*(p + S(1))), x) rule6149 = ReplacementRule(pattern6149, replacement6149) pattern6150 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*asinh(x_*WC('c', S(1))))**WC('n', S(1))/(x_*(d_ + x_**S(2)*WC('e', S(1)))), x_), cons2, cons3, cons7, cons27, cons48, cons1778, cons148) def replacement6150(b, d, a, n, c, x, e): rubi.append(6150) return Dist(S(1)/d, Subst(Int((a + b*x)**n/(sinh(x)*cosh(x)), x), x, asinh(c*x)), x) rule6150 = ReplacementRule(pattern6150, replacement6150) pattern6151 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1))))**WC('n', S(1))/(x_*(d_ + x_**S(2)*WC('e', S(1)))), x_), cons2, cons3, cons7, cons27, cons48, cons1737, cons148) def replacement6151(b, d, a, n, c, x, e): rubi.append(6151) return -Dist(S(1)/d, Subst(Int((a + b*x)**n/(sinh(x)*cosh(x)), x), x, acosh(c*x)), x) rule6151 = ReplacementRule(pattern6151, replacement6151) pattern6152 = Pattern(Integral((x_*WC('f', S(1)))**m_*(d_ + x_**S(2)*WC('e', S(1)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons5, cons1737, cons87, cons88, cons242, cons66, cons38) def replacement6152(p, m, f, b, d, a, n, c, x, e): rubi.append(6152) return Dist(b*c*n*(-d)**p/(f*(m + S(1))), Int((f*x)**(m + S(1))*(a + b*acosh(c*x))**(n + S(-1))*(c*x + S(-1))**(p + S(1)/2)*(c*x + S(1))**(p + S(1)/2), x), x) + Simp((f*x)**(m + S(1))*(a + b*acosh(c*x))**n*(d + e*x**S(2))**(p + S(1))/(d*f*(m + S(1))), x) rule6152 = ReplacementRule(pattern6152, replacement6152) pattern6153 = Pattern(Integral((x_*WC('f', S(1)))**m_*(d_ + x_**S(2)*WC('e', S(1)))**p_*(WC('a', S(0)) + WC('b', S(1))*asinh(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons5, cons1778, cons87, cons88, cons242, cons66) def replacement6153(p, m, f, b, d, a, n, c, x, e): rubi.append(6153) return -Dist(b*c*d**IntPart(p)*n*(d + e*x**S(2))**FracPart(p)*(c**S(2)*x**S(2) + S(1))**(-FracPart(p))/(f*(m + S(1))), Int((f*x)**(m + S(1))*(a + b*asinh(c*x))**(n + S(-1))*(c**S(2)*x**S(2) + S(1))**(p + S(1)/2), x), x) + Simp((f*x)**(m + S(1))*(a + b*asinh(c*x))**n*(d + e*x**S(2))**(p + S(1))/(d*f*(m + S(1))), x) rule6153 = ReplacementRule(pattern6153, replacement6153) pattern6154 = Pattern(Integral((x_*WC('f', S(1)))**m_*(d1_ + x_*WC('e1', S(1)))**WC('p', S(1))*(d2_ + x_*WC('e2', S(1)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons731, cons652, cons732, cons654, cons125, cons21, cons5, cons1892, cons1893, cons87, cons88, cons242, cons66, cons667) def replacement6154(p, d2, m, f, b, e2, a, n, c, d1, e1, x): rubi.append(6154) return Dist(b*c*n*(-d1*d2)**IntPart(p)*(d1 + e1*x)**FracPart(p)*(d2 + e2*x)**FracPart(p)*(c*x + S(-1))**(-FracPart(p))*(c*x + S(1))**(-FracPart(p))/(f*(m + S(1))), Int((f*x)**(m + S(1))*(a + b*acosh(c*x))**(n + S(-1))*(c**S(2)*x**S(2) + S(-1))**(p + S(1)/2), x), x) + Simp((f*x)**(m + S(1))*(a + b*acosh(c*x))**n*(d1 + e1*x)**(p + S(1))*(d2 + e2*x)**(p + S(1))/(d1*d2*f*(m + S(1))), x) rule6154 = ReplacementRule(pattern6154, replacement6154) pattern6155 = Pattern(Integral((x_*WC('f', S(1)))**m_*(d1_ + x_*WC('e1', S(1)))**WC('p', S(1))*(d2_ + x_*WC('e2', S(1)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons731, cons652, cons732, cons654, cons125, cons21, cons5, cons1892, cons1893, cons87, cons88, cons242, cons66) def replacement6155(p, d2, m, f, b, e2, a, n, c, d1, e1, x): rubi.append(6155) return Dist(b*c*n*(-d1*d2)**IntPart(p)*(d1 + e1*x)**FracPart(p)*(d2 + e2*x)**FracPart(p)*(c*x + S(-1))**(-FracPart(p))*(c*x + S(1))**(-FracPart(p))/(f*(m + S(1))), Int((f*x)**(m + S(1))*(a + b*acosh(c*x))**(n + S(-1))*(c*x + S(-1))**(p + S(1)/2)*(c*x + S(1))**(p + S(1)/2), x), x) + Simp((f*x)**(m + S(1))*(a + b*acosh(c*x))**n*(d1 + e1*x)**(p + S(1))*(d2 + e2*x)**(p + S(1))/(d1*d2*f*(m + S(1))), x) rule6155 = ReplacementRule(pattern6155, replacement6155) pattern6156 = Pattern(Integral((d_ + x_**S(2)*WC('e', S(1)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*asinh(x_*WC('c', S(1))))/x_, x_), cons2, cons3, cons7, cons27, cons48, cons1778, cons128) def replacement6156(p, b, d, a, c, x, e): rubi.append(6156) return Dist(d, Int((a + b*asinh(c*x))*(d + e*x**S(2))**(p + S(-1))/x, x), x) - Dist(b*c*d**p/(S(2)*p), Int((c**S(2)*x**S(2) + S(1))**(p + S(-1)/2), x), x) + Simp((a + b*asinh(c*x))*(d + e*x**S(2))**p/(S(2)*p), x) rule6156 = ReplacementRule(pattern6156, replacement6156) pattern6157 = Pattern(Integral((d_ + x_**S(2)*WC('e', S(1)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1))))/x_, x_), cons2, cons3, cons7, cons27, cons48, cons1737, cons128) def replacement6157(p, b, d, a, c, x, e): rubi.append(6157) return Dist(d, Int((a + b*acosh(c*x))*(d + e*x**S(2))**(p + S(-1))/x, x), x) - Dist(b*c*(-d)**p/(S(2)*p), Int((c*x + S(-1))**(p + S(-1)/2)*(c*x + S(1))**(p + S(-1)/2), x), x) + Simp((a + b*acosh(c*x))*(d + e*x**S(2))**p/(S(2)*p), x) rule6157 = ReplacementRule(pattern6157, replacement6157) pattern6158 = Pattern(Integral((x_*WC('f', S(1)))**m_*(d_ + x_**S(2)*WC('e', S(1)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*asinh(x_*WC('c', S(1)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons1778, cons128, cons1746) def replacement6158(p, m, f, b, d, a, c, x, e): rubi.append(6158) return -Dist(S(2)*e*p/(f**S(2)*(m + S(1))), Int((f*x)**(m + S(2))*(a + b*asinh(c*x))*(d + e*x**S(2))**(p + S(-1)), x), x) - Dist(b*c*d**p/(f*(m + S(1))), Int((f*x)**(m + S(1))*(c**S(2)*x**S(2) + S(1))**(p + S(-1)/2), x), x) + Simp((f*x)**(m + S(1))*(a + b*asinh(c*x))*(d + e*x**S(2))**p/(f*(m + S(1))), x) rule6158 = ReplacementRule(pattern6158, replacement6158) pattern6159 = Pattern(Integral((x_*WC('f', S(1)))**m_*(d_ + x_**S(2)*WC('e', S(1)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons1737, cons128, cons1746) def replacement6159(p, m, f, b, d, a, c, x, e): rubi.append(6159) return -Dist(S(2)*e*p/(f**S(2)*(m + S(1))), Int((f*x)**(m + S(2))*(a + b*acosh(c*x))*(d + e*x**S(2))**(p + S(-1)), x), x) - Dist(b*c*(-d)**p/(f*(m + S(1))), Int((f*x)**(m + S(1))*(c*x + S(-1))**(p + S(-1)/2)*(c*x + S(1))**(p + S(-1)/2), x), x) + Simp((f*x)**(m + S(1))*(a + b*acosh(c*x))*(d + e*x**S(2))**p/(f*(m + S(1))), x) rule6159 = ReplacementRule(pattern6159, replacement6159) def With6160(p, m, f, b, d, a, c, x, e): u = IntHide((f*x)**m*(d + e*x**S(2))**p, x) rubi.append(6160) return -Dist(b*c, Int(SimplifyIntegrand(u/sqrt(c**S(2)*x**S(2) + S(1)), x), x), x) + Dist(a + b*asinh(c*x), u, x) pattern6160 = Pattern(Integral((x_*WC('f', S(1)))**m_*(d_ + x_**S(2)*WC('e', S(1)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*asinh(x_*WC('c', S(1)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons1778, cons128) rule6160 = ReplacementRule(pattern6160, With6160) def With6161(p, m, f, b, d, a, c, x, e): u = IntHide((f*x)**m*(d + e*x**S(2))**p, x) rubi.append(6161) return -Dist(b*c, Int(SimplifyIntegrand(u/(sqrt(c*x + S(-1))*sqrt(c*x + S(1))), x), x), x) + Dist(a + b*acosh(c*x), u, x) pattern6161 = Pattern(Integral((x_*WC('f', S(1)))**m_*(d_ + x_**S(2)*WC('e', S(1)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons1737, cons128) rule6161 = ReplacementRule(pattern6161, With6161) def With6162(p, m, b, d, a, c, x, e): u = IntHide(x**m*(c**S(2)*x**S(2) + S(1))**p, x) rubi.append(6162) return Dist(d**p*(a + b*asinh(c*x)), u, x) - Dist(b*c*d**p, Int(SimplifyIntegrand(u/sqrt(c**S(2)*x**S(2) + S(1)), x), x), x) pattern6162 = Pattern(Integral(x_**m_*(d_ + x_**S(2)*WC('e', S(1)))**p_*(WC('a', S(0)) + WC('b', S(1))*asinh(x_*WC('c', S(1)))), x_), cons2, cons3, cons7, cons27, cons48, cons1778, cons347, cons1747, cons486, cons268) rule6162 = ReplacementRule(pattern6162, With6162) def With6163(p, d2, m, b, e2, a, c, d1, e1, x): u = IntHide(x**m*(c*x + S(-1))**p*(c*x + S(1))**p, x) rubi.append(6163) return Dist((-d1*d2)**p*(a + b*acosh(c*x)), u, x) - Dist(b*c*(-d1*d2)**p, Int(SimplifyIntegrand(u/(sqrt(c*x + S(-1))*sqrt(c*x + S(1))), x), x), x) pattern6163 = Pattern(Integral(x_**m_*(d1_ + x_*WC('e1', S(1)))**p_*(d2_ + x_*WC('e2', S(1)))**p_*(WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1)))), x_), cons2, cons3, cons7, cons731, cons652, cons732, cons654, cons1892, cons1893, cons347, cons1747, cons486, cons1894, cons1895) rule6163 = ReplacementRule(pattern6163, With6163) def With6164(p, m, b, d, a, c, x, e): u = IntHide(x**m*(c**S(2)*x**S(2) + S(1))**p, x) rubi.append(6164) return -Dist(b*c*d**(p + S(-1)/2)*sqrt(d + e*x**S(2))/sqrt(c**S(2)*x**S(2) + S(1)), Int(SimplifyIntegrand(u/sqrt(c**S(2)*x**S(2) + S(1)), x), x), x) + Dist(a + b*asinh(c*x), Int(x**m*(d + e*x**S(2))**p, x), x) pattern6164 = Pattern(Integral(x_**m_*(d_ + x_**S(2)*WC('e', S(1)))**p_*(WC('a', S(0)) + WC('b', S(1))*asinh(x_*WC('c', S(1)))), x_), cons2, cons3, cons7, cons27, cons48, cons1778, cons961, cons1747) rule6164 = ReplacementRule(pattern6164, With6164) def With6165(p, d2, m, b, e2, a, c, d1, e1, x): u = IntHide(x**m*(c*x + S(-1))**p*(c*x + S(1))**p, x) rubi.append(6165) return -Dist(b*c*(-d1*d2)**(p + S(-1)/2)*sqrt(d1 + e1*x)*sqrt(d2 + e2*x)/(sqrt(c*x + S(-1))*sqrt(c*x + S(1))), Int(SimplifyIntegrand(u/(sqrt(c*x + S(-1))*sqrt(c*x + S(1))), x), x), x) + Dist(a + b*acosh(c*x), Int(x**m*(d1 + e1*x)**p*(d2 + e2*x)**p, x), x) pattern6165 = Pattern(Integral(x_**m_*(d1_ + x_*WC('e1', S(1)))**p_*(d2_ + x_*WC('e2', S(1)))**p_*(WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1)))), x_), cons2, cons3, cons7, cons731, cons652, cons732, cons654, cons1892, cons1893, cons961, cons1747) rule6165 = ReplacementRule(pattern6165, With6165) pattern6166 = Pattern(Integral((x_*WC('f', S(1)))**m_*(d_ + x_**S(2)*WC('e', S(1)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons1737, cons162, cons88, cons163, cons94, cons38) def replacement6166(p, m, f, b, d, a, n, c, x, e): rubi.append(6166) return -Dist(S(2)*e*p/(f**S(2)*(m + S(1))), Int((f*x)**(m + S(2))*(a + b*acosh(c*x))**n*(d + e*x**S(2))**(p + S(-1)), x), x) - Dist(b*c*n*(-d)**p/(f*(m + S(1))), Int((f*x)**(m + S(1))*(a + b*acosh(c*x))**(n + S(-1))*(c*x + S(-1))**(p + S(-1)/2)*(c*x + S(1))**(p + S(-1)/2), x), x) + Simp((f*x)**(m + S(1))*(a + b*acosh(c*x))**n*(d + e*x**S(2))**p/(f*(m + S(1))), x) rule6166 = ReplacementRule(pattern6166, replacement6166) pattern6167 = Pattern(Integral((x_*WC('f', S(1)))**m_*sqrt(d_ + x_**S(2)*WC('e', S(1)))*(WC('a', S(0)) + WC('b', S(1))*asinh(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons1778, cons93, cons88, cons94) def replacement6167(m, f, b, d, a, n, c, x, e): rubi.append(6167) return -Dist(c**S(2)*sqrt(d + e*x**S(2))/(f**S(2)*(m + S(1))*sqrt(c**S(2)*x**S(2) + S(1))), Int((f*x)**(m + S(2))*(a + b*asinh(c*x))**n/sqrt(c**S(2)*x**S(2) + S(1)), x), x) - Dist(b*c*n*sqrt(d + e*x**S(2))/(f*(m + S(1))*sqrt(c**S(2)*x**S(2) + S(1))), Int((f*x)**(m + S(1))*(a + b*asinh(c*x))**(n + S(-1)), x), x) + Simp((f*x)**(m + S(1))*(a + b*asinh(c*x))**n*sqrt(d + e*x**S(2))/(f*(m + S(1))), x) rule6167 = ReplacementRule(pattern6167, replacement6167) pattern6168 = Pattern(Integral((x_*WC('f', S(1)))**m_*sqrt(d1_ + x_*WC('e1', S(1)))*sqrt(d2_ + x_*WC('e2', S(1)))*(WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons731, cons652, cons732, cons654, cons125, cons1892, cons1893, cons93, cons88, cons94) def replacement6168(d2, m, f, b, e2, a, n, c, d1, e1, x): rubi.append(6168) return -Dist(c**S(2)*sqrt(d1 + e1*x)*sqrt(d2 + e2*x)/(f**S(2)*(m + S(1))*sqrt(c*x + S(-1))*sqrt(c*x + S(1))), Int((f*x)**(m + S(2))*(a + b*acosh(c*x))**n/(sqrt(c*x + S(-1))*sqrt(c*x + S(1))), x), x) - Dist(b*c*n*sqrt(d1 + e1*x)*sqrt(d2 + e2*x)/(f*(m + S(1))*sqrt(c*x + S(-1))*sqrt(c*x + S(1))), Int((f*x)**(m + S(1))*(a + b*acosh(c*x))**(n + S(-1)), x), x) + Simp((f*x)**(m + S(1))*(a + b*acosh(c*x))**n*sqrt(d1 + e1*x)*sqrt(d2 + e2*x)/(f*(m + S(1))), x) rule6168 = ReplacementRule(pattern6168, replacement6168) pattern6169 = Pattern(Integral((x_*WC('f', S(1)))**m_*(d_ + x_**S(2)*WC('e', S(1)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*asinh(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons1778, cons162, cons88, cons163, cons94) def replacement6169(p, m, f, b, d, a, n, c, x, e): rubi.append(6169) return -Dist(S(2)*e*p/(f**S(2)*(m + S(1))), Int((f*x)**(m + S(2))*(a + b*asinh(c*x))**n*(d + e*x**S(2))**(p + S(-1)), x), x) - Dist(b*c*d**IntPart(p)*n*(d + e*x**S(2))**FracPart(p)*(c**S(2)*x**S(2) + S(1))**(-FracPart(p))/(f*(m + S(1))), Int((f*x)**(m + S(1))*(a + b*asinh(c*x))**(n + S(-1))*(c**S(2)*x**S(2) + S(1))**(p + S(-1)/2), x), x) + Simp((f*x)**(m + S(1))*(a + b*asinh(c*x))**n*(d + e*x**S(2))**p/(f*(m + S(1))), x) rule6169 = ReplacementRule(pattern6169, replacement6169) pattern6170 = Pattern(Integral((x_*WC('f', S(1)))**m_*(d1_ + x_*WC('e1', S(1)))**p_*(d2_ + x_*WC('e2', S(1)))**p_*(WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons731, cons652, cons732, cons654, cons125, cons1892, cons1893, cons162, cons88, cons163, cons94, cons347) def replacement6170(p, d2, m, f, b, e2, a, n, c, d1, e1, x): rubi.append(6170) return -Dist(S(2)*e1*e2*p/(f**S(2)*(m + S(1))), Int((f*x)**(m + S(2))*(a + b*acosh(c*x))**n*(d1 + e1*x)**(p + S(-1))*(d2 + e2*x)**(p + S(-1)), x), x) - Dist(b*c*n*(-d1*d2)**(p + S(-1)/2)*sqrt(d1 + e1*x)*sqrt(d2 + e2*x)/(f*(m + S(1))*sqrt(c*x + S(-1))*sqrt(c*x + S(1))), Int((f*x)**(m + S(1))*(a + b*acosh(c*x))**(n + S(-1))*(c**S(2)*x**S(2) + S(-1))**(p + S(-1)/2), x), x) + Simp((f*x)**(m + S(1))*(a + b*acosh(c*x))**n*(d1 + e1*x)**p*(d2 + e2*x)**p/(f*(m + S(1))), x) rule6170 = ReplacementRule(pattern6170, replacement6170) pattern6171 = Pattern(Integral((x_*WC('f', S(1)))**m_*(d_ + x_**S(2)*WC('e', S(1)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons1737, cons338, cons88, cons163, cons272, cons38, cons1748) def replacement6171(p, m, f, b, d, a, n, c, x, e): rubi.append(6171) return Dist(S(2)*d*p/(m + S(2)*p + S(1)), Int((f*x)**m*(a + b*acosh(c*x))**n*(d + e*x**S(2))**(p + S(-1)), x), x) - Dist(b*c*n*(-d)**p/(f*(m + S(2)*p + S(1))), Int((f*x)**(m + S(1))*(a + b*acosh(c*x))**(n + S(-1))*(c*x + S(-1))**(p + S(-1)/2)*(c*x + S(1))**(p + S(-1)/2), x), x) + Simp((f*x)**(m + S(1))*(a + b*acosh(c*x))**n*(d + e*x**S(2))**p/(f*(m + S(2)*p + S(1))), x) rule6171 = ReplacementRule(pattern6171, replacement6171) pattern6172 = Pattern(Integral((x_*WC('f', S(1)))**m_*sqrt(d_ + x_**S(2)*WC('e', S(1)))*(WC('a', S(0)) + WC('b', S(1))*asinh(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons1778, cons87, cons88, cons272, cons1748) def replacement6172(m, f, b, d, a, n, c, x, e): rubi.append(6172) return Dist(sqrt(d + e*x**S(2))/((m + S(2))*sqrt(c**S(2)*x**S(2) + S(1))), Int((f*x)**m*(a + b*asinh(c*x))**n/sqrt(c**S(2)*x**S(2) + S(1)), x), x) - Dist(b*c*n*sqrt(d + e*x**S(2))/(f*(m + S(2))*sqrt(c**S(2)*x**S(2) + S(1))), Int((f*x)**(m + S(1))*(a + b*asinh(c*x))**(n + S(-1)), x), x) + Simp((f*x)**(m + S(1))*(a + b*asinh(c*x))**n*sqrt(d + e*x**S(2))/(f*(m + S(2))), x) rule6172 = ReplacementRule(pattern6172, replacement6172) pattern6173 = Pattern(Integral((x_*WC('f', S(1)))**m_*sqrt(d1_ + x_*WC('e1', S(1)))*sqrt(d2_ + x_*WC('e2', S(1)))*(WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons731, cons652, cons732, cons654, cons125, cons21, cons1892, cons1893, cons87, cons88, cons272, cons1748) def replacement6173(d2, m, f, b, e2, a, n, c, d1, e1, x): rubi.append(6173) return -Dist(sqrt(d1 + e1*x)*sqrt(d2 + e2*x)/((m + S(2))*sqrt(c*x + S(-1))*sqrt(c*x + S(1))), Int((f*x)**m*(a + b*acosh(c*x))**n/(sqrt(c*x + S(-1))*sqrt(c*x + S(1))), x), x) - Dist(b*c*n*sqrt(d1 + e1*x)*sqrt(d2 + e2*x)/(f*(m + S(2))*sqrt(c*x + S(-1))*sqrt(c*x + S(1))), Int((f*x)**(m + S(1))*(a + b*acosh(c*x))**(n + S(-1)), x), x) + Simp((f*x)**(m + S(1))*(a + b*acosh(c*x))**n*sqrt(d1 + e1*x)*sqrt(d2 + e2*x)/(f*(m + S(2))), x) rule6173 = ReplacementRule(pattern6173, replacement6173) pattern6174 = Pattern(Integral((x_*WC('f', S(1)))**m_*(d_ + x_**S(2)*WC('e', S(1)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*asinh(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons1778, cons338, cons88, cons163, cons272, cons1748) def replacement6174(p, m, f, b, d, a, n, c, x, e): rubi.append(6174) return Dist(S(2)*d*p/(m + S(2)*p + S(1)), Int((f*x)**m*(a + b*asinh(c*x))**n*(d + e*x**S(2))**(p + S(-1)), x), x) - Dist(b*c*d**IntPart(p)*n*(d + e*x**S(2))**FracPart(p)*(c**S(2)*x**S(2) + S(1))**(-FracPart(p))/(f*(m + S(2)*p + S(1))), Int((f*x)**(m + S(1))*(a + b*asinh(c*x))**(n + S(-1))*(c**S(2)*x**S(2) + S(1))**(p + S(-1)/2), x), x) + Simp((f*x)**(m + S(1))*(a + b*asinh(c*x))**n*(d + e*x**S(2))**p/(f*(m + S(2)*p + S(1))), x) rule6174 = ReplacementRule(pattern6174, replacement6174) pattern6175 = Pattern(Integral((x_*WC('f', S(1)))**m_*(d1_ + x_*WC('e1', S(1)))**p_*(d2_ + x_*WC('e2', S(1)))**p_*(WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons731, cons652, cons732, cons654, cons125, cons21, cons1892, cons1893, cons338, cons88, cons163, cons272, cons347, cons1748) def replacement6175(p, d2, m, f, b, e2, a, n, c, d1, e1, x): rubi.append(6175) return Dist(S(2)*d1*d2*p/(m + S(2)*p + S(1)), Int((f*x)**m*(a + b*acosh(c*x))**n*(d1 + e1*x)**(p + S(-1))*(d2 + e2*x)**(p + S(-1)), x), x) - Dist(b*c*n*(-d1*d2)**(p + S(-1)/2)*sqrt(d1 + e1*x)*sqrt(d2 + e2*x)/(f*sqrt(c*x + S(-1))*sqrt(c*x + S(1))*(m + S(2)*p + S(1))), Int((f*x)**(m + S(1))*(a + b*acosh(c*x))**(n + S(-1))*(c**S(2)*x**S(2) + S(-1))**(p + S(-1)/2), x), x) + Simp((f*x)**(m + S(1))*(a + b*acosh(c*x))**n*(d1 + e1*x)**p*(d2 + e2*x)**p/(f*(m + S(2)*p + S(1))), x) rule6175 = ReplacementRule(pattern6175, replacement6175) pattern6176 = Pattern(Integral((x_*WC('f', S(1)))**m_*(d_ + x_**S(2)*WC('e', S(1)))**p_*(WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons5, cons1737, cons93, cons88, cons94, cons17, cons38) def replacement6176(p, m, f, b, d, a, n, c, x, e): rubi.append(6176) return Dist(c**S(2)*(m + S(2)*p + S(3))/(f**S(2)*(m + S(1))), Int((f*x)**(m + S(2))*(a + b*acosh(c*x))**n*(d + e*x**S(2))**p, x), x) + Dist(b*c*n*(-d)**p/(f*(m + S(1))), Int((f*x)**(m + S(1))*(a + b*acosh(c*x))**(n + S(-1))*(c*x + S(-1))**(p + S(1)/2)*(c*x + S(1))**(p + S(1)/2), x), x) + Simp((f*x)**(m + S(1))*(a + b*acosh(c*x))**n*(d + e*x**S(2))**(p + S(1))/(d*f*(m + S(1))), x) rule6176 = ReplacementRule(pattern6176, replacement6176) pattern6177 = Pattern(Integral((x_*WC('f', S(1)))**m_*(d_ + x_**S(2)*WC('e', S(1)))**p_*(WC('a', S(0)) + WC('b', S(1))*asinh(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons5, cons1778, cons93, cons88, cons94, cons17) def replacement6177(p, m, f, b, d, a, n, c, x, e): rubi.append(6177) return -Dist(c**S(2)*(m + S(2)*p + S(3))/(f**S(2)*(m + S(1))), Int((f*x)**(m + S(2))*(a + b*asinh(c*x))**n*(d + e*x**S(2))**p, x), x) - Dist(b*c*d**IntPart(p)*n*(d + e*x**S(2))**FracPart(p)*(c**S(2)*x**S(2) + S(1))**(-FracPart(p))/(f*(m + S(1))), Int((f*x)**(m + S(1))*(a + b*asinh(c*x))**(n + S(-1))*(c**S(2)*x**S(2) + S(1))**(p + S(1)/2), x), x) + Simp((f*x)**(m + S(1))*(a + b*asinh(c*x))**n*(d + e*x**S(2))**(p + S(1))/(d*f*(m + S(1))), x) rule6177 = ReplacementRule(pattern6177, replacement6177) pattern6178 = Pattern(Integral((x_*WC('f', S(1)))**m_*(d1_ + x_*WC('e1', S(1)))**p_*(d2_ + x_*WC('e2', S(1)))**p_*(WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons731, cons652, cons732, cons654, cons125, cons5, cons1892, cons1893, cons93, cons88, cons94, cons17, cons667) def replacement6178(p, d2, m, f, b, e2, a, n, c, d1, e1, x): rubi.append(6178) return Dist(c**S(2)*(m + S(2)*p + S(3))/(f**S(2)*(m + S(1))), Int((f*x)**(m + S(2))*(a + b*acosh(c*x))**n*(d1 + e1*x)**p*(d2 + e2*x)**p, x), x) + Dist(b*c*n*(-d1*d2)**IntPart(p)*(d1 + e1*x)**FracPart(p)*(d2 + e2*x)**FracPart(p)*(c*x + S(-1))**(-FracPart(p))*(c*x + S(1))**(-FracPart(p))/(f*(m + S(1))), Int((f*x)**(m + S(1))*(a + b*acosh(c*x))**(n + S(-1))*(c**S(2)*x**S(2) + S(-1))**(p + S(1)/2), x), x) + Simp((f*x)**(m + S(1))*(a + b*acosh(c*x))**n*(d1 + e1*x)**(p + S(1))*(d2 + e2*x)**(p + S(1))/(d1*d2*f*(m + S(1))), x) rule6178 = ReplacementRule(pattern6178, replacement6178) pattern6179 = Pattern(Integral((x_*WC('f', S(1)))**m_*(d1_ + x_*WC('e1', S(1)))**p_*(d2_ + x_*WC('e2', S(1)))**p_*(WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons731, cons652, cons732, cons654, cons125, cons5, cons1892, cons1893, cons93, cons88, cons94, cons17) def replacement6179(p, d2, m, f, b, e2, a, n, c, d1, e1, x): rubi.append(6179) return Dist(c**S(2)*(m + S(2)*p + S(3))/(f**S(2)*(m + S(1))), Int((f*x)**(m + S(2))*(a + b*acosh(c*x))**n*(d1 + e1*x)**p*(d2 + e2*x)**p, x), x) + Dist(b*c*n*(-d1*d2)**IntPart(p)*(d1 + e1*x)**FracPart(p)*(d2 + e2*x)**FracPart(p)*(c*x + S(-1))**(-FracPart(p))*(c*x + S(1))**(-FracPart(p))/(f*(m + S(1))), Int((f*x)**(m + S(1))*(a + b*acosh(c*x))**(n + S(-1))*(c*x + S(-1))**(p + S(1)/2)*(c*x + S(1))**(p + S(1)/2), x), x) + Simp((f*x)**(m + S(1))*(a + b*acosh(c*x))**n*(d1 + e1*x)**(p + S(1))*(d2 + e2*x)**(p + S(1))/(d1*d2*f*(m + S(1))), x) rule6179 = ReplacementRule(pattern6179, replacement6179) pattern6180 = Pattern(Integral((x_*WC('f', S(1)))**m_*(d_ + x_**S(2)*WC('e', S(1)))**p_*(WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons1737, cons93, cons88, cons137, cons166, cons38) def replacement6180(p, m, f, b, d, a, n, c, x, e): rubi.append(6180) return -Dist(f**S(2)*(m + S(-1))/(S(2)*e*(p + S(1))), Int((f*x)**(m + S(-2))*(a + b*acosh(c*x))**n*(d + e*x**S(2))**(p + S(1)), x), x) - Dist(b*f*n*(-d)**p/(S(2)*c*(p + S(1))), Int((f*x)**(m + S(-1))*(a + b*acosh(c*x))**(n + S(-1))*(c*x + S(-1))**(p + S(1)/2)*(c*x + S(1))**(p + S(1)/2), x), x) + Simp(f*(f*x)**(m + S(-1))*(a + b*acosh(c*x))**n*(d + e*x**S(2))**(p + S(1))/(S(2)*e*(p + S(1))), x) rule6180 = ReplacementRule(pattern6180, replacement6180) pattern6181 = Pattern(Integral((x_*WC('f', S(1)))**m_*(d_ + x_**S(2)*WC('e', S(1)))**p_*(WC('a', S(0)) + WC('b', S(1))*asinh(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons1778, cons162, cons88, cons137, cons166) def replacement6181(p, m, f, b, d, a, n, c, x, e): rubi.append(6181) return -Dist(f**S(2)*(m + S(-1))/(S(2)*e*(p + S(1))), Int((f*x)**(m + S(-2))*(a + b*asinh(c*x))**n*(d + e*x**S(2))**(p + S(1)), x), x) - Dist(b*d**IntPart(p)*f*n*(d + e*x**S(2))**FracPart(p)*(c**S(2)*x**S(2) + S(1))**(-FracPart(p))/(S(2)*c*(p + S(1))), Int((f*x)**(m + S(-1))*(a + b*asinh(c*x))**(n + S(-1))*(c**S(2)*x**S(2) + S(1))**(p + S(1)/2), x), x) + Simp(f*(f*x)**(m + S(-1))*(a + b*asinh(c*x))**n*(d + e*x**S(2))**(p + S(1))/(S(2)*e*(p + S(1))), x) rule6181 = ReplacementRule(pattern6181, replacement6181) pattern6182 = Pattern(Integral((x_*WC('f', S(1)))**m_*(d1_ + x_*WC('e1', S(1)))**p_*(d2_ + x_*WC('e2', S(1)))**p_*(WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons731, cons652, cons732, cons654, cons125, cons1892, cons1893, cons162, cons88, cons137, cons166, cons667) def replacement6182(p, d2, m, f, b, e2, a, n, c, d1, e1, x): rubi.append(6182) return -Dist(f**S(2)*(m + S(-1))/(S(2)*e1*e2*(p + S(1))), Int((f*x)**(m + S(-2))*(a + b*acosh(c*x))**n*(d1 + e1*x)**(p + S(1))*(d2 + e2*x)**(p + S(1)), x), x) - Dist(b*f*n*(-d1*d2)**IntPart(p)*(d1 + e1*x)**FracPart(p)*(d2 + e2*x)**FracPart(p)*(c*x + S(-1))**(-FracPart(p))*(c*x + S(1))**(-FracPart(p))/(S(2)*c*(p + S(1))), Int((f*x)**(m + S(-1))*(a + b*acosh(c*x))**(n + S(-1))*(c**S(2)*x**S(2) + S(-1))**(p + S(1)/2), x), x) + Simp(f*(f*x)**(m + S(-1))*(a + b*acosh(c*x))**n*(d1 + e1*x)**(p + S(1))*(d2 + e2*x)**(p + S(1))/(S(2)*e1*e2*(p + S(1))), x) rule6182 = ReplacementRule(pattern6182, replacement6182) pattern6183 = Pattern(Integral((x_*WC('f', S(1)))**m_*(d1_ + x_*WC('e1', S(1)))**p_*(d2_ + x_*WC('e2', S(1)))**p_*(WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons731, cons652, cons732, cons654, cons125, cons1892, cons1893, cons162, cons88, cons137, cons147, cons166) def replacement6183(p, d2, m, f, b, e2, a, n, c, d1, e1, x): rubi.append(6183) return -Dist(f**S(2)*(m + S(-1))/(S(2)*e1*e2*(p + S(1))), Int((f*x)**(m + S(-2))*(a + b*acosh(c*x))**n*(d1 + e1*x)**(p + S(1))*(d2 + e2*x)**(p + S(1)), x), x) - Dist(b*f*n*(-d1*d2)**IntPart(p)*(d1 + e1*x)**FracPart(p)*(d2 + e2*x)**FracPart(p)*(c*x + S(-1))**(-FracPart(p))*(c*x + S(1))**(-FracPart(p))/(S(2)*c*(p + S(1))), Int((f*x)**(m + S(-1))*(a + b*acosh(c*x))**(n + S(-1))*(c*x + S(-1))**(p + S(1)/2)*(c*x + S(1))**(p + S(1)/2), x), x) + Simp(f*(f*x)**(m + S(-1))*(a + b*acosh(c*x))**n*(d1 + e1*x)**(p + S(1))*(d2 + e2*x)**(p + S(1))/(S(2)*e1*e2*(p + S(1))), x) rule6183 = ReplacementRule(pattern6183, replacement6183) pattern6184 = Pattern(Integral((x_*WC('f', S(1)))**m_*(d_ + x_**S(2)*WC('e', S(1)))**p_*(WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons1737, cons338, cons88, cons137, cons274, cons38) def replacement6184(p, m, f, b, d, a, n, c, x, e): rubi.append(6184) return Dist((m + S(2)*p + S(3))/(S(2)*d*(p + S(1))), Int((f*x)**m*(a + b*acosh(c*x))**n*(d + e*x**S(2))**(p + S(1)), x), x) - Dist(b*c*n*(-d)**p/(S(2)*f*(p + S(1))), Int((f*x)**(m + S(1))*(a + b*acosh(c*x))**(n + S(-1))*(c*x + S(-1))**(p + S(1)/2)*(c*x + S(1))**(p + S(1)/2), x), x) - Simp((f*x)**(m + S(1))*(a + b*acosh(c*x))**n*(d + e*x**S(2))**(p + S(1))/(S(2)*d*f*(p + S(1))), x) rule6184 = ReplacementRule(pattern6184, replacement6184) pattern6185 = Pattern(Integral((x_*WC('f', S(1)))**m_*(d_ + x_**S(2)*WC('e', S(1)))**p_*(WC('a', S(0)) + WC('b', S(1))*asinh(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons1778, cons338, cons88, cons137, cons274, cons1749) def replacement6185(p, m, f, b, d, a, n, c, x, e): rubi.append(6185) return Dist((m + S(2)*p + S(3))/(S(2)*d*(p + S(1))), Int((f*x)**m*(a + b*asinh(c*x))**n*(d + e*x**S(2))**(p + S(1)), x), x) + Dist(b*c*d**IntPart(p)*n*(d + e*x**S(2))**FracPart(p)*(c**S(2)*x**S(2) + S(1))**(-FracPart(p))/(S(2)*f*(p + S(1))), Int((f*x)**(m + S(1))*(a + b*asinh(c*x))**(n + S(-1))*(c**S(2)*x**S(2) + S(1))**(p + S(1)/2), x), x) - Simp((f*x)**(m + S(1))*(a + b*asinh(c*x))**n*(d + e*x**S(2))**(p + S(1))/(S(2)*d*f*(p + S(1))), x) rule6185 = ReplacementRule(pattern6185, replacement6185) pattern6186 = Pattern(Integral((x_*WC('f', S(1)))**m_*(d1_ + x_*WC('e1', S(1)))**p_*(d2_ + x_*WC('e2', S(1)))**p_*(WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons731, cons652, cons732, cons654, cons125, cons21, cons1892, cons1893, cons338, cons88, cons137, cons274, cons1750, cons667) def replacement6186(p, d2, m, f, b, e2, a, n, c, d1, e1, x): rubi.append(6186) return Dist((m + S(2)*p + S(3))/(S(2)*d1*d2*(p + S(1))), Int((f*x)**m*(a + b*acosh(c*x))**n*(d1 + e1*x)**(p + S(1))*(d2 + e2*x)**(p + S(1)), x), x) - Dist(b*c*n*(-d1*d2)**IntPart(p)*(d1 + e1*x)**FracPart(p)*(d2 + e2*x)**FracPart(p)*(c*x + S(-1))**(-FracPart(p))*(c*x + S(1))**(-FracPart(p))/(S(2)*f*(p + S(1))), Int((f*x)**(m + S(1))*(a + b*acosh(c*x))**(n + S(-1))*(c**S(2)*x**S(2) + S(-1))**(p + S(1)/2), x), x) - Simp((f*x)**(m + S(1))*(a + b*acosh(c*x))**n*(d1 + e1*x)**(p + S(1))*(d2 + e2*x)**(p + S(1))/(S(2)*d1*d2*f*(p + S(1))), x) rule6186 = ReplacementRule(pattern6186, replacement6186) pattern6187 = Pattern(Integral((x_*WC('f', S(1)))**m_*(d1_ + x_*WC('e1', S(1)))**p_*(d2_ + x_*WC('e2', S(1)))**p_*(WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons731, cons652, cons732, cons654, cons125, cons21, cons1892, cons1893, cons338, cons88, cons137, cons274, cons1749) def replacement6187(p, d2, m, f, b, e2, a, n, c, d1, e1, x): rubi.append(6187) return Dist((m + S(2)*p + S(3))/(S(2)*d1*d2*(p + S(1))), Int((f*x)**m*(a + b*acosh(c*x))**n*(d1 + e1*x)**(p + S(1))*(d2 + e2*x)**(p + S(1)), x), x) - Dist(b*c*n*(-d1*d2)**IntPart(p)*(d1 + e1*x)**FracPart(p)*(d2 + e2*x)**FracPart(p)*(c*x + S(-1))**(-FracPart(p))*(c*x + S(1))**(-FracPart(p))/(S(2)*f*(p + S(1))), Int((f*x)**(m + S(1))*(a + b*acosh(c*x))**(n + S(-1))*(c*x + S(-1))**(p + S(1)/2)*(c*x + S(1))**(p + S(1)/2), x), x) - Simp((f*x)**(m + S(1))*(a + b*acosh(c*x))**n*(d1 + e1*x)**(p + S(1))*(d2 + e2*x)**(p + S(1))/(S(2)*d1*d2*f*(p + S(1))), x) rule6187 = ReplacementRule(pattern6187, replacement6187) pattern6188 = Pattern(Integral((x_*WC('f', S(1)))**m_*(WC('a', S(0)) + WC('b', S(1))*asinh(x_*WC('c', S(1))))**WC('n', S(1))/sqrt(d_ + x_**S(2)*WC('e', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons1778, cons93, cons88, cons166, cons17) def replacement6188(m, f, b, d, a, n, c, x, e): rubi.append(6188) return -Dist(f**S(2)*(m + S(-1))/(c**S(2)*m), Int((f*x)**(m + S(-2))*(a + b*asinh(c*x))**n/sqrt(d + e*x**S(2)), x), x) - Dist(b*f*n*sqrt(c**S(2)*x**S(2) + S(1))/(c*m*sqrt(d + e*x**S(2))), Int((f*x)**(m + S(-1))*(a + b*asinh(c*x))**(n + S(-1)), x), x) + Simp(f*(f*x)**(m + S(-1))*(a + b*asinh(c*x))**n*sqrt(d + e*x**S(2))/(e*m), x) rule6188 = ReplacementRule(pattern6188, replacement6188) pattern6189 = Pattern(Integral((x_*WC('f', S(1)))**m_*(WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1))))**WC('n', S(1))/(sqrt(d1_ + x_*WC('e1', S(1)))*sqrt(d2_ + x_*WC('e2', S(1)))), x_), cons2, cons3, cons7, cons731, cons652, cons732, cons654, cons125, cons1892, cons1893, cons93, cons88, cons166, cons17) def replacement6189(d2, m, f, b, e2, a, n, c, d1, e1, x): rubi.append(6189) return Dist(f**S(2)*(m + S(-1))/(c**S(2)*m), Int((f*x)**(m + S(-2))*(a + b*acosh(c*x))**n/(sqrt(d1 + e1*x)*sqrt(d2 + e2*x)), x), x) + Dist(b*f*n*sqrt(d1 + e1*x)*sqrt(d2 + e2*x)/(c*d1*d2*m*sqrt(c*x + S(-1))*sqrt(c*x + S(1))), Int((f*x)**(m + S(-1))*(a + b*acosh(c*x))**(n + S(-1)), x), x) + Simp(f*(f*x)**(m + S(-1))*(a + b*acosh(c*x))**n*sqrt(d1 + e1*x)*sqrt(d2 + e2*x)/(e1*e2*m), x) rule6189 = ReplacementRule(pattern6189, replacement6189) pattern6190 = Pattern(Integral(x_**m_*(WC('a', S(0)) + WC('b', S(1))*asinh(x_*WC('c', S(1))))**WC('n', S(1))/sqrt(d_ + x_**S(2)*WC('e', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons1778, cons268, cons148, cons17) def replacement6190(m, b, d, a, n, c, x, e): rubi.append(6190) return Dist(c**(-m + S(-1))/sqrt(d), Subst(Int((a + b*x)**n*sinh(x)**m, x), x, asinh(c*x)), x) rule6190 = ReplacementRule(pattern6190, replacement6190) pattern6191 = Pattern(Integral(x_**m_*(WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1))))**WC('n', S(1))/(sqrt(d1_ + x_*WC('e1', S(1)))*sqrt(d2_ + x_*WC('e2', S(1)))), x_), cons2, cons3, cons7, cons731, cons652, cons732, cons654, cons1892, cons1893, cons148, cons1894, cons1895, cons17) def replacement6191(d2, m, b, e2, a, n, c, d1, e1, x): rubi.append(6191) return Dist(c**(-m + S(-1))/sqrt(-d1*d2), Subst(Int((a + b*x)**n*cosh(x)**m, x), x, acosh(c*x)), x) rule6191 = ReplacementRule(pattern6191, replacement6191) pattern6192 = Pattern(Integral((x_*WC('f', S(1)))**m_*(WC('a', S(0)) + WC('b', S(1))*asinh(x_*WC('c', S(1))))/sqrt(d_ + x_**S(2)*WC('e', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons1778, cons268, cons18) def replacement6192(m, f, b, d, a, c, x, e): rubi.append(6192) return Simp((f*x)**(m + S(1))*(a + b*asinh(c*x))*Hypergeometric2F1(S(1)/2, m/S(2) + S(1)/2, m/S(2) + S(3)/2, -c**S(2)*x**S(2))/(sqrt(d)*f*(m + S(1))), x) - Simp(b*c*(f*x)**(m + S(2))*HypergeometricPFQ(List(S(1), m/S(2) + S(1), m/S(2) + S(1)), List(m/S(2) + S(3)/2, m/S(2) + S(2)), -c**S(2)*x**S(2))/(sqrt(d)*f**S(2)*(m + S(1))*(m + S(2))), x) rule6192 = ReplacementRule(pattern6192, replacement6192) pattern6193 = Pattern(Integral((x_*WC('f', S(1)))**m_*(WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1))))/(sqrt(d1_ + x_*WC('e1', S(1)))*sqrt(d2_ + x_*WC('e2', S(1)))), x_), cons2, cons3, cons7, cons731, cons652, cons732, cons654, cons125, cons21, cons1892, cons1893, cons1894, cons1895, cons18) def replacement6193(d2, m, f, b, e2, a, c, d1, e1, x): rubi.append(6193) return Simp(b*c*(f*x)**(m + S(2))*HypergeometricPFQ(List(S(1), m/S(2) + S(1), m/S(2) + S(1)), List(m/S(2) + S(3)/2, m/S(2) + S(2)), c**S(2)*x**S(2))/(f**S(2)*sqrt(-d1*d2)*(m + S(1))*(m + S(2))), x) + Simp((f*x)**(m + S(1))*(a + b*acosh(c*x))*sqrt(-c**S(2)*x**S(2) + S(1))*Hypergeometric2F1(S(1)/2, m/S(2) + S(1)/2, m/S(2) + S(3)/2, c**S(2)*x**S(2))/(f*sqrt(d1 + e1*x)*sqrt(d2 + e2*x)*(m + S(1))), x) rule6193 = ReplacementRule(pattern6193, replacement6193) pattern6194 = Pattern(Integral((x_*WC('f', S(1)))**m_*(WC('a', S(0)) + WC('b', S(1))*asinh(x_*WC('c', S(1))))**WC('n', S(1))/sqrt(d_ + x_**S(2)*WC('e', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons1778, cons87, cons88, cons1738, cons1750) def replacement6194(m, f, b, d, a, n, c, x, e): rubi.append(6194) return Dist(sqrt(c**S(2)*x**S(2) + S(1))/sqrt(d + e*x**S(2)), Int((f*x)**m*(a + b*asinh(c*x))**n/sqrt(c**S(2)*x**S(2) + S(1)), x), x) rule6194 = ReplacementRule(pattern6194, replacement6194) pattern6195 = Pattern(Integral((x_*WC('f', S(1)))**m_*(WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1))))**WC('n', S(1))/(sqrt(d1_ + x_*WC('e1', S(1)))*sqrt(d2_ + x_*WC('e2', S(1)))), x_), cons2, cons3, cons7, cons731, cons652, cons732, cons654, cons125, cons21, cons1892, cons1893, cons87, cons88, cons1896, cons1750) def replacement6195(d2, m, f, b, e2, a, n, c, d1, e1, x): rubi.append(6195) return Dist(sqrt(c*x + S(-1))*sqrt(c*x + S(1))/(sqrt(d1 + e1*x)*sqrt(d2 + e2*x)), Int((f*x)**m*(a + b*acosh(c*x))**n/(sqrt(c*x + S(-1))*sqrt(c*x + S(1))), x), x) rule6195 = ReplacementRule(pattern6195, replacement6195) pattern6196 = Pattern(Integral((x_*WC('f', S(1)))**m_*(d_ + x_**S(2)*WC('e', S(1)))**p_*(WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons5, cons1737, cons93, cons88, cons166, cons238, cons38, cons17) def replacement6196(p, m, f, b, d, a, n, c, x, e): rubi.append(6196) return Dist(f**S(2)*(m + S(-1))/(c**S(2)*(m + S(2)*p + S(1))), Int((f*x)**(m + S(-2))*(a + b*acosh(c*x))**n*(d + e*x**S(2))**p, x), x) - Dist(b*f*n*(-d)**p/(c*(m + S(2)*p + S(1))), Int((f*x)**(m + S(-1))*(a + b*acosh(c*x))**(n + S(-1))*(c*x + S(-1))**(p + S(1)/2)*(c*x + S(1))**(p + S(1)/2), x), x) + Simp(f*(f*x)**(m + S(-1))*(a + b*acosh(c*x))**n*(d + e*x**S(2))**(p + S(1))/(e*(m + S(2)*p + S(1))), x) rule6196 = ReplacementRule(pattern6196, replacement6196) pattern6197 = Pattern(Integral((x_*WC('f', S(1)))**m_*(d_ + x_**S(2)*WC('e', S(1)))**p_*(WC('a', S(0)) + WC('b', S(1))*asinh(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons5, cons1778, cons93, cons88, cons166, cons238, cons17) def replacement6197(p, m, f, b, d, a, n, c, x, e): rubi.append(6197) return -Dist(f**S(2)*(m + S(-1))/(c**S(2)*(m + S(2)*p + S(1))), Int((f*x)**(m + S(-2))*(a + b*asinh(c*x))**n*(d + e*x**S(2))**p, x), x) - Dist(b*d**IntPart(p)*f*n*(d + e*x**S(2))**FracPart(p)*(c**S(2)*x**S(2) + S(1))**(-FracPart(p))/(c*(m + S(2)*p + S(1))), Int((f*x)**(m + S(-1))*(a + b*asinh(c*x))**(n + S(-1))*(c**S(2)*x**S(2) + S(1))**(p + S(1)/2), x), x) + Simp(f*(f*x)**(m + S(-1))*(a + b*asinh(c*x))**n*(d + e*x**S(2))**(p + S(1))/(e*(m + S(2)*p + S(1))), x) rule6197 = ReplacementRule(pattern6197, replacement6197) pattern6198 = Pattern(Integral((x_*WC('f', S(1)))**m_*(d1_ + x_*WC('e1', S(1)))**p_*(d2_ + x_*WC('e2', S(1)))**p_*(WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons731, cons652, cons732, cons654, cons125, cons5, cons1892, cons1893, cons93, cons88, cons166, cons238, cons17, cons667) def replacement6198(p, d2, m, f, b, e2, a, n, c, d1, e1, x): rubi.append(6198) return Dist(f**S(2)*(m + S(-1))/(c**S(2)*(m + S(2)*p + S(1))), Int((f*x)**(m + S(-2))*(a + b*acosh(c*x))**n*(d1 + e1*x)**p*(d2 + e2*x)**p, x), x) - Dist(b*f*n*(-d1*d2)**IntPart(p)*(d1 + e1*x)**FracPart(p)*(d2 + e2*x)**FracPart(p)*(c*x + S(-1))**(-FracPart(p))*(c*x + S(1))**(-FracPart(p))/(c*(m + S(2)*p + S(1))), Int((f*x)**(m + S(-1))*(a + b*acosh(c*x))**(n + S(-1))*(c**S(2)*x**S(2) + S(-1))**(p + S(1)/2), x), x) + Simp(f*(f*x)**(m + S(-1))*(a + b*acosh(c*x))**n*(d1 + e1*x)**(p + S(1))*(d2 + e2*x)**(p + S(1))/(e1*e2*(m + S(2)*p + S(1))), x) rule6198 = ReplacementRule(pattern6198, replacement6198) pattern6199 = Pattern(Integral((x_*WC('f', S(1)))**m_*(d1_ + x_*WC('e1', S(1)))**p_*(d2_ + x_*WC('e2', S(1)))**p_*(WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons731, cons652, cons732, cons654, cons125, cons5, cons1892, cons1893, cons93, cons88, cons166, cons238, cons17) def replacement6199(p, d2, m, f, b, e2, a, n, c, d1, e1, x): rubi.append(6199) return Dist(f**S(2)*(m + S(-1))/(c**S(2)*(m + S(2)*p + S(1))), Int((f*x)**(m + S(-2))*(a + b*acosh(c*x))**n*(d1 + e1*x)**p*(d2 + e2*x)**p, x), x) - Dist(b*f*n*(-d1*d2)**IntPart(p)*(d1 + e1*x)**FracPart(p)*(d2 + e2*x)**FracPart(p)*(c*x + S(-1))**(-FracPart(p))*(c*x + S(1))**(-FracPart(p))/(c*(m + S(2)*p + S(1))), Int((f*x)**(m + S(-1))*(a + b*acosh(c*x))**(n + S(-1))*(c*x + S(-1))**(p + S(1)/2)*(c*x + S(1))**(p + S(1)/2), x), x) + Simp(f*(f*x)**(m + S(-1))*(a + b*acosh(c*x))**n*(d1 + e1*x)**(p + S(1))*(d2 + e2*x)**(p + S(1))/(e1*e2*(m + S(2)*p + S(1))), x) rule6199 = ReplacementRule(pattern6199, replacement6199) pattern6200 = Pattern(Integral((x_*WC('f', S(1)))**WC('m', S(1))*(d_ + x_**S(2)*WC('e', S(1)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons5, cons1737, cons87, cons89, cons237, cons38) def replacement6200(p, m, f, b, d, a, c, n, x, e): rubi.append(6200) return Dist(f*m*(-d)**p/(b*c*(n + S(1))), Int((f*x)**(m + S(-1))*(a + b*acosh(c*x))**(n + S(1))*(c*x + S(-1))**(p + S(-1)/2)*(c*x + S(1))**(p + S(-1)/2), x), x) + Simp((f*x)**m*(a + b*acosh(c*x))**(n + S(1))*(d + e*x**S(2))**p*sqrt(c*x + S(-1))*sqrt(c*x + S(1))/(b*c*(n + S(1))), x) rule6200 = ReplacementRule(pattern6200, replacement6200) pattern6201 = Pattern(Integral((x_*WC('f', S(1)))**WC('m', S(1))*(d_ + x_**S(2)*WC('e', S(1)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*asinh(x_*WC('c', S(1))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons5, cons1778, cons87, cons89, cons237) def replacement6201(p, m, f, b, d, a, c, n, x, e): rubi.append(6201) return -Dist(d**IntPart(p)*f*m*(d + e*x**S(2))**FracPart(p)*(c**S(2)*x**S(2) + S(1))**(-FracPart(p))/(b*c*(n + S(1))), Int((f*x)**(m + S(-1))*(a + b*asinh(c*x))**(n + S(1))*(c**S(2)*x**S(2) + S(1))**(p + S(-1)/2), x), x) + Simp((f*x)**m*(a + b*asinh(c*x))**(n + S(1))*(d + e*x**S(2))**p*sqrt(c**S(2)*x**S(2) + S(1))/(b*c*(n + S(1))), x) rule6201 = ReplacementRule(pattern6201, replacement6201) pattern6202 = Pattern(Integral((x_*WC('f', S(1)))**WC('m', S(1))*(d1_ + x_*WC('e1', S(1)))**WC('p', S(1))*(d2_ + x_*WC('e2', S(1)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1))))**n_, x_), cons2, cons3, cons7, cons731, cons652, cons732, cons654, cons125, cons21, cons5, cons1892, cons1893, cons87, cons89, cons237, cons347) def replacement6202(p, d2, m, f, b, e2, a, c, n, d1, e1, x): rubi.append(6202) return Dist(f*m*(-d1*d2)**IntPart(p)*(d1 + e1*x)**FracPart(p)*(d2 + e2*x)**FracPart(p)*(c*x + S(-1))**(-FracPart(p))*(c*x + S(1))**(-FracPart(p))/(b*c*(n + S(1))), Int((f*x)**(m + S(-1))*(a + b*acosh(c*x))**(n + S(1))*(c**S(2)*x**S(2) + S(-1))**(p + S(-1)/2), x), x) + Simp((f*x)**m*(a + b*acosh(c*x))**(n + S(1))*(d1 + e1*x)**p*(d2 + e2*x)**p*sqrt(c*x + S(-1))*sqrt(c*x + S(1))/(b*c*(n + S(1))), x) rule6202 = ReplacementRule(pattern6202, replacement6202) pattern6203 = Pattern(Integral((x_*WC('f', S(1)))**WC('m', S(1))*(d1_ + x_*WC('e1', S(1)))**WC('p', S(1))*(d2_ + x_*WC('e2', S(1)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1))))**n_, x_), cons2, cons3, cons7, cons731, cons652, cons732, cons654, cons125, cons21, cons5, cons1892, cons1893, cons87, cons89, cons237) def replacement6203(p, d2, m, f, b, e2, a, c, n, d1, e1, x): rubi.append(6203) return Dist(f*m*(-d1*d2)**IntPart(p)*(d1 + e1*x)**FracPart(p)*(d2 + e2*x)**FracPart(p)*(c*x + S(-1))**(-FracPart(p))*(c*x + S(1))**(-FracPart(p))/(b*c*(n + S(1))), Int((f*x)**(m + S(-1))*(a + b*acosh(c*x))**(n + S(1))*(c*x + S(-1))**(p + S(-1)/2)*(c*x + S(1))**(p + S(-1)/2), x), x) + Simp((f*x)**m*(a + b*acosh(c*x))**(n + S(1))*(d1 + e1*x)**p*(d2 + e2*x)**p*sqrt(c*x + S(-1))*sqrt(c*x + S(1))/(b*c*(n + S(1))), x) rule6203 = ReplacementRule(pattern6203, replacement6203) pattern6204 = Pattern(Integral((x_*WC('f', S(1)))**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*asinh(x_*WC('c', S(1))))**n_/sqrt(d_ + x_**S(2)*WC('e', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons1778, cons87, cons89, cons268) def replacement6204(m, f, b, d, a, c, n, x, e): rubi.append(6204) return -Dist(f*m/(b*c*sqrt(d)*(n + S(1))), Int((f*x)**(m + S(-1))*(a + b*asinh(c*x))**(n + S(1)), x), x) + Simp((f*x)**m*(a + b*asinh(c*x))**(n + S(1))/(b*c*sqrt(d)*(n + S(1))), x) rule6204 = ReplacementRule(pattern6204, replacement6204) pattern6205 = Pattern(Integral((x_*WC('f', S(1)))**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1))))**n_/(sqrt(d1_ + x_*WC('e1', S(1)))*sqrt(d2_ + x_*WC('e2', S(1)))), x_), cons2, cons3, cons7, cons731, cons652, cons732, cons654, cons125, cons21, cons1892, cons1893, cons87, cons89, cons1894, cons1895) def replacement6205(d2, m, f, b, e2, a, c, n, d1, e1, x): rubi.append(6205) return -Dist(f*m/(b*c*sqrt(-d1*d2)*(n + S(1))), Int((f*x)**(m + S(-1))*(a + b*acosh(c*x))**(n + S(1)), x), x) + Simp((f*x)**m*(a + b*acosh(c*x))**(n + S(1))/(b*c*sqrt(-d1*d2)*(n + S(1))), x) rule6205 = ReplacementRule(pattern6205, replacement6205) pattern6206 = Pattern(Integral((x_*WC('f', S(1)))**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*asinh(x_*WC('c', S(1))))**n_/sqrt(d_ + x_**S(2)*WC('e', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons1778, cons87, cons89, cons1738) def replacement6206(m, f, b, d, a, c, n, x, e): rubi.append(6206) return Dist(sqrt(c**S(2)*x**S(2) + S(1))/sqrt(d + e*x**S(2)), Int((f*x)**m*(a + b*asinh(c*x))**n/sqrt(c**S(2)*x**S(2) + S(1)), x), x) rule6206 = ReplacementRule(pattern6206, replacement6206) pattern6207 = Pattern(Integral((x_*WC('f', S(1)))**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1))))**n_/(sqrt(d1_ + x_*WC('e1', S(1)))*sqrt(d2_ + x_*WC('e2', S(1)))), x_), cons2, cons3, cons7, cons731, cons652, cons732, cons654, cons125, cons21, cons1892, cons1893, cons87, cons89, cons1896) def replacement6207(d2, m, f, b, e2, a, c, n, d1, e1, x): rubi.append(6207) return Dist(sqrt(c*x + S(-1))*sqrt(c*x + S(1))/(sqrt(d1 + e1*x)*sqrt(d2 + e2*x)), Int((f*x)**m*(a + b*acosh(c*x))**n/(sqrt(c*x + S(-1))*sqrt(c*x + S(1))), x), x) rule6207 = ReplacementRule(pattern6207, replacement6207) pattern6208 = Pattern(Integral((x_*WC('f', S(1)))**WC('m', S(1))*(d_ + x_**S(2)*WC('e', S(1)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons1737, cons87, cons89, cons17, cons1751, cons128) def replacement6208(p, m, f, b, d, a, c, n, x, e): rubi.append(6208) return Dist(f*m*(-d)**p/(b*c*(n + S(1))), Int((f*x)**(m + S(-1))*(a + b*acosh(c*x))**(n + S(1))*(c*x + S(-1))**(p + S(-1)/2)*(c*x + S(1))**(p + S(-1)/2), x), x) - Dist(c*(-d)**p*(m + S(2)*p + S(1))/(b*f*(n + S(1))), Int((f*x)**(m + S(1))*(a + b*acosh(c*x))**(n + S(1))*(c*x + S(-1))**(p + S(-1)/2)*(c*x + S(1))**(p + S(-1)/2), x), x) + Simp((f*x)**m*(a + b*acosh(c*x))**(n + S(1))*(d + e*x**S(2))**p*sqrt(c*x + S(-1))*sqrt(c*x + S(1))/(b*c*(n + S(1))), x) rule6208 = ReplacementRule(pattern6208, replacement6208) pattern6209 = Pattern(Integral((x_*WC('f', S(1)))**WC('m', S(1))*(d_ + x_**S(2)*WC('e', S(1)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*asinh(x_*WC('c', S(1))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons1778, cons87, cons89, cons17, cons1751, cons1739) def replacement6209(p, m, f, b, d, a, c, n, x, e): rubi.append(6209) return -Dist(d**IntPart(p)*f*m*(d + e*x**S(2))**FracPart(p)*(c**S(2)*x**S(2) + S(1))**(-FracPart(p))/(b*c*(n + S(1))), Int((f*x)**(m + S(-1))*(a + b*asinh(c*x))**(n + S(1))*(c**S(2)*x**S(2) + S(1))**(p + S(-1)/2), x), x) - Dist(c*d**IntPart(p)*(d + e*x**S(2))**FracPart(p)*(c**S(2)*x**S(2) + S(1))**(-FracPart(p))*(m + S(2)*p + S(1))/(b*f*(n + S(1))), Int((f*x)**(m + S(1))*(a + b*asinh(c*x))**(n + S(1))*(c**S(2)*x**S(2) + S(1))**(p + S(-1)/2), x), x) + Simp((f*x)**m*(a + b*asinh(c*x))**(n + S(1))*(d + e*x**S(2))**p*sqrt(c**S(2)*x**S(2) + S(1))/(b*c*(n + S(1))), x) rule6209 = ReplacementRule(pattern6209, replacement6209) pattern6210 = Pattern(Integral((x_*WC('f', S(1)))**WC('m', S(1))*(d1_ + x_*WC('e1', S(1)))**WC('p', S(1))*(d2_ + x_*WC('e2', S(1)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1))))**n_, x_), cons2, cons3, cons7, cons731, cons652, cons732, cons654, cons125, cons1892, cons1893, cons87, cons89, cons17, cons1751, cons961) def replacement6210(p, d2, m, f, b, e2, a, c, n, d1, e1, x): rubi.append(6210) return Dist(f*m*(-d1*d2)**IntPart(p)*(d1 + e1*x)**FracPart(p)*(d2 + e2*x)**FracPart(p)*(c*x + S(-1))**(-FracPart(p))*(c*x + S(1))**(-FracPart(p))/(b*c*(n + S(1))), Int((f*x)**(m + S(-1))*(a + b*acosh(c*x))**(n + S(1))*(c**S(2)*x**S(2) + S(-1))**(p + S(-1)/2), x), x) - Dist(c*(-d1*d2)**IntPart(p)*(d1 + e1*x)**FracPart(p)*(d2 + e2*x)**FracPart(p)*(c*x + S(-1))**(-FracPart(p))*(c*x + S(1))**(-FracPart(p))*(m + S(2)*p + S(1))/(b*f*(n + S(1))), Int((f*x)**(m + S(1))*(a + b*acosh(c*x))**(n + S(1))*(c**S(2)*x**S(2) + S(-1))**(p + S(-1)/2), x), x) + Simp((f*x)**m*(a + b*acosh(c*x))**(n + S(1))*(d1 + e1*x)**p*(d2 + e2*x)**p*sqrt(c*x + S(-1))*sqrt(c*x + S(1))/(b*c*(n + S(1))), x) rule6210 = ReplacementRule(pattern6210, replacement6210) pattern6211 = Pattern(Integral(x_**WC('m', S(1))*(d_ + x_**S(2)*WC('e', S(1)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*asinh(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons4, cons1778, cons246, cons1752, cons62, cons1740) def replacement6211(p, m, b, d, a, n, c, x, e): rubi.append(6211) return Dist(c**(-m + S(-1))*d**p, Subst(Int((a + b*x)**n*sinh(x)**m*cosh(x)**(S(2)*p + S(1)), x), x, asinh(c*x)), x) rule6211 = ReplacementRule(pattern6211, replacement6211) pattern6212 = Pattern(Integral(x_**WC('m', S(1))*(d_ + x_**S(2)*WC('e', S(1)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons4, cons1737, cons128, cons62) def replacement6212(p, m, b, d, a, n, c, x, e): rubi.append(6212) return Dist(c**(-m + S(-1))*(-d)**p, Subst(Int((a + b*x)**n*sinh(x)**(S(2)*p + S(1))*cosh(x)**m, x), x, acosh(c*x)), x) rule6212 = ReplacementRule(pattern6212, replacement6212) pattern6213 = Pattern(Integral(x_**WC('m', S(1))*(d1_ + x_*WC('e1', S(1)))**WC('p', S(1))*(d2_ + x_*WC('e2', S(1)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons731, cons652, cons732, cons654, cons4, cons1892, cons1893, cons667, cons1752, cons62, cons1897) def replacement6213(p, d2, m, b, e2, a, n, c, d1, e1, x): rubi.append(6213) return Dist(c**(-m + S(-1))*(-d1*d2)**p, Subst(Int((a + b*x)**n*sinh(x)**(S(2)*p + S(1))*cosh(x)**m, x), x, acosh(c*x)), x) rule6213 = ReplacementRule(pattern6213, replacement6213) pattern6214 = Pattern(Integral(x_**WC('m', S(1))*(d_ + x_**S(2)*WC('e', S(1)))**p_*(WC('a', S(0)) + WC('b', S(1))*asinh(x_*WC('c', S(1))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons4, cons1778, cons246, cons1752, cons62, cons1741) def replacement6214(p, m, b, d, a, c, n, x, e): rubi.append(6214) return Dist(d**IntPart(p)*(d + e*x**S(2))**FracPart(p)*(c**S(2)*x**S(2) + S(1))**(-FracPart(p)), Int(x**m*(a + b*asinh(c*x))**n*(c**S(2)*x**S(2) + S(1))**p, x), x) rule6214 = ReplacementRule(pattern6214, replacement6214) pattern6215 = Pattern(Integral(x_**WC('m', S(1))*(d1_ + x_*WC('e1', S(1)))**WC('p', S(1))*(d2_ + x_*WC('e2', S(1)))**p_*(WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons731, cons652, cons732, cons654, cons4, cons1892, cons1893, cons246, cons1752, cons62, cons1901) def replacement6215(p, d2, m, b, e2, a, n, c, d1, e1, x): rubi.append(6215) return Dist((-d1*d2)**IntPart(p)*(d1 + e1*x)**FracPart(p)*(d2 + e2*x)**FracPart(p)*(c*x + S(-1))**(-FracPart(p))*(c*x + S(1))**(-FracPart(p)), Int(x**m*(a + b*acosh(c*x))**n*(c*x + S(-1))**p*(c*x + S(1))**p, x), x) rule6215 = ReplacementRule(pattern6215, replacement6215) pattern6216 = Pattern(Integral((x_*WC('f', S(1)))**m_*(d_ + x_**S(2)*WC('e', S(1)))**p_*(WC('a', S(0)) + WC('b', S(1))*asinh(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons4, cons1778, cons268, cons961, cons1753, cons17, cons1754) def replacement6216(p, m, f, b, d, a, n, c, x, e): rubi.append(6216) return Int(ExpandIntegrand((a + b*asinh(c*x))**n/sqrt(d + e*x**S(2)), (f*x)**m*(d + e*x**S(2))**(p + S(1)/2), x), x) rule6216 = ReplacementRule(pattern6216, replacement6216) pattern6217 = Pattern(Integral((x_*WC('f', S(1)))**m_*(d1_ + x_*WC('e1', S(1)))**p_*(d2_ + x_*WC('e2', S(1)))**p_*(WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons731, cons652, cons732, cons654, cons125, cons21, cons4, cons1892, cons1893, cons1894, cons1895, cons961, cons1753, cons17, cons1754) def replacement6217(p, d2, m, f, b, e2, a, n, c, d1, e1, x): rubi.append(6217) return Int(ExpandIntegrand((a + b*acosh(c*x))**n/(sqrt(d1 + e1*x)*sqrt(d2 + e2*x)), (f*x)**m*(d1 + e1*x)**(p + S(1)/2)*(d2 + e2*x)**(p + S(1)/2), x), x) rule6217 = ReplacementRule(pattern6217, replacement6217) pattern6218 = Pattern(Integral((x_*WC('f', S(1)))**WC('m', S(1))*(d_ + x_**S(2)*WC('e', S(1)))*(WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons1742, cons66, cons1902) def replacement6218(m, f, b, d, a, c, x, e): rubi.append(6218) return -Dist(b*c/(f*(m + S(1))*(m + S(3))), Int((f*x)**(m + S(1))*(d*(m + S(3)) + e*x**S(2)*(m + S(1)))/(sqrt(c*x + S(-1))*sqrt(c*x + S(1))), x), x) + Simp(d*(f*x)**(m + S(1))*(a + b*acosh(c*x))/(f*(m + S(1))), x) + Simp(e*(f*x)**(m + S(3))*(a + b*acosh(c*x))/(f**S(3)*(m + S(3))), x) rule6218 = ReplacementRule(pattern6218, replacement6218) pattern6219 = Pattern(Integral(x_*(d_ + x_**S(2)*WC('e', S(1)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*asinh(x_*WC('c', S(1)))), x_), cons2, cons3, cons7, cons27, cons48, cons5, cons1898, cons54) def replacement6219(p, b, d, a, c, x, e): rubi.append(6219) return -Dist(b*c/(S(2)*e*(p + S(1))), Int((d + e*x**S(2))**(p + S(1))/sqrt(c**S(2)*x**S(2) + S(1)), x), x) + Simp((a + b*asinh(c*x))*(d + e*x**S(2))**(p + S(1))/(S(2)*e*(p + S(1))), x) rule6219 = ReplacementRule(pattern6219, replacement6219) pattern6220 = Pattern(Integral(x_*(d_ + x_**S(2)*WC('e', S(1)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1)))), x_), cons2, cons3, cons7, cons27, cons48, cons5, cons1742, cons54) def replacement6220(p, b, d, a, c, x, e): rubi.append(6220) return -Dist(b*c/(S(2)*e*(p + S(1))), Int((d + e*x**S(2))**(p + S(1))/(sqrt(c*x + S(-1))*sqrt(c*x + S(1))), x), x) + Simp((a + b*acosh(c*x))*(d + e*x**S(2))**(p + S(1))/(S(2)*e*(p + S(1))), x) rule6220 = ReplacementRule(pattern6220, replacement6220) def With6221(p, m, f, b, d, a, c, x, e): u = IntHide((f*x)**m*(d + e*x**S(2))**p, x) rubi.append(6221) return -Dist(b*c, Int(SimplifyIntegrand(u/sqrt(c**S(2)*x**S(2) + S(1)), x), x), x) + Dist(a + b*asinh(c*x), u, x) pattern6221 = Pattern(Integral((x_*WC('f', S(1)))**WC('m', S(1))*(d_ + x_**S(2)*WC('e', S(1)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*asinh(x_*WC('c', S(1)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons1898, cons38, cons1755) rule6221 = ReplacementRule(pattern6221, With6221) def With6222(p, m, f, b, d, a, c, x, e): u = IntHide((f*x)**m*(d + e*x**S(2))**p, x) rubi.append(6222) return -Dist(b*c, Int(SimplifyIntegrand(u/(sqrt(c*x + S(-1))*sqrt(c*x + S(1))), x), x), x) + Dist(a + b*acosh(c*x), u, x) pattern6222 = Pattern(Integral((x_*WC('f', S(1)))**WC('m', S(1))*(d_ + x_**S(2)*WC('e', S(1)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons1742, cons38, cons1755) rule6222 = ReplacementRule(pattern6222, With6222) pattern6223 = Pattern(Integral((x_*WC('f', S(1)))**WC('m', S(1))*(d_ + x_**S(2)*WC('e', S(1)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*asinh(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons1898, cons148, cons38, cons17) def replacement6223(p, m, f, b, d, a, n, c, x, e): rubi.append(6223) return Int(ExpandIntegrand((a + b*asinh(c*x))**n, (f*x)**m*(d + e*x**S(2))**p, x), x) rule6223 = ReplacementRule(pattern6223, replacement6223) pattern6224 = Pattern(Integral((x_*WC('f', S(1)))**WC('m', S(1))*(d_ + x_**S(2)*WC('e', S(1)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons1742, cons148, cons38, cons17) def replacement6224(p, m, f, b, d, a, n, c, x, e): rubi.append(6224) return Int(ExpandIntegrand((a + b*acosh(c*x))**n, (f*x)**m*(d + e*x**S(2))**p, x), x) rule6224 = ReplacementRule(pattern6224, replacement6224) pattern6225 = Pattern(Integral((x_*WC('f', S(1)))**WC('m', S(1))*(d_ + x_**S(2)*WC('e', S(1)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*asinh(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons4, cons5, cons1756) def replacement6225(p, m, f, b, d, a, n, c, x, e): rubi.append(6225) return Int((f*x)**m*(a + b*asinh(c*x))**n*(d + e*x**S(2))**p, x) rule6225 = ReplacementRule(pattern6225, replacement6225) pattern6226 = Pattern(Integral((x_*WC('f', S(1)))**WC('m', S(1))*(d_ + x_**S(2)*WC('e', S(1)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons4, cons5, cons38) def replacement6226(p, m, f, b, d, a, n, c, x, e): rubi.append(6226) return Int((f*x)**m*(a + b*acosh(c*x))**n*(d + e*x**S(2))**p, x) rule6226 = ReplacementRule(pattern6226, replacement6226) pattern6227 = Pattern(Integral((x_*WC('f', S(1)))**WC('m', S(1))*(d1_ + x_*WC('e1', S(1)))**WC('p', S(1))*(d2_ + x_*WC('e2', S(1)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons731, cons652, cons732, cons654, cons125, cons21, cons4, cons5, cons1903) def replacement6227(p, d2, m, f, b, e2, a, n, c, d1, e1, x): rubi.append(6227) return Int((f*x)**m*(a + b*acosh(c*x))**n*(d1 + e1*x)**p*(d2 + e2*x)**p, x) rule6227 = ReplacementRule(pattern6227, replacement6227) pattern6228 = Pattern(Integral((x_*WC('h', S(1)))**WC('m', S(1))*(d_ + x_*WC('e', S(1)))**p_*(f_ + x_*WC('g', S(1)))**p_*(WC('a', S(0)) + WC('b', S(1))*asinh(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons209, cons21, cons4, cons5, cons336, cons1900, cons147) def replacement6228(p, m, g, b, f, d, a, n, c, x, h, e): rubi.append(6228) return Dist((d + e*x)**FracPart(p)*(f + g*x)**FracPart(p)*(d*f + e*g*x**S(2))**(-FracPart(p)), Int((h*x)**m*(a + b*asinh(c*x))**n*(d*f + e*g*x**S(2))**p, x), x) rule6228 = ReplacementRule(pattern6228, replacement6228) pattern6229 = Pattern(Integral((x_*WC('f', S(1)))**WC('m', S(1))*(d_ + x_**S(2)*WC('e', S(1)))**p_*(WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons4, cons5, cons1737, cons147) def replacement6229(p, m, f, b, d, a, n, c, x, e): rubi.append(6229) return Dist((-d)**IntPart(p)*(d + e*x**S(2))**FracPart(p)*(c*x + S(-1))**(-FracPart(p))*(c*x + S(1))**(-FracPart(p)), Int((f*x)**m*(a + b*acosh(c*x))**n*(c*x + S(-1))**p*(c*x + S(1))**p, x), x) rule6229 = ReplacementRule(pattern6229, replacement6229) pattern6230 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*asinh(x_*WC('c', S(1))))**WC('n', S(1))/(x_*WC('e', S(1)) + WC('d', S(0))), x_), cons2, cons3, cons7, cons27, cons48, cons148) def replacement6230(b, d, a, n, c, x, e): rubi.append(6230) return Subst(Int((a + b*x)**n*cosh(x)/(c*d + e*sinh(x)), x), x, asinh(c*x)) rule6230 = ReplacementRule(pattern6230, replacement6230) pattern6231 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1))))**WC('n', S(1))/(x_*WC('e', S(1)) + WC('d', S(0))), x_), cons2, cons3, cons7, cons27, cons48, cons148) def replacement6231(b, d, a, n, c, x, e): rubi.append(6231) return Subst(Int((a + b*x)**n*sinh(x)/(c*d + e*cosh(x)), x), x, acosh(c*x)) rule6231 = ReplacementRule(pattern6231, replacement6231) pattern6232 = Pattern(Integral((x_*WC('e', S(1)) + WC('d', S(0)))**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*asinh(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons21, cons148, cons66) def replacement6232(m, b, d, a, n, c, x, e): rubi.append(6232) return -Dist(b*c*n/(e*(m + S(1))), Int((a + b*asinh(c*x))**(n + S(-1))*(d + e*x)**(m + S(1))/sqrt(c**S(2)*x**S(2) + S(1)), x), x) + Simp((a + b*asinh(c*x))**n*(d + e*x)**(m + S(1))/(e*(m + S(1))), x) rule6232 = ReplacementRule(pattern6232, replacement6232) pattern6233 = Pattern(Integral((x_*WC('e', S(1)) + WC('d', S(0)))**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons21, cons148, cons66) def replacement6233(m, b, d, a, n, c, x, e): rubi.append(6233) return -Dist(b*c*n/(e*(m + S(1))), Int((a + b*acosh(c*x))**(n + S(-1))*(d + e*x)**(m + S(1))/(sqrt(c*x + S(-1))*sqrt(c*x + S(1))), x), x) + Simp((a + b*acosh(c*x))**n*(d + e*x)**(m + S(1))/(e*(m + S(1))), x) rule6233 = ReplacementRule(pattern6233, replacement6233) pattern6234 = Pattern(Integral((d_ + x_*WC('e', S(1)))**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*asinh(x_*WC('c', S(1))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons62, cons87, cons89) def replacement6234(m, b, d, a, c, n, x, e): rubi.append(6234) return Int(ExpandIntegrand((a + b*asinh(c*x))**n*(d + e*x)**m, x), x) rule6234 = ReplacementRule(pattern6234, replacement6234) pattern6235 = Pattern(Integral((d_ + x_*WC('e', S(1)))**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons62, cons87, cons89) def replacement6235(m, b, d, a, c, n, x, e): rubi.append(6235) return Int(ExpandIntegrand((a + b*acosh(c*x))**n*(d + e*x)**m, x), x) rule6235 = ReplacementRule(pattern6235, replacement6235) pattern6236 = Pattern(Integral((x_*WC('e', S(1)) + WC('d', S(0)))**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*asinh(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons4, cons62) def replacement6236(m, b, d, a, n, c, x, e): rubi.append(6236) return Dist(c**(-m + S(-1)), Subst(Int((a + b*x)**n*(c*d + e*sinh(x))**m*cosh(x), x), x, asinh(c*x)), x) rule6236 = ReplacementRule(pattern6236, replacement6236) pattern6237 = Pattern(Integral((x_*WC('e', S(1)) + WC('d', S(0)))**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons4, cons62) def replacement6237(m, b, d, a, n, c, x, e): rubi.append(6237) return Dist(c**(-m + S(-1)), Subst(Int((a + b*x)**n*(c*d + e*cosh(x))**m*sinh(x), x), x, acosh(c*x)), x) rule6237 = ReplacementRule(pattern6237, replacement6237) def With6238(b, Px, a, c, x): u = IntHide(Px, x) rubi.append(6238) return -Dist(b*c, Int(SimplifyIntegrand(u/sqrt(c**S(2)*x**S(2) + S(1)), x), x), x) + Dist(a + b*asinh(c*x), u, x) pattern6238 = Pattern(Integral(Px_*(WC('a', S(0)) + WC('b', S(1))*asinh(x_*WC('c', S(1)))), x_), cons2, cons3, cons7, cons925) rule6238 = ReplacementRule(pattern6238, With6238) def With6239(b, Px, a, c, x): u = IntHide(Px, x) rubi.append(6239) return -Dist(b*c*sqrt(-c**S(2)*x**S(2) + S(1))/(sqrt(c*x + S(-1))*sqrt(c*x + S(1))), Int(SimplifyIntegrand(u/sqrt(-c**S(2)*x**S(2) + S(1)), x), x), x) + Dist(a + b*acosh(c*x), u, x) pattern6239 = Pattern(Integral(Px_*(WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1)))), x_), cons2, cons3, cons7, cons925) rule6239 = ReplacementRule(pattern6239, With6239) pattern6240 = Pattern(Integral(Px_*(WC('a', S(0)) + WC('b', S(1))*asinh(x_*WC('c', S(1))))**n_, x_), cons2, cons3, cons7, cons4, cons925) def replacement6240(b, Px, a, n, c, x): rubi.append(6240) return Int(ExpandIntegrand(Px*(a + b*asinh(c*x))**n, x), x) rule6240 = ReplacementRule(pattern6240, replacement6240) pattern6241 = Pattern(Integral(Px_*(WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1))))**n_, x_), cons2, cons3, cons7, cons4, cons925) def replacement6241(b, Px, a, n, c, x): rubi.append(6241) return Int(ExpandIntegrand(Px*(a + b*acosh(c*x))**n, x), x) rule6241 = ReplacementRule(pattern6241, replacement6241) def With6242(m, b, Px, d, a, c, x, e): u = IntHide(Px*(d + e*x)**m, x) rubi.append(6242) return -Dist(b*c, Int(SimplifyIntegrand(u/sqrt(c**S(2)*x**S(2) + S(1)), x), x), x) + Dist(a + b*asinh(c*x), u, x) pattern6242 = Pattern(Integral(Px_*(x_*WC('e', S(1)) + WC('d', S(0)))**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*asinh(x_*WC('c', S(1)))), x_), cons2, cons3, cons7, cons27, cons48, cons21, cons925) rule6242 = ReplacementRule(pattern6242, With6242) def With6243(m, b, Px, d, a, c, x, e): u = IntHide(Px*(d + e*x)**m, x) rubi.append(6243) return -Dist(b*c*sqrt(-c**S(2)*x**S(2) + S(1))/(sqrt(c*x + S(-1))*sqrt(c*x + S(1))), Int(SimplifyIntegrand(u/sqrt(-c**S(2)*x**S(2) + S(1)), x), x), x) + Dist(a + b*acosh(c*x), u, x) pattern6243 = Pattern(Integral(Px_*(x_*WC('e', S(1)) + WC('d', S(0)))**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1)))), x_), cons2, cons3, cons7, cons27, cons48, cons21, cons925) rule6243 = ReplacementRule(pattern6243, With6243) def With6244(p, m, f, b, g, d, a, c, n, x, e): u = IntHide((d + e*x)**m*(f + g*x)**p, x) rubi.append(6244) return -Dist(b*c*n, Int(SimplifyIntegrand(u*(a + b*asinh(c*x))**(n + S(-1))/sqrt(c**S(2)*x**S(2) + S(1)), x), x), x) + Dist((a + b*asinh(c*x))**n, u, x) pattern6244 = Pattern(Integral((d_ + x_*WC('e', S(1)))**m_*(x_*WC('g', S(1)) + WC('f', S(0)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*asinh(x_*WC('c', S(1))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons464, cons84, cons1757) rule6244 = ReplacementRule(pattern6244, With6244) def With6245(p, m, f, b, g, d, a, c, n, x, e): u = IntHide((d + e*x)**m*(f + g*x)**p, x) rubi.append(6245) return -Dist(b*c*n, Int(SimplifyIntegrand(u*(a + b*acosh(c*x))**(n + S(-1))/(sqrt(c*x + S(-1))*sqrt(c*x + S(1))), x), x), x) + Dist((a + b*acosh(c*x))**n, u, x) pattern6245 = Pattern(Integral((d_ + x_*WC('e', S(1)))**m_*(x_*WC('g', S(1)) + WC('f', S(0)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons464, cons84, cons1757) rule6245 = ReplacementRule(pattern6245, With6245) def With6246(p, f, b, g, d, a, c, n, x, h, e): u = IntHide((f + g*x + h*x**S(2))**p/(d + e*x)**S(2), x) rubi.append(6246) return -Dist(b*c*n, Int(SimplifyIntegrand(u*(a + b*asinh(c*x))**(n + S(-1))/sqrt(c**S(2)*x**S(2) + S(1)), x), x), x) + Dist((a + b*asinh(c*x))**n, u, x) pattern6246 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*asinh(x_*WC('c', S(1))))**n_*(x_**S(2)*WC('h', S(1)) + x_*WC('g', S(1)) + WC('f', S(0)))**WC('p', S(1))/(d_ + x_*WC('e', S(1)))**S(2), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons209, cons464, cons1758) rule6246 = ReplacementRule(pattern6246, With6246) def With6247(p, f, b, g, d, a, c, n, x, h, e): u = IntHide((f + g*x + h*x**S(2))**p/(d + e*x)**S(2), x) rubi.append(6247) return -Dist(b*c*n, Int(SimplifyIntegrand(u*(a + b*acosh(c*x))**(n + S(-1))/(sqrt(c*x + S(-1))*sqrt(c*x + S(1))), x), x), x) + Dist((a + b*acosh(c*x))**n, u, x) pattern6247 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1))))**n_*(x_**S(2)*WC('h', S(1)) + x_*WC('g', S(1)) + WC('f', S(0)))**WC('p', S(1))/(d_ + x_*WC('e', S(1)))**S(2), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons209, cons464, cons1758) rule6247 = ReplacementRule(pattern6247, With6247) pattern6248 = Pattern(Integral(Px_*(d_ + x_*WC('e', S(1)))**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*asinh(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons925, cons148, cons17) def replacement6248(m, b, Px, d, a, n, c, x, e): rubi.append(6248) return Int(ExpandIntegrand(Px*(a + b*asinh(c*x))**n*(d + e*x)**m, x), x) rule6248 = ReplacementRule(pattern6248, replacement6248) pattern6249 = Pattern(Integral(Px_*(d_ + x_*WC('e', S(1)))**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons925, cons148, cons17) def replacement6249(m, b, Px, d, a, n, c, x, e): rubi.append(6249) return Int(ExpandIntegrand(Px*(a + b*acosh(c*x))**n*(d + e*x)**m, x), x) rule6249 = ReplacementRule(pattern6249, replacement6249) def With6250(p, m, g, b, f, d, a, c, x, e): u = IntHide((d + e*x**S(2))**p*(f + g*x)**m, x) rubi.append(6250) return -Dist(b*c, Int(Dist(S(1)/sqrt(c**S(2)*x**S(2) + S(1)), u, x), x), x) + Dist(a + b*asinh(c*x), u, x) pattern6250 = Pattern(Integral((d_ + x_**S(2)*WC('e', S(1)))**p_*(f_ + x_*WC('g', S(1)))**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*asinh(x_*WC('c', S(1)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons1778, cons17, cons719, cons268, cons168, cons1759) rule6250 = ReplacementRule(pattern6250, With6250) def With6251(p, d2, m, g, b, f, e2, a, c, d1, e1, x): u = IntHide((d1 + e1*x)**p*(d2 + e2*x)**p*(f + g*x)**m, x) rubi.append(6251) return -Dist(b*c, Int(Dist(S(1)/(sqrt(c*x + S(-1))*sqrt(c*x + S(1))), u, x), x), x) + Dist(a + b*acosh(c*x), u, x) pattern6251 = Pattern(Integral((d1_ + x_*WC('e1', S(1)))**p_*(d2_ + x_*WC('e2', S(1)))**p_*(f_ + x_*WC('g', S(1)))**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1)))), x_), cons2, cons3, cons7, cons731, cons652, cons732, cons654, cons125, cons208, cons1892, cons1893, cons17, cons719, cons1894, cons1895, cons168, cons1759) rule6251 = ReplacementRule(pattern6251, With6251) pattern6252 = Pattern(Integral((d_ + x_**S(2)*WC('e', S(1)))**p_*(f_ + x_*WC('g', S(1)))**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*asinh(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons1778, cons17, cons667, cons268, cons148, cons168, cons1760) def replacement6252(p, m, g, b, f, d, a, n, c, x, e): rubi.append(6252) return Int(ExpandIntegrand((a + b*asinh(c*x))**n*(d + e*x**S(2))**p, (f + g*x)**m, x), x) rule6252 = ReplacementRule(pattern6252, replacement6252) pattern6253 = Pattern(Integral((d1_ + x_*WC('e1', S(1)))**p_*(d2_ + x_*WC('e2', S(1)))**p_*(f_ + x_*WC('g', S(1)))**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons731, cons652, cons732, cons654, cons125, cons208, cons1892, cons1893, cons17, cons667, cons1894, cons1895, cons148, cons168, cons1760) def replacement6253(p, d2, m, g, b, f, e2, a, n, c, d1, e1, x): rubi.append(6253) return Int(ExpandIntegrand((a + b*acosh(c*x))**n*(d1 + e1*x)**p*(d2 + e2*x)**p, (f + g*x)**m, x), x) rule6253 = ReplacementRule(pattern6253, replacement6253) pattern6254 = Pattern(Integral(sqrt(d_ + x_**S(2)*WC('e', S(1)))*(x_*WC('g', S(1)) + WC('f', S(0)))**m_*(WC('a', S(0)) + WC('b', S(1))*asinh(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons1778, cons17, cons268, cons148, cons267) def replacement6254(m, f, b, g, d, a, n, c, x, e): rubi.append(6254) return -Dist(S(1)/(b*c*sqrt(d)*(n + S(1))), Int((a + b*asinh(c*x))**(n + S(1))*(f + g*x)**(m + S(-1))*(d*g*m + S(2)*e*f*x + e*g*x**S(2)*(m + S(2))), x), x) + Simp((a + b*asinh(c*x))**(n + S(1))*(d + e*x**S(2))*(f + g*x)**m/(b*c*sqrt(d)*(n + S(1))), x) rule6254 = ReplacementRule(pattern6254, replacement6254) pattern6255 = Pattern(Integral(sqrt(d1_ + x_*WC('e1', S(1)))*sqrt(d2_ + x_*WC('e2', S(1)))*(f_ + x_*WC('g', S(1)))**m_*(WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons731, cons652, cons732, cons654, cons125, cons208, cons1892, cons1893, cons17, cons1894, cons1895, cons148, cons267) def replacement6255(d2, m, g, b, f, e2, a, n, c, d1, e1, x): rubi.append(6255) return -Dist(S(1)/(b*c*sqrt(-d1*d2)*(n + S(1))), Int((a + b*acosh(c*x))**(n + S(1))*(f + g*x)**(m + S(-1))*(d1*d2*g*m + S(2)*e1*e2*f*x + e1*e2*g*x**S(2)*(m + S(2))), x), x) + Simp((a + b*acosh(c*x))**(n + S(1))*(f + g*x)**m*(d1*d2 + e1*e2*x**S(2))/(b*c*sqrt(-d1*d2)*(n + S(1))), x) rule6255 = ReplacementRule(pattern6255, replacement6255) pattern6256 = Pattern(Integral((d_ + x_**S(2)*WC('e', S(1)))**p_*(f_ + x_*WC('g', S(1)))**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*asinh(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons1778, cons17, cons961, cons268, cons148) def replacement6256(p, m, g, b, f, d, a, n, c, x, e): rubi.append(6256) return Int(ExpandIntegrand((a + b*asinh(c*x))**n*sqrt(d + e*x**S(2)), (d + e*x**S(2))**(p + S(-1)/2)*(f + g*x)**m, x), x) rule6256 = ReplacementRule(pattern6256, replacement6256) pattern6257 = Pattern(Integral((d1_ + x_*WC('e1', S(1)))**p_*(d2_ + x_*WC('e2', S(1)))**p_*(f_ + x_*WC('g', S(1)))**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons731, cons652, cons732, cons654, cons125, cons208, cons1892, cons1893, cons17, cons961, cons1894, cons1895, cons148) def replacement6257(p, d2, m, g, b, f, e2, a, n, c, d1, e1, x): rubi.append(6257) return Int(ExpandIntegrand((a + b*acosh(c*x))**n*sqrt(d1 + e1*x)*sqrt(d2 + e2*x), (d1 + e1*x)**(p + S(-1)/2)*(d2 + e2*x)**(p + S(-1)/2)*(f + g*x)**m, x), x) rule6257 = ReplacementRule(pattern6257, replacement6257) pattern6258 = Pattern(Integral((d_ + x_**S(2)*WC('e', S(1)))**p_*(f_ + x_*WC('g', S(1)))**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*asinh(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons1778, cons17, cons717, cons268, cons148, cons267) def replacement6258(p, m, g, b, f, d, a, n, c, x, e): rubi.append(6258) return -Dist(S(1)/(b*c*sqrt(d)*(n + S(1))), Int(ExpandIntegrand((a + b*asinh(c*x))**(n + S(1))*(f + g*x)**(m + S(-1)), (d + e*x**S(2))**(p + S(-1)/2)*(d*g*m + e*f*x*(S(2)*p + S(1)) + e*g*x**S(2)*(m + S(2)*p + S(1))), x), x), x) + Simp((a + b*asinh(c*x))**(n + S(1))*(d + e*x**S(2))**(p + S(1)/2)*(f + g*x)**m/(b*c*sqrt(d)*(n + S(1))), x) rule6258 = ReplacementRule(pattern6258, replacement6258) pattern6259 = Pattern(Integral((d1_ + x_*WC('e1', S(1)))**p_*(d2_ + x_*WC('e2', S(1)))**p_*(f_ + x_*WC('g', S(1)))**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons731, cons652, cons732, cons654, cons125, cons208, cons1892, cons1893, cons17, cons717, cons1894, cons1895, cons148, cons267) def replacement6259(p, d2, m, g, b, f, e2, a, n, c, d1, e1, x): rubi.append(6259) return -Dist(S(1)/(b*c*sqrt(-d1*d2)*(n + S(1))), Int(ExpandIntegrand((a + b*acosh(c*x))**(n + S(1))*(f + g*x)**(m + S(-1)), (d1 + e1*x)**(p + S(-1)/2)*(d2 + e2*x)**(p + S(-1)/2)*(d1*d2*g*m + e1*e2*f*x*(S(2)*p + S(1)) + e1*e2*g*x**S(2)*(m + S(2)*p + S(1))), x), x), x) + Simp((a + b*acosh(c*x))**(n + S(1))*(d1 + e1*x)**(p + S(1)/2)*(d2 + e2*x)**(p + S(1)/2)*(f + g*x)**m/(b*c*sqrt(-d1*d2)*(n + S(1))), x) rule6259 = ReplacementRule(pattern6259, replacement6259) pattern6260 = Pattern(Integral((f_ + x_*WC('g', S(1)))**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*asinh(x_*WC('c', S(1))))**n_/sqrt(d_ + x_**S(2)*WC('e', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons1778, cons17, cons268, cons168, cons87, cons89) def replacement6260(m, g, b, f, d, a, c, n, x, e): rubi.append(6260) return -Dist(g*m/(b*c*sqrt(d)*(n + S(1))), Int((a + b*asinh(c*x))**(n + S(1))*(f + g*x)**(m + S(-1)), x), x) + Simp((a + b*asinh(c*x))**(n + S(1))*(f + g*x)**m/(b*c*sqrt(d)*(n + S(1))), x) rule6260 = ReplacementRule(pattern6260, replacement6260) pattern6261 = Pattern(Integral((f_ + x_*WC('g', S(1)))**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1))))**n_/(sqrt(d1_ + x_*WC('e1', S(1)))*sqrt(d2_ + x_*WC('e2', S(1)))), x_), cons2, cons3, cons7, cons731, cons652, cons732, cons654, cons125, cons208, cons1892, cons1893, cons17, cons1894, cons1895, cons168, cons87, cons89) def replacement6261(d2, m, g, b, f, e2, a, c, n, d1, e1, x): rubi.append(6261) return -Dist(g*m/(b*c*sqrt(-d1*d2)*(n + S(1))), Int((a + b*acosh(c*x))**(n + S(1))*(f + g*x)**(m + S(-1)), x), x) + Simp((a + b*acosh(c*x))**(n + S(1))*(f + g*x)**m/(b*c*sqrt(-d1*d2)*(n + S(1))), x) rule6261 = ReplacementRule(pattern6261, replacement6261) pattern6262 = Pattern(Integral((f_ + x_*WC('g', S(1)))**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*asinh(x_*WC('c', S(1))))**WC('n', S(1))/sqrt(d_ + x_**S(2)*WC('e', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons4, cons1778, cons17, cons268, cons1761) def replacement6262(m, g, b, f, d, a, n, c, x, e): rubi.append(6262) return Dist(c**(-m + S(-1))/sqrt(d), Subst(Int((a + b*x)**n*(c*f + g*sinh(x))**m, x), x, asinh(c*x)), x) rule6262 = ReplacementRule(pattern6262, replacement6262) pattern6263 = Pattern(Integral((f_ + x_*WC('g', S(1)))**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1))))**WC('n', S(1))/(sqrt(d1_ + x_*WC('e1', S(1)))*sqrt(d2_ + x_*WC('e2', S(1)))), x_), cons2, cons3, cons7, cons731, cons652, cons732, cons654, cons125, cons208, cons4, cons1892, cons1893, cons17, cons1894, cons1895, cons1761) def replacement6263(d2, m, g, b, f, e2, a, n, c, d1, e1, x): rubi.append(6263) return Dist(c**(-m + S(-1))/sqrt(-d1*d2), Subst(Int((a + b*x)**n*(c*f + g*cosh(x))**m, x), x, acosh(c*x)), x) rule6263 = ReplacementRule(pattern6263, replacement6263) pattern6264 = Pattern(Integral((d_ + x_**S(2)*WC('e', S(1)))**p_*(f_ + x_*WC('g', S(1)))**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*asinh(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons1778, cons17, cons719, cons268, cons148) def replacement6264(p, m, g, b, f, d, a, n, c, x, e): rubi.append(6264) return Int(ExpandIntegrand((a + b*asinh(c*x))**n/sqrt(d + e*x**S(2)), (d + e*x**S(2))**(p + S(1)/2)*(f + g*x)**m, x), x) rule6264 = ReplacementRule(pattern6264, replacement6264) pattern6265 = Pattern(Integral((d1_ + x_*WC('e1', S(1)))**p_*(d2_ + x_*WC('e2', S(1)))**p_*(f_ + x_*WC('g', S(1)))**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons731, cons652, cons732, cons654, cons125, cons208, cons1892, cons1893, cons17, cons719, cons1894, cons1895, cons148) def replacement6265(p, d2, m, g, b, f, e2, a, n, c, d1, e1, x): rubi.append(6265) return Int(ExpandIntegrand((a + b*acosh(c*x))**n/(sqrt(d1 + e1*x)*sqrt(d2 + e2*x)), (d1 + e1*x)**(p + S(1)/2)*(d2 + e2*x)**(p + S(1)/2)*(f + g*x)**m, x), x) rule6265 = ReplacementRule(pattern6265, replacement6265) pattern6266 = Pattern(Integral((d_ + x_**S(2)*WC('e', S(1)))**p_*(f_ + x_*WC('g', S(1)))**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*asinh(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons4, cons1778, cons17, cons347, cons1738) def replacement6266(p, m, g, b, f, d, a, n, c, x, e): rubi.append(6266) return Dist(d**IntPart(p)*(d + e*x**S(2))**FracPart(p)*(c**S(2)*x**S(2) + S(1))**(-FracPart(p)), Int((a + b*asinh(c*x))**n*(f + g*x)**m*(c**S(2)*x**S(2) + S(1))**p, x), x) rule6266 = ReplacementRule(pattern6266, replacement6266) pattern6267 = Pattern(Integral((d_ + x_**S(2)*WC('e', S(1)))**p_*(f_ + x_*WC('g', S(1)))**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons4, cons1737, cons17, cons347) def replacement6267(p, m, g, b, f, d, a, n, c, x, e): rubi.append(6267) return Dist((-d)**IntPart(p)*(d + e*x**S(2))**FracPart(p)*(c*x + S(-1))**(-FracPart(p))*(c*x + S(1))**(-FracPart(p)), Int((a + b*acosh(c*x))**n*(f + g*x)**m*(c*x + S(-1))**p*(c*x + S(1))**p, x), x) rule6267 = ReplacementRule(pattern6267, replacement6267) pattern6268 = Pattern(Integral((d1_ + x_*WC('e1', S(1)))**p_*(d2_ + x_*WC('e2', S(1)))**p_*(f_ + x_*WC('g', S(1)))**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons731, cons652, cons732, cons654, cons125, cons208, cons4, cons1892, cons1893, cons17, cons347, cons1896) def replacement6268(p, d2, m, g, b, f, e2, a, n, c, d1, e1, x): rubi.append(6268) return Dist((-d1*d2)**IntPart(p)*(d1 + e1*x)**FracPart(p)*(d2 + e2*x)**FracPart(p)*(-c**S(2)*x**S(2) + S(1))**(-FracPart(p)), Int((a + b*acosh(c*x))**n*(f + g*x)**m*(c*x + S(-1))**p*(c*x + S(1))**p, x), x) rule6268 = ReplacementRule(pattern6268, replacement6268) pattern6269 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*asinh(x_*WC('c', S(1))))**WC('n', S(1))*log((x_*WC('g', S(1)) + WC('f', S(0)))**WC('m', S(1))*WC('h', S(1)))/sqrt(d_ + x_**S(2)*WC('e', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons209, cons21, cons1778, cons268, cons148) def replacement6269(m, f, g, b, d, a, c, n, x, h, e): rubi.append(6269) return -Dist(g*m/(b*c*sqrt(d)*(n + S(1))), Int((a + b*asinh(c*x))**(n + S(1))/(f + g*x), x), x) + Simp((a + b*asinh(c*x))**(n + S(1))*log(h*(f + g*x)**m)/(b*c*sqrt(d)*(n + S(1))), x) rule6269 = ReplacementRule(pattern6269, replacement6269) pattern6270 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1))))**WC('n', S(1))*log((x_*WC('g', S(1)) + WC('f', S(0)))**WC('m', S(1))*WC('h', S(1)))/(sqrt(d1_ + x_*WC('e1', S(1)))*sqrt(d2_ + x_*WC('e2', S(1)))), x_), cons2, cons3, cons7, cons731, cons652, cons732, cons654, cons125, cons208, cons209, cons21, cons1892, cons1893, cons1894, cons1895, cons148) def replacement6270(d2, m, f, g, b, e2, a, c, n, d1, e1, x, h): rubi.append(6270) return -Dist(g*m/(b*c*sqrt(-d1*d2)*(n + S(1))), Int((a + b*acosh(c*x))**(n + S(1))/(f + g*x), x), x) + Simp((a + b*acosh(c*x))**(n + S(1))*log(h*(f + g*x)**m)/(b*c*sqrt(-d1*d2)*(n + S(1))), x) rule6270 = ReplacementRule(pattern6270, replacement6270) pattern6271 = Pattern(Integral((d_ + x_**S(2)*WC('e', S(1)))**p_*(WC('a', S(0)) + WC('b', S(1))*asinh(x_*WC('c', S(1))))**WC('n', S(1))*log((x_*WC('g', S(1)) + WC('f', S(0)))**WC('m', S(1))*WC('h', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons209, cons21, cons4, cons1778, cons347, cons1738) def replacement6271(p, m, f, g, b, d, a, c, n, x, h, e): rubi.append(6271) return Dist(d**IntPart(p)*(d + e*x**S(2))**FracPart(p)*(c**S(2)*x**S(2) + S(1))**(-FracPart(p)), Int((a + b*asinh(c*x))**n*(c**S(2)*x**S(2) + S(1))**p*log(h*(f + g*x)**m), x), x) rule6271 = ReplacementRule(pattern6271, replacement6271) pattern6272 = Pattern(Integral((d_ + x_**S(2)*WC('e', S(1)))**p_*(WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1))))**WC('n', S(1))*log((x_*WC('g', S(1)) + WC('f', S(0)))**WC('m', S(1))*WC('h', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons209, cons21, cons4, cons1737, cons347) def replacement6272(p, m, f, g, b, d, a, c, n, x, h, e): rubi.append(6272) return Dist((-d)**IntPart(p)*(d + e*x**S(2))**FracPart(p)*(c*x + S(-1))**(-FracPart(p))*(c*x + S(1))**(-FracPart(p)), Int((a + b*acosh(c*x))**n*(c*x + S(-1))**p*(c*x + S(1))**p*log(h*(f + g*x)**m), x), x) rule6272 = ReplacementRule(pattern6272, replacement6272) pattern6273 = Pattern(Integral((d1_ + x_*WC('e1', S(1)))**p_*(d2_ + x_*WC('e2', S(1)))**p_*(WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1))))**WC('n', S(1))*log((x_*WC('g', S(1)) + WC('f', S(0)))**WC('m', S(1))*WC('h', S(1))), x_), cons2, cons3, cons7, cons731, cons652, cons732, cons654, cons125, cons208, cons209, cons21, cons4, cons1892, cons1893, cons347, cons1896) def replacement6273(p, d2, m, f, g, b, e2, a, c, n, d1, e1, x, h): rubi.append(6273) return Dist((-d1*d2)**IntPart(p)*(d1 + e1*x)**FracPart(p)*(d2 + e2*x)**FracPart(p)*(c*x + S(-1))**(-FracPart(p))*(c*x + S(1))**(-FracPart(p)), Int((a + b*acosh(c*x))**n*(c*x + S(-1))**p*(c*x + S(1))**p*log(h*(f + g*x)**m), x), x) rule6273 = ReplacementRule(pattern6273, replacement6273) def With6274(m, g, b, f, d, a, c, x, e): u = IntHide((d + e*x)**m*(f + g*x)**m, x) rubi.append(6274) return -Dist(b*c, Int(Dist(S(1)/sqrt(c**S(2)*x**S(2) + S(1)), u, x), x), x) + Dist(a + b*asinh(c*x), u, x) pattern6274 = Pattern(Integral((d_ + x_*WC('e', S(1)))**m_*(f_ + x_*WC('g', S(1)))**m_*(WC('a', S(0)) + WC('b', S(1))*asinh(x_*WC('c', S(1)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons1608) rule6274 = ReplacementRule(pattern6274, With6274) def With6275(m, g, b, f, d, a, c, x, e): u = IntHide((d + e*x)**m*(f + g*x)**m, x) rubi.append(6275) return -Dist(b*c, Int(Dist(S(1)/(sqrt(c*x + S(-1))*sqrt(c*x + S(1))), u, x), x), x) + Dist(a + b*acosh(c*x), u, x) pattern6275 = Pattern(Integral((d_ + x_*WC('e', S(1)))**m_*(f_ + x_*WC('g', S(1)))**m_*(WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons1608) rule6275 = ReplacementRule(pattern6275, With6275) pattern6276 = Pattern(Integral((d_ + x_*WC('e', S(1)))**WC('m', S(1))*(f_ + x_*WC('g', S(1)))**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*asinh(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons4, cons17) def replacement6276(m, g, b, f, d, a, n, c, x, e): rubi.append(6276) return Int(ExpandIntegrand((a + b*asinh(c*x))**n, (d + e*x)**m*(f + g*x)**m, x), x) rule6276 = ReplacementRule(pattern6276, replacement6276) pattern6277 = Pattern(Integral((d_ + x_*WC('e', S(1)))**WC('m', S(1))*(f_ + x_*WC('g', S(1)))**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons4, cons17) def replacement6277(m, g, b, f, d, a, n, c, x, e): rubi.append(6277) return Int(ExpandIntegrand((a + b*acosh(c*x))**n, (d + e*x)**m*(f + g*x)**m, x), x) rule6277 = ReplacementRule(pattern6277, replacement6277) def With6278(u, b, a, c, x): if isinstance(x, (int, Integer, float, Float)): return False v = IntHide(u, x) if InverseFunctionFreeQ(v, x): return True return False pattern6278 = Pattern(Integral(u_*(WC('a', S(0)) + WC('b', S(1))*asinh(x_*WC('c', S(1)))), x_), cons2, cons3, cons7, cons14, CustomConstraint(With6278)) def replacement6278(u, b, a, c, x): v = IntHide(u, x) rubi.append(6278) return -Dist(b*c, Int(SimplifyIntegrand(v/sqrt(c**S(2)*x**S(2) + S(1)), x), x), x) + Dist(a + b*asinh(c*x), v, x) rule6278 = ReplacementRule(pattern6278, replacement6278) def With6279(u, b, a, c, x): if isinstance(x, (int, Integer, float, Float)): return False v = IntHide(u, x) if InverseFunctionFreeQ(v, x): return True return False pattern6279 = Pattern(Integral(u_*(WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1)))), x_), cons2, cons3, cons7, cons14, CustomConstraint(With6279)) def replacement6279(u, b, a, c, x): v = IntHide(u, x) rubi.append(6279) return -Dist(b*c*sqrt(-c**S(2)*x**S(2) + S(1))/(sqrt(c*x + S(-1))*sqrt(c*x + S(1))), Int(SimplifyIntegrand(v/sqrt(-c**S(2)*x**S(2) + S(1)), x), x), x) + Dist(a + b*acosh(c*x), v, x) rule6279 = ReplacementRule(pattern6279, replacement6279) def With6280(p, b, Px, d, a, c, n, x, e): if isinstance(x, (int, Integer, float, Float)): return False u = ExpandIntegrand(Px*(a + b*asinh(c*x))**n*(d + e*x**S(2))**p, x) if SumQ(u): return True return False pattern6280 = Pattern(Integral(Px_*(d_ + x_**S(2)*WC('e', S(1)))**p_*(WC('a', S(0)) + WC('b', S(1))*asinh(x_*WC('c', S(1))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons4, cons925, cons1778, cons347, CustomConstraint(With6280)) def replacement6280(p, b, Px, d, a, c, n, x, e): u = ExpandIntegrand(Px*(a + b*asinh(c*x))**n*(d + e*x**S(2))**p, x) rubi.append(6280) return Int(u, x) rule6280 = ReplacementRule(pattern6280, replacement6280) def With6281(p, d2, b, Px, e2, a, c, n, d1, e1, x): if isinstance(x, (int, Integer, float, Float)): return False u = ExpandIntegrand(Px*(a + b*acosh(c*x))**n*(d1 + e1*x)**p*(d2 + e2*x)**p, x) if SumQ(u): return True return False pattern6281 = Pattern(Integral(Px_*(d1_ + x_*WC('e1', S(1)))**p_*(d2_ + x_*WC('e2', S(1)))**p_*(WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1))))**n_, x_), cons2, cons3, cons7, cons731, cons652, cons732, cons654, cons4, cons925, cons1892, cons1893, cons347, CustomConstraint(With6281)) def replacement6281(p, d2, b, Px, e2, a, c, n, d1, e1, x): u = ExpandIntegrand(Px*(a + b*acosh(c*x))**n*(d1 + e1*x)**p*(d2 + e2*x)**p, x) rubi.append(6281) return Int(u, x) rule6281 = ReplacementRule(pattern6281, replacement6281) def With6282(p, m, g, b, f, Px, d, a, n, c, x, e): if isinstance(x, (int, Integer, float, Float)): return False u = ExpandIntegrand(Px*(a + b*asinh(c*x))**n*(f + g*(d + e*x**S(2))**p)**m, x) if SumQ(u): return True return False pattern6282 = Pattern(Integral((f_ + (d_ + x_**S(2)*WC('e', S(1)))**p_*WC('g', S(1)))**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*asinh(x_*WC('c', S(1))))**WC('n', S(1))*WC('Px', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons925, cons1778, cons961, cons150, CustomConstraint(With6282)) def replacement6282(p, m, g, b, f, Px, d, a, n, c, x, e): u = ExpandIntegrand(Px*(a + b*asinh(c*x))**n*(f + g*(d + e*x**S(2))**p)**m, x) rubi.append(6282) return Int(u, x) rule6282 = ReplacementRule(pattern6282, replacement6282) def With6283(p, d2, m, g, b, f, Px, e2, a, n, c, d1, e1, x): if isinstance(x, (int, Integer, float, Float)): return False u = ExpandIntegrand(Px*(a + b*acosh(c*x))**n*(f + g*(d1 + e1*x)**p*(d2 + e2*x)**p)**m, x) if SumQ(u): return True return False pattern6283 = Pattern(Integral((f_ + (d1_ + x_*WC('e1', S(1)))**p_*(d2_ + x_*WC('e2', S(1)))**p_*WC('g', S(1)))**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1))))**WC('n', S(1))*WC('Px', S(1)), x_), cons2, cons3, cons7, cons731, cons652, cons732, cons654, cons125, cons208, cons925, cons1892, cons1893, cons961, cons150, CustomConstraint(With6283)) def replacement6283(p, d2, m, g, b, f, Px, e2, a, n, c, d1, e1, x): u = ExpandIntegrand(Px*(a + b*acosh(c*x))**n*(f + g*(d1 + e1*x)**p*(d2 + e2*x)**p)**m, x) rubi.append(6283) return Int(u, x) rule6283 = ReplacementRule(pattern6283, replacement6283) def With6284(x, c, n, RFx): if isinstance(x, (int, Integer, float, Float)): return False u = ExpandIntegrand(asinh(c*x)**n, RFx, x) if SumQ(u): return True return False pattern6284 = Pattern(Integral(RFx_*asinh(x_*WC('c', S(1)))**WC('n', S(1)), x_), cons7, cons1198, cons148, CustomConstraint(With6284)) def replacement6284(x, c, n, RFx): u = ExpandIntegrand(asinh(c*x)**n, RFx, x) rubi.append(6284) return Int(u, x) rule6284 = ReplacementRule(pattern6284, replacement6284) def With6285(x, c, n, RFx): if isinstance(x, (int, Integer, float, Float)): return False u = ExpandIntegrand(acosh(c*x)**n, RFx, x) if SumQ(u): return True return False pattern6285 = Pattern(Integral(RFx_*acosh(x_*WC('c', S(1)))**WC('n', S(1)), x_), cons7, cons1198, cons148, CustomConstraint(With6285)) def replacement6285(x, c, n, RFx): u = ExpandIntegrand(acosh(c*x)**n, RFx, x) rubi.append(6285) return Int(u, x) rule6285 = ReplacementRule(pattern6285, replacement6285) pattern6286 = Pattern(Integral(RFx_*(a_ + WC('b', S(1))*asinh(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons1198, cons148) def replacement6286(RFx, b, c, n, a, x): rubi.append(6286) return Int(ExpandIntegrand(RFx*(a + b*asinh(c*x))**n, x), x) rule6286 = ReplacementRule(pattern6286, replacement6286) pattern6287 = Pattern(Integral(RFx_*(a_ + WC('b', S(1))*acosh(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons1198, cons148) def replacement6287(RFx, b, c, n, a, x): rubi.append(6287) return Int(ExpandIntegrand(RFx*(a + b*acosh(c*x))**n, x), x) rule6287 = ReplacementRule(pattern6287, replacement6287) def With6288(p, RFx, d, c, n, x, e): if isinstance(x, (int, Integer, float, Float)): return False u = ExpandIntegrand((d + e*x**S(2))**p*asinh(c*x)**n, RFx, x) if SumQ(u): return True return False pattern6288 = Pattern(Integral(RFx_*(d_ + x_**S(2)*WC('e', S(1)))**p_*asinh(x_*WC('c', S(1)))**WC('n', S(1)), x_), cons7, cons27, cons48, cons1198, cons148, cons1778, cons347, CustomConstraint(With6288)) def replacement6288(p, RFx, d, c, n, x, e): u = ExpandIntegrand((d + e*x**S(2))**p*asinh(c*x)**n, RFx, x) rubi.append(6288) return Int(u, x) rule6288 = ReplacementRule(pattern6288, replacement6288) def With6289(p, RFx, d2, e2, c, n, d1, e1, x): if isinstance(x, (int, Integer, float, Float)): return False u = ExpandIntegrand((d1 + e1*x)**p*(d2 + e2*x)**p*acosh(c*x)**n, RFx, x) if SumQ(u): return True return False pattern6289 = Pattern(Integral(RFx_*(d1_ + x_*WC('e1', S(1)))**p_*(d2_ + x_*WC('e2', S(1)))**p_*acosh(x_*WC('c', S(1)))**WC('n', S(1)), x_), cons7, cons731, cons652, cons732, cons654, cons1198, cons148, cons1892, cons1893, cons347, CustomConstraint(With6289)) def replacement6289(p, RFx, d2, e2, c, n, d1, e1, x): u = ExpandIntegrand((d1 + e1*x)**p*(d2 + e2*x)**p*acosh(c*x)**n, RFx, x) rubi.append(6289) return Int(u, x) rule6289 = ReplacementRule(pattern6289, replacement6289) pattern6290 = Pattern(Integral(RFx_*(a_ + WC('b', S(1))*asinh(x_*WC('c', S(1))))**WC('n', S(1))*(d_ + x_**S(2)*WC('e', S(1)))**p_, x_), cons2, cons3, cons7, cons27, cons48, cons1198, cons148, cons1778, cons347) def replacement6290(p, RFx, b, d, c, n, a, x, e): rubi.append(6290) return Int(ExpandIntegrand((d + e*x**S(2))**p, RFx*(a + b*asinh(c*x))**n, x), x) rule6290 = ReplacementRule(pattern6290, replacement6290) pattern6291 = Pattern(Integral(RFx_*(a_ + WC('b', S(1))*acosh(x_*WC('c', S(1))))**WC('n', S(1))*(d1_ + x_*WC('e1', S(1)))**p_*(d2_ + x_*WC('e2', S(1)))**p_, x_), cons2, cons3, cons7, cons731, cons652, cons732, cons654, cons1198, cons148, cons1892, cons1893, cons347) def replacement6291(p, RFx, d2, b, e2, c, n, a, d1, e1, x): rubi.append(6291) return Int(ExpandIntegrand((d1 + e1*x)**p*(d2 + e2*x)**p, RFx*(a + b*acosh(c*x))**n, x), x) rule6291 = ReplacementRule(pattern6291, replacement6291) pattern6292 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*asinh(x_*WC('c', S(1))))**WC('n', S(1))*WC('u', S(1)), x_), cons2, cons3, cons7, cons4, cons1579) def replacement6292(u, b, a, n, c, x): rubi.append(6292) return Int(u*(a + b*asinh(c*x))**n, x) rule6292 = ReplacementRule(pattern6292, replacement6292) pattern6293 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1))))**WC('n', S(1))*WC('u', S(1)), x_), cons2, cons3, cons7, cons4, cons1579) def replacement6293(u, b, a, n, c, x): rubi.append(6293) return Int(u*(a + b*acosh(c*x))**n, x) rule6293 = ReplacementRule(pattern6293, replacement6293) pattern6294 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*asinh(c_ + x_*WC('d', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons4, cons1273) def replacement6294(b, d, c, a, n, x): rubi.append(6294) return Dist(S(1)/d, Subst(Int((a + b*asinh(x))**n, x), x, c + d*x), x) rule6294 = ReplacementRule(pattern6294, replacement6294) pattern6295 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*acosh(c_ + x_*WC('d', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons4, cons1273) def replacement6295(b, d, c, a, n, x): rubi.append(6295) return Dist(S(1)/d, Subst(Int((a + b*acosh(x))**n, x), x, c + d*x), x) rule6295 = ReplacementRule(pattern6295, replacement6295) pattern6296 = Pattern(Integral((x_*WC('f', S(1)) + WC('e', S(0)))**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*asinh(c_ + x_*WC('d', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons4, cons1360) def replacement6296(m, f, b, d, a, n, c, x, e): rubi.append(6296) return Dist(S(1)/d, Subst(Int((a + b*asinh(x))**n*(f*x/d + (-c*f + d*e)/d)**m, x), x, c + d*x), x) rule6296 = ReplacementRule(pattern6296, replacement6296) pattern6297 = Pattern(Integral((x_*WC('f', S(1)) + WC('e', S(0)))**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*acosh(c_ + x_*WC('d', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons4, cons1360) def replacement6297(m, f, b, d, a, n, c, x, e): rubi.append(6297) return Dist(S(1)/d, Subst(Int((a + b*acosh(x))**n*(f*x/d + (-c*f + d*e)/d)**m, x), x, c + d*x), x) rule6297 = ReplacementRule(pattern6297, replacement6297) pattern6298 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*asinh(c_ + x_*WC('d', S(1))))**WC('n', S(1))*(x_**S(2)*WC('C', S(1)) + x_*WC('B', S(1)) + WC('A', S(0)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons34, cons35, cons36, cons4, cons5, cons1830, cons1763) def replacement6298(B, C, p, b, d, a, n, c, x, A): rubi.append(6298) return Dist(S(1)/d, Subst(Int((a + b*asinh(x))**n*(C*x**S(2)/d**S(2) + C/d**S(2))**p, x), x, c + d*x), x) rule6298 = ReplacementRule(pattern6298, replacement6298) pattern6299 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*acosh(c_ + x_*WC('d', S(1))))**WC('n', S(1))*(x_**S(2)*WC('C', S(1)) + x_*WC('B', S(1)) + WC('A', S(0)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons34, cons35, cons36, cons4, cons5, cons1762, cons1763) def replacement6299(B, C, p, b, d, a, n, c, x, A): rubi.append(6299) return Dist(S(1)/d, Subst(Int((a + b*acosh(x))**n*(C*x**S(2)/d**S(2) - C/d**S(2))**p, x), x, c + d*x), x) rule6299 = ReplacementRule(pattern6299, replacement6299) pattern6300 = Pattern(Integral((x_*WC('f', S(1)) + WC('e', S(0)))**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*asinh(c_ + x_*WC('d', S(1))))**WC('n', S(1))*(x_**S(2)*WC('C', S(1)) + x_*WC('B', S(1)) + WC('A', S(0)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons36, cons21, cons4, cons5, cons1830, cons1763) def replacement6300(B, C, p, m, f, b, d, a, n, c, A, x, e): rubi.append(6300) return Dist(S(1)/d, Subst(Int((a + b*asinh(x))**n*(C*x**S(2)/d**S(2) + C/d**S(2))**p*(f*x/d + (-c*f + d*e)/d)**m, x), x, c + d*x), x) rule6300 = ReplacementRule(pattern6300, replacement6300) pattern6301 = Pattern(Integral((x_*WC('f', S(1)) + WC('e', S(0)))**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*acosh(c_ + x_*WC('d', S(1))))**WC('n', S(1))*(x_**S(2)*WC('C', S(1)) + x_*WC('B', S(1)) + WC('A', S(0)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons36, cons21, cons4, cons5, cons1762, cons1763) def replacement6301(B, C, p, m, f, b, d, a, n, c, A, x, e): rubi.append(6301) return Dist(S(1)/d, Subst(Int((a + b*acosh(x))**n*(C*x**S(2)/d**S(2) - C/d**S(2))**p*(f*x/d + (-c*f + d*e)/d)**m, x), x, c + d*x), x) rule6301 = ReplacementRule(pattern6301, replacement6301) pattern6302 = Pattern(Integral(sqrt(WC('a', S(0)) + WC('b', S(1))*asinh(c_ + x_**S(2)*WC('d', S(1)))), x_), cons2, cons3, cons7, cons27, cons1904) def replacement6302(b, d, c, a, x): rubi.append(6302) return Simp(x*sqrt(a + b*asinh(c + d*x**S(2))), x) - Simp(sqrt(Pi)*x*(-c*sinh(a/(S(2)*b)) + cosh(a/(S(2)*b)))*FresnelC(sqrt(-c/(Pi*b))*sqrt(a + b*asinh(c + d*x**S(2))))/(sqrt(-c/b)*(c*sinh(asinh(c + d*x**S(2))/S(2)) + cosh(asinh(c + d*x**S(2))/S(2)))), x) + Simp(sqrt(Pi)*x*(c*sinh(a/(S(2)*b)) + cosh(a/(S(2)*b)))*FresnelS(sqrt(-c/(Pi*b))*sqrt(a + b*asinh(c + d*x**S(2))))/(sqrt(-c/b)*(c*sinh(asinh(c + d*x**S(2))/S(2)) + cosh(asinh(c + d*x**S(2))/S(2)))), x) rule6302 = ReplacementRule(pattern6302, replacement6302) pattern6303 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*asinh(c_ + x_**S(2)*WC('d', S(1))))**n_, x_), cons2, cons3, cons7, cons27, cons1904, cons87, cons165) def replacement6303(b, d, c, a, n, x): rubi.append(6303) return Dist(S(4)*b**S(2)*n*(n + S(-1)), Int((a + b*asinh(c + d*x**S(2)))**(n + S(-2)), x), x) + Simp(x*(a + b*asinh(c + d*x**S(2)))**n, x) - Simp(S(2)*b*n*(a + b*asinh(c + d*x**S(2)))**(n + S(-1))*sqrt(S(2)*c*d*x**S(2) + d**S(2)*x**S(4))/(d*x), x) rule6303 = ReplacementRule(pattern6303, replacement6303) pattern6304 = Pattern(Integral(S(1)/(WC('a', S(0)) + WC('b', S(1))*asinh(c_ + x_**S(2)*WC('d', S(1)))), x_), cons2, cons3, cons7, cons27, cons1904) def replacement6304(b, d, c, a, x): rubi.append(6304) return Simp(x*(-c*sinh(a/(S(2)*b)) + cosh(a/(S(2)*b)))*SinhIntegral((a + b*asinh(c + d*x**S(2)))/(S(2)*b))/(S(2)*b*(c*sinh(asinh(c + d*x**S(2))/S(2)) + cosh(asinh(c + d*x**S(2))/S(2)))), x) + Simp(x*(c*cosh(a/(S(2)*b)) - sinh(a/(S(2)*b)))*CoshIntegral((a + b*asinh(c + d*x**S(2)))/(S(2)*b))/(S(2)*b*(c*sinh(asinh(c + d*x**S(2))/S(2)) + cosh(asinh(c + d*x**S(2))/S(2)))), x) rule6304 = ReplacementRule(pattern6304, replacement6304) pattern6305 = Pattern(Integral(S(1)/sqrt(WC('a', S(0)) + WC('b', S(1))*asinh(c_ + x_**S(2)*WC('d', S(1)))), x_), cons2, cons3, cons7, cons27, cons1904) def replacement6305(b, d, c, a, x): rubi.append(6305) return Simp(sqrt(S(2))*sqrt(Pi)*x*(c + S(-1))*(sinh(a/(S(2)*b)) + cosh(a/(S(2)*b)))*Erf(sqrt(S(2))*sqrt(a + b*asinh(c + d*x**S(2)))/(S(2)*sqrt(b)))/(S(4)*sqrt(b)*(c*sinh(asinh(c + d*x**S(2))/S(2)) + cosh(asinh(c + d*x**S(2))/S(2)))), x) + Simp(sqrt(S(2))*sqrt(Pi)*x*(c + S(1))*(-sinh(a/(S(2)*b)) + cosh(a/(S(2)*b)))*Erfi(sqrt(S(2))*sqrt(a + b*asinh(c + d*x**S(2)))/(S(2)*sqrt(b)))/(S(4)*sqrt(b)*(c*sinh(asinh(c + d*x**S(2))/S(2)) + cosh(asinh(c + d*x**S(2))/S(2)))), x) rule6305 = ReplacementRule(pattern6305, replacement6305) pattern6306 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*asinh(c_ + x_**S(2)*WC('d', S(1))))**(S(-3)/2), x_), cons2, cons3, cons7, cons27, cons1904) def replacement6306(b, d, c, a, x): rubi.append(6306) return -Simp(sqrt(S(2)*c*d*x**S(2) + d**S(2)*x**S(4))/(b*d*x*sqrt(a + b*asinh(c + d*x**S(2)))), x) - Simp(sqrt(Pi)*x*(-c/b)**(S(3)/2)*(-c*sinh(a/(S(2)*b)) + cosh(a/(S(2)*b)))*FresnelC(sqrt(-c/(Pi*b))*sqrt(a + b*asinh(c + d*x**S(2))))/(c*sinh(asinh(c + d*x**S(2))/S(2)) + cosh(asinh(c + d*x**S(2))/S(2))), x) + Simp(sqrt(Pi)*x*(-c/b)**(S(3)/2)*(c*sinh(a/(S(2)*b)) + cosh(a/(S(2)*b)))*FresnelS(sqrt(-c/(Pi*b))*sqrt(a + b*asinh(c + d*x**S(2))))/(c*sinh(asinh(c + d*x**S(2))/S(2)) + cosh(asinh(c + d*x**S(2))/S(2))), x) rule6306 = ReplacementRule(pattern6306, replacement6306) pattern6307 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*asinh(c_ + x_**S(2)*WC('d', S(1))))**(S(-2)), x_), cons2, cons3, cons7, cons27, cons1904) def replacement6307(b, d, c, a, x): rubi.append(6307) return Simp(x*(-c*sinh(a/(S(2)*b)) + cosh(a/(S(2)*b)))*CoshIntegral((a + b*asinh(c + d*x**S(2)))/(S(2)*b))/(S(4)*b**S(2)*(c*sinh(asinh(c + d*x**S(2))/S(2)) + cosh(asinh(c + d*x**S(2))/S(2)))), x) + Simp(x*(c*cosh(a/(S(2)*b)) - sinh(a/(S(2)*b)))*SinhIntegral((a + b*asinh(c + d*x**S(2)))/(S(2)*b))/(S(4)*b**S(2)*(c*sinh(asinh(c + d*x**S(2))/S(2)) + cosh(asinh(c + d*x**S(2))/S(2)))), x) - Simp(sqrt(S(2)*c*d*x**S(2) + d**S(2)*x**S(4))/(S(2)*b*d*x*(a + b*asinh(c + d*x**S(2)))), x) rule6307 = ReplacementRule(pattern6307, replacement6307) pattern6308 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*asinh(c_ + x_**S(2)*WC('d', S(1))))**n_, x_), cons2, cons3, cons7, cons27, cons1904, cons87, cons89, cons1442) def replacement6308(b, d, c, a, n, x): rubi.append(6308) return Dist(S(1)/(S(4)*b**S(2)*(n + S(1))*(n + S(2))), Int((a + b*asinh(c + d*x**S(2)))**(n + S(2)), x), x) - Simp(x*(a + b*asinh(c + d*x**S(2)))**(n + S(2))/(S(4)*b**S(2)*(n + S(1))*(n + S(2))), x) + Simp((a + b*asinh(c + d*x**S(2)))**(n + S(1))*sqrt(S(2)*c*d*x**S(2) + d**S(2)*x**S(4))/(S(2)*b*d*x*(n + S(1))), x) rule6308 = ReplacementRule(pattern6308, replacement6308) pattern6309 = Pattern(Integral(sqrt(WC('a', S(0)) + WC('b', S(1))*acosh(x_**S(2)*WC('d', S(1)) + S(1))), x_), cons2, cons3, cons27, cons1765) def replacement6309(d, a, b, x): rubi.append(6309) return Simp(S(2)*sqrt(a + b*acosh(d*x**S(2) + S(1)))*sinh(acosh(d*x**S(2) + S(1))/S(2))**S(2)/(d*x), x) - Simp(sqrt(S(2))*sqrt(Pi)*sqrt(b)*(-sinh(a/(S(2)*b)) + cosh(a/(S(2)*b)))*Erfi(sqrt(S(2))*sqrt(a + b*acosh(d*x**S(2) + S(1)))/(S(2)*sqrt(b)))*sinh(acosh(d*x**S(2) + S(1))/S(2))/(S(2)*d*x), x) + Simp(sqrt(S(2))*sqrt(Pi)*sqrt(b)*(sinh(a/(S(2)*b)) + cosh(a/(S(2)*b)))*Erf(sqrt(S(2))*sqrt(a + b*acosh(d*x**S(2) + S(1)))/(S(2)*sqrt(b)))*sinh(acosh(d*x**S(2) + S(1))/S(2))/(S(2)*d*x), x) rule6309 = ReplacementRule(pattern6309, replacement6309) pattern6310 = Pattern(Integral(sqrt(WC('a', S(0)) + WC('b', S(1))*acosh(x_**S(2)*WC('d', S(1)) + S(-1))), x_), cons2, cons3, cons27, cons1765) def replacement6310(d, a, b, x): rubi.append(6310) return Simp(S(2)*sqrt(a + b*acosh(d*x**S(2) + S(-1)))*cosh(acosh(d*x**S(2) + S(-1))/S(2))**S(2)/(d*x), x) - Simp(sqrt(S(2))*sqrt(Pi)*sqrt(b)*(-sinh(a/(S(2)*b)) + cosh(a/(S(2)*b)))*Erfi(sqrt(S(2))*sqrt(a + b*acosh(d*x**S(2) + S(-1)))/(S(2)*sqrt(b)))*cosh(acosh(d*x**S(2) + S(-1))/S(2))/(S(2)*d*x), x) - Simp(sqrt(S(2))*sqrt(Pi)*sqrt(b)*(sinh(a/(S(2)*b)) + cosh(a/(S(2)*b)))*Erf(sqrt(S(2))*sqrt(a + b*acosh(d*x**S(2) + S(-1)))/(S(2)*sqrt(b)))*cosh(acosh(d*x**S(2) + S(-1))/S(2))/(S(2)*d*x), x) rule6310 = ReplacementRule(pattern6310, replacement6310) pattern6311 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*acosh(c_ + x_**S(2)*WC('d', S(1))))**n_, x_), cons2, cons3, cons7, cons27, cons1764, cons87, cons165) def replacement6311(b, d, c, a, n, x): rubi.append(6311) return Dist(S(4)*b**S(2)*n*(n + S(-1)), Int((a + b*acosh(c + d*x**S(2)))**(n + S(-2)), x), x) + Simp(x*(a + b*acosh(c + d*x**S(2)))**n, x) - Simp(S(2)*b*n*(a + b*acosh(c + d*x**S(2)))**(n + S(-1))*(S(2)*c*d*x**S(2) + d**S(2)*x**S(4))/(d*x*sqrt(c + d*x**S(2) + S(-1))*sqrt(c + d*x**S(2) + S(1))), x) rule6311 = ReplacementRule(pattern6311, replacement6311) pattern6312 = Pattern(Integral(S(1)/(WC('a', S(0)) + WC('b', S(1))*acosh(x_**S(2)*WC('d', S(1)) + S(1))), x_), cons2, cons3, cons27, cons1765) def replacement6312(d, a, b, x): rubi.append(6312) return Simp(sqrt(S(2))*x*CoshIntegral((a + b*acosh(d*x**S(2) + S(1)))/(S(2)*b))*cosh(a/(S(2)*b))/(S(2)*b*sqrt(d*x**S(2))), x) - Simp(sqrt(S(2))*x*SinhIntegral((a + b*acosh(d*x**S(2) + S(1)))/(S(2)*b))*sinh(a/(S(2)*b))/(S(2)*b*sqrt(d*x**S(2))), x) rule6312 = ReplacementRule(pattern6312, replacement6312) pattern6313 = Pattern(Integral(S(1)/(WC('a', S(0)) + WC('b', S(1))*acosh(x_**S(2)*WC('d', S(1)) + S(-1))), x_), cons2, cons3, cons27, cons1765) def replacement6313(d, a, b, x): rubi.append(6313) return -Simp(sqrt(S(2))*x*CoshIntegral((a + b*acosh(d*x**S(2) + S(-1)))/(S(2)*b))*sinh(a/(S(2)*b))/(S(2)*b*sqrt(d*x**S(2))), x) + Simp(sqrt(S(2))*x*SinhIntegral((a + b*acosh(d*x**S(2) + S(-1)))/(S(2)*b))*cosh(a/(S(2)*b))/(S(2)*b*sqrt(d*x**S(2))), x) rule6313 = ReplacementRule(pattern6313, replacement6313) pattern6314 = Pattern(Integral(S(1)/sqrt(WC('a', S(0)) + WC('b', S(1))*acosh(x_**S(2)*WC('d', S(1)) + S(1))), x_), cons2, cons3, cons27, cons1765) def replacement6314(d, a, b, x): rubi.append(6314) return Simp(sqrt(S(2))*sqrt(Pi)*(-sinh(a/(S(2)*b)) + cosh(a/(S(2)*b)))*Erfi(sqrt(S(2))*sqrt(a + b*acosh(d*x**S(2) + S(1)))/(S(2)*sqrt(b)))*sinh(acosh(d*x**S(2) + S(1))/S(2))/(S(2)*sqrt(b)*d*x), x) + Simp(sqrt(S(2))*sqrt(Pi)*(sinh(a/(S(2)*b)) + cosh(a/(S(2)*b)))*Erf(sqrt(S(2))*sqrt(a + b*acosh(d*x**S(2) + S(1)))/(S(2)*sqrt(b)))*sinh(acosh(d*x**S(2) + S(1))/S(2))/(S(2)*sqrt(b)*d*x), x) rule6314 = ReplacementRule(pattern6314, replacement6314) pattern6315 = Pattern(Integral(S(1)/sqrt(WC('a', S(0)) + WC('b', S(1))*acosh(x_**S(2)*WC('d', S(1)) + S(-1))), x_), cons2, cons3, cons27, cons1765) def replacement6315(d, a, b, x): rubi.append(6315) return Simp(sqrt(S(2))*sqrt(Pi)*(-sinh(a/(S(2)*b)) + cosh(a/(S(2)*b)))*Erfi(sqrt(S(2))*sqrt(a + b*acosh(d*x**S(2) + S(-1)))/(S(2)*sqrt(b)))*cosh(acosh(d*x**S(2) + S(-1))/S(2))/(S(2)*sqrt(b)*d*x), x) - Simp(sqrt(S(2))*sqrt(Pi)*(sinh(a/(S(2)*b)) + cosh(a/(S(2)*b)))*Erf(sqrt(S(2))*sqrt(a + b*acosh(d*x**S(2) + S(-1)))/(S(2)*sqrt(b)))*cosh(acosh(d*x**S(2) + S(-1))/S(2))/(S(2)*sqrt(b)*d*x), x) rule6315 = ReplacementRule(pattern6315, replacement6315) pattern6316 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*acosh(x_**S(2)*WC('d', S(1)) + S(1)))**(S(-3)/2), x_), cons2, cons3, cons27, cons1765) def replacement6316(d, a, b, x): rubi.append(6316) return -Simp(sqrt(d*x**S(2))*sqrt(d*x**S(2) + S(2))/(b*d*x*sqrt(a + b*acosh(d*x**S(2) + S(1)))), x) + Simp(sqrt(S(2))*sqrt(Pi)*(-sinh(a/(S(2)*b)) + cosh(a/(S(2)*b)))*Erfi(sqrt(S(2))*sqrt(a + b*acosh(d*x**S(2) + S(1)))/(S(2)*sqrt(b)))*sinh(acosh(d*x**S(2) + S(1))/S(2))/(S(2)*b**(S(3)/2)*d*x), x) - Simp(sqrt(S(2))*sqrt(Pi)*(sinh(a/(S(2)*b)) + cosh(a/(S(2)*b)))*Erf(sqrt(S(2))*sqrt(a + b*acosh(d*x**S(2) + S(1)))/(S(2)*sqrt(b)))*sinh(acosh(d*x**S(2) + S(1))/S(2))/(S(2)*b**(S(3)/2)*d*x), x) rule6316 = ReplacementRule(pattern6316, replacement6316) pattern6317 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*acosh(x_**S(2)*WC('d', S(1)) + S(-1)))**(S(-3)/2), x_), cons2, cons3, cons27, cons1765) def replacement6317(d, a, b, x): rubi.append(6317) return -Simp(sqrt(d*x**S(2))*sqrt(d*x**S(2) + S(-2))/(b*d*x*sqrt(a + b*acosh(d*x**S(2) + S(-1)))), x) + Simp(sqrt(S(2))*sqrt(Pi)*(-sinh(a/(S(2)*b)) + cosh(a/(S(2)*b)))*Erfi(sqrt(S(2))*sqrt(a + b*acosh(d*x**S(2) + S(-1)))/(S(2)*sqrt(b)))*cosh(acosh(d*x**S(2) + S(-1))/S(2))/(S(2)*b**(S(3)/2)*d*x), x) + Simp(sqrt(S(2))*sqrt(Pi)*(sinh(a/(S(2)*b)) + cosh(a/(S(2)*b)))*Erf(sqrt(S(2))*sqrt(a + b*acosh(d*x**S(2) + S(-1)))/(S(2)*sqrt(b)))*cosh(acosh(d*x**S(2) + S(-1))/S(2))/(S(2)*b**(S(3)/2)*d*x), x) rule6317 = ReplacementRule(pattern6317, replacement6317) pattern6318 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*acosh(x_**S(2)*WC('d', S(1)) + S(1)))**(S(-2)), x_), cons2, cons3, cons27, cons1765) def replacement6318(d, a, b, x): rubi.append(6318) return -Simp(sqrt(S(2))*x*CoshIntegral((a + b*acosh(d*x**S(2) + S(1)))/(S(2)*b))*sinh(a/(S(2)*b))/(S(4)*b**S(2)*sqrt(d*x**S(2))), x) + Simp(sqrt(S(2))*x*SinhIntegral((a + b*acosh(d*x**S(2) + S(1)))/(S(2)*b))*cosh(a/(S(2)*b))/(S(4)*b**S(2)*sqrt(d*x**S(2))), x) - Simp(sqrt(d*x**S(2))*sqrt(d*x**S(2) + S(2))/(S(2)*b*d*x*(a + b*acosh(d*x**S(2) + S(1)))), x) rule6318 = ReplacementRule(pattern6318, replacement6318) pattern6319 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*acosh(x_**S(2)*WC('d', S(1)) + S(-1)))**(S(-2)), x_), cons2, cons3, cons27, cons1765) def replacement6319(d, a, b, x): rubi.append(6319) return Simp(sqrt(S(2))*x*CoshIntegral((a + b*acosh(d*x**S(2) + S(-1)))/(S(2)*b))*cosh(a/(S(2)*b))/(S(4)*b**S(2)*sqrt(d*x**S(2))), x) - Simp(sqrt(S(2))*x*SinhIntegral((a + b*acosh(d*x**S(2) + S(-1)))/(S(2)*b))*sinh(a/(S(2)*b))/(S(4)*b**S(2)*sqrt(d*x**S(2))), x) - Simp(sqrt(d*x**S(2))*sqrt(d*x**S(2) + S(-2))/(S(2)*b*d*x*(a + b*acosh(d*x**S(2) + S(-1)))), x) rule6319 = ReplacementRule(pattern6319, replacement6319) pattern6320 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*acosh(c_ + x_**S(2)*WC('d', S(1))))**n_, x_), cons2, cons3, cons7, cons27, cons1764, cons87, cons89, cons1442) def replacement6320(b, d, c, a, n, x): rubi.append(6320) return Dist(S(1)/(S(4)*b**S(2)*(n + S(1))*(n + S(2))), Int((a + b*acosh(c + d*x**S(2)))**(n + S(2)), x), x) - Simp(x*(a + b*acosh(c + d*x**S(2)))**(n + S(2))/(S(4)*b**S(2)*(n + S(1))*(n + S(2))), x) + Simp((a + b*acosh(c + d*x**S(2)))**(n + S(1))*(S(2)*c*x**S(2) + d*x**S(4))/(S(2)*b*x*(n + S(1))*sqrt(c + d*x**S(2) + S(-1))*sqrt(c + d*x**S(2) + S(1))), x) rule6320 = ReplacementRule(pattern6320, replacement6320) pattern6321 = Pattern(Integral(asinh(x_**p_*WC('a', S(1)))**WC('n', S(1))/x_, x_), cons2, cons5, cons148) def replacement6321(x, a, n, p): rubi.append(6321) return Dist(S(1)/p, Subst(Int(x**n/tanh(x), x), x, asinh(a*x**p)), x) rule6321 = ReplacementRule(pattern6321, replacement6321) pattern6322 = Pattern(Integral(acosh(x_**p_*WC('a', S(1)))**WC('n', S(1))/x_, x_), cons2, cons5, cons148) def replacement6322(x, a, n, p): rubi.append(6322) return Dist(S(1)/p, Subst(Int(x**n*tanh(x), x), x, acosh(a*x**p)), x) rule6322 = ReplacementRule(pattern6322, replacement6322) pattern6323 = Pattern(Integral(WC('u', S(1))*asinh(WC('c', S(1))/(x_**WC('n', S(1))*WC('b', S(1)) + WC('a', S(0))))**WC('m', S(1)), x_), cons2, cons3, cons7, cons4, cons21, cons1766) def replacement6323(u, m, b, c, n, a, x): rubi.append(6323) return Int(u*acsch(a/c + b*x**n/c)**m, x) rule6323 = ReplacementRule(pattern6323, replacement6323) pattern6324 = Pattern(Integral(WC('u', S(1))*acosh(WC('c', S(1))/(x_**WC('n', S(1))*WC('b', S(1)) + WC('a', S(0))))**WC('m', S(1)), x_), cons2, cons3, cons7, cons4, cons21, cons1766) def replacement6324(u, m, b, c, n, a, x): rubi.append(6324) return Int(u*asech(a/c + b*x**n/c)**m, x) rule6324 = ReplacementRule(pattern6324, replacement6324) pattern6325 = Pattern(Integral(asinh(sqrt(x_**S(2)*WC('b', S(1)) + S(-1)))**WC('n', S(1))/sqrt(x_**S(2)*WC('b', S(1)) + S(-1)), x_), cons3, cons4, cons1767) def replacement6325(x, n, b): rubi.append(6325) return Dist(sqrt(b*x**S(2))/(b*x), Subst(Int(asinh(x)**n/sqrt(x**S(2) + S(1)), x), x, sqrt(b*x**S(2) + S(-1))), x) rule6325 = ReplacementRule(pattern6325, replacement6325) pattern6326 = Pattern(Integral(acosh(sqrt(x_**S(2)*WC('b', S(1)) + S(1)))**WC('n', S(1))/sqrt(x_**S(2)*WC('b', S(1)) + S(1)), x_), cons3, cons4, cons1767) def replacement6326(x, n, b): rubi.append(6326) return Dist(sqrt(sqrt(b*x**S(2) + S(1)) + S(-1))*sqrt(sqrt(b*x**S(2) + S(1)) + S(1))/(b*x), Subst(Int(acosh(x)**n/(sqrt(x + S(-1))*sqrt(x + S(1))), x), x, sqrt(b*x**S(2) + S(1))), x) rule6326 = ReplacementRule(pattern6326, replacement6326) pattern6327 = Pattern(Integral(f_**(WC('c', S(1))*asinh(x_*WC('b', S(1)) + WC('a', S(0)))**WC('n', S(1))), x_), cons2, cons3, cons7, cons125, cons148) def replacement6327(f, b, c, a, n, x): rubi.append(6327) return Dist(S(1)/b, Subst(Int(f**(c*x**n)*cosh(x), x), x, asinh(a + b*x)), x) rule6327 = ReplacementRule(pattern6327, replacement6327) pattern6328 = Pattern(Integral(f_**(WC('c', S(1))*acosh(x_*WC('b', S(1)) + WC('a', S(0)))**WC('n', S(1))), x_), cons2, cons3, cons7, cons125, cons148) def replacement6328(f, b, c, a, n, x): rubi.append(6328) return Dist(S(1)/b, Subst(Int(f**(c*x**n)*sinh(x), x), x, acosh(a + b*x)), x) rule6328 = ReplacementRule(pattern6328, replacement6328) pattern6329 = Pattern(Integral(f_**(WC('c', S(1))*asinh(x_*WC('b', S(1)) + WC('a', S(0)))**WC('n', S(1)))*x_**WC('m', S(1)), x_), cons2, cons3, cons7, cons125, cons528) def replacement6329(m, f, b, c, a, n, x): rubi.append(6329) return Dist(S(1)/b, Subst(Int(f**(c*x**n)*(-a/b + sinh(x)/b)**m*cosh(x), x), x, asinh(a + b*x)), x) rule6329 = ReplacementRule(pattern6329, replacement6329) pattern6330 = Pattern(Integral(f_**(WC('c', S(1))*acosh(x_*WC('b', S(1)) + WC('a', S(0)))**WC('n', S(1)))*x_**WC('m', S(1)), x_), cons2, cons3, cons7, cons125, cons528) def replacement6330(m, f, b, c, a, n, x): rubi.append(6330) return Dist(S(1)/b, Subst(Int(f**(c*x**n)*(-a/b + cosh(x)/b)**m*sinh(x), x), x, acosh(a + b*x)), x) rule6330 = ReplacementRule(pattern6330, replacement6330) pattern6331 = Pattern(Integral(asinh(u_), x_), cons1230, cons1769) def replacement6331(x, u): rubi.append(6331) return -Int(SimplifyIntegrand(x*D(u, x)/sqrt(u**S(2) + S(1)), x), x) + Simp(x*asinh(u), x) rule6331 = ReplacementRule(pattern6331, replacement6331) pattern6332 = Pattern(Integral(acosh(u_), x_), cons1230, cons1769) def replacement6332(x, u): rubi.append(6332) return -Int(SimplifyIntegrand(x*D(u, x)/(sqrt(u + S(-1))*sqrt(u + S(1))), x), x) + Simp(x*acosh(u), x) rule6332 = ReplacementRule(pattern6332, replacement6332) pattern6333 = Pattern(Integral((x_*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*asinh(u_)), x_), cons2, cons3, cons7, cons27, cons21, cons66, cons1230, cons1770, cons1769) def replacement6333(u, m, b, d, c, a, x): rubi.append(6333) return -Dist(b/(d*(m + S(1))), Int(SimplifyIntegrand((c + d*x)**(m + S(1))*D(u, x)/sqrt(u**S(2) + S(1)), x), x), x) + Simp((a + b*asinh(u))*(c + d*x)**(m + S(1))/(d*(m + S(1))), x) rule6333 = ReplacementRule(pattern6333, replacement6333) pattern6334 = Pattern(Integral((x_*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*acosh(u_)), x_), cons2, cons3, cons7, cons27, cons21, cons66, cons1230, cons1770, cons1769) def replacement6334(u, m, b, d, c, a, x): rubi.append(6334) return -Dist(b/(d*(m + S(1))), Int(SimplifyIntegrand((c + d*x)**(m + S(1))*D(u, x)/(sqrt(u + S(-1))*sqrt(u + S(1))), x), x), x) + Simp((a + b*acosh(u))*(c + d*x)**(m + S(1))/(d*(m + S(1))), x) rule6334 = ReplacementRule(pattern6334, replacement6334) def With6335(v, u, b, a, x): if isinstance(x, (int, Integer, float, Float)): return False w = IntHide(v, x) if InverseFunctionFreeQ(w, x): return True return False pattern6335 = Pattern(Integral(v_*(WC('a', S(0)) + WC('b', S(1))*asinh(u_)), x_), cons2, cons3, cons1230, cons1905, CustomConstraint(With6335)) def replacement6335(v, u, b, a, x): w = IntHide(v, x) rubi.append(6335) return -Dist(b, Int(SimplifyIntegrand(w*D(u, x)/sqrt(u**S(2) + S(1)), x), x), x) + Dist(a + b*asinh(u), w, x) rule6335 = ReplacementRule(pattern6335, replacement6335) def With6336(v, u, b, a, x): if isinstance(x, (int, Integer, float, Float)): return False w = IntHide(v, x) if InverseFunctionFreeQ(w, x): return True return False pattern6336 = Pattern(Integral(v_*(WC('a', S(0)) + WC('b', S(1))*acosh(u_)), x_), cons2, cons3, cons1230, cons1906, CustomConstraint(With6336)) def replacement6336(v, u, b, a, x): w = IntHide(v, x) rubi.append(6336) return -Dist(b, Int(SimplifyIntegrand(w*D(u, x)/(sqrt(u + S(-1))*sqrt(u + S(1))), x), x), x) + Dist(a + b*acosh(u), w, x) rule6336 = ReplacementRule(pattern6336, replacement6336) pattern6337 = Pattern(Integral(exp(WC('n', S(1))*asinh(u_)), x_), cons85, cons804) def replacement6337(x, n, u): rubi.append(6337) return Int((u + sqrt(u**S(2) + S(1)))**n, x) rule6337 = ReplacementRule(pattern6337, replacement6337) pattern6338 = Pattern(Integral(x_**WC('m', S(1))*exp(WC('n', S(1))*asinh(u_)), x_), cons31, cons85, cons804) def replacement6338(x, m, n, u): rubi.append(6338) return Int(x**m*(u + sqrt(u**S(2) + S(1)))**n, x) rule6338 = ReplacementRule(pattern6338, replacement6338) pattern6339 = Pattern(Integral(exp(WC('n', S(1))*acosh(u_)), x_), cons85, cons804) def replacement6339(x, n, u): rubi.append(6339) return Int((u + sqrt(u + S(-1))*sqrt(u + S(1)))**n, x) rule6339 = ReplacementRule(pattern6339, replacement6339) pattern6340 = Pattern(Integral(x_**WC('m', S(1))*exp(WC('n', S(1))*acosh(u_)), x_), cons31, cons85, cons804) def replacement6340(x, m, n, u): rubi.append(6340) return Int(x**m*(u + sqrt(u + S(-1))*sqrt(u + S(1)))**n, x) rule6340 = ReplacementRule(pattern6340, replacement6340) pattern6341 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*atanh(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons148) def replacement6341(b, a, n, c, x): rubi.append(6341) return -Dist(b*c*n, Int(x*(a + b*atanh(c*x))**(n + S(-1))/(-c**S(2)*x**S(2) + S(1)), x), x) + Simp(x*(a + b*atanh(c*x))**n, x) rule6341 = ReplacementRule(pattern6341, replacement6341) pattern6342 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*acoth(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons148) def replacement6342(b, a, n, c, x): rubi.append(6342) return -Dist(b*c*n, Int(x*(a + b*acoth(c*x))**(n + S(-1))/(-c**S(2)*x**S(2) + S(1)), x), x) + Simp(x*(a + b*acoth(c*x))**n, x) rule6342 = ReplacementRule(pattern6342, replacement6342) pattern6343 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*atanh(x_*WC('c', S(1))))**n_, x_), cons2, cons3, cons7, cons4, cons340) def replacement6343(b, a, n, c, x): rubi.append(6343) return Int((a + b*atanh(c*x))**n, x) rule6343 = ReplacementRule(pattern6343, replacement6343) pattern6344 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*acoth(x_*WC('c', S(1))))**n_, x_), cons2, cons3, cons7, cons4, cons340) def replacement6344(b, a, n, c, x): rubi.append(6344) return Int((a + b*acoth(c*x))**n, x) rule6344 = ReplacementRule(pattern6344, replacement6344) pattern6345 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*atanh(x_*WC('c', S(1))))**WC('n', S(1))/(d_ + x_*WC('e', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons1907, cons148) def replacement6345(b, d, a, n, c, x, e): rubi.append(6345) return Dist(b*c*n/e, Int((a + b*atanh(c*x))**(n + S(-1))*log(S(2)*d/(d + e*x))/(-c**S(2)*x**S(2) + S(1)), x), x) - Simp((a + b*atanh(c*x))**n*log(S(2)*d/(d + e*x))/e, x) rule6345 = ReplacementRule(pattern6345, replacement6345) pattern6346 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*acoth(x_*WC('c', S(1))))**WC('n', S(1))/(d_ + x_*WC('e', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons1907, cons148) def replacement6346(b, d, a, n, c, x, e): rubi.append(6346) return Dist(b*c*n/e, Int((a + b*acoth(c*x))**(n + S(-1))*log(S(2)*d/(d + e*x))/(-c**S(2)*x**S(2) + S(1)), x), x) - Simp((a + b*acoth(c*x))**n*log(S(2)*d/(d + e*x))/e, x) rule6346 = ReplacementRule(pattern6346, replacement6346) pattern6347 = Pattern(Integral(atanh(x_*WC('c', S(1)))/(d_ + x_*WC('e', S(1))), x_), cons7, cons27, cons48, cons1908, cons1909) def replacement6347(x, d, c, e): rubi.append(6347) return -Simp(PolyLog(S(2), Simp(c*(d + e*x)/(c*d - e), x))/(S(2)*e), x) + Simp(PolyLog(S(2), Simp(c*(d + e*x)/(c*d + e), x))/(S(2)*e), x) - Simp(log(d + e*x)*atanh(c*d/e)/e, x) rule6347 = ReplacementRule(pattern6347, replacement6347) pattern6348 = Pattern(Integral(atanh(x_*WC('c', S(1)))/(x_*WC('e', S(1)) + WC('d', S(0))), x_), cons7, cons27, cons48, cons1776) def replacement6348(d, c, x, e): rubi.append(6348) return -Dist(S(1)/2, Int(log(-c*x + S(1))/(d + e*x), x), x) + Dist(S(1)/2, Int(log(c*x + S(1))/(d + e*x), x), x) rule6348 = ReplacementRule(pattern6348, replacement6348) pattern6349 = Pattern(Integral(acoth(x_*WC('c', S(1)))/(x_*WC('e', S(1)) + WC('d', S(0))), x_), cons7, cons27, cons48, cons1776) def replacement6349(d, c, x, e): rubi.append(6349) return -Dist(S(1)/2, Int(log(S(1) - S(1)/(c*x))/(d + e*x), x), x) + Dist(S(1)/2, Int(log(S(1) + S(1)/(c*x))/(d + e*x), x), x) rule6349 = ReplacementRule(pattern6349, replacement6349) pattern6350 = Pattern(Integral((a_ + WC('b', S(1))*atanh(x_*WC('c', S(1))))/(x_*WC('e', S(1)) + WC('d', S(0))), x_), cons2, cons3, cons7, cons27, cons48, cons1043) def replacement6350(b, d, c, a, x, e): rubi.append(6350) return Dist(b, Int(atanh(c*x)/(d + e*x), x), x) + Simp(a*log(RemoveContent(d + e*x, x))/e, x) rule6350 = ReplacementRule(pattern6350, replacement6350) pattern6351 = Pattern(Integral((a_ + WC('b', S(1))*acoth(x_*WC('c', S(1))))/(x_*WC('e', S(1)) + WC('d', S(0))), x_), cons2, cons3, cons7, cons27, cons48, cons1043) def replacement6351(b, d, c, a, x, e): rubi.append(6351) return Dist(b, Int(acoth(c*x)/(d + e*x), x), x) + Simp(a*log(RemoveContent(d + e*x, x))/e, x) rule6351 = ReplacementRule(pattern6351, replacement6351) pattern6352 = Pattern(Integral((x_*WC('e', S(1)) + WC('d', S(0)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*atanh(x_*WC('c', S(1)))), x_), cons2, cons3, cons7, cons27, cons48, cons5, cons54) def replacement6352(p, b, d, a, c, x, e): rubi.append(6352) return -Dist(b*c/(e*(p + S(1))), Int((d + e*x)**(p + S(1))/(-c**S(2)*x**S(2) + S(1)), x), x) + Simp((a + b*atanh(c*x))*(d + e*x)**(p + S(1))/(e*(p + S(1))), x) rule6352 = ReplacementRule(pattern6352, replacement6352) pattern6353 = Pattern(Integral((x_*WC('e', S(1)) + WC('d', S(0)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*acoth(x_*WC('c', S(1)))), x_), cons2, cons3, cons7, cons27, cons48, cons5, cons54) def replacement6353(p, b, d, a, c, x, e): rubi.append(6353) return -Dist(b*c/(e*(p + S(1))), Int((d + e*x)**(p + S(1))/(-c**S(2)*x**S(2) + S(1)), x), x) + Simp((a + b*acoth(c*x))*(d + e*x)**(p + S(1))/(e*(p + S(1))), x) rule6353 = ReplacementRule(pattern6353, replacement6353) pattern6354 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*atanh(x_*WC('c', S(1))))**n_/x_, x_), cons2, cons3, cons7, cons85, cons165) def replacement6354(b, a, n, c, x): rubi.append(6354) return -Dist(S(2)*b*c*n, Int((a + b*atanh(c*x))**(n + S(-1))*atanh(S(1) - S(2)/(-c*x + S(1)))/(-c**S(2)*x**S(2) + S(1)), x), x) + Simp(S(2)*(a + b*atanh(c*x))**n*atanh(S(1) - S(2)/(-c*x + S(1))), x) rule6354 = ReplacementRule(pattern6354, replacement6354) pattern6355 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*acoth(x_*WC('c', S(1))))**n_/x_, x_), cons2, cons3, cons7, cons85, cons165) def replacement6355(b, a, n, c, x): rubi.append(6355) return -Dist(S(2)*b*c*n, Int((a + b*acoth(c*x))**(n + S(-1))*acoth(S(1) - S(2)/(-c*x + S(1)))/(-c**S(2)*x**S(2) + S(1)), x), x) + Simp(S(2)*(a + b*acoth(c*x))**n*acoth(S(1) - S(2)/(-c*x + S(1))), x) rule6355 = ReplacementRule(pattern6355, replacement6355) pattern6356 = Pattern(Integral(x_**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*atanh(x_*WC('c', S(1))))**n_, x_), cons2, cons3, cons7, cons21, cons85, cons165, cons66) def replacement6356(m, b, a, c, n, x): rubi.append(6356) return -Dist(b*c*n/(m + S(1)), Int(x**(m + S(1))*(a + b*atanh(c*x))**(n + S(-1))/(-c**S(2)*x**S(2) + S(1)), x), x) + Simp(x**(m + S(1))*(a + b*atanh(c*x))**n/(m + S(1)), x) rule6356 = ReplacementRule(pattern6356, replacement6356) pattern6357 = Pattern(Integral(x_**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*acoth(x_*WC('c', S(1))))**n_, x_), cons2, cons3, cons7, cons21, cons85, cons165, cons66) def replacement6357(m, b, a, c, n, x): rubi.append(6357) return -Dist(b*c*n/(m + S(1)), Int(x**(m + S(1))*(a + b*acoth(c*x))**(n + S(-1))/(-c**S(2)*x**S(2) + S(1)), x), x) + Simp(x**(m + S(1))*(a + b*acoth(c*x))**n/(m + S(1)), x) rule6357 = ReplacementRule(pattern6357, replacement6357) pattern6358 = Pattern(Integral((d_ + x_*WC('e', S(1)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*atanh(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons464) def replacement6358(p, b, d, a, n, c, x, e): rubi.append(6358) return Int(ExpandIntegrand((a + b*atanh(c*x))**n*(d + e*x)**p, x), x) rule6358 = ReplacementRule(pattern6358, replacement6358) pattern6359 = Pattern(Integral((d_ + x_*WC('e', S(1)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*acoth(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons464) def replacement6359(p, b, d, a, n, c, x, e): rubi.append(6359) return Int(ExpandIntegrand((a + b*acoth(c*x))**n*(d + e*x)**p, x), x) rule6359 = ReplacementRule(pattern6359, replacement6359) pattern6360 = Pattern(Integral((x_*WC('e', S(1)) + WC('d', S(0)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*atanh(x_*WC('c', S(1))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons4, cons5, cons340) def replacement6360(p, b, d, a, c, n, x, e): rubi.append(6360) return Int((a + b*atanh(c*x))**n*(d + e*x)**p, x) rule6360 = ReplacementRule(pattern6360, replacement6360) pattern6361 = Pattern(Integral((x_*WC('e', S(1)) + WC('d', S(0)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*acoth(x_*WC('c', S(1))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons4, cons5, cons340) def replacement6361(p, b, d, a, c, n, x, e): rubi.append(6361) return Int((a + b*acoth(c*x))**n*(d + e*x)**p, x) rule6361 = ReplacementRule(pattern6361, replacement6361) pattern6362 = Pattern(Integral(x_**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*atanh(x_*WC('c', S(1))))**WC('n', S(1))/(d_ + x_*WC('e', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons1907, cons148, cons31, cons168) def replacement6362(m, b, d, a, n, c, x, e): rubi.append(6362) return Dist(S(1)/e, Int(x**(m + S(-1))*(a + b*atanh(c*x))**n, x), x) - Dist(d/e, Int(x**(m + S(-1))*(a + b*atanh(c*x))**n/(d + e*x), x), x) rule6362 = ReplacementRule(pattern6362, replacement6362) pattern6363 = Pattern(Integral(x_**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*acoth(x_*WC('c', S(1))))**WC('n', S(1))/(d_ + x_*WC('e', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons1907, cons148, cons31, cons168) def replacement6363(m, b, d, a, n, c, x, e): rubi.append(6363) return Dist(S(1)/e, Int(x**(m + S(-1))*(a + b*acoth(c*x))**n, x), x) - Dist(d/e, Int(x**(m + S(-1))*(a + b*acoth(c*x))**n/(d + e*x), x), x) rule6363 = ReplacementRule(pattern6363, replacement6363) pattern6364 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*atanh(x_*WC('c', S(1))))**WC('n', S(1))/(x_*(d_ + x_*WC('e', S(1)))), x_), cons2, cons3, cons7, cons27, cons48, cons1907, cons148) def replacement6364(b, d, a, n, c, x, e): rubi.append(6364) return -Dist(b*c*n/d, Int((a + b*atanh(c*x))**(n + S(-1))*log(S(2)*e*x/(d + e*x))/(-c**S(2)*x**S(2) + S(1)), x), x) + Simp((a + b*atanh(c*x))**n*log(S(2)*e*x/(d + e*x))/d, x) rule6364 = ReplacementRule(pattern6364, replacement6364) pattern6365 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*acoth(x_*WC('c', S(1))))**WC('n', S(1))/(x_*(d_ + x_*WC('e', S(1)))), x_), cons2, cons3, cons7, cons27, cons48, cons1907, cons148) def replacement6365(b, d, a, n, c, x, e): rubi.append(6365) return -Dist(b*c*n/d, Int((a + b*acoth(c*x))**(n + S(-1))*log(S(2)*e*x/(d + e*x))/(-c**S(2)*x**S(2) + S(1)), x), x) + Simp((a + b*acoth(c*x))**n*log(S(2)*e*x/(d + e*x))/d, x) rule6365 = ReplacementRule(pattern6365, replacement6365) pattern6366 = Pattern(Integral(x_**m_*(WC('a', S(0)) + WC('b', S(1))*atanh(x_*WC('c', S(1))))**WC('n', S(1))/(d_ + x_*WC('e', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons1907, cons148, cons31, cons94) def replacement6366(m, b, d, a, n, c, x, e): rubi.append(6366) return Dist(S(1)/d, Int(x**m*(a + b*atanh(c*x))**n, x), x) - Dist(e/d, Int(x**(m + S(1))*(a + b*atanh(c*x))**n/(d + e*x), x), x) rule6366 = ReplacementRule(pattern6366, replacement6366) pattern6367 = Pattern(Integral(x_**m_*(WC('a', S(0)) + WC('b', S(1))*acoth(x_*WC('c', S(1))))**WC('n', S(1))/(d_ + x_*WC('e', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons1907, cons148, cons31, cons94) def replacement6367(m, b, d, a, n, c, x, e): rubi.append(6367) return Dist(S(1)/d, Int(x**m*(a + b*acoth(c*x))**n, x), x) - Dist(e/d, Int(x**(m + S(1))*(a + b*acoth(c*x))**n/(d + e*x), x), x) rule6367 = ReplacementRule(pattern6367, replacement6367) pattern6368 = Pattern(Integral(x_**WC('m', S(1))*(d_ + x_*WC('e', S(1)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*atanh(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons21, cons38, cons148, cons1777) def replacement6368(p, m, b, d, a, n, c, x, e): rubi.append(6368) return Int(ExpandIntegrand(x**m*(a + b*atanh(c*x))**n*(d + e*x)**p, x), x) rule6368 = ReplacementRule(pattern6368, replacement6368) pattern6369 = Pattern(Integral(x_**WC('m', S(1))*(d_ + x_*WC('e', S(1)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*acoth(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons21, cons38, cons148, cons1777) def replacement6369(p, m, b, d, a, n, c, x, e): rubi.append(6369) return Int(ExpandIntegrand(x**m*(a + b*acoth(c*x))**n*(d + e*x)**p, x), x) rule6369 = ReplacementRule(pattern6369, replacement6369) pattern6370 = Pattern(Integral(x_**WC('m', S(1))*(x_*WC('e', S(1)) + WC('d', S(0)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*atanh(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons21, cons4, cons5, cons1497) def replacement6370(p, m, b, d, a, n, c, x, e): rubi.append(6370) return Int(x**m*(a + b*atanh(c*x))**n*(d + e*x)**p, x) rule6370 = ReplacementRule(pattern6370, replacement6370) pattern6371 = Pattern(Integral(x_**WC('m', S(1))*(x_*WC('e', S(1)) + WC('d', S(0)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*acoth(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons21, cons4, cons5, cons1497) def replacement6371(p, m, b, d, a, n, c, x, e): rubi.append(6371) return Int(x**m*(a + b*acoth(c*x))**n*(d + e*x)**p, x) rule6371 = ReplacementRule(pattern6371, replacement6371) pattern6372 = Pattern(Integral((d_ + x_**S(2)*WC('e', S(1)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*atanh(x_*WC('c', S(1)))), x_), cons2, cons3, cons7, cons27, cons48, cons1737, cons13, cons163) def replacement6372(p, b, d, a, c, x, e): rubi.append(6372) return Dist(S(2)*d*p/(S(2)*p + S(1)), Int((a + b*atanh(c*x))*(d + e*x**S(2))**(p + S(-1)), x), x) + Simp(x*(a + b*atanh(c*x))*(d + e*x**S(2))**p/(S(2)*p + S(1)), x) + Simp(b*(d + e*x**S(2))**p/(S(2)*c*p*(S(2)*p + S(1))), x) rule6372 = ReplacementRule(pattern6372, replacement6372) pattern6373 = Pattern(Integral((d_ + x_**S(2)*WC('e', S(1)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*acoth(x_*WC('c', S(1)))), x_), cons2, cons3, cons7, cons27, cons48, cons1737, cons13, cons163) def replacement6373(p, b, d, a, c, x, e): rubi.append(6373) return Dist(S(2)*d*p/(S(2)*p + S(1)), Int((a + b*acoth(c*x))*(d + e*x**S(2))**(p + S(-1)), x), x) + Simp(x*(a + b*acoth(c*x))*(d + e*x**S(2))**p/(S(2)*p + S(1)), x) + Simp(b*(d + e*x**S(2))**p/(S(2)*c*p*(S(2)*p + S(1))), x) rule6373 = ReplacementRule(pattern6373, replacement6373) pattern6374 = Pattern(Integral((d_ + x_**S(2)*WC('e', S(1)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*atanh(x_*WC('c', S(1))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons1737, cons338, cons163, cons165) def replacement6374(p, b, d, a, c, n, x, e): rubi.append(6374) return Dist(S(2)*d*p/(S(2)*p + S(1)), Int((a + b*atanh(c*x))**n*(d + e*x**S(2))**(p + S(-1)), x), x) - Dist(b**S(2)*d*n*(n + S(-1))/(S(2)*p*(S(2)*p + S(1))), Int((a + b*atanh(c*x))**(n + S(-2))*(d + e*x**S(2))**(p + S(-1)), x), x) + Simp(x*(a + b*atanh(c*x))**n*(d + e*x**S(2))**p/(S(2)*p + S(1)), x) + Simp(b*n*(a + b*atanh(c*x))**(n + S(-1))*(d + e*x**S(2))**p/(S(2)*c*p*(S(2)*p + S(1))), x) rule6374 = ReplacementRule(pattern6374, replacement6374) pattern6375 = Pattern(Integral((d_ + x_**S(2)*WC('e', S(1)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*acoth(x_*WC('c', S(1))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons1737, cons338, cons163, cons165) def replacement6375(p, b, d, a, c, n, x, e): rubi.append(6375) return Dist(S(2)*d*p/(S(2)*p + S(1)), Int((a + b*acoth(c*x))**n*(d + e*x**S(2))**(p + S(-1)), x), x) - Dist(b**S(2)*d*n*(n + S(-1))/(S(2)*p*(S(2)*p + S(1))), Int((a + b*acoth(c*x))**(n + S(-2))*(d + e*x**S(2))**(p + S(-1)), x), x) + Simp(x*(a + b*acoth(c*x))**n*(d + e*x**S(2))**p/(S(2)*p + S(1)), x) + Simp(b*n*(a + b*acoth(c*x))**(n + S(-1))*(d + e*x**S(2))**p/(S(2)*c*p*(S(2)*p + S(1))), x) rule6375 = ReplacementRule(pattern6375, replacement6375) pattern6376 = Pattern(Integral(S(1)/((d_ + x_**S(2)*WC('e', S(1)))*(WC('a', S(0)) + WC('b', S(1))*atanh(x_*WC('c', S(1))))), x_), cons2, cons3, cons7, cons27, cons48, cons1737) def replacement6376(b, d, a, c, x, e): rubi.append(6376) return Simp(log(RemoveContent(a + b*atanh(c*x), x))/(b*c*d), x) rule6376 = ReplacementRule(pattern6376, replacement6376) pattern6377 = Pattern(Integral(S(1)/((d_ + x_**S(2)*WC('e', S(1)))*(WC('a', S(0)) + WC('b', S(1))*acoth(x_*WC('c', S(1))))), x_), cons2, cons3, cons7, cons27, cons48, cons1737) def replacement6377(b, d, a, c, x, e): rubi.append(6377) return Simp(log(RemoveContent(a + b*acoth(c*x), x))/(b*c*d), x) rule6377 = ReplacementRule(pattern6377, replacement6377) pattern6378 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*atanh(x_*WC('c', S(1))))**WC('n', S(1))/(d_ + x_**S(2)*WC('e', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons4, cons1737, cons584) def replacement6378(b, d, a, n, c, x, e): rubi.append(6378) return Simp((a + b*atanh(c*x))**(n + S(1))/(b*c*d*(n + S(1))), x) rule6378 = ReplacementRule(pattern6378, replacement6378) pattern6379 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*acoth(x_*WC('c', S(1))))**WC('n', S(1))/(d_ + x_**S(2)*WC('e', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons4, cons1737, cons584) def replacement6379(b, d, a, n, c, x, e): rubi.append(6379) return Simp((a + b*acoth(c*x))**(n + S(1))/(b*c*d*(n + S(1))), x) rule6379 = ReplacementRule(pattern6379, replacement6379) pattern6380 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*atanh(x_*WC('c', S(1))))/sqrt(d_ + x_**S(2)*WC('e', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons1737, cons268) def replacement6380(b, d, a, c, x, e): rubi.append(6380) return Simp(-S(2)*(a + b*atanh(c*x))*ArcTan(sqrt(-c*x + S(1))/sqrt(c*x + S(1)))/(c*sqrt(d)), x) - Simp(I*b*PolyLog(S(2), -I*sqrt(-c*x + S(1))/sqrt(c*x + S(1)))/(c*sqrt(d)), x) + Simp(I*b*PolyLog(S(2), I*sqrt(-c*x + S(1))/sqrt(c*x + S(1)))/(c*sqrt(d)), x) rule6380 = ReplacementRule(pattern6380, replacement6380) pattern6381 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*acoth(x_*WC('c', S(1))))/sqrt(d_ + x_**S(2)*WC('e', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons1737, cons268) def replacement6381(b, d, a, c, x, e): rubi.append(6381) return Simp(-S(2)*(a + b*acoth(c*x))*ArcTan(sqrt(-c*x + S(1))/sqrt(c*x + S(1)))/(c*sqrt(d)), x) - Simp(I*b*PolyLog(S(2), -I*sqrt(-c*x + S(1))/sqrt(c*x + S(1)))/(c*sqrt(d)), x) + Simp(I*b*PolyLog(S(2), I*sqrt(-c*x + S(1))/sqrt(c*x + S(1)))/(c*sqrt(d)), x) rule6381 = ReplacementRule(pattern6381, replacement6381) pattern6382 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*atanh(x_*WC('c', S(1))))**WC('n', S(1))/sqrt(d_ + x_**S(2)*WC('e', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons1737, cons148, cons268) def replacement6382(b, d, a, n, c, x, e): rubi.append(6382) return Dist(S(1)/(c*sqrt(d)), Subst(Int((a + b*x)**n/cosh(x), x), x, atanh(c*x)), x) rule6382 = ReplacementRule(pattern6382, replacement6382) pattern6383 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*acoth(x_*WC('c', S(1))))**WC('n', S(1))/sqrt(d_ + x_**S(2)*WC('e', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons1737, cons148, cons268) def replacement6383(b, d, a, n, c, x, e): rubi.append(6383) return -Dist(x*sqrt(S(1) - S(1)/(c**S(2)*x**S(2)))/sqrt(d + e*x**S(2)), Subst(Int((a + b*x)**n/sinh(x), x), x, acoth(c*x)), x) rule6383 = ReplacementRule(pattern6383, replacement6383) pattern6384 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*atanh(x_*WC('c', S(1))))**WC('n', S(1))/sqrt(d_ + x_**S(2)*WC('e', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons1737, cons148, cons1738) def replacement6384(b, d, a, n, c, x, e): rubi.append(6384) return Dist(sqrt(-c**S(2)*x**S(2) + S(1))/sqrt(d + e*x**S(2)), Int((a + b*atanh(c*x))**n/sqrt(-c**S(2)*x**S(2) + S(1)), x), x) rule6384 = ReplacementRule(pattern6384, replacement6384) pattern6385 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*acoth(x_*WC('c', S(1))))**WC('n', S(1))/sqrt(d_ + x_**S(2)*WC('e', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons1737, cons148, cons1738) def replacement6385(b, d, a, n, c, x, e): rubi.append(6385) return Dist(sqrt(-c**S(2)*x**S(2) + S(1))/sqrt(d + e*x**S(2)), Int((a + b*acoth(c*x))**n/sqrt(-c**S(2)*x**S(2) + S(1)), x), x) rule6385 = ReplacementRule(pattern6385, replacement6385) pattern6386 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*atanh(x_*WC('c', S(1))))**WC('n', S(1))/(d_ + x_**S(2)*WC('e', S(1)))**S(2), x_), cons2, cons3, cons7, cons27, cons48, cons1737, cons87, cons88) def replacement6386(b, d, a, n, c, x, e): rubi.append(6386) return -Dist(b*c*n/S(2), Int(x*(a + b*atanh(c*x))**(n + S(-1))/(d + e*x**S(2))**S(2), x), x) + Simp(x*(a + b*atanh(c*x))**n/(S(2)*d*(d + e*x**S(2))), x) + Simp((a + b*atanh(c*x))**(n + S(1))/(S(2)*b*c*d**S(2)*(n + S(1))), x) rule6386 = ReplacementRule(pattern6386, replacement6386) pattern6387 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*acoth(x_*WC('c', S(1))))**WC('n', S(1))/(d_ + x_**S(2)*WC('e', S(1)))**S(2), x_), cons2, cons3, cons7, cons27, cons48, cons1737, cons87, cons88) def replacement6387(b, d, a, n, c, x, e): rubi.append(6387) return -Dist(b*c*n/S(2), Int(x*(a + b*acoth(c*x))**(n + S(-1))/(d + e*x**S(2))**S(2), x), x) + Simp(x*(a + b*acoth(c*x))**n/(S(2)*d*(d + e*x**S(2))), x) + Simp((a + b*acoth(c*x))**(n + S(1))/(S(2)*b*c*d**S(2)*(n + S(1))), x) rule6387 = ReplacementRule(pattern6387, replacement6387) pattern6388 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*atanh(x_*WC('c', S(1))))/(d_ + x_**S(2)*WC('e', S(1)))**(S(3)/2), x_), cons2, cons3, cons7, cons27, cons48, cons1737) def replacement6388(b, d, a, c, x, e): rubi.append(6388) return -Simp(b/(c*d*sqrt(d + e*x**S(2))), x) + Simp(x*(a + b*atanh(c*x))/(d*sqrt(d + e*x**S(2))), x) rule6388 = ReplacementRule(pattern6388, replacement6388) pattern6389 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*acoth(x_*WC('c', S(1))))/(d_ + x_**S(2)*WC('e', S(1)))**(S(3)/2), x_), cons2, cons3, cons7, cons27, cons48, cons1737) def replacement6389(b, d, a, c, x, e): rubi.append(6389) return -Simp(b/(c*d*sqrt(d + e*x**S(2))), x) + Simp(x*(a + b*acoth(c*x))/(d*sqrt(d + e*x**S(2))), x) rule6389 = ReplacementRule(pattern6389, replacement6389) pattern6390 = Pattern(Integral((d_ + x_**S(2)*WC('e', S(1)))**p_*(WC('a', S(0)) + WC('b', S(1))*atanh(x_*WC('c', S(1)))), x_), cons2, cons3, cons7, cons27, cons48, cons1737, cons13, cons137, cons230) def replacement6390(p, b, d, a, c, x, e): rubi.append(6390) return Dist((S(2)*p + S(3))/(S(2)*d*(p + S(1))), Int((a + b*atanh(c*x))*(d + e*x**S(2))**(p + S(1)), x), x) - Simp(b*(d + e*x**S(2))**(p + S(1))/(S(4)*c*d*(p + S(1))**S(2)), x) - Simp(x*(a + b*atanh(c*x))*(d + e*x**S(2))**(p + S(1))/(S(2)*d*(p + S(1))), x) rule6390 = ReplacementRule(pattern6390, replacement6390) pattern6391 = Pattern(Integral((d_ + x_**S(2)*WC('e', S(1)))**p_*(WC('a', S(0)) + WC('b', S(1))*acoth(x_*WC('c', S(1)))), x_), cons2, cons3, cons7, cons27, cons48, cons1737, cons13, cons137, cons230) def replacement6391(p, b, d, a, c, x, e): rubi.append(6391) return Dist((S(2)*p + S(3))/(S(2)*d*(p + S(1))), Int((a + b*acoth(c*x))*(d + e*x**S(2))**(p + S(1)), x), x) - Simp(b*(d + e*x**S(2))**(p + S(1))/(S(4)*c*d*(p + S(1))**S(2)), x) - Simp(x*(a + b*acoth(c*x))*(d + e*x**S(2))**(p + S(1))/(S(2)*d*(p + S(1))), x) rule6391 = ReplacementRule(pattern6391, replacement6391) pattern6392 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*atanh(x_*WC('c', S(1))))**n_/(d_ + x_**S(2)*WC('e', S(1)))**(S(3)/2), x_), cons2, cons3, cons7, cons27, cons48, cons1737, cons87, cons165) def replacement6392(b, d, a, c, n, x, e): rubi.append(6392) return Dist(b**S(2)*n*(n + S(-1)), Int((a + b*atanh(c*x))**(n + S(-2))/(d + e*x**S(2))**(S(3)/2), x), x) + Simp(x*(a + b*atanh(c*x))**n/(d*sqrt(d + e*x**S(2))), x) - Simp(b*n*(a + b*atanh(c*x))**(n + S(-1))/(c*d*sqrt(d + e*x**S(2))), x) rule6392 = ReplacementRule(pattern6392, replacement6392) pattern6393 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*acoth(x_*WC('c', S(1))))**n_/(d_ + x_**S(2)*WC('e', S(1)))**(S(3)/2), x_), cons2, cons3, cons7, cons27, cons48, cons1737, cons87, cons165) def replacement6393(b, d, a, c, n, x, e): rubi.append(6393) return Dist(b**S(2)*n*(n + S(-1)), Int((a + b*acoth(c*x))**(n + S(-2))/(d + e*x**S(2))**(S(3)/2), x), x) + Simp(x*(a + b*acoth(c*x))**n/(d*sqrt(d + e*x**S(2))), x) - Simp(b*n*(a + b*acoth(c*x))**(n + S(-1))/(c*d*sqrt(d + e*x**S(2))), x) rule6393 = ReplacementRule(pattern6393, replacement6393) pattern6394 = Pattern(Integral((d_ + x_**S(2)*WC('e', S(1)))**p_*(WC('a', S(0)) + WC('b', S(1))*atanh(x_*WC('c', S(1))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons1737, cons338, cons137, cons165, cons230) def replacement6394(p, b, d, a, c, n, x, e): rubi.append(6394) return Dist((S(2)*p + S(3))/(S(2)*d*(p + S(1))), Int((a + b*atanh(c*x))**n*(d + e*x**S(2))**(p + S(1)), x), x) + Dist(b**S(2)*n*(n + S(-1))/(S(4)*(p + S(1))**S(2)), Int((a + b*atanh(c*x))**(n + S(-2))*(d + e*x**S(2))**p, x), x) - Simp(x*(a + b*atanh(c*x))**n*(d + e*x**S(2))**(p + S(1))/(S(2)*d*(p + S(1))), x) - Simp(b*n*(a + b*atanh(c*x))**(n + S(-1))*(d + e*x**S(2))**(p + S(1))/(S(4)*c*d*(p + S(1))**S(2)), x) rule6394 = ReplacementRule(pattern6394, replacement6394) pattern6395 = Pattern(Integral((d_ + x_**S(2)*WC('e', S(1)))**p_*(WC('a', S(0)) + WC('b', S(1))*acoth(x_*WC('c', S(1))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons1737, cons338, cons137, cons165, cons230) def replacement6395(p, b, d, a, c, n, x, e): rubi.append(6395) return Dist((S(2)*p + S(3))/(S(2)*d*(p + S(1))), Int((a + b*acoth(c*x))**n*(d + e*x**S(2))**(p + S(1)), x), x) + Dist(b**S(2)*n*(n + S(-1))/(S(4)*(p + S(1))**S(2)), Int((a + b*acoth(c*x))**(n + S(-2))*(d + e*x**S(2))**p, x), x) - Simp(x*(a + b*acoth(c*x))**n*(d + e*x**S(2))**(p + S(1))/(S(2)*d*(p + S(1))), x) - Simp(b*n*(a + b*acoth(c*x))**(n + S(-1))*(d + e*x**S(2))**(p + S(1))/(S(4)*c*d*(p + S(1))**S(2)), x) rule6395 = ReplacementRule(pattern6395, replacement6395) pattern6396 = Pattern(Integral((d_ + x_**S(2)*WC('e', S(1)))**p_*(WC('a', S(0)) + WC('b', S(1))*atanh(x_*WC('c', S(1))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons1737, cons338, cons137, cons89) def replacement6396(p, b, d, a, c, n, x, e): rubi.append(6396) return Dist(S(2)*c*(p + S(1))/(b*(n + S(1))), Int(x*(a + b*atanh(c*x))**(n + S(1))*(d + e*x**S(2))**p, x), x) + Simp((a + b*atanh(c*x))**(n + S(1))*(d + e*x**S(2))**(p + S(1))/(b*c*d*(n + S(1))), x) rule6396 = ReplacementRule(pattern6396, replacement6396) pattern6397 = Pattern(Integral((d_ + x_**S(2)*WC('e', S(1)))**p_*(WC('a', S(0)) + WC('b', S(1))*acoth(x_*WC('c', S(1))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons1737, cons338, cons137, cons89) def replacement6397(p, b, d, a, c, n, x, e): rubi.append(6397) return Dist(S(2)*c*(p + S(1))/(b*(n + S(1))), Int(x*(a + b*acoth(c*x))**(n + S(1))*(d + e*x**S(2))**p, x), x) + Simp((a + b*acoth(c*x))**(n + S(1))*(d + e*x**S(2))**(p + S(1))/(b*c*d*(n + S(1))), x) rule6397 = ReplacementRule(pattern6397, replacement6397) pattern6398 = Pattern(Integral((d_ + x_**S(2)*WC('e', S(1)))**p_*(WC('a', S(0)) + WC('b', S(1))*atanh(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons4, cons1737, cons1779, cons1740) def replacement6398(p, b, d, a, n, c, x, e): rubi.append(6398) return Dist(d**p/c, Subst(Int((a + b*x)**n*cosh(x)**(-S(2)*p + S(-2)), x), x, atanh(c*x)), x) rule6398 = ReplacementRule(pattern6398, replacement6398) pattern6399 = Pattern(Integral((d_ + x_**S(2)*WC('e', S(1)))**p_*(WC('a', S(0)) + WC('b', S(1))*atanh(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons4, cons1737, cons1779, cons1741) def replacement6399(p, b, d, a, n, c, x, e): rubi.append(6399) return Dist(d**(p + S(1)/2)*sqrt(-c**S(2)*x**S(2) + S(1))/sqrt(d + e*x**S(2)), Int((a + b*atanh(c*x))**n*(-c**S(2)*x**S(2) + S(1))**p, x), x) rule6399 = ReplacementRule(pattern6399, replacement6399) pattern6400 = Pattern(Integral((d_ + x_**S(2)*WC('e', S(1)))**p_*(WC('a', S(0)) + WC('b', S(1))*acoth(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons4, cons1737, cons1779, cons38) def replacement6400(p, b, d, a, n, c, x, e): rubi.append(6400) return -Dist((-d)**p/c, Subst(Int((a + b*x)**n*sinh(x)**(-S(2)*p + S(-2)), x), x, acoth(c*x)), x) rule6400 = ReplacementRule(pattern6400, replacement6400) pattern6401 = Pattern(Integral((d_ + x_**S(2)*WC('e', S(1)))**p_*(WC('a', S(0)) + WC('b', S(1))*acoth(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons4, cons1737, cons1779, cons147) def replacement6401(p, b, d, a, n, c, x, e): rubi.append(6401) return -Dist(x*(-d)**(p + S(1)/2)*sqrt((c**S(2)*x**S(2) + S(-1))/(c**S(2)*x**S(2)))/sqrt(d + e*x**S(2)), Subst(Int((a + b*x)**n*sinh(x)**(-S(2)*p + S(-2)), x), x, acoth(c*x)), x) rule6401 = ReplacementRule(pattern6401, replacement6401) pattern6402 = Pattern(Integral(atanh(x_*WC('c', S(1)))/(x_**S(2)*WC('e', S(1)) + WC('d', S(0))), x_), cons7, cons27, cons48, cons1776) def replacement6402(d, c, x, e): rubi.append(6402) return -Dist(S(1)/2, Int(log(-c*x + S(1))/(d + e*x**S(2)), x), x) + Dist(S(1)/2, Int(log(c*x + S(1))/(d + e*x**S(2)), x), x) rule6402 = ReplacementRule(pattern6402, replacement6402) pattern6403 = Pattern(Integral(acoth(x_*WC('c', S(1)))/(x_**S(2)*WC('e', S(1)) + WC('d', S(0))), x_), cons7, cons27, cons48, cons1776) def replacement6403(d, c, x, e): rubi.append(6403) return -Dist(S(1)/2, Int(log(S(1) - S(1)/(c*x))/(d + e*x**S(2)), x), x) + Dist(S(1)/2, Int(log(S(1) + S(1)/(c*x))/(d + e*x**S(2)), x), x) rule6403 = ReplacementRule(pattern6403, replacement6403) pattern6404 = Pattern(Integral((a_ + WC('b', S(1))*atanh(x_*WC('c', S(1))))/(x_**S(2)*WC('e', S(1)) + WC('d', S(0))), x_), cons2, cons3, cons7, cons27, cons48, cons1043) def replacement6404(b, d, c, a, x, e): rubi.append(6404) return Dist(a, Int(S(1)/(d + e*x**S(2)), x), x) + Dist(b, Int(atanh(c*x)/(d + e*x**S(2)), x), x) rule6404 = ReplacementRule(pattern6404, replacement6404) pattern6405 = Pattern(Integral((a_ + WC('b', S(1))*acoth(x_*WC('c', S(1))))/(x_**S(2)*WC('e', S(1)) + WC('d', S(0))), x_), cons2, cons3, cons7, cons27, cons48, cons1043) def replacement6405(b, d, c, a, x, e): rubi.append(6405) return Dist(a, Int(S(1)/(d + e*x**S(2)), x), x) + Dist(b, Int(acoth(c*x)/(d + e*x**S(2)), x), x) rule6405 = ReplacementRule(pattern6405, replacement6405) def With6406(p, b, d, a, c, x, e): u = IntHide((d + e*x**S(2))**p, x) rubi.append(6406) return -Dist(b*c, Int(ExpandIntegrand(u/(-c**S(2)*x**S(2) + S(1)), x), x), x) + Dist(a + b*atanh(c*x), u, x) pattern6406 = Pattern(Integral((x_**S(2)*WC('e', S(1)) + WC('d', S(0)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*atanh(x_*WC('c', S(1)))), x_), cons2, cons3, cons7, cons27, cons48, cons1780) rule6406 = ReplacementRule(pattern6406, With6406) def With6407(p, b, d, a, c, x, e): u = IntHide((d + e*x**S(2))**p, x) rubi.append(6407) return -Dist(b*c, Int(ExpandIntegrand(u/(-c**S(2)*x**S(2) + S(1)), x), x), x) + Dist(a + b*acoth(c*x), u, x) pattern6407 = Pattern(Integral((x_**S(2)*WC('e', S(1)) + WC('d', S(0)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*acoth(x_*WC('c', S(1)))), x_), cons2, cons3, cons7, cons27, cons48, cons1780) rule6407 = ReplacementRule(pattern6407, With6407) pattern6408 = Pattern(Integral((d_ + x_**S(2)*WC('e', S(1)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*atanh(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons38, cons148) def replacement6408(p, b, d, a, n, c, x, e): rubi.append(6408) return Int(ExpandIntegrand((a + b*atanh(c*x))**n*(d + e*x**S(2))**p, x), x) rule6408 = ReplacementRule(pattern6408, replacement6408) pattern6409 = Pattern(Integral((d_ + x_**S(2)*WC('e', S(1)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*acoth(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons38, cons148) def replacement6409(p, b, d, a, n, c, x, e): rubi.append(6409) return Int(ExpandIntegrand((a + b*acoth(c*x))**n*(d + e*x**S(2))**p, x), x) rule6409 = ReplacementRule(pattern6409, replacement6409) pattern6410 = Pattern(Integral((x_**S(2)*WC('e', S(1)) + WC('d', S(0)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*atanh(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons4, cons5, cons1570) def replacement6410(p, b, d, a, n, c, x, e): rubi.append(6410) return Int((a + b*atanh(c*x))**n*(d + e*x**S(2))**p, x) rule6410 = ReplacementRule(pattern6410, replacement6410) pattern6411 = Pattern(Integral((x_**S(2)*WC('e', S(1)) + WC('d', S(0)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*acoth(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons4, cons5, cons1570) def replacement6411(p, b, d, a, n, c, x, e): rubi.append(6411) return Int((a + b*acoth(c*x))**n*(d + e*x**S(2))**p, x) rule6411 = ReplacementRule(pattern6411, replacement6411) pattern6412 = Pattern(Integral(x_**m_*(WC('a', S(0)) + WC('b', S(1))*atanh(x_*WC('c', S(1))))**WC('n', S(1))/(d_ + x_**S(2)*WC('e', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons93, cons88, cons166) def replacement6412(m, b, d, a, n, c, x, e): rubi.append(6412) return Dist(S(1)/e, Int(x**(m + S(-2))*(a + b*atanh(c*x))**n, x), x) - Dist(d/e, Int(x**(m + S(-2))*(a + b*atanh(c*x))**n/(d + e*x**S(2)), x), x) rule6412 = ReplacementRule(pattern6412, replacement6412) pattern6413 = Pattern(Integral(x_**m_*(WC('a', S(0)) + WC('b', S(1))*acoth(x_*WC('c', S(1))))**WC('n', S(1))/(d_ + x_**S(2)*WC('e', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons93, cons88, cons166) def replacement6413(m, b, d, a, n, c, x, e): rubi.append(6413) return Dist(S(1)/e, Int(x**(m + S(-2))*(a + b*acoth(c*x))**n, x), x) - Dist(d/e, Int(x**(m + S(-2))*(a + b*acoth(c*x))**n/(d + e*x**S(2)), x), x) rule6413 = ReplacementRule(pattern6413, replacement6413) pattern6414 = Pattern(Integral(x_**m_*(WC('a', S(0)) + WC('b', S(1))*atanh(x_*WC('c', S(1))))**WC('n', S(1))/(d_ + x_**S(2)*WC('e', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons93, cons88, cons94) def replacement6414(m, b, d, a, n, c, x, e): rubi.append(6414) return Dist(S(1)/d, Int(x**m*(a + b*atanh(c*x))**n, x), x) - Dist(e/d, Int(x**(m + S(2))*(a + b*atanh(c*x))**n/(d + e*x**S(2)), x), x) rule6414 = ReplacementRule(pattern6414, replacement6414) pattern6415 = Pattern(Integral(x_**m_*(WC('a', S(0)) + WC('b', S(1))*acoth(x_*WC('c', S(1))))**WC('n', S(1))/(d_ + x_**S(2)*WC('e', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons93, cons88, cons94) def replacement6415(m, b, d, a, n, c, x, e): rubi.append(6415) return Dist(S(1)/d, Int(x**m*(a + b*acoth(c*x))**n, x), x) - Dist(e/d, Int(x**(m + S(2))*(a + b*acoth(c*x))**n/(d + e*x**S(2)), x), x) rule6415 = ReplacementRule(pattern6415, replacement6415) pattern6416 = Pattern(Integral(x_*(WC('a', S(0)) + WC('b', S(1))*atanh(x_*WC('c', S(1))))**WC('n', S(1))/(d_ + x_**S(2)*WC('e', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons1737, cons148) def replacement6416(b, d, a, n, c, x, e): rubi.append(6416) return Dist(S(1)/(c*d), Int((a + b*atanh(c*x))**n/(-c*x + S(1)), x), x) + Simp((a + b*atanh(c*x))**(n + S(1))/(b*e*(n + S(1))), x) rule6416 = ReplacementRule(pattern6416, replacement6416) pattern6417 = Pattern(Integral(x_*(WC('a', S(0)) + WC('b', S(1))*acoth(x_*WC('c', S(1))))**WC('n', S(1))/(d_ + x_**S(2)*WC('e', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons1737, cons148) def replacement6417(b, d, a, n, c, x, e): rubi.append(6417) return Dist(S(1)/(c*d), Int((a + b*acoth(c*x))**n/(-c*x + S(1)), x), x) + Simp((a + b*acoth(c*x))**(n + S(1))/(b*e*(n + S(1))), x) rule6417 = ReplacementRule(pattern6417, replacement6417) pattern6418 = Pattern(Integral(x_*(WC('a', S(0)) + WC('b', S(1))*atanh(x_*WC('c', S(1))))**n_/(d_ + x_**S(2)*WC('e', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons1737, cons340, cons584) def replacement6418(b, d, a, c, n, x, e): rubi.append(6418) return -Dist(S(1)/(b*c*d*(n + S(1))), Int((a + b*atanh(c*x))**(n + S(1)), x), x) + Simp(x*(a + b*atanh(c*x))**(n + S(1))/(b*c*d*(n + S(1))), x) rule6418 = ReplacementRule(pattern6418, replacement6418) pattern6419 = Pattern(Integral(x_*(WC('a', S(0)) + WC('b', S(1))*acoth(x_*WC('c', S(1))))**n_/(d_ + x_**S(2)*WC('e', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons1737, cons340, cons584) def replacement6419(b, d, a, c, n, x, e): rubi.append(6419) return -Dist(S(1)/(b*c*d*(n + S(1))), Int((a + b*acoth(c*x))**(n + S(1)), x), x) - Simp(x*(a + b*acoth(c*x))**(n + S(1))/(b*c*d*(n + S(1))), x) rule6419 = ReplacementRule(pattern6419, replacement6419) pattern6420 = Pattern(Integral(x_**m_*(WC('a', S(0)) + WC('b', S(1))*atanh(x_*WC('c', S(1))))**WC('n', S(1))/(d_ + x_**S(2)*WC('e', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons1737, cons93, cons88, cons166) def replacement6420(m, b, d, a, n, c, x, e): rubi.append(6420) return Dist(S(1)/e, Int(x**(m + S(-2))*(a + b*atanh(c*x))**n, x), x) - Dist(d/e, Int(x**(m + S(-2))*(a + b*atanh(c*x))**n/(d + e*x**S(2)), x), x) rule6420 = ReplacementRule(pattern6420, replacement6420) pattern6421 = Pattern(Integral(x_**m_*(WC('a', S(0)) + WC('b', S(1))*acoth(x_*WC('c', S(1))))**WC('n', S(1))/(d_ + x_**S(2)*WC('e', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons1737, cons93, cons88, cons166) def replacement6421(m, b, d, a, n, c, x, e): rubi.append(6421) return Dist(S(1)/e, Int(x**(m + S(-2))*(a + b*acoth(c*x))**n, x), x) - Dist(d/e, Int(x**(m + S(-2))*(a + b*acoth(c*x))**n/(d + e*x**S(2)), x), x) rule6421 = ReplacementRule(pattern6421, replacement6421) pattern6422 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*atanh(x_*WC('c', S(1))))**WC('n', S(1))/(x_*(d_ + x_**S(2)*WC('e', S(1)))), x_), cons2, cons3, cons7, cons27, cons48, cons1737, cons87, cons88) def replacement6422(b, d, a, n, c, x, e): rubi.append(6422) return Dist(S(1)/d, Int((a + b*atanh(c*x))**n/(x*(c*x + S(1))), x), x) + Simp((a + b*atanh(c*x))**(n + S(1))/(b*d*(n + S(1))), x) rule6422 = ReplacementRule(pattern6422, replacement6422) pattern6423 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*acoth(x_*WC('c', S(1))))**WC('n', S(1))/(x_*(d_ + x_**S(2)*WC('e', S(1)))), x_), cons2, cons3, cons7, cons27, cons48, cons1737, cons87, cons88) def replacement6423(b, d, a, n, c, x, e): rubi.append(6423) return Dist(S(1)/d, Int((a + b*acoth(c*x))**n/(x*(c*x + S(1))), x), x) + Simp((a + b*acoth(c*x))**(n + S(1))/(b*d*(n + S(1))), x) rule6423 = ReplacementRule(pattern6423, replacement6423) pattern6424 = Pattern(Integral(x_**m_*(WC('a', S(0)) + WC('b', S(1))*atanh(x_*WC('c', S(1))))**WC('n', S(1))/(d_ + x_**S(2)*WC('e', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons1737, cons93, cons88, cons94) def replacement6424(m, b, d, a, n, c, x, e): rubi.append(6424) return Dist(S(1)/d, Int(x**m*(a + b*atanh(c*x))**n, x), x) - Dist(e/d, Int(x**(m + S(2))*(a + b*atanh(c*x))**n/(d + e*x**S(2)), x), x) rule6424 = ReplacementRule(pattern6424, replacement6424) pattern6425 = Pattern(Integral(x_**m_*(WC('a', S(0)) + WC('b', S(1))*acoth(x_*WC('c', S(1))))**WC('n', S(1))/(d_ + x_**S(2)*WC('e', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons1737, cons93, cons88, cons94) def replacement6425(m, b, d, a, n, c, x, e): rubi.append(6425) return Dist(S(1)/d, Int(x**m*(a + b*acoth(c*x))**n, x), x) - Dist(e/d, Int(x**(m + S(2))*(a + b*acoth(c*x))**n/(d + e*x**S(2)), x), x) rule6425 = ReplacementRule(pattern6425, replacement6425) pattern6426 = Pattern(Integral(x_**m_*(WC('a', S(0)) + WC('b', S(1))*atanh(x_*WC('c', S(1))))**n_/(d_ + x_**S(2)*WC('e', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons21, cons1737, cons87, cons89) def replacement6426(m, b, d, a, c, n, x, e): rubi.append(6426) return -Dist(m/(b*c*d*(n + S(1))), Int(x**(m + S(-1))*(a + b*atanh(c*x))**(n + S(1)), x), x) + Simp(x**m*(a + b*atanh(c*x))**(n + S(1))/(b*c*d*(n + S(1))), x) rule6426 = ReplacementRule(pattern6426, replacement6426) pattern6427 = Pattern(Integral(x_**m_*(WC('a', S(0)) + WC('b', S(1))*acoth(x_*WC('c', S(1))))**n_/(d_ + x_**S(2)*WC('e', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons21, cons1737, cons87, cons89) def replacement6427(m, b, d, a, c, n, x, e): rubi.append(6427) return -Dist(m/(b*c*d*(n + S(1))), Int(x**(m + S(-1))*(a + b*acoth(c*x))**(n + S(1)), x), x) + Simp(x**m*(a + b*acoth(c*x))**(n + S(1))/(b*c*d*(n + S(1))), x) rule6427 = ReplacementRule(pattern6427, replacement6427) pattern6428 = Pattern(Integral(x_**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*atanh(x_*WC('c', S(1))))/(d_ + x_**S(2)*WC('e', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons17, cons1781) def replacement6428(m, b, d, a, c, x, e): rubi.append(6428) return Int(ExpandIntegrand(a + b*atanh(c*x), x**m/(d + e*x**S(2)), x), x) rule6428 = ReplacementRule(pattern6428, replacement6428) pattern6429 = Pattern(Integral(x_**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*acoth(x_*WC('c', S(1))))/(d_ + x_**S(2)*WC('e', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons17, cons1781) def replacement6429(m, b, d, a, c, x, e): rubi.append(6429) return Int(ExpandIntegrand(a + b*acoth(c*x), x**m/(d + e*x**S(2)), x), x) rule6429 = ReplacementRule(pattern6429, replacement6429) pattern6430 = Pattern(Integral(x_*(d_ + x_**S(2)*WC('e', S(1)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*atanh(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons5, cons1737, cons87, cons88, cons54) def replacement6430(p, b, d, a, n, c, x, e): rubi.append(6430) return Dist(b*n/(S(2)*c*(p + S(1))), Int((a + b*atanh(c*x))**(n + S(-1))*(d + e*x**S(2))**p, x), x) + Simp((a + b*atanh(c*x))**n*(d + e*x**S(2))**(p + S(1))/(S(2)*e*(p + S(1))), x) rule6430 = ReplacementRule(pattern6430, replacement6430) pattern6431 = Pattern(Integral(x_*(d_ + x_**S(2)*WC('e', S(1)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*acoth(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons5, cons1737, cons87, cons88, cons54) def replacement6431(p, b, d, a, n, c, x, e): rubi.append(6431) return Dist(b*n/(S(2)*c*(p + S(1))), Int((a + b*acoth(c*x))**(n + S(-1))*(d + e*x**S(2))**p, x), x) + Simp((a + b*acoth(c*x))**n*(d + e*x**S(2))**(p + S(1))/(S(2)*e*(p + S(1))), x) rule6431 = ReplacementRule(pattern6431, replacement6431) pattern6432 = Pattern(Integral(x_*(WC('a', S(0)) + WC('b', S(1))*atanh(x_*WC('c', S(1))))**n_/(d_ + x_**S(2)*WC('e', S(1)))**S(2), x_), cons2, cons3, cons7, cons27, cons48, cons1737, cons87, cons89, cons1442) def replacement6432(b, d, a, c, n, x, e): rubi.append(6432) return Dist(S(4)/(b**S(2)*(n + S(1))*(n + S(2))), Int(x*(a + b*atanh(c*x))**(n + S(2))/(d + e*x**S(2))**S(2), x), x) + Simp((a + b*atanh(c*x))**(n + S(2))*(c**S(2)*x**S(2) + S(1))/(b**S(2)*e*(d + e*x**S(2))*(n + S(1))*(n + S(2))), x) + Simp(x*(a + b*atanh(c*x))**(n + S(1))/(b*c*d*(d + e*x**S(2))*(n + S(1))), x) rule6432 = ReplacementRule(pattern6432, replacement6432) pattern6433 = Pattern(Integral(x_*(WC('a', S(0)) + WC('b', S(1))*acoth(x_*WC('c', S(1))))**n_/(d_ + x_**S(2)*WC('e', S(1)))**S(2), x_), cons2, cons3, cons7, cons27, cons48, cons1737, cons87, cons89, cons1442) def replacement6433(b, d, a, c, n, x, e): rubi.append(6433) return Dist(S(4)/(b**S(2)*(n + S(1))*(n + S(2))), Int(x*(a + b*acoth(c*x))**(n + S(2))/(d + e*x**S(2))**S(2), x), x) + Simp((a + b*acoth(c*x))**(n + S(2))*(c**S(2)*x**S(2) + S(1))/(b**S(2)*e*(d + e*x**S(2))*(n + S(1))*(n + S(2))), x) + Simp(x*(a + b*acoth(c*x))**(n + S(1))/(b*c*d*(d + e*x**S(2))*(n + S(1))), x) rule6433 = ReplacementRule(pattern6433, replacement6433) pattern6434 = Pattern(Integral(x_**S(2)*(d_ + x_**S(2)*WC('e', S(1)))**p_*(WC('a', S(0)) + WC('b', S(1))*atanh(x_*WC('c', S(1)))), x_), cons2, cons3, cons7, cons27, cons48, cons1737, cons13, cons137, cons1782) def replacement6434(p, b, d, a, c, x, e): rubi.append(6434) return Dist(S(1)/(S(2)*c**S(2)*d*(p + S(1))), Int((a + b*atanh(c*x))*(d + e*x**S(2))**(p + S(1)), x), x) - Simp(b*(d + e*x**S(2))**(p + S(1))/(S(4)*c**S(3)*d*(p + S(1))**S(2)), x) - Simp(x*(a + b*atanh(c*x))*(d + e*x**S(2))**(p + S(1))/(S(2)*c**S(2)*d*(p + S(1))), x) rule6434 = ReplacementRule(pattern6434, replacement6434) pattern6435 = Pattern(Integral(x_**S(2)*(d_ + x_**S(2)*WC('e', S(1)))**p_*(WC('a', S(0)) + WC('b', S(1))*acoth(x_*WC('c', S(1)))), x_), cons2, cons3, cons7, cons27, cons48, cons1737, cons13, cons137, cons1782) def replacement6435(p, b, d, a, c, x, e): rubi.append(6435) return Dist(S(1)/(S(2)*c**S(2)*d*(p + S(1))), Int((a + b*acoth(c*x))*(d + e*x**S(2))**(p + S(1)), x), x) - Simp(b*(d + e*x**S(2))**(p + S(1))/(S(4)*c**S(3)*d*(p + S(1))**S(2)), x) - Simp(x*(a + b*acoth(c*x))*(d + e*x**S(2))**(p + S(1))/(S(2)*c**S(2)*d*(p + S(1))), x) rule6435 = ReplacementRule(pattern6435, replacement6435) pattern6436 = Pattern(Integral(x_**S(2)*(WC('a', S(0)) + WC('b', S(1))*atanh(x_*WC('c', S(1))))**WC('n', S(1))/(d_ + x_**S(2)*WC('e', S(1)))**S(2), x_), cons2, cons3, cons7, cons27, cons48, cons1737, cons87, cons88) def replacement6436(b, d, a, n, c, x, e): rubi.append(6436) return -Dist(b*n/(S(2)*c), Int(x*(a + b*atanh(c*x))**(n + S(-1))/(d + e*x**S(2))**S(2), x), x) - Simp((a + b*atanh(c*x))**(n + S(1))/(S(2)*b*c**S(3)*d**S(2)*(n + S(1))), x) + Simp(x*(a + b*atanh(c*x))**n/(S(2)*c**S(2)*d*(d + e*x**S(2))), x) rule6436 = ReplacementRule(pattern6436, replacement6436) pattern6437 = Pattern(Integral(x_**S(2)*(WC('a', S(0)) + WC('b', S(1))*acoth(x_*WC('c', S(1))))**WC('n', S(1))/(d_ + x_**S(2)*WC('e', S(1)))**S(2), x_), cons2, cons3, cons7, cons27, cons48, cons1737, cons87, cons88) def replacement6437(b, d, a, n, c, x, e): rubi.append(6437) return -Dist(b*n/(S(2)*c), Int(x*(a + b*acoth(c*x))**(n + S(-1))/(d + e*x**S(2))**S(2), x), x) - Simp((a + b*acoth(c*x))**(n + S(1))/(S(2)*b*c**S(3)*d**S(2)*(n + S(1))), x) + Simp(x*(a + b*acoth(c*x))**n/(S(2)*c**S(2)*d*(d + e*x**S(2))), x) rule6437 = ReplacementRule(pattern6437, replacement6437) pattern6438 = Pattern(Integral(x_**m_*(d_ + x_**S(2)*WC('e', S(1)))**p_*(WC('a', S(0)) + WC('b', S(1))*atanh(x_*WC('c', S(1)))), x_), cons2, cons3, cons7, cons27, cons48, cons1737, cons240, cons13, cons137) def replacement6438(p, m, b, d, a, c, x, e): rubi.append(6438) return -Dist((m + S(-1))/(c**S(2)*d*m), Int(x**(m + S(-2))*(a + b*atanh(c*x))*(d + e*x**S(2))**(p + S(1)), x), x) - Simp(b*x**m*(d + e*x**S(2))**(p + S(1))/(c*d*m**S(2)), x) + Simp(x**(m + S(-1))*(a + b*atanh(c*x))*(d + e*x**S(2))**(p + S(1))/(c**S(2)*d*m), x) rule6438 = ReplacementRule(pattern6438, replacement6438) pattern6439 = Pattern(Integral(x_**m_*(d_ + x_**S(2)*WC('e', S(1)))**p_*(WC('a', S(0)) + WC('b', S(1))*acoth(x_*WC('c', S(1)))), x_), cons2, cons3, cons7, cons27, cons48, cons1737, cons240, cons13, cons137) def replacement6439(p, m, b, d, a, c, x, e): rubi.append(6439) return -Dist((m + S(-1))/(c**S(2)*d*m), Int(x**(m + S(-2))*(a + b*acoth(c*x))*(d + e*x**S(2))**(p + S(1)), x), x) - Simp(b*x**m*(d + e*x**S(2))**(p + S(1))/(c*d*m**S(2)), x) + Simp(x**(m + S(-1))*(a + b*acoth(c*x))*(d + e*x**S(2))**(p + S(1))/(c**S(2)*d*m), x) rule6439 = ReplacementRule(pattern6439, replacement6439) pattern6440 = Pattern(Integral(x_**m_*(d_ + x_**S(2)*WC('e', S(1)))**p_*(WC('a', S(0)) + WC('b', S(1))*atanh(x_*WC('c', S(1))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons21, cons1737, cons240, cons338, cons137, cons165) def replacement6440(p, m, b, d, a, c, n, x, e): rubi.append(6440) return Dist(b**S(2)*n*(n + S(-1))/m**S(2), Int(x**m*(a + b*atanh(c*x))**(n + S(-2))*(d + e*x**S(2))**p, x), x) - Dist((m + S(-1))/(c**S(2)*d*m), Int(x**(m + S(-2))*(a + b*atanh(c*x))**n*(d + e*x**S(2))**(p + S(1)), x), x) + Simp(x**(m + S(-1))*(a + b*atanh(c*x))**n*(d + e*x**S(2))**(p + S(1))/(c**S(2)*d*m), x) - Simp(b*n*x**m*(a + b*atanh(c*x))**(n + S(-1))*(d + e*x**S(2))**(p + S(1))/(c*d*m**S(2)), x) rule6440 = ReplacementRule(pattern6440, replacement6440) pattern6441 = Pattern(Integral(x_**m_*(d_ + x_**S(2)*WC('e', S(1)))**p_*(WC('a', S(0)) + WC('b', S(1))*acoth(x_*WC('c', S(1))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons21, cons1737, cons240, cons338, cons137, cons165) def replacement6441(p, m, b, d, a, c, n, x, e): rubi.append(6441) return Dist(b**S(2)*n*(n + S(-1))/m**S(2), Int(x**m*(a + b*acoth(c*x))**(n + S(-2))*(d + e*x**S(2))**p, x), x) - Dist((m + S(-1))/(c**S(2)*d*m), Int(x**(m + S(-2))*(a + b*acoth(c*x))**n*(d + e*x**S(2))**(p + S(1)), x), x) + Simp(x**(m + S(-1))*(a + b*acoth(c*x))**n*(d + e*x**S(2))**(p + S(1))/(c**S(2)*d*m), x) - Simp(b*n*x**m*(a + b*acoth(c*x))**(n + S(-1))*(d + e*x**S(2))**(p + S(1))/(c*d*m**S(2)), x) rule6441 = ReplacementRule(pattern6441, replacement6441) pattern6442 = Pattern(Integral(x_**WC('m', S(1))*(d_ + x_**S(2)*WC('e', S(1)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*atanh(x_*WC('c', S(1))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons21, cons5, cons1737, cons240, cons87, cons89) def replacement6442(p, m, b, d, a, c, n, x, e): rubi.append(6442) return -Dist(m/(b*c*(n + S(1))), Int(x**(m + S(-1))*(a + b*atanh(c*x))**(n + S(1))*(d + e*x**S(2))**p, x), x) + Simp(x**m*(a + b*atanh(c*x))**(n + S(1))*(d + e*x**S(2))**(p + S(1))/(b*c*d*(n + S(1))), x) rule6442 = ReplacementRule(pattern6442, replacement6442) pattern6443 = Pattern(Integral(x_**WC('m', S(1))*(d_ + x_**S(2)*WC('e', S(1)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*acoth(x_*WC('c', S(1))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons21, cons5, cons1737, cons240, cons87, cons89) def replacement6443(p, m, b, d, a, c, n, x, e): rubi.append(6443) return -Dist(m/(b*c*(n + S(1))), Int(x**(m + S(-1))*(a + b*acoth(c*x))**(n + S(1))*(d + e*x**S(2))**p, x), x) + Simp(x**m*(a + b*acoth(c*x))**(n + S(1))*(d + e*x**S(2))**(p + S(1))/(b*c*d*(n + S(1))), x) rule6443 = ReplacementRule(pattern6443, replacement6443) pattern6444 = Pattern(Integral(x_**WC('m', S(1))*(d_ + x_**S(2)*WC('e', S(1)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*atanh(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons21, cons5, cons1737, cons242, cons87, cons88, cons66) def replacement6444(p, m, b, d, a, n, c, x, e): rubi.append(6444) return -Dist(b*c*n/(m + S(1)), Int(x**(m + S(1))*(a + b*atanh(c*x))**(n + S(-1))*(d + e*x**S(2))**p, x), x) + Simp(x**(m + S(1))*(a + b*atanh(c*x))**n*(d + e*x**S(2))**(p + S(1))/(d*(m + S(1))), x) rule6444 = ReplacementRule(pattern6444, replacement6444) pattern6445 = Pattern(Integral(x_**WC('m', S(1))*(d_ + x_**S(2)*WC('e', S(1)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*acoth(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons21, cons5, cons1737, cons242, cons87, cons88, cons66) def replacement6445(p, m, b, d, a, n, c, x, e): rubi.append(6445) return -Dist(b*c*n/(m + S(1)), Int(x**(m + S(1))*(a + b*acoth(c*x))**(n + S(-1))*(d + e*x**S(2))**p, x), x) + Simp(x**(m + S(1))*(a + b*acoth(c*x))**n*(d + e*x**S(2))**(p + S(1))/(d*(m + S(1))), x) rule6445 = ReplacementRule(pattern6445, replacement6445) pattern6446 = Pattern(Integral(x_**m_*sqrt(d_ + x_**S(2)*WC('e', S(1)))*(WC('a', S(0)) + WC('b', S(1))*atanh(x_*WC('c', S(1)))), x_), cons2, cons3, cons7, cons27, cons48, cons21, cons1737, cons241) def replacement6446(m, b, d, a, c, x, e): rubi.append(6446) return Dist(d/(m + S(2)), Int(x**m*(a + b*atanh(c*x))/sqrt(d + e*x**S(2)), x), x) - Dist(b*c*d/(m + S(2)), Int(x**(m + S(1))/sqrt(d + e*x**S(2)), x), x) + Simp(x**(m + S(1))*(a + b*atanh(c*x))*sqrt(d + e*x**S(2))/(m + S(2)), x) rule6446 = ReplacementRule(pattern6446, replacement6446) pattern6447 = Pattern(Integral(x_**m_*sqrt(d_ + x_**S(2)*WC('e', S(1)))*(WC('a', S(0)) + WC('b', S(1))*acoth(x_*WC('c', S(1)))), x_), cons2, cons3, cons7, cons27, cons48, cons21, cons1737, cons241) def replacement6447(m, b, d, a, c, x, e): rubi.append(6447) return Dist(d/(m + S(2)), Int(x**m*(a + b*acoth(c*x))/sqrt(d + e*x**S(2)), x), x) - Dist(b*c*d/(m + S(2)), Int(x**(m + S(1))/sqrt(d + e*x**S(2)), x), x) + Simp(x**(m + S(1))*(a + b*acoth(c*x))*sqrt(d + e*x**S(2))/(m + S(2)), x) rule6447 = ReplacementRule(pattern6447, replacement6447) pattern6448 = Pattern(Integral(x_**m_*(d_ + x_**S(2)*WC('e', S(1)))**p_*(WC('a', S(0)) + WC('b', S(1))*atanh(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons21, cons1737, cons148, cons38, cons146) def replacement6448(p, m, b, d, a, n, c, x, e): rubi.append(6448) return Int(ExpandIntegrand(x**m*(a + b*atanh(c*x))**n*(d + e*x**S(2))**p, x), x) rule6448 = ReplacementRule(pattern6448, replacement6448) pattern6449 = Pattern(Integral(x_**m_*(d_ + x_**S(2)*WC('e', S(1)))**p_*(WC('a', S(0)) + WC('b', S(1))*acoth(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons21, cons1737, cons148, cons38, cons146) def replacement6449(p, m, b, d, a, n, c, x, e): rubi.append(6449) return Int(ExpandIntegrand(x**m*(a + b*acoth(c*x))**n*(d + e*x**S(2))**p, x), x) rule6449 = ReplacementRule(pattern6449, replacement6449) pattern6450 = Pattern(Integral(x_**m_*(d_ + x_**S(2)*WC('e', S(1)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*atanh(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons21, cons1737, cons13, cons163, cons148, cons1783) def replacement6450(p, m, b, d, a, n, c, x, e): rubi.append(6450) return Dist(d, Int(x**m*(a + b*atanh(c*x))**n*(d + e*x**S(2))**(p + S(-1)), x), x) - Dist(c**S(2)*d, Int(x**(m + S(2))*(a + b*atanh(c*x))**n*(d + e*x**S(2))**(p + S(-1)), x), x) rule6450 = ReplacementRule(pattern6450, replacement6450) pattern6451 = Pattern(Integral(x_**m_*(d_ + x_**S(2)*WC('e', S(1)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*acoth(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons21, cons1737, cons13, cons163, cons148, cons1783) def replacement6451(p, m, b, d, a, n, c, x, e): rubi.append(6451) return Dist(d, Int(x**m*(a + b*acoth(c*x))**n*(d + e*x**S(2))**(p + S(-1)), x), x) - Dist(c**S(2)*d, Int(x**(m + S(2))*(a + b*acoth(c*x))**n*(d + e*x**S(2))**(p + S(-1)), x), x) rule6451 = ReplacementRule(pattern6451, replacement6451) pattern6452 = Pattern(Integral(x_**m_*(WC('a', S(0)) + WC('b', S(1))*atanh(x_*WC('c', S(1))))**WC('n', S(1))/sqrt(d_ + x_**S(2)*WC('e', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons1737, cons93, cons88, cons166) def replacement6452(m, b, d, a, n, c, x, e): rubi.append(6452) return Dist((m + S(-1))/(c**S(2)*m), Int(x**(m + S(-2))*(a + b*atanh(c*x))**n/sqrt(d + e*x**S(2)), x), x) + Dist(b*n/(c*m), Int(x**(m + S(-1))*(a + b*atanh(c*x))**(n + S(-1))/sqrt(d + e*x**S(2)), x), x) - Simp(x**(m + S(-1))*(a + b*atanh(c*x))**n*sqrt(d + e*x**S(2))/(c**S(2)*d*m), x) rule6452 = ReplacementRule(pattern6452, replacement6452) pattern6453 = Pattern(Integral(x_**m_*(WC('a', S(0)) + WC('b', S(1))*acoth(x_*WC('c', S(1))))**WC('n', S(1))/sqrt(d_ + x_**S(2)*WC('e', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons1737, cons93, cons88, cons166) def replacement6453(m, b, d, a, n, c, x, e): rubi.append(6453) return Dist((m + S(-1))/(c**S(2)*m), Int(x**(m + S(-2))*(a + b*acoth(c*x))**n/sqrt(d + e*x**S(2)), x), x) + Dist(b*n/(c*m), Int(x**(m + S(-1))*(a + b*acoth(c*x))**(n + S(-1))/sqrt(d + e*x**S(2)), x), x) - Simp(x**(m + S(-1))*(a + b*acoth(c*x))**n*sqrt(d + e*x**S(2))/(c**S(2)*d*m), x) rule6453 = ReplacementRule(pattern6453, replacement6453) pattern6454 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*atanh(x_*WC('c', S(1))))/(x_*sqrt(d_ + x_**S(2)*WC('e', S(1)))), x_), cons2, cons3, cons7, cons27, cons48, cons1737, cons268) def replacement6454(b, d, a, c, x, e): rubi.append(6454) return Simp(b*PolyLog(S(2), -sqrt(-c*x + S(1))/sqrt(c*x + S(1)))/sqrt(d), x) - Simp(b*PolyLog(S(2), sqrt(-c*x + S(1))/sqrt(c*x + S(1)))/sqrt(d), x) + Simp(-S(2)*(a + b*atanh(c*x))*atanh(sqrt(-c*x + S(1))/sqrt(c*x + S(1)))/sqrt(d), x) rule6454 = ReplacementRule(pattern6454, replacement6454) pattern6455 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*acoth(x_*WC('c', S(1))))/(x_*sqrt(d_ + x_**S(2)*WC('e', S(1)))), x_), cons2, cons3, cons7, cons27, cons48, cons1737, cons268) def replacement6455(b, d, a, c, x, e): rubi.append(6455) return Simp(b*PolyLog(S(2), -sqrt(-c*x + S(1))/sqrt(c*x + S(1)))/sqrt(d), x) - Simp(b*PolyLog(S(2), sqrt(-c*x + S(1))/sqrt(c*x + S(1)))/sqrt(d), x) + Simp(-S(2)*(a + b*acoth(c*x))*atanh(sqrt(-c*x + S(1))/sqrt(c*x + S(1)))/sqrt(d), x) rule6455 = ReplacementRule(pattern6455, replacement6455) pattern6456 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*atanh(x_*WC('c', S(1))))**n_/(x_*sqrt(d_ + x_**S(2)*WC('e', S(1)))), x_), cons2, cons3, cons7, cons27, cons48, cons1737, cons148, cons268) def replacement6456(b, d, a, c, n, x, e): rubi.append(6456) return Dist(S(1)/sqrt(d), Subst(Int((a + b*x)**n/sinh(x), x), x, atanh(c*x)), x) rule6456 = ReplacementRule(pattern6456, replacement6456) pattern6457 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*acoth(x_*WC('c', S(1))))**n_/(x_*sqrt(d_ + x_**S(2)*WC('e', S(1)))), x_), cons2, cons3, cons7, cons27, cons48, cons1737, cons148, cons268) def replacement6457(b, d, a, c, n, x, e): rubi.append(6457) return -Dist(c*x*sqrt(S(1) - S(1)/(c**S(2)*x**S(2)))/sqrt(d + e*x**S(2)), Subst(Int((a + b*x)**n/cosh(x), x), x, acoth(c*x)), x) rule6457 = ReplacementRule(pattern6457, replacement6457) pattern6458 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*atanh(x_*WC('c', S(1))))**WC('n', S(1))/(x_*sqrt(d_ + x_**S(2)*WC('e', S(1)))), x_), cons2, cons3, cons7, cons27, cons48, cons1737, cons148, cons1738) def replacement6458(b, d, a, n, c, x, e): rubi.append(6458) return Dist(sqrt(-c**S(2)*x**S(2) + S(1))/sqrt(d + e*x**S(2)), Int((a + b*atanh(c*x))**n/(x*sqrt(-c**S(2)*x**S(2) + S(1))), x), x) rule6458 = ReplacementRule(pattern6458, replacement6458) pattern6459 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*acoth(x_*WC('c', S(1))))**WC('n', S(1))/(x_*sqrt(d_ + x_**S(2)*WC('e', S(1)))), x_), cons2, cons3, cons7, cons27, cons48, cons1737, cons148, cons1738) def replacement6459(b, d, a, n, c, x, e): rubi.append(6459) return Dist(sqrt(-c**S(2)*x**S(2) + S(1))/sqrt(d + e*x**S(2)), Int((a + b*acoth(c*x))**n/(x*sqrt(-c**S(2)*x**S(2) + S(1))), x), x) rule6459 = ReplacementRule(pattern6459, replacement6459) pattern6460 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*atanh(x_*WC('c', S(1))))**WC('n', S(1))/(x_**S(2)*sqrt(d_ + x_**S(2)*WC('e', S(1)))), x_), cons2, cons3, cons7, cons27, cons48, cons1737, cons87, cons88) def replacement6460(b, d, a, n, c, x, e): rubi.append(6460) return Dist(b*c*n, Int((a + b*atanh(c*x))**(n + S(-1))/(x*sqrt(d + e*x**S(2))), x), x) - Simp((a + b*atanh(c*x))**n*sqrt(d + e*x**S(2))/(d*x), x) rule6460 = ReplacementRule(pattern6460, replacement6460) pattern6461 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*acoth(x_*WC('c', S(1))))**WC('n', S(1))/(x_**S(2)*sqrt(d_ + x_**S(2)*WC('e', S(1)))), x_), cons2, cons3, cons7, cons27, cons48, cons1737, cons87, cons88) def replacement6461(b, d, a, n, c, x, e): rubi.append(6461) return Dist(b*c*n, Int((a + b*acoth(c*x))**(n + S(-1))/(x*sqrt(d + e*x**S(2))), x), x) - Simp((a + b*acoth(c*x))**n*sqrt(d + e*x**S(2))/(d*x), x) rule6461 = ReplacementRule(pattern6461, replacement6461) pattern6462 = Pattern(Integral(x_**m_*(WC('a', S(0)) + WC('b', S(1))*atanh(x_*WC('c', S(1))))**WC('n', S(1))/sqrt(d_ + x_**S(2)*WC('e', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons1737, cons93, cons88, cons94, cons1510) def replacement6462(m, b, d, a, n, c, x, e): rubi.append(6462) return Dist(c**S(2)*(m + S(2))/(m + S(1)), Int(x**(m + S(2))*(a + b*atanh(c*x))**n/sqrt(d + e*x**S(2)), x), x) - Dist(b*c*n/(m + S(1)), Int(x**(m + S(1))*(a + b*atanh(c*x))**(n + S(-1))/sqrt(d + e*x**S(2)), x), x) + Simp(x**(m + S(1))*(a + b*atanh(c*x))**n*sqrt(d + e*x**S(2))/(d*(m + S(1))), x) rule6462 = ReplacementRule(pattern6462, replacement6462) pattern6463 = Pattern(Integral(x_**m_*(WC('a', S(0)) + WC('b', S(1))*acoth(x_*WC('c', S(1))))**WC('n', S(1))/sqrt(d_ + x_**S(2)*WC('e', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons1737, cons93, cons88, cons94, cons1510) def replacement6463(m, b, d, a, n, c, x, e): rubi.append(6463) return Dist(c**S(2)*(m + S(2))/(m + S(1)), Int(x**(m + S(2))*(a + b*acoth(c*x))**n/sqrt(d + e*x**S(2)), x), x) - Dist(b*c*n/(m + S(1)), Int(x**(m + S(1))*(a + b*acoth(c*x))**(n + S(-1))/sqrt(d + e*x**S(2)), x), x) + Simp(x**(m + S(1))*(a + b*acoth(c*x))**n*sqrt(d + e*x**S(2))/(d*(m + S(1))), x) rule6463 = ReplacementRule(pattern6463, replacement6463) pattern6464 = Pattern(Integral(x_**m_*(d_ + x_**S(2)*WC('e', S(1)))**p_*(WC('a', S(0)) + WC('b', S(1))*atanh(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons1737, cons1784, cons137, cons166, cons1152) def replacement6464(p, m, b, d, a, n, c, x, e): rubi.append(6464) return Dist(S(1)/e, Int(x**(m + S(-2))*(a + b*atanh(c*x))**n*(d + e*x**S(2))**(p + S(1)), x), x) - Dist(d/e, Int(x**(m + S(-2))*(a + b*atanh(c*x))**n*(d + e*x**S(2))**p, x), x) rule6464 = ReplacementRule(pattern6464, replacement6464) pattern6465 = Pattern(Integral(x_**m_*(d_ + x_**S(2)*WC('e', S(1)))**p_*(WC('a', S(0)) + WC('b', S(1))*acoth(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons1737, cons1784, cons137, cons166, cons1152) def replacement6465(p, m, b, d, a, n, c, x, e): rubi.append(6465) return Dist(S(1)/e, Int(x**(m + S(-2))*(a + b*acoth(c*x))**n*(d + e*x**S(2))**(p + S(1)), x), x) - Dist(d/e, Int(x**(m + S(-2))*(a + b*acoth(c*x))**n*(d + e*x**S(2))**p, x), x) rule6465 = ReplacementRule(pattern6465, replacement6465) pattern6466 = Pattern(Integral(x_**m_*(d_ + x_**S(2)*WC('e', S(1)))**p_*(WC('a', S(0)) + WC('b', S(1))*atanh(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons1737, cons1784, cons137, cons267, cons1152) def replacement6466(p, m, b, d, a, n, c, x, e): rubi.append(6466) return Dist(S(1)/d, Int(x**m*(a + b*atanh(c*x))**n*(d + e*x**S(2))**(p + S(1)), x), x) - Dist(e/d, Int(x**(m + S(2))*(a + b*atanh(c*x))**n*(d + e*x**S(2))**p, x), x) rule6466 = ReplacementRule(pattern6466, replacement6466) pattern6467 = Pattern(Integral(x_**m_*(d_ + x_**S(2)*WC('e', S(1)))**p_*(WC('a', S(0)) + WC('b', S(1))*acoth(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons1737, cons1784, cons137, cons267, cons1152) def replacement6467(p, m, b, d, a, n, c, x, e): rubi.append(6467) return Dist(S(1)/d, Int(x**m*(a + b*acoth(c*x))**n*(d + e*x**S(2))**(p + S(1)), x), x) - Dist(e/d, Int(x**(m + S(2))*(a + b*acoth(c*x))**n*(d + e*x**S(2))**p, x), x) rule6467 = ReplacementRule(pattern6467, replacement6467) pattern6468 = Pattern(Integral(x_**WC('m', S(1))*(d_ + x_**S(2)*WC('e', S(1)))**p_*(WC('a', S(0)) + WC('b', S(1))*atanh(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons1737, cons162, cons137, cons89, cons319) def replacement6468(p, m, b, d, a, n, c, x, e): rubi.append(6468) return -Dist(m/(b*c*(n + S(1))), Int(x**(m + S(-1))*(a + b*atanh(c*x))**(n + S(1))*(d + e*x**S(2))**p, x), x) + Dist(c*(m + S(2)*p + S(2))/(b*(n + S(1))), Int(x**(m + S(1))*(a + b*atanh(c*x))**(n + S(1))*(d + e*x**S(2))**p, x), x) + Simp(x**m*(a + b*atanh(c*x))**(n + S(1))*(d + e*x**S(2))**(p + S(1))/(b*c*d*(n + S(1))), x) rule6468 = ReplacementRule(pattern6468, replacement6468) pattern6469 = Pattern(Integral(x_**WC('m', S(1))*(d_ + x_**S(2)*WC('e', S(1)))**p_*(WC('a', S(0)) + WC('b', S(1))*acoth(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons1737, cons162, cons137, cons89, cons319) def replacement6469(p, m, b, d, a, n, c, x, e): rubi.append(6469) return -Dist(m/(b*c*(n + S(1))), Int(x**(m + S(-1))*(a + b*acoth(c*x))**(n + S(1))*(d + e*x**S(2))**p, x), x) + Dist(c*(m + S(2)*p + S(2))/(b*(n + S(1))), Int(x**(m + S(1))*(a + b*acoth(c*x))**(n + S(1))*(d + e*x**S(2))**p, x), x) + Simp(x**m*(a + b*acoth(c*x))**(n + S(1))*(d + e*x**S(2))**(p + S(1))/(b*c*d*(n + S(1))), x) rule6469 = ReplacementRule(pattern6469, replacement6469) pattern6470 = Pattern(Integral(x_**WC('m', S(1))*(d_ + x_**S(2)*WC('e', S(1)))**p_*(WC('a', S(0)) + WC('b', S(1))*atanh(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons4, cons1737, cons62, cons1785, cons1740) def replacement6470(p, m, b, d, a, n, c, x, e): rubi.append(6470) return Dist(c**(-m + S(-1))*d**p, Subst(Int((a + b*x)**n*sinh(x)**m*cosh(x)**(-m - S(2)*p + S(-2)), x), x, atanh(c*x)), x) rule6470 = ReplacementRule(pattern6470, replacement6470) pattern6471 = Pattern(Integral(x_**WC('m', S(1))*(d_ + x_**S(2)*WC('e', S(1)))**p_*(WC('a', S(0)) + WC('b', S(1))*atanh(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons4, cons1737, cons62, cons1785, cons1741) def replacement6471(p, m, b, d, a, n, c, x, e): rubi.append(6471) return Dist(d**(p + S(1)/2)*sqrt(-c**S(2)*x**S(2) + S(1))/sqrt(d + e*x**S(2)), Int(x**m*(a + b*atanh(c*x))**n*(-c**S(2)*x**S(2) + S(1))**p, x), x) rule6471 = ReplacementRule(pattern6471, replacement6471) pattern6472 = Pattern(Integral(x_**WC('m', S(1))*(d_ + x_**S(2)*WC('e', S(1)))**p_*(WC('a', S(0)) + WC('b', S(1))*acoth(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons4, cons1737, cons62, cons1785, cons38) def replacement6472(p, m, b, d, a, n, c, x, e): rubi.append(6472) return -Dist(c**(-m + S(-1))*(-d)**p, Subst(Int((a + b*x)**n*sinh(x)**(-m - S(2)*p + S(-2))*cosh(x)**m, x), x, acoth(c*x)), x) rule6472 = ReplacementRule(pattern6472, replacement6472) pattern6473 = Pattern(Integral(x_**WC('m', S(1))*(d_ + x_**S(2)*WC('e', S(1)))**p_*(WC('a', S(0)) + WC('b', S(1))*acoth(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons4, cons1737, cons62, cons1785, cons147) def replacement6473(p, m, b, d, a, n, c, x, e): rubi.append(6473) return -Dist(c**(-m)*x*(-d)**(p + S(1)/2)*sqrt((c**S(2)*x**S(2) + S(-1))/(c**S(2)*x**S(2)))/sqrt(d + e*x**S(2)), Subst(Int((a + b*x)**n*sinh(x)**(-m - S(2)*p + S(-2))*cosh(x)**m, x), x, acoth(c*x)), x) rule6473 = ReplacementRule(pattern6473, replacement6473) pattern6474 = Pattern(Integral(x_*(x_**S(2)*WC('e', S(1)) + WC('d', S(0)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*atanh(x_*WC('c', S(1)))), x_), cons2, cons3, cons7, cons27, cons48, cons5, cons54) def replacement6474(p, b, d, a, c, x, e): rubi.append(6474) return -Dist(b*c/(S(2)*e*(p + S(1))), Int((d + e*x**S(2))**(p + S(1))/(-c**S(2)*x**S(2) + S(1)), x), x) + Simp((a + b*atanh(c*x))*(d + e*x**S(2))**(p + S(1))/(S(2)*e*(p + S(1))), x) rule6474 = ReplacementRule(pattern6474, replacement6474) pattern6475 = Pattern(Integral(x_*(x_**S(2)*WC('e', S(1)) + WC('d', S(0)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*acoth(x_*WC('c', S(1)))), x_), cons2, cons3, cons7, cons27, cons48, cons5, cons54) def replacement6475(p, b, d, a, c, x, e): rubi.append(6475) return -Dist(b*c/(S(2)*e*(p + S(1))), Int((d + e*x**S(2))**(p + S(1))/(-c**S(2)*x**S(2) + S(1)), x), x) + Simp((a + b*acoth(c*x))*(d + e*x**S(2))**(p + S(1))/(S(2)*e*(p + S(1))), x) rule6475 = ReplacementRule(pattern6475, replacement6475) def With6476(p, m, b, d, a, c, x, e): u = IntHide(x**m*(d + e*x**S(2))**p, x) rubi.append(6476) return -Dist(b*c, Int(SimplifyIntegrand(u/(-c**S(2)*x**S(2) + S(1)), x), x), x) + Dist(a + b*atanh(c*x), u, x) pattern6476 = Pattern(Integral(x_**WC('m', S(1))*(x_**S(2)*WC('e', S(1)) + WC('d', S(0)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*atanh(x_*WC('c', S(1)))), x_), cons2, cons3, cons7, cons27, cons48, cons21, cons5, cons1786) rule6476 = ReplacementRule(pattern6476, With6476) def With6477(p, m, b, d, a, c, x, e): u = IntHide(x**m*(d + e*x**S(2))**p, x) rubi.append(6477) return -Dist(b*c, Int(SimplifyIntegrand(u/(-c**S(2)*x**S(2) + S(1)), x), x), x) + Dist(a + b*acoth(c*x), u, x) pattern6477 = Pattern(Integral(x_**WC('m', S(1))*(x_**S(2)*WC('e', S(1)) + WC('d', S(0)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*acoth(x_*WC('c', S(1)))), x_), cons2, cons3, cons7, cons27, cons48, cons21, cons5, cons1786) rule6477 = ReplacementRule(pattern6477, With6477) pattern6478 = Pattern(Integral(x_**WC('m', S(1))*(d_ + x_**S(2)*WC('e', S(1)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*atanh(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons21, cons38, cons148, cons1787) def replacement6478(p, m, b, d, a, n, c, x, e): rubi.append(6478) return Int(ExpandIntegrand((a + b*atanh(c*x))**n, x**m*(d + e*x**S(2))**p, x), x) rule6478 = ReplacementRule(pattern6478, replacement6478) pattern6479 = Pattern(Integral(x_**WC('m', S(1))*(d_ + x_**S(2)*WC('e', S(1)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*acoth(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons21, cons38, cons148, cons1787) def replacement6479(p, m, b, d, a, n, c, x, e): rubi.append(6479) return Int(ExpandIntegrand((a + b*acoth(c*x))**n, x**m*(d + e*x**S(2))**p, x), x) rule6479 = ReplacementRule(pattern6479, replacement6479) pattern6480 = Pattern(Integral(x_**WC('m', S(1))*(a_ + WC('b', S(1))*atanh(x_*WC('c', S(1))))*(d_ + x_**S(2)*WC('e', S(1)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons21, cons5, cons1788) def replacement6480(p, m, b, d, c, a, x, e): rubi.append(6480) return Dist(a, Int(x**m*(d + e*x**S(2))**p, x), x) + Dist(b, Int(x**m*(d + e*x**S(2))**p*atanh(c*x), x), x) rule6480 = ReplacementRule(pattern6480, replacement6480) pattern6481 = Pattern(Integral(x_**WC('m', S(1))*(a_ + WC('b', S(1))*acoth(x_*WC('c', S(1))))*(d_ + x_**S(2)*WC('e', S(1)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons21, cons5, cons1788) def replacement6481(p, m, b, d, c, a, x, e): rubi.append(6481) return Dist(a, Int(x**m*(d + e*x**S(2))**p, x), x) + Dist(b, Int(x**m*(d + e*x**S(2))**p*acoth(c*x), x), x) rule6481 = ReplacementRule(pattern6481, replacement6481) pattern6482 = Pattern(Integral(x_**WC('m', S(1))*(x_**S(2)*WC('e', S(1)) + WC('d', S(0)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*atanh(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons21, cons4, cons5, cons1497) def replacement6482(p, m, b, d, a, n, c, x, e): rubi.append(6482) return Int(x**m*(a + b*atanh(c*x))**n*(d + e*x**S(2))**p, x) rule6482 = ReplacementRule(pattern6482, replacement6482) pattern6483 = Pattern(Integral(x_**WC('m', S(1))*(x_**S(2)*WC('e', S(1)) + WC('d', S(0)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*acoth(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons21, cons4, cons5, cons1497) def replacement6483(p, m, b, d, a, n, c, x, e): rubi.append(6483) return Int(x**m*(a + b*acoth(c*x))**n*(d + e*x**S(2))**p, x) rule6483 = ReplacementRule(pattern6483, replacement6483) pattern6484 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*atanh(x_*WC('c', S(1))))**WC('n', S(1))*atanh(u_)/(d_ + x_**S(2)*WC('e', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons1737, cons87, cons88, cons1910) def replacement6484(u, b, d, a, n, c, x, e): rubi.append(6484) return -Dist(S(1)/2, Int((a + b*atanh(c*x))**n*log(-u + S(1))/(d + e*x**S(2)), x), x) + Dist(S(1)/2, Int((a + b*atanh(c*x))**n*log(u + S(1))/(d + e*x**S(2)), x), x) rule6484 = ReplacementRule(pattern6484, replacement6484) pattern6485 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*acoth(x_*WC('c', S(1))))**WC('n', S(1))*acoth(u_)/(d_ + x_**S(2)*WC('e', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons1737, cons87, cons88, cons1910) def replacement6485(u, b, d, a, n, c, x, e): rubi.append(6485) return -Dist(S(1)/2, Int((a + b*acoth(c*x))**n*log(SimplifyIntegrand(S(1) - S(1)/u, x))/(d + e*x**S(2)), x), x) + Dist(S(1)/2, Int((a + b*acoth(c*x))**n*log(SimplifyIntegrand(S(1) + S(1)/u, x))/(d + e*x**S(2)), x), x) rule6485 = ReplacementRule(pattern6485, replacement6485) pattern6486 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*atanh(x_*WC('c', S(1))))**WC('n', S(1))*atanh(u_)/(d_ + x_**S(2)*WC('e', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons1737, cons87, cons88, cons1911) def replacement6486(u, b, d, a, n, c, x, e): rubi.append(6486) return -Dist(S(1)/2, Int((a + b*atanh(c*x))**n*log(-u + S(1))/(d + e*x**S(2)), x), x) + Dist(S(1)/2, Int((a + b*atanh(c*x))**n*log(u + S(1))/(d + e*x**S(2)), x), x) rule6486 = ReplacementRule(pattern6486, replacement6486) pattern6487 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*acoth(x_*WC('c', S(1))))**WC('n', S(1))*acoth(u_)/(d_ + x_**S(2)*WC('e', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons1737, cons87, cons88, cons1911) def replacement6487(u, b, d, a, n, c, x, e): rubi.append(6487) return -Dist(S(1)/2, Int((a + b*acoth(c*x))**n*log(SimplifyIntegrand(S(1) - S(1)/u, x))/(d + e*x**S(2)), x), x) + Dist(S(1)/2, Int((a + b*acoth(c*x))**n*log(SimplifyIntegrand(S(1) + S(1)/u, x))/(d + e*x**S(2)), x), x) rule6487 = ReplacementRule(pattern6487, replacement6487) pattern6488 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*atanh(x_*WC('c', S(1))))**WC('n', S(1))*log(u_)/(d_ + x_**S(2)*WC('e', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons1737, cons87, cons88, cons1912) def replacement6488(u, b, d, a, n, c, x, e): rubi.append(6488) return -Dist(b*n/S(2), Int((a + b*atanh(c*x))**(n + S(-1))*PolyLog(S(2), Together(-u + S(1)))/(d + e*x**S(2)), x), x) + Simp((a + b*atanh(c*x))**n*PolyLog(S(2), Together(-u + S(1)))/(S(2)*c*d), x) rule6488 = ReplacementRule(pattern6488, replacement6488) pattern6489 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*acoth(x_*WC('c', S(1))))**WC('n', S(1))*log(u_)/(d_ + x_**S(2)*WC('e', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons1737, cons87, cons88, cons1912) def replacement6489(u, b, d, a, n, c, x, e): rubi.append(6489) return -Dist(b*n/S(2), Int((a + b*acoth(c*x))**(n + S(-1))*PolyLog(S(2), Together(-u + S(1)))/(d + e*x**S(2)), x), x) + Simp((a + b*acoth(c*x))**n*PolyLog(S(2), Together(-u + S(1)))/(S(2)*c*d), x) rule6489 = ReplacementRule(pattern6489, replacement6489) pattern6490 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*atanh(x_*WC('c', S(1))))**WC('n', S(1))*log(u_)/(d_ + x_**S(2)*WC('e', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons1737, cons87, cons88, cons1913) def replacement6490(u, b, d, a, n, c, x, e): rubi.append(6490) return Dist(b*n/S(2), Int((a + b*atanh(c*x))**(n + S(-1))*PolyLog(S(2), Together(-u + S(1)))/(d + e*x**S(2)), x), x) - Simp((a + b*atanh(c*x))**n*PolyLog(S(2), Together(-u + S(1)))/(S(2)*c*d), x) rule6490 = ReplacementRule(pattern6490, replacement6490) pattern6491 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*acoth(x_*WC('c', S(1))))**WC('n', S(1))*log(u_)/(d_ + x_**S(2)*WC('e', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons1737, cons87, cons88, cons1913) def replacement6491(u, b, d, a, n, c, x, e): rubi.append(6491) return Dist(b*n/S(2), Int((a + b*acoth(c*x))**(n + S(-1))*PolyLog(S(2), Together(-u + S(1)))/(d + e*x**S(2)), x), x) - Simp((a + b*acoth(c*x))**n*PolyLog(S(2), Together(-u + S(1)))/(S(2)*c*d), x) rule6491 = ReplacementRule(pattern6491, replacement6491) pattern6492 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*atanh(x_*WC('c', S(1))))**WC('n', S(1))*PolyLog(p_, u_)/(d_ + x_**S(2)*WC('e', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons5, cons1737, cons87, cons88, cons1910) def replacement6492(p, u, b, d, a, n, c, x, e): rubi.append(6492) return Dist(b*n/S(2), Int((a + b*atanh(c*x))**(n + S(-1))*PolyLog(p + S(1), u)/(d + e*x**S(2)), x), x) - Simp((a + b*atanh(c*x))**n*PolyLog(p + S(1), u)/(S(2)*c*d), x) rule6492 = ReplacementRule(pattern6492, replacement6492) pattern6493 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*acoth(x_*WC('c', S(1))))**WC('n', S(1))*PolyLog(p_, u_)/(d_ + x_**S(2)*WC('e', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons5, cons1737, cons87, cons88, cons1910) def replacement6493(p, u, b, d, a, n, c, x, e): rubi.append(6493) return Dist(b*n/S(2), Int((a + b*acoth(c*x))**(n + S(-1))*PolyLog(p + S(1), u)/(d + e*x**S(2)), x), x) - Simp((a + b*acoth(c*x))**n*PolyLog(p + S(1), u)/(S(2)*c*d), x) rule6493 = ReplacementRule(pattern6493, replacement6493) pattern6494 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*atanh(x_*WC('c', S(1))))**WC('n', S(1))*PolyLog(p_, u_)/(d_ + x_**S(2)*WC('e', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons5, cons1737, cons87, cons88, cons1911) def replacement6494(p, u, b, d, a, n, c, x, e): rubi.append(6494) return -Dist(b*n/S(2), Int((a + b*atanh(c*x))**(n + S(-1))*PolyLog(p + S(1), u)/(d + e*x**S(2)), x), x) + Simp((a + b*atanh(c*x))**n*PolyLog(p + S(1), u)/(S(2)*c*d), x) rule6494 = ReplacementRule(pattern6494, replacement6494) pattern6495 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*acoth(x_*WC('c', S(1))))**WC('n', S(1))*PolyLog(p_, u_)/(d_ + x_**S(2)*WC('e', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons5, cons1737, cons87, cons88, cons1911) def replacement6495(p, u, b, d, a, n, c, x, e): rubi.append(6495) return -Dist(b*n/S(2), Int((a + b*acoth(c*x))**(n + S(-1))*PolyLog(p + S(1), u)/(d + e*x**S(2)), x), x) + Simp((a + b*acoth(c*x))**n*PolyLog(p + S(1), u)/(S(2)*c*d), x) rule6495 = ReplacementRule(pattern6495, replacement6495) pattern6496 = Pattern(Integral(S(1)/((d_ + x_**S(2)*WC('e', S(1)))*(WC('a', S(0)) + WC('b', S(1))*acoth(x_*WC('c', S(1))))*(WC('a', S(0)) + WC('b', S(1))*atanh(x_*WC('c', S(1))))), x_), cons2, cons3, cons7, cons27, cons48, cons1737) def replacement6496(b, d, a, c, x, e): rubi.append(6496) return Simp((-log(a + b*acoth(c*x)) + log(a + b*atanh(c*x)))/(b**S(2)*c*d*(acoth(c*x) - atanh(c*x))), x) rule6496 = ReplacementRule(pattern6496, replacement6496) pattern6497 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*acoth(x_*WC('c', S(1))))**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*atanh(x_*WC('c', S(1))))**WC('n', S(1))/(d_ + x_**S(2)*WC('e', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons1737, cons150, cons1793) def replacement6497(m, b, d, a, n, c, x, e): rubi.append(6497) return -Dist(n/(m + S(1)), Int((a + b*acoth(c*x))**(m + S(1))*(a + b*atanh(c*x))**(n + S(-1))/(d + e*x**S(2)), x), x) + Simp((a + b*acoth(c*x))**(m + S(1))*(a + b*atanh(c*x))**n/(b*c*d*(m + S(1))), x) rule6497 = ReplacementRule(pattern6497, replacement6497) pattern6498 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*acoth(x_*WC('c', S(1))))**WC('n', S(1))*(WC('a', S(0)) + WC('b', S(1))*atanh(x_*WC('c', S(1))))**WC('m', S(1))/(d_ + x_**S(2)*WC('e', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons1737, cons150, cons1794) def replacement6498(m, b, d, a, n, c, x, e): rubi.append(6498) return -Dist(n/(m + S(1)), Int((a + b*acoth(c*x))**(n + S(-1))*(a + b*atanh(c*x))**(m + S(1))/(d + e*x**S(2)), x), x) + Simp((a + b*acoth(c*x))**n*(a + b*atanh(c*x))**(m + S(1))/(b*c*d*(m + S(1))), x) rule6498 = ReplacementRule(pattern6498, replacement6498) pattern6499 = Pattern(Integral(atanh(x_*WC('a', S(1)))/(c_ + x_**WC('n', S(1))*WC('d', S(1))), x_), cons2, cons7, cons27, cons85, cons1914) def replacement6499(d, a, n, c, x): rubi.append(6499) return -Dist(S(1)/2, Int(log(-a*x + S(1))/(c + d*x**n), x), x) + Dist(S(1)/2, Int(log(a*x + S(1))/(c + d*x**n), x), x) rule6499 = ReplacementRule(pattern6499, replacement6499) pattern6500 = Pattern(Integral(acoth(x_*WC('a', S(1)))/(c_ + x_**WC('n', S(1))*WC('d', S(1))), x_), cons2, cons7, cons27, cons85, cons1914) def replacement6500(d, a, n, c, x): rubi.append(6500) return -Dist(S(1)/2, Int(log(S(1) - S(1)/(a*x))/(c + d*x**n), x), x) + Dist(S(1)/2, Int(log(S(1) + S(1)/(a*x))/(c + d*x**n), x), x) rule6500 = ReplacementRule(pattern6500, replacement6500) pattern6501 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*atanh(x_*WC('c', S(1))))*(WC('d', S(0)) + WC('e', S(1))*log(x_**S(2)*WC('g', S(1)) + WC('f', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons1796) def replacement6501(f, b, g, d, a, c, x, e): rubi.append(6501) return -Dist(b*c, Int(x*(d + e*log(f + g*x**S(2)))/(-c**S(2)*x**S(2) + S(1)), x), x) - Dist(S(2)*e*g, Int(x**S(2)*(a + b*atanh(c*x))/(f + g*x**S(2)), x), x) + Simp(x*(a + b*atanh(c*x))*(d + e*log(f + g*x**S(2))), x) rule6501 = ReplacementRule(pattern6501, replacement6501) pattern6502 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*acoth(x_*WC('c', S(1))))*(WC('d', S(0)) + WC('e', S(1))*log(x_**S(2)*WC('g', S(1)) + WC('f', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons1796) def replacement6502(f, b, g, d, a, c, x, e): rubi.append(6502) return -Dist(b*c, Int(x*(d + e*log(f + g*x**S(2)))/(-c**S(2)*x**S(2) + S(1)), x), x) - Dist(S(2)*e*g, Int(x**S(2)*(a + b*acoth(c*x))/(f + g*x**S(2)), x), x) + Simp(x*(a + b*acoth(c*x))*(d + e*log(f + g*x**S(2))), x) rule6502 = ReplacementRule(pattern6502, replacement6502) pattern6503 = Pattern(Integral(x_**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*atanh(x_*WC('c', S(1))))*(WC('d', S(0)) + WC('e', S(1))*log(x_**S(2)*WC('g', S(1)) + WC('f', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons601) def replacement6503(m, f, b, g, d, a, c, x, e): rubi.append(6503) return -Dist(b*c/(m + S(1)), Int(x**(m + S(1))*(d + e*log(f + g*x**S(2)))/(-c**S(2)*x**S(2) + S(1)), x), x) - Dist(S(2)*e*g/(m + S(1)), Int(x**(m + S(2))*(a + b*atanh(c*x))/(f + g*x**S(2)), x), x) + Simp(x**(m + S(1))*(a + b*atanh(c*x))*(d + e*log(f + g*x**S(2)))/(m + S(1)), x) rule6503 = ReplacementRule(pattern6503, replacement6503) pattern6504 = Pattern(Integral(x_**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*acoth(x_*WC('c', S(1))))*(WC('d', S(0)) + WC('e', S(1))*log(x_**S(2)*WC('g', S(1)) + WC('f', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons601) def replacement6504(m, f, b, g, d, a, c, x, e): rubi.append(6504) return -Dist(b*c/(m + S(1)), Int(x**(m + S(1))*(d + e*log(f + g*x**S(2)))/(-c**S(2)*x**S(2) + S(1)), x), x) - Dist(S(2)*e*g/(m + S(1)), Int(x**(m + S(2))*(a + b*acoth(c*x))/(f + g*x**S(2)), x), x) + Simp(x**(m + S(1))*(a + b*acoth(c*x))*(d + e*log(f + g*x**S(2)))/(m + S(1)), x) rule6504 = ReplacementRule(pattern6504, replacement6504) def With6505(m, f, b, g, d, a, c, x, e): u = IntHide(x**m*(d + e*log(f + g*x**S(2))), x) rubi.append(6505) return -Dist(b*c, Int(ExpandIntegrand(u/(-c**S(2)*x**S(2) + S(1)), x), x), x) + Dist(a + b*atanh(c*x), u, x) pattern6505 = Pattern(Integral(x_**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*atanh(x_*WC('c', S(1))))*(WC('d', S(0)) + WC('e', S(1))*log(x_**S(2)*WC('g', S(1)) + WC('f', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons1797) rule6505 = ReplacementRule(pattern6505, With6505) def With6506(m, f, b, g, d, a, c, x, e): u = IntHide(x**m*(d + e*log(f + g*x**S(2))), x) rubi.append(6506) return -Dist(b*c, Int(ExpandIntegrand(u/(-c**S(2)*x**S(2) + S(1)), x), x), x) + Dist(a + b*acoth(c*x), u, x) pattern6506 = Pattern(Integral(x_**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*acoth(x_*WC('c', S(1))))*(WC('d', S(0)) + WC('e', S(1))*log(x_**S(2)*WC('g', S(1)) + WC('f', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons1797) rule6506 = ReplacementRule(pattern6506, With6506) def With6507(m, f, b, g, d, a, c, x, e): u = IntHide(x**m*(a + b*atanh(c*x)), x) rubi.append(6507) return -Dist(S(2)*e*g, Int(ExpandIntegrand(u*x/(f + g*x**S(2)), x), x), x) + Dist(d + e*log(f + g*x**S(2)), u, x) pattern6507 = Pattern(Integral(x_**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*atanh(x_*WC('c', S(1))))*(WC('d', S(0)) + WC('e', S(1))*log(x_**S(2)*WC('g', S(1)) + WC('f', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons17, cons261) rule6507 = ReplacementRule(pattern6507, With6507) def With6508(m, f, b, g, d, a, c, x, e): u = IntHide(x**m*(a + b*acoth(c*x)), x) rubi.append(6508) return -Dist(S(2)*e*g, Int(ExpandIntegrand(u*x/(f + g*x**S(2)), x), x), x) + Dist(d + e*log(f + g*x**S(2)), u, x) pattern6508 = Pattern(Integral(x_**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*acoth(x_*WC('c', S(1))))*(WC('d', S(0)) + WC('e', S(1))*log(x_**S(2)*WC('g', S(1)) + WC('f', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons17, cons261) rule6508 = ReplacementRule(pattern6508, With6508) pattern6509 = Pattern(Integral(x_*(WC('a', S(0)) + WC('b', S(1))*atanh(x_*WC('c', S(1))))**S(2)*(WC('d', S(0)) + WC('e', S(1))*log(f_ + x_**S(2)*WC('g', S(1)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons1915) def replacement6509(g, b, f, d, a, c, x, e): rubi.append(6509) return Dist(b/c, Int((a + b*atanh(c*x))*(d + e*log(f + g*x**S(2))), x), x) + Dist(b*c*e, Int(x**S(2)*(a + b*atanh(c*x))/(-c**S(2)*x**S(2) + S(1)), x), x) - Simp(e*x**S(2)*(a + b*atanh(c*x))**S(2)/S(2), x) + Simp((a + b*atanh(c*x))**S(2)*(d + e*log(f + g*x**S(2)))*(f + g*x**S(2))/(S(2)*g), x) rule6509 = ReplacementRule(pattern6509, replacement6509) pattern6510 = Pattern(Integral(x_*(WC('a', S(0)) + WC('b', S(1))*acoth(x_*WC('c', S(1))))**S(2)*(WC('d', S(0)) + WC('e', S(1))*log(f_ + x_**S(2)*WC('g', S(1)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons1915) def replacement6510(g, b, f, d, a, c, x, e): rubi.append(6510) return Dist(b/c, Int((a + b*acoth(c*x))*(d + e*log(f + g*x**S(2))), x), x) + Dist(b*c*e, Int(x**S(2)*(a + b*acoth(c*x))/(-c**S(2)*x**S(2) + S(1)), x), x) - Simp(e*x**S(2)*(a + b*acoth(c*x))**S(2)/S(2), x) + Simp((a + b*acoth(c*x))**S(2)*(d + e*log(f + g*x**S(2)))*(f + g*x**S(2))/(S(2)*g), x) rule6510 = ReplacementRule(pattern6510, replacement6510) pattern6511 = Pattern(Integral(exp(WC('n', S(1))*atanh(x_*WC('a', S(1)))), x_), cons2, cons1482) def replacement6511(x, a, n): rubi.append(6511) return Int((-a*x + S(1))**(-n/S(2) + S(1)/2)*(a*x + S(1))**(n/S(2) + S(1)/2)/sqrt(-a**S(2)*x**S(2) + S(1)), x) rule6511 = ReplacementRule(pattern6511, replacement6511) pattern6512 = Pattern(Integral(x_**WC('m', S(1))*exp(WC('n', S(1))*atanh(x_*WC('a', S(1)))), x_), cons2, cons21, cons1482) def replacement6512(x, m, a, n): rubi.append(6512) return Int(x**m*(-a*x + S(1))**(-n/S(2) + S(1)/2)*(a*x + S(1))**(n/S(2) + S(1)/2)/sqrt(-a**S(2)*x**S(2) + S(1)), x) rule6512 = ReplacementRule(pattern6512, replacement6512) pattern6513 = Pattern(Integral(exp(n_*atanh(x_*WC('a', S(1)))), x_), cons2, cons4, cons1441) def replacement6513(x, a, n): rubi.append(6513) return Int((-a*x + S(1))**(-n/S(2))*(a*x + S(1))**(n/S(2)), x) rule6513 = ReplacementRule(pattern6513, replacement6513) pattern6514 = Pattern(Integral(x_**WC('m', S(1))*exp(n_*atanh(x_*WC('a', S(1)))), x_), cons2, cons21, cons4, cons1441) def replacement6514(x, m, a, n): rubi.append(6514) return Int(x**m*(-a*x + S(1))**(-n/S(2))*(a*x + S(1))**(n/S(2)), x) rule6514 = ReplacementRule(pattern6514, replacement6514) pattern6515 = Pattern(Integral((c_ + x_*WC('d', S(1)))**WC('p', S(1))*exp(WC('n', S(1))*atanh(x_*WC('a', S(1)))), x_), cons2, cons7, cons27, cons5, cons1916, cons1250, cons246) def replacement6515(p, d, a, n, c, x): rubi.append(6515) return Dist(c**n, Int((c + d*x)**(-n + p)*(-a**S(2)*x**S(2) + S(1))**(n/S(2)), x), x) rule6515 = ReplacementRule(pattern6515, replacement6515) pattern6516 = Pattern(Integral((c_ + x_*WC('d', S(1)))**WC('p', S(1))*(x_*WC('f', S(1)) + WC('e', S(0)))**WC('m', S(1))*exp(WC('n', S(1))*atanh(x_*WC('a', S(1)))), x_), cons2, cons7, cons27, cons48, cons125, cons21, cons5, cons1916, cons1250, cons1917, cons246) def replacement6516(p, m, f, d, a, n, c, x, e): rubi.append(6516) return Dist(c**n, Int((c + d*x)**(-n + p)*(e + f*x)**m*(-a**S(2)*x**S(2) + S(1))**(n/S(2)), x), x) rule6516 = ReplacementRule(pattern6516, replacement6516) pattern6517 = Pattern(Integral((c_ + x_*WC('d', S(1)))**WC('p', S(1))*WC('u', S(1))*exp(WC('n', S(1))*atanh(x_*WC('a', S(1)))), x_), cons2, cons7, cons27, cons4, cons5, cons1918, cons1802) def replacement6517(p, u, d, a, n, c, x): rubi.append(6517) return Dist(c**p, Int(u*(S(1) + d*x/c)**p*(-a*x + S(1))**(-n/S(2))*(a*x + S(1))**(n/S(2)), x), x) rule6517 = ReplacementRule(pattern6517, replacement6517) pattern6518 = Pattern(Integral((c_ + x_*WC('d', S(1)))**WC('p', S(1))*WC('u', S(1))*exp(WC('n', S(1))*atanh(x_*WC('a', S(1)))), x_), cons2, cons7, cons27, cons4, cons5, cons1918, cons1803) def replacement6518(p, u, d, a, n, c, x): rubi.append(6518) return Int(u*(c + d*x)**p*(-a*x + S(1))**(-n/S(2))*(a*x + S(1))**(n/S(2)), x) rule6518 = ReplacementRule(pattern6518, replacement6518) pattern6519 = Pattern(Integral((c_ + WC('d', S(1))/x_)**WC('p', S(1))*WC('u', S(1))*exp(WC('n', S(1))*atanh(x_*WC('a', S(1)))), x_), cons2, cons7, cons27, cons4, cons1919, cons38) def replacement6519(p, u, d, a, n, c, x): rubi.append(6519) return Dist(d**p, Int(u*x**(-p)*(c*x/d + S(1))**p*exp(n*atanh(a*x)), x), x) rule6519 = ReplacementRule(pattern6519, replacement6519) pattern6520 = Pattern(Integral((c_ + WC('d', S(1))/x_)**p_*WC('u', S(1))*exp(n_*atanh(x_*WC('a', S(1)))), x_), cons2, cons7, cons27, cons5, cons1919, cons147, cons743, cons177) def replacement6520(p, u, d, a, n, c, x): rubi.append(6520) return Dist((S(-1))**(n/S(2))*c**p, Int(u*(S(1) - S(1)/(a*x))**(-n/S(2))*(S(1) + S(1)/(a*x))**(n/S(2))*(S(1) + d/(c*x))**p, x), x) rule6520 = ReplacementRule(pattern6520, replacement6520) pattern6521 = Pattern(Integral((c_ + WC('d', S(1))/x_)**p_*WC('u', S(1))*exp(n_*atanh(x_*WC('a', S(1)))), x_), cons2, cons7, cons27, cons5, cons1919, cons147, cons743, cons117) def replacement6521(p, u, d, a, n, c, x): rubi.append(6521) return Int(u*(c + d/x)**p*(-a*x + S(1))**(-n/S(2))*(a*x + S(1))**(n/S(2)), x) rule6521 = ReplacementRule(pattern6521, replacement6521) pattern6522 = Pattern(Integral((c_ + WC('d', S(1))/x_)**p_*WC('u', S(1))*exp(WC('n', S(1))*atanh(x_*WC('a', S(1)))), x_), cons2, cons7, cons27, cons4, cons5, cons1919, cons147) def replacement6522(p, u, d, a, n, c, x): rubi.append(6522) return Dist(x**p*(c + d/x)**p*(c*x/d + S(1))**(-p), Int(u*x**(-p)*(c*x/d + S(1))**p*exp(n*atanh(a*x)), x), x) rule6522 = ReplacementRule(pattern6522, replacement6522) pattern6523 = Pattern(Integral(exp(n_*atanh(x_*WC('a', S(1))))/(c_ + x_**S(2)*WC('d', S(1)))**(S(3)/2), x_), cons2, cons7, cons27, cons4, cons1920, cons23) def replacement6523(d, a, n, c, x): rubi.append(6523) return Simp((-a*x + n)*exp(n*atanh(a*x))/(a*c*sqrt(c + d*x**S(2))*(n**S(2) + S(-1))), x) rule6523 = ReplacementRule(pattern6523, replacement6523) pattern6524 = Pattern(Integral((c_ + x_**S(2)*WC('d', S(1)))**p_*exp(n_*atanh(x_*WC('a', S(1)))), x_), cons2, cons7, cons27, cons4, cons1920, cons13, cons137, cons23, cons1921, cons246) def replacement6524(p, d, a, n, c, x): rubi.append(6524) return -Dist(S(2)*(p + S(1))*(S(2)*p + S(3))/(c*(n**S(2) - S(4)*(p + S(1))**S(2))), Int((c + d*x**S(2))**(p + S(1))*exp(n*atanh(a*x)), x), x) + Simp((c + d*x**S(2))**(p + S(1))*(S(2)*a*x*(p + S(1)) + n)*exp(n*atanh(a*x))/(a*c*(n**S(2) - S(4)*(p + S(1))**S(2))), x) rule6524 = ReplacementRule(pattern6524, replacement6524) pattern6525 = Pattern(Integral(exp(WC('n', S(1))*atanh(x_*WC('a', S(1))))/(c_ + x_**S(2)*WC('d', S(1))), x_), cons2, cons7, cons27, cons4, cons1920, cons1922) def replacement6525(d, a, n, c, x): rubi.append(6525) return Simp(exp(n*atanh(a*x))/(a*c*n), x) rule6525 = ReplacementRule(pattern6525, replacement6525) pattern6526 = Pattern(Integral((c_ + x_**S(2)*WC('d', S(1)))**WC('p', S(1))*exp(WC('n', S(1))*atanh(x_*WC('a', S(1)))), x_), cons2, cons7, cons27, cons5, cons1920, cons38, cons1923, cons1924) def replacement6526(p, d, a, n, c, x): rubi.append(6526) return Dist(c**p, Int((a*x + S(1))**n*(-a**S(2)*x**S(2) + S(1))**(-n/S(2) + p), x), x) rule6526 = ReplacementRule(pattern6526, replacement6526) pattern6527 = Pattern(Integral((c_ + x_**S(2)*WC('d', S(1)))**WC('p', S(1))*exp(n_*atanh(x_*WC('a', S(1)))), x_), cons2, cons7, cons27, cons5, cons1920, cons38, cons1925, cons1924) def replacement6527(p, d, a, n, c, x): rubi.append(6527) return Dist(c**p, Int((-a*x + S(1))**(-n)*(-a**S(2)*x**S(2) + S(1))**(n/S(2) + p), x), x) rule6527 = ReplacementRule(pattern6527, replacement6527) pattern6528 = Pattern(Integral((c_ + x_**S(2)*WC('d', S(1)))**WC('p', S(1))*exp(WC('n', S(1))*atanh(x_*WC('a', S(1)))), x_), cons2, cons7, cons27, cons4, cons5, cons1920, cons1802) def replacement6528(p, d, a, n, c, x): rubi.append(6528) return Dist(c**p, Int((-a*x + S(1))**(-n/S(2) + p)*(a*x + S(1))**(n/S(2) + p), x), x) rule6528 = ReplacementRule(pattern6528, replacement6528) pattern6529 = Pattern(Integral((c_ + x_**S(2)*WC('d', S(1)))**WC('p', S(1))*exp(n_*atanh(x_*WC('a', S(1)))), x_), cons2, cons7, cons27, cons5, cons1920, cons1803, cons674) def replacement6529(p, d, a, n, c, x): rubi.append(6529) return Dist(c**(n/S(2)), Int((c + d*x**S(2))**(-n/S(2) + p)*(a*x + S(1))**n, x), x) rule6529 = ReplacementRule(pattern6529, replacement6529) pattern6530 = Pattern(Integral((c_ + x_**S(2)*WC('d', S(1)))**WC('p', S(1))*exp(n_*atanh(x_*WC('a', S(1)))), x_), cons2, cons7, cons27, cons5, cons1920, cons1803, cons1926) def replacement6530(p, d, a, n, c, x): rubi.append(6530) return Dist(c**(-n/S(2)), Int((c + d*x**S(2))**(n/S(2) + p)*(-a*x + S(1))**(-n), x), x) rule6530 = ReplacementRule(pattern6530, replacement6530) pattern6531 = Pattern(Integral((c_ + x_**S(2)*WC('d', S(1)))**p_*exp(WC('n', S(1))*atanh(x_*WC('a', S(1)))), x_), cons2, cons7, cons27, cons4, cons5, cons1920, cons1803) def replacement6531(p, d, a, n, c, x): rubi.append(6531) return Dist(c**IntPart(p)*(c + d*x**S(2))**FracPart(p)*(-a**S(2)*x**S(2) + S(1))**(-FracPart(p)), Int((-a**S(2)*x**S(2) + S(1))**p*exp(n*atanh(a*x)), x), x) rule6531 = ReplacementRule(pattern6531, replacement6531) pattern6532 = Pattern(Integral(x_*exp(n_*atanh(x_*WC('a', S(1))))/(c_ + x_**S(2)*WC('d', S(1)))**(S(3)/2), x_), cons2, cons7, cons27, cons4, cons1920, cons23) def replacement6532(d, a, n, c, x): rubi.append(6532) return Simp((-a*n*x + S(1))*exp(n*atanh(a*x))/(d*sqrt(c + d*x**S(2))*(n**S(2) + S(-1))), x) rule6532 = ReplacementRule(pattern6532, replacement6532) pattern6533 = Pattern(Integral(x_*(c_ + x_**S(2)*WC('d', S(1)))**p_*exp(n_*atanh(x_*WC('a', S(1)))), x_), cons2, cons7, cons27, cons4, cons1920, cons13, cons137, cons23, cons246) def replacement6533(p, d, a, n, c, x): rubi.append(6533) return -Dist(a*c*n/(S(2)*d*(p + S(1))), Int((c + d*x**S(2))**p*exp(n*atanh(a*x)), x), x) + Simp((c + d*x**S(2))**(p + S(1))*exp(n*atanh(a*x))/(S(2)*d*(p + S(1))), x) rule6533 = ReplacementRule(pattern6533, replacement6533) pattern6534 = Pattern(Integral(x_**S(2)*(c_ + x_**S(2)*WC('d', S(1)))**WC('p', S(1))*exp(n_*atanh(x_*WC('a', S(1)))), x_), cons2, cons7, cons27, cons4, cons1920, cons1927, cons23) def replacement6534(p, d, a, n, c, x): rubi.append(6534) return Simp((c + d*x**S(2))**(p + S(1))*(-a*n*x + S(1))*exp(n*atanh(a*x))/(a*d*n*(n**S(2) + S(-1))), x) rule6534 = ReplacementRule(pattern6534, replacement6534) pattern6535 = Pattern(Integral(x_**S(2)*(c_ + x_**S(2)*WC('d', S(1)))**p_*exp(n_*atanh(x_*WC('a', S(1)))), x_), cons2, cons7, cons27, cons4, cons1920, cons13, cons137, cons23, cons1921, cons246) def replacement6535(p, d, a, n, c, x): rubi.append(6535) return Dist((n**S(2) + S(2)*p + S(2))/(d*(n**S(2) - S(4)*(p + S(1))**S(2))), Int((c + d*x**S(2))**(p + S(1))*exp(n*atanh(a*x)), x), x) - Simp((c + d*x**S(2))**(p + S(1))*(S(2)*a*x*(p + S(1)) + n)*exp(n*atanh(a*x))/(a*d*(n**S(2) - S(4)*(p + S(1))**S(2))), x) rule6535 = ReplacementRule(pattern6535, replacement6535) pattern6536 = Pattern(Integral(x_**WC('m', S(1))*(c_ + x_**S(2)*WC('d', S(1)))**WC('p', S(1))*exp(WC('n', S(1))*atanh(x_*WC('a', S(1)))), x_), cons2, cons7, cons27, cons21, cons5, cons1920, cons1802, cons1923, cons1924) def replacement6536(p, m, d, a, n, c, x): rubi.append(6536) return Dist(c**p, Int(x**m*(a*x + S(1))**n*(-a**S(2)*x**S(2) + S(1))**(-n/S(2) + p), x), x) rule6536 = ReplacementRule(pattern6536, replacement6536) pattern6537 = Pattern(Integral(x_**WC('m', S(1))*(c_ + x_**S(2)*WC('d', S(1)))**WC('p', S(1))*exp(n_*atanh(x_*WC('a', S(1)))), x_), cons2, cons7, cons27, cons21, cons5, cons1920, cons1802, cons1925, cons1924) def replacement6537(p, m, d, a, n, c, x): rubi.append(6537) return Dist(c**p, Int(x**m*(-a*x + S(1))**(-n)*(-a**S(2)*x**S(2) + S(1))**(n/S(2) + p), x), x) rule6537 = ReplacementRule(pattern6537, replacement6537) pattern6538 = Pattern(Integral(x_**WC('m', S(1))*(c_ + x_**S(2)*WC('d', S(1)))**WC('p', S(1))*exp(WC('n', S(1))*atanh(x_*WC('a', S(1)))), x_), cons2, cons7, cons27, cons21, cons4, cons5, cons1920, cons1802) def replacement6538(p, m, d, a, n, c, x): rubi.append(6538) return Dist(c**p, Int(x**m*(-a*x + S(1))**(-n/S(2) + p)*(a*x + S(1))**(n/S(2) + p), x), x) rule6538 = ReplacementRule(pattern6538, replacement6538) pattern6539 = Pattern(Integral(x_**WC('m', S(1))*(c_ + x_**S(2)*WC('d', S(1)))**WC('p', S(1))*exp(n_*atanh(x_*WC('a', S(1)))), x_), cons2, cons7, cons27, cons21, cons5, cons1920, cons1803, cons674) def replacement6539(p, m, d, a, n, c, x): rubi.append(6539) return Dist(c**(n/S(2)), Int(x**m*(c + d*x**S(2))**(-n/S(2) + p)*(a*x + S(1))**n, x), x) rule6539 = ReplacementRule(pattern6539, replacement6539) pattern6540 = Pattern(Integral(x_**WC('m', S(1))*(c_ + x_**S(2)*WC('d', S(1)))**WC('p', S(1))*exp(n_*atanh(x_*WC('a', S(1)))), x_), cons2, cons7, cons27, cons21, cons5, cons1920, cons1803, cons1926) def replacement6540(p, m, d, a, n, c, x): rubi.append(6540) return Dist(c**(-n/S(2)), Int(x**m*(c + d*x**S(2))**(n/S(2) + p)*(-a*x + S(1))**(-n), x), x) rule6540 = ReplacementRule(pattern6540, replacement6540) pattern6541 = Pattern(Integral(x_**WC('m', S(1))*(c_ + x_**S(2)*WC('d', S(1)))**p_*exp(WC('n', S(1))*atanh(x_*WC('a', S(1)))), x_), cons2, cons7, cons27, cons21, cons4, cons5, cons1920, cons1803, cons1922) def replacement6541(p, m, d, a, n, c, x): rubi.append(6541) return Dist(c**IntPart(p)*(c + d*x**S(2))**FracPart(p)*(-a**S(2)*x**S(2) + S(1))**(-FracPart(p)), Int(x**m*(-a**S(2)*x**S(2) + S(1))**p*exp(n*atanh(a*x)), x), x) rule6541 = ReplacementRule(pattern6541, replacement6541) pattern6542 = Pattern(Integral(u_*(c_ + x_**S(2)*WC('d', S(1)))**WC('p', S(1))*exp(WC('n', S(1))*atanh(x_*WC('a', S(1)))), x_), cons2, cons7, cons27, cons4, cons5, cons1920, cons1802) def replacement6542(p, u, d, a, n, c, x): rubi.append(6542) return Dist(c**p, Int(u*(-a*x + S(1))**(-n/S(2) + p)*(a*x + S(1))**(n/S(2) + p), x), x) rule6542 = ReplacementRule(pattern6542, replacement6542) pattern6543 = Pattern(Integral(u_*(c_ + x_**S(2)*WC('d', S(1)))**p_*exp(n_*atanh(x_*WC('a', S(1)))), x_), cons2, cons7, cons27, cons4, cons5, cons1920, cons1803, cons743) def replacement6543(p, u, d, a, n, c, x): rubi.append(6543) return Dist(c**IntPart(p)*(c + d*x**S(2))**FracPart(p)*(-a*x + S(1))**(-FracPart(p))*(a*x + S(1))**(-FracPart(p)), Int(u*(-a*x + S(1))**(-n/S(2) + p)*(a*x + S(1))**(n/S(2) + p), x), x) rule6543 = ReplacementRule(pattern6543, replacement6543) pattern6544 = Pattern(Integral(u_*(c_ + x_**S(2)*WC('d', S(1)))**p_*exp(WC('n', S(1))*atanh(x_*WC('a', S(1)))), x_), cons2, cons7, cons27, cons4, cons5, cons1920, cons1803, cons1922) def replacement6544(p, u, d, a, n, c, x): rubi.append(6544) return Dist(c**IntPart(p)*(c + d*x**S(2))**FracPart(p)*(-a**S(2)*x**S(2) + S(1))**(-FracPart(p)), Int(u*(-a**S(2)*x**S(2) + S(1))**p*exp(n*atanh(a*x)), x), x) rule6544 = ReplacementRule(pattern6544, replacement6544) pattern6545 = Pattern(Integral((c_ + WC('d', S(1))/x_**S(2))**WC('p', S(1))*WC('u', S(1))*exp(WC('n', S(1))*atanh(x_*WC('a', S(1)))), x_), cons2, cons7, cons27, cons4, cons1928, cons38) def replacement6545(p, u, d, a, n, c, x): rubi.append(6545) return Dist(d**p, Int(u*x**(-S(2)*p)*(-a**S(2)*x**S(2) + S(1))**p*exp(n*atanh(a*x)), x), x) rule6545 = ReplacementRule(pattern6545, replacement6545) pattern6546 = Pattern(Integral((c_ + WC('d', S(1))/x_**S(2))**p_*WC('u', S(1))*exp(n_*atanh(x_*WC('a', S(1)))), x_), cons2, cons7, cons27, cons5, cons1928, cons147, cons743, cons177) def replacement6546(p, u, d, a, n, c, x): rubi.append(6546) return Dist(c**p, Int(u*(S(1) - S(1)/(a*x))**p*(S(1) + S(1)/(a*x))**p*exp(n*atanh(a*x)), x), x) rule6546 = ReplacementRule(pattern6546, replacement6546) pattern6547 = Pattern(Integral((c_ + WC('d', S(1))/x_**S(2))**p_*WC('u', S(1))*exp(n_*atanh(x_*WC('a', S(1)))), x_), cons2, cons7, cons27, cons4, cons5, cons1928, cons147, cons743, cons117) def replacement6547(p, u, d, a, n, c, x): rubi.append(6547) return Dist(x**(S(2)*p)*(c + d/x**S(2))**p*(-a*x + S(1))**(-p)*(a*x + S(1))**(-p), Int(u*x**(-S(2)*p)*(-a*x + S(1))**p*(a*x + S(1))**p*exp(n*atanh(a*x)), x), x) rule6547 = ReplacementRule(pattern6547, replacement6547) pattern6548 = Pattern(Integral((c_ + WC('d', S(1))/x_**S(2))**p_*WC('u', S(1))*exp(WC('n', S(1))*atanh(x_*WC('a', S(1)))), x_), cons2, cons7, cons27, cons4, cons5, cons1928, cons147, cons1922) def replacement6548(p, u, d, a, n, c, x): rubi.append(6548) return Dist(x**(S(2)*p)*(c + d/x**S(2))**p*(c*x**S(2)/d + S(1))**(-p), Int(u*x**(-S(2)*p)*(c*x**S(2)/d + S(1))**p*exp(n*atanh(a*x)), x), x) rule6548 = ReplacementRule(pattern6548, replacement6548) pattern6549 = Pattern(Integral(exp(WC('n', S(1))*atanh((a_ + x_*WC('b', S(1)))*WC('c', S(1)))), x_), cons2, cons3, cons7, cons4, cons1579) def replacement6549(b, c, n, a, x): rubi.append(6549) return Int((-a*c - b*c*x + S(1))**(-n/S(2))*(a*c + b*c*x + S(1))**(n/S(2)), x) rule6549 = ReplacementRule(pattern6549, replacement6549) pattern6550 = Pattern(Integral(x_**m_*exp(n_*atanh((a_ + x_*WC('b', S(1)))*WC('c', S(1)))), x_), cons2, cons3, cons7, cons84, cons87, cons994) def replacement6550(m, b, c, n, a, x): rubi.append(6550) return Dist(S(4)*b**(-m + S(-1))*c**(-m + S(-1))/n, Subst(Int(x**(S(2)/n)*(x**(S(2)/n) + S(1))**(-m + S(-2))*(-a*c + x**(S(2)/n)*(-a*c + S(1)) + S(-1))**m, x), x, (-c*(a + b*x) + S(1))**(-n/S(2))*(c*(a + b*x) + S(1))**(n/S(2))), x) rule6550 = ReplacementRule(pattern6550, replacement6550) pattern6551 = Pattern(Integral((x_*WC('e', S(1)) + WC('d', S(0)))**WC('m', S(1))*exp(WC('n', S(1))*atanh((a_ + x_*WC('b', S(1)))*WC('c', S(1)))), x_), cons2, cons3, cons7, cons27, cons48, cons21, cons4, cons1580) def replacement6551(m, b, d, c, n, a, x, e): rubi.append(6551) return Int((d + e*x)**m*(-a*c - b*c*x + S(1))**(-n/S(2))*(a*c + b*c*x + S(1))**(n/S(2)), x) rule6551 = ReplacementRule(pattern6551, replacement6551) pattern6552 = Pattern(Integral((c_ + x_**S(2)*WC('e', S(1)) + x_*WC('d', S(1)))**WC('p', S(1))*WC('u', S(1))*exp(WC('n', S(1))*atanh(a_ + x_*WC('b', S(1)))), x_), cons2, cons3, cons7, cons27, cons48, cons4, cons5, cons1818, cons1929, cons1930) def replacement6552(p, u, b, d, a, n, c, x, e): rubi.append(6552) return Dist((c/(-a**S(2) + S(1)))**p, Int(u*(-a - b*x + S(1))**(-n/S(2) + p)*(a + b*x + S(1))**(n/S(2) + p), x), x) rule6552 = ReplacementRule(pattern6552, replacement6552) pattern6553 = Pattern(Integral((c_ + x_**S(2)*WC('e', S(1)) + x_*WC('d', S(1)))**WC('p', S(1))*WC('u', S(1))*exp(WC('n', S(1))*atanh(a_ + x_*WC('b', S(1)))), x_), cons2, cons3, cons7, cons27, cons48, cons4, cons5, cons1818, cons1929, cons1931) def replacement6553(p, u, b, d, a, n, c, x, e): rubi.append(6553) return Dist((c + d*x + e*x**S(2))**p*(-a**S(2) - S(2)*a*b*x - b**S(2)*x**S(2) + S(1))**(-p), Int(u*(-a**S(2) - S(2)*a*b*x - b**S(2)*x**S(2) + S(1))**p*exp(n*atanh(a*x)), x), x) rule6553 = ReplacementRule(pattern6553, replacement6553) pattern6554 = Pattern(Integral(WC('u', S(1))*exp(WC('n', S(1))*atanh(WC('c', S(1))/(x_*WC('b', S(1)) + WC('a', S(0))))), x_), cons2, cons3, cons7, cons4, cons1579) def replacement6554(u, b, c, n, a, x): rubi.append(6554) return Int(u*exp(n*acoth(a/c + b*x/c)), x) rule6554 = ReplacementRule(pattern6554, replacement6554) pattern6555 = Pattern(Integral(WC('u', S(1))*exp(n_*acoth(x_*WC('a', S(1)))), x_), cons2, cons743) def replacement6555(x, a, n, u): rubi.append(6555) return Dist((S(-1))**(n/S(2)), Int(u*exp(n*atanh(a*x)), x), x) rule6555 = ReplacementRule(pattern6555, replacement6555) pattern6556 = Pattern(Integral(exp(WC('n', S(1))*acoth(x_*WC('a', S(1)))), x_), cons2, cons1482) def replacement6556(x, a, n): rubi.append(6556) return -Subst(Int((S(1) - x/a)**(-n/S(2) + S(1)/2)*(S(1) + x/a)**(n/S(2) + S(1)/2)/(x**S(2)*sqrt(S(1) - x**S(2)/a**S(2))), x), x, S(1)/x) rule6556 = ReplacementRule(pattern6556, replacement6556) pattern6557 = Pattern(Integral(x_**WC('m', S(1))*exp(WC('n', S(1))*acoth(x_*WC('a', S(1)))), x_), cons2, cons1482, cons17) def replacement6557(x, m, a, n): rubi.append(6557) return -Subst(Int(x**(-m + S(-2))*(S(1) - x/a)**(-n/S(2) + S(1)/2)*(S(1) + x/a)**(n/S(2) + S(1)/2)/sqrt(S(1) - x**S(2)/a**S(2)), x), x, S(1)/x) rule6557 = ReplacementRule(pattern6557, replacement6557) pattern6558 = Pattern(Integral(exp(n_*acoth(x_*WC('a', S(1)))), x_), cons2, cons4, cons23) def replacement6558(x, a, n): rubi.append(6558) return -Subst(Int((S(1) - x/a)**(-n/S(2))*(S(1) + x/a)**(n/S(2))/x**S(2), x), x, S(1)/x) rule6558 = ReplacementRule(pattern6558, replacement6558) pattern6559 = Pattern(Integral(x_**WC('m', S(1))*exp(n_*acoth(x_*WC('a', S(1)))), x_), cons2, cons4, cons23, cons17) def replacement6559(x, m, a, n): rubi.append(6559) return -Subst(Int(x**(-m + S(-2))*(S(1) - x/a)**(-n/S(2))*(S(1) + x/a)**(n/S(2)), x), x, S(1)/x) rule6559 = ReplacementRule(pattern6559, replacement6559) pattern6560 = Pattern(Integral(x_**m_*exp(WC('n', S(1))*acoth(x_*WC('a', S(1)))), x_), cons2, cons21, cons1482, cons18) def replacement6560(x, m, a, n): rubi.append(6560) return -Dist(x**m*(S(1)/x)**m, Subst(Int(x**(-m + S(-2))*(S(1) - x/a)**(-n/S(2) + S(1)/2)*(S(1) + x/a)**(n/S(2) + S(1)/2)/sqrt(S(1) - x**S(2)/a**S(2)), x), x, S(1)/x), x) rule6560 = ReplacementRule(pattern6560, replacement6560) pattern6561 = Pattern(Integral(x_**m_*exp(n_*acoth(x_*WC('a', S(1)))), x_), cons2, cons21, cons4, cons23, cons18) def replacement6561(x, m, a, n): rubi.append(6561) return -Dist(x**m*(S(1)/x)**m, Subst(Int(x**(-m + S(-2))*(S(1) - x/a)**(-n/S(2))*(S(1) + x/a)**(n/S(2)), x), x, S(1)/x), x) rule6561 = ReplacementRule(pattern6561, replacement6561) pattern6562 = Pattern(Integral((c_ + x_*WC('d', S(1)))**WC('p', S(1))*exp(WC('n', S(1))*acoth(x_*WC('a', S(1)))), x_), cons2, cons7, cons27, cons4, cons5, cons1916, cons1932, cons1922) def replacement6562(p, d, a, n, c, x): rubi.append(6562) return Simp((c + d*x)**p*(a*x + S(1))*exp(n*acoth(a*x))/(a*(p + S(1))), x) rule6562 = ReplacementRule(pattern6562, replacement6562) pattern6563 = Pattern(Integral((c_ + x_*WC('d', S(1)))**WC('p', S(1))*WC('u', S(1))*exp(WC('n', S(1))*acoth(x_*WC('a', S(1)))), x_), cons2, cons7, cons27, cons4, cons1918, cons1922, cons38) def replacement6563(p, u, d, a, n, c, x): rubi.append(6563) return Dist(d**p, Int(u*x**p*(c/(d*x) + S(1))**p*exp(n*acoth(a*x)), x), x) rule6563 = ReplacementRule(pattern6563, replacement6563) pattern6564 = Pattern(Integral((c_ + x_*WC('d', S(1)))**p_*WC('u', S(1))*exp(WC('n', S(1))*acoth(x_*WC('a', S(1)))), x_), cons2, cons7, cons27, cons4, cons5, cons1918, cons1922, cons147) def replacement6564(p, u, d, a, n, c, x): rubi.append(6564) return Dist(x**(-p)*(c + d*x)**p*(c/(d*x) + S(1))**(-p), Int(u*x**p*(c/(d*x) + S(1))**p*exp(n*acoth(a*x)), x), x) rule6564 = ReplacementRule(pattern6564, replacement6564) pattern6565 = Pattern(Integral((c_ + WC('d', S(1))/x_)**WC('p', S(1))*exp(WC('n', S(1))*acoth(x_*WC('a', S(1)))), x_), cons2, cons7, cons27, cons5, cons1933, cons1250, cons1917, cons246) def replacement6565(p, d, a, n, c, x): rubi.append(6565) return -Dist(c**n, Subst(Int((S(1) - x**S(2)/a**S(2))**(n/S(2))*(c + d*x)**(-n + p)/x**S(2), x), x, S(1)/x), x) rule6565 = ReplacementRule(pattern6565, replacement6565) pattern6566 = Pattern(Integral(x_**WC('m', S(1))*(c_ + WC('d', S(1))/x_)**WC('p', S(1))*exp(WC('n', S(1))*acoth(x_*WC('a', S(1)))), x_), cons2, cons7, cons27, cons5, cons1933, cons1250, cons17, cons1934, cons246) def replacement6566(p, m, d, a, n, c, x): rubi.append(6566) return -Dist(c**n, Subst(Int(x**(-m + S(-2))*(S(1) - x**S(2)/a**S(2))**(n/S(2))*(c + d*x)**(-n + p), x), x, S(1)/x), x) rule6566 = ReplacementRule(pattern6566, replacement6566) pattern6567 = Pattern(Integral((c_ + WC('d', S(1))/x_)**WC('p', S(1))*exp(WC('n', S(1))*acoth(x_*WC('a', S(1)))), x_), cons2, cons7, cons27, cons4, cons5, cons1919, cons1922, cons1802) def replacement6567(p, d, a, n, c, x): rubi.append(6567) return -Dist(c**p, Subst(Int((S(1) - x/a)**(-n/S(2))*(S(1) + x/a)**(n/S(2))*(S(1) + d*x/c)**p/x**S(2), x), x, S(1)/x), x) rule6567 = ReplacementRule(pattern6567, replacement6567) pattern6568 = Pattern(Integral(x_**WC('m', S(1))*(c_ + WC('d', S(1))/x_)**WC('p', S(1))*exp(WC('n', S(1))*acoth(x_*WC('a', S(1)))), x_), cons2, cons7, cons27, cons4, cons5, cons1919, cons1922, cons1802, cons17) def replacement6568(p, m, d, a, n, c, x): rubi.append(6568) return -Dist(c**p, Subst(Int(x**(-m + S(-2))*(S(1) - x/a)**(-n/S(2))*(S(1) + x/a)**(n/S(2))*(S(1) + d*x/c)**p, x), x, S(1)/x), x) rule6568 = ReplacementRule(pattern6568, replacement6568) pattern6569 = Pattern(Integral(x_**m_*(c_ + WC('d', S(1))/x_)**WC('p', S(1))*exp(WC('n', S(1))*acoth(x_*WC('a', S(1)))), x_), cons2, cons7, cons27, cons21, cons4, cons5, cons1919, cons1922, cons1802, cons18) def replacement6569(p, m, d, a, n, c, x): rubi.append(6569) return -Dist(c**p*x**m*(S(1)/x)**m, Subst(Int(x**(-m + S(-2))*(S(1) - x/a)**(-n/S(2))*(S(1) + x/a)**(n/S(2))*(S(1) + d*x/c)**p, x), x, S(1)/x), x) rule6569 = ReplacementRule(pattern6569, replacement6569) pattern6570 = Pattern(Integral((c_ + WC('d', S(1))/x_)**p_*WC('u', S(1))*exp(WC('n', S(1))*acoth(x_*WC('a', S(1)))), x_), cons2, cons7, cons27, cons4, cons5, cons1919, cons1922, cons1803) def replacement6570(p, u, d, a, n, c, x): rubi.append(6570) return Dist((S(1) + d/(c*x))**(-p)*(c + d/x)**p, Int(u*(S(1) + d/(c*x))**p*exp(n*acoth(a*x)), x), x) rule6570 = ReplacementRule(pattern6570, replacement6570) pattern6571 = Pattern(Integral(exp(WC('n', S(1))*acoth(x_*WC('a', S(1))))/(c_ + x_**S(2)*WC('d', S(1))), x_), cons2, cons7, cons27, cons4, cons1920, cons1922) def replacement6571(d, a, n, c, x): rubi.append(6571) return Simp(exp(n*acoth(a*x))/(a*c*n), x) rule6571 = ReplacementRule(pattern6571, replacement6571) pattern6572 = Pattern(Integral(exp(n_*acoth(x_*WC('a', S(1))))/(c_ + x_**S(2)*WC('d', S(1)))**(S(3)/2), x_), cons2, cons7, cons27, cons4, cons1920, cons23) def replacement6572(d, a, n, c, x): rubi.append(6572) return Simp((-a*x + n)*exp(n*acoth(a*x))/(a*c*sqrt(c + d*x**S(2))*(n**S(2) + S(-1))), x) rule6572 = ReplacementRule(pattern6572, replacement6572) pattern6573 = Pattern(Integral((c_ + x_**S(2)*WC('d', S(1)))**p_*exp(WC('n', S(1))*acoth(x_*WC('a', S(1)))), x_), cons2, cons7, cons27, cons4, cons1920, cons1922, cons13, cons137, cons230, cons1921, cons1935) def replacement6573(p, d, a, n, c, x): rubi.append(6573) return -Dist(S(2)*(p + S(1))*(S(2)*p + S(3))/(c*(n**S(2) - S(4)*(p + S(1))**S(2))), Int((c + d*x**S(2))**(p + S(1))*exp(n*acoth(a*x)), x), x) + Simp((c + d*x**S(2))**(p + S(1))*(S(2)*a*x*(p + S(1)) + n)*exp(n*acoth(a*x))/(a*c*(n**S(2) - S(4)*(p + S(1))**S(2))), x) rule6573 = ReplacementRule(pattern6573, replacement6573) pattern6574 = Pattern(Integral(x_*exp(n_*acoth(x_*WC('a', S(1))))/(c_ + x_**S(2)*WC('d', S(1)))**(S(3)/2), x_), cons2, cons7, cons27, cons4, cons1920, cons23) def replacement6574(d, a, n, c, x): rubi.append(6574) return -Simp((-a*n*x + S(1))*exp(n*acoth(a*x))/(a**S(2)*c*sqrt(c + d*x**S(2))*(n**S(2) + S(-1))), x) rule6574 = ReplacementRule(pattern6574, replacement6574) pattern6575 = Pattern(Integral(x_*(c_ + x_**S(2)*WC('d', S(1)))**p_*exp(WC('n', S(1))*acoth(x_*WC('a', S(1)))), x_), cons2, cons7, cons27, cons4, cons1920, cons1922, cons13, cons1824, cons230, cons1921, cons1935) def replacement6575(p, d, a, n, c, x): rubi.append(6575) return -Dist(n*(S(2)*p + S(3))/(a*c*(n**S(2) - S(4)*(p + S(1))**S(2))), Int((c + d*x**S(2))**(p + S(1))*exp(n*acoth(a*x)), x), x) + Simp((c + d*x**S(2))**(p + S(1))*(a*n*x + S(2)*p + S(2))*exp(n*acoth(a*x))/(a**S(2)*c*(n**S(2) - S(4)*(p + S(1))**S(2))), x) rule6575 = ReplacementRule(pattern6575, replacement6575) pattern6576 = Pattern(Integral(x_**S(2)*(c_ + x_**S(2)*WC('d', S(1)))**WC('p', S(1))*exp(WC('n', S(1))*acoth(x_*WC('a', S(1)))), x_), cons2, cons7, cons27, cons4, cons1920, cons1922, cons1927, cons973) def replacement6576(p, d, a, n, c, x): rubi.append(6576) return -Simp((c + d*x**S(2))**(p + S(1))*(S(2)*a*x*(p + S(1)) + n)*exp(n*acoth(a*x))/(a**S(3)*c*n**S(2)*(n**S(2) + S(-1))), x) rule6576 = ReplacementRule(pattern6576, replacement6576) pattern6577 = Pattern(Integral(x_**S(2)*(c_ + x_**S(2)*WC('d', S(1)))**p_*exp(WC('n', S(1))*acoth(x_*WC('a', S(1)))), x_), cons2, cons7, cons27, cons4, cons1920, cons1922, cons13, cons1824, cons1936, cons1921, cons1935) def replacement6577(p, d, a, n, c, x): rubi.append(6577) return -Dist((n**S(2) + S(2)*p + S(2))/(a**S(2)*c*(n**S(2) - S(4)*(p + S(1))**S(2))), Int((c + d*x**S(2))**(p + S(1))*exp(n*acoth(a*x)), x), x) + Simp((c + d*x**S(2))**(p + S(1))*(S(2)*a*x*(p + S(1)) + n)*exp(n*acoth(a*x))/(a**S(3)*c*(n**S(2) - S(4)*(p + S(1))**S(2))), x) rule6577 = ReplacementRule(pattern6577, replacement6577) pattern6578 = Pattern(Integral(x_**WC('m', S(1))*(c_ + x_**S(2)*WC('d', S(1)))**p_*exp(WC('n', S(1))*acoth(x_*WC('a', S(1)))), x_), cons2, cons7, cons27, cons4, cons1920, cons1922, cons17, cons13, cons1827, cons38) def replacement6578(p, m, d, a, n, c, x): rubi.append(6578) return -Dist(a**(-m + S(-1))*(-c)**p, Subst(Int((S(1)/tanh(x))**(m + S(2)*p + S(2))*exp(n*x)*cosh(x)**(-S(2)*p + S(-2)), x), x, acoth(a*x)), x) rule6578 = ReplacementRule(pattern6578, replacement6578) pattern6579 = Pattern(Integral((c_ + x_**S(2)*WC('d', S(1)))**WC('p', S(1))*WC('u', S(1))*exp(WC('n', S(1))*acoth(x_*WC('a', S(1)))), x_), cons2, cons7, cons27, cons4, cons1920, cons1922, cons38) def replacement6579(p, u, d, a, n, c, x): rubi.append(6579) return Dist(d**p, Int(u*x**(S(2)*p)*(S(1) - S(1)/(a**S(2)*x**S(2)))**p*exp(n*acoth(a*x)), x), x) rule6579 = ReplacementRule(pattern6579, replacement6579) pattern6580 = Pattern(Integral((c_ + x_**S(2)*WC('d', S(1)))**p_*WC('u', S(1))*exp(WC('n', S(1))*acoth(x_*WC('a', S(1)))), x_), cons2, cons7, cons27, cons4, cons5, cons1920, cons1922, cons147) def replacement6580(p, u, d, a, n, c, x): rubi.append(6580) return Dist(x**(-S(2)*p)*(S(1) - S(1)/(a**S(2)*x**S(2)))**(-p)*(c + d*x**S(2))**p, Int(u*x**(S(2)*p)*(S(1) - S(1)/(a**S(2)*x**S(2)))**p*exp(n*acoth(a*x)), x), x) rule6580 = ReplacementRule(pattern6580, replacement6580) pattern6581 = Pattern(Integral((c_ + WC('d', S(1))/x_**S(2))**WC('p', S(1))*WC('u', S(1))*exp(WC('n', S(1))*acoth(x_*WC('a', S(1)))), x_), cons2, cons7, cons27, cons4, cons5, cons1928, cons1922, cons1802, cons1937) def replacement6581(p, u, d, a, n, c, x): rubi.append(6581) return Dist(a**(-S(2)*p)*c**p, Int(u*x**(-S(2)*p)*(a*x + S(-1))**(-n/S(2) + p)*(a*x + S(1))**(n/S(2) + p), x), x) rule6581 = ReplacementRule(pattern6581, replacement6581) pattern6582 = Pattern(Integral((c_ + WC('d', S(1))/x_**S(2))**WC('p', S(1))*exp(WC('n', S(1))*acoth(x_*WC('a', S(1)))), x_), cons2, cons7, cons27, cons4, cons5, cons1928, cons1922, cons1802, cons1938) def replacement6582(p, d, a, n, c, x): rubi.append(6582) return -Dist(c**p, Subst(Int((S(1) - x/a)**(-n/S(2) + p)*(S(1) + x/a)**(n/S(2) + p)/x**S(2), x), x, S(1)/x), x) rule6582 = ReplacementRule(pattern6582, replacement6582) pattern6583 = Pattern(Integral(x_**WC('m', S(1))*(c_ + WC('d', S(1))/x_**S(2))**WC('p', S(1))*exp(WC('n', S(1))*acoth(x_*WC('a', S(1)))), x_), cons2, cons7, cons27, cons4, cons5, cons1928, cons1922, cons1802, cons1938, cons17) def replacement6583(p, m, d, a, n, c, x): rubi.append(6583) return -Dist(c**p, Subst(Int(x**(-m + S(-2))*(S(1) - x/a)**(-n/S(2) + p)*(S(1) + x/a)**(n/S(2) + p), x), x, S(1)/x), x) rule6583 = ReplacementRule(pattern6583, replacement6583) pattern6584 = Pattern(Integral(x_**m_*(c_ + WC('d', S(1))/x_**S(2))**WC('p', S(1))*exp(WC('n', S(1))*acoth(x_*WC('a', S(1)))), x_), cons2, cons7, cons27, cons21, cons4, cons5, cons1928, cons1922, cons1802, cons1938, cons18) def replacement6584(p, m, d, a, n, c, x): rubi.append(6584) return -Dist(c**p*x**m*(S(1)/x)**m, Subst(Int(x**(-m + S(-2))*(S(1) - x/a)**(-n/S(2) + p)*(S(1) + x/a)**(n/S(2) + p), x), x, S(1)/x), x) rule6584 = ReplacementRule(pattern6584, replacement6584) pattern6585 = Pattern(Integral((c_ + WC('d', S(1))/x_**S(2))**p_*WC('u', S(1))*exp(WC('n', S(1))*acoth(x_*WC('a', S(1)))), x_), cons2, cons7, cons27, cons4, cons5, cons1928, cons1922, cons1803) def replacement6585(p, u, d, a, n, c, x): rubi.append(6585) return Dist(c**IntPart(p)*(S(1) - S(1)/(a**S(2)*x**S(2)))**(-FracPart(p))*(c + d/x**S(2))**FracPart(p), Int(u*(S(1) - S(1)/(a**S(2)*x**S(2)))**p*exp(n*acoth(a*x)), x), x) rule6585 = ReplacementRule(pattern6585, replacement6585) pattern6586 = Pattern(Integral(WC('u', S(1))*exp(n_*acoth((a_ + x_*WC('b', S(1)))*WC('c', S(1)))), x_), cons2, cons3, cons7, cons743) def replacement6586(u, b, c, a, n, x): rubi.append(6586) return Dist((S(-1))**(n/S(2)), Int(u*exp(n*atanh(c*(a + b*x))), x), x) rule6586 = ReplacementRule(pattern6586, replacement6586) pattern6587 = Pattern(Integral(exp(WC('n', S(1))*acoth((a_ + x_*WC('b', S(1)))*WC('c', S(1)))), x_), cons2, cons3, cons7, cons4, cons1922) def replacement6587(b, c, n, a, x): rubi.append(6587) return Dist((c*(a + b*x))**(n/S(2))*(S(1) + S(1)/(c*(a + b*x)))**(n/S(2))*(a*c + b*c*x + S(1))**(-n/S(2)), Int((a*c + b*c*x + S(-1))**(-n/S(2))*(a*c + b*c*x + S(1))**(n/S(2)), x), x) rule6587 = ReplacementRule(pattern6587, replacement6587) pattern6588 = Pattern(Integral(x_**m_*exp(n_*acoth((a_ + x_*WC('b', S(1)))*WC('c', S(1)))), x_), cons2, cons3, cons7, cons84, cons87, cons994) def replacement6588(m, b, c, n, a, x): rubi.append(6588) return Dist(-S(4)*b**(-m + S(-1))*c**(-m + S(-1))/n, Subst(Int(x**(S(2)/n)*(x**(S(2)/n) + S(-1))**(-m + S(-2))*(a*c + x**(S(2)/n)*(-a*c + S(1)) + S(1))**m, x), x, (S(1) - S(1)/(c*(a + b*x)))**(-n/S(2))*(S(1) + S(1)/(c*(a + b*x)))**(n/S(2))), x) rule6588 = ReplacementRule(pattern6588, replacement6588) pattern6589 = Pattern(Integral((x_*WC('e', S(1)) + WC('d', S(0)))**WC('m', S(1))*exp(WC('n', S(1))*acoth((a_ + x_*WC('b', S(1)))*WC('c', S(1)))), x_), cons2, cons3, cons7, cons27, cons48, cons21, cons4, cons1922) def replacement6589(m, b, d, c, n, a, x, e): rubi.append(6589) return Dist((c*(a + b*x))**(n/S(2))*(S(1) + S(1)/(c*(a + b*x)))**(n/S(2))*(a*c + b*c*x + S(1))**(-n/S(2)), Int((d + e*x)**m*(a*c + b*c*x + S(-1))**(-n/S(2))*(a*c + b*c*x + S(1))**(n/S(2)), x), x) rule6589 = ReplacementRule(pattern6589, replacement6589) pattern6590 = Pattern(Integral((c_ + x_**S(2)*WC('e', S(1)) + x_*WC('d', S(1)))**WC('p', S(1))*WC('u', S(1))*exp(WC('n', S(1))*acoth(a_ + x_*WC('b', S(1)))), x_), cons2, cons3, cons7, cons27, cons48, cons4, cons5, cons1922, cons1818, cons1929, cons1930) def replacement6590(p, u, b, d, a, n, c, x, e): rubi.append(6590) return Dist((c/(-a**S(2) + S(1)))**p*((a + b*x + S(1))/(a + b*x))**(n/S(2))*((a + b*x)/(a + b*x + S(1)))**(n/S(2))*(-a - b*x + S(1))**(n/S(2))*(a + b*x + S(-1))**(-n/S(2)), Int(u*(-a - b*x + S(1))**(-n/S(2) + p)*(a + b*x + S(1))**(n/S(2) + p), x), x) rule6590 = ReplacementRule(pattern6590, replacement6590) pattern6591 = Pattern(Integral((c_ + x_**S(2)*WC('e', S(1)) + x_*WC('d', S(1)))**WC('p', S(1))*WC('u', S(1))*exp(WC('n', S(1))*acoth(a_ + x_*WC('b', S(1)))), x_), cons2, cons3, cons7, cons27, cons48, cons4, cons5, cons1922, cons1818, cons1929, cons1931) def replacement6591(p, u, b, d, a, n, c, x, e): rubi.append(6591) return Dist((c + d*x + e*x**S(2))**p*(-a**S(2) - S(2)*a*b*x - b**S(2)*x**S(2) + S(1))**(-p), Int(u*(-a**S(2) - S(2)*a*b*x - b**S(2)*x**S(2) + S(1))**p*exp(n*acoth(a*x)), x), x) rule6591 = ReplacementRule(pattern6591, replacement6591) pattern6592 = Pattern(Integral(WC('u', S(1))*exp(WC('n', S(1))*acoth(WC('c', S(1))/(x_*WC('b', S(1)) + WC('a', S(0))))), x_), cons2, cons3, cons7, cons4, cons1579) def replacement6592(u, b, c, n, a, x): rubi.append(6592) return Int(u*exp(n*atanh(a/c + b*x/c)), x) rule6592 = ReplacementRule(pattern6592, replacement6592) pattern6593 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*atanh(c_ + x_*WC('d', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons148) def replacement6593(b, d, c, a, n, x): rubi.append(6593) return Dist(S(1)/d, Subst(Int((a + b*atanh(x))**n, x), x, c + d*x), x) rule6593 = ReplacementRule(pattern6593, replacement6593) pattern6594 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*acoth(c_ + x_*WC('d', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons148) def replacement6594(b, d, c, a, n, x): rubi.append(6594) return Dist(S(1)/d, Subst(Int((a + b*acoth(x))**n, x), x, c + d*x), x) rule6594 = ReplacementRule(pattern6594, replacement6594) pattern6595 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*atanh(c_ + x_*WC('d', S(1))))**n_, x_), cons2, cons3, cons7, cons27, cons4, cons340) def replacement6595(b, d, c, a, n, x): rubi.append(6595) return Int((a + b*atanh(c + d*x))**n, x) rule6595 = ReplacementRule(pattern6595, replacement6595) pattern6596 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*acoth(c_ + x_*WC('d', S(1))))**n_, x_), cons2, cons3, cons7, cons27, cons4, cons340) def replacement6596(b, d, c, a, n, x): rubi.append(6596) return Int((a + b*acoth(c + d*x))**n, x) rule6596 = ReplacementRule(pattern6596, replacement6596) pattern6597 = Pattern(Integral((x_*WC('f', S(1)) + WC('e', S(0)))**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*atanh(c_ + x_*WC('d', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons4, cons148) def replacement6597(m, f, b, d, a, n, c, x, e): rubi.append(6597) return Dist(S(1)/d, Subst(Int((a + b*atanh(x))**n*(f*x/d + (-c*f + d*e)/d)**m, x), x, c + d*x), x) rule6597 = ReplacementRule(pattern6597, replacement6597) pattern6598 = Pattern(Integral((x_*WC('f', S(1)) + WC('e', S(0)))**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*acoth(c_ + x_*WC('d', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons4, cons148) def replacement6598(m, f, b, d, a, n, c, x, e): rubi.append(6598) return Dist(S(1)/d, Subst(Int((a + b*acoth(x))**n*(f*x/d + (-c*f + d*e)/d)**m, x), x, c + d*x), x) rule6598 = ReplacementRule(pattern6598, replacement6598) pattern6599 = Pattern(Integral((x_*WC('f', S(1)) + WC('e', S(0)))**m_*(WC('a', S(0)) + WC('b', S(1))*atanh(c_ + x_*WC('d', S(1))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons4, cons340) def replacement6599(m, f, b, d, a, c, n, x, e): rubi.append(6599) return Int((a + b*atanh(c + d*x))**n*(e + f*x)**m, x) rule6599 = ReplacementRule(pattern6599, replacement6599) pattern6600 = Pattern(Integral((x_*WC('f', S(1)) + WC('e', S(0)))**m_*(WC('a', S(0)) + WC('b', S(1))*acoth(c_ + x_*WC('d', S(1))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons4, cons340) def replacement6600(m, f, b, d, a, c, n, x, e): rubi.append(6600) return Int((a + b*acoth(c + d*x))**n*(e + f*x)**m, x) rule6600 = ReplacementRule(pattern6600, replacement6600) pattern6601 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*atanh(c_ + x_*WC('d', S(1))))**WC('n', S(1))*(x_**S(2)*WC('C', S(1)) + x_*WC('B', S(1)) + WC('A', S(0)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons34, cons35, cons36, cons4, cons5, cons1762, cons1763) def replacement6601(B, C, p, b, d, a, n, c, x, A): rubi.append(6601) return Dist(S(1)/d, Subst(Int((a + b*atanh(x))**n*(C*x**S(2)/d**S(2) - C/d**S(2))**p, x), x, c + d*x), x) rule6601 = ReplacementRule(pattern6601, replacement6601) pattern6602 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*acoth(c_ + x_*WC('d', S(1))))**WC('n', S(1))*(x_**S(2)*WC('C', S(1)) + x_*WC('B', S(1)) + WC('A', S(0)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons34, cons35, cons36, cons4, cons5, cons1762, cons1763) def replacement6602(B, C, p, b, d, a, n, c, x, A): rubi.append(6602) return Dist(S(1)/d, Subst(Int((a + b*acoth(x))**n*(C*x**S(2)/d**S(2) + C/d**S(2))**p, x), x, c + d*x), x) rule6602 = ReplacementRule(pattern6602, replacement6602) pattern6603 = Pattern(Integral((x_*WC('f', S(1)) + WC('e', S(0)))**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*atanh(c_ + x_*WC('d', S(1))))**WC('n', S(1))*(x_**S(2)*WC('C', S(1)) + x_*WC('B', S(1)) + WC('A', S(0)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons36, cons21, cons4, cons5, cons1762, cons1763) def replacement6603(B, C, p, m, f, b, d, a, n, c, A, x, e): rubi.append(6603) return Dist(S(1)/d, Subst(Int((a + b*atanh(x))**n*(C*x**S(2)/d**S(2) - C/d**S(2))**p*(f*x/d + (-c*f + d*e)/d)**m, x), x, c + d*x), x) rule6603 = ReplacementRule(pattern6603, replacement6603) pattern6604 = Pattern(Integral((x_*WC('f', S(1)) + WC('e', S(0)))**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*acoth(c_ + x_*WC('d', S(1))))**WC('n', S(1))*(x_**S(2)*WC('C', S(1)) + x_*WC('B', S(1)) + WC('A', S(0)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons36, cons21, cons4, cons5, cons1762, cons1763) def replacement6604(B, C, p, m, f, b, d, a, n, c, A, x, e): rubi.append(6604) return Dist(S(1)/d, Subst(Int((a + b*acoth(x))**n*(C*x**S(2)/d**S(2) - C/d**S(2))**p*(f*x/d + (-c*f + d*e)/d)**m, x), x, c + d*x), x) rule6604 = ReplacementRule(pattern6604, replacement6604) pattern6605 = Pattern(Integral(atanh(a_ + x_*WC('b', S(1)))/(c_ + x_**WC('n', S(1))*WC('d', S(1))), x_), cons2, cons3, cons7, cons27, cons87) def replacement6605(b, d, a, n, c, x): rubi.append(6605) return -Dist(S(1)/2, Int(log(-a - b*x + S(1))/(c + d*x**n), x), x) + Dist(S(1)/2, Int(log(a + b*x + S(1))/(c + d*x**n), x), x) rule6605 = ReplacementRule(pattern6605, replacement6605) pattern6606 = Pattern(Integral(acoth(a_ + x_*WC('b', S(1)))/(c_ + x_**WC('n', S(1))*WC('d', S(1))), x_), cons2, cons3, cons7, cons27, cons87) def replacement6606(b, d, a, n, c, x): rubi.append(6606) return -Dist(S(1)/2, Int(log((a + b*x + S(-1))/(a + b*x))/(c + d*x**n), x), x) + Dist(S(1)/2, Int(log((a + b*x + S(1))/(a + b*x))/(c + d*x**n), x), x) rule6606 = ReplacementRule(pattern6606, replacement6606) pattern6607 = Pattern(Integral(atanh(a_ + x_*WC('b', S(1)))/(c_ + x_**n_*WC('d', S(1))), x_), cons2, cons3, cons7, cons27, cons4, cons1094) def replacement6607(b, d, c, a, n, x): rubi.append(6607) return Int(atanh(a + b*x)/(c + d*x**n), x) rule6607 = ReplacementRule(pattern6607, replacement6607) pattern6608 = Pattern(Integral(acoth(a_ + x_*WC('b', S(1)))/(c_ + x_**n_*WC('d', S(1))), x_), cons2, cons3, cons7, cons27, cons4, cons1094) def replacement6608(b, d, c, a, n, x): rubi.append(6608) return Int(acoth(a + b*x)/(c + d*x**n), x) rule6608 = ReplacementRule(pattern6608, replacement6608) pattern6609 = Pattern(Integral(atanh(a_ + x_**n_*WC('b', S(1))), x_), cons2, cons3, cons4, cons1831) def replacement6609(x, a, n, b): rubi.append(6609) return -Dist(b*n, Int(x**n/(-a**S(2) - S(2)*a*b*x**n - b**S(2)*x**(S(2)*n) + S(1)), x), x) + Simp(x*atanh(a + b*x**n), x) rule6609 = ReplacementRule(pattern6609, replacement6609) pattern6610 = Pattern(Integral(acoth(a_ + x_**n_*WC('b', S(1))), x_), cons2, cons3, cons4, cons1831) def replacement6610(x, a, n, b): rubi.append(6610) return -Dist(b*n, Int(x**n/(-a**S(2) - S(2)*a*b*x**n - b**S(2)*x**(S(2)*n) + S(1)), x), x) + Simp(x*acoth(a + b*x**n), x) rule6610 = ReplacementRule(pattern6610, replacement6610) pattern6611 = Pattern(Integral(atanh(x_**WC('n', S(1))*WC('b', S(1)) + WC('a', S(0)))/x_, x_), cons2, cons3, cons4, cons1831) def replacement6611(x, a, n, b): rubi.append(6611) return -Dist(S(1)/2, Int(log(-a - b*x**n + S(1))/x, x), x) + Dist(S(1)/2, Int(log(a + b*x**n + S(1))/x, x), x) rule6611 = ReplacementRule(pattern6611, replacement6611) pattern6612 = Pattern(Integral(acoth(x_**WC('n', S(1))*WC('b', S(1)) + WC('a', S(0)))/x_, x_), cons2, cons3, cons4, cons1831) def replacement6612(x, a, n, b): rubi.append(6612) return -Dist(S(1)/2, Int(log(S(1) - S(1)/(a + b*x**n))/x, x), x) + Dist(S(1)/2, Int(log(S(1) + S(1)/(a + b*x**n))/x, x), x) rule6612 = ReplacementRule(pattern6612, replacement6612) pattern6613 = Pattern(Integral(x_**WC('m', S(1))*atanh(a_ + x_**n_*WC('b', S(1))), x_), cons2, cons3, cons93, cons1832, cons1833) def replacement6613(m, b, a, n, x): rubi.append(6613) return -Dist(b*n/(m + S(1)), Int(x**(m + n)/(-a**S(2) - S(2)*a*b*x**n - b**S(2)*x**(S(2)*n) + S(1)), x), x) + Simp(x**(m + S(1))*atanh(a + b*x**n)/(m + S(1)), x) rule6613 = ReplacementRule(pattern6613, replacement6613) pattern6614 = Pattern(Integral(x_**WC('m', S(1))*acoth(a_ + x_**n_*WC('b', S(1))), x_), cons2, cons3, cons93, cons1832, cons1833) def replacement6614(m, b, a, n, x): rubi.append(6614) return -Dist(b*n/(m + S(1)), Int(x**(m + n)/(-a**S(2) - S(2)*a*b*x**n - b**S(2)*x**(S(2)*n) + S(1)), x), x) + Simp(x**(m + S(1))*acoth(a + b*x**n)/(m + S(1)), x) rule6614 = ReplacementRule(pattern6614, replacement6614) pattern6615 = Pattern(Integral(atanh(f_**(x_*WC('d', S(1)) + WC('c', S(0)))*WC('b', S(1)) + WC('a', S(0))), x_), cons2, cons3, cons7, cons27, cons125, cons1834) def replacement6615(f, b, d, c, a, x): rubi.append(6615) return -Dist(S(1)/2, Int(log(-a - b*f**(c + d*x) + S(1)), x), x) + Dist(S(1)/2, Int(log(a + b*f**(c + d*x) + S(1)), x), x) rule6615 = ReplacementRule(pattern6615, replacement6615) pattern6616 = Pattern(Integral(acoth(f_**(x_*WC('d', S(1)) + WC('c', S(0)))*WC('b', S(1)) + WC('a', S(0))), x_), cons2, cons3, cons7, cons27, cons125, cons1834) def replacement6616(f, b, d, c, a, x): rubi.append(6616) return -Dist(S(1)/2, Int(log(S(1) - S(1)/(a + b*f**(c + d*x))), x), x) + Dist(S(1)/2, Int(log(S(1) + S(1)/(a + b*f**(c + d*x))), x), x) rule6616 = ReplacementRule(pattern6616, replacement6616) pattern6617 = Pattern(Integral(x_**WC('m', S(1))*atanh(f_**(x_*WC('d', S(1)) + WC('c', S(0)))*WC('b', S(1)) + WC('a', S(0))), x_), cons2, cons3, cons7, cons27, cons125, cons17, cons168) def replacement6617(m, f, b, d, c, a, x): rubi.append(6617) return -Dist(S(1)/2, Int(x**m*log(-a - b*f**(c + d*x) + S(1)), x), x) + Dist(S(1)/2, Int(x**m*log(a + b*f**(c + d*x) + S(1)), x), x) rule6617 = ReplacementRule(pattern6617, replacement6617) pattern6618 = Pattern(Integral(x_**WC('m', S(1))*acoth(f_**(x_*WC('d', S(1)) + WC('c', S(0)))*WC('b', S(1)) + WC('a', S(0))), x_), cons2, cons3, cons7, cons27, cons125, cons17, cons168) def replacement6618(m, f, b, d, c, a, x): rubi.append(6618) return -Dist(S(1)/2, Int(x**m*log(S(1) - S(1)/(a + b*f**(c + d*x))), x), x) + Dist(S(1)/2, Int(x**m*log(S(1) + S(1)/(a + b*f**(c + d*x))), x), x) rule6618 = ReplacementRule(pattern6618, replacement6618) pattern6619 = Pattern(Integral(WC('u', S(1))*atanh(WC('c', S(1))/(x_**WC('n', S(1))*WC('b', S(1)) + WC('a', S(0))))**WC('m', S(1)), x_), cons2, cons3, cons7, cons4, cons21, cons1766) def replacement6619(u, m, b, c, n, a, x): rubi.append(6619) return Int(u*acoth(a/c + b*x**n/c)**m, x) rule6619 = ReplacementRule(pattern6619, replacement6619) pattern6620 = Pattern(Integral(WC('u', S(1))*acoth(WC('c', S(1))/(x_**WC('n', S(1))*WC('b', S(1)) + WC('a', S(0))))**WC('m', S(1)), x_), cons2, cons3, cons7, cons4, cons21, cons1766) def replacement6620(u, m, b, c, n, a, x): rubi.append(6620) return Int(u*atanh(a/c + b*x**n/c)**m, x) rule6620 = ReplacementRule(pattern6620, replacement6620) pattern6621 = Pattern(Integral(S(1)/(sqrt(x_**S(2)*WC('b', S(1)) + WC('a', S(0)))*atanh(x_*WC('c', S(1))/sqrt(x_**S(2)*WC('b', S(1)) + WC('a', S(0))))), x_), cons2, cons3, cons7, cons1939) def replacement6621(x, c, b, a): rubi.append(6621) return Simp(log(atanh(c*x/sqrt(a + b*x**S(2))))/c, x) rule6621 = ReplacementRule(pattern6621, replacement6621) pattern6622 = Pattern(Integral(S(1)/(sqrt(x_**S(2)*WC('b', S(1)) + WC('a', S(0)))*acoth(x_*WC('c', S(1))/sqrt(x_**S(2)*WC('b', S(1)) + WC('a', S(0))))), x_), cons2, cons3, cons7, cons1939) def replacement6622(x, c, b, a): rubi.append(6622) return -Simp(log(acoth(c*x/sqrt(a + b*x**S(2))))/c, x) rule6622 = ReplacementRule(pattern6622, replacement6622) pattern6623 = Pattern(Integral(atanh(x_*WC('c', S(1))/sqrt(x_**S(2)*WC('b', S(1)) + WC('a', S(0))))**WC('m', S(1))/sqrt(x_**S(2)*WC('b', S(1)) + WC('a', S(0))), x_), cons2, cons3, cons7, cons21, cons1939, cons66) def replacement6623(m, b, c, a, x): rubi.append(6623) return Simp(atanh(c*x/sqrt(a + b*x**S(2)))**(m + S(1))/(c*(m + S(1))), x) rule6623 = ReplacementRule(pattern6623, replacement6623) pattern6624 = Pattern(Integral(acoth(x_*WC('c', S(1))/sqrt(x_**S(2)*WC('b', S(1)) + WC('a', S(0))))**WC('m', S(1))/sqrt(x_**S(2)*WC('b', S(1)) + WC('a', S(0))), x_), cons2, cons3, cons7, cons21, cons1939, cons66) def replacement6624(m, b, c, a, x): rubi.append(6624) return -Simp(acoth(c*x/sqrt(a + b*x**S(2)))**(m + S(1))/(c*(m + S(1))), x) rule6624 = ReplacementRule(pattern6624, replacement6624) pattern6625 = Pattern(Integral(atanh(x_*WC('c', S(1))/sqrt(x_**S(2)*WC('b', S(1)) + WC('a', S(0))))**WC('m', S(1))/sqrt(x_**S(2)*WC('e', S(1)) + WC('d', S(0))), x_), cons2, cons3, cons7, cons27, cons48, cons21, cons1939, cons383) def replacement6625(m, b, d, c, a, x, e): rubi.append(6625) return Dist(sqrt(a + b*x**S(2))/sqrt(d + e*x**S(2)), Int(atanh(c*x/sqrt(a + b*x**S(2)))**m/sqrt(a + b*x**S(2)), x), x) rule6625 = ReplacementRule(pattern6625, replacement6625) pattern6626 = Pattern(Integral(acoth(x_*WC('c', S(1))/sqrt(x_**S(2)*WC('b', S(1)) + WC('a', S(0))))**WC('m', S(1))/sqrt(x_**S(2)*WC('e', S(1)) + WC('d', S(0))), x_), cons2, cons3, cons7, cons27, cons48, cons21, cons1939, cons383) def replacement6626(m, b, d, c, a, x, e): rubi.append(6626) return Dist(sqrt(a + b*x**S(2))/sqrt(d + e*x**S(2)), Int(acoth(c*x/sqrt(a + b*x**S(2)))**m/sqrt(a + b*x**S(2)), x), x) rule6626 = ReplacementRule(pattern6626, replacement6626) def With6627(d, a, n, c, x): u = IntHide((c + d*x**S(2))**n, x) rubi.append(6627) return -Dist(a, Int(Dist(S(1)/(-a**S(2)*x**S(2) + S(1)), u, x), x), x) + Dist(atanh(a*x), u, x) pattern6627 = Pattern(Integral((x_**S(2)*WC('d', S(1)) + WC('c', S(0)))**n_*atanh(x_*WC('a', S(1))), x_), cons2, cons7, cons27, cons808, cons1586) rule6627 = ReplacementRule(pattern6627, With6627) def With6628(d, a, n, c, x): u = IntHide((c + d*x**S(2))**n, x) rubi.append(6628) return -Dist(a, Int(Dist(S(1)/(-a**S(2)*x**S(2) + S(1)), u, x), x), x) + Dist(acoth(a*x), u, x) pattern6628 = Pattern(Integral((x_**S(2)*WC('d', S(1)) + WC('c', S(0)))**n_*acoth(x_*WC('a', S(1))), x_), cons2, cons7, cons27, cons808, cons1586) rule6628 = ReplacementRule(pattern6628, With6628) def With6629(v, x, n, u): if isinstance(x, (int, Integer, float, Float)): return False try: tmp = InverseFunctionOfLinear(u, x) res = And(Not(FalseQ(tmp)), SameQ(Head(tmp), ArcTanh), ZeroQ(-D(v, x)**S(2) + Discriminant(v, x)*Part(tmp, S(1))**S(2))) except (TypeError, AttributeError): return False if res: return True return False pattern6629 = Pattern(Integral(u_*v_**WC('n', S(1)), x_), cons818, cons85, cons463, cons1940, cons1941, CustomConstraint(With6629)) def replacement6629(v, x, n, u): tmp = InverseFunctionOfLinear(u, x) rubi.append(6629) return Dist((-Discriminant(v, x)/(S(4)*Coefficient(v, x, S(2))))**n/Coefficient(Part(tmp, S(1)), x, S(1)), Subst(Int(SimplifyIntegrand((S(1)/cosh(x))**(S(2)*n + S(2))*SubstForInverseFunction(u, tmp, x), x), x), x, tmp), x) rule6629 = ReplacementRule(pattern6629, replacement6629) def With6630(v, x, n, u): if isinstance(x, (int, Integer, float, Float)): return False try: tmp = InverseFunctionOfLinear(u, x) res = And(Not(FalseQ(tmp)), SameQ(Head(tmp), ArcCoth), ZeroQ(-D(v, x)**S(2) + Discriminant(v, x)*Part(tmp, S(1))**S(2))) except (TypeError, AttributeError): return False if res: return True return False pattern6630 = Pattern(Integral(u_*v_**WC('n', S(1)), x_), cons818, cons85, cons463, cons1940, cons1942, CustomConstraint(With6630)) def replacement6630(v, x, n, u): tmp = InverseFunctionOfLinear(u, x) rubi.append(6630) return Dist((-Discriminant(v, x)/(S(4)*Coefficient(v, x, S(2))))**n/Coefficient(Part(tmp, S(1)), x, S(1)), Subst(Int(SimplifyIntegrand((-S(1)/sinh(x)**S(2))**(n + S(1))*SubstForInverseFunction(u, tmp, x), x), x), x, tmp), x) rule6630 = ReplacementRule(pattern6630, replacement6630) pattern6631 = Pattern(Integral(atanh(WC('c', S(0)) + WC('d', S(1))*tanh(x_*WC('b', S(1)) + WC('a', S(0)))), x_), cons2, cons3, cons7, cons27, cons1943) def replacement6631(b, d, c, a, x): rubi.append(6631) return Dist(b, Int(x/(c*exp(S(2)*a + S(2)*b*x) + c - d), x), x) + Simp(x*atanh(c + d*tanh(a + b*x)), x) rule6631 = ReplacementRule(pattern6631, replacement6631) pattern6632 = Pattern(Integral(acoth(WC('c', S(0)) + WC('d', S(1))*tanh(x_*WC('b', S(1)) + WC('a', S(0)))), x_), cons2, cons3, cons7, cons27, cons1943) def replacement6632(b, d, c, a, x): rubi.append(6632) return Dist(b, Int(x/(c*exp(S(2)*a + S(2)*b*x) + c - d), x), x) + Simp(x*acoth(c + d*tanh(a + b*x)), x) rule6632 = ReplacementRule(pattern6632, replacement6632) pattern6633 = Pattern(Integral(atanh(WC('c', S(0)) + WC('d', S(1))/tanh(x_*WC('b', S(1)) + WC('a', S(0)))), x_), cons2, cons3, cons7, cons27, cons1943) def replacement6633(b, d, c, a, x): rubi.append(6633) return Dist(b, Int(x/(-c*exp(S(2)*a + S(2)*b*x) + c - d), x), x) + Simp(x*atanh(c + d/tanh(a + b*x)), x) rule6633 = ReplacementRule(pattern6633, replacement6633) pattern6634 = Pattern(Integral(acoth(WC('c', S(0)) + WC('d', S(1))/tanh(x_*WC('b', S(1)) + WC('a', S(0)))), x_), cons2, cons3, cons7, cons27, cons1943) def replacement6634(b, d, c, a, x): rubi.append(6634) return Dist(b, Int(x/(-c*exp(S(2)*a + S(2)*b*x) + c - d), x), x) + Simp(x*acoth(c + d/tanh(a + b*x)), x) rule6634 = ReplacementRule(pattern6634, replacement6634) pattern6635 = Pattern(Integral(atanh(WC('c', S(0)) + WC('d', S(1))*tanh(x_*WC('b', S(1)) + WC('a', S(0)))), x_), cons2, cons3, cons7, cons27, cons1944) def replacement6635(b, d, c, a, x): rubi.append(6635) return Dist(b*(-c - d + S(1)), Int(x*exp(S(2)*a + S(2)*b*x)/(-c + d + (-c - d + S(1))*exp(S(2)*a + S(2)*b*x) + S(1)), x), x) - Dist(b*(c + d + S(1)), Int(x*exp(S(2)*a + S(2)*b*x)/(c - d + (c + d + S(1))*exp(S(2)*a + S(2)*b*x) + S(1)), x), x) + Simp(x*atanh(c + d*tanh(a + b*x)), x) rule6635 = ReplacementRule(pattern6635, replacement6635) pattern6636 = Pattern(Integral(acoth(WC('c', S(0)) + WC('d', S(1))*tanh(x_*WC('b', S(1)) + WC('a', S(0)))), x_), cons2, cons3, cons7, cons27, cons1944) def replacement6636(b, d, c, a, x): rubi.append(6636) return Dist(b*(-c - d + S(1)), Int(x*exp(S(2)*a + S(2)*b*x)/(-c + d + (-c - d + S(1))*exp(S(2)*a + S(2)*b*x) + S(1)), x), x) - Dist(b*(c + d + S(1)), Int(x*exp(S(2)*a + S(2)*b*x)/(c - d + (c + d + S(1))*exp(S(2)*a + S(2)*b*x) + S(1)), x), x) + Simp(x*acoth(c + d*tanh(a + b*x)), x) rule6636 = ReplacementRule(pattern6636, replacement6636) pattern6637 = Pattern(Integral(atanh(WC('c', S(0)) + WC('d', S(1))/tanh(x_*WC('b', S(1)) + WC('a', S(0)))), x_), cons2, cons3, cons7, cons27, cons1944) def replacement6637(b, d, c, a, x): rubi.append(6637) return -Dist(b*(-c - d + S(1)), Int(x*exp(S(2)*a + S(2)*b*x)/(-c + d - (-c - d + S(1))*exp(S(2)*a + S(2)*b*x) + S(1)), x), x) + Dist(b*(c + d + S(1)), Int(x*exp(S(2)*a + S(2)*b*x)/(c - d - (c + d + S(1))*exp(S(2)*a + S(2)*b*x) + S(1)), x), x) + Simp(x*atanh(c + d/tanh(a + b*x)), x) rule6637 = ReplacementRule(pattern6637, replacement6637) pattern6638 = Pattern(Integral(acoth(WC('c', S(0)) + WC('d', S(1))/tanh(x_*WC('b', S(1)) + WC('a', S(0)))), x_), cons2, cons3, cons7, cons27, cons1944) def replacement6638(b, d, c, a, x): rubi.append(6638) return -Dist(b*(-c - d + S(1)), Int(x*exp(S(2)*a + S(2)*b*x)/(-c + d - (-c - d + S(1))*exp(S(2)*a + S(2)*b*x) + S(1)), x), x) + Dist(b*(c + d + S(1)), Int(x*exp(S(2)*a + S(2)*b*x)/(c - d - (c + d + S(1))*exp(S(2)*a + S(2)*b*x) + S(1)), x), x) + Simp(x*acoth(c + d/tanh(a + b*x)), x) rule6638 = ReplacementRule(pattern6638, replacement6638) pattern6639 = Pattern(Integral((x_*WC('f', S(1)) + WC('e', S(0)))**WC('m', S(1))*atanh(WC('c', S(0)) + WC('d', S(1))*tanh(x_*WC('b', S(1)) + WC('a', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons62, cons1943) def replacement6639(m, f, b, d, c, a, x, e): rubi.append(6639) return Dist(b/(f*(m + S(1))), Int((e + f*x)**(m + S(1))/(c*exp(S(2)*a + S(2)*b*x) + c - d), x), x) + Simp((e + f*x)**(m + S(1))*atanh(c + d*tanh(a + b*x))/(f*(m + S(1))), x) rule6639 = ReplacementRule(pattern6639, replacement6639) pattern6640 = Pattern(Integral((x_*WC('f', S(1)) + WC('e', S(0)))**WC('m', S(1))*acoth(WC('c', S(0)) + WC('d', S(1))*tanh(x_*WC('b', S(1)) + WC('a', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons62, cons1943) def replacement6640(m, f, b, d, c, a, x, e): rubi.append(6640) return Dist(b/(f*(m + S(1))), Int((e + f*x)**(m + S(1))/(c*exp(S(2)*a + S(2)*b*x) + c - d), x), x) + Simp((e + f*x)**(m + S(1))*acoth(c + d*tanh(a + b*x))/(f*(m + S(1))), x) rule6640 = ReplacementRule(pattern6640, replacement6640) pattern6641 = Pattern(Integral((x_*WC('f', S(1)) + WC('e', S(0)))**WC('m', S(1))*atanh(WC('c', S(0)) + WC('d', S(1))/tanh(x_*WC('b', S(1)) + WC('a', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons62, cons1943) def replacement6641(m, f, b, d, c, a, x, e): rubi.append(6641) return Dist(b/(f*(m + S(1))), Int((e + f*x)**(m + S(1))/(-c*exp(S(2)*a + S(2)*b*x) + c - d), x), x) + Simp((e + f*x)**(m + S(1))*atanh(c + d/tanh(a + b*x))/(f*(m + S(1))), x) rule6641 = ReplacementRule(pattern6641, replacement6641) pattern6642 = Pattern(Integral((x_*WC('f', S(1)) + WC('e', S(0)))**WC('m', S(1))*acoth(WC('c', S(0)) + WC('d', S(1))/tanh(x_*WC('b', S(1)) + WC('a', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons62, cons1943) def replacement6642(m, f, b, d, c, a, x, e): rubi.append(6642) return Dist(b/(f*(m + S(1))), Int((e + f*x)**(m + S(1))/(-c*exp(S(2)*a + S(2)*b*x) + c - d), x), x) + Simp((e + f*x)**(m + S(1))*acoth(c + d/tanh(a + b*x))/(f*(m + S(1))), x) rule6642 = ReplacementRule(pattern6642, replacement6642) pattern6643 = Pattern(Integral((x_*WC('f', S(1)) + WC('e', S(0)))**WC('m', S(1))*atanh(WC('c', S(0)) + WC('d', S(1))*tanh(x_*WC('b', S(1)) + WC('a', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons62, cons1944) def replacement6643(m, f, b, d, c, a, x, e): rubi.append(6643) return Dist(b*(-c - d + S(1))/(f*(m + S(1))), Int((e + f*x)**(m + S(1))*exp(S(2)*a + S(2)*b*x)/(-c + d + (-c - d + S(1))*exp(S(2)*a + S(2)*b*x) + S(1)), x), x) - Dist(b*(c + d + S(1))/(f*(m + S(1))), Int((e + f*x)**(m + S(1))*exp(S(2)*a + S(2)*b*x)/(c - d + (c + d + S(1))*exp(S(2)*a + S(2)*b*x) + S(1)), x), x) + Simp((e + f*x)**(m + S(1))*atanh(c + d*tanh(a + b*x))/(f*(m + S(1))), x) rule6643 = ReplacementRule(pattern6643, replacement6643) pattern6644 = Pattern(Integral((x_*WC('f', S(1)) + WC('e', S(0)))**WC('m', S(1))*acoth(WC('c', S(0)) + WC('d', S(1))*tanh(x_*WC('b', S(1)) + WC('a', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons62, cons1944) def replacement6644(m, f, b, d, c, a, x, e): rubi.append(6644) return Dist(b*(-c - d + S(1))/(f*(m + S(1))), Int((e + f*x)**(m + S(1))*exp(S(2)*a + S(2)*b*x)/(-c + d + (-c - d + S(1))*exp(S(2)*a + S(2)*b*x) + S(1)), x), x) - Dist(b*(c + d + S(1))/(f*(m + S(1))), Int((e + f*x)**(m + S(1))*exp(S(2)*a + S(2)*b*x)/(c - d + (c + d + S(1))*exp(S(2)*a + S(2)*b*x) + S(1)), x), x) + Simp((e + f*x)**(m + S(1))*acoth(c + d*tanh(a + b*x))/(f*(m + S(1))), x) rule6644 = ReplacementRule(pattern6644, replacement6644) pattern6645 = Pattern(Integral((x_*WC('f', S(1)) + WC('e', S(0)))**WC('m', S(1))*atanh(WC('c', S(0)) + WC('d', S(1))/tanh(x_*WC('b', S(1)) + WC('a', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons62, cons1944) def replacement6645(m, f, b, d, c, a, x, e): rubi.append(6645) return -Dist(b*(-c - d + S(1))/(f*(m + S(1))), Int((e + f*x)**(m + S(1))*exp(S(2)*a + S(2)*b*x)/(-c + d - (-c - d + S(1))*exp(S(2)*a + S(2)*b*x) + S(1)), x), x) + Dist(b*(c + d + S(1))/(f*(m + S(1))), Int((e + f*x)**(m + S(1))*exp(S(2)*a + S(2)*b*x)/(c - d - (c + d + S(1))*exp(S(2)*a + S(2)*b*x) + S(1)), x), x) + Simp((e + f*x)**(m + S(1))*atanh(c + d/tanh(a + b*x))/(f*(m + S(1))), x) rule6645 = ReplacementRule(pattern6645, replacement6645) pattern6646 = Pattern(Integral((x_*WC('f', S(1)) + WC('e', S(0)))**WC('m', S(1))*acoth(WC('c', S(0)) + WC('d', S(1))/tanh(x_*WC('b', S(1)) + WC('a', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons62, cons1944) def replacement6646(m, f, b, d, c, a, x, e): rubi.append(6646) return -Dist(b*(-c - d + S(1))/(f*(m + S(1))), Int((e + f*x)**(m + S(1))*exp(S(2)*a + S(2)*b*x)/(-c + d - (-c - d + S(1))*exp(S(2)*a + S(2)*b*x) + S(1)), x), x) + Dist(b*(c + d + S(1))/(f*(m + S(1))), Int((e + f*x)**(m + S(1))*exp(S(2)*a + S(2)*b*x)/(c - d - (c + d + S(1))*exp(S(2)*a + S(2)*b*x) + S(1)), x), x) + Simp((e + f*x)**(m + S(1))*acoth(c + d/tanh(a + b*x))/(f*(m + S(1))), x) rule6646 = ReplacementRule(pattern6646, replacement6646) pattern6647 = Pattern(Integral(atanh(tan(x_*WC('b', S(1)) + WC('a', S(0)))), x_), cons2, cons3, cons67) def replacement6647(x, a, b): rubi.append(6647) return -Dist(b, Int(x/cos(S(2)*a + S(2)*b*x), x), x) + Simp(x*atanh(tan(a + b*x)), x) rule6647 = ReplacementRule(pattern6647, replacement6647) pattern6648 = Pattern(Integral(acoth(tan(x_*WC('b', S(1)) + WC('a', S(0)))), x_), cons2, cons3, cons67) def replacement6648(x, a, b): rubi.append(6648) return -Dist(b, Int(x/cos(S(2)*a + S(2)*b*x), x), x) + Simp(x*acoth(tan(a + b*x)), x) rule6648 = ReplacementRule(pattern6648, replacement6648) pattern6649 = Pattern(Integral(atanh(S(1)/tan(x_*WC('b', S(1)) + WC('a', S(0)))), x_), cons2, cons3, cons67) def replacement6649(x, a, b): rubi.append(6649) return -Dist(b, Int(x/cos(S(2)*a + S(2)*b*x), x), x) + Simp(x*atanh(S(1)/tan(a + b*x)), x) rule6649 = ReplacementRule(pattern6649, replacement6649) pattern6650 = Pattern(Integral(acoth(S(1)/tan(x_*WC('b', S(1)) + WC('a', S(0)))), x_), cons2, cons3, cons67) def replacement6650(x, a, b): rubi.append(6650) return -Dist(b, Int(x/cos(S(2)*a + S(2)*b*x), x), x) + Simp(x*acoth(S(1)/tan(a + b*x)), x) rule6650 = ReplacementRule(pattern6650, replacement6650) pattern6651 = Pattern(Integral((x_*WC('f', S(1)) + WC('e', S(0)))**WC('m', S(1))*atanh(tan(x_*WC('b', S(1)) + WC('a', S(0)))), x_), cons2, cons3, cons48, cons125, cons62) def replacement6651(m, f, b, a, x, e): rubi.append(6651) return -Dist(b/(f*(m + S(1))), Int((e + f*x)**(m + S(1))/cos(S(2)*a + S(2)*b*x), x), x) + Simp((e + f*x)**(m + S(1))*atanh(tan(a + b*x))/(f*(m + S(1))), x) rule6651 = ReplacementRule(pattern6651, replacement6651) pattern6652 = Pattern(Integral((x_*WC('f', S(1)) + WC('e', S(0)))**WC('m', S(1))*acoth(tan(x_*WC('b', S(1)) + WC('a', S(0)))), x_), cons2, cons3, cons48, cons125, cons62) def replacement6652(m, f, b, a, x, e): rubi.append(6652) return -Dist(b/(f*(m + S(1))), Int((e + f*x)**(m + S(1))/cos(S(2)*a + S(2)*b*x), x), x) + Simp((e + f*x)**(m + S(1))*acoth(tan(a + b*x))/(f*(m + S(1))), x) rule6652 = ReplacementRule(pattern6652, replacement6652) pattern6653 = Pattern(Integral((x_*WC('f', S(1)) + WC('e', S(0)))**WC('m', S(1))*atanh(S(1)/tan(x_*WC('b', S(1)) + WC('a', S(0)))), x_), cons2, cons3, cons48, cons125, cons62) def replacement6653(m, f, b, a, x, e): rubi.append(6653) return -Dist(b/(f*(m + S(1))), Int((e + f*x)**(m + S(1))/cos(S(2)*a + S(2)*b*x), x), x) + Simp((e + f*x)**(m + S(1))*atanh(S(1)/tan(a + b*x))/(f*(m + S(1))), x) rule6653 = ReplacementRule(pattern6653, replacement6653) pattern6654 = Pattern(Integral((x_*WC('f', S(1)) + WC('e', S(0)))**WC('m', S(1))*acoth(S(1)/tan(x_*WC('b', S(1)) + WC('a', S(0)))), x_), cons2, cons3, cons48, cons125, cons62) def replacement6654(m, f, b, a, x, e): rubi.append(6654) return -Dist(b/(f*(m + S(1))), Int((e + f*x)**(m + S(1))/cos(S(2)*a + S(2)*b*x), x), x) + Simp((e + f*x)**(m + S(1))*acoth(S(1)/tan(a + b*x))/(f*(m + S(1))), x) rule6654 = ReplacementRule(pattern6654, replacement6654) pattern6655 = Pattern(Integral(atanh(WC('c', S(0)) + WC('d', S(1))*tan(x_*WC('b', S(1)) + WC('a', S(0)))), x_), cons2, cons3, cons7, cons27, cons1945) def replacement6655(b, d, c, a, x): rubi.append(6655) return Dist(I*b, Int(x/(c*exp(S(2)*I*a + S(2)*I*b*x) + c + I*d), x), x) + Simp(x*atanh(c + d*tan(a + b*x)), x) rule6655 = ReplacementRule(pattern6655, replacement6655) pattern6656 = Pattern(Integral(acoth(WC('c', S(0)) + WC('d', S(1))*tan(x_*WC('b', S(1)) + WC('a', S(0)))), x_), cons2, cons3, cons7, cons27, cons1945) def replacement6656(b, d, c, a, x): rubi.append(6656) return Dist(I*b, Int(x/(c*exp(S(2)*I*a + S(2)*I*b*x) + c + I*d), x), x) + Simp(x*acoth(c + d*tan(a + b*x)), x) rule6656 = ReplacementRule(pattern6656, replacement6656) pattern6657 = Pattern(Integral(atanh(WC('c', S(0)) + WC('d', S(1))/tan(x_*WC('b', S(1)) + WC('a', S(0)))), x_), cons2, cons3, cons7, cons27, cons1946) def replacement6657(b, d, c, a, x): rubi.append(6657) return Dist(I*b, Int(x/(-c*exp(S(2)*I*a + S(2)*I*b*x) + c - I*d), x), x) + Simp(x*atanh(c + d/tan(a + b*x)), x) rule6657 = ReplacementRule(pattern6657, replacement6657) pattern6658 = Pattern(Integral(acoth(WC('c', S(0)) + WC('d', S(1))/tan(x_*WC('b', S(1)) + WC('a', S(0)))), x_), cons2, cons3, cons7, cons27, cons1946) def replacement6658(b, d, c, a, x): rubi.append(6658) return Dist(I*b, Int(x/(-c*exp(S(2)*I*a + S(2)*I*b*x) + c - I*d), x), x) + Simp(x*acoth(c + d/tan(a + b*x)), x) rule6658 = ReplacementRule(pattern6658, replacement6658) pattern6659 = Pattern(Integral(atanh(WC('c', S(0)) + WC('d', S(1))*tan(x_*WC('b', S(1)) + WC('a', S(0)))), x_), cons2, cons3, cons7, cons27, cons1947) def replacement6659(b, d, c, a, x): rubi.append(6659) return Dist(I*b*(-c + I*d + S(1)), Int(x*exp(S(2)*I*a + S(2)*I*b*x)/(-c - I*d + (-c + I*d + S(1))*exp(S(2)*I*a + S(2)*I*b*x) + S(1)), x), x) - Dist(I*b*(c - I*d + S(1)), Int(x*exp(S(2)*I*a + S(2)*I*b*x)/(c + I*d + (c - I*d + S(1))*exp(S(2)*I*a + S(2)*I*b*x) + S(1)), x), x) + Simp(x*atanh(c + d*tan(a + b*x)), x) rule6659 = ReplacementRule(pattern6659, replacement6659) pattern6660 = Pattern(Integral(acoth(WC('c', S(0)) + WC('d', S(1))*tan(x_*WC('b', S(1)) + WC('a', S(0)))), x_), cons2, cons3, cons7, cons27, cons1947) def replacement6660(b, d, c, a, x): rubi.append(6660) return Dist(I*b*(-c + I*d + S(1)), Int(x*exp(S(2)*I*a + S(2)*I*b*x)/(-c - I*d + (-c + I*d + S(1))*exp(S(2)*I*a + S(2)*I*b*x) + S(1)), x), x) - Dist(I*b*(c - I*d + S(1)), Int(x*exp(S(2)*I*a + S(2)*I*b*x)/(c + I*d + (c - I*d + S(1))*exp(S(2)*I*a + S(2)*I*b*x) + S(1)), x), x) + Simp(x*acoth(c + d*tan(a + b*x)), x) rule6660 = ReplacementRule(pattern6660, replacement6660) pattern6661 = Pattern(Integral(atanh(WC('c', S(0)) + WC('d', S(1))/tan(x_*WC('b', S(1)) + WC('a', S(0)))), x_), cons2, cons3, cons7, cons27, cons1948) def replacement6661(b, d, c, a, x): rubi.append(6661) return -Dist(I*b*(-c - I*d + S(1)), Int(x*exp(S(2)*I*a + S(2)*I*b*x)/(-c + I*d - (-c - I*d + S(1))*exp(S(2)*I*a + S(2)*I*b*x) + S(1)), x), x) + Dist(I*b*(c + I*d + S(1)), Int(x*exp(S(2)*I*a + S(2)*I*b*x)/(c - I*d - (c + I*d + S(1))*exp(S(2)*I*a + S(2)*I*b*x) + S(1)), x), x) + Simp(x*atanh(c + d/tan(a + b*x)), x) rule6661 = ReplacementRule(pattern6661, replacement6661) pattern6662 = Pattern(Integral(acoth(WC('c', S(0)) + WC('d', S(1))/tan(x_*WC('b', S(1)) + WC('a', S(0)))), x_), cons2, cons3, cons7, cons27, cons1948) def replacement6662(b, d, c, a, x): rubi.append(6662) return -Dist(I*b*(-c - I*d + S(1)), Int(x*exp(S(2)*I*a + S(2)*I*b*x)/(-c + I*d - (-c - I*d + S(1))*exp(S(2)*I*a + S(2)*I*b*x) + S(1)), x), x) + Dist(I*b*(c + I*d + S(1)), Int(x*exp(S(2)*I*a + S(2)*I*b*x)/(c - I*d - (c + I*d + S(1))*exp(S(2)*I*a + S(2)*I*b*x) + S(1)), x), x) + Simp(x*acoth(c + d/tan(a + b*x)), x) rule6662 = ReplacementRule(pattern6662, replacement6662) pattern6663 = Pattern(Integral((x_*WC('f', S(1)) + WC('e', S(0)))**WC('m', S(1))*atanh(WC('c', S(0)) + WC('d', S(1))*tan(x_*WC('b', S(1)) + WC('a', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons62, cons1945) def replacement6663(m, f, b, d, c, a, x, e): rubi.append(6663) return Dist(I*b/(f*(m + S(1))), Int((e + f*x)**(m + S(1))/(c*exp(S(2)*I*a + S(2)*I*b*x) + c + I*d), x), x) + Simp((e + f*x)**(m + S(1))*atanh(c + d*tan(a + b*x))/(f*(m + S(1))), x) rule6663 = ReplacementRule(pattern6663, replacement6663) pattern6664 = Pattern(Integral((x_*WC('f', S(1)) + WC('e', S(0)))**WC('m', S(1))*acoth(WC('c', S(0)) + WC('d', S(1))*tan(x_*WC('b', S(1)) + WC('a', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons62, cons1945) def replacement6664(m, f, b, d, c, a, x, e): rubi.append(6664) return Dist(I*b/(f*(m + S(1))), Int((e + f*x)**(m + S(1))/(c*exp(S(2)*I*a + S(2)*I*b*x) + c + I*d), x), x) + Simp((e + f*x)**(m + S(1))*acoth(c + d*tan(a + b*x))/(f*(m + S(1))), x) rule6664 = ReplacementRule(pattern6664, replacement6664) pattern6665 = Pattern(Integral((x_*WC('f', S(1)) + WC('e', S(0)))**WC('m', S(1))*atanh(WC('c', S(0)) + WC('d', S(1))/tan(x_*WC('b', S(1)) + WC('a', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons62, cons1946) def replacement6665(m, f, b, d, c, a, x, e): rubi.append(6665) return Dist(I*b/(f*(m + S(1))), Int((e + f*x)**(m + S(1))/(-c*exp(S(2)*I*a + S(2)*I*b*x) + c - I*d), x), x) + Simp((e + f*x)**(m + S(1))*atanh(c + d/tan(a + b*x))/(f*(m + S(1))), x) rule6665 = ReplacementRule(pattern6665, replacement6665) pattern6666 = Pattern(Integral((x_*WC('f', S(1)) + WC('e', S(0)))**WC('m', S(1))*acoth(WC('c', S(0)) + WC('d', S(1))/tan(x_*WC('b', S(1)) + WC('a', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons62, cons1946) def replacement6666(m, f, b, d, c, a, x, e): rubi.append(6666) return Dist(I*b/(f*(m + S(1))), Int((e + f*x)**(m + S(1))/(-c*exp(S(2)*I*a + S(2)*I*b*x) + c - I*d), x), x) + Simp((e + f*x)**(m + S(1))*acoth(c + d/tan(a + b*x))/(f*(m + S(1))), x) rule6666 = ReplacementRule(pattern6666, replacement6666) pattern6667 = Pattern(Integral((x_*WC('f', S(1)) + WC('e', S(0)))**WC('m', S(1))*atanh(WC('c', S(0)) + WC('d', S(1))*tan(x_*WC('b', S(1)) + WC('a', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons62, cons1947) def replacement6667(m, f, b, d, c, a, x, e): rubi.append(6667) return Dist(I*b*(-c + I*d + S(1))/(f*(m + S(1))), Int((e + f*x)**(m + S(1))*exp(S(2)*I*a + S(2)*I*b*x)/(-c - I*d + (-c + I*d + S(1))*exp(S(2)*I*a + S(2)*I*b*x) + S(1)), x), x) - Dist(I*b*(c - I*d + S(1))/(f*(m + S(1))), Int((e + f*x)**(m + S(1))*exp(S(2)*I*a + S(2)*I*b*x)/(c + I*d + (c - I*d + S(1))*exp(S(2)*I*a + S(2)*I*b*x) + S(1)), x), x) + Simp((e + f*x)**(m + S(1))*atanh(c + d*tan(a + b*x))/(f*(m + S(1))), x) rule6667 = ReplacementRule(pattern6667, replacement6667) pattern6668 = Pattern(Integral((x_*WC('f', S(1)) + WC('e', S(0)))**WC('m', S(1))*acoth(WC('c', S(0)) + WC('d', S(1))*tan(x_*WC('b', S(1)) + WC('a', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons62, cons1947) def replacement6668(m, f, b, d, c, a, x, e): rubi.append(6668) return Dist(I*b*(-c + I*d + S(1))/(f*(m + S(1))), Int((e + f*x)**(m + S(1))*exp(S(2)*I*a + S(2)*I*b*x)/(-c - I*d + (-c + I*d + S(1))*exp(S(2)*I*a + S(2)*I*b*x) + S(1)), x), x) - Dist(I*b*(c - I*d + S(1))/(f*(m + S(1))), Int((e + f*x)**(m + S(1))*exp(S(2)*I*a + S(2)*I*b*x)/(c + I*d + (c - I*d + S(1))*exp(S(2)*I*a + S(2)*I*b*x) + S(1)), x), x) + Simp((e + f*x)**(m + S(1))*acoth(c + d*tan(a + b*x))/(f*(m + S(1))), x) rule6668 = ReplacementRule(pattern6668, replacement6668) pattern6669 = Pattern(Integral((x_*WC('f', S(1)) + WC('e', S(0)))**WC('m', S(1))*atanh(WC('c', S(0)) + WC('d', S(1))/tan(x_*WC('b', S(1)) + WC('a', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons62, cons1948) def replacement6669(m, f, b, d, c, a, x, e): rubi.append(6669) return -Dist(I*b*(-c - I*d + S(1))/(f*(m + S(1))), Int((e + f*x)**(m + S(1))*exp(S(2)*I*a + S(2)*I*b*x)/(-c + I*d - (-c - I*d + S(1))*exp(S(2)*I*a + S(2)*I*b*x) + S(1)), x), x) + Dist(I*b*(c + I*d + S(1))/(f*(m + S(1))), Int((e + f*x)**(m + S(1))*exp(S(2)*I*a + S(2)*I*b*x)/(c - I*d - (c + I*d + S(1))*exp(S(2)*I*a + S(2)*I*b*x) + S(1)), x), x) + Simp((e + f*x)**(m + S(1))*atanh(c + d/tan(a + b*x))/(f*(m + S(1))), x) rule6669 = ReplacementRule(pattern6669, replacement6669) pattern6670 = Pattern(Integral((x_*WC('f', S(1)) + WC('e', S(0)))**WC('m', S(1))*acoth(WC('c', S(0)) + WC('d', S(1))/tan(x_*WC('b', S(1)) + WC('a', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons62, cons1948) def replacement6670(m, f, b, d, c, a, x, e): rubi.append(6670) return -Dist(I*b*(-c - I*d + S(1))/(f*(m + S(1))), Int((e + f*x)**(m + S(1))*exp(S(2)*I*a + S(2)*I*b*x)/(-c + I*d - (-c - I*d + S(1))*exp(S(2)*I*a + S(2)*I*b*x) + S(1)), x), x) + Dist(I*b*(c + I*d + S(1))/(f*(m + S(1))), Int((e + f*x)**(m + S(1))*exp(S(2)*I*a + S(2)*I*b*x)/(c - I*d - (c + I*d + S(1))*exp(S(2)*I*a + S(2)*I*b*x) + S(1)), x), x) + Simp((e + f*x)**(m + S(1))*acoth(c + d/tan(a + b*x))/(f*(m + S(1))), x) rule6670 = ReplacementRule(pattern6670, replacement6670) pattern6671 = Pattern(Integral(atanh(u_), x_), cons1230) def replacement6671(x, u): rubi.append(6671) return -Int(SimplifyIntegrand(x*D(u, x)/(-u**S(2) + S(1)), x), x) + Simp(x*atanh(u), x) rule6671 = ReplacementRule(pattern6671, replacement6671) pattern6672 = Pattern(Integral(acoth(u_), x_), cons1230) def replacement6672(x, u): rubi.append(6672) return -Int(SimplifyIntegrand(x*D(u, x)/(-u**S(2) + S(1)), x), x) + Simp(x*acoth(u), x) rule6672 = ReplacementRule(pattern6672, replacement6672) pattern6673 = Pattern(Integral((x_*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*atanh(u_)), x_), cons2, cons3, cons7, cons27, cons21, cons66, cons1230, cons1770, cons1847) def replacement6673(u, m, b, d, c, a, x): rubi.append(6673) return -Dist(b/(d*(m + S(1))), Int(SimplifyIntegrand((c + d*x)**(m + S(1))*D(u, x)/(-u**S(2) + S(1)), x), x), x) + Simp((a + b*atanh(u))*(c + d*x)**(m + S(1))/(d*(m + S(1))), x) rule6673 = ReplacementRule(pattern6673, replacement6673) pattern6674 = Pattern(Integral((x_*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*acoth(u_)), x_), cons2, cons3, cons7, cons27, cons21, cons66, cons1230, cons1770, cons1847) def replacement6674(u, m, b, d, c, a, x): rubi.append(6674) return -Dist(b/(d*(m + S(1))), Int(SimplifyIntegrand((c + d*x)**(m + S(1))*D(u, x)/(-u**S(2) + S(1)), x), x), x) + Simp((a + b*acoth(u))*(c + d*x)**(m + S(1))/(d*(m + S(1))), x) rule6674 = ReplacementRule(pattern6674, replacement6674) def With6675(v, u, b, a, x): if isinstance(x, (int, Integer, float, Float)): return False w = IntHide(v, x) if InverseFunctionFreeQ(w, x): return True return False pattern6675 = Pattern(Integral(v_*(WC('a', S(0)) + WC('b', S(1))*atanh(u_)), x_), cons2, cons3, cons1230, cons1949, cons1950, CustomConstraint(With6675)) def replacement6675(v, u, b, a, x): w = IntHide(v, x) rubi.append(6675) return -Dist(b, Int(SimplifyIntegrand(w*D(u, x)/(-u**S(2) + S(1)), x), x), x) + Dist(a + b*atanh(u), w, x) rule6675 = ReplacementRule(pattern6675, replacement6675) def With6676(v, u, b, a, x): if isinstance(x, (int, Integer, float, Float)): return False w = IntHide(v, x) if InverseFunctionFreeQ(w, x): return True return False pattern6676 = Pattern(Integral(v_*(WC('a', S(0)) + WC('b', S(1))*acoth(u_)), x_), cons2, cons3, cons1230, cons1951, cons1952, CustomConstraint(With6676)) def replacement6676(v, u, b, a, x): w = IntHide(v, x) rubi.append(6676) return -Dist(b, Int(SimplifyIntegrand(w*D(u, x)/(-u**S(2) + S(1)), x), x), x) + Dist(a + b*acoth(u), w, x) rule6676 = ReplacementRule(pattern6676, replacement6676) pattern6677 = Pattern(Integral(asech(x_*WC('c', S(1))), x_), cons7, cons7) def replacement6677(x, c): rubi.append(6677) return Dist(sqrt(c*x + S(1))*sqrt(S(1)/(c*x + S(1))), Int(S(1)/(sqrt(-c*x + S(1))*sqrt(c*x + S(1))), x), x) + Simp(x*asech(c*x), x) rule6677 = ReplacementRule(pattern6677, replacement6677) pattern6678 = Pattern(Integral(acsch(x_*WC('c', S(1))), x_), cons7, cons7) def replacement6678(x, c): rubi.append(6678) return Dist(S(1)/c, Int(S(1)/(x*sqrt(S(1) + S(1)/(c**S(2)*x**S(2)))), x), x) + Simp(x*acsch(c*x), x) rule6678 = ReplacementRule(pattern6678, replacement6678) pattern6679 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*asech(x_*WC('c', S(1))))**n_, x_), cons2, cons3, cons7, cons4, cons1579) def replacement6679(b, a, n, c, x): rubi.append(6679) return -Dist(S(1)/c, Subst(Int((a + b*x)**n*tanh(x)/cosh(x), x), x, asech(c*x)), x) rule6679 = ReplacementRule(pattern6679, replacement6679) pattern6680 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*acsch(x_*WC('c', S(1))))**n_, x_), cons2, cons3, cons7, cons4, cons1579) def replacement6680(b, a, n, c, x): rubi.append(6680) return -Dist(S(1)/c, Subst(Int((a + b*x)**n/(sinh(x)*tanh(x)), x), x, acsch(c*x)), x) rule6680 = ReplacementRule(pattern6680, replacement6680) pattern6681 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*asech(x_*WC('c', S(1))))/x_, x_), cons2, cons3, cons7, cons14) def replacement6681(x, a, c, b): rubi.append(6681) return -Subst(Int((a + b*acosh(x/c))/x, x), x, S(1)/x) rule6681 = ReplacementRule(pattern6681, replacement6681) pattern6682 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*acsch(x_*WC('c', S(1))))/x_, x_), cons2, cons3, cons7, cons14) def replacement6682(x, a, c, b): rubi.append(6682) return -Subst(Int((a + b*asinh(x/c))/x, x), x, S(1)/x) rule6682 = ReplacementRule(pattern6682, replacement6682) pattern6683 = Pattern(Integral(x_**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*asech(x_*WC('c', S(1)))), x_), cons2, cons3, cons7, cons21, cons66) def replacement6683(m, b, a, c, x): rubi.append(6683) return Dist(b*sqrt(c*x + S(1))*sqrt(S(1)/(c*x + S(1)))/(m + S(1)), Int(x**m/(sqrt(-c*x + S(1))*sqrt(c*x + S(1))), x), x) + Simp(x**(m + S(1))*(a + b*asech(c*x))/(m + S(1)), x) rule6683 = ReplacementRule(pattern6683, replacement6683) pattern6684 = Pattern(Integral(x_**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*acsch(x_*WC('c', S(1)))), x_), cons2, cons3, cons7, cons21, cons66) def replacement6684(m, b, a, c, x): rubi.append(6684) return Dist(b/(c*(m + S(1))), Int(x**(m + S(-1))/sqrt(S(1) + S(1)/(c**S(2)*x**S(2))), x), x) + Simp(x**(m + S(1))*(a + b*acsch(c*x))/(m + S(1)), x) rule6684 = ReplacementRule(pattern6684, replacement6684) pattern6685 = Pattern(Integral(x_**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*asech(x_*WC('c', S(1))))**n_, x_), cons2, cons3, cons7, cons4, cons17) def replacement6685(m, b, a, c, n, x): rubi.append(6685) return -Dist(c**(-m + S(-1)), Subst(Int((a + b*x)**n*(S(1)/cosh(x))**(m + S(1))*tanh(x), x), x, asech(c*x)), x) rule6685 = ReplacementRule(pattern6685, replacement6685) pattern6686 = Pattern(Integral(x_**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*acsch(x_*WC('c', S(1))))**n_, x_), cons2, cons3, cons7, cons4, cons17) def replacement6686(m, b, a, c, n, x): rubi.append(6686) return -Dist(c**(-m + S(-1)), Subst(Int((a + b*x)**n*(S(1)/sinh(x))**(m + S(1))/tanh(x), x), x, acsch(c*x)), x) rule6686 = ReplacementRule(pattern6686, replacement6686) pattern6687 = Pattern(Integral(x_**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*asech(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons21, cons4, cons1854) def replacement6687(m, b, a, n, c, x): rubi.append(6687) return Int(x**m*(a + b*asech(c*x))**n, x) rule6687 = ReplacementRule(pattern6687, replacement6687) pattern6688 = Pattern(Integral(x_**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*acsch(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons21, cons4, cons1854) def replacement6688(m, b, a, n, c, x): rubi.append(6688) return Int(x**m*(a + b*acsch(c*x))**n, x) rule6688 = ReplacementRule(pattern6688, replacement6688) def With6689(p, b, d, a, c, x, e): u = IntHide((d + e*x**S(2))**p, x) rubi.append(6689) return Dist(b*sqrt(c*x + S(1))*sqrt(S(1)/(c*x + S(1))), Int(SimplifyIntegrand(u/(x*sqrt(-c*x + S(1))*sqrt(c*x + S(1))), x), x), x) + Dist(a + b*asech(c*x), u, x) pattern6689 = Pattern(Integral((x_**S(2)*WC('e', S(1)) + WC('d', S(0)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*asech(x_*WC('c', S(1)))), x_), cons2, cons3, cons7, cons27, cons48, cons1743) rule6689 = ReplacementRule(pattern6689, With6689) def With6690(p, b, d, a, c, x, e): u = IntHide((d + e*x**S(2))**p, x) rubi.append(6690) return -Dist(b*c*x/sqrt(-c**S(2)*x**S(2)), Int(SimplifyIntegrand(u/(x*sqrt(-c**S(2)*x**S(2) + S(-1))), x), x), x) + Dist(a + b*acsch(c*x), u, x) pattern6690 = Pattern(Integral((x_**S(2)*WC('e', S(1)) + WC('d', S(0)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*acsch(x_*WC('c', S(1)))), x_), cons2, cons3, cons7, cons27, cons48, cons1743) rule6690 = ReplacementRule(pattern6690, With6690) pattern6691 = Pattern(Integral((x_**S(2)*WC('e', S(1)) + WC('d', S(0)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*asech(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons4, cons38) def replacement6691(p, b, d, a, n, c, x, e): rubi.append(6691) return -Subst(Int(x**(-S(2)*p + S(-2))*(a + b*acosh(x/c))**n*(d*x**S(2) + e)**p, x), x, S(1)/x) rule6691 = ReplacementRule(pattern6691, replacement6691) pattern6692 = Pattern(Integral((x_**S(2)*WC('e', S(1)) + WC('d', S(0)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*acsch(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons4, cons38) def replacement6692(p, b, d, a, n, c, x, e): rubi.append(6692) return -Subst(Int(x**(-S(2)*p + S(-2))*(a + b*asinh(x/c))**n*(d*x**S(2) + e)**p, x), x, S(1)/x) rule6692 = ReplacementRule(pattern6692, replacement6692) pattern6693 = Pattern(Integral((x_**S(2)*WC('e', S(1)) + WC('d', S(0)))**p_*(WC('a', S(0)) + WC('b', S(1))*asech(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons4, cons1737, cons667, cons178, cons1855) def replacement6693(p, b, d, a, n, c, x, e): rubi.append(6693) return -Dist(sqrt(x**S(2))/x, Subst(Int(x**(-S(2)*p + S(-2))*(a + b*acosh(x/c))**n*(d*x**S(2) + e)**p, x), x, S(1)/x), x) rule6693 = ReplacementRule(pattern6693, replacement6693) pattern6694 = Pattern(Integral((x_**S(2)*WC('e', S(1)) + WC('d', S(0)))**p_*(WC('a', S(0)) + WC('b', S(1))*acsch(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons4, cons1778, cons667, cons178, cons1855) def replacement6694(p, b, d, a, n, c, x, e): rubi.append(6694) return -Dist(sqrt(x**S(2))/x, Subst(Int(x**(-S(2)*p + S(-2))*(a + b*asinh(x/c))**n*(d*x**S(2) + e)**p, x), x, S(1)/x), x) rule6694 = ReplacementRule(pattern6694, replacement6694) pattern6695 = Pattern(Integral((x_**S(2)*WC('e', S(1)) + WC('d', S(0)))**p_*(WC('a', S(0)) + WC('b', S(1))*asech(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons4, cons1737, cons667, cons1856) def replacement6695(p, b, d, a, n, c, x, e): rubi.append(6695) return -Dist(sqrt(d + e*x**S(2))/(x*sqrt(d/x**S(2) + e)), Subst(Int(x**(-S(2)*p + S(-2))*(a + b*acosh(x/c))**n*(d*x**S(2) + e)**p, x), x, S(1)/x), x) rule6695 = ReplacementRule(pattern6695, replacement6695) pattern6696 = Pattern(Integral((x_**S(2)*WC('e', S(1)) + WC('d', S(0)))**p_*(WC('a', S(0)) + WC('b', S(1))*acsch(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons4, cons1778, cons667, cons1856) def replacement6696(p, b, d, a, n, c, x, e): rubi.append(6696) return -Dist(sqrt(d + e*x**S(2))/(x*sqrt(d/x**S(2) + e)), Subst(Int(x**(-S(2)*p + S(-2))*(a + b*asinh(x/c))**n*(d*x**S(2) + e)**p, x), x, S(1)/x), x) rule6696 = ReplacementRule(pattern6696, replacement6696) pattern6697 = Pattern(Integral((x_**S(2)*WC('e', S(1)) + WC('d', S(0)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*asech(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons4, cons5, cons1570) def replacement6697(p, b, d, a, n, c, x, e): rubi.append(6697) return Int((a + b*asech(c*x))**n*(d + e*x**S(2))**p, x) rule6697 = ReplacementRule(pattern6697, replacement6697) pattern6698 = Pattern(Integral((x_**S(2)*WC('e', S(1)) + WC('d', S(0)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*acsch(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons4, cons5, cons1570) def replacement6698(p, b, d, a, n, c, x, e): rubi.append(6698) return Int((a + b*acsch(c*x))**n*(d + e*x**S(2))**p, x) rule6698 = ReplacementRule(pattern6698, replacement6698) pattern6699 = Pattern(Integral(x_*(x_**S(2)*WC('e', S(1)) + WC('d', S(0)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*asech(x_*WC('c', S(1)))), x_), cons2, cons3, cons7, cons27, cons48, cons5, cons54) def replacement6699(p, b, d, a, c, x, e): rubi.append(6699) return Dist(b*sqrt(c*x + S(1))*sqrt(S(1)/(c*x + S(1)))/(S(2)*e*(p + S(1))), Int((d + e*x**S(2))**(p + S(1))/(x*sqrt(-c*x + S(1))*sqrt(c*x + S(1))), x), x) + Simp((a + b*asech(c*x))*(d + e*x**S(2))**(p + S(1))/(S(2)*e*(p + S(1))), x) rule6699 = ReplacementRule(pattern6699, replacement6699) pattern6700 = Pattern(Integral(x_*(x_**S(2)*WC('e', S(1)) + WC('d', S(0)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*acsch(x_*WC('c', S(1)))), x_), cons2, cons3, cons7, cons27, cons48, cons5, cons54) def replacement6700(p, b, d, a, c, x, e): rubi.append(6700) return -Dist(b*c*x/(S(2)*e*sqrt(-c**S(2)*x**S(2))*(p + S(1))), Int((d + e*x**S(2))**(p + S(1))/(x*sqrt(-c**S(2)*x**S(2) + S(-1))), x), x) + Simp((a + b*acsch(c*x))*(d + e*x**S(2))**(p + S(1))/(S(2)*e*(p + S(1))), x) rule6700 = ReplacementRule(pattern6700, replacement6700) def With6701(p, m, b, d, a, c, x, e): u = IntHide(x**m*(d + e*x**S(2))**p, x) rubi.append(6701) return Dist(b*sqrt(c*x + S(1))*sqrt(S(1)/(c*x + S(1))), Int(SimplifyIntegrand(u/(x*sqrt(-c*x + S(1))*sqrt(c*x + S(1))), x), x), x) + Dist(a + b*asech(c*x), u, x) pattern6701 = Pattern(Integral(x_**WC('m', S(1))*(x_**S(2)*WC('e', S(1)) + WC('d', S(0)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*asech(x_*WC('c', S(1)))), x_), cons2, cons3, cons7, cons27, cons48, cons21, cons5, cons1786) rule6701 = ReplacementRule(pattern6701, With6701) def With6702(p, m, b, d, a, c, x, e): u = IntHide(x**m*(d + e*x**S(2))**p, x) rubi.append(6702) return -Dist(b*c*x/sqrt(-c**S(2)*x**S(2)), Int(SimplifyIntegrand(u/(x*sqrt(-c**S(2)*x**S(2) + S(-1))), x), x), x) + Dist(a + b*acsch(c*x), u, x) pattern6702 = Pattern(Integral(x_**WC('m', S(1))*(x_**S(2)*WC('e', S(1)) + WC('d', S(0)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*acsch(x_*WC('c', S(1)))), x_), cons2, cons3, cons7, cons27, cons48, cons21, cons5, cons1786) rule6702 = ReplacementRule(pattern6702, With6702) pattern6703 = Pattern(Integral(x_**WC('m', S(1))*(x_**S(2)*WC('e', S(1)) + WC('d', S(0)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*asech(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons4, cons1299) def replacement6703(p, m, b, d, a, n, c, x, e): rubi.append(6703) return -Subst(Int(x**(-m - S(2)*p + S(-2))*(a + b*acosh(x/c))**n*(d*x**S(2) + e)**p, x), x, S(1)/x) rule6703 = ReplacementRule(pattern6703, replacement6703) pattern6704 = Pattern(Integral(x_**WC('m', S(1))*(x_**S(2)*WC('e', S(1)) + WC('d', S(0)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*acsch(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons4, cons1299) def replacement6704(p, m, b, d, a, n, c, x, e): rubi.append(6704) return -Subst(Int(x**(-m - S(2)*p + S(-2))*(a + b*asinh(x/c))**n*(d*x**S(2) + e)**p, x), x, S(1)/x) rule6704 = ReplacementRule(pattern6704, replacement6704) pattern6705 = Pattern(Integral(x_**WC('m', S(1))*(x_**S(2)*WC('e', S(1)) + WC('d', S(0)))**p_*(WC('a', S(0)) + WC('b', S(1))*asech(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons4, cons1737, cons17, cons667, cons178, cons1855) def replacement6705(p, m, b, d, a, n, c, x, e): rubi.append(6705) return -Dist(sqrt(x**S(2))/x, Subst(Int(x**(-m - S(2)*p + S(-2))*(a + b*acosh(x/c))**n*(d*x**S(2) + e)**p, x), x, S(1)/x), x) rule6705 = ReplacementRule(pattern6705, replacement6705) pattern6706 = Pattern(Integral(x_**WC('m', S(1))*(x_**S(2)*WC('e', S(1)) + WC('d', S(0)))**p_*(WC('a', S(0)) + WC('b', S(1))*acsch(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons4, cons1778, cons17, cons667, cons178, cons1855) def replacement6706(p, m, b, d, a, n, c, x, e): rubi.append(6706) return -Dist(sqrt(x**S(2))/x, Subst(Int(x**(-m - S(2)*p + S(-2))*(a + b*asinh(x/c))**n*(d*x**S(2) + e)**p, x), x, S(1)/x), x) rule6706 = ReplacementRule(pattern6706, replacement6706) pattern6707 = Pattern(Integral(x_**WC('m', S(1))*(x_**S(2)*WC('e', S(1)) + WC('d', S(0)))**p_*(WC('a', S(0)) + WC('b', S(1))*asech(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons4, cons1737, cons17, cons667, cons1856) def replacement6707(p, m, b, d, a, n, c, x, e): rubi.append(6707) return -Dist(sqrt(d + e*x**S(2))/(x*sqrt(d/x**S(2) + e)), Subst(Int(x**(-m - S(2)*p + S(-2))*(a + b*acosh(x/c))**n*(d*x**S(2) + e)**p, x), x, S(1)/x), x) rule6707 = ReplacementRule(pattern6707, replacement6707) pattern6708 = Pattern(Integral(x_**WC('m', S(1))*(x_**S(2)*WC('e', S(1)) + WC('d', S(0)))**p_*(WC('a', S(0)) + WC('b', S(1))*acsch(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons4, cons1778, cons17, cons667, cons1856) def replacement6708(p, m, b, d, a, n, c, x, e): rubi.append(6708) return -Dist(sqrt(d + e*x**S(2))/(x*sqrt(d/x**S(2) + e)), Subst(Int(x**(-m - S(2)*p + S(-2))*(a + b*asinh(x/c))**n*(d*x**S(2) + e)**p, x), x, S(1)/x), x) rule6708 = ReplacementRule(pattern6708, replacement6708) pattern6709 = Pattern(Integral(x_**WC('m', S(1))*(x_**S(2)*WC('e', S(1)) + WC('d', S(0)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*asech(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons21, cons4, cons5, cons1497) def replacement6709(p, m, b, d, a, n, c, x, e): rubi.append(6709) return Int(x**m*(a + b*asech(c*x))**n*(d + e*x**S(2))**p, x) rule6709 = ReplacementRule(pattern6709, replacement6709) pattern6710 = Pattern(Integral(x_**WC('m', S(1))*(x_**S(2)*WC('e', S(1)) + WC('d', S(0)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*acsch(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons21, cons4, cons5, cons1497) def replacement6710(p, m, b, d, a, n, c, x, e): rubi.append(6710) return Int(x**m*(a + b*acsch(c*x))**n*(d + e*x**S(2))**p, x) rule6710 = ReplacementRule(pattern6710, replacement6710) pattern6711 = Pattern(Integral(asech(a_ + x_*WC('b', S(1))), x_), cons2, cons3, cons67) def replacement6711(x, a, b): rubi.append(6711) return Int(sqrt((-a - b*x + S(1))/(a + b*x + S(1)))/(-a - b*x + S(1)), x) + Simp((a + b*x)*asech(a + b*x)/b, x) rule6711 = ReplacementRule(pattern6711, replacement6711) pattern6712 = Pattern(Integral(acsch(a_ + x_*WC('b', S(1))), x_), cons2, cons3, cons67) def replacement6712(x, a, b): rubi.append(6712) return Int(S(1)/(sqrt(S(1) + (a + b*x)**(S(-2)))*(a + b*x)), x) + Simp((a + b*x)*acsch(a + b*x)/b, x) rule6712 = ReplacementRule(pattern6712, replacement6712) pattern6713 = Pattern(Integral(asech(a_ + x_*WC('b', S(1)))**n_, x_), cons2, cons3, cons4, cons1831) def replacement6713(x, a, n, b): rubi.append(6713) return -Dist(S(1)/b, Subst(Int(x**n*tanh(x)/cosh(x), x), x, asech(a + b*x)), x) rule6713 = ReplacementRule(pattern6713, replacement6713) pattern6714 = Pattern(Integral(acsch(a_ + x_*WC('b', S(1)))**n_, x_), cons2, cons3, cons4, cons1831) def replacement6714(x, a, n, b): rubi.append(6714) return -Dist(S(1)/b, Subst(Int(x**n/(sinh(x)*tanh(x)), x), x, acsch(a + b*x)), x) rule6714 = ReplacementRule(pattern6714, replacement6714) pattern6715 = Pattern(Integral(asech(a_ + x_*WC('b', S(1)))/x_, x_), cons2, cons3, cons67) def replacement6715(x, a, b): rubi.append(6715) return Simp(log(S(1) - (-sqrt(-a**S(2) + S(1)) + S(1))*exp(-asech(a + b*x))/a)*asech(a + b*x), x) + Simp(log(S(1) - (sqrt(-a**S(2) + S(1)) + S(1))*exp(-asech(a + b*x))/a)*asech(a + b*x), x) - Simp(log(S(1) + exp(-S(2)*asech(a + b*x)))*asech(a + b*x), x) - Simp(PolyLog(S(2), (-sqrt(-a**S(2) + S(1)) + S(1))*exp(-asech(a + b*x))/a), x) - Simp(PolyLog(S(2), (sqrt(-a**S(2) + S(1)) + S(1))*exp(-asech(a + b*x))/a), x) + Simp(PolyLog(S(2), -exp(-S(2)*asech(a + b*x)))/S(2), x) rule6715 = ReplacementRule(pattern6715, replacement6715) pattern6716 = Pattern(Integral(acsch(a_ + x_*WC('b', S(1)))/x_, x_), cons2, cons3, cons67) def replacement6716(x, a, b): rubi.append(6716) return Simp(log(S(1) + (-sqrt(a**S(2) + S(1)) + S(1))*exp(acsch(a + b*x))/a)*acsch(a + b*x), x) + Simp(log(S(1) + (sqrt(a**S(2) + S(1)) + S(1))*exp(acsch(a + b*x))/a)*acsch(a + b*x), x) - Simp(log(S(1) - exp(-S(2)*acsch(a + b*x)))*acsch(a + b*x), x) + Simp(PolyLog(S(2), -(-sqrt(a**S(2) + S(1)) + S(1))*exp(acsch(a + b*x))/a), x) + Simp(PolyLog(S(2), -(sqrt(a**S(2) + S(1)) + S(1))*exp(acsch(a + b*x))/a), x) + Simp(PolyLog(S(2), exp(-S(2)*acsch(a + b*x)))/S(2), x) - Simp(acsch(a + b*x)**S(2), x) rule6716 = ReplacementRule(pattern6716, replacement6716) pattern6717 = Pattern(Integral(x_**WC('m', S(1))*asech(a_ + x_*WC('b', S(1))), x_), cons2, cons3, cons21, cons17, cons66) def replacement6717(x, m, b, a): rubi.append(6717) return Dist(b**(-m + S(-1))/(m + S(1)), Subst(Int(x**(-m + S(-1))*((-a*x)**(m + S(1)) - (-a*x + S(1))**(m + S(1)))/(sqrt(x + S(-1))*sqrt(x + S(1))), x), x, S(1)/(a + b*x)), x) - Simp(b**(-m + S(-1))*(-b**(m + S(1))*x**(m + S(1)) + (-a)**(m + S(1)))*asech(a + b*x)/(m + S(1)), x) rule6717 = ReplacementRule(pattern6717, replacement6717) pattern6718 = Pattern(Integral(x_**WC('m', S(1))*acsch(a_ + x_*WC('b', S(1))), x_), cons2, cons3, cons21, cons17, cons66) def replacement6718(x, m, b, a): rubi.append(6718) return Dist(b**(-m + S(-1))/(m + S(1)), Subst(Int(x**(-m + S(-1))*((-a*x)**(m + S(1)) - (-a*x + S(1))**(m + S(1)))/sqrt(x**S(2) + S(1)), x), x, S(1)/(a + b*x)), x) - Simp(b**(-m + S(-1))*(-b**(m + S(1))*x**(m + S(1)) + (-a)**(m + S(1)))*acsch(a + b*x)/(m + S(1)), x) rule6718 = ReplacementRule(pattern6718, replacement6718) pattern6719 = Pattern(Integral(x_**WC('m', S(1))*asech(a_ + x_*WC('b', S(1)))**n_, x_), cons2, cons3, cons4, cons62) def replacement6719(m, b, a, n, x): rubi.append(6719) return -Dist(b**(-m + S(-1)), Subst(Int(x**n*(-a + S(1)/cosh(x))**m*tanh(x)/cosh(x), x), x, asech(a + b*x)), x) rule6719 = ReplacementRule(pattern6719, replacement6719) pattern6720 = Pattern(Integral(x_**WC('m', S(1))*acsch(a_ + x_*WC('b', S(1)))**n_, x_), cons2, cons3, cons4, cons62) def replacement6720(m, b, a, n, x): rubi.append(6720) return -Dist(b**(-m + S(-1)), Subst(Int(x**n*(-a + S(1)/sinh(x))**m/(sinh(x)*tanh(x)), x), x, acsch(a + b*x)), x) rule6720 = ReplacementRule(pattern6720, replacement6720) pattern6721 = Pattern(Integral(WC('u', S(1))*asech(WC('c', S(1))/(x_**WC('n', S(1))*WC('b', S(1)) + WC('a', S(0))))**WC('m', S(1)), x_), cons2, cons3, cons7, cons4, cons21, cons1766) def replacement6721(u, m, b, c, n, a, x): rubi.append(6721) return Int(u*acosh(a/c + b*x**n/c)**m, x) rule6721 = ReplacementRule(pattern6721, replacement6721) pattern6722 = Pattern(Integral(WC('u', S(1))*acsch(WC('c', S(1))/(x_**WC('n', S(1))*WC('b', S(1)) + WC('a', S(0))))**WC('m', S(1)), x_), cons2, cons3, cons7, cons4, cons21, cons1766) def replacement6722(u, m, b, c, n, a, x): rubi.append(6722) return Int(u*asinh(a/c + b*x**n/c)**m, x) rule6722 = ReplacementRule(pattern6722, replacement6722) pattern6723 = Pattern(Integral(exp(asech(x_*WC('a', S(1)))), x_), cons2, cons2) def replacement6723(x, a): rubi.append(6723) return Dist(S(1)/a, Int(sqrt((-a*x + S(1))/(a*x + S(1)))/(x*(-a*x + S(1))), x), x) + Simp(log(x)/a, x) + Simp(x*exp(asech(a*x)), x) rule6723 = ReplacementRule(pattern6723, replacement6723) pattern6724 = Pattern(Integral(exp(asech(x_**p_*WC('a', S(1)))), x_), cons2, cons5, cons1953) def replacement6724(x, a, p): rubi.append(6724) return Dist(p/a, Int(x**(-p), x), x) + Dist(p*sqrt(a*x**p + S(1))*sqrt(S(1)/(a*x**p + S(1)))/a, Int(x**(-p)/(sqrt(-a*x**p + S(1))*sqrt(a*x**p + S(1))), x), x) + Simp(x*exp(asech(a*x**p)), x) rule6724 = ReplacementRule(pattern6724, replacement6724) pattern6725 = Pattern(Integral(exp(acsch(x_**WC('p', S(1))*WC('a', S(1)))), x_), cons2, cons5, cons1953) def replacement6725(x, a, p): rubi.append(6725) return Dist(S(1)/a, Int(x**(-p), x), x) + Int(sqrt(S(1) + x**(-S(2)*p)/a**S(2)), x) rule6725 = ReplacementRule(pattern6725, replacement6725) pattern6726 = Pattern(Integral(exp(WC('n', S(1))*asech(u_)), x_), cons85) def replacement6726(x, n, u): rubi.append(6726) return Int((sqrt((-u + S(1))/(u + S(1))) + sqrt((-u + S(1))/(u + S(1)))/u + S(1)/u)**n, x) rule6726 = ReplacementRule(pattern6726, replacement6726) pattern6727 = Pattern(Integral(exp(WC('n', S(1))*acsch(u_)), x_), cons85) def replacement6727(x, n, u): rubi.append(6727) return Int((sqrt(S(1) + u**(S(-2))) + S(1)/u)**n, x) rule6727 = ReplacementRule(pattern6727, replacement6727) pattern6728 = Pattern(Integral(exp(asech(x_**WC('p', S(1))*WC('a', S(1))))/x_, x_), cons2, cons5, cons1953) def replacement6728(x, a, p): rubi.append(6728) return Dist(sqrt(a*x**p + S(1))*sqrt(S(1)/(a*x**p + S(1)))/a, Int(x**(-p + S(-1))*sqrt(-a*x**p + S(1))*sqrt(a*x**p + S(1)), x), x) - Simp(x**(-p)/(a*p), x) rule6728 = ReplacementRule(pattern6728, replacement6728) pattern6729 = Pattern(Integral(x_**WC('m', S(1))*exp(asech(x_**WC('p', S(1))*WC('a', S(1)))), x_), cons2, cons21, cons5, cons66) def replacement6729(x, m, a, p): rubi.append(6729) return Dist(p/(a*(m + S(1))), Int(x**(m - p), x), x) + Dist(p*sqrt(a*x**p + S(1))*sqrt(S(1)/(a*x**p + S(1)))/(a*(m + S(1))), Int(x**(m - p)/(sqrt(-a*x**p + S(1))*sqrt(a*x**p + S(1))), x), x) + Simp(x**(m + S(1))*exp(asech(a*x**p))/(m + S(1)), x) rule6729 = ReplacementRule(pattern6729, replacement6729) pattern6730 = Pattern(Integral(x_**WC('m', S(1))*exp(acsch(x_**WC('p', S(1))*WC('a', S(1)))), x_), cons2, cons21, cons5, cons1954) def replacement6730(x, m, a, p): rubi.append(6730) return Dist(S(1)/a, Int(x**(m - p), x), x) + Int(x**m*sqrt(S(1) + x**(-S(2)*p)/a**S(2)), x) rule6730 = ReplacementRule(pattern6730, replacement6730) pattern6731 = Pattern(Integral(x_**WC('m', S(1))*exp(WC('n', S(1))*asech(u_)), x_), cons21, cons85) def replacement6731(x, m, n, u): rubi.append(6731) return Int(x**m*(sqrt((-u + S(1))/(u + S(1))) + sqrt((-u + S(1))/(u + S(1)))/u + S(1)/u)**n, x) rule6731 = ReplacementRule(pattern6731, replacement6731) pattern6732 = Pattern(Integral(x_**WC('m', S(1))*exp(WC('n', S(1))*acsch(u_)), x_), cons21, cons85) def replacement6732(x, m, n, u): rubi.append(6732) return Int(x**m*(sqrt(S(1) + u**(S(-2))) + S(1)/u)**n, x) rule6732 = ReplacementRule(pattern6732, replacement6732) pattern6733 = Pattern(Integral(asech(u_), x_), cons1230, cons1769) def replacement6733(x, u): rubi.append(6733) return Dist(sqrt(-u**S(2) + S(1))/(u*sqrt(S(-1) + S(1)/u)*sqrt(S(1) + S(1)/u)), Int(SimplifyIntegrand(x*D(u, x)/(u*sqrt(-u**S(2) + S(1))), x), x), x) + Simp(x*asech(u), x) rule6733 = ReplacementRule(pattern6733, replacement6733) pattern6734 = Pattern(Integral(acsch(u_), x_), cons1230, cons1769) def replacement6734(x, u): rubi.append(6734) return -Dist(u/sqrt(-u**S(2)), Int(SimplifyIntegrand(x*D(u, x)/(u*sqrt(-u**S(2) + S(-1))), x), x), x) + Simp(x*acsch(u), x) rule6734 = ReplacementRule(pattern6734, replacement6734) pattern6735 = Pattern(Integral((x_*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*asech(u_)), x_), cons2, cons3, cons7, cons27, cons21, cons66, cons1230, cons1770, cons1769) def replacement6735(u, m, b, d, c, a, x): rubi.append(6735) return Dist(b*sqrt(-u**S(2) + S(1))/(d*u*sqrt(S(-1) + S(1)/u)*sqrt(S(1) + S(1)/u)*(m + S(1))), Int(SimplifyIntegrand((c + d*x)**(m + S(1))*D(u, x)/(u*sqrt(-u**S(2) + S(1))), x), x), x) + Simp((a + b*asech(u))*(c + d*x)**(m + S(1))/(d*(m + S(1))), x) rule6735 = ReplacementRule(pattern6735, replacement6735) pattern6736 = Pattern(Integral((x_*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*acsch(u_)), x_), cons2, cons3, cons7, cons27, cons21, cons66, cons1230, cons1770, cons1769) def replacement6736(u, m, b, d, c, a, x): rubi.append(6736) return -Dist(b*u/(d*sqrt(-u**S(2))*(m + S(1))), Int(SimplifyIntegrand((c + d*x)**(m + S(1))*D(u, x)/(u*sqrt(-u**S(2) + S(-1))), x), x), x) + Simp((a + b*acsch(u))*(c + d*x)**(m + S(1))/(d*(m + S(1))), x) rule6736 = ReplacementRule(pattern6736, replacement6736) def With6737(v, u, b, a, x): if isinstance(x, (int, Integer, float, Float)): return False w = IntHide(v, x) if InverseFunctionFreeQ(w, x): return True return False pattern6737 = Pattern(Integral(v_*(WC('a', S(0)) + WC('b', S(1))*asech(u_)), x_), cons2, cons3, cons1230, cons1955, CustomConstraint(With6737)) def replacement6737(v, u, b, a, x): w = IntHide(v, x) rubi.append(6737) return Dist(b*sqrt(-u**S(2) + S(1))/(u*sqrt(S(-1) + S(1)/u)*sqrt(S(1) + S(1)/u)), Int(SimplifyIntegrand(w*D(u, x)/(u*sqrt(-u**S(2) + S(1))), x), x), x) + Dist(a + b*asech(u), w, x) rule6737 = ReplacementRule(pattern6737, replacement6737) def With6738(v, u, b, a, x): if isinstance(x, (int, Integer, float, Float)): return False w = IntHide(v, x) if InverseFunctionFreeQ(w, x): return True return False pattern6738 = Pattern(Integral(v_*(WC('a', S(0)) + WC('b', S(1))*acsch(u_)), x_), cons2, cons3, cons1230, cons1956, CustomConstraint(With6738)) def replacement6738(v, u, b, a, x): w = IntHide(v, x) rubi.append(6738) return -Dist(b*u/sqrt(-u**S(2)), Int(SimplifyIntegrand(w*D(u, x)/(u*sqrt(-u**S(2) + S(-1))), x), x), x) + Dist(a + b*acsch(u), w, x) rule6738 = ReplacementRule(pattern6738, replacement6738) return [rule6084, rule6085, rule6086, rule6087, rule6088, rule6089, rule6090, rule6091, rule6092, rule6093, rule6094, rule6095, rule6096, rule6097, rule6098, rule6099, rule6100, rule6101, rule6102, rule6103, rule6104, rule6105, rule6106, rule6107, rule6108, rule6109, rule6110, rule6111, rule6112, rule6113, rule6114, rule6115, rule6116, rule6117, rule6118, rule6119, rule6120, rule6121, rule6122, rule6123, rule6124, rule6125, rule6126, rule6127, rule6128, rule6129, rule6130, rule6131, rule6132, rule6133, rule6134, rule6135, rule6136, rule6137, rule6138, rule6139, rule6140, rule6141, rule6142, rule6143, rule6144, rule6145, rule6146, rule6147, rule6148, rule6149, rule6150, rule6151, rule6152, rule6153, rule6154, rule6155, rule6156, rule6157, rule6158, rule6159, rule6160, rule6161, rule6162, rule6163, rule6164, rule6165, rule6166, rule6167, rule6168, rule6169, rule6170, rule6171, rule6172, rule6173, rule6174, rule6175, rule6176, rule6177, rule6178, rule6179, rule6180, rule6181, rule6182, rule6183, rule6184, rule6185, rule6186, rule6187, rule6188, rule6189, rule6190, rule6191, rule6192, rule6193, rule6194, rule6195, rule6196, rule6197, rule6198, rule6199, rule6200, rule6201, rule6202, rule6203, rule6204, rule6205, rule6206, rule6207, rule6208, rule6209, rule6210, rule6211, rule6212, rule6213, rule6214, rule6215, rule6216, rule6217, rule6218, rule6219, rule6220, rule6221, rule6222, rule6223, rule6224, rule6225, rule6226, rule6227, rule6228, rule6229, rule6230, rule6231, rule6232, rule6233, rule6234, rule6235, rule6236, rule6237, rule6238, rule6239, rule6240, rule6241, rule6242, rule6243, rule6244, rule6245, rule6246, rule6247, rule6248, rule6249, rule6250, rule6251, rule6252, rule6253, rule6254, rule6255, rule6256, rule6257, rule6258, rule6259, rule6260, rule6261, rule6262, rule6263, rule6264, rule6265, rule6266, rule6267, rule6268, rule6269, rule6270, rule6271, rule6272, rule6273, rule6274, rule6275, rule6276, rule6277, rule6278, rule6279, rule6280, rule6281, rule6282, rule6283, rule6284, rule6285, rule6286, rule6287, rule6288, rule6289, rule6290, rule6291, rule6292, rule6293, rule6294, rule6295, rule6296, rule6297, rule6298, rule6299, rule6300, rule6301, rule6302, rule6303, rule6304, rule6305, rule6306, rule6307, rule6308, rule6309, rule6310, rule6311, rule6312, rule6313, rule6314, rule6315, rule6316, rule6317, rule6318, rule6319, rule6320, rule6321, rule6322, rule6323, rule6324, rule6325, rule6326, rule6327, rule6328, rule6329, rule6330, rule6331, rule6332, rule6333, rule6334, rule6335, rule6336, rule6337, rule6338, rule6339, rule6340, rule6341, rule6342, rule6343, rule6344, rule6345, rule6346, rule6347, rule6348, rule6349, rule6350, rule6351, rule6352, rule6353, rule6354, rule6355, rule6356, rule6357, rule6358, rule6359, rule6360, rule6361, rule6362, rule6363, rule6364, rule6365, rule6366, rule6367, rule6368, rule6369, rule6370, rule6371, rule6372, rule6373, rule6374, rule6375, rule6376, rule6377, rule6378, rule6379, rule6380, rule6381, rule6382, rule6383, rule6384, rule6385, rule6386, rule6387, rule6388, rule6389, rule6390, rule6391, rule6392, rule6393, rule6394, rule6395, rule6396, rule6397, rule6398, rule6399, rule6400, rule6401, rule6402, rule6403, rule6404, rule6405, rule6406, rule6407, rule6408, rule6409, rule6410, rule6411, rule6412, rule6413, rule6414, rule6415, rule6416, rule6417, rule6418, rule6419, rule6420, rule6421, rule6422, rule6423, rule6424, rule6425, rule6426, rule6427, rule6428, rule6429, rule6430, rule6431, rule6432, rule6433, rule6434, rule6435, rule6436, rule6437, rule6438, rule6439, rule6440, rule6441, rule6442, rule6443, rule6444, rule6445, rule6446, rule6447, rule6448, rule6449, rule6450, rule6451, rule6452, rule6453, rule6454, rule6455, rule6456, rule6457, rule6458, rule6459, rule6460, rule6461, rule6462, rule6463, rule6464, rule6465, rule6466, rule6467, rule6468, rule6469, rule6470, rule6471, rule6472, rule6473, rule6474, rule6475, rule6476, rule6477, rule6478, rule6479, rule6480, rule6481, rule6482, rule6483, rule6484, rule6485, rule6486, rule6487, rule6488, rule6489, rule6490, rule6491, rule6492, rule6493, rule6494, rule6495, rule6496, rule6497, rule6498, rule6499, rule6500, rule6501, rule6502, rule6503, rule6504, rule6505, rule6506, rule6507, rule6508, rule6509, rule6510, rule6511, rule6512, rule6513, rule6514, rule6515, rule6516, rule6517, rule6518, rule6519, rule6520, rule6521, rule6522, rule6523, rule6524, rule6525, rule6526, rule6527, rule6528, rule6529, rule6530, rule6531, rule6532, rule6533, rule6534, rule6535, rule6536, rule6537, rule6538, rule6539, rule6540, rule6541, rule6542, rule6543, rule6544, rule6545, rule6546, rule6547, rule6548, rule6549, rule6550, rule6551, rule6552, rule6553, rule6554, rule6555, rule6556, rule6557, rule6558, rule6559, rule6560, rule6561, rule6562, rule6563, rule6564, rule6565, rule6566, rule6567, rule6568, rule6569, rule6570, rule6571, rule6572, rule6573, rule6574, rule6575, rule6576, rule6577, rule6578, rule6579, rule6580, rule6581, rule6582, rule6583, rule6584, rule6585, rule6586, rule6587, rule6588, rule6589, rule6590, rule6591, rule6592, rule6593, rule6594, rule6595, rule6596, rule6597, rule6598, rule6599, rule6600, rule6601, rule6602, rule6603, rule6604, rule6605, rule6606, rule6607, rule6608, rule6609, rule6610, rule6611, rule6612, rule6613, rule6614, rule6615, rule6616, rule6617, rule6618, rule6619, rule6620, rule6621, rule6622, rule6623, rule6624, rule6625, rule6626, rule6627, rule6628, rule6629, rule6630, rule6631, rule6632, rule6633, rule6634, rule6635, rule6636, rule6637, rule6638, rule6639, rule6640, rule6641, rule6642, rule6643, rule6644, rule6645, rule6646, rule6647, rule6648, rule6649, rule6650, rule6651, rule6652, rule6653, rule6654, rule6655, rule6656, rule6657, rule6658, rule6659, rule6660, rule6661, rule6662, rule6663, rule6664, rule6665, rule6666, rule6667, rule6668, rule6669, rule6670, rule6671, rule6672, rule6673, rule6674, rule6675, rule6676, rule6677, rule6678, rule6679, rule6680, rule6681, rule6682, rule6683, rule6684, rule6685, rule6686, rule6687, rule6688, rule6689, rule6690, rule6691, rule6692, rule6693, rule6694, rule6695, rule6696, rule6697, rule6698, rule6699, rule6700, rule6701, rule6702, rule6703, rule6704, rule6705, rule6706, rule6707, rule6708, rule6709, rule6710, rule6711, rule6712, rule6713, rule6714, rule6715, rule6716, rule6717, rule6718, rule6719, rule6720, rule6721, rule6722, rule6723, rule6724, rule6725, rule6726, rule6727, rule6728, rule6729, rule6730, rule6731, rule6732, rule6733, rule6734, rule6735, rule6736, rule6737, rule6738, ]
46b9245a7cad572c8daa2d28e3566ac2251b1cda10b5b26e782975016f323af1
''' This code is automatically generated. Never edit it manually. For details of generating the code see `rubi_parsing_guide.md` in `parsetools`. ''' from sympy.external import import_module matchpy = import_module("matchpy") from sympy.utilities.decorator import doctest_depends_on if matchpy: from matchpy import Pattern, ReplacementRule, CustomConstraint, is_match from sympy.integrals.rubi.utility_function import ( Int, Sum, Set, With, Module, Scan, MapAnd, FalseQ, ZeroQ, NegativeQ, NonzeroQ, FreeQ, NFreeQ, List, Log, PositiveQ, PositiveIntegerQ, NegativeIntegerQ, IntegerQ, IntegersQ, ComplexNumberQ, PureComplexNumberQ, RealNumericQ, PositiveOrZeroQ, NegativeOrZeroQ, FractionOrNegativeQ, NegQ, Equal, Unequal, IntPart, FracPart, RationalQ, ProductQ, SumQ, NonsumQ, Subst, First, Rest, SqrtNumberQ, SqrtNumberSumQ, LinearQ, Sqrt, ArcCosh, Coefficient, Denominator, Hypergeometric2F1, Not, Simplify, FractionalPart, IntegerPart, AppellF1, EllipticPi, EllipticE, EllipticF, ArcTan, ArcCot, ArcCoth, ArcTanh, ArcSin, ArcSinh, ArcCos, ArcCsc, ArcSec, ArcCsch, ArcSech, Sinh, Tanh, Cosh, Sech, Csch, Coth, LessEqual, Less, Greater, GreaterEqual, FractionQ, IntLinearcQ, Expand, IndependentQ, PowerQ, IntegerPowerQ, PositiveIntegerPowerQ, FractionalPowerQ, AtomQ, ExpQ, LogQ, Head, MemberQ, TrigQ, SinQ, CosQ, TanQ, CotQ, SecQ, CscQ, Sin, Cos, Tan, Cot, Sec, Csc, HyperbolicQ, SinhQ, CoshQ, TanhQ, CothQ, SechQ, CschQ, InverseTrigQ, SinCosQ, SinhCoshQ, LeafCount, Numerator, NumberQ, NumericQ, Length, ListQ, Im, Re, InverseHyperbolicQ, InverseFunctionQ, TrigHyperbolicFreeQ, InverseFunctionFreeQ, RealQ, EqQ, FractionalPowerFreeQ, ComplexFreeQ, PolynomialQ, FactorSquareFree, PowerOfLinearQ, Exponent, QuadraticQ, LinearPairQ, BinomialParts, TrinomialParts, PolyQ, EvenQ, OddQ, PerfectSquareQ, NiceSqrtAuxQ, NiceSqrtQ, Together, PosAux, PosQ, CoefficientList, ReplaceAll, ExpandLinearProduct, GCD, ContentFactor, NumericFactor, NonnumericFactors, MakeAssocList, GensymSubst, KernelSubst, ExpandExpression, Apart, SmartApart, MatchQ, PolynomialQuotientRemainder, FreeFactors, NonfreeFactors, RemoveContentAux, RemoveContent, FreeTerms, NonfreeTerms, ExpandAlgebraicFunction, CollectReciprocals, ExpandCleanup, AlgebraicFunctionQ, Coeff, LeadTerm, RemainingTerms, LeadFactor, RemainingFactors, LeadBase, LeadDegree, Numer, Denom, hypergeom, Expon, MergeMonomials, PolynomialDivide, BinomialQ, TrinomialQ, GeneralizedBinomialQ, GeneralizedTrinomialQ, FactorSquareFreeList, PerfectPowerTest, SquareFreeFactorTest, RationalFunctionQ, RationalFunctionFactors, NonrationalFunctionFactors, Reverse, RationalFunctionExponents, RationalFunctionExpand, ExpandIntegrand, SimplerQ, SimplerSqrtQ, SumSimplerQ, BinomialDegree, TrinomialDegree, CancelCommonFactors, SimplerIntegrandQ, GeneralizedBinomialDegree, GeneralizedBinomialParts, GeneralizedTrinomialDegree, GeneralizedTrinomialParts, MonomialQ, MonomialSumQ, MinimumMonomialExponent, MonomialExponent, LinearMatchQ, PowerOfLinearMatchQ, QuadraticMatchQ, CubicMatchQ, BinomialMatchQ, TrinomialMatchQ, GeneralizedBinomialMatchQ, GeneralizedTrinomialMatchQ, QuotientOfLinearsMatchQ, PolynomialTermQ, PolynomialTerms, NonpolynomialTerms, PseudoBinomialParts, NormalizePseudoBinomial, PseudoBinomialPairQ, PseudoBinomialQ, PolynomialGCD, PolyGCD, AlgebraicFunctionFactors, NonalgebraicFunctionFactors, QuotientOfLinearsP, QuotientOfLinearsParts, QuotientOfLinearsQ, Flatten, Sort, AbsurdNumberQ, AbsurdNumberFactors, NonabsurdNumberFactors, SumSimplerAuxQ, Prepend, Drop, CombineExponents, FactorInteger, FactorAbsurdNumber, SubstForInverseFunction, SubstForFractionalPower, SubstForFractionalPowerOfQuotientOfLinears, FractionalPowerOfQuotientOfLinears, SubstForFractionalPowerQ, SubstForFractionalPowerAuxQ, FractionalPowerOfSquareQ, FractionalPowerSubexpressionQ, Apply, FactorNumericGcd, MergeableFactorQ, MergeFactor, MergeFactors, TrigSimplifyQ, TrigSimplify, TrigSimplifyRecur, Order, FactorOrder, Smallest, OrderedQ, MinimumDegree, PositiveFactors, Sign, NonpositiveFactors, PolynomialInAuxQ, PolynomialInQ, ExponentInAux, ExponentIn, PolynomialInSubstAux, PolynomialInSubst, Distrib, DistributeDegree, FunctionOfPower, DivideDegreesOfFactors, MonomialFactor, FullSimplify, FunctionOfLinearSubst, FunctionOfLinear, NormalizeIntegrand, NormalizeIntegrandAux, NormalizeIntegrandFactor, NormalizeIntegrandFactorBase, NormalizeTogether, NormalizeLeadTermSigns, AbsorbMinusSign, NormalizeSumFactors, SignOfFactor, NormalizePowerOfLinear, SimplifyIntegrand, SimplifyTerm, TogetherSimplify, SmartSimplify, SubstForExpn, ExpandToSum, UnifySum, UnifyTerms, UnifyTerm, CalculusQ, FunctionOfInverseLinear, PureFunctionOfSinhQ, PureFunctionOfTanhQ, PureFunctionOfCoshQ, IntegerQuotientQ, OddQuotientQ, EvenQuotientQ, FindTrigFactor, FunctionOfSinhQ, FunctionOfCoshQ, OddHyperbolicPowerQ, FunctionOfTanhQ, FunctionOfTanhWeight, FunctionOfHyperbolicQ, SmartNumerator, SmartDenominator, SubstForAux, ActivateTrig, ExpandTrig, TrigExpand, SubstForTrig, SubstForHyperbolic, InertTrigFreeQ, LCM, SubstForFractionalPowerOfLinear, FractionalPowerOfLinear, InverseFunctionOfLinear, InertTrigQ, InertReciprocalQ, DeactivateTrig, FixInertTrigFunction, DeactivateTrigAux, PowerOfInertTrigSumQ, PiecewiseLinearQ, KnownTrigIntegrandQ, KnownSineIntegrandQ, KnownTangentIntegrandQ, KnownCotangentIntegrandQ, KnownSecantIntegrandQ, TryPureTanSubst, TryTanhSubst, TryPureTanhSubst, AbsurdNumberGCD, AbsurdNumberGCDList, ExpandTrigExpand, ExpandTrigReduce, ExpandTrigReduceAux, NormalizeTrig, TrigToExp, ExpandTrigToExp, TrigReduce, FunctionOfTrig, AlgebraicTrigFunctionQ, FunctionOfHyperbolic, FunctionOfQ, FunctionOfExpnQ, PureFunctionOfSinQ, PureFunctionOfCosQ, PureFunctionOfTanQ, PureFunctionOfCotQ, FunctionOfCosQ, FunctionOfSinQ, OddTrigPowerQ, FunctionOfTanQ, FunctionOfTanWeight, FunctionOfTrigQ, FunctionOfDensePolynomialsQ, FunctionOfLog, PowerVariableExpn, PowerVariableDegree, PowerVariableSubst, EulerIntegrandQ, FunctionOfSquareRootOfQuadratic, SquareRootOfQuadraticSubst, Divides, EasyDQ, ProductOfLinearPowersQ, Rt, NthRoot, AtomBaseQ, SumBaseQ, NegSumBaseQ, AllNegTermQ, SomeNegTermQ, TrigSquareQ, RtAux, TrigSquare, IntSum, IntTerm, Map2, ConstantFactor, SameQ, ReplacePart, CommonFactors, MostMainFactorPosition, FunctionOfExponentialQ, FunctionOfExponential, FunctionOfExponentialFunction, FunctionOfExponentialFunctionAux, FunctionOfExponentialTest, FunctionOfExponentialTestAux, stdev, rubi_test, If, IntQuadraticQ, IntBinomialQ, RectifyTangent, RectifyCotangent, Inequality, Condition, Simp, SimpHelp, SplitProduct, SplitSum, SubstFor, SubstForAux, FresnelS, FresnelC, Erfc, Erfi, Gamma, FunctionOfTrigOfLinearQ, ElementaryFunctionQ, Complex, UnsameQ, _SimpFixFactor, SimpFixFactor, _FixSimplify, FixSimplify, _SimplifyAntiderivativeSum, SimplifyAntiderivativeSum, _SimplifyAntiderivative, SimplifyAntiderivative, _TrigSimplifyAux, TrigSimplifyAux, Cancel, Part, PolyLog, D, Dist, Sum_doit, PolynomialQuotient, Floor, PolynomialRemainder, Factor, PolyLog, CosIntegral, SinIntegral, LogIntegral, SinhIntegral, CoshIntegral, Rule, Erf, PolyGamma, ExpIntegralEi, ExpIntegralE, LogGamma , UtilityOperator, Factorial, Zeta, ProductLog, DerivativeDivides, HypergeometricPFQ, IntHide, OneQ, Null, rubi_exp as exp, rubi_log as log, Discriminant, Negative, Quotient ) from sympy import (Integral, S, sqrt, And, Or, Integer, Float, Mod, I, Abs, simplify, Mul, Add, Pow, sign, EulerGamma) from sympy.integrals.rubi.symbol import WC from sympy.core.symbol import symbols, Symbol from sympy.functions import (sin, cos, tan, cot, csc, sec, sqrt, erf) from sympy.functions.elementary.hyperbolic import (acosh, asinh, atanh, acoth, acsch, asech, cosh, sinh, tanh, coth, sech, csch) from sympy.functions.elementary.trigonometric import (atan, acsc, asin, acot, acos, asec, atan2) from sympy import pi as Pi A_, B_, C_, F_, G_, H_, a_, b_, c_, d_, e_, f_, g_, h_, i_, j_, k_, l_, m_, n_, p_, q_, r_, t_, u_, v_, s_, w_, x_, y_, z_ = [WC(i) for i in 'ABCFGHabcdefghijklmnpqrtuvswxyz'] a1_, a2_, b1_, b2_, c1_, c2_, d1_, d2_, n1_, n2_, e1_, e2_, f1_, f2_, g1_, g2_, n1_, n2_, n3_, Pq_, Pm_, Px_, Qm_, Qr_, Qx_, jn_, mn_, non2_, RFx_, RGx_ = [WC(i) for i in ['a1', 'a2', 'b1', 'b2', 'c1', 'c2', 'd1', 'd2', 'n1', 'n2', 'e1', 'e2', 'f1', 'f2', 'g1', 'g2', 'n1', 'n2', 'n3', 'Pq', 'Pm', 'Px', 'Qm', 'Qr', 'Qx', 'jn', 'mn', 'non2', 'RFx', 'RGx']] i, ii , Pqq, Q, R, r, C, k, u = symbols('i ii Pqq Q R r C k u') _UseGamma = False ShowSteps = False StepCounter = None def inverse_trig(rubi): from sympy.integrals.rubi.constraints import cons87, cons88, cons2, cons3, cons7, cons89, cons1579, cons4, cons148, cons66, cons27, cons21, cons62, cons1734, cons1735, cons1736, cons1737, cons268, cons48, cons584, cons1738, cons128, cons338, cons163, cons137, cons230, cons5, cons1739, cons1740, cons1741, cons1742, cons1743, cons38, cons1744, cons1570, cons336, cons1745, cons147, cons125, cons208, cons54, cons242, cons1746, cons347, cons1747, cons486, cons961, cons93, cons94, cons162, cons272, cons1748, cons17, cons166, cons274, cons1749, cons18, cons1750, cons238, cons237, cons1751, cons246, cons1752, cons1753, cons1754, cons1755, cons1756, cons209, cons925, cons464, cons84, cons1757, cons1758, cons719, cons168, cons1759, cons667, cons1760, cons267, cons717, cons1761, cons1608, cons14, cons150, cons1198, cons1273, cons1360, cons1762, cons1763, cons34, cons35, cons36, cons1764, cons1765, cons165, cons1442, cons1766, cons1767, cons1768, cons1230, cons1769, cons1770, cons1771, cons1772, cons340, cons1773, cons1774, cons1775, cons1776, cons1043, cons85, cons31, cons1777, cons1497, cons1778, cons13, cons1779, cons1780, cons1781, cons1782, cons240, cons241, cons146, cons1783, cons1510, cons1784, cons1152, cons319, cons1785, cons1786, cons1787, cons1788, cons1789, cons1790, cons1791, cons1792, cons1793, cons1794, cons1795, cons1796, cons601, cons1797, cons261, cons1798, cons1799, cons1800, cons1801, cons1802, cons1803, cons1804, cons1805, cons177, cons117, cons1806, cons1807, cons1808, cons1809, cons1810, cons1811, cons1812, cons1813, cons1814, cons1815, cons1816, cons1817, cons1580, cons1818, cons1819, cons1820, cons1821, cons1822, cons1823, cons1824, cons1825, cons1826, cons1827, cons1828, cons1829, cons1830, cons1094, cons1831, cons1832, cons1833, cons1834, cons1835, cons383, cons1836, cons1837, cons818, cons463, cons1838, cons1839, cons1840, cons1841, cons1842, cons1843, cons1844, cons67, cons1845, cons1846, cons1847, cons1848, cons1849, cons1850, cons1851, cons552, cons1146, cons1852, cons1853, cons1242, cons1243, cons1854, cons178, cons1855, cons1856, cons1299, cons1857, cons1858 pattern5031 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*asin(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons87, cons88) def replacement5031(b, a, n, c, x): rubi.append(5031) return -Dist(b*c*n, Int(x*(a + b*asin(c*x))**(n + S(-1))/sqrt(-c**S(2)*x**S(2) + S(1)), x), x) + Simp(x*(a + b*asin(c*x))**n, x) rule5031 = ReplacementRule(pattern5031, replacement5031) pattern5032 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*acos(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons87, cons88) def replacement5032(b, a, n, c, x): rubi.append(5032) return Dist(b*c*n, Int(x*(a + b*acos(c*x))**(n + S(-1))/sqrt(-c**S(2)*x**S(2) + S(1)), x), x) + Simp(x*(a + b*acos(c*x))**n, x) rule5032 = ReplacementRule(pattern5032, replacement5032) pattern5033 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*asin(x_*WC('c', S(1))))**n_, x_), cons2, cons3, cons7, cons87, cons89) def replacement5033(b, a, n, c, x): rubi.append(5033) return Dist(c/(b*(n + S(1))), Int(x*(a + b*asin(c*x))**(n + S(1))/sqrt(-c**S(2)*x**S(2) + S(1)), x), x) + Simp((a + b*asin(c*x))**(n + S(1))*sqrt(-c**S(2)*x**S(2) + S(1))/(b*c*(n + S(1))), x) rule5033 = ReplacementRule(pattern5033, replacement5033) pattern5034 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*acos(x_*WC('c', S(1))))**n_, x_), cons2, cons3, cons7, cons87, cons89) def replacement5034(b, a, n, c, x): rubi.append(5034) return -Dist(c/(b*(n + S(1))), Int(x*(a + b*acos(c*x))**(n + S(1))/sqrt(-c**S(2)*x**S(2) + S(1)), x), x) - Simp((a + b*acos(c*x))**(n + S(1))*sqrt(-c**S(2)*x**S(2) + S(1))/(b*c*(n + S(1))), x) rule5034 = ReplacementRule(pattern5034, replacement5034) pattern5035 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*asin(x_*WC('c', S(1))))**n_, x_), cons2, cons3, cons7, cons4, cons1579) def replacement5035(b, a, n, c, x): rubi.append(5035) return Dist(S(1)/(b*c), Subst(Int(x**n*cos(a/b - x/b), x), x, a + b*asin(c*x)), x) rule5035 = ReplacementRule(pattern5035, replacement5035) pattern5036 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*acos(x_*WC('c', S(1))))**n_, x_), cons2, cons3, cons7, cons4, cons1579) def replacement5036(b, a, n, c, x): rubi.append(5036) return Dist(S(1)/(b*c), Subst(Int(x**n*sin(a/b - x/b), x), x, a + b*acos(c*x)), x) rule5036 = ReplacementRule(pattern5036, replacement5036) pattern5037 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*asin(x_*WC('c', S(1))))**WC('n', S(1))/x_, x_), cons2, cons3, cons7, cons148) def replacement5037(b, a, n, c, x): rubi.append(5037) return Subst(Int((a + b*x)**n/tan(x), x), x, asin(c*x)) rule5037 = ReplacementRule(pattern5037, replacement5037) pattern5038 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*acos(x_*WC('c', S(1))))**WC('n', S(1))/x_, x_), cons2, cons3, cons7, cons148) def replacement5038(b, a, n, c, x): rubi.append(5038) return -Subst(Int((a + b*x)**n*tan(x), x), x, acos(c*x)) rule5038 = ReplacementRule(pattern5038, replacement5038) pattern5039 = Pattern(Integral((x_*WC('d', S(1)))**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*asin(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons21, cons148, cons66) def replacement5039(m, b, d, a, n, c, x): rubi.append(5039) return -Dist(b*c*n/(d*(m + S(1))), Int((d*x)**(m + S(1))*(a + b*asin(c*x))**(n + S(-1))/sqrt(-c**S(2)*x**S(2) + S(1)), x), x) + Simp((d*x)**(m + S(1))*(a + b*asin(c*x))**n/(d*(m + S(1))), x) rule5039 = ReplacementRule(pattern5039, replacement5039) pattern5040 = Pattern(Integral((x_*WC('d', S(1)))**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*acos(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons21, cons148, cons66) def replacement5040(m, b, d, a, n, c, x): rubi.append(5040) return Dist(b*c*n/(d*(m + S(1))), Int((d*x)**(m + S(1))*(a + b*acos(c*x))**(n + S(-1))/sqrt(-c**S(2)*x**S(2) + S(1)), x), x) + Simp((d*x)**(m + S(1))*(a + b*acos(c*x))**n/(d*(m + S(1))), x) rule5040 = ReplacementRule(pattern5040, replacement5040) pattern5041 = Pattern(Integral(x_**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*asin(x_*WC('c', S(1))))**n_, x_), cons2, cons3, cons7, cons62, cons87, cons88) def replacement5041(m, b, a, c, n, x): rubi.append(5041) return -Dist(b*c*n/(m + S(1)), Int(x**(m + S(1))*(a + b*asin(c*x))**(n + S(-1))/sqrt(-c**S(2)*x**S(2) + S(1)), x), x) + Simp(x**(m + S(1))*(a + b*asin(c*x))**n/(m + S(1)), x) rule5041 = ReplacementRule(pattern5041, replacement5041) pattern5042 = Pattern(Integral(x_**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*acos(x_*WC('c', S(1))))**n_, x_), cons2, cons3, cons7, cons62, cons87, cons88) def replacement5042(m, b, a, c, n, x): rubi.append(5042) return Dist(b*c*n/(m + S(1)), Int(x**(m + S(1))*(a + b*acos(c*x))**(n + S(-1))/sqrt(-c**S(2)*x**S(2) + S(1)), x), x) + Simp(x**(m + S(1))*(a + b*acos(c*x))**n/(m + S(1)), x) rule5042 = ReplacementRule(pattern5042, replacement5042) pattern5043 = Pattern(Integral(x_**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*asin(x_*WC('c', S(1))))**n_, x_), cons2, cons3, cons7, cons62, cons87, cons1734) def replacement5043(m, b, a, c, n, x): rubi.append(5043) return -Dist(c**(-m + S(-1))/(b*(n + S(1))), Subst(Int(ExpandTrigReduce((a + b*x)**(n + S(1)), (m - (m + S(1))*sin(x)**S(2))*sin(x)**(m + S(-1)), x), x), x, asin(c*x)), x) + Simp(x**m*(a + b*asin(c*x))**(n + S(1))*sqrt(-c**S(2)*x**S(2) + S(1))/(b*c*(n + S(1))), x) rule5043 = ReplacementRule(pattern5043, replacement5043) pattern5044 = Pattern(Integral(x_**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*acos(x_*WC('c', S(1))))**n_, x_), cons2, cons3, cons7, cons62, cons87, cons1734) def replacement5044(m, b, a, c, n, x): rubi.append(5044) return -Dist(c**(-m + S(-1))/(b*(n + S(1))), Subst(Int(ExpandTrigReduce((a + b*x)**(n + S(1)), (m - (m + S(1))*cos(x)**S(2))*cos(x)**(m + S(-1)), x), x), x, acos(c*x)), x) - Simp(x**m*(a + b*acos(c*x))**(n + S(1))*sqrt(-c**S(2)*x**S(2) + S(1))/(b*c*(n + S(1))), x) rule5044 = ReplacementRule(pattern5044, replacement5044) pattern5045 = Pattern(Integral(x_**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*asin(x_*WC('c', S(1))))**n_, x_), cons2, cons3, cons7, cons62, cons87, cons1735) def replacement5045(m, b, a, c, n, x): rubi.append(5045) return -Dist(m/(b*c*(n + S(1))), Int(x**(m + S(-1))*(a + b*asin(c*x))**(n + S(1))/sqrt(-c**S(2)*x**S(2) + S(1)), x), x) + Dist(c*(m + S(1))/(b*(n + S(1))), Int(x**(m + S(1))*(a + b*asin(c*x))**(n + S(1))/sqrt(-c**S(2)*x**S(2) + S(1)), x), x) + Simp(x**m*(a + b*asin(c*x))**(n + S(1))*sqrt(-c**S(2)*x**S(2) + S(1))/(b*c*(n + S(1))), x) rule5045 = ReplacementRule(pattern5045, replacement5045) pattern5046 = Pattern(Integral(x_**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*acos(x_*WC('c', S(1))))**n_, x_), cons2, cons3, cons7, cons62, cons87, cons1735) def replacement5046(m, b, a, c, n, x): rubi.append(5046) return Dist(m/(b*c*(n + S(1))), Int(x**(m + S(-1))*(a + b*acos(c*x))**(n + S(1))/sqrt(-c**S(2)*x**S(2) + S(1)), x), x) - Dist(c*(m + S(1))/(b*(n + S(1))), Int(x**(m + S(1))*(a + b*acos(c*x))**(n + S(1))/sqrt(-c**S(2)*x**S(2) + S(1)), x), x) - Simp(x**m*(a + b*acos(c*x))**(n + S(1))*sqrt(-c**S(2)*x**S(2) + S(1))/(b*c*(n + S(1))), x) rule5046 = ReplacementRule(pattern5046, replacement5046) pattern5047 = Pattern(Integral(x_**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*asin(x_*WC('c', S(1))))**n_, x_), cons2, cons3, cons7, cons4, cons62) def replacement5047(m, b, a, c, n, x): rubi.append(5047) return Dist(c**(-m + S(-1)), Subst(Int((a + b*x)**n*sin(x)**m*cos(x), x), x, asin(c*x)), x) rule5047 = ReplacementRule(pattern5047, replacement5047) pattern5048 = Pattern(Integral(x_**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*acos(x_*WC('c', S(1))))**n_, x_), cons2, cons3, cons7, cons4, cons62) def replacement5048(m, b, a, c, n, x): rubi.append(5048) return -Dist(c**(-m + S(-1)), Subst(Int((a + b*x)**n*sin(x)*cos(x)**m, x), x, acos(c*x)), x) rule5048 = ReplacementRule(pattern5048, replacement5048) pattern5049 = Pattern(Integral((x_*WC('d', S(1)))**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*asin(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons21, cons4, cons1736) def replacement5049(m, b, d, a, n, c, x): rubi.append(5049) return Int((d*x)**m*(a + b*asin(c*x))**n, x) rule5049 = ReplacementRule(pattern5049, replacement5049) pattern5050 = Pattern(Integral((x_*WC('d', S(1)))**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*acos(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons21, cons4, cons1736) def replacement5050(m, b, d, a, n, c, x): rubi.append(5050) return Int((d*x)**m*(a + b*acos(c*x))**n, x) rule5050 = ReplacementRule(pattern5050, replacement5050) pattern5051 = Pattern(Integral(S(1)/(sqrt(d_ + x_**S(2)*WC('e', S(1)))*(WC('a', S(0)) + WC('b', S(1))*asin(x_*WC('c', S(1))))), x_), cons2, cons3, cons7, cons27, cons48, cons1737, cons268) def replacement5051(b, d, a, c, x, e): rubi.append(5051) return Simp(log(a + b*asin(c*x))/(b*c*sqrt(d)), x) rule5051 = ReplacementRule(pattern5051, replacement5051) pattern5052 = Pattern(Integral(S(1)/(sqrt(d_ + x_**S(2)*WC('e', S(1)))*(WC('a', S(0)) + WC('b', S(1))*acos(x_*WC('c', S(1))))), x_), cons2, cons3, cons7, cons27, cons48, cons1737, cons268) def replacement5052(b, d, a, c, x, e): rubi.append(5052) return -Simp(log(a + b*acos(c*x))/(b*c*sqrt(d)), x) rule5052 = ReplacementRule(pattern5052, replacement5052) pattern5053 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*asin(x_*WC('c', S(1))))**WC('n', S(1))/sqrt(d_ + x_**S(2)*WC('e', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons4, cons1737, cons268, cons584) def replacement5053(b, d, a, n, c, x, e): rubi.append(5053) return Simp((a + b*asin(c*x))**(n + S(1))/(b*c*sqrt(d)*(n + S(1))), x) rule5053 = ReplacementRule(pattern5053, replacement5053) pattern5054 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*acos(x_*WC('c', S(1))))**WC('n', S(1))/sqrt(d_ + x_**S(2)*WC('e', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons4, cons1737, cons268, cons584) def replacement5054(b, d, a, n, c, x, e): rubi.append(5054) return -Simp((a + b*acos(c*x))**(n + S(1))/(b*c*sqrt(d)*(n + S(1))), x) rule5054 = ReplacementRule(pattern5054, replacement5054) pattern5055 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*asin(x_*WC('c', S(1))))**WC('n', S(1))/sqrt(d_ + x_**S(2)*WC('e', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons4, cons1737, cons1738) def replacement5055(b, d, a, n, c, x, e): rubi.append(5055) return Dist(sqrt(-c**S(2)*x**S(2) + S(1))/sqrt(d + e*x**S(2)), Int((a + b*asin(c*x))**n/sqrt(-c**S(2)*x**S(2) + S(1)), x), x) rule5055 = ReplacementRule(pattern5055, replacement5055) pattern5056 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*acos(x_*WC('c', S(1))))**WC('n', S(1))/sqrt(d_ + x_**S(2)*WC('e', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons4, cons1737, cons1738) def replacement5056(b, d, a, n, c, x, e): rubi.append(5056) return Dist(sqrt(-c**S(2)*x**S(2) + S(1))/sqrt(d + e*x**S(2)), Int((a + b*acos(c*x))**n/sqrt(-c**S(2)*x**S(2) + S(1)), x), x) rule5056 = ReplacementRule(pattern5056, replacement5056) def With5057(p, b, d, a, c, x, e): u = IntHide((d + e*x**S(2))**p, x) rubi.append(5057) return -Dist(b*c, Int(SimplifyIntegrand(u/sqrt(-c**S(2)*x**S(2) + S(1)), x), x), x) + Dist(a + b*asin(c*x), u, x) pattern5057 = Pattern(Integral((d_ + x_**S(2)*WC('e', S(1)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*asin(x_*WC('c', S(1)))), x_), cons2, cons3, cons7, cons27, cons48, cons1737, cons128) rule5057 = ReplacementRule(pattern5057, With5057) def With5058(p, b, d, a, c, x, e): u = IntHide((d + e*x**S(2))**p, x) rubi.append(5058) return Dist(b*c, Int(SimplifyIntegrand(u/sqrt(-c**S(2)*x**S(2) + S(1)), x), x), x) + Dist(a + b*acos(c*x), u, x) pattern5058 = Pattern(Integral((d_ + x_**S(2)*WC('e', S(1)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*acos(x_*WC('c', S(1)))), x_), cons2, cons3, cons7, cons27, cons48, cons1737, cons128) rule5058 = ReplacementRule(pattern5058, With5058) pattern5059 = Pattern(Integral(sqrt(d_ + x_**S(2)*WC('e', S(1)))*(WC('a', S(0)) + WC('b', S(1))*asin(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons1737, cons87, cons88) def replacement5059(b, d, a, n, c, x, e): rubi.append(5059) return Dist(sqrt(d + e*x**S(2))/(S(2)*sqrt(-c**S(2)*x**S(2) + S(1))), Int((a + b*asin(c*x))**n/sqrt(-c**S(2)*x**S(2) + S(1)), x), x) - Dist(b*c*n*sqrt(d + e*x**S(2))/(S(2)*sqrt(-c**S(2)*x**S(2) + S(1))), Int(x*(a + b*asin(c*x))**(n + S(-1)), x), x) + Simp(x*(a + b*asin(c*x))**n*sqrt(d + e*x**S(2))/S(2), x) rule5059 = ReplacementRule(pattern5059, replacement5059) pattern5060 = Pattern(Integral(sqrt(d_ + x_**S(2)*WC('e', S(1)))*(WC('a', S(0)) + WC('b', S(1))*acos(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons1737, cons87, cons88) def replacement5060(b, d, a, n, c, x, e): rubi.append(5060) return Dist(sqrt(d + e*x**S(2))/(S(2)*sqrt(-c**S(2)*x**S(2) + S(1))), Int((a + b*acos(c*x))**n/sqrt(-c**S(2)*x**S(2) + S(1)), x), x) + Dist(b*c*n*sqrt(d + e*x**S(2))/(S(2)*sqrt(-c**S(2)*x**S(2) + S(1))), Int(x*(a + b*acos(c*x))**(n + S(-1)), x), x) + Simp(x*(a + b*acos(c*x))**n*sqrt(d + e*x**S(2))/S(2), x) rule5060 = ReplacementRule(pattern5060, replacement5060) pattern5061 = Pattern(Integral((d_ + x_**S(2)*WC('e', S(1)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*asin(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons1737, cons338, cons88, cons163) def replacement5061(p, b, d, a, n, c, x, e): rubi.append(5061) return Dist(S(2)*d*p/(S(2)*p + S(1)), Int((a + b*asin(c*x))**n*(d + e*x**S(2))**(p + S(-1)), x), x) - Dist(b*c*d**IntPart(p)*n*(d + e*x**S(2))**FracPart(p)*(-c**S(2)*x**S(2) + S(1))**(-FracPart(p))/(S(2)*p + S(1)), Int(x*(a + b*asin(c*x))**(n + S(-1))*(-c**S(2)*x**S(2) + S(1))**(p + S(-1)/2), x), x) + Simp(x*(a + b*asin(c*x))**n*(d + e*x**S(2))**p/(S(2)*p + S(1)), x) rule5061 = ReplacementRule(pattern5061, replacement5061) pattern5062 = Pattern(Integral((d_ + x_**S(2)*WC('e', S(1)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*acos(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons1737, cons338, cons88, cons163) def replacement5062(p, b, d, a, n, c, x, e): rubi.append(5062) return Dist(S(2)*d*p/(S(2)*p + S(1)), Int((a + b*acos(c*x))**n*(d + e*x**S(2))**(p + S(-1)), x), x) + Dist(b*c*d**IntPart(p)*n*(d + e*x**S(2))**FracPart(p)*(-c**S(2)*x**S(2) + S(1))**(-FracPart(p))/(S(2)*p + S(1)), Int(x*(a + b*acos(c*x))**(n + S(-1))*(-c**S(2)*x**S(2) + S(1))**(p + S(-1)/2), x), x) + Simp(x*(a + b*acos(c*x))**n*(d + e*x**S(2))**p/(S(2)*p + S(1)), x) rule5062 = ReplacementRule(pattern5062, replacement5062) pattern5063 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*asin(x_*WC('c', S(1))))**WC('n', S(1))/(d_ + x_**S(2)*WC('e', S(1)))**(S(3)/2), x_), cons2, cons3, cons7, cons27, cons48, cons1737, cons87, cons88, cons268) def replacement5063(b, d, a, n, c, x, e): rubi.append(5063) return -Dist(b*c*n/sqrt(d), Int(x*(a + b*asin(c*x))**(n + S(-1))/(d + e*x**S(2)), x), x) + Simp(x*(a + b*asin(c*x))**n/(d*sqrt(d + e*x**S(2))), x) rule5063 = ReplacementRule(pattern5063, replacement5063) pattern5064 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*acos(x_*WC('c', S(1))))**WC('n', S(1))/(d_ + x_**S(2)*WC('e', S(1)))**(S(3)/2), x_), cons2, cons3, cons7, cons27, cons48, cons1737, cons87, cons88, cons268) def replacement5064(b, d, a, n, c, x, e): rubi.append(5064) return Dist(b*c*n/sqrt(d), Int(x*(a + b*acos(c*x))**(n + S(-1))/(d + e*x**S(2)), x), x) + Simp(x*(a + b*acos(c*x))**n/(d*sqrt(d + e*x**S(2))), x) rule5064 = ReplacementRule(pattern5064, replacement5064) pattern5065 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*asin(x_*WC('c', S(1))))**WC('n', S(1))/(d_ + x_**S(2)*WC('e', S(1)))**(S(3)/2), x_), cons2, cons3, cons7, cons27, cons48, cons1737, cons87, cons88) def replacement5065(b, d, a, n, c, x, e): rubi.append(5065) return -Dist(b*c*n*sqrt(-c**S(2)*x**S(2) + S(1))/(d*sqrt(d + e*x**S(2))), Int(x*(a + b*asin(c*x))**(n + S(-1))/(-c**S(2)*x**S(2) + S(1)), x), x) + Simp(x*(a + b*asin(c*x))**n/(d*sqrt(d + e*x**S(2))), x) rule5065 = ReplacementRule(pattern5065, replacement5065) pattern5066 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*acos(x_*WC('c', S(1))))**WC('n', S(1))/(d_ + x_**S(2)*WC('e', S(1)))**(S(3)/2), x_), cons2, cons3, cons7, cons27, cons48, cons1737, cons87, cons88) def replacement5066(b, d, a, n, c, x, e): rubi.append(5066) return Dist(b*c*n*sqrt(-c**S(2)*x**S(2) + S(1))/(d*sqrt(d + e*x**S(2))), Int(x*(a + b*acos(c*x))**(n + S(-1))/(-c**S(2)*x**S(2) + S(1)), x), x) + Simp(x*(a + b*acos(c*x))**n/(d*sqrt(d + e*x**S(2))), x) rule5066 = ReplacementRule(pattern5066, replacement5066) pattern5067 = Pattern(Integral((d_ + x_**S(2)*WC('e', S(1)))**p_*(WC('a', S(0)) + WC('b', S(1))*asin(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons1737, cons338, cons88, cons137, cons230) def replacement5067(p, b, d, a, n, c, x, e): rubi.append(5067) return Dist((S(2)*p + S(3))/(S(2)*d*(p + S(1))), Int((a + b*asin(c*x))**n*(d + e*x**S(2))**(p + S(1)), x), x) + Dist(b*c*d**IntPart(p)*n*(d + e*x**S(2))**FracPart(p)*(-c**S(2)*x**S(2) + S(1))**(-FracPart(p))/(S(2)*(p + S(1))), Int(x*(a + b*asin(c*x))**(n + S(-1))*(-c**S(2)*x**S(2) + S(1))**(p + S(1)/2), x), x) - Simp(x*(a + b*asin(c*x))**n*(d + e*x**S(2))**(p + S(1))/(S(2)*d*(p + S(1))), x) rule5067 = ReplacementRule(pattern5067, replacement5067) pattern5068 = Pattern(Integral((d_ + x_**S(2)*WC('e', S(1)))**p_*(WC('a', S(0)) + WC('b', S(1))*acos(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons1737, cons338, cons88, cons137, cons230) def replacement5068(p, b, d, a, n, c, x, e): rubi.append(5068) return Dist((S(2)*p + S(3))/(S(2)*d*(p + S(1))), Int((a + b*acos(c*x))**n*(d + e*x**S(2))**(p + S(1)), x), x) - Dist(b*c*d**IntPart(p)*n*(d + e*x**S(2))**FracPart(p)*(-c**S(2)*x**S(2) + S(1))**(-FracPart(p))/(S(2)*(p + S(1))), Int(x*(a + b*acos(c*x))**(n + S(-1))*(-c**S(2)*x**S(2) + S(1))**(p + S(1)/2), x), x) - Simp(x*(a + b*acos(c*x))**n*(d + e*x**S(2))**(p + S(1))/(S(2)*d*(p + S(1))), x) rule5068 = ReplacementRule(pattern5068, replacement5068) pattern5069 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*asin(x_*WC('c', S(1))))**WC('n', S(1))/(d_ + x_**S(2)*WC('e', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons1737, cons148) def replacement5069(b, d, a, n, c, x, e): rubi.append(5069) return Dist(S(1)/(c*d), Subst(Int((a + b*x)**n/cos(x), x), x, asin(c*x)), x) rule5069 = ReplacementRule(pattern5069, replacement5069) pattern5070 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*acos(x_*WC('c', S(1))))**WC('n', S(1))/(d_ + x_**S(2)*WC('e', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons1737, cons148) def replacement5070(b, d, a, n, c, x, e): rubi.append(5070) return -Dist(S(1)/(c*d), Subst(Int((a + b*x)**n/sin(x), x), x, acos(c*x)), x) rule5070 = ReplacementRule(pattern5070, replacement5070) pattern5071 = Pattern(Integral((d_ + x_**S(2)*WC('e', S(1)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*asin(x_*WC('c', S(1))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons5, cons1737, cons87, cons89) def replacement5071(p, b, d, a, c, n, x, e): rubi.append(5071) return Dist(c*d**IntPart(p)*(d + e*x**S(2))**FracPart(p)*(S(2)*p + S(1))*(-c**S(2)*x**S(2) + S(1))**(-FracPart(p))/(b*(n + S(1))), Int(x*(a + b*asin(c*x))**(n + S(1))*(-c**S(2)*x**S(2) + S(1))**(p + S(-1)/2), x), x) + Simp((a + b*asin(c*x))**(n + S(1))*(d + e*x**S(2))**p*sqrt(-c**S(2)*x**S(2) + S(1))/(b*c*(n + S(1))), x) rule5071 = ReplacementRule(pattern5071, replacement5071) pattern5072 = Pattern(Integral((d_ + x_**S(2)*WC('e', S(1)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*acos(x_*WC('c', S(1))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons5, cons1737, cons87, cons89) def replacement5072(p, b, d, a, c, n, x, e): rubi.append(5072) return -Dist(c*d**IntPart(p)*(d + e*x**S(2))**FracPart(p)*(S(2)*p + S(1))*(-c**S(2)*x**S(2) + S(1))**(-FracPart(p))/(b*(n + S(1))), Int(x*(a + b*acos(c*x))**(n + S(1))*(-c**S(2)*x**S(2) + S(1))**(p + S(-1)/2), x), x) - Simp((a + b*acos(c*x))**(n + S(1))*(d + e*x**S(2))**p*sqrt(-c**S(2)*x**S(2) + S(1))/(b*c*(n + S(1))), x) rule5072 = ReplacementRule(pattern5072, replacement5072) pattern5073 = Pattern(Integral((d_ + x_**S(2)*WC('e', S(1)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*asin(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons4, cons1737, cons1739, cons1740) def replacement5073(p, b, d, a, n, c, x, e): rubi.append(5073) return Dist(d**p/c, Subst(Int((a + b*x)**n*cos(x)**(S(2)*p + S(1)), x), x, asin(c*x)), x) rule5073 = ReplacementRule(pattern5073, replacement5073) pattern5074 = Pattern(Integral((d_ + x_**S(2)*WC('e', S(1)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*acos(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons4, cons1737, cons1739, cons1740) def replacement5074(p, b, d, a, n, c, x, e): rubi.append(5074) return -Dist(d**p/c, Subst(Int((a + b*x)**n*sin(x)**(S(2)*p + S(1)), x), x, acos(c*x)), x) rule5074 = ReplacementRule(pattern5074, replacement5074) pattern5075 = Pattern(Integral((d_ + x_**S(2)*WC('e', S(1)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*asin(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons4, cons1737, cons1739, cons1741) def replacement5075(p, b, d, a, n, c, x, e): rubi.append(5075) return Dist(d**(p + S(-1)/2)*sqrt(d + e*x**S(2))/sqrt(-c**S(2)*x**S(2) + S(1)), Int((a + b*asin(c*x))**n*(-c**S(2)*x**S(2) + S(1))**p, x), x) rule5075 = ReplacementRule(pattern5075, replacement5075) pattern5076 = Pattern(Integral((d_ + x_**S(2)*WC('e', S(1)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*acos(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons4, cons1737, cons1739, cons1741) def replacement5076(p, b, d, a, n, c, x, e): rubi.append(5076) return Dist(d**(p + S(-1)/2)*sqrt(d + e*x**S(2))/sqrt(-c**S(2)*x**S(2) + S(1)), Int((a + b*acos(c*x))**n*(-c**S(2)*x**S(2) + S(1))**p, x), x) rule5076 = ReplacementRule(pattern5076, replacement5076) def With5077(p, b, d, a, c, x, e): u = IntHide((d + e*x**S(2))**p, x) rubi.append(5077) return -Dist(b*c, Int(SimplifyIntegrand(u/sqrt(-c**S(2)*x**S(2) + S(1)), x), x), x) + Dist(a + b*asin(c*x), u, x) pattern5077 = Pattern(Integral((d_ + x_**S(2)*WC('e', S(1)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*asin(x_*WC('c', S(1)))), x_), cons2, cons3, cons7, cons27, cons48, cons1742, cons1743) rule5077 = ReplacementRule(pattern5077, With5077) def With5078(p, b, d, a, c, x, e): u = IntHide((d + e*x**S(2))**p, x) rubi.append(5078) return Dist(b*c, Int(SimplifyIntegrand(u/sqrt(-c**S(2)*x**S(2) + S(1)), x), x), x) + Dist(a + b*acos(c*x), u, x) pattern5078 = Pattern(Integral((d_ + x_**S(2)*WC('e', S(1)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*acos(x_*WC('c', S(1)))), x_), cons2, cons3, cons7, cons27, cons48, cons1742, cons1743) rule5078 = ReplacementRule(pattern5078, With5078) pattern5079 = Pattern(Integral((d_ + x_**S(2)*WC('e', S(1)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*asin(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons4, cons1742, cons38, cons1744) def replacement5079(p, b, d, a, n, c, x, e): rubi.append(5079) return Int(ExpandIntegrand((a + b*asin(c*x))**n, (d + e*x**S(2))**p, x), x) rule5079 = ReplacementRule(pattern5079, replacement5079) pattern5080 = Pattern(Integral((d_ + x_**S(2)*WC('e', S(1)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*acos(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons4, cons1742, cons38, cons1744) def replacement5080(p, b, d, a, n, c, x, e): rubi.append(5080) return Int(ExpandIntegrand((a + b*acos(c*x))**n, (d + e*x**S(2))**p, x), x) rule5080 = ReplacementRule(pattern5080, replacement5080) pattern5081 = Pattern(Integral((d_ + x_**S(2)*WC('e', S(1)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*asin(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons4, cons5, cons1570) def replacement5081(p, b, d, a, n, c, x, e): rubi.append(5081) return Int((a + b*asin(c*x))**n*(d + e*x**S(2))**p, x) rule5081 = ReplacementRule(pattern5081, replacement5081) pattern5082 = Pattern(Integral((d_ + x_**S(2)*WC('e', S(1)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*acos(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons4, cons5, cons1570) def replacement5082(p, b, d, a, n, c, x, e): rubi.append(5082) return Int((a + b*acos(c*x))**n*(d + e*x**S(2))**p, x) rule5082 = ReplacementRule(pattern5082, replacement5082) pattern5083 = Pattern(Integral((d_ + x_*WC('e', S(1)))**p_*(f_ + x_*WC('g', S(1)))**p_*(WC('a', S(0)) + WC('b', S(1))*asin(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons4, cons5, cons336, cons1745, cons147) def replacement5083(p, g, b, f, d, a, n, c, x, e): rubi.append(5083) return Dist((d + e*x)**FracPart(p)*(f + g*x)**FracPart(p)*(d*f + e*g*x**S(2))**(-FracPart(p)), Int((a + b*asin(c*x))**n*(d*f + e*g*x**S(2))**p, x), x) rule5083 = ReplacementRule(pattern5083, replacement5083) pattern5084 = Pattern(Integral((d_ + x_*WC('e', S(1)))**p_*(f_ + x_*WC('g', S(1)))**p_*(WC('a', S(0)) + WC('b', S(1))*acos(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons4, cons5, cons336, cons1745, cons147) def replacement5084(p, g, b, f, d, a, n, c, x, e): rubi.append(5084) return Dist((d + e*x)**FracPart(p)*(f + g*x)**FracPart(p)*(d*f + e*g*x**S(2))**(-FracPart(p)), Int((a + b*acos(c*x))**n*(d*f + e*g*x**S(2))**p, x), x) rule5084 = ReplacementRule(pattern5084, replacement5084) pattern5085 = Pattern(Integral(x_*(WC('a', S(0)) + WC('b', S(1))*asin(x_*WC('c', S(1))))**WC('n', S(1))/(d_ + x_**S(2)*WC('e', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons1737, cons148) def replacement5085(b, d, a, n, c, x, e): rubi.append(5085) return -Dist(S(1)/e, Subst(Int((a + b*x)**n*tan(x), x), x, asin(c*x)), x) rule5085 = ReplacementRule(pattern5085, replacement5085) pattern5086 = Pattern(Integral(x_*(WC('a', S(0)) + WC('b', S(1))*acos(x_*WC('c', S(1))))**WC('n', S(1))/(d_ + x_**S(2)*WC('e', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons1737, cons148) def replacement5086(b, d, a, n, c, x, e): rubi.append(5086) return Dist(S(1)/e, Subst(Int((a + b*x)**n/tan(x), x), x, acos(c*x)), x) rule5086 = ReplacementRule(pattern5086, replacement5086) pattern5087 = Pattern(Integral(x_*(d_ + x_**S(2)*WC('e', S(1)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*asin(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons5, cons1737, cons87, cons88, cons54) def replacement5087(p, b, d, a, n, c, x, e): rubi.append(5087) return Dist(b*d**IntPart(p)*n*(d + e*x**S(2))**FracPart(p)*(-c**S(2)*x**S(2) + S(1))**(-FracPart(p))/(S(2)*c*(p + S(1))), Int((a + b*asin(c*x))**(n + S(-1))*(-c**S(2)*x**S(2) + S(1))**(p + S(1)/2), x), x) + Simp((a + b*asin(c*x))**n*(d + e*x**S(2))**(p + S(1))/(S(2)*e*(p + S(1))), x) rule5087 = ReplacementRule(pattern5087, replacement5087) pattern5088 = Pattern(Integral(x_*(d_ + x_**S(2)*WC('e', S(1)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*acos(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons5, cons1737, cons87, cons88, cons54) def replacement5088(p, b, d, a, n, c, x, e): rubi.append(5088) return -Dist(b*d**IntPart(p)*n*(d + e*x**S(2))**FracPart(p)*(-c**S(2)*x**S(2) + S(1))**(-FracPart(p))/(S(2)*c*(p + S(1))), Int((a + b*acos(c*x))**(n + S(-1))*(-c**S(2)*x**S(2) + S(1))**(p + S(1)/2), x), x) + Simp((a + b*acos(c*x))**n*(d + e*x**S(2))**(p + S(1))/(S(2)*e*(p + S(1))), x) rule5088 = ReplacementRule(pattern5088, replacement5088) pattern5089 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*asin(x_*WC('c', S(1))))**WC('n', S(1))/(x_*(d_ + x_**S(2)*WC('e', S(1)))), x_), cons2, cons3, cons7, cons27, cons48, cons1737, cons148) def replacement5089(b, d, a, n, c, x, e): rubi.append(5089) return Dist(S(1)/d, Subst(Int((a + b*x)**n/(sin(x)*cos(x)), x), x, asin(c*x)), x) rule5089 = ReplacementRule(pattern5089, replacement5089) pattern5090 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*acos(x_*WC('c', S(1))))**WC('n', S(1))/(x_*(d_ + x_**S(2)*WC('e', S(1)))), x_), cons2, cons3, cons7, cons27, cons48, cons1737, cons148) def replacement5090(b, d, a, n, c, x, e): rubi.append(5090) return -Dist(S(1)/d, Subst(Int((a + b*x)**n/(sin(x)*cos(x)), x), x, acos(c*x)), x) rule5090 = ReplacementRule(pattern5090, replacement5090) pattern5091 = Pattern(Integral((x_*WC('f', S(1)))**m_*(d_ + x_**S(2)*WC('e', S(1)))**p_*(WC('a', S(0)) + WC('b', S(1))*asin(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons5, cons1737, cons87, cons88, cons242, cons66) def replacement5091(p, m, f, b, d, a, n, c, x, e): rubi.append(5091) return -Dist(b*c*d**IntPart(p)*n*(d + e*x**S(2))**FracPart(p)*(-c**S(2)*x**S(2) + S(1))**(-FracPart(p))/(f*(m + S(1))), Int((f*x)**(m + S(1))*(a + b*asin(c*x))**(n + S(-1))*(-c**S(2)*x**S(2) + S(1))**(p + S(1)/2), x), x) + Simp((f*x)**(m + S(1))*(a + b*asin(c*x))**n*(d + e*x**S(2))**(p + S(1))/(d*f*(m + S(1))), x) rule5091 = ReplacementRule(pattern5091, replacement5091) pattern5092 = Pattern(Integral((x_*WC('f', S(1)))**m_*(d_ + x_**S(2)*WC('e', S(1)))**p_*(WC('a', S(0)) + WC('b', S(1))*acos(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons5, cons1737, cons87, cons88, cons242, cons66) def replacement5092(p, m, f, b, d, a, n, c, x, e): rubi.append(5092) return Dist(b*c*d**IntPart(p)*n*(d + e*x**S(2))**FracPart(p)*(-c**S(2)*x**S(2) + S(1))**(-FracPart(p))/(f*(m + S(1))), Int((f*x)**(m + S(1))*(a + b*acos(c*x))**(n + S(-1))*(-c**S(2)*x**S(2) + S(1))**(p + S(1)/2), x), x) + Simp((f*x)**(m + S(1))*(a + b*acos(c*x))**n*(d + e*x**S(2))**(p + S(1))/(d*f*(m + S(1))), x) rule5092 = ReplacementRule(pattern5092, replacement5092) pattern5093 = Pattern(Integral((d_ + x_**S(2)*WC('e', S(1)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*asin(x_*WC('c', S(1))))/x_, x_), cons2, cons3, cons7, cons27, cons48, cons1737, cons128) def replacement5093(p, b, d, a, c, x, e): rubi.append(5093) return Dist(d, Int((a + b*asin(c*x))*(d + e*x**S(2))**(p + S(-1))/x, x), x) - Dist(b*c*d**p/(S(2)*p), Int((-c**S(2)*x**S(2) + S(1))**(p + S(-1)/2), x), x) + Simp((a + b*asin(c*x))*(d + e*x**S(2))**p/(S(2)*p), x) rule5093 = ReplacementRule(pattern5093, replacement5093) pattern5094 = Pattern(Integral((d_ + x_**S(2)*WC('e', S(1)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*acos(x_*WC('c', S(1))))/x_, x_), cons2, cons3, cons7, cons27, cons48, cons1737, cons128) def replacement5094(p, b, d, a, c, x, e): rubi.append(5094) return Dist(d, Int((a + b*acos(c*x))*(d + e*x**S(2))**(p + S(-1))/x, x), x) + Dist(b*c*d**p/(S(2)*p), Int((-c**S(2)*x**S(2) + S(1))**(p + S(-1)/2), x), x) + Simp((a + b*acos(c*x))*(d + e*x**S(2))**p/(S(2)*p), x) rule5094 = ReplacementRule(pattern5094, replacement5094) pattern5095 = Pattern(Integral((x_*WC('f', S(1)))**m_*(d_ + x_**S(2)*WC('e', S(1)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*asin(x_*WC('c', S(1)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons1737, cons128, cons1746) def replacement5095(p, m, f, b, d, a, c, x, e): rubi.append(5095) return -Dist(S(2)*e*p/(f**S(2)*(m + S(1))), Int((f*x)**(m + S(2))*(a + b*asin(c*x))*(d + e*x**S(2))**(p + S(-1)), x), x) - Dist(b*c*d**p/(f*(m + S(1))), Int((f*x)**(m + S(1))*(-c**S(2)*x**S(2) + S(1))**(p + S(-1)/2), x), x) + Simp((f*x)**(m + S(1))*(a + b*asin(c*x))*(d + e*x**S(2))**p/(f*(m + S(1))), x) rule5095 = ReplacementRule(pattern5095, replacement5095) pattern5096 = Pattern(Integral((x_*WC('f', S(1)))**m_*(d_ + x_**S(2)*WC('e', S(1)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*acos(x_*WC('c', S(1)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons1737, cons128, cons1746) def replacement5096(p, m, f, b, d, a, c, x, e): rubi.append(5096) return -Dist(S(2)*e*p/(f**S(2)*(m + S(1))), Int((f*x)**(m + S(2))*(a + b*acos(c*x))*(d + e*x**S(2))**(p + S(-1)), x), x) + Dist(b*c*d**p/(f*(m + S(1))), Int((f*x)**(m + S(1))*(-c**S(2)*x**S(2) + S(1))**(p + S(-1)/2), x), x) + Simp((f*x)**(m + S(1))*(a + b*acos(c*x))*(d + e*x**S(2))**p/(f*(m + S(1))), x) rule5096 = ReplacementRule(pattern5096, replacement5096) def With5097(p, m, f, b, d, a, c, x, e): u = IntHide((f*x)**m*(d + e*x**S(2))**p, x) rubi.append(5097) return -Dist(b*c, Int(SimplifyIntegrand(u/sqrt(-c**S(2)*x**S(2) + S(1)), x), x), x) + Dist(a + b*asin(c*x), u, x) pattern5097 = Pattern(Integral((x_*WC('f', S(1)))**m_*(d_ + x_**S(2)*WC('e', S(1)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*asin(x_*WC('c', S(1)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons1737, cons128) rule5097 = ReplacementRule(pattern5097, With5097) def With5098(p, m, f, b, d, a, c, x, e): u = IntHide((f*x)**m*(d + e*x**S(2))**p, x) rubi.append(5098) return Dist(b*c, Int(SimplifyIntegrand(u/sqrt(-c**S(2)*x**S(2) + S(1)), x), x), x) + Dist(a + b*acos(c*x), u, x) pattern5098 = Pattern(Integral((x_*WC('f', S(1)))**m_*(d_ + x_**S(2)*WC('e', S(1)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*acos(x_*WC('c', S(1)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons1737, cons128) rule5098 = ReplacementRule(pattern5098, With5098) def With5099(p, m, b, d, a, c, x, e): u = IntHide(x**m*(-c**S(2)*x**S(2) + S(1))**p, x) rubi.append(5099) return Dist(d**p*(a + b*asin(c*x)), u, x) - Dist(b*c*d**p, Int(SimplifyIntegrand(u/sqrt(-c**S(2)*x**S(2) + S(1)), x), x), x) pattern5099 = Pattern(Integral(x_**m_*(d_ + x_**S(2)*WC('e', S(1)))**p_*(WC('a', S(0)) + WC('b', S(1))*asin(x_*WC('c', S(1)))), x_), cons2, cons3, cons7, cons27, cons48, cons1737, cons347, cons1747, cons486, cons268) rule5099 = ReplacementRule(pattern5099, With5099) def With5100(p, m, b, d, a, c, x, e): u = IntHide(x**m*(-c**S(2)*x**S(2) + S(1))**p, x) rubi.append(5100) return Dist(d**p*(a + b*acos(c*x)), u, x) + Dist(b*c*d**p, Int(SimplifyIntegrand(u/sqrt(-c**S(2)*x**S(2) + S(1)), x), x), x) pattern5100 = Pattern(Integral(x_**m_*(d_ + x_**S(2)*WC('e', S(1)))**p_*(WC('a', S(0)) + WC('b', S(1))*acos(x_*WC('c', S(1)))), x_), cons2, cons3, cons7, cons27, cons48, cons1737, cons347, cons1747, cons486, cons268) rule5100 = ReplacementRule(pattern5100, With5100) def With5101(p, m, b, d, a, c, x, e): u = IntHide(x**m*(-c**S(2)*x**S(2) + S(1))**p, x) rubi.append(5101) return -Dist(b*c*d**(p + S(-1)/2)*sqrt(d + e*x**S(2))/sqrt(-c**S(2)*x**S(2) + S(1)), Int(SimplifyIntegrand(u/sqrt(-c**S(2)*x**S(2) + S(1)), x), x), x) + Dist(a + b*asin(c*x), Int(x**m*(d + e*x**S(2))**p, x), x) pattern5101 = Pattern(Integral(x_**m_*(d_ + x_**S(2)*WC('e', S(1)))**p_*(WC('a', S(0)) + WC('b', S(1))*asin(x_*WC('c', S(1)))), x_), cons2, cons3, cons7, cons27, cons48, cons1737, cons961, cons1747) rule5101 = ReplacementRule(pattern5101, With5101) def With5102(p, m, b, d, a, c, x, e): u = IntHide(x**m*(-c**S(2)*x**S(2) + S(1))**p, x) rubi.append(5102) return Dist(b*c*d**(p + S(-1)/2)*sqrt(d + e*x**S(2))/sqrt(-c**S(2)*x**S(2) + S(1)), Int(SimplifyIntegrand(u/sqrt(-c**S(2)*x**S(2) + S(1)), x), x), x) + Dist(a + b*acos(c*x), Int(x**m*(d + e*x**S(2))**p, x), x) pattern5102 = Pattern(Integral(x_**m_*(d_ + x_**S(2)*WC('e', S(1)))**p_*(WC('a', S(0)) + WC('b', S(1))*acos(x_*WC('c', S(1)))), x_), cons2, cons3, cons7, cons27, cons48, cons1737, cons961, cons1747) rule5102 = ReplacementRule(pattern5102, With5102) pattern5103 = Pattern(Integral((x_*WC('f', S(1)))**m_*sqrt(d_ + x_**S(2)*WC('e', S(1)))*(WC('a', S(0)) + WC('b', S(1))*asin(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons1737, cons93, cons88, cons94) def replacement5103(m, f, b, d, a, n, c, x, e): rubi.append(5103) return Dist(c**S(2)*sqrt(d + e*x**S(2))/(f**S(2)*(m + S(1))*sqrt(-c**S(2)*x**S(2) + S(1))), Int((f*x)**(m + S(2))*(a + b*asin(c*x))**n/sqrt(-c**S(2)*x**S(2) + S(1)), x), x) - Dist(b*c*n*sqrt(d + e*x**S(2))/(f*(m + S(1))*sqrt(-c**S(2)*x**S(2) + S(1))), Int((f*x)**(m + S(1))*(a + b*asin(c*x))**(n + S(-1)), x), x) + Simp((f*x)**(m + S(1))*(a + b*asin(c*x))**n*sqrt(d + e*x**S(2))/(f*(m + S(1))), x) rule5103 = ReplacementRule(pattern5103, replacement5103) pattern5104 = Pattern(Integral((x_*WC('f', S(1)))**m_*sqrt(d_ + x_**S(2)*WC('e', S(1)))*(WC('a', S(0)) + WC('b', S(1))*acos(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons1737, cons93, cons88, cons94) def replacement5104(m, f, b, d, a, n, c, x, e): rubi.append(5104) return Dist(c**S(2)*sqrt(d + e*x**S(2))/(f**S(2)*(m + S(1))*sqrt(-c**S(2)*x**S(2) + S(1))), Int((f*x)**(m + S(2))*(a + b*acos(c*x))**n/sqrt(-c**S(2)*x**S(2) + S(1)), x), x) + Dist(b*c*n*sqrt(d + e*x**S(2))/(f*(m + S(1))*sqrt(-c**S(2)*x**S(2) + S(1))), Int((f*x)**(m + S(1))*(a + b*acos(c*x))**(n + S(-1)), x), x) + Simp((f*x)**(m + S(1))*(a + b*acos(c*x))**n*sqrt(d + e*x**S(2))/(f*(m + S(1))), x) rule5104 = ReplacementRule(pattern5104, replacement5104) pattern5105 = Pattern(Integral((x_*WC('f', S(1)))**m_*(d_ + x_**S(2)*WC('e', S(1)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*asin(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons1737, cons162, cons88, cons163, cons94) def replacement5105(p, m, f, b, d, a, n, c, x, e): rubi.append(5105) return -Dist(S(2)*e*p/(f**S(2)*(m + S(1))), Int((f*x)**(m + S(2))*(a + b*asin(c*x))**n*(d + e*x**S(2))**(p + S(-1)), x), x) - Dist(b*c*d**IntPart(p)*n*(d + e*x**S(2))**FracPart(p)*(-c**S(2)*x**S(2) + S(1))**(-FracPart(p))/(f*(m + S(1))), Int((f*x)**(m + S(1))*(a + b*asin(c*x))**(n + S(-1))*(-c**S(2)*x**S(2) + S(1))**(p + S(-1)/2), x), x) + Simp((f*x)**(m + S(1))*(a + b*asin(c*x))**n*(d + e*x**S(2))**p/(f*(m + S(1))), x) rule5105 = ReplacementRule(pattern5105, replacement5105) pattern5106 = Pattern(Integral((x_*WC('f', S(1)))**m_*(d_ + x_**S(2)*WC('e', S(1)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*acos(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons1737, cons162, cons88, cons163, cons94) def replacement5106(p, m, f, b, d, a, n, c, x, e): rubi.append(5106) return -Dist(S(2)*e*p/(f**S(2)*(m + S(1))), Int((f*x)**(m + S(2))*(a + b*acos(c*x))**n*(d + e*x**S(2))**(p + S(-1)), x), x) + Dist(b*c*d**IntPart(p)*n*(d + e*x**S(2))**FracPart(p)*(-c**S(2)*x**S(2) + S(1))**(-FracPart(p))/(f*(m + S(1))), Int((f*x)**(m + S(1))*(a + b*acos(c*x))**(n + S(-1))*(-c**S(2)*x**S(2) + S(1))**(p + S(-1)/2), x), x) + Simp((f*x)**(m + S(1))*(a + b*acos(c*x))**n*(d + e*x**S(2))**p/(f*(m + S(1))), x) rule5106 = ReplacementRule(pattern5106, replacement5106) pattern5107 = Pattern(Integral((x_*WC('f', S(1)))**m_*sqrt(d_ + x_**S(2)*WC('e', S(1)))*(WC('a', S(0)) + WC('b', S(1))*asin(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons1737, cons87, cons88, cons272, cons1748) def replacement5107(m, f, b, d, a, n, c, x, e): rubi.append(5107) return Dist(sqrt(d + e*x**S(2))/((m + S(2))*sqrt(-c**S(2)*x**S(2) + S(1))), Int((f*x)**m*(a + b*asin(c*x))**n/sqrt(-c**S(2)*x**S(2) + S(1)), x), x) - Dist(b*c*n*sqrt(d + e*x**S(2))/(f*(m + S(2))*sqrt(-c**S(2)*x**S(2) + S(1))), Int((f*x)**(m + S(1))*(a + b*asin(c*x))**(n + S(-1)), x), x) + Simp((f*x)**(m + S(1))*(a + b*asin(c*x))**n*sqrt(d + e*x**S(2))/(f*(m + S(2))), x) rule5107 = ReplacementRule(pattern5107, replacement5107) pattern5108 = Pattern(Integral((x_*WC('f', S(1)))**m_*sqrt(d_ + x_**S(2)*WC('e', S(1)))*(WC('a', S(0)) + WC('b', S(1))*acos(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons1737, cons87, cons88, cons272, cons1748) def replacement5108(m, f, b, d, a, n, c, x, e): rubi.append(5108) return Dist(sqrt(d + e*x**S(2))/((m + S(2))*sqrt(-c**S(2)*x**S(2) + S(1))), Int((f*x)**m*(a + b*acos(c*x))**n/sqrt(-c**S(2)*x**S(2) + S(1)), x), x) + Dist(b*c*n*sqrt(d + e*x**S(2))/(f*(m + S(2))*sqrt(-c**S(2)*x**S(2) + S(1))), Int((f*x)**(m + S(1))*(a + b*acos(c*x))**(n + S(-1)), x), x) + Simp((f*x)**(m + S(1))*(a + b*acos(c*x))**n*sqrt(d + e*x**S(2))/(f*(m + S(2))), x) rule5108 = ReplacementRule(pattern5108, replacement5108) pattern5109 = Pattern(Integral((x_*WC('f', S(1)))**m_*(d_ + x_**S(2)*WC('e', S(1)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*asin(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons1737, cons338, cons88, cons163, cons272, cons1748) def replacement5109(p, m, f, b, d, a, n, c, x, e): rubi.append(5109) return Dist(S(2)*d*p/(m + S(2)*p + S(1)), Int((f*x)**m*(a + b*asin(c*x))**n*(d + e*x**S(2))**(p + S(-1)), x), x) - Dist(b*c*d**IntPart(p)*n*(d + e*x**S(2))**FracPart(p)*(-c**S(2)*x**S(2) + S(1))**(-FracPart(p))/(f*(m + S(2)*p + S(1))), Int((f*x)**(m + S(1))*(a + b*asin(c*x))**(n + S(-1))*(-c**S(2)*x**S(2) + S(1))**(p + S(-1)/2), x), x) + Simp((f*x)**(m + S(1))*(a + b*asin(c*x))**n*(d + e*x**S(2))**p/(f*(m + S(2)*p + S(1))), x) rule5109 = ReplacementRule(pattern5109, replacement5109) pattern5110 = Pattern(Integral((x_*WC('f', S(1)))**m_*(d_ + x_**S(2)*WC('e', S(1)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*acos(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons1737, cons338, cons88, cons163, cons272, cons1748) def replacement5110(p, m, f, b, d, a, n, c, x, e): rubi.append(5110) return Dist(S(2)*d*p/(m + S(2)*p + S(1)), Int((f*x)**m*(a + b*acos(c*x))**n*(d + e*x**S(2))**(p + S(-1)), x), x) + Dist(b*c*d**IntPart(p)*n*(d + e*x**S(2))**FracPart(p)*(-c**S(2)*x**S(2) + S(1))**(-FracPart(p))/(f*(m + S(2)*p + S(1))), Int((f*x)**(m + S(1))*(a + b*acos(c*x))**(n + S(-1))*(-c**S(2)*x**S(2) + S(1))**(p + S(-1)/2), x), x) + Simp((f*x)**(m + S(1))*(a + b*acos(c*x))**n*(d + e*x**S(2))**p/(f*(m + S(2)*p + S(1))), x) rule5110 = ReplacementRule(pattern5110, replacement5110) pattern5111 = Pattern(Integral((x_*WC('f', S(1)))**m_*(d_ + x_**S(2)*WC('e', S(1)))**p_*(WC('a', S(0)) + WC('b', S(1))*asin(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons5, cons1737, cons93, cons88, cons94, cons17) def replacement5111(p, m, f, b, d, a, n, c, x, e): rubi.append(5111) return Dist(c**S(2)*(m + S(2)*p + S(3))/(f**S(2)*(m + S(1))), Int((f*x)**(m + S(2))*(a + b*asin(c*x))**n*(d + e*x**S(2))**p, x), x) - Dist(b*c*d**IntPart(p)*n*(d + e*x**S(2))**FracPart(p)*(-c**S(2)*x**S(2) + S(1))**(-FracPart(p))/(f*(m + S(1))), Int((f*x)**(m + S(1))*(a + b*asin(c*x))**(n + S(-1))*(-c**S(2)*x**S(2) + S(1))**(p + S(1)/2), x), x) + Simp((f*x)**(m + S(1))*(a + b*asin(c*x))**n*(d + e*x**S(2))**(p + S(1))/(d*f*(m + S(1))), x) rule5111 = ReplacementRule(pattern5111, replacement5111) pattern5112 = Pattern(Integral((x_*WC('f', S(1)))**m_*(d_ + x_**S(2)*WC('e', S(1)))**p_*(WC('a', S(0)) + WC('b', S(1))*acos(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons5, cons1737, cons93, cons88, cons94, cons17) def replacement5112(p, m, f, b, d, a, n, c, x, e): rubi.append(5112) return Dist(c**S(2)*(m + S(2)*p + S(3))/(f**S(2)*(m + S(1))), Int((f*x)**(m + S(2))*(a + b*acos(c*x))**n*(d + e*x**S(2))**p, x), x) + Dist(b*c*d**IntPart(p)*n*(d + e*x**S(2))**FracPart(p)*(-c**S(2)*x**S(2) + S(1))**(-FracPart(p))/(f*(m + S(1))), Int((f*x)**(m + S(1))*(a + b*acos(c*x))**(n + S(-1))*(-c**S(2)*x**S(2) + S(1))**(p + S(1)/2), x), x) + Simp((f*x)**(m + S(1))*(a + b*acos(c*x))**n*(d + e*x**S(2))**(p + S(1))/(d*f*(m + S(1))), x) rule5112 = ReplacementRule(pattern5112, replacement5112) pattern5113 = Pattern(Integral((x_*WC('f', S(1)))**m_*(d_ + x_**S(2)*WC('e', S(1)))**p_*(WC('a', S(0)) + WC('b', S(1))*asin(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons1737, cons162, cons88, cons137, cons166) def replacement5113(p, m, f, b, d, a, n, c, x, e): rubi.append(5113) return -Dist(f**S(2)*(m + S(-1))/(S(2)*e*(p + S(1))), Int((f*x)**(m + S(-2))*(a + b*asin(c*x))**n*(d + e*x**S(2))**(p + S(1)), x), x) + Dist(b*d**IntPart(p)*f*n*(d + e*x**S(2))**FracPart(p)*(-c**S(2)*x**S(2) + S(1))**(-FracPart(p))/(S(2)*c*(p + S(1))), Int((f*x)**(m + S(-1))*(a + b*asin(c*x))**(n + S(-1))*(-c**S(2)*x**S(2) + S(1))**(p + S(1)/2), x), x) + Simp(f*(f*x)**(m + S(-1))*(a + b*asin(c*x))**n*(d + e*x**S(2))**(p + S(1))/(S(2)*e*(p + S(1))), x) rule5113 = ReplacementRule(pattern5113, replacement5113) pattern5114 = Pattern(Integral((x_*WC('f', S(1)))**m_*(d_ + x_**S(2)*WC('e', S(1)))**p_*(WC('a', S(0)) + WC('b', S(1))*acos(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons1737, cons162, cons88, cons137, cons166) def replacement5114(p, m, f, b, d, a, n, c, x, e): rubi.append(5114) return -Dist(f**S(2)*(m + S(-1))/(S(2)*e*(p + S(1))), Int((f*x)**(m + S(-2))*(a + b*acos(c*x))**n*(d + e*x**S(2))**(p + S(1)), x), x) - Dist(b*d**IntPart(p)*f*n*(d + e*x**S(2))**FracPart(p)*(-c**S(2)*x**S(2) + S(1))**(-FracPart(p))/(S(2)*c*(p + S(1))), Int((f*x)**(m + S(-1))*(a + b*acos(c*x))**(n + S(-1))*(-c**S(2)*x**S(2) + S(1))**(p + S(1)/2), x), x) + Simp(f*(f*x)**(m + S(-1))*(a + b*acos(c*x))**n*(d + e*x**S(2))**(p + S(1))/(S(2)*e*(p + S(1))), x) rule5114 = ReplacementRule(pattern5114, replacement5114) pattern5115 = Pattern(Integral((x_*WC('f', S(1)))**m_*(d_ + x_**S(2)*WC('e', S(1)))**p_*(WC('a', S(0)) + WC('b', S(1))*asin(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons1737, cons338, cons88, cons137, cons274, cons1749) def replacement5115(p, m, f, b, d, a, n, c, x, e): rubi.append(5115) return Dist((m + S(2)*p + S(3))/(S(2)*d*(p + S(1))), Int((f*x)**m*(a + b*asin(c*x))**n*(d + e*x**S(2))**(p + S(1)), x), x) + Dist(b*c*d**IntPart(p)*n*(d + e*x**S(2))**FracPart(p)*(-c**S(2)*x**S(2) + S(1))**(-FracPart(p))/(S(2)*f*(p + S(1))), Int((f*x)**(m + S(1))*(a + b*asin(c*x))**(n + S(-1))*(-c**S(2)*x**S(2) + S(1))**(p + S(1)/2), x), x) - Simp((f*x)**(m + S(1))*(a + b*asin(c*x))**n*(d + e*x**S(2))**(p + S(1))/(S(2)*d*f*(p + S(1))), x) rule5115 = ReplacementRule(pattern5115, replacement5115) pattern5116 = Pattern(Integral((x_*WC('f', S(1)))**m_*(d_ + x_**S(2)*WC('e', S(1)))**p_*(WC('a', S(0)) + WC('b', S(1))*acos(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons1737, cons338, cons88, cons137, cons274, cons1749) def replacement5116(p, m, f, b, d, a, n, c, x, e): rubi.append(5116) return Dist((m + S(2)*p + S(3))/(S(2)*d*(p + S(1))), Int((f*x)**m*(a + b*acos(c*x))**n*(d + e*x**S(2))**(p + S(1)), x), x) - Dist(b*c*d**IntPart(p)*n*(d + e*x**S(2))**FracPart(p)*(-c**S(2)*x**S(2) + S(1))**(-FracPart(p))/(S(2)*f*(p + S(1))), Int((f*x)**(m + S(1))*(a + b*acos(c*x))**(n + S(-1))*(-c**S(2)*x**S(2) + S(1))**(p + S(1)/2), x), x) - Simp((f*x)**(m + S(1))*(a + b*acos(c*x))**n*(d + e*x**S(2))**(p + S(1))/(S(2)*d*f*(p + S(1))), x) rule5116 = ReplacementRule(pattern5116, replacement5116) pattern5117 = Pattern(Integral((x_*WC('f', S(1)))**m_*(WC('a', S(0)) + WC('b', S(1))*asin(x_*WC('c', S(1))))**WC('n', S(1))/sqrt(d_ + x_**S(2)*WC('e', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons1737, cons93, cons88, cons166, cons17) def replacement5117(m, f, b, d, a, n, c, x, e): rubi.append(5117) return Dist(f**S(2)*(m + S(-1))/(c**S(2)*m), Int((f*x)**(m + S(-2))*(a + b*asin(c*x))**n/sqrt(d + e*x**S(2)), x), x) + Dist(b*f*n*sqrt(-c**S(2)*x**S(2) + S(1))/(c*m*sqrt(d + e*x**S(2))), Int((f*x)**(m + S(-1))*(a + b*asin(c*x))**(n + S(-1)), x), x) + Simp(f*(f*x)**(m + S(-1))*(a + b*asin(c*x))**n*sqrt(d + e*x**S(2))/(e*m), x) rule5117 = ReplacementRule(pattern5117, replacement5117) pattern5118 = Pattern(Integral((x_*WC('f', S(1)))**m_*(WC('a', S(0)) + WC('b', S(1))*acos(x_*WC('c', S(1))))**WC('n', S(1))/sqrt(d_ + x_**S(2)*WC('e', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons1737, cons93, cons88, cons166, cons17) def replacement5118(m, f, b, d, a, n, c, x, e): rubi.append(5118) return Dist(f**S(2)*(m + S(-1))/(c**S(2)*m), Int((f*x)**(m + S(-2))*(a + b*acos(c*x))**n/sqrt(d + e*x**S(2)), x), x) - Dist(b*f*n*sqrt(-c**S(2)*x**S(2) + S(1))/(c*m*sqrt(d + e*x**S(2))), Int((f*x)**(m + S(-1))*(a + b*acos(c*x))**(n + S(-1)), x), x) + Simp(f*(f*x)**(m + S(-1))*(a + b*acos(c*x))**n*sqrt(d + e*x**S(2))/(e*m), x) rule5118 = ReplacementRule(pattern5118, replacement5118) pattern5119 = Pattern(Integral(x_**m_*(WC('a', S(0)) + WC('b', S(1))*asin(x_*WC('c', S(1))))**WC('n', S(1))/sqrt(d_ + x_**S(2)*WC('e', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons1737, cons268, cons148, cons17) def replacement5119(m, b, d, a, n, c, x, e): rubi.append(5119) return Dist(c**(-m + S(-1))/sqrt(d), Subst(Int((a + b*x)**n*sin(x)**m, x), x, asin(c*x)), x) rule5119 = ReplacementRule(pattern5119, replacement5119) pattern5120 = Pattern(Integral(x_**m_*(WC('a', S(0)) + WC('b', S(1))*acos(x_*WC('c', S(1))))**WC('n', S(1))/sqrt(d_ + x_**S(2)*WC('e', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons1737, cons268, cons148, cons17) def replacement5120(m, b, d, a, n, c, x, e): rubi.append(5120) return -Dist(c**(-m + S(-1))/sqrt(d), Subst(Int((a + b*x)**n*cos(x)**m, x), x, acos(c*x)), x) rule5120 = ReplacementRule(pattern5120, replacement5120) pattern5121 = Pattern(Integral((x_*WC('f', S(1)))**m_*(WC('a', S(0)) + WC('b', S(1))*asin(x_*WC('c', S(1))))/sqrt(d_ + x_**S(2)*WC('e', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons1737, cons268, cons18) def replacement5121(m, f, b, d, a, c, x, e): rubi.append(5121) return Simp((f*x)**(m + S(1))*(a + b*asin(c*x))*Hypergeometric2F1(S(1)/2, m/S(2) + S(1)/2, m/S(2) + S(3)/2, c**S(2)*x**S(2))/(sqrt(d)*f*(m + S(1))), x) - Simp(b*c*(f*x)**(m + S(2))*HypergeometricPFQ(List(S(1), m/S(2) + S(1), m/S(2) + S(1)), List(m/S(2) + S(3)/2, m/S(2) + S(2)), c**S(2)*x**S(2))/(sqrt(d)*f**S(2)*(m + S(1))*(m + S(2))), x) rule5121 = ReplacementRule(pattern5121, replacement5121) pattern5122 = Pattern(Integral((x_*WC('f', S(1)))**m_*(WC('a', S(0)) + WC('b', S(1))*acos(x_*WC('c', S(1))))/sqrt(d_ + x_**S(2)*WC('e', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons1737, cons268, cons18) def replacement5122(m, f, b, d, a, c, x, e): rubi.append(5122) return Simp((f*x)**(m + S(1))*(a + b*acos(c*x))*Hypergeometric2F1(S(1)/2, m/S(2) + S(1)/2, m/S(2) + S(3)/2, c**S(2)*x**S(2))/(sqrt(d)*f*(m + S(1))), x) + Simp(b*c*(f*x)**(m + S(2))*HypergeometricPFQ(List(S(1), m/S(2) + S(1), m/S(2) + S(1)), List(m/S(2) + S(3)/2, m/S(2) + S(2)), c**S(2)*x**S(2))/(sqrt(d)*f**S(2)*(m + S(1))*(m + S(2))), x) rule5122 = ReplacementRule(pattern5122, replacement5122) pattern5123 = Pattern(Integral((x_*WC('f', S(1)))**m_*(WC('a', S(0)) + WC('b', S(1))*asin(x_*WC('c', S(1))))**WC('n', S(1))/sqrt(d_ + x_**S(2)*WC('e', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons1737, cons87, cons88, cons1738, cons1750) def replacement5123(m, f, b, d, a, n, c, x, e): rubi.append(5123) return Dist(sqrt(-c**S(2)*x**S(2) + S(1))/sqrt(d + e*x**S(2)), Int((f*x)**m*(a + b*asin(c*x))**n/sqrt(-c**S(2)*x**S(2) + S(1)), x), x) rule5123 = ReplacementRule(pattern5123, replacement5123) pattern5124 = Pattern(Integral((x_*WC('f', S(1)))**m_*(WC('a', S(0)) + WC('b', S(1))*acos(x_*WC('c', S(1))))**WC('n', S(1))/sqrt(d_ + x_**S(2)*WC('e', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons1737, cons87, cons88, cons1738, cons1750) def replacement5124(m, f, b, d, a, n, c, x, e): rubi.append(5124) return Dist(sqrt(-c**S(2)*x**S(2) + S(1))/sqrt(d + e*x**S(2)), Int((f*x)**m*(a + b*acos(c*x))**n/sqrt(-c**S(2)*x**S(2) + S(1)), x), x) rule5124 = ReplacementRule(pattern5124, replacement5124) pattern5125 = Pattern(Integral((x_*WC('f', S(1)))**m_*(d_ + x_**S(2)*WC('e', S(1)))**p_*(WC('a', S(0)) + WC('b', S(1))*asin(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons5, cons1737, cons93, cons88, cons166, cons238, cons17) def replacement5125(p, m, f, b, d, a, n, c, x, e): rubi.append(5125) return Dist(f**S(2)*(m + S(-1))/(c**S(2)*(m + S(2)*p + S(1))), Int((f*x)**(m + S(-2))*(a + b*asin(c*x))**n*(d + e*x**S(2))**p, x), x) + Dist(b*d**IntPart(p)*f*n*(d + e*x**S(2))**FracPart(p)*(-c**S(2)*x**S(2) + S(1))**(-FracPart(p))/(c*(m + S(2)*p + S(1))), Int((f*x)**(m + S(-1))*(a + b*asin(c*x))**(n + S(-1))*(-c**S(2)*x**S(2) + S(1))**(p + S(1)/2), x), x) + Simp(f*(f*x)**(m + S(-1))*(a + b*asin(c*x))**n*(d + e*x**S(2))**(p + S(1))/(e*(m + S(2)*p + S(1))), x) rule5125 = ReplacementRule(pattern5125, replacement5125) pattern5126 = Pattern(Integral((x_*WC('f', S(1)))**m_*(d_ + x_**S(2)*WC('e', S(1)))**p_*(WC('a', S(0)) + WC('b', S(1))*acos(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons5, cons1737, cons93, cons88, cons166, cons238, cons17) def replacement5126(p, m, f, b, d, a, n, c, x, e): rubi.append(5126) return Dist(f**S(2)*(m + S(-1))/(c**S(2)*(m + S(2)*p + S(1))), Int((f*x)**(m + S(-2))*(a + b*acos(c*x))**n*(d + e*x**S(2))**p, x), x) - Dist(b*d**IntPart(p)*f*n*(d + e*x**S(2))**FracPart(p)*(-c**S(2)*x**S(2) + S(1))**(-FracPart(p))/(c*(m + S(2)*p + S(1))), Int((f*x)**(m + S(-1))*(a + b*acos(c*x))**(n + S(-1))*(-c**S(2)*x**S(2) + S(1))**(p + S(1)/2), x), x) + Simp(f*(f*x)**(m + S(-1))*(a + b*acos(c*x))**n*(d + e*x**S(2))**(p + S(1))/(e*(m + S(2)*p + S(1))), x) rule5126 = ReplacementRule(pattern5126, replacement5126) pattern5127 = Pattern(Integral((x_*WC('f', S(1)))**WC('m', S(1))*(d_ + x_**S(2)*WC('e', S(1)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*asin(x_*WC('c', S(1))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons5, cons1737, cons87, cons89, cons237) def replacement5127(p, m, f, b, d, a, c, n, x, e): rubi.append(5127) return -Dist(d**IntPart(p)*f*m*(d + e*x**S(2))**FracPart(p)*(-c**S(2)*x**S(2) + S(1))**(-FracPart(p))/(b*c*(n + S(1))), Int((f*x)**(m + S(-1))*(a + b*asin(c*x))**(n + S(1))*(-c**S(2)*x**S(2) + S(1))**(p + S(-1)/2), x), x) + Simp((f*x)**m*(a + b*asin(c*x))**(n + S(1))*(d + e*x**S(2))**p*sqrt(-c**S(2)*x**S(2) + S(1))/(b*c*(n + S(1))), x) rule5127 = ReplacementRule(pattern5127, replacement5127) pattern5128 = Pattern(Integral((x_*WC('f', S(1)))**WC('m', S(1))*(d_ + x_**S(2)*WC('e', S(1)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*acos(x_*WC('c', S(1))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons5, cons1737, cons87, cons89, cons237) def replacement5128(p, m, f, b, d, a, c, n, x, e): rubi.append(5128) return Dist(d**IntPart(p)*f*m*(d + e*x**S(2))**FracPart(p)*(-c**S(2)*x**S(2) + S(1))**(-FracPart(p))/(b*c*(n + S(1))), Int((f*x)**(m + S(-1))*(a + b*acos(c*x))**(n + S(1))*(-c**S(2)*x**S(2) + S(1))**(p + S(-1)/2), x), x) - Simp((f*x)**m*(a + b*acos(c*x))**(n + S(1))*(d + e*x**S(2))**p*sqrt(-c**S(2)*x**S(2) + S(1))/(b*c*(n + S(1))), x) rule5128 = ReplacementRule(pattern5128, replacement5128) pattern5129 = Pattern(Integral((x_*WC('f', S(1)))**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*asin(x_*WC('c', S(1))))**n_/sqrt(d_ + x_**S(2)*WC('e', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons1737, cons87, cons89, cons268) def replacement5129(m, f, b, d, a, c, n, x, e): rubi.append(5129) return -Dist(f*m/(b*c*sqrt(d)*(n + S(1))), Int((f*x)**(m + S(-1))*(a + b*asin(c*x))**(n + S(1)), x), x) + Simp((f*x)**m*(a + b*asin(c*x))**(n + S(1))/(b*c*sqrt(d)*(n + S(1))), x) rule5129 = ReplacementRule(pattern5129, replacement5129) pattern5130 = Pattern(Integral((x_*WC('f', S(1)))**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*acos(x_*WC('c', S(1))))**n_/sqrt(d_ + x_**S(2)*WC('e', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons1737, cons87, cons89, cons268) def replacement5130(m, f, b, d, a, c, n, x, e): rubi.append(5130) return Dist(f*m/(b*c*sqrt(d)*(n + S(1))), Int((f*x)**(m + S(-1))*(a + b*acos(c*x))**(n + S(1)), x), x) - Simp((f*x)**m*(a + b*acos(c*x))**(n + S(1))/(b*c*sqrt(d)*(n + S(1))), x) rule5130 = ReplacementRule(pattern5130, replacement5130) pattern5131 = Pattern(Integral((x_*WC('f', S(1)))**WC('m', S(1))*(d_ + x_**S(2)*WC('e', S(1)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*asin(x_*WC('c', S(1))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons1737, cons87, cons89, cons17, cons1751, cons1739) def replacement5131(p, m, f, b, d, a, c, n, x, e): rubi.append(5131) return -Dist(d**IntPart(p)*f*m*(d + e*x**S(2))**FracPart(p)*(-c**S(2)*x**S(2) + S(1))**(-FracPart(p))/(b*c*(n + S(1))), Int((f*x)**(m + S(-1))*(a + b*asin(c*x))**(n + S(1))*(-c**S(2)*x**S(2) + S(1))**(p + S(-1)/2), x), x) + Dist(c*d**IntPart(p)*(d + e*x**S(2))**FracPart(p)*(-c**S(2)*x**S(2) + S(1))**(-FracPart(p))*(m + S(2)*p + S(1))/(b*f*(n + S(1))), Int((f*x)**(m + S(1))*(a + b*asin(c*x))**(n + S(1))*(-c**S(2)*x**S(2) + S(1))**(p + S(-1)/2), x), x) + Simp((f*x)**m*(a + b*asin(c*x))**(n + S(1))*(d + e*x**S(2))**p*sqrt(-c**S(2)*x**S(2) + S(1))/(b*c*(n + S(1))), x) rule5131 = ReplacementRule(pattern5131, replacement5131) pattern5132 = Pattern(Integral((x_*WC('f', S(1)))**WC('m', S(1))*(d_ + x_**S(2)*WC('e', S(1)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*acos(x_*WC('c', S(1))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons1737, cons87, cons89, cons17, cons1751, cons1739) def replacement5132(p, m, f, b, d, a, c, n, x, e): rubi.append(5132) return Dist(d**IntPart(p)*f*m*(d + e*x**S(2))**FracPart(p)*(-c**S(2)*x**S(2) + S(1))**(-FracPart(p))/(b*c*(n + S(1))), Int((f*x)**(m + S(-1))*(a + b*acos(c*x))**(n + S(1))*(-c**S(2)*x**S(2) + S(1))**(p + S(-1)/2), x), x) - Dist(c*d**IntPart(p)*(d + e*x**S(2))**FracPart(p)*(-c**S(2)*x**S(2) + S(1))**(-FracPart(p))*(m + S(2)*p + S(1))/(b*f*(n + S(1))), Int((f*x)**(m + S(1))*(a + b*acos(c*x))**(n + S(1))*(-c**S(2)*x**S(2) + S(1))**(p + S(-1)/2), x), x) - Simp((f*x)**m*(a + b*acos(c*x))**(n + S(1))*(d + e*x**S(2))**p*sqrt(-c**S(2)*x**S(2) + S(1))/(b*c*(n + S(1))), x) rule5132 = ReplacementRule(pattern5132, replacement5132) pattern5133 = Pattern(Integral(x_**WC('m', S(1))*(d_ + x_**S(2)*WC('e', S(1)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*asin(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons4, cons1737, cons246, cons1752, cons62, cons1740) def replacement5133(p, m, b, d, a, n, c, x, e): rubi.append(5133) return Dist(c**(-m + S(-1))*d**p, Subst(Int((a + b*x)**n*sin(x)**m*cos(x)**(S(2)*p + S(1)), x), x, asin(c*x)), x) rule5133 = ReplacementRule(pattern5133, replacement5133) pattern5134 = Pattern(Integral(x_**WC('m', S(1))*(d_ + x_**S(2)*WC('e', S(1)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*acos(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons4, cons1737, cons246, cons1752, cons62, cons1740) def replacement5134(p, m, b, d, a, n, c, x, e): rubi.append(5134) return -Dist(c**(-m + S(-1))*d**p, Subst(Int((a + b*x)**n*sin(x)**(S(2)*p + S(1))*cos(x)**m, x), x, acos(c*x)), x) rule5134 = ReplacementRule(pattern5134, replacement5134) pattern5135 = Pattern(Integral(x_**WC('m', S(1))*(d_ + x_**S(2)*WC('e', S(1)))**p_*(WC('a', S(0)) + WC('b', S(1))*asin(x_*WC('c', S(1))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons4, cons1737, cons246, cons1752, cons62, cons1741) def replacement5135(p, m, b, d, a, c, n, x, e): rubi.append(5135) return Dist(d**IntPart(p)*(d + e*x**S(2))**FracPart(p)*(-c**S(2)*x**S(2) + S(1))**(-FracPart(p)), Int(x**m*(a + b*asin(c*x))**n*(-c**S(2)*x**S(2) + S(1))**p, x), x) rule5135 = ReplacementRule(pattern5135, replacement5135) pattern5136 = Pattern(Integral(x_**WC('m', S(1))*(d_ + x_**S(2)*WC('e', S(1)))**p_*(WC('a', S(0)) + WC('b', S(1))*acos(x_*WC('c', S(1))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons4, cons1737, cons246, cons1752, cons62, cons1741) def replacement5136(p, m, b, d, a, c, n, x, e): rubi.append(5136) return Dist(d**IntPart(p)*(d + e*x**S(2))**FracPart(p)*(-c**S(2)*x**S(2) + S(1))**(-FracPart(p)), Int(x**m*(a + b*acos(c*x))**n*(-c**S(2)*x**S(2) + S(1))**p, x), x) rule5136 = ReplacementRule(pattern5136, replacement5136) pattern5137 = Pattern(Integral((x_*WC('f', S(1)))**m_*(d_ + x_**S(2)*WC('e', S(1)))**p_*(WC('a', S(0)) + WC('b', S(1))*asin(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons4, cons1737, cons268, cons961, cons1753, cons17, cons1754) def replacement5137(p, m, f, b, d, a, n, c, x, e): rubi.append(5137) return Int(ExpandIntegrand((a + b*asin(c*x))**n/sqrt(d + e*x**S(2)), (f*x)**m*(d + e*x**S(2))**(p + S(1)/2), x), x) rule5137 = ReplacementRule(pattern5137, replacement5137) pattern5138 = Pattern(Integral((x_*WC('f', S(1)))**m_*(d_ + x_**S(2)*WC('e', S(1)))**p_*(WC('a', S(0)) + WC('b', S(1))*acos(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons4, cons1737, cons268, cons961, cons1753, cons17, cons1754) def replacement5138(p, m, f, b, d, a, n, c, x, e): rubi.append(5138) return Int(ExpandIntegrand((a + b*acos(c*x))**n/sqrt(d + e*x**S(2)), (f*x)**m*(d + e*x**S(2))**(p + S(1)/2), x), x) rule5138 = ReplacementRule(pattern5138, replacement5138) pattern5139 = Pattern(Integral(x_*(d_ + x_**S(2)*WC('e', S(1)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*asin(x_*WC('c', S(1)))), x_), cons2, cons3, cons7, cons27, cons48, cons5, cons1742, cons54) def replacement5139(p, b, d, a, c, x, e): rubi.append(5139) return -Dist(b*c/(S(2)*e*(p + S(1))), Int((d + e*x**S(2))**(p + S(1))/sqrt(-c**S(2)*x**S(2) + S(1)), x), x) + Simp((a + b*asin(c*x))*(d + e*x**S(2))**(p + S(1))/(S(2)*e*(p + S(1))), x) rule5139 = ReplacementRule(pattern5139, replacement5139) pattern5140 = Pattern(Integral(x_*(d_ + x_**S(2)*WC('e', S(1)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*acos(x_*WC('c', S(1)))), x_), cons2, cons3, cons7, cons27, cons48, cons5, cons1742, cons54) def replacement5140(p, b, d, a, c, x, e): rubi.append(5140) return Dist(b*c/(S(2)*e*(p + S(1))), Int((d + e*x**S(2))**(p + S(1))/sqrt(-c**S(2)*x**S(2) + S(1)), x), x) + Simp((a + b*acos(c*x))*(d + e*x**S(2))**(p + S(1))/(S(2)*e*(p + S(1))), x) rule5140 = ReplacementRule(pattern5140, replacement5140) def With5141(p, m, f, b, d, a, c, x, e): u = IntHide((f*x)**m*(d + e*x**S(2))**p, x) rubi.append(5141) return -Dist(b*c, Int(SimplifyIntegrand(u/sqrt(-c**S(2)*x**S(2) + S(1)), x), x), x) + Dist(a + b*asin(c*x), u, x) pattern5141 = Pattern(Integral((x_*WC('f', S(1)))**WC('m', S(1))*(d_ + x_**S(2)*WC('e', S(1)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*asin(x_*WC('c', S(1)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons1742, cons38, cons1755) rule5141 = ReplacementRule(pattern5141, With5141) def With5142(p, m, f, b, d, a, c, x, e): u = IntHide((f*x)**m*(d + e*x**S(2))**p, x) rubi.append(5142) return Dist(b*c, Int(SimplifyIntegrand(u/sqrt(-c**S(2)*x**S(2) + S(1)), x), x), x) + Dist(a + b*acos(c*x), u, x) pattern5142 = Pattern(Integral((x_*WC('f', S(1)))**WC('m', S(1))*(d_ + x_**S(2)*WC('e', S(1)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*acos(x_*WC('c', S(1)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons1742, cons38, cons1755) rule5142 = ReplacementRule(pattern5142, With5142) pattern5143 = Pattern(Integral((x_*WC('f', S(1)))**WC('m', S(1))*(d_ + x_**S(2)*WC('e', S(1)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*asin(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons1742, cons148, cons38, cons17) def replacement5143(p, m, f, b, d, a, n, c, x, e): rubi.append(5143) return Int(ExpandIntegrand((a + b*asin(c*x))**n, (f*x)**m*(d + e*x**S(2))**p, x), x) rule5143 = ReplacementRule(pattern5143, replacement5143) pattern5144 = Pattern(Integral((x_*WC('f', S(1)))**WC('m', S(1))*(d_ + x_**S(2)*WC('e', S(1)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*acos(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons1742, cons148, cons38, cons17) def replacement5144(p, m, f, b, d, a, n, c, x, e): rubi.append(5144) return Int(ExpandIntegrand((a + b*acos(c*x))**n, (f*x)**m*(d + e*x**S(2))**p, x), x) rule5144 = ReplacementRule(pattern5144, replacement5144) pattern5145 = Pattern(Integral((x_*WC('f', S(1)))**WC('m', S(1))*(d_ + x_**S(2)*WC('e', S(1)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*asin(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons4, cons5, cons1756) def replacement5145(p, m, f, b, d, a, n, c, x, e): rubi.append(5145) return Int((f*x)**m*(a + b*asin(c*x))**n*(d + e*x**S(2))**p, x) rule5145 = ReplacementRule(pattern5145, replacement5145) pattern5146 = Pattern(Integral((x_*WC('f', S(1)))**WC('m', S(1))*(d_ + x_**S(2)*WC('e', S(1)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*acos(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons4, cons5, cons1756) def replacement5146(p, m, f, b, d, a, n, c, x, e): rubi.append(5146) return Int((f*x)**m*(a + b*acos(c*x))**n*(d + e*x**S(2))**p, x) rule5146 = ReplacementRule(pattern5146, replacement5146) pattern5147 = Pattern(Integral((x_*WC('h', S(1)))**WC('m', S(1))*(d_ + x_*WC('e', S(1)))**p_*(f_ + x_*WC('g', S(1)))**p_*(WC('a', S(0)) + WC('b', S(1))*asin(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons209, cons21, cons4, cons5, cons336, cons1745, cons147) def replacement5147(p, m, g, b, f, d, a, n, c, x, h, e): rubi.append(5147) return Dist((d + e*x)**FracPart(p)*(f + g*x)**FracPart(p)*(d*f + e*g*x**S(2))**(-FracPart(p)), Int((h*x)**m*(a + b*asin(c*x))**n*(d*f + e*g*x**S(2))**p, x), x) rule5147 = ReplacementRule(pattern5147, replacement5147) pattern5148 = Pattern(Integral((x_*WC('h', S(1)))**WC('m', S(1))*(d_ + x_*WC('e', S(1)))**p_*(f_ + x_*WC('g', S(1)))**p_*(WC('a', S(0)) + WC('b', S(1))*acos(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons209, cons21, cons4, cons5, cons336, cons1745, cons147) def replacement5148(p, m, g, b, f, d, a, n, c, x, h, e): rubi.append(5148) return Dist((d + e*x)**FracPart(p)*(f + g*x)**FracPart(p)*(d*f + e*g*x**S(2))**(-FracPart(p)), Int((h*x)**m*(a + b*acos(c*x))**n*(d*f + e*g*x**S(2))**p, x), x) rule5148 = ReplacementRule(pattern5148, replacement5148) pattern5149 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*asin(x_*WC('c', S(1))))**WC('n', S(1))/(d_ + x_*WC('e', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons148) def replacement5149(b, d, a, n, c, x, e): rubi.append(5149) return Subst(Int((a + b*x)**n*cos(x)/(c*d + e*sin(x)), x), x, asin(c*x)) rule5149 = ReplacementRule(pattern5149, replacement5149) pattern5150 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*acos(x_*WC('c', S(1))))**WC('n', S(1))/(d_ + x_*WC('e', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons148) def replacement5150(b, d, a, n, c, x, e): rubi.append(5150) return -Subst(Int((a + b*x)**n*sin(x)/(c*d + e*cos(x)), x), x, acos(c*x)) rule5150 = ReplacementRule(pattern5150, replacement5150) pattern5151 = Pattern(Integral((d_ + x_*WC('e', S(1)))**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*asin(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons21, cons148, cons66) def replacement5151(m, b, d, a, n, c, x, e): rubi.append(5151) return -Dist(b*c*n/(e*(m + S(1))), Int((a + b*asin(c*x))**(n + S(-1))*(d + e*x)**(m + S(1))/sqrt(-c**S(2)*x**S(2) + S(1)), x), x) + Simp((a + b*asin(c*x))**n*(d + e*x)**(m + S(1))/(e*(m + S(1))), x) rule5151 = ReplacementRule(pattern5151, replacement5151) pattern5152 = Pattern(Integral((d_ + x_*WC('e', S(1)))**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*acos(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons21, cons148, cons66) def replacement5152(m, b, d, a, n, c, x, e): rubi.append(5152) return Dist(b*c*n/(e*(m + S(1))), Int((a + b*acos(c*x))**(n + S(-1))*(d + e*x)**(m + S(1))/sqrt(-c**S(2)*x**S(2) + S(1)), x), x) + Simp((a + b*acos(c*x))**n*(d + e*x)**(m + S(1))/(e*(m + S(1))), x) rule5152 = ReplacementRule(pattern5152, replacement5152) pattern5153 = Pattern(Integral((d_ + x_*WC('e', S(1)))**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*asin(x_*WC('c', S(1))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons62, cons87, cons89) def replacement5153(m, b, d, a, c, n, x, e): rubi.append(5153) return Int(ExpandIntegrand((a + b*asin(c*x))**n*(d + e*x)**m, x), x) rule5153 = ReplacementRule(pattern5153, replacement5153) pattern5154 = Pattern(Integral((d_ + x_*WC('e', S(1)))**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*acos(x_*WC('c', S(1))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons62, cons87, cons89) def replacement5154(m, b, d, a, c, n, x, e): rubi.append(5154) return Int(ExpandIntegrand((a + b*acos(c*x))**n*(d + e*x)**m, x), x) rule5154 = ReplacementRule(pattern5154, replacement5154) pattern5155 = Pattern(Integral((x_*WC('e', S(1)) + WC('d', S(0)))**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*asin(x_*WC('c', S(1))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons4, cons62) def replacement5155(m, b, d, a, c, n, x, e): rubi.append(5155) return Dist(c**(-m + S(-1)), Subst(Int((a + b*x)**n*(c*d + e*sin(x))**m*cos(x), x), x, asin(c*x)), x) rule5155 = ReplacementRule(pattern5155, replacement5155) pattern5156 = Pattern(Integral((x_*WC('e', S(1)) + WC('d', S(0)))**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*acos(x_*WC('c', S(1))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons4, cons62) def replacement5156(m, b, d, a, c, n, x, e): rubi.append(5156) return -Dist(c**(-m + S(-1)), Subst(Int((a + b*x)**n*(c*d + e*cos(x))**m*sin(x), x), x, acos(c*x)), x) rule5156 = ReplacementRule(pattern5156, replacement5156) def With5157(b, Px, a, c, x): u = IntHide(Px, x) rubi.append(5157) return -Dist(b*c, Int(SimplifyIntegrand(u/sqrt(-c**S(2)*x**S(2) + S(1)), x), x), x) + Dist(a + b*asin(c*x), u, x) pattern5157 = Pattern(Integral(Px_*(WC('a', S(0)) + WC('b', S(1))*asin(x_*WC('c', S(1)))), x_), cons2, cons3, cons7, cons925) rule5157 = ReplacementRule(pattern5157, With5157) def With5158(b, Px, a, c, x): u = IntHide(Px, x) rubi.append(5158) return Dist(b*c, Int(SimplifyIntegrand(u/sqrt(-c**S(2)*x**S(2) + S(1)), x), x), x) + Dist(a + b*acos(c*x), u, x) pattern5158 = Pattern(Integral(Px_*(WC('a', S(0)) + WC('b', S(1))*acos(x_*WC('c', S(1)))), x_), cons2, cons3, cons7, cons925) rule5158 = ReplacementRule(pattern5158, With5158) pattern5159 = Pattern(Integral(Px_*(WC('a', S(0)) + WC('b', S(1))*asin(x_*WC('c', S(1))))**n_, x_), cons2, cons3, cons7, cons4, cons925) def replacement5159(b, Px, a, n, c, x): rubi.append(5159) return Int(ExpandIntegrand(Px*(a + b*asin(c*x))**n, x), x) rule5159 = ReplacementRule(pattern5159, replacement5159) pattern5160 = Pattern(Integral(Px_*(WC('a', S(0)) + WC('b', S(1))*acos(x_*WC('c', S(1))))**n_, x_), cons2, cons3, cons7, cons4, cons925) def replacement5160(b, Px, a, n, c, x): rubi.append(5160) return Int(ExpandIntegrand(Px*(a + b*acos(c*x))**n, x), x) rule5160 = ReplacementRule(pattern5160, replacement5160) def With5161(m, b, Px, d, a, c, x, e): u = IntHide(Px*(d + e*x)**m, x) rubi.append(5161) return -Dist(b*c, Int(SimplifyIntegrand(u/sqrt(-c**S(2)*x**S(2) + S(1)), x), x), x) + Dist(a + b*asin(c*x), u, x) pattern5161 = Pattern(Integral(Px_*(x_*WC('e', S(1)) + WC('d', S(0)))**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*asin(x_*WC('c', S(1)))), x_), cons2, cons3, cons7, cons27, cons48, cons21, cons925) rule5161 = ReplacementRule(pattern5161, With5161) def With5162(m, b, Px, d, a, c, x, e): u = IntHide(Px*(d + e*x)**m, x) rubi.append(5162) return Dist(b*c, Int(SimplifyIntegrand(u/sqrt(-c**S(2)*x**S(2) + S(1)), x), x), x) + Dist(a + b*acos(c*x), u, x) pattern5162 = Pattern(Integral(Px_*(x_*WC('e', S(1)) + WC('d', S(0)))**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*acos(x_*WC('c', S(1)))), x_), cons2, cons3, cons7, cons27, cons48, cons21, cons925) rule5162 = ReplacementRule(pattern5162, With5162) def With5163(p, m, f, b, g, d, a, c, n, x, e): u = IntHide((d + e*x)**m*(f + g*x)**p, x) rubi.append(5163) return -Dist(b*c*n, Int(SimplifyIntegrand(u*(a + b*asin(c*x))**(n + S(-1))/sqrt(-c**S(2)*x**S(2) + S(1)), x), x), x) + Dist((a + b*asin(c*x))**n, u, x) pattern5163 = Pattern(Integral((d_ + x_*WC('e', S(1)))**m_*(x_*WC('g', S(1)) + WC('f', S(0)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*asin(x_*WC('c', S(1))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons464, cons84, cons1757) rule5163 = ReplacementRule(pattern5163, With5163) def With5164(p, m, f, b, g, d, a, c, n, x, e): u = IntHide((d + e*x)**m*(f + g*x)**p, x) rubi.append(5164) return Dist(b*c*n, Int(SimplifyIntegrand(u*(a + b*acos(c*x))**(n + S(-1))/sqrt(-c**S(2)*x**S(2) + S(1)), x), x), x) + Dist((a + b*acos(c*x))**n, u, x) pattern5164 = Pattern(Integral((d_ + x_*WC('e', S(1)))**m_*(x_*WC('g', S(1)) + WC('f', S(0)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*acos(x_*WC('c', S(1))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons464, cons84, cons1757) rule5164 = ReplacementRule(pattern5164, With5164) def With5165(p, f, b, g, d, a, c, n, x, h, e): u = IntHide((f + g*x + h*x**S(2))**p/(d + e*x)**S(2), x) rubi.append(5165) return -Dist(b*c*n, Int(SimplifyIntegrand(u*(a + b*asin(c*x))**(n + S(-1))/sqrt(-c**S(2)*x**S(2) + S(1)), x), x), x) + Dist((a + b*asin(c*x))**n, u, x) pattern5165 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*asin(x_*WC('c', S(1))))**n_*(x_**S(2)*WC('h', S(1)) + x_*WC('g', S(1)) + WC('f', S(0)))**WC('p', S(1))/(d_ + x_*WC('e', S(1)))**S(2), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons209, cons464, cons1758) rule5165 = ReplacementRule(pattern5165, With5165) def With5166(p, f, b, g, d, a, c, n, x, h, e): u = IntHide((f + g*x + h*x**S(2))**p/(d + e*x)**S(2), x) rubi.append(5166) return Dist(b*c*n, Int(SimplifyIntegrand(u*(a + b*acos(c*x))**(n + S(-1))/sqrt(-c**S(2)*x**S(2) + S(1)), x), x), x) + Dist((a + b*acos(c*x))**n, u, x) pattern5166 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*acos(x_*WC('c', S(1))))**n_*(x_**S(2)*WC('h', S(1)) + x_*WC('g', S(1)) + WC('f', S(0)))**WC('p', S(1))/(d_ + x_*WC('e', S(1)))**S(2), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons209, cons464, cons1758) rule5166 = ReplacementRule(pattern5166, With5166) pattern5167 = Pattern(Integral(Px_*(d_ + x_*WC('e', S(1)))**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*asin(x_*WC('c', S(1))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons925, cons148, cons17) def replacement5167(m, b, Px, d, a, c, n, x, e): rubi.append(5167) return Int(ExpandIntegrand(Px*(a + b*asin(c*x))**n*(d + e*x)**m, x), x) rule5167 = ReplacementRule(pattern5167, replacement5167) pattern5168 = Pattern(Integral(Px_*(d_ + x_*WC('e', S(1)))**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*acos(x_*WC('c', S(1))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons925, cons148, cons17) def replacement5168(m, b, Px, d, a, c, n, x, e): rubi.append(5168) return Int(ExpandIntegrand(Px*(a + b*acos(c*x))**n*(d + e*x)**m, x), x) rule5168 = ReplacementRule(pattern5168, replacement5168) def With5169(p, m, g, b, f, d, a, c, x, e): u = IntHide((d + e*x**S(2))**p*(f + g*x)**m, x) rubi.append(5169) return -Dist(b*c, Int(Dist(S(1)/sqrt(-c**S(2)*x**S(2) + S(1)), u, x), x), x) + Dist(a + b*asin(c*x), u, x) pattern5169 = Pattern(Integral((d_ + x_**S(2)*WC('e', S(1)))**p_*(f_ + x_*WC('g', S(1)))**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*asin(x_*WC('c', S(1)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons1737, cons17, cons719, cons268, cons168, cons1759) rule5169 = ReplacementRule(pattern5169, With5169) def With5170(p, m, g, b, f, d, a, c, x, e): u = IntHide((d + e*x**S(2))**p*(f + g*x)**m, x) rubi.append(5170) return Dist(b*c, Int(Dist(S(1)/sqrt(-c**S(2)*x**S(2) + S(1)), u, x), x), x) + Dist(a + b*acos(c*x), u, x) pattern5170 = Pattern(Integral((d_ + x_**S(2)*WC('e', S(1)))**p_*(f_ + x_*WC('g', S(1)))**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*acos(x_*WC('c', S(1)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons1737, cons17, cons719, cons268, cons168, cons1759) rule5170 = ReplacementRule(pattern5170, With5170) pattern5171 = Pattern(Integral((d_ + x_**S(2)*WC('e', S(1)))**p_*(f_ + x_*WC('g', S(1)))**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*asin(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons1737, cons17, cons667, cons268, cons148, cons168, cons1760) def replacement5171(p, m, g, b, f, d, a, n, c, x, e): rubi.append(5171) return Int(ExpandIntegrand((a + b*asin(c*x))**n*(d + e*x**S(2))**p, (f + g*x)**m, x), x) rule5171 = ReplacementRule(pattern5171, replacement5171) pattern5172 = Pattern(Integral((d_ + x_**S(2)*WC('e', S(1)))**p_*(f_ + x_*WC('g', S(1)))**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*acos(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons1737, cons17, cons667, cons268, cons148, cons168, cons1760) def replacement5172(p, m, g, b, f, d, a, n, c, x, e): rubi.append(5172) return Int(ExpandIntegrand((a + b*acos(c*x))**n*(d + e*x**S(2))**p, (f + g*x)**m, x), x) rule5172 = ReplacementRule(pattern5172, replacement5172) pattern5173 = Pattern(Integral(sqrt(d_ + x_**S(2)*WC('e', S(1)))*(f_ + x_*WC('g', S(1)))**m_*(WC('a', S(0)) + WC('b', S(1))*asin(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons1737, cons17, cons268, cons148, cons267) def replacement5173(m, g, b, f, d, a, n, c, x, e): rubi.append(5173) return -Dist(S(1)/(b*c*sqrt(d)*(n + S(1))), Int((a + b*asin(c*x))**(n + S(1))*(f + g*x)**(m + S(-1))*(d*g*m + S(2)*e*f*x + e*g*x**S(2)*(m + S(2))), x), x) + Simp((a + b*asin(c*x))**(n + S(1))*(d + e*x**S(2))*(f + g*x)**m/(b*c*sqrt(d)*(n + S(1))), x) rule5173 = ReplacementRule(pattern5173, replacement5173) pattern5174 = Pattern(Integral(sqrt(d_ + x_**S(2)*WC('e', S(1)))*(f_ + x_*WC('g', S(1)))**m_*(WC('a', S(0)) + WC('b', S(1))*acos(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons1737, cons17, cons268, cons148, cons267) def replacement5174(m, g, b, f, d, a, n, c, x, e): rubi.append(5174) return Dist(S(1)/(b*c*sqrt(d)*(n + S(1))), Int((a + b*acos(c*x))**(n + S(1))*(f + g*x)**(m + S(-1))*(d*g*m + S(2)*e*f*x + e*g*x**S(2)*(m + S(2))), x), x) - Simp((a + b*acos(c*x))**(n + S(1))*(d + e*x**S(2))*(f + g*x)**m/(b*c*sqrt(d)*(n + S(1))), x) rule5174 = ReplacementRule(pattern5174, replacement5174) pattern5175 = Pattern(Integral((d_ + x_**S(2)*WC('e', S(1)))**p_*(f_ + x_*WC('g', S(1)))**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*asin(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons1737, cons17, cons961, cons268, cons148) def replacement5175(p, m, g, b, f, d, a, n, c, x, e): rubi.append(5175) return Int(ExpandIntegrand((a + b*asin(c*x))**n*sqrt(d + e*x**S(2)), (d + e*x**S(2))**(p + S(-1)/2)*(f + g*x)**m, x), x) rule5175 = ReplacementRule(pattern5175, replacement5175) pattern5176 = Pattern(Integral((d_ + x_**S(2)*WC('e', S(1)))**p_*(f_ + x_*WC('g', S(1)))**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*acos(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons1737, cons17, cons961, cons268, cons148) def replacement5176(p, m, g, b, f, d, a, n, c, x, e): rubi.append(5176) return Int(ExpandIntegrand((a + b*acos(c*x))**n*sqrt(d + e*x**S(2)), (d + e*x**S(2))**(p + S(-1)/2)*(f + g*x)**m, x), x) rule5176 = ReplacementRule(pattern5176, replacement5176) pattern5177 = Pattern(Integral((d_ + x_**S(2)*WC('e', S(1)))**p_*(f_ + x_*WC('g', S(1)))**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*asin(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons1737, cons17, cons717, cons268, cons148, cons267) def replacement5177(p, m, g, b, f, d, a, n, c, x, e): rubi.append(5177) return -Dist(S(1)/(b*c*sqrt(d)*(n + S(1))), Int(ExpandIntegrand((a + b*asin(c*x))**(n + S(1))*(f + g*x)**(m + S(-1)), (d + e*x**S(2))**(p + S(-1)/2)*(d*g*m + e*f*x*(S(2)*p + S(1)) + e*g*x**S(2)*(m + S(2)*p + S(1))), x), x), x) + Simp((a + b*asin(c*x))**(n + S(1))*(d + e*x**S(2))**(p + S(1)/2)*(f + g*x)**m/(b*c*sqrt(d)*(n + S(1))), x) rule5177 = ReplacementRule(pattern5177, replacement5177) pattern5178 = Pattern(Integral((d_ + x_**S(2)*WC('e', S(1)))**p_*(f_ + x_*WC('g', S(1)))**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*acos(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons1737, cons17, cons717, cons268, cons148, cons267) def replacement5178(p, m, g, b, f, d, a, n, c, x, e): rubi.append(5178) return Dist(S(1)/(b*c*sqrt(d)*(n + S(1))), Int(ExpandIntegrand((a + b*acos(c*x))**(n + S(1))*(f + g*x)**(m + S(-1)), (d + e*x**S(2))**(p + S(-1)/2)*(d*g*m + e*f*x*(S(2)*p + S(1)) + e*g*x**S(2)*(m + S(2)*p + S(1))), x), x), x) - Simp((a + b*acos(c*x))**(n + S(1))*(d + e*x**S(2))**(p + S(1)/2)*(f + g*x)**m/(b*c*sqrt(d)*(n + S(1))), x) rule5178 = ReplacementRule(pattern5178, replacement5178) pattern5179 = Pattern(Integral((f_ + x_*WC('g', S(1)))**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*asin(x_*WC('c', S(1))))**n_/sqrt(d_ + x_**S(2)*WC('e', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons1737, cons17, cons268, cons168, cons87, cons89) def replacement5179(m, g, b, f, d, a, c, n, x, e): rubi.append(5179) return -Dist(g*m/(b*c*sqrt(d)*(n + S(1))), Int((a + b*asin(c*x))**(n + S(1))*(f + g*x)**(m + S(-1)), x), x) + Simp((a + b*asin(c*x))**(n + S(1))*(f + g*x)**m/(b*c*sqrt(d)*(n + S(1))), x) rule5179 = ReplacementRule(pattern5179, replacement5179) pattern5180 = Pattern(Integral((f_ + x_*WC('g', S(1)))**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*acos(x_*WC('c', S(1))))**n_/sqrt(d_ + x_**S(2)*WC('e', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons1737, cons17, cons268, cons168, cons87, cons89) def replacement5180(m, g, b, f, d, a, c, n, x, e): rubi.append(5180) return Dist(g*m/(b*c*sqrt(d)*(n + S(1))), Int((a + b*acos(c*x))**(n + S(1))*(f + g*x)**(m + S(-1)), x), x) - Simp((a + b*acos(c*x))**(n + S(1))*(f + g*x)**m/(b*c*sqrt(d)*(n + S(1))), x) rule5180 = ReplacementRule(pattern5180, replacement5180) pattern5181 = Pattern(Integral((f_ + x_*WC('g', S(1)))**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*asin(x_*WC('c', S(1))))**WC('n', S(1))/sqrt(d_ + x_**S(2)*WC('e', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons4, cons1737, cons17, cons268, cons1761) def replacement5181(m, g, b, f, d, a, n, c, x, e): rubi.append(5181) return Dist(c**(-m + S(-1))/sqrt(d), Subst(Int((a + b*x)**n*(c*f + g*sin(x))**m, x), x, asin(c*x)), x) rule5181 = ReplacementRule(pattern5181, replacement5181) pattern5182 = Pattern(Integral((f_ + x_*WC('g', S(1)))**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*acos(x_*WC('c', S(1))))**WC('n', S(1))/sqrt(d_ + x_**S(2)*WC('e', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons4, cons1737, cons17, cons268, cons1761) def replacement5182(m, g, b, f, d, a, n, c, x, e): rubi.append(5182) return -Dist(c**(-m + S(-1))/sqrt(d), Subst(Int((a + b*x)**n*(c*f + g*cos(x))**m, x), x, acos(c*x)), x) rule5182 = ReplacementRule(pattern5182, replacement5182) pattern5183 = Pattern(Integral((d_ + x_**S(2)*WC('e', S(1)))**p_*(f_ + x_*WC('g', S(1)))**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*asin(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons1737, cons17, cons719, cons268, cons148) def replacement5183(p, m, g, b, f, d, a, n, c, x, e): rubi.append(5183) return Int(ExpandIntegrand((a + b*asin(c*x))**n/sqrt(d + e*x**S(2)), (d + e*x**S(2))**(p + S(1)/2)*(f + g*x)**m, x), x) rule5183 = ReplacementRule(pattern5183, replacement5183) pattern5184 = Pattern(Integral((d_ + x_**S(2)*WC('e', S(1)))**p_*(f_ + x_*WC('g', S(1)))**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*acos(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons1737, cons17, cons719, cons268, cons148) def replacement5184(p, m, g, b, f, d, a, n, c, x, e): rubi.append(5184) return Int(ExpandIntegrand((a + b*acos(c*x))**n/sqrt(d + e*x**S(2)), (d + e*x**S(2))**(p + S(1)/2)*(f + g*x)**m, x), x) rule5184 = ReplacementRule(pattern5184, replacement5184) pattern5185 = Pattern(Integral((d_ + x_**S(2)*WC('e', S(1)))**p_*(f_ + x_*WC('g', S(1)))**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*asin(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons4, cons1737, cons17, cons347, cons1738) def replacement5185(p, m, g, b, f, d, a, n, c, x, e): rubi.append(5185) return Dist(d**IntPart(p)*(d + e*x**S(2))**FracPart(p)*(-c**S(2)*x**S(2) + S(1))**(-FracPart(p)), Int((a + b*asin(c*x))**n*(f + g*x)**m*(-c**S(2)*x**S(2) + S(1))**p, x), x) rule5185 = ReplacementRule(pattern5185, replacement5185) pattern5186 = Pattern(Integral((d_ + x_**S(2)*WC('e', S(1)))**p_*(f_ + x_*WC('g', S(1)))**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*acos(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons4, cons1737, cons17, cons347, cons1738) def replacement5186(p, m, g, b, f, d, a, n, c, x, e): rubi.append(5186) return Dist(d**IntPart(p)*(d + e*x**S(2))**FracPart(p)*(-c**S(2)*x**S(2) + S(1))**(-FracPart(p)), Int((a + b*acos(c*x))**n*(f + g*x)**m*(-c**S(2)*x**S(2) + S(1))**p, x), x) rule5186 = ReplacementRule(pattern5186, replacement5186) pattern5187 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*asin(x_*WC('c', S(1))))**WC('n', S(1))*log((x_*WC('g', S(1)) + WC('f', S(0)))**WC('m', S(1))*WC('h', S(1)))/sqrt(d_ + x_**S(2)*WC('e', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons209, cons21, cons1737, cons268, cons148) def replacement5187(m, f, g, b, d, a, c, n, x, h, e): rubi.append(5187) return -Dist(g*m/(b*c*sqrt(d)*(n + S(1))), Int((a + b*asin(c*x))**(n + S(1))/(f + g*x), x), x) + Simp((a + b*asin(c*x))**(n + S(1))*log(h*(f + g*x)**m)/(b*c*sqrt(d)*(n + S(1))), x) rule5187 = ReplacementRule(pattern5187, replacement5187) pattern5188 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*acos(x_*WC('c', S(1))))**WC('n', S(1))*log((x_*WC('g', S(1)) + WC('f', S(0)))**WC('m', S(1))*WC('h', S(1)))/sqrt(d_ + x_**S(2)*WC('e', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons209, cons21, cons1737, cons268, cons148) def replacement5188(m, f, g, b, d, a, c, n, x, h, e): rubi.append(5188) return Dist(g*m/(b*c*sqrt(d)*(n + S(1))), Int((a + b*acos(c*x))**(n + S(1))/(f + g*x), x), x) - Simp((a + b*acos(c*x))**(n + S(1))*log(h*(f + g*x)**m)/(b*c*sqrt(d)*(n + S(1))), x) rule5188 = ReplacementRule(pattern5188, replacement5188) pattern5189 = Pattern(Integral((d_ + x_**S(2)*WC('e', S(1)))**p_*(WC('a', S(0)) + WC('b', S(1))*asin(x_*WC('c', S(1))))**WC('n', S(1))*log((x_*WC('g', S(1)) + WC('f', S(0)))**WC('m', S(1))*WC('h', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons209, cons21, cons4, cons1737, cons347, cons1738) def replacement5189(p, m, f, g, b, d, a, c, n, x, h, e): rubi.append(5189) return Dist(d**IntPart(p)*(d + e*x**S(2))**FracPart(p)*(-c**S(2)*x**S(2) + S(1))**(-FracPart(p)), Int((a + b*asin(c*x))**n*(-c**S(2)*x**S(2) + S(1))**p*log(h*(f + g*x)**m), x), x) rule5189 = ReplacementRule(pattern5189, replacement5189) pattern5190 = Pattern(Integral((d_ + x_**S(2)*WC('e', S(1)))**p_*(WC('a', S(0)) + WC('b', S(1))*acos(x_*WC('c', S(1))))**WC('n', S(1))*log((x_*WC('g', S(1)) + WC('f', S(0)))**WC('m', S(1))*WC('h', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons209, cons21, cons4, cons1737, cons347, cons1738) def replacement5190(p, m, f, g, b, d, a, c, n, x, h, e): rubi.append(5190) return Dist(d**IntPart(p)*(d + e*x**S(2))**FracPart(p)*(-c**S(2)*x**S(2) + S(1))**(-FracPart(p)), Int((a + b*acos(c*x))**n*(-c**S(2)*x**S(2) + S(1))**p*log(h*(f + g*x)**m), x), x) rule5190 = ReplacementRule(pattern5190, replacement5190) def With5191(m, g, b, f, d, a, c, x, e): u = IntHide((d + e*x)**m*(f + g*x)**m, x) rubi.append(5191) return -Dist(b*c, Int(Dist(S(1)/sqrt(-c**S(2)*x**S(2) + S(1)), u, x), x), x) + Dist(a + b*asin(c*x), u, x) pattern5191 = Pattern(Integral((d_ + x_*WC('e', S(1)))**m_*(f_ + x_*WC('g', S(1)))**m_*(WC('a', S(0)) + WC('b', S(1))*asin(x_*WC('c', S(1)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons1608) rule5191 = ReplacementRule(pattern5191, With5191) def With5192(m, g, b, f, d, a, c, x, e): u = IntHide((d + e*x)**m*(f + g*x)**m, x) rubi.append(5192) return Dist(b*c, Int(Dist(S(1)/sqrt(-c**S(2)*x**S(2) + S(1)), u, x), x), x) + Dist(a + b*acos(c*x), u, x) pattern5192 = Pattern(Integral((d_ + x_*WC('e', S(1)))**m_*(f_ + x_*WC('g', S(1)))**m_*(WC('a', S(0)) + WC('b', S(1))*acos(x_*WC('c', S(1)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons1608) rule5192 = ReplacementRule(pattern5192, With5192) pattern5193 = Pattern(Integral((d_ + x_*WC('e', S(1)))**WC('m', S(1))*(f_ + x_*WC('g', S(1)))**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*asin(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons4, cons17) def replacement5193(m, g, b, f, d, a, n, c, x, e): rubi.append(5193) return Int(ExpandIntegrand((a + b*asin(c*x))**n*(d + e*x)**m*(f + g*x)**m, x), x) rule5193 = ReplacementRule(pattern5193, replacement5193) pattern5194 = Pattern(Integral((d_ + x_*WC('e', S(1)))**WC('m', S(1))*(f_ + x_*WC('g', S(1)))**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*acos(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons4, cons17) def replacement5194(m, g, b, f, d, a, n, c, x, e): rubi.append(5194) return Int(ExpandIntegrand((a + b*acos(c*x))**n*(d + e*x)**m*(f + g*x)**m, x), x) rule5194 = ReplacementRule(pattern5194, replacement5194) def With5195(u, b, a, c, x): if isinstance(x, (int, Integer, float, Float)): return False v = IntHide(u, x) if InverseFunctionFreeQ(v, x): return True return False pattern5195 = Pattern(Integral(u_*(WC('a', S(0)) + WC('b', S(1))*asin(x_*WC('c', S(1)))), x_), cons2, cons3, cons7, cons14, CustomConstraint(With5195)) def replacement5195(u, b, a, c, x): v = IntHide(u, x) rubi.append(5195) return -Dist(b*c, Int(SimplifyIntegrand(v/sqrt(-c**S(2)*x**S(2) + S(1)), x), x), x) + Dist(a + b*asin(c*x), v, x) rule5195 = ReplacementRule(pattern5195, replacement5195) def With5196(u, b, a, c, x): if isinstance(x, (int, Integer, float, Float)): return False v = IntHide(u, x) if InverseFunctionFreeQ(v, x): return True return False pattern5196 = Pattern(Integral(u_*(WC('a', S(0)) + WC('b', S(1))*acos(x_*WC('c', S(1)))), x_), cons2, cons3, cons7, cons14, CustomConstraint(With5196)) def replacement5196(u, b, a, c, x): v = IntHide(u, x) rubi.append(5196) return Dist(b*c, Int(SimplifyIntegrand(v/sqrt(-c**S(2)*x**S(2) + S(1)), x), x), x) + Dist(a + b*acos(c*x), v, x) rule5196 = ReplacementRule(pattern5196, replacement5196) def With5197(p, b, Px, d, a, n, c, x, e): if isinstance(x, (int, Integer, float, Float)): return False u = ExpandIntegrand(Px*(a + b*asin(c*x))**n*(d + e*x**S(2))**p, x) if SumQ(u): return True return False pattern5197 = Pattern(Integral(Px_*(d_ + x_**S(2)*WC('e', S(1)))**p_*(WC('a', S(0)) + WC('b', S(1))*asin(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons4, cons925, cons1737, cons347, CustomConstraint(With5197)) def replacement5197(p, b, Px, d, a, n, c, x, e): u = ExpandIntegrand(Px*(a + b*asin(c*x))**n*(d + e*x**S(2))**p, x) rubi.append(5197) return Int(u, x) rule5197 = ReplacementRule(pattern5197, replacement5197) def With5198(p, b, Px, d, a, n, c, x, e): if isinstance(x, (int, Integer, float, Float)): return False u = ExpandIntegrand(Px*(a + b*acos(c*x))**n*(d + e*x**S(2))**p, x) if SumQ(u): return True return False pattern5198 = Pattern(Integral(Px_*(d_ + x_**S(2)*WC('e', S(1)))**p_*(WC('a', S(0)) + WC('b', S(1))*acos(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons4, cons925, cons1737, cons347, CustomConstraint(With5198)) def replacement5198(p, b, Px, d, a, n, c, x, e): u = ExpandIntegrand(Px*(a + b*acos(c*x))**n*(d + e*x**S(2))**p, x) rubi.append(5198) return Int(u, x) rule5198 = ReplacementRule(pattern5198, replacement5198) def With5199(p, m, g, b, f, Px, d, a, n, c, x, e): if isinstance(x, (int, Integer, float, Float)): return False u = ExpandIntegrand(Px*(a + b*asin(c*x))**n*(f + g*(d + e*x**S(2))**p)**m, x) if SumQ(u): return True return False pattern5199 = Pattern(Integral((f_ + (d_ + x_**S(2)*WC('e', S(1)))**p_*WC('g', S(1)))**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*asin(x_*WC('c', S(1))))**WC('n', S(1))*WC('Px', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons925, cons1737, cons961, cons150, CustomConstraint(With5199)) def replacement5199(p, m, g, b, f, Px, d, a, n, c, x, e): u = ExpandIntegrand(Px*(a + b*asin(c*x))**n*(f + g*(d + e*x**S(2))**p)**m, x) rubi.append(5199) return Int(u, x) rule5199 = ReplacementRule(pattern5199, replacement5199) def With5200(p, m, g, b, f, Px, d, a, n, c, x, e): if isinstance(x, (int, Integer, float, Float)): return False u = ExpandIntegrand(Px*(a + b*acos(c*x))**n*(f + g*(d + e*x**S(2))**p)**m, x) if SumQ(u): return True return False pattern5200 = Pattern(Integral((f_ + (d_ + x_**S(2)*WC('e', S(1)))**p_*WC('g', S(1)))**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*acos(x_*WC('c', S(1))))**WC('n', S(1))*WC('Px', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons925, cons1737, cons961, cons150, CustomConstraint(With5200)) def replacement5200(p, m, g, b, f, Px, d, a, n, c, x, e): u = ExpandIntegrand(Px*(a + b*acos(c*x))**n*(f + g*(d + e*x**S(2))**p)**m, x) rubi.append(5200) return Int(u, x) rule5200 = ReplacementRule(pattern5200, replacement5200) def With5201(x, c, n, RFx): if isinstance(x, (int, Integer, float, Float)): return False u = ExpandIntegrand(asin(c*x)**n, RFx, x) if SumQ(u): return True return False pattern5201 = Pattern(Integral(RFx_*asin(x_*WC('c', S(1)))**WC('n', S(1)), x_), cons7, cons1198, cons148, CustomConstraint(With5201)) def replacement5201(x, c, n, RFx): u = ExpandIntegrand(asin(c*x)**n, RFx, x) rubi.append(5201) return Int(u, x) rule5201 = ReplacementRule(pattern5201, replacement5201) def With5202(x, c, n, RFx): if isinstance(x, (int, Integer, float, Float)): return False u = ExpandIntegrand(acos(c*x)**n, RFx, x) if SumQ(u): return True return False pattern5202 = Pattern(Integral(RFx_*acos(x_*WC('c', S(1)))**WC('n', S(1)), x_), cons7, cons1198, cons148, CustomConstraint(With5202)) def replacement5202(x, c, n, RFx): u = ExpandIntegrand(acos(c*x)**n, RFx, x) rubi.append(5202) return Int(u, x) rule5202 = ReplacementRule(pattern5202, replacement5202) pattern5203 = Pattern(Integral(RFx_*(a_ + WC('b', S(1))*asin(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons1198, cons148) def replacement5203(RFx, b, c, n, a, x): rubi.append(5203) return Int(ExpandIntegrand(RFx*(a + b*asin(c*x))**n, x), x) rule5203 = ReplacementRule(pattern5203, replacement5203) pattern5204 = Pattern(Integral(RFx_*(a_ + WC('b', S(1))*acos(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons1198, cons148) def replacement5204(RFx, b, c, n, a, x): rubi.append(5204) return Int(ExpandIntegrand(RFx*(a + b*acos(c*x))**n, x), x) rule5204 = ReplacementRule(pattern5204, replacement5204) def With5205(p, RFx, d, c, n, x, e): if isinstance(x, (int, Integer, float, Float)): return False u = ExpandIntegrand((d + e*x**S(2))**p*asin(c*x)**n, RFx, x) if SumQ(u): return True return False pattern5205 = Pattern(Integral(RFx_*(d_ + x_**S(2)*WC('e', S(1)))**p_*asin(x_*WC('c', S(1)))**WC('n', S(1)), x_), cons7, cons27, cons48, cons1198, cons148, cons1737, cons347, CustomConstraint(With5205)) def replacement5205(p, RFx, d, c, n, x, e): u = ExpandIntegrand((d + e*x**S(2))**p*asin(c*x)**n, RFx, x) rubi.append(5205) return Int(u, x) rule5205 = ReplacementRule(pattern5205, replacement5205) def With5206(p, RFx, d, c, n, x, e): if isinstance(x, (int, Integer, float, Float)): return False u = ExpandIntegrand((d + e*x**S(2))**p*acos(c*x)**n, RFx, x) if SumQ(u): return True return False pattern5206 = Pattern(Integral(RFx_*(d_ + x_**S(2)*WC('e', S(1)))**p_*acos(x_*WC('c', S(1)))**WC('n', S(1)), x_), cons7, cons27, cons48, cons1198, cons148, cons1737, cons347, CustomConstraint(With5206)) def replacement5206(p, RFx, d, c, n, x, e): u = ExpandIntegrand((d + e*x**S(2))**p*acos(c*x)**n, RFx, x) rubi.append(5206) return Int(u, x) rule5206 = ReplacementRule(pattern5206, replacement5206) pattern5207 = Pattern(Integral(RFx_*(a_ + WC('b', S(1))*asin(x_*WC('c', S(1))))**WC('n', S(1))*(d_ + x_**S(2)*WC('e', S(1)))**p_, x_), cons2, cons3, cons7, cons27, cons48, cons1198, cons148, cons1737, cons347) def replacement5207(p, RFx, b, d, c, n, a, x, e): rubi.append(5207) return Int(ExpandIntegrand((d + e*x**S(2))**p, RFx*(a + b*asin(c*x))**n, x), x) rule5207 = ReplacementRule(pattern5207, replacement5207) pattern5208 = Pattern(Integral(RFx_*(a_ + WC('b', S(1))*acos(x_*WC('c', S(1))))**WC('n', S(1))*(d_ + x_**S(2)*WC('e', S(1)))**p_, x_), cons2, cons3, cons7, cons27, cons48, cons1198, cons148, cons1737, cons347) def replacement5208(p, RFx, b, d, c, n, a, x, e): rubi.append(5208) return Int(ExpandIntegrand((d + e*x**S(2))**p, RFx*(a + b*acos(c*x))**n, x), x) rule5208 = ReplacementRule(pattern5208, replacement5208) pattern5209 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*asin(x_*WC('c', S(1))))**WC('n', S(1))*WC('u', S(1)), x_), cons2, cons3, cons7, cons4, cons1579) def replacement5209(u, b, a, n, c, x): rubi.append(5209) return Int(u*(a + b*asin(c*x))**n, x) rule5209 = ReplacementRule(pattern5209, replacement5209) pattern5210 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*acos(x_*WC('c', S(1))))**WC('n', S(1))*WC('u', S(1)), x_), cons2, cons3, cons7, cons4, cons1579) def replacement5210(u, b, a, n, c, x): rubi.append(5210) return Int(u*(a + b*acos(c*x))**n, x) rule5210 = ReplacementRule(pattern5210, replacement5210) pattern5211 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*asin(c_ + x_*WC('d', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons4, cons1273) def replacement5211(b, d, c, a, n, x): rubi.append(5211) return Dist(S(1)/d, Subst(Int((a + b*asin(x))**n, x), x, c + d*x), x) rule5211 = ReplacementRule(pattern5211, replacement5211) pattern5212 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*acos(c_ + x_*WC('d', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons4, cons1273) def replacement5212(b, d, c, a, n, x): rubi.append(5212) return Dist(S(1)/d, Subst(Int((a + b*acos(x))**n, x), x, c + d*x), x) rule5212 = ReplacementRule(pattern5212, replacement5212) pattern5213 = Pattern(Integral((x_*WC('f', S(1)) + WC('e', S(0)))**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*asin(c_ + x_*WC('d', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons4, cons1360) def replacement5213(m, f, b, d, a, n, c, x, e): rubi.append(5213) return Dist(S(1)/d, Subst(Int((a + b*asin(x))**n*(f*x/d + (-c*f + d*e)/d)**m, x), x, c + d*x), x) rule5213 = ReplacementRule(pattern5213, replacement5213) pattern5214 = Pattern(Integral((x_*WC('f', S(1)) + WC('e', S(0)))**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*acos(c_ + x_*WC('d', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons4, cons1360) def replacement5214(m, f, b, d, a, n, c, x, e): rubi.append(5214) return Dist(S(1)/d, Subst(Int((a + b*acos(x))**n*(f*x/d + (-c*f + d*e)/d)**m, x), x, c + d*x), x) rule5214 = ReplacementRule(pattern5214, replacement5214) pattern5215 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*asin(c_ + x_*WC('d', S(1))))**WC('n', S(1))*(x_**S(2)*WC('C', S(1)) + x_*WC('B', S(1)) + WC('A', S(0)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons34, cons35, cons36, cons4, cons5, cons1762, cons1763) def replacement5215(B, C, p, b, d, a, n, c, x, A): rubi.append(5215) return Dist(S(1)/d, Subst(Int((a + b*asin(x))**n*(C*x**S(2)/d**S(2) - C/d**S(2))**p, x), x, c + d*x), x) rule5215 = ReplacementRule(pattern5215, replacement5215) pattern5216 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*acos(c_ + x_*WC('d', S(1))))**WC('n', S(1))*(x_**S(2)*WC('C', S(1)) + x_*WC('B', S(1)) + WC('A', S(0)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons34, cons35, cons36, cons4, cons5, cons1762, cons1763) def replacement5216(B, C, p, b, d, a, n, c, x, A): rubi.append(5216) return Dist(S(1)/d, Subst(Int((a + b*acos(x))**n*(C*x**S(2)/d**S(2) - C/d**S(2))**p, x), x, c + d*x), x) rule5216 = ReplacementRule(pattern5216, replacement5216) pattern5217 = Pattern(Integral((x_*WC('f', S(1)) + WC('e', S(0)))**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*asin(c_ + x_*WC('d', S(1))))**WC('n', S(1))*(x_**S(2)*WC('C', S(1)) + x_*WC('B', S(1)) + WC('A', S(0)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons36, cons21, cons4, cons5, cons1762, cons1763) def replacement5217(B, C, p, m, f, b, d, a, n, c, A, x, e): rubi.append(5217) return Dist(S(1)/d, Subst(Int((a + b*asin(x))**n*(C*x**S(2)/d**S(2) - C/d**S(2))**p*(f*x/d + (-c*f + d*e)/d)**m, x), x, c + d*x), x) rule5217 = ReplacementRule(pattern5217, replacement5217) pattern5218 = Pattern(Integral((x_*WC('f', S(1)) + WC('e', S(0)))**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*acos(c_ + x_*WC('d', S(1))))**WC('n', S(1))*(x_**S(2)*WC('C', S(1)) + x_*WC('B', S(1)) + WC('A', S(0)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons36, cons21, cons4, cons5, cons1762, cons1763) def replacement5218(B, C, p, m, f, b, d, a, n, c, A, x, e): rubi.append(5218) return Dist(S(1)/d, Subst(Int((a + b*acos(x))**n*(C*x**S(2)/d**S(2) - C/d**S(2))**p*(f*x/d + (-c*f + d*e)/d)**m, x), x, c + d*x), x) rule5218 = ReplacementRule(pattern5218, replacement5218) pattern5219 = Pattern(Integral(sqrt(WC('a', S(0)) + WC('b', S(1))*asin(c_ + x_**S(2)*WC('d', S(1)))), x_), cons2, cons3, cons7, cons27, cons1764) def replacement5219(b, d, c, a, x): rubi.append(5219) return Simp(x*sqrt(a + b*asin(c + d*x**S(2))), x) + Simp(sqrt(Pi)*x*(-c*sin(a/(S(2)*b)) + cos(a/(S(2)*b)))*FresnelS(sqrt(c/(Pi*b))*sqrt(a + b*asin(c + d*x**S(2))))/(sqrt(c/b)*(-c*sin(asin(c + d*x**S(2))/S(2)) + cos(asin(c + d*x**S(2))/S(2)))), x) - Simp(sqrt(Pi)*x*(c*sin(a/(S(2)*b)) + cos(a/(S(2)*b)))*FresnelC(sqrt(c/(Pi*b))*sqrt(a + b*asin(c + d*x**S(2))))/(sqrt(c/b)*(-c*sin(asin(c + d*x**S(2))/S(2)) + cos(asin(c + d*x**S(2))/S(2)))), x) rule5219 = ReplacementRule(pattern5219, replacement5219) pattern5220 = Pattern(Integral(sqrt(WC('a', S(0)) + WC('b', S(1))*acos(x_**S(2)*WC('d', S(1)) + S(1))), x_), cons2, cons3, cons27, cons1765) def replacement5220(d, a, b, x): rubi.append(5220) return Simp(-S(2)*sqrt(a + b*acos(d*x**S(2) + S(1)))*sin(acos(d*x**S(2) + S(1))/S(2))**S(2)/(d*x), x) - Simp(S(2)*sqrt(Pi)*FresnelC(sqrt(S(1)/(Pi*b))*sqrt(a + b*acos(d*x**S(2) + S(1))))*sin(a/(S(2)*b))*sin(acos(d*x**S(2) + S(1))/S(2))/(d*x*sqrt(S(1)/b)), x) + Simp(S(2)*sqrt(Pi)*FresnelS(sqrt(S(1)/(Pi*b))*sqrt(a + b*acos(d*x**S(2) + S(1))))*sin(acos(d*x**S(2) + S(1))/S(2))*cos(a/(S(2)*b))/(d*x*sqrt(S(1)/b)), x) rule5220 = ReplacementRule(pattern5220, replacement5220) pattern5221 = Pattern(Integral(sqrt(WC('a', S(0)) + WC('b', S(1))*acos(x_**S(2)*WC('d', S(1)) + S(-1))), x_), cons2, cons3, cons27, cons1765) def replacement5221(d, a, b, x): rubi.append(5221) return Simp(S(2)*sqrt(a + b*acos(d*x**S(2) + S(-1)))*cos(acos(d*x**S(2) + S(-1))/S(2))**S(2)/(d*x), x) - Simp(S(2)*sqrt(Pi)*FresnelC(sqrt(S(1)/(Pi*b))*sqrt(a + b*acos(d*x**S(2) + S(-1))))*cos(a/(S(2)*b))*cos(acos(d*x**S(2) + S(-1))/S(2))/(d*x*sqrt(S(1)/b)), x) - Simp(S(2)*sqrt(Pi)*FresnelS(sqrt(S(1)/(Pi*b))*sqrt(a + b*acos(d*x**S(2) + S(-1))))*sin(a/(S(2)*b))*cos(acos(d*x**S(2) + S(-1))/S(2))/(d*x*sqrt(S(1)/b)), x) rule5221 = ReplacementRule(pattern5221, replacement5221) pattern5222 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*asin(c_ + x_**S(2)*WC('d', S(1))))**n_, x_), cons2, cons3, cons7, cons27, cons1764, cons87, cons165) def replacement5222(b, d, c, a, n, x): rubi.append(5222) return -Dist(S(4)*b**S(2)*n*(n + S(-1)), Int((a + b*asin(c + d*x**S(2)))**(n + S(-2)), x), x) + Simp(x*(a + b*asin(c + d*x**S(2)))**n, x) + Simp(S(2)*b*n*(a + b*asin(c + d*x**S(2)))**(n + S(-1))*sqrt(-S(2)*c*d*x**S(2) - d**S(2)*x**S(4))/(d*x), x) rule5222 = ReplacementRule(pattern5222, replacement5222) pattern5223 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*acos(c_ + x_**S(2)*WC('d', S(1))))**n_, x_), cons2, cons3, cons7, cons27, cons1764, cons87, cons165) def replacement5223(b, d, c, a, n, x): rubi.append(5223) return -Dist(S(4)*b**S(2)*n*(n + S(-1)), Int((a + b*acos(c + d*x**S(2)))**(n + S(-2)), x), x) + Simp(x*(a + b*acos(c + d*x**S(2)))**n, x) - Simp(S(2)*b*n*(a + b*acos(c + d*x**S(2)))**(n + S(-1))*sqrt(-S(2)*c*d*x**S(2) - d**S(2)*x**S(4))/(d*x), x) rule5223 = ReplacementRule(pattern5223, replacement5223) pattern5224 = Pattern(Integral(S(1)/(WC('a', S(0)) + WC('b', S(1))*asin(c_ + x_**S(2)*WC('d', S(1)))), x_), cons2, cons3, cons7, cons27, cons1764) def replacement5224(b, d, c, a, x): rubi.append(5224) return -Simp(x*(c*cos(a/(S(2)*b)) - sin(a/(S(2)*b)))*CosIntegral(c*(a + b*asin(c + d*x**S(2)))/(S(2)*b))/(S(2)*b*(-c*sin(asin(c + d*x**S(2))/S(2)) + cos(asin(c + d*x**S(2))/S(2)))), x) - Simp(x*(c*cos(a/(S(2)*b)) + sin(a/(S(2)*b)))*SinIntegral(c*(a + b*asin(c + d*x**S(2)))/(S(2)*b))/(S(2)*b*(-c*sin(asin(c + d*x**S(2))/S(2)) + cos(asin(c + d*x**S(2))/S(2)))), x) rule5224 = ReplacementRule(pattern5224, replacement5224) pattern5225 = Pattern(Integral(S(1)/(WC('a', S(0)) + WC('b', S(1))*acos(x_**S(2)*WC('d', S(1)) + S(1))), x_), cons2, cons3, cons27, cons1765) def replacement5225(d, a, b, x): rubi.append(5225) return Simp(sqrt(S(2))*x*CosIntegral((a + b*acos(d*x**S(2) + S(1)))/(S(2)*b))*cos(a/(S(2)*b))/(S(2)*b*sqrt(-d*x**S(2))), x) + Simp(sqrt(S(2))*x*SinIntegral((a + b*acos(d*x**S(2) + S(1)))/(S(2)*b))*sin(a/(S(2)*b))/(S(2)*b*sqrt(-d*x**S(2))), x) rule5225 = ReplacementRule(pattern5225, replacement5225) pattern5226 = Pattern(Integral(S(1)/(WC('a', S(0)) + WC('b', S(1))*acos(x_**S(2)*WC('d', S(1)) + S(-1))), x_), cons2, cons3, cons27, cons1765) def replacement5226(d, a, b, x): rubi.append(5226) return Simp(sqrt(S(2))*x*CosIntegral((a + b*acos(d*x**S(2) + S(-1)))/(S(2)*b))*sin(a/(S(2)*b))/(S(2)*b*sqrt(d*x**S(2))), x) - Simp(sqrt(S(2))*x*SinIntegral((a + b*acos(d*x**S(2) + S(-1)))/(S(2)*b))*cos(a/(S(2)*b))/(S(2)*b*sqrt(d*x**S(2))), x) rule5226 = ReplacementRule(pattern5226, replacement5226) pattern5227 = Pattern(Integral(S(1)/sqrt(WC('a', S(0)) + WC('b', S(1))*asin(c_ + x_**S(2)*WC('d', S(1)))), x_), cons2, cons3, cons7, cons27, cons1764) def replacement5227(b, d, c, a, x): rubi.append(5227) return -Simp(sqrt(Pi)*x*(-c*sin(a/(S(2)*b)) + cos(a/(S(2)*b)))*FresnelC(sqrt(a + b*asin(c + d*x**S(2)))/(sqrt(Pi)*sqrt(b*c)))/(sqrt(b*c)*(-c*sin(asin(c + d*x**S(2))/S(2)) + cos(asin(c + d*x**S(2))/S(2)))), x) - Simp(sqrt(Pi)*x*(c*sin(a/(S(2)*b)) + cos(a/(S(2)*b)))*FresnelS(sqrt(a + b*asin(c + d*x**S(2)))/(sqrt(Pi)*sqrt(b*c)))/(sqrt(b*c)*(-c*sin(asin(c + d*x**S(2))/S(2)) + cos(asin(c + d*x**S(2))/S(2)))), x) rule5227 = ReplacementRule(pattern5227, replacement5227) pattern5228 = Pattern(Integral(S(1)/sqrt(WC('a', S(0)) + WC('b', S(1))*acos(x_**S(2)*WC('d', S(1)) + S(1))), x_), cons2, cons3, cons27, cons1765) def replacement5228(d, a, b, x): rubi.append(5228) return Simp(-S(2)*sqrt(Pi/b)*FresnelC(sqrt(S(1)/(Pi*b))*sqrt(a + b*acos(d*x**S(2) + S(1))))*sin(acos(d*x**S(2) + S(1))/S(2))*cos(a/(S(2)*b))/(d*x), x) - Simp(S(2)*sqrt(Pi/b)*FresnelS(sqrt(S(1)/(Pi*b))*sqrt(a + b*acos(d*x**S(2) + S(1))))*sin(a/(S(2)*b))*sin(acos(d*x**S(2) + S(1))/S(2))/(d*x), x) rule5228 = ReplacementRule(pattern5228, replacement5228) pattern5229 = Pattern(Integral(S(1)/sqrt(WC('a', S(0)) + WC('b', S(1))*acos(x_**S(2)*WC('d', S(1)) + S(-1))), x_), cons2, cons3, cons27, cons1765) def replacement5229(d, a, b, x): rubi.append(5229) return Simp(S(2)*sqrt(Pi/b)*FresnelC(sqrt(S(1)/(Pi*b))*sqrt(a + b*acos(d*x**S(2) + S(-1))))*sin(a/(S(2)*b))*cos(acos(d*x**S(2) + S(-1))/S(2))/(d*x), x) - Simp(S(2)*sqrt(Pi/b)*FresnelS(sqrt(S(1)/(Pi*b))*sqrt(a + b*acos(d*x**S(2) + S(-1))))*cos(a/(S(2)*b))*cos(acos(d*x**S(2) + S(-1))/S(2))/(d*x), x) rule5229 = ReplacementRule(pattern5229, replacement5229) pattern5230 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*asin(c_ + x_**S(2)*WC('d', S(1))))**(S(-3)/2), x_), cons2, cons3, cons7, cons27, cons1764) def replacement5230(b, d, c, a, x): rubi.append(5230) return -Simp(sqrt(-S(2)*c*d*x**S(2) - d**S(2)*x**S(4))/(b*d*x*sqrt(a + b*asin(c + d*x**S(2)))), x) + Simp(sqrt(Pi)*x*(c/b)**(S(3)/2)*(-c*sin(a/(S(2)*b)) + cos(a/(S(2)*b)))*FresnelS(sqrt(c/(Pi*b))*sqrt(a + b*asin(c + d*x**S(2))))/(-c*sin(asin(c + d*x**S(2))/S(2)) + cos(asin(c + d*x**S(2))/S(2))), x) - Simp(sqrt(Pi)*x*(c/b)**(S(3)/2)*(c*sin(a/(S(2)*b)) + cos(a/(S(2)*b)))*FresnelC(sqrt(c/(Pi*b))*sqrt(a + b*asin(c + d*x**S(2))))/(-c*sin(asin(c + d*x**S(2))/S(2)) + cos(asin(c + d*x**S(2))/S(2))), x) rule5230 = ReplacementRule(pattern5230, replacement5230) pattern5231 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*acos(x_**S(2)*WC('d', S(1)) + S(1)))**(S(-3)/2), x_), cons2, cons3, cons27, cons1765) def replacement5231(d, a, b, x): rubi.append(5231) return Simp(sqrt(-d**S(2)*x**S(4) - S(2)*d*x**S(2))/(b*d*x*sqrt(a + b*acos(d*x**S(2) + S(1)))), x) - Simp(S(2)*sqrt(Pi)*(S(1)/b)**(S(3)/2)*FresnelC(sqrt(S(1)/(Pi*b))*sqrt(a + b*acos(d*x**S(2) + S(1))))*sin(a/(S(2)*b))*sin(acos(d*x**S(2) + S(1))/S(2))/(d*x), x) + Simp(S(2)*sqrt(Pi)*(S(1)/b)**(S(3)/2)*FresnelS(sqrt(S(1)/(Pi*b))*sqrt(a + b*acos(d*x**S(2) + S(1))))*sin(acos(d*x**S(2) + S(1))/S(2))*cos(a/(S(2)*b))/(d*x), x) rule5231 = ReplacementRule(pattern5231, replacement5231) pattern5232 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*acos(x_**S(2)*WC('d', S(1)) + S(-1)))**(S(-3)/2), x_), cons2, cons3, cons27, cons1765) def replacement5232(d, a, b, x): rubi.append(5232) return Simp(sqrt(-d**S(2)*x**S(4) + S(2)*d*x**S(2))/(b*d*x*sqrt(a + b*acos(d*x**S(2) + S(-1)))), x) - Simp(S(2)*sqrt(Pi)*(S(1)/b)**(S(3)/2)*FresnelC(sqrt(S(1)/(Pi*b))*sqrt(a + b*acos(d*x**S(2) + S(-1))))*cos(a/(S(2)*b))*cos(acos(d*x**S(2) + S(-1))/S(2))/(d*x), x) - Simp(S(2)*sqrt(Pi)*(S(1)/b)**(S(3)/2)*FresnelS(sqrt(S(1)/(Pi*b))*sqrt(a + b*acos(d*x**S(2) + S(-1))))*sin(a/(S(2)*b))*cos(acos(d*x**S(2) + S(-1))/S(2))/(d*x), x) rule5232 = ReplacementRule(pattern5232, replacement5232) pattern5233 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*asin(c_ + x_**S(2)*WC('d', S(1))))**(S(-2)), x_), cons2, cons3, cons7, cons27, cons1764) def replacement5233(b, d, c, a, x): rubi.append(5233) return Simp(x*(-c*sin(a/(S(2)*b)) + cos(a/(S(2)*b)))*SinIntegral(c*(a + b*asin(c + d*x**S(2)))/(S(2)*b))/(S(4)*b**S(2)*(-c*sin(asin(c + d*x**S(2))/S(2)) + cos(asin(c + d*x**S(2))/S(2)))), x) - Simp(x*(c*sin(a/(S(2)*b)) + cos(a/(S(2)*b)))*CosIntegral(c*(a + b*asin(c + d*x**S(2)))/(S(2)*b))/(S(4)*b**S(2)*(-c*sin(asin(c + d*x**S(2))/S(2)) + cos(asin(c + d*x**S(2))/S(2)))), x) - Simp(sqrt(-S(2)*c*d*x**S(2) - d**S(2)*x**S(4))/(S(2)*b*d*x*(a + b*asin(c + d*x**S(2)))), x) rule5233 = ReplacementRule(pattern5233, replacement5233) pattern5234 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*acos(x_**S(2)*WC('d', S(1)) + S(1)))**(S(-2)), x_), cons2, cons3, cons27, cons1765) def replacement5234(d, a, b, x): rubi.append(5234) return Simp(sqrt(-d**S(2)*x**S(4) - S(2)*d*x**S(2))/(S(2)*b*d*x*(a + b*acos(d*x**S(2) + S(1)))), x) + Simp(sqrt(S(2))*x*CosIntegral((a + b*acos(d*x**S(2) + S(1)))/(S(2)*b))*sin(a/(S(2)*b))/(S(4)*b**S(2)*sqrt(-d*x**S(2))), x) - Simp(sqrt(S(2))*x*SinIntegral((a + b*acos(d*x**S(2) + S(1)))/(S(2)*b))*cos(a/(S(2)*b))/(S(4)*b**S(2)*sqrt(-d*x**S(2))), x) rule5234 = ReplacementRule(pattern5234, replacement5234) pattern5235 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*acos(x_**S(2)*WC('d', S(1)) + S(-1)))**(S(-2)), x_), cons2, cons3, cons27, cons1765) def replacement5235(d, a, b, x): rubi.append(5235) return Simp(sqrt(-d**S(2)*x**S(4) + S(2)*d*x**S(2))/(S(2)*b*d*x*(a + b*acos(d*x**S(2) + S(-1)))), x) - Simp(sqrt(S(2))*x*CosIntegral((a + b*acos(d*x**S(2) + S(-1)))/(S(2)*b))*cos(a/(S(2)*b))/(S(4)*b**S(2)*sqrt(d*x**S(2))), x) - Simp(sqrt(S(2))*x*SinIntegral((a + b*acos(d*x**S(2) + S(-1)))/(S(2)*b))*sin(a/(S(2)*b))/(S(4)*b**S(2)*sqrt(d*x**S(2))), x) rule5235 = ReplacementRule(pattern5235, replacement5235) pattern5236 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*asin(c_ + x_**S(2)*WC('d', S(1))))**n_, x_), cons2, cons3, cons7, cons27, cons1764, cons87, cons89, cons1442) def replacement5236(b, d, c, a, n, x): rubi.append(5236) return -Dist(S(1)/(S(4)*b**S(2)*(n + S(1))*(n + S(2))), Int((a + b*asin(c + d*x**S(2)))**(n + S(2)), x), x) + Simp(x*(a + b*asin(c + d*x**S(2)))**(n + S(2))/(S(4)*b**S(2)*(n + S(1))*(n + S(2))), x) + Simp((a + b*asin(c + d*x**S(2)))**(n + S(1))*sqrt(-S(2)*c*d*x**S(2) - d**S(2)*x**S(4))/(S(2)*b*d*x*(n + S(1))), x) rule5236 = ReplacementRule(pattern5236, replacement5236) pattern5237 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*acos(c_ + x_**S(2)*WC('d', S(1))))**n_, x_), cons2, cons3, cons7, cons27, cons1764, cons87, cons89, cons1442) def replacement5237(b, d, c, a, n, x): rubi.append(5237) return -Dist(S(1)/(S(4)*b**S(2)*(n + S(1))*(n + S(2))), Int((a + b*acos(c + d*x**S(2)))**(n + S(2)), x), x) + Simp(x*(a + b*acos(c + d*x**S(2)))**(n + S(2))/(S(4)*b**S(2)*(n + S(1))*(n + S(2))), x) - Simp((a + b*acos(c + d*x**S(2)))**(n + S(1))*sqrt(-S(2)*c*d*x**S(2) - d**S(2)*x**S(4))/(S(2)*b*d*x*(n + S(1))), x) rule5237 = ReplacementRule(pattern5237, replacement5237) pattern5238 = Pattern(Integral(asin(x_**p_*WC('a', S(1)))**WC('n', S(1))/x_, x_), cons2, cons5, cons148) def replacement5238(x, a, n, p): rubi.append(5238) return Dist(S(1)/p, Subst(Int(x**n/tan(x), x), x, asin(a*x**p)), x) rule5238 = ReplacementRule(pattern5238, replacement5238) pattern5239 = Pattern(Integral(acos(x_**p_*WC('a', S(1)))**WC('n', S(1))/x_, x_), cons2, cons5, cons148) def replacement5239(x, a, n, p): rubi.append(5239) return -Dist(S(1)/p, Subst(Int(x**n*tan(x), x), x, acos(a*x**p)), x) rule5239 = ReplacementRule(pattern5239, replacement5239) pattern5240 = Pattern(Integral(WC('u', S(1))*asin(WC('c', S(1))/(x_**WC('n', S(1))*WC('b', S(1)) + WC('a', S(0))))**WC('m', S(1)), x_), cons2, cons3, cons7, cons4, cons21, cons1766) def replacement5240(u, m, b, c, n, a, x): rubi.append(5240) return Int(u*acsc(a/c + b*x**n/c)**m, x) rule5240 = ReplacementRule(pattern5240, replacement5240) pattern5241 = Pattern(Integral(WC('u', S(1))*acos(WC('c', S(1))/(x_**WC('n', S(1))*WC('b', S(1)) + WC('a', S(0))))**WC('m', S(1)), x_), cons2, cons3, cons7, cons4, cons21, cons1766) def replacement5241(u, m, b, c, n, a, x): rubi.append(5241) return Int(u*asec(a/c + b*x**n/c)**m, x) rule5241 = ReplacementRule(pattern5241, replacement5241) pattern5242 = Pattern(Integral(asin(sqrt(x_**S(2)*WC('b', S(1)) + S(1)))**WC('n', S(1))/sqrt(x_**S(2)*WC('b', S(1)) + S(1)), x_), cons3, cons4, cons1767) def replacement5242(x, n, b): rubi.append(5242) return Dist(sqrt(-b*x**S(2))/(b*x), Subst(Int(asin(x)**n/sqrt(-x**S(2) + S(1)), x), x, sqrt(b*x**S(2) + S(1))), x) rule5242 = ReplacementRule(pattern5242, replacement5242) pattern5243 = Pattern(Integral(acos(sqrt(x_**S(2)*WC('b', S(1)) + S(1)))**WC('n', S(1))/sqrt(x_**S(2)*WC('b', S(1)) + S(1)), x_), cons3, cons4, cons1767) def replacement5243(x, n, b): rubi.append(5243) return Dist(sqrt(-b*x**S(2))/(b*x), Subst(Int(acos(x)**n/sqrt(-x**S(2) + S(1)), x), x, sqrt(b*x**S(2) + S(1))), x) rule5243 = ReplacementRule(pattern5243, replacement5243) pattern5244 = Pattern(Integral(f_**(WC('c', S(1))*asin(x_*WC('b', S(1)) + WC('a', S(0)))**WC('n', S(1)))*WC('u', S(1)), x_), cons2, cons3, cons7, cons125, cons148) def replacement5244(u, f, b, c, a, n, x): rubi.append(5244) return Dist(S(1)/b, Subst(Int(f**(c*x**n)*ReplaceAll(u, Rule(x, -a/b + sin(x)/b))*cos(x), x), x, asin(a + b*x)), x) rule5244 = ReplacementRule(pattern5244, replacement5244) pattern5245 = Pattern(Integral(f_**(WC('c', S(1))*acos(x_*WC('b', S(1)) + WC('a', S(0)))**WC('n', S(1)))*WC('u', S(1)), x_), cons2, cons3, cons7, cons125, cons148) def replacement5245(u, f, b, c, a, n, x): rubi.append(5245) return -Dist(S(1)/b, Subst(Int(f**(c*x**n)*ReplaceAll(u, Rule(x, -a/b + cos(x)/b))*sin(x), x), x, acos(a + b*x)), x) rule5245 = ReplacementRule(pattern5245, replacement5245) pattern5246 = Pattern(Integral(asin(x_**S(2)*WC('a', S(1)) + sqrt(c_ + x_**S(2)*WC('d', S(1)))*WC('b', S(1))), x_), cons2, cons3, cons7, cons27, cons1768) def replacement5246(b, d, c, a, x): rubi.append(5246) return -Dist(x*sqrt(a**S(2)*x**S(2) + S(2)*a*b*sqrt(c + d*x**S(2)) + b**S(2)*d)/sqrt(-x**S(2)*(a**S(2)*x**S(2) + S(2)*a*b*sqrt(c + d*x**S(2)) + b**S(2)*d)), Int(x*(S(2)*a*sqrt(c + d*x**S(2)) + b*d)/(sqrt(c + d*x**S(2))*sqrt(a**S(2)*x**S(2) + S(2)*a*b*sqrt(c + d*x**S(2)) + b**S(2)*d)), x), x) + Simp(x*asin(a*x**S(2) + b*sqrt(c + d*x**S(2))), x) rule5246 = ReplacementRule(pattern5246, replacement5246) pattern5247 = Pattern(Integral(acos(x_**S(2)*WC('a', S(1)) + sqrt(c_ + x_**S(2)*WC('d', S(1)))*WC('b', S(1))), x_), cons2, cons3, cons7, cons27, cons1768) def replacement5247(b, d, c, a, x): rubi.append(5247) return Dist(x*sqrt(a**S(2)*x**S(2) + S(2)*a*b*sqrt(c + d*x**S(2)) + b**S(2)*d)/sqrt(-x**S(2)*(a**S(2)*x**S(2) + S(2)*a*b*sqrt(c + d*x**S(2)) + b**S(2)*d)), Int(x*(S(2)*a*sqrt(c + d*x**S(2)) + b*d)/(sqrt(c + d*x**S(2))*sqrt(a**S(2)*x**S(2) + S(2)*a*b*sqrt(c + d*x**S(2)) + b**S(2)*d)), x), x) + Simp(x*acos(a*x**S(2) + b*sqrt(c + d*x**S(2))), x) rule5247 = ReplacementRule(pattern5247, replacement5247) pattern5248 = Pattern(Integral(asin(u_), x_), cons1230, cons1769) def replacement5248(x, u): rubi.append(5248) return -Int(SimplifyIntegrand(x*D(u, x)/sqrt(-u**S(2) + S(1)), x), x) + Simp(x*asin(u), x) rule5248 = ReplacementRule(pattern5248, replacement5248) pattern5249 = Pattern(Integral(acos(u_), x_), cons1230, cons1769) def replacement5249(x, u): rubi.append(5249) return Int(SimplifyIntegrand(x*D(u, x)/sqrt(-u**S(2) + S(1)), x), x) + Simp(x*acos(u), x) rule5249 = ReplacementRule(pattern5249, replacement5249) pattern5250 = Pattern(Integral((x_*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*asin(u_)), x_), cons2, cons3, cons7, cons27, cons21, cons66, cons1230, cons1770, cons1769) def replacement5250(u, m, b, d, c, a, x): rubi.append(5250) return -Dist(b/(d*(m + S(1))), Int(SimplifyIntegrand((c + d*x)**(m + S(1))*D(u, x)/sqrt(-u**S(2) + S(1)), x), x), x) + Simp((a + b*asin(u))*(c + d*x)**(m + S(1))/(d*(m + S(1))), x) rule5250 = ReplacementRule(pattern5250, replacement5250) pattern5251 = Pattern(Integral((x_*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*acos(u_)), x_), cons2, cons3, cons7, cons27, cons21, cons66, cons1230, cons1770, cons1769) def replacement5251(u, m, b, d, c, a, x): rubi.append(5251) return Dist(b/(d*(m + S(1))), Int(SimplifyIntegrand((c + d*x)**(m + S(1))*D(u, x)/sqrt(-u**S(2) + S(1)), x), x), x) + Simp((a + b*acos(u))*(c + d*x)**(m + S(1))/(d*(m + S(1))), x) rule5251 = ReplacementRule(pattern5251, replacement5251) def With5252(v, u, b, a, x): if isinstance(x, (int, Integer, float, Float)): return False w = IntHide(v, x) if InverseFunctionFreeQ(w, x): return True return False pattern5252 = Pattern(Integral(v_*(WC('a', S(0)) + WC('b', S(1))*asin(u_)), x_), cons2, cons3, cons1230, cons1771, CustomConstraint(With5252)) def replacement5252(v, u, b, a, x): w = IntHide(v, x) rubi.append(5252) return -Dist(b, Int(SimplifyIntegrand(w*D(u, x)/sqrt(-u**S(2) + S(1)), x), x), x) + Dist(a + b*asin(u), w, x) rule5252 = ReplacementRule(pattern5252, replacement5252) def With5253(v, u, b, a, x): if isinstance(x, (int, Integer, float, Float)): return False w = IntHide(v, x) if InverseFunctionFreeQ(w, x): return True return False pattern5253 = Pattern(Integral(v_*(WC('a', S(0)) + WC('b', S(1))*acos(u_)), x_), cons2, cons3, cons1230, cons1772, CustomConstraint(With5253)) def replacement5253(v, u, b, a, x): w = IntHide(v, x) rubi.append(5253) return Dist(b, Int(SimplifyIntegrand(w*D(u, x)/sqrt(-u**S(2) + S(1)), x), x), x) + Dist(a + b*acos(u), w, x) rule5253 = ReplacementRule(pattern5253, replacement5253) pattern5254 = Pattern(Integral((ArcTan(x_*WC('c', S(1)))*WC('b', S(1)) + WC('a', S(0)))**WC('n', S(1)), x_), cons2, cons3, cons7, cons148) def replacement5254(b, a, n, c, x): rubi.append(5254) return -Dist(b*c*n, Int(x*(a + b*ArcTan(c*x))**(n + S(-1))/(c**S(2)*x**S(2) + S(1)), x), x) + Simp(x*(a + b*ArcTan(c*x))**n, x) rule5254 = ReplacementRule(pattern5254, replacement5254) pattern5255 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*acot(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons148) def replacement5255(b, a, n, c, x): rubi.append(5255) return Dist(b*c*n, Int(x*(a + b*acot(c*x))**(n + S(-1))/(c**S(2)*x**S(2) + S(1)), x), x) + Simp(x*(a + b*acot(c*x))**n, x) rule5255 = ReplacementRule(pattern5255, replacement5255) pattern5256 = Pattern(Integral((ArcTan(x_*WC('c', S(1)))*WC('b', S(1)) + WC('a', S(0)))**n_, x_), cons2, cons3, cons7, cons4, cons340) def replacement5256(b, a, n, c, x): rubi.append(5256) return Int((a + b*ArcTan(c*x))**n, x) rule5256 = ReplacementRule(pattern5256, replacement5256) pattern5257 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*acot(x_*WC('c', S(1))))**n_, x_), cons2, cons3, cons7, cons4, cons340) def replacement5257(b, a, n, c, x): rubi.append(5257) return Int((a + b*acot(c*x))**n, x) rule5257 = ReplacementRule(pattern5257, replacement5257) pattern5258 = Pattern(Integral((ArcTan(x_*WC('c', S(1)))*WC('b', S(1)) + WC('a', S(0)))**WC('n', S(1))/(d_ + x_*WC('e', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons1773, cons148) def replacement5258(b, d, a, n, c, x, e): rubi.append(5258) return Dist(b*c*n/e, Int((a + b*ArcTan(c*x))**(n + S(-1))*log(S(2)*d/(d + e*x))/(c**S(2)*x**S(2) + S(1)), x), x) - Simp((a + b*ArcTan(c*x))**n*log(S(2)*d/(d + e*x))/e, x) rule5258 = ReplacementRule(pattern5258, replacement5258) pattern5259 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*acot(x_*WC('c', S(1))))**WC('n', S(1))/(d_ + x_*WC('e', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons1773, cons148) def replacement5259(b, d, a, n, c, x, e): rubi.append(5259) return -Dist(b*c*n/e, Int((a + b*acot(c*x))**(n + S(-1))*log(S(2)*d/(d + e*x))/(c**S(2)*x**S(2) + S(1)), x), x) - Simp((a + b*acot(c*x))**n*log(S(2)*d/(d + e*x))/e, x) rule5259 = ReplacementRule(pattern5259, replacement5259) pattern5260 = Pattern(Integral(ArcTan(x_*WC('c', S(1)))/(d_ + x_*WC('e', S(1))), x_), cons7, cons27, cons48, cons1774, cons1775) def replacement5260(x, d, c, e): rubi.append(5260) return Simp(I*PolyLog(S(2), Simp(I*c*(d + e*x)/(I*c*d - e), x))/(S(2)*e), x) - Simp(I*PolyLog(S(2), Simp(I*c*(d + e*x)/(I*c*d + e), x))/(S(2)*e), x) - Simp(ArcTan(c*d/e)*log(d + e*x)/e, x) rule5260 = ReplacementRule(pattern5260, replacement5260) pattern5261 = Pattern(Integral(ArcTan(x_*WC('c', S(1)))/(x_*WC('e', S(1)) + WC('d', S(0))), x_), cons7, cons27, cons48, cons1776) def replacement5261(d, c, x, e): rubi.append(5261) return Dist(I/S(2), Int(log(-I*c*x + S(1))/(d + e*x), x), x) - Dist(I/S(2), Int(log(I*c*x + S(1))/(d + e*x), x), x) rule5261 = ReplacementRule(pattern5261, replacement5261) pattern5262 = Pattern(Integral(acot(x_*WC('c', S(1)))/(x_*WC('e', S(1)) + WC('d', S(0))), x_), cons7, cons27, cons48, cons1776) def replacement5262(d, c, x, e): rubi.append(5262) return Dist(I/S(2), Int(log(S(1) - I/(c*x))/(d + e*x), x), x) - Dist(I/S(2), Int(log(S(1) + I/(c*x))/(d + e*x), x), x) rule5262 = ReplacementRule(pattern5262, replacement5262) pattern5263 = Pattern(Integral((a_ + ArcTan(x_*WC('c', S(1)))*WC('b', S(1)))/(x_*WC('e', S(1)) + WC('d', S(0))), x_), cons2, cons3, cons7, cons27, cons48, cons1043) def replacement5263(b, d, c, a, x, e): rubi.append(5263) return Dist(b, Int(ArcTan(c*x)/(d + e*x), x), x) + Simp(a*log(RemoveContent(d + e*x, x))/e, x) rule5263 = ReplacementRule(pattern5263, replacement5263) pattern5264 = Pattern(Integral((a_ + WC('b', S(1))*acot(x_*WC('c', S(1))))/(x_*WC('e', S(1)) + WC('d', S(0))), x_), cons2, cons3, cons7, cons27, cons48, cons1043) def replacement5264(b, d, c, a, x, e): rubi.append(5264) return Dist(b, Int(acot(c*x)/(d + e*x), x), x) + Simp(a*log(RemoveContent(d + e*x, x))/e, x) rule5264 = ReplacementRule(pattern5264, replacement5264) pattern5265 = Pattern(Integral((x_*WC('e', S(1)) + WC('d', S(0)))**WC('p', S(1))*(ArcTan(x_*WC('c', S(1)))*WC('b', S(1)) + WC('a', S(0))), x_), cons2, cons3, cons7, cons27, cons48, cons5, cons54) def replacement5265(p, b, d, a, c, x, e): rubi.append(5265) return -Dist(b*c/(e*(p + S(1))), Int((d + e*x)**(p + S(1))/(c**S(2)*x**S(2) + S(1)), x), x) + Simp((a + b*ArcTan(c*x))*(d + e*x)**(p + S(1))/(e*(p + S(1))), x) rule5265 = ReplacementRule(pattern5265, replacement5265) pattern5266 = Pattern(Integral((x_*WC('e', S(1)) + WC('d', S(0)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*acot(x_*WC('c', S(1)))), x_), cons2, cons3, cons7, cons27, cons48, cons5, cons54) def replacement5266(p, b, d, a, c, x, e): rubi.append(5266) return Dist(b*c/(e*(p + S(1))), Int((d + e*x)**(p + S(1))/(c**S(2)*x**S(2) + S(1)), x), x) + Simp((a + b*acot(c*x))*(d + e*x)**(p + S(1))/(e*(p + S(1))), x) rule5266 = ReplacementRule(pattern5266, replacement5266) pattern5267 = Pattern(Integral((ArcTan(x_*WC('c', S(1)))*WC('b', S(1)) + WC('a', S(0)))**n_/x_, x_), cons2, cons3, cons7, cons85, cons165) def replacement5267(b, a, n, c, x): rubi.append(5267) return -Dist(S(2)*b*c*n, Int((a + b*ArcTan(c*x))**(n + S(-1))*atanh(S(1) - S(2)*I/(-c*x + I))/(c**S(2)*x**S(2) + S(1)), x), x) + Simp(S(2)*(a + b*ArcTan(c*x))**n*atanh(S(1) - S(2)*I/(-c*x + I)), x) rule5267 = ReplacementRule(pattern5267, replacement5267) pattern5268 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*acot(x_*WC('c', S(1))))**n_/x_, x_), cons2, cons3, cons7, cons85, cons165) def replacement5268(b, a, n, c, x): rubi.append(5268) return Dist(S(2)*b*c*n, Int((a + b*acot(c*x))**(n + S(-1))*acoth(S(1) - S(2)*I/(-c*x + I))/(c**S(2)*x**S(2) + S(1)), x), x) + Simp(S(2)*(a + b*acot(c*x))**n*acoth(S(1) - S(2)*I/(-c*x + I)), x) rule5268 = ReplacementRule(pattern5268, replacement5268) pattern5269 = Pattern(Integral(x_**WC('m', S(1))*(ArcTan(x_*WC('c', S(1)))*WC('b', S(1)) + WC('a', S(0)))**n_, x_), cons2, cons3, cons7, cons21, cons85, cons165, cons66) def replacement5269(m, b, a, c, n, x): rubi.append(5269) return -Dist(b*c*n/(m + S(1)), Int(x**(m + S(1))*(a + b*ArcTan(c*x))**(n + S(-1))/(c**S(2)*x**S(2) + S(1)), x), x) + Simp(x**(m + S(1))*(a + b*ArcTan(c*x))**n/(m + S(1)), x) rule5269 = ReplacementRule(pattern5269, replacement5269) pattern5270 = Pattern(Integral(x_**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*acot(x_*WC('c', S(1))))**n_, x_), cons2, cons3, cons7, cons21, cons85, cons165, cons66) def replacement5270(m, b, a, c, n, x): rubi.append(5270) return Dist(b*c*n/(m + S(1)), Int(x**(m + S(1))*(a + b*acot(c*x))**(n + S(-1))/(c**S(2)*x**S(2) + S(1)), x), x) + Simp(x**(m + S(1))*(a + b*acot(c*x))**n/(m + S(1)), x) rule5270 = ReplacementRule(pattern5270, replacement5270) pattern5271 = Pattern(Integral((d_ + x_*WC('e', S(1)))**WC('p', S(1))*(ArcTan(x_*WC('c', S(1)))*WC('b', S(1)) + WC('a', S(0)))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons464) def replacement5271(p, b, d, a, n, c, x, e): rubi.append(5271) return Int(ExpandIntegrand((a + b*ArcTan(c*x))**n*(d + e*x)**p, x), x) rule5271 = ReplacementRule(pattern5271, replacement5271) pattern5272 = Pattern(Integral((d_ + x_*WC('e', S(1)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*acot(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons464) def replacement5272(p, b, d, a, n, c, x, e): rubi.append(5272) return Int(ExpandIntegrand((a + b*acot(c*x))**n*(d + e*x)**p, x), x) rule5272 = ReplacementRule(pattern5272, replacement5272) pattern5273 = Pattern(Integral((x_*WC('e', S(1)) + WC('d', S(0)))**WC('p', S(1))*(ArcTan(x_*WC('c', S(1)))*WC('b', S(1)) + WC('a', S(0)))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons4, cons5, cons1570) def replacement5273(p, b, d, a, n, c, x, e): rubi.append(5273) return Int((a + b*ArcTan(c*x))**n*(d + e*x)**p, x) rule5273 = ReplacementRule(pattern5273, replacement5273) pattern5274 = Pattern(Integral((x_*WC('e', S(1)) + WC('d', S(0)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*acot(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons4, cons5, cons1570) def replacement5274(p, b, d, a, n, c, x, e): rubi.append(5274) return Int((a + b*acot(c*x))**n*(d + e*x)**p, x) rule5274 = ReplacementRule(pattern5274, replacement5274) pattern5275 = Pattern(Integral(x_**WC('m', S(1))*(ArcTan(x_*WC('c', S(1)))*WC('b', S(1)) + WC('a', S(0)))**WC('n', S(1))/(d_ + x_*WC('e', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons1773, cons148, cons31, cons168) def replacement5275(m, b, d, a, n, c, x, e): rubi.append(5275) return Dist(S(1)/e, Int(x**(m + S(-1))*(a + b*ArcTan(c*x))**n, x), x) - Dist(d/e, Int(x**(m + S(-1))*(a + b*ArcTan(c*x))**n/(d + e*x), x), x) rule5275 = ReplacementRule(pattern5275, replacement5275) pattern5276 = Pattern(Integral(x_**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*acot(x_*WC('c', S(1))))**WC('n', S(1))/(d_ + x_*WC('e', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons1773, cons148, cons31, cons168) def replacement5276(m, b, d, a, n, c, x, e): rubi.append(5276) return Dist(S(1)/e, Int(x**(m + S(-1))*(a + b*acot(c*x))**n, x), x) - Dist(d/e, Int(x**(m + S(-1))*(a + b*acot(c*x))**n/(d + e*x), x), x) rule5276 = ReplacementRule(pattern5276, replacement5276) pattern5277 = Pattern(Integral((ArcTan(x_*WC('c', S(1)))*WC('b', S(1)) + WC('a', S(0)))**WC('n', S(1))/(x_*(d_ + x_*WC('e', S(1)))), x_), cons2, cons3, cons7, cons27, cons48, cons1773, cons148) def replacement5277(b, d, a, n, c, x, e): rubi.append(5277) return -Dist(b*c*n/d, Int((a + b*ArcTan(c*x))**(n + S(-1))*log(S(2)*e*x/(d + e*x))/(c**S(2)*x**S(2) + S(1)), x), x) + Simp((a + b*ArcTan(c*x))**n*log(S(2)*e*x/(d + e*x))/d, x) rule5277 = ReplacementRule(pattern5277, replacement5277) pattern5278 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*acot(x_*WC('c', S(1))))**WC('n', S(1))/(x_*(d_ + x_*WC('e', S(1)))), x_), cons2, cons3, cons7, cons27, cons48, cons1773, cons148) def replacement5278(b, d, a, n, c, x, e): rubi.append(5278) return Dist(b*c*n/d, Int((a + b*acot(c*x))**(n + S(-1))*log(S(2)*e*x/(d + e*x))/(c**S(2)*x**S(2) + S(1)), x), x) + Simp((a + b*acot(c*x))**n*log(S(2)*e*x/(d + e*x))/d, x) rule5278 = ReplacementRule(pattern5278, replacement5278) pattern5279 = Pattern(Integral(x_**m_*(ArcTan(x_*WC('c', S(1)))*WC('b', S(1)) + WC('a', S(0)))**WC('n', S(1))/(d_ + x_*WC('e', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons1773, cons148, cons31, cons94) def replacement5279(m, b, d, a, n, c, x, e): rubi.append(5279) return Dist(S(1)/d, Int(x**m*(a + b*ArcTan(c*x))**n, x), x) - Dist(e/d, Int(x**(m + S(1))*(a + b*ArcTan(c*x))**n/(d + e*x), x), x) rule5279 = ReplacementRule(pattern5279, replacement5279) pattern5280 = Pattern(Integral(x_**m_*(WC('a', S(0)) + WC('b', S(1))*acot(x_*WC('c', S(1))))**WC('n', S(1))/(d_ + x_*WC('e', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons1773, cons148, cons31, cons94) def replacement5280(m, b, d, a, n, c, x, e): rubi.append(5280) return Dist(S(1)/d, Int(x**m*(a + b*acot(c*x))**n, x), x) - Dist(e/d, Int(x**(m + S(1))*(a + b*acot(c*x))**n/(d + e*x), x), x) rule5280 = ReplacementRule(pattern5280, replacement5280) pattern5281 = Pattern(Integral(x_**WC('m', S(1))*(d_ + x_*WC('e', S(1)))**WC('p', S(1))*(ArcTan(x_*WC('c', S(1)))*WC('b', S(1)) + WC('a', S(0)))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons21, cons38, cons148, cons1777) def replacement5281(p, m, b, d, a, n, c, x, e): rubi.append(5281) return Int(ExpandIntegrand(x**m*(a + b*ArcTan(c*x))**n*(d + e*x)**p, x), x) rule5281 = ReplacementRule(pattern5281, replacement5281) pattern5282 = Pattern(Integral(x_**WC('m', S(1))*(d_ + x_*WC('e', S(1)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*acot(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons21, cons38, cons148, cons1777) def replacement5282(p, m, b, d, a, n, c, x, e): rubi.append(5282) return Int(ExpandIntegrand(x**m*(a + b*acot(c*x))**n*(d + e*x)**p, x), x) rule5282 = ReplacementRule(pattern5282, replacement5282) pattern5283 = Pattern(Integral(x_**WC('m', S(1))*(x_*WC('e', S(1)) + WC('d', S(0)))**WC('p', S(1))*(ArcTan(x_*WC('c', S(1)))*WC('b', S(1)) + WC('a', S(0)))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons21, cons4, cons5, cons1497) def replacement5283(p, m, b, d, a, n, c, x, e): rubi.append(5283) return Int(x**m*(a + b*ArcTan(c*x))**n*(d + e*x)**p, x) rule5283 = ReplacementRule(pattern5283, replacement5283) pattern5284 = Pattern(Integral(x_**WC('m', S(1))*(x_*WC('e', S(1)) + WC('d', S(0)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*acot(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons21, cons4, cons5, cons1497) def replacement5284(p, m, b, d, a, n, c, x, e): rubi.append(5284) return Int(x**m*(a + b*acot(c*x))**n*(d + e*x)**p, x) rule5284 = ReplacementRule(pattern5284, replacement5284) pattern5285 = Pattern(Integral((d_ + x_**S(2)*WC('e', S(1)))**WC('p', S(1))*(ArcTan(x_*WC('c', S(1)))*WC('b', S(1)) + WC('a', S(0))), x_), cons2, cons3, cons7, cons27, cons48, cons1778, cons13, cons163) def replacement5285(p, b, d, a, c, x, e): rubi.append(5285) return Dist(S(2)*d*p/(S(2)*p + S(1)), Int((a + b*ArcTan(c*x))*(d + e*x**S(2))**(p + S(-1)), x), x) + Simp(x*(a + b*ArcTan(c*x))*(d + e*x**S(2))**p/(S(2)*p + S(1)), x) - Simp(b*(d + e*x**S(2))**p/(S(2)*c*p*(S(2)*p + S(1))), x) rule5285 = ReplacementRule(pattern5285, replacement5285) pattern5286 = Pattern(Integral((d_ + x_**S(2)*WC('e', S(1)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*acot(x_*WC('c', S(1)))), x_), cons2, cons3, cons7, cons27, cons48, cons1778, cons13, cons163) def replacement5286(p, b, d, a, c, x, e): rubi.append(5286) return Dist(S(2)*d*p/(S(2)*p + S(1)), Int((a + b*acot(c*x))*(d + e*x**S(2))**(p + S(-1)), x), x) + Simp(x*(a + b*acot(c*x))*(d + e*x**S(2))**p/(S(2)*p + S(1)), x) + Simp(b*(d + e*x**S(2))**p/(S(2)*c*p*(S(2)*p + S(1))), x) rule5286 = ReplacementRule(pattern5286, replacement5286) pattern5287 = Pattern(Integral((d_ + x_**S(2)*WC('e', S(1)))**WC('p', S(1))*(ArcTan(x_*WC('c', S(1)))*WC('b', S(1)) + WC('a', S(0)))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons1778, cons338, cons163, cons165) def replacement5287(p, b, d, a, c, n, x, e): rubi.append(5287) return Dist(S(2)*d*p/(S(2)*p + S(1)), Int((a + b*ArcTan(c*x))**n*(d + e*x**S(2))**(p + S(-1)), x), x) + Dist(b**S(2)*d*n*(n + S(-1))/(S(2)*p*(S(2)*p + S(1))), Int((a + b*ArcTan(c*x))**(n + S(-2))*(d + e*x**S(2))**(p + S(-1)), x), x) + Simp(x*(a + b*ArcTan(c*x))**n*(d + e*x**S(2))**p/(S(2)*p + S(1)), x) - Simp(b*n*(a + b*ArcTan(c*x))**(n + S(-1))*(d + e*x**S(2))**p/(S(2)*c*p*(S(2)*p + S(1))), x) rule5287 = ReplacementRule(pattern5287, replacement5287) pattern5288 = Pattern(Integral((d_ + x_**S(2)*WC('e', S(1)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*acot(x_*WC('c', S(1))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons1778, cons338, cons163, cons165) def replacement5288(p, b, d, a, c, n, x, e): rubi.append(5288) return Dist(S(2)*d*p/(S(2)*p + S(1)), Int((a + b*acot(c*x))**n*(d + e*x**S(2))**(p + S(-1)), x), x) + Dist(b**S(2)*d*n*(n + S(-1))/(S(2)*p*(S(2)*p + S(1))), Int((a + b*acot(c*x))**(n + S(-2))*(d + e*x**S(2))**(p + S(-1)), x), x) + Simp(x*(a + b*acot(c*x))**n*(d + e*x**S(2))**p/(S(2)*p + S(1)), x) + Simp(b*n*(a + b*acot(c*x))**(n + S(-1))*(d + e*x**S(2))**p/(S(2)*c*p*(S(2)*p + S(1))), x) rule5288 = ReplacementRule(pattern5288, replacement5288) pattern5289 = Pattern(Integral(S(1)/((d_ + x_**S(2)*WC('e', S(1)))*(ArcTan(x_*WC('c', S(1)))*WC('b', S(1)) + WC('a', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons1778) def replacement5289(b, d, a, c, x, e): rubi.append(5289) return Simp(log(RemoveContent(a + b*ArcTan(c*x), x))/(b*c*d), x) rule5289 = ReplacementRule(pattern5289, replacement5289) pattern5290 = Pattern(Integral(S(1)/((d_ + x_**S(2)*WC('e', S(1)))*(WC('a', S(0)) + WC('b', S(1))*acot(x_*WC('c', S(1))))), x_), cons2, cons3, cons7, cons27, cons48, cons1778) def replacement5290(b, d, a, c, x, e): rubi.append(5290) return -Simp(log(RemoveContent(a + b*acot(c*x), x))/(b*c*d), x) rule5290 = ReplacementRule(pattern5290, replacement5290) pattern5291 = Pattern(Integral((ArcTan(x_*WC('c', S(1)))*WC('b', S(1)) + WC('a', S(0)))**WC('n', S(1))/(d_ + x_**S(2)*WC('e', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons4, cons1778, cons584) def replacement5291(b, d, a, n, c, x, e): rubi.append(5291) return Simp((a + b*ArcTan(c*x))**(n + S(1))/(b*c*d*(n + S(1))), x) rule5291 = ReplacementRule(pattern5291, replacement5291) pattern5292 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*acot(x_*WC('c', S(1))))**WC('n', S(1))/(d_ + x_**S(2)*WC('e', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons4, cons1778, cons584) def replacement5292(b, d, a, n, c, x, e): rubi.append(5292) return -Simp((a + b*acot(c*x))**(n + S(1))/(b*c*d*(n + S(1))), x) rule5292 = ReplacementRule(pattern5292, replacement5292) pattern5293 = Pattern(Integral((ArcTan(x_*WC('c', S(1)))*WC('b', S(1)) + WC('a', S(0)))/sqrt(d_ + x_**S(2)*WC('e', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons1778, cons268) def replacement5293(b, d, a, c, x, e): rubi.append(5293) return Simp(I*b*PolyLog(S(2), -I*sqrt(I*c*x + S(1))/sqrt(-I*c*x + S(1)))/(c*sqrt(d)), x) - Simp(I*b*PolyLog(S(2), I*sqrt(I*c*x + S(1))/sqrt(-I*c*x + S(1)))/(c*sqrt(d)), x) + Simp(-S(2)*I*(a + b*ArcTan(c*x))*ArcTan(sqrt(I*c*x + S(1))/sqrt(-I*c*x + S(1)))/(c*sqrt(d)), x) rule5293 = ReplacementRule(pattern5293, replacement5293) pattern5294 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*acot(x_*WC('c', S(1))))/sqrt(d_ + x_**S(2)*WC('e', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons1778, cons268) def replacement5294(b, d, a, c, x, e): rubi.append(5294) return -Simp(I*b*PolyLog(S(2), -I*sqrt(I*c*x + S(1))/sqrt(-I*c*x + S(1)))/(c*sqrt(d)), x) + Simp(I*b*PolyLog(S(2), I*sqrt(I*c*x + S(1))/sqrt(-I*c*x + S(1)))/(c*sqrt(d)), x) + Simp(-S(2)*I*(a + b*acot(c*x))*ArcTan(sqrt(I*c*x + S(1))/sqrt(-I*c*x + S(1)))/(c*sqrt(d)), x) rule5294 = ReplacementRule(pattern5294, replacement5294) pattern5295 = Pattern(Integral((ArcTan(x_*WC('c', S(1)))*WC('b', S(1)) + WC('a', S(0)))**WC('n', S(1))/sqrt(d_ + x_**S(2)*WC('e', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons1778, cons148, cons268) def replacement5295(b, d, a, n, c, x, e): rubi.append(5295) return Dist(S(1)/(c*sqrt(d)), Subst(Int((a + b*x)**n/cos(x), x), x, ArcTan(c*x)), x) rule5295 = ReplacementRule(pattern5295, replacement5295) pattern5296 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*acot(x_*WC('c', S(1))))**WC('n', S(1))/sqrt(d_ + x_**S(2)*WC('e', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons1778, cons148, cons268) def replacement5296(b, d, a, n, c, x, e): rubi.append(5296) return -Dist(x*sqrt(S(1) + S(1)/(c**S(2)*x**S(2)))/sqrt(d + e*x**S(2)), Subst(Int((a + b*x)**n/sin(x), x), x, acot(c*x)), x) rule5296 = ReplacementRule(pattern5296, replacement5296) pattern5297 = Pattern(Integral((ArcTan(x_*WC('c', S(1)))*WC('b', S(1)) + WC('a', S(0)))**WC('n', S(1))/sqrt(d_ + x_**S(2)*WC('e', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons1778, cons148, cons1738) def replacement5297(b, d, a, n, c, x, e): rubi.append(5297) return Dist(sqrt(c**S(2)*x**S(2) + S(1))/sqrt(d + e*x**S(2)), Int((a + b*ArcTan(c*x))**n/sqrt(c**S(2)*x**S(2) + S(1)), x), x) rule5297 = ReplacementRule(pattern5297, replacement5297) pattern5298 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*acot(x_*WC('c', S(1))))**WC('n', S(1))/sqrt(d_ + x_**S(2)*WC('e', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons1778, cons148, cons1738) def replacement5298(b, d, a, n, c, x, e): rubi.append(5298) return Dist(sqrt(c**S(2)*x**S(2) + S(1))/sqrt(d + e*x**S(2)), Int((a + b*acot(c*x))**n/sqrt(c**S(2)*x**S(2) + S(1)), x), x) rule5298 = ReplacementRule(pattern5298, replacement5298) pattern5299 = Pattern(Integral((ArcTan(x_*WC('c', S(1)))*WC('b', S(1)) + WC('a', S(0)))**WC('n', S(1))/(d_ + x_**S(2)*WC('e', S(1)))**S(2), x_), cons2, cons3, cons7, cons27, cons48, cons1778, cons87, cons88) def replacement5299(b, d, a, n, c, x, e): rubi.append(5299) return -Dist(b*c*n/S(2), Int(x*(a + b*ArcTan(c*x))**(n + S(-1))/(d + e*x**S(2))**S(2), x), x) + Simp(x*(a + b*ArcTan(c*x))**n/(S(2)*d*(d + e*x**S(2))), x) + Simp((a + b*ArcTan(c*x))**(n + S(1))/(S(2)*b*c*d**S(2)*(n + S(1))), x) rule5299 = ReplacementRule(pattern5299, replacement5299) pattern5300 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*acot(x_*WC('c', S(1))))**WC('n', S(1))/(d_ + x_**S(2)*WC('e', S(1)))**S(2), x_), cons2, cons3, cons7, cons27, cons48, cons1778, cons87, cons88) def replacement5300(b, d, a, n, c, x, e): rubi.append(5300) return Dist(b*c*n/S(2), Int(x*(a + b*acot(c*x))**(n + S(-1))/(d + e*x**S(2))**S(2), x), x) + Simp(x*(a + b*acot(c*x))**n/(S(2)*d*(d + e*x**S(2))), x) - Simp((a + b*acot(c*x))**(n + S(1))/(S(2)*b*c*d**S(2)*(n + S(1))), x) rule5300 = ReplacementRule(pattern5300, replacement5300) pattern5301 = Pattern(Integral((ArcTan(x_*WC('c', S(1)))*WC('b', S(1)) + WC('a', S(0)))/(d_ + x_**S(2)*WC('e', S(1)))**(S(3)/2), x_), cons2, cons3, cons7, cons27, cons48, cons1778) def replacement5301(b, d, a, c, x, e): rubi.append(5301) return Simp(b/(c*d*sqrt(d + e*x**S(2))), x) + Simp(x*(a + b*ArcTan(c*x))/(d*sqrt(d + e*x**S(2))), x) rule5301 = ReplacementRule(pattern5301, replacement5301) pattern5302 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*acot(x_*WC('c', S(1))))/(d_ + x_**S(2)*WC('e', S(1)))**(S(3)/2), x_), cons2, cons3, cons7, cons27, cons48, cons1778) def replacement5302(b, d, a, c, x, e): rubi.append(5302) return -Simp(b/(c*d*sqrt(d + e*x**S(2))), x) + Simp(x*(a + b*acot(c*x))/(d*sqrt(d + e*x**S(2))), x) rule5302 = ReplacementRule(pattern5302, replacement5302) pattern5303 = Pattern(Integral((d_ + x_**S(2)*WC('e', S(1)))**p_*(ArcTan(x_*WC('c', S(1)))*WC('b', S(1)) + WC('a', S(0))), x_), cons2, cons3, cons7, cons27, cons48, cons1778, cons13, cons137, cons230) def replacement5303(p, b, d, a, c, x, e): rubi.append(5303) return Dist((S(2)*p + S(3))/(S(2)*d*(p + S(1))), Int((a + b*ArcTan(c*x))*(d + e*x**S(2))**(p + S(1)), x), x) + Simp(b*(d + e*x**S(2))**(p + S(1))/(S(4)*c*d*(p + S(1))**S(2)), x) - Simp(x*(a + b*ArcTan(c*x))*(d + e*x**S(2))**(p + S(1))/(S(2)*d*(p + S(1))), x) rule5303 = ReplacementRule(pattern5303, replacement5303) pattern5304 = Pattern(Integral((d_ + x_**S(2)*WC('e', S(1)))**p_*(WC('a', S(0)) + WC('b', S(1))*acot(x_*WC('c', S(1)))), x_), cons2, cons3, cons7, cons27, cons48, cons1778, cons13, cons137, cons230) def replacement5304(p, b, d, a, c, x, e): rubi.append(5304) return Dist((S(2)*p + S(3))/(S(2)*d*(p + S(1))), Int((a + b*acot(c*x))*(d + e*x**S(2))**(p + S(1)), x), x) - Simp(b*(d + e*x**S(2))**(p + S(1))/(S(4)*c*d*(p + S(1))**S(2)), x) - Simp(x*(a + b*acot(c*x))*(d + e*x**S(2))**(p + S(1))/(S(2)*d*(p + S(1))), x) rule5304 = ReplacementRule(pattern5304, replacement5304) pattern5305 = Pattern(Integral((ArcTan(x_*WC('c', S(1)))*WC('b', S(1)) + WC('a', S(0)))**n_/(d_ + x_**S(2)*WC('e', S(1)))**(S(3)/2), x_), cons2, cons3, cons7, cons27, cons48, cons1778, cons87, cons165) def replacement5305(b, d, a, c, n, x, e): rubi.append(5305) return -Dist(b**S(2)*n*(n + S(-1)), Int((a + b*ArcTan(c*x))**(n + S(-2))/(d + e*x**S(2))**(S(3)/2), x), x) + Simp(x*(a + b*ArcTan(c*x))**n/(d*sqrt(d + e*x**S(2))), x) + Simp(b*n*(a + b*ArcTan(c*x))**(n + S(-1))/(c*d*sqrt(d + e*x**S(2))), x) rule5305 = ReplacementRule(pattern5305, replacement5305) pattern5306 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*acot(x_*WC('c', S(1))))**n_/(d_ + x_**S(2)*WC('e', S(1)))**(S(3)/2), x_), cons2, cons3, cons7, cons27, cons48, cons1778, cons87, cons165) def replacement5306(b, d, a, c, n, x, e): rubi.append(5306) return -Dist(b**S(2)*n*(n + S(-1)), Int((a + b*acot(c*x))**(n + S(-2))/(d + e*x**S(2))**(S(3)/2), x), x) + Simp(x*(a + b*acot(c*x))**n/(d*sqrt(d + e*x**S(2))), x) - Simp(b*n*(a + b*acot(c*x))**(n + S(-1))/(c*d*sqrt(d + e*x**S(2))), x) rule5306 = ReplacementRule(pattern5306, replacement5306) pattern5307 = Pattern(Integral((d_ + x_**S(2)*WC('e', S(1)))**p_*(ArcTan(x_*WC('c', S(1)))*WC('b', S(1)) + WC('a', S(0)))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons1778, cons338, cons137, cons165, cons230) def replacement5307(p, b, d, a, c, n, x, e): rubi.append(5307) return Dist((S(2)*p + S(3))/(S(2)*d*(p + S(1))), Int((a + b*ArcTan(c*x))**n*(d + e*x**S(2))**(p + S(1)), x), x) - Dist(b**S(2)*n*(n + S(-1))/(S(4)*(p + S(1))**S(2)), Int((a + b*ArcTan(c*x))**(n + S(-2))*(d + e*x**S(2))**p, x), x) - Simp(x*(a + b*ArcTan(c*x))**n*(d + e*x**S(2))**(p + S(1))/(S(2)*d*(p + S(1))), x) + Simp(b*n*(a + b*ArcTan(c*x))**(n + S(-1))*(d + e*x**S(2))**(p + S(1))/(S(4)*c*d*(p + S(1))**S(2)), x) rule5307 = ReplacementRule(pattern5307, replacement5307) pattern5308 = Pattern(Integral((d_ + x_**S(2)*WC('e', S(1)))**p_*(WC('a', S(0)) + WC('b', S(1))*acot(x_*WC('c', S(1))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons1778, cons338, cons137, cons165, cons230) def replacement5308(p, b, d, a, c, n, x, e): rubi.append(5308) return Dist((S(2)*p + S(3))/(S(2)*d*(p + S(1))), Int((a + b*acot(c*x))**n*(d + e*x**S(2))**(p + S(1)), x), x) - Dist(b**S(2)*n*(n + S(-1))/(S(4)*(p + S(1))**S(2)), Int((a + b*acot(c*x))**(n + S(-2))*(d + e*x**S(2))**p, x), x) - Simp(x*(a + b*acot(c*x))**n*(d + e*x**S(2))**(p + S(1))/(S(2)*d*(p + S(1))), x) - Simp(b*n*(a + b*acot(c*x))**(n + S(-1))*(d + e*x**S(2))**(p + S(1))/(S(4)*c*d*(p + S(1))**S(2)), x) rule5308 = ReplacementRule(pattern5308, replacement5308) pattern5309 = Pattern(Integral((d_ + x_**S(2)*WC('e', S(1)))**p_*(ArcTan(x_*WC('c', S(1)))*WC('b', S(1)) + WC('a', S(0)))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons1778, cons338, cons137, cons89) def replacement5309(p, b, d, a, c, n, x, e): rubi.append(5309) return -Dist(S(2)*c*(p + S(1))/(b*(n + S(1))), Int(x*(a + b*ArcTan(c*x))**(n + S(1))*(d + e*x**S(2))**p, x), x) + Simp((a + b*ArcTan(c*x))**(n + S(1))*(d + e*x**S(2))**(p + S(1))/(b*c*d*(n + S(1))), x) rule5309 = ReplacementRule(pattern5309, replacement5309) pattern5310 = Pattern(Integral((d_ + x_**S(2)*WC('e', S(1)))**p_*(WC('a', S(0)) + WC('b', S(1))*acot(x_*WC('c', S(1))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons1778, cons338, cons137, cons89) def replacement5310(p, b, d, a, c, n, x, e): rubi.append(5310) return Dist(S(2)*c*(p + S(1))/(b*(n + S(1))), Int(x*(a + b*acot(c*x))**(n + S(1))*(d + e*x**S(2))**p, x), x) - Simp((a + b*acot(c*x))**(n + S(1))*(d + e*x**S(2))**(p + S(1))/(b*c*d*(n + S(1))), x) rule5310 = ReplacementRule(pattern5310, replacement5310) pattern5311 = Pattern(Integral((d_ + x_**S(2)*WC('e', S(1)))**p_*(ArcTan(x_*WC('c', S(1)))*WC('b', S(1)) + WC('a', S(0)))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons4, cons1778, cons1779, cons1740) def replacement5311(p, b, d, a, n, c, x, e): rubi.append(5311) return Dist(d**p/c, Subst(Int((a + b*x)**n*cos(x)**(-S(2)*p + S(-2)), x), x, ArcTan(c*x)), x) rule5311 = ReplacementRule(pattern5311, replacement5311) pattern5312 = Pattern(Integral((d_ + x_**S(2)*WC('e', S(1)))**p_*(ArcTan(x_*WC('c', S(1)))*WC('b', S(1)) + WC('a', S(0)))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons4, cons1778, cons1779, cons1741) def replacement5312(p, b, d, a, n, c, x, e): rubi.append(5312) return Dist(d**(p + S(1)/2)*sqrt(c**S(2)*x**S(2) + S(1))/sqrt(d + e*x**S(2)), Int((a + b*ArcTan(c*x))**n*(c**S(2)*x**S(2) + S(1))**p, x), x) rule5312 = ReplacementRule(pattern5312, replacement5312) pattern5313 = Pattern(Integral((d_ + x_**S(2)*WC('e', S(1)))**p_*(WC('a', S(0)) + WC('b', S(1))*acot(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons4, cons1778, cons1779, cons38) def replacement5313(p, b, d, a, n, c, x, e): rubi.append(5313) return -Dist(d**p/c, Subst(Int((a + b*x)**n*sin(x)**(-S(2)*p + S(-2)), x), x, acot(c*x)), x) rule5313 = ReplacementRule(pattern5313, replacement5313) pattern5314 = Pattern(Integral((d_ + x_**S(2)*WC('e', S(1)))**p_*(WC('a', S(0)) + WC('b', S(1))*acot(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons4, cons1778, cons1779, cons147) def replacement5314(p, b, d, a, n, c, x, e): rubi.append(5314) return -Dist(d**(p + S(1)/2)*x*sqrt((c**S(2)*x**S(2) + S(1))/(c**S(2)*x**S(2)))/sqrt(d + e*x**S(2)), Subst(Int((a + b*x)**n*sin(x)**(-S(2)*p + S(-2)), x), x, acot(c*x)), x) rule5314 = ReplacementRule(pattern5314, replacement5314) pattern5315 = Pattern(Integral(ArcTan(x_*WC('c', S(1)))/(x_**S(2)*WC('e', S(1)) + WC('d', S(0))), x_), cons7, cons27, cons48, cons1776) def replacement5315(d, c, x, e): rubi.append(5315) return Dist(I/S(2), Int(log(-I*c*x + S(1))/(d + e*x**S(2)), x), x) - Dist(I/S(2), Int(log(I*c*x + S(1))/(d + e*x**S(2)), x), x) rule5315 = ReplacementRule(pattern5315, replacement5315) pattern5316 = Pattern(Integral(acot(x_*WC('c', S(1)))/(x_**S(2)*WC('e', S(1)) + WC('d', S(0))), x_), cons7, cons27, cons48, cons1776) def replacement5316(d, c, x, e): rubi.append(5316) return Dist(I/S(2), Int(log(S(1) - I/(c*x))/(d + e*x**S(2)), x), x) - Dist(I/S(2), Int(log(S(1) + I/(c*x))/(d + e*x**S(2)), x), x) rule5316 = ReplacementRule(pattern5316, replacement5316) pattern5317 = Pattern(Integral((a_ + ArcTan(x_*WC('c', S(1)))*WC('b', S(1)))/(x_**S(2)*WC('e', S(1)) + WC('d', S(0))), x_), cons2, cons3, cons7, cons27, cons48, cons1043) def replacement5317(b, d, c, a, x, e): rubi.append(5317) return Dist(a, Int(S(1)/(d + e*x**S(2)), x), x) + Dist(b, Int(ArcTan(c*x)/(d + e*x**S(2)), x), x) rule5317 = ReplacementRule(pattern5317, replacement5317) pattern5318 = Pattern(Integral((a_ + WC('b', S(1))*acot(x_*WC('c', S(1))))/(x_**S(2)*WC('e', S(1)) + WC('d', S(0))), x_), cons2, cons3, cons7, cons27, cons48, cons1043) def replacement5318(b, d, c, a, x, e): rubi.append(5318) return Dist(a, Int(S(1)/(d + e*x**S(2)), x), x) + Dist(b, Int(acot(c*x)/(d + e*x**S(2)), x), x) rule5318 = ReplacementRule(pattern5318, replacement5318) def With5319(p, b, d, a, c, x, e): u = IntHide((d + e*x**S(2))**p, x) rubi.append(5319) return -Dist(b*c, Int(ExpandIntegrand(u/(c**S(2)*x**S(2) + S(1)), x), x), x) + Dist(a + b*ArcTan(c*x), u, x) pattern5319 = Pattern(Integral((x_**S(2)*WC('e', S(1)) + WC('d', S(0)))**WC('p', S(1))*(ArcTan(x_*WC('c', S(1)))*WC('b', S(1)) + WC('a', S(0))), x_), cons2, cons3, cons7, cons27, cons48, cons1780) rule5319 = ReplacementRule(pattern5319, With5319) def With5320(p, b, d, a, c, x, e): u = IntHide((d + e*x**S(2))**p, x) rubi.append(5320) return Dist(b*c, Int(ExpandIntegrand(u/(c**S(2)*x**S(2) + S(1)), x), x), x) + Dist(a + b*acot(c*x), u, x) pattern5320 = Pattern(Integral((x_**S(2)*WC('e', S(1)) + WC('d', S(0)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*acot(x_*WC('c', S(1)))), x_), cons2, cons3, cons7, cons27, cons48, cons1780) rule5320 = ReplacementRule(pattern5320, With5320) pattern5321 = Pattern(Integral((d_ + x_**S(2)*WC('e', S(1)))**WC('p', S(1))*(ArcTan(x_*WC('c', S(1)))*WC('b', S(1)) + WC('a', S(0)))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons38, cons148) def replacement5321(p, b, d, a, n, c, x, e): rubi.append(5321) return Int(ExpandIntegrand((a + b*ArcTan(c*x))**n*(d + e*x**S(2))**p, x), x) rule5321 = ReplacementRule(pattern5321, replacement5321) pattern5322 = Pattern(Integral((d_ + x_**S(2)*WC('e', S(1)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*acot(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons38, cons148) def replacement5322(p, b, d, a, n, c, x, e): rubi.append(5322) return Int(ExpandIntegrand((a + b*acot(c*x))**n*(d + e*x**S(2))**p, x), x) rule5322 = ReplacementRule(pattern5322, replacement5322) pattern5323 = Pattern(Integral((x_**S(2)*WC('e', S(1)) + WC('d', S(0)))**WC('p', S(1))*(ArcTan(x_*WC('c', S(1)))*WC('b', S(1)) + WC('a', S(0)))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons4, cons5, cons1570) def replacement5323(p, b, d, a, n, c, x, e): rubi.append(5323) return Int((a + b*ArcTan(c*x))**n*(d + e*x**S(2))**p, x) rule5323 = ReplacementRule(pattern5323, replacement5323) pattern5324 = Pattern(Integral((x_**S(2)*WC('e', S(1)) + WC('d', S(0)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*acot(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons4, cons5, cons1570) def replacement5324(p, b, d, a, n, c, x, e): rubi.append(5324) return Int((a + b*acot(c*x))**n*(d + e*x**S(2))**p, x) rule5324 = ReplacementRule(pattern5324, replacement5324) pattern5325 = Pattern(Integral(x_**m_*(ArcTan(x_*WC('c', S(1)))*WC('b', S(1)) + WC('a', S(0)))**WC('n', S(1))/(d_ + x_**S(2)*WC('e', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons93, cons88, cons166) def replacement5325(m, b, d, a, n, c, x, e): rubi.append(5325) return Dist(S(1)/e, Int(x**(m + S(-2))*(a + b*ArcTan(c*x))**n, x), x) - Dist(d/e, Int(x**(m + S(-2))*(a + b*ArcTan(c*x))**n/(d + e*x**S(2)), x), x) rule5325 = ReplacementRule(pattern5325, replacement5325) pattern5326 = Pattern(Integral(x_**m_*(WC('a', S(0)) + WC('b', S(1))*acot(x_*WC('c', S(1))))**WC('n', S(1))/(d_ + x_**S(2)*WC('e', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons93, cons88, cons166) def replacement5326(m, b, d, a, n, c, x, e): rubi.append(5326) return Dist(S(1)/e, Int(x**(m + S(-2))*(a + b*acot(c*x))**n, x), x) - Dist(d/e, Int(x**(m + S(-2))*(a + b*acot(c*x))**n/(d + e*x**S(2)), x), x) rule5326 = ReplacementRule(pattern5326, replacement5326) pattern5327 = Pattern(Integral(x_**m_*(ArcTan(x_*WC('c', S(1)))*WC('b', S(1)) + WC('a', S(0)))**WC('n', S(1))/(d_ + x_**S(2)*WC('e', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons93, cons88, cons94) def replacement5327(m, b, d, a, n, c, x, e): rubi.append(5327) return Dist(S(1)/d, Int(x**m*(a + b*ArcTan(c*x))**n, x), x) - Dist(e/d, Int(x**(m + S(2))*(a + b*ArcTan(c*x))**n/(d + e*x**S(2)), x), x) rule5327 = ReplacementRule(pattern5327, replacement5327) pattern5328 = Pattern(Integral(x_**m_*(WC('a', S(0)) + WC('b', S(1))*acot(x_*WC('c', S(1))))**WC('n', S(1))/(d_ + x_**S(2)*WC('e', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons93, cons88, cons94) def replacement5328(m, b, d, a, n, c, x, e): rubi.append(5328) return Dist(S(1)/d, Int(x**m*(a + b*acot(c*x))**n, x), x) - Dist(e/d, Int(x**(m + S(2))*(a + b*acot(c*x))**n/(d + e*x**S(2)), x), x) rule5328 = ReplacementRule(pattern5328, replacement5328) pattern5329 = Pattern(Integral(x_*(ArcTan(x_*WC('c', S(1)))*WC('b', S(1)) + WC('a', S(0)))**WC('n', S(1))/(d_ + x_**S(2)*WC('e', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons1778, cons148) def replacement5329(b, d, a, n, c, x, e): rubi.append(5329) return -Dist(S(1)/(c*d), Int((a + b*ArcTan(c*x))**n/(-c*x + I), x), x) - Simp(I*(a + b*ArcTan(c*x))**(n + S(1))/(b*e*(n + S(1))), x) rule5329 = ReplacementRule(pattern5329, replacement5329) pattern5330 = Pattern(Integral(x_*(WC('a', S(0)) + WC('b', S(1))*acot(x_*WC('c', S(1))))**WC('n', S(1))/(d_ + x_**S(2)*WC('e', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons1778, cons148) def replacement5330(b, d, a, n, c, x, e): rubi.append(5330) return -Dist(S(1)/(c*d), Int((a + b*acot(c*x))**n/(-c*x + I), x), x) + Simp(I*(a + b*acot(c*x))**(n + S(1))/(b*e*(n + S(1))), x) rule5330 = ReplacementRule(pattern5330, replacement5330) pattern5331 = Pattern(Integral(x_*(ArcTan(x_*WC('c', S(1)))*WC('b', S(1)) + WC('a', S(0)))**n_/(d_ + x_**S(2)*WC('e', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons1778, cons340, cons584) def replacement5331(b, d, a, c, n, x, e): rubi.append(5331) return -Dist(S(1)/(b*c*d*(n + S(1))), Int((a + b*ArcTan(c*x))**(n + S(1)), x), x) + Simp(x*(a + b*ArcTan(c*x))**(n + S(1))/(b*c*d*(n + S(1))), x) rule5331 = ReplacementRule(pattern5331, replacement5331) pattern5332 = Pattern(Integral(x_*(WC('a', S(0)) + WC('b', S(1))*acot(x_*WC('c', S(1))))**n_/(d_ + x_**S(2)*WC('e', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons1778, cons340, cons584) def replacement5332(b, d, a, c, n, x, e): rubi.append(5332) return Dist(S(1)/(b*c*d*(n + S(1))), Int((a + b*acot(c*x))**(n + S(1)), x), x) - Simp(x*(a + b*acot(c*x))**(n + S(1))/(b*c*d*(n + S(1))), x) rule5332 = ReplacementRule(pattern5332, replacement5332) pattern5333 = Pattern(Integral(x_**m_*(ArcTan(x_*WC('c', S(1)))*WC('b', S(1)) + WC('a', S(0)))**WC('n', S(1))/(d_ + x_**S(2)*WC('e', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons1778, cons93, cons88, cons166) def replacement5333(m, b, d, a, n, c, x, e): rubi.append(5333) return Dist(S(1)/e, Int(x**(m + S(-2))*(a + b*ArcTan(c*x))**n, x), x) - Dist(d/e, Int(x**(m + S(-2))*(a + b*ArcTan(c*x))**n/(d + e*x**S(2)), x), x) rule5333 = ReplacementRule(pattern5333, replacement5333) pattern5334 = Pattern(Integral(x_**m_*(WC('a', S(0)) + WC('b', S(1))*acot(x_*WC('c', S(1))))**WC('n', S(1))/(d_ + x_**S(2)*WC('e', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons1778, cons93, cons88, cons166) def replacement5334(m, b, d, a, n, c, x, e): rubi.append(5334) return Dist(S(1)/e, Int(x**(m + S(-2))*(a + b*acot(c*x))**n, x), x) - Dist(d/e, Int(x**(m + S(-2))*(a + b*acot(c*x))**n/(d + e*x**S(2)), x), x) rule5334 = ReplacementRule(pattern5334, replacement5334) pattern5335 = Pattern(Integral((ArcTan(x_*WC('c', S(1)))*WC('b', S(1)) + WC('a', S(0)))**WC('n', S(1))/(x_*(d_ + x_**S(2)*WC('e', S(1)))), x_), cons2, cons3, cons7, cons27, cons48, cons1778, cons87, cons88) def replacement5335(b, d, a, n, c, x, e): rubi.append(5335) return Dist(I/d, Int((a + b*ArcTan(c*x))**n/(x*(c*x + I)), x), x) - Simp(I*(a + b*ArcTan(c*x))**(n + S(1))/(b*d*(n + S(1))), x) rule5335 = ReplacementRule(pattern5335, replacement5335) pattern5336 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*acot(x_*WC('c', S(1))))**WC('n', S(1))/(x_*(d_ + x_**S(2)*WC('e', S(1)))), x_), cons2, cons3, cons7, cons27, cons48, cons1778, cons87, cons88) def replacement5336(b, d, a, n, c, x, e): rubi.append(5336) return Dist(I/d, Int((a + b*acot(c*x))**n/(x*(c*x + I)), x), x) + Simp(I*(a + b*acot(c*x))**(n + S(1))/(b*d*(n + S(1))), x) rule5336 = ReplacementRule(pattern5336, replacement5336) pattern5337 = Pattern(Integral(x_**m_*(ArcTan(x_*WC('c', S(1)))*WC('b', S(1)) + WC('a', S(0)))**WC('n', S(1))/(d_ + x_**S(2)*WC('e', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons1778, cons93, cons88, cons94) def replacement5337(m, b, d, a, n, c, x, e): rubi.append(5337) return Dist(S(1)/d, Int(x**m*(a + b*ArcTan(c*x))**n, x), x) - Dist(e/d, Int(x**(m + S(2))*(a + b*ArcTan(c*x))**n/(d + e*x**S(2)), x), x) rule5337 = ReplacementRule(pattern5337, replacement5337) pattern5338 = Pattern(Integral(x_**m_*(WC('a', S(0)) + WC('b', S(1))*acot(x_*WC('c', S(1))))**WC('n', S(1))/(d_ + x_**S(2)*WC('e', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons1778, cons93, cons88, cons94) def replacement5338(m, b, d, a, n, c, x, e): rubi.append(5338) return Dist(S(1)/d, Int(x**m*(a + b*acot(c*x))**n, x), x) - Dist(e/d, Int(x**(m + S(2))*(a + b*acot(c*x))**n/(d + e*x**S(2)), x), x) rule5338 = ReplacementRule(pattern5338, replacement5338) pattern5339 = Pattern(Integral(x_**m_*(ArcTan(x_*WC('c', S(1)))*WC('b', S(1)) + WC('a', S(0)))**n_/(d_ + x_**S(2)*WC('e', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons21, cons1778, cons87, cons89) def replacement5339(m, b, d, a, c, n, x, e): rubi.append(5339) return -Dist(m/(b*c*d*(n + S(1))), Int(x**(m + S(-1))*(a + b*ArcTan(c*x))**(n + S(1)), x), x) + Simp(x**m*(a + b*ArcTan(c*x))**(n + S(1))/(b*c*d*(n + S(1))), x) rule5339 = ReplacementRule(pattern5339, replacement5339) pattern5340 = Pattern(Integral(x_**m_*(WC('a', S(0)) + WC('b', S(1))*acot(x_*WC('c', S(1))))**n_/(d_ + x_**S(2)*WC('e', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons21, cons1778, cons87, cons89) def replacement5340(m, b, d, a, c, n, x, e): rubi.append(5340) return Dist(m/(b*c*d*(n + S(1))), Int(x**(m + S(-1))*(a + b*acot(c*x))**(n + S(1)), x), x) - Simp(x**m*(a + b*acot(c*x))**(n + S(1))/(b*c*d*(n + S(1))), x) rule5340 = ReplacementRule(pattern5340, replacement5340) pattern5341 = Pattern(Integral(x_**WC('m', S(1))*(ArcTan(x_*WC('c', S(1)))*WC('b', S(1)) + WC('a', S(0)))/(d_ + x_**S(2)*WC('e', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons17, cons1781) def replacement5341(m, b, d, a, c, x, e): rubi.append(5341) return Int(ExpandIntegrand(a + b*ArcTan(c*x), x**m/(d + e*x**S(2)), x), x) rule5341 = ReplacementRule(pattern5341, replacement5341) pattern5342 = Pattern(Integral(x_**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*acot(x_*WC('c', S(1))))/(d_ + x_**S(2)*WC('e', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons17, cons1781) def replacement5342(m, b, d, a, c, x, e): rubi.append(5342) return Int(ExpandIntegrand(a + b*acot(c*x), x**m/(d + e*x**S(2)), x), x) rule5342 = ReplacementRule(pattern5342, replacement5342) pattern5343 = Pattern(Integral(x_*(d_ + x_**S(2)*WC('e', S(1)))**WC('p', S(1))*(ArcTan(x_*WC('c', S(1)))*WC('b', S(1)) + WC('a', S(0)))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons5, cons1778, cons87, cons88, cons54) def replacement5343(p, b, d, a, n, c, x, e): rubi.append(5343) return -Dist(b*n/(S(2)*c*(p + S(1))), Int((a + b*ArcTan(c*x))**(n + S(-1))*(d + e*x**S(2))**p, x), x) + Simp((a + b*ArcTan(c*x))**n*(d + e*x**S(2))**(p + S(1))/(S(2)*e*(p + S(1))), x) rule5343 = ReplacementRule(pattern5343, replacement5343) pattern5344 = Pattern(Integral(x_*(d_ + x_**S(2)*WC('e', S(1)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*acot(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons5, cons1778, cons87, cons88, cons54) def replacement5344(p, b, d, a, n, c, x, e): rubi.append(5344) return Dist(b*n/(S(2)*c*(p + S(1))), Int((a + b*acot(c*x))**(n + S(-1))*(d + e*x**S(2))**p, x), x) + Simp((a + b*acot(c*x))**n*(d + e*x**S(2))**(p + S(1))/(S(2)*e*(p + S(1))), x) rule5344 = ReplacementRule(pattern5344, replacement5344) pattern5345 = Pattern(Integral(x_*(ArcTan(x_*WC('c', S(1)))*WC('b', S(1)) + WC('a', S(0)))**n_/(d_ + x_**S(2)*WC('e', S(1)))**S(2), x_), cons2, cons3, cons7, cons27, cons48, cons1778, cons87, cons89, cons1442) def replacement5345(b, d, a, c, n, x, e): rubi.append(5345) return -Dist(S(4)/(b**S(2)*(n + S(1))*(n + S(2))), Int(x*(a + b*ArcTan(c*x))**(n + S(2))/(d + e*x**S(2))**S(2), x), x) - Simp((a + b*ArcTan(c*x))**(n + S(2))*(-c**S(2)*x**S(2) + S(1))/(b**S(2)*e*(d + e*x**S(2))*(n + S(1))*(n + S(2))), x) + Simp(x*(a + b*ArcTan(c*x))**(n + S(1))/(b*c*d*(d + e*x**S(2))*(n + S(1))), x) rule5345 = ReplacementRule(pattern5345, replacement5345) pattern5346 = Pattern(Integral(x_*(WC('a', S(0)) + WC('b', S(1))*acot(x_*WC('c', S(1))))**n_/(d_ + x_**S(2)*WC('e', S(1)))**S(2), x_), cons2, cons3, cons7, cons27, cons48, cons1778, cons87, cons89, cons1442) def replacement5346(b, d, a, c, n, x, e): rubi.append(5346) return -Dist(S(4)/(b**S(2)*(n + S(1))*(n + S(2))), Int(x*(a + b*acot(c*x))**(n + S(2))/(d + e*x**S(2))**S(2), x), x) - Simp((a + b*acot(c*x))**(n + S(2))*(-c**S(2)*x**S(2) + S(1))/(b**S(2)*e*(d + e*x**S(2))*(n + S(1))*(n + S(2))), x) - Simp(x*(a + b*acot(c*x))**(n + S(1))/(b*c*d*(d + e*x**S(2))*(n + S(1))), x) rule5346 = ReplacementRule(pattern5346, replacement5346) pattern5347 = Pattern(Integral(x_**S(2)*(d_ + x_**S(2)*WC('e', S(1)))**p_*(ArcTan(x_*WC('c', S(1)))*WC('b', S(1)) + WC('a', S(0))), x_), cons2, cons3, cons7, cons27, cons48, cons1778, cons13, cons137, cons1782) def replacement5347(p, b, d, a, c, x, e): rubi.append(5347) return -Dist(S(1)/(S(2)*c**S(2)*d*(p + S(1))), Int((a + b*ArcTan(c*x))*(d + e*x**S(2))**(p + S(1)), x), x) - Simp(b*(d + e*x**S(2))**(p + S(1))/(S(4)*c**S(3)*d*(p + S(1))**S(2)), x) + Simp(x*(a + b*ArcTan(c*x))*(d + e*x**S(2))**(p + S(1))/(S(2)*c**S(2)*d*(p + S(1))), x) rule5347 = ReplacementRule(pattern5347, replacement5347) pattern5348 = Pattern(Integral(x_**S(2)*(d_ + x_**S(2)*WC('e', S(1)))**p_*(WC('a', S(0)) + WC('b', S(1))*acot(x_*WC('c', S(1)))), x_), cons2, cons3, cons7, cons27, cons48, cons1778, cons13, cons137, cons1782) def replacement5348(p, b, d, a, c, x, e): rubi.append(5348) return -Dist(S(1)/(S(2)*c**S(2)*d*(p + S(1))), Int((a + b*acot(c*x))*(d + e*x**S(2))**(p + S(1)), x), x) + Simp(b*(d + e*x**S(2))**(p + S(1))/(S(4)*c**S(3)*d*(p + S(1))**S(2)), x) + Simp(x*(a + b*acot(c*x))*(d + e*x**S(2))**(p + S(1))/(S(2)*c**S(2)*d*(p + S(1))), x) rule5348 = ReplacementRule(pattern5348, replacement5348) pattern5349 = Pattern(Integral(x_**S(2)*(ArcTan(x_*WC('c', S(1)))*WC('b', S(1)) + WC('a', S(0)))**WC('n', S(1))/(d_ + x_**S(2)*WC('e', S(1)))**S(2), x_), cons2, cons3, cons7, cons27, cons48, cons1778, cons87, cons88) def replacement5349(b, d, a, n, c, x, e): rubi.append(5349) return Dist(b*n/(S(2)*c), Int(x*(a + b*ArcTan(c*x))**(n + S(-1))/(d + e*x**S(2))**S(2), x), x) + Simp((a + b*ArcTan(c*x))**(n + S(1))/(S(2)*b*c**S(3)*d**S(2)*(n + S(1))), x) - Simp(x*(a + b*ArcTan(c*x))**n/(S(2)*c**S(2)*d*(d + e*x**S(2))), x) rule5349 = ReplacementRule(pattern5349, replacement5349) pattern5350 = Pattern(Integral(x_**S(2)*(WC('a', S(0)) + WC('b', S(1))*acot(x_*WC('c', S(1))))**WC('n', S(1))/(d_ + x_**S(2)*WC('e', S(1)))**S(2), x_), cons2, cons3, cons7, cons27, cons48, cons1778, cons87, cons88) def replacement5350(b, d, a, n, c, x, e): rubi.append(5350) return -Dist(b*n/(S(2)*c), Int(x*(a + b*acot(c*x))**(n + S(-1))/(d + e*x**S(2))**S(2), x), x) - Simp((a + b*acot(c*x))**(n + S(1))/(S(2)*b*c**S(3)*d**S(2)*(n + S(1))), x) - Simp(x*(a + b*acot(c*x))**n/(S(2)*c**S(2)*d*(d + e*x**S(2))), x) rule5350 = ReplacementRule(pattern5350, replacement5350) pattern5351 = Pattern(Integral(x_**m_*(d_ + x_**S(2)*WC('e', S(1)))**p_*(ArcTan(x_*WC('c', S(1)))*WC('b', S(1)) + WC('a', S(0))), x_), cons2, cons3, cons7, cons27, cons48, cons1778, cons240, cons13, cons137) def replacement5351(p, m, b, d, a, c, x, e): rubi.append(5351) return Dist((m + S(-1))/(c**S(2)*d*m), Int(x**(m + S(-2))*(a + b*ArcTan(c*x))*(d + e*x**S(2))**(p + S(1)), x), x) + Simp(b*x**m*(d + e*x**S(2))**(p + S(1))/(c*d*m**S(2)), x) - Simp(x**(m + S(-1))*(a + b*ArcTan(c*x))*(d + e*x**S(2))**(p + S(1))/(c**S(2)*d*m), x) rule5351 = ReplacementRule(pattern5351, replacement5351) pattern5352 = Pattern(Integral(x_**m_*(d_ + x_**S(2)*WC('e', S(1)))**p_*(WC('a', S(0)) + WC('b', S(1))*acot(x_*WC('c', S(1)))), x_), cons2, cons3, cons7, cons27, cons48, cons1778, cons240, cons13, cons137) def replacement5352(p, m, b, d, a, c, x, e): rubi.append(5352) return Dist((m + S(-1))/(c**S(2)*d*m), Int(x**(m + S(-2))*(a + b*acot(c*x))*(d + e*x**S(2))**(p + S(1)), x), x) - Simp(b*x**m*(d + e*x**S(2))**(p + S(1))/(c*d*m**S(2)), x) - Simp(x**(m + S(-1))*(a + b*acot(c*x))*(d + e*x**S(2))**(p + S(1))/(c**S(2)*d*m), x) rule5352 = ReplacementRule(pattern5352, replacement5352) pattern5353 = Pattern(Integral(x_**m_*(d_ + x_**S(2)*WC('e', S(1)))**p_*(ArcTan(x_*WC('c', S(1)))*WC('b', S(1)) + WC('a', S(0)))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons21, cons1778, cons240, cons338, cons137, cons165) def replacement5353(p, m, b, d, a, c, n, x, e): rubi.append(5353) return -Dist(b**S(2)*n*(n + S(-1))/m**S(2), Int(x**m*(a + b*ArcTan(c*x))**(n + S(-2))*(d + e*x**S(2))**p, x), x) + Dist((m + S(-1))/(c**S(2)*d*m), Int(x**(m + S(-2))*(a + b*ArcTan(c*x))**n*(d + e*x**S(2))**(p + S(1)), x), x) - Simp(x**(m + S(-1))*(a + b*ArcTan(c*x))**n*(d + e*x**S(2))**(p + S(1))/(c**S(2)*d*m), x) + Simp(b*n*x**m*(a + b*ArcTan(c*x))**(n + S(-1))*(d + e*x**S(2))**(p + S(1))/(c*d*m**S(2)), x) rule5353 = ReplacementRule(pattern5353, replacement5353) pattern5354 = Pattern(Integral(x_**m_*(d_ + x_**S(2)*WC('e', S(1)))**p_*(WC('a', S(0)) + WC('b', S(1))*acot(x_*WC('c', S(1))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons21, cons1778, cons240, cons338, cons137, cons165) def replacement5354(p, m, b, d, a, c, n, x, e): rubi.append(5354) return -Dist(b**S(2)*n*(n + S(-1))/m**S(2), Int(x**m*(a + b*acot(c*x))**(n + S(-2))*(d + e*x**S(2))**p, x), x) + Dist((m + S(-1))/(c**S(2)*d*m), Int(x**(m + S(-2))*(a + b*acot(c*x))**n*(d + e*x**S(2))**(p + S(1)), x), x) - Simp(x**(m + S(-1))*(a + b*acot(c*x))**n*(d + e*x**S(2))**(p + S(1))/(c**S(2)*d*m), x) - Simp(b*n*x**m*(a + b*acot(c*x))**(n + S(-1))*(d + e*x**S(2))**(p + S(1))/(c*d*m**S(2)), x) rule5354 = ReplacementRule(pattern5354, replacement5354) pattern5355 = Pattern(Integral(x_**WC('m', S(1))*(d_ + x_**S(2)*WC('e', S(1)))**WC('p', S(1))*(ArcTan(x_*WC('c', S(1)))*WC('b', S(1)) + WC('a', S(0)))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons21, cons5, cons1778, cons240, cons87, cons89) def replacement5355(p, m, b, d, a, c, n, x, e): rubi.append(5355) return -Dist(m/(b*c*(n + S(1))), Int(x**(m + S(-1))*(a + b*ArcTan(c*x))**(n + S(1))*(d + e*x**S(2))**p, x), x) + Simp(x**m*(a + b*ArcTan(c*x))**(n + S(1))*(d + e*x**S(2))**(p + S(1))/(b*c*d*(n + S(1))), x) rule5355 = ReplacementRule(pattern5355, replacement5355) pattern5356 = Pattern(Integral(x_**WC('m', S(1))*(d_ + x_**S(2)*WC('e', S(1)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*acot(x_*WC('c', S(1))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons21, cons5, cons1778, cons240, cons87, cons89) def replacement5356(p, m, b, d, a, c, n, x, e): rubi.append(5356) return Dist(m/(b*c*(n + S(1))), Int(x**(m + S(-1))*(a + b*acot(c*x))**(n + S(1))*(d + e*x**S(2))**p, x), x) - Simp(x**m*(a + b*acot(c*x))**(n + S(1))*(d + e*x**S(2))**(p + S(1))/(b*c*d*(n + S(1))), x) rule5356 = ReplacementRule(pattern5356, replacement5356) pattern5357 = Pattern(Integral(x_**WC('m', S(1))*(d_ + x_**S(2)*WC('e', S(1)))**WC('p', S(1))*(ArcTan(x_*WC('c', S(1)))*WC('b', S(1)) + WC('a', S(0)))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons21, cons5, cons1778, cons242, cons87, cons88, cons66) def replacement5357(p, m, b, d, a, n, c, x, e): rubi.append(5357) return -Dist(b*c*n/(m + S(1)), Int(x**(m + S(1))*(a + b*ArcTan(c*x))**(n + S(-1))*(d + e*x**S(2))**p, x), x) + Simp(x**(m + S(1))*(a + b*ArcTan(c*x))**n*(d + e*x**S(2))**(p + S(1))/(d*(m + S(1))), x) rule5357 = ReplacementRule(pattern5357, replacement5357) pattern5358 = Pattern(Integral(x_**WC('m', S(1))*(d_ + x_**S(2)*WC('e', S(1)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*acot(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons21, cons5, cons1778, cons242, cons87, cons88, cons66) def replacement5358(p, m, b, d, a, n, c, x, e): rubi.append(5358) return Dist(b*c*n/(m + S(1)), Int(x**(m + S(1))*(a + b*acot(c*x))**(n + S(-1))*(d + e*x**S(2))**p, x), x) + Simp(x**(m + S(1))*(a + b*acot(c*x))**n*(d + e*x**S(2))**(p + S(1))/(d*(m + S(1))), x) rule5358 = ReplacementRule(pattern5358, replacement5358) pattern5359 = Pattern(Integral(x_**m_*sqrt(d_ + x_**S(2)*WC('e', S(1)))*(ArcTan(x_*WC('c', S(1)))*WC('b', S(1)) + WC('a', S(0))), x_), cons2, cons3, cons7, cons27, cons48, cons21, cons1778, cons241) def replacement5359(m, b, d, a, c, x, e): rubi.append(5359) return Dist(d/(m + S(2)), Int(x**m*(a + b*ArcTan(c*x))/sqrt(d + e*x**S(2)), x), x) - Dist(b*c*d/(m + S(2)), Int(x**(m + S(1))/sqrt(d + e*x**S(2)), x), x) + Simp(x**(m + S(1))*(a + b*ArcTan(c*x))*sqrt(d + e*x**S(2))/(m + S(2)), x) rule5359 = ReplacementRule(pattern5359, replacement5359) pattern5360 = Pattern(Integral(x_**m_*sqrt(d_ + x_**S(2)*WC('e', S(1)))*(WC('a', S(0)) + WC('b', S(1))*acot(x_*WC('c', S(1)))), x_), cons2, cons3, cons7, cons27, cons48, cons21, cons1778, cons241) def replacement5360(m, b, d, a, c, x, e): rubi.append(5360) return Dist(d/(m + S(2)), Int(x**m*(a + b*acot(c*x))/sqrt(d + e*x**S(2)), x), x) + Dist(b*c*d/(m + S(2)), Int(x**(m + S(1))/sqrt(d + e*x**S(2)), x), x) + Simp(x**(m + S(1))*(a + b*acot(c*x))*sqrt(d + e*x**S(2))/(m + S(2)), x) rule5360 = ReplacementRule(pattern5360, replacement5360) pattern5361 = Pattern(Integral(x_**m_*(d_ + x_**S(2)*WC('e', S(1)))**p_*(ArcTan(x_*WC('c', S(1)))*WC('b', S(1)) + WC('a', S(0)))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons21, cons1778, cons148, cons38, cons146) def replacement5361(p, m, b, d, a, n, c, x, e): rubi.append(5361) return Int(ExpandIntegrand(x**m*(a + b*ArcTan(c*x))**n*(d + e*x**S(2))**p, x), x) rule5361 = ReplacementRule(pattern5361, replacement5361) pattern5362 = Pattern(Integral(x_**m_*(d_ + x_**S(2)*WC('e', S(1)))**p_*(WC('a', S(0)) + WC('b', S(1))*acot(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons21, cons1778, cons148, cons38, cons146) def replacement5362(p, m, b, d, a, n, c, x, e): rubi.append(5362) return Int(ExpandIntegrand(x**m*(a + b*acot(c*x))**n*(d + e*x**S(2))**p, x), x) rule5362 = ReplacementRule(pattern5362, replacement5362) pattern5363 = Pattern(Integral(x_**m_*(d_ + x_**S(2)*WC('e', S(1)))**WC('p', S(1))*(ArcTan(x_*WC('c', S(1)))*WC('b', S(1)) + WC('a', S(0)))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons21, cons1778, cons13, cons163, cons148, cons1783) def replacement5363(p, m, b, d, a, n, c, x, e): rubi.append(5363) return Dist(d, Int(x**m*(a + b*ArcTan(c*x))**n*(d + e*x**S(2))**(p + S(-1)), x), x) + Dist(c**S(2)*d, Int(x**(m + S(2))*(a + b*ArcTan(c*x))**n*(d + e*x**S(2))**(p + S(-1)), x), x) rule5363 = ReplacementRule(pattern5363, replacement5363) pattern5364 = Pattern(Integral(x_**m_*(d_ + x_**S(2)*WC('e', S(1)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*acot(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons21, cons1778, cons13, cons163, cons148, cons1783) def replacement5364(p, m, b, d, a, n, c, x, e): rubi.append(5364) return Dist(d, Int(x**m*(a + b*acot(c*x))**n*(d + e*x**S(2))**(p + S(-1)), x), x) + Dist(c**S(2)*d, Int(x**(m + S(2))*(a + b*acot(c*x))**n*(d + e*x**S(2))**(p + S(-1)), x), x) rule5364 = ReplacementRule(pattern5364, replacement5364) pattern5365 = Pattern(Integral(x_**m_*(ArcTan(x_*WC('c', S(1)))*WC('b', S(1)) + WC('a', S(0)))**WC('n', S(1))/sqrt(d_ + x_**S(2)*WC('e', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons1778, cons93, cons88, cons166) def replacement5365(m, b, d, a, n, c, x, e): rubi.append(5365) return -Dist((m + S(-1))/(c**S(2)*m), Int(x**(m + S(-2))*(a + b*ArcTan(c*x))**n/sqrt(d + e*x**S(2)), x), x) - Dist(b*n/(c*m), Int(x**(m + S(-1))*(a + b*ArcTan(c*x))**(n + S(-1))/sqrt(d + e*x**S(2)), x), x) + Simp(x**(m + S(-1))*(a + b*ArcTan(c*x))**n*sqrt(d + e*x**S(2))/(c**S(2)*d*m), x) rule5365 = ReplacementRule(pattern5365, replacement5365) pattern5366 = Pattern(Integral(x_**m_*(WC('a', S(0)) + WC('b', S(1))*acot(x_*WC('c', S(1))))**WC('n', S(1))/sqrt(d_ + x_**S(2)*WC('e', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons1778, cons93, cons88, cons166) def replacement5366(m, b, d, a, n, c, x, e): rubi.append(5366) return -Dist((m + S(-1))/(c**S(2)*m), Int(x**(m + S(-2))*(a + b*acot(c*x))**n/sqrt(d + e*x**S(2)), x), x) + Dist(b*n/(c*m), Int(x**(m + S(-1))*(a + b*acot(c*x))**(n + S(-1))/sqrt(d + e*x**S(2)), x), x) + Simp(x**(m + S(-1))*(a + b*acot(c*x))**n*sqrt(d + e*x**S(2))/(c**S(2)*d*m), x) rule5366 = ReplacementRule(pattern5366, replacement5366) pattern5367 = Pattern(Integral((ArcTan(x_*WC('c', S(1)))*WC('b', S(1)) + WC('a', S(0)))/(x_*sqrt(d_ + x_**S(2)*WC('e', S(1)))), x_), cons2, cons3, cons7, cons27, cons48, cons1778, cons268) def replacement5367(b, d, a, c, x, e): rubi.append(5367) return Simp(-S(2)*(a + b*ArcTan(c*x))*atanh(sqrt(I*c*x + S(1))/sqrt(-I*c*x + S(1)))/sqrt(d), x) + Simp(I*b*PolyLog(S(2), -sqrt(I*c*x + S(1))/sqrt(-I*c*x + S(1)))/sqrt(d), x) - Simp(I*b*PolyLog(S(2), sqrt(I*c*x + S(1))/sqrt(-I*c*x + S(1)))/sqrt(d), x) rule5367 = ReplacementRule(pattern5367, replacement5367) pattern5368 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*acot(x_*WC('c', S(1))))/(x_*sqrt(d_ + x_**S(2)*WC('e', S(1)))), x_), cons2, cons3, cons7, cons27, cons48, cons1778, cons268) def replacement5368(b, d, a, c, x, e): rubi.append(5368) return Simp(-S(2)*(a + b*acot(c*x))*atanh(sqrt(I*c*x + S(1))/sqrt(-I*c*x + S(1)))/sqrt(d), x) - Simp(I*b*PolyLog(S(2), -sqrt(I*c*x + S(1))/sqrt(-I*c*x + S(1)))/sqrt(d), x) + Simp(I*b*PolyLog(S(2), sqrt(I*c*x + S(1))/sqrt(-I*c*x + S(1)))/sqrt(d), x) rule5368 = ReplacementRule(pattern5368, replacement5368) pattern5369 = Pattern(Integral((ArcTan(x_*WC('c', S(1)))*WC('b', S(1)) + WC('a', S(0)))**n_/(x_*sqrt(d_ + x_**S(2)*WC('e', S(1)))), x_), cons2, cons3, cons7, cons27, cons48, cons1778, cons148, cons268) def replacement5369(b, d, a, c, n, x, e): rubi.append(5369) return Dist(S(1)/sqrt(d), Subst(Int((a + b*x)**n/sin(x), x), x, ArcTan(c*x)), x) rule5369 = ReplacementRule(pattern5369, replacement5369) pattern5370 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*acot(x_*WC('c', S(1))))**n_/(x_*sqrt(d_ + x_**S(2)*WC('e', S(1)))), x_), cons2, cons3, cons7, cons27, cons48, cons1778, cons148, cons268) def replacement5370(b, d, a, c, n, x, e): rubi.append(5370) return -Dist(c*x*sqrt(S(1) + S(1)/(c**S(2)*x**S(2)))/sqrt(d + e*x**S(2)), Subst(Int((a + b*x)**n/cos(x), x), x, acot(c*x)), x) rule5370 = ReplacementRule(pattern5370, replacement5370) pattern5371 = Pattern(Integral((ArcTan(x_*WC('c', S(1)))*WC('b', S(1)) + WC('a', S(0)))**WC('n', S(1))/(x_*sqrt(d_ + x_**S(2)*WC('e', S(1)))), x_), cons2, cons3, cons7, cons27, cons48, cons1778, cons148, cons1738) def replacement5371(b, d, a, n, c, x, e): rubi.append(5371) return Dist(sqrt(c**S(2)*x**S(2) + S(1))/sqrt(d + e*x**S(2)), Int((a + b*ArcTan(c*x))**n/(x*sqrt(c**S(2)*x**S(2) + S(1))), x), x) rule5371 = ReplacementRule(pattern5371, replacement5371) pattern5372 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*acot(x_*WC('c', S(1))))**WC('n', S(1))/(x_*sqrt(d_ + x_**S(2)*WC('e', S(1)))), x_), cons2, cons3, cons7, cons27, cons48, cons1778, cons148, cons1738) def replacement5372(b, d, a, n, c, x, e): rubi.append(5372) return Dist(sqrt(c**S(2)*x**S(2) + S(1))/sqrt(d + e*x**S(2)), Int((a + b*acot(c*x))**n/(x*sqrt(c**S(2)*x**S(2) + S(1))), x), x) rule5372 = ReplacementRule(pattern5372, replacement5372) pattern5373 = Pattern(Integral((ArcTan(x_*WC('c', S(1)))*WC('b', S(1)) + WC('a', S(0)))**WC('n', S(1))/(x_**S(2)*sqrt(d_ + x_**S(2)*WC('e', S(1)))), x_), cons2, cons3, cons7, cons27, cons48, cons1778, cons87, cons88) def replacement5373(b, d, a, n, c, x, e): rubi.append(5373) return Dist(b*c*n, Int((a + b*ArcTan(c*x))**(n + S(-1))/(x*sqrt(d + e*x**S(2))), x), x) - Simp((a + b*ArcTan(c*x))**n*sqrt(d + e*x**S(2))/(d*x), x) rule5373 = ReplacementRule(pattern5373, replacement5373) pattern5374 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*acot(x_*WC('c', S(1))))**WC('n', S(1))/(x_**S(2)*sqrt(d_ + x_**S(2)*WC('e', S(1)))), x_), cons2, cons3, cons7, cons27, cons48, cons1778, cons87, cons88) def replacement5374(b, d, a, n, c, x, e): rubi.append(5374) return -Dist(b*c*n, Int((a + b*acot(c*x))**(n + S(-1))/(x*sqrt(d + e*x**S(2))), x), x) - Simp((a + b*acot(c*x))**n*sqrt(d + e*x**S(2))/(d*x), x) rule5374 = ReplacementRule(pattern5374, replacement5374) pattern5375 = Pattern(Integral(x_**m_*(ArcTan(x_*WC('c', S(1)))*WC('b', S(1)) + WC('a', S(0)))**WC('n', S(1))/sqrt(d_ + x_**S(2)*WC('e', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons1778, cons93, cons88, cons94, cons1510) def replacement5375(m, b, d, a, n, c, x, e): rubi.append(5375) return -Dist(c**S(2)*(m + S(2))/(m + S(1)), Int(x**(m + S(2))*(a + b*ArcTan(c*x))**n/sqrt(d + e*x**S(2)), x), x) - Dist(b*c*n/(m + S(1)), Int(x**(m + S(1))*(a + b*ArcTan(c*x))**(n + S(-1))/sqrt(d + e*x**S(2)), x), x) + Simp(x**(m + S(1))*(a + b*ArcTan(c*x))**n*sqrt(d + e*x**S(2))/(d*(m + S(1))), x) rule5375 = ReplacementRule(pattern5375, replacement5375) pattern5376 = Pattern(Integral(x_**m_*(WC('a', S(0)) + WC('b', S(1))*acot(x_*WC('c', S(1))))**WC('n', S(1))/sqrt(d_ + x_**S(2)*WC('e', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons1778, cons93, cons88, cons94, cons1510) def replacement5376(m, b, d, a, n, c, x, e): rubi.append(5376) return -Dist(c**S(2)*(m + S(2))/(m + S(1)), Int(x**(m + S(2))*(a + b*acot(c*x))**n/sqrt(d + e*x**S(2)), x), x) + Dist(b*c*n/(m + S(1)), Int(x**(m + S(1))*(a + b*acot(c*x))**(n + S(-1))/sqrt(d + e*x**S(2)), x), x) + Simp(x**(m + S(1))*(a + b*acot(c*x))**n*sqrt(d + e*x**S(2))/(d*(m + S(1))), x) rule5376 = ReplacementRule(pattern5376, replacement5376) pattern5377 = Pattern(Integral(x_**m_*(d_ + x_**S(2)*WC('e', S(1)))**p_*(ArcTan(x_*WC('c', S(1)))*WC('b', S(1)) + WC('a', S(0)))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons1778, cons1784, cons137, cons166, cons1152) def replacement5377(p, m, b, d, a, n, c, x, e): rubi.append(5377) return Dist(S(1)/e, Int(x**(m + S(-2))*(a + b*ArcTan(c*x))**n*(d + e*x**S(2))**(p + S(1)), x), x) - Dist(d/e, Int(x**(m + S(-2))*(a + b*ArcTan(c*x))**n*(d + e*x**S(2))**p, x), x) rule5377 = ReplacementRule(pattern5377, replacement5377) pattern5378 = Pattern(Integral(x_**m_*(d_ + x_**S(2)*WC('e', S(1)))**p_*(WC('a', S(0)) + WC('b', S(1))*acot(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons1778, cons1784, cons137, cons166, cons1152) def replacement5378(p, m, b, d, a, n, c, x, e): rubi.append(5378) return Dist(S(1)/e, Int(x**(m + S(-2))*(a + b*acot(c*x))**n*(d + e*x**S(2))**(p + S(1)), x), x) - Dist(d/e, Int(x**(m + S(-2))*(a + b*acot(c*x))**n*(d + e*x**S(2))**p, x), x) rule5378 = ReplacementRule(pattern5378, replacement5378) pattern5379 = Pattern(Integral(x_**m_*(d_ + x_**S(2)*WC('e', S(1)))**p_*(ArcTan(x_*WC('c', S(1)))*WC('b', S(1)) + WC('a', S(0)))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons1778, cons1784, cons137, cons267, cons1152) def replacement5379(p, m, b, d, a, n, c, x, e): rubi.append(5379) return Dist(S(1)/d, Int(x**m*(a + b*ArcTan(c*x))**n*(d + e*x**S(2))**(p + S(1)), x), x) - Dist(e/d, Int(x**(m + S(2))*(a + b*ArcTan(c*x))**n*(d + e*x**S(2))**p, x), x) rule5379 = ReplacementRule(pattern5379, replacement5379) pattern5380 = Pattern(Integral(x_**m_*(d_ + x_**S(2)*WC('e', S(1)))**p_*(WC('a', S(0)) + WC('b', S(1))*acot(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons1778, cons1784, cons137, cons267, cons1152) def replacement5380(p, m, b, d, a, n, c, x, e): rubi.append(5380) return Dist(S(1)/d, Int(x**m*(a + b*acot(c*x))**n*(d + e*x**S(2))**(p + S(1)), x), x) - Dist(e/d, Int(x**(m + S(2))*(a + b*acot(c*x))**n*(d + e*x**S(2))**p, x), x) rule5380 = ReplacementRule(pattern5380, replacement5380) pattern5381 = Pattern(Integral(x_**WC('m', S(1))*(d_ + x_**S(2)*WC('e', S(1)))**p_*(ArcTan(x_*WC('c', S(1)))*WC('b', S(1)) + WC('a', S(0)))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons1778, cons162, cons137, cons89, cons319) def replacement5381(p, m, b, d, a, n, c, x, e): rubi.append(5381) return -Dist(m/(b*c*(n + S(1))), Int(x**(m + S(-1))*(a + b*ArcTan(c*x))**(n + S(1))*(d + e*x**S(2))**p, x), x) - Dist(c*(m + S(2)*p + S(2))/(b*(n + S(1))), Int(x**(m + S(1))*(a + b*ArcTan(c*x))**(n + S(1))*(d + e*x**S(2))**p, x), x) + Simp(x**m*(a + b*ArcTan(c*x))**(n + S(1))*(d + e*x**S(2))**(p + S(1))/(b*c*d*(n + S(1))), x) rule5381 = ReplacementRule(pattern5381, replacement5381) pattern5382 = Pattern(Integral(x_**WC('m', S(1))*(d_ + x_**S(2)*WC('e', S(1)))**p_*(WC('a', S(0)) + WC('b', S(1))*acot(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons1778, cons162, cons137, cons89, cons319) def replacement5382(p, m, b, d, a, n, c, x, e): rubi.append(5382) return Dist(m/(b*c*(n + S(1))), Int(x**(m + S(-1))*(a + b*acot(c*x))**(n + S(1))*(d + e*x**S(2))**p, x), x) + Dist(c*(m + S(2)*p + S(2))/(b*(n + S(1))), Int(x**(m + S(1))*(a + b*acot(c*x))**(n + S(1))*(d + e*x**S(2))**p, x), x) - Simp(x**m*(a + b*acot(c*x))**(n + S(1))*(d + e*x**S(2))**(p + S(1))/(b*c*d*(n + S(1))), x) rule5382 = ReplacementRule(pattern5382, replacement5382) pattern5383 = Pattern(Integral(x_**WC('m', S(1))*(d_ + x_**S(2)*WC('e', S(1)))**p_*(ArcTan(x_*WC('c', S(1)))*WC('b', S(1)) + WC('a', S(0)))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons4, cons1778, cons62, cons1785, cons1740) def replacement5383(p, m, b, d, a, n, c, x, e): rubi.append(5383) return Dist(c**(-m + S(-1))*d**p, Subst(Int((a + b*x)**n*sin(x)**m*cos(x)**(-m - S(2)*p + S(-2)), x), x, ArcTan(c*x)), x) rule5383 = ReplacementRule(pattern5383, replacement5383) pattern5384 = Pattern(Integral(x_**WC('m', S(1))*(d_ + x_**S(2)*WC('e', S(1)))**p_*(ArcTan(x_*WC('c', S(1)))*WC('b', S(1)) + WC('a', S(0)))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons4, cons1778, cons62, cons1785, cons1741) def replacement5384(p, m, b, d, a, n, c, x, e): rubi.append(5384) return Dist(d**(p + S(1)/2)*sqrt(c**S(2)*x**S(2) + S(1))/sqrt(d + e*x**S(2)), Int(x**m*(a + b*ArcTan(c*x))**n*(c**S(2)*x**S(2) + S(1))**p, x), x) rule5384 = ReplacementRule(pattern5384, replacement5384) pattern5385 = Pattern(Integral(x_**WC('m', S(1))*(d_ + x_**S(2)*WC('e', S(1)))**p_*(WC('a', S(0)) + WC('b', S(1))*acot(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons4, cons1778, cons62, cons1785, cons38) def replacement5385(p, m, b, d, a, n, c, x, e): rubi.append(5385) return -Dist(c**(-m + S(-1))*d**p, Subst(Int((a + b*x)**n*sin(x)**(-m - S(2)*p + S(-2))*cos(x)**m, x), x, acot(c*x)), x) rule5385 = ReplacementRule(pattern5385, replacement5385) pattern5386 = Pattern(Integral(x_**WC('m', S(1))*(d_ + x_**S(2)*WC('e', S(1)))**p_*(WC('a', S(0)) + WC('b', S(1))*acot(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons4, cons1778, cons62, cons1785, cons147) def replacement5386(p, m, b, d, a, n, c, x, e): rubi.append(5386) return -Dist(c**(-m)*d**(p + S(1)/2)*x*sqrt((c**S(2)*x**S(2) + S(1))/(c**S(2)*x**S(2)))/sqrt(d + e*x**S(2)), Subst(Int((a + b*x)**n*sin(x)**(-m - S(2)*p + S(-2))*cos(x)**m, x), x, acot(c*x)), x) rule5386 = ReplacementRule(pattern5386, replacement5386) pattern5387 = Pattern(Integral(x_*(x_**S(2)*WC('e', S(1)) + WC('d', S(0)))**WC('p', S(1))*(ArcTan(x_*WC('c', S(1)))*WC('b', S(1)) + WC('a', S(0))), x_), cons2, cons3, cons7, cons27, cons48, cons5, cons54) def replacement5387(p, b, d, a, c, x, e): rubi.append(5387) return -Dist(b*c/(S(2)*e*(p + S(1))), Int((d + e*x**S(2))**(p + S(1))/(c**S(2)*x**S(2) + S(1)), x), x) + Simp((a + b*ArcTan(c*x))*(d + e*x**S(2))**(p + S(1))/(S(2)*e*(p + S(1))), x) rule5387 = ReplacementRule(pattern5387, replacement5387) pattern5388 = Pattern(Integral(x_*(x_**S(2)*WC('e', S(1)) + WC('d', S(0)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*acot(x_*WC('c', S(1)))), x_), cons2, cons3, cons7, cons27, cons48, cons5, cons54) def replacement5388(p, b, d, a, c, x, e): rubi.append(5388) return Dist(b*c/(S(2)*e*(p + S(1))), Int((d + e*x**S(2))**(p + S(1))/(c**S(2)*x**S(2) + S(1)), x), x) + Simp((a + b*acot(c*x))*(d + e*x**S(2))**(p + S(1))/(S(2)*e*(p + S(1))), x) rule5388 = ReplacementRule(pattern5388, replacement5388) def With5389(p, m, b, d, a, c, x, e): u = IntHide(x**m*(d + e*x**S(2))**p, x) rubi.append(5389) return -Dist(b*c, Int(SimplifyIntegrand(u/(c**S(2)*x**S(2) + S(1)), x), x), x) + Dist(a + b*ArcTan(c*x), u, x) pattern5389 = Pattern(Integral(x_**WC('m', S(1))*(x_**S(2)*WC('e', S(1)) + WC('d', S(0)))**WC('p', S(1))*(ArcTan(x_*WC('c', S(1)))*WC('b', S(1)) + WC('a', S(0))), x_), cons2, cons3, cons7, cons27, cons48, cons21, cons5, cons1786) rule5389 = ReplacementRule(pattern5389, With5389) def With5390(p, m, b, d, a, c, x, e): u = IntHide(x**m*(d + e*x**S(2))**p, x) rubi.append(5390) return Dist(b*c, Int(SimplifyIntegrand(u/(c**S(2)*x**S(2) + S(1)), x), x), x) + Dist(a + b*acot(c*x), u, x) pattern5390 = Pattern(Integral(x_**WC('m', S(1))*(x_**S(2)*WC('e', S(1)) + WC('d', S(0)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*acot(x_*WC('c', S(1)))), x_), cons2, cons3, cons7, cons27, cons48, cons21, cons5, cons1786) rule5390 = ReplacementRule(pattern5390, With5390) pattern5391 = Pattern(Integral(x_**WC('m', S(1))*(d_ + x_**S(2)*WC('e', S(1)))**WC('p', S(1))*(ArcTan(x_*WC('c', S(1)))*WC('b', S(1)) + WC('a', S(0)))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons21, cons38, cons148, cons1787) def replacement5391(p, m, b, d, a, n, c, x, e): rubi.append(5391) return Int(ExpandIntegrand((a + b*ArcTan(c*x))**n, x**m*(d + e*x**S(2))**p, x), x) rule5391 = ReplacementRule(pattern5391, replacement5391) pattern5392 = Pattern(Integral(x_**WC('m', S(1))*(d_ + x_**S(2)*WC('e', S(1)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*acot(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons21, cons38, cons148, cons1787) def replacement5392(p, m, b, d, a, n, c, x, e): rubi.append(5392) return Int(ExpandIntegrand((a + b*acot(c*x))**n, x**m*(d + e*x**S(2))**p, x), x) rule5392 = ReplacementRule(pattern5392, replacement5392) pattern5393 = Pattern(Integral(x_**WC('m', S(1))*(a_ + ArcTan(x_*WC('c', S(1)))*WC('b', S(1)))*(d_ + x_**S(2)*WC('e', S(1)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons21, cons5, cons1788) def replacement5393(p, m, b, d, c, a, x, e): rubi.append(5393) return Dist(a, Int(x**m*(d + e*x**S(2))**p, x), x) + Dist(b, Int(x**m*(d + e*x**S(2))**p*ArcTan(c*x), x), x) rule5393 = ReplacementRule(pattern5393, replacement5393) pattern5394 = Pattern(Integral(x_**WC('m', S(1))*(a_ + WC('b', S(1))*acot(x_*WC('c', S(1))))*(d_ + x_**S(2)*WC('e', S(1)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons21, cons5, cons1788) def replacement5394(p, m, b, d, c, a, x, e): rubi.append(5394) return Dist(a, Int(x**m*(d + e*x**S(2))**p, x), x) + Dist(b, Int(x**m*(d + e*x**S(2))**p*acot(c*x), x), x) rule5394 = ReplacementRule(pattern5394, replacement5394) pattern5395 = Pattern(Integral(x_**WC('m', S(1))*(x_**S(2)*WC('e', S(1)) + WC('d', S(0)))**WC('p', S(1))*(ArcTan(x_*WC('c', S(1)))*WC('b', S(1)) + WC('a', S(0)))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons21, cons4, cons5, cons1497) def replacement5395(p, m, b, d, a, n, c, x, e): rubi.append(5395) return Int(x**m*(a + b*ArcTan(c*x))**n*(d + e*x**S(2))**p, x) rule5395 = ReplacementRule(pattern5395, replacement5395) pattern5396 = Pattern(Integral(x_**WC('m', S(1))*(x_**S(2)*WC('e', S(1)) + WC('d', S(0)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*acot(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons21, cons4, cons5, cons1497) def replacement5396(p, m, b, d, a, n, c, x, e): rubi.append(5396) return Int(x**m*(a + b*acot(c*x))**n*(d + e*x**S(2))**p, x) rule5396 = ReplacementRule(pattern5396, replacement5396) pattern5397 = Pattern(Integral((ArcTan(x_*WC('c', S(1)))*WC('b', S(1)) + WC('a', S(0)))**WC('n', S(1))*atanh(u_)/(d_ + x_**S(2)*WC('e', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons1778, cons87, cons88, cons1789) def replacement5397(u, b, d, a, n, c, x, e): rubi.append(5397) return -Dist(S(1)/2, Int((a + b*ArcTan(c*x))**n*log(-u + S(1))/(d + e*x**S(2)), x), x) + Dist(S(1)/2, Int((a + b*ArcTan(c*x))**n*log(u + S(1))/(d + e*x**S(2)), x), x) rule5397 = ReplacementRule(pattern5397, replacement5397) pattern5398 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*acot(x_*WC('c', S(1))))**WC('n', S(1))*acoth(u_)/(d_ + x_**S(2)*WC('e', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons1778, cons87, cons88, cons1789) def replacement5398(u, b, d, a, n, c, x, e): rubi.append(5398) return -Dist(S(1)/2, Int((a + b*acot(c*x))**n*log(SimplifyIntegrand(S(1) - S(1)/u, x))/(d + e*x**S(2)), x), x) + Dist(S(1)/2, Int((a + b*acot(c*x))**n*log(SimplifyIntegrand(S(1) + S(1)/u, x))/(d + e*x**S(2)), x), x) rule5398 = ReplacementRule(pattern5398, replacement5398) pattern5399 = Pattern(Integral((ArcTan(x_*WC('c', S(1)))*WC('b', S(1)) + WC('a', S(0)))**WC('n', S(1))*atanh(u_)/(d_ + x_**S(2)*WC('e', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons1778, cons87, cons88, cons1790) def replacement5399(u, b, d, a, n, c, x, e): rubi.append(5399) return -Dist(S(1)/2, Int((a + b*ArcTan(c*x))**n*log(-u + S(1))/(d + e*x**S(2)), x), x) + Dist(S(1)/2, Int((a + b*ArcTan(c*x))**n*log(u + S(1))/(d + e*x**S(2)), x), x) rule5399 = ReplacementRule(pattern5399, replacement5399) pattern5400 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*acot(x_*WC('c', S(1))))**WC('n', S(1))*acoth(u_)/(d_ + x_**S(2)*WC('e', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons1778, cons87, cons88, cons1790) def replacement5400(u, b, d, a, n, c, x, e): rubi.append(5400) return -Dist(S(1)/2, Int((a + b*acot(c*x))**n*log(SimplifyIntegrand(S(1) - S(1)/u, x))/(d + e*x**S(2)), x), x) + Dist(S(1)/2, Int((a + b*acot(c*x))**n*log(SimplifyIntegrand(S(1) + S(1)/u, x))/(d + e*x**S(2)), x), x) rule5400 = ReplacementRule(pattern5400, replacement5400) pattern5401 = Pattern(Integral((ArcTan(x_*WC('c', S(1)))*WC('b', S(1)) + WC('a', S(0)))**WC('n', S(1))*log(u_)/(d_ + x_**S(2)*WC('e', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons1778, cons87, cons88, cons1791) def replacement5401(u, b, d, a, n, c, x, e): rubi.append(5401) return -Dist(I*b*n/S(2), Int((a + b*ArcTan(c*x))**(n + S(-1))*PolyLog(S(2), Together(-u + S(1)))/(d + e*x**S(2)), x), x) + Simp(I*(a + b*ArcTan(c*x))**n*PolyLog(S(2), Together(-u + S(1)))/(S(2)*c*d), x) rule5401 = ReplacementRule(pattern5401, replacement5401) pattern5402 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*acot(x_*WC('c', S(1))))**WC('n', S(1))*log(u_)/(d_ + x_**S(2)*WC('e', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons1778, cons87, cons88, cons1791) def replacement5402(u, b, d, a, n, c, x, e): rubi.append(5402) return Dist(I*b*n/S(2), Int((a + b*acot(c*x))**(n + S(-1))*PolyLog(S(2), Together(-u + S(1)))/(d + e*x**S(2)), x), x) + Simp(I*(a + b*acot(c*x))**n*PolyLog(S(2), Together(-u + S(1)))/(S(2)*c*d), x) rule5402 = ReplacementRule(pattern5402, replacement5402) pattern5403 = Pattern(Integral((ArcTan(x_*WC('c', S(1)))*WC('b', S(1)) + WC('a', S(0)))**WC('n', S(1))*log(u_)/(d_ + x_**S(2)*WC('e', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons1778, cons87, cons88, cons1792) def replacement5403(u, b, d, a, n, c, x, e): rubi.append(5403) return Dist(I*b*n/S(2), Int((a + b*ArcTan(c*x))**(n + S(-1))*PolyLog(S(2), Together(-u + S(1)))/(d + e*x**S(2)), x), x) - Simp(I*(a + b*ArcTan(c*x))**n*PolyLog(S(2), Together(-u + S(1)))/(S(2)*c*d), x) rule5403 = ReplacementRule(pattern5403, replacement5403) pattern5404 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*acot(x_*WC('c', S(1))))**WC('n', S(1))*log(u_)/(d_ + x_**S(2)*WC('e', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons1778, cons87, cons88, cons1792) def replacement5404(u, b, d, a, n, c, x, e): rubi.append(5404) return -Dist(I*b*n/S(2), Int((a + b*acot(c*x))**(n + S(-1))*PolyLog(S(2), Together(-u + S(1)))/(d + e*x**S(2)), x), x) - Simp(I*(a + b*acot(c*x))**n*PolyLog(S(2), Together(-u + S(1)))/(S(2)*c*d), x) rule5404 = ReplacementRule(pattern5404, replacement5404) pattern5405 = Pattern(Integral((ArcTan(x_*WC('c', S(1)))*WC('b', S(1)) + WC('a', S(0)))**WC('n', S(1))*PolyLog(p_, u_)/(d_ + x_**S(2)*WC('e', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons5, cons1778, cons87, cons88, cons1789) def replacement5405(p, u, b, d, a, n, c, x, e): rubi.append(5405) return Dist(I*b*n/S(2), Int((a + b*ArcTan(c*x))**(n + S(-1))*PolyLog(p + S(1), u)/(d + e*x**S(2)), x), x) - Simp(I*(a + b*ArcTan(c*x))**n*PolyLog(p + S(1), u)/(S(2)*c*d), x) rule5405 = ReplacementRule(pattern5405, replacement5405) pattern5406 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*acot(x_*WC('c', S(1))))**WC('n', S(1))*PolyLog(p_, u_)/(d_ + x_**S(2)*WC('e', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons5, cons1778, cons87, cons88, cons1789) def replacement5406(p, u, b, d, a, n, c, x, e): rubi.append(5406) return -Dist(I*b*n/S(2), Int((a + b*acot(c*x))**(n + S(-1))*PolyLog(p + S(1), u)/(d + e*x**S(2)), x), x) - Simp(I*(a + b*acot(c*x))**n*PolyLog(p + S(1), u)/(S(2)*c*d), x) rule5406 = ReplacementRule(pattern5406, replacement5406) pattern5407 = Pattern(Integral((ArcTan(x_*WC('c', S(1)))*WC('b', S(1)) + WC('a', S(0)))**WC('n', S(1))*PolyLog(p_, u_)/(d_ + x_**S(2)*WC('e', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons5, cons1778, cons87, cons88, cons1790) def replacement5407(p, u, b, d, a, n, c, x, e): rubi.append(5407) return -Dist(I*b*n/S(2), Int((a + b*ArcTan(c*x))**(n + S(-1))*PolyLog(p + S(1), u)/(d + e*x**S(2)), x), x) + Simp(I*(a + b*ArcTan(c*x))**n*PolyLog(p + S(1), u)/(S(2)*c*d), x) rule5407 = ReplacementRule(pattern5407, replacement5407) pattern5408 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*acot(x_*WC('c', S(1))))**WC('n', S(1))*PolyLog(p_, u_)/(d_ + x_**S(2)*WC('e', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons5, cons1778, cons87, cons88, cons1790) def replacement5408(p, u, b, d, a, n, c, x, e): rubi.append(5408) return Dist(I*b*n/S(2), Int((a + b*acot(c*x))**(n + S(-1))*PolyLog(p + S(1), u)/(d + e*x**S(2)), x), x) + Simp(I*(a + b*acot(c*x))**n*PolyLog(p + S(1), u)/(S(2)*c*d), x) rule5408 = ReplacementRule(pattern5408, replacement5408) pattern5409 = Pattern(Integral(S(1)/((d_ + x_**S(2)*WC('e', S(1)))*(ArcTan(x_*WC('c', S(1)))*WC('b', S(1)) + WC('a', S(0)))*(WC('a', S(0)) + WC('b', S(1))*acot(x_*WC('c', S(1))))), x_), cons2, cons3, cons7, cons27, cons48, cons1778) def replacement5409(b, d, a, c, x, e): rubi.append(5409) return Simp((log(a + b*ArcTan(c*x)) - log(a + b*acot(c*x)))/(b*c*d*(S(2)*a + b*ArcTan(c*x) + b*acot(c*x))), x) rule5409 = ReplacementRule(pattern5409, replacement5409) pattern5410 = Pattern(Integral((ArcTan(x_*WC('c', S(1)))*WC('b', S(1)) + WC('a', S(0)))**WC('n', S(1))*(WC('a', S(0)) + WC('b', S(1))*acot(x_*WC('c', S(1))))**WC('m', S(1))/(d_ + x_**S(2)*WC('e', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons1778, cons150, cons1793) def replacement5410(m, b, d, a, n, c, x, e): rubi.append(5410) return Dist(n/(m + S(1)), Int((a + b*ArcTan(c*x))**(n + S(-1))*(a + b*acot(c*x))**(m + S(1))/(d + e*x**S(2)), x), x) - Simp((a + b*ArcTan(c*x))**n*(a + b*acot(c*x))**(m + S(1))/(b*c*d*(m + S(1))), x) rule5410 = ReplacementRule(pattern5410, replacement5410) pattern5411 = Pattern(Integral((ArcTan(x_*WC('c', S(1)))*WC('b', S(1)) + WC('a', S(0)))**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*acot(x_*WC('c', S(1))))**WC('n', S(1))/(d_ + x_**S(2)*WC('e', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons1778, cons150, cons1794) def replacement5411(m, b, d, a, n, c, x, e): rubi.append(5411) return Dist(n/(m + S(1)), Int((a + b*ArcTan(c*x))**(m + S(1))*(a + b*acot(c*x))**(n + S(-1))/(d + e*x**S(2)), x), x) + Simp((a + b*ArcTan(c*x))**(m + S(1))*(a + b*acot(c*x))**n/(b*c*d*(m + S(1))), x) rule5411 = ReplacementRule(pattern5411, replacement5411) pattern5412 = Pattern(Integral(ArcTan(x_*WC('a', S(1)))/(c_ + x_**WC('n', S(1))*WC('d', S(1))), x_), cons2, cons7, cons27, cons85, cons1795) def replacement5412(d, a, n, c, x): rubi.append(5412) return Dist(I/S(2), Int(log(-I*a*x + S(1))/(c + d*x**n), x), x) - Dist(I/S(2), Int(log(I*a*x + S(1))/(c + d*x**n), x), x) rule5412 = ReplacementRule(pattern5412, replacement5412) pattern5413 = Pattern(Integral(acot(x_*WC('a', S(1)))/(c_ + x_**WC('n', S(1))*WC('d', S(1))), x_), cons2, cons7, cons27, cons85, cons1795) def replacement5413(d, a, n, c, x): rubi.append(5413) return Dist(I/S(2), Int(log(S(1) - I/(a*x))/(c + d*x**n), x), x) - Dist(I/S(2), Int(log(S(1) + I/(a*x))/(c + d*x**n), x), x) rule5413 = ReplacementRule(pattern5413, replacement5413) pattern5414 = Pattern(Integral((ArcTan(x_*WC('c', S(1)))*WC('b', S(1)) + WC('a', S(0)))*(WC('d', S(0)) + WC('e', S(1))*log(x_**S(2)*WC('g', S(1)) + WC('f', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons1796) def replacement5414(f, b, g, d, a, c, x, e): rubi.append(5414) return -Dist(b*c, Int(x*(d + e*log(f + g*x**S(2)))/(c**S(2)*x**S(2) + S(1)), x), x) - Dist(S(2)*e*g, Int(x**S(2)*(a + b*ArcTan(c*x))/(f + g*x**S(2)), x), x) + Simp(x*(a + b*ArcTan(c*x))*(d + e*log(f + g*x**S(2))), x) rule5414 = ReplacementRule(pattern5414, replacement5414) pattern5415 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*acot(x_*WC('c', S(1))))*(WC('d', S(0)) + WC('e', S(1))*log(x_**S(2)*WC('g', S(1)) + WC('f', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons1796) def replacement5415(f, b, g, d, a, c, x, e): rubi.append(5415) return Dist(b*c, Int(x*(d + e*log(f + g*x**S(2)))/(c**S(2)*x**S(2) + S(1)), x), x) - Dist(S(2)*e*g, Int(x**S(2)*(a + b*acot(c*x))/(f + g*x**S(2)), x), x) + Simp(x*(a + b*acot(c*x))*(d + e*log(f + g*x**S(2))), x) rule5415 = ReplacementRule(pattern5415, replacement5415) pattern5416 = Pattern(Integral(x_**WC('m', S(1))*(ArcTan(x_*WC('c', S(1)))*WC('b', S(1)) + WC('a', S(0)))*(WC('d', S(0)) + WC('e', S(1))*log(x_**S(2)*WC('g', S(1)) + WC('f', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons601) def replacement5416(m, f, b, g, d, a, c, x, e): rubi.append(5416) return -Dist(b*c/(m + S(1)), Int(x**(m + S(1))*(d + e*log(f + g*x**S(2)))/(c**S(2)*x**S(2) + S(1)), x), x) - Dist(S(2)*e*g/(m + S(1)), Int(x**(m + S(2))*(a + b*ArcTan(c*x))/(f + g*x**S(2)), x), x) + Simp(x**(m + S(1))*(a + b*ArcTan(c*x))*(d + e*log(f + g*x**S(2)))/(m + S(1)), x) rule5416 = ReplacementRule(pattern5416, replacement5416) pattern5417 = Pattern(Integral(x_**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*acot(x_*WC('c', S(1))))*(WC('d', S(0)) + WC('e', S(1))*log(x_**S(2)*WC('g', S(1)) + WC('f', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons601) def replacement5417(m, f, b, g, d, a, c, x, e): rubi.append(5417) return Dist(b*c/(m + S(1)), Int(x**(m + S(1))*(d + e*log(f + g*x**S(2)))/(c**S(2)*x**S(2) + S(1)), x), x) - Dist(S(2)*e*g/(m + S(1)), Int(x**(m + S(2))*(a + b*acot(c*x))/(f + g*x**S(2)), x), x) + Simp(x**(m + S(1))*(a + b*acot(c*x))*(d + e*log(f + g*x**S(2)))/(m + S(1)), x) rule5417 = ReplacementRule(pattern5417, replacement5417) def With5418(m, f, b, g, d, a, c, x, e): u = IntHide(x**m*(d + e*log(f + g*x**S(2))), x) rubi.append(5418) return -Dist(b*c, Int(ExpandIntegrand(u/(c**S(2)*x**S(2) + S(1)), x), x), x) + Dist(a + b*ArcTan(c*x), u, x) pattern5418 = Pattern(Integral(x_**WC('m', S(1))*(ArcTan(x_*WC('c', S(1)))*WC('b', S(1)) + WC('a', S(0)))*(WC('d', S(0)) + WC('e', S(1))*log(x_**S(2)*WC('g', S(1)) + WC('f', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons1797) rule5418 = ReplacementRule(pattern5418, With5418) def With5419(m, f, b, g, d, a, c, x, e): u = IntHide(x**m*(d + e*log(f + g*x**S(2))), x) rubi.append(5419) return Dist(b*c, Int(ExpandIntegrand(u/(c**S(2)*x**S(2) + S(1)), x), x), x) + Dist(a + b*acot(c*x), u, x) pattern5419 = Pattern(Integral(x_**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*acot(x_*WC('c', S(1))))*(WC('d', S(0)) + WC('e', S(1))*log(x_**S(2)*WC('g', S(1)) + WC('f', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons1797) rule5419 = ReplacementRule(pattern5419, With5419) def With5420(m, f, b, g, d, a, c, x, e): u = IntHide(x**m*(a + b*ArcTan(c*x)), x) rubi.append(5420) return -Dist(S(2)*e*g, Int(ExpandIntegrand(u*x/(f + g*x**S(2)), x), x), x) + Dist(d + e*log(f + g*x**S(2)), u, x) pattern5420 = Pattern(Integral(x_**WC('m', S(1))*(ArcTan(x_*WC('c', S(1)))*WC('b', S(1)) + WC('a', S(0)))*(WC('d', S(0)) + WC('e', S(1))*log(x_**S(2)*WC('g', S(1)) + WC('f', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons17, cons261) rule5420 = ReplacementRule(pattern5420, With5420) def With5421(m, f, b, g, d, a, c, x, e): u = IntHide(x**m*(a + b*acot(c*x)), x) rubi.append(5421) return -Dist(S(2)*e*g, Int(ExpandIntegrand(u*x/(f + g*x**S(2)), x), x), x) + Dist(d + e*log(f + g*x**S(2)), u, x) pattern5421 = Pattern(Integral(x_**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*acot(x_*WC('c', S(1))))*(WC('d', S(0)) + WC('e', S(1))*log(x_**S(2)*WC('g', S(1)) + WC('f', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons17, cons261) rule5421 = ReplacementRule(pattern5421, With5421) pattern5422 = Pattern(Integral(x_*(ArcTan(x_*WC('c', S(1)))*WC('b', S(1)) + WC('a', S(0)))**S(2)*(WC('d', S(0)) + WC('e', S(1))*log(f_ + x_**S(2)*WC('g', S(1)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons1798) def replacement5422(g, b, f, d, a, c, x, e): rubi.append(5422) return -Dist(b/c, Int((a + b*ArcTan(c*x))*(d + e*log(f + g*x**S(2))), x), x) + Dist(b*c*e, Int(x**S(2)*(a + b*ArcTan(c*x))/(c**S(2)*x**S(2) + S(1)), x), x) - Simp(e*x**S(2)*(a + b*ArcTan(c*x))**S(2)/S(2), x) + Simp((a + b*ArcTan(c*x))**S(2)*(d + e*log(f + g*x**S(2)))*(f + g*x**S(2))/(S(2)*g), x) rule5422 = ReplacementRule(pattern5422, replacement5422) pattern5423 = Pattern(Integral(x_*(WC('a', S(0)) + WC('b', S(1))*acot(x_*WC('c', S(1))))**S(2)*(WC('d', S(0)) + WC('e', S(1))*log(f_ + x_**S(2)*WC('g', S(1)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons1798) def replacement5423(g, b, f, d, a, c, x, e): rubi.append(5423) return Dist(b/c, Int((a + b*acot(c*x))*(d + e*log(f + g*x**S(2))), x), x) - Dist(b*c*e, Int(x**S(2)*(a + b*acot(c*x))/(c**S(2)*x**S(2) + S(1)), x), x) - Simp(e*x**S(2)*(a + b*acot(c*x))**S(2)/S(2), x) + Simp((a + b*acot(c*x))**S(2)*(d + e*log(f + g*x**S(2)))*(f + g*x**S(2))/(S(2)*g), x) rule5423 = ReplacementRule(pattern5423, replacement5423) pattern5424 = Pattern(Integral(exp(n_*ArcTan(x_*WC('a', S(1)))), x_), cons2, cons1799) def replacement5424(x, a, n): rubi.append(5424) return Int((-I*a*x + S(1))**(I*n/S(2) + S(1)/2)*(I*a*x + S(1))**(-I*n/S(2) + S(1)/2)/sqrt(a**S(2)*x**S(2) + S(1)), x) rule5424 = ReplacementRule(pattern5424, replacement5424) pattern5425 = Pattern(Integral(x_**WC('m', S(1))*exp(n_*ArcTan(x_*WC('a', S(1)))), x_), cons2, cons21, cons1799) def replacement5425(x, m, a, n): rubi.append(5425) return Int(x**m*(-I*a*x + S(1))**(I*n/S(2) + S(1)/2)*(I*a*x + S(1))**(-I*n/S(2) + S(1)/2)/sqrt(a**S(2)*x**S(2) + S(1)), x) rule5425 = ReplacementRule(pattern5425, replacement5425) pattern5426 = Pattern(Integral(exp(ArcTan(x_*WC('a', S(1)))*WC('n', S(1))), x_), cons2, cons4, cons1800) def replacement5426(x, a, n): rubi.append(5426) return Int((-I*a*x + S(1))**(I*n/S(2))*(I*a*x + S(1))**(-I*n/S(2)), x) rule5426 = ReplacementRule(pattern5426, replacement5426) pattern5427 = Pattern(Integral(x_**WC('m', S(1))*exp(ArcTan(x_*WC('a', S(1)))*WC('n', S(1))), x_), cons2, cons21, cons4, cons1800) def replacement5427(x, m, a, n): rubi.append(5427) return Int(x**m*(-I*a*x + S(1))**(I*n/S(2))*(I*a*x + S(1))**(-I*n/S(2)), x) rule5427 = ReplacementRule(pattern5427, replacement5427) pattern5428 = Pattern(Integral((c_ + x_*WC('d', S(1)))**WC('p', S(1))*WC('u', S(1))*exp(ArcTan(x_*WC('a', S(1)))*WC('n', S(1))), x_), cons2, cons7, cons27, cons4, cons5, cons1801, cons1802) def replacement5428(p, u, d, a, n, c, x): rubi.append(5428) return Dist(c**p, Int(u*(S(1) + d*x/c)**p*(-I*a*x + S(1))**(I*n/S(2))*(I*a*x + S(1))**(-I*n/S(2)), x), x) rule5428 = ReplacementRule(pattern5428, replacement5428) pattern5429 = Pattern(Integral((c_ + x_*WC('d', S(1)))**WC('p', S(1))*WC('u', S(1))*exp(ArcTan(x_*WC('a', S(1)))*WC('n', S(1))), x_), cons2, cons7, cons27, cons4, cons5, cons1801, cons1803) def replacement5429(p, u, d, a, n, c, x): rubi.append(5429) return Int(u*(c + d*x)**p*(-I*a*x + S(1))**(I*n/S(2))*(I*a*x + S(1))**(-I*n/S(2)), x) rule5429 = ReplacementRule(pattern5429, replacement5429) pattern5430 = Pattern(Integral((c_ + WC('d', S(1))/x_)**WC('p', S(1))*WC('u', S(1))*exp(ArcTan(x_*WC('a', S(1)))*WC('n', S(1))), x_), cons2, cons7, cons27, cons4, cons1804, cons38) def replacement5430(p, u, d, a, n, c, x): rubi.append(5430) return Dist(d**p, Int(u*x**(-p)*(c*x/d + S(1))**p*exp(n*ArcTan(a*x)), x), x) rule5430 = ReplacementRule(pattern5430, replacement5430) pattern5431 = Pattern(Integral((c_ + WC('d', S(1))/x_)**p_*WC('u', S(1))*exp(n_*atanh(x_*WC('a', S(1)))), x_), cons2, cons7, cons27, cons5, cons1804, cons147, cons1805, cons177) def replacement5431(p, u, d, a, n, c, x): rubi.append(5431) return Dist((S(-1))**(n/S(2))*c**p, Int(u*(S(1) - I/(a*x))**(-I*n/S(2))*(S(1) + I/(a*x))**(I*n/S(2))*(S(1) + d/(c*x))**p, x), x) rule5431 = ReplacementRule(pattern5431, replacement5431) pattern5432 = Pattern(Integral((c_ + WC('d', S(1))/x_)**p_*WC('u', S(1))*exp(n_*ArcTan(x_*WC('a', S(1)))), x_), cons2, cons7, cons27, cons5, cons1804, cons147, cons1805, cons117) def replacement5432(p, u, d, a, n, c, x): rubi.append(5432) return Int(u*(c + d/x)**p*(-I*a*x + S(1))**(I*n/S(2))*(I*a*x + S(1))**(-I*n/S(2)), x) rule5432 = ReplacementRule(pattern5432, replacement5432) pattern5433 = Pattern(Integral((c_ + WC('d', S(1))/x_)**p_*WC('u', S(1))*exp(ArcTan(x_*WC('a', S(1)))*WC('n', S(1))), x_), cons2, cons7, cons27, cons4, cons5, cons1804, cons147) def replacement5433(p, u, d, a, n, c, x): rubi.append(5433) return Dist(x**p*(c + d/x)**p*(c*x/d + S(1))**(-p), Int(u*x**(-p)*(c*x/d + S(1))**p*exp(n*ArcTan(a*x)), x), x) rule5433 = ReplacementRule(pattern5433, replacement5433) pattern5434 = Pattern(Integral(exp(ArcTan(x_*WC('a', S(1)))*WC('n', S(1)))/(c_ + x_**S(2)*WC('d', S(1)))**(S(3)/2), x_), cons2, cons7, cons27, cons4, cons1806, cons1807) def replacement5434(d, a, n, c, x): rubi.append(5434) return Simp((a*x + n)*exp(n*ArcTan(a*x))/(a*c*sqrt(c + d*x**S(2))*(n**S(2) + S(1))), x) rule5434 = ReplacementRule(pattern5434, replacement5434) pattern5435 = Pattern(Integral((c_ + x_**S(2)*WC('d', S(1)))**p_*exp(ArcTan(x_*WC('a', S(1)))*WC('n', S(1))), x_), cons2, cons7, cons27, cons4, cons1806, cons13, cons137, cons1807, cons1808, cons246) def replacement5435(p, d, a, n, c, x): rubi.append(5435) return Dist(S(2)*(p + S(1))*(S(2)*p + S(3))/(c*(n**S(2) + S(4)*(p + S(1))**S(2))), Int((c + d*x**S(2))**(p + S(1))*exp(n*ArcTan(a*x)), x), x) + Simp((c + d*x**S(2))**(p + S(1))*(-S(2)*a*x*(p + S(1)) + n)*exp(n*ArcTan(a*x))/(a*c*(n**S(2) + S(4)*(p + S(1))**S(2))), x) rule5435 = ReplacementRule(pattern5435, replacement5435) pattern5436 = Pattern(Integral(exp(ArcTan(x_*WC('a', S(1)))*WC('n', S(1)))/(c_ + x_**S(2)*WC('d', S(1))), x_), cons2, cons7, cons27, cons4, cons1806) def replacement5436(d, a, n, c, x): rubi.append(5436) return Simp(exp(n*ArcTan(a*x))/(a*c*n), x) rule5436 = ReplacementRule(pattern5436, replacement5436) pattern5437 = Pattern(Integral((c_ + x_**S(2)*WC('d', S(1)))**WC('p', S(1))*exp(n_*ArcTan(x_*WC('a', S(1)))), x_), cons2, cons7, cons27, cons5, cons1806, cons38, cons1809, cons1810) def replacement5437(p, d, a, n, c, x): rubi.append(5437) return Dist(c**p, Int((a**S(2)*x**S(2) + S(1))**(-I*n/S(2) + p)*(-I*a*x + S(1))**(I*n), x), x) rule5437 = ReplacementRule(pattern5437, replacement5437) pattern5438 = Pattern(Integral((c_ + x_**S(2)*WC('d', S(1)))**WC('p', S(1))*exp(ArcTan(x_*WC('a', S(1)))*WC('n', S(1))), x_), cons2, cons7, cons27, cons4, cons5, cons1806, cons1802) def replacement5438(p, d, a, n, c, x): rubi.append(5438) return Dist(c**p, Int((-I*a*x + S(1))**(I*n/S(2) + p)*(I*a*x + S(1))**(-I*n/S(2) + p), x), x) rule5438 = ReplacementRule(pattern5438, replacement5438) pattern5439 = Pattern(Integral((c_ + x_**S(2)*WC('d', S(1)))**p_*exp(n_*ArcTan(x_*WC('a', S(1)))), x_), cons2, cons7, cons27, cons5, cons1806, cons1803, cons1811) def replacement5439(p, d, a, n, c, x): rubi.append(5439) return Dist(c**(I*n/S(2)), Int((c + d*x**S(2))**(-I*n/S(2) + p)*(-I*a*x + S(1))**(I*n), x), x) rule5439 = ReplacementRule(pattern5439, replacement5439) pattern5440 = Pattern(Integral((c_ + x_**S(2)*WC('d', S(1)))**p_*exp(n_*ArcTan(x_*WC('a', S(1)))), x_), cons2, cons7, cons27, cons5, cons1806, cons1803, cons1812) def replacement5440(p, d, a, n, c, x): rubi.append(5440) return Dist(c**(-I*n/S(2)), Int((c + d*x**S(2))**(I*n/S(2) + p)*(I*a*x + S(1))**(-I*n), x), x) rule5440 = ReplacementRule(pattern5440, replacement5440) pattern5441 = Pattern(Integral((c_ + x_**S(2)*WC('d', S(1)))**p_*exp(ArcTan(x_*WC('a', S(1)))*WC('n', S(1))), x_), cons2, cons7, cons27, cons4, cons5, cons1806, cons1803) def replacement5441(p, d, a, n, c, x): rubi.append(5441) return Dist(c**IntPart(p)*(c + d*x**S(2))**FracPart(p)*(a**S(2)*x**S(2) + S(1))**(-FracPart(p)), Int((a**S(2)*x**S(2) + S(1))**p*exp(n*ArcTan(a*x)), x), x) rule5441 = ReplacementRule(pattern5441, replacement5441) pattern5442 = Pattern(Integral(x_*exp(ArcTan(x_*WC('a', S(1)))*WC('n', S(1)))/(c_ + x_**S(2)*WC('d', S(1)))**(S(3)/2), x_), cons2, cons7, cons27, cons4, cons1806, cons1807) def replacement5442(d, a, n, c, x): rubi.append(5442) return -Simp((-a*n*x + S(1))*exp(n*ArcTan(a*x))/(d*sqrt(c + d*x**S(2))*(n**S(2) + S(1))), x) rule5442 = ReplacementRule(pattern5442, replacement5442) pattern5443 = Pattern(Integral(x_*(c_ + x_**S(2)*WC('d', S(1)))**p_*exp(ArcTan(x_*WC('a', S(1)))*WC('n', S(1))), x_), cons2, cons7, cons27, cons4, cons1806, cons13, cons137, cons1807, cons246) def replacement5443(p, d, a, n, c, x): rubi.append(5443) return -Dist(a*c*n/(S(2)*d*(p + S(1))), Int((c + d*x**S(2))**p*exp(n*ArcTan(a*x)), x), x) + Simp((c + d*x**S(2))**(p + S(1))*exp(n*ArcTan(a*x))/(S(2)*d*(p + S(1))), x) rule5443 = ReplacementRule(pattern5443, replacement5443) pattern5444 = Pattern(Integral(x_**S(2)*(c_ + x_**S(2)*WC('d', S(1)))**WC('p', S(1))*exp(ArcTan(x_*WC('a', S(1)))*WC('n', S(1))), x_), cons2, cons7, cons27, cons4, cons1806, cons1813, cons1807) def replacement5444(p, d, a, n, c, x): rubi.append(5444) return -Simp((c + d*x**S(2))**(p + S(1))*(-a*n*x + S(1))*exp(n*ArcTan(a*x))/(a*d*n*(n**S(2) + S(1))), x) rule5444 = ReplacementRule(pattern5444, replacement5444) pattern5445 = Pattern(Integral(x_**S(2)*(c_ + x_**S(2)*WC('d', S(1)))**p_*exp(ArcTan(x_*WC('a', S(1)))*WC('n', S(1))), x_), cons2, cons7, cons27, cons4, cons1806, cons13, cons137, cons1807, cons1808, cons246) def replacement5445(p, d, a, n, c, x): rubi.append(5445) return Dist((n**S(2) - S(2)*p + S(-2))/(d*(n**S(2) + S(4)*(p + S(1))**S(2))), Int((c + d*x**S(2))**(p + S(1))*exp(n*ArcTan(a*x)), x), x) - Simp((c + d*x**S(2))**(p + S(1))*(-S(2)*a*x*(p + S(1)) + n)*exp(n*ArcTan(a*x))/(a*d*(n**S(2) + S(4)*(p + S(1))**S(2))), x) rule5445 = ReplacementRule(pattern5445, replacement5445) pattern5446 = Pattern(Integral(x_**WC('m', S(1))*(c_ + x_**S(2)*WC('d', S(1)))**WC('p', S(1))*exp(n_*ArcTan(x_*WC('a', S(1)))), x_), cons2, cons7, cons27, cons21, cons5, cons1806, cons1802, cons1809, cons1810) def replacement5446(p, m, d, a, n, c, x): rubi.append(5446) return Dist(c**p, Int(x**m*(a**S(2)*x**S(2) + S(1))**(-I*n/S(2) + p)*(-I*a*x + S(1))**(I*n), x), x) rule5446 = ReplacementRule(pattern5446, replacement5446) pattern5447 = Pattern(Integral(x_**WC('m', S(1))*(c_ + x_**S(2)*WC('d', S(1)))**WC('p', S(1))*exp(ArcTan(x_*WC('a', S(1)))*WC('n', S(1))), x_), cons2, cons7, cons27, cons21, cons4, cons5, cons1806, cons1802) def replacement5447(p, m, d, a, n, c, x): rubi.append(5447) return Dist(c**p, Int(x**m*(-I*a*x + S(1))**(I*n/S(2) + p)*(I*a*x + S(1))**(-I*n/S(2) + p), x), x) rule5447 = ReplacementRule(pattern5447, replacement5447) pattern5448 = Pattern(Integral(x_**WC('m', S(1))*(c_ + x_**S(2)*WC('d', S(1)))**p_*exp(n_*ArcTan(x_*WC('a', S(1)))), x_), cons2, cons7, cons27, cons21, cons5, cons1806, cons1803, cons1811) def replacement5448(p, m, d, a, n, c, x): rubi.append(5448) return Dist(c**(I*n/S(2)), Int(x**m*(c + d*x**S(2))**(-I*n/S(2) + p)*(-I*a*x + S(1))**(I*n), x), x) rule5448 = ReplacementRule(pattern5448, replacement5448) pattern5449 = Pattern(Integral(x_**WC('m', S(1))*(c_ + x_**S(2)*WC('d', S(1)))**p_*exp(n_*ArcTan(x_*WC('a', S(1)))), x_), cons2, cons7, cons27, cons21, cons5, cons1806, cons1803, cons1812) def replacement5449(p, m, d, a, n, c, x): rubi.append(5449) return Dist(c**(-I*n/S(2)), Int(x**m*(c + d*x**S(2))**(I*n/S(2) + p)*(I*a*x + S(1))**(-I*n), x), x) rule5449 = ReplacementRule(pattern5449, replacement5449) pattern5450 = Pattern(Integral(x_**WC('m', S(1))*(c_ + x_**S(2)*WC('d', S(1)))**p_*exp(ArcTan(x_*WC('a', S(1)))*WC('n', S(1))), x_), cons2, cons7, cons27, cons21, cons4, cons5, cons1806, cons1803) def replacement5450(p, m, d, a, n, c, x): rubi.append(5450) return Dist(c**IntPart(p)*(c + d*x**S(2))**FracPart(p)*(a**S(2)*x**S(2) + S(1))**(-FracPart(p)), Int(x**m*(a**S(2)*x**S(2) + S(1))**p*exp(n*ArcTan(a*x)), x), x) rule5450 = ReplacementRule(pattern5450, replacement5450) pattern5451 = Pattern(Integral(u_*(c_ + x_**S(2)*WC('d', S(1)))**WC('p', S(1))*exp(ArcTan(x_*WC('a', S(1)))*WC('n', S(1))), x_), cons2, cons7, cons27, cons4, cons5, cons1806, cons1802) def replacement5451(p, u, d, a, n, c, x): rubi.append(5451) return Dist(c**p, Int(u*(-I*a*x + S(1))**(I*n/S(2) + p)*(I*a*x + S(1))**(-I*n/S(2) + p), x), x) rule5451 = ReplacementRule(pattern5451, replacement5451) pattern5452 = Pattern(Integral(u_*(c_ + x_**S(2)*WC('d', S(1)))**WC('p', S(1))*exp(n_*ArcTan(x_*WC('a', S(1)))), x_), cons2, cons7, cons27, cons4, cons5, cons1806, cons1802, cons1805) def replacement5452(p, u, d, a, n, c, x): rubi.append(5452) return Dist(c**IntPart(p)*(c + d*x**S(2))**FracPart(p)*(-I*a*x + S(1))**(-FracPart(p))*(I*a*x + S(1))**(-FracPart(p)), Int(u*(-I*a*x + S(1))**(I*n/S(2) + p)*(I*a*x + S(1))**(-I*n/S(2) + p), x), x) rule5452 = ReplacementRule(pattern5452, replacement5452) pattern5453 = Pattern(Integral(u_*(c_ + x_**S(2)*WC('d', S(1)))**p_*exp(ArcTan(x_*WC('a', S(1)))*WC('n', S(1))), x_), cons2, cons7, cons27, cons4, cons5, cons1806, cons1803, cons1814) def replacement5453(p, u, d, a, n, c, x): rubi.append(5453) return Dist(c**IntPart(p)*(c + d*x**S(2))**FracPart(p)*(a**S(2)*x**S(2) + S(1))**(-FracPart(p)), Int(u*(a**S(2)*x**S(2) + S(1))**p*exp(n*ArcTan(a*x)), x), x) rule5453 = ReplacementRule(pattern5453, replacement5453) pattern5454 = Pattern(Integral((c_ + WC('d', S(1))/x_**S(2))**WC('p', S(1))*WC('u', S(1))*exp(ArcTan(x_*WC('a', S(1)))*WC('n', S(1))), x_), cons2, cons7, cons27, cons4, cons1815, cons38) def replacement5454(p, u, d, a, n, c, x): rubi.append(5454) return Dist(d**p, Int(u*x**(-S(2)*p)*(a**S(2)*x**S(2) + S(1))**p*exp(n*ArcTan(a*x)), x), x) rule5454 = ReplacementRule(pattern5454, replacement5454) pattern5455 = Pattern(Integral((c_ + WC('d', S(1))/x_**S(2))**p_*WC('u', S(1))*exp(n_*ArcTan(x_*WC('a', S(1)))), x_), cons2, cons7, cons27, cons5, cons1815, cons147, cons1805, cons177) def replacement5455(p, u, d, a, n, c, x): rubi.append(5455) return Dist(c**p, Int(u*(S(1) - I/(a*x))**p*(S(1) + I/(a*x))**p*exp(n*ArcTan(a*x)), x), x) rule5455 = ReplacementRule(pattern5455, replacement5455) pattern5456 = Pattern(Integral((c_ + WC('d', S(1))/x_**S(2))**p_*WC('u', S(1))*exp(n_*ArcTan(x_*WC('a', S(1)))), x_), cons2, cons7, cons27, cons4, cons5, cons1815, cons147, cons1805, cons117) def replacement5456(p, u, d, a, n, c, x): rubi.append(5456) return Dist(x**(S(2)*p)*(c + d/x**S(2))**p*(-I*a*x + S(1))**(-p)*(I*a*x + S(1))**(-p), Int(u*x**(-S(2)*p)*(-I*a*x + S(1))**p*(I*a*x + S(1))**p*exp(n*ArcTan(a*x)), x), x) rule5456 = ReplacementRule(pattern5456, replacement5456) pattern5457 = Pattern(Integral((c_ + WC('d', S(1))/x_**S(2))**p_*WC('u', S(1))*exp(ArcTan(x_*WC('a', S(1)))*WC('n', S(1))), x_), cons2, cons7, cons27, cons4, cons5, cons1815, cons147, cons1814) def replacement5457(p, u, d, a, n, c, x): rubi.append(5457) return Dist(x**(S(2)*p)*(c + d/x**S(2))**p*(a**S(2)*x**S(2) + S(1))**(-p), Int(u*x**(-S(2)*p)*(a**S(2)*x**S(2) + S(1))**p*exp(n*ArcTan(a*x)), x), x) rule5457 = ReplacementRule(pattern5457, replacement5457) pattern5458 = Pattern(Integral(exp(ArcTan((a_ + x_*WC('b', S(1)))*WC('c', S(1)))*WC('n', S(1))), x_), cons2, cons3, cons7, cons4, cons1579) def replacement5458(b, c, n, a, x): rubi.append(5458) return Int((-I*a*c - I*b*c*x + S(1))**(I*n/S(2))*(I*a*c + I*b*c*x + S(1))**(-I*n/S(2)), x) rule5458 = ReplacementRule(pattern5458, replacement5458) pattern5459 = Pattern(Integral(x_**m_*exp(n_*ArcTan((a_ + x_*WC('b', S(1)))*WC('c', S(1)))), x_), cons2, cons3, cons7, cons84, cons1816, cons1817) def replacement5459(m, b, c, n, a, x): rubi.append(5459) return Dist(S(4)*I**(-m)*b**(-m + S(-1))*c**(-m + S(-1))/n, Subst(Int(x**(-S(2)*I/n)*(S(1) + x**(-S(2)*I/n))**(-m + S(-2))*(-I*a*c + S(1) - x**(-S(2)*I/n)*(I*a*c + S(1)))**m, x), x, (-I*c*(a + b*x) + S(1))**(I*n/S(2))*(I*c*(a + b*x) + S(1))**(-I*n/S(2))), x) rule5459 = ReplacementRule(pattern5459, replacement5459) pattern5460 = Pattern(Integral((x_*WC('e', S(1)) + WC('d', S(0)))**WC('m', S(1))*exp(ArcTan((a_ + x_*WC('b', S(1)))*WC('c', S(1)))*WC('n', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons21, cons4, cons1580) def replacement5460(m, b, d, c, n, a, x, e): rubi.append(5460) return Int((d + e*x)**m*(-I*a*c - I*b*c*x + S(1))**(I*n/S(2))*(I*a*c + I*b*c*x + S(1))**(-I*n/S(2)), x) rule5460 = ReplacementRule(pattern5460, replacement5460) pattern5461 = Pattern(Integral((c_ + x_**S(2)*WC('e', S(1)) + x_*WC('d', S(1)))**WC('p', S(1))*WC('u', S(1))*exp(ArcTan(a_ + x_*WC('b', S(1)))*WC('n', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons4, cons5, cons1818, cons1819, cons1820) def replacement5461(p, u, b, d, a, n, c, x, e): rubi.append(5461) return Dist((c/(a**S(2) + S(1)))**p, Int(u*(-I*a - I*b*x + S(1))**(I*n/S(2) + p)*(I*a + I*b*x + S(1))**(-I*n/S(2) + p), x), x) rule5461 = ReplacementRule(pattern5461, replacement5461) pattern5462 = Pattern(Integral((c_ + x_**S(2)*WC('e', S(1)) + x_*WC('d', S(1)))**WC('p', S(1))*WC('u', S(1))*exp(ArcTan(a_ + x_*WC('b', S(1)))*WC('n', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons4, cons5, cons1818, cons1819, cons1821) def replacement5462(p, u, b, d, a, n, c, x, e): rubi.append(5462) return Dist((c + d*x + e*x**S(2))**p*(a**S(2) + S(2)*a*b*x + b**S(2)*x**S(2) + S(1))**(-p), Int(u*(a**S(2) + S(2)*a*b*x + b**S(2)*x**S(2) + S(1))**p*exp(n*ArcTan(a*x)), x), x) rule5462 = ReplacementRule(pattern5462, replacement5462) pattern5463 = Pattern(Integral(WC('u', S(1))*exp(ArcTan(WC('c', S(1))/(x_*WC('b', S(1)) + WC('a', S(0))))*WC('n', S(1))), x_), cons2, cons3, cons7, cons4, cons1579) def replacement5463(u, b, c, n, a, x): rubi.append(5463) return Int(u*exp(n*acot(a/c + b*x/c)), x) rule5463 = ReplacementRule(pattern5463, replacement5463) pattern5464 = Pattern(Integral(WC('u', S(1))*exp(n_*acot(x_*WC('a', S(1)))), x_), cons2, cons1805) def replacement5464(x, a, n, u): rubi.append(5464) return Dist((S(-1))**(I*n/S(2)), Int(u*exp(-n*ArcTan(a*x)), x), x) rule5464 = ReplacementRule(pattern5464, replacement5464) pattern5465 = Pattern(Integral(exp(n_*acot(x_*WC('a', S(1)))), x_), cons2, cons1799) def replacement5465(x, a, n): rubi.append(5465) return -Subst(Int((S(1) - I*x/a)**(I*n/S(2) + S(1)/2)*(S(1) + I*x/a)**(-I*n/S(2) + S(1)/2)/(x**S(2)*sqrt(S(1) + x**S(2)/a**S(2))), x), x, S(1)/x) rule5465 = ReplacementRule(pattern5465, replacement5465) pattern5466 = Pattern(Integral(x_**WC('m', S(1))*exp(n_*acot(x_*WC('a', S(1)))), x_), cons2, cons1799, cons17) def replacement5466(x, m, a, n): rubi.append(5466) return -Subst(Int(x**(-m + S(-2))*(S(1) - I*x/a)**(I*n/S(2) + S(1)/2)*(S(1) + I*x/a)**(-I*n/S(2) + S(1)/2)/sqrt(S(1) + x**S(2)/a**S(2)), x), x, S(1)/x) rule5466 = ReplacementRule(pattern5466, replacement5466) pattern5467 = Pattern(Integral(exp(WC('n', S(1))*acot(x_*WC('a', S(1)))), x_), cons2, cons4, cons1807) def replacement5467(x, a, n): rubi.append(5467) return -Subst(Int((S(1) - I*x/a)**(I*n/S(2))*(S(1) + I*x/a)**(-I*n/S(2))/x**S(2), x), x, S(1)/x) rule5467 = ReplacementRule(pattern5467, replacement5467) pattern5468 = Pattern(Integral(x_**WC('m', S(1))*exp(WC('n', S(1))*acot(x_*WC('a', S(1)))), x_), cons2, cons4, cons1807, cons17) def replacement5468(x, m, a, n): rubi.append(5468) return -Subst(Int(x**(-m + S(-2))*(S(1) - I*x/a)**(n/S(2))*(S(1) + I*x/a)**(-n/S(2)), x), x, S(1)/x) rule5468 = ReplacementRule(pattern5468, replacement5468) pattern5469 = Pattern(Integral(x_**m_*exp(n_*acot(x_*WC('a', S(1)))), x_), cons2, cons21, cons1799, cons18) def replacement5469(x, m, a, n): rubi.append(5469) return -Dist(x**m*(S(1)/x)**m, Subst(Int(x**(-m + S(-2))*(S(1) - I*x/a)**(I*n/S(2) + S(1)/2)*(S(1) + I*x/a)**(-I*n/S(2) + S(1)/2)/sqrt(S(1) + x**S(2)/a**S(2)), x), x, S(1)/x), x) rule5469 = ReplacementRule(pattern5469, replacement5469) pattern5470 = Pattern(Integral(x_**m_*exp(WC('n', S(1))*acot(x_*WC('a', S(1)))), x_), cons2, cons21, cons4, cons1814, cons18) def replacement5470(x, m, a, n): rubi.append(5470) return -Subst(Int(x**(-m + S(-2))*(S(1) - I*x/a)**(n/S(2))*(S(1) + I*x/a)**(-n/S(2)), x), x, S(1)/x) rule5470 = ReplacementRule(pattern5470, replacement5470) pattern5471 = Pattern(Integral((c_ + x_*WC('d', S(1)))**WC('p', S(1))*WC('u', S(1))*exp(WC('n', S(1))*acot(x_*WC('a', S(1)))), x_), cons2, cons7, cons27, cons4, cons1801, cons1814, cons38) def replacement5471(p, u, d, a, n, c, x): rubi.append(5471) return Dist(d**p, Int(u*x**p*(c/(d*x) + S(1))**p*exp(n*acot(a*x)), x), x) rule5471 = ReplacementRule(pattern5471, replacement5471) pattern5472 = Pattern(Integral((c_ + x_*WC('d', S(1)))**p_*WC('u', S(1))*exp(WC('n', S(1))*acot(x_*WC('a', S(1)))), x_), cons2, cons7, cons27, cons4, cons5, cons1801, cons1814, cons147) def replacement5472(p, u, d, a, n, c, x): rubi.append(5472) return Dist(x**(-p)*(c + d*x)**p*(c/(d*x) + S(1))**(-p), Int(u*x**p*(c/(d*x) + S(1))**p*exp(n*acot(a*x)), x), x) rule5472 = ReplacementRule(pattern5472, replacement5472) pattern5473 = Pattern(Integral((c_ + WC('d', S(1))/x_)**WC('p', S(1))*exp(WC('n', S(1))*acot(x_*WC('a', S(1)))), x_), cons2, cons7, cons27, cons4, cons5, cons1804, cons1814, cons1802) def replacement5473(p, d, a, n, c, x): rubi.append(5473) return -Dist(c**p, Subst(Int((S(1) - I*x/a)**(I*n/S(2))*(S(1) + I*x/a)**(-I*n/S(2))*(S(1) + d*x/c)**p/x**S(2), x), x, S(1)/x), x) rule5473 = ReplacementRule(pattern5473, replacement5473) pattern5474 = Pattern(Integral(x_**WC('m', S(1))*(c_ + WC('d', S(1))/x_)**WC('p', S(1))*exp(WC('n', S(1))*acot(x_*WC('a', S(1)))), x_), cons2, cons7, cons27, cons21, cons4, cons5, cons1804, cons1814, cons1802, cons17) def replacement5474(p, m, d, a, n, c, x): rubi.append(5474) return -Dist(c**p, Subst(Int(x**(-m + S(-2))*(S(1) - I*x/a)**(I*n/S(2))*(S(1) + I*x/a)**(-I*n/S(2))*(S(1) + d*x/c)**p, x), x, S(1)/x), x) rule5474 = ReplacementRule(pattern5474, replacement5474) pattern5475 = Pattern(Integral((c_ + WC('d', S(1))/x_)**p_*exp(WC('n', S(1))*acot(x_*WC('a', S(1)))), x_), cons2, cons7, cons27, cons4, cons5, cons1804, cons1814, cons1803) def replacement5475(p, d, a, n, c, x): rubi.append(5475) return Dist((S(1) + d/(c*x))**(-p)*(c + d/x)**p, Int((S(1) + d/(c*x))**p*exp(n*acot(a*x)), x), x) rule5475 = ReplacementRule(pattern5475, replacement5475) pattern5476 = Pattern(Integral(x_**m_*(c_ + WC('d', S(1))/x_)**WC('p', S(1))*exp(WC('n', S(1))*acot(x_*WC('a', S(1)))), x_), cons2, cons7, cons27, cons21, cons4, cons5, cons1804, cons1814, cons1802, cons18) def replacement5476(p, m, d, a, n, c, x): rubi.append(5476) return -Dist(c**p*x**m*(S(1)/x)**m, Subst(Int(x**(-m + S(-2))*(S(1) - I*x/a)**(I*n/S(2))*(S(1) + I*x/a)**(-I*n/S(2))*(S(1) + d*x/c)**p, x), x, S(1)/x), x) rule5476 = ReplacementRule(pattern5476, replacement5476) pattern5477 = Pattern(Integral((c_ + WC('d', S(1))/x_)**p_*WC('u', S(1))*exp(WC('n', S(1))*acot(x_*WC('a', S(1)))), x_), cons2, cons7, cons27, cons4, cons5, cons1804, cons1814, cons1803) def replacement5477(p, u, d, a, n, c, x): rubi.append(5477) return Dist((S(1) + d/(c*x))**(-p)*(c + d/x)**p, Int(u*(S(1) + d/(c*x))**p*exp(n*acot(a*x)), x), x) rule5477 = ReplacementRule(pattern5477, replacement5477) pattern5478 = Pattern(Integral(exp(WC('n', S(1))*acot(x_*WC('a', S(1))))/(c_ + x_**S(2)*WC('d', S(1))), x_), cons2, cons7, cons27, cons4, cons1806) def replacement5478(d, a, n, c, x): rubi.append(5478) return -Simp(exp(n*acot(a*x))/(a*c*n), x) rule5478 = ReplacementRule(pattern5478, replacement5478) pattern5479 = Pattern(Integral(exp(WC('n', S(1))*acot(x_*WC('a', S(1))))/(c_ + x_**S(2)*WC('d', S(1)))**(S(3)/2), x_), cons2, cons7, cons27, cons4, cons1806, cons1800) def replacement5479(d, a, n, c, x): rubi.append(5479) return -Simp((-a*x + n)*exp(n*acot(a*x))/(a*c*sqrt(c + d*x**S(2))*(n**S(2) + S(1))), x) rule5479 = ReplacementRule(pattern5479, replacement5479) pattern5480 = Pattern(Integral((c_ + x_**S(2)*WC('d', S(1)))**p_*exp(WC('n', S(1))*acot(x_*WC('a', S(1)))), x_), cons2, cons7, cons27, cons4, cons1806, cons13, cons137, cons230, cons1808, cons1822, cons1823) def replacement5480(p, d, a, n, c, x): rubi.append(5480) return Dist(S(2)*(p + S(1))*(S(2)*p + S(3))/(c*(n**S(2) + S(4)*(p + S(1))**S(2))), Int((c + d*x**S(2))**(p + S(1))*exp(n*acot(a*x)), x), x) - Simp((c + d*x**S(2))**(p + S(1))*(S(2)*a*x*(p + S(1)) + n)*exp(n*acot(a*x))/(a*c*(n**S(2) + S(4)*(p + S(1))**S(2))), x) rule5480 = ReplacementRule(pattern5480, replacement5480) pattern5481 = Pattern(Integral(x_*exp(WC('n', S(1))*acot(x_*WC('a', S(1))))/(c_ + x_**S(2)*WC('d', S(1)))**(S(3)/2), x_), cons2, cons7, cons27, cons4, cons1806, cons1800) def replacement5481(d, a, n, c, x): rubi.append(5481) return -Simp((a*n*x + S(1))*exp(n*acot(a*x))/(a**S(2)*c*sqrt(c + d*x**S(2))*(n**S(2) + S(1))), x) rule5481 = ReplacementRule(pattern5481, replacement5481) pattern5482 = Pattern(Integral(x_*(c_ + x_**S(2)*WC('d', S(1)))**p_*exp(WC('n', S(1))*acot(x_*WC('a', S(1)))), x_), cons2, cons7, cons27, cons4, cons1806, cons13, cons1824, cons230, cons1808, cons1822, cons1823) def replacement5482(p, d, a, n, c, x): rubi.append(5482) return Dist(n*(S(2)*p + S(3))/(a*c*(n**S(2) + S(4)*(p + S(1))**S(2))), Int((c + d*x**S(2))**(p + S(1))*exp(n*acot(a*x)), x), x) + Simp((c + d*x**S(2))**(p + S(1))*(-a*n*x + S(2)*p + S(2))*exp(n*acot(a*x))/(a**S(2)*c*(n**S(2) + S(4)*(p + S(1))**S(2))), x) rule5482 = ReplacementRule(pattern5482, replacement5482) pattern5483 = Pattern(Integral(x_**S(2)*(c_ + x_**S(2)*WC('d', S(1)))**WC('p', S(1))*exp(WC('n', S(1))*acot(x_*WC('a', S(1)))), x_), cons2, cons7, cons27, cons4, cons1806, cons1813, cons1825) def replacement5483(p, d, a, n, c, x): rubi.append(5483) return Simp((c + d*x**S(2))**(p + S(1))*(S(2)*a*x*(p + S(1)) + n)*exp(n*acot(a*x))/(a**S(3)*c*n**S(2)*(n**S(2) + S(1))), x) rule5483 = ReplacementRule(pattern5483, replacement5483) pattern5484 = Pattern(Integral(x_**S(2)*(c_ + x_**S(2)*WC('d', S(1)))**p_*exp(WC('n', S(1))*acot(x_*WC('a', S(1)))), x_), cons2, cons7, cons27, cons4, cons1806, cons13, cons1824, cons1826, cons1808, cons1822, cons1823) def replacement5484(p, d, a, n, c, x): rubi.append(5484) return Dist((n**S(2) - S(2)*p + S(-2))/(a**S(2)*c*(n**S(2) + S(4)*(p + S(1))**S(2))), Int((c + d*x**S(2))**(p + S(1))*exp(n*acot(a*x)), x), x) + Simp((c + d*x**S(2))**(p + S(1))*(S(2)*a*x*(p + S(1)) + n)*exp(n*acot(a*x))/(a**S(3)*c*(n**S(2) + S(4)*(p + S(1))**S(2))), x) rule5484 = ReplacementRule(pattern5484, replacement5484) pattern5485 = Pattern(Integral(x_**WC('m', S(1))*(c_ + x_**S(2)*WC('d', S(1)))**p_*exp(WC('n', S(1))*acot(x_*WC('a', S(1)))), x_), cons2, cons7, cons27, cons4, cons1806, cons17, cons1827, cons38) def replacement5485(p, m, d, a, n, c, x): rubi.append(5485) return -Dist(a**(-m + S(-1))*c**p, Subst(Int((S(1)/tan(x))**(m + S(2)*p + S(2))*exp(n*x)*cos(x)**(-S(2)*p + S(-2)), x), x, acot(a*x)), x) rule5485 = ReplacementRule(pattern5485, replacement5485) pattern5486 = Pattern(Integral((c_ + x_**S(2)*WC('d', S(1)))**WC('p', S(1))*WC('u', S(1))*exp(WC('n', S(1))*acot(x_*WC('a', S(1)))), x_), cons2, cons7, cons27, cons4, cons1806, cons1814, cons38) def replacement5486(p, u, d, a, n, c, x): rubi.append(5486) return Dist(d**p, Int(u*x**(S(2)*p)*(S(1) + S(1)/(a**S(2)*x**S(2)))**p*exp(n*acot(a*x)), x), x) rule5486 = ReplacementRule(pattern5486, replacement5486) pattern5487 = Pattern(Integral((c_ + x_**S(2)*WC('d', S(1)))**p_*WC('u', S(1))*exp(WC('n', S(1))*acot(x_*WC('a', S(1)))), x_), cons2, cons7, cons27, cons4, cons5, cons1806, cons1814, cons147) def replacement5487(p, u, d, a, n, c, x): rubi.append(5487) return Dist(x**(-S(2)*p)*(S(1) + S(1)/(a**S(2)*x**S(2)))**(-p)*(c + d*x**S(2))**p, Int(u*x**(S(2)*p)*(S(1) + S(1)/(a**S(2)*x**S(2)))**p*exp(n*acot(a*x)), x), x) rule5487 = ReplacementRule(pattern5487, replacement5487) pattern5488 = Pattern(Integral((c_ + WC('d', S(1))/x_**S(2))**WC('p', S(1))*WC('u', S(1))*exp(WC('n', S(1))*acot(x_*WC('a', S(1)))), x_), cons2, cons7, cons27, cons4, cons5, cons1815, cons1814, cons1802, cons1828) def replacement5488(p, u, d, a, n, c, x): rubi.append(5488) return Dist(c**p*(I*a)**(-S(2)*p), Int(u*x**(-S(2)*p)*(I*a*x + S(-1))**(-I*n/S(2) + p)*(I*a*x + S(1))**(I*n/S(2) + p), x), x) rule5488 = ReplacementRule(pattern5488, replacement5488) pattern5489 = Pattern(Integral((c_ + WC('d', S(1))/x_**S(2))**WC('p', S(1))*exp(WC('n', S(1))*acot(x_*WC('a', S(1)))), x_), cons2, cons7, cons27, cons4, cons5, cons1815, cons1814, cons1802, cons1829) def replacement5489(p, d, a, n, c, x): rubi.append(5489) return -Dist(c**p, Subst(Int((S(1) - I*x/a)**(I*n/S(2) + p)*(S(1) + I*x/a)**(-I*n/S(2) + p)/x**S(2), x), x, S(1)/x), x) rule5489 = ReplacementRule(pattern5489, replacement5489) pattern5490 = Pattern(Integral(x_**WC('m', S(1))*(c_ + WC('d', S(1))/x_**S(2))**WC('p', S(1))*exp(WC('n', S(1))*acot(x_*WC('a', S(1)))), x_), cons2, cons7, cons27, cons4, cons5, cons1815, cons1814, cons1802, cons1829, cons17) def replacement5490(p, m, d, a, n, c, x): rubi.append(5490) return -Dist(c**p, Subst(Int(x**(-m + S(-2))*(S(1) - I*x/a)**(I*n/S(2) + p)*(S(1) + I*x/a)**(-I*n/S(2) + p), x), x, S(1)/x), x) rule5490 = ReplacementRule(pattern5490, replacement5490) pattern5491 = Pattern(Integral(x_**m_*(c_ + WC('d', S(1))/x_**S(2))**WC('p', S(1))*exp(WC('n', S(1))*acot(x_*WC('a', S(1)))), x_), cons2, cons7, cons27, cons21, cons4, cons5, cons1815, cons1814, cons1802, cons1829, cons18) def replacement5491(p, m, d, a, n, c, x): rubi.append(5491) return -Dist(c**p*x**m*(S(1)/x)**m, Subst(Int(x**(-m + S(-2))*(S(1) - I*x/a)**(I*n/S(2) + p)*(S(1) + I*x/a)**(-I*n/S(2) + p), x), x, S(1)/x), x) rule5491 = ReplacementRule(pattern5491, replacement5491) pattern5492 = Pattern(Integral((c_ + WC('d', S(1))/x_**S(2))**p_*WC('u', S(1))*exp(WC('n', S(1))*acot(x_*WC('a', S(1)))), x_), cons2, cons7, cons27, cons4, cons5, cons1815, cons1814, cons1803) def replacement5492(p, u, d, a, n, c, x): rubi.append(5492) return Dist((S(1) + S(1)/(a**S(2)*x**S(2)))**(-p)*(c + d/x**S(2))**p, Int(u*(S(1) + S(1)/(a**S(2)*x**S(2)))**p*exp(n*acot(a*x)), x), x) rule5492 = ReplacementRule(pattern5492, replacement5492) pattern5493 = Pattern(Integral(WC('u', S(1))*exp(n_*acot((a_ + x_*WC('b', S(1)))*WC('c', S(1)))), x_), cons2, cons3, cons7, cons1805) def replacement5493(u, b, c, a, n, x): rubi.append(5493) return Dist((S(-1))**(I*n/S(2)), Int(u*exp(-n*ArcTan(c*(a + b*x))), x), x) rule5493 = ReplacementRule(pattern5493, replacement5493) pattern5494 = Pattern(Integral(exp(WC('n', S(1))*acot((a_ + x_*WC('b', S(1)))*WC('c', S(1)))), x_), cons2, cons3, cons7, cons4, cons1814) def replacement5494(b, c, n, a, x): rubi.append(5494) return Dist((I*c*(a + b*x))**(I*n/S(2))*(S(1) - I/(c*(a + b*x)))**(I*n/S(2))*(I*a*c + I*b*c*x + S(1))**(-I*n/S(2)), Int((I*a*c + I*b*c*x + S(-1))**(-I*n/S(2))*(I*a*c + I*b*c*x + S(1))**(I*n/S(2)), x), x) rule5494 = ReplacementRule(pattern5494, replacement5494) pattern5495 = Pattern(Integral(x_**m_*exp(n_*acoth((a_ + x_*WC('b', S(1)))*WC('c', S(1)))), x_), cons2, cons3, cons7, cons84, cons1816, cons1817) def replacement5495(m, b, c, n, a, x): rubi.append(5495) return Dist(S(4)*I**(-m)*b**(-m + S(-1))*c**(-m + S(-1))/n, Subst(Int(x**(-S(2)*I/n)*(S(-1) + x**(-S(2)*I/n))**(-m + S(-2))*(I*a*c + S(1) + x**(-S(2)*I/n)*(-I*a*c + S(1)))**m, x), x, (S(1) - I/(c*(a + b*x)))**(I*n/S(2))*(S(1) + I/(c*(a + b*x)))**(-I*n/S(2))), x) rule5495 = ReplacementRule(pattern5495, replacement5495) pattern5496 = Pattern(Integral((x_*WC('e', S(1)) + WC('d', S(0)))**WC('m', S(1))*exp(WC('n', S(1))*acoth((a_ + x_*WC('b', S(1)))*WC('c', S(1)))), x_), cons2, cons3, cons7, cons27, cons48, cons21, cons4, cons1814) def replacement5496(m, b, d, c, n, a, x, e): rubi.append(5496) return Dist((I*c*(a + b*x))**(I*n/S(2))*(S(1) - I/(c*(a + b*x)))**(I*n/S(2))*(I*a*c + I*b*c*x + S(1))**(-I*n/S(2)), Int((d + e*x)**m*(I*a*c + I*b*c*x + S(-1))**(-I*n/S(2))*(I*a*c + I*b*c*x + S(1))**(I*n/S(2)), x), x) rule5496 = ReplacementRule(pattern5496, replacement5496) pattern5497 = Pattern(Integral((c_ + x_**S(2)*WC('e', S(1)) + x_*WC('d', S(1)))**WC('p', S(1))*WC('u', S(1))*exp(WC('n', S(1))*acot(a_ + x_*WC('b', S(1)))), x_), cons2, cons3, cons7, cons27, cons48, cons4, cons5, cons1814, cons1818, cons1819, cons1820) def replacement5497(p, u, b, d, a, n, c, x, e): rubi.append(5497) return Dist((c/(a**S(2) + S(1)))**p*((I*a + I*b*x + S(1))/(I*a + I*b*x))**(I*n/S(2))*((I*a + I*b*x)/(I*a + I*b*x + S(1)))**(I*n/S(2))*(-I*a - I*b*x + S(1))**(I*n/S(2))*(I*a + I*b*x + S(-1))**(-I*n/S(2)), Int(u*(-I*a - I*b*x + S(1))**(-I*n/S(2) + p)*(I*a + I*b*x + S(1))**(I*n/S(2) + p), x), x) rule5497 = ReplacementRule(pattern5497, replacement5497) pattern5498 = Pattern(Integral((c_ + x_**S(2)*WC('e', S(1)) + x_*WC('d', S(1)))**WC('p', S(1))*WC('u', S(1))*exp(WC('n', S(1))*acot(a_ + x_*WC('b', S(1)))), x_), cons2, cons3, cons7, cons27, cons48, cons4, cons5, cons1814, cons1818, cons1819, cons1821) def replacement5498(p, u, b, d, a, n, c, x, e): rubi.append(5498) return Dist((c + d*x + e*x**S(2))**p*(a**S(2) + S(2)*a*b*x + b**S(2)*x**S(2) + S(1))**(-p), Int(u*(a**S(2) + S(2)*a*b*x + b**S(2)*x**S(2) + S(1))**p*exp(n*acot(a*x)), x), x) rule5498 = ReplacementRule(pattern5498, replacement5498) pattern5499 = Pattern(Integral(WC('u', S(1))*exp(WC('n', S(1))*acot(WC('c', S(1))/(x_*WC('b', S(1)) + WC('a', S(0))))), x_), cons2, cons3, cons7, cons4, cons1579) def replacement5499(u, b, c, n, a, x): rubi.append(5499) return Int(u*exp(n*ArcTan(a/c + b*x/c)), x) rule5499 = ReplacementRule(pattern5499, replacement5499) pattern5500 = Pattern(Integral((ArcTan(c_ + x_*WC('d', S(1)))*WC('b', S(1)) + WC('a', S(0)))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons148) def replacement5500(b, d, c, a, n, x): rubi.append(5500) return Dist(S(1)/d, Subst(Int((a + b*ArcTan(x))**n, x), x, c + d*x), x) rule5500 = ReplacementRule(pattern5500, replacement5500) pattern5501 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*acot(c_ + x_*WC('d', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons148) def replacement5501(b, d, c, a, n, x): rubi.append(5501) return Dist(S(1)/d, Subst(Int((a + b*acot(x))**n, x), x, c + d*x), x) rule5501 = ReplacementRule(pattern5501, replacement5501) pattern5502 = Pattern(Integral((ArcTan(c_ + x_*WC('d', S(1)))*WC('b', S(1)) + WC('a', S(0)))**n_, x_), cons2, cons3, cons7, cons27, cons4, cons340) def replacement5502(b, d, c, a, n, x): rubi.append(5502) return Int((a + b*ArcTan(c + d*x))**n, x) rule5502 = ReplacementRule(pattern5502, replacement5502) pattern5503 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*acot(c_ + x_*WC('d', S(1))))**n_, x_), cons2, cons3, cons7, cons27, cons4, cons340) def replacement5503(b, d, c, a, n, x): rubi.append(5503) return Int((a + b*acot(c + d*x))**n, x) rule5503 = ReplacementRule(pattern5503, replacement5503) pattern5504 = Pattern(Integral((x_*WC('f', S(1)) + WC('e', S(0)))**WC('m', S(1))*(ArcTan(c_ + x_*WC('d', S(1)))*WC('b', S(1)) + WC('a', S(0)))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons4, cons148) def replacement5504(m, f, b, d, a, n, c, x, e): rubi.append(5504) return Dist(S(1)/d, Subst(Int((a + b*ArcTan(x))**n*(f*x/d + (-c*f + d*e)/d)**m, x), x, c + d*x), x) rule5504 = ReplacementRule(pattern5504, replacement5504) pattern5505 = Pattern(Integral((x_*WC('f', S(1)) + WC('e', S(0)))**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*acot(c_ + x_*WC('d', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons4, cons148) def replacement5505(m, f, b, d, a, n, c, x, e): rubi.append(5505) return Dist(S(1)/d, Subst(Int((a + b*acot(x))**n*(f*x/d + (-c*f + d*e)/d)**m, x), x, c + d*x), x) rule5505 = ReplacementRule(pattern5505, replacement5505) pattern5506 = Pattern(Integral((x_*WC('f', S(1)) + WC('e', S(0)))**m_*(ArcTan(c_ + x_*WC('d', S(1)))*WC('b', S(1)) + WC('a', S(0)))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons4, cons340) def replacement5506(m, f, b, d, a, c, n, x, e): rubi.append(5506) return Int((a + b*ArcTan(c + d*x))**n*(e + f*x)**m, x) rule5506 = ReplacementRule(pattern5506, replacement5506) pattern5507 = Pattern(Integral((x_*WC('f', S(1)) + WC('e', S(0)))**m_*(WC('a', S(0)) + WC('b', S(1))*acot(c_ + x_*WC('d', S(1))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons4, cons340) def replacement5507(m, f, b, d, a, c, n, x, e): rubi.append(5507) return Int((a + b*acot(c + d*x))**n*(e + f*x)**m, x) rule5507 = ReplacementRule(pattern5507, replacement5507) pattern5508 = Pattern(Integral((ArcTan(c_ + x_*WC('d', S(1)))*WC('b', S(1)) + WC('a', S(0)))**WC('n', S(1))*(x_**S(2)*WC('C', S(1)) + x_*WC('B', S(1)) + WC('A', S(0)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons34, cons35, cons36, cons4, cons5, cons1830, cons1763) def replacement5508(B, C, p, b, d, a, n, c, x, A): rubi.append(5508) return Dist(S(1)/d, Subst(Int((a + b*ArcTan(x))**n*(C*x**S(2)/d**S(2) + C/d**S(2))**p, x), x, c + d*x), x) rule5508 = ReplacementRule(pattern5508, replacement5508) pattern5509 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*acot(c_ + x_*WC('d', S(1))))**WC('n', S(1))*(x_**S(2)*WC('C', S(1)) + x_*WC('B', S(1)) + WC('A', S(0)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons34, cons35, cons36, cons4, cons5, cons1830, cons1763) def replacement5509(B, C, p, b, d, a, n, c, x, A): rubi.append(5509) return Dist(S(1)/d, Subst(Int((a + b*acot(x))**n*(C*x**S(2)/d**S(2) + C/d**S(2))**p, x), x, c + d*x), x) rule5509 = ReplacementRule(pattern5509, replacement5509) pattern5510 = Pattern(Integral((x_*WC('f', S(1)) + WC('e', S(0)))**WC('m', S(1))*(ArcTan(c_ + x_*WC('d', S(1)))*WC('b', S(1)) + WC('a', S(0)))**WC('n', S(1))*(x_**S(2)*WC('C', S(1)) + x_*WC('B', S(1)) + WC('A', S(0)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons36, cons21, cons4, cons5, cons1830, cons1763) def replacement5510(B, C, p, m, f, b, d, a, n, c, A, x, e): rubi.append(5510) return Dist(S(1)/d, Subst(Int((a + b*ArcTan(x))**n*(C*x**S(2)/d**S(2) + C/d**S(2))**p*(f*x/d + (-c*f + d*e)/d)**m, x), x, c + d*x), x) rule5510 = ReplacementRule(pattern5510, replacement5510) pattern5511 = Pattern(Integral((x_*WC('f', S(1)) + WC('e', S(0)))**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*acot(c_ + x_*WC('d', S(1))))**WC('n', S(1))*(x_**S(2)*WC('C', S(1)) + x_*WC('B', S(1)) + WC('A', S(0)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons36, cons21, cons4, cons5, cons1830, cons1763) def replacement5511(B, C, p, m, f, b, d, a, n, c, A, x, e): rubi.append(5511) return Dist(S(1)/d, Subst(Int((a + b*acot(x))**n*(C*x**S(2)/d**S(2) + C/d**S(2))**p*(f*x/d + (-c*f + d*e)/d)**m, x), x, c + d*x), x) rule5511 = ReplacementRule(pattern5511, replacement5511) pattern5512 = Pattern(Integral(ArcTan(a_ + x_*WC('b', S(1)))/(c_ + x_**WC('n', S(1))*WC('d', S(1))), x_), cons2, cons3, cons7, cons27, cons87) def replacement5512(b, d, a, n, c, x): rubi.append(5512) return Dist(I/S(2), Int(log(-I*a - I*b*x + S(1))/(c + d*x**n), x), x) - Dist(I/S(2), Int(log(I*a + I*b*x + S(1))/(c + d*x**n), x), x) rule5512 = ReplacementRule(pattern5512, replacement5512) pattern5513 = Pattern(Integral(acot(a_ + x_*WC('b', S(1)))/(c_ + x_**WC('n', S(1))*WC('d', S(1))), x_), cons2, cons3, cons7, cons27, cons87) def replacement5513(b, d, a, n, c, x): rubi.append(5513) return Dist(I/S(2), Int(log((a + b*x - I)/(a + b*x))/(c + d*x**n), x), x) - Dist(I/S(2), Int(log((a + b*x + I)/(a + b*x))/(c + d*x**n), x), x) rule5513 = ReplacementRule(pattern5513, replacement5513) pattern5514 = Pattern(Integral(ArcTan(a_ + x_*WC('b', S(1)))/(c_ + x_**n_*WC('d', S(1))), x_), cons2, cons3, cons7, cons27, cons4, cons1094) def replacement5514(b, d, c, a, n, x): rubi.append(5514) return Int(ArcTan(a + b*x)/(c + d*x**n), x) rule5514 = ReplacementRule(pattern5514, replacement5514) pattern5515 = Pattern(Integral(acot(a_ + x_*WC('b', S(1)))/(c_ + x_**n_*WC('d', S(1))), x_), cons2, cons3, cons7, cons27, cons4, cons1094) def replacement5515(b, d, c, a, n, x): rubi.append(5515) return Int(acot(a + b*x)/(c + d*x**n), x) rule5515 = ReplacementRule(pattern5515, replacement5515) pattern5516 = Pattern(Integral(ArcTan(a_ + x_**n_*WC('b', S(1))), x_), cons2, cons3, cons4, cons1831) def replacement5516(x, a, n, b): rubi.append(5516) return -Dist(b*n, Int(x**n/(a**S(2) + S(2)*a*b*x**n + b**S(2)*x**(S(2)*n) + S(1)), x), x) + Simp(x*ArcTan(a + b*x**n), x) rule5516 = ReplacementRule(pattern5516, replacement5516) pattern5517 = Pattern(Integral(acot(a_ + x_**n_*WC('b', S(1))), x_), cons2, cons3, cons4, cons1831) def replacement5517(x, a, n, b): rubi.append(5517) return Dist(b*n, Int(x**n/(a**S(2) + S(2)*a*b*x**n + b**S(2)*x**(S(2)*n) + S(1)), x), x) + Simp(x*acot(a + b*x**n), x) rule5517 = ReplacementRule(pattern5517, replacement5517) pattern5518 = Pattern(Integral(ArcTan(x_**n_*WC('b', S(1)) + WC('a', S(0)))/x_, x_), cons2, cons3, cons4, cons1831) def replacement5518(x, a, n, b): rubi.append(5518) return Dist(I/S(2), Int(log(-I*a - I*b*x**n + S(1))/x, x), x) - Dist(I/S(2), Int(log(I*a + I*b*x**n + S(1))/x, x), x) rule5518 = ReplacementRule(pattern5518, replacement5518) pattern5519 = Pattern(Integral(acot(x_**n_*WC('b', S(1)) + WC('a', S(0)))/x_, x_), cons2, cons3, cons4, cons1831) def replacement5519(x, a, n, b): rubi.append(5519) return Dist(I/S(2), Int(log(S(1) - I/(a + b*x**n))/x, x), x) - Dist(I/S(2), Int(log(S(1) + I/(a + b*x**n))/x, x), x) rule5519 = ReplacementRule(pattern5519, replacement5519) pattern5520 = Pattern(Integral(x_**WC('m', S(1))*ArcTan(a_ + x_**n_*WC('b', S(1))), x_), cons2, cons3, cons93, cons1832, cons1833) def replacement5520(m, b, a, n, x): rubi.append(5520) return -Dist(b*n/(m + S(1)), Int(x**(m + n)/(a**S(2) + S(2)*a*b*x**n + b**S(2)*x**(S(2)*n) + S(1)), x), x) + Simp(x**(m + S(1))*ArcTan(a + b*x**n)/(m + S(1)), x) rule5520 = ReplacementRule(pattern5520, replacement5520) pattern5521 = Pattern(Integral(x_**WC('m', S(1))*acot(a_ + x_**n_*WC('b', S(1))), x_), cons2, cons3, cons93, cons1832, cons1833) def replacement5521(m, b, a, n, x): rubi.append(5521) return Dist(b*n/(m + S(1)), Int(x**(m + n)/(a**S(2) + S(2)*a*b*x**n + b**S(2)*x**(S(2)*n) + S(1)), x), x) + Simp(x**(m + S(1))*acot(a + b*x**n)/(m + S(1)), x) rule5521 = ReplacementRule(pattern5521, replacement5521) pattern5522 = Pattern(Integral(ArcTan(f_**(x_*WC('d', S(1)) + WC('c', S(0)))*WC('b', S(1)) + WC('a', S(0))), x_), cons2, cons3, cons7, cons27, cons125, cons1834) def replacement5522(f, b, d, c, a, x): rubi.append(5522) return Dist(I/S(2), Int(log(-I*a - I*b*f**(c + d*x) + S(1)), x), x) - Dist(I/S(2), Int(log(I*a + I*b*f**(c + d*x) + S(1)), x), x) rule5522 = ReplacementRule(pattern5522, replacement5522) pattern5523 = Pattern(Integral(acot(f_**(x_*WC('d', S(1)) + WC('c', S(0)))*WC('b', S(1)) + WC('a', S(0))), x_), cons2, cons3, cons7, cons27, cons125, cons1834) def replacement5523(f, b, d, c, a, x): rubi.append(5523) return Dist(I/S(2), Int(log(S(1) - I/(a + b*f**(c + d*x))), x), x) - Dist(I/S(2), Int(log(S(1) + I/(a + b*f**(c + d*x))), x), x) rule5523 = ReplacementRule(pattern5523, replacement5523) pattern5524 = Pattern(Integral(x_**WC('m', S(1))*ArcTan(f_**(x_*WC('d', S(1)) + WC('c', S(0)))*WC('b', S(1)) + WC('a', S(0))), x_), cons2, cons3, cons7, cons27, cons125, cons17, cons168) def replacement5524(m, f, b, d, c, a, x): rubi.append(5524) return Dist(I/S(2), Int(x**m*log(-I*a - I*b*f**(c + d*x) + S(1)), x), x) - Dist(I/S(2), Int(x**m*log(I*a + I*b*f**(c + d*x) + S(1)), x), x) rule5524 = ReplacementRule(pattern5524, replacement5524) pattern5525 = Pattern(Integral(x_**WC('m', S(1))*acot(f_**(x_*WC('d', S(1)) + WC('c', S(0)))*WC('b', S(1)) + WC('a', S(0))), x_), cons2, cons3, cons7, cons27, cons125, cons17, cons168) def replacement5525(m, f, b, d, c, a, x): rubi.append(5525) return Dist(I/S(2), Int(x**m*log(S(1) - I/(a + b*f**(c + d*x))), x), x) - Dist(I/S(2), Int(x**m*log(S(1) + I/(a + b*f**(c + d*x))), x), x) rule5525 = ReplacementRule(pattern5525, replacement5525) pattern5526 = Pattern(Integral(ArcTan(WC('c', S(1))/(x_**WC('n', S(1))*WC('b', S(1)) + WC('a', S(0))))**WC('m', S(1))*WC('u', S(1)), x_), cons2, cons3, cons7, cons4, cons21, cons1766) def replacement5526(u, m, b, c, n, a, x): rubi.append(5526) return Int(u*acot(a/c + b*x**n/c)**m, x) rule5526 = ReplacementRule(pattern5526, replacement5526) pattern5527 = Pattern(Integral(WC('u', S(1))*acot(WC('c', S(1))/(x_**WC('n', S(1))*WC('b', S(1)) + WC('a', S(0))))**WC('m', S(1)), x_), cons2, cons3, cons7, cons4, cons21, cons1766) def replacement5527(u, m, b, c, n, a, x): rubi.append(5527) return Int(u*ArcTan(a/c + b*x**n/c)**m, x) rule5527 = ReplacementRule(pattern5527, replacement5527) pattern5528 = Pattern(Integral(S(1)/(sqrt(x_**S(2)*WC('b', S(1)) + WC('a', S(0)))*ArcTan(x_*WC('c', S(1))/sqrt(x_**S(2)*WC('b', S(1)) + WC('a', S(0))))), x_), cons2, cons3, cons7, cons1835) def replacement5528(x, c, b, a): rubi.append(5528) return Simp(log(ArcTan(c*x/sqrt(a + b*x**S(2))))/c, x) rule5528 = ReplacementRule(pattern5528, replacement5528) pattern5529 = Pattern(Integral(S(1)/(sqrt(x_**S(2)*WC('b', S(1)) + WC('a', S(0)))*acot(x_*WC('c', S(1))/sqrt(x_**S(2)*WC('b', S(1)) + WC('a', S(0))))), x_), cons2, cons3, cons7, cons1835) def replacement5529(x, c, b, a): rubi.append(5529) return -Simp(log(acot(c*x/sqrt(a + b*x**S(2))))/c, x) rule5529 = ReplacementRule(pattern5529, replacement5529) pattern5530 = Pattern(Integral(ArcTan(x_*WC('c', S(1))/sqrt(x_**S(2)*WC('b', S(1)) + WC('a', S(0))))**WC('m', S(1))/sqrt(x_**S(2)*WC('b', S(1)) + WC('a', S(0))), x_), cons2, cons3, cons7, cons21, cons1835, cons66) def replacement5530(m, b, c, a, x): rubi.append(5530) return Simp(ArcTan(c*x/sqrt(a + b*x**S(2)))**(m + S(1))/(c*(m + S(1))), x) rule5530 = ReplacementRule(pattern5530, replacement5530) pattern5531 = Pattern(Integral(acot(x_*WC('c', S(1))/sqrt(x_**S(2)*WC('b', S(1)) + WC('a', S(0))))**WC('m', S(1))/sqrt(x_**S(2)*WC('b', S(1)) + WC('a', S(0))), x_), cons2, cons3, cons7, cons21, cons1835, cons66) def replacement5531(m, b, c, a, x): rubi.append(5531) return -Simp(acot(c*x/sqrt(a + b*x**S(2)))**(m + S(1))/(c*(m + S(1))), x) rule5531 = ReplacementRule(pattern5531, replacement5531) pattern5532 = Pattern(Integral(ArcTan(x_*WC('c', S(1))/sqrt(x_**S(2)*WC('b', S(1)) + WC('a', S(0))))**WC('m', S(1))/sqrt(x_**S(2)*WC('e', S(1)) + WC('d', S(0))), x_), cons2, cons3, cons7, cons27, cons48, cons21, cons1835, cons383) def replacement5532(m, b, d, c, a, x, e): rubi.append(5532) return Dist(sqrt(a + b*x**S(2))/sqrt(d + e*x**S(2)), Int(ArcTan(c*x/sqrt(a + b*x**S(2)))**m/sqrt(a + b*x**S(2)), x), x) rule5532 = ReplacementRule(pattern5532, replacement5532) pattern5533 = Pattern(Integral(acot(x_*WC('c', S(1))/sqrt(x_**S(2)*WC('b', S(1)) + WC('a', S(0))))**WC('m', S(1))/sqrt(x_**S(2)*WC('e', S(1)) + WC('d', S(0))), x_), cons2, cons3, cons7, cons27, cons48, cons21, cons1835, cons383) def replacement5533(m, b, d, c, a, x, e): rubi.append(5533) return Dist(sqrt(a + b*x**S(2))/sqrt(d + e*x**S(2)), Int(acot(c*x/sqrt(a + b*x**S(2)))**m/sqrt(a + b*x**S(2)), x), x) rule5533 = ReplacementRule(pattern5533, replacement5533) pattern5534 = Pattern(Integral(ArcTan(v_ + sqrt(w_)*WC('s', S(1)))*WC('u', S(1)), x_), cons1836, cons1837) def replacement5534(v, w, u, x, s): rubi.append(5534) return Dist(S(1)/2, Int(u*ArcTan(v), x), x) + Dist(Pi*s/S(4), Int(u, x), x) rule5534 = ReplacementRule(pattern5534, replacement5534) pattern5535 = Pattern(Integral(WC('u', S(1))*acot(v_ + sqrt(w_)*WC('s', S(1))), x_), cons1836, cons1837) def replacement5535(v, w, u, x, s): rubi.append(5535) return -Dist(S(1)/2, Int(u*ArcTan(v), x), x) + Dist(Pi*s/S(4), Int(u, x), x) rule5535 = ReplacementRule(pattern5535, replacement5535) def With5536(v, x, n, u): if isinstance(x, (int, Integer, float, Float)): return False try: tmp = InverseFunctionOfLinear(u, x) res = And(Not(FalseQ(tmp)), SameQ(Head(tmp), ArcTan), ZeroQ(D(v, x)**S(2) + Discriminant(v, x)*Part(tmp, S(1))**S(2))) except (TypeError, AttributeError): return False if res: return True return False pattern5536 = Pattern(Integral(u_*v_**WC('n', S(1)), x_), cons818, cons85, cons463, cons1838, cons1839, CustomConstraint(With5536)) def replacement5536(v, x, n, u): tmp = InverseFunctionOfLinear(u, x) rubi.append(5536) return Dist((-Discriminant(v, x)/(S(4)*Coefficient(v, x, S(2))))**n/Coefficient(Part(tmp, S(1)), x, S(1)), Subst(Int(SimplifyIntegrand((S(1)/cos(x))**(S(2)*n + S(2))*SubstForInverseFunction(u, tmp, x), x), x), x, tmp), x) rule5536 = ReplacementRule(pattern5536, replacement5536) def With5537(v, x, n, u): if isinstance(x, (int, Integer, float, Float)): return False try: tmp = InverseFunctionOfLinear(u, x) res = And(Not(FalseQ(tmp)), SameQ(Head(tmp), ArcCot), ZeroQ(D(v, x)**S(2) + Discriminant(v, x)*Part(tmp, S(1))**S(2))) except (TypeError, AttributeError): return False if res: return True return False pattern5537 = Pattern(Integral(u_*v_**WC('n', S(1)), x_), cons818, cons85, cons463, cons1838, cons1840, CustomConstraint(With5537)) def replacement5537(v, x, n, u): tmp = InverseFunctionOfLinear(u, x) rubi.append(5537) return -Dist((-Discriminant(v, x)/(S(4)*Coefficient(v, x, S(2))))**n/Coefficient(Part(tmp, S(1)), x, S(1)), Subst(Int(SimplifyIntegrand((S(1)/sin(x))**(S(2)*n + S(2))*SubstForInverseFunction(u, tmp, x), x), x), x, tmp), x) rule5537 = ReplacementRule(pattern5537, replacement5537) pattern5538 = Pattern(Integral(ArcTan(WC('c', S(0)) + WC('d', S(1))*tan(x_*WC('b', S(1)) + WC('a', S(0)))), x_), cons2, cons3, cons7, cons27, cons1841) def replacement5538(b, d, c, a, x): rubi.append(5538) return -Dist(I*b, Int(x/(c*exp(S(2)*I*a + S(2)*I*b*x) + c + I*d), x), x) + Simp(x*ArcTan(c + d*tan(a + b*x)), x) rule5538 = ReplacementRule(pattern5538, replacement5538) pattern5539 = Pattern(Integral(acot(WC('c', S(0)) + WC('d', S(1))*tan(x_*WC('b', S(1)) + WC('a', S(0)))), x_), cons2, cons3, cons7, cons27, cons1841) def replacement5539(b, d, c, a, x): rubi.append(5539) return Dist(I*b, Int(x/(c*exp(S(2)*I*a + S(2)*I*b*x) + c + I*d), x), x) + Simp(x*acot(c + d*tan(a + b*x)), x) rule5539 = ReplacementRule(pattern5539, replacement5539) pattern5540 = Pattern(Integral(ArcTan(WC('c', S(0)) + WC('d', S(1))/tan(x_*WC('b', S(1)) + WC('a', S(0)))), x_), cons2, cons3, cons7, cons27, cons1842) def replacement5540(b, d, c, a, x): rubi.append(5540) return -Dist(I*b, Int(x/(-c*exp(S(2)*I*a + S(2)*I*b*x) + c - I*d), x), x) + Simp(x*ArcTan(c + d/tan(a + b*x)), x) rule5540 = ReplacementRule(pattern5540, replacement5540) pattern5541 = Pattern(Integral(acot(WC('c', S(0)) + WC('d', S(1))/tan(x_*WC('b', S(1)) + WC('a', S(0)))), x_), cons2, cons3, cons7, cons27, cons1842) def replacement5541(b, d, c, a, x): rubi.append(5541) return Dist(I*b, Int(x/(-c*exp(S(2)*I*a + S(2)*I*b*x) + c - I*d), x), x) + Simp(x*acot(c + d/tan(a + b*x)), x) rule5541 = ReplacementRule(pattern5541, replacement5541) pattern5542 = Pattern(Integral(ArcTan(WC('c', S(0)) + WC('d', S(1))*tan(x_*WC('b', S(1)) + WC('a', S(0)))), x_), cons2, cons3, cons7, cons27, cons1843) def replacement5542(b, d, c, a, x): rubi.append(5542) return Dist(b*(-I*c - d + S(1)), Int(x*exp(S(2)*I*a + S(2)*I*b*x)/(-I*c + d + (-I*c - d + S(1))*exp(S(2)*I*a + S(2)*I*b*x) + S(1)), x), x) - Dist(b*(I*c + d + S(1)), Int(x*exp(S(2)*I*a + S(2)*I*b*x)/(I*c - d + (I*c + d + S(1))*exp(S(2)*I*a + S(2)*I*b*x) + S(1)), x), x) + Simp(x*ArcTan(c + d*tan(a + b*x)), x) rule5542 = ReplacementRule(pattern5542, replacement5542) pattern5543 = Pattern(Integral(acot(WC('c', S(0)) + WC('d', S(1))*tan(x_*WC('b', S(1)) + WC('a', S(0)))), x_), cons2, cons3, cons7, cons27, cons1843) def replacement5543(b, d, c, a, x): rubi.append(5543) return -Dist(b*(-I*c - d + S(1)), Int(x*exp(S(2)*I*a + S(2)*I*b*x)/(-I*c + d + (-I*c - d + S(1))*exp(S(2)*I*a + S(2)*I*b*x) + S(1)), x), x) + Dist(b*(I*c + d + S(1)), Int(x*exp(S(2)*I*a + S(2)*I*b*x)/(I*c - d + (I*c + d + S(1))*exp(S(2)*I*a + S(2)*I*b*x) + S(1)), x), x) + Simp(x*acot(c + d*tan(a + b*x)), x) rule5543 = ReplacementRule(pattern5543, replacement5543) pattern5544 = Pattern(Integral(ArcTan(WC('c', S(0)) + WC('d', S(1))/tan(x_*WC('b', S(1)) + WC('a', S(0)))), x_), cons2, cons3, cons7, cons27, cons1843) def replacement5544(b, d, c, a, x): rubi.append(5544) return -Dist(b*(-I*c + d + S(1)), Int(x*exp(S(2)*I*a + S(2)*I*b*x)/(-I*c - d - (-I*c + d + S(1))*exp(S(2)*I*a + S(2)*I*b*x) + S(1)), x), x) + Dist(b*(I*c - d + S(1)), Int(x*exp(S(2)*I*a + S(2)*I*b*x)/(I*c + d - (I*c - d + S(1))*exp(S(2)*I*a + S(2)*I*b*x) + S(1)), x), x) + Simp(x*ArcTan(c + d/tan(a + b*x)), x) rule5544 = ReplacementRule(pattern5544, replacement5544) pattern5545 = Pattern(Integral(acot(WC('c', S(0)) + WC('d', S(1))/tan(x_*WC('b', S(1)) + WC('a', S(0)))), x_), cons2, cons3, cons7, cons27, cons1844) def replacement5545(b, d, c, a, x): rubi.append(5545) return Dist(b*(-I*c + d + S(1)), Int(x*exp(S(2)*I*a + S(2)*I*b*x)/(-I*c - d - (-I*c + d + S(1))*exp(S(2)*I*a + S(2)*I*b*x) + S(1)), x), x) - Dist(b*(I*c - d + S(1)), Int(x*exp(S(2)*I*a + S(2)*I*b*x)/(I*c + d - (I*c - d + S(1))*exp(S(2)*I*a + S(2)*I*b*x) + S(1)), x), x) + Simp(x*acot(c + d/tan(a + b*x)), x) rule5545 = ReplacementRule(pattern5545, replacement5545) pattern5546 = Pattern(Integral((x_*WC('f', S(1)) + WC('e', S(0)))**WC('m', S(1))*ArcTan(WC('c', S(0)) + WC('d', S(1))*tan(x_*WC('b', S(1)) + WC('a', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons62, cons1841) def replacement5546(m, f, b, d, c, a, x, e): rubi.append(5546) return -Dist(I*b/(f*(m + S(1))), Int((e + f*x)**(m + S(1))/(c*exp(S(2)*I*a + S(2)*I*b*x) + c + I*d), x), x) + Simp((e + f*x)**(m + S(1))*ArcTan(c + d*tan(a + b*x))/(f*(m + S(1))), x) rule5546 = ReplacementRule(pattern5546, replacement5546) pattern5547 = Pattern(Integral((x_*WC('f', S(1)) + WC('e', S(0)))**WC('m', S(1))*acot(WC('c', S(0)) + WC('d', S(1))*tan(x_*WC('b', S(1)) + WC('a', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons62, cons1841) def replacement5547(m, f, b, d, c, a, x, e): rubi.append(5547) return Dist(I*b/(f*(m + S(1))), Int((e + f*x)**(m + S(1))/(c*exp(S(2)*I*a + S(2)*I*b*x) + c + I*d), x), x) + Simp((e + f*x)**(m + S(1))*acot(c + d*tan(a + b*x))/(f*(m + S(1))), x) rule5547 = ReplacementRule(pattern5547, replacement5547) pattern5548 = Pattern(Integral((x_*WC('f', S(1)) + WC('e', S(0)))**WC('m', S(1))*ArcTan(WC('c', S(0)) + WC('d', S(1))/tan(x_*WC('b', S(1)) + WC('a', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons62, cons1842) def replacement5548(m, f, b, d, c, a, x, e): rubi.append(5548) return -Dist(I*b/(f*(m + S(1))), Int((e + f*x)**(m + S(1))/(-c*exp(S(2)*I*a + S(2)*I*b*x) + c - I*d), x), x) + Simp((e + f*x)**(m + S(1))*ArcTan(c + d/tan(a + b*x))/(f*(m + S(1))), x) rule5548 = ReplacementRule(pattern5548, replacement5548) pattern5549 = Pattern(Integral((x_*WC('f', S(1)) + WC('e', S(0)))**WC('m', S(1))*acot(WC('c', S(0)) + WC('d', S(1))/tan(x_*WC('b', S(1)) + WC('a', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons62, cons1842) def replacement5549(m, f, b, d, c, a, x, e): rubi.append(5549) return Dist(I*b/(f*(m + S(1))), Int((e + f*x)**(m + S(1))/(-c*exp(S(2)*I*a + S(2)*I*b*x) + c - I*d), x), x) + Simp((e + f*x)**(m + S(1))*acot(c + d/tan(a + b*x))/(f*(m + S(1))), x) rule5549 = ReplacementRule(pattern5549, replacement5549) pattern5550 = Pattern(Integral((x_*WC('f', S(1)) + WC('e', S(0)))**WC('m', S(1))*ArcTan(WC('c', S(0)) + WC('d', S(1))*tan(x_*WC('b', S(1)) + WC('a', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons62, cons1843) def replacement5550(m, f, b, d, c, a, x, e): rubi.append(5550) return Dist(b*(-I*c - d + S(1))/(f*(m + S(1))), Int((e + f*x)**(m + S(1))*exp(S(2)*I*a + S(2)*I*b*x)/(-I*c + d + (-I*c - d + S(1))*exp(S(2)*I*a + S(2)*I*b*x) + S(1)), x), x) - Dist(b*(I*c + d + S(1))/(f*(m + S(1))), Int((e + f*x)**(m + S(1))*exp(S(2)*I*a + S(2)*I*b*x)/(I*c - d + (I*c + d + S(1))*exp(S(2)*I*a + S(2)*I*b*x) + S(1)), x), x) + Simp((e + f*x)**(m + S(1))*ArcTan(c + d*tan(a + b*x))/(f*(m + S(1))), x) rule5550 = ReplacementRule(pattern5550, replacement5550) pattern5551 = Pattern(Integral((x_*WC('f', S(1)) + WC('e', S(0)))**WC('m', S(1))*acot(WC('c', S(0)) + WC('d', S(1))*tan(x_*WC('b', S(1)) + WC('a', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons62, cons1843) def replacement5551(m, f, b, d, c, a, x, e): rubi.append(5551) return -Dist(b*(-I*c - d + S(1))/(f*(m + S(1))), Int((e + f*x)**(m + S(1))*exp(S(2)*I*a + S(2)*I*b*x)/(-I*c + d + (-I*c - d + S(1))*exp(S(2)*I*a + S(2)*I*b*x) + S(1)), x), x) + Dist(b*(I*c + d + S(1))/(f*(m + S(1))), Int((e + f*x)**(m + S(1))*exp(S(2)*I*a + S(2)*I*b*x)/(I*c - d + (I*c + d + S(1))*exp(S(2)*I*a + S(2)*I*b*x) + S(1)), x), x) + Simp((e + f*x)**(m + S(1))*acot(c + d*tan(a + b*x))/(f*(m + S(1))), x) rule5551 = ReplacementRule(pattern5551, replacement5551) pattern5552 = Pattern(Integral((x_*WC('f', S(1)) + WC('e', S(0)))**WC('m', S(1))*ArcTan(WC('c', S(0)) + WC('d', S(1))/tan(x_*WC('b', S(1)) + WC('a', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons62, cons1844) def replacement5552(m, f, b, d, c, a, x, e): rubi.append(5552) return -Dist(b*(-I*c + d + S(1))/(f*(m + S(1))), Int((e + f*x)**(m + S(1))*exp(S(2)*I*a + S(2)*I*b*x)/(-I*c - d - (-I*c + d + S(1))*exp(S(2)*I*a + S(2)*I*b*x) + S(1)), x), x) + Dist(b*(I*c - d + S(1))/(f*(m + S(1))), Int((e + f*x)**(m + S(1))*exp(S(2)*I*a + S(2)*I*b*x)/(I*c + d - (I*c - d + S(1))*exp(S(2)*I*a + S(2)*I*b*x) + S(1)), x), x) + Simp((e + f*x)**(m + S(1))*ArcTan(c + d/tan(a + b*x))/(f*(m + S(1))), x) rule5552 = ReplacementRule(pattern5552, replacement5552) pattern5553 = Pattern(Integral((x_*WC('f', S(1)) + WC('e', S(0)))**WC('m', S(1))*acot(WC('c', S(0)) + WC('d', S(1))/tan(x_*WC('b', S(1)) + WC('a', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons62, cons1844) def replacement5553(m, f, b, d, c, a, x, e): rubi.append(5553) return Dist(b*(-I*c + d + S(1))/(f*(m + S(1))), Int((e + f*x)**(m + S(1))*exp(S(2)*I*a + S(2)*I*b*x)/(-I*c - d - (-I*c + d + S(1))*exp(S(2)*I*a + S(2)*I*b*x) + S(1)), x), x) - Dist(b*(I*c - d + S(1))/(f*(m + S(1))), Int((e + f*x)**(m + S(1))*exp(S(2)*I*a + S(2)*I*b*x)/(I*c + d - (I*c - d + S(1))*exp(S(2)*I*a + S(2)*I*b*x) + S(1)), x), x) + Simp((e + f*x)**(m + S(1))*acot(c + d/tan(a + b*x))/(f*(m + S(1))), x) rule5553 = ReplacementRule(pattern5553, replacement5553) pattern5554 = Pattern(Integral(ArcTan(tanh(x_*WC('b', S(1)) + WC('a', S(0)))), x_), cons2, cons3, cons67) def replacement5554(x, a, b): rubi.append(5554) return -Dist(b, Int(x/cosh(S(2)*a + S(2)*b*x), x), x) + Simp(x*ArcTan(tanh(a + b*x)), x) rule5554 = ReplacementRule(pattern5554, replacement5554) pattern5555 = Pattern(Integral(acot(tanh(x_*WC('b', S(1)) + WC('a', S(0)))), x_), cons2, cons3, cons67) def replacement5555(x, a, b): rubi.append(5555) return Dist(b, Int(x/cosh(S(2)*a + S(2)*b*x), x), x) + Simp(x*acot(tanh(a + b*x)), x) rule5555 = ReplacementRule(pattern5555, replacement5555) pattern5556 = Pattern(Integral(ArcTan(S(1)/tanh(x_*WC('b', S(1)) + WC('a', S(0)))), x_), cons2, cons3, cons67) def replacement5556(x, a, b): rubi.append(5556) return Dist(b, Int(x/cosh(S(2)*a + S(2)*b*x), x), x) + Simp(x*ArcTan(S(1)/tanh(a + b*x)), x) rule5556 = ReplacementRule(pattern5556, replacement5556) pattern5557 = Pattern(Integral(acot(S(1)/tanh(x_*WC('b', S(1)) + WC('a', S(0)))), x_), cons2, cons3, cons67) def replacement5557(x, a, b): rubi.append(5557) return -Dist(b, Int(x/cosh(S(2)*a + S(2)*b*x), x), x) + Simp(x*acot(S(1)/tanh(a + b*x)), x) rule5557 = ReplacementRule(pattern5557, replacement5557) pattern5558 = Pattern(Integral((x_*WC('f', S(1)) + WC('e', S(0)))**WC('m', S(1))*ArcTan(tanh(x_*WC('b', S(1)) + WC('a', S(0)))), x_), cons2, cons3, cons48, cons125, cons62) def replacement5558(m, f, b, a, x, e): rubi.append(5558) return -Dist(b/(f*(m + S(1))), Int((e + f*x)**(m + S(1))/cosh(S(2)*a + S(2)*b*x), x), x) + Simp((e + f*x)**(m + S(1))*ArcTan(tanh(a + b*x))/(f*(m + S(1))), x) rule5558 = ReplacementRule(pattern5558, replacement5558) pattern5559 = Pattern(Integral((x_*WC('f', S(1)) + WC('e', S(0)))**WC('m', S(1))*acot(tanh(x_*WC('b', S(1)) + WC('a', S(0)))), x_), cons2, cons3, cons48, cons125, cons62) def replacement5559(m, f, b, a, x, e): rubi.append(5559) return Dist(b/(f*(m + S(1))), Int((e + f*x)**(m + S(1))/cosh(S(2)*a + S(2)*b*x), x), x) + Simp((e + f*x)**(m + S(1))*acot(tanh(a + b*x))/(f*(m + S(1))), x) rule5559 = ReplacementRule(pattern5559, replacement5559) pattern5560 = Pattern(Integral((x_*WC('f', S(1)) + WC('e', S(0)))**WC('m', S(1))*ArcTan(S(1)/tanh(x_*WC('b', S(1)) + WC('a', S(0)))), x_), cons2, cons3, cons48, cons125, cons62) def replacement5560(m, f, b, a, x, e): rubi.append(5560) return Dist(b/(f*(m + S(1))), Int((e + f*x)**(m + S(1))/cosh(S(2)*a + S(2)*b*x), x), x) + Simp((e + f*x)**(m + S(1))*ArcTan(S(1)/tanh(a + b*x))/(f*(m + S(1))), x) rule5560 = ReplacementRule(pattern5560, replacement5560) pattern5561 = Pattern(Integral((x_*WC('f', S(1)) + WC('e', S(0)))**WC('m', S(1))*acot(S(1)/tanh(x_*WC('b', S(1)) + WC('a', S(0)))), x_), cons2, cons3, cons48, cons125, cons62) def replacement5561(m, f, b, a, x, e): rubi.append(5561) return -Dist(b/(f*(m + S(1))), Int((e + f*x)**(m + S(1))/cosh(S(2)*a + S(2)*b*x), x), x) + Simp((e + f*x)**(m + S(1))*acot(S(1)/tanh(a + b*x))/(f*(m + S(1))), x) rule5561 = ReplacementRule(pattern5561, replacement5561) pattern5562 = Pattern(Integral(ArcTan(WC('c', S(0)) + WC('d', S(1))*tanh(x_*WC('b', S(1)) + WC('a', S(0)))), x_), cons2, cons3, cons7, cons27, cons1845) def replacement5562(b, d, c, a, x): rubi.append(5562) return -Dist(b, Int(x/(c*exp(S(2)*a + S(2)*b*x) + c - d), x), x) + Simp(x*ArcTan(c + d*tanh(a + b*x)), x) rule5562 = ReplacementRule(pattern5562, replacement5562) pattern5563 = Pattern(Integral(acot(WC('c', S(0)) + WC('d', S(1))*tanh(x_*WC('b', S(1)) + WC('a', S(0)))), x_), cons2, cons3, cons7, cons27, cons1845) def replacement5563(b, d, c, a, x): rubi.append(5563) return Dist(b, Int(x/(c*exp(S(2)*a + S(2)*b*x) + c - d), x), x) + Simp(x*acot(c + d*tanh(a + b*x)), x) rule5563 = ReplacementRule(pattern5563, replacement5563) pattern5564 = Pattern(Integral(ArcTan(WC('c', S(0)) + WC('d', S(1))/tanh(x_*WC('b', S(1)) + WC('a', S(0)))), x_), cons2, cons3, cons7, cons27, cons1845) def replacement5564(b, d, c, a, x): rubi.append(5564) return -Dist(b, Int(x/(-c*exp(S(2)*a + S(2)*b*x) + c - d), x), x) + Simp(x*ArcTan(c + d/tanh(a + b*x)), x) rule5564 = ReplacementRule(pattern5564, replacement5564) pattern5565 = Pattern(Integral(acot(WC('c', S(0)) + WC('d', S(1))/tanh(x_*WC('b', S(1)) + WC('a', S(0)))), x_), cons2, cons3, cons7, cons27, cons1845) def replacement5565(b, d, c, a, x): rubi.append(5565) return Dist(b, Int(x/(-c*exp(S(2)*a + S(2)*b*x) + c - d), x), x) + Simp(x*acot(c + d/tanh(a + b*x)), x) rule5565 = ReplacementRule(pattern5565, replacement5565) pattern5566 = Pattern(Integral(ArcTan(WC('c', S(0)) + WC('d', S(1))*tanh(x_*WC('b', S(1)) + WC('a', S(0)))), x_), cons2, cons3, cons7, cons27, cons1846) def replacement5566(b, d, c, a, x): rubi.append(5566) return Dist(I*b*(-c - d + I), Int(x*exp(S(2)*a + S(2)*b*x)/(-c + d + (-c - d + I)*exp(S(2)*a + S(2)*b*x) + I), x), x) - Dist(I*b*(c + d + I), Int(x*exp(S(2)*a + S(2)*b*x)/(c - d + (c + d + I)*exp(S(2)*a + S(2)*b*x) + I), x), x) + Simp(x*ArcTan(c + d*tanh(a + b*x)), x) rule5566 = ReplacementRule(pattern5566, replacement5566) pattern5567 = Pattern(Integral(acot(WC('c', S(0)) + WC('d', S(1))*tanh(x_*WC('b', S(1)) + WC('a', S(0)))), x_), cons2, cons3, cons7, cons27, cons1846) def replacement5567(b, d, c, a, x): rubi.append(5567) return -Dist(I*b*(-c - d + I), Int(x*exp(S(2)*a + S(2)*b*x)/(-c + d + (-c - d + I)*exp(S(2)*a + S(2)*b*x) + I), x), x) + Dist(I*b*(c + d + I), Int(x*exp(S(2)*a + S(2)*b*x)/(c - d + (c + d + I)*exp(S(2)*a + S(2)*b*x) + I), x), x) + Simp(x*acot(c + d*tanh(a + b*x)), x) rule5567 = ReplacementRule(pattern5567, replacement5567) pattern5568 = Pattern(Integral(ArcTan(WC('c', S(0)) + WC('d', S(1))/tanh(x_*WC('b', S(1)) + WC('a', S(0)))), x_), cons2, cons3, cons7, cons27, cons1846) def replacement5568(b, d, c, a, x): rubi.append(5568) return -Dist(I*b*(-c - d + I), Int(x*exp(S(2)*a + S(2)*b*x)/(-c + d - (-c - d + I)*exp(S(2)*a + S(2)*b*x) + I), x), x) + Dist(I*b*(c + d + I), Int(x*exp(S(2)*a + S(2)*b*x)/(c - d - (c + d + I)*exp(S(2)*a + S(2)*b*x) + I), x), x) + Simp(x*ArcTan(c + d/tanh(a + b*x)), x) rule5568 = ReplacementRule(pattern5568, replacement5568) pattern5569 = Pattern(Integral(acot(WC('c', S(0)) + WC('d', S(1))/tanh(x_*WC('b', S(1)) + WC('a', S(0)))), x_), cons2, cons3, cons7, cons27, cons1846) def replacement5569(b, d, c, a, x): rubi.append(5569) return Dist(I*b*(-c - d + I), Int(x*exp(S(2)*a + S(2)*b*x)/(-c + d - (-c - d + I)*exp(S(2)*a + S(2)*b*x) + I), x), x) - Dist(I*b*(c + d + I), Int(x*exp(S(2)*a + S(2)*b*x)/(c - d - (c + d + I)*exp(S(2)*a + S(2)*b*x) + I), x), x) + Simp(x*acot(c + d/tanh(a + b*x)), x) rule5569 = ReplacementRule(pattern5569, replacement5569) pattern5570 = Pattern(Integral((x_*WC('f', S(1)) + WC('e', S(0)))**WC('m', S(1))*ArcTan(WC('c', S(0)) + WC('d', S(1))*tanh(x_*WC('b', S(1)) + WC('a', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons62, cons1845) def replacement5570(m, f, b, d, c, a, x, e): rubi.append(5570) return -Dist(b/(f*(m + S(1))), Int((e + f*x)**(m + S(1))/(c*exp(S(2)*a + S(2)*b*x) + c - d), x), x) + Simp((e + f*x)**(m + S(1))*ArcTan(c + d*tanh(a + b*x))/(f*(m + S(1))), x) rule5570 = ReplacementRule(pattern5570, replacement5570) pattern5571 = Pattern(Integral((x_*WC('f', S(1)) + WC('e', S(0)))**WC('m', S(1))*acot(WC('c', S(0)) + WC('d', S(1))*tanh(x_*WC('b', S(1)) + WC('a', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons62, cons1845) def replacement5571(m, f, b, d, c, a, x, e): rubi.append(5571) return Dist(b/(f*(m + S(1))), Int((e + f*x)**(m + S(1))/(c*exp(S(2)*a + S(2)*b*x) + c - d), x), x) + Simp((e + f*x)**(m + S(1))*acot(c + d*tanh(a + b*x))/(f*(m + S(1))), x) rule5571 = ReplacementRule(pattern5571, replacement5571) pattern5572 = Pattern(Integral((x_*WC('f', S(1)) + WC('e', S(0)))**WC('m', S(1))*ArcTan(WC('c', S(0)) + WC('d', S(1))/tanh(x_*WC('b', S(1)) + WC('a', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons62, cons1845) def replacement5572(m, f, b, d, c, a, x, e): rubi.append(5572) return -Dist(b/(f*(m + S(1))), Int((e + f*x)**(m + S(1))/(-c*exp(S(2)*a + S(2)*b*x) + c - d), x), x) + Simp((e + f*x)**(m + S(1))*ArcTan(c + d/tanh(a + b*x))/(f*(m + S(1))), x) rule5572 = ReplacementRule(pattern5572, replacement5572) pattern5573 = Pattern(Integral((x_*WC('f', S(1)) + WC('e', S(0)))**WC('m', S(1))*acot(WC('c', S(0)) + WC('d', S(1))/tanh(x_*WC('b', S(1)) + WC('a', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons62, cons1845) def replacement5573(m, f, b, d, c, a, x, e): rubi.append(5573) return Dist(b/(f*(m + S(1))), Int((e + f*x)**(m + S(1))/(-c*exp(S(2)*a + S(2)*b*x) + c - d), x), x) + Simp((e + f*x)**(m + S(1))*acot(c + d/tanh(a + b*x))/(f*(m + S(1))), x) rule5573 = ReplacementRule(pattern5573, replacement5573) pattern5574 = Pattern(Integral((x_*WC('f', S(1)) + WC('e', S(0)))**WC('m', S(1))*ArcTan(WC('c', S(0)) + WC('d', S(1))*tanh(x_*WC('b', S(1)) + WC('a', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons62, cons1846) def replacement5574(m, f, b, d, c, a, x, e): rubi.append(5574) return Dist(I*b*(-c - d + I)/(f*(m + S(1))), Int((e + f*x)**(m + S(1))*exp(S(2)*a + S(2)*b*x)/(-c + d + (-c - d + I)*exp(S(2)*a + S(2)*b*x) + I), x), x) - Dist(I*b*(c + d + I)/(f*(m + S(1))), Int((e + f*x)**(m + S(1))*exp(S(2)*a + S(2)*b*x)/(c - d + (c + d + I)*exp(S(2)*a + S(2)*b*x) + I), x), x) + Simp((e + f*x)**(m + S(1))*ArcTan(c + d*tanh(a + b*x))/(f*(m + S(1))), x) rule5574 = ReplacementRule(pattern5574, replacement5574) pattern5575 = Pattern(Integral((x_*WC('f', S(1)) + WC('e', S(0)))**WC('m', S(1))*acot(WC('c', S(0)) + WC('d', S(1))*tanh(x_*WC('b', S(1)) + WC('a', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons62, cons1846) def replacement5575(m, f, b, d, c, a, x, e): rubi.append(5575) return -Dist(I*b*(-c - d + I)/(f*(m + S(1))), Int((e + f*x)**(m + S(1))*exp(S(2)*a + S(2)*b*x)/(-c + d + (-c - d + I)*exp(S(2)*a + S(2)*b*x) + I), x), x) + Dist(I*b*(c + d + I)/(f*(m + S(1))), Int((e + f*x)**(m + S(1))*exp(S(2)*a + S(2)*b*x)/(c - d + (c + d + I)*exp(S(2)*a + S(2)*b*x) + I), x), x) + Simp((e + f*x)**(m + S(1))*acot(c + d*tanh(a + b*x))/(f*(m + S(1))), x) rule5575 = ReplacementRule(pattern5575, replacement5575) pattern5576 = Pattern(Integral((x_*WC('f', S(1)) + WC('e', S(0)))**WC('m', S(1))*ArcTan(WC('c', S(0)) + WC('d', S(1))/tanh(x_*WC('b', S(1)) + WC('a', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons62, cons1846) def replacement5576(m, f, b, d, c, a, x, e): rubi.append(5576) return -Dist(I*b*(-c - d + I)/(f*(m + S(1))), Int((e + f*x)**(m + S(1))*exp(S(2)*a + S(2)*b*x)/(-c + d - (-c - d + I)*exp(S(2)*a + S(2)*b*x) + I), x), x) + Dist(I*b*(c + d + I)/(f*(m + S(1))), Int((e + f*x)**(m + S(1))*exp(S(2)*a + S(2)*b*x)/(c - d - (c + d + I)*exp(S(2)*a + S(2)*b*x) + I), x), x) + Simp((e + f*x)**(m + S(1))*ArcTan(c + d/tanh(a + b*x))/(f*(m + S(1))), x) rule5576 = ReplacementRule(pattern5576, replacement5576) pattern5577 = Pattern(Integral((x_*WC('f', S(1)) + WC('e', S(0)))**WC('m', S(1))*acot(WC('c', S(0)) + WC('d', S(1))/tanh(x_*WC('b', S(1)) + WC('a', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons62, cons1846) def replacement5577(m, f, b, d, c, a, x, e): rubi.append(5577) return Dist(I*b*(-c - d + I)/(f*(m + S(1))), Int((e + f*x)**(m + S(1))*exp(S(2)*a + S(2)*b*x)/(-c + d - (-c - d + I)*exp(S(2)*a + S(2)*b*x) + I), x), x) - Dist(I*b*(c + d + I)/(f*(m + S(1))), Int((e + f*x)**(m + S(1))*exp(S(2)*a + S(2)*b*x)/(c - d - (c + d + I)*exp(S(2)*a + S(2)*b*x) + I), x), x) + Simp((e + f*x)**(m + S(1))*acot(c + d/tanh(a + b*x))/(f*(m + S(1))), x) rule5577 = ReplacementRule(pattern5577, replacement5577) pattern5578 = Pattern(Integral(ArcTan(u_), x_), cons1230) def replacement5578(x, u): rubi.append(5578) return -Int(SimplifyIntegrand(x*D(u, x)/(u**S(2) + S(1)), x), x) + Simp(x*ArcTan(u), x) rule5578 = ReplacementRule(pattern5578, replacement5578) pattern5579 = Pattern(Integral(acot(u_), x_), cons1230) def replacement5579(x, u): rubi.append(5579) return Int(SimplifyIntegrand(x*D(u, x)/(u**S(2) + S(1)), x), x) + Simp(x*acot(u), x) rule5579 = ReplacementRule(pattern5579, replacement5579) pattern5580 = Pattern(Integral((x_*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1))*(ArcTan(u_)*WC('b', S(1)) + WC('a', S(0))), x_), cons2, cons3, cons7, cons27, cons21, cons66, cons1230, cons1770, cons1847) def replacement5580(u, m, b, d, c, a, x): rubi.append(5580) return -Dist(b/(d*(m + S(1))), Int(SimplifyIntegrand((c + d*x)**(m + S(1))*D(u, x)/(u**S(2) + S(1)), x), x), x) + Simp((a + b*ArcTan(u))*(c + d*x)**(m + S(1))/(d*(m + S(1))), x) rule5580 = ReplacementRule(pattern5580, replacement5580) pattern5581 = Pattern(Integral((x_*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*acot(u_)), x_), cons2, cons3, cons7, cons27, cons21, cons66, cons1230, cons1770, cons1847) def replacement5581(u, m, b, d, c, a, x): rubi.append(5581) return Dist(b/(d*(m + S(1))), Int(SimplifyIntegrand((c + d*x)**(m + S(1))*D(u, x)/(u**S(2) + S(1)), x), x), x) + Simp((a + b*acot(u))*(c + d*x)**(m + S(1))/(d*(m + S(1))), x) rule5581 = ReplacementRule(pattern5581, replacement5581) def With5582(v, u, b, a, x): if isinstance(x, (int, Integer, float, Float)): return False w = IntHide(v, x) if InverseFunctionFreeQ(w, x): return True return False pattern5582 = Pattern(Integral(v_*(ArcTan(u_)*WC('b', S(1)) + WC('a', S(0))), x_), cons2, cons3, cons1230, cons1848, cons1849, CustomConstraint(With5582)) def replacement5582(v, u, b, a, x): w = IntHide(v, x) rubi.append(5582) return -Dist(b, Int(SimplifyIntegrand(w*D(u, x)/(u**S(2) + S(1)), x), x), x) + Dist(a + b*ArcTan(u), w, x) rule5582 = ReplacementRule(pattern5582, replacement5582) def With5583(v, u, b, a, x): if isinstance(x, (int, Integer, float, Float)): return False w = IntHide(v, x) if InverseFunctionFreeQ(w, x): return True return False pattern5583 = Pattern(Integral(v_*(WC('a', S(0)) + WC('b', S(1))*acot(u_)), x_), cons2, cons3, cons1230, cons1850, cons1851, CustomConstraint(With5583)) def replacement5583(v, u, b, a, x): w = IntHide(v, x) rubi.append(5583) return Dist(b, Int(SimplifyIntegrand(w*D(u, x)/(u**S(2) + S(1)), x), x), x) + Dist(a + b*acot(u), w, x) rule5583 = ReplacementRule(pattern5583, replacement5583) pattern5584 = Pattern(Integral(ArcTan(v_)*log(w_)/(x_*WC('b', S(1)) + WC('a', S(0))), x_), cons2, cons3, cons552, cons1146, cons1852, cons1853) def replacement5584(v, w, b, a, x): rubi.append(5584) return Dist(I/S(2), Int(log(w)*log(-I*v + S(1))/(a + b*x), x), x) - Dist(I/S(2), Int(log(w)*log(I*v + S(1))/(a + b*x), x), x) rule5584 = ReplacementRule(pattern5584, replacement5584) pattern5585 = Pattern(Integral(ArcTan(v_)*log(w_), x_), cons1242, cons1243) def replacement5585(v, w, x): rubi.append(5585) return -Int(SimplifyIntegrand(x*ArcTan(v)*D(w, x)/w, x), x) - Int(SimplifyIntegrand(x*D(v, x)*log(w)/(v**S(2) + S(1)), x), x) + Simp(x*ArcTan(v)*log(w), x) rule5585 = ReplacementRule(pattern5585, replacement5585) pattern5586 = Pattern(Integral(log(w_)*acot(v_), x_), cons1242, cons1243) def replacement5586(v, w, x): rubi.append(5586) return -Int(SimplifyIntegrand(x*D(w, x)*acot(v)/w, x), x) + Int(SimplifyIntegrand(x*D(v, x)*log(w)/(v**S(2) + S(1)), x), x) + Simp(x*log(w)*acot(v), x) rule5586 = ReplacementRule(pattern5586, replacement5586) def With5587(v, w, u, x): if isinstance(x, (int, Integer, float, Float)): return False z = IntHide(u, x) if InverseFunctionFreeQ(z, x): return True return False pattern5587 = Pattern(Integral(u_*ArcTan(v_)*log(w_), x_), cons1242, cons1243, CustomConstraint(With5587)) def replacement5587(v, w, u, x): z = IntHide(u, x) rubi.append(5587) return Dist(ArcTan(v)*log(w), z, x) - Int(SimplifyIntegrand(z*ArcTan(v)*D(w, x)/w, x), x) - Int(SimplifyIntegrand(z*D(v, x)*log(w)/(v**S(2) + S(1)), x), x) rule5587 = ReplacementRule(pattern5587, replacement5587) def With5588(v, w, u, x): if isinstance(x, (int, Integer, float, Float)): return False z = IntHide(u, x) if InverseFunctionFreeQ(z, x): return True return False pattern5588 = Pattern(Integral(u_*log(w_)*acot(v_), x_), cons1242, cons1243, CustomConstraint(With5588)) def replacement5588(v, w, u, x): z = IntHide(u, x) rubi.append(5588) return Dist(log(w)*acot(v), z, x) - Int(SimplifyIntegrand(z*D(w, x)*acot(v)/w, x), x) + Int(SimplifyIntegrand(z*D(v, x)*log(w)/(v**S(2) + S(1)), x), x) rule5588 = ReplacementRule(pattern5588, replacement5588) pattern5589 = Pattern(Integral(asec(x_*WC('c', S(1))), x_), cons7, cons7) def replacement5589(x, c): rubi.append(5589) return -Dist(S(1)/c, Int(S(1)/(x*sqrt(S(1) - S(1)/(c**S(2)*x**S(2)))), x), x) + Simp(x*asec(c*x), x) rule5589 = ReplacementRule(pattern5589, replacement5589) pattern5590 = Pattern(Integral(acsc(x_*WC('c', S(1))), x_), cons7, cons7) def replacement5590(x, c): rubi.append(5590) return Dist(S(1)/c, Int(S(1)/(x*sqrt(S(1) - S(1)/(c**S(2)*x**S(2)))), x), x) + Simp(x*acsc(c*x), x) rule5590 = ReplacementRule(pattern5590, replacement5590) pattern5591 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*asec(x_*WC('c', S(1))))**n_, x_), cons2, cons3, cons7, cons4, cons1579) def replacement5591(b, a, n, c, x): rubi.append(5591) return Dist(S(1)/c, Subst(Int((a + b*x)**n*tan(x)/cos(x), x), x, asec(c*x)), x) rule5591 = ReplacementRule(pattern5591, replacement5591) pattern5592 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*acsc(x_*WC('c', S(1))))**n_, x_), cons2, cons3, cons7, cons4, cons1579) def replacement5592(b, a, n, c, x): rubi.append(5592) return -Dist(S(1)/c, Subst(Int((a + b*x)**n/(sin(x)*tan(x)), x), x, acsc(c*x)), x) rule5592 = ReplacementRule(pattern5592, replacement5592) pattern5593 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*asec(x_*WC('c', S(1))))/x_, x_), cons2, cons3, cons7, cons14) def replacement5593(x, a, c, b): rubi.append(5593) return -Subst(Int((a + b*acos(x/c))/x, x), x, S(1)/x) rule5593 = ReplacementRule(pattern5593, replacement5593) pattern5594 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*acsc(x_*WC('c', S(1))))/x_, x_), cons2, cons3, cons7, cons14) def replacement5594(x, a, c, b): rubi.append(5594) return -Subst(Int((a + b*asin(x/c))/x, x), x, S(1)/x) rule5594 = ReplacementRule(pattern5594, replacement5594) pattern5595 = Pattern(Integral(x_**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*asec(x_*WC('c', S(1)))), x_), cons2, cons3, cons7, cons21, cons66) def replacement5595(m, b, a, c, x): rubi.append(5595) return -Dist(b/(c*(m + S(1))), Int(x**(m + S(-1))/sqrt(S(1) - S(1)/(c**S(2)*x**S(2))), x), x) + Simp(x**(m + S(1))*(a + b*asec(c*x))/(m + S(1)), x) rule5595 = ReplacementRule(pattern5595, replacement5595) pattern5596 = Pattern(Integral(x_**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*acsc(x_*WC('c', S(1)))), x_), cons2, cons3, cons7, cons21, cons66) def replacement5596(m, b, a, c, x): rubi.append(5596) return Dist(b/(c*(m + S(1))), Int(x**(m + S(-1))/sqrt(S(1) - S(1)/(c**S(2)*x**S(2))), x), x) + Simp(x**(m + S(1))*(a + b*acsc(c*x))/(m + S(1)), x) rule5596 = ReplacementRule(pattern5596, replacement5596) pattern5597 = Pattern(Integral(x_**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*asec(x_*WC('c', S(1))))**n_, x_), cons2, cons3, cons7, cons4, cons17) def replacement5597(m, b, a, c, n, x): rubi.append(5597) return Dist(c**(-m + S(-1)), Subst(Int((a + b*x)**n*(S(1)/cos(x))**(m + S(1))*tan(x), x), x, asec(c*x)), x) rule5597 = ReplacementRule(pattern5597, replacement5597) pattern5598 = Pattern(Integral(x_**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*acsc(x_*WC('c', S(1))))**n_, x_), cons2, cons3, cons7, cons4, cons17) def replacement5598(m, b, a, c, n, x): rubi.append(5598) return -Dist(c**(-m + S(-1)), Subst(Int((a + b*x)**n*(S(1)/sin(x))**(m + S(1))/tan(x), x), x, acsc(c*x)), x) rule5598 = ReplacementRule(pattern5598, replacement5598) pattern5599 = Pattern(Integral(x_**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*asec(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons21, cons4, cons1854) def replacement5599(m, b, a, n, c, x): rubi.append(5599) return Int(x**m*(a + b*asec(c*x))**n, x) rule5599 = ReplacementRule(pattern5599, replacement5599) pattern5600 = Pattern(Integral(x_**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*acsc(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons21, cons4, cons1854) def replacement5600(m, b, a, n, c, x): rubi.append(5600) return Int(x**m*(a + b*acsc(c*x))**n, x) rule5600 = ReplacementRule(pattern5600, replacement5600) def With5601(p, b, d, a, c, x, e): u = IntHide((d + e*x**S(2))**p, x) rubi.append(5601) return -Dist(b*c*x/sqrt(c**S(2)*x**S(2)), Int(SimplifyIntegrand(u/(x*sqrt(c**S(2)*x**S(2) + S(-1))), x), x), x) + Dist(a + b*asec(c*x), u, x) pattern5601 = Pattern(Integral((x_**S(2)*WC('e', S(1)) + WC('d', S(0)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*asec(x_*WC('c', S(1)))), x_), cons2, cons3, cons7, cons27, cons48, cons1743) rule5601 = ReplacementRule(pattern5601, With5601) def With5602(p, b, d, a, c, x, e): u = IntHide((d + e*x**S(2))**p, x) rubi.append(5602) return Dist(b*c*x/sqrt(c**S(2)*x**S(2)), Int(SimplifyIntegrand(u/(x*sqrt(c**S(2)*x**S(2) + S(-1))), x), x), x) + Dist(a + b*acsc(c*x), u, x) pattern5602 = Pattern(Integral((x_**S(2)*WC('e', S(1)) + WC('d', S(0)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*acsc(x_*WC('c', S(1)))), x_), cons2, cons3, cons7, cons27, cons48, cons1743) rule5602 = ReplacementRule(pattern5602, With5602) pattern5603 = Pattern(Integral((x_**S(2)*WC('e', S(1)) + WC('d', S(0)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*asec(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons4, cons38) def replacement5603(p, b, d, a, n, c, x, e): rubi.append(5603) return -Subst(Int(x**(-S(2)*p + S(-2))*(a + b*acos(x/c))**n*(d*x**S(2) + e)**p, x), x, S(1)/x) rule5603 = ReplacementRule(pattern5603, replacement5603) pattern5604 = Pattern(Integral((x_**S(2)*WC('e', S(1)) + WC('d', S(0)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*acsc(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons4, cons38) def replacement5604(p, b, d, a, n, c, x, e): rubi.append(5604) return -Subst(Int(x**(-S(2)*p + S(-2))*(a + b*asin(x/c))**n*(d*x**S(2) + e)**p, x), x, S(1)/x) rule5604 = ReplacementRule(pattern5604, replacement5604) pattern5605 = Pattern(Integral((x_**S(2)*WC('e', S(1)) + WC('d', S(0)))**p_*(WC('a', S(0)) + WC('b', S(1))*asec(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons4, cons1737, cons667, cons178, cons1855) def replacement5605(p, b, d, a, n, c, x, e): rubi.append(5605) return -Dist(sqrt(x**S(2))/x, Subst(Int(x**(-S(2)*p + S(-2))*(a + b*acos(x/c))**n*(d*x**S(2) + e)**p, x), x, S(1)/x), x) rule5605 = ReplacementRule(pattern5605, replacement5605) pattern5606 = Pattern(Integral((x_**S(2)*WC('e', S(1)) + WC('d', S(0)))**p_*(WC('a', S(0)) + WC('b', S(1))*acsc(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons4, cons1737, cons667, cons178, cons1855) def replacement5606(p, b, d, a, n, c, x, e): rubi.append(5606) return -Dist(sqrt(x**S(2))/x, Subst(Int(x**(-S(2)*p + S(-2))*(a + b*asin(x/c))**n*(d*x**S(2) + e)**p, x), x, S(1)/x), x) rule5606 = ReplacementRule(pattern5606, replacement5606) pattern5607 = Pattern(Integral((x_**S(2)*WC('e', S(1)) + WC('d', S(0)))**p_*(WC('a', S(0)) + WC('b', S(1))*asec(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons4, cons1737, cons667, cons1856) def replacement5607(p, b, d, a, n, c, x, e): rubi.append(5607) return -Dist(sqrt(d + e*x**S(2))/(x*sqrt(d/x**S(2) + e)), Subst(Int(x**(-S(2)*p + S(-2))*(a + b*acos(x/c))**n*(d*x**S(2) + e)**p, x), x, S(1)/x), x) rule5607 = ReplacementRule(pattern5607, replacement5607) pattern5608 = Pattern(Integral((x_**S(2)*WC('e', S(1)) + WC('d', S(0)))**p_*(WC('a', S(0)) + WC('b', S(1))*acsc(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons4, cons1737, cons667, cons1856) def replacement5608(p, b, d, a, n, c, x, e): rubi.append(5608) return -Dist(sqrt(d + e*x**S(2))/(x*sqrt(d/x**S(2) + e)), Subst(Int(x**(-S(2)*p + S(-2))*(a + b*asin(x/c))**n*(d*x**S(2) + e)**p, x), x, S(1)/x), x) rule5608 = ReplacementRule(pattern5608, replacement5608) pattern5609 = Pattern(Integral((x_**S(2)*WC('e', S(1)) + WC('d', S(0)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*asec(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons4, cons5, cons1570) def replacement5609(p, b, d, a, n, c, x, e): rubi.append(5609) return Int((a + b*asec(c*x))**n*(d + e*x**S(2))**p, x) rule5609 = ReplacementRule(pattern5609, replacement5609) pattern5610 = Pattern(Integral((x_**S(2)*WC('e', S(1)) + WC('d', S(0)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*acsc(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons4, cons5, cons1570) def replacement5610(p, b, d, a, n, c, x, e): rubi.append(5610) return Int((a + b*acsc(c*x))**n*(d + e*x**S(2))**p, x) rule5610 = ReplacementRule(pattern5610, replacement5610) pattern5611 = Pattern(Integral(x_*(x_**S(2)*WC('e', S(1)) + WC('d', S(0)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*asec(x_*WC('c', S(1)))), x_), cons2, cons3, cons7, cons27, cons48, cons5, cons54) def replacement5611(p, b, d, a, c, x, e): rubi.append(5611) return -Dist(b*c*x/(S(2)*e*sqrt(c**S(2)*x**S(2))*(p + S(1))), Int((d + e*x**S(2))**(p + S(1))/(x*sqrt(c**S(2)*x**S(2) + S(-1))), x), x) + Simp((a + b*asec(c*x))*(d + e*x**S(2))**(p + S(1))/(S(2)*e*(p + S(1))), x) rule5611 = ReplacementRule(pattern5611, replacement5611) pattern5612 = Pattern(Integral(x_*(x_**S(2)*WC('e', S(1)) + WC('d', S(0)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*acsc(x_*WC('c', S(1)))), x_), cons2, cons3, cons7, cons27, cons48, cons5, cons54) def replacement5612(p, b, d, a, c, x, e): rubi.append(5612) return Dist(b*c*x/(S(2)*e*sqrt(c**S(2)*x**S(2))*(p + S(1))), Int((d + e*x**S(2))**(p + S(1))/(x*sqrt(c**S(2)*x**S(2) + S(-1))), x), x) + Simp((a + b*acsc(c*x))*(d + e*x**S(2))**(p + S(1))/(S(2)*e*(p + S(1))), x) rule5612 = ReplacementRule(pattern5612, replacement5612) def With5613(p, m, b, d, a, c, x, e): u = IntHide(x**m*(d + e*x**S(2))**p, x) rubi.append(5613) return -Dist(b*c*x/sqrt(c**S(2)*x**S(2)), Int(SimplifyIntegrand(u/(x*sqrt(c**S(2)*x**S(2) + S(-1))), x), x), x) + Dist(a + b*asec(c*x), u, x) pattern5613 = Pattern(Integral(x_**WC('m', S(1))*(x_**S(2)*WC('e', S(1)) + WC('d', S(0)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*asec(x_*WC('c', S(1)))), x_), cons2, cons3, cons7, cons27, cons48, cons21, cons5, cons1786) rule5613 = ReplacementRule(pattern5613, With5613) def With5614(p, m, b, d, a, c, x, e): u = IntHide(x**m*(d + e*x**S(2))**p, x) rubi.append(5614) return Dist(b*c*x/sqrt(c**S(2)*x**S(2)), Int(SimplifyIntegrand(u/(x*sqrt(c**S(2)*x**S(2) + S(-1))), x), x), x) + Dist(a + b*acsc(c*x), u, x) pattern5614 = Pattern(Integral(x_**WC('m', S(1))*(x_**S(2)*WC('e', S(1)) + WC('d', S(0)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*acsc(x_*WC('c', S(1)))), x_), cons2, cons3, cons7, cons27, cons48, cons21, cons5, cons1786) rule5614 = ReplacementRule(pattern5614, With5614) pattern5615 = Pattern(Integral(x_**WC('m', S(1))*(x_**S(2)*WC('e', S(1)) + WC('d', S(0)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*asec(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons4, cons1299) def replacement5615(p, m, b, d, a, n, c, x, e): rubi.append(5615) return -Subst(Int(x**(-m - S(2)*p + S(-2))*(a + b*acos(x/c))**n*(d*x**S(2) + e)**p, x), x, S(1)/x) rule5615 = ReplacementRule(pattern5615, replacement5615) pattern5616 = Pattern(Integral(x_**WC('m', S(1))*(x_**S(2)*WC('e', S(1)) + WC('d', S(0)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*acsc(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons4, cons1299) def replacement5616(p, m, b, d, a, n, c, x, e): rubi.append(5616) return -Subst(Int(x**(-m - S(2)*p + S(-2))*(a + b*asin(x/c))**n*(d*x**S(2) + e)**p, x), x, S(1)/x) rule5616 = ReplacementRule(pattern5616, replacement5616) pattern5617 = Pattern(Integral(x_**WC('m', S(1))*(x_**S(2)*WC('e', S(1)) + WC('d', S(0)))**p_*(WC('a', S(0)) + WC('b', S(1))*asec(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons4, cons1737, cons17, cons667, cons178, cons1855) def replacement5617(p, m, b, d, a, n, c, x, e): rubi.append(5617) return -Dist(sqrt(x**S(2))/x, Subst(Int(x**(-m - S(2)*p + S(-2))*(a + b*acos(x/c))**n*(d*x**S(2) + e)**p, x), x, S(1)/x), x) rule5617 = ReplacementRule(pattern5617, replacement5617) pattern5618 = Pattern(Integral(x_**WC('m', S(1))*(x_**S(2)*WC('e', S(1)) + WC('d', S(0)))**p_*(WC('a', S(0)) + WC('b', S(1))*acsc(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons4, cons1737, cons17, cons667, cons178, cons1855) def replacement5618(p, m, b, d, a, n, c, x, e): rubi.append(5618) return -Dist(sqrt(x**S(2))/x, Subst(Int(x**(-m - S(2)*p + S(-2))*(a + b*asin(x/c))**n*(d*x**S(2) + e)**p, x), x, S(1)/x), x) rule5618 = ReplacementRule(pattern5618, replacement5618) pattern5619 = Pattern(Integral(x_**WC('m', S(1))*(x_**S(2)*WC('e', S(1)) + WC('d', S(0)))**p_*(WC('a', S(0)) + WC('b', S(1))*asec(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons4, cons1737, cons17, cons667, cons1856) def replacement5619(p, m, b, d, a, n, c, x, e): rubi.append(5619) return -Dist(sqrt(d + e*x**S(2))/(x*sqrt(d/x**S(2) + e)), Subst(Int(x**(-m - S(2)*p + S(-2))*(a + b*acos(x/c))**n*(d*x**S(2) + e)**p, x), x, S(1)/x), x) rule5619 = ReplacementRule(pattern5619, replacement5619) pattern5620 = Pattern(Integral(x_**WC('m', S(1))*(x_**S(2)*WC('e', S(1)) + WC('d', S(0)))**p_*(WC('a', S(0)) + WC('b', S(1))*acsc(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons4, cons1737, cons17, cons667, cons1856) def replacement5620(p, m, b, d, a, n, c, x, e): rubi.append(5620) return -Dist(sqrt(d + e*x**S(2))/(x*sqrt(d/x**S(2) + e)), Subst(Int(x**(-m - S(2)*p + S(-2))*(a + b*asin(x/c))**n*(d*x**S(2) + e)**p, x), x, S(1)/x), x) rule5620 = ReplacementRule(pattern5620, replacement5620) pattern5621 = Pattern(Integral(x_**WC('m', S(1))*(x_**S(2)*WC('e', S(1)) + WC('d', S(0)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*asec(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons21, cons4, cons5, cons1497) def replacement5621(p, m, b, d, a, n, c, x, e): rubi.append(5621) return Int(x**m*(a + b*asec(c*x))**n*(d + e*x**S(2))**p, x) rule5621 = ReplacementRule(pattern5621, replacement5621) pattern5622 = Pattern(Integral(x_**WC('m', S(1))*(x_**S(2)*WC('e', S(1)) + WC('d', S(0)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*acsc(x_*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons21, cons4, cons5, cons1497) def replacement5622(p, m, b, d, a, n, c, x, e): rubi.append(5622) return Int(x**m*(a + b*acsc(c*x))**n*(d + e*x**S(2))**p, x) rule5622 = ReplacementRule(pattern5622, replacement5622) pattern5623 = Pattern(Integral(asec(a_ + x_*WC('b', S(1))), x_), cons2, cons3, cons67) def replacement5623(x, a, b): rubi.append(5623) return -Int(S(1)/(sqrt(S(1) - S(1)/(a + b*x)**S(2))*(a + b*x)), x) + Simp((a + b*x)*asec(a + b*x)/b, x) rule5623 = ReplacementRule(pattern5623, replacement5623) pattern5624 = Pattern(Integral(acsc(a_ + x_*WC('b', S(1))), x_), cons2, cons3, cons67) def replacement5624(x, a, b): rubi.append(5624) return Int(S(1)/(sqrt(S(1) - S(1)/(a + b*x)**S(2))*(a + b*x)), x) + Simp((a + b*x)*acsc(a + b*x)/b, x) rule5624 = ReplacementRule(pattern5624, replacement5624) pattern5625 = Pattern(Integral(asec(a_ + x_*WC('b', S(1)))**n_, x_), cons2, cons3, cons4, cons1831) def replacement5625(x, a, n, b): rubi.append(5625) return Dist(S(1)/b, Subst(Int(x**n*tan(x)/cos(x), x), x, asec(a + b*x)), x) rule5625 = ReplacementRule(pattern5625, replacement5625) pattern5626 = Pattern(Integral(acsc(a_ + x_*WC('b', S(1)))**n_, x_), cons2, cons3, cons4, cons1831) def replacement5626(x, a, n, b): rubi.append(5626) return -Dist(S(1)/b, Subst(Int(x**n/(sin(x)*tan(x)), x), x, acsc(a + b*x)), x) rule5626 = ReplacementRule(pattern5626, replacement5626) pattern5627 = Pattern(Integral(asec(a_ + x_*WC('b', S(1)))/x_, x_), cons2, cons3, cons67) def replacement5627(x, a, b): rubi.append(5627) return -Simp(I*PolyLog(S(2), (-sqrt(-a**S(2) + S(1)) + S(1))*exp(I*asec(a + b*x))/a), x) - Simp(I*PolyLog(S(2), (sqrt(-a**S(2) + S(1)) + S(1))*exp(I*asec(a + b*x))/a), x) + Simp(I*PolyLog(S(2), -exp(S(2)*I*asec(a + b*x)))/S(2), x) + Simp(log(S(1) - (-sqrt(-a**S(2) + S(1)) + S(1))*exp(I*asec(a + b*x))/a)*asec(a + b*x), x) + Simp(log(S(1) - (sqrt(-a**S(2) + S(1)) + S(1))*exp(I*asec(a + b*x))/a)*asec(a + b*x), x) - Simp(log(exp(S(2)*I*asec(a + b*x)) + S(1))*asec(a + b*x), x) rule5627 = ReplacementRule(pattern5627, replacement5627) pattern5628 = Pattern(Integral(acsc(a_ + x_*WC('b', S(1)))/x_, x_), cons2, cons3, cons67) def replacement5628(x, a, b): rubi.append(5628) return Simp(I*PolyLog(S(2), I*(-sqrt(-a**S(2) + S(1)) + S(1))*exp(-I*acsc(a + b*x))/a), x) + Simp(I*PolyLog(S(2), I*(sqrt(-a**S(2) + S(1)) + S(1))*exp(-I*acsc(a + b*x))/a), x) + Simp(I*PolyLog(S(2), exp(S(2)*I*acsc(a + b*x)))/S(2), x) + Simp(I*acsc(a + b*x)**S(2), x) + Simp(log(S(1) - I*(-sqrt(-a**S(2) + S(1)) + S(1))*exp(-I*acsc(a + b*x))/a)*acsc(a + b*x), x) + Simp(log(S(1) - I*(sqrt(-a**S(2) + S(1)) + S(1))*exp(-I*acsc(a + b*x))/a)*acsc(a + b*x), x) - Simp(log(-exp(S(2)*I*acsc(a + b*x)) + S(1))*acsc(a + b*x), x) rule5628 = ReplacementRule(pattern5628, replacement5628) pattern5629 = Pattern(Integral(x_**WC('m', S(1))*asec(a_ + x_*WC('b', S(1))), x_), cons2, cons3, cons21, cons17, cons66) def replacement5629(x, m, b, a): rubi.append(5629) return -Dist(b**(-m + S(-1))/(m + S(1)), Subst(Int(x**(-m + S(-1))*((-a*x)**(m + S(1)) - (-a*x + S(1))**(m + S(1)))/sqrt(-x**S(2) + S(1)), x), x, S(1)/(a + b*x)), x) - Simp(b**(-m + S(-1))*(-b**(m + S(1))*x**(m + S(1)) + (-a)**(m + S(1)))*asec(a + b*x)/(m + S(1)), x) rule5629 = ReplacementRule(pattern5629, replacement5629) pattern5630 = Pattern(Integral(x_**WC('m', S(1))*acsc(a_ + x_*WC('b', S(1))), x_), cons2, cons3, cons21, cons17, cons66) def replacement5630(x, m, b, a): rubi.append(5630) return Dist(b**(-m + S(-1))/(m + S(1)), Subst(Int(x**(-m + S(-1))*((-a*x)**(m + S(1)) - (-a*x + S(1))**(m + S(1)))/sqrt(-x**S(2) + S(1)), x), x, S(1)/(a + b*x)), x) - Simp(b**(-m + S(-1))*(-b**(m + S(1))*x**(m + S(1)) + (-a)**(m + S(1)))*acsc(a + b*x)/(m + S(1)), x) rule5630 = ReplacementRule(pattern5630, replacement5630) pattern5631 = Pattern(Integral(x_**WC('m', S(1))*asec(a_ + x_*WC('b', S(1)))**n_, x_), cons2, cons3, cons4, cons62) def replacement5631(m, b, a, n, x): rubi.append(5631) return Dist(b**(-m + S(-1)), Subst(Int(x**n*(-a + S(1)/cos(x))**m*tan(x)/cos(x), x), x, asec(a + b*x)), x) rule5631 = ReplacementRule(pattern5631, replacement5631) pattern5632 = Pattern(Integral(x_**WC('m', S(1))*acsc(a_ + x_*WC('b', S(1)))**n_, x_), cons2, cons3, cons4, cons62) def replacement5632(m, b, a, n, x): rubi.append(5632) return -Dist(b**(-m + S(-1)), Subst(Int(x**n*(-a + S(1)/sin(x))**m/(sin(x)*tan(x)), x), x, acsc(a + b*x)), x) rule5632 = ReplacementRule(pattern5632, replacement5632) pattern5633 = Pattern(Integral(WC('u', S(1))*asec(WC('c', S(1))/(x_**WC('n', S(1))*WC('b', S(1)) + WC('a', S(0))))**WC('m', S(1)), x_), cons2, cons3, cons7, cons4, cons21, cons1766) def replacement5633(u, m, b, c, n, a, x): rubi.append(5633) return Int(u*acos(a/c + b*x**n/c)**m, x) rule5633 = ReplacementRule(pattern5633, replacement5633) pattern5634 = Pattern(Integral(WC('u', S(1))*acsc(WC('c', S(1))/(x_**WC('n', S(1))*WC('b', S(1)) + WC('a', S(0))))**WC('m', S(1)), x_), cons2, cons3, cons7, cons4, cons21, cons1766) def replacement5634(u, m, b, c, n, a, x): rubi.append(5634) return Int(u*asin(a/c + b*x**n/c)**m, x) rule5634 = ReplacementRule(pattern5634, replacement5634) pattern5635 = Pattern(Integral(f_**(WC('c', S(1))*asec(x_*WC('b', S(1)) + WC('a', S(0)))**WC('n', S(1)))*WC('u', S(1)), x_), cons2, cons3, cons7, cons125, cons148) def replacement5635(u, f, b, c, a, n, x): rubi.append(5635) return Dist(S(1)/b, Subst(Int(f**(c*x**n)*ReplaceAll(u, Rule(x, -a/b + S(1)/(b*cos(x))))*tan(x)/cos(x), x), x, asec(a + b*x)), x) rule5635 = ReplacementRule(pattern5635, replacement5635) pattern5636 = Pattern(Integral(f_**(WC('c', S(1))*acsc(x_*WC('b', S(1)) + WC('a', S(0)))**WC('n', S(1)))*WC('u', S(1)), x_), cons2, cons3, cons7, cons125, cons148) def replacement5636(u, f, b, c, a, n, x): rubi.append(5636) return -Dist(S(1)/b, Subst(Int(f**(c*x**n)*ReplaceAll(u, Rule(x, -a/b + S(1)/(b*sin(x))))/(sin(x)*tan(x)), x), x, acsc(a + b*x)), x) rule5636 = ReplacementRule(pattern5636, replacement5636) pattern5637 = Pattern(Integral(asec(u_), x_), cons1230, cons1769) def replacement5637(x, u): rubi.append(5637) return -Dist(u/sqrt(u**S(2)), Int(SimplifyIntegrand(x*D(u, x)/(u*sqrt(u**S(2) + S(-1))), x), x), x) + Simp(x*asec(u), x) rule5637 = ReplacementRule(pattern5637, replacement5637) pattern5638 = Pattern(Integral(acsc(u_), x_), cons1230, cons1769) def replacement5638(x, u): rubi.append(5638) return Dist(u/sqrt(u**S(2)), Int(SimplifyIntegrand(x*D(u, x)/(u*sqrt(u**S(2) + S(-1))), x), x), x) + Simp(x*acsc(u), x) rule5638 = ReplacementRule(pattern5638, replacement5638) pattern5639 = Pattern(Integral((x_*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*asec(u_)), x_), cons2, cons3, cons7, cons27, cons21, cons66, cons1230, cons1770, cons1769) def replacement5639(u, m, b, d, c, a, x): rubi.append(5639) return -Dist(b*u/(d*(m + S(1))*sqrt(u**S(2))), Int(SimplifyIntegrand((c + d*x)**(m + S(1))*D(u, x)/(u*sqrt(u**S(2) + S(-1))), x), x), x) + Simp((a + b*asec(u))*(c + d*x)**(m + S(1))/(d*(m + S(1))), x) rule5639 = ReplacementRule(pattern5639, replacement5639) pattern5640 = Pattern(Integral((x_*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*acsc(u_)), x_), cons2, cons3, cons7, cons27, cons21, cons66, cons1230, cons1770, cons1769) def replacement5640(u, m, b, d, c, a, x): rubi.append(5640) return Dist(b*u/(d*(m + S(1))*sqrt(u**S(2))), Int(SimplifyIntegrand((c + d*x)**(m + S(1))*D(u, x)/(u*sqrt(u**S(2) + S(-1))), x), x), x) + Simp((a + b*acsc(u))*(c + d*x)**(m + S(1))/(d*(m + S(1))), x) rule5640 = ReplacementRule(pattern5640, replacement5640) def With5641(v, u, b, a, x): if isinstance(x, (int, Integer, float, Float)): return False w = IntHide(v, x) if InverseFunctionFreeQ(w, x): return True return False pattern5641 = Pattern(Integral(v_*(WC('a', S(0)) + WC('b', S(1))*asec(u_)), x_), cons2, cons3, cons1230, cons1857, CustomConstraint(With5641)) def replacement5641(v, u, b, a, x): w = IntHide(v, x) rubi.append(5641) return -Dist(b*u/sqrt(u**S(2)), Int(SimplifyIntegrand(w*D(u, x)/(u*sqrt(u**S(2) + S(-1))), x), x), x) + Dist(a + b*asec(u), w, x) rule5641 = ReplacementRule(pattern5641, replacement5641) def With5642(v, u, b, a, x): if isinstance(x, (int, Integer, float, Float)): return False w = IntHide(v, x) if InverseFunctionFreeQ(w, x): return True return False pattern5642 = Pattern(Integral(v_*(WC('a', S(0)) + WC('b', S(1))*acsc(u_)), x_), cons2, cons3, cons1230, cons1858, CustomConstraint(With5642)) def replacement5642(v, u, b, a, x): w = IntHide(v, x) rubi.append(5642) return Dist(b*u/sqrt(u**S(2)), Int(SimplifyIntegrand(w*D(u, x)/(u*sqrt(u**S(2) + S(-1))), x), x), x) + Dist(a + b*acsc(u), w, x) rule5642 = ReplacementRule(pattern5642, replacement5642) return [rule5031, rule5032, rule5033, rule5034, rule5035, rule5036, rule5037, rule5038, rule5039, rule5040, rule5041, rule5042, rule5043, rule5044, rule5045, rule5046, rule5047, rule5048, rule5049, rule5050, rule5051, rule5052, rule5053, rule5054, rule5055, rule5056, rule5057, rule5058, rule5059, rule5060, rule5061, rule5062, rule5063, rule5064, rule5065, rule5066, rule5067, rule5068, rule5069, rule5070, rule5071, rule5072, rule5073, rule5074, rule5075, rule5076, rule5077, rule5078, rule5079, rule5080, rule5081, rule5082, rule5083, rule5084, rule5085, rule5086, rule5087, rule5088, rule5089, rule5090, rule5091, rule5092, rule5093, rule5094, rule5095, rule5096, rule5097, rule5098, rule5099, rule5100, rule5101, rule5102, rule5103, rule5104, rule5105, rule5106, rule5107, rule5108, rule5109, rule5110, rule5111, rule5112, rule5113, rule5114, rule5115, rule5116, rule5117, rule5118, rule5119, rule5120, rule5121, rule5122, rule5123, rule5124, rule5125, rule5126, rule5127, rule5128, rule5129, rule5130, rule5131, rule5132, rule5133, rule5134, rule5135, rule5136, rule5137, rule5138, rule5139, rule5140, rule5141, rule5142, rule5143, rule5144, rule5145, rule5146, rule5147, rule5148, rule5149, rule5150, rule5151, rule5152, rule5153, rule5154, rule5155, rule5156, rule5157, rule5158, rule5159, rule5160, rule5161, rule5162, rule5163, rule5164, rule5165, rule5166, rule5167, rule5168, rule5169, rule5170, rule5171, rule5172, rule5173, rule5174, rule5175, rule5176, rule5177, rule5178, rule5179, rule5180, rule5181, rule5182, rule5183, rule5184, rule5185, rule5186, rule5187, rule5188, rule5189, rule5190, rule5191, rule5192, rule5193, rule5194, rule5195, rule5196, rule5197, rule5198, rule5199, rule5200, rule5201, rule5202, rule5203, rule5204, rule5205, rule5206, rule5207, rule5208, rule5209, rule5210, rule5211, rule5212, rule5213, rule5214, rule5215, rule5216, rule5217, rule5218, rule5219, rule5220, rule5221, rule5222, rule5223, rule5224, rule5225, rule5226, rule5227, rule5228, rule5229, rule5230, rule5231, rule5232, rule5233, rule5234, rule5235, rule5236, rule5237, rule5238, rule5239, rule5240, rule5241, rule5242, rule5243, rule5244, rule5245, rule5246, rule5247, rule5248, rule5249, rule5250, rule5251, rule5252, rule5253, rule5254, rule5255, rule5256, rule5257, rule5258, rule5259, rule5260, rule5261, rule5262, rule5263, rule5264, rule5265, rule5266, rule5267, rule5268, rule5269, rule5270, rule5271, rule5272, rule5273, rule5274, rule5275, rule5276, rule5277, rule5278, rule5279, rule5280, rule5281, rule5282, rule5283, rule5284, rule5285, rule5286, rule5287, rule5288, rule5289, rule5290, rule5291, rule5292, rule5293, rule5294, rule5295, rule5296, rule5297, rule5298, rule5299, rule5300, rule5301, rule5302, rule5303, rule5304, rule5305, rule5306, rule5307, rule5308, rule5309, rule5310, rule5311, rule5312, rule5313, rule5314, rule5315, rule5316, rule5317, rule5318, rule5319, rule5320, rule5321, rule5322, rule5323, rule5324, rule5325, rule5326, rule5327, rule5328, rule5329, rule5330, rule5331, rule5332, rule5333, rule5334, rule5335, rule5336, rule5337, rule5338, rule5339, rule5340, rule5341, rule5342, rule5343, rule5344, rule5345, rule5346, rule5347, rule5348, rule5349, rule5350, rule5351, rule5352, rule5353, rule5354, rule5355, rule5356, rule5357, rule5358, rule5359, rule5360, rule5361, rule5362, rule5363, rule5364, rule5365, rule5366, rule5367, rule5368, rule5369, rule5370, rule5371, rule5372, rule5373, rule5374, rule5375, rule5376, rule5377, rule5378, rule5379, rule5380, rule5381, rule5382, rule5383, rule5384, rule5385, rule5386, rule5387, rule5388, rule5389, rule5390, rule5391, rule5392, rule5393, rule5394, rule5395, rule5396, rule5397, rule5398, rule5399, rule5400, rule5401, rule5402, rule5403, rule5404, rule5405, rule5406, rule5407, rule5408, rule5409, rule5410, rule5411, rule5412, rule5413, rule5414, rule5415, rule5416, rule5417, rule5418, rule5419, rule5420, rule5421, rule5422, rule5423, rule5424, rule5425, rule5426, rule5427, rule5428, rule5429, rule5430, rule5431, rule5432, rule5433, rule5434, rule5435, rule5436, rule5437, rule5438, rule5439, rule5440, rule5441, rule5442, rule5443, rule5444, rule5445, rule5446, rule5447, rule5448, rule5449, rule5450, rule5451, rule5452, rule5453, rule5454, rule5455, rule5456, rule5457, rule5458, rule5459, rule5460, rule5461, rule5462, rule5463, rule5464, rule5465, rule5466, rule5467, rule5468, rule5469, rule5470, rule5471, rule5472, rule5473, rule5474, rule5475, rule5476, rule5477, rule5478, rule5479, rule5480, rule5481, rule5482, rule5483, rule5484, rule5485, rule5486, rule5487, rule5488, rule5489, rule5490, rule5491, rule5492, rule5493, rule5494, rule5495, rule5496, rule5497, rule5498, rule5499, rule5500, rule5501, rule5502, rule5503, rule5504, rule5505, rule5506, rule5507, rule5508, rule5509, rule5510, rule5511, rule5512, rule5513, rule5514, rule5515, rule5516, rule5517, rule5518, rule5519, rule5520, rule5521, rule5522, rule5523, rule5524, rule5525, rule5526, rule5527, rule5528, rule5529, rule5530, rule5531, rule5532, rule5533, rule5534, rule5535, rule5536, rule5537, rule5538, rule5539, rule5540, rule5541, rule5542, rule5543, rule5544, rule5545, rule5546, rule5547, rule5548, rule5549, rule5550, rule5551, rule5552, rule5553, rule5554, rule5555, rule5556, rule5557, rule5558, rule5559, rule5560, rule5561, rule5562, rule5563, rule5564, rule5565, rule5566, rule5567, rule5568, rule5569, rule5570, rule5571, rule5572, rule5573, rule5574, rule5575, rule5576, rule5577, rule5578, rule5579, rule5580, rule5581, rule5582, rule5583, rule5584, rule5585, rule5586, rule5587, rule5588, rule5589, rule5590, rule5591, rule5592, rule5593, rule5594, rule5595, rule5596, rule5597, rule5598, rule5599, rule5600, rule5601, rule5602, rule5603, rule5604, rule5605, rule5606, rule5607, rule5608, rule5609, rule5610, rule5611, rule5612, rule5613, rule5614, rule5615, rule5616, rule5617, rule5618, rule5619, rule5620, rule5621, rule5622, rule5623, rule5624, rule5625, rule5626, rule5627, rule5628, rule5629, rule5630, rule5631, rule5632, rule5633, rule5634, rule5635, rule5636, rule5637, rule5638, rule5639, rule5640, rule5641, rule5642, ]
98903fe9a14b59cf899bb228421332b5f4ace2fafd0587eded9606f7533f543a
''' This code is automatically generated. Never edit it manually. For details of generating the code see `rubi_parsing_guide.md` in `parsetools`. ''' from sympy.external import import_module matchpy = import_module("matchpy") from sympy.utilities.decorator import doctest_depends_on if matchpy: from matchpy import Pattern, ReplacementRule, CustomConstraint, is_match from sympy.integrals.rubi.utility_function import ( Int, Sum, Set, With, Module, Scan, MapAnd, FalseQ, ZeroQ, NegativeQ, NonzeroQ, FreeQ, NFreeQ, List, Log, PositiveQ, PositiveIntegerQ, NegativeIntegerQ, IntegerQ, IntegersQ, ComplexNumberQ, PureComplexNumberQ, RealNumericQ, PositiveOrZeroQ, NegativeOrZeroQ, FractionOrNegativeQ, NegQ, Equal, Unequal, IntPart, FracPart, RationalQ, ProductQ, SumQ, NonsumQ, Subst, First, Rest, SqrtNumberQ, SqrtNumberSumQ, LinearQ, Sqrt, ArcCosh, Coefficient, Denominator, Hypergeometric2F1, Not, Simplify, FractionalPart, IntegerPart, AppellF1, EllipticPi, EllipticE, EllipticF, ArcTan, ArcCot, ArcCoth, ArcTanh, ArcSin, ArcSinh, ArcCos, ArcCsc, ArcSec, ArcCsch, ArcSech, Sinh, Tanh, Cosh, Sech, Csch, Coth, LessEqual, Less, Greater, GreaterEqual, FractionQ, IntLinearcQ, Expand, IndependentQ, PowerQ, IntegerPowerQ, PositiveIntegerPowerQ, FractionalPowerQ, AtomQ, ExpQ, LogQ, Head, MemberQ, TrigQ, SinQ, CosQ, TanQ, CotQ, SecQ, CscQ, Sin, Cos, Tan, Cot, Sec, Csc, HyperbolicQ, SinhQ, CoshQ, TanhQ, CothQ, SechQ, CschQ, InverseTrigQ, SinCosQ, SinhCoshQ, LeafCount, Numerator, NumberQ, NumericQ, Length, ListQ, Im, Re, InverseHyperbolicQ, InverseFunctionQ, TrigHyperbolicFreeQ, InverseFunctionFreeQ, RealQ, EqQ, FractionalPowerFreeQ, ComplexFreeQ, PolynomialQ, FactorSquareFree, PowerOfLinearQ, Exponent, QuadraticQ, LinearPairQ, BinomialParts, TrinomialParts, PolyQ, EvenQ, OddQ, PerfectSquareQ, NiceSqrtAuxQ, NiceSqrtQ, Together, PosAux, PosQ, CoefficientList, ReplaceAll, ExpandLinearProduct, GCD, ContentFactor, NumericFactor, NonnumericFactors, MakeAssocList, GensymSubst, KernelSubst, ExpandExpression, Apart, SmartApart, MatchQ, PolynomialQuotientRemainder, FreeFactors, NonfreeFactors, RemoveContentAux, RemoveContent, FreeTerms, NonfreeTerms, ExpandAlgebraicFunction, CollectReciprocals, ExpandCleanup, AlgebraicFunctionQ, Coeff, LeadTerm, RemainingTerms, LeadFactor, RemainingFactors, LeadBase, LeadDegree, Numer, Denom, hypergeom, Expon, MergeMonomials, PolynomialDivide, BinomialQ, TrinomialQ, GeneralizedBinomialQ, GeneralizedTrinomialQ, FactorSquareFreeList, PerfectPowerTest, SquareFreeFactorTest, RationalFunctionQ, RationalFunctionFactors, NonrationalFunctionFactors, Reverse, RationalFunctionExponents, RationalFunctionExpand, ExpandIntegrand, SimplerQ, SimplerSqrtQ, SumSimplerQ, BinomialDegree, TrinomialDegree, CancelCommonFactors, SimplerIntegrandQ, GeneralizedBinomialDegree, GeneralizedBinomialParts, GeneralizedTrinomialDegree, GeneralizedTrinomialParts, MonomialQ, MonomialSumQ, MinimumMonomialExponent, MonomialExponent, LinearMatchQ, PowerOfLinearMatchQ, QuadraticMatchQ, CubicMatchQ, BinomialMatchQ, TrinomialMatchQ, GeneralizedBinomialMatchQ, GeneralizedTrinomialMatchQ, QuotientOfLinearsMatchQ, PolynomialTermQ, PolynomialTerms, NonpolynomialTerms, PseudoBinomialParts, NormalizePseudoBinomial, PseudoBinomialPairQ, PseudoBinomialQ, PolynomialGCD, PolyGCD, AlgebraicFunctionFactors, NonalgebraicFunctionFactors, QuotientOfLinearsP, QuotientOfLinearsParts, QuotientOfLinearsQ, Flatten, Sort, AbsurdNumberQ, AbsurdNumberFactors, NonabsurdNumberFactors, SumSimplerAuxQ, Prepend, Drop, CombineExponents, FactorInteger, FactorAbsurdNumber, SubstForInverseFunction, SubstForFractionalPower, SubstForFractionalPowerOfQuotientOfLinears, FractionalPowerOfQuotientOfLinears, SubstForFractionalPowerQ, SubstForFractionalPowerAuxQ, FractionalPowerOfSquareQ, FractionalPowerSubexpressionQ, Apply, FactorNumericGcd, MergeableFactorQ, MergeFactor, MergeFactors, TrigSimplifyQ, TrigSimplify, TrigSimplifyRecur, Order, FactorOrder, Smallest, OrderedQ, MinimumDegree, PositiveFactors, Sign, NonpositiveFactors, PolynomialInAuxQ, PolynomialInQ, ExponentInAux, ExponentIn, PolynomialInSubstAux, PolynomialInSubst, Distrib, DistributeDegree, FunctionOfPower, DivideDegreesOfFactors, MonomialFactor, FullSimplify, FunctionOfLinearSubst, FunctionOfLinear, NormalizeIntegrand, NormalizeIntegrandAux, NormalizeIntegrandFactor, NormalizeIntegrandFactorBase, NormalizeTogether, NormalizeLeadTermSigns, AbsorbMinusSign, NormalizeSumFactors, SignOfFactor, NormalizePowerOfLinear, SimplifyIntegrand, SimplifyTerm, TogetherSimplify, SmartSimplify, SubstForExpn, ExpandToSum, UnifySum, UnifyTerms, UnifyTerm, CalculusQ, FunctionOfInverseLinear, PureFunctionOfSinhQ, PureFunctionOfTanhQ, PureFunctionOfCoshQ, IntegerQuotientQ, OddQuotientQ, EvenQuotientQ, FindTrigFactor, FunctionOfSinhQ, FunctionOfCoshQ, OddHyperbolicPowerQ, FunctionOfTanhQ, FunctionOfTanhWeight, FunctionOfHyperbolicQ, SmartNumerator, SmartDenominator, SubstForAux, ActivateTrig, ExpandTrig, TrigExpand, SubstForTrig, SubstForHyperbolic, InertTrigFreeQ, LCM, SubstForFractionalPowerOfLinear, FractionalPowerOfLinear, InverseFunctionOfLinear, InertTrigQ, InertReciprocalQ, DeactivateTrig, FixInertTrigFunction, DeactivateTrigAux, PowerOfInertTrigSumQ, PiecewiseLinearQ, KnownTrigIntegrandQ, KnownSineIntegrandQ, KnownTangentIntegrandQ, KnownCotangentIntegrandQ, KnownSecantIntegrandQ, TryPureTanSubst, TryTanhSubst, TryPureTanhSubst, AbsurdNumberGCD, AbsurdNumberGCDList, ExpandTrigExpand, ExpandTrigReduce, ExpandTrigReduceAux, NormalizeTrig, TrigToExp, ExpandTrigToExp, TrigReduce, FunctionOfTrig, AlgebraicTrigFunctionQ, FunctionOfHyperbolic, FunctionOfQ, FunctionOfExpnQ, PureFunctionOfSinQ, PureFunctionOfCosQ, PureFunctionOfTanQ, PureFunctionOfCotQ, FunctionOfCosQ, FunctionOfSinQ, OddTrigPowerQ, FunctionOfTanQ, FunctionOfTanWeight, FunctionOfTrigQ, FunctionOfDensePolynomialsQ, FunctionOfLog, PowerVariableExpn, PowerVariableDegree, PowerVariableSubst, EulerIntegrandQ, FunctionOfSquareRootOfQuadratic, SquareRootOfQuadraticSubst, Divides, EasyDQ, ProductOfLinearPowersQ, Rt, NthRoot, AtomBaseQ, SumBaseQ, NegSumBaseQ, AllNegTermQ, SomeNegTermQ, TrigSquareQ, RtAux, TrigSquare, IntSum, IntTerm, Map2, ConstantFactor, SameQ, ReplacePart, CommonFactors, MostMainFactorPosition, FunctionOfExponentialQ, FunctionOfExponential, FunctionOfExponentialFunction, FunctionOfExponentialFunctionAux, FunctionOfExponentialTest, FunctionOfExponentialTestAux, stdev, rubi_test, If, IntQuadraticQ, IntBinomialQ, RectifyTangent, RectifyCotangent, Inequality, Condition, Simp, SimpHelp, SplitProduct, SplitSum, SubstFor, SubstForAux, FresnelS, FresnelC, Erfc, Erfi, Gamma, FunctionOfTrigOfLinearQ, ElementaryFunctionQ, Complex, UnsameQ, _SimpFixFactor, SimpFixFactor, _FixSimplify, FixSimplify, _SimplifyAntiderivativeSum, SimplifyAntiderivativeSum, _SimplifyAntiderivative, SimplifyAntiderivative, _TrigSimplifyAux, TrigSimplifyAux, Cancel, Part, PolyLog, D, Dist, Sum_doit, PolynomialQuotient, Floor, PolynomialRemainder, Factor, PolyLog, CosIntegral, SinIntegral, LogIntegral, SinhIntegral, CoshIntegral, Rule, Erf, PolyGamma, ExpIntegralEi, ExpIntegralE, LogGamma , UtilityOperator, Factorial, Zeta, ProductLog, DerivativeDivides, HypergeometricPFQ, IntHide, OneQ, Null, rubi_exp as exp, rubi_log as log, Discriminant, Negative, Quotient ) from sympy import (Integral, S, sqrt, And, Or, Integer, Float, Mod, I, Abs, simplify, Mul, Add, Pow, sign, EulerGamma) from sympy.integrals.rubi.symbol import WC from sympy.core.symbol import symbols, Symbol from sympy.functions import (sin, cos, tan, cot, csc, sec, sqrt, erf) from sympy.functions.elementary.hyperbolic import (acosh, asinh, atanh, acoth, acsch, asech, cosh, sinh, tanh, coth, sech, csch) from sympy.functions.elementary.trigonometric import (atan, acsc, asin, acot, acos, asec, atan2) from sympy import pi as Pi A_, B_, C_, F_, G_, H_, a_, b_, c_, d_, e_, f_, g_, h_, i_, j_, k_, l_, m_, n_, p_, q_, r_, t_, u_, v_, s_, w_, x_, y_, z_ = [WC(i) for i in 'ABCFGHabcdefghijklmnpqrtuvswxyz'] a1_, a2_, b1_, b2_, c1_, c2_, d1_, d2_, n1_, n2_, e1_, e2_, f1_, f2_, g1_, g2_, n1_, n2_, n3_, Pq_, Pm_, Px_, Qm_, Qr_, Qx_, jn_, mn_, non2_, RFx_, RGx_ = [WC(i) for i in ['a1', 'a2', 'b1', 'b2', 'c1', 'c2', 'd1', 'd2', 'n1', 'n2', 'e1', 'e2', 'f1', 'f2', 'g1', 'g2', 'n1', 'n2', 'n3', 'Pq', 'Pm', 'Px', 'Qm', 'Qr', 'Qx', 'jn', 'mn', 'non2', 'RFx', 'RGx']] i, ii , Pqq, Q, R, r, C, k, u = symbols('i ii Pqq Q R r C k u') _UseGamma = False ShowSteps = False StepCounter = None def piecewise_linear(rubi): from sympy.integrals.rubi.constraints import cons1090, cons21, cons1091, cons87, cons88, cons1092, cons89, cons23, cons72, cons66, cons4, cons1093, cons214, cons683, cons100, cons101, cons1094, cons1095, cons31, cons94, cons356, cons1096, cons18, cons1097, cons2, cons3 def With1882(x, m, u): c = D(u, x) rubi.append(1882) return Dist(S(1)/c, Subst(Int(x**m, x), x, u), x) pattern1882 = Pattern(Integral(u_**WC('m', S(1)), x_), cons21, cons1090) rule1882 = ReplacementRule(pattern1882, With1882) def With1883(v, x, u): if isinstance(x, (int, Integer, float, Float)): return False a = D(u, x) b = D(v, x) if NonzeroQ(-a*v + b*u): return True return False pattern1883 = Pattern(Integral(v_/u_, x_), cons1091, CustomConstraint(With1883)) def replacement1883(v, x, u): a = D(u, x) b = D(v, x) rubi.append(1883) return -Dist((-a*v + b*u)/a, Int(S(1)/u, x), x) + Simp(b*x/a, x) rule1883 = ReplacementRule(pattern1883, replacement1883) def With1884(v, x, n, u): if isinstance(x, (int, Integer, float, Float)): return False a = D(u, x) b = D(v, x) if NonzeroQ(-a*v + b*u): return True return False pattern1884 = Pattern(Integral(v_**n_/u_, x_), cons1091, cons87, cons88, cons1092, CustomConstraint(With1884)) def replacement1884(v, x, n, u): a = D(u, x) b = D(v, x) rubi.append(1884) return -Dist((-a*v + b*u)/a, Int(v**(n + S(-1))/u, x), x) + Simp(v**n/(a*n), x) rule1884 = ReplacementRule(pattern1884, replacement1884) def With1885(v, x, u): if isinstance(x, (int, Integer, float, Float)): return False a = D(u, x) b = D(v, x) if NonzeroQ(-a*v + b*u): return True return False pattern1885 = Pattern(Integral(S(1)/(u_*v_), x_), cons1091, CustomConstraint(With1885)) def replacement1885(v, x, u): a = D(u, x) b = D(v, x) rubi.append(1885) return -Dist(a/(-a*v + b*u), Int(S(1)/u, x), x) + Dist(b/(-a*v + b*u), Int(S(1)/v, x), x) rule1885 = ReplacementRule(pattern1885, replacement1885) def With1886(v, x, u): if isinstance(x, (int, Integer, float, Float)): return False a = D(u, x) b = D(v, x) if And(NonzeroQ(-a*v + b*u), PosQ((-a*v + b*u)/a)): return True return False pattern1886 = Pattern(Integral(S(1)/(u_*sqrt(v_)), x_), cons1091, CustomConstraint(With1886)) def replacement1886(v, x, u): a = D(u, x) b = D(v, x) rubi.append(1886) return Simp(S(2)*ArcTan(sqrt(v)/Rt((-a*v + b*u)/a, S(2)))/(a*Rt((-a*v + b*u)/a, S(2))), x) rule1886 = ReplacementRule(pattern1886, replacement1886) def With1887(v, x, u): if isinstance(x, (int, Integer, float, Float)): return False a = D(u, x) b = D(v, x) if And(NonzeroQ(-a*v + b*u), NegQ((-a*v + b*u)/a)): return True return False pattern1887 = Pattern(Integral(S(1)/(u_*sqrt(v_)), x_), cons1091, CustomConstraint(With1887)) def replacement1887(v, x, u): a = D(u, x) b = D(v, x) rubi.append(1887) return Simp(-S(2)*atanh(sqrt(v)/Rt(-(-a*v + b*u)/a, S(2)))/(a*Rt(-(-a*v + b*u)/a, S(2))), x) rule1887 = ReplacementRule(pattern1887, replacement1887) def With1888(v, x, n, u): if isinstance(x, (int, Integer, float, Float)): return False a = D(u, x) b = D(v, x) if NonzeroQ(-a*v + b*u): return True return False pattern1888 = Pattern(Integral(v_**n_/u_, x_), cons1091, cons87, cons89, CustomConstraint(With1888)) def replacement1888(v, x, n, u): a = D(u, x) b = D(v, x) rubi.append(1888) return -Dist(a/(-a*v + b*u), Int(v**(n + S(1))/u, x), x) + Simp(v**(n + S(1))/((n + S(1))*(-a*v + b*u)), x) rule1888 = ReplacementRule(pattern1888, replacement1888) def With1889(v, x, n, u): if isinstance(x, (int, Integer, float, Float)): return False a = D(u, x) b = D(v, x) if NonzeroQ(-a*v + b*u): return True return False pattern1889 = Pattern(Integral(v_**n_/u_, x_), cons1091, cons23, CustomConstraint(With1889)) def replacement1889(v, x, n, u): a = D(u, x) b = D(v, x) rubi.append(1889) return Simp(v**(n + S(1))*Hypergeometric2F1(S(1), n + S(1), n + S(2), -a*v/(-a*v + b*u))/((n + S(1))*(-a*v + b*u)), x) rule1889 = ReplacementRule(pattern1889, replacement1889) def With1890(v, x, u): if isinstance(x, (int, Integer, float, Float)): return False a = D(u, x) b = D(v, x) if And(NonzeroQ(-a*v + b*u), PosQ(a*b)): return True return False pattern1890 = Pattern(Integral(S(1)/(sqrt(u_)*sqrt(v_)), x_), cons1091, CustomConstraint(With1890)) def replacement1890(v, x, u): a = D(u, x) b = D(v, x) rubi.append(1890) return Simp(S(2)*atanh(sqrt(u)*Rt(a*b, S(2))/(a*sqrt(v)))/Rt(a*b, S(2)), x) rule1890 = ReplacementRule(pattern1890, replacement1890) def With1891(v, x, u): if isinstance(x, (int, Integer, float, Float)): return False a = D(u, x) b = D(v, x) if And(NonzeroQ(-a*v + b*u), NegQ(a*b)): return True return False pattern1891 = Pattern(Integral(S(1)/(sqrt(u_)*sqrt(v_)), x_), cons1091, CustomConstraint(With1891)) def replacement1891(v, x, u): a = D(u, x) b = D(v, x) rubi.append(1891) return Simp(S(2)*ArcTan(sqrt(u)*Rt(-a*b, S(2))/(a*sqrt(v)))/Rt(-a*b, S(2)), x) rule1891 = ReplacementRule(pattern1891, replacement1891) def With1892(v, u, m, n, x): if isinstance(x, (int, Integer, float, Float)): return False a = D(u, x) b = D(v, x) if NonzeroQ(-a*v + b*u): return True return False pattern1892 = Pattern(Integral(u_**m_*v_**n_, x_), cons21, cons4, cons1091, cons72, cons66, CustomConstraint(With1892)) def replacement1892(v, u, m, n, x): a = D(u, x) b = D(v, x) rubi.append(1892) return -Simp(u**(m + S(1))*v**(n + S(1))/((m + S(1))*(-a*v + b*u)), x) rule1892 = ReplacementRule(pattern1892, replacement1892) def With1893(v, u, m, n, x): if isinstance(x, (int, Integer, float, Float)): return False a = D(u, x) b = D(v, x) if NonzeroQ(-a*v + b*u): return True return False pattern1893 = Pattern(Integral(u_**m_*v_**WC('n', S(1)), x_), cons21, cons4, cons1091, cons66, cons1093, CustomConstraint(With1893)) def replacement1893(v, u, m, n, x): a = D(u, x) b = D(v, x) rubi.append(1893) return -Dist(b*n/(a*(m + S(1))), Int(u**(m + S(1))*v**(n + S(-1)), x), x) + Simp(u**(m + S(1))*v**n/(a*(m + S(1))), x) rule1893 = ReplacementRule(pattern1893, replacement1893) def With1894(v, u, m, n, x): if isinstance(x, (int, Integer, float, Float)): return False a = D(u, x) b = D(v, x) if NonzeroQ(-a*v + b*u): return True return False pattern1894 = Pattern(Integral(u_**m_*v_**WC('n', S(1)), x_), cons1091, cons214, cons87, cons88, cons683, cons100, cons101, CustomConstraint(With1894)) def replacement1894(v, u, m, n, x): a = D(u, x) b = D(v, x) rubi.append(1894) return -Dist(n*(-a*v + b*u)/(a*(m + n + S(1))), Int(u**m*v**(n + S(-1)), x), x) + Simp(u**(m + S(1))*v**n/(a*(m + n + S(1))), x) rule1894 = ReplacementRule(pattern1894, replacement1894) def With1895(v, u, m, n, x): if isinstance(x, (int, Integer, float, Float)): return False a = D(u, x) b = D(v, x) if NonzeroQ(-a*v + b*u): return True return False pattern1895 = Pattern(Integral(u_**m_*v_**n_, x_), cons1091, cons683, cons1094, cons1095, CustomConstraint(With1895)) def replacement1895(v, u, m, n, x): a = D(u, x) b = D(v, x) rubi.append(1895) return -Dist(n*(-a*v + b*u)/(a*(m + n + S(1))), Int(u**m*v**(n + S(-1)), x), x) + Simp(u**(m + S(1))*v**n/(a*(m + n + S(1))), x) rule1895 = ReplacementRule(pattern1895, replacement1895) def With1896(v, u, m, n, x): if isinstance(x, (int, Integer, float, Float)): return False a = D(u, x) b = D(v, x) if NonzeroQ(-a*v + b*u): return True return False pattern1896 = Pattern(Integral(u_**m_*v_**n_, x_), cons1091, cons214, cons31, cons94, CustomConstraint(With1896)) def replacement1896(v, u, m, n, x): a = D(u, x) b = D(v, x) rubi.append(1896) return Dist(b*(m + n + S(2))/((m + S(1))*(-a*v + b*u)), Int(u**(m + S(1))*v**n, x), x) - Simp(u**(m + S(1))*v**(n + S(1))/((m + S(1))*(-a*v + b*u)), x) rule1896 = ReplacementRule(pattern1896, replacement1896) def With1897(v, u, m, n, x): if isinstance(x, (int, Integer, float, Float)): return False a = D(u, x) b = D(v, x) if NonzeroQ(-a*v + b*u): return True return False pattern1897 = Pattern(Integral(u_**m_*v_**n_, x_), cons1091, cons356, cons1096, CustomConstraint(With1897)) def replacement1897(v, u, m, n, x): a = D(u, x) b = D(v, x) rubi.append(1897) return Dist(b*(m + n + S(2))/((m + S(1))*(-a*v + b*u)), Int(u**(m + S(1))*v**n, x), x) - Simp(u**(m + S(1))*v**(n + S(1))/((m + S(1))*(-a*v + b*u)), x) rule1897 = ReplacementRule(pattern1897, replacement1897) def With1898(v, u, m, n, x): if isinstance(x, (int, Integer, float, Float)): return False a = D(u, x) b = D(v, x) if NonzeroQ(-a*v + b*u): return True return False pattern1898 = Pattern(Integral(u_**m_*v_**n_, x_), cons1091, cons18, cons23, CustomConstraint(With1898)) def replacement1898(v, u, m, n, x): a = D(u, x) b = D(v, x) rubi.append(1898) return Simp(u**m*v**(n + S(1))*(b*u/(-a*v + b*u))**(-m)*Hypergeometric2F1(-m, n + S(1), n + S(2), -a*v/(-a*v + b*u))/(b*(n + S(1))), x) rule1898 = ReplacementRule(pattern1898, replacement1898) def With1899(u, b, a, n, x): c = D(u, x) rubi.append(1899) return -Dist(c*n/b, Int(u**(n + S(-1))*(a + b*x)*log(a + b*x), x), x) - Int(u**n, x) + Simp(u**n*(a + b*x)*log(a + b*x)/b, x) pattern1899 = Pattern(Integral(u_**WC('n', S(1))*log(x_*WC('b', S(1)) + WC('a', S(0))), x_), cons2, cons3, cons1090, cons1097, cons87, cons88) rule1899 = ReplacementRule(pattern1899, With1899) def With1900(u, m, b, a, n, x): c = D(u, x) rubi.append(1900) return -Dist(c*n/(b*(m + S(1))), Int(u**(n + S(-1))*(a + b*x)**(m + S(1))*log(a + b*x), x), x) - Dist(S(1)/(m + S(1)), Int(u**n*(a + b*x)**m, x), x) + Simp(u**n*(a + b*x)**(m + S(1))*log(a + b*x)/(b*(m + S(1))), x) pattern1900 = Pattern(Integral(u_**WC('n', S(1))*(x_*WC('b', S(1)) + WC('a', S(0)))**WC('m', S(1))*log(x_*WC('b', S(1)) + WC('a', S(0))), x_), cons2, cons3, cons21, cons1090, cons1097, cons87, cons88, cons66) rule1900 = ReplacementRule(pattern1900, With1900) return [rule1882, rule1883, rule1884, rule1885, rule1886, rule1887, rule1888, rule1889, rule1890, rule1891, rule1892, rule1893, rule1894, rule1895, rule1896, rule1897, rule1898, rule1899, rule1900, ]
2219edf07e7cefe01595b56eda1f7440d85a9660e015acec1b0e6792619ab3b0
''' This code is automatically generated. Never edit it manually. For details of generating the code see `rubi_parsing_guide.md` in `parsetools`. ''' from sympy.external import import_module matchpy = import_module("matchpy") from sympy.utilities.decorator import doctest_depends_on if matchpy: from matchpy import Pattern, ReplacementRule, CustomConstraint, is_match from sympy.integrals.rubi.utility_function import ( Int, Sum, Set, With, Module, Scan, MapAnd, FalseQ, ZeroQ, NegativeQ, NonzeroQ, FreeQ, NFreeQ, List, Log, PositiveQ, PositiveIntegerQ, NegativeIntegerQ, IntegerQ, IntegersQ, ComplexNumberQ, PureComplexNumberQ, RealNumericQ, PositiveOrZeroQ, NegativeOrZeroQ, FractionOrNegativeQ, NegQ, Equal, Unequal, IntPart, FracPart, RationalQ, ProductQ, SumQ, NonsumQ, Subst, First, Rest, SqrtNumberQ, SqrtNumberSumQ, LinearQ, Sqrt, ArcCosh, Coefficient, Denominator, Hypergeometric2F1, Not, Simplify, FractionalPart, IntegerPart, AppellF1, EllipticPi, EllipticE, EllipticF, ArcTan, ArcCot, ArcCoth, ArcTanh, ArcSin, ArcSinh, ArcCos, ArcCsc, ArcSec, ArcCsch, ArcSech, Sinh, Tanh, Cosh, Sech, Csch, Coth, LessEqual, Less, Greater, GreaterEqual, FractionQ, IntLinearcQ, Expand, IndependentQ, PowerQ, IntegerPowerQ, PositiveIntegerPowerQ, FractionalPowerQ, AtomQ, ExpQ, LogQ, Head, MemberQ, TrigQ, SinQ, CosQ, TanQ, CotQ, SecQ, CscQ, Sin, Cos, Tan, Cot, Sec, Csc, HyperbolicQ, SinhQ, CoshQ, TanhQ, CothQ, SechQ, CschQ, InverseTrigQ, SinCosQ, SinhCoshQ, LeafCount, Numerator, NumberQ, NumericQ, Length, ListQ, Im, Re, InverseHyperbolicQ, InverseFunctionQ, TrigHyperbolicFreeQ, InverseFunctionFreeQ, RealQ, EqQ, FractionalPowerFreeQ, ComplexFreeQ, PolynomialQ, FactorSquareFree, PowerOfLinearQ, Exponent, QuadraticQ, LinearPairQ, BinomialParts, TrinomialParts, PolyQ, EvenQ, OddQ, PerfectSquareQ, NiceSqrtAuxQ, NiceSqrtQ, Together, PosAux, PosQ, CoefficientList, ReplaceAll, ExpandLinearProduct, GCD, ContentFactor, NumericFactor, NonnumericFactors, MakeAssocList, GensymSubst, KernelSubst, ExpandExpression, Apart, SmartApart, MatchQ, PolynomialQuotientRemainder, FreeFactors, NonfreeFactors, RemoveContentAux, RemoveContent, FreeTerms, NonfreeTerms, ExpandAlgebraicFunction, CollectReciprocals, ExpandCleanup, AlgebraicFunctionQ, Coeff, LeadTerm, RemainingTerms, LeadFactor, RemainingFactors, LeadBase, LeadDegree, Numer, Denom, hypergeom, Expon, MergeMonomials, PolynomialDivide, BinomialQ, TrinomialQ, GeneralizedBinomialQ, GeneralizedTrinomialQ, FactorSquareFreeList, PerfectPowerTest, SquareFreeFactorTest, RationalFunctionQ, RationalFunctionFactors, NonrationalFunctionFactors, Reverse, RationalFunctionExponents, RationalFunctionExpand, ExpandIntegrand, SimplerQ, SimplerSqrtQ, SumSimplerQ, BinomialDegree, TrinomialDegree, CancelCommonFactors, SimplerIntegrandQ, GeneralizedBinomialDegree, GeneralizedBinomialParts, GeneralizedTrinomialDegree, GeneralizedTrinomialParts, MonomialQ, MonomialSumQ, MinimumMonomialExponent, MonomialExponent, LinearMatchQ, PowerOfLinearMatchQ, QuadraticMatchQ, CubicMatchQ, BinomialMatchQ, TrinomialMatchQ, GeneralizedBinomialMatchQ, GeneralizedTrinomialMatchQ, QuotientOfLinearsMatchQ, PolynomialTermQ, PolynomialTerms, NonpolynomialTerms, PseudoBinomialParts, NormalizePseudoBinomial, PseudoBinomialPairQ, PseudoBinomialQ, PolynomialGCD, PolyGCD, AlgebraicFunctionFactors, NonalgebraicFunctionFactors, QuotientOfLinearsP, QuotientOfLinearsParts, QuotientOfLinearsQ, Flatten, Sort, AbsurdNumberQ, AbsurdNumberFactors, NonabsurdNumberFactors, SumSimplerAuxQ, Prepend, Drop, CombineExponents, FactorInteger, FactorAbsurdNumber, SubstForInverseFunction, SubstForFractionalPower, SubstForFractionalPowerOfQuotientOfLinears, FractionalPowerOfQuotientOfLinears, SubstForFractionalPowerQ, SubstForFractionalPowerAuxQ, FractionalPowerOfSquareQ, FractionalPowerSubexpressionQ, Apply, FactorNumericGcd, MergeableFactorQ, MergeFactor, MergeFactors, TrigSimplifyQ, TrigSimplify, TrigSimplifyRecur, Order, FactorOrder, Smallest, OrderedQ, MinimumDegree, PositiveFactors, Sign, NonpositiveFactors, PolynomialInAuxQ, PolynomialInQ, ExponentInAux, ExponentIn, PolynomialInSubstAux, PolynomialInSubst, Distrib, DistributeDegree, FunctionOfPower, DivideDegreesOfFactors, MonomialFactor, FullSimplify, FunctionOfLinearSubst, FunctionOfLinear, NormalizeIntegrand, NormalizeIntegrandAux, NormalizeIntegrandFactor, NormalizeIntegrandFactorBase, NormalizeTogether, NormalizeLeadTermSigns, AbsorbMinusSign, NormalizeSumFactors, SignOfFactor, NormalizePowerOfLinear, SimplifyIntegrand, SimplifyTerm, TogetherSimplify, SmartSimplify, SubstForExpn, ExpandToSum, UnifySum, UnifyTerms, UnifyTerm, CalculusQ, FunctionOfInverseLinear, PureFunctionOfSinhQ, PureFunctionOfTanhQ, PureFunctionOfCoshQ, IntegerQuotientQ, OddQuotientQ, EvenQuotientQ, FindTrigFactor, FunctionOfSinhQ, FunctionOfCoshQ, OddHyperbolicPowerQ, FunctionOfTanhQ, FunctionOfTanhWeight, FunctionOfHyperbolicQ, SmartNumerator, SmartDenominator, SubstForAux, ActivateTrig, ExpandTrig, TrigExpand, SubstForTrig, SubstForHyperbolic, InertTrigFreeQ, LCM, SubstForFractionalPowerOfLinear, FractionalPowerOfLinear, InverseFunctionOfLinear, InertTrigQ, InertReciprocalQ, DeactivateTrig, FixInertTrigFunction, DeactivateTrigAux, PowerOfInertTrigSumQ, PiecewiseLinearQ, KnownTrigIntegrandQ, KnownSineIntegrandQ, KnownTangentIntegrandQ, KnownCotangentIntegrandQ, KnownSecantIntegrandQ, TryPureTanSubst, TryTanhSubst, TryPureTanhSubst, AbsurdNumberGCD, AbsurdNumberGCDList, ExpandTrigExpand, ExpandTrigReduce, ExpandTrigReduceAux, NormalizeTrig, TrigToExp, ExpandTrigToExp, TrigReduce, FunctionOfTrig, AlgebraicTrigFunctionQ, FunctionOfHyperbolic, FunctionOfQ, FunctionOfExpnQ, PureFunctionOfSinQ, PureFunctionOfCosQ, PureFunctionOfTanQ, PureFunctionOfCotQ, FunctionOfCosQ, FunctionOfSinQ, OddTrigPowerQ, FunctionOfTanQ, FunctionOfTanWeight, FunctionOfTrigQ, FunctionOfDensePolynomialsQ, FunctionOfLog, PowerVariableExpn, PowerVariableDegree, PowerVariableSubst, EulerIntegrandQ, FunctionOfSquareRootOfQuadratic, SquareRootOfQuadraticSubst, Divides, EasyDQ, ProductOfLinearPowersQ, Rt, NthRoot, AtomBaseQ, SumBaseQ, NegSumBaseQ, AllNegTermQ, SomeNegTermQ, TrigSquareQ, RtAux, TrigSquare, IntSum, IntTerm, Map2, ConstantFactor, SameQ, ReplacePart, CommonFactors, MostMainFactorPosition, FunctionOfExponentialQ, FunctionOfExponential, FunctionOfExponentialFunction, FunctionOfExponentialFunctionAux, FunctionOfExponentialTest, FunctionOfExponentialTestAux, stdev, rubi_test, If, IntQuadraticQ, IntBinomialQ, RectifyTangent, RectifyCotangent, Inequality, Condition, Simp, SimpHelp, SplitProduct, SplitSum, SubstFor, SubstForAux, FresnelS, FresnelC, Erfc, Erfi, Gamma, FunctionOfTrigOfLinearQ, ElementaryFunctionQ, Complex, UnsameQ, _SimpFixFactor, SimpFixFactor, _FixSimplify, FixSimplify, _SimplifyAntiderivativeSum, SimplifyAntiderivativeSum, _SimplifyAntiderivative, SimplifyAntiderivative, _TrigSimplifyAux, TrigSimplifyAux, Cancel, Part, PolyLog, D, Dist, Sum_doit, PolynomialQuotient, Floor, PolynomialRemainder, Factor, PolyLog, CosIntegral, SinIntegral, LogIntegral, SinhIntegral, CoshIntegral, Rule, Erf, PolyGamma, ExpIntegralEi, ExpIntegralE, LogGamma , UtilityOperator, Factorial, Zeta, ProductLog, DerivativeDivides, HypergeometricPFQ, IntHide, OneQ, Null, rubi_exp as exp, rubi_log as log, Discriminant, Negative, Quotient ) from sympy import (Integral, S, sqrt, And, Or, Integer, Float, Mod, I, Abs, simplify, Mul, Add, Pow, sign, EulerGamma) from sympy.integrals.rubi.symbol import WC from sympy.core.symbol import symbols, Symbol from sympy.functions import (sin, cos, tan, cot, csc, sec, sqrt, erf) from sympy.functions.elementary.hyperbolic import (acosh, asinh, atanh, acoth, acsch, asech, cosh, sinh, tanh, coth, sech, csch) from sympy.functions.elementary.trigonometric import (atan, acsc, asin, acot, acos, asec, atan2) from sympy import pi as Pi A_, B_, C_, F_, G_, H_, a_, b_, c_, d_, e_, f_, g_, h_, i_, j_, k_, l_, m_, n_, p_, q_, r_, t_, u_, v_, s_, w_, x_, y_, z_ = [WC(i) for i in 'ABCFGHabcdefghijklmnpqrtuvswxyz'] a1_, a2_, b1_, b2_, c1_, c2_, d1_, d2_, n1_, n2_, e1_, e2_, f1_, f2_, g1_, g2_, n1_, n2_, n3_, Pq_, Pm_, Px_, Qm_, Qr_, Qx_, jn_, mn_, non2_, RFx_, RGx_ = [WC(i) for i in ['a1', 'a2', 'b1', 'b2', 'c1', 'c2', 'd1', 'd2', 'n1', 'n2', 'e1', 'e2', 'f1', 'f2', 'g1', 'g2', 'n1', 'n2', 'n3', 'Pq', 'Pm', 'Px', 'Qm', 'Qr', 'Qx', 'jn', 'mn', 'non2', 'RFx', 'RGx']] i, ii , Pqq, Q, R, r, C, k, u = symbols('i ii Pqq Q R r C k u') _UseGamma = False ShowSteps = False StepCounter = None def miscellaneous_integration(rubi): from sympy.integrals.rubi.constraints import cons147, cons2002, cons2, cons3, cons7, cons4, cons5, cons386, cons27, cons50, cons2003, cons2004, cons2005, cons2006, cons48, cons125, cons208, cons34, cons35, cons36, cons1099, cons2007, cons66, cons21, cons84, cons1037, cons1036, cons38, cons2008, cons10, cons2009, cons2010, cons2011, cons209, cons1831, cons1244, cons2012, cons46, cons2013, cons2014, cons2015, cons2016, cons52, cons2017, cons800, cons2018, cons17, cons2019, cons586, cons2020, cons2021, cons2022, cons2023, cons2024, cons2025, cons2026, cons2027, cons2028, cons667, cons196, cons2029, cons840, cons2030, cons18, cons2031, cons148, cons45, cons2032, cons1854, cons1247, cons261, cons2033, cons367, cons2034, cons67, cons1479, cons744, cons1482, cons165, cons2035, cons2036, cons1676, cons1255, cons2037, cons347 pattern6931 = Pattern(Integral(u_*((x_*WC('b', S(1)) + WC('a', S(0)))**n_*WC('c', S(1)))**p_, x_), cons2, cons3, cons7, cons4, cons5, cons147, cons2002) def replacement6931(p, u, b, c, a, n, x): rubi.append(6931) return Dist(c**IntPart(p)*(c*(a + b*x)**n)**FracPart(p)*(a + b*x)**(-n*FracPart(p)), Int(u*(a + b*x)**(n*p), x), x) rule6931 = ReplacementRule(pattern6931, replacement6931) pattern6932 = Pattern(Integral(((d_*(x_*WC('b', S(1)) + WC('a', S(0))))**p_*WC('c', S(1)))**q_*WC('u', S(1)), x_), cons2, cons3, cons7, cons27, cons5, cons50, cons147, cons386) def replacement6932(p, u, b, d, c, a, x, q): rubi.append(6932) return Dist((c*(d*(a + b*x))**p)**q*(a + b*x)**(-p*q), Int(u*(a + b*x)**(p*q), x), x) rule6932 = ReplacementRule(pattern6932, replacement6932) pattern6933 = Pattern(Integral((((x_*WC('b', S(1)) + WC('a', S(0)))**n_*WC('d', S(1)))**p_*WC('c', S(1)))**q_*WC('u', S(1)), x_), cons2, cons3, cons7, cons27, cons4, cons5, cons50, cons147, cons386) def replacement6933(p, u, b, d, c, a, n, x, q): rubi.append(6933) return Dist((c*(d*(a + b*x)**n)**p)**q*(a + b*x)**(-n*p*q), Int(u*(a + b*x)**(n*p*q), x), x) rule6933 = ReplacementRule(pattern6933, replacement6933) pattern6934 = Pattern(Integral((F_*sqrt(x_*WC('e', S(1)) + WC('d', S(0)))*WC('b', S(1))*WC('c', S(1))/sqrt(x_*WC('g', S(1)) + WC('f', S(0))) + WC('a', S(0)))**WC('n', S(1))/(x_**S(2)*WC('C', S(1)) + x_*WC('B', S(1)) + WC('A', S(0))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons34, cons35, cons36, cons1099, cons2003, cons2004, cons2005, cons2006) def replacement6934(B, C, e, f, b, g, d, a, c, n, x, F, A): rubi.append(6934) return Dist(g/C, Subst(Int((a + b*F(c*x))**n/x, x), x, sqrt(d + e*x)/sqrt(f + g*x)), x) rule6934 = ReplacementRule(pattern6934, replacement6934) pattern6935 = Pattern(Integral((F_*sqrt(x_*WC('e', S(1)) + S(1))*WC('b', S(1))*WC('c', S(1))/sqrt(x_*WC('g', S(1)) + S(1)) + WC('a', S(0)))**WC('n', S(1))/(x_**S(2)*WC('C', S(1)) + WC('A', S(0))), x_), cons2, cons3, cons7, cons48, cons208, cons34, cons36, cons1099, cons2003, cons2007) def replacement6935(C, e, g, b, c, a, n, x, F, A): rubi.append(6935) return Dist(g/C, Subst(Int((a + b*F(c*x))**n/x, x), x, sqrt(e*x + S(1))/sqrt(g*x + S(1))), x) rule6935 = ReplacementRule(pattern6935, replacement6935) pattern6936 = Pattern(Integral((F_**(sqrt(x_*WC('e', S(1)) + WC('d', S(0)))*WC('c', S(1))/sqrt(x_*WC('g', S(1)) + WC('f', S(0))))*WC('b', S(1)) + WC('a', S(0)))**WC('n', S(1))/(x_**S(2)*WC('C', S(1)) + x_*WC('B', S(1)) + WC('A', S(0))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons34, cons35, cons36, cons1099, cons2003, cons2004, cons2005, cons2006) def replacement6936(B, C, f, b, g, d, c, a, n, A, x, F, e): rubi.append(6936) return Dist(g/C, Subst(Int((F**(c*x)*b + a)**n/x, x), x, sqrt(d + e*x)/sqrt(f + g*x)), x) rule6936 = ReplacementRule(pattern6936, replacement6936) pattern6937 = Pattern(Integral((F_**(sqrt(x_*WC('e', S(1)) + S(1))*WC('c', S(1))/sqrt(x_*WC('g', S(1)) + S(1)))*WC('b', S(1)) + WC('a', S(0)))**WC('n', S(1))/(x_**S(2)*WC('C', S(1)) + WC('A', S(0))), x_), cons2, cons3, cons7, cons48, cons208, cons34, cons36, cons1099, cons2003, cons2007) def replacement6937(C, g, b, c, a, n, A, x, F, e): rubi.append(6937) return Dist(g/C, Subst(Int((F**(c*x)*b + a)**n/x, x), x, sqrt(e*x + S(1))/sqrt(g*x + S(1))), x) rule6937 = ReplacementRule(pattern6937, replacement6937) def With6938(y, x, u): if isinstance(x, (int, Integer, float, Float)): return False try: q = DerivativeDivides(y, u, x) res = Not(FalseQ(q)) except (TypeError, AttributeError): return False if res: return True return False pattern6938 = Pattern(Integral(u_/y_, x_), CustomConstraint(With6938)) def replacement6938(y, x, u): q = DerivativeDivides(y, u, x) rubi.append(6938) return Simp(q*log(RemoveContent(y, x)), x) rule6938 = ReplacementRule(pattern6938, replacement6938) def With6939(y, w, u, x): if isinstance(x, (int, Integer, float, Float)): return False try: q = DerivativeDivides(w*y, u, x) res = Not(FalseQ(q)) except (TypeError, AttributeError): return False if res: return True return False pattern6939 = Pattern(Integral(u_/(w_*y_), x_), CustomConstraint(With6939)) def replacement6939(y, w, u, x): q = DerivativeDivides(w*y, u, x) rubi.append(6939) return Simp(q*log(RemoveContent(w*y, x)), x) rule6939 = ReplacementRule(pattern6939, replacement6939) def With6940(y, m, u, x): if isinstance(x, (int, Integer, float, Float)): return False try: q = DerivativeDivides(y, u, x) res = Not(FalseQ(q)) except (TypeError, AttributeError): return False if res: return True return False pattern6940 = Pattern(Integral(u_*y_**WC('m', S(1)), x_), cons21, cons66, CustomConstraint(With6940)) def replacement6940(y, m, u, x): q = DerivativeDivides(y, u, x) rubi.append(6940) return Simp(q*y**(m + S(1))/(m + S(1)), x) rule6940 = ReplacementRule(pattern6940, replacement6940) def With6941(z, y, u, m, n, x): if isinstance(x, (int, Integer, float, Float)): return False try: q = DerivativeDivides(y*z, u*z**(-m + n), x) res = Not(FalseQ(q)) except (TypeError, AttributeError): return False if res: return True return False pattern6941 = Pattern(Integral(u_*y_**WC('m', S(1))*z_**WC('n', S(1)), x_), cons21, cons4, cons66, CustomConstraint(With6941)) def replacement6941(z, y, u, m, n, x): q = DerivativeDivides(y*z, u*z**(-m + n), x) rubi.append(6941) return Simp(q*y**(m + S(1))*z**(m + S(1))/(m + S(1)), x) rule6941 = ReplacementRule(pattern6941, replacement6941) def With6942(x, u): if isinstance(x, (int, Integer, float, Float)): return False v = SimplifyIntegrand(u, x) if SimplerIntegrandQ(v, u, x): return True return False pattern6942 = Pattern(Integral(u_, x_), CustomConstraint(With6942)) def replacement6942(x, u): v = SimplifyIntegrand(u, x) rubi.append(6942) return Int(v, x) rule6942 = ReplacementRule(pattern6942, replacement6942) pattern6943 = Pattern(Integral((sqrt(x_**WC('n', S(1))*WC('b', S(1)) + WC('a', S(0)))*WC('e', S(1)) + sqrt(x_**WC('n', S(1))*WC('d', S(1)) + WC('c', S(0)))*WC('f', S(1)))**m_*WC('u', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons4, cons84, cons1037) def replacement6943(u, m, f, b, d, a, n, c, x, e): rubi.append(6943) return Dist((a*e**S(2) - c*f**S(2))**m, Int(ExpandIntegrand(u*(e*sqrt(a + b*x**n) - f*sqrt(c + d*x**n))**(-m), x), x), x) rule6943 = ReplacementRule(pattern6943, replacement6943) pattern6944 = Pattern(Integral((sqrt(x_**WC('n', S(1))*WC('b', S(1)) + WC('a', S(0)))*WC('e', S(1)) + sqrt(x_**WC('n', S(1))*WC('d', S(1)) + WC('c', S(0)))*WC('f', S(1)))**m_*WC('u', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons4, cons84, cons1036) def replacement6944(u, m, f, b, d, a, n, c, x, e): rubi.append(6944) return Dist((b*e**S(2) - d*f**S(2))**m, Int(ExpandIntegrand(u*x**(m*n)*(e*sqrt(a + b*x**n) - f*sqrt(c + d*x**n))**(-m), x), x), x) rule6944 = ReplacementRule(pattern6944, replacement6944) pattern6945 = Pattern(Integral(u_**WC('m', S(1))*w_*(u_**n_*WC('a', S(1)) + v_)**WC('p', S(1)), x_), cons2, cons21, cons4, cons38, cons2008, cons10) def replacement6945(v, w, p, u, m, a, n, x): rubi.append(6945) return Int(u**(m + n*p)*w*(a + u**(-n)*v)**p, x) rule6945 = ReplacementRule(pattern6945, replacement6945) def With6946(v, u, y, m, b, d, c, n, a, x): if isinstance(x, (int, Integer, float, Float)): return False try: q = DerivativeDivides(y, u, x) res = Not(FalseQ(q)) except (TypeError, AttributeError): return False if res: return True return False pattern6946 = Pattern(Integral(u_*(v_*WC('d', S(1)) + WC('c', S(0)))**WC('n', S(1))*(y_*WC('b', S(1)) + WC('a', S(0)))**WC('m', S(1)), x_), cons2, cons3, cons7, cons27, cons21, cons4, cons2009, CustomConstraint(With6946)) def replacement6946(v, u, y, m, b, d, c, n, a, x): q = DerivativeDivides(y, u, x) rubi.append(6946) return Dist(q, Subst(Int((a + b*x)**m*(c + d*x)**n, x), x, y), x) rule6946 = ReplacementRule(pattern6946, replacement6946) def With6947(v, w, p, u, y, m, f, b, d, c, n, a, x, e): if isinstance(x, (int, Integer, float, Float)): return False try: q = DerivativeDivides(y, u, x) res = Not(FalseQ(q)) except (TypeError, AttributeError): return False if res: return True return False pattern6947 = Pattern(Integral(u_*(v_*WC('d', S(1)) + WC('c', S(0)))**WC('n', S(1))*(w_*WC('f', S(1)) + WC('e', S(0)))**WC('p', S(1))*(y_*WC('b', S(1)) + WC('a', S(0)))**WC('m', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons4, cons5, cons2009, cons2010, CustomConstraint(With6947)) def replacement6947(v, w, p, u, y, m, f, b, d, c, n, a, x, e): q = DerivativeDivides(y, u, x) rubi.append(6947) return Dist(q, Subst(Int((a + b*x)**m*(c + d*x)**n*(e + f*x)**p, x), x, y), x) rule6947 = ReplacementRule(pattern6947, replacement6947) def With6948(v, z, w, p, u, y, m, f, b, g, d, c, n, a, x, h, q, e): if isinstance(x, (int, Integer, float, Float)): return False try: r = DerivativeDivides(y, u, x) res = Not(FalseQ(r)) except (TypeError, AttributeError): return False if res: return True return False pattern6948 = Pattern(Integral(u_*(v_*WC('d', S(1)) + WC('c', S(0)))**WC('n', S(1))*(w_*WC('f', S(1)) + WC('e', S(0)))**WC('p', S(1))*(y_*WC('b', S(1)) + WC('a', S(0)))**WC('m', S(1))*(z_*WC('h', S(1)) + WC('g', S(0)))**WC('q', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons209, cons21, cons4, cons5, cons50, cons2009, cons2010, cons2011, CustomConstraint(With6948)) def replacement6948(v, z, w, p, u, y, m, f, b, g, d, c, n, a, x, h, q, e): r = DerivativeDivides(y, u, x) rubi.append(6948) return Dist(r, Subst(Int((a + b*x)**m*(c + d*x)**n*(e + f*x)**p*(g + h*x)**q, x), x, y), x) rule6948 = ReplacementRule(pattern6948, replacement6948) def With6949(y, u, b, a, n, x): if isinstance(x, (int, Integer, float, Float)): return False try: q = DerivativeDivides(y, u, x) res = Not(FalseQ(q)) except (TypeError, AttributeError): return False if res: return True return False pattern6949 = Pattern(Integral((a_ + y_**n_*WC('b', S(1)))*WC('u', S(1)), x_), cons2, cons3, cons4, cons1831, CustomConstraint(With6949)) def replacement6949(y, u, b, a, n, x): q = DerivativeDivides(y, u, x) rubi.append(6949) return Dist(a, Int(u, x), x) + Dist(b*q, Subst(Int(x**n, x), x, y), x) rule6949 = ReplacementRule(pattern6949, replacement6949) def With6950(p, y, u, b, a, n, x): if isinstance(x, (int, Integer, float, Float)): return False try: q = DerivativeDivides(y, u, x) res = Not(FalseQ(q)) except (TypeError, AttributeError): return False if res: return True return False pattern6950 = Pattern(Integral((y_**n_*WC('b', S(1)) + WC('a', S(0)))**p_*WC('u', S(1)), x_), cons2, cons3, cons4, cons5, cons1244, CustomConstraint(With6950)) def replacement6950(p, y, u, b, a, n, x): q = DerivativeDivides(y, u, x) rubi.append(6950) return Dist(q, Subst(Int((a + b*x**n)**p, x), x, y), x) rule6950 = ReplacementRule(pattern6950, replacement6950) def With6951(v, p, u, y, m, b, a, n, x): if isinstance(x, (int, Integer, float, Float)): return False try: q = Symbol('q') r = Symbol('r') r = Divides(y**m, v**m, x) q = DerivativeDivides(y, u, x) res = And(Not(FalseQ(Set(r, Divides(y**m, v**m, x)))), Not(FalseQ(Set(q, DerivativeDivides(y, u, x))))) except (TypeError, AttributeError): return False if res: return True return False pattern6951 = Pattern(Integral(v_**WC('m', S(1))*(y_**n_*WC('b', S(1)) + WC('a', S(0)))**WC('p', S(1))*WC('u', S(1)), x_), cons2, cons3, cons21, cons4, cons5, cons2012, CustomConstraint(With6951)) def replacement6951(v, p, u, y, m, b, a, n, x): q = Symbol('q') r = Symbol('r') r = Divides(y**m, v**m, x) q = DerivativeDivides(y, u, x) rubi.append(6951) return Dist(q*r, Subst(Int(x**m*(a + b*x**n)**p, x), x, y), x) rule6951 = ReplacementRule(pattern6951, replacement6951) def With6952(v, p, u, y, b, n2, a, c, n, x): if isinstance(x, (int, Integer, float, Float)): return False try: q = DerivativeDivides(y, u, x) res = Not(FalseQ(q)) except (TypeError, AttributeError): return False if res: return True return False pattern6952 = Pattern(Integral((v_**WC('n2', S(1))*WC('c', S(1)) + y_**n_*WC('b', S(1)) + WC('a', S(0)))**p_*WC('u', S(1)), x_), cons2, cons3, cons7, cons4, cons5, cons46, cons2009, CustomConstraint(With6952)) def replacement6952(v, p, u, y, b, n2, a, c, n, x): q = DerivativeDivides(y, u, x) rubi.append(6952) return Dist(q, Subst(Int((a + b*x**n + c*x**(S(2)*n))**p, x), x, y), x) rule6952 = ReplacementRule(pattern6952, replacement6952) def With6953(B, v, w, p, u, y, b, n2, c, a, n, x, A): if isinstance(x, (int, Integer, float, Float)): return False try: q = DerivativeDivides(y, u, x) res = Not(FalseQ(q)) except (TypeError, AttributeError): return False if res: return True return False pattern6953 = Pattern(Integral((A_ + y_**n_*WC('B', S(1)))*(v_**n_*WC('b', S(1)) + w_**WC('n2', S(1))*WC('c', S(1)) + WC('a', S(0)))**WC('p', S(1))*WC('u', S(1)), x_), cons2, cons3, cons7, cons34, cons35, cons4, cons5, cons46, cons2009, cons2010, CustomConstraint(With6953)) def replacement6953(B, v, w, p, u, y, b, n2, c, a, n, x, A): q = DerivativeDivides(y, u, x) rubi.append(6953) return Dist(q, Subst(Int((A + B*x**n)*(a + b*x**n + c*x**(S(2)*n))**p, x), x, y), x) rule6953 = ReplacementRule(pattern6953, replacement6953) def With6954(B, w, p, u, y, n2, a, c, n, x, A): if isinstance(x, (int, Integer, float, Float)): return False try: q = DerivativeDivides(y, u, x) res = Not(FalseQ(q)) except (TypeError, AttributeError): return False if res: return True return False pattern6954 = Pattern(Integral((A_ + y_**n_*WC('B', S(1)))*(w_**WC('n2', S(1))*WC('c', S(1)) + WC('a', S(0)))**WC('p', S(1))*WC('u', S(1)), x_), cons2, cons7, cons34, cons35, cons4, cons5, cons46, cons2010, CustomConstraint(With6954)) def replacement6954(B, w, p, u, y, n2, a, c, n, x, A): q = DerivativeDivides(y, u, x) rubi.append(6954) return Dist(q, Subst(Int((A + B*x**n)*(a + c*x**(S(2)*n))**p, x), x, y), x) rule6954 = ReplacementRule(pattern6954, replacement6954) def With6955(v, w, p, u, y, m, b, n2, c, a, n, x): if isinstance(x, (int, Integer, float, Float)): return False try: q = Symbol('q') r = Symbol('r') r = Divides(y**m, v**m, x) q = DerivativeDivides(y, u, x) res = And(Not(FalseQ(Set(r, Divides(y**m, v**m, x)))), Not(FalseQ(Set(q, DerivativeDivides(y, u, x))))) except (TypeError, AttributeError): return False if res: return True return False pattern6955 = Pattern(Integral(v_**WC('m', S(1))*(w_**WC('n2', S(1))*WC('c', S(1)) + y_**n_*WC('b', S(1)) + WC('a', S(0)))**WC('p', S(1))*WC('u', S(1)), x_), cons2, cons3, cons7, cons21, cons4, cons5, cons46, cons2010, CustomConstraint(With6955)) def replacement6955(v, w, p, u, y, m, b, n2, c, a, n, x): q = Symbol('q') r = Symbol('r') r = Divides(y**m, v**m, x) q = DerivativeDivides(y, u, x) rubi.append(6955) return Dist(q*r, Subst(Int(x**m*(a + b*x**n + c*x**(S(2)*n))**p, x), x, y), x) rule6955 = ReplacementRule(pattern6955, replacement6955) def With6956(B, v, w, p, z, u, y, m, b, n2, c, a, n, x, A): if isinstance(x, (int, Integer, float, Float)): return False try: q = Symbol('q') r = Symbol('r') r = Divides(y**m, z**m, x) q = DerivativeDivides(y, u, x) res = And(Not(FalseQ(Set(r, Divides(y**m, z**m, x)))), Not(FalseQ(Set(q, DerivativeDivides(y, u, x))))) except (TypeError, AttributeError): return False if res: return True return False pattern6956 = Pattern(Integral(z_**WC('m', S(1))*(A_ + y_**n_*WC('B', S(1)))*(v_**n_*WC('b', S(1)) + w_**WC('n2', S(1))*WC('c', S(1)) + WC('a', S(0)))**WC('p', S(1))*WC('u', S(1)), x_), cons2, cons3, cons7, cons34, cons35, cons21, cons4, cons5, cons46, cons2009, cons2010, CustomConstraint(With6956)) def replacement6956(B, v, w, p, z, u, y, m, b, n2, c, a, n, x, A): q = Symbol('q') r = Symbol('r') r = Divides(y**m, z**m, x) q = DerivativeDivides(y, u, x) rubi.append(6956) return Dist(q*r, Subst(Int(x**m*(A + B*x**n)*(a + b*x**n + c*x**(S(2)*n))**p, x), x, y), x) rule6956 = ReplacementRule(pattern6956, replacement6956) def With6957(B, z, w, p, u, y, m, n2, a, c, n, x, A): if isinstance(x, (int, Integer, float, Float)): return False try: q = Symbol('q') r = Symbol('r') r = Divides(y**m, z**m, x) q = DerivativeDivides(y, u, x) res = And(Not(FalseQ(Set(r, Divides(y**m, z**m, x)))), Not(FalseQ(Set(q, DerivativeDivides(y, u, x))))) except (TypeError, AttributeError): return False if res: return True return False pattern6957 = Pattern(Integral(z_**WC('m', S(1))*(A_ + y_**n_*WC('B', S(1)))*(w_**WC('n2', S(1))*WC('c', S(1)) + WC('a', S(0)))**WC('p', S(1))*WC('u', S(1)), x_), cons2, cons7, cons34, cons35, cons21, cons4, cons5, cons46, cons2010, CustomConstraint(With6957)) def replacement6957(B, z, w, p, u, y, m, n2, a, c, n, x, A): q = Symbol('q') r = Symbol('r') r = Divides(y**m, z**m, x) q = DerivativeDivides(y, u, x) rubi.append(6957) return Dist(q*r, Subst(Int(x**m*(A + B*x**n)*(a + c*x**(S(2)*n))**p, x), x, y), x) rule6957 = ReplacementRule(pattern6957, replacement6957) def With6958(v, p, u, y, m, b, d, c, a, n, x): if isinstance(x, (int, Integer, float, Float)): return False try: q = DerivativeDivides(y, u, x) res = Not(FalseQ(q)) except (TypeError, AttributeError): return False if res: return True return False pattern6958 = Pattern(Integral((v_**n_*WC('d', S(1)) + WC('c', S(0)))**WC('p', S(1))*(y_**n_*WC('b', S(1)) + WC('a', S(0)))**WC('m', S(1))*WC('u', S(1)), x_), cons2, cons3, cons7, cons27, cons21, cons4, cons5, cons2009, CustomConstraint(With6958)) def replacement6958(v, p, u, y, m, b, d, c, a, n, x): q = DerivativeDivides(y, u, x) rubi.append(6958) return Dist(q, Subst(Int((a + b*x**n)**m*(c + d*x**n)**p, x), x, y), x) rule6958 = ReplacementRule(pattern6958, replacement6958) def With6959(v, w, p, u, y, m, f, b, d, c, a, n, x, q, e): if isinstance(x, (int, Integer, float, Float)): return False try: r = DerivativeDivides(y, u, x) res = Not(FalseQ(r)) except (TypeError, AttributeError): return False if res: return True return False pattern6959 = Pattern(Integral((v_**n_*WC('d', S(1)) + WC('c', S(0)))**WC('p', S(1))*(w_**n_*WC('f', S(1)) + WC('e', S(0)))**WC('q', S(1))*(y_**n_*WC('b', S(1)) + WC('a', S(0)))**WC('m', S(1))*WC('u', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons4, cons5, cons50, cons2009, cons2010, CustomConstraint(With6959)) def replacement6959(v, w, p, u, y, m, f, b, d, c, a, n, x, q, e): r = DerivativeDivides(y, u, x) rubi.append(6959) return Dist(r, Subst(Int((a + b*x**n)**m*(c + d*x**n)**p*(e + f*x**n)**q, x), x, y), x) rule6959 = ReplacementRule(pattern6959, replacement6959) def With6960(v, x, u, F): if isinstance(x, (int, Integer, float, Float)): return False try: q = DerivativeDivides(v, u, x) res = Not(FalseQ(q)) except (TypeError, AttributeError): return False if res: return True return False pattern6960 = Pattern(Integral(F_**v_*u_, x_), cons1099, cons1099, CustomConstraint(With6960)) def replacement6960(v, x, u, F): q = DerivativeDivides(v, u, x) rubi.append(6960) return Simp(F**v*q/log(F), x) rule6960 = ReplacementRule(pattern6960, replacement6960) def With6961(v, w, u, m, x, F): if isinstance(x, (int, Integer, float, Float)): return False try: q = DerivativeDivides(v, u, x) res = Not(FalseQ(q)) except (TypeError, AttributeError): return False if res: return True return False pattern6961 = Pattern(Integral(F_**v_*u_*w_**WC('m', S(1)), x_), cons1099, cons21, cons2013, CustomConstraint(With6961)) def replacement6961(v, w, u, m, x, F): q = DerivativeDivides(v, u, x) rubi.append(6961) return Dist(q, Subst(Int(F**x*x**m, x), x, v), x) rule6961 = ReplacementRule(pattern6961, replacement6961) def With6962(v, w, p, u, m, b, a, x): if isinstance(x, (int, Integer, float, Float)): return False c = u/(v*D(w, x) + w*D(v, x)) if FreeQ(c, x): return True return False pattern6962 = Pattern(Integral(u_*(a_ + v_**WC('p', S(1))*w_**WC('p', S(1))*WC('b', S(1)))**WC('m', S(1)), x_), cons2, cons3, cons21, cons5, cons38, CustomConstraint(With6962)) def replacement6962(v, w, p, u, m, b, a, x): c = u/(v*D(w, x) + w*D(v, x)) rubi.append(6962) return Dist(c, Subst(Int((a + b*x**p)**m, x), x, v*w), x) rule6962 = ReplacementRule(pattern6962, replacement6962) def With6963(v, w, p, u, m, b, r, a, x, q): if isinstance(x, (int, Integer, float, Float)): return False c = u/(p*w*D(v, x) + q*v*D(w, x)) if FreeQ(c, x): return True return False pattern6963 = Pattern(Integral(u_*v_**WC('r', S(1))*(a_ + v_**WC('p', S(1))*w_**WC('q', S(1))*WC('b', S(1)))**WC('m', S(1)), x_), cons2, cons3, cons21, cons5, cons50, cons52, cons2014, cons2015, cons2016, CustomConstraint(With6963)) def replacement6963(v, w, p, u, m, b, r, a, x, q): c = u/(p*w*D(v, x) + q*v*D(w, x)) rubi.append(6963) return Dist(c*p/(r + S(1)), Subst(Int((a + b*x**(p/(r + S(1))))**m, x), x, v**(r + S(1))*w), x) rule6963 = ReplacementRule(pattern6963, replacement6963) def With6964(v, w, p, u, m, b, r, a, x, s, q): if isinstance(x, (int, Integer, float, Float)): return False c = u/(p*w*D(v, x) + q*v*D(w, x)) if FreeQ(c, x): return True return False pattern6964 = Pattern(Integral(u_*v_**WC('r', S(1))*w_**WC('s', S(1))*(a_ + v_**WC('p', S(1))*w_**WC('q', S(1))*WC('b', S(1)))**WC('m', S(1)), x_), cons2, cons3, cons21, cons5, cons50, cons52, cons800, cons2017, cons2015, cons2016, CustomConstraint(With6964)) def replacement6964(v, w, p, u, m, b, r, a, x, s, q): c = u/(p*w*D(v, x) + q*v*D(w, x)) rubi.append(6964) return Dist(c*p/(r + S(1)), Subst(Int((a + b*x**(p/(r + S(1))))**m, x), x, v**(r + S(1))*w**(s + S(1))), x) rule6964 = ReplacementRule(pattern6964, replacement6964) def With6965(v, w, p, u, m, b, a, x, q): if isinstance(x, (int, Integer, float, Float)): return False c = u/(p*w*D(v, x) - q*v*D(w, x)) if FreeQ(c, x): return True return False pattern6965 = Pattern(Integral(u_*(v_**WC('p', S(1))*WC('a', S(1)) + w_**WC('q', S(1))*WC('b', S(1)))**WC('m', S(1)), x_), cons2, cons3, cons21, cons5, cons50, cons2018, cons38, cons17, CustomConstraint(With6965)) def replacement6965(v, w, p, u, m, b, a, x, q): c = u/(p*w*D(v, x) - q*v*D(w, x)) rubi.append(6965) return Dist(c*p, Subst(Int((a*x**p + b)**m, x), x, v*w**(m*q + S(1))), x) rule6965 = ReplacementRule(pattern6965, replacement6965) def With6966(v, w, p, u, m, b, r, a, x, q): if isinstance(x, (int, Integer, float, Float)): return False c = u/(p*w*D(v, x) - q*v*D(w, x)) if FreeQ(c, x): return True return False pattern6966 = Pattern(Integral(u_*v_**WC('r', S(1))*(v_**WC('p', S(1))*WC('a', S(1)) + w_**WC('q', S(1))*WC('b', S(1)))**WC('m', S(1)), x_), cons2, cons3, cons21, cons5, cons50, cons52, cons2019, cons586, cons17, CustomConstraint(With6966)) def replacement6966(v, w, p, u, m, b, r, a, x, q): c = u/(p*w*D(v, x) - q*v*D(w, x)) rubi.append(6966) return -Dist(c*q, Subst(Int((a + b*x**q)**m, x), x, v**(m*p + r + S(1))*w), x) rule6966 = ReplacementRule(pattern6966, replacement6966) def With6967(v, w, p, u, m, b, a, x, s, q): if isinstance(x, (int, Integer, float, Float)): return False c = u/(p*w*D(v, x) - q*v*D(w, x)) if FreeQ(c, x): return True return False pattern6967 = Pattern(Integral(u_*w_**WC('s', S(1))*(v_**WC('p', S(1))*WC('a', S(1)) + w_**WC('q', S(1))*WC('b', S(1)))**WC('m', S(1)), x_), cons2, cons3, cons21, cons5, cons50, cons800, cons2020, cons2021, cons2022, cons17, CustomConstraint(With6967)) def replacement6967(v, w, p, u, m, b, a, x, s, q): c = u/(p*w*D(v, x) - q*v*D(w, x)) rubi.append(6967) return -Dist(c*q/(s + S(1)), Subst(Int((a + b*x**(q/(s + S(1))))**m, x), x, v**(m*p + S(1))*w**(s + S(1))), x) rule6967 = ReplacementRule(pattern6967, replacement6967) def With6968(v, w, p, u, m, b, r, a, x, s, q): if isinstance(x, (int, Integer, float, Float)): return False c = u/(p*w*D(v, x) - q*v*D(w, x)) if FreeQ(c, x): return True return False pattern6968 = Pattern(Integral(u_*v_**WC('r', S(1))*w_**WC('s', S(1))*(v_**WC('p', S(1))*WC('a', S(1)) + w_**WC('q', S(1))*WC('b', S(1)))**WC('m', S(1)), x_), cons2, cons3, cons21, cons5, cons50, cons52, cons800, cons2023, cons2021, cons2022, cons17, CustomConstraint(With6968)) def replacement6968(v, w, p, u, m, b, r, a, x, s, q): c = u/(p*w*D(v, x) - q*v*D(w, x)) rubi.append(6968) return -Dist(c*q/(s + S(1)), Subst(Int((a + b*x**(q/(s + S(1))))**m, x), x, v**(m*p + r + S(1))*w**(s + S(1))), x) rule6968 = ReplacementRule(pattern6968, replacement6968) pattern6969 = Pattern(Integral(u_*x_**WC('m', S(1)), x_), cons21, cons66, cons2024) def replacement6969(x, m, u): rubi.append(6969) return Dist(S(1)/(m + S(1)), Subst(Int(SubstFor(x**(m + S(1)), u, x), x), x, x**(m + S(1))), x) rule6969 = ReplacementRule(pattern6969, replacement6969) def With6970(x, u): if isinstance(x, (int, Integer, float, Float)): return False try: lst = SubstForFractionalPowerOfLinear(u, x) res = And(Not(FalseQ(lst)), SubstForFractionalPowerQ(u, Part(lst, S(3)), x)) except (TypeError, AttributeError): return False if res: return True return False pattern6970 = Pattern(Integral(u_, x_), CustomConstraint(With6970)) def replacement6970(x, u): lst = SubstForFractionalPowerOfLinear(u, x) rubi.append(6970) return Dist(Part(lst, S(2))*Part(lst, S(4)), Subst(Int(Part(lst, S(1)), x), x, Part(lst, S(3))**(S(1)/Part(lst, S(2)))), x) rule6970 = ReplacementRule(pattern6970, replacement6970) def With6971(x, u): if isinstance(x, (int, Integer, float, Float)): return False try: lst = SubstForFractionalPowerOfQuotientOfLinears(u, x) res = Not(FalseQ(lst)) except (TypeError, AttributeError): return False if res: return True return False pattern6971 = Pattern(Integral(u_, x_), CustomConstraint(With6971)) def replacement6971(x, u): lst = SubstForFractionalPowerOfQuotientOfLinears(u, x) rubi.append(6971) return Dist(Part(lst, S(2))*Part(lst, S(4)), Subst(Int(Part(lst, S(1)), x), x, Part(lst, S(3))**(S(1)/Part(lst, S(2)))), x) rule6971 = ReplacementRule(pattern6971, replacement6971) pattern6972 = Pattern(Integral((v_**WC('m', S(1))*w_**WC('n', S(1))*z_**WC('q', S(1))*WC('a', S(1)))**p_*WC('u', S(1)), x_), cons2, cons21, cons4, cons5, cons50, cons147, cons10, cons2025, cons2026) def replacement6972(v, z, w, p, u, m, a, n, x, q): rubi.append(6972) return Dist(a**IntPart(p)*v**(-m*FracPart(p))*w**(-n*FracPart(p))*z**(-q*FracPart(p))*(a*v**m*w**n*z**q)**FracPart(p), Int(u*v**(m*p)*w**(n*p)*z**(p*q), x), x) rule6972 = ReplacementRule(pattern6972, replacement6972) pattern6973 = Pattern(Integral((v_**WC('m', S(1))*w_**WC('n', S(1))*WC('a', S(1)))**p_*WC('u', S(1)), x_), cons2, cons21, cons4, cons5, cons147, cons10, cons2025) def replacement6973(v, w, p, u, m, a, n, x): rubi.append(6973) return Dist(a**IntPart(p)*v**(-m*FracPart(p))*w**(-n*FracPart(p))*(a*v**m*w**n)**FracPart(p), Int(u*v**(m*p)*w**(n*p), x), x) rule6973 = ReplacementRule(pattern6973, replacement6973) pattern6974 = Pattern(Integral((v_**WC('m', S(1))*WC('a', S(1)))**p_*WC('u', S(1)), x_), cons2, cons21, cons5, cons147, cons10, cons2027, cons2028) def replacement6974(v, p, u, m, a, x): rubi.append(6974) return Dist(a**IntPart(p)*v**(-m*FracPart(p))*(a*v**m)**FracPart(p), Int(u*v**(m*p), x), x) rule6974 = ReplacementRule(pattern6974, replacement6974) pattern6975 = Pattern(Integral((x_**n_*WC('b', S(1)) + WC('a', S(0)))**p_*WC('u', S(1)), x_), cons2, cons3, cons5, cons667, cons196, cons2029) def replacement6975(p, u, b, a, n, x): rubi.append(6975) return Dist(FullSimplify(x**(-n/S(2))*sqrt(a + b*x**n)/sqrt(a*x**(-n) + b)), Int(u*x**(n*p)*(a*x**(-n) + b)**p, x), x) rule6975 = ReplacementRule(pattern6975, replacement6975) pattern6976 = Pattern(Integral((v_**n_*WC('b', S(1)) + WC('a', S(0)))**p_*WC('u', S(1)), x_), cons2, cons3, cons5, cons147, cons196, cons840, cons2030) def replacement6976(v, p, u, b, a, n, x): rubi.append(6976) return Dist(v**(-n*FracPart(p))*(a + b*v**n)**FracPart(p)*(a*v**(-n) + b)**(-FracPart(p)), Int(u*v**(n*p)*(a*v**(-n) + b)**p, x), x) rule6976 = ReplacementRule(pattern6976, replacement6976) pattern6977 = Pattern(Integral((v_**n_*x_**WC('m', S(1))*WC('b', S(1)) + WC('a', S(0)))**p_*WC('u', S(1)), x_), cons2, cons3, cons21, cons5, cons147, cons196, cons840) def replacement6977(v, p, u, m, b, a, n, x): rubi.append(6977) return Dist(v**(-n*FracPart(p))*(a + b*v**n*x**m)**FracPart(p)*(a*v**(-n) + b*x**m)**(-FracPart(p)), Int(u*v**(n*p)*(a*v**(-n) + b*x**m)**p, x), x) rule6977 = ReplacementRule(pattern6977, replacement6977) def With6978(u, m, b, r, a, x, s): if isinstance(x, (int, Integer, float, Float)): return False v = x**(-r*FracPart(m))*(a + b*x**(-r + s))**(-FracPart(m))*(a*x**r + b*x**s)**FracPart(m) if Not(EqQ(v, S(1))): return True return False pattern6978 = Pattern(Integral((x_**WC('r', S(1))*WC('a', S(1)) + x_**WC('s', S(1))*WC('b', S(1)))**m_*WC('u', S(1)), x_), cons2, cons3, cons21, cons52, cons800, cons18, cons2031, CustomConstraint(With6978)) def replacement6978(u, m, b, r, a, x, s): v = x**(-r*FracPart(m))*(a + b*x**(-r + s))**(-FracPart(m))*(a*x**r + b*x**s)**FracPart(m) rubi.append(6978) return Dist(v, Int(u*x**(m*r)*(a + b*x**(-r + s))**m, x), x) rule6978 = ReplacementRule(pattern6978, replacement6978) def With6979(u, b, a, n, x): if isinstance(x, (int, Integer, float, Float)): return False v = RationalFunctionExpand(u/(a + b*x**n), x) if SumQ(v): return True return False pattern6979 = Pattern(Integral(u_/(a_ + x_**n_*WC('b', S(1))), x_), cons2, cons3, cons148, CustomConstraint(With6979)) def replacement6979(u, b, a, n, x): v = RationalFunctionExpand(u/(a + b*x**n), x) rubi.append(6979) return Int(v, x) rule6979 = ReplacementRule(pattern6979, replacement6979) pattern6980 = Pattern(Integral(u_*(x_**WC('n', S(1))*WC('b', S(1)) + x_**WC('n2', S(1))*WC('c', S(1)) + WC('a', S(0)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons4, cons46, cons45, cons38, cons2032) def replacement6980(p, u, b, n2, c, a, n, x): rubi.append(6980) return Dist(S(4)**(-p)*c**(-p), Int(u*(b + S(2)*c*x**n)**(S(2)*p), x), x) rule6980 = ReplacementRule(pattern6980, replacement6980) pattern6981 = Pattern(Integral(u_*(x_**WC('n', S(1))*WC('b', S(1)) + x_**WC('n2', S(1))*WC('c', S(1)) + WC('a', S(0)))**p_, x_), cons2, cons3, cons7, cons4, cons5, cons46, cons45, cons147, cons2032) def replacement6981(p, u, b, n2, c, a, n, x): rubi.append(6981) return Dist((b + S(2)*c*x**n)**(-S(2)*p)*(a + b*x**n + c*x**(S(2)*n))**p, Int(u*(b + S(2)*c*x**n)**(S(2)*p), x), x) rule6981 = ReplacementRule(pattern6981, replacement6981) def With6982(u, b, n2, c, a, n, x): if isinstance(x, (int, Integer, float, Float)): return False v = RationalFunctionExpand(u/(a + b*x**n + c*x**(S(2)*n)), x) if SumQ(v): return True return False pattern6982 = Pattern(Integral(u_/(x_**WC('n', S(1))*WC('b', S(1)) + x_**WC('n2', S(1))*WC('c', S(1)) + WC('a', S(0))), x_), cons2, cons3, cons7, cons46, cons148, CustomConstraint(With6982)) def replacement6982(u, b, n2, c, a, n, x): v = RationalFunctionExpand(u/(a + b*x**n + c*x**(S(2)*n)), x) rubi.append(6982) return Int(v, x) rule6982 = ReplacementRule(pattern6982, replacement6982) pattern6983 = Pattern(Integral(WC('u', S(1))/(x_**WC('m', S(1))*WC('a', S(1)) + sqrt(x_**n_*WC('c', S(1)))*WC('b', S(1))), x_), cons2, cons3, cons7, cons21, cons4, cons1854) def replacement6983(u, m, b, a, c, n, x): rubi.append(6983) return Int(u*(a*x**m - b*sqrt(c*x**n))/(a**S(2)*x**(S(2)*m) - b**S(2)*c*x**n), x) rule6983 = ReplacementRule(pattern6983, replacement6983) def With6984(x, u): if isinstance(x, (int, Integer, float, Float)): return False try: lst = FunctionOfLinear(u, x) res = Not(FalseQ(lst)) except (TypeError, AttributeError): return False if res: return True return False pattern6984 = Pattern(Integral(u_, x_), CustomConstraint(With6984)) def replacement6984(x, u): lst = FunctionOfLinear(u, x) rubi.append(6984) return Dist(S(1)/Part(lst, S(3)), Subst(Int(Part(lst, S(1)), x), x, x*Part(lst, S(3)) + Part(lst, S(2))), x) rule6984 = ReplacementRule(pattern6984, replacement6984) def With6985(x, u): if isinstance(x, (int, Integer, float, Float)): return False try: lst = PowerVariableExpn(u, S(0), x) res = And(Not(FalseQ(lst)), NonzeroQ(Part(lst, S(2)))) except (TypeError, AttributeError): return False if res: return True return False pattern6985 = Pattern(Integral(u_/x_, x_), cons1247, cons2029, CustomConstraint(With6985)) def replacement6985(x, u): lst = PowerVariableExpn(u, S(0), x) rubi.append(6985) return Dist(S(1)/Part(lst, S(2)), Subst(Int(NormalizeIntegrand(Part(lst, S(1))/x, x), x), x, (x*Part(lst, S(3)))**Part(lst, S(2))), x) rule6985 = ReplacementRule(pattern6985, replacement6985) def With6986(x, m, u): if isinstance(x, (int, Integer, float, Float)): return False try: lst = PowerVariableExpn(u, m + S(1), x) res = And(Not(FalseQ(lst)), NonzeroQ(-m + Part(lst, S(2)) + S(-1))) except (TypeError, AttributeError): return False if res: return True return False pattern6986 = Pattern(Integral(u_*x_**WC('m', S(1)), x_), cons17, cons261, cons1247, cons2033, CustomConstraint(With6986)) def replacement6986(x, m, u): lst = PowerVariableExpn(u, m + S(1), x) rubi.append(6986) return Dist(S(1)/Part(lst, S(2)), Subst(Int(NormalizeIntegrand(Part(lst, S(1))/x, x), x), x, (x*Part(lst, S(3)))**Part(lst, S(2))), x) rule6986 = ReplacementRule(pattern6986, replacement6986) def With6987(x, m, u): k = Denominator(m) rubi.append(6987) return Dist(k, Subst(Int(x**(k*(m + S(1)) + S(-1))*ReplaceAll(u, Rule(x, x**k)), x), x, x**(S(1)/k)), x) pattern6987 = Pattern(Integral(u_*x_**m_, x_), cons367) rule6987 = ReplacementRule(pattern6987, With6987) def With6988(x, u): if isinstance(x, (int, Integer, float, Float)): return False try: lst = FunctionOfSquareRootOfQuadratic(u, x) res = Not(FalseQ(lst)) except (TypeError, AttributeError): return False if res: return True return False pattern6988 = Pattern(Integral(u_, x_), cons2034, CustomConstraint(With6988)) def replacement6988(x, u): lst = FunctionOfSquareRootOfQuadratic(u, x) rubi.append(6988) return Dist(S(2), Subst(Int(Part(lst, S(1)), x), x, Part(lst, S(2))), x) rule6988 = ReplacementRule(pattern6988, replacement6988) pattern6989 = Pattern(Integral(S(1)/(a_ + v_**S(2)*WC('b', S(1))), x_), cons2, cons3, cons67) def replacement6989(v, a, b, x): rubi.append(6989) return Dist(S(1)/(S(2)*a), Int(Together(S(1)/(-v/Rt(-a/b, S(2)) + S(1))), x), x) + Dist(S(1)/(S(2)*a), Int(Together(S(1)/(v/Rt(-a/b, S(2)) + S(1))), x), x) rule6989 = ReplacementRule(pattern6989, replacement6989) pattern6990 = Pattern(Integral(S(1)/(a_ + v_**n_*WC('b', S(1))), x_), cons2, cons3, cons1479, cons744) def replacement6990(v, b, a, n, x): rubi.append(6990) return Dist(S(2)/(a*n), Sum_doit(Int(Together(S(1)/(S(1) - (S(-1))**(-S(4)*k/n)*v**S(2)/Rt(-a/b, n/S(2)))), x), List(k, S(1), n/S(2))), x) rule6990 = ReplacementRule(pattern6990, replacement6990) pattern6991 = Pattern(Integral(S(1)/(a_ + v_**n_*WC('b', S(1))), x_), cons2, cons3, cons1482, cons165) def replacement6991(v, b, a, n, x): rubi.append(6991) return Dist(S(1)/(a*n), Sum_doit(Int(Together(S(1)/(S(1) - (S(-1))**(-S(2)*k/n)*v/Rt(-a/b, n))), x), List(k, S(1), n)), x) rule6991 = ReplacementRule(pattern6991, replacement6991) pattern6992 = Pattern(Integral(v_/(a_ + u_**WC('n', S(1))*WC('b', S(1))), x_), cons2, cons3, cons148, cons2035) def replacement6992(v, u, b, a, n, x): rubi.append(6992) return Int(ReplaceAll(ExpandIntegrand(PolynomialInSubst(v, u, x)/(a + b*x**n), x), Rule(x, u)), x) rule6992 = ReplacementRule(pattern6992, replacement6992) def With6993(x, u): if isinstance(x, (int, Integer, float, Float)): return False v = NormalizeIntegrand(u, x) if UnsameQ(v, u): return True return False pattern6993 = Pattern(Integral(u_, x_), CustomConstraint(With6993)) def replacement6993(x, u): v = NormalizeIntegrand(u, x) rubi.append(6993) return Int(v, x) rule6993 = ReplacementRule(pattern6993, replacement6993) def With6994(x, u): if isinstance(x, (int, Integer, float, Float)): return False v = ExpandIntegrand(u, x) if SumQ(v): return True return False pattern6994 = Pattern(Integral(u_, x_), CustomConstraint(With6994)) def replacement6994(x, u): v = ExpandIntegrand(u, x) rubi.append(6994) return Int(v, x) rule6994 = ReplacementRule(pattern6994, replacement6994) pattern6995 = Pattern(Integral((x_**WC('m', S(1))*WC('b', S(1)) + WC('a', S(0)))**WC('p', S(1))*(x_**WC('n', S(1))*WC('d', S(1)) + WC('c', S(0)))**WC('q', S(1))*WC('u', S(1)), x_), cons2, cons3, cons7, cons27, cons21, cons4, cons5, cons50, cons2036, cons1676, cons1255, cons2037) def replacement6995(p, u, m, b, d, a, c, n, x, q): rubi.append(6995) return Dist(x**(-m*p)*(a + b*x**m)**p*(c + d*x**n)**q, Int(u*x**(m*p), x), x) rule6995 = ReplacementRule(pattern6995, replacement6995) pattern6996 = Pattern(Integral(u_*(a_ + x_**WC('n', S(1))*WC('b', S(1)) + x_**WC('n2', S(1))*WC('c', S(1)))**p_, x_), cons2, cons3, cons7, cons4, cons5, cons46, cons45, cons347) def replacement6996(p, u, b, n2, c, n, a, x): rubi.append(6996) return Dist((S(4)*c)**(-p + S(1)/2)*sqrt(a + b*x**n + c*x**(S(2)*n))/(b + S(2)*c*x**n), Int(u*(b + S(2)*c*x**n)**(S(2)*p), x), x) rule6996 = ReplacementRule(pattern6996, replacement6996) def With6997(x, u): if isinstance(x, (int, Integer, float, Float)): return False try: lst = SubstForFractionalPowerOfLinear(u, x) res = Not(FalseQ(lst)) except (TypeError, AttributeError): return False if res: return True return False pattern6997 = Pattern(Integral(u_, x_), CustomConstraint(With6997)) def replacement6997(x, u): lst = SubstForFractionalPowerOfLinear(u, x) rubi.append(6997) return Dist(Part(lst, S(2))*Part(lst, S(4)), Subst(Int(Part(lst, S(1)), x), x, Part(lst, S(3))**(S(1)/Part(lst, S(2)))), x) rule6997 = ReplacementRule(pattern6997, replacement6997) pattern6998 = Pattern(Integral(u_, x_)) def replacement6998(x, u): rubi.append(6998) return Int(u, x) rule6998 = ReplacementRule(pattern6998, replacement6998) return [rule6931, rule6932, rule6933, rule6934, rule6935, rule6936, rule6937, rule6938, rule6939, rule6940, rule6941, rule6942, rule6943, rule6944, rule6945, rule6946, rule6947, rule6948, rule6949, rule6950, rule6951, rule6952, rule6953, rule6954, rule6955, rule6956, rule6957, rule6958, rule6959, rule6960, rule6961, rule6962, rule6963, rule6964, rule6965, rule6966, rule6967, rule6968, rule6969, rule6970, rule6971, rule6972, rule6973, rule6974, rule6975, rule6976, rule6977, rule6978, rule6979, rule6980, rule6981, rule6982, rule6983, rule6984, rule6985, rule6986, rule6987, rule6988, rule6989, rule6990, rule6991, rule6992, rule6993, rule6994, rule6995, rule6996, rule6997, rule6998, ]
861b885a0dadfd35dec443d147d7acbea78f51170dcd2151a391041c93c3633a
''' This code is automatically generated. Never edit it manually. For details of generating the code see `rubi_parsing_guide.md` in `parsetools`. ''' from sympy.external import import_module matchpy = import_module("matchpy") from sympy.utilities.decorator import doctest_depends_on if matchpy: from matchpy import Pattern, ReplacementRule, CustomConstraint, is_match from sympy.integrals.rubi.utility_function import ( Int, Sum, Set, With, Module, Scan, MapAnd, FalseQ, ZeroQ, NegativeQ, NonzeroQ, FreeQ, NFreeQ, List, Log, PositiveQ, PositiveIntegerQ, NegativeIntegerQ, IntegerQ, IntegersQ, ComplexNumberQ, PureComplexNumberQ, RealNumericQ, PositiveOrZeroQ, NegativeOrZeroQ, FractionOrNegativeQ, NegQ, Equal, Unequal, IntPart, FracPart, RationalQ, ProductQ, SumQ, NonsumQ, Subst, First, Rest, SqrtNumberQ, SqrtNumberSumQ, LinearQ, Sqrt, ArcCosh, Coefficient, Denominator, Hypergeometric2F1, Not, Simplify, FractionalPart, IntegerPart, AppellF1, EllipticPi, EllipticE, EllipticF, ArcTan, ArcCot, ArcCoth, ArcTanh, ArcSin, ArcSinh, ArcCos, ArcCsc, ArcSec, ArcCsch, ArcSech, Sinh, Tanh, Cosh, Sech, Csch, Coth, LessEqual, Less, Greater, GreaterEqual, FractionQ, IntLinearcQ, Expand, IndependentQ, PowerQ, IntegerPowerQ, PositiveIntegerPowerQ, FractionalPowerQ, AtomQ, ExpQ, LogQ, Head, MemberQ, TrigQ, SinQ, CosQ, TanQ, CotQ, SecQ, CscQ, Sin, Cos, Tan, Cot, Sec, Csc, HyperbolicQ, SinhQ, CoshQ, TanhQ, CothQ, SechQ, CschQ, InverseTrigQ, SinCosQ, SinhCoshQ, LeafCount, Numerator, NumberQ, NumericQ, Length, ListQ, Im, Re, InverseHyperbolicQ, InverseFunctionQ, TrigHyperbolicFreeQ, InverseFunctionFreeQ, RealQ, EqQ, FractionalPowerFreeQ, ComplexFreeQ, PolynomialQ, FactorSquareFree, PowerOfLinearQ, Exponent, QuadraticQ, LinearPairQ, BinomialParts, TrinomialParts, PolyQ, EvenQ, OddQ, PerfectSquareQ, NiceSqrtAuxQ, NiceSqrtQ, Together, PosAux, PosQ, CoefficientList, ReplaceAll, ExpandLinearProduct, GCD, ContentFactor, NumericFactor, NonnumericFactors, MakeAssocList, GensymSubst, KernelSubst, ExpandExpression, Apart, SmartApart, MatchQ, PolynomialQuotientRemainder, FreeFactors, NonfreeFactors, RemoveContentAux, RemoveContent, FreeTerms, NonfreeTerms, ExpandAlgebraicFunction, CollectReciprocals, ExpandCleanup, AlgebraicFunctionQ, Coeff, LeadTerm, RemainingTerms, LeadFactor, RemainingFactors, LeadBase, LeadDegree, Numer, Denom, hypergeom, Expon, MergeMonomials, PolynomialDivide, BinomialQ, TrinomialQ, GeneralizedBinomialQ, GeneralizedTrinomialQ, FactorSquareFreeList, PerfectPowerTest, SquareFreeFactorTest, RationalFunctionQ, RationalFunctionFactors, NonrationalFunctionFactors, Reverse, RationalFunctionExponents, RationalFunctionExpand, ExpandIntegrand, SimplerQ, SimplerSqrtQ, SumSimplerQ, BinomialDegree, TrinomialDegree, CancelCommonFactors, SimplerIntegrandQ, GeneralizedBinomialDegree, GeneralizedBinomialParts, GeneralizedTrinomialDegree, GeneralizedTrinomialParts, MonomialQ, MonomialSumQ, MinimumMonomialExponent, MonomialExponent, LinearMatchQ, PowerOfLinearMatchQ, QuadraticMatchQ, CubicMatchQ, BinomialMatchQ, TrinomialMatchQ, GeneralizedBinomialMatchQ, GeneralizedTrinomialMatchQ, QuotientOfLinearsMatchQ, PolynomialTermQ, PolynomialTerms, NonpolynomialTerms, PseudoBinomialParts, NormalizePseudoBinomial, PseudoBinomialPairQ, PseudoBinomialQ, PolynomialGCD, PolyGCD, AlgebraicFunctionFactors, NonalgebraicFunctionFactors, QuotientOfLinearsP, QuotientOfLinearsParts, QuotientOfLinearsQ, Flatten, Sort, AbsurdNumberQ, AbsurdNumberFactors, NonabsurdNumberFactors, SumSimplerAuxQ, Prepend, Drop, CombineExponents, FactorInteger, FactorAbsurdNumber, SubstForInverseFunction, SubstForFractionalPower, SubstForFractionalPowerOfQuotientOfLinears, FractionalPowerOfQuotientOfLinears, SubstForFractionalPowerQ, SubstForFractionalPowerAuxQ, FractionalPowerOfSquareQ, FractionalPowerSubexpressionQ, Apply, FactorNumericGcd, MergeableFactorQ, MergeFactor, MergeFactors, TrigSimplifyQ, TrigSimplify, TrigSimplifyRecur, Order, FactorOrder, Smallest, OrderedQ, MinimumDegree, PositiveFactors, Sign, NonpositiveFactors, PolynomialInAuxQ, PolynomialInQ, ExponentInAux, ExponentIn, PolynomialInSubstAux, PolynomialInSubst, Distrib, DistributeDegree, FunctionOfPower, DivideDegreesOfFactors, MonomialFactor, FullSimplify, FunctionOfLinearSubst, FunctionOfLinear, NormalizeIntegrand, NormalizeIntegrandAux, NormalizeIntegrandFactor, NormalizeIntegrandFactorBase, NormalizeTogether, NormalizeLeadTermSigns, AbsorbMinusSign, NormalizeSumFactors, SignOfFactor, NormalizePowerOfLinear, SimplifyIntegrand, SimplifyTerm, TogetherSimplify, SmartSimplify, SubstForExpn, ExpandToSum, UnifySum, UnifyTerms, UnifyTerm, CalculusQ, FunctionOfInverseLinear, PureFunctionOfSinhQ, PureFunctionOfTanhQ, PureFunctionOfCoshQ, IntegerQuotientQ, OddQuotientQ, EvenQuotientQ, FindTrigFactor, FunctionOfSinhQ, FunctionOfCoshQ, OddHyperbolicPowerQ, FunctionOfTanhQ, FunctionOfTanhWeight, FunctionOfHyperbolicQ, SmartNumerator, SmartDenominator, SubstForAux, ActivateTrig, ExpandTrig, TrigExpand, SubstForTrig, SubstForHyperbolic, InertTrigFreeQ, LCM, SubstForFractionalPowerOfLinear, FractionalPowerOfLinear, InverseFunctionOfLinear, InertTrigQ, InertReciprocalQ, DeactivateTrig, FixInertTrigFunction, DeactivateTrigAux, PowerOfInertTrigSumQ, PiecewiseLinearQ, KnownTrigIntegrandQ, KnownSineIntegrandQ, KnownTangentIntegrandQ, KnownCotangentIntegrandQ, KnownSecantIntegrandQ, TryPureTanSubst, TryTanhSubst, TryPureTanhSubst, AbsurdNumberGCD, AbsurdNumberGCDList, ExpandTrigExpand, ExpandTrigReduce, ExpandTrigReduceAux, NormalizeTrig, TrigToExp, ExpandTrigToExp, TrigReduce, FunctionOfTrig, AlgebraicTrigFunctionQ, FunctionOfHyperbolic, FunctionOfQ, FunctionOfExpnQ, PureFunctionOfSinQ, PureFunctionOfCosQ, PureFunctionOfTanQ, PureFunctionOfCotQ, FunctionOfCosQ, FunctionOfSinQ, OddTrigPowerQ, FunctionOfTanQ, FunctionOfTanWeight, FunctionOfTrigQ, FunctionOfDensePolynomialsQ, FunctionOfLog, PowerVariableExpn, PowerVariableDegree, PowerVariableSubst, EulerIntegrandQ, FunctionOfSquareRootOfQuadratic, SquareRootOfQuadraticSubst, Divides, EasyDQ, ProductOfLinearPowersQ, Rt, NthRoot, AtomBaseQ, SumBaseQ, NegSumBaseQ, AllNegTermQ, SomeNegTermQ, TrigSquareQ, RtAux, TrigSquare, IntSum, IntTerm, Map2, ConstantFactor, SameQ, ReplacePart, CommonFactors, MostMainFactorPosition, FunctionOfExponentialQ, FunctionOfExponential, FunctionOfExponentialFunction, FunctionOfExponentialFunctionAux, FunctionOfExponentialTest, FunctionOfExponentialTestAux, stdev, rubi_test, If, IntQuadraticQ, IntBinomialQ, RectifyTangent, RectifyCotangent, Inequality, Condition, Simp, SimpHelp, SplitProduct, SplitSum, SubstFor, SubstForAux, FresnelS, FresnelC, Erfc, Erfi, Gamma, FunctionOfTrigOfLinearQ, ElementaryFunctionQ, Complex, UnsameQ, _SimpFixFactor, SimpFixFactor, _FixSimplify, FixSimplify, _SimplifyAntiderivativeSum, SimplifyAntiderivativeSum, _SimplifyAntiderivative, SimplifyAntiderivative, _TrigSimplifyAux, TrigSimplifyAux, Cancel, Part, PolyLog, D, Dist, Sum_doit, PolynomialQuotient, Floor, PolynomialRemainder, Factor, PolyLog, CosIntegral, SinIntegral, LogIntegral, SinhIntegral, CoshIntegral, Rule, Erf, PolyGamma, ExpIntegralEi, ExpIntegralE, LogGamma , UtilityOperator, Factorial, Zeta, ProductLog, DerivativeDivides, HypergeometricPFQ, IntHide, OneQ, Null, rubi_exp as exp, rubi_log as log, Discriminant, Negative, Quotient ) from sympy import (Integral, S, sqrt, And, Or, Integer, Float, Mod, I, Abs, simplify, Mul, Add, Pow, sign, EulerGamma) from sympy.integrals.rubi.symbol import WC from sympy.core.symbol import symbols, Symbol from sympy.functions import (sin, cos, tan, cot, csc, sec, sqrt, erf) from sympy.functions.elementary.hyperbolic import (acosh, asinh, atanh, acoth, acsch, asech, cosh, sinh, tanh, coth, sech, csch) from sympy.functions.elementary.trigonometric import (atan, acsc, asin, acot, acos, asec, atan2) from sympy import pi as Pi A_, B_, C_, F_, G_, H_, a_, b_, c_, d_, e_, f_, g_, h_, i_, j_, k_, l_, m_, n_, p_, q_, r_, t_, u_, v_, s_, w_, x_, y_, z_ = [WC(i) for i in 'ABCFGHabcdefghijklmnpqrtuvswxyz'] a1_, a2_, b1_, b2_, c1_, c2_, d1_, d2_, n1_, n2_, e1_, e2_, f1_, f2_, g1_, g2_, n1_, n2_, n3_, Pq_, Pm_, Px_, Qm_, Qr_, Qx_, jn_, mn_, non2_, RFx_, RGx_ = [WC(i) for i in ['a1', 'a2', 'b1', 'b2', 'c1', 'c2', 'd1', 'd2', 'n1', 'n2', 'e1', 'e2', 'f1', 'f2', 'g1', 'g2', 'n1', 'n2', 'n3', 'Pq', 'Pm', 'Px', 'Qm', 'Qr', 'Qx', 'jn', 'mn', 'non2', 'RFx', 'RGx']] i, ii , Pqq, Q, R, r, C, k, u = symbols('i ii Pqq Q R r C k u') _UseGamma = False ShowSteps = False StepCounter = None def exponential(rubi): from sympy.integrals.rubi.constraints import cons31, cons168, cons515, cons1098, cons1099, cons3, cons7, cons27, cons48, cons125, cons208, cons4, cons94, cons17, cons18, cons21, cons1100, cons128, cons2, cons244, cons137, cons552, cons1101, cons1102, cons5, cons380, cons54, cons1103, cons1104, cons1105, cons209, cons224, cons796, cons797, cons50, cons1106, cons804, cons1107, cons812, cons1108, cons1109, cons1110, cons1111, cons584, cons1112, cons1113, cons479, cons480, cons1114, cons196, cons23, cons1115, cons53, cons1116, cons1117, cons1118, cons1119, cons85, cons1120, cons356, cons531, cons1121, cons1122, cons535, cons93, cons1123, cons1124, cons176, cons367, cons166, cons744, cons68, cons840, cons1125, cons1126, cons1127, cons25, cons71, cons1128, cons1129, cons1130, cons818, cons1131, cons1132, cons1133, cons1134, cons819, cons1135, cons1136, cons1137, cons1138, cons148, cons810, cons811, cons1139, cons1140, cons52, cons800, cons1141, cons1142, cons1143, cons813, cons1144, cons226, cons62, cons1145, cons1146, cons1147, cons1148, cons1149, cons1150, cons1151, cons463, cons1152, cons43, cons448, cons1153, cons1154, cons1155, cons1017 pattern1901 = Pattern(Integral((F_**((x_*WC('f', S(1)) + WC('e', S(0)))*WC('g', S(1)))*WC('b', S(1)))**WC('n', S(1))*(x_*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1)), x_), cons1099, cons3, cons7, cons27, cons48, cons125, cons208, cons4, cons31, cons168, cons515, cons1098) def replacement1901(m, f, g, b, d, c, n, x, F, e): rubi.append(1901) return -Dist(d*m/(f*g*n*log(F)), Int((F**(g*(e + f*x))*b)**n*(c + d*x)**(m + S(-1)), x), x) + Simp((F**(g*(e + f*x))*b)**n*(c + d*x)**m/(f*g*n*log(F)), x) rule1901 = ReplacementRule(pattern1901, replacement1901) pattern1902 = Pattern(Integral((F_**((x_*WC('f', S(1)) + WC('e', S(0)))*WC('g', S(1)))*WC('b', S(1)))**WC('n', S(1))*(x_*WC('d', S(1)) + WC('c', S(0)))**m_, x_), cons1099, cons3, cons7, cons27, cons48, cons125, cons208, cons4, cons31, cons94, cons515, cons1098) def replacement1902(m, f, g, b, d, c, n, x, F, e): rubi.append(1902) return -Dist(f*g*n*log(F)/(d*(m + S(1))), Int((F**(g*(e + f*x))*b)**n*(c + d*x)**(m + S(1)), x), x) + Simp((F**(g*(e + f*x))*b)**n*(c + d*x)**(m + S(1))/(d*(m + S(1))), x) rule1902 = ReplacementRule(pattern1902, replacement1902) pattern1903 = Pattern(Integral(F_**((x_*WC('f', S(1)) + WC('e', S(0)))*WC('g', S(1)))/(x_*WC('d', S(1)) + WC('c', S(0))), x_), cons1099, cons7, cons27, cons48, cons125, cons208, cons1098) def replacement1903(f, g, d, c, x, F, e): rubi.append(1903) return Simp(F**(g*(-c*f/d + e))*ExpIntegralEi(f*g*(c + d*x)*log(F)/d)/d, x) rule1903 = ReplacementRule(pattern1903, replacement1903) pattern1904 = Pattern(Integral(F_**((x_*WC('f', S(1)) + WC('e', S(0)))*WC('g', S(1)))*(x_*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1)), x_), cons1099, cons7, cons27, cons48, cons125, cons208, cons17) def replacement1904(m, f, g, d, c, x, F, e): rubi.append(1904) return Simp(F**(g*(-c*f/d + e))*f**(-m + S(-1))*g**(-m + S(-1))*(-d)**m*Gamma(m + S(1), -f*g*(c + d*x)*log(F)/d)*log(F)**(-m + S(-1)), x) rule1904 = ReplacementRule(pattern1904, replacement1904) pattern1905 = Pattern(Integral(F_**((x_*WC('f', S(1)) + WC('e', S(0)))*WC('g', S(1)))/sqrt(x_*WC('d', S(1)) + WC('c', S(0))), x_), cons1099, cons7, cons27, cons48, cons125, cons208, cons1098) def replacement1905(f, g, d, c, x, F, e): rubi.append(1905) return Dist(S(2)/d, Subst(Int(F**(g*(-c*f/d + e) + f*g*x**S(2)/d), x), x, sqrt(c + d*x)), x) rule1905 = ReplacementRule(pattern1905, replacement1905) pattern1906 = Pattern(Integral(F_**((x_*WC('f', S(1)) + WC('e', S(0)))*WC('g', S(1)))*(x_*WC('d', S(1)) + WC('c', S(0)))**m_, x_), cons1099, cons7, cons27, cons48, cons125, cons208, cons21, cons18) def replacement1906(m, f, g, d, c, x, F, e): rubi.append(1906) return -Simp(F**(g*(-c*f/d + e))*(-f*g*log(F)/d)**(-IntPart(m) + S(-1))*(-f*g*(c + d*x)*log(F)/d)**(-FracPart(m))*(c + d*x)**FracPart(m)*Gamma(m + S(1), -f*g*(c + d*x)*log(F)/d)/d, x) rule1906 = ReplacementRule(pattern1906, replacement1906) pattern1907 = Pattern(Integral((F_**((x_*WC('f', S(1)) + WC('e', S(0)))*WC('g', S(1)))*WC('b', S(1)))**n_*(x_*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1)), x_), cons1099, cons3, cons7, cons27, cons48, cons125, cons208, cons21, cons4, cons1100) def replacement1907(m, f, g, b, d, c, n, x, F, e): rubi.append(1907) return Dist(F**(-g*n*(e + f*x))*(F**(g*(e + f*x))*b)**n, Int(F**(g*n*(e + f*x))*(c + d*x)**m, x), x) rule1907 = ReplacementRule(pattern1907, replacement1907) pattern1908 = Pattern(Integral((a_ + (F_**((x_*WC('f', S(1)) + WC('e', S(0)))*WC('g', S(1))))**WC('n', S(1))*WC('b', S(1)))**WC('p', S(1))*(x_*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1)), x_), cons1099, cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons21, cons4, cons128) def replacement1908(p, m, f, g, b, d, c, n, a, x, F, e): rubi.append(1908) return Int(ExpandIntegrand((c + d*x)**m, (a + b*(F**(g*(e + f*x)))**n)**p, x), x) rule1908 = ReplacementRule(pattern1908, replacement1908) pattern1909 = Pattern(Integral((x_*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1))/(a_ + (F_**((x_*WC('f', S(1)) + WC('e', S(0)))*WC('g', S(1))))**WC('n', S(1))*WC('b', S(1))), x_), cons1099, cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons4, cons31, cons168) def replacement1909(m, f, g, b, d, c, n, a, x, F, e): rubi.append(1909) return Dist(d*m/(a*f*g*n*log(F)), Int((c + d*x)**(m + S(-1))*log(a*(F**(g*(e + f*x)))**(-n)/b + S(1)), x), x) - Simp((c + d*x)**m*log(a*(F**(g*(e + f*x)))**(-n)/b + S(1))/(a*f*g*n*log(F)), x) rule1909 = ReplacementRule(pattern1909, replacement1909) def With1910(p, m, f, g, b, d, c, n, a, x, F, e): u = IntHide((a + b*(F**(g*(e + f*x)))**n)**p, x) rubi.append(1910) return -Dist(d*m, Int(u*(c + d*x)**(m + S(-1)), x), x) + Dist((c + d*x)**m, u, x) pattern1910 = Pattern(Integral((a_ + (F_**((x_*WC('f', S(1)) + WC('e', S(0)))*WC('g', S(1))))**WC('n', S(1))*WC('b', S(1)))**p_*(x_*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1)), x_), cons1099, cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons4, cons244, cons168, cons137) rule1910 = ReplacementRule(pattern1910, With1910) pattern1911 = Pattern(Integral(u_**WC('m', S(1))*((F_**(v_*WC('g', S(1))))**WC('n', S(1))*WC('b', S(1)) + WC('a', S(0)))**WC('p', S(1)), x_), cons1099, cons2, cons3, cons208, cons4, cons5, cons552, cons1101, cons1102, cons17) def replacement1911(v, p, u, m, g, b, a, n, x, F): rubi.append(1911) return Int((a + b*(F**(g*ExpandToSum(v, x)))**n)**p*NormalizePowerOfLinear(u, x)**m, x) rule1911 = ReplacementRule(pattern1911, replacement1911) def With1912(v, p, u, m, g, b, a, n, x, F): uu = NormalizePowerOfLinear(u, x) z = Symbol('z') z = If(And(PowerQ(uu), FreeQ(Part(uu, S(2)), x)), Part(uu, S(1))**(m*Part(uu, S(2))), uu**m) z = If(And(PowerQ(uu), FreeQ(Part(uu, 2), x)), Part(uu, 1)**(m*Part(uu, 2)), uu**m) return Simp(uu**m*Int(z*(a + b*(F**(g*ExpandToSum(v, x)))**n)**p, x)/z, x) pattern1912 = Pattern(Integral(u_**WC('m', S(1))*((F_**(v_*WC('g', S(1))))**WC('n', S(1))*WC('b', S(1)) + WC('a', S(0)))**WC('p', S(1)), x_), cons1099, cons2, cons3, cons208, cons21, cons4, cons5, cons552, cons1101, cons1102, cons18) rule1912 = ReplacementRule(pattern1912, With1912) pattern1913 = Pattern(Integral((a_ + (F_**((x_*WC('f', S(1)) + WC('e', S(0)))*WC('g', S(1))))**WC('n', S(1))*WC('b', S(1)))**WC('p', S(1))*(x_*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons21, cons4, cons5, cons380) def replacement1913(p, m, f, g, b, d, c, n, a, x, F, e): rubi.append(1913) return Int((a + b*(F**(g*(e + f*x)))**n)**p*(c + d*x)**m, x) rule1913 = ReplacementRule(pattern1913, replacement1913) pattern1914 = Pattern(Integral((x_*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1))*(F_**((x_*WC('f', S(1)) + WC('e', S(0)))*WC('g', S(1))))**WC('n', S(1))/(a_ + (F_**((x_*WC('f', S(1)) + WC('e', S(0)))*WC('g', S(1))))**WC('n', S(1))*WC('b', S(1))), x_), cons1099, cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons4, cons31, cons168) def replacement1914(m, f, g, b, d, c, n, a, x, F, e): rubi.append(1914) return -Dist(d*m/(b*f*g*n*log(F)), Int((c + d*x)**(m + S(-1))*log(S(1) + b*(F**(g*(e + f*x)))**n/a), x), x) + Simp((c + d*x)**m*log(S(1) + b*(F**(g*(e + f*x)))**n/a)/(b*f*g*n*log(F)), x) rule1914 = ReplacementRule(pattern1914, replacement1914) pattern1915 = Pattern(Integral((x_*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1))*((F_**((x_*WC('f', S(1)) + WC('e', S(0)))*WC('g', S(1))))**WC('n', S(1))*WC('b', S(1)) + WC('a', S(0)))**WC('p', S(1))*(F_**((x_*WC('f', S(1)) + WC('e', S(0)))*WC('g', S(1))))**WC('n', S(1)), x_), cons1099, cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons21, cons4, cons5, cons54) def replacement1915(p, m, f, g, b, d, a, n, c, x, F, e): rubi.append(1915) return -Dist(d*m/(b*f*g*n*(p + S(1))*log(F)), Int((a + b*(F**(g*(e + f*x)))**n)**(p + S(1))*(c + d*x)**(m + S(-1)), x), x) + Simp((a + b*(F**(g*(e + f*x)))**n)**(p + S(1))*(c + d*x)**m/(b*f*g*n*(p + S(1))*log(F)), x) rule1915 = ReplacementRule(pattern1915, replacement1915) pattern1916 = Pattern(Integral((x_*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1))*((F_**((x_*WC('f', S(1)) + WC('e', S(0)))*WC('g', S(1))))**WC('n', S(1))*WC('b', S(1)) + WC('a', S(0)))**WC('p', S(1))*(F_**((x_*WC('f', S(1)) + WC('e', S(0)))*WC('g', S(1))))**WC('n', S(1)), x_), cons1099, cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons21, cons4, cons5, cons1103) def replacement1916(p, m, f, g, b, d, a, n, c, x, F, e): rubi.append(1916) return Int((a + b*(F**(g*(e + f*x)))**n)**p*(c + d*x)**m*(F**(g*(e + f*x)))**n, x) rule1916 = ReplacementRule(pattern1916, replacement1916) pattern1917 = Pattern(Integral((G_**((x_*WC('i', S(1)) + WC('h', S(0)))*WC('j', S(1)))*WC('k', S(1)))**WC('q', S(1))*(x_*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1))*((F_**((x_*WC('f', S(1)) + WC('e', S(0)))*WC('g', S(1))))**WC('n', S(1))*WC('b', S(1)) + WC('a', S(0)))**WC('p', S(1)), x_), cons1099, cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons209, cons224, cons796, cons797, cons21, cons4, cons5, cons50, cons1104, cons1105) def replacement1917(p, j, k, m, f, g, b, i, d, G, a, n, c, x, h, q, e, F): rubi.append(1917) return Dist((G**(j*(h + i*x))*k)**q*(F**(g*(e + f*x)))**(-n), Int((a + b*(F**(g*(e + f*x)))**n)**p*(c + d*x)**m*(F**(g*(e + f*x)))**n, x), x) rule1917 = ReplacementRule(pattern1917, replacement1917) pattern1918 = Pattern(Integral((F_**((x_*WC('b', S(1)) + WC('a', S(0)))*WC('c', S(1))))**WC('n', S(1)), x_), cons1099, cons2, cons3, cons7, cons4, cons1106) def replacement1918(b, c, n, a, x, F): rubi.append(1918) return Simp((F**(c*(a + b*x)))**n/(b*c*n*log(F)), x) rule1918 = ReplacementRule(pattern1918, replacement1918) pattern1919 = Pattern(Integral(F_**(v_*WC('c', S(1)))*u_, x_), cons1099, cons7, cons804, cons552, cons1107) def replacement1919(v, u, c, x, F): rubi.append(1919) return Int(ExpandIntegrand(F**(c*ExpandToSum(v, x))*u, x), x) rule1919 = ReplacementRule(pattern1919, replacement1919) pattern1920 = Pattern(Integral(F_**(v_*WC('c', S(1)))*u_, x_), cons1099, cons7, cons804, cons552, cons1098) def replacement1920(v, u, c, x, F): rubi.append(1920) return Int(ExpandIntegrand(F**(c*ExpandToSum(v, x)), u, x), x) rule1920 = ReplacementRule(pattern1920, replacement1920) pattern1921 = Pattern(Integral(F_**(v_*WC('c', S(1)))*u_**WC('m', S(1))*w_, x_), cons1099, cons7, cons21, cons812, cons1108) def replacement1921(v, w, u, m, c, x, F): rubi.append(1921) return Simp(F**(c*v)*u**(m + S(1))*Coefficient(w, x, S(1))/(c*Coefficient(u, x, S(1))*Coefficient(v, x, S(1))*log(F)), x) rule1921 = ReplacementRule(pattern1921, replacement1921) pattern1922 = Pattern(Integral(F_**(v_*WC('c', S(1)))*u_**WC('m', S(1))*w_, x_), cons1099, cons7, cons1109, cons552, cons1101, cons17, cons1107) def replacement1922(v, w, u, m, c, x, F): rubi.append(1922) return Int(ExpandIntegrand(F**(c*ExpandToSum(v, x))*w*NormalizePowerOfLinear(u, x)**m, x), x) rule1922 = ReplacementRule(pattern1922, replacement1922) pattern1923 = Pattern(Integral(F_**(v_*WC('c', S(1)))*u_**WC('m', S(1))*w_, x_), cons1099, cons7, cons1109, cons552, cons1101, cons17, cons1098) def replacement1923(v, w, u, m, c, x, F): rubi.append(1923) return Int(ExpandIntegrand(F**(c*ExpandToSum(v, x)), w*NormalizePowerOfLinear(u, x)**m, x), x) rule1923 = ReplacementRule(pattern1923, replacement1923) def With1924(v, w, u, m, c, x, F): uu = NormalizePowerOfLinear(u, x) z = Symbol('z') z = If(And(PowerQ(uu), FreeQ(Part(uu, S(2)), x)), Part(uu, S(1))**(m*Part(uu, S(2))), uu**m) z = If(And(PowerQ(uu), FreeQ(Part(uu, 2), x)), Part(uu, 1)**(m*Part(uu, 2)), uu**m) return Simp(uu**m*Int(ExpandIntegrand(F**(c*ExpandToSum(v, x))*w*z, x), x)/z, x) pattern1924 = Pattern(Integral(F_**(v_*WC('c', S(1)))*u_**WC('m', S(1))*w_, x_), cons1099, cons7, cons21, cons1109, cons552, cons1101, cons18) rule1924 = ReplacementRule(pattern1924, With1924) pattern1925 = Pattern(Integral(F_**((x_*WC('b', S(1)) + WC('a', S(0)))*WC('c', S(1)))*(e_ + (x_*WC('g', S(1)) + WC('f', S(0)))*WC('h', S(1))*log(x_*WC('d', S(1))))*log(x_*WC('d', S(1)))**WC('n', S(1)), x_), cons1099, cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons209, cons4, cons1110, cons1111, cons584) def replacement1925(f, b, g, d, c, n, a, x, h, F, e): rubi.append(1925) return Simp(F**(c*(a + b*x))*e*x*log(d*x)**(n + S(1))/(n + S(1)), x) rule1925 = ReplacementRule(pattern1925, replacement1925) pattern1926 = Pattern(Integral(F_**((x_*WC('b', S(1)) + WC('a', S(0)))*WC('c', S(1)))*x_**WC('m', S(1))*(e_ + (x_*WC('g', S(1)) + WC('f', S(0)))*WC('h', S(1))*log(x_*WC('d', S(1))))*log(x_*WC('d', S(1)))**WC('n', S(1)), x_), cons1099, cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons209, cons21, cons4, cons1112, cons1111, cons584) def replacement1926(m, f, b, g, d, c, n, a, x, h, F, e): rubi.append(1926) return Simp(F**(c*(a + b*x))*e*x**(m + S(1))*log(d*x)**(n + S(1))/(n + S(1)), x) rule1926 = ReplacementRule(pattern1926, replacement1926) pattern1927 = Pattern(Integral(F_**((x_*WC('d', S(1)) + WC('c', S(0)))*WC('b', S(1)) + WC('a', S(0))), x_), cons1099, cons2, cons3, cons7, cons27, cons1113) def replacement1927(b, d, c, a, x, F): rubi.append(1927) return Simp(F**(a + b*(c + d*x))/(b*d*log(F)), x) rule1927 = ReplacementRule(pattern1927, replacement1927) pattern1928 = Pattern(Integral(F_**((x_*WC('d', S(1)) + WC('c', S(0)))**S(2)*WC('b', S(1)) + WC('a', S(0))), x_), cons1099, cons2, cons3, cons7, cons27, cons479) def replacement1928(b, d, c, a, x, F): rubi.append(1928) return Simp(F**a*sqrt(Pi)*Erfi((c + d*x)*Rt(b*log(F), S(2)))/(S(2)*d*Rt(b*log(F), S(2))), x) rule1928 = ReplacementRule(pattern1928, replacement1928) pattern1929 = Pattern(Integral(F_**((x_*WC('d', S(1)) + WC('c', S(0)))**S(2)*WC('b', S(1)) + WC('a', S(0))), x_), cons1099, cons2, cons3, cons7, cons27, cons480) def replacement1929(b, d, c, a, x, F): rubi.append(1929) return Simp(F**a*sqrt(Pi)*Erf((c + d*x)*Rt(-b*log(F), S(2)))/(S(2)*d*Rt(-b*log(F), S(2))), x) rule1929 = ReplacementRule(pattern1929, replacement1929) pattern1930 = Pattern(Integral(F_**((x_*WC('d', S(1)) + WC('c', S(0)))**n_*WC('b', S(1)) + WC('a', S(0))), x_), cons1099, cons2, cons3, cons7, cons27, cons1114, cons196) def replacement1930(b, d, c, a, n, x, F): rubi.append(1930) return -Dist(b*n*log(F), Int(F**(a + b*(c + d*x)**n)*(c + d*x)**n, x), x) + Simp(F**(a + b*(c + d*x)**n)*(c + d*x)/d, x) rule1930 = ReplacementRule(pattern1930, replacement1930) def With1931(b, d, c, a, n, x, F): k = Denominator(n) rubi.append(1931) return Dist(k/d, Subst(Int(F**(a + b*x**(k*n))*x**(k + S(-1)), x), x, (c + d*x)**(S(1)/k)), x) pattern1931 = Pattern(Integral(F_**((x_*WC('d', S(1)) + WC('c', S(0)))**n_*WC('b', S(1)) + WC('a', S(0))), x_), cons1099, cons2, cons3, cons7, cons27, cons1114, cons23) rule1931 = ReplacementRule(pattern1931, With1931) pattern1932 = Pattern(Integral(F_**((x_*WC('d', S(1)) + WC('c', S(0)))**n_*WC('b', S(1)) + WC('a', S(0))), x_), cons1099, cons2, cons3, cons7, cons27, cons4, cons1115) def replacement1932(b, d, c, a, n, x, F): rubi.append(1932) return -Simp(F**a*(-b*(c + d*x)**n*log(F))**(-S(1)/n)*(c + d*x)*Gamma(S(1)/n, -b*(c + d*x)**n*log(F))/(d*n), x) rule1932 = ReplacementRule(pattern1932, replacement1932) pattern1933 = Pattern(Integral(F_**((x_*WC('d', S(1)) + WC('c', S(0)))**n_*WC('b', S(1)) + WC('a', S(0)))*(x_*WC('f', S(1)) + WC('e', S(0)))**WC('m', S(1)), x_), cons1099, cons2, cons3, cons7, cons27, cons48, cons125, cons4, cons53, cons1116) def replacement1933(m, f, b, d, c, a, n, x, F, e): rubi.append(1933) return Simp(F**(a + b*(c + d*x)**n)*(c + d*x)**(-n)*(e + f*x)**n/(b*f*n*log(F)), x) rule1933 = ReplacementRule(pattern1933, replacement1933) pattern1934 = Pattern(Integral(F_**((x_*WC('d', S(1)) + WC('c', S(0)))**n_*WC('b', S(1)) + WC('a', S(0)))/(x_*WC('f', S(1)) + WC('e', S(0))), x_), cons1099, cons2, cons3, cons7, cons27, cons48, cons125, cons4, cons1116) def replacement1934(f, b, d, c, a, n, x, F, e): rubi.append(1934) return Simp(F**a*ExpIntegralEi(b*(c + d*x)**n*log(F))/(f*n), x) rule1934 = ReplacementRule(pattern1934, replacement1934) pattern1935 = Pattern(Integral(F_**((x_*WC('d', S(1)) + WC('c', S(0)))**n_*WC('b', S(1)) + WC('a', S(0)))*(x_*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1)), x_), cons1099, cons2, cons3, cons7, cons27, cons21, cons4, cons1117) def replacement1935(m, b, d, c, a, n, x, F): rubi.append(1935) return Dist(S(1)/(d*(m + S(1))), Subst(Int(F**(a + b*x**S(2)), x), x, (c + d*x)**(m + S(1))), x) rule1935 = ReplacementRule(pattern1935, replacement1935) pattern1936 = Pattern(Integral(F_**((x_*WC('d', S(1)) + WC('c', S(0)))**n_*WC('b', S(1)) + WC('a', S(0)))*(x_*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1)), x_), cons1099, cons2, cons3, cons7, cons27, cons31, cons1118, cons1119, cons85, cons1120) def replacement1936(m, b, d, c, a, n, x, F): rubi.append(1936) return -Dist((m - n + S(1))/(b*n*log(F)), Int(F**(a + b*(c + d*x)**n)*(c + d*x)**(m - n), x), x) + Simp(F**(a + b*(c + d*x)**n)*(c + d*x)**(m - n + S(1))/(b*d*n*log(F)), x) rule1936 = ReplacementRule(pattern1936, replacement1936) pattern1937 = Pattern(Integral(F_**((x_*WC('d', S(1)) + WC('c', S(0)))**n_*WC('b', S(1)) + WC('a', S(0)))*(x_*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1)), x_), cons1099, cons2, cons3, cons7, cons27, cons21, cons4, cons1118, cons1119, cons356, cons531) def replacement1937(m, b, d, c, a, n, x, F): rubi.append(1937) return -Dist((m - n + S(1))/(b*n*log(F)), Int(F**(a + b*(c + d*x)**n)*(c + d*x)**(m - n), x), x) + Simp(F**(a + b*(c + d*x)**n)*(c + d*x)**(m - n + S(1))/(b*d*n*log(F)), x) rule1937 = ReplacementRule(pattern1937, replacement1937) pattern1938 = Pattern(Integral(F_**((x_*WC('d', S(1)) + WC('c', S(0)))**n_*WC('b', S(1)) + WC('a', S(0)))*(x_*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1)), x_), cons1099, cons2, cons3, cons7, cons27, cons31, cons1118, cons1121, cons85, cons1122) def replacement1938(m, b, d, c, a, n, x, F): rubi.append(1938) return -Dist(b*n*log(F)/(m + S(1)), Int(F**(a + b*(c + d*x)**n)*(c + d*x)**(m + n), x), x) + Simp(F**(a + b*(c + d*x)**n)*(c + d*x)**(m + S(1))/(d*(m + S(1))), x) rule1938 = ReplacementRule(pattern1938, replacement1938) pattern1939 = Pattern(Integral(F_**((x_*WC('d', S(1)) + WC('c', S(0)))**n_*WC('b', S(1)) + WC('a', S(0)))*(x_*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1)), x_), cons1099, cons2, cons3, cons7, cons27, cons21, cons4, cons1118, cons1121, cons356, cons535) def replacement1939(m, b, d, c, a, n, x, F): rubi.append(1939) return -Dist(b*n*log(F)/(m + S(1)), Int(F**(a + b*(c + d*x)**n)*(c + d*x)**(m + n), x), x) + Simp(F**(a + b*(c + d*x)**n)*(c + d*x)**(m + S(1))/(d*(m + S(1))), x) rule1939 = ReplacementRule(pattern1939, replacement1939) def With1940(m, b, d, c, a, n, x, F): k = Denominator(n) rubi.append(1940) return Dist(k/d, Subst(Int(F**(a + b*x**(k*n))*x**(k*(m + S(1)) + S(-1)), x), x, (c + d*x)**(S(1)/k)), x) pattern1940 = Pattern(Integral(F_**((x_*WC('d', S(1)) + WC('c', S(0)))**n_*WC('b', S(1)) + WC('a', S(0)))*(x_*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1)), x_), cons1099, cons2, cons3, cons7, cons27, cons93, cons1118, cons1119, cons23) rule1940 = ReplacementRule(pattern1940, With1940) pattern1941 = Pattern(Integral(F_**((x_*WC('d', S(1)) + WC('c', S(0)))**n_*WC('b', S(1)) + WC('a', S(0)))*(x_*WC('f', S(1)) + WC('e', S(0)))**WC('m', S(1)), x_), cons1099, cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons4, cons1116, cons1118, cons1123, cons18, cons1124) def replacement1941(m, f, b, d, c, a, n, x, F, e): rubi.append(1941) return Dist((c + d*x)**(-m)*(e + f*x)**m, Int(F**(a + b*(c + d*x)**n)*(c + d*x)**m, x), x) rule1941 = ReplacementRule(pattern1941, replacement1941) pattern1942 = Pattern(Integral(F_**((x_*WC('d', S(1)) + WC('c', S(0)))**n_*WC('b', S(1)) + WC('a', S(0)))*(x_*WC('f', S(1)) + WC('e', S(0)))**WC('m', S(1)), x_), cons1099, cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons4, cons1116) def replacement1942(m, f, b, d, c, a, n, x, F, e): rubi.append(1942) return -Simp(F**a*(-b*(c + d*x)**n*log(F))**(-(m + S(1))/n)*(e + f*x)**(m + S(1))*Gamma((m + S(1))/n, -b*(c + d*x)**n*log(F))/(f*n), x) rule1942 = ReplacementRule(pattern1942, replacement1942) pattern1943 = Pattern(Integral(F_**((x_*WC('d', S(1)) + WC('c', S(0)))**S(2)*WC('b', S(1)) + WC('a', S(0)))*(x_*WC('f', S(1)) + WC('e', S(0)))**m_, x_), cons1099, cons2, cons3, cons7, cons27, cons48, cons125, cons176, cons367, cons166) def replacement1943(m, f, b, d, c, a, x, F, e): rubi.append(1943) return Dist((-c*f + d*e)/d, Int(F**(a + b*(c + d*x)**S(2))*(e + f*x)**(m + S(-1)), x), x) - Dist(f**S(2)*(m + S(-1))/(S(2)*b*d**S(2)*log(F)), Int(F**(a + b*(c + d*x)**S(2))*(e + f*x)**(m + S(-2)), x), x) + Simp(F**(a + b*(c + d*x)**S(2))*f*(e + f*x)**(m + S(-1))/(S(2)*b*d**S(2)*log(F)), x) rule1943 = ReplacementRule(pattern1943, replacement1943) pattern1944 = Pattern(Integral(F_**((x_*WC('d', S(1)) + WC('c', S(0)))**S(2)*WC('b', S(1)) + WC('a', S(0)))*(x_*WC('f', S(1)) + WC('e', S(0)))**m_, x_), cons1099, cons2, cons3, cons7, cons27, cons48, cons125, cons176, cons31, cons94) def replacement1944(m, f, b, d, c, a, x, F, e): rubi.append(1944) return -Dist(S(2)*b*d**S(2)*log(F)/(f**S(2)*(m + S(1))), Int(F**(a + b*(c + d*x)**S(2))*(e + f*x)**(m + S(2)), x), x) + Dist(S(2)*b*d*(-c*f + d*e)*log(F)/(f**S(2)*(m + S(1))), Int(F**(a + b*(c + d*x)**S(2))*(e + f*x)**(m + S(1)), x), x) + Simp(F**(a + b*(c + d*x)**S(2))*(e + f*x)**(m + S(1))/(f*(m + S(1))), x) rule1944 = ReplacementRule(pattern1944, replacement1944) pattern1945 = Pattern(Integral(F_**((x_*WC('d', S(1)) + WC('c', S(0)))**n_*WC('b', S(1)) + WC('a', S(0)))*(x_*WC('f', S(1)) + WC('e', S(0)))**m_, x_), cons1099, cons2, cons3, cons7, cons27, cons48, cons125, cons176, cons85, cons744, cons31, cons94) def replacement1945(m, f, b, d, c, a, n, x, F, e): rubi.append(1945) return -Dist(b*d*n*log(F)/(f*(m + S(1))), Int(F**(a + b*(c + d*x)**n)*(c + d*x)**(n + S(-1))*(e + f*x)**(m + S(1)), x), x) + Simp(F**(a + b*(c + d*x)**n)*(e + f*x)**(m + S(1))/(f*(m + S(1))), x) rule1945 = ReplacementRule(pattern1945, replacement1945) pattern1946 = Pattern(Integral(F_**(WC('a', S(0)) + WC('b', S(1))/(x_*WC('d', S(1)) + WC('c', S(0))))/(x_*WC('f', S(1)) + WC('e', S(0))), x_), cons1099, cons2, cons3, cons7, cons27, cons48, cons125, cons176) def replacement1946(f, b, d, c, a, x, F, e): rubi.append(1946) return Dist(d/f, Int(F**(a + b/(c + d*x))/(c + d*x), x), x) - Dist((-c*f + d*e)/f, Int(F**(a + b/(c + d*x))/((c + d*x)*(e + f*x)), x), x) rule1946 = ReplacementRule(pattern1946, replacement1946) pattern1947 = Pattern(Integral(F_**(WC('a', S(0)) + WC('b', S(1))/(x_*WC('d', S(1)) + WC('c', S(0))))*(x_*WC('f', S(1)) + WC('e', S(0)))**m_, x_), cons1099, cons2, cons3, cons7, cons27, cons48, cons125, cons176, cons17, cons94) def replacement1947(m, f, b, d, c, a, x, F, e): rubi.append(1947) return Dist(b*d*log(F)/(f*(m + S(1))), Int(F**(a + b/(c + d*x))*(e + f*x)**(m + S(1))/(c + d*x)**S(2), x), x) + Simp(F**(a + b/(c + d*x))*(e + f*x)**(m + S(1))/(f*(m + S(1))), x) rule1947 = ReplacementRule(pattern1947, replacement1947) pattern1948 = Pattern(Integral(F_**((x_*WC('d', S(1)) + WC('c', S(0)))**n_*WC('b', S(1)) + WC('a', S(0)))/(x_*WC('f', S(1)) + WC('e', S(0))), x_), cons1099, cons2, cons3, cons7, cons27, cons48, cons125, cons4, cons176) def replacement1948(f, b, d, c, a, n, x, F, e): rubi.append(1948) return Int(F**(a + b*(c + d*x)**n)/(e + f*x), x) rule1948 = ReplacementRule(pattern1948, replacement1948) pattern1949 = Pattern(Integral(F_**v_*u_**WC('m', S(1)), x_), cons1099, cons21, cons68, cons840, cons1125) def replacement1949(v, u, m, x, F): rubi.append(1949) return Int(F**ExpandToSum(v, x)*ExpandToSum(u, x)**m, x) rule1949 = ReplacementRule(pattern1949, replacement1949) pattern1950 = Pattern(Integral(F_**((x_*WC('d', S(1)) + WC('c', S(0)))**n_*WC('b', S(1)) + WC('a', S(0)))*u_, x_), cons1099, cons2, cons3, cons7, cons27, cons4, cons804) def replacement1950(u, b, d, c, a, n, x, F): rubi.append(1950) return Int(ExpandLinearProduct(F**(a + b*(c + d*x)**n), u, c, d, x), x) rule1950 = ReplacementRule(pattern1950, replacement1950) pattern1951 = Pattern(Integral(F_**(v_*WC('b', S(1)) + WC('a', S(0)))*WC('u', S(1)), x_), cons1099, cons2, cons3, cons804, cons1126, cons1127) def replacement1951(v, u, b, a, x, F): rubi.append(1951) return Int(F**(a + b*NormalizePowerOfLinear(v, x))*u, x) rule1951 = ReplacementRule(pattern1951, replacement1951) pattern1952 = Pattern(Integral(F_**(WC('a', S(0)) + WC('b', S(1))/(x_*WC('d', S(1)) + WC('c', S(0))))/((x_*WC('f', S(1)) + WC('e', S(0)))*(x_*WC('h', S(1)) + WC('g', S(0)))), x_), cons1099, cons2, cons3, cons7, cons27, cons48, cons125, cons1116) def replacement1952(f, b, g, d, c, a, x, h, F, e): rubi.append(1952) return -Dist(d/(f*(-c*h + d*g)), Subst(Int(F**(a + b*d*x/(-c*h + d*g) - b*h/(-c*h + d*g))/x, x), x, (g + h*x)/(c + d*x)), x) rule1952 = ReplacementRule(pattern1952, replacement1952) pattern1953 = Pattern(Integral(F_**((x_*WC('b', S(1)) + WC('a', S(0)))*WC('f', S(1))/(x_*WC('d', S(1)) + WC('c', S(0))) + WC('e', S(0)))*(x_*WC('h', S(1)) + WC('g', S(0)))**WC('m', S(1)), x_), cons1099, cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons209, cons21, cons25) def replacement1953(m, f, b, g, d, c, a, x, h, F, e): rubi.append(1953) return Dist(F**(b*f/d + e), Int((g + h*x)**m, x), x) rule1953 = ReplacementRule(pattern1953, replacement1953) pattern1954 = Pattern(Integral(F_**((x_*WC('b', S(1)) + WC('a', S(0)))*WC('f', S(1))/(x_*WC('d', S(1)) + WC('c', S(0))) + WC('e', S(0)))*(x_*WC('h', S(1)) + WC('g', S(0)))**WC('m', S(1)), x_), cons1099, cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons209, cons21, cons71, cons1128) def replacement1954(m, f, b, g, d, c, a, x, h, F, e): rubi.append(1954) return Int(F**(-f*(-a*d + b*c)/(d*(c + d*x)) + (b*f + d*e)/d)*(g + h*x)**m, x) rule1954 = ReplacementRule(pattern1954, replacement1954) pattern1955 = Pattern(Integral(F_**((x_*WC('b', S(1)) + WC('a', S(0)))*WC('f', S(1))/(x_*WC('d', S(1)) + WC('c', S(0))) + WC('e', S(0)))/(x_*WC('h', S(1)) + WC('g', S(0))), x_), cons1099, cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons209, cons71, cons1129) def replacement1955(f, b, g, d, c, a, x, h, F, e): rubi.append(1955) return Dist(d/h, Int(F**(e + f*(a + b*x)/(c + d*x))/(c + d*x), x), x) - Dist((-c*h + d*g)/h, Int(F**(e + f*(a + b*x)/(c + d*x))/((c + d*x)*(g + h*x)), x), x) rule1955 = ReplacementRule(pattern1955, replacement1955) pattern1956 = Pattern(Integral(F_**((x_*WC('b', S(1)) + WC('a', S(0)))*WC('f', S(1))/(x_*WC('d', S(1)) + WC('c', S(0))) + WC('e', S(0)))*(x_*WC('h', S(1)) + WC('g', S(0)))**m_, x_), cons1099, cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons209, cons71, cons1129, cons17, cons94) def replacement1956(m, f, b, g, d, c, a, x, h, F, e): rubi.append(1956) return -Dist(f*(-a*d + b*c)*log(F)/(h*(m + S(1))), Int(F**(e + f*(a + b*x)/(c + d*x))*(g + h*x)**(m + S(1))/(c + d*x)**S(2), x), x) + Simp(F**(e + f*(a + b*x)/(c + d*x))*(g + h*x)**(m + S(1))/(h*(m + S(1))), x) rule1956 = ReplacementRule(pattern1956, replacement1956) pattern1957 = Pattern(Integral(F_**((x_*WC('b', S(1)) + WC('a', S(0)))*WC('f', S(1))/(x_*WC('d', S(1)) + WC('c', S(0))) + WC('e', S(0)))/((x_*WC('h', S(1)) + WC('g', S(0)))*(x_*WC('j', S(1)) + WC('i', S(0)))), x_), cons1099, cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons209, cons1128) def replacement1957(j, f, b, g, i, d, c, a, x, h, F, e): rubi.append(1957) return -Dist(d/(h*(-c*j + d*i)), Subst(Int(F**(e - f*x*(-a*d + b*c)/(-c*j + d*i) + f*(-a*j + b*i)/(-c*j + d*i))/x, x), x, (i + j*x)/(c + d*x)), x) rule1957 = ReplacementRule(pattern1957, replacement1957) pattern1958 = Pattern(Integral(F_**(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0))), x_), cons1099, cons2, cons3, cons7, cons1130) def replacement1958(b, c, a, x, F): rubi.append(1958) return Dist(F**(a - b**S(2)/(S(4)*c)), Int(F**((b + S(2)*c*x)**S(2)/(S(4)*c)), x), x) rule1958 = ReplacementRule(pattern1958, replacement1958) pattern1959 = Pattern(Integral(F_**v_, x_), cons1099, cons818, cons1131) def replacement1959(v, x, F): rubi.append(1959) return Int(F**ExpandToSum(v, x), x) rule1959 = ReplacementRule(pattern1959, replacement1959) pattern1960 = Pattern(Integral(F_**(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0)))*(x_*WC('e', S(1)) + WC('d', S(0))), x_), cons1099, cons2, cons3, cons7, cons27, cons48, cons1132) def replacement1960(b, d, c, a, x, F, e): rubi.append(1960) return Simp(F**(a + b*x + c*x**S(2))*e/(S(2)*c*log(F)), x) rule1960 = ReplacementRule(pattern1960, replacement1960) pattern1961 = Pattern(Integral(F_**(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0)))*(x_*WC('e', S(1)) + WC('d', S(0)))**m_, x_), cons1099, cons2, cons3, cons7, cons27, cons48, cons1132, cons31, cons166) def replacement1961(m, b, d, c, a, x, F, e): rubi.append(1961) return -Dist(e**S(2)*(m + S(-1))/(S(2)*c*log(F)), Int(F**(a + b*x + c*x**S(2))*(d + e*x)**(m + S(-2)), x), x) + Simp(F**(a + b*x + c*x**S(2))*e*(d + e*x)**(m + S(-1))/(S(2)*c*log(F)), x) rule1961 = ReplacementRule(pattern1961, replacement1961) pattern1962 = Pattern(Integral(F_**(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0)))/(x_*WC('e', S(1)) + WC('d', S(0))), x_), cons1099, cons2, cons3, cons7, cons27, cons48, cons1132) def replacement1962(b, d, c, a, x, F, e): rubi.append(1962) return Simp(F**(a - b**S(2)/(S(4)*c))*ExpIntegralEi((b + S(2)*c*x)**S(2)*log(F)/(S(4)*c))/(S(2)*e), x) rule1962 = ReplacementRule(pattern1962, replacement1962) pattern1963 = Pattern(Integral(F_**(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0)))*(x_*WC('e', S(1)) + WC('d', S(0)))**m_, x_), cons1099, cons2, cons3, cons7, cons27, cons48, cons1132, cons31, cons94) def replacement1963(m, b, d, c, a, x, F, e): rubi.append(1963) return -Dist(S(2)*c*log(F)/(e**S(2)*(m + S(1))), Int(F**(a + b*x + c*x**S(2))*(d + e*x)**(m + S(2)), x), x) + Simp(F**(a + b*x + c*x**S(2))*(d + e*x)**(m + S(1))/(e*(m + S(1))), x) rule1963 = ReplacementRule(pattern1963, replacement1963) pattern1964 = Pattern(Integral(F_**(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0)))*(x_*WC('e', S(1)) + WC('d', S(0))), x_), cons1099, cons2, cons3, cons7, cons27, cons48, cons1133) def replacement1964(b, d, c, a, x, F, e): rubi.append(1964) return -Dist((b*e - S(2)*c*d)/(S(2)*c), Int(F**(a + b*x + c*x**S(2)), x), x) + Simp(F**(a + b*x + c*x**S(2))*e/(S(2)*c*log(F)), x) rule1964 = ReplacementRule(pattern1964, replacement1964) pattern1965 = Pattern(Integral(F_**(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0)))*(x_*WC('e', S(1)) + WC('d', S(0)))**m_, x_), cons1099, cons2, cons3, cons7, cons27, cons48, cons1133, cons31, cons166) def replacement1965(m, b, d, c, a, x, F, e): rubi.append(1965) return -Dist((b*e - S(2)*c*d)/(S(2)*c), Int(F**(a + b*x + c*x**S(2))*(d + e*x)**(m + S(-1)), x), x) - Dist(e**S(2)*(m + S(-1))/(S(2)*c*log(F)), Int(F**(a + b*x + c*x**S(2))*(d + e*x)**(m + S(-2)), x), x) + Simp(F**(a + b*x + c*x**S(2))*e*(d + e*x)**(m + S(-1))/(S(2)*c*log(F)), x) rule1965 = ReplacementRule(pattern1965, replacement1965) pattern1966 = Pattern(Integral(F_**(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0)))*(x_*WC('e', S(1)) + WC('d', S(0)))**m_, x_), cons1099, cons2, cons3, cons7, cons27, cons48, cons1133, cons31, cons94) def replacement1966(m, b, d, c, a, x, F, e): rubi.append(1966) return -Dist(S(2)*c*log(F)/(e**S(2)*(m + S(1))), Int(F**(a + b*x + c*x**S(2))*(d + e*x)**(m + S(2)), x), x) - Dist((b*e - S(2)*c*d)*log(F)/(e**S(2)*(m + S(1))), Int(F**(a + b*x + c*x**S(2))*(d + e*x)**(m + S(1)), x), x) + Simp(F**(a + b*x + c*x**S(2))*(d + e*x)**(m + S(1))/(e*(m + S(1))), x) rule1966 = ReplacementRule(pattern1966, replacement1966) pattern1967 = Pattern(Integral(F_**(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0)))*(x_*WC('e', S(1)) + WC('d', S(0)))**WC('m', S(1)), x_), cons1099, cons2, cons3, cons7, cons27, cons48, cons21, cons1134) def replacement1967(m, b, d, c, a, x, F, e): rubi.append(1967) return Int(F**(a + b*x + c*x**S(2))*(d + e*x)**m, x) rule1967 = ReplacementRule(pattern1967, replacement1967) pattern1968 = Pattern(Integral(F_**v_*u_**WC('m', S(1)), x_), cons1099, cons21, cons68, cons818, cons819) def replacement1968(v, u, m, x, F): rubi.append(1968) return Int(F**ExpandToSum(v, x)*ExpandToSum(u, x)**m, x) rule1968 = ReplacementRule(pattern1968, replacement1968) def With1969(v, m, b, d, c, a, n, x, F, e): u = IntHide(F**(e*(c + d*x))*(F**v*b + a)**n, x) rubi.append(1969) return -Dist(m, Int(u*x**(m + S(-1)), x), x) + Dist(x**m, u, x) pattern1969 = Pattern(Integral(F_**((x_*WC('d', S(1)) + WC('c', S(0)))*WC('e', S(1)))*x_**WC('m', S(1))*(F_**v_*WC('b', S(1)) + WC('a', S(0)))**n_, x_), cons1099, cons2, cons3, cons7, cons27, cons48, cons1135, cons31, cons168, cons196) rule1969 = ReplacementRule(pattern1969, With1969) def With1970(f, b, g, G, d, c, n, a, x, h, F, e): if isinstance(x, (int, Integer, float, Float)): return False m = FullSimplify(g*h*log(G)/(d*e*log(F))) if And(RationalQ(m), GreaterEqual(Abs(m), S(1))): return True return False pattern1970 = Pattern(Integral(G_**((x_*WC('g', S(1)) + WC('f', S(0)))*WC('h', S(1)))*(F_**((x_*WC('d', S(1)) + WC('c', S(0)))*WC('e', S(1)))*WC('b', S(1)) + a_)**WC('n', S(1)), x_), cons1099, cons1137, cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons209, cons4, cons1136, CustomConstraint(With1970)) def replacement1970(f, b, g, G, d, c, n, a, x, h, F, e): m = FullSimplify(g*h*log(G)/(d*e*log(F))) rubi.append(1970) return Dist(G**(-c*g*h/d + f*h)*Denominator(m)/(d*e*log(F)), Subst(Int(x**(Numerator(m) + S(-1))*(a + b*x**Denominator(m))**n, x), x, F**(e*(c + d*x)/Denominator(m))), x) rule1970 = ReplacementRule(pattern1970, replacement1970) def With1971(f, b, g, G, d, c, n, a, x, h, F, e): if isinstance(x, (int, Integer, float, Float)): return False m = FullSimplify(d*e*log(F)/(g*h*log(G))) if And(RationalQ(m), Greater(Abs(m), S(1))): return True return False pattern1971 = Pattern(Integral(G_**((x_*WC('g', S(1)) + WC('f', S(0)))*WC('h', S(1)))*(F_**((x_*WC('d', S(1)) + WC('c', S(0)))*WC('e', S(1)))*WC('b', S(1)) + a_)**WC('n', S(1)), x_), cons1099, cons1137, cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons209, cons4, cons1136, CustomConstraint(With1971)) def replacement1971(f, b, g, G, d, c, n, a, x, h, F, e): m = FullSimplify(d*e*log(F)/(g*h*log(G))) rubi.append(1971) return Dist(Denominator(m)/(g*h*log(G)), Subst(Int(x**(Denominator(m) + S(-1))*(F**(c*e - d*e*f/g)*b*x**Numerator(m) + a)**n, x), x, G**(h*(f + g*x)/Denominator(m))), x) rule1971 = ReplacementRule(pattern1971, replacement1971) pattern1972 = Pattern(Integral(G_**((x_*WC('g', S(1)) + WC('f', S(0)))*WC('h', S(1)))*(F_**((x_*WC('d', S(1)) + WC('c', S(0)))*WC('e', S(1)))*WC('b', S(1)) + a_)**WC('n', S(1)), x_), cons1099, cons1137, cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons209, cons1138, cons148) def replacement1972(f, b, g, G, d, c, n, a, x, h, F, e): rubi.append(1972) return Int(G**(f*h)*G**(g*h*x)*(F**(c*e)*F**(d*e*x)*b + a)**n, x) rule1972 = ReplacementRule(pattern1972, replacement1972) pattern1973 = Pattern(Integral(G_**((x_*WC('g', S(1)) + WC('f', S(0)))*WC('h', S(1)))*(F_**((x_*WC('d', S(1)) + WC('c', S(0)))*WC('e', S(1)))*WC('b', S(1)) + a_)**n_, x_), cons1099, cons1137, cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons209, cons1138, cons196) def replacement1973(f, b, g, G, d, c, a, n, x, h, F, e): rubi.append(1973) return Simp(G**(h*(f + g*x))*a**n*Hypergeometric2F1(-n, g*h*log(G)/(d*e*log(F)), S(1) + g*h*log(G)/(d*e*log(F)), -F**(e*(c + d*x))*b/a)/(g*h*log(G)), x) rule1973 = ReplacementRule(pattern1973, replacement1973) pattern1974 = Pattern(Integral(G_**((x_*WC('g', S(1)) + WC('f', S(0)))*WC('h', S(1)))*(F_**((x_*WC('d', S(1)) + WC('c', S(0)))*WC('e', S(1)))*WC('b', S(1)) + a_)**n_, x_), cons1099, cons1137, cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons209, cons4, cons1138, cons23) def replacement1974(f, b, g, G, d, c, a, n, x, h, F, e): rubi.append(1974) return Simp(G**(h*(f + g*x))*(F**(e*(c + d*x))*b + a)**(n + S(1))*Hypergeometric2F1(S(1), n + S(1) + g*h*log(G)/(d*e*log(F)), S(1) + g*h*log(G)/(d*e*log(F)), -F**(e*(c + d*x))*b/a)/(a*g*h*log(G)), x) rule1974 = ReplacementRule(pattern1974, replacement1974) pattern1975 = Pattern(Integral(G_**(u_*WC('h', S(1)))*(F_**(v_*WC('e', S(1)))*WC('b', S(1)) + a_)**n_, x_), cons1099, cons1137, cons2, cons3, cons48, cons209, cons4, cons810, cons811) def replacement1975(v, u, b, G, a, n, x, h, F, e): rubi.append(1975) return Int(G**(h*ExpandToSum(u, x))*(F**(e*ExpandToSum(v, x))*b + a)**n, x) rule1975 = ReplacementRule(pattern1975, replacement1975) def With1976(t, f, b, g, r, G, d, c, n, a, H, x, h, s, e, F): if isinstance(x, (int, Integer, float, Float)): return False m = FullSimplify((g*h*log(G) + s*t*log(H))/(d*e*log(F))) if RationalQ(m): return True return False pattern1976 = Pattern(Integral(G_**((x_*WC('g', S(1)) + WC('f', S(0)))*WC('h', S(1)))*H_**((x_*WC('s', S(1)) + WC('r', S(0)))*WC('t', S(1)))*(F_**((x_*WC('d', S(1)) + WC('c', S(0)))*WC('e', S(1)))*WC('b', S(1)) + a_)**WC('n', S(1)), x_), cons1099, cons1137, cons1140, cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons209, cons52, cons800, cons1141, cons4, cons1139, CustomConstraint(With1976)) def replacement1976(t, f, b, g, r, G, d, c, n, a, H, x, h, s, e, F): m = FullSimplify((g*h*log(G) + s*t*log(H))/(d*e*log(F))) rubi.append(1976) return Dist(G**(-c*g*h/d + f*h)*H**(-c*s*t/d + r*t)*Denominator(m)/(d*e*log(F)), Subst(Int(x**(Numerator(m) + S(-1))*(a + b*x**Denominator(m))**n, x), x, F**(e*(c + d*x)/Denominator(m))), x) rule1976 = ReplacementRule(pattern1976, replacement1976) pattern1977 = Pattern(Integral(G_**((x_*WC('g', S(1)) + WC('f', S(0)))*WC('h', S(1)))*H_**((x_*WC('s', S(1)) + WC('r', S(0)))*WC('t', S(1)))*(F_**((x_*WC('d', S(1)) + WC('c', S(0)))*WC('e', S(1)))*WC('b', S(1)) + a_)**WC('n', S(1)), x_), cons1099, cons1137, cons1140, cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons209, cons52, cons800, cons1141, cons1142, cons85) def replacement1977(t, f, b, g, r, G, d, c, n, a, H, x, h, s, e, F): rubi.append(1977) return Dist(G**(h*(-c*g/d + f)), Int(H**(t*(r + s*x))*(b + F**(-e*(c + d*x))*a)**n, x), x) rule1977 = ReplacementRule(pattern1977, replacement1977) pattern1978 = Pattern(Integral(G_**((x_*WC('g', S(1)) + WC('f', S(0)))*WC('h', S(1)))*H_**((x_*WC('s', S(1)) + WC('r', S(0)))*WC('t', S(1)))*(F_**((x_*WC('d', S(1)) + WC('c', S(0)))*WC('e', S(1)))*WC('b', S(1)) + a_)**WC('n', S(1)), x_), cons1099, cons1137, cons1140, cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons209, cons52, cons800, cons1141, cons1143, cons148) def replacement1978(t, f, b, g, r, G, d, c, n, a, H, x, h, s, e, F): rubi.append(1978) return Int(G**(f*h)*G**(g*h*x)*H**(r*t)*H**(s*t*x)*(F**(c*e)*F**(d*e*x)*b + a)**n, x) rule1978 = ReplacementRule(pattern1978, replacement1978) pattern1979 = Pattern(Integral(G_**((x_*WC('g', S(1)) + WC('f', S(0)))*WC('h', S(1)))*H_**((x_*WC('s', S(1)) + WC('r', S(0)))*WC('t', S(1)))*(F_**((x_*WC('d', S(1)) + WC('c', S(0)))*WC('e', S(1)))*WC('b', S(1)) + a_)**n_, x_), cons1099, cons1137, cons1140, cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons209, cons52, cons800, cons1141, cons1143, cons196) def replacement1979(t, f, b, g, r, G, d, c, a, n, H, x, h, s, e, F): rubi.append(1979) return Simp(G**(h*(f + g*x))*H**(t*(r + s*x))*a**n*Hypergeometric2F1(-n, (g*h*log(G) + s*t*log(H))/(d*e*log(F)), S(1) + (g*h*log(G) + s*t*log(H))/(d*e*log(F)), -F**(e*(c + d*x))*b/a)/(g*h*log(G) + s*t*log(H)), x) rule1979 = ReplacementRule(pattern1979, replacement1979) pattern1980 = Pattern(Integral(G_**((x_*WC('g', S(1)) + WC('f', S(0)))*WC('h', S(1)))*H_**((x_*WC('s', S(1)) + WC('r', S(0)))*WC('t', S(1)))*(F_**((x_*WC('d', S(1)) + WC('c', S(0)))*WC('e', S(1)))*WC('b', S(1)) + a_)**n_, x_), cons1099, cons1137, cons1140, cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons209, cons52, cons800, cons1141, cons4, cons1143, cons23) def replacement1980(t, f, b, g, r, G, d, c, a, n, H, x, h, s, e, F): rubi.append(1980) return Simp(G**(h*(f + g*x))*H**(t*(r + s*x))*((F**(e*(c + d*x))*b + a)/a)**(-n)*(F**(e*(c + d*x))*b + a)**n*Hypergeometric2F1(-n, (g*h*log(G) + s*t*log(H))/(d*e*log(F)), S(1) + (g*h*log(G) + s*t*log(H))/(d*e*log(F)), -F**(e*(c + d*x))*b/a)/(g*h*log(G) + s*t*log(H)), x) rule1980 = ReplacementRule(pattern1980, replacement1980) pattern1981 = Pattern(Integral(G_**(u_*WC('h', S(1)))*H_**(w_*WC('t', S(1)))*(F_**(v_*WC('e', S(1)))*WC('b', S(1)) + a_)**n_, x_), cons1099, cons1137, cons1140, cons2, cons3, cons48, cons209, cons1141, cons4, cons812, cons813) def replacement1981(v, w, u, t, b, G, a, n, H, x, h, F, e): rubi.append(1981) return Int(G**(h*ExpandToSum(u, x))*H**(t*ExpandToSum(w, x))*(F**(e*ExpandToSum(v, x))*b + a)**n, x) rule1981 = ReplacementRule(pattern1981, replacement1981) pattern1982 = Pattern(Integral(F_**((x_*WC('d', S(1)) + WC('c', S(0)))*WC('e', S(1)))*(F_**((x_*WC('d', S(1)) + WC('c', S(0)))*WC('e', S(1)))*WC('b', S(1)) + x_**WC('n', S(1))*WC('a', S(1)))**WC('p', S(1)), x_), cons1099, cons2, cons3, cons7, cons27, cons48, cons4, cons5, cons54) def replacement1982(p, b, d, c, a, n, x, F, e): rubi.append(1982) return -Dist(a*n/(b*d*e*log(F)), Int(x**(n + S(-1))*(F**(e*(c + d*x))*b + a*x**n)**p, x), x) + Simp((F**(e*(c + d*x))*b + a*x**n)**(p + S(1))/(b*d*e*(p + S(1))*log(F)), x) rule1982 = ReplacementRule(pattern1982, replacement1982) pattern1983 = Pattern(Integral(F_**((x_*WC('d', S(1)) + WC('c', S(0)))*WC('e', S(1)))*x_**WC('m', S(1))*(F_**((x_*WC('d', S(1)) + WC('c', S(0)))*WC('e', S(1)))*WC('b', S(1)) + x_**WC('n', S(1))*WC('a', S(1)))**WC('p', S(1)), x_), cons1099, cons2, cons3, cons7, cons27, cons48, cons21, cons4, cons5, cons54) def replacement1983(p, m, b, d, c, a, n, x, F, e): rubi.append(1983) return -Dist(a*n/(b*d*e*log(F)), Int(x**(m + n + S(-1))*(F**(e*(c + d*x))*b + a*x**n)**p, x), x) - Dist(m/(b*d*e*(p + S(1))*log(F)), Int(x**(m + S(-1))*(F**(e*(c + d*x))*b + a*x**n)**(p + S(1)), x), x) + Simp(x**m*(F**(e*(c + d*x))*b + a*x**n)**(p + S(1))/(b*d*e*(p + S(1))*log(F)), x) rule1983 = ReplacementRule(pattern1983, replacement1983) def With1984(v, u, m, f, b, g, c, a, x, F): q = Rt(-S(4)*a*c + b**S(2), S(2)) rubi.append(1984) return Dist(S(2)*c/q, Int((f + g*x)**m/(S(2)*F**u*c + b - q), x), x) - Dist(S(2)*c/q, Int((f + g*x)**m/(S(2)*F**u*c + b + q), x), x) pattern1984 = Pattern(Integral((x_*WC('g', S(1)) + WC('f', S(0)))**WC('m', S(1))/(F_**u_*WC('b', S(1)) + F_**v_*WC('c', S(1)) + WC('a', S(0))), x_), cons1099, cons2, cons3, cons7, cons125, cons208, cons1144, cons68, cons226, cons62) rule1984 = ReplacementRule(pattern1984, With1984) def With1985(v, u, m, f, b, g, c, a, x, F): q = Rt(-S(4)*a*c + b**S(2), S(2)) rubi.append(1985) return Dist(S(2)*c/q, Int(F**u*(f + g*x)**m/(S(2)*F**u*c + b - q), x), x) - Dist(S(2)*c/q, Int(F**u*(f + g*x)**m/(S(2)*F**u*c + b + q), x), x) pattern1985 = Pattern(Integral(F_**u_*(x_*WC('g', S(1)) + WC('f', S(0)))**WC('m', S(1))/(F_**u_*WC('b', S(1)) + F_**v_*WC('c', S(1)) + WC('a', S(0))), x_), cons1099, cons2, cons3, cons7, cons125, cons208, cons1144, cons68, cons226, cons62) rule1985 = ReplacementRule(pattern1985, With1985) def With1986(v, u, m, f, b, g, i, c, a, x, h, F): q = Rt(-S(4)*a*c + b**S(2), S(2)) rubi.append(1986) return -Dist(-i + (-b*i + S(2)*c*h)/q, Int((f + g*x)**m/(S(2)*F**u*c + b + q), x), x) + Dist(i + (-b*i + S(2)*c*h)/q, Int((f + g*x)**m/(S(2)*F**u*c + b - q), x), x) pattern1986 = Pattern(Integral((F_**u_*WC('i', S(1)) + h_)*(x_*WC('g', S(1)) + WC('f', S(0)))**WC('m', S(1))/(F_**u_*WC('b', S(1)) + F_**v_*WC('c', S(1)) + WC('a', S(0))), x_), cons1099, cons2, cons3, cons7, cons125, cons208, cons209, cons224, cons1144, cons68, cons226, cons62) rule1986 = ReplacementRule(pattern1986, With1986) def With1987(v, m, b, d, c, a, x, F): u = IntHide(S(1)/(F**v*b + F**(c + d*x)*a), x) rubi.append(1987) return -Dist(m, Int(u*x**(m + S(-1)), x), x) + Simp(u*x**m, x) pattern1987 = Pattern(Integral(x_**WC('m', S(1))/(F_**v_*WC('b', S(1)) + F_**(x_*WC('d', S(1)) + WC('c', S(0)))*WC('a', S(1))), x_), cons1099, cons2, cons3, cons7, cons27, cons1145, cons31, cons168) rule1987 = ReplacementRule(pattern1987, With1987) pattern1988 = Pattern(Integral(u_/(F_**v_*WC('b', S(1)) + F_**w_*WC('c', S(1)) + a_), x_), cons1099, cons2, cons3, cons7, cons552, cons1146, cons1147, cons1148) def replacement1988(v, w, u, b, c, a, x, F): rubi.append(1988) return Int(F**v*u/(F**(S(2)*v)*b + F**v*a + c), x) rule1988 = ReplacementRule(pattern1988, replacement1988) pattern1989 = Pattern(Integral(F_**((x_*WC('e', S(1)) + WC('d', S(0)))**WC('n', S(1))*WC('g', S(1)))/(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0))), x_), cons1099, cons2, cons3, cons7, cons27, cons48, cons208, cons4, cons1149) def replacement1989(g, b, d, a, n, c, x, F, e): rubi.append(1989) return Int(ExpandIntegrand(F**(g*(d + e*x)**n), S(1)/(a + b*x + c*x**S(2)), x), x) rule1989 = ReplacementRule(pattern1989, replacement1989) pattern1990 = Pattern(Integral(F_**((x_*WC('e', S(1)) + WC('d', S(0)))**WC('n', S(1))*WC('g', S(1)))/(a_ + x_**S(2)*WC('c', S(1))), x_), cons1099, cons2, cons7, cons27, cons48, cons208, cons4, cons1150) def replacement1990(g, d, c, n, a, x, F, e): rubi.append(1990) return Int(ExpandIntegrand(F**(g*(d + e*x)**n), S(1)/(a + c*x**S(2)), x), x) rule1990 = ReplacementRule(pattern1990, replacement1990) pattern1991 = Pattern(Integral(F_**((x_*WC('e', S(1)) + WC('d', S(0)))**WC('n', S(1))*WC('g', S(1)))*u_**WC('m', S(1))/(c_*x_**S(2) + x_*WC('b', S(1)) + WC('a', S(0))), x_), cons1099, cons2, cons3, cons7, cons27, cons48, cons208, cons4, cons804, cons17) def replacement1991(u, m, g, b, d, a, n, c, x, F, e): rubi.append(1991) return Int(ExpandIntegrand(F**(g*(d + e*x)**n), u**m/(a + b*x + c*x**S(2)), x), x) rule1991 = ReplacementRule(pattern1991, replacement1991) pattern1992 = Pattern(Integral(F_**((x_*WC('e', S(1)) + WC('d', S(0)))**WC('n', S(1))*WC('g', S(1)))*u_**WC('m', S(1))/(a_ + c_*x_**S(2)), x_), cons1099, cons2, cons7, cons27, cons48, cons208, cons4, cons804, cons17) def replacement1992(u, m, g, d, a, n, c, x, F, e): rubi.append(1992) return Int(ExpandIntegrand(F**(g*(d + e*x)**n), u**m/(a + c*x**S(2)), x), x) rule1992 = ReplacementRule(pattern1992, replacement1992) pattern1993 = Pattern(Integral(F_**((x_**S(4)*WC('b', S(1)) + WC('a', S(0)))/x_**S(2)), x_), cons1099, cons2, cons3, cons1151) def replacement1993(x, a, b, F): rubi.append(1993) return -Simp(sqrt(Pi)*Erf((-x**S(2)*sqrt(-b*log(F)) + sqrt(-a*log(F)))/x)*exp(-S(2)*sqrt(-a*log(F))*sqrt(-b*log(F)))/(S(4)*sqrt(-b*log(F))), x) + Simp(sqrt(Pi)*Erf((x**S(2)*sqrt(-b*log(F)) + sqrt(-a*log(F)))/x)*exp(S(2)*sqrt(-a*log(F))*sqrt(-b*log(F)))/(S(4)*sqrt(-b*log(F))), x) rule1993 = ReplacementRule(pattern1993, replacement1993) pattern1994 = Pattern(Integral(x_**WC('m', S(1))*(x_**WC('m', S(1)) + exp(x_))**n_, x_), cons93, cons168, cons463, cons1152) def replacement1994(x, m, n): rubi.append(1994) return Dist(m, Int(x**(m + S(-1))*(x**m + exp(x))**n, x), x) + Int((x**m + exp(x))**(n + S(1)), x) - Simp((x**m + exp(x))**(n + S(1))/(n + S(1)), x) rule1994 = ReplacementRule(pattern1994, replacement1994) pattern1995 = Pattern(Integral(log(a_ + (F_**((x_*WC('d', S(1)) + WC('c', S(0)))*WC('e', S(1))))**WC('n', S(1))*WC('b', S(1))), x_), cons1099, cons2, cons3, cons7, cons27, cons48, cons4, cons43) def replacement1995(b, d, c, n, a, x, F, e): rubi.append(1995) return Dist(S(1)/(d*e*n*log(F)), Subst(Int(log(a + b*x)/x, x), x, (F**(e*(c + d*x)))**n), x) rule1995 = ReplacementRule(pattern1995, replacement1995) pattern1996 = Pattern(Integral(log(a_ + (F_**((x_*WC('d', S(1)) + WC('c', S(0)))*WC('e', S(1))))**WC('n', S(1))*WC('b', S(1))), x_), cons1099, cons2, cons3, cons7, cons27, cons48, cons4, cons448) def replacement1996(b, d, c, n, a, x, F, e): rubi.append(1996) return -Dist(b*d*e*n*log(F), Int(x*(F**(e*(c + d*x)))**n/(a + b*(F**(e*(c + d*x)))**n), x), x) + Simp(x*log(a + b*(F**(e*(c + d*x)))**n), x) rule1996 = ReplacementRule(pattern1996, replacement1996) pattern1997 = Pattern(Integral((F_**v_*WC('a', S(1)))**n_*WC('u', S(1)), x_), cons1099, cons2, cons4, cons23) def replacement1997(v, u, a, n, x, F): rubi.append(1997) return Dist(F**(-n*v)*(F**v*a)**n, Int(F**(n*v)*u, x), x) rule1997 = ReplacementRule(pattern1997, replacement1997) def With1998(x, u): v = FunctionOfExponential(u, x) rubi.append(1998) return Dist(v/D(v, x), Subst(Int(FunctionOfExponentialFunction(u, x)/x, x), x, v), x) pattern1998 = Pattern(Integral(u_, x_), cons1153) rule1998 = ReplacementRule(pattern1998, With1998) pattern1999 = Pattern(Integral((F_**v_*WC('a', S(1)) + F_**w_*WC('b', S(1)))**n_*WC('u', S(1)), x_), cons1099, cons2, cons3, cons4, cons196, cons1154) def replacement1999(v, w, u, b, a, n, x, F): rubi.append(1999) return Int(F**(n*v)*u*(F**ExpandToSum(-v + w, x)*b + a)**n, x) rule1999 = ReplacementRule(pattern1999, replacement1999) pattern2000 = Pattern(Integral((F_**v_*WC('a', S(1)) + G_**w_*WC('b', S(1)))**n_*WC('u', S(1)), x_), cons1099, cons1137, cons2, cons3, cons4, cons196, cons1154) def replacement2000(v, w, u, b, G, a, n, x, F): rubi.append(2000) return Int(F**(n*v)*u*(a + b*exp(ExpandToSum(-v*log(F) + w*log(G), x)))**n, x) rule2000 = ReplacementRule(pattern2000, replacement2000) pattern2001 = Pattern(Integral((F_**v_*WC('a', S(1)) + F_**w_*WC('b', S(1)))**n_*WC('u', S(1)), x_), cons1099, cons2, cons3, cons4, cons23, cons1154) def replacement2001(v, w, u, b, a, n, x, F): rubi.append(2001) return Dist(F**(-n*v)*(F**v*a + F**w*b)**n*(F**ExpandToSum(-v + w, x)*b + a)**(-n), Int(F**(n*v)*u*(F**ExpandToSum(-v + w, x)*b + a)**n, x), x) rule2001 = ReplacementRule(pattern2001, replacement2001) pattern2002 = Pattern(Integral((F_**v_*WC('a', S(1)) + G_**w_*WC('b', S(1)))**n_*WC('u', S(1)), x_), cons1099, cons1137, cons2, cons3, cons4, cons23, cons1154) def replacement2002(v, w, u, b, G, a, n, x, F): rubi.append(2002) return Dist(F**(-n*v)*(a + b*exp(ExpandToSum(-v*log(F) + w*log(G), x)))**(-n)*(F**v*a + G**w*b)**n, Int(F**(n*v)*u*(a + b*exp(ExpandToSum(-v*log(F) + w*log(G), x)))**n, x), x) rule2002 = ReplacementRule(pattern2002, replacement2002) pattern2003 = Pattern(Integral(F_**v_*G_**w_*WC('u', S(1)), x_), cons1099, cons1137, cons1155) def replacement2003(v, w, u, G, x, F): rubi.append(2003) return Int(u*NormalizeIntegrand(exp(v*log(F) + w*log(G)), x), x) rule2003 = ReplacementRule(pattern2003, replacement2003) def With2004(v, w, u, y, x, F): if isinstance(x, (int, Integer, float, Float)): return False z = v*y/(D(u, x)*log(F)) if ZeroQ(-w*y + D(z, x)): return True return False pattern2004 = Pattern(Integral(F_**u_*(v_ + w_)*WC('y', S(1)), x_), cons1099, cons1099, CustomConstraint(With2004)) def replacement2004(v, w, u, y, x, F): z = v*y/(D(u, x)*log(F)) rubi.append(2004) return Simp(F**u*z, x) rule2004 = ReplacementRule(pattern2004, replacement2004) def With2005(v, w, u, n, x, F): if isinstance(x, (int, Integer, float, Float)): return False z = v*D(u, x)*log(F) + (n + S(1))*D(v, x) if And(Equal(Exponent(w, x), Exponent(z, x)), ZeroQ(w*Coefficient(z, x, Exponent(z, x)) - z*Coefficient(w, x, Exponent(w, x)))): return True return False pattern2005 = Pattern(Integral(F_**u_*v_**WC('n', S(1))*w_, x_), cons1099, cons4, cons804, cons1017, cons1109, CustomConstraint(With2005)) def replacement2005(v, w, u, n, x, F): z = v*D(u, x)*log(F) + (n + S(1))*D(v, x) rubi.append(2005) return Simp(F**u*v**(n + S(1))*Coefficient(w, x, Exponent(w, x))/Coefficient(z, x, Exponent(z, x)), x) rule2005 = ReplacementRule(pattern2005, replacement2005) return [rule1901, rule1902, rule1903, rule1904, rule1905, rule1906, rule1907, rule1908, rule1909, rule1910, rule1911, rule1912, rule1913, rule1914, rule1915, rule1916, rule1917, rule1918, rule1919, rule1920, rule1921, rule1922, rule1923, rule1924, rule1925, rule1926, rule1927, rule1928, rule1929, rule1930, rule1931, rule1932, rule1933, rule1934, rule1935, rule1936, rule1937, rule1938, rule1939, rule1940, rule1941, rule1942, rule1943, rule1944, rule1945, rule1946, rule1947, rule1948, rule1949, rule1950, rule1951, rule1952, rule1953, rule1954, rule1955, rule1956, rule1957, rule1958, rule1959, rule1960, rule1961, rule1962, rule1963, rule1964, rule1965, rule1966, rule1967, rule1968, rule1969, rule1970, rule1971, rule1972, rule1973, rule1974, rule1975, rule1976, rule1977, rule1978, rule1979, rule1980, rule1981, rule1982, rule1983, rule1984, rule1985, rule1986, rule1987, rule1988, rule1989, rule1990, rule1991, rule1992, rule1993, rule1994, rule1995, rule1996, rule1997, rule1998, rule1999, rule2000, rule2001, rule2002, rule2003, rule2004, rule2005, ]
1ff79596c8df2dc186ae2a1b39bebd81906a02ab73819bfaa452f1a7203458af
''' This code is automatically generated. Never edit it manually. For details of generating the code see `rubi_parsing_guide.md` in `parsetools`. ''' from sympy.external import import_module matchpy = import_module("matchpy") from sympy.utilities.decorator import doctest_depends_on if matchpy: from matchpy import Pattern, ReplacementRule, CustomConstraint, is_match from sympy.integrals.rubi.utility_function import ( Int, Sum, Set, With, Module, Scan, MapAnd, FalseQ, ZeroQ, NegativeQ, NonzeroQ, FreeQ, NFreeQ, List, Log, PositiveQ, PositiveIntegerQ, NegativeIntegerQ, IntegerQ, IntegersQ, ComplexNumberQ, PureComplexNumberQ, RealNumericQ, PositiveOrZeroQ, NegativeOrZeroQ, FractionOrNegativeQ, NegQ, Equal, Unequal, IntPart, FracPart, RationalQ, ProductQ, SumQ, NonsumQ, Subst, First, Rest, SqrtNumberQ, SqrtNumberSumQ, LinearQ, Sqrt, ArcCosh, Coefficient, Denominator, Hypergeometric2F1, Not, Simplify, FractionalPart, IntegerPart, AppellF1, EllipticPi, EllipticE, EllipticF, ArcTan, ArcCot, ArcCoth, ArcTanh, ArcSin, ArcSinh, ArcCos, ArcCsc, ArcSec, ArcCsch, ArcSech, Sinh, Tanh, Cosh, Sech, Csch, Coth, LessEqual, Less, Greater, GreaterEqual, FractionQ, IntLinearcQ, Expand, IndependentQ, PowerQ, IntegerPowerQ, PositiveIntegerPowerQ, FractionalPowerQ, AtomQ, ExpQ, LogQ, Head, MemberQ, TrigQ, SinQ, CosQ, TanQ, CotQ, SecQ, CscQ, Sin, Cos, Tan, Cot, Sec, Csc, HyperbolicQ, SinhQ, CoshQ, TanhQ, CothQ, SechQ, CschQ, InverseTrigQ, SinCosQ, SinhCoshQ, LeafCount, Numerator, NumberQ, NumericQ, Length, ListQ, Im, Re, InverseHyperbolicQ, InverseFunctionQ, TrigHyperbolicFreeQ, InverseFunctionFreeQ, RealQ, EqQ, FractionalPowerFreeQ, ComplexFreeQ, PolynomialQ, FactorSquareFree, PowerOfLinearQ, Exponent, QuadraticQ, LinearPairQ, BinomialParts, TrinomialParts, PolyQ, EvenQ, OddQ, PerfectSquareQ, NiceSqrtAuxQ, NiceSqrtQ, Together, PosAux, PosQ, CoefficientList, ReplaceAll, ExpandLinearProduct, GCD, ContentFactor, NumericFactor, NonnumericFactors, MakeAssocList, GensymSubst, KernelSubst, ExpandExpression, Apart, SmartApart, MatchQ, PolynomialQuotientRemainder, FreeFactors, NonfreeFactors, RemoveContentAux, RemoveContent, FreeTerms, NonfreeTerms, ExpandAlgebraicFunction, CollectReciprocals, ExpandCleanup, AlgebraicFunctionQ, Coeff, LeadTerm, RemainingTerms, LeadFactor, RemainingFactors, LeadBase, LeadDegree, Numer, Denom, hypergeom, Expon, MergeMonomials, PolynomialDivide, BinomialQ, TrinomialQ, GeneralizedBinomialQ, GeneralizedTrinomialQ, FactorSquareFreeList, PerfectPowerTest, SquareFreeFactorTest, RationalFunctionQ, RationalFunctionFactors, NonrationalFunctionFactors, Reverse, RationalFunctionExponents, RationalFunctionExpand, ExpandIntegrand, SimplerQ, SimplerSqrtQ, SumSimplerQ, BinomialDegree, TrinomialDegree, CancelCommonFactors, SimplerIntegrandQ, GeneralizedBinomialDegree, GeneralizedBinomialParts, GeneralizedTrinomialDegree, GeneralizedTrinomialParts, MonomialQ, MonomialSumQ, MinimumMonomialExponent, MonomialExponent, LinearMatchQ, PowerOfLinearMatchQ, QuadraticMatchQ, CubicMatchQ, BinomialMatchQ, TrinomialMatchQ, GeneralizedBinomialMatchQ, GeneralizedTrinomialMatchQ, QuotientOfLinearsMatchQ, PolynomialTermQ, PolynomialTerms, NonpolynomialTerms, PseudoBinomialParts, NormalizePseudoBinomial, PseudoBinomialPairQ, PseudoBinomialQ, PolynomialGCD, PolyGCD, AlgebraicFunctionFactors, NonalgebraicFunctionFactors, QuotientOfLinearsP, QuotientOfLinearsParts, QuotientOfLinearsQ, Flatten, Sort, AbsurdNumberQ, AbsurdNumberFactors, NonabsurdNumberFactors, SumSimplerAuxQ, Prepend, Drop, CombineExponents, FactorInteger, FactorAbsurdNumber, SubstForInverseFunction, SubstForFractionalPower, SubstForFractionalPowerOfQuotientOfLinears, FractionalPowerOfQuotientOfLinears, SubstForFractionalPowerQ, SubstForFractionalPowerAuxQ, FractionalPowerOfSquareQ, FractionalPowerSubexpressionQ, Apply, FactorNumericGcd, MergeableFactorQ, MergeFactor, MergeFactors, TrigSimplifyQ, TrigSimplify, TrigSimplifyRecur, Order, FactorOrder, Smallest, OrderedQ, MinimumDegree, PositiveFactors, Sign, NonpositiveFactors, PolynomialInAuxQ, PolynomialInQ, ExponentInAux, ExponentIn, PolynomialInSubstAux, PolynomialInSubst, Distrib, DistributeDegree, FunctionOfPower, DivideDegreesOfFactors, MonomialFactor, FullSimplify, FunctionOfLinearSubst, FunctionOfLinear, NormalizeIntegrand, NormalizeIntegrandAux, NormalizeIntegrandFactor, NormalizeIntegrandFactorBase, NormalizeTogether, NormalizeLeadTermSigns, AbsorbMinusSign, NormalizeSumFactors, SignOfFactor, NormalizePowerOfLinear, SimplifyIntegrand, SimplifyTerm, TogetherSimplify, SmartSimplify, SubstForExpn, ExpandToSum, UnifySum, UnifyTerms, UnifyTerm, CalculusQ, FunctionOfInverseLinear, PureFunctionOfSinhQ, PureFunctionOfTanhQ, PureFunctionOfCoshQ, IntegerQuotientQ, OddQuotientQ, EvenQuotientQ, FindTrigFactor, FunctionOfSinhQ, FunctionOfCoshQ, OddHyperbolicPowerQ, FunctionOfTanhQ, FunctionOfTanhWeight, FunctionOfHyperbolicQ, SmartNumerator, SmartDenominator, SubstForAux, ActivateTrig, ExpandTrig, TrigExpand, SubstForTrig, SubstForHyperbolic, InertTrigFreeQ, LCM, SubstForFractionalPowerOfLinear, FractionalPowerOfLinear, InverseFunctionOfLinear, InertTrigQ, InertReciprocalQ, DeactivateTrig, FixInertTrigFunction, DeactivateTrigAux, PowerOfInertTrigSumQ, PiecewiseLinearQ, KnownTrigIntegrandQ, KnownSineIntegrandQ, KnownTangentIntegrandQ, KnownCotangentIntegrandQ, KnownSecantIntegrandQ, TryPureTanSubst, TryTanhSubst, TryPureTanhSubst, AbsurdNumberGCD, AbsurdNumberGCDList, ExpandTrigExpand, ExpandTrigReduce, ExpandTrigReduceAux, NormalizeTrig, TrigToExp, ExpandTrigToExp, TrigReduce, FunctionOfTrig, AlgebraicTrigFunctionQ, FunctionOfHyperbolic, FunctionOfQ, FunctionOfExpnQ, PureFunctionOfSinQ, PureFunctionOfCosQ, PureFunctionOfTanQ, PureFunctionOfCotQ, FunctionOfCosQ, FunctionOfSinQ, OddTrigPowerQ, FunctionOfTanQ, FunctionOfTanWeight, FunctionOfTrigQ, FunctionOfDensePolynomialsQ, FunctionOfLog, PowerVariableExpn, PowerVariableDegree, PowerVariableSubst, EulerIntegrandQ, FunctionOfSquareRootOfQuadratic, SquareRootOfQuadraticSubst, Divides, EasyDQ, ProductOfLinearPowersQ, Rt, NthRoot, AtomBaseQ, SumBaseQ, NegSumBaseQ, AllNegTermQ, SomeNegTermQ, TrigSquareQ, RtAux, TrigSquare, IntSum, IntTerm, Map2, ConstantFactor, SameQ, ReplacePart, CommonFactors, MostMainFactorPosition, FunctionOfExponentialQ, FunctionOfExponential, FunctionOfExponentialFunction, FunctionOfExponentialFunctionAux, FunctionOfExponentialTest, FunctionOfExponentialTestAux, stdev, rubi_test, If, IntQuadraticQ, IntBinomialQ, RectifyTangent, RectifyCotangent, Inequality, Condition, Simp, SimpHelp, SplitProduct, SplitSum, SubstFor, SubstForAux, FresnelS, FresnelC, Erfc, Erfi, Gamma, FunctionOfTrigOfLinearQ, ElementaryFunctionQ, Complex, UnsameQ, _SimpFixFactor, SimpFixFactor, _FixSimplify, FixSimplify, _SimplifyAntiderivativeSum, SimplifyAntiderivativeSum, _SimplifyAntiderivative, SimplifyAntiderivative, _TrigSimplifyAux, TrigSimplifyAux, Cancel, Part, PolyLog, D, Dist, Sum_doit, PolynomialQuotient, Floor, PolynomialRemainder, Factor, PolyLog, CosIntegral, SinIntegral, LogIntegral, SinhIntegral, CoshIntegral, Rule, Erf, PolyGamma, ExpIntegralEi, ExpIntegralE, LogGamma , UtilityOperator, Factorial, Zeta, ProductLog, DerivativeDivides, HypergeometricPFQ, IntHide, OneQ, Null, rubi_exp as exp, rubi_log as log, Discriminant, Negative, Quotient ) from sympy import (Integral, S, sqrt, And, Or, Integer, Float, Mod, I, Abs, simplify, Mul, Add, Pow, sign, EulerGamma) from sympy.integrals.rubi.symbol import WC from sympy.core.symbol import symbols, Symbol from sympy.functions import (sin, cos, tan, cot, csc, sec, sqrt, erf) from sympy.functions.elementary.hyperbolic import (acosh, asinh, atanh, acoth, acsch, asech, cosh, sinh, tanh, coth, sech, csch) from sympy.functions.elementary.trigonometric import (atan, acsc, asin, acot, acos, asec, atan2) from sympy import pi as Pi A_, B_, C_, F_, G_, H_, a_, b_, c_, d_, e_, f_, g_, h_, i_, j_, k_, l_, m_, n_, p_, q_, r_, t_, u_, v_, s_, w_, x_, y_, z_ = [WC(i) for i in 'ABCFGHabcdefghijklmnpqrtuvswxyz'] a1_, a2_, b1_, b2_, c1_, c2_, d1_, d2_, n1_, n2_, e1_, e2_, f1_, f2_, g1_, g2_, n1_, n2_, n3_, Pq_, Pm_, Px_, Qm_, Qr_, Qx_, jn_, mn_, non2_, RFx_, RGx_ = [WC(i) for i in ['a1', 'a2', 'b1', 'b2', 'c1', 'c2', 'd1', 'd2', 'n1', 'n2', 'e1', 'e2', 'f1', 'f2', 'g1', 'g2', 'n1', 'n2', 'n3', 'Pq', 'Pm', 'Px', 'Qm', 'Qr', 'Qx', 'jn', 'mn', 'non2', 'RFx', 'RGx']] i, ii , Pqq, Q, R, r, C, k, u = symbols('i ii Pqq Q R r C k u') _UseGamma = False ShowSteps = False StepCounter = None def linear_products(rubi): from sympy.integrals.rubi.constraints import cons66, cons21, cons67, cons2, cons3, cons68, cons69, cons70, cons7, cons27, cons71, cons72, cons4, cons73, cons74, cons75, cons43, cons76, cons77, cons78, cons79, cons80, cons81, cons82, cons62, cons83, cons84, cons85, cons86, cons87, cons88, cons89, cons90, cons91, cons92, cons23, cons93, cons94, cons95, cons96, cons97, cons98, cons99, cons100, cons101, cons102, cons103, cons104, cons105, cons106, cons31, cons107, cons108, cons109, cons110, cons111, cons112, cons113, cons114, cons18, cons115, cons116, cons117, cons118, cons119, cons120, cons121, cons122, cons123, cons124, cons17, cons48, cons125, cons5, cons126, cons127, cons128, cons129, cons130, cons131, cons132, cons133, cons134, cons135, cons54, cons136, cons13, cons137, cons138, cons12, cons139, cons140, cons141, cons142, cons143, cons144, cons38, cons145, cons146, cons147, cons148, cons149, cons150, cons151, cons152, cons153, cons154, cons155, cons156, cons157, cons158, cons159, cons160, cons161, cons162, cons163, cons164, cons165, cons166, cons167, cons168, cons169, cons170, cons171, cons172, cons173, cons174, cons175, cons176, cons177, cons178, cons179, cons180, cons181, cons182, cons183, cons184, cons185, cons186, cons187, cons188, cons189, cons190, cons191, cons192, cons193, cons194, cons195, cons196, cons197, cons198, cons199, cons200, cons201, cons202, cons203, cons204, cons205, cons206, cons207, cons208, cons209, cons210, cons211, cons212, cons213, cons214, cons215, cons216, cons217, cons218, cons219, cons50, cons220, cons221, cons222, cons223, cons224, cons52 pattern37 = Pattern(Integral(S(1)/x_, x_)) def replacement37(x): rubi.append(37) return Simp(log(x), x) rule37 = ReplacementRule(pattern37, replacement37) pattern38 = Pattern(Integral(x_**WC('m', S(1)), x_), cons21, cons66) def replacement38(x, m): rubi.append(38) return Simp(x**(m + S(1))/(m + S(1)), x) rule38 = ReplacementRule(pattern38, replacement38) pattern39 = Pattern(Integral(S(1)/(a_ + x_*WC('b', S(1))), x_), cons2, cons3, cons67) def replacement39(x, a, b): rubi.append(39) return Simp(log(RemoveContent(a + b*x, x))/b, x) rule39 = ReplacementRule(pattern39, replacement39) pattern40 = Pattern(Integral((x_*WC('b', S(1)) + WC('a', S(0)))**m_, x_), cons2, cons3, cons21, cons66) def replacement40(x, m, a, b): rubi.append(40) return Simp((a + b*x)**(m + S(1))/(b*(m + S(1))), x) rule40 = ReplacementRule(pattern40, replacement40) pattern41 = Pattern(Integral((u_*WC('b', S(1)) + WC('a', S(0)))**m_, x_), cons2, cons3, cons21, cons68, cons69) def replacement41(u, m, b, a, x): rubi.append(41) return Dist(S(1)/Coefficient(u, x, S(1)), Subst(Int((a + b*x)**m, x), x, u), x) rule41 = ReplacementRule(pattern41, replacement41) pattern42 = Pattern(Integral(S(1)/((a_ + x_*WC('b', S(1)))*(c_ + x_*WC('d', S(1)))), x_), cons2, cons3, cons7, cons27, cons70) def replacement42(b, d, c, a, x): rubi.append(42) return Int(S(1)/(a*c + b*d*x**S(2)), x) rule42 = ReplacementRule(pattern42, replacement42) pattern43 = Pattern(Integral(S(1)/((x_*WC('b', S(1)) + WC('a', S(0)))*(x_*WC('d', S(1)) + WC('c', S(0)))), x_), cons2, cons3, cons7, cons27, cons71) def replacement43(b, d, c, a, x): rubi.append(43) return Dist(b/(-a*d + b*c), Int(S(1)/(a + b*x), x), x) - Dist(d/(-a*d + b*c), Int(S(1)/(c + d*x), x), x) rule43 = ReplacementRule(pattern43, replacement43) pattern44 = Pattern(Integral((c_ + x_*WC('d', S(1)))**n_*(x_*WC('b', S(1)) + WC('a', S(0)))**WC('m', S(1)), x_), cons2, cons3, cons7, cons27, cons21, cons4, cons71, cons72, cons66) def replacement44(m, b, d, a, c, n, x): rubi.append(44) return Simp((a + b*x)**(m + S(1))*(c + d*x)**(n + S(1))/((m + S(1))*(-a*d + b*c)), x) rule44 = ReplacementRule(pattern44, replacement44) pattern45 = Pattern(Integral((a_ + x_*WC('b', S(1)))**m_*(c_ + x_*WC('d', S(1)))**m_, x_), cons2, cons3, cons7, cons27, cons70, cons73) def replacement45(m, b, d, a, c, x): rubi.append(45) return Dist(S(2)*a*c*m/(S(2)*m + S(1)), Int((a + b*x)**(m + S(-1))*(c + d*x)**(m + S(-1)), x), x) + Simp(x*(a + b*x)**m*(c + d*x)**m/(S(2)*m + S(1)), x) rule45 = ReplacementRule(pattern45, replacement45) pattern46 = Pattern(Integral(S(1)/((a_ + x_*WC('b', S(1)))**(S(3)/2)*(c_ + x_*WC('d', S(1)))**(S(3)/2)), x_), cons2, cons3, cons7, cons27, cons70) def replacement46(b, d, c, a, x): rubi.append(46) return Simp(x/(a*c*sqrt(a + b*x)*sqrt(c + d*x)), x) rule46 = ReplacementRule(pattern46, replacement46) pattern47 = Pattern(Integral((a_ + x_*WC('b', S(1)))**m_*(c_ + x_*WC('d', S(1)))**m_, x_), cons2, cons3, cons7, cons27, cons70, cons74) def replacement47(m, b, d, a, c, x): rubi.append(47) return Dist((S(2)*m + S(3))/(S(2)*a*c*(m + S(1))), Int((a + b*x)**(m + S(1))*(c + d*x)**(m + S(1)), x), x) - Simp(x*(a + b*x)**(m + S(1))*(c + d*x)**(m + S(1))/(S(2)*a*c*(m + S(1))), x) rule47 = ReplacementRule(pattern47, replacement47) pattern48 = Pattern(Integral((a_ + x_*WC('b', S(1)))**WC('m', S(1))*(c_ + x_*WC('d', S(1)))**WC('m', S(1)), x_), cons2, cons3, cons7, cons27, cons21, cons70, cons75) def replacement48(m, b, d, a, c, x): rubi.append(48) return Int((a*c + b*d*x**S(2))**m, x) rule48 = ReplacementRule(pattern48, replacement48) pattern49 = Pattern(Integral(S(1)/(sqrt(a_ + x_*WC('b', S(1)))*sqrt(c_ + x_*WC('d', S(1)))), x_), cons2, cons3, cons7, cons27, cons70, cons43, cons76) def replacement49(b, d, c, a, x): rubi.append(49) return Simp(acosh(b*x/a)/b, x) rule49 = ReplacementRule(pattern49, replacement49) pattern50 = Pattern(Integral(S(1)/(sqrt(a_ + x_*WC('b', S(1)))*sqrt(c_ + x_*WC('d', S(1)))), x_), cons2, cons3, cons7, cons27, cons70) def replacement50(b, d, c, a, x): rubi.append(50) return Dist(S(2), Subst(Int(S(1)/(b - d*x**S(2)), x), x, sqrt(a + b*x)/sqrt(c + d*x)), x) rule50 = ReplacementRule(pattern50, replacement50) pattern51 = Pattern(Integral((a_ + x_*WC('b', S(1)))**m_*(c_ + x_*WC('d', S(1)))**m_, x_), cons2, cons3, cons7, cons27, cons21, cons70, cons77) def replacement51(m, b, d, a, c, x): rubi.append(51) return Dist((a + b*x)**FracPart(m)*(c + d*x)**FracPart(m)*(a*c + b*d*x**S(2))**(-FracPart(m)), Int((a*c + b*d*x**S(2))**m, x), x) rule51 = ReplacementRule(pattern51, replacement51) pattern52 = Pattern(Integral(S(1)/((a_ + x_*WC('b', S(1)))**(S(5)/4)*(c_ + x_*WC('d', S(1)))**(S(1)/4)), x_), cons2, cons3, cons7, cons27, cons70, cons78) def replacement52(b, d, c, a, x): rubi.append(52) return Dist((-a*d + b*c)/(S(2)*b), Int(S(1)/((a + b*x)**(S(5)/4)*(c + d*x)**(S(5)/4)), x), x) + Simp(-S(2)/(b*(a + b*x)**(S(1)/4)*(c + d*x)**(S(1)/4)), x) rule52 = ReplacementRule(pattern52, replacement52) pattern53 = Pattern(Integral(S(1)/((a_ + x_*WC('b', S(1)))**(S(9)/4)*(c_ + x_*WC('d', S(1)))**(S(1)/4)), x_), cons2, cons3, cons7, cons27, cons70, cons78) def replacement53(b, d, c, a, x): rubi.append(53) return -Dist(d/(S(5)*b), Int(S(1)/((a + b*x)**(S(5)/4)*(c + d*x)**(S(5)/4)), x), x) + Simp(-S(4)/(S(5)*b*(a + b*x)**(S(5)/4)*(c + d*x)**(S(1)/4)), x) rule53 = ReplacementRule(pattern53, replacement53) pattern54 = Pattern(Integral((a_ + x_*WC('b', S(1)))**m_*(c_ + x_*WC('d', S(1)))**n_, x_), cons2, cons3, cons7, cons27, cons70, cons79, cons80, cons81) def replacement54(m, b, d, a, c, n, x): rubi.append(54) return Dist(S(2)*c*n/(m + n + S(1)), Int((a + b*x)**m*(c + d*x)**(n + S(-1)), x), x) + Simp((a + b*x)**(m + S(1))*(c + d*x)**n/(b*(m + n + S(1))), x) rule54 = ReplacementRule(pattern54, replacement54) pattern55 = Pattern(Integral((a_ + x_*WC('b', S(1)))**m_*(c_ + x_*WC('d', S(1)))**n_, x_), cons2, cons3, cons7, cons27, cons70, cons79, cons80, cons82) def replacement55(m, b, d, a, c, n, x): rubi.append(55) return Dist((m + n + S(2))/(S(2)*a*(m + S(1))), Int((a + b*x)**(m + S(1))*(c + d*x)**n, x), x) - Simp((a + b*x)**(m + S(1))*(c + d*x)**(n + S(1))/(S(2)*a*d*(m + S(1))), x) rule55 = ReplacementRule(pattern55, replacement55) pattern56 = Pattern(Integral((x_*WC('b', S(1)) + WC('a', S(0)))**WC('m', S(1))*(x_*WC('d', S(1)) + WC('c', S(0)))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons4, cons71, cons62, cons83) def replacement56(m, b, d, a, c, n, x): rubi.append(56) return Int(ExpandIntegrand((a + b*x)**m*(c + d*x)**n, x), x) rule56 = ReplacementRule(pattern56, replacement56) pattern57 = Pattern(Integral((a_ + x_*WC('b', S(1)))**WC('m', S(1))*(x_*WC('d', S(1)) + WC('c', S(0)))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons4, cons71, cons84, cons85, cons86) def replacement57(m, b, d, c, n, a, x): rubi.append(57) return Int(ExpandIntegrand((a + b*x)**m*(c + d*x)**n, x), x) rule57 = ReplacementRule(pattern57, replacement57) pattern58 = Pattern(Integral((x_*WC('d', S(1)) + WC('c', S(0)))**n_/(x_*WC('b', S(1)) + WC('a', S(0))), x_), cons2, cons3, cons7, cons27, cons71, cons87, cons88) def replacement58(b, d, c, a, n, x): rubi.append(58) return Dist((-a*d + b*c)/b, Int((c + d*x)**(n + S(-1))/(a + b*x), x), x) + Simp((c + d*x)**n/(b*n), x) rule58 = ReplacementRule(pattern58, replacement58) pattern59 = Pattern(Integral((x_*WC('d', S(1)) + WC('c', S(0)))**n_/(x_*WC('b', S(1)) + WC('a', S(0))), x_), cons2, cons3, cons7, cons27, cons71, cons87, cons89) def replacement59(b, d, c, a, n, x): rubi.append(59) return Dist(b/(-a*d + b*c), Int((c + d*x)**(n + S(1))/(a + b*x), x), x) - Simp((c + d*x)**(n + S(1))/((n + S(1))*(-a*d + b*c)), x) rule59 = ReplacementRule(pattern59, replacement59) def With60(b, d, c, a, x): q = Rt((-a*d + b*c)/b, S(3)) rubi.append(60) return Dist(S(3)/(S(2)*b), Subst(Int(S(1)/(q**S(2) + q*x + x**S(2)), x), x, (c + d*x)**(S(1)/3)), x) - Dist(S(3)/(S(2)*b*q), Subst(Int(S(1)/(q - x), x), x, (c + d*x)**(S(1)/3)), x) - Simp(log(RemoveContent(a + b*x, x))/(S(2)*b*q), x) pattern60 = Pattern(Integral(S(1)/((x_*WC('b', S(1)) + WC('a', S(0)))*(x_*WC('d', S(1)) + WC('c', S(0)))**(S(1)/3)), x_), cons2, cons3, cons7, cons27, cons90) rule60 = ReplacementRule(pattern60, With60) def With61(b, d, c, a, x): q = Rt(-(-a*d + b*c)/b, S(3)) rubi.append(61) return Dist(S(3)/(S(2)*b), Subst(Int(S(1)/(q**S(2) - q*x + x**S(2)), x), x, (c + d*x)**(S(1)/3)), x) - Dist(S(3)/(S(2)*b*q), Subst(Int(S(1)/(q + x), x), x, (c + d*x)**(S(1)/3)), x) + Simp(log(RemoveContent(a + b*x, x))/(S(2)*b*q), x) pattern61 = Pattern(Integral(S(1)/((x_*WC('b', S(1)) + WC('a', S(0)))*(x_*WC('d', S(1)) + WC('c', S(0)))**(S(1)/3)), x_), cons2, cons3, cons7, cons27, cons91) rule61 = ReplacementRule(pattern61, With61) def With62(b, d, c, a, x): q = Rt((-a*d + b*c)/b, S(3)) rubi.append(62) return -Dist(S(3)/(S(2)*b*q**S(2)), Subst(Int(S(1)/(q - x), x), x, (c + d*x)**(S(1)/3)), x) - Dist(S(3)/(S(2)*b*q), Subst(Int(S(1)/(q**S(2) + q*x + x**S(2)), x), x, (c + d*x)**(S(1)/3)), x) - Simp(log(RemoveContent(a + b*x, x))/(S(2)*b*q**S(2)), x) pattern62 = Pattern(Integral(S(1)/((x_*WC('b', S(1)) + WC('a', S(0)))*(x_*WC('d', S(1)) + WC('c', S(0)))**(S(2)/3)), x_), cons2, cons3, cons7, cons27, cons90) rule62 = ReplacementRule(pattern62, With62) def With63(b, d, c, a, x): q = Rt(-(-a*d + b*c)/b, S(3)) rubi.append(63) return Dist(S(3)/(S(2)*b*q**S(2)), Subst(Int(S(1)/(q + x), x), x, (c + d*x)**(S(1)/3)), x) + Dist(S(3)/(S(2)*b*q), Subst(Int(S(1)/(q**S(2) - q*x + x**S(2)), x), x, (c + d*x)**(S(1)/3)), x) - Simp(log(RemoveContent(a + b*x, x))/(S(2)*b*q**S(2)), x) pattern63 = Pattern(Integral(S(1)/((x_*WC('b', S(1)) + WC('a', S(0)))*(x_*WC('d', S(1)) + WC('c', S(0)))**(S(2)/3)), x_), cons2, cons3, cons7, cons27, cons91) rule63 = ReplacementRule(pattern63, With63) def With64(b, d, c, a, n, x): p = Denominator(n) rubi.append(64) return Dist(p, Subst(Int(x**(p*(n + S(1)) + S(-1))/(a*d - b*c + b*x**p), x), x, (c + d*x)**(S(1)/p)), x) pattern64 = Pattern(Integral((x_*WC('d', S(1)) + WC('c', S(0)))**n_/(x_*WC('b', S(1)) + WC('a', S(0))), x_), cons2, cons3, cons7, cons27, cons71, cons87, cons92) rule64 = ReplacementRule(pattern64, With64) pattern65 = Pattern(Integral((c_ + x_*WC('d', S(1)))**n_/x_, x_), cons7, cons27, cons4, cons23) def replacement65(d, x, n, c): rubi.append(65) return -Simp((c + d*x)**(n + S(1))*Hypergeometric2F1(S(1), n + S(1), n + S(2), S(1) + d*x/c)/(c*(n + S(1))), x) rule65 = ReplacementRule(pattern65, replacement65) pattern66 = Pattern(Integral((x_*WC('d', S(1)) + WC('c', S(0)))**n_/(a_ + x_*WC('b', S(1))), x_), cons2, cons3, cons7, cons27, cons4, cons71, cons23) def replacement66(b, d, c, a, n, x): rubi.append(66) return -Simp((c + d*x)**(n + S(1))*Hypergeometric2F1(S(1), n + S(1), n + S(2), TogetherSimplify(b*(c + d*x)/(-a*d + b*c)))/((n + S(1))*(-a*d + b*c)), x) rule66 = ReplacementRule(pattern66, replacement66) pattern67 = Pattern(Integral((x_*WC('b', S(1)) + WC('a', S(0)))**m_*(x_*WC('d', S(1)) + WC('c', S(0)))**n_, x_), cons2, cons3, cons7, cons27, cons71, cons93, cons94, cons88, cons95, cons96, cons97) def replacement67(m, b, d, c, a, n, x): rubi.append(67) return -Dist(d*n/(b*(m + S(1))), Int((a + b*x)**(m + S(1))*(c + d*x)**(n + S(-1)), x), x) + Simp((a + b*x)**(m + S(1))*(c + d*x)**n/(b*(m + S(1))), x) rule67 = ReplacementRule(pattern67, replacement67) pattern68 = Pattern(Integral((x_*WC('b', S(1)) + WC('a', S(0)))**m_*(x_*WC('d', S(1)) + WC('c', S(0)))**n_, x_), cons2, cons3, cons7, cons27, cons71, cons93, cons94, cons98, cons97) def replacement68(m, b, d, c, a, n, x): rubi.append(68) return -Dist(d*(m + n + S(2))/((m + S(1))*(-a*d + b*c)), Int((a + b*x)**(m + S(1))*(c + d*x)**n, x), x) + Simp((a + b*x)**(m + S(1))*(c + d*x)**(n + S(1))/((m + S(1))*(-a*d + b*c)), x) rule68 = ReplacementRule(pattern68, replacement68) pattern69 = Pattern(Integral((x_*WC('b', S(1)) + WC('a', S(0)))**m_*(x_*WC('d', S(1)) + WC('c', S(0)))**n_, x_), cons2, cons3, cons7, cons27, cons71, cons93, cons88, cons99, cons100, cons101, cons97) def replacement69(m, b, d, c, a, n, x): rubi.append(69) return Dist(n*(-a*d + b*c)/(b*(m + n + S(1))), Int((a + b*x)**m*(c + d*x)**(n + S(-1)), x), x) + Simp((a + b*x)**(m + S(1))*(c + d*x)**n/(b*(m + n + S(1))), x) rule69 = ReplacementRule(pattern69, replacement69) pattern70 = Pattern(Integral(S(1)/(sqrt(a_ + x_*WC('b', S(1)))*sqrt(x_*WC('d', S(1)) + WC('c', S(0)))), x_), cons2, cons3, cons7, cons27, cons102, cons103) def replacement70(b, d, c, a, x): rubi.append(70) return Int(S(1)/sqrt(a*c - b**S(2)*x**S(2) - b*x*(a - c)), x) rule70 = ReplacementRule(pattern70, replacement70) pattern71 = Pattern(Integral(S(1)/(sqrt(x_*WC('b', S(1)) + WC('a', S(0)))*sqrt(x_*WC('d', S(1)) + WC('c', S(0)))), x_), cons2, cons3, cons7, cons27, cons104, cons105) def replacement71(b, d, c, a, x): rubi.append(71) return Dist(S(2)/sqrt(b), Subst(Int(S(1)/sqrt(-a*d + b*c + d*x**S(2)), x), x, sqrt(a + b*x)), x) rule71 = ReplacementRule(pattern71, replacement71) pattern72 = Pattern(Integral(S(1)/(sqrt(c_ + x_*WC('d', S(1)))*sqrt(x_*WC('b', S(1)) + WC('a', S(0)))), x_), cons2, cons3, cons7, cons27, cons71, cons106) def replacement72(b, d, c, a, x): rubi.append(72) return Dist(S(2)/b, Subst(Int(S(1)/sqrt(-a + c + x**S(2)), x), x, sqrt(a + b*x)), x) rule72 = ReplacementRule(pattern72, replacement72) pattern73 = Pattern(Integral(S(1)/(sqrt(x_*WC('b', S(1)) + WC('a', S(0)))*sqrt(x_*WC('d', S(1)) + WC('c', S(0)))), x_), cons2, cons3, cons7, cons27, cons71) def replacement73(b, d, c, a, x): rubi.append(73) return Dist(S(2), Subst(Int(S(1)/(b - d*x**S(2)), x), x, sqrt(a + b*x)/sqrt(c + d*x)), x) rule73 = ReplacementRule(pattern73, replacement73) pattern74 = Pattern(Integral((c_ + x_*WC('d', S(1)))**m_*(x_*WC('b', S(1)) + WC('a', S(0)))**m_, x_), cons2, cons3, cons7, cons27, cons71, cons31, cons107, cons108) def replacement74(m, b, d, a, c, x): rubi.append(74) return Dist((a + b*x)**m*(c + d*x)**m*(a*c + b*d*x**S(2) + x*(a*d + b*c))**(-m), Int((a*c + b*d*x**S(2) + x*(a*d + b*c))**m, x), x) rule74 = ReplacementRule(pattern74, replacement74) def With75(b, d, c, a, x): q = Rt(d/b, S(3)) rubi.append(75) return -Simp(q*log(c + d*x)/(S(2)*d), x) - Simp(S(3)*q*log(q*(a + b*x)**(S(1)/3)/(c + d*x)**(S(1)/3) + S(-1))/(S(2)*d), x) - Simp(sqrt(S(3))*q*ArcTan(S(2)*sqrt(S(3))*q*(a + b*x)**(S(1)/3)/(S(3)*(c + d*x)**(S(1)/3)) + sqrt(S(3))/S(3))/d, x) pattern75 = Pattern(Integral(S(1)/((x_*WC('b', S(1)) + WC('a', S(0)))**(S(1)/3)*(x_*WC('d', S(1)) + WC('c', S(0)))**(S(2)/3)), x_), cons2, cons3, cons7, cons27, cons71, cons109) rule75 = ReplacementRule(pattern75, With75) def With76(b, d, c, a, x): q = Rt(-d/b, S(3)) rubi.append(76) return Simp(q*log(c + d*x)/(S(2)*d), x) + Simp(S(3)*q*log(q*(a + b*x)**(S(1)/3)/(c + d*x)**(S(1)/3) + S(1))/(S(2)*d), x) + Simp(sqrt(S(3))*q*ArcTan(-S(2)*sqrt(S(3))*q*(a + b*x)**(S(1)/3)/(S(3)*(c + d*x)**(S(1)/3)) + sqrt(S(3))/S(3))/d, x) pattern76 = Pattern(Integral(S(1)/((x_*WC('b', S(1)) + WC('a', S(0)))**(S(1)/3)*(x_*WC('d', S(1)) + WC('c', S(0)))**(S(2)/3)), x_), cons2, cons3, cons7, cons27, cons71, cons110) rule76 = ReplacementRule(pattern76, With76) def With77(m, b, d, c, a, n, x): p = Denominator(m) rubi.append(77) return Dist(p, Subst(Int(x**(p*(m + S(1)) + S(-1))/(b - d*x**p), x), x, (a + b*x)**(S(1)/p)*(c + d*x)**(-S(1)/p)), x) pattern77 = Pattern(Integral((x_*WC('b', S(1)) + WC('a', S(0)))**m_*(x_*WC('d', S(1)) + WC('c', S(0)))**n_, x_), cons2, cons3, cons7, cons27, cons71, cons93, cons107, cons111) rule77 = ReplacementRule(pattern77, With77) def With78(m, b, d, c, a, n, x): p = Denominator(m) rubi.append(78) return Dist(p/b, Subst(Int(x**(p*(m + S(1)) + S(-1))*(-a*d/b + c + d*x**p/b)**n, x), x, (a + b*x)**(S(1)/p)), x) pattern78 = Pattern(Integral((x_*WC('b', S(1)) + WC('a', S(0)))**m_*(x_*WC('d', S(1)) + WC('c', S(0)))**n_, x_), cons2, cons3, cons7, cons27, cons71, cons93, cons107, cons92, cons112, cons97) rule78 = ReplacementRule(pattern78, With78) pattern79 = Pattern(Integral((x_*WC('b', S(1)) + WC('a', S(0)))**m_*(x_*WC('d', S(1)) + WC('c', S(0)))**n_, x_), cons2, cons3, cons7, cons27, cons21, cons4, cons71, cons113, cons66, cons114) def replacement79(m, b, d, c, a, n, x): rubi.append(79) return -Dist(d*(m + n + S(2))/((m + S(1))*(-a*d + b*c)), Int((a + b*x)**(m + S(1))*(c + d*x)**n, x), x) + Simp((a + b*x)**(m + S(1))*(c + d*x)**(n + S(1))/((m + S(1))*(-a*d + b*c)), x) rule79 = ReplacementRule(pattern79, replacement79) pattern80 = Pattern(Integral((x_*WC('b', S(1)))**m_*(c_ + x_*WC('d', S(1)))**n_, x_), cons3, cons7, cons27, cons21, cons4, cons18, cons115) def replacement80(m, b, d, c, n, x): rubi.append(80) return Simp(c**n*(b*x)**(m + S(1))*Hypergeometric2F1(-n, m + S(1), m + S(2), -d*x/c)/(b*(m + S(1))), x) rule80 = ReplacementRule(pattern80, replacement80) pattern81 = Pattern(Integral((x_*WC('b', S(1)))**m_*(c_ + x_*WC('d', S(1)))**n_, x_), cons3, cons7, cons27, cons21, cons4, cons23, cons116) def replacement81(m, b, d, c, n, x): rubi.append(81) return Simp((-d/(b*c))**(-m)*(c + d*x)**(n + S(1))*Hypergeometric2F1(-m, n + S(1), n + S(2), S(1) + d*x/c)/(d*(n + S(1))), x) rule81 = ReplacementRule(pattern81, replacement81) pattern82 = Pattern(Integral((x_*WC('b', S(1)))**m_*(c_ + x_*WC('d', S(1)))**n_, x_), cons3, cons7, cons27, cons21, cons4, cons18, cons23, cons117, cons118, cons119) def replacement82(m, b, d, c, n, x): rubi.append(82) return Dist(c**IntPart(n)*(S(1) + d*x/c)**(-FracPart(n))*(c + d*x)**FracPart(n), Int((b*x)**m*(S(1) + d*x/c)**n, x), x) rule82 = ReplacementRule(pattern82, replacement82) pattern83 = Pattern(Integral((x_*WC('b', S(1)))**m_*(c_ + x_*WC('d', S(1)))**n_, x_), cons3, cons7, cons27, cons21, cons4, cons18, cons23, cons117, cons118) def replacement83(m, b, d, c, n, x): rubi.append(83) return Dist((b*x)**FracPart(m)*(-b*c/d)**IntPart(m)*(-d*x/c)**(-FracPart(m)), Int((-d*x/c)**m*(c + d*x)**n, x), x) rule83 = ReplacementRule(pattern83, replacement83) pattern84 = Pattern(Integral((a_ + x_*WC('b', S(1)))**m_*(c_ + x_*WC('d', S(1)))**n_, x_), cons2, cons3, cons7, cons27, cons21, cons71, cons18, cons85) def replacement84(m, b, d, a, c, n, x): rubi.append(84) return Simp(b**(-n + S(-1))*(a + b*x)**(m + S(1))*(-a*d + b*c)**n*Hypergeometric2F1(-n, m + S(1), m + S(2), -d*(a + b*x)/(-a*d + b*c))/(m + S(1)), x) rule84 = ReplacementRule(pattern84, replacement84) pattern85 = Pattern(Integral((a_ + x_*WC('b', S(1)))**m_*(c_ + x_*WC('d', S(1)))**n_, x_), cons2, cons3, cons7, cons27, cons21, cons4, cons71, cons18, cons23, cons120, cons121) def replacement85(m, b, d, a, c, n, x): rubi.append(85) return Simp((b/(-a*d + b*c))**(-n)*(a + b*x)**(m + S(1))*Hypergeometric2F1(-n, m + S(1), m + S(2), -d*(a + b*x)/(-a*d + b*c))/(b*(m + S(1))), x) rule85 = ReplacementRule(pattern85, replacement85) pattern86 = Pattern(Integral((a_ + x_*WC('b', S(1)))**m_*(c_ + x_*WC('d', S(1)))**n_, x_), cons2, cons3, cons7, cons27, cons21, cons4, cons71, cons18, cons23, cons122) def replacement86(m, b, d, a, c, n, x): rubi.append(86) return Dist((b/(-a*d + b*c))**(-IntPart(n))*(b*(c + d*x)/(-a*d + b*c))**(-FracPart(n))*(c + d*x)**FracPart(n), Int((a + b*x)**m*(b*c/(-a*d + b*c) + b*d*x/(-a*d + b*c))**n, x), x) rule86 = ReplacementRule(pattern86, replacement86) pattern87 = Pattern(Integral((u_*WC('b', S(1)) + WC('a', S(0)))**WC('m', S(1))*(u_*WC('d', S(1)) + WC('c', S(0)))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons21, cons4, cons68, cons123) def replacement87(u, m, b, d, a, c, n, x): rubi.append(87) return Dist(S(1)/Coefficient(u, x, S(1)), Subst(Int((a + b*x)**m*(c + d*x)**n, x), x, u), x) rule87 = ReplacementRule(pattern87, replacement87) pattern88 = Pattern(Integral((a_ + x_*WC('b', S(1)))**WC('m', S(1))*(c_ + x_*WC('d', S(1)))**WC('n', S(1))*(x_*WC('f', S(1)) + WC('e', S(0)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons4, cons5, cons70, cons124, cons17) def replacement88(p, m, f, b, d, a, n, c, x, e): rubi.append(88) return Int((e + f*x)**p*(a*c + b*d*x**S(2))**m, x) rule88 = ReplacementRule(pattern88, replacement88) pattern89 = Pattern(Integral((x_*WC('b', S(1)) + WC('a', S(0)))*(x_*WC('d', S(1)) + WC('c', S(0)))**WC('n', S(1))*(x_*WC('f', S(1)) + WC('e', S(0)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons4, cons5, cons126, cons127) def replacement89(p, f, b, d, c, a, n, x, e): rubi.append(89) return Simp(b*(c + d*x)**(n + S(1))*(e + f*x)**(p + S(1))/(d*f*(n + p + S(2))), x) rule89 = ReplacementRule(pattern89, replacement89) pattern90 = Pattern(Integral((x_*WC('d', S(1)))**WC('n', S(1))*(a_ + x_*WC('b', S(1)))*(e_ + x_*WC('f', S(1)))**WC('p', S(1)), x_), cons2, cons3, cons27, cons48, cons125, cons4, cons128, cons129, cons130) def replacement90(p, f, b, d, a, n, x, e): rubi.append(90) return Int(ExpandIntegrand((d*x)**n*(a + b*x)*(e + f*x)**p, x), x) rule90 = ReplacementRule(pattern90, replacement90) pattern91 = Pattern(Integral((x_*WC('d', S(1)))**WC('n', S(1))*(a_ + x_*WC('b', S(1)))*(e_ + x_*WC('f', S(1)))**WC('p', S(1)), x_), cons2, cons3, cons27, cons48, cons125, cons4, cons128, cons131, cons132, cons133) def replacement91(p, f, b, d, a, n, x, e): rubi.append(91) return Int(ExpandIntegrand((d*x)**n*(a + b*x)*(e + f*x)**p, x), x) rule91 = ReplacementRule(pattern91, replacement91) pattern92 = Pattern(Integral((c_ + x_*WC('d', S(1)))**WC('n', S(1))*(x_*WC('b', S(1)) + WC('a', S(0)))*(x_*WC('f', S(1)) + WC('e', S(0)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons4, cons71, cons134) def replacement92(p, f, b, d, a, n, c, x, e): rubi.append(92) return Int(ExpandIntegrand((a + b*x)*(c + d*x)**n*(e + f*x)**p, x), x) rule92 = ReplacementRule(pattern92, replacement92) pattern93 = Pattern(Integral((x_*WC('b', S(1)) + WC('a', S(0)))*(x_*WC('d', S(1)) + WC('c', S(0)))**WC('n', S(1))*(x_*WC('f', S(1)) + WC('e', S(0)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons4, cons5, cons135, cons54, cons136) def replacement93(p, f, b, d, c, a, n, x, e): rubi.append(93) return Dist(b/f, Int((c + d*x)**n*(e + f*x)**(p + S(1)), x), x) - Simp((c + d*x)**(n + S(1))*(e + f*x)**(p + S(1))*(-a*f + b*e)/(f*(p + S(1))*(c*f - d*e)), x) rule93 = ReplacementRule(pattern93, replacement93) pattern94 = Pattern(Integral((x_*WC('b', S(1)) + WC('a', S(0)))*(x_*WC('d', S(1)) + WC('c', S(0)))**WC('n', S(1))*(x_*WC('f', S(1)) + WC('e', S(0)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons4, cons126, cons13, cons137, cons138) def replacement94(p, f, b, d, c, a, n, x, e): rubi.append(94) return -Dist((a*d*f*(n + p + S(2)) - b*(c*f*(p + S(1)) + d*e*(n + S(1))))/(f*(p + S(1))*(c*f - d*e)), Int((c + d*x)**n*(e + f*x)**(p + S(1)), x), x) - Simp((c + d*x)**(n + S(1))*(e + f*x)**(p + S(1))*(-a*f + b*e)/(f*(p + S(1))*(c*f - d*e)), x) rule94 = ReplacementRule(pattern94, replacement94) pattern95 = Pattern(Integral((x_*WC('b', S(1)) + WC('a', S(0)))*(x_*WC('d', S(1)) + WC('c', S(0)))**WC('n', S(1))*(x_*WC('f', S(1)) + WC('e', S(0)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons4, cons5, cons126, cons12, cons139) def replacement95(p, f, b, d, c, a, n, x, e): rubi.append(95) return -Dist((a*d*f*(n + p + S(2)) - b*(c*f*(p + S(1)) + d*e*(n + S(1))))/(f*(p + S(1))*(c*f - d*e)), Int((c + d*x)**n*(e + f*x)**(p + S(1)), x), x) - Simp((c + d*x)**(n + S(1))*(e + f*x)**(p + S(1))*(-a*f + b*e)/(f*(p + S(1))*(c*f - d*e)), x) rule95 = ReplacementRule(pattern95, replacement95) pattern96 = Pattern(Integral((x_*WC('b', S(1)) + WC('a', S(0)))*(x_*WC('d', S(1)) + WC('c', S(0)))**WC('n', S(1))*(x_*WC('f', S(1)) + WC('e', S(0)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons4, cons5, cons126) def replacement96(p, f, b, d, c, a, n, x, e): rubi.append(96) return Dist((a*d*f*(n + p + S(2)) - b*(c*f*(p + S(1)) + d*e*(n + S(1))))/(d*f*(n + p + S(2))), Int((c + d*x)**n*(e + f*x)**p, x), x) + Simp(b*(c + d*x)**(n + S(1))*(e + f*x)**(p + S(1))/(d*f*(n + p + S(2))), x) rule96 = ReplacementRule(pattern96, replacement96) pattern97 = Pattern(Integral((x_*WC('b', S(1)) + WC('a', S(0)))**S(2)*(x_*WC('d', S(1)) + WC('c', S(0)))**WC('n', S(1))*(x_*WC('f', S(1)) + WC('e', S(0)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons4, cons5, cons126, cons140, cons141) def replacement97(p, f, b, d, c, a, n, x, e): rubi.append(97) return Simp(b*(c + d*x)**(n + S(1))*(e + f*x)**(p + S(1))*(S(2)*a*d*f*(n + p + S(3)) + b*d*f*x*(n + p + S(2)) - b*(c*f*(p + S(2)) + d*e*(n + S(2))))/(d**S(2)*f**S(2)*(n + p + S(2))*(n + p + S(3))), x) rule97 = ReplacementRule(pattern97, replacement97) pattern98 = Pattern(Integral((x_*WC('f', S(1)))**WC('p', S(1))*(x_*WC('b', S(1)) + WC('a', S(0)))**WC('m', S(1))*(x_*WC('d', S(1)) + WC('c', S(0)))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons125, cons21, cons4, cons5, cons70, cons142, cons12, cons143, cons144) def replacement98(p, m, f, b, d, a, c, n, x): rubi.append(98) return Dist(a, Int((f*x)**p*(a + b*x)**n*(c + d*x)**n, x), x) + Dist(b/f, Int((f*x)**(p + S(1))*(a + b*x)**n*(c + d*x)**n, x), x) rule98 = ReplacementRule(pattern98, replacement98) pattern99 = Pattern(Integral((x_*WC('f', S(1)) + WC('e', S(0)))**WC('p', S(1))/((x_*WC('b', S(1)) + WC('a', S(0)))*(x_*WC('d', S(1)) + WC('c', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons38) def replacement99(p, f, b, d, c, a, x, e): rubi.append(99) return Int(ExpandIntegrand((e + f*x)**p/((a + b*x)*(c + d*x)), x), x) rule99 = ReplacementRule(pattern99, replacement99) pattern100 = Pattern(Integral((x_*WC('f', S(1)) + WC('e', S(0)))**WC('p', S(1))/((x_*WC('b', S(1)) + WC('a', S(0)))*(x_*WC('d', S(1)) + WC('c', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons13, cons145) def replacement100(p, f, b, d, c, a, x, e): rubi.append(100) return Dist((-a*f + b*e)/(-a*d + b*c), Int((e + f*x)**(p + S(-1))/(a + b*x), x), x) - Dist((-c*f + d*e)/(-a*d + b*c), Int((e + f*x)**(p + S(-1))/(c + d*x), x), x) rule100 = ReplacementRule(pattern100, replacement100) pattern101 = Pattern(Integral((x_*WC('f', S(1)) + WC('e', S(0)))**p_/((x_*WC('b', S(1)) + WC('a', S(0)))*(x_*WC('d', S(1)) + WC('c', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons13, cons146) def replacement101(p, f, b, d, c, a, x, e): rubi.append(101) return Dist(S(1)/(b*d), Int((e + f*x)**(p + S(-2))*(-a*c*f**S(2) + b*d*e**S(2) + f*x*(-a*d*f - b*c*f + S(2)*b*d*e))/((a + b*x)*(c + d*x)), x), x) + Simp(f*(e + f*x)**(p + S(-1))/(b*d*(p + S(-1))), x) rule101 = ReplacementRule(pattern101, replacement101) pattern102 = Pattern(Integral((x_*WC('f', S(1)) + WC('e', S(0)))**p_/((x_*WC('b', S(1)) + WC('a', S(0)))*(x_*WC('d', S(1)) + WC('c', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons13, cons137) def replacement102(p, f, b, d, c, a, x, e): rubi.append(102) return Dist(S(1)/((-a*f + b*e)*(-c*f + d*e)), Int((e + f*x)**(p + S(1))*(-a*d*f - b*c*f + b*d*e - b*d*f*x)/((a + b*x)*(c + d*x)), x), x) + Simp(f*(e + f*x)**(p + S(1))/((p + S(1))*(-a*f + b*e)*(-c*f + d*e)), x) rule102 = ReplacementRule(pattern102, replacement102) pattern103 = Pattern(Integral((x_*WC('f', S(1)) + WC('e', S(0)))**p_/((x_*WC('b', S(1)) + WC('a', S(0)))*(x_*WC('d', S(1)) + WC('c', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons5, cons147) def replacement103(p, f, b, d, c, a, x, e): rubi.append(103) return Dist(b/(-a*d + b*c), Int((e + f*x)**p/(a + b*x), x), x) - Dist(d/(-a*d + b*c), Int((e + f*x)**p/(c + d*x), x), x) rule103 = ReplacementRule(pattern103, replacement103) pattern104 = Pattern(Integral((x_*WC('d', S(1)) + WC('c', S(0)))**WC('n', S(1))*(x_*WC('f', S(1)) + WC('e', S(0)))**p_/(x_*WC('b', S(1)) + WC('a', S(0))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons148, cons149, cons137) def replacement104(p, f, b, d, c, a, n, x, e): rubi.append(104) return Int(ExpandIntegrand((e + f*x)**FractionalPart(p), (c + d*x)**n*(e + f*x)**IntegerPart(p)/(a + b*x), x), x) rule104 = ReplacementRule(pattern104, replacement104) pattern105 = Pattern(Integral((x_*WC('b', S(1)) + WC('a', S(0)))**WC('m', S(1))*(x_*WC('d', S(1)) + WC('c', S(0)))**WC('n', S(1))*(x_*WC('f', S(1)) + WC('e', S(0)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons5, cons150, cons151) def replacement105(p, m, f, b, d, a, c, n, x, e): rubi.append(105) return Int(ExpandIntegrand((a + b*x)**m*(c + d*x)**n*(e + f*x)**p, x), x) rule105 = ReplacementRule(pattern105, replacement105) pattern106 = Pattern(Integral((x_*WC('b', S(1)) + WC('a', S(0)))**S(2)*(x_*WC('d', S(1)) + WC('c', S(0)))**WC('n', S(1))*(x_*WC('f', S(1)) + WC('e', S(0)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons4, cons5, cons152) def replacement106(p, f, b, d, c, a, n, x, e): rubi.append(106) return -Dist(S(1)/(d**S(2)*(n + S(1))*(-c*f + d*e)), Int((c + d*x)**(n + S(1))*(e + f*x)**p*Simp(a**S(2)*d**S(2)*f*(n + p + S(2)) - S(2)*a*b*d*(c*f*(p + S(1)) + d*e*(n + S(1))) + b**S(2)*c*(c*f*(p + S(1)) + d*e*(n + S(1))) - b**S(2)*d*x*(n + S(1))*(-c*f + d*e), x), x), x) + Simp((c + d*x)**(n + S(1))*(e + f*x)**(p + S(1))*(-a*d + b*c)**S(2)/(d**S(2)*(n + S(1))*(-c*f + d*e)), x) rule106 = ReplacementRule(pattern106, replacement106) pattern107 = Pattern(Integral((x_*WC('b', S(1)) + WC('a', S(0)))**S(2)*(x_*WC('d', S(1)) + WC('c', S(0)))**WC('n', S(1))*(x_*WC('f', S(1)) + WC('e', S(0)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons4, cons5, cons140) def replacement107(p, f, b, d, c, a, n, x, e): rubi.append(107) return Dist(S(1)/(d*f*(n + p + S(3))), Int((c + d*x)**n*(e + f*x)**p*Simp(a**S(2)*d*f*(n + p + S(3)) + b*x*(a*d*f*(n + p + S(4)) - b*(c*f*(p + S(2)) + d*e*(n + S(2)))) - b*(a*(c*f*(p + S(1)) + d*e*(n + S(1))) + b*c*e), x), x), x) + Simp(b*(a + b*x)*(c + d*x)**(n + S(1))*(e + f*x)**(p + S(1))/(d*f*(n + p + S(3))), x) rule107 = ReplacementRule(pattern107, replacement107) def With108(f, b, d, c, a, x, e): q = Rt((-c*f + d*e)/(-a*f + b*e), S(3)) rubi.append(108) return Simp(q*log(e + f*x)/(-S(2)*c*f + S(2)*d*e), x) - Simp(S(3)*q*log(q*(a + b*x)**(S(1)/3) - (c + d*x)**(S(1)/3))/(-S(2)*c*f + S(2)*d*e), x) - Simp(sqrt(S(3))*q*ArcTan(S(2)*sqrt(S(3))*q*(a + b*x)**(S(1)/3)/(S(3)*(c + d*x)**(S(1)/3)) + sqrt(S(3))/S(3))/(-c*f + d*e), x) pattern108 = Pattern(Integral(S(1)/((x_*WC('b', S(1)) + WC('a', S(0)))**(S(1)/3)*(x_*WC('d', S(1)) + WC('c', S(0)))**(S(2)/3)*(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons153) rule108 = ReplacementRule(pattern108, With108) pattern109 = Pattern(Integral(S(1)/(sqrt(x_*WC('b', S(1)) + WC('a', S(0)))*sqrt(x_*WC('d', S(1)) + WC('c', S(0)))*(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons154) def replacement109(f, b, d, c, a, x, e): rubi.append(109) return Dist(b*f, Subst(Int(S(1)/(b*f**S(2)*x**S(2) + d*(-a*f + b*e)**S(2)), x), x, sqrt(a + b*x)*sqrt(c + d*x)), x) rule109 = ReplacementRule(pattern109, replacement109) def With110(m, f, b, d, c, a, n, x, e): q = Denominator(m) rubi.append(110) return Dist(q, Subst(Int(x**(q*(m + S(1)) + S(-1))/(-a*f + b*e - x**q*(-c*f + d*e)), x), x, (a + b*x)**(S(1)/q)*(c + d*x)**(-S(1)/q)), x) pattern110 = Pattern(Integral((x_*WC('b', S(1)) + WC('a', S(0)))**m_*(x_*WC('d', S(1)) + WC('c', S(0)))**n_/(x_*WC('f', S(1)) + WC('e', S(0))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons155, cons93, cons107, cons156) rule110 = ReplacementRule(pattern110, With110) pattern111 = Pattern(Integral((x_*WC('b', S(1)) + WC('a', S(0)))**m_*(x_*WC('d', S(1)) + WC('c', S(0)))**WC('n', S(1))*(x_*WC('f', S(1)) + WC('e', S(0)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons5, cons157, cons87, cons88, cons158) def replacement111(p, m, f, b, d, c, a, n, x, e): rubi.append(111) return -Dist(n*(-c*f + d*e)/((m + S(1))*(-a*f + b*e)), Int((a + b*x)**(m + S(1))*(c + d*x)**(n + S(-1))*(e + f*x)**p, x), x) + Simp((a + b*x)**(m + S(1))*(c + d*x)**n*(e + f*x)**(p + S(1))/((m + S(1))*(-a*f + b*e)), x) rule111 = ReplacementRule(pattern111, replacement111) pattern112 = Pattern(Integral((x_*WC('b', S(1)) + WC('a', S(0)))**m_*(x_*WC('d', S(1)) + WC('c', S(0)))**WC('n', S(1))*(x_*WC('f', S(1)) + WC('e', S(0)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons4, cons5, cons159, cons160, cons66) def replacement112(p, m, f, b, d, c, a, n, x, e): rubi.append(112) return Simp(b*(a + b*x)**(m + S(1))*(c + d*x)**(n + S(1))*(e + f*x)**(p + S(1))/((m + S(1))*(-a*d + b*c)*(-a*f + b*e)), x) rule112 = ReplacementRule(pattern112, replacement112) pattern113 = Pattern(Integral((x_*WC('b', S(1)) + WC('a', S(0)))**m_*(x_*WC('d', S(1)) + WC('c', S(0)))**WC('n', S(1))*(x_*WC('f', S(1)) + WC('e', S(0)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons4, cons5, cons159, cons161) def replacement113(p, m, f, b, d, c, a, n, x, e): rubi.append(113) return Dist((a*d*f*(m + S(1)) + b*c*f*(n + S(1)) + b*d*e*(p + S(1)))/((m + S(1))*(-a*d + b*c)*(-a*f + b*e)), Int((a + b*x)**(m + S(1))*(c + d*x)**n*(e + f*x)**p, x), x) + Simp(b*(a + b*x)**(m + S(1))*(c + d*x)**(n + S(1))*(e + f*x)**(p + S(1))/((m + S(1))*(-a*d + b*c)*(-a*f + b*e)), x) rule113 = ReplacementRule(pattern113, replacement113) pattern114 = Pattern(Integral((x_*WC('b', S(1)) + WC('a', S(0)))**m_*(x_*WC('d', S(1)) + WC('c', S(0)))**WC('n', S(1))*(x_*WC('f', S(1)) + WC('e', S(0)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons162, cons94, cons88, cons163, cons164) def replacement114(p, m, f, b, d, c, a, n, x, e): rubi.append(114) return -Dist(S(1)/(b*(m + S(1))), Int((a + b*x)**(m + S(1))*(c + d*x)**(n + S(-1))*(e + f*x)**(p + S(-1))*Simp(c*f*p + d*e*n + d*f*x*(n + p), x), x), x) + Simp((a + b*x)**(m + S(1))*(c + d*x)**n*(e + f*x)**p/(b*(m + S(1))), x) rule114 = ReplacementRule(pattern114, replacement114) pattern115 = Pattern(Integral((x_*WC('b', S(1)) + WC('a', S(0)))**m_*(x_*WC('d', S(1)) + WC('c', S(0)))**WC('n', S(1))*(x_*WC('f', S(1)) + WC('e', S(0)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons5, cons162, cons94, cons165, cons164) def replacement115(p, m, f, b, d, c, a, n, x, e): rubi.append(115) return Dist(S(1)/(b*(m + S(1))*(-a*f + b*e)), Int((a + b*x)**(m + S(1))*(c + d*x)**(n + S(-2))*(e + f*x)**p*Simp(a*d*(c*f*(p + S(1)) + d*e*(n + S(-1))) + b*c*(-c*f*(m + p + S(2)) + d*e*(m - n + S(2))) + d*x*(a*d*f*(n + p) + b*(-c*f*(m + n + p + S(1)) + d*e*(m + S(1)))), x), x), x) + Simp((a + b*x)**(m + S(1))*(c + d*x)**(n + S(-1))*(e + f*x)**(p + S(1))*(-a*d + b*c)/(b*(m + S(1))*(-a*f + b*e)), x) rule115 = ReplacementRule(pattern115, replacement115) pattern116 = Pattern(Integral((x_*WC('b', S(1)) + WC('a', S(0)))**m_*(x_*WC('d', S(1)) + WC('c', S(0)))**WC('n', S(1))*(x_*WC('f', S(1)) + WC('e', S(0)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons5, cons162, cons94, cons88, cons164) def replacement116(p, m, f, b, d, c, a, n, x, e): rubi.append(116) return -Dist(S(1)/((m + S(1))*(-a*f + b*e)), Int((a + b*x)**(m + S(1))*(c + d*x)**(n + S(-1))*(e + f*x)**p*Simp(c*f*(m + p + S(2)) + d*e*n + d*f*x*(m + n + p + S(2)), x), x), x) + Simp((a + b*x)**(m + S(1))*(c + d*x)**n*(e + f*x)**(p + S(1))/((m + S(1))*(-a*f + b*e)), x) rule116 = ReplacementRule(pattern116, replacement116) pattern117 = Pattern(Integral((x_*WC('b', S(1)) + WC('a', S(0)))**m_*(x_*WC('d', S(1)) + WC('c', S(0)))**WC('n', S(1))*(x_*WC('f', S(1)) + WC('e', S(0)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons4, cons5, cons31, cons166, cons167, cons17) def replacement117(p, m, f, b, d, c, a, n, x, e): rubi.append(117) return Dist(S(1)/(d*f*(m + n + p + S(1))), Int((a + b*x)**(m + S(-2))*(c + d*x)**n*(e + f*x)**p*Simp(a**S(2)*d*f*(m + n + p + S(1)) + b*x*(a*d*f*(S(2)*m + n + p) - b*(c*f*(m + p) + d*e*(m + n))) - b*(a*(c*f*(p + S(1)) + d*e*(n + S(1))) + b*c*e*(m + S(-1))), x), x), x) + Simp(b*(a + b*x)**(m + S(-1))*(c + d*x)**(n + S(1))*(e + f*x)**(p + S(1))/(d*f*(m + n + p + S(1))), x) rule117 = ReplacementRule(pattern117, replacement117) pattern118 = Pattern(Integral((x_*WC('b', S(1)) + WC('a', S(0)))**WC('m', S(1))*(x_*WC('d', S(1)) + WC('c', S(0)))**WC('n', S(1))*(x_*WC('f', S(1)) + WC('e', S(0)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons162, cons168, cons88, cons167, cons169) def replacement118(p, m, f, b, d, a, c, n, x, e): rubi.append(118) return -Dist(S(1)/(f*(m + n + p + S(1))), Int((a + b*x)**(m + S(-1))*(c + d*x)**(n + S(-1))*(e + f*x)**p*Simp(a*n*(-c*f + d*e) + c*m*(-a*f + b*e) + x*(b*n*(-c*f + d*e) + d*m*(-a*f + b*e)), x), x), x) + Simp((a + b*x)**m*(c + d*x)**n*(e + f*x)**(p + S(1))/(f*(m + n + p + S(1))), x) rule118 = ReplacementRule(pattern118, replacement118) pattern119 = Pattern(Integral((x_*WC('b', S(1)) + WC('a', S(0)))**m_*(x_*WC('d', S(1)) + WC('c', S(0)))**WC('n', S(1))*(x_*WC('f', S(1)) + WC('e', S(0)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons4, cons5, cons31, cons166, cons167, cons170) def replacement119(p, m, f, b, d, c, a, n, x, e): rubi.append(119) return Dist(S(1)/(d*f*(m + n + p + S(1))), Int((a + b*x)**(m + S(-2))*(c + d*x)**n*(e + f*x)**p*Simp(a**S(2)*d*f*(m + n + p + S(1)) + b*x*(a*d*f*(S(2)*m + n + p) - b*(c*f*(m + p) + d*e*(m + n))) - b*(a*(c*f*(p + S(1)) + d*e*(n + S(1))) + b*c*e*(m + S(-1))), x), x), x) + Simp(b*(a + b*x)**(m + S(-1))*(c + d*x)**(n + S(1))*(e + f*x)**(p + S(1))/(d*f*(m + n + p + S(1))), x) rule119 = ReplacementRule(pattern119, replacement119) pattern120 = Pattern(Integral((x_*WC('b', S(1)) + WC('a', S(0)))**m_*(x_*WC('d', S(1)) + WC('c', S(0)))**WC('n', S(1))*(x_*WC('f', S(1)) + WC('e', S(0)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons4, cons5, cons31, cons94, cons17, cons171) def replacement120(p, m, f, b, d, c, a, n, x, e): rubi.append(120) return Dist(S(1)/((m + S(1))*(-a*d + b*c)*(-a*f + b*e)), Int((a + b*x)**(m + S(1))*(c + d*x)**n*(e + f*x)**p*Simp(a*d*f*(m + S(1)) - b*d*f*x*(m + n + p + S(3)) - b*(c*f*(m + p + S(2)) + d*e*(m + n + S(2))), x), x), x) + Simp(b*(a + b*x)**(m + S(1))*(c + d*x)**(n + S(1))*(e + f*x)**(p + S(1))/((m + S(1))*(-a*d + b*c)*(-a*f + b*e)), x) rule120 = ReplacementRule(pattern120, replacement120) pattern121 = Pattern(Integral((x_*WC('b', S(1)) + WC('a', S(0)))**m_*(x_*WC('d', S(1)) + WC('c', S(0)))**WC('n', S(1))*(x_*WC('f', S(1)) + WC('e', S(0)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons4, cons5, cons31, cons94, cons170) def replacement121(p, m, f, b, d, c, a, n, x, e): rubi.append(121) return Dist(S(1)/((m + S(1))*(-a*d + b*c)*(-a*f + b*e)), Int((a + b*x)**(m + S(1))*(c + d*x)**n*(e + f*x)**p*Simp(a*d*f*(m + S(1)) - b*d*f*x*(m + n + p + S(3)) - b*(c*f*(m + p + S(2)) + d*e*(m + n + S(2))), x), x), x) + Simp(b*(a + b*x)**(m + S(1))*(c + d*x)**(n + S(1))*(e + f*x)**(p + S(1))/((m + S(1))*(-a*d + b*c)*(-a*f + b*e)), x) rule121 = ReplacementRule(pattern121, replacement121) pattern122 = Pattern(Integral((x_*WC('b', S(1)) + WC('a', S(0)))**m_*(x_*WC('d', S(1)) + WC('c', S(0)))**n_/(x_*WC('f', S(1)) + WC('e', S(0))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons4, cons172, cons173) def replacement122(m, f, b, d, c, a, n, x, e): rubi.append(122) return Dist(b/f, Int((a + b*x)**(m + S(-1))*(c + d*x)**n, x), x) - Dist((-a*f + b*e)/f, Int((a + b*x)**(m + S(-1))*(c + d*x)**n/(e + f*x), x), x) rule122 = ReplacementRule(pattern122, replacement122) pattern123 = Pattern(Integral(S(1)/((x_*WC('b', S(1)) + WC('a', S(0)))*sqrt(x_*WC('d', S(1)) + WC('c', S(0)))*(x_*WC('f', S(1)) + WC('e', S(0)))**(S(1)/4)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons174) def replacement123(f, b, d, c, a, x, e): rubi.append(123) return Dist(S(-4), Subst(Int(x**S(2)/(sqrt(c - d*e/f + d*x**S(4)/f)*(-a*f + b*e - b*x**S(4))), x), x, (e + f*x)**(S(1)/4)), x) rule123 = ReplacementRule(pattern123, replacement123) pattern124 = Pattern(Integral(S(1)/((x_*WC('b', S(1)) + WC('a', S(0)))*sqrt(x_*WC('d', S(1)) + WC('c', S(0)))*(x_*WC('f', S(1)) + WC('e', S(0)))**(S(1)/4)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons175) def replacement124(f, b, d, c, a, x, e): rubi.append(124) return Dist(sqrt(-f*(c + d*x)/(-c*f + d*e))/sqrt(c + d*x), Int(S(1)/((a + b*x)*(e + f*x)**(S(1)/4)*sqrt(-c*f/(-c*f + d*e) - d*f*x/(-c*f + d*e))), x), x) rule124 = ReplacementRule(pattern124, replacement124) pattern125 = Pattern(Integral(S(1)/((x_*WC('b', S(1)) + WC('a', S(0)))*sqrt(x_*WC('d', S(1)) + WC('c', S(0)))*(x_*WC('f', S(1)) + WC('e', S(0)))**(S(3)/4)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons174) def replacement125(f, b, d, c, a, x, e): rubi.append(125) return Dist(S(-4), Subst(Int(S(1)/(sqrt(c - d*e/f + d*x**S(4)/f)*(-a*f + b*e - b*x**S(4))), x), x, (e + f*x)**(S(1)/4)), x) rule125 = ReplacementRule(pattern125, replacement125) pattern126 = Pattern(Integral(S(1)/((x_*WC('b', S(1)) + WC('a', S(0)))*sqrt(x_*WC('d', S(1)) + WC('c', S(0)))*(x_*WC('f', S(1)) + WC('e', S(0)))**(S(3)/4)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons175) def replacement126(f, b, d, c, a, x, e): rubi.append(126) return Dist(sqrt(-f*(c + d*x)/(-c*f + d*e))/sqrt(c + d*x), Int(S(1)/((a + b*x)*(e + f*x)**(S(3)/4)*sqrt(-c*f/(-c*f + d*e) - d*f*x/(-c*f + d*e))), x), x) rule126 = ReplacementRule(pattern126, replacement126) pattern127 = Pattern(Integral(sqrt(e_ + x_*WC('f', S(1)))/(sqrt(x_*WC('b', S(1)))*sqrt(c_ + x_*WC('d', S(1)))), x_), cons3, cons7, cons27, cons48, cons125, cons176, cons177, cons178, cons179) def replacement127(f, b, d, c, x, e): rubi.append(127) return Simp(S(2)*sqrt(e)*EllipticE(asin(sqrt(b*x)/(sqrt(c)*Rt(-b/d, S(2)))), c*f/(d*e))*Rt(-b/d, S(2))/b, x) rule127 = ReplacementRule(pattern127, replacement127) pattern128 = Pattern(Integral(sqrt(e_ + x_*WC('f', S(1)))/(sqrt(x_*WC('b', S(1)))*sqrt(c_ + x_*WC('d', S(1)))), x_), cons3, cons7, cons27, cons48, cons125, cons176, cons177, cons178, cons180) def replacement128(f, b, d, c, x, e): rubi.append(128) return Dist(sqrt(-b*x)/sqrt(b*x), Int(sqrt(e + f*x)/(sqrt(-b*x)*sqrt(c + d*x)), x), x) rule128 = ReplacementRule(pattern128, replacement128) pattern129 = Pattern(Integral(sqrt(e_ + x_*WC('f', S(1)))/(sqrt(x_*WC('b', S(1)))*sqrt(c_ + x_*WC('d', S(1)))), x_), cons3, cons7, cons27, cons48, cons125, cons176, cons181) def replacement129(f, b, d, c, x, e): rubi.append(129) return Dist(sqrt(S(1) + d*x/c)*sqrt(e + f*x)/(sqrt(S(1) + f*x/e)*sqrt(c + d*x)), Int(sqrt(S(1) + f*x/e)/(sqrt(b*x)*sqrt(S(1) + d*x/c)), x), x) rule129 = ReplacementRule(pattern129, replacement129) pattern130 = Pattern(Integral(sqrt(x_*WC('f', S(1)) + WC('e', S(0)))/(sqrt(a_ + x_*WC('b', S(1)))*sqrt(c_ + x_*WC('d', S(1)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons120, cons182, cons183, cons184) def replacement130(f, b, d, a, c, x, e): rubi.append(130) return Simp(S(2)*EllipticE(asin(sqrt(a + b*x)/Rt(-(-a*d + b*c)/d, S(2))), f*(-a*d + b*c)/(d*(-a*f + b*e)))*Rt(-(-a*f + b*e)/d, S(2))/b, x) rule130 = ReplacementRule(pattern130, replacement130) pattern131 = Pattern(Integral(sqrt(x_*WC('f', S(1)) + WC('e', S(0)))/(sqrt(a_ + x_*WC('b', S(1)))*sqrt(c_ + x_*WC('d', S(1)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons185, cons183) def replacement131(f, b, d, a, c, x, e): rubi.append(131) return Dist(sqrt(b*(c + d*x)/(-a*d + b*c))*sqrt(e + f*x)/(sqrt(b*(e + f*x)/(-a*f + b*e))*sqrt(c + d*x)), Int(sqrt(b*e/(-a*f + b*e) + b*f*x/(-a*f + b*e))/(sqrt(a + b*x)*sqrt(b*c/(-a*d + b*c) + b*d*x/(-a*d + b*c))), x), x) rule131 = ReplacementRule(pattern131, replacement131) pattern132 = Pattern(Integral(S(1)/(sqrt(x_*WC('b', S(1)))*sqrt(c_ + x_*WC('d', S(1)))*sqrt(e_ + x_*WC('f', S(1)))), x_), cons3, cons7, cons27, cons48, cons125, cons177, cons178, cons186) def replacement132(f, b, d, c, x, e): rubi.append(132) return Simp(S(2)*EllipticF(asin(sqrt(b*x)/(sqrt(c)*Rt(-b/d, S(2)))), c*f/(d*e))*Rt(-b/d, S(2))/(b*sqrt(e)), x) rule132 = ReplacementRule(pattern132, replacement132) pattern133 = Pattern(Integral(S(1)/(sqrt(x_*WC('b', S(1)))*sqrt(c_ + x_*WC('d', S(1)))*sqrt(e_ + x_*WC('f', S(1)))), x_), cons3, cons7, cons27, cons48, cons125, cons177, cons178, cons187) def replacement133(f, b, d, c, x, e): rubi.append(133) return Simp(S(2)*EllipticF(asin(sqrt(b*x)/(sqrt(c)*Rt(-b/d, S(2)))), c*f/(d*e))*Rt(-b/d, S(2))/(b*sqrt(e)), x) rule133 = ReplacementRule(pattern133, replacement133) pattern134 = Pattern(Integral(S(1)/(sqrt(x_*WC('b', S(1)))*sqrt(c_ + x_*WC('d', S(1)))*sqrt(e_ + x_*WC('f', S(1)))), x_), cons3, cons7, cons27, cons48, cons125, cons181) def replacement134(f, b, d, c, x, e): rubi.append(134) return Dist(sqrt(S(1) + d*x/c)*sqrt(S(1) + f*x/e)/(sqrt(c + d*x)*sqrt(e + f*x)), Int(S(1)/(sqrt(b*x)*sqrt(S(1) + d*x/c)*sqrt(S(1) + f*x/e)), x), x) rule134 = ReplacementRule(pattern134, replacement134) pattern135 = Pattern(Integral(S(1)/(sqrt(a_ + x_*WC('b', S(1)))*sqrt(c_ + x_*WC('d', S(1)))*sqrt(e_ + x_*WC('f', S(1)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons120, cons182, cons156, cons188, cons189) def replacement135(f, b, d, a, c, x, e): rubi.append(135) return Simp(S(2)*sqrt(b**S(2)/((-a*d + b*c)*(-a*f + b*e)))*EllipticF(asin(sqrt(a + b*x)/Rt(-(-a*d + b*c)/d, S(2))), f*(-a*d + b*c)/(d*(-a*f + b*e)))*Rt(-(-a*d + b*c)/d, S(2))/b, x) rule135 = ReplacementRule(pattern135, replacement135) pattern136 = Pattern(Integral(S(1)/(sqrt(a_ + x_*WC('b', S(1)))*sqrt(c_ + x_*WC('d', S(1)))*sqrt(e_ + x_*WC('f', S(1)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons120, cons182, cons156, cons188, cons190) def replacement136(f, b, d, a, c, x, e): rubi.append(136) return Simp(S(2)*sqrt(b**S(2)/((-a*d + b*c)*(-a*f + b*e)))*EllipticF(asin(sqrt(a + b*x)/Rt(-(-a*d + b*c)/d, S(2))), f*(-a*d + b*c)/(d*(-a*f + b*e)))*Rt(-(-a*d + b*c)/d, S(2))/b, x) rule136 = ReplacementRule(pattern136, replacement136) pattern137 = Pattern(Integral(S(1)/(sqrt(a_ + x_*WC('b', S(1)))*sqrt(c_ + x_*WC('d', S(1)))*sqrt(e_ + x_*WC('f', S(1)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons185, cons156, cons188) def replacement137(f, b, d, a, c, x, e): rubi.append(137) return Dist(sqrt(b*(c + d*x)/(-a*d + b*c))*sqrt(b*(e + f*x)/(-a*f + b*e))/(sqrt(c + d*x)*sqrt(e + f*x)), Int(S(1)/(sqrt(a + b*x)*sqrt(b*c/(-a*d + b*c) + b*d*x/(-a*d + b*c))*sqrt(b*e/(-a*f + b*e) + b*f*x/(-a*f + b*e))), x), x) rule137 = ReplacementRule(pattern137, replacement137) def With138(f, b, d, c, a, x, e): q = Rt(b*(-a*f + b*e)/(-a*d + b*c)**S(2), S(3)) rubi.append(138) return -Simp(log(a + b*x)/(S(2)*q*(-a*d + b*c)), x) + Simp(S(3)*log(q*(c + d*x)**(S(2)/3) - (e + f*x)**(S(1)/3))/(S(4)*q*(-a*d + b*c)), x) - Simp(sqrt(S(3))*ArcTan(S(2)*sqrt(S(3))*q*(c + d*x)**(S(2)/3)/(S(3)*(e + f*x)**(S(1)/3)) + sqrt(S(3))/S(3))/(S(2)*q*(-a*d + b*c)), x) pattern138 = Pattern(Integral(S(1)/((x_*WC('b', S(1)) + WC('a', S(0)))*(x_*WC('d', S(1)) + WC('c', S(0)))**(S(1)/3)*(x_*WC('f', S(1)) + WC('e', S(0)))**(S(1)/3)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons191) rule138 = ReplacementRule(pattern138, With138) pattern139 = Pattern(Integral((x_*WC('b', S(1)) + WC('a', S(0)))**m_/((x_*WC('d', S(1)) + WC('c', S(0)))**(S(1)/3)*(x_*WC('f', S(1)) + WC('e', S(0)))**(S(1)/3)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons191, cons17, cons94) def replacement139(m, f, b, d, c, a, x, e): rubi.append(139) return Dist(f/(S(6)*(m + S(1))*(-a*d + b*c)*(-a*f + b*e)), Int((a + b*x)**(m + S(1))*(a*d*(S(3)*m + S(1)) - S(3)*b*c*(S(3)*m + S(5)) - S(2)*b*d*x*(S(3)*m + S(7)))/((c + d*x)**(S(1)/3)*(e + f*x)**(S(1)/3)), x), x) + Simp(b*(a + b*x)**(m + S(1))*(c + d*x)**(S(2)/3)*(e + f*x)**(S(2)/3)/((m + S(1))*(-a*d + b*c)*(-a*f + b*e)), x) rule139 = ReplacementRule(pattern139, replacement139) pattern140 = Pattern(Integral((x_*WC('f', S(1)))**WC('p', S(1))*(x_*WC('b', S(1)) + WC('a', S(0)))**WC('m', S(1))*(x_*WC('d', S(1)) + WC('c', S(0)))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons125, cons21, cons4, cons5, cons70, cons124, cons43, cons177) def replacement140(p, m, f, b, d, a, c, n, x): rubi.append(140) return Int((f*x)**p*(a*c + b*d*x**S(2))**m, x) rule140 = ReplacementRule(pattern140, replacement140) pattern141 = Pattern(Integral((x_*WC('f', S(1)))**WC('p', S(1))*(x_*WC('b', S(1)) + WC('a', S(0)))**WC('m', S(1))*(x_*WC('d', S(1)) + WC('c', S(0)))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons125, cons21, cons4, cons5, cons70, cons124) def replacement141(p, m, f, b, d, a, c, n, x): rubi.append(141) return Dist((a + b*x)**FracPart(m)*(c + d*x)**FracPart(m)*(a*c + b*d*x**S(2))**(-FracPart(m)), Int((f*x)**p*(a*c + b*d*x**S(2))**m, x), x) rule141 = ReplacementRule(pattern141, replacement141) pattern142 = Pattern(Integral((x_*WC('f', S(1)))**WC('p', S(1))*(x_*WC('b', S(1)) + WC('a', S(0)))**WC('m', S(1))*(x_*WC('d', S(1)) + WC('c', S(0)))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons125, cons21, cons4, cons5, cons70, cons192, cons144) def replacement142(p, m, f, b, d, a, c, n, x): rubi.append(142) return Int(ExpandIntegrand((f*x)**p*(a + b*x)**n*(c + d*x)**n, (a + b*x)**(m - n), x), x) rule142 = ReplacementRule(pattern142, replacement142) pattern143 = Pattern(Integral((x_*WC('b', S(1)) + WC('a', S(0)))**WC('m', S(1))*(x_*WC('d', S(1)) + WC('c', S(0)))**WC('n', S(1))*(x_*WC('f', S(1)) + WC('e', S(0)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons4, cons5, cons193) def replacement143(p, m, f, b, d, a, c, n, x, e): rubi.append(143) return Int(ExpandIntegrand((a + b*x)**m*(c + d*x)**n*(e + f*x)**p, x), x) rule143 = ReplacementRule(pattern143, replacement143) pattern144 = Pattern(Integral((x_*WC('b', S(1)) + WC('a', S(0)))**m_*(x_*WC('d', S(1)) + WC('c', S(0)))**WC('n', S(1))*(x_*WC('f', S(1)) + WC('e', S(0)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons4, cons5, cons194, cons66, cons195) def replacement144(p, m, f, b, d, c, a, n, x, e): rubi.append(144) return Dist(S(1)/((m + S(1))*(-a*d + b*c)*(-a*f + b*e)), Int((a + b*x)**(m + S(1))*(c + d*x)**n*(e + f*x)**p*Simp(a*d*f*(m + S(1)) - b*d*f*x*(m + n + p + S(3)) - b*(c*f*(m + p + S(2)) + d*e*(m + n + S(2))), x), x), x) + Simp(b*(a + b*x)**(m + S(1))*(c + d*x)**(n + S(1))*(e + f*x)**(p + S(1))/((m + S(1))*(-a*d + b*c)*(-a*f + b*e)), x) rule144 = ReplacementRule(pattern144, replacement144) pattern145 = Pattern(Integral((x_*WC('b', S(1)) + WC('a', S(0)))**m_*(x_*WC('d', S(1)) + WC('c', S(0)))**WC('n', S(1))*(x_*WC('f', S(1)) + WC('e', S(0)))**p_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons5, cons157, cons196) def replacement145(p, m, f, b, d, c, a, n, x, e): rubi.append(145) return Simp((a + b*x)**(m + S(1))*(e + f*x)**(-m + S(-1))*(-a*d + b*c)**n*(-a*f + b*e)**(-n + S(-1))*Hypergeometric2F1(m + S(1), -n, m + S(2), -(a + b*x)*(-c*f + d*e)/((e + f*x)*(-a*d + b*c)))/(m + S(1)), x) rule145 = ReplacementRule(pattern145, replacement145) pattern146 = Pattern(Integral((x_*WC('b', S(1)) + WC('a', S(0)))**m_*(x_*WC('d', S(1)) + WC('c', S(0)))**n_*(x_*WC('f', S(1)) + WC('e', S(0)))**p_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons4, cons5, cons157, cons23) def replacement146(p, m, f, b, d, c, a, n, x, e): rubi.append(146) return Simp(((c + d*x)*(-a*f + b*e)/((e + f*x)*(-a*d + b*c)))**(-n)*(a + b*x)**(m + S(1))*(c + d*x)**n*(e + f*x)**(p + S(1))*Hypergeometric2F1(m + S(1), -n, m + S(2), -(a + b*x)*(-c*f + d*e)/((e + f*x)*(-a*d + b*c)))/((m + S(1))*(-a*f + b*e)), x) rule146 = ReplacementRule(pattern146, replacement146) pattern147 = Pattern(Integral((x_*WC('b', S(1)))**m_*(c_ + x_*WC('d', S(1)))**n_*(e_ + x_*WC('f', S(1)))**p_, x_), cons3, cons7, cons27, cons48, cons125, cons21, cons4, cons5, cons18, cons23, cons177, cons197) def replacement147(p, m, f, b, d, c, n, x, e): rubi.append(147) return Simp(c**n*e**p*(b*x)**(m + S(1))*AppellF1(m + S(1), -n, -p, m + S(2), -d*x/c, -f*x/e)/(b*(m + S(1))), x) rule147 = ReplacementRule(pattern147, replacement147) pattern148 = Pattern(Integral((x_*WC('b', S(1)))**m_*(c_ + x_*WC('d', S(1)))**n_*(e_ + x_*WC('f', S(1)))**p_, x_), cons3, cons7, cons27, cons48, cons125, cons21, cons4, cons5, cons18, cons23, cons198, cons199) def replacement148(p, m, f, b, d, c, n, x, e): rubi.append(148) return Simp((d/(-c*f + d*e))**(-p)*(-d/(b*c))**(-m)*(c + d*x)**(n + S(1))*AppellF1(n + S(1), -m, -p, n + S(2), S(1) + d*x/c, -f*(c + d*x)/(-c*f + d*e))/(d*(n + S(1))), x) rule148 = ReplacementRule(pattern148, replacement148) pattern149 = Pattern(Integral((x_*WC('b', S(1)))**m_*(c_ + x_*WC('d', S(1)))**n_*(e_ + x_*WC('f', S(1)))**p_, x_), cons3, cons7, cons27, cons48, cons125, cons21, cons4, cons5, cons18, cons23, cons117) def replacement149(p, m, f, b, d, c, n, x, e): rubi.append(149) return Dist(c**IntPart(n)*(S(1) + d*x/c)**(-FracPart(n))*(c + d*x)**FracPart(n), Int((b*x)**m*(S(1) + d*x/c)**n*(e + f*x)**p, x), x) rule149 = ReplacementRule(pattern149, replacement149) pattern150 = Pattern(Integral((a_ + x_*WC('b', S(1)))**m_*(x_*WC('d', S(1)) + WC('c', S(0)))**n_*(x_*WC('f', S(1)) + WC('e', S(0)))**p_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons4, cons18, cons23, cons38, cons120, cons200) def replacement150(p, m, f, b, d, c, a, n, x, e): rubi.append(150) return Simp(b**(-p + S(-1))*(b/(-a*d + b*c))**(-n)*(a + b*x)**(m + S(1))*(-a*f + b*e)**p*AppellF1(m + S(1), -n, -p, m + S(2), -d*(a + b*x)/(-a*d + b*c), -f*(a + b*x)/(-a*f + b*e))/(m + S(1)), x) rule150 = ReplacementRule(pattern150, replacement150) pattern151 = Pattern(Integral((a_ + x_*WC('b', S(1)))**m_*(x_*WC('d', S(1)) + WC('c', S(0)))**n_*(x_*WC('f', S(1)) + WC('e', S(0)))**p_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons4, cons18, cons23, cons38, cons201, cons202) def replacement151(p, m, f, b, d, c, a, n, x, e): rubi.append(151) return Dist((b/(-a*d + b*c))**(-IntPart(n))*(b*(c + d*x)/(-a*d + b*c))**(-FracPart(n))*(c + d*x)**FracPart(n), Int((a + b*x)**m*(e + f*x)**p*(b*c/(-a*d + b*c) + b*d*x/(-a*d + b*c))**n, x), x) rule151 = ReplacementRule(pattern151, replacement151) pattern152 = Pattern(Integral((a_ + x_*WC('b', S(1)))**m_*(x_*WC('d', S(1)) + WC('c', S(0)))**n_*(x_*WC('f', S(1)) + WC('e', S(0)))**p_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons4, cons5, cons18, cons23, cons147, cons120, cons182, cons203, cons204) def replacement152(p, m, f, b, d, c, a, n, x, e): rubi.append(152) return Simp((b/(-a*d + b*c))**(-n)*(b/(-a*f + b*e))**(-p)*(a + b*x)**(m + S(1))*AppellF1(m + S(1), -n, -p, m + S(2), -d*(a + b*x)/(-a*d + b*c), -f*(a + b*x)/(-a*f + b*e))/(b*(m + S(1))), x) rule152 = ReplacementRule(pattern152, replacement152) pattern153 = Pattern(Integral((a_ + x_*WC('b', S(1)))**m_*(x_*WC('d', S(1)) + WC('c', S(0)))**n_*(x_*WC('f', S(1)) + WC('e', S(0)))**p_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons4, cons5, cons18, cons23, cons147, cons120, cons205) def replacement153(p, m, f, b, d, c, a, n, x, e): rubi.append(153) return Dist((b/(-a*f + b*e))**(-IntPart(p))*(b*(e + f*x)/(-a*f + b*e))**(-FracPart(p))*(e + f*x)**FracPart(p), Int((a + b*x)**m*(c + d*x)**n*(b*e/(-a*f + b*e) + b*f*x/(-a*f + b*e))**p, x), x) rule153 = ReplacementRule(pattern153, replacement153) pattern154 = Pattern(Integral((a_ + x_*WC('b', S(1)))**m_*(x_*WC('d', S(1)) + WC('c', S(0)))**n_*(x_*WC('f', S(1)) + WC('e', S(0)))**p_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons4, cons5, cons18, cons23, cons147, cons201, cons202, cons206) def replacement154(p, m, f, b, d, c, a, n, x, e): rubi.append(154) return Dist((b/(-a*d + b*c))**(-IntPart(n))*(b*(c + d*x)/(-a*d + b*c))**(-FracPart(n))*(c + d*x)**FracPart(n), Int((a + b*x)**m*(e + f*x)**p*(b*c/(-a*d + b*c) + b*d*x/(-a*d + b*c))**n, x), x) rule154 = ReplacementRule(pattern154, replacement154) pattern155 = Pattern(Integral((e_ + u_*WC('f', S(1)))**WC('p', S(1))*(u_*WC('b', S(1)) + WC('a', S(0)))**WC('m', S(1))*(u_*WC('d', S(1)) + WC('c', S(0)))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons4, cons5, cons68, cons69) def replacement155(p, u, m, f, b, d, a, c, n, x, e): rubi.append(155) return Dist(S(1)/Coefficient(u, x, S(1)), Subst(Int((a + b*x)**m*(c + d*x)**n*(e + f*x)**p, x), x, u), x) rule155 = ReplacementRule(pattern155, replacement155) pattern156 = Pattern(Integral((e_ + x_*WC('f', S(1)))*(x_*WC('b', S(1)) + WC('a', S(0)))**WC('m', S(1))*(x_*WC('d', S(1)) + WC('c', S(0)))**WC('n', S(1))*(x_*WC('h', S(1)) + WC('g', S(0))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons209, cons207) def replacement156(m, f, b, g, d, a, c, n, x, h, e): rubi.append(156) return Int(ExpandIntegrand((a + b*x)**m*(c + d*x)**n*(e + f*x)*(g + h*x), x), x) rule156 = ReplacementRule(pattern156, replacement156) pattern157 = Pattern(Integral((e_ + x_*WC('f', S(1)))*(x_*WC('b', S(1)) + WC('a', S(0)))**m_*(x_*WC('d', S(1)) + WC('c', S(0)))**WC('n', S(1))*(x_*WC('h', S(1)) + WC('g', S(0))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons209, cons21, cons4, cons72, cons66, cons210) def replacement157(m, f, b, g, d, c, a, n, x, h, e): rubi.append(157) return Dist((a*d*f*h*m + b*(-c*f*h*(m + S(2)) + d*(e*h + f*g)))/(b**S(2)*d), Int((a + b*x)**(m + S(1))*(c + d*x)**n, x), x) + Simp((a + b*x)**(m + S(1))*(c + d*x)**(n + S(1))*(-a**S(2)*d*f*h*m - a*b*(-c*f*h*(m + S(1)) + d*(e*h + f*g)) + b**S(2)*d*e*g + b*f*h*x*(m + S(1))*(-a*d + b*c))/(b**S(2)*d*(m + S(1))*(-a*d + b*c)), x) rule157 = ReplacementRule(pattern157, replacement157) pattern158 = Pattern(Integral((e_ + x_*WC('f', S(1)))*(x_*WC('b', S(1)) + WC('a', S(0)))**m_*(x_*WC('d', S(1)) + WC('c', S(0)))**n_*(x_*WC('h', S(1)) + WC('g', S(0))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons209, cons93, cons94, cons89) def replacement158(m, f, b, g, d, c, a, n, x, h, e): rubi.append(158) return -Dist((a**S(2)*d**S(2)*f*h*(n**S(2) + S(3)*n + S(2)) + a*b*d*(n + S(1))*(S(2)*c*f*h*(m + S(1)) - d*(e*h + f*g)*(m + n + S(3))) + b**S(2)*(c**S(2)*f*h*(m**S(2) + S(3)*m + S(2)) - c*d*(m + S(1))*(e*h + f*g)*(m + n + S(3)) + d**S(2)*e*g*(m**S(2) + m*(S(2)*n + S(5)) + n**S(2) + S(5)*n + S(6))))/(b*d*(m + S(1))*(n + S(1))*(-a*d + b*c)**S(2)), Int((a + b*x)**(m + S(1))*(c + d*x)**(n + S(1)), x), x) + Simp((a + b*x)**(m + S(1))*(c + d*x)**(n + S(1))*(a**S(2)*c*d*f*h*(n + S(1)) + a*b*(c**S(2)*f*h*(m + S(1)) - c*d*(e*h + f*g)*(m + n + S(2)) + d**S(2)*e*g*(m + S(1))) + b**S(2)*c*d*e*g*(n + S(1)) + x*(a**S(2)*d**S(2)*f*h*(n + S(1)) - a*b*d**S(2)*(n + S(1))*(e*h + f*g) + b**S(2)*(c**S(2)*f*h*(m + S(1)) - c*d*(m + S(1))*(e*h + f*g) + d**S(2)*e*g*(m + n + S(2)))))/(b*d*(m + S(1))*(n + S(1))*(-a*d + b*c)**S(2)), x) rule158 = ReplacementRule(pattern158, replacement158) pattern159 = Pattern(Integral((e_ + x_*WC('f', S(1)))*(x_*WC('b', S(1)) + WC('a', S(0)))**m_*(x_*WC('d', S(1)) + WC('c', S(0)))**WC('n', S(1))*(x_*WC('h', S(1)) + WC('g', S(0))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons209, cons21, cons4, cons211) def replacement159(m, f, b, g, d, c, a, n, x, h, e): rubi.append(159) return Dist(-d*(m + n + S(3))*(a**S(2)*d*f*h*(m - n) - a*b*(S(2)*c*f*h*(m + S(1)) - d*(n + S(1))*(e*h + f*g)) + b**S(2)*(c*(m + S(1))*(e*h + f*g) - d*e*g*(m + n + S(2))))/(b**S(2)*(m + S(1))*(m + S(2))*(-a*d + b*c)**S(2)) + f*h/b**S(2), Int((a + b*x)**(m + S(2))*(c + d*x)**n, x), x) + Simp((a + b*x)**(m + S(1))*(c + d*x)**(n + S(1))*(-a**S(3)*d*f*h*(n + S(2)) - a**S(2)*b*(c*f*h*m - d*(e*h + f*g)*(m + n + S(3))) - a*b**S(2)*(c*(e*h + f*g) + d*e*g*(S(2)*m + n + S(4))) + b**S(3)*c*e*g*(m + S(2)) + b*x*(a**S(2)*d*f*h*(m - n) - a*b*(S(2)*c*f*h*(m + S(1)) - d*(n + S(1))*(e*h + f*g)) + b**S(2)*(c*(m + S(1))*(e*h + f*g) - d*e*g*(m + n + S(2)))))/(b**S(2)*(m + S(1))*(m + S(2))*(-a*d + b*c)**S(2)), x) rule159 = ReplacementRule(pattern159, replacement159) pattern160 = Pattern(Integral((e_ + x_*WC('f', S(1)))*(x_*WC('b', S(1)) + WC('a', S(0)))**m_*(x_*WC('d', S(1)) + WC('c', S(0)))**WC('n', S(1))*(x_*WC('h', S(1)) + WC('g', S(0))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons209, cons21, cons4, cons212, cons66, cons213) def replacement160(m, f, b, g, d, c, a, n, x, h, e): rubi.append(160) return -Dist((a**S(2)*d**S(2)*f*h*(n + S(1))*(n + S(2)) + a*b*d*(n + S(1))*(S(2)*c*f*h*(m + S(1)) - d*(e*h + f*g)*(m + n + S(3))) + b**S(2)*(c**S(2)*f*h*(m + S(1))*(m + S(2)) - c*d*(m + S(1))*(e*h + f*g)*(m + n + S(3)) + d**S(2)*e*g*(m + n + S(2))*(m + n + S(3))))/(b**S(2)*d*(m + S(1))*(-a*d + b*c)*(m + n + S(3))), Int((a + b*x)**(m + S(1))*(c + d*x)**n, x), x) + Simp((a + b*x)**(m + S(1))*(c + d*x)**(n + S(1))*(a**S(2)*d*f*h*(n + S(2)) + a*b*(c*f*h*(m + S(1)) - d*(e*h + f*g)*(m + n + S(3))) + b**S(2)*d*e*g*(m + n + S(3)) + b*f*h*x*(m + S(1))*(-a*d + b*c))/(b**S(2)*d*(m + S(1))*(-a*d + b*c)*(m + n + S(3))), x) rule160 = ReplacementRule(pattern160, replacement160) pattern161 = Pattern(Integral((e_ + x_*WC('f', S(1)))*(x_*WC('b', S(1)) + WC('a', S(0)))**WC('m', S(1))*(x_*WC('d', S(1)) + WC('c', S(0)))**WC('n', S(1))*(x_*WC('h', S(1)) + WC('g', S(0))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons209, cons21, cons4, cons214, cons213) def replacement161(m, f, b, g, d, a, c, n, x, h, e): rubi.append(161) return Dist((a**S(2)*d**S(2)*f*h*(n + S(1))*(n + S(2)) + a*b*d*(n + S(1))*(S(2)*c*f*h*(m + S(1)) - d*(e*h + f*g)*(m + n + S(3))) + b**S(2)*(c**S(2)*f*h*(m + S(1))*(m + S(2)) - c*d*(m + S(1))*(e*h + f*g)*(m + n + S(3)) + d**S(2)*e*g*(m + n + S(2))*(m + n + S(3))))/(b**S(2)*d**S(2)*(m + n + S(2))*(m + n + S(3))), Int((a + b*x)**m*(c + d*x)**n, x), x) - Simp((a + b*x)**(m + S(1))*(c + d*x)**(n + S(1))*(a*d*f*h*(n + S(2)) + b*c*f*h*(m + S(2)) - b*d*f*h*x*(m + n + S(2)) - b*d*(e*h + f*g)*(m + n + S(3)))/(b**S(2)*d**S(2)*(m + n + S(2))*(m + n + S(3))), x) rule161 = ReplacementRule(pattern161, replacement161) pattern162 = Pattern(Integral((x_*WC('b', S(1)) + WC('a', S(0)))**m_*(x_*WC('d', S(1)) + WC('c', S(0)))**n_*(x_*WC('f', S(1)) + WC('e', S(0)))**p_*(x_*WC('h', S(1)) + WC('g', S(0))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons209, cons21, cons215) def replacement162(p, m, f, b, g, d, c, a, n, x, h, e): rubi.append(162) return Int(ExpandIntegrand((a + b*x)**m*(c + d*x)**n*(e + f*x)**p*(g + h*x), x), x) rule162 = ReplacementRule(pattern162, replacement162) pattern163 = Pattern(Integral((x_*WC('b', S(1)) + WC('a', S(0)))**m_*(x_*WC('d', S(1)) + WC('c', S(0)))**n_*(x_*WC('f', S(1)) + WC('e', S(0)))**p_*(x_*WC('h', S(1)) + WC('g', S(0))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons209, cons5, cons93, cons94, cons88, cons17) def replacement163(p, m, f, b, g, d, c, a, n, x, h, e): rubi.append(163) return -Dist(S(1)/(b*(m + S(1))*(-a*f + b*e)), Int((a + b*x)**(m + S(1))*(c + d*x)**(n + S(-1))*(e + f*x)**p*Simp(b*c*(m + S(1))*(-e*h + f*g) + d*x*(b*(m + S(1))*(-e*h + f*g) + f*(-a*h + b*g)*(n + p + S(1))) + (-a*h + b*g)*(c*f*(p + S(1)) + d*e*n), x), x), x) + Simp((a + b*x)**(m + S(1))*(c + d*x)**n*(e + f*x)**(p + S(1))*(-a*h + b*g)/(b*(m + S(1))*(-a*f + b*e)), x) rule163 = ReplacementRule(pattern163, replacement163) pattern164 = Pattern(Integral((x_*WC('b', S(1)) + WC('a', S(0)))**m_*(x_*WC('d', S(1)) + WC('c', S(0)))**n_*(x_*WC('f', S(1)) + WC('e', S(0)))**p_*(x_*WC('h', S(1)) + WC('g', S(0))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons209, cons5, cons93, cons94, cons88, cons170) def replacement164(p, m, f, b, g, d, c, a, n, x, h, e): rubi.append(164) return -Dist(S(1)/(b*(m + S(1))*(-a*f + b*e)), Int((a + b*x)**(m + S(1))*(c + d*x)**(n + S(-1))*(e + f*x)**p*Simp(b*c*(m + S(1))*(-e*h + f*g) + d*x*(b*(m + S(1))*(-e*h + f*g) + f*(-a*h + b*g)*(n + p + S(1))) + (-a*h + b*g)*(c*f*(p + S(1)) + d*e*n), x), x), x) + Simp((a + b*x)**(m + S(1))*(c + d*x)**n*(e + f*x)**(p + S(1))*(-a*h + b*g)/(b*(m + S(1))*(-a*f + b*e)), x) rule164 = ReplacementRule(pattern164, replacement164) pattern165 = Pattern(Integral((x_*WC('b', S(1)) + WC('a', S(0)))**m_*(x_*WC('d', S(1)) + WC('c', S(0)))**n_*(x_*WC('f', S(1)) + WC('e', S(0)))**p_*(x_*WC('h', S(1)) + WC('g', S(0))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons209, cons4, cons5, cons31, cons94, cons17) def replacement165(p, m, f, b, g, d, c, a, n, x, h, e): rubi.append(165) return Dist(S(1)/((m + S(1))*(-a*d + b*c)*(-a*f + b*e)), Int((a + b*x)**(m + S(1))*(c + d*x)**n*(e + f*x)**p*Simp(-d*f*x*(-a*h + b*g)*(m + n + p + S(3)) + (m + S(1))*(a*d*f*g + b*c*e*h - b*g*(c*f + d*e)) - (-a*h + b*g)*(c*f*(p + S(1)) + d*e*(n + S(1))), x), x), x) + Simp((a + b*x)**(m + S(1))*(c + d*x)**(n + S(1))*(e + f*x)**(p + S(1))*(-a*h + b*g)/((m + S(1))*(-a*d + b*c)*(-a*f + b*e)), x) rule165 = ReplacementRule(pattern165, replacement165) pattern166 = Pattern(Integral((x_*WC('b', S(1)) + WC('a', S(0)))**m_*(x_*WC('d', S(1)) + WC('c', S(0)))**n_*(x_*WC('f', S(1)) + WC('e', S(0)))**p_*(x_*WC('h', S(1)) + WC('g', S(0))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons209, cons4, cons5, cons31, cons94, cons170) def replacement166(p, m, f, b, g, d, c, a, n, x, h, e): rubi.append(166) return Dist(S(1)/((m + S(1))*(-a*d + b*c)*(-a*f + b*e)), Int((a + b*x)**(m + S(1))*(c + d*x)**n*(e + f*x)**p*Simp(-d*f*x*(-a*h + b*g)*(m + n + p + S(3)) + (m + S(1))*(a*d*f*g + b*c*e*h - b*g*(c*f + d*e)) - (-a*h + b*g)*(c*f*(p + S(1)) + d*e*(n + S(1))), x), x), x) + Simp((a + b*x)**(m + S(1))*(c + d*x)**(n + S(1))*(e + f*x)**(p + S(1))*(-a*h + b*g)/((m + S(1))*(-a*d + b*c)*(-a*f + b*e)), x) rule166 = ReplacementRule(pattern166, replacement166) pattern167 = Pattern(Integral((x_*WC('b', S(1)) + WC('a', S(0)))**m_*(x_*WC('d', S(1)) + WC('c', S(0)))**n_*(x_*WC('f', S(1)) + WC('e', S(0)))**p_*(x_*WC('h', S(1)) + WC('g', S(0))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons209, cons4, cons5, cons31, cons168, cons144, cons17) def replacement167(p, m, f, b, g, d, c, a, n, x, h, e): rubi.append(167) return Dist(S(1)/(d*f*(m + n + p + S(2))), Int((a + b*x)**(m + S(-1))*(c + d*x)**n*(e + f*x)**p*Simp(a*d*f*g*(m + n + p + S(2)) - h*(a*(c*f*(p + S(1)) + d*e*(n + S(1))) + b*c*e*m) + x*(b*d*f*g*(m + n + p + S(2)) + h*(a*d*f*m - b*(c*f*(m + p + S(1)) + d*e*(m + n + S(1))))), x), x), x) + Simp(h*(a + b*x)**m*(c + d*x)**(n + S(1))*(e + f*x)**(p + S(1))/(d*f*(m + n + p + S(2))), x) rule167 = ReplacementRule(pattern167, replacement167) pattern168 = Pattern(Integral((x_*WC('b', S(1)) + WC('a', S(0)))**m_*(x_*WC('d', S(1)) + WC('c', S(0)))**n_*(x_*WC('f', S(1)) + WC('e', S(0)))**p_*(x_*WC('h', S(1)) + WC('g', S(0))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons209, cons4, cons5, cons31, cons168, cons144, cons170) def replacement168(p, m, f, b, g, d, c, a, n, x, h, e): rubi.append(168) return Dist(S(1)/(d*f*(m + n + p + S(2))), Int((a + b*x)**(m + S(-1))*(c + d*x)**n*(e + f*x)**p*Simp(a*d*f*g*(m + n + p + S(2)) - h*(a*(c*f*(p + S(1)) + d*e*(n + S(1))) + b*c*e*m) + x*(b*d*f*g*(m + n + p + S(2)) + h*(a*d*f*m - b*(c*f*(m + p + S(1)) + d*e*(m + n + S(1))))), x), x), x) + Simp(h*(a + b*x)**m*(c + d*x)**(n + S(1))*(e + f*x)**(p + S(1))/(d*f*(m + n + p + S(2))), x) rule168 = ReplacementRule(pattern168, replacement168) pattern169 = Pattern(Integral((x_*WC('b', S(1)) + WC('a', S(0)))**m_*(x_*WC('d', S(1)) + WC('c', S(0)))**n_*(x_*WC('f', S(1)) + WC('e', S(0)))**p_*(x_*WC('h', S(1)) + WC('g', S(0))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons209, cons4, cons5, cons194, cons66, cons195) def replacement169(p, m, f, b, g, d, c, a, n, x, h, e): rubi.append(169) return Dist(S(1)/((m + S(1))*(-a*d + b*c)*(-a*f + b*e)), Int((a + b*x)**(m + S(1))*(c + d*x)**n*(e + f*x)**p*Simp(-d*f*x*(-a*h + b*g)*(m + n + p + S(3)) + (m + S(1))*(a*d*f*g + b*c*e*h - b*g*(c*f + d*e)) - (-a*h + b*g)*(c*f*(p + S(1)) + d*e*(n + S(1))), x), x), x) + Simp((a + b*x)**(m + S(1))*(c + d*x)**(n + S(1))*(e + f*x)**(p + S(1))*(-a*h + b*g)/((m + S(1))*(-a*d + b*c)*(-a*f + b*e)), x) rule169 = ReplacementRule(pattern169, replacement169) pattern170 = Pattern(Integral((x_*WC('f', S(1)) + WC('e', S(0)))**p_*(x_*WC('h', S(1)) + WC('g', S(0)))/((x_*WC('b', S(1)) + WC('a', S(0)))*(x_*WC('d', S(1)) + WC('c', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons209, cons216) def replacement170(p, f, b, g, d, c, a, x, h, e): rubi.append(170) return Dist((-a*h + b*g)/(-a*d + b*c), Int((e + f*x)**p/(a + b*x), x), x) - Dist((-c*h + d*g)/(-a*d + b*c), Int((e + f*x)**p/(c + d*x), x), x) rule170 = ReplacementRule(pattern170, replacement170) pattern171 = Pattern(Integral((x_*WC('d', S(1)) + WC('c', S(0)))**n_*(x_*WC('f', S(1)) + WC('e', S(0)))**p_*(x_*WC('h', S(1)) + WC('g', S(0)))/(x_*WC('b', S(1)) + WC('a', S(0))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons209, cons4, cons5, cons217) def replacement171(p, f, b, g, d, c, a, n, x, h, e): rubi.append(171) return Dist(h/b, Int((c + d*x)**n*(e + f*x)**p, x), x) + Dist((-a*h + b*g)/b, Int((c + d*x)**n*(e + f*x)**p/(a + b*x), x), x) rule171 = ReplacementRule(pattern171, replacement171) pattern172 = Pattern(Integral((x_*WC('h', S(1)) + WC('g', S(0)))/(sqrt(c_ + x_*WC('d', S(1)))*sqrt(e_ + x_*WC('f', S(1)))*sqrt(x_*WC('b', S(1)) + WC('a', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons209, cons188, cons218) def replacement172(f, b, g, d, a, c, x, h, e): rubi.append(172) return Dist(h/f, Int(sqrt(e + f*x)/(sqrt(a + b*x)*sqrt(c + d*x)), x), x) + Dist((-e*h + f*g)/f, Int(S(1)/(sqrt(a + b*x)*sqrt(c + d*x)*sqrt(e + f*x)), x), x) rule172 = ReplacementRule(pattern172, replacement172) pattern173 = Pattern(Integral((x_*WC('b', S(1)) + WC('a', S(0)))**m_*(x_*WC('d', S(1)) + WC('c', S(0)))**n_*(x_*WC('f', S(1)) + WC('e', S(0)))**p_*(x_*WC('h', S(1)) + WC('g', S(0))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons209, cons21, cons4, cons5, cons219) def replacement173(p, m, f, b, g, d, c, a, n, x, h, e): rubi.append(173) return Dist(h/b, Int((a + b*x)**(m + S(1))*(c + d*x)**n*(e + f*x)**p, x), x) + Dist((-a*h + b*g)/b, Int((a + b*x)**m*(c + d*x)**n*(e + f*x)**p, x), x) rule173 = ReplacementRule(pattern173, replacement173) pattern174 = Pattern(Integral((x_*WC('f', S(1)) + WC('e', S(0)))**p_*(x_*WC('h', S(1)) + WC('g', S(0)))**q_/((x_*WC('b', S(1)) + WC('a', S(0)))*(x_*WC('d', S(1)) + WC('c', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons209, cons50, cons13, cons145) def replacement174(p, f, b, g, d, c, a, x, h, q, e): rubi.append(174) return Dist((-a*f + b*e)/(-a*d + b*c), Int((e + f*x)**(p + S(-1))*(g + h*x)**q/(a + b*x), x), x) - Dist((-c*f + d*e)/(-a*d + b*c), Int((e + f*x)**(p + S(-1))*(g + h*x)**q/(c + d*x), x), x) rule174 = ReplacementRule(pattern174, replacement174) pattern175 = Pattern(Integral(S(1)/((x_*WC('b', S(1)) + WC('a', S(0)))*sqrt(x_*WC('d', S(1)) + WC('c', S(0)))*sqrt(x_*WC('f', S(1)) + WC('e', S(0)))*sqrt(x_*WC('h', S(1)) + WC('g', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons209, cons216) def replacement175(f, b, g, d, c, a, x, h, e): rubi.append(175) return Simp(-S(2)*sqrt(d*(e + f*x)/(-c*f + d*e))*sqrt(d*(g + h*x)/(-c*h + d*g))*EllipticPi(-b*(-c*f + d*e)/(f*(-a*d + b*c)), asin(sqrt(-f/(-c*f + d*e))*sqrt(c + d*x)), h*(-c*f + d*e)/(f*(-c*h + d*g)))/(sqrt(-f/(-c*f + d*e))*sqrt(e + f*x)*sqrt(g + h*x)*(-a*d + b*c)), x) rule175 = ReplacementRule(pattern175, replacement175) pattern176 = Pattern(Integral((x_*WC('d', S(1)) + WC('c', S(0)))**n_/((x_*WC('b', S(1)) + WC('a', S(0)))*sqrt(x_*WC('f', S(1)) + WC('e', S(0)))*sqrt(x_*WC('h', S(1)) + WC('g', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons209, cons80) def replacement176(f, b, g, d, c, a, n, x, h, e): rubi.append(176) return Int(ExpandIntegrand(S(1)/(sqrt(c + d*x)*sqrt(e + f*x)*sqrt(g + h*x)), (c + d*x)**(n + S(1)/2)/(a + b*x), x), x) rule176 = ReplacementRule(pattern176, replacement176) pattern177 = Pattern(Integral(sqrt(x_*WC('f', S(1)) + WC('e', S(0)))*sqrt(x_*WC('h', S(1)) + WC('g', S(0)))/((x_*WC('b', S(1)) + WC('a', S(0)))*sqrt(x_*WC('d', S(1)) + WC('c', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons209, cons216) def replacement177(f, b, g, d, c, a, x, h, e): rubi.append(177) return Dist(b**(S(-2)), Int((-a*f*h + b*e*h + b*f*g + b*f*h*x)/(sqrt(c + d*x)*sqrt(e + f*x)*sqrt(g + h*x)), x), x) + Dist((-a*f + b*e)*(-a*h + b*g)/b**S(2), Int(S(1)/((a + b*x)*sqrt(c + d*x)*sqrt(e + f*x)*sqrt(g + h*x)), x), x) rule177 = ReplacementRule(pattern177, replacement177) pattern178 = Pattern(Integral(S(1)/(sqrt(x_*WC('b', S(1)) + WC('a', S(0)))*sqrt(x_*WC('d', S(1)) + WC('c', S(0)))*sqrt(x_*WC('f', S(1)) + WC('e', S(0)))*sqrt(x_*WC('h', S(1)) + WC('g', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons209, cons216) def replacement178(f, b, g, d, c, a, x, h, e): rubi.append(178) return Dist(-S(2)*sqrt((c + d*x)*(-a*h + b*g)/((a + b*x)*(-c*h + d*g)))*sqrt((e + f*x)*(-a*h + b*g)/((a + b*x)*(-e*h + f*g)))*(a + b*x)/(sqrt(c + d*x)*sqrt(e + f*x)*(-a*h + b*g)), Subst(Int(S(1)/(sqrt(x**S(2)*(-a*d + b*c)/(-c*h + d*g) + S(1))*sqrt(x**S(2)*(-a*f + b*e)/(-e*h + f*g) + S(1))), x), x, sqrt(g + h*x)/sqrt(a + b*x)), x) rule178 = ReplacementRule(pattern178, replacement178) pattern179 = Pattern(Integral(sqrt(x_*WC('d', S(1)) + WC('c', S(0)))/((x_*WC('b', S(1)) + WC('a', S(0)))**(S(3)/2)*sqrt(x_*WC('f', S(1)) + WC('e', S(0)))*sqrt(x_*WC('h', S(1)) + WC('g', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons209, cons216) def replacement179(f, b, g, d, c, a, x, h, e): rubi.append(179) return Dist(-S(2)*sqrt((c + d*x)*(-a*h + b*g)/((a + b*x)*(-c*h + d*g)))*sqrt((e + f*x)*(-a*h + b*g)/((a + b*x)*(-e*h + f*g)))*(a + b*x)*(-c*h + d*g)/(sqrt(c + d*x)*sqrt(e + f*x)*(-a*h + b*g)**S(2)), Subst(Int(sqrt(x**S(2)*(-a*d + b*c)/(-c*h + d*g) + S(1))/sqrt(x**S(2)*(-a*f + b*e)/(-e*h + f*g) + S(1)), x), x, sqrt(g + h*x)/sqrt(a + b*x)), x) rule179 = ReplacementRule(pattern179, replacement179) pattern180 = Pattern(Integral(sqrt(x_*WC('b', S(1)) + WC('a', S(0)))/(sqrt(x_*WC('d', S(1)) + WC('c', S(0)))*sqrt(x_*WC('f', S(1)) + WC('e', S(0)))*sqrt(x_*WC('h', S(1)) + WC('g', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons209, cons216) def replacement180(f, b, g, d, c, a, x, h, e): rubi.append(180) return Dist(S(2)*sqrt((c + d*x)*(-a*h + b*g)/((a + b*x)*(-c*h + d*g)))*sqrt((e + f*x)*(-a*h + b*g)/((a + b*x)*(-e*h + f*g)))*(a + b*x)/(sqrt(c + d*x)*sqrt(e + f*x)), Subst(Int(S(1)/((-b*x**S(2) + h)*sqrt(x**S(2)*(-a*d + b*c)/(-c*h + d*g) + S(1))*sqrt(x**S(2)*(-a*f + b*e)/(-e*h + f*g) + S(1))), x), x, sqrt(g + h*x)/sqrt(a + b*x)), x) rule180 = ReplacementRule(pattern180, replacement180) pattern181 = Pattern(Integral(S(1)/((x_*WC('b', S(1)) + WC('a', S(0)))**(S(3)/2)*sqrt(x_*WC('d', S(1)) + WC('c', S(0)))*sqrt(x_*WC('f', S(1)) + WC('e', S(0)))*sqrt(x_*WC('h', S(1)) + WC('g', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons209, cons216) def replacement181(f, b, g, d, c, a, x, h, e): rubi.append(181) return Dist(b/(-a*d + b*c), Int(sqrt(c + d*x)/((a + b*x)**(S(3)/2)*sqrt(e + f*x)*sqrt(g + h*x)), x), x) - Dist(d/(-a*d + b*c), Int(S(1)/(sqrt(a + b*x)*sqrt(c + d*x)*sqrt(e + f*x)*sqrt(g + h*x)), x), x) rule181 = ReplacementRule(pattern181, replacement181) pattern182 = Pattern(Integral(sqrt(x_*WC('b', S(1)) + WC('a', S(0)))*sqrt(x_*WC('d', S(1)) + WC('c', S(0)))/(sqrt(x_*WC('f', S(1)) + WC('e', S(0)))*sqrt(x_*WC('h', S(1)) + WC('g', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons209, cons216) def replacement182(f, b, g, d, c, a, x, h, e): rubi.append(182) return Dist((a*d*f*h - b*(-c*f*h + d*e*h + d*f*g))/(S(2)*f**S(2)*h), Int(sqrt(e + f*x)/(sqrt(a + b*x)*sqrt(c + d*x)*sqrt(g + h*x)), x), x) + Dist((-c*f + d*e)*(-S(2)*a*f*h + b*e*h + b*f*g)/(S(2)*f**S(2)*h), Int(S(1)/(sqrt(a + b*x)*sqrt(c + d*x)*sqrt(e + f*x)*sqrt(g + h*x)), x), x) - Dist((-c*f + d*e)*(-e*h + f*g)/(S(2)*f*h), Int(sqrt(a + b*x)/(sqrt(c + d*x)*(e + f*x)**(S(3)/2)*sqrt(g + h*x)), x), x) + Simp(sqrt(a + b*x)*sqrt(c + d*x)*sqrt(g + h*x)/(h*sqrt(e + f*x)), x) rule182 = ReplacementRule(pattern182, replacement182) pattern183 = Pattern(Integral((x_*WC('b', S(1)) + WC('a', S(0)))**(S(3)/2)/(sqrt(x_*WC('d', S(1)) + WC('c', S(0)))*sqrt(x_*WC('f', S(1)) + WC('e', S(0)))*sqrt(x_*WC('h', S(1)) + WC('g', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons209, cons216) def replacement183(f, b, g, d, c, a, x, h, e): rubi.append(183) return Dist(b/d, Int(sqrt(a + b*x)*sqrt(c + d*x)/(sqrt(e + f*x)*sqrt(g + h*x)), x), x) - Dist((-a*d + b*c)/d, Int(sqrt(a + b*x)/(sqrt(c + d*x)*sqrt(e + f*x)*sqrt(g + h*x)), x), x) rule183 = ReplacementRule(pattern183, replacement183) pattern184 = Pattern(Integral((x_*WC('b', S(1)) + WC('a', S(0)))**m_*(x_*WC('d', S(1)) + WC('c', S(0)))**n_*(x_*WC('f', S(1)) + WC('e', S(0)))**p_*(x_*WC('h', S(1)) + WC('g', S(0)))**q_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons209, cons21, cons4, cons220) def replacement184(p, m, f, b, g, d, c, a, n, x, h, q, e): rubi.append(184) return Int(ExpandIntegrand((a + b*x)**m*(c + d*x)**n*(e + f*x)**p*(g + h*x)**q, x), x) rule184 = ReplacementRule(pattern184, replacement184) pattern185 = Pattern(Integral((x_*WC('b', S(1)) + WC('a', S(0)))**m_*(x_*WC('d', S(1)) + WC('c', S(0)))**n_*(x_*WC('f', S(1)) + WC('e', S(0)))**p_*(x_*WC('h', S(1)) + WC('g', S(0)))**q_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons209, cons21, cons4, cons5, cons221, cons219) def replacement185(p, m, f, b, g, d, c, a, n, x, h, q, e): rubi.append(185) return Dist(h/b, Int((a + b*x)**(m + S(1))*(c + d*x)**n*(e + f*x)**p*(g + h*x)**(q + S(-1)), x), x) + Dist((-a*h + b*g)/b, Int((a + b*x)**m*(c + d*x)**n*(e + f*x)**p*(g + h*x)**(q + S(-1)), x), x) rule185 = ReplacementRule(pattern185, replacement185) pattern186 = Pattern(Integral((x_*WC('b', S(1)) + WC('a', S(0)))**WC('m', S(1))*(x_*WC('d', S(1)) + WC('c', S(0)))**WC('n', S(1))*(x_*WC('f', S(1)) + WC('e', S(0)))**WC('p', S(1))*(x_*WC('h', S(1)) + WC('g', S(0)))**WC('q', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons209, cons21, cons4, cons5, cons50, cons222) def replacement186(p, m, f, b, g, d, a, c, n, x, h, q, e): rubi.append(186) return Int((a + b*x)**m*(c + d*x)**n*(e + f*x)**p*(g + h*x)**q, x) rule186 = ReplacementRule(pattern186, replacement186) pattern187 = Pattern(Integral((u_*WC('b', S(1)) + WC('a', S(0)))**WC('m', S(1))*(u_*WC('d', S(1)) + WC('c', S(0)))**WC('n', S(1))*(u_*WC('f', S(1)) + WC('e', S(0)))**WC('p', S(1))*(u_*WC('h', S(1)) + WC('g', S(0)))**WC('q', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons209, cons21, cons4, cons5, cons50, cons68, cons69) def replacement187(p, u, m, f, b, g, d, a, c, n, x, h, q, e): rubi.append(187) return Dist(S(1)/Coefficient(u, x, S(1)), Subst(Int((a + b*x)**m*(c + d*x)**n*(e + f*x)**p*(g + h*x)**q, x), x, u), x) rule187 = ReplacementRule(pattern187, replacement187) pattern188 = Pattern(Integral(((x_*WC('b', S(1)) + WC('a', S(0)))**m_*(x_*WC('d', S(1)) + WC('c', S(0)))**n_*(x_*WC('f', S(1)) + WC('e', S(0)))**p_*(x_*WC('h', S(1)) + WC('g', S(0)))**q_*WC('i', S(1)))**r_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons209, cons224, cons21, cons4, cons5, cons50, cons52, cons223) def replacement188(p, m, f, b, g, r, i, d, c, a, n, x, h, q, e): rubi.append(188) return Dist((i*(a + b*x)**m*(c + d*x)**n*(e + f*x)**p*(g + h*x)**q)**r*(a + b*x)**(-m*r)*(c + d*x)**(-n*r)*(e + f*x)**(-p*r)*(g + h*x)**(-q*r), Int((a + b*x)**(m*r)*(c + d*x)**(n*r)*(e + f*x)**(p*r)*(g + h*x)**(q*r), x), x) rule188 = ReplacementRule(pattern188, replacement188) return [rule37, rule38, rule39, rule40, rule41, rule42, rule43, rule44, rule45, rule46, rule47, rule48, rule49, rule50, rule51, rule52, rule53, rule54, rule55, rule56, rule57, rule58, rule59, rule60, rule61, rule62, rule63, rule64, rule65, rule66, rule67, rule68, rule69, rule70, rule71, rule72, rule73, rule74, rule75, rule76, rule77, rule78, rule79, rule80, rule81, rule82, rule83, rule84, rule85, rule86, rule87, rule88, rule89, rule90, rule91, rule92, rule93, rule94, rule95, rule96, rule97, rule98, rule99, rule100, rule101, rule102, rule103, rule104, rule105, rule106, rule107, rule108, rule109, rule110, rule111, rule112, rule113, rule114, rule115, rule116, rule117, rule118, rule119, rule120, rule121, rule122, rule123, rule124, rule125, rule126, rule127, rule128, rule129, rule130, rule131, rule132, rule133, rule134, rule135, rule136, rule137, rule138, rule139, rule140, rule141, rule142, rule143, rule144, rule145, rule146, rule147, rule148, rule149, rule150, rule151, rule152, rule153, rule154, rule155, rule156, rule157, rule158, rule159, rule160, rule161, rule162, rule163, rule164, rule165, rule166, rule167, rule168, rule169, rule170, rule171, rule172, rule173, rule174, rule175, rule176, rule177, rule178, rule179, rule180, rule181, rule182, rule183, rule184, rule185, rule186, rule187, rule188, ]
b3604f1926512d7617309200212ebf7f6b61da9acbb1f5ead185dbd58c6e300b
''' This code is automatically generated. Never edit it manually. For details of generating the code see `rubi_parsing_guide.md` in `parsetools`. ''' from sympy.external import import_module matchpy = import_module("matchpy") from sympy.utilities.decorator import doctest_depends_on if matchpy: from matchpy import Pattern, ReplacementRule, CustomConstraint, is_match from sympy.integrals.rubi.utility_function import ( Int, Sum, Set, With, Module, Scan, MapAnd, FalseQ, ZeroQ, NegativeQ, NonzeroQ, FreeQ, NFreeQ, List, Log, PositiveQ, PositiveIntegerQ, NegativeIntegerQ, IntegerQ, IntegersQ, ComplexNumberQ, PureComplexNumberQ, RealNumericQ, PositiveOrZeroQ, NegativeOrZeroQ, FractionOrNegativeQ, NegQ, Equal, Unequal, IntPart, FracPart, RationalQ, ProductQ, SumQ, NonsumQ, Subst, First, Rest, SqrtNumberQ, SqrtNumberSumQ, LinearQ, Sqrt, ArcCosh, Coefficient, Denominator, Hypergeometric2F1, Not, Simplify, FractionalPart, IntegerPart, AppellF1, EllipticPi, EllipticE, EllipticF, ArcTan, ArcCot, ArcCoth, ArcTanh, ArcSin, ArcSinh, ArcCos, ArcCsc, ArcSec, ArcCsch, ArcSech, Sinh, Tanh, Cosh, Sech, Csch, Coth, LessEqual, Less, Greater, GreaterEqual, FractionQ, IntLinearcQ, Expand, IndependentQ, PowerQ, IntegerPowerQ, PositiveIntegerPowerQ, FractionalPowerQ, AtomQ, ExpQ, LogQ, Head, MemberQ, TrigQ, SinQ, CosQ, TanQ, CotQ, SecQ, CscQ, Sin, Cos, Tan, Cot, Sec, Csc, HyperbolicQ, SinhQ, CoshQ, TanhQ, CothQ, SechQ, CschQ, InverseTrigQ, SinCosQ, SinhCoshQ, LeafCount, Numerator, NumberQ, NumericQ, Length, ListQ, Im, Re, InverseHyperbolicQ, InverseFunctionQ, TrigHyperbolicFreeQ, InverseFunctionFreeQ, RealQ, EqQ, FractionalPowerFreeQ, ComplexFreeQ, PolynomialQ, FactorSquareFree, PowerOfLinearQ, Exponent, QuadraticQ, LinearPairQ, BinomialParts, TrinomialParts, PolyQ, EvenQ, OddQ, PerfectSquareQ, NiceSqrtAuxQ, NiceSqrtQ, Together, PosAux, PosQ, CoefficientList, ReplaceAll, ExpandLinearProduct, GCD, ContentFactor, NumericFactor, NonnumericFactors, MakeAssocList, GensymSubst, KernelSubst, ExpandExpression, Apart, SmartApart, MatchQ, PolynomialQuotientRemainder, FreeFactors, NonfreeFactors, RemoveContentAux, RemoveContent, FreeTerms, NonfreeTerms, ExpandAlgebraicFunction, CollectReciprocals, ExpandCleanup, AlgebraicFunctionQ, Coeff, LeadTerm, RemainingTerms, LeadFactor, RemainingFactors, LeadBase, LeadDegree, Numer, Denom, hypergeom, Expon, MergeMonomials, PolynomialDivide, BinomialQ, TrinomialQ, GeneralizedBinomialQ, GeneralizedTrinomialQ, FactorSquareFreeList, PerfectPowerTest, SquareFreeFactorTest, RationalFunctionQ, RationalFunctionFactors, NonrationalFunctionFactors, Reverse, RationalFunctionExponents, RationalFunctionExpand, ExpandIntegrand, SimplerQ, SimplerSqrtQ, SumSimplerQ, BinomialDegree, TrinomialDegree, CancelCommonFactors, SimplerIntegrandQ, GeneralizedBinomialDegree, GeneralizedBinomialParts, GeneralizedTrinomialDegree, GeneralizedTrinomialParts, MonomialQ, MonomialSumQ, MinimumMonomialExponent, MonomialExponent, LinearMatchQ, PowerOfLinearMatchQ, QuadraticMatchQ, CubicMatchQ, BinomialMatchQ, TrinomialMatchQ, GeneralizedBinomialMatchQ, GeneralizedTrinomialMatchQ, QuotientOfLinearsMatchQ, PolynomialTermQ, PolynomialTerms, NonpolynomialTerms, PseudoBinomialParts, NormalizePseudoBinomial, PseudoBinomialPairQ, PseudoBinomialQ, PolynomialGCD, PolyGCD, AlgebraicFunctionFactors, NonalgebraicFunctionFactors, QuotientOfLinearsP, QuotientOfLinearsParts, QuotientOfLinearsQ, Flatten, Sort, AbsurdNumberQ, AbsurdNumberFactors, NonabsurdNumberFactors, SumSimplerAuxQ, Prepend, Drop, CombineExponents, FactorInteger, FactorAbsurdNumber, SubstForInverseFunction, SubstForFractionalPower, SubstForFractionalPowerOfQuotientOfLinears, FractionalPowerOfQuotientOfLinears, SubstForFractionalPowerQ, SubstForFractionalPowerAuxQ, FractionalPowerOfSquareQ, FractionalPowerSubexpressionQ, Apply, FactorNumericGcd, MergeableFactorQ, MergeFactor, MergeFactors, TrigSimplifyQ, TrigSimplify, TrigSimplifyRecur, Order, FactorOrder, Smallest, OrderedQ, MinimumDegree, PositiveFactors, Sign, NonpositiveFactors, PolynomialInAuxQ, PolynomialInQ, ExponentInAux, ExponentIn, PolynomialInSubstAux, PolynomialInSubst, Distrib, DistributeDegree, FunctionOfPower, DivideDegreesOfFactors, MonomialFactor, FullSimplify, FunctionOfLinearSubst, FunctionOfLinear, NormalizeIntegrand, NormalizeIntegrandAux, NormalizeIntegrandFactor, NormalizeIntegrandFactorBase, NormalizeTogether, NormalizeLeadTermSigns, AbsorbMinusSign, NormalizeSumFactors, SignOfFactor, NormalizePowerOfLinear, SimplifyIntegrand, SimplifyTerm, TogetherSimplify, SmartSimplify, SubstForExpn, ExpandToSum, UnifySum, UnifyTerms, UnifyTerm, CalculusQ, FunctionOfInverseLinear, PureFunctionOfSinhQ, PureFunctionOfTanhQ, PureFunctionOfCoshQ, IntegerQuotientQ, OddQuotientQ, EvenQuotientQ, FindTrigFactor, FunctionOfSinhQ, FunctionOfCoshQ, OddHyperbolicPowerQ, FunctionOfTanhQ, FunctionOfTanhWeight, FunctionOfHyperbolicQ, SmartNumerator, SmartDenominator, SubstForAux, ActivateTrig, ExpandTrig, TrigExpand, SubstForTrig, SubstForHyperbolic, InertTrigFreeQ, LCM, SubstForFractionalPowerOfLinear, FractionalPowerOfLinear, InverseFunctionOfLinear, InertTrigQ, InertReciprocalQ, DeactivateTrig, FixInertTrigFunction, DeactivateTrigAux, PowerOfInertTrigSumQ, PiecewiseLinearQ, KnownTrigIntegrandQ, KnownSineIntegrandQ, KnownTangentIntegrandQ, KnownCotangentIntegrandQ, KnownSecantIntegrandQ, TryPureTanSubst, TryTanhSubst, TryPureTanhSubst, AbsurdNumberGCD, AbsurdNumberGCDList, ExpandTrigExpand, ExpandTrigReduce, ExpandTrigReduceAux, NormalizeTrig, TrigToExp, ExpandTrigToExp, TrigReduce, FunctionOfTrig, AlgebraicTrigFunctionQ, FunctionOfHyperbolic, FunctionOfQ, FunctionOfExpnQ, PureFunctionOfSinQ, PureFunctionOfCosQ, PureFunctionOfTanQ, PureFunctionOfCotQ, FunctionOfCosQ, FunctionOfSinQ, OddTrigPowerQ, FunctionOfTanQ, FunctionOfTanWeight, FunctionOfTrigQ, FunctionOfDensePolynomialsQ, FunctionOfLog, PowerVariableExpn, PowerVariableDegree, PowerVariableSubst, EulerIntegrandQ, FunctionOfSquareRootOfQuadratic, SquareRootOfQuadraticSubst, Divides, EasyDQ, ProductOfLinearPowersQ, Rt, NthRoot, AtomBaseQ, SumBaseQ, NegSumBaseQ, AllNegTermQ, SomeNegTermQ, TrigSquareQ, RtAux, TrigSquare, IntSum, IntTerm, Map2, ConstantFactor, SameQ, ReplacePart, CommonFactors, MostMainFactorPosition, FunctionOfExponentialQ, FunctionOfExponential, FunctionOfExponentialFunction, FunctionOfExponentialFunctionAux, FunctionOfExponentialTest, FunctionOfExponentialTestAux, stdev, rubi_test, If, IntQuadraticQ, IntBinomialQ, RectifyTangent, RectifyCotangent, Inequality, Condition, Simp, SimpHelp, SplitProduct, SplitSum, SubstFor, SubstForAux, FresnelS, FresnelC, Erfc, Erfi, Gamma, FunctionOfTrigOfLinearQ, ElementaryFunctionQ, Complex, UnsameQ, _SimpFixFactor, SimpFixFactor, _FixSimplify, FixSimplify, _SimplifyAntiderivativeSum, SimplifyAntiderivativeSum, _SimplifyAntiderivative, SimplifyAntiderivative, _TrigSimplifyAux, TrigSimplifyAux, Cancel, Part, PolyLog, D, Dist, Sum_doit, PolynomialQuotient, Floor, PolynomialRemainder, Factor, PolyLog, CosIntegral, SinIntegral, LogIntegral, SinhIntegral, CoshIntegral, Rule, Erf, PolyGamma, ExpIntegralEi, ExpIntegralE, LogGamma , UtilityOperator, Factorial, Zeta, ProductLog, DerivativeDivides, HypergeometricPFQ, IntHide, OneQ, Null, rubi_exp as exp, rubi_log as log, Discriminant, Negative, Quotient ) from sympy import (Integral, S, sqrt, And, Or, Integer, Float, Mod, I, Abs, simplify, Mul, Add, Pow, sign, EulerGamma) from sympy.integrals.rubi.symbol import WC from sympy.core.symbol import symbols, Symbol from sympy.functions import (sin, cos, tan, cot, csc, sec, sqrt, erf) from sympy.functions.elementary.hyperbolic import (acosh, asinh, atanh, acoth, acsch, asech, cosh, sinh, tanh, coth, sech, csch) from sympy.functions.elementary.trigonometric import (atan, acsc, asin, acot, acos, asec, atan2) from sympy import pi as Pi A_, B_, C_, F_, G_, H_, a_, b_, c_, d_, e_, f_, g_, h_, i_, j_, k_, l_, m_, n_, p_, q_, r_, t_, u_, v_, s_, w_, x_, y_, z_ = [WC(i) for i in 'ABCFGHabcdefghijklmnpqrtuvswxyz'] a1_, a2_, b1_, b2_, c1_, c2_, d1_, d2_, n1_, n2_, e1_, e2_, f1_, f2_, g1_, g2_, n1_, n2_, n3_, Pq_, Pm_, Px_, Qm_, Qr_, Qx_, jn_, mn_, non2_, RFx_, RGx_ = [WC(i) for i in ['a1', 'a2', 'b1', 'b2', 'c1', 'c2', 'd1', 'd2', 'n1', 'n2', 'e1', 'e2', 'f1', 'f2', 'g1', 'g2', 'n1', 'n2', 'n3', 'Pq', 'Pm', 'Px', 'Qm', 'Qr', 'Qx', 'jn', 'mn', 'non2', 'RFx', 'RGx']] i, ii , Pqq, Q, R, r, C, k, u = symbols('i ii Pqq Q R r C k u') _UseGamma = False ShowSteps = False StepCounter = None def hyperbolic(rubi): from sympy.integrals.rubi.constraints import cons31, cons168, cons7, cons27, cons48, cons125, cons94, cons1116, cons176, cons1488, cons21, cons87, cons165, cons3, cons93, cons166, cons85, cons1489, cons245, cons247, cons89, cons1442, cons148, cons1859, cons2, cons1490, cons1439, cons808, cons1491, cons1492, cons1454, cons1440, cons62, cons1267, cons1493, cons810, cons811, cons4, cons1360, cons128, cons38, cons137, cons744, cons63, cons1494, cons196, cons1495, cons5, cons53, cons13, cons596, cons1496, cons17, cons1497, cons376, cons146, cons489, cons1498, cons68, cons69, cons823, cons824, cons1499, cons1501, cons1255, cons1502, cons56, cons150, cons1503, cons1504, cons683, cons367, cons1505, cons356, cons66, cons854, cons23, cons1506, cons54, cons14, cons818, cons1131, cons1132, cons1133, cons1507, cons819, cons528, cons1265, cons1510, cons18, cons1571, cons1572, cons1573, cons1574, cons1575, cons1576, cons1577, cons1578, cons1579, cons1043, cons1580, cons1644, cons1736, cons1645, cons584, cons464, cons1683, cons1408, cons1684, cons1685, cons1860, cons1861, cons1688, cons812, cons813, cons555, cons1862, cons1863, cons25, cons1691, cons1864, cons1099, cons1865, cons1866, cons1395, cons1867, cons1693, cons1868, cons963, cons1869, cons1870, cons208, cons1700, cons1011, cons1551, cons1701, cons1702, cons209, cons224, cons1699, cons1871, cons1703, cons1704, cons1872, cons1706, cons1707, cons1873, cons1874, cons1875, cons1876, cons1877, cons1878, cons1879, cons1880, cons1881, cons1882, cons1883, cons1884, cons1885, cons1886, cons1720, cons1887, cons1888, cons1889, cons1723, cons1890, cons163, cons338, cons162, cons627, cons71, cons1725, cons1726, cons1727, cons88, cons1728, cons1456, cons463, cons1729, cons1478, cons1730, cons1891, cons34, cons35, cons1474, cons1481, cons1733 pattern5643 = Pattern(Integral((x_*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1))*sinh(x_*WC('f', S(1)) + WC('e', S(0))), x_), cons7, cons27, cons48, cons125, cons31, cons168) def replacement5643(m, f, d, c, x, e): rubi.append(5643) return -Dist(d*m/f, Int((c + d*x)**(m + S(-1))*cosh(e + f*x), x), x) + Simp((c + d*x)**m*cosh(e + f*x)/f, x) rule5643 = ReplacementRule(pattern5643, replacement5643) pattern5644 = Pattern(Integral((x_*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1))*cosh(x_*WC('f', S(1)) + WC('e', S(0))), x_), cons7, cons27, cons48, cons125, cons31, cons168) def replacement5644(m, f, d, c, x, e): rubi.append(5644) return -Dist(d*m/f, Int((c + d*x)**(m + S(-1))*sinh(e + f*x), x), x) + Simp((c + d*x)**m*sinh(e + f*x)/f, x) rule5644 = ReplacementRule(pattern5644, replacement5644) pattern5645 = Pattern(Integral((x_*WC('d', S(1)) + WC('c', S(0)))**m_*sinh(x_*WC('f', S(1)) + WC('e', S(0))), x_), cons7, cons27, cons48, cons125, cons31, cons94) def replacement5645(m, f, d, c, x, e): rubi.append(5645) return -Dist(f/(d*(m + S(1))), Int((c + d*x)**(m + S(1))*cosh(e + f*x), x), x) + Simp((c + d*x)**(m + S(1))*sinh(e + f*x)/(d*(m + S(1))), x) rule5645 = ReplacementRule(pattern5645, replacement5645) pattern5646 = Pattern(Integral((x_*WC('d', S(1)) + WC('c', S(0)))**m_*cosh(x_*WC('f', S(1)) + WC('e', S(0))), x_), cons7, cons27, cons48, cons125, cons31, cons94) def replacement5646(m, f, d, c, x, e): rubi.append(5646) return -Dist(f/(d*(m + S(1))), Int((c + d*x)**(m + S(1))*sinh(e + f*x), x), x) + Simp((c + d*x)**(m + S(1))*cosh(e + f*x)/(d*(m + S(1))), x) rule5646 = ReplacementRule(pattern5646, replacement5646) pattern5647 = Pattern(Integral(sinh(x_*WC('f', S(1)) + WC('e', S(0)))/(x_*WC('d', S(1)) + WC('c', S(0))), x_), cons7, cons27, cons48, cons125, cons1116) def replacement5647(f, d, c, x, e): rubi.append(5647) return Simp(SinhIntegral(e + f*x)/d, x) rule5647 = ReplacementRule(pattern5647, replacement5647) pattern5648 = Pattern(Integral(cosh(x_*WC('f', S(1)) + WC('e', S(0)))/(x_*WC('d', S(1)) + WC('c', S(0))), x_), cons7, cons27, cons48, cons125, cons1116) def replacement5648(f, d, c, x, e): rubi.append(5648) return Simp(CoshIntegral(e + f*x)/d, x) rule5648 = ReplacementRule(pattern5648, replacement5648) pattern5649 = Pattern(Integral(sinh(x_*WC('f', S(1)) + WC('e', S(0)))/(x_*WC('d', S(1)) + WC('c', S(0))), x_), cons7, cons27, cons48, cons125, cons176) def replacement5649(f, d, c, x, e): rubi.append(5649) return Dist(sinh((-c*f + d*e)/d), Int(cosh(c*f/d + f*x)/(c + d*x), x), x) + Dist(cosh((-c*f + d*e)/d), Int(sinh(c*f/d + f*x)/(c + d*x), x), x) rule5649 = ReplacementRule(pattern5649, replacement5649) pattern5650 = Pattern(Integral(cosh(x_*WC('f', S(1)) + WC('e', S(0)))/(x_*WC('d', S(1)) + WC('c', S(0))), x_), cons7, cons27, cons48, cons125, cons176) def replacement5650(f, d, c, x, e): rubi.append(5650) return Dist(sinh((-c*f + d*e)/d), Int(sinh(c*f/d + f*x)/(c + d*x), x), x) + Dist(cosh((-c*f + d*e)/d), Int(cosh(c*f/d + f*x)/(c + d*x), x), x) rule5650 = ReplacementRule(pattern5650, replacement5650) pattern5651 = Pattern(Integral((x_*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1))*sinh(x_*WC('f', S(1)) + WC('e', S(0))), x_), cons7, cons27, cons48, cons125, cons21, cons1488) def replacement5651(m, f, d, c, x, e): rubi.append(5651) return -Dist(S(1)/2, Int((c + d*x)**m*exp(-e - f*x), x), x) + Dist(S(1)/2, Int((c + d*x)**m*exp(e + f*x), x), x) rule5651 = ReplacementRule(pattern5651, replacement5651) pattern5652 = Pattern(Integral((x_*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1))*cosh(x_*WC('f', S(1)) + WC('e', S(0))), x_), cons7, cons27, cons48, cons125, cons21, cons1488) def replacement5652(m, f, d, c, x, e): rubi.append(5652) return Dist(S(1)/2, Int((c + d*x)**m*exp(-e - f*x), x), x) + Dist(S(1)/2, Int((c + d*x)**m*exp(e + f*x), x), x) rule5652 = ReplacementRule(pattern5652, replacement5652) pattern5653 = Pattern(Integral((WC('b', S(1))*sinh(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(x_*WC('d', S(1)) + WC('c', S(0))), x_), cons3, cons7, cons27, cons48, cons125, cons87, cons165) def replacement5653(f, b, d, c, n, x, e): rubi.append(5653) return -Dist(b**S(2)*(n + S(-1))/n, Int((b*sinh(e + f*x))**(n + S(-2))*(c + d*x), x), x) - Simp(d*(b*sinh(e + f*x))**n/(f**S(2)*n**S(2)), x) + Simp(b*(b*sinh(e + f*x))**(n + S(-1))*(c + d*x)*cosh(e + f*x)/(f*n), x) rule5653 = ReplacementRule(pattern5653, replacement5653) pattern5654 = Pattern(Integral((WC('b', S(1))*cosh(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(x_*WC('d', S(1)) + WC('c', S(0))), x_), cons3, cons7, cons27, cons48, cons125, cons87, cons165) def replacement5654(f, b, d, c, n, x, e): rubi.append(5654) return Dist(b**S(2)*(n + S(-1))/n, Int((b*cosh(e + f*x))**(n + S(-2))*(c + d*x), x), x) - Simp(d*(b*cosh(e + f*x))**n/(f**S(2)*n**S(2)), x) + Simp(b*(b*cosh(e + f*x))**(n + S(-1))*(c + d*x)*sinh(e + f*x)/(f*n), x) rule5654 = ReplacementRule(pattern5654, replacement5654) pattern5655 = Pattern(Integral((WC('b', S(1))*sinh(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(x_*WC('d', S(1)) + WC('c', S(0)))**m_, x_), cons3, cons7, cons27, cons48, cons125, cons93, cons165, cons166) def replacement5655(m, f, b, d, c, n, x, e): rubi.append(5655) return -Dist(b**S(2)*(n + S(-1))/n, Int((b*sinh(e + f*x))**(n + S(-2))*(c + d*x)**m, x), x) + Dist(d**S(2)*m*(m + S(-1))/(f**S(2)*n**S(2)), Int((b*sinh(e + f*x))**n*(c + d*x)**(m + S(-2)), x), x) + Simp(b*(b*sinh(e + f*x))**(n + S(-1))*(c + d*x)**m*cosh(e + f*x)/(f*n), x) - Simp(d*m*(b*sinh(e + f*x))**n*(c + d*x)**(m + S(-1))/(f**S(2)*n**S(2)), x) rule5655 = ReplacementRule(pattern5655, replacement5655) pattern5656 = Pattern(Integral((WC('b', S(1))*cosh(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(x_*WC('d', S(1)) + WC('c', S(0)))**m_, x_), cons3, cons7, cons27, cons48, cons125, cons93, cons165, cons166) def replacement5656(m, f, b, d, c, n, x, e): rubi.append(5656) return Dist(b**S(2)*(n + S(-1))/n, Int((b*cosh(e + f*x))**(n + S(-2))*(c + d*x)**m, x), x) + Dist(d**S(2)*m*(m + S(-1))/(f**S(2)*n**S(2)), Int((b*cosh(e + f*x))**n*(c + d*x)**(m + S(-2)), x), x) + Simp(b*(b*cosh(e + f*x))**(n + S(-1))*(c + d*x)**m*sinh(e + f*x)/(f*n), x) - Simp(d*m*(b*cosh(e + f*x))**n*(c + d*x)**(m + S(-1))/(f**S(2)*n**S(2)), x) rule5656 = ReplacementRule(pattern5656, replacement5656) pattern5657 = Pattern(Integral((x_*WC('d', S(1)) + WC('c', S(0)))**m_*sinh(x_*WC('f', S(1)) + WC('e', S(0)))**n_, x_), cons7, cons27, cons48, cons125, cons21, cons85, cons165, cons1489) def replacement5657(m, f, d, c, n, x, e): rubi.append(5657) return Int(ExpandTrigReduce((c + d*x)**m, sinh(e + f*x)**n, x), x) rule5657 = ReplacementRule(pattern5657, replacement5657) pattern5658 = Pattern(Integral((x_*WC('d', S(1)) + WC('c', S(0)))**m_*cosh(x_*WC('f', S(1)) + WC('e', S(0)))**n_, x_), cons7, cons27, cons48, cons125, cons21, cons85, cons165, cons1489) def replacement5658(m, f, d, c, n, x, e): rubi.append(5658) return Int(ExpandTrigReduce((c + d*x)**m, cosh(e + f*x)**n, x), x) rule5658 = ReplacementRule(pattern5658, replacement5658) pattern5659 = Pattern(Integral((x_*WC('d', S(1)) + WC('c', S(0)))**m_*sinh(x_*WC('f', S(1)) + WC('e', S(0)))**n_, x_), cons7, cons27, cons48, cons125, cons21, cons85, cons165, cons31, cons245) def replacement5659(m, f, d, c, n, x, e): rubi.append(5659) return -Dist(f*n/(d*(m + S(1))), Int(ExpandTrigReduce((c + d*x)**(m + S(1)), sinh(e + f*x)**(n + S(-1))*cosh(e + f*x), x), x), x) + Simp((c + d*x)**(m + S(1))*sinh(e + f*x)**n/(d*(m + S(1))), x) rule5659 = ReplacementRule(pattern5659, replacement5659) pattern5660 = Pattern(Integral((x_*WC('d', S(1)) + WC('c', S(0)))**m_*cosh(x_*WC('f', S(1)) + WC('e', S(0)))**n_, x_), cons7, cons27, cons48, cons125, cons21, cons85, cons165, cons31, cons245) def replacement5660(m, f, d, c, n, x, e): rubi.append(5660) return -Dist(f*n/(d*(m + S(1))), Int(ExpandTrigReduce((c + d*x)**(m + S(1)), sinh(e + f*x)*cosh(e + f*x)**(n + S(-1)), x), x), x) + Simp((c + d*x)**(m + S(1))*cosh(e + f*x)**n/(d*(m + S(1))), x) rule5660 = ReplacementRule(pattern5660, replacement5660) pattern5661 = Pattern(Integral((WC('b', S(1))*sinh(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(x_*WC('d', S(1)) + WC('c', S(0)))**m_, x_), cons3, cons7, cons27, cons48, cons125, cons93, cons165, cons247) def replacement5661(m, f, b, d, c, n, x, e): rubi.append(5661) return Dist(f**S(2)*n**S(2)/(d**S(2)*(m + S(1))*(m + S(2))), Int((b*sinh(e + f*x))**n*(c + d*x)**(m + S(2)), x), x) + Dist(b**S(2)*f**S(2)*n*(n + S(-1))/(d**S(2)*(m + S(1))*(m + S(2))), Int((b*sinh(e + f*x))**(n + S(-2))*(c + d*x)**(m + S(2)), x), x) + Simp((b*sinh(e + f*x))**n*(c + d*x)**(m + S(1))/(d*(m + S(1))), x) - Simp(b*f*n*(b*sinh(e + f*x))**(n + S(-1))*(c + d*x)**(m + S(2))*cosh(e + f*x)/(d**S(2)*(m + S(1))*(m + S(2))), x) rule5661 = ReplacementRule(pattern5661, replacement5661) pattern5662 = Pattern(Integral((WC('b', S(1))*cosh(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(x_*WC('d', S(1)) + WC('c', S(0)))**m_, x_), cons3, cons7, cons27, cons48, cons125, cons93, cons165, cons247) def replacement5662(m, f, b, d, c, n, x, e): rubi.append(5662) return Dist(f**S(2)*n**S(2)/(d**S(2)*(m + S(1))*(m + S(2))), Int((b*cosh(e + f*x))**n*(c + d*x)**(m + S(2)), x), x) - Dist(b**S(2)*f**S(2)*n*(n + S(-1))/(d**S(2)*(m + S(1))*(m + S(2))), Int((b*cosh(e + f*x))**(n + S(-2))*(c + d*x)**(m + S(2)), x), x) + Simp((b*cosh(e + f*x))**n*(c + d*x)**(m + S(1))/(d*(m + S(1))), x) - Simp(b*f*n*(b*cosh(e + f*x))**(n + S(-1))*(c + d*x)**(m + S(2))*sinh(e + f*x)/(d**S(2)*(m + S(1))*(m + S(2))), x) rule5662 = ReplacementRule(pattern5662, replacement5662) pattern5663 = Pattern(Integral((WC('b', S(1))*sinh(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(x_*WC('d', S(1)) + WC('c', S(0))), x_), cons3, cons7, cons27, cons48, cons125, cons87, cons89, cons1442) def replacement5663(f, b, d, c, n, x, e): rubi.append(5663) return -Dist((n + S(2))/(b**S(2)*(n + S(1))), Int((b*sinh(e + f*x))**(n + S(2))*(c + d*x), x), x) - Simp(d*(b*sinh(e + f*x))**(n + S(2))/(b**S(2)*f**S(2)*(n + S(1))*(n + S(2))), x) + Simp((b*sinh(e + f*x))**(n + S(1))*(c + d*x)*cosh(e + f*x)/(b*f*(n + S(1))), x) rule5663 = ReplacementRule(pattern5663, replacement5663) pattern5664 = Pattern(Integral((WC('b', S(1))*cosh(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(x_*WC('d', S(1)) + WC('c', S(0))), x_), cons3, cons7, cons27, cons48, cons125, cons87, cons89, cons1442) def replacement5664(f, b, d, c, n, x, e): rubi.append(5664) return Dist((n + S(2))/(b**S(2)*(n + S(1))), Int((b*cosh(e + f*x))**(n + S(2))*(c + d*x), x), x) + Simp(d*(b*cosh(e + f*x))**(n + S(2))/(b**S(2)*f**S(2)*(n + S(1))*(n + S(2))), x) - Simp((b*cosh(e + f*x))**(n + S(1))*(c + d*x)*sinh(e + f*x)/(b*f*(n + S(1))), x) rule5664 = ReplacementRule(pattern5664, replacement5664) pattern5665 = Pattern(Integral((WC('b', S(1))*sinh(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(x_*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1)), x_), cons3, cons7, cons27, cons48, cons125, cons93, cons89, cons1442, cons166) def replacement5665(m, f, b, d, c, n, x, e): rubi.append(5665) return -Dist((n + S(2))/(b**S(2)*(n + S(1))), Int((b*sinh(e + f*x))**(n + S(2))*(c + d*x)**m, x), x) + Dist(d**S(2)*m*(m + S(-1))/(b**S(2)*f**S(2)*(n + S(1))*(n + S(2))), Int((b*sinh(e + f*x))**(n + S(2))*(c + d*x)**(m + S(-2)), x), x) + Simp((b*sinh(e + f*x))**(n + S(1))*(c + d*x)**m*cosh(e + f*x)/(b*f*(n + S(1))), x) - Simp(d*m*(b*sinh(e + f*x))**(n + S(2))*(c + d*x)**(m + S(-1))/(b**S(2)*f**S(2)*(n + S(1))*(n + S(2))), x) rule5665 = ReplacementRule(pattern5665, replacement5665) pattern5666 = Pattern(Integral((WC('b', S(1))*cosh(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(x_*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1)), x_), cons3, cons7, cons27, cons48, cons125, cons93, cons89, cons1442, cons166) def replacement5666(m, f, b, d, c, n, x, e): rubi.append(5666) return Dist((n + S(2))/(b**S(2)*(n + S(1))), Int((b*cosh(e + f*x))**(n + S(2))*(c + d*x)**m, x), x) - Dist(d**S(2)*m*(m + S(-1))/(b**S(2)*f**S(2)*(n + S(1))*(n + S(2))), Int((b*cosh(e + f*x))**(n + S(2))*(c + d*x)**(m + S(-2)), x), x) - Simp((b*cosh(e + f*x))**(n + S(1))*(c + d*x)**m*sinh(e + f*x)/(b*f*(n + S(1))), x) + Simp(d*m*(b*cosh(e + f*x))**(n + S(2))*(c + d*x)**(m + S(-1))/(b**S(2)*f**S(2)*(n + S(1))*(n + S(2))), x) rule5666 = ReplacementRule(pattern5666, replacement5666) pattern5667 = Pattern(Integral((a_ + WC('b', S(1))*sinh(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1))*(x_*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons148, cons1859) def replacement5667(m, f, b, d, c, n, a, x, e): rubi.append(5667) return Int(ExpandIntegrand((c + d*x)**m, (a + b*sinh(e + f*x))**n, x), x) rule5667 = ReplacementRule(pattern5667, replacement5667) pattern5668 = Pattern(Integral((a_ + WC('b', S(1))*cosh(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1))*(x_*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons148, cons1490) def replacement5668(m, f, b, d, c, n, a, x, e): rubi.append(5668) return Int(ExpandIntegrand((c + d*x)**m, (a + b*cosh(e + f*x))**n, x), x) rule5668 = ReplacementRule(pattern5668, replacement5668) pattern5669 = Pattern(Integral((a_ + WC('b', S(1))*sinh(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1))*(x_*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons1439, cons85) def replacement5669(m, f, b, d, c, n, a, x, e): rubi.append(5669) return Dist((S(2)*a)**n, Int((c + d*x)**m*cosh(-Pi*a/(S(4)*b) + e/S(2) + f*x/S(2))**(S(2)*n), x), x) rule5669 = ReplacementRule(pattern5669, replacement5669) pattern5670 = Pattern(Integral((a_ + WC('b', S(1))*sinh(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(x_*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons1439, cons808, cons1491) def replacement5670(m, f, b, d, c, a, n, x, e): rubi.append(5670) return Dist((S(2)*a)**IntPart(n)*(a + b*sinh(e + f*x))**FracPart(n)*cosh(-Pi*a/(S(4)*b) + e/S(2) + f*x/S(2))**(-S(2)*FracPart(n)), Int((c + d*x)**m*cosh(-Pi*a/(S(4)*b) + e/S(2) + f*x/S(2))**(S(2)*n), x), x) rule5670 = ReplacementRule(pattern5670, replacement5670) pattern5671 = Pattern(Integral((a_ + WC('b', S(1))*cosh(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1))*(x_*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons1492, cons85) def replacement5671(m, f, b, d, c, n, a, x, e): rubi.append(5671) return Dist((S(2)*a)**n, Int((c + d*x)**m*cosh(e/S(2) + f*x/S(2))**(S(2)*n), x), x) rule5671 = ReplacementRule(pattern5671, replacement5671) pattern5672 = Pattern(Integral((a_ + WC('b', S(1))*cosh(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1))*(x_*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons1454, cons85) def replacement5672(m, f, b, d, c, n, a, x, e): rubi.append(5672) return Dist((-S(2)*a)**n, Int((c + d*x)**m*sinh(e/S(2) + f*x/S(2))**(S(2)*n), x), x) rule5672 = ReplacementRule(pattern5672, replacement5672) pattern5673 = Pattern(Integral((a_ + WC('b', S(1))*cosh(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(x_*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons1492, cons808, cons1491) def replacement5673(m, f, b, d, c, a, n, x, e): rubi.append(5673) return Dist((S(2)*a)**IntPart(n)*(a + b*cosh(e + f*x))**FracPart(n)*cosh(e/S(2) + f*x/S(2))**(-S(2)*FracPart(n)), Int((c + d*x)**m*cosh(e/S(2) + f*x/S(2))**(S(2)*n), x), x) rule5673 = ReplacementRule(pattern5673, replacement5673) pattern5674 = Pattern(Integral((a_ + WC('b', S(1))*cosh(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(x_*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons1454, cons808, cons1491) def replacement5674(m, f, b, d, c, a, n, x, e): rubi.append(5674) return Dist((-S(2)*a)**IntPart(n)*(a + b*cosh(e + f*x))**FracPart(n)*sinh(e/S(2) + f*x/S(2))**(-S(2)*FracPart(n)), Int((c + d*x)**m*sinh(e/S(2) + f*x/S(2))**(S(2)*n), x), x) rule5674 = ReplacementRule(pattern5674, replacement5674) pattern5675 = Pattern(Integral((x_*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1))/(a_ + WC('b', S(1))*sinh(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons1440, cons62) def replacement5675(m, f, b, d, c, a, x, e): rubi.append(5675) return Dist(S(-2), Int((c + d*x)**m*exp(e + f*x)/(-S(2)*a*exp(e + f*x) - b*exp(S(2)*e + S(2)*f*x) + b), x), x) rule5675 = ReplacementRule(pattern5675, replacement5675) pattern5676 = Pattern(Integral((x_*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1))/(a_ + WC('b', S(1))*cosh(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons1267, cons62) def replacement5676(m, f, b, d, c, a, x, e): rubi.append(5676) return Dist(S(2), Int((c + d*x)**m*exp(e + f*x)/(S(2)*a*exp(e + f*x) + b*exp(S(2)*e + S(2)*f*x) + b), x), x) rule5676 = ReplacementRule(pattern5676, replacement5676) pattern5677 = Pattern(Integral((x_*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1))/(a_ + WC('b', S(1))*sinh(x_*WC('f', S(1)) + WC('e', S(0))))**S(2), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons1440, cons62) def replacement5677(m, f, b, d, c, a, x, e): rubi.append(5677) return Dist(a/(a**S(2) + b**S(2)), Int((c + d*x)**m/(a + b*sinh(e + f*x)), x), x) + Dist(b*d*m/(f*(a**S(2) + b**S(2))), Int((c + d*x)**(m + S(-1))*cosh(e + f*x)/(a + b*sinh(e + f*x)), x), x) - Simp(b*(c + d*x)**m*cosh(e + f*x)/(f*(a + b*sinh(e + f*x))*(a**S(2) + b**S(2))), x) rule5677 = ReplacementRule(pattern5677, replacement5677) pattern5678 = Pattern(Integral((x_*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1))/(a_ + WC('b', S(1))*cosh(x_*WC('f', S(1)) + WC('e', S(0))))**S(2), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons1267, cons62) def replacement5678(m, f, b, d, c, a, x, e): rubi.append(5678) return Dist(a/(a**S(2) - b**S(2)), Int((c + d*x)**m/(a + b*cosh(e + f*x)), x), x) + Dist(b*d*m/(f*(a**S(2) - b**S(2))), Int((c + d*x)**(m + S(-1))*sinh(e + f*x)/(a + b*cosh(e + f*x)), x), x) - Simp(b*(c + d*x)**m*sinh(e + f*x)/(f*(a + b*cosh(e + f*x))*(a**S(2) - b**S(2))), x) rule5678 = ReplacementRule(pattern5678, replacement5678) pattern5679 = Pattern(Integral((a_ + WC('b', S(1))*sinh(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(x_*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons1440, cons1493, cons62) def replacement5679(m, f, b, d, c, a, n, x, e): rubi.append(5679) return Dist(a/(a**S(2) + b**S(2)), Int((a + b*sinh(e + f*x))**(n + S(1))*(c + d*x)**m, x), x) - Dist(b*(n + S(2))/((a**S(2) + b**S(2))*(n + S(1))), Int((a + b*sinh(e + f*x))**(n + S(1))*(c + d*x)**m*sinh(e + f*x), x), x) - Dist(b*d*m/(f*(a**S(2) + b**S(2))*(n + S(1))), Int((a + b*sinh(e + f*x))**(n + S(1))*(c + d*x)**(m + S(-1))*cosh(e + f*x), x), x) + Simp(b*(a + b*sinh(e + f*x))**(n + S(1))*(c + d*x)**m*cosh(e + f*x)/(f*(a**S(2) + b**S(2))*(n + S(1))), x) rule5679 = ReplacementRule(pattern5679, replacement5679) pattern5680 = Pattern(Integral((a_ + WC('b', S(1))*cosh(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(x_*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons1267, cons1493, cons62) def replacement5680(m, f, b, d, c, a, n, x, e): rubi.append(5680) return Dist(a/(a**S(2) - b**S(2)), Int((a + b*cosh(e + f*x))**(n + S(1))*(c + d*x)**m, x), x) - Dist(b*(n + S(2))/((a**S(2) - b**S(2))*(n + S(1))), Int((a + b*cosh(e + f*x))**(n + S(1))*(c + d*x)**m*cosh(e + f*x), x), x) - Dist(b*d*m/(f*(a**S(2) - b**S(2))*(n + S(1))), Int((a + b*cosh(e + f*x))**(n + S(1))*(c + d*x)**(m + S(-1))*sinh(e + f*x), x), x) + Simp(b*(a + b*cosh(e + f*x))**(n + S(1))*(c + d*x)**m*sinh(e + f*x)/(f*(a**S(2) - b**S(2))*(n + S(1))), x) rule5680 = ReplacementRule(pattern5680, replacement5680) pattern5681 = Pattern(Integral(u_**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*sinh(v_))**WC('n', S(1)), x_), cons2, cons3, cons21, cons4, cons810, cons811) def replacement5681(v, u, m, b, a, n, x): rubi.append(5681) return Int((a + b*sinh(ExpandToSum(v, x)))**n*ExpandToSum(u, x)**m, x) rule5681 = ReplacementRule(pattern5681, replacement5681) pattern5682 = Pattern(Integral(u_**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*cosh(v_))**WC('n', S(1)), x_), cons2, cons3, cons21, cons4, cons810, cons811) def replacement5682(v, u, m, b, a, n, x): rubi.append(5682) return Int((a + b*cosh(ExpandToSum(v, x)))**n*ExpandToSum(u, x)**m, x) rule5682 = ReplacementRule(pattern5682, replacement5682) pattern5683 = Pattern(Integral((x_*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*sinh(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons4, cons1360) def replacement5683(m, f, b, d, c, a, n, x, e): rubi.append(5683) return Int((a + b*sinh(e + f*x))**n*(c + d*x)**m, x) rule5683 = ReplacementRule(pattern5683, replacement5683) pattern5684 = Pattern(Integral((x_*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*cosh(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons4, cons1360) def replacement5684(m, f, b, d, a, n, c, x, e): rubi.append(5684) return Int((a + b*cosh(e + f*x))**n*(c + d*x)**m, x) rule5684 = ReplacementRule(pattern5684, replacement5684) pattern5685 = Pattern(Integral((a_ + x_**n_*WC('b', S(1)))**WC('p', S(1))*sinh(x_*WC('d', S(1)) + WC('c', S(0))), x_), cons2, cons3, cons7, cons27, cons4, cons128) def replacement5685(p, b, d, c, a, n, x): rubi.append(5685) return Int(ExpandIntegrand(sinh(c + d*x), (a + b*x**n)**p, x), x) rule5685 = ReplacementRule(pattern5685, replacement5685) pattern5686 = Pattern(Integral((a_ + x_**n_*WC('b', S(1)))**WC('p', S(1))*cosh(x_*WC('d', S(1)) + WC('c', S(0))), x_), cons2, cons3, cons7, cons27, cons4, cons128) def replacement5686(p, b, d, c, a, n, x): rubi.append(5686) return Int(ExpandIntegrand(cosh(c + d*x), (a + b*x**n)**p, x), x) rule5686 = ReplacementRule(pattern5686, replacement5686) pattern5687 = Pattern(Integral((a_ + x_**n_*WC('b', S(1)))**p_*sinh(x_*WC('d', S(1)) + WC('c', S(0))), x_), cons2, cons3, cons7, cons27, cons38, cons148, cons137, cons744) def replacement5687(p, b, d, c, a, n, x): rubi.append(5687) return -Dist(d/(b*n*(p + S(1))), Int(x**(-n + S(1))*(a + b*x**n)**(p + S(1))*cosh(c + d*x), x), x) - Dist((-n + S(1))/(b*n*(p + S(1))), Int(x**(-n)*(a + b*x**n)**(p + S(1))*sinh(c + d*x), x), x) + Simp(x**(-n + S(1))*(a + b*x**n)**(p + S(1))*sinh(c + d*x)/(b*n*(p + S(1))), x) rule5687 = ReplacementRule(pattern5687, replacement5687) pattern5688 = Pattern(Integral((a_ + x_**n_*WC('b', S(1)))**p_*cosh(x_*WC('d', S(1)) + WC('c', S(0))), x_), cons2, cons3, cons7, cons27, cons38, cons148, cons137, cons744) def replacement5688(p, b, d, c, a, n, x): rubi.append(5688) return -Dist(d/(b*n*(p + S(1))), Int(x**(-n + S(1))*(a + b*x**n)**(p + S(1))*sinh(c + d*x), x), x) - Dist((-n + S(1))/(b*n*(p + S(1))), Int(x**(-n)*(a + b*x**n)**(p + S(1))*cosh(c + d*x), x), x) + Simp(x**(-n + S(1))*(a + b*x**n)**(p + S(1))*cosh(c + d*x)/(b*n*(p + S(1))), x) rule5688 = ReplacementRule(pattern5688, replacement5688) pattern5689 = Pattern(Integral((a_ + x_**n_*WC('b', S(1)))**p_*sinh(x_*WC('d', S(1)) + WC('c', S(0))), x_), cons2, cons3, cons7, cons27, cons63, cons148, cons1494) def replacement5689(p, b, d, c, a, n, x): rubi.append(5689) return Int(ExpandIntegrand(sinh(c + d*x), (a + b*x**n)**p, x), x) rule5689 = ReplacementRule(pattern5689, replacement5689) pattern5690 = Pattern(Integral((a_ + x_**n_*WC('b', S(1)))**p_*cosh(x_*WC('d', S(1)) + WC('c', S(0))), x_), cons2, cons3, cons7, cons27, cons63, cons148, cons1494) def replacement5690(p, b, d, c, a, n, x): rubi.append(5690) return Int(ExpandIntegrand(cosh(c + d*x), (a + b*x**n)**p, x), x) rule5690 = ReplacementRule(pattern5690, replacement5690) pattern5691 = Pattern(Integral((a_ + x_**n_*WC('b', S(1)))**p_*sinh(x_*WC('d', S(1)) + WC('c', S(0))), x_), cons2, cons3, cons7, cons27, cons63, cons196) def replacement5691(p, b, d, c, a, n, x): rubi.append(5691) return Int(x**(n*p)*(a*x**(-n) + b)**p*sinh(c + d*x), x) rule5691 = ReplacementRule(pattern5691, replacement5691) pattern5692 = Pattern(Integral((a_ + x_**n_*WC('b', S(1)))**p_*cosh(x_*WC('d', S(1)) + WC('c', S(0))), x_), cons2, cons3, cons7, cons27, cons63, cons196) def replacement5692(p, b, d, c, a, n, x): rubi.append(5692) return Int(x**(n*p)*(a*x**(-n) + b)**p*cosh(c + d*x), x) rule5692 = ReplacementRule(pattern5692, replacement5692) pattern5693 = Pattern(Integral((a_ + x_**n_*WC('b', S(1)))**p_*sinh(x_*WC('d', S(1)) + WC('c', S(0))), x_), cons2, cons3, cons7, cons27, cons4, cons5, cons1495) def replacement5693(p, b, d, c, a, n, x): rubi.append(5693) return Int((a + b*x**n)**p*sinh(c + d*x), x) rule5693 = ReplacementRule(pattern5693, replacement5693) pattern5694 = Pattern(Integral((a_ + x_**n_*WC('b', S(1)))**p_*cosh(x_*WC('d', S(1)) + WC('c', S(0))), x_), cons2, cons3, cons7, cons27, cons4, cons5, cons1495) def replacement5694(p, b, d, c, a, n, x): rubi.append(5694) return Int((a + b*x**n)**p*cosh(c + d*x), x) rule5694 = ReplacementRule(pattern5694, replacement5694) pattern5695 = Pattern(Integral((x_*WC('e', S(1)))**WC('m', S(1))*(a_ + x_**n_*WC('b', S(1)))**WC('p', S(1))*sinh(x_*WC('d', S(1)) + WC('c', S(0))), x_), cons2, cons3, cons7, cons27, cons48, cons21, cons4, cons128) def replacement5695(p, m, b, d, c, a, n, x, e): rubi.append(5695) return Int(ExpandIntegrand(sinh(c + d*x), (e*x)**m*(a + b*x**n)**p, x), x) rule5695 = ReplacementRule(pattern5695, replacement5695) pattern5696 = Pattern(Integral((x_*WC('e', S(1)))**WC('m', S(1))*(a_ + x_**n_*WC('b', S(1)))**WC('p', S(1))*cosh(x_*WC('d', S(1)) + WC('c', S(0))), x_), cons2, cons3, cons7, cons27, cons48, cons21, cons4, cons128) def replacement5696(p, m, b, d, c, a, n, x, e): rubi.append(5696) return Int(ExpandIntegrand(cosh(c + d*x), (e*x)**m*(a + b*x**n)**p, x), x) rule5696 = ReplacementRule(pattern5696, replacement5696) pattern5697 = Pattern(Integral((x_*WC('e', S(1)))**WC('m', S(1))*(a_ + x_**n_*WC('b', S(1)))**p_*sinh(x_*WC('d', S(1)) + WC('c', S(0))), x_), cons2, cons3, cons7, cons27, cons48, cons21, cons4, cons38, cons53, cons13, cons137, cons596) def replacement5697(p, m, b, d, c, a, n, x, e): rubi.append(5697) return -Dist(d*e**m/(b*n*(p + S(1))), Int((a + b*x**n)**(p + S(1))*cosh(c + d*x), x), x) + Simp(e**m*(a + b*x**n)**(p + S(1))*sinh(c + d*x)/(b*n*(p + S(1))), x) rule5697 = ReplacementRule(pattern5697, replacement5697) pattern5698 = Pattern(Integral((x_*WC('e', S(1)))**WC('m', S(1))*(a_ + x_**n_*WC('b', S(1)))**p_*cosh(x_*WC('d', S(1)) + WC('c', S(0))), x_), cons2, cons3, cons7, cons27, cons48, cons21, cons4, cons38, cons53, cons13, cons137, cons596) def replacement5698(p, m, b, d, c, a, n, x, e): rubi.append(5698) return -Dist(d*e**m/(b*n*(p + S(1))), Int((a + b*x**n)**(p + S(1))*sinh(c + d*x), x), x) + Simp(e**m*(a + b*x**n)**(p + S(1))*cosh(c + d*x)/(b*n*(p + S(1))), x) rule5698 = ReplacementRule(pattern5698, replacement5698) pattern5699 = Pattern(Integral(x_**WC('m', S(1))*(a_ + x_**n_*WC('b', S(1)))**p_*sinh(x_*WC('d', S(1)) + WC('c', S(0))), x_), cons2, cons3, cons7, cons27, cons38, cons148, cons31, cons137, cons1496) def replacement5699(p, m, b, d, c, a, n, x): rubi.append(5699) return -Dist(d/(b*n*(p + S(1))), Int(x**(m - n + S(1))*(a + b*x**n)**(p + S(1))*cosh(c + d*x), x), x) - Dist((m - n + S(1))/(b*n*(p + S(1))), Int(x**(m - n)*(a + b*x**n)**(p + S(1))*sinh(c + d*x), x), x) + Simp(x**(m - n + S(1))*(a + b*x**n)**(p + S(1))*sinh(c + d*x)/(b*n*(p + S(1))), x) rule5699 = ReplacementRule(pattern5699, replacement5699) pattern5700 = Pattern(Integral(x_**WC('m', S(1))*(a_ + x_**n_*WC('b', S(1)))**p_*cosh(x_*WC('d', S(1)) + WC('c', S(0))), x_), cons2, cons3, cons7, cons27, cons38, cons148, cons31, cons137, cons1496) def replacement5700(p, m, b, d, c, a, n, x): rubi.append(5700) return -Dist(d/(b*n*(p + S(1))), Int(x**(m - n + S(1))*(a + b*x**n)**(p + S(1))*sinh(c + d*x), x), x) - Dist((m - n + S(1))/(b*n*(p + S(1))), Int(x**(m - n)*(a + b*x**n)**(p + S(1))*cosh(c + d*x), x), x) + Simp(x**(m - n + S(1))*(a + b*x**n)**(p + S(1))*cosh(c + d*x)/(b*n*(p + S(1))), x) rule5700 = ReplacementRule(pattern5700, replacement5700) pattern5701 = Pattern(Integral(x_**WC('m', S(1))*(a_ + x_**n_*WC('b', S(1)))**p_*sinh(x_*WC('d', S(1)) + WC('c', S(0))), x_), cons2, cons3, cons7, cons27, cons63, cons17, cons148, cons1494) def replacement5701(p, m, b, d, c, a, n, x): rubi.append(5701) return Int(ExpandIntegrand(sinh(c + d*x), x**m*(a + b*x**n)**p, x), x) rule5701 = ReplacementRule(pattern5701, replacement5701) pattern5702 = Pattern(Integral(x_**WC('m', S(1))*(a_ + x_**n_*WC('b', S(1)))**p_*cosh(x_*WC('d', S(1)) + WC('c', S(0))), x_), cons2, cons3, cons7, cons27, cons63, cons17, cons148, cons1494) def replacement5702(p, m, b, d, c, a, n, x): rubi.append(5702) return Int(ExpandIntegrand(cosh(c + d*x), x**m*(a + b*x**n)**p, x), x) rule5702 = ReplacementRule(pattern5702, replacement5702) pattern5703 = Pattern(Integral(x_**WC('m', S(1))*(a_ + x_**n_*WC('b', S(1)))**p_*sinh(x_*WC('d', S(1)) + WC('c', S(0))), x_), cons2, cons3, cons7, cons27, cons21, cons63, cons196) def replacement5703(p, m, b, d, c, a, n, x): rubi.append(5703) return Int(x**(m + n*p)*(a*x**(-n) + b)**p*sinh(c + d*x), x) rule5703 = ReplacementRule(pattern5703, replacement5703) pattern5704 = Pattern(Integral(x_**WC('m', S(1))*(a_ + x_**n_*WC('b', S(1)))**p_*cosh(x_*WC('d', S(1)) + WC('c', S(0))), x_), cons2, cons3, cons7, cons27, cons21, cons63, cons196) def replacement5704(p, m, b, d, c, a, n, x): rubi.append(5704) return Int(x**(m + n*p)*(a*x**(-n) + b)**p*cosh(c + d*x), x) rule5704 = ReplacementRule(pattern5704, replacement5704) pattern5705 = Pattern(Integral((x_*WC('e', S(1)))**WC('m', S(1))*(a_ + x_**n_*WC('b', S(1)))**WC('p', S(1))*sinh(x_*WC('d', S(1)) + WC('c', S(0))), x_), cons2, cons3, cons7, cons27, cons48, cons21, cons4, cons5, cons1497) def replacement5705(p, m, b, d, c, a, n, x, e): rubi.append(5705) return Int((e*x)**m*(a + b*x**n)**p*sinh(c + d*x), x) rule5705 = ReplacementRule(pattern5705, replacement5705) pattern5706 = Pattern(Integral((x_*WC('e', S(1)))**WC('m', S(1))*(a_ + x_**n_*WC('b', S(1)))**WC('p', S(1))*cosh(x_*WC('d', S(1)) + WC('c', S(0))), x_), cons2, cons3, cons7, cons27, cons48, cons21, cons4, cons5, cons1497) def replacement5706(p, m, b, d, c, a, n, x, e): rubi.append(5706) return Int((e*x)**m*(a + b*x**n)**p*cosh(c + d*x), x) rule5706 = ReplacementRule(pattern5706, replacement5706) pattern5707 = Pattern(Integral(sinh(x_**n_*WC('d', S(1)) + WC('c', S(0))), x_), cons7, cons27, cons85, cons165) def replacement5707(d, c, n, x): rubi.append(5707) return -Dist(S(1)/2, Int(exp(-c - d*x**n), x), x) + Dist(S(1)/2, Int(exp(c + d*x**n), x), x) rule5707 = ReplacementRule(pattern5707, replacement5707) pattern5708 = Pattern(Integral(cosh(x_**n_*WC('d', S(1)) + WC('c', S(0))), x_), cons7, cons27, cons85, cons165) def replacement5708(d, c, n, x): rubi.append(5708) return Dist(S(1)/2, Int(exp(-c - d*x**n), x), x) + Dist(S(1)/2, Int(exp(c + d*x**n), x), x) rule5708 = ReplacementRule(pattern5708, replacement5708) pattern5709 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*sinh(x_**n_*WC('d', S(1)) + WC('c', S(0))))**p_, x_), cons2, cons3, cons7, cons27, cons376, cons165, cons146) def replacement5709(p, b, d, c, a, n, x): rubi.append(5709) return Int(ExpandTrigReduce((a + b*sinh(c + d*x**n))**p, x), x) rule5709 = ReplacementRule(pattern5709, replacement5709) pattern5710 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*cosh(x_**n_*WC('d', S(1)) + WC('c', S(0))))**p_, x_), cons2, cons3, cons7, cons27, cons376, cons165, cons146) def replacement5710(p, b, d, a, c, n, x): rubi.append(5710) return Int(ExpandTrigReduce((a + b*cosh(c + d*x**n))**p, x), x) rule5710 = ReplacementRule(pattern5710, replacement5710) pattern5711 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*sinh(x_**n_*WC('d', S(1)) + WC('c', S(0))))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons38, cons196) def replacement5711(p, b, d, c, a, n, x): rubi.append(5711) return -Subst(Int((a + b*sinh(c + d*x**(-n)))**p/x**S(2), x), x, S(1)/x) rule5711 = ReplacementRule(pattern5711, replacement5711) pattern5712 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*cosh(x_**n_*WC('d', S(1)) + WC('c', S(0))))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons38, cons196) def replacement5712(p, b, d, a, c, n, x): rubi.append(5712) return -Subst(Int((a + b*cosh(c + d*x**(-n)))**p/x**S(2), x), x, S(1)/x) rule5712 = ReplacementRule(pattern5712, replacement5712) def With5713(p, b, d, c, a, n, x): k = Denominator(n) rubi.append(5713) return Dist(k, Subst(Int(x**(k + S(-1))*(a + b*sinh(c + d*x**(k*n)))**p, x), x, x**(S(1)/k)), x) pattern5713 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*sinh(x_**n_*WC('d', S(1)) + WC('c', S(0))))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons38, cons489) rule5713 = ReplacementRule(pattern5713, With5713) def With5714(p, b, d, a, c, n, x): k = Denominator(n) rubi.append(5714) return Dist(k, Subst(Int(x**(k + S(-1))*(a + b*cosh(c + d*x**(k*n)))**p, x), x, x**(S(1)/k)), x) pattern5714 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*cosh(x_**n_*WC('d', S(1)) + WC('c', S(0))))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons38, cons489) rule5714 = ReplacementRule(pattern5714, With5714) pattern5715 = Pattern(Integral(sinh(x_**n_*WC('d', S(1)) + WC('c', S(0))), x_), cons7, cons27, cons4, cons1498) def replacement5715(d, c, n, x): rubi.append(5715) return -Dist(S(1)/2, Int(exp(-c - d*x**n), x), x) + Dist(S(1)/2, Int(exp(c + d*x**n), x), x) rule5715 = ReplacementRule(pattern5715, replacement5715) pattern5716 = Pattern(Integral(cosh(x_**n_*WC('d', S(1)) + WC('c', S(0))), x_), cons7, cons27, cons4, cons1498) def replacement5716(d, c, n, x): rubi.append(5716) return Dist(S(1)/2, Int(exp(-c - d*x**n), x), x) + Dist(S(1)/2, Int(exp(c + d*x**n), x), x) rule5716 = ReplacementRule(pattern5716, replacement5716) pattern5717 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*sinh(x_**n_*WC('d', S(1)) + WC('c', S(0))))**p_, x_), cons2, cons3, cons7, cons27, cons4, cons128) def replacement5717(p, b, d, c, a, n, x): rubi.append(5717) return Int(ExpandTrigReduce((a + b*sinh(c + d*x**n))**p, x), x) rule5717 = ReplacementRule(pattern5717, replacement5717) pattern5718 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*cosh(x_**n_*WC('d', S(1)) + WC('c', S(0))))**p_, x_), cons2, cons3, cons7, cons27, cons4, cons128) def replacement5718(p, b, d, a, c, n, x): rubi.append(5718) return Int(ExpandTrigReduce((a + b*cosh(c + d*x**n))**p, x), x) rule5718 = ReplacementRule(pattern5718, replacement5718) pattern5719 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*sinh(u_**n_*WC('d', S(1)) + WC('c', S(0))))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons4, cons38, cons68, cons69) def replacement5719(p, u, b, d, c, a, n, x): rubi.append(5719) return Dist(S(1)/Coefficient(u, x, S(1)), Subst(Int((a + b*sinh(c + d*x**n))**p, x), x, u), x) rule5719 = ReplacementRule(pattern5719, replacement5719) pattern5720 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*cosh(u_**n_*WC('d', S(1)) + WC('c', S(0))))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons4, cons38, cons68, cons69) def replacement5720(p, u, b, d, a, c, n, x): rubi.append(5720) return Dist(S(1)/Coefficient(u, x, S(1)), Subst(Int((a + b*cosh(c + d*x**n))**p, x), x, u), x) rule5720 = ReplacementRule(pattern5720, replacement5720) pattern5721 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*sinh(u_**n_*WC('d', S(1)) + WC('c', S(0))))**p_, x_), cons2, cons3, cons7, cons27, cons4, cons5, cons68) def replacement5721(p, u, b, d, c, a, n, x): rubi.append(5721) return Int((a + b*sinh(c + d*u**n))**p, x) rule5721 = ReplacementRule(pattern5721, replacement5721) pattern5722 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*cosh(u_**n_*WC('d', S(1)) + WC('c', S(0))))**p_, x_), cons2, cons3, cons7, cons27, cons4, cons5, cons68) def replacement5722(p, u, b, d, a, c, n, x): rubi.append(5722) return Int((a + b*cosh(c + d*u**n))**p, x) rule5722 = ReplacementRule(pattern5722, replacement5722) pattern5723 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*sinh(u_))**WC('p', S(1)), x_), cons2, cons3, cons5, cons823, cons824) def replacement5723(p, u, b, a, x): rubi.append(5723) return Int((a + b*sinh(ExpandToSum(u, x)))**p, x) rule5723 = ReplacementRule(pattern5723, replacement5723) pattern5724 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*cosh(u_))**WC('p', S(1)), x_), cons2, cons3, cons5, cons823, cons824) def replacement5724(p, u, b, a, x): rubi.append(5724) return Int((a + b*cosh(ExpandToSum(u, x)))**p, x) rule5724 = ReplacementRule(pattern5724, replacement5724) pattern5725 = Pattern(Integral(sinh(x_**n_*WC('d', S(1)))/x_, x_), cons27, cons4, cons1499) def replacement5725(d, x, n): rubi.append(5725) return Simp(SinhIntegral(d*x**n)/n, x) rule5725 = ReplacementRule(pattern5725, replacement5725) pattern5726 = Pattern(Integral(cosh(x_**n_*WC('d', S(1)))/x_, x_), cons27, cons4, cons1499) def replacement5726(d, x, n): rubi.append(5726) return Simp(CoshIntegral(d*x**n)/n, x) rule5726 = ReplacementRule(pattern5726, replacement5726) pattern5727 = Pattern(Integral(sinh(c_ + x_**n_*WC('d', S(1)))/x_, x_), cons7, cons27, cons4, cons1498) def replacement5727(d, x, n, c): rubi.append(5727) return Dist(sinh(c), Int(cosh(d*x**n)/x, x), x) + Dist(cosh(c), Int(sinh(d*x**n)/x, x), x) rule5727 = ReplacementRule(pattern5727, replacement5727) pattern5728 = Pattern(Integral(cosh(c_ + x_**n_*WC('d', S(1)))/x_, x_), cons7, cons27, cons4, cons1498) def replacement5728(d, c, n, x): rubi.append(5728) return Dist(sinh(c), Int(sinh(d*x**n)/x, x), x) + Dist(cosh(c), Int(cosh(d*x**n)/x, x), x) rule5728 = ReplacementRule(pattern5728, replacement5728) def With5729(p, m, b, d, c, a, n, x): if isinstance(x, (int, Integer, float, Float)): return False mn = (m + S(1))/n if And(IntegerQ(mn), Or(Equal(p, S(1)), Greater(mn, S(0)))): return True return False pattern5729 = Pattern(Integral(x_**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*sinh(x_**n_*WC('d', S(1)) + WC('c', S(0))))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons21, cons4, cons38, CustomConstraint(With5729)) def replacement5729(p, m, b, d, c, a, n, x): mn = (m + S(1))/n rubi.append(5729) return Dist(S(1)/n, Subst(Int(x**(mn + S(-1))*(a + b*sinh(c + d*x))**p, x), x, x**n), x) rule5729 = ReplacementRule(pattern5729, replacement5729) def With5730(p, m, b, d, a, c, n, x): if isinstance(x, (int, Integer, float, Float)): return False mn = (m + S(1))/n if And(IntegerQ(mn), Or(Equal(p, S(1)), Greater(mn, S(0)))): return True return False pattern5730 = Pattern(Integral(x_**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*cosh(x_**n_*WC('d', S(1)) + WC('c', S(0))))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons21, cons4, cons38, CustomConstraint(With5730)) def replacement5730(p, m, b, d, a, c, n, x): mn = (m + S(1))/n rubi.append(5730) return Dist(S(1)/n, Subst(Int(x**(mn + S(-1))*(a + b*cosh(c + d*x))**p, x), x, x**n), x) rule5730 = ReplacementRule(pattern5730, replacement5730) def With5731(p, m, b, d, c, a, n, x, e): if isinstance(x, (int, Integer, float, Float)): return False mn = (m + S(1))/n if And(IntegerQ(mn), Or(Equal(p, S(1)), Greater(mn, S(0)))): return True return False pattern5731 = Pattern(Integral((e_*x_)**m_*(WC('a', S(0)) + WC('b', S(1))*sinh(x_**n_*WC('d', S(1)) + WC('c', S(0))))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons21, cons4, cons38, CustomConstraint(With5731)) def replacement5731(p, m, b, d, c, a, n, x, e): mn = (m + S(1))/n rubi.append(5731) return Dist(e**IntPart(m)*x**(-FracPart(m))*(e*x)**FracPart(m), Int(x**m*(a + b*sinh(c + d*x**n))**p, x), x) rule5731 = ReplacementRule(pattern5731, replacement5731) def With5732(p, m, b, d, a, c, n, x, e): if isinstance(x, (int, Integer, float, Float)): return False mn = (m + S(1))/n if And(IntegerQ(mn), Or(Equal(p, S(1)), Greater(mn, S(0)))): return True return False pattern5732 = Pattern(Integral((e_*x_)**m_*(WC('a', S(0)) + WC('b', S(1))*cosh(x_**n_*WC('d', S(1)) + WC('c', S(0))))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons21, cons4, cons38, CustomConstraint(With5732)) def replacement5732(p, m, b, d, a, c, n, x, e): mn = (m + S(1))/n rubi.append(5732) return Dist(e**IntPart(m)*x**(-FracPart(m))*(e*x)**FracPart(m), Int(x**m*(a + b*cosh(c + d*x**n))**p, x), x) rule5732 = ReplacementRule(pattern5732, replacement5732) pattern5733 = Pattern(Integral((x_*WC('e', S(1)))**WC('m', S(1))*sinh(x_**n_*WC('d', S(1)) + WC('c', S(0))), x_), cons7, cons27, cons48, cons148, cons31, cons1501) def replacement5733(m, d, c, n, x, e): rubi.append(5733) return -Dist(e**n*(m - n + S(1))/(d*n), Int((e*x)**(m - n)*cosh(c + d*x**n), x), x) + Simp(e**(n + S(-1))*(e*x)**(m - n + S(1))*cosh(c + d*x**n)/(d*n), x) rule5733 = ReplacementRule(pattern5733, replacement5733) pattern5734 = Pattern(Integral((x_*WC('e', S(1)))**WC('m', S(1))*cosh(x_**n_*WC('d', S(1)) + WC('c', S(0))), x_), cons7, cons27, cons48, cons148, cons31, cons1501) def replacement5734(m, d, c, n, x, e): rubi.append(5734) return -Dist(e**n*(m - n + S(1))/(d*n), Int((e*x)**(m - n)*sinh(c + d*x**n), x), x) + Simp(e**(n + S(-1))*(e*x)**(m - n + S(1))*sinh(c + d*x**n)/(d*n), x) rule5734 = ReplacementRule(pattern5734, replacement5734) pattern5735 = Pattern(Integral((x_*WC('e', S(1)))**m_*sinh(x_**n_*WC('d', S(1)) + WC('c', S(0))), x_), cons7, cons27, cons48, cons148, cons31, cons94) def replacement5735(m, d, c, n, x, e): rubi.append(5735) return -Dist(d*e**(-n)*n/(m + S(1)), Int((e*x)**(m + n)*cosh(c + d*x**n), x), x) + Simp((e*x)**(m + S(1))*sinh(c + d*x**n)/(e*(m + S(1))), x) rule5735 = ReplacementRule(pattern5735, replacement5735) pattern5736 = Pattern(Integral((x_*WC('e', S(1)))**m_*cosh(x_**n_*WC('d', S(1)) + WC('c', S(0))), x_), cons7, cons27, cons48, cons148, cons31, cons94) def replacement5736(m, d, c, n, x, e): rubi.append(5736) return -Dist(d*e**(-n)*n/(m + S(1)), Int((e*x)**(m + n)*sinh(c + d*x**n), x), x) + Simp((e*x)**(m + S(1))*cosh(c + d*x**n)/(e*(m + S(1))), x) rule5736 = ReplacementRule(pattern5736, replacement5736) pattern5737 = Pattern(Integral((x_*WC('e', S(1)))**WC('m', S(1))*sinh(x_**n_*WC('d', S(1)) + WC('c', S(0))), x_), cons7, cons27, cons48, cons21, cons148) def replacement5737(m, d, c, n, x, e): rubi.append(5737) return -Dist(S(1)/2, Int((e*x)**m*exp(-c - d*x**n), x), x) + Dist(S(1)/2, Int((e*x)**m*exp(c + d*x**n), x), x) rule5737 = ReplacementRule(pattern5737, replacement5737) pattern5738 = Pattern(Integral((x_*WC('e', S(1)))**WC('m', S(1))*cosh(x_**n_*WC('d', S(1)) + WC('c', S(0))), x_), cons7, cons27, cons48, cons21, cons148) def replacement5738(m, d, c, n, x, e): rubi.append(5738) return Dist(S(1)/2, Int((e*x)**m*exp(-c - d*x**n), x), x) + Dist(S(1)/2, Int((e*x)**m*exp(c + d*x**n), x), x) rule5738 = ReplacementRule(pattern5738, replacement5738) pattern5739 = Pattern(Integral(x_**WC('m', S(1))*sinh(x_**n_*WC('b', S(1)) + WC('a', S(0)))**p_, x_), cons2, cons3, cons376, cons1255, cons146, cons1502) def replacement5739(p, m, b, a, n, x): rubi.append(5739) return Dist(b*n*p/(n + S(-1)), Int(sinh(a + b*x**n)**(p + S(-1))*cosh(a + b*x**n), x), x) - Simp(x**(-n + S(1))*sinh(a + b*x**n)**p/(n + S(-1)), x) rule5739 = ReplacementRule(pattern5739, replacement5739) pattern5740 = Pattern(Integral(x_**WC('m', S(1))*cosh(x_**n_*WC('b', S(1)) + WC('a', S(0)))**p_, x_), cons2, cons3, cons376, cons1255, cons146, cons1502) def replacement5740(p, m, b, a, n, x): rubi.append(5740) return Dist(b*n*p/(n + S(-1)), Int(sinh(a + b*x**n)*cosh(a + b*x**n)**(p + S(-1)), x), x) - Simp(x**(-n + S(1))*cosh(a + b*x**n)**p/(n + S(-1)), x) rule5740 = ReplacementRule(pattern5740, replacement5740) pattern5741 = Pattern(Integral(x_**WC('m', S(1))*sinh(x_**n_*WC('b', S(1)) + WC('a', S(0)))**p_, x_), cons2, cons3, cons21, cons4, cons56, cons13, cons146) def replacement5741(p, m, b, a, n, x): rubi.append(5741) return -Dist((p + S(-1))/p, Int(x**m*sinh(a + b*x**n)**(p + S(-2)), x), x) - Simp(sinh(a + b*x**n)**p/(b**S(2)*n*p**S(2)), x) + Simp(x**n*sinh(a + b*x**n)**(p + S(-1))*cosh(a + b*x**n)/(b*n*p), x) rule5741 = ReplacementRule(pattern5741, replacement5741) pattern5742 = Pattern(Integral(x_**WC('m', S(1))*cosh(x_**n_*WC('b', S(1)) + WC('a', S(0)))**p_, x_), cons2, cons3, cons21, cons4, cons56, cons13, cons146) def replacement5742(p, m, b, a, n, x): rubi.append(5742) return Dist((p + S(-1))/p, Int(x**m*cosh(a + b*x**n)**(p + S(-2)), x), x) - Simp(cosh(a + b*x**n)**p/(b**S(2)*n*p**S(2)), x) + Simp(x**n*sinh(a + b*x**n)*cosh(a + b*x**n)**(p + S(-1))/(b*n*p), x) rule5742 = ReplacementRule(pattern5742, replacement5742) pattern5743 = Pattern(Integral(x_**WC('m', S(1))*sinh(x_**n_*WC('b', S(1)) + WC('a', S(0)))**p_, x_), cons2, cons3, cons150, cons13, cons146, cons1503) def replacement5743(p, m, b, a, n, x): rubi.append(5743) return -Dist((p + S(-1))/p, Int(x**m*sinh(a + b*x**n)**(p + S(-2)), x), x) + Dist((m - S(2)*n + S(1))*(m - n + S(1))/(b**S(2)*n**S(2)*p**S(2)), Int(x**(m - S(2)*n)*sinh(a + b*x**n)**p, x), x) - Simp(x**(m - S(2)*n + S(1))*(m - n + S(1))*sinh(a + b*x**n)**p/(b**S(2)*n**S(2)*p**S(2)), x) + Simp(x**(m - n + S(1))*sinh(a + b*x**n)**(p + S(-1))*cosh(a + b*x**n)/(b*n*p), x) rule5743 = ReplacementRule(pattern5743, replacement5743) pattern5744 = Pattern(Integral(x_**WC('m', S(1))*cosh(x_**n_*WC('b', S(1)) + WC('a', S(0)))**p_, x_), cons2, cons3, cons150, cons13, cons146, cons1503) def replacement5744(p, m, b, a, n, x): rubi.append(5744) return Dist((p + S(-1))/p, Int(x**m*cosh(a + b*x**n)**(p + S(-2)), x), x) + Dist((m - S(2)*n + S(1))*(m - n + S(1))/(b**S(2)*n**S(2)*p**S(2)), Int(x**(m - S(2)*n)*cosh(a + b*x**n)**p, x), x) - Simp(x**(m - S(2)*n + S(1))*(m - n + S(1))*cosh(a + b*x**n)**p/(b**S(2)*n**S(2)*p**S(2)), x) + Simp(x**(m - n + S(1))*sinh(a + b*x**n)*cosh(a + b*x**n)**(p + S(-1))/(b*n*p), x) rule5744 = ReplacementRule(pattern5744, replacement5744) pattern5745 = Pattern(Integral(x_**WC('m', S(1))*sinh(x_**n_*WC('b', S(1)) + WC('a', S(0)))**p_, x_), cons2, cons3, cons150, cons13, cons146, cons1504, cons683) def replacement5745(p, m, b, a, n, x): rubi.append(5745) return Dist(b**S(2)*n**S(2)*p**S(2)/((m + S(1))*(m + n + S(1))), Int(x**(m + S(2)*n)*sinh(a + b*x**n)**p, x), x) + Dist(b**S(2)*n**S(2)*p*(p + S(-1))/((m + S(1))*(m + n + S(1))), Int(x**(m + S(2)*n)*sinh(a + b*x**n)**(p + S(-2)), x), x) + Simp(x**(m + S(1))*sinh(a + b*x**n)**p/(m + S(1)), x) - Simp(b*n*p*x**(m + n + S(1))*sinh(a + b*x**n)**(p + S(-1))*cosh(a + b*x**n)/((m + S(1))*(m + n + S(1))), x) rule5745 = ReplacementRule(pattern5745, replacement5745) pattern5746 = Pattern(Integral(x_**WC('m', S(1))*cosh(x_**n_*WC('b', S(1)) + WC('a', S(0)))**p_, x_), cons2, cons3, cons150, cons13, cons146, cons1504, cons683) def replacement5746(p, m, b, a, n, x): rubi.append(5746) return Dist(b**S(2)*n**S(2)*p**S(2)/((m + S(1))*(m + n + S(1))), Int(x**(m + S(2)*n)*cosh(a + b*x**n)**p, x), x) - Dist(b**S(2)*n**S(2)*p*(p + S(-1))/((m + S(1))*(m + n + S(1))), Int(x**(m + S(2)*n)*cosh(a + b*x**n)**(p + S(-2)), x), x) + Simp(x**(m + S(1))*cosh(a + b*x**n)**p/(m + S(1)), x) - Simp(b*n*p*x**(m + n + S(1))*sinh(a + b*x**n)*cosh(a + b*x**n)**(p + S(-1))/((m + S(1))*(m + n + S(1))), x) rule5746 = ReplacementRule(pattern5746, replacement5746) def With5747(p, m, b, d, c, a, n, x, e): k = Denominator(m) rubi.append(5747) return Dist(k/e, Subst(Int(x**(k*(m + S(1)) + S(-1))*(a + b*sinh(c + d*e**(-n)*x**(k*n)))**p, x), x, (e*x)**(S(1)/k)), x) pattern5747 = Pattern(Integral((x_*WC('e', S(1)))**m_*(WC('a', S(0)) + WC('b', S(1))*sinh(x_**n_*WC('d', S(1)) + WC('c', S(0))))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons38, cons148, cons367) rule5747 = ReplacementRule(pattern5747, With5747) def With5748(p, m, b, d, a, c, n, x, e): k = Denominator(m) rubi.append(5748) return Dist(k/e, Subst(Int(x**(k*(m + S(1)) + S(-1))*(a + b*cosh(c + d*e**(-n)*x**(k*n)))**p, x), x, (e*x)**(S(1)/k)), x) pattern5748 = Pattern(Integral((x_*WC('e', S(1)))**m_*(WC('a', S(0)) + WC('b', S(1))*cosh(x_**n_*WC('d', S(1)) + WC('c', S(0))))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons38, cons148, cons367) rule5748 = ReplacementRule(pattern5748, With5748) pattern5749 = Pattern(Integral((x_*WC('e', S(1)))**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*sinh(x_**n_*WC('d', S(1)) + WC('c', S(0))))**p_, x_), cons2, cons3, cons7, cons27, cons48, cons21, cons38, cons148, cons146) def replacement5749(p, m, b, d, c, a, n, x, e): rubi.append(5749) return Int(ExpandTrigReduce((e*x)**m, (a + b*sinh(c + d*x**n))**p, x), x) rule5749 = ReplacementRule(pattern5749, replacement5749) pattern5750 = Pattern(Integral((x_*WC('e', S(1)))**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*cosh(x_**n_*WC('d', S(1)) + WC('c', S(0))))**p_, x_), cons2, cons3, cons7, cons27, cons48, cons21, cons38, cons148, cons146) def replacement5750(p, m, b, d, a, c, n, x, e): rubi.append(5750) return Int(ExpandTrigReduce((e*x)**m, (a + b*cosh(c + d*x**n))**p, x), x) rule5750 = ReplacementRule(pattern5750, replacement5750) pattern5751 = Pattern(Integral(x_**WC('m', S(1))*sinh(x_**n_*WC('b', S(1)) + WC('a', S(0)))**p_, x_), cons2, cons3, cons21, cons4, cons56, cons13, cons137, cons1505) def replacement5751(p, m, b, a, n, x): rubi.append(5751) return -Dist((p + S(2))/(p + S(1)), Int(x**m*sinh(a + b*x**n)**(p + S(2)), x), x) - Simp(sinh(a + b*x**n)**(p + S(2))/(b**S(2)*n*(p + S(1))*(p + S(2))), x) + Simp(x**n*sinh(a + b*x**n)**(p + S(1))*cosh(a + b*x**n)/(b*n*(p + S(1))), x) rule5751 = ReplacementRule(pattern5751, replacement5751) pattern5752 = Pattern(Integral(x_**WC('m', S(1))*cosh(x_**n_*WC('b', S(1)) + WC('a', S(0)))**p_, x_), cons2, cons3, cons21, cons4, cons56, cons13, cons137, cons1505) def replacement5752(p, m, b, a, n, x): rubi.append(5752) return Dist((p + S(2))/(p + S(1)), Int(x**m*cosh(a + b*x**n)**(p + S(2)), x), x) + Simp(cosh(a + b*x**n)**(p + S(2))/(b**S(2)*n*(p + S(1))*(p + S(2))), x) - Simp(x**n*sinh(a + b*x**n)*cosh(a + b*x**n)**(p + S(1))/(b*n*(p + S(1))), x) rule5752 = ReplacementRule(pattern5752, replacement5752) pattern5753 = Pattern(Integral(x_**WC('m', S(1))*sinh(x_**n_*WC('b', S(1)) + WC('a', S(0)))**p_, x_), cons2, cons3, cons150, cons13, cons137, cons1505, cons1503) def replacement5753(p, m, b, a, n, x): rubi.append(5753) return -Dist((p + S(2))/(p + S(1)), Int(x**m*sinh(a + b*x**n)**(p + S(2)), x), x) + Dist((m - S(2)*n + S(1))*(m - n + S(1))/(b**S(2)*n**S(2)*(p + S(1))*(p + S(2))), Int(x**(m - S(2)*n)*sinh(a + b*x**n)**(p + S(2)), x), x) + Simp(x**(m - n + S(1))*sinh(a + b*x**n)**(p + S(1))*cosh(a + b*x**n)/(b*n*(p + S(1))), x) - Simp(x**(m - S(2)*n + S(1))*(m - n + S(1))*sinh(a + b*x**n)**(p + S(2))/(b**S(2)*n**S(2)*(p + S(1))*(p + S(2))), x) rule5753 = ReplacementRule(pattern5753, replacement5753) pattern5754 = Pattern(Integral(x_**WC('m', S(1))*cosh(x_**n_*WC('b', S(1)) + WC('a', S(0)))**p_, x_), cons2, cons3, cons150, cons13, cons137, cons1505, cons1503) def replacement5754(p, m, b, a, n, x): rubi.append(5754) return Dist((p + S(2))/(p + S(1)), Int(x**m*cosh(a + b*x**n)**(p + S(2)), x), x) - Dist((m - S(2)*n + S(1))*(m - n + S(1))/(b**S(2)*n**S(2)*(p + S(1))*(p + S(2))), Int(x**(m - S(2)*n)*cosh(a + b*x**n)**(p + S(2)), x), x) - Simp(x**(m - n + S(1))*sinh(a + b*x**n)*cosh(a + b*x**n)**(p + S(1))/(b*n*(p + S(1))), x) + Simp(x**(m - S(2)*n + S(1))*(m - n + S(1))*cosh(a + b*x**n)**(p + S(2))/(b**S(2)*n**S(2)*(p + S(1))*(p + S(2))), x) rule5754 = ReplacementRule(pattern5754, replacement5754) pattern5755 = Pattern(Integral(x_**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*sinh(x_**n_*WC('d', S(1)) + WC('c', S(0))))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons38, cons196, cons17) def replacement5755(p, m, b, d, c, a, n, x): rubi.append(5755) return -Subst(Int(x**(-m + S(-2))*(a + b*sinh(c + d*x**(-n)))**p, x), x, S(1)/x) rule5755 = ReplacementRule(pattern5755, replacement5755) pattern5756 = Pattern(Integral(x_**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*cosh(x_**n_*WC('d', S(1)) + WC('c', S(0))))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons38, cons196, cons17) def replacement5756(p, m, b, d, a, c, n, x): rubi.append(5756) return -Subst(Int(x**(-m + S(-2))*(a + b*cosh(c + d*x**(-n)))**p, x), x, S(1)/x) rule5756 = ReplacementRule(pattern5756, replacement5756) def With5757(p, m, b, d, c, a, n, x, e): k = Denominator(m) rubi.append(5757) return -Dist(k/e, Subst(Int(x**(-k*(m + S(1)) + S(-1))*(a + b*sinh(c + d*e**(-n)*x**(-k*n)))**p, x), x, (e*x)**(-S(1)/k)), x) pattern5757 = Pattern(Integral((x_*WC('e', S(1)))**m_*(WC('a', S(0)) + WC('b', S(1))*sinh(x_**n_*WC('d', S(1)) + WC('c', S(0))))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons38, cons196, cons367) rule5757 = ReplacementRule(pattern5757, With5757) def With5758(p, m, b, d, a, c, n, x, e): k = Denominator(m) rubi.append(5758) return -Dist(k/e, Subst(Int(x**(-k*(m + S(1)) + S(-1))*(a + b*cosh(c + d*e**(-n)*x**(-k*n)))**p, x), x, (e*x)**(-S(1)/k)), x) pattern5758 = Pattern(Integral((x_*WC('e', S(1)))**m_*(WC('a', S(0)) + WC('b', S(1))*cosh(x_**n_*WC('d', S(1)) + WC('c', S(0))))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons38, cons196, cons367) rule5758 = ReplacementRule(pattern5758, With5758) pattern5759 = Pattern(Integral((x_*WC('e', S(1)))**m_*(WC('a', S(0)) + WC('b', S(1))*sinh(x_**n_*WC('d', S(1)) + WC('c', S(0))))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons21, cons38, cons196, cons356) def replacement5759(p, m, b, d, c, a, n, x, e): rubi.append(5759) return -Dist((e*x)**m*(S(1)/x)**m, Subst(Int(x**(-m + S(-2))*(a + b*sinh(c + d*x**(-n)))**p, x), x, S(1)/x), x) rule5759 = ReplacementRule(pattern5759, replacement5759) pattern5760 = Pattern(Integral((x_*WC('e', S(1)))**m_*(WC('a', S(0)) + WC('b', S(1))*cosh(x_**n_*WC('d', S(1)) + WC('c', S(0))))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons21, cons38, cons196, cons356) def replacement5760(p, m, b, d, a, c, n, x, e): rubi.append(5760) return -Dist((e*x)**m*(S(1)/x)**m, Subst(Int(x**(-m + S(-2))*(a + b*cosh(c + d*x**(-n)))**p, x), x, S(1)/x), x) rule5760 = ReplacementRule(pattern5760, replacement5760) def With5761(p, m, b, d, c, a, n, x): k = Denominator(n) rubi.append(5761) return Dist(k, Subst(Int(x**(k*(m + S(1)) + S(-1))*(a + b*sinh(c + d*x**(k*n)))**p, x), x, x**(S(1)/k)), x) pattern5761 = Pattern(Integral(x_**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*sinh(x_**n_*WC('d', S(1)) + WC('c', S(0))))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons21, cons38, cons489) rule5761 = ReplacementRule(pattern5761, With5761) def With5762(p, m, b, d, a, c, n, x): k = Denominator(n) rubi.append(5762) return Dist(k, Subst(Int(x**(k*(m + S(1)) + S(-1))*(a + b*cosh(c + d*x**(k*n)))**p, x), x, x**(S(1)/k)), x) pattern5762 = Pattern(Integral(x_**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*cosh(x_**n_*WC('d', S(1)) + WC('c', S(0))))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons21, cons38, cons489) rule5762 = ReplacementRule(pattern5762, With5762) pattern5763 = Pattern(Integral((e_*x_)**m_*(WC('a', S(0)) + WC('b', S(1))*sinh(x_**n_*WC('d', S(1)) + WC('c', S(0))))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons21, cons38, cons489) def replacement5763(p, m, b, d, c, a, n, x, e): rubi.append(5763) return Dist(e**IntPart(m)*x**(-FracPart(m))*(e*x)**FracPart(m), Int(x**m*(a + b*sinh(c + d*x**n))**p, x), x) rule5763 = ReplacementRule(pattern5763, replacement5763) pattern5764 = Pattern(Integral((e_*x_)**m_*(WC('a', S(0)) + WC('b', S(1))*cosh(x_**n_*WC('d', S(1)) + WC('c', S(0))))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons21, cons38, cons489) def replacement5764(p, m, b, d, a, c, n, x, e): rubi.append(5764) return Dist(e**IntPart(m)*x**(-FracPart(m))*(e*x)**FracPart(m), Int(x**m*(a + b*cosh(c + d*x**n))**p, x), x) rule5764 = ReplacementRule(pattern5764, replacement5764) pattern5765 = Pattern(Integral(x_**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*sinh(x_**n_*WC('d', S(1)) + WC('c', S(0))))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons21, cons4, cons38, cons66, cons854, cons23) def replacement5765(p, m, b, d, c, a, n, x): rubi.append(5765) return Dist(S(1)/(m + S(1)), Subst(Int((a + b*sinh(c + d*x**(n/(m + S(1)))))**p, x), x, x**(m + S(1))), x) rule5765 = ReplacementRule(pattern5765, replacement5765) pattern5766 = Pattern(Integral(x_**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*cosh(x_**n_*WC('d', S(1)) + WC('c', S(0))))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons21, cons4, cons38, cons66, cons854, cons23) def replacement5766(p, m, b, d, a, c, n, x): rubi.append(5766) return Dist(S(1)/(m + S(1)), Subst(Int((a + b*cosh(c + d*x**(n/(m + S(1)))))**p, x), x, x**(m + S(1))), x) rule5766 = ReplacementRule(pattern5766, replacement5766) pattern5767 = Pattern(Integral((e_*x_)**m_*(WC('a', S(0)) + WC('b', S(1))*sinh(x_**n_*WC('d', S(1)) + WC('c', S(0))))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons21, cons4, cons38, cons66, cons854, cons23) def replacement5767(p, m, b, d, c, a, n, x, e): rubi.append(5767) return Dist(e**IntPart(m)*x**(-FracPart(m))*(e*x)**FracPart(m), Int(x**m*(a + b*sinh(c + d*x**n))**p, x), x) rule5767 = ReplacementRule(pattern5767, replacement5767) pattern5768 = Pattern(Integral((e_*x_)**m_*(WC('a', S(0)) + WC('b', S(1))*cosh(x_**n_*WC('d', S(1)) + WC('c', S(0))))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons21, cons4, cons38, cons66, cons854, cons23) def replacement5768(p, m, b, d, a, c, n, x, e): rubi.append(5768) return Dist(e**IntPart(m)*x**(-FracPart(m))*(e*x)**FracPart(m), Int(x**m*(a + b*cosh(c + d*x**n))**p, x), x) rule5768 = ReplacementRule(pattern5768, replacement5768) pattern5769 = Pattern(Integral((x_*WC('e', S(1)))**WC('m', S(1))*sinh(x_**n_*WC('d', S(1)) + WC('c', S(0))), x_), cons7, cons27, cons48, cons21, cons4, cons1506) def replacement5769(m, d, c, n, x, e): rubi.append(5769) return -Dist(S(1)/2, Int((e*x)**m*exp(-c - d*x**n), x), x) + Dist(S(1)/2, Int((e*x)**m*exp(c + d*x**n), x), x) rule5769 = ReplacementRule(pattern5769, replacement5769) pattern5770 = Pattern(Integral((x_*WC('e', S(1)))**WC('m', S(1))*cosh(x_**n_*WC('d', S(1)) + WC('c', S(0))), x_), cons7, cons27, cons48, cons21, cons4, cons1506) def replacement5770(m, d, c, n, x, e): rubi.append(5770) return Dist(S(1)/2, Int((e*x)**m*exp(-c - d*x**n), x), x) + Dist(S(1)/2, Int((e*x)**m*exp(c + d*x**n), x), x) rule5770 = ReplacementRule(pattern5770, replacement5770) pattern5771 = Pattern(Integral((x_*WC('e', S(1)))**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*sinh(x_**n_*WC('d', S(1)) + WC('c', S(0))))**p_, x_), cons2, cons3, cons7, cons27, cons48, cons21, cons4, cons128) def replacement5771(p, m, b, d, c, a, n, x, e): rubi.append(5771) return Int(ExpandTrigReduce((e*x)**m, (a + b*sinh(c + d*x**n))**p, x), x) rule5771 = ReplacementRule(pattern5771, replacement5771) pattern5772 = Pattern(Integral((x_*WC('e', S(1)))**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*cosh(x_**n_*WC('d', S(1)) + WC('c', S(0))))**p_, x_), cons2, cons3, cons7, cons27, cons48, cons21, cons4, cons128) def replacement5772(p, m, b, d, a, c, n, x, e): rubi.append(5772) return Int(ExpandTrigReduce((e*x)**m, (a + b*cosh(c + d*x**n))**p, x), x) rule5772 = ReplacementRule(pattern5772, replacement5772) pattern5773 = Pattern(Integral(x_**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*sinh(u_**n_*WC('d', S(1)) + WC('c', S(0))))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons4, cons5, cons68, cons69, cons17) def replacement5773(p, u, m, b, d, c, a, n, x): rubi.append(5773) return Dist(Coefficient(u, x, S(1))**(-m + S(-1)), Subst(Int((a + b*sinh(c + d*x**n))**p*(x - Coefficient(u, x, S(0)))**m, x), x, u), x) rule5773 = ReplacementRule(pattern5773, replacement5773) pattern5774 = Pattern(Integral(x_**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*cosh(u_**n_*WC('d', S(1)) + WC('c', S(0))))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons4, cons5, cons68, cons69, cons17) def replacement5774(p, u, m, b, d, a, c, n, x): rubi.append(5774) return Dist(Coefficient(u, x, S(1))**(-m + S(-1)), Subst(Int((a + b*cosh(c + d*x**n))**p*(x - Coefficient(u, x, S(0)))**m, x), x, u), x) rule5774 = ReplacementRule(pattern5774, replacement5774) pattern5775 = Pattern(Integral((x_*WC('e', S(1)))**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*sinh(u_**n_*WC('d', S(1)) + WC('c', S(0))))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons21, cons4, cons5, cons68) def replacement5775(p, u, m, b, d, c, a, n, x, e): rubi.append(5775) return Int((e*x)**m*(a + b*sinh(c + d*u**n))**p, x) rule5775 = ReplacementRule(pattern5775, replacement5775) pattern5776 = Pattern(Integral((x_*WC('e', S(1)))**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*cosh(u_**n_*WC('d', S(1)) + WC('c', S(0))))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons21, cons4, cons5, cons68) def replacement5776(p, u, m, b, d, a, c, n, x, e): rubi.append(5776) return Int((e*x)**m*(a + b*cosh(c + d*u**n))**p, x) rule5776 = ReplacementRule(pattern5776, replacement5776) pattern5777 = Pattern(Integral((e_*x_)**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*sinh(u_))**WC('p', S(1)), x_), cons2, cons3, cons48, cons21, cons5, cons823, cons824) def replacement5777(p, u, m, b, a, x, e): rubi.append(5777) return Int((e*x)**m*(a + b*sinh(ExpandToSum(u, x)))**p, x) rule5777 = ReplacementRule(pattern5777, replacement5777) pattern5778 = Pattern(Integral((e_*x_)**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*cosh(u_))**WC('p', S(1)), x_), cons2, cons3, cons48, cons21, cons5, cons823, cons824) def replacement5778(p, u, m, b, a, x, e): rubi.append(5778) return Int((e*x)**m*(a + b*cosh(ExpandToSum(u, x)))**p, x) rule5778 = ReplacementRule(pattern5778, replacement5778) pattern5779 = Pattern(Integral(x_**WC('m', S(1))*sinh(x_**WC('n', S(1))*WC('b', S(1)) + WC('a', S(0)))**WC('p', S(1))*cosh(x_**WC('n', S(1))*WC('b', S(1)) + WC('a', S(0))), x_), cons2, cons3, cons21, cons4, cons5, cons53, cons54) def replacement5779(p, m, b, a, n, x): rubi.append(5779) return Simp(sinh(a + b*x**n)**(p + S(1))/(b*n*(p + S(1))), x) rule5779 = ReplacementRule(pattern5779, replacement5779) pattern5780 = Pattern(Integral(x_**WC('m', S(1))*sinh(x_**WC('n', S(1))*WC('b', S(1)) + WC('a', S(0)))*cosh(x_**WC('n', S(1))*WC('b', S(1)) + WC('a', S(0)))**WC('p', S(1)), x_), cons2, cons3, cons21, cons4, cons5, cons53, cons54) def replacement5780(p, m, b, a, n, x): rubi.append(5780) return Simp(cosh(a + b*x**n)**(p + S(1))/(b*n*(p + S(1))), x) rule5780 = ReplacementRule(pattern5780, replacement5780) pattern5781 = Pattern(Integral(x_**WC('m', S(1))*sinh(x_**WC('n', S(1))*WC('b', S(1)) + WC('a', S(0)))**WC('p', S(1))*cosh(x_**WC('n', S(1))*WC('b', S(1)) + WC('a', S(0))), x_), cons2, cons3, cons5, cons93, cons1501, cons54) def replacement5781(p, m, b, a, n, x): rubi.append(5781) return -Dist((m - n + S(1))/(b*n*(p + S(1))), Int(x**(m - n)*sinh(a + b*x**n)**(p + S(1)), x), x) + Simp(x**(m - n + S(1))*sinh(a + b*x**n)**(p + S(1))/(b*n*(p + S(1))), x) rule5781 = ReplacementRule(pattern5781, replacement5781) pattern5782 = Pattern(Integral(x_**WC('m', S(1))*sinh(x_**WC('n', S(1))*WC('b', S(1)) + WC('a', S(0)))*cosh(x_**WC('n', S(1))*WC('b', S(1)) + WC('a', S(0)))**WC('p', S(1)), x_), cons2, cons3, cons5, cons93, cons1501, cons54) def replacement5782(p, m, b, a, n, x): rubi.append(5782) return -Dist((m - n + S(1))/(b*n*(p + S(1))), Int(x**(m - n)*cosh(a + b*x**n)**(p + S(1)), x), x) + Simp(x**(m - n + S(1))*cosh(a + b*x**n)**(p + S(1))/(b*n*(p + S(1))), x) rule5782 = ReplacementRule(pattern5782, replacement5782) pattern5783 = Pattern(Integral(sinh(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0))), x_), cons2, cons3, cons7, cons14) def replacement5783(x, c, a, b): rubi.append(5783) return -Dist(S(1)/2, Int(exp(-a - b*x - c*x**S(2)), x), x) + Dist(S(1)/2, Int(exp(a + b*x + c*x**S(2)), x), x) rule5783 = ReplacementRule(pattern5783, replacement5783) pattern5784 = Pattern(Integral(cosh(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0))), x_), cons2, cons3, cons7, cons14) def replacement5784(x, c, a, b): rubi.append(5784) return Dist(S(1)/2, Int(exp(-a - b*x - c*x**S(2)), x), x) + Dist(S(1)/2, Int(exp(a + b*x + c*x**S(2)), x), x) rule5784 = ReplacementRule(pattern5784, replacement5784) pattern5785 = Pattern(Integral(sinh(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0)))**n_, x_), cons2, cons3, cons7, cons85, cons165) def replacement5785(b, c, a, n, x): rubi.append(5785) return Int(ExpandTrigReduce(sinh(a + b*x + c*x**S(2))**n, x), x) rule5785 = ReplacementRule(pattern5785, replacement5785) pattern5786 = Pattern(Integral(cosh(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0)))**n_, x_), cons2, cons3, cons7, cons85, cons165) def replacement5786(b, c, a, n, x): rubi.append(5786) return Int(ExpandTrigReduce(cosh(a + b*x + c*x**S(2))**n, x), x) rule5786 = ReplacementRule(pattern5786, replacement5786) pattern5787 = Pattern(Integral(sinh(v_)**WC('n', S(1)), x_), cons148, cons818, cons1131) def replacement5787(v, x, n): rubi.append(5787) return Int(sinh(ExpandToSum(v, x))**n, x) rule5787 = ReplacementRule(pattern5787, replacement5787) pattern5788 = Pattern(Integral(cosh(v_)**WC('n', S(1)), x_), cons148, cons818, cons1131) def replacement5788(v, x, n): rubi.append(5788) return Int(cosh(ExpandToSum(v, x))**n, x) rule5788 = ReplacementRule(pattern5788, replacement5788) pattern5789 = Pattern(Integral((x_*WC('e', S(1)) + WC('d', S(0)))*sinh(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0))), x_), cons2, cons3, cons7, cons27, cons48, cons1132) def replacement5789(b, d, c, a, x, e): rubi.append(5789) return Simp(e*cosh(a + b*x + c*x**S(2))/(S(2)*c), x) rule5789 = ReplacementRule(pattern5789, replacement5789) pattern5790 = Pattern(Integral((x_*WC('e', S(1)) + WC('d', S(0)))*cosh(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0))), x_), cons2, cons3, cons7, cons27, cons48, cons1132) def replacement5790(b, d, c, a, x, e): rubi.append(5790) return Simp(e*sinh(a + b*x + c*x**S(2))/(S(2)*c), x) rule5790 = ReplacementRule(pattern5790, replacement5790) pattern5791 = Pattern(Integral((x_*WC('e', S(1)) + WC('d', S(0)))*sinh(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0))), x_), cons2, cons3, cons7, cons27, cons48, cons1133) def replacement5791(b, d, c, a, x, e): rubi.append(5791) return -Dist((b*e - S(2)*c*d)/(S(2)*c), Int(sinh(a + b*x + c*x**S(2)), x), x) + Simp(e*cosh(a + b*x + c*x**S(2))/(S(2)*c), x) rule5791 = ReplacementRule(pattern5791, replacement5791) pattern5792 = Pattern(Integral((x_*WC('e', S(1)) + WC('d', S(0)))*cosh(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0))), x_), cons2, cons3, cons7, cons27, cons48, cons1133) def replacement5792(b, d, c, a, x, e): rubi.append(5792) return -Dist((b*e - S(2)*c*d)/(S(2)*c), Int(cosh(a + b*x + c*x**S(2)), x), x) + Simp(e*sinh(a + b*x + c*x**S(2))/(S(2)*c), x) rule5792 = ReplacementRule(pattern5792, replacement5792) pattern5793 = Pattern(Integral((x_*WC('e', S(1)) + WC('d', S(0)))**m_*sinh(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0))), x_), cons2, cons3, cons7, cons27, cons48, cons31, cons166, cons1132) def replacement5793(m, b, d, c, a, x, e): rubi.append(5793) return -Dist(e**S(2)*(m + S(-1))/(S(2)*c), Int((d + e*x)**(m + S(-2))*cosh(a + b*x + c*x**S(2)), x), x) + Simp(e*(d + e*x)**(m + S(-1))*cosh(a + b*x + c*x**S(2))/(S(2)*c), x) rule5793 = ReplacementRule(pattern5793, replacement5793) pattern5794 = Pattern(Integral((x_*WC('e', S(1)) + WC('d', S(0)))**m_*cosh(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0))), x_), cons2, cons3, cons7, cons27, cons48, cons31, cons166, cons1132) def replacement5794(m, b, d, c, a, x, e): rubi.append(5794) return -Dist(e**S(2)*(m + S(-1))/(S(2)*c), Int((d + e*x)**(m + S(-2))*sinh(a + b*x + c*x**S(2)), x), x) + Simp(e*(d + e*x)**(m + S(-1))*sinh(a + b*x + c*x**S(2))/(S(2)*c), x) rule5794 = ReplacementRule(pattern5794, replacement5794) pattern5795 = Pattern(Integral((x_*WC('e', S(1)) + WC('d', S(0)))**m_*sinh(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0))), x_), cons2, cons3, cons7, cons27, cons48, cons31, cons166, cons1133) def replacement5795(m, b, d, c, a, x, e): rubi.append(5795) return -Dist((b*e - S(2)*c*d)/(S(2)*c), Int((d + e*x)**(m + S(-1))*sinh(a + b*x + c*x**S(2)), x), x) - Dist(e**S(2)*(m + S(-1))/(S(2)*c), Int((d + e*x)**(m + S(-2))*cosh(a + b*x + c*x**S(2)), x), x) + Simp(e*(d + e*x)**(m + S(-1))*cosh(a + b*x + c*x**S(2))/(S(2)*c), x) rule5795 = ReplacementRule(pattern5795, replacement5795) pattern5796 = Pattern(Integral((x_*WC('e', S(1)) + WC('d', S(0)))**m_*cosh(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0))), x_), cons2, cons3, cons7, cons27, cons48, cons31, cons166, cons1133) def replacement5796(m, b, d, c, a, x, e): rubi.append(5796) return -Dist((b*e - S(2)*c*d)/(S(2)*c), Int((d + e*x)**(m + S(-1))*cosh(a + b*x + c*x**S(2)), x), x) - Dist(e**S(2)*(m + S(-1))/(S(2)*c), Int((d + e*x)**(m + S(-2))*sinh(a + b*x + c*x**S(2)), x), x) + Simp(e*(d + e*x)**(m + S(-1))*sinh(a + b*x + c*x**S(2))/(S(2)*c), x) rule5796 = ReplacementRule(pattern5796, replacement5796) pattern5797 = Pattern(Integral((x_*WC('e', S(1)) + WC('d', S(0)))**m_*sinh(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0))), x_), cons2, cons3, cons7, cons27, cons48, cons31, cons94, cons1132) def replacement5797(m, b, d, c, a, x, e): rubi.append(5797) return -Dist(S(2)*c/(e**S(2)*(m + S(1))), Int((d + e*x)**(m + S(2))*cosh(a + b*x + c*x**S(2)), x), x) + Simp((d + e*x)**(m + S(1))*sinh(a + b*x + c*x**S(2))/(e*(m + S(1))), x) rule5797 = ReplacementRule(pattern5797, replacement5797) pattern5798 = Pattern(Integral((x_*WC('e', S(1)) + WC('d', S(0)))**m_*cosh(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0))), x_), cons2, cons3, cons7, cons27, cons48, cons31, cons94, cons1132) def replacement5798(m, b, d, c, a, x, e): rubi.append(5798) return -Dist(S(2)*c/(e**S(2)*(m + S(1))), Int((d + e*x)**(m + S(2))*sinh(a + b*x + c*x**S(2)), x), x) + Simp((d + e*x)**(m + S(1))*cosh(a + b*x + c*x**S(2))/(e*(m + S(1))), x) rule5798 = ReplacementRule(pattern5798, replacement5798) pattern5799 = Pattern(Integral((x_*WC('e', S(1)) + WC('d', S(0)))**m_*sinh(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0))), x_), cons2, cons3, cons7, cons27, cons48, cons31, cons94, cons1133) def replacement5799(m, b, d, c, a, x, e): rubi.append(5799) return -Dist(S(2)*c/(e**S(2)*(m + S(1))), Int((d + e*x)**(m + S(2))*cosh(a + b*x + c*x**S(2)), x), x) - Dist((b*e - S(2)*c*d)/(e**S(2)*(m + S(1))), Int((d + e*x)**(m + S(1))*cosh(a + b*x + c*x**S(2)), x), x) + Simp((d + e*x)**(m + S(1))*sinh(a + b*x + c*x**S(2))/(e*(m + S(1))), x) rule5799 = ReplacementRule(pattern5799, replacement5799) pattern5800 = Pattern(Integral((x_*WC('e', S(1)) + WC('d', S(0)))**m_*cosh(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0))), x_), cons2, cons3, cons7, cons27, cons48, cons31, cons94, cons1133) def replacement5800(m, b, d, c, a, x, e): rubi.append(5800) return -Dist(S(2)*c/(e**S(2)*(m + S(1))), Int((d + e*x)**(m + S(2))*sinh(a + b*x + c*x**S(2)), x), x) - Dist((b*e - S(2)*c*d)/(e**S(2)*(m + S(1))), Int((d + e*x)**(m + S(1))*sinh(a + b*x + c*x**S(2)), x), x) + Simp((d + e*x)**(m + S(1))*cosh(a + b*x + c*x**S(2))/(e*(m + S(1))), x) rule5800 = ReplacementRule(pattern5800, replacement5800) pattern5801 = Pattern(Integral((x_*WC('e', S(1)) + WC('d', S(0)))**WC('m', S(1))*sinh(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0))), x_), cons2, cons3, cons7, cons27, cons48, cons21, cons1507) def replacement5801(m, b, d, a, c, x, e): rubi.append(5801) return Int((d + e*x)**m*sinh(a + b*x + c*x**S(2)), x) rule5801 = ReplacementRule(pattern5801, replacement5801) pattern5802 = Pattern(Integral((x_*WC('e', S(1)) + WC('d', S(0)))**WC('m', S(1))*cosh(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0))), x_), cons2, cons3, cons7, cons27, cons48, cons21, cons1507) def replacement5802(m, b, d, c, a, x, e): rubi.append(5802) return Int((d + e*x)**m*cosh(a + b*x + c*x**S(2)), x) rule5802 = ReplacementRule(pattern5802, replacement5802) pattern5803 = Pattern(Integral((x_*WC('e', S(1)) + WC('d', S(0)))**WC('m', S(1))*sinh(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0)))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons21, cons85, cons165) def replacement5803(m, b, d, a, c, n, x, e): rubi.append(5803) return Int(ExpandTrigReduce((d + e*x)**m, sinh(a + b*x + c*x**S(2))**n, x), x) rule5803 = ReplacementRule(pattern5803, replacement5803) pattern5804 = Pattern(Integral((x_*WC('e', S(1)) + WC('d', S(0)))**WC('m', S(1))*cosh(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0)))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons21, cons85, cons165) def replacement5804(m, b, d, c, a, n, x, e): rubi.append(5804) return Int(ExpandTrigReduce((d + e*x)**m, cosh(a + b*x + c*x**S(2))**n, x), x) rule5804 = ReplacementRule(pattern5804, replacement5804) pattern5805 = Pattern(Integral(u_**WC('m', S(1))*sinh(v_)**WC('n', S(1)), x_), cons21, cons148, cons68, cons818, cons819) def replacement5805(v, u, m, n, x): rubi.append(5805) return Int(ExpandToSum(u, x)**m*sinh(ExpandToSum(v, x))**n, x) rule5805 = ReplacementRule(pattern5805, replacement5805) pattern5806 = Pattern(Integral(u_**WC('m', S(1))*cosh(v_)**WC('n', S(1)), x_), cons21, cons148, cons68, cons818, cons819) def replacement5806(v, u, m, n, x): rubi.append(5806) return Int(ExpandToSum(u, x)**m*cosh(ExpandToSum(v, x))**n, x) rule5806 = ReplacementRule(pattern5806, replacement5806) pattern5807 = Pattern(Integral((x_*WC('b', S(1)) + WC('a', S(0)))**WC('m', S(1))*tanh(x_*WC('f', S(1)) + WC('e', S(0))), x_), cons2, cons3, cons48, cons125, cons62) def replacement5807(m, f, b, a, x, e): rubi.append(5807) return Dist(S(2), Int((a + b*x)**m*exp(S(2)*e + S(2)*f*x)/(exp(S(2)*e + S(2)*f*x) + S(1)), x), x) - Simp((a + b*x)**(m + S(1))/(b*(m + S(1))), x) rule5807 = ReplacementRule(pattern5807, replacement5807) pattern5808 = Pattern(Integral((x_*WC('b', S(1)) + WC('a', S(0)))**WC('m', S(1))/tanh(x_*WC('f', S(1)) + WC('e', S(0))), x_), cons2, cons3, cons48, cons125, cons62) def replacement5808(m, f, b, a, x, e): rubi.append(5808) return -Dist(S(2), Int((a + b*x)**m*exp(S(2)*e + S(2)*f*x)/(-exp(S(2)*e + S(2)*f*x) + S(1)), x), x) - Simp((a + b*x)**(m + S(1))/(b*(m + S(1))), x) rule5808 = ReplacementRule(pattern5808, replacement5808) pattern5809 = Pattern(Integral((WC('c', S(1))*tanh(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(x_*WC('b', S(1)) + WC('a', S(0)))**WC('m', S(1)), x_), cons2, cons3, cons7, cons48, cons125, cons93, cons165, cons168) def replacement5809(m, f, b, a, c, n, x, e): rubi.append(5809) return Dist(c**S(2), Int((c*tanh(e + f*x))**(n + S(-2))*(a + b*x)**m, x), x) + Dist(b*c*m/(f*(n + S(-1))), Int((c*tanh(e + f*x))**(n + S(-1))*(a + b*x)**(m + S(-1)), x), x) - Simp(c*(c*tanh(e + f*x))**(n + S(-1))*(a + b*x)**m/(f*(n + S(-1))), x) rule5809 = ReplacementRule(pattern5809, replacement5809) pattern5810 = Pattern(Integral((WC('c', S(1))/tanh(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(x_*WC('b', S(1)) + WC('a', S(0)))**WC('m', S(1)), x_), cons2, cons3, cons7, cons48, cons125, cons93, cons165, cons168) def replacement5810(m, f, b, c, a, n, x, e): rubi.append(5810) return Dist(c**S(2), Int((c/tanh(e + f*x))**(n + S(-2))*(a + b*x)**m, x), x) + Dist(b*c*m/(f*(n + S(-1))), Int((c/tanh(e + f*x))**(n + S(-1))*(a + b*x)**(m + S(-1)), x), x) - Simp(c*(c/tanh(e + f*x))**(n + S(-1))*(a + b*x)**m/(f*(n + S(-1))), x) rule5810 = ReplacementRule(pattern5810, replacement5810) pattern5811 = Pattern(Integral((WC('c', S(1))*tanh(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(x_*WC('b', S(1)) + WC('a', S(0)))**WC('m', S(1)), x_), cons2, cons3, cons7, cons48, cons125, cons93, cons89, cons168) def replacement5811(m, f, b, a, c, n, x, e): rubi.append(5811) return Dist(c**(S(-2)), Int((c*tanh(e + f*x))**(n + S(2))*(a + b*x)**m, x), x) - Dist(b*m/(c*f*(n + S(1))), Int((c*tanh(e + f*x))**(n + S(1))*(a + b*x)**(m + S(-1)), x), x) + Simp((c*tanh(e + f*x))**(n + S(1))*(a + b*x)**m/(c*f*(n + S(1))), x) rule5811 = ReplacementRule(pattern5811, replacement5811) pattern5812 = Pattern(Integral((WC('c', S(1))/tanh(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(x_*WC('b', S(1)) + WC('a', S(0)))**WC('m', S(1)), x_), cons2, cons3, cons7, cons48, cons125, cons93, cons89, cons168) def replacement5812(m, f, b, c, a, n, x, e): rubi.append(5812) return Dist(c**(S(-2)), Int((c/tanh(e + f*x))**(n + S(2))*(a + b*x)**m, x), x) - Dist(b*m/(c*f*(n + S(1))), Int((c/tanh(e + f*x))**(n + S(1))*(a + b*x)**(m + S(-1)), x), x) + Simp((c/tanh(e + f*x))**(n + S(1))*(a + b*x)**m/(c*f*(n + S(1))), x) rule5812 = ReplacementRule(pattern5812, replacement5812) pattern5813 = Pattern(Integral((a_ + WC('b', S(1))*tanh(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1))*(x_*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons528) def replacement5813(m, f, b, d, c, n, a, x, e): rubi.append(5813) return Int(ExpandIntegrand((c + d*x)**m, (a + b*tanh(e + f*x))**n, x), x) rule5813 = ReplacementRule(pattern5813, replacement5813) pattern5814 = Pattern(Integral((a_ + WC('b', S(1))/tanh(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1))*(x_*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons528) def replacement5814(m, f, b, d, c, n, a, x, e): rubi.append(5814) return Int(ExpandIntegrand((c + d*x)**m, (a + b/tanh(e + f*x))**n, x), x) rule5814 = ReplacementRule(pattern5814, replacement5814) pattern5815 = Pattern(Integral((x_*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1))/(a_ + WC('b', S(1))*tanh(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons1265, cons31, cons168) def replacement5815(m, f, b, d, c, a, x, e): rubi.append(5815) return Dist(a*d*m/(S(2)*b*f), Int((c + d*x)**(m + S(-1))/(a + b*tanh(e + f*x)), x), x) + Simp((c + d*x)**(m + S(1))/(S(2)*a*d*(m + S(1))), x) - Simp(a*(c + d*x)**m/(S(2)*b*f*(a + b*tanh(e + f*x))), x) rule5815 = ReplacementRule(pattern5815, replacement5815) pattern5816 = Pattern(Integral((x_*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1))/(a_ + WC('b', S(1))/tanh(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons1265, cons31, cons168) def replacement5816(m, f, b, d, c, a, x, e): rubi.append(5816) return Dist(a*d*m/(S(2)*b*f), Int((c + d*x)**(m + S(-1))/(a + b/tanh(e + f*x)), x), x) + Simp((c + d*x)**(m + S(1))/(S(2)*a*d*(m + S(1))), x) - Simp(a*(c + d*x)**m/(S(2)*b*f*(a + b/tanh(e + f*x))), x) rule5816 = ReplacementRule(pattern5816, replacement5816) pattern5817 = Pattern(Integral(S(1)/((a_ + WC('b', S(1))*tanh(x_*WC('f', S(1)) + WC('e', S(0))))*(x_*WC('d', S(1)) + WC('c', S(0)))**S(2)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons1265) def replacement5817(f, b, d, c, a, x, e): rubi.append(5817) return Dist(f/(a*d), Int(sinh(S(2)*e + S(2)*f*x)/(c + d*x), x), x) - Dist(f/(b*d), Int(cosh(S(2)*e + S(2)*f*x)/(c + d*x), x), x) - Simp(S(1)/(d*(a + b*tanh(e + f*x))*(c + d*x)), x) rule5817 = ReplacementRule(pattern5817, replacement5817) pattern5818 = Pattern(Integral(S(1)/((a_ + WC('b', S(1))/tanh(x_*WC('f', S(1)) + WC('e', S(0))))*(x_*WC('d', S(1)) + WC('c', S(0)))**S(2)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons1265) def replacement5818(f, b, d, c, a, x, e): rubi.append(5818) return -Dist(f/(a*d), Int(sinh(S(2)*e + S(2)*f*x)/(c + d*x), x), x) + Dist(f/(b*d), Int(cosh(S(2)*e + S(2)*f*x)/(c + d*x), x), x) - Simp(S(1)/(d*(a + b/tanh(e + f*x))*(c + d*x)), x) rule5818 = ReplacementRule(pattern5818, replacement5818) pattern5819 = Pattern(Integral((x_*WC('d', S(1)) + WC('c', S(0)))**m_/(a_ + WC('b', S(1))*tanh(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons1265, cons31, cons94, cons1510) def replacement5819(m, f, b, d, c, a, x, e): rubi.append(5819) return Dist(S(2)*b*f/(a*d*(m + S(1))), Int((c + d*x)**(m + S(1))/(a + b*tanh(e + f*x)), x), x) + Simp((c + d*x)**(m + S(1))/(d*(a + b*tanh(e + f*x))*(m + S(1))), x) - Simp(f*(c + d*x)**(m + S(2))/(b*d**S(2)*(m + S(1))*(m + S(2))), x) rule5819 = ReplacementRule(pattern5819, replacement5819) pattern5820 = Pattern(Integral((x_*WC('d', S(1)) + WC('c', S(0)))**m_/(a_ + WC('b', S(1))/tanh(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons1265, cons31, cons94, cons1510) def replacement5820(m, f, b, d, c, a, x, e): rubi.append(5820) return Dist(S(2)*b*f/(a*d*(m + S(1))), Int((c + d*x)**(m + S(1))/(a + b/tanh(e + f*x)), x), x) + Simp((c + d*x)**(m + S(1))/(d*(a + b/tanh(e + f*x))*(m + S(1))), x) - Simp(f*(c + d*x)**(m + S(2))/(b*d**S(2)*(m + S(1))*(m + S(2))), x) rule5820 = ReplacementRule(pattern5820, replacement5820) pattern5821 = Pattern(Integral(S(1)/((a_ + WC('b', S(1))*tanh(x_*WC('f', S(1)) + WC('e', S(0))))*(x_*WC('d', S(1)) + WC('c', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons1265) def replacement5821(f, b, d, c, a, x, e): rubi.append(5821) return Dist(S(1)/(S(2)*a), Int(cosh(S(2)*e + S(2)*f*x)/(c + d*x), x), x) - Dist(S(1)/(S(2)*b), Int(sinh(S(2)*e + S(2)*f*x)/(c + d*x), x), x) + Simp(log(c + d*x)/(S(2)*a*d), x) rule5821 = ReplacementRule(pattern5821, replacement5821) pattern5822 = Pattern(Integral(S(1)/((a_ + WC('b', S(1))/tanh(x_*WC('f', S(1)) + WC('e', S(0))))*(x_*WC('d', S(1)) + WC('c', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons1265) def replacement5822(f, b, d, c, a, x, e): rubi.append(5822) return -Dist(S(1)/(S(2)*a), Int(cosh(S(2)*e + S(2)*f*x)/(c + d*x), x), x) + Dist(S(1)/(S(2)*b), Int(sinh(S(2)*e + S(2)*f*x)/(c + d*x), x), x) + Simp(log(c + d*x)/(S(2)*a*d), x) rule5822 = ReplacementRule(pattern5822, replacement5822) pattern5823 = Pattern(Integral((x_*WC('d', S(1)) + WC('c', S(0)))**m_/(a_ + WC('b', S(1))*tanh(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons1265, cons18) def replacement5823(m, f, b, d, c, a, x, e): rubi.append(5823) return Dist(S(1)/(S(2)*a), Int((c + d*x)**m*exp(-S(2)*a*(e + f*x)/b), x), x) + Simp((c + d*x)**(m + S(1))/(S(2)*a*d*(m + S(1))), x) rule5823 = ReplacementRule(pattern5823, replacement5823) pattern5824 = Pattern(Integral((x_*WC('d', S(1)) + WC('c', S(0)))**m_/(a_ + WC('b', S(1))/tanh(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons1265, cons18) def replacement5824(m, f, b, d, c, a, x, e): rubi.append(5824) return -Dist(S(1)/(S(2)*a), Int((c + d*x)**m*exp(-S(2)*a*(e + f*x)/b), x), x) + Simp((c + d*x)**(m + S(1))/(S(2)*a*d*(m + S(1))), x) rule5824 = ReplacementRule(pattern5824, replacement5824) pattern5825 = Pattern(Integral((a_ + WC('b', S(1))*tanh(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(x_*WC('d', S(1)) + WC('c', S(0)))**m_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons1265, cons1571) def replacement5825(m, f, b, d, c, a, n, x, e): rubi.append(5825) return Int(ExpandIntegrand((c + d*x)**m, (-sinh(S(2)*e + S(2)*f*x)/(S(2)*b) + cosh(S(2)*e + S(2)*f*x)/(S(2)*a) + S(1)/(S(2)*a))**(-n), x), x) rule5825 = ReplacementRule(pattern5825, replacement5825) pattern5826 = Pattern(Integral((a_ + WC('b', S(1))/tanh(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(x_*WC('d', S(1)) + WC('c', S(0)))**m_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons1265, cons1571) def replacement5826(m, f, b, d, c, a, n, x, e): rubi.append(5826) return Int(ExpandIntegrand((c + d*x)**m, (sinh(S(2)*e + S(2)*f*x)/(S(2)*b) - cosh(S(2)*e + S(2)*f*x)/(S(2)*a) + S(1)/(S(2)*a))**(-n), x), x) rule5826 = ReplacementRule(pattern5826, replacement5826) pattern5827 = Pattern(Integral((a_ + WC('b', S(1))*tanh(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(x_*WC('d', S(1)) + WC('c', S(0)))**m_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons1265, cons196) def replacement5827(m, f, b, d, c, a, n, x, e): rubi.append(5827) return Int(ExpandIntegrand((c + d*x)**m, (S(1)/(S(2)*a) + exp(-S(2)*a*(e + f*x)/b)/(S(2)*a))**(-n), x), x) rule5827 = ReplacementRule(pattern5827, replacement5827) pattern5828 = Pattern(Integral((a_ + WC('b', S(1))/tanh(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(x_*WC('d', S(1)) + WC('c', S(0)))**m_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons1265, cons196) def replacement5828(m, f, b, d, c, a, n, x, e): rubi.append(5828) return Int(ExpandIntegrand((c + d*x)**m, (S(1)/(S(2)*a) - exp(-S(2)*a*(e + f*x)/b)/(S(2)*a))**(-n), x), x) rule5828 = ReplacementRule(pattern5828, replacement5828) def With5829(m, f, b, d, c, a, n, x, e): u = IntHide((a + b*tanh(e + f*x))**n, x) rubi.append(5829) return -Dist(d*m, Int(Dist((c + d*x)**(m + S(-1)), u, x), x), x) + Dist((c + d*x)**m, u, x) pattern5829 = Pattern(Integral((a_ + WC('b', S(1))*tanh(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(x_*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons1265, cons1572, cons31, cons168) rule5829 = ReplacementRule(pattern5829, With5829) def With5830(m, f, b, d, c, a, n, x, e): u = IntHide((a + b/tanh(e + f*x))**n, x) rubi.append(5830) return -Dist(d*m, Int(Dist((c + d*x)**(m + S(-1)), u, x), x), x) + Dist((c + d*x)**m, u, x) pattern5830 = Pattern(Integral((a_ + WC('b', S(1))/tanh(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(x_*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons1265, cons1572, cons31, cons168) rule5830 = ReplacementRule(pattern5830, With5830) pattern5831 = Pattern(Integral((x_*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1))/(a_ + WC('b', S(1))*tanh(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons1267, cons62) def replacement5831(m, f, b, d, c, a, x, e): rubi.append(5831) return -Dist(S(2)*b, Int((c + d*x)**m/(a**S(2) - b**S(2) + (a - b)**S(2)*exp(-S(2)*e - S(2)*f*x)), x), x) + Simp((c + d*x)**(m + S(1))/(d*(a - b)*(m + S(1))), x) rule5831 = ReplacementRule(pattern5831, replacement5831) pattern5832 = Pattern(Integral((x_*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1))/(a_ + WC('b', S(1))/tanh(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons1267, cons62) def replacement5832(m, f, b, d, c, a, x, e): rubi.append(5832) return Dist(S(2)*b, Int((c + d*x)**m/(a**S(2) - b**S(2) - (a + b)**S(2)*exp(S(2)*e + S(2)*f*x)), x), x) + Simp((c + d*x)**(m + S(1))/(d*(a + b)*(m + S(1))), x) rule5832 = ReplacementRule(pattern5832, replacement5832) pattern5833 = Pattern(Integral((x_*WC('d', S(1)) + WC('c', S(0)))/(a_ + WC('b', S(1))*tanh(x_*WC('f', S(1)) + WC('e', S(0))))**S(2), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons1267) def replacement5833(f, b, d, c, a, x, e): rubi.append(5833) return -Dist(S(1)/(f*(a**S(2) - b**S(2))), Int((-S(2)*a*c*f - S(2)*a*d*f*x + b*d)/(a + b*tanh(e + f*x)), x), x) - Simp((c + d*x)**S(2)/(S(2)*d*(a**S(2) - b**S(2))), x) + Simp(b*(c + d*x)/(f*(a + b*tanh(e + f*x))*(a**S(2) - b**S(2))), x) rule5833 = ReplacementRule(pattern5833, replacement5833) pattern5834 = Pattern(Integral((x_*WC('d', S(1)) + WC('c', S(0)))/(a_ + WC('b', S(1))/tanh(x_*WC('f', S(1)) + WC('e', S(0))))**S(2), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons1267) def replacement5834(f, b, d, c, a, x, e): rubi.append(5834) return -Dist(S(1)/(f*(a**S(2) - b**S(2))), Int((-S(2)*a*c*f - S(2)*a*d*f*x + b*d)/(a + b/tanh(e + f*x)), x), x) - Simp((c + d*x)**S(2)/(S(2)*d*(a**S(2) - b**S(2))), x) + Simp(b*(c + d*x)/(f*(a + b/tanh(e + f*x))*(a**S(2) - b**S(2))), x) rule5834 = ReplacementRule(pattern5834, replacement5834) pattern5835 = Pattern(Integral((a_ + WC('b', S(1))*tanh(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(x_*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons1267, cons196, cons62) def replacement5835(m, f, b, d, c, a, n, x, e): rubi.append(5835) return Int(ExpandIntegrand((c + d*x)**m, (-S(2)*b/(a**S(2) - b**S(2) + (a - b)**S(2)*exp(-S(2)*e - S(2)*f*x)) + S(1)/(a - b))**(-n), x), x) rule5835 = ReplacementRule(pattern5835, replacement5835) pattern5836 = Pattern(Integral((a_ + WC('b', S(1))/tanh(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(x_*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons1267, cons196, cons62) def replacement5836(m, f, b, d, c, a, n, x, e): rubi.append(5836) return Int(ExpandIntegrand((c + d*x)**m, (S(2)*b/(a**S(2) - b**S(2) - (a + b)**S(2)*exp(S(2)*e + S(2)*f*x)) + S(1)/(a + b))**(-n), x), x) rule5836 = ReplacementRule(pattern5836, replacement5836) pattern5837 = Pattern(Integral(u_**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*tanh(v_))**WC('n', S(1)), x_), cons2, cons3, cons21, cons4, cons810, cons811) def replacement5837(v, u, m, b, a, n, x): rubi.append(5837) return Int((a + b*tanh(ExpandToSum(v, x)))**n*ExpandToSum(u, x)**m, x) rule5837 = ReplacementRule(pattern5837, replacement5837) pattern5838 = Pattern(Integral(u_**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))/tanh(v_))**WC('n', S(1)), x_), cons2, cons3, cons21, cons4, cons810, cons811) def replacement5838(v, u, m, b, a, n, x): rubi.append(5838) return Int((a + b/tanh(ExpandToSum(v, x)))**n*ExpandToSum(u, x)**m, x) rule5838 = ReplacementRule(pattern5838, replacement5838) pattern5839 = Pattern(Integral((x_*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*tanh(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons4, cons1360) def replacement5839(m, f, b, d, c, a, n, x, e): rubi.append(5839) return Int((a + b*tanh(e + f*x))**n*(c + d*x)**m, x) rule5839 = ReplacementRule(pattern5839, replacement5839) pattern5840 = Pattern(Integral((x_*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))/tanh(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons4, cons1360) def replacement5840(m, f, b, d, a, n, c, x, e): rubi.append(5840) return Int((a + b/tanh(e + f*x))**n*(c + d*x)**m, x) rule5840 = ReplacementRule(pattern5840, replacement5840) pattern5841 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*tanh(x_**n_*WC('d', S(1)) + WC('c', S(0))))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons5, cons1573, cons38) def replacement5841(p, b, d, c, a, n, x): rubi.append(5841) return Dist(S(1)/n, Subst(Int(x**(S(-1) + S(1)/n)*(a + b*tanh(c + d*x))**p, x), x, x**n), x) rule5841 = ReplacementRule(pattern5841, replacement5841) pattern5842 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))/tanh(x_**n_*WC('d', S(1)) + WC('c', S(0))))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons5, cons1573, cons38) def replacement5842(p, b, d, a, c, n, x): rubi.append(5842) return Dist(S(1)/n, Subst(Int(x**(S(-1) + S(1)/n)*(a + b/tanh(c + d*x))**p, x), x, x**n), x) rule5842 = ReplacementRule(pattern5842, replacement5842) pattern5843 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*tanh(x_**n_*WC('d', S(1)) + WC('c', S(0))))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons4, cons5, cons1495) def replacement5843(p, b, d, c, a, n, x): rubi.append(5843) return Int((a + b*tanh(c + d*x**n))**p, x) rule5843 = ReplacementRule(pattern5843, replacement5843) pattern5844 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))/tanh(x_**n_*WC('d', S(1)) + WC('c', S(0))))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons4, cons5, cons1495) def replacement5844(p, b, d, a, c, n, x): rubi.append(5844) return Int((a + b/tanh(c + d*x**n))**p, x) rule5844 = ReplacementRule(pattern5844, replacement5844) pattern5845 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*tanh(u_**n_*WC('d', S(1)) + WC('c', S(0))))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons4, cons5, cons68, cons69) def replacement5845(p, u, b, d, c, a, n, x): rubi.append(5845) return Dist(S(1)/Coefficient(u, x, S(1)), Subst(Int((a + b*tanh(c + d*x**n))**p, x), x, u), x) rule5845 = ReplacementRule(pattern5845, replacement5845) pattern5846 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))/tanh(u_**n_*WC('d', S(1)) + WC('c', S(0))))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons4, cons5, cons68, cons69) def replacement5846(p, u, b, d, a, c, n, x): rubi.append(5846) return Dist(S(1)/Coefficient(u, x, S(1)), Subst(Int((a + b/tanh(c + d*x**n))**p, x), x, u), x) rule5846 = ReplacementRule(pattern5846, replacement5846) pattern5847 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*tanh(u_))**WC('p', S(1)), x_), cons2, cons3, cons5, cons823, cons824) def replacement5847(p, u, b, a, x): rubi.append(5847) return Int((a + b*tanh(ExpandToSum(u, x)))**p, x) rule5847 = ReplacementRule(pattern5847, replacement5847) pattern5848 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))/tanh(u_))**WC('p', S(1)), x_), cons2, cons3, cons5, cons823, cons824) def replacement5848(p, u, b, a, x): rubi.append(5848) return Int((a + b/tanh(ExpandToSum(u, x)))**p, x) rule5848 = ReplacementRule(pattern5848, replacement5848) pattern5849 = Pattern(Integral(x_**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*tanh(x_**n_*WC('d', S(1)) + WC('c', S(0))))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons21, cons4, cons5, cons1574, cons38) def replacement5849(p, m, b, d, c, a, n, x): rubi.append(5849) return Dist(S(1)/n, Subst(Int(x**(S(-1) + (m + S(1))/n)*(a + b*tanh(c + d*x))**p, x), x, x**n), x) rule5849 = ReplacementRule(pattern5849, replacement5849) pattern5850 = Pattern(Integral(x_**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))/tanh(x_**n_*WC('d', S(1)) + WC('c', S(0))))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons21, cons4, cons5, cons1574, cons38) def replacement5850(p, m, b, d, a, c, n, x): rubi.append(5850) return Dist(S(1)/n, Subst(Int(x**(S(-1) + (m + S(1))/n)*(a + b/tanh(c + d*x))**p, x), x, x**n), x) rule5850 = ReplacementRule(pattern5850, replacement5850) pattern5851 = Pattern(Integral(x_**WC('m', S(1))*tanh(x_**n_*WC('d', S(1)) + WC('c', S(0)))**S(2), x_), cons7, cons27, cons21, cons4, cons1575) def replacement5851(m, d, c, n, x): rubi.append(5851) return Dist((m - n + S(1))/(d*n), Int(x**(m - n)*tanh(c + d*x**n), x), x) + Int(x**m, x) - Simp(x**(m - n + S(1))*tanh(c + d*x**n)/(d*n), x) rule5851 = ReplacementRule(pattern5851, replacement5851) pattern5852 = Pattern(Integral(x_**WC('m', S(1))/tanh(x_**n_*WC('d', S(1)) + WC('c', S(0)))**S(2), x_), cons7, cons27, cons21, cons4, cons1575) def replacement5852(m, d, c, n, x): rubi.append(5852) return Dist((m - n + S(1))/(d*n), Int(x**(m - n)/tanh(c + d*x**n), x), x) + Int(x**m, x) - Simp(x**(m - n + S(1))/(d*n*tanh(c + d*x**n)), x) rule5852 = ReplacementRule(pattern5852, replacement5852) pattern5853 = Pattern(Integral(x_**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*tanh(x_**n_*WC('d', S(1)) + WC('c', S(0))))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons21, cons4, cons5, cons1576) def replacement5853(p, m, b, d, c, a, n, x): rubi.append(5853) return Int(x**m*(a + b*tanh(c + d*x**n))**p, x) rule5853 = ReplacementRule(pattern5853, replacement5853) pattern5854 = Pattern(Integral(x_**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))/tanh(x_**n_*WC('d', S(1)) + WC('c', S(0))))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons21, cons4, cons5, cons1576) def replacement5854(p, m, b, d, a, c, n, x): rubi.append(5854) return Int(x**m*(a + b/tanh(c + d*x**n))**p, x) rule5854 = ReplacementRule(pattern5854, replacement5854) pattern5855 = Pattern(Integral((e_*x_)**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*tanh(x_**n_*WC('d', S(1)) + WC('c', S(0))))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons21, cons4, cons5, cons1497) def replacement5855(p, m, b, d, c, a, n, x, e): rubi.append(5855) return Dist(e**IntPart(m)*x**(-FracPart(m))*(e*x)**FracPart(m), Int(x**m*(a + b*tanh(c + d*x**n))**p, x), x) rule5855 = ReplacementRule(pattern5855, replacement5855) pattern5856 = Pattern(Integral((e_*x_)**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))/tanh(x_**n_*WC('d', S(1)) + WC('c', S(0))))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons21, cons4, cons5, cons1497) def replacement5856(p, m, b, d, a, c, n, x, e): rubi.append(5856) return Dist(e**IntPart(m)*x**(-FracPart(m))*(e*x)**FracPart(m), Int(x**m*(a + b/tanh(c + d*x**n))**p, x), x) rule5856 = ReplacementRule(pattern5856, replacement5856) pattern5857 = Pattern(Integral((e_*x_)**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*tanh(u_))**WC('p', S(1)), x_), cons2, cons3, cons48, cons21, cons5, cons823, cons824) def replacement5857(p, u, m, b, a, x, e): rubi.append(5857) return Int((e*x)**m*(a + b*tanh(ExpandToSum(u, x)))**p, x) rule5857 = ReplacementRule(pattern5857, replacement5857) pattern5858 = Pattern(Integral((e_*x_)**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))/tanh(u_))**WC('p', S(1)), x_), cons2, cons3, cons48, cons21, cons5, cons823, cons824) def replacement5858(p, u, m, b, a, x, e): rubi.append(5858) return Int((e*x)**m*(a + b/tanh(ExpandToSum(u, x)))**p, x) rule5858 = ReplacementRule(pattern5858, replacement5858) pattern5859 = Pattern(Integral(x_**WC('m', S(1))*(S(1)/cosh(x_**WC('n', S(1))*WC('b', S(1)) + WC('a', S(0))))**WC('p', S(1))*tanh(x_**WC('n', S(1))*WC('b', S(1)) + WC('a', S(0)))**WC('q', S(1)), x_), cons2, cons3, cons5, cons31, cons85, cons1577, cons1578) def replacement5859(p, m, b, a, n, x, q): rubi.append(5859) return Dist((m - n + S(1))/(b*n*p), Int(x**(m - n)*(S(1)/cosh(a + b*x**n))**p, x), x) - Simp(x**(m - n + S(1))*(S(1)/cosh(a + b*x**n))**p/(b*n*p), x) rule5859 = ReplacementRule(pattern5859, replacement5859) pattern5860 = Pattern(Integral(x_**WC('m', S(1))*(S(1)/sinh(x_**WC('n', S(1))*WC('b', S(1)) + WC('a', S(0))))**WC('p', S(1))*(S(1)/tanh(x_**WC('n', S(1))*WC('b', S(1)) + WC('a', S(0))))**WC('q', S(1)), x_), cons2, cons3, cons5, cons31, cons85, cons1577, cons1578) def replacement5860(p, m, b, a, n, x, q): rubi.append(5860) return Dist((m - n + S(1))/(b*n*p), Int(x**(m - n)*(S(1)/sinh(a + b*x**n))**p, x), x) - Simp(x**(m - n + S(1))*(S(1)/sinh(a + b*x**n))**p/(b*n*p), x) rule5860 = ReplacementRule(pattern5860, replacement5860) pattern5861 = Pattern(Integral(tanh(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0)))**WC('n', S(1)), x_), cons2, cons3, cons7, cons4, cons1579) def replacement5861(b, c, a, n, x): rubi.append(5861) return Int(tanh(a + b*x + c*x**S(2))**n, x) rule5861 = ReplacementRule(pattern5861, replacement5861) pattern5862 = Pattern(Integral((S(1)/tanh(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons4, cons1579) def replacement5862(b, c, a, n, x): rubi.append(5862) return Int((S(1)/tanh(a + b*x + c*x**S(2)))**n, x) rule5862 = ReplacementRule(pattern5862, replacement5862) pattern5863 = Pattern(Integral((x_*WC('e', S(1)) + WC('d', S(0)))*tanh(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0))), x_), cons2, cons3, cons7, cons27, cons48, cons1043) def replacement5863(b, d, c, a, x, e): rubi.append(5863) return Dist((-b*e + S(2)*c*d)/(S(2)*c), Int(tanh(a + b*x + c*x**S(2)), x), x) + Simp(e*log(cosh(a + b*x + c*x**S(2)))/(S(2)*c), x) rule5863 = ReplacementRule(pattern5863, replacement5863) pattern5864 = Pattern(Integral((x_*WC('e', S(1)) + WC('d', S(0)))/tanh(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0))), x_), cons2, cons3, cons7, cons27, cons48, cons1043) def replacement5864(b, d, c, a, x, e): rubi.append(5864) return Dist((-b*e + S(2)*c*d)/(S(2)*c), Int(S(1)/tanh(a + b*x + c*x**S(2)), x), x) + Simp(e*log(sinh(a + b*x + c*x**S(2)))/(S(2)*c), x) rule5864 = ReplacementRule(pattern5864, replacement5864) pattern5865 = Pattern(Integral((x_*WC('e', S(1)) + WC('d', S(0)))**WC('m', S(1))*tanh(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0)))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons21, cons4, cons1580) def replacement5865(m, b, d, a, c, n, x, e): rubi.append(5865) return Int((d + e*x)**m*tanh(a + b*x + c*x**S(2))**n, x) rule5865 = ReplacementRule(pattern5865, replacement5865) pattern5866 = Pattern(Integral((x_*WC('e', S(1)) + WC('d', S(0)))**WC('m', S(1))*(S(1)/tanh(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons21, cons4, cons1580) def replacement5866(m, b, d, c, a, n, x, e): rubi.append(5866) return Int((d + e*x)**m*(S(1)/tanh(a + b*x + c*x**S(2)))**n, x) rule5866 = ReplacementRule(pattern5866, replacement5866) pattern5867 = Pattern(Integral((x_*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1))/cosh(x_*WC('b', S(1)) + WC('a', S(0))), x_), cons2, cons3, cons7, cons27, cons62) def replacement5867(m, b, d, c, a, x): rubi.append(5867) return -Dist(I*d*m/b, Int((c + d*x)**(m + S(-1))*log(-I*exp(a + b*x) + S(1)), x), x) + Dist(I*d*m/b, Int((c + d*x)**(m + S(-1))*log(I*exp(a + b*x) + S(1)), x), x) + Simp(S(2)*(c + d*x)**m*ArcTan(exp(a + b*x))/b, x) rule5867 = ReplacementRule(pattern5867, replacement5867) pattern5868 = Pattern(Integral((x_*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1))/sinh(x_*WC('b', S(1)) + WC('a', S(0))), x_), cons2, cons3, cons7, cons27, cons62) def replacement5868(m, b, d, c, a, x): rubi.append(5868) return -Dist(d*m/b, Int((c + d*x)**(m + S(-1))*log(-exp(a + b*x) + S(1)), x), x) + Dist(d*m/b, Int((c + d*x)**(m + S(-1))*log(exp(a + b*x) + S(1)), x), x) + Simp(-S(2)*(c + d*x)**m*atanh(exp(a + b*x))/b, x) rule5868 = ReplacementRule(pattern5868, replacement5868) pattern5869 = Pattern(Integral((x_*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1))/cosh(x_*WC('b', S(1)) + WC('a', S(0)))**S(2), x_), cons2, cons3, cons7, cons27, cons31, cons168) def replacement5869(m, b, d, c, a, x): rubi.append(5869) return -Dist(d*m/b, Int((c + d*x)**(m + S(-1))*tanh(a + b*x), x), x) + Simp((c + d*x)**m*tanh(a + b*x)/b, x) rule5869 = ReplacementRule(pattern5869, replacement5869) pattern5870 = Pattern(Integral((x_*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1))/sinh(x_*WC('b', S(1)) + WC('a', S(0)))**S(2), x_), cons2, cons3, cons7, cons27, cons31, cons168) def replacement5870(m, b, d, c, a, x): rubi.append(5870) return Dist(d*m/b, Int((c + d*x)**(m + S(-1))/tanh(a + b*x), x), x) - Simp((c + d*x)**m/(b*tanh(a + b*x)), x) rule5870 = ReplacementRule(pattern5870, replacement5870) pattern5871 = Pattern(Integral((x_*WC('d', S(1)) + WC('c', S(0)))*(S(1)/cosh(x_*WC('b', S(1)) + WC('a', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons87, cons165, cons1644) def replacement5871(b, d, c, a, n, x): rubi.append(5871) return Dist((n + S(-2))/(n + S(-1)), Int((c + d*x)*(S(1)/cosh(a + b*x))**(n + S(-2)), x), x) + Simp(d*(S(1)/cosh(a + b*x))**(n + S(-2))/(b**S(2)*(n + S(-2))*(n + S(-1))), x) + Simp((c + d*x)*(S(1)/cosh(a + b*x))**(n + S(-2))*tanh(a + b*x)/(b*(n + S(-1))), x) rule5871 = ReplacementRule(pattern5871, replacement5871) pattern5872 = Pattern(Integral((x_*WC('d', S(1)) + WC('c', S(0)))*(S(1)/sinh(x_*WC('b', S(1)) + WC('a', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons87, cons165, cons1644) def replacement5872(b, d, c, a, n, x): rubi.append(5872) return -Dist((n + S(-2))/(n + S(-1)), Int((c + d*x)*(S(1)/sinh(a + b*x))**(n + S(-2)), x), x) - Simp(d*(S(1)/sinh(a + b*x))**(n + S(-2))/(b**S(2)*(n + S(-2))*(n + S(-1))), x) - Simp((c + d*x)*(S(1)/sinh(a + b*x))**(n + S(-2))/(b*(n + S(-1))*tanh(a + b*x)), x) rule5872 = ReplacementRule(pattern5872, replacement5872) pattern5873 = Pattern(Integral((x_*WC('d', S(1)) + WC('c', S(0)))**m_*(S(1)/cosh(x_*WC('b', S(1)) + WC('a', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons93, cons165, cons1644, cons166) def replacement5873(m, b, d, c, a, n, x): rubi.append(5873) return Dist((n + S(-2))/(n + S(-1)), Int((c + d*x)**m*(S(1)/cosh(a + b*x))**(n + S(-2)), x), x) - Dist(d**S(2)*m*(m + S(-1))/(b**S(2)*(n + S(-2))*(n + S(-1))), Int((c + d*x)**(m + S(-2))*(S(1)/cosh(a + b*x))**(n + S(-2)), x), x) + Simp((c + d*x)**m*(S(1)/cosh(a + b*x))**(n + S(-2))*tanh(a + b*x)/(b*(n + S(-1))), x) + Simp(d*m*(c + d*x)**(m + S(-1))*(S(1)/cosh(a + b*x))**(n + S(-2))/(b**S(2)*(n + S(-2))*(n + S(-1))), x) rule5873 = ReplacementRule(pattern5873, replacement5873) pattern5874 = Pattern(Integral((x_*WC('d', S(1)) + WC('c', S(0)))**m_*(S(1)/sinh(x_*WC('b', S(1)) + WC('a', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons93, cons165, cons1644, cons166) def replacement5874(m, b, d, c, a, n, x): rubi.append(5874) return -Dist((n + S(-2))/(n + S(-1)), Int((c + d*x)**m*(S(1)/sinh(a + b*x))**(n + S(-2)), x), x) + Dist(d**S(2)*m*(m + S(-1))/(b**S(2)*(n + S(-2))*(n + S(-1))), Int((c + d*x)**(m + S(-2))*(S(1)/sinh(a + b*x))**(n + S(-2)), x), x) - Simp((c + d*x)**m*(S(1)/sinh(a + b*x))**(n + S(-2))/(b*(n + S(-1))*tanh(a + b*x)), x) - Simp(d*m*(c + d*x)**(m + S(-1))*(S(1)/sinh(a + b*x))**(n + S(-2))/(b**S(2)*(n + S(-2))*(n + S(-1))), x) rule5874 = ReplacementRule(pattern5874, replacement5874) pattern5875 = Pattern(Integral((x_*WC('d', S(1)) + WC('c', S(0)))*(S(1)/cosh(x_*WC('b', S(1)) + WC('a', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons87, cons89) def replacement5875(b, d, c, a, n, x): rubi.append(5875) return Dist((n + S(1))/n, Int((c + d*x)*(S(1)/cosh(a + b*x))**(n + S(2)), x), x) - Simp(d*(S(1)/cosh(a + b*x))**n/(b**S(2)*n**S(2)), x) - Simp((c + d*x)*(S(1)/cosh(a + b*x))**(n + S(1))*sinh(a + b*x)/(b*n), x) rule5875 = ReplacementRule(pattern5875, replacement5875) pattern5876 = Pattern(Integral((x_*WC('d', S(1)) + WC('c', S(0)))*(S(1)/sinh(x_*WC('b', S(1)) + WC('a', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons87, cons89) def replacement5876(b, d, c, a, n, x): rubi.append(5876) return -Dist((n + S(1))/n, Int((c + d*x)*(S(1)/sinh(a + b*x))**(n + S(2)), x), x) - Simp(d*(S(1)/sinh(a + b*x))**n/(b**S(2)*n**S(2)), x) - Simp((c + d*x)*(S(1)/sinh(a + b*x))**(n + S(1))*cosh(a + b*x)/(b*n), x) rule5876 = ReplacementRule(pattern5876, replacement5876) pattern5877 = Pattern(Integral((x_*WC('d', S(1)) + WC('c', S(0)))**m_*(S(1)/cosh(x_*WC('b', S(1)) + WC('a', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons93, cons89, cons166) def replacement5877(m, b, d, c, a, n, x): rubi.append(5877) return Dist((n + S(1))/n, Int((c + d*x)**m*(S(1)/cosh(a + b*x))**(n + S(2)), x), x) + Dist(d**S(2)*m*(m + S(-1))/(b**S(2)*n**S(2)), Int((c + d*x)**(m + S(-2))*(S(1)/cosh(a + b*x))**n, x), x) - Simp((c + d*x)**m*(S(1)/cosh(a + b*x))**(n + S(1))*sinh(a + b*x)/(b*n), x) - Simp(d*m*(c + d*x)**(m + S(-1))*(S(1)/cosh(a + b*x))**n/(b**S(2)*n**S(2)), x) rule5877 = ReplacementRule(pattern5877, replacement5877) pattern5878 = Pattern(Integral((x_*WC('d', S(1)) + WC('c', S(0)))**m_*(S(1)/sinh(x_*WC('b', S(1)) + WC('a', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons93, cons89, cons166) def replacement5878(m, b, d, c, a, n, x): rubi.append(5878) return -Dist((n + S(1))/n, Int((c + d*x)**m*(S(1)/sinh(a + b*x))**(n + S(2)), x), x) + Dist(d**S(2)*m*(m + S(-1))/(b**S(2)*n**S(2)), Int((c + d*x)**(m + S(-2))*(S(1)/sinh(a + b*x))**n, x), x) - Simp((c + d*x)**m*(S(1)/sinh(a + b*x))**(n + S(1))*cosh(a + b*x)/(b*n), x) - Simp(d*m*(c + d*x)**(m + S(-1))*(S(1)/sinh(a + b*x))**n/(b**S(2)*n**S(2)), x) rule5878 = ReplacementRule(pattern5878, replacement5878) pattern5879 = Pattern(Integral((x_*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1))*(S(1)/cosh(x_*WC('b', S(1)) + WC('a', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons21, cons4, cons23) def replacement5879(m, b, d, c, a, n, x): rubi.append(5879) return Dist((S(1)/cosh(a + b*x))**n*cosh(a + b*x)**n, Int((c + d*x)**m*cosh(a + b*x)**(-n), x), x) rule5879 = ReplacementRule(pattern5879, replacement5879) pattern5880 = Pattern(Integral((x_*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1))*(S(1)/sinh(x_*WC('b', S(1)) + WC('a', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons21, cons4, cons23) def replacement5880(m, b, d, c, a, n, x): rubi.append(5880) return Dist((S(1)/sinh(a + b*x))**n*sinh(a + b*x)**n, Int((c + d*x)**m*sinh(a + b*x)**(-n), x), x) rule5880 = ReplacementRule(pattern5880, replacement5880) pattern5881 = Pattern(Integral((a_ + WC('b', S(1))/cosh(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1))*(x_*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons528) def replacement5881(m, f, b, d, c, n, a, x, e): rubi.append(5881) return Int(ExpandIntegrand((c + d*x)**m, (a + b/cosh(e + f*x))**n, x), x) rule5881 = ReplacementRule(pattern5881, replacement5881) pattern5882 = Pattern(Integral((a_ + WC('b', S(1))/sinh(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1))*(x_*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons528) def replacement5882(m, f, b, d, c, n, a, x, e): rubi.append(5882) return Int(ExpandIntegrand((c + d*x)**m, (a + b/sinh(e + f*x))**n, x), x) rule5882 = ReplacementRule(pattern5882, replacement5882) pattern5883 = Pattern(Integral((a_ + WC('b', S(1))/cosh(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1))*(x_*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons196, cons62) def replacement5883(m, f, b, d, c, n, a, x, e): rubi.append(5883) return Int(ExpandIntegrand((c + d*x)**m, (a*cosh(e + f*x) + b)**n*cosh(e + f*x)**(-n), x), x) rule5883 = ReplacementRule(pattern5883, replacement5883) pattern5884 = Pattern(Integral((a_ + WC('b', S(1))/sinh(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1))*(x_*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons196, cons62) def replacement5884(m, f, b, d, c, n, a, x, e): rubi.append(5884) return Int(ExpandIntegrand((c + d*x)**m, (a*sinh(e + f*x) + b)**n*sinh(e + f*x)**(-n), x), x) rule5884 = ReplacementRule(pattern5884, replacement5884) pattern5885 = Pattern(Integral(u_**WC('m', S(1))*(S(1)/cosh(v_))**WC('n', S(1)), x_), cons21, cons4, cons810, cons811) def replacement5885(v, u, m, n, x): rubi.append(5885) return Int((S(1)/cosh(ExpandToSum(v, x)))**n*ExpandToSum(u, x)**m, x) rule5885 = ReplacementRule(pattern5885, replacement5885) pattern5886 = Pattern(Integral(u_**WC('m', S(1))*(S(1)/sinh(v_))**WC('n', S(1)), x_), cons21, cons4, cons810, cons811) def replacement5886(v, u, m, n, x): rubi.append(5886) return Int((S(1)/sinh(ExpandToSum(v, x)))**n*ExpandToSum(u, x)**m, x) rule5886 = ReplacementRule(pattern5886, replacement5886) pattern5887 = Pattern(Integral((x_*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1))*(S(1)/cosh(x_*WC('b', S(1)) + WC('a', S(0))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons21, cons4, cons1736) def replacement5887(m, b, d, c, a, n, x): rubi.append(5887) return Int((c + d*x)**m*(S(1)/cosh(a + b*x))**n, x) rule5887 = ReplacementRule(pattern5887, replacement5887) pattern5888 = Pattern(Integral((x_*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1))*(S(1)/sinh(x_*WC('b', S(1)) + WC('a', S(0))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons21, cons4, cons1736) def replacement5888(m, b, d, c, a, n, x): rubi.append(5888) return Int((c + d*x)**m*(S(1)/sinh(a + b*x))**n, x) rule5888 = ReplacementRule(pattern5888, replacement5888) pattern5889 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))/cosh(x_**n_*WC('d', S(1)) + WC('c', S(0))))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons5, cons1573, cons38) def replacement5889(p, b, d, c, a, n, x): rubi.append(5889) return Dist(S(1)/n, Subst(Int(x**(S(-1) + S(1)/n)*(a + b/cosh(c + d*x))**p, x), x, x**n), x) rule5889 = ReplacementRule(pattern5889, replacement5889) pattern5890 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))/sinh(x_**n_*WC('d', S(1)) + WC('c', S(0))))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons5, cons1573, cons38) def replacement5890(p, b, d, a, c, n, x): rubi.append(5890) return Dist(S(1)/n, Subst(Int(x**(S(-1) + S(1)/n)*(a + b/sinh(c + d*x))**p, x), x, x**n), x) rule5890 = ReplacementRule(pattern5890, replacement5890) pattern5891 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))/cosh(x_**n_*WC('d', S(1)) + WC('c', S(0))))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons4, cons5, cons1495) def replacement5891(p, b, d, c, a, n, x): rubi.append(5891) return Int((a + b/cosh(c + d*x**n))**p, x) rule5891 = ReplacementRule(pattern5891, replacement5891) pattern5892 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))/sinh(x_**n_*WC('d', S(1)) + WC('c', S(0))))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons4, cons5, cons1495) def replacement5892(p, b, d, a, c, n, x): rubi.append(5892) return Int((a + b/sinh(c + d*x**n))**p, x) rule5892 = ReplacementRule(pattern5892, replacement5892) pattern5893 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))/cosh(u_**n_*WC('d', S(1)) + WC('c', S(0))))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons4, cons5, cons68, cons69) def replacement5893(p, u, b, d, c, a, n, x): rubi.append(5893) return Dist(S(1)/Coefficient(u, x, S(1)), Subst(Int((a + b/cosh(c + d*x**n))**p, x), x, u), x) rule5893 = ReplacementRule(pattern5893, replacement5893) pattern5894 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))/sinh(u_**n_*WC('d', S(1)) + WC('c', S(0))))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons4, cons5, cons68, cons69) def replacement5894(p, u, b, d, a, c, n, x): rubi.append(5894) return Dist(S(1)/Coefficient(u, x, S(1)), Subst(Int((a + b/sinh(c + d*x**n))**p, x), x, u), x) rule5894 = ReplacementRule(pattern5894, replacement5894) pattern5895 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))/cosh(u_))**WC('p', S(1)), x_), cons2, cons3, cons5, cons823, cons824) def replacement5895(p, u, b, a, x): rubi.append(5895) return Int((a + b/cosh(ExpandToSum(u, x)))**p, x) rule5895 = ReplacementRule(pattern5895, replacement5895) pattern5896 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))/sinh(u_))**WC('p', S(1)), x_), cons2, cons3, cons5, cons823, cons824) def replacement5896(p, u, b, a, x): rubi.append(5896) return Int((a + b/sinh(ExpandToSum(u, x)))**p, x) rule5896 = ReplacementRule(pattern5896, replacement5896) pattern5897 = Pattern(Integral(x_**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))/cosh(x_**n_*WC('d', S(1)) + WC('c', S(0))))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons21, cons4, cons5, cons1574, cons38) def replacement5897(p, m, b, d, c, a, n, x): rubi.append(5897) return Dist(S(1)/n, Subst(Int(x**(S(-1) + (m + S(1))/n)*(a + b/cosh(c + d*x))**p, x), x, x**n), x) rule5897 = ReplacementRule(pattern5897, replacement5897) pattern5898 = Pattern(Integral(x_**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))/sinh(x_**n_*WC('d', S(1)) + WC('c', S(0))))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons21, cons4, cons5, cons1574, cons38) def replacement5898(p, m, b, d, a, c, n, x): rubi.append(5898) return Dist(S(1)/n, Subst(Int(x**(S(-1) + (m + S(1))/n)*(a + b/sinh(c + d*x))**p, x), x, x**n), x) rule5898 = ReplacementRule(pattern5898, replacement5898) pattern5899 = Pattern(Integral(x_**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))/cosh(x_**n_*WC('d', S(1)) + WC('c', S(0))))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons21, cons4, cons5, cons1576) def replacement5899(p, m, b, d, c, a, n, x): rubi.append(5899) return Int(x**m*(a + b/cosh(c + d*x**n))**p, x) rule5899 = ReplacementRule(pattern5899, replacement5899) pattern5900 = Pattern(Integral(x_**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))/sinh(x_**n_*WC('d', S(1)) + WC('c', S(0))))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons21, cons4, cons5, cons1576) def replacement5900(p, m, b, d, a, c, n, x): rubi.append(5900) return Int(x**m*(a + b/sinh(c + d*x**n))**p, x) rule5900 = ReplacementRule(pattern5900, replacement5900) pattern5901 = Pattern(Integral((e_*x_)**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))/cosh(x_**n_*WC('d', S(1)) + WC('c', S(0))))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons21, cons4, cons5, cons1497) def replacement5901(p, m, b, d, c, a, n, x, e): rubi.append(5901) return Dist(e**IntPart(m)*x**(-FracPart(m))*(e*x)**FracPart(m), Int(x**m*(a + b/cosh(c + d*x**n))**p, x), x) rule5901 = ReplacementRule(pattern5901, replacement5901) pattern5902 = Pattern(Integral((e_*x_)**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))/sinh(x_**n_*WC('d', S(1)) + WC('c', S(0))))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons21, cons4, cons5, cons1497) def replacement5902(p, m, b, d, a, c, n, x, e): rubi.append(5902) return Dist(e**IntPart(m)*x**(-FracPart(m))*(e*x)**FracPart(m), Int(x**m*(a + b/sinh(c + d*x**n))**p, x), x) rule5902 = ReplacementRule(pattern5902, replacement5902) pattern5903 = Pattern(Integral((e_*x_)**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))/cosh(u_))**WC('p', S(1)), x_), cons2, cons3, cons48, cons21, cons5, cons823, cons824) def replacement5903(p, u, m, b, a, x, e): rubi.append(5903) return Int((e*x)**m*(a + b/cosh(ExpandToSum(u, x)))**p, x) rule5903 = ReplacementRule(pattern5903, replacement5903) pattern5904 = Pattern(Integral((e_*x_)**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))/sinh(u_))**WC('p', S(1)), x_), cons2, cons3, cons48, cons21, cons5, cons823, cons824) def replacement5904(p, u, m, b, a, x, e): rubi.append(5904) return Int((e*x)**m*(a + b/sinh(ExpandToSum(u, x)))**p, x) rule5904 = ReplacementRule(pattern5904, replacement5904) pattern5905 = Pattern(Integral(x_**WC('m', S(1))*(S(1)/cosh(x_**WC('n', S(1))*WC('b', S(1)) + WC('a', S(0))))**p_*sinh(x_**WC('n', S(1))*WC('b', S(1)) + WC('a', S(0))), x_), cons2, cons3, cons5, cons31, cons85, cons1577, cons1645) def replacement5905(p, m, b, a, n, x): rubi.append(5905) return Dist((m - n + S(1))/(b*n*(p + S(-1))), Int(x**(m - n)*(S(1)/cosh(a + b*x**n))**(p + S(-1)), x), x) - Simp(x**(m - n + S(1))*(S(1)/cosh(a + b*x**n))**(p + S(-1))/(b*n*(p + S(-1))), x) rule5905 = ReplacementRule(pattern5905, replacement5905) pattern5906 = Pattern(Integral(x_**WC('m', S(1))*(S(1)/sinh(x_**WC('n', S(1))*WC('b', S(1)) + WC('a', S(0))))**p_*cosh(x_**WC('n', S(1))*WC('b', S(1)) + WC('a', S(0))), x_), cons2, cons3, cons5, cons31, cons85, cons1577, cons1645) def replacement5906(p, m, b, a, n, x): rubi.append(5906) return Dist((m - n + S(1))/(b*n*(p + S(-1))), Int(x**(m - n)*(S(1)/sinh(a + b*x**n))**(p + S(-1)), x), x) - Simp(x**(m - n + S(1))*(S(1)/sinh(a + b*x**n))**(p + S(-1))/(b*n*(p + S(-1))), x) rule5906 = ReplacementRule(pattern5906, replacement5906) pattern5907 = Pattern(Integral((x_*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1))*sinh(x_*WC('b', S(1)) + WC('a', S(0)))**WC('n', S(1))*cosh(x_*WC('b', S(1)) + WC('a', S(0))), x_), cons2, cons3, cons7, cons27, cons4, cons62, cons584) def replacement5907(m, b, d, c, a, n, x): rubi.append(5907) return -Dist(d*m/(b*(n + S(1))), Int((c + d*x)**(m + S(-1))*sinh(a + b*x)**(n + S(1)), x), x) + Simp((c + d*x)**m*sinh(a + b*x)**(n + S(1))/(b*(n + S(1))), x) rule5907 = ReplacementRule(pattern5907, replacement5907) pattern5908 = Pattern(Integral((x_*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1))*sinh(x_*WC('b', S(1)) + WC('a', S(0)))*cosh(x_*WC('b', S(1)) + WC('a', S(0)))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons4, cons62, cons584) def replacement5908(m, b, d, c, a, n, x): rubi.append(5908) return -Dist(d*m/(b*(n + S(1))), Int((c + d*x)**(m + S(-1))*cosh(a + b*x)**(n + S(1)), x), x) + Simp((c + d*x)**m*cosh(a + b*x)**(n + S(1))/(b*(n + S(1))), x) rule5908 = ReplacementRule(pattern5908, replacement5908) pattern5909 = Pattern(Integral((x_*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1))*sinh(x_*WC('b', S(1)) + WC('a', S(0)))**WC('n', S(1))*cosh(x_*WC('b', S(1)) + WC('a', S(0)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons21, cons464) def replacement5909(p, m, b, d, c, a, n, x): rubi.append(5909) return Int(ExpandTrigReduce((c + d*x)**m, sinh(a + b*x)**n*cosh(a + b*x)**p, x), x) rule5909 = ReplacementRule(pattern5909, replacement5909) pattern5910 = Pattern(Integral((x_*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1))*sinh(x_*WC('b', S(1)) + WC('a', S(0)))**WC('n', S(1))*tanh(x_*WC('b', S(1)) + WC('a', S(0)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons21, cons464) def replacement5910(p, m, b, d, c, a, n, x): rubi.append(5910) return Int((c + d*x)**m*sinh(a + b*x)**n*tanh(a + b*x)**(p + S(-2)), x) - Int((c + d*x)**m*sinh(a + b*x)**(n + S(-2))*tanh(a + b*x)**p, x) rule5910 = ReplacementRule(pattern5910, replacement5910) pattern5911 = Pattern(Integral((x_*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1))*(S(1)/tanh(x_*WC('b', S(1)) + WC('a', S(0))))**WC('p', S(1))*cosh(x_*WC('b', S(1)) + WC('a', S(0)))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons21, cons464) def replacement5911(p, m, b, d, c, a, n, x): rubi.append(5911) return Int((c + d*x)**m*(S(1)/tanh(a + b*x))**p*cosh(a + b*x)**(n + S(-2)), x) + Int((c + d*x)**m*(S(1)/tanh(a + b*x))**(p + S(-2))*cosh(a + b*x)**n, x) rule5911 = ReplacementRule(pattern5911, replacement5911) pattern5912 = Pattern(Integral((x_*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1))*(S(1)/cosh(x_*WC('b', S(1)) + WC('a', S(0))))**WC('n', S(1))*tanh(x_*WC('b', S(1)) + WC('a', S(0)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons4, cons1683, cons31, cons168) def replacement5912(p, m, b, d, c, a, n, x): rubi.append(5912) return Dist(d*m/(b*n), Int((c + d*x)**(m + S(-1))*(S(1)/cosh(a + b*x))**n, x), x) - Simp((c + d*x)**m*(S(1)/cosh(a + b*x))**n/(b*n), x) rule5912 = ReplacementRule(pattern5912, replacement5912) pattern5913 = Pattern(Integral((x_*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1))*(S(1)/sinh(x_*WC('b', S(1)) + WC('a', S(0))))**WC('n', S(1))*(S(1)/tanh(x_*WC('b', S(1)) + WC('a', S(0))))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons4, cons1683, cons31, cons168) def replacement5913(p, m, b, d, c, a, n, x): rubi.append(5913) return Dist(d*m/(b*n), Int((c + d*x)**(m + S(-1))*(S(1)/sinh(a + b*x))**n, x), x) - Simp((c + d*x)**m*(S(1)/sinh(a + b*x))**n/(b*n), x) rule5913 = ReplacementRule(pattern5913, replacement5913) pattern5914 = Pattern(Integral((x_*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1))*tanh(x_*WC('b', S(1)) + WC('a', S(0)))**WC('n', S(1))/cosh(x_*WC('b', S(1)) + WC('a', S(0)))**S(2), x_), cons2, cons3, cons7, cons27, cons4, cons62, cons584) def replacement5914(m, b, d, c, a, n, x): rubi.append(5914) return -Dist(d*m/(b*(n + S(1))), Int((c + d*x)**(m + S(-1))*tanh(a + b*x)**(n + S(1)), x), x) + Simp((c + d*x)**m*tanh(a + b*x)**(n + S(1))/(b*(n + S(1))), x) rule5914 = ReplacementRule(pattern5914, replacement5914) pattern5915 = Pattern(Integral((x_*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1))*(S(1)/tanh(x_*WC('b', S(1)) + WC('a', S(0))))**WC('n', S(1))/sinh(x_*WC('b', S(1)) + WC('a', S(0)))**S(2), x_), cons2, cons3, cons7, cons27, cons4, cons62, cons584) def replacement5915(m, b, d, c, a, n, x): rubi.append(5915) return Dist(d*m/(b*(n + S(1))), Int((c + d*x)**(m + S(-1))*(S(1)/tanh(a + b*x))**(n + S(1)), x), x) - Simp((c + d*x)**m*(S(1)/tanh(a + b*x))**(n + S(1))/(b*(n + S(1))), x) rule5915 = ReplacementRule(pattern5915, replacement5915) pattern5916 = Pattern(Integral((x_*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1))*tanh(x_*WC('b', S(1)) + WC('a', S(0)))**p_/cosh(x_*WC('b', S(1)) + WC('a', S(0))), x_), cons2, cons3, cons7, cons27, cons21, cons1408) def replacement5916(p, m, b, d, c, a, x): rubi.append(5916) return -Int((c + d*x)**m*tanh(a + b*x)**(p + S(-2))/cosh(a + b*x)**S(3), x) + Int((c + d*x)**m*tanh(a + b*x)**(p + S(-2))/cosh(a + b*x), x) rule5916 = ReplacementRule(pattern5916, replacement5916) pattern5917 = Pattern(Integral((x_*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1))*(S(1)/cosh(x_*WC('b', S(1)) + WC('a', S(0))))**WC('n', S(1))*tanh(x_*WC('b', S(1)) + WC('a', S(0)))**p_, x_), cons2, cons3, cons7, cons27, cons21, cons4, cons1408) def replacement5917(p, m, b, d, c, a, n, x): rubi.append(5917) return Int((c + d*x)**m*(S(1)/cosh(a + b*x))**n*tanh(a + b*x)**(p + S(-2)), x) - Int((c + d*x)**m*(S(1)/cosh(a + b*x))**(n + S(2))*tanh(a + b*x)**(p + S(-2)), x) rule5917 = ReplacementRule(pattern5917, replacement5917) pattern5918 = Pattern(Integral((x_*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1))*(S(1)/tanh(x_*WC('b', S(1)) + WC('a', S(0))))**p_/sinh(x_*WC('b', S(1)) + WC('a', S(0))), x_), cons2, cons3, cons7, cons27, cons21, cons1408) def replacement5918(p, m, b, d, c, a, x): rubi.append(5918) return Int((c + d*x)**m*(S(1)/tanh(a + b*x))**(p + S(-2))/sinh(a + b*x)**S(3), x) + Int((c + d*x)**m*(S(1)/tanh(a + b*x))**(p + S(-2))/sinh(a + b*x), x) rule5918 = ReplacementRule(pattern5918, replacement5918) pattern5919 = Pattern(Integral((x_*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1))*(S(1)/sinh(x_*WC('b', S(1)) + WC('a', S(0))))**WC('n', S(1))*(S(1)/tanh(x_*WC('b', S(1)) + WC('a', S(0))))**p_, x_), cons2, cons3, cons7, cons27, cons21, cons4, cons1408) def replacement5919(p, m, b, d, c, a, n, x): rubi.append(5919) return Int((c + d*x)**m*(S(1)/sinh(a + b*x))**n*(S(1)/tanh(a + b*x))**(p + S(-2)), x) + Int((c + d*x)**m*(S(1)/sinh(a + b*x))**(n + S(2))*(S(1)/tanh(a + b*x))**(p + S(-2)), x) rule5919 = ReplacementRule(pattern5919, replacement5919) def With5920(p, m, b, d, c, a, n, x): u = IntHide((S(1)/cosh(a + b*x))**n*tanh(a + b*x)**p, x) rubi.append(5920) return -Dist(d*m, Int(u*(c + d*x)**(m + S(-1)), x), x) + Dist((c + d*x)**m, u, x) pattern5920 = Pattern(Integral((x_*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1))*(S(1)/cosh(x_*WC('b', S(1)) + WC('a', S(0))))**WC('n', S(1))*tanh(x_*WC('b', S(1)) + WC('a', S(0)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons4, cons5, cons62, cons1684) rule5920 = ReplacementRule(pattern5920, With5920) def With5921(p, m, b, d, c, a, n, x): u = IntHide((S(1)/sinh(a + b*x))**n*(S(1)/tanh(a + b*x))**p, x) rubi.append(5921) return -Dist(d*m, Int(u*(c + d*x)**(m + S(-1)), x), x) + Dist((c + d*x)**m, u, x) pattern5921 = Pattern(Integral((x_*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1))*(S(1)/sinh(x_*WC('b', S(1)) + WC('a', S(0))))**WC('n', S(1))*(S(1)/tanh(x_*WC('b', S(1)) + WC('a', S(0))))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons4, cons5, cons62, cons1684) rule5921 = ReplacementRule(pattern5921, With5921) pattern5922 = Pattern(Integral((x_*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1))*(S(1)/sinh(x_*WC('b', S(1)) + WC('a', S(0))))**WC('n', S(1))*(S(1)/cosh(x_*WC('b', S(1)) + WC('a', S(0))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons31, cons85) def replacement5922(m, b, d, c, a, n, x): rubi.append(5922) return Dist(S(2)**n, Int((c + d*x)**m*(S(1)/sinh(S(2)*a + S(2)*b*x))**n, x), x) rule5922 = ReplacementRule(pattern5922, replacement5922) def With5923(p, m, b, d, c, a, n, x): u = IntHide((S(1)/sinh(a + b*x))**n*(S(1)/cosh(a + b*x))**p, x) rubi.append(5923) return -Dist(d*m, Int(u*(c + d*x)**(m + S(-1)), x), x) + Dist((c + d*x)**m, u, x) pattern5923 = Pattern(Integral((x_*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1))*(S(1)/sinh(x_*WC('b', S(1)) + WC('a', S(0))))**WC('n', S(1))*(S(1)/cosh(x_*WC('b', S(1)) + WC('a', S(0))))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons376, cons31, cons168, cons1685) rule5923 = ReplacementRule(pattern5923, With5923) pattern5924 = Pattern(Integral(F_**v_*G_**w_*u_**WC('m', S(1)), x_), cons21, cons4, cons5, cons1860, cons1861, cons1688, cons812, cons813) def replacement5924(v, w, p, u, m, G, n, x, F): rubi.append(5924) return Int(ExpandToSum(u, x)**m*F(ExpandToSum(v, x))**n*G(ExpandToSum(v, x))**p, x) rule5924 = ReplacementRule(pattern5924, replacement5924) pattern5925 = Pattern(Integral((a_ + WC('b', S(1))*sinh(x_*WC('d', S(1)) + WC('c', S(0))))**WC('n', S(1))*(x_*WC('f', S(1)) + WC('e', S(0)))**WC('m', S(1))*cosh(x_*WC('d', S(1)) + WC('c', S(0))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons4, cons62, cons584) def replacement5925(m, f, b, d, c, n, a, x, e): rubi.append(5925) return -Dist(f*m/(b*d*(n + S(1))), Int((a + b*sinh(c + d*x))**(n + S(1))*(e + f*x)**(m + S(-1)), x), x) + Simp((a + b*sinh(c + d*x))**(n + S(1))*(e + f*x)**m/(b*d*(n + S(1))), x) rule5925 = ReplacementRule(pattern5925, replacement5925) pattern5926 = Pattern(Integral((a_ + WC('b', S(1))*cosh(x_*WC('d', S(1)) + WC('c', S(0))))**WC('n', S(1))*(x_*WC('f', S(1)) + WC('e', S(0)))**WC('m', S(1))*sinh(x_*WC('d', S(1)) + WC('c', S(0))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons4, cons62, cons584) def replacement5926(m, f, b, d, c, n, a, x, e): rubi.append(5926) return -Dist(f*m/(b*d*(n + S(1))), Int((a + b*cosh(c + d*x))**(n + S(1))*(e + f*x)**(m + S(-1)), x), x) + Simp((a + b*cosh(c + d*x))**(n + S(1))*(e + f*x)**m/(b*d*(n + S(1))), x) rule5926 = ReplacementRule(pattern5926, replacement5926) pattern5927 = Pattern(Integral((a_ + WC('b', S(1))*tanh(x_*WC('d', S(1)) + WC('c', S(0))))**WC('n', S(1))*(x_*WC('f', S(1)) + WC('e', S(0)))**WC('m', S(1))/cosh(x_*WC('d', S(1)) + WC('c', S(0)))**S(2), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons4, cons62, cons584) def replacement5927(m, f, b, d, c, n, a, x, e): rubi.append(5927) return -Dist(f*m/(b*d*(n + S(1))), Int((a + b*tanh(c + d*x))**(n + S(1))*(e + f*x)**(m + S(-1)), x), x) + Simp((a + b*tanh(c + d*x))**(n + S(1))*(e + f*x)**m/(b*d*(n + S(1))), x) rule5927 = ReplacementRule(pattern5927, replacement5927) pattern5928 = Pattern(Integral((a_ + WC('b', S(1))/tanh(x_*WC('d', S(1)) + WC('c', S(0))))**WC('n', S(1))*(x_*WC('f', S(1)) + WC('e', S(0)))**WC('m', S(1))/sinh(x_*WC('d', S(1)) + WC('c', S(0)))**S(2), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons4, cons62, cons584) def replacement5928(m, f, b, d, c, n, a, x, e): rubi.append(5928) return Dist(f*m/(b*d*(n + S(1))), Int((a + b/tanh(c + d*x))**(n + S(1))*(e + f*x)**(m + S(-1)), x), x) - Simp((a + b/tanh(c + d*x))**(n + S(1))*(e + f*x)**m/(b*d*(n + S(1))), x) rule5928 = ReplacementRule(pattern5928, replacement5928) pattern5929 = Pattern(Integral((a_ + WC('b', S(1))/cosh(x_*WC('d', S(1)) + WC('c', S(0))))**WC('n', S(1))*(x_*WC('f', S(1)) + WC('e', S(0)))**WC('m', S(1))*tanh(x_*WC('d', S(1)) + WC('c', S(0)))/cosh(x_*WC('d', S(1)) + WC('c', S(0))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons4, cons62, cons584) def replacement5929(m, f, b, d, c, n, a, x, e): rubi.append(5929) return Dist(f*m/(b*d*(n + S(1))), Int((a + b/cosh(c + d*x))**(n + S(1))*(e + f*x)**(m + S(-1)), x), x) - Simp((a + b/cosh(c + d*x))**(n + S(1))*(e + f*x)**m/(b*d*(n + S(1))), x) rule5929 = ReplacementRule(pattern5929, replacement5929) pattern5930 = Pattern(Integral((a_ + WC('b', S(1))/sinh(x_*WC('d', S(1)) + WC('c', S(0))))**WC('n', S(1))*(x_*WC('f', S(1)) + WC('e', S(0)))**WC('m', S(1))/(sinh(x_*WC('d', S(1)) + WC('c', S(0)))*tanh(x_*WC('d', S(1)) + WC('c', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons4, cons62, cons584) def replacement5930(m, f, b, d, c, n, a, x, e): rubi.append(5930) return Dist(f*m/(b*d*(n + S(1))), Int((a + b/sinh(c + d*x))**(n + S(1))*(e + f*x)**(m + S(-1)), x), x) - Simp((a + b/sinh(c + d*x))**(n + S(1))*(e + f*x)**m/(b*d*(n + S(1))), x) rule5930 = ReplacementRule(pattern5930, replacement5930) pattern5931 = Pattern(Integral((x_*WC('f', S(1)) + WC('e', S(0)))**WC('m', S(1))*sinh(x_*WC('b', S(1)) + WC('a', S(0)))**WC('p', S(1))*sinh(x_*WC('d', S(1)) + WC('c', S(0)))**WC('q', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons555, cons17) def replacement5931(p, m, f, b, d, a, c, x, q, e): rubi.append(5931) return Int(ExpandTrigReduce((e + f*x)**m, sinh(a + b*x)**p*sinh(c + d*x)**q, x), x) rule5931 = ReplacementRule(pattern5931, replacement5931) pattern5932 = Pattern(Integral((x_*WC('f', S(1)) + WC('e', S(0)))**WC('m', S(1))*cosh(x_*WC('b', S(1)) + WC('a', S(0)))**WC('p', S(1))*cosh(x_*WC('d', S(1)) + WC('c', S(0)))**WC('q', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons555, cons17) def replacement5932(p, m, f, b, d, c, a, x, q, e): rubi.append(5932) return Int(ExpandTrigReduce((e + f*x)**m, cosh(a + b*x)**p*cosh(c + d*x)**q, x), x) rule5932 = ReplacementRule(pattern5932, replacement5932) pattern5933 = Pattern(Integral((x_*WC('f', S(1)) + WC('e', S(0)))**WC('m', S(1))*sinh(x_*WC('b', S(1)) + WC('a', S(0)))**WC('p', S(1))*cosh(x_*WC('d', S(1)) + WC('c', S(0)))**WC('q', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons555) def replacement5933(p, m, f, b, d, c, a, x, q, e): rubi.append(5933) return Int(ExpandTrigReduce((e + f*x)**m, sinh(a + b*x)**p*cosh(c + d*x)**q, x), x) rule5933 = ReplacementRule(pattern5933, replacement5933) pattern5934 = Pattern(Integral(F_**(x_*WC('b', S(1)) + WC('a', S(0)))*G_**(x_*WC('d', S(1)) + WC('c', S(0)))*(x_*WC('f', S(1)) + WC('e', S(0)))**WC('m', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons1862, cons1863, cons555, cons25, cons1691) def replacement5934(p, m, f, b, G, d, a, c, x, q, e, F): rubi.append(5934) return Int(ExpandTrigExpand((e + f*x)**m*G(c + d*x)**q, F, c + d*x, p, b/d, x), x) rule5934 = ReplacementRule(pattern5934, replacement5934) pattern5935 = Pattern(Integral(F_**((x_*WC('b', S(1)) + WC('a', S(0)))*WC('c', S(1)))*sinh(x_*WC('e', S(1)) + WC('d', S(0))), x_), cons1099, cons2, cons3, cons7, cons27, cons48, cons1864) def replacement5935(b, d, c, a, x, F, e): rubi.append(5935) return Simp(F**(c*(a + b*x))*e*cosh(d + e*x)/(-b**S(2)*c**S(2)*log(F)**S(2) + e**S(2)), x) - Simp(F**(c*(a + b*x))*b*c*log(F)*sinh(d + e*x)/(-b**S(2)*c**S(2)*log(F)**S(2) + e**S(2)), x) rule5935 = ReplacementRule(pattern5935, replacement5935) pattern5936 = Pattern(Integral(F_**((x_*WC('b', S(1)) + WC('a', S(0)))*WC('c', S(1)))*cosh(x_*WC('e', S(1)) + WC('d', S(0))), x_), cons1099, cons2, cons3, cons7, cons27, cons48, cons1864) def replacement5936(b, d, c, a, x, F, e): rubi.append(5936) return Simp(F**(c*(a + b*x))*e*sinh(d + e*x)/(-b**S(2)*c**S(2)*log(F)**S(2) + e**S(2)), x) - Simp(F**(c*(a + b*x))*b*c*log(F)*cosh(d + e*x)/(-b**S(2)*c**S(2)*log(F)**S(2) + e**S(2)), x) rule5936 = ReplacementRule(pattern5936, replacement5936) pattern5937 = Pattern(Integral(F_**((x_*WC('b', S(1)) + WC('a', S(0)))*WC('c', S(1)))*sinh(x_*WC('e', S(1)) + WC('d', S(0)))**n_, x_), cons1099, cons2, cons3, cons7, cons27, cons48, cons1865, cons87, cons165) def replacement5937(b, d, c, a, n, x, F, e): rubi.append(5937) return -Dist(e**S(2)*n*(n + S(-1))/(-b**S(2)*c**S(2)*log(F)**S(2) + e**S(2)*n**S(2)), Int(F**(c*(a + b*x))*sinh(d + e*x)**(n + S(-2)), x), x) - Simp(F**(c*(a + b*x))*b*c*log(F)*sinh(d + e*x)**n/(-b**S(2)*c**S(2)*log(F)**S(2) + e**S(2)*n**S(2)), x) + Simp(F**(c*(a + b*x))*e*n*sinh(d + e*x)**(n + S(-1))*cosh(d + e*x)/(-b**S(2)*c**S(2)*log(F)**S(2) + e**S(2)*n**S(2)), x) rule5937 = ReplacementRule(pattern5937, replacement5937) pattern5938 = Pattern(Integral(F_**((x_*WC('b', S(1)) + WC('a', S(0)))*WC('c', S(1)))*cosh(x_*WC('e', S(1)) + WC('d', S(0)))**n_, x_), cons1099, cons2, cons3, cons7, cons27, cons48, cons1865, cons87, cons165) def replacement5938(b, d, c, a, n, x, F, e): rubi.append(5938) return Dist(e**S(2)*n*(n + S(-1))/(-b**S(2)*c**S(2)*log(F)**S(2) + e**S(2)*n**S(2)), Int(F**(c*(a + b*x))*cosh(d + e*x)**(n + S(-2)), x), x) - Simp(F**(c*(a + b*x))*b*c*log(F)*cosh(d + e*x)**n/(-b**S(2)*c**S(2)*log(F)**S(2) + e**S(2)*n**S(2)), x) + Simp(F**(c*(a + b*x))*e*n*sinh(d + e*x)*cosh(d + e*x)**(n + S(-1))/(-b**S(2)*c**S(2)*log(F)**S(2) + e**S(2)*n**S(2)), x) rule5938 = ReplacementRule(pattern5938, replacement5938) pattern5939 = Pattern(Integral(F_**((x_*WC('b', S(1)) + WC('a', S(0)))*WC('c', S(1)))*sinh(x_*WC('e', S(1)) + WC('d', S(0)))**n_, x_), cons1099, cons2, cons3, cons7, cons27, cons48, cons4, cons1866, cons584, cons1395) def replacement5939(b, d, c, a, n, x, F, e): rubi.append(5939) return Simp(F**(c*(a + b*x))*sinh(d + e*x)**(n + S(1))*cosh(d + e*x)/(e*(n + S(1))), x) - Simp(F**(c*(a + b*x))*b*c*log(F)*sinh(d + e*x)**(n + S(2))/(e**S(2)*(n + S(1))*(n + S(2))), x) rule5939 = ReplacementRule(pattern5939, replacement5939) pattern5940 = Pattern(Integral(F_**((x_*WC('b', S(1)) + WC('a', S(0)))*WC('c', S(1)))*cosh(x_*WC('e', S(1)) + WC('d', S(0)))**n_, x_), cons1099, cons2, cons3, cons7, cons27, cons48, cons4, cons1866, cons584, cons1395) def replacement5940(b, d, c, a, n, x, F, e): rubi.append(5940) return -Simp(F**(c*(a + b*x))*sinh(d + e*x)*cosh(d + e*x)**(n + S(1))/(e*(n + S(1))), x) + Simp(F**(c*(a + b*x))*b*c*log(F)*cosh(d + e*x)**(n + S(2))/(e**S(2)*(n + S(1))*(n + S(2))), x) rule5940 = ReplacementRule(pattern5940, replacement5940) pattern5941 = Pattern(Integral(F_**((x_*WC('b', S(1)) + WC('a', S(0)))*WC('c', S(1)))*sinh(x_*WC('e', S(1)) + WC('d', S(0)))**n_, x_), cons1099, cons2, cons3, cons7, cons27, cons48, cons1867, cons87, cons89, cons1442) def replacement5941(b, d, c, a, n, x, F, e): rubi.append(5941) return -Dist((-b**S(2)*c**S(2)*log(F)**S(2) + e**S(2)*(n + S(2))**S(2))/(e**S(2)*(n + S(1))*(n + S(2))), Int(F**(c*(a + b*x))*sinh(d + e*x)**(n + S(2)), x), x) + Simp(F**(c*(a + b*x))*sinh(d + e*x)**(n + S(1))*cosh(d + e*x)/(e*(n + S(1))), x) - Simp(F**(c*(a + b*x))*b*c*log(F)*sinh(d + e*x)**(n + S(2))/(e**S(2)*(n + S(1))*(n + S(2))), x) rule5941 = ReplacementRule(pattern5941, replacement5941) pattern5942 = Pattern(Integral(F_**((x_*WC('b', S(1)) + WC('a', S(0)))*WC('c', S(1)))*cosh(x_*WC('e', S(1)) + WC('d', S(0)))**n_, x_), cons1099, cons2, cons3, cons7, cons27, cons48, cons1867, cons87, cons89, cons1442) def replacement5942(b, d, c, a, n, x, F, e): rubi.append(5942) return Dist((-b**S(2)*c**S(2)*log(F)**S(2) + e**S(2)*(n + S(2))**S(2))/(e**S(2)*(n + S(1))*(n + S(2))), Int(F**(c*(a + b*x))*cosh(d + e*x)**(n + S(2)), x), x) - Simp(F**(c*(a + b*x))*sinh(d + e*x)*cosh(d + e*x)**(n + S(1))/(e*(n + S(1))), x) + Simp(F**(c*(a + b*x))*b*c*log(F)*cosh(d + e*x)**(n + S(2))/(e**S(2)*(n + S(1))*(n + S(2))), x) rule5942 = ReplacementRule(pattern5942, replacement5942) pattern5943 = Pattern(Integral(F_**((x_*WC('b', S(1)) + WC('a', S(0)))*WC('c', S(1)))*sinh(x_*WC('e', S(1)) + WC('d', S(0)))**n_, x_), cons1099, cons2, cons3, cons7, cons27, cons48, cons4, cons23) def replacement5943(b, d, c, a, n, x, F, e): rubi.append(5943) return Dist((exp(S(2)*d + S(2)*e*x) + S(-1))**(-n)*exp(n*(d + e*x))*sinh(d + e*x)**n, Int(F**(c*(a + b*x))*(exp(S(2)*d + S(2)*e*x) + S(-1))**n*exp(-n*(d + e*x)), x), x) rule5943 = ReplacementRule(pattern5943, replacement5943) pattern5944 = Pattern(Integral(F_**((x_*WC('b', S(1)) + WC('a', S(0)))*WC('c', S(1)))*cosh(x_*WC('e', S(1)) + WC('d', S(0)))**n_, x_), cons1099, cons2, cons3, cons7, cons27, cons48, cons4, cons23) def replacement5944(b, d, c, a, n, x, F, e): rubi.append(5944) return Dist((exp(S(2)*d + S(2)*e*x) + S(1))**(-n)*exp(n*(d + e*x))*cosh(d + e*x)**n, Int(F**(c*(a + b*x))*(exp(S(2)*d + S(2)*e*x) + S(1))**n*exp(-n*(d + e*x)), x), x) rule5944 = ReplacementRule(pattern5944, replacement5944) pattern5945 = Pattern(Integral(F_**((x_*WC('b', S(1)) + WC('a', S(0)))*WC('c', S(1)))*tanh(x_*WC('e', S(1)) + WC('d', S(0)))**WC('n', S(1)), x_), cons1099, cons2, cons3, cons7, cons27, cons48, cons85) def replacement5945(b, d, c, a, n, x, F, e): rubi.append(5945) return Int(ExpandIntegrand(F**(c*(a + b*x))*(exp(S(2)*d + S(2)*e*x) + S(-1))**n*(exp(S(2)*d + S(2)*e*x) + S(1))**(-n), x), x) rule5945 = ReplacementRule(pattern5945, replacement5945) pattern5946 = Pattern(Integral(F_**((x_*WC('b', S(1)) + WC('a', S(0)))*WC('c', S(1)))*(S(1)/tanh(x_*WC('e', S(1)) + WC('d', S(0))))**WC('n', S(1)), x_), cons1099, cons2, cons3, cons7, cons27, cons48, cons85) def replacement5946(b, d, c, n, a, x, F, e): rubi.append(5946) return Int(ExpandIntegrand(F**(c*(a + b*x))*(exp(S(2)*d + S(2)*e*x) + S(-1))**(-n)*(exp(S(2)*d + S(2)*e*x) + S(1))**n, x), x) rule5946 = ReplacementRule(pattern5946, replacement5946) pattern5947 = Pattern(Integral(F_**((x_*WC('b', S(1)) + WC('a', S(0)))*WC('c', S(1)))*(S(1)/cosh(x_*WC('e', S(1)) + WC('d', S(0))))**n_, x_), cons1099, cons2, cons3, cons7, cons27, cons48, cons1693, cons87, cons89) def replacement5947(b, d, c, a, n, x, F, e): rubi.append(5947) return Dist(e**S(2)*n*(n + S(1))/(-b**S(2)*c**S(2)*log(F)**S(2) + e**S(2)*n**S(2)), Int(F**(c*(a + b*x))*(S(1)/cosh(d + e*x))**(n + S(2)), x), x) - Simp(F**(c*(a + b*x))*b*c*(S(1)/cosh(d + e*x))**n*log(F)/(-b**S(2)*c**S(2)*log(F)**S(2) + e**S(2)*n**S(2)), x) - Simp(F**(c*(a + b*x))*e*n*(S(1)/cosh(d + e*x))**(n + S(1))*sinh(d + e*x)/(-b**S(2)*c**S(2)*log(F)**S(2) + e**S(2)*n**S(2)), x) rule5947 = ReplacementRule(pattern5947, replacement5947) pattern5948 = Pattern(Integral(F_**((x_*WC('b', S(1)) + WC('a', S(0)))*WC('c', S(1)))*(S(1)/sinh(x_*WC('e', S(1)) + WC('d', S(0))))**n_, x_), cons1099, cons2, cons3, cons7, cons27, cons48, cons1693, cons87, cons89) def replacement5948(b, d, c, a, n, x, F, e): rubi.append(5948) return -Dist(e**S(2)*n*(n + S(1))/(-b**S(2)*c**S(2)*log(F)**S(2) + e**S(2)*n**S(2)), Int(F**(c*(a + b*x))*(S(1)/sinh(d + e*x))**(n + S(2)), x), x) - Simp(F**(c*(a + b*x))*b*c*(S(1)/sinh(d + e*x))**n*log(F)/(-b**S(2)*c**S(2)*log(F)**S(2) + e**S(2)*n**S(2)), x) - Simp(F**(c*(a + b*x))*e*n*(S(1)/sinh(d + e*x))**(n + S(1))*cosh(d + e*x)/(-b**S(2)*c**S(2)*log(F)**S(2) + e**S(2)*n**S(2)), x) rule5948 = ReplacementRule(pattern5948, replacement5948) pattern5949 = Pattern(Integral(F_**((x_*WC('b', S(1)) + WC('a', S(0)))*WC('c', S(1)))*(S(1)/cosh(x_*WC('e', S(1)) + WC('d', S(0))))**n_, x_), cons1099, cons2, cons3, cons7, cons27, cons48, cons4, cons1868, cons1502, cons963) def replacement5949(b, d, c, a, n, x, F, e): rubi.append(5949) return Simp(F**(c*(a + b*x))*(S(1)/cosh(d + e*x))**(n + S(-1))*sinh(d + e*x)/(e*(n + S(-1))), x) + Simp(F**(c*(a + b*x))*b*c*(S(1)/cosh(d + e*x))**(n + S(-2))*log(F)/(e**S(2)*(n + S(-2))*(n + S(-1))), x) rule5949 = ReplacementRule(pattern5949, replacement5949) pattern5950 = Pattern(Integral(F_**((x_*WC('b', S(1)) + WC('a', S(0)))*WC('c', S(1)))*(S(1)/sinh(x_*WC('e', S(1)) + WC('d', S(0))))**n_, x_), cons1099, cons2, cons3, cons7, cons27, cons48, cons4, cons1868, cons1502, cons963) def replacement5950(b, d, c, a, n, x, F, e): rubi.append(5950) return -Simp(F**(c*(a + b*x))*(S(1)/sinh(d + e*x))**(n + S(-1))*cosh(d + e*x)/(e*(n + S(-1))), x) - Simp(F**(c*(a + b*x))*b*c*(S(1)/sinh(d + e*x))**(n + S(-2))*log(F)/(e**S(2)*(n + S(-2))*(n + S(-1))), x) rule5950 = ReplacementRule(pattern5950, replacement5950) pattern5951 = Pattern(Integral(F_**((x_*WC('b', S(1)) + WC('a', S(0)))*WC('c', S(1)))*(S(1)/cosh(x_*WC('e', S(1)) + WC('d', S(0))))**n_, x_), cons1099, cons2, cons3, cons7, cons27, cons48, cons1869, cons87, cons165, cons1644) def replacement5951(b, d, c, a, n, x, F, e): rubi.append(5951) return Dist((-b**S(2)*c**S(2)*log(F)**S(2) + e**S(2)*(n + S(-2))**S(2))/(e**S(2)*(n + S(-2))*(n + S(-1))), Int(F**(c*(a + b*x))*(S(1)/cosh(d + e*x))**(n + S(-2)), x), x) + Simp(F**(c*(a + b*x))*(S(1)/cosh(d + e*x))**(n + S(-1))*sinh(d + e*x)/(e*(n + S(-1))), x) + Simp(F**(c*(a + b*x))*b*c*(S(1)/cosh(d + e*x))**(n + S(-2))*log(F)/(e**S(2)*(n + S(-2))*(n + S(-1))), x) rule5951 = ReplacementRule(pattern5951, replacement5951) pattern5952 = Pattern(Integral(F_**((x_*WC('b', S(1)) + WC('a', S(0)))*WC('c', S(1)))*(S(1)/sinh(x_*WC('e', S(1)) + WC('d', S(0))))**n_, x_), cons1099, cons2, cons3, cons7, cons27, cons48, cons1869, cons87, cons165, cons1644) def replacement5952(b, d, c, a, n, x, F, e): rubi.append(5952) return -Dist((-b**S(2)*c**S(2)*log(F)**S(2) + e**S(2)*(n + S(-2))**S(2))/(e**S(2)*(n + S(-2))*(n + S(-1))), Int(F**(c*(a + b*x))*(S(1)/sinh(d + e*x))**(n + S(-2)), x), x) - Simp(F**(c*(a + b*x))*(S(1)/sinh(d + e*x))**(n + S(-1))*cosh(d + e*x)/(e*(n + S(-1))), x) - Simp(F**(c*(a + b*x))*b*c*(S(1)/sinh(d + e*x))**(n + S(-2))*log(F)/(e**S(2)*(n + S(-2))*(n + S(-1))), x) rule5952 = ReplacementRule(pattern5952, replacement5952) pattern5953 = Pattern(Integral(F_**((x_*WC('b', S(1)) + WC('a', S(0)))*WC('c', S(1)))*(S(1)/cosh(x_*WC('e', S(1)) + WC('d', S(0))))**WC('n', S(1)), x_), cons1099, cons2, cons3, cons7, cons27, cons48, cons85) def replacement5953(b, d, c, a, n, x, F, e): rubi.append(5953) return Simp(S(2)**n*F**(c*(a + b*x))*Hypergeometric2F1(n, b*c*log(F)/(S(2)*e) + n/S(2), b*c*log(F)/(S(2)*e) + n/S(2) + S(1), -exp(S(2)*d + S(2)*e*x))*exp(n*(d + e*x))/(b*c*log(F) + e*n), x) rule5953 = ReplacementRule(pattern5953, replacement5953) pattern5954 = Pattern(Integral(F_**((x_*WC('b', S(1)) + WC('a', S(0)))*WC('c', S(1)))*(S(1)/sinh(x_*WC('e', S(1)) + WC('d', S(0))))**WC('n', S(1)), x_), cons1099, cons2, cons3, cons7, cons27, cons48, cons85) def replacement5954(b, d, c, n, a, x, F, e): rubi.append(5954) return Simp((S(-2))**n*F**(c*(a + b*x))*Hypergeometric2F1(n, b*c*log(F)/(S(2)*e) + n/S(2), b*c*log(F)/(S(2)*e) + n/S(2) + S(1), exp(S(2)*d + S(2)*e*x))*exp(n*(d + e*x))/(b*c*log(F) + e*n), x) rule5954 = ReplacementRule(pattern5954, replacement5954) pattern5955 = Pattern(Integral(F_**((x_*WC('b', S(1)) + WC('a', S(0)))*WC('c', S(1)))*(S(1)/cosh(x_*WC('e', S(1)) + WC('d', S(0))))**WC('n', S(1)), x_), cons1099, cons2, cons3, cons7, cons27, cons48, cons23) def replacement5955(b, d, c, a, n, x, F, e): rubi.append(5955) return Dist((exp(S(2)*d + S(2)*e*x) + S(1))**n*(S(1)/cosh(d + e*x))**n*exp(-n*(d + e*x)), Int(SimplifyIntegrand(F**(c*(a + b*x))*(exp(S(2)*d + S(2)*e*x) + S(1))**(-n)*exp(n*(d + e*x)), x), x), x) rule5955 = ReplacementRule(pattern5955, replacement5955) pattern5956 = Pattern(Integral(F_**((x_*WC('b', S(1)) + WC('a', S(0)))*WC('c', S(1)))*(S(1)/sinh(x_*WC('e', S(1)) + WC('d', S(0))))**WC('n', S(1)), x_), cons1099, cons2, cons3, cons7, cons27, cons48, cons23) def replacement5956(b, d, c, n, a, x, F, e): rubi.append(5956) return Dist((-exp(-S(2)*d - S(2)*e*x) + S(1))**n*(S(1)/sinh(d + e*x))**n*exp(n*(d + e*x)), Int(SimplifyIntegrand(F**(c*(a + b*x))*(-exp(-S(2)*d - S(2)*e*x) + S(1))**(-n)*exp(-n*(d + e*x)), x), x), x) rule5956 = ReplacementRule(pattern5956, replacement5956) pattern5957 = Pattern(Integral(F_**((x_*WC('b', S(1)) + WC('a', S(0)))*WC('c', S(1)))*(f_ + WC('g', S(1))*sinh(x_*WC('e', S(1)) + WC('d', S(0))))**WC('n', S(1)), x_), cons1099, cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons1870, cons196) def replacement5957(g, b, f, d, c, a, n, x, F, e): rubi.append(5957) return Dist(S(2)**n*f**n, Int(F**(c*(a + b*x))*cosh(-Pi*f/(S(4)*g) + d/S(2) + e*x/S(2))**(S(2)*n), x), x) rule5957 = ReplacementRule(pattern5957, replacement5957) pattern5958 = Pattern(Integral(F_**((x_*WC('b', S(1)) + WC('a', S(0)))*WC('c', S(1)))*(f_ + WC('g', S(1))*cosh(x_*WC('e', S(1)) + WC('d', S(0))))**WC('n', S(1)), x_), cons1099, cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons1700, cons196) def replacement5958(g, b, f, d, c, n, a, x, F, e): rubi.append(5958) return Dist(S(2)**n*g**n, Int(F**(c*(a + b*x))*cosh(d/S(2) + e*x/S(2))**(S(2)*n), x), x) rule5958 = ReplacementRule(pattern5958, replacement5958) pattern5959 = Pattern(Integral(F_**((x_*WC('b', S(1)) + WC('a', S(0)))*WC('c', S(1)))*(f_ + WC('g', S(1))*cosh(x_*WC('e', S(1)) + WC('d', S(0))))**WC('n', S(1)), x_), cons1099, cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons1011, cons196) def replacement5959(g, b, f, d, c, n, a, x, F, e): rubi.append(5959) return Dist(S(2)**n*g**n, Int(F**(c*(a + b*x))*sinh(d/S(2) + e*x/S(2))**(S(2)*n), x), x) rule5959 = ReplacementRule(pattern5959, replacement5959) pattern5960 = Pattern(Integral(F_**((x_*WC('b', S(1)) + WC('a', S(0)))*WC('c', S(1)))*(f_ + WC('g', S(1))*sinh(x_*WC('e', S(1)) + WC('d', S(0))))**WC('n', S(1))*cosh(x_*WC('e', S(1)) + WC('d', S(0)))**WC('m', S(1)), x_), cons1099, cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons1870, cons150, cons1551) def replacement5960(m, g, b, f, d, c, a, n, x, F, e): rubi.append(5960) return Dist(g**n, Int(F**(c*(a + b*x))*tanh(-Pi*f/(S(4)*g) + d/S(2) + e*x/S(2))**m, x), x) rule5960 = ReplacementRule(pattern5960, replacement5960) pattern5961 = Pattern(Integral(F_**((x_*WC('b', S(1)) + WC('a', S(0)))*WC('c', S(1)))*(f_ + WC('g', S(1))*cosh(x_*WC('e', S(1)) + WC('d', S(0))))**WC('n', S(1))*sinh(x_*WC('e', S(1)) + WC('d', S(0)))**WC('m', S(1)), x_), cons1099, cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons1700, cons150, cons1551) def replacement5961(m, g, b, f, d, c, n, a, x, F, e): rubi.append(5961) return Dist(g**n, Int(F**(c*(a + b*x))*tanh(d/S(2) + e*x/S(2))**m, x), x) rule5961 = ReplacementRule(pattern5961, replacement5961) pattern5962 = Pattern(Integral(F_**((x_*WC('b', S(1)) + WC('a', S(0)))*WC('c', S(1)))*(f_ + WC('g', S(1))*cosh(x_*WC('e', S(1)) + WC('d', S(0))))**WC('n', S(1))*sinh(x_*WC('e', S(1)) + WC('d', S(0)))**WC('m', S(1)), x_), cons1099, cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons1011, cons150, cons1551) def replacement5962(m, g, b, f, d, c, n, a, x, F, e): rubi.append(5962) return Dist(g**n, Int(F**(c*(a + b*x))*(S(1)/tanh(d/S(2) + e*x/S(2)))**m, x), x) rule5962 = ReplacementRule(pattern5962, replacement5962) pattern5963 = Pattern(Integral(F_**((x_*WC('b', S(1)) + WC('a', S(0)))*WC('c', S(1)))*(h_ + WC('i', S(1))*cosh(x_*WC('e', S(1)) + WC('d', S(0))))/(f_ + WC('g', S(1))*sinh(x_*WC('e', S(1)) + WC('d', S(0)))), x_), cons1099, cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons209, cons224, cons1870, cons1701, cons1702) def replacement5963(g, b, f, i, d, c, a, x, h, F, e): rubi.append(5963) return Dist(S(2)*i, Int(F**(c*(a + b*x))*cosh(d + e*x)/(f + g*sinh(d + e*x)), x), x) + Int(F**(c*(a + b*x))*(h - i*cosh(d + e*x))/(f + g*sinh(d + e*x)), x) rule5963 = ReplacementRule(pattern5963, replacement5963) pattern5964 = Pattern(Integral(F_**((x_*WC('b', S(1)) + WC('a', S(0)))*WC('c', S(1)))*(h_ + WC('i', S(1))*sinh(x_*WC('e', S(1)) + WC('d', S(0))))/(f_ + WC('g', S(1))*cosh(x_*WC('e', S(1)) + WC('d', S(0)))), x_), cons1099, cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons209, cons224, cons1699, cons1871, cons1703) def replacement5964(g, b, f, i, d, c, a, x, h, F, e): rubi.append(5964) return Dist(S(2)*i, Int(F**(c*(a + b*x))*sinh(d + e*x)/(f + g*cosh(d + e*x)), x), x) + Int(F**(c*(a + b*x))*(h - i*sinh(d + e*x))/(f + g*cosh(d + e*x)), x) rule5964 = ReplacementRule(pattern5964, replacement5964) pattern5965 = Pattern(Integral(F_**(u_*WC('c', S(1)))*G_**v_, x_), cons1099, cons7, cons4, cons1861, cons810, cons811) def replacement5965(v, u, G, c, n, x, F): rubi.append(5965) return Int(F**(c*ExpandToSum(u, x))*G(ExpandToSum(v, x))**n, x) rule5965 = ReplacementRule(pattern5965, replacement5965) def With5966(m, b, d, c, a, n, x, F, e): u = IntHide(F**(c*(a + b*x))*sinh(d + e*x)**n, x) rubi.append(5966) return -Dist(m, Int(u*x**(m + S(-1)), x), x) + Simp(u*x**m, x) pattern5966 = Pattern(Integral(F_**((x_*WC('b', S(1)) + WC('a', S(0)))*WC('c', S(1)))*x_**WC('m', S(1))*sinh(x_*WC('e', S(1)) + WC('d', S(0)))**WC('n', S(1)), x_), cons1099, cons2, cons3, cons7, cons27, cons48, cons31, cons168, cons148) rule5966 = ReplacementRule(pattern5966, With5966) def With5967(m, b, d, c, n, a, x, F, e): u = IntHide(F**(c*(a + b*x))*cosh(d + e*x)**n, x) rubi.append(5967) return -Dist(m, Int(u*x**(m + S(-1)), x), x) + Simp(u*x**m, x) pattern5967 = Pattern(Integral(F_**((x_*WC('b', S(1)) + WC('a', S(0)))*WC('c', S(1)))*x_**WC('m', S(1))*cosh(x_*WC('e', S(1)) + WC('d', S(0)))**WC('n', S(1)), x_), cons1099, cons2, cons3, cons7, cons27, cons48, cons31, cons168, cons148) rule5967 = ReplacementRule(pattern5967, With5967) pattern5968 = Pattern(Integral(F_**((x_*WC('b', S(1)) + WC('a', S(0)))*WC('c', S(1)))*sinh(x_*WC('e', S(1)) + WC('d', S(0)))**WC('m', S(1))*cosh(x_*WC('g', S(1)) + WC('f', S(0)))**WC('n', S(1)), x_), cons1099, cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons528) def replacement5968(m, f, g, b, d, c, n, a, x, F, e): rubi.append(5968) return Int(ExpandTrigReduce(F**(c*(a + b*x)), sinh(d + e*x)**m*cosh(f + g*x)**n, x), x) rule5968 = ReplacementRule(pattern5968, replacement5968) pattern5969 = Pattern(Integral(F_**((x_*WC('b', S(1)) + WC('a', S(0)))*WC('c', S(1)))*x_**WC('p', S(1))*sinh(x_*WC('e', S(1)) + WC('d', S(0)))**WC('m', S(1))*cosh(x_*WC('g', S(1)) + WC('f', S(0)))**WC('n', S(1)), x_), cons1099, cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons1704) def replacement5969(p, m, f, g, b, d, c, n, a, x, F, e): rubi.append(5969) return Int(ExpandTrigReduce(F**(c*(a + b*x))*x**p, sinh(d + e*x)**m*cosh(f + g*x)**n, x), x) rule5969 = ReplacementRule(pattern5969, replacement5969) pattern5970 = Pattern(Integral(F_**((x_*WC('b', S(1)) + WC('a', S(0)))*WC('c', S(1)))*G_**(x_*WC('e', S(1)) + WC('d', S(0)))*H_**(x_*WC('e', S(1)) + WC('d', S(0))), x_), cons1099, cons2, cons3, cons7, cons27, cons48, cons528, cons1861, cons1872) def replacement5970(m, b, G, d, c, a, n, H, x, F, e): rubi.append(5970) return Int(ExpandTrigToExp(F**(c*(a + b*x)), G(d + e*x)**m*H(d + e*x)**n, x), x) rule5970 = ReplacementRule(pattern5970, replacement5970) pattern5971 = Pattern(Integral(F_**u_*sinh(v_)**WC('n', S(1)), x_), cons1099, cons1706, cons1707, cons148) def replacement5971(v, u, n, x, F): rubi.append(5971) return Int(ExpandTrigToExp(F**u, sinh(v)**n, x), x) rule5971 = ReplacementRule(pattern5971, replacement5971) pattern5972 = Pattern(Integral(F_**u_*cosh(v_)**WC('n', S(1)), x_), cons1099, cons1706, cons1707, cons148) def replacement5972(v, u, n, x, F): rubi.append(5972) return Int(ExpandTrigToExp(F**u, cosh(v)**n, x), x) rule5972 = ReplacementRule(pattern5972, replacement5972) pattern5973 = Pattern(Integral(F_**u_*sinh(v_)**WC('m', S(1))*cosh(v_)**WC('n', S(1)), x_), cons1099, cons1706, cons1707, cons528) def replacement5973(v, u, m, n, x, F): rubi.append(5973) return Int(ExpandTrigToExp(F**u, sinh(v)**m*cosh(v)**n, x), x) rule5973 = ReplacementRule(pattern5973, replacement5973) pattern5974 = Pattern(Integral(sinh(WC('b', S(1))*log(x_**WC('n', S(1))*WC('c', S(1))))**WC('p', S(1)), x_), cons7, cons1873) def replacement5974(p, b, c, n, x): rubi.append(5974) return Int(((c*x**n)**b/S(2) - (c*x**n)**(-b)/S(2))**p, x) rule5974 = ReplacementRule(pattern5974, replacement5974) pattern5975 = Pattern(Integral(cosh(WC('b', S(1))*log(x_**WC('n', S(1))*WC('c', S(1))))**WC('p', S(1)), x_), cons7, cons1873) def replacement5975(p, b, c, n, x): rubi.append(5975) return Int(((c*x**n)**b/S(2) + (c*x**n)**(-b)/S(2))**p, x) rule5975 = ReplacementRule(pattern5975, replacement5975) pattern5976 = Pattern(Integral(sinh(WC('a', S(0)) + WC('b', S(1))*log(x_**WC('n', S(1))*WC('c', S(1))))**p_, x_), cons2, cons3, cons7, cons4, cons5, cons1874, cons54) def replacement5976(p, b, a, n, c, x): rubi.append(5976) return -Simp(x*(p + S(2))*sinh(a + b*log(c*x**n))**(p + S(2))/(p + S(1)), x) + Simp(x*sinh(a + b*log(c*x**n))**(p + S(2))/(b*n*(p + S(1))*tanh(a + b*log(c*x**n))), x) rule5976 = ReplacementRule(pattern5976, replacement5976) pattern5977 = Pattern(Integral(cosh(WC('a', S(0)) + WC('b', S(1))*log(x_**WC('n', S(1))*WC('c', S(1))))**p_, x_), cons2, cons3, cons7, cons4, cons5, cons1874, cons54) def replacement5977(p, b, a, n, c, x): rubi.append(5977) return Simp(x*(p + S(2))*cosh(a + b*log(c*x**n))**(p + S(2))/(p + S(1)), x) - Simp(x*cosh(a + b*log(c*x**n))**(p + S(2))*tanh(a + b*log(c*x**n))/(b*n*(p + S(1))), x) rule5977 = ReplacementRule(pattern5977, replacement5977) pattern5978 = Pattern(Integral(sqrt(sinh(WC('a', S(0)) + WC('b', S(1))*log(x_**WC('n', S(1))*WC('c', S(1))))), x_), cons2, cons3, cons7, cons4, cons1875) def replacement5978(b, a, n, c, x): rubi.append(5978) return Dist(x*sqrt(sinh(a + b*log(c*x**n)))/sqrt((c*x**n)**(S(4)/n)*exp(S(2)*a) + S(-1)), Int(sqrt((c*x**n)**(S(4)/n)*exp(S(2)*a) + S(-1))/x, x), x) rule5978 = ReplacementRule(pattern5978, replacement5978) pattern5979 = Pattern(Integral(sqrt(cosh(WC('a', S(0)) + WC('b', S(1))*log(x_**WC('n', S(1))*WC('c', S(1))))), x_), cons2, cons3, cons7, cons4, cons1875) def replacement5979(b, a, n, c, x): rubi.append(5979) return Dist(x*sqrt(cosh(a + b*log(c*x**n)))/sqrt((c*x**n)**(S(4)/n)*exp(S(2)*a) + S(1)), Int(sqrt((c*x**n)**(S(4)/n)*exp(S(2)*a) + S(1))/x, x), x) rule5979 = ReplacementRule(pattern5979, replacement5979) pattern5980 = Pattern(Integral(sinh(WC('a', S(0)) + WC('b', S(1))*log(x_**WC('n', S(1))*WC('c', S(1))))**WC('p', S(1)), x_), cons2, cons3, cons7, cons4, cons128, cons1876) def replacement5980(p, b, a, n, c, x): rubi.append(5980) return Int(ExpandIntegrand(((c*x**n)**(S(1)/(n*p))*exp(a*b*n*p)/(S(2)*b*n*p) - (c*x**n)**(-S(1)/(n*p))*exp(-a*b*n*p)/(S(2)*b*n*p))**p, x), x) rule5980 = ReplacementRule(pattern5980, replacement5980) pattern5981 = Pattern(Integral(cosh(WC('a', S(0)) + WC('b', S(1))*log(x_**WC('n', S(1))*WC('c', S(1))))**WC('p', S(1)), x_), cons2, cons3, cons7, cons4, cons128, cons1876) def replacement5981(p, b, a, n, c, x): rubi.append(5981) return Int(ExpandIntegrand(((c*x**n)**(S(1)/(n*p))*exp(a*b*n*p)/S(2) + (c*x**n)**(-S(1)/(n*p))*exp(-a*b*n*p)/S(2))**p, x), x) rule5981 = ReplacementRule(pattern5981, replacement5981) pattern5982 = Pattern(Integral(sinh(WC('a', S(0)) + WC('b', S(1))*log(x_**WC('n', S(1))*WC('c', S(1)))), x_), cons2, cons3, cons7, cons4, cons1877) def replacement5982(b, a, n, c, x): rubi.append(5982) return -Simp(x*sinh(a + b*log(c*x**n))/(b**S(2)*n**S(2) + S(-1)), x) + Simp(b*n*x*cosh(a + b*log(c*x**n))/(b**S(2)*n**S(2) + S(-1)), x) rule5982 = ReplacementRule(pattern5982, replacement5982) pattern5983 = Pattern(Integral(cosh(WC('a', S(0)) + WC('b', S(1))*log(x_**WC('n', S(1))*WC('c', S(1)))), x_), cons2, cons3, cons7, cons4, cons1877) def replacement5983(b, a, n, c, x): rubi.append(5983) return -Simp(x*cosh(a + b*log(c*x**n))/(b**S(2)*n**S(2) + S(-1)), x) + Simp(b*n*x*sinh(a + b*log(c*x**n))/(b**S(2)*n**S(2) + S(-1)), x) rule5983 = ReplacementRule(pattern5983, replacement5983) pattern5984 = Pattern(Integral(sinh(WC('a', S(0)) + WC('b', S(1))*log(x_**WC('n', S(1))*WC('c', S(1))))**p_, x_), cons2, cons3, cons7, cons4, cons13, cons146, cons1878) def replacement5984(p, b, a, n, c, x): rubi.append(5984) return -Dist(b**S(2)*n**S(2)*p*(p + S(-1))/(b**S(2)*n**S(2)*p**S(2) + S(-1)), Int(sinh(a + b*log(c*x**n))**(p + S(-2)), x), x) - Simp(x*sinh(a + b*log(c*x**n))**p/(b**S(2)*n**S(2)*p**S(2) + S(-1)), x) + Simp(b*n*p*x*sinh(a + b*log(c*x**n))**(p + S(-1))*cosh(a + b*log(c*x**n))/(b**S(2)*n**S(2)*p**S(2) + S(-1)), x) rule5984 = ReplacementRule(pattern5984, replacement5984) pattern5985 = Pattern(Integral(cosh(WC('a', S(0)) + WC('b', S(1))*log(x_**WC('n', S(1))*WC('c', S(1))))**p_, x_), cons2, cons3, cons7, cons4, cons13, cons146, cons1878) def replacement5985(p, b, a, n, c, x): rubi.append(5985) return Dist(b**S(2)*n**S(2)*p*(p + S(-1))/(b**S(2)*n**S(2)*p**S(2) + S(-1)), Int(cosh(a + b*log(c*x**n))**(p + S(-2)), x), x) - Simp(x*cosh(a + b*log(c*x**n))**p/(b**S(2)*n**S(2)*p**S(2) + S(-1)), x) + Simp(b*n*p*x*sinh(a + b*log(c*x**n))*cosh(a + b*log(c*x**n))**(p + S(-1))/(b**S(2)*n**S(2)*p**S(2) + S(-1)), x) rule5985 = ReplacementRule(pattern5985, replacement5985) pattern5986 = Pattern(Integral(sinh(WC('a', S(0)) + WC('b', S(1))*log(x_**WC('n', S(1))*WC('c', S(1))))**p_, x_), cons2, cons3, cons7, cons4, cons13, cons137, cons1505, cons1879) def replacement5986(p, b, a, n, c, x): rubi.append(5986) return -Dist((b**S(2)*n**S(2)*(p + S(2))**S(2) + S(-1))/(b**S(2)*n**S(2)*(p + S(1))*(p + S(2))), Int(sinh(a + b*log(c*x**n))**(p + S(2)), x), x) - Simp(x*sinh(a + b*log(c*x**n))**(p + S(2))/(b**S(2)*n**S(2)*(p + S(1))*(p + S(2))), x) + Simp(x*sinh(a + b*log(c*x**n))**(p + S(2))/(b*n*(p + S(1))*tanh(a + b*log(c*x**n))), x) rule5986 = ReplacementRule(pattern5986, replacement5986) pattern5987 = Pattern(Integral(cosh(WC('a', S(0)) + WC('b', S(1))*log(x_**WC('n', S(1))*WC('c', S(1))))**p_, x_), cons2, cons3, cons7, cons4, cons13, cons137, cons1505, cons1879) def replacement5987(p, b, a, n, c, x): rubi.append(5987) return Dist((b**S(2)*n**S(2)*(p + S(2))**S(2) + S(-1))/(b**S(2)*n**S(2)*(p + S(1))*(p + S(2))), Int(cosh(a + b*log(c*x**n))**(p + S(2)), x), x) + Simp(x*cosh(a + b*log(c*x**n))**(p + S(2))/(b**S(2)*n**S(2)*(p + S(1))*(p + S(2))), x) - Simp(x*cosh(a + b*log(c*x**n))**(p + S(2))*tanh(a + b*log(c*x**n))/(b*n*(p + S(1))), x) rule5987 = ReplacementRule(pattern5987, replacement5987) pattern5988 = Pattern(Integral(sinh(WC('a', S(0)) + WC('b', S(1))*log(x_**WC('n', S(1))*WC('c', S(1))))**p_, x_), cons2, cons3, cons7, cons4, cons5, cons1878) def replacement5988(p, b, a, n, c, x): rubi.append(5988) return Simp(x*(S(2) - S(2)*(c*x**n)**(-S(2)*b)*exp(-S(2)*a))**(-p)*((c*x**n)**b*exp(a) - (c*x**n)**(-b)*exp(-a))**p*Hypergeometric2F1(-p, -(b*n*p + S(1))/(S(2)*b*n), S(1) - (b*n*p + S(1))/(S(2)*b*n), (c*x**n)**(-S(2)*b)*exp(-S(2)*a))/(b*n*p + S(1)), x) rule5988 = ReplacementRule(pattern5988, replacement5988) pattern5989 = Pattern(Integral(cosh(WC('a', S(0)) + WC('b', S(1))*log(x_**WC('n', S(1))*WC('c', S(1))))**p_, x_), cons2, cons3, cons7, cons4, cons5, cons1878) def replacement5989(p, b, a, n, c, x): rubi.append(5989) return Simp(x*(S(2) + S(2)*(c*x**n)**(-S(2)*b)*exp(-S(2)*a))**(-p)*((c*x**n)**b*exp(a) + (c*x**n)**(-b)*exp(-a))**p*Hypergeometric2F1(-p, -(b*n*p + S(1))/(S(2)*b*n), S(1) - (b*n*p + S(1))/(S(2)*b*n), -(c*x**n)**(-S(2)*b)*exp(-S(2)*a))/(b*n*p + S(1)), x) rule5989 = ReplacementRule(pattern5989, replacement5989) pattern5990 = Pattern(Integral(x_**WC('m', S(1))*sinh(WC('a', S(0)) + WC('b', S(1))*log(x_**WC('n', S(1))*WC('c', S(1))))**p_, x_), cons2, cons3, cons7, cons21, cons4, cons5, cons1880, cons54, cons66) def replacement5990(p, m, b, c, n, a, x): rubi.append(5990) return -Simp(x**(m + S(1))*(p + S(2))*sinh(a + b*log(c*x**n))**(p + S(2))/((m + S(1))*(p + S(1))), x) + Simp(x**(m + S(1))*sinh(a + b*log(c*x**n))**(p + S(2))/(b*n*(p + S(1))*tanh(a + b*log(c*x**n))), x) rule5990 = ReplacementRule(pattern5990, replacement5990) pattern5991 = Pattern(Integral(x_**WC('m', S(1))*cosh(WC('a', S(0)) + WC('b', S(1))*log(x_**WC('n', S(1))*WC('c', S(1))))**p_, x_), cons2, cons3, cons7, cons21, cons4, cons5, cons1880, cons54, cons66) def replacement5991(p, m, b, a, n, c, x): rubi.append(5991) return Simp(x**(m + S(1))*(p + S(2))*cosh(a + b*log(c*x**n))**(p + S(2))/((m + S(1))*(p + S(1))), x) - Simp(x**(m + S(1))*cosh(a + b*log(c*x**n))**(p + S(2))*tanh(a + b*log(c*x**n))/(b*n*(p + S(1))), x) rule5991 = ReplacementRule(pattern5991, replacement5991) pattern5992 = Pattern(Integral(x_**WC('m', S(1))*sinh(WC('a', S(0)) + WC('b', S(1))*log(x_**WC('n', S(1))*WC('c', S(1))))**WC('p', S(1)), x_), cons2, cons3, cons7, cons21, cons4, cons128, cons1881) def replacement5992(p, m, b, c, n, a, x): rubi.append(5992) return Dist(S(2)**(-p), Int(ExpandIntegrand(x**m*((c*x**n)**((m + S(1))/(n*p))*(m + S(1))*exp(a*b*n*p/(m + S(1)))/(b*n*p) - (c*x**n)**(-(m + S(1))/(n*p))*(m + S(1))*exp(-a*b*n*p/(m + S(1)))/(b*n*p))**p, x), x), x) rule5992 = ReplacementRule(pattern5992, replacement5992) pattern5993 = Pattern(Integral(x_**WC('m', S(1))*cosh(WC('a', S(0)) + WC('b', S(1))*log(x_**WC('n', S(1))*WC('c', S(1))))**WC('p', S(1)), x_), cons2, cons3, cons7, cons21, cons4, cons128, cons1881) def replacement5993(p, m, b, a, n, c, x): rubi.append(5993) return Dist(S(2)**(-p), Int(ExpandIntegrand(x**m*((c*x**n)**((m + S(1))/(n*p))*exp(a*b*n*p/(m + S(1))) + (c*x**n)**(-(m + S(1))/(n*p))*exp(-a*b*n*p/(m + S(1))))**p, x), x), x) rule5993 = ReplacementRule(pattern5993, replacement5993) pattern5994 = Pattern(Integral(x_**WC('m', S(1))*sinh(WC('a', S(0)) + WC('b', S(1))*log(x_**WC('n', S(1))*WC('c', S(1)))), x_), cons2, cons3, cons7, cons21, cons4, cons1882, cons66) def replacement5994(m, b, c, n, a, x): rubi.append(5994) return -Simp(x**(m + S(1))*(m + S(1))*sinh(a + b*log(c*x**n))/(b**S(2)*n**S(2) - (m + S(1))**S(2)), x) + Simp(b*n*x**(m + S(1))*cosh(a + b*log(c*x**n))/(b**S(2)*n**S(2) - (m + S(1))**S(2)), x) rule5994 = ReplacementRule(pattern5994, replacement5994) pattern5995 = Pattern(Integral(x_**WC('m', S(1))*cosh(WC('a', S(0)) + WC('b', S(1))*log(x_**WC('n', S(1))*WC('c', S(1)))), x_), cons2, cons3, cons7, cons21, cons4, cons1882, cons66) def replacement5995(m, b, a, n, c, x): rubi.append(5995) return -Simp(x**(m + S(1))*(m + S(1))*cosh(a + b*log(c*x**n))/(b**S(2)*n**S(2) - (m + S(1))**S(2)), x) + Simp(b*n*x**(m + S(1))*sinh(a + b*log(c*x**n))/(b**S(2)*n**S(2) - (m + S(1))**S(2)), x) rule5995 = ReplacementRule(pattern5995, replacement5995) pattern5996 = Pattern(Integral(x_**WC('m', S(1))*sinh(WC('a', S(0)) + WC('b', S(1))*log(x_**WC('n', S(1))*WC('c', S(1))))**p_, x_), cons2, cons3, cons7, cons21, cons4, cons1883, cons13, cons146, cons66) def replacement5996(p, m, b, c, n, a, x): rubi.append(5996) return -Dist(b**S(2)*n**S(2)*p*(p + S(-1))/(b**S(2)*n**S(2)*p**S(2) - (m + S(1))**S(2)), Int(x**m*sinh(a + b*log(c*x**n))**(p + S(-2)), x), x) - Simp(x**(m + S(1))*(m + S(1))*sinh(a + b*log(c*x**n))**p/(b**S(2)*n**S(2)*p**S(2) - (m + S(1))**S(2)), x) + Simp(b*n*p*x**(m + S(1))*sinh(a + b*log(c*x**n))**(p + S(-1))*cosh(a + b*log(c*x**n))/(b**S(2)*n**S(2)*p**S(2) - (m + S(1))**S(2)), x) rule5996 = ReplacementRule(pattern5996, replacement5996) pattern5997 = Pattern(Integral(x_**WC('m', S(1))*cosh(WC('a', S(0)) + WC('b', S(1))*log(x_**WC('n', S(1))*WC('c', S(1))))**p_, x_), cons2, cons3, cons7, cons21, cons4, cons1883, cons13, cons146, cons66) def replacement5997(p, m, b, a, n, c, x): rubi.append(5997) return Dist(b**S(2)*n**S(2)*p*(p + S(-1))/(b**S(2)*n**S(2)*p**S(2) - (m + S(1))**S(2)), Int(x**m*cosh(a + b*log(c*x**n))**(p + S(-2)), x), x) - Simp(x**(m + S(1))*(m + S(1))*cosh(a + b*log(c*x**n))**p/(b**S(2)*n**S(2)*p**S(2) - (m + S(1))**S(2)), x) + Simp(b*n*p*x**(m + S(1))*sinh(a + b*log(c*x**n))*cosh(a + b*log(c*x**n))**(p + S(-1))/(b**S(2)*n**S(2)*p**S(2) - (m + S(1))**S(2)), x) rule5997 = ReplacementRule(pattern5997, replacement5997) pattern5998 = Pattern(Integral(x_**WC('m', S(1))*sinh(WC('a', S(0)) + WC('b', S(1))*log(x_**WC('n', S(1))*WC('c', S(1))))**p_, x_), cons2, cons3, cons7, cons21, cons4, cons1884, cons13, cons137, cons1505, cons66) def replacement5998(p, m, b, c, n, a, x): rubi.append(5998) return -Dist((b**S(2)*n**S(2)*(p + S(2))**S(2) - (m + S(1))**S(2))/(b**S(2)*n**S(2)*(p + S(1))*(p + S(2))), Int(x**m*sinh(a + b*log(c*x**n))**(p + S(2)), x), x) + Simp(x**(m + S(1))*sinh(a + b*log(c*x**n))**(p + S(2))/(b*n*(p + S(1))*tanh(a + b*log(c*x**n))), x) - Simp(x**(m + S(1))*(m + S(1))*sinh(a + b*log(c*x**n))**(p + S(2))/(b**S(2)*n**S(2)*(p + S(1))*(p + S(2))), x) rule5998 = ReplacementRule(pattern5998, replacement5998) pattern5999 = Pattern(Integral(x_**WC('m', S(1))*cosh(WC('a', S(0)) + WC('b', S(1))*log(x_**WC('n', S(1))*WC('c', S(1))))**p_, x_), cons2, cons3, cons7, cons21, cons4, cons1884, cons13, cons137, cons1505, cons66) def replacement5999(p, m, b, a, n, c, x): rubi.append(5999) return Dist((b**S(2)*n**S(2)*(p + S(2))**S(2) - (m + S(1))**S(2))/(b**S(2)*n**S(2)*(p + S(1))*(p + S(2))), Int(x**m*cosh(a + b*log(c*x**n))**(p + S(2)), x), x) - Simp(x**(m + S(1))*cosh(a + b*log(c*x**n))**(p + S(2))*tanh(a + b*log(c*x**n))/(b*n*(p + S(1))), x) + Simp(x**(m + S(1))*(m + S(1))*cosh(a + b*log(c*x**n))**(p + S(2))/(b**S(2)*n**S(2)*(p + S(1))*(p + S(2))), x) rule5999 = ReplacementRule(pattern5999, replacement5999) pattern6000 = Pattern(Integral(x_**WC('m', S(1))*sinh(WC('a', S(0)) + WC('b', S(1))*log(x_**WC('n', S(1))*WC('c', S(1))))**p_, x_), cons2, cons3, cons7, cons21, cons4, cons5, cons1883) def replacement6000(p, m, b, c, n, a, x): rubi.append(6000) return Simp(x**(m + S(1))*(S(2) - S(2)*(c*x**n)**(-S(2)*b)*exp(-S(2)*a))**(-p)*((c*x**n)**b*exp(a) - (c*x**n)**(-b)*exp(-a))**p*Hypergeometric2F1(-p, -(b*n*p + m + S(1))/(S(2)*b*n), S(1) - (b*n*p + m + S(1))/(S(2)*b*n), (c*x**n)**(-S(2)*b)*exp(-S(2)*a))/(b*n*p + m + S(1)), x) rule6000 = ReplacementRule(pattern6000, replacement6000) pattern6001 = Pattern(Integral(x_**WC('m', S(1))*cosh(WC('a', S(0)) + WC('b', S(1))*log(x_**WC('n', S(1))*WC('c', S(1))))**p_, x_), cons2, cons3, cons7, cons21, cons4, cons5, cons1883) def replacement6001(p, m, b, a, n, c, x): rubi.append(6001) return Simp(x**(m + S(1))*(S(2) + S(2)*(c*x**n)**(-S(2)*b)*exp(-S(2)*a))**(-p)*((c*x**n)**b*exp(a) + (c*x**n)**(-b)*exp(-a))**p*Hypergeometric2F1(-p, -(b*n*p + m + S(1))/(S(2)*b*n), S(1) - (b*n*p + m + S(1))/(S(2)*b*n), -(c*x**n)**(-S(2)*b)*exp(-S(2)*a))/(b*n*p + m + S(1)), x) rule6001 = ReplacementRule(pattern6001, replacement6001) pattern6002 = Pattern(Integral((S(1)/cosh(WC('b', S(1))*log(x_**WC('n', S(1))*WC('c', S(1)))))**WC('p', S(1)), x_), cons7, cons1873) def replacement6002(p, b, c, n, x): rubi.append(6002) return Dist(S(2)**p, Int(((c*x**n)**b/((c*x**n)**(S(2)*b) + S(1)))**p, x), x) rule6002 = ReplacementRule(pattern6002, replacement6002) pattern6003 = Pattern(Integral((S(1)/sinh(WC('b', S(1))*log(x_**WC('n', S(1))*WC('c', S(1)))))**WC('p', S(1)), x_), cons7, cons1873) def replacement6003(p, b, c, n, x): rubi.append(6003) return Dist(S(2)**p, Int(((c*x**n)**b/((c*x**n)**(S(2)*b) + S(-1)))**p, x), x) rule6003 = ReplacementRule(pattern6003, replacement6003) pattern6004 = Pattern(Integral(S(1)/cosh(WC('a', S(0)) + WC('b', S(1))*log(x_**WC('n', S(1))*WC('c', S(1)))), x_), cons2, cons3, cons7, cons4, cons1885) def replacement6004(b, a, n, c, x): rubi.append(6004) return Dist(S(2)*exp(-a*b*n), Int((c*x**n)**(S(1)/n)/((c*x**n)**(S(2)/n) + exp(-S(2)*a*b*n)), x), x) rule6004 = ReplacementRule(pattern6004, replacement6004) pattern6005 = Pattern(Integral(S(1)/sinh(WC('a', S(0)) + WC('b', S(1))*log(x_**WC('n', S(1))*WC('c', S(1)))), x_), cons2, cons3, cons7, cons4, cons1885) def replacement6005(b, a, n, c, x): rubi.append(6005) return Dist(-S(2)*b*n*exp(-a*b*n), Int((c*x**n)**(S(1)/n)/(-(c*x**n)**(S(2)/n) + exp(-S(2)*a*b*n)), x), x) rule6005 = ReplacementRule(pattern6005, replacement6005) pattern6006 = Pattern(Integral((S(1)/cosh(WC('a', S(0)) + WC('b', S(1))*log(x_**WC('n', S(1))*WC('c', S(1)))))**p_, x_), cons2, cons3, cons7, cons4, cons5, cons1886, cons1645) def replacement6006(p, b, a, n, c, x): rubi.append(6006) return Simp(x*(p + S(-2))*(S(1)/cosh(a + b*log(c*x**n)))**(p + S(-2))/(p + S(-1)), x) + Simp(x*(S(1)/cosh(a + b*log(c*x**n)))**(p + S(-2))*tanh(a + b*log(c*x**n))/(b*n*(p + S(-1))), x) rule6006 = ReplacementRule(pattern6006, replacement6006) pattern6007 = Pattern(Integral((S(1)/sinh(WC('a', S(0)) + WC('b', S(1))*log(x_**WC('n', S(1))*WC('c', S(1)))))**p_, x_), cons2, cons3, cons7, cons4, cons5, cons1886, cons1645) def replacement6007(p, b, a, n, c, x): rubi.append(6007) return -Simp(x*(p + S(-2))*(S(1)/sinh(a + b*log(c*x**n)))**(p + S(-2))/(p + S(-1)), x) - Simp(x*(S(1)/sinh(a + b*log(c*x**n)))**(p + S(-2))/(b*n*(p + S(-1))*tanh(a + b*log(c*x**n))), x) rule6007 = ReplacementRule(pattern6007, replacement6007) pattern6008 = Pattern(Integral((S(1)/cosh(WC('a', S(0)) + WC('b', S(1))*log(x_**WC('n', S(1))*WC('c', S(1)))))**p_, x_), cons2, cons3, cons7, cons4, cons13, cons146, cons1720, cons1887) def replacement6008(p, b, a, n, c, x): rubi.append(6008) return Dist((b**S(2)*n**S(2)*(p + S(-2))**S(2) + S(-1))/(b**S(2)*n**S(2)*(p + S(-2))*(p + S(-1))), Int((S(1)/cosh(a + b*log(c*x**n)))**(p + S(-2)), x), x) + Simp(x*(S(1)/cosh(a + b*log(c*x**n)))**(p + S(-2))/(b**S(2)*n**S(2)*(p + S(-2))*(p + S(-1))), x) + Simp(x*(S(1)/cosh(a + b*log(c*x**n)))**(p + S(-2))*tanh(a + b*log(c*x**n))/(b*n*(p + S(-1))), x) rule6008 = ReplacementRule(pattern6008, replacement6008) pattern6009 = Pattern(Integral((S(1)/sinh(WC('a', S(0)) + WC('b', S(1))*log(x_**WC('n', S(1))*WC('c', S(1)))))**p_, x_), cons2, cons3, cons7, cons4, cons13, cons146, cons1720, cons1887) def replacement6009(p, b, a, n, c, x): rubi.append(6009) return -Dist((b**S(2)*n**S(2)*(p + S(-2))**S(2) + S(-1))/(b**S(2)*n**S(2)*(p + S(-2))*(p + S(-1))), Int((S(1)/sinh(a + b*log(c*x**n)))**(p + S(-2)), x), x) - Simp(x*(S(1)/sinh(a + b*log(c*x**n)))**(p + S(-2))/(b**S(2)*n**S(2)*(p + S(-2))*(p + S(-1))), x) - Simp(x*(S(1)/sinh(a + b*log(c*x**n)))**(p + S(-2))/(b*n*(p + S(-1))*tanh(a + b*log(c*x**n))), x) rule6009 = ReplacementRule(pattern6009, replacement6009) pattern6010 = Pattern(Integral((S(1)/cosh(WC('a', S(0)) + WC('b', S(1))*log(x_**WC('n', S(1))*WC('c', S(1)))))**p_, x_), cons2, cons3, cons7, cons4, cons13, cons137, cons1878) def replacement6010(p, b, a, n, c, x): rubi.append(6010) return Dist(b**S(2)*n**S(2)*p*(p + S(1))/(b**S(2)*n**S(2)*p**S(2) + S(-1)), Int((S(1)/cosh(a + b*log(c*x**n)))**(p + S(2)), x), x) - Simp(x*(S(1)/cosh(a + b*log(c*x**n)))**p/(b**S(2)*n**S(2)*p**S(2) + S(-1)), x) - Simp(b*n*p*x*(S(1)/cosh(a + b*log(c*x**n)))**(p + S(1))*sinh(a + b*log(c*x**n))/(b**S(2)*n**S(2)*p**S(2) + S(-1)), x) rule6010 = ReplacementRule(pattern6010, replacement6010) pattern6011 = Pattern(Integral((S(1)/sinh(WC('a', S(0)) + WC('b', S(1))*log(x_**WC('n', S(1))*WC('c', S(1)))))**p_, x_), cons2, cons3, cons7, cons4, cons13, cons137, cons1878) def replacement6011(p, b, a, n, c, x): rubi.append(6011) return -Dist(b**S(2)*n**S(2)*p*(p + S(1))/(b**S(2)*n**S(2)*p**S(2) + S(-1)), Int((S(1)/sinh(a + b*log(c*x**n)))**(p + S(2)), x), x) - Simp(x*(S(1)/sinh(a + b*log(c*x**n)))**p/(b**S(2)*n**S(2)*p**S(2) + S(-1)), x) - Simp(b*n*p*x*(S(1)/sinh(a + b*log(c*x**n)))**(p + S(1))*cosh(a + b*log(c*x**n))/(b**S(2)*n**S(2)*p**S(2) + S(-1)), x) rule6011 = ReplacementRule(pattern6011, replacement6011) pattern6012 = Pattern(Integral((S(1)/cosh(WC('a', S(0)) + WC('b', S(1))*log(x_**WC('n', S(1))*WC('c', S(1)))))**WC('p', S(1)), x_), cons2, cons3, cons7, cons4, cons5, cons1878) def replacement6012(p, b, a, n, c, x): rubi.append(6012) return Simp(S(2)**p*x*((c*x**n)**b*exp(a)/((c*x**n)**(S(2)*b)*exp(S(2)*a) + S(1)))**p*((c*x**n)**(S(2)*b)*exp(S(2)*a) + S(1))**p*Hypergeometric2F1(p, (b*n*p + S(1))/(S(2)*b*n), S(1) + (b*n*p + S(1))/(S(2)*b*n), -(c*x**n)**(S(2)*b)*exp(S(2)*a))/(b*n*p + S(1)), x) rule6012 = ReplacementRule(pattern6012, replacement6012) pattern6013 = Pattern(Integral((S(1)/sinh(WC('a', S(0)) + WC('b', S(1))*log(x_**WC('n', S(1))*WC('c', S(1)))))**WC('p', S(1)), x_), cons2, cons3, cons7, cons4, cons5, cons1878) def replacement6013(p, b, a, n, c, x): rubi.append(6013) return Simp(x*((c*x**n)**b*exp(a)/((c*x**n)**(S(2)*b)*exp(S(2)*a) + S(-1)))**p*(-S(2)*(c*x**n)**(S(2)*b)*exp(S(2)*a) + S(2))**p*Hypergeometric2F1(p, (b*n*p + S(1))/(S(2)*b*n), S(1) + (b*n*p + S(1))/(S(2)*b*n), (c*x**n)**(S(2)*b)*exp(S(2)*a))/(b*n*p + S(1)), x) rule6013 = ReplacementRule(pattern6013, replacement6013) pattern6014 = Pattern(Integral(x_**WC('m', S(1))*(S(1)/cosh(WC('b', S(1))*log(x_**WC('n', S(1))*WC('c', S(1)))))**WC('p', S(1)), x_), cons7, cons1888) def replacement6014(p, m, b, c, n, x): rubi.append(6014) return Dist(S(2)**p, Int(x**m*((c*x**n)**b/((c*x**n)**(S(2)*b) + S(1)))**p, x), x) rule6014 = ReplacementRule(pattern6014, replacement6014) pattern6015 = Pattern(Integral(x_**WC('m', S(1))*(S(1)/sinh(WC('b', S(1))*log(x_**WC('n', S(1))*WC('c', S(1)))))**WC('p', S(1)), x_), cons7, cons1888) def replacement6015(p, m, b, c, n, x): rubi.append(6015) return Dist(S(2)**p, Int(x**m*((c*x**n)**b/((c*x**n)**(S(2)*b) + S(-1)))**p, x), x) rule6015 = ReplacementRule(pattern6015, replacement6015) pattern6016 = Pattern(Integral(x_**WC('m', S(1))/cos(WC('a', S(0)) + WC('b', S(1))*log(x_**WC('n', S(1))*WC('c', S(1)))), x_), cons2, cons3, cons7, cons21, cons4, cons1889) def replacement6016(m, b, c, n, a, x): rubi.append(6016) return Dist(S(2)*exp(-a*b*n/(m + S(1))), Int(x**m*(c*x**n)**((m + S(1))/n)/((c*x**n)**(S(2)*(m + S(1))/n) + exp(-S(2)*a*b*n/(m + S(1)))), x), x) rule6016 = ReplacementRule(pattern6016, replacement6016) pattern6017 = Pattern(Integral(x_**WC('m', S(1))/sin(WC('a', S(0)) + WC('b', S(1))*log(x_**WC('n', S(1))*WC('c', S(1)))), x_), cons2, cons3, cons7, cons21, cons4, cons1889) def replacement6017(m, b, a, n, c, x): rubi.append(6017) return Dist(-S(2)*b*n*exp(-a*b*n/(m + S(1)))/(m + S(1)), Int(x**m*(c*x**n)**((m + S(1))/n)/(-(c*x**n)**(S(2)*(m + S(1))/n) + exp(-S(2)*a*b*n/(m + S(1)))), x), x) rule6017 = ReplacementRule(pattern6017, replacement6017) pattern6018 = Pattern(Integral(x_**WC('m', S(1))*(S(1)/cosh(WC('a', S(0)) + WC('b', S(1))*log(x_**WC('n', S(1))*WC('c', S(1)))))**p_, x_), cons2, cons3, cons7, cons21, cons4, cons5, cons1723, cons66, cons1645) def replacement6018(p, m, b, c, n, a, x): rubi.append(6018) return Simp(x**(m + S(1))*(p + S(-2))*(S(1)/cosh(a + b*log(c*x**n)))**(p + S(-2))/((m + S(1))*(p + S(-1))), x) + Simp(x**(m + S(1))*(S(1)/cosh(a + b*log(c*x**n)))**(p + S(-2))*tanh(a + b*log(c*x**n))/(b*n*(p + S(-1))), x) rule6018 = ReplacementRule(pattern6018, replacement6018) pattern6019 = Pattern(Integral(x_**WC('m', S(1))*(S(1)/sinh(WC('a', S(0)) + WC('b', S(1))*log(x_**WC('n', S(1))*WC('c', S(1)))))**p_, x_), cons2, cons3, cons7, cons21, cons4, cons5, cons1723, cons66, cons1645) def replacement6019(p, m, b, a, n, c, x): rubi.append(6019) return -Simp(x**(m + S(1))*(p + S(-2))*(S(1)/sinh(a + b*log(c*x**n)))**(p + S(-2))/((m + S(1))*(p + S(-1))), x) - Simp(x**(m + S(1))*(S(1)/sinh(a + b*log(c*x**n)))**(p + S(-2))/(b*n*(p + S(-1))*tanh(a + b*log(c*x**n))), x) rule6019 = ReplacementRule(pattern6019, replacement6019) pattern6020 = Pattern(Integral(x_**WC('m', S(1))*(S(1)/cosh(WC('a', S(0)) + WC('b', S(1))*log(x_**WC('n', S(1))*WC('c', S(1)))))**p_, x_), cons2, cons3, cons7, cons21, cons4, cons13, cons146, cons1720, cons1890) def replacement6020(p, m, b, c, n, a, x): rubi.append(6020) return Dist((b**S(2)*n**S(2)*(p + S(-2))**S(2) - (m + S(1))**S(2))/(b**S(2)*n**S(2)*(p + S(-2))*(p + S(-1))), Int(x**m*(S(1)/cosh(a + b*log(c*x**n)))**(p + S(-2)), x), x) + Simp(x**(m + S(1))*(S(1)/cosh(a + b*log(c*x**n)))**(p + S(-2))*tanh(a + b*log(c*x**n))/(b*n*(p + S(-1))), x) + Simp(x**(m + S(1))*(m + S(1))*(S(1)/cosh(a + b*log(c*x**n)))**(p + S(-2))/(b**S(2)*n**S(2)*(p + S(-2))*(p + S(-1))), x) rule6020 = ReplacementRule(pattern6020, replacement6020) pattern6021 = Pattern(Integral(x_**WC('m', S(1))*(S(1)/sinh(WC('a', S(0)) + WC('b', S(1))*log(x_**WC('n', S(1))*WC('c', S(1)))))**p_, x_), cons2, cons3, cons7, cons21, cons4, cons13, cons146, cons1720, cons1890) def replacement6021(p, m, b, a, n, c, x): rubi.append(6021) return -Dist((b**S(2)*n**S(2)*(p + S(-2))**S(2) - (m + S(1))**S(2))/(b**S(2)*n**S(2)*(p + S(-2))*(p + S(-1))), Int(x**m*(S(1)/sinh(a + b*log(c*x**n)))**(p + S(-2)), x), x) - Simp(x**(m + S(1))*(S(1)/sinh(a + b*log(c*x**n)))**(p + S(-2))/(b*n*(p + S(-1))*tanh(a + b*log(c*x**n))), x) - Simp(x**(m + S(1))*(m + S(1))*(S(1)/sinh(a + b*log(c*x**n)))**(p + S(-2))/(b**S(2)*n**S(2)*(p + S(-2))*(p + S(-1))), x) rule6021 = ReplacementRule(pattern6021, replacement6021) pattern6022 = Pattern(Integral(x_**WC('m', S(1))*(S(1)/cosh(WC('a', S(0)) + WC('b', S(1))*log(x_**WC('n', S(1))*WC('c', S(1)))))**p_, x_), cons2, cons3, cons7, cons21, cons4, cons13, cons137, cons1883) def replacement6022(p, m, b, c, n, a, x): rubi.append(6022) return Dist(b**S(2)*n**S(2)*p*(p + S(1))/(b**S(2)*n**S(2)*p**S(2) - (m + S(1))**S(2)), Int(x**m*(S(1)/cosh(a + b*log(c*x**n)))**(p + S(2)), x), x) - Simp(x**(m + S(1))*(m + S(1))*(S(1)/cosh(a + b*log(c*x**n)))**p/(b**S(2)*n**S(2)*p**S(2) - (m + S(1))**S(2)), x) - Simp(b*n*p*x**(m + S(1))*(S(1)/cosh(a + b*log(c*x**n)))**(p + S(1))*sinh(a + b*log(c*x**n))/(b**S(2)*n**S(2)*p**S(2) - (m + S(1))**S(2)), x) rule6022 = ReplacementRule(pattern6022, replacement6022) pattern6023 = Pattern(Integral(x_**WC('m', S(1))*(S(1)/sinh(WC('a', S(0)) + WC('b', S(1))*log(x_**WC('n', S(1))*WC('c', S(1)))))**p_, x_), cons2, cons3, cons7, cons21, cons4, cons13, cons137, cons1883) def replacement6023(p, m, b, a, n, c, x): rubi.append(6023) return -Dist(b**S(2)*n**S(2)*p*(p + S(1))/(b**S(2)*n**S(2)*p**S(2) - (m + S(1))**S(2)), Int(x**m*(S(1)/sinh(a + b*log(c*x**n)))**(p + S(2)), x), x) - Simp(x**(m + S(1))*(m + S(1))*(S(1)/sinh(a + b*log(c*x**n)))**p/(b**S(2)*n**S(2)*p**S(2) - (m + S(1))**S(2)), x) - Simp(b*n*p*x**(m + S(1))*(S(1)/sinh(a + b*log(c*x**n)))**(p + S(1))*cosh(a + b*log(c*x**n))/(b**S(2)*n**S(2)*p**S(2) - (m + S(1))**S(2)), x) rule6023 = ReplacementRule(pattern6023, replacement6023) pattern6024 = Pattern(Integral(x_**WC('m', S(1))*(S(1)/cosh(WC('a', S(0)) + WC('b', S(1))*log(x_**WC('n', S(1))*WC('c', S(1)))))**WC('p', S(1)), x_), cons2, cons3, cons7, cons21, cons4, cons5, cons1883) def replacement6024(p, m, b, c, n, a, x): rubi.append(6024) return Simp(S(2)**p*x**(m + S(1))*((c*x**n)**b*exp(a)/((c*x**n)**(S(2)*b)*exp(S(2)*a) + S(1)))**p*((c*x**n)**(S(2)*b)*exp(S(2)*a) + S(1))**p*Hypergeometric2F1(p, (b*n*p + m + S(1))/(S(2)*b*n), S(1) + (b*n*p + m + S(1))/(S(2)*b*n), -(c*x**n)**(S(2)*b)*exp(S(2)*a))/(b*n*p + m + S(1)), x) rule6024 = ReplacementRule(pattern6024, replacement6024) pattern6025 = Pattern(Integral(x_**WC('m', S(1))*(S(1)/sinh(WC('a', S(0)) + WC('b', S(1))*log(x_**WC('n', S(1))*WC('c', S(1)))))**WC('p', S(1)), x_), cons2, cons3, cons7, cons21, cons4, cons5, cons1883) def replacement6025(p, m, b, a, n, c, x): rubi.append(6025) return Simp(S(2)**p*x**(m + S(1))*((c*x**n)**b*exp(a)/((c*x**n)**(S(2)*b)*exp(S(2)*a) + S(-1)))**p*(-(c*x**n)**(S(2)*b)*exp(S(2)*a) + S(1))**p*Hypergeometric2F1(p, (b*n*p + m + S(1))/(S(2)*b*n), S(1) + (b*n*p + m + S(1))/(S(2)*b*n), (c*x**n)**(S(2)*b)*exp(S(2)*a))/(b*n*p + m + S(1)), x) rule6025 = ReplacementRule(pattern6025, replacement6025) pattern6026 = Pattern(Integral(log(x_*WC('b', S(1)))**WC('p', S(1))*sinh(x_*WC('a', S(1))*log(x_*WC('b', S(1)))**WC('p', S(1))), x_), cons2, cons3, cons13, cons163) def replacement6026(x, a, p, b): rubi.append(6026) return -Dist(p, Int(log(b*x)**(p + S(-1))*sinh(a*x*log(b*x)**p), x), x) + Simp(cosh(a*x*log(b*x)**p)/a, x) rule6026 = ReplacementRule(pattern6026, replacement6026) pattern6027 = Pattern(Integral(log(x_*WC('b', S(1)))**WC('p', S(1))*cosh(x_*WC('a', S(1))*log(x_*WC('b', S(1)))**WC('p', S(1))), x_), cons2, cons3, cons13, cons163) def replacement6027(x, a, p, b): rubi.append(6027) return -Dist(p, Int(log(b*x)**(p + S(-1))*cosh(a*x*log(b*x)**p), x), x) + Simp(sinh(a*x*log(b*x)**p)/a, x) rule6027 = ReplacementRule(pattern6027, replacement6027) pattern6028 = Pattern(Integral(log(x_*WC('b', S(1)))**WC('p', S(1))*sinh(x_**n_*WC('a', S(1))*log(x_*WC('b', S(1)))**WC('p', S(1))), x_), cons2, cons3, cons338, cons163) def replacement6028(p, b, a, n, x): rubi.append(6028) return -Dist(p/n, Int(log(b*x)**(p + S(-1))*sinh(a*x**n*log(b*x)**p), x), x) + Dist((n + S(-1))/(a*n), Int(x**(-n)*cosh(a*x**n*log(b*x)**p), x), x) + Simp(x**(-n + S(1))*cosh(a*x**n*log(b*x)**p)/(a*n), x) rule6028 = ReplacementRule(pattern6028, replacement6028) pattern6029 = Pattern(Integral(log(x_*WC('b', S(1)))**WC('p', S(1))*cosh(x_**n_*WC('a', S(1))*log(x_*WC('b', S(1)))**WC('p', S(1))), x_), cons2, cons3, cons338, cons163) def replacement6029(p, b, a, n, x): rubi.append(6029) return -Dist(p/n, Int(log(b*x)**(p + S(-1))*cosh(a*x**n*log(b*x)**p), x), x) + Dist((n + S(-1))/(a*n), Int(x**(-n)*sinh(a*x**n*log(b*x)**p), x), x) + Simp(x**(-n + S(1))*sinh(a*x**n*log(b*x)**p)/(a*n), x) rule6029 = ReplacementRule(pattern6029, replacement6029) pattern6030 = Pattern(Integral(x_**WC('m', S(1))*log(x_*WC('b', S(1)))**WC('p', S(1))*sinh(x_**WC('n', S(1))*WC('a', S(1))*log(x_*WC('b', S(1)))**WC('p', S(1))), x_), cons2, cons3, cons21, cons4, cons53, cons13, cons163) def replacement6030(p, m, b, a, n, x): rubi.append(6030) return -Dist(p/n, Int(x**(n + S(-1))*log(b*x)**(p + S(-1))*sinh(a*x**n*log(b*x)**p), x), x) - Simp(cosh(a*x**n*log(b*x)**p)/(a*n), x) rule6030 = ReplacementRule(pattern6030, replacement6030) pattern6031 = Pattern(Integral(x_**WC('m', S(1))*log(x_*WC('b', S(1)))**WC('p', S(1))*cosh(x_**WC('n', S(1))*WC('a', S(1))*log(x_*WC('b', S(1)))**WC('p', S(1))), x_), cons2, cons3, cons21, cons4, cons53, cons13, cons163) def replacement6031(p, m, b, a, n, x): rubi.append(6031) return -Dist(p/n, Int(x**(n + S(-1))*log(b*x)**(p + S(-1))*cosh(a*x**n*log(b*x)**p), x), x) + Simp(sinh(a*x**n*log(b*x)**p)/(a*n), x) rule6031 = ReplacementRule(pattern6031, replacement6031) pattern6032 = Pattern(Integral(x_**m_*log(x_*WC('b', S(1)))**WC('p', S(1))*sinh(x_**WC('n', S(1))*WC('a', S(1))*log(x_*WC('b', S(1)))**WC('p', S(1))), x_), cons2, cons3, cons162, cons163, cons627) def replacement6032(p, m, b, a, n, x): rubi.append(6032) return -Dist(p/n, Int(x**m*log(b*x)**(p + S(-1))*sinh(a*x**n*log(b*x)**p), x), x) - Dist((m - n + S(1))/(a*n), Int(x**(m - n)*cosh(a*x**n*log(b*x)**p), x), x) + Simp(x**(m - n + S(1))*cosh(a*x**n*log(b*x)**p)/(a*n), x) rule6032 = ReplacementRule(pattern6032, replacement6032) pattern6033 = Pattern(Integral(x_**m_*log(x_*WC('b', S(1)))**WC('p', S(1))*cosh(x_**WC('n', S(1))*WC('a', S(1))*log(x_*WC('b', S(1)))**WC('p', S(1))), x_), cons2, cons3, cons162, cons163, cons627) def replacement6033(p, m, b, a, n, x): rubi.append(6033) return -Dist(p/n, Int(x**m*log(b*x)**(p + S(-1))*cosh(a*x**n*log(b*x)**p), x), x) - Dist((m - n + S(1))/(a*n), Int(x**(m - n)*sinh(a*x**n*log(b*x)**p), x), x) + Simp(x**(m - n + S(1))*sinh(a*x**n*log(b*x)**p)/(a*n), x) rule6033 = ReplacementRule(pattern6033, replacement6033) pattern6034 = Pattern(Integral(sinh(WC('a', S(1))/(x_*WC('d', S(1)) + WC('c', S(0))))**WC('n', S(1)), x_), cons2, cons7, cons27, cons148) def replacement6034(d, a, n, c, x): rubi.append(6034) return -Dist(S(1)/d, Subst(Int(sinh(a*x)**n/x**S(2), x), x, S(1)/(c + d*x)), x) rule6034 = ReplacementRule(pattern6034, replacement6034) pattern6035 = Pattern(Integral(cosh(WC('a', S(1))/(x_*WC('d', S(1)) + WC('c', S(0))))**WC('n', S(1)), x_), cons2, cons7, cons27, cons148) def replacement6035(d, a, n, c, x): rubi.append(6035) return -Dist(S(1)/d, Subst(Int(cosh(a*x)**n/x**S(2), x), x, S(1)/(c + d*x)), x) rule6035 = ReplacementRule(pattern6035, replacement6035) pattern6036 = Pattern(Integral(sinh((x_*WC('b', S(1)) + WC('a', S(0)))*WC('e', S(1))/(x_*WC('d', S(1)) + WC('c', S(0))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons148, cons71) def replacement6036(b, d, c, a, n, x, e): rubi.append(6036) return -Dist(S(1)/d, Subst(Int(sinh(b*e/d - e*x*(-a*d + b*c)/d)**n/x**S(2), x), x, S(1)/(c + d*x)), x) rule6036 = ReplacementRule(pattern6036, replacement6036) pattern6037 = Pattern(Integral(cosh((x_*WC('b', S(1)) + WC('a', S(0)))*WC('e', S(1))/(x_*WC('d', S(1)) + WC('c', S(0))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons148, cons71) def replacement6037(b, d, c, a, n, x, e): rubi.append(6037) return -Dist(S(1)/d, Subst(Int(cosh(b*e/d - e*x*(-a*d + b*c)/d)**n/x**S(2), x), x, S(1)/(c + d*x)), x) rule6037 = ReplacementRule(pattern6037, replacement6037) def With6038(x, n, u): lst = QuotientOfLinearsParts(u, x) rubi.append(6038) return Int(sinh((x*Part(lst, S(2)) + Part(lst, S(1)))/(x*Part(lst, S(4)) + Part(lst, S(3))))**n, x) pattern6038 = Pattern(Integral(sinh(u_)**WC('n', S(1)), x_), cons148, cons1725) rule6038 = ReplacementRule(pattern6038, With6038) def With6039(x, n, u): lst = QuotientOfLinearsParts(u, x) rubi.append(6039) return Int(cosh((x*Part(lst, S(2)) + Part(lst, S(1)))/(x*Part(lst, S(4)) + Part(lst, S(3))))**n, x) pattern6039 = Pattern(Integral(cosh(u_)**WC('n', S(1)), x_), cons148, cons1725) rule6039 = ReplacementRule(pattern6039, With6039) pattern6040 = Pattern(Integral(WC('u', S(1))*sinh(v_)**WC('p', S(1))*sinh(w_)**WC('q', S(1)), x_), cons1688) def replacement6040(v, w, p, u, x, q): rubi.append(6040) return Int(u*sinh(v)**(p + q), x) rule6040 = ReplacementRule(pattern6040, replacement6040) pattern6041 = Pattern(Integral(WC('u', S(1))*cosh(v_)**WC('p', S(1))*cosh(w_)**WC('q', S(1)), x_), cons1688) def replacement6041(v, w, p, u, x, q): rubi.append(6041) return Int(u*cosh(v)**(p + q), x) rule6041 = ReplacementRule(pattern6041, replacement6041) pattern6042 = Pattern(Integral(sinh(v_)**WC('p', S(1))*sinh(w_)**WC('q', S(1)), x_), cons555, cons1726) def replacement6042(v, w, p, x, q): rubi.append(6042) return Int(ExpandTrigReduce(sinh(v)**p*sinh(w)**q, x), x) rule6042 = ReplacementRule(pattern6042, replacement6042) pattern6043 = Pattern(Integral(cosh(v_)**WC('p', S(1))*cosh(w_)**WC('q', S(1)), x_), cons555, cons1726) def replacement6043(v, w, p, x, q): rubi.append(6043) return Int(ExpandTrigReduce(cosh(v)**p*cosh(w)**q, x), x) rule6043 = ReplacementRule(pattern6043, replacement6043) pattern6044 = Pattern(Integral(x_**WC('m', S(1))*sinh(v_)**WC('p', S(1))*sinh(w_)**WC('q', S(1)), x_), cons1727, cons1726) def replacement6044(v, w, p, m, x, q): rubi.append(6044) return Int(ExpandTrigReduce(x**m, sinh(v)**p*sinh(w)**q, x), x) rule6044 = ReplacementRule(pattern6044, replacement6044) pattern6045 = Pattern(Integral(x_**WC('m', S(1))*cosh(v_)**WC('p', S(1))*cosh(w_)**WC('q', S(1)), x_), cons1727, cons1726) def replacement6045(v, w, p, m, x, q): rubi.append(6045) return Int(ExpandTrigReduce(x**m, cosh(v)**p*cosh(w)**q, x), x) rule6045 = ReplacementRule(pattern6045, replacement6045) pattern6046 = Pattern(Integral(WC('u', S(1))*sinh(v_)**WC('p', S(1))*cosh(w_)**WC('p', S(1)), x_), cons1688, cons38) def replacement6046(v, w, p, u, x): rubi.append(6046) return Dist(S(2)**(-p), Int(u*sinh(S(2)*v)**p, x), x) rule6046 = ReplacementRule(pattern6046, replacement6046) pattern6047 = Pattern(Integral(sinh(v_)**WC('p', S(1))*cosh(w_)**WC('q', S(1)), x_), cons555, cons1726) def replacement6047(v, w, p, x, q): rubi.append(6047) return Int(ExpandTrigReduce(sinh(v)**p*cosh(w)**q, x), x) rule6047 = ReplacementRule(pattern6047, replacement6047) pattern6048 = Pattern(Integral(x_**WC('m', S(1))*sinh(v_)**WC('p', S(1))*cosh(w_)**WC('q', S(1)), x_), cons1727, cons1726) def replacement6048(v, w, p, m, x, q): rubi.append(6048) return Int(ExpandTrigReduce(x**m, sinh(v)**p*cosh(w)**q, x), x) rule6048 = ReplacementRule(pattern6048, replacement6048) pattern6049 = Pattern(Integral(sinh(v_)*tanh(w_)**WC('n', S(1)), x_), cons87, cons88, cons1728) def replacement6049(v, w, n, x): rubi.append(6049) return -Dist(cosh(v - w), Int(tanh(w)**(n + S(-1))/cosh(w), x), x) + Int(cosh(v)*tanh(w)**(n + S(-1)), x) rule6049 = ReplacementRule(pattern6049, replacement6049) pattern6050 = Pattern(Integral((S(1)/tanh(w_))**WC('n', S(1))*cosh(v_), x_), cons87, cons88, cons1728) def replacement6050(v, w, n, x): rubi.append(6050) return Dist(cosh(v - w), Int((S(1)/tanh(w))**(n + S(-1))/sinh(w), x), x) + Int((S(1)/tanh(w))**(n + S(-1))*sinh(v), x) rule6050 = ReplacementRule(pattern6050, replacement6050) pattern6051 = Pattern(Integral((S(1)/tanh(w_))**WC('n', S(1))*sinh(v_), x_), cons87, cons88, cons1728) def replacement6051(v, w, n, x): rubi.append(6051) return Dist(sinh(v - w), Int((S(1)/tanh(w))**(n + S(-1))/sinh(w), x), x) + Int((S(1)/tanh(w))**(n + S(-1))*cosh(v), x) rule6051 = ReplacementRule(pattern6051, replacement6051) pattern6052 = Pattern(Integral(cosh(v_)*tanh(w_)**WC('n', S(1)), x_), cons87, cons88, cons1728) def replacement6052(v, w, n, x): rubi.append(6052) return -Dist(sinh(v - w), Int(tanh(w)**(n + S(-1))/cosh(w), x), x) + Int(sinh(v)*tanh(w)**(n + S(-1)), x) rule6052 = ReplacementRule(pattern6052, replacement6052) pattern6053 = Pattern(Integral((S(1)/cosh(w_))**WC('n', S(1))*sinh(v_), x_), cons87, cons88, cons1728) def replacement6053(v, w, n, x): rubi.append(6053) return Dist(sinh(v - w), Int((S(1)/cosh(w))**(n + S(-1)), x), x) + Dist(cosh(v - w), Int((S(1)/cosh(w))**(n + S(-1))*tanh(w), x), x) rule6053 = ReplacementRule(pattern6053, replacement6053) pattern6054 = Pattern(Integral((S(1)/sinh(w_))**WC('n', S(1))*cosh(v_), x_), cons87, cons88, cons1728) def replacement6054(v, w, n, x): rubi.append(6054) return Dist(sinh(v - w), Int((S(1)/sinh(w))**(n + S(-1)), x), x) + Dist(cosh(v - w), Int((S(1)/sinh(w))**(n + S(-1))/tanh(w), x), x) rule6054 = ReplacementRule(pattern6054, replacement6054) pattern6055 = Pattern(Integral((S(1)/sinh(w_))**WC('n', S(1))*sinh(v_), x_), cons87, cons88, cons1728) def replacement6055(v, w, n, x): rubi.append(6055) return Dist(sinh(v - w), Int((S(1)/sinh(w))**(n + S(-1))/tanh(w), x), x) + Dist(cosh(v - w), Int((S(1)/sinh(w))**(n + S(-1)), x), x) rule6055 = ReplacementRule(pattern6055, replacement6055) pattern6056 = Pattern(Integral((S(1)/cosh(w_))**WC('n', S(1))*cosh(v_), x_), cons87, cons88, cons1728) def replacement6056(v, w, n, x): rubi.append(6056) return Dist(sinh(v - w), Int((S(1)/cosh(w))**(n + S(-1))*tanh(w), x), x) + Dist(cosh(v - w), Int((S(1)/cosh(w))**(n + S(-1)), x), x) rule6056 = ReplacementRule(pattern6056, replacement6056) pattern6057 = Pattern(Integral((a_ + WC('b', S(1))*sinh(x_*WC('d', S(1)) + WC('c', S(0)))*cosh(x_*WC('d', S(1)) + WC('c', S(0))))**WC('n', S(1))*(x_*WC('f', S(1)) + WC('e', S(0)))**WC('m', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons4, cons1360) def replacement6057(m, f, b, d, c, n, a, x, e): rubi.append(6057) return Int((a + b*sinh(S(2)*c + S(2)*d*x)/S(2))**n*(e + f*x)**m, x) rule6057 = ReplacementRule(pattern6057, replacement6057) pattern6058 = Pattern(Integral(x_**WC('m', S(1))*(a_ + WC('b', S(1))*sinh(x_*WC('d', S(1)) + WC('c', S(0)))**S(2))**n_, x_), cons2, cons3, cons7, cons27, cons1456, cons150, cons168, cons463, cons1729) def replacement6058(m, b, d, c, a, n, x): rubi.append(6058) return Dist(S(2)**(-n), Int(x**m*(S(2)*a + b*cosh(S(2)*c + S(2)*d*x) - b)**n, x), x) rule6058 = ReplacementRule(pattern6058, replacement6058) pattern6059 = Pattern(Integral(x_**WC('m', S(1))*(a_ + WC('b', S(1))*cosh(x_*WC('d', S(1)) + WC('c', S(0)))**S(2))**n_, x_), cons2, cons3, cons7, cons27, cons1478, cons150, cons168, cons463, cons1729) def replacement6059(m, b, d, c, a, n, x): rubi.append(6059) return Dist(S(2)**(-n), Int(x**m*(S(2)*a + b*cosh(S(2)*c + S(2)*d*x) + b)**n, x), x) rule6059 = ReplacementRule(pattern6059, replacement6059) pattern6060 = Pattern(Integral((x_*WC('f', S(1)) + WC('e', S(0)))**WC('m', S(1))*sinh((c_ + x_*WC('d', S(1)))**n_*WC('b', S(1)) + WC('a', S(0)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons4, cons62, cons13) def replacement6060(p, m, f, b, d, a, c, n, x, e): rubi.append(6060) return Dist(d**(-m + S(-1)), Subst(Int((-c*f + d*e + f*x)**m*sinh(a + b*x**n)**p, x), x, c + d*x), x) rule6060 = ReplacementRule(pattern6060, replacement6060) pattern6061 = Pattern(Integral((x_*WC('f', S(1)) + WC('e', S(0)))**WC('m', S(1))*cosh((c_ + x_*WC('d', S(1)))**n_*WC('b', S(1)) + WC('a', S(0)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons4, cons62, cons13) def replacement6061(p, m, f, b, d, a, c, n, x, e): rubi.append(6061) return Dist(d**(-m + S(-1)), Subst(Int((-c*f + d*e + f*x)**m*cosh(a + b*x**n)**p, x), x, c + d*x), x) rule6061 = ReplacementRule(pattern6061, replacement6061) pattern6062 = Pattern(Integral((x_*WC('g', S(1)) + WC('f', S(0)))**WC('m', S(1))/(WC('a', S(0)) + WC('b', S(1))*cosh(x_*WC('e', S(1)) + WC('d', S(0)))**S(2) + WC('c', S(1))*sinh(x_*WC('e', S(1)) + WC('d', S(0)))**S(2)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons62, cons1478, cons1730) def replacement6062(m, f, g, b, d, a, c, x, e): rubi.append(6062) return Dist(S(2), Int((f + g*x)**m/(S(2)*a + b - c + (b + c)*cosh(S(2)*d + S(2)*e*x)), x), x) rule6062 = ReplacementRule(pattern6062, replacement6062) pattern6063 = Pattern(Integral((x_*WC('g', S(1)) + WC('f', S(0)))**WC('m', S(1))/((b_ + WC('c', S(1))*tanh(x_*WC('e', S(1)) + WC('d', S(0)))**S(2))*cosh(x_*WC('e', S(1)) + WC('d', S(0)))**S(2)), x_), cons3, cons7, cons27, cons48, cons125, cons208, cons62) def replacement6063(m, f, g, b, d, c, x, e): rubi.append(6063) return Dist(S(2), Int((f + g*x)**m/(b - c + (b + c)*cosh(S(2)*d + S(2)*e*x)), x), x) rule6063 = ReplacementRule(pattern6063, replacement6063) pattern6064 = Pattern(Integral((x_*WC('g', S(1)) + WC('f', S(0)))**WC('m', S(1))/((WC('a', S(1))/cosh(x_*WC('e', S(1)) + WC('d', S(0)))**S(2) + WC('b', S(0)) + WC('c', S(1))*tanh(x_*WC('e', S(1)) + WC('d', S(0)))**S(2))*cosh(x_*WC('e', S(1)) + WC('d', S(0)))**S(2)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons62, cons1478, cons1730) def replacement6064(m, f, g, b, d, a, c, x, e): rubi.append(6064) return Dist(S(2), Int((f + g*x)**m/(S(2)*a + b - c + (b + c)*cosh(S(2)*d + S(2)*e*x)), x), x) rule6064 = ReplacementRule(pattern6064, replacement6064) pattern6065 = Pattern(Integral((x_*WC('g', S(1)) + WC('f', S(0)))**WC('m', S(1))/((c_ + WC('b', S(1))/tanh(x_*WC('e', S(1)) + WC('d', S(0)))**S(2))*sinh(x_*WC('e', S(1)) + WC('d', S(0)))**S(2)), x_), cons3, cons7, cons27, cons48, cons125, cons208, cons62) def replacement6065(m, f, b, g, d, c, x, e): rubi.append(6065) return Dist(S(2), Int((f + g*x)**m/(b - c + (b + c)*cosh(S(2)*d + S(2)*e*x)), x), x) rule6065 = ReplacementRule(pattern6065, replacement6065) pattern6066 = Pattern(Integral((x_*WC('g', S(1)) + WC('f', S(0)))**WC('m', S(1))/((WC('a', S(1))/sinh(x_*WC('e', S(1)) + WC('d', S(0)))**S(2) + WC('b', S(1))/tanh(x_*WC('e', S(1)) + WC('d', S(0)))**S(2) + WC('c', S(0)))*sinh(x_*WC('e', S(1)) + WC('d', S(0)))**S(2)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons62, cons1478, cons1730) def replacement6066(m, f, b, g, d, c, a, x, e): rubi.append(6066) return Dist(S(2), Int((f + g*x)**m/(S(2)*a + b - c + (b + c)*cosh(S(2)*d + S(2)*e*x)), x), x) rule6066 = ReplacementRule(pattern6066, replacement6066) pattern6067 = Pattern(Integral((x_*WC('f', S(1)) + WC('e', S(0)))**WC('m', S(1))*cosh(x_*WC('d', S(1)) + WC('c', S(0)))/(a_ + WC('b', S(1))*sinh(x_*WC('d', S(1)) + WC('c', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons62) def replacement6067(m, f, b, d, c, a, x, e): rubi.append(6067) return Int((e + f*x)**m*exp(c + d*x)/(a + b*exp(c + d*x) - Rt(a**S(2) + b**S(2), S(2))), x) + Int((e + f*x)**m*exp(c + d*x)/(a + b*exp(c + d*x) + Rt(a**S(2) + b**S(2), S(2))), x) - Simp((e + f*x)**(m + S(1))/(b*f*(m + S(1))), x) rule6067 = ReplacementRule(pattern6067, replacement6067) pattern6068 = Pattern(Integral((x_*WC('f', S(1)) + WC('e', S(0)))**WC('m', S(1))*sinh(x_*WC('d', S(1)) + WC('c', S(0)))/(a_ + WC('b', S(1))*cosh(x_*WC('d', S(1)) + WC('c', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons62) def replacement6068(m, f, b, d, c, a, x, e): rubi.append(6068) return Int((e + f*x)**m*exp(c + d*x)/(a + b*exp(c + d*x) - Rt(a**S(2) - b**S(2), S(2))), x) + Int((e + f*x)**m*exp(c + d*x)/(a + b*exp(c + d*x) + Rt(a**S(2) - b**S(2), S(2))), x) - Simp((e + f*x)**(m + S(1))/(b*f*(m + S(1))), x) rule6068 = ReplacementRule(pattern6068, replacement6068) pattern6069 = Pattern(Integral((x_*WC('f', S(1)) + WC('e', S(0)))**WC('m', S(1))*cosh(x_*WC('d', S(1)) + WC('c', S(0)))**n_/(a_ + WC('b', S(1))*sinh(x_*WC('d', S(1)) + WC('c', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons62, cons85, cons165, cons1439) def replacement6069(m, f, b, d, c, n, a, x, e): rubi.append(6069) return Dist(S(1)/a, Int((e + f*x)**m*cosh(c + d*x)**(n + S(-2)), x), x) + Dist(S(1)/b, Int((e + f*x)**m*sinh(c + d*x)*cosh(c + d*x)**(n + S(-2)), x), x) rule6069 = ReplacementRule(pattern6069, replacement6069) pattern6070 = Pattern(Integral((x_*WC('f', S(1)) + WC('e', S(0)))**WC('m', S(1))*sinh(x_*WC('d', S(1)) + WC('c', S(0)))**n_/(a_ + WC('b', S(1))*cosh(x_*WC('d', S(1)) + WC('c', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons62, cons85, cons165, cons1265) def replacement6070(m, f, b, d, c, a, n, x, e): rubi.append(6070) return Dist(S(1)/a, Int((e + f*x)**m*sinh(c + d*x)**(n + S(-2)), x), x) + Dist(S(1)/b, Int((e + f*x)**m*sinh(c + d*x)**(n + S(-2))*cosh(c + d*x), x), x) rule6070 = ReplacementRule(pattern6070, replacement6070) pattern6071 = Pattern(Integral((x_*WC('f', S(1)) + WC('e', S(0)))**WC('m', S(1))*cosh(x_*WC('d', S(1)) + WC('c', S(0)))**n_/(a_ + WC('b', S(1))*sinh(x_*WC('d', S(1)) + WC('c', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons62, cons85, cons165, cons1440) def replacement6071(m, f, b, d, c, n, a, x, e): rubi.append(6071) return Dist(S(1)/b, Int((e + f*x)**m*sinh(c + d*x)*cosh(c + d*x)**(n + S(-2)), x), x) - Dist(a/b**S(2), Int((e + f*x)**m*cosh(c + d*x)**(n + S(-2)), x), x) + Dist((a**S(2) + b**S(2))/b**S(2), Int((e + f*x)**m*cosh(c + d*x)**(n + S(-2))/(a + b*sinh(c + d*x)), x), x) rule6071 = ReplacementRule(pattern6071, replacement6071) pattern6072 = Pattern(Integral((x_*WC('f', S(1)) + WC('e', S(0)))**WC('m', S(1))*sinh(x_*WC('d', S(1)) + WC('c', S(0)))**n_/(a_ + WC('b', S(1))*cosh(x_*WC('d', S(1)) + WC('c', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons62, cons85, cons165, cons1267) def replacement6072(m, f, b, d, c, a, n, x, e): rubi.append(6072) return Dist(S(1)/b, Int((e + f*x)**m*sinh(c + d*x)**(n + S(-2))*cosh(c + d*x), x), x) - Dist(a/b**S(2), Int((e + f*x)**m*sinh(c + d*x)**(n + S(-2)), x), x) + Dist((a**S(2) - b**S(2))/b**S(2), Int((e + f*x)**m*sinh(c + d*x)**(n + S(-2))/(a + b*cosh(c + d*x)), x), x) rule6072 = ReplacementRule(pattern6072, replacement6072) pattern6073 = Pattern(Integral((A_ + WC('B', S(1))*sinh(x_*WC('d', S(1)) + WC('c', S(0))))*(x_*WC('f', S(1)) + WC('e', S(0)))/(a_ + WC('b', S(1))*sinh(x_*WC('d', S(1)) + WC('c', S(0))))**S(2), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons1891) def replacement6073(B, f, b, d, c, a, A, x, e): rubi.append(6073) return -Dist(B*f/(a*d), Int(cosh(c + d*x)/(a + b*sinh(c + d*x)), x), x) + Simp(B*(e + f*x)*cosh(c + d*x)/(a*d*(a + b*sinh(c + d*x))), x) rule6073 = ReplacementRule(pattern6073, replacement6073) pattern6074 = Pattern(Integral((A_ + WC('B', S(1))*cosh(x_*WC('d', S(1)) + WC('c', S(0))))*(x_*WC('f', S(1)) + WC('e', S(0)))/(a_ + WC('b', S(1))*cosh(x_*WC('d', S(1)) + WC('c', S(0))))**S(2), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons1474) def replacement6074(B, f, b, d, c, a, A, x, e): rubi.append(6074) return -Dist(B*f/(a*d), Int(sinh(c + d*x)/(a + b*cosh(c + d*x)), x), x) + Simp(B*(e + f*x)*sinh(c + d*x)/(a*d*(a + b*cosh(c + d*x))), x) rule6074 = ReplacementRule(pattern6074, replacement6074) pattern6075 = Pattern(Integral((a_ + WC('b', S(1))*tanh(v_))**WC('n', S(1))*(S(1)/cosh(v_))**WC('m', S(1)), x_), cons2, cons3, cons150, cons1551, cons1481) def replacement6075(v, m, b, a, n, x): rubi.append(6075) return Int((a*cosh(v) + b*sinh(v))**n, x) rule6075 = ReplacementRule(pattern6075, replacement6075) pattern6076 = Pattern(Integral((a_ + WC('b', S(1))/tanh(v_))**WC('n', S(1))*(S(1)/sinh(v_))**WC('m', S(1)), x_), cons2, cons3, cons150, cons1551, cons1481) def replacement6076(v, m, b, a, n, x): rubi.append(6076) return Int((a*sinh(v) + b*cosh(v))**n, x) rule6076 = ReplacementRule(pattern6076, replacement6076) pattern6077 = Pattern(Integral(WC('u', S(1))*sinh(x_*WC('b', S(1)) + WC('a', S(0)))**WC('m', S(1))*sinh(x_*WC('d', S(1)) + WC('c', S(0)))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons528) def replacement6077(u, m, b, d, a, c, n, x): rubi.append(6077) return Int(ExpandTrigReduce(u, sinh(a + b*x)**m*sinh(c + d*x)**n, x), x) rule6077 = ReplacementRule(pattern6077, replacement6077) pattern6078 = Pattern(Integral(WC('u', S(1))*cosh(x_*WC('b', S(1)) + WC('a', S(0)))**WC('m', S(1))*cosh(x_*WC('d', S(1)) + WC('c', S(0)))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons528) def replacement6078(u, m, b, d, a, c, n, x): rubi.append(6078) return Int(ExpandTrigReduce(u, cosh(a + b*x)**m*cosh(c + d*x)**n, x), x) rule6078 = ReplacementRule(pattern6078, replacement6078) pattern6079 = Pattern(Integral(S(1)/(cosh(c_ + x_*WC('d', S(1)))*cosh(x_*WC('b', S(1)) + WC('a', S(0)))), x_), cons2, cons3, cons7, cons27, cons1733, cons71) def replacement6079(b, d, c, a, x): rubi.append(6079) return Dist(S(1)/sinh((-a*d + b*c)/b), Int(tanh(c + d*x), x), x) - Dist(S(1)/sinh((-a*d + b*c)/d), Int(tanh(a + b*x), x), x) rule6079 = ReplacementRule(pattern6079, replacement6079) pattern6080 = Pattern(Integral(S(1)/(sinh(c_ + x_*WC('d', S(1)))*sinh(x_*WC('b', S(1)) + WC('a', S(0)))), x_), cons2, cons3, cons7, cons27, cons1733, cons71) def replacement6080(b, d, c, a, x): rubi.append(6080) return Dist(S(1)/sinh((-a*d + b*c)/b), Int(S(1)/tanh(a + b*x), x), x) - Dist(S(1)/sinh((-a*d + b*c)/d), Int(S(1)/tanh(c + d*x), x), x) rule6080 = ReplacementRule(pattern6080, replacement6080) pattern6081 = Pattern(Integral(tanh(c_ + x_*WC('d', S(1)))*tanh(x_*WC('b', S(1)) + WC('a', S(0))), x_), cons2, cons3, cons7, cons27, cons1733, cons71) def replacement6081(b, d, c, a, x): rubi.append(6081) return -Dist(b*cosh((-a*d + b*c)/d)/d, Int(S(1)/(cosh(a + b*x)*cosh(c + d*x)), x), x) + Simp(b*x/d, x) rule6081 = ReplacementRule(pattern6081, replacement6081) pattern6082 = Pattern(Integral(S(1)/(tanh(c_ + x_*WC('d', S(1)))*tanh(x_*WC('b', S(1)) + WC('a', S(0)))), x_), cons2, cons3, cons7, cons27, cons1733, cons71) def replacement6082(b, d, c, a, x): rubi.append(6082) return Dist(cosh((-a*d + b*c)/d), Int(S(1)/(sinh(a + b*x)*sinh(c + d*x)), x), x) + Simp(b*x/d, x) rule6082 = ReplacementRule(pattern6082, replacement6082) pattern6083 = Pattern(Integral((WC('a', S(1))*cosh(v_) + WC('b', S(1))*sinh(v_))**WC('n', S(1))*WC('u', S(1)), x_), cons2, cons3, cons4, cons1265) def replacement6083(v, u, b, a, n, x): rubi.append(6083) return Int(u*(a*exp(a*v/b))**n, x) rule6083 = ReplacementRule(pattern6083, replacement6083) return [rule5643, rule5644, rule5645, rule5646, rule5647, rule5648, rule5649, rule5650, rule5651, rule5652, rule5653, rule5654, rule5655, rule5656, rule5657, rule5658, rule5659, rule5660, rule5661, rule5662, rule5663, rule5664, rule5665, rule5666, rule5667, rule5668, rule5669, rule5670, rule5671, rule5672, rule5673, rule5674, rule5675, rule5676, rule5677, rule5678, rule5679, rule5680, rule5681, rule5682, rule5683, rule5684, rule5685, rule5686, rule5687, rule5688, rule5689, rule5690, rule5691, rule5692, rule5693, rule5694, rule5695, rule5696, rule5697, rule5698, rule5699, rule5700, rule5701, rule5702, rule5703, rule5704, rule5705, rule5706, rule5707, rule5708, rule5709, rule5710, rule5711, rule5712, rule5713, rule5714, rule5715, rule5716, rule5717, rule5718, rule5719, rule5720, rule5721, rule5722, rule5723, rule5724, rule5725, rule5726, rule5727, rule5728, rule5729, rule5730, rule5731, rule5732, rule5733, rule5734, rule5735, rule5736, rule5737, rule5738, rule5739, rule5740, rule5741, rule5742, rule5743, rule5744, rule5745, rule5746, rule5747, rule5748, rule5749, rule5750, rule5751, rule5752, rule5753, rule5754, rule5755, rule5756, rule5757, rule5758, rule5759, rule5760, rule5761, rule5762, rule5763, rule5764, rule5765, rule5766, rule5767, rule5768, rule5769, rule5770, rule5771, rule5772, rule5773, rule5774, rule5775, rule5776, rule5777, rule5778, rule5779, rule5780, rule5781, rule5782, rule5783, rule5784, rule5785, rule5786, rule5787, rule5788, rule5789, rule5790, rule5791, rule5792, rule5793, rule5794, rule5795, rule5796, rule5797, rule5798, rule5799, rule5800, rule5801, rule5802, rule5803, rule5804, rule5805, rule5806, rule5807, rule5808, rule5809, rule5810, rule5811, rule5812, rule5813, rule5814, rule5815, rule5816, rule5817, rule5818, rule5819, rule5820, rule5821, rule5822, rule5823, rule5824, rule5825, rule5826, rule5827, rule5828, rule5829, rule5830, rule5831, rule5832, rule5833, rule5834, rule5835, rule5836, rule5837, rule5838, rule5839, rule5840, rule5841, rule5842, rule5843, rule5844, rule5845, rule5846, rule5847, rule5848, rule5849, rule5850, rule5851, rule5852, rule5853, rule5854, rule5855, rule5856, rule5857, rule5858, rule5859, rule5860, rule5861, rule5862, rule5863, rule5864, rule5865, rule5866, rule5867, rule5868, rule5869, rule5870, rule5871, rule5872, rule5873, rule5874, rule5875, rule5876, rule5877, rule5878, rule5879, rule5880, rule5881, rule5882, rule5883, rule5884, rule5885, rule5886, rule5887, rule5888, rule5889, rule5890, rule5891, rule5892, rule5893, rule5894, rule5895, rule5896, rule5897, rule5898, rule5899, rule5900, rule5901, rule5902, rule5903, rule5904, rule5905, rule5906, rule5907, rule5908, rule5909, rule5910, rule5911, rule5912, rule5913, rule5914, rule5915, rule5916, rule5917, rule5918, rule5919, rule5920, rule5921, rule5922, rule5923, rule5924, rule5925, rule5926, rule5927, rule5928, rule5929, rule5930, rule5931, rule5932, rule5933, rule5934, rule5935, rule5936, rule5937, rule5938, rule5939, rule5940, rule5941, rule5942, rule5943, rule5944, rule5945, rule5946, rule5947, rule5948, rule5949, rule5950, rule5951, rule5952, rule5953, rule5954, rule5955, rule5956, rule5957, rule5958, rule5959, rule5960, rule5961, rule5962, rule5963, rule5964, rule5965, rule5966, rule5967, rule5968, rule5969, rule5970, rule5971, rule5972, rule5973, rule5974, rule5975, rule5976, rule5977, rule5978, rule5979, rule5980, rule5981, rule5982, rule5983, rule5984, rule5985, rule5986, rule5987, rule5988, rule5989, rule5990, rule5991, rule5992, rule5993, rule5994, rule5995, rule5996, rule5997, rule5998, rule5999, rule6000, rule6001, rule6002, rule6003, rule6004, rule6005, rule6006, rule6007, rule6008, rule6009, rule6010, rule6011, rule6012, rule6013, rule6014, rule6015, rule6016, rule6017, rule6018, rule6019, rule6020, rule6021, rule6022, rule6023, rule6024, rule6025, rule6026, rule6027, rule6028, rule6029, rule6030, rule6031, rule6032, rule6033, rule6034, rule6035, rule6036, rule6037, rule6038, rule6039, rule6040, rule6041, rule6042, rule6043, rule6044, rule6045, rule6046, rule6047, rule6048, rule6049, rule6050, rule6051, rule6052, rule6053, rule6054, rule6055, rule6056, rule6057, rule6058, rule6059, rule6060, rule6061, rule6062, rule6063, rule6064, rule6065, rule6066, rule6067, rule6068, rule6069, rule6070, rule6071, rule6072, rule6073, rule6074, rule6075, rule6076, rule6077, rule6078, rule6079, rule6080, rule6081, rule6082, rule6083, ]
0d0723e108f47f46ff378158ae5f15e41e43a6d1d6d21edfcf0720ff9fccd604
''' This code is automatically generated. Never edit it manually. For details of generating the code see `rubi_parsing_guide.md` in `parsetools`. ''' from sympy.external import import_module matchpy = import_module("matchpy") from sympy.utilities.decorator import doctest_depends_on if matchpy: from matchpy import Pattern, ReplacementRule, CustomConstraint, is_match from sympy.integrals.rubi.utility_function import ( Int, Sum, Set, With, Module, Scan, MapAnd, FalseQ, ZeroQ, NegativeQ, NonzeroQ, FreeQ, NFreeQ, List, Log, PositiveQ, PositiveIntegerQ, NegativeIntegerQ, IntegerQ, IntegersQ, ComplexNumberQ, PureComplexNumberQ, RealNumericQ, PositiveOrZeroQ, NegativeOrZeroQ, FractionOrNegativeQ, NegQ, Equal, Unequal, IntPart, FracPart, RationalQ, ProductQ, SumQ, NonsumQ, Subst, First, Rest, SqrtNumberQ, SqrtNumberSumQ, LinearQ, Sqrt, ArcCosh, Coefficient, Denominator, Hypergeometric2F1, Not, Simplify, FractionalPart, IntegerPart, AppellF1, EllipticPi, EllipticE, EllipticF, ArcTan, ArcCot, ArcCoth, ArcTanh, ArcSin, ArcSinh, ArcCos, ArcCsc, ArcSec, ArcCsch, ArcSech, Sinh, Tanh, Cosh, Sech, Csch, Coth, LessEqual, Less, Greater, GreaterEqual, FractionQ, IntLinearcQ, Expand, IndependentQ, PowerQ, IntegerPowerQ, PositiveIntegerPowerQ, FractionalPowerQ, AtomQ, ExpQ, LogQ, Head, MemberQ, TrigQ, SinQ, CosQ, TanQ, CotQ, SecQ, CscQ, Sin, Cos, Tan, Cot, Sec, Csc, HyperbolicQ, SinhQ, CoshQ, TanhQ, CothQ, SechQ, CschQ, InverseTrigQ, SinCosQ, SinhCoshQ, LeafCount, Numerator, NumberQ, NumericQ, Length, ListQ, Im, Re, InverseHyperbolicQ, InverseFunctionQ, TrigHyperbolicFreeQ, InverseFunctionFreeQ, RealQ, EqQ, FractionalPowerFreeQ, ComplexFreeQ, PolynomialQ, FactorSquareFree, PowerOfLinearQ, Exponent, QuadraticQ, LinearPairQ, BinomialParts, TrinomialParts, PolyQ, EvenQ, OddQ, PerfectSquareQ, NiceSqrtAuxQ, NiceSqrtQ, Together, PosAux, PosQ, CoefficientList, ReplaceAll, ExpandLinearProduct, GCD, ContentFactor, NumericFactor, NonnumericFactors, MakeAssocList, GensymSubst, KernelSubst, ExpandExpression, Apart, SmartApart, MatchQ, PolynomialQuotientRemainder, FreeFactors, NonfreeFactors, RemoveContentAux, RemoveContent, FreeTerms, NonfreeTerms, ExpandAlgebraicFunction, CollectReciprocals, ExpandCleanup, AlgebraicFunctionQ, Coeff, LeadTerm, RemainingTerms, LeadFactor, RemainingFactors, LeadBase, LeadDegree, Numer, Denom, hypergeom, Expon, MergeMonomials, PolynomialDivide, BinomialQ, TrinomialQ, GeneralizedBinomialQ, GeneralizedTrinomialQ, FactorSquareFreeList, PerfectPowerTest, SquareFreeFactorTest, RationalFunctionQ, RationalFunctionFactors, NonrationalFunctionFactors, Reverse, RationalFunctionExponents, RationalFunctionExpand, ExpandIntegrand, SimplerQ, SimplerSqrtQ, SumSimplerQ, BinomialDegree, TrinomialDegree, CancelCommonFactors, SimplerIntegrandQ, GeneralizedBinomialDegree, GeneralizedBinomialParts, GeneralizedTrinomialDegree, GeneralizedTrinomialParts, MonomialQ, MonomialSumQ, MinimumMonomialExponent, MonomialExponent, LinearMatchQ, PowerOfLinearMatchQ, QuadraticMatchQ, CubicMatchQ, BinomialMatchQ, TrinomialMatchQ, GeneralizedBinomialMatchQ, GeneralizedTrinomialMatchQ, QuotientOfLinearsMatchQ, PolynomialTermQ, PolynomialTerms, NonpolynomialTerms, PseudoBinomialParts, NormalizePseudoBinomial, PseudoBinomialPairQ, PseudoBinomialQ, PolynomialGCD, PolyGCD, AlgebraicFunctionFactors, NonalgebraicFunctionFactors, QuotientOfLinearsP, QuotientOfLinearsParts, QuotientOfLinearsQ, Flatten, Sort, AbsurdNumberQ, AbsurdNumberFactors, NonabsurdNumberFactors, SumSimplerAuxQ, Prepend, Drop, CombineExponents, FactorInteger, FactorAbsurdNumber, SubstForInverseFunction, SubstForFractionalPower, SubstForFractionalPowerOfQuotientOfLinears, FractionalPowerOfQuotientOfLinears, SubstForFractionalPowerQ, SubstForFractionalPowerAuxQ, FractionalPowerOfSquareQ, FractionalPowerSubexpressionQ, Apply, FactorNumericGcd, MergeableFactorQ, MergeFactor, MergeFactors, TrigSimplifyQ, TrigSimplify, TrigSimplifyRecur, Order, FactorOrder, Smallest, OrderedQ, MinimumDegree, PositiveFactors, Sign, NonpositiveFactors, PolynomialInAuxQ, PolynomialInQ, ExponentInAux, ExponentIn, PolynomialInSubstAux, PolynomialInSubst, Distrib, DistributeDegree, FunctionOfPower, DivideDegreesOfFactors, MonomialFactor, FullSimplify, FunctionOfLinearSubst, FunctionOfLinear, NormalizeIntegrand, NormalizeIntegrandAux, NormalizeIntegrandFactor, NormalizeIntegrandFactorBase, NormalizeTogether, NormalizeLeadTermSigns, AbsorbMinusSign, NormalizeSumFactors, SignOfFactor, NormalizePowerOfLinear, SimplifyIntegrand, SimplifyTerm, TogetherSimplify, SmartSimplify, SubstForExpn, ExpandToSum, UnifySum, UnifyTerms, UnifyTerm, CalculusQ, FunctionOfInverseLinear, PureFunctionOfSinhQ, PureFunctionOfTanhQ, PureFunctionOfCoshQ, IntegerQuotientQ, OddQuotientQ, EvenQuotientQ, FindTrigFactor, FunctionOfSinhQ, FunctionOfCoshQ, OddHyperbolicPowerQ, FunctionOfTanhQ, FunctionOfTanhWeight, FunctionOfHyperbolicQ, SmartNumerator, SmartDenominator, SubstForAux, ActivateTrig, ExpandTrig, TrigExpand, SubstForTrig, SubstForHyperbolic, InertTrigFreeQ, LCM, SubstForFractionalPowerOfLinear, FractionalPowerOfLinear, InverseFunctionOfLinear, InertTrigQ, InertReciprocalQ, DeactivateTrig, FixInertTrigFunction, DeactivateTrigAux, PowerOfInertTrigSumQ, PiecewiseLinearQ, KnownTrigIntegrandQ, KnownSineIntegrandQ, KnownTangentIntegrandQ, KnownCotangentIntegrandQ, KnownSecantIntegrandQ, TryPureTanSubst, TryTanhSubst, TryPureTanhSubst, AbsurdNumberGCD, AbsurdNumberGCDList, ExpandTrigExpand, ExpandTrigReduce, ExpandTrigReduceAux, NormalizeTrig, TrigToExp, ExpandTrigToExp, TrigReduce, FunctionOfTrig, AlgebraicTrigFunctionQ, FunctionOfHyperbolic, FunctionOfQ, FunctionOfExpnQ, PureFunctionOfSinQ, PureFunctionOfCosQ, PureFunctionOfTanQ, PureFunctionOfCotQ, FunctionOfCosQ, FunctionOfSinQ, OddTrigPowerQ, FunctionOfTanQ, FunctionOfTanWeight, FunctionOfTrigQ, FunctionOfDensePolynomialsQ, FunctionOfLog, PowerVariableExpn, PowerVariableDegree, PowerVariableSubst, EulerIntegrandQ, FunctionOfSquareRootOfQuadratic, SquareRootOfQuadraticSubst, Divides, EasyDQ, ProductOfLinearPowersQ, Rt, NthRoot, AtomBaseQ, SumBaseQ, NegSumBaseQ, AllNegTermQ, SomeNegTermQ, TrigSquareQ, RtAux, TrigSquare, IntSum, IntTerm, Map2, ConstantFactor, SameQ, ReplacePart, CommonFactors, MostMainFactorPosition, FunctionOfExponentialQ, FunctionOfExponential, FunctionOfExponentialFunction, FunctionOfExponentialFunctionAux, FunctionOfExponentialTest, FunctionOfExponentialTestAux, stdev, rubi_test, If, IntQuadraticQ, IntBinomialQ, RectifyTangent, RectifyCotangent, Inequality, Condition, Simp, SimpHelp, SplitProduct, SplitSum, SubstFor, SubstForAux, FresnelS, FresnelC, Erfc, Erfi, Gamma, FunctionOfTrigOfLinearQ, ElementaryFunctionQ, Complex, UnsameQ, _SimpFixFactor, SimpFixFactor, _FixSimplify, FixSimplify, _SimplifyAntiderivativeSum, SimplifyAntiderivativeSum, _SimplifyAntiderivative, SimplifyAntiderivative, _TrigSimplifyAux, TrigSimplifyAux, Cancel, Part, PolyLog, D, Dist, Sum_doit, PolynomialQuotient, Floor, PolynomialRemainder, Factor, PolyLog, CosIntegral, SinIntegral, LogIntegral, SinhIntegral, CoshIntegral, Rule, Erf, PolyGamma, ExpIntegralEi, ExpIntegralE, LogGamma , UtilityOperator, Factorial, Zeta, ProductLog, DerivativeDivides, HypergeometricPFQ, IntHide, OneQ, Null, rubi_exp as exp, rubi_log as log, Discriminant, Negative, Quotient ) from sympy import (Integral, S, sqrt, And, Or, Integer, Float, Mod, I, Abs, simplify, Mul, Add, Pow, sign, EulerGamma) from sympy.integrals.rubi.symbol import WC from sympy.core.symbol import symbols, Symbol from sympy.functions import (sin, cos, tan, cot, csc, sec, sqrt, erf) from sympy.functions.elementary.hyperbolic import (acosh, asinh, atanh, acoth, acsch, asech, cosh, sinh, tanh, coth, sech, csch) from sympy.functions.elementary.trigonometric import (atan, acsc, asin, acot, acos, asec, atan2) from sympy import pi as Pi A_, B_, C_, F_, G_, H_, a_, b_, c_, d_, e_, f_, g_, h_, i_, j_, k_, l_, m_, n_, p_, q_, r_, t_, u_, v_, s_, w_, x_, y_, z_ = [WC(i) for i in 'ABCFGHabcdefghijklmnpqrtuvswxyz'] a1_, a2_, b1_, b2_, c1_, c2_, d1_, d2_, n1_, n2_, e1_, e2_, f1_, f2_, g1_, g2_, n1_, n2_, n3_, Pq_, Pm_, Px_, Qm_, Qr_, Qx_, jn_, mn_, non2_, RFx_, RGx_ = [WC(i) for i in ['a1', 'a2', 'b1', 'b2', 'c1', 'c2', 'd1', 'd2', 'n1', 'n2', 'e1', 'e2', 'f1', 'f2', 'g1', 'g2', 'n1', 'n2', 'n3', 'Pq', 'Pm', 'Px', 'Qm', 'Qr', 'Qx', 'jn', 'mn', 'non2', 'RFx', 'RGx']] i, ii , Pqq, Q, R, r, C, k, u = symbols('i ii Pqq Q R r C k u') _UseGamma = False ShowSteps = False StepCounter = None def tangent(rubi): from sympy.integrals.rubi.constraints import cons1508, cons2, cons3, cons48, cons125, cons21, cons4, cons1509, cons17, cons23, cons93, cons165, cons94, cons1510, cons1170, cons87, cons1511, cons89, cons166, cons683, cons31, cons266, cons32, cons1512, cons1513, cons18, cons155, cons1250, cons1514, cons1515, cons1516, cons1517, cons1518, cons1519, cons1520, cons1521, cons1522, cons80, cons79, cons1523, cons1524, cons1525, cons1526, cons27, cons5, cons1527, cons7, cons1261, cons1264, cons1439, cons463, cons1440, cons1528, cons1255, cons1529, cons88, cons1530, cons1531, cons1532, cons515, cons1533, cons1534, cons1535, cons1536, cons1537, cons1538, cons66, cons1539, cons84, cons1228, cons148, cons196, cons1540, cons85, cons70, cons1541, cons71, cons1412, cons267, cons1303, cons168, cons1542, cons1543, cons1322, cons1544, cons1323, cons1545, cons1546, cons1547, cons1548, cons77, cons1549, cons1550, cons1551, cons1423, cons1385, cons111, cons272, cons1325, cons1327, cons1334, cons1552, cons1553, cons1333, cons1554, cons1555, cons1336, cons1556, cons1557, cons808, cons380, cons208, cons147, cons1417, cons50, cons38, cons34, cons35, cons346, cons1418, cons1426, cons1558, cons1559, cons1560, cons1256, cons1561, cons36, cons33, cons1433, cons1562, cons1563, cons1564, cons1565, cons1566, cons1567, cons1568, cons1569, cons1492, cons1456, cons1570, cons1481, cons1479, cons743, cons1497, cons46, cons45, cons226, cons1480, cons62, cons528, cons1571, cons1572, cons810, cons811, cons1360, cons1573, cons1495, cons68, cons69, cons823, cons824, cons1574, cons1575, cons1576, cons1577, cons1578, cons1579, cons47, cons239, cons1580 pattern3398 = Pattern(Integral((WC('a', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons48, cons125, cons21, cons4, cons1508) def replacement3398(m, f, b, a, n, x, e): rubi.append(3398) return -Simp(b*(a*sin(e + f*x))**m*(b*tan(e + f*x))**(n + S(-1))/(f*m), x) rule3398 = ReplacementRule(pattern3398, replacement3398) pattern3399 = Pattern(Integral((WC('a', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons48, cons125, cons21, cons4, cons1508) def replacement3399(m, f, b, a, n, x, e): rubi.append(3399) return Simp(b*(a*cos(e + f*x))**m*(b/tan(e + f*x))**(n + S(-1))/(f*m), x) rule3399 = ReplacementRule(pattern3399, replacement3399) pattern3400 = Pattern(Integral(sin(x_*WC('f', S(1)) + WC('e', S(0)))**WC('m', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0)))**WC('n', S(1)), x_), cons48, cons125, cons1509) def replacement3400(m, f, n, x, e): rubi.append(3400) return -Dist(S(1)/f, Subst(Int(x**(-n)*(-x**S(2) + S(1))**(m/S(2) + n/S(2) + S(-1)/2), x), x, cos(e + f*x)), x) rule3400 = ReplacementRule(pattern3400, replacement3400) pattern3401 = Pattern(Integral((S(1)/tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0)))**WC('m', S(1)), x_), cons48, cons125, cons1509) def replacement3401(m, f, n, x, e): rubi.append(3401) return Dist(S(1)/f, Subst(Int(x**(-n)*(-x**S(2) + S(1))**(m/S(2) + n/S(2) + S(-1)/2), x), x, sin(e + f*x)), x) rule3401 = ReplacementRule(pattern3401, replacement3401) pattern3402 = Pattern(Integral((WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_*sin(x_*WC('f', S(1)) + WC('e', S(0)))**WC('m', S(1)), x_), cons3, cons48, cons125, cons4, cons17, cons23) def replacement3402(m, f, b, n, x, e): rubi.append(3402) return Dist(b**(-m), Int((b*tan(e + f*x))**(m + n)*(S(1)/cos(e + f*x))**(-m), x), x) rule3402 = ReplacementRule(pattern3402, replacement3402) pattern3403 = Pattern(Integral((WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_*cos(x_*WC('f', S(1)) + WC('e', S(0)))**WC('m', S(1)), x_), cons3, cons48, cons125, cons4, cons17, cons23) def replacement3403(m, f, b, n, x, e): rubi.append(3403) return Dist(b**(-m), Int((b/tan(e + f*x))**(m + n)*(S(1)/sin(e + f*x))**(-m), x), x) rule3403 = ReplacementRule(pattern3403, replacement3403) pattern3404 = Pattern(Integral((WC('a', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons48, cons125, cons93, cons165, cons94, cons1510, cons1170) def replacement3404(m, f, b, a, n, x, e): rubi.append(3404) return -Dist(b**S(2)*(m + S(2))/(a**S(2)*(n + S(-1))), Int((a*sin(e + f*x))**(m + S(2))*(b*tan(e + f*x))**(n + S(-2)), x), x) + Simp(b*(a*sin(e + f*x))**(m + S(2))*(b*tan(e + f*x))**(n + S(-1))/(a**S(2)*f*(n + S(-1))), x) rule3404 = ReplacementRule(pattern3404, replacement3404) pattern3405 = Pattern(Integral((WC('a', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons48, cons125, cons93, cons165, cons94, cons1510, cons1170) def replacement3405(m, f, b, a, n, x, e): rubi.append(3405) return -Dist(b**S(2)*(m + S(2))/(a**S(2)*(n + S(-1))), Int((a*cos(e + f*x))**(m + S(2))*(b/tan(e + f*x))**(n + S(-2)), x), x) - Simp(b*(a*cos(e + f*x))**(m + S(2))*(b/tan(e + f*x))**(n + S(-1))/(a**S(2)*f*(n + S(-1))), x) rule3405 = ReplacementRule(pattern3405, replacement3405) pattern3406 = Pattern(Integral((WC('a', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons48, cons125, cons21, cons87, cons165, cons1170, cons1511) def replacement3406(m, f, b, a, n, x, e): rubi.append(3406) return -Dist(b**S(2)*(m + n + S(-1))/(n + S(-1)), Int((a*sin(e + f*x))**m*(b*tan(e + f*x))**(n + S(-2)), x), x) + Simp(b*(a*sin(e + f*x))**m*(b*tan(e + f*x))**(n + S(-1))/(f*(n + S(-1))), x) rule3406 = ReplacementRule(pattern3406, replacement3406) pattern3407 = Pattern(Integral((WC('a', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons48, cons125, cons21, cons87, cons165, cons1170, cons1511) def replacement3407(m, f, b, a, n, x, e): rubi.append(3407) return -Dist(b**S(2)*(m + n + S(-1))/(n + S(-1)), Int((a*cos(e + f*x))**m*(b/tan(e + f*x))**(n + S(-2)), x), x) - Simp(b*(a*cos(e + f*x))**m*(b/tan(e + f*x))**(n + S(-1))/(f*(n + S(-1))), x) rule3407 = ReplacementRule(pattern3407, replacement3407) pattern3408 = Pattern(Integral((WC('a', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons48, cons125, cons93, cons89, cons166, cons1170) def replacement3408(m, f, b, a, n, x, e): rubi.append(3408) return -Dist(a**S(2)*(n + S(1))/(b**S(2)*m), Int((a*sin(e + f*x))**(m + S(-2))*(b*tan(e + f*x))**(n + S(2)), x), x) + Simp((a*sin(e + f*x))**m*(b*tan(e + f*x))**(n + S(1))/(b*f*m), x) rule3408 = ReplacementRule(pattern3408, replacement3408) pattern3409 = Pattern(Integral((WC('a', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons48, cons125, cons93, cons89, cons166, cons1170) def replacement3409(m, f, b, a, n, x, e): rubi.append(3409) return -Dist(a**S(2)*(n + S(1))/(b**S(2)*m), Int((a*cos(e + f*x))**(m + S(-2))*(b/tan(e + f*x))**(n + S(2)), x), x) - Simp((a*cos(e + f*x))**m*(b/tan(e + f*x))**(n + S(1))/(b*f*m), x) rule3409 = ReplacementRule(pattern3409, replacement3409) pattern3410 = Pattern(Integral((WC('a', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons48, cons125, cons21, cons87, cons89, cons683, cons1170) def replacement3410(m, f, b, a, n, x, e): rubi.append(3410) return -Dist((n + S(1))/(b**S(2)*(m + n + S(1))), Int((a*sin(e + f*x))**m*(b*tan(e + f*x))**(n + S(2)), x), x) + Simp((a*sin(e + f*x))**m*(b*tan(e + f*x))**(n + S(1))/(b*f*(m + n + S(1))), x) rule3410 = ReplacementRule(pattern3410, replacement3410) pattern3411 = Pattern(Integral((WC('a', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons48, cons125, cons21, cons87, cons89, cons683, cons1170) def replacement3411(m, f, b, a, n, x, e): rubi.append(3411) return -Dist((n + S(1))/(b**S(2)*(m + n + S(1))), Int((a*cos(e + f*x))**m*(b/tan(e + f*x))**(n + S(2)), x), x) - Simp((a*cos(e + f*x))**m*(b/tan(e + f*x))**(n + S(1))/(b*f*(m + n + S(1))), x) rule3411 = ReplacementRule(pattern3411, replacement3411) pattern3412 = Pattern(Integral((WC('a', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1)), x_), cons2, cons3, cons48, cons125, cons4, cons31, cons266, cons1170) def replacement3412(m, f, b, a, n, x, e): rubi.append(3412) return Dist(a**S(2)*(m + n + S(-1))/m, Int((a*sin(e + f*x))**(m + S(-2))*(b*tan(e + f*x))**n, x), x) - Simp(b*(a*sin(e + f*x))**m*(b*tan(e + f*x))**(n + S(-1))/(f*m), x) rule3412 = ReplacementRule(pattern3412, replacement3412) pattern3413 = Pattern(Integral((WC('a', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1)), x_), cons2, cons3, cons48, cons125, cons4, cons31, cons266, cons1170) def replacement3413(m, f, b, a, n, x, e): rubi.append(3413) return Dist(a**S(2)*(m + n + S(-1))/m, Int((a*cos(e + f*x))**(m + S(-2))*(b/tan(e + f*x))**n, x), x) + Simp(b*(a*cos(e + f*x))**m*(b/tan(e + f*x))**(n + S(-1))/(f*m), x) rule3413 = ReplacementRule(pattern3413, replacement3413) pattern3414 = Pattern(Integral((WC('a', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1)), x_), cons2, cons3, cons48, cons125, cons4, cons31, cons32, cons683, cons1170) def replacement3414(m, f, b, a, n, x, e): rubi.append(3414) return Dist((m + S(2))/(a**S(2)*(m + n + S(1))), Int((a*sin(e + f*x))**(m + S(2))*(b*tan(e + f*x))**n, x), x) + Simp(b*(a*sin(e + f*x))**(m + S(2))*(b*tan(e + f*x))**(n + S(-1))/(a**S(2)*f*(m + n + S(1))), x) rule3414 = ReplacementRule(pattern3414, replacement3414) pattern3415 = Pattern(Integral((WC('a', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1)), x_), cons2, cons3, cons48, cons125, cons4, cons31, cons32, cons683, cons1170) def replacement3415(m, f, b, a, n, x, e): rubi.append(3415) return Dist((m + S(2))/(a**S(2)*(m + n + S(1))), Int((a*cos(e + f*x))**(m + S(2))*(b/tan(e + f*x))**n, x), x) - Simp(b*(a*cos(e + f*x))**(m + S(2))*(b/tan(e + f*x))**(n + S(-1))/(a**S(2)*f*(m + n + S(1))), x) rule3415 = ReplacementRule(pattern3415, replacement3415) pattern3416 = Pattern(Integral((WC('a', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0)))**WC('n', S(1)), x_), cons2, cons48, cons125, cons21, cons1512) def replacement3416(m, f, a, n, x, e): rubi.append(3416) return Dist(S(1)/f, Subst(Int(x**(m + n)*(a**S(2) - x**S(2))**(-n/S(2) + S(-1)/2), x), x, a*sin(e + f*x)), x) rule3416 = ReplacementRule(pattern3416, replacement3416) pattern3417 = Pattern(Integral((WC('a', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(S(1)/tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1)), x_), cons2, cons48, cons125, cons21, cons1512) def replacement3417(m, f, a, n, x, e): rubi.append(3417) return -Dist(S(1)/f, Subst(Int(x**(m + n)*(a**S(2) - x**S(2))**(-n/S(2) + S(-1)/2), x), x, a*cos(e + f*x)), x) rule3417 = ReplacementRule(pattern3417, replacement3417) pattern3418 = Pattern(Integral((WC('a', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1)), x_), cons2, cons3, cons48, cons125, cons21, cons4, cons1513) def replacement3418(m, f, b, a, n, x, e): rubi.append(3418) return Dist(a**(-S(2)*IntPart(n/S(2) + S(1)/2) + S(1))*b**(S(2)*IntPart(n/S(2) + S(1)/2) + S(-1))*(a*sin(e + f*x))**(-S(2)*FracPart(n/S(2) + S(1)/2))*(b*tan(e + f*x))**(S(2)*FracPart(n/S(2) + S(1)/2))*(cos(e + f*x)**S(2))**FracPart(n/S(2) + S(1)/2)/f, Subst(Int((a*x)**(m + n)*(-x**S(2) + S(1))**(-n/S(2) + S(-1)/2), x), x, sin(e + f*x)), x) rule3418 = ReplacementRule(pattern3418, replacement3418) pattern3419 = Pattern(Integral((WC('a', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1)), x_), cons2, cons3, cons48, cons125, cons21, cons4, cons1513) def replacement3419(m, f, b, a, n, x, e): rubi.append(3419) return -Dist(a**(-S(2)*IntPart(n/S(2) + S(1)/2) + S(1))*b**(S(2)*IntPart(n/S(2) + S(1)/2) + S(-1))*(a*cos(e + f*x))**(-S(2)*FracPart(n/S(2) + S(1)/2))*(b/tan(e + f*x))**(S(2)*FracPart(n/S(2) + S(1)/2))*(sin(e + f*x)**S(2))**FracPart(n/S(2) + S(1)/2)/f, Subst(Int((a*x)**(m + n)*(-x**S(2) + S(1))**(-n/S(2) + S(-1)/2), x), x, cos(e + f*x)), x) rule3419 = ReplacementRule(pattern3419, replacement3419) pattern3420 = Pattern(Integral((WC('a', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons48, cons125, cons21, cons4, cons18, cons23) def replacement3420(m, f, b, a, n, x, e): rubi.append(3420) return Dist((S(1)/(a*cos(e + f*x)))**FracPart(m)*(a*cos(e + f*x))**FracPart(m), Int((S(1)/(a*cos(e + f*x)))**(-m)*(b*tan(e + f*x))**n, x), x) rule3420 = ReplacementRule(pattern3420, replacement3420) pattern3421 = Pattern(Integral((WC('a', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons48, cons125, cons21, cons4, cons18, cons23) def replacement3421(m, f, b, a, n, x, e): rubi.append(3421) return Dist((S(1)/(a*sin(e + f*x)))**FracPart(m)*(a*sin(e + f*x))**FracPart(m), Int((S(1)/(a*sin(e + f*x)))**(-m)*(b/tan(e + f*x))**n, x), x) rule3421 = ReplacementRule(pattern3421, replacement3421) pattern3422 = Pattern(Integral((WC('a', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons48, cons125, cons21, cons4, cons18, cons23) def replacement3422(m, f, b, a, n, x, e): rubi.append(3422) return Dist((a/tan(e + f*x))**m*(b*tan(e + f*x))**m, Int((b*tan(e + f*x))**(-m + n), x), x) rule3422 = ReplacementRule(pattern3422, replacement3422) pattern3423 = Pattern(Integral((WC('a', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1)), x_), cons2, cons3, cons48, cons125, cons21, cons4, cons155) def replacement3423(m, f, b, a, n, x, e): rubi.append(3423) return -Simp((a/cos(e + f*x))**m*(b*tan(e + f*x))**(n + S(1))/(b*f*m), x) rule3423 = ReplacementRule(pattern3423, replacement3423) pattern3424 = Pattern(Integral((WC('a', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1)), x_), cons2, cons3, cons48, cons125, cons21, cons4, cons155) def replacement3424(m, f, b, a, n, x, e): rubi.append(3424) return Simp((a/sin(e + f*x))**m*(b/tan(e + f*x))**(n + S(1))/(b*f*m), x) rule3424 = ReplacementRule(pattern3424, replacement3424) pattern3425 = Pattern(Integral((WC('a', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1)), x_), cons2, cons48, cons125, cons21, cons1250, cons1514) def replacement3425(m, f, b, a, n, x, e): rubi.append(3425) return Dist(a/f, Subst(Int((a*x)**(m + S(-1))*(x**S(2) + S(-1))**(n/S(2) + S(-1)/2), x), x, S(1)/cos(e + f*x)), x) rule3425 = ReplacementRule(pattern3425, replacement3425) pattern3426 = Pattern(Integral((WC('a', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1)), x_), cons2, cons48, cons125, cons21, cons1250, cons1514) def replacement3426(m, f, b, a, n, x, e): rubi.append(3426) return -Dist(a/f, Subst(Int((a*x)**(m + S(-1))*(x**S(2) + S(-1))**(n/S(2) + S(-1)/2), x), x, S(1)/sin(e + f*x)), x) rule3426 = ReplacementRule(pattern3426, replacement3426) pattern3427 = Pattern(Integral((WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1))*(S(1)/cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_, x_), cons3, cons48, cons125, cons4, cons1515, cons1516) def replacement3427(m, f, b, n, x, e): rubi.append(3427) return Dist(S(1)/f, Subst(Int((b*x)**n*(x**S(2) + S(1))**(m/S(2) + S(-1)), x), x, tan(e + f*x)), x) rule3427 = ReplacementRule(pattern3427, replacement3427) pattern3428 = Pattern(Integral((WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1))*(S(1)/sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_, x_), cons3, cons48, cons125, cons4, cons1515, cons1516) def replacement3428(m, f, b, n, x, e): rubi.append(3428) return -Dist(S(1)/f, Subst(Int((b*x)**n*(x**S(2) + S(1))**(m/S(2) + S(-1)), x), x, S(1)/tan(e + f*x)), x) rule3428 = ReplacementRule(pattern3428, replacement3428) pattern3429 = Pattern(Integral((WC('a', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons48, cons125, cons93, cons89, cons1517, cons1170) def replacement3429(m, f, b, a, n, x, e): rubi.append(3429) return -Dist(a**S(2)*(m + S(-2))/(b**S(2)*(n + S(1))), Int((a/cos(e + f*x))**(m + S(-2))*(b*tan(e + f*x))**(n + S(2)), x), x) + Simp(a**S(2)*(a/cos(e + f*x))**(m + S(-2))*(b*tan(e + f*x))**(n + S(1))/(b*f*(n + S(1))), x) rule3429 = ReplacementRule(pattern3429, replacement3429) pattern3430 = Pattern(Integral((WC('a', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons48, cons125, cons93, cons89, cons1517, cons1170) def replacement3430(m, f, b, a, n, x, e): rubi.append(3430) return -Dist(a**S(2)*(m + S(-2))/(b**S(2)*(n + S(1))), Int((a/sin(e + f*x))**(m + S(-2))*(b/tan(e + f*x))**(n + S(2)), x), x) - Simp(a**S(2)*(a/sin(e + f*x))**(m + S(-2))*(b/tan(e + f*x))**(n + S(1))/(b*f*(n + S(1))), x) rule3430 = ReplacementRule(pattern3430, replacement3430) pattern3431 = Pattern(Integral((WC('a', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons48, cons125, cons21, cons87, cons89, cons1170) def replacement3431(m, f, b, a, n, x, e): rubi.append(3431) return -Dist((m + n + S(1))/(b**S(2)*(n + S(1))), Int((a/cos(e + f*x))**m*(b*tan(e + f*x))**(n + S(2)), x), x) + Simp((a/cos(e + f*x))**m*(b*tan(e + f*x))**(n + S(1))/(b*f*(n + S(1))), x) rule3431 = ReplacementRule(pattern3431, replacement3431) pattern3432 = Pattern(Integral((WC('a', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons48, cons125, cons21, cons87, cons89, cons1170) def replacement3432(m, f, b, a, n, x, e): rubi.append(3432) return -Dist((m + n + S(1))/(b**S(2)*(n + S(1))), Int((a/sin(e + f*x))**m*(b/tan(e + f*x))**(n + S(2)), x), x) - Simp((a/sin(e + f*x))**m*(b/tan(e + f*x))**(n + S(1))/(b*f*(n + S(1))), x) rule3432 = ReplacementRule(pattern3432, replacement3432) pattern3433 = Pattern(Integral((WC('a', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons48, cons125, cons93, cons165, cons1518, cons1170) def replacement3433(m, f, b, a, n, x, e): rubi.append(3433) return -Dist(b**S(2)*(n + S(-1))/(a**S(2)*m), Int((a/cos(e + f*x))**(m + S(2))*(b*tan(e + f*x))**(n + S(-2)), x), x) + Simp(b*(a/cos(e + f*x))**m*(b*tan(e + f*x))**(n + S(-1))/(f*m), x) rule3433 = ReplacementRule(pattern3433, replacement3433) pattern3434 = Pattern(Integral((WC('a', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons48, cons125, cons93, cons165, cons1518, cons1170) def replacement3434(m, f, b, a, n, x, e): rubi.append(3434) return -Dist(b**S(2)*(n + S(-1))/(a**S(2)*m), Int((a/sin(e + f*x))**(m + S(2))*(b/tan(e + f*x))**(n + S(-2)), x), x) - Simp(b*(a/sin(e + f*x))**m*(b/tan(e + f*x))**(n + S(-1))/(f*m), x) rule3434 = ReplacementRule(pattern3434, replacement3434) pattern3435 = Pattern(Integral((WC('a', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons48, cons125, cons21, cons87, cons165, cons1519, cons1170) def replacement3435(m, f, b, a, n, x, e): rubi.append(3435) return -Dist(b**S(2)*(n + S(-1))/(m + n + S(-1)), Int((a/cos(e + f*x))**m*(b*tan(e + f*x))**(n + S(-2)), x), x) + Simp(b*(a/cos(e + f*x))**m*(b*tan(e + f*x))**(n + S(-1))/(f*(m + n + S(-1))), x) rule3435 = ReplacementRule(pattern3435, replacement3435) pattern3436 = Pattern(Integral((WC('a', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons48, cons125, cons21, cons87, cons165, cons1519, cons1170) def replacement3436(m, f, b, a, n, x, e): rubi.append(3436) return -Dist(b**S(2)*(n + S(-1))/(m + n + S(-1)), Int((a/sin(e + f*x))**m*(b/tan(e + f*x))**(n + S(-2)), x), x) - Simp(b*(a/sin(e + f*x))**m*(b/tan(e + f*x))**(n + S(-1))/(f*(m + n + S(-1))), x) rule3436 = ReplacementRule(pattern3436, replacement3436) pattern3437 = Pattern(Integral((WC('a', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons48, cons125, cons4, cons31, cons1520, cons1170) def replacement3437(m, f, b, a, n, x, e): rubi.append(3437) return Dist((m + n + S(1))/(a**S(2)*m), Int((a/cos(e + f*x))**(m + S(2))*(b*tan(e + f*x))**n, x), x) - Simp((a/cos(e + f*x))**m*(b*tan(e + f*x))**(n + S(1))/(b*f*m), x) rule3437 = ReplacementRule(pattern3437, replacement3437) pattern3438 = Pattern(Integral((WC('a', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons48, cons125, cons4, cons31, cons1520, cons1170) def replacement3438(m, f, b, a, n, x, e): rubi.append(3438) return Dist((m + n + S(1))/(a**S(2)*m), Int((a/sin(e + f*x))**(m + S(2))*(b/tan(e + f*x))**n, x), x) + Simp((a/sin(e + f*x))**m*(b/tan(e + f*x))**(n + S(1))/(b*f*m), x) rule3438 = ReplacementRule(pattern3438, replacement3438) pattern3439 = Pattern(Integral((WC('a', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons48, cons125, cons4, cons31, cons1521, cons1519, cons1170) def replacement3439(m, f, b, a, n, x, e): rubi.append(3439) return Dist(a**S(2)*(m + S(-2))/(m + n + S(-1)), Int((a/cos(e + f*x))**(m + S(-2))*(b*tan(e + f*x))**n, x), x) + Simp(a**S(2)*(a/cos(e + f*x))**(m + S(-2))*(b*tan(e + f*x))**(n + S(1))/(b*f*(m + n + S(-1))), x) rule3439 = ReplacementRule(pattern3439, replacement3439) pattern3440 = Pattern(Integral((WC('a', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons48, cons125, cons4, cons31, cons1521, cons1519, cons1170) def replacement3440(m, f, b, a, n, x, e): rubi.append(3440) return Dist(a**S(2)*(m + S(-2))/(m + n + S(-1)), Int((a/sin(e + f*x))**(m + S(-2))*(b/tan(e + f*x))**n, x), x) - Simp(a**S(2)*(a/sin(e + f*x))**(m + S(-2))*(b/tan(e + f*x))**(n + S(1))/(b*f*(m + n + S(-1))), x) rule3440 = ReplacementRule(pattern3440, replacement3440) pattern3441 = Pattern(Integral(S(1)/(sqrt(WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))*cos(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons3, cons48, cons125, cons1522) def replacement3441(x, f, b, e): rubi.append(3441) return Dist(sqrt(sin(e + f*x))/(sqrt(b*tan(e + f*x))*sqrt(cos(e + f*x))), Int(S(1)/(sqrt(sin(e + f*x))*sqrt(cos(e + f*x))), x), x) rule3441 = ReplacementRule(pattern3441, replacement3441) pattern3442 = Pattern(Integral(S(1)/(sqrt(WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))*sin(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons3, cons48, cons125, cons1522) def replacement3442(x, f, b, e): rubi.append(3442) return Dist(sqrt(cos(e + f*x))/(sqrt(b/tan(e + f*x))*sqrt(sin(e + f*x))), Int(S(1)/(sqrt(sin(e + f*x))*sqrt(cos(e + f*x))), x), x) rule3442 = ReplacementRule(pattern3442, replacement3442) pattern3443 = Pattern(Integral(sqrt(WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))*cos(x_*WC('f', S(1)) + WC('e', S(0))), x_), cons3, cons48, cons125, cons1522) def replacement3443(x, f, b, e): rubi.append(3443) return Dist(sqrt(b*tan(e + f*x))*sqrt(cos(e + f*x))/sqrt(sin(e + f*x)), Int(sqrt(sin(e + f*x))*sqrt(cos(e + f*x)), x), x) rule3443 = ReplacementRule(pattern3443, replacement3443) pattern3444 = Pattern(Integral(sqrt(WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))*sin(x_*WC('f', S(1)) + WC('e', S(0))), x_), cons3, cons48, cons125, cons1522) def replacement3444(x, f, b, e): rubi.append(3444) return Dist(sqrt(b/tan(e + f*x))*sqrt(sin(e + f*x))/sqrt(cos(e + f*x)), Int(sqrt(sin(e + f*x))*sqrt(cos(e + f*x)), x), x) rule3444 = ReplacementRule(pattern3444, replacement3444) pattern3445 = Pattern(Integral((WC('a', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons48, cons125, cons21, cons4, cons80, cons79) def replacement3445(m, f, b, a, n, x, e): rubi.append(3445) return Dist(a**(m + n)*(a/cos(e + f*x))**(-n)*(b*sin(e + f*x))**(-n)*(b*tan(e + f*x))**n, Int((b*sin(e + f*x))**n*cos(e + f*x)**(-m - n), x), x) rule3445 = ReplacementRule(pattern3445, replacement3445) pattern3446 = Pattern(Integral((WC('a', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons48, cons125, cons21, cons4, cons80, cons79) def replacement3446(m, f, b, a, n, x, e): rubi.append(3446) return Dist(a**(m + n)*(a/sin(e + f*x))**(-n)*(b*cos(e + f*x))**(-n)*(b/tan(e + f*x))**n, Int((b*cos(e + f*x))**n*sin(e + f*x)**(-m - n), x), x) rule3446 = ReplacementRule(pattern3446, replacement3446) pattern3447 = Pattern(Integral((WC('a', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons48, cons125, cons21, cons4, cons1523, cons1524) def replacement3447(m, f, b, a, n, x, e): rubi.append(3447) return Simp((a/cos(e + f*x))**m*(b*tan(e + f*x))**(n + S(1))*(cos(e + f*x)**S(2))**(m/S(2) + n/S(2) + S(1)/2)*Hypergeometric2F1(n/S(2) + S(1)/2, m/S(2) + n/S(2) + S(1)/2, n/S(2) + S(3)/2, sin(e + f*x)**S(2))/(b*f*(n + S(1))), x) rule3447 = ReplacementRule(pattern3447, replacement3447) pattern3448 = Pattern(Integral((WC('a', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons48, cons125, cons21, cons4, cons1523, cons1524) def replacement3448(m, f, b, a, n, x, e): rubi.append(3448) return -Simp((a/sin(e + f*x))**m*(b/tan(e + f*x))**(n + S(1))*(sin(e + f*x)**S(2))**(m/S(2) + n/S(2) + S(1)/2)*Hypergeometric2F1(n/S(2) + S(1)/2, m/S(2) + n/S(2) + S(1)/2, n/S(2) + S(3)/2, cos(e + f*x)**S(2))/(b*f*(n + S(1))), x) rule3448 = ReplacementRule(pattern3448, replacement3448) pattern3449 = Pattern(Integral((WC('a', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons48, cons125, cons21, cons4, cons18, cons23) def replacement3449(m, f, b, a, n, x, e): rubi.append(3449) return Dist((sin(e + f*x)/a)**FracPart(m)*(a/sin(e + f*x))**FracPart(m), Int((sin(e + f*x)/a)**(-m)*(b*tan(e + f*x))**n, x), x) rule3449 = ReplacementRule(pattern3449, replacement3449) pattern3450 = Pattern(Integral((WC('a', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons48, cons125, cons21, cons4, cons18, cons23) def replacement3450(m, f, b, a, n, x, e): rubi.append(3450) return Dist((cos(e + f*x)/a)**FracPart(m)*(a/cos(e + f*x))**FracPart(m), Int((cos(e + f*x)/a)**(-m)*(b/tan(e + f*x))**n, x), x) rule3450 = ReplacementRule(pattern3450, replacement3450) pattern3451 = Pattern(Integral(((WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**p_*WC('a', S(1)))**WC('m', S(1))*(WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons27, cons48, cons125, cons21, cons5, cons87, cons165, cons1525, cons1526) def replacement3451(p, m, f, b, d, a, n, x, e): rubi.append(3451) return -Dist(b**S(2)*(n + S(-1))/(m*p + n + S(-1)), Int((a*(d/cos(e + f*x))**p)**m*(b*tan(e + f*x))**(n + S(-2)), x), x) + Simp(b*(a*(d/cos(e + f*x))**p)**m*(b*tan(e + f*x))**(n + S(-1))/(f*(m*p + n + S(-1))), x) rule3451 = ReplacementRule(pattern3451, replacement3451) pattern3452 = Pattern(Integral(((WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**p_*WC('a', S(1)))**WC('m', S(1))*(WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons27, cons48, cons125, cons21, cons5, cons87, cons165, cons1525, cons1526) def replacement3452(p, m, f, b, d, a, n, x, e): rubi.append(3452) return -Dist(b**S(2)*(n + S(-1))/(m*p + n + S(-1)), Int((a*(d/sin(e + f*x))**p)**m*(b/tan(e + f*x))**(n + S(-2)), x), x) - Simp(b*(a*(d/sin(e + f*x))**p)**m*(b/tan(e + f*x))**(n + S(-1))/(f*(m*p + n + S(-1))), x) rule3452 = ReplacementRule(pattern3452, replacement3452) pattern3453 = Pattern(Integral(((WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**p_*WC('a', S(1)))**WC('m', S(1))*(WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons27, cons48, cons125, cons21, cons5, cons87, cons89, cons1527, cons1526) def replacement3453(p, m, f, b, d, a, n, x, e): rubi.append(3453) return -Dist((m*p + n + S(1))/(b**S(2)*(n + S(1))), Int((a*(d/cos(e + f*x))**p)**m*(b*tan(e + f*x))**(n + S(2)), x), x) + Simp((a*(d/cos(e + f*x))**p)**m*(b*tan(e + f*x))**(n + S(1))/(b*f*(n + S(1))), x) rule3453 = ReplacementRule(pattern3453, replacement3453) pattern3454 = Pattern(Integral(((WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**p_*WC('a', S(1)))**WC('m', S(1))*(WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons27, cons48, cons125, cons21, cons5, cons87, cons89, cons1527, cons1526) def replacement3454(p, m, f, b, d, a, n, x, e): rubi.append(3454) return -Dist((m*p + n + S(1))/(b**S(2)*(n + S(1))), Int((a*(d/sin(e + f*x))**p)**m*(b/tan(e + f*x))**(n + S(2)), x), x) + Simp((a*(d/sin(e + f*x))**p)**m*(b/tan(e + f*x))**(n + S(1))/(b*f*(n + S(1))), x) rule3454 = ReplacementRule(pattern3454, replacement3454) pattern3455 = Pattern(Integral((WC('b', S(1))*tan(x_*WC('d', S(1)) + WC('c', S(0))))**n_, x_), cons3, cons7, cons27, cons87, cons165) def replacement3455(b, d, c, n, x): rubi.append(3455) return -Dist(b**S(2), Int((b*tan(c + d*x))**(n + S(-2)), x), x) + Simp(b*(b*tan(c + d*x))**(n + S(-1))/(d*(n + S(-1))), x) rule3455 = ReplacementRule(pattern3455, replacement3455) pattern3456 = Pattern(Integral((WC('b', S(1))/tan(x_*WC('d', S(1)) + WC('c', S(0))))**n_, x_), cons3, cons7, cons27, cons87, cons165) def replacement3456(b, d, c, n, x): rubi.append(3456) return -Dist(b**S(2), Int((b/tan(c + d*x))**(n + S(-2)), x), x) - Simp(b*(b/tan(c + d*x))**(n + S(-1))/(d*(n + S(-1))), x) rule3456 = ReplacementRule(pattern3456, replacement3456) pattern3457 = Pattern(Integral((WC('b', S(1))*tan(x_*WC('d', S(1)) + WC('c', S(0))))**n_, x_), cons3, cons7, cons27, cons87, cons89) def replacement3457(b, d, c, n, x): rubi.append(3457) return -Dist(b**(S(-2)), Int((b*tan(c + d*x))**(n + S(2)), x), x) + Simp((b*tan(c + d*x))**(n + S(1))/(b*d*(n + S(1))), x) rule3457 = ReplacementRule(pattern3457, replacement3457) pattern3458 = Pattern(Integral((WC('b', S(1))/tan(x_*WC('d', S(1)) + WC('c', S(0))))**n_, x_), cons3, cons7, cons27, cons87, cons89) def replacement3458(b, d, c, n, x): rubi.append(3458) return -Dist(b**(S(-2)), Int((b/tan(c + d*x))**(n + S(2)), x), x) - Simp((b/tan(c + d*x))**(n + S(1))/(b*d*(n + S(1))), x) rule3458 = ReplacementRule(pattern3458, replacement3458) pattern3459 = Pattern(Integral(tan(x_*WC('d', S(1)) + WC('c', S(0))), x_), cons7, cons27, cons1261) def replacement3459(d, c, x): rubi.append(3459) return -Simp(log(RemoveContent(cos(c + d*x), x))/d, x) rule3459 = ReplacementRule(pattern3459, replacement3459) pattern3460 = Pattern(Integral(S(1)/tan(x_*WC('d', S(1)) + WC('c', S(0))), x_), cons7, cons27, cons1261) def replacement3460(d, c, x): rubi.append(3460) return Simp(log(RemoveContent(sin(c + d*x), x))/d, x) rule3460 = ReplacementRule(pattern3460, replacement3460) pattern3461 = Pattern(Integral((WC('b', S(1))*tan(x_*WC('d', S(1)) + WC('c', S(0))))**n_, x_), cons3, cons7, cons27, cons4, cons23) def replacement3461(b, d, c, n, x): rubi.append(3461) return Dist(b/d, Subst(Int(x**n/(b**S(2) + x**S(2)), x), x, b*tan(c + d*x)), x) rule3461 = ReplacementRule(pattern3461, replacement3461) pattern3462 = Pattern(Integral((WC('b', S(1))/tan(x_*WC('d', S(1)) + WC('c', S(0))))**n_, x_), cons3, cons7, cons27, cons4, cons23) def replacement3462(b, d, c, n, x): rubi.append(3462) return -Dist(b/d, Subst(Int(x**n/(b**S(2) + x**S(2)), x), x, b/tan(c + d*x)), x) rule3462 = ReplacementRule(pattern3462, replacement3462) pattern3463 = Pattern(Integral((a_ + WC('b', S(1))*tan(x_*WC('d', S(1)) + WC('c', S(0))))**S(2), x_), cons2, cons3, cons7, cons27, cons1264) def replacement3463(b, d, c, a, x): rubi.append(3463) return Dist(S(2)*a*b, Int(tan(c + d*x), x), x) + Simp(x*(a**S(2) - b**S(2)), x) + Simp(b**S(2)*tan(c + d*x)/d, x) rule3463 = ReplacementRule(pattern3463, replacement3463) pattern3464 = Pattern(Integral((a_ + WC('b', S(1))/tan(x_*WC('d', S(1)) + WC('c', S(0))))**S(2), x_), cons2, cons3, cons7, cons27, cons1264) def replacement3464(b, d, c, a, x): rubi.append(3464) return Dist(S(2)*a*b, Int(S(1)/tan(c + d*x), x), x) + Simp(x*(a**S(2) - b**S(2)), x) - Simp(b**S(2)/(d*tan(c + d*x)), x) rule3464 = ReplacementRule(pattern3464, replacement3464) pattern3465 = Pattern(Integral((a_ + WC('b', S(1))*tan(x_*WC('d', S(1)) + WC('c', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons1439, cons87, cons165) def replacement3465(b, d, c, a, n, x): rubi.append(3465) return Dist(S(2)*a, Int((a + b*tan(c + d*x))**(n + S(-1)), x), x) + Simp(b*(a + b*tan(c + d*x))**(n + S(-1))/(d*(n + S(-1))), x) rule3465 = ReplacementRule(pattern3465, replacement3465) pattern3466 = Pattern(Integral((a_ + WC('b', S(1))/tan(x_*WC('d', S(1)) + WC('c', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons1439, cons87, cons165) def replacement3466(b, d, c, a, n, x): rubi.append(3466) return Dist(S(2)*a, Int((a + b/tan(c + d*x))**(n + S(-1)), x), x) - Simp(b*(a + b/tan(c + d*x))**(n + S(-1))/(d*(n + S(-1))), x) rule3466 = ReplacementRule(pattern3466, replacement3466) pattern3467 = Pattern(Integral((a_ + WC('b', S(1))*tan(x_*WC('d', S(1)) + WC('c', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons1439, cons87, cons463) def replacement3467(b, d, c, a, n, x): rubi.append(3467) return Dist(S(1)/(S(2)*a), Int((a + b*tan(c + d*x))**(n + S(1)), x), x) + Simp(a*(a + b*tan(c + d*x))**n/(S(2)*b*d*n), x) rule3467 = ReplacementRule(pattern3467, replacement3467) pattern3468 = Pattern(Integral((a_ + WC('b', S(1))/tan(x_*WC('d', S(1)) + WC('c', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons1439, cons87, cons463) def replacement3468(b, d, c, a, n, x): rubi.append(3468) return Dist(S(1)/(S(2)*a), Int((a + b/tan(c + d*x))**(n + S(1)), x), x) - Simp(a*(a + b/tan(c + d*x))**n/(S(2)*b*d*n), x) rule3468 = ReplacementRule(pattern3468, replacement3468) pattern3469 = Pattern(Integral(sqrt(a_ + WC('b', S(1))*tan(x_*WC('d', S(1)) + WC('c', S(0)))), x_), cons2, cons3, cons7, cons27, cons1439) def replacement3469(b, d, c, a, x): rubi.append(3469) return Dist(-S(2)*b/d, Subst(Int(S(1)/(S(2)*a - x**S(2)), x), x, sqrt(a + b*tan(c + d*x))), x) rule3469 = ReplacementRule(pattern3469, replacement3469) pattern3470 = Pattern(Integral(sqrt(a_ + WC('b', S(1))/tan(x_*WC('d', S(1)) + WC('c', S(0)))), x_), cons2, cons3, cons7, cons27, cons1439) def replacement3470(b, d, c, a, x): rubi.append(3470) return Dist(S(2)*b/d, Subst(Int(S(1)/(S(2)*a - x**S(2)), x), x, sqrt(a + b/tan(c + d*x))), x) rule3470 = ReplacementRule(pattern3470, replacement3470) pattern3471 = Pattern(Integral((a_ + WC('b', S(1))*tan(x_*WC('d', S(1)) + WC('c', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons4, cons1439) def replacement3471(b, d, c, a, n, x): rubi.append(3471) return -Dist(b/d, Subst(Int((a + x)**(n + S(-1))/(a - x), x), x, b*tan(c + d*x)), x) rule3471 = ReplacementRule(pattern3471, replacement3471) pattern3472 = Pattern(Integral((a_ + WC('b', S(1))/tan(x_*WC('d', S(1)) + WC('c', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons4, cons1439) def replacement3472(b, d, c, a, n, x): rubi.append(3472) return Dist(b/d, Subst(Int((a + x)**(n + S(-1))/(a - x), x), x, b/tan(c + d*x)), x) rule3472 = ReplacementRule(pattern3472, replacement3472) pattern3473 = Pattern(Integral((a_ + WC('b', S(1))*tan(x_*WC('d', S(1)) + WC('c', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons1440, cons87, cons165) def replacement3473(b, d, c, a, n, x): rubi.append(3473) return Int((a + b*tan(c + d*x))**(n + S(-2))*(a**S(2) + S(2)*a*b*tan(c + d*x) - b**S(2)), x) + Simp(b*(a + b*tan(c + d*x))**(n + S(-1))/(d*(n + S(-1))), x) rule3473 = ReplacementRule(pattern3473, replacement3473) pattern3474 = Pattern(Integral((a_ + WC('b', S(1))/tan(x_*WC('d', S(1)) + WC('c', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons1440, cons87, cons165) def replacement3474(b, d, c, a, n, x): rubi.append(3474) return Int((a + b/tan(c + d*x))**(n + S(-2))*(a**S(2) + S(2)*a*b/tan(c + d*x) - b**S(2)), x) - Simp(b*(a + b/tan(c + d*x))**(n + S(-1))/(d*(n + S(-1))), x) rule3474 = ReplacementRule(pattern3474, replacement3474) pattern3475 = Pattern(Integral((a_ + WC('b', S(1))*tan(x_*WC('d', S(1)) + WC('c', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons1440, cons87, cons89) def replacement3475(b, d, c, a, n, x): rubi.append(3475) return Dist(S(1)/(a**S(2) + b**S(2)), Int((a - b*tan(c + d*x))*(a + b*tan(c + d*x))**(n + S(1)), x), x) + Simp(b*(a + b*tan(c + d*x))**(n + S(1))/(d*(a**S(2) + b**S(2))*(n + S(1))), x) rule3475 = ReplacementRule(pattern3475, replacement3475) pattern3476 = Pattern(Integral((a_ + WC('b', S(1))/tan(x_*WC('d', S(1)) + WC('c', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons1440, cons87, cons89) def replacement3476(b, d, c, a, n, x): rubi.append(3476) return Dist(S(1)/(a**S(2) + b**S(2)), Int((a - b/tan(c + d*x))*(a + b/tan(c + d*x))**(n + S(1)), x), x) - Simp(b*(a + b/tan(c + d*x))**(n + S(1))/(d*(a**S(2) + b**S(2))*(n + S(1))), x) rule3476 = ReplacementRule(pattern3476, replacement3476) pattern3477 = Pattern(Integral(S(1)/(a_ + WC('b', S(1))*tan(x_*WC('d', S(1)) + WC('c', S(0)))), x_), cons2, cons3, cons7, cons27, cons1440) def replacement3477(b, d, c, a, x): rubi.append(3477) return Dist(b/(a**S(2) + b**S(2)), Int((-a*tan(c + d*x) + b)/(a + b*tan(c + d*x)), x), x) + Simp(a*x/(a**S(2) + b**S(2)), x) rule3477 = ReplacementRule(pattern3477, replacement3477) pattern3478 = Pattern(Integral(S(1)/(a_ + WC('b', S(1))/tan(x_*WC('d', S(1)) + WC('c', S(0)))), x_), cons2, cons3, cons7, cons27, cons1440) def replacement3478(b, d, c, a, x): rubi.append(3478) return Dist(b/(a**S(2) + b**S(2)), Int((-a/tan(c + d*x) + b)/(a + b/tan(c + d*x)), x), x) + Simp(a*x/(a**S(2) + b**S(2)), x) rule3478 = ReplacementRule(pattern3478, replacement3478) pattern3479 = Pattern(Integral((a_ + WC('b', S(1))*tan(x_*WC('d', S(1)) + WC('c', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons4, cons1440) def replacement3479(b, d, c, a, n, x): rubi.append(3479) return Dist(b/d, Subst(Int((a + x)**n/(b**S(2) + x**S(2)), x), x, b*tan(c + d*x)), x) rule3479 = ReplacementRule(pattern3479, replacement3479) pattern3480 = Pattern(Integral((a_ + WC('b', S(1))/tan(x_*WC('d', S(1)) + WC('c', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons4, cons1440) def replacement3480(b, d, c, a, n, x): rubi.append(3480) return -Dist(b/d, Subst(Int((a + x)**n/(b**S(2) + x**S(2)), x), x, b/tan(c + d*x)), x) rule3480 = ReplacementRule(pattern3480, replacement3480) pattern3481 = Pattern(Integral((WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(a_ + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons27, cons48, cons125, cons21, cons1528) def replacement3481(m, f, b, d, a, x, e): rubi.append(3481) return Dist(a, Int((d/cos(e + f*x))**m, x), x) + Simp(b*(d/cos(e + f*x))**m/(f*m), x) rule3481 = ReplacementRule(pattern3481, replacement3481) pattern3482 = Pattern(Integral((WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(a_ + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons27, cons48, cons125, cons21, cons1528) def replacement3482(m, f, b, d, a, x, e): rubi.append(3482) return Dist(a, Int((d/sin(e + f*x))**m, x), x) - Simp(b*(d/sin(e + f*x))**m/(f*m), x) rule3482 = ReplacementRule(pattern3482, replacement3482) pattern3483 = Pattern(Integral((a_ + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(S(1)/cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_, x_), cons2, cons3, cons48, cons125, cons4, cons1439, cons1515) def replacement3483(m, f, b, a, n, x, e): rubi.append(3483) return Dist(a**(-m + S(2))/(b*f), Subst(Int((a - x)**(m/S(2) + S(-1))*(a + x)**(m/S(2) + n + S(-1)), x), x, b*tan(e + f*x)), x) rule3483 = ReplacementRule(pattern3483, replacement3483) pattern3484 = Pattern(Integral((a_ + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(S(1)/sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_, x_), cons2, cons3, cons48, cons125, cons4, cons1439, cons1515) def replacement3484(m, f, b, a, n, x, e): rubi.append(3484) return -Dist(a**(-m + S(2))/(b*f), Subst(Int((a - x)**(m/S(2) + S(-1))*(a + x)**(m/S(2) + n + S(-1)), x), x, b/tan(e + f*x)), x) rule3484 = ReplacementRule(pattern3484, replacement3484) pattern3485 = Pattern(Integral((WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(a_ + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons27, cons48, cons125, cons21, cons4, cons1439, cons1255) def replacement3485(m, f, b, d, a, n, x, e): rubi.append(3485) return Simp(b*(d/cos(e + f*x))**m*(a + b*tan(e + f*x))**n/(a*f*m), x) rule3485 = ReplacementRule(pattern3485, replacement3485) pattern3486 = Pattern(Integral((WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(a_ + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons27, cons48, cons125, cons21, cons4, cons1439, cons1255) def replacement3486(m, f, b, d, a, n, x, e): rubi.append(3486) return -Simp(b*(d/sin(e + f*x))**m*(a + b/tan(e + f*x))**n/(a*f*m), x) rule3486 = ReplacementRule(pattern3486, replacement3486) pattern3487 = Pattern(Integral(S(1)/(sqrt(a_ + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))*cos(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons48, cons125, cons1439) def replacement3487(f, b, a, x, e): rubi.append(3487) return Dist(-S(2)*a/(b*f), Subst(Int(S(1)/(-a*x**S(2) + S(2)), x), x, S(1)/(sqrt(a + b*tan(e + f*x))*cos(e + f*x))), x) rule3487 = ReplacementRule(pattern3487, replacement3487) pattern3488 = Pattern(Integral(S(1)/(sqrt(a_ + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))*sin(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons48, cons125, cons1439) def replacement3488(f, b, a, x, e): rubi.append(3488) return Dist(S(2)*a/(b*f), Subst(Int(S(1)/(-a*x**S(2) + S(2)), x), x, S(1)/(sqrt(a + b/tan(e + f*x))*sin(e + f*x))), x) rule3488 = ReplacementRule(pattern3488, replacement3488) pattern3489 = Pattern(Integral((WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(a_ + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons27, cons48, cons125, cons1439, cons1529, cons93, cons88) def replacement3489(m, f, b, d, a, n, x, e): rubi.append(3489) return Dist(a/(S(2)*d**S(2)), Int((d/cos(e + f*x))**(m + S(2))*(a + b*tan(e + f*x))**(n + S(-1)), x), x) + Simp(b*(d/cos(e + f*x))**m*(a + b*tan(e + f*x))**n/(a*f*m), x) rule3489 = ReplacementRule(pattern3489, replacement3489) pattern3490 = Pattern(Integral((WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(a_ + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons27, cons48, cons125, cons1439, cons1529, cons93, cons88) def replacement3490(m, f, b, d, a, n, x, e): rubi.append(3490) return Dist(a/(S(2)*d**S(2)), Int((d/sin(e + f*x))**(m + S(2))*(a + b/tan(e + f*x))**(n + S(-1)), x), x) - Simp(b*(d/sin(e + f*x))**m*(a + b/tan(e + f*x))**n/(a*f*m), x) rule3490 = ReplacementRule(pattern3490, replacement3490) pattern3491 = Pattern(Integral((WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(a_ + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons27, cons48, cons125, cons1439, cons1529, cons93, cons89) def replacement3491(m, f, b, d, a, n, x, e): rubi.append(3491) return Dist(S(2)*d**S(2)/a, Int((d/cos(e + f*x))**(m + S(-2))*(a + b*tan(e + f*x))**(n + S(1)), x), x) + Simp(S(2)*d**S(2)*(d/cos(e + f*x))**(m + S(-2))*(a + b*tan(e + f*x))**(n + S(1))/(b*f*(m + S(-2))), x) rule3491 = ReplacementRule(pattern3491, replacement3491) pattern3492 = Pattern(Integral((WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(a_ + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons27, cons48, cons125, cons1439, cons1529, cons93, cons89) def replacement3492(m, f, b, d, a, n, x, e): rubi.append(3492) return Dist(S(2)*d**S(2)/a, Int((d/sin(e + f*x))**(m + S(-2))*(a + b/tan(e + f*x))**(n + S(1)), x), x) + Simp(-S(2)*d**S(2)*(d/sin(e + f*x))**(m + S(-2))*(a + b/tan(e + f*x))**(n + S(1))/(b*f*(m + S(-2))), x) rule3492 = ReplacementRule(pattern3492, replacement3492) pattern3493 = Pattern(Integral((WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(a_ + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons27, cons48, cons125, cons21, cons4, cons1439, cons1529) def replacement3493(m, f, b, d, a, n, x, e): rubi.append(3493) return Dist((a/d)**(S(2)*IntPart(n))*(d/cos(e + f*x))**(-S(2)*FracPart(n))*(a - b*tan(e + f*x))**FracPart(n)*(a + b*tan(e + f*x))**FracPart(n), Int((a - b*tan(e + f*x))**(-n), x), x) rule3493 = ReplacementRule(pattern3493, replacement3493) pattern3494 = Pattern(Integral((WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(a_ + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons27, cons48, cons125, cons21, cons4, cons1439, cons1529) def replacement3494(m, f, b, d, a, n, x, e): rubi.append(3494) return Dist((a/d)**(S(2)*IntPart(n))*(d/sin(e + f*x))**(-S(2)*FracPart(n))*(a - b/tan(e + f*x))**FracPart(n)*(a + b/tan(e + f*x))**FracPart(n), Int((a - b/tan(e + f*x))**(-n), x), x) rule3494 = ReplacementRule(pattern3494, replacement3494) pattern3495 = Pattern(Integral((WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(a_ + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons27, cons48, cons125, cons21, cons4, cons1439, cons1530) def replacement3495(m, f, b, d, a, n, x, e): rubi.append(3495) return Simp(S(2)*b*(d/cos(e + f*x))**m*(a + b*tan(e + f*x))**(n + S(-1))/(f*m), x) rule3495 = ReplacementRule(pattern3495, replacement3495) pattern3496 = Pattern(Integral((WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(a_ + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons27, cons48, cons125, cons21, cons4, cons1439, cons1530) def replacement3496(m, f, b, d, a, n, x, e): rubi.append(3496) return Simp(-S(2)*b*(d/sin(e + f*x))**m*(a + b/tan(e + f*x))**(n + S(-1))/(f*m), x) rule3496 = ReplacementRule(pattern3496, replacement3496) pattern3497 = Pattern(Integral((WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(a_ + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons27, cons48, cons125, cons21, cons4, cons1439, cons1531, cons23) def replacement3497(m, f, b, d, a, n, x, e): rubi.append(3497) return Dist(a*(m + S(2)*n + S(-2))/(m + n + S(-1)), Int((d/cos(e + f*x))**m*(a + b*tan(e + f*x))**(n + S(-1)), x), x) + Simp(b*(d/cos(e + f*x))**m*(a + b*tan(e + f*x))**(n + S(-1))/(f*(m + n + S(-1))), x) rule3497 = ReplacementRule(pattern3497, replacement3497) pattern3498 = Pattern(Integral((WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(a_ + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons27, cons48, cons125, cons21, cons4, cons1439, cons1531, cons23) def replacement3498(m, f, b, d, a, n, x, e): rubi.append(3498) return Dist(a*(m + S(2)*n + S(-2))/(m + n + S(-1)), Int((d/sin(e + f*x))**m*(a + b/tan(e + f*x))**(n + S(-1)), x), x) - Simp(b*(d/sin(e + f*x))**m*(a + b/tan(e + f*x))**(n + S(-1))/(f*(m + n + S(-1))), x) rule3498 = ReplacementRule(pattern3498, replacement3498) pattern3499 = Pattern(Integral(sqrt(WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))*sqrt(a_ + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons27, cons48, cons125, cons1439) def replacement3499(f, b, d, a, x, e): rubi.append(3499) return Dist(-S(4)*b*d**S(2)/f, Subst(Int(x**S(2)/(a**S(2) + d**S(2)*x**S(4)), x), x, sqrt(a + b*tan(e + f*x))/sqrt(d/cos(e + f*x))), x) rule3499 = ReplacementRule(pattern3499, replacement3499) pattern3500 = Pattern(Integral(sqrt(WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))*sqrt(a_ + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons27, cons48, cons125, cons1439) def replacement3500(f, b, d, a, x, e): rubi.append(3500) return Dist(S(4)*b*d**S(2)/f, Subst(Int(x**S(2)/(a**S(2) + d**S(2)*x**S(4)), x), x, sqrt(a + b/tan(e + f*x))/sqrt(d/sin(e + f*x))), x) rule3500 = ReplacementRule(pattern3500, replacement3500) pattern3501 = Pattern(Integral((WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(a_ + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons27, cons48, cons125, cons1439, cons93, cons165, cons1532, cons515) def replacement3501(m, f, b, d, a, n, x, e): rubi.append(3501) return -Dist(b**S(2)*(m + S(2)*n + S(-2))/(d**S(2)*m), Int((d/cos(e + f*x))**(m + S(2))*(a + b*tan(e + f*x))**(n + S(-2)), x), x) + Simp(S(2)*b*(d/cos(e + f*x))**m*(a + b*tan(e + f*x))**(n + S(-1))/(f*m), x) rule3501 = ReplacementRule(pattern3501, replacement3501) pattern3502 = Pattern(Integral((WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(a_ + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons27, cons48, cons125, cons1439, cons93, cons165, cons1533, cons515) def replacement3502(m, f, b, d, a, n, x, e): rubi.append(3502) return -Dist(b**S(2)*(m + S(2)*n + S(-2))/(d**S(2)*m), Int((d/sin(e + f*x))**(m + S(2))*(a + b/tan(e + f*x))**(n + S(-2)), x), x) + Simp(-S(2)*b*(d/sin(e + f*x))**m*(a + b/tan(e + f*x))**(n + S(-1))/(f*m), x) rule3502 = ReplacementRule(pattern3502, replacement3502) pattern3503 = Pattern(Integral((WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(a_ + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons27, cons48, cons125, cons1439, cons93, cons88, cons94, cons1170) def replacement3503(m, f, b, d, a, n, x, e): rubi.append(3503) return Dist(a*(m + n)/(d**S(2)*m), Int((d/cos(e + f*x))**(m + S(2))*(a + b*tan(e + f*x))**(n + S(-1)), x), x) + Simp(b*(d/cos(e + f*x))**m*(a + b*tan(e + f*x))**n/(a*f*m), x) rule3503 = ReplacementRule(pattern3503, replacement3503) pattern3504 = Pattern(Integral((WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(a_ + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons27, cons48, cons125, cons1439, cons93, cons88, cons94, cons1170) def replacement3504(m, f, b, d, a, n, x, e): rubi.append(3504) return Dist(a*(m + n)/(d**S(2)*m), Int((d/sin(e + f*x))**(m + S(2))*(a + b/tan(e + f*x))**(n + S(-1)), x), x) - Simp(b*(d/sin(e + f*x))**m*(a + b/tan(e + f*x))**n/(a*f*m), x) rule3504 = ReplacementRule(pattern3504, replacement3504) pattern3505 = Pattern(Integral((WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(a_ + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons27, cons48, cons125, cons21, cons1439, cons87, cons88, cons1519, cons1170) def replacement3505(m, f, b, d, a, n, x, e): rubi.append(3505) return Dist(a*(m + S(2)*n + S(-2))/(m + n + S(-1)), Int((d/cos(e + f*x))**m*(a + b*tan(e + f*x))**(n + S(-1)), x), x) + Simp(b*(d/cos(e + f*x))**m*(a + b*tan(e + f*x))**(n + S(-1))/(f*(m + n + S(-1))), x) rule3505 = ReplacementRule(pattern3505, replacement3505) pattern3506 = Pattern(Integral((WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(a_ + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons27, cons48, cons125, cons21, cons1439, cons87, cons88, cons1519, cons1170) def replacement3506(m, f, b, d, a, n, x, e): rubi.append(3506) return Dist(a*(m + S(2)*n + S(-2))/(m + n + S(-1)), Int((d/sin(e + f*x))**m*(a + b/tan(e + f*x))**(n + S(-1)), x), x) - Simp(b*(d/sin(e + f*x))**m*(a + b/tan(e + f*x))**(n + S(-1))/(f*(m + n + S(-1))), x) rule3506 = ReplacementRule(pattern3506, replacement3506) pattern3507 = Pattern(Integral((WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**(S(3)/2)/sqrt(a_ + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons27, cons48, cons125, cons1439) def replacement3507(f, b, d, a, x, e): rubi.append(3507) return Dist(d/(sqrt(a - b*tan(e + f*x))*sqrt(a + b*tan(e + f*x))*cos(e + f*x)), Int(sqrt(d/cos(e + f*x))*sqrt(a - b*tan(e + f*x)), x), x) rule3507 = ReplacementRule(pattern3507, replacement3507) pattern3508 = Pattern(Integral((WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**(S(3)/2)/sqrt(a_ + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons27, cons48, cons125, cons1439) def replacement3508(f, b, d, a, x, e): rubi.append(3508) return Dist(d/(sqrt(a - b/tan(e + f*x))*sqrt(a + b/tan(e + f*x))*sin(e + f*x)), Int(sqrt(d/sin(e + f*x))*sqrt(a - b/tan(e + f*x)), x), x) rule3508 = ReplacementRule(pattern3508, replacement3508) pattern3509 = Pattern(Integral((WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(a_ + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons27, cons48, cons125, cons21, cons1439, cons87, cons89, cons1534, cons515) def replacement3509(m, f, b, d, a, n, x, e): rubi.append(3509) return -Dist(d**S(2)*(m + S(-2))/(b**S(2)*(m + S(2)*n)), Int((d/cos(e + f*x))**(m + S(-2))*(a + b*tan(e + f*x))**(n + S(2)), x), x) + Simp(S(2)*d**S(2)*(d/cos(e + f*x))**(m + S(-2))*(a + b*tan(e + f*x))**(n + S(1))/(b*f*(m + S(2)*n)), x) rule3509 = ReplacementRule(pattern3509, replacement3509) pattern3510 = Pattern(Integral((WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(a_ + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons27, cons48, cons125, cons21, cons1439, cons87, cons89, cons1534, cons515) def replacement3510(m, f, b, d, a, n, x, e): rubi.append(3510) return -Dist(d**S(2)*(m + S(-2))/(b**S(2)*(m + S(2)*n)), Int((d/sin(e + f*x))**(m + S(-2))*(a + b/tan(e + f*x))**(n + S(2)), x), x) + Simp(-S(2)*d**S(2)*(d/sin(e + f*x))**(m + S(-2))*(a + b/tan(e + f*x))**(n + S(1))/(b*f*(m + S(2)*n)), x) rule3510 = ReplacementRule(pattern3510, replacement3510) pattern3511 = Pattern(Integral((WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(a_ + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons27, cons48, cons125, cons1439, cons93, cons463, cons166, cons1535, cons1519, cons1170) def replacement3511(m, f, b, d, a, n, x, e): rubi.append(3511) return Dist(d**S(2)*(m + S(-2))/(a*(m + n + S(-1))), Int((d/cos(e + f*x))**(m + S(-2))*(a + b*tan(e + f*x))**(n + S(1)), x), x) + Simp(d**S(2)*(d/cos(e + f*x))**(m + S(-2))*(a + b*tan(e + f*x))**(n + S(1))/(b*f*(m + n + S(-1))), x) rule3511 = ReplacementRule(pattern3511, replacement3511) pattern3512 = Pattern(Integral((WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(a_ + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons27, cons48, cons125, cons1439, cons93, cons463, cons166, cons1535, cons1519, cons1170) def replacement3512(m, f, b, d, a, n, x, e): rubi.append(3512) return Dist(d**S(2)*(m + S(-2))/(a*(m + n + S(-1))), Int((d/sin(e + f*x))**(m + S(-2))*(a + b/tan(e + f*x))**(n + S(1)), x), x) - Simp(d**S(2)*(d/sin(e + f*x))**(m + S(-2))*(a + b/tan(e + f*x))**(n + S(1))/(b*f*(m + n + S(-1))), x) rule3512 = ReplacementRule(pattern3512, replacement3512) pattern3513 = Pattern(Integral((WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(a_ + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons27, cons48, cons125, cons21, cons1439, cons87, cons463, cons1536, cons1170) def replacement3513(m, f, b, d, a, n, x, e): rubi.append(3513) return Dist((m + n)/(a*(m + S(2)*n)), Int((d/cos(e + f*x))**m*(a + b*tan(e + f*x))**(n + S(1)), x), x) + Simp(a*(d/cos(e + f*x))**m*(a + b*tan(e + f*x))**n/(b*f*(m + S(2)*n)), x) rule3513 = ReplacementRule(pattern3513, replacement3513) pattern3514 = Pattern(Integral((WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(a_ + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons27, cons48, cons125, cons21, cons1439, cons87, cons463, cons1536, cons1170) def replacement3514(m, f, b, d, a, n, x, e): rubi.append(3514) return Dist((m + n)/(a*(m + S(2)*n)), Int((d/sin(e + f*x))**m*(a + b/tan(e + f*x))**(n + S(1)), x), x) - Simp(a*(d/sin(e + f*x))**m*(a + b/tan(e + f*x))**n/(b*f*(m + S(2)*n)), x) rule3514 = ReplacementRule(pattern3514, replacement3514) pattern3515 = Pattern(Integral((WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(a_ + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons27, cons48, cons125, cons21, cons4, cons1439, cons1537, cons87) def replacement3515(m, f, b, d, a, n, x, e): rubi.append(3515) return Dist(a*(m + S(2)*n + S(-2))/(m + n + S(-1)), Int((d/cos(e + f*x))**m*(a + b*tan(e + f*x))**(n + S(-1)), x), x) + Simp(b*(d/cos(e + f*x))**m*(a + b*tan(e + f*x))**(n + S(-1))/(f*(m + n + S(-1))), x) rule3515 = ReplacementRule(pattern3515, replacement3515) pattern3516 = Pattern(Integral((WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(a_ + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons27, cons48, cons125, cons21, cons4, cons1439, cons1537, cons87) def replacement3516(m, f, b, d, a, n, x, e): rubi.append(3516) return Dist(a*(m + S(2)*n + S(-2))/(m + n + S(-1)), Int((d/sin(e + f*x))**m*(a + b/tan(e + f*x))**(n + S(-1)), x), x) - Simp(b*(d/sin(e + f*x))**m*(a + b/tan(e + f*x))**(n + S(-1))/(f*(m + n + S(-1))), x) rule3516 = ReplacementRule(pattern3516, replacement3516) pattern3517 = Pattern(Integral((WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(a_ + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons27, cons48, cons125, cons21, cons4, cons1439, cons1538, cons1536) def replacement3517(m, f, b, d, a, n, x, e): rubi.append(3517) return Dist((m + n)/(a*(m + S(2)*n)), Int((d/cos(e + f*x))**m*(a + b*tan(e + f*x))**(n + S(1)), x), x) + Simp(a*(d/cos(e + f*x))**m*(a + b*tan(e + f*x))**n/(b*f*(m + S(2)*n)), x) rule3517 = ReplacementRule(pattern3517, replacement3517) pattern3518 = Pattern(Integral((WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(a_ + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons27, cons48, cons125, cons21, cons4, cons1439, cons1538, cons1536) def replacement3518(m, f, b, d, a, n, x, e): rubi.append(3518) return Dist((m + n)/(a*(m + S(2)*n)), Int((d/sin(e + f*x))**m*(a + b/tan(e + f*x))**(n + S(1)), x), x) - Simp(a*(d/sin(e + f*x))**m*(a + b/tan(e + f*x))**n/(b*f*(m + S(2)*n)), x) rule3518 = ReplacementRule(pattern3518, replacement3518) pattern3519 = Pattern(Integral((WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(a_ + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1)), x_), cons2, cons3, cons27, cons48, cons125, cons21, cons4, cons1439) def replacement3519(m, f, b, d, a, n, x, e): rubi.append(3519) return Dist((d/cos(e + f*x))**m*(a - b*tan(e + f*x))**(-m/S(2))*(a + b*tan(e + f*x))**(-m/S(2)), Int((a - b*tan(e + f*x))**(m/S(2))*(a + b*tan(e + f*x))**(m/S(2) + n), x), x) rule3519 = ReplacementRule(pattern3519, replacement3519) pattern3520 = Pattern(Integral((WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(a_ + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1)), x_), cons2, cons3, cons27, cons48, cons125, cons21, cons4, cons1439) def replacement3520(m, f, b, d, a, n, x, e): rubi.append(3520) return Dist((d/sin(e + f*x))**m*(a - b/tan(e + f*x))**(-m/S(2))*(a + b/tan(e + f*x))**(-m/S(2)), Int((a - b/tan(e + f*x))**(m/S(2))*(a + b/tan(e + f*x))**(m/S(2) + n), x), x) rule3520 = ReplacementRule(pattern3520, replacement3520) pattern3521 = Pattern(Integral((a_ + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(S(1)/cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_, x_), cons2, cons3, cons48, cons125, cons4, cons1440, cons1515) def replacement3521(m, f, b, a, n, x, e): rubi.append(3521) return Dist(S(1)/(b*f), Subst(Int((S(1) + x**S(2)/b**S(2))**(m/S(2) + S(-1))*(a + x)**n, x), x, b*tan(e + f*x)), x) rule3521 = ReplacementRule(pattern3521, replacement3521) pattern3522 = Pattern(Integral((a_ + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(S(1)/sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_, x_), cons2, cons3, cons48, cons125, cons4, cons1440, cons1515) def replacement3522(m, f, b, a, n, x, e): rubi.append(3522) return -Dist(S(1)/(b*f), Subst(Int((S(1) + x**S(2)/b**S(2))**(m/S(2) + S(-1))*(a + x)**n, x), x, b/tan(e + f*x)), x) rule3522 = ReplacementRule(pattern3522, replacement3522) pattern3523 = Pattern(Integral((a_ + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**S(2)*cos(x_*WC('f', S(1)) + WC('e', S(0))), x_), cons2, cons3, cons48, cons125, cons1440) def replacement3523(f, b, a, x, e): rubi.append(3523) return Simp(b**S(2)*atanh(sin(e + f*x))/f, x) + Simp((a**S(2) - b**S(2))*sin(e + f*x)/f, x) - Simp(S(2)*a*b*cos(e + f*x)/f, x) rule3523 = ReplacementRule(pattern3523, replacement3523) pattern3524 = Pattern(Integral((a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**S(2)*tan(x_*WC('f', S(1)) + WC('e', S(0))), x_), cons2, cons3, cons48, cons125, cons1440) def replacement3524(f, b, a, x, e): rubi.append(3524) return -Simp(b**S(2)*atanh(cos(e + f*x))/f, x) - Simp((a**S(2) - b**S(2))*cos(e + f*x)/f, x) + Simp(S(2)*a*b*sin(e + f*x)/f, x) rule3524 = ReplacementRule(pattern3524, replacement3524) pattern3525 = Pattern(Integral((WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(a_ + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**S(2), x_), cons2, cons3, cons27, cons48, cons125, cons21, cons1440, cons66) def replacement3525(m, f, b, d, a, x, e): rubi.append(3525) return Dist(S(1)/(m + S(1)), Int((d/cos(e + f*x))**m*(a**S(2)*(m + S(1)) + a*b*(m + S(2))*tan(e + f*x) - b**S(2)), x), x) + Simp(b*(d/cos(e + f*x))**m*(a + b*tan(e + f*x))/(f*(m + S(1))), x) rule3525 = ReplacementRule(pattern3525, replacement3525) pattern3526 = Pattern(Integral((WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(a_ + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**S(2), x_), cons2, cons3, cons27, cons48, cons125, cons21, cons1440, cons66) def replacement3526(m, f, b, d, a, x, e): rubi.append(3526) return Dist(S(1)/(m + S(1)), Int((d/sin(e + f*x))**m*(a**S(2)*(m + S(1)) + a*b*(m + S(2))/tan(e + f*x) - b**S(2)), x), x) - Simp(b*(d/sin(e + f*x))**m*(a + b/tan(e + f*x))/(f*(m + S(1))), x) rule3526 = ReplacementRule(pattern3526, replacement3526) pattern3527 = Pattern(Integral(S(1)/((a_ + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))*cos(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons48, cons125, cons1440) def replacement3527(f, b, a, x, e): rubi.append(3527) return -Dist(S(1)/f, Subst(Int(S(1)/(a**S(2) + b**S(2) - x**S(2)), x), x, (-a*tan(e + f*x) + b)*cos(e + f*x)), x) rule3527 = ReplacementRule(pattern3527, replacement3527) pattern3528 = Pattern(Integral(S(1)/((a_ + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))*sin(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons48, cons125, cons1440) def replacement3528(f, b, a, x, e): rubi.append(3528) return Dist(S(1)/f, Subst(Int(S(1)/(a**S(2) + b**S(2) - x**S(2)), x), x, (-a/tan(e + f*x) + b)*sin(e + f*x)), x) rule3528 = ReplacementRule(pattern3528, replacement3528) pattern3529 = Pattern(Integral((WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_/(a_ + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons27, cons48, cons125, cons1440, cons1539) def replacement3529(m, f, b, d, a, x, e): rubi.append(3529) return -Dist(d**S(2)/b**S(2), Int((d/cos(e + f*x))**(m + S(-2))*(a - b*tan(e + f*x)), x), x) + Dist(d**S(2)*(a**S(2) + b**S(2))/b**S(2), Int((d/cos(e + f*x))**(m + S(-2))/(a + b*tan(e + f*x)), x), x) rule3529 = ReplacementRule(pattern3529, replacement3529) pattern3530 = Pattern(Integral((WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_/(a_ + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons27, cons48, cons125, cons1440, cons1539) def replacement3530(m, f, b, d, a, x, e): rubi.append(3530) return -Dist(d**S(2)/b**S(2), Int((d/sin(e + f*x))**(m + S(-2))*(a - b/tan(e + f*x)), x), x) + Dist(d**S(2)*(a**S(2) + b**S(2))/b**S(2), Int((d/sin(e + f*x))**(m + S(-2))/(a + b/tan(e + f*x)), x), x) rule3530 = ReplacementRule(pattern3530, replacement3530) pattern3531 = Pattern(Integral((WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_/(a_ + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons27, cons48, cons125, cons1440, cons84) def replacement3531(m, f, b, d, a, x, e): rubi.append(3531) return Dist(b**S(2)/(d**S(2)*(a**S(2) + b**S(2))), Int((d/cos(e + f*x))**(m + S(2))/(a + b*tan(e + f*x)), x), x) + Dist(S(1)/(a**S(2) + b**S(2)), Int((d/cos(e + f*x))**m*(a - b*tan(e + f*x)), x), x) rule3531 = ReplacementRule(pattern3531, replacement3531) pattern3532 = Pattern(Integral((WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_/(a_ + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons27, cons48, cons125, cons1440, cons84) def replacement3532(m, f, b, d, a, x, e): rubi.append(3532) return Dist(b**S(2)/(d**S(2)*(a**S(2) + b**S(2))), Int((d/sin(e + f*x))**(m + S(2))/(a + b/tan(e + f*x)), x), x) + Dist(S(1)/(a**S(2) + b**S(2)), Int((d/sin(e + f*x))**m*(a - b/tan(e + f*x)), x), x) rule3532 = ReplacementRule(pattern3532, replacement3532) pattern3533 = Pattern(Integral((WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(a_ + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons27, cons48, cons125, cons21, cons4, cons1440, cons1524) def replacement3533(m, f, b, d, a, n, x, e): rubi.append(3533) return Dist(d**(S(2)*IntPart(m/S(2)))*(d/cos(e + f*x))**(S(2)*FracPart(m/S(2)))*(cos(e + f*x)**(S(-2)))**(-FracPart(m/S(2)))/(b*f), Subst(Int((S(1) + x**S(2)/b**S(2))**(m/S(2) + S(-1))*(a + x)**n, x), x, b*tan(e + f*x)), x) rule3533 = ReplacementRule(pattern3533, replacement3533) pattern3534 = Pattern(Integral((WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(a_ + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons27, cons48, cons125, cons21, cons4, cons1440, cons1524) def replacement3534(m, f, b, d, a, n, x, e): rubi.append(3534) return -Dist(d**(S(2)*IntPart(m/S(2)))*(d/sin(e + f*x))**(S(2)*FracPart(m/S(2)))*(sin(e + f*x)**(S(-2)))**(-FracPart(m/S(2)))/(b*f), Subst(Int((S(1) + x**S(2)/b**S(2))**(m/S(2) + S(-1))*(a + x)**n, x), x, b/tan(e + f*x)), x) rule3534 = ReplacementRule(pattern3534, replacement3534) pattern3535 = Pattern(Integral(sqrt(a_ + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))/sqrt(WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons27, cons48, cons125, cons1439) def replacement3535(f, b, d, a, x, e): rubi.append(3535) return Dist(-S(4)*b/f, Subst(Int(x**S(2)/(a**S(2)*d**S(2) + x**S(4)), x), x, sqrt(d*cos(e + f*x))*sqrt(a + b*tan(e + f*x))), x) rule3535 = ReplacementRule(pattern3535, replacement3535) pattern3536 = Pattern(Integral(sqrt(a_ + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))/sqrt(WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons27, cons48, cons125, cons1439) def replacement3536(f, b, d, a, x, e): rubi.append(3536) return Dist(S(4)*b/f, Subst(Int(x**S(2)/(a**S(2)*d**S(2) + x**S(4)), x), x, sqrt(d*sin(e + f*x))*sqrt(a + b/tan(e + f*x))), x) rule3536 = ReplacementRule(pattern3536, replacement3536) pattern3537 = Pattern(Integral(S(1)/((WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**(S(3)/2)*sqrt(a_ + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))), x_), cons2, cons3, cons27, cons48, cons125, cons1439) def replacement3537(f, b, d, a, x, e): rubi.append(3537) return Dist(S(1)/(d*sqrt(a - b*tan(e + f*x))*sqrt(a + b*tan(e + f*x))*cos(e + f*x)), Int(sqrt(a - b*tan(e + f*x))/sqrt(d*cos(e + f*x)), x), x) rule3537 = ReplacementRule(pattern3537, replacement3537) pattern3538 = Pattern(Integral(S(1)/((WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**(S(3)/2)*sqrt(a_ + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))), x_), cons2, cons3, cons27, cons48, cons125, cons1439) def replacement3538(f, b, d, a, x, e): rubi.append(3538) return Dist(S(1)/(d*sqrt(a - b/tan(e + f*x))*sqrt(a + b/tan(e + f*x))*sin(e + f*x)), Int(sqrt(a - b/tan(e + f*x))/sqrt(d*sin(e + f*x)), x), x) rule3538 = ReplacementRule(pattern3538, replacement3538) pattern3539 = Pattern(Integral((WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(a_ + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1)), x_), cons2, cons3, cons27, cons48, cons125, cons21, cons4, cons18) def replacement3539(m, f, b, d, a, n, x, e): rubi.append(3539) return Dist((d/cos(e + f*x))**m*(d*cos(e + f*x))**m, Int((d/cos(e + f*x))**(-m)*(a + b*tan(e + f*x))**n, x), x) rule3539 = ReplacementRule(pattern3539, replacement3539) pattern3540 = Pattern(Integral((WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(a_ + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1)), x_), cons2, cons3, cons27, cons48, cons125, cons21, cons4, cons18) def replacement3540(m, f, b, d, a, n, x, e): rubi.append(3540) return Dist((d/sin(e + f*x))**m*(d*sin(e + f*x))**m, Int((d/sin(e + f*x))**(-m)*(a + b/tan(e + f*x))**n, x), x) rule3540 = ReplacementRule(pattern3540, replacement3540) pattern3541 = Pattern(Integral((a_ + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_*sin(x_*WC('f', S(1)) + WC('e', S(0)))**m_, x_), cons2, cons3, cons48, cons125, cons4, cons1515) def replacement3541(m, f, b, a, n, x, e): rubi.append(3541) return Dist(b/f, Subst(Int(x**m*(a + x)**n*(b**S(2) + x**S(2))**(-m/S(2) + S(-1)), x), x, b*tan(e + f*x)), x) rule3541 = ReplacementRule(pattern3541, replacement3541) pattern3542 = Pattern(Integral((a_ + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_*cos(x_*WC('f', S(1)) + WC('e', S(0)))**m_, x_), cons2, cons3, cons48, cons125, cons4, cons1515) def replacement3542(m, f, b, a, n, x, e): rubi.append(3542) return -Dist(b/f, Subst(Int(x**m*(a + x)**n*(b**S(2) + x**S(2))**(-m/S(2) + S(-1)), x), x, b/tan(e + f*x)), x) rule3542 = ReplacementRule(pattern3542, replacement3542) pattern3543 = Pattern(Integral((a_ + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0)))**WC('m', S(1)), x_), cons2, cons3, cons48, cons125, cons1228, cons148) def replacement3543(m, f, b, a, n, x, e): rubi.append(3543) return Int((a + b*tan(e + f*x))**n*sin(e + f*x)**m, x) rule3543 = ReplacementRule(pattern3543, replacement3543) pattern3544 = Pattern(Integral((a_ + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0)))**WC('m', S(1)), x_), cons2, cons3, cons48, cons125, cons1228, cons148) def replacement3544(m, f, b, a, n, x, e): rubi.append(3544) return Int((a + b/tan(e + f*x))**n*cos(e + f*x)**m, x) rule3544 = ReplacementRule(pattern3544, replacement3544) pattern3545 = Pattern(Integral((a_ + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0)))**WC('m', S(1)), x_), cons2, cons3, cons48, cons125, cons1228, cons196, cons1540) def replacement3545(m, f, b, a, n, x, e): rubi.append(3545) return Int((a*cos(e + f*x) + b*sin(e + f*x))**n*sin(e + f*x)**m*cos(e + f*x)**(-n), x) rule3545 = ReplacementRule(pattern3545, replacement3545) pattern3546 = Pattern(Integral((a_ + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0)))**WC('m', S(1)), x_), cons2, cons3, cons48, cons125, cons1228, cons196, cons1540) def replacement3546(m, f, b, a, n, x, e): rubi.append(3546) return Int((a*sin(e + f*x) + b*cos(e + f*x))**n*sin(e + f*x)**(-n)*cos(e + f*x)**m, x) rule3546 = ReplacementRule(pattern3546, replacement3546) pattern3547 = Pattern(Integral((WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('a', S(0)) + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1)), x_), cons2, cons3, cons27, cons48, cons125, cons21, cons4, cons18) def replacement3547(m, f, b, d, a, n, x, e): rubi.append(3547) return Dist((sin(e + f*x)/d)**FracPart(m)*(d/sin(e + f*x))**FracPart(m), Int((sin(e + f*x)/d)**(-m)*(a + b*tan(e + f*x))**n, x), x) rule3547 = ReplacementRule(pattern3547, replacement3547) pattern3548 = Pattern(Integral((WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('a', S(0)) + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1)), x_), cons2, cons3, cons27, cons48, cons125, cons21, cons4, cons18) def replacement3548(m, f, b, d, a, n, x, e): rubi.append(3548) return Dist((cos(e + f*x)/d)**FracPart(m)*(d/cos(e + f*x))**FracPart(m), Int((cos(e + f*x)/d)**(-m)*(a + b/tan(e + f*x))**n, x), x) rule3548 = ReplacementRule(pattern3548, replacement3548) pattern3549 = Pattern(Integral((a_ + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0)))**WC('p', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0)))**WC('m', S(1)), x_), cons2, cons3, cons48, cons125, cons21, cons5, cons85) def replacement3549(p, m, f, b, a, n, x, e): rubi.append(3549) return Int((a*cos(e + f*x) + b*sin(e + f*x))**n*sin(e + f*x)**p*cos(e + f*x)**(m - n), x) rule3549 = ReplacementRule(pattern3549, replacement3549) pattern3550 = Pattern(Integral((a_ + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0)))**WC('m', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0)))**WC('p', S(1)), x_), cons2, cons3, cons48, cons125, cons21, cons5, cons85) def replacement3550(p, m, f, b, a, n, x, e): rubi.append(3550) return Int((a*sin(e + f*x) + b*cos(e + f*x))**n*sin(e + f*x)**(m - n)*cos(e + f*x)**p, x) rule3550 = ReplacementRule(pattern3550, replacement3550) pattern3551 = Pattern(Integral((a_ + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(c_ + WC('d', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons4, cons70, cons1439, cons17, cons1541) def replacement3551(m, f, b, d, a, n, c, x, e): rubi.append(3551) return Dist(a**m*c**m, Int((c + d*tan(e + f*x))**(-m + n)*(S(1)/cos(e + f*x))**(S(2)*m), x), x) rule3551 = ReplacementRule(pattern3551, replacement3551) pattern3552 = Pattern(Integral((a_ + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(c_ + WC('d', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons4, cons70, cons1439, cons17, cons1541) def replacement3552(m, f, b, d, a, n, c, x, e): rubi.append(3552) return Dist(a**m*c**m, Int((c + d/tan(e + f*x))**(-m + n)*(S(1)/sin(e + f*x))**(S(2)*m), x), x) rule3552 = ReplacementRule(pattern3552, replacement3552) pattern3553 = Pattern(Integral((a_ + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(c_ + WC('d', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons4, cons70, cons1439) def replacement3553(m, f, b, d, a, c, n, x, e): rubi.append(3553) return Dist(a*c/f, Subst(Int((a + b*x)**(m + S(-1))*(c + d*x)**(n + S(-1)), x), x, tan(e + f*x)), x) rule3553 = ReplacementRule(pattern3553, replacement3553) pattern3554 = Pattern(Integral((a_ + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(c_ + WC('d', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons4, cons70, cons1439) def replacement3554(m, f, b, d, a, c, n, x, e): rubi.append(3554) return -Dist(a*c/f, Subst(Int((a + b*x)**(m + S(-1))*(c + d*x)**(n + S(-1)), x), x, S(1)/tan(e + f*x)), x) rule3554 = ReplacementRule(pattern3554, replacement3554) pattern3555 = Pattern(Integral((a_ + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))*(c_ + WC('d', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons70) def replacement3555(f, b, d, a, c, x, e): rubi.append(3555) return Simp(x*(a*c - b*d), x) + Simp(b*d*tan(e + f*x)/f, x) rule3555 = ReplacementRule(pattern3555, replacement3555) pattern3556 = Pattern(Integral((a_ + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))*(c_ + WC('d', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons70) def replacement3556(f, b, d, a, c, x, e): rubi.append(3556) return Simp(x*(a*c - b*d), x) - Simp(b*d/(f*tan(e + f*x)), x) rule3556 = ReplacementRule(pattern3556, replacement3556) pattern3557 = Pattern(Integral((a_ + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))*(WC('c', S(0)) + WC('d', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1412) def replacement3557(f, b, d, c, a, x, e): rubi.append(3557) return Dist(a*d + b*c, Int(tan(e + f*x), x), x) + Simp(x*(a*c - b*d), x) + Simp(b*d*tan(e + f*x)/f, x) rule3557 = ReplacementRule(pattern3557, replacement3557) pattern3558 = Pattern(Integral((a_ + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))*(WC('c', S(0)) + WC('d', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1412) def replacement3558(f, b, d, c, a, x, e): rubi.append(3558) return Dist(a*d + b*c, Int(S(1)/tan(e + f*x), x), x) + Simp(x*(a*c - b*d), x) - Simp(b*d/(f*tan(e + f*x)), x) rule3558 = ReplacementRule(pattern3558, replacement3558) pattern3559 = Pattern(Integral((a_ + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1439, cons31, cons267) def replacement3559(m, f, b, d, c, a, x, e): rubi.append(3559) return Dist((a*d + b*c)/(S(2)*a*b), Int((a + b*tan(e + f*x))**(m + S(1)), x), x) - Simp((a + b*tan(e + f*x))**m*(-a*d + b*c)/(S(2)*a*f*m), x) rule3559 = ReplacementRule(pattern3559, replacement3559) pattern3560 = Pattern(Integral((a_ + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1439, cons31, cons267) def replacement3560(m, f, b, d, c, a, x, e): rubi.append(3560) return Dist((a*d + b*c)/(S(2)*a*b), Int((a + b/tan(e + f*x))**(m + S(1)), x), x) + Simp((a + b/tan(e + f*x))**m*(-a*d + b*c)/(S(2)*a*f*m), x) rule3560 = ReplacementRule(pattern3560, replacement3560) pattern3561 = Pattern(Integral((a_ + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons71, cons1439, cons1303) def replacement3561(m, f, b, d, c, a, x, e): rubi.append(3561) return Dist((a*d + b*c)/b, Int((a + b*tan(e + f*x))**m, x), x) + Simp(d*(a + b*tan(e + f*x))**m/(f*m), x) rule3561 = ReplacementRule(pattern3561, replacement3561) pattern3562 = Pattern(Integral((a_ + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons71, cons1439, cons1303) def replacement3562(m, f, b, d, c, a, x, e): rubi.append(3562) return Dist((a*d + b*c)/b, Int((a + b/tan(e + f*x))**m, x), x) - Simp(d*(a + b/tan(e + f*x))**m/(f*m), x) rule3562 = ReplacementRule(pattern3562, replacement3562) pattern3563 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1440, cons31, cons168) def replacement3563(m, f, b, d, c, a, x, e): rubi.append(3563) return Int((a + b*tan(e + f*x))**(m + S(-1))*Simp(a*c - b*d + (a*d + b*c)*tan(e + f*x), x), x) + Simp(d*(a + b*tan(e + f*x))**m/(f*m), x) rule3563 = ReplacementRule(pattern3563, replacement3563) pattern3564 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1440, cons31, cons168) def replacement3564(m, f, b, d, c, a, x, e): rubi.append(3564) return Int((a + b/tan(e + f*x))**(m + S(-1))*Simp(a*c - b*d + (a*d + b*c)/tan(e + f*x), x), x) - Simp(d*(a + b/tan(e + f*x))**m/(f*m), x) rule3564 = ReplacementRule(pattern3564, replacement3564) pattern3565 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1440, cons31, cons94) def replacement3565(m, f, b, d, c, a, x, e): rubi.append(3565) return Dist(S(1)/(a**S(2) + b**S(2)), Int((a + b*tan(e + f*x))**(m + S(1))*Simp(a*c + b*d - (-a*d + b*c)*tan(e + f*x), x), x), x) + Simp((a + b*tan(e + f*x))**(m + S(1))*(-a*d + b*c)/(f*(a**S(2) + b**S(2))*(m + S(1))), x) rule3565 = ReplacementRule(pattern3565, replacement3565) pattern3566 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1440, cons31, cons94) def replacement3566(m, f, b, d, c, a, x, e): rubi.append(3566) return Dist(S(1)/(a**S(2) + b**S(2)), Int((a + b/tan(e + f*x))**(m + S(1))*Simp(a*c + b*d - (-a*d + b*c)/tan(e + f*x), x), x), x) - Simp((a + b/tan(e + f*x))**(m + S(1))*(-a*d + b*c)/(f*(a**S(2) + b**S(2))*(m + S(1))), x) rule3566 = ReplacementRule(pattern3566, replacement3566) pattern3567 = Pattern(Integral((c_ + WC('d', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))/(a_ + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1440, cons1542) def replacement3567(f, b, d, a, c, x, e): rubi.append(3567) return Simp(c*log(RemoveContent(a*cos(e + f*x) + b*sin(e + f*x), x))/(b*f), x) rule3567 = ReplacementRule(pattern3567, replacement3567) pattern3568 = Pattern(Integral((c_ + WC('d', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))/(a_ + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1440, cons1542) def replacement3568(f, b, d, a, c, x, e): rubi.append(3568) return -Simp(c*log(RemoveContent(a*sin(e + f*x) + b*cos(e + f*x), x))/(b*f), x) rule3568 = ReplacementRule(pattern3568, replacement3568) pattern3569 = Pattern(Integral((WC('c', S(0)) + WC('d', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))/(WC('a', S(0)) + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1440, cons1543) def replacement3569(f, b, d, c, a, x, e): rubi.append(3569) return Dist((-a*d + b*c)/(a**S(2) + b**S(2)), Int((-a*tan(e + f*x) + b)/(a + b*tan(e + f*x)), x), x) + Simp(x*(a*c + b*d)/(a**S(2) + b**S(2)), x) rule3569 = ReplacementRule(pattern3569, replacement3569) pattern3570 = Pattern(Integral((WC('c', S(0)) + WC('d', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))/(WC('a', S(0)) + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1440, cons1543) def replacement3570(f, b, d, c, a, x, e): rubi.append(3570) return Dist((-a*d + b*c)/(a**S(2) + b**S(2)), Int((-a/tan(e + f*x) + b)/(a + b/tan(e + f*x)), x), x) + Simp(x*(a*c + b*d)/(a**S(2) + b**S(2)), x) rule3570 = ReplacementRule(pattern3570, replacement3570) pattern3571 = Pattern(Integral((c_ + WC('d', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))/sqrt(WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons3, cons7, cons27, cons48, cons125, cons1322) def replacement3571(f, b, d, c, x, e): rubi.append(3571) return Dist(-S(2)*d**S(2)/f, Subst(Int(S(1)/(b*x**S(2) + S(2)*c*d), x), x, (c - d*tan(e + f*x))/sqrt(b*tan(e + f*x))), x) rule3571 = ReplacementRule(pattern3571, replacement3571) pattern3572 = Pattern(Integral((c_ + WC('d', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))/sqrt(WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons3, cons7, cons27, cons48, cons125, cons1322) def replacement3572(f, b, d, c, x, e): rubi.append(3572) return Dist(S(2)*d**S(2)/f, Subst(Int(S(1)/(b*x**S(2) + S(2)*c*d), x), x, (c - d/tan(e + f*x))/sqrt(b/tan(e + f*x))), x) rule3572 = ReplacementRule(pattern3572, replacement3572) pattern3573 = Pattern(Integral((c_ + WC('d', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))/sqrt(WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons3, cons7, cons27, cons48, cons125, cons1544) def replacement3573(f, b, d, c, x, e): rubi.append(3573) return Dist(S(2)*c**S(2)/f, Subst(Int(S(1)/(b*c - d*x**S(2)), x), x, sqrt(b*tan(e + f*x))), x) rule3573 = ReplacementRule(pattern3573, replacement3573) pattern3574 = Pattern(Integral((c_ + WC('d', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))/sqrt(WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons3, cons7, cons27, cons48, cons125, cons1544) def replacement3574(f, b, d, c, x, e): rubi.append(3574) return Dist(-S(2)*c**S(2)/f, Subst(Int(S(1)/(b*c - d*x**S(2)), x), x, sqrt(b/tan(e + f*x))), x) rule3574 = ReplacementRule(pattern3574, replacement3574) pattern3575 = Pattern(Integral((c_ + WC('d', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))/sqrt(WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons3, cons7, cons27, cons48, cons125, cons1323, cons1545) def replacement3575(f, b, d, c, x, e): rubi.append(3575) return Dist(S(2)/f, Subst(Int((b*c + d*x**S(2))/(b**S(2) + x**S(4)), x), x, sqrt(b*tan(e + f*x))), x) rule3575 = ReplacementRule(pattern3575, replacement3575) pattern3576 = Pattern(Integral((c_ + WC('d', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))/sqrt(WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons3, cons7, cons27, cons48, cons125, cons1323, cons1545) def replacement3576(f, b, d, c, x, e): rubi.append(3576) return Dist(-S(2)/f, Subst(Int((b*c + d*x**S(2))/(b**S(2) + x**S(4)), x), x, sqrt(b/tan(e + f*x))), x) rule3576 = ReplacementRule(pattern3576, replacement3576) pattern3577 = Pattern(Integral((WC('c', S(0)) + WC('d', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))/sqrt(a_ + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1440, cons1545, cons1546) def replacement3577(f, b, d, c, a, x, e): rubi.append(3577) return Dist(-S(2)*d**S(2)/f, Subst(Int(S(1)/(-S(4)*a*d**S(2) + S(2)*b*c*d + x**S(2)), x), x, (-S(2)*a*d + b*c - b*d*tan(e + f*x))/sqrt(a + b*tan(e + f*x))), x) rule3577 = ReplacementRule(pattern3577, replacement3577) pattern3578 = Pattern(Integral((WC('c', S(0)) + WC('d', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))/sqrt(a_ + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1440, cons1545, cons1546) def replacement3578(f, b, d, c, a, x, e): rubi.append(3578) return Dist(S(2)*d**S(2)/f, Subst(Int(S(1)/(-S(4)*a*d**S(2) + S(2)*b*c*d + x**S(2)), x), x, (-S(2)*a*d + b*c - b*d/tan(e + f*x))/sqrt(a + b/tan(e + f*x))), x) rule3578 = ReplacementRule(pattern3578, replacement3578) def With3579(f, b, d, c, a, x, e): q = Rt(a**S(2) + b**S(2), S(2)) rubi.append(3579) return -Dist(S(1)/(S(2)*q), Int((a*c + b*d - c*q + (-a*d + b*c - d*q)*tan(e + f*x))/sqrt(a + b*tan(e + f*x)), x), x) + Dist(S(1)/(S(2)*q), Int((a*c + b*d + c*q + (-a*d + b*c + d*q)*tan(e + f*x))/sqrt(a + b*tan(e + f*x)), x), x) pattern3579 = Pattern(Integral((WC('c', S(0)) + WC('d', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))/sqrt(a_ + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1440, cons1545, cons1547, cons1548) rule3579 = ReplacementRule(pattern3579, With3579) def With3580(f, b, d, c, a, x, e): q = Rt(a**S(2) + b**S(2), S(2)) rubi.append(3580) return -Dist(S(1)/(S(2)*q), Int((a*c + b*d - c*q + (-a*d + b*c - d*q)/tan(e + f*x))/sqrt(a + b/tan(e + f*x)), x), x) + Dist(S(1)/(S(2)*q), Int((a*c + b*d + c*q + (-a*d + b*c + d*q)/tan(e + f*x))/sqrt(a + b/tan(e + f*x)), x), x) pattern3580 = Pattern(Integral((WC('c', S(0)) + WC('d', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))/sqrt(a_ + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1440, cons1545, cons1547, cons1548) rule3580 = ReplacementRule(pattern3580, With3580) pattern3581 = Pattern(Integral((c_ + WC('d', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))*(WC('a', S(0)) + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons71, cons1440, cons1544) def replacement3581(m, f, b, d, a, c, x, e): rubi.append(3581) return Dist(c*d/f, Subst(Int((a + b*x/d)**m/(c*x + d**S(2)), x), x, d*tan(e + f*x)), x) rule3581 = ReplacementRule(pattern3581, replacement3581) pattern3582 = Pattern(Integral((c_ + WC('d', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))*(WC('a', S(0)) + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons71, cons1440, cons1544) def replacement3582(m, f, b, d, a, c, x, e): rubi.append(3582) return -Dist(c*d/f, Subst(Int((a + b*x/d)**m/(c*x + d**S(2)), x), x, d/tan(e + f*x)), x) rule3582 = ReplacementRule(pattern3582, replacement3582) pattern3583 = Pattern(Integral((WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(c_ + WC('d', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons3, cons7, cons27, cons48, cons125, cons21, cons1545, cons77) def replacement3583(m, f, b, d, c, x, e): rubi.append(3583) return Dist(c, Int((b*tan(e + f*x))**m, x), x) + Dist(d/b, Int((b*tan(e + f*x))**(m + S(1)), x), x) rule3583 = ReplacementRule(pattern3583, replacement3583) pattern3584 = Pattern(Integral((WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(c_ + WC('d', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons3, cons7, cons27, cons48, cons125, cons21, cons1545, cons77) def replacement3584(m, f, b, d, c, x, e): rubi.append(3584) return Dist(c, Int((b/tan(e + f*x))**m, x), x) + Dist(d/b, Int((b/tan(e + f*x))**(m + S(1)), x), x) rule3584 = ReplacementRule(pattern3584, replacement3584) pattern3585 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons71, cons1440, cons1545, cons18) def replacement3585(m, f, b, d, c, a, x, e): rubi.append(3585) return Dist(c/S(2) - I*d/S(2), Int((a + b*tan(e + f*x))**m*(I*tan(e + f*x) + S(1)), x), x) + Dist(c/S(2) + I*d/S(2), Int((a + b*tan(e + f*x))**m*(-I*tan(e + f*x) + S(1)), x), x) rule3585 = ReplacementRule(pattern3585, replacement3585) pattern3586 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons71, cons1440, cons1545, cons18) def replacement3586(m, f, b, d, c, a, x, e): rubi.append(3586) return Dist(c/S(2) - I*d/S(2), Int((S(1) + I/tan(e + f*x))*(a + b/tan(e + f*x))**m, x), x) + Dist(c/S(2) + I*d/S(2), Int((S(1) - I/tan(e + f*x))*(a + b/tan(e + f*x))**m, x), x) rule3586 = ReplacementRule(pattern3586, replacement3586) pattern3587 = Pattern(Integral((a_ + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**S(2), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons31, cons32, cons1439) def replacement3587(m, f, b, d, c, a, x, e): rubi.append(3587) return Dist(S(1)/(S(2)*a**S(2)), Int((a + b*tan(e + f*x))**(m + S(1))*Simp(a*c**S(2) + a*d**S(2) - S(2)*b*c*d - S(2)*b*d**S(2)*tan(e + f*x), x), x), x) - Simp(b*(a + b*tan(e + f*x))**m*(a*c + b*d)**S(2)/(S(2)*a**S(3)*f*m), x) rule3587 = ReplacementRule(pattern3587, replacement3587) pattern3588 = Pattern(Integral((a_ + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**S(2), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons31, cons32, cons1439) def replacement3588(m, f, b, d, c, a, x, e): rubi.append(3588) return Dist(S(1)/(S(2)*a**S(2)), Int((a + b/tan(e + f*x))**(m + S(1))*Simp(a*c**S(2) + a*d**S(2) - S(2)*b*c*d - S(2)*b*d**S(2)/tan(e + f*x), x), x), x) + Simp(b*(a + b/tan(e + f*x))**m*(a*c + b*d)**S(2)/(S(2)*a**S(3)*f*m), x) rule3588 = ReplacementRule(pattern3588, replacement3588) pattern3589 = Pattern(Integral((WC('c', S(0)) + WC('d', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**S(2)/(WC('a', S(0)) + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1440) def replacement3589(f, b, d, c, a, x, e): rubi.append(3589) return Dist((-a*d + b*c)**S(2)/b**S(2), Int(S(1)/(a + b*tan(e + f*x)), x), x) + Dist(d**S(2)/b, Int(tan(e + f*x), x), x) + Simp(d*x*(-a*d + S(2)*b*c)/b**S(2), x) rule3589 = ReplacementRule(pattern3589, replacement3589) pattern3590 = Pattern(Integral((WC('c', S(0)) + WC('d', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**S(2)/(WC('a', S(0)) + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1440) def replacement3590(f, b, d, c, a, x, e): rubi.append(3590) return Dist((-a*d + b*c)**S(2)/b**S(2), Int(S(1)/(a + b/tan(e + f*x)), x), x) + Dist(d**S(2)/b, Int(S(1)/tan(e + f*x), x), x) + Simp(d*x*(-a*d + S(2)*b*c)/b**S(2), x) rule3590 = ReplacementRule(pattern3590, replacement3590) pattern3591 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**S(2), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons31, cons94, cons1440) def replacement3591(m, f, b, d, c, a, x, e): rubi.append(3591) return Dist(S(1)/(a**S(2) + b**S(2)), Int((a + b*tan(e + f*x))**(m + S(1))*Simp(a*c**S(2) - a*d**S(2) + S(2)*b*c*d - (-S(2)*a*c*d + b*c**S(2) - b*d**S(2))*tan(e + f*x), x), x), x) + Simp((a + b*tan(e + f*x))**(m + S(1))*(-a*d + b*c)**S(2)/(b*f*(a**S(2) + b**S(2))*(m + S(1))), x) rule3591 = ReplacementRule(pattern3591, replacement3591) pattern3592 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**S(2), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons31, cons94, cons1440) def replacement3592(m, f, b, d, c, a, x, e): rubi.append(3592) return Dist(S(1)/(a**S(2) + b**S(2)), Int((a + b/tan(e + f*x))**(m + S(1))*Simp(a*c**S(2) - a*d**S(2) + S(2)*b*c*d - (-S(2)*a*c*d + b*c**S(2) - b*d**S(2))/tan(e + f*x), x), x), x) - Simp((a + b/tan(e + f*x))**(m + S(1))*(-a*d + b*c)**S(2)/(b*f*(a**S(2) + b**S(2))*(m + S(1))), x) rule3592 = ReplacementRule(pattern3592, replacement3592) pattern3593 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**S(2), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons71, cons1549, cons1550) def replacement3593(m, f, b, d, c, a, x, e): rubi.append(3593) return Int((a + b*tan(e + f*x))**m*Simp(c**S(2) + S(2)*c*d*tan(e + f*x) - d**S(2), x), x) + Simp(d**S(2)*(a + b*tan(e + f*x))**(m + S(1))/(b*f*(m + S(1))), x) rule3593 = ReplacementRule(pattern3593, replacement3593) pattern3594 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**S(2), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons71, cons1549, cons1550) def replacement3594(m, f, b, d, c, a, x, e): rubi.append(3594) return Int((a + b/tan(e + f*x))**m*Simp(c**S(2) + S(2)*c*d/tan(e + f*x) - d**S(2), x), x) - Simp(d**S(2)*(a + b/tan(e + f*x))**(m + S(1))/(b*f*(m + S(1))), x) rule3594 = ReplacementRule(pattern3594, replacement3594) pattern3595 = Pattern(Integral(sqrt(a_ + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))/sqrt(WC('c', S(0)) + WC('d', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1439, cons1545) def replacement3595(f, b, d, c, a, x, e): rubi.append(3595) return Dist(-S(2)*a*b/f, Subst(Int(S(1)/(-S(2)*a**S(2)*x**S(2) + a*c - b*d), x), x, sqrt(c + d*tan(e + f*x))/sqrt(a + b*tan(e + f*x))), x) rule3595 = ReplacementRule(pattern3595, replacement3595) pattern3596 = Pattern(Integral(sqrt(a_ + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))/sqrt(WC('c', S(0)) + WC('d', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1439, cons1545) def replacement3596(f, b, d, c, a, x, e): rubi.append(3596) return Dist(S(2)*a*b/f, Subst(Int(S(1)/(-S(2)*a**S(2)*x**S(2) + a*c - b*d), x), x, sqrt(c + d/tan(e + f*x))/sqrt(a + b/tan(e + f*x))), x) rule3596 = ReplacementRule(pattern3596, replacement3596) pattern3597 = Pattern(Integral((a_ + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1439, cons1545, cons93, cons1551, cons1423) def replacement3597(m, f, b, d, c, a, n, x, e): rubi.append(3597) return Dist(S(2)*a**S(2)/(a*c - b*d), Int((a + b*tan(e + f*x))**(m + S(-1))*(c + d*tan(e + f*x))**(n + S(1)), x), x) + Simp(a*b*(a + b*tan(e + f*x))**(m + S(-1))*(c + d*tan(e + f*x))**(n + S(1))/(f*(m + S(-1))*(a*c - b*d)), x) rule3597 = ReplacementRule(pattern3597, replacement3597) pattern3598 = Pattern(Integral((a_ + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1439, cons1545, cons93, cons1551, cons1423) def replacement3598(m, f, b, d, c, n, a, x, e): rubi.append(3598) return Dist(S(2)*a**S(2)/(a*c - b*d), Int((a + b/tan(e + f*x))**(m + S(-1))*(c + d/tan(e + f*x))**(n + S(1)), x), x) - Simp(a*b*(a + b/tan(e + f*x))**(m + S(-1))*(c + d/tan(e + f*x))**(n + S(1))/(f*(m + S(-1))*(a*c - b*d)), x) rule3598 = ReplacementRule(pattern3598, replacement3598) pattern3599 = Pattern(Integral((a_ + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1439, cons1545, cons93, cons1551, cons1385) def replacement3599(m, f, b, d, c, a, n, x, e): rubi.append(3599) return -Dist((a*c - b*d)/(S(2)*b**S(2)), Int((a + b*tan(e + f*x))**(m + S(1))*(c + d*tan(e + f*x))**(n + S(-1)), x), x) + Simp(a*(a + b*tan(e + f*x))**m*(c + d*tan(e + f*x))**n/(S(2)*b*f*m), x) rule3599 = ReplacementRule(pattern3599, replacement3599) pattern3600 = Pattern(Integral((a_ + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1439, cons1545, cons93, cons1551, cons1385) def replacement3600(m, f, b, d, c, n, a, x, e): rubi.append(3600) return -Dist((a*c - b*d)/(S(2)*b**S(2)), Int((a + b/tan(e + f*x))**(m + S(1))*(c + d/tan(e + f*x))**(n + S(-1)), x), x) - Simp(a*(a + b/tan(e + f*x))**m*(c + d/tan(e + f*x))**n/(S(2)*b*f*m), x) rule3600 = ReplacementRule(pattern3600, replacement3600) pattern3601 = Pattern(Integral((a_ + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1439, cons1545, cons93, cons111, cons94) def replacement3601(m, f, b, d, c, a, n, x, e): rubi.append(3601) return Dist(S(1)/(S(2)*a), Int((a + b*tan(e + f*x))**(m + S(1))*(c + d*tan(e + f*x))**n, x), x) + Simp(a*(a + b*tan(e + f*x))**m*(c + d*tan(e + f*x))**(n + S(1))/(S(2)*f*m*(-a*d + b*c)), x) rule3601 = ReplacementRule(pattern3601, replacement3601) pattern3602 = Pattern(Integral((a_ + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1439, cons1545, cons93, cons111, cons94) def replacement3602(m, f, b, d, c, n, a, x, e): rubi.append(3602) return Dist(S(1)/(S(2)*a), Int((a + b/tan(e + f*x))**(m + S(1))*(c + d/tan(e + f*x))**n, x), x) - Simp(a*(a + b/tan(e + f*x))**m*(c + d/tan(e + f*x))**(n + S(1))/(S(2)*f*m*(-a*d + b*c)), x) rule3602 = ReplacementRule(pattern3602, replacement3602) pattern3603 = Pattern(Integral((a_ + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons4, cons71, cons1439, cons1545, cons155, cons272) def replacement3603(m, f, b, d, c, a, n, x, e): rubi.append(3603) return Dist(a/(a*c - b*d), Int((a + b*tan(e + f*x))**m*(c + d*tan(e + f*x))**(n + S(1)), x), x) - Simp(d*(a + b*tan(e + f*x))**m*(c + d*tan(e + f*x))**(n + S(1))/(f*m*(c**S(2) + d**S(2))), x) rule3603 = ReplacementRule(pattern3603, replacement3603) pattern3604 = Pattern(Integral((a_ + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons4, cons71, cons1439, cons1545, cons155, cons272) def replacement3604(m, f, b, d, c, n, a, x, e): rubi.append(3604) return Dist(a/(a*c - b*d), Int((a + b/tan(e + f*x))**m*(c + d/tan(e + f*x))**(n + S(1)), x), x) + Simp(d*(a + b/tan(e + f*x))**m*(c + d/tan(e + f*x))**(n + S(1))/(f*m*(c**S(2) + d**S(2))), x) rule3604 = ReplacementRule(pattern3604, replacement3604) pattern3605 = Pattern(Integral((WC('c', S(0)) + WC('d', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_/(a_ + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1439, cons1545, cons87, cons1325) def replacement3605(f, b, d, c, a, n, x, e): rubi.append(3605) return Dist(S(1)/(S(2)*a*(-a*d + b*c)), Int((c + d*tan(e + f*x))**(n + S(-1))*Simp(a*c*d*(n + S(-1)) + b*c**S(2) + b*d**S(2)*n - d*(n + S(-1))*(-a*d + b*c)*tan(e + f*x), x), x), x) - Simp((c + d*tan(e + f*x))**n*(a*c + b*d)/(S(2)*f*(a + b*tan(e + f*x))*(-a*d + b*c)), x) rule3605 = ReplacementRule(pattern3605, replacement3605) pattern3606 = Pattern(Integral((WC('c', S(0)) + WC('d', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_/(a_ + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1439, cons1545, cons87, cons1325) def replacement3606(f, b, d, c, n, a, x, e): rubi.append(3606) return Dist(S(1)/(S(2)*a*(-a*d + b*c)), Int((c + d/tan(e + f*x))**(n + S(-1))*Simp(a*c*d*(n + S(-1)) + b*c**S(2) + b*d**S(2)*n - d*(n + S(-1))*(-a*d + b*c)/tan(e + f*x), x), x), x) + Simp((c + d/tan(e + f*x))**n*(a*c + b*d)/(S(2)*f*(a + b/tan(e + f*x))*(-a*d + b*c)), x) rule3606 = ReplacementRule(pattern3606, replacement3606) pattern3607 = Pattern(Integral((WC('c', S(0)) + WC('d', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_/(a_ + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1439, cons1545, cons87, cons165) def replacement3607(f, b, d, c, a, n, x, e): rubi.append(3607) return Dist(S(1)/(S(2)*a**S(2)), Int((c + d*tan(e + f*x))**(n + S(-2))*Simp(a*c**S(2) + a*d**S(2)*(n + S(-1)) - b*c*d*n - d*(a*c*(n + S(-2)) + b*d*n)*tan(e + f*x), x), x), x) + Simp((c + d*tan(e + f*x))**(n + S(-1))*(-a*d + b*c)/(S(2)*a*f*(a + b*tan(e + f*x))), x) rule3607 = ReplacementRule(pattern3607, replacement3607) pattern3608 = Pattern(Integral((WC('c', S(0)) + WC('d', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_/(a_ + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1439, cons1545, cons87, cons165) def replacement3608(f, b, d, c, n, a, x, e): rubi.append(3608) return Dist(S(1)/(S(2)*a**S(2)), Int((c + d/tan(e + f*x))**(n + S(-2))*Simp(a*c**S(2) + a*d**S(2)*(n + S(-1)) - b*c*d*n - d*(a*c*(n + S(-2)) + b*d*n)/tan(e + f*x), x), x), x) - Simp((c + d/tan(e + f*x))**(n + S(-1))*(-a*d + b*c)/(S(2)*a*f*(a + b/tan(e + f*x))), x) rule3608 = ReplacementRule(pattern3608, replacement3608) pattern3609 = Pattern(Integral(S(1)/((WC('a', S(0)) + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))*(WC('c', S(0)) + WC('d', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1439, cons1545) def replacement3609(f, b, d, c, a, x, e): rubi.append(3609) return Dist(b/(-a*d + b*c), Int(S(1)/(a + b*tan(e + f*x)), x), x) - Dist(d/(-a*d + b*c), Int(S(1)/(c + d*tan(e + f*x)), x), x) rule3609 = ReplacementRule(pattern3609, replacement3609) pattern3610 = Pattern(Integral(S(1)/((WC('a', S(0)) + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))*(WC('c', S(0)) + WC('d', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1439, cons1545) def replacement3610(f, b, d, c, a, x, e): rubi.append(3610) return Dist(b/(-a*d + b*c), Int(S(1)/(a + b/tan(e + f*x)), x), x) - Dist(d/(-a*d + b*c), Int(S(1)/(c + d/tan(e + f*x)), x), x) rule3610 = ReplacementRule(pattern3610, replacement3610) pattern3611 = Pattern(Integral((WC('c', S(0)) + WC('d', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_/(a_ + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons4, cons71, cons1439, cons1545, cons1327) def replacement3611(f, b, d, c, a, n, x, e): rubi.append(3611) return Dist(S(1)/(S(2)*a*(-a*d + b*c)), Int((c + d*tan(e + f*x))**n*Simp(a*d*(n + S(-1)) + b*c - b*d*n*tan(e + f*x), x), x), x) - Simp(a*(c + d*tan(e + f*x))**(n + S(1))/(S(2)*f*(a + b*tan(e + f*x))*(-a*d + b*c)), x) rule3611 = ReplacementRule(pattern3611, replacement3611) pattern3612 = Pattern(Integral((WC('c', S(0)) + WC('d', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_/(a_ + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons4, cons71, cons1439, cons1545, cons1327) def replacement3612(f, b, d, c, n, a, x, e): rubi.append(3612) return Dist(S(1)/(S(2)*a*(-a*d + b*c)), Int((c + d/tan(e + f*x))**n*Simp(a*d*(n + S(-1)) + b*c - b*d*n/tan(e + f*x), x), x), x) + Simp(a*(c + d/tan(e + f*x))**(n + S(1))/(S(2)*f*(a + b/tan(e + f*x))*(-a*d + b*c)), x) rule3612 = ReplacementRule(pattern3612, replacement3612) pattern3613 = Pattern(Integral((a_ + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1439, cons1545, cons93, cons166, cons89, cons1334) def replacement3613(m, f, b, d, c, a, n, x, e): rubi.append(3613) return Dist(a/(d*(n + S(1))*(a*d + b*c)), Int((a + b*tan(e + f*x))**(m + S(-2))*(c + d*tan(e + f*x))**(n + S(1))*Simp(b*(-a*d*(m - S(2)*n + S(-4)) + b*c*(m + S(-2))) + (-a**S(2)*d*(m + n + S(-1)) + a*b*c*(m + S(-2)) + b**S(2)*d*(n + S(1)))*tan(e + f*x), x), x), x) - Simp(a**S(2)*(a + b*tan(e + f*x))**(m + S(-2))*(c + d*tan(e + f*x))**(n + S(1))*(-a*d + b*c)/(d*f*(n + S(1))*(a*d + b*c)), x) rule3613 = ReplacementRule(pattern3613, replacement3613) pattern3614 = Pattern(Integral((a_ + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1439, cons1545, cons93, cons166, cons89, cons1334) def replacement3614(m, f, b, d, c, n, a, x, e): rubi.append(3614) return Dist(a/(d*(n + S(1))*(a*d + b*c)), Int((a + b/tan(e + f*x))**(m + S(-2))*(c + d/tan(e + f*x))**(n + S(1))*Simp(b*(-a*d*(m - S(2)*n + S(-4)) + b*c*(m + S(-2))) + (-a**S(2)*d*(m + n + S(-1)) + a*b*c*(m + S(-2)) + b**S(2)*d*(n + S(1)))/tan(e + f*x), x), x), x) + Simp(a**S(2)*(a + b/tan(e + f*x))**(m + S(-2))*(c + d/tan(e + f*x))**(n + S(1))*(-a*d + b*c)/(d*f*(n + S(1))*(a*d + b*c)), x) rule3614 = ReplacementRule(pattern3614, replacement3614) pattern3615 = Pattern(Integral((a_ + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**(S(3)/2)/(WC('c', S(0)) + WC('d', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1439, cons1545) def replacement3615(f, b, d, c, a, x, e): rubi.append(3615) return Dist(S(2)*a**S(2)/(a*c - b*d), Int(sqrt(a + b*tan(e + f*x)), x), x) - Dist((a*(c**S(2) - d**S(2)) + S(2)*b*c*d)/(a*(c**S(2) + d**S(2))), Int((a - b*tan(e + f*x))*sqrt(a + b*tan(e + f*x))/(c + d*tan(e + f*x)), x), x) rule3615 = ReplacementRule(pattern3615, replacement3615) pattern3616 = Pattern(Integral((a_ + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**(S(3)/2)/(WC('c', S(0)) + WC('d', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1439, cons1545) def replacement3616(f, b, d, c, a, x, e): rubi.append(3616) return Dist(S(2)*a**S(2)/(a*c - b*d), Int(sqrt(a + b/tan(e + f*x)), x), x) - Dist((a*(c**S(2) - d**S(2)) + S(2)*b*c*d)/(a*(c**S(2) + d**S(2))), Int((a - b/tan(e + f*x))*sqrt(a + b/tan(e + f*x))/(c + d/tan(e + f*x)), x), x) rule3616 = ReplacementRule(pattern3616, replacement3616) pattern3617 = Pattern(Integral((a_ + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**(S(3)/2)/sqrt(WC('c', S(0)) + WC('d', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1439, cons1545) def replacement3617(f, b, d, c, a, x, e): rubi.append(3617) return Dist(S(2)*a, Int(sqrt(a + b*tan(e + f*x))/sqrt(c + d*tan(e + f*x)), x), x) + Dist(b/a, Int(sqrt(a + b*tan(e + f*x))*(a*tan(e + f*x) + b)/sqrt(c + d*tan(e + f*x)), x), x) rule3617 = ReplacementRule(pattern3617, replacement3617) pattern3618 = Pattern(Integral((a_ + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**(S(3)/2)/sqrt(WC('c', S(0)) + WC('d', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1439, cons1545) def replacement3618(f, b, d, c, a, x, e): rubi.append(3618) return Dist(S(2)*a, Int(sqrt(a + b/tan(e + f*x))/sqrt(c + d/tan(e + f*x)), x), x) + Dist(b/a, Int(sqrt(a + b/tan(e + f*x))*(a/tan(e + f*x) + b)/sqrt(c + d/tan(e + f*x)), x), x) rule3618 = ReplacementRule(pattern3618, replacement3618) pattern3619 = Pattern(Integral((a_ + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons4, cons71, cons1439, cons1545, cons515, cons166, cons1519, cons1334) def replacement3619(m, f, b, d, c, a, n, x, e): rubi.append(3619) return Dist(a/(d*(m + n + S(-1))), Int((a + b*tan(e + f*x))**(m + S(-2))*(c + d*tan(e + f*x))**n*Simp(a*d*(m + S(2)*n) + b*c*(m + S(-2)) + (a*c*(m + S(-2)) + b*d*(S(3)*m + S(2)*n + S(-4)))*tan(e + f*x), x), x), x) + Simp(b**S(2)*(a + b*tan(e + f*x))**(m + S(-2))*(c + d*tan(e + f*x))**(n + S(1))/(d*f*(m + n + S(-1))), x) rule3619 = ReplacementRule(pattern3619, replacement3619) pattern3620 = Pattern(Integral((a_ + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons4, cons71, cons1439, cons1545, cons515, cons166, cons1519, cons1334) def replacement3620(m, f, b, d, c, n, a, x, e): rubi.append(3620) return Dist(a/(d*(m + n + S(-1))), Int((a + b/tan(e + f*x))**(m + S(-2))*(c + d/tan(e + f*x))**n*Simp(a*d*(m + S(2)*n) + b*c*(m + S(-2)) + (a*c*(m + S(-2)) + b*d*(S(3)*m + S(2)*n + S(-4)))/tan(e + f*x), x), x), x) - Simp(b**S(2)*(a + b/tan(e + f*x))**(m + S(-2))*(c + d/tan(e + f*x))**(n + S(1))/(d*f*(m + n + S(-1))), x) rule3620 = ReplacementRule(pattern3620, replacement3620) pattern3621 = Pattern(Integral((a_ + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*sqrt(WC('c', S(0)) + WC('d', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1439, cons1545, cons31, cons267, cons1552) def replacement3621(m, f, b, d, c, a, x, e): rubi.append(3621) return Dist(S(1)/(S(4)*a**S(2)*m), Int((a + b*tan(e + f*x))**(m + S(1))*Simp(S(2)*a*c*m + a*d*(S(2)*m + S(1))*tan(e + f*x) + b*d, x)/sqrt(c + d*tan(e + f*x)), x), x) - Simp(b*(a + b*tan(e + f*x))**m*sqrt(c + d*tan(e + f*x))/(S(2)*a*f*m), x) rule3621 = ReplacementRule(pattern3621, replacement3621) pattern3622 = Pattern(Integral((a_ + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*sqrt(WC('c', S(0)) + WC('d', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1439, cons1545, cons31, cons267, cons1552) def replacement3622(m, f, b, d, c, a, x, e): rubi.append(3622) return Dist(S(1)/(S(4)*a**S(2)*m), Int((a + b/tan(e + f*x))**(m + S(1))*Simp(S(2)*a*c*m + a*d*(S(2)*m + S(1))/tan(e + f*x) + b*d, x)/sqrt(c + d/tan(e + f*x)), x), x) + Simp(b*(a + b/tan(e + f*x))**m*sqrt(c + d/tan(e + f*x))/(S(2)*a*f*m), x) rule3622 = ReplacementRule(pattern3622, replacement3622) pattern3623 = Pattern(Integral((a_ + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1439, cons1545, cons93, cons267, cons165, cons1334) def replacement3623(m, f, b, d, c, a, n, x, e): rubi.append(3623) return Dist(S(1)/(S(2)*a**S(2)*m), Int((a + b*tan(e + f*x))**(m + S(1))*(c + d*tan(e + f*x))**(n + S(-2))*Simp(c*(a*c*m + b*d*(n + S(-1))) - d*(-a*c*(m + n + S(-1)) + b*d*(m - n + S(1)))*tan(e + f*x) - d*(a*d*(n + S(-1)) + b*c*m), x), x), x) - Simp((a + b*tan(e + f*x))**m*(c + d*tan(e + f*x))**(n + S(-1))*(-a*d + b*c)/(S(2)*a*f*m), x) rule3623 = ReplacementRule(pattern3623, replacement3623) pattern3624 = Pattern(Integral((a_ + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1439, cons1545, cons93, cons267, cons165, cons1334) def replacement3624(m, f, b, d, c, n, a, x, e): rubi.append(3624) return Dist(S(1)/(S(2)*a**S(2)*m), Int((a + b/tan(e + f*x))**(m + S(1))*(c + d/tan(e + f*x))**(n + S(-2))*Simp(c*(a*c*m + b*d*(n + S(-1))) - d*(-a*c*(m + n + S(-1)) + b*d*(m - n + S(1)))/tan(e + f*x) - d*(a*d*(n + S(-1)) + b*c*m), x), x), x) + Simp((a + b/tan(e + f*x))**m*(c + d/tan(e + f*x))**(n + S(-1))*(-a*d + b*c)/(S(2)*a*f*m), x) rule3624 = ReplacementRule(pattern3624, replacement3624) pattern3625 = Pattern(Integral((a_ + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons4, cons71, cons1439, cons1545, cons31, cons267, cons1334) def replacement3625(m, f, b, d, c, a, n, x, e): rubi.append(3625) return Dist(S(1)/(S(2)*a*m*(-a*d + b*c)), Int((a + b*tan(e + f*x))**(m + S(1))*(c + d*tan(e + f*x))**n*Simp(-a*d*(S(2)*m + n + S(1)) + b*c*m + b*d*(m + n + S(1))*tan(e + f*x), x), x), x) + Simp(a*(a + b*tan(e + f*x))**m*(c + d*tan(e + f*x))**(n + S(1))/(S(2)*f*m*(-a*d + b*c)), x) rule3625 = ReplacementRule(pattern3625, replacement3625) pattern3626 = Pattern(Integral((a_ + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons4, cons71, cons1439, cons1545, cons31, cons267, cons1334) def replacement3626(m, f, b, d, c, n, a, x, e): rubi.append(3626) return Dist(S(1)/(S(2)*a*m*(-a*d + b*c)), Int((a + b/tan(e + f*x))**(m + S(1))*(c + d/tan(e + f*x))**n*Simp(-a*d*(S(2)*m + n + S(1)) + b*c*m + b*d*(m + n + S(1))/tan(e + f*x), x), x), x) - Simp(a*(a + b/tan(e + f*x))**m*(c + d/tan(e + f*x))**(n + S(1))/(S(2)*f*m*(-a*d + b*c)), x) rule3626 = ReplacementRule(pattern3626, replacement3626) pattern3627 = Pattern(Integral((a_ + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons71, cons1439, cons1545, cons87, cons165, cons1519, cons1553) def replacement3627(m, f, b, d, c, a, n, x, e): rubi.append(3627) return -Dist(S(1)/(a*(m + n + S(-1))), Int((a + b*tan(e + f*x))**m*(c + d*tan(e + f*x))**(n + S(-2))*Simp(-a*c**S(2)*(m + n + S(-1)) + d*(-a*c*(m + S(2)*n + S(-2)) + b*d*m)*tan(e + f*x) + d*(a*d*(n + S(-1)) + b*c*m), x), x), x) + Simp(d*(a + b*tan(e + f*x))**m*(c + d*tan(e + f*x))**(n + S(-1))/(f*(m + n + S(-1))), x) rule3627 = ReplacementRule(pattern3627, replacement3627) pattern3628 = Pattern(Integral((a_ + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(WC('c', S(0)) + WC('d', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons71, cons1439, cons1545, cons87, cons165, cons1519, cons1553) def replacement3628(m, f, b, d, c, a, n, x, e): rubi.append(3628) return -Dist(S(1)/(a*(m + n + S(-1))), Int((a + b/tan(e + f*x))**m*(c + d/tan(e + f*x))**(n + S(-2))*Simp(-a*c**S(2)*(m + n + S(-1)) + d*(-a*c*(m + S(2)*n + S(-2)) + b*d*m)/tan(e + f*x) + d*(a*d*(n + S(-1)) + b*c*m), x), x), x) - Simp(d*(a + b/tan(e + f*x))**m*(c + d/tan(e + f*x))**(n + S(-1))/(f*(m + n + S(-1))), x) rule3628 = ReplacementRule(pattern3628, replacement3628) pattern3629 = Pattern(Integral((a_ + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons71, cons1439, cons1545, cons87, cons89, cons1553) def replacement3629(m, f, b, d, c, a, n, x, e): rubi.append(3629) return -Dist(S(1)/(a*(c**S(2) + d**S(2))*(n + S(1))), Int((a + b*tan(e + f*x))**m*(c + d*tan(e + f*x))**(n + S(1))*Simp(-a*c*(n + S(1)) + a*d*(m + n + S(1))*tan(e + f*x) + b*d*m, x), x), x) + Simp(d*(a + b*tan(e + f*x))**m*(c + d*tan(e + f*x))**(n + S(1))/(f*(c**S(2) + d**S(2))*(n + S(1))), x) rule3629 = ReplacementRule(pattern3629, replacement3629) pattern3630 = Pattern(Integral((a_ + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons71, cons1439, cons1545, cons87, cons89, cons1553) def replacement3630(m, f, b, d, c, n, a, x, e): rubi.append(3630) return -Dist(S(1)/(a*(c**S(2) + d**S(2))*(n + S(1))), Int((a + b/tan(e + f*x))**m*(c + d/tan(e + f*x))**(n + S(1))*Simp(-a*c*(n + S(1)) + a*d*(m + n + S(1))/tan(e + f*x) + b*d*m, x), x), x) - Simp(d*(a + b/tan(e + f*x))**m*(c + d/tan(e + f*x))**(n + S(1))/(f*(c**S(2) + d**S(2))*(n + S(1))), x) rule3630 = ReplacementRule(pattern3630, replacement3630) pattern3631 = Pattern(Integral((a_ + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_/(WC('c', S(0)) + WC('d', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons71, cons1439, cons1545) def replacement3631(m, f, b, d, c, a, x, e): rubi.append(3631) return Dist(a/(a*c - b*d), Int((a + b*tan(e + f*x))**m, x), x) - Dist(d/(a*c - b*d), Int((a + b*tan(e + f*x))**m*(a*tan(e + f*x) + b)/(c + d*tan(e + f*x)), x), x) rule3631 = ReplacementRule(pattern3631, replacement3631) pattern3632 = Pattern(Integral((a_ + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_/(WC('c', S(0)) + WC('d', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons71, cons1439, cons1545) def replacement3632(m, f, b, d, c, a, x, e): rubi.append(3632) return Dist(a/(a*c - b*d), Int((a + b/tan(e + f*x))**m, x), x) - Dist(d/(a*c - b*d), Int((a + b/tan(e + f*x))**m*(a/tan(e + f*x) + b)/(c + d/tan(e + f*x)), x), x) rule3632 = ReplacementRule(pattern3632, replacement3632) pattern3633 = Pattern(Integral(sqrt(a_ + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))*sqrt(WC('c', S(0)) + WC('d', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1439, cons1545) def replacement3633(f, b, d, c, a, x, e): rubi.append(3633) return Dist(d/a, Int(sqrt(a + b*tan(e + f*x))*(a*tan(e + f*x) + b)/sqrt(c + d*tan(e + f*x)), x), x) + Dist((a*c - b*d)/a, Int(sqrt(a + b*tan(e + f*x))/sqrt(c + d*tan(e + f*x)), x), x) rule3633 = ReplacementRule(pattern3633, replacement3633) pattern3634 = Pattern(Integral(sqrt(a_ + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))*sqrt(WC('c', S(0)) + WC('d', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1439, cons1545) def replacement3634(f, b, d, c, a, x, e): rubi.append(3634) return Dist(d/a, Int(sqrt(a + b/tan(e + f*x))*(a/tan(e + f*x) + b)/sqrt(c + d/tan(e + f*x)), x), x) + Dist((a*c - b*d)/a, Int(sqrt(a + b/tan(e + f*x))/sqrt(c + d/tan(e + f*x)), x), x) rule3634 = ReplacementRule(pattern3634, replacement3634) pattern3635 = Pattern(Integral((a_ + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons4, cons71, cons1439, cons1545) def replacement3635(m, f, b, d, c, a, n, x, e): rubi.append(3635) return Dist(a*b/f, Subst(Int((a + x)**(m + S(-1))*(c + d*x/b)**n/(a*x + b**S(2)), x), x, b*tan(e + f*x)), x) rule3635 = ReplacementRule(pattern3635, replacement3635) pattern3636 = Pattern(Integral((a_ + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(WC('c', S(0)) + WC('d', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons4, cons71, cons1439, cons1545) def replacement3636(m, f, b, d, c, a, n, x, e): rubi.append(3636) return -Dist(a*b/f, Subst(Int((a + x)**(m + S(-1))*(c + d*x/b)**n/(a*x + b**S(2)), x), x, b/tan(e + f*x)), x) rule3636 = ReplacementRule(pattern3636, replacement3636) pattern3637 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1440, cons1545, cons93, cons1333, cons89, cons515) def replacement3637(m, f, b, d, c, a, n, x, e): rubi.append(3637) return -Dist(S(1)/(d*(c**S(2) + d**S(2))*(n + S(1))), Int((a + b*tan(e + f*x))**(m + S(-3))*(c + d*tan(e + f*x))**(n + S(1))*Simp(a**S(2)*d*(-a*c*(n + S(1)) + b*d*(m + S(-2))) + b*(-S(2)*a*d + b*c)*(a*d*(n + S(1)) + b*c*(m + S(-2))) - b*(a*d*(-a*d + S(2)*b*c)*(m + n + S(-1)) - b**S(2)*(c**S(2)*(m + S(-2)) - d**S(2)*(n + S(1))))*tan(e + f*x)**S(2) - d*(n + S(1))*(-a**S(3)*d + S(3)*a**S(2)*b*c + S(3)*a*b**S(2)*d - b**S(3)*c)*tan(e + f*x), x), x), x) + Simp((a + b*tan(e + f*x))**(m + S(-2))*(c + d*tan(e + f*x))**(n + S(1))*(-a*d + b*c)**S(2)/(d*f*(c**S(2) + d**S(2))*(n + S(1))), x) rule3637 = ReplacementRule(pattern3637, replacement3637) pattern3638 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1440, cons1545, cons93, cons1333, cons89, cons515) def replacement3638(m, f, b, d, c, a, n, x, e): rubi.append(3638) return -Dist(S(1)/(d*(c**S(2) + d**S(2))*(n + S(1))), Int((a + b/tan(e + f*x))**(m + S(-3))*(c + d/tan(e + f*x))**(n + S(1))*Simp(a**S(2)*d*(-a*c*(n + S(1)) + b*d*(m + S(-2))) + b*(-S(2)*a*d + b*c)*(a*d*(n + S(1)) + b*c*(m + S(-2))) - b*(a*d*(-a*d + S(2)*b*c)*(m + n + S(-1)) - b**S(2)*(c**S(2)*(m + S(-2)) - d**S(2)*(n + S(1))))/tan(e + f*x)**S(2) - d*(n + S(1))*(-a**S(3)*d + S(3)*a**S(2)*b*c + S(3)*a*b**S(2)*d - b**S(3)*c)/tan(e + f*x), x), x), x) - Simp((a + b/tan(e + f*x))**(m + S(-2))*(c + d/tan(e + f*x))**(n + S(1))*(-a*d + b*c)**S(2)/(d*f*(c**S(2) + d**S(2))*(n + S(1))), x) rule3638 = ReplacementRule(pattern3638, replacement3638) pattern3639 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons4, cons71, cons1440, cons1545, cons515, cons1333, cons1554, cons1555) def replacement3639(m, f, b, d, c, a, n, x, e): rubi.append(3639) return Dist(S(1)/(d*(m + n + S(-1))), Int((a + b*tan(e + f*x))**(m + S(-3))*(c + d*tan(e + f*x))**n*Simp(a**S(3)*d*(m + n + S(-1)) - b**S(2)*(a*d*(n + S(1)) + b*c*(m + S(-2))) - b**S(2)*(-a*d*(S(3)*m + S(2)*n + S(-4)) + b*c*(m + S(-2)))*tan(e + f*x)**S(2) + b*d*(S(3)*a**S(2) - b**S(2))*(m + n + S(-1))*tan(e + f*x), x), x), x) + Simp(b**S(2)*(a + b*tan(e + f*x))**(m + S(-2))*(c + d*tan(e + f*x))**(n + S(1))/(d*f*(m + n + S(-1))), x) rule3639 = ReplacementRule(pattern3639, replacement3639) pattern3640 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons4, cons71, cons1440, cons1545, cons515, cons1333, cons1554, cons1555) def replacement3640(m, f, b, d, c, a, n, x, e): rubi.append(3640) return Dist(S(1)/(d*(m + n + S(-1))), Int((a + b/tan(e + f*x))**(m + S(-3))*(c + d/tan(e + f*x))**n*Simp(a**S(3)*d*(m + n + S(-1)) - b**S(2)*(a*d*(n + S(1)) + b*c*(m + S(-2))) - b**S(2)*(-a*d*(S(3)*m + S(2)*n + S(-4)) + b*c*(m + S(-2)))/tan(e + f*x)**S(2) + b*d*(S(3)*a**S(2) - b**S(2))*(m + n + S(-1))/tan(e + f*x), x), x), x) - Simp(b**S(2)*(a + b/tan(e + f*x))**(m + S(-2))*(c + d/tan(e + f*x))**(n + S(1))/(d*f*(m + n + S(-1))), x) rule3640 = ReplacementRule(pattern3640, replacement3640) pattern3641 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1440, cons1545, cons93, cons94, cons1336, cons515) def replacement3641(m, f, b, d, c, a, n, x, e): rubi.append(3641) return Dist(S(1)/((a**S(2) + b**S(2))*(m + S(1))), Int((a + b*tan(e + f*x))**(m + S(1))*(c + d*tan(e + f*x))**(n + S(-2))*Simp(a*c**S(2)*(m + S(1)) + a*d**S(2)*(n + S(-1)) + b*c*d*(m - n + S(2)) - d*(m + n)*(-a*d + b*c)*tan(e + f*x)**S(2) - (m + S(1))*(-S(2)*a*c*d + b*c**S(2) - b*d**S(2))*tan(e + f*x), x), x), x) + Simp((a + b*tan(e + f*x))**(m + S(1))*(c + d*tan(e + f*x))**(n + S(-1))*(-a*d + b*c)/(f*(a**S(2) + b**S(2))*(m + S(1))), x) rule3641 = ReplacementRule(pattern3641, replacement3641) pattern3642 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1440, cons1545, cons93, cons94, cons1336, cons515) def replacement3642(m, f, b, d, c, a, n, x, e): rubi.append(3642) return Dist(S(1)/((a**S(2) + b**S(2))*(m + S(1))), Int((a + b/tan(e + f*x))**(m + S(1))*(c + d/tan(e + f*x))**(n + S(-2))*Simp(a*c**S(2)*(m + S(1)) + a*d**S(2)*(n + S(-1)) + b*c*d*(m - n + S(2)) - d*(m + n)*(-a*d + b*c)/tan(e + f*x)**S(2) - (m + S(1))*(-S(2)*a*c*d + b*c**S(2) - b*d**S(2))/tan(e + f*x), x), x), x) - Simp((a + b/tan(e + f*x))**(m + S(1))*(c + d/tan(e + f*x))**(n + S(-1))*(-a*d + b*c)/(f*(a**S(2) + b**S(2))*(m + S(1))), x) rule3642 = ReplacementRule(pattern3642, replacement3642) pattern3643 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1440, cons1545, cons93, cons94, cons88, cons515) def replacement3643(m, f, b, d, c, a, n, x, e): rubi.append(3643) return Dist(S(1)/((a**S(2) + b**S(2))*(m + S(1))), Int((a + b*tan(e + f*x))**(m + S(1))*(c + d*tan(e + f*x))**(n + S(-1))*Simp(a*c*(m + S(1)) - b*d*n - b*d*(m + n + S(1))*tan(e + f*x)**S(2) - (m + S(1))*(-a*d + b*c)*tan(e + f*x), x), x), x) + Simp(b*(a + b*tan(e + f*x))**(m + S(1))*(c + d*tan(e + f*x))**n/(f*(a**S(2) + b**S(2))*(m + S(1))), x) rule3643 = ReplacementRule(pattern3643, replacement3643) pattern3644 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1440, cons1545, cons93, cons94, cons88, cons515) def replacement3644(m, f, b, d, c, a, n, x, e): rubi.append(3644) return Dist(S(1)/((a**S(2) + b**S(2))*(m + S(1))), Int((a + b/tan(e + f*x))**(m + S(1))*(c + d/tan(e + f*x))**(n + S(-1))*Simp(a*c*(m + S(1)) - b*d*n - b*d*(m + n + S(1))/tan(e + f*x)**S(2) - (m + S(1))*(-a*d + b*c)/tan(e + f*x), x), x), x) - Simp(b*(a + b/tan(e + f*x))**(m + S(1))*(c + d/tan(e + f*x))**n/(f*(a**S(2) + b**S(2))*(m + S(1))), x) rule3644 = ReplacementRule(pattern3644, replacement3644) pattern3645 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons4, cons71, cons1440, cons1545, cons515, cons94, cons1556, cons1557) def replacement3645(m, f, b, d, c, a, n, x, e): rubi.append(3645) return Dist(S(1)/((a**S(2) + b**S(2))*(m + S(1))*(-a*d + b*c)), Int((a + b*tan(e + f*x))**(m + S(1))*(c + d*tan(e + f*x))**n*Simp(a*(m + S(1))*(-a*d + b*c) - b**S(2)*d*(m + n + S(2))*tan(e + f*x)**S(2) - b**S(2)*d*(m + n + S(2)) - b*(m + S(1))*(-a*d + b*c)*tan(e + f*x), x), x), x) + Simp(b**S(2)*(a + b*tan(e + f*x))**(m + S(1))*(c + d*tan(e + f*x))**(n + S(1))/(f*(a**S(2) + b**S(2))*(m + S(1))*(-a*d + b*c)), x) rule3645 = ReplacementRule(pattern3645, replacement3645) pattern3646 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons4, cons71, cons1440, cons1545, cons515, cons94, cons1556, cons1557) def replacement3646(m, f, b, d, c, a, n, x, e): rubi.append(3646) return Dist(S(1)/((a**S(2) + b**S(2))*(m + S(1))*(-a*d + b*c)), Int((a + b/tan(e + f*x))**(m + S(1))*(c + d/tan(e + f*x))**n*Simp(a*(m + S(1))*(-a*d + b*c) - b**S(2)*d*(m + n + S(2)) - b**S(2)*d*(m + n + S(2))/tan(e + f*x)**S(2) - b*(m + S(1))*(-a*d + b*c)/tan(e + f*x), x), x), x) - Simp(b**S(2)*(a + b/tan(e + f*x))**(m + S(1))*(c + d/tan(e + f*x))**(n + S(1))/(f*(a**S(2) + b**S(2))*(m + S(1))*(-a*d + b*c)), x) rule3646 = ReplacementRule(pattern3646, replacement3646) pattern3647 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1440, cons1545, cons93, cons166, cons88, cons808) def replacement3647(m, f, b, d, c, a, n, x, e): rubi.append(3647) return Dist(S(1)/(m + n + S(-1)), Int((a + b*tan(e + f*x))**(m + S(-2))*(c + d*tan(e + f*x))**(n + S(-1))*Simp(a**S(2)*c*(m + n + S(-1)) - b*(a*d*n + b*c*(m + S(-1))) + b*(a*d*(S(2)*m + n + S(-2)) + b*c*n)*tan(e + f*x)**S(2) + (m + n + S(-1))*(a**S(2)*d + S(2)*a*b*c - b**S(2)*d)*tan(e + f*x), x), x), x) + Simp(b*(a + b*tan(e + f*x))**(m + S(-1))*(c + d*tan(e + f*x))**n/(f*(m + n + S(-1))), x) rule3647 = ReplacementRule(pattern3647, replacement3647) pattern3648 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1440, cons1545, cons93, cons166, cons88, cons808) def replacement3648(m, f, b, d, c, a, n, x, e): rubi.append(3648) return Dist(S(1)/(m + n + S(-1)), Int((a + b/tan(e + f*x))**(m + S(-2))*(c + d/tan(e + f*x))**(n + S(-1))*Simp(a**S(2)*c*(m + n + S(-1)) - b*(a*d*n + b*c*(m + S(-1))) + b*(a*d*(S(2)*m + n + S(-2)) + b*c*n)/tan(e + f*x)**S(2) + (m + n + S(-1))*(a**S(2)*d + S(2)*a*b*c - b**S(2)*d)/tan(e + f*x), x), x), x) - Simp(b*(a + b/tan(e + f*x))**(m + S(-1))*(c + d/tan(e + f*x))**n/(f*(m + n + S(-1))), x) rule3648 = ReplacementRule(pattern3648, replacement3648) pattern3649 = Pattern(Integral(S(1)/((a_ + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))*(WC('c', S(0)) + WC('d', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1440, cons1545) def replacement3649(f, b, d, c, a, x, e): rubi.append(3649) return Dist(b**S(2)/((a**S(2) + b**S(2))*(-a*d + b*c)), Int((-a*tan(e + f*x) + b)/(a + b*tan(e + f*x)), x), x) - Dist(d**S(2)/((c**S(2) + d**S(2))*(-a*d + b*c)), Int((-c*tan(e + f*x) + d)/(c + d*tan(e + f*x)), x), x) + Simp(x*(a*c - b*d)/((a**S(2) + b**S(2))*(c**S(2) + d**S(2))), x) rule3649 = ReplacementRule(pattern3649, replacement3649) pattern3650 = Pattern(Integral(S(1)/((a_ + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))*(WC('c', S(0)) + WC('d', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1440, cons1545) def replacement3650(f, b, d, c, a, x, e): rubi.append(3650) return Dist(b**S(2)/((a**S(2) + b**S(2))*(-a*d + b*c)), Int((-a/tan(e + f*x) + b)/(a + b/tan(e + f*x)), x), x) - Dist(d**S(2)/((c**S(2) + d**S(2))*(-a*d + b*c)), Int((-c/tan(e + f*x) + d)/(c + d/tan(e + f*x)), x), x) + Simp(x*(a*c - b*d)/((a**S(2) + b**S(2))*(c**S(2) + d**S(2))), x) rule3650 = ReplacementRule(pattern3650, replacement3650) pattern3651 = Pattern(Integral(sqrt(WC('a', S(0)) + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))/(WC('c', S(0)) + WC('d', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons71, cons1440, cons1545) def replacement3651(f, b, d, c, a, x, e): rubi.append(3651) return -Dist(d*(-a*d + b*c)/(c**S(2) + d**S(2)), Int((tan(e + f*x)**S(2) + S(1))/(sqrt(a + b*tan(e + f*x))*(c + d*tan(e + f*x))), x), x) + Dist(S(1)/(c**S(2) + d**S(2)), Int(Simp(a*c + b*d + (-a*d + b*c)*tan(e + f*x), x)/sqrt(a + b*tan(e + f*x)), x), x) rule3651 = ReplacementRule(pattern3651, replacement3651) pattern3652 = Pattern(Integral(sqrt(WC('a', S(0)) + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))/(WC('c', S(0)) + WC('d', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons71, cons1440, cons1545) def replacement3652(f, b, d, c, a, x, e): rubi.append(3652) return -Dist(d*(-a*d + b*c)/(c**S(2) + d**S(2)), Int((S(1) + tan(e + f*x)**(S(-2)))/(sqrt(a + b/tan(e + f*x))*(c + d/tan(e + f*x))), x), x) + Dist(S(1)/(c**S(2) + d**S(2)), Int(Simp(a*c + b*d + (-a*d + b*c)/tan(e + f*x), x)/sqrt(a + b/tan(e + f*x)), x), x) rule3652 = ReplacementRule(pattern3652, replacement3652) pattern3653 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**(S(3)/2)/(WC('c', S(0)) + WC('d', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1440, cons1545) def replacement3653(f, b, d, c, a, x, e): rubi.append(3653) return Dist((-a*d + b*c)**S(2)/(c**S(2) + d**S(2)), Int((tan(e + f*x)**S(2) + S(1))/(sqrt(a + b*tan(e + f*x))*(c + d*tan(e + f*x))), x), x) + Dist(S(1)/(c**S(2) + d**S(2)), Int(Simp(a**S(2)*c + S(2)*a*b*d - b**S(2)*c + (-a**S(2)*d + S(2)*a*b*c + b**S(2)*d)*tan(e + f*x), x)/sqrt(a + b*tan(e + f*x)), x), x) rule3653 = ReplacementRule(pattern3653, replacement3653) pattern3654 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**(S(3)/2)/(WC('c', S(0)) + WC('d', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1440, cons1545) def replacement3654(f, b, d, c, a, x, e): rubi.append(3654) return Dist((-a*d + b*c)**S(2)/(c**S(2) + d**S(2)), Int((S(1) + tan(e + f*x)**(S(-2)))/(sqrt(a + b/tan(e + f*x))*(c + d/tan(e + f*x))), x), x) + Dist(S(1)/(c**S(2) + d**S(2)), Int(Simp(a**S(2)*c + S(2)*a*b*d - b**S(2)*c + (-a**S(2)*d + S(2)*a*b*c + b**S(2)*d)/tan(e + f*x), x)/sqrt(a + b/tan(e + f*x)), x), x) rule3654 = ReplacementRule(pattern3654, replacement3654) pattern3655 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_/(WC('c', S(0)) + WC('d', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons71, cons1440, cons1545, cons18) def replacement3655(m, f, b, d, c, a, x, e): rubi.append(3655) return Dist(d**S(2)/(c**S(2) + d**S(2)), Int((a + b*tan(e + f*x))**m*(tan(e + f*x)**S(2) + S(1))/(c + d*tan(e + f*x)), x), x) + Dist(S(1)/(c**S(2) + d**S(2)), Int((a + b*tan(e + f*x))**m*(c - d*tan(e + f*x)), x), x) rule3655 = ReplacementRule(pattern3655, replacement3655) pattern3656 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_/(WC('c', S(0)) + WC('d', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons71, cons1440, cons1545, cons18) def replacement3656(m, f, b, d, c, a, x, e): rubi.append(3656) return Dist(d**S(2)/(c**S(2) + d**S(2)), Int((S(1) + tan(e + f*x)**(S(-2)))*(a + b/tan(e + f*x))**m/(c + d/tan(e + f*x)), x), x) + Dist(S(1)/(c**S(2) + d**S(2)), Int((a + b/tan(e + f*x))**m*(c - d/tan(e + f*x)), x), x) rule3656 = ReplacementRule(pattern3656, replacement3656) pattern3657 = Pattern(Integral((c_ + WC('d', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(WC('a', S(0)) + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons4, cons71, cons1440, cons1545) def replacement3657(m, f, b, d, a, c, n, x, e): rubi.append(3657) return Dist(b/f, Subst(Int((a + x)**m*(c + d*x/b)**n/(b**S(2) + x**S(2)), x), x, b*tan(e + f*x)), x) rule3657 = ReplacementRule(pattern3657, replacement3657) pattern3658 = Pattern(Integral((c_ + WC('d', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(WC('a', S(0)) + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons4, cons71, cons1440, cons1545) def replacement3658(m, f, b, d, a, c, n, x, e): rubi.append(3658) return -Dist(b/f, Subst(Int((a + x)**m*(c + d*x/b)**n/(b**S(2) + x**S(2)), x), x, b/tan(e + f*x)), x) rule3658 = ReplacementRule(pattern3658, replacement3658) pattern3659 = Pattern(Integral((WC('d', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(WC('a', S(0)) + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1)), x_), cons2, cons3, cons27, cons48, cons125, cons4, cons23, cons17) def replacement3659(m, f, b, d, a, n, x, e): rubi.append(3659) return Dist(d**m, Int((d/tan(e + f*x))**(-m + n)*(a/tan(e + f*x) + b)**m, x), x) rule3659 = ReplacementRule(pattern3659, replacement3659) pattern3660 = Pattern(Integral((WC('d', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(WC('a', S(0)) + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1)), x_), cons2, cons3, cons27, cons48, cons125, cons4, cons23, cons17) def replacement3660(m, f, b, d, a, n, x, e): rubi.append(3660) return Dist(d**m, Int((d*tan(e + f*x))**(-m + n)*(a*tan(e + f*x) + b)**m, x), x) rule3660 = ReplacementRule(pattern3660, replacement3660) pattern3661 = Pattern(Integral(((WC('d', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**p_*WC('c', S(1)))**n_*(WC('a', S(0)) + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons4, cons5, cons23, cons18) def replacement3661(p, m, f, b, d, c, a, n, x, e): rubi.append(3661) return Dist(c**IntPart(n)*(c*(d*tan(e + f*x))**p)**FracPart(n)*(d*tan(e + f*x))**(-p*FracPart(n)), Int((d*tan(e + f*x))**(n*p)*(a + b*tan(e + f*x))**m, x), x) rule3661 = ReplacementRule(pattern3661, replacement3661) pattern3662 = Pattern(Integral(((WC('d', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**p_*WC('c', S(1)))**n_*(WC('a', S(0)) + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons4, cons5, cons23, cons18) def replacement3662(p, m, f, b, d, a, c, n, x, e): rubi.append(3662) return Dist(c**IntPart(n)*(c*(d/tan(e + f*x))**p)**FracPart(n)*(d/tan(e + f*x))**(-p*FracPart(n)), Int((d/tan(e + f*x))**(n*p)*(a + b/tan(e + f*x))**m, x), x) rule3662 = ReplacementRule(pattern3662, replacement3662) pattern3663 = Pattern(Integral((WC('g', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('p', S(1))*(a_ + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(c_ + WC('d', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons21, cons4, cons5, cons380) def replacement3663(p, m, f, g, b, d, a, c, n, x, e): rubi.append(3663) return Int((g*tan(e + f*x))**p*(a + b*tan(e + f*x))**m*(c + d*tan(e + f*x))**n, x) rule3663 = ReplacementRule(pattern3663, replacement3663) pattern3664 = Pattern(Integral((WC('g', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('p', S(1))*(a_ + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(c_ + WC('d', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons21, cons4, cons5, cons380) def replacement3664(p, m, f, b, g, d, a, c, n, x, e): rubi.append(3664) return Int((g/tan(e + f*x))**p*(a + b/tan(e + f*x))**m*(c + d/tan(e + f*x))**n, x) rule3664 = ReplacementRule(pattern3664, replacement3664) pattern3665 = Pattern(Integral((WC('g', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**p_*(c_ + WC('d', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1))*(WC('a', S(0)) + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons5, cons147, cons17, cons85) def replacement3665(p, m, f, g, b, d, a, n, c, x, e): rubi.append(3665) return Dist(g**(m + n), Int((g/tan(e + f*x))**(-m - n + p)*(a/tan(e + f*x) + b)**m*(c/tan(e + f*x) + d)**n, x), x) rule3665 = ReplacementRule(pattern3665, replacement3665) pattern3666 = Pattern(Integral((WC('g', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**p_*(c_ + WC('d', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1))*(WC('a', S(0)) + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons5, cons147, cons17, cons85) def replacement3666(p, m, f, b, g, d, a, n, c, x, e): rubi.append(3666) return Dist(g**(m + n), Int((g*tan(e + f*x))**(-m - n + p)*(a*tan(e + f*x) + b)**m*(c*tan(e + f*x) + d)**n, x), x) rule3666 = ReplacementRule(pattern3666, replacement3666) pattern3667 = Pattern(Integral((WC('g', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0)))**q_)**p_*(c_ + WC('d', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1))*(WC('a', S(0)) + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons21, cons4, cons5, cons50, cons147, cons1417) def replacement3667(p, m, f, g, b, d, a, n, c, x, q, e): rubi.append(3667) return Dist((g*tan(e + f*x))**(-p*q)*(g*tan(e + f*x)**q)**p, Int((g*tan(e + f*x))**(p*q)*(a + b*tan(e + f*x))**m*(c + d*tan(e + f*x))**n, x), x) rule3667 = ReplacementRule(pattern3667, replacement3667) pattern3668 = Pattern(Integral(((S(1)/tan(x_*WC('f', S(1)) + WC('e', S(0))))**q_*WC('g', S(1)))**p_*(c_ + WC('d', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1))*(WC('a', S(0)) + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons21, cons4, cons5, cons50, cons147, cons1417) def replacement3668(p, m, f, b, g, d, a, n, c, x, q, e): rubi.append(3668) return Dist((g*(S(1)/tan(e + f*x))**q)**p*(g/tan(e + f*x))**(-p*q), Int((g/tan(e + f*x))**(p*q)*(a + b/tan(e + f*x))**m*(c + d/tan(e + f*x))**n, x), x) rule3668 = ReplacementRule(pattern3668, replacement3668) pattern3669 = Pattern(Integral((WC('g', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('p', S(1))*(a_ + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(c_ + WC('d', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons21, cons5, cons85) def replacement3669(p, m, g, f, b, d, c, n, a, x, e): rubi.append(3669) return Dist(g**n, Int((g*tan(e + f*x))**(-n + p)*(a + b*tan(e + f*x))**m*(c*tan(e + f*x) + d)**n, x), x) rule3669 = ReplacementRule(pattern3669, replacement3669) pattern3670 = Pattern(Integral((WC('g', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('p', S(1))*(a_ + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(c_ + WC('d', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons21, cons5, cons85) def replacement3670(p, m, f, b, g, d, a, n, c, x, e): rubi.append(3670) return Dist(g**n, Int((g/tan(e + f*x))**(-n + p)*(a + b/tan(e + f*x))**m*(c/tan(e + f*x) + d)**n, x), x) rule3670 = ReplacementRule(pattern3670, replacement3670) pattern3671 = Pattern(Integral((a_ + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(c_ + WC('d', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_*tan(x_*WC('f', S(1)) + WC('e', S(0)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons4, cons23, cons17, cons38) def replacement3671(p, m, f, b, d, c, n, a, x, e): rubi.append(3671) return Int((c + d/tan(e + f*x))**n*(a/tan(e + f*x) + b)**m*(S(1)/tan(e + f*x))**(-m - p), x) rule3671 = ReplacementRule(pattern3671, replacement3671) pattern3672 = Pattern(Integral((a_ + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(c_ + WC('d', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(S(1)/tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons4, cons23, cons17, cons38) def replacement3672(p, m, f, b, d, a, c, n, x, e): rubi.append(3672) return Int((c + d*tan(e + f*x))**n*(a*tan(e + f*x) + b)**m*tan(e + f*x)**(-m - p), x) rule3672 = ReplacementRule(pattern3672, replacement3672) pattern3673 = Pattern(Integral((WC('g', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**p_*(a_ + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(c_ + WC('d', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons4, cons5, cons23, cons17, cons147) def replacement3673(p, m, f, b, g, d, c, n, a, x, e): rubi.append(3673) return Dist((g*tan(e + f*x))**p*(S(1)/tan(e + f*x))**p, Int((c + d/tan(e + f*x))**n*(a/tan(e + f*x) + b)**m*(S(1)/tan(e + f*x))**(-m - p), x), x) rule3673 = ReplacementRule(pattern3673, replacement3673) pattern3674 = Pattern(Integral((WC('g', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**p_*(a_ + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(c_ + WC('d', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons4, cons5, cons23, cons17, cons147) def replacement3674(p, m, f, b, g, d, a, c, n, x, e): rubi.append(3674) return Dist((g/tan(e + f*x))**p*tan(e + f*x)**p, Int((c + d*tan(e + f*x))**n*(a*tan(e + f*x) + b)**m*tan(e + f*x)**(-m - p), x), x) rule3674 = ReplacementRule(pattern3674, replacement3674) pattern3675 = Pattern(Integral((WC('g', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('p', S(1))*(a_ + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(c_ + WC('d', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons21, cons4, cons5, cons23, cons18) def replacement3675(p, m, f, g, b, d, c, n, a, x, e): rubi.append(3675) return Dist((g*tan(e + f*x))**n*(c + d/tan(e + f*x))**n*(c*tan(e + f*x) + d)**(-n), Int((g*tan(e + f*x))**(-n + p)*(a + b*tan(e + f*x))**m*(c*tan(e + f*x) + d)**n, x), x) rule3675 = ReplacementRule(pattern3675, replacement3675) pattern3676 = Pattern(Integral((WC('g', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('p', S(1))*(a_ + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(c_ + WC('d', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons21, cons4, cons5, cons23, cons18) def replacement3676(p, m, f, b, g, d, a, c, n, x, e): rubi.append(3676) return Dist((g/tan(e + f*x))**n*(c + d*tan(e + f*x))**n*(c/tan(e + f*x) + d)**(-n), Int((g/tan(e + f*x))**(-n + p)*(a + b/tan(e + f*x))**m*(c/tan(e + f*x) + d)**n, x), x) rule3676 = ReplacementRule(pattern3676, replacement3676) pattern3677 = Pattern(Integral((a_ + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(c_ + WC('d', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1))*(WC('A', S(0)) + WC('B', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons21, cons4, cons70, cons1439) def replacement3677(B, e, m, f, b, d, a, n, c, x, A): rubi.append(3677) return Dist(a*c/f, Subst(Int((A + B*x)*(a + b*x)**(m + S(-1))*(c + d*x)**(n + S(-1)), x), x, tan(e + f*x)), x) rule3677 = ReplacementRule(pattern3677, replacement3677) pattern3678 = Pattern(Integral((a_ + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(c_ + WC('d', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1))*(WC('A', S(0)) + WC('B', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons21, cons4, cons70, cons1439) def replacement3678(B, m, f, b, d, a, n, c, A, x, e): rubi.append(3678) return -Dist(a*c/f, Subst(Int((A + B*x)*(a + b*x)**(m + S(-1))*(c + d*x)**(n + S(-1)), x), x, S(1)/tan(e + f*x)), x) rule3678 = ReplacementRule(pattern3678, replacement3678) pattern3679 = Pattern(Integral((WC('A', S(0)) + WC('B', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))*(WC('c', S(0)) + WC('d', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))/(WC('a', S(0)) + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons71) def replacement3679(B, e, f, b, d, a, c, x, A): rubi.append(3679) return Dist(S(1)/b, Int(Simp(A*b*c + (A*b*d + B*(-a*d + b*c))*tan(e + f*x), x)/(a + b*tan(e + f*x)), x), x) + Dist(B*d/b, Int(tan(e + f*x), x), x) rule3679 = ReplacementRule(pattern3679, replacement3679) pattern3680 = Pattern(Integral((WC('A', S(0)) + WC('B', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))*(WC('c', S(0)) + WC('d', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))/(WC('a', S(0)) + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons71) def replacement3680(B, e, f, b, d, a, c, x, A): rubi.append(3680) return Dist(S(1)/b, Int(Simp(A*b*c + (A*b*d + B*(-a*d + b*c))/tan(e + f*x), x)/(a + b/tan(e + f*x)), x), x) + Dist(B*d/b, Int(S(1)/tan(e + f*x), x), x) rule3680 = ReplacementRule(pattern3680, replacement3680) pattern3681 = Pattern(Integral((a_ + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('A', S(0)) + WC('B', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))*(WC('c', S(0)) + WC('d', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons71, cons31, cons94, cons1439) def replacement3681(B, e, m, f, b, d, c, a, x, A): rubi.append(3681) return Dist(S(1)/(S(2)*a*b), Int((a + b*tan(e + f*x))**(m + S(1))*Simp(A*a*d + A*b*c + B*a*c + S(2)*B*a*d*tan(e + f*x) + B*b*d, x), x), x) - Simp((a + b*tan(e + f*x))**m*(A*b - B*a)*(a*c + b*d)/(S(2)*a**S(2)*f*m), x) rule3681 = ReplacementRule(pattern3681, replacement3681) pattern3682 = Pattern(Integral((a_ + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('A', S(0)) + WC('B', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))*(WC('c', S(0)) + WC('d', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons71, cons31, cons94, cons1439) def replacement3682(B, m, f, b, d, c, a, A, x, e): rubi.append(3682) return Dist(S(1)/(S(2)*a*b), Int((a + b/tan(e + f*x))**(m + S(1))*Simp(A*a*d + A*b*c + B*a*c + S(2)*B*a*d/tan(e + f*x) + B*b*d, x), x), x) + Simp((a + b/tan(e + f*x))**m*(A*b - B*a)*(a*c + b*d)/(S(2)*a**S(2)*f*m), x) rule3682 = ReplacementRule(pattern3682, replacement3682) pattern3683 = Pattern(Integral((WC('A', S(0)) + WC('B', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))*(WC('a', S(0)) + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons71, cons31, cons94, cons1440) def replacement3683(B, e, m, f, b, d, a, c, x, A): rubi.append(3683) return Dist(S(1)/(a**S(2) + b**S(2)), Int((a + b*tan(e + f*x))**(m + S(1))*Simp(A*a*c + A*b*d - B*a*d + B*b*c - (-A*a*d + A*b*c - B*a*c - B*b*d)*tan(e + f*x), x), x), x) + Simp((a + b*tan(e + f*x))**(m + S(1))*(A*b - B*a)*(-a*d + b*c)/(b*f*(a**S(2) + b**S(2))*(m + S(1))), x) rule3683 = ReplacementRule(pattern3683, replacement3683) pattern3684 = Pattern(Integral((WC('A', S(0)) + WC('B', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))*(WC('a', S(0)) + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons71, cons31, cons94, cons1440) def replacement3684(B, e, m, f, b, d, a, c, x, A): rubi.append(3684) return Dist(S(1)/(a**S(2) + b**S(2)), Int((a + b/tan(e + f*x))**(m + S(1))*Simp(A*a*c + A*b*d - B*a*d + B*b*c - (-A*a*d + A*b*c - B*a*c - B*b*d)/tan(e + f*x), x), x), x) - Simp((a + b/tan(e + f*x))**(m + S(1))*(A*b - B*a)*(-a*d + b*c)/(b*f*(a**S(2) + b**S(2))*(m + S(1))), x) rule3684 = ReplacementRule(pattern3684, replacement3684) pattern3685 = Pattern(Integral((WC('A', S(0)) + WC('B', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))*(WC('a', S(0)) + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(WC('c', S(0)) + WC('d', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons21, cons71, cons1549) def replacement3685(B, m, f, b, d, a, c, A, x, e): rubi.append(3685) return Int((a + b*tan(e + f*x))**m*Simp(A*c - B*d + (A*d + B*c)*tan(e + f*x), x), x) + Simp(B*d*(a + b*tan(e + f*x))**(m + S(1))/(b*f*(m + S(1))), x) rule3685 = ReplacementRule(pattern3685, replacement3685) pattern3686 = Pattern(Integral((WC('A', S(0)) + WC('B', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))*(WC('a', S(0)) + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(WC('c', S(0)) + WC('d', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons21, cons71, cons1549) def replacement3686(B, m, f, b, d, a, c, A, x, e): rubi.append(3686) return Int((a + b/tan(e + f*x))**m*Simp(A*c - B*d + (A*d + B*c)/tan(e + f*x), x), x) - Simp(B*d*(a + b/tan(e + f*x))**(m + S(1))/(b*f*(m + S(1))), x) rule3686 = ReplacementRule(pattern3686, replacement3686) pattern3687 = Pattern(Integral((a_ + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('A', S(0)) + WC('B', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))*(WC('c', S(0)) + WC('d', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons71, cons1439, cons93, cons166, cons89) def replacement3687(B, e, m, f, b, d, c, a, n, x, A): rubi.append(3687) return -Dist(a/(d*(n + S(1))*(a*d + b*c)), Int((a + b*tan(e + f*x))**(m + S(-1))*(c + d*tan(e + f*x))**(n + S(1))*Simp(A*b*d*(m - n + S(-2)) - B*(a*d*(n + S(1)) + b*c*(m + S(-1))) + (A*a*d*(m + n) - B*(a*c*(m + S(-1)) + b*d*(n + S(1))))*tan(e + f*x), x), x), x) - Simp(a**S(2)*(a + b*tan(e + f*x))**(m + S(-1))*(c + d*tan(e + f*x))**(n + S(1))*(-A*d + B*c)/(d*f*(n + S(1))*(a*d + b*c)), x) rule3687 = ReplacementRule(pattern3687, replacement3687) pattern3688 = Pattern(Integral((a_ + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('A', S(0)) + WC('B', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))*(WC('c', S(0)) + WC('d', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons71, cons1439, cons93, cons166, cons89) def replacement3688(B, m, f, b, d, c, n, a, A, x, e): rubi.append(3688) return -Dist(a/(d*(n + S(1))*(a*d + b*c)), Int((a + b/tan(e + f*x))**(m + S(-1))*(c + d/tan(e + f*x))**(n + S(1))*Simp(A*b*d*(m - n + S(-2)) - B*(a*d*(n + S(1)) + b*c*(m + S(-1))) + (A*a*d*(m + n) - B*(a*c*(m + S(-1)) + b*d*(n + S(1))))/tan(e + f*x), x), x), x) + Simp(a**S(2)*(a + b/tan(e + f*x))**(m + S(-1))*(c + d/tan(e + f*x))**(n + S(1))*(-A*d + B*c)/(d*f*(n + S(1))*(a*d + b*c)), x) rule3688 = ReplacementRule(pattern3688, replacement3688) pattern3689 = Pattern(Integral((a_ + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('A', S(0)) + WC('B', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))*(WC('c', S(0)) + WC('d', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons4, cons71, cons1439, cons31, cons166, cons346) def replacement3689(B, e, m, f, b, d, c, a, n, x, A): rubi.append(3689) return Dist(S(1)/(d*(m + n)), Int((a + b*tan(e + f*x))**(m + S(-1))*(c + d*tan(e + f*x))**n*Simp(A*a*d*(m + n) + B*(a*c*(m + S(-1)) - b*d*(n + S(1))) - (B*(m + S(-1))*(-a*d + b*c) - d*(m + n)*(A*b + B*a))*tan(e + f*x), x), x), x) + Simp(B*b*(a + b*tan(e + f*x))**(m + S(-1))*(c + d*tan(e + f*x))**(n + S(1))/(d*f*(m + n)), x) rule3689 = ReplacementRule(pattern3689, replacement3689) pattern3690 = Pattern(Integral((a_ + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('A', S(0)) + WC('B', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))*(WC('c', S(0)) + WC('d', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons4, cons71, cons1439, cons31, cons166, cons346) def replacement3690(B, m, f, b, d, c, n, a, A, x, e): rubi.append(3690) return Dist(S(1)/(d*(m + n)), Int((a + b/tan(e + f*x))**(m + S(-1))*(c + d/tan(e + f*x))**n*Simp(A*a*d*(m + n) + B*(a*c*(m + S(-1)) - b*d*(n + S(1))) - (B*(m + S(-1))*(-a*d + b*c) - d*(m + n)*(A*b + B*a))/tan(e + f*x), x), x), x) - Simp(B*b*(a + b/tan(e + f*x))**(m + S(-1))*(c + d/tan(e + f*x))**(n + S(1))/(d*f*(m + n)), x) rule3690 = ReplacementRule(pattern3690, replacement3690) pattern3691 = Pattern(Integral((a_ + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('A', S(0)) + WC('B', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))*(WC('c', S(0)) + WC('d', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons71, cons1439, cons93, cons267, cons88) def replacement3691(B, e, m, f, b, d, c, a, n, x, A): rubi.append(3691) return Dist(S(1)/(S(2)*a**S(2)*m), Int((a + b*tan(e + f*x))**(m + S(1))*(c + d*tan(e + f*x))**(n + S(-1))*Simp(A*(a*c*m + b*d*n) - B*(a*d*n + b*c*m) - d*(-A*a*(m + n) + B*b*(m - n))*tan(e + f*x), x), x), x) - Simp((a + b*tan(e + f*x))**m*(c + d*tan(e + f*x))**n*(A*b - B*a)/(S(2)*a*f*m), x) rule3691 = ReplacementRule(pattern3691, replacement3691) pattern3692 = Pattern(Integral((a_ + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('A', S(0)) + WC('B', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))*(WC('c', S(0)) + WC('d', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons71, cons1439, cons93, cons267, cons88) def replacement3692(B, m, f, b, d, c, n, a, A, x, e): rubi.append(3692) return Dist(S(1)/(S(2)*a**S(2)*m), Int((a + b/tan(e + f*x))**(m + S(1))*(c + d/tan(e + f*x))**(n + S(-1))*Simp(A*(a*c*m + b*d*n) - B*(a*d*n + b*c*m) - d*(-A*a*(m + n) + B*b*(m - n))/tan(e + f*x), x), x), x) + Simp((a + b/tan(e + f*x))**m*(c + d/tan(e + f*x))**n*(A*b - B*a)/(S(2)*a*f*m), x) rule3692 = ReplacementRule(pattern3692, replacement3692) pattern3693 = Pattern(Integral((a_ + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('A', S(0)) + WC('B', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))*(WC('c', S(0)) + WC('d', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons4, cons71, cons1439, cons31, cons267, cons1327) def replacement3693(B, e, m, f, b, d, c, a, n, x, A): rubi.append(3693) return Dist(S(1)/(S(2)*a*m*(-a*d + b*c)), Int((a + b*tan(e + f*x))**(m + S(1))*(c + d*tan(e + f*x))**n*Simp(A*(-a*d*(S(2)*m + n + S(1)) + b*c*m) + B*(a*c*m - b*d*(n + S(1))) + d*(A*b - B*a)*(m + n + S(1))*tan(e + f*x), x), x), x) + Simp((a + b*tan(e + f*x))**m*(c + d*tan(e + f*x))**(n + S(1))*(A*a + B*b)/(S(2)*f*m*(-a*d + b*c)), x) rule3693 = ReplacementRule(pattern3693, replacement3693) pattern3694 = Pattern(Integral((a_ + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('A', S(0)) + WC('B', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))*(WC('c', S(0)) + WC('d', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons4, cons71, cons1439, cons31, cons267, cons1327) def replacement3694(B, m, f, b, d, c, n, a, A, x, e): rubi.append(3694) return Dist(S(1)/(S(2)*a*m*(-a*d + b*c)), Int((a + b/tan(e + f*x))**(m + S(1))*(c + d/tan(e + f*x))**n*Simp(A*(-a*d*(S(2)*m + n + S(1)) + b*c*m) + B*(a*c*m - b*d*(n + S(1))) + d*(A*b - B*a)*(m + n + S(1))/tan(e + f*x), x), x), x) - Simp((a + b/tan(e + f*x))**m*(c + d/tan(e + f*x))**(n + S(1))*(A*a + B*b)/(S(2)*f*m*(-a*d + b*c)), x) rule3694 = ReplacementRule(pattern3694, replacement3694) pattern3695 = Pattern(Integral((a_ + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('A', S(0)) + WC('B', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))*(WC('c', S(0)) + WC('d', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons21, cons71, cons1439, cons87, cons88) def replacement3695(B, e, m, f, b, d, c, a, n, x, A): rubi.append(3695) return Dist(S(1)/(a*(m + n)), Int((a + b*tan(e + f*x))**m*(c + d*tan(e + f*x))**(n + S(-1))*Simp(A*a*c*(m + n) - B*(a*d*n + b*c*m) + (A*a*d*(m + n) - B*(-a*c*n + b*d*m))*tan(e + f*x), x), x), x) + Simp(B*(a + b*tan(e + f*x))**m*(c + d*tan(e + f*x))**n/(f*(m + n)), x) rule3695 = ReplacementRule(pattern3695, replacement3695) pattern3696 = Pattern(Integral((a_ + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('A', S(0)) + WC('B', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))*(WC('c', S(0)) + WC('d', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons21, cons71, cons1439, cons87, cons88) def replacement3696(B, m, f, b, d, c, n, a, A, x, e): rubi.append(3696) return Dist(S(1)/(a*(m + n)), Int((a + b/tan(e + f*x))**m*(c + d/tan(e + f*x))**(n + S(-1))*Simp(A*a*c*(m + n) - B*(a*d*n + b*c*m) + (A*a*d*(m + n) - B*(-a*c*n + b*d*m))/tan(e + f*x), x), x), x) - Simp(B*(a + b/tan(e + f*x))**m*(c + d/tan(e + f*x))**n/(f*(m + n)), x) rule3696 = ReplacementRule(pattern3696, replacement3696) pattern3697 = Pattern(Integral((a_ + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('A', S(0)) + WC('B', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))*(WC('c', S(0)) + WC('d', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons21, cons71, cons1439, cons87, cons89) def replacement3697(B, e, m, f, b, d, c, a, n, x, A): rubi.append(3697) return -Dist(S(1)/(a*(c**S(2) + d**S(2))*(n + S(1))), Int((a + b*tan(e + f*x))**m*(c + d*tan(e + f*x))**(n + S(1))*Simp(A*(-a*c*(n + S(1)) + b*d*m) - B*(a*d*(n + S(1)) + b*c*m) - a*(-A*d + B*c)*(m + n + S(1))*tan(e + f*x), x), x), x) + Simp((a + b*tan(e + f*x))**m*(c + d*tan(e + f*x))**(n + S(1))*(A*d - B*c)/(f*(c**S(2) + d**S(2))*(n + S(1))), x) rule3697 = ReplacementRule(pattern3697, replacement3697) pattern3698 = Pattern(Integral((a_ + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('A', S(0)) + WC('B', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))*(WC('c', S(0)) + WC('d', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons21, cons71, cons1439, cons87, cons89) def replacement3698(B, m, f, b, d, c, n, a, A, x, e): rubi.append(3698) return -Dist(S(1)/(a*(c**S(2) + d**S(2))*(n + S(1))), Int((a + b/tan(e + f*x))**m*(c + d/tan(e + f*x))**(n + S(1))*Simp(A*(-a*c*(n + S(1)) + b*d*m) - B*(a*d*(n + S(1)) + b*c*m) - a*(-A*d + B*c)*(m + n + S(1))/tan(e + f*x), x), x), x) - Simp((a + b/tan(e + f*x))**m*(c + d/tan(e + f*x))**(n + S(1))*(A*d - B*c)/(f*(c**S(2) + d**S(2))*(n + S(1))), x) rule3698 = ReplacementRule(pattern3698, replacement3698) pattern3699 = Pattern(Integral((a_ + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('A', S(0)) + WC('B', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))*(WC('c', S(0)) + WC('d', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons21, cons4, cons71, cons1439, cons1418) def replacement3699(B, e, m, f, b, d, c, a, n, x, A): rubi.append(3699) return Dist(B*b/f, Subst(Int((a + b*x)**(m + S(-1))*(c + d*x)**n, x), x, tan(e + f*x)), x) rule3699 = ReplacementRule(pattern3699, replacement3699) pattern3700 = Pattern(Integral((a_ + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('A', S(0)) + WC('B', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))*(WC('c', S(0)) + WC('d', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons21, cons4, cons71, cons1439, cons1418) def replacement3700(B, m, f, b, d, c, n, a, A, x, e): rubi.append(3700) return -Dist(B*b/f, Subst(Int((a + b*x)**(m + S(-1))*(c + d*x)**n, x), x, S(1)/tan(e + f*x)), x) rule3700 = ReplacementRule(pattern3700, replacement3700) pattern3701 = Pattern(Integral((a_ + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('A', S(0)) + WC('B', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))/(WC('c', S(0)) + WC('d', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons21, cons71, cons1439, cons1426) def replacement3701(B, e, m, f, b, d, c, a, x, A): rubi.append(3701) return Dist((A*b + B*a)/(a*d + b*c), Int((a + b*tan(e + f*x))**m, x), x) - Dist((-A*d + B*c)/(a*d + b*c), Int((a - b*tan(e + f*x))*(a + b*tan(e + f*x))**m/(c + d*tan(e + f*x)), x), x) rule3701 = ReplacementRule(pattern3701, replacement3701) pattern3702 = Pattern(Integral((a_ + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('A', S(0)) + WC('B', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))/(WC('c', S(0)) + WC('d', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons21, cons71, cons1439, cons1426) def replacement3702(B, m, f, b, d, c, a, A, x, e): rubi.append(3702) return Dist((A*b + B*a)/(a*d + b*c), Int((a + b/tan(e + f*x))**m, x), x) - Dist((-A*d + B*c)/(a*d + b*c), Int((a - b/tan(e + f*x))*(a + b/tan(e + f*x))**m/(c + d/tan(e + f*x)), x), x) rule3702 = ReplacementRule(pattern3702, replacement3702) pattern3703 = Pattern(Integral((a_ + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('A', S(0)) + WC('B', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))*(WC('c', S(0)) + WC('d', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons21, cons4, cons71, cons1439, cons1426) def replacement3703(B, e, m, f, b, d, c, a, n, x, A): rubi.append(3703) return -Dist(B/b, Int((a - b*tan(e + f*x))*(a + b*tan(e + f*x))**m*(c + d*tan(e + f*x))**n, x), x) + Dist((A*b + B*a)/b, Int((a + b*tan(e + f*x))**m*(c + d*tan(e + f*x))**n, x), x) rule3703 = ReplacementRule(pattern3703, replacement3703) pattern3704 = Pattern(Integral((a_ + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('A', S(0)) + WC('B', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))*(WC('c', S(0)) + WC('d', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons21, cons4, cons71, cons1439, cons1426) def replacement3704(B, m, f, b, d, c, n, a, A, x, e): rubi.append(3704) return -Dist(B/b, Int((a - b/tan(e + f*x))*(a + b/tan(e + f*x))**m*(c + d/tan(e + f*x))**n, x), x) + Dist((A*b + B*a)/b, Int((a + b/tan(e + f*x))**m*(c + d/tan(e + f*x))**n, x), x) rule3704 = ReplacementRule(pattern3704, replacement3704) pattern3705 = Pattern(Integral((A_ + WC('B', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))*(WC('a', S(0)) + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons21, cons4, cons71, cons1440, cons18, cons23, cons1513, cons1558) def replacement3705(B, m, f, b, d, a, c, n, A, x, e): rubi.append(3705) return Dist(A**S(2)/f, Subst(Int((a + b*x)**m*(c + d*x)**n/(A - B*x), x), x, tan(e + f*x)), x) rule3705 = ReplacementRule(pattern3705, replacement3705) pattern3706 = Pattern(Integral((A_ + WC('B', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))*(WC('a', S(0)) + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons21, cons4, cons71, cons1440, cons18, cons23, cons1513, cons1558) def replacement3706(B, m, f, b, d, c, a, n, A, x, e): rubi.append(3706) return -Dist(A**S(2)/f, Subst(Int((a + b*x)**m*(c + d*x)**n/(A - B*x), x), x, S(1)/tan(e + f*x)), x) rule3706 = ReplacementRule(pattern3706, replacement3706) pattern3707 = Pattern(Integral((WC('A', S(0)) + WC('B', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))*(WC('a', S(0)) + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons21, cons4, cons71, cons1440, cons18, cons23, cons1513, cons1559) def replacement3707(B, e, m, f, b, d, a, c, n, x, A): rubi.append(3707) return Dist(A/S(2) - I*B/S(2), Int((a + b*tan(e + f*x))**m*(c + d*tan(e + f*x))**n*(I*tan(e + f*x) + S(1)), x), x) + Dist(A/S(2) + I*B/S(2), Int((a + b*tan(e + f*x))**m*(c + d*tan(e + f*x))**n*(-I*tan(e + f*x) + S(1)), x), x) rule3707 = ReplacementRule(pattern3707, replacement3707) pattern3708 = Pattern(Integral((WC('A', S(0)) + WC('B', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))*(WC('a', S(0)) + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons21, cons4, cons71, cons1440, cons18, cons23, cons1513, cons1559) def replacement3708(B, e, m, f, b, d, a, c, n, x, A): rubi.append(3708) return Dist(A/S(2) - I*B/S(2), Int((S(1) + I/tan(e + f*x))*(a + b/tan(e + f*x))**m*(c + d/tan(e + f*x))**n, x), x) + Dist(A/S(2) + I*B/S(2), Int((S(1) - I/tan(e + f*x))*(a + b/tan(e + f*x))**m*(c + d/tan(e + f*x))**n, x), x) rule3708 = ReplacementRule(pattern3708, replacement3708) pattern3709 = Pattern(Integral((WC('A', S(0)) + WC('B', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))*(WC('a', S(0)) + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons71, cons1440, cons1545, cons93, cons166, cons89, cons1334) def replacement3709(B, e, m, f, b, d, a, c, n, x, A): rubi.append(3709) return -Dist(S(1)/(d*(c**S(2) + d**S(2))*(n + S(1))), Int((a + b*tan(e + f*x))**(m + S(-2))*(c + d*tan(e + f*x))**(n + S(1))*Simp(A*a*d*(-a*c*(n + S(1)) + b*d*(m + S(-1))) - b*(-B*b*(c**S(2)*(m + S(-1)) - d**S(2)*(n + S(1))) + d*(m + n)*(-A*a*d + A*b*c + B*a*c))*tan(e + f*x)**S(2) - d*(n + S(1))*((A*a - B*b)*(-a*d + b*c) + (A*b + B*a)*(a*c + b*d))*tan(e + f*x) + (B*b*c - d*(A*b + B*a))*(a*d*(n + S(1)) + b*c*(m + S(-1))), x), x), x) + Simp((a + b*tan(e + f*x))**(m + S(-1))*(c + d*tan(e + f*x))**(n + S(1))*(-A*d + B*c)*(-a*d + b*c)/(d*f*(c**S(2) + d**S(2))*(n + S(1))), x) rule3709 = ReplacementRule(pattern3709, replacement3709) pattern3710 = Pattern(Integral((WC('A', S(0)) + WC('B', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))*(WC('a', S(0)) + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons71, cons1440, cons1545, cons93, cons166, cons89, cons1334) def replacement3710(B, e, m, f, b, d, a, c, n, x, A): rubi.append(3710) return -Dist(S(1)/(d*(c**S(2) + d**S(2))*(n + S(1))), Int((a + b/tan(e + f*x))**(m + S(-2))*(c + d/tan(e + f*x))**(n + S(1))*Simp(A*a*d*(-a*c*(n + S(1)) + b*d*(m + S(-1))) - b*(-B*b*(c**S(2)*(m + S(-1)) - d**S(2)*(n + S(1))) + d*(m + n)*(-A*a*d + A*b*c + B*a*c))/tan(e + f*x)**S(2) - d*(n + S(1))*((A*a - B*b)*(-a*d + b*c) + (A*b + B*a)*(a*c + b*d))/tan(e + f*x) + (B*b*c - d*(A*b + B*a))*(a*d*(n + S(1)) + b*c*(m + S(-1))), x), x), x) - Simp((a + b/tan(e + f*x))**(m + S(-1))*(c + d/tan(e + f*x))**(n + S(1))*(-A*d + B*c)*(-a*d + b*c)/(d*f*(c**S(2) + d**S(2))*(n + S(1))), x) rule3710 = ReplacementRule(pattern3710, replacement3710) pattern3711 = Pattern(Integral((WC('A', S(0)) + WC('B', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))*(WC('a', S(0)) + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons4, cons71, cons1440, cons1545, cons31, cons166, cons1334, cons1560) def replacement3711(B, e, m, f, b, d, a, c, n, x, A): rubi.append(3711) return Dist(S(1)/(d*(m + n)), Int((a + b*tan(e + f*x))**(m + S(-2))*(c + d*tan(e + f*x))**n*Simp(A*a**S(2)*d*(m + n) - B*b*(a*d*(n + S(1)) + b*c*(m + S(-1))) + d*(m + n)*(S(2)*A*a*b + B*(a**S(2) - b**S(2)))*tan(e + f*x) - (B*b*(m + S(-1))*(-a*d + b*c) - b*d*(m + n)*(A*b + B*a))*tan(e + f*x)**S(2), x), x), x) + Simp(B*b*(a + b*tan(e + f*x))**(m + S(-1))*(c + d*tan(e + f*x))**(n + S(1))/(d*f*(m + n)), x) rule3711 = ReplacementRule(pattern3711, replacement3711) pattern3712 = Pattern(Integral((WC('A', S(0)) + WC('B', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))*(WC('a', S(0)) + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons4, cons71, cons1440, cons1545, cons31, cons166, cons1334, cons1560) def replacement3712(B, e, m, f, b, d, a, c, n, x, A): rubi.append(3712) return Dist(S(1)/(d*(m + n)), Int((a + b/tan(e + f*x))**(m + S(-2))*(c + d/tan(e + f*x))**n*Simp(A*a**S(2)*d*(m + n) - B*b*(a*d*(n + S(1)) + b*c*(m + S(-1))) + d*(m + n)*(S(2)*A*a*b + B*(a**S(2) - b**S(2)))/tan(e + f*x) - (B*b*(m + S(-1))*(-a*d + b*c) - b*d*(m + n)*(A*b + B*a))/tan(e + f*x)**S(2), x), x), x) - Simp(B*b*(a + b/tan(e + f*x))**(m + S(-1))*(c + d/tan(e + f*x))**(n + S(1))/(d*f*(m + n)), x) rule3712 = ReplacementRule(pattern3712, replacement3712) pattern3713 = Pattern(Integral((WC('A', S(0)) + WC('B', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))*(WC('a', S(0)) + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons71, cons1440, cons1545, cons93, cons94, cons1325, cons1334) def replacement3713(B, e, m, f, b, d, a, c, n, x, A): rubi.append(3713) return Dist(S(1)/(b*(a**S(2) + b**S(2))*(m + S(1))), Int((a + b*tan(e + f*x))**(m + S(1))*(c + d*tan(e + f*x))**(n + S(-1))*Simp(A*b*(a*c*(m + S(1)) - b*d*n) + B*b*(a*d*n + b*c*(m + S(1))) - b*d*(A*b - B*a)*(m + n + S(1))*tan(e + f*x)**S(2) - b*(m + S(1))*(A*(-a*d + b*c) - B*(a*c + b*d))*tan(e + f*x), x), x), x) + Simp((a + b*tan(e + f*x))**(m + S(1))*(c + d*tan(e + f*x))**n*(A*b - B*a)/(f*(a**S(2) + b**S(2))*(m + S(1))), x) rule3713 = ReplacementRule(pattern3713, replacement3713) pattern3714 = Pattern(Integral((WC('A', S(0)) + WC('B', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))*(WC('a', S(0)) + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons71, cons1440, cons1545, cons93, cons94, cons1325, cons1334) def replacement3714(B, e, m, f, b, d, a, c, n, x, A): rubi.append(3714) return Dist(S(1)/(b*(a**S(2) + b**S(2))*(m + S(1))), Int((a + b/tan(e + f*x))**(m + S(1))*(c + d/tan(e + f*x))**(n + S(-1))*Simp(A*b*(a*c*(m + S(1)) - b*d*n) + B*b*(a*d*n + b*c*(m + S(1))) - b*d*(A*b - B*a)*(m + n + S(1))/tan(e + f*x)**S(2) - b*(m + S(1))*(A*(-a*d + b*c) - B*(a*c + b*d))/tan(e + f*x), x), x), x) - Simp((a + b/tan(e + f*x))**(m + S(1))*(c + d/tan(e + f*x))**n*(A*b - B*a)/(f*(a**S(2) + b**S(2))*(m + S(1))), x) rule3714 = ReplacementRule(pattern3714, replacement3714) pattern3715 = Pattern(Integral((WC('A', S(0)) + WC('B', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))*(WC('a', S(0)) + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons4, cons71, cons1440, cons1545, cons31, cons94, cons1334, cons1557) def replacement3715(B, e, m, f, b, d, a, c, n, x, A): rubi.append(3715) return Dist(S(1)/((a**S(2) + b**S(2))*(m + S(1))*(-a*d + b*c)), Int((a + b*tan(e + f*x))**(m + S(1))*(c + d*tan(e + f*x))**n*Simp(A*(a*(m + S(1))*(-a*d + b*c) - b**S(2)*d*(m + n + S(2))) + B*b*(a*d*(n + S(1)) + b*c*(m + S(1))) - b*d*(A*b - B*a)*(m + n + S(2))*tan(e + f*x)**S(2) - (m + S(1))*(A*b - B*a)*(-a*d + b*c)*tan(e + f*x), x), x), x) + Simp(b*(a + b*tan(e + f*x))**(m + S(1))*(c + d*tan(e + f*x))**(n + S(1))*(A*b - B*a)/(f*(a**S(2) + b**S(2))*(m + S(1))*(-a*d + b*c)), x) rule3715 = ReplacementRule(pattern3715, replacement3715) pattern3716 = Pattern(Integral((WC('A', S(0)) + WC('B', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))*(WC('a', S(0)) + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons4, cons71, cons1440, cons1545, cons31, cons94, cons1334, cons1557) def replacement3716(B, e, m, f, b, d, a, c, n, x, A): rubi.append(3716) return Dist(S(1)/((a**S(2) + b**S(2))*(m + S(1))*(-a*d + b*c)), Int((a + b/tan(e + f*x))**(m + S(1))*(c + d/tan(e + f*x))**n*Simp(A*(a*(m + S(1))*(-a*d + b*c) - b**S(2)*d*(m + n + S(2))) + B*b*(a*d*(n + S(1)) + b*c*(m + S(1))) - b*d*(A*b - B*a)*(m + n + S(2))/tan(e + f*x)**S(2) - (m + S(1))*(A*b - B*a)*(-a*d + b*c)/tan(e + f*x), x), x), x) - Simp(b*(a + b/tan(e + f*x))**(m + S(1))*(c + d/tan(e + f*x))**(n + S(1))*(A*b - B*a)/(f*(a**S(2) + b**S(2))*(m + S(1))*(-a*d + b*c)), x) rule3716 = ReplacementRule(pattern3716, replacement3716) pattern3717 = Pattern(Integral((WC('A', S(0)) + WC('B', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))*(WC('a', S(0)) + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons71, cons1440, cons1545, cons93, cons1256, cons1325) def replacement3717(B, e, m, f, b, d, a, c, n, x, A): rubi.append(3717) return Dist(S(1)/(m + n), Int((a + b*tan(e + f*x))**(m + S(-1))*(c + d*tan(e + f*x))**(n + S(-1))*Simp(A*a*c*(m + n) - B*(a*d*n + b*c*m) + (m + n)*(A*a*d + A*b*c + B*a*c - B*b*d)*tan(e + f*x) + (A*b*d*(m + n) + B*(a*d*m + b*c*n))*tan(e + f*x)**S(2), x), x), x) + Simp(B*(a + b*tan(e + f*x))**m*(c + d*tan(e + f*x))**n/(f*(m + n)), x) rule3717 = ReplacementRule(pattern3717, replacement3717) pattern3718 = Pattern(Integral((WC('A', S(0)) + WC('B', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))*(WC('a', S(0)) + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons71, cons1440, cons1545, cons93, cons1256, cons1325) def replacement3718(B, e, m, f, b, d, a, c, n, x, A): rubi.append(3718) return Dist(S(1)/(m + n), Int((a + b/tan(e + f*x))**(m + S(-1))*(c + d/tan(e + f*x))**(n + S(-1))*Simp(A*a*c*(m + n) - B*(a*d*n + b*c*m) + (m + n)*(A*a*d + A*b*c + B*a*c - B*b*d)/tan(e + f*x) + (A*b*d*(m + n) + B*(a*d*m + b*c*n))/tan(e + f*x)**S(2), x), x), x) - Simp(B*(a + b/tan(e + f*x))**m*(c + d/tan(e + f*x))**n/(f*(m + n)), x) rule3718 = ReplacementRule(pattern3718, replacement3718) pattern3719 = Pattern(Integral((WC('A', S(0)) + WC('B', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))/((a_ + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))*(WC('c', S(0)) + WC('d', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons71, cons1440, cons1545) def replacement3719(B, e, f, b, d, c, a, x, A): rubi.append(3719) return Dist(b*(A*b - B*a)/((a**S(2) + b**S(2))*(-a*d + b*c)), Int((-a*tan(e + f*x) + b)/(a + b*tan(e + f*x)), x), x) + Dist(d*(-A*d + B*c)/((c**S(2) + d**S(2))*(-a*d + b*c)), Int((-c*tan(e + f*x) + d)/(c + d*tan(e + f*x)), x), x) + Simp(x*(A*(a*c - b*d) + B*(a*d + b*c))/((a**S(2) + b**S(2))*(c**S(2) + d**S(2))), x) rule3719 = ReplacementRule(pattern3719, replacement3719) pattern3720 = Pattern(Integral((WC('A', S(0)) + WC('B', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))/((a_ + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))*(WC('c', S(0)) + WC('d', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons71, cons1440, cons1545) def replacement3720(B, f, b, d, c, a, A, x, e): rubi.append(3720) return Dist(b*(A*b - B*a)/((a**S(2) + b**S(2))*(-a*d + b*c)), Int((-a/tan(e + f*x) + b)/(a + b/tan(e + f*x)), x), x) + Dist(d*(-A*d + B*c)/((c**S(2) + d**S(2))*(-a*d + b*c)), Int((-c/tan(e + f*x) + d)/(c + d/tan(e + f*x)), x), x) + Simp(x*(A*(a*c - b*d) + B*(a*d + b*c))/((a**S(2) + b**S(2))*(c**S(2) + d**S(2))), x) rule3720 = ReplacementRule(pattern3720, replacement3720) pattern3721 = Pattern(Integral((WC('A', S(0)) + WC('B', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))*sqrt(WC('c', S(0)) + WC('d', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))/(WC('a', S(0)) + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons71, cons1440, cons1545) def replacement3721(B, e, f, b, d, a, c, x, A): rubi.append(3721) return -Dist((-A*b + B*a)*(-a*d + b*c)/(a**S(2) + b**S(2)), Int((tan(e + f*x)**S(2) + S(1))/((a + b*tan(e + f*x))*sqrt(c + d*tan(e + f*x))), x), x) + Dist(S(1)/(a**S(2) + b**S(2)), Int(Simp(A*(a*c + b*d) + B*(-a*d + b*c) - (A*(-a*d + b*c) - B*(a*c + b*d))*tan(e + f*x), x)/sqrt(c + d*tan(e + f*x)), x), x) rule3721 = ReplacementRule(pattern3721, replacement3721) pattern3722 = Pattern(Integral((WC('A', S(0)) + WC('B', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))*sqrt(WC('c', S(0)) + WC('d', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))/(WC('a', S(0)) + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons71, cons1440, cons1545) def replacement3722(B, e, f, b, d, a, c, x, A): rubi.append(3722) return -Dist((-A*b + B*a)*(-a*d + b*c)/(a**S(2) + b**S(2)), Int((S(1) + tan(e + f*x)**(S(-2)))/((a + b/tan(e + f*x))*sqrt(c + d/tan(e + f*x))), x), x) + Dist(S(1)/(a**S(2) + b**S(2)), Int(Simp(A*(a*c + b*d) + B*(-a*d + b*c) - (A*(-a*d + b*c) - B*(a*c + b*d))/tan(e + f*x), x)/sqrt(c + d/tan(e + f*x)), x), x) rule3722 = ReplacementRule(pattern3722, replacement3722) pattern3723 = Pattern(Integral((WC('A', S(0)) + WC('B', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))*(WC('c', S(0)) + WC('d', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_/(WC('a', S(0)) + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons4, cons71, cons1440, cons1545) def replacement3723(B, e, f, b, d, a, c, n, x, A): rubi.append(3723) return Dist(b*(A*b - B*a)/(a**S(2) + b**S(2)), Int((c + d*tan(e + f*x))**n*(tan(e + f*x)**S(2) + S(1))/(a + b*tan(e + f*x)), x), x) + Dist(S(1)/(a**S(2) + b**S(2)), Int((c + d*tan(e + f*x))**n*Simp(A*a + B*b - (A*b - B*a)*tan(e + f*x), x), x), x) rule3723 = ReplacementRule(pattern3723, replacement3723) pattern3724 = Pattern(Integral((WC('A', S(0)) + WC('B', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))*(WC('c', S(0)) + WC('d', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_/(WC('a', S(0)) + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons4, cons71, cons1440, cons1545) def replacement3724(B, e, f, b, d, a, c, n, x, A): rubi.append(3724) return Dist(b*(A*b - B*a)/(a**S(2) + b**S(2)), Int((S(1) + tan(e + f*x)**(S(-2)))*(c + d/tan(e + f*x))**n/(a + b/tan(e + f*x)), x), x) + Dist(S(1)/(a**S(2) + b**S(2)), Int((c + d/tan(e + f*x))**n*Simp(A*a + B*b - (A*b - B*a)/tan(e + f*x), x), x), x) rule3724 = ReplacementRule(pattern3724, replacement3724) pattern3725 = Pattern(Integral((WC('A', S(0)) + WC('B', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))*sqrt(WC('a', S(0)) + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))/sqrt(WC('c', S(0)) + WC('d', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons71, cons1440, cons1545) def replacement3725(B, e, f, b, d, a, c, x, A): rubi.append(3725) return Dist(B*b, Int((tan(e + f*x)**S(2) + S(1))/(sqrt(a + b*tan(e + f*x))*sqrt(c + d*tan(e + f*x))), x), x) + Int(Simp(A*a - B*b + (A*b + B*a)*tan(e + f*x), x)/(sqrt(a + b*tan(e + f*x))*sqrt(c + d*tan(e + f*x))), x) rule3725 = ReplacementRule(pattern3725, replacement3725) pattern3726 = Pattern(Integral((WC('A', S(0)) + WC('B', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))*sqrt(WC('a', S(0)) + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))/sqrt(WC('c', S(0)) + WC('d', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons71, cons1440, cons1545) def replacement3726(B, e, f, b, d, a, c, x, A): rubi.append(3726) return Dist(B*b, Int((S(1) + tan(e + f*x)**(S(-2)))/(sqrt(a + b/tan(e + f*x))*sqrt(c + d/tan(e + f*x))), x), x) + Int(Simp(A*a - B*b + (A*b + B*a)/tan(e + f*x), x)/(sqrt(a + b/tan(e + f*x))*sqrt(c + d/tan(e + f*x))), x) rule3726 = ReplacementRule(pattern3726, replacement3726) pattern3727 = Pattern(Integral((WC('A', S(0)) + WC('B', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))*(WC('a', S(0)) + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons21, cons4, cons71, cons1440, cons1558) def replacement3727(B, e, m, f, b, d, a, c, n, x, A): rubi.append(3727) return Dist(A**S(2)/f, Subst(Int((a + b*x)**m*(c + d*x)**n/(A - B*x), x), x, tan(e + f*x)), x) rule3727 = ReplacementRule(pattern3727, replacement3727) pattern3728 = Pattern(Integral((WC('A', S(0)) + WC('B', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))*(WC('a', S(0)) + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons21, cons4, cons71, cons1440, cons1558) def replacement3728(B, e, m, f, b, d, a, c, n, x, A): rubi.append(3728) return -Dist(A**S(2)/f, Subst(Int((a + b*x)**m*(c + d*x)**n/(A - B*x), x), x, S(1)/tan(e + f*x)), x) rule3728 = ReplacementRule(pattern3728, replacement3728) pattern3729 = Pattern(Integral((WC('A', S(0)) + WC('B', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))*(WC('a', S(0)) + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons21, cons4, cons71, cons1440, cons1559) def replacement3729(B, e, m, f, b, d, a, c, n, x, A): rubi.append(3729) return Dist(A/S(2) - I*B/S(2), Int((a + b*tan(e + f*x))**m*(c + d*tan(e + f*x))**n*(I*tan(e + f*x) + S(1)), x), x) + Dist(A/S(2) + I*B/S(2), Int((a + b*tan(e + f*x))**m*(c + d*tan(e + f*x))**n*(-I*tan(e + f*x) + S(1)), x), x) rule3729 = ReplacementRule(pattern3729, replacement3729) pattern3730 = Pattern(Integral((WC('A', S(0)) + WC('B', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))*(WC('a', S(0)) + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons21, cons4, cons71, cons1440, cons1559) def replacement3730(B, e, m, f, b, d, a, c, n, x, A): rubi.append(3730) return Dist(A/S(2) - I*B/S(2), Int((S(1) + I/tan(e + f*x))*(a + b/tan(e + f*x))**m*(c + d/tan(e + f*x))**n, x), x) + Dist(A/S(2) + I*B/S(2), Int((S(1) - I/tan(e + f*x))*(a + b/tan(e + f*x))**m*(c + d/tan(e + f*x))**n, x), x) rule3730 = ReplacementRule(pattern3730, replacement3730) pattern3731 = Pattern(Integral((A_ + WC('C', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0)))**S(2))*(WC('a', S(0)) + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1)), x_), cons2, cons3, cons48, cons125, cons34, cons36, cons21, cons1561) def replacement3731(C, m, f, b, a, A, x, e): rubi.append(3731) return Dist(A/(b*f), Subst(Int((a + x)**m, x), x, b*tan(e + f*x)), x) rule3731 = ReplacementRule(pattern3731, replacement3731) pattern3732 = Pattern(Integral((A_ + WC('C', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0)))**S(2))*(WC('a', S(0)) + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1)), x_), cons2, cons3, cons48, cons125, cons34, cons36, cons21, cons1561) def replacement3732(C, m, f, b, a, A, x, e): rubi.append(3732) return -Dist(A/(b*f), Subst(Int((a + x)**m, x), x, b/tan(e + f*x)), x) rule3732 = ReplacementRule(pattern3732, replacement3732) pattern3733 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(WC('A', S(0)) + WC('B', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))) + WC('C', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0)))**S(2)), x_), cons2, cons3, cons48, cons125, cons34, cons35, cons36, cons21, cons33) def replacement3733(B, C, m, f, b, a, A, x, e): rubi.append(3733) return Dist(b**(S(-2)), Int((a + b*tan(e + f*x))**(m + S(1))*Simp(B*b - C*a + C*b*tan(e + f*x), x), x), x) rule3733 = ReplacementRule(pattern3733, replacement3733) pattern3734 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(WC('A', S(0)) + WC('B', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))) + WC('C', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0)))**S(2)), x_), cons2, cons3, cons48, cons125, cons34, cons35, cons36, cons21, cons33) def replacement3734(B, C, m, f, b, a, A, x, e): rubi.append(3734) return Dist(b**(S(-2)), Int((a + b/tan(e + f*x))**(m + S(1))*Simp(B*b - C*a + C*b/tan(e + f*x), x), x), x) rule3734 = ReplacementRule(pattern3734, replacement3734) pattern3735 = Pattern(Integral((WC('A', S(0)) + WC('C', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0)))**S(2))*(WC('a', S(0)) + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1)), x_), cons2, cons3, cons48, cons125, cons34, cons36, cons21, cons1433) def replacement3735(C, m, f, b, a, A, x, e): rubi.append(3735) return -Dist(C/b**S(2), Int((a - b*tan(e + f*x))*(a + b*tan(e + f*x))**(m + S(1)), x), x) rule3735 = ReplacementRule(pattern3735, replacement3735) pattern3736 = Pattern(Integral((WC('A', S(0)) + WC('C', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0)))**S(2))*(WC('a', S(0)) + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1)), x_), cons2, cons3, cons48, cons125, cons34, cons36, cons21, cons1433) def replacement3736(C, m, f, b, a, A, x, e): rubi.append(3736) return -Dist(C/b**S(2), Int((a - b/tan(e + f*x))*(a + b/tan(e + f*x))**(m + S(1)), x), x) rule3736 = ReplacementRule(pattern3736, replacement3736) pattern3737 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(WC('A', S(0)) + WC('B', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))) + WC('C', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0)))**S(2)), x_), cons2, cons3, cons48, cons125, cons34, cons35, cons36, cons1562, cons31, cons32, cons1439) def replacement3737(B, C, m, f, b, a, A, x, e): rubi.append(3737) return Dist(S(1)/(S(2)*a**S(2)*m), Int((a + b*tan(e + f*x))**(m + S(1))*Simp(A*a*(S(2)*m + S(1)) + B*b - C*a - (C*b*(m + S(-1)) + (m + S(1))*(A*b - B*a))*tan(e + f*x), x), x), x) - Simp((a + b*tan(e + f*x))**m*(A*a + B*b - C*a)*tan(e + f*x)/(S(2)*a*f*m), x) rule3737 = ReplacementRule(pattern3737, replacement3737) pattern3738 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(WC('A', S(0)) + WC('B', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))) + WC('C', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0)))**S(2)), x_), cons2, cons3, cons48, cons125, cons34, cons35, cons36, cons1562, cons31, cons32, cons1439) def replacement3738(B, C, m, f, b, a, A, x, e): rubi.append(3738) return Dist(S(1)/(S(2)*a**S(2)*m), Int((a + b/tan(e + f*x))**(m + S(1))*Simp(A*a*(S(2)*m + S(1)) + B*b - C*a - (C*b*(m + S(-1)) + (m + S(1))*(A*b - B*a))/tan(e + f*x), x), x), x) + Simp((a + b/tan(e + f*x))**m*(A*a + B*b - C*a)/(S(2)*a*f*m*tan(e + f*x)), x) rule3738 = ReplacementRule(pattern3738, replacement3738) pattern3739 = Pattern(Integral((WC('A', S(0)) + WC('C', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0)))**S(2))*(WC('a', S(0)) + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1)), x_), cons2, cons3, cons48, cons125, cons34, cons36, cons1563, cons31, cons32, cons1439) def replacement3739(C, m, f, b, a, A, x, e): rubi.append(3739) return Dist(S(1)/(S(2)*a**S(2)*m), Int((a + b*tan(e + f*x))**(m + S(1))*Simp(A*a*(S(2)*m + S(1)) - C*a - (A*b*(m + S(1)) + C*b*(m + S(-1)))*tan(e + f*x), x), x), x) - Simp((a + b*tan(e + f*x))**m*(A*a - C*a)*tan(e + f*x)/(S(2)*a*f*m), x) rule3739 = ReplacementRule(pattern3739, replacement3739) pattern3740 = Pattern(Integral((WC('A', S(0)) + WC('C', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0)))**S(2))*(WC('a', S(0)) + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1)), x_), cons2, cons3, cons48, cons125, cons34, cons36, cons1563, cons31, cons32, cons1439) def replacement3740(C, m, f, b, a, A, x, e): rubi.append(3740) return Dist(S(1)/(S(2)*a**S(2)*m), Int((a + b/tan(e + f*x))**(m + S(1))*Simp(A*a*(S(2)*m + S(1)) - C*a - (A*b*(m + S(1)) + C*b*(m + S(-1)))/tan(e + f*x), x), x), x) + Simp((a + b/tan(e + f*x))**m*(A*a - C*a)/(S(2)*a*f*m*tan(e + f*x)), x) rule3740 = ReplacementRule(pattern3740, replacement3740) pattern3741 = Pattern(Integral((A_ + WC('B', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))) + WC('C', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0)))**S(2))/(WC('a', S(0)) + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons48, cons125, cons34, cons35, cons36, cons1440, cons1564) def replacement3741(B, C, f, b, a, A, x, e): rubi.append(3741) return Dist((A*b**S(2) - B*a*b + C*a**S(2))/(a**S(2) + b**S(2)), Int((tan(e + f*x)**S(2) + S(1))/(a + b*tan(e + f*x)), x), x) + Simp(x*(A*a + B*b - C*a)/(a**S(2) + b**S(2)), x) rule3741 = ReplacementRule(pattern3741, replacement3741) pattern3742 = Pattern(Integral((A_ + WC('B', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))) + WC('C', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0)))**S(2))/(WC('a', S(0)) + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons48, cons125, cons34, cons35, cons36, cons1440, cons1564) def replacement3742(B, C, f, b, a, A, x, e): rubi.append(3742) return Dist((A*b**S(2) - B*a*b + C*a**S(2))/(a**S(2) + b**S(2)), Int((S(1) + tan(e + f*x)**(S(-2)))/(a + b/tan(e + f*x)), x), x) + Simp(x*(A*a + B*b - C*a)/(a**S(2) + b**S(2)), x) rule3742 = ReplacementRule(pattern3742, replacement3742) pattern3743 = Pattern(Integral((A_ + WC('B', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))) + WC('C', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0)))**S(2))/tan(x_*WC('f', S(1)) + WC('e', S(0))), x_), cons48, cons125, cons34, cons35, cons36, cons1565) def replacement3743(B, C, f, A, x, e): rubi.append(3743) return Dist(A, Int(S(1)/tan(e + f*x), x), x) + Dist(C, Int(tan(e + f*x), x), x) + Simp(B*x, x) rule3743 = ReplacementRule(pattern3743, replacement3743) pattern3744 = Pattern(Integral((A_ + WC('B', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))) + WC('C', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0)))**S(2))*tan(x_*WC('f', S(1)) + WC('e', S(0))), x_), cons48, cons125, cons34, cons35, cons36, cons1565) def replacement3744(B, C, f, A, x, e): rubi.append(3744) return Dist(A, Int(tan(e + f*x), x), x) + Dist(C, Int(S(1)/tan(e + f*x), x), x) + Simp(B*x, x) rule3744 = ReplacementRule(pattern3744, replacement3744) pattern3745 = Pattern(Integral((A_ + WC('C', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0)))**S(2))/tan(x_*WC('f', S(1)) + WC('e', S(0))), x_), cons48, cons125, cons34, cons36, cons1565) def replacement3745(C, e, f, x, A): rubi.append(3745) return Dist(A, Int(S(1)/tan(e + f*x), x), x) + Dist(C, Int(tan(e + f*x), x), x) rule3745 = ReplacementRule(pattern3745, replacement3745) pattern3746 = Pattern(Integral((A_ + WC('C', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0)))**S(2))*tan(x_*WC('f', S(1)) + WC('e', S(0))), x_), cons48, cons125, cons34, cons36, cons1565) def replacement3746(C, e, f, x, A): rubi.append(3746) return Dist(A, Int(tan(e + f*x), x), x) + Dist(C, Int(S(1)/tan(e + f*x), x), x) rule3746 = ReplacementRule(pattern3746, replacement3746) pattern3747 = Pattern(Integral((A_ + WC('B', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))) + WC('C', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0)))**S(2))/(WC('a', S(0)) + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons48, cons125, cons34, cons35, cons36, cons1562, cons1440, cons1566) def replacement3747(B, C, f, b, a, A, x, e): rubi.append(3747) return -Dist((A*b - B*a - C*b)/(a**S(2) + b**S(2)), Int(tan(e + f*x), x), x) + Dist((A*b**S(2) - B*a*b + C*a**S(2))/(a**S(2) + b**S(2)), Int((tan(e + f*x)**S(2) + S(1))/(a + b*tan(e + f*x)), x), x) + Simp(x*(A*a + B*b - C*a)/(a**S(2) + b**S(2)), x) rule3747 = ReplacementRule(pattern3747, replacement3747) pattern3748 = Pattern(Integral((A_ + WC('B', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))) + WC('C', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0)))**S(2))/(WC('a', S(0)) + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons48, cons125, cons34, cons35, cons36, cons1562, cons1440, cons1566) def replacement3748(B, C, f, b, a, A, x, e): rubi.append(3748) return -Dist((A*b - B*a - C*b)/(a**S(2) + b**S(2)), Int(S(1)/tan(e + f*x), x), x) + Dist((A*b**S(2) - B*a*b + C*a**S(2))/(a**S(2) + b**S(2)), Int((S(1) + tan(e + f*x)**(S(-2)))/(a + b/tan(e + f*x)), x), x) + Simp(x*(A*a + B*b - C*a)/(a**S(2) + b**S(2)), x) rule3748 = ReplacementRule(pattern3748, replacement3748) pattern3749 = Pattern(Integral((A_ + WC('C', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0)))**S(2))/(a_ + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons48, cons125, cons34, cons36, cons1563, cons1440, cons1565) def replacement3749(C, f, b, a, A, x, e): rubi.append(3749) return Dist((A*b**S(2) + C*a**S(2))/(a**S(2) + b**S(2)), Int((tan(e + f*x)**S(2) + S(1))/(a + b*tan(e + f*x)), x), x) - Dist(b*(A - C)/(a**S(2) + b**S(2)), Int(tan(e + f*x), x), x) + Simp(a*x*(A - C)/(a**S(2) + b**S(2)), x) rule3749 = ReplacementRule(pattern3749, replacement3749) pattern3750 = Pattern(Integral((A_ + WC('C', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0)))**S(2))/(a_ + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons48, cons125, cons34, cons36, cons1563, cons1440, cons1565) def replacement3750(C, f, b, a, A, x, e): rubi.append(3750) return Dist((A*b**S(2) + C*a**S(2))/(a**S(2) + b**S(2)), Int((S(1) + tan(e + f*x)**(S(-2)))/(a + b/tan(e + f*x)), x), x) - Dist(b*(A - C)/(a**S(2) + b**S(2)), Int(S(1)/tan(e + f*x), x), x) + Simp(a*x*(A - C)/(a**S(2) + b**S(2)), x) rule3750 = ReplacementRule(pattern3750, replacement3750) pattern3751 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('A', S(0)) + WC('B', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))) + WC('C', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0)))**S(2)), x_), cons2, cons3, cons48, cons125, cons34, cons35, cons36, cons1562, cons31, cons94, cons1440) def replacement3751(B, C, e, m, f, b, a, x, A): rubi.append(3751) return Dist(S(1)/(a**S(2) + b**S(2)), Int((a + b*tan(e + f*x))**(m + S(1))*Simp(B*b + a*(A - C) - (A*b - B*a - C*b)*tan(e + f*x), x), x), x) + Simp((a + b*tan(e + f*x))**(m + S(1))*(A*b**S(2) - B*a*b + C*a**S(2))/(b*f*(a**S(2) + b**S(2))*(m + S(1))), x) rule3751 = ReplacementRule(pattern3751, replacement3751) pattern3752 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('A', S(0)) + WC('B', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))) + WC('C', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0)))**S(2)), x_), cons2, cons3, cons48, cons125, cons34, cons35, cons36, cons1562, cons31, cons94, cons1440) def replacement3752(B, C, e, m, f, b, a, x, A): rubi.append(3752) return Dist(S(1)/(a**S(2) + b**S(2)), Int((a + b/tan(e + f*x))**(m + S(1))*Simp(B*b + a*(A - C) - (A*b - B*a - C*b)/tan(e + f*x), x), x), x) - Simp((a + b/tan(e + f*x))**(m + S(1))*(A*b**S(2) - B*a*b + C*a**S(2))/(b*f*(a**S(2) + b**S(2))*(m + S(1))), x) rule3752 = ReplacementRule(pattern3752, replacement3752) pattern3753 = Pattern(Integral((WC('A', S(0)) + WC('C', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0)))**S(2))*(WC('a', S(0)) + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_, x_), cons2, cons3, cons48, cons125, cons34, cons36, cons1563, cons31, cons94, cons1440) def replacement3753(C, e, m, f, b, a, x, A): rubi.append(3753) return Dist(S(1)/(a**S(2) + b**S(2)), Int((a + b*tan(e + f*x))**(m + S(1))*Simp(a*(A - C) - (A*b - C*b)*tan(e + f*x), x), x), x) + Simp((a + b*tan(e + f*x))**(m + S(1))*(A*b**S(2) + C*a**S(2))/(b*f*(a**S(2) + b**S(2))*(m + S(1))), x) rule3753 = ReplacementRule(pattern3753, replacement3753) pattern3754 = Pattern(Integral((WC('A', S(0)) + WC('C', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0)))**S(2))*(WC('a', S(0)) + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_, x_), cons2, cons3, cons48, cons125, cons34, cons36, cons1563, cons31, cons94, cons1440) def replacement3754(C, e, m, f, b, a, x, A): rubi.append(3754) return Dist(S(1)/(a**S(2) + b**S(2)), Int((a + b/tan(e + f*x))**(m + S(1))*Simp(a*(A - C) - (A*b - C*b)/tan(e + f*x), x), x), x) - Simp((a + b/tan(e + f*x))**(m + S(1))*(A*b**S(2) + C*a**S(2))/(b*f*(a**S(2) + b**S(2))*(m + S(1))), x) rule3754 = ReplacementRule(pattern3754, replacement3754) pattern3755 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(WC('A', S(0)) + WC('B', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))) + WC('C', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0)))**S(2)), x_), cons2, cons3, cons48, cons125, cons34, cons35, cons36, cons21, cons1562, cons1549) def replacement3755(B, C, m, f, b, a, A, x, e): rubi.append(3755) return Int((a + b*tan(e + f*x))**m*Simp(A + B*tan(e + f*x) - C, x), x) + Simp(C*(a + b*tan(e + f*x))**(m + S(1))/(b*f*(m + S(1))), x) rule3755 = ReplacementRule(pattern3755, replacement3755) pattern3756 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(WC('A', S(0)) + WC('B', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))) + WC('C', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0)))**S(2)), x_), cons2, cons3, cons48, cons125, cons34, cons35, cons36, cons21, cons1562, cons1549) def replacement3756(B, C, m, f, b, a, A, x, e): rubi.append(3756) return Int((a + b/tan(e + f*x))**m*Simp(A + B/tan(e + f*x) - C, x), x) - Simp(C*(a + b/tan(e + f*x))**(m + S(1))/(b*f*(m + S(1))), x) rule3756 = ReplacementRule(pattern3756, replacement3756) pattern3757 = Pattern(Integral((WC('A', S(0)) + WC('C', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0)))**S(2))*(WC('a', S(0)) + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1)), x_), cons2, cons3, cons48, cons125, cons34, cons36, cons21, cons1563, cons1549) def replacement3757(C, m, f, b, a, A, x, e): rubi.append(3757) return Dist(A - C, Int((a + b*tan(e + f*x))**m, x), x) + Simp(C*(a + b*tan(e + f*x))**(m + S(1))/(b*f*(m + S(1))), x) rule3757 = ReplacementRule(pattern3757, replacement3757) pattern3758 = Pattern(Integral((WC('A', S(0)) + WC('C', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0)))**S(2))*(WC('a', S(0)) + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1)), x_), cons2, cons3, cons48, cons125, cons34, cons36, cons21, cons1563, cons1549) def replacement3758(C, m, f, b, a, A, x, e): rubi.append(3758) return Dist(A - C, Int((a + b/tan(e + f*x))**m, x), x) - Simp(C*(a + b/tan(e + f*x))**(m + S(1))/(b*f*(m + S(1))), x) rule3758 = ReplacementRule(pattern3758, replacement3758) pattern3759 = Pattern(Integral((A_ + WC('C', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0)))**S(2))*(WC('a', S(0)) + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(WC('c', S(0)) + WC('d', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons36, cons21, cons4, cons1561) def replacement3759(C, m, f, b, d, a, c, n, A, x, e): rubi.append(3759) return Dist(A/f, Subst(Int((a + b*x)**m*(c + d*x)**n, x), x, tan(e + f*x)), x) rule3759 = ReplacementRule(pattern3759, replacement3759) pattern3760 = Pattern(Integral((A_ + WC('C', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0)))**S(2))*(WC('a', S(0)) + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(WC('c', S(0)) + WC('d', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons36, cons21, cons4, cons1561) def replacement3760(C, m, f, b, d, a, c, n, A, x, e): rubi.append(3760) return -Dist(A/f, Subst(Int((a + b*x)**m*(c + d*x)**n, x), x, S(1)/tan(e + f*x)), x) rule3760 = ReplacementRule(pattern3760, replacement3760) pattern3761 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))*(WC('c', S(0)) + WC('d', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(WC('A', S(0)) + WC('B', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))) + WC('C', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0)))**S(2)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons36, cons71, cons1545, cons87, cons89) def replacement3761(B, C, f, b, d, c, a, n, A, x, e): rubi.append(3761) return Dist(S(1)/(d*(c**S(2) + d**S(2))), Int((c + d*tan(e + f*x))**(n + S(1))*Simp(C*b*(c**S(2) + d**S(2))*tan(e + f*x)**S(2) + a*d*(A*c + B*d - C*c) + b*(A*d**S(2) - B*c*d + C*c**S(2)) + d*(-A*a*d + A*b*c + B*a*c + B*b*d + C*a*d - C*b*c)*tan(e + f*x), x), x), x) - Simp((c + d*tan(e + f*x))**(n + S(1))*(-a*d + b*c)*(A*d**S(2) - B*c*d + C*c**S(2))/(d**S(2)*f*(c**S(2) + d**S(2))*(n + S(1))), x) rule3761 = ReplacementRule(pattern3761, replacement3761) pattern3762 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))*(WC('c', S(0)) + WC('d', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(WC('A', S(0)) + WC('B', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))) + WC('C', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0)))**S(2)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons36, cons71, cons1545, cons87, cons89) def replacement3762(B, C, e, f, b, d, a, c, n, x, A): rubi.append(3762) return Dist(S(1)/(d*(c**S(2) + d**S(2))), Int((c + d/tan(e + f*x))**(n + S(1))*Simp(C*b*(c**S(2) + d**S(2))/tan(e + f*x)**S(2) + a*d*(A*c + B*d - C*c) + b*(A*d**S(2) - B*c*d + C*c**S(2)) + d*(-A*a*d + A*b*c + B*a*c + B*b*d + C*a*d - C*b*c)/tan(e + f*x), x), x), x) + Simp((c + d/tan(e + f*x))**(n + S(1))*(-a*d + b*c)*(A*d**S(2) - B*c*d + C*c**S(2))/(d**S(2)*f*(c**S(2) + d**S(2))*(n + S(1))), x) rule3762 = ReplacementRule(pattern3762, replacement3762) pattern3763 = Pattern(Integral((WC('A', S(0)) + WC('C', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0)))**S(2))*(WC('a', S(0)) + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))*(WC('c', S(0)) + WC('d', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons36, cons71, cons1545, cons87, cons89) def replacement3763(C, f, b, d, c, a, n, A, x, e): rubi.append(3763) return Dist(S(1)/(d*(c**S(2) + d**S(2))), Int((c + d*tan(e + f*x))**(n + S(1))*Simp(C*b*(c**S(2) + d**S(2))*tan(e + f*x)**S(2) + a*d*(A*c - C*c) + b*(A*d**S(2) + C*c**S(2)) + d*(-A*a*d + A*b*c + C*a*d - C*b*c)*tan(e + f*x), x), x), x) - Simp((c + d*tan(e + f*x))**(n + S(1))*(A*d**S(2) + C*c**S(2))*(-a*d + b*c)/(d**S(2)*f*(c**S(2) + d**S(2))*(n + S(1))), x) rule3763 = ReplacementRule(pattern3763, replacement3763) pattern3764 = Pattern(Integral((WC('A', S(0)) + WC('C', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0)))**S(2))*(WC('a', S(0)) + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))*(WC('c', S(0)) + WC('d', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons36, cons71, cons1545, cons87, cons89) def replacement3764(C, e, f, b, d, a, c, n, x, A): rubi.append(3764) return Dist(S(1)/(d*(c**S(2) + d**S(2))), Int((c + d/tan(e + f*x))**(n + S(1))*Simp(C*b*(c**S(2) + d**S(2))/tan(e + f*x)**S(2) + a*d*(A*c - C*c) + b*(A*d**S(2) + C*c**S(2)) + d*(-A*a*d + A*b*c + C*a*d - C*b*c)/tan(e + f*x), x), x), x) + Simp((c + d/tan(e + f*x))**(n + S(1))*(A*d**S(2) + C*c**S(2))*(-a*d + b*c)/(d**S(2)*f*(c**S(2) + d**S(2))*(n + S(1))), x) rule3764 = ReplacementRule(pattern3764, replacement3764) pattern3765 = Pattern(Integral((a_ + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))*(WC('c', S(0)) + WC('d', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1))*(WC('A', S(0)) + WC('B', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))) + WC('C', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0)))**S(2)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons36, cons4, cons71, cons1545, cons346) def replacement3765(B, C, f, b, d, c, n, a, A, x, e): rubi.append(3765) return -Dist(S(1)/(d*(n + S(2))), Int((c + d*tan(e + f*x))**n*Simp(-A*a*d*(n + S(2)) + C*b*c - d*(n + S(2))*(A*b + B*a - C*b)*tan(e + f*x) - (C*a*d*(n + S(2)) - b*(-B*d*(n + S(2)) + C*c))*tan(e + f*x)**S(2), x), x), x) + Simp(C*b*(c + d*tan(e + f*x))**(n + S(1))*tan(e + f*x)/(d*f*(n + S(2))), x) rule3765 = ReplacementRule(pattern3765, replacement3765) pattern3766 = Pattern(Integral((a_ + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))*(WC('c', S(0)) + WC('d', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1))*(WC('A', S(0)) + WC('B', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))) + WC('C', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0)))**S(2)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons36, cons4, cons71, cons1545, cons346) def replacement3766(B, C, f, b, d, c, n, a, A, x, e): rubi.append(3766) return -Dist(S(1)/(d*(n + S(2))), Int((c + d/tan(e + f*x))**n*Simp(-A*a*d*(n + S(2)) + C*b*c - d*(n + S(2))*(A*b + B*a - C*b)/tan(e + f*x) - (C*a*d*(n + S(2)) - b*(-B*d*(n + S(2)) + C*c))/tan(e + f*x)**S(2), x), x), x) - Simp(C*b*(c + d/tan(e + f*x))**(n + S(1))/(d*f*(n + S(2))*tan(e + f*x)), x) rule3766 = ReplacementRule(pattern3766, replacement3766) pattern3767 = Pattern(Integral((a_ + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))*(WC('A', S(0)) + WC('C', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0)))**S(2))*(WC('c', S(0)) + WC('d', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons36, cons4, cons71, cons1545, cons346) def replacement3767(C, f, b, d, c, n, a, A, x, e): rubi.append(3767) return -Dist(S(1)/(d*(n + S(2))), Int((c + d*tan(e + f*x))**n*Simp(-A*a*d*(n + S(2)) + C*b*c - d*(n + S(2))*(A*b - C*b)*tan(e + f*x) - (C*a*d*(n + S(2)) - C*b*c)*tan(e + f*x)**S(2), x), x), x) + Simp(C*b*(c + d*tan(e + f*x))**(n + S(1))*tan(e + f*x)/(d*f*(n + S(2))), x) rule3767 = ReplacementRule(pattern3767, replacement3767) pattern3768 = Pattern(Integral((a_ + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))*(WC('A', S(0)) + WC('C', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0)))**S(2))*(WC('c', S(0)) + WC('d', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons36, cons4, cons71, cons1545, cons346) def replacement3768(C, f, b, d, c, n, a, A, x, e): rubi.append(3768) return -Dist(S(1)/(d*(n + S(2))), Int((c + d/tan(e + f*x))**n*Simp(-A*a*d*(n + S(2)) + C*b*c - d*(n + S(2))*(A*b - C*b)/tan(e + f*x) - (C*a*d*(n + S(2)) - C*b*c)/tan(e + f*x)**S(2), x), x), x) - Simp(C*b*(c + d/tan(e + f*x))**(n + S(1))/(d*f*(n + S(2))*tan(e + f*x)), x) rule3768 = ReplacementRule(pattern3768, replacement3768) pattern3769 = Pattern(Integral((a_ + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1))*(WC('A', S(0)) + WC('B', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))) + WC('C', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0)))**S(2)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons36, cons4, cons71, cons1439, cons1567) def replacement3769(B, C, m, f, b, d, c, n, a, A, x, e): rubi.append(3769) return Dist(S(1)/(S(2)*a*m*(-a*d + b*c)), Int((a + b*tan(e + f*x))**(m + S(1))*(c + d*tan(e + f*x))**n*Simp(a*(-A*d*(S(2)*m + n + S(1)) + B*c*m + C*d*(n + S(1))) + b*(-B*d*(n + S(1)) + c*m*(A + C)) + (A*b*d*(m + n + S(1)) + C*b*d*(m - n + S(-1)) + a*(-B*d*(m + n + S(1)) + S(2)*C*c*m))*tan(e + f*x), x), x), x) + Simp((a + b*tan(e + f*x))**m*(c + d*tan(e + f*x))**(n + S(1))*(A*a + B*b - C*a)/(S(2)*f*m*(-a*d + b*c)), x) rule3769 = ReplacementRule(pattern3769, replacement3769) pattern3770 = Pattern(Integral((a_ + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1))*(WC('A', S(0)) + WC('B', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))) + WC('C', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0)))**S(2)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons36, cons4, cons71, cons1439, cons1567) def replacement3770(B, C, m, f, b, d, c, n, a, A, x, e): rubi.append(3770) return Dist(S(1)/(S(2)*a*m*(-a*d + b*c)), Int((a + b/tan(e + f*x))**(m + S(1))*(c + d/tan(e + f*x))**n*Simp(a*(-A*d*(S(2)*m + n + S(1)) + B*c*m + C*d*(n + S(1))) + b*(-B*d*(n + S(1)) + c*m*(A + C)) + (A*b*d*(m + n + S(1)) + C*b*d*(m - n + S(-1)) + a*(-B*d*(m + n + S(1)) + S(2)*C*c*m))/tan(e + f*x), x), x), x) - Simp((a + b/tan(e + f*x))**m*(c + d/tan(e + f*x))**(n + S(1))*(A*a + B*b - C*a)/(S(2)*f*m*(-a*d + b*c)), x) rule3770 = ReplacementRule(pattern3770, replacement3770) pattern3771 = Pattern(Integral((a_ + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('A', S(0)) + WC('C', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0)))**S(2))*(WC('c', S(0)) + WC('d', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons36, cons4, cons71, cons1439, cons1567) def replacement3771(C, m, f, b, d, c, n, a, A, x, e): rubi.append(3771) return Dist(S(1)/(S(2)*a*m*(-a*d + b*c)), Int((a + b*tan(e + f*x))**(m + S(1))*(c + d*tan(e + f*x))**n*Simp(a*(-A*d*(S(2)*m + n + S(1)) + C*d*(n + S(1))) + b*c*m*(A + C) + (A*b*d*(m + n + S(1)) + S(2)*C*a*c*m + C*b*d*(m - n + S(-1)))*tan(e + f*x), x), x), x) + Simp(a*(A - C)*(a + b*tan(e + f*x))**m*(c + d*tan(e + f*x))**(n + S(1))/(S(2)*f*m*(-a*d + b*c)), x) rule3771 = ReplacementRule(pattern3771, replacement3771) pattern3772 = Pattern(Integral((a_ + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('A', S(0)) + WC('C', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0)))**S(2))*(WC('c', S(0)) + WC('d', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons36, cons4, cons71, cons1439, cons1567) def replacement3772(C, m, f, b, d, c, n, a, A, x, e): rubi.append(3772) return Dist(S(1)/(S(2)*a*m*(-a*d + b*c)), Int((a + b/tan(e + f*x))**(m + S(1))*(c + d/tan(e + f*x))**n*Simp(a*(-A*d*(S(2)*m + n + S(1)) + C*d*(n + S(1))) + b*c*m*(A + C) + (A*b*d*(m + n + S(1)) + S(2)*C*a*c*m + C*b*d*(m - n + S(-1)))/tan(e + f*x), x), x), x) - Simp(a*(A - C)*(a + b/tan(e + f*x))**m*(c + d/tan(e + f*x))**(n + S(1))/(S(2)*f*m*(-a*d + b*c)), x) rule3772 = ReplacementRule(pattern3772, replacement3772) pattern3773 = Pattern(Integral((a_ + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(WC('c', S(0)) + WC('d', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(WC('A', S(0)) + WC('B', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))) + WC('C', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0)))**S(2)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons36, cons21, cons71, cons1439, cons1303, cons87, cons89, cons1545) def replacement3773(B, C, m, f, b, d, c, a, n, A, x, e): rubi.append(3773) return -Dist(S(1)/(a*d*(c**S(2) + d**S(2))*(n + S(1))), Int((a + b*tan(e + f*x))**m*(c + d*tan(e + f*x))**(n + S(1))*Simp(-a*d*(n + S(1))*(A*c + B*d - C*c) - a*(-C*(c**S(2)*m - d**S(2)*(n + S(1))) + d*(-A*d + B*c)*(m + n + S(1)))*tan(e + f*x) + b*m*(A*d**S(2) - B*c*d + C*c**S(2)), x), x), x) + Simp((a + b*tan(e + f*x))**m*(c + d*tan(e + f*x))**(n + S(1))*(A*d**S(2) - B*c*d + C*c**S(2))/(d*f*(c**S(2) + d**S(2))*(n + S(1))), x) rule3773 = ReplacementRule(pattern3773, replacement3773) pattern3774 = Pattern(Integral((a_ + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(WC('c', S(0)) + WC('d', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(WC('A', S(0)) + WC('B', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))) + WC('C', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0)))**S(2)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons36, cons21, cons71, cons1439, cons1303, cons87, cons89, cons1545) def replacement3774(B, C, m, f, b, d, c, n, a, A, x, e): rubi.append(3774) return -Dist(S(1)/(a*d*(c**S(2) + d**S(2))*(n + S(1))), Int((a + b/tan(e + f*x))**m*(c + d/tan(e + f*x))**(n + S(1))*Simp(-a*d*(n + S(1))*(A*c + B*d - C*c) - a*(-C*(c**S(2)*m - d**S(2)*(n + S(1))) + d*(-A*d + B*c)*(m + n + S(1)))/tan(e + f*x) + b*m*(A*d**S(2) - B*c*d + C*c**S(2)), x), x), x) - Simp((a + b/tan(e + f*x))**m*(c + d/tan(e + f*x))**(n + S(1))*(A*d**S(2) - B*c*d + C*c**S(2))/(d*f*(c**S(2) + d**S(2))*(n + S(1))), x) rule3774 = ReplacementRule(pattern3774, replacement3774) pattern3775 = Pattern(Integral((a_ + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(WC('A', S(0)) + WC('C', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0)))**S(2))*(WC('c', S(0)) + WC('d', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons36, cons21, cons71, cons1439, cons1303, cons87, cons89, cons1545) def replacement3775(C, m, f, b, d, c, a, n, A, x, e): rubi.append(3775) return -Dist(S(1)/(a*d*(c**S(2) + d**S(2))*(n + S(1))), Int((a + b*tan(e + f*x))**m*(c + d*tan(e + f*x))**(n + S(1))*Simp(-a*d*(n + S(1))*(A*c - C*c) - a*(-A*d**S(2)*(m + n + S(1)) - C*(c**S(2)*m - d**S(2)*(n + S(1))))*tan(e + f*x) + b*m*(A*d**S(2) + C*c**S(2)), x), x), x) + Simp((a + b*tan(e + f*x))**m*(c + d*tan(e + f*x))**(n + S(1))*(A*d**S(2) + C*c**S(2))/(d*f*(c**S(2) + d**S(2))*(n + S(1))), x) rule3775 = ReplacementRule(pattern3775, replacement3775) pattern3776 = Pattern(Integral((a_ + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(WC('A', S(0)) + WC('C', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0)))**S(2))*(WC('c', S(0)) + WC('d', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons36, cons21, cons71, cons1439, cons1303, cons87, cons89, cons1545) def replacement3776(C, m, f, b, d, c, n, a, A, x, e): rubi.append(3776) return -Dist(S(1)/(a*d*(c**S(2) + d**S(2))*(n + S(1))), Int((a + b/tan(e + f*x))**m*(c + d/tan(e + f*x))**(n + S(1))*Simp(-a*d*(n + S(1))*(A*c - C*c) - a*(-A*d**S(2)*(m + n + S(1)) - C*(c**S(2)*m - d**S(2)*(n + S(1))))/tan(e + f*x) + b*m*(A*d**S(2) + C*c**S(2)), x), x), x) - Simp((a + b/tan(e + f*x))**m*(c + d/tan(e + f*x))**(n + S(1))*(A*d**S(2) + C*c**S(2))/(d*f*(c**S(2) + d**S(2))*(n + S(1))), x) rule3776 = ReplacementRule(pattern3776, replacement3776) pattern3777 = Pattern(Integral((a_ + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(WC('c', S(0)) + WC('d', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1))*(WC('A', S(0)) + WC('B', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))) + WC('C', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0)))**S(2)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons36, cons21, cons4, cons71, cons1439, cons1303, cons683) def replacement3777(B, C, m, f, b, d, c, n, a, A, x, e): rubi.append(3777) return Dist(S(1)/(b*d*(m + n + S(1))), Int((a + b*tan(e + f*x))**m*(c + d*tan(e + f*x))**n*Simp(A*b*d*(m + n + S(1)) + C*(a*c*m - b*d*(n + S(1))) - (-B*b*d*(m + n + S(1)) + C*m*(-a*d + b*c))*tan(e + f*x), x), x), x) + Simp(C*(a + b*tan(e + f*x))**m*(c + d*tan(e + f*x))**(n + S(1))/(d*f*(m + n + S(1))), x) rule3777 = ReplacementRule(pattern3777, replacement3777) pattern3778 = Pattern(Integral((a_ + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(WC('c', S(0)) + WC('d', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1))*(WC('A', S(0)) + WC('B', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))) + WC('C', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0)))**S(2)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons36, cons21, cons4, cons71, cons1439, cons1303, cons683) def replacement3778(B, C, m, f, b, d, c, n, a, A, x, e): rubi.append(3778) return Dist(S(1)/(b*d*(m + n + S(1))), Int((a + b/tan(e + f*x))**m*(c + d/tan(e + f*x))**n*Simp(A*b*d*(m + n + S(1)) + C*(a*c*m - b*d*(n + S(1))) - (-B*b*d*(m + n + S(1)) + C*m*(-a*d + b*c))/tan(e + f*x), x), x), x) - Simp(C*(a + b/tan(e + f*x))**m*(c + d/tan(e + f*x))**(n + S(1))/(d*f*(m + n + S(1))), x) rule3778 = ReplacementRule(pattern3778, replacement3778) pattern3779 = Pattern(Integral((a_ + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(WC('A', S(0)) + WC('C', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0)))**S(2))*(WC('c', S(0)) + WC('d', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons36, cons21, cons4, cons71, cons1439, cons1303, cons683) def replacement3779(C, m, f, b, d, c, n, a, A, x, e): rubi.append(3779) return Dist(S(1)/(b*d*(m + n + S(1))), Int((a + b*tan(e + f*x))**m*(c + d*tan(e + f*x))**n*Simp(A*b*d*(m + n + S(1)) - C*m*(-a*d + b*c)*tan(e + f*x) + C*(a*c*m - b*d*(n + S(1))), x), x), x) + Simp(C*(a + b*tan(e + f*x))**m*(c + d*tan(e + f*x))**(n + S(1))/(d*f*(m + n + S(1))), x) rule3779 = ReplacementRule(pattern3779, replacement3779) pattern3780 = Pattern(Integral((a_ + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(WC('A', S(0)) + WC('C', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0)))**S(2))*(WC('c', S(0)) + WC('d', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons36, cons21, cons4, cons71, cons1439, cons1303, cons683) def replacement3780(C, m, f, b, d, c, n, a, A, x, e): rubi.append(3780) return Dist(S(1)/(b*d*(m + n + S(1))), Int((a + b/tan(e + f*x))**m*(c + d/tan(e + f*x))**n*Simp(A*b*d*(m + n + S(1)) - C*m*(-a*d + b*c)/tan(e + f*x) + C*(a*c*m - b*d*(n + S(1))), x), x), x) - Simp(C*(a + b/tan(e + f*x))**m*(c + d/tan(e + f*x))**(n + S(1))/(d*f*(m + n + S(1))), x) rule3780 = ReplacementRule(pattern3780, replacement3780) pattern3781 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(WC('A', S(0)) + WC('B', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))) + WC('C', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0)))**S(2)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons36, cons71, cons1440, cons1545, cons93, cons168, cons89) def replacement3781(B, C, m, f, b, d, c, a, n, A, x, e): rubi.append(3781) return -Dist(S(1)/(d*(c**S(2) + d**S(2))*(n + S(1))), Int((a + b*tan(e + f*x))**(m + S(-1))*(c + d*tan(e + f*x))**(n + S(1))*Simp(A*d*(-a*c*(n + S(1)) + b*d*m) - b*(-C*(c**S(2)*m - d**S(2)*(n + S(1))) + d*(-A*d + B*c)*(m + n + S(1)))*tan(e + f*x)**S(2) - d*(n + S(1))*(B*(a*c + b*d) + (A - C)*(-a*d + b*c))*tan(e + f*x) + (-B*d + C*c)*(a*d*(n + S(1)) + b*c*m), x), x), x) + Simp((a + b*tan(e + f*x))**m*(c + d*tan(e + f*x))**(n + S(1))*(A*d**S(2) + c*(-B*d + C*c))/(d*f*(c**S(2) + d**S(2))*(n + S(1))), x) rule3781 = ReplacementRule(pattern3781, replacement3781) pattern3782 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(WC('A', S(0)) + WC('B', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))) + WC('C', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0)))**S(2)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons36, cons71, cons1440, cons1545, cons93, cons168, cons89) def replacement3782(B, C, e, m, f, b, d, a, c, n, x, A): rubi.append(3782) return -Dist(S(1)/(d*(c**S(2) + d**S(2))*(n + S(1))), Int((a + b/tan(e + f*x))**(m + S(-1))*(c + d/tan(e + f*x))**(n + S(1))*Simp(A*d*(-a*c*(n + S(1)) + b*d*m) - b*(-C*(c**S(2)*m - d**S(2)*(n + S(1))) + d*(-A*d + B*c)*(m + n + S(1)))/tan(e + f*x)**S(2) - d*(n + S(1))*(B*(a*c + b*d) + (A - C)*(-a*d + b*c))/tan(e + f*x) + (-B*d + C*c)*(a*d*(n + S(1)) + b*c*m), x), x), x) - Simp((a + b/tan(e + f*x))**m*(c + d/tan(e + f*x))**(n + S(1))*(A*d**S(2) + c*(-B*d + C*c))/(d*f*(c**S(2) + d**S(2))*(n + S(1))), x) rule3782 = ReplacementRule(pattern3782, replacement3782) pattern3783 = Pattern(Integral((WC('A', S(0)) + WC('C', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0)))**S(2))*(WC('a', S(0)) + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons36, cons71, cons1440, cons1545, cons93, cons168, cons89) def replacement3783(C, m, f, b, d, c, a, n, A, x, e): rubi.append(3783) return -Dist(S(1)/(d*(c**S(2) + d**S(2))*(n + S(1))), Int((a + b*tan(e + f*x))**(m + S(-1))*(c + d*tan(e + f*x))**(n + S(1))*Simp(A*d*(-a*c*(n + S(1)) + b*d*m) + C*c*(a*d*(n + S(1)) + b*c*m) + b*(A*d**S(2)*(m + n + S(1)) + C*(c**S(2)*m - d**S(2)*(n + S(1))))*tan(e + f*x)**S(2) - d*(A - C)*(n + S(1))*(-a*d + b*c)*tan(e + f*x), x), x), x) + Simp((a + b*tan(e + f*x))**m*(c + d*tan(e + f*x))**(n + S(1))*(A*d**S(2) + C*c**S(2))/(d*f*(c**S(2) + d**S(2))*(n + S(1))), x) rule3783 = ReplacementRule(pattern3783, replacement3783) pattern3784 = Pattern(Integral((WC('A', S(0)) + WC('C', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0)))**S(2))*(WC('a', S(0)) + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons36, cons71, cons1440, cons1545, cons93, cons168, cons89) def replacement3784(C, e, m, f, b, d, a, c, n, x, A): rubi.append(3784) return -Dist(S(1)/(d*(c**S(2) + d**S(2))*(n + S(1))), Int((a + b/tan(e + f*x))**(m + S(-1))*(c + d/tan(e + f*x))**(n + S(1))*Simp(A*d*(-a*c*(n + S(1)) + b*d*m) + C*c*(a*d*(n + S(1)) + b*c*m) + b*(A*d**S(2)*(m + n + S(1)) + C*(c**S(2)*m - d**S(2)*(n + S(1))))/tan(e + f*x)**S(2) - d*(A - C)*(n + S(1))*(-a*d + b*c)/tan(e + f*x), x), x), x) - Simp((a + b/tan(e + f*x))**m*(c + d/tan(e + f*x))**(n + S(1))*(A*d**S(2) + C*c**S(2))/(d*f*(c**S(2) + d**S(2))*(n + S(1))), x) rule3784 = ReplacementRule(pattern3784, replacement3784) pattern3785 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(WC('c', S(0)) + WC('d', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(WC('A', S(0)) + WC('B', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))) + WC('C', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0)))**S(2)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons36, cons4, cons71, cons1440, cons1545, cons31, cons168, cons1568) def replacement3785(B, C, m, f, b, d, a, c, n, A, x, e): rubi.append(3785) return Dist(S(1)/(d*(m + n + S(1))), Int((a + b*tan(e + f*x))**(m + S(-1))*(c + d*tan(e + f*x))**n*Simp(A*a*d*(m + n + S(1)) - C*(a*d*(n + S(1)) + b*c*m) + d*(m + n + S(1))*(A*b + B*a - C*b)*tan(e + f*x) - (-B*b*d*(m + n + S(1)) + C*m*(-a*d + b*c))*tan(e + f*x)**S(2), x), x), x) + Simp(C*(a + b*tan(e + f*x))**m*(c + d*tan(e + f*x))**(n + S(1))/(d*f*(m + n + S(1))), x) rule3785 = ReplacementRule(pattern3785, replacement3785) pattern3786 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(WC('c', S(0)) + WC('d', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(WC('A', S(0)) + WC('B', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))) + WC('C', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0)))**S(2)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons36, cons4, cons71, cons1440, cons1545, cons31, cons168, cons1568) def replacement3786(B, C, m, f, b, d, a, c, n, A, x, e): rubi.append(3786) return Dist(S(1)/(d*(m + n + S(1))), Int((a + b/tan(e + f*x))**(m + S(-1))*(c + d/tan(e + f*x))**n*Simp(A*a*d*(m + n + S(1)) - C*(a*d*(n + S(1)) + b*c*m) + d*(m + n + S(1))*(A*b + B*a - C*b)/tan(e + f*x) - (-B*b*d*(m + n + S(1)) + C*m*(-a*d + b*c))/tan(e + f*x)**S(2), x), x), x) - Simp(C*(a + b/tan(e + f*x))**m*(c + d/tan(e + f*x))**(n + S(1))/(d*f*(m + n + S(1))), x) rule3786 = ReplacementRule(pattern3786, replacement3786) pattern3787 = Pattern(Integral((WC('A', S(0)) + WC('C', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0)))**S(2))*(WC('a', S(0)) + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(WC('c', S(0)) + WC('d', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons36, cons4, cons71, cons1440, cons1545, cons31, cons168, cons1568) def replacement3787(C, m, f, b, d, a, c, n, A, x, e): rubi.append(3787) return Dist(S(1)/(d*(m + n + S(1))), Int((a + b*tan(e + f*x))**(m + S(-1))*(c + d*tan(e + f*x))**n*Simp(A*a*d*(m + n + S(1)) - C*m*(-a*d + b*c)*tan(e + f*x)**S(2) - C*(a*d*(n + S(1)) + b*c*m) + d*(A*b - C*b)*(m + n + S(1))*tan(e + f*x), x), x), x) + Simp(C*(a + b*tan(e + f*x))**m*(c + d*tan(e + f*x))**(n + S(1))/(d*f*(m + n + S(1))), x) rule3787 = ReplacementRule(pattern3787, replacement3787) pattern3788 = Pattern(Integral((WC('A', S(0)) + WC('C', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0)))**S(2))*(WC('a', S(0)) + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(WC('c', S(0)) + WC('d', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons36, cons4, cons71, cons1440, cons1545, cons31, cons168, cons1568) def replacement3788(C, m, f, b, d, a, c, n, A, x, e): rubi.append(3788) return Dist(S(1)/(d*(m + n + S(1))), Int((a + b/tan(e + f*x))**(m + S(-1))*(c + d/tan(e + f*x))**n*Simp(A*a*d*(m + n + S(1)) - C*m*(-a*d + b*c)/tan(e + f*x)**S(2) - C*(a*d*(n + S(1)) + b*c*m) + d*(A*b - C*b)*(m + n + S(1))/tan(e + f*x), x), x), x) - Simp(C*(a + b/tan(e + f*x))**m*(c + d/tan(e + f*x))**(n + S(1))/(d*f*(m + n + S(1))), x) rule3788 = ReplacementRule(pattern3788, replacement3788) pattern3789 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(WC('A', S(0)) + WC('B', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))) + WC('C', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0)))**S(2)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons36, cons4, cons71, cons1440, cons1545, cons31, cons94, cons1557) def replacement3789(B, C, m, f, b, d, c, a, n, A, x, e): rubi.append(3789) return Dist(S(1)/((a**S(2) + b**S(2))*(m + S(1))*(-a*d + b*c)), Int((a + b*tan(e + f*x))**(m + S(1))*(c + d*tan(e + f*x))**n*Simp(A*(a*(m + S(1))*(-a*d + b*c) - b**S(2)*d*(m + n + S(2))) - d*(A*b**S(2) - a*(B*b - C*a))*(m + n + S(2))*tan(e + f*x)**S(2) - (m + S(1))*(-a*d + b*c)*(A*b - B*a - C*b)*tan(e + f*x) + (B*b - C*a)*(a*d*(n + S(1)) + b*c*(m + S(1))), x), x), x) + Simp((a + b*tan(e + f*x))**(m + S(1))*(c + d*tan(e + f*x))**(n + S(1))*(A*b**S(2) - a*(B*b - C*a))/(f*(a**S(2) + b**S(2))*(m + S(1))*(-a*d + b*c)), x) rule3789 = ReplacementRule(pattern3789, replacement3789) pattern3790 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(WC('A', S(0)) + WC('B', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))) + WC('C', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0)))**S(2)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons36, cons4, cons71, cons1440, cons1545, cons31, cons94, cons1557) def replacement3790(B, C, e, m, f, b, d, a, c, n, x, A): rubi.append(3790) return Dist(S(1)/((a**S(2) + b**S(2))*(m + S(1))*(-a*d + b*c)), Int((a + b/tan(e + f*x))**(m + S(1))*(c + d/tan(e + f*x))**n*Simp(A*(a*(m + S(1))*(-a*d + b*c) - b**S(2)*d*(m + n + S(2))) - d*(A*b**S(2) - a*(B*b - C*a))*(m + n + S(2))/tan(e + f*x)**S(2) - (m + S(1))*(-a*d + b*c)*(A*b - B*a - C*b)/tan(e + f*x) + (B*b - C*a)*(a*d*(n + S(1)) + b*c*(m + S(1))), x), x), x) - Simp((a + b/tan(e + f*x))**(m + S(1))*(c + d/tan(e + f*x))**(n + S(1))*(A*b**S(2) - a*(B*b - C*a))/(f*(a**S(2) + b**S(2))*(m + S(1))*(-a*d + b*c)), x) rule3790 = ReplacementRule(pattern3790, replacement3790) pattern3791 = Pattern(Integral((WC('A', S(0)) + WC('C', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0)))**S(2))*(WC('a', S(0)) + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons36, cons4, cons71, cons1440, cons1545, cons31, cons94, cons1557) def replacement3791(C, m, f, b, d, c, a, n, A, x, e): rubi.append(3791) return Dist(S(1)/((a**S(2) + b**S(2))*(m + S(1))*(-a*d + b*c)), Int((a + b*tan(e + f*x))**(m + S(1))*(c + d*tan(e + f*x))**n*Simp(A*(a*(m + S(1))*(-a*d + b*c) - b**S(2)*d*(m + n + S(2))) - C*a*(a*d*(n + S(1)) + b*c*(m + S(1))) - d*(A*b**S(2) + C*a**S(2))*(m + n + S(2))*tan(e + f*x)**S(2) - (m + S(1))*(A*b - C*b)*(-a*d + b*c)*tan(e + f*x), x), x), x) + Simp((a + b*tan(e + f*x))**(m + S(1))*(c + d*tan(e + f*x))**(n + S(1))*(A*b**S(2) + C*a**S(2))/(f*(a**S(2) + b**S(2))*(m + S(1))*(-a*d + b*c)), x) rule3791 = ReplacementRule(pattern3791, replacement3791) pattern3792 = Pattern(Integral((WC('A', S(0)) + WC('C', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0)))**S(2))*(WC('a', S(0)) + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons36, cons4, cons71, cons1440, cons1545, cons31, cons94, cons1557) def replacement3792(C, e, m, f, b, d, a, c, n, x, A): rubi.append(3792) return Dist(S(1)/((a**S(2) + b**S(2))*(m + S(1))*(-a*d + b*c)), Int((a + b/tan(e + f*x))**(m + S(1))*(c + d/tan(e + f*x))**n*Simp(A*(a*(m + S(1))*(-a*d + b*c) - b**S(2)*d*(m + n + S(2))) - C*a*(a*d*(n + S(1)) + b*c*(m + S(1))) - d*(A*b**S(2) + C*a**S(2))*(m + n + S(2))/tan(e + f*x)**S(2) - (m + S(1))*(A*b - C*b)*(-a*d + b*c)/tan(e + f*x), x), x), x) - Simp((a + b/tan(e + f*x))**(m + S(1))*(c + d/tan(e + f*x))**(n + S(1))*(A*b**S(2) + C*a**S(2))/(f*(a**S(2) + b**S(2))*(m + S(1))*(-a*d + b*c)), x) rule3792 = ReplacementRule(pattern3792, replacement3792) pattern3793 = Pattern(Integral((WC('A', S(0)) + WC('B', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))) + WC('C', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0)))**S(2))/((a_ + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))*(WC('c', S(0)) + WC('d', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons36, cons71, cons1440, cons1545) def replacement3793(B, C, f, b, d, c, a, A, x, e): rubi.append(3793) return Dist((A*b**S(2) - B*a*b + C*a**S(2))/((a**S(2) + b**S(2))*(-a*d + b*c)), Int((-a*tan(e + f*x) + b)/(a + b*tan(e + f*x)), x), x) - Dist((A*d**S(2) - B*c*d + C*c**S(2))/((c**S(2) + d**S(2))*(-a*d + b*c)), Int((-c*tan(e + f*x) + d)/(c + d*tan(e + f*x)), x), x) + Simp(x*(a*(A*c + B*d - C*c) + b*(-A*d + B*c + C*d))/((a**S(2) + b**S(2))*(c**S(2) + d**S(2))), x) rule3793 = ReplacementRule(pattern3793, replacement3793) pattern3794 = Pattern(Integral((WC('A', S(0)) + WC('B', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))) + WC('C', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0)))**S(2))/((a_ + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))*(WC('c', S(0)) + WC('d', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons36, cons71, cons1440, cons1545) def replacement3794(B, C, f, b, d, c, a, A, x, e): rubi.append(3794) return Dist((A*b**S(2) - B*a*b + C*a**S(2))/((a**S(2) + b**S(2))*(-a*d + b*c)), Int((-a/tan(e + f*x) + b)/(a + b/tan(e + f*x)), x), x) - Dist((A*d**S(2) - B*c*d + C*c**S(2))/((c**S(2) + d**S(2))*(-a*d + b*c)), Int((-c/tan(e + f*x) + d)/(c + d/tan(e + f*x)), x), x) + Simp(x*(a*(A*c + B*d - C*c) + b*(-A*d + B*c + C*d))/((a**S(2) + b**S(2))*(c**S(2) + d**S(2))), x) rule3794 = ReplacementRule(pattern3794, replacement3794) pattern3795 = Pattern(Integral((WC('A', S(0)) + WC('C', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0)))**S(2))/((a_ + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))*(WC('c', S(0)) + WC('d', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons36, cons71, cons1440, cons1545) def replacement3795(C, f, b, d, c, a, A, x, e): rubi.append(3795) return Dist((A*b**S(2) + C*a**S(2))/((a**S(2) + b**S(2))*(-a*d + b*c)), Int((-a*tan(e + f*x) + b)/(a + b*tan(e + f*x)), x), x) - Dist((A*d**S(2) + C*c**S(2))/((c**S(2) + d**S(2))*(-a*d + b*c)), Int((-c*tan(e + f*x) + d)/(c + d*tan(e + f*x)), x), x) + Simp(x*(a*(A*c - C*c) - b*(A*d - C*d))/((a**S(2) + b**S(2))*(c**S(2) + d**S(2))), x) rule3795 = ReplacementRule(pattern3795, replacement3795) pattern3796 = Pattern(Integral((WC('A', S(0)) + WC('C', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0)))**S(2))/((a_ + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))*(WC('c', S(0)) + WC('d', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons36, cons71, cons1440, cons1545) def replacement3796(C, f, b, d, c, a, A, x, e): rubi.append(3796) return Dist((A*b**S(2) + C*a**S(2))/((a**S(2) + b**S(2))*(-a*d + b*c)), Int((-a/tan(e + f*x) + b)/(a + b/tan(e + f*x)), x), x) - Dist((A*d**S(2) + C*c**S(2))/((c**S(2) + d**S(2))*(-a*d + b*c)), Int((-c/tan(e + f*x) + d)/(c + d/tan(e + f*x)), x), x) + Simp(x*(a*(A*c - C*c) - b*(A*d - C*d))/((a**S(2) + b**S(2))*(c**S(2) + d**S(2))), x) rule3796 = ReplacementRule(pattern3796, replacement3796) pattern3797 = Pattern(Integral((WC('c', S(0)) + WC('d', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(WC('A', S(0)) + WC('B', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))) + WC('C', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0)))**S(2))/(WC('a', S(0)) + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons36, cons4, cons71, cons1440, cons1545, cons1327, cons1569) def replacement3797(B, C, f, b, d, c, a, n, A, x, e): rubi.append(3797) return Dist((A*b**S(2) - B*a*b + C*a**S(2))/(a**S(2) + b**S(2)), Int((c + d*tan(e + f*x))**n*(tan(e + f*x)**S(2) + S(1))/(a + b*tan(e + f*x)), x), x) + Dist(S(1)/(a**S(2) + b**S(2)), Int((c + d*tan(e + f*x))**n*Simp(B*b + a*(A - C) + (B*a - b*(A - C))*tan(e + f*x), x), x), x) rule3797 = ReplacementRule(pattern3797, replacement3797) pattern3798 = Pattern(Integral((WC('c', S(0)) + WC('d', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(WC('A', S(0)) + WC('B', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))) + WC('C', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0)))**S(2))/(WC('a', S(0)) + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons36, cons4, cons71, cons1440, cons1545, cons1327, cons1569) def replacement3798(B, C, e, f, b, d, a, c, n, x, A): rubi.append(3798) return Dist((A*b**S(2) - B*a*b + C*a**S(2))/(a**S(2) + b**S(2)), Int((S(1) + tan(e + f*x)**(S(-2)))*(c + d/tan(e + f*x))**n/(a + b/tan(e + f*x)), x), x) + Dist(S(1)/(a**S(2) + b**S(2)), Int((c + d/tan(e + f*x))**n*Simp(B*b + a*(A - C) + (B*a - b*(A - C))/tan(e + f*x), x), x), x) rule3798 = ReplacementRule(pattern3798, replacement3798) pattern3799 = Pattern(Integral((WC('A', S(0)) + WC('C', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0)))**S(2))*(WC('c', S(0)) + WC('d', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_/(WC('a', S(0)) + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons36, cons4, cons71, cons1440, cons1545, cons1327, cons1569) def replacement3799(C, f, b, d, c, a, n, A, x, e): rubi.append(3799) return Dist((A*b**S(2) + C*a**S(2))/(a**S(2) + b**S(2)), Int((c + d*tan(e + f*x))**n*(tan(e + f*x)**S(2) + S(1))/(a + b*tan(e + f*x)), x), x) + Dist(S(1)/(a**S(2) + b**S(2)), Int((c + d*tan(e + f*x))**n*Simp(a*(A - C) - (A*b - C*b)*tan(e + f*x), x), x), x) rule3799 = ReplacementRule(pattern3799, replacement3799) pattern3800 = Pattern(Integral((WC('A', S(0)) + WC('C', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0)))**S(2))*(WC('c', S(0)) + WC('d', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_/(WC('a', S(0)) + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons36, cons4, cons71, cons1440, cons1545, cons1327, cons1569) def replacement3800(C, e, f, b, d, a, c, n, x, A): rubi.append(3800) return Dist((A*b**S(2) + C*a**S(2))/(a**S(2) + b**S(2)), Int((S(1) + tan(e + f*x)**(S(-2)))*(c + d/tan(e + f*x))**n/(a + b/tan(e + f*x)), x), x) + Dist(S(1)/(a**S(2) + b**S(2)), Int((c + d/tan(e + f*x))**n*Simp(a*(A - C) - (A*b - C*b)/tan(e + f*x), x), x), x) rule3800 = ReplacementRule(pattern3800, replacement3800) pattern3801 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(WC('A', S(0)) + WC('B', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))) + WC('C', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0)))**S(2)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons36, cons21, cons4, cons71, cons1440, cons1545) def replacement3801(B, C, m, f, b, d, c, a, n, A, x, e): rubi.append(3801) return Dist(S(1)/(b*f), Subst(Int((a + x)**m*(c + d*x/b)**n*(A*b**S(2) + B*b*x + C*x**S(2))/(b**S(2) + x**S(2)), x), x, b*tan(e + f*x)), x) rule3801 = ReplacementRule(pattern3801, replacement3801) pattern3802 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(WC('A', S(0)) + WC('B', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))) + WC('C', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0)))**S(2)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons36, cons21, cons4, cons71, cons1440, cons1545) def replacement3802(B, C, e, m, f, b, d, a, c, n, x, A): rubi.append(3802) return -Dist(S(1)/(b*f), Subst(Int((a + x)**m*(c + d*x/b)**n*(A*b**S(2) + B*b*x + C*x**S(2))/(b**S(2) + x**S(2)), x), x, b/tan(e + f*x)), x) rule3802 = ReplacementRule(pattern3802, replacement3802) pattern3803 = Pattern(Integral((WC('A', S(0)) + WC('C', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0)))**S(2))*(WC('a', S(0)) + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons36, cons21, cons4, cons71, cons1440, cons1545) def replacement3803(C, m, f, b, d, c, a, n, A, x, e): rubi.append(3803) return Dist(S(1)/(b*f), Subst(Int((a + x)**m*(c + d*x/b)**n*(A*b**S(2) + C*x**S(2))/(b**S(2) + x**S(2)), x), x, b*tan(e + f*x)), x) rule3803 = ReplacementRule(pattern3803, replacement3803) pattern3804 = Pattern(Integral((WC('A', S(0)) + WC('C', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0)))**S(2))*(WC('a', S(0)) + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons36, cons21, cons4, cons71, cons1440, cons1545) def replacement3804(C, e, m, f, b, d, a, c, n, x, A): rubi.append(3804) return -Dist(S(1)/(b*f), Subst(Int((a + x)**m*(c + d*x/b)**n*(A*b**S(2) + C*x**S(2))/(b**S(2) + x**S(2)), x), x, b/tan(e + f*x)), x) rule3804 = ReplacementRule(pattern3804, replacement3804) pattern3805 = Pattern(Integral(S(1)/(a_ + WC('b', S(1))*tan(x_*WC('d', S(1)) + WC('c', S(0)))**S(2)), x_), cons2, cons3, cons7, cons27, cons1492) def replacement3805(b, d, c, a, x): rubi.append(3805) return Dist(S(1)/a, Int(cos(c + d*x)**S(2), x), x) rule3805 = ReplacementRule(pattern3805, replacement3805) pattern3806 = Pattern(Integral(S(1)/(a_ + WC('b', S(1))/tan(x_*WC('d', S(1)) + WC('c', S(0)))**S(2)), x_), cons2, cons3, cons7, cons27, cons1492) def replacement3806(b, d, c, a, x): rubi.append(3806) return Dist(S(1)/a, Int(sin(c + d*x)**S(2), x), x) rule3806 = ReplacementRule(pattern3806, replacement3806) pattern3807 = Pattern(Integral(S(1)/(a_ + WC('b', S(1))*tan(x_*WC('d', S(1)) + WC('c', S(0)))**S(2)), x_), cons2, cons3, cons7, cons27, cons1456) def replacement3807(b, d, c, a, x): rubi.append(3807) return -Dist(b/(a - b), Int(S(1)/((a + b*tan(c + d*x)**S(2))*cos(c + d*x)**S(2)), x), x) + Simp(x/(a - b), x) rule3807 = ReplacementRule(pattern3807, replacement3807) pattern3808 = Pattern(Integral(S(1)/(a_ + WC('b', S(1))/tan(x_*WC('d', S(1)) + WC('c', S(0)))**S(2)), x_), cons2, cons3, cons7, cons27, cons1456) def replacement3808(b, d, c, a, x): rubi.append(3808) return -Dist(b/(a - b), Int(S(1)/((a + b/tan(c + d*x)**S(2))*sin(c + d*x)**S(2)), x), x) + Simp(x/(a - b), x) rule3808 = ReplacementRule(pattern3808, replacement3808) pattern3809 = Pattern(Integral((a_ + (WC('e', S(1))*tan(x_*WC('d', S(1)) + WC('c', S(0))))**n_*WC('b', S(1)))**p_, x_), cons2, cons3, cons7, cons27, cons48, cons4, cons5, cons1570) def replacement3809(p, b, d, c, a, n, x, e): rubi.append(3809) return Dist(e/d, Subst(Int((a + b*x**n)**p/(e**S(2) + x**S(2)), x), x, e*tan(c + d*x)), x) rule3809 = ReplacementRule(pattern3809, replacement3809) pattern3810 = Pattern(Integral((a_ + (WC('e', S(1))/tan(x_*WC('d', S(1)) + WC('c', S(0))))**n_*WC('b', S(1)))**p_, x_), cons2, cons3, cons7, cons27, cons48, cons4, cons5, cons1570) def replacement3810(p, b, d, c, n, a, x, e): rubi.append(3810) return -Dist(e/d, Subst(Int((a + b*x**n)**p/(e**S(2) + x**S(2)), x), x, e/tan(c + d*x)), x) rule3810 = ReplacementRule(pattern3810, replacement3810) def With3811(p, m, b, d, c, a, n, x, e): f = FreeFactors(tan(c + d*x), x) rubi.append(3811) return Dist(f**(m + S(1))/d, Subst(Int(x**m*(a + b*(e*f*x)**n)**p*(f**S(2)*x**S(2) + S(1))**(-m/S(2) + S(-1)), x), x, tan(c + d*x)/f), x) pattern3811 = Pattern(Integral((a_ + (WC('e', S(1))*tan(x_*WC('d', S(1)) + WC('c', S(0))))**n_*WC('b', S(1)))**p_*sin(x_*WC('d', S(1)) + WC('c', S(0)))**m_, x_), cons2, cons3, cons7, cons27, cons48, cons4, cons5, cons1515) rule3811 = ReplacementRule(pattern3811, With3811) def With3812(p, m, b, d, c, n, a, x, e): f = FreeFactors(S(1)/tan(c + d*x), x) rubi.append(3812) return -Dist(f**(m + S(1))/d, Subst(Int(x**m*(a + b*(e*f*x)**n)**p*(f**S(2)*x**S(2) + S(1))**(-m/S(2) + S(-1)), x), x, S(1)/(f*tan(c + d*x))), x) pattern3812 = Pattern(Integral((a_ + (WC('e', S(1))/tan(x_*WC('d', S(1)) + WC('c', S(0))))**n_*WC('b', S(1)))**p_*cos(x_*WC('d', S(1)) + WC('c', S(0)))**m_, x_), cons2, cons3, cons7, cons27, cons48, cons4, cons5, cons1515) rule3812 = ReplacementRule(pattern3812, With3812) def With3813(p, m, b, d, c, a, n, x): f = FreeFactors(cos(c + d*x), x) rubi.append(3813) return -Dist(f/d, Subst(Int((f*x)**(-n*p)*(-f**S(2)*x**S(2) + S(1))**(m/S(2) + S(-1)/2)*ExpandToSum(a*(f*x)**n + b*(-f**S(2)*x**S(2) + S(1))**(n/S(2)), x)**p, x), x, cos(c + d*x)/f), x) pattern3813 = Pattern(Integral((a_ + WC('b', S(1))*tan(x_*WC('d', S(1)) + WC('c', S(0)))**n_)**WC('p', S(1))*sin(x_*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1)), x_), cons2, cons3, cons7, cons27, cons1481, cons1479, cons38) rule3813 = ReplacementRule(pattern3813, With3813) def With3814(p, m, b, d, c, n, a, x): f = FreeFactors(sin(c + d*x), x) rubi.append(3814) return Dist(f/d, Subst(Int((f*x)**(-n*p)*(-f**S(2)*x**S(2) + S(1))**(m/S(2) + S(-1)/2)*ExpandToSum(a*(f*x)**n + b*(-f**S(2)*x**S(2) + S(1))**(n/S(2)), x)**p, x), x, sin(c + d*x)/f), x) pattern3814 = Pattern(Integral((a_ + (S(1)/tan(x_*WC('d', S(1)) + WC('c', S(0))))**n_*WC('b', S(1)))**WC('p', S(1))*cos(x_*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1)), x_), cons2, cons3, cons7, cons27, cons1481, cons1479, cons38) rule3814 = ReplacementRule(pattern3814, With3814) def With3815(p, m, b, d, c, a, n, x, e): f = FreeFactors(tan(c + d*x), x) rubi.append(3815) return Dist(f/d, Subst(Int((a + b*(e*f*x)**n)**p*(f**S(2)*x**S(2) + S(1))**(m/S(2) + S(-1)), x), x, tan(c + d*x)/f), x) pattern3815 = Pattern(Integral((a_ + (WC('e', S(1))*tan(x_*WC('d', S(1)) + WC('c', S(0))))**n_*WC('b', S(1)))**WC('p', S(1))*(S(1)/cos(x_*WC('d', S(1)) + WC('c', S(0))))**m_, x_), cons2, cons3, cons7, cons27, cons48, cons4, cons5, cons1515) rule3815 = ReplacementRule(pattern3815, With3815) def With3816(p, m, b, d, c, n, a, x, e): f = FreeFactors(S(1)/tan(c + d*x), x) rubi.append(3816) return -Dist(f/d, Subst(Int((a + b*(e*f*x)**n)**p*(f**S(2)*x**S(2) + S(1))**(m/S(2) + S(-1)), x), x, S(1)/(f*tan(c + d*x))), x) pattern3816 = Pattern(Integral((a_ + (WC('e', S(1))/tan(x_*WC('d', S(1)) + WC('c', S(0))))**n_*WC('b', S(1)))**WC('p', S(1))*(S(1)/sin(x_*WC('d', S(1)) + WC('c', S(0))))**m_, x_), cons2, cons3, cons7, cons27, cons48, cons4, cons5, cons1515) rule3816 = ReplacementRule(pattern3816, With3816) def With3817(p, m, b, d, c, a, n, x): f = FreeFactors(sin(c + d*x), x) rubi.append(3817) return Dist(f/d, Subst(Int((-f**S(2)*x**S(2) + S(1))**(-m/S(2) - n*p/S(2) + S(-1)/2)*ExpandToSum(a*(-f**S(2)*x**S(2) + S(1))**(n/S(2)) + b*(f*x)**n, x)**p, x), x, sin(c + d*x)/f), x) pattern3817 = Pattern(Integral((a_ + WC('b', S(1))*tan(x_*WC('d', S(1)) + WC('c', S(0)))**n_)**WC('p', S(1))*(S(1)/cos(x_*WC('d', S(1)) + WC('c', S(0))))**WC('m', S(1)), x_), cons2, cons3, cons7, cons27, cons1228, cons743, cons38) rule3817 = ReplacementRule(pattern3817, With3817) def With3818(p, m, b, d, c, n, a, x): f = FreeFactors(cos(c + d*x), x) rubi.append(3818) return -Dist(f/d, Subst(Int((-f**S(2)*x**S(2) + S(1))**(-m/S(2) - n*p/S(2) + S(-1)/2)*ExpandToSum(a*(-f**S(2)*x**S(2) + S(1))**(n/S(2)) + b*(f*x)**n, x)**p, x), x, cos(c + d*x)/f), x) pattern3818 = Pattern(Integral((a_ + (S(1)/tan(x_*WC('d', S(1)) + WC('c', S(0))))**n_*WC('b', S(1)))**WC('p', S(1))*(S(1)/sin(x_*WC('d', S(1)) + WC('c', S(0))))**WC('m', S(1)), x_), cons2, cons3, cons7, cons27, cons1228, cons743, cons38) rule3818 = ReplacementRule(pattern3818, With3818) pattern3819 = Pattern(Integral((a_ + (WC('e', S(1))*tan(x_*WC('d', S(1)) + WC('c', S(0))))**n_*WC('b', S(1)))**p_*tan(x_*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons21, cons4, cons5, cons1497) def replacement3819(p, m, b, d, c, a, n, x, e): rubi.append(3819) return Dist(e/d, Subst(Int((x/e)**m*(a + b*x**n)**p/(e**S(2) + x**S(2)), x), x, e*tan(c + d*x)), x) rule3819 = ReplacementRule(pattern3819, replacement3819) pattern3820 = Pattern(Integral((a_ + (WC('e', S(1))/tan(x_*WC('d', S(1)) + WC('c', S(0))))**n_*WC('b', S(1)))**p_*(S(1)/tan(x_*WC('d', S(1)) + WC('c', S(0))))**WC('m', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons21, cons4, cons5, cons1497) def replacement3820(p, m, b, d, c, n, a, x, e): rubi.append(3820) return -Dist(e/d, Subst(Int((x/e)**m*(a + b*x**n)**p/(e**S(2) + x**S(2)), x), x, e/tan(c + d*x)), x) rule3820 = ReplacementRule(pattern3820, replacement3820) pattern3821 = Pattern(Integral((a_ + WC('b', S(1))*tan(x_*WC('e', S(1)) + WC('d', S(0)))**WC('n', S(1)) + WC('c', S(1))*tan(x_*WC('e', S(1)) + WC('d', S(0)))**WC('n2', S(1)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons4, cons46, cons45, cons38) def replacement3821(p, b, n2, d, c, n, a, x, e): rubi.append(3821) return Dist(S(4)**(-p)*c**(-p), Int((b + S(2)*c*tan(d + e*x)**n)**(S(2)*p), x), x) rule3821 = ReplacementRule(pattern3821, replacement3821) pattern3822 = Pattern(Integral((a_ + (S(1)/tan(x_*WC('e', S(1)) + WC('d', S(0))))**WC('n', S(1))*WC('b', S(1)) + (S(1)/tan(x_*WC('e', S(1)) + WC('d', S(0))))**WC('n2', S(1))*WC('c', S(1)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons4, cons46, cons45, cons38) def replacement3822(p, b, n2, d, c, n, a, x, e): rubi.append(3822) return Dist(S(4)**(-p)*c**(-p), Int((b + S(2)*c*(S(1)/tan(d + e*x))**n)**(S(2)*p), x), x) rule3822 = ReplacementRule(pattern3822, replacement3822) pattern3823 = Pattern(Integral((a_ + WC('b', S(1))*tan(x_*WC('e', S(1)) + WC('d', S(0)))**WC('n', S(1)) + WC('c', S(1))*tan(x_*WC('e', S(1)) + WC('d', S(0)))**WC('n2', S(1)))**p_, x_), cons2, cons3, cons7, cons27, cons48, cons4, cons46, cons45, cons147) def replacement3823(p, b, n2, d, c, n, a, x, e): rubi.append(3823) return Dist((b + S(2)*c*tan(d + e*x)**n)**(-S(2)*p)*(a + b*tan(d + e*x)**n + c*tan(d + e*x)**(S(2)*n))**p, Int((b + S(2)*c*tan(d + e*x)**n)**(S(2)*p), x), x) rule3823 = ReplacementRule(pattern3823, replacement3823) pattern3824 = Pattern(Integral((a_ + (S(1)/tan(x_*WC('e', S(1)) + WC('d', S(0))))**WC('n', S(1))*WC('b', S(1)) + (S(1)/tan(x_*WC('e', S(1)) + WC('d', S(0))))**WC('n2', S(1))*WC('c', S(1)))**p_, x_), cons2, cons3, cons7, cons27, cons48, cons4, cons46, cons45, cons147) def replacement3824(p, b, n2, d, c, n, a, x, e): rubi.append(3824) return Dist((b + S(2)*c*(S(1)/tan(d + e*x))**n)**(-S(2)*p)*(a + b*(S(1)/tan(d + e*x))**n + c*(S(1)/tan(d + e*x))**(S(2)*n))**p, Int((b + S(2)*c*(S(1)/tan(d + e*x))**n)**(S(2)*p), x), x) rule3824 = ReplacementRule(pattern3824, replacement3824) def With3825(b, n2, d, a, n, c, x, e): q = Rt(-S(4)*a*c + b**S(2), S(2)) rubi.append(3825) return Dist(S(2)*c/q, Int(S(1)/(b + S(2)*c*tan(d + e*x)**n - q), x), x) - Dist(S(2)*c/q, Int(S(1)/(b + S(2)*c*tan(d + e*x)**n + q), x), x) pattern3825 = Pattern(Integral(S(1)/(WC('a', S(0)) + WC('b', S(1))*tan(x_*WC('e', S(1)) + WC('d', S(0)))**WC('n', S(1)) + WC('c', S(1))*tan(x_*WC('e', S(1)) + WC('d', S(0)))**WC('n2', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons4, cons46, cons226) rule3825 = ReplacementRule(pattern3825, With3825) def With3826(b, n2, d, a, n, c, x, e): q = Rt(-S(4)*a*c + b**S(2), S(2)) rubi.append(3826) return Dist(S(2)*c/q, Int(S(1)/(b + S(2)*c*(S(1)/tan(d + e*x))**n - q), x), x) - Dist(S(2)*c/q, Int(S(1)/(b + S(2)*c*(S(1)/tan(d + e*x))**n + q), x), x) pattern3826 = Pattern(Integral(S(1)/((S(1)/tan(x_*WC('e', S(1)) + WC('d', S(0))))**WC('n', S(1))*WC('b', S(1)) + (S(1)/tan(x_*WC('e', S(1)) + WC('d', S(0))))**WC('n2', S(1))*WC('c', S(1)) + WC('a', S(0))), x_), cons2, cons3, cons7, cons27, cons48, cons4, cons46, cons226) rule3826 = ReplacementRule(pattern3826, With3826) pattern3827 = Pattern(Integral(((WC('f', S(1))*tan(x_*WC('e', S(1)) + WC('d', S(0))))**WC('n', S(1))*WC('b', S(1)) + (WC('f', S(1))*tan(x_*WC('e', S(1)) + WC('d', S(0))))**WC('n2', S(1))*WC('c', S(1)) + WC('a', S(0)))**p_*sin(x_*WC('e', S(1)) + WC('d', S(0)))**m_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons4, cons5, cons46, cons1515) def replacement3827(p, m, f, b, n2, d, a, n, c, x, e): rubi.append(3827) return Dist(f/e, Subst(Int(x**m*(f**S(2) + x**S(2))**(-m/S(2) + S(-1))*(a + b*x**n + c*x**(S(2)*n))**p, x), x, f*tan(d + e*x)), x) rule3827 = ReplacementRule(pattern3827, replacement3827) pattern3828 = Pattern(Integral(((WC('f', S(1))/tan(x_*WC('e', S(1)) + WC('d', S(0))))**WC('n', S(1))*WC('b', S(1)) + (WC('f', S(1))/tan(x_*WC('e', S(1)) + WC('d', S(0))))**WC('n2', S(1))*WC('c', S(1)) + WC('a', S(0)))**p_*cos(x_*WC('e', S(1)) + WC('d', S(0)))**m_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons4, cons5, cons46, cons1515) def replacement3828(p, m, f, b, n2, d, a, n, c, x, e): rubi.append(3828) return -Dist(f/e, Subst(Int(x**m*(f**S(2) + x**S(2))**(-m/S(2) + S(-1))*(a + b*x**n + c*x**(S(2)*n))**p, x), x, f/tan(d + e*x)), x) rule3828 = ReplacementRule(pattern3828, replacement3828) def With3829(p, m, b, n2, d, a, n, c, x, e): g = FreeFactors(cos(d + e*x), x) rubi.append(3829) return -Dist(g/e, Subst(Int((g*x)**(-S(2)*n*p)*(-g**S(2)*x**S(2) + S(1))**(m/S(2) + S(-1)/2)*ExpandToSum(a*(g*x)**(S(2)*n) + b*(g*x)**n*(-g**S(2)*x**S(2) + S(1))**(n/S(2)) + c*(-g**S(2)*x**S(2) + S(1))**n, x)**p, x), x, cos(d + e*x)/g), x) pattern3829 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*tan(x_*WC('e', S(1)) + WC('d', S(0)))**WC('n', S(1)) + WC('c', S(1))*tan(x_*WC('e', S(1)) + WC('d', S(0)))**WC('n2', S(1)))**WC('p', S(1))*sin(x_*WC('e', S(1)) + WC('d', S(0)))**WC('m', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons46, cons1481, cons1479, cons38) rule3829 = ReplacementRule(pattern3829, With3829) def With3830(p, m, b, n2, d, a, n, c, x, e): g = FreeFactors(sin(d + e*x), x) rubi.append(3830) return Dist(g/e, Subst(Int((g*x)**(-S(2)*n*p)*(-g**S(2)*x**S(2) + S(1))**(m/S(2) + S(-1)/2)*ExpandToSum(a*(g*x)**(S(2)*n) + b*(g*x)**n*(-g**S(2)*x**S(2) + S(1))**(n/S(2)) + c*(-g**S(2)*x**S(2) + S(1))**n, x)**p, x), x, sin(d + e*x)/g), x) pattern3830 = Pattern(Integral(((S(1)/tan(x_*WC('e', S(1)) + WC('d', S(0))))**WC('n', S(1))*WC('b', S(1)) + WC('a', S(0)) + WC('c', S(1))*tan(x_*WC('e', S(1)) + WC('d', S(0)))**WC('n2', S(1)))**WC('p', S(1))*cos(x_*WC('e', S(1)) + WC('d', S(0)))**WC('m', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons46, cons1481, cons1479, cons38) rule3830 = ReplacementRule(pattern3830, With3830) pattern3831 = Pattern(Integral(((WC('f', S(1))*tan(x_*WC('e', S(1)) + WC('d', S(0))))**WC('n', S(1))*WC('b', S(1)) + (WC('f', S(1))*tan(x_*WC('e', S(1)) + WC('d', S(0))))**WC('n2', S(1))*WC('c', S(1)) + WC('a', S(0)))**WC('p', S(1))*cos(x_*WC('e', S(1)) + WC('d', S(0)))**m_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons4, cons5, cons46, cons1480) def replacement3831(p, m, f, b, n2, d, a, n, c, x, e): rubi.append(3831) return Dist(f**(m + S(1))/e, Subst(Int((f**S(2) + x**S(2))**(-m/S(2) + S(-1))*(a + b*x**n + c*x**(S(2)*n))**p, x), x, f*tan(d + e*x)), x) rule3831 = ReplacementRule(pattern3831, replacement3831) pattern3832 = Pattern(Integral(((WC('f', S(1))/tan(x_*WC('e', S(1)) + WC('d', S(0))))**WC('n', S(1))*WC('b', S(1)) + (WC('f', S(1))/tan(x_*WC('e', S(1)) + WC('d', S(0))))**WC('n2', S(1))*WC('c', S(1)) + WC('a', S(0)))**WC('p', S(1))*sin(x_*WC('e', S(1)) + WC('d', S(0)))**m_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons4, cons5, cons46, cons1480) def replacement3832(p, m, f, b, n2, d, a, n, c, x, e): rubi.append(3832) return -Dist(f**(m + S(1))/e, Subst(Int((f**S(2) + x**S(2))**(-m/S(2) + S(-1))*(a + b*x**n + c*x**(S(2)*n))**p, x), x, f/tan(d + e*x)), x) rule3832 = ReplacementRule(pattern3832, replacement3832) def With3833(p, m, b, n2, d, a, n, c, x, e): g = FreeFactors(sin(d + e*x), x) rubi.append(3833) return Dist(g/e, Subst(Int((-g**S(2)*x**S(2) + S(1))**(m/S(2) - n*p + S(-1)/2)*ExpandToSum(a*(-x**S(2) + S(1))**n + b*x**n*(-x**S(2) + S(1))**(n/S(2)) + c*x**(S(2)*n), x)**p, x), x, sin(d + e*x)/g), x) pattern3833 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*tan(x_*WC('e', S(1)) + WC('d', S(0)))**WC('n', S(1)) + WC('c', S(1))*tan(x_*WC('e', S(1)) + WC('d', S(0)))**WC('n2', S(1)))**WC('p', S(1))*cos(x_*WC('e', S(1)) + WC('d', S(0)))**m_, x_), cons2, cons3, cons7, cons27, cons48, cons46, cons1481, cons1479, cons38) rule3833 = ReplacementRule(pattern3833, With3833) def With3834(p, m, b, n2, d, a, n, c, x, e): g = FreeFactors(cos(d + e*x), x) rubi.append(3834) return -Dist(g/e, Subst(Int((-g**S(2)*x**S(2) + S(1))**(m/S(2) - n*p + S(-1)/2)*ExpandToSum(a*(-x**S(2) + S(1))**n + b*x**n*(-x**S(2) + S(1))**(n/S(2)) + c*x**(S(2)*n), x)**p, x), x, cos(d + e*x)/g), x) pattern3834 = Pattern(Integral(((S(1)/tan(x_*WC('e', S(1)) + WC('d', S(0))))**WC('n', S(1))*WC('b', S(1)) + (S(1)/tan(x_*WC('e', S(1)) + WC('d', S(0))))**WC('n2', S(1))*WC('c', S(1)) + WC('a', S(0)))**WC('p', S(1))*sin(x_*WC('e', S(1)) + WC('d', S(0)))**m_, x_), cons2, cons3, cons7, cons27, cons48, cons46, cons1481, cons1479, cons38) rule3834 = ReplacementRule(pattern3834, With3834) pattern3835 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*tan(x_*WC('e', S(1)) + WC('d', S(0)))**WC('n', S(1)) + WC('c', S(1))*tan(x_*WC('e', S(1)) + WC('d', S(0)))**WC('n2', S(1)))**p_*tan(x_*WC('e', S(1)) + WC('d', S(0)))**WC('m', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons21, cons4, cons46, cons45, cons38) def replacement3835(p, m, b, n2, d, a, n, c, x, e): rubi.append(3835) return Dist(S(4)**(-p)*c**(-p), Int((b + S(2)*c*tan(d + e*x)**n)**(S(2)*p)*tan(d + e*x)**m, x), x) rule3835 = ReplacementRule(pattern3835, replacement3835) pattern3836 = Pattern(Integral(((S(1)/tan(x_*WC('e', S(1)) + WC('d', S(0))))**WC('n', S(1))*WC('b', S(1)) + (S(1)/tan(x_*WC('e', S(1)) + WC('d', S(0))))**WC('n2', S(1))*WC('c', S(1)) + WC('a', S(0)))**p_*(S(1)/tan(x_*WC('e', S(1)) + WC('d', S(0))))**WC('m', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons21, cons4, cons46, cons45, cons38) def replacement3836(p, m, b, n2, d, a, n, c, x, e): rubi.append(3836) return Dist(S(4)**(-p)*c**(-p), Int((b + S(2)*c*(S(1)/tan(d + e*x))**n)**(S(2)*p)*(S(1)/tan(d + e*x))**m, x), x) rule3836 = ReplacementRule(pattern3836, replacement3836) pattern3837 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*tan(x_*WC('e', S(1)) + WC('d', S(0)))**WC('n', S(1)) + WC('c', S(1))*tan(x_*WC('e', S(1)) + WC('d', S(0)))**WC('n2', S(1)))**p_*tan(x_*WC('e', S(1)) + WC('d', S(0)))**WC('m', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons21, cons4, cons5, cons46, cons45, cons147) def replacement3837(p, m, b, n2, d, a, n, c, x, e): rubi.append(3837) return Dist((b + S(2)*c*tan(d + e*x)**n)**(-S(2)*p)*(a + b*tan(d + e*x)**n + c*tan(d + e*x)**(S(2)*n))**p, Int((b + S(2)*c*tan(d + e*x)**n)**(S(2)*p)*tan(d + e*x)**m, x), x) rule3837 = ReplacementRule(pattern3837, replacement3837) pattern3838 = Pattern(Integral(((S(1)/tan(x_*WC('e', S(1)) + WC('d', S(0))))**WC('n', S(1))*WC('b', S(1)) + (S(1)/tan(x_*WC('e', S(1)) + WC('d', S(0))))**WC('n2', S(1))*WC('c', S(1)) + WC('a', S(0)))**p_*(S(1)/tan(x_*WC('e', S(1)) + WC('d', S(0))))**WC('m', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons21, cons4, cons5, cons46, cons45, cons147) def replacement3838(p, m, b, n2, d, a, n, c, x, e): rubi.append(3838) return Dist((b + S(2)*c*(S(1)/tan(d + e*x))**n)**(-S(2)*p)*(a + b*(S(1)/tan(d + e*x))**n + c*(S(1)/tan(d + e*x))**(S(2)*n))**p, Int((b + S(2)*c*(S(1)/tan(d + e*x))**n)**(S(2)*p)*(S(1)/tan(d + e*x))**m, x), x) rule3838 = ReplacementRule(pattern3838, replacement3838) pattern3839 = Pattern(Integral(((WC('f', S(1))*tan(x_*WC('e', S(1)) + WC('d', S(0))))**WC('n', S(1))*WC('b', S(1)) + (WC('f', S(1))*tan(x_*WC('e', S(1)) + WC('d', S(0))))**WC('n2', S(1))*WC('c', S(1)) + WC('a', S(0)))**p_*tan(x_*WC('e', S(1)) + WC('d', S(0)))**WC('m', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons4, cons5, cons46, cons226) def replacement3839(p, m, f, b, n2, d, a, n, c, x, e): rubi.append(3839) return Dist(f/e, Subst(Int((x/f)**m*(a + b*x**n + c*x**(S(2)*n))**p/(f**S(2) + x**S(2)), x), x, f*tan(d + e*x)), x) rule3839 = ReplacementRule(pattern3839, replacement3839) pattern3840 = Pattern(Integral(((WC('f', S(1))/tan(x_*WC('e', S(1)) + WC('d', S(0))))**WC('n', S(1))*WC('b', S(1)) + (WC('f', S(1))/tan(x_*WC('e', S(1)) + WC('d', S(0))))**WC('n2', S(1))*WC('c', S(1)) + WC('a', S(0)))**p_*(S(1)/tan(x_*WC('e', S(1)) + WC('d', S(0))))**WC('m', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons4, cons5, cons46, cons226) def replacement3840(p, m, f, b, n2, d, a, n, c, x, e): rubi.append(3840) return -Dist(f/e, Subst(Int((x/f)**m*(a + b*x**n + c*x**(S(2)*n))**p/(f**S(2) + x**S(2)), x), x, f/tan(d + e*x)), x) rule3840 = ReplacementRule(pattern3840, replacement3840) pattern3841 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*tan(x_*WC('e', S(1)) + WC('d', S(0)))**WC('n', S(1)) + WC('c', S(1))*tan(x_*WC('e', S(1)) + WC('d', S(0)))**WC('n2', S(1)))**WC('p', S(1))*(S(1)/tan(x_*WC('e', S(1)) + WC('d', S(0))))**WC('m', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons21, cons4, cons46, cons45, cons38) def replacement3841(p, m, b, n2, d, a, n, c, x, e): rubi.append(3841) return Dist(S(4)**(-p)*c**(-p), Int((b + S(2)*c*tan(d + e*x)**n)**(S(2)*p)*(S(1)/tan(d + e*x))**m, x), x) rule3841 = ReplacementRule(pattern3841, replacement3841) pattern3842 = Pattern(Integral(((S(1)/tan(x_*WC('e', S(1)) + WC('d', S(0))))**WC('n', S(1))*WC('b', S(1)) + (S(1)/tan(x_*WC('e', S(1)) + WC('d', S(0))))**WC('n2', S(1))*WC('c', S(1)) + WC('a', S(0)))**WC('p', S(1))*tan(x_*WC('e', S(1)) + WC('d', S(0)))**WC('m', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons21, cons4, cons46, cons45, cons38) def replacement3842(p, m, b, n2, d, a, n, c, x, e): rubi.append(3842) return Dist(S(4)**(-p)*c**(-p), Int((b + S(2)*c*(S(1)/tan(d + e*x))**n)**(S(2)*p)*tan(d + e*x)**m, x), x) rule3842 = ReplacementRule(pattern3842, replacement3842) pattern3843 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*tan(x_*WC('e', S(1)) + WC('d', S(0)))**WC('n', S(1)) + WC('c', S(1))*tan(x_*WC('e', S(1)) + WC('d', S(0)))**WC('n2', S(1)))**p_*(S(1)/tan(x_*WC('e', S(1)) + WC('d', S(0))))**WC('m', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons21, cons4, cons5, cons46, cons45, cons147) def replacement3843(p, m, b, n2, d, a, n, c, x, e): rubi.append(3843) return Dist((b + S(2)*c*tan(d + e*x)**n)**(-S(2)*p)*(a + b*tan(d + e*x)**n + c*tan(d + e*x)**(S(2)*n))**p, Int((b + S(2)*c*tan(d + e*x)**n)**(S(2)*p)*(S(1)/tan(d + e*x))**m, x), x) rule3843 = ReplacementRule(pattern3843, replacement3843) pattern3844 = Pattern(Integral(((S(1)/tan(x_*WC('e', S(1)) + WC('d', S(0))))**WC('n', S(1))*WC('b', S(1)) + (S(1)/tan(x_*WC('e', S(1)) + WC('d', S(0))))**WC('n2', S(1))*WC('c', S(1)) + WC('a', S(0)))**p_*tan(x_*WC('e', S(1)) + WC('d', S(0)))**WC('m', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons21, cons4, cons5, cons46, cons45, cons147) def replacement3844(p, m, b, n2, d, a, n, c, x, e): rubi.append(3844) return Dist((b + S(2)*c*(S(1)/tan(d + e*x))**n)**(-S(2)*p)*(a + b*(S(1)/tan(d + e*x))**n + c*(S(1)/tan(d + e*x))**(S(2)*n))**p, Int((b + S(2)*c*(S(1)/tan(d + e*x))**n)**(S(2)*p)*tan(d + e*x)**m, x), x) rule3844 = ReplacementRule(pattern3844, replacement3844) def With3845(p, m, b, n2, d, a, c, n, x, e): g = FreeFactors(S(1)/tan(d + e*x), x) rubi.append(3845) return Dist(g/e, Subst(Int((g*x)**(m - S(2)*n*p)*(a*(g*x)**(S(2)*n) + b*(g*x)**n + c)**p/(g**S(2)*x**S(2) + S(1)), x), x, S(1)/(g*tan(d + e*x))), x) pattern3845 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*tan(x_*WC('e', S(1)) + WC('d', S(0)))**n_ + WC('c', S(1))*tan(x_*WC('e', S(1)) + WC('d', S(0)))**n2_)**WC('p', S(1))*(S(1)/tan(x_*WC('e', S(1)) + WC('d', S(0))))**WC('m', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons21, cons5, cons46, cons226, cons1479) rule3845 = ReplacementRule(pattern3845, With3845) def With3846(p, m, b, n2, d, c, a, n, x, e): g = FreeFactors(tan(d + e*x), x) rubi.append(3846) return -Dist(g/e, Subst(Int((g*x)**(m - S(2)*n*p)*(a*(g*x)**(S(2)*n) + b*(g*x)**n + c)**p/(g**S(2)*x**S(2) + S(1)), x), x, tan(d + e*x)/g), x) pattern3846 = Pattern(Integral(((S(1)/tan(x_*WC('e', S(1)) + WC('d', S(0))))**n2_*WC('c', S(1)) + (S(1)/tan(x_*WC('e', S(1)) + WC('d', S(0))))**n_*WC('b', S(1)) + WC('a', S(0)))**WC('p', S(1))*tan(x_*WC('e', S(1)) + WC('d', S(0)))**WC('m', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons21, cons5, cons46, cons226, cons1479) rule3846 = ReplacementRule(pattern3846, With3846) pattern3847 = Pattern(Integral((A_ + WC('B', S(1))*tan(x_*WC('e', S(1)) + WC('d', S(0))))*(a_ + WC('b', S(1))*tan(x_*WC('e', S(1)) + WC('d', S(0))) + WC('c', S(1))*tan(x_*WC('e', S(1)) + WC('d', S(0)))**S(2))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons34, cons35, cons45, cons85) def replacement3847(B, b, d, c, a, n, A, x, e): rubi.append(3847) return Dist(S(4)**(-n)*c**(-n), Int((A + B*tan(d + e*x))*(b + S(2)*c*tan(d + e*x))**(S(2)*n), x), x) rule3847 = ReplacementRule(pattern3847, replacement3847) pattern3848 = Pattern(Integral((A_ + WC('B', S(1))/tan(x_*WC('e', S(1)) + WC('d', S(0))))*(a_ + WC('b', S(1))/tan(x_*WC('e', S(1)) + WC('d', S(0))) + WC('c', S(1))/tan(x_*WC('e', S(1)) + WC('d', S(0)))**S(2))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons34, cons35, cons45, cons85) def replacement3848(B, b, d, c, a, n, A, x, e): rubi.append(3848) return Dist(S(4)**(-n)*c**(-n), Int((A + B/tan(d + e*x))*(b + S(2)*c/tan(d + e*x))**(S(2)*n), x), x) rule3848 = ReplacementRule(pattern3848, replacement3848) pattern3849 = Pattern(Integral((A_ + WC('B', S(1))*tan(x_*WC('e', S(1)) + WC('d', S(0))))*(a_ + WC('b', S(1))*tan(x_*WC('e', S(1)) + WC('d', S(0))) + WC('c', S(1))*tan(x_*WC('e', S(1)) + WC('d', S(0)))**S(2))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons34, cons35, cons45, cons23) def replacement3849(B, b, d, c, a, n, A, x, e): rubi.append(3849) return Dist((b + S(2)*c*tan(d + e*x))**(-S(2)*n)*(a + b*tan(d + e*x) + c*tan(d + e*x)**S(2))**n, Int((A + B*tan(d + e*x))*(b + S(2)*c*tan(d + e*x))**(S(2)*n), x), x) rule3849 = ReplacementRule(pattern3849, replacement3849) pattern3850 = Pattern(Integral((A_ + WC('B', S(1))/tan(x_*WC('e', S(1)) + WC('d', S(0))))*(a_ + WC('b', S(1))/tan(x_*WC('e', S(1)) + WC('d', S(0))) + WC('c', S(1))/tan(x_*WC('e', S(1)) + WC('d', S(0)))**S(2))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons34, cons35, cons45, cons23) def replacement3850(B, b, d, c, a, n, A, x, e): rubi.append(3850) return Dist((b + S(2)*c/tan(d + e*x))**(-S(2)*n)*(a + b/tan(d + e*x) + c/tan(d + e*x)**S(2))**n, Int((A + B/tan(d + e*x))*(b + S(2)*c/tan(d + e*x))**(S(2)*n), x), x) rule3850 = ReplacementRule(pattern3850, replacement3850) def With3851(B, b, d, a, c, A, x, e): q = Rt(-S(4)*a*c + b**S(2), S(2)) rubi.append(3851) return Dist(B - (-S(2)*A*c + B*b)/q, Int(S(1)/Simp(b + S(2)*c*tan(d + e*x) - q, x), x), x) + Dist(B + (-S(2)*A*c + B*b)/q, Int(S(1)/Simp(b + S(2)*c*tan(d + e*x) + q, x), x), x) pattern3851 = Pattern(Integral((A_ + WC('B', S(1))*tan(x_*WC('e', S(1)) + WC('d', S(0))))/(WC('a', S(0)) + WC('b', S(1))*tan(x_*WC('e', S(1)) + WC('d', S(0))) + WC('c', S(1))*tan(x_*WC('e', S(1)) + WC('d', S(0)))**S(2)), x_), cons2, cons3, cons7, cons27, cons48, cons34, cons35, cons226) rule3851 = ReplacementRule(pattern3851, With3851) def With3852(B, b, d, c, a, A, x, e): q = Rt(-S(4)*a*c + b**S(2), S(2)) rubi.append(3852) return Dist(B - (-S(2)*A*c + B*b)/q, Int(S(1)/Simp(b + S(2)*c/tan(d + e*x) - q, x), x), x) + Dist(B + (-S(2)*A*c + B*b)/q, Int(S(1)/Simp(b + S(2)*c/tan(d + e*x) + q, x), x), x) pattern3852 = Pattern(Integral((A_ + WC('B', S(1))/tan(x_*WC('e', S(1)) + WC('d', S(0))))/(WC('a', S(0)) + WC('b', S(1))/tan(x_*WC('e', S(1)) + WC('d', S(0))) + WC('c', S(1))/tan(x_*WC('e', S(1)) + WC('d', S(0)))**S(2)), x_), cons2, cons3, cons7, cons27, cons48, cons34, cons35, cons226) rule3852 = ReplacementRule(pattern3852, With3852) pattern3853 = Pattern(Integral((A_ + WC('B', S(1))*tan(x_*WC('e', S(1)) + WC('d', S(0))))*(WC('a', S(0)) + WC('b', S(1))*tan(x_*WC('e', S(1)) + WC('d', S(0))) + WC('c', S(1))*tan(x_*WC('e', S(1)) + WC('d', S(0)))**S(2))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons34, cons35, cons226, cons85) def replacement3853(B, b, d, a, c, n, A, x, e): rubi.append(3853) return Int(ExpandTrig((A + B*tan(d + e*x))*(a + b*tan(d + e*x) + c*tan(d + e*x)**S(2))**n, x), x) rule3853 = ReplacementRule(pattern3853, replacement3853) pattern3854 = Pattern(Integral((A_ + WC('B', S(1))/tan(x_*WC('e', S(1)) + WC('d', S(0))))*(WC('a', S(0)) + WC('b', S(1))/tan(x_*WC('e', S(1)) + WC('d', S(0))) + WC('c', S(1))/tan(x_*WC('e', S(1)) + WC('d', S(0)))**S(2))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons34, cons35, cons226, cons85) def replacement3854(B, b, d, c, a, n, A, x, e): rubi.append(3854) return Int(ExpandTrig((A + B/tan(d + e*x))*(a + b/tan(d + e*x) + c/tan(d + e*x)**S(2))**n, x), x) rule3854 = ReplacementRule(pattern3854, replacement3854) pattern3855 = Pattern(Integral((x_*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))), x_), cons7, cons27, cons48, cons125, cons62) def replacement3855(m, f, d, c, x, e): rubi.append(3855) return -Dist(S(2)*I, Int((c + d*x)**m*exp(S(2)*I*(e + f*x))/(exp(S(2)*I*(e + f*x)) + S(1)), x), x) + Simp(I*(c + d*x)**(m + S(1))/(d*(m + S(1))), x) rule3855 = ReplacementRule(pattern3855, replacement3855) pattern3856 = Pattern(Integral((x_*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))), x_), cons7, cons27, cons48, cons125, cons62) def replacement3856(m, f, d, c, x, e): rubi.append(3856) return -Dist(S(2)*I, Int((c + d*x)**m*exp(S(2)*I*(e + f*x))/(-exp(S(2)*I*(e + f*x)) + S(1)), x), x) - Simp(I*(c + d*x)**(m + S(1))/(d*(m + S(1))), x) rule3856 = ReplacementRule(pattern3856, replacement3856) pattern3857 = Pattern(Integral((WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(x_*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1)), x_), cons3, cons7, cons27, cons48, cons125, cons93, cons165, cons168) def replacement3857(m, f, b, d, c, n, x, e): rubi.append(3857) return -Dist(b**S(2), Int((b*tan(e + f*x))**(n + S(-2))*(c + d*x)**m, x), x) - Dist(b*d*m/(f*(n + S(-1))), Int((b*tan(e + f*x))**(n + S(-1))*(c + d*x)**(m + S(-1)), x), x) + Simp(b*(b*tan(e + f*x))**(n + S(-1))*(c + d*x)**m/(f*(n + S(-1))), x) rule3857 = ReplacementRule(pattern3857, replacement3857) pattern3858 = Pattern(Integral((WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(x_*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1)), x_), cons3, cons7, cons27, cons48, cons125, cons93, cons165, cons168) def replacement3858(m, f, b, d, c, n, x, e): rubi.append(3858) return -Dist(b**S(2), Int((b/tan(e + f*x))**(n + S(-2))*(c + d*x)**m, x), x) + Dist(b*d*m/(f*(n + S(-1))), Int((b/tan(e + f*x))**(n + S(-1))*(c + d*x)**(m + S(-1)), x), x) - Simp(b*(b/tan(e + f*x))**(n + S(-1))*(c + d*x)**m/(f*(n + S(-1))), x) rule3858 = ReplacementRule(pattern3858, replacement3858) pattern3859 = Pattern(Integral((WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(x_*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1)), x_), cons3, cons7, cons27, cons48, cons125, cons93, cons89, cons168) def replacement3859(m, f, b, d, c, n, x, e): rubi.append(3859) return -Dist(b**(S(-2)), Int((b*tan(e + f*x))**(n + S(2))*(c + d*x)**m, x), x) - Dist(d*m/(b*f*(n + S(1))), Int((b*tan(e + f*x))**(n + S(1))*(c + d*x)**(m + S(-1)), x), x) + Simp((b*tan(e + f*x))**(n + S(1))*(c + d*x)**m/(b*f*(n + S(1))), x) rule3859 = ReplacementRule(pattern3859, replacement3859) pattern3860 = Pattern(Integral((WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(x_*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1)), x_), cons3, cons7, cons27, cons48, cons125, cons93, cons89, cons168) def replacement3860(m, f, b, d, c, n, x, e): rubi.append(3860) return -Dist(b**(S(-2)), Int((b/tan(e + f*x))**(n + S(2))*(c + d*x)**m, x), x) + Dist(d*m/(b*f*(n + S(1))), Int((b/tan(e + f*x))**(n + S(1))*(c + d*x)**(m + S(-1)), x), x) - Simp((b/tan(e + f*x))**(n + S(1))*(c + d*x)**m/(b*f*(n + S(1))), x) rule3860 = ReplacementRule(pattern3860, replacement3860) pattern3861 = Pattern(Integral((a_ + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1))*(x_*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons528) def replacement3861(m, f, b, d, c, n, a, x, e): rubi.append(3861) return Int(ExpandIntegrand((c + d*x)**m, (a + b*tan(e + f*x))**n, x), x) rule3861 = ReplacementRule(pattern3861, replacement3861) pattern3862 = Pattern(Integral((a_ + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1))*(x_*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons528) def replacement3862(m, f, b, d, c, n, a, x, e): rubi.append(3862) return Int(ExpandIntegrand((c + d*x)**m, (a + b/tan(e + f*x))**n, x), x) rule3862 = ReplacementRule(pattern3862, replacement3862) pattern3863 = Pattern(Integral((x_*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1))/(a_ + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons1439, cons31, cons168) def replacement3863(m, f, b, d, c, a, x, e): rubi.append(3863) return Dist(a*d*m/(S(2)*b*f), Int((c + d*x)**(m + S(-1))/(a + b*tan(e + f*x)), x), x) + Simp((c + d*x)**(m + S(1))/(S(2)*a*d*(m + S(1))), x) - Simp(a*(c + d*x)**m/(S(2)*b*f*(a + b*tan(e + f*x))), x) rule3863 = ReplacementRule(pattern3863, replacement3863) pattern3864 = Pattern(Integral((x_*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1))/(a_ + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons1439, cons31, cons168) def replacement3864(m, f, b, d, c, a, x, e): rubi.append(3864) return -Dist(a*d*m/(S(2)*b*f), Int((c + d*x)**(m + S(-1))/(a + b/tan(e + f*x)), x), x) + Simp((c + d*x)**(m + S(1))/(S(2)*a*d*(m + S(1))), x) + Simp(a*(c + d*x)**m/(S(2)*b*f*(a + b/tan(e + f*x))), x) rule3864 = ReplacementRule(pattern3864, replacement3864) pattern3865 = Pattern(Integral(S(1)/((a_ + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))*(x_*WC('d', S(1)) + WC('c', S(0)))**S(2)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons1439) def replacement3865(f, b, d, c, a, x, e): rubi.append(3865) return -Dist(f/(a*d), Int(sin(S(2)*e + S(2)*f*x)/(c + d*x), x), x) + Dist(f/(b*d), Int(cos(S(2)*e + S(2)*f*x)/(c + d*x), x), x) - Simp(S(1)/(d*(a + b*tan(e + f*x))*(c + d*x)), x) rule3865 = ReplacementRule(pattern3865, replacement3865) pattern3866 = Pattern(Integral(S(1)/((a_ + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))*(x_*WC('d', S(1)) + WC('c', S(0)))**S(2)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons1439) def replacement3866(f, b, d, c, a, x, e): rubi.append(3866) return Dist(f/(a*d), Int(sin(S(2)*e + S(2)*f*x)/(c + d*x), x), x) + Dist(f/(b*d), Int(cos(S(2)*e + S(2)*f*x)/(c + d*x), x), x) - Simp(S(1)/(d*(a + b/tan(e + f*x))*(c + d*x)), x) rule3866 = ReplacementRule(pattern3866, replacement3866) pattern3867 = Pattern(Integral((x_*WC('d', S(1)) + WC('c', S(0)))**m_/(a_ + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons1439, cons31, cons94, cons1510) def replacement3867(m, f, b, d, c, a, x, e): rubi.append(3867) return Dist(S(2)*b*f/(a*d*(m + S(1))), Int((c + d*x)**(m + S(1))/(a + b*tan(e + f*x)), x), x) + Simp((c + d*x)**(m + S(1))/(d*(a + b*tan(e + f*x))*(m + S(1))), x) + Simp(f*(c + d*x)**(m + S(2))/(b*d**S(2)*(m + S(1))*(m + S(2))), x) rule3867 = ReplacementRule(pattern3867, replacement3867) pattern3868 = Pattern(Integral((x_*WC('d', S(1)) + WC('c', S(0)))**m_/(a_ + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons1439, cons31, cons94, cons1510) def replacement3868(m, f, b, d, c, a, x, e): rubi.append(3868) return -Dist(S(2)*b*f/(a*d*(m + S(1))), Int((c + d*x)**(m + S(1))/(a + b/tan(e + f*x)), x), x) + Simp((c + d*x)**(m + S(1))/(d*(a + b/tan(e + f*x))*(m + S(1))), x) - Simp(f*(c + d*x)**(m + S(2))/(b*d**S(2)*(m + S(1))*(m + S(2))), x) rule3868 = ReplacementRule(pattern3868, replacement3868) pattern3869 = Pattern(Integral(S(1)/((a_ + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))*(x_*WC('d', S(1)) + WC('c', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons1439) def replacement3869(f, b, d, c, a, x, e): rubi.append(3869) return Dist(S(1)/(S(2)*a), Int(cos(S(2)*e + S(2)*f*x)/(c + d*x), x), x) + Dist(S(1)/(S(2)*b), Int(sin(S(2)*e + S(2)*f*x)/(c + d*x), x), x) + Simp(log(c + d*x)/(S(2)*a*d), x) rule3869 = ReplacementRule(pattern3869, replacement3869) pattern3870 = Pattern(Integral(S(1)/((a_ + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))*(x_*WC('d', S(1)) + WC('c', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons1439) def replacement3870(f, b, d, c, a, x, e): rubi.append(3870) return -Dist(S(1)/(S(2)*a), Int(cos(S(2)*e + S(2)*f*x)/(c + d*x), x), x) + Dist(S(1)/(S(2)*b), Int(sin(S(2)*e + S(2)*f*x)/(c + d*x), x), x) + Simp(log(c + d*x)/(S(2)*a*d), x) rule3870 = ReplacementRule(pattern3870, replacement3870) pattern3871 = Pattern(Integral((x_*WC('d', S(1)) + WC('c', S(0)))**m_/(a_ + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons1439, cons18) def replacement3871(m, f, b, d, c, a, x, e): rubi.append(3871) return Dist(S(1)/(S(2)*a), Int((c + d*x)**m*exp(S(2)*a*(e + f*x)/b), x), x) + Simp((c + d*x)**(m + S(1))/(S(2)*a*d*(m + S(1))), x) rule3871 = ReplacementRule(pattern3871, replacement3871) pattern3872 = Pattern(Integral((x_*WC('d', S(1)) + WC('c', S(0)))**m_/(a_ + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons1439, cons18) def replacement3872(m, f, b, d, c, a, x, e): rubi.append(3872) return -Dist(S(1)/(S(2)*a), Int((c + d*x)**m*exp(-S(2)*a*(e + f*x)/b), x), x) + Simp((c + d*x)**(m + S(1))/(S(2)*a*d*(m + S(1))), x) rule3872 = ReplacementRule(pattern3872, replacement3872) pattern3873 = Pattern(Integral((a_ + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(x_*WC('d', S(1)) + WC('c', S(0)))**m_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons1439, cons1571) def replacement3873(m, f, b, d, c, a, n, x, e): rubi.append(3873) return Int(ExpandIntegrand((c + d*x)**m, (sin(S(2)*e + S(2)*f*x)/(S(2)*b) + cos(S(2)*e + S(2)*f*x)/(S(2)*a) + S(1)/(S(2)*a))**(-n), x), x) rule3873 = ReplacementRule(pattern3873, replacement3873) pattern3874 = Pattern(Integral((a_ + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(x_*WC('d', S(1)) + WC('c', S(0)))**m_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons1439, cons1571) def replacement3874(m, f, b, d, c, a, n, x, e): rubi.append(3874) return Int(ExpandIntegrand((c + d*x)**m, (sin(S(2)*e + S(2)*f*x)/(S(2)*b) - cos(S(2)*e + S(2)*f*x)/(S(2)*a) + S(1)/(S(2)*a))**(-n), x), x) rule3874 = ReplacementRule(pattern3874, replacement3874) pattern3875 = Pattern(Integral((a_ + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(x_*WC('d', S(1)) + WC('c', S(0)))**m_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons1439, cons196) def replacement3875(m, f, b, d, c, a, n, x, e): rubi.append(3875) return Int(ExpandIntegrand((c + d*x)**m, (exp(S(2)*a*(e + f*x)/b)/(S(2)*a) + S(1)/(S(2)*a))**(-n), x), x) rule3875 = ReplacementRule(pattern3875, replacement3875) pattern3876 = Pattern(Integral((a_ + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(x_*WC('d', S(1)) + WC('c', S(0)))**m_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons1439, cons196) def replacement3876(m, f, b, d, c, a, n, x, e): rubi.append(3876) return Int(ExpandIntegrand((c + d*x)**m, (S(1)/(S(2)*a) - exp(-S(2)*a*(e + f*x)/b)/(S(2)*a))**(-n), x), x) rule3876 = ReplacementRule(pattern3876, replacement3876) def With3877(m, f, b, d, c, a, n, x, e): u = IntHide((a + b*tan(e + f*x))**n, x) rubi.append(3877) return -Dist(d*m, Int(Dist((c + d*x)**(m + S(-1)), u, x), x), x) + Dist((c + d*x)**m, u, x) pattern3877 = Pattern(Integral((a_ + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(x_*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons1439, cons1572, cons31, cons168) rule3877 = ReplacementRule(pattern3877, With3877) def With3878(m, f, b, d, c, a, n, x, e): u = IntHide((a + b/tan(e + f*x))**n, x) rubi.append(3878) return -Dist(d*m, Int(Dist((c + d*x)**(m + S(-1)), u, x), x), x) + Dist((c + d*x)**m, u, x) pattern3878 = Pattern(Integral((a_ + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(x_*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons1439, cons1572, cons31, cons168) rule3878 = ReplacementRule(pattern3878, With3878) pattern3879 = Pattern(Integral((x_*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1))/(a_ + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons1440, cons62) def replacement3879(m, f, b, d, c, a, x, e): rubi.append(3879) return -Dist(S(2)*I*b, Int((c + d*x)**m/(a**S(2) + b**S(2) + (a - I*b)**S(2)*exp(S(2)*I*(e + f*x))), x), x) + Simp((c + d*x)**(m + S(1))/(d*(a - I*b)*(m + S(1))), x) rule3879 = ReplacementRule(pattern3879, replacement3879) pattern3880 = Pattern(Integral((x_*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1))/(a_ + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons1440, cons62) def replacement3880(m, f, b, d, c, a, x, e): rubi.append(3880) return Dist(S(2)*I*b, Int((c + d*x)**m/(a**S(2) + b**S(2) - (a + I*b)**S(2)*exp(S(2)*I*(e + f*x))), x), x) + Simp((c + d*x)**(m + S(1))/(d*(a + I*b)*(m + S(1))), x) rule3880 = ReplacementRule(pattern3880, replacement3880) pattern3881 = Pattern(Integral((x_*WC('d', S(1)) + WC('c', S(0)))/(a_ + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**S(2), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons1440) def replacement3881(f, b, d, c, a, x, e): rubi.append(3881) return Dist(S(1)/(f*(a**S(2) + b**S(2))), Int((S(2)*a*c*f + S(2)*a*d*f*x + b*d)/(a + b*tan(e + f*x)), x), x) - Simp((c + d*x)**S(2)/(S(2)*d*(a**S(2) + b**S(2))), x) - Simp(b*(c + d*x)/(f*(a + b*tan(e + f*x))*(a**S(2) + b**S(2))), x) rule3881 = ReplacementRule(pattern3881, replacement3881) pattern3882 = Pattern(Integral((x_*WC('d', S(1)) + WC('c', S(0)))/(a_ + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**S(2), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons1440) def replacement3882(f, b, d, c, a, x, e): rubi.append(3882) return -Dist(S(1)/(f*(a**S(2) + b**S(2))), Int((-S(2)*a*c*f - S(2)*a*d*f*x + b*d)/(a + b/tan(e + f*x)), x), x) - Simp((c + d*x)**S(2)/(S(2)*d*(a**S(2) + b**S(2))), x) + Simp(b*(c + d*x)/(f*(a + b/tan(e + f*x))*(a**S(2) + b**S(2))), x) rule3882 = ReplacementRule(pattern3882, replacement3882) pattern3883 = Pattern(Integral((a_ + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(x_*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons1440, cons196, cons62) def replacement3883(m, f, b, d, c, a, n, x, e): rubi.append(3883) return Int(ExpandIntegrand((c + d*x)**m, (-S(2)*I*b/(a**S(2) + b**S(2) + (a - I*b)**S(2)*exp(S(2)*I*(e + f*x))) + S(1)/(a - I*b))**(-n), x), x) rule3883 = ReplacementRule(pattern3883, replacement3883) pattern3884 = Pattern(Integral((a_ + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(x_*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons1440, cons196, cons62) def replacement3884(m, f, b, d, c, a, n, x, e): rubi.append(3884) return Int(ExpandIntegrand((c + d*x)**m, (S(2)*I*b/(a**S(2) + b**S(2) - (a + I*b)**S(2)*exp(S(2)*I*(e + f*x))) + S(1)/(a + I*b))**(-n), x), x) rule3884 = ReplacementRule(pattern3884, replacement3884) pattern3885 = Pattern(Integral(u_**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*tan(v_))**WC('n', S(1)), x_), cons2, cons3, cons21, cons4, cons810, cons811) def replacement3885(v, u, m, b, a, n, x): rubi.append(3885) return Int((a + b*tan(ExpandToSum(v, x)))**n*ExpandToSum(u, x)**m, x) rule3885 = ReplacementRule(pattern3885, replacement3885) pattern3886 = Pattern(Integral(u_**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))/tan(v_))**WC('n', S(1)), x_), cons2, cons3, cons21, cons4, cons810, cons811) def replacement3886(v, u, m, b, a, n, x): rubi.append(3886) return Int((a + b/tan(ExpandToSum(v, x)))**n*ExpandToSum(u, x)**m, x) rule3886 = ReplacementRule(pattern3886, replacement3886) pattern3887 = Pattern(Integral((x_*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons4, cons1360) def replacement3887(m, f, b, d, c, a, n, x, e): rubi.append(3887) return Int((a + b*tan(e + f*x))**n*(c + d*x)**m, x) rule3887 = ReplacementRule(pattern3887, replacement3887) pattern3888 = Pattern(Integral((x_*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons4, cons1360) def replacement3888(m, f, b, d, a, n, c, x, e): rubi.append(3888) return Int((a + b/tan(e + f*x))**n*(c + d*x)**m, x) rule3888 = ReplacementRule(pattern3888, replacement3888) pattern3889 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*tan(x_**n_*WC('d', S(1)) + WC('c', S(0))))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons5, cons1573, cons38) def replacement3889(p, b, d, c, a, n, x): rubi.append(3889) return Dist(S(1)/n, Subst(Int(x**(S(-1) + S(1)/n)*(a + b*tan(c + d*x))**p, x), x, x**n), x) rule3889 = ReplacementRule(pattern3889, replacement3889) pattern3890 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))/tan(x_**n_*WC('d', S(1)) + WC('c', S(0))))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons5, cons1573, cons38) def replacement3890(p, b, d, a, c, n, x): rubi.append(3890) return Dist(S(1)/n, Subst(Int(x**(S(-1) + S(1)/n)*(a + b/tan(c + d*x))**p, x), x, x**n), x) rule3890 = ReplacementRule(pattern3890, replacement3890) pattern3891 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*tan(x_**n_*WC('d', S(1)) + WC('c', S(0))))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons4, cons5, cons1495) def replacement3891(p, b, d, c, a, n, x): rubi.append(3891) return Int((a + b*tan(c + d*x**n))**p, x) rule3891 = ReplacementRule(pattern3891, replacement3891) pattern3892 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))/tan(x_**n_*WC('d', S(1)) + WC('c', S(0))))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons4, cons5, cons1495) def replacement3892(p, b, d, a, c, n, x): rubi.append(3892) return Int((a + b/tan(c + d*x**n))**p, x) rule3892 = ReplacementRule(pattern3892, replacement3892) pattern3893 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*tan(u_**n_*WC('d', S(1)) + WC('c', S(0))))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons4, cons5, cons68, cons69) def replacement3893(p, u, b, d, c, a, n, x): rubi.append(3893) return Dist(S(1)/Coefficient(u, x, S(1)), Subst(Int((a + b*tan(c + d*x**n))**p, x), x, u), x) rule3893 = ReplacementRule(pattern3893, replacement3893) pattern3894 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))/tan(u_**n_*WC('d', S(1)) + WC('c', S(0))))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons4, cons5, cons68, cons69) def replacement3894(p, u, b, d, a, c, n, x): rubi.append(3894) return Dist(S(1)/Coefficient(u, x, S(1)), Subst(Int((a + b/tan(c + d*x**n))**p, x), x, u), x) rule3894 = ReplacementRule(pattern3894, replacement3894) pattern3895 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*tan(u_))**WC('p', S(1)), x_), cons2, cons3, cons5, cons823, cons824) def replacement3895(p, u, b, a, x): rubi.append(3895) return Int((a + b*tan(ExpandToSum(u, x)))**p, x) rule3895 = ReplacementRule(pattern3895, replacement3895) pattern3896 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))/tan(u_))**WC('p', S(1)), x_), cons2, cons3, cons5, cons823, cons824) def replacement3896(p, u, b, a, x): rubi.append(3896) return Int((a + b/tan(ExpandToSum(u, x)))**p, x) rule3896 = ReplacementRule(pattern3896, replacement3896) pattern3897 = Pattern(Integral(x_**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*tan(x_**n_*WC('d', S(1)) + WC('c', S(0))))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons21, cons4, cons5, cons1574, cons38) def replacement3897(p, m, b, d, c, a, n, x): rubi.append(3897) return Dist(S(1)/n, Subst(Int(x**(S(-1) + (m + S(1))/n)*(a + b*tan(c + d*x))**p, x), x, x**n), x) rule3897 = ReplacementRule(pattern3897, replacement3897) pattern3898 = Pattern(Integral(x_**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))/tan(x_**n_*WC('d', S(1)) + WC('c', S(0))))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons21, cons4, cons5, cons1574, cons38) def replacement3898(p, m, b, d, a, c, n, x): rubi.append(3898) return Dist(S(1)/n, Subst(Int(x**(S(-1) + (m + S(1))/n)*(a + b/tan(c + d*x))**p, x), x, x**n), x) rule3898 = ReplacementRule(pattern3898, replacement3898) pattern3899 = Pattern(Integral(x_**WC('m', S(1))*tan(x_**n_*WC('d', S(1)) + WC('c', S(0)))**S(2), x_), cons7, cons27, cons21, cons4, cons1575) def replacement3899(m, d, c, n, x): rubi.append(3899) return -Dist((m - n + S(1))/(d*n), Int(x**(m - n)*tan(c + d*x**n), x), x) - Int(x**m, x) + Simp(x**(m - n + S(1))*tan(c + d*x**n)/(d*n), x) rule3899 = ReplacementRule(pattern3899, replacement3899) pattern3900 = Pattern(Integral(x_**WC('m', S(1))/tan(x_**n_*WC('d', S(1)) + WC('c', S(0)))**S(2), x_), cons7, cons27, cons21, cons4, cons1575) def replacement3900(m, d, c, n, x): rubi.append(3900) return Dist((m - n + S(1))/(d*n), Int(x**(m - n)/tan(c + d*x**n), x), x) - Int(x**m, x) - Simp(x**(m - n + S(1))/(d*n*tan(c + d*x**n)), x) rule3900 = ReplacementRule(pattern3900, replacement3900) pattern3901 = Pattern(Integral(x_**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*tan(x_**n_*WC('d', S(1)) + WC('c', S(0))))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons21, cons4, cons5, cons1576) def replacement3901(p, m, b, d, c, a, n, x): rubi.append(3901) return Int(x**m*(a + b*tan(c + d*x**n))**p, x) rule3901 = ReplacementRule(pattern3901, replacement3901) pattern3902 = Pattern(Integral(x_**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))/tan(x_**n_*WC('d', S(1)) + WC('c', S(0))))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons21, cons4, cons5, cons1576) def replacement3902(p, m, b, d, a, c, n, x): rubi.append(3902) return Int(x**m*(a + b/tan(c + d*x**n))**p, x) rule3902 = ReplacementRule(pattern3902, replacement3902) pattern3903 = Pattern(Integral((e_*x_)**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*tan(x_**n_*WC('d', S(1)) + WC('c', S(0))))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons21, cons4, cons5, cons1497) def replacement3903(p, m, b, d, c, a, n, x, e): rubi.append(3903) return Dist(e**IntPart(m)*x**(-FracPart(m))*(e*x)**FracPart(m), Int(x**m*(a + b*tan(c + d*x**n))**p, x), x) rule3903 = ReplacementRule(pattern3903, replacement3903) pattern3904 = Pattern(Integral((e_*x_)**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))/tan(x_**n_*WC('d', S(1)) + WC('c', S(0))))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons21, cons4, cons5, cons1497) def replacement3904(p, m, b, d, a, c, n, x, e): rubi.append(3904) return Dist(e**IntPart(m)*x**(-FracPart(m))*(e*x)**FracPart(m), Int(x**m*(a + b/tan(c + d*x**n))**p, x), x) rule3904 = ReplacementRule(pattern3904, replacement3904) pattern3905 = Pattern(Integral((e_*x_)**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*tan(u_))**WC('p', S(1)), x_), cons2, cons3, cons48, cons21, cons5, cons823, cons824) def replacement3905(p, u, m, b, a, x, e): rubi.append(3905) return Int((e*x)**m*(a + b*tan(ExpandToSum(u, x)))**p, x) rule3905 = ReplacementRule(pattern3905, replacement3905) pattern3906 = Pattern(Integral((e_*x_)**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))/tan(u_))**WC('p', S(1)), x_), cons2, cons3, cons48, cons21, cons5, cons823, cons824) def replacement3906(p, u, m, b, a, x, e): rubi.append(3906) return Int((e*x)**m*(a + b/tan(ExpandToSum(u, x)))**p, x) rule3906 = ReplacementRule(pattern3906, replacement3906) pattern3907 = Pattern(Integral(x_**WC('m', S(1))*(S(1)/cos(x_**WC('n', S(1))*WC('b', S(1)) + WC('a', S(0))))**WC('p', S(1))*tan(x_**WC('n', S(1))*WC('b', S(1)) + WC('a', S(0)))**WC('q', S(1)), x_), cons2, cons3, cons5, cons31, cons85, cons1577, cons1578) def replacement3907(p, m, b, a, n, x, q): rubi.append(3907) return -Dist((m - n + S(1))/(b*n*p), Int(x**(m - n)*(S(1)/cos(a + b*x**n))**p, x), x) + Simp(x**(m - n + S(1))*(S(1)/cos(a + b*x**n))**p/(b*n*p), x) rule3907 = ReplacementRule(pattern3907, replacement3907) pattern3908 = Pattern(Integral(x_**WC('m', S(1))*(S(1)/sin(x_**WC('n', S(1))*WC('b', S(1)) + WC('a', S(0))))**WC('p', S(1))*(S(1)/tan(x_**WC('n', S(1))*WC('b', S(1)) + WC('a', S(0))))**WC('q', S(1)), x_), cons2, cons3, cons5, cons31, cons85, cons1577, cons1578) def replacement3908(p, m, b, a, n, x, q): rubi.append(3908) return Dist((m - n + S(1))/(b*n*p), Int(x**(m - n)*(S(1)/sin(a + b*x**n))**p, x), x) - Simp(x**(m - n + S(1))*(S(1)/sin(a + b*x**n))**p/(b*n*p), x) rule3908 = ReplacementRule(pattern3908, replacement3908) pattern3909 = Pattern(Integral(tan(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0)))**WC('n', S(1)), x_), cons2, cons3, cons7, cons4, cons1579) def replacement3909(b, c, a, n, x): rubi.append(3909) return Int(tan(a + b*x + c*x**S(2))**n, x) rule3909 = ReplacementRule(pattern3909, replacement3909) pattern3910 = Pattern(Integral((S(1)/tan(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons4, cons1579) def replacement3910(b, c, a, n, x): rubi.append(3910) return Int((S(1)/tan(a + b*x + c*x**S(2)))**n, x) rule3910 = ReplacementRule(pattern3910, replacement3910) pattern3911 = Pattern(Integral((d_ + x_*WC('e', S(1)))*tan(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0))), x_), cons2, cons3, cons7, cons27, cons48, cons47) def replacement3911(b, d, c, a, x, e): rubi.append(3911) return -Simp(e*log(cos(a + b*x + c*x**S(2)))/(S(2)*c), x) rule3911 = ReplacementRule(pattern3911, replacement3911) pattern3912 = Pattern(Integral((d_ + x_*WC('e', S(1)))/tan(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0))), x_), cons2, cons3, cons7, cons27, cons48, cons47) def replacement3912(b, d, c, a, x, e): rubi.append(3912) return Simp(e*log(sin(a + b*x + c*x**S(2)))/(S(2)*c), x) rule3912 = ReplacementRule(pattern3912, replacement3912) pattern3913 = Pattern(Integral((x_*WC('e', S(1)) + WC('d', S(0)))*tan(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0))), x_), cons2, cons3, cons7, cons27, cons48, cons239) def replacement3913(b, d, c, a, x, e): rubi.append(3913) return Dist((-b*e + S(2)*c*d)/(S(2)*c), Int(tan(a + b*x + c*x**S(2)), x), x) - Simp(e*log(cos(a + b*x + c*x**S(2)))/(S(2)*c), x) rule3913 = ReplacementRule(pattern3913, replacement3913) pattern3914 = Pattern(Integral((x_*WC('e', S(1)) + WC('d', S(0)))/tan(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0))), x_), cons2, cons3, cons7, cons27, cons48, cons239) def replacement3914(b, d, c, a, x, e): rubi.append(3914) return Dist((-b*e + S(2)*c*d)/(S(2)*c), Int(S(1)/tan(a + b*x + c*x**S(2)), x), x) + Simp(e*log(sin(a + b*x + c*x**S(2)))/(S(2)*c), x) rule3914 = ReplacementRule(pattern3914, replacement3914) pattern3915 = Pattern(Integral((x_*WC('e', S(1)) + WC('d', S(0)))**WC('m', S(1))*tan(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0)))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons21, cons4, cons1580) def replacement3915(m, b, d, a, c, n, x, e): rubi.append(3915) return Int((d + e*x)**m*tan(a + b*x + c*x**S(2))**n, x) rule3915 = ReplacementRule(pattern3915, replacement3915) pattern3916 = Pattern(Integral((x_*WC('e', S(1)) + WC('d', S(0)))**WC('m', S(1))*(S(1)/tan(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons21, cons4, cons1580) def replacement3916(m, b, d, c, a, n, x, e): rubi.append(3916) return Int((d + e*x)**m*(S(1)/tan(a + b*x + c*x**S(2)))**n, x) rule3916 = ReplacementRule(pattern3916, replacement3916) return [rule3398, rule3399, rule3400, rule3401, rule3402, rule3403, rule3404, rule3405, rule3406, rule3407, rule3408, rule3409, rule3410, rule3411, rule3412, rule3413, rule3414, rule3415, rule3416, rule3417, rule3418, rule3419, rule3420, rule3421, rule3422, rule3423, rule3424, rule3425, rule3426, rule3427, rule3428, rule3429, rule3430, rule3431, rule3432, rule3433, rule3434, rule3435, rule3436, rule3437, rule3438, rule3439, rule3440, rule3441, rule3442, rule3443, rule3444, rule3445, rule3446, rule3447, rule3448, rule3449, rule3450, rule3451, rule3452, rule3453, rule3454, rule3455, rule3456, rule3457, rule3458, rule3459, rule3460, rule3461, rule3462, rule3463, rule3464, rule3465, rule3466, rule3467, rule3468, rule3469, rule3470, rule3471, rule3472, rule3473, rule3474, rule3475, rule3476, rule3477, rule3478, rule3479, rule3480, rule3481, rule3482, rule3483, rule3484, rule3485, rule3486, rule3487, rule3488, rule3489, rule3490, rule3491, rule3492, rule3493, rule3494, rule3495, rule3496, rule3497, rule3498, rule3499, rule3500, rule3501, rule3502, rule3503, rule3504, rule3505, rule3506, rule3507, rule3508, rule3509, rule3510, rule3511, rule3512, rule3513, rule3514, rule3515, rule3516, rule3517, rule3518, rule3519, rule3520, rule3521, rule3522, rule3523, rule3524, rule3525, rule3526, rule3527, rule3528, rule3529, rule3530, rule3531, rule3532, rule3533, rule3534, rule3535, rule3536, rule3537, rule3538, rule3539, rule3540, rule3541, rule3542, rule3543, rule3544, rule3545, rule3546, rule3547, rule3548, rule3549, rule3550, rule3551, rule3552, rule3553, rule3554, rule3555, rule3556, rule3557, rule3558, rule3559, rule3560, rule3561, rule3562, rule3563, rule3564, rule3565, rule3566, rule3567, rule3568, rule3569, rule3570, rule3571, rule3572, rule3573, rule3574, rule3575, rule3576, rule3577, rule3578, rule3579, rule3580, rule3581, rule3582, rule3583, rule3584, rule3585, rule3586, rule3587, rule3588, rule3589, rule3590, rule3591, rule3592, rule3593, rule3594, rule3595, rule3596, rule3597, rule3598, rule3599, rule3600, rule3601, rule3602, rule3603, rule3604, rule3605, rule3606, rule3607, rule3608, rule3609, rule3610, rule3611, rule3612, rule3613, rule3614, rule3615, rule3616, rule3617, rule3618, rule3619, rule3620, rule3621, rule3622, rule3623, rule3624, rule3625, rule3626, rule3627, rule3628, rule3629, rule3630, rule3631, rule3632, rule3633, rule3634, rule3635, rule3636, rule3637, rule3638, rule3639, rule3640, rule3641, rule3642, rule3643, rule3644, rule3645, rule3646, rule3647, rule3648, rule3649, rule3650, rule3651, rule3652, rule3653, rule3654, rule3655, rule3656, rule3657, rule3658, rule3659, rule3660, rule3661, rule3662, rule3663, rule3664, rule3665, rule3666, rule3667, rule3668, rule3669, rule3670, rule3671, rule3672, rule3673, rule3674, rule3675, rule3676, rule3677, rule3678, rule3679, rule3680, rule3681, rule3682, rule3683, rule3684, rule3685, rule3686, rule3687, rule3688, rule3689, rule3690, rule3691, rule3692, rule3693, rule3694, rule3695, rule3696, rule3697, rule3698, rule3699, rule3700, rule3701, rule3702, rule3703, rule3704, rule3705, rule3706, rule3707, rule3708, rule3709, rule3710, rule3711, rule3712, rule3713, rule3714, rule3715, rule3716, rule3717, rule3718, rule3719, rule3720, rule3721, rule3722, rule3723, rule3724, rule3725, rule3726, rule3727, rule3728, rule3729, rule3730, rule3731, rule3732, rule3733, rule3734, rule3735, rule3736, rule3737, rule3738, rule3739, rule3740, rule3741, rule3742, rule3743, rule3744, rule3745, rule3746, rule3747, rule3748, rule3749, rule3750, rule3751, rule3752, rule3753, rule3754, rule3755, rule3756, rule3757, rule3758, rule3759, rule3760, rule3761, rule3762, rule3763, rule3764, rule3765, rule3766, rule3767, rule3768, rule3769, rule3770, rule3771, rule3772, rule3773, rule3774, rule3775, rule3776, rule3777, rule3778, rule3779, rule3780, rule3781, rule3782, rule3783, rule3784, rule3785, rule3786, rule3787, rule3788, rule3789, rule3790, rule3791, rule3792, rule3793, rule3794, rule3795, rule3796, rule3797, rule3798, rule3799, rule3800, rule3801, rule3802, rule3803, rule3804, rule3805, rule3806, rule3807, rule3808, rule3809, rule3810, rule3811, rule3812, rule3813, rule3814, rule3815, rule3816, rule3817, rule3818, rule3819, rule3820, rule3821, rule3822, rule3823, rule3824, rule3825, rule3826, rule3827, rule3828, rule3829, rule3830, rule3831, rule3832, rule3833, rule3834, rule3835, rule3836, rule3837, rule3838, rule3839, rule3840, rule3841, rule3842, rule3843, rule3844, rule3845, rule3846, rule3847, rule3848, rule3849, rule3850, rule3851, rule3852, rule3853, rule3854, rule3855, rule3856, rule3857, rule3858, rule3859, rule3860, rule3861, rule3862, rule3863, rule3864, rule3865, rule3866, rule3867, rule3868, rule3869, rule3870, rule3871, rule3872, rule3873, rule3874, rule3875, rule3876, rule3877, rule3878, rule3879, rule3880, rule3881, rule3882, rule3883, rule3884, rule3885, rule3886, rule3887, rule3888, rule3889, rule3890, rule3891, rule3892, rule3893, rule3894, rule3895, rule3896, rule3897, rule3898, rule3899, rule3900, rule3901, rule3902, rule3903, rule3904, rule3905, rule3906, rule3907, rule3908, rule3909, rule3910, rule3911, rule3912, rule3913, rule3914, rule3915, rule3916, ]
d3cb717b958e9214b11a522a8b3a8de00a35b8613fcc1d3e104e858e31d4816f
''' This code is automatically generated. Never edit it manually. For details of generating the code see `rubi_parsing_guide.md` in `parsetools`. ''' from sympy.external import import_module matchpy = import_module("matchpy") from sympy.utilities.decorator import doctest_depends_on if matchpy: from matchpy import Pattern, ReplacementRule, CustomConstraint, is_match from sympy.integrals.rubi.utility_function import ( Int, Sum, Set, With, Module, Scan, MapAnd, FalseQ, ZeroQ, NegativeQ, NonzeroQ, FreeQ, NFreeQ, List, Log, PositiveQ, PositiveIntegerQ, NegativeIntegerQ, IntegerQ, IntegersQ, ComplexNumberQ, PureComplexNumberQ, RealNumericQ, PositiveOrZeroQ, NegativeOrZeroQ, FractionOrNegativeQ, NegQ, Equal, Unequal, IntPart, FracPart, RationalQ, ProductQ, SumQ, NonsumQ, Subst, First, Rest, SqrtNumberQ, SqrtNumberSumQ, LinearQ, Sqrt, ArcCosh, Coefficient, Denominator, Hypergeometric2F1, Not, Simplify, FractionalPart, IntegerPart, AppellF1, EllipticPi, EllipticE, EllipticF, ArcTan, ArcCot, ArcCoth, ArcTanh, ArcSin, ArcSinh, ArcCos, ArcCsc, ArcSec, ArcCsch, ArcSech, Sinh, Tanh, Cosh, Sech, Csch, Coth, LessEqual, Less, Greater, GreaterEqual, FractionQ, IntLinearcQ, Expand, IndependentQ, PowerQ, IntegerPowerQ, PositiveIntegerPowerQ, FractionalPowerQ, AtomQ, ExpQ, LogQ, Head, MemberQ, TrigQ, SinQ, CosQ, TanQ, CotQ, SecQ, CscQ, Sin, Cos, Tan, Cot, Sec, Csc, HyperbolicQ, SinhQ, CoshQ, TanhQ, CothQ, SechQ, CschQ, InverseTrigQ, SinCosQ, SinhCoshQ, LeafCount, Numerator, NumberQ, NumericQ, Length, ListQ, Im, Re, InverseHyperbolicQ, InverseFunctionQ, TrigHyperbolicFreeQ, InverseFunctionFreeQ, RealQ, EqQ, FractionalPowerFreeQ, ComplexFreeQ, PolynomialQ, FactorSquareFree, PowerOfLinearQ, Exponent, QuadraticQ, LinearPairQ, BinomialParts, TrinomialParts, PolyQ, EvenQ, OddQ, PerfectSquareQ, NiceSqrtAuxQ, NiceSqrtQ, Together, PosAux, PosQ, CoefficientList, ReplaceAll, ExpandLinearProduct, GCD, ContentFactor, NumericFactor, NonnumericFactors, MakeAssocList, GensymSubst, KernelSubst, ExpandExpression, Apart, SmartApart, MatchQ, PolynomialQuotientRemainder, FreeFactors, NonfreeFactors, RemoveContentAux, RemoveContent, FreeTerms, NonfreeTerms, ExpandAlgebraicFunction, CollectReciprocals, ExpandCleanup, AlgebraicFunctionQ, Coeff, LeadTerm, RemainingTerms, LeadFactor, RemainingFactors, LeadBase, LeadDegree, Numer, Denom, hypergeom, Expon, MergeMonomials, PolynomialDivide, BinomialQ, TrinomialQ, GeneralizedBinomialQ, GeneralizedTrinomialQ, FactorSquareFreeList, PerfectPowerTest, SquareFreeFactorTest, RationalFunctionQ, RationalFunctionFactors, NonrationalFunctionFactors, Reverse, RationalFunctionExponents, RationalFunctionExpand, ExpandIntegrand, SimplerQ, SimplerSqrtQ, SumSimplerQ, BinomialDegree, TrinomialDegree, CancelCommonFactors, SimplerIntegrandQ, GeneralizedBinomialDegree, GeneralizedBinomialParts, GeneralizedTrinomialDegree, GeneralizedTrinomialParts, MonomialQ, MonomialSumQ, MinimumMonomialExponent, MonomialExponent, LinearMatchQ, PowerOfLinearMatchQ, QuadraticMatchQ, CubicMatchQ, BinomialMatchQ, TrinomialMatchQ, GeneralizedBinomialMatchQ, GeneralizedTrinomialMatchQ, QuotientOfLinearsMatchQ, PolynomialTermQ, PolynomialTerms, NonpolynomialTerms, PseudoBinomialParts, NormalizePseudoBinomial, PseudoBinomialPairQ, PseudoBinomialQ, PolynomialGCD, PolyGCD, AlgebraicFunctionFactors, NonalgebraicFunctionFactors, QuotientOfLinearsP, QuotientOfLinearsParts, QuotientOfLinearsQ, Flatten, Sort, AbsurdNumberQ, AbsurdNumberFactors, NonabsurdNumberFactors, SumSimplerAuxQ, Prepend, Drop, CombineExponents, FactorInteger, FactorAbsurdNumber, SubstForInverseFunction, SubstForFractionalPower, SubstForFractionalPowerOfQuotientOfLinears, FractionalPowerOfQuotientOfLinears, SubstForFractionalPowerQ, SubstForFractionalPowerAuxQ, FractionalPowerOfSquareQ, FractionalPowerSubexpressionQ, Apply, FactorNumericGcd, MergeableFactorQ, MergeFactor, MergeFactors, TrigSimplifyQ, TrigSimplify, TrigSimplifyRecur, Order, FactorOrder, Smallest, OrderedQ, MinimumDegree, PositiveFactors, Sign, NonpositiveFactors, PolynomialInAuxQ, PolynomialInQ, ExponentInAux, ExponentIn, PolynomialInSubstAux, PolynomialInSubst, Distrib, DistributeDegree, FunctionOfPower, DivideDegreesOfFactors, MonomialFactor, FullSimplify, FunctionOfLinearSubst, FunctionOfLinear, NormalizeIntegrand, NormalizeIntegrandAux, NormalizeIntegrandFactor, NormalizeIntegrandFactorBase, NormalizeTogether, NormalizeLeadTermSigns, AbsorbMinusSign, NormalizeSumFactors, SignOfFactor, NormalizePowerOfLinear, SimplifyIntegrand, SimplifyTerm, TogetherSimplify, SmartSimplify, SubstForExpn, ExpandToSum, UnifySum, UnifyTerms, UnifyTerm, CalculusQ, FunctionOfInverseLinear, PureFunctionOfSinhQ, PureFunctionOfTanhQ, PureFunctionOfCoshQ, IntegerQuotientQ, OddQuotientQ, EvenQuotientQ, FindTrigFactor, FunctionOfSinhQ, FunctionOfCoshQ, OddHyperbolicPowerQ, FunctionOfTanhQ, FunctionOfTanhWeight, FunctionOfHyperbolicQ, SmartNumerator, SmartDenominator, SubstForAux, ActivateTrig, ExpandTrig, TrigExpand, SubstForTrig, SubstForHyperbolic, InertTrigFreeQ, LCM, SubstForFractionalPowerOfLinear, FractionalPowerOfLinear, InverseFunctionOfLinear, InertTrigQ, InertReciprocalQ, DeactivateTrig, FixInertTrigFunction, DeactivateTrigAux, PowerOfInertTrigSumQ, PiecewiseLinearQ, KnownTrigIntegrandQ, KnownSineIntegrandQ, KnownTangentIntegrandQ, KnownCotangentIntegrandQ, KnownSecantIntegrandQ, TryPureTanSubst, TryTanhSubst, TryPureTanhSubst, AbsurdNumberGCD, AbsurdNumberGCDList, ExpandTrigExpand, ExpandTrigReduce, ExpandTrigReduceAux, NormalizeTrig, TrigToExp, ExpandTrigToExp, TrigReduce, FunctionOfTrig, AlgebraicTrigFunctionQ, FunctionOfHyperbolic, FunctionOfQ, FunctionOfExpnQ, PureFunctionOfSinQ, PureFunctionOfCosQ, PureFunctionOfTanQ, PureFunctionOfCotQ, FunctionOfCosQ, FunctionOfSinQ, OddTrigPowerQ, FunctionOfTanQ, FunctionOfTanWeight, FunctionOfTrigQ, FunctionOfDensePolynomialsQ, FunctionOfLog, PowerVariableExpn, PowerVariableDegree, PowerVariableSubst, EulerIntegrandQ, FunctionOfSquareRootOfQuadratic, SquareRootOfQuadraticSubst, Divides, EasyDQ, ProductOfLinearPowersQ, Rt, NthRoot, AtomBaseQ, SumBaseQ, NegSumBaseQ, AllNegTermQ, SomeNegTermQ, TrigSquareQ, RtAux, TrigSquare, IntSum, IntTerm, Map2, ConstantFactor, SameQ, ReplacePart, CommonFactors, MostMainFactorPosition, FunctionOfExponentialQ, FunctionOfExponential, FunctionOfExponentialFunction, FunctionOfExponentialFunctionAux, FunctionOfExponentialTest, FunctionOfExponentialTestAux, stdev, rubi_test, If, IntQuadraticQ, IntBinomialQ, RectifyTangent, RectifyCotangent, Inequality, Condition, Simp, SimpHelp, SplitProduct, SplitSum, SubstFor, SubstForAux, FresnelS, FresnelC, Erfc, Erfi, Gamma, FunctionOfTrigOfLinearQ, ElementaryFunctionQ, Complex, UnsameQ, _SimpFixFactor, SimpFixFactor, _FixSimplify, FixSimplify, _SimplifyAntiderivativeSum, SimplifyAntiderivativeSum, _SimplifyAntiderivative, SimplifyAntiderivative, _TrigSimplifyAux, TrigSimplifyAux, Cancel, Part, PolyLog, D, Dist, Sum_doit, PolynomialQuotient, Floor, PolynomialRemainder, Factor, PolyLog, CosIntegral, SinIntegral, LogIntegral, SinhIntegral, CoshIntegral, Rule, Erf, PolyGamma, ExpIntegralEi, ExpIntegralE, LogGamma , UtilityOperator, Factorial, Zeta, ProductLog, DerivativeDivides, HypergeometricPFQ, IntHide, OneQ, Null, rubi_exp as exp, rubi_log as log, Discriminant, Negative, Quotient ) from sympy import (Integral, S, sqrt, And, Or, Integer, Float, Mod, I, Abs, simplify, Mul, Add, Pow, sign, EulerGamma) from sympy.integrals.rubi.symbol import WC from sympy.core.symbol import symbols, Symbol from sympy.functions import (sin, cos, tan, cot, csc, sec, sqrt, erf) from sympy.functions.elementary.hyperbolic import (acosh, asinh, atanh, acoth, acsch, asech, cosh, sinh, tanh, coth, sech, csch) from sympy.functions.elementary.trigonometric import (atan, acsc, asin, acot, acos, asec, atan2) from sympy import pi as Pi A_, B_, C_, F_, G_, H_, a_, b_, c_, d_, e_, f_, g_, h_, i_, j_, k_, l_, m_, n_, p_, q_, r_, t_, u_, v_, s_, w_, x_, y_, z_ = [WC(i) for i in 'ABCFGHabcdefghijklmnpqrtuvswxyz'] a1_, a2_, b1_, b2_, c1_, c2_, d1_, d2_, n1_, n2_, e1_, e2_, f1_, f2_, g1_, g2_, n1_, n2_, n3_, Pq_, Pm_, Px_, Qm_, Qr_, Qx_, jn_, mn_, non2_, RFx_, RGx_ = [WC(i) for i in ['a1', 'a2', 'b1', 'b2', 'c1', 'c2', 'd1', 'd2', 'n1', 'n2', 'e1', 'e2', 'f1', 'f2', 'g1', 'g2', 'n1', 'n2', 'n3', 'Pq', 'Pm', 'Px', 'Qm', 'Qr', 'Qx', 'jn', 'mn', 'non2', 'RFx', 'RGx']] i, ii , Pqq, Q, R, r, C, k, u = symbols('i ii Pqq Q R r C k u') _UseGamma = False ShowSteps = False StepCounter = None def sine(rubi): from sympy.integrals.rubi.constraints import cons1249, cons72, cons66, cons2, cons3, cons48, cons125, cons21, cons4, cons1250, cons1251, cons1252, cons93, cons166, cons89, cons1253, cons31, cons1170, cons94, cons1254, cons1255, cons1256, cons1257, cons1258, cons1259, cons165, cons1260, cons18, cons23, cons521, cons7, cons27, cons808, cons1261, cons1262, cons1263, cons543, cons1264, cons1265, cons148, cons1266, cons87, cons43, cons448, cons1267, cons1268, cons1269, cons1270, cons1271, cons481, cons482, cons1272, cons1273, cons1274, cons1275, cons1276, cons208, cons5, cons17, cons13, cons137, cons1277, cons1278, cons1279, cons1280, cons1281, cons143, cons1282, cons1283, cons1284, cons1285, cons244, cons168, cons1286, cons1287, cons1288, cons146, cons1289, cons1290, cons1291, cons246, cons1292, cons1293, cons1294, cons1295, cons1296, cons84, cons1297, cons147, cons54, cons1298, cons1299, cons1300, cons1301, cons1302, cons62, cons267, cons1303, cons1304, cons1305, cons1306, cons515, cons272, cons1307, cons1308, cons71, cons70, cons1309, cons1310, cons1311, cons1312, cons346, cons1313, cons155, cons1314, cons1315, cons114, cons1316, cons1317, cons1318, cons1319, cons1320, cons1321, cons77, cons1322, cons1323, cons1324, cons1325, cons1326, cons1327, cons1328, cons463, cons88, cons1329, cons1330, cons85, cons1331, cons1332, cons1333, cons1334, cons1335, cons1336, cons1337, cons1338, cons1339, cons1340, cons1341, cons1342, cons1343, cons1344, cons1345, cons1346, cons1347, cons1348, cons1349, cons1350, cons1351, cons1352, cons1353, cons1354, cons1355, cons1356, cons1357, cons1358, cons1359, cons1360, cons1361, cons1362, cons1363, cons1364, cons142, cons335, cons1365, cons1366, cons1367, cons1368, cons1369, cons1370, cons170, cons1371, cons1372, cons1373, cons1374, cons1375, cons253, cons1376, cons1377, cons1378, cons1379, cons1380, cons358, cons1381, cons1382, cons1383, cons1384, cons1385, cons1386, cons1387, cons1388, cons1389, cons1390, cons1391, cons1392, cons1393, cons1394, cons213, cons584, cons1395, cons1396, cons1397, cons1398, cons1399, cons1400, cons1401, cons1402, cons1403, cons1404, cons1405, cons1406, cons1407, cons1408, cons1409, cons1410, cons1411, cons105, cons1412, cons1413, cons1414, cons1415, cons1416, cons1417, cons38, cons1418, cons34, cons35, cons1419, cons1420, cons1421, cons683, cons1422, cons1423, cons1424, cons1425, cons1426, cons1427, cons1428, cons1429, cons1430, cons1431, cons36, cons1228, cons1432, cons33, cons1433, cons1434, cons1435, cons1436, cons214, cons1437, cons1438, cons1439, cons1440, cons1441, cons1442, cons1443, cons1444, cons1445, cons1446, cons1152, cons1447, cons196, cons128, cons63, cons150, cons375, cons322, cons1448, cons1449, cons1450, cons1451, cons1452, cons1453, cons1454, cons76, cons1455, cons1456, cons1457, cons1458, cons1459, cons1460, cons1461, cons1462, cons1463, cons1464, cons1465, cons1466, cons1467, cons1468, cons1469, cons1470, cons1471, cons1245, cons1472, cons1473, cons1474, cons1475, cons1476, cons1477, cons1043, cons1478, cons1479, cons1480, cons1481, cons1482, cons1483, cons1484, cons1485, cons1486, cons1487, cons46, cons45, cons226, cons376, cons1116, cons176, cons1488, cons1489, cons245, cons247, cons1490, cons1491, cons1492, cons1493, cons810, cons811, cons744, cons1494, cons1495, cons53, cons596, cons1496, cons1497, cons489, cons1498, cons68, cons69, cons823, cons824, cons1499, cons1500, cons1501, cons1502, cons56, cons1503, cons1504, cons367, cons1505, cons356, cons854, cons1506, cons818, cons1131, cons47, cons239, cons1132, cons1133, cons1507, cons819 pattern2164 = Pattern(Integral(u_, x_), cons1249) def replacement2164(x, u): rubi.append(2164) return Int(DeactivateTrig(u, x), x) rule2164 = ReplacementRule(pattern2164, replacement2164) pattern2165 = Pattern(Integral((WC('a', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1)), x_), cons2, cons3, cons48, cons125, cons21, cons4, cons72, cons66) def replacement2165(m, f, b, a, n, x, e): rubi.append(2165) return Simp((a*sin(e + f*x))**(m + S(1))*(b*cos(e + f*x))**(n + S(1))/(a*b*f*(m + S(1))), x) rule2165 = ReplacementRule(pattern2165, replacement2165) pattern2166 = Pattern(Integral((WC('a', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0)))**WC('n', S(1)), x_), cons2, cons48, cons125, cons21, cons1250, cons1251) def replacement2166(m, f, a, n, x, e): rubi.append(2166) return Dist(S(1)/(a*f), Subst(Int(x**m*(S(1) - x**S(2)/a**S(2))**(n/S(2) + S(-1)/2), x), x, a*sin(e + f*x)), x) rule2166 = ReplacementRule(pattern2166, replacement2166) pattern2167 = Pattern(Integral((WC('a', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0)))**WC('n', S(1)), x_), cons2, cons48, cons125, cons21, cons1250, cons1252) def replacement2167(m, f, a, n, x, e): rubi.append(2167) return -Dist(S(1)/(a*f), Subst(Int(x**m*(S(1) - x**S(2)/a**S(2))**(n/S(2) + S(-1)/2), x), x, a*cos(e + f*x)), x) rule2167 = ReplacementRule(pattern2167, replacement2167) pattern2168 = Pattern(Integral((WC('a', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons48, cons125, cons93, cons166, cons89, cons1253) def replacement2168(m, f, b, a, n, x, e): rubi.append(2168) return Dist(a**S(2)*(m + S(-1))/(b**S(2)*(n + S(1))), Int((a*sin(e + f*x))**(m + S(-2))*(b*cos(e + f*x))**(n + S(2)), x), x) - Simp(a*(a*sin(e + f*x))**(m + S(-1))*(b*cos(e + f*x))**(n + S(1))/(b*f*(n + S(1))), x) rule2168 = ReplacementRule(pattern2168, replacement2168) pattern2169 = Pattern(Integral((WC('a', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons48, cons125, cons93, cons166, cons89, cons1253) def replacement2169(m, f, b, a, n, x, e): rubi.append(2169) return Dist(a**S(2)*(m + S(-1))/(b**S(2)*(n + S(1))), Int((a*cos(e + f*x))**(m + S(-2))*(b*sin(e + f*x))**(n + S(2)), x), x) + Simp(a*(a*cos(e + f*x))**(m + S(-1))*(b*sin(e + f*x))**(n + S(1))/(b*f*(n + S(1))), x) rule2169 = ReplacementRule(pattern2169, replacement2169) pattern2170 = Pattern(Integral((WC('a', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons48, cons125, cons4, cons31, cons166, cons1170) def replacement2170(m, f, b, a, n, x, e): rubi.append(2170) return Dist(a**S(2)*(m + S(-1))/(m + n), Int((a*sin(e + f*x))**(m + S(-2))*(b*cos(e + f*x))**n, x), x) - Simp(a*(a*sin(e + f*x))**(m + S(-1))*(b*cos(e + f*x))**(n + S(1))/(b*f*(m + n)), x) rule2170 = ReplacementRule(pattern2170, replacement2170) pattern2171 = Pattern(Integral((WC('a', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons48, cons125, cons4, cons31, cons166, cons1170) def replacement2171(m, f, b, a, n, x, e): rubi.append(2171) return Dist(a**S(2)*(m + S(-1))/(m + n), Int((a*cos(e + f*x))**(m + S(-2))*(b*sin(e + f*x))**n, x), x) + Simp(a*(a*cos(e + f*x))**(m + S(-1))*(b*sin(e + f*x))**(n + S(1))/(b*f*(m + n)), x) rule2171 = ReplacementRule(pattern2171, replacement2171) pattern2172 = Pattern(Integral((WC('a', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons48, cons125, cons4, cons31, cons94, cons1170) def replacement2172(m, f, b, a, n, x, e): rubi.append(2172) return Dist((m + n + S(2))/(a**S(2)*(m + S(1))), Int((a*sin(e + f*x))**(m + S(2))*(b*cos(e + f*x))**n, x), x) + Simp((a*sin(e + f*x))**(m + S(1))*(b*cos(e + f*x))**(n + S(1))/(a*b*f*(m + S(1))), x) rule2172 = ReplacementRule(pattern2172, replacement2172) pattern2173 = Pattern(Integral((WC('a', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons48, cons125, cons4, cons31, cons94, cons1170) def replacement2173(m, f, b, a, n, x, e): rubi.append(2173) return Dist((m + n + S(2))/(a**S(2)*(m + S(1))), Int((a*cos(e + f*x))**(m + S(2))*(b*sin(e + f*x))**n, x), x) - Simp((a*cos(e + f*x))**(m + S(1))*(b*sin(e + f*x))**(n + S(1))/(a*b*f*(m + S(1))), x) rule2173 = ReplacementRule(pattern2173, replacement2173) pattern2174 = Pattern(Integral(sqrt(WC('a', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))*sqrt(WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons48, cons125, cons1254) def replacement2174(f, b, a, x, e): rubi.append(2174) return Dist(sqrt(a*sin(e + f*x))*sqrt(b*cos(e + f*x))/sqrt(sin(S(2)*e + S(2)*f*x)), Int(sqrt(sin(S(2)*e + S(2)*f*x)), x), x) rule2174 = ReplacementRule(pattern2174, replacement2174) pattern2175 = Pattern(Integral(S(1)/(sqrt(WC('a', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))*sqrt(WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))), x_), cons2, cons3, cons48, cons125, cons1254) def replacement2175(f, b, a, x, e): rubi.append(2175) return Dist(sqrt(sin(S(2)*e + S(2)*f*x))/(sqrt(a*sin(e + f*x))*sqrt(b*cos(e + f*x))), Int(S(1)/sqrt(sin(S(2)*e + S(2)*f*x)), x), x) rule2175 = ReplacementRule(pattern2175, replacement2175) def With2176(m, f, b, a, n, x, e): k = Denominator(m) rubi.append(2176) return Dist(a*b*k/f, Subst(Int(x**(k*(m + S(1)) + S(-1))/(a**S(2) + b**S(2)*x**(S(2)*k)), x), x, (a*sin(e + f*x))**(S(1)/k)*(b*cos(e + f*x))**(-S(1)/k)), x) pattern2176 = Pattern(Integral((WC('a', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons48, cons125, cons1255, cons31, cons1256) rule2176 = ReplacementRule(pattern2176, With2176) def With2177(m, f, b, a, n, x, e): k = Denominator(m) rubi.append(2177) return -Dist(a*b*k/f, Subst(Int(x**(k*(m + S(1)) + S(-1))/(a**S(2) + b**S(2)*x**(S(2)*k)), x), x, (a*cos(e + f*x))**(S(1)/k)*(b*sin(e + f*x))**(-S(1)/k)), x) pattern2177 = Pattern(Integral((WC('a', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons48, cons125, cons1255, cons31, cons1256) rule2177 = ReplacementRule(pattern2177, With2177) pattern2178 = Pattern(Integral((WC('a', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons48, cons125, cons21, cons4, cons1257) def replacement2178(m, f, b, a, n, x, e): rubi.append(2178) return Simp(b**(S(2)*IntPart(n/S(2) + S(-1)/2) + S(1))*(a*sin(e + f*x))**(m + S(1))*(b*cos(e + f*x))**(S(2)*FracPart(n/S(2) + S(-1)/2))*(cos(e + f*x)**S(2))**(-FracPart(n/S(2) + S(-1)/2))*Hypergeometric2F1(m/S(2) + S(1)/2, -n/S(2) + S(1)/2, m/S(2) + S(3)/2, sin(e + f*x)**S(2))/(a*f*(m + S(1))), x) rule2178 = ReplacementRule(pattern2178, replacement2178) pattern2179 = Pattern(Integral((WC('a', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons48, cons125, cons21, cons4, cons1258) def replacement2179(m, f, b, a, n, x, e): rubi.append(2179) return -Simp(b**(S(2)*IntPart(n/S(2) + S(-1)/2) + S(1))*(a*cos(e + f*x))**(m + S(1))*(b*sin(e + f*x))**(S(2)*FracPart(n/S(2) + S(-1)/2))*(sin(e + f*x)**S(2))**(-FracPart(n/S(2) + S(-1)/2))*Hypergeometric2F1(m/S(2) + S(1)/2, -n/S(2) + S(1)/2, m/S(2) + S(3)/2, cos(e + f*x)**S(2))/(a*f*(m + S(1))), x) rule2179 = ReplacementRule(pattern2179, replacement2179) pattern2180 = Pattern(Integral((WC('a', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1)), x_), cons2, cons3, cons48, cons125, cons21, cons4, cons1259, cons66) def replacement2180(m, f, b, a, n, x, e): rubi.append(2180) return Simp(b*(a*sin(e + f*x))**(m + S(1))*(b/cos(e + f*x))**(n + S(-1))/(a*f*(m + S(1))), x) rule2180 = ReplacementRule(pattern2180, replacement2180) pattern2181 = Pattern(Integral((WC('a', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1)), x_), cons2, cons3, cons48, cons125, cons21, cons4, cons1259, cons66) def replacement2181(m, f, b, a, n, x, e): rubi.append(2181) return -Simp(b*(a*cos(e + f*x))**(m + S(1))*(b/sin(e + f*x))**(n + S(-1))/(a*f*(m + S(1))), x) rule2181 = ReplacementRule(pattern2181, replacement2181) pattern2182 = Pattern(Integral((WC('a', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons48, cons125, cons93, cons166, cons165, cons1170) def replacement2182(m, f, b, a, n, x, e): rubi.append(2182) return -Dist(a**S(2)*b**S(2)*(m + S(-1))/(n + S(-1)), Int((a*sin(e + f*x))**(m + S(-2))*(b/cos(e + f*x))**(n + S(-2)), x), x) + Simp(a*b*(a*sin(e + f*x))**(m + S(-1))*(b/cos(e + f*x))**(n + S(-1))/(f*(n + S(-1))), x) rule2182 = ReplacementRule(pattern2182, replacement2182) pattern2183 = Pattern(Integral((WC('a', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons48, cons125, cons93, cons166, cons165, cons1170) def replacement2183(m, f, b, a, n, x, e): rubi.append(2183) return -Dist(a**S(2)*b**S(2)*(m + S(-1))/(n + S(-1)), Int((a*cos(e + f*x))**(m + S(-2))*(b/sin(e + f*x))**(n + S(-2)), x), x) - Simp(a*b*(a*cos(e + f*x))**(m + S(-1))*(b/sin(e + f*x))**(n + S(-1))/(f*(n + S(-1))), x) rule2183 = ReplacementRule(pattern2183, replacement2183) pattern2184 = Pattern(Integral((WC('a', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons48, cons125, cons4, cons31, cons166, cons1260, cons1170) def replacement2184(m, f, b, a, n, x, e): rubi.append(2184) return Dist(a**S(2)*(m + S(-1))/(m - n), Int((a*sin(e + f*x))**(m + S(-2))*(b/cos(e + f*x))**n, x), x) - Simp(a*b*(a*sin(e + f*x))**(m + S(-1))*(b/cos(e + f*x))**(n + S(-1))/(f*(m - n)), x) rule2184 = ReplacementRule(pattern2184, replacement2184) pattern2185 = Pattern(Integral((WC('a', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons48, cons125, cons4, cons31, cons166, cons1260, cons1170) def replacement2185(m, f, b, a, n, x, e): rubi.append(2185) return Dist(a**S(2)*(m + S(-1))/(m - n), Int((a*cos(e + f*x))**(m + S(-2))*(b/sin(e + f*x))**n, x), x) + Simp(a*b*(a*cos(e + f*x))**(m + S(-1))*(b/sin(e + f*x))**(n + S(-1))/(f*(m - n)), x) rule2185 = ReplacementRule(pattern2185, replacement2185) pattern2186 = Pattern(Integral((WC('a', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons48, cons125, cons4, cons31, cons94, cons1170) def replacement2186(m, f, b, a, n, x, e): rubi.append(2186) return Dist((m - n + S(2))/(a**S(2)*(m + S(1))), Int((a*sin(e + f*x))**(m + S(2))*(b/cos(e + f*x))**n, x), x) + Simp(b*(a*sin(e + f*x))**(m + S(1))*(b/cos(e + f*x))**(n + S(-1))/(a*f*(m + S(1))), x) rule2186 = ReplacementRule(pattern2186, replacement2186) pattern2187 = Pattern(Integral((WC('a', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons48, cons125, cons4, cons31, cons94, cons1170) def replacement2187(m, f, b, a, n, x, e): rubi.append(2187) return Dist((m - n + S(2))/(a**S(2)*(m + S(1))), Int((a*cos(e + f*x))**(m + S(2))*(b/sin(e + f*x))**n, x), x) - Simp(b*(a*cos(e + f*x))**(m + S(1))*(b/sin(e + f*x))**(n + S(-1))/(a*f*(m + S(1))), x) rule2187 = ReplacementRule(pattern2187, replacement2187) pattern2188 = Pattern(Integral((WC('a', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons48, cons125, cons21, cons4, cons18, cons23) def replacement2188(m, f, b, a, n, x, e): rubi.append(2188) return Dist((cos(e + f*x)/b)**(FracPart(n) + S(1))*(b/cos(e + f*x))**(FracPart(n) + S(1)), Int((a*sin(e + f*x))**m*(cos(e + f*x)/b)**(-n), x), x) rule2188 = ReplacementRule(pattern2188, replacement2188) pattern2189 = Pattern(Integral((WC('a', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons48, cons125, cons21, cons4, cons18, cons23) def replacement2189(m, f, b, a, n, x, e): rubi.append(2189) return Dist((sin(e + f*x)/b)**(FracPart(n) + S(1))*(b/sin(e + f*x))**(FracPart(n) + S(1)), Int((a*cos(e + f*x))**m*(sin(e + f*x)/b)**(-n), x), x) rule2189 = ReplacementRule(pattern2189, replacement2189) pattern2190 = Pattern(Integral((WC('a', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons48, cons125, cons21, cons4, cons18, cons23) def replacement2190(m, f, b, a, n, x, e): rubi.append(2190) return Dist((a*b)**IntPart(n)*(a*sin(e + f*x))**FracPart(n)*(b/sin(e + f*x))**FracPart(n), Int((a*sin(e + f*x))**(m - n), x), x) rule2190 = ReplacementRule(pattern2190, replacement2190) pattern2191 = Pattern(Integral((WC('a', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons48, cons125, cons21, cons4, cons18, cons23) def replacement2191(m, f, b, a, n, x, e): rubi.append(2191) return Dist((a*b)**IntPart(n)*(a*cos(e + f*x))**FracPart(n)*(b/cos(e + f*x))**FracPart(n), Int((a*cos(e + f*x))**(m - n), x), x) rule2191 = ReplacementRule(pattern2191, replacement2191) pattern2192 = Pattern(Integral(sin(x_*WC('d', S(1)) + WC('c', S(0)))**n_, x_), cons7, cons27, cons521) def replacement2192(d, c, n, x): rubi.append(2192) return -Dist(S(1)/d, Subst(Int((-x**S(2) + S(1))**(n/S(2))/sqrt(-x**S(2) + S(1)), x), x, cos(c + d*x)), x) rule2192 = ReplacementRule(pattern2192, replacement2192) pattern2193 = Pattern(Integral(cos(x_*WC('d', S(1)) + WC('c', S(0)))**n_, x_), cons7, cons27, cons521) def replacement2193(d, c, n, x): rubi.append(2193) return Dist(S(1)/d, Subst(Int((-x**S(2) + S(1))**(n/S(2))/sqrt(-x**S(2) + S(1)), x), x, sin(c + d*x)), x) rule2193 = ReplacementRule(pattern2193, replacement2193) pattern2194 = Pattern(Integral((WC('b', S(1))*sin(x_*WC('d', S(1)) + WC('c', S(0))))**n_, x_), cons3, cons7, cons27, cons808, cons165) def replacement2194(b, d, c, n, x): rubi.append(2194) return Dist(b**S(2)*(n + S(-1))/n, Int((b*sin(c + d*x))**(n + S(-2)), x), x) - Simp(b*(b*sin(c + d*x))**(n + S(-1))*cos(c + d*x)/(d*n), x) rule2194 = ReplacementRule(pattern2194, replacement2194) pattern2195 = Pattern(Integral((WC('b', S(1))*cos(x_*WC('d', S(1)) + WC('c', S(0))))**n_, x_), cons3, cons7, cons27, cons808, cons165) def replacement2195(b, d, c, n, x): rubi.append(2195) return Dist(b**S(2)*(n + S(-1))/n, Int((b*cos(c + d*x))**(n + S(-2)), x), x) + Simp(b*(b*cos(c + d*x))**(n + S(-1))*sin(c + d*x)/(d*n), x) rule2195 = ReplacementRule(pattern2195, replacement2195) pattern2196 = Pattern(Integral((WC('b', S(1))*sin(x_*WC('d', S(1)) + WC('c', S(0))))**n_, x_), cons3, cons7, cons27, cons808, cons89) def replacement2196(b, d, c, n, x): rubi.append(2196) return Dist((n + S(2))/(b**S(2)*(n + S(1))), Int((b*sin(c + d*x))**(n + S(2)), x), x) + Simp((b*sin(c + d*x))**(n + S(1))*cos(c + d*x)/(b*d*(n + S(1))), x) rule2196 = ReplacementRule(pattern2196, replacement2196) pattern2197 = Pattern(Integral((WC('b', S(1))*cos(x_*WC('d', S(1)) + WC('c', S(0))))**n_, x_), cons3, cons7, cons27, cons808, cons89) def replacement2197(b, d, c, n, x): rubi.append(2197) return Dist((n + S(2))/(b**S(2)*(n + S(1))), Int((b*cos(c + d*x))**(n + S(2)), x), x) - Simp((b*cos(c + d*x))**(n + S(1))*sin(c + d*x)/(b*d*(n + S(1))), x) rule2197 = ReplacementRule(pattern2197, replacement2197) pattern2198 = Pattern(Integral(sin(x_*WC('d', S(1)) + WC('c', S(0))), x_), cons7, cons27, cons1261) def replacement2198(d, c, x): rubi.append(2198) return -Simp(cos(c + d*x)/d, x) rule2198 = ReplacementRule(pattern2198, replacement2198) pattern2199 = Pattern(Integral(cos(x_*WC('d', S(1)) + WC('c', S(0))), x_), cons7, cons7, cons1262) def replacement2199(d, c, x): rubi.append(2199) return Simp(sin(c + d*x)/d, x) rule2199 = ReplacementRule(pattern2199, replacement2199) pattern2200 = Pattern(Integral(sqrt(sin(x_*WC('d', S(1)) + WC('c', S(0)))), x_), cons7, cons27, cons1261) def replacement2200(d, c, x): rubi.append(2200) return Simp(S(2)*EllipticE(-Pi/S(4) + c/S(2) + d*x/S(2), S(2))/d, x) rule2200 = ReplacementRule(pattern2200, replacement2200) pattern2201 = Pattern(Integral(sqrt(cos(x_*WC('d', S(1)) + WC('c', S(0)))), x_), cons7, cons27, cons1261) def replacement2201(d, c, x): rubi.append(2201) return Simp(S(2)*EllipticE(c/S(2) + d*x/S(2), S(2))/d, x) rule2201 = ReplacementRule(pattern2201, replacement2201) pattern2202 = Pattern(Integral(sqrt(b_*sin(x_*WC('d', S(1)) + WC('c', S(0)))), x_), cons3, cons7, cons27, cons1263) def replacement2202(d, c, b, x): rubi.append(2202) return Dist(sqrt(b*sin(c + d*x))/sqrt(sin(c + d*x)), Int(sqrt(sin(c + d*x)), x), x) rule2202 = ReplacementRule(pattern2202, replacement2202) pattern2203 = Pattern(Integral(sqrt(b_*cos(x_*WC('d', S(1)) + WC('c', S(0)))), x_), cons3, cons7, cons27, cons1263) def replacement2203(d, c, b, x): rubi.append(2203) return Dist(sqrt(b*cos(c + d*x))/sqrt(cos(c + d*x)), Int(sqrt(cos(c + d*x)), x), x) rule2203 = ReplacementRule(pattern2203, replacement2203) pattern2204 = Pattern(Integral(S(1)/sqrt(sin(x_*WC('d', S(1)) + WC('c', S(0)))), x_), cons7, cons27, cons1261) def replacement2204(d, c, x): rubi.append(2204) return Simp(S(2)*EllipticF(-Pi/S(4) + c/S(2) + d*x/S(2), S(2))/d, x) rule2204 = ReplacementRule(pattern2204, replacement2204) pattern2205 = Pattern(Integral(S(1)/sqrt(cos(x_*WC('d', S(1)) + WC('c', S(0)))), x_), cons7, cons27, cons1261) def replacement2205(d, c, x): rubi.append(2205) return Simp(S(2)*EllipticF(c/S(2) + d*x/S(2), S(2))/d, x) rule2205 = ReplacementRule(pattern2205, replacement2205) pattern2206 = Pattern(Integral(S(1)/sqrt(b_*sin(x_*WC('d', S(1)) + WC('c', S(0)))), x_), cons3, cons7, cons27, cons1263) def replacement2206(d, c, b, x): rubi.append(2206) return Dist(sqrt(sin(c + d*x))/sqrt(b*sin(c + d*x)), Int(S(1)/sqrt(sin(c + d*x)), x), x) rule2206 = ReplacementRule(pattern2206, replacement2206) pattern2207 = Pattern(Integral(S(1)/sqrt(b_*cos(x_*WC('d', S(1)) + WC('c', S(0)))), x_), cons3, cons7, cons27, cons1263) def replacement2207(d, c, b, x): rubi.append(2207) return Dist(sqrt(cos(c + d*x))/sqrt(b*cos(c + d*x)), Int(S(1)/sqrt(cos(c + d*x)), x), x) rule2207 = ReplacementRule(pattern2207, replacement2207) pattern2208 = Pattern(Integral((WC('b', S(1))*sin(x_*WC('d', S(1)) + WC('c', S(0))))**n_, x_), cons3, cons7, cons27, cons4, cons543) def replacement2208(b, d, c, n, x): rubi.append(2208) return Simp((b*sin(c + d*x))**(n + S(1))*Hypergeometric2F1(S(1)/2, n/S(2) + S(1)/2, n/S(2) + S(3)/2, sin(c + d*x)**S(2))*cos(c + d*x)/(b*d*(n + S(1))*sqrt(cos(c + d*x)**S(2))), x) rule2208 = ReplacementRule(pattern2208, replacement2208) pattern2209 = Pattern(Integral((WC('b', S(1))*cos(x_*WC('d', S(1)) + WC('c', S(0))))**n_, x_), cons3, cons7, cons27, cons4, cons543) def replacement2209(b, d, c, n, x): rubi.append(2209) return -Simp((b*cos(c + d*x))**(n + S(1))*Hypergeometric2F1(S(1)/2, n/S(2) + S(1)/2, n/S(2) + S(3)/2, cos(c + d*x)**S(2))*sin(c + d*x)/(b*d*(n + S(1))*sqrt(sin(c + d*x)**S(2))), x) rule2209 = ReplacementRule(pattern2209, replacement2209) pattern2210 = Pattern(Integral((a_ + WC('b', S(1))*sin(x_*WC('d', S(1)) + WC('c', S(0))))**S(2), x_), cons2, cons3, cons7, cons27, cons1264) def replacement2210(b, d, c, a, x): rubi.append(2210) return Dist(S(2)*a*b, Int(sin(c + d*x), x), x) + Simp(x*(S(2)*a**S(2) + b**S(2))/S(2), x) - Simp(b**S(2)*sin(c + d*x)*cos(c + d*x)/(S(2)*d), x) rule2210 = ReplacementRule(pattern2210, replacement2210) pattern2211 = Pattern(Integral((a_ + WC('b', S(1))*cos(x_*WC('d', S(1)) + WC('c', S(0))))**S(2), x_), cons2, cons3, cons7, cons27, cons1264) def replacement2211(b, d, c, a, x): rubi.append(2211) return Dist(S(2)*a*b, Int(cos(c + d*x), x), x) + Simp(x*(S(2)*a**S(2) + b**S(2))/S(2), x) + Simp(b**S(2)*sin(c + d*x)*cos(c + d*x)/(S(2)*d), x) rule2211 = ReplacementRule(pattern2211, replacement2211) pattern2212 = Pattern(Integral((a_ + WC('b', S(1))*sin(x_*WC('d', S(1)) + WC('c', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons4, cons1265, cons148) def replacement2212(b, d, c, a, n, x): rubi.append(2212) return Int(ExpandTrig((a + b*sin(c + d*x))**n, x), x) rule2212 = ReplacementRule(pattern2212, replacement2212) pattern2213 = Pattern(Integral((a_ + WC('b', S(1))*cos(x_*WC('d', S(1)) + WC('c', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons4, cons1265, cons148) def replacement2213(b, d, c, a, n, x): rubi.append(2213) return Int(ExpandTrig((a + b*cos(c + d*x))**n, x), x) rule2213 = ReplacementRule(pattern2213, replacement2213) pattern2214 = Pattern(Integral(sqrt(a_ + WC('b', S(1))*sin(x_*WC('d', S(1)) + WC('c', S(0)))), x_), cons2, cons3, cons7, cons27, cons1265) def replacement2214(b, d, c, a, x): rubi.append(2214) return Simp(-S(2)*b*cos(c + d*x)/(d*sqrt(a + b*sin(c + d*x))), x) rule2214 = ReplacementRule(pattern2214, replacement2214) pattern2215 = Pattern(Integral(sqrt(a_ + WC('b', S(1))*cos(x_*WC('d', S(1)) + WC('c', S(0)))), x_), cons2, cons3, cons7, cons27, cons1265) def replacement2215(b, d, c, a, x): rubi.append(2215) return Simp(S(2)*b*sin(c + d*x)/(d*sqrt(a + b*cos(c + d*x))), x) rule2215 = ReplacementRule(pattern2215, replacement2215) pattern2216 = Pattern(Integral((a_ + WC('b', S(1))*sin(x_*WC('d', S(1)) + WC('c', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons1265, cons1266) def replacement2216(b, d, c, a, n, x): rubi.append(2216) return Dist(a*(S(2)*n + S(-1))/n, Int((a + b*sin(c + d*x))**(n + S(-1)), x), x) - Simp(b*(a + b*sin(c + d*x))**(n + S(-1))*cos(c + d*x)/(d*n), x) rule2216 = ReplacementRule(pattern2216, replacement2216) pattern2217 = Pattern(Integral((a_ + WC('b', S(1))*cos(x_*WC('d', S(1)) + WC('c', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons1265, cons1266) def replacement2217(b, d, c, a, n, x): rubi.append(2217) return Dist(a*(S(2)*n + S(-1))/n, Int((a + b*cos(c + d*x))**(n + S(-1)), x), x) + Simp(b*(a + b*cos(c + d*x))**(n + S(-1))*sin(c + d*x)/(d*n), x) rule2217 = ReplacementRule(pattern2217, replacement2217) pattern2218 = Pattern(Integral(S(1)/(a_ + WC('b', S(1))*sin(x_*WC('d', S(1)) + WC('c', S(0)))), x_), cons2, cons3, cons7, cons27, cons1265) def replacement2218(b, d, c, a, x): rubi.append(2218) return -Simp(cos(c + d*x)/(d*(a*sin(c + d*x) + b)), x) rule2218 = ReplacementRule(pattern2218, replacement2218) pattern2219 = Pattern(Integral(S(1)/(a_ + WC('b', S(1))*cos(x_*WC('d', S(1)) + WC('c', S(0)))), x_), cons2, cons3, cons7, cons27, cons1265) def replacement2219(b, d, c, a, x): rubi.append(2219) return Simp(sin(c + d*x)/(d*(a*cos(c + d*x) + b)), x) rule2219 = ReplacementRule(pattern2219, replacement2219) pattern2220 = Pattern(Integral(S(1)/sqrt(a_ + WC('b', S(1))*sin(x_*WC('d', S(1)) + WC('c', S(0)))), x_), cons2, cons3, cons7, cons27, cons1265) def replacement2220(b, d, c, a, x): rubi.append(2220) return Dist(-S(2)/d, Subst(Int(S(1)/(S(2)*a - x**S(2)), x), x, b*cos(c + d*x)/sqrt(a + b*sin(c + d*x))), x) rule2220 = ReplacementRule(pattern2220, replacement2220) pattern2221 = Pattern(Integral(S(1)/sqrt(a_ + WC('b', S(1))*cos(x_*WC('d', S(1)) + WC('c', S(0)))), x_), cons2, cons3, cons7, cons27, cons1265) def replacement2221(b, d, c, a, x): rubi.append(2221) return Dist(S(2)/d, Subst(Int(S(1)/(S(2)*a - x**S(2)), x), x, b*sin(c + d*x)/sqrt(a + b*cos(c + d*x))), x) rule2221 = ReplacementRule(pattern2221, replacement2221) pattern2222 = Pattern(Integral((a_ + WC('b', S(1))*sin(x_*WC('d', S(1)) + WC('c', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons1265, cons87, cons89, cons808) def replacement2222(b, d, c, a, n, x): rubi.append(2222) return Dist((n + S(1))/(a*(S(2)*n + S(1))), Int((a + b*sin(c + d*x))**(n + S(1)), x), x) + Simp(b*(a + b*sin(c + d*x))**n*cos(c + d*x)/(a*d*(S(2)*n + S(1))), x) rule2222 = ReplacementRule(pattern2222, replacement2222) pattern2223 = Pattern(Integral((a_ + WC('b', S(1))*cos(x_*WC('d', S(1)) + WC('c', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons1265, cons87, cons89, cons808) def replacement2223(b, d, c, a, n, x): rubi.append(2223) return Dist((n + S(1))/(a*(S(2)*n + S(1))), Int((a + b*cos(c + d*x))**(n + S(1)), x), x) - Simp(b*(a + b*cos(c + d*x))**n*sin(c + d*x)/(a*d*(S(2)*n + S(1))), x) rule2223 = ReplacementRule(pattern2223, replacement2223) pattern2224 = Pattern(Integral((a_ + WC('b', S(1))*sin(x_*WC('d', S(1)) + WC('c', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons4, cons1265, cons543, cons43) def replacement2224(b, d, c, a, n, x): rubi.append(2224) return -Simp(S(2)**(n + S(1)/2)*a**(n + S(-1)/2)*b*Hypergeometric2F1(S(1)/2, -n + S(1)/2, S(3)/2, S(1)/2 - b*sin(c + d*x)/(S(2)*a))*cos(c + d*x)/(d*sqrt(a + b*sin(c + d*x))), x) rule2224 = ReplacementRule(pattern2224, replacement2224) pattern2225 = Pattern(Integral((a_ + WC('b', S(1))*cos(x_*WC('d', S(1)) + WC('c', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons4, cons1265, cons543, cons43) def replacement2225(b, d, c, a, n, x): rubi.append(2225) return Simp(S(2)**(n + S(1)/2)*a**(n + S(-1)/2)*b*Hypergeometric2F1(S(1)/2, -n + S(1)/2, S(3)/2, S(1)/2 - b*cos(c + d*x)/(S(2)*a))*sin(c + d*x)/(d*sqrt(a + b*cos(c + d*x))), x) rule2225 = ReplacementRule(pattern2225, replacement2225) pattern2226 = Pattern(Integral((a_ + WC('b', S(1))*sin(x_*WC('d', S(1)) + WC('c', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons4, cons1265, cons543, cons448) def replacement2226(b, d, c, a, n, x): rubi.append(2226) return Dist(a**IntPart(n)*(S(1) + b*sin(c + d*x)/a)**(-FracPart(n))*(a + b*sin(c + d*x))**FracPart(n), Int((S(1) + b*sin(c + d*x)/a)**n, x), x) rule2226 = ReplacementRule(pattern2226, replacement2226) pattern2227 = Pattern(Integral((a_ + WC('b', S(1))*cos(x_*WC('d', S(1)) + WC('c', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons4, cons1265, cons543, cons448) def replacement2227(b, d, c, a, n, x): rubi.append(2227) return Dist(a**IntPart(n)*(S(1) + b*cos(c + d*x)/a)**(-FracPart(n))*(a + b*cos(c + d*x))**FracPart(n), Int((S(1) + b*cos(c + d*x)/a)**n, x), x) rule2227 = ReplacementRule(pattern2227, replacement2227) pattern2228 = Pattern(Integral(sqrt(a_ + WC('b', S(1))*sin(x_*WC('d', S(1)) + WC('c', S(0)))), x_), cons2, cons3, cons7, cons27, cons1267, cons1268) def replacement2228(b, d, c, a, x): rubi.append(2228) return Simp(S(2)*sqrt(a + b)*EllipticE(-Pi/S(4) + c/S(2) + d*x/S(2), S(2)*b/(a + b))/d, x) rule2228 = ReplacementRule(pattern2228, replacement2228) pattern2229 = Pattern(Integral(sqrt(a_ + WC('b', S(1))*cos(x_*WC('d', S(1)) + WC('c', S(0)))), x_), cons2, cons3, cons7, cons27, cons1267, cons1268) def replacement2229(b, d, c, a, x): rubi.append(2229) return Simp(S(2)*sqrt(a + b)*EllipticE(c/S(2) + d*x/S(2), S(2)*b/(a + b))/d, x) rule2229 = ReplacementRule(pattern2229, replacement2229) pattern2230 = Pattern(Integral(sqrt(a_ + WC('b', S(1))*sin(x_*WC('d', S(1)) + WC('c', S(0)))), x_), cons2, cons3, cons7, cons27, cons1267, cons1269) def replacement2230(b, d, c, a, x): rubi.append(2230) return Simp(S(2)*sqrt(a - b)*EllipticE(Pi/S(4) + c/S(2) + d*x/S(2), -S(2)*b/(a - b))/d, x) rule2230 = ReplacementRule(pattern2230, replacement2230) pattern2231 = Pattern(Integral(sqrt(a_ + WC('b', S(1))*cos(x_*WC('d', S(1)) + WC('c', S(0)))), x_), cons2, cons3, cons7, cons27, cons1267, cons1269) def replacement2231(b, d, c, a, x): rubi.append(2231) return Simp(S(2)*sqrt(a - b)*EllipticE(Pi/S(2) + c/S(2) + d*x/S(2), -S(2)*b/(a - b))/d, x) rule2231 = ReplacementRule(pattern2231, replacement2231) pattern2232 = Pattern(Integral(sqrt(a_ + WC('b', S(1))*sin(x_*WC('d', S(1)) + WC('c', S(0)))), x_), cons2, cons3, cons7, cons27, cons1267, cons1270) def replacement2232(b, d, c, a, x): rubi.append(2232) return Dist(sqrt(a + b*sin(c + d*x))/sqrt((a + b*sin(c + d*x))/(a + b)), Int(sqrt(a/(a + b) + b*sin(c + d*x)/(a + b)), x), x) rule2232 = ReplacementRule(pattern2232, replacement2232) pattern2233 = Pattern(Integral(sqrt(a_ + WC('b', S(1))*cos(x_*WC('d', S(1)) + WC('c', S(0)))), x_), cons2, cons3, cons7, cons27, cons1267, cons1270) def replacement2233(b, d, c, a, x): rubi.append(2233) return Dist(sqrt(a + b*cos(c + d*x))/sqrt((a + b*cos(c + d*x))/(a + b)), Int(sqrt(a/(a + b) + b*cos(c + d*x)/(a + b)), x), x) rule2233 = ReplacementRule(pattern2233, replacement2233) pattern2234 = Pattern(Integral((a_ + WC('b', S(1))*sin(x_*WC('d', S(1)) + WC('c', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons1267, cons87, cons165, cons808) def replacement2234(b, d, c, a, n, x): rubi.append(2234) return Dist(S(1)/n, Int((a + b*sin(c + d*x))**(n + S(-2))*Simp(a**S(2)*n + a*b*(S(2)*n + S(-1))*sin(c + d*x) + b**S(2)*(n + S(-1)), x), x), x) - Simp(b*(a + b*sin(c + d*x))**(n + S(-1))*cos(c + d*x)/(d*n), x) rule2234 = ReplacementRule(pattern2234, replacement2234) pattern2235 = Pattern(Integral((a_ + WC('b', S(1))*cos(x_*WC('d', S(1)) + WC('c', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons1267, cons87, cons165, cons808) def replacement2235(b, d, c, a, n, x): rubi.append(2235) return Dist(S(1)/n, Int((a + b*cos(c + d*x))**(n + S(-2))*Simp(a**S(2)*n + a*b*(S(2)*n + S(-1))*cos(c + d*x) + b**S(2)*(n + S(-1)), x), x), x) + Simp(b*(a + b*cos(c + d*x))**(n + S(-1))*sin(c + d*x)/(d*n), x) rule2235 = ReplacementRule(pattern2235, replacement2235) def With2236(b, d, c, a, x): q = Rt(a**S(2) - b**S(2), S(2)) rubi.append(2236) return Simp(x/q, x) + Simp(S(2)*ArcTan(b*cos(c + d*x)/(a + b*sin(c + d*x) + q))/(d*q), x) pattern2236 = Pattern(Integral(S(1)/(a_ + WC('b', S(1))*sin(x_*WC('d', S(1)) + WC('c', S(0)))), x_), cons2, cons3, cons7, cons27, cons1271, cons481) rule2236 = ReplacementRule(pattern2236, With2236) def With2237(b, d, c, a, x): q = Rt(a**S(2) - b**S(2), S(2)) rubi.append(2237) return Simp(x/q, x) - Simp(S(2)*ArcTan(b*sin(c + d*x)/(a + b*cos(c + d*x) + q))/(d*q), x) pattern2237 = Pattern(Integral(S(1)/(a_ + WC('b', S(1))*cos(x_*WC('d', S(1)) + WC('c', S(0)))), x_), cons2, cons3, cons7, cons27, cons1271, cons481) rule2237 = ReplacementRule(pattern2237, With2237) def With2238(b, d, c, a, x): q = Rt(a**S(2) - b**S(2), S(2)) rubi.append(2238) return -Simp(x/q, x) - Simp(S(2)*ArcTan(b*cos(c + d*x)/(a + b*sin(c + d*x) - q))/(d*q), x) pattern2238 = Pattern(Integral(S(1)/(a_ + WC('b', S(1))*sin(x_*WC('d', S(1)) + WC('c', S(0)))), x_), cons2, cons3, cons7, cons27, cons1271, cons482) rule2238 = ReplacementRule(pattern2238, With2238) def With2239(b, d, c, a, x): q = Rt(a**S(2) - b**S(2), S(2)) rubi.append(2239) return -Simp(x/q, x) + Simp(S(2)*ArcTan(b*sin(c + d*x)/(a + b*cos(c + d*x) - q))/(d*q), x) pattern2239 = Pattern(Integral(S(1)/(a_ + WC('b', S(1))*cos(x_*WC('d', S(1)) + WC('c', S(0)))), x_), cons2, cons3, cons7, cons27, cons1271, cons482) rule2239 = ReplacementRule(pattern2239, With2239) def With2240(b, d, c, a, x): e = FreeFactors(tan(-Pi/S(4) + c/S(2) + d*x/S(2)), x) rubi.append(2240) return Dist(S(2)*e/d, Subst(Int(S(1)/(a + b + e**S(2)*x**S(2)*(a - b)), x), x, tan(-Pi/S(4) + c/S(2) + d*x/S(2))/e), x) pattern2240 = Pattern(Integral(S(1)/(a_ + WC('b', S(1))*sin(x_*WC('d', S(1)) + WC('c', S(0)))), x_), cons2, cons3, cons7, cons27, cons1267, cons1272) rule2240 = ReplacementRule(pattern2240, With2240) def With2241(b, d, c, a, x): e = FreeFactors(tan(c/S(2) + d*x/S(2)), x) rubi.append(2241) return Dist(S(2)*e/d, Subst(Int(S(1)/(a*e**S(2)*x**S(2) + a + S(2)*b*e*x), x), x, tan(c/S(2) + d*x/S(2))/e), x) pattern2241 = Pattern(Integral(S(1)/(a_ + WC('b', S(1))*sin(x_*WC('d', S(1)) + WC('c', S(0)))), x_), cons2, cons3, cons7, cons27, cons1267) rule2241 = ReplacementRule(pattern2241, With2241) def With2242(b, d, c, a, x): e = FreeFactors(tan(c/S(2) + d*x/S(2)), x) rubi.append(2242) return Dist(S(2)*e/d, Subst(Int(S(1)/(a + b + e**S(2)*x**S(2)*(a - b)), x), x, tan(c/S(2) + d*x/S(2))/e), x) pattern2242 = Pattern(Integral(S(1)/(a_ + WC('b', S(1))*cos(x_*WC('d', S(1)) + WC('c', S(0)))), x_), cons2, cons3, cons7, cons27, cons1267) rule2242 = ReplacementRule(pattern2242, With2242) pattern2243 = Pattern(Integral(S(1)/sqrt(a_ + WC('b', S(1))*sin(x_*WC('d', S(1)) + WC('c', S(0)))), x_), cons2, cons3, cons7, cons27, cons1267, cons1268) def replacement2243(b, d, c, a, x): rubi.append(2243) return Simp(S(2)*EllipticF(-Pi/S(4) + c/S(2) + d*x/S(2), S(2)*b/(a + b))/(d*sqrt(a + b)), x) rule2243 = ReplacementRule(pattern2243, replacement2243) pattern2244 = Pattern(Integral(S(1)/sqrt(a_ + WC('b', S(1))*cos(x_*WC('d', S(1)) + WC('c', S(0)))), x_), cons2, cons3, cons7, cons27, cons1267, cons1268) def replacement2244(b, d, c, a, x): rubi.append(2244) return Simp(S(2)*EllipticF(c/S(2) + d*x/S(2), S(2)*b/(a + b))/(d*sqrt(a + b)), x) rule2244 = ReplacementRule(pattern2244, replacement2244) pattern2245 = Pattern(Integral(S(1)/sqrt(a_ + WC('b', S(1))*sin(x_*WC('d', S(1)) + WC('c', S(0)))), x_), cons2, cons3, cons7, cons27, cons1267, cons1269) def replacement2245(b, d, c, a, x): rubi.append(2245) return Simp(S(2)*EllipticF(Pi/S(4) + c/S(2) + d*x/S(2), -S(2)*b/(a - b))/(d*sqrt(a - b)), x) rule2245 = ReplacementRule(pattern2245, replacement2245) pattern2246 = Pattern(Integral(S(1)/sqrt(a_ + WC('b', S(1))*cos(x_*WC('d', S(1)) + WC('c', S(0)))), x_), cons2, cons3, cons7, cons27, cons1267, cons1269) def replacement2246(b, d, c, a, x): rubi.append(2246) return Simp(S(2)*EllipticF(Pi/S(2) + c/S(2) + d*x/S(2), -S(2)*b/(a - b))/(d*sqrt(a - b)), x) rule2246 = ReplacementRule(pattern2246, replacement2246) pattern2247 = Pattern(Integral(S(1)/sqrt(a_ + WC('b', S(1))*sin(x_*WC('d', S(1)) + WC('c', S(0)))), x_), cons2, cons3, cons7, cons27, cons1267, cons1270) def replacement2247(b, d, c, a, x): rubi.append(2247) return Dist(sqrt((a + b*sin(c + d*x))/(a + b))/sqrt(a + b*sin(c + d*x)), Int(S(1)/sqrt(a/(a + b) + b*sin(c + d*x)/(a + b)), x), x) rule2247 = ReplacementRule(pattern2247, replacement2247) pattern2248 = Pattern(Integral(S(1)/sqrt(a_ + WC('b', S(1))*cos(x_*WC('d', S(1)) + WC('c', S(0)))), x_), cons2, cons3, cons7, cons27, cons1267, cons1270) def replacement2248(b, d, c, a, x): rubi.append(2248) return Dist(sqrt((a + b*cos(c + d*x))/(a + b))/sqrt(a + b*cos(c + d*x)), Int(S(1)/sqrt(a/(a + b) + b*cos(c + d*x)/(a + b)), x), x) rule2248 = ReplacementRule(pattern2248, replacement2248) pattern2249 = Pattern(Integral((a_ + WC('b', S(1))*sin(x_*WC('d', S(1)) + WC('c', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons1267, cons87, cons89, cons808) def replacement2249(b, d, c, a, n, x): rubi.append(2249) return Dist(S(1)/((a**S(2) - b**S(2))*(n + S(1))), Int((a + b*sin(c + d*x))**(n + S(1))*Simp(a*(n + S(1)) - b*(n + S(2))*sin(c + d*x), x), x), x) - Simp(b*(a + b*sin(c + d*x))**(n + S(1))*cos(c + d*x)/(d*(a**S(2) - b**S(2))*(n + S(1))), x) rule2249 = ReplacementRule(pattern2249, replacement2249) pattern2250 = Pattern(Integral((a_ + WC('b', S(1))*cos(x_*WC('d', S(1)) + WC('c', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons1267, cons87, cons89, cons808) def replacement2250(b, d, c, a, n, x): rubi.append(2250) return Dist(S(1)/((a**S(2) - b**S(2))*(n + S(1))), Int((a + b*cos(c + d*x))**(n + S(1))*Simp(a*(n + S(1)) - b*(n + S(2))*cos(c + d*x), x), x), x) + Simp(b*(a + b*cos(c + d*x))**(n + S(1))*sin(c + d*x)/(d*(a**S(2) - b**S(2))*(n + S(1))), x) rule2250 = ReplacementRule(pattern2250, replacement2250) pattern2251 = Pattern(Integral((a_ + WC('b', S(1))*sin(x_*WC('d', S(1)) + WC('c', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons4, cons1267, cons543) def replacement2251(b, d, c, a, n, x): rubi.append(2251) return Dist(cos(c + d*x)/(d*sqrt(-sin(c + d*x) + S(1))*sqrt(sin(c + d*x) + S(1))), Subst(Int((a + b*x)**n/(sqrt(-x + S(1))*sqrt(x + S(1))), x), x, sin(c + d*x)), x) rule2251 = ReplacementRule(pattern2251, replacement2251) pattern2252 = Pattern(Integral((a_ + WC('b', S(1))*cos(x_*WC('d', S(1)) + WC('c', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons4, cons1267, cons543) def replacement2252(b, d, c, a, n, x): rubi.append(2252) return -Dist(sin(c + d*x)/(d*sqrt(-cos(c + d*x) + S(1))*sqrt(cos(c + d*x) + S(1))), Subst(Int((a + b*x)**n/(sqrt(-x + S(1))*sqrt(x + S(1))), x), x, cos(c + d*x)), x) rule2252 = ReplacementRule(pattern2252, replacement2252) pattern2253 = Pattern(Integral((a_ + WC('b', S(1))*sin(x_*WC('d', S(1)) + WC('c', S(0)))*cos(x_*WC('d', S(1)) + WC('c', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons4, cons1273) def replacement2253(b, d, c, a, n, x): rubi.append(2253) return Int((a + b*sin(S(2)*c + S(2)*d*x)/S(2))**n, x) rule2253 = ReplacementRule(pattern2253, replacement2253) pattern2254 = Pattern(Integral((a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0)))**WC('p', S(1)), x_), cons2, cons3, cons48, cons125, cons21, cons1274, cons1265, cons1275) def replacement2254(p, m, f, b, a, x, e): rubi.append(2254) return Dist(b**(-p)/f, Subst(Int((a - x)**(p/S(2) + S(-1)/2)*(a + x)**(m + p/S(2) + S(-1)/2), x), x, b*sin(e + f*x)), x) rule2254 = ReplacementRule(pattern2254, replacement2254) pattern2255 = Pattern(Integral((a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0)))**WC('p', S(1)), x_), cons2, cons3, cons48, cons125, cons21, cons1274, cons1265, cons1275) def replacement2255(p, m, f, b, a, x, e): rubi.append(2255) return -Dist(b**(-p)/f, Subst(Int((a - x)**(p/S(2) + S(-1)/2)*(a + x)**(m + p/S(2) + S(-1)/2), x), x, b*cos(e + f*x)), x) rule2255 = ReplacementRule(pattern2255, replacement2255) pattern2256 = Pattern(Integral((a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0)))**WC('p', S(1)), x_), cons2, cons3, cons48, cons125, cons21, cons1274, cons1267) def replacement2256(p, m, f, b, a, x, e): rubi.append(2256) return Dist(b**(-p)/f, Subst(Int((a + x)**m*(b**S(2) - x**S(2))**(p/S(2) + S(-1)/2), x), x, b*sin(e + f*x)), x) rule2256 = ReplacementRule(pattern2256, replacement2256) pattern2257 = Pattern(Integral((a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0)))**WC('p', S(1)), x_), cons2, cons3, cons48, cons125, cons21, cons1274, cons1267) def replacement2257(p, m, f, b, a, x, e): rubi.append(2257) return -Dist(b**(-p)/f, Subst(Int((a + x)**m*(b**S(2) - x**S(2))**(p/S(2) + S(-1)/2), x), x, b*cos(e + f*x)), x) rule2257 = ReplacementRule(pattern2257, replacement2257) pattern2258 = Pattern(Integral((WC('g', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**p_*(a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons48, cons125, cons208, cons5, cons1276) def replacement2258(p, f, b, g, a, x, e): rubi.append(2258) return Dist(a, Int((g*cos(e + f*x))**p, x), x) - Simp(b*(g*cos(e + f*x))**(p + S(1))/(f*g*(p + S(1))), x) rule2258 = ReplacementRule(pattern2258, replacement2258) pattern2259 = Pattern(Integral((WC('g', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**p_*(a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons48, cons125, cons208, cons5, cons1276) def replacement2259(p, f, b, g, a, x, e): rubi.append(2259) return Dist(a, Int((g*sin(e + f*x))**p, x), x) + Simp(b*(g*sin(e + f*x))**(p + S(1))/(f*g*(p + S(1))), x) rule2259 = ReplacementRule(pattern2259, replacement2259) pattern2260 = Pattern(Integral((WC('g', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**p_*(a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_, x_), cons2, cons3, cons48, cons125, cons208, cons1265, cons17, cons13, cons137, cons1277) def replacement2260(p, m, f, b, g, a, x, e): rubi.append(2260) return Dist((a/g)**(S(2)*m), Int((g*cos(e + f*x))**(S(2)*m + p)*(a - b*sin(e + f*x))**(-m), x), x) rule2260 = ReplacementRule(pattern2260, replacement2260) pattern2261 = Pattern(Integral((WC('g', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**p_*(a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_, x_), cons2, cons3, cons48, cons125, cons208, cons1265, cons17, cons13, cons137, cons1277) def replacement2261(p, m, f, b, g, a, x, e): rubi.append(2261) return Dist((a/g)**(S(2)*m), Int((g*sin(e + f*x))**(S(2)*m + p)*(a - b*cos(e + f*x))**(-m), x), x) rule2261 = ReplacementRule(pattern2261, replacement2261) pattern2262 = Pattern(Integral((WC('g', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**p_*(a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_, x_), cons2, cons3, cons48, cons125, cons208, cons21, cons5, cons1265, cons1278, cons1279) def replacement2262(p, m, f, b, g, a, x, e): rubi.append(2262) return Simp(b*(g*cos(e + f*x))**(p + S(1))*(a + b*sin(e + f*x))**m/(a*f*g*m), x) rule2262 = ReplacementRule(pattern2262, replacement2262) pattern2263 = Pattern(Integral((WC('g', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**p_*(a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_, x_), cons2, cons3, cons48, cons125, cons208, cons21, cons5, cons1265, cons1278, cons1279) def replacement2263(p, m, f, b, g, a, x, e): rubi.append(2263) return -Simp(b*(g*sin(e + f*x))**(p + S(1))*(a + b*cos(e + f*x))**m/(a*f*g*m), x) rule2263 = ReplacementRule(pattern2263, replacement2263) pattern2264 = Pattern(Integral((WC('g', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**p_*(a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_, x_), cons2, cons3, cons48, cons125, cons208, cons21, cons5, cons1265, cons1280, cons1281, cons143) def replacement2264(p, m, f, b, g, a, x, e): rubi.append(2264) return Dist((m + p + S(1))/(a*(S(2)*m + p + S(1))), Int((g*cos(e + f*x))**p*(a + b*sin(e + f*x))**(m + S(1)), x), x) + Simp(b*(g*cos(e + f*x))**(p + S(1))*(a + b*sin(e + f*x))**m/(a*f*g*(S(2)*m + p + S(1))), x) rule2264 = ReplacementRule(pattern2264, replacement2264) pattern2265 = Pattern(Integral((WC('g', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**p_*(a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_, x_), cons2, cons3, cons48, cons125, cons208, cons21, cons5, cons1265, cons1280, cons1281, cons143) def replacement2265(p, m, f, b, g, a, x, e): rubi.append(2265) return Dist((m + p + S(1))/(a*(S(2)*m + p + S(1))), Int((g*sin(e + f*x))**p*(a + b*cos(e + f*x))**(m + S(1)), x), x) - Simp(b*(g*sin(e + f*x))**(p + S(1))*(a + b*cos(e + f*x))**m/(a*f*g*(S(2)*m + p + S(1))), x) rule2265 = ReplacementRule(pattern2265, replacement2265) pattern2266 = Pattern(Integral((WC('g', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**p_*(a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_, x_), cons2, cons3, cons48, cons125, cons208, cons21, cons5, cons1265, cons1282, cons1283) def replacement2266(p, m, f, b, g, a, x, e): rubi.append(2266) return Simp(b*(g*cos(e + f*x))**(p + S(1))*(a + b*sin(e + f*x))**(m + S(-1))/(f*g*(m + S(-1))), x) rule2266 = ReplacementRule(pattern2266, replacement2266) pattern2267 = Pattern(Integral((WC('g', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**p_*(a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_, x_), cons2, cons3, cons48, cons125, cons208, cons21, cons5, cons1265, cons1282, cons1283) def replacement2267(p, m, f, b, g, a, x, e): rubi.append(2267) return -Simp(b*(g*sin(e + f*x))**(p + S(1))*(a + b*cos(e + f*x))**(m + S(-1))/(f*g*(m + S(-1))), x) rule2267 = ReplacementRule(pattern2267, replacement2267) pattern2268 = Pattern(Integral((WC('g', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**p_*(a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_, x_), cons2, cons3, cons48, cons125, cons208, cons21, cons5, cons1265, cons1284, cons1285) def replacement2268(p, m, f, b, g, a, x, e): rubi.append(2268) return Dist(a*(S(2)*m + p + S(-1))/(m + p), Int((g*cos(e + f*x))**p*(a + b*sin(e + f*x))**(m + S(-1)), x), x) - Simp(b*(g*cos(e + f*x))**(p + S(1))*(a + b*sin(e + f*x))**(m + S(-1))/(f*g*(m + p)), x) rule2268 = ReplacementRule(pattern2268, replacement2268) pattern2269 = Pattern(Integral((WC('g', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**p_*(a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_, x_), cons2, cons3, cons48, cons125, cons208, cons21, cons5, cons1265, cons1284, cons1285) def replacement2269(p, m, f, b, g, a, x, e): rubi.append(2269) return Dist(a*(S(2)*m + p + S(-1))/(m + p), Int((g*sin(e + f*x))**p*(a + b*cos(e + f*x))**(m + S(-1)), x), x) + Simp(b*(g*sin(e + f*x))**(p + S(1))*(a + b*cos(e + f*x))**(m + S(-1))/(f*g*(m + p)), x) rule2269 = ReplacementRule(pattern2269, replacement2269) pattern2270 = Pattern(Integral((WC('g', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**p_*(a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_, x_), cons2, cons3, cons48, cons125, cons208, cons1265, cons244, cons168, cons1286, cons1287) def replacement2270(p, m, f, b, g, a, x, e): rubi.append(2270) return Dist(a*(m + p + S(1))/(g**S(2)*(p + S(1))), Int((g*cos(e + f*x))**(p + S(2))*(a + b*sin(e + f*x))**(m + S(-1)), x), x) - Simp(b*(g*cos(e + f*x))**(p + S(1))*(a + b*sin(e + f*x))**m/(a*f*g*(p + S(1))), x) rule2270 = ReplacementRule(pattern2270, replacement2270) pattern2271 = Pattern(Integral((WC('g', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**p_*(a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_, x_), cons2, cons3, cons48, cons125, cons208, cons1265, cons244, cons168, cons1286, cons1287) def replacement2271(p, m, f, b, g, a, x, e): rubi.append(2271) return Dist(a*(m + p + S(1))/(g**S(2)*(p + S(1))), Int((g*sin(e + f*x))**(p + S(2))*(a + b*cos(e + f*x))**(m + S(-1)), x), x) + Simp(b*(g*sin(e + f*x))**(p + S(1))*(a + b*cos(e + f*x))**m/(a*f*g*(p + S(1))), x) rule2271 = ReplacementRule(pattern2271, replacement2271) pattern2272 = Pattern(Integral((WC('g', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**p_*(a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_, x_), cons2, cons3, cons48, cons125, cons208, cons1265, cons244, cons166, cons137, cons1288) def replacement2272(p, m, f, b, g, a, x, e): rubi.append(2272) return Dist(b**S(2)*(S(2)*m + p + S(-1))/(g**S(2)*(p + S(1))), Int((g*cos(e + f*x))**(p + S(2))*(a + b*sin(e + f*x))**(m + S(-2)), x), x) + Simp(-S(2)*b*(g*cos(e + f*x))**(p + S(1))*(a + b*sin(e + f*x))**(m + S(-1))/(f*g*(p + S(1))), x) rule2272 = ReplacementRule(pattern2272, replacement2272) pattern2273 = Pattern(Integral((WC('g', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**p_*(a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_, x_), cons2, cons3, cons48, cons125, cons208, cons1265, cons244, cons166, cons137, cons1288) def replacement2273(p, m, f, b, g, a, x, e): rubi.append(2273) return Dist(b**S(2)*(S(2)*m + p + S(-1))/(g**S(2)*(p + S(1))), Int((g*sin(e + f*x))**(p + S(2))*(a + b*cos(e + f*x))**(m + S(-2)), x), x) + Simp(S(2)*b*(g*sin(e + f*x))**(p + S(1))*(a + b*cos(e + f*x))**(m + S(-1))/(f*g*(p + S(1))), x) rule2273 = ReplacementRule(pattern2273, replacement2273) pattern2274 = Pattern(Integral(sqrt(a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))/sqrt(WC('g', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons48, cons125, cons208, cons1265) def replacement2274(f, b, g, a, x, e): rubi.append(2274) return Dist(a*sqrt(a + b*sin(e + f*x))*sqrt(cos(e + f*x) + S(1))/(a*cos(e + f*x) + a + b*sin(e + f*x)), Int(sqrt(cos(e + f*x) + S(1))/sqrt(g*cos(e + f*x)), x), x) + Dist(b*sqrt(a + b*sin(e + f*x))*sqrt(cos(e + f*x) + S(1))/(a*cos(e + f*x) + a + b*sin(e + f*x)), Int(sin(e + f*x)/(sqrt(g*cos(e + f*x))*sqrt(cos(e + f*x) + S(1))), x), x) rule2274 = ReplacementRule(pattern2274, replacement2274) pattern2275 = Pattern(Integral(sqrt(a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))/sqrt(WC('g', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons48, cons125, cons208, cons1265) def replacement2275(f, b, g, a, x, e): rubi.append(2275) return Dist(a*sqrt(a + b*cos(e + f*x))*sqrt(sin(e + f*x) + S(1))/(a*sin(e + f*x) + a + b*cos(e + f*x)), Int(sqrt(sin(e + f*x) + S(1))/sqrt(g*sin(e + f*x)), x), x) + Dist(b*sqrt(a + b*cos(e + f*x))*sqrt(sin(e + f*x) + S(1))/(a*sin(e + f*x) + a + b*cos(e + f*x)), Int(cos(e + f*x)/(sqrt(g*sin(e + f*x))*sqrt(sin(e + f*x) + S(1))), x), x) rule2275 = ReplacementRule(pattern2275, replacement2275) pattern2276 = Pattern(Integral((WC('g', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**p_*(a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_, x_), cons2, cons3, cons48, cons125, cons208, cons21, cons5, cons1265, cons31, cons168, cons1285, cons1288) def replacement2276(p, m, f, b, g, a, x, e): rubi.append(2276) return Dist(a*(S(2)*m + p + S(-1))/(m + p), Int((g*cos(e + f*x))**p*(a + b*sin(e + f*x))**(m + S(-1)), x), x) - Simp(b*(g*cos(e + f*x))**(p + S(1))*(a + b*sin(e + f*x))**(m + S(-1))/(f*g*(m + p)), x) rule2276 = ReplacementRule(pattern2276, replacement2276) pattern2277 = Pattern(Integral((WC('g', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**p_*(a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_, x_), cons2, cons3, cons48, cons125, cons208, cons21, cons5, cons1265, cons31, cons168, cons1285, cons1288) def replacement2277(p, m, f, b, g, a, x, e): rubi.append(2277) return Dist(a*(S(2)*m + p + S(-1))/(m + p), Int((g*sin(e + f*x))**p*(a + b*cos(e + f*x))**(m + S(-1)), x), x) + Simp(b*(g*sin(e + f*x))**(p + S(1))*(a + b*cos(e + f*x))**(m + S(-1))/(f*g*(m + p)), x) rule2277 = ReplacementRule(pattern2277, replacement2277) pattern2278 = Pattern(Integral((WC('g', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**p_*(a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_, x_), cons2, cons3, cons48, cons125, cons208, cons1265, cons244, cons94, cons146, cons1289, cons1285, cons1288) def replacement2278(p, m, f, b, g, a, x, e): rubi.append(2278) return Dist(g**S(2)*(p + S(-1))/(a*(m + p)), Int((g*cos(e + f*x))**(p + S(-2))*(a + b*sin(e + f*x))**(m + S(1)), x), x) + Simp(g*(g*cos(e + f*x))**(p + S(-1))*(a + b*sin(e + f*x))**(m + S(1))/(b*f*(m + p)), x) rule2278 = ReplacementRule(pattern2278, replacement2278) pattern2279 = Pattern(Integral((WC('g', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**p_*(a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_, x_), cons2, cons3, cons48, cons125, cons208, cons1265, cons244, cons94, cons146, cons1289, cons1285, cons1288) def replacement2279(p, m, f, b, g, a, x, e): rubi.append(2279) return Dist(g**S(2)*(p + S(-1))/(a*(m + p)), Int((g*sin(e + f*x))**(p + S(-2))*(a + b*cos(e + f*x))**(m + S(1)), x), x) - Simp(g*(g*sin(e + f*x))**(p + S(-1))*(a + b*cos(e + f*x))**(m + S(1))/(b*f*(m + p)), x) rule2279 = ReplacementRule(pattern2279, replacement2279) pattern2280 = Pattern(Integral((WC('g', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**p_*(a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_, x_), cons2, cons3, cons48, cons125, cons208, cons1265, cons244, cons1290, cons146, cons1281, cons1291, cons1288) def replacement2280(p, m, f, b, g, a, x, e): rubi.append(2280) return Dist(g**S(2)*(p + S(-1))/(b**S(2)*(S(2)*m + p + S(1))), Int((g*cos(e + f*x))**(p + S(-2))*(a + b*sin(e + f*x))**(m + S(2)), x), x) + Simp(S(2)*g*(g*cos(e + f*x))**(p + S(-1))*(a + b*sin(e + f*x))**(m + S(1))/(b*f*(S(2)*m + p + S(1))), x) rule2280 = ReplacementRule(pattern2280, replacement2280) pattern2281 = Pattern(Integral((WC('g', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**p_*(a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_, x_), cons2, cons3, cons48, cons125, cons208, cons1265, cons244, cons1290, cons146, cons1281, cons1291, cons1288) def replacement2281(p, m, f, b, g, a, x, e): rubi.append(2281) return Dist(g**S(2)*(p + S(-1))/(b**S(2)*(S(2)*m + p + S(1))), Int((g*sin(e + f*x))**(p + S(-2))*(a + b*cos(e + f*x))**(m + S(2)), x), x) + Simp(-S(2)*g*(g*sin(e + f*x))**(p + S(-1))*(a + b*cos(e + f*x))**(m + S(1))/(b*f*(S(2)*m + p + S(1))), x) rule2281 = ReplacementRule(pattern2281, replacement2281) pattern2282 = Pattern(Integral((WC('g', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**p_*(a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_, x_), cons2, cons3, cons48, cons125, cons208, cons21, cons5, cons1265, cons31, cons94, cons1281, cons1288) def replacement2282(p, m, f, b, g, a, x, e): rubi.append(2282) return Dist((m + p + S(1))/(a*(S(2)*m + p + S(1))), Int((g*cos(e + f*x))**p*(a + b*sin(e + f*x))**(m + S(1)), x), x) + Simp(b*(g*cos(e + f*x))**(p + S(1))*(a + b*sin(e + f*x))**m/(a*f*g*(S(2)*m + p + S(1))), x) rule2282 = ReplacementRule(pattern2282, replacement2282) pattern2283 = Pattern(Integral((WC('g', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**p_*(a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_, x_), cons2, cons3, cons48, cons125, cons208, cons21, cons5, cons1265, cons31, cons94, cons1281, cons1288) def replacement2283(p, m, f, b, g, a, x, e): rubi.append(2283) return Dist((m + p + S(1))/(a*(S(2)*m + p + S(1))), Int((g*sin(e + f*x))**p*(a + b*cos(e + f*x))**(m + S(1)), x), x) - Simp(b*(g*sin(e + f*x))**(p + S(1))*(a + b*cos(e + f*x))**m/(a*f*g*(S(2)*m + p + S(1))), x) rule2283 = ReplacementRule(pattern2283, replacement2283) pattern2284 = Pattern(Integral((WC('g', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**p_/(a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons48, cons125, cons208, cons1265, cons13, cons146, cons246) def replacement2284(p, f, b, g, a, x, e): rubi.append(2284) return Dist(g**S(2)/a, Int((g*cos(e + f*x))**(p + S(-2)), x), x) + Simp(g*(g*cos(e + f*x))**(p + S(-1))/(b*f*(p + S(-1))), x) rule2284 = ReplacementRule(pattern2284, replacement2284) pattern2285 = Pattern(Integral((WC('g', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**p_/(a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons48, cons125, cons208, cons1265, cons13, cons146, cons246) def replacement2285(p, f, b, g, a, x, e): rubi.append(2285) return Dist(g**S(2)/a, Int((g*sin(e + f*x))**(p + S(-2)), x), x) - Simp(g*(g*sin(e + f*x))**(p + S(-1))/(b*f*(p + S(-1))), x) rule2285 = ReplacementRule(pattern2285, replacement2285) pattern2286 = Pattern(Integral((WC('g', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**p_/(a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons48, cons125, cons208, cons5, cons1265, cons1292, cons246) def replacement2286(p, f, b, g, a, x, e): rubi.append(2286) return Dist(p/(a*(p + S(-1))), Int((g*cos(e + f*x))**p, x), x) + Simp(b*(g*cos(e + f*x))**(p + S(1))/(a*f*g*(a + b*sin(e + f*x))*(p + S(-1))), x) rule2286 = ReplacementRule(pattern2286, replacement2286) pattern2287 = Pattern(Integral((WC('g', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**p_/(a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons48, cons125, cons208, cons5, cons1265, cons1292, cons246) def replacement2287(p, f, b, g, a, x, e): rubi.append(2287) return Dist(p/(a*(p + S(-1))), Int((g*sin(e + f*x))**p, x), x) - Simp(b*(g*sin(e + f*x))**(p + S(1))/(a*f*g*(a + b*cos(e + f*x))*(p + S(-1))), x) rule2287 = ReplacementRule(pattern2287, replacement2287) pattern2288 = Pattern(Integral(sqrt(WC('g', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))/sqrt(a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons48, cons125, cons208, cons1265) def replacement2288(f, b, g, a, x, e): rubi.append(2288) return -Dist(g*sqrt(a + b*sin(e + f*x))*sqrt(cos(e + f*x) + S(1))/(a*sin(e + f*x) + b*cos(e + f*x) + b), Int(sin(e + f*x)/(sqrt(g*cos(e + f*x))*sqrt(cos(e + f*x) + S(1))), x), x) + Dist(g*sqrt(a + b*sin(e + f*x))*sqrt(cos(e + f*x) + S(1))/(a*cos(e + f*x) + a + b*sin(e + f*x)), Int(sqrt(cos(e + f*x) + S(1))/sqrt(g*cos(e + f*x)), x), x) rule2288 = ReplacementRule(pattern2288, replacement2288) pattern2289 = Pattern(Integral(sqrt(WC('g', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))/sqrt(a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons48, cons125, cons208, cons1265) def replacement2289(f, b, g, a, x, e): rubi.append(2289) return Dist(g*sqrt(a + b*cos(e + f*x))*sqrt(sin(e + f*x) + S(1))/(a*sin(e + f*x) + a + b*cos(e + f*x)), Int(sqrt(sin(e + f*x) + S(1))/sqrt(g*sin(e + f*x)), x), x) - Dist(g*sqrt(a + b*cos(e + f*x))*sqrt(sin(e + f*x) + S(1))/(a*cos(e + f*x) + b*sin(e + f*x) + b), Int(cos(e + f*x)/(sqrt(g*sin(e + f*x))*sqrt(sin(e + f*x) + S(1))), x), x) rule2289 = ReplacementRule(pattern2289, replacement2289) pattern2290 = Pattern(Integral((WC('g', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**(S(3)/2)/sqrt(a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons48, cons125, cons208, cons1265) def replacement2290(f, b, g, a, x, e): rubi.append(2290) return Dist(g**S(2)/(S(2)*a), Int(sqrt(a + b*sin(e + f*x))/sqrt(g*cos(e + f*x)), x), x) + Simp(g*sqrt(g*cos(e + f*x))*sqrt(a + b*sin(e + f*x))/(b*f), x) rule2290 = ReplacementRule(pattern2290, replacement2290) pattern2291 = Pattern(Integral((WC('g', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**(S(3)/2)/sqrt(a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons48, cons125, cons208, cons1265) def replacement2291(f, b, g, a, x, e): rubi.append(2291) return Dist(g**S(2)/(S(2)*a), Int(sqrt(a + b*cos(e + f*x))/sqrt(g*sin(e + f*x)), x), x) - Simp(g*sqrt(g*sin(e + f*x))*sqrt(a + b*cos(e + f*x))/(b*f), x) rule2291 = ReplacementRule(pattern2291, replacement2291) pattern2292 = Pattern(Integral((WC('g', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**p_/sqrt(a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons48, cons125, cons208, cons1265, cons13, cons1293, cons246) def replacement2292(p, f, b, g, a, x, e): rubi.append(2292) return Dist(S(2)*a*(p + S(-2))/(S(2)*p + S(-1)), Int((g*cos(e + f*x))**p/(a + b*sin(e + f*x))**(S(3)/2), x), x) + Simp(-S(2)*b*(g*cos(e + f*x))**(p + S(1))/(f*g*(a + b*sin(e + f*x))**(S(3)/2)*(S(2)*p + S(-1))), x) rule2292 = ReplacementRule(pattern2292, replacement2292) pattern2293 = Pattern(Integral((WC('g', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**p_/sqrt(a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons48, cons125, cons208, cons1265, cons13, cons1293, cons246) def replacement2293(p, f, b, g, a, x, e): rubi.append(2293) return Dist(S(2)*a*(p + S(-2))/(S(2)*p + S(-1)), Int((g*sin(e + f*x))**p/(a + b*cos(e + f*x))**(S(3)/2), x), x) + Simp(S(2)*b*(g*sin(e + f*x))**(p + S(1))/(f*g*(a + b*cos(e + f*x))**(S(3)/2)*(S(2)*p + S(-1))), x) rule2293 = ReplacementRule(pattern2293, replacement2293) pattern2294 = Pattern(Integral((WC('g', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**p_/sqrt(a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons48, cons125, cons208, cons1265, cons13, cons137, cons246) def replacement2294(p, f, b, g, a, x, e): rubi.append(2294) return Dist(a*(S(2)*p + S(1))/(S(2)*g**S(2)*(p + S(1))), Int((g*cos(e + f*x))**(p + S(2))/(a + b*sin(e + f*x))**(S(3)/2), x), x) - Simp(b*(g*cos(e + f*x))**(p + S(1))/(a*f*g*sqrt(a + b*sin(e + f*x))*(p + S(1))), x) rule2294 = ReplacementRule(pattern2294, replacement2294) pattern2295 = Pattern(Integral((WC('g', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**p_/sqrt(a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons48, cons125, cons208, cons1265, cons13, cons137, cons246) def replacement2295(p, f, b, g, a, x, e): rubi.append(2295) return Dist(a*(S(2)*p + S(1))/(S(2)*g**S(2)*(p + S(1))), Int((g*sin(e + f*x))**(p + S(2))/(a + b*cos(e + f*x))**(S(3)/2), x), x) + Simp(b*(g*sin(e + f*x))**(p + S(1))/(a*f*g*sqrt(a + b*cos(e + f*x))*(p + S(1))), x) rule2295 = ReplacementRule(pattern2295, replacement2295) pattern2296 = Pattern(Integral((WC('g', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**p_*(a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1)), x_), cons2, cons3, cons48, cons125, cons208, cons5, cons1265, cons17) def replacement2296(p, m, f, b, g, a, x, e): rubi.append(2296) return Dist(a**m*(g*cos(e + f*x))**(p + S(1))*(-sin(e + f*x) + S(1))**(-p/S(2) + S(-1)/2)*(sin(e + f*x) + S(1))**(-p/S(2) + S(-1)/2)/(f*g), Subst(Int((S(1) - b*x/a)**(p/S(2) + S(-1)/2)*(S(1) + b*x/a)**(m + p/S(2) + S(-1)/2), x), x, sin(e + f*x)), x) rule2296 = ReplacementRule(pattern2296, replacement2296) pattern2297 = Pattern(Integral((WC('g', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**p_*(a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1)), x_), cons2, cons3, cons48, cons125, cons208, cons5, cons1265, cons17) def replacement2297(p, m, f, b, g, a, x, e): rubi.append(2297) return -Dist(a**m*(g*sin(e + f*x))**(p + S(1))*(-cos(e + f*x) + S(1))**(-p/S(2) + S(-1)/2)*(cos(e + f*x) + S(1))**(-p/S(2) + S(-1)/2)/(f*g), Subst(Int((S(1) - b*x/a)**(p/S(2) + S(-1)/2)*(S(1) + b*x/a)**(m + p/S(2) + S(-1)/2), x), x, cos(e + f*x)), x) rule2297 = ReplacementRule(pattern2297, replacement2297) pattern2298 = Pattern(Integral((WC('g', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**p_*(a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1)), x_), cons2, cons3, cons48, cons125, cons208, cons21, cons5, cons1265, cons18) def replacement2298(p, m, f, b, g, a, x, e): rubi.append(2298) return Dist(a**S(2)*(g*cos(e + f*x))**(p + S(1))*(a - b*sin(e + f*x))**(-p/S(2) + S(-1)/2)*(a + b*sin(e + f*x))**(-p/S(2) + S(-1)/2)/(f*g), Subst(Int((a - b*x)**(p/S(2) + S(-1)/2)*(a + b*x)**(m + p/S(2) + S(-1)/2), x), x, sin(e + f*x)), x) rule2298 = ReplacementRule(pattern2298, replacement2298) pattern2299 = Pattern(Integral((WC('g', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**p_*(a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1)), x_), cons2, cons3, cons48, cons125, cons208, cons21, cons5, cons1265, cons18) def replacement2299(p, m, f, b, g, a, x, e): rubi.append(2299) return -Dist(a**S(2)*(g*sin(e + f*x))**(p + S(1))*(a - b*cos(e + f*x))**(-p/S(2) + S(-1)/2)*(a + b*cos(e + f*x))**(-p/S(2) + S(-1)/2)/(f*g), Subst(Int((a - b*x)**(p/S(2) + S(-1)/2)*(a + b*x)**(m + p/S(2) + S(-1)/2), x), x, cos(e + f*x)), x) rule2299 = ReplacementRule(pattern2299, replacement2299) pattern2300 = Pattern(Integral((WC('g', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**p_*(a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_, x_), cons2, cons3, cons48, cons125, cons208, cons1267, cons244, cons1256, cons137, cons1294) def replacement2300(p, m, f, b, g, a, x, e): rubi.append(2300) return Dist(S(1)/(g**S(2)*(p + S(1))), Int((g*cos(e + f*x))**(p + S(2))*(a + b*sin(e + f*x))**(m + S(-1))*(a*(p + S(2)) + b*(m + p + S(2))*sin(e + f*x)), x), x) - Simp((g*cos(e + f*x))**(p + S(1))*(a + b*sin(e + f*x))**m*sin(e + f*x)/(f*g*(p + S(1))), x) rule2300 = ReplacementRule(pattern2300, replacement2300) pattern2301 = Pattern(Integral((WC('g', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**p_*(a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_, x_), cons2, cons3, cons48, cons125, cons208, cons1267, cons244, cons1256, cons137, cons1294) def replacement2301(p, m, f, b, g, a, x, e): rubi.append(2301) return Dist(S(1)/(g**S(2)*(p + S(1))), Int((g*sin(e + f*x))**(p + S(2))*(a + b*cos(e + f*x))**(m + S(-1))*(a*(p + S(2)) + b*(m + p + S(2))*cos(e + f*x)), x), x) + Simp((g*sin(e + f*x))**(p + S(1))*(a + b*cos(e + f*x))**m*cos(e + f*x)/(f*g*(p + S(1))), x) rule2301 = ReplacementRule(pattern2301, replacement2301) pattern2302 = Pattern(Integral((WC('g', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**p_*(a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_, x_), cons2, cons3, cons48, cons125, cons208, cons1267, cons244, cons166, cons137, cons1294) def replacement2302(p, m, f, b, g, a, x, e): rubi.append(2302) return Dist(S(1)/(g**S(2)*(p + S(1))), Int((g*cos(e + f*x))**(p + S(2))*(a + b*sin(e + f*x))**(m + S(-2))*(a**S(2)*(p + S(2)) + a*b*(m + p + S(1))*sin(e + f*x) + b**S(2)*(m + S(-1))), x), x) - Simp((g*cos(e + f*x))**(p + S(1))*(a + b*sin(e + f*x))**(m + S(-1))*(a*sin(e + f*x) + b)/(f*g*(p + S(1))), x) rule2302 = ReplacementRule(pattern2302, replacement2302) pattern2303 = Pattern(Integral((WC('g', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**p_*(a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_, x_), cons2, cons3, cons48, cons125, cons208, cons1267, cons244, cons166, cons137, cons1294) def replacement2303(p, m, f, b, g, a, x, e): rubi.append(2303) return Dist(S(1)/(g**S(2)*(p + S(1))), Int((g*sin(e + f*x))**(p + S(2))*(a + b*cos(e + f*x))**(m + S(-2))*(a**S(2)*(p + S(2)) + a*b*(m + p + S(1))*cos(e + f*x) + b**S(2)*(m + S(-1))), x), x) + Simp((g*sin(e + f*x))**(p + S(1))*(a + b*cos(e + f*x))**(m + S(-1))*(a*cos(e + f*x) + b)/(f*g*(p + S(1))), x) rule2303 = ReplacementRule(pattern2303, replacement2303) pattern2304 = Pattern(Integral((WC('g', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**p_*(a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_, x_), cons2, cons3, cons48, cons125, cons208, cons5, cons1267, cons31, cons166, cons1285, cons1294) def replacement2304(p, m, f, b, g, a, x, e): rubi.append(2304) return Dist(S(1)/(m + p), Int((g*cos(e + f*x))**p*(a + b*sin(e + f*x))**(m + S(-2))*(a**S(2)*(m + p) + a*b*(S(2)*m + p + S(-1))*sin(e + f*x) + b**S(2)*(m + S(-1))), x), x) - Simp(b*(g*cos(e + f*x))**(p + S(1))*(a + b*sin(e + f*x))**(m + S(-1))/(f*g*(m + p)), x) rule2304 = ReplacementRule(pattern2304, replacement2304) pattern2305 = Pattern(Integral((WC('g', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**p_*(a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_, x_), cons2, cons3, cons48, cons125, cons208, cons5, cons1267, cons31, cons166, cons1285, cons1294) def replacement2305(p, m, f, b, g, a, x, e): rubi.append(2305) return Dist(S(1)/(m + p), Int((g*sin(e + f*x))**p*(a + b*cos(e + f*x))**(m + S(-2))*(a**S(2)*(m + p) + a*b*(S(2)*m + p + S(-1))*cos(e + f*x) + b**S(2)*(m + S(-1))), x), x) + Simp(b*(g*sin(e + f*x))**(p + S(1))*(a + b*cos(e + f*x))**(m + S(-1))/(f*g*(m + p)), x) rule2305 = ReplacementRule(pattern2305, replacement2305) pattern2306 = Pattern(Integral((WC('g', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**p_*(a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_, x_), cons2, cons3, cons48, cons125, cons208, cons1267, cons244, cons94, cons146, cons1288) def replacement2306(p, m, f, b, g, a, x, e): rubi.append(2306) return Dist(g**S(2)*(p + S(-1))/(b*(m + S(1))), Int((g*cos(e + f*x))**(p + S(-2))*(a + b*sin(e + f*x))**(m + S(1))*sin(e + f*x), x), x) + Simp(g*(g*cos(e + f*x))**(p + S(-1))*(a + b*sin(e + f*x))**(m + S(1))/(b*f*(m + S(1))), x) rule2306 = ReplacementRule(pattern2306, replacement2306) pattern2307 = Pattern(Integral((WC('g', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**p_*(a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_, x_), cons2, cons3, cons48, cons125, cons208, cons1267, cons244, cons94, cons146, cons1288) def replacement2307(p, m, f, b, g, a, x, e): rubi.append(2307) return Dist(g**S(2)*(p + S(-1))/(b*(m + S(1))), Int((g*sin(e + f*x))**(p + S(-2))*(a + b*cos(e + f*x))**(m + S(1))*cos(e + f*x), x), x) - Simp(g*(g*sin(e + f*x))**(p + S(-1))*(a + b*cos(e + f*x))**(m + S(1))/(b*f*(m + S(1))), x) rule2307 = ReplacementRule(pattern2307, replacement2307) pattern2308 = Pattern(Integral((WC('g', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**p_*(a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_, x_), cons2, cons3, cons48, cons125, cons208, cons5, cons1267, cons31, cons94, cons1288) def replacement2308(p, m, f, b, g, a, x, e): rubi.append(2308) return Dist(S(1)/((a**S(2) - b**S(2))*(m + S(1))), Int((g*cos(e + f*x))**p*(a + b*sin(e + f*x))**(m + S(1))*(a*(m + S(1)) - b*(m + p + S(2))*sin(e + f*x)), x), x) - Simp(b*(g*cos(e + f*x))**(p + S(1))*(a + b*sin(e + f*x))**(m + S(1))/(f*g*(a**S(2) - b**S(2))*(m + S(1))), x) rule2308 = ReplacementRule(pattern2308, replacement2308) pattern2309 = Pattern(Integral((WC('g', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**p_*(a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_, x_), cons2, cons3, cons48, cons125, cons208, cons5, cons1267, cons31, cons94, cons1288) def replacement2309(p, m, f, b, g, a, x, e): rubi.append(2309) return Dist(S(1)/((a**S(2) - b**S(2))*(m + S(1))), Int((g*sin(e + f*x))**p*(a + b*cos(e + f*x))**(m + S(1))*(a*(m + S(1)) - b*(m + p + S(2))*cos(e + f*x)), x), x) + Simp(b*(g*sin(e + f*x))**(p + S(1))*(a + b*cos(e + f*x))**(m + S(1))/(f*g*(a**S(2) - b**S(2))*(m + S(1))), x) rule2309 = ReplacementRule(pattern2309, replacement2309) pattern2310 = Pattern(Integral((WC('g', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**p_*(a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_, x_), cons2, cons3, cons48, cons125, cons208, cons21, cons1267, cons13, cons146, cons1285, cons1288) def replacement2310(p, m, f, b, g, a, x, e): rubi.append(2310) return Dist(g**S(2)*(p + S(-1))/(b*(m + p)), Int((g*cos(e + f*x))**(p + S(-2))*(a + b*sin(e + f*x))**m*(a*sin(e + f*x) + b), x), x) + Simp(g*(g*cos(e + f*x))**(p + S(-1))*(a + b*sin(e + f*x))**(m + S(1))/(b*f*(m + p)), x) rule2310 = ReplacementRule(pattern2310, replacement2310) pattern2311 = Pattern(Integral((WC('g', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**p_*(a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_, x_), cons2, cons3, cons48, cons125, cons208, cons21, cons1267, cons13, cons146, cons1285, cons1288) def replacement2311(p, m, f, b, g, a, x, e): rubi.append(2311) return Dist(g**S(2)*(p + S(-1))/(b*(m + p)), Int((g*sin(e + f*x))**(p + S(-2))*(a + b*cos(e + f*x))**m*(a*cos(e + f*x) + b), x), x) - Simp(g*(g*sin(e + f*x))**(p + S(-1))*(a + b*cos(e + f*x))**(m + S(1))/(b*f*(m + p)), x) rule2311 = ReplacementRule(pattern2311, replacement2311) pattern2312 = Pattern(Integral((WC('g', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**p_*(a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_, x_), cons2, cons3, cons48, cons125, cons208, cons21, cons1267, cons13, cons137, cons1288) def replacement2312(p, m, f, b, g, a, x, e): rubi.append(2312) return Dist(S(1)/(g**S(2)*(a**S(2) - b**S(2))*(p + S(1))), Int((g*cos(e + f*x))**(p + S(2))*(a + b*sin(e + f*x))**m*(a**S(2)*(p + S(2)) + a*b*(m + p + S(3))*sin(e + f*x) - b**S(2)*(m + p + S(2))), x), x) + Simp((g*cos(e + f*x))**(p + S(1))*(a + b*sin(e + f*x))**(m + S(1))*(-a*sin(e + f*x) + b)/(f*g*(a**S(2) - b**S(2))*(p + S(1))), x) rule2312 = ReplacementRule(pattern2312, replacement2312) pattern2313 = Pattern(Integral((WC('g', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**p_*(a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_, x_), cons2, cons3, cons48, cons125, cons208, cons21, cons1267, cons13, cons137, cons1288) def replacement2313(p, m, f, b, g, a, x, e): rubi.append(2313) return Dist(S(1)/(g**S(2)*(a**S(2) - b**S(2))*(p + S(1))), Int((g*sin(e + f*x))**(p + S(2))*(a + b*cos(e + f*x))**m*(a**S(2)*(p + S(2)) + a*b*(m + p + S(3))*cos(e + f*x) - b**S(2)*(m + p + S(2))), x), x) - Simp((g*sin(e + f*x))**(p + S(1))*(a + b*cos(e + f*x))**(m + S(1))*(-a*cos(e + f*x) + b)/(f*g*(a**S(2) - b**S(2))*(p + S(1))), x) rule2313 = ReplacementRule(pattern2313, replacement2313) pattern2314 = Pattern(Integral(S(1)/(sqrt(WC('g', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))*sqrt(a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))), x_), cons2, cons3, cons48, cons125, cons208, cons1267) def replacement2314(f, b, g, a, x, e): rubi.append(2314) return Dist(S(2)*sqrt(S(2))*sqrt(g*cos(e + f*x))*sqrt((a + b*sin(e + f*x))/((a - b)*(-sin(e + f*x) + S(1))))/(f*g*sqrt((sin(e + f*x) + cos(e + f*x) + S(1))/(-sin(e + f*x) + cos(e + f*x) + S(1)))*sqrt(a + b*sin(e + f*x))), Subst(Int(S(1)/sqrt(x**S(4)*(a + b)/(a - b) + S(1)), x), x, sqrt((sin(e + f*x) + cos(e + f*x) + S(1))/(-sin(e + f*x) + cos(e + f*x) + S(1)))), x) rule2314 = ReplacementRule(pattern2314, replacement2314) pattern2315 = Pattern(Integral(S(1)/(sqrt(WC('g', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))*sqrt(a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))), x_), cons2, cons3, cons48, cons125, cons208, cons1267) def replacement2315(f, b, g, a, x, e): rubi.append(2315) return Dist(-S(2)*sqrt(S(2))*sqrt(g*sin(e + f*x))*sqrt((a + b*cos(e + f*x))/((a - b)*(-cos(e + f*x) + S(1))))/(f*g*sqrt((sin(e + f*x) + cos(e + f*x) + S(1))/(sin(e + f*x) - cos(e + f*x) + S(1)))*sqrt(a + b*cos(e + f*x))), Subst(Int(S(1)/sqrt(x**S(4)*(a + b)/(a - b) + S(1)), x), x, sqrt((sin(e + f*x) + cos(e + f*x) + S(1))/(sin(e + f*x) - cos(e + f*x) + S(1)))), x) rule2315 = ReplacementRule(pattern2315, replacement2315) pattern2316 = Pattern(Integral((WC('g', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**p_*(a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_, x_), cons2, cons3, cons48, cons125, cons208, cons21, cons5, cons1267, cons1278) def replacement2316(p, m, f, b, g, a, x, e): rubi.append(2316) return Simp(g*(g*cos(e + f*x))**(p + S(-1))*(-(a - b)*(-sin(e + f*x) + S(1))/((a + b)*(sin(e + f*x) + S(1))))**(m/S(2))*(a + b*sin(e + f*x))**(m + S(1))*(-sin(e + f*x) + S(1))*Hypergeometric2F1(m + S(1), m/S(2) + S(1), m + S(2), S(2)*(a + b*sin(e + f*x))/((a + b)*(sin(e + f*x) + S(1))))/(f*(a + b)*(m + S(1))), x) rule2316 = ReplacementRule(pattern2316, replacement2316) pattern2317 = Pattern(Integral((WC('g', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**p_*(a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_, x_), cons2, cons3, cons48, cons125, cons208, cons21, cons5, cons1267, cons1278) def replacement2317(p, m, f, b, g, a, x, e): rubi.append(2317) return -Simp(g*(g*sin(e + f*x))**(p + S(-1))*(-(a - b)*(-cos(e + f*x) + S(1))/((a + b)*(cos(e + f*x) + S(1))))**(m/S(2))*(a + b*cos(e + f*x))**(m + S(1))*(-cos(e + f*x) + S(1))*Hypergeometric2F1(m + S(1), m/S(2) + S(1), m + S(2), S(2)*(a + b*cos(e + f*x))/((a + b)*(cos(e + f*x) + S(1))))/(f*(a + b)*(m + S(1))), x) rule2317 = ReplacementRule(pattern2317, replacement2317) pattern2318 = Pattern(Integral((WC('g', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**p_*(a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_, x_), cons2, cons3, cons48, cons125, cons208, cons21, cons5, cons1267, cons1295) def replacement2318(p, m, f, b, g, a, x, e): rubi.append(2318) return Dist(a/(g**S(2)*(a - b)), Int((g*cos(e + f*x))**(p + S(2))*(a + b*sin(e + f*x))**m/(-sin(e + f*x) + S(1)), x), x) + Simp((g*cos(e + f*x))**(p + S(1))*(a + b*sin(e + f*x))**(m + S(1))/(f*g*(a - b)*(p + S(1))), x) rule2318 = ReplacementRule(pattern2318, replacement2318) pattern2319 = Pattern(Integral((WC('g', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**p_*(a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_, x_), cons2, cons3, cons48, cons125, cons208, cons21, cons5, cons1267, cons1295) def replacement2319(p, m, f, b, g, a, x, e): rubi.append(2319) return Dist(a/(g**S(2)*(a - b)), Int((g*sin(e + f*x))**(p + S(2))*(a + b*cos(e + f*x))**m/(-cos(e + f*x) + S(1)), x), x) - Simp((g*sin(e + f*x))**(p + S(1))*(a + b*cos(e + f*x))**(m + S(1))/(f*g*(a - b)*(p + S(1))), x) rule2319 = ReplacementRule(pattern2319, replacement2319) pattern2320 = Pattern(Integral((WC('g', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**p_*(a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_, x_), cons2, cons3, cons48, cons125, cons208, cons21, cons5, cons1267, cons1296) def replacement2320(p, m, f, b, g, a, x, e): rubi.append(2320) return Dist(a/(g**S(2)*(a - b)), Int((g*cos(e + f*x))**(p + S(2))*(a + b*sin(e + f*x))**m/(-sin(e + f*x) + S(1)), x), x) - Dist(b*(m + p + S(2))/(g**S(2)*(a - b)*(p + S(1))), Int((g*cos(e + f*x))**(p + S(2))*(a + b*sin(e + f*x))**m, x), x) + Simp((g*cos(e + f*x))**(p + S(1))*(a + b*sin(e + f*x))**(m + S(1))/(f*g*(a - b)*(p + S(1))), x) rule2320 = ReplacementRule(pattern2320, replacement2320) pattern2321 = Pattern(Integral((WC('g', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**p_*(a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_, x_), cons2, cons3, cons48, cons125, cons208, cons21, cons5, cons1267, cons1296) def replacement2321(p, m, f, b, g, a, x, e): rubi.append(2321) return Dist(a/(g**S(2)*(a - b)), Int((g*sin(e + f*x))**(p + S(2))*(a + b*cos(e + f*x))**m/(-cos(e + f*x) + S(1)), x), x) - Dist(b*(m + p + S(2))/(g**S(2)*(a - b)*(p + S(1))), Int((g*sin(e + f*x))**(p + S(2))*(a + b*cos(e + f*x))**m, x), x) - Simp((g*sin(e + f*x))**(p + S(1))*(a + b*cos(e + f*x))**(m + S(1))/(f*g*(a - b)*(p + S(1))), x) rule2321 = ReplacementRule(pattern2321, replacement2321) def With2322(f, b, g, a, x, e): q = Rt(-a**S(2) + b**S(2), S(2)) rubi.append(2322) return -Dist(a*g/(S(2)*b), Int(S(1)/(sqrt(g*cos(e + f*x))*(-b*cos(e + f*x) + q)), x), x) + Dist(a*g/(S(2)*b), Int(S(1)/(sqrt(g*cos(e + f*x))*(b*cos(e + f*x) + q)), x), x) + Dist(b*g/f, Subst(Int(sqrt(x)/(b**S(2)*x**S(2) + g**S(2)*(a**S(2) - b**S(2))), x), x, g*cos(e + f*x)), x) pattern2322 = Pattern(Integral(sqrt(WC('g', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))/(a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons48, cons125, cons208, cons1267) rule2322 = ReplacementRule(pattern2322, With2322) def With2323(f, b, g, a, x, e): q = Rt(-a**S(2) + b**S(2), S(2)) rubi.append(2323) return -Dist(a*g/(S(2)*b), Int(S(1)/(sqrt(g*sin(e + f*x))*(-b*sin(e + f*x) + q)), x), x) + Dist(a*g/(S(2)*b), Int(S(1)/(sqrt(g*sin(e + f*x))*(b*sin(e + f*x) + q)), x), x) - Dist(b*g/f, Subst(Int(sqrt(x)/(b**S(2)*x**S(2) + g**S(2)*(a**S(2) - b**S(2))), x), x, g*sin(e + f*x)), x) pattern2323 = Pattern(Integral(sqrt(WC('g', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))/(a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons48, cons125, cons208, cons1267) rule2323 = ReplacementRule(pattern2323, With2323) def With2324(f, b, g, a, x, e): q = Rt(-a**S(2) + b**S(2), S(2)) rubi.append(2324) return -Dist(a/(S(2)*q), Int(S(1)/(sqrt(g*cos(e + f*x))*(-b*cos(e + f*x) + q)), x), x) - Dist(a/(S(2)*q), Int(S(1)/(sqrt(g*cos(e + f*x))*(b*cos(e + f*x) + q)), x), x) + Dist(b*g/f, Subst(Int(S(1)/(sqrt(x)*(b**S(2)*x**S(2) + g**S(2)*(a**S(2) - b**S(2)))), x), x, g*cos(e + f*x)), x) pattern2324 = Pattern(Integral(S(1)/(sqrt(WC('g', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))*(a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))), x_), cons2, cons3, cons48, cons125, cons208, cons1267) rule2324 = ReplacementRule(pattern2324, With2324) def With2325(f, b, g, a, x, e): q = Rt(-a**S(2) + b**S(2), S(2)) rubi.append(2325) return -Dist(a/(S(2)*q), Int(S(1)/(sqrt(g*sin(e + f*x))*(-b*sin(e + f*x) + q)), x), x) - Dist(a/(S(2)*q), Int(S(1)/(sqrt(g*sin(e + f*x))*(b*sin(e + f*x) + q)), x), x) - Dist(b*g/f, Subst(Int(S(1)/(sqrt(x)*(b**S(2)*x**S(2) + g**S(2)*(a**S(2) - b**S(2)))), x), x, g*sin(e + f*x)), x) pattern2325 = Pattern(Integral(S(1)/(sqrt(WC('g', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))*(a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))), x_), cons2, cons3, cons48, cons125, cons208, cons1267) rule2325 = ReplacementRule(pattern2325, With2325) pattern2326 = Pattern(Integral((WC('g', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**p_*(a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_, x_), cons2, cons3, cons48, cons125, cons208, cons5, cons1267, cons84, cons1297) def replacement2326(p, m, f, b, g, a, x, e): rubi.append(2326) return Simp(g*(g*cos(e + f*x))**(p + S(-1))*(b*(sin(e + f*x) + S(1))/(a + b*sin(e + f*x)))**(-p/S(2) + S(1)/2)*(-b*(-sin(e + f*x) + S(1))/(a + b*sin(e + f*x)))**(-p/S(2) + S(1)/2)*(a + b*sin(e + f*x))**(m + S(1))*AppellF1(-m - p, -p/S(2) + S(1)/2, -p/S(2) + S(1)/2, -m - p + S(1), (a + b)/(a + b*sin(e + f*x)), (a - b)/(a + b*sin(e + f*x)))/(b*f*(m + p)), x) rule2326 = ReplacementRule(pattern2326, replacement2326) pattern2327 = Pattern(Integral((WC('g', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**p_*(a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_, x_), cons2, cons3, cons48, cons125, cons208, cons5, cons1267, cons84, cons1297) def replacement2327(p, m, f, b, g, a, x, e): rubi.append(2327) return -Simp(g*(g*sin(e + f*x))**(p + S(-1))*(b*(cos(e + f*x) + S(1))/(a + b*cos(e + f*x)))**(-p/S(2) + S(1)/2)*(-b*(-cos(e + f*x) + S(1))/(a + b*cos(e + f*x)))**(-p/S(2) + S(1)/2)*(a + b*cos(e + f*x))**(m + S(1))*AppellF1(-m - p, -p/S(2) + S(1)/2, -p/S(2) + S(1)/2, -m - p + S(1), (a + b)/(a + b*cos(e + f*x)), (a - b)/(a + b*cos(e + f*x)))/(b*f*(m + p)), x) rule2327 = ReplacementRule(pattern2327, replacement2327) pattern2328 = Pattern(Integral((WC('g', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**p_*(a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_, x_), cons2, cons3, cons48, cons125, cons208, cons21, cons5, cons1267, cons143) def replacement2328(p, m, f, b, g, a, x, e): rubi.append(2328) return Dist(g*(g*cos(e + f*x))**(p + S(-1))*(S(1) - (a + b*sin(e + f*x))/(a - b))**(-p/S(2) + S(1)/2)*(S(1) - (a + b*sin(e + f*x))/(a + b))**(-p/S(2) + S(1)/2)/f, Subst(Int((a + b*x)**m*(-b*x/(a - b) - b/(a - b))**(p/S(2) + S(-1)/2)*(-b*x/(a + b) + b/(a + b))**(p/S(2) + S(-1)/2), x), x, sin(e + f*x)), x) rule2328 = ReplacementRule(pattern2328, replacement2328) pattern2329 = Pattern(Integral((WC('g', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**p_*(a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_, x_), cons2, cons3, cons48, cons125, cons208, cons21, cons5, cons1267, cons143) def replacement2329(p, m, f, b, g, a, x, e): rubi.append(2329) return -Dist(g*(g*sin(e + f*x))**(p + S(-1))*(S(1) - (a + b*cos(e + f*x))/(a - b))**(-p/S(2) + S(1)/2)*(S(1) - (a + b*cos(e + f*x))/(a + b))**(-p/S(2) + S(1)/2)/f, Subst(Int((a + b*x)**m*(-b*x/(a - b) - b/(a - b))**(p/S(2) + S(-1)/2)*(-b*x/(a + b) + b/(a + b))**(p/S(2) + S(-1)/2), x), x, cos(e + f*x)), x) rule2329 = ReplacementRule(pattern2329, replacement2329) pattern2330 = Pattern(Integral((WC('g', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**p_*(a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1)), x_), cons2, cons3, cons48, cons125, cons208, cons21, cons5, cons147) def replacement2330(p, m, f, g, b, a, x, e): rubi.append(2330) return Dist(g**(S(2)*IntPart(p))*(g/cos(e + f*x))**FracPart(p)*(g*cos(e + f*x))**FracPart(p), Int((g*cos(e + f*x))**(-p)*(a + b*sin(e + f*x))**m, x), x) rule2330 = ReplacementRule(pattern2330, replacement2330) pattern2331 = Pattern(Integral((WC('g', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**p_*(a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1)), x_), cons2, cons3, cons48, cons125, cons208, cons21, cons5, cons147) def replacement2331(p, m, f, b, g, a, x, e): rubi.append(2331) return Dist(g**(S(2)*IntPart(p))*(g/sin(e + f*x))**FracPart(p)*(g*sin(e + f*x))**FracPart(p), Int((g*sin(e + f*x))**(-p)*(a + b*cos(e + f*x))**m, x), x) rule2331 = ReplacementRule(pattern2331, replacement2331) pattern2332 = Pattern(Integral((WC('g', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('p', S(1))/(a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons48, cons125, cons208, cons5, cons1265, cons54) def replacement2332(p, f, b, g, a, x, e): rubi.append(2332) return Dist(S(1)/a, Int((g*tan(e + f*x))**p/cos(e + f*x)**S(2), x), x) - Dist(S(1)/(b*g), Int((g*tan(e + f*x))**(p + S(1))/cos(e + f*x), x), x) rule2332 = ReplacementRule(pattern2332, replacement2332) pattern2333 = Pattern(Integral((WC('g', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('p', S(1))/(a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons48, cons125, cons208, cons5, cons1265, cons54) def replacement2333(p, f, b, g, a, x, e): rubi.append(2333) return Dist(S(1)/a, Int((g/tan(e + f*x))**p/sin(e + f*x)**S(2), x), x) - Dist(S(1)/(b*g), Int((g/tan(e + f*x))**(p + S(1))/sin(e + f*x), x), x) rule2333 = ReplacementRule(pattern2333, replacement2333) pattern2334 = Pattern(Integral((a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0)))**WC('p', S(1)), x_), cons2, cons3, cons48, cons125, cons21, cons1265, cons1298) def replacement2334(p, m, f, b, a, x, e): rubi.append(2334) return Dist(S(1)/f, Subst(Int(x**p*(a - x)**(-p/S(2) + S(-1)/2)*(a + x)**(m - p/S(2) + S(-1)/2), x), x, b*sin(e + f*x)), x) rule2334 = ReplacementRule(pattern2334, replacement2334) pattern2335 = Pattern(Integral((a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(S(1)/tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('p', S(1)), x_), cons2, cons3, cons48, cons125, cons21, cons1265, cons1298) def replacement2335(p, m, f, b, a, x, e): rubi.append(2335) return -Dist(S(1)/f, Subst(Int(x**p*(a - x)**(-p/S(2) + S(-1)/2)*(a + x)**(m - p/S(2) + S(-1)/2), x), x, b*cos(e + f*x)), x) rule2335 = ReplacementRule(pattern2335, replacement2335) pattern2336 = Pattern(Integral((a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0)))**p_, x_), cons2, cons3, cons48, cons125, cons1265, cons1299, cons1300) def replacement2336(p, m, f, b, a, x, e): rubi.append(2336) return Dist(a**p, Int((a - b*sin(e + f*x))**(-m)*sin(e + f*x)**p, x), x) rule2336 = ReplacementRule(pattern2336, replacement2336) pattern2337 = Pattern(Integral((a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(S(1)/tan(x_*WC('f', S(1)) + WC('e', S(0))))**p_, x_), cons2, cons3, cons48, cons125, cons1265, cons1299, cons1300) def replacement2337(p, m, f, b, a, x, e): rubi.append(2337) return Dist(a**p, Int((a - b*cos(e + f*x))**(-m)*cos(e + f*x)**p, x), x) rule2337 = ReplacementRule(pattern2337, replacement2337) pattern2338 = Pattern(Integral((a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*tan(x_*WC('f', S(1)) + WC('e', S(0)))**p_, x_), cons2, cons3, cons48, cons125, cons1265, cons1301, cons1302) def replacement2338(p, m, f, b, a, x, e): rubi.append(2338) return Dist(a**p, Int(ExpandIntegrand((a - b*sin(e + f*x))**(-p/S(2))*(a + b*sin(e + f*x))**(m - p/S(2))*sin(e + f*x)**p, x), x), x) rule2338 = ReplacementRule(pattern2338, replacement2338) pattern2339 = Pattern(Integral((a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(S(1)/tan(x_*WC('f', S(1)) + WC('e', S(0))))**p_, x_), cons2, cons3, cons48, cons125, cons1265, cons1301, cons1302) def replacement2339(p, m, f, b, a, x, e): rubi.append(2339) return Dist(a**p, Int(ExpandIntegrand((a - b*cos(e + f*x))**(-p/S(2))*(a + b*cos(e + f*x))**(m - p/S(2))*cos(e + f*x)**p, x), x), x) rule2339 = ReplacementRule(pattern2339, replacement2339) pattern2340 = Pattern(Integral((WC('g', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('p', S(1))*(a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1)), x_), cons2, cons3, cons48, cons125, cons208, cons5, cons1265, cons62) def replacement2340(p, m, f, b, g, a, x, e): rubi.append(2340) return Int(ExpandIntegrand((g*tan(e + f*x))**p, (a + b*sin(e + f*x))**m, x), x) rule2340 = ReplacementRule(pattern2340, replacement2340) pattern2341 = Pattern(Integral((WC('g', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('p', S(1))*(a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1)), x_), cons2, cons3, cons48, cons125, cons208, cons5, cons1265, cons62) def replacement2341(p, m, f, b, g, a, x, e): rubi.append(2341) return Int(ExpandIntegrand((g/tan(e + f*x))**p, (a + b*cos(e + f*x))**m, x), x) rule2341 = ReplacementRule(pattern2341, replacement2341) pattern2342 = Pattern(Integral((WC('g', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('p', S(1))*(a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_, x_), cons2, cons3, cons48, cons125, cons208, cons5, cons1265, cons84) def replacement2342(p, m, f, b, g, a, x, e): rubi.append(2342) return Dist(a**(S(2)*m), Int(ExpandIntegrand((g*tan(e + f*x))**p*(S(1)/cos(e + f*x))**(-m), (a/cos(e + f*x) - b*tan(e + f*x))**(-m), x), x), x) rule2342 = ReplacementRule(pattern2342, replacement2342) pattern2343 = Pattern(Integral((WC('g', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('p', S(1))*(a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_, x_), cons2, cons3, cons48, cons125, cons208, cons5, cons1265, cons84) def replacement2343(p, m, f, b, g, a, x, e): rubi.append(2343) return Dist(a**(S(2)*m), Int(ExpandIntegrand((g/tan(e + f*x))**p*(S(1)/sin(e + f*x))**(-m), (a/sin(e + f*x) - b/tan(e + f*x))**(-m), x), x), x) rule2343 = ReplacementRule(pattern2343, replacement2343) pattern2344 = Pattern(Integral((a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*tan(x_*WC('f', S(1)) + WC('e', S(0)))**S(2), x_), cons2, cons3, cons48, cons125, cons1265, cons18, cons31, cons267) def replacement2344(m, f, b, a, x, e): rubi.append(2344) return -Dist(S(1)/(a**S(2)*(S(2)*m + S(-1))), Int((a + b*sin(e + f*x))**(m + S(1))*(a*m - b*(S(2)*m + S(-1))*sin(e + f*x))/cos(e + f*x)**S(2), x), x) + Simp(b*(a + b*sin(e + f*x))**m/(a*f*(S(2)*m + S(-1))*cos(e + f*x)), x) rule2344 = ReplacementRule(pattern2344, replacement2344) pattern2345 = Pattern(Integral((a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_/tan(x_*WC('f', S(1)) + WC('e', S(0)))**S(2), x_), cons2, cons3, cons48, cons125, cons1265, cons18, cons31, cons267) def replacement2345(m, f, b, a, x, e): rubi.append(2345) return -Dist(S(1)/(a**S(2)*(S(2)*m + S(-1))), Int((a + b*cos(e + f*x))**(m + S(1))*(a*m - b*(S(2)*m + S(-1))*cos(e + f*x))/sin(e + f*x)**S(2), x), x) - Simp(b*(a + b*cos(e + f*x))**m/(a*f*(S(2)*m + S(-1))*sin(e + f*x)), x) rule2345 = ReplacementRule(pattern2345, replacement2345) pattern2346 = Pattern(Integral((a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*tan(x_*WC('f', S(1)) + WC('e', S(0)))**S(2), x_), cons2, cons3, cons48, cons125, cons21, cons1265, cons18, cons1303) def replacement2346(m, f, b, a, x, e): rubi.append(2346) return Dist(S(1)/(b*m), Int((a + b*sin(e + f*x))**m*(a*sin(e + f*x) + b*(m + S(1)))/cos(e + f*x)**S(2), x), x) - Simp((a + b*sin(e + f*x))**(m + S(1))/(b*f*m*cos(e + f*x)), x) rule2346 = ReplacementRule(pattern2346, replacement2346) pattern2347 = Pattern(Integral((a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_/tan(x_*WC('f', S(1)) + WC('e', S(0)))**S(2), x_), cons2, cons3, cons48, cons125, cons21, cons1265, cons18, cons1303) def replacement2347(m, f, b, a, x, e): rubi.append(2347) return Dist(S(1)/(b*m), Int((a + b*cos(e + f*x))**m*(a*cos(e + f*x) + b*(m + S(1)))/sin(e + f*x)**S(2), x), x) + Simp((a + b*cos(e + f*x))**(m + S(1))/(b*f*m*sin(e + f*x)), x) rule2347 = ReplacementRule(pattern2347, replacement2347) pattern2348 = Pattern(Integral((a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*tan(x_*WC('f', S(1)) + WC('e', S(0)))**S(4), x_), cons2, cons3, cons48, cons125, cons21, cons1265, cons1304) def replacement2348(m, f, b, a, x, e): rubi.append(2348) return -Int((a + b*sin(e + f*x))**m*(-S(2)*sin(e + f*x)**S(2) + S(1))/cos(e + f*x)**S(4), x) + Int((a + b*sin(e + f*x))**m, x) rule2348 = ReplacementRule(pattern2348, replacement2348) pattern2349 = Pattern(Integral((a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_/tan(x_*WC('f', S(1)) + WC('e', S(0)))**S(4), x_), cons2, cons3, cons48, cons125, cons21, cons1265, cons1304) def replacement2349(m, f, b, a, x, e): rubi.append(2349) return -Int((a + b*cos(e + f*x))**m*(-S(2)*cos(e + f*x)**S(2) + S(1))/sin(e + f*x)**S(4), x) + Int((a + b*cos(e + f*x))**m, x) rule2349 = ReplacementRule(pattern2349, replacement2349) pattern2350 = Pattern(Integral((a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_/tan(x_*WC('f', S(1)) + WC('e', S(0)))**S(2), x_), cons2, cons3, cons48, cons125, cons1265, cons1304, cons94) def replacement2350(m, f, b, a, x, e): rubi.append(2350) return Dist(b**(S(-2)), Int((a + b*sin(e + f*x))**(m + S(1))*(-a*(m + S(1))*sin(e + f*x) + b*m)/sin(e + f*x), x), x) - Simp((a + b*sin(e + f*x))**(m + S(1))/(a*f*tan(e + f*x)), x) rule2350 = ReplacementRule(pattern2350, replacement2350) pattern2351 = Pattern(Integral((a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*tan(x_*WC('f', S(1)) + WC('e', S(0)))**S(2), x_), cons2, cons3, cons48, cons125, cons1265, cons1304, cons94) def replacement2351(m, f, b, a, x, e): rubi.append(2351) return Dist(b**(S(-2)), Int((a + b*cos(e + f*x))**(m + S(1))*(-a*(m + S(1))*cos(e + f*x) + b*m)/cos(e + f*x), x), x) + Simp((a + b*cos(e + f*x))**(m + S(1))*tan(e + f*x)/(a*f), x) rule2351 = ReplacementRule(pattern2351, replacement2351) pattern2352 = Pattern(Integral((a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0)))**S(2), x_), cons2, cons3, cons48, cons125, cons21, cons1265, cons1304, cons1305) def replacement2352(m, f, b, a, x, e): rubi.append(2352) return Dist(S(1)/a, Int((a + b*sin(e + f*x))**m*(-a*(m + S(1))*sin(e + f*x) + b*m)/sin(e + f*x), x), x) - Simp((a + b*sin(e + f*x))**m/(f*tan(e + f*x)), x) rule2352 = ReplacementRule(pattern2352, replacement2352) pattern2353 = Pattern(Integral((a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0)))**S(2), x_), cons2, cons3, cons48, cons125, cons21, cons1265, cons1304, cons1305) def replacement2353(m, f, b, a, x, e): rubi.append(2353) return Dist(S(1)/a, Int((a + b*cos(e + f*x))**m*(-a*(m + S(1))*cos(e + f*x) + b*m)/cos(e + f*x), x), x) + Simp((a + b*cos(e + f*x))**m*tan(e + f*x)/f, x) rule2353 = ReplacementRule(pattern2353, replacement2353) pattern2354 = Pattern(Integral((a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_/tan(x_*WC('f', S(1)) + WC('e', S(0)))**S(4), x_), cons2, cons3, cons48, cons125, cons1265, cons1304, cons94) def replacement2354(m, f, b, a, x, e): rubi.append(2354) return Dist(a**(S(-2)), Int((a + b*sin(e + f*x))**(m + S(2))*(sin(e + f*x)**S(2) + S(1))/sin(e + f*x)**S(4), x), x) + Dist(-S(2)/(a*b), Int((a + b*sin(e + f*x))**(m + S(2))/sin(e + f*x)**S(3), x), x) rule2354 = ReplacementRule(pattern2354, replacement2354) pattern2355 = Pattern(Integral((a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*tan(x_*WC('f', S(1)) + WC('e', S(0)))**S(4), x_), cons2, cons3, cons48, cons125, cons1265, cons1304, cons94) def replacement2355(m, f, b, a, x, e): rubi.append(2355) return Dist(a**(S(-2)), Int((a + b*cos(e + f*x))**(m + S(2))*(cos(e + f*x)**S(2) + S(1))/cos(e + f*x)**S(4), x), x) + Dist(-S(2)/(a*b), Int((a + b*cos(e + f*x))**(m + S(2))/cos(e + f*x)**S(3), x), x) rule2355 = ReplacementRule(pattern2355, replacement2355) pattern2356 = Pattern(Integral((a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_/tan(x_*WC('f', S(1)) + WC('e', S(0)))**S(4), x_), cons2, cons3, cons48, cons125, cons21, cons1265, cons1304, cons1305) def replacement2356(m, f, b, a, x, e): rubi.append(2356) return Int((a + b*sin(e + f*x))**m*(-S(2)*sin(e + f*x)**S(2) + S(1))/sin(e + f*x)**S(4), x) + Int((a + b*sin(e + f*x))**m, x) rule2356 = ReplacementRule(pattern2356, replacement2356) pattern2357 = Pattern(Integral((a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*tan(x_*WC('f', S(1)) + WC('e', S(0)))**S(4), x_), cons2, cons3, cons48, cons125, cons21, cons1265, cons1304, cons1305) def replacement2357(m, f, b, a, x, e): rubi.append(2357) return Int((a + b*cos(e + f*x))**m*(-S(2)*cos(e + f*x)**S(2) + S(1))/cos(e + f*x)**S(4), x) + Int((a + b*cos(e + f*x))**m, x) rule2357 = ReplacementRule(pattern2357, replacement2357) pattern2358 = Pattern(Integral((a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*tan(x_*WC('f', S(1)) + WC('e', S(0)))**p_, x_), cons2, cons3, cons48, cons125, cons21, cons1265, cons18, cons1306) def replacement2358(p, m, f, b, a, x, e): rubi.append(2358) return Dist(sqrt(a - b*sin(e + f*x))*sqrt(a + b*sin(e + f*x))/(b*f*cos(e + f*x)), Subst(Int(x**p*(a - x)**(-p/S(2) + S(-1)/2)*(a + x)**(m - p/S(2) + S(-1)/2), x), x, b*sin(e + f*x)), x) rule2358 = ReplacementRule(pattern2358, replacement2358) pattern2359 = Pattern(Integral((a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(S(1)/tan(x_*WC('f', S(1)) + WC('e', S(0))))**p_, x_), cons2, cons3, cons48, cons125, cons21, cons1265, cons18, cons1306) def replacement2359(p, m, f, b, a, x, e): rubi.append(2359) return -Dist(sqrt(a - b*cos(e + f*x))*sqrt(a + b*cos(e + f*x))/(b*f*sin(e + f*x)), Subst(Int(x**p*(a - x)**(-p/S(2) + S(-1)/2)*(a + x)**(m - p/S(2) + S(-1)/2), x), x, b*cos(e + f*x)), x) rule2359 = ReplacementRule(pattern2359, replacement2359) pattern2360 = Pattern(Integral((WC('g', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**p_*(a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_, x_), cons2, cons3, cons48, cons125, cons208, cons21, cons5, cons1265, cons18, cons147) def replacement2360(p, m, f, b, g, a, x, e): rubi.append(2360) return Dist((b*sin(e + f*x))**(-p + S(-1))*(g*tan(e + f*x))**(p + S(1))*(a - b*sin(e + f*x))**(p/S(2) + S(1)/2)*(a + b*sin(e + f*x))**(p/S(2) + S(1)/2)/(f*g), Subst(Int(x**p*(a - x)**(-p/S(2) + S(-1)/2)*(a + x)**(m - p/S(2) + S(-1)/2), x), x, b*sin(e + f*x)), x) rule2360 = ReplacementRule(pattern2360, replacement2360) pattern2361 = Pattern(Integral((WC('g', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**p_*(a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_, x_), cons2, cons3, cons48, cons125, cons208, cons21, cons5, cons1265, cons18, cons147) def replacement2361(p, m, f, b, g, a, x, e): rubi.append(2361) return -Dist((b*cos(e + f*x))**(-p + S(-1))*(g/tan(e + f*x))**(p + S(1))*(a - b*cos(e + f*x))**(p/S(2) + S(1)/2)*(a + b*cos(e + f*x))**(p/S(2) + S(1)/2)/(f*g), Subst(Int(x**p*(a - x)**(-p/S(2) + S(-1)/2)*(a + x)**(m - p/S(2) + S(-1)/2), x), x, b*cos(e + f*x)), x) rule2361 = ReplacementRule(pattern2361, replacement2361) pattern2362 = Pattern(Integral((a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0)))**WC('p', S(1)), x_), cons2, cons3, cons48, cons125, cons21, cons1267, cons1298) def replacement2362(p, m, f, b, a, x, e): rubi.append(2362) return Dist(S(1)/f, Subst(Int(x**p*(a + x)**m*(b**S(2) - x**S(2))**(-p/S(2) + S(-1)/2), x), x, b*sin(e + f*x)), x) rule2362 = ReplacementRule(pattern2362, replacement2362) pattern2363 = Pattern(Integral((a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(S(1)/tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('p', S(1)), x_), cons2, cons3, cons48, cons125, cons21, cons1267, cons1298) def replacement2363(p, m, f, b, a, x, e): rubi.append(2363) return -Dist(S(1)/f, Subst(Int(x**p*(a + x)**m*(b**S(2) - x**S(2))**(-p/S(2) + S(-1)/2), x), x, b*cos(e + f*x)), x) rule2363 = ReplacementRule(pattern2363, replacement2363) pattern2364 = Pattern(Integral((WC('g', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('p', S(1))*(a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1)), x_), cons2, cons3, cons48, cons125, cons208, cons5, cons1267, cons62) def replacement2364(p, m, f, b, g, a, x, e): rubi.append(2364) return Int(ExpandIntegrand((g*tan(e + f*x))**p, (a + b*sin(e + f*x))**m, x), x) rule2364 = ReplacementRule(pattern2364, replacement2364) pattern2365 = Pattern(Integral((WC('g', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('p', S(1))*(a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1)), x_), cons2, cons3, cons48, cons125, cons208, cons5, cons1267, cons62) def replacement2365(p, m, f, b, g, a, x, e): rubi.append(2365) return Int(ExpandIntegrand((g/tan(e + f*x))**p, (a + b*cos(e + f*x))**m, x), x) rule2365 = ReplacementRule(pattern2365, replacement2365) pattern2366 = Pattern(Integral((a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_/tan(x_*WC('f', S(1)) + WC('e', S(0)))**S(2), x_), cons2, cons3, cons48, cons125, cons21, cons1267) def replacement2366(m, f, b, a, x, e): rubi.append(2366) return Int((a + b*sin(e + f*x))**m*(-sin(e + f*x)**S(2) + S(1))/sin(e + f*x)**S(2), x) rule2366 = ReplacementRule(pattern2366, replacement2366) pattern2367 = Pattern(Integral((a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*tan(x_*WC('f', S(1)) + WC('e', S(0)))**S(2), x_), cons2, cons3, cons48, cons125, cons21, cons1267) def replacement2367(m, f, b, a, x, e): rubi.append(2367) return Int((a + b*cos(e + f*x))**m*(-cos(e + f*x)**S(2) + S(1))/cos(e + f*x)**S(2), x) rule2367 = ReplacementRule(pattern2367, replacement2367) pattern2368 = Pattern(Integral((a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_/tan(x_*WC('f', S(1)) + WC('e', S(0)))**S(4), x_), cons2, cons3, cons48, cons125, cons1267, cons31, cons94, cons515) def replacement2368(m, f, b, a, x, e): rubi.append(2368) return -Dist(S(1)/(S(3)*a**S(2)*b*(m + S(1))), Int((a + b*sin(e + f*x))**(m + S(1))*Simp(S(6)*a**S(2) + a*b*(m + S(1))*sin(e + f*x) - b**S(2)*(m + S(-2))*(m + S(-1)) - (S(3)*a**S(2) - b**S(2)*m*(m + S(-2)))*sin(e + f*x)**S(2), x)/sin(e + f*x)**S(3), x), x) - Simp((a + b*sin(e + f*x))**(m + S(1))*cos(e + f*x)/(S(3)*a*f*sin(e + f*x)**S(3)), x) - Simp((a + b*sin(e + f*x))**(m + S(1))*(S(3)*a**S(2) + b**S(2)*(m + S(-2)))*cos(e + f*x)/(S(3)*a**S(2)*b*f*(m + S(1))*sin(e + f*x)**S(2)), x) rule2368 = ReplacementRule(pattern2368, replacement2368) pattern2369 = Pattern(Integral((a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*tan(x_*WC('f', S(1)) + WC('e', S(0)))**S(4), x_), cons2, cons3, cons48, cons125, cons1267, cons31, cons94, cons515) def replacement2369(m, f, b, a, x, e): rubi.append(2369) return -Dist(S(1)/(S(3)*a**S(2)*b*(m + S(1))), Int((a + b*cos(e + f*x))**(m + S(1))*Simp(S(6)*a**S(2) + a*b*(m + S(1))*cos(e + f*x) - b**S(2)*(m + S(-2))*(m + S(-1)) - (S(3)*a**S(2) - b**S(2)*m*(m + S(-2)))*cos(e + f*x)**S(2), x)/cos(e + f*x)**S(3), x), x) + Simp((a + b*cos(e + f*x))**(m + S(1))*sin(e + f*x)/(S(3)*a*f*cos(e + f*x)**S(3)), x) + Simp((a + b*cos(e + f*x))**(m + S(1))*(S(3)*a**S(2) + b**S(2)*(m + S(-2)))*sin(e + f*x)/(S(3)*a**S(2)*b*f*(m + S(1))*cos(e + f*x)**S(2)), x) rule2369 = ReplacementRule(pattern2369, replacement2369) pattern2370 = Pattern(Integral((a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_/tan(x_*WC('f', S(1)) + WC('e', S(0)))**S(4), x_), cons2, cons3, cons48, cons125, cons21, cons1267, cons272, cons515) def replacement2370(m, f, b, a, x, e): rubi.append(2370) return -Dist(S(1)/(S(6)*a**S(2)), Int((a + b*sin(e + f*x))**m*Simp(S(8)*a**S(2) + a*b*m*sin(e + f*x) - b**S(2)*(m + S(-2))*(m + S(-1)) - (S(6)*a**S(2) - b**S(2)*m*(m + S(-2)))*sin(e + f*x)**S(2), x)/sin(e + f*x)**S(2), x), x) - Simp((a + b*sin(e + f*x))**(m + S(1))*cos(e + f*x)/(S(3)*a*f*sin(e + f*x)**S(3)), x) - Simp(b*(a + b*sin(e + f*x))**(m + S(1))*(m + S(-2))*cos(e + f*x)/(S(6)*a**S(2)*f*sin(e + f*x)**S(2)), x) rule2370 = ReplacementRule(pattern2370, replacement2370) pattern2371 = Pattern(Integral((a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*tan(x_*WC('f', S(1)) + WC('e', S(0)))**S(4), x_), cons2, cons3, cons48, cons125, cons21, cons1267, cons272, cons515) def replacement2371(m, f, b, a, x, e): rubi.append(2371) return -Dist(S(1)/(S(6)*a**S(2)), Int((a + b*cos(e + f*x))**m*Simp(S(8)*a**S(2) + a*b*m*cos(e + f*x) - b**S(2)*(m + S(-2))*(m + S(-1)) - (S(6)*a**S(2) - b**S(2)*m*(m + S(-2)))*cos(e + f*x)**S(2), x)/cos(e + f*x)**S(2), x), x) + Simp((a + b*cos(e + f*x))**(m + S(1))*sin(e + f*x)/(S(3)*a*f*cos(e + f*x)**S(3)), x) + Simp(b*(a + b*cos(e + f*x))**(m + S(1))*(m + S(-2))*sin(e + f*x)/(S(6)*a**S(2)*f*cos(e + f*x)**S(2)), x) rule2371 = ReplacementRule(pattern2371, replacement2371) pattern2372 = Pattern(Integral((a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_/tan(x_*WC('f', S(1)) + WC('e', S(0)))**S(6), x_), cons2, cons3, cons48, cons125, cons21, cons1267, cons1283, cons515) def replacement2372(m, f, b, a, x, e): rubi.append(2372) return Dist(S(1)/(S(20)*a**S(2)*b**S(2)*m*(m + S(-1))), Int((a + b*sin(e + f*x))**m*Simp(S(60)*a**S(4) - S(44)*a**S(2)*b**S(2)*m*(m + S(-1)) + a*b*m*(S(20)*a**S(2) - b**S(2)*m*(m + S(-1)))*sin(e + f*x) + b**S(4)*m*(m + S(-4))*(m + S(-3))*(m + S(-1)) - (S(40)*a**S(4) - S(20)*a**S(2)*b**S(2)*(m + S(-1))*(S(2)*m + S(1)) + b**S(4)*m*(m + S(-4))*(m + S(-2))*(m + S(-1)))*sin(e + f*x)**S(2), x)/sin(e + f*x)**S(4), x), x) - Simp((a + b*sin(e + f*x))**(m + S(1))*cos(e + f*x)/(S(5)*a*f*sin(e + f*x)**S(5)), x) + Simp((a + b*sin(e + f*x))**(m + S(1))*cos(e + f*x)/(b*f*m*sin(e + f*x)**S(2)), x) - Simp(b*(a + b*sin(e + f*x))**(m + S(1))*(m + S(-4))*cos(e + f*x)/(S(20)*a**S(2)*f*sin(e + f*x)**S(4)), x) + Simp(a*(a + b*sin(e + f*x))**(m + S(1))*cos(e + f*x)/(b**S(2)*f*m*(m + S(-1))*sin(e + f*x)**S(3)), x) rule2372 = ReplacementRule(pattern2372, replacement2372) pattern2373 = Pattern(Integral((a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*tan(x_*WC('f', S(1)) + WC('e', S(0)))**S(6), x_), cons2, cons3, cons48, cons125, cons21, cons1267, cons1283, cons515) def replacement2373(m, f, b, a, x, e): rubi.append(2373) return Dist(S(1)/(S(20)*a**S(2)*b**S(2)*m*(m + S(-1))), Int((a + b*cos(e + f*x))**m*Simp(S(60)*a**S(4) - S(44)*a**S(2)*b**S(2)*m*(m + S(-1)) + a*b*m*(S(20)*a**S(2) - b**S(2)*m*(m + S(-1)))*cos(e + f*x) + b**S(4)*m*(m + S(-4))*(m + S(-3))*(m + S(-1)) - (S(40)*a**S(4) - S(20)*a**S(2)*b**S(2)*(m + S(-1))*(S(2)*m + S(1)) + b**S(4)*m*(m + S(-4))*(m + S(-2))*(m + S(-1)))*cos(e + f*x)**S(2), x)/cos(e + f*x)**S(4), x), x) + Simp((a + b*cos(e + f*x))**(m + S(1))*sin(e + f*x)/(S(5)*a*f*cos(e + f*x)**S(5)), x) - Simp((a + b*cos(e + f*x))**(m + S(1))*sin(e + f*x)/(b*f*m*cos(e + f*x)**S(2)), x) + Simp(b*(a + b*cos(e + f*x))**(m + S(1))*(m + S(-4))*sin(e + f*x)/(S(20)*a**S(2)*f*cos(e + f*x)**S(4)), x) - Simp(a*(a + b*cos(e + f*x))**(m + S(1))*sin(e + f*x)/(b**S(2)*f*m*(m + S(-1))*cos(e + f*x)**S(3)), x) rule2373 = ReplacementRule(pattern2373, replacement2373) pattern2374 = Pattern(Integral((WC('g', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**p_/(a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons48, cons125, cons208, cons1267, cons1307, cons146) def replacement2374(p, f, b, g, a, x, e): rubi.append(2374) return Dist(a/(a**S(2) - b**S(2)), Int((g*tan(e + f*x))**p/sin(e + f*x)**S(2), x), x) - Dist(a**S(2)*g**S(2)/(a**S(2) - b**S(2)), Int((g*tan(e + f*x))**(p + S(-2))/(a + b*sin(e + f*x)), x), x) - Dist(b*g/(a**S(2) - b**S(2)), Int((g*tan(e + f*x))**(p + S(-1))/cos(e + f*x), x), x) rule2374 = ReplacementRule(pattern2374, replacement2374) pattern2375 = Pattern(Integral((WC('g', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**p_/(a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons48, cons125, cons208, cons1267, cons1307, cons146) def replacement2375(p, f, b, g, a, x, e): rubi.append(2375) return Dist(a/(a**S(2) - b**S(2)), Int((g/tan(e + f*x))**p/cos(e + f*x)**S(2), x), x) - Dist(a**S(2)*g**S(2)/(a**S(2) - b**S(2)), Int((g/tan(e + f*x))**(p + S(-2))/(a + b*cos(e + f*x)), x), x) - Dist(b*g/(a**S(2) - b**S(2)), Int((g/tan(e + f*x))**(p + S(-1))/sin(e + f*x), x), x) rule2375 = ReplacementRule(pattern2375, replacement2375) pattern2376 = Pattern(Integral((WC('g', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**p_/(a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons48, cons125, cons208, cons1267, cons1307, cons137) def replacement2376(p, f, b, g, a, x, e): rubi.append(2376) return Dist(S(1)/a, Int((g*tan(e + f*x))**p/cos(e + f*x)**S(2), x), x) - Dist(b/(a**S(2)*g), Int((g*tan(e + f*x))**(p + S(1))/cos(e + f*x), x), x) - Dist((a**S(2) - b**S(2))/(a**S(2)*g**S(2)), Int((g*tan(e + f*x))**(p + S(2))/(a + b*sin(e + f*x)), x), x) rule2376 = ReplacementRule(pattern2376, replacement2376) pattern2377 = Pattern(Integral((WC('g', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**p_/(a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons48, cons125, cons208, cons1267, cons1307, cons137) def replacement2377(p, f, b, g, a, x, e): rubi.append(2377) return Dist(S(1)/a, Int((g/tan(e + f*x))**p/sin(e + f*x)**S(2), x), x) - Dist(b/(a**S(2)*g), Int((g/tan(e + f*x))**(p + S(1))/sin(e + f*x), x), x) - Dist((a**S(2) - b**S(2))/(a**S(2)*g**S(2)), Int((g/tan(e + f*x))**(p + S(2))/(a + b*cos(e + f*x)), x), x) rule2377 = ReplacementRule(pattern2377, replacement2377) pattern2378 = Pattern(Integral(sqrt(WC('g', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))/(a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons48, cons125, cons208, cons1267) def replacement2378(f, b, g, a, x, e): rubi.append(2378) return Dist(sqrt(g*tan(e + f*x))*sqrt(cos(e + f*x))/sqrt(sin(e + f*x)), Int(sqrt(sin(e + f*x))/((a + b*sin(e + f*x))*sqrt(cos(e + f*x))), x), x) rule2378 = ReplacementRule(pattern2378, replacement2378) pattern2379 = Pattern(Integral(sqrt(WC('g', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))/(a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons48, cons125, cons208, cons1267) def replacement2379(f, b, g, a, x, e): rubi.append(2379) return Dist(sqrt(g/tan(e + f*x))*sqrt(sin(e + f*x))/sqrt(cos(e + f*x)), Int(sqrt(cos(e + f*x))/((a + b*cos(e + f*x))*sqrt(sin(e + f*x))), x), x) rule2379 = ReplacementRule(pattern2379, replacement2379) pattern2380 = Pattern(Integral(S(1)/(sqrt(g_*tan(x_*WC('f', S(1)) + WC('e', S(0))))*(a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))), x_), cons2, cons3, cons48, cons125, cons208, cons1267) def replacement2380(f, b, g, a, x, e): rubi.append(2380) return Dist(sqrt(sin(e + f*x))/(sqrt(g*tan(e + f*x))*sqrt(cos(e + f*x))), Int(sqrt(cos(e + f*x))/((a + b*sin(e + f*x))*sqrt(sin(e + f*x))), x), x) rule2380 = ReplacementRule(pattern2380, replacement2380) pattern2381 = Pattern(Integral(S(1)/(sqrt(g_/tan(x_*WC('f', S(1)) + WC('e', S(0))))*(a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))), x_), cons2, cons3, cons48, cons125, cons208, cons1267) def replacement2381(f, b, g, a, x, e): rubi.append(2381) return Dist(sqrt(cos(e + f*x))/(sqrt(g/tan(e + f*x))*sqrt(sin(e + f*x))), Int(sqrt(sin(e + f*x))/((a + b*cos(e + f*x))*sqrt(cos(e + f*x))), x), x) rule2381 = ReplacementRule(pattern2381, replacement2381) pattern2382 = Pattern(Integral((a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*tan(x_*WC('f', S(1)) + WC('e', S(0)))**p_, x_), cons2, cons3, cons48, cons125, cons1267, cons1301) def replacement2382(p, m, f, b, a, x, e): rubi.append(2382) return Int(ExpandIntegrand((a + b*sin(e + f*x))**m*(-sin(e + f*x)**S(2) + S(1))**(-p/S(2))*sin(e + f*x)**p, x), x) rule2382 = ReplacementRule(pattern2382, replacement2382) pattern2383 = Pattern(Integral((a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(S(1)/tan(x_*WC('f', S(1)) + WC('e', S(0))))**p_, x_), cons2, cons3, cons48, cons125, cons1267, cons1301) def replacement2383(p, m, f, b, a, x, e): rubi.append(2383) return Int(ExpandIntegrand((a + b*cos(e + f*x))**m*(-cos(e + f*x)**S(2) + S(1))**(-p/S(2))*cos(e + f*x)**p, x), x) rule2383 = ReplacementRule(pattern2383, replacement2383) pattern2384 = Pattern(Integral((WC('g', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('p', S(1))*(a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1)), x_), cons2, cons3, cons48, cons125, cons208, cons21, cons5, cons1308) def replacement2384(p, m, f, b, g, a, x, e): rubi.append(2384) return Int((g*tan(e + f*x))**p*(a + b*sin(e + f*x))**m, x) rule2384 = ReplacementRule(pattern2384, replacement2384) pattern2385 = Pattern(Integral((WC('g', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('p', S(1))*(a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1)), x_), cons2, cons3, cons48, cons125, cons208, cons21, cons5, cons1308) def replacement2385(p, m, f, b, g, a, x, e): rubi.append(2385) return Int((g/tan(e + f*x))**p*(a + b*cos(e + f*x))**m, x) rule2385 = ReplacementRule(pattern2385, replacement2385) pattern2386 = Pattern(Integral((WC('g', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**p_*(a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1)), x_), cons2, cons3, cons48, cons125, cons208, cons21, cons5, cons147) def replacement2386(p, m, f, b, g, a, x, e): rubi.append(2386) return Dist(g**(S(2)*IntPart(p))*(g/tan(e + f*x))**FracPart(p)*(g*tan(e + f*x))**FracPart(p), Int((g*tan(e + f*x))**(-p)*(a + b*sin(e + f*x))**m, x), x) rule2386 = ReplacementRule(pattern2386, replacement2386) pattern2387 = Pattern(Integral((WC('g', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**p_*(a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1)), x_), cons2, cons3, cons48, cons125, cons208, cons21, cons5, cons147) def replacement2387(p, m, f, b, g, a, x, e): rubi.append(2387) return Dist(g**(S(2)*IntPart(p))*(g/tan(e + f*x))**FracPart(p)*(g*tan(e + f*x))**FracPart(p), Int((g/tan(e + f*x))**(-p)*(a + b*cos(e + f*x))**m, x), x) rule2387 = ReplacementRule(pattern2387, replacement2387) pattern2388 = Pattern(Integral((a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))*(WC('c', S(0)) + WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71) def replacement2388(f, b, d, c, a, x, e): rubi.append(2388) return Simp(x*(S(2)*a*c + b*d)/S(2), x) - Simp((a*d + b*c)*cos(e + f*x)/f, x) - Simp(b*d*sin(e + f*x)*cos(e + f*x)/(S(2)*f), x) rule2388 = ReplacementRule(pattern2388, replacement2388) pattern2389 = Pattern(Integral((a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))*(WC('c', S(0)) + WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71) def replacement2389(f, b, d, c, a, x, e): rubi.append(2389) return Simp(x*(S(2)*a*c + b*d)/S(2), x) + Simp((a*d + b*c)*sin(e + f*x)/f, x) + Simp(b*d*sin(e + f*x)*cos(e + f*x)/(S(2)*f), x) rule2389 = ReplacementRule(pattern2389, replacement2389) pattern2390 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))/(WC('c', S(0)) + WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71) def replacement2390(f, b, d, c, a, x, e): rubi.append(2390) return -Dist((-a*d + b*c)/d, Int(S(1)/(c + d*sin(e + f*x)), x), x) + Simp(b*x/d, x) rule2390 = ReplacementRule(pattern2390, replacement2390) pattern2391 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))/(WC('c', S(0)) + WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71) def replacement2391(f, b, d, c, a, x, e): rubi.append(2391) return -Dist((-a*d + b*c)/d, Int(S(1)/(c + d*cos(e + f*x)), x), x) + Simp(b*x/d, x) rule2391 = ReplacementRule(pattern2391, replacement2391) pattern2392 = Pattern(Integral((a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(c_ + WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons4, cons70, cons1265, cons17, cons1309) def replacement2392(m, f, b, d, a, n, c, x, e): rubi.append(2392) return Dist(a**m*c**m, Int((c + d*sin(e + f*x))**(-m + n)*cos(e + f*x)**(S(2)*m), x), x) rule2392 = ReplacementRule(pattern2392, replacement2392) pattern2393 = Pattern(Integral((a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(c_ + WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons4, cons70, cons1265, cons17, cons1309) def replacement2393(m, f, b, d, a, n, c, x, e): rubi.append(2393) return Dist(a**m*c**m, Int((c + d*cos(e + f*x))**(-m + n)*sin(e + f*x)**(S(2)*m), x), x) rule2393 = ReplacementRule(pattern2393, replacement2393) pattern2394 = Pattern(Integral(sqrt(a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))/sqrt(c_ + WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons70, cons1265) def replacement2394(f, b, d, a, c, x, e): rubi.append(2394) return Dist(a*c*cos(e + f*x)/(sqrt(a + b*sin(e + f*x))*sqrt(c + d*sin(e + f*x))), Int(cos(e + f*x)/(c + d*sin(e + f*x)), x), x) rule2394 = ReplacementRule(pattern2394, replacement2394) pattern2395 = Pattern(Integral(sqrt(a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))/sqrt(c_ + WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons70, cons1265) def replacement2395(f, b, d, a, c, x, e): rubi.append(2395) return Dist(a*c*sin(e + f*x)/(sqrt(a + b*cos(e + f*x))*sqrt(c + d*cos(e + f*x))), Int(sin(e + f*x)/(c + d*cos(e + f*x)), x), x) rule2395 = ReplacementRule(pattern2395, replacement2395) pattern2396 = Pattern(Integral(sqrt(a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))*(c_ + WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons4, cons70, cons1265, cons1310) def replacement2396(f, b, d, a, c, n, x, e): rubi.append(2396) return Simp(-S(2)*b*(c + d*sin(e + f*x))**n*cos(e + f*x)/(f*sqrt(a + b*sin(e + f*x))*(S(2)*n + S(1))), x) rule2396 = ReplacementRule(pattern2396, replacement2396) pattern2397 = Pattern(Integral(sqrt(a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))*(c_ + WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons4, cons70, cons1265, cons1310) def replacement2397(f, b, d, a, c, n, x, e): rubi.append(2397) return Simp(S(2)*b*(c + d*cos(e + f*x))**n*sin(e + f*x)/(f*sqrt(a + b*cos(e + f*x))*(S(2)*n + S(1))), x) rule2397 = ReplacementRule(pattern2397, replacement2397) pattern2398 = Pattern(Integral((a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(c_ + WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons70, cons1265, cons1311, cons87, cons89, cons1312) def replacement2398(m, f, b, d, a, c, n, x, e): rubi.append(2398) return -Dist(b*(S(2)*m + S(-1))/(d*(S(2)*n + S(1))), Int((a + b*sin(e + f*x))**(m + S(-1))*(c + d*sin(e + f*x))**(n + S(1)), x), x) + Simp(-S(2)*b*(a + b*sin(e + f*x))**(m + S(-1))*(c + d*sin(e + f*x))**n*cos(e + f*x)/(f*(S(2)*n + S(1))), x) rule2398 = ReplacementRule(pattern2398, replacement2398) pattern2399 = Pattern(Integral((a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(c_ + WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons70, cons1265, cons1311, cons87, cons89, cons1312) def replacement2399(m, f, b, d, a, c, n, x, e): rubi.append(2399) return -Dist(b*(S(2)*m + S(-1))/(d*(S(2)*n + S(1))), Int((a + b*cos(e + f*x))**(m + S(-1))*(c + d*cos(e + f*x))**(n + S(1)), x), x) + Simp(S(2)*b*(a + b*cos(e + f*x))**(m + S(-1))*(c + d*cos(e + f*x))**n*sin(e + f*x)/(f*(S(2)*n + S(1))), x) rule2399 = ReplacementRule(pattern2399, replacement2399) pattern2400 = Pattern(Integral((a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(c_ + WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons4, cons70, cons1265, cons1311, cons346, cons1313, cons1312) def replacement2400(m, f, b, d, a, c, n, x, e): rubi.append(2400) return Dist(a*(S(2)*m + S(-1))/(m + n), Int((a + b*sin(e + f*x))**(m + S(-1))*(c + d*sin(e + f*x))**n, x), x) - Simp(b*(a + b*sin(e + f*x))**(m + S(-1))*(c + d*sin(e + f*x))**n*cos(e + f*x)/(f*(m + n)), x) rule2400 = ReplacementRule(pattern2400, replacement2400) pattern2401 = Pattern(Integral((a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(c_ + WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons4, cons70, cons1265, cons1311, cons346, cons1313, cons1312) def replacement2401(m, f, b, d, a, c, n, x, e): rubi.append(2401) return Dist(a*(S(2)*m + S(-1))/(m + n), Int((a + b*cos(e + f*x))**(m + S(-1))*(c + d*cos(e + f*x))**n, x), x) + Simp(b*(a + b*cos(e + f*x))**(m + S(-1))*(c + d*cos(e + f*x))**n*sin(e + f*x)/(f*(m + n)), x) rule2401 = ReplacementRule(pattern2401, replacement2401) pattern2402 = Pattern(Integral(S(1)/(sqrt(a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))*sqrt(c_ + WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons70, cons1265) def replacement2402(f, b, d, a, c, x, e): rubi.append(2402) return Dist(cos(e + f*x)/(sqrt(a + b*sin(e + f*x))*sqrt(c + d*sin(e + f*x))), Int(S(1)/cos(e + f*x), x), x) rule2402 = ReplacementRule(pattern2402, replacement2402) pattern2403 = Pattern(Integral(S(1)/(sqrt(a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))*sqrt(c_ + WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons70, cons1265) def replacement2403(f, b, d, a, c, x, e): rubi.append(2403) return Dist(sin(e + f*x)/(sqrt(a + b*cos(e + f*x))*sqrt(c + d*cos(e + f*x))), Int(S(1)/sin(e + f*x), x), x) rule2403 = ReplacementRule(pattern2403, replacement2403) pattern2404 = Pattern(Integral((a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(c_ + WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons4, cons70, cons1265, cons155, cons1314) def replacement2404(m, f, b, d, a, c, n, x, e): rubi.append(2404) return Simp(b*(a + b*sin(e + f*x))**m*(c + d*sin(e + f*x))**n*cos(e + f*x)/(a*f*(S(2)*m + S(1))), x) rule2404 = ReplacementRule(pattern2404, replacement2404) pattern2405 = Pattern(Integral((a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(c_ + WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons4, cons70, cons1265, cons155, cons1314) def replacement2405(m, f, b, d, a, c, n, x, e): rubi.append(2405) return -Simp(b*(a + b*cos(e + f*x))**m*(c + d*cos(e + f*x))**n*sin(e + f*x)/(a*f*(S(2)*m + S(1))), x) rule2405 = ReplacementRule(pattern2405, replacement2405) pattern2406 = Pattern(Integral((a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(c_ + WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons4, cons70, cons1265, cons1315, cons1314, cons114) def replacement2406(m, f, b, d, a, c, n, x, e): rubi.append(2406) return Dist((m + n + S(1))/(a*(S(2)*m + S(1))), Int((a + b*sin(e + f*x))**(m + S(1))*(c + d*sin(e + f*x))**n, x), x) + Simp(b*(a + b*sin(e + f*x))**m*(c + d*sin(e + f*x))**n*cos(e + f*x)/(a*f*(S(2)*m + S(1))), x) rule2406 = ReplacementRule(pattern2406, replacement2406) pattern2407 = Pattern(Integral((a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(c_ + WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons4, cons70, cons1265, cons1315, cons1314, cons114) def replacement2407(m, f, b, d, a, c, n, x, e): rubi.append(2407) return Dist((m + n + S(1))/(a*(S(2)*m + S(1))), Int((a + b*cos(e + f*x))**(m + S(1))*(c + d*cos(e + f*x))**n, x), x) - Simp(b*(a + b*cos(e + f*x))**m*(c + d*cos(e + f*x))**n*sin(e + f*x)/(a*f*(S(2)*m + S(1))), x) rule2407 = ReplacementRule(pattern2407, replacement2407) pattern2408 = Pattern(Integral((a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(c_ + WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons4, cons70, cons1265, cons31, cons94, cons1316, cons1170) def replacement2408(m, f, b, d, a, c, n, x, e): rubi.append(2408) return Dist((m + n + S(1))/(a*(S(2)*m + S(1))), Int((a + b*sin(e + f*x))**(m + S(1))*(c + d*sin(e + f*x))**n, x), x) + Simp(b*(a + b*sin(e + f*x))**m*(c + d*sin(e + f*x))**n*cos(e + f*x)/(a*f*(S(2)*m + S(1))), x) rule2408 = ReplacementRule(pattern2408, replacement2408) pattern2409 = Pattern(Integral((a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(c_ + WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons4, cons70, cons1265, cons31, cons94, cons1316, cons1170) def replacement2409(m, f, b, d, a, c, n, x, e): rubi.append(2409) return Dist((m + n + S(1))/(a*(S(2)*m + S(1))), Int((a + b*cos(e + f*x))**(m + S(1))*(c + d*cos(e + f*x))**n, x), x) - Simp(b*(a + b*cos(e + f*x))**m*(c + d*cos(e + f*x))**n*sin(e + f*x)/(a*f*(S(2)*m + S(1))), x) rule2409 = ReplacementRule(pattern2409, replacement2409) pattern2410 = Pattern(Integral((a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(c_ + WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons4, cons70, cons1265, cons1317) def replacement2410(m, f, b, d, a, c, n, x, e): rubi.append(2410) return Dist(a**IntPart(m)*c**IntPart(m)*(a + b*sin(e + f*x))**FracPart(m)*(c + d*sin(e + f*x))**FracPart(m)*cos(e + f*x)**(-S(2)*FracPart(m)), Int((c + d*sin(e + f*x))**(-m + n)*cos(e + f*x)**(S(2)*m), x), x) rule2410 = ReplacementRule(pattern2410, replacement2410) pattern2411 = Pattern(Integral((a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(c_ + WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons4, cons70, cons1265, cons1317) def replacement2411(m, f, b, d, a, c, n, x, e): rubi.append(2411) return Dist(a**IntPart(m)*c**IntPart(m)*(a + b*cos(e + f*x))**FracPart(m)*(c + d*cos(e + f*x))**FracPart(m)*sin(e + f*x)**(-S(2)*FracPart(m)), Int((c + d*cos(e + f*x))**(-m + n)*sin(e + f*x)**(S(2)*m), x), x) rule2411 = ReplacementRule(pattern2411, replacement2411) pattern2412 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**S(2)/(WC('c', S(0)) + WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71) def replacement2412(f, b, d, c, a, x, e): rubi.append(2412) return Dist(S(1)/d, Int(Simp(a**S(2)*d - b*(-S(2)*a*d + b*c)*sin(e + f*x), x)/(c + d*sin(e + f*x)), x), x) - Simp(b**S(2)*cos(e + f*x)/(d*f), x) rule2412 = ReplacementRule(pattern2412, replacement2412) pattern2413 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**S(2)/(WC('c', S(0)) + WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71) def replacement2413(f, b, d, c, a, x, e): rubi.append(2413) return Dist(S(1)/d, Int(Simp(a**S(2)*d - b*(-S(2)*a*d + b*c)*cos(e + f*x), x)/(c + d*cos(e + f*x)), x), x) + Simp(b**S(2)*sin(e + f*x)/(d*f), x) rule2413 = ReplacementRule(pattern2413, replacement2413) pattern2414 = Pattern(Integral(S(1)/((WC('a', S(0)) + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))*(WC('c', S(0)) + WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71) def replacement2414(f, b, d, c, a, x, e): rubi.append(2414) return Dist(b/(-a*d + b*c), Int(S(1)/(a + b*sin(e + f*x)), x), x) - Dist(d/(-a*d + b*c), Int(S(1)/(c + d*sin(e + f*x)), x), x) rule2414 = ReplacementRule(pattern2414, replacement2414) pattern2415 = Pattern(Integral(S(1)/((WC('a', S(0)) + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))*(WC('c', S(0)) + WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71) def replacement2415(f, b, d, c, a, x, e): rubi.append(2415) return Dist(b/(-a*d + b*c), Int(S(1)/(a + b*cos(e + f*x)), x), x) - Dist(d/(-a*d + b*c), Int(S(1)/(c + d*cos(e + f*x)), x), x) rule2415 = ReplacementRule(pattern2415, replacement2415) pattern2416 = Pattern(Integral((WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(c_ + WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons3, cons7, cons27, cons48, cons125, cons21, cons1318) def replacement2416(m, f, b, d, c, x, e): rubi.append(2416) return Dist(c, Int((b*sin(e + f*x))**m, x), x) + Dist(d/b, Int((b*sin(e + f*x))**(m + S(1)), x), x) rule2416 = ReplacementRule(pattern2416, replacement2416) pattern2417 = Pattern(Integral((WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(c_ + WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons3, cons7, cons27, cons48, cons125, cons21, cons1318) def replacement2417(m, f, b, d, c, x, e): rubi.append(2417) return Dist(c, Int((b*cos(e + f*x))**m, x), x) + Dist(d/b, Int((b*cos(e + f*x))**(m + S(1)), x), x) rule2417 = ReplacementRule(pattern2417, replacement2417) pattern2418 = Pattern(Integral((a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(c_ + WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons71, cons1265, cons1319) def replacement2418(m, f, b, d, a, c, x, e): rubi.append(2418) return -Simp(d*(a + b*sin(e + f*x))**m*cos(e + f*x)/(f*(m + S(1))), x) rule2418 = ReplacementRule(pattern2418, replacement2418) pattern2419 = Pattern(Integral((a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(c_ + WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons71, cons1265, cons1319) def replacement2419(m, f, b, d, a, c, x, e): rubi.append(2419) return Simp(d*(a + b*cos(e + f*x))**m*sin(e + f*x)/(f*(m + S(1))), x) rule2419 = ReplacementRule(pattern2419, replacement2419) pattern2420 = Pattern(Integral((a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1265, cons31, cons1320) def replacement2420(m, f, b, d, c, a, x, e): rubi.append(2420) return Dist((a*d*m + b*c*(m + S(1)))/(a*b*(S(2)*m + S(1))), Int((a + b*sin(e + f*x))**(m + S(1)), x), x) + Simp((a + b*sin(e + f*x))**m*(-a*d + b*c)*cos(e + f*x)/(a*f*(S(2)*m + S(1))), x) rule2420 = ReplacementRule(pattern2420, replacement2420) pattern2421 = Pattern(Integral((a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1265, cons31, cons1320) def replacement2421(m, f, b, d, c, a, x, e): rubi.append(2421) return Dist((a*d*m + b*c*(m + S(1)))/(a*b*(S(2)*m + S(1))), Int((a + b*cos(e + f*x))**(m + S(1)), x), x) - Simp((a + b*cos(e + f*x))**m*(-a*d + b*c)*sin(e + f*x)/(a*f*(S(2)*m + S(1))), x) rule2421 = ReplacementRule(pattern2421, replacement2421) pattern2422 = Pattern(Integral((a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons71, cons1265, cons1321) def replacement2422(m, f, b, d, c, a, x, e): rubi.append(2422) return Dist((a*d*m + b*c*(m + S(1)))/(b*(m + S(1))), Int((a + b*sin(e + f*x))**m, x), x) - Simp(d*(a + b*sin(e + f*x))**m*cos(e + f*x)/(f*(m + S(1))), x) rule2422 = ReplacementRule(pattern2422, replacement2422) pattern2423 = Pattern(Integral((a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons71, cons1265, cons1321) def replacement2423(m, f, b, d, c, a, x, e): rubi.append(2423) return Dist((a*d*m + b*c*(m + S(1)))/(b*(m + S(1))), Int((a + b*cos(e + f*x))**m, x), x) + Simp(d*(a + b*cos(e + f*x))**m*sin(e + f*x)/(f*(m + S(1))), x) rule2423 = ReplacementRule(pattern2423, replacement2423) pattern2424 = Pattern(Integral((WC('c', S(0)) + WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))/sqrt(a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1267) def replacement2424(f, b, d, c, a, x, e): rubi.append(2424) return Dist(d/b, Int(sqrt(a + b*sin(e + f*x)), x), x) + Dist((-a*d + b*c)/b, Int(S(1)/sqrt(a + b*sin(e + f*x)), x), x) rule2424 = ReplacementRule(pattern2424, replacement2424) pattern2425 = Pattern(Integral((WC('c', S(0)) + WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))/sqrt(a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1267) def replacement2425(f, b, d, c, a, x, e): rubi.append(2425) return Dist(d/b, Int(sqrt(a + b*cos(e + f*x)), x), x) + Dist((-a*d + b*c)/b, Int(S(1)/sqrt(a + b*cos(e + f*x)), x), x) rule2425 = ReplacementRule(pattern2425, replacement2425) pattern2426 = Pattern(Integral((a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1267, cons31, cons168, cons515) def replacement2426(m, f, b, d, c, a, x, e): rubi.append(2426) return Dist(S(1)/(m + S(1)), Int((a + b*sin(e + f*x))**(m + S(-1))*Simp(a*c*(m + S(1)) + b*d*m + (a*d*m + b*c*(m + S(1)))*sin(e + f*x), x), x), x) - Simp(d*(a + b*sin(e + f*x))**m*cos(e + f*x)/(f*(m + S(1))), x) rule2426 = ReplacementRule(pattern2426, replacement2426) pattern2427 = Pattern(Integral((a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1267, cons31, cons168, cons515) def replacement2427(m, f, b, d, c, a, x, e): rubi.append(2427) return Dist(S(1)/(m + S(1)), Int((a + b*cos(e + f*x))**(m + S(-1))*Simp(a*c*(m + S(1)) + b*d*m + (a*d*m + b*c*(m + S(1)))*cos(e + f*x), x), x), x) + Simp(d*(a + b*cos(e + f*x))**m*sin(e + f*x)/(f*(m + S(1))), x) rule2427 = ReplacementRule(pattern2427, replacement2427) pattern2428 = Pattern(Integral((a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1267, cons31, cons94, cons515) def replacement2428(m, f, b, d, c, a, x, e): rubi.append(2428) return Dist(S(1)/((a**S(2) - b**S(2))*(m + S(1))), Int((a + b*sin(e + f*x))**(m + S(1))*Simp((m + S(1))*(a*c - b*d) - (m + S(2))*(-a*d + b*c)*sin(e + f*x), x), x), x) - Simp((a + b*sin(e + f*x))**(m + S(1))*(-a*d + b*c)*cos(e + f*x)/(f*(a**S(2) - b**S(2))*(m + S(1))), x) rule2428 = ReplacementRule(pattern2428, replacement2428) pattern2429 = Pattern(Integral((a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1267, cons31, cons94, cons515) def replacement2429(m, f, b, d, c, a, x, e): rubi.append(2429) return Dist(S(1)/((a**S(2) - b**S(2))*(m + S(1))), Int((a + b*cos(e + f*x))**(m + S(1))*Simp((m + S(1))*(a*c - b*d) - (m + S(2))*(-a*d + b*c)*cos(e + f*x), x), x), x) + Simp((a + b*cos(e + f*x))**(m + S(1))*(-a*d + b*c)*sin(e + f*x)/(f*(a**S(2) - b**S(2))*(m + S(1))), x) rule2429 = ReplacementRule(pattern2429, replacement2429) pattern2430 = Pattern(Integral((a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(c_ + WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons71, cons1267, cons77, cons1322) def replacement2430(m, f, b, d, a, c, x, e): rubi.append(2430) return Dist(c*cos(e + f*x)/(f*sqrt(-sin(e + f*x) + S(1))*sqrt(sin(e + f*x) + S(1))), Subst(Int(sqrt(S(1) + d*x/c)*(a + b*x)**m/sqrt(S(1) - d*x/c), x), x, sin(e + f*x)), x) rule2430 = ReplacementRule(pattern2430, replacement2430) pattern2431 = Pattern(Integral((a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(c_ + WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons71, cons1267, cons77, cons1322) def replacement2431(m, f, b, d, a, c, x, e): rubi.append(2431) return -Dist(c*sin(e + f*x)/(f*sqrt(-cos(e + f*x) + S(1))*sqrt(cos(e + f*x) + S(1))), Subst(Int(sqrt(S(1) + d*x/c)*(a + b*x)**m/sqrt(S(1) - d*x/c), x), x, cos(e + f*x)), x) rule2431 = ReplacementRule(pattern2431, replacement2431) pattern2432 = Pattern(Integral((a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons71, cons1267) def replacement2432(m, f, b, d, c, a, x, e): rubi.append(2432) return Dist(d/b, Int((a + b*sin(e + f*x))**(m + S(1)), x), x) + Dist((-a*d + b*c)/b, Int((a + b*sin(e + f*x))**m, x), x) rule2432 = ReplacementRule(pattern2432, replacement2432) pattern2433 = Pattern(Integral((a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons71, cons1267) def replacement2433(m, f, b, d, c, a, x, e): rubi.append(2433) return Dist(d/b, Int((a + b*cos(e + f*x))**(m + S(1)), x), x) + Dist((-a*d + b*c)/b, Int((a + b*cos(e + f*x))**m, x), x) rule2433 = ReplacementRule(pattern2433, replacement2433) pattern2434 = Pattern(Integral((WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1))*(a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1)), x_), cons2, cons3, cons27, cons48, cons125, cons4, cons1265, cons62, cons87) def replacement2434(m, f, b, d, a, n, x, e): rubi.append(2434) return Int(ExpandTrig((d*sin(e + f*x))**n*(a + b*sin(e + f*x))**m, x), x) rule2434 = ReplacementRule(pattern2434, replacement2434) pattern2435 = Pattern(Integral((WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1))*(a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1)), x_), cons2, cons3, cons27, cons48, cons125, cons4, cons1265, cons62, cons87) def replacement2435(m, f, b, d, a, n, x, e): rubi.append(2435) return Int(ExpandTrig((d*cos(e + f*x))**n*(a + b*cos(e + f*x))**m, x), x) rule2435 = ReplacementRule(pattern2435, replacement2435) pattern2436 = Pattern(Integral((a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*sin(x_*WC('f', S(1)) + WC('e', S(0)))**S(2), x_), cons2, cons3, cons48, cons125, cons1265, cons31, cons1320) def replacement2436(m, f, b, a, x, e): rubi.append(2436) return -Dist(S(1)/(a**S(2)*(S(2)*m + S(1))), Int((a + b*sin(e + f*x))**(m + S(1))*(a*m - b*(S(2)*m + S(1))*sin(e + f*x)), x), x) + Simp(b*(a + b*sin(e + f*x))**m*cos(e + f*x)/(a*f*(S(2)*m + S(1))), x) rule2436 = ReplacementRule(pattern2436, replacement2436) pattern2437 = Pattern(Integral((a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*cos(x_*WC('f', S(1)) + WC('e', S(0)))**S(2), x_), cons2, cons3, cons48, cons125, cons1265, cons31, cons1320) def replacement2437(m, f, b, a, x, e): rubi.append(2437) return -Dist(S(1)/(a**S(2)*(S(2)*m + S(1))), Int((a + b*cos(e + f*x))**(m + S(1))*(a*m - b*(S(2)*m + S(1))*cos(e + f*x)), x), x) - Simp(b*(a + b*cos(e + f*x))**m*sin(e + f*x)/(a*f*(S(2)*m + S(1))), x) rule2437 = ReplacementRule(pattern2437, replacement2437) pattern2438 = Pattern(Integral((a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*sin(x_*WC('f', S(1)) + WC('e', S(0)))**S(2), x_), cons2, cons3, cons48, cons125, cons21, cons1265, cons1321) def replacement2438(m, f, b, a, x, e): rubi.append(2438) return Dist(S(1)/(b*(m + S(2))), Int((a + b*sin(e + f*x))**m*(-a*sin(e + f*x) + b*(m + S(1))), x), x) - Simp((a + b*sin(e + f*x))**(m + S(1))*cos(e + f*x)/(b*f*(m + S(2))), x) rule2438 = ReplacementRule(pattern2438, replacement2438) pattern2439 = Pattern(Integral((a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*cos(x_*WC('f', S(1)) + WC('e', S(0)))**S(2), x_), cons2, cons3, cons48, cons125, cons21, cons1265, cons1321) def replacement2439(m, f, b, a, x, e): rubi.append(2439) return Dist(S(1)/(b*(m + S(2))), Int((a + b*cos(e + f*x))**m*(-a*cos(e + f*x) + b*(m + S(1))), x), x) + Simp((a + b*cos(e + f*x))**(m + S(1))*sin(e + f*x)/(b*f*(m + S(2))), x) rule2439 = ReplacementRule(pattern2439, replacement2439) pattern2440 = Pattern(Integral((a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(c_ + WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**S(2), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1265, cons31, cons94) def replacement2440(m, f, b, d, a, c, x, e): rubi.append(2440) return Dist(S(1)/(a*b*(S(2)*m + S(1))), Int((a + b*sin(e + f*x))**(m + S(1))*Simp(a*c*d*(m + S(-1)) + b*(c**S(2)*(m + S(1)) + d**S(2)) + d*(a*d*(m + S(-1)) + b*c*(m + S(2)))*sin(e + f*x), x), x), x) + Simp((a + b*sin(e + f*x))**m*(c + d*sin(e + f*x))*(-a*d + b*c)*cos(e + f*x)/(a*f*(S(2)*m + S(1))), x) rule2440 = ReplacementRule(pattern2440, replacement2440) pattern2441 = Pattern(Integral((a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(c_ + WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**S(2), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1265, cons31, cons94) def replacement2441(m, f, b, d, a, c, x, e): rubi.append(2441) return Dist(S(1)/(a*b*(S(2)*m + S(1))), Int((a + b*cos(e + f*x))**(m + S(1))*Simp(a*c*d*(m + S(-1)) + b*(c**S(2)*(m + S(1)) + d**S(2)) + d*(a*d*(m + S(-1)) + b*c*(m + S(2)))*cos(e + f*x), x), x), x) - Simp((a + b*cos(e + f*x))**m*(c + d*cos(e + f*x))*(-a*d + b*c)*sin(e + f*x)/(a*f*(S(2)*m + S(1))), x) rule2441 = ReplacementRule(pattern2441, replacement2441) pattern2442 = Pattern(Integral((a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(c_ + WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**S(2), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons71, cons1265, cons272) def replacement2442(m, f, b, d, a, c, x, e): rubi.append(2442) return Dist(S(1)/(b*(m + S(2))), Int((a + b*sin(e + f*x))**m*Simp(b*(c**S(2)*(m + S(2)) + d**S(2)*(m + S(1))) - d*(a*d - S(2)*b*c*(m + S(2)))*sin(e + f*x), x), x), x) - Simp(d**S(2)*(a + b*sin(e + f*x))**(m + S(1))*cos(e + f*x)/(b*f*(m + S(2))), x) rule2442 = ReplacementRule(pattern2442, replacement2442) pattern2443 = Pattern(Integral((a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(c_ + WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**S(2), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons71, cons1265, cons272) def replacement2443(m, f, b, d, a, c, x, e): rubi.append(2443) return Dist(S(1)/(b*(m + S(2))), Int((a + b*cos(e + f*x))**m*Simp(b*(c**S(2)*(m + S(2)) + d**S(2)*(m + S(1))) - d*(a*d - S(2)*b*c*(m + S(2)))*cos(e + f*x), x), x), x) + Simp(d**S(2)*(a + b*cos(e + f*x))**(m + S(1))*sin(e + f*x)/(b*f*(m + S(2))), x) rule2443 = ReplacementRule(pattern2443, replacement2443) pattern2444 = Pattern(Integral((a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1265, cons1323, cons93, cons166, cons89, cons1324) def replacement2444(m, f, b, d, c, a, n, x, e): rubi.append(2444) return Dist(b**S(2)/(d*(n + S(1))*(a*d + b*c)), Int((a + b*sin(e + f*x))**(m + S(-2))*(c + d*sin(e + f*x))**(n + S(1))*Simp(a*c*(m + S(-2)) - b*d*(m - S(2)*n + S(-4)) - (-a*d*(m + S(2)*n + S(1)) + b*c*(m + S(-1)))*sin(e + f*x), x), x), x) - Simp(b**S(2)*(a + b*sin(e + f*x))**(m + S(-2))*(c + d*sin(e + f*x))**(n + S(1))*(-a*d + b*c)*cos(e + f*x)/(d*f*(n + S(1))*(a*d + b*c)), x) rule2444 = ReplacementRule(pattern2444, replacement2444) pattern2445 = Pattern(Integral((a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1265, cons1323, cons93, cons166, cons89, cons1324) def replacement2445(m, f, b, d, c, n, a, x, e): rubi.append(2445) return Dist(b**S(2)/(d*(n + S(1))*(a*d + b*c)), Int((a + b*cos(e + f*x))**(m + S(-2))*(c + d*cos(e + f*x))**(n + S(1))*Simp(a*c*(m + S(-2)) - b*d*(m - S(2)*n + S(-4)) - (-a*d*(m + S(2)*n + S(1)) + b*c*(m + S(-1)))*cos(e + f*x), x), x), x) + Simp(b**S(2)*(a + b*cos(e + f*x))**(m + S(-2))*(c + d*cos(e + f*x))**(n + S(1))*(-a*d + b*c)*sin(e + f*x)/(d*f*(n + S(1))*(a*d + b*c)), x) rule2445 = ReplacementRule(pattern2445, replacement2445) pattern2446 = Pattern(Integral((a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons4, cons71, cons1265, cons1323, cons31, cons166, cons346, cons1324) def replacement2446(m, f, b, d, c, a, n, x, e): rubi.append(2446) return Dist(S(1)/(d*(m + n)), Int((a + b*sin(e + f*x))**(m + S(-2))*(c + d*sin(e + f*x))**n*Simp(a**S(2)*d*(m + n) + a*b*c*(m + S(-2)) + b**S(2)*d*(n + S(1)) - b*(-a*d*(S(3)*m + S(2)*n + S(-2)) + b*c*(m + S(-1)))*sin(e + f*x), x), x), x) - Simp(b**S(2)*(a + b*sin(e + f*x))**(m + S(-2))*(c + d*sin(e + f*x))**(n + S(1))*cos(e + f*x)/(d*f*(m + n)), x) rule2446 = ReplacementRule(pattern2446, replacement2446) pattern2447 = Pattern(Integral((a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons4, cons71, cons1265, cons1323, cons31, cons166, cons346, cons1324) def replacement2447(m, f, b, d, c, n, a, x, e): rubi.append(2447) return Dist(S(1)/(d*(m + n)), Int((a + b*cos(e + f*x))**(m + S(-2))*(c + d*cos(e + f*x))**n*Simp(a**S(2)*d*(m + n) + a*b*c*(m + S(-2)) + b**S(2)*d*(n + S(1)) - b*(-a*d*(S(3)*m + S(2)*n + S(-2)) + b*c*(m + S(-1)))*cos(e + f*x), x), x), x) + Simp(b**S(2)*(a + b*cos(e + f*x))**(m + S(-2))*(c + d*cos(e + f*x))**(n + S(1))*sin(e + f*x)/(d*f*(m + n)), x) rule2447 = ReplacementRule(pattern2447, replacement2447) pattern2448 = Pattern(Integral((a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1265, cons1323, cons93, cons94, cons1325, cons1326) def replacement2448(m, f, b, d, c, a, n, x, e): rubi.append(2448) return -Dist(S(1)/(a*b*(S(2)*m + S(1))), Int((a + b*sin(e + f*x))**(m + S(1))*(c + d*sin(e + f*x))**(n + S(-1))*Simp(a*d*n - b*c*(m + S(1)) - b*d*(m + n + S(1))*sin(e + f*x), x), x), x) + Simp(b*(a + b*sin(e + f*x))**m*(c + d*sin(e + f*x))**n*cos(e + f*x)/(a*f*(S(2)*m + S(1))), x) rule2448 = ReplacementRule(pattern2448, replacement2448) pattern2449 = Pattern(Integral((a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1265, cons1323, cons93, cons94, cons1325, cons1326) def replacement2449(m, f, b, d, c, n, a, x, e): rubi.append(2449) return -Dist(S(1)/(a*b*(S(2)*m + S(1))), Int((a + b*cos(e + f*x))**(m + S(1))*(c + d*cos(e + f*x))**(n + S(-1))*Simp(a*d*n - b*c*(m + S(1)) - b*d*(m + n + S(1))*cos(e + f*x), x), x), x) - Simp(b*(a + b*cos(e + f*x))**m*(c + d*cos(e + f*x))**n*sin(e + f*x)/(a*f*(S(2)*m + S(1))), x) rule2449 = ReplacementRule(pattern2449, replacement2449) pattern2450 = Pattern(Integral((a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1265, cons1323, cons93, cons94, cons165, cons1326) def replacement2450(m, f, b, d, c, a, n, x, e): rubi.append(2450) return Dist(S(1)/(a*b*(S(2)*m + S(1))), Int((a + b*sin(e + f*x))**(m + S(1))*(c + d*sin(e + f*x))**(n + S(-2))*Simp(a*c*d*(m - n + S(1)) + b*(c**S(2)*(m + S(1)) + d**S(2)*(n + S(-1))) + d*(a*d*(m - n + S(1)) + b*c*(m + n))*sin(e + f*x), x), x), x) + Simp((a + b*sin(e + f*x))**m*(c + d*sin(e + f*x))**(n + S(-1))*(-a*d + b*c)*cos(e + f*x)/(a*f*(S(2)*m + S(1))), x) rule2450 = ReplacementRule(pattern2450, replacement2450) pattern2451 = Pattern(Integral((a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1265, cons1323, cons93, cons94, cons165, cons1326) def replacement2451(m, f, b, d, c, n, a, x, e): rubi.append(2451) return Dist(S(1)/(a*b*(S(2)*m + S(1))), Int((a + b*cos(e + f*x))**(m + S(1))*(c + d*cos(e + f*x))**(n + S(-2))*Simp(a*c*d*(m - n + S(1)) + b*(c**S(2)*(m + S(1)) + d**S(2)*(n + S(-1))) + d*(a*d*(m - n + S(1)) + b*c*(m + n))*cos(e + f*x), x), x), x) - Simp((a + b*cos(e + f*x))**m*(c + d*cos(e + f*x))**(n + S(-1))*(-a*d + b*c)*sin(e + f*x)/(a*f*(S(2)*m + S(1))), x) rule2451 = ReplacementRule(pattern2451, replacement2451) pattern2452 = Pattern(Integral((a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons4, cons71, cons1265, cons1323, cons31, cons94, cons1327, cons1326) def replacement2452(m, f, b, d, c, a, n, x, e): rubi.append(2452) return Dist(S(1)/(a*(S(2)*m + S(1))*(-a*d + b*c)), Int((a + b*sin(e + f*x))**(m + S(1))*(c + d*sin(e + f*x))**n*Simp(-a*d*(S(2)*m + n + S(2)) + b*c*(m + S(1)) + b*d*(m + n + S(2))*sin(e + f*x), x), x), x) + Simp(b**S(2)*(a + b*sin(e + f*x))**m*(c + d*sin(e + f*x))**(n + S(1))*cos(e + f*x)/(a*f*(S(2)*m + S(1))*(-a*d + b*c)), x) rule2452 = ReplacementRule(pattern2452, replacement2452) pattern2453 = Pattern(Integral((a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons4, cons71, cons1265, cons1323, cons31, cons94, cons1327, cons1326) def replacement2453(m, f, b, d, c, n, a, x, e): rubi.append(2453) return Dist(S(1)/(a*(S(2)*m + S(1))*(-a*d + b*c)), Int((a + b*cos(e + f*x))**(m + S(1))*(c + d*cos(e + f*x))**n*Simp(-a*d*(S(2)*m + n + S(2)) + b*c*(m + S(1)) + b*d*(m + n + S(2))*cos(e + f*x), x), x), x) - Simp(b**S(2)*(a + b*cos(e + f*x))**m*(c + d*cos(e + f*x))**(n + S(1))*sin(e + f*x)/(a*f*(S(2)*m + S(1))*(-a*d + b*c)), x) rule2453 = ReplacementRule(pattern2453, replacement2453) pattern2454 = Pattern(Integral((WC('c', S(0)) + WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_/(a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1265, cons1323, cons87, cons165, cons1328) def replacement2454(f, b, d, c, a, n, x, e): rubi.append(2454) return -Dist(d/(a*b), Int((c + d*sin(e + f*x))**(n + S(-2))*Simp(-a*c*n + b*d*(n + S(-1)) + (-a*d*n + b*c*(n + S(-1)))*sin(e + f*x), x), x), x) - Simp((c + d*sin(e + f*x))**(n + S(-1))*(-a*d + b*c)*cos(e + f*x)/(a*f*(a + b*sin(e + f*x))), x) rule2454 = ReplacementRule(pattern2454, replacement2454) pattern2455 = Pattern(Integral((WC('c', S(0)) + WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_/(a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1265, cons1323, cons87, cons165, cons1328) def replacement2455(f, b, d, c, n, a, x, e): rubi.append(2455) return -Dist(d/(a*b), Int((c + d*cos(e + f*x))**(n + S(-2))*Simp(-a*c*n + b*d*(n + S(-1)) + (-a*d*n + b*c*(n + S(-1)))*cos(e + f*x), x), x), x) + Simp((c + d*cos(e + f*x))**(n + S(-1))*(-a*d + b*c)*sin(e + f*x)/(a*f*(a + b*cos(e + f*x))), x) rule2455 = ReplacementRule(pattern2455, replacement2455) pattern2456 = Pattern(Integral((WC('c', S(0)) + WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_/(a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1265, cons1323, cons87, cons463, cons1328) def replacement2456(f, b, d, c, a, n, x, e): rubi.append(2456) return Dist(d/(a*(-a*d + b*c)), Int((c + d*sin(e + f*x))**n*(a*n - b*(n + S(1))*sin(e + f*x)), x), x) - Simp(b**S(2)*(c + d*sin(e + f*x))**(n + S(1))*cos(e + f*x)/(a*f*(a + b*sin(e + f*x))*(-a*d + b*c)), x) rule2456 = ReplacementRule(pattern2456, replacement2456) pattern2457 = Pattern(Integral((WC('c', S(0)) + WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_/(a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1265, cons1323, cons87, cons463, cons1328) def replacement2457(f, b, d, c, n, a, x, e): rubi.append(2457) return Dist(d/(a*(-a*d + b*c)), Int((c + d*cos(e + f*x))**n*(a*n - b*(n + S(1))*cos(e + f*x)), x), x) + Simp(b**S(2)*(c + d*cos(e + f*x))**(n + S(1))*sin(e + f*x)/(a*f*(a + b*cos(e + f*x))*(-a*d + b*c)), x) rule2457 = ReplacementRule(pattern2457, replacement2457) pattern2458 = Pattern(Integral((WC('c', S(0)) + WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_/(a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons4, cons71, cons1265, cons1323, cons1328) def replacement2458(f, b, d, c, a, n, x, e): rubi.append(2458) return Dist(d*n/(a*b), Int((a - b*sin(e + f*x))*(c + d*sin(e + f*x))**(n + S(-1)), x), x) - Simp(b*(c + d*sin(e + f*x))**n*cos(e + f*x)/(a*f*(a + b*sin(e + f*x))), x) rule2458 = ReplacementRule(pattern2458, replacement2458) pattern2459 = Pattern(Integral((WC('c', S(0)) + WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_/(a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons4, cons71, cons1265, cons1323, cons1328) def replacement2459(f, b, d, c, n, a, x, e): rubi.append(2459) return Dist(d*n/(a*b), Int((a - b*cos(e + f*x))*(c + d*cos(e + f*x))**(n + S(-1)), x), x) + Simp(b*(c + d*cos(e + f*x))**n*sin(e + f*x)/(a*f*(a + b*cos(e + f*x))), x) rule2459 = ReplacementRule(pattern2459, replacement2459) pattern2460 = Pattern(Integral(sqrt(a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))*(WC('c', S(0)) + WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1265, cons1323, cons87, cons88, cons808) def replacement2460(f, b, d, c, a, n, x, e): rubi.append(2460) return Dist(S(2)*n*(a*d + b*c)/(b*(S(2)*n + S(1))), Int(sqrt(a + b*sin(e + f*x))*(c + d*sin(e + f*x))**(n + S(-1)), x), x) + Simp(-S(2)*b*(c + d*sin(e + f*x))**n*cos(e + f*x)/(f*sqrt(a + b*sin(e + f*x))*(S(2)*n + S(1))), x) rule2460 = ReplacementRule(pattern2460, replacement2460) pattern2461 = Pattern(Integral(sqrt(a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))*(WC('c', S(0)) + WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1265, cons1323, cons87, cons88, cons808) def replacement2461(f, b, d, c, n, a, x, e): rubi.append(2461) return Dist(S(2)*n*(a*d + b*c)/(b*(S(2)*n + S(1))), Int(sqrt(a + b*cos(e + f*x))*(c + d*cos(e + f*x))**(n + S(-1)), x), x) + Simp(S(2)*b*(c + d*cos(e + f*x))**n*sin(e + f*x)/(f*sqrt(a + b*cos(e + f*x))*(S(2)*n + S(1))), x) rule2461 = ReplacementRule(pattern2461, replacement2461) pattern2462 = Pattern(Integral(sqrt(a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))/(WC('c', S(0)) + WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**(S(3)/2), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1265, cons1323) def replacement2462(f, b, d, c, a, x, e): rubi.append(2462) return Simp(-S(2)*b**S(2)*cos(e + f*x)/(f*sqrt(a + b*sin(e + f*x))*sqrt(c + d*sin(e + f*x))*(a*d + b*c)), x) rule2462 = ReplacementRule(pattern2462, replacement2462) pattern2463 = Pattern(Integral(sqrt(a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))/(WC('c', S(0)) + WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**(S(3)/2), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1265, cons1323) def replacement2463(f, b, d, c, a, x, e): rubi.append(2463) return Simp(S(2)*b**S(2)*sin(e + f*x)/(f*sqrt(a + b*cos(e + f*x))*sqrt(c + d*cos(e + f*x))*(a*d + b*c)), x) rule2463 = ReplacementRule(pattern2463, replacement2463) pattern2464 = Pattern(Integral(sqrt(a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))*(WC('c', S(0)) + WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1265, cons1323, cons87, cons89, cons1329, cons808) def replacement2464(f, b, d, c, a, n, x, e): rubi.append(2464) return Dist((S(2)*n + S(3))*(-a*d + b*c)/(S(2)*b*(c**S(2) - d**S(2))*(n + S(1))), Int(sqrt(a + b*sin(e + f*x))*(c + d*sin(e + f*x))**(n + S(1)), x), x) + Simp((c + d*sin(e + f*x))**(n + S(1))*(-a*d + b*c)*cos(e + f*x)/(f*sqrt(a + b*sin(e + f*x))*(c**S(2) - d**S(2))*(n + S(1))), x) rule2464 = ReplacementRule(pattern2464, replacement2464) pattern2465 = Pattern(Integral(sqrt(a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))*(WC('c', S(0)) + WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1265, cons1323, cons87, cons89, cons808) def replacement2465(f, b, d, c, n, a, x, e): rubi.append(2465) return Dist((S(2)*n + S(3))*(-a*d + b*c)/(S(2)*b*(c**S(2) - d**S(2))*(n + S(1))), Int(sqrt(a + b*cos(e + f*x))*(c + d*cos(e + f*x))**(n + S(1)), x), x) - Simp((c + d*cos(e + f*x))**(n + S(1))*(-a*d + b*c)*sin(e + f*x)/(f*sqrt(a + b*cos(e + f*x))*(c**S(2) - d**S(2))*(n + S(1))), x) rule2465 = ReplacementRule(pattern2465, replacement2465) pattern2466 = Pattern(Integral(sqrt(a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))/(WC('c', S(0)) + WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1265, cons1323) def replacement2466(f, b, d, c, a, x, e): rubi.append(2466) return Dist(-S(2)*b/f, Subst(Int(S(1)/(a*d + b*c - d*x**S(2)), x), x, b*cos(e + f*x)/sqrt(a + b*sin(e + f*x))), x) rule2466 = ReplacementRule(pattern2466, replacement2466) pattern2467 = Pattern(Integral(sqrt(a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))/(WC('c', S(0)) + WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1265, cons1323) def replacement2467(f, b, d, c, a, x, e): rubi.append(2467) return Dist(S(2)*b/f, Subst(Int(S(1)/(a*d + b*c - d*x**S(2)), x), x, b*sin(e + f*x)/sqrt(a + b*cos(e + f*x))), x) rule2467 = ReplacementRule(pattern2467, replacement2467) pattern2468 = Pattern(Integral(sqrt(a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))/sqrt(WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons27, cons48, cons125, cons1265, cons1330) def replacement2468(f, b, d, a, x, e): rubi.append(2468) return Dist(-S(2)/f, Subst(Int(S(1)/sqrt(S(1) - x**S(2)/a), x), x, b*cos(e + f*x)/sqrt(a + b*sin(e + f*x))), x) rule2468 = ReplacementRule(pattern2468, replacement2468) pattern2469 = Pattern(Integral(sqrt(a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))/sqrt(WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons27, cons48, cons125, cons1265, cons1330) def replacement2469(f, b, d, a, x, e): rubi.append(2469) return Dist(S(2)/f, Subst(Int(S(1)/sqrt(S(1) - x**S(2)/a), x), x, b*sin(e + f*x)/sqrt(a + b*cos(e + f*x))), x) rule2469 = ReplacementRule(pattern2469, replacement2469) pattern2470 = Pattern(Integral(sqrt(a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))/sqrt(WC('c', S(0)) + WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1265, cons1323) def replacement2470(f, b, d, c, a, x, e): rubi.append(2470) return Dist(-S(2)*b/f, Subst(Int(S(1)/(b + d*x**S(2)), x), x, b*cos(e + f*x)/(sqrt(a + b*sin(e + f*x))*sqrt(c + d*sin(e + f*x)))), x) rule2470 = ReplacementRule(pattern2470, replacement2470) pattern2471 = Pattern(Integral(sqrt(a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))/sqrt(WC('c', S(0)) + WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1265, cons1323) def replacement2471(f, b, d, c, a, x, e): rubi.append(2471) return Dist(S(2)*b/f, Subst(Int(S(1)/(b + d*x**S(2)), x), x, b*sin(e + f*x)/(sqrt(a + b*cos(e + f*x))*sqrt(c + d*cos(e + f*x)))), x) rule2471 = ReplacementRule(pattern2471, replacement2471) pattern2472 = Pattern(Integral(sqrt(a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))*(WC('c', S(0)) + WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons4, cons71, cons1265, cons1323, cons543) def replacement2472(f, b, d, c, a, n, x, e): rubi.append(2472) return Dist(a**S(2)*cos(e + f*x)/(f*sqrt(a - b*sin(e + f*x))*sqrt(a + b*sin(e + f*x))), Subst(Int((c + d*x)**n/sqrt(a - b*x), x), x, sin(e + f*x)), x) rule2472 = ReplacementRule(pattern2472, replacement2472) pattern2473 = Pattern(Integral(sqrt(a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))*(WC('c', S(0)) + WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons4, cons71, cons1265, cons1323, cons543) def replacement2473(f, b, d, c, n, a, x, e): rubi.append(2473) return -Dist(a**S(2)*sin(e + f*x)/(f*sqrt(a - b*cos(e + f*x))*sqrt(a + b*cos(e + f*x))), Subst(Int((c + d*x)**n/sqrt(a - b*x), x), x, cos(e + f*x)), x) rule2473 = ReplacementRule(pattern2473, replacement2473) pattern2474 = Pattern(Integral(sqrt(WC('c', S(0)) + WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))/sqrt(a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1265, cons1323) def replacement2474(f, b, d, c, a, x, e): rubi.append(2474) return Dist(d/b, Int(sqrt(a + b*sin(e + f*x))/sqrt(c + d*sin(e + f*x)), x), x) + Dist((-a*d + b*c)/b, Int(S(1)/(sqrt(a + b*sin(e + f*x))*sqrt(c + d*sin(e + f*x))), x), x) rule2474 = ReplacementRule(pattern2474, replacement2474) pattern2475 = Pattern(Integral(sqrt(WC('c', S(0)) + WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))/sqrt(a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1265, cons1323) def replacement2475(f, b, d, c, a, x, e): rubi.append(2475) return Dist(d/b, Int(sqrt(a + b*cos(e + f*x))/sqrt(c + d*cos(e + f*x)), x), x) + Dist((-a*d + b*c)/b, Int(S(1)/(sqrt(a + b*cos(e + f*x))*sqrt(c + d*cos(e + f*x))), x), x) rule2475 = ReplacementRule(pattern2475, replacement2475) pattern2476 = Pattern(Integral((WC('c', S(0)) + WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_/sqrt(a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1265, cons1323, cons87, cons165, cons808) def replacement2476(f, b, d, c, a, n, x, e): rubi.append(2476) return -Dist(S(1)/(b*(S(2)*n + S(-1))), Int((c + d*sin(e + f*x))**(n + S(-2))*Simp(a*c*d - b*(c**S(2)*(S(2)*n + S(-1)) + S(2)*d**S(2)*(n + S(-1))) + d*(a*d - b*c*(S(4)*n + S(-3)))*sin(e + f*x), x)/sqrt(a + b*sin(e + f*x)), x), x) + Simp(-S(2)*d*(c + d*sin(e + f*x))**(n + S(-1))*cos(e + f*x)/(f*sqrt(a + b*sin(e + f*x))*(S(2)*n + S(-1))), x) rule2476 = ReplacementRule(pattern2476, replacement2476) pattern2477 = Pattern(Integral((WC('c', S(0)) + WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_/sqrt(a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1265, cons1323, cons87, cons165, cons808) def replacement2477(f, b, d, c, n, a, x, e): rubi.append(2477) return -Dist(S(1)/(b*(S(2)*n + S(-1))), Int((c + d*cos(e + f*x))**(n + S(-2))*Simp(a*c*d - b*(c**S(2)*(S(2)*n + S(-1)) + S(2)*d**S(2)*(n + S(-1))) + d*(a*d - b*c*(S(4)*n + S(-3)))*cos(e + f*x), x)/sqrt(a + b*cos(e + f*x)), x), x) + Simp(S(2)*d*(c + d*cos(e + f*x))**(n + S(-1))*sin(e + f*x)/(f*sqrt(a + b*cos(e + f*x))*(S(2)*n + S(-1))), x) rule2477 = ReplacementRule(pattern2477, replacement2477) pattern2478 = Pattern(Integral((WC('c', S(0)) + WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_/sqrt(a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1265, cons1323, cons87, cons89, cons808) def replacement2478(f, b, d, c, a, n, x, e): rubi.append(2478) return -Dist(S(1)/(S(2)*b*(c**S(2) - d**S(2))*(n + S(1))), Int((c + d*sin(e + f*x))**(n + S(1))*Simp(a*d - S(2)*b*c*(n + S(1)) + b*d*(S(2)*n + S(3))*sin(e + f*x), x)/sqrt(a + b*sin(e + f*x)), x), x) - Simp(d*(c + d*sin(e + f*x))**(n + S(1))*cos(e + f*x)/(f*sqrt(a + b*sin(e + f*x))*(c**S(2) - d**S(2))*(n + S(1))), x) rule2478 = ReplacementRule(pattern2478, replacement2478) pattern2479 = Pattern(Integral((WC('c', S(0)) + WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_/sqrt(a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1265, cons1323, cons87, cons89, cons808) def replacement2479(f, b, d, c, n, a, x, e): rubi.append(2479) return -Dist(S(1)/(S(2)*b*(c**S(2) - d**S(2))*(n + S(1))), Int((c + d*cos(e + f*x))**(n + S(1))*Simp(a*d - S(2)*b*c*(n + S(1)) + b*d*(S(2)*n + S(3))*cos(e + f*x), x)/sqrt(a + b*cos(e + f*x)), x), x) + Simp(d*(c + d*cos(e + f*x))**(n + S(1))*sin(e + f*x)/(f*sqrt(a + b*cos(e + f*x))*(c**S(2) - d**S(2))*(n + S(1))), x) rule2479 = ReplacementRule(pattern2479, replacement2479) pattern2480 = Pattern(Integral(S(1)/(sqrt(a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))*(WC('c', S(0)) + WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1265, cons1323) def replacement2480(f, b, d, c, a, x, e): rubi.append(2480) return Dist(b/(-a*d + b*c), Int(S(1)/sqrt(a + b*sin(e + f*x)), x), x) - Dist(d/(-a*d + b*c), Int(sqrt(a + b*sin(e + f*x))/(c + d*sin(e + f*x)), x), x) rule2480 = ReplacementRule(pattern2480, replacement2480) pattern2481 = Pattern(Integral(S(1)/(sqrt(a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))*(WC('c', S(0)) + WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1265, cons1323) def replacement2481(f, b, d, c, a, x, e): rubi.append(2481) return Dist(b/(-a*d + b*c), Int(S(1)/sqrt(a + b*cos(e + f*x)), x), x) - Dist(d/(-a*d + b*c), Int(sqrt(a + b*cos(e + f*x))/(c + d*cos(e + f*x)), x), x) rule2481 = ReplacementRule(pattern2481, replacement2481) pattern2482 = Pattern(Integral(S(1)/(sqrt(WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))*sqrt(a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))), x_), cons2, cons3, cons27, cons48, cons125, cons1265, cons1330, cons43) def replacement2482(f, b, d, a, x, e): rubi.append(2482) return -Dist(sqrt(S(2))/(sqrt(a)*f), Subst(Int(S(1)/sqrt(-x**S(2) + S(1)), x), x, b*cos(e + f*x)/(a + b*sin(e + f*x))), x) rule2482 = ReplacementRule(pattern2482, replacement2482) pattern2483 = Pattern(Integral(S(1)/(sqrt(WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))*sqrt(a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))), x_), cons2, cons3, cons27, cons48, cons125, cons1265, cons1330, cons43) def replacement2483(f, b, d, a, x, e): rubi.append(2483) return Dist(sqrt(S(2))/(sqrt(a)*f), Subst(Int(S(1)/sqrt(-x**S(2) + S(1)), x), x, b*sin(e + f*x)/(a + b*cos(e + f*x))), x) rule2483 = ReplacementRule(pattern2483, replacement2483) pattern2484 = Pattern(Integral(S(1)/(sqrt(a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))*sqrt(WC('c', S(0)) + WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1265, cons1323) def replacement2484(f, b, d, c, a, x, e): rubi.append(2484) return Dist(-S(2)*a/f, Subst(Int(S(1)/(S(2)*b**S(2) - x**S(2)*(a*c - b*d)), x), x, b*cos(e + f*x)/(sqrt(a + b*sin(e + f*x))*sqrt(c + d*sin(e + f*x)))), x) rule2484 = ReplacementRule(pattern2484, replacement2484) pattern2485 = Pattern(Integral(S(1)/(sqrt(a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))*sqrt(WC('c', S(0)) + WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1265, cons1323) def replacement2485(f, b, d, c, a, x, e): rubi.append(2485) return Dist(S(2)*a/f, Subst(Int(S(1)/(S(2)*b**S(2) - x**S(2)*(a*c - b*d)), x), x, b*sin(e + f*x)/(sqrt(a + b*cos(e + f*x))*sqrt(c + d*cos(e + f*x)))), x) rule2485 = ReplacementRule(pattern2485, replacement2485) pattern2486 = Pattern(Integral((a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons71, cons1265, cons1323, cons87, cons165, cons85) def replacement2486(m, f, b, d, c, a, n, x, e): rubi.append(2486) return Dist(S(1)/(b*(m + n)), Int((a + b*sin(e + f*x))**m*(c + d*sin(e + f*x))**(n + S(-2))*Simp(b*c**S(2)*(m + n) + d*(a*c*m + b*d*(n + S(-1))) + d*(a*d*m + b*c*(m + S(2)*n + S(-1)))*sin(e + f*x), x), x), x) - Simp(d*(a + b*sin(e + f*x))**m*(c + d*sin(e + f*x))**(n + S(-1))*cos(e + f*x)/(f*(m + n)), x) rule2486 = ReplacementRule(pattern2486, replacement2486) pattern2487 = Pattern(Integral((a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons71, cons1265, cons1323, cons87, cons165, cons85) def replacement2487(m, f, b, d, c, n, a, x, e): rubi.append(2487) return Dist(S(1)/(b*(m + n)), Int((a + b*cos(e + f*x))**m*(c + d*cos(e + f*x))**(n + S(-2))*Simp(b*c**S(2)*(m + n) + d*(a*c*m + b*d*(n + S(-1))) + d*(a*d*m + b*c*(m + S(2)*n + S(-1)))*cos(e + f*x), x), x), x) + Simp(d*(a + b*cos(e + f*x))**m*(c + d*cos(e + f*x))**(n + S(-1))*sin(e + f*x)/(f*(m + n)), x) rule2487 = ReplacementRule(pattern2487, replacement2487) pattern2488 = Pattern(Integral((a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons4, cons71, cons1265, cons1323, cons17) def replacement2488(m, f, b, d, c, n, a, x, e): rubi.append(2488) return Dist(a**m*cos(e + f*x)/(f*sqrt(-sin(e + f*x) + S(1))*sqrt(sin(e + f*x) + S(1))), Subst(Int((S(1) + b*x/a)**(m + S(-1)/2)*(c + d*x)**n/sqrt(S(1) - b*x/a), x), x, sin(e + f*x)), x) rule2488 = ReplacementRule(pattern2488, replacement2488) pattern2489 = Pattern(Integral((a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons4, cons71, cons1265, cons1323, cons17) def replacement2489(m, f, b, d, c, n, a, x, e): rubi.append(2489) return -Dist(a**m*sin(e + f*x)/(f*sqrt(-cos(e + f*x) + S(1))*sqrt(cos(e + f*x) + S(1))), Subst(Int((S(1) + b*x/a)**(m + S(-1)/2)*(c + d*x)**n/sqrt(S(1) - b*x/a), x), x, cos(e + f*x)), x) rule2489 = ReplacementRule(pattern2489, replacement2489) pattern2490 = Pattern(Integral((WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_, x_), cons2, cons3, cons27, cons48, cons125, cons21, cons4, cons1265, cons18, cons43, cons1331) def replacement2490(m, f, b, d, a, n, x, e): rubi.append(2490) return -Dist(b*(d/b)**n*cos(e + f*x)/(f*sqrt(a - b*sin(e + f*x))*sqrt(a + b*sin(e + f*x))), Subst(Int((a - x)**n*(S(2)*a - x)**(m + S(-1)/2)/sqrt(x), x), x, a - b*sin(e + f*x)), x) rule2490 = ReplacementRule(pattern2490, replacement2490) pattern2491 = Pattern(Integral((WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_, x_), cons2, cons3, cons27, cons48, cons125, cons21, cons4, cons1265, cons18, cons43, cons1331) def replacement2491(m, f, b, d, a, n, x, e): rubi.append(2491) return Dist(b*(d/b)**n*sin(e + f*x)/(f*sqrt(a - b*cos(e + f*x))*sqrt(a + b*cos(e + f*x))), Subst(Int((a - x)**n*(S(2)*a - x)**(m + S(-1)/2)/sqrt(x), x), x, a - b*cos(e + f*x)), x) rule2491 = ReplacementRule(pattern2491, replacement2491) pattern2492 = Pattern(Integral((WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1))*(a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_, x_), cons2, cons3, cons27, cons48, cons125, cons21, cons4, cons1265, cons18, cons43, cons1332) def replacement2492(m, f, b, d, a, n, x, e): rubi.append(2492) return Dist((d/b)**IntPart(n)*(b*sin(e + f*x))**(-FracPart(n))*(d*sin(e + f*x))**FracPart(n), Int((b*sin(e + f*x))**n*(a + b*sin(e + f*x))**m, x), x) rule2492 = ReplacementRule(pattern2492, replacement2492) pattern2493 = Pattern(Integral((WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1))*(a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_, x_), cons2, cons3, cons27, cons48, cons125, cons21, cons4, cons1265, cons18, cons43, cons1332) def replacement2493(m, f, b, d, a, n, x, e): rubi.append(2493) return Dist((d/b)**IntPart(n)*(b*cos(e + f*x))**(-FracPart(n))*(d*cos(e + f*x))**FracPart(n), Int((b*cos(e + f*x))**n*(a + b*cos(e + f*x))**m, x), x) rule2493 = ReplacementRule(pattern2493, replacement2493) pattern2494 = Pattern(Integral((WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1))*(a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_, x_), cons2, cons3, cons27, cons48, cons125, cons21, cons4, cons1265, cons18, cons448) def replacement2494(m, f, b, d, a, n, x, e): rubi.append(2494) return Dist(a**IntPart(m)*(S(1) + b*sin(e + f*x)/a)**(-FracPart(m))*(a + b*sin(e + f*x))**FracPart(m), Int((d*sin(e + f*x))**n*(S(1) + b*sin(e + f*x)/a)**m, x), x) rule2494 = ReplacementRule(pattern2494, replacement2494) pattern2495 = Pattern(Integral((WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1))*(a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_, x_), cons2, cons3, cons27, cons48, cons125, cons21, cons4, cons1265, cons18, cons448) def replacement2495(m, f, b, d, a, n, x, e): rubi.append(2495) return Dist(a**IntPart(m)*(S(1) + b*cos(e + f*x)/a)**(-FracPart(m))*(a + b*cos(e + f*x))**FracPart(m), Int((d*cos(e + f*x))**n*(S(1) + b*cos(e + f*x)/a)**m, x), x) rule2495 = ReplacementRule(pattern2495, replacement2495) pattern2496 = Pattern(Integral((a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(c_ + WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons4, cons71, cons1265, cons1323, cons18) def replacement2496(m, f, b, d, a, n, c, x, e): rubi.append(2496) return Dist(a**S(2)*cos(e + f*x)/(f*sqrt(a - b*sin(e + f*x))*sqrt(a + b*sin(e + f*x))), Subst(Int((a + b*x)**(m + S(-1)/2)*(c + d*x)**n/sqrt(a - b*x), x), x, sin(e + f*x)), x) rule2496 = ReplacementRule(pattern2496, replacement2496) pattern2497 = Pattern(Integral((a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(c_ + WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons4, cons71, cons1265, cons1323, cons18) def replacement2497(m, f, b, d, a, n, c, x, e): rubi.append(2497) return -Dist(a**S(2)*sin(e + f*x)/(f*sqrt(a - b*cos(e + f*x))*sqrt(a + b*cos(e + f*x))), Subst(Int((a + b*x)**(m + S(-1)/2)*(c + d*x)**n/sqrt(a - b*x), x), x, cos(e + f*x)), x) rule2497 = ReplacementRule(pattern2497, replacement2497) pattern2498 = Pattern(Integral((WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(c_ + WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**S(2), x_), cons3, cons7, cons27, cons48, cons125, cons21, cons1318) def replacement2498(m, f, b, d, c, x, e): rubi.append(2498) return Dist(S(2)*c*d/b, Int((b*sin(e + f*x))**(m + S(1)), x), x) + Int((b*sin(e + f*x))**m*(c**S(2) + d**S(2)*sin(e + f*x)**S(2)), x) rule2498 = ReplacementRule(pattern2498, replacement2498) pattern2499 = Pattern(Integral((WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(c_ + WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**S(2), x_), cons3, cons7, cons27, cons48, cons125, cons21, cons1318) def replacement2499(m, f, b, d, c, x, e): rubi.append(2499) return Dist(S(2)*c*d/b, Int((b*cos(e + f*x))**(m + S(1)), x), x) + Int((b*cos(e + f*x))**m*(c**S(2) + d**S(2)*cos(e + f*x)**S(2)), x) rule2499 = ReplacementRule(pattern2499, replacement2499) pattern2500 = Pattern(Integral((a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**S(2), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1267, cons31, cons94) def replacement2500(m, f, b, d, c, a, x, e): rubi.append(2500) return -Dist(S(1)/(b*(a**S(2) - b**S(2))*(m + S(1))), Int((a + b*sin(e + f*x))**(m + S(1))*Simp(b*(m + S(1))*(-a*(c**S(2) + d**S(2)) + S(2)*b*c*d) + (a**S(2)*d**S(2) - S(2)*a*b*c*d*(m + S(2)) + b**S(2)*(c**S(2)*(m + S(2)) + d**S(2)*(m + S(1))))*sin(e + f*x), x), x), x) - Simp((a + b*sin(e + f*x))**(m + S(1))*(a**S(2)*d**S(2) - S(2)*a*b*c*d + b**S(2)*c**S(2))*cos(e + f*x)/(b*f*(a**S(2) - b**S(2))*(m + S(1))), x) rule2500 = ReplacementRule(pattern2500, replacement2500) pattern2501 = Pattern(Integral((a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**S(2), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1267, cons31, cons94) def replacement2501(m, f, b, d, c, a, x, e): rubi.append(2501) return -Dist(S(1)/(b*(a**S(2) - b**S(2))*(m + S(1))), Int((a + b*cos(e + f*x))**(m + S(1))*Simp(b*(m + S(1))*(-a*(c**S(2) + d**S(2)) + S(2)*b*c*d) + (a**S(2)*d**S(2) - S(2)*a*b*c*d*(m + S(2)) + b**S(2)*(c**S(2)*(m + S(2)) + d**S(2)*(m + S(1))))*cos(e + f*x), x), x), x) + Simp((a + b*cos(e + f*x))**(m + S(1))*(a**S(2)*d**S(2) - S(2)*a*b*c*d + b**S(2)*c**S(2))*sin(e + f*x)/(b*f*(a**S(2) - b**S(2))*(m + S(1))), x) rule2501 = ReplacementRule(pattern2501, replacement2501) pattern2502 = Pattern(Integral((a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**S(2), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons71, cons1267, cons272) def replacement2502(m, f, b, d, c, a, x, e): rubi.append(2502) return Dist(S(1)/(b*(m + S(2))), Int((a + b*sin(e + f*x))**m*Simp(b*(c**S(2)*(m + S(2)) + d**S(2)*(m + S(1))) - d*(a*d - S(2)*b*c*(m + S(2)))*sin(e + f*x), x), x), x) - Simp(d**S(2)*(a + b*sin(e + f*x))**(m + S(1))*cos(e + f*x)/(b*f*(m + S(2))), x) rule2502 = ReplacementRule(pattern2502, replacement2502) pattern2503 = Pattern(Integral((a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**S(2), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons71, cons1267, cons272) def replacement2503(m, f, b, d, c, a, x, e): rubi.append(2503) return Dist(S(1)/(b*(m + S(2))), Int((a + b*cos(e + f*x))**m*Simp(b*(c**S(2)*(m + S(2)) + d**S(2)*(m + S(1))) - d*(a*d - S(2)*b*c*(m + S(2)))*cos(e + f*x), x), x), x) + Simp(d**S(2)*(a + b*cos(e + f*x))**(m + S(1))*sin(e + f*x)/(b*f*(m + S(2))), x) rule2503 = ReplacementRule(pattern2503, replacement2503) pattern2504 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1267, cons1323, cons93, cons1333, cons89, cons1334) def replacement2504(m, f, b, d, c, a, n, x, e): rubi.append(2504) return Dist(S(1)/(d*(c**S(2) - d**S(2))*(n + S(1))), Int((a + b*sin(e + f*x))**(m + S(-3))*(c + d*sin(e + f*x))**(n + S(1))*Simp(a*d*(n + S(1))*(-S(2)*a*b*d + c*(a**S(2) + b**S(2))) + b*(m + S(-2))*(-a*d + b*c)**S(2) + b*(b**S(2)*(c**S(2) - d**S(2)) + d*n*(S(2)*a*b*c - d*(a**S(2) + b**S(2))) - m*(-a*d + b*c)**S(2))*sin(e + f*x)**S(2) + (-a*(n + S(2))*(-a*d + b*c)**S(2) + b*(n + S(1))*(a*b*c**S(2) - S(3)*a*b*d**S(2) + c*d*(a**S(2) + b**S(2))))*sin(e + f*x), x), x), x) - Simp((a + b*sin(e + f*x))**(m + S(-2))*(c + d*sin(e + f*x))**(n + S(1))*(a**S(2)*d**S(2) - S(2)*a*b*c*d + b**S(2)*c**S(2))*cos(e + f*x)/(d*f*(c**S(2) - d**S(2))*(n + S(1))), x) rule2504 = ReplacementRule(pattern2504, replacement2504) pattern2505 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1267, cons1323, cons93, cons1333, cons89, cons1334) def replacement2505(m, f, b, d, c, a, n, x, e): rubi.append(2505) return Dist(S(1)/(d*(c**S(2) - d**S(2))*(n + S(1))), Int((a + b*cos(e + f*x))**(m + S(-3))*(c + d*cos(e + f*x))**(n + S(1))*Simp(a*d*(n + S(1))*(-S(2)*a*b*d + c*(a**S(2) + b**S(2))) + b*(m + S(-2))*(-a*d + b*c)**S(2) + b*(b**S(2)*(c**S(2) - d**S(2)) + d*n*(S(2)*a*b*c - d*(a**S(2) + b**S(2))) - m*(-a*d + b*c)**S(2))*cos(e + f*x)**S(2) + (-a*(n + S(2))*(-a*d + b*c)**S(2) + b*(n + S(1))*(a*b*c**S(2) - S(3)*a*b*d**S(2) + c*d*(a**S(2) + b**S(2))))*cos(e + f*x), x), x), x) + Simp((a + b*cos(e + f*x))**(m + S(-2))*(c + d*cos(e + f*x))**(n + S(1))*(a**S(2)*d**S(2) - S(2)*a*b*c*d + b**S(2)*c**S(2))*sin(e + f*x)/(d*f*(c**S(2) - d**S(2))*(n + S(1))), x) rule2505 = ReplacementRule(pattern2505, replacement2505) pattern2506 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons4, cons71, cons1267, cons1323, cons31, cons1333, cons1334, cons1335) def replacement2506(m, f, b, d, c, a, n, x, e): rubi.append(2506) return Dist(S(1)/(d*(m + n)), Int((a + b*sin(e + f*x))**(m + S(-3))*(c + d*sin(e + f*x))**n*Simp(a**S(3)*d*(m + n) + b**S(2)*(a*d*(n + S(1)) + b*c*(m + S(-2))) - b**S(2)*(-a*d*(S(3)*m + S(2)*n + S(-2)) + b*c*(m + S(-1)))*sin(e + f*x)**S(2) - b*(-S(3)*a**S(2)*d*(m + n) + a*b*c - b**S(2)*d*(m + n + S(-1)))*sin(e + f*x), x), x), x) - Simp(b**S(2)*(a + b*sin(e + f*x))**(m + S(-2))*(c + d*sin(e + f*x))**(n + S(1))*cos(e + f*x)/(d*f*(m + n)), x) rule2506 = ReplacementRule(pattern2506, replacement2506) pattern2507 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons4, cons71, cons1267, cons1323, cons31, cons1333, cons1334, cons1335) def replacement2507(m, f, b, d, c, a, n, x, e): rubi.append(2507) return Dist(S(1)/(d*(m + n)), Int((a + b*cos(e + f*x))**(m + S(-3))*(c + d*cos(e + f*x))**n*Simp(a**S(3)*d*(m + n) + b**S(2)*(a*d*(n + S(1)) + b*c*(m + S(-2))) - b**S(2)*(-a*d*(S(3)*m + S(2)*n + S(-2)) + b*c*(m + S(-1)))*cos(e + f*x)**S(2) - b*(-S(3)*a**S(2)*d*(m + n) + a*b*c - b**S(2)*d*(m + n + S(-1)))*cos(e + f*x), x), x), x) + Simp(b**S(2)*(a + b*cos(e + f*x))**(m + S(-2))*(c + d*cos(e + f*x))**(n + S(1))*sin(e + f*x)/(d*f*(m + n)), x) rule2507 = ReplacementRule(pattern2507, replacement2507) pattern2508 = Pattern(Integral(sqrt(WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))/(a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**(S(3)/2), x_), cons2, cons3, cons27, cons48, cons125, cons1267) def replacement2508(f, b, d, a, x, e): rubi.append(2508) return -Dist(d**S(2)/(a**S(2) - b**S(2)), Int(sqrt(a + b*sin(e + f*x))/(d*sin(e + f*x))**(S(3)/2), x), x) + Simp(-S(2)*a*d*cos(e + f*x)/(f*sqrt(d*sin(e + f*x))*sqrt(a + b*sin(e + f*x))*(a**S(2) - b**S(2))), x) rule2508 = ReplacementRule(pattern2508, replacement2508) pattern2509 = Pattern(Integral(sqrt(WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))/(a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**(S(3)/2), x_), cons2, cons3, cons27, cons48, cons125, cons1267) def replacement2509(f, b, d, a, x, e): rubi.append(2509) return -Dist(d**S(2)/(a**S(2) - b**S(2)), Int(sqrt(a + b*cos(e + f*x))/(d*cos(e + f*x))**(S(3)/2), x), x) + Simp(S(2)*a*d*sin(e + f*x)/(f*sqrt(d*cos(e + f*x))*sqrt(a + b*cos(e + f*x))*(a**S(2) - b**S(2))), x) rule2509 = ReplacementRule(pattern2509, replacement2509) pattern2510 = Pattern(Integral(sqrt(c_ + WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))/(WC('a', S(0)) + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**(S(3)/2), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1267, cons1323) def replacement2510(f, b, d, a, c, x, e): rubi.append(2510) return Dist((c - d)/(a - b), Int(S(1)/(sqrt(a + b*sin(e + f*x))*sqrt(c + d*sin(e + f*x))), x), x) - Dist((-a*d + b*c)/(a - b), Int((sin(e + f*x) + S(1))/((a + b*sin(e + f*x))**(S(3)/2)*sqrt(c + d*sin(e + f*x))), x), x) rule2510 = ReplacementRule(pattern2510, replacement2510) pattern2511 = Pattern(Integral(sqrt(c_ + WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))/(WC('a', S(0)) + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**(S(3)/2), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1267, cons1323) def replacement2511(f, b, d, a, c, x, e): rubi.append(2511) return Dist((c - d)/(a - b), Int(S(1)/(sqrt(a + b*cos(e + f*x))*sqrt(c + d*cos(e + f*x))), x), x) - Dist((-a*d + b*c)/(a - b), Int((cos(e + f*x) + S(1))/((a + b*cos(e + f*x))**(S(3)/2)*sqrt(c + d*cos(e + f*x))), x), x) rule2511 = ReplacementRule(pattern2511, replacement2511) pattern2512 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1267, cons1323, cons93, cons94, cons1325, cons1170) def replacement2512(m, f, b, d, c, a, n, x, e): rubi.append(2512) return Dist(S(1)/((a**S(2) - b**S(2))*(m + S(1))), Int((a + b*sin(e + f*x))**(m + S(1))*(c + d*sin(e + f*x))**(n + S(-1))*Simp(a*c*(m + S(1)) + b*d*n - b*d*(m + n + S(2))*sin(e + f*x)**S(2) + (a*d*(m + S(1)) - b*c*(m + S(2)))*sin(e + f*x), x), x), x) - Simp(b*(a + b*sin(e + f*x))**(m + S(1))*(c + d*sin(e + f*x))**n*cos(e + f*x)/(f*(a**S(2) - b**S(2))*(m + S(1))), x) rule2512 = ReplacementRule(pattern2512, replacement2512) pattern2513 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1267, cons1323, cons93, cons94, cons1325, cons1170) def replacement2513(m, f, b, d, c, a, n, x, e): rubi.append(2513) return Dist(S(1)/((a**S(2) - b**S(2))*(m + S(1))), Int((a + b*cos(e + f*x))**(m + S(1))*(c + d*cos(e + f*x))**(n + S(-1))*Simp(a*c*(m + S(1)) + b*d*n - b*d*(m + n + S(2))*cos(e + f*x)**S(2) + (a*d*(m + S(1)) - b*c*(m + S(2)))*cos(e + f*x), x), x), x) + Simp(b*(a + b*cos(e + f*x))**(m + S(1))*(c + d*cos(e + f*x))**n*sin(e + f*x)/(f*(a**S(2) - b**S(2))*(m + S(1))), x) rule2513 = ReplacementRule(pattern2513, replacement2513) pattern2514 = Pattern(Integral((WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**(S(3)/2)/(a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**(S(3)/2), x_), cons2, cons3, cons27, cons48, cons125, cons1267) def replacement2514(f, b, d, a, x, e): rubi.append(2514) return Dist(d/b, Int(sqrt(d*sin(e + f*x))/sqrt(a + b*sin(e + f*x)), x), x) - Dist(a*d/b, Int(sqrt(d*sin(e + f*x))/(a + b*sin(e + f*x))**(S(3)/2), x), x) rule2514 = ReplacementRule(pattern2514, replacement2514) pattern2515 = Pattern(Integral((WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**(S(3)/2)/(a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**(S(3)/2), x_), cons2, cons3, cons27, cons48, cons125, cons1267) def replacement2515(f, b, d, a, x, e): rubi.append(2515) return Dist(d/b, Int(sqrt(d*cos(e + f*x))/sqrt(a + b*cos(e + f*x)), x), x) - Dist(a*d/b, Int(sqrt(d*cos(e + f*x))/(a + b*cos(e + f*x))**(S(3)/2), x), x) rule2515 = ReplacementRule(pattern2515, replacement2515) pattern2516 = Pattern(Integral((c_ + WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**(S(3)/2)/(WC('a', S(0)) + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**(S(3)/2), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1267, cons1323) def replacement2516(f, b, d, a, c, x, e): rubi.append(2516) return Dist(d**S(2)/b**S(2), Int(sqrt(a + b*sin(e + f*x))/sqrt(c + d*sin(e + f*x)), x), x) + Dist((-a*d + b*c)/b**S(2), Int(Simp(a*d + b*c + S(2)*b*d*sin(e + f*x), x)/((a + b*sin(e + f*x))**(S(3)/2)*sqrt(c + d*sin(e + f*x))), x), x) rule2516 = ReplacementRule(pattern2516, replacement2516) pattern2517 = Pattern(Integral((c_ + WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**(S(3)/2)/(WC('a', S(0)) + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**(S(3)/2), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1267, cons1323) def replacement2517(f, b, d, a, c, x, e): rubi.append(2517) return Dist(d**S(2)/b**S(2), Int(sqrt(a + b*cos(e + f*x))/sqrt(c + d*cos(e + f*x)), x), x) + Dist((-a*d + b*c)/b**S(2), Int(Simp(a*d + b*c + S(2)*b*d*cos(e + f*x), x)/((a + b*cos(e + f*x))**(S(3)/2)*sqrt(c + d*cos(e + f*x))), x), x) rule2517 = ReplacementRule(pattern2517, replacement2517) pattern2518 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1267, cons1323, cons93, cons94, cons1336, cons1170) def replacement2518(m, f, b, d, c, a, n, x, e): rubi.append(2518) return Dist(S(1)/((a**S(2) - b**S(2))*(m + S(1))), Int((a + b*sin(e + f*x))**(m + S(1))*(c + d*sin(e + f*x))**(n + S(-2))*Simp(c*(m + S(1))*(a*c - b*d) + d*(n + S(-1))*(-a*d + b*c) - d*(-a*d + b*c)*(m + n + S(1))*sin(e + f*x)**S(2) + (-c*(m + S(2))*(-a*d + b*c) + d*(m + S(1))*(a*c - b*d))*sin(e + f*x), x), x), x) - Simp((a + b*sin(e + f*x))**(m + S(1))*(c + d*sin(e + f*x))**(n + S(-1))*(-a*d + b*c)*cos(e + f*x)/(f*(a**S(2) - b**S(2))*(m + S(1))), x) rule2518 = ReplacementRule(pattern2518, replacement2518) pattern2519 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1267, cons1323, cons93, cons94, cons1336, cons1170) def replacement2519(m, f, b, d, c, a, n, x, e): rubi.append(2519) return Dist(S(1)/((a**S(2) - b**S(2))*(m + S(1))), Int((a + b*cos(e + f*x))**(m + S(1))*(c + d*cos(e + f*x))**(n + S(-2))*Simp(c*(m + S(1))*(a*c - b*d) + d*(n + S(-1))*(-a*d + b*c) - d*(-a*d + b*c)*(m + n + S(1))*cos(e + f*x)**S(2) + (-c*(m + S(2))*(-a*d + b*c) + d*(m + S(1))*(a*c - b*d))*cos(e + f*x), x), x), x) + Simp((a + b*cos(e + f*x))**(m + S(1))*(c + d*cos(e + f*x))**(n + S(-1))*(-a*d + b*c)*sin(e + f*x)/(f*(a**S(2) - b**S(2))*(m + S(1))), x) rule2519 = ReplacementRule(pattern2519, replacement2519) pattern2520 = Pattern(Integral(S(1)/(sqrt(WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))*(a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**(S(3)/2)), x_), cons2, cons3, cons27, cons48, cons125, cons1267) def replacement2520(f, b, d, a, x, e): rubi.append(2520) return Dist(d/(a**S(2) - b**S(2)), Int((a*sin(e + f*x) + b)/((d*sin(e + f*x))**(S(3)/2)*sqrt(a + b*sin(e + f*x))), x), x) + Simp(S(2)*b*cos(e + f*x)/(f*sqrt(d*sin(e + f*x))*sqrt(a + b*sin(e + f*x))*(a**S(2) - b**S(2))), x) rule2520 = ReplacementRule(pattern2520, replacement2520) pattern2521 = Pattern(Integral(S(1)/(sqrt(WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))*(a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**(S(3)/2)), x_), cons2, cons3, cons27, cons48, cons125, cons1267) def replacement2521(f, b, d, a, x, e): rubi.append(2521) return Dist(d/(a**S(2) - b**S(2)), Int((a*cos(e + f*x) + b)/((d*cos(e + f*x))**(S(3)/2)*sqrt(a + b*cos(e + f*x))), x), x) + Simp(-S(2)*b*sin(e + f*x)/(f*sqrt(d*cos(e + f*x))*sqrt(a + b*cos(e + f*x))*(a**S(2) - b**S(2))), x) rule2521 = ReplacementRule(pattern2521, replacement2521) pattern2522 = Pattern(Integral(S(1)/((WC('a', S(0)) + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**(S(3)/2)*sqrt(WC('c', S(0)) + WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1267, cons1323) def replacement2522(f, b, d, c, a, x, e): rubi.append(2522) return -Dist(b/(a - b), Int((sin(e + f*x) + S(1))/((a + b*sin(e + f*x))**(S(3)/2)*sqrt(c + d*sin(e + f*x))), x), x) + Dist(S(1)/(a - b), Int(S(1)/(sqrt(a + b*sin(e + f*x))*sqrt(c + d*sin(e + f*x))), x), x) rule2522 = ReplacementRule(pattern2522, replacement2522) pattern2523 = Pattern(Integral(S(1)/((WC('a', S(0)) + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**(S(3)/2)*sqrt(WC('c', S(0)) + WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1267, cons1323) def replacement2523(f, b, d, c, a, x, e): rubi.append(2523) return -Dist(b/(a - b), Int((cos(e + f*x) + S(1))/((a + b*cos(e + f*x))**(S(3)/2)*sqrt(c + d*cos(e + f*x))), x), x) + Dist(S(1)/(a - b), Int(S(1)/(sqrt(a + b*cos(e + f*x))*sqrt(c + d*cos(e + f*x))), x), x) rule2523 = ReplacementRule(pattern2523, replacement2523) pattern2524 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons4, cons71, cons1267, cons1323, cons31, cons94, cons1170, cons1337) def replacement2524(m, f, b, d, c, a, n, x, e): rubi.append(2524) return Dist(S(1)/((a**S(2) - b**S(2))*(m + S(1))*(-a*d + b*c)), Int((a + b*sin(e + f*x))**(m + S(1))*(c + d*sin(e + f*x))**n*Simp(a*(m + S(1))*(-a*d + b*c) + b**S(2)*d*(m + n + S(2)) - b**S(2)*d*(m + n + S(3))*sin(e + f*x)**S(2) - (b**S(2)*c + b*(m + S(1))*(-a*d + b*c))*sin(e + f*x), x), x), x) - Simp(b**S(2)*(a + b*sin(e + f*x))**(m + S(1))*(c + d*sin(e + f*x))**(n + S(1))*cos(e + f*x)/(f*(a**S(2) - b**S(2))*(m + S(1))*(-a*d + b*c)), x) rule2524 = ReplacementRule(pattern2524, replacement2524) pattern2525 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons4, cons71, cons1267, cons1323, cons31, cons94, cons1170, cons1337) def replacement2525(m, f, b, d, c, a, n, x, e): rubi.append(2525) return Dist(S(1)/((a**S(2) - b**S(2))*(m + S(1))*(-a*d + b*c)), Int((a + b*cos(e + f*x))**(m + S(1))*(c + d*cos(e + f*x))**n*Simp(a*(m + S(1))*(-a*d + b*c) + b**S(2)*d*(m + n + S(2)) - b**S(2)*d*(m + n + S(3))*cos(e + f*x)**S(2) - (b**S(2)*c + b*(m + S(1))*(-a*d + b*c))*cos(e + f*x), x), x), x) + Simp(b**S(2)*(a + b*cos(e + f*x))**(m + S(1))*(c + d*cos(e + f*x))**(n + S(1))*sin(e + f*x)/(f*(a**S(2) - b**S(2))*(m + S(1))*(-a*d + b*c)), x) rule2525 = ReplacementRule(pattern2525, replacement2525) pattern2526 = Pattern(Integral(sqrt(WC('c', S(0)) + WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))/(WC('a', S(0)) + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1267, cons1323) def replacement2526(f, b, d, c, a, x, e): rubi.append(2526) return Dist(d/b, Int(S(1)/sqrt(c + d*sin(e + f*x)), x), x) + Dist((-a*d + b*c)/b, Int(S(1)/((a + b*sin(e + f*x))*sqrt(c + d*sin(e + f*x))), x), x) rule2526 = ReplacementRule(pattern2526, replacement2526) pattern2527 = Pattern(Integral(sqrt(WC('c', S(0)) + WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))/(WC('a', S(0)) + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1267, cons1323) def replacement2527(f, b, d, c, a, x, e): rubi.append(2527) return Dist(d/b, Int(S(1)/sqrt(c + d*cos(e + f*x)), x), x) + Dist((-a*d + b*c)/b, Int(S(1)/((a + b*cos(e + f*x))*sqrt(c + d*cos(e + f*x))), x), x) rule2527 = ReplacementRule(pattern2527, replacement2527) pattern2528 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**(S(3)/2)/(WC('c', S(0)) + WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1267, cons1323) def replacement2528(f, b, d, c, a, x, e): rubi.append(2528) return Dist(b/d, Int(sqrt(a + b*sin(e + f*x)), x), x) - Dist((-a*d + b*c)/d, Int(sqrt(a + b*sin(e + f*x))/(c + d*sin(e + f*x)), x), x) rule2528 = ReplacementRule(pattern2528, replacement2528) pattern2529 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**(S(3)/2)/(WC('c', S(0)) + WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1267, cons1323) def replacement2529(f, b, d, c, a, x, e): rubi.append(2529) return Dist(b/d, Int(sqrt(a + b*cos(e + f*x)), x), x) - Dist((-a*d + b*c)/d, Int(sqrt(a + b*cos(e + f*x))/(c + d*cos(e + f*x)), x), x) rule2529 = ReplacementRule(pattern2529, replacement2529) pattern2530 = Pattern(Integral(S(1)/((WC('a', S(0)) + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))*sqrt(WC('c', S(0)) + WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1267, cons1323, cons1338) def replacement2530(f, b, d, c, a, x, e): rubi.append(2530) return Simp(S(2)*EllipticPi(S(2)*b/(a + b), -Pi/S(4) + e/S(2) + f*x/S(2), S(2)*d/(c + d))/(f*(a + b)*sqrt(c + d)), x) rule2530 = ReplacementRule(pattern2530, replacement2530) pattern2531 = Pattern(Integral(S(1)/((WC('a', S(0)) + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))*sqrt(WC('c', S(0)) + WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1267, cons1323, cons1338) def replacement2531(f, b, d, c, a, x, e): rubi.append(2531) return Simp(S(2)*EllipticPi(S(2)*b/(a + b), e/S(2) + f*x/S(2), S(2)*d/(c + d))/(f*(a + b)*sqrt(c + d)), x) rule2531 = ReplacementRule(pattern2531, replacement2531) pattern2532 = Pattern(Integral(S(1)/((WC('a', S(0)) + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))*sqrt(WC('c', S(0)) + WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1267, cons1323, cons1339) def replacement2532(f, b, d, c, a, x, e): rubi.append(2532) return Simp(S(2)*EllipticPi(-S(2)*b/(a - b), Pi/S(4) + e/S(2) + f*x/S(2), -S(2)*d/(c - d))/(f*(a - b)*sqrt(c - d)), x) rule2532 = ReplacementRule(pattern2532, replacement2532) pattern2533 = Pattern(Integral(S(1)/((WC('a', S(0)) + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))*sqrt(WC('c', S(0)) + WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1267, cons1323, cons1339) def replacement2533(f, b, d, c, a, x, e): rubi.append(2533) return Simp(S(2)*EllipticPi(-S(2)*b/(a - b), Pi/S(2) + e/S(2) + f*x/S(2), -S(2)*d/(c - d))/(f*(a - b)*sqrt(c - d)), x) rule2533 = ReplacementRule(pattern2533, replacement2533) pattern2534 = Pattern(Integral(S(1)/((WC('a', S(0)) + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))*sqrt(WC('c', S(0)) + WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1267, cons1323, cons1340) def replacement2534(f, b, d, c, a, x, e): rubi.append(2534) return Dist(sqrt((c + d*sin(e + f*x))/(c + d))/sqrt(c + d*sin(e + f*x)), Int(S(1)/((a + b*sin(e + f*x))*sqrt(c/(c + d) + d*sin(e + f*x)/(c + d))), x), x) rule2534 = ReplacementRule(pattern2534, replacement2534) pattern2535 = Pattern(Integral(S(1)/((WC('a', S(0)) + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))*sqrt(WC('c', S(0)) + WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1267, cons1323, cons1340) def replacement2535(f, b, d, c, a, x, e): rubi.append(2535) return Dist(sqrt((c + d*cos(e + f*x))/(c + d))/sqrt(c + d*cos(e + f*x)), Int(S(1)/((a + b*cos(e + f*x))*sqrt(c/(c + d) + d*cos(e + f*x)/(c + d))), x), x) rule2535 = ReplacementRule(pattern2535, replacement2535) pattern2536 = Pattern(Integral(sqrt(WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))/sqrt(c_ + WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons3, cons7, cons27, cons48, cons125, cons1341, cons1342, cons1343) def replacement2536(f, b, d, c, x, e): rubi.append(2536) return Simp(S(2)*c*sqrt(S(1) - S(1)/sin(e + f*x))*sqrt(S(1) + S(1)/sin(e + f*x))*EllipticPi((c + d)/d, asin(sqrt(c + d*sin(e + f*x))/(sqrt(b*sin(e + f*x))*Rt((c + d)/b, S(2)))), -(c + d)/(c - d))*Rt(b*(c + d), S(2))*tan(e + f*x)/(d*f*sqrt(c**S(2) - d**S(2))), x) rule2536 = ReplacementRule(pattern2536, replacement2536) pattern2537 = Pattern(Integral(sqrt(WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))/sqrt(c_ + WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons3, cons7, cons27, cons48, cons125, cons1341, cons1342, cons1343) def replacement2537(f, b, d, c, x, e): rubi.append(2537) return Simp(-S(2)*c*sqrt(S(1) - S(1)/cos(e + f*x))*sqrt(S(1) + S(1)/cos(e + f*x))*EllipticPi((c + d)/d, asin(sqrt(c + d*cos(e + f*x))/(sqrt(b*cos(e + f*x))*Rt((c + d)/b, S(2)))), -(c + d)/(c - d))*Rt(b*(c + d), S(2))/(d*f*sqrt(c**S(2) - d**S(2))*tan(e + f*x)), x) rule2537 = ReplacementRule(pattern2537, replacement2537) pattern2538 = Pattern(Integral(sqrt(WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))/sqrt(c_ + WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons3, cons7, cons27, cons48, cons125, cons1323, cons1342) def replacement2538(f, b, d, c, x, e): rubi.append(2538) return Simp(S(2)*b*sqrt(c*(S(1) - S(1)/sin(e + f*x))/(c + d))*sqrt(c*(S(1) + S(1)/sin(e + f*x))/(c - d))*EllipticPi((c + d)/d, asin(sqrt(c + d*sin(e + f*x))/(sqrt(b*sin(e + f*x))*Rt((c + d)/b, S(2)))), -(c + d)/(c - d))*Rt((c + d)/b, S(2))*tan(e + f*x)/(d*f), x) rule2538 = ReplacementRule(pattern2538, replacement2538) pattern2539 = Pattern(Integral(sqrt(WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))/sqrt(c_ + WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons3, cons7, cons27, cons48, cons125, cons1323, cons1342) def replacement2539(f, b, d, c, x, e): rubi.append(2539) return Simp(-S(2)*b*sqrt(c*(S(1) - S(1)/cos(e + f*x))/(c + d))*sqrt(c*(S(1) + S(1)/cos(e + f*x))/(c - d))*EllipticPi((c + d)/d, asin(sqrt(c + d*cos(e + f*x))/(sqrt(b*cos(e + f*x))*Rt((c + d)/b, S(2)))), -(c + d)/(c - d))*Rt((c + d)/b, S(2))/(d*f*tan(e + f*x)), x) rule2539 = ReplacementRule(pattern2539, replacement2539) pattern2540 = Pattern(Integral(sqrt(WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))/sqrt(c_ + WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons3, cons7, cons27, cons48, cons125, cons1323, cons1344) def replacement2540(f, b, d, c, x, e): rubi.append(2540) return Dist(sqrt(b*sin(e + f*x))/sqrt(-b*sin(e + f*x)), Int(sqrt(-b*sin(e + f*x))/sqrt(c + d*sin(e + f*x)), x), x) rule2540 = ReplacementRule(pattern2540, replacement2540) pattern2541 = Pattern(Integral(sqrt(WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))/sqrt(c_ + WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons3, cons7, cons27, cons48, cons125, cons1323, cons1344) def replacement2541(f, b, d, c, x, e): rubi.append(2541) return Dist(sqrt(b*cos(e + f*x))/sqrt(-b*cos(e + f*x)), Int(sqrt(-b*cos(e + f*x))/sqrt(c + d*cos(e + f*x)), x), x) rule2541 = ReplacementRule(pattern2541, replacement2541) pattern2542 = Pattern(Integral(sqrt(a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))/sqrt(WC('c', S(0)) + WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1267, cons1323, cons1345) def replacement2542(f, b, d, c, a, x, e): rubi.append(2542) return Simp(S(2)*sqrt((-a*d + b*c)*(sin(e + f*x) + S(1))/((a + b*sin(e + f*x))*(c - d)))*sqrt(-(-a*d + b*c)*(-sin(e + f*x) + S(1))/((a + b*sin(e + f*x))*(c + d)))*(a + b*sin(e + f*x))*EllipticPi(b*(c + d)/(d*(a + b)), asin(sqrt(c + d*sin(e + f*x))*Rt((a + b)/(c + d), S(2))/sqrt(a + b*sin(e + f*x))), (a - b)*(c + d)/((a + b)*(c - d)))/(d*f*Rt((a + b)/(c + d), S(2))*cos(e + f*x)), x) rule2542 = ReplacementRule(pattern2542, replacement2542) pattern2543 = Pattern(Integral(sqrt(a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))/sqrt(WC('c', S(0)) + WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1267, cons1323, cons1345) def replacement2543(f, b, d, c, a, x, e): rubi.append(2543) return Simp(-S(2)*sqrt((-a*d + b*c)*(cos(e + f*x) + S(1))/((a + b*cos(e + f*x))*(c - d)))*sqrt(-(-a*d + b*c)*(-cos(e + f*x) + S(1))/((a + b*cos(e + f*x))*(c + d)))*(a + b*cos(e + f*x))*EllipticPi(b*(c + d)/(d*(a + b)), asin(sqrt(c + d*cos(e + f*x))*Rt((a + b)/(c + d), S(2))/sqrt(a + b*cos(e + f*x))), (a - b)*(c + d)/((a + b)*(c - d)))/(d*f*Rt((a + b)/(c + d), S(2))*sin(e + f*x)), x) rule2543 = ReplacementRule(pattern2543, replacement2543) pattern2544 = Pattern(Integral(sqrt(a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))/sqrt(WC('c', S(0)) + WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1267, cons1323, cons1346) def replacement2544(f, b, d, c, a, x, e): rubi.append(2544) return Dist(sqrt(-c - d*sin(e + f*x))/sqrt(c + d*sin(e + f*x)), Int(sqrt(a + b*sin(e + f*x))/sqrt(-c - d*sin(e + f*x)), x), x) rule2544 = ReplacementRule(pattern2544, replacement2544) pattern2545 = Pattern(Integral(sqrt(a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))/sqrt(WC('c', S(0)) + WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1267, cons1323, cons1346) def replacement2545(f, b, d, c, a, x, e): rubi.append(2545) return Dist(sqrt(-c - d*cos(e + f*x))/sqrt(c + d*cos(e + f*x)), Int(sqrt(a + b*cos(e + f*x))/sqrt(-c - d*cos(e + f*x)), x), x) rule2545 = ReplacementRule(pattern2545, replacement2545) pattern2546 = Pattern(Integral(S(1)/(sqrt(WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))*sqrt(a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))), x_), cons2, cons3, cons27, cons48, cons125, cons1347, cons1348, cons1349) def replacement2546(f, b, d, a, x, e): rubi.append(2546) return Simp(-S(2)*d*EllipticF(asin(cos(e + f*x)/(d*sin(e + f*x) + S(1))), -(a - b*d)/(a + b*d))/(f*sqrt(a + b*d)), x) rule2546 = ReplacementRule(pattern2546, replacement2546) pattern2547 = Pattern(Integral(S(1)/(sqrt(WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))*sqrt(a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))), x_), cons2, cons3, cons27, cons48, cons125, cons1347, cons1348, cons1349) def replacement2547(f, b, d, a, x, e): rubi.append(2547) return Simp(S(2)*d*EllipticF(asin(sin(e + f*x)/(d*cos(e + f*x) + S(1))), -(a - b*d)/(a + b*d))/(f*sqrt(a + b*d)), x) rule2547 = ReplacementRule(pattern2547, replacement2547) pattern2548 = Pattern(Integral(S(1)/(sqrt(WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))*sqrt(a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))), x_), cons2, cons3, cons27, cons48, cons125, cons1347, cons1350, cons1351) def replacement2548(f, b, d, a, x, e): rubi.append(2548) return Dist(sqrt(sin(e + f*x)*sign(b))/sqrt(d*sin(e + f*x)), Int(S(1)/(sqrt(sin(e + f*x)*sign(b))*sqrt(a + b*sin(e + f*x))), x), x) rule2548 = ReplacementRule(pattern2548, replacement2548) pattern2549 = Pattern(Integral(S(1)/(sqrt(WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))*sqrt(a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))), x_), cons2, cons3, cons27, cons48, cons125, cons1347, cons1350, cons1351) def replacement2549(f, b, d, a, x, e): rubi.append(2549) return Dist(sqrt(cos(e + f*x)*sign(b))/sqrt(d*cos(e + f*x)), Int(S(1)/(sqrt(cos(e + f*x)*sign(b))*sqrt(a + b*cos(e + f*x))), x), x) rule2549 = ReplacementRule(pattern2549, replacement2549) pattern2550 = Pattern(Integral(S(1)/(sqrt(WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))*sqrt(a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))), x_), cons2, cons3, cons27, cons48, cons125, cons1271, cons1352, cons1353) def replacement2550(f, b, d, a, x, e): rubi.append(2550) return Simp(-S(2)*sqrt(-S(1)/tan(e + f*x)**S(2))*sqrt(a**S(2))*EllipticF(asin(sqrt(a + b*sin(e + f*x))/(sqrt(d*sin(e + f*x))*Rt((a + b)/d, S(2)))), -(a + b)/(a - b))*Rt((a + b)/d, S(2))*tan(e + f*x)/(a*f*sqrt(a**S(2) - b**S(2))), x) rule2550 = ReplacementRule(pattern2550, replacement2550) pattern2551 = Pattern(Integral(S(1)/(sqrt(WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))*sqrt(a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))), x_), cons2, cons3, cons27, cons48, cons125, cons1271, cons1352, cons1353) def replacement2551(f, b, d, a, x, e): rubi.append(2551) return Simp(S(2)*sqrt(-tan(e + f*x)**S(2))*sqrt(a**S(2))*EllipticF(asin(sqrt(a + b*cos(e + f*x))/(sqrt(d*cos(e + f*x))*Rt((a + b)/d, S(2)))), -(a + b)/(a - b))*Rt((a + b)/d, S(2))/(a*f*sqrt(a**S(2) - b**S(2))*tan(e + f*x)), x) rule2551 = ReplacementRule(pattern2551, replacement2551) pattern2552 = Pattern(Integral(S(1)/(sqrt(WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))*sqrt(a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))), x_), cons2, cons3, cons27, cons48, cons125, cons1267, cons1352) def replacement2552(f, b, d, a, x, e): rubi.append(2552) return Simp(-S(2)*sqrt(a*(S(1) - S(1)/sin(e + f*x))/(a + b))*sqrt(a*(S(1) + S(1)/sin(e + f*x))/(a - b))*EllipticF(asin(sqrt(a + b*sin(e + f*x))/(sqrt(d*sin(e + f*x))*Rt((a + b)/d, S(2)))), -(a + b)/(a - b))*Rt((a + b)/d, S(2))*tan(e + f*x)/(a*f), x) rule2552 = ReplacementRule(pattern2552, replacement2552) pattern2553 = Pattern(Integral(S(1)/(sqrt(WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))*sqrt(a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))), x_), cons2, cons3, cons27, cons48, cons125, cons1267, cons1352) def replacement2553(f, b, d, a, x, e): rubi.append(2553) return Simp(S(2)*sqrt(a*(S(1) - S(1)/cos(e + f*x))/(a + b))*sqrt(a*(S(1) + S(1)/cos(e + f*x))/(a - b))*EllipticF(asin(sqrt(a + b*cos(e + f*x))/(sqrt(d*cos(e + f*x))*Rt((a + b)/d, S(2)))), -(a + b)/(a - b))*Rt((a + b)/d, S(2))/(a*f*tan(e + f*x)), x) rule2553 = ReplacementRule(pattern2553, replacement2553) pattern2554 = Pattern(Integral(S(1)/(sqrt(WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))*sqrt(a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))), x_), cons2, cons3, cons27, cons48, cons125, cons1267, cons1354) def replacement2554(f, b, d, a, x, e): rubi.append(2554) return Dist(sqrt(-d*sin(e + f*x))/sqrt(d*sin(e + f*x)), Int(S(1)/(sqrt(-d*sin(e + f*x))*sqrt(a + b*sin(e + f*x))), x), x) rule2554 = ReplacementRule(pattern2554, replacement2554) pattern2555 = Pattern(Integral(S(1)/(sqrt(WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))*sqrt(a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))), x_), cons2, cons3, cons27, cons48, cons125, cons1267, cons1354) def replacement2555(f, b, d, a, x, e): rubi.append(2555) return Dist(sqrt(-d*cos(e + f*x))/sqrt(d*cos(e + f*x)), Int(S(1)/(sqrt(-d*cos(e + f*x))*sqrt(a + b*cos(e + f*x))), x), x) rule2555 = ReplacementRule(pattern2555, replacement2555) pattern2556 = Pattern(Integral(S(1)/(sqrt(a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))*sqrt(c_ + WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1267, cons1323, cons1355) def replacement2556(f, b, d, a, c, x, e): rubi.append(2556) return Simp(S(2)*sqrt((-a*d + b*c)*(-sin(e + f*x) + S(1))/((a + b)*(c + d*sin(e + f*x))))*sqrt(-(-a*d + b*c)*(sin(e + f*x) + S(1))/((a - b)*(c + d*sin(e + f*x))))*(c + d*sin(e + f*x))*EllipticF(asin(sqrt(a + b*sin(e + f*x))*Rt((c + d)/(a + b), S(2))/sqrt(c + d*sin(e + f*x))), (a + b)*(c - d)/((a - b)*(c + d)))/(f*(-a*d + b*c)*Rt((c + d)/(a + b), S(2))*cos(e + f*x)), x) rule2556 = ReplacementRule(pattern2556, replacement2556) pattern2557 = Pattern(Integral(S(1)/(sqrt(a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))*sqrt(c_ + WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1267, cons1323, cons1355) def replacement2557(f, b, d, a, c, x, e): rubi.append(2557) return Simp(-S(2)*sqrt((-a*d + b*c)*(-cos(e + f*x) + S(1))/((a + b)*(c + d*cos(e + f*x))))*sqrt(-(-a*d + b*c)*(cos(e + f*x) + S(1))/((a - b)*(c + d*cos(e + f*x))))*(c + d*cos(e + f*x))*EllipticF(asin(sqrt(a + b*cos(e + f*x))*Rt((c + d)/(a + b), S(2))/sqrt(c + d*cos(e + f*x))), (a + b)*(c - d)/((a - b)*(c + d)))/(f*(-a*d + b*c)*Rt((c + d)/(a + b), S(2))*sin(e + f*x)), x) rule2557 = ReplacementRule(pattern2557, replacement2557) pattern2558 = Pattern(Integral(S(1)/(sqrt(c_ + WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))*sqrt(WC('a', S(0)) + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1267, cons1323, cons1356) def replacement2558(f, b, d, a, c, x, e): rubi.append(2558) return Dist(sqrt(-a - b*sin(e + f*x))/sqrt(a + b*sin(e + f*x)), Int(S(1)/(sqrt(-a - b*sin(e + f*x))*sqrt(c + d*sin(e + f*x))), x), x) rule2558 = ReplacementRule(pattern2558, replacement2558) pattern2559 = Pattern(Integral(S(1)/(sqrt(c_ + WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))*sqrt(WC('a', S(0)) + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1267, cons1323, cons1356) def replacement2559(f, b, d, a, c, x, e): rubi.append(2559) return Dist(sqrt(-a - b*cos(e + f*x))/sqrt(a + b*cos(e + f*x)), Int(S(1)/(sqrt(-a - b*cos(e + f*x))*sqrt(c + d*cos(e + f*x))), x), x) rule2559 = ReplacementRule(pattern2559, replacement2559) pattern2560 = Pattern(Integral((WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**(S(3)/2)/sqrt(WC('a', S(0)) + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons27, cons48, cons125, cons1267) def replacement2560(f, b, d, a, x, e): rubi.append(2560) return Dist(d/(S(2)*b), Int(sqrt(d*sin(e + f*x))*(a + S(2)*b*sin(e + f*x))/sqrt(a + b*sin(e + f*x)), x), x) - Dist(a*d/(S(2)*b), Int(sqrt(d*sin(e + f*x))/sqrt(a + b*sin(e + f*x)), x), x) rule2560 = ReplacementRule(pattern2560, replacement2560) pattern2561 = Pattern(Integral((WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**(S(3)/2)/sqrt(WC('a', S(0)) + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons27, cons48, cons125, cons1267) def replacement2561(f, b, d, a, x, e): rubi.append(2561) return Dist(d/(S(2)*b), Int(sqrt(d*cos(e + f*x))*(a + S(2)*b*cos(e + f*x))/sqrt(a + b*cos(e + f*x)), x), x) - Dist(a*d/(S(2)*b), Int(sqrt(d*cos(e + f*x))/sqrt(a + b*cos(e + f*x)), x), x) rule2561 = ReplacementRule(pattern2561, replacement2561) pattern2562 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1267, cons1323, cons93, cons1357, cons1358, cons1359, cons1334) def replacement2562(m, f, b, d, c, a, n, x, e): rubi.append(2562) return Dist(S(1)/(d*(m + n)), Int((a + b*sin(e + f*x))**(m + S(-2))*(c + d*sin(e + f*x))**(n + S(-1))*Simp(a**S(2)*c*d*(m + n) + b*d*(a*d*n + b*c*(m + S(-1))) + b*d*(a*d*(S(2)*m + n + S(-1)) + b*c*n)*sin(e + f*x)**S(2) + (a*d*(m + n)*(a*d + S(2)*b*c) - b*d*(a*c - b*d*(m + n + S(-1))))*sin(e + f*x), x), x), x) - Simp(b*(a + b*sin(e + f*x))**(m + S(-1))*(c + d*sin(e + f*x))**n*cos(e + f*x)/(f*(m + n)), x) rule2562 = ReplacementRule(pattern2562, replacement2562) pattern2563 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1267, cons1323, cons93, cons1357, cons1358, cons1359, cons1334) def replacement2563(m, f, b, d, c, a, n, x, e): rubi.append(2563) return Dist(S(1)/(d*(m + n)), Int((a + b*cos(e + f*x))**(m + S(-2))*(c + d*cos(e + f*x))**(n + S(-1))*Simp(a**S(2)*c*d*(m + n) + b*d*(a*d*n + b*c*(m + S(-1))) + b*d*(a*d*(S(2)*m + n + S(-1)) + b*c*n)*cos(e + f*x)**S(2) + (a*d*(m + n)*(a*d + S(2)*b*c) - b*d*(a*c - b*d*(m + n + S(-1))))*cos(e + f*x), x), x), x) + Simp(b*(a + b*cos(e + f*x))**(m + S(-1))*(c + d*cos(e + f*x))**n*sin(e + f*x)/(f*(m + n)), x) rule2563 = ReplacementRule(pattern2563, replacement2563) pattern2564 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons4, cons71, cons62) def replacement2564(m, f, b, d, c, a, n, x, e): rubi.append(2564) return Dist(b/d, Int((a + b*sin(e + f*x))**(m + S(-1))*(c + d*sin(e + f*x))**(n + S(1)), x), x) - Dist((-a*d + b*c)/d, Int((a + b*sin(e + f*x))**(m + S(-1))*(c + d*sin(e + f*x))**n, x), x) rule2564 = ReplacementRule(pattern2564, replacement2564) pattern2565 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons4, cons71, cons62) def replacement2565(m, f, b, d, c, a, n, x, e): rubi.append(2565) return Dist(b/d, Int((a + b*cos(e + f*x))**(m + S(-1))*(c + d*cos(e + f*x))**(n + S(1)), x), x) - Dist((-a*d + b*c)/d, Int((a + b*cos(e + f*x))**(m + S(-1))*(c + d*cos(e + f*x))**n, x), x) rule2565 = ReplacementRule(pattern2565, replacement2565) pattern2566 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons4, cons71, cons1267, cons1323) def replacement2566(m, f, b, d, c, a, n, x, e): rubi.append(2566) return Int((a + b*sin(e + f*x))**m*(c + d*sin(e + f*x))**n, x) rule2566 = ReplacementRule(pattern2566, replacement2566) pattern2567 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons4, cons71, cons1267, cons1323) def replacement2567(m, f, b, d, c, a, n, x, e): rubi.append(2567) return Int((a + b*cos(e + f*x))**m*(c + d*cos(e + f*x))**n, x) rule2567 = ReplacementRule(pattern2567, replacement2567) pattern2568 = Pattern(Integral(((WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**p_*WC('c', S(1)))**n_*(WC('a', S(0)) + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons4, cons5, cons23) def replacement2568(p, m, f, b, d, c, a, n, x, e): rubi.append(2568) return Dist(c**IntPart(n)*(c*(d*sin(e + f*x))**p)**FracPart(n)*(d*sin(e + f*x))**(-p*FracPart(n)), Int((d*sin(e + f*x))**(n*p)*(a + b*sin(e + f*x))**m, x), x) rule2568 = ReplacementRule(pattern2568, replacement2568) pattern2569 = Pattern(Integral(((WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**p_*WC('c', S(1)))**n_*(WC('a', S(0)) + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons4, cons5, cons23) def replacement2569(p, m, f, b, d, a, c, n, x, e): rubi.append(2569) return Dist(c**IntPart(n)*(c*(d*cos(e + f*x))**p)**FracPart(n)*(d*cos(e + f*x))**(-p*FracPart(n)), Int((d*cos(e + f*x))**(n*p)*(a + b*cos(e + f*x))**m, x), x) rule2569 = ReplacementRule(pattern2569, replacement2569) pattern2570 = Pattern(Integral((a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(c_ + WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons85) def replacement2570(m, f, b, d, c, n, a, x, e): rubi.append(2570) return Int((a + b*sin(e + f*x))**m*(c*sin(e + f*x) + d)**n*sin(e + f*x)**(-n), x) rule2570 = ReplacementRule(pattern2570, replacement2570) pattern2571 = Pattern(Integral((a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(c_ + WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons85) def replacement2571(m, f, b, d, a, n, c, x, e): rubi.append(2571) return Int((a + b*cos(e + f*x))**m*(c*cos(e + f*x) + d)**n*cos(e + f*x)**(-n), x) rule2571 = ReplacementRule(pattern2571, replacement2571) pattern2572 = Pattern(Integral((a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(c_ + WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons4, cons23, cons17) def replacement2572(m, f, b, d, c, n, a, x, e): rubi.append(2572) return Int((c + d/sin(e + f*x))**n*(a/sin(e + f*x) + b)**m*(S(1)/sin(e + f*x))**(-m), x) rule2572 = ReplacementRule(pattern2572, replacement2572) pattern2573 = Pattern(Integral((a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(c_ + WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons4, cons23, cons17) def replacement2573(m, f, b, d, a, c, n, x, e): rubi.append(2573) return Int((c + d/cos(e + f*x))**n*(a/cos(e + f*x) + b)**m*(S(1)/cos(e + f*x))**(-m), x) rule2573 = ReplacementRule(pattern2573, replacement2573) pattern2574 = Pattern(Integral((a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(c_ + WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons4, cons23, cons18) def replacement2574(m, f, b, d, c, n, a, x, e): rubi.append(2574) return Dist((c + d/sin(e + f*x))**n*(c*sin(e + f*x) + d)**(-n)*sin(e + f*x)**n, Int((a + b*sin(e + f*x))**m*(c*sin(e + f*x) + d)**n*sin(e + f*x)**(-n), x), x) rule2574 = ReplacementRule(pattern2574, replacement2574) pattern2575 = Pattern(Integral((a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(c_ + WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons4, cons23, cons18) def replacement2575(m, f, b, d, a, c, n, x, e): rubi.append(2575) return Dist((c + d/cos(e + f*x))**n*(c*cos(e + f*x) + d)**(-n)*cos(e + f*x)**n, Int((a + b*cos(e + f*x))**m*(c*cos(e + f*x) + d)**n*cos(e + f*x)**(-n), x), x) rule2575 = ReplacementRule(pattern2575, replacement2575) pattern2576 = Pattern(Integral((a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(WC('c', S(0)) + WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons4, cons1360) def replacement2576(m, f, b, d, c, n, a, x, e): rubi.append(2576) return Dist(S(1)/(b*f), Subst(Int((a + x)**m*(c + d*x/b)**n, x), x, b*sin(e + f*x)), x) rule2576 = ReplacementRule(pattern2576, replacement2576) pattern2577 = Pattern(Integral((a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(WC('c', S(0)) + WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons4, cons1360) def replacement2577(m, f, b, d, c, n, a, x, e): rubi.append(2577) return -Dist(S(1)/(b*f), Subst(Int((a + x)**m*(c + d*x/b)**n, x), x, b*cos(e + f*x)), x) rule2577 = ReplacementRule(pattern2577, replacement2577) pattern2578 = Pattern(Integral((WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1))*(a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))*cos(x_*WC('f', S(1)) + WC('e', S(0)))**p_, x_), cons2, cons3, cons27, cons48, cons125, cons4, cons5, cons1274, cons85, cons1361) def replacement2578(p, f, b, d, a, n, x, e): rubi.append(2578) return Dist(a, Int((d*sin(e + f*x))**n*cos(e + f*x)**p, x), x) + Dist(b/d, Int((d*sin(e + f*x))**(n + S(1))*cos(e + f*x)**p, x), x) rule2578 = ReplacementRule(pattern2578, replacement2578) pattern2579 = Pattern(Integral((WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1))*(a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))*sin(x_*WC('f', S(1)) + WC('e', S(0)))**p_, x_), cons2, cons3, cons27, cons48, cons125, cons4, cons5, cons1274, cons85, cons1361) def replacement2579(p, f, b, d, a, n, x, e): rubi.append(2579) return Dist(a, Int((d*cos(e + f*x))**n*sin(e + f*x)**p, x), x) + Dist(b/d, Int((d*cos(e + f*x))**(n + S(1))*sin(e + f*x)**p, x), x) rule2579 = ReplacementRule(pattern2579, replacement2579) pattern2580 = Pattern(Integral((WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0)))**p_/(a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons27, cons48, cons125, cons4, cons5, cons1274, cons1265, cons85, cons1362) def replacement2580(p, f, b, d, a, n, x, e): rubi.append(2580) return Dist(S(1)/a, Int((d*sin(e + f*x))**n*cos(e + f*x)**(p + S(-2)), x), x) - Dist(S(1)/(b*d), Int((d*sin(e + f*x))**(n + S(1))*cos(e + f*x)**(p + S(-2)), x), x) rule2580 = ReplacementRule(pattern2580, replacement2580) pattern2581 = Pattern(Integral((WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0)))**p_/(a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons27, cons48, cons125, cons4, cons5, cons1274, cons1265, cons85, cons1362) def replacement2581(p, f, b, d, a, n, x, e): rubi.append(2581) return Dist(S(1)/a, Int((d*cos(e + f*x))**n*sin(e + f*x)**(p + S(-2)), x), x) - Dist(S(1)/(b*d), Int((d*cos(e + f*x))**(n + S(1))*sin(e + f*x)**(p + S(-2)), x), x) rule2581 = ReplacementRule(pattern2581, replacement2581) pattern2582 = Pattern(Integral((a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(WC('c', S(0)) + WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0)))**p_, x_), cons2, cons3, cons48, cons125, cons7, cons27, cons21, cons4, cons1274, cons1265) def replacement2582(p, m, f, b, d, c, n, a, x, e): rubi.append(2582) return Dist(b**(-p)/f, Subst(Int((a - x)**(p/S(2) + S(-1)/2)*(a + x)**(m + p/S(2) + S(-1)/2)*(c + d*x/b)**n, x), x, b*sin(e + f*x)), x) rule2582 = ReplacementRule(pattern2582, replacement2582) pattern2583 = Pattern(Integral((a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(WC('c', S(0)) + WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0)))**p_, x_), cons2, cons3, cons48, cons125, cons7, cons27, cons21, cons4, cons1274, cons1265) def replacement2583(p, m, f, b, d, c, n, a, x, e): rubi.append(2583) return -Dist(b**(-p)/f, Subst(Int((a - x)**(p/S(2) + S(-1)/2)*(a + x)**(m + p/S(2) + S(-1)/2)*(c + d*x/b)**n, x), x, b*cos(e + f*x)), x) rule2583 = ReplacementRule(pattern2583, replacement2583) pattern2584 = Pattern(Integral((a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(WC('c', S(0)) + WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0)))**p_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons4, cons1274, cons1267) def replacement2584(p, m, f, b, d, c, n, a, x, e): rubi.append(2584) return Dist(b**(-p)/f, Subst(Int((a + x)**m*(b**S(2) - x**S(2))**(p/S(2) + S(-1)/2)*(c + d*x/b)**n, x), x, b*sin(e + f*x)), x) rule2584 = ReplacementRule(pattern2584, replacement2584) pattern2585 = Pattern(Integral((a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(WC('c', S(0)) + WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0)))**p_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons4, cons1274, cons1267) def replacement2585(p, m, f, b, d, c, n, a, x, e): rubi.append(2585) return -Dist(b**(-p)/f, Subst(Int((a + x)**m*(b**S(2) - x**S(2))**(p/S(2) + S(-1)/2)*(c + d*x/b)**n, x), x, b*cos(e + f*x)), x) rule2585 = ReplacementRule(pattern2585, replacement2585) pattern2586 = Pattern(Integral((WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1))*(WC('g', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**p_*(a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons27, cons48, cons125, cons208, cons4, cons5, cons1363) def replacement2586(p, f, g, b, d, a, n, x, e): rubi.append(2586) return Dist(a, Int((d*sin(e + f*x))**n*(g*cos(e + f*x))**p, x), x) + Dist(b/d, Int((d*sin(e + f*x))**(n + S(1))*(g*cos(e + f*x))**p, x), x) rule2586 = ReplacementRule(pattern2586, replacement2586) pattern2587 = Pattern(Integral((WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1))*(WC('g', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**p_*(a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons27, cons48, cons125, cons208, cons4, cons5, cons1363) def replacement2587(p, f, b, g, d, a, n, x, e): rubi.append(2587) return Dist(a, Int((d*cos(e + f*x))**n*(g*sin(e + f*x))**p, x), x) + Dist(b/d, Int((d*cos(e + f*x))**(n + S(1))*(g*sin(e + f*x))**p, x), x) rule2587 = ReplacementRule(pattern2587, replacement2587) pattern2588 = Pattern(Integral((WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1))*(WC('g', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**p_/(a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons27, cons48, cons125, cons208, cons4, cons5, cons1265) def replacement2588(p, f, g, b, d, a, n, x, e): rubi.append(2588) return Dist(g**S(2)/a, Int((d*sin(e + f*x))**n*(g*cos(e + f*x))**(p + S(-2)), x), x) - Dist(g**S(2)/(b*d), Int((d*sin(e + f*x))**(n + S(1))*(g*cos(e + f*x))**(p + S(-2)), x), x) rule2588 = ReplacementRule(pattern2588, replacement2588) pattern2589 = Pattern(Integral((WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1))*(WC('g', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**p_/(a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons27, cons48, cons125, cons208, cons4, cons5, cons1265) def replacement2589(p, f, b, g, d, a, n, x, e): rubi.append(2589) return Dist(g**S(2)/a, Int((d*cos(e + f*x))**n*(g*sin(e + f*x))**(p + S(-2)), x), x) - Dist(g**S(2)/(b*d), Int((d*cos(e + f*x))**(n + S(1))*(g*sin(e + f*x))**(p + S(-2)), x), x) rule2589 = ReplacementRule(pattern2589, replacement2589) pattern2590 = Pattern(Integral((WC('g', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**p_*(a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(c_ + WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons4, cons5, cons70, cons1265, cons17, cons1364) def replacement2590(p, m, f, b, g, d, a, n, c, x, e): rubi.append(2590) return Dist(a**m*c**m*g**(-S(2)*m), Int((g*cos(e + f*x))**(S(2)*m + p)*(c + d*sin(e + f*x))**(-m + n), x), x) rule2590 = ReplacementRule(pattern2590, replacement2590) pattern2591 = Pattern(Integral((WC('g', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**p_*(a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(c_ + WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons4, cons5, cons70, cons1265, cons17, cons1364) def replacement2591(p, m, f, b, g, d, a, n, c, x, e): rubi.append(2591) return Dist(a**m*c**m*g**(-S(2)*m), Int((g*sin(e + f*x))**(S(2)*m + p)*(c + d*cos(e + f*x))**(-m + n), x), x) rule2591 = ReplacementRule(pattern2591, replacement2591) pattern2592 = Pattern(Integral((a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(c_ + WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0)))**p_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons4, cons5, cons70, cons1265, cons1306) def replacement2592(p, m, f, b, d, a, n, c, x, e): rubi.append(2592) return Dist(a**(-p/S(2))*c**(-p/S(2)), Int((a + b*sin(e + f*x))**(m + p/S(2))*(c + d*sin(e + f*x))**(n + p/S(2)), x), x) rule2592 = ReplacementRule(pattern2592, replacement2592) pattern2593 = Pattern(Integral((a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(c_ + WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0)))**p_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons4, cons5, cons70, cons1265, cons1306) def replacement2593(p, m, f, b, d, a, n, c, x, e): rubi.append(2593) return Dist(a**(-p/S(2))*c**(-p/S(2)), Int((a + b*cos(e + f*x))**(m + p/S(2))*(c + d*cos(e + f*x))**(n + p/S(2)), x), x) rule2593 = ReplacementRule(pattern2593, replacement2593) pattern2594 = Pattern(Integral((WC('g', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**p_/(sqrt(a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))*sqrt(c_ + WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons5, cons70, cons1265) def replacement2594(p, f, b, g, d, a, c, x, e): rubi.append(2594) return Dist(g*cos(e + f*x)/(sqrt(a + b*sin(e + f*x))*sqrt(c + d*sin(e + f*x))), Int((g*cos(e + f*x))**(p + S(-1)), x), x) rule2594 = ReplacementRule(pattern2594, replacement2594) pattern2595 = Pattern(Integral((WC('g', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**p_/(sqrt(a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))*sqrt(c_ + WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons5, cons70, cons1265) def replacement2595(p, f, b, g, d, a, c, x, e): rubi.append(2595) return Dist(g*sin(e + f*x)/(sqrt(a + b*cos(e + f*x))*sqrt(c + d*cos(e + f*x))), Int((g*sin(e + f*x))**(p + S(-1)), x), x) rule2595 = ReplacementRule(pattern2595, replacement2595) pattern2596 = Pattern(Integral((WC('g', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**p_*(a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(c_ + WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons21, cons4, cons5, cons70, cons1265, cons1282, cons142) def replacement2596(p, m, f, b, g, d, a, c, n, x, e): rubi.append(2596) return Dist(a**IntPart(m)*c**IntPart(m)*g**(-S(2)*IntPart(m))*(g*cos(e + f*x))**(-S(2)*FracPart(m))*(a + b*sin(e + f*x))**FracPart(m)*(c + d*sin(e + f*x))**FracPart(m), Int((g*cos(e + f*x))**(S(2)*m + p)/(c + d*sin(e + f*x)), x), x) rule2596 = ReplacementRule(pattern2596, replacement2596) pattern2597 = Pattern(Integral((WC('g', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**p_*(a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(c_ + WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons21, cons4, cons5, cons70, cons1265, cons1282, cons142) def replacement2597(p, m, f, b, g, d, a, c, n, x, e): rubi.append(2597) return Dist(a**IntPart(m)*c**IntPart(m)*g**(-S(2)*IntPart(m))*(g*sin(e + f*x))**(-S(2)*FracPart(m))*(a + b*cos(e + f*x))**FracPart(m)*(c + d*cos(e + f*x))**FracPart(m), Int((g*sin(e + f*x))**(S(2)*m + p)/(c + d*cos(e + f*x)), x), x) rule2597 = ReplacementRule(pattern2597, replacement2597) pattern2598 = Pattern(Integral((WC('g', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**p_*(a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(c_ + WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons21, cons4, cons5, cons70, cons1265, cons1282, cons335) def replacement2598(p, m, f, b, g, d, a, c, n, x, e): rubi.append(2598) return Simp(b*(g*cos(e + f*x))**(p + S(1))*(a + b*sin(e + f*x))**(m + S(-1))*(c + d*sin(e + f*x))**n/(f*g*(m - n + S(-1))), x) rule2598 = ReplacementRule(pattern2598, replacement2598) pattern2599 = Pattern(Integral((WC('g', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**p_*(a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(c_ + WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons21, cons4, cons5, cons70, cons1265, cons1282, cons335) def replacement2599(p, m, f, b, g, d, a, c, n, x, e): rubi.append(2599) return -Simp(b*(g*sin(e + f*x))**(p + S(1))*(a + b*cos(e + f*x))**(m + S(-1))*(c + d*cos(e + f*x))**n/(f*g*(m - n + S(-1))), x) rule2599 = ReplacementRule(pattern2599, replacement2599) pattern2600 = Pattern(Integral((WC('g', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**p_*(a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(c_ + WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons5, cons70, cons1265, cons1284, cons87, cons89, cons1365, cons1366) def replacement2600(p, m, f, b, g, d, a, c, n, x, e): rubi.append(2600) return -Dist(b*(S(2)*m + p + S(-1))/(d*(S(2)*n + p + S(1))), Int((g*cos(e + f*x))**p*(a + b*sin(e + f*x))**(m + S(-1))*(c + d*sin(e + f*x))**(n + S(1)), x), x) + Simp(-S(2)*b*(g*cos(e + f*x))**(p + S(1))*(a + b*sin(e + f*x))**(m + S(-1))*(c + d*sin(e + f*x))**n/(f*g*(S(2)*n + p + S(1))), x) rule2600 = ReplacementRule(pattern2600, replacement2600) pattern2601 = Pattern(Integral((WC('g', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**p_*(a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(c_ + WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons5, cons70, cons1265, cons1284, cons87, cons89, cons1365, cons1366) def replacement2601(p, m, f, b, g, d, a, c, n, x, e): rubi.append(2601) return -Dist(b*(S(2)*m + p + S(-1))/(d*(S(2)*n + p + S(1))), Int((g*sin(e + f*x))**p*(a + b*cos(e + f*x))**(m + S(-1))*(c + d*cos(e + f*x))**(n + S(1)), x), x) + Simp(S(2)*b*(g*sin(e + f*x))**(p + S(1))*(a + b*cos(e + f*x))**(m + S(-1))*(c + d*cos(e + f*x))**n/(f*g*(S(2)*n + p + S(1))), x) rule2601 = ReplacementRule(pattern2601, replacement2601) pattern2602 = Pattern(Integral((WC('g', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**p_*(a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(c_ + WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons4, cons5, cons70, cons1265, cons1284, cons346, cons1367, cons1366) def replacement2602(p, m, f, b, g, d, a, c, n, x, e): rubi.append(2602) return Dist(a*(S(2)*m + p + S(-1))/(m + n + p), Int((g*cos(e + f*x))**p*(a + b*sin(e + f*x))**(m + S(-1))*(c + d*sin(e + f*x))**n, x), x) - Simp(b*(g*cos(e + f*x))**(p + S(1))*(a + b*sin(e + f*x))**(m + S(-1))*(c + d*sin(e + f*x))**n/(f*g*(m + n + p)), x) rule2602 = ReplacementRule(pattern2602, replacement2602) pattern2603 = Pattern(Integral((WC('g', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**p_*(a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(c_ + WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons4, cons5, cons70, cons1265, cons1284, cons346, cons1367, cons1366) def replacement2603(p, m, f, b, g, d, a, c, n, x, e): rubi.append(2603) return Dist(a*(S(2)*m + p + S(-1))/(m + n + p), Int((g*sin(e + f*x))**p*(a + b*cos(e + f*x))**(m + S(-1))*(c + d*cos(e + f*x))**n, x), x) + Simp(b*(g*sin(e + f*x))**(p + S(1))*(a + b*cos(e + f*x))**(m + S(-1))*(c + d*cos(e + f*x))**n/(f*g*(m + n + p)), x) rule2603 = ReplacementRule(pattern2603, replacement2603) pattern2604 = Pattern(Integral((WC('g', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**p_*(a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(c_ + WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons21, cons5, cons70, cons1265, cons1368) def replacement2604(p, m, f, b, g, d, a, c, x, e): rubi.append(2604) return Dist(a**IntPart(m)*c**IntPart(m)*g**(-S(2)*IntPart(m))*(g*cos(e + f*x))**(-S(2)*FracPart(m))*(a + b*sin(e + f*x))**FracPart(m)*(c + d*sin(e + f*x))**FracPart(m), Int((g*cos(e + f*x))**(S(2)*m + p), x), x) rule2604 = ReplacementRule(pattern2604, replacement2604) pattern2605 = Pattern(Integral((WC('g', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**p_*(a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(c_ + WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons21, cons5, cons70, cons1265, cons1368) def replacement2605(p, m, f, b, g, d, a, c, x, e): rubi.append(2605) return Dist(a**IntPart(m)*c**IntPart(m)*g**(-S(2)*IntPart(m))*(g*sin(e + f*x))**(-S(2)*FracPart(m))*(a + b*cos(e + f*x))**FracPart(m)*(c + d*cos(e + f*x))**FracPart(m), Int((g*sin(e + f*x))**(S(2)*m + p), x), x) rule2605 = ReplacementRule(pattern2605, replacement2605) pattern2606 = Pattern(Integral((WC('g', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**p_*(a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(c_ + WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons21, cons4, cons5, cons70, cons1265, cons1369, cons1260) def replacement2606(p, m, f, b, g, d, a, c, n, x, e): rubi.append(2606) return Simp(b*(g*cos(e + f*x))**(p + S(1))*(a + b*sin(e + f*x))**m*(c + d*sin(e + f*x))**n/(a*f*g*(m - n)), x) rule2606 = ReplacementRule(pattern2606, replacement2606) pattern2607 = Pattern(Integral((WC('g', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**p_*(a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(c_ + WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons21, cons4, cons5, cons70, cons1265, cons1369, cons1260) def replacement2607(p, m, f, b, g, d, a, c, n, x, e): rubi.append(2607) return -Simp(b*(g*sin(e + f*x))**(p + S(1))*(a + b*cos(e + f*x))**m*(c + d*cos(e + f*x))**n/(a*f*g*(m - n)), x) rule2607 = ReplacementRule(pattern2607, replacement2607) pattern2608 = Pattern(Integral((WC('g', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**p_*(a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(c_ + WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons21, cons4, cons5, cons70, cons1265, cons1370, cons1281, cons114) def replacement2608(p, m, f, b, g, d, a, c, n, x, e): rubi.append(2608) return Dist((m + n + p + S(1))/(a*(S(2)*m + p + S(1))), Int((g*cos(e + f*x))**p*(a + b*sin(e + f*x))**(m + S(1))*(c + d*sin(e + f*x))**n, x), x) + Simp(b*(g*cos(e + f*x))**(p + S(1))*(a + b*sin(e + f*x))**m*(c + d*sin(e + f*x))**n/(a*f*g*(S(2)*m + p + S(1))), x) rule2608 = ReplacementRule(pattern2608, replacement2608) pattern2609 = Pattern(Integral((WC('g', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**p_*(a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(c_ + WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons21, cons4, cons5, cons70, cons1265, cons1370, cons1281, cons114) def replacement2609(p, m, f, b, g, d, a, c, n, x, e): rubi.append(2609) return Dist((m + n + p + S(1))/(a*(S(2)*m + p + S(1))), Int((g*sin(e + f*x))**p*(a + b*cos(e + f*x))**(m + S(1))*(c + d*cos(e + f*x))**n, x), x) - Simp(b*(g*sin(e + f*x))**(p + S(1))*(a + b*cos(e + f*x))**m*(c + d*cos(e + f*x))**n/(a*f*g*(S(2)*m + p + S(1))), x) rule2609 = ReplacementRule(pattern2609, replacement2609) pattern2610 = Pattern(Integral((WC('g', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**p_*(a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(c_ + WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons5, cons70, cons1265, cons93, cons168, cons89, cons1365, cons170) def replacement2610(p, m, f, b, g, d, a, c, n, x, e): rubi.append(2610) return -Dist(b*(S(2)*m + p + S(-1))/(d*(S(2)*n + p + S(1))), Int((g*cos(e + f*x))**p*(a + b*sin(e + f*x))**(m + S(-1))*(c + d*sin(e + f*x))**(n + S(1)), x), x) + Simp(-S(2)*b*(g*cos(e + f*x))**(p + S(1))*(a + b*sin(e + f*x))**(m + S(-1))*(c + d*sin(e + f*x))**n/(f*g*(S(2)*n + p + S(1))), x) rule2610 = ReplacementRule(pattern2610, replacement2610) pattern2611 = Pattern(Integral((WC('g', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**p_*(a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(c_ + WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons5, cons70, cons1265, cons93, cons168, cons89, cons1365, cons170) def replacement2611(p, m, f, b, g, d, a, c, n, x, e): rubi.append(2611) return -Dist(b*(S(2)*m + p + S(-1))/(d*(S(2)*n + p + S(1))), Int((g*sin(e + f*x))**p*(a + b*cos(e + f*x))**(m + S(-1))*(c + d*cos(e + f*x))**(n + S(1)), x), x) + Simp(S(2)*b*(g*sin(e + f*x))**(p + S(1))*(a + b*cos(e + f*x))**(m + S(-1))*(c + d*cos(e + f*x))**n/(f*g*(S(2)*n + p + S(1))), x) rule2611 = ReplacementRule(pattern2611, replacement2611) pattern2612 = Pattern(Integral((WC('g', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**p_*(a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(c_ + WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons4, cons5, cons70, cons1265, cons31, cons168, cons1371, cons1372, cons170) def replacement2612(p, m, f, b, g, d, a, c, n, x, e): rubi.append(2612) return Dist(a*(S(2)*m + p + S(-1))/(m + n + p), Int((g*cos(e + f*x))**p*(a + b*sin(e + f*x))**(m + S(-1))*(c + d*sin(e + f*x))**n, x), x) - Simp(b*(g*cos(e + f*x))**(p + S(1))*(a + b*sin(e + f*x))**(m + S(-1))*(c + d*sin(e + f*x))**n/(f*g*(m + n + p)), x) rule2612 = ReplacementRule(pattern2612, replacement2612) pattern2613 = Pattern(Integral((WC('g', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**p_*(a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(c_ + WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons4, cons5, cons70, cons1265, cons31, cons168, cons1371, cons1372, cons170) def replacement2613(p, m, f, b, g, d, a, c, n, x, e): rubi.append(2613) return Dist(a*(S(2)*m + p + S(-1))/(m + n + p), Int((g*sin(e + f*x))**p*(a + b*cos(e + f*x))**(m + S(-1))*(c + d*cos(e + f*x))**n, x), x) + Simp(b*(g*sin(e + f*x))**(p + S(1))*(a + b*cos(e + f*x))**(m + S(-1))*(c + d*cos(e + f*x))**n/(f*g*(m + n + p)), x) rule2613 = ReplacementRule(pattern2613, replacement2613) pattern2614 = Pattern(Integral((WC('g', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**p_*(a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(c_ + WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons4, cons5, cons70, cons1265, cons31, cons94, cons1281, cons1316, cons170) def replacement2614(p, m, f, b, g, d, a, c, n, x, e): rubi.append(2614) return Dist((m + n + p + S(1))/(a*(S(2)*m + p + S(1))), Int((g*cos(e + f*x))**p*(a + b*sin(e + f*x))**(m + S(1))*(c + d*sin(e + f*x))**n, x), x) + Simp(b*(g*cos(e + f*x))**(p + S(1))*(a + b*sin(e + f*x))**m*(c + d*sin(e + f*x))**n/(a*f*g*(S(2)*m + p + S(1))), x) rule2614 = ReplacementRule(pattern2614, replacement2614) pattern2615 = Pattern(Integral((WC('g', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**p_*(a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(c_ + WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons4, cons5, cons70, cons1265, cons31, cons94, cons1281, cons1316, cons170) def replacement2615(p, m, f, b, g, d, a, c, n, x, e): rubi.append(2615) return Dist((m + n + p + S(1))/(a*(S(2)*m + p + S(1))), Int((g*sin(e + f*x))**p*(a + b*cos(e + f*x))**(m + S(1))*(c + d*cos(e + f*x))**n, x), x) - Simp(b*(g*sin(e + f*x))**(p + S(1))*(a + b*cos(e + f*x))**m*(c + d*cos(e + f*x))**n/(a*f*g*(S(2)*m + p + S(1))), x) rule2615 = ReplacementRule(pattern2615, replacement2615) pattern2616 = Pattern(Integral((WC('g', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**p_*(a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(c_ + WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons21, cons4, cons5, cons70, cons1265, cons1317) def replacement2616(p, m, f, b, g, d, a, c, n, x, e): rubi.append(2616) return Dist(a**IntPart(m)*c**IntPart(m)*g**(-S(2)*IntPart(m))*(g*cos(e + f*x))**(-S(2)*FracPart(m))*(a + b*sin(e + f*x))**FracPart(m)*(c + d*sin(e + f*x))**FracPart(m), Int((g*cos(e + f*x))**(S(2)*m + p)*(c + d*sin(e + f*x))**(-m + n), x), x) rule2616 = ReplacementRule(pattern2616, replacement2616) pattern2617 = Pattern(Integral((WC('g', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**p_*(a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(c_ + WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons21, cons4, cons5, cons70, cons1265, cons1317) def replacement2617(p, m, f, b, g, d, a, c, n, x, e): rubi.append(2617) return Dist(a**IntPart(m)*c**IntPart(m)*g**(-S(2)*IntPart(m))*(g*sin(e + f*x))**(-S(2)*FracPart(m))*(a + b*cos(e + f*x))**FracPart(m)*(c + d*cos(e + f*x))**FracPart(m), Int((g*sin(e + f*x))**(S(2)*m + p)*(c + d*cos(e + f*x))**(-m + n), x), x) rule2617 = ReplacementRule(pattern2617, replacement2617) pattern2618 = Pattern(Integral((WC('g', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**p_*(a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(WC('c', S(0)) + WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons21, cons5, cons1265, cons1373) def replacement2618(p, m, f, b, g, d, c, a, x, e): rubi.append(2618) return -Simp(d*(g*cos(e + f*x))**(p + S(1))*(a + b*sin(e + f*x))**m/(f*g*(m + p + S(1))), x) rule2618 = ReplacementRule(pattern2618, replacement2618) pattern2619 = Pattern(Integral((WC('g', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**p_*(a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(WC('c', S(0)) + WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons21, cons5, cons1265, cons1373) def replacement2619(p, m, f, b, g, d, c, a, x, e): rubi.append(2619) return Simp(d*(g*sin(e + f*x))**(p + S(1))*(a + b*cos(e + f*x))**m/(f*g*(m + p + S(1))), x) rule2619 = ReplacementRule(pattern2619, replacement2619) pattern2620 = Pattern(Integral((WC('g', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**p_*(a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(WC('c', S(0)) + WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons1265, cons244, cons1374, cons137) def replacement2620(p, m, f, b, g, d, c, a, x, e): rubi.append(2620) return Dist(b*(a*d*m + b*c*(m + p + S(1)))/(a*g**S(2)*(p + S(1))), Int((g*cos(e + f*x))**(p + S(2))*(a + b*sin(e + f*x))**(m + S(-1)), x), x) - Simp((g*cos(e + f*x))**(p + S(1))*(a + b*sin(e + f*x))**m*(a*d + b*c)/(a*f*g*(p + S(1))), x) rule2620 = ReplacementRule(pattern2620, replacement2620) pattern2621 = Pattern(Integral((WC('g', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**p_*(a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(WC('c', S(0)) + WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons1265, cons244, cons1374, cons137) def replacement2621(p, m, f, b, g, d, c, a, x, e): rubi.append(2621) return Dist(b*(a*d*m + b*c*(m + p + S(1)))/(a*g**S(2)*(p + S(1))), Int((g*sin(e + f*x))**(p + S(2))*(a + b*cos(e + f*x))**(m + S(-1)), x), x) + Simp((g*sin(e + f*x))**(p + S(1))*(a + b*cos(e + f*x))**m*(a*d + b*c)/(a*f*g*(p + S(1))), x) rule2621 = ReplacementRule(pattern2621, replacement2621) pattern2622 = Pattern(Integral((WC('g', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**p_*(a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(WC('c', S(0)) + WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons21, cons5, cons1265, cons1375, cons253) def replacement2622(p, m, f, b, g, d, c, a, x, e): rubi.append(2622) return Dist((a*d*m + b*c*(m + p + S(1)))/(b*(m + p + S(1))), Int((g*cos(e + f*x))**p*(a + b*sin(e + f*x))**m, x), x) - Simp(d*(g*cos(e + f*x))**(p + S(1))*(a + b*sin(e + f*x))**m/(f*g*(m + p + S(1))), x) rule2622 = ReplacementRule(pattern2622, replacement2622) pattern2623 = Pattern(Integral((WC('g', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**p_*(a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(WC('c', S(0)) + WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons21, cons5, cons1265, cons1375, cons253) def replacement2623(p, m, f, b, g, d, c, a, x, e): rubi.append(2623) return Dist((a*d*m + b*c*(m + p + S(1)))/(b*(m + p + S(1))), Int((g*sin(e + f*x))**p*(a + b*cos(e + f*x))**m, x), x) + Simp(d*(g*sin(e + f*x))**(p + S(1))*(a + b*cos(e + f*x))**m/(f*g*(m + p + S(1))), x) rule2623 = ReplacementRule(pattern2623, replacement2623) pattern2624 = Pattern(Integral((a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))*cos(x_*WC('f', S(1)) + WC('e', S(0)))**S(2), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons1265, cons31, cons1376) def replacement2624(m, f, b, d, c, a, x, e): rubi.append(2624) return Dist(S(1)/(b**S(3)*(S(2)*m + S(3))), Int((a + b*sin(e + f*x))**(m + S(2))*(S(2)*a*d*(m + S(1)) + b*c - b*d*(S(2)*m + S(3))*sin(e + f*x)), x), x) + Simp(S(2)*(a + b*sin(e + f*x))**(m + S(1))*(-a*d + b*c)*cos(e + f*x)/(b**S(2)*f*(S(2)*m + S(3))), x) rule2624 = ReplacementRule(pattern2624, replacement2624) pattern2625 = Pattern(Integral((a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))*sin(x_*WC('f', S(1)) + WC('e', S(0)))**S(2), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons1265, cons31, cons1376) def replacement2625(m, f, b, d, c, a, x, e): rubi.append(2625) return Dist(S(1)/(b**S(3)*(S(2)*m + S(3))), Int((a + b*cos(e + f*x))**(m + S(2))*(S(2)*a*d*(m + S(1)) + b*c - b*d*(S(2)*m + S(3))*cos(e + f*x)), x), x) + Simp(-S(2)*(a + b*cos(e + f*x))**(m + S(1))*(-a*d + b*c)*sin(e + f*x)/(b**S(2)*f*(S(2)*m + S(3))), x) rule2625 = ReplacementRule(pattern2625, replacement2625) pattern2626 = Pattern(Integral((a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))*cos(x_*WC('f', S(1)) + WC('e', S(0)))**S(2), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons1265, cons31, cons1377) def replacement2626(m, f, b, d, c, a, x, e): rubi.append(2626) return -Dist(S(1)/(b**S(2)*(m + S(3))), Int((a + b*sin(e + f*x))**(m + S(1))*(-a*c*(m + S(3)) + b*d*(m + S(2)) + (-a*d*(m + S(4)) + b*c*(m + S(3)))*sin(e + f*x)), x), x) + Simp(d*(a + b*sin(e + f*x))**(m + S(2))*cos(e + f*x)/(b**S(2)*f*(m + S(3))), x) rule2626 = ReplacementRule(pattern2626, replacement2626) pattern2627 = Pattern(Integral((a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))*sin(x_*WC('f', S(1)) + WC('e', S(0)))**S(2), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons1265, cons31, cons1377) def replacement2627(m, f, b, d, c, a, x, e): rubi.append(2627) return -Dist(S(1)/(b**S(2)*(m + S(3))), Int((a + b*cos(e + f*x))**(m + S(1))*(-a*c*(m + S(3)) + b*d*(m + S(2)) + (-a*d*(m + S(4)) + b*c*(m + S(3)))*cos(e + f*x)), x), x) - Simp(d*(a + b*cos(e + f*x))**(m + S(2))*sin(e + f*x)/(b**S(2)*f*(m + S(3))), x) rule2627 = ReplacementRule(pattern2627, replacement2627) pattern2628 = Pattern(Integral((WC('g', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**p_*(a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons21, cons5, cons1265, cons1378, cons1281) def replacement2628(p, m, f, b, g, d, c, a, x, e): rubi.append(2628) return Dist((a*d*m + b*c*(m + p + S(1)))/(a*b*(S(2)*m + p + S(1))), Int((g*cos(e + f*x))**p*(a + b*sin(e + f*x))**(m + S(1)), x), x) + Simp((g*cos(e + f*x))**(p + S(1))*(a + b*sin(e + f*x))**m*(-a*d + b*c)/(a*f*g*(S(2)*m + p + S(1))), x) rule2628 = ReplacementRule(pattern2628, replacement2628) pattern2629 = Pattern(Integral((WC('g', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**p_*(a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons21, cons5, cons1265, cons1378, cons1281) def replacement2629(p, m, f, b, g, d, c, a, x, e): rubi.append(2629) return Dist((a*d*m + b*c*(m + p + S(1)))/(a*b*(S(2)*m + p + S(1))), Int((g*sin(e + f*x))**p*(a + b*cos(e + f*x))**(m + S(1)), x), x) - Simp((g*sin(e + f*x))**(p + S(1))*(a + b*cos(e + f*x))**m*(-a*d + b*c)/(a*f*g*(S(2)*m + p + S(1))), x) rule2629 = ReplacementRule(pattern2629, replacement2629) pattern2630 = Pattern(Integral((WC('g', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**p_*(a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(WC('c', S(0)) + WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons21, cons5, cons1265, cons253) def replacement2630(p, m, f, b, g, d, c, a, x, e): rubi.append(2630) return Dist((a*d*m + b*c*(m + p + S(1)))/(b*(m + p + S(1))), Int((g*cos(e + f*x))**p*(a + b*sin(e + f*x))**m, x), x) - Simp(d*(g*cos(e + f*x))**(p + S(1))*(a + b*sin(e + f*x))**m/(f*g*(m + p + S(1))), x) rule2630 = ReplacementRule(pattern2630, replacement2630) pattern2631 = Pattern(Integral((WC('g', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**p_*(a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(WC('c', S(0)) + WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons21, cons5, cons1265, cons253) def replacement2631(p, m, f, b, g, d, c, a, x, e): rubi.append(2631) return Dist((a*d*m + b*c*(m + p + S(1)))/(b*(m + p + S(1))), Int((g*sin(e + f*x))**p*(a + b*cos(e + f*x))**m, x), x) + Simp(d*(g*sin(e + f*x))**(p + S(1))*(a + b*cos(e + f*x))**m/(f*g*(m + p + S(1))), x) rule2631 = ReplacementRule(pattern2631, replacement2631) pattern2632 = Pattern(Integral((WC('g', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**p_*(a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(WC('c', S(0)) + WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons1267, cons244, cons168, cons137, cons515) def replacement2632(p, m, f, b, g, d, c, a, x, e): rubi.append(2632) return Dist(S(1)/(g**S(2)*(p + S(1))), Int((g*cos(e + f*x))**(p + S(2))*(a + b*sin(e + f*x))**(m + S(-1))*Simp(a*c*(p + S(2)) + b*c*(m + p + S(2))*sin(e + f*x) + b*d*m, x), x), x) - Simp((g*cos(e + f*x))**(p + S(1))*(a + b*sin(e + f*x))**m*(c*sin(e + f*x) + d)/(f*g*(p + S(1))), x) rule2632 = ReplacementRule(pattern2632, replacement2632) pattern2633 = Pattern(Integral((WC('g', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**p_*(a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(WC('c', S(0)) + WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons1267, cons244, cons168, cons137, cons515) def replacement2633(p, m, f, b, g, d, c, a, x, e): rubi.append(2633) return Dist(S(1)/(g**S(2)*(p + S(1))), Int((g*sin(e + f*x))**(p + S(2))*(a + b*cos(e + f*x))**(m + S(-1))*Simp(a*c*(p + S(2)) + b*c*(m + p + S(2))*cos(e + f*x) + b*d*m, x), x), x) + Simp((g*sin(e + f*x))**(p + S(1))*(a + b*cos(e + f*x))**m*(c*cos(e + f*x) + d)/(f*g*(p + S(1))), x) rule2633 = ReplacementRule(pattern2633, replacement2633) pattern2634 = Pattern(Integral((WC('g', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**p_*(a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(WC('c', S(0)) + WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons5, cons1267, cons31, cons168, cons1379, cons515) def replacement2634(p, m, f, b, g, d, c, a, x, e): rubi.append(2634) return Dist(S(1)/(m + p + S(1)), Int((g*cos(e + f*x))**p*(a + b*sin(e + f*x))**(m + S(-1))*Simp(a*c*(m + p + S(1)) + b*d*m + (a*d*m + b*c*(m + p + S(1)))*sin(e + f*x), x), x), x) - Simp(d*(g*cos(e + f*x))**(p + S(1))*(a + b*sin(e + f*x))**m/(f*g*(m + p + S(1))), x) rule2634 = ReplacementRule(pattern2634, replacement2634) pattern2635 = Pattern(Integral((WC('g', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**p_*(a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(WC('c', S(0)) + WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons5, cons1267, cons31, cons168, cons1379, cons515) def replacement2635(p, m, f, b, g, d, c, a, x, e): rubi.append(2635) return Dist(S(1)/(m + p + S(1)), Int((g*sin(e + f*x))**p*(a + b*cos(e + f*x))**(m + S(-1))*Simp(a*c*(m + p + S(1)) + b*d*m + (a*d*m + b*c*(m + p + S(1)))*cos(e + f*x), x), x), x) + Simp(d*(g*sin(e + f*x))**(p + S(1))*(a + b*cos(e + f*x))**m/(f*g*(m + p + S(1))), x) rule2635 = ReplacementRule(pattern2635, replacement2635) pattern2636 = Pattern(Integral((WC('g', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**p_*(a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons1267, cons244, cons94, cons146, cons253, cons515) def replacement2636(p, m, f, b, g, d, c, a, x, e): rubi.append(2636) return Dist(g**S(2)*(p + S(-1))/(b**S(2)*(m + S(1))*(m + p + S(1))), Int((g*cos(e + f*x))**(p + S(-2))*(a + b*sin(e + f*x))**(m + S(1))*Simp(b*d*(m + S(1)) + (-a*d*p + b*c*(m + p + S(1)))*sin(e + f*x), x), x), x) + Simp(g*(g*cos(e + f*x))**(p + S(-1))*(a + b*sin(e + f*x))**(m + S(1))*(-a*d*p + b*c*(m + p + S(1)) + b*d*(m + S(1))*sin(e + f*x))/(b**S(2)*f*(m + S(1))*(m + p + S(1))), x) rule2636 = ReplacementRule(pattern2636, replacement2636) pattern2637 = Pattern(Integral((WC('g', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**p_*(a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons1267, cons244, cons94, cons146, cons253, cons515) def replacement2637(p, m, f, b, g, d, c, a, x, e): rubi.append(2637) return Dist(g**S(2)*(p + S(-1))/(b**S(2)*(m + S(1))*(m + p + S(1))), Int((g*sin(e + f*x))**(p + S(-2))*(a + b*cos(e + f*x))**(m + S(1))*Simp(b*d*(m + S(1)) + (-a*d*p + b*c*(m + p + S(1)))*cos(e + f*x), x), x), x) - Simp(g*(g*sin(e + f*x))**(p + S(-1))*(a + b*cos(e + f*x))**(m + S(1))*(-a*d*p + b*c*(m + p + S(1)) + b*d*(m + S(1))*cos(e + f*x))/(b**S(2)*f*(m + S(1))*(m + p + S(1))), x) rule2637 = ReplacementRule(pattern2637, replacement2637) pattern2638 = Pattern(Integral((WC('g', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**p_*(a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons5, cons1267, cons31, cons94, cons515) def replacement2638(p, m, f, b, g, d, c, a, x, e): rubi.append(2638) return Dist(S(1)/((a**S(2) - b**S(2))*(m + S(1))), Int((g*cos(e + f*x))**p*(a + b*sin(e + f*x))**(m + S(1))*Simp((m + S(1))*(a*c - b*d) - (-a*d + b*c)*(m + p + S(2))*sin(e + f*x), x), x), x) - Simp((g*cos(e + f*x))**(p + S(1))*(a + b*sin(e + f*x))**(m + S(1))*(-a*d + b*c)/(f*g*(a**S(2) - b**S(2))*(m + S(1))), x) rule2638 = ReplacementRule(pattern2638, replacement2638) pattern2639 = Pattern(Integral((WC('g', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**p_*(a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons5, cons1267, cons31, cons94, cons515) def replacement2639(p, m, f, b, g, d, c, a, x, e): rubi.append(2639) return Dist(S(1)/((a**S(2) - b**S(2))*(m + S(1))), Int((g*sin(e + f*x))**p*(a + b*cos(e + f*x))**(m + S(1))*Simp((m + S(1))*(a*c - b*d) - (-a*d + b*c)*(m + p + S(2))*cos(e + f*x), x), x), x) + Simp((g*sin(e + f*x))**(p + S(1))*(a + b*cos(e + f*x))**(m + S(1))*(-a*d + b*c)/(f*g*(a**S(2) - b**S(2))*(m + S(1))), x) rule2639 = ReplacementRule(pattern2639, replacement2639) pattern2640 = Pattern(Integral((WC('g', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**p_*(a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(WC('c', S(0)) + WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons21, cons1267, cons13, cons146, cons1285, cons253, cons515) def replacement2640(p, m, f, b, g, d, c, a, x, e): rubi.append(2640) return Dist(g**S(2)*(p + S(-1))/(b**S(2)*(m + p)*(m + p + S(1))), Int((g*cos(e + f*x))**(p + S(-2))*(a + b*sin(e + f*x))**m*Simp(b*(a*d*m + b*c*(m + p + S(1))) + (a*b*c*(m + p + S(1)) - d*(a**S(2)*p - b**S(2)*(m + p)))*sin(e + f*x), x), x), x) + Simp(g*(g*cos(e + f*x))**(p + S(-1))*(a + b*sin(e + f*x))**(m + S(1))*(-a*d*p + b*c*(m + p + S(1)) + b*d*(m + p)*sin(e + f*x))/(b**S(2)*f*(m + p)*(m + p + S(1))), x) rule2640 = ReplacementRule(pattern2640, replacement2640) pattern2641 = Pattern(Integral((WC('g', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**p_*(a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(WC('c', S(0)) + WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons21, cons1267, cons13, cons146, cons1285, cons253, cons515) def replacement2641(p, m, f, b, g, d, c, a, x, e): rubi.append(2641) return Dist(g**S(2)*(p + S(-1))/(b**S(2)*(m + p)*(m + p + S(1))), Int((g*sin(e + f*x))**(p + S(-2))*(a + b*cos(e + f*x))**m*Simp(b*(a*d*m + b*c*(m + p + S(1))) + (a*b*c*(m + p + S(1)) - d*(a**S(2)*p - b**S(2)*(m + p)))*cos(e + f*x), x), x), x) - Simp(g*(g*sin(e + f*x))**(p + S(-1))*(a + b*cos(e + f*x))**(m + S(1))*(-a*d*p + b*c*(m + p + S(1)) + b*d*(m + p)*cos(e + f*x))/(b**S(2)*f*(m + p)*(m + p + S(1))), x) rule2641 = ReplacementRule(pattern2641, replacement2641) pattern2642 = Pattern(Integral((WC('g', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**p_*(a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(WC('c', S(0)) + WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons21, cons1267, cons13, cons137, cons515) def replacement2642(p, m, f, b, g, d, c, a, x, e): rubi.append(2642) return Dist(S(1)/(g**S(2)*(a**S(2) - b**S(2))*(p + S(1))), Int((g*cos(e + f*x))**(p + S(2))*(a + b*sin(e + f*x))**m*Simp(a*b*d*m + b*(a*c - b*d)*(m + p + S(3))*sin(e + f*x) + c*(a**S(2)*(p + S(2)) - b**S(2)*(m + p + S(2))), x), x), x) + Simp((g*cos(e + f*x))**(p + S(1))*(a + b*sin(e + f*x))**(m + S(1))*(-a*d + b*c - (a*c - b*d)*sin(e + f*x))/(f*g*(a**S(2) - b**S(2))*(p + S(1))), x) rule2642 = ReplacementRule(pattern2642, replacement2642) pattern2643 = Pattern(Integral((WC('g', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**p_*(a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(WC('c', S(0)) + WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons21, cons1267, cons13, cons137, cons515) def replacement2643(p, m, f, b, g, d, c, a, x, e): rubi.append(2643) return Dist(S(1)/(g**S(2)*(a**S(2) - b**S(2))*(p + S(1))), Int((g*sin(e + f*x))**(p + S(2))*(a + b*cos(e + f*x))**m*Simp(a*b*d*m + b*(a*c - b*d)*(m + p + S(3))*cos(e + f*x) + c*(a**S(2)*(p + S(2)) - b**S(2)*(m + p + S(2))), x), x), x) - Simp((g*sin(e + f*x))**(p + S(1))*(a + b*cos(e + f*x))**(m + S(1))*(-a*d + b*c - (a*c - b*d)*cos(e + f*x))/(f*g*(a**S(2) - b**S(2))*(p + S(1))), x) rule2643 = ReplacementRule(pattern2643, replacement2643) pattern2644 = Pattern(Integral((WC('g', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**p_*(WC('c', S(0)) + WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))/(a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons1267) def replacement2644(p, f, b, g, d, c, a, x, e): rubi.append(2644) return Dist(d/b, Int((g*cos(e + f*x))**p, x), x) + Dist((-a*d + b*c)/b, Int((g*cos(e + f*x))**p/(a + b*sin(e + f*x)), x), x) rule2644 = ReplacementRule(pattern2644, replacement2644) pattern2645 = Pattern(Integral((WC('g', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**p_*(WC('c', S(0)) + WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))/(a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons1267) def replacement2645(p, f, b, g, d, c, a, x, e): rubi.append(2645) return Dist(d/b, Int((g*sin(e + f*x))**p, x), x) + Dist((-a*d + b*c)/b, Int((g*sin(e + f*x))**p/(a + b*cos(e + f*x)), x), x) rule2645 = ReplacementRule(pattern2645, replacement2645) pattern2646 = Pattern(Integral((WC('g', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**p_*(a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(c_ + WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons5, cons1267, cons1322) def replacement2646(p, m, f, b, g, d, a, c, x, e): rubi.append(2646) return Dist(c*g*(g*cos(e + f*x))**(p + S(-1))*(-sin(e + f*x) + S(1))**(-p/S(2) + S(1)/2)*(sin(e + f*x) + S(1))**(-p/S(2) + S(1)/2)/f, Subst(Int((S(1) - d*x/c)**(p/S(2) + S(-1)/2)*(S(1) + d*x/c)**(p/S(2) + S(1)/2)*(a + b*x)**m, x), x, sin(e + f*x)), x) rule2646 = ReplacementRule(pattern2646, replacement2646) pattern2647 = Pattern(Integral((WC('g', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**p_*(a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(c_ + WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons5, cons1267, cons1322) def replacement2647(p, m, f, b, g, d, a, c, x, e): rubi.append(2647) return -Dist(c*g*(g*sin(e + f*x))**(p + S(-1))*(-cos(e + f*x) + S(1))**(-p/S(2) + S(1)/2)*(cos(e + f*x) + S(1))**(-p/S(2) + S(1)/2)/f, Subst(Int((S(1) - d*x/c)**(p/S(2) + S(-1)/2)*(S(1) + d*x/c)**(p/S(2) + S(1)/2)*(a + b*x)**m, x), x, cos(e + f*x)), x) rule2647 = ReplacementRule(pattern2647, replacement2647) pattern2648 = Pattern(Integral((WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*cos(x_*WC('f', S(1)) + WC('e', S(0)))**p_, x_), cons2, cons3, cons27, cons48, cons125, cons4, cons1265, cons1299, cons1380) def replacement2648(p, m, f, b, d, a, n, x, e): rubi.append(2648) return Dist(a**(S(2)*m), Int((d*sin(e + f*x))**n*(a - b*sin(e + f*x))**(-m), x), x) rule2648 = ReplacementRule(pattern2648, replacement2648) pattern2649 = Pattern(Integral((WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*sin(x_*WC('f', S(1)) + WC('e', S(0)))**p_, x_), cons2, cons3, cons27, cons48, cons125, cons4, cons1265, cons1299, cons1380) def replacement2649(p, m, f, b, d, a, n, x, e): rubi.append(2649) return Dist(a**(S(2)*m), Int((d*cos(e + f*x))**n*(a - b*cos(e + f*x))**(-m), x), x) rule2649 = ReplacementRule(pattern2649, replacement2649) pattern2650 = Pattern(Integral((WC('g', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**p_*(a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*sin(x_*WC('f', S(1)) + WC('e', S(0)))**S(2), x_), cons2, cons3, cons48, cons125, cons208, cons21, cons5, cons1265, cons358) def replacement2650(p, m, f, b, g, a, x, e): rubi.append(2650) return Dist(a/(S(2)*g**S(2)), Int((g*cos(e + f*x))**(p + S(2))*(a + b*sin(e + f*x))**(m + S(-1)), x), x) - Simp((g*cos(e + f*x))**(p + S(1))*(a + b*sin(e + f*x))**(m + S(1))/(S(2)*b*f*g*(m + S(1))), x) rule2650 = ReplacementRule(pattern2650, replacement2650) pattern2651 = Pattern(Integral((WC('g', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**p_*(a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*cos(x_*WC('f', S(1)) + WC('e', S(0)))**S(2), x_), cons2, cons3, cons48, cons125, cons208, cons21, cons5, cons1265, cons358) def replacement2651(p, m, f, b, g, a, x, e): rubi.append(2651) return Dist(a/(S(2)*g**S(2)), Int((g*sin(e + f*x))**(p + S(2))*(a + b*cos(e + f*x))**(m + S(-1)), x), x) + Simp((g*sin(e + f*x))**(p + S(1))*(a + b*cos(e + f*x))**(m + S(1))/(S(2)*b*f*g*(m + S(1))), x) rule2651 = ReplacementRule(pattern2651, replacement2651) pattern2652 = Pattern(Integral((WC('g', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**p_*(a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*sin(x_*WC('f', S(1)) + WC('e', S(0)))**S(2), x_), cons2, cons3, cons48, cons125, cons208, cons21, cons5, cons1265, cons1278) def replacement2652(p, m, f, b, g, a, x, e): rubi.append(2652) return -Dist(g**(S(-2)), Int((g*cos(e + f*x))**(p + S(2))*(a + b*sin(e + f*x))**m, x), x) + Simp(b*(g*cos(e + f*x))**(p + S(1))*(a + b*sin(e + f*x))**m/(a*f*g*m), x) rule2652 = ReplacementRule(pattern2652, replacement2652) pattern2653 = Pattern(Integral((WC('g', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**p_*(a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*cos(x_*WC('f', S(1)) + WC('e', S(0)))**S(2), x_), cons2, cons3, cons48, cons125, cons208, cons21, cons5, cons1265, cons1278) def replacement2653(p, m, f, b, g, a, x, e): rubi.append(2653) return -Dist(g**(S(-2)), Int((g*sin(e + f*x))**(p + S(2))*(a + b*cos(e + f*x))**m, x), x) - Simp(b*(g*sin(e + f*x))**(p + S(1))*(a + b*cos(e + f*x))**m/(a*f*g*m), x) rule2653 = ReplacementRule(pattern2653, replacement2653) pattern2654 = Pattern(Integral((WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*cos(x_*WC('f', S(1)) + WC('e', S(0)))**p_, x_), cons2, cons3, cons27, cons48, cons125, cons1265, cons1381, cons1382) def replacement2654(p, m, f, b, d, a, n, x, e): rubi.append(2654) return Dist(a**(-p), Int(ExpandTrig((d*sin(e + f*x))**n*(a - b*sin(e + f*x))**(p/S(2))*(a + b*sin(e + f*x))**(m + p/S(2)), x), x), x) rule2654 = ReplacementRule(pattern2654, replacement2654) pattern2655 = Pattern(Integral((WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*sin(x_*WC('f', S(1)) + WC('e', S(0)))**p_, x_), cons2, cons3, cons27, cons48, cons125, cons1265, cons1381, cons1382) def replacement2655(p, m, f, b, d, a, n, x, e): rubi.append(2655) return Dist(a**(-p), Int(ExpandTrig((d*cos(e + f*x))**n*(a - b*cos(e + f*x))**(p/S(2))*(a + b*cos(e + f*x))**(m + p/S(2)), x), x), x) rule2655 = ReplacementRule(pattern2655, replacement2655) pattern2656 = Pattern(Integral((WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(WC('g', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**p_*(a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_, x_), cons2, cons3, cons27, cons48, cons125, cons208, cons4, cons5, cons1265, cons62) def replacement2656(p, m, f, b, g, d, a, n, x, e): rubi.append(2656) return Int(ExpandTrig((g*cos(e + f*x))**p, (d*sin(e + f*x))**n*(a + b*sin(e + f*x))**m, x), x) rule2656 = ReplacementRule(pattern2656, replacement2656) pattern2657 = Pattern(Integral((WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(WC('g', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**p_*(a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_, x_), cons2, cons3, cons27, cons48, cons125, cons208, cons4, cons5, cons1265, cons62) def replacement2657(p, m, f, b, g, d, a, n, x, e): rubi.append(2657) return Int(ExpandTrig((g*sin(e + f*x))**p, (d*cos(e + f*x))**n*(a + b*cos(e + f*x))**m, x), x) rule2657 = ReplacementRule(pattern2657, replacement2657) pattern2658 = Pattern(Integral((WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*cos(x_*WC('f', S(1)) + WC('e', S(0)))**S(2), x_), cons2, cons3, cons27, cons48, cons125, cons21, cons4, cons1265, cons1383) def replacement2658(m, f, b, d, a, n, x, e): rubi.append(2658) return Dist(b**(S(-2)), Int((d*sin(e + f*x))**n*(a - b*sin(e + f*x))*(a + b*sin(e + f*x))**(m + S(1)), x), x) rule2658 = ReplacementRule(pattern2658, replacement2658) pattern2659 = Pattern(Integral((WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*sin(x_*WC('f', S(1)) + WC('e', S(0)))**S(2), x_), cons2, cons3, cons27, cons48, cons125, cons21, cons4, cons1265, cons1383) def replacement2659(m, f, b, d, a, n, x, e): rubi.append(2659) return Dist(b**(S(-2)), Int((d*cos(e + f*x))**n*(a - b*cos(e + f*x))*(a + b*cos(e + f*x))**(m + S(1)), x), x) rule2659 = ReplacementRule(pattern2659, replacement2659) pattern2660 = Pattern(Integral((WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(WC('g', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**p_*(a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_, x_), cons2, cons3, cons27, cons48, cons125, cons208, cons4, cons5, cons1265, cons84) def replacement2660(p, m, f, b, g, d, a, n, x, e): rubi.append(2660) return Dist((a/g)**(S(2)*m), Int((d*sin(e + f*x))**n*(g*cos(e + f*x))**(S(2)*m + p)*(a - b*sin(e + f*x))**(-m), x), x) rule2660 = ReplacementRule(pattern2660, replacement2660) pattern2661 = Pattern(Integral((WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(WC('g', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**p_*(a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_, x_), cons2, cons3, cons27, cons48, cons125, cons208, cons4, cons5, cons1265, cons84) def replacement2661(p, m, f, b, g, d, a, n, x, e): rubi.append(2661) return Dist((a/g)**(S(2)*m), Int((d*cos(e + f*x))**n*(g*sin(e + f*x))**(S(2)*m + p)*(a - b*cos(e + f*x))**(-m), x), x) rule2661 = ReplacementRule(pattern2661, replacement2661) pattern2662 = Pattern(Integral((WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(WC('g', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**p_*(a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_, x_), cons2, cons3, cons27, cons48, cons125, cons208, cons4, cons1265, cons17, cons13, cons1384) def replacement2662(p, m, f, b, g, d, a, n, x, e): rubi.append(2662) return Dist((a/g)**(S(2)*m), Int((d*sin(e + f*x))**n*(g*cos(e + f*x))**(S(2)*m + p)*(a - b*sin(e + f*x))**(-m), x), x) rule2662 = ReplacementRule(pattern2662, replacement2662) pattern2663 = Pattern(Integral((WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(WC('g', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**p_*(a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_, x_), cons2, cons3, cons27, cons48, cons125, cons208, cons4, cons1265, cons17, cons13, cons1384) def replacement2663(p, m, f, b, g, d, a, n, x, e): rubi.append(2663) return Dist((a/g)**(S(2)*m), Int((d*cos(e + f*x))**n*(g*sin(e + f*x))**(S(2)*m + p)*(a - b*cos(e + f*x))**(-m), x), x) rule2663 = ReplacementRule(pattern2663, replacement2663) pattern2664 = Pattern(Integral((WC('g', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**p_*(a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*sin(x_*WC('f', S(1)) + WC('e', S(0)))**S(2), x_), cons2, cons3, cons48, cons125, cons208, cons5, cons1265, cons31, cons1385, cons1281) def replacement2664(p, m, f, b, g, a, x, e): rubi.append(2664) return -Dist(S(1)/(a**S(2)*(S(2)*m + p + S(1))), Int((g*cos(e + f*x))**p*(a + b*sin(e + f*x))**(m + S(1))*(a*m - b*(S(2)*m + p + S(1))*sin(e + f*x)), x), x) + Simp(b*(g*cos(e + f*x))**(p + S(1))*(a + b*sin(e + f*x))**m/(a*f*g*(S(2)*m + p + S(1))), x) rule2664 = ReplacementRule(pattern2664, replacement2664) pattern2665 = Pattern(Integral((WC('g', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**p_*(a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*cos(x_*WC('f', S(1)) + WC('e', S(0)))**S(2), x_), cons2, cons3, cons48, cons125, cons208, cons5, cons1265, cons31, cons1385, cons1281) def replacement2665(p, m, f, b, g, a, x, e): rubi.append(2665) return -Dist(S(1)/(a**S(2)*(S(2)*m + p + S(1))), Int((g*sin(e + f*x))**p*(a + b*cos(e + f*x))**(m + S(1))*(a*m - b*(S(2)*m + p + S(1))*cos(e + f*x)), x), x) - Simp(b*(g*sin(e + f*x))**(p + S(1))*(a + b*cos(e + f*x))**m/(a*f*g*(S(2)*m + p + S(1))), x) rule2665 = ReplacementRule(pattern2665, replacement2665) pattern2666 = Pattern(Integral((WC('g', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**p_*(a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*sin(x_*WC('f', S(1)) + WC('e', S(0)))**S(2), x_), cons2, cons3, cons48, cons125, cons208, cons21, cons5, cons1265, cons1386) def replacement2666(p, m, f, b, g, a, x, e): rubi.append(2666) return Dist(S(1)/(b*(m + p + S(2))), Int((g*cos(e + f*x))**p*(a + b*sin(e + f*x))**m*(-a*(p + S(1))*sin(e + f*x) + b*(m + S(1))), x), x) - Simp((g*cos(e + f*x))**(p + S(1))*(a + b*sin(e + f*x))**(m + S(1))/(b*f*g*(m + p + S(2))), x) rule2666 = ReplacementRule(pattern2666, replacement2666) pattern2667 = Pattern(Integral((WC('g', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**p_*(a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*cos(x_*WC('f', S(1)) + WC('e', S(0)))**S(2), x_), cons2, cons3, cons48, cons125, cons208, cons21, cons5, cons1265, cons1386) def replacement2667(p, m, f, b, g, a, x, e): rubi.append(2667) return Dist(S(1)/(b*(m + p + S(2))), Int((g*sin(e + f*x))**p*(a + b*cos(e + f*x))**m*(-a*(p + S(1))*cos(e + f*x) + b*(m + S(1))), x), x) + Simp((g*sin(e + f*x))**(p + S(1))*(a + b*cos(e + f*x))**(m + S(1))/(b*f*g*(m + p + S(2))), x) rule2667 = ReplacementRule(pattern2667, replacement2667) pattern2668 = Pattern(Integral((WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*cos(x_*WC('f', S(1)) + WC('e', S(0)))**S(2), x_), cons2, cons3, cons27, cons48, cons125, cons21, cons4, cons1265, cons1170) def replacement2668(m, f, b, d, a, n, x, e): rubi.append(2668) return Dist(b**(S(-2)), Int((d*sin(e + f*x))**n*(a - b*sin(e + f*x))*(a + b*sin(e + f*x))**(m + S(1)), x), x) rule2668 = ReplacementRule(pattern2668, replacement2668) pattern2669 = Pattern(Integral((WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*sin(x_*WC('f', S(1)) + WC('e', S(0)))**S(2), x_), cons2, cons3, cons27, cons48, cons125, cons21, cons4, cons1265, cons1170) def replacement2669(m, f, b, d, a, n, x, e): rubi.append(2669) return Dist(b**(S(-2)), Int((d*cos(e + f*x))**n*(a - b*cos(e + f*x))*(a + b*cos(e + f*x))**(m + S(1)), x), x) rule2669 = ReplacementRule(pattern2669, replacement2669) pattern2670 = Pattern(Integral((WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*cos(x_*WC('f', S(1)) + WC('e', S(0)))**S(4), x_), cons2, cons3, cons27, cons48, cons125, cons4, cons1265, cons31, cons94) def replacement2670(m, f, b, d, a, n, x, e): rubi.append(2670) return Dist(a**(S(-2)), Int((d*sin(e + f*x))**n*(a + b*sin(e + f*x))**(m + S(2))*(sin(e + f*x)**S(2) + S(1)), x), x) + Dist(-S(2)/(a*b*d), Int((d*sin(e + f*x))**(n + S(1))*(a + b*sin(e + f*x))**(m + S(2)), x), x) rule2670 = ReplacementRule(pattern2670, replacement2670) pattern2671 = Pattern(Integral((WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*sin(x_*WC('f', S(1)) + WC('e', S(0)))**S(4), x_), cons2, cons3, cons27, cons48, cons125, cons4, cons1265, cons31, cons94) def replacement2671(m, f, b, d, a, n, x, e): rubi.append(2671) return Dist(a**(S(-2)), Int((d*cos(e + f*x))**n*(a + b*cos(e + f*x))**(m + S(2))*(cos(e + f*x)**S(2) + S(1)), x), x) + Dist(-S(2)/(a*b*d), Int((d*cos(e + f*x))**(n + S(1))*(a + b*cos(e + f*x))**(m + S(2)), x), x) rule2671 = ReplacementRule(pattern2671, replacement2671) pattern2672 = Pattern(Integral((WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*cos(x_*WC('f', S(1)) + WC('e', S(0)))**S(4), x_), cons2, cons3, cons27, cons48, cons125, cons21, cons4, cons1265, cons143) def replacement2672(m, f, b, d, a, n, x, e): rubi.append(2672) return Dist(d**(S(-4)), Int((d*sin(e + f*x))**(n + S(4))*(a + b*sin(e + f*x))**m, x), x) + Int((d*sin(e + f*x))**n*(a + b*sin(e + f*x))**m*(-S(2)*sin(e + f*x)**S(2) + S(1)), x) rule2672 = ReplacementRule(pattern2672, replacement2672) pattern2673 = Pattern(Integral((WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*sin(x_*WC('f', S(1)) + WC('e', S(0)))**S(4), x_), cons2, cons3, cons27, cons48, cons125, cons21, cons4, cons1265, cons143) def replacement2673(m, f, b, d, a, n, x, e): rubi.append(2673) return Dist(d**(S(-4)), Int((d*cos(e + f*x))**(n + S(4))*(a + b*cos(e + f*x))**m, x), x) + Int((d*cos(e + f*x))**n*(a + b*cos(e + f*x))**m*(-S(2)*cos(e + f*x)**S(2) + S(1)), x) rule2673 = ReplacementRule(pattern2673, replacement2673) pattern2674 = Pattern(Integral((WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*cos(x_*WC('f', S(1)) + WC('e', S(0)))**p_, x_), cons2, cons3, cons27, cons48, cons125, cons4, cons1265, cons1306, cons17) def replacement2674(p, m, f, b, d, a, n, x, e): rubi.append(2674) return Dist(a**m*cos(e + f*x)/(f*sqrt(-sin(e + f*x) + S(1))*sqrt(sin(e + f*x) + S(1))), Subst(Int((d*x)**n*(S(1) - b*x/a)**(p/S(2) + S(-1)/2)*(S(1) + b*x/a)**(m + p/S(2) + S(-1)/2), x), x, sin(e + f*x)), x) rule2674 = ReplacementRule(pattern2674, replacement2674) pattern2675 = Pattern(Integral((WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*sin(x_*WC('f', S(1)) + WC('e', S(0)))**p_, x_), cons2, cons3, cons27, cons48, cons125, cons4, cons1265, cons1306, cons17) def replacement2675(p, m, f, b, d, a, n, x, e): rubi.append(2675) return -Dist(a**m*sin(e + f*x)/(f*sqrt(-cos(e + f*x) + S(1))*sqrt(cos(e + f*x) + S(1))), Subst(Int((d*x)**n*(S(1) - b*x/a)**(p/S(2) + S(-1)/2)*(S(1) + b*x/a)**(m + p/S(2) + S(-1)/2), x), x, cos(e + f*x)), x) rule2675 = ReplacementRule(pattern2675, replacement2675) pattern2676 = Pattern(Integral((WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*cos(x_*WC('f', S(1)) + WC('e', S(0)))**p_, x_), cons2, cons3, cons27, cons48, cons125, cons21, cons4, cons1265, cons1306, cons18) def replacement2676(p, m, f, b, d, a, n, x, e): rubi.append(2676) return Dist(a**(-p + S(2))*cos(e + f*x)/(f*sqrt(a - b*sin(e + f*x))*sqrt(a + b*sin(e + f*x))), Subst(Int((d*x)**n*(a - b*x)**(p/S(2) + S(-1)/2)*(a + b*x)**(m + p/S(2) + S(-1)/2), x), x, sin(e + f*x)), x) rule2676 = ReplacementRule(pattern2676, replacement2676) pattern2677 = Pattern(Integral((WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*sin(x_*WC('f', S(1)) + WC('e', S(0)))**p_, x_), cons2, cons3, cons27, cons48, cons125, cons21, cons4, cons1265, cons1306, cons18) def replacement2677(p, m, f, b, d, a, n, x, e): rubi.append(2677) return -Dist(a**(-p + S(2))*sin(e + f*x)/(f*sqrt(a - b*cos(e + f*x))*sqrt(a + b*cos(e + f*x))), Subst(Int((d*x)**n*(a - b*x)**(p/S(2) + S(-1)/2)*(a + b*x)**(m + p/S(2) + S(-1)/2), x), x, cos(e + f*x)), x) rule2677 = ReplacementRule(pattern2677, replacement2677) pattern2678 = Pattern(Integral((WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(WC('g', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**p_*(a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_, x_), cons2, cons3, cons27, cons48, cons125, cons208, cons4, cons5, cons1265, cons62, cons1387) def replacement2678(p, m, f, b, g, d, a, n, x, e): rubi.append(2678) return Int(ExpandTrig((g*cos(e + f*x))**p, (d*sin(e + f*x))**n*(a + b*sin(e + f*x))**m, x), x) rule2678 = ReplacementRule(pattern2678, replacement2678) pattern2679 = Pattern(Integral((WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(WC('g', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**p_*(a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_, x_), cons2, cons3, cons27, cons48, cons125, cons208, cons4, cons5, cons1265, cons62, cons1387) def replacement2679(p, m, f, b, g, d, a, n, x, e): rubi.append(2679) return Int(ExpandTrig((g*sin(e + f*x))**p, (d*cos(e + f*x))**n*(a + b*cos(e + f*x))**m, x), x) rule2679 = ReplacementRule(pattern2679, replacement2679) pattern2680 = Pattern(Integral((WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(WC('g', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**p_*(a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_, x_), cons2, cons3, cons27, cons48, cons125, cons4, cons5, cons1265, cons17) def replacement2680(p, m, f, b, g, d, a, n, x, e): rubi.append(2680) return Dist(a**m*g*(g*cos(e + f*x))**(p + S(-1))*(-sin(e + f*x) + S(1))**(-p/S(2) + S(1)/2)*(sin(e + f*x) + S(1))**(-p/S(2) + S(1)/2)/f, Subst(Int((d*x)**n*(S(1) - b*x/a)**(p/S(2) + S(-1)/2)*(S(1) + b*x/a)**(m + p/S(2) + S(-1)/2), x), x, sin(e + f*x)), x) rule2680 = ReplacementRule(pattern2680, replacement2680) pattern2681 = Pattern(Integral((WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(WC('g', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**p_*(a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_, x_), cons2, cons3, cons27, cons48, cons125, cons4, cons5, cons1265, cons17) def replacement2681(p, m, f, b, g, d, a, n, x, e): rubi.append(2681) return -Dist(a**m*g*(g*sin(e + f*x))**(p + S(-1))*(-cos(e + f*x) + S(1))**(-p/S(2) + S(1)/2)*(cos(e + f*x) + S(1))**(-p/S(2) + S(1)/2)/f, Subst(Int((d*x)**n*(S(1) - b*x/a)**(p/S(2) + S(-1)/2)*(S(1) + b*x/a)**(m + p/S(2) + S(-1)/2), x), x, cos(e + f*x)), x) rule2681 = ReplacementRule(pattern2681, replacement2681) pattern2682 = Pattern(Integral((WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(WC('g', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**p_*(a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_, x_), cons2, cons3, cons27, cons48, cons125, cons21, cons4, cons5, cons1265, cons18) def replacement2682(p, m, f, b, g, d, a, n, x, e): rubi.append(2682) return Dist(g*(g*cos(e + f*x))**(p + S(-1))*(a - b*sin(e + f*x))**(-p/S(2) + S(1)/2)*(a + b*sin(e + f*x))**(-p/S(2) + S(1)/2)/f, Subst(Int((d*x)**n*(a - b*x)**(p/S(2) + S(-1)/2)*(a + b*x)**(m + p/S(2) + S(-1)/2), x), x, sin(e + f*x)), x) rule2682 = ReplacementRule(pattern2682, replacement2682) pattern2683 = Pattern(Integral((WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(WC('g', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**p_*(a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_, x_), cons2, cons3, cons27, cons48, cons125, cons21, cons4, cons5, cons1265, cons18) def replacement2683(p, m, f, b, g, d, a, n, x, e): rubi.append(2683) return -Dist(g*(g*sin(e + f*x))**(p + S(-1))*(a - b*cos(e + f*x))**(-p/S(2) + S(1)/2)*(a + b*cos(e + f*x))**(-p/S(2) + S(1)/2)/f, Subst(Int((d*x)**n*(a - b*x)**(p/S(2) + S(-1)/2)*(a + b*x)**(m + p/S(2) + S(-1)/2), x), x, cos(e + f*x)), x) rule2683 = ReplacementRule(pattern2683, replacement2683) pattern2684 = Pattern(Integral((WC('g', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**p_*(a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_/sqrt(WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons27, cons48, cons125, cons208, cons1267, cons31, cons94, cons1388) def replacement2684(p, m, f, b, g, d, a, x, e): rubi.append(2684) return Dist(g**S(2)*(S(2)*m + S(3))/(S(2)*a*(m + S(1))), Int((g*cos(e + f*x))**(p + S(-2))*(a + b*sin(e + f*x))**(m + S(1))/sqrt(d*sin(e + f*x)), x), x) - Simp(g*sqrt(d*sin(e + f*x))*(g*cos(e + f*x))**(p + S(-1))*(a + b*sin(e + f*x))**(m + S(1))/(a*d*f*(m + S(1))), x) rule2684 = ReplacementRule(pattern2684, replacement2684) pattern2685 = Pattern(Integral((WC('g', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**p_*(a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_/sqrt(WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons27, cons48, cons125, cons208, cons1267, cons31, cons94, cons1388) def replacement2685(p, m, f, b, g, d, a, x, e): rubi.append(2685) return Dist(g**S(2)*(S(2)*m + S(3))/(S(2)*a*(m + S(1))), Int((g*sin(e + f*x))**(p + S(-2))*(a + b*cos(e + f*x))**(m + S(1))/sqrt(d*cos(e + f*x)), x), x) + Simp(g*sqrt(d*cos(e + f*x))*(g*sin(e + f*x))**(p + S(-1))*(a + b*cos(e + f*x))**(m + S(1))/(a*d*f*(m + S(1))), x) rule2685 = ReplacementRule(pattern2685, replacement2685) pattern2686 = Pattern(Integral((WC('g', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**p_*(a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_/sqrt(WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons48, cons125, cons208, cons1267, cons31, cons168, cons1389) def replacement2686(p, m, f, b, g, d, a, x, e): rubi.append(2686) return Dist(S(2)*a*m/(g**S(2)*(S(2)*m + S(1))), Int((g*cos(e + f*x))**(p + S(2))*(a + b*sin(e + f*x))**(m + S(-1))/sqrt(d*sin(e + f*x)), x), x) + Simp(S(2)*sqrt(d*sin(e + f*x))*(g*cos(e + f*x))**(p + S(1))*(a + b*sin(e + f*x))**m/(d*f*g*(S(2)*m + S(1))), x) rule2686 = ReplacementRule(pattern2686, replacement2686) pattern2687 = Pattern(Integral((WC('g', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**p_*(a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_/sqrt(WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons48, cons125, cons208, cons1267, cons31, cons168, cons1389) def replacement2687(p, m, f, b, g, d, a, x, e): rubi.append(2687) return Dist(S(2)*a*m/(g**S(2)*(S(2)*m + S(1))), Int((g*sin(e + f*x))**(p + S(2))*(a + b*cos(e + f*x))**(m + S(-1))/sqrt(d*cos(e + f*x)), x), x) + Simp(-S(2)*sqrt(d*cos(e + f*x))*(g*sin(e + f*x))**(p + S(1))*(a + b*cos(e + f*x))**m/(d*f*g*(S(2)*m + S(1))), x) rule2687 = ReplacementRule(pattern2687, replacement2687) pattern2688 = Pattern(Integral((WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*cos(x_*WC('f', S(1)) + WC('e', S(0)))**S(2), x_), cons2, cons3, cons27, cons48, cons125, cons21, cons4, cons1267, cons1390) def replacement2688(m, f, b, d, a, n, x, e): rubi.append(2688) return Int((d*sin(e + f*x))**n*(a + b*sin(e + f*x))**m*(-sin(e + f*x)**S(2) + S(1)), x) rule2688 = ReplacementRule(pattern2688, replacement2688) pattern2689 = Pattern(Integral((WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*sin(x_*WC('f', S(1)) + WC('e', S(0)))**S(2), x_), cons2, cons3, cons27, cons48, cons125, cons21, cons4, cons1267, cons1390) def replacement2689(m, f, b, d, a, n, x, e): rubi.append(2689) return Int((d*cos(e + f*x))**n*(a + b*cos(e + f*x))**m*(-cos(e + f*x)**S(2) + S(1)), x) rule2689 = ReplacementRule(pattern2689, replacement2689) pattern2690 = Pattern(Integral((WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*cos(x_*WC('f', S(1)) + WC('e', S(0)))**S(4), x_), cons2, cons3, cons27, cons48, cons125, cons1267, cons1170, cons94, cons89) def replacement2690(m, f, b, d, a, n, x, e): rubi.append(2690) return Dist(S(1)/(a**S(2)*b*d*(m + S(1))*(n + S(1))), Int((d*sin(e + f*x))**(n + S(1))*(a + b*sin(e + f*x))**(m + S(1))*Simp(a**S(2)*(n + S(1))*(n + S(2)) + a*b*(m + S(1))*sin(e + f*x) - b**S(2)*(m + n + S(2))*(m + n + S(3)) - (a**S(2)*(n + S(1))*(n + S(3)) - b**S(2)*(m + n + S(2))*(m + n + S(4)))*sin(e + f*x)**S(2), x), x), x) + Simp((d*sin(e + f*x))**(n + S(1))*(a + b*sin(e + f*x))**(m + S(1))*cos(e + f*x)/(a*d*f*(n + S(1))), x) - Simp((d*sin(e + f*x))**(n + S(2))*(a + b*sin(e + f*x))**(m + S(1))*(a**S(2)*(n + S(1)) - b**S(2)*(m + n + S(2)))*cos(e + f*x)/(a**S(2)*b*d**S(2)*f*(m + S(1))*(n + S(1))), x) rule2690 = ReplacementRule(pattern2690, replacement2690) pattern2691 = Pattern(Integral((WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*sin(x_*WC('f', S(1)) + WC('e', S(0)))**S(4), x_), cons2, cons3, cons27, cons48, cons125, cons1267, cons1170, cons94, cons89) def replacement2691(m, f, b, d, a, n, x, e): rubi.append(2691) return Dist(S(1)/(a**S(2)*b*d*(m + S(1))*(n + S(1))), Int((d*cos(e + f*x))**(n + S(1))*(a + b*cos(e + f*x))**(m + S(1))*Simp(a**S(2)*(n + S(1))*(n + S(2)) + a*b*(m + S(1))*cos(e + f*x) - b**S(2)*(m + n + S(2))*(m + n + S(3)) - (a**S(2)*(n + S(1))*(n + S(3)) - b**S(2)*(m + n + S(2))*(m + n + S(4)))*cos(e + f*x)**S(2), x), x), x) - Simp((d*cos(e + f*x))**(n + S(1))*(a + b*cos(e + f*x))**(m + S(1))*sin(e + f*x)/(a*d*f*(n + S(1))), x) + Simp((d*cos(e + f*x))**(n + S(2))*(a + b*cos(e + f*x))**(m + S(1))*(a**S(2)*(n + S(1)) - b**S(2)*(m + n + S(2)))*sin(e + f*x)/(a**S(2)*b*d**S(2)*f*(m + S(1))*(n + S(1))), x) rule2691 = ReplacementRule(pattern2691, replacement2691) pattern2692 = Pattern(Integral((WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*cos(x_*WC('f', S(1)) + WC('e', S(0)))**S(4), x_), cons2, cons3, cons27, cons48, cons125, cons4, cons1267, cons1170, cons94, cons1391, cons1392) def replacement2692(m, f, b, d, a, n, x, e): rubi.append(2692) return -Dist(S(1)/(a**S(2)*b**S(2)*(m + S(1))*(m + S(2))), Int((d*sin(e + f*x))**n*(a + b*sin(e + f*x))**(m + S(2))*Simp(a**S(2)*(n + S(1))*(n + S(3)) + a*b*(m + S(2))*sin(e + f*x) - b**S(2)*(m + n + S(2))*(m + n + S(3)) - (a**S(2)*(n + S(2))*(n + S(3)) - b**S(2)*(m + n + S(2))*(m + n + S(4)))*sin(e + f*x)**S(2), x), x), x) + Simp((d*sin(e + f*x))**(n + S(1))*(a + b*sin(e + f*x))**(m + S(1))*(a**S(2) - b**S(2))*cos(e + f*x)/(a*b**S(2)*d*f*(m + S(1))), x) + Simp((d*sin(e + f*x))**(n + S(1))*(a + b*sin(e + f*x))**(m + S(2))*(a**S(2)*(-m + n + S(1)) - b**S(2)*(m + n + S(2)))*cos(e + f*x)/(a**S(2)*b**S(2)*d*f*(m + S(1))*(m + S(2))), x) rule2692 = ReplacementRule(pattern2692, replacement2692) pattern2693 = Pattern(Integral((WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*sin(x_*WC('f', S(1)) + WC('e', S(0)))**S(4), x_), cons2, cons3, cons27, cons48, cons125, cons4, cons1267, cons1170, cons94, cons1391, cons1392) def replacement2693(m, f, b, d, a, n, x, e): rubi.append(2693) return -Dist(S(1)/(a**S(2)*b**S(2)*(m + S(1))*(m + S(2))), Int((d*cos(e + f*x))**n*(a + b*cos(e + f*x))**(m + S(2))*Simp(a**S(2)*(n + S(1))*(n + S(3)) + a*b*(m + S(2))*cos(e + f*x) - b**S(2)*(m + n + S(2))*(m + n + S(3)) - (a**S(2)*(n + S(2))*(n + S(3)) - b**S(2)*(m + n + S(2))*(m + n + S(4)))*cos(e + f*x)**S(2), x), x), x) - Simp((d*cos(e + f*x))**(n + S(1))*(a + b*cos(e + f*x))**(m + S(1))*(a**S(2) - b**S(2))*sin(e + f*x)/(a*b**S(2)*d*f*(m + S(1))), x) - Simp((d*cos(e + f*x))**(n + S(1))*(a + b*cos(e + f*x))**(m + S(2))*(a**S(2)*(-m + n + S(1)) - b**S(2)*(m + n + S(2)))*sin(e + f*x)/(a**S(2)*b**S(2)*d*f*(m + S(1))*(m + S(2))), x) rule2693 = ReplacementRule(pattern2693, replacement2693) pattern2694 = Pattern(Integral((WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*cos(x_*WC('f', S(1)) + WC('e', S(0)))**S(4), x_), cons2, cons3, cons27, cons48, cons125, cons4, cons1267, cons1170, cons94, cons1391, cons1393) def replacement2694(m, f, b, d, a, n, x, e): rubi.append(2694) return -Dist(S(1)/(a*b**S(2)*(m + S(1))*(m + n + S(4))), Int((d*sin(e + f*x))**n*(a + b*sin(e + f*x))**(m + S(1))*Simp(a**S(2)*(n + S(1))*(n + S(3)) + a*b*(m + S(1))*sin(e + f*x) - b**S(2)*(m + n + S(2))*(m + n + S(4)) - (a**S(2)*(n + S(2))*(n + S(3)) - b**S(2)*(m + n + S(3))*(m + n + S(4)))*sin(e + f*x)**S(2), x), x), x) - Simp((d*sin(e + f*x))**(n + S(1))*(a + b*sin(e + f*x))**(m + S(2))*cos(e + f*x)/(b**S(2)*d*f*(m + n + S(4))), x) + Simp((d*sin(e + f*x))**(n + S(1))*(a + b*sin(e + f*x))**(m + S(1))*(a**S(2) - b**S(2))*cos(e + f*x)/(a*b**S(2)*d*f*(m + S(1))), x) rule2694 = ReplacementRule(pattern2694, replacement2694) pattern2695 = Pattern(Integral((WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*sin(x_*WC('f', S(1)) + WC('e', S(0)))**S(4), x_), cons2, cons3, cons27, cons48, cons125, cons4, cons1267, cons1170, cons94, cons1391, cons1393) def replacement2695(m, f, b, d, a, n, x, e): rubi.append(2695) return -Dist(S(1)/(a*b**S(2)*(m + S(1))*(m + n + S(4))), Int((d*cos(e + f*x))**n*(a + b*cos(e + f*x))**(m + S(1))*Simp(a**S(2)*(n + S(1))*(n + S(3)) + a*b*(m + S(1))*cos(e + f*x) - b**S(2)*(m + n + S(2))*(m + n + S(4)) - (a**S(2)*(n + S(2))*(n + S(3)) - b**S(2)*(m + n + S(3))*(m + n + S(4)))*cos(e + f*x)**S(2), x), x), x) + Simp((d*cos(e + f*x))**(n + S(1))*(a + b*cos(e + f*x))**(m + S(2))*sin(e + f*x)/(b**S(2)*d*f*(m + n + S(4))), x) - Simp((d*cos(e + f*x))**(n + S(1))*(a + b*cos(e + f*x))**(m + S(1))*(a**S(2) - b**S(2))*sin(e + f*x)/(a*b**S(2)*d*f*(m + S(1))), x) rule2695 = ReplacementRule(pattern2695, replacement2695) pattern2696 = Pattern(Integral((WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*cos(x_*WC('f', S(1)) + WC('e', S(0)))**S(4), x_), cons2, cons3, cons27, cons48, cons125, cons21, cons1267, cons1390, cons1305, cons87, cons89, cons1394) def replacement2696(m, f, b, d, a, n, x, e): rubi.append(2696) return -Dist(S(1)/(a**S(2)*d**S(2)*(n + S(1))*(n + S(2))), Int((d*sin(e + f*x))**(n + S(2))*(a + b*sin(e + f*x))**m*Simp(a**S(2)*n*(n + S(2)) + a*b*m*sin(e + f*x) - b**S(2)*(m + n + S(2))*(m + n + S(3)) - (a**S(2)*(n + S(1))*(n + S(2)) - b**S(2)*(m + n + S(2))*(m + n + S(4)))*sin(e + f*x)**S(2), x), x), x) + Simp((d*sin(e + f*x))**(n + S(1))*(a + b*sin(e + f*x))**(m + S(1))*cos(e + f*x)/(a*d*f*(n + S(1))), x) - Simp(b*(d*sin(e + f*x))**(n + S(2))*(a + b*sin(e + f*x))**(m + S(1))*(m + n + S(2))*cos(e + f*x)/(a**S(2)*d**S(2)*f*(n + S(1))*(n + S(2))), x) rule2696 = ReplacementRule(pattern2696, replacement2696) pattern2697 = Pattern(Integral((WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*sin(x_*WC('f', S(1)) + WC('e', S(0)))**S(4), x_), cons2, cons3, cons27, cons48, cons125, cons21, cons1267, cons1390, cons1305, cons87, cons89, cons1394) def replacement2697(m, f, b, d, a, n, x, e): rubi.append(2697) return -Dist(S(1)/(a**S(2)*d**S(2)*(n + S(1))*(n + S(2))), Int((d*cos(e + f*x))**(n + S(2))*(a + b*cos(e + f*x))**m*Simp(a**S(2)*n*(n + S(2)) + a*b*m*cos(e + f*x) - b**S(2)*(m + n + S(2))*(m + n + S(3)) - (a**S(2)*(n + S(1))*(n + S(2)) - b**S(2)*(m + n + S(2))*(m + n + S(4)))*cos(e + f*x)**S(2), x), x), x) - Simp((d*cos(e + f*x))**(n + S(1))*(a + b*cos(e + f*x))**(m + S(1))*sin(e + f*x)/(a*d*f*(n + S(1))), x) + Simp(b*(d*cos(e + f*x))**(n + S(2))*(a + b*cos(e + f*x))**(m + S(1))*(m + n + S(2))*sin(e + f*x)/(a**S(2)*d**S(2)*f*(n + S(1))*(n + S(2))), x) rule2697 = ReplacementRule(pattern2697, replacement2697) pattern2698 = Pattern(Integral((WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*cos(x_*WC('f', S(1)) + WC('e', S(0)))**S(4), x_), cons2, cons3, cons27, cons48, cons125, cons21, cons1267, cons1390, cons1305, cons87, cons89, cons1393) def replacement2698(m, f, b, d, a, n, x, e): rubi.append(2698) return Dist(S(1)/(a*b*d*(n + S(1))*(m + n + S(4))), Int((d*sin(e + f*x))**(n + S(1))*(a + b*sin(e + f*x))**m*Simp(a**S(2)*(n + S(1))*(n + S(2)) + a*b*(m + S(3))*sin(e + f*x) - b**S(2)*(m + n + S(2))*(m + n + S(4)) - (a**S(2)*(n + S(1))*(n + S(3)) - b**S(2)*(m + n + S(3))*(m + n + S(4)))*sin(e + f*x)**S(2), x), x), x) + Simp((d*sin(e + f*x))**(n + S(1))*(a + b*sin(e + f*x))**(m + S(1))*cos(e + f*x)/(a*d*f*(n + S(1))), x) - Simp((d*sin(e + f*x))**(n + S(2))*(a + b*sin(e + f*x))**(m + S(1))*cos(e + f*x)/(b*d**S(2)*f*(m + n + S(4))), x) rule2698 = ReplacementRule(pattern2698, replacement2698) pattern2699 = Pattern(Integral((WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*sin(x_*WC('f', S(1)) + WC('e', S(0)))**S(4), x_), cons2, cons3, cons27, cons48, cons125, cons21, cons1267, cons1390, cons1305, cons87, cons89, cons1393) def replacement2699(m, f, b, d, a, n, x, e): rubi.append(2699) return Dist(S(1)/(a*b*d*(n + S(1))*(m + n + S(4))), Int((d*cos(e + f*x))**(n + S(1))*(a + b*cos(e + f*x))**m*Simp(a**S(2)*(n + S(1))*(n + S(2)) + a*b*(m + S(3))*cos(e + f*x) - b**S(2)*(m + n + S(2))*(m + n + S(4)) - (a**S(2)*(n + S(1))*(n + S(3)) - b**S(2)*(m + n + S(3))*(m + n + S(4)))*cos(e + f*x)**S(2), x), x), x) - Simp((d*cos(e + f*x))**(n + S(1))*(a + b*cos(e + f*x))**(m + S(1))*sin(e + f*x)/(a*d*f*(n + S(1))), x) + Simp((d*cos(e + f*x))**(n + S(2))*(a + b*cos(e + f*x))**(m + S(1))*sin(e + f*x)/(b*d**S(2)*f*(m + n + S(4))), x) rule2699 = ReplacementRule(pattern2699, replacement2699) pattern2700 = Pattern(Integral((WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*cos(x_*WC('f', S(1)) + WC('e', S(0)))**S(4), x_), cons2, cons3, cons27, cons48, cons125, cons21, cons4, cons1267, cons1390, cons1305, cons346, cons213, cons1393) def replacement2700(m, f, b, d, a, n, x, e): rubi.append(2700) return -Dist(S(1)/(b**S(2)*(m + n + S(3))*(m + n + S(4))), Int((d*sin(e + f*x))**n*(a + b*sin(e + f*x))**m*Simp(a**S(2)*(n + S(1))*(n + S(3)) + a*b*m*sin(e + f*x) - b**S(2)*(m + n + S(3))*(m + n + S(4)) - (a**S(2)*(n + S(2))*(n + S(3)) - b**S(2)*(m + n + S(3))*(m + n + S(5)))*sin(e + f*x)**S(2), x), x), x) - Simp((d*sin(e + f*x))**(n + S(2))*(a + b*sin(e + f*x))**(m + S(1))*cos(e + f*x)/(b*d**S(2)*f*(m + n + S(4))), x) + Simp(a*(d*sin(e + f*x))**(n + S(1))*(a + b*sin(e + f*x))**(m + S(1))*(n + S(3))*cos(e + f*x)/(b**S(2)*d*f*(m + n + S(3))*(m + n + S(4))), x) rule2700 = ReplacementRule(pattern2700, replacement2700) pattern2701 = Pattern(Integral((WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*sin(x_*WC('f', S(1)) + WC('e', S(0)))**S(4), x_), cons2, cons3, cons27, cons48, cons125, cons21, cons4, cons1267, cons1390, cons1305, cons346, cons213, cons1393) def replacement2701(m, f, b, d, a, n, x, e): rubi.append(2701) return -Dist(S(1)/(b**S(2)*(m + n + S(3))*(m + n + S(4))), Int((d*cos(e + f*x))**n*(a + b*cos(e + f*x))**m*Simp(a**S(2)*(n + S(1))*(n + S(3)) + a*b*m*cos(e + f*x) - b**S(2)*(m + n + S(3))*(m + n + S(4)) - (a**S(2)*(n + S(2))*(n + S(3)) - b**S(2)*(m + n + S(3))*(m + n + S(5)))*cos(e + f*x)**S(2), x), x), x) + Simp((d*cos(e + f*x))**(n + S(2))*(a + b*cos(e + f*x))**(m + S(1))*sin(e + f*x)/(b*d**S(2)*f*(m + n + S(4))), x) - Simp(a*(d*cos(e + f*x))**(n + S(1))*(a + b*cos(e + f*x))**(m + S(1))*(n + S(3))*sin(e + f*x)/(b**S(2)*d*f*(m + n + S(3))*(m + n + S(4))), x) rule2701 = ReplacementRule(pattern2701, replacement2701) pattern2702 = Pattern(Integral((WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*cos(x_*WC('f', S(1)) + WC('e', S(0)))**S(6), x_), cons2, cons3, cons27, cons48, cons125, cons21, cons4, cons1267, cons1170, cons584, cons1395, cons1396, cons1397, cons143) def replacement2702(m, f, b, d, a, n, x, e): rubi.append(2702) return Dist(S(1)/(a**S(2)*b**S(2)*d**S(2)*(n + S(1))*(n + S(2))*(m + n + S(5))*(m + n + S(6))), Int((d*sin(e + f*x))**(n + S(2))*(a + b*sin(e + f*x))**m*Simp(a**S(4)*(n + S(1))*(n + S(2))*(n + S(3))*(n + S(5)) - a**S(2)*b**S(2)*(n + S(2))*(S(2)*n + S(1))*(m + n + S(5))*(m + n + S(6)) + a*b*m*(a**S(2)*(n + S(1))*(n + S(2)) - b**S(2)*(m + n + S(5))*(m + n + S(6)))*sin(e + f*x) + b**S(4)*(m + n + S(2))*(m + n + S(3))*(m + n + S(5))*(m + n + S(6)) - (a**S(4)*(n + S(1))*(n + S(2))*(n + S(4))*(n + S(5)) - a**S(2)*b**S(2)*(n + S(1))*(n + S(2))*(m + n + S(5))*(S(2)*m + S(2)*n + S(13)) + b**S(4)*(m + n + S(2))*(m + n + S(4))*(m + n + S(5))*(m + n + S(6)))*sin(e + f*x)**S(2), x), x), x) + Simp((d*sin(e + f*x))**(n + S(1))*(a + b*sin(e + f*x))**(m + S(1))*cos(e + f*x)/(a*d*f*(n + S(1))), x) + Simp((d*sin(e + f*x))**(n + S(4))*(a + b*sin(e + f*x))**(m + S(1))*cos(e + f*x)/(b*d**S(4)*f*(m + n + S(6))), x) - Simp(b*(d*sin(e + f*x))**(n + S(2))*(a + b*sin(e + f*x))**(m + S(1))*(m + n + S(2))*cos(e + f*x)/(a**S(2)*d**S(2)*f*(n + S(1))*(n + S(2))), x) - Simp(a*(d*sin(e + f*x))**(n + S(3))*(a + b*sin(e + f*x))**(m + S(1))*(n + S(5))*cos(e + f*x)/(b**S(2)*d**S(3)*f*(m + n + S(5))*(m + n + S(6))), x) rule2702 = ReplacementRule(pattern2702, replacement2702) pattern2703 = Pattern(Integral((WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*sin(x_*WC('f', S(1)) + WC('e', S(0)))**S(6), x_), cons2, cons3, cons27, cons48, cons125, cons21, cons4, cons1267, cons1170, cons584, cons1395, cons1396, cons1397, cons143) def replacement2703(m, f, b, d, a, n, x, e): rubi.append(2703) return Dist(S(1)/(a**S(2)*b**S(2)*d**S(2)*(n + S(1))*(n + S(2))*(m + n + S(5))*(m + n + S(6))), Int((d*cos(e + f*x))**(n + S(2))*(a + b*cos(e + f*x))**m*Simp(a**S(4)*(n + S(1))*(n + S(2))*(n + S(3))*(n + S(5)) - a**S(2)*b**S(2)*(n + S(2))*(S(2)*n + S(1))*(m + n + S(5))*(m + n + S(6)) + a*b*m*(a**S(2)*(n + S(1))*(n + S(2)) - b**S(2)*(m + n + S(5))*(m + n + S(6)))*cos(e + f*x) + b**S(4)*(m + n + S(2))*(m + n + S(3))*(m + n + S(5))*(m + n + S(6)) - (a**S(4)*(n + S(1))*(n + S(2))*(n + S(4))*(n + S(5)) - a**S(2)*b**S(2)*(n + S(1))*(n + S(2))*(m + n + S(5))*(S(2)*m + S(2)*n + S(13)) + b**S(4)*(m + n + S(2))*(m + n + S(4))*(m + n + S(5))*(m + n + S(6)))*cos(e + f*x)**S(2), x), x), x) - Simp((d*cos(e + f*x))**(n + S(1))*(a + b*cos(e + f*x))**(m + S(1))*sin(e + f*x)/(a*d*f*(n + S(1))), x) - Simp((d*cos(e + f*x))**(n + S(4))*(a + b*cos(e + f*x))**(m + S(1))*sin(e + f*x)/(b*d**S(4)*f*(m + n + S(6))), x) + Simp(b*(d*cos(e + f*x))**(n + S(2))*(a + b*cos(e + f*x))**(m + S(1))*(m + n + S(2))*sin(e + f*x)/(a**S(2)*d**S(2)*f*(n + S(1))*(n + S(2))), x) + Simp(a*(d*cos(e + f*x))**(n + S(3))*(a + b*cos(e + f*x))**(m + S(1))*(n + S(5))*sin(e + f*x)/(b**S(2)*d**S(3)*f*(m + n + S(5))*(m + n + S(6))), x) rule2703 = ReplacementRule(pattern2703, replacement2703) pattern2704 = Pattern(Integral((WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*cos(x_*WC('f', S(1)) + WC('e', S(0)))**p_, x_), cons2, cons3, cons27, cons48, cons125, cons1267, cons1398, cons1399) def replacement2704(p, m, f, b, d, a, n, x, e): rubi.append(2704) return Int(ExpandTrig((d*sin(e + f*x))**n*(a + b*sin(e + f*x))**m*(-sin(e + f*x)**S(2) + S(1))**(p/S(2)), x), x) rule2704 = ReplacementRule(pattern2704, replacement2704) pattern2705 = Pattern(Integral((WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*sin(x_*WC('f', S(1)) + WC('e', S(0)))**p_, x_), cons2, cons3, cons27, cons48, cons125, cons1267, cons1398, cons1399) def replacement2705(p, m, f, b, d, a, n, x, e): rubi.append(2705) return Int(ExpandTrig((d*cos(e + f*x))**n*(a + b*cos(e + f*x))**m*(-cos(e + f*x)**S(2) + S(1))**(p/S(2)), x), x) rule2705 = ReplacementRule(pattern2705, replacement2705) pattern2706 = Pattern(Integral((WC('g', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**p_*sin(x_*WC('f', S(1)) + WC('e', S(0)))**n_/(a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons48, cons125, cons208, cons5, cons1267, cons85, cons1400) def replacement2706(p, f, b, g, a, n, x, e): rubi.append(2706) return Int(ExpandTrig((g*cos(e + f*x))**p, sin(e + f*x)**n/(a + b*sin(e + f*x)), x), x) rule2706 = ReplacementRule(pattern2706, replacement2706) pattern2707 = Pattern(Integral((WC('g', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**p_*cos(x_*WC('f', S(1)) + WC('e', S(0)))**n_/(a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons48, cons125, cons208, cons5, cons1267, cons85, cons1400) def replacement2707(p, f, b, g, a, n, x, e): rubi.append(2707) return Int(ExpandTrig((g*sin(e + f*x))**p, cos(e + f*x)**n/(a + b*cos(e + f*x)), x), x) rule2707 = ReplacementRule(pattern2707, replacement2707) pattern2708 = Pattern(Integral((WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(WC('g', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**p_/(a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons27, cons48, cons125, cons208, cons1267, cons1401, cons146, cons1402) def replacement2708(p, f, b, g, d, a, n, x, e): rubi.append(2708) return Dist(g**S(2)/a, Int((d*sin(e + f*x))**n*(g*cos(e + f*x))**(p + S(-2)), x), x) - Dist(b*g**S(2)/(a**S(2)*d), Int((d*sin(e + f*x))**(n + S(1))*(g*cos(e + f*x))**(p + S(-2)), x), x) - Dist(g**S(2)*(a**S(2) - b**S(2))/(a**S(2)*d**S(2)), Int((d*sin(e + f*x))**(n + S(2))*(g*cos(e + f*x))**(p + S(-2))/(a + b*sin(e + f*x)), x), x) rule2708 = ReplacementRule(pattern2708, replacement2708) pattern2709 = Pattern(Integral((WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(WC('g', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**p_/(a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons27, cons48, cons125, cons208, cons1267, cons1401, cons146, cons1402) def replacement2709(p, f, b, g, d, a, n, x, e): rubi.append(2709) return Dist(g**S(2)/a, Int((d*cos(e + f*x))**n*(g*sin(e + f*x))**(p + S(-2)), x), x) - Dist(b*g**S(2)/(a**S(2)*d), Int((d*cos(e + f*x))**(n + S(1))*(g*sin(e + f*x))**(p + S(-2)), x), x) - Dist(g**S(2)*(a**S(2) - b**S(2))/(a**S(2)*d**S(2)), Int((d*cos(e + f*x))**(n + S(2))*(g*sin(e + f*x))**(p + S(-2))/(a + b*cos(e + f*x)), x), x) rule2709 = ReplacementRule(pattern2709, replacement2709) pattern2710 = Pattern(Integral((WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(WC('g', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**p_/(a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons27, cons48, cons125, cons208, cons1267, cons1401, cons146, cons1403) def replacement2710(p, f, b, g, d, a, n, x, e): rubi.append(2710) return Dist(g**S(2)/(a*b), Int((d*sin(e + f*x))**n*(g*cos(e + f*x))**(p + S(-2))*(-a*sin(e + f*x) + b), x), x) + Dist(g**S(2)*(a**S(2) - b**S(2))/(a*b*d), Int((d*sin(e + f*x))**(n + S(1))*(g*cos(e + f*x))**(p + S(-2))/(a + b*sin(e + f*x)), x), x) rule2710 = ReplacementRule(pattern2710, replacement2710) pattern2711 = Pattern(Integral((WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(WC('g', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**p_/(a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons27, cons48, cons125, cons208, cons1267, cons1401, cons146, cons1403) def replacement2711(p, f, b, g, d, a, n, x, e): rubi.append(2711) return Dist(g**S(2)/(a*b), Int((d*cos(e + f*x))**n*(g*sin(e + f*x))**(p + S(-2))*(-a*cos(e + f*x) + b), x), x) + Dist(g**S(2)*(a**S(2) - b**S(2))/(a*b*d), Int((d*cos(e + f*x))**(n + S(1))*(g*sin(e + f*x))**(p + S(-2))/(a + b*cos(e + f*x)), x), x) rule2711 = ReplacementRule(pattern2711, replacement2711) pattern2712 = Pattern(Integral((WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(WC('g', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**p_/(a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons27, cons48, cons125, cons208, cons1267, cons1401, cons146) def replacement2712(p, f, b, g, d, a, n, x, e): rubi.append(2712) return Dist(g**S(2)/b**S(2), Int((d*sin(e + f*x))**n*(g*cos(e + f*x))**(p + S(-2))*(a - b*sin(e + f*x)), x), x) - Dist(g**S(2)*(a**S(2) - b**S(2))/b**S(2), Int((d*sin(e + f*x))**n*(g*cos(e + f*x))**(p + S(-2))/(a + b*sin(e + f*x)), x), x) rule2712 = ReplacementRule(pattern2712, replacement2712) pattern2713 = Pattern(Integral((WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(WC('g', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**p_/(a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons27, cons48, cons125, cons208, cons1267, cons1401, cons146) def replacement2713(p, f, b, g, d, a, n, x, e): rubi.append(2713) return Dist(g**S(2)/b**S(2), Int((d*cos(e + f*x))**n*(g*sin(e + f*x))**(p + S(-2))*(a - b*cos(e + f*x)), x), x) - Dist(g**S(2)*(a**S(2) - b**S(2))/b**S(2), Int((d*cos(e + f*x))**n*(g*sin(e + f*x))**(p + S(-2))/(a + b*cos(e + f*x)), x), x) rule2713 = ReplacementRule(pattern2713, replacement2713) pattern2714 = Pattern(Integral((WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(WC('g', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**p_/(a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons27, cons48, cons125, cons208, cons1267, cons1401, cons137, cons165) def replacement2714(p, f, b, g, d, a, n, x, e): rubi.append(2714) return Dist(a*d**S(2)/(a**S(2) - b**S(2)), Int((d*sin(e + f*x))**(n + S(-2))*(g*cos(e + f*x))**p, x), x) - Dist(b*d/(a**S(2) - b**S(2)), Int((d*sin(e + f*x))**(n + S(-1))*(g*cos(e + f*x))**p, x), x) - Dist(a**S(2)*d**S(2)/(g**S(2)*(a**S(2) - b**S(2))), Int((d*sin(e + f*x))**(n + S(-2))*(g*cos(e + f*x))**(p + S(2))/(a + b*sin(e + f*x)), x), x) rule2714 = ReplacementRule(pattern2714, replacement2714) pattern2715 = Pattern(Integral((WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(WC('g', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**p_/(a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons27, cons48, cons125, cons208, cons1267, cons1401, cons137, cons165) def replacement2715(p, f, b, g, d, a, n, x, e): rubi.append(2715) return Dist(a*d**S(2)/(a**S(2) - b**S(2)), Int((d*cos(e + f*x))**(n + S(-2))*(g*sin(e + f*x))**p, x), x) - Dist(b*d/(a**S(2) - b**S(2)), Int((d*cos(e + f*x))**(n + S(-1))*(g*sin(e + f*x))**p, x), x) - Dist(a**S(2)*d**S(2)/(g**S(2)*(a**S(2) - b**S(2))), Int((d*cos(e + f*x))**(n + S(-2))*(g*sin(e + f*x))**(p + S(2))/(a + b*cos(e + f*x)), x), x) rule2715 = ReplacementRule(pattern2715, replacement2715) pattern2716 = Pattern(Integral((WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(WC('g', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**p_/(a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons27, cons48, cons125, cons208, cons1267, cons1401, cons137, cons88) def replacement2716(p, f, b, g, d, a, n, x, e): rubi.append(2716) return -Dist(d/(a**S(2) - b**S(2)), Int((d*sin(e + f*x))**(n + S(-1))*(g*cos(e + f*x))**p*(-a*sin(e + f*x) + b), x), x) + Dist(a*b*d/(g**S(2)*(a**S(2) - b**S(2))), Int((d*sin(e + f*x))**(n + S(-1))*(g*cos(e + f*x))**(p + S(2))/(a + b*sin(e + f*x)), x), x) rule2716 = ReplacementRule(pattern2716, replacement2716) pattern2717 = Pattern(Integral((WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(WC('g', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**p_/(a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons27, cons48, cons125, cons208, cons1267, cons1401, cons137, cons88) def replacement2717(p, f, b, g, d, a, n, x, e): rubi.append(2717) return -Dist(d/(a**S(2) - b**S(2)), Int((d*cos(e + f*x))**(n + S(-1))*(g*sin(e + f*x))**p*(-a*cos(e + f*x) + b), x), x) + Dist(a*b*d/(g**S(2)*(a**S(2) - b**S(2))), Int((d*cos(e + f*x))**(n + S(-1))*(g*sin(e + f*x))**(p + S(2))/(a + b*cos(e + f*x)), x), x) rule2717 = ReplacementRule(pattern2717, replacement2717) pattern2718 = Pattern(Integral((WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(WC('g', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**p_/(a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons27, cons48, cons125, cons208, cons1267, cons1401, cons137) def replacement2718(p, f, b, g, d, a, n, x, e): rubi.append(2718) return -Dist(b**S(2)/(g**S(2)*(a**S(2) - b**S(2))), Int((d*sin(e + f*x))**n*(g*cos(e + f*x))**(p + S(2))/(a + b*sin(e + f*x)), x), x) + Dist(S(1)/(a**S(2) - b**S(2)), Int((d*sin(e + f*x))**n*(g*cos(e + f*x))**p*(a - b*sin(e + f*x)), x), x) rule2718 = ReplacementRule(pattern2718, replacement2718) pattern2719 = Pattern(Integral((WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(WC('g', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**p_/(a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons27, cons48, cons125, cons208, cons1267, cons1401, cons137) def replacement2719(p, f, b, g, d, a, n, x, e): rubi.append(2719) return -Dist(b**S(2)/(g**S(2)*(a**S(2) - b**S(2))), Int((d*cos(e + f*x))**n*(g*sin(e + f*x))**(p + S(2))/(a + b*cos(e + f*x)), x), x) + Dist(S(1)/(a**S(2) - b**S(2)), Int((d*cos(e + f*x))**n*(g*sin(e + f*x))**p*(a - b*cos(e + f*x)), x), x) rule2719 = ReplacementRule(pattern2719, replacement2719) pattern2720 = Pattern(Integral(sqrt(WC('g', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))/((a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))*sqrt(sin(x_*WC('f', S(1)) + WC('e', S(0))))), x_), cons2, cons3, cons48, cons125, cons208, cons1267) def replacement2720(f, b, g, a, x, e): rubi.append(2720) return Dist(-S(4)*sqrt(S(2))*g/f, Subst(Int(x**S(2)/(sqrt(S(1) - x**S(4)/g**S(2))*(g**S(2)*(a + b) + x**S(4)*(a - b))), x), x, sqrt(g*cos(e + f*x))/sqrt(sin(e + f*x) + S(1))), x) rule2720 = ReplacementRule(pattern2720, replacement2720) pattern2721 = Pattern(Integral(sqrt(WC('g', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))/((a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))*sqrt(cos(x_*WC('f', S(1)) + WC('e', S(0))))), x_), cons2, cons3, cons48, cons125, cons208, cons1267) def replacement2721(f, b, g, a, x, e): rubi.append(2721) return Dist(S(4)*sqrt(S(2))*g/f, Subst(Int(x**S(2)/(sqrt(S(1) - x**S(4)/g**S(2))*(g**S(2)*(a + b) + x**S(4)*(a - b))), x), x, sqrt(g*sin(e + f*x))/sqrt(cos(e + f*x) + S(1))), x) rule2721 = ReplacementRule(pattern2721, replacement2721) pattern2722 = Pattern(Integral(sqrt(WC('g', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))/(sqrt(d_*sin(x_*WC('f', S(1)) + WC('e', S(0))))*(a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))), x_), cons2, cons3, cons27, cons48, cons125, cons208, cons1267) def replacement2722(f, b, g, d, a, x, e): rubi.append(2722) return Dist(sqrt(sin(e + f*x))/sqrt(d*sin(e + f*x)), Int(sqrt(g*cos(e + f*x))/((a + b*sin(e + f*x))*sqrt(sin(e + f*x))), x), x) rule2722 = ReplacementRule(pattern2722, replacement2722) pattern2723 = Pattern(Integral(sqrt(WC('g', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))/(sqrt(d_*cos(x_*WC('f', S(1)) + WC('e', S(0))))*(a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))), x_), cons2, cons3, cons27, cons48, cons125, cons208, cons1267) def replacement2723(f, b, g, d, a, x, e): rubi.append(2723) return Dist(sqrt(cos(e + f*x))/sqrt(d*cos(e + f*x)), Int(sqrt(g*sin(e + f*x))/((a + b*cos(e + f*x))*sqrt(cos(e + f*x))), x), x) rule2723 = ReplacementRule(pattern2723, replacement2723) def With2724(f, b, d, a, x, e): q = Rt(-a**S(2) + b**S(2), S(2)) rubi.append(2724) return -Dist(S(2)*sqrt(S(2))*d*(b - q)/(f*q), Subst(Int(S(1)/(sqrt(S(1) - x**S(4)/d**S(2))*(a*x**S(2) + d*(b - q))), x), x, sqrt(d*sin(e + f*x))/sqrt(cos(e + f*x) + S(1))), x) + Dist(S(2)*sqrt(S(2))*d*(b + q)/(f*q), Subst(Int(S(1)/(sqrt(S(1) - x**S(4)/d**S(2))*(a*x**S(2) + d*(b + q))), x), x, sqrt(d*sin(e + f*x))/sqrt(cos(e + f*x) + S(1))), x) pattern2724 = Pattern(Integral(sqrt(WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))/((a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))*sqrt(cos(x_*WC('f', S(1)) + WC('e', S(0))))), x_), cons2, cons3, cons27, cons48, cons125, cons1267) rule2724 = ReplacementRule(pattern2724, With2724) def With2725(f, b, d, a, x, e): q = Rt(-a**S(2) + b**S(2), S(2)) rubi.append(2725) return Dist(S(2)*sqrt(S(2))*d*(b - q)/(f*q), Subst(Int(S(1)/(sqrt(S(1) - x**S(4)/d**S(2))*(a*x**S(2) + d*(b - q))), x), x, sqrt(d*cos(e + f*x))/sqrt(sin(e + f*x) + S(1))), x) + Dist(-S(2)*sqrt(S(2))*d*(b + q)/(f*q), Subst(Int(S(1)/(sqrt(S(1) - x**S(4)/d**S(2))*(a*x**S(2) + d*(b + q))), x), x, sqrt(d*cos(e + f*x))/sqrt(sin(e + f*x) + S(1))), x) pattern2725 = Pattern(Integral(sqrt(WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))/((a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))*sqrt(sin(x_*WC('f', S(1)) + WC('e', S(0))))), x_), cons2, cons3, cons27, cons48, cons125, cons1267) rule2725 = ReplacementRule(pattern2725, With2725) pattern2726 = Pattern(Integral(sqrt(WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))/(sqrt(WC('g', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))*(a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))), x_), cons2, cons3, cons27, cons48, cons125, cons208, cons1267) def replacement2726(f, b, g, d, a, x, e): rubi.append(2726) return Dist(sqrt(cos(e + f*x))/sqrt(g*cos(e + f*x)), Int(sqrt(d*sin(e + f*x))/((a + b*sin(e + f*x))*sqrt(cos(e + f*x))), x), x) rule2726 = ReplacementRule(pattern2726, replacement2726) pattern2727 = Pattern(Integral(sqrt(WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))/(sqrt(WC('g', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))*(a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))), x_), cons2, cons3, cons27, cons48, cons125, cons208, cons1267) def replacement2727(f, b, g, d, a, x, e): rubi.append(2727) return Dist(sqrt(sin(e + f*x))/sqrt(g*sin(e + f*x)), Int(sqrt(d*cos(e + f*x))/((a + b*cos(e + f*x))*sqrt(sin(e + f*x))), x), x) rule2727 = ReplacementRule(pattern2727, replacement2727) pattern2728 = Pattern(Integral((WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(WC('g', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**p_/(a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons27, cons48, cons125, cons208, cons1267, cons1401, cons1404, cons88) def replacement2728(p, f, b, g, d, a, n, x, e): rubi.append(2728) return Dist(d/b, Int((d*sin(e + f*x))**(n + S(-1))*(g*cos(e + f*x))**p, x), x) - Dist(a*d/b, Int((d*sin(e + f*x))**(n + S(-1))*(g*cos(e + f*x))**p/(a + b*sin(e + f*x)), x), x) rule2728 = ReplacementRule(pattern2728, replacement2728) pattern2729 = Pattern(Integral((WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(WC('g', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**p_/(a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons27, cons48, cons125, cons208, cons1267, cons1401, cons1404, cons88) def replacement2729(p, f, b, g, d, a, n, x, e): rubi.append(2729) return Dist(d/b, Int((d*cos(e + f*x))**(n + S(-1))*(g*sin(e + f*x))**p, x), x) - Dist(a*d/b, Int((d*cos(e + f*x))**(n + S(-1))*(g*sin(e + f*x))**p/(a + b*cos(e + f*x)), x), x) rule2729 = ReplacementRule(pattern2729, replacement2729) pattern2730 = Pattern(Integral((WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(WC('g', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**p_/(a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons27, cons48, cons125, cons208, cons1267, cons1401, cons1404, cons463) def replacement2730(p, f, b, g, d, a, n, x, e): rubi.append(2730) return Dist(S(1)/a, Int((d*sin(e + f*x))**n*(g*cos(e + f*x))**p, x), x) - Dist(b/(a*d), Int((d*sin(e + f*x))**(n + S(1))*(g*cos(e + f*x))**p/(a + b*sin(e + f*x)), x), x) rule2730 = ReplacementRule(pattern2730, replacement2730) pattern2731 = Pattern(Integral((WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(WC('g', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**p_/(a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons27, cons48, cons125, cons208, cons1267, cons1401, cons1404, cons463) def replacement2731(p, f, b, g, d, a, n, x, e): rubi.append(2731) return Dist(S(1)/a, Int((d*cos(e + f*x))**n*(g*sin(e + f*x))**p, x), x) - Dist(b/(a*d), Int((d*cos(e + f*x))**(n + S(1))*(g*sin(e + f*x))**p/(a + b*cos(e + f*x)), x), x) rule2731 = ReplacementRule(pattern2731, replacement2731) pattern2732 = Pattern(Integral((WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(WC('g', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**p_*(a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_, x_), cons2, cons3, cons27, cons48, cons125, cons208, cons4, cons5, cons1267, cons17, cons1405) def replacement2732(p, m, f, b, g, d, a, n, x, e): rubi.append(2732) return Int(ExpandTrig((g*cos(e + f*x))**p, (d*sin(e + f*x))**n*(a + b*sin(e + f*x))**m, x), x) rule2732 = ReplacementRule(pattern2732, replacement2732) pattern2733 = Pattern(Integral((WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(WC('g', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**p_*(a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_, x_), cons2, cons3, cons27, cons48, cons125, cons208, cons4, cons5, cons1267, cons17, cons1405) def replacement2733(p, m, f, b, g, d, a, n, x, e): rubi.append(2733) return Int(ExpandTrig((g*sin(e + f*x))**p, (d*cos(e + f*x))**n*(a + b*cos(e + f*x))**m, x), x) rule2733 = ReplacementRule(pattern2733, replacement2733) pattern2734 = Pattern(Integral((WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(WC('g', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**p_*(a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_, x_), cons2, cons3, cons27, cons48, cons125, cons208, cons1267, cons1406, cons267, cons146, cons1407) def replacement2734(p, m, f, b, g, d, a, n, x, e): rubi.append(2734) return Dist(g**S(2)/a, Int((d*sin(e + f*x))**n*(g*cos(e + f*x))**(p + S(-2))*(a + b*sin(e + f*x))**(m + S(1)), x), x) - Dist(b*g**S(2)/(a**S(2)*d), Int((d*sin(e + f*x))**(n + S(1))*(g*cos(e + f*x))**(p + S(-2))*(a + b*sin(e + f*x))**(m + S(1)), x), x) - Dist(g**S(2)*(a**S(2) - b**S(2))/(a**S(2)*d**S(2)), Int((d*sin(e + f*x))**(n + S(2))*(g*cos(e + f*x))**(p + S(-2))*(a + b*sin(e + f*x))**m, x), x) rule2734 = ReplacementRule(pattern2734, replacement2734) pattern2735 = Pattern(Integral((WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(WC('g', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**p_*(a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_, x_), cons2, cons3, cons27, cons48, cons125, cons208, cons1267, cons1406, cons267, cons146, cons1407) def replacement2735(p, m, f, b, g, d, a, n, x, e): rubi.append(2735) return Dist(g**S(2)/a, Int((d*cos(e + f*x))**n*(g*sin(e + f*x))**(p + S(-2))*(a + b*cos(e + f*x))**(m + S(1)), x), x) - Dist(b*g**S(2)/(a**S(2)*d), Int((d*cos(e + f*x))**(n + S(1))*(g*sin(e + f*x))**(p + S(-2))*(a + b*cos(e + f*x))**(m + S(1)), x), x) - Dist(g**S(2)*(a**S(2) - b**S(2))/(a**S(2)*d**S(2)), Int((d*cos(e + f*x))**(n + S(2))*(g*sin(e + f*x))**(p + S(-2))*(a + b*cos(e + f*x))**m, x), x) rule2735 = ReplacementRule(pattern2735, replacement2735) pattern2736 = Pattern(Integral((a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(c_ + WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_*cos(x_*WC('f', S(1)) + WC('e', S(0)))**p_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons4, cons1265, cons1299, cons1380) def replacement2736(p, m, f, b, d, a, c, n, x, e): rubi.append(2736) return Dist(a**(S(2)*m), Int((a - b*sin(e + f*x))**(-m)*(c + d*sin(e + f*x))**n, x), x) rule2736 = ReplacementRule(pattern2736, replacement2736) pattern2737 = Pattern(Integral((a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(c_ + WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_*sin(x_*WC('f', S(1)) + WC('e', S(0)))**p_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons4, cons1265, cons1299, cons1380) def replacement2737(p, m, f, b, d, a, c, n, x, e): rubi.append(2737) return Dist(a**(S(2)*m), Int((a - b*cos(e + f*x))**(-m)*(c + d*cos(e + f*x))**n, x), x) rule2737 = ReplacementRule(pattern2737, replacement2737) pattern2738 = Pattern(Integral((WC('g', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**p_*(a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(c_ + WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons4, cons1265, cons17, cons13, cons1384) def replacement2738(p, m, f, b, g, d, a, c, n, x, e): rubi.append(2738) return Dist((a/g)**(S(2)*m), Int((g*cos(e + f*x))**(S(2)*m + p)*(a - b*sin(e + f*x))**(-m)*(c + d*sin(e + f*x))**n, x), x) rule2738 = ReplacementRule(pattern2738, replacement2738) pattern2739 = Pattern(Integral((WC('g', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**p_*(a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(c_ + WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons4, cons1265, cons17, cons13, cons1384) def replacement2739(p, m, f, b, g, d, a, c, n, x, e): rubi.append(2739) return Dist((a/g)**(S(2)*m), Int((g*sin(e + f*x))**(S(2)*m + p)*(a - b*cos(e + f*x))**(-m)*(c + d*cos(e + f*x))**n, x), x) rule2739 = ReplacementRule(pattern2739, replacement2739) pattern2740 = Pattern(Integral((a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(c_ + WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_*cos(x_*WC('f', S(1)) + WC('e', S(0)))**S(2), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons4, cons1265, cons1170) def replacement2740(m, f, b, d, a, c, n, x, e): rubi.append(2740) return Dist(b**(S(-2)), Int((a - b*sin(e + f*x))*(a + b*sin(e + f*x))**(m + S(1))*(c + d*sin(e + f*x))**n, x), x) rule2740 = ReplacementRule(pattern2740, replacement2740) pattern2741 = Pattern(Integral((a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(c_ + WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_*sin(x_*WC('f', S(1)) + WC('e', S(0)))**S(2), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons4, cons1265, cons1170) def replacement2741(m, f, b, d, a, c, n, x, e): rubi.append(2741) return Dist(b**(S(-2)), Int((a - b*cos(e + f*x))*(a + b*cos(e + f*x))**(m + S(1))*(c + d*cos(e + f*x))**n, x), x) rule2741 = ReplacementRule(pattern2741, replacement2741) pattern2742 = Pattern(Integral((a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(c_ + WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_*cos(x_*WC('f', S(1)) + WC('e', S(0)))**p_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons4, cons1265, cons1306, cons17) def replacement2742(p, m, f, b, d, a, c, n, x, e): rubi.append(2742) return Dist(a**m*cos(e + f*x)/(f*sqrt(-sin(e + f*x) + S(1))*sqrt(sin(e + f*x) + S(1))), Subst(Int((S(1) - b*x/a)**(p/S(2) + S(-1)/2)*(S(1) + b*x/a)**(m + p/S(2) + S(-1)/2)*(c + d*x)**n, x), x, sin(e + f*x)), x) rule2742 = ReplacementRule(pattern2742, replacement2742) pattern2743 = Pattern(Integral((a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(c_ + WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_*sin(x_*WC('f', S(1)) + WC('e', S(0)))**p_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons4, cons1265, cons1306, cons17) def replacement2743(p, m, f, b, d, a, c, n, x, e): rubi.append(2743) return -Dist(a**m*sin(e + f*x)/(f*sqrt(-cos(e + f*x) + S(1))*sqrt(cos(e + f*x) + S(1))), Subst(Int((S(1) - b*x/a)**(p/S(2) + S(-1)/2)*(S(1) + b*x/a)**(m + p/S(2) + S(-1)/2)*(c + d*x)**n, x), x, cos(e + f*x)), x) rule2743 = ReplacementRule(pattern2743, replacement2743) pattern2744 = Pattern(Integral((a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(c_ + WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_*cos(x_*WC('f', S(1)) + WC('e', S(0)))**p_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons4, cons1265, cons1306, cons18) def replacement2744(p, m, f, b, d, a, c, n, x, e): rubi.append(2744) return Dist(a**(-p + S(2))*cos(e + f*x)/(f*sqrt(a - b*sin(e + f*x))*sqrt(a + b*sin(e + f*x))), Subst(Int((a - b*x)**(p/S(2) + S(-1)/2)*(a + b*x)**(m + p/S(2) + S(-1)/2)*(c + d*x)**n, x), x, sin(e + f*x)), x) rule2744 = ReplacementRule(pattern2744, replacement2744) pattern2745 = Pattern(Integral((a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(c_ + WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_*sin(x_*WC('f', S(1)) + WC('e', S(0)))**p_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons4, cons1265, cons1306, cons18) def replacement2745(p, m, f, b, d, a, c, n, x, e): rubi.append(2745) return -Dist(a**(-p + S(2))*sin(e + f*x)/(f*sqrt(a - b*cos(e + f*x))*sqrt(a + b*cos(e + f*x))), Subst(Int((a - b*x)**(p/S(2) + S(-1)/2)*(a + b*x)**(m + p/S(2) + S(-1)/2)*(c + d*x)**n, x), x, cos(e + f*x)), x) rule2745 = ReplacementRule(pattern2745, replacement2745) pattern2746 = Pattern(Integral((WC('g', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**p_*(a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(c_ + WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons4, cons5, cons1265, cons62, cons1387) def replacement2746(p, m, f, b, g, d, a, c, n, x, e): rubi.append(2746) return Int(ExpandTrig((g*cos(e + f*x))**p, (a + b*sin(e + f*x))**m*(c + d*sin(e + f*x))**n, x), x) rule2746 = ReplacementRule(pattern2746, replacement2746) pattern2747 = Pattern(Integral((WC('g', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**p_*(a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(c_ + WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons4, cons5, cons1265, cons62, cons1387) def replacement2747(p, m, f, b, g, d, a, c, n, x, e): rubi.append(2747) return Int(ExpandTrig((g*sin(e + f*x))**p, (a + b*cos(e + f*x))**m*(c + d*cos(e + f*x))**n, x), x) rule2747 = ReplacementRule(pattern2747, replacement2747) pattern2748 = Pattern(Integral((WC('g', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**p_*(a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(c_ + WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons4, cons5, cons1265, cons17) def replacement2748(p, m, f, b, g, d, a, c, n, x, e): rubi.append(2748) return Dist(a**m*g*(g*cos(e + f*x))**(p + S(-1))*(-sin(e + f*x) + S(1))**(-p/S(2) + S(1)/2)*(sin(e + f*x) + S(1))**(-p/S(2) + S(1)/2)/f, Subst(Int((S(1) - b*x/a)**(p/S(2) + S(-1)/2)*(S(1) + b*x/a)**(m + p/S(2) + S(-1)/2)*(c + d*x)**n, x), x, sin(e + f*x)), x) rule2748 = ReplacementRule(pattern2748, replacement2748) pattern2749 = Pattern(Integral((WC('g', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**p_*(a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(c_ + WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons4, cons5, cons1265, cons17) def replacement2749(p, m, f, b, g, d, a, c, n, x, e): rubi.append(2749) return -Dist(a**m*g*(g*sin(e + f*x))**(p + S(-1))*(-cos(e + f*x) + S(1))**(-p/S(2) + S(1)/2)*(cos(e + f*x) + S(1))**(-p/S(2) + S(1)/2)/f, Subst(Int((S(1) - b*x/a)**(p/S(2) + S(-1)/2)*(S(1) + b*x/a)**(m + p/S(2) + S(-1)/2)*(c + d*x)**n, x), x, cos(e + f*x)), x) rule2749 = ReplacementRule(pattern2749, replacement2749) pattern2750 = Pattern(Integral((WC('g', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**p_*(a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(c_ + WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons4, cons5, cons1265, cons18) def replacement2750(p, m, f, b, g, d, a, c, n, x, e): rubi.append(2750) return Dist(g*(g*cos(e + f*x))**(p + S(-1))*(a - b*sin(e + f*x))**(-p/S(2) + S(1)/2)*(a + b*sin(e + f*x))**(-p/S(2) + S(1)/2)/f, Subst(Int((a - b*x)**(p/S(2) + S(-1)/2)*(a + b*x)**(m + p/S(2) + S(-1)/2)*(c + d*x)**n, x), x, sin(e + f*x)), x) rule2750 = ReplacementRule(pattern2750, replacement2750) pattern2751 = Pattern(Integral((WC('g', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**p_*(a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(c_ + WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons4, cons5, cons1265, cons18) def replacement2751(p, m, f, b, g, d, a, c, n, x, e): rubi.append(2751) return -Dist(g*(g*sin(e + f*x))**(p + S(-1))*(a - b*cos(e + f*x))**(-p/S(2) + S(1)/2)*(a + b*cos(e + f*x))**(-p/S(2) + S(1)/2)/f, Subst(Int((a - b*x)**(p/S(2) + S(-1)/2)*(a + b*x)**(m + p/S(2) + S(-1)/2)*(c + d*x)**n, x), x, cos(e + f*x)), x) rule2751 = ReplacementRule(pattern2751, replacement2751) pattern2752 = Pattern(Integral((a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(c_ + WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_*cos(x_*WC('f', S(1)) + WC('e', S(0)))**S(2), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons4, cons1267, cons1390) def replacement2752(m, f, b, d, a, c, n, x, e): rubi.append(2752) return Int((a + b*sin(e + f*x))**m*(c + d*sin(e + f*x))**n*(-sin(e + f*x)**S(2) + S(1)), x) rule2752 = ReplacementRule(pattern2752, replacement2752) pattern2753 = Pattern(Integral((a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(c_ + WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_*sin(x_*WC('f', S(1)) + WC('e', S(0)))**S(2), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons4, cons1267, cons1390) def replacement2753(m, f, b, d, a, c, n, x, e): rubi.append(2753) return Int((a + b*cos(e + f*x))**m*(c + d*cos(e + f*x))**n*(-cos(e + f*x)**S(2) + S(1)), x) rule2753 = ReplacementRule(pattern2753, replacement2753) pattern2754 = Pattern(Integral((a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(c_ + WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_*cos(x_*WC('f', S(1)) + WC('e', S(0)))**p_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons4, cons1267, cons1408, cons1390) def replacement2754(p, m, f, b, d, a, c, n, x, e): rubi.append(2754) return Int(ExpandTrig((a + b*sin(e + f*x))**m*(c + d*sin(e + f*x))**n*(-sin(e + f*x)**S(2) + S(1))**(p/S(2)), x), x) rule2754 = ReplacementRule(pattern2754, replacement2754) pattern2755 = Pattern(Integral((a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(c_ + WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_*sin(x_*WC('f', S(1)) + WC('e', S(0)))**p_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons4, cons1267, cons1408, cons1390) def replacement2755(p, m, f, b, d, a, c, n, x, e): rubi.append(2755) return Int(ExpandTrig((a + b*cos(e + f*x))**m*(c + d*cos(e + f*x))**n*(-cos(e + f*x)**S(2) + S(1))**(p/S(2)), x), x) rule2755 = ReplacementRule(pattern2755, replacement2755) pattern2756 = Pattern(Integral((WC('g', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**p_*(a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(c_ + WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons5, cons1267, cons1170) def replacement2756(p, m, f, b, g, d, a, c, n, x, e): rubi.append(2756) return Int(ExpandTrig((g*cos(e + f*x))**p*(a + b*sin(e + f*x))**m*(c + d*sin(e + f*x))**n, x), x) rule2756 = ReplacementRule(pattern2756, replacement2756) pattern2757 = Pattern(Integral((WC('g', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**p_*(a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(c_ + WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons5, cons1267, cons1170) def replacement2757(p, m, f, b, g, d, a, c, n, x, e): rubi.append(2757) return Int(ExpandTrig((g*sin(e + f*x))**p*(a + b*cos(e + f*x))**m*(c + d*cos(e + f*x))**n, x), x) rule2757 = ReplacementRule(pattern2757, replacement2757) pattern2758 = Pattern(Integral((WC('g', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**p_*(a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(WC('c', S(0)) + WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons21, cons4, cons5, cons1267) def replacement2758(p, m, f, b, g, d, c, n, a, x, e): rubi.append(2758) return Int((g*cos(e + f*x))**p*(a + b*sin(e + f*x))**m*(c + d*sin(e + f*x))**n, x) rule2758 = ReplacementRule(pattern2758, replacement2758) pattern2759 = Pattern(Integral((WC('g', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**p_*(a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(WC('c', S(0)) + WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons21, cons4, cons5, cons1267) def replacement2759(p, m, f, b, g, d, c, n, a, x, e): rubi.append(2759) return Int((g*sin(e + f*x))**p*(a + b*cos(e + f*x))**m*(c + d*cos(e + f*x))**n, x) rule2759 = ReplacementRule(pattern2759, replacement2759) pattern2760 = Pattern(Integral((WC('g', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**p_*(WC('a', S(0)) + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(WC('c', S(0)) + WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons21, cons4, cons5, cons147) def replacement2760(p, m, f, g, b, d, a, c, n, x, e): rubi.append(2760) return Dist(g**(S(2)*IntPart(p))*(g/cos(e + f*x))**FracPart(p)*(g*cos(e + f*x))**FracPart(p), Int((g*cos(e + f*x))**(-p)*(a + b*sin(e + f*x))**m*(c + d*sin(e + f*x))**n, x), x) rule2760 = ReplacementRule(pattern2760, replacement2760) pattern2761 = Pattern(Integral((WC('g', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**p_*(WC('a', S(0)) + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(WC('c', S(0)) + WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons21, cons4, cons5, cons147) def replacement2761(p, m, f, b, g, d, a, c, n, x, e): rubi.append(2761) return Dist(g**(S(2)*IntPart(p))*(g/sin(e + f*x))**FracPart(p)*(g*sin(e + f*x))**FracPart(p), Int((g*sin(e + f*x))**(-p)*(a + b*cos(e + f*x))**m*(c + d*cos(e + f*x))**n, x), x) rule2761 = ReplacementRule(pattern2761, replacement2761) pattern2762 = Pattern(Integral(sqrt(WC('g', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))*sqrt(a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))/(c_ + WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons71, cons1409) def replacement2762(f, g, b, d, a, c, x, e): rubi.append(2762) return Dist(g/d, Int(sqrt(a + b*sin(e + f*x))/sqrt(g*sin(e + f*x)), x), x) - Dist(c*g/d, Int(sqrt(a + b*sin(e + f*x))/(sqrt(g*sin(e + f*x))*(c + d*sin(e + f*x))), x), x) rule2762 = ReplacementRule(pattern2762, replacement2762) pattern2763 = Pattern(Integral(sqrt(WC('g', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))*sqrt(a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))/(c_ + WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons71, cons1409) def replacement2763(f, b, g, d, a, c, x, e): rubi.append(2763) return Dist(g/d, Int(sqrt(a + b*cos(e + f*x))/sqrt(g*cos(e + f*x)), x), x) - Dist(c*g/d, Int(sqrt(a + b*cos(e + f*x))/(sqrt(g*cos(e + f*x))*(c + d*cos(e + f*x))), x), x) rule2763 = ReplacementRule(pattern2763, replacement2763) pattern2764 = Pattern(Integral(sqrt(WC('g', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))*sqrt(a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))/(c_ + WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons71, cons1267, cons1323) def replacement2764(f, g, b, d, a, c, x, e): rubi.append(2764) return Dist(b/d, Int(sqrt(g*sin(e + f*x))/sqrt(a + b*sin(e + f*x)), x), x) - Dist((-a*d + b*c)/d, Int(sqrt(g*sin(e + f*x))/(sqrt(a + b*sin(e + f*x))*(c + d*sin(e + f*x))), x), x) rule2764 = ReplacementRule(pattern2764, replacement2764) pattern2765 = Pattern(Integral(sqrt(WC('g', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))*sqrt(a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))/(c_ + WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons71, cons1267, cons1323) def replacement2765(f, b, g, d, a, c, x, e): rubi.append(2765) return Dist(b/d, Int(sqrt(g*cos(e + f*x))/sqrt(a + b*cos(e + f*x)), x), x) - Dist((-a*d + b*c)/d, Int(sqrt(g*cos(e + f*x))/(sqrt(a + b*cos(e + f*x))*(c + d*cos(e + f*x))), x), x) rule2765 = ReplacementRule(pattern2765, replacement2765) pattern2766 = Pattern(Integral(sqrt(a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))/(sqrt(WC('g', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))*(c_ + WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons71, cons1265) def replacement2766(f, g, b, d, a, c, x, e): rubi.append(2766) return Dist(-S(2)*b/f, Subst(Int(S(1)/(a*d + b*c + c*g*x**S(2)), x), x, b*cos(e + f*x)/(sqrt(g*sin(e + f*x))*sqrt(a + b*sin(e + f*x)))), x) rule2766 = ReplacementRule(pattern2766, replacement2766) pattern2767 = Pattern(Integral(sqrt(a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))/(sqrt(WC('g', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))*(c_ + WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons71, cons1265) def replacement2767(f, b, g, d, a, c, x, e): rubi.append(2767) return Dist(S(2)*b/f, Subst(Int(S(1)/(a*d + b*c + c*g*x**S(2)), x), x, b*sin(e + f*x)/(sqrt(g*cos(e + f*x))*sqrt(a + b*cos(e + f*x)))), x) rule2767 = ReplacementRule(pattern2767, replacement2767) pattern2768 = Pattern(Integral(sqrt(a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))/((c_ + WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))*sqrt(sin(x_*WC('f', S(1)) + WC('e', S(0))))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons1410, cons1411, cons105) def replacement2768(f, b, d, a, c, x, e): rubi.append(2768) return -Simp(sqrt(a + b)*EllipticE(asin(cos(e + f*x)/(sin(e + f*x) + S(1))), -(a - b)/(a + b))/(c*f), x) rule2768 = ReplacementRule(pattern2768, replacement2768) pattern2769 = Pattern(Integral(sqrt(a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))/((c_ + WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))*sqrt(cos(x_*WC('f', S(1)) + WC('e', S(0))))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons1410, cons1411, cons105) def replacement2769(f, b, d, a, c, x, e): rubi.append(2769) return Simp(sqrt(a + b)*EllipticE(asin(sin(e + f*x)/(cos(e + f*x) + S(1))), -(a - b)/(a + b))/(c*f), x) rule2769 = ReplacementRule(pattern2769, replacement2769) pattern2770 = Pattern(Integral(sqrt(a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))/(sqrt(WC('g', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))*(c_ + WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons71, cons1267, cons1322) def replacement2770(f, g, b, d, a, c, x, e): rubi.append(2770) return -Simp(sqrt(d*sin(e + f*x)/(c + d*sin(e + f*x)))*sqrt(a + b*sin(e + f*x))*EllipticE(asin(c*cos(e + f*x)/(c + d*sin(e + f*x))), (-a*d + b*c)/(a*d + b*c))/(d*f*sqrt(g*sin(e + f*x))*sqrt(c**S(2)*(a + b*sin(e + f*x))/((c + d*sin(e + f*x))*(a*c + b*d)))), x) rule2770 = ReplacementRule(pattern2770, replacement2770) pattern2771 = Pattern(Integral(sqrt(a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))/(sqrt(WC('g', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))*(c_ + WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons71, cons1267, cons1322) def replacement2771(f, b, g, d, a, c, x, e): rubi.append(2771) return Simp(sqrt(d*cos(e + f*x)/(c + d*cos(e + f*x)))*sqrt(a + b*cos(e + f*x))*EllipticE(asin(c*sin(e + f*x)/(c + d*cos(e + f*x))), (-a*d + b*c)/(a*d + b*c))/(d*f*sqrt(g*cos(e + f*x))*sqrt(c**S(2)*(a + b*cos(e + f*x))/((c + d*cos(e + f*x))*(a*c + b*d)))), x) rule2771 = ReplacementRule(pattern2771, replacement2771) pattern2772 = Pattern(Integral(sqrt(a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))/(sqrt(WC('g', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))*(c_ + WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons71, cons1267, cons1323) def replacement2772(f, g, b, d, a, c, x, e): rubi.append(2772) return Dist(a/c, Int(S(1)/(sqrt(g*sin(e + f*x))*sqrt(a + b*sin(e + f*x))), x), x) + Dist((-a*d + b*c)/(c*g), Int(sqrt(g*sin(e + f*x))/(sqrt(a + b*sin(e + f*x))*(c + d*sin(e + f*x))), x), x) rule2772 = ReplacementRule(pattern2772, replacement2772) pattern2773 = Pattern(Integral(sqrt(a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))/(sqrt(WC('g', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))*(c_ + WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons71, cons1267, cons1323) def replacement2773(f, b, g, d, a, c, x, e): rubi.append(2773) return Dist(a/c, Int(S(1)/(sqrt(g*cos(e + f*x))*sqrt(a + b*cos(e + f*x))), x), x) + Dist((-a*d + b*c)/(c*g), Int(sqrt(g*cos(e + f*x))/(sqrt(a + b*cos(e + f*x))*(c + d*cos(e + f*x))), x), x) rule2773 = ReplacementRule(pattern2773, replacement2773) pattern2774 = Pattern(Integral(sqrt(a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))/((c_ + WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))*sin(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1265) def replacement2774(f, b, d, a, c, x, e): rubi.append(2774) return Dist(S(1)/c, Int(sqrt(a + b*sin(e + f*x))/sin(e + f*x), x), x) - Dist(d/c, Int(sqrt(a + b*sin(e + f*x))/(c + d*sin(e + f*x)), x), x) rule2774 = ReplacementRule(pattern2774, replacement2774) pattern2775 = Pattern(Integral(sqrt(a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))/((c_ + WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))*cos(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1265) def replacement2775(f, b, d, a, c, x, e): rubi.append(2775) return Dist(S(1)/c, Int(sqrt(a + b*cos(e + f*x))/cos(e + f*x), x), x) - Dist(d/c, Int(sqrt(a + b*cos(e + f*x))/(c + d*cos(e + f*x)), x), x) rule2775 = ReplacementRule(pattern2775, replacement2775) pattern2776 = Pattern(Integral(sqrt(a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))/((c_ + WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))*sin(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1267) def replacement2776(f, b, d, a, c, x, e): rubi.append(2776) return Dist(a/c, Int(S(1)/(sqrt(a + b*sin(e + f*x))*sin(e + f*x)), x), x) + Dist((-a*d + b*c)/c, Int(S(1)/(sqrt(a + b*sin(e + f*x))*(c + d*sin(e + f*x))), x), x) rule2776 = ReplacementRule(pattern2776, replacement2776) pattern2777 = Pattern(Integral(sqrt(a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))/((c_ + WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))*cos(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1267) def replacement2777(f, b, d, a, c, x, e): rubi.append(2777) return Dist(a/c, Int(S(1)/(sqrt(a + b*cos(e + f*x))*cos(e + f*x)), x), x) + Dist((-a*d + b*c)/c, Int(S(1)/(sqrt(a + b*cos(e + f*x))*(c + d*cos(e + f*x))), x), x) rule2777 = ReplacementRule(pattern2777, replacement2777) pattern2778 = Pattern(Integral(sqrt(WC('g', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))/(sqrt(a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))*(c_ + WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons71, cons1409) def replacement2778(f, g, b, d, a, c, x, e): rubi.append(2778) return -Dist(a*g/(-a*d + b*c), Int(S(1)/(sqrt(g*sin(e + f*x))*sqrt(a + b*sin(e + f*x))), x), x) + Dist(c*g/(-a*d + b*c), Int(sqrt(a + b*sin(e + f*x))/(sqrt(g*sin(e + f*x))*(c + d*sin(e + f*x))), x), x) rule2778 = ReplacementRule(pattern2778, replacement2778) pattern2779 = Pattern(Integral(sqrt(WC('g', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))/(sqrt(a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))*(c_ + WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons71, cons1409) def replacement2779(f, b, g, d, a, c, x, e): rubi.append(2779) return -Dist(a*g/(-a*d + b*c), Int(S(1)/(sqrt(g*cos(e + f*x))*sqrt(a + b*cos(e + f*x))), x), x) + Dist(c*g/(-a*d + b*c), Int(sqrt(a + b*cos(e + f*x))/(sqrt(g*cos(e + f*x))*(c + d*cos(e + f*x))), x), x) rule2779 = ReplacementRule(pattern2779, replacement2779) pattern2780 = Pattern(Integral(sqrt(WC('g', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))/(sqrt(a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))*(c_ + WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons71, cons1267, cons1323) def replacement2780(f, g, b, d, a, c, x, e): rubi.append(2780) return Simp(S(2)*sqrt(-S(1)/tan(e + f*x)**S(2))*sqrt(g*sin(e + f*x))*sqrt((a/sin(e + f*x) + b)/(a + b))*EllipticPi(S(2)*c/(c + d), asin(sqrt(S(2))*sqrt(S(1) - S(1)/sin(e + f*x))/S(2)), S(2)*a/(a + b))*tan(e + f*x)/(f*sqrt(a + b*sin(e + f*x))*(c + d)), x) rule2780 = ReplacementRule(pattern2780, replacement2780) pattern2781 = Pattern(Integral(sqrt(WC('g', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))/(sqrt(a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))*(c_ + WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons71, cons1267, cons1323) def replacement2781(f, b, g, d, a, c, x, e): rubi.append(2781) return Simp(-S(2)*sqrt(-tan(e + f*x)**S(2))*sqrt(g*cos(e + f*x))*sqrt((a/cos(e + f*x) + b)/(a + b))*EllipticPi(S(2)*c/(c + d), asin(sqrt(S(2))*sqrt(S(1) - S(1)/cos(e + f*x))/S(2)), S(2)*a/(a + b))/(f*sqrt(a + b*cos(e + f*x))*(c + d)*tan(e + f*x)), x) rule2781 = ReplacementRule(pattern2781, replacement2781) pattern2782 = Pattern(Integral(S(1)/(sqrt(WC('g', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))*sqrt(a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))*(c_ + WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons71, cons1409) def replacement2782(f, g, b, d, a, c, x, e): rubi.append(2782) return Dist(b/(-a*d + b*c), Int(S(1)/(sqrt(g*sin(e + f*x))*sqrt(a + b*sin(e + f*x))), x), x) - Dist(d/(-a*d + b*c), Int(sqrt(a + b*sin(e + f*x))/(sqrt(g*sin(e + f*x))*(c + d*sin(e + f*x))), x), x) rule2782 = ReplacementRule(pattern2782, replacement2782) pattern2783 = Pattern(Integral(S(1)/(sqrt(WC('g', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))*sqrt(a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))*(c_ + WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons71, cons1409) def replacement2783(f, b, g, d, a, c, x, e): rubi.append(2783) return Dist(b/(-a*d + b*c), Int(S(1)/(sqrt(g*cos(e + f*x))*sqrt(a + b*cos(e + f*x))), x), x) - Dist(d/(-a*d + b*c), Int(sqrt(a + b*cos(e + f*x))/(sqrt(g*cos(e + f*x))*(c + d*cos(e + f*x))), x), x) rule2783 = ReplacementRule(pattern2783, replacement2783) pattern2784 = Pattern(Integral(S(1)/(sqrt(WC('g', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))*sqrt(a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))*(c_ + WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons71, cons1267, cons1323) def replacement2784(f, g, b, d, a, c, x, e): rubi.append(2784) return Dist(S(1)/c, Int(S(1)/(sqrt(g*sin(e + f*x))*sqrt(a + b*sin(e + f*x))), x), x) - Dist(d/(c*g), Int(sqrt(g*sin(e + f*x))/(sqrt(a + b*sin(e + f*x))*(c + d*sin(e + f*x))), x), x) rule2784 = ReplacementRule(pattern2784, replacement2784) pattern2785 = Pattern(Integral(S(1)/(sqrt(WC('g', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))*sqrt(a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))*(c_ + WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons71, cons1267, cons1323) def replacement2785(f, b, g, d, a, c, x, e): rubi.append(2785) return Dist(S(1)/c, Int(S(1)/(sqrt(g*cos(e + f*x))*sqrt(a + b*cos(e + f*x))), x), x) - Dist(d/(c*g), Int(sqrt(g*cos(e + f*x))/(sqrt(a + b*cos(e + f*x))*(c + d*cos(e + f*x))), x), x) rule2785 = ReplacementRule(pattern2785, replacement2785) pattern2786 = Pattern(Integral(S(1)/(sqrt(a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))*(c_ + WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))*sin(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1265) def replacement2786(f, b, d, a, c, x, e): rubi.append(2786) return Dist(S(1)/(c*(-a*d + b*c)), Int((-a*d + b*c - b*d*sin(e + f*x))/(sqrt(a + b*sin(e + f*x))*sin(e + f*x)), x), x) + Dist(d**S(2)/(c*(-a*d + b*c)), Int(sqrt(a + b*sin(e + f*x))/(c + d*sin(e + f*x)), x), x) rule2786 = ReplacementRule(pattern2786, replacement2786) pattern2787 = Pattern(Integral(S(1)/(sqrt(a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))*(c_ + WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))*cos(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1265) def replacement2787(f, b, d, a, c, x, e): rubi.append(2787) return Dist(S(1)/(c*(-a*d + b*c)), Int((-a*d + b*c - b*d*cos(e + f*x))/(sqrt(a + b*cos(e + f*x))*cos(e + f*x)), x), x) + Dist(d**S(2)/(c*(-a*d + b*c)), Int(sqrt(a + b*cos(e + f*x))/(c + d*cos(e + f*x)), x), x) rule2787 = ReplacementRule(pattern2787, replacement2787) pattern2788 = Pattern(Integral(S(1)/(sqrt(a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))*(c_ + WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))*sin(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1267) def replacement2788(f, b, d, a, c, x, e): rubi.append(2788) return Dist(S(1)/c, Int(S(1)/(sqrt(a + b*sin(e + f*x))*sin(e + f*x)), x), x) - Dist(d/c, Int(S(1)/(sqrt(a + b*sin(e + f*x))*(c + d*sin(e + f*x))), x), x) rule2788 = ReplacementRule(pattern2788, replacement2788) pattern2789 = Pattern(Integral(S(1)/(sqrt(a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))*(c_ + WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))*cos(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1267) def replacement2789(f, b, d, a, c, x, e): rubi.append(2789) return Dist(S(1)/c, Int(S(1)/(sqrt(a + b*cos(e + f*x))*cos(e + f*x)), x), x) - Dist(d/c, Int(S(1)/(sqrt(a + b*cos(e + f*x))*(c + d*cos(e + f*x))), x), x) rule2789 = ReplacementRule(pattern2789, replacement2789) pattern2790 = Pattern(Integral(sqrt(a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))/(sqrt(c_ + WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))*sin(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1265, cons70) def replacement2790(f, b, d, a, c, x, e): rubi.append(2790) return Dist(S(1)/c, Int(sqrt(a + b*sin(e + f*x))*sqrt(c + d*sin(e + f*x))/sin(e + f*x), x), x) - Dist(d/c, Int(sqrt(a + b*sin(e + f*x))/sqrt(c + d*sin(e + f*x)), x), x) rule2790 = ReplacementRule(pattern2790, replacement2790) pattern2791 = Pattern(Integral(sqrt(a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))/(sqrt(c_ + WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))*cos(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1265, cons70) def replacement2791(f, b, d, a, c, x, e): rubi.append(2791) return Dist(S(1)/c, Int(sqrt(a + b*cos(e + f*x))*sqrt(c + d*cos(e + f*x))/cos(e + f*x), x), x) - Dist(d/c, Int(sqrt(a + b*cos(e + f*x))/sqrt(c + d*cos(e + f*x)), x), x) rule2791 = ReplacementRule(pattern2791, replacement2791) pattern2792 = Pattern(Integral(sqrt(a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))/(sqrt(c_ + WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))*sin(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1265, cons1412) def replacement2792(f, b, d, a, c, x, e): rubi.append(2792) return Dist(-S(2)*a/f, Subst(Int(S(1)/(-a*c*x**S(2) + S(1)), x), x, cos(e + f*x)/(sqrt(a + b*sin(e + f*x))*sqrt(c + d*sin(e + f*x)))), x) rule2792 = ReplacementRule(pattern2792, replacement2792) pattern2793 = Pattern(Integral(sqrt(a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))/(sqrt(c_ + WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))*cos(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1265, cons1412) def replacement2793(f, b, d, a, c, x, e): rubi.append(2793) return Dist(S(2)*a/f, Subst(Int(S(1)/(-a*c*x**S(2) + S(1)), x), x, sin(e + f*x)/(sqrt(a + b*cos(e + f*x))*sqrt(c + d*cos(e + f*x)))), x) rule2793 = ReplacementRule(pattern2793, replacement2793) pattern2794 = Pattern(Integral(sqrt(a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))/(sqrt(c_ + WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))*sin(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1267, cons1322) def replacement2794(f, b, d, a, c, x, e): rubi.append(2794) return Dist(a/c, Int(sqrt(c + d*sin(e + f*x))/(sqrt(a + b*sin(e + f*x))*sin(e + f*x)), x), x) + Dist((-a*d + b*c)/c, Int(S(1)/(sqrt(a + b*sin(e + f*x))*sqrt(c + d*sin(e + f*x))), x), x) rule2794 = ReplacementRule(pattern2794, replacement2794) pattern2795 = Pattern(Integral(sqrt(a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))/(sqrt(c_ + WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))*cos(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1267, cons1322) def replacement2795(f, b, d, a, c, x, e): rubi.append(2795) return Dist(a/c, Int(sqrt(c + d*cos(e + f*x))/(sqrt(a + b*cos(e + f*x))*cos(e + f*x)), x), x) + Dist((-a*d + b*c)/c, Int(S(1)/(sqrt(a + b*cos(e + f*x))*sqrt(c + d*cos(e + f*x))), x), x) rule2795 = ReplacementRule(pattern2795, replacement2795) pattern2796 = Pattern(Integral(sqrt(a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))/(sqrt(c_ + WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))*sin(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1267, cons1323) def replacement2796(f, b, d, a, c, x, e): rubi.append(2796) return Simp(-S(2)*sqrt((-a*d + b*c)*(sin(e + f*x) + S(1))/((a + b*sin(e + f*x))*(c - d)))*sqrt(-(-a*d + b*c)*(-sin(e + f*x) + S(1))/((a + b*sin(e + f*x))*(c + d)))*(a + b*sin(e + f*x))*EllipticPi(a*(c + d)/(c*(a + b)), asin(sqrt(c + d*sin(e + f*x))*Rt((a + b)/(c + d), S(2))/sqrt(a + b*sin(e + f*x))), (a - b)*(c + d)/((a + b)*(c - d)))/(c*f*Rt((a + b)/(c + d), S(2))*cos(e + f*x)), x) rule2796 = ReplacementRule(pattern2796, replacement2796) pattern2797 = Pattern(Integral(sqrt(a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))/(sqrt(c_ + WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))*cos(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1267, cons1323) def replacement2797(f, b, d, a, c, x, e): rubi.append(2797) return Simp(S(2)*sqrt((-a*d + b*c)*(cos(e + f*x) + S(1))/((a + b*cos(e + f*x))*(c - d)))*sqrt(-(-a*d + b*c)*(-cos(e + f*x) + S(1))/((a + b*cos(e + f*x))*(c + d)))*(a + b*cos(e + f*x))*EllipticPi(a*(c + d)/(c*(a + b)), asin(sqrt(c + d*cos(e + f*x))*Rt((a + b)/(c + d), S(2))/sqrt(a + b*cos(e + f*x))), (a - b)*(c + d)/((a + b)*(c - d)))/(c*f*Rt((a + b)/(c + d), S(2))*sin(e + f*x)), x) rule2797 = ReplacementRule(pattern2797, replacement2797) pattern2798 = Pattern(Integral(S(1)/(sqrt(a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))*sqrt(c_ + WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))*sin(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1265, cons1322) def replacement2798(f, b, d, a, c, x, e): rubi.append(2798) return Dist(cos(e + f*x)/(sqrt(a + b*sin(e + f*x))*sqrt(c + d*sin(e + f*x))), Int(S(1)/(sin(e + f*x)*cos(e + f*x)), x), x) rule2798 = ReplacementRule(pattern2798, replacement2798) pattern2799 = Pattern(Integral(S(1)/(sqrt(a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))*sqrt(c_ + WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))*cos(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1265, cons1322) def replacement2799(f, b, d, a, c, x, e): rubi.append(2799) return Dist(sin(e + f*x)/(sqrt(a + b*cos(e + f*x))*sqrt(c + d*cos(e + f*x))), Int(S(1)/(sin(e + f*x)*cos(e + f*x)), x), x) rule2799 = ReplacementRule(pattern2799, replacement2799) pattern2800 = Pattern(Integral(S(1)/(sqrt(a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))*sqrt(c_ + WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))*sin(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1413) def replacement2800(f, b, d, a, c, x, e): rubi.append(2800) return Dist(S(1)/a, Int(sqrt(a + b*sin(e + f*x))/(sqrt(c + d*sin(e + f*x))*sin(e + f*x)), x), x) - Dist(b/a, Int(S(1)/(sqrt(a + b*sin(e + f*x))*sqrt(c + d*sin(e + f*x))), x), x) rule2800 = ReplacementRule(pattern2800, replacement2800) pattern2801 = Pattern(Integral(S(1)/(sqrt(a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))*sqrt(c_ + WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))*cos(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1413) def replacement2801(f, b, d, a, c, x, e): rubi.append(2801) return Dist(S(1)/a, Int(sqrt(a + b*cos(e + f*x))/(sqrt(c + d*cos(e + f*x))*cos(e + f*x)), x), x) - Dist(b/a, Int(S(1)/(sqrt(a + b*cos(e + f*x))*sqrt(c + d*cos(e + f*x))), x), x) rule2801 = ReplacementRule(pattern2801, replacement2801) pattern2802 = Pattern(Integral(sqrt(a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))*sqrt(c_ + WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))/sin(x_*WC('f', S(1)) + WC('e', S(0))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1265, cons1322) def replacement2802(f, b, d, a, c, x, e): rubi.append(2802) return Dist(sqrt(a + b*sin(e + f*x))*sqrt(c + d*sin(e + f*x))/cos(e + f*x), Int(S(1)/tan(e + f*x), x), x) rule2802 = ReplacementRule(pattern2802, replacement2802) pattern2803 = Pattern(Integral(sqrt(a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))*sqrt(c_ + WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))/cos(x_*WC('f', S(1)) + WC('e', S(0))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1265, cons1322) def replacement2803(f, b, d, a, c, x, e): rubi.append(2803) return Dist(sqrt(a + b*cos(e + f*x))*sqrt(c + d*cos(e + f*x))/sin(e + f*x), Int(tan(e + f*x), x), x) rule2803 = ReplacementRule(pattern2803, replacement2803) pattern2804 = Pattern(Integral(sqrt(a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))*sqrt(c_ + WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))/sin(x_*WC('f', S(1)) + WC('e', S(0))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1413) def replacement2804(f, b, d, a, c, x, e): rubi.append(2804) return Dist(c, Int(sqrt(a + b*sin(e + f*x))/(sqrt(c + d*sin(e + f*x))*sin(e + f*x)), x), x) + Dist(d, Int(sqrt(a + b*sin(e + f*x))/sqrt(c + d*sin(e + f*x)), x), x) rule2804 = ReplacementRule(pattern2804, replacement2804) pattern2805 = Pattern(Integral(sqrt(a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))*sqrt(c_ + WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))/cos(x_*WC('f', S(1)) + WC('e', S(0))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1413) def replacement2805(f, b, d, a, c, x, e): rubi.append(2805) return Dist(c, Int(sqrt(a + b*cos(e + f*x))/(sqrt(c + d*cos(e + f*x))*cos(e + f*x)), x), x) + Dist(d, Int(sqrt(a + b*cos(e + f*x))/sqrt(c + d*cos(e + f*x)), x), x) rule2805 = ReplacementRule(pattern2805, replacement2805) pattern2806 = Pattern(Integral((a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(c_ + WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0)))**p_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons70, cons1265, cons1414, cons85) def replacement2806(p, m, f, b, d, a, n, c, x, e): rubi.append(2806) return Dist(a**n*c**n, Int((a + b*sin(e + f*x))**(m - n)*tan(e + f*x)**p, x), x) rule2806 = ReplacementRule(pattern2806, replacement2806) pattern2807 = Pattern(Integral((a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(c_ + WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0)))**p_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons70, cons1265, cons1414, cons85) def replacement2807(p, m, f, b, d, a, n, c, x, e): rubi.append(2807) return Dist(a**n*c**n, Int((a + b*cos(e + f*x))**(m - n)*(S(1)/tan(e + f*x))**p, x), x) rule2807 = ReplacementRule(pattern2807, replacement2807) pattern2808 = Pattern(Integral((WC('g', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**p_*(a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(c_ + WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons21, cons4, cons5, cons71, cons1265, cons1323, cons1304) def replacement2808(p, m, f, g, b, d, a, c, n, x, e): rubi.append(2808) return Dist(sqrt(a - b*sin(e + f*x))*sqrt(a + b*sin(e + f*x))/(f*cos(e + f*x)), Subst(Int((g*x)**p*(a + b*x)**(m + S(-1)/2)*(c + d*x)**n/sqrt(a - b*x), x), x, sin(e + f*x)), x) rule2808 = ReplacementRule(pattern2808, replacement2808) pattern2809 = Pattern(Integral((WC('g', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**p_*(a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(c_ + WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons21, cons4, cons5, cons71, cons1265, cons1323, cons1304) def replacement2809(p, m, f, b, g, d, a, c, n, x, e): rubi.append(2809) return -Dist(sqrt(a - b*cos(e + f*x))*sqrt(a + b*cos(e + f*x))/(f*sin(e + f*x)), Subst(Int((g*x)**p*(a + b*x)**(m + S(-1)/2)*(c + d*x)**n/sqrt(a - b*x), x), x, cos(e + f*x)), x) rule2809 = ReplacementRule(pattern2809, replacement2809) pattern2810 = Pattern(Integral((WC('g', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**p_*(a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(c_ + WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons4, cons5, cons71, cons1415, cons1416) def replacement2810(p, m, f, g, b, d, a, c, n, x, e): rubi.append(2810) return Int(ExpandTrig((g*sin(e + f*x))**p*(a + b*sin(e + f*x))**m*(c + d*sin(e + f*x))**n, x), x) rule2810 = ReplacementRule(pattern2810, replacement2810) pattern2811 = Pattern(Integral((WC('g', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**p_*(a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(c_ + WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons4, cons5, cons71, cons1415, cons1416) def replacement2811(p, m, f, b, g, d, a, c, n, x, e): rubi.append(2811) return Int(ExpandTrig((g*cos(e + f*x))**p*(a + b*cos(e + f*x))**m*(c + d*cos(e + f*x))**n, x), x) rule2811 = ReplacementRule(pattern2811, replacement2811) pattern2812 = Pattern(Integral((WC('g', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**p_*(a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(c_ + WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons21, cons4, cons5, cons1416) def replacement2812(p, m, f, g, b, d, a, c, n, x, e): rubi.append(2812) return Int((g*sin(e + f*x))**p*(a + b*sin(e + f*x))**m*(c + d*sin(e + f*x))**n, x) rule2812 = ReplacementRule(pattern2812, replacement2812) pattern2813 = Pattern(Integral((WC('g', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**p_*(a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(c_ + WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons21, cons4, cons5, cons1416) def replacement2813(p, m, f, b, g, d, a, c, n, x, e): rubi.append(2813) return Int((g*cos(e + f*x))**p*(a + b*cos(e + f*x))**m*(c + d*cos(e + f*x))**n, x) rule2813 = ReplacementRule(pattern2813, replacement2813) pattern2814 = Pattern(Integral((WC('g', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('p', S(1))*(c_ + WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1))*(WC('a', S(0)) + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons5, cons71, cons147, cons17, cons85) def replacement2814(p, m, f, b, g, d, a, n, c, x, e): rubi.append(2814) return Dist(g**(m + n), Int((g*sin(e + f*x))**(-m - n + p)*(a*sin(e + f*x) + b)**m*(c*sin(e + f*x) + d)**n, x), x) rule2814 = ReplacementRule(pattern2814, replacement2814) pattern2815 = Pattern(Integral((WC('g', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('p', S(1))*(c_ + WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1))*(WC('a', S(0)) + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons5, cons71, cons147, cons17, cons85) def replacement2815(p, m, f, g, b, d, a, n, c, x, e): rubi.append(2815) return Dist(g**(m + n), Int((g*cos(e + f*x))**(-m - n + p)*(a*cos(e + f*x) + b)**m*(c*cos(e + f*x) + d)**n, x), x) rule2815 = ReplacementRule(pattern2815, replacement2815) pattern2816 = Pattern(Integral((WC('g', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('p', S(1))*(c_ + WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1))*(WC('a', S(0)) + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons21, cons4, cons5, cons71, cons147, cons1417) def replacement2816(p, m, f, b, g, d, a, n, c, x, e): rubi.append(2816) return Dist((g/sin(e + f*x))**p*(g*sin(e + f*x))**p, Int((g/sin(e + f*x))**(-p)*(a + b/sin(e + f*x))**m*(c + d/sin(e + f*x))**n, x), x) rule2816 = ReplacementRule(pattern2816, replacement2816) pattern2817 = Pattern(Integral((WC('g', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('p', S(1))*(c_ + WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1))*(WC('a', S(0)) + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons21, cons4, cons5, cons71, cons147, cons1417) def replacement2817(p, m, f, g, b, d, a, n, c, x, e): rubi.append(2817) return Dist((g/cos(e + f*x))**p*(g*cos(e + f*x))**p, Int((g/cos(e + f*x))**(-p)*(a + b/cos(e + f*x))**m*(c + d/cos(e + f*x))**n, x), x) rule2817 = ReplacementRule(pattern2817, replacement2817) pattern2818 = Pattern(Integral((WC('g', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('p', S(1))*(a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(c_ + WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons21, cons5, cons85) def replacement2818(p, m, g, f, b, d, c, n, a, x, e): rubi.append(2818) return Dist(g**n, Int((g*sin(e + f*x))**(-n + p)*(a + b*sin(e + f*x))**m*(c*sin(e + f*x) + d)**n, x), x) rule2818 = ReplacementRule(pattern2818, replacement2818) pattern2819 = Pattern(Integral((WC('g', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('p', S(1))*(a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(c_ + WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons21, cons5, cons85) def replacement2819(p, m, f, b, g, d, a, n, c, x, e): rubi.append(2819) return Dist(g**n, Int((g*cos(e + f*x))**(-n + p)*(a + b*cos(e + f*x))**m*(c*cos(e + f*x) + d)**n, x), x) rule2819 = ReplacementRule(pattern2819, replacement2819) pattern2820 = Pattern(Integral((a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(c_ + WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_*sin(x_*WC('f', S(1)) + WC('e', S(0)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons4, cons23, cons17, cons38) def replacement2820(p, m, f, b, d, c, n, a, x, e): rubi.append(2820) return Int((c + d/sin(e + f*x))**n*(a/sin(e + f*x) + b)**m*(S(1)/sin(e + f*x))**(-m - p), x) rule2820 = ReplacementRule(pattern2820, replacement2820) pattern2821 = Pattern(Integral((a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(c_ + WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_*cos(x_*WC('f', S(1)) + WC('e', S(0)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons4, cons23, cons17, cons38) def replacement2821(p, m, f, b, d, a, c, n, x, e): rubi.append(2821) return Int((c + d/cos(e + f*x))**n*(a/cos(e + f*x) + b)**m*(S(1)/cos(e + f*x))**(-m - p), x) rule2821 = ReplacementRule(pattern2821, replacement2821) pattern2822 = Pattern(Integral((WC('g', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**p_*(a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(c_ + WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons4, cons5, cons23, cons17, cons147) def replacement2822(p, m, f, b, g, d, c, n, a, x, e): rubi.append(2822) return Dist((g*sin(e + f*x))**p*(S(1)/sin(e + f*x))**p, Int((c + d/sin(e + f*x))**n*(a/sin(e + f*x) + b)**m*(S(1)/sin(e + f*x))**(-m - p), x), x) rule2822 = ReplacementRule(pattern2822, replacement2822) pattern2823 = Pattern(Integral((WC('g', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**p_*(a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(c_ + WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons4, cons5, cons23, cons17, cons147) def replacement2823(p, m, f, b, g, d, a, c, n, x, e): rubi.append(2823) return Dist((g*cos(e + f*x))**p*(S(1)/cos(e + f*x))**p, Int((c + d/cos(e + f*x))**n*(a/cos(e + f*x) + b)**m*(S(1)/cos(e + f*x))**(-m - p), x), x) rule2823 = ReplacementRule(pattern2823, replacement2823) pattern2824 = Pattern(Integral((WC('g', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('p', S(1))*(a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(c_ + WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons21, cons4, cons5, cons23, cons18) def replacement2824(p, m, f, g, b, d, c, n, a, x, e): rubi.append(2824) return Dist((g*sin(e + f*x))**n*(c + d/sin(e + f*x))**n*(c*sin(e + f*x) + d)**(-n), Int((g*sin(e + f*x))**(-n + p)*(a + b*sin(e + f*x))**m*(c*sin(e + f*x) + d)**n, x), x) rule2824 = ReplacementRule(pattern2824, replacement2824) pattern2825 = Pattern(Integral((WC('g', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('p', S(1))*(a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(c_ + WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons21, cons4, cons5, cons23, cons18) def replacement2825(p, m, f, b, g, d, a, c, n, x, e): rubi.append(2825) return Dist((g*cos(e + f*x))**n*(c + d/cos(e + f*x))**n*(c*cos(e + f*x) + d)**(-n), Int((g*cos(e + f*x))**(-n + p)*(a + b*cos(e + f*x))**m*(c*cos(e + f*x) + d)**n, x), x) rule2825 = ReplacementRule(pattern2825, replacement2825) pattern2826 = Pattern(Integral((WC('g', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('p', S(1))*(c_ + WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1))*(WC('a', S(0)) + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons5, cons71, cons147, cons17, cons85) def replacement2826(p, m, f, g, b, d, a, n, c, x, e): rubi.append(2826) return Dist(g**(m + n), Int((g/sin(e + f*x))**(-m - n + p)*(a/sin(e + f*x) + b)**m*(c/sin(e + f*x) + d)**n, x), x) rule2826 = ReplacementRule(pattern2826, replacement2826) pattern2827 = Pattern(Integral((WC('g', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('p', S(1))*(c_ + WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1))*(WC('a', S(0)) + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons5, cons71, cons147, cons17, cons85) def replacement2827(p, m, f, b, g, d, a, n, c, x, e): rubi.append(2827) return Dist(g**(m + n), Int((g/cos(e + f*x))**(-m - n + p)*(a/cos(e + f*x) + b)**m*(c/cos(e + f*x) + d)**n, x), x) rule2827 = ReplacementRule(pattern2827, replacement2827) pattern2828 = Pattern(Integral((WC('g', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('p', S(1))*(c_ + WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1))*(WC('a', S(0)) + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons21, cons4, cons5, cons71, cons147, cons1417) def replacement2828(p, m, f, g, b, d, a, n, c, x, e): rubi.append(2828) return Dist((g/sin(e + f*x))**p*(g*sin(e + f*x))**p, Int((g*sin(e + f*x))**(-p)*(a + b*sin(e + f*x))**m*(c + d*sin(e + f*x))**n, x), x) rule2828 = ReplacementRule(pattern2828, replacement2828) pattern2829 = Pattern(Integral((WC('g', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('p', S(1))*(c_ + WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1))*(WC('a', S(0)) + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons21, cons4, cons5, cons71, cons147, cons1417) def replacement2829(p, m, f, b, g, d, a, n, c, x, e): rubi.append(2829) return Dist((g/cos(e + f*x))**p*(g*cos(e + f*x))**p, Int((g*cos(e + f*x))**(-p)*(a + b*cos(e + f*x))**m*(c + d*cos(e + f*x))**n, x), x) rule2829 = ReplacementRule(pattern2829, replacement2829) pattern2830 = Pattern(Integral((WC('g', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('p', S(1))*(a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(c_ + WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons4, cons5, cons17) def replacement2830(p, m, f, g, b, d, c, n, a, x, e): rubi.append(2830) return Dist(g**m, Int((g/sin(e + f*x))**(-m + p)*(c + d/sin(e + f*x))**n*(a/sin(e + f*x) + b)**m, x), x) rule2830 = ReplacementRule(pattern2830, replacement2830) pattern2831 = Pattern(Integral((WC('g', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('p', S(1))*(a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(c_ + WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons4, cons5, cons17) def replacement2831(p, m, f, b, g, d, a, n, c, x, e): rubi.append(2831) return Dist(g**m, Int((g/cos(e + f*x))**(-m + p)*(c + d/cos(e + f*x))**n*(a/cos(e + f*x) + b)**m, x), x) rule2831 = ReplacementRule(pattern2831, replacement2831) pattern2832 = Pattern(Integral((a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(c_ + WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1))*(S(1)/sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons18, cons85, cons38) def replacement2832(p, m, f, b, d, c, n, a, x, e): rubi.append(2832) return Int((a + b*sin(e + f*x))**m*(c*sin(e + f*x) + d)**n*sin(e + f*x)**(-n - p), x) rule2832 = ReplacementRule(pattern2832, replacement2832) pattern2833 = Pattern(Integral((a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(c_ + WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1))*(S(1)/cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons18, cons85, cons38) def replacement2833(p, m, f, b, d, a, n, c, x, e): rubi.append(2833) return Int((a + b*cos(e + f*x))**m*(c*cos(e + f*x) + d)**n*cos(e + f*x)**(-n - p), x) rule2833 = ReplacementRule(pattern2833, replacement2833) pattern2834 = Pattern(Integral((WC('g', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**p_*(a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(c_ + WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons21, cons5, cons18, cons85, cons147) def replacement2834(p, m, f, g, b, d, c, n, a, x, e): rubi.append(2834) return Dist((g/sin(e + f*x))**p*sin(e + f*x)**p, Int((a + b*sin(e + f*x))**m*(c*sin(e + f*x) + d)**n*sin(e + f*x)**(-n - p), x), x) rule2834 = ReplacementRule(pattern2834, replacement2834) pattern2835 = Pattern(Integral((WC('g', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**p_*(a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(c_ + WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons21, cons5, cons18, cons85, cons147) def replacement2835(p, m, f, b, g, d, a, n, c, x, e): rubi.append(2835) return Dist((g/cos(e + f*x))**p*cos(e + f*x)**p, Int((a + b*cos(e + f*x))**m*(c*cos(e + f*x) + d)**n*cos(e + f*x)**(-n - p), x), x) rule2835 = ReplacementRule(pattern2835, replacement2835) pattern2836 = Pattern(Integral((WC('g', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('p', S(1))*(a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(c_ + WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons21, cons4, cons5, cons18, cons23) def replacement2836(p, m, f, g, b, d, c, n, a, x, e): rubi.append(2836) return Dist((g/sin(e + f*x))**m*(a + b*sin(e + f*x))**m*(a/sin(e + f*x) + b)**(-m), Int((g/sin(e + f*x))**(-m + p)*(c + d/sin(e + f*x))**n*(a/sin(e + f*x) + b)**m, x), x) rule2836 = ReplacementRule(pattern2836, replacement2836) pattern2837 = Pattern(Integral((WC('g', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('p', S(1))*(a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(c_ + WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons21, cons4, cons5, cons18, cons23) def replacement2837(p, m, f, b, g, d, a, c, n, x, e): rubi.append(2837) return Dist((g/cos(e + f*x))**m*(a + b*cos(e + f*x))**m*(a/cos(e + f*x) + b)**(-m), Int((g/cos(e + f*x))**(-m + p)*(c + d/cos(e + f*x))**n*(a/cos(e + f*x) + b)**m, x), x) rule2837 = ReplacementRule(pattern2837, replacement2837) pattern2838 = Pattern(Integral((a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(WC('A', S(0)) + WC('B', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))*sin(x_*WC('f', S(1)) + WC('e', S(0)))**WC('n', S(1)), x_), cons2, cons3, cons48, cons125, cons34, cons35, cons1418, cons1265, cons17, cons85) def replacement2838(B, m, f, b, a, n, A, x, e): rubi.append(2838) return Int(ExpandTrig((A + B*sin(e + f*x))*(a + b*sin(e + f*x))**m*sin(e + f*x)**n, x), x) rule2838 = ReplacementRule(pattern2838, replacement2838) pattern2839 = Pattern(Integral((a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(WC('A', S(0)) + WC('B', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))*cos(x_*WC('f', S(1)) + WC('e', S(0)))**WC('n', S(1)), x_), cons2, cons3, cons48, cons125, cons34, cons35, cons1418, cons1265, cons17, cons85) def replacement2839(B, e, m, f, b, a, n, x, A): rubi.append(2839) return Int(ExpandTrig((A + B*cos(e + f*x))*(a + b*cos(e + f*x))**m*cos(e + f*x)**n, x), x) rule2839 = ReplacementRule(pattern2839, replacement2839) pattern2840 = Pattern(Integral((a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(c_ + WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1))*(WC('A', S(0)) + WC('B', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons4, cons70, cons1265, cons17, cons1309) def replacement2840(B, e, m, f, b, d, a, n, c, x, A): rubi.append(2840) return Dist(a**m*c**m, Int((A + B*sin(e + f*x))*(c + d*sin(e + f*x))**(-m + n)*cos(e + f*x)**(S(2)*m), x), x) rule2840 = ReplacementRule(pattern2840, replacement2840) pattern2841 = Pattern(Integral((a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(c_ + WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1))*(WC('A', S(0)) + WC('B', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons4, cons70, cons1265, cons17, cons1309) def replacement2841(B, m, f, b, d, a, n, c, A, x, e): rubi.append(2841) return Dist(a**m*c**m, Int((A + B*cos(e + f*x))*(c + d*cos(e + f*x))**(-m + n)*sin(e + f*x)**(S(2)*m), x), x) rule2841 = ReplacementRule(pattern2841, replacement2841) pattern2842 = Pattern(Integral((WC('A', S(0)) + WC('B', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))*(WC('a', S(0)) + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(WC('c', S(0)) + WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons21, cons71) def replacement2842(B, m, f, b, d, a, c, A, x, e): rubi.append(2842) return Int((a + b*sin(e + f*x))**m*(A*c + B*d*sin(e + f*x)**S(2) + (A*d + B*c)*sin(e + f*x)), x) rule2842 = ReplacementRule(pattern2842, replacement2842) pattern2843 = Pattern(Integral((WC('A', S(0)) + WC('B', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))*(WC('a', S(0)) + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(WC('c', S(0)) + WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons21, cons71) def replacement2843(B, m, f, b, d, a, c, A, x, e): rubi.append(2843) return Int((a + b*cos(e + f*x))**m*(A*c + B*d*cos(e + f*x)**S(2) + (A*d + B*c)*cos(e + f*x)), x) rule2843 = ReplacementRule(pattern2843, replacement2843) pattern2844 = Pattern(Integral((WC('A', S(0)) + WC('B', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))/(sqrt(a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))*sqrt(c_ + WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons70, cons1265) def replacement2844(B, e, f, b, d, a, c, x, A): rubi.append(2844) return Dist((A*b + B*a)/(S(2)*a*b), Int(sqrt(a + b*sin(e + f*x))/sqrt(c + d*sin(e + f*x)), x), x) + Dist((A*d + B*c)/(S(2)*c*d), Int(sqrt(c + d*sin(e + f*x))/sqrt(a + b*sin(e + f*x)), x), x) rule2844 = ReplacementRule(pattern2844, replacement2844) pattern2845 = Pattern(Integral((WC('A', S(0)) + WC('B', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))/(sqrt(a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))*sqrt(c_ + WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons70, cons1265) def replacement2845(B, f, b, d, a, c, A, x, e): rubi.append(2845) return Dist((A*b + B*a)/(S(2)*a*b), Int(sqrt(a + b*cos(e + f*x))/sqrt(c + d*cos(e + f*x)), x), x) + Dist((A*d + B*c)/(S(2)*c*d), Int(sqrt(c + d*cos(e + f*x))/sqrt(a + b*cos(e + f*x)), x), x) rule2845 = ReplacementRule(pattern2845, replacement2845) pattern2846 = Pattern(Integral((a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(c_ + WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1))*(WC('A', S(0)) + WC('B', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons21, cons4, cons70, cons1265, cons1419, cons1314) def replacement2846(B, e, m, f, b, d, a, n, c, x, A): rubi.append(2846) return -Simp(B*(a + b*sin(e + f*x))**m*(c + d*sin(e + f*x))**n*cos(e + f*x)/(f*(m + n + S(1))), x) rule2846 = ReplacementRule(pattern2846, replacement2846) pattern2847 = Pattern(Integral((a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(c_ + WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1))*(WC('A', S(0)) + WC('B', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons21, cons4, cons70, cons1265, cons1419, cons1314) def replacement2847(B, m, f, b, d, a, n, c, A, x, e): rubi.append(2847) return Simp(B*(a + b*cos(e + f*x))**m*(c + d*cos(e + f*x))**n*sin(e + f*x)/(f*(m + n + S(1))), x) rule2847 = ReplacementRule(pattern2847, replacement2847) pattern2848 = Pattern(Integral((c_ + WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(WC('A', S(0)) + WC('B', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))*sqrt(WC('a', S(0)) + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons4, cons70, cons1265) def replacement2848(B, e, f, b, d, a, c, n, x, A): rubi.append(2848) return Dist(B/d, Int(sqrt(a + b*sin(e + f*x))*(c + d*sin(e + f*x))**(n + S(1)), x), x) - Dist((-A*d + B*c)/d, Int(sqrt(a + b*sin(e + f*x))*(c + d*sin(e + f*x))**n, x), x) rule2848 = ReplacementRule(pattern2848, replacement2848) pattern2849 = Pattern(Integral((c_ + WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(WC('A', S(0)) + WC('B', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))*sqrt(WC('a', S(0)) + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons4, cons70, cons1265) def replacement2849(B, e, f, b, d, a, c, n, x, A): rubi.append(2849) return Dist(B/d, Int(sqrt(a + b*cos(e + f*x))*(c + d*cos(e + f*x))**(n + S(1)), x), x) - Dist((-A*d + B*c)/d, Int(sqrt(a + b*cos(e + f*x))*(c + d*cos(e + f*x))**n, x), x) rule2849 = ReplacementRule(pattern2849, replacement2849) pattern2850 = Pattern(Integral((a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(c_ + WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1))*(WC('A', S(0)) + WC('B', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons21, cons4, cons70, cons1265, cons1420, cons1421) def replacement2850(B, e, m, f, b, d, a, n, c, x, A): rubi.append(2850) return Dist((A*b*(m + n + S(1)) + B*a*(m - n))/(a*b*(S(2)*m + S(1))), Int((a + b*sin(e + f*x))**(m + S(1))*(c + d*sin(e + f*x))**n, x), x) + Simp((a + b*sin(e + f*x))**m*(c + d*sin(e + f*x))**n*(A*b - B*a)*cos(e + f*x)/(a*f*(S(2)*m + S(1))), x) rule2850 = ReplacementRule(pattern2850, replacement2850) pattern2851 = Pattern(Integral((a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(c_ + WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1))*(WC('A', S(0)) + WC('B', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons21, cons4, cons70, cons1265, cons1420, cons1421) def replacement2851(B, m, f, b, d, a, n, c, A, x, e): rubi.append(2851) return Dist((A*b*(m + n + S(1)) + B*a*(m - n))/(a*b*(S(2)*m + S(1))), Int((a + b*cos(e + f*x))**(m + S(1))*(c + d*cos(e + f*x))**n, x), x) - Simp((a + b*cos(e + f*x))**m*(c + d*cos(e + f*x))**n*(A*b - B*a)*sin(e + f*x)/(a*f*(S(2)*m + S(1))), x) rule2851 = ReplacementRule(pattern2851, replacement2851) pattern2852 = Pattern(Integral((a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(c_ + WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(WC('A', S(0)) + WC('B', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons21, cons4, cons70, cons1265, cons1321, cons683) def replacement2852(B, e, m, f, b, d, a, c, n, x, A): rubi.append(2852) return -Dist((-A*d*(m + n + S(1)) + B*c*(m - n))/(d*(m + n + S(1))), Int((a + b*sin(e + f*x))**m*(c + d*sin(e + f*x))**n, x), x) - Simp(B*(a + b*sin(e + f*x))**m*(c + d*sin(e + f*x))**n*cos(e + f*x)/(f*(m + n + S(1))), x) rule2852 = ReplacementRule(pattern2852, replacement2852) pattern2853 = Pattern(Integral((a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(c_ + WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(WC('A', S(0)) + WC('B', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons21, cons4, cons70, cons1265, cons1321, cons683) def replacement2853(B, m, f, b, d, a, c, n, A, x, e): rubi.append(2853) return -Dist((-A*d*(m + n + S(1)) + B*c*(m - n))/(d*(m + n + S(1))), Int((a + b*cos(e + f*x))**m*(c + d*cos(e + f*x))**n, x), x) + Simp(B*(a + b*cos(e + f*x))**m*(c + d*cos(e + f*x))**n*sin(e + f*x)/(f*(m + n + S(1))), x) rule2853 = ReplacementRule(pattern2853, replacement2853) pattern2854 = Pattern(Integral((a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('A', S(0)) + WC('B', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))*(WC('c', S(0)) + WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons21, cons4, cons71, cons1265, cons1323, cons72, cons1422) def replacement2854(B, e, m, f, b, d, c, a, n, x, A): rubi.append(2854) return Simp((a + b*sin(e + f*x))**m*(c + d*sin(e + f*x))**(n + S(1))*(-A*d + B*c)*cos(e + f*x)/(f*(c**S(2) - d**S(2))*(n + S(1))), x) rule2854 = ReplacementRule(pattern2854, replacement2854) pattern2855 = Pattern(Integral((a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('A', S(0)) + WC('B', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))*(WC('c', S(0)) + WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons21, cons4, cons71, cons1265, cons1323, cons72, cons1422) def replacement2855(B, m, f, b, d, c, n, a, A, x, e): rubi.append(2855) return -Simp((a + b*cos(e + f*x))**m*(c + d*cos(e + f*x))**(n + S(1))*(-A*d + B*c)*sin(e + f*x)/(f*(c**S(2) - d**S(2))*(n + S(1))), x) rule2855 = ReplacementRule(pattern2855, replacement2855) pattern2856 = Pattern(Integral((a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('A', S(0)) + WC('B', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))*(WC('c', S(0)) + WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons71, cons1265, cons1323, cons93, cons1423, cons89, cons515, cons1328) def replacement2856(B, e, m, f, b, d, c, a, n, x, A): rubi.append(2856) return -Dist(b/(d*(n + S(1))*(a*d + b*c)), Int((a + b*sin(e + f*x))**(m + S(-1))*(c + d*sin(e + f*x))**(n + S(1))*Simp(A*a*d*(m - n + S(-2)) - B*(a*c*(m + S(-1)) + b*d*(n + S(1))) - (A*b*d*(m + n + S(1)) - B*(-a*d*(n + S(1)) + b*c*m))*sin(e + f*x), x), x), x) - Simp(b**S(2)*(a + b*sin(e + f*x))**(m + S(-1))*(c + d*sin(e + f*x))**(n + S(1))*(-A*d + B*c)*cos(e + f*x)/(d*f*(n + S(1))*(a*d + b*c)), x) rule2856 = ReplacementRule(pattern2856, replacement2856) pattern2857 = Pattern(Integral((a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('A', S(0)) + WC('B', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))*(WC('c', S(0)) + WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons71, cons1265, cons1323, cons93, cons1423, cons89, cons515, cons1328) def replacement2857(B, m, f, b, d, c, n, a, A, x, e): rubi.append(2857) return -Dist(b/(d*(n + S(1))*(a*d + b*c)), Int((a + b*cos(e + f*x))**(m + S(-1))*(c + d*cos(e + f*x))**(n + S(1))*Simp(A*a*d*(m - n + S(-2)) - B*(a*c*(m + S(-1)) + b*d*(n + S(1))) - (A*b*d*(m + n + S(1)) - B*(-a*d*(n + S(1)) + b*c*m))*cos(e + f*x), x), x), x) + Simp(b**S(2)*(a + b*cos(e + f*x))**(m + S(-1))*(c + d*cos(e + f*x))**(n + S(1))*(-A*d + B*c)*sin(e + f*x)/(d*f*(n + S(1))*(a*d + b*c)), x) rule2857 = ReplacementRule(pattern2857, replacement2857) pattern2858 = Pattern(Integral((a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('A', S(0)) + WC('B', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))*(WC('c', S(0)) + WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons4, cons71, cons1265, cons1323, cons31, cons1423, cons346, cons515, cons1328) def replacement2858(B, e, m, f, b, d, c, a, n, x, A): rubi.append(2858) return Dist(S(1)/(d*(m + n + S(1))), Int((a + b*sin(e + f*x))**(m + S(-1))*(c + d*sin(e + f*x))**n*Simp(A*a*d*(m + n + S(1)) + B*(a*c*(m + S(-1)) + b*d*(n + S(1))) + (A*b*d*(m + n + S(1)) - B*(-a*d*(S(2)*m + n) + b*c*m))*sin(e + f*x), x), x), x) - Simp(B*b*(a + b*sin(e + f*x))**(m + S(-1))*(c + d*sin(e + f*x))**(n + S(1))*cos(e + f*x)/(d*f*(m + n + S(1))), x) rule2858 = ReplacementRule(pattern2858, replacement2858) pattern2859 = Pattern(Integral((a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('A', S(0)) + WC('B', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))*(WC('c', S(0)) + WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons4, cons71, cons1265, cons1323, cons31, cons1423, cons346, cons515, cons1328) def replacement2859(B, m, f, b, d, c, n, a, A, x, e): rubi.append(2859) return Dist(S(1)/(d*(m + n + S(1))), Int((a + b*cos(e + f*x))**(m + S(-1))*(c + d*cos(e + f*x))**n*Simp(A*a*d*(m + n + S(1)) + B*(a*c*(m + S(-1)) + b*d*(n + S(1))) + (A*b*d*(m + n + S(1)) - B*(-a*d*(S(2)*m + n) + b*c*m))*cos(e + f*x), x), x), x) + Simp(B*b*(a + b*cos(e + f*x))**(m + S(-1))*(c + d*cos(e + f*x))**(n + S(1))*sin(e + f*x)/(d*f*(m + n + S(1))), x) rule2859 = ReplacementRule(pattern2859, replacement2859) pattern2860 = Pattern(Integral((a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('A', S(0)) + WC('B', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))*(WC('c', S(0)) + WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons71, cons1265, cons1323, cons93, cons1320, cons88, cons515, cons1328) def replacement2860(B, e, m, f, b, d, c, a, n, x, A): rubi.append(2860) return -Dist(S(1)/(a*b*(S(2)*m + S(1))), Int((a + b*sin(e + f*x))**(m + S(1))*(c + d*sin(e + f*x))**(n + S(-1))*Simp(A*(a*d*n - b*c*(m + S(1))) - B*(a*c*m + b*d*n) - d*(A*b*(m + n + S(1)) + B*a*(m - n))*sin(e + f*x), x), x), x) + Simp((a + b*sin(e + f*x))**m*(c + d*sin(e + f*x))**n*(A*b - B*a)*cos(e + f*x)/(a*f*(S(2)*m + S(1))), x) rule2860 = ReplacementRule(pattern2860, replacement2860) pattern2861 = Pattern(Integral((a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('A', S(0)) + WC('B', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))*(WC('c', S(0)) + WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons71, cons1265, cons1323, cons93, cons1320, cons88, cons515, cons1328) def replacement2861(B, m, f, b, d, c, n, a, A, x, e): rubi.append(2861) return -Dist(S(1)/(a*b*(S(2)*m + S(1))), Int((a + b*cos(e + f*x))**(m + S(1))*(c + d*cos(e + f*x))**(n + S(-1))*Simp(A*(a*d*n - b*c*(m + S(1))) - B*(a*c*m + b*d*n) - d*(A*b*(m + n + S(1)) + B*a*(m - n))*cos(e + f*x), x), x), x) - Simp((a + b*cos(e + f*x))**m*(c + d*cos(e + f*x))**n*(A*b - B*a)*sin(e + f*x)/(a*f*(S(2)*m + S(1))), x) rule2861 = ReplacementRule(pattern2861, replacement2861) pattern2862 = Pattern(Integral((a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('A', S(0)) + WC('B', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))*(WC('c', S(0)) + WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons4, cons71, cons1265, cons1323, cons31, cons1320, cons1327, cons515, cons1328) def replacement2862(B, e, m, f, b, d, c, a, n, x, A): rubi.append(2862) return Dist(S(1)/(a*(S(2)*m + S(1))*(-a*d + b*c)), Int((a + b*sin(e + f*x))**(m + S(1))*(c + d*sin(e + f*x))**n*Simp(A*(-a*d*(S(2)*m + n + S(2)) + b*c*(m + S(1))) + B*(a*c*m + b*d*(n + S(1))) + d*(A*b - B*a)*(m + n + S(2))*sin(e + f*x), x), x), x) + Simp(b*(a + b*sin(e + f*x))**m*(c + d*sin(e + f*x))**(n + S(1))*(A*b - B*a)*cos(e + f*x)/(a*f*(S(2)*m + S(1))*(-a*d + b*c)), x) rule2862 = ReplacementRule(pattern2862, replacement2862) pattern2863 = Pattern(Integral((a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('A', S(0)) + WC('B', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))*(WC('c', S(0)) + WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons4, cons71, cons1265, cons1323, cons31, cons1320, cons1327, cons515, cons1328) def replacement2863(B, m, f, b, d, c, n, a, A, x, e): rubi.append(2863) return Dist(S(1)/(a*(S(2)*m + S(1))*(-a*d + b*c)), Int((a + b*cos(e + f*x))**(m + S(1))*(c + d*cos(e + f*x))**n*Simp(A*(-a*d*(S(2)*m + n + S(2)) + b*c*(m + S(1))) + B*(a*c*m + b*d*(n + S(1))) + d*(A*b - B*a)*(m + n + S(2))*cos(e + f*x), x), x), x) - Simp(b*(a + b*cos(e + f*x))**m*(c + d*cos(e + f*x))**(n + S(1))*(A*b - B*a)*sin(e + f*x)/(a*f*(S(2)*m + S(1))*(-a*d + b*c)), x) rule2863 = ReplacementRule(pattern2863, replacement2863) pattern2864 = Pattern(Integral(sqrt(a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))*(WC('A', S(0)) + WC('B', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))*(WC('c', S(0)) + WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons4, cons71, cons1265, cons1323, cons1424) def replacement2864(B, e, f, b, d, c, a, n, x, A): rubi.append(2864) return Simp(-S(2)*B*b*(c + d*sin(e + f*x))**(n + S(1))*cos(e + f*x)/(d*f*sqrt(a + b*sin(e + f*x))*(S(2)*n + S(3))), x) rule2864 = ReplacementRule(pattern2864, replacement2864) pattern2865 = Pattern(Integral(sqrt(a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))*(WC('A', S(0)) + WC('B', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))*(WC('c', S(0)) + WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons4, cons71, cons1265, cons1323, cons1424) def replacement2865(B, f, b, d, c, n, a, A, x, e): rubi.append(2865) return Simp(S(2)*B*b*(c + d*cos(e + f*x))**(n + S(1))*sin(e + f*x)/(d*f*sqrt(a + b*cos(e + f*x))*(S(2)*n + S(3))), x) rule2865 = ReplacementRule(pattern2865, replacement2865) pattern2866 = Pattern(Integral(sqrt(a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))*(WC('A', S(0)) + WC('B', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))*(WC('c', S(0)) + WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons71, cons1265, cons1323, cons87, cons89) def replacement2866(B, e, f, b, d, c, a, n, x, A): rubi.append(2866) return Dist((A*b*d*(S(2)*n + S(3)) - B*(-S(2)*a*d*(n + S(1)) + b*c))/(S(2)*d*(n + S(1))*(a*d + b*c)), Int(sqrt(a + b*sin(e + f*x))*(c + d*sin(e + f*x))**(n + S(1)), x), x) - Simp(b**S(2)*(c + d*sin(e + f*x))**(n + S(1))*(-A*d + B*c)*cos(e + f*x)/(d*f*sqrt(a + b*sin(e + f*x))*(n + S(1))*(a*d + b*c)), x) rule2866 = ReplacementRule(pattern2866, replacement2866) pattern2867 = Pattern(Integral(sqrt(a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))*(WC('A', S(0)) + WC('B', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))*(WC('c', S(0)) + WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons71, cons1265, cons1323, cons87, cons89) def replacement2867(B, f, b, d, c, n, a, A, x, e): rubi.append(2867) return Dist((A*b*d*(S(2)*n + S(3)) - B*(-S(2)*a*d*(n + S(1)) + b*c))/(S(2)*d*(n + S(1))*(a*d + b*c)), Int(sqrt(a + b*cos(e + f*x))*(c + d*cos(e + f*x))**(n + S(1)), x), x) + Simp(b**S(2)*(c + d*cos(e + f*x))**(n + S(1))*(-A*d + B*c)*sin(e + f*x)/(d*f*sqrt(a + b*cos(e + f*x))*(n + S(1))*(a*d + b*c)), x) rule2867 = ReplacementRule(pattern2867, replacement2867) pattern2868 = Pattern(Integral(sqrt(a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))*(WC('A', S(0)) + WC('B', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))*(WC('c', S(0)) + WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons4, cons71, cons1265, cons1323, cons346) def replacement2868(B, e, f, b, d, c, a, n, x, A): rubi.append(2868) return Dist((A*b*d*(S(2)*n + S(3)) - B*(-S(2)*a*d*(n + S(1)) + b*c))/(b*d*(S(2)*n + S(3))), Int(sqrt(a + b*sin(e + f*x))*(c + d*sin(e + f*x))**n, x), x) + Simp(-S(2)*B*b*(c + d*sin(e + f*x))**(n + S(1))*cos(e + f*x)/(d*f*sqrt(a + b*sin(e + f*x))*(S(2)*n + S(3))), x) rule2868 = ReplacementRule(pattern2868, replacement2868) pattern2869 = Pattern(Integral(sqrt(a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))*(WC('A', S(0)) + WC('B', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))*(WC('c', S(0)) + WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons4, cons71, cons1265, cons1323, cons346) def replacement2869(B, f, b, d, c, n, a, A, x, e): rubi.append(2869) return Dist((A*b*d*(S(2)*n + S(3)) - B*(-S(2)*a*d*(n + S(1)) + b*c))/(b*d*(S(2)*n + S(3))), Int(sqrt(a + b*cos(e + f*x))*(c + d*cos(e + f*x))**n, x), x) + Simp(S(2)*B*b*(c + d*cos(e + f*x))**(n + S(1))*sin(e + f*x)/(d*f*sqrt(a + b*cos(e + f*x))*(S(2)*n + S(3))), x) rule2869 = ReplacementRule(pattern2869, replacement2869) pattern2870 = Pattern(Integral((WC('A', S(0)) + WC('B', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))/(sqrt(a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))*sqrt(WC('c', S(0)) + WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons71, cons1265, cons1323) def replacement2870(B, e, f, b, d, c, a, x, A): rubi.append(2870) return Dist(B/b, Int(sqrt(a + b*sin(e + f*x))/sqrt(c + d*sin(e + f*x)), x), x) + Dist((A*b - B*a)/b, Int(S(1)/(sqrt(a + b*sin(e + f*x))*sqrt(c + d*sin(e + f*x))), x), x) rule2870 = ReplacementRule(pattern2870, replacement2870) pattern2871 = Pattern(Integral((WC('A', S(0)) + WC('B', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))/(sqrt(a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))*sqrt(WC('c', S(0)) + WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons71, cons1265, cons1323) def replacement2871(B, f, b, d, c, a, A, x, e): rubi.append(2871) return Dist(B/b, Int(sqrt(a + b*cos(e + f*x))/sqrt(c + d*cos(e + f*x)), x), x) + Dist((A*b - B*a)/b, Int(S(1)/(sqrt(a + b*cos(e + f*x))*sqrt(c + d*cos(e + f*x))), x), x) rule2871 = ReplacementRule(pattern2871, replacement2871) pattern2872 = Pattern(Integral((a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('A', S(0)) + WC('B', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))*(WC('c', S(0)) + WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons21, cons71, cons1265, cons1323, cons87, cons88, cons1425) def replacement2872(B, e, m, f, b, d, c, a, n, x, A): rubi.append(2872) return Dist(S(1)/(b*(m + n + S(1))), Int((a + b*sin(e + f*x))**m*(c + d*sin(e + f*x))**(n + S(-1))*Simp(A*b*c*(m + n + S(1)) + B*(a*c*m + b*d*n) + (A*b*d*(m + n + S(1)) + B*(a*d*m + b*c*n))*sin(e + f*x), x), x), x) - Simp(B*(a + b*sin(e + f*x))**m*(c + d*sin(e + f*x))**n*cos(e + f*x)/(f*(m + n + S(1))), x) rule2872 = ReplacementRule(pattern2872, replacement2872) pattern2873 = Pattern(Integral((a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('A', S(0)) + WC('B', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))*(WC('c', S(0)) + WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons21, cons71, cons1265, cons1323, cons87, cons88, cons1425) def replacement2873(B, m, f, b, d, c, n, a, A, x, e): rubi.append(2873) return Dist(S(1)/(b*(m + n + S(1))), Int((a + b*cos(e + f*x))**m*(c + d*cos(e + f*x))**(n + S(-1))*Simp(A*b*c*(m + n + S(1)) + B*(a*c*m + b*d*n) + (A*b*d*(m + n + S(1)) + B*(a*d*m + b*c*n))*cos(e + f*x), x), x), x) + Simp(B*(a + b*cos(e + f*x))**m*(c + d*cos(e + f*x))**n*sin(e + f*x)/(f*(m + n + S(1))), x) rule2873 = ReplacementRule(pattern2873, replacement2873) pattern2874 = Pattern(Integral((a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('A', S(0)) + WC('B', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))*(WC('c', S(0)) + WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons21, cons71, cons1265, cons1323, cons87, cons89, cons1425) def replacement2874(B, e, m, f, b, d, c, a, n, x, A): rubi.append(2874) return Dist(S(1)/(b*(c**S(2) - d**S(2))*(n + S(1))), Int((a + b*sin(e + f*x))**m*(c + d*sin(e + f*x))**(n + S(1))*Simp(A*(a*d*m + b*c*(n + S(1))) - B*(a*c*m + b*d*(n + S(1))) + b*(-A*d + B*c)*(m + n + S(2))*sin(e + f*x), x), x), x) + Simp((a + b*sin(e + f*x))**m*(c + d*sin(e + f*x))**(n + S(1))*(-A*d + B*c)*cos(e + f*x)/(f*(c**S(2) - d**S(2))*(n + S(1))), x) rule2874 = ReplacementRule(pattern2874, replacement2874) pattern2875 = Pattern(Integral((a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('A', S(0)) + WC('B', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))*(WC('c', S(0)) + WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons21, cons71, cons1265, cons1323, cons87, cons89, cons1425) def replacement2875(B, m, f, b, d, c, n, a, A, x, e): rubi.append(2875) return Dist(S(1)/(b*(c**S(2) - d**S(2))*(n + S(1))), Int((a + b*cos(e + f*x))**m*(c + d*cos(e + f*x))**(n + S(1))*Simp(A*(a*d*m + b*c*(n + S(1))) - B*(a*c*m + b*d*(n + S(1))) + b*(-A*d + B*c)*(m + n + S(2))*cos(e + f*x), x), x), x) - Simp((a + b*cos(e + f*x))**m*(c + d*cos(e + f*x))**(n + S(1))*(-A*d + B*c)*sin(e + f*x)/(f*(c**S(2) - d**S(2))*(n + S(1))), x) rule2875 = ReplacementRule(pattern2875, replacement2875) pattern2876 = Pattern(Integral((WC('A', S(0)) + WC('B', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))/(sqrt(a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))*(WC('c', S(0)) + WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons71, cons1265, cons1323) def replacement2876(B, e, f, b, d, c, a, x, A): rubi.append(2876) return Dist((A*b - B*a)/(-a*d + b*c), Int(S(1)/sqrt(a + b*sin(e + f*x)), x), x) + Dist((-A*d + B*c)/(-a*d + b*c), Int(sqrt(a + b*sin(e + f*x))/(c + d*sin(e + f*x)), x), x) rule2876 = ReplacementRule(pattern2876, replacement2876) pattern2877 = Pattern(Integral((WC('A', S(0)) + WC('B', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))/(sqrt(a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))*(WC('c', S(0)) + WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons71, cons1265, cons1323) def replacement2877(B, f, b, d, c, a, A, x, e): rubi.append(2877) return Dist((A*b - B*a)/(-a*d + b*c), Int(S(1)/sqrt(a + b*cos(e + f*x)), x), x) + Dist((-A*d + B*c)/(-a*d + b*c), Int(sqrt(a + b*cos(e + f*x))/(c + d*cos(e + f*x)), x), x) rule2877 = ReplacementRule(pattern2877, replacement2877) pattern2878 = Pattern(Integral((a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('A', S(0)) + WC('B', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))/(WC('c', S(0)) + WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons21, cons71, cons1265, cons1323, cons1314) def replacement2878(B, e, m, f, b, d, c, a, x, A): rubi.append(2878) return Dist(B/d, Int((a + b*sin(e + f*x))**m, x), x) - Dist((-A*d + B*c)/d, Int((a + b*sin(e + f*x))**m/(c + d*sin(e + f*x)), x), x) rule2878 = ReplacementRule(pattern2878, replacement2878) pattern2879 = Pattern(Integral((a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('A', S(0)) + WC('B', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))/(WC('c', S(0)) + WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons21, cons71, cons1265, cons1323, cons1314) def replacement2879(B, m, f, b, d, c, a, A, x, e): rubi.append(2879) return Dist(B/d, Int((a + b*cos(e + f*x))**m, x), x) - Dist((-A*d + B*c)/d, Int((a + b*cos(e + f*x))**m/(c + d*cos(e + f*x)), x), x) rule2879 = ReplacementRule(pattern2879, replacement2879) pattern2880 = Pattern(Integral((a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(WC('A', S(0)) + WC('B', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))*(WC('c', S(0)) + WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons21, cons4, cons71, cons1265, cons1323, cons1426) def replacement2880(B, e, m, f, b, d, c, a, n, x, A): rubi.append(2880) return Dist(B/b, Int((a + b*sin(e + f*x))**(m + S(1))*(c + d*sin(e + f*x))**n, x), x) + Dist((A*b - B*a)/b, Int((a + b*sin(e + f*x))**m*(c + d*sin(e + f*x))**n, x), x) rule2880 = ReplacementRule(pattern2880, replacement2880) pattern2881 = Pattern(Integral((a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(WC('A', S(0)) + WC('B', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))*(WC('c', S(0)) + WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons21, cons4, cons71, cons1265, cons1323, cons1426) def replacement2881(B, m, f, b, d, c, n, a, A, x, e): rubi.append(2881) return Dist(B/b, Int((a + b*cos(e + f*x))**(m + S(1))*(c + d*cos(e + f*x))**n, x), x) + Dist((A*b - B*a)/b, Int((a + b*cos(e + f*x))**m*(c + d*cos(e + f*x))**n, x), x) rule2881 = ReplacementRule(pattern2881, replacement2881) pattern2882 = Pattern(Integral((WC('A', S(0)) + WC('B', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))*(WC('a', S(0)) + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons71, cons1267, cons1323, cons93, cons166, cons89) def replacement2882(B, e, m, f, b, d, a, c, n, x, A): rubi.append(2882) return Dist(S(1)/(d*(c**S(2) - d**S(2))*(n + S(1))), Int((a + b*sin(e + f*x))**(m + S(-2))*(c + d*sin(e + f*x))**(n + S(1))*Simp(a*d*(n + S(1))*(A*a*c + B*b*c - d*(A*b + B*a)) + b*(m + S(-1))*(-A*d + B*c)*(-a*d + b*c) + b*(-B*b*(c**S(2)*m + d**S(2)*(n + S(1))) + d*(m + n + S(1))*(-A*a*d + A*b*c + B*a*c))*sin(e + f*x)**S(2) + (-a*(n + S(2))*(-A*d + B*c)*(-a*d + b*c) + b*(n + S(1))*(a*(A*c*d + B*(c**S(2) - S(2)*d**S(2))) + b*d*(-A*d + B*c)))*sin(e + f*x), x), x), x) - Simp((a + b*sin(e + f*x))**(m + S(-1))*(c + d*sin(e + f*x))**(n + S(1))*(-A*d + B*c)*(-a*d + b*c)*cos(e + f*x)/(d*f*(c**S(2) - d**S(2))*(n + S(1))), x) rule2882 = ReplacementRule(pattern2882, replacement2882) pattern2883 = Pattern(Integral((WC('A', S(0)) + WC('B', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))*(WC('a', S(0)) + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons71, cons1267, cons1323, cons93, cons166, cons89) def replacement2883(B, e, m, f, b, d, a, c, n, x, A): rubi.append(2883) return Dist(S(1)/(d*(c**S(2) - d**S(2))*(n + S(1))), Int((a + b*cos(e + f*x))**(m + S(-2))*(c + d*cos(e + f*x))**(n + S(1))*Simp(a*d*(n + S(1))*(A*a*c + B*b*c - d*(A*b + B*a)) + b*(m + S(-1))*(-A*d + B*c)*(-a*d + b*c) + b*(-B*b*(c**S(2)*m + d**S(2)*(n + S(1))) + d*(m + n + S(1))*(-A*a*d + A*b*c + B*a*c))*cos(e + f*x)**S(2) + (-a*(n + S(2))*(-A*d + B*c)*(-a*d + b*c) + b*(n + S(1))*(a*(A*c*d + B*(c**S(2) - S(2)*d**S(2))) + b*d*(-A*d + B*c)))*cos(e + f*x), x), x), x) + Simp((a + b*cos(e + f*x))**(m + S(-1))*(c + d*cos(e + f*x))**(n + S(1))*(-A*d + B*c)*(-a*d + b*c)*sin(e + f*x)/(d*f*(c**S(2) - d**S(2))*(n + S(1))), x) rule2883 = ReplacementRule(pattern2883, replacement2883) pattern2884 = Pattern(Integral((WC('A', S(0)) + WC('B', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))*(WC('a', S(0)) + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons4, cons71, cons1267, cons1323, cons31, cons166, cons1427) def replacement2884(B, e, m, f, b, d, a, c, n, x, A): rubi.append(2884) return Dist(S(1)/(d*(m + n + S(1))), Int((a + b*sin(e + f*x))**(m + S(-2))*(c + d*sin(e + f*x))**n*Simp(A*a**S(2)*d*(m + n + S(1)) + B*b*(a*d*(n + S(1)) + b*c*(m + S(-1))) + b*(A*b*d*(m + n + S(1)) - B*(-a*d*(S(2)*m + n) + b*c*m))*sin(e + f*x)**S(2) + (-B*b*(a*c - b*d*(m + n)) + a*d*(S(2)*A*b + B*a)*(m + n + S(1)))*sin(e + f*x), x), x), x) - Simp(B*b*(a + b*sin(e + f*x))**(m + S(-1))*(c + d*sin(e + f*x))**(n + S(1))*cos(e + f*x)/(d*f*(m + n + S(1))), x) rule2884 = ReplacementRule(pattern2884, replacement2884) pattern2885 = Pattern(Integral((WC('A', S(0)) + WC('B', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))*(WC('a', S(0)) + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons4, cons71, cons1267, cons1323, cons31, cons166, cons1427) def replacement2885(B, e, m, f, b, d, a, c, n, x, A): rubi.append(2885) return Dist(S(1)/(d*(m + n + S(1))), Int((a + b*cos(e + f*x))**(m + S(-2))*(c + d*cos(e + f*x))**n*Simp(A*a**S(2)*d*(m + n + S(1)) + B*b*(a*d*(n + S(1)) + b*c*(m + S(-1))) + b*(A*b*d*(m + n + S(1)) - B*(-a*d*(S(2)*m + n) + b*c*m))*cos(e + f*x)**S(2) + (-B*b*(a*c - b*d*(m + n)) + a*d*(S(2)*A*b + B*a)*(m + n + S(1)))*cos(e + f*x), x), x), x) + Simp(B*b*(a + b*cos(e + f*x))**(m + S(-1))*(c + d*cos(e + f*x))**(n + S(1))*sin(e + f*x)/(d*f*(m + n + S(1))), x) rule2885 = ReplacementRule(pattern2885, replacement2885) pattern2886 = Pattern(Integral(sqrt(c_ + WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))*(WC('A', S(0)) + WC('B', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))/(WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**(S(3)/2), x_), cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons1323) def replacement2886(B, e, f, b, d, c, x, A): rubi.append(2886) return Dist(B*d/b**S(2), Int(sqrt(b*sin(e + f*x))/sqrt(c + d*sin(e + f*x)), x), x) + Int((A*c + (A*d + B*c)*sin(e + f*x))/((b*sin(e + f*x))**(S(3)/2)*sqrt(c + d*sin(e + f*x))), x) rule2886 = ReplacementRule(pattern2886, replacement2886) pattern2887 = Pattern(Integral(sqrt(c_ + WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))*(WC('A', S(0)) + WC('B', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))/(WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**(S(3)/2), x_), cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons1323) def replacement2887(B, e, f, b, d, c, x, A): rubi.append(2887) return Dist(B*d/b**S(2), Int(sqrt(b*cos(e + f*x))/sqrt(c + d*cos(e + f*x)), x), x) + Int((A*c + (A*d + B*c)*cos(e + f*x))/((b*cos(e + f*x))**(S(3)/2)*sqrt(c + d*cos(e + f*x))), x) rule2887 = ReplacementRule(pattern2887, replacement2887) pattern2888 = Pattern(Integral((WC('A', S(0)) + WC('B', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))*sqrt(WC('c', S(0)) + WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))/(a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**(S(3)/2), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons71, cons1267, cons1323) def replacement2888(B, e, f, b, d, c, a, x, A): rubi.append(2888) return Dist(B/b, Int(sqrt(c + d*sin(e + f*x))/sqrt(a + b*sin(e + f*x)), x), x) + Dist((A*b - B*a)/b, Int(sqrt(c + d*sin(e + f*x))/(a + b*sin(e + f*x))**(S(3)/2), x), x) rule2888 = ReplacementRule(pattern2888, replacement2888) pattern2889 = Pattern(Integral((WC('A', S(0)) + WC('B', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))*sqrt(WC('c', S(0)) + WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))/(a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**(S(3)/2), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons71, cons1267, cons1323) def replacement2889(B, f, b, d, c, a, A, x, e): rubi.append(2889) return Dist(B/b, Int(sqrt(c + d*cos(e + f*x))/sqrt(a + b*cos(e + f*x)), x), x) + Dist((A*b - B*a)/b, Int(sqrt(c + d*cos(e + f*x))/(a + b*cos(e + f*x))**(S(3)/2), x), x) rule2889 = ReplacementRule(pattern2889, replacement2889) pattern2890 = Pattern(Integral((WC('A', S(0)) + WC('B', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))/(sqrt(WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))*(a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**(S(3)/2)), x_), cons2, cons3, cons27, cons48, cons125, cons34, cons35, cons1267) def replacement2890(B, e, f, b, d, a, x, A): rubi.append(2890) return Dist(d/(a**S(2) - b**S(2)), Int((A*b - B*a + (A*a - B*b)*sin(e + f*x))/((d*sin(e + f*x))**(S(3)/2)*sqrt(a + b*sin(e + f*x))), x), x) + Simp(S(2)*(A*b - B*a)*cos(e + f*x)/(f*sqrt(d*sin(e + f*x))*sqrt(a + b*sin(e + f*x))*(a**S(2) - b**S(2))), x) rule2890 = ReplacementRule(pattern2890, replacement2890) pattern2891 = Pattern(Integral((WC('A', S(0)) + WC('B', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))/(sqrt(WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))*(a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**(S(3)/2)), x_), cons2, cons3, cons27, cons48, cons125, cons34, cons35, cons1267) def replacement2891(B, f, b, d, a, A, x, e): rubi.append(2891) return Dist(d/(a**S(2) - b**S(2)), Int((A*b - B*a + (A*a - B*b)*cos(e + f*x))/((d*cos(e + f*x))**(S(3)/2)*sqrt(a + b*cos(e + f*x))), x), x) + Simp(-S(2)*(A*b - B*a)*sin(e + f*x)/(f*sqrt(d*cos(e + f*x))*sqrt(a + b*cos(e + f*x))*(a**S(2) - b**S(2))), x) rule2891 = ReplacementRule(pattern2891, replacement2891) pattern2892 = Pattern(Integral((A_ + WC('B', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))/((WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**(S(3)/2)*sqrt(c_ + WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))), x_), cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons1323, cons1428, cons1342) def replacement2892(B, f, b, d, c, A, x, e): rubi.append(2892) return Simp(-S(2)*A*sqrt(c*(S(1) - S(1)/sin(e + f*x))/(c + d))*sqrt(c*(S(1) + S(1)/sin(e + f*x))/(c - d))*(c - d)*EllipticE(asin(sqrt(c + d*sin(e + f*x))/(sqrt(b*sin(e + f*x))*Rt((c + d)/b, S(2)))), -(c + d)/(c - d))*Rt((c + d)/b, S(2))*tan(e + f*x)/(b*c**S(2)*f), x) rule2892 = ReplacementRule(pattern2892, replacement2892) pattern2893 = Pattern(Integral((A_ + WC('B', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))/((WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**(S(3)/2)*sqrt(c_ + WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))), x_), cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons1323, cons1428, cons1342) def replacement2893(B, f, b, d, c, A, x, e): rubi.append(2893) return Simp(S(2)*A*sqrt(c*(S(1) - S(1)/cos(e + f*x))/(c + d))*sqrt(c*(S(1) + S(1)/cos(e + f*x))/(c - d))*(c - d)*EllipticE(asin(sqrt(c + d*cos(e + f*x))/(sqrt(b*cos(e + f*x))*Rt((c + d)/b, S(2)))), -(c + d)/(c - d))*Rt((c + d)/b, S(2))/(b*c**S(2)*f*tan(e + f*x)), x) rule2893 = ReplacementRule(pattern2893, replacement2893) pattern2894 = Pattern(Integral((A_ + WC('B', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))/((WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**(S(3)/2)*sqrt(c_ + WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))), x_), cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons1323, cons1428, cons1344) def replacement2894(B, f, b, d, c, A, x, e): rubi.append(2894) return -Dist(sqrt(-b*sin(e + f*x))/sqrt(b*sin(e + f*x)), Int((A + B*sin(e + f*x))/((-b*sin(e + f*x))**(S(3)/2)*sqrt(c + d*sin(e + f*x))), x), x) rule2894 = ReplacementRule(pattern2894, replacement2894) pattern2895 = Pattern(Integral((A_ + WC('B', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))/((WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**(S(3)/2)*sqrt(c_ + WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))), x_), cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons1323, cons1428, cons1344) def replacement2895(B, f, b, d, c, A, x, e): rubi.append(2895) return -Dist(sqrt(-b*cos(e + f*x))/sqrt(b*cos(e + f*x)), Int((A + B*cos(e + f*x))/((-b*cos(e + f*x))**(S(3)/2)*sqrt(c + d*cos(e + f*x))), x), x) rule2895 = ReplacementRule(pattern2895, replacement2895) pattern2896 = Pattern(Integral((A_ + WC('B', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))/((a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**(S(3)/2)*sqrt(c_ + WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons71, cons1267, cons1323, cons1428, cons1345) def replacement2896(B, f, b, d, a, c, A, x, e): rubi.append(2896) return Simp(-S(2)*A*sqrt((-a*d + b*c)*(sin(e + f*x) + S(1))/((a + b*sin(e + f*x))*(c - d)))*sqrt(-(-a*d + b*c)*(-sin(e + f*x) + S(1))/((a + b*sin(e + f*x))*(c + d)))*(a + b*sin(e + f*x))*(c - d)*EllipticE(asin(sqrt(c + d*sin(e + f*x))*Rt((a + b)/(c + d), S(2))/sqrt(a + b*sin(e + f*x))), (a - b)*(c + d)/((a + b)*(c - d)))/(f*(-a*d + b*c)**S(2)*Rt((a + b)/(c + d), S(2))*cos(e + f*x)), x) rule2896 = ReplacementRule(pattern2896, replacement2896) pattern2897 = Pattern(Integral((A_ + WC('B', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))/((a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**(S(3)/2)*sqrt(c_ + WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons71, cons1267, cons1323, cons1428, cons1345) def replacement2897(B, f, b, d, a, c, A, x, e): rubi.append(2897) return Simp(S(2)*A*sqrt((-a*d + b*c)*(cos(e + f*x) + S(1))/((a + b*cos(e + f*x))*(c - d)))*sqrt(-(-a*d + b*c)*(-cos(e + f*x) + S(1))/((a + b*cos(e + f*x))*(c + d)))*(a + b*cos(e + f*x))*(c - d)*EllipticE(asin(sqrt(c + d*cos(e + f*x))*Rt((a + b)/(c + d), S(2))/sqrt(a + b*cos(e + f*x))), (a - b)*(c + d)/((a + b)*(c - d)))/(f*(-a*d + b*c)**S(2)*Rt((a + b)/(c + d), S(2))*sin(e + f*x)), x) rule2897 = ReplacementRule(pattern2897, replacement2897) pattern2898 = Pattern(Integral((A_ + WC('B', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))/((a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**(S(3)/2)*sqrt(c_ + WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons71, cons1267, cons1323, cons1428, cons1346) def replacement2898(B, f, b, d, a, c, A, x, e): rubi.append(2898) return Dist(sqrt(-c - d*sin(e + f*x))/sqrt(c + d*sin(e + f*x)), Int((A + B*sin(e + f*x))/((a + b*sin(e + f*x))**(S(3)/2)*sqrt(-c - d*sin(e + f*x))), x), x) rule2898 = ReplacementRule(pattern2898, replacement2898) pattern2899 = Pattern(Integral((A_ + WC('B', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))/((a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**(S(3)/2)*sqrt(c_ + WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons71, cons1267, cons1323, cons1428, cons1346) def replacement2899(B, f, b, d, a, c, A, x, e): rubi.append(2899) return Dist(sqrt(-c - d*cos(e + f*x))/sqrt(c + d*cos(e + f*x)), Int((A + B*cos(e + f*x))/((a + b*cos(e + f*x))**(S(3)/2)*sqrt(-c - d*cos(e + f*x))), x), x) rule2899 = ReplacementRule(pattern2899, replacement2899) pattern2900 = Pattern(Integral((WC('A', S(0)) + WC('B', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))/(sqrt(c_ + WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))*(WC('a', S(0)) + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**(S(3)/2)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons71, cons1267, cons1323, cons1429) def replacement2900(B, e, f, b, d, a, c, x, A): rubi.append(2900) return Dist((A - B)/(a - b), Int(S(1)/(sqrt(a + b*sin(e + f*x))*sqrt(c + d*sin(e + f*x))), x), x) - Dist((A*b - B*a)/(a - b), Int((sin(e + f*x) + S(1))/((a + b*sin(e + f*x))**(S(3)/2)*sqrt(c + d*sin(e + f*x))), x), x) rule2900 = ReplacementRule(pattern2900, replacement2900) pattern2901 = Pattern(Integral((WC('A', S(0)) + WC('B', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))/(sqrt(c_ + WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))*(WC('a', S(0)) + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**(S(3)/2)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons71, cons1267, cons1323, cons1429) def replacement2901(B, e, f, b, d, a, c, x, A): rubi.append(2901) return Dist((A - B)/(a - b), Int(S(1)/(sqrt(a + b*cos(e + f*x))*sqrt(c + d*cos(e + f*x))), x), x) - Dist((A*b - B*a)/(a - b), Int((cos(e + f*x) + S(1))/((a + b*cos(e + f*x))**(S(3)/2)*sqrt(c + d*cos(e + f*x))), x), x) rule2901 = ReplacementRule(pattern2901, replacement2901) pattern2902 = Pattern(Integral((WC('A', S(0)) + WC('B', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))*(WC('a', S(0)) + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons71, cons1267, cons1323, cons93, cons94, cons88) def replacement2902(B, e, m, f, b, d, a, c, n, x, A): rubi.append(2902) return Dist(S(1)/((a**S(2) - b**S(2))*(m + S(1))), Int((a + b*sin(e + f*x))**(m + S(1))*(c + d*sin(e + f*x))**(n + S(-1))*Simp(c*(m + S(1))*(A*a - B*b) + d*n*(A*b - B*a) - d*(A*b - B*a)*(m + n + S(2))*sin(e + f*x)**S(2) + (-c*(m + S(2))*(A*b - B*a) + d*(m + S(1))*(A*a - B*b))*sin(e + f*x), x), x), x) + Simp((a + b*sin(e + f*x))**(m + S(1))*(c + d*sin(e + f*x))**n*(-A*b + B*a)*cos(e + f*x)/(f*(a**S(2) - b**S(2))*(m + S(1))), x) rule2902 = ReplacementRule(pattern2902, replacement2902) pattern2903 = Pattern(Integral((WC('A', S(0)) + WC('B', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))*(WC('a', S(0)) + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons71, cons1267, cons1323, cons93, cons94, cons88) def replacement2903(B, e, m, f, b, d, a, c, n, x, A): rubi.append(2903) return Dist(S(1)/((a**S(2) - b**S(2))*(m + S(1))), Int((a + b*cos(e + f*x))**(m + S(1))*(c + d*cos(e + f*x))**(n + S(-1))*Simp(c*(m + S(1))*(A*a - B*b) + d*n*(A*b - B*a) - d*(A*b - B*a)*(m + n + S(2))*cos(e + f*x)**S(2) + (-c*(m + S(2))*(A*b - B*a) + d*(m + S(1))*(A*a - B*b))*cos(e + f*x), x), x), x) - Simp((a + b*cos(e + f*x))**(m + S(1))*(c + d*cos(e + f*x))**n*(-A*b + B*a)*sin(e + f*x)/(f*(a**S(2) - b**S(2))*(m + S(1))), x) rule2903 = ReplacementRule(pattern2903, replacement2903) pattern2904 = Pattern(Integral((WC('A', S(0)) + WC('B', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))*(WC('a', S(0)) + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons4, cons71, cons1267, cons1323, cons31, cons94, cons1337) def replacement2904(B, e, m, f, b, d, a, c, n, x, A): rubi.append(2904) return Dist(S(1)/((a**S(2) - b**S(2))*(m + S(1))*(-a*d + b*c)), Int((a + b*sin(e + f*x))**(m + S(1))*(c + d*sin(e + f*x))**n*Simp(b*d*(A*b - B*a)*(m + n + S(2)) - b*d*(A*b - B*a)*(m + n + S(3))*sin(e + f*x)**S(2) + (m + S(1))*(A*a - B*b)*(-a*d + b*c) + (A*b - B*a)*(a*d*(m + S(1)) - b*c*(m + S(2)))*sin(e + f*x), x), x), x) - Simp((a + b*sin(e + f*x))**(m + S(1))*(c + d*sin(e + f*x))**(n + S(1))*(A*b**S(2) - B*a*b)*cos(e + f*x)/(f*(a**S(2) - b**S(2))*(m + S(1))*(-a*d + b*c)), x) rule2904 = ReplacementRule(pattern2904, replacement2904) pattern2905 = Pattern(Integral((WC('A', S(0)) + WC('B', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))*(WC('a', S(0)) + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons4, cons71, cons1267, cons1323, cons31, cons94, cons1337) def replacement2905(B, e, m, f, b, d, a, c, n, x, A): rubi.append(2905) return Dist(S(1)/((a**S(2) - b**S(2))*(m + S(1))*(-a*d + b*c)), Int((a + b*cos(e + f*x))**(m + S(1))*(c + d*cos(e + f*x))**n*Simp(b*d*(A*b - B*a)*(m + n + S(2)) - b*d*(A*b - B*a)*(m + n + S(3))*cos(e + f*x)**S(2) + (m + S(1))*(A*a - B*b)*(-a*d + b*c) + (A*b - B*a)*(a*d*(m + S(1)) - b*c*(m + S(2)))*cos(e + f*x), x), x), x) + Simp((a + b*cos(e + f*x))**(m + S(1))*(c + d*cos(e + f*x))**(n + S(1))*(A*b**S(2) - B*a*b)*sin(e + f*x)/(f*(a**S(2) - b**S(2))*(m + S(1))*(-a*d + b*c)), x) rule2905 = ReplacementRule(pattern2905, replacement2905) pattern2906 = Pattern(Integral((WC('A', S(0)) + WC('B', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))/((WC('a', S(0)) + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))*(WC('c', S(0)) + WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons71, cons1267, cons1323) def replacement2906(B, e, f, b, d, a, c, x, A): rubi.append(2906) return Dist((A*b - B*a)/(-a*d + b*c), Int(S(1)/(a + b*sin(e + f*x)), x), x) + Dist((-A*d + B*c)/(-a*d + b*c), Int(S(1)/(c + d*sin(e + f*x)), x), x) rule2906 = ReplacementRule(pattern2906, replacement2906) pattern2907 = Pattern(Integral((WC('A', S(0)) + WC('B', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))/((WC('a', S(0)) + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))*(WC('c', S(0)) + WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons71, cons1267, cons1323) def replacement2907(B, e, f, b, d, a, c, x, A): rubi.append(2907) return Dist((A*b - B*a)/(-a*d + b*c), Int(S(1)/(a + b*cos(e + f*x)), x), x) + Dist((-A*d + B*c)/(-a*d + b*c), Int(S(1)/(c + d*cos(e + f*x)), x), x) rule2907 = ReplacementRule(pattern2907, replacement2907) pattern2908 = Pattern(Integral((WC('A', S(0)) + WC('B', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))*(WC('a', S(0)) + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_/(WC('c', S(0)) + WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons21, cons71, cons1267, cons1323) def replacement2908(B, e, m, f, b, d, a, c, x, A): rubi.append(2908) return Dist(B/d, Int((a + b*sin(e + f*x))**m, x), x) - Dist((-A*d + B*c)/d, Int((a + b*sin(e + f*x))**m/(c + d*sin(e + f*x)), x), x) rule2908 = ReplacementRule(pattern2908, replacement2908) pattern2909 = Pattern(Integral((WC('A', S(0)) + WC('B', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))*(WC('a', S(0)) + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_/(WC('c', S(0)) + WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons21, cons71, cons1267, cons1323) def replacement2909(B, e, m, f, b, d, a, c, x, A): rubi.append(2909) return Dist(B/d, Int((a + b*cos(e + f*x))**m, x), x) - Dist((-A*d + B*c)/d, Int((a + b*cos(e + f*x))**m/(c + d*cos(e + f*x)), x), x) rule2909 = ReplacementRule(pattern2909, replacement2909) pattern2910 = Pattern(Integral((WC('A', S(0)) + WC('B', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))*sqrt(WC('a', S(0)) + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))*(WC('c', S(0)) + WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons71, cons1267, cons1323, cons87, cons1430) def replacement2910(B, e, f, b, d, a, c, n, x, A): rubi.append(2910) return Dist(S(1)/(S(2)*n + S(3)), Int((c + d*sin(e + f*x))**(n + S(-1))*Simp(A*a*c*(S(2)*n + S(3)) + B*(S(2)*a*d*n + b*c) + (A*(S(2)*n + S(3))*(a*d + b*c) + B*(S(2)*n + S(1))*(a*c + b*d))*sin(e + f*x) + (A*b*d*(S(2)*n + S(3)) + B*(a*d + S(2)*b*c*n))*sin(e + f*x)**S(2), x)/sqrt(a + b*sin(e + f*x)), x), x) + Simp(-S(2)*B*sqrt(a + b*sin(e + f*x))*(c + d*sin(e + f*x))**n*cos(e + f*x)/(f*(S(2)*n + S(3))), x) rule2910 = ReplacementRule(pattern2910, replacement2910) pattern2911 = Pattern(Integral((WC('A', S(0)) + WC('B', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))*sqrt(WC('a', S(0)) + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))*(WC('c', S(0)) + WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons71, cons1267, cons1323, cons87, cons1430) def replacement2911(B, e, f, b, d, a, c, n, x, A): rubi.append(2911) return Dist(S(1)/(S(2)*n + S(3)), Int((c + d*cos(e + f*x))**(n + S(-1))*Simp(A*a*c*(S(2)*n + S(3)) + B*(S(2)*a*d*n + b*c) + (A*(S(2)*n + S(3))*(a*d + b*c) + B*(S(2)*n + S(1))*(a*c + b*d))*cos(e + f*x) + (A*b*d*(S(2)*n + S(3)) + B*(a*d + S(2)*b*c*n))*cos(e + f*x)**S(2), x)/sqrt(a + b*cos(e + f*x)), x), x) + Simp(S(2)*B*sqrt(a + b*cos(e + f*x))*(c + d*cos(e + f*x))**n*sin(e + f*x)/(f*(S(2)*n + S(3))), x) rule2911 = ReplacementRule(pattern2911, replacement2911) pattern2912 = Pattern(Integral((A_ + WC('B', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))/(sqrt(a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))*sqrt(sin(x_*WC('f', S(1)) + WC('e', S(0))))), x_), cons2, cons3, cons48, cons125, cons34, cons35, cons105, cons1411, cons1428) def replacement2912(B, f, b, a, A, x, e): rubi.append(2912) return Simp(S(4)*A*EllipticPi(S(-1), -asin(cos(e + f*x)/(sin(e + f*x) + S(1))), -(a - b)/(a + b))/(f*sqrt(a + b)), x) rule2912 = ReplacementRule(pattern2912, replacement2912) pattern2913 = Pattern(Integral((A_ + WC('B', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))/(sqrt(a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))*sqrt(cos(x_*WC('f', S(1)) + WC('e', S(0))))), x_), cons2, cons3, cons48, cons125, cons34, cons35, cons105, cons1411, cons1428) def replacement2913(B, f, b, a, A, x, e): rubi.append(2913) return Simp(S(4)*A*EllipticPi(S(-1), asin(sin(e + f*x)/(cos(e + f*x) + S(1))), -(a - b)/(a + b))/(f*sqrt(a + b)), x) rule2913 = ReplacementRule(pattern2913, replacement2913) pattern2914 = Pattern(Integral((A_ + WC('B', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))/(sqrt(d_*sin(x_*WC('f', S(1)) + WC('e', S(0))))*sqrt(a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))), x_), cons2, cons3, cons48, cons125, cons27, cons34, cons35, cons105, cons1411, cons1428) def replacement2914(B, f, b, d, a, A, x, e): rubi.append(2914) return Dist(sqrt(sin(e + f*x))/sqrt(d*sin(e + f*x)), Int((A + B*sin(e + f*x))/(sqrt(a + b*sin(e + f*x))*sqrt(sin(e + f*x))), x), x) rule2914 = ReplacementRule(pattern2914, replacement2914) pattern2915 = Pattern(Integral((A_ + WC('B', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))/(sqrt(d_*cos(x_*WC('f', S(1)) + WC('e', S(0))))*sqrt(a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))), x_), cons2, cons3, cons48, cons125, cons27, cons34, cons35, cons105, cons1411, cons1428) def replacement2915(B, f, b, d, a, A, x, e): rubi.append(2915) return Dist(sqrt(cos(e + f*x))/sqrt(d*cos(e + f*x)), Int((A + B*cos(e + f*x))/(sqrt(a + b*cos(e + f*x))*sqrt(cos(e + f*x))), x), x) rule2915 = ReplacementRule(pattern2915, replacement2915) pattern2916 = Pattern(Integral((WC('A', S(0)) + WC('B', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))/(sqrt(a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))*sqrt(WC('c', S(0)) + WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons71, cons1267, cons1323) def replacement2916(B, e, f, b, d, c, a, x, A): rubi.append(2916) return Dist(B/d, Int(sqrt(c + d*sin(e + f*x))/sqrt(a + b*sin(e + f*x)), x), x) - Dist((-A*d + B*c)/d, Int(S(1)/(sqrt(a + b*sin(e + f*x))*sqrt(c + d*sin(e + f*x))), x), x) rule2916 = ReplacementRule(pattern2916, replacement2916) pattern2917 = Pattern(Integral((WC('A', S(0)) + WC('B', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))/(sqrt(a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))*sqrt(WC('c', S(0)) + WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons71, cons1267, cons1323) def replacement2917(B, f, b, d, c, a, A, x, e): rubi.append(2917) return Dist(B/d, Int(sqrt(c + d*cos(e + f*x))/sqrt(a + b*cos(e + f*x)), x), x) - Dist((-A*d + B*c)/d, Int(S(1)/(sqrt(a + b*cos(e + f*x))*sqrt(c + d*cos(e + f*x))), x), x) rule2917 = ReplacementRule(pattern2917, replacement2917) pattern2918 = Pattern(Integral((WC('A', S(0)) + WC('B', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))*(WC('a', S(0)) + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons21, cons4, cons71, cons1267, cons1323) def replacement2918(B, e, m, f, b, d, a, c, n, x, A): rubi.append(2918) return Int((A + B*sin(e + f*x))*(a + b*sin(e + f*x))**m*(c + d*sin(e + f*x))**n, x) rule2918 = ReplacementRule(pattern2918, replacement2918) pattern2919 = Pattern(Integral((WC('A', S(0)) + WC('B', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))*(WC('a', S(0)) + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons21, cons4, cons71, cons1267, cons1323) def replacement2919(B, e, m, f, b, d, a, c, n, x, A): rubi.append(2919) return Int((A + B*cos(e + f*x))*(a + b*cos(e + f*x))**m*(c + d*cos(e + f*x))**n, x) rule2919 = ReplacementRule(pattern2919, replacement2919) pattern2920 = Pattern(Integral((a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(c_ + WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1))*(WC('A', S(0)) + WC('B', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**p_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons21, cons4, cons5, cons70, cons1265) def replacement2920(B, p, e, m, f, b, d, a, n, c, x, A): rubi.append(2920) return Dist(sqrt(a + b*sin(e + f*x))*sqrt(c + d*sin(e + f*x))/(f*cos(e + f*x)), Subst(Int((A + B*x)**p*(a + b*x)**(m + S(-1)/2)*(c + d*x)**(n + S(-1)/2), x), x, sin(e + f*x)), x) rule2920 = ReplacementRule(pattern2920, replacement2920) pattern2921 = Pattern(Integral((a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(c_ + WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1))*(WC('A', S(0)) + WC('B', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**p_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons21, cons4, cons5, cons70, cons1265) def replacement2921(B, p, m, f, b, d, a, n, c, A, x, e): rubi.append(2921) return -Dist(sqrt(a + b*cos(e + f*x))*sqrt(c + d*cos(e + f*x))/(f*sin(e + f*x)), Subst(Int((A + B*x)**p*(a + b*x)**(m + S(-1)/2)*(c + d*x)**(n + S(-1)/2), x), x, cos(e + f*x)), x) rule2921 = ReplacementRule(pattern2921, replacement2921) pattern2922 = Pattern(Integral((WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(WC('B', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))) + WC('C', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0)))**S(2)), x_), cons3, cons48, cons125, cons35, cons36, cons21, cons1431) def replacement2922(B, C, m, f, b, x, e): rubi.append(2922) return Dist(S(1)/b, Int((b*sin(e + f*x))**(m + S(1))*(B + C*sin(e + f*x)), x), x) rule2922 = ReplacementRule(pattern2922, replacement2922) pattern2923 = Pattern(Integral((WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(WC('B', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))) + WC('C', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0)))**S(2)), x_), cons3, cons48, cons125, cons35, cons36, cons21, cons1431) def replacement2923(B, C, m, f, b, x, e): rubi.append(2923) return Dist(S(1)/b, Int((b*cos(e + f*x))**(m + S(1))*(B + C*cos(e + f*x)), x), x) rule2923 = ReplacementRule(pattern2923, replacement2923) pattern2924 = Pattern(Integral((A_ + WC('C', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0)))**S(2))*sin(x_*WC('f', S(1)) + WC('e', S(0)))**WC('m', S(1)), x_), cons48, cons125, cons34, cons36, cons1228) def replacement2924(C, m, f, A, x, e): rubi.append(2924) return -Dist(S(1)/f, Subst(Int((-x**S(2) + S(1))**(m/S(2) + S(-1)/2)*(A - C*x**S(2) + C), x), x, cos(e + f*x)), x) rule2924 = ReplacementRule(pattern2924, replacement2924) pattern2925 = Pattern(Integral((A_ + WC('C', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0)))**S(2))*cos(x_*WC('f', S(1)) + WC('e', S(0)))**WC('m', S(1)), x_), cons48, cons125, cons34, cons36, cons1228) def replacement2925(C, m, f, A, x, e): rubi.append(2925) return Dist(S(1)/f, Subst(Int((-x**S(2) + S(1))**(m/S(2) + S(-1)/2)*(A - C*x**S(2) + C), x), x, sin(e + f*x)), x) rule2925 = ReplacementRule(pattern2925, replacement2925) pattern2926 = Pattern(Integral((WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(A_ + WC('C', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0)))**S(2)), x_), cons3, cons48, cons125, cons34, cons36, cons21, cons1432) def replacement2926(C, m, f, b, A, x, e): rubi.append(2926) return Simp(A*(b*sin(e + f*x))**(m + S(1))*cos(e + f*x)/(b*f*(m + S(1))), x) rule2926 = ReplacementRule(pattern2926, replacement2926) pattern2927 = Pattern(Integral((WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(A_ + WC('C', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0)))**S(2)), x_), cons3, cons48, cons125, cons34, cons36, cons21, cons1432) def replacement2927(C, m, f, b, A, x, e): rubi.append(2927) return -Simp(A*(b*cos(e + f*x))**(m + S(1))*sin(e + f*x)/(b*f*(m + S(1))), x) rule2927 = ReplacementRule(pattern2927, replacement2927) pattern2928 = Pattern(Integral((WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(A_ + WC('C', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0)))**S(2)), x_), cons3, cons48, cons125, cons34, cons36, cons31, cons94) def replacement2928(C, m, f, b, A, x, e): rubi.append(2928) return Dist((A*(m + S(2)) + C*(m + S(1)))/(b**S(2)*(m + S(1))), Int((b*sin(e + f*x))**(m + S(2)), x), x) + Simp(A*(b*sin(e + f*x))**(m + S(1))*cos(e + f*x)/(b*f*(m + S(1))), x) rule2928 = ReplacementRule(pattern2928, replacement2928) pattern2929 = Pattern(Integral((WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(A_ + WC('C', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0)))**S(2)), x_), cons3, cons48, cons125, cons34, cons36, cons31, cons94) def replacement2929(C, m, f, b, A, x, e): rubi.append(2929) return Dist((A*(m + S(2)) + C*(m + S(1)))/(b**S(2)*(m + S(1))), Int((b*cos(e + f*x))**(m + S(2)), x), x) - Simp(A*(b*cos(e + f*x))**(m + S(1))*sin(e + f*x)/(b*f*(m + S(1))), x) rule2929 = ReplacementRule(pattern2929, replacement2929) pattern2930 = Pattern(Integral((WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(A_ + WC('C', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0)))**S(2)), x_), cons3, cons48, cons125, cons34, cons36, cons21, cons272) def replacement2930(C, m, f, b, A, x, e): rubi.append(2930) return Dist((A*(m + S(2)) + C*(m + S(1)))/(m + S(2)), Int((b*sin(e + f*x))**m, x), x) - Simp(C*(b*sin(e + f*x))**(m + S(1))*cos(e + f*x)/(b*f*(m + S(2))), x) rule2930 = ReplacementRule(pattern2930, replacement2930) pattern2931 = Pattern(Integral((WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(A_ + WC('C', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0)))**S(2)), x_), cons3, cons48, cons125, cons34, cons36, cons21, cons272) def replacement2931(C, m, f, b, A, x, e): rubi.append(2931) return Dist((A*(m + S(2)) + C*(m + S(1)))/(m + S(2)), Int((b*cos(e + f*x))**m, x), x) + Simp(C*(b*cos(e + f*x))**(m + S(1))*sin(e + f*x)/(b*f*(m + S(2))), x) rule2931 = ReplacementRule(pattern2931, replacement2931) pattern2932 = Pattern(Integral((a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(WC('A', S(0)) + WC('B', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))) + WC('C', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0)))**S(2)), x_), cons2, cons3, cons48, cons125, cons34, cons35, cons36, cons21, cons33) def replacement2932(B, C, e, m, f, b, a, x, A): rubi.append(2932) return Dist(b**(S(-2)), Int((a + b*sin(e + f*x))**(m + S(1))*Simp(B*b - C*a + C*b*sin(e + f*x), x), x), x) rule2932 = ReplacementRule(pattern2932, replacement2932) pattern2933 = Pattern(Integral((a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(WC('A', S(0)) + WC('B', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))) + WC('C', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0)))**S(2)), x_), cons2, cons3, cons48, cons125, cons34, cons35, cons36, cons21, cons33) def replacement2933(B, C, m, f, b, a, A, x, e): rubi.append(2933) return Dist(b**(S(-2)), Int((a + b*cos(e + f*x))**(m + S(1))*Simp(B*b - C*a + C*b*cos(e + f*x), x), x), x) rule2933 = ReplacementRule(pattern2933, replacement2933) pattern2934 = Pattern(Integral((a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(WC('A', S(0)) + WC('C', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0)))**S(2)), x_), cons2, cons3, cons48, cons125, cons34, cons36, cons21, cons1433) def replacement2934(C, e, m, f, b, a, x, A): rubi.append(2934) return Dist(C/b**S(2), Int((a + b*sin(e + f*x))**(m + S(1))*Simp(-a + b*sin(e + f*x), x), x), x) rule2934 = ReplacementRule(pattern2934, replacement2934) pattern2935 = Pattern(Integral((a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(WC('A', S(0)) + WC('C', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0)))**S(2)), x_), cons2, cons3, cons48, cons125, cons34, cons36, cons21, cons1433) def replacement2935(C, m, f, b, a, A, x, e): rubi.append(2935) return Dist(C/b**S(2), Int((a + b*cos(e + f*x))**(m + S(1))*Simp(-a + b*cos(e + f*x), x), x), x) rule2935 = ReplacementRule(pattern2935, replacement2935) pattern2936 = Pattern(Integral((a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(WC('A', S(0)) + WC('B', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))) + WC('C', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0)))**S(2)), x_), cons2, cons3, cons48, cons125, cons34, cons35, cons36, cons21, cons1434, cons77) def replacement2936(B, C, e, m, f, b, a, x, A): rubi.append(2936) return Dist(C, Int((a + b*sin(e + f*x))**m*(sin(e + f*x) + S(1))**S(2), x), x) + Dist(A - C, Int((a + b*sin(e + f*x))**m*(sin(e + f*x) + S(1)), x), x) rule2936 = ReplacementRule(pattern2936, replacement2936) pattern2937 = Pattern(Integral((a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(WC('A', S(0)) + WC('B', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))) + WC('C', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0)))**S(2)), x_), cons2, cons3, cons48, cons125, cons34, cons35, cons36, cons21, cons1434, cons77) def replacement2937(B, C, m, f, b, a, A, x, e): rubi.append(2937) return Dist(C, Int((a + b*cos(e + f*x))**m*(cos(e + f*x) + S(1))**S(2), x), x) + Dist(A - C, Int((a + b*cos(e + f*x))**m*(cos(e + f*x) + S(1)), x), x) rule2937 = ReplacementRule(pattern2937, replacement2937) pattern2938 = Pattern(Integral((a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(WC('A', S(0)) + WC('C', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0)))**S(2)), x_), cons2, cons3, cons48, cons125, cons34, cons36, cons21, cons1435, cons77) def replacement2938(C, e, m, f, b, a, x, A): rubi.append(2938) return Dist(C, Int((a + b*sin(e + f*x))**m*(sin(e + f*x) + S(1))**S(2), x), x) + Dist(A - C, Int((a + b*sin(e + f*x))**m*(sin(e + f*x) + S(1)), x), x) rule2938 = ReplacementRule(pattern2938, replacement2938) pattern2939 = Pattern(Integral((a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(WC('A', S(0)) + WC('C', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0)))**S(2)), x_), cons2, cons3, cons48, cons125, cons34, cons36, cons21, cons1435, cons77) def replacement2939(C, m, f, b, a, A, x, e): rubi.append(2939) return Dist(C, Int((a + b*cos(e + f*x))**m*(cos(e + f*x) + S(1))**S(2), x), x) + Dist(A - C, Int((a + b*cos(e + f*x))**m*(cos(e + f*x) + S(1)), x), x) rule2939 = ReplacementRule(pattern2939, replacement2939) pattern2940 = Pattern(Integral((a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('A', S(0)) + WC('B', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))) + WC('C', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0)))**S(2)), x_), cons2, cons3, cons48, cons125, cons34, cons35, cons36, cons31, cons94, cons1265) def replacement2940(B, C, e, m, f, b, a, x, A): rubi.append(2940) return Dist(S(1)/(a**S(2)*(S(2)*m + S(1))), Int((a + b*sin(e + f*x))**(m + S(1))*Simp(A*a*(m + S(1)) + C*b*(S(2)*m + S(1))*sin(e + f*x) + m*(B*b - C*a), x), x), x) + Simp((a + b*sin(e + f*x))**m*(A*b - B*a + C*b)*cos(e + f*x)/(a*f*(S(2)*m + S(1))), x) rule2940 = ReplacementRule(pattern2940, replacement2940) pattern2941 = Pattern(Integral((a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('A', S(0)) + WC('B', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))) + WC('C', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0)))**S(2)), x_), cons2, cons3, cons48, cons125, cons34, cons35, cons36, cons31, cons94, cons1265) def replacement2941(B, C, m, f, b, a, A, x, e): rubi.append(2941) return Dist(S(1)/(a**S(2)*(S(2)*m + S(1))), Int((a + b*cos(e + f*x))**(m + S(1))*Simp(A*a*(m + S(1)) + C*b*(S(2)*m + S(1))*cos(e + f*x) + m*(B*b - C*a), x), x), x) - Simp((a + b*cos(e + f*x))**m*(A*b - B*a + C*b)*sin(e + f*x)/(a*f*(S(2)*m + S(1))), x) rule2941 = ReplacementRule(pattern2941, replacement2941) pattern2942 = Pattern(Integral((a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('A', S(0)) + WC('C', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0)))**S(2)), x_), cons2, cons3, cons48, cons125, cons34, cons36, cons31, cons94, cons1265) def replacement2942(C, e, m, f, b, a, x, A): rubi.append(2942) return Dist(S(1)/(a**S(2)*(S(2)*m + S(1))), Int((a + b*sin(e + f*x))**(m + S(1))*Simp(A*a*(m + S(1)) - C*a*m + C*b*(S(2)*m + S(1))*sin(e + f*x), x), x), x) + Simp(b*(A + C)*(a + b*sin(e + f*x))**m*cos(e + f*x)/(a*f*(S(2)*m + S(1))), x) rule2942 = ReplacementRule(pattern2942, replacement2942) pattern2943 = Pattern(Integral((a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('A', S(0)) + WC('C', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0)))**S(2)), x_), cons2, cons3, cons48, cons125, cons34, cons36, cons31, cons94, cons1265) def replacement2943(C, m, f, b, a, A, x, e): rubi.append(2943) return Dist(S(1)/(a**S(2)*(S(2)*m + S(1))), Int((a + b*cos(e + f*x))**(m + S(1))*Simp(A*a*(m + S(1)) - C*a*m + C*b*(S(2)*m + S(1))*cos(e + f*x), x), x), x) - Simp(b*(A + C)*(a + b*cos(e + f*x))**m*sin(e + f*x)/(a*f*(S(2)*m + S(1))), x) rule2943 = ReplacementRule(pattern2943, replacement2943) pattern2944 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('A', S(0)) + WC('B', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))) + WC('C', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0)))**S(2)), x_), cons2, cons3, cons48, cons125, cons34, cons35, cons36, cons31, cons94, cons1267) def replacement2944(B, C, e, m, f, b, a, x, A): rubi.append(2944) return Dist(S(1)/(b*(a**S(2) - b**S(2))*(m + S(1))), Int((a + b*sin(e + f*x))**(m + S(1))*Simp(b*(m + S(1))*(A*a - B*b + C*a) - (A*b**S(2) - B*a*b + C*a**S(2) + b*(m + S(1))*(A*b - B*a + C*b))*sin(e + f*x), x), x), x) - Simp((a + b*sin(e + f*x))**(m + S(1))*(A*b**S(2) - B*a*b + C*a**S(2))*cos(e + f*x)/(b*f*(a**S(2) - b**S(2))*(m + S(1))), x) rule2944 = ReplacementRule(pattern2944, replacement2944) pattern2945 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('A', S(0)) + WC('B', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))) + WC('C', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0)))**S(2)), x_), cons2, cons3, cons48, cons125, cons34, cons35, cons36, cons31, cons94, cons1267) def replacement2945(B, C, e, m, f, b, a, x, A): rubi.append(2945) return Dist(S(1)/(b*(a**S(2) - b**S(2))*(m + S(1))), Int((a + b*cos(e + f*x))**(m + S(1))*Simp(b*(m + S(1))*(A*a - B*b + C*a) - (A*b**S(2) - B*a*b + C*a**S(2) + b*(m + S(1))*(A*b - B*a + C*b))*cos(e + f*x), x), x), x) + Simp((a + b*cos(e + f*x))**(m + S(1))*(A*b**S(2) - B*a*b + C*a**S(2))*sin(e + f*x)/(b*f*(a**S(2) - b**S(2))*(m + S(1))), x) rule2945 = ReplacementRule(pattern2945, replacement2945) pattern2946 = Pattern(Integral((a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('A', S(0)) + WC('C', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0)))**S(2)), x_), cons2, cons3, cons48, cons125, cons34, cons36, cons31, cons94, cons1267) def replacement2946(C, e, m, f, b, a, x, A): rubi.append(2946) return Dist(S(1)/(b*(a**S(2) - b**S(2))*(m + S(1))), Int((a + b*sin(e + f*x))**(m + S(1))*Simp(a*b*(A + C)*(m + S(1)) - (A*b**S(2) + C*a**S(2) + b**S(2)*(A + C)*(m + S(1)))*sin(e + f*x), x), x), x) - Simp((a + b*sin(e + f*x))**(m + S(1))*(A*b**S(2) + C*a**S(2))*cos(e + f*x)/(b*f*(a**S(2) - b**S(2))*(m + S(1))), x) rule2946 = ReplacementRule(pattern2946, replacement2946) pattern2947 = Pattern(Integral((a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('A', S(0)) + WC('C', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0)))**S(2)), x_), cons2, cons3, cons48, cons125, cons34, cons36, cons31, cons94, cons1267) def replacement2947(C, m, f, b, a, A, x, e): rubi.append(2947) return Dist(S(1)/(b*(a**S(2) - b**S(2))*(m + S(1))), Int((a + b*cos(e + f*x))**(m + S(1))*Simp(a*b*(A + C)*(m + S(1)) - (A*b**S(2) + C*a**S(2) + b**S(2)*(A + C)*(m + S(1)))*cos(e + f*x), x), x), x) + Simp((a + b*cos(e + f*x))**(m + S(1))*(A*b**S(2) + C*a**S(2))*sin(e + f*x)/(b*f*(a**S(2) - b**S(2))*(m + S(1))), x) rule2947 = ReplacementRule(pattern2947, replacement2947) pattern2948 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(WC('A', S(0)) + WC('B', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))) + WC('C', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0)))**S(2)), x_), cons2, cons3, cons48, cons125, cons34, cons35, cons36, cons21, cons272) def replacement2948(B, C, m, f, b, a, A, x, e): rubi.append(2948) return Dist(S(1)/(b*(m + S(2))), Int((a + b*sin(e + f*x))**m*Simp(A*b*(m + S(2)) + C*b*(m + S(1)) + (B*b*(m + S(2)) - C*a)*sin(e + f*x), x), x), x) - Simp(C*(a + b*sin(e + f*x))**(m + S(1))*cos(e + f*x)/(b*f*(m + S(2))), x) rule2948 = ReplacementRule(pattern2948, replacement2948) pattern2949 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(WC('A', S(0)) + WC('B', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))) + WC('C', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0)))**S(2)), x_), cons2, cons3, cons48, cons125, cons34, cons35, cons36, cons21, cons272) def replacement2949(B, C, m, f, b, a, A, x, e): rubi.append(2949) return Dist(S(1)/(b*(m + S(2))), Int((a + b*cos(e + f*x))**m*Simp(A*b*(m + S(2)) + C*b*(m + S(1)) + (B*b*(m + S(2)) - C*a)*cos(e + f*x), x), x), x) + Simp(C*(a + b*cos(e + f*x))**(m + S(1))*sin(e + f*x)/(b*f*(m + S(2))), x) rule2949 = ReplacementRule(pattern2949, replacement2949) pattern2950 = Pattern(Integral((a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(WC('A', S(0)) + WC('C', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0)))**S(2)), x_), cons2, cons3, cons48, cons125, cons34, cons36, cons21, cons272) def replacement2950(C, e, m, f, b, a, x, A): rubi.append(2950) return Dist(S(1)/(b*(m + S(2))), Int((a + b*sin(e + f*x))**m*Simp(A*b*(m + S(2)) - C*a*sin(e + f*x) + C*b*(m + S(1)), x), x), x) - Simp(C*(a + b*sin(e + f*x))**(m + S(1))*cos(e + f*x)/(b*f*(m + S(2))), x) rule2950 = ReplacementRule(pattern2950, replacement2950) pattern2951 = Pattern(Integral((a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(WC('A', S(0)) + WC('C', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0)))**S(2)), x_), cons2, cons3, cons48, cons125, cons34, cons36, cons21, cons272) def replacement2951(C, m, f, b, a, A, x, e): rubi.append(2951) return Dist(S(1)/(b*(m + S(2))), Int((a + b*cos(e + f*x))**m*Simp(A*b*(m + S(2)) - C*a*cos(e + f*x) + C*b*(m + S(1)), x), x), x) + Simp(C*(a + b*cos(e + f*x))**(m + S(1))*sin(e + f*x)/(b*f*(m + S(2))), x) rule2951 = ReplacementRule(pattern2951, replacement2951) pattern2952 = Pattern(Integral((WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0)))**p_)**m_*(WC('A', S(0)) + WC('B', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))) + WC('C', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0)))**S(2)), x_), cons3, cons48, cons125, cons34, cons35, cons36, cons21, cons5, cons18) def replacement2952(B, C, e, p, m, f, b, x, A): rubi.append(2952) return Dist((b*sin(e + f*x))**(-m*p)*(b*sin(e + f*x)**p)**m, Int((b*sin(e + f*x))**(m*p)*(A + B*sin(e + f*x) + C*sin(e + f*x)**S(2)), x), x) rule2952 = ReplacementRule(pattern2952, replacement2952) pattern2953 = Pattern(Integral((WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0)))**p_)**m_*(WC('A', S(0)) + WC('B', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))) + WC('C', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0)))**S(2)), x_), cons3, cons48, cons125, cons34, cons35, cons36, cons21, cons5, cons18) def replacement2953(B, C, e, p, m, f, b, x, A): rubi.append(2953) return Dist((b*cos(e + f*x))**(-m*p)*(b*cos(e + f*x)**p)**m, Int((b*cos(e + f*x))**(m*p)*(A + B*cos(e + f*x) + C*cos(e + f*x)**S(2)), x), x) rule2953 = ReplacementRule(pattern2953, replacement2953) pattern2954 = Pattern(Integral((WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0)))**p_)**m_*(WC('A', S(0)) + WC('C', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0)))**S(2)), x_), cons3, cons48, cons125, cons34, cons36, cons21, cons5, cons18) def replacement2954(C, e, p, m, f, b, x, A): rubi.append(2954) return Dist((b*sin(e + f*x))**(-m*p)*(b*sin(e + f*x)**p)**m, Int((b*sin(e + f*x))**(m*p)*(A + C*sin(e + f*x)**S(2)), x), x) rule2954 = ReplacementRule(pattern2954, replacement2954) pattern2955 = Pattern(Integral((WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0)))**p_)**m_*(WC('A', S(0)) + WC('C', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0)))**S(2)), x_), cons3, cons48, cons125, cons34, cons36, cons21, cons5, cons18) def replacement2955(C, e, p, m, f, b, x, A): rubi.append(2955) return Dist((b*cos(e + f*x))**(-m*p)*(b*cos(e + f*x)**p)**m, Int((b*cos(e + f*x))**(m*p)*(A + C*cos(e + f*x)**S(2)), x), x) rule2955 = ReplacementRule(pattern2955, replacement2955) pattern2956 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))*(WC('A', S(0)) + WC('B', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))) + WC('C', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0)))**S(2)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons36, cons71, cons1267, cons31, cons94) def replacement2956(B, C, m, f, b, d, c, a, A, x, e): rubi.append(2956) return -Dist(S(1)/(b**S(2)*(a**S(2) - b**S(2))*(m + S(1))), Int((a + b*sin(e + f*x))**(m + S(1))*Simp(-C*b*d*(a**S(2) - b**S(2))*(m + S(1))*sin(e + f*x)**S(2) + b*(m + S(1))*(-A*b*(a*c - b*d) + (B*b - C*a)*(-a*d + b*c)) + (B*b*(a**S(2)*d - a*b*c*(m + S(2)) + b**S(2)*d*(m + S(1))) + (-a*d + b*c)*(A*b**S(2)*(m + S(2)) + C*(a**S(2) + b**S(2)*(m + S(1)))))*sin(e + f*x), x), x), x) - Simp((a + b*sin(e + f*x))**(m + S(1))*(-a*d + b*c)*(A*b**S(2) - B*a*b + C*a**S(2))*cos(e + f*x)/(b**S(2)*f*(a**S(2) - b**S(2))*(m + S(1))), x) rule2956 = ReplacementRule(pattern2956, replacement2956) pattern2957 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))*(WC('A', S(0)) + WC('B', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))) + WC('C', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0)))**S(2)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons36, cons71, cons1267, cons31, cons94) def replacement2957(B, C, e, m, f, b, d, a, c, x, A): rubi.append(2957) return -Dist(S(1)/(b**S(2)*(a**S(2) - b**S(2))*(m + S(1))), Int((a + b*cos(e + f*x))**(m + S(1))*Simp(-C*b*d*(a**S(2) - b**S(2))*(m + S(1))*cos(e + f*x)**S(2) + b*(m + S(1))*(-A*b*(a*c - b*d) + (B*b - C*a)*(-a*d + b*c)) + (B*b*(a**S(2)*d - a*b*c*(m + S(2)) + b**S(2)*d*(m + S(1))) + (-a*d + b*c)*(A*b**S(2)*(m + S(2)) + C*(a**S(2) + b**S(2)*(m + S(1)))))*cos(e + f*x), x), x), x) + Simp((a + b*cos(e + f*x))**(m + S(1))*(-a*d + b*c)*(A*b**S(2) - B*a*b + C*a**S(2))*sin(e + f*x)/(b**S(2)*f*(a**S(2) - b**S(2))*(m + S(1))), x) rule2957 = ReplacementRule(pattern2957, replacement2957) pattern2958 = Pattern(Integral((WC('A', S(0)) + WC('C', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0)))**S(2))*(WC('a', S(0)) + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons36, cons71, cons1267, cons31, cons94) def replacement2958(C, m, f, b, d, c, a, A, x, e): rubi.append(2958) return Dist(S(1)/(b**S(2)*(a**S(2) - b**S(2))*(m + S(1))), Int((a + b*sin(e + f*x))**(m + S(1))*Simp(C*b*d*(a**S(2) - b**S(2))*(m + S(1))*sin(e + f*x)**S(2) + b*(m + S(1))*(A*b*(a*c - b*d) + C*a*(-a*d + b*c)) - (-a*d + b*c)*(A*b**S(2)*(m + S(2)) + C*(a**S(2) + b**S(2)*(m + S(1))))*sin(e + f*x), x), x), x) - Simp((a + b*sin(e + f*x))**(m + S(1))*(A*b**S(2) + C*a**S(2))*(-a*d + b*c)*cos(e + f*x)/(b**S(2)*f*(a**S(2) - b**S(2))*(m + S(1))), x) rule2958 = ReplacementRule(pattern2958, replacement2958) pattern2959 = Pattern(Integral((WC('A', S(0)) + WC('C', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0)))**S(2))*(WC('a', S(0)) + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons36, cons71, cons1267, cons31, cons94) def replacement2959(C, e, m, f, b, d, a, c, x, A): rubi.append(2959) return Dist(S(1)/(b**S(2)*(a**S(2) - b**S(2))*(m + S(1))), Int((a + b*cos(e + f*x))**(m + S(1))*Simp(C*b*d*(a**S(2) - b**S(2))*(m + S(1))*cos(e + f*x)**S(2) + b*(m + S(1))*(A*b*(a*c - b*d) + C*a*(-a*d + b*c)) - (-a*d + b*c)*(A*b**S(2)*(m + S(2)) + C*(a**S(2) + b**S(2)*(m + S(1))))*cos(e + f*x), x), x), x) + Simp((a + b*cos(e + f*x))**(m + S(1))*(A*b**S(2) + C*a**S(2))*(-a*d + b*c)*sin(e + f*x)/(b**S(2)*f*(a**S(2) - b**S(2))*(m + S(1))), x) rule2959 = ReplacementRule(pattern2959, replacement2959) pattern2960 = Pattern(Integral((c_ + WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))*(WC('a', S(0)) + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(WC('A', S(0)) + WC('B', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))) + WC('C', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0)))**S(2)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons36, cons21, cons71, cons1267, cons272) def replacement2960(B, C, m, f, b, d, a, c, A, x, e): rubi.append(2960) return Dist(S(1)/(b*(m + S(3))), Int((a + b*sin(e + f*x))**m*Simp(A*b*c*(m + S(3)) + C*a*d + b*(B*c*(m + S(3)) + d*(A*(m + S(3)) + C*(m + S(2))))*sin(e + f*x) - (S(2)*C*a*d - b*(m + S(3))*(B*d + C*c))*sin(e + f*x)**S(2), x), x), x) - Simp(C*d*(a + b*sin(e + f*x))**(m + S(1))*sin(e + f*x)*cos(e + f*x)/(b*f*(m + S(3))), x) rule2960 = ReplacementRule(pattern2960, replacement2960) pattern2961 = Pattern(Integral((c_ + WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))*(WC('a', S(0)) + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(WC('A', S(0)) + WC('B', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))) + WC('C', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0)))**S(2)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons36, cons21, cons71, cons1267, cons272) def replacement2961(B, C, m, f, b, d, a, c, A, x, e): rubi.append(2961) return Dist(S(1)/(b*(m + S(3))), Int((a + b*cos(e + f*x))**m*Simp(A*b*c*(m + S(3)) + C*a*d + b*(B*c*(m + S(3)) + d*(A*(m + S(3)) + C*(m + S(2))))*cos(e + f*x) - (S(2)*C*a*d - b*(m + S(3))*(B*d + C*c))*cos(e + f*x)**S(2), x), x), x) + Simp(C*d*(a + b*cos(e + f*x))**(m + S(1))*sin(e + f*x)*cos(e + f*x)/(b*f*(m + S(3))), x) rule2961 = ReplacementRule(pattern2961, replacement2961) pattern2962 = Pattern(Integral((c_ + WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))*(WC('A', S(0)) + WC('C', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0)))**S(2))*(WC('a', S(0)) + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons36, cons21, cons71, cons1267, cons272) def replacement2962(C, m, f, b, d, a, c, A, x, e): rubi.append(2962) return Dist(S(1)/(b*(m + S(3))), Int((a + b*sin(e + f*x))**m*Simp(A*b*c*(m + S(3)) + C*a*d + b*d*(A*(m + S(3)) + C*(m + S(2)))*sin(e + f*x) - (S(2)*C*a*d - C*b*c*(m + S(3)))*sin(e + f*x)**S(2), x), x), x) - Simp(C*d*(a + b*sin(e + f*x))**(m + S(1))*sin(e + f*x)*cos(e + f*x)/(b*f*(m + S(3))), x) rule2962 = ReplacementRule(pattern2962, replacement2962) pattern2963 = Pattern(Integral((c_ + WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))*(WC('A', S(0)) + WC('C', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0)))**S(2))*(WC('a', S(0)) + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons36, cons21, cons71, cons1267, cons272) def replacement2963(C, m, f, b, d, a, c, A, x, e): rubi.append(2963) return Dist(S(1)/(b*(m + S(3))), Int((a + b*cos(e + f*x))**m*Simp(A*b*c*(m + S(3)) + C*a*d + b*d*(A*(m + S(3)) + C*(m + S(2)))*cos(e + f*x) - (S(2)*C*a*d - C*b*c*(m + S(3)))*cos(e + f*x)**S(2), x), x), x) + Simp(C*d*(a + b*cos(e + f*x))**(m + S(1))*sin(e + f*x)*cos(e + f*x)/(b*f*(m + S(3))), x) rule2963 = ReplacementRule(pattern2963, replacement2963) pattern2964 = Pattern(Integral((a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1))*(WC('A', S(0)) + WC('B', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))) + WC('C', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0)))**S(2)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons36, cons21, cons4, cons70, cons1265, cons1436) def replacement2964(B, C, m, f, b, d, c, n, a, A, x, e): rubi.append(2964) return -Dist(S(1)/(S(2)*b*c*d*(S(2)*m + S(1))), Int((a + b*sin(e + f*x))**(m + S(1))*(c + d*sin(e + f*x))**n*Simp(A*(c**S(2)*(m + S(1)) + d**S(2)*(S(2)*m + n + S(2))) - B*c*d*(m - n + S(-1)) - C*(c**S(2)*m - d**S(2)*(n + S(1))) + d*(-C*c*(S(3)*m - n) + (A*c + B*d)*(m + n + S(2)))*sin(e + f*x), x), x), x) + Simp((a + b*sin(e + f*x))**m*(c + d*sin(e + f*x))**(n + S(1))*(A*a - B*b + C*a)*cos(e + f*x)/(S(2)*b*c*f*(S(2)*m + S(1))), x) rule2964 = ReplacementRule(pattern2964, replacement2964) pattern2965 = Pattern(Integral((a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1))*(WC('A', S(0)) + WC('B', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))) + WC('C', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0)))**S(2)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons36, cons21, cons4, cons70, cons1265, cons1436) def replacement2965(B, C, m, f, b, d, c, n, a, A, x, e): rubi.append(2965) return -Dist(S(1)/(S(2)*b*c*d*(S(2)*m + S(1))), Int((a + b*cos(e + f*x))**(m + S(1))*(c + d*cos(e + f*x))**n*Simp(A*(c**S(2)*(m + S(1)) + d**S(2)*(S(2)*m + n + S(2))) - B*c*d*(m - n + S(-1)) - C*(c**S(2)*m - d**S(2)*(n + S(1))) + d*(-C*c*(S(3)*m - n) + (A*c + B*d)*(m + n + S(2)))*cos(e + f*x), x), x), x) - Simp((a + b*cos(e + f*x))**m*(c + d*cos(e + f*x))**(n + S(1))*(A*a - B*b + C*a)*sin(e + f*x)/(S(2)*b*c*f*(S(2)*m + S(1))), x) rule2965 = ReplacementRule(pattern2965, replacement2965) pattern2966 = Pattern(Integral((a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('A', S(0)) + WC('C', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0)))**S(2))*(WC('c', S(0)) + WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons36, cons21, cons4, cons70, cons1265, cons1436) def replacement2966(C, m, f, b, d, c, n, a, A, x, e): rubi.append(2966) return -Dist(S(1)/(S(2)*b*c*d*(S(2)*m + S(1))), Int((a + b*sin(e + f*x))**(m + S(1))*(c + d*sin(e + f*x))**n*Simp(A*(c**S(2)*(m + S(1)) + d**S(2)*(S(2)*m + n + S(2))) - C*(c**S(2)*m - d**S(2)*(n + S(1))) + d*(A*c*(m + n + S(2)) - C*c*(S(3)*m - n))*sin(e + f*x), x), x), x) + Simp((a + b*sin(e + f*x))**m*(c + d*sin(e + f*x))**(n + S(1))*(A*a + C*a)*cos(e + f*x)/(S(2)*b*c*f*(S(2)*m + S(1))), x) rule2966 = ReplacementRule(pattern2966, replacement2966) pattern2967 = Pattern(Integral((a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('A', S(0)) + WC('C', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0)))**S(2))*(WC('c', S(0)) + WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons36, cons21, cons4, cons70, cons1265, cons1436) def replacement2967(C, m, f, b, d, c, n, a, A, x, e): rubi.append(2967) return -Dist(S(1)/(S(2)*b*c*d*(S(2)*m + S(1))), Int((a + b*cos(e + f*x))**(m + S(1))*(c + d*cos(e + f*x))**n*Simp(A*(c**S(2)*(m + S(1)) + d**S(2)*(S(2)*m + n + S(2))) - C*(c**S(2)*m - d**S(2)*(n + S(1))) + d*(A*c*(m + n + S(2)) - C*c*(S(3)*m - n))*cos(e + f*x), x), x), x) - Simp((a + b*cos(e + f*x))**m*(c + d*cos(e + f*x))**(n + S(1))*(A*a + C*a)*sin(e + f*x)/(S(2)*b*c*f*(S(2)*m + S(1))), x) rule2967 = ReplacementRule(pattern2967, replacement2967) pattern2968 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(WC('A', S(0)) + WC('B', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))) + WC('C', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0)))**S(2))/sqrt(WC('c', S(0)) + WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons36, cons21, cons70, cons1265, cons1321) def replacement2968(B, C, m, f, b, d, a, c, A, x, e): rubi.append(2968) return Int((a + b*sin(e + f*x))**m*Simp(A + B*sin(e + f*x) + C, x)/sqrt(c + d*sin(e + f*x)), x) + Simp(-S(2)*C*(a + b*sin(e + f*x))**(m + S(1))*cos(e + f*x)/(b*f*sqrt(c + d*sin(e + f*x))*(S(2)*m + S(3))), x) rule2968 = ReplacementRule(pattern2968, replacement2968) pattern2969 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(WC('A', S(0)) + WC('B', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))) + WC('C', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0)))**S(2))/sqrt(WC('c', S(0)) + WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons36, cons21, cons70, cons1265, cons1321) def replacement2969(B, C, m, f, b, d, a, c, A, x, e): rubi.append(2969) return Int((a + b*cos(e + f*x))**m*Simp(A + B*cos(e + f*x) + C, x)/sqrt(c + d*cos(e + f*x)), x) + Simp(S(2)*C*(a + b*cos(e + f*x))**(m + S(1))*sin(e + f*x)/(b*f*sqrt(c + d*cos(e + f*x))*(S(2)*m + S(3))), x) rule2969 = ReplacementRule(pattern2969, replacement2969) pattern2970 = Pattern(Integral((WC('A', S(0)) + WC('C', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0)))**S(2))*(WC('a', S(0)) + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))/sqrt(WC('c', S(0)) + WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons36, cons21, cons70, cons1265, cons1321) def replacement2970(C, m, f, b, d, a, c, A, x, e): rubi.append(2970) return Dist(A + C, Int((a + b*sin(e + f*x))**m/sqrt(c + d*sin(e + f*x)), x), x) + Simp(-S(2)*C*(a + b*sin(e + f*x))**(m + S(1))*cos(e + f*x)/(b*f*sqrt(c + d*sin(e + f*x))*(S(2)*m + S(3))), x) rule2970 = ReplacementRule(pattern2970, replacement2970) pattern2971 = Pattern(Integral((WC('A', S(0)) + WC('C', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0)))**S(2))*(WC('a', S(0)) + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))/sqrt(WC('c', S(0)) + WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons36, cons21, cons70, cons1265, cons1321) def replacement2971(C, m, f, b, d, a, c, A, x, e): rubi.append(2971) return Dist(A + C, Int((a + b*cos(e + f*x))**m/sqrt(c + d*cos(e + f*x)), x), x) + Simp(S(2)*C*(a + b*cos(e + f*x))**(m + S(1))*sin(e + f*x)/(b*f*sqrt(c + d*cos(e + f*x))*(S(2)*m + S(3))), x) rule2971 = ReplacementRule(pattern2971, replacement2971) pattern2972 = Pattern(Integral((a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(WC('c', S(0)) + WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1))*(WC('A', S(0)) + WC('B', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))) + WC('C', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0)))**S(2)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons36, cons21, cons4, cons70, cons1265, cons1321, cons214) def replacement2972(B, C, m, f, b, d, c, n, a, A, x, e): rubi.append(2972) return Dist(S(1)/(b*d*(m + n + S(2))), Int((a + b*sin(e + f*x))**m*(c + d*sin(e + f*x))**n*Simp(A*b*d*(m + n + S(2)) + C*(a*c*m + b*d*(n + S(1))) + (B*b*d*(m + n + S(2)) - C*b*c*(S(2)*m + S(1)))*sin(e + f*x), x), x), x) - Simp(C*(a + b*sin(e + f*x))**m*(c + d*sin(e + f*x))**(n + S(1))*cos(e + f*x)/(d*f*(m + n + S(2))), x) rule2972 = ReplacementRule(pattern2972, replacement2972) pattern2973 = Pattern(Integral((a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(WC('c', S(0)) + WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1))*(WC('A', S(0)) + WC('B', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))) + WC('C', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0)))**S(2)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons36, cons21, cons4, cons70, cons1265, cons1321, cons214) def replacement2973(B, C, m, f, b, d, c, n, a, A, x, e): rubi.append(2973) return Dist(S(1)/(b*d*(m + n + S(2))), Int((a + b*cos(e + f*x))**m*(c + d*cos(e + f*x))**n*Simp(A*b*d*(m + n + S(2)) + C*(a*c*m + b*d*(n + S(1))) + (B*b*d*(m + n + S(2)) - C*b*c*(S(2)*m + S(1)))*cos(e + f*x), x), x), x) + Simp(C*(a + b*cos(e + f*x))**m*(c + d*cos(e + f*x))**(n + S(1))*sin(e + f*x)/(d*f*(m + n + S(2))), x) rule2973 = ReplacementRule(pattern2973, replacement2973) pattern2974 = Pattern(Integral((a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(WC('A', S(0)) + WC('C', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0)))**S(2))*(WC('c', S(0)) + WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons36, cons21, cons4, cons70, cons1265, cons1321, cons214) def replacement2974(C, m, f, b, d, c, n, a, A, x, e): rubi.append(2974) return Dist(S(1)/(b*d*(m + n + S(2))), Int((a + b*sin(e + f*x))**m*(c + d*sin(e + f*x))**n*Simp(A*b*d*(m + n + S(2)) - C*b*c*(S(2)*m + S(1))*sin(e + f*x) + C*(a*c*m + b*d*(n + S(1))), x), x), x) - Simp(C*(a + b*sin(e + f*x))**m*(c + d*sin(e + f*x))**(n + S(1))*cos(e + f*x)/(d*f*(m + n + S(2))), x) rule2974 = ReplacementRule(pattern2974, replacement2974) pattern2975 = Pattern(Integral((a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(WC('A', S(0)) + WC('C', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0)))**S(2))*(WC('c', S(0)) + WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons36, cons21, cons4, cons70, cons1265, cons1321, cons214) def replacement2975(C, m, f, b, d, c, n, a, A, x, e): rubi.append(2975) return Dist(S(1)/(b*d*(m + n + S(2))), Int((a + b*cos(e + f*x))**m*(c + d*cos(e + f*x))**n*Simp(A*b*d*(m + n + S(2)) - C*b*c*(S(2)*m + S(1))*cos(e + f*x) + C*(a*c*m + b*d*(n + S(1))), x), x), x) + Simp(C*(a + b*cos(e + f*x))**m*(c + d*cos(e + f*x))**(n + S(1))*sin(e + f*x)/(d*f*(m + n + S(2))), x) rule2975 = ReplacementRule(pattern2975, replacement2975) pattern2976 = Pattern(Integral((a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1))*(WC('A', S(0)) + WC('B', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))) + WC('C', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0)))**S(2)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons36, cons4, cons71, cons1265, cons1323, cons31, cons1320) def replacement2976(B, C, m, f, b, d, c, n, a, A, x, e): rubi.append(2976) return Dist(S(1)/(b*(S(2)*m + S(1))*(-a*d + b*c)), Int((a + b*sin(e + f*x))**(m + S(1))*(c + d*sin(e + f*x))**n*Simp(A*(a*c*(m + S(1)) - b*d*(S(2)*m + n + S(2))) + B*(a*d*(n + S(1)) + b*c*m) - C*(a*c*m + b*d*(n + S(1))) + (C*(-a*d*(m - n + S(-1)) + b*c*(S(2)*m + S(1))) + d*(A*a - B*b)*(m + n + S(2)))*sin(e + f*x), x), x), x) + Simp((a + b*sin(e + f*x))**m*(c + d*sin(e + f*x))**(n + S(1))*(A*a - B*b + C*a)*cos(e + f*x)/(f*(S(2)*m + S(1))*(-a*d + b*c)), x) rule2976 = ReplacementRule(pattern2976, replacement2976) pattern2977 = Pattern(Integral((a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1))*(WC('A', S(0)) + WC('B', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))) + WC('C', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0)))**S(2)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons36, cons4, cons71, cons1265, cons1323, cons31, cons1320) def replacement2977(B, C, m, f, b, d, c, n, a, A, x, e): rubi.append(2977) return Dist(S(1)/(b*(S(2)*m + S(1))*(-a*d + b*c)), Int((a + b*cos(e + f*x))**(m + S(1))*(c + d*cos(e + f*x))**n*Simp(A*(a*c*(m + S(1)) - b*d*(S(2)*m + n + S(2))) + B*(a*d*(n + S(1)) + b*c*m) - C*(a*c*m + b*d*(n + S(1))) + (C*(-a*d*(m - n + S(-1)) + b*c*(S(2)*m + S(1))) + d*(A*a - B*b)*(m + n + S(2)))*cos(e + f*x), x), x), x) - Simp((a + b*cos(e + f*x))**m*(c + d*cos(e + f*x))**(n + S(1))*(A*a - B*b + C*a)*sin(e + f*x)/(f*(S(2)*m + S(1))*(-a*d + b*c)), x) rule2977 = ReplacementRule(pattern2977, replacement2977) pattern2978 = Pattern(Integral((a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('A', S(0)) + WC('C', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0)))**S(2))*(WC('c', S(0)) + WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons36, cons4, cons71, cons1265, cons1323, cons31, cons1320) def replacement2978(C, m, f, b, d, c, n, a, A, x, e): rubi.append(2978) return Dist(S(1)/(b*(S(2)*m + S(1))*(-a*d + b*c)), Int((a + b*sin(e + f*x))**(m + S(1))*(c + d*sin(e + f*x))**n*Simp(A*(a*c*(m + S(1)) - b*d*(S(2)*m + n + S(2))) - C*(a*c*m + b*d*(n + S(1))) + (A*a*d*(m + n + S(2)) + C*(-a*d*(m - n + S(-1)) + b*c*(S(2)*m + S(1))))*sin(e + f*x), x), x), x) + Simp(a*(A + C)*(a + b*sin(e + f*x))**m*(c + d*sin(e + f*x))**(n + S(1))*cos(e + f*x)/(f*(S(2)*m + S(1))*(-a*d + b*c)), x) rule2978 = ReplacementRule(pattern2978, replacement2978) pattern2979 = Pattern(Integral((a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('A', S(0)) + WC('C', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0)))**S(2))*(WC('c', S(0)) + WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons36, cons4, cons71, cons1265, cons1323, cons31, cons1320) def replacement2979(C, m, f, b, d, c, n, a, A, x, e): rubi.append(2979) return Dist(S(1)/(b*(S(2)*m + S(1))*(-a*d + b*c)), Int((a + b*cos(e + f*x))**(m + S(1))*(c + d*cos(e + f*x))**n*Simp(A*(a*c*(m + S(1)) - b*d*(S(2)*m + n + S(2))) - C*(a*c*m + b*d*(n + S(1))) + (A*a*d*(m + n + S(2)) + C*(-a*d*(m - n + S(-1)) + b*c*(S(2)*m + S(1))))*cos(e + f*x), x), x), x) - Simp(a*(A + C)*(a + b*cos(e + f*x))**m*(c + d*cos(e + f*x))**(n + S(1))*sin(e + f*x)/(f*(S(2)*m + S(1))*(-a*d + b*c)), x) rule2979 = ReplacementRule(pattern2979, replacement2979) pattern2980 = Pattern(Integral((a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(WC('c', S(0)) + WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(WC('A', S(0)) + WC('B', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))) + WC('C', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0)))**S(2)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons36, cons21, cons71, cons1265, cons1323, cons1321, cons1437) def replacement2980(B, C, m, f, b, d, c, a, n, A, x, e): rubi.append(2980) return Dist(S(1)/(b*d*(c**S(2) - d**S(2))*(n + S(1))), Int((a + b*sin(e + f*x))**m*(c + d*sin(e + f*x))**(n + S(1))*Simp(A*d*(a*d*m + b*c*(n + S(1))) + b*(-C*(c**S(2)*(m + S(1)) + d**S(2)*(n + S(1))) + d*(-A*d + B*c)*(m + n + S(2)))*sin(e + f*x) + (-B*d + C*c)*(a*c*m + b*d*(n + S(1))), x), x), x) - Simp((a + b*sin(e + f*x))**m*(c + d*sin(e + f*x))**(n + S(1))*(A*d**S(2) - B*c*d + C*c**S(2))*cos(e + f*x)/(d*f*(c**S(2) - d**S(2))*(n + S(1))), x) rule2980 = ReplacementRule(pattern2980, replacement2980) pattern2981 = Pattern(Integral((a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(WC('c', S(0)) + WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(WC('A', S(0)) + WC('B', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))) + WC('C', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0)))**S(2)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons36, cons21, cons71, cons1265, cons1323, cons1321, cons1437) def replacement2981(B, C, m, f, b, d, c, n, a, A, x, e): rubi.append(2981) return Dist(S(1)/(b*d*(c**S(2) - d**S(2))*(n + S(1))), Int((a + b*cos(e + f*x))**m*(c + d*cos(e + f*x))**(n + S(1))*Simp(A*d*(a*d*m + b*c*(n + S(1))) + b*(-C*(c**S(2)*(m + S(1)) + d**S(2)*(n + S(1))) + d*(-A*d + B*c)*(m + n + S(2)))*cos(e + f*x) + (-B*d + C*c)*(a*c*m + b*d*(n + S(1))), x), x), x) + Simp((a + b*cos(e + f*x))**m*(c + d*cos(e + f*x))**(n + S(1))*(A*d**S(2) - B*c*d + C*c**S(2))*sin(e + f*x)/(d*f*(c**S(2) - d**S(2))*(n + S(1))), x) rule2981 = ReplacementRule(pattern2981, replacement2981) pattern2982 = Pattern(Integral((a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(WC('A', S(0)) + WC('C', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0)))**S(2))*(WC('c', S(0)) + WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons36, cons21, cons71, cons1265, cons1323, cons1321, cons1437) def replacement2982(C, m, f, b, d, c, a, n, A, x, e): rubi.append(2982) return Dist(S(1)/(b*d*(c**S(2) - d**S(2))*(n + S(1))), Int((a + b*sin(e + f*x))**m*(c + d*sin(e + f*x))**(n + S(1))*Simp(A*d*(a*d*m + b*c*(n + S(1))) + C*c*(a*c*m + b*d*(n + S(1))) - b*(A*d**S(2)*(m + n + S(2)) + C*(c**S(2)*(m + S(1)) + d**S(2)*(n + S(1))))*sin(e + f*x), x), x), x) - Simp((a + b*sin(e + f*x))**m*(c + d*sin(e + f*x))**(n + S(1))*(A*d**S(2) + C*c**S(2))*cos(e + f*x)/(d*f*(c**S(2) - d**S(2))*(n + S(1))), x) rule2982 = ReplacementRule(pattern2982, replacement2982) pattern2983 = Pattern(Integral((a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(WC('A', S(0)) + WC('C', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0)))**S(2))*(WC('c', S(0)) + WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons36, cons21, cons71, cons1265, cons1323, cons1321, cons1437) def replacement2983(C, m, f, b, d, c, n, a, A, x, e): rubi.append(2983) return Dist(S(1)/(b*d*(c**S(2) - d**S(2))*(n + S(1))), Int((a + b*cos(e + f*x))**m*(c + d*cos(e + f*x))**(n + S(1))*Simp(A*d*(a*d*m + b*c*(n + S(1))) + C*c*(a*c*m + b*d*(n + S(1))) - b*(A*d**S(2)*(m + n + S(2)) + C*(c**S(2)*(m + S(1)) + d**S(2)*(n + S(1))))*cos(e + f*x), x), x), x) + Simp((a + b*cos(e + f*x))**m*(c + d*cos(e + f*x))**(n + S(1))*(A*d**S(2) + C*c**S(2))*sin(e + f*x)/(d*f*(c**S(2) - d**S(2))*(n + S(1))), x) rule2983 = ReplacementRule(pattern2983, replacement2983) pattern2984 = Pattern(Integral((a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(WC('c', S(0)) + WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1))*(WC('A', S(0)) + WC('B', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))) + WC('C', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0)))**S(2)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons36, cons21, cons4, cons71, cons1265, cons1323, cons1321, cons214) def replacement2984(B, C, m, f, b, d, c, n, a, A, x, e): rubi.append(2984) return Dist(S(1)/(b*d*(m + n + S(2))), Int((a + b*sin(e + f*x))**m*(c + d*sin(e + f*x))**n*Simp(A*b*d*(m + n + S(2)) + C*(a*c*m + b*d*(n + S(1))) + (B*b*d*(m + n + S(2)) + C*(a*d*m - b*c*(m + S(1))))*sin(e + f*x), x), x), x) - Simp(C*(a + b*sin(e + f*x))**m*(c + d*sin(e + f*x))**(n + S(1))*cos(e + f*x)/(d*f*(m + n + S(2))), x) rule2984 = ReplacementRule(pattern2984, replacement2984) pattern2985 = Pattern(Integral((a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(WC('c', S(0)) + WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1))*(WC('A', S(0)) + WC('B', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))) + WC('C', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0)))**S(2)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons36, cons21, cons4, cons71, cons1265, cons1323, cons1321, cons214) def replacement2985(B, C, m, f, b, d, c, n, a, A, x, e): rubi.append(2985) return Dist(S(1)/(b*d*(m + n + S(2))), Int((a + b*cos(e + f*x))**m*(c + d*cos(e + f*x))**n*Simp(A*b*d*(m + n + S(2)) + C*(a*c*m + b*d*(n + S(1))) + (B*b*d*(m + n + S(2)) + C*(a*d*m - b*c*(m + S(1))))*cos(e + f*x), x), x), x) + Simp(C*(a + b*cos(e + f*x))**m*(c + d*cos(e + f*x))**(n + S(1))*sin(e + f*x)/(d*f*(m + n + S(2))), x) rule2985 = ReplacementRule(pattern2985, replacement2985) pattern2986 = Pattern(Integral((a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(WC('A', S(0)) + WC('C', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0)))**S(2))*(WC('c', S(0)) + WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons36, cons21, cons4, cons71, cons1265, cons1323, cons1321, cons214) def replacement2986(C, m, f, b, d, c, n, a, A, x, e): rubi.append(2986) return Dist(S(1)/(b*d*(m + n + S(2))), Int((a + b*sin(e + f*x))**m*(c + d*sin(e + f*x))**n*Simp(A*b*d*(m + n + S(2)) + C*(a*c*m + b*d*(n + S(1))) + C*(a*d*m - b*c*(m + S(1)))*sin(e + f*x), x), x), x) - Simp(C*(a + b*sin(e + f*x))**m*(c + d*sin(e + f*x))**(n + S(1))*cos(e + f*x)/(d*f*(m + n + S(2))), x) rule2986 = ReplacementRule(pattern2986, replacement2986) pattern2987 = Pattern(Integral((a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(WC('A', S(0)) + WC('C', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0)))**S(2))*(WC('c', S(0)) + WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons36, cons21, cons4, cons71, cons1265, cons1323, cons1321, cons214) def replacement2987(C, m, f, b, d, c, n, a, A, x, e): rubi.append(2987) return Dist(S(1)/(b*d*(m + n + S(2))), Int((a + b*cos(e + f*x))**m*(c + d*cos(e + f*x))**n*Simp(A*b*d*(m + n + S(2)) + C*(a*c*m + b*d*(n + S(1))) + C*(a*d*m - b*c*(m + S(1)))*cos(e + f*x), x), x), x) + Simp(C*(a + b*cos(e + f*x))**m*(c + d*cos(e + f*x))**(n + S(1))*sin(e + f*x)/(d*f*(m + n + S(2))), x) rule2987 = ReplacementRule(pattern2987, replacement2987) pattern2988 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(WC('A', S(0)) + WC('B', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))) + WC('C', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0)))**S(2)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons36, cons71, cons1267, cons1323, cons93, cons168, cons89) def replacement2988(B, C, m, f, b, d, c, a, n, A, x, e): rubi.append(2988) return Dist(S(1)/(d*(c**S(2) - d**S(2))*(n + S(1))), Int((a + b*sin(e + f*x))**(m + S(-1))*(c + d*sin(e + f*x))**(n + S(1))*Simp(A*d*(a*c*(n + S(1)) + b*d*m) + b*(-C*(c**S(2)*(m + S(1)) + d**S(2)*(n + S(1))) + d*(-A*d + B*c)*(m + n + S(2)))*sin(e + f*x)**S(2) + (-B*d + C*c)*(a*d*(n + S(1)) + b*c*m) - (-C*(-a*(c**S(2) + d**S(2)*(n + S(1))) + b*c*d*(n + S(1))) + d*(A*(a*d*(n + S(2)) - b*c*(n + S(1))) + B*(-a*c*(n + S(2)) + b*d*(n + S(1)))))*sin(e + f*x), x), x), x) - Simp((a + b*sin(e + f*x))**m*(c + d*sin(e + f*x))**(n + S(1))*(A*d**S(2) - B*c*d + C*c**S(2))*cos(e + f*x)/(d*f*(c**S(2) - d**S(2))*(n + S(1))), x) rule2988 = ReplacementRule(pattern2988, replacement2988) pattern2989 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(WC('A', S(0)) + WC('B', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))) + WC('C', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0)))**S(2)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons36, cons71, cons1267, cons1323, cons93, cons168, cons89) def replacement2989(B, C, e, m, f, b, d, a, c, n, x, A): rubi.append(2989) return Dist(S(1)/(d*(c**S(2) - d**S(2))*(n + S(1))), Int((a + b*cos(e + f*x))**(m + S(-1))*(c + d*cos(e + f*x))**(n + S(1))*Simp(A*d*(a*c*(n + S(1)) + b*d*m) + b*(-C*(c**S(2)*(m + S(1)) + d**S(2)*(n + S(1))) + d*(-A*d + B*c)*(m + n + S(2)))*cos(e + f*x)**S(2) + (-B*d + C*c)*(a*d*(n + S(1)) + b*c*m) - (-C*(-a*(c**S(2) + d**S(2)*(n + S(1))) + b*c*d*(n + S(1))) + d*(A*(a*d*(n + S(2)) - b*c*(n + S(1))) + B*(-a*c*(n + S(2)) + b*d*(n + S(1)))))*cos(e + f*x), x), x), x) + Simp((a + b*cos(e + f*x))**m*(c + d*cos(e + f*x))**(n + S(1))*(A*d**S(2) - B*c*d + C*c**S(2))*sin(e + f*x)/(d*f*(c**S(2) - d**S(2))*(n + S(1))), x) rule2989 = ReplacementRule(pattern2989, replacement2989) pattern2990 = Pattern(Integral((WC('A', S(0)) + WC('C', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0)))**S(2))*(WC('a', S(0)) + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons36, cons71, cons1267, cons1323, cons93, cons168, cons89) def replacement2990(C, m, f, b, d, c, a, n, A, x, e): rubi.append(2990) return Dist(S(1)/(d*(c**S(2) - d**S(2))*(n + S(1))), Int((a + b*sin(e + f*x))**(m + S(-1))*(c + d*sin(e + f*x))**(n + S(1))*Simp(A*d*(a*c*(n + S(1)) + b*d*m) + C*c*(a*d*(n + S(1)) + b*c*m) - b*(A*d**S(2)*(m + n + S(2)) + C*(c**S(2)*(m + S(1)) + d**S(2)*(n + S(1))))*sin(e + f*x)**S(2) - (A*d*(a*d*(n + S(2)) - b*c*(n + S(1))) - C*(-a*(c**S(2) + d**S(2)*(n + S(1))) + b*c*d*(n + S(1))))*sin(e + f*x), x), x), x) - Simp((a + b*sin(e + f*x))**m*(c + d*sin(e + f*x))**(n + S(1))*(A*d**S(2) + C*c**S(2))*cos(e + f*x)/(d*f*(c**S(2) - d**S(2))*(n + S(1))), x) rule2990 = ReplacementRule(pattern2990, replacement2990) pattern2991 = Pattern(Integral((WC('A', S(0)) + WC('C', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0)))**S(2))*(WC('a', S(0)) + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons36, cons71, cons1267, cons1323, cons93, cons168, cons89) def replacement2991(C, e, m, f, b, d, a, c, n, x, A): rubi.append(2991) return Dist(S(1)/(d*(c**S(2) - d**S(2))*(n + S(1))), Int((a + b*cos(e + f*x))**(m + S(-1))*(c + d*cos(e + f*x))**(n + S(1))*Simp(A*d*(a*c*(n + S(1)) + b*d*m) + C*c*(a*d*(n + S(1)) + b*c*m) - b*(A*d**S(2)*(m + n + S(2)) + C*(c**S(2)*(m + S(1)) + d**S(2)*(n + S(1))))*cos(e + f*x)**S(2) - (A*d*(a*d*(n + S(2)) - b*c*(n + S(1))) - C*(-a*(c**S(2) + d**S(2)*(n + S(1))) + b*c*d*(n + S(1))))*cos(e + f*x), x), x), x) + Simp((a + b*cos(e + f*x))**m*(c + d*cos(e + f*x))**(n + S(1))*(A*d**S(2) + C*c**S(2))*sin(e + f*x)/(d*f*(c**S(2) - d**S(2))*(n + S(1))), x) rule2991 = ReplacementRule(pattern2991, replacement2991) pattern2992 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(WC('c', S(0)) + WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1))*(WC('A', S(0)) + WC('B', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))) + WC('C', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0)))**S(2)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons36, cons4, cons71, cons1267, cons1323, cons31, cons168, cons1438) def replacement2992(B, C, m, f, b, d, a, c, n, A, x, e): rubi.append(2992) return Dist(S(1)/(d*(m + n + S(2))), Int((a + b*sin(e + f*x))**(m + S(-1))*(c + d*sin(e + f*x))**n*Simp(A*a*d*(m + n + S(2)) + C*(a*d*(n + S(1)) + b*c*m) + (-C*(a*c - b*d*(m + n + S(1))) + d*(A*b + B*a)*(m + n + S(2)))*sin(e + f*x) + (B*b*d*(m + n + S(2)) + C*(a*d*m - b*c*(m + S(1))))*sin(e + f*x)**S(2), x), x), x) - Simp(C*(a + b*sin(e + f*x))**m*(c + d*sin(e + f*x))**(n + S(1))*cos(e + f*x)/(d*f*(m + n + S(2))), x) rule2992 = ReplacementRule(pattern2992, replacement2992) pattern2993 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(WC('c', S(0)) + WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1))*(WC('A', S(0)) + WC('B', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))) + WC('C', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0)))**S(2)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons36, cons4, cons71, cons1267, cons1323, cons31, cons168, cons1438) def replacement2993(B, C, m, f, b, d, a, c, n, A, x, e): rubi.append(2993) return Dist(S(1)/(d*(m + n + S(2))), Int((a + b*cos(e + f*x))**(m + S(-1))*(c + d*cos(e + f*x))**n*Simp(A*a*d*(m + n + S(2)) + C*(a*d*(n + S(1)) + b*c*m) + (-C*(a*c - b*d*(m + n + S(1))) + d*(A*b + B*a)*(m + n + S(2)))*cos(e + f*x) + (B*b*d*(m + n + S(2)) + C*(a*d*m - b*c*(m + S(1))))*cos(e + f*x)**S(2), x), x), x) + Simp(C*(a + b*cos(e + f*x))**m*(c + d*cos(e + f*x))**(n + S(1))*sin(e + f*x)/(d*f*(m + n + S(2))), x) rule2993 = ReplacementRule(pattern2993, replacement2993) pattern2994 = Pattern(Integral((WC('A', S(0)) + WC('C', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0)))**S(2))*(WC('a', S(0)) + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(WC('c', S(0)) + WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons36, cons4, cons71, cons1267, cons1323, cons31, cons168, cons1438) def replacement2994(C, m, f, b, d, a, c, n, A, x, e): rubi.append(2994) return Dist(S(1)/(d*(m + n + S(2))), Int((a + b*sin(e + f*x))**(m + S(-1))*(c + d*sin(e + f*x))**n*Simp(A*a*d*(m + n + S(2)) + C*(a*d*m - b*c*(m + S(1)))*sin(e + f*x)**S(2) + C*(a*d*(n + S(1)) + b*c*m) + (A*b*d*(m + n + S(2)) - C*(a*c - b*d*(m + n + S(1))))*sin(e + f*x), x), x), x) - Simp(C*(a + b*sin(e + f*x))**m*(c + d*sin(e + f*x))**(n + S(1))*cos(e + f*x)/(d*f*(m + n + S(2))), x) rule2994 = ReplacementRule(pattern2994, replacement2994) pattern2995 = Pattern(Integral((WC('A', S(0)) + WC('C', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0)))**S(2))*(WC('a', S(0)) + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(WC('c', S(0)) + WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons36, cons4, cons71, cons1267, cons1323, cons31, cons168, cons1438) def replacement2995(C, m, f, b, d, a, c, n, A, x, e): rubi.append(2995) return Dist(S(1)/(d*(m + n + S(2))), Int((a + b*cos(e + f*x))**(m + S(-1))*(c + d*cos(e + f*x))**n*Simp(A*a*d*(m + n + S(2)) + C*(a*d*m - b*c*(m + S(1)))*cos(e + f*x)**S(2) + C*(a*d*(n + S(1)) + b*c*m) + (A*b*d*(m + n + S(2)) - C*(a*c - b*d*(m + n + S(1))))*cos(e + f*x), x), x), x) + Simp(C*(a + b*cos(e + f*x))**m*(c + d*cos(e + f*x))**(n + S(1))*sin(e + f*x)/(d*f*(m + n + S(2))), x) rule2995 = ReplacementRule(pattern2995, replacement2995) pattern2996 = Pattern(Integral((WC('A', S(0)) + WC('B', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))) + WC('C', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0)))**S(2))/(sqrt(WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))*(a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**(S(3)/2)), x_), cons2, cons3, cons27, cons48, cons125, cons34, cons35, cons36, cons1267) def replacement2996(B, C, e, f, b, d, a, x, A): rubi.append(2996) return Dist(S(1)/b, Int((A*b + (B*b - C*a)*sin(e + f*x))/(sqrt(d*sin(e + f*x))*(a + b*sin(e + f*x))**(S(3)/2)), x), x) + Dist(C/(b*d), Int(sqrt(d*sin(e + f*x))/sqrt(a + b*sin(e + f*x)), x), x) rule2996 = ReplacementRule(pattern2996, replacement2996) pattern2997 = Pattern(Integral((WC('A', S(0)) + WC('B', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))) + WC('C', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0)))**S(2))/(sqrt(WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))*(a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**(S(3)/2)), x_), cons2, cons3, cons27, cons48, cons125, cons34, cons35, cons36, cons1267) def replacement2997(B, C, f, b, d, a, A, x, e): rubi.append(2997) return Dist(S(1)/b, Int((A*b + (B*b - C*a)*cos(e + f*x))/(sqrt(d*cos(e + f*x))*(a + b*cos(e + f*x))**(S(3)/2)), x), x) + Dist(C/(b*d), Int(sqrt(d*cos(e + f*x))/sqrt(a + b*cos(e + f*x)), x), x) rule2997 = ReplacementRule(pattern2997, replacement2997) pattern2998 = Pattern(Integral((WC('A', S(0)) + WC('C', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0)))**S(2))/(sqrt(WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))*(a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**(S(3)/2)), x_), cons2, cons3, cons27, cons48, cons125, cons34, cons36, cons1267) def replacement2998(C, e, f, b, d, a, x, A): rubi.append(2998) return Dist(S(1)/b, Int((A*b - C*a*sin(e + f*x))/(sqrt(d*sin(e + f*x))*(a + b*sin(e + f*x))**(S(3)/2)), x), x) + Dist(C/(b*d), Int(sqrt(d*sin(e + f*x))/sqrt(a + b*sin(e + f*x)), x), x) rule2998 = ReplacementRule(pattern2998, replacement2998) pattern2999 = Pattern(Integral((WC('A', S(0)) + WC('C', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0)))**S(2))/(sqrt(WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))*(a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**(S(3)/2)), x_), cons2, cons3, cons27, cons48, cons125, cons34, cons36, cons1267) def replacement2999(C, f, b, d, a, A, x, e): rubi.append(2999) return Dist(S(1)/b, Int((A*b - C*a*cos(e + f*x))/(sqrt(d*cos(e + f*x))*(a + b*cos(e + f*x))**(S(3)/2)), x), x) + Dist(C/(b*d), Int(sqrt(d*cos(e + f*x))/sqrt(a + b*cos(e + f*x)), x), x) rule2999 = ReplacementRule(pattern2999, replacement2999) pattern3000 = Pattern(Integral((WC('A', S(0)) + WC('B', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))) + WC('C', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0)))**S(2))/((WC('a', S(0)) + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**(S(3)/2)*sqrt(WC('c', S(0)) + WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons36, cons71, cons1267, cons1323) def replacement3000(B, C, f, b, d, c, a, A, x, e): rubi.append(3000) return Dist(b**(S(-2)), Int((A*b**S(2) - C*a**S(2) + b*(B*b - S(2)*C*a)*sin(e + f*x))/((a + b*sin(e + f*x))**(S(3)/2)*sqrt(c + d*sin(e + f*x))), x), x) + Dist(C/b**S(2), Int(sqrt(a + b*sin(e + f*x))/sqrt(c + d*sin(e + f*x)), x), x) rule3000 = ReplacementRule(pattern3000, replacement3000) pattern3001 = Pattern(Integral((WC('A', S(0)) + WC('B', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))) + WC('C', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0)))**S(2))/((WC('a', S(0)) + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**(S(3)/2)*sqrt(WC('c', S(0)) + WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons36, cons71, cons1267, cons1323) def replacement3001(B, C, e, f, b, d, a, c, x, A): rubi.append(3001) return Dist(b**(S(-2)), Int((A*b**S(2) - C*a**S(2) + b*(B*b - S(2)*C*a)*cos(e + f*x))/((a + b*cos(e + f*x))**(S(3)/2)*sqrt(c + d*cos(e + f*x))), x), x) + Dist(C/b**S(2), Int(sqrt(a + b*cos(e + f*x))/sqrt(c + d*cos(e + f*x)), x), x) rule3001 = ReplacementRule(pattern3001, replacement3001) pattern3002 = Pattern(Integral((WC('A', S(0)) + WC('C', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0)))**S(2))/((WC('a', S(0)) + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**(S(3)/2)*sqrt(WC('c', S(0)) + WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons36, cons71, cons1267, cons1323) def replacement3002(C, f, b, d, c, a, A, x, e): rubi.append(3002) return Dist(b**(S(-2)), Int((A*b**S(2) - C*a**S(2) - S(2)*C*a*b*sin(e + f*x))/((a + b*sin(e + f*x))**(S(3)/2)*sqrt(c + d*sin(e + f*x))), x), x) + Dist(C/b**S(2), Int(sqrt(a + b*sin(e + f*x))/sqrt(c + d*sin(e + f*x)), x), x) rule3002 = ReplacementRule(pattern3002, replacement3002) pattern3003 = Pattern(Integral((WC('A', S(0)) + WC('C', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0)))**S(2))/((WC('a', S(0)) + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**(S(3)/2)*sqrt(WC('c', S(0)) + WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons36, cons71, cons1267, cons1323) def replacement3003(C, e, f, b, d, a, c, x, A): rubi.append(3003) return Dist(b**(S(-2)), Int((A*b**S(2) - C*a**S(2) - S(2)*C*a*b*cos(e + f*x))/((a + b*cos(e + f*x))**(S(3)/2)*sqrt(c + d*cos(e + f*x))), x), x) + Dist(C/b**S(2), Int(sqrt(a + b*cos(e + f*x))/sqrt(c + d*cos(e + f*x)), x), x) rule3003 = ReplacementRule(pattern3003, replacement3003) pattern3004 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(WC('A', S(0)) + WC('B', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))) + WC('C', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0)))**S(2)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons36, cons4, cons71, cons1267, cons1323, cons31, cons94, cons1337) def replacement3004(B, C, m, f, b, d, c, a, n, A, x, e): rubi.append(3004) return Dist(S(1)/((a**S(2) - b**S(2))*(m + S(1))*(-a*d + b*c)), Int((a + b*sin(e + f*x))**(m + S(1))*(c + d*sin(e + f*x))**n*Simp(d*(m + n + S(2))*(A*b**S(2) - B*a*b + C*a**S(2)) - d*(m + n + S(3))*(A*b**S(2) - B*a*b + C*a**S(2))*sin(e + f*x)**S(2) + (m + S(1))*(-a*d + b*c)*(A*a - B*b + C*a) - (c*(A*b**S(2) - B*a*b + C*a**S(2)) + (m + S(1))*(-a*d + b*c)*(A*b - B*a + C*b))*sin(e + f*x), x), x), x) - Simp((a + b*sin(e + f*x))**(m + S(1))*(c + d*sin(e + f*x))**(n + S(1))*(A*b**S(2) - B*a*b + C*a**S(2))*cos(e + f*x)/(f*(a**S(2) - b**S(2))*(m + S(1))*(-a*d + b*c)), x) rule3004 = ReplacementRule(pattern3004, replacement3004) pattern3005 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(WC('A', S(0)) + WC('B', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))) + WC('C', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0)))**S(2)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons36, cons4, cons71, cons1267, cons1323, cons31, cons94, cons1337) def replacement3005(B, C, e, m, f, b, d, a, c, n, x, A): rubi.append(3005) return Dist(S(1)/((a**S(2) - b**S(2))*(m + S(1))*(-a*d + b*c)), Int((a + b*cos(e + f*x))**(m + S(1))*(c + d*cos(e + f*x))**n*Simp(d*(m + n + S(2))*(A*b**S(2) - B*a*b + C*a**S(2)) - d*(m + n + S(3))*(A*b**S(2) - B*a*b + C*a**S(2))*cos(e + f*x)**S(2) + (m + S(1))*(-a*d + b*c)*(A*a - B*b + C*a) - (c*(A*b**S(2) - B*a*b + C*a**S(2)) + (m + S(1))*(-a*d + b*c)*(A*b - B*a + C*b))*cos(e + f*x), x), x), x) + Simp((a + b*cos(e + f*x))**(m + S(1))*(c + d*cos(e + f*x))**(n + S(1))*(A*b**S(2) - B*a*b + C*a**S(2))*sin(e + f*x)/(f*(a**S(2) - b**S(2))*(m + S(1))*(-a*d + b*c)), x) rule3005 = ReplacementRule(pattern3005, replacement3005) pattern3006 = Pattern(Integral((WC('A', S(0)) + WC('C', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0)))**S(2))*(WC('a', S(0)) + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons36, cons4, cons71, cons1267, cons1323, cons31, cons94, cons1337) def replacement3006(C, m, f, b, d, c, a, n, A, x, e): rubi.append(3006) return Dist(S(1)/((a**S(2) - b**S(2))*(m + S(1))*(-a*d + b*c)), Int((a + b*sin(e + f*x))**(m + S(1))*(c + d*sin(e + f*x))**n*Simp(a*(A + C)*(m + S(1))*(-a*d + b*c) + d*(A*b**S(2) + C*a**S(2))*(m + n + S(2)) - d*(A*b**S(2) + C*a**S(2))*(m + n + S(3))*sin(e + f*x)**S(2) - (b*(A + C)*(m + S(1))*(-a*d + b*c) + c*(A*b**S(2) + C*a**S(2)))*sin(e + f*x), x), x), x) - Simp((a + b*sin(e + f*x))**(m + S(1))*(c + d*sin(e + f*x))**(n + S(1))*(A*b**S(2) + C*a**S(2))*cos(e + f*x)/(f*(a**S(2) - b**S(2))*(m + S(1))*(-a*d + b*c)), x) rule3006 = ReplacementRule(pattern3006, replacement3006) pattern3007 = Pattern(Integral((WC('A', S(0)) + WC('C', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0)))**S(2))*(WC('a', S(0)) + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons36, cons4, cons71, cons1267, cons1323, cons31, cons94, cons1337) def replacement3007(C, e, m, f, b, d, a, c, n, x, A): rubi.append(3007) return Dist(S(1)/((a**S(2) - b**S(2))*(m + S(1))*(-a*d + b*c)), Int((a + b*cos(e + f*x))**(m + S(1))*(c + d*cos(e + f*x))**n*Simp(a*(A + C)*(m + S(1))*(-a*d + b*c) + d*(A*b**S(2) + C*a**S(2))*(m + n + S(2)) - d*(A*b**S(2) + C*a**S(2))*(m + n + S(3))*cos(e + f*x)**S(2) - (b*(A + C)*(m + S(1))*(-a*d + b*c) + c*(A*b**S(2) + C*a**S(2)))*cos(e + f*x), x), x), x) + Simp((a + b*cos(e + f*x))**(m + S(1))*(c + d*cos(e + f*x))**(n + S(1))*(A*b**S(2) + C*a**S(2))*sin(e + f*x)/(f*(a**S(2) - b**S(2))*(m + S(1))*(-a*d + b*c)), x) rule3007 = ReplacementRule(pattern3007, replacement3007) pattern3008 = Pattern(Integral((WC('A', S(0)) + WC('B', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))) + WC('C', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0)))**S(2))/((a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))*(WC('c', S(0)) + WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons36, cons71, cons1267, cons1323) def replacement3008(B, C, f, b, d, c, a, A, x, e): rubi.append(3008) return Dist((A*b**S(2) - B*a*b + C*a**S(2))/(b*(-a*d + b*c)), Int(S(1)/(a + b*sin(e + f*x)), x), x) - Dist((A*d**S(2) - B*c*d + C*c**S(2))/(d*(-a*d + b*c)), Int(S(1)/(c + d*sin(e + f*x)), x), x) + Simp(C*x/(b*d), x) rule3008 = ReplacementRule(pattern3008, replacement3008) pattern3009 = Pattern(Integral((WC('A', S(0)) + WC('B', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))) + WC('C', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0)))**S(2))/((a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))*(WC('c', S(0)) + WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons36, cons71, cons1267, cons1323) def replacement3009(B, C, f, b, d, c, a, A, x, e): rubi.append(3009) return Dist((A*b**S(2) - B*a*b + C*a**S(2))/(b*(-a*d + b*c)), Int(S(1)/(a + b*cos(e + f*x)), x), x) - Dist((A*d**S(2) - B*c*d + C*c**S(2))/(d*(-a*d + b*c)), Int(S(1)/(c + d*cos(e + f*x)), x), x) + Simp(C*x/(b*d), x) rule3009 = ReplacementRule(pattern3009, replacement3009) pattern3010 = Pattern(Integral((WC('A', S(0)) + WC('C', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0)))**S(2))/((a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))*(WC('c', S(0)) + WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons36, cons71, cons1267, cons1323) def replacement3010(C, f, b, d, c, a, A, x, e): rubi.append(3010) return Dist((A*b**S(2) + C*a**S(2))/(b*(-a*d + b*c)), Int(S(1)/(a + b*sin(e + f*x)), x), x) - Dist((A*d**S(2) + C*c**S(2))/(d*(-a*d + b*c)), Int(S(1)/(c + d*sin(e + f*x)), x), x) + Simp(C*x/(b*d), x) rule3010 = ReplacementRule(pattern3010, replacement3010) pattern3011 = Pattern(Integral((WC('A', S(0)) + WC('C', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0)))**S(2))/((a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))*(WC('c', S(0)) + WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons36, cons71, cons1267, cons1323) def replacement3011(C, f, b, d, c, a, A, x, e): rubi.append(3011) return Dist((A*b**S(2) + C*a**S(2))/(b*(-a*d + b*c)), Int(S(1)/(a + b*cos(e + f*x)), x), x) - Dist((A*d**S(2) + C*c**S(2))/(d*(-a*d + b*c)), Int(S(1)/(c + d*cos(e + f*x)), x), x) + Simp(C*x/(b*d), x) rule3011 = ReplacementRule(pattern3011, replacement3011) pattern3012 = Pattern(Integral((WC('A', S(0)) + WC('B', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))) + WC('C', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0)))**S(2))/(sqrt(WC('a', S(0)) + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))*(WC('c', S(0)) + WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons36, cons71, cons1267, cons1323) def replacement3012(B, C, f, b, d, c, a, A, x, e): rubi.append(3012) return -Dist(S(1)/(b*d), Int(Simp(-A*b*d + C*a*c + (-B*b*d + C*a*d + C*b*c)*sin(e + f*x), x)/(sqrt(a + b*sin(e + f*x))*(c + d*sin(e + f*x))), x), x) + Dist(C/(b*d), Int(sqrt(a + b*sin(e + f*x)), x), x) rule3012 = ReplacementRule(pattern3012, replacement3012) pattern3013 = Pattern(Integral((WC('A', S(0)) + WC('B', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))) + WC('C', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0)))**S(2))/(sqrt(WC('a', S(0)) + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))*(WC('c', S(0)) + WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons36, cons71, cons1267, cons1323) def replacement3013(B, C, e, f, b, d, a, c, x, A): rubi.append(3013) return -Dist(S(1)/(b*d), Int(Simp(-A*b*d + C*a*c + (-B*b*d + C*a*d + C*b*c)*cos(e + f*x), x)/(sqrt(a + b*cos(e + f*x))*(c + d*cos(e + f*x))), x), x) + Dist(C/(b*d), Int(sqrt(a + b*cos(e + f*x)), x), x) rule3013 = ReplacementRule(pattern3013, replacement3013) pattern3014 = Pattern(Integral((WC('A', S(0)) + WC('C', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0)))**S(2))/(sqrt(WC('a', S(0)) + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))*(WC('c', S(0)) + WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons36, cons71, cons1267, cons1323) def replacement3014(C, f, b, d, c, a, A, x, e): rubi.append(3014) return -Dist(S(1)/(b*d), Int(Simp(-A*b*d + C*a*c + (C*a*d + C*b*c)*sin(e + f*x), x)/(sqrt(a + b*sin(e + f*x))*(c + d*sin(e + f*x))), x), x) + Dist(C/(b*d), Int(sqrt(a + b*sin(e + f*x)), x), x) rule3014 = ReplacementRule(pattern3014, replacement3014) pattern3015 = Pattern(Integral((WC('A', S(0)) + WC('C', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0)))**S(2))/(sqrt(WC('a', S(0)) + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))*(WC('c', S(0)) + WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons36, cons71, cons1267, cons1323) def replacement3015(C, e, f, b, d, a, c, x, A): rubi.append(3015) return -Dist(S(1)/(b*d), Int(Simp(-A*b*d + C*a*c + (C*a*d + C*b*c)*cos(e + f*x), x)/(sqrt(a + b*cos(e + f*x))*(c + d*cos(e + f*x))), x), x) + Dist(C/(b*d), Int(sqrt(a + b*cos(e + f*x)), x), x) rule3015 = ReplacementRule(pattern3015, replacement3015) pattern3016 = Pattern(Integral((WC('A', S(0)) + WC('B', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))) + WC('C', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0)))**S(2))/(sqrt(c_ + WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))*sqrt(WC('a', S(0)) + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons36, cons71, cons1267, cons1323) def replacement3016(B, C, f, b, d, a, c, A, x, e): rubi.append(3016) return Dist(S(1)/(S(2)*d), Int(Simp(S(2)*A*a*d - C*(-a*d + b*c) + (S(2)*B*b*d - C*(a*d + b*c))*sin(e + f*x)**S(2) - S(2)*(C*a*c - d*(A*b + B*a))*sin(e + f*x), x)/((a + b*sin(e + f*x))**(S(3)/2)*sqrt(c + d*sin(e + f*x))), x), x) - Simp(C*sqrt(c + d*sin(e + f*x))*cos(e + f*x)/(d*f*sqrt(a + b*sin(e + f*x))), x) rule3016 = ReplacementRule(pattern3016, replacement3016) pattern3017 = Pattern(Integral((WC('A', S(0)) + WC('B', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))) + WC('C', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0)))**S(2))/(sqrt(c_ + WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))*sqrt(WC('a', S(0)) + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons36, cons71, cons1267, cons1323) def replacement3017(B, C, e, f, b, d, a, c, x, A): rubi.append(3017) return Dist(S(1)/(S(2)*d), Int(Simp(S(2)*A*a*d - C*(-a*d + b*c) + (S(2)*B*b*d - C*(a*d + b*c))*cos(e + f*x)**S(2) - S(2)*(C*a*c - d*(A*b + B*a))*cos(e + f*x), x)/((a + b*cos(e + f*x))**(S(3)/2)*sqrt(c + d*cos(e + f*x))), x), x) + Simp(C*sqrt(c + d*cos(e + f*x))*sin(e + f*x)/(d*f*sqrt(a + b*cos(e + f*x))), x) rule3017 = ReplacementRule(pattern3017, replacement3017) pattern3018 = Pattern(Integral((WC('A', S(0)) + WC('C', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0)))**S(2))/(sqrt(c_ + WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))*sqrt(WC('a', S(0)) + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons36, cons71, cons1267, cons1323) def replacement3018(C, f, b, d, a, c, A, x, e): rubi.append(3018) return Dist(S(1)/(S(2)*d), Int(Simp(S(2)*A*a*d - C*(-a*d + b*c) - C*(a*d + b*c)*sin(e + f*x)**S(2) - S(2)*(-A*b*d + C*a*c)*sin(e + f*x), x)/((a + b*sin(e + f*x))**(S(3)/2)*sqrt(c + d*sin(e + f*x))), x), x) - Simp(C*sqrt(c + d*sin(e + f*x))*cos(e + f*x)/(d*f*sqrt(a + b*sin(e + f*x))), x) rule3018 = ReplacementRule(pattern3018, replacement3018) pattern3019 = Pattern(Integral((WC('A', S(0)) + WC('C', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0)))**S(2))/(sqrt(c_ + WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))*sqrt(WC('a', S(0)) + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons36, cons71, cons1267, cons1323) def replacement3019(C, e, f, b, d, a, c, x, A): rubi.append(3019) return Dist(S(1)/(S(2)*d), Int(Simp(S(2)*A*a*d - C*(-a*d + b*c) - C*(a*d + b*c)*cos(e + f*x)**S(2) - S(2)*(-A*b*d + C*a*c)*cos(e + f*x), x)/((a + b*cos(e + f*x))**(S(3)/2)*sqrt(c + d*cos(e + f*x))), x), x) + Simp(C*sqrt(c + d*cos(e + f*x))*sin(e + f*x)/(d*f*sqrt(a + b*cos(e + f*x))), x) rule3019 = ReplacementRule(pattern3019, replacement3019) pattern3020 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(WC('A', S(0)) + WC('B', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))) + WC('C', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0)))**S(2)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons36, cons21, cons4, cons71, cons1267, cons1323) def replacement3020(B, C, m, f, b, d, c, a, n, A, x, e): rubi.append(3020) return Int((a + b*sin(e + f*x))**m*(c + d*sin(e + f*x))**n*(A + B*sin(e + f*x) + C*sin(e + f*x)**S(2)), x) rule3020 = ReplacementRule(pattern3020, replacement3020) pattern3021 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(WC('A', S(0)) + WC('B', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))) + WC('C', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0)))**S(2)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons36, cons21, cons4, cons71, cons1267, cons1323) def replacement3021(B, C, e, m, f, b, d, a, c, n, x, A): rubi.append(3021) return Int((a + b*cos(e + f*x))**m*(c + d*cos(e + f*x))**n*(A + B*cos(e + f*x) + C*cos(e + f*x)**S(2)), x) rule3021 = ReplacementRule(pattern3021, replacement3021) pattern3022 = Pattern(Integral((WC('A', S(0)) + WC('C', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0)))**S(2))*(WC('a', S(0)) + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons36, cons21, cons4, cons71, cons1267, cons1323) def replacement3022(C, m, f, b, d, c, a, n, A, x, e): rubi.append(3022) return Int((A + C*sin(e + f*x)**S(2))*(a + b*sin(e + f*x))**m*(c + d*sin(e + f*x))**n, x) rule3022 = ReplacementRule(pattern3022, replacement3022) pattern3023 = Pattern(Integral((WC('A', S(0)) + WC('C', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0)))**S(2))*(WC('a', S(0)) + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons36, cons21, cons4, cons71, cons1267, cons1323) def replacement3023(C, e, m, f, b, d, a, c, n, x, A): rubi.append(3023) return Int((A + C*cos(e + f*x)**S(2))*(a + b*cos(e + f*x))**m*(c + d*cos(e + f*x))**n, x) rule3023 = ReplacementRule(pattern3023, replacement3023) pattern3024 = Pattern(Integral((WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0)))**p_)**m_*(WC('c', S(0)) + WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1))*(WC('A', S(0)) + WC('B', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))) + WC('C', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0)))**S(2)), x_), cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons36, cons21, cons4, cons5, cons18) def replacement3024(B, C, p, m, f, b, d, c, n, A, x, e): rubi.append(3024) return Dist((b*sin(e + f*x))**(-m*p)*(b*sin(e + f*x)**p)**m, Int((b*sin(e + f*x))**(m*p)*(c + d*sin(e + f*x))**n*(A + B*sin(e + f*x) + C*sin(e + f*x)**S(2)), x), x) rule3024 = ReplacementRule(pattern3024, replacement3024) pattern3025 = Pattern(Integral((WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0)))**p_)**m_*(WC('c', S(0)) + WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1))*(WC('A', S(0)) + WC('B', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))) + WC('C', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0)))**S(2)), x_), cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons36, cons21, cons4, cons5, cons18) def replacement3025(B, C, e, p, m, f, b, d, c, n, x, A): rubi.append(3025) return Dist((b*cos(e + f*x))**(-m*p)*(b*cos(e + f*x)**p)**m, Int((b*cos(e + f*x))**(m*p)*(c + d*cos(e + f*x))**n*(A + B*cos(e + f*x) + C*cos(e + f*x)**S(2)), x), x) rule3025 = ReplacementRule(pattern3025, replacement3025) pattern3026 = Pattern(Integral((WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0)))**p_)**m_*(WC('A', S(0)) + WC('C', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0)))**S(2))*(WC('c', S(0)) + WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1)), x_), cons3, cons7, cons27, cons48, cons125, cons34, cons36, cons21, cons4, cons5, cons18) def replacement3026(C, p, m, f, b, d, c, n, A, x, e): rubi.append(3026) return Dist((b*sin(e + f*x))**(-m*p)*(b*sin(e + f*x)**p)**m, Int((b*sin(e + f*x))**(m*p)*(A + C*sin(e + f*x)**S(2))*(c + d*sin(e + f*x))**n, x), x) rule3026 = ReplacementRule(pattern3026, replacement3026) pattern3027 = Pattern(Integral((WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0)))**p_)**m_*(WC('A', S(0)) + WC('C', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0)))**S(2))*(WC('c', S(0)) + WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1)), x_), cons3, cons7, cons27, cons48, cons125, cons34, cons36, cons21, cons4, cons5, cons18) def replacement3027(C, e, p, m, f, b, d, c, n, x, A): rubi.append(3027) return Dist((b*cos(e + f*x))**(-m*p)*(b*cos(e + f*x)**p)**m, Int((b*cos(e + f*x))**(m*p)*(A + C*cos(e + f*x)**S(2))*(c + d*cos(e + f*x))**n, x), x) rule3027 = ReplacementRule(pattern3027, replacement3027) pattern3028 = Pattern(Integral((WC('a', S(1))*cos(x_*WC('d', S(1)) + WC('c', S(0))) + WC('b', S(1))*sin(x_*WC('d', S(1)) + WC('c', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons4, cons1439) def replacement3028(b, d, c, a, n, x): rubi.append(3028) return Simp(a*(a*cos(c + d*x) + b*sin(c + d*x))**n/(b*d*n), x) rule3028 = ReplacementRule(pattern3028, replacement3028) pattern3029 = Pattern(Integral((WC('a', S(1))*cos(x_*WC('d', S(1)) + WC('c', S(0))) + WC('b', S(1))*sin(x_*WC('d', S(1)) + WC('c', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons1440, cons521) def replacement3029(b, d, c, a, n, x): rubi.append(3029) return -Dist(S(1)/d, Subst(Int((a**S(2) + b**S(2) - x**S(2))**(n/S(2) + S(-1)/2), x), x, -a*sin(c + d*x) + b*cos(c + d*x)), x) rule3029 = ReplacementRule(pattern3029, replacement3029) pattern3030 = Pattern(Integral((WC('a', S(1))*cos(x_*WC('d', S(1)) + WC('c', S(0))) + WC('b', S(1))*sin(x_*WC('d', S(1)) + WC('c', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons1440, cons1441, cons87, cons165) def replacement3030(b, d, c, a, n, x): rubi.append(3030) return Dist((a**S(2) + b**S(2))*(n + S(-1))/n, Int((a*cos(c + d*x) + b*sin(c + d*x))**(n + S(-2)), x), x) - Simp((-a*sin(c + d*x) + b*cos(c + d*x))*(a*cos(c + d*x) + b*sin(c + d*x))**(n + S(-1))/(d*n), x) rule3030 = ReplacementRule(pattern3030, replacement3030) pattern3031 = Pattern(Integral(S(1)/(WC('a', S(1))*cos(x_*WC('d', S(1)) + WC('c', S(0))) + WC('b', S(1))*sin(x_*WC('d', S(1)) + WC('c', S(0)))), x_), cons2, cons3, cons7, cons27, cons1440) def replacement3031(b, d, c, a, x): rubi.append(3031) return -Dist(S(1)/d, Subst(Int(S(1)/(a**S(2) + b**S(2) - x**S(2)), x), x, -a*sin(c + d*x) + b*cos(c + d*x)), x) rule3031 = ReplacementRule(pattern3031, replacement3031) pattern3032 = Pattern(Integral((WC('a', S(1))*cos(x_*WC('d', S(1)) + WC('c', S(0))) + WC('b', S(1))*sin(x_*WC('d', S(1)) + WC('c', S(0))))**(S(-2)), x_), cons2, cons3, cons7, cons27, cons1440) def replacement3032(b, d, c, a, x): rubi.append(3032) return Simp(sin(c + d*x)/(a*d*(a*cos(c + d*x) + b*sin(c + d*x))), x) rule3032 = ReplacementRule(pattern3032, replacement3032) pattern3033 = Pattern(Integral((WC('a', S(1))*cos(x_*WC('d', S(1)) + WC('c', S(0))) + WC('b', S(1))*sin(x_*WC('d', S(1)) + WC('c', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons1440, cons87, cons89, cons1442) def replacement3033(b, d, c, a, n, x): rubi.append(3033) return Dist((n + S(2))/((a**S(2) + b**S(2))*(n + S(1))), Int((a*cos(c + d*x) + b*sin(c + d*x))**(n + S(2)), x), x) + Simp((-a*sin(c + d*x) + b*cos(c + d*x))*(a*cos(c + d*x) + b*sin(c + d*x))**(n + S(1))/(d*(a**S(2) + b**S(2))*(n + S(1))), x) rule3033 = ReplacementRule(pattern3033, replacement3033) pattern3034 = Pattern(Integral((WC('a', S(1))*cos(x_*WC('d', S(1)) + WC('c', S(0))) + WC('b', S(1))*sin(x_*WC('d', S(1)) + WC('c', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons4, cons1443, cons1444) def replacement3034(b, d, c, a, n, x): rubi.append(3034) return Dist((a**S(2) + b**S(2))**(n/S(2)), Int(cos(c + d*x - ArcTan(a, b))**n, x), x) rule3034 = ReplacementRule(pattern3034, replacement3034) pattern3035 = Pattern(Integral((WC('a', S(1))*cos(x_*WC('d', S(1)) + WC('c', S(0))) + WC('b', S(1))*sin(x_*WC('d', S(1)) + WC('c', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons4, cons1443, cons1445) def replacement3035(b, d, c, a, n, x): rubi.append(3035) return Dist(((a*cos(c + d*x) + b*sin(c + d*x))/sqrt(a**S(2) + b**S(2)))**(-n)*(a*cos(c + d*x) + b*sin(c + d*x))**n, Int(cos(c + d*x - ArcTan(a, b))**n, x), x) rule3035 = ReplacementRule(pattern3035, replacement3035) pattern3036 = Pattern(Integral((WC('a', S(1))*cos(x_*WC('d', S(1)) + WC('c', S(0))) + WC('b', S(1))*sin(x_*WC('d', S(1)) + WC('c', S(0))))**n_*sin(x_*WC('d', S(1)) + WC('c', S(0)))**m_, x_), cons2, cons3, cons7, cons27, cons1255, cons1439, cons87, cons165) def replacement3036(m, b, d, c, a, n, x): rubi.append(3036) return Dist(S(2)*b, Int((a*cos(c + d*x) + b*sin(c + d*x))**(n + S(-1))*sin(c + d*x)**(-n + S(1)), x), x) - Simp(a*(a*cos(c + d*x) + b*sin(c + d*x))**(n + S(-1))*sin(c + d*x)**(-n + S(1))/(d*(n + S(-1))), x) rule3036 = ReplacementRule(pattern3036, replacement3036) pattern3037 = Pattern(Integral((WC('a', S(1))*cos(x_*WC('d', S(1)) + WC('c', S(0))) + WC('b', S(1))*sin(x_*WC('d', S(1)) + WC('c', S(0))))**n_*cos(x_*WC('d', S(1)) + WC('c', S(0)))**m_, x_), cons2, cons3, cons7, cons27, cons1255, cons1439, cons87, cons165) def replacement3037(m, b, d, c, a, n, x): rubi.append(3037) return Dist(S(2)*a, Int((a*cos(c + d*x) + b*sin(c + d*x))**(n + S(-1))*cos(c + d*x)**(-n + S(1)), x), x) + Simp(b*(a*cos(c + d*x) + b*sin(c + d*x))**(n + S(-1))*cos(c + d*x)**(-n + S(1))/(d*(n + S(-1))), x) rule3037 = ReplacementRule(pattern3037, replacement3037) pattern3038 = Pattern(Integral((WC('a', S(1))*cos(x_*WC('d', S(1)) + WC('c', S(0))) + WC('b', S(1))*sin(x_*WC('d', S(1)) + WC('c', S(0))))**n_*sin(x_*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1)), x_), cons2, cons3, cons7, cons27, cons1255, cons1439, cons87, cons463) def replacement3038(m, b, d, c, a, n, x): rubi.append(3038) return Dist(S(1)/(S(2)*b), Int((a*cos(c + d*x) + b*sin(c + d*x))**(n + S(1))*sin(c + d*x)**(-n + S(-1)), x), x) + Simp(a*(a*cos(c + d*x) + b*sin(c + d*x))**n*sin(c + d*x)**(-n)/(S(2)*b*d*n), x) rule3038 = ReplacementRule(pattern3038, replacement3038) pattern3039 = Pattern(Integral((WC('a', S(1))*cos(x_*WC('d', S(1)) + WC('c', S(0))) + WC('b', S(1))*sin(x_*WC('d', S(1)) + WC('c', S(0))))**n_*cos(x_*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1)), x_), cons2, cons3, cons7, cons27, cons1255, cons1439, cons87, cons463) def replacement3039(m, b, d, c, a, n, x): rubi.append(3039) return Dist(S(1)/(S(2)*a), Int((a*cos(c + d*x) + b*sin(c + d*x))**(n + S(1))*cos(c + d*x)**(-n + S(-1)), x), x) - Simp(b*(a*cos(c + d*x) + b*sin(c + d*x))**n*cos(c + d*x)**(-n)/(S(2)*a*d*n), x) rule3039 = ReplacementRule(pattern3039, replacement3039) pattern3040 = Pattern(Integral((WC('a', S(1))*cos(x_*WC('d', S(1)) + WC('c', S(0))) + WC('b', S(1))*sin(x_*WC('d', S(1)) + WC('c', S(0))))**n_*sin(x_*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1)), x_), cons2, cons3, cons7, cons27, cons4, cons1255, cons1439, cons23) def replacement3040(m, b, d, c, a, n, x): rubi.append(3040) return Simp(a*(a*cos(c + d*x) + b*sin(c + d*x))**n*Hypergeometric2F1(S(1), n, n + S(1), (a/tan(c + d*x) + b)/(S(2)*b))*sin(c + d*x)**(-n)/(S(2)*b*d*n), x) rule3040 = ReplacementRule(pattern3040, replacement3040) pattern3041 = Pattern(Integral((WC('a', S(1))*cos(x_*WC('d', S(1)) + WC('c', S(0))) + WC('b', S(1))*sin(x_*WC('d', S(1)) + WC('c', S(0))))**n_*cos(x_*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1)), x_), cons2, cons3, cons7, cons27, cons4, cons1255, cons1439, cons23) def replacement3041(m, b, d, c, a, n, x): rubi.append(3041) return -Simp(b*(a*cos(c + d*x) + b*sin(c + d*x))**n*Hypergeometric2F1(S(1), n, n + S(1), (a + b*tan(c + d*x))/(S(2)*a))*cos(c + d*x)**(-n)/(S(2)*a*d*n), x) rule3041 = ReplacementRule(pattern3041, replacement3041) pattern3042 = Pattern(Integral((WC('a', S(1))*cos(x_*WC('d', S(1)) + WC('c', S(0))) + WC('b', S(1))*sin(x_*WC('d', S(1)) + WC('c', S(0))))**WC('n', S(1))*sin(x_*WC('d', S(1)) + WC('c', S(0)))**m_, x_), cons2, cons3, cons7, cons27, cons1255, cons85, cons1440) def replacement3042(m, b, d, c, n, a, x): rubi.append(3042) return Int((a/tan(c + d*x) + b)**n, x) rule3042 = ReplacementRule(pattern3042, replacement3042) pattern3043 = Pattern(Integral((WC('a', S(1))*cos(x_*WC('d', S(1)) + WC('c', S(0))) + WC('b', S(1))*sin(x_*WC('d', S(1)) + WC('c', S(0))))**WC('n', S(1))*cos(x_*WC('d', S(1)) + WC('c', S(0)))**m_, x_), cons2, cons3, cons7, cons27, cons1255, cons85, cons1440) def replacement3043(m, b, d, c, n, a, x): rubi.append(3043) return Int((a + b*tan(c + d*x))**n, x) rule3043 = ReplacementRule(pattern3043, replacement3043) pattern3044 = Pattern(Integral((WC('a', S(1))*cos(x_*WC('d', S(1)) + WC('c', S(0))) + WC('b', S(1))*sin(x_*WC('d', S(1)) + WC('c', S(0))))**n_*sin(x_*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1)), x_), cons2, cons3, cons7, cons27, cons85, cons1446, cons1152, cons1447) def replacement3044(m, b, d, c, a, n, x): rubi.append(3044) return Dist(S(1)/d, Subst(Int(x**m*(a + b*x)**n*(x**S(2) + S(1))**(-m/S(2) - n/S(2) + S(-1)), x), x, tan(c + d*x)), x) rule3044 = ReplacementRule(pattern3044, replacement3044) pattern3045 = Pattern(Integral((WC('a', S(1))*cos(x_*WC('d', S(1)) + WC('c', S(0))) + WC('b', S(1))*sin(x_*WC('d', S(1)) + WC('c', S(0))))**n_*cos(x_*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1)), x_), cons2, cons3, cons7, cons27, cons85, cons1446, cons1152, cons1447) def replacement3045(m, b, d, c, a, n, x): rubi.append(3045) return -Dist(S(1)/d, Subst(Int(x**m*(x**S(2) + S(1))**(-m/S(2) - n/S(2) + S(-1))*(a*x + b)**n, x), x, S(1)/tan(c + d*x)), x) rule3045 = ReplacementRule(pattern3045, replacement3045) pattern3046 = Pattern(Integral((WC('a', S(1))*cos(x_*WC('d', S(1)) + WC('c', S(0))) + WC('b', S(1))*sin(x_*WC('d', S(1)) + WC('c', S(0))))**WC('n', S(1))*sin(x_*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1)), x_), cons2, cons3, cons7, cons27, cons17, cons148) def replacement3046(m, b, d, c, a, n, x): rubi.append(3046) return Int(ExpandTrig((a*cos(c + d*x) + b*sin(c + d*x))**n*sin(c + d*x)**m, x), x) rule3046 = ReplacementRule(pattern3046, replacement3046) pattern3047 = Pattern(Integral((WC('a', S(1))*cos(x_*WC('d', S(1)) + WC('c', S(0))) + WC('b', S(1))*sin(x_*WC('d', S(1)) + WC('c', S(0))))**WC('n', S(1))*cos(x_*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1)), x_), cons2, cons3, cons7, cons27, cons17, cons148) def replacement3047(m, b, d, c, a, n, x): rubi.append(3047) return Int(ExpandTrig((a*cos(c + d*x) + b*sin(c + d*x))**n*cos(c + d*x)**m, x), x) rule3047 = ReplacementRule(pattern3047, replacement3047) pattern3048 = Pattern(Integral((WC('a', S(1))*cos(x_*WC('d', S(1)) + WC('c', S(0))) + WC('b', S(1))*sin(x_*WC('d', S(1)) + WC('c', S(0))))**n_*sin(x_*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1)), x_), cons2, cons3, cons7, cons27, cons21, cons1439, cons196) def replacement3048(m, b, d, c, a, n, x): rubi.append(3048) return Dist(a**n*b**n, Int((a*sin(c + d*x) + b*cos(c + d*x))**(-n)*sin(c + d*x)**m, x), x) rule3048 = ReplacementRule(pattern3048, replacement3048) pattern3049 = Pattern(Integral((WC('a', S(1))*cos(x_*WC('d', S(1)) + WC('c', S(0))) + WC('b', S(1))*sin(x_*WC('d', S(1)) + WC('c', S(0))))**n_*cos(x_*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1)), x_), cons2, cons3, cons7, cons27, cons21, cons1439, cons196) def replacement3049(m, b, d, c, a, n, x): rubi.append(3049) return Dist(a**n*b**n, Int((a*sin(c + d*x) + b*cos(c + d*x))**(-n)*cos(c + d*x)**m, x), x) rule3049 = ReplacementRule(pattern3049, replacement3049) pattern3050 = Pattern(Integral((WC('a', S(1))*cos(x_*WC('d', S(1)) + WC('c', S(0))) + WC('b', S(1))*sin(x_*WC('d', S(1)) + WC('c', S(0))))**n_/sin(x_*WC('d', S(1)) + WC('c', S(0))), x_), cons2, cons3, cons7, cons27, cons1440, cons87, cons89) def replacement3050(b, d, c, a, n, x): rubi.append(3050) return Dist(a**(S(-2)), Int((a*cos(c + d*x) + b*sin(c + d*x))**(n + S(2))/sin(c + d*x), x), x) - Dist(b/a**S(2), Int((a*cos(c + d*x) + b*sin(c + d*x))**(n + S(1)), x), x) - Simp((a*cos(c + d*x) + b*sin(c + d*x))**(n + S(1))/(a*d*(n + S(1))), x) rule3050 = ReplacementRule(pattern3050, replacement3050) pattern3051 = Pattern(Integral((WC('a', S(1))*cos(x_*WC('d', S(1)) + WC('c', S(0))) + WC('b', S(1))*sin(x_*WC('d', S(1)) + WC('c', S(0))))**n_/cos(x_*WC('d', S(1)) + WC('c', S(0))), x_), cons2, cons3, cons7, cons27, cons1440, cons87, cons89) def replacement3051(b, d, c, a, n, x): rubi.append(3051) return Dist(b**(S(-2)), Int((a*cos(c + d*x) + b*sin(c + d*x))**(n + S(2))/cos(c + d*x), x), x) - Dist(a/b**S(2), Int((a*cos(c + d*x) + b*sin(c + d*x))**(n + S(1)), x), x) + Simp((a*cos(c + d*x) + b*sin(c + d*x))**(n + S(1))/(b*d*(n + S(1))), x) rule3051 = ReplacementRule(pattern3051, replacement3051) pattern3052 = Pattern(Integral((WC('a', S(1))*cos(x_*WC('d', S(1)) + WC('c', S(0))) + WC('b', S(1))*sin(x_*WC('d', S(1)) + WC('c', S(0))))**n_*sin(x_*WC('d', S(1)) + WC('c', S(0)))**m_, x_), cons2, cons3, cons7, cons27, cons1440, cons93, cons165, cons94) def replacement3052(m, b, d, c, a, n, x): rubi.append(3052) return Dist(a**S(2), Int((a*cos(c + d*x) + b*sin(c + d*x))**(n + S(-2))*sin(c + d*x)**m, x), x) + Dist(S(2)*b, Int((a*cos(c + d*x) + b*sin(c + d*x))**(n + S(-1))*sin(c + d*x)**(m + S(1)), x), x) - Dist(a**S(2) + b**S(2), Int((a*cos(c + d*x) + b*sin(c + d*x))**(n + S(-2))*sin(c + d*x)**(m + S(2)), x), x) rule3052 = ReplacementRule(pattern3052, replacement3052) pattern3053 = Pattern(Integral((WC('a', S(1))*cos(x_*WC('d', S(1)) + WC('c', S(0))) + WC('b', S(1))*sin(x_*WC('d', S(1)) + WC('c', S(0))))**n_*cos(x_*WC('d', S(1)) + WC('c', S(0)))**m_, x_), cons2, cons3, cons7, cons27, cons1440, cons93, cons165, cons94) def replacement3053(m, b, d, c, a, n, x): rubi.append(3053) return Dist(S(2)*a, Int((a*cos(c + d*x) + b*sin(c + d*x))**(n + S(-1))*cos(c + d*x)**(m + S(1)), x), x) + Dist(b**S(2), Int((a*cos(c + d*x) + b*sin(c + d*x))**(n + S(-2))*cos(c + d*x)**m, x), x) - Dist(a**S(2) + b**S(2), Int((a*cos(c + d*x) + b*sin(c + d*x))**(n + S(-2))*cos(c + d*x)**(m + S(2)), x), x) rule3053 = ReplacementRule(pattern3053, replacement3053) pattern3054 = Pattern(Integral(sin(x_*WC('d', S(1)) + WC('c', S(0)))/(WC('a', S(1))*cos(x_*WC('d', S(1)) + WC('c', S(0))) + WC('b', S(1))*sin(x_*WC('d', S(1)) + WC('c', S(0)))), x_), cons2, cons3, cons7, cons27, cons1440) def replacement3054(b, d, c, a, x): rubi.append(3054) return -Dist(a/(a**S(2) + b**S(2)), Int((-a*sin(c + d*x) + b*cos(c + d*x))/(a*cos(c + d*x) + b*sin(c + d*x)), x), x) + Simp(b*x/(a**S(2) + b**S(2)), x) rule3054 = ReplacementRule(pattern3054, replacement3054) pattern3055 = Pattern(Integral(cos(x_*WC('d', S(1)) + WC('c', S(0)))/(WC('a', S(1))*cos(x_*WC('d', S(1)) + WC('c', S(0))) + WC('b', S(1))*sin(x_*WC('d', S(1)) + WC('c', S(0)))), x_), cons2, cons3, cons7, cons27, cons1440) def replacement3055(b, d, c, a, x): rubi.append(3055) return Dist(b/(a**S(2) + b**S(2)), Int((-a*sin(c + d*x) + b*cos(c + d*x))/(a*cos(c + d*x) + b*sin(c + d*x)), x), x) + Simp(a*x/(a**S(2) + b**S(2)), x) rule3055 = ReplacementRule(pattern3055, replacement3055) pattern3056 = Pattern(Integral(sin(x_*WC('d', S(1)) + WC('c', S(0)))**m_/(WC('a', S(1))*cos(x_*WC('d', S(1)) + WC('c', S(0))) + WC('b', S(1))*sin(x_*WC('d', S(1)) + WC('c', S(0)))), x_), cons2, cons3, cons7, cons27, cons1440, cons31, cons166) def replacement3056(m, b, d, c, a, x): rubi.append(3056) return Dist(a**S(2)/(a**S(2) + b**S(2)), Int(sin(c + d*x)**(m + S(-2))/(a*cos(c + d*x) + b*sin(c + d*x)), x), x) + Dist(b/(a**S(2) + b**S(2)), Int(sin(c + d*x)**(m + S(-1)), x), x) - Simp(a*sin(c + d*x)**(m + S(-1))/(d*(a**S(2) + b**S(2))*(m + S(-1))), x) rule3056 = ReplacementRule(pattern3056, replacement3056) pattern3057 = Pattern(Integral(cos(x_*WC('d', S(1)) + WC('c', S(0)))**m_/(WC('a', S(1))*cos(x_*WC('d', S(1)) + WC('c', S(0))) + WC('b', S(1))*sin(x_*WC('d', S(1)) + WC('c', S(0)))), x_), cons2, cons3, cons7, cons27, cons1440, cons31, cons166) def replacement3057(m, b, d, c, a, x): rubi.append(3057) return Dist(a/(a**S(2) + b**S(2)), Int(cos(c + d*x)**(m + S(-1)), x), x) + Dist(b**S(2)/(a**S(2) + b**S(2)), Int(cos(c + d*x)**(m + S(-2))/(a*cos(c + d*x) + b*sin(c + d*x)), x), x) + Simp(b*cos(c + d*x)**(m + S(-1))/(d*(a**S(2) + b**S(2))*(m + S(-1))), x) rule3057 = ReplacementRule(pattern3057, replacement3057) pattern3058 = Pattern(Integral(S(1)/((WC('a', S(1))*cos(x_*WC('d', S(1)) + WC('c', S(0))) + WC('b', S(1))*sin(x_*WC('d', S(1)) + WC('c', S(0))))*sin(x_*WC('d', S(1)) + WC('c', S(0)))), x_), cons2, cons3, cons7, cons27, cons1440) def replacement3058(b, d, c, a, x): rubi.append(3058) return -Dist(S(1)/a, Int((-a*sin(c + d*x) + b*cos(c + d*x))/(a*cos(c + d*x) + b*sin(c + d*x)), x), x) + Dist(S(1)/a, Int(S(1)/tan(c + d*x), x), x) rule3058 = ReplacementRule(pattern3058, replacement3058) pattern3059 = Pattern(Integral(S(1)/((WC('a', S(1))*cos(x_*WC('d', S(1)) + WC('c', S(0))) + WC('b', S(1))*sin(x_*WC('d', S(1)) + WC('c', S(0))))*cos(x_*WC('d', S(1)) + WC('c', S(0)))), x_), cons2, cons3, cons7, cons27, cons1440) def replacement3059(b, d, c, a, x): rubi.append(3059) return Dist(S(1)/b, Int((-a*sin(c + d*x) + b*cos(c + d*x))/(a*cos(c + d*x) + b*sin(c + d*x)), x), x) + Dist(S(1)/b, Int(tan(c + d*x), x), x) rule3059 = ReplacementRule(pattern3059, replacement3059) pattern3060 = Pattern(Integral(sin(x_*WC('d', S(1)) + WC('c', S(0)))**m_/(WC('a', S(1))*cos(x_*WC('d', S(1)) + WC('c', S(0))) + WC('b', S(1))*sin(x_*WC('d', S(1)) + WC('c', S(0)))), x_), cons2, cons3, cons7, cons27, cons1440, cons31, cons94) def replacement3060(m, b, d, c, a, x): rubi.append(3060) return -Dist(b/a**S(2), Int(sin(c + d*x)**(m + S(1)), x), x) + Dist((a**S(2) + b**S(2))/a**S(2), Int(sin(c + d*x)**(m + S(2))/(a*cos(c + d*x) + b*sin(c + d*x)), x), x) + Simp(sin(c + d*x)**(m + S(1))/(a*d*(m + S(1))), x) rule3060 = ReplacementRule(pattern3060, replacement3060) pattern3061 = Pattern(Integral(cos(x_*WC('d', S(1)) + WC('c', S(0)))**m_/(WC('a', S(1))*cos(x_*WC('d', S(1)) + WC('c', S(0))) + WC('b', S(1))*sin(x_*WC('d', S(1)) + WC('c', S(0)))), x_), cons2, cons3, cons7, cons27, cons1440, cons31, cons94) def replacement3061(m, b, d, c, a, x): rubi.append(3061) return -Dist(a/b**S(2), Int(cos(c + d*x)**(m + S(1)), x), x) + Dist((a**S(2) + b**S(2))/b**S(2), Int(cos(c + d*x)**(m + S(2))/(a*cos(c + d*x) + b*sin(c + d*x)), x), x) - Simp(cos(c + d*x)**(m + S(1))/(b*d*(m + S(1))), x) rule3061 = ReplacementRule(pattern3061, replacement3061) pattern3062 = Pattern(Integral((WC('a', S(1))*cos(x_*WC('d', S(1)) + WC('c', S(0))) + WC('b', S(1))*sin(x_*WC('d', S(1)) + WC('c', S(0))))**n_*sin(x_*WC('d', S(1)) + WC('c', S(0)))**m_, x_), cons2, cons3, cons7, cons27, cons1440, cons93, cons89, cons94) def replacement3062(m, b, d, c, a, n, x): rubi.append(3062) return Dist(a**(S(-2)), Int((a*cos(c + d*x) + b*sin(c + d*x))**(n + S(2))*sin(c + d*x)**m, x), x) - Dist(S(2)*b/a**S(2), Int((a*cos(c + d*x) + b*sin(c + d*x))**(n + S(1))*sin(c + d*x)**(m + S(1)), x), x) + Dist((a**S(2) + b**S(2))/a**S(2), Int((a*cos(c + d*x) + b*sin(c + d*x))**n*sin(c + d*x)**(m + S(2)), x), x) rule3062 = ReplacementRule(pattern3062, replacement3062) pattern3063 = Pattern(Integral((WC('a', S(1))*cos(x_*WC('d', S(1)) + WC('c', S(0))) + WC('b', S(1))*sin(x_*WC('d', S(1)) + WC('c', S(0))))**n_*cos(x_*WC('d', S(1)) + WC('c', S(0)))**m_, x_), cons2, cons3, cons7, cons27, cons1440, cons93, cons89, cons94) def replacement3063(m, b, d, c, a, n, x): rubi.append(3063) return Dist(b**(S(-2)), Int((a*cos(c + d*x) + b*sin(c + d*x))**(n + S(2))*cos(c + d*x)**m, x), x) - Dist(S(2)*a/b**S(2), Int((a*cos(c + d*x) + b*sin(c + d*x))**(n + S(1))*cos(c + d*x)**(m + S(1)), x), x) + Dist((a**S(2) + b**S(2))/b**S(2), Int((a*cos(c + d*x) + b*sin(c + d*x))**n*cos(c + d*x)**(m + S(2)), x), x) rule3063 = ReplacementRule(pattern3063, replacement3063) pattern3064 = Pattern(Integral((WC('a', S(1))*cos(x_*WC('d', S(1)) + WC('c', S(0))) + WC('b', S(1))*sin(x_*WC('d', S(1)) + WC('c', S(0))))**WC('p', S(1))*sin(x_*WC('d', S(1)) + WC('c', S(0)))**WC('n', S(1))*cos(x_*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1)), x_), cons2, cons3, cons7, cons27, cons21, cons4, cons128) def replacement3064(p, m, b, d, c, n, a, x): rubi.append(3064) return Int(ExpandTrig((a*cos(c + d*x) + b*sin(c + d*x))**p*sin(c + d*x)**n*cos(c + d*x)**m, x), x) rule3064 = ReplacementRule(pattern3064, replacement3064) pattern3065 = Pattern(Integral((WC('a', S(1))*cos(x_*WC('d', S(1)) + WC('c', S(0))) + WC('b', S(1))*sin(x_*WC('d', S(1)) + WC('c', S(0))))**p_*sin(x_*WC('d', S(1)) + WC('c', S(0)))**WC('n', S(1))*cos(x_*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1)), x_), cons2, cons3, cons7, cons27, cons21, cons4, cons1439, cons63) def replacement3065(p, m, b, d, c, n, a, x): rubi.append(3065) return Dist(a**p*b**p, Int((a*sin(c + d*x) + b*cos(c + d*x))**(-p)*sin(c + d*x)**n*cos(c + d*x)**m, x), x) rule3065 = ReplacementRule(pattern3065, replacement3065) pattern3066 = Pattern(Integral(sin(x_*WC('d', S(1)) + WC('c', S(0)))**WC('n', S(1))*cos(x_*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1))/(WC('a', S(1))*cos(x_*WC('d', S(1)) + WC('c', S(0))) + WC('b', S(1))*sin(x_*WC('d', S(1)) + WC('c', S(0)))), x_), cons2, cons3, cons7, cons27, cons1440, cons150, cons168, cons88) def replacement3066(m, b, d, c, n, a, x): rubi.append(3066) return Dist(a/(a**S(2) + b**S(2)), Int(sin(c + d*x)**n*cos(c + d*x)**(m + S(-1)), x), x) + Dist(b/(a**S(2) + b**S(2)), Int(sin(c + d*x)**(n + S(-1))*cos(c + d*x)**m, x), x) - Dist(a*b/(a**S(2) + b**S(2)), Int(sin(c + d*x)**(n + S(-1))*cos(c + d*x)**(m + S(-1))/(a*cos(c + d*x) + b*sin(c + d*x)), x), x) rule3066 = ReplacementRule(pattern3066, replacement3066) pattern3067 = Pattern(Integral(sin(x_*WC('d', S(1)) + WC('c', S(0)))**WC('n', S(1))*cos(x_*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1))/(WC('a', S(1))*cos(x_*WC('d', S(1)) + WC('c', S(0))) + WC('b', S(1))*sin(x_*WC('d', S(1)) + WC('c', S(0)))), x_), cons2, cons3, cons7, cons27, cons21, cons4, cons150) def replacement3067(m, b, d, c, n, a, x): rubi.append(3067) return Int(ExpandTrig(sin(c + d*x)**n*cos(c + d*x)**m/(a*cos(c + d*x) + b*sin(c + d*x)), x), x) rule3067 = ReplacementRule(pattern3067, replacement3067) pattern3068 = Pattern(Integral((WC('a', S(1))*cos(x_*WC('d', S(1)) + WC('c', S(0))) + WC('b', S(1))*sin(x_*WC('d', S(1)) + WC('c', S(0))))**p_*sin(x_*WC('d', S(1)) + WC('c', S(0)))**WC('n', S(1))*cos(x_*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1)), x_), cons2, cons3, cons7, cons27, cons1440, cons375, cons168, cons88, cons322) def replacement3068(p, m, b, d, c, n, a, x): rubi.append(3068) return Dist(a/(a**S(2) + b**S(2)), Int((a*cos(c + d*x) + b*sin(c + d*x))**(p + S(1))*sin(c + d*x)**n*cos(c + d*x)**(m + S(-1)), x), x) + Dist(b/(a**S(2) + b**S(2)), Int((a*cos(c + d*x) + b*sin(c + d*x))**(p + S(1))*sin(c + d*x)**(n + S(-1))*cos(c + d*x)**m, x), x) - Dist(a*b/(a**S(2) + b**S(2)), Int((a*cos(c + d*x) + b*sin(c + d*x))**p*sin(c + d*x)**(n + S(-1))*cos(c + d*x)**(m + S(-1)), x), x) rule3068 = ReplacementRule(pattern3068, replacement3068) pattern3069 = Pattern(Integral(sqrt(a_ + WC('b', S(1))*cos(x_*WC('e', S(1)) + WC('d', S(0))) + WC('c', S(1))*sin(x_*WC('e', S(1)) + WC('d', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons1448) def replacement3069(b, d, c, a, x, e): rubi.append(3069) return Simp(-S(2)*(-b*sin(d + e*x) + c*cos(d + e*x))/(e*sqrt(a + b*cos(d + e*x) + c*sin(d + e*x))), x) rule3069 = ReplacementRule(pattern3069, replacement3069) pattern3070 = Pattern(Integral((a_ + WC('b', S(1))*cos(x_*WC('e', S(1)) + WC('d', S(0))) + WC('c', S(1))*sin(x_*WC('e', S(1)) + WC('d', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons1448, cons87, cons88) def replacement3070(b, d, c, a, n, x, e): rubi.append(3070) return Dist(a*(S(2)*n + S(-1))/n, Int((a + b*cos(d + e*x) + c*sin(d + e*x))**(n + S(-1)), x), x) - Simp((-b*sin(d + e*x) + c*cos(d + e*x))*(a + b*cos(d + e*x) + c*sin(d + e*x))**(n + S(-1))/(e*n), x) rule3070 = ReplacementRule(pattern3070, replacement3070) pattern3071 = Pattern(Integral(S(1)/(a_ + WC('b', S(1))*cos(x_*WC('e', S(1)) + WC('d', S(0))) + WC('c', S(1))*sin(x_*WC('e', S(1)) + WC('d', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons1448) def replacement3071(b, d, c, a, x, e): rubi.append(3071) return -Simp((-a*sin(d + e*x) + c)/(c*e*(-b*sin(d + e*x) + c*cos(d + e*x))), x) rule3071 = ReplacementRule(pattern3071, replacement3071) pattern3072 = Pattern(Integral(S(1)/sqrt(a_ + WC('b', S(1))*cos(x_*WC('e', S(1)) + WC('d', S(0))) + WC('c', S(1))*sin(x_*WC('e', S(1)) + WC('d', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons1448) def replacement3072(b, d, c, a, x, e): rubi.append(3072) return Int(S(1)/sqrt(a + sqrt(b**S(2) + c**S(2))*cos(d + e*x - ArcTan(b, c))), x) rule3072 = ReplacementRule(pattern3072, replacement3072) pattern3073 = Pattern(Integral((a_ + WC('b', S(1))*cos(x_*WC('e', S(1)) + WC('d', S(0))) + WC('c', S(1))*sin(x_*WC('e', S(1)) + WC('d', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons1448, cons87, cons89) def replacement3073(b, d, c, a, n, x, e): rubi.append(3073) return Dist((n + S(1))/(a*(S(2)*n + S(1))), Int((a + b*cos(d + e*x) + c*sin(d + e*x))**(n + S(1)), x), x) + Simp((-b*sin(d + e*x) + c*cos(d + e*x))*(a + b*cos(d + e*x) + c*sin(d + e*x))**n/(a*e*(S(2)*n + S(1))), x) rule3073 = ReplacementRule(pattern3073, replacement3073) pattern3074 = Pattern(Integral(sqrt(a_ + WC('b', S(1))*cos(x_*WC('e', S(1)) + WC('d', S(0))) + WC('c', S(1))*sin(x_*WC('e', S(1)) + WC('d', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons1449) def replacement3074(b, d, c, a, x, e): rubi.append(3074) return Dist(b/(c*e), Subst(Int(sqrt(a + x)/x, x), x, b*cos(d + e*x) + c*sin(d + e*x)), x) rule3074 = ReplacementRule(pattern3074, replacement3074) pattern3075 = Pattern(Integral(sqrt(a_ + WC('b', S(1))*cos(x_*WC('e', S(1)) + WC('d', S(0))) + WC('c', S(1))*sin(x_*WC('e', S(1)) + WC('d', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons1450, cons1451) def replacement3075(b, d, c, a, x, e): rubi.append(3075) return Int(sqrt(a + sqrt(b**S(2) + c**S(2))*cos(d + e*x - ArcTan(b, c))), x) rule3075 = ReplacementRule(pattern3075, replacement3075) pattern3076 = Pattern(Integral(sqrt(a_ + WC('b', S(1))*cos(x_*WC('e', S(1)) + WC('d', S(0))) + WC('c', S(1))*sin(x_*WC('e', S(1)) + WC('d', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons1452, cons1450, cons1453) def replacement3076(b, d, c, a, x, e): rubi.append(3076) return Dist(sqrt(a + b*cos(d + e*x) + c*sin(d + e*x))/sqrt((a + b*cos(d + e*x) + c*sin(d + e*x))/(a + sqrt(b**S(2) + c**S(2)))), Int(sqrt(a/(a + sqrt(b**S(2) + c**S(2))) + sqrt(b**S(2) + c**S(2))*cos(d + e*x - ArcTan(b, c))/(a + sqrt(b**S(2) + c**S(2)))), x), x) rule3076 = ReplacementRule(pattern3076, replacement3076) pattern3077 = Pattern(Integral((a_ + WC('b', S(1))*cos(x_*WC('e', S(1)) + WC('d', S(0))) + WC('c', S(1))*sin(x_*WC('e', S(1)) + WC('d', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons1452, cons87, cons165) def replacement3077(b, d, c, a, n, x, e): rubi.append(3077) return Dist(S(1)/n, Int((a + b*cos(d + e*x) + c*sin(d + e*x))**(n + S(-2))*Simp(a**S(2)*n + a*b*(S(2)*n + S(-1))*cos(d + e*x) + a*c*(S(2)*n + S(-1))*sin(d + e*x) + (b**S(2) + c**S(2))*(n + S(-1)), x), x), x) - Simp((-b*sin(d + e*x) + c*cos(d + e*x))*(a + b*cos(d + e*x) + c*sin(d + e*x))**(n + S(-1))/(e*n), x) rule3077 = ReplacementRule(pattern3077, replacement3077) def With3078(b, d, c, a, x, e): f = FreeFactors(S(1)/tan(d/S(2) + e*x/S(2)), x) rubi.append(3078) return -Dist(f/e, Subst(Int(S(1)/(a + c*f*x), x), x, S(1)/(f*tan(d/S(2) + e*x/S(2)))), x) pattern3078 = Pattern(Integral(S(1)/(a_ + WC('b', S(1))*cos(x_*WC('e', S(1)) + WC('d', S(0))) + WC('c', S(1))*sin(x_*WC('e', S(1)) + WC('d', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons1454) rule3078 = ReplacementRule(pattern3078, With3078) def With3079(b, d, c, a, x, e): f = FreeFactors(tan(Pi/S(4) + d/S(2) + e*x/S(2)), x) rubi.append(3079) return Dist(f/e, Subst(Int(S(1)/(a + b*f*x), x), x, tan(Pi/S(4) + d/S(2) + e*x/S(2))/f), x) pattern3079 = Pattern(Integral(S(1)/(a_ + WC('b', S(1))*cos(x_*WC('e', S(1)) + WC('d', S(0))) + WC('c', S(1))*sin(x_*WC('e', S(1)) + WC('d', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons76) rule3079 = ReplacementRule(pattern3079, With3079) def With3080(b, d, c, a, x, e): f = FreeFactors(S(1)/tan(Pi/S(4) + d/S(2) + e*x/S(2)), x) rubi.append(3080) return -Dist(f/e, Subst(Int(S(1)/(a + b*f*x), x), x, S(1)/(f*tan(Pi/S(4) + d/S(2) + e*x/S(2)))), x) pattern3080 = Pattern(Integral(S(1)/(a_ + WC('b', S(1))*cos(x_*WC('e', S(1)) + WC('d', S(0))) + WC('c', S(1))*sin(x_*WC('e', S(1)) + WC('d', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons1455, cons1456) rule3080 = ReplacementRule(pattern3080, With3080) def With3081(b, d, c, a, x, e): f = FreeFactors(tan(d/S(2) + e*x/S(2)), x) rubi.append(3081) return Dist(S(2)*f/e, Subst(Int(S(1)/(a + b + S(2)*c*f*x + f**S(2)*x**S(2)*(a - b)), x), x, tan(d/S(2) + e*x/S(2))/f), x) pattern3081 = Pattern(Integral(S(1)/(a_ + WC('b', S(1))*cos(x_*WC('e', S(1)) + WC('d', S(0))) + WC('c', S(1))*sin(x_*WC('e', S(1)) + WC('d', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons1452) rule3081 = ReplacementRule(pattern3081, With3081) pattern3082 = Pattern(Integral(S(1)/sqrt(a_ + WC('b', S(1))*cos(x_*WC('e', S(1)) + WC('d', S(0))) + WC('c', S(1))*sin(x_*WC('e', S(1)) + WC('d', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons1449) def replacement3082(b, d, c, a, x, e): rubi.append(3082) return Dist(b/(c*e), Subst(Int(S(1)/(x*sqrt(a + x)), x), x, b*cos(d + e*x) + c*sin(d + e*x)), x) rule3082 = ReplacementRule(pattern3082, replacement3082) pattern3083 = Pattern(Integral(S(1)/sqrt(a_ + WC('b', S(1))*cos(x_*WC('e', S(1)) + WC('d', S(0))) + WC('c', S(1))*sin(x_*WC('e', S(1)) + WC('d', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons1450, cons1451) def replacement3083(b, d, c, a, x, e): rubi.append(3083) return Int(S(1)/sqrt(a + sqrt(b**S(2) + c**S(2))*cos(d + e*x - ArcTan(b, c))), x) rule3083 = ReplacementRule(pattern3083, replacement3083) pattern3084 = Pattern(Integral(S(1)/sqrt(a_ + WC('b', S(1))*cos(x_*WC('e', S(1)) + WC('d', S(0))) + WC('c', S(1))*sin(x_*WC('e', S(1)) + WC('d', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons1452, cons1450, cons1453) def replacement3084(b, d, c, a, x, e): rubi.append(3084) return Dist(sqrt((a + b*cos(d + e*x) + c*sin(d + e*x))/(a + sqrt(b**S(2) + c**S(2))))/sqrt(a + b*cos(d + e*x) + c*sin(d + e*x)), Int(S(1)/sqrt(a/(a + sqrt(b**S(2) + c**S(2))) + sqrt(b**S(2) + c**S(2))*cos(d + e*x - ArcTan(b, c))/(a + sqrt(b**S(2) + c**S(2)))), x), x) rule3084 = ReplacementRule(pattern3084, replacement3084) pattern3085 = Pattern(Integral((a_ + WC('b', S(1))*cos(x_*WC('e', S(1)) + WC('d', S(0))) + WC('c', S(1))*sin(x_*WC('e', S(1)) + WC('d', S(0))))**(S(-3)/2), x_), cons2, cons3, cons7, cons27, cons48, cons1452) def replacement3085(b, d, c, a, x, e): rubi.append(3085) return Dist(S(1)/(a**S(2) - b**S(2) - c**S(2)), Int(sqrt(a + b*cos(d + e*x) + c*sin(d + e*x)), x), x) + Simp(S(2)*(-b*sin(d + e*x) + c*cos(d + e*x))/(e*sqrt(a + b*cos(d + e*x) + c*sin(d + e*x))*(a**S(2) - b**S(2) - c**S(2))), x) rule3085 = ReplacementRule(pattern3085, replacement3085) pattern3086 = Pattern(Integral((a_ + WC('b', S(1))*cos(x_*WC('e', S(1)) + WC('d', S(0))) + WC('c', S(1))*sin(x_*WC('e', S(1)) + WC('d', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons1452, cons87, cons89, cons1457) def replacement3086(b, d, c, a, n, x, e): rubi.append(3086) return Dist(S(1)/((n + S(1))*(a**S(2) - b**S(2) - c**S(2))), Int((a + b*cos(d + e*x) + c*sin(d + e*x))**(n + S(1))*(a*(n + S(1)) - b*(n + S(2))*cos(d + e*x) - c*(n + S(2))*sin(d + e*x)), x), x) + Simp((b*sin(d + e*x) - c*cos(d + e*x))*(a + b*cos(d + e*x) + c*sin(d + e*x))**(n + S(1))/(e*(n + S(1))*(a**S(2) - b**S(2) - c**S(2))), x) rule3086 = ReplacementRule(pattern3086, replacement3086) pattern3087 = Pattern(Integral((WC('A', S(0)) + WC('B', S(1))*cos(x_*WC('e', S(1)) + WC('d', S(0))) + WC('C', S(1))*sin(x_*WC('e', S(1)) + WC('d', S(0))))/(a_ + WC('b', S(1))*cos(x_*WC('e', S(1)) + WC('d', S(0))) + WC('c', S(1))*sin(x_*WC('e', S(1)) + WC('d', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons34, cons35, cons36, cons1449) def replacement3087(B, C, e, b, d, c, a, x, A): rubi.append(3087) return Simp(x*(S(2)*A*a - B*b - C*c)/(S(2)*a**S(2)), x) + Simp((-S(2)*A*a*b**S(2) + a**S(2)*(B*b - C*c) + b**S(2)*(B*b + C*c))*log(RemoveContent(a + b*cos(d + e*x) + c*sin(d + e*x), x))/(S(2)*a**S(2)*b*c*e), x) - Simp((B*b + C*c)*(b*cos(d + e*x) - c*sin(d + e*x))/(S(2)*a*b*c*e), x) rule3087 = ReplacementRule(pattern3087, replacement3087) pattern3088 = Pattern(Integral((WC('A', S(0)) + WC('C', S(1))*sin(x_*WC('e', S(1)) + WC('d', S(0))))/(a_ + WC('b', S(1))*cos(x_*WC('e', S(1)) + WC('d', S(0))) + WC('c', S(1))*sin(x_*WC('e', S(1)) + WC('d', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons34, cons36, cons1449) def replacement3088(C, e, b, d, c, a, x, A): rubi.append(3088) return Simp(x*(S(2)*A*a - C*c)/(S(2)*a**S(2)), x) - Simp(C*cos(d + e*x)/(S(2)*a*e), x) + Simp((S(2)*A*a*c - C*a**S(2) + C*b**S(2))*log(RemoveContent(a + b*cos(d + e*x) + c*sin(d + e*x), x))/(S(2)*a**S(2)*b*e), x) + Simp(C*c*sin(d + e*x)/(S(2)*a*b*e), x) rule3088 = ReplacementRule(pattern3088, replacement3088) pattern3089 = Pattern(Integral((WC('A', S(0)) + WC('B', S(1))*cos(x_*WC('e', S(1)) + WC('d', S(0))))/(a_ + WC('b', S(1))*cos(x_*WC('e', S(1)) + WC('d', S(0))) + WC('c', S(1))*sin(x_*WC('e', S(1)) + WC('d', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons34, cons35, cons1449) def replacement3089(B, b, d, c, a, A, x, e): rubi.append(3089) return Simp(x*(S(2)*A*a - B*b)/(S(2)*a**S(2)), x) + Simp(B*sin(d + e*x)/(S(2)*a*e), x) + Simp((-S(2)*A*a*b + B*a**S(2) + B*b**S(2))*log(RemoveContent(a + b*cos(d + e*x) + c*sin(d + e*x), x))/(S(2)*a**S(2)*c*e), x) - Simp(B*b*cos(d + e*x)/(S(2)*a*c*e), x) rule3089 = ReplacementRule(pattern3089, replacement3089) pattern3090 = Pattern(Integral((WC('A', S(0)) + WC('B', S(1))*cos(x_*WC('e', S(1)) + WC('d', S(0))) + WC('C', S(1))*sin(x_*WC('e', S(1)) + WC('d', S(0))))/(WC('a', S(0)) + WC('b', S(1))*cos(x_*WC('e', S(1)) + WC('d', S(0))) + WC('c', S(1))*sin(x_*WC('e', S(1)) + WC('d', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons34, cons35, cons36, cons1450, cons1458) def replacement3090(B, C, b, d, c, a, A, x, e): rubi.append(3090) return Simp(x*(B*b + C*c)/(b**S(2) + c**S(2)), x) + Simp((B*c - C*b)*log(a + b*cos(d + e*x) + c*sin(d + e*x))/(e*(b**S(2) + c**S(2))), x) rule3090 = ReplacementRule(pattern3090, replacement3090) pattern3091 = Pattern(Integral((WC('A', S(0)) + WC('C', S(1))*sin(x_*WC('e', S(1)) + WC('d', S(0))))/(WC('a', S(0)) + WC('b', S(1))*cos(x_*WC('e', S(1)) + WC('d', S(0))) + WC('c', S(1))*sin(x_*WC('e', S(1)) + WC('d', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons34, cons36, cons1450, cons1459) def replacement3091(C, b, d, c, a, A, x, e): rubi.append(3091) return Simp(C*c*x/(b**S(2) + c**S(2)), x) - Simp(C*b*log(a + b*cos(d + e*x) + c*sin(d + e*x))/(e*(b**S(2) + c**S(2))), x) rule3091 = ReplacementRule(pattern3091, replacement3091) pattern3092 = Pattern(Integral((WC('A', S(0)) + WC('B', S(1))*cos(x_*WC('e', S(1)) + WC('d', S(0))))/(WC('a', S(0)) + WC('b', S(1))*cos(x_*WC('e', S(1)) + WC('d', S(0))) + WC('c', S(1))*sin(x_*WC('e', S(1)) + WC('d', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons34, cons35, cons1450, cons1460) def replacement3092(B, b, d, a, c, A, x, e): rubi.append(3092) return Simp(B*b*x/(b**S(2) + c**S(2)), x) + Simp(B*c*log(a + b*cos(d + e*x) + c*sin(d + e*x))/(e*(b**S(2) + c**S(2))), x) rule3092 = ReplacementRule(pattern3092, replacement3092) pattern3093 = Pattern(Integral((WC('A', S(0)) + WC('B', S(1))*cos(x_*WC('e', S(1)) + WC('d', S(0))) + WC('C', S(1))*sin(x_*WC('e', S(1)) + WC('d', S(0))))/(WC('a', S(0)) + WC('b', S(1))*cos(x_*WC('e', S(1)) + WC('d', S(0))) + WC('c', S(1))*sin(x_*WC('e', S(1)) + WC('d', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons34, cons35, cons36, cons1450, cons1461) def replacement3093(B, C, b, d, c, a, A, x, e): rubi.append(3093) return Dist((A*(b**S(2) + c**S(2)) - a*(B*b + C*c))/(b**S(2) + c**S(2)), Int(S(1)/(a + b*cos(d + e*x) + c*sin(d + e*x)), x), x) + Simp(x*(B*b + C*c)/(b**S(2) + c**S(2)), x) + Simp((B*c - C*b)*log(a + b*cos(d + e*x) + c*sin(d + e*x))/(e*(b**S(2) + c**S(2))), x) rule3093 = ReplacementRule(pattern3093, replacement3093) pattern3094 = Pattern(Integral((WC('A', S(0)) + WC('C', S(1))*sin(x_*WC('e', S(1)) + WC('d', S(0))))/(WC('a', S(0)) + WC('b', S(1))*cos(x_*WC('e', S(1)) + WC('d', S(0))) + WC('c', S(1))*sin(x_*WC('e', S(1)) + WC('d', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons34, cons36, cons1450, cons1462) def replacement3094(C, b, d, c, a, A, x, e): rubi.append(3094) return Dist((A*(b**S(2) + c**S(2)) - C*a*c)/(b**S(2) + c**S(2)), Int(S(1)/(a + b*cos(d + e*x) + c*sin(d + e*x)), x), x) - Simp(C*b*log(a + b*cos(d + e*x) + c*sin(d + e*x))/(e*(b**S(2) + c**S(2))), x) + Simp(C*c*(d + e*x)/(e*(b**S(2) + c**S(2))), x) rule3094 = ReplacementRule(pattern3094, replacement3094) pattern3095 = Pattern(Integral((WC('A', S(0)) + WC('B', S(1))*cos(x_*WC('e', S(1)) + WC('d', S(0))))/(WC('a', S(0)) + WC('b', S(1))*cos(x_*WC('e', S(1)) + WC('d', S(0))) + WC('c', S(1))*sin(x_*WC('e', S(1)) + WC('d', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons34, cons35, cons1450, cons1463) def replacement3095(B, b, d, a, c, A, x, e): rubi.append(3095) return Dist((A*(b**S(2) + c**S(2)) - B*a*b)/(b**S(2) + c**S(2)), Int(S(1)/(a + b*cos(d + e*x) + c*sin(d + e*x)), x), x) + Simp(B*b*(d + e*x)/(e*(b**S(2) + c**S(2))), x) + Simp(B*c*log(a + b*cos(d + e*x) + c*sin(d + e*x))/(e*(b**S(2) + c**S(2))), x) rule3095 = ReplacementRule(pattern3095, replacement3095) pattern3096 = Pattern(Integral((a_ + WC('b', S(1))*cos(x_*WC('e', S(1)) + WC('d', S(0))) + WC('c', S(1))*sin(x_*WC('e', S(1)) + WC('d', S(0))))**WC('n', S(1))*(WC('A', S(0)) + WC('B', S(1))*cos(x_*WC('e', S(1)) + WC('d', S(0))) + WC('C', S(1))*sin(x_*WC('e', S(1)) + WC('d', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons34, cons35, cons36, cons4, cons584, cons1448, cons1464) def replacement3096(B, C, b, d, c, n, a, A, x, e): rubi.append(3096) return Simp((a + b*cos(d + e*x) + c*sin(d + e*x))**n*(B*a*sin(d + e*x) + B*c - C*a*cos(d + e*x) - C*b)/(a*e*(n + S(1))), x) rule3096 = ReplacementRule(pattern3096, replacement3096) pattern3097 = Pattern(Integral((WC('A', S(0)) + WC('C', S(1))*sin(x_*WC('e', S(1)) + WC('d', S(0))))*(a_ + WC('b', S(1))*cos(x_*WC('e', S(1)) + WC('d', S(0))) + WC('c', S(1))*sin(x_*WC('e', S(1)) + WC('d', S(0))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons34, cons36, cons4, cons584, cons1448, cons1465) def replacement3097(C, b, d, c, n, a, A, x, e): rubi.append(3097) return -Simp((C*a*cos(d + e*x) + C*b)*(a + b*cos(d + e*x) + c*sin(d + e*x))**n/(a*e*(n + S(1))), x) rule3097 = ReplacementRule(pattern3097, replacement3097) pattern3098 = Pattern(Integral((WC('A', S(0)) + WC('B', S(1))*cos(x_*WC('e', S(1)) + WC('d', S(0))))*(a_ + WC('b', S(1))*cos(x_*WC('e', S(1)) + WC('d', S(0))) + WC('c', S(1))*sin(x_*WC('e', S(1)) + WC('d', S(0))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons34, cons35, cons4, cons584, cons1448, cons1466) def replacement3098(B, b, d, c, n, a, A, x, e): rubi.append(3098) return Simp((B*a*sin(d + e*x) + B*c)*(a + b*cos(d + e*x) + c*sin(d + e*x))**n/(a*e*(n + S(1))), x) rule3098 = ReplacementRule(pattern3098, replacement3098) pattern3099 = Pattern(Integral((a_ + WC('b', S(1))*cos(x_*WC('e', S(1)) + WC('d', S(0))) + WC('c', S(1))*sin(x_*WC('e', S(1)) + WC('d', S(0))))**WC('n', S(1))*(WC('A', S(0)) + WC('B', S(1))*cos(x_*WC('e', S(1)) + WC('d', S(0))) + WC('C', S(1))*sin(x_*WC('e', S(1)) + WC('d', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons34, cons35, cons36, cons4, cons584, cons1448, cons1467) def replacement3099(B, C, b, d, c, n, a, A, x, e): rubi.append(3099) return Dist((A*a*(n + S(1)) + n*(B*b + C*c))/(a*(n + S(1))), Int((a + b*cos(d + e*x) + c*sin(d + e*x))**n, x), x) + Simp((a + b*cos(d + e*x) + c*sin(d + e*x))**n*(B*a*sin(d + e*x) + B*c - C*a*cos(d + e*x) - C*b)/(a*e*(n + S(1))), x) rule3099 = ReplacementRule(pattern3099, replacement3099) pattern3100 = Pattern(Integral((WC('A', S(0)) + WC('C', S(1))*sin(x_*WC('e', S(1)) + WC('d', S(0))))*(a_ + WC('b', S(1))*cos(x_*WC('e', S(1)) + WC('d', S(0))) + WC('c', S(1))*sin(x_*WC('e', S(1)) + WC('d', S(0))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons34, cons36, cons4, cons584, cons1448, cons1468) def replacement3100(C, b, d, c, n, a, A, x, e): rubi.append(3100) return Dist((A*a*(n + S(1)) + C*c*n)/(a*(n + S(1))), Int((a + b*cos(d + e*x) + c*sin(d + e*x))**n, x), x) - Simp((C*a*cos(d + e*x) + C*b)*(a + b*cos(d + e*x) + c*sin(d + e*x))**n/(a*e*(n + S(1))), x) rule3100 = ReplacementRule(pattern3100, replacement3100) pattern3101 = Pattern(Integral((WC('A', S(0)) + WC('B', S(1))*cos(x_*WC('e', S(1)) + WC('d', S(0))))*(a_ + WC('b', S(1))*cos(x_*WC('e', S(1)) + WC('d', S(0))) + WC('c', S(1))*sin(x_*WC('e', S(1)) + WC('d', S(0))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons34, cons35, cons4, cons584, cons1448, cons1469) def replacement3101(B, b, d, c, n, a, A, x, e): rubi.append(3101) return Dist((A*a*(n + S(1)) + B*b*n)/(a*(n + S(1))), Int((a + b*cos(d + e*x) + c*sin(d + e*x))**n, x), x) + Simp((B*a*sin(d + e*x) + B*c)*(a + b*cos(d + e*x) + c*sin(d + e*x))**n/(a*e*(n + S(1))), x) rule3101 = ReplacementRule(pattern3101, replacement3101) pattern3102 = Pattern(Integral((WC('B', S(1))*cos(x_*WC('e', S(1)) + WC('d', S(0))) + WC('C', S(1))*sin(x_*WC('e', S(1)) + WC('d', S(0))))*(WC('b', S(1))*cos(x_*WC('e', S(1)) + WC('d', S(0))) + WC('c', S(1))*sin(x_*WC('e', S(1)) + WC('d', S(0))))**WC('n', S(1)), x_), cons3, cons7, cons27, cons48, cons35, cons36, cons584, cons1450, cons1470) def replacement3102(B, C, b, d, c, n, x, e): rubi.append(3102) return Simp((B*c - C*b)*(b*cos(d + e*x) + c*sin(d + e*x))**(n + S(1))/(e*(b**S(2) + c**S(2))*(n + S(1))), x) rule3102 = ReplacementRule(pattern3102, replacement3102) pattern3103 = Pattern(Integral((a_ + WC('b', S(1))*cos(x_*WC('e', S(1)) + WC('d', S(0))) + WC('c', S(1))*sin(x_*WC('e', S(1)) + WC('d', S(0))))**WC('n', S(1))*(WC('A', S(0)) + WC('B', S(1))*cos(x_*WC('e', S(1)) + WC('d', S(0))) + WC('C', S(1))*sin(x_*WC('e', S(1)) + WC('d', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons34, cons35, cons36, cons87, cons88, cons1452) def replacement3103(B, C, b, d, c, n, a, A, x, e): rubi.append(3103) return Dist(S(1)/(a*(n + S(1))), Int((a + b*cos(d + e*x) + c*sin(d + e*x))**(n + S(-1))*Simp(A*a**S(2)*(n + S(1)) + a*n*(B*b + C*c) + (A*a*b*(n + S(1)) + n*(B*a**S(2) - B*c**S(2) + C*b*c))*cos(d + e*x) + (A*a*c*(n + S(1)) + n*(B*b*c + C*a**S(2) - C*b**S(2)))*sin(d + e*x), x), x), x) + Simp((a + b*cos(d + e*x) + c*sin(d + e*x))**n*(B*a*sin(d + e*x) + B*c - C*a*cos(d + e*x) - C*b)/(a*e*(n + S(1))), x) rule3103 = ReplacementRule(pattern3103, replacement3103) pattern3104 = Pattern(Integral((WC('A', S(0)) + WC('C', S(1))*sin(x_*WC('e', S(1)) + WC('d', S(0))))*(a_ + WC('b', S(1))*cos(x_*WC('e', S(1)) + WC('d', S(0))) + WC('c', S(1))*sin(x_*WC('e', S(1)) + WC('d', S(0))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons34, cons36, cons87, cons88, cons1452) def replacement3104(C, b, d, c, n, a, A, x, e): rubi.append(3104) return Dist(S(1)/(a*(n + S(1))), Int((a + b*cos(d + e*x) + c*sin(d + e*x))**(n + S(-1))*Simp(A*a**S(2)*(n + S(1)) + C*a*c*n + (A*a*b*(n + S(1)) + C*b*c*n)*cos(d + e*x) + (A*a*c*(n + S(1)) + C*a**S(2)*n - C*b**S(2)*n)*sin(d + e*x), x), x), x) - Simp((C*a*cos(d + e*x) + C*b)*(a + b*cos(d + e*x) + c*sin(d + e*x))**n/(a*e*(n + S(1))), x) rule3104 = ReplacementRule(pattern3104, replacement3104) pattern3105 = Pattern(Integral((WC('A', S(0)) + WC('B', S(1))*cos(x_*WC('e', S(1)) + WC('d', S(0))))*(a_ + WC('b', S(1))*cos(x_*WC('e', S(1)) + WC('d', S(0))) + WC('c', S(1))*sin(x_*WC('e', S(1)) + WC('d', S(0))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons34, cons35, cons87, cons88, cons1452) def replacement3105(B, b, d, c, n, a, A, x, e): rubi.append(3105) return Dist(S(1)/(a*(n + S(1))), Int((a + b*cos(d + e*x) + c*sin(d + e*x))**(n + S(-1))*Simp(A*a**S(2)*(n + S(1)) + B*a*b*n + (A*a*c*(n + S(1)) + B*b*c*n)*sin(d + e*x) + (A*a*b*(n + S(1)) + B*a**S(2)*n - B*c**S(2)*n)*cos(d + e*x), x), x), x) + Simp((B*a*sin(d + e*x) + B*c)*(a + b*cos(d + e*x) + c*sin(d + e*x))**n/(a*e*(n + S(1))), x) rule3105 = ReplacementRule(pattern3105, replacement3105) pattern3106 = Pattern(Integral((WC('A', S(0)) + WC('B', S(1))*cos(x_*WC('e', S(1)) + WC('d', S(0))) + WC('C', S(1))*sin(x_*WC('e', S(1)) + WC('d', S(0))))/sqrt(a_ + WC('b', S(1))*cos(x_*WC('e', S(1)) + WC('d', S(0))) + WC('c', S(1))*sin(x_*WC('e', S(1)) + WC('d', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons34, cons35, cons36, cons1471, cons1245) def replacement3106(B, C, e, b, d, c, a, x, A): rubi.append(3106) return Dist(B/b, Int(sqrt(a + b*cos(d + e*x) + c*sin(d + e*x)), x), x) + Dist((A*b - B*a)/b, Int(S(1)/sqrt(a + b*cos(d + e*x) + c*sin(d + e*x)), x), x) rule3106 = ReplacementRule(pattern3106, replacement3106) pattern3107 = Pattern(Integral((WC('A', S(0)) + WC('B', S(1))*cos(x_*WC('e', S(1)) + WC('d', S(0))) + WC('C', S(1))*sin(x_*WC('e', S(1)) + WC('d', S(0))))/(WC('a', S(0)) + WC('b', S(1))*cos(x_*WC('e', S(1)) + WC('d', S(0))) + WC('c', S(1))*sin(x_*WC('e', S(1)) + WC('d', S(0))))**S(2), x_), cons2, cons3, cons7, cons27, cons48, cons34, cons35, cons36, cons1452, cons1472) def replacement3107(B, C, b, d, c, a, A, x, e): rubi.append(3107) return Simp((B*c - C*b + (-A*b + B*a)*sin(d + e*x) - (-A*c + C*a)*cos(d + e*x))/(e*(a + b*cos(d + e*x) + c*sin(d + e*x))*(a**S(2) - b**S(2) - c**S(2))), x) rule3107 = ReplacementRule(pattern3107, replacement3107) pattern3108 = Pattern(Integral((WC('A', S(0)) + WC('C', S(1))*sin(x_*WC('e', S(1)) + WC('d', S(0))))/(WC('a', S(0)) + WC('b', S(1))*cos(x_*WC('e', S(1)) + WC('d', S(0))) + WC('c', S(1))*sin(x_*WC('e', S(1)) + WC('d', S(0))))**S(2), x_), cons2, cons3, cons7, cons27, cons48, cons34, cons36, cons1452, cons1473) def replacement3108(C, b, d, c, a, A, x, e): rubi.append(3108) return -Simp((A*b*sin(d + e*x) + C*b + (-A*c + C*a)*cos(d + e*x))/(e*(a + b*cos(d + e*x) + c*sin(d + e*x))*(a**S(2) - b**S(2) - c**S(2))), x) rule3108 = ReplacementRule(pattern3108, replacement3108) pattern3109 = Pattern(Integral((WC('A', S(0)) + WC('B', S(1))*cos(x_*WC('e', S(1)) + WC('d', S(0))))/(WC('a', S(0)) + WC('b', S(1))*cos(x_*WC('e', S(1)) + WC('d', S(0))) + WC('c', S(1))*sin(x_*WC('e', S(1)) + WC('d', S(0))))**S(2), x_), cons2, cons3, cons7, cons27, cons48, cons34, cons35, cons1452, cons1474) def replacement3109(B, b, d, a, c, A, x, e): rubi.append(3109) return Simp((A*c*cos(d + e*x) + B*c + (-A*b + B*a)*sin(d + e*x))/(e*(a + b*cos(d + e*x) + c*sin(d + e*x))*(a**S(2) - b**S(2) - c**S(2))), x) rule3109 = ReplacementRule(pattern3109, replacement3109) pattern3110 = Pattern(Integral((WC('A', S(0)) + WC('B', S(1))*cos(x_*WC('e', S(1)) + WC('d', S(0))) + WC('C', S(1))*sin(x_*WC('e', S(1)) + WC('d', S(0))))/(WC('a', S(0)) + WC('b', S(1))*cos(x_*WC('e', S(1)) + WC('d', S(0))) + WC('c', S(1))*sin(x_*WC('e', S(1)) + WC('d', S(0))))**S(2), x_), cons2, cons3, cons7, cons27, cons48, cons34, cons35, cons36, cons1452, cons1475) def replacement3110(B, C, b, d, c, a, A, x, e): rubi.append(3110) return Dist((A*a - B*b - C*c)/(a**S(2) - b**S(2) - c**S(2)), Int(S(1)/(a + b*cos(d + e*x) + c*sin(d + e*x)), x), x) + Simp((B*c - C*b + (-A*b + B*a)*sin(d + e*x) - (-A*c + C*a)*cos(d + e*x))/(e*(a + b*cos(d + e*x) + c*sin(d + e*x))*(a**S(2) - b**S(2) - c**S(2))), x) rule3110 = ReplacementRule(pattern3110, replacement3110) pattern3111 = Pattern(Integral((WC('A', S(0)) + WC('C', S(1))*sin(x_*WC('e', S(1)) + WC('d', S(0))))/(WC('a', S(0)) + WC('b', S(1))*cos(x_*WC('e', S(1)) + WC('d', S(0))) + WC('c', S(1))*sin(x_*WC('e', S(1)) + WC('d', S(0))))**S(2), x_), cons2, cons3, cons7, cons27, cons48, cons34, cons36, cons1452, cons1476) def replacement3111(C, b, d, c, a, A, x, e): rubi.append(3111) return Dist((A*a - C*c)/(a**S(2) - b**S(2) - c**S(2)), Int(S(1)/(a + b*cos(d + e*x) + c*sin(d + e*x)), x), x) - Simp((A*b*sin(d + e*x) + C*b + (-A*c + C*a)*cos(d + e*x))/(e*(a + b*cos(d + e*x) + c*sin(d + e*x))*(a**S(2) - b**S(2) - c**S(2))), x) rule3111 = ReplacementRule(pattern3111, replacement3111) pattern3112 = Pattern(Integral((WC('A', S(0)) + WC('B', S(1))*cos(x_*WC('e', S(1)) + WC('d', S(0))))/(WC('a', S(0)) + WC('b', S(1))*cos(x_*WC('e', S(1)) + WC('d', S(0))) + WC('c', S(1))*sin(x_*WC('e', S(1)) + WC('d', S(0))))**S(2), x_), cons2, cons3, cons7, cons27, cons48, cons34, cons35, cons1452, cons1477) def replacement3112(B, b, d, a, c, A, x, e): rubi.append(3112) return Dist((A*a - B*b)/(a**S(2) - b**S(2) - c**S(2)), Int(S(1)/(a + b*cos(d + e*x) + c*sin(d + e*x)), x), x) + Simp((A*c*cos(d + e*x) + B*c + (-A*b + B*a)*sin(d + e*x))/(e*(a + b*cos(d + e*x) + c*sin(d + e*x))*(a**S(2) - b**S(2) - c**S(2))), x) rule3112 = ReplacementRule(pattern3112, replacement3112) pattern3113 = Pattern(Integral((WC('A', S(0)) + WC('B', S(1))*cos(x_*WC('e', S(1)) + WC('d', S(0))) + WC('C', S(1))*sin(x_*WC('e', S(1)) + WC('d', S(0))))*(WC('a', S(0)) + WC('b', S(1))*cos(x_*WC('e', S(1)) + WC('d', S(0))) + WC('c', S(1))*sin(x_*WC('e', S(1)) + WC('d', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons34, cons35, cons36, cons87, cons89, cons1452, cons1442) def replacement3113(B, C, b, d, c, a, n, A, x, e): rubi.append(3113) return Dist(S(1)/((n + S(1))*(a**S(2) - b**S(2) - c**S(2))), Int((a + b*cos(d + e*x) + c*sin(d + e*x))**(n + S(1))*Simp((n + S(1))*(A*a - B*b - C*c) + (n + S(2))*(-A*b + B*a)*cos(d + e*x) + (n + S(2))*(-A*c + C*a)*sin(d + e*x), x), x), x) - Simp((a + b*cos(d + e*x) + c*sin(d + e*x))**(n + S(1))*(B*c - C*b + (-A*b + B*a)*sin(d + e*x) - (-A*c + C*a)*cos(d + e*x))/(e*(n + S(1))*(a**S(2) - b**S(2) - c**S(2))), x) rule3113 = ReplacementRule(pattern3113, replacement3113) pattern3114 = Pattern(Integral((WC('A', S(0)) + WC('C', S(1))*sin(x_*WC('e', S(1)) + WC('d', S(0))))*(WC('a', S(0)) + WC('b', S(1))*cos(x_*WC('e', S(1)) + WC('d', S(0))) + WC('c', S(1))*sin(x_*WC('e', S(1)) + WC('d', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons34, cons36, cons87, cons89, cons1452, cons1442) def replacement3114(C, b, d, c, a, n, A, x, e): rubi.append(3114) return Dist(S(1)/((n + S(1))*(a**S(2) - b**S(2) - c**S(2))), Int((a + b*cos(d + e*x) + c*sin(d + e*x))**(n + S(1))*Simp(-A*b*(n + S(2))*cos(d + e*x) + (n + S(1))*(A*a - C*c) + (n + S(2))*(-A*c + C*a)*sin(d + e*x), x), x), x) + Simp((a + b*cos(d + e*x) + c*sin(d + e*x))**(n + S(1))*(A*b*sin(d + e*x) + C*b + (-A*c + C*a)*cos(d + e*x))/(e*(n + S(1))*(a**S(2) - b**S(2) - c**S(2))), x) rule3114 = ReplacementRule(pattern3114, replacement3114) pattern3115 = Pattern(Integral((WC('A', S(0)) + WC('B', S(1))*cos(x_*WC('e', S(1)) + WC('d', S(0))))*(WC('a', S(0)) + WC('b', S(1))*cos(x_*WC('e', S(1)) + WC('d', S(0))) + WC('c', S(1))*sin(x_*WC('e', S(1)) + WC('d', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons34, cons35, cons87, cons89, cons1452, cons1442) def replacement3115(B, b, d, a, c, n, A, x, e): rubi.append(3115) return Dist(S(1)/((n + S(1))*(a**S(2) - b**S(2) - c**S(2))), Int((a + b*cos(d + e*x) + c*sin(d + e*x))**(n + S(1))*Simp(-A*c*(n + S(2))*sin(d + e*x) + (n + S(1))*(A*a - B*b) + (n + S(2))*(-A*b + B*a)*cos(d + e*x), x), x), x) - Simp((a + b*cos(d + e*x) + c*sin(d + e*x))**(n + S(1))*(A*c*cos(d + e*x) + B*c + (-A*b + B*a)*sin(d + e*x))/(e*(n + S(1))*(a**S(2) - b**S(2) - c**S(2))), x) rule3115 = ReplacementRule(pattern3115, replacement3115) pattern3116 = Pattern(Integral(S(1)/(WC('a', S(0)) + WC('b', S(1))/cos(x_*WC('e', S(1)) + WC('d', S(0))) + WC('c', S(1))*tan(x_*WC('e', S(1)) + WC('d', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons1043) def replacement3116(b, d, c, a, x, e): rubi.append(3116) return Int(cos(d + e*x)/(a*cos(d + e*x) + b + c*sin(d + e*x)), x) rule3116 = ReplacementRule(pattern3116, replacement3116) pattern3117 = Pattern(Integral(S(1)/(WC('a', S(0)) + WC('b', S(1))/sin(x_*WC('e', S(1)) + WC('d', S(0))) + WC('c', S(1))/tan(x_*WC('e', S(1)) + WC('d', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons1043) def replacement3117(b, d, c, a, x, e): rubi.append(3117) return Int(sin(d + e*x)/(a*sin(d + e*x) + b + c*cos(d + e*x)), x) rule3117 = ReplacementRule(pattern3117, replacement3117) pattern3118 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))/cos(x_*WC('e', S(1)) + WC('d', S(0))) + WC('c', S(1))*tan(x_*WC('e', S(1)) + WC('d', S(0))))**WC('n', S(1))*cos(x_*WC('e', S(1)) + WC('d', S(0)))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons85) def replacement3118(b, d, a, n, c, x, e): rubi.append(3118) return Int((a*cos(d + e*x) + b + c*sin(d + e*x))**n, x) rule3118 = ReplacementRule(pattern3118, replacement3118) pattern3119 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))/sin(x_*WC('e', S(1)) + WC('d', S(0))) + WC('c', S(1))/tan(x_*WC('e', S(1)) + WC('d', S(0))))**WC('n', S(1))*sin(x_*WC('e', S(1)) + WC('d', S(0)))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons85) def replacement3119(b, d, c, a, n, x, e): rubi.append(3119) return Int((a*sin(d + e*x) + b + c*cos(d + e*x))**n, x) rule3119 = ReplacementRule(pattern3119, replacement3119) pattern3120 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))/cos(x_*WC('e', S(1)) + WC('d', S(0))) + WC('c', S(1))*tan(x_*WC('e', S(1)) + WC('d', S(0))))**n_*cos(x_*WC('e', S(1)) + WC('d', S(0)))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons23) def replacement3120(b, d, c, a, n, x, e): rubi.append(3120) return Dist((a + b/cos(d + e*x) + c*tan(d + e*x))**n*(a*cos(d + e*x) + b + c*sin(d + e*x))**(-n)*cos(d + e*x)**n, Int((a*cos(d + e*x) + b + c*sin(d + e*x))**n, x), x) rule3120 = ReplacementRule(pattern3120, replacement3120) pattern3121 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))/sin(x_*WC('e', S(1)) + WC('d', S(0))) + WC('c', S(1))/tan(x_*WC('e', S(1)) + WC('d', S(0))))**n_*sin(x_*WC('e', S(1)) + WC('d', S(0)))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons23) def replacement3121(b, d, c, a, n, x, e): rubi.append(3121) return Dist((a + b/sin(d + e*x) + c/tan(d + e*x))**n*(a*sin(d + e*x) + b + c*cos(d + e*x))**(-n)*sin(d + e*x)**n, Int((a*sin(d + e*x) + b + c*cos(d + e*x))**n, x), x) rule3121 = ReplacementRule(pattern3121, replacement3121) pattern3122 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))/cos(x_*WC('e', S(1)) + WC('d', S(0))) + WC('c', S(1))*tan(x_*WC('e', S(1)) + WC('d', S(0))))**m_*(S(1)/cos(x_*WC('e', S(1)) + WC('d', S(0))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons1255, cons85) def replacement3122(m, b, d, a, n, c, x, e): rubi.append(3122) return Int((a*cos(d + e*x) + b + c*sin(d + e*x))**(-n), x) rule3122 = ReplacementRule(pattern3122, replacement3122) pattern3123 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))/sin(x_*WC('e', S(1)) + WC('d', S(0))) + WC('c', S(1))/tan(x_*WC('e', S(1)) + WC('d', S(0))))**m_*(S(1)/sin(x_*WC('e', S(1)) + WC('d', S(0))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons1255, cons85) def replacement3123(m, b, d, a, n, c, x, e): rubi.append(3123) return Int((a*sin(d + e*x) + b + c*cos(d + e*x))**(-n), x) rule3123 = ReplacementRule(pattern3123, replacement3123) pattern3124 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))/cos(x_*WC('e', S(1)) + WC('d', S(0))) + WC('c', S(1))*tan(x_*WC('e', S(1)) + WC('d', S(0))))**m_*(S(1)/cos(x_*WC('e', S(1)) + WC('d', S(0))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons1255, cons23) def replacement3124(m, b, d, a, n, c, x, e): rubi.append(3124) return Dist((a + b/cos(d + e*x) + c*tan(d + e*x))**(-n)*(a*cos(d + e*x) + b + c*sin(d + e*x))**n*(S(1)/cos(d + e*x))**n, Int((a*cos(d + e*x) + b + c*sin(d + e*x))**(-n), x), x) rule3124 = ReplacementRule(pattern3124, replacement3124) pattern3125 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))/sin(x_*WC('e', S(1)) + WC('d', S(0))) + WC('c', S(1))/tan(x_*WC('e', S(1)) + WC('d', S(0))))**m_*(S(1)/sin(x_*WC('e', S(1)) + WC('d', S(0))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons1255, cons23) def replacement3125(m, b, d, a, n, c, x, e): rubi.append(3125) return Dist((a + b/sin(d + e*x) + c/tan(d + e*x))**(-n)*(a*sin(d + e*x) + b + c*cos(d + e*x))**n*(S(1)/sin(d + e*x))**n, Int((a*sin(d + e*x) + b + c*cos(d + e*x))**(-n), x), x) rule3125 = ReplacementRule(pattern3125, replacement3125) pattern3126 = Pattern(Integral((WC('b', S(1))*sin(x_*WC('d', S(1)) + WC('c', S(0)))**S(2))**p_, x_), cons3, cons7, cons27, cons13, cons146) def replacement3126(p, b, d, c, x): rubi.append(3126) return Dist(b*(S(2)*p + S(-1))/(S(2)*p), Int((b*sin(c + d*x)**S(2))**(p + S(-1)), x), x) - Simp((b*sin(c + d*x)**S(2))**p/(S(2)*d*p*tan(c + d*x)), x) rule3126 = ReplacementRule(pattern3126, replacement3126) pattern3127 = Pattern(Integral((WC('b', S(1))*cos(x_*WC('d', S(1)) + WC('c', S(0)))**S(2))**p_, x_), cons3, cons7, cons27, cons13, cons146) def replacement3127(p, b, d, c, x): rubi.append(3127) return Dist(b*(S(2)*p + S(-1))/(S(2)*p), Int((b*cos(c + d*x)**S(2))**(p + S(-1)), x), x) + Simp((b*cos(c + d*x)**S(2))**p*tan(c + d*x)/(S(2)*d*p), x) rule3127 = ReplacementRule(pattern3127, replacement3127) pattern3128 = Pattern(Integral((WC('b', S(1))*sin(x_*WC('d', S(1)) + WC('c', S(0)))**S(2))**p_, x_), cons3, cons7, cons27, cons13, cons137) def replacement3128(p, b, d, c, x): rubi.append(3128) return Dist(S(2)*(p + S(1))/(b*(S(2)*p + S(1))), Int((b*sin(c + d*x)**S(2))**(p + S(1)), x), x) + Simp((b*sin(c + d*x)**S(2))**(p + S(1))/(b*d*(S(2)*p + S(1))*tan(c + d*x)), x) rule3128 = ReplacementRule(pattern3128, replacement3128) pattern3129 = Pattern(Integral((WC('b', S(1))*cos(x_*WC('d', S(1)) + WC('c', S(0)))**S(2))**p_, x_), cons3, cons7, cons27, cons13, cons137) def replacement3129(p, b, d, c, x): rubi.append(3129) return Dist(S(2)*(p + S(1))/(b*(S(2)*p + S(1))), Int((b*cos(c + d*x)**S(2))**(p + S(1)), x), x) - Simp((b*cos(c + d*x)**S(2))**(p + S(1))*tan(c + d*x)/(b*d*(S(2)*p + S(1))), x) rule3129 = ReplacementRule(pattern3129, replacement3129) pattern3130 = Pattern(Integral((a_ + WC('b', S(1))*sin(x_*WC('d', S(1)) + WC('c', S(0)))**S(2))**p_, x_), cons2, cons3, cons7, cons27, cons1454, cons38) def replacement3130(p, b, d, c, a, x): rubi.append(3130) return Dist(a**p, Int(cos(c + d*x)**(S(2)*p), x), x) rule3130 = ReplacementRule(pattern3130, replacement3130) pattern3131 = Pattern(Integral((a_ + WC('b', S(1))*cos(x_*WC('d', S(1)) + WC('c', S(0)))**S(2))**p_, x_), cons2, cons3, cons7, cons27, cons1454, cons38) def replacement3131(p, b, d, c, a, x): rubi.append(3131) return Dist(a**p, Int(sin(c + d*x)**(S(2)*p), x), x) rule3131 = ReplacementRule(pattern3131, replacement3131) pattern3132 = Pattern(Integral((a_ + WC('b', S(1))*sin(x_*WC('d', S(1)) + WC('c', S(0)))**S(2))**p_, x_), cons2, cons3, cons7, cons27, cons5, cons1454, cons147) def replacement3132(p, b, d, c, a, x): rubi.append(3132) return Int((a*cos(c + d*x)**S(2))**p, x) rule3132 = ReplacementRule(pattern3132, replacement3132) pattern3133 = Pattern(Integral((a_ + WC('b', S(1))*cos(x_*WC('d', S(1)) + WC('c', S(0)))**S(2))**p_, x_), cons2, cons3, cons7, cons27, cons5, cons1454, cons147) def replacement3133(p, b, d, c, a, x): rubi.append(3133) return Int((a*sin(c + d*x)**S(2))**p, x) rule3133 = ReplacementRule(pattern3133, replacement3133) def With3134(p, b, d, c, a, x): e = FreeFactors(tan(c + d*x), x) rubi.append(3134) return Dist(e/d, Subst(Int((a + e**S(2)*x**S(2)*(a + b))**p*(e**S(2)*x**S(2) + S(1))**(-p + S(-1)), x), x, tan(c + d*x)/e), x) pattern3134 = Pattern(Integral((a_ + WC('b', S(1))*sin(x_*WC('d', S(1)) + WC('c', S(0)))**S(2))**p_, x_), cons2, cons3, cons7, cons27, cons38) rule3134 = ReplacementRule(pattern3134, With3134) def With3135(p, b, d, c, a, x): e = FreeFactors(tan(c + d*x), x) rubi.append(3135) return Dist(e/d, Subst(Int((e**S(2)*x**S(2) + S(1))**(-p + S(-1))*(a*e**S(2)*x**S(2) + a + b)**p, x), x, tan(c + d*x)/e), x) pattern3135 = Pattern(Integral((a_ + WC('b', S(1))*cos(x_*WC('d', S(1)) + WC('c', S(0)))**S(2))**p_, x_), cons2, cons3, cons7, cons27, cons38) rule3135 = ReplacementRule(pattern3135, With3135) pattern3136 = Pattern(Integral((a_ + WC('b', S(1))*sin(x_*WC('d', S(1)) + WC('c', S(0)))**S(2))**p_, x_), cons2, cons3, cons7, cons27, cons5, cons1478, cons147) def replacement3136(p, b, d, c, a, x): rubi.append(3136) return Dist(S(2)**(-p), Int((S(2)*a - b*cos(S(2)*c + S(2)*d*x) + b)**p, x), x) rule3136 = ReplacementRule(pattern3136, replacement3136) pattern3137 = Pattern(Integral((a_ + WC('b', S(1))*cos(x_*WC('d', S(1)) + WC('c', S(0)))**S(2))**p_, x_), cons2, cons3, cons7, cons27, cons5, cons1478, cons147) def replacement3137(p, b, d, c, a, x): rubi.append(3137) return Dist(S(2)**(-p), Int((S(2)*a + b*cos(S(2)*c + S(2)*d*x) + b)**p, x), x) rule3137 = ReplacementRule(pattern3137, replacement3137) pattern3138 = Pattern(Integral((a_ + WC('b', S(1))*sin(x_*WC('d', S(1)) + WC('c', S(0)))**n_)**p_, x_), cons2, cons3, cons7, cons27, cons85, cons128) def replacement3138(p, b, d, c, a, n, x): rubi.append(3138) return Int((a + b*sin(c + d*x)**n)**p, x) rule3138 = ReplacementRule(pattern3138, replacement3138) pattern3139 = Pattern(Integral((a_ + WC('b', S(1))*cos(x_*WC('d', S(1)) + WC('c', S(0)))**n_)**p_, x_), cons2, cons3, cons7, cons27, cons85, cons128) def replacement3139(p, b, d, c, n, a, x): rubi.append(3139) return Int((a + b*cos(c + d*x)**n)**p, x) rule3139 = ReplacementRule(pattern3139, replacement3139) def With3140(p, b, d, c, a, n, x): f = FreeFactors(S(1)/tan(c + d*x), x) rubi.append(3140) return -Dist(f/d, Subst(Int((f**S(2)*x**S(2) + S(1))**(-n*p/S(2) + S(-1))*ExpandToSum(a*(f**S(2)*x**S(2) + S(1))**(n/S(2)) + b, x)**p, x), x, S(1)/(f*tan(c + d*x))), x) pattern3140 = Pattern(Integral((a_ + WC('b', S(1))*sin(x_*WC('d', S(1)) + WC('c', S(0)))**n_)**p_, x_), cons2, cons3, cons7, cons27, cons1479, cons38, cons137) rule3140 = ReplacementRule(pattern3140, With3140) def With3141(p, b, d, c, n, a, x): f = FreeFactors(tan(c + d*x), x) rubi.append(3141) return Dist(f/d, Subst(Int((f**S(2)*x**S(2) + S(1))**(-n*p/S(2) + S(-1))*ExpandToSum(a*(f**S(2)*x**S(2) + S(1))**(n/S(2)) + b, x)**p, x), x, tan(c + d*x)/f), x) pattern3141 = Pattern(Integral((a_ + WC('b', S(1))*cos(x_*WC('d', S(1)) + WC('c', S(0)))**n_)**p_, x_), cons2, cons3, cons7, cons27, cons1479, cons38, cons137) rule3141 = ReplacementRule(pattern3141, With3141) pattern3142 = Pattern(Integral(u_*(a_ + WC('b', S(1))*sin(x_*WC('d', S(1)) + WC('c', S(0)))**S(2))**p_, x_), cons2, cons3, cons7, cons27, cons1454, cons38) def replacement3142(p, u, b, d, c, a, x): rubi.append(3142) return Dist(a**p, Int(ActivateTrig(u)*cos(c + d*x)**(S(2)*p), x), x) rule3142 = ReplacementRule(pattern3142, replacement3142) pattern3143 = Pattern(Integral(u_*(a_ + WC('b', S(1))*cos(x_*WC('d', S(1)) + WC('c', S(0)))**S(2))**p_, x_), cons2, cons3, cons7, cons27, cons1454, cons38) def replacement3143(p, u, b, d, c, a, x): rubi.append(3143) return Dist(a**p, Int(ActivateTrig(u)*sin(c + d*x)**(S(2)*p), x), x) rule3143 = ReplacementRule(pattern3143, replacement3143) pattern3144 = Pattern(Integral(u_*(a_ + WC('b', S(1))*sin(x_*WC('d', S(1)) + WC('c', S(0)))**S(2))**p_, x_), cons2, cons3, cons7, cons27, cons5, cons1454, cons147) def replacement3144(p, u, b, d, c, a, x): rubi.append(3144) return Dist((a*cos(c + d*x)**S(2))**p*cos(c + d*x)**(-S(2)*p), Int(ActivateTrig(u)*cos(c + d*x)**(S(2)*p), x), x) rule3144 = ReplacementRule(pattern3144, replacement3144) pattern3145 = Pattern(Integral(u_*(a_ + WC('b', S(1))*cos(x_*WC('d', S(1)) + WC('c', S(0)))**S(2))**p_, x_), cons2, cons3, cons7, cons27, cons5, cons1454, cons147) def replacement3145(p, u, b, d, c, a, x): rubi.append(3145) return Dist((a*sin(c + d*x)**S(2))**p*sin(c + d*x)**(-S(2)*p), Int(ActivateTrig(u)*sin(c + d*x)**(S(2)*p), x), x) rule3145 = ReplacementRule(pattern3145, replacement3145) def With3146(p, m, b, d, c, a, n, x): f = FreeFactors(S(1)/tan(c + d*x), x) rubi.append(3146) return -Dist(f/d, Subst(Int((f**S(2)*x**S(2) + S(1))**(-m/S(2) - n*p/S(2) + S(-1))*ExpandToSum(a*(f**S(2)*x**S(2) + S(1))**(n/S(2)) + b, x)**p, x), x, S(1)/(f*tan(c + d*x))), x) pattern3146 = Pattern(Integral((a_ + WC('b', S(1))*sin(x_*WC('d', S(1)) + WC('c', S(0)))**n_)**p_*sin(x_*WC('d', S(1)) + WC('c', S(0)))**m_, x_), cons2, cons3, cons7, cons27, cons1479, cons1480, cons38) rule3146 = ReplacementRule(pattern3146, With3146) def With3147(p, m, b, d, c, n, a, x): f = FreeFactors(tan(c + d*x), x) rubi.append(3147) return Dist(f/d, Subst(Int((f**S(2)*x**S(2) + S(1))**(-m/S(2) - n*p/S(2) + S(-1))*ExpandToSum(a*(f**S(2)*x**S(2) + S(1))**(n/S(2)) + b, x)**p, x), x, tan(c + d*x)/f), x) pattern3147 = Pattern(Integral((a_ + WC('b', S(1))*cos(x_*WC('d', S(1)) + WC('c', S(0)))**n_)**p_*cos(x_*WC('d', S(1)) + WC('c', S(0)))**m_, x_), cons2, cons3, cons7, cons27, cons1479, cons1480, cons38) rule3147 = ReplacementRule(pattern3147, With3147) def With3148(p, m, b, d, c, a, n, x): f = FreeFactors(cos(c + d*x), x) rubi.append(3148) return -Dist(f/d, Subst(Int((-f**S(2)*x**S(2) + S(1))**(m/S(2) + S(-1)/2)*ExpandToSum(a + b*(-f**S(2)*x**S(2) + S(1))**(n/S(2)), x)**p, x), x, cos(c + d*x)/f), x) pattern3148 = Pattern(Integral((a_ + WC('b', S(1))*sin(x_*WC('d', S(1)) + WC('c', S(0)))**n_)**p_*sin(x_*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1)), x_), cons2, cons3, cons7, cons27, cons5, cons1479, cons1481) rule3148 = ReplacementRule(pattern3148, With3148) def With3149(p, m, b, d, c, n, a, x): f = FreeFactors(sin(c + d*x), x) rubi.append(3149) return Dist(f/d, Subst(Int((-f**S(2)*x**S(2) + S(1))**(m/S(2) + S(-1)/2)*ExpandToSum(a + b*(-f**S(2)*x**S(2) + S(1))**(n/S(2)), x)**p, x), x, sin(c + d*x)/f), x) pattern3149 = Pattern(Integral((a_ + WC('b', S(1))*cos(x_*WC('d', S(1)) + WC('c', S(0)))**n_)**p_*cos(x_*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1)), x_), cons2, cons3, cons7, cons27, cons5, cons1479, cons1481) rule3149 = ReplacementRule(pattern3149, With3149) pattern3150 = Pattern(Integral((a_ + WC('b', S(1))*sin(x_*WC('d', S(1)) + WC('c', S(0)))**n_)**p_*sin(x_*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1)), x_), cons2, cons3, cons7, cons27, cons375) def replacement3150(p, m, b, d, c, a, n, x): rubi.append(3150) return Int(ExpandTrig((a + b*sin(c + d*x)**n)**p*sin(c + d*x)**m, x), x) rule3150 = ReplacementRule(pattern3150, replacement3150) pattern3151 = Pattern(Integral((a_ + WC('b', S(1))*cos(x_*WC('d', S(1)) + WC('c', S(0)))**n_)**p_*cos(x_*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1)), x_), cons2, cons3, cons7, cons27, cons375) def replacement3151(p, m, b, d, c, n, a, x): rubi.append(3151) return Int(ExpandTrig((a + b*cos(c + d*x)**n)**p*cos(c + d*x)**m, x), x) rule3151 = ReplacementRule(pattern3151, replacement3151) def With3152(p, m, b, d, c, a, n, x): f = FreeFactors(tan(c + d*x), x) rubi.append(3152) return Dist(f/d, Subst(Int((f**S(2)*x**S(2) + S(1))**(-m/S(2) - n*p/S(2) + S(-1))*ExpandToSum(a*(f**S(2)*x**S(2) + S(1))**(n/S(2)) + b*f**n*x**n, x)**p, x), x, tan(c + d*x)/f), x) pattern3152 = Pattern(Integral((a_ + WC('b', S(1))*sin(x_*WC('d', S(1)) + WC('c', S(0)))**n_)**p_*cos(x_*WC('d', S(1)) + WC('c', S(0)))**m_, x_), cons2, cons3, cons7, cons27, cons1480, cons1479, cons38) rule3152 = ReplacementRule(pattern3152, With3152) def With3153(p, m, b, d, c, n, a, x): f = FreeFactors(S(1)/tan(c + d*x), x) rubi.append(3153) return -Dist(f/d, Subst(Int((f**S(2)*x**S(2) + S(1))**(-m/S(2) - n*p/S(2) + S(-1))*ExpandToSum(a*(f**S(2)*x**S(2) + S(1))**(n/S(2)) + b*f**n*x**n, x)**p, x), x, S(1)/(f*tan(c + d*x))), x) pattern3153 = Pattern(Integral((a_ + WC('b', S(1))*cos(x_*WC('d', S(1)) + WC('c', S(0)))**n_)**p_*sin(x_*WC('d', S(1)) + WC('c', S(0)))**m_, x_), cons2, cons3, cons7, cons27, cons1480, cons1479, cons38) rule3153 = ReplacementRule(pattern3153, With3153) pattern3154 = Pattern(Integral((a_ + WC('b', S(1))*sin(x_*WC('d', S(1)) + WC('c', S(0)))**n_)**p_*cos(x_*WC('d', S(1)) + WC('c', S(0)))**m_, x_), cons2, cons3, cons7, cons27, cons1480, cons1482, cons38, cons168) def replacement3154(p, m, b, d, c, a, n, x): rubi.append(3154) return Int((a + b*sin(c + d*x)**n)**p*(-sin(c + d*x)**S(2) + S(1))**(m/S(2)), x) rule3154 = ReplacementRule(pattern3154, replacement3154) pattern3155 = Pattern(Integral((a_ + WC('b', S(1))*cos(x_*WC('d', S(1)) + WC('c', S(0)))**n_)**p_*sin(x_*WC('d', S(1)) + WC('c', S(0)))**m_, x_), cons2, cons3, cons7, cons27, cons1480, cons1482, cons38, cons168) def replacement3155(p, m, b, d, c, n, a, x): rubi.append(3155) return Int((a + b*cos(c + d*x)**n)**p*(-cos(c + d*x)**S(2) + S(1))**(m/S(2)), x) rule3155 = ReplacementRule(pattern3155, replacement3155) pattern3156 = Pattern(Integral((a_ + WC('b', S(1))*sin(x_*WC('d', S(1)) + WC('c', S(0)))**n_)**p_*cos(x_*WC('d', S(1)) + WC('c', S(0)))**m_, x_), cons2, cons3, cons7, cons27, cons1480, cons1482, cons38, cons267, cons137) def replacement3156(p, m, b, d, c, a, n, x): rubi.append(3156) return Int(ExpandTrig((a + b*sin(c + d*x)**n)**p*(-sin(c + d*x)**S(2) + S(1))**(m/S(2)), x), x) rule3156 = ReplacementRule(pattern3156, replacement3156) pattern3157 = Pattern(Integral((a_ + WC('b', S(1))*cos(x_*WC('d', S(1)) + WC('c', S(0)))**n_)**p_*sin(x_*WC('d', S(1)) + WC('c', S(0)))**m_, x_), cons2, cons3, cons7, cons27, cons1480, cons1482, cons38, cons267, cons137) def replacement3157(p, m, b, d, c, n, a, x): rubi.append(3157) return Int(ExpandTrig((a + b*cos(c + d*x)**n)**p*(-cos(c + d*x)**S(2) + S(1))**(m/S(2)), x), x) rule3157 = ReplacementRule(pattern3157, replacement3157) def With3158(p, m, b, d, c, a, n, x, e): f = FreeFactors(sin(c + d*x), x) rubi.append(3158) return Dist(f/d, Subst(Int((a + b*(e*f*x)**n)**p*(-f**S(2)*x**S(2) + S(1))**(m/S(2) + S(-1)/2), x), x, sin(c + d*x)/f), x) pattern3158 = Pattern(Integral((a_ + (WC('e', S(1))*sin(x_*WC('d', S(1)) + WC('c', S(0))))**n_*WC('b', S(1)))**WC('p', S(1))*cos(x_*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons4, cons5, cons1481) rule3158 = ReplacementRule(pattern3158, With3158) def With3159(p, m, b, d, c, n, a, x, e): f = FreeFactors(cos(c + d*x), x) rubi.append(3159) return -Dist(f/d, Subst(Int((a + b*(e*f*x)**n)**p*(-f**S(2)*x**S(2) + S(1))**(m/S(2) + S(-1)/2), x), x, cos(c + d*x)/f), x) pattern3159 = Pattern(Integral((a_ + (WC('e', S(1))*cos(x_*WC('d', S(1)) + WC('c', S(0))))**n_*WC('b', S(1)))**WC('p', S(1))*sin(x_*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons4, cons5, cons1481) rule3159 = ReplacementRule(pattern3159, With3159) def With3160(p, m, b, d, c, a, n, x, e): f = FreeFactors(sin(c + d*x), x) rubi.append(3160) return Dist(f**(m + S(1))/d, Subst(Int(x**m*(a + b*(e*f*x)**n)**p*(-f**S(2)*x**S(2) + S(1))**(-m/S(2) + S(-1)/2), x), x, sin(c + d*x)/f), x) pattern3160 = Pattern(Integral((a_ + (WC('e', S(1))*sin(x_*WC('d', S(1)) + WC('c', S(0))))**n_*WC('b', S(1)))**WC('p', S(1))*tan(x_*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons4, cons1481, cons246) rule3160 = ReplacementRule(pattern3160, With3160) def With3161(p, m, b, d, c, n, a, x, e): f = FreeFactors(cos(c + d*x), x) rubi.append(3161) return -Dist(f**(m + S(1))/d, Subst(Int(x**m*(a + b*(e*f*x)**n)**p*(-f**S(2)*x**S(2) + S(1))**(-m/S(2) + S(-1)/2), x), x, cos(c + d*x)/f), x) pattern3161 = Pattern(Integral((a_ + (WC('e', S(1))*cos(x_*WC('d', S(1)) + WC('c', S(0))))**n_*WC('b', S(1)))**WC('p', S(1))*(S(1)/tan(x_*WC('d', S(1)) + WC('c', S(0))))**WC('m', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons4, cons1481, cons246) rule3161 = ReplacementRule(pattern3161, With3161) def With3162(p, m, b, d, c, a, n, x): f = FreeFactors(tan(c + d*x), x) rubi.append(3162) return Dist(f**(m + S(1))/d, Subst(Int(x**m*(f**S(2)*x**S(2) + S(1))**(-n*p/S(2) + S(-1))*ExpandToSum(a*(f**S(2)*x**S(2) + S(1))**(n/S(2)) + b*f**n*x**n, x)**p, x), x, tan(c + d*x)/f), x) pattern3162 = Pattern(Integral((a_ + WC('b', S(1))*sin(x_*WC('d', S(1)) + WC('c', S(0)))**n_)**WC('p', S(1))*tan(x_*WC('d', S(1)) + WC('c', S(0)))**m_, x_), cons2, cons3, cons7, cons27, cons21, cons1483, cons1479, cons38) rule3162 = ReplacementRule(pattern3162, With3162) def With3163(p, m, b, d, c, n, a, x): f = FreeFactors(S(1)/tan(c + d*x), x) rubi.append(3163) return -Dist(f**(m + S(1))/d, Subst(Int(x**m*(f**S(2)*x**S(2) + S(1))**(-n*p/S(2) + S(-1))*ExpandToSum(a*(f**S(2)*x**S(2) + S(1))**(n/S(2)) + b*f**n*x**n, x)**p, x), x, S(1)/(f*tan(c + d*x))), x) pattern3163 = Pattern(Integral((a_ + WC('b', S(1))*cos(x_*WC('d', S(1)) + WC('c', S(0)))**n_)**WC('p', S(1))*(S(1)/tan(x_*WC('d', S(1)) + WC('c', S(0))))**m_, x_), cons2, cons3, cons7, cons27, cons21, cons1483, cons1479, cons38) rule3163 = ReplacementRule(pattern3163, With3163) def With3164(p, m, b, d, c, a, n, x): f = FreeFactors(tan(c + d*x), x) rubi.append(3164) return Dist(f**(m + S(1))/d, Subst(Int(x**m*((f**S(2)*x**S(2) + S(1))**(-n/S(2))*ExpandToSum(a*(f**S(2)*x**S(2) + S(1))**(n/S(2)) + b*f**n*x**n, x))**p/(f**S(2)*x**S(2) + S(1)), x), x, tan(c + d*x)/f), x) pattern3164 = Pattern(Integral((a_ + WC('b', S(1))*sin(x_*WC('d', S(1)) + WC('c', S(0)))**n_)**WC('p', S(1))*tan(x_*WC('d', S(1)) + WC('c', S(0)))**m_, x_), cons2, cons3, cons7, cons27, cons21, cons5, cons1483, cons1479, cons147) rule3164 = ReplacementRule(pattern3164, With3164) def With3165(p, m, b, d, c, n, a, x): f = FreeFactors(S(1)/tan(c + d*x), x) rubi.append(3165) return -Dist(f**(m + S(1))/d, Subst(Int(x**m*((f**S(2)*x**S(2) + S(1))**(-n/S(2))*ExpandToSum(a*(f**S(2)*x**S(2) + S(1))**(n/S(2)) + b*f**n*x**n, x))**p/(f**S(2)*x**S(2) + S(1)), x), x, S(1)/(f*tan(c + d*x))), x) pattern3165 = Pattern(Integral((a_ + WC('b', S(1))*cos(x_*WC('d', S(1)) + WC('c', S(0)))**n_)**WC('p', S(1))*(S(1)/tan(x_*WC('d', S(1)) + WC('c', S(0))))**m_, x_), cons2, cons3, cons7, cons27, cons21, cons5, cons1483, cons1479, cons147) rule3165 = ReplacementRule(pattern3165, With3165) def With3166(p, m, b, d, c, a, n, x, q, e): f = FreeFactors(S(1)/tan(d + e*x), x) rubi.append(3166) return -Dist(f/e, Subst(Int((f**S(2)*x**S(2) + S(1))**(-m/S(2) - n*q/S(2) + S(-1))*ExpandToSum(a*(f**S(2)*x**S(2) + S(1))**(q/S(2)) + b*(f**S(2)*x**S(2) + S(1))**(-p/S(2) + q/S(2)) + c, x)**n, x), x, S(1)/(f*tan(d + e*x))), x) pattern3166 = Pattern(Integral((a_ + WC('b', S(1))*cos(x_*WC('e', S(1)) + WC('d', S(0)))**p_ + WC('c', S(1))*sin(x_*WC('e', S(1)) + WC('d', S(0)))**q_)**n_*sin(x_*WC('e', S(1)) + WC('d', S(0)))**m_, x_), cons2, cons3, cons7, cons27, cons48, cons1480, cons1484, cons1485, cons85, cons1486) rule3166 = ReplacementRule(pattern3166, With3166) def With3167(p, m, b, d, c, a, n, x, q, e): f = FreeFactors(tan(d + e*x), x) rubi.append(3167) return Dist(f/e, Subst(Int((f**S(2)*x**S(2) + S(1))**(-m/S(2) - n*q/S(2) + S(-1))*ExpandToSum(a*(f**S(2)*x**S(2) + S(1))**(q/S(2)) + b*(f**S(2)*x**S(2) + S(1))**(-p/S(2) + q/S(2)) + c, x)**n, x), x, tan(d + e*x)/f), x) pattern3167 = Pattern(Integral((a_ + WC('b', S(1))*sin(x_*WC('e', S(1)) + WC('d', S(0)))**p_ + WC('c', S(1))*cos(x_*WC('e', S(1)) + WC('d', S(0)))**q_)**n_*cos(x_*WC('e', S(1)) + WC('d', S(0)))**m_, x_), cons2, cons3, cons7, cons27, cons48, cons1480, cons1484, cons1485, cons85, cons1486) rule3167 = ReplacementRule(pattern3167, With3167) def With3168(p, m, b, d, c, a, n, x, q, e): f = FreeFactors(S(1)/tan(d + e*x), x) rubi.append(3168) return -Dist(f/e, Subst(Int((f**S(2)*x**S(2) + S(1))**(-m/S(2) - n*p/S(2) + S(-1))*ExpandToSum(a*(f**S(2)*x**S(2) + S(1))**(p/S(2)) + b*f**p*x**p + c*(f**S(2)*x**S(2) + S(1))**(p/S(2) - q/S(2)), x)**n, x), x, S(1)/(f*tan(d + e*x))), x) pattern3168 = Pattern(Integral((a_ + WC('b', S(1))*cos(x_*WC('e', S(1)) + WC('d', S(0)))**p_ + WC('c', S(1))*sin(x_*WC('e', S(1)) + WC('d', S(0)))**q_)**n_*sin(x_*WC('e', S(1)) + WC('d', S(0)))**m_, x_), cons2, cons3, cons7, cons27, cons48, cons1480, cons1484, cons1485, cons85, cons1487) rule3168 = ReplacementRule(pattern3168, With3168) def With3169(p, m, b, d, c, a, n, x, q, e): f = FreeFactors(tan(d + e*x), x) rubi.append(3169) return Dist(f/e, Subst(Int((f**S(2)*x**S(2) + S(1))**(-m/S(2) - n*p/S(2) + S(-1))*ExpandToSum(a*(f**S(2)*x**S(2) + S(1))**(p/S(2)) + b*f**p*x**p + c*(f**S(2)*x**S(2) + S(1))**(p/S(2) - q/S(2)), x)**n, x), x, tan(d + e*x)/f), x) pattern3169 = Pattern(Integral((a_ + WC('b', S(1))*sin(x_*WC('e', S(1)) + WC('d', S(0)))**p_ + WC('c', S(1))*cos(x_*WC('e', S(1)) + WC('d', S(0)))**q_)**n_*cos(x_*WC('e', S(1)) + WC('d', S(0)))**m_, x_), cons2, cons3, cons7, cons27, cons48, cons1480, cons1484, cons1485, cons85, cons1487) rule3169 = ReplacementRule(pattern3169, With3169) pattern3170 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*sin(x_*WC('e', S(1)) + WC('d', S(0)))**WC('n', S(1)) + WC('c', S(1))*sin(x_*WC('e', S(1)) + WC('d', S(0)))**WC('n2', S(1)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons4, cons46, cons45, cons38) def replacement3170(p, b, n2, d, a, n, c, x, e): rubi.append(3170) return Dist(S(4)**(-p)*c**(-p), Int((b + S(2)*c*sin(d + e*x)**n)**(S(2)*p), x), x) rule3170 = ReplacementRule(pattern3170, replacement3170) pattern3171 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*cos(x_*WC('e', S(1)) + WC('d', S(0)))**WC('n', S(1)) + WC('c', S(1))*cos(x_*WC('e', S(1)) + WC('d', S(0)))**WC('n2', S(1)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons4, cons46, cons45, cons38) def replacement3171(p, b, n2, d, a, n, c, x, e): rubi.append(3171) return Dist(S(4)**(-p)*c**(-p), Int((b + S(2)*c*cos(d + e*x)**n)**(S(2)*p), x), x) rule3171 = ReplacementRule(pattern3171, replacement3171) pattern3172 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*sin(x_*WC('e', S(1)) + WC('d', S(0)))**WC('n', S(1)) + WC('c', S(1))*sin(x_*WC('e', S(1)) + WC('d', S(0)))**WC('n2', S(1)))**p_, x_), cons2, cons3, cons7, cons27, cons48, cons4, cons5, cons46, cons45, cons147) def replacement3172(p, b, n2, d, a, n, c, x, e): rubi.append(3172) return Dist((b + S(2)*c*sin(d + e*x)**n)**(-S(2)*p)*(a + b*sin(d + e*x)**n + c*sin(d + e*x)**(S(2)*n))**p, Int(u*(b + S(2)*c*sin(d + e*x)**n)**(S(2)*p), x), x) rule3172 = ReplacementRule(pattern3172, replacement3172) pattern3173 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*cos(x_*WC('e', S(1)) + WC('d', S(0)))**WC('n', S(1)) + WC('c', S(1))*cos(x_*WC('e', S(1)) + WC('d', S(0)))**WC('n2', S(1)))**p_, x_), cons2, cons3, cons7, cons27, cons48, cons4, cons5, cons46, cons45, cons147) def replacement3173(p, b, n2, d, a, n, c, x, e): rubi.append(3173) return Dist((b + S(2)*c*cos(d + e*x)**n)**(-S(2)*p)*(a + b*cos(d + e*x)**n + c*cos(d + e*x)**(S(2)*n))**p, Int(u*(b + S(2)*c*cos(d + e*x)**n)**(S(2)*p), x), x) rule3173 = ReplacementRule(pattern3173, replacement3173) def With3174(b, n2, d, a, n, c, x, e): q = Rt(-S(4)*a*c + b**S(2), S(2)) rubi.append(3174) return Dist(S(2)*c/q, Int(S(1)/(b + S(2)*c*sin(d + e*x)**n - q), x), x) - Dist(S(2)*c/q, Int(S(1)/(b + S(2)*c*sin(d + e*x)**n + q), x), x) pattern3174 = Pattern(Integral(S(1)/(WC('a', S(0)) + WC('b', S(1))*sin(x_*WC('e', S(1)) + WC('d', S(0)))**WC('n', S(1)) + WC('c', S(1))*sin(x_*WC('e', S(1)) + WC('d', S(0)))**WC('n2', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons4, cons46, cons226) rule3174 = ReplacementRule(pattern3174, With3174) def With3175(b, n2, d, a, n, c, x, e): q = Rt(-S(4)*a*c + b**S(2), S(2)) rubi.append(3175) return Dist(S(2)*c/q, Int(S(1)/(b + S(2)*c*cos(d + e*x)**n - q), x), x) - Dist(S(2)*c/q, Int(S(1)/(b + S(2)*c*cos(d + e*x)**n + q), x), x) pattern3175 = Pattern(Integral(S(1)/(WC('a', S(0)) + WC('b', S(1))*cos(x_*WC('e', S(1)) + WC('d', S(0)))**WC('n', S(1)) + WC('c', S(1))*cos(x_*WC('e', S(1)) + WC('d', S(0)))**WC('n2', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons4, cons46, cons226) rule3175 = ReplacementRule(pattern3175, With3175) pattern3176 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*sin(x_*WC('e', S(1)) + WC('d', S(0)))**WC('n', S(1)) + WC('c', S(1))*sin(x_*WC('e', S(1)) + WC('d', S(0)))**WC('n2', S(1)))**p_*sin(x_*WC('e', S(1)) + WC('d', S(0)))**WC('m', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons21, cons4, cons46, cons45, cons38) def replacement3176(p, m, b, n2, d, a, n, c, x, e): rubi.append(3176) return Dist(S(4)**(-p)*c**(-p), Int((b + S(2)*c*sin(d + e*x)**n)**(S(2)*p)*sin(d + e*x)**m, x), x) rule3176 = ReplacementRule(pattern3176, replacement3176) pattern3177 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*cos(x_*WC('e', S(1)) + WC('d', S(0)))**WC('n', S(1)) + WC('c', S(1))*cos(x_*WC('e', S(1)) + WC('d', S(0)))**WC('n2', S(1)))**p_*cos(x_*WC('e', S(1)) + WC('d', S(0)))**WC('m', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons21, cons4, cons46, cons45, cons38) def replacement3177(p, m, b, n2, d, a, n, c, x, e): rubi.append(3177) return Dist(S(4)**(-p)*c**(-p), Int((b + S(2)*c*cos(d + e*x)**n)**(S(2)*p)*cos(d + e*x)**m, x), x) rule3177 = ReplacementRule(pattern3177, replacement3177) pattern3178 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*sin(x_*WC('e', S(1)) + WC('d', S(0)))**WC('n', S(1)) + WC('c', S(1))*sin(x_*WC('e', S(1)) + WC('d', S(0)))**WC('n2', S(1)))**p_*sin(x_*WC('e', S(1)) + WC('d', S(0)))**WC('m', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons21, cons4, cons5, cons46, cons45, cons147) def replacement3178(p, m, b, n2, d, a, n, c, x, e): rubi.append(3178) return Dist((b + S(2)*c*sin(d + e*x)**n)**(-S(2)*p)*(a + b*sin(d + e*x)**n + c*sin(d + e*x)**(S(2)*n))**p, Int((b + S(2)*c*sin(d + e*x)**n)**(S(2)*p)*sin(d + e*x)**m, x), x) rule3178 = ReplacementRule(pattern3178, replacement3178) pattern3179 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*cos(x_*WC('e', S(1)) + WC('d', S(0)))**WC('n', S(1)) + WC('c', S(1))*cos(x_*WC('e', S(1)) + WC('d', S(0)))**WC('n2', S(1)))**p_*cos(x_*WC('e', S(1)) + WC('d', S(0)))**WC('m', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons21, cons4, cons5, cons46, cons45, cons147) def replacement3179(p, m, b, n2, d, a, n, c, x, e): rubi.append(3179) return Dist((b + S(2)*c*cos(d + e*x)**n)**(-S(2)*p)*(a + b*cos(d + e*x)**n + c*cos(d + e*x)**(S(2)*n))**p, Int((b + S(2)*c*cos(d + e*x)**n)**(S(2)*p)*cos(d + e*x)**m, x), x) rule3179 = ReplacementRule(pattern3179, replacement3179) def With3180(p, m, b, n2, d, c, a, n, x, e): f = FreeFactors(S(1)/tan(d + e*x), x) rubi.append(3180) return -Dist(f/e, Subst(Int((f**S(2)*x**S(2) + S(1))**(-m/S(2) - n*p + S(-1))*ExpandToSum(a*(x**S(2) + S(1))**n + b*(x**S(2) + S(1))**(n/S(2)) + c, x)**p, x), x, S(1)/(f*tan(d + e*x))), x) pattern3180 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*sin(x_*WC('e', S(1)) + WC('d', S(0)))**n_ + WC('c', S(1))*sin(x_*WC('e', S(1)) + WC('d', S(0)))**n2_)**p_*sin(x_*WC('e', S(1)) + WC('d', S(0)))**m_, x_), cons2, cons3, cons7, cons27, cons48, cons46, cons1480, cons226, cons1479, cons38) rule3180 = ReplacementRule(pattern3180, With3180) def With3181(p, m, b, n2, d, a, c, n, x, e): f = FreeFactors(tan(d + e*x), x) rubi.append(3181) return Dist(f/e, Subst(Int((f**S(2)*x**S(2) + S(1))**(-m/S(2) - n*p + S(-1))*ExpandToSum(a*(x**S(2) + S(1))**n + b*(x**S(2) + S(1))**(n/S(2)) + c, x)**p, x), x, tan(d + e*x)/f), x) pattern3181 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*cos(x_*WC('e', S(1)) + WC('d', S(0)))**n_ + WC('c', S(1))*cos(x_*WC('e', S(1)) + WC('d', S(0)))**n2_)**p_*cos(x_*WC('e', S(1)) + WC('d', S(0)))**WC('m', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons46, cons1480, cons226, cons1479, cons38) rule3181 = ReplacementRule(pattern3181, With3181) pattern3182 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*sin(x_*WC('e', S(1)) + WC('d', S(0)))**WC('n', S(1)) + WC('c', S(1))*sin(x_*WC('e', S(1)) + WC('d', S(0)))**WC('n2', S(1)))**p_*sin(x_*WC('e', S(1)) + WC('d', S(0)))**WC('m', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons46, cons226, cons375) def replacement3182(p, m, b, n2, d, a, n, c, x, e): rubi.append(3182) return Int(ExpandTrig((a + b*sin(d + e*x)**n + c*sin(d + e*x)**(S(2)*n))**p*sin(d + e*x)**m, x), x) rule3182 = ReplacementRule(pattern3182, replacement3182) pattern3183 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*cos(x_*WC('e', S(1)) + WC('d', S(0)))**WC('n', S(1)) + WC('c', S(1))*cos(x_*WC('e', S(1)) + WC('d', S(0)))**WC('n2', S(1)))**p_*cos(x_*WC('e', S(1)) + WC('d', S(0)))**WC('m', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons46, cons226, cons375) def replacement3183(p, m, b, n2, d, a, n, c, x, e): rubi.append(3183) return Int(ExpandTrig((a + b*cos(d + e*x)**n + c*cos(d + e*x)**(S(2)*n))**p*cos(d + e*x)**m, x), x) rule3183 = ReplacementRule(pattern3183, replacement3183) def With3184(p, m, f, b, n2, d, a, n, c, x, e): g = FreeFactors(sin(d + e*x), x) rubi.append(3184) return Dist(g/e, Subst(Int((-g**S(2)*x**S(2) + S(1))**(m/S(2) + S(-1)/2)*(a + b*(f*g*x)**n + c*(f*g*x)**(S(2)*n))**p, x), x, sin(d + e*x)/g), x) pattern3184 = Pattern(Integral(((WC('f', S(1))*sin(x_*WC('e', S(1)) + WC('d', S(0))))**WC('n', S(1))*WC('b', S(1)) + (WC('f', S(1))*sin(x_*WC('e', S(1)) + WC('d', S(0))))**WC('n2', S(1))*WC('c', S(1)) + WC('a', S(0)))**WC('p', S(1))*cos(x_*WC('e', S(1)) + WC('d', S(0)))**WC('m', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons4, cons5, cons46, cons1481) rule3184 = ReplacementRule(pattern3184, With3184) def With3185(p, m, f, b, n2, d, a, n, c, x, e): g = FreeFactors(cos(d + e*x), x) rubi.append(3185) return -Dist(g/e, Subst(Int((-g**S(2)*x**S(2) + S(1))**(m/S(2) + S(-1)/2)*(a + b*(f*g*x)**n + c*(f*g*x)**(S(2)*n))**p, x), x, cos(d + e*x)/g), x) pattern3185 = Pattern(Integral(((WC('f', S(1))*cos(x_*WC('e', S(1)) + WC('d', S(0))))**WC('n', S(1))*WC('b', S(1)) + (WC('f', S(1))*cos(x_*WC('e', S(1)) + WC('d', S(0))))**WC('n2', S(1))*WC('c', S(1)) + WC('a', S(0)))**WC('p', S(1))*sin(x_*WC('e', S(1)) + WC('d', S(0)))**WC('m', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons4, cons5, cons46, cons1481) rule3185 = ReplacementRule(pattern3185, With3185) pattern3186 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*sin(x_*WC('e', S(1)) + WC('d', S(0)))**WC('n', S(1)) + WC('c', S(1))*sin(x_*WC('e', S(1)) + WC('d', S(0)))**WC('n2', S(1)))**WC('p', S(1))*cos(x_*WC('e', S(1)) + WC('d', S(0)))**m_, x_), cons2, cons3, cons7, cons27, cons48, cons21, cons4, cons46, cons1483, cons45, cons38) def replacement3186(p, m, b, n2, d, a, n, c, x, e): rubi.append(3186) return Dist(S(4)**(-p)*c**(-p), Int((b + S(2)*c*sin(d + e*x)**n)**(S(2)*p)*cos(d + e*x)**m, x), x) rule3186 = ReplacementRule(pattern3186, replacement3186) pattern3187 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*cos(x_*WC('e', S(1)) + WC('d', S(0)))**WC('n', S(1)) + WC('c', S(1))*cos(x_*WC('e', S(1)) + WC('d', S(0)))**WC('n2', S(1)))**WC('p', S(1))*sin(x_*WC('e', S(1)) + WC('d', S(0)))**m_, x_), cons2, cons3, cons7, cons27, cons48, cons21, cons4, cons46, cons1483, cons45, cons38) def replacement3187(p, m, b, n2, d, a, n, c, x, e): rubi.append(3187) return Dist(S(4)**(-p)*c**(-p), Int((b + S(2)*c*cos(d + e*x)**n)**(S(2)*p)*sin(d + e*x)**m, x), x) rule3187 = ReplacementRule(pattern3187, replacement3187) pattern3188 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*sin(x_*WC('e', S(1)) + WC('d', S(0)))**WC('n', S(1)) + WC('c', S(1))*sin(x_*WC('e', S(1)) + WC('d', S(0)))**WC('n2', S(1)))**p_*cos(x_*WC('e', S(1)) + WC('d', S(0)))**m_, x_), cons2, cons3, cons7, cons27, cons48, cons21, cons4, cons5, cons46, cons1483, cons45, cons147) def replacement3188(p, m, b, n2, d, a, n, c, x, e): rubi.append(3188) return Dist((b + S(2)*c*sin(d + e*x)**n)**(-S(2)*p)*(a + b*sin(d + e*x)**n + c*sin(d + e*x)**(S(2)*n))**p, Int((b + S(2)*c*sin(d + e*x)**n)**(S(2)*p)*cos(d + e*x)**m, x), x) rule3188 = ReplacementRule(pattern3188, replacement3188) pattern3189 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*cos(x_*WC('e', S(1)) + WC('d', S(0)))**WC('n', S(1)) + WC('c', S(1))*cos(x_*WC('e', S(1)) + WC('d', S(0)))**WC('n2', S(1)))**p_*sin(x_*WC('e', S(1)) + WC('d', S(0)))**m_, x_), cons2, cons3, cons7, cons27, cons48, cons21, cons4, cons5, cons46, cons1483, cons45, cons147) def replacement3189(p, m, b, n2, d, a, n, c, x, e): rubi.append(3189) return Dist((b + S(2)*c*cos(d + e*x)**n)**(-S(2)*p)*(a + b*cos(d + e*x)**n + c*cos(d + e*x)**(S(2)*n))**p, Int((b + S(2)*c*cos(d + e*x)**n)**(S(2)*p)*sin(d + e*x)**m, x), x) rule3189 = ReplacementRule(pattern3189, replacement3189) def With3190(p, m, b, n2, d, c, a, n, x, e): f = FreeFactors(S(1)/tan(d + e*x), x) rubi.append(3190) return -Dist(f**(m + S(1))/e, Subst(Int(x**m*(f**S(2)*x**S(2) + S(1))**(-m/S(2) - n*p + S(-1))*ExpandToSum(a*(x**S(2) + S(1))**n + b*(x**S(2) + S(1))**(n/S(2)) + c, x)**p, x), x, S(1)/(f*tan(d + e*x))), x) pattern3190 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*sin(x_*WC('e', S(1)) + WC('d', S(0)))**n_ + WC('c', S(1))*sin(x_*WC('e', S(1)) + WC('d', S(0)))**n2_)**WC('p', S(1))*cos(x_*WC('e', S(1)) + WC('d', S(0)))**m_, x_), cons2, cons3, cons7, cons27, cons48, cons46, cons1480, cons226, cons1479, cons38) rule3190 = ReplacementRule(pattern3190, With3190) def With3191(p, m, b, n2, d, c, a, n, x, e): f = FreeFactors(tan(d + e*x), x) rubi.append(3191) return Dist(f**(m + S(1))/e, Subst(Int(x**m*(f**S(2)*x**S(2) + S(1))**(-m/S(2) - n*p + S(-1))*ExpandToSum(a*(x**S(2) + S(1))**n + b*(x**S(2) + S(1))**(n/S(2)) + c, x)**p, x), x, tan(d + e*x)/f), x) pattern3191 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*cos(x_*WC('e', S(1)) + WC('d', S(0)))**n_ + WC('c', S(1))*cos(x_*WC('e', S(1)) + WC('d', S(0)))**n2_)**WC('p', S(1))*sin(x_*WC('e', S(1)) + WC('d', S(0)))**WC('m', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons46, cons1480, cons226, cons1479, cons38) rule3191 = ReplacementRule(pattern3191, With3191) pattern3192 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*sin(x_*WC('e', S(1)) + WC('d', S(0)))**WC('n', S(1)) + WC('c', S(1))*sin(x_*WC('e', S(1)) + WC('d', S(0)))**WC('n2', S(1)))**WC('p', S(1))*cos(x_*WC('e', S(1)) + WC('d', S(0)))**WC('m', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons46, cons1480, cons226, cons376) def replacement3192(p, m, b, n2, d, a, n, c, x, e): rubi.append(3192) return Int(ExpandTrig((-sin(d + e*x)**S(2) + S(1))**(m/S(2))*(a + b*sin(d + e*x)**n + c*sin(d + e*x)**(S(2)*n))**p, x), x) rule3192 = ReplacementRule(pattern3192, replacement3192) pattern3193 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*cos(x_*WC('e', S(1)) + WC('d', S(0)))**WC('n', S(1)) + WC('c', S(1))*cos(x_*WC('e', S(1)) + WC('d', S(0)))**WC('n2', S(1)))**WC('p', S(1))*sin(x_*WC('e', S(1)) + WC('d', S(0)))**WC('m', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons46, cons1480, cons226, cons376) def replacement3193(p, m, b, n2, d, a, n, c, x, e): rubi.append(3193) return Int(ExpandTrig((-cos(d + e*x)**S(2) + S(1))**(m/S(2))*(a + b*cos(d + e*x)**n + c*cos(d + e*x)**(S(2)*n))**p, x), x) rule3193 = ReplacementRule(pattern3193, replacement3193) def With3194(p, m, f, b, n2, d, c, a, n, x, e): g = FreeFactors(sin(d + e*x), x) rubi.append(3194) return Dist(g**(m + S(1))/e, Subst(Int(x**m*(-g**S(2)*x**S(2) + S(1))**(-m/S(2) + S(-1)/2)*(a + b*(f*g*x)**n + c*(f*g*x)**(S(2)*n))**p, x), x, sin(d + e*x)/g), x) pattern3194 = Pattern(Integral((a_ + (WC('f', S(1))*sin(x_*WC('e', S(1)) + WC('d', S(0))))**n_*WC('b', S(1)) + (WC('f', S(1))*sin(x_*WC('e', S(1)) + WC('d', S(0))))**WC('n2', S(1))*WC('c', S(1)))**WC('p', S(1))*tan(x_*WC('e', S(1)) + WC('d', S(0)))**WC('m', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons4, cons1481, cons246) rule3194 = ReplacementRule(pattern3194, With3194) def With3195(p, m, f, b, n2, d, c, n, a, x, e): g = FreeFactors(cos(d + e*x), x) rubi.append(3195) return -Dist(g**(m + S(1))/e, Subst(Int(x**m*(-g**S(2)*x**S(2) + S(1))**(-m/S(2) + S(-1)/2)*(a + b*(f*g*x)**n + c*(f*g*x)**(S(2)*n))**p, x), x, cos(d + e*x)/g), x) pattern3195 = Pattern(Integral((a_ + (WC('f', S(1))*cos(x_*WC('e', S(1)) + WC('d', S(0))))**n_*WC('b', S(1)) + (WC('f', S(1))*cos(x_*WC('e', S(1)) + WC('d', S(0))))**WC('n2', S(1))*WC('c', S(1)))**WC('p', S(1))*(S(1)/tan(x_*WC('e', S(1)) + WC('d', S(0))))**WC('m', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons4, cons1481, cons246) rule3195 = ReplacementRule(pattern3195, With3195) pattern3196 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*sin(x_*WC('e', S(1)) + WC('d', S(0)))**WC('n', S(1)) + WC('c', S(1))*sin(x_*WC('e', S(1)) + WC('d', S(0)))**WC('n2', S(1)))**WC('p', S(1))*tan(x_*WC('e', S(1)) + WC('d', S(0)))**m_, x_), cons2, cons3, cons7, cons27, cons48, cons21, cons4, cons46, cons1483, cons45, cons38) def replacement3196(p, m, b, n2, d, a, n, c, x, e): rubi.append(3196) return Dist(S(4)**(-p)*c**(-p), Int((b + S(2)*c*sin(d + e*x)**n)**(S(2)*p)*tan(d + e*x)**m, x), x) rule3196 = ReplacementRule(pattern3196, replacement3196) pattern3197 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*cos(x_*WC('e', S(1)) + WC('d', S(0)))**WC('n', S(1)) + WC('c', S(1))*cos(x_*WC('e', S(1)) + WC('d', S(0)))**WC('n2', S(1)))**WC('p', S(1))*(S(1)/tan(x_*WC('e', S(1)) + WC('d', S(0))))**m_, x_), cons2, cons3, cons7, cons27, cons48, cons21, cons4, cons46, cons1483, cons45, cons38) def replacement3197(p, m, b, n2, d, a, n, c, x, e): rubi.append(3197) return Dist(S(4)**(-p)*c**(-p), Int((b + S(2)*c*cos(d + e*x)**n)**(S(2)*p)*(S(1)/tan(d + e*x))**m, x), x) rule3197 = ReplacementRule(pattern3197, replacement3197) pattern3198 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*sin(x_*WC('e', S(1)) + WC('d', S(0)))**WC('n', S(1)) + WC('c', S(1))*sin(x_*WC('e', S(1)) + WC('d', S(0)))**WC('n2', S(1)))**p_*tan(x_*WC('e', S(1)) + WC('d', S(0)))**m_, x_), cons2, cons3, cons7, cons27, cons48, cons21, cons4, cons5, cons46, cons1483, cons45, cons147) def replacement3198(p, m, b, n2, d, a, n, c, x, e): rubi.append(3198) return Dist((b + S(2)*c*sin(d + e*x)**n)**(-S(2)*p)*(a + b*sin(d + e*x)**n + c*sin(d + e*x)**(S(2)*n))**p, Int((b + S(2)*c*sin(d + e*x)**n)**(S(2)*p)*tan(d + e*x)**m, x), x) rule3198 = ReplacementRule(pattern3198, replacement3198) pattern3199 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*cos(x_*WC('e', S(1)) + WC('d', S(0)))**WC('n', S(1)) + WC('c', S(1))*cos(x_*WC('e', S(1)) + WC('d', S(0)))**WC('n2', S(1)))**p_*(S(1)/tan(x_*WC('e', S(1)) + WC('d', S(0))))**m_, x_), cons2, cons3, cons7, cons27, cons48, cons21, cons4, cons5, cons46, cons1483, cons45, cons147) def replacement3199(p, m, b, n2, d, a, n, c, x, e): rubi.append(3199) return Dist((b + S(2)*c*cos(d + e*x)**n)**(-S(2)*p)*(a + b*cos(d + e*x)**n + c*cos(d + e*x)**(S(2)*n))**p, Int((b + S(2)*c*cos(d + e*x)**n)**(S(2)*p)*(S(1)/tan(d + e*x))**m, x), x) rule3199 = ReplacementRule(pattern3199, replacement3199) def With3200(p, m, b, n2, d, c, a, n, x, e): f = FreeFactors(tan(d + e*x), x) rubi.append(3200) return Dist(f**(m + S(1))/e, Subst(Int(x**m*(f**S(2)*x**S(2) + S(1))**(-n*p + S(-1))*ExpandToSum(a*(x**S(2) + S(1))**n + b*x**n*(x**S(2) + S(1))**(n/S(2)) + c*x**(S(2)*n), x)**p, x), x, tan(d + e*x)/f), x) pattern3200 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*sin(x_*WC('e', S(1)) + WC('d', S(0)))**n_ + WC('c', S(1))*sin(x_*WC('e', S(1)) + WC('d', S(0)))**n2_)**WC('p', S(1))*tan(x_*WC('e', S(1)) + WC('d', S(0)))**WC('m', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons21, cons46, cons1483, cons226, cons1479, cons38) rule3200 = ReplacementRule(pattern3200, With3200) def With3201(p, m, b, n2, d, a, c, n, x, e): f = FreeFactors(S(1)/tan(d + e*x), x) rubi.append(3201) return -Dist(f**(m + S(1))/e, Subst(Int(x**m*(f**S(2)*x**S(2) + S(1))**(-n*p + S(-1))*ExpandToSum(a*(x**S(2) + S(1))**n + b*x**n*(x**S(2) + S(1))**(n/S(2)) + c*x**(S(2)*n), x)**p, x), x, S(1)/(f*tan(d + e*x))), x) pattern3201 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*cos(x_*WC('e', S(1)) + WC('d', S(0)))**n_ + WC('c', S(1))*cos(x_*WC('e', S(1)) + WC('d', S(0)))**n2_)**WC('p', S(1))*(S(1)/tan(x_*WC('e', S(1)) + WC('d', S(0))))**WC('m', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons21, cons46, cons1483, cons226, cons1479, cons38) rule3201 = ReplacementRule(pattern3201, With3201) pattern3202 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*sin(x_*WC('e', S(1)) + WC('d', S(0)))**WC('n', S(1)) + WC('c', S(1))*sin(x_*WC('e', S(1)) + WC('d', S(0)))**WC('n2', S(1)))**WC('p', S(1))*tan(x_*WC('e', S(1)) + WC('d', S(0)))**WC('m', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons46, cons1480, cons226, cons376) def replacement3202(p, m, b, n2, d, a, n, c, x, e): rubi.append(3202) return Int(ExpandTrig((-sin(d + e*x)**S(2) + S(1))**(-m/S(2))*(a + b*sin(d + e*x)**n + c*sin(d + e*x)**(S(2)*n))**p*sin(d + e*x)**m, x), x) rule3202 = ReplacementRule(pattern3202, replacement3202) pattern3203 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*cos(x_*WC('e', S(1)) + WC('d', S(0)))**WC('n', S(1)) + WC('c', S(1))*cos(x_*WC('e', S(1)) + WC('d', S(0)))**WC('n2', S(1)))**WC('p', S(1))*(S(1)/tan(x_*WC('e', S(1)) + WC('d', S(0))))**WC('m', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons46, cons1480, cons226, cons376) def replacement3203(p, m, b, n2, d, a, n, c, x, e): rubi.append(3203) return Int(ExpandTrig((-cos(d + e*x)**S(2) + S(1))**(-m/S(2))*(a + b*cos(d + e*x)**n + c*cos(d + e*x)**(S(2)*n))**p*cos(d + e*x)**m, x), x) rule3203 = ReplacementRule(pattern3203, replacement3203) def With3204(p, m, f, b, n2, d, c, a, n, x, e): g = FreeFactors(sin(d + e*x), x) rubi.append(3204) return Dist(g**(m + S(1))/e, Subst(Int(x**(-m)*(-g**S(2)*x**S(2) + S(1))**(m/S(2) + S(-1)/2)*(a + b*(f*g*x)**n + c*(f*g*x)**(S(2)*n))**p, x), x, sin(d + e*x)/g), x) pattern3204 = Pattern(Integral((a_ + (WC('f', S(1))*sin(x_*WC('e', S(1)) + WC('d', S(0))))**n_*WC('b', S(1)) + (WC('f', S(1))*sin(x_*WC('e', S(1)) + WC('d', S(0))))**WC('n2', S(1))*WC('c', S(1)))**WC('p', S(1))*(S(1)/tan(x_*WC('e', S(1)) + WC('d', S(0))))**WC('m', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons4, cons1481, cons246) rule3204 = ReplacementRule(pattern3204, With3204) def With3205(p, m, f, b, n2, d, c, n, a, x, e): g = FreeFactors(cos(d + e*x), x) rubi.append(3205) return -Dist(g**(m + S(1))/e, Subst(Int(x**(-m)*(-g**S(2)*x**S(2) + S(1))**(m/S(2) + S(-1)/2)*(a + b*(f*g*x)**n + c*(f*g*x)**(S(2)*n))**p, x), x, cos(d + e*x)/g), x) pattern3205 = Pattern(Integral((a_ + (WC('f', S(1))*cos(x_*WC('e', S(1)) + WC('d', S(0))))**n_*WC('b', S(1)) + (WC('f', S(1))*cos(x_*WC('e', S(1)) + WC('d', S(0))))**WC('n2', S(1))*WC('c', S(1)))**WC('p', S(1))*tan(x_*WC('e', S(1)) + WC('d', S(0)))**WC('m', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons4, cons1481, cons246) rule3205 = ReplacementRule(pattern3205, With3205) pattern3206 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*sin(x_*WC('e', S(1)) + WC('d', S(0)))**WC('n', S(1)) + WC('c', S(1))*sin(x_*WC('e', S(1)) + WC('d', S(0)))**WC('n2', S(1)))**WC('p', S(1))*(S(1)/tan(x_*WC('e', S(1)) + WC('d', S(0))))**m_, x_), cons2, cons3, cons7, cons27, cons48, cons21, cons4, cons46, cons1483, cons45, cons38) def replacement3206(p, m, b, n2, d, a, n, c, x, e): rubi.append(3206) return Dist(S(4)**(-p)*c**(-p), Int((b + S(2)*c*sin(d + e*x)**n)**(S(2)*p)*(S(1)/tan(d + e*x))**m, x), x) rule3206 = ReplacementRule(pattern3206, replacement3206) pattern3207 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*cos(x_*WC('e', S(1)) + WC('d', S(0)))**WC('n', S(1)) + WC('c', S(1))*cos(x_*WC('e', S(1)) + WC('d', S(0)))**WC('n2', S(1)))**WC('p', S(1))*tan(x_*WC('e', S(1)) + WC('d', S(0)))**m_, x_), cons2, cons3, cons7, cons27, cons48, cons21, cons4, cons46, cons1483, cons45, cons38) def replacement3207(p, m, b, n2, d, a, n, c, x, e): rubi.append(3207) return Dist(S(4)**(-p)*c**(-p), Int((b + S(2)*c*cos(d + e*x)**n)**(S(2)*p)*tan(d + e*x)**m, x), x) rule3207 = ReplacementRule(pattern3207, replacement3207) pattern3208 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*sin(x_*WC('e', S(1)) + WC('d', S(0)))**WC('n', S(1)) + WC('c', S(1))*sin(x_*WC('e', S(1)) + WC('d', S(0)))**WC('n2', S(1)))**p_*(S(1)/tan(x_*WC('e', S(1)) + WC('d', S(0))))**m_, x_), cons2, cons3, cons7, cons27, cons48, cons21, cons4, cons5, cons46, cons1483, cons45, cons147) def replacement3208(p, m, b, n2, d, a, n, c, x, e): rubi.append(3208) return Dist((b + S(2)*c*sin(d + e*x)**n)**(-S(2)*p)*(a + b*sin(d + e*x)**n + c*sin(d + e*x)**(S(2)*n))**p, Int((b + S(2)*c*sin(d + e*x)**n)**(S(2)*p)*(S(1)/tan(d + e*x))**m, x), x) rule3208 = ReplacementRule(pattern3208, replacement3208) pattern3209 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*cos(x_*WC('e', S(1)) + WC('d', S(0)))**WC('n', S(1)) + WC('c', S(1))*cos(x_*WC('e', S(1)) + WC('d', S(0)))**WC('n2', S(1)))**p_*tan(x_*WC('e', S(1)) + WC('d', S(0)))**m_, x_), cons2, cons3, cons7, cons27, cons48, cons21, cons4, cons5, cons46, cons1483, cons45, cons147) def replacement3209(p, m, b, n2, d, a, n, c, x, e): rubi.append(3209) return Dist((b + S(2)*c*cos(d + e*x)**n)**(-S(2)*p)*(a + b*cos(d + e*x)**n + c*cos(d + e*x)**(S(2)*n))**p, Int((b + S(2)*c*cos(d + e*x)**n)**(S(2)*p)*tan(d + e*x)**m, x), x) rule3209 = ReplacementRule(pattern3209, replacement3209) def With3210(p, m, b, n2, d, c, a, n, x, e): f = FreeFactors(S(1)/tan(d + e*x), x) rubi.append(3210) return -Dist(f**(m + S(1))/e, Subst(Int(x**m*(f**S(2)*x**S(2) + S(1))**(-n*p + S(-1))*ExpandToSum(a*(f**S(2)*x**S(2) + S(1))**n + b*(f**S(2)*x**S(2) + S(1))**(n/S(2)) + c, x)**p, x), x, S(1)/(f*tan(d + e*x))), x) pattern3210 = Pattern(Integral((a_ + WC('b', S(1))*sin(x_*WC('e', S(1)) + WC('d', S(0)))**n_ + WC('c', S(1))*sin(x_*WC('e', S(1)) + WC('d', S(0)))**n2_)**WC('p', S(1))*(S(1)/tan(x_*WC('e', S(1)) + WC('d', S(0))))**WC('m', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons21, cons46, cons1479, cons38) rule3210 = ReplacementRule(pattern3210, With3210) def With3211(p, m, b, n2, d, c, n, a, x, e): f = FreeFactors(tan(d + e*x), x) rubi.append(3211) return Dist(f**(m + S(1))/e, Subst(Int(x**m*(f**S(2)*x**S(2) + S(1))**(-n*p + S(-1))*ExpandToSum(a*(f**S(2)*x**S(2) + S(1))**n + b*(f**S(2)*x**S(2) + S(1))**(n/S(2)) + c, x)**p, x), x, tan(d + e*x)/f), x) pattern3211 = Pattern(Integral((a_ + WC('b', S(1))*cos(x_*WC('e', S(1)) + WC('d', S(0)))**n_ + WC('c', S(1))*cos(x_*WC('e', S(1)) + WC('d', S(0)))**n2_)**WC('p', S(1))*tan(x_*WC('e', S(1)) + WC('d', S(0)))**WC('m', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons21, cons46, cons1479, cons38) rule3211 = ReplacementRule(pattern3211, With3211) pattern3212 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*sin(x_*WC('e', S(1)) + WC('d', S(0)))**WC('n', S(1)) + WC('c', S(1))*sin(x_*WC('e', S(1)) + WC('d', S(0)))**WC('n2', S(1)))**WC('p', S(1))*(S(1)/tan(x_*WC('e', S(1)) + WC('d', S(0))))**WC('m', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons46, cons1480, cons226, cons376) def replacement3212(p, m, b, n2, d, a, n, c, x, e): rubi.append(3212) return Int(ExpandTrig((-sin(d + e*x)**S(2) + S(1))**(m/S(2))*(a + b*sin(d + e*x)**n + c*sin(d + e*x)**(S(2)*n))**p*sin(d + e*x)**(-m), x), x) rule3212 = ReplacementRule(pattern3212, replacement3212) pattern3213 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*cos(x_*WC('e', S(1)) + WC('d', S(0)))**WC('n', S(1)) + WC('c', S(1))*cos(x_*WC('e', S(1)) + WC('d', S(0)))**WC('n2', S(1)))**WC('p', S(1))*tan(x_*WC('e', S(1)) + WC('d', S(0)))**WC('m', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons46, cons1480, cons226, cons376) def replacement3213(p, m, b, n2, d, a, n, c, x, e): rubi.append(3213) return Int(ExpandTrig((-cos(d + e*x)**S(2) + S(1))**(m/S(2))*(a + b*cos(d + e*x)**n + c*cos(d + e*x)**(S(2)*n))**p*cos(d + e*x)**(-m), x), x) rule3213 = ReplacementRule(pattern3213, replacement3213) pattern3214 = Pattern(Integral((A_ + WC('B', S(1))*sin(x_*WC('e', S(1)) + WC('d', S(0))))*(a_ + WC('b', S(1))*sin(x_*WC('e', S(1)) + WC('d', S(0))) + WC('c', S(1))*sin(x_*WC('e', S(1)) + WC('d', S(0)))**S(2))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons34, cons35, cons45, cons85) def replacement3214(B, b, d, c, a, n, A, x, e): rubi.append(3214) return Dist(S(4)**(-n)*c**(-n), Int((A + B*sin(d + e*x))*(b + S(2)*c*sin(d + e*x))**(S(2)*n), x), x) rule3214 = ReplacementRule(pattern3214, replacement3214) pattern3215 = Pattern(Integral((A_ + WC('B', S(1))*cos(x_*WC('e', S(1)) + WC('d', S(0))))*(a_ + WC('b', S(1))*cos(x_*WC('e', S(1)) + WC('d', S(0))) + WC('c', S(1))*cos(x_*WC('e', S(1)) + WC('d', S(0)))**S(2))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons34, cons35, cons45, cons85) def replacement3215(B, b, d, c, a, n, A, x, e): rubi.append(3215) return Dist(S(4)**(-n)*c**(-n), Int((A + B*cos(d + e*x))*(b + S(2)*c*cos(d + e*x))**(S(2)*n), x), x) rule3215 = ReplacementRule(pattern3215, replacement3215) pattern3216 = Pattern(Integral((A_ + WC('B', S(1))*sin(x_*WC('e', S(1)) + WC('d', S(0))))*(a_ + WC('b', S(1))*sin(x_*WC('e', S(1)) + WC('d', S(0))) + WC('c', S(1))*sin(x_*WC('e', S(1)) + WC('d', S(0)))**S(2))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons34, cons35, cons45, cons23) def replacement3216(B, b, d, c, a, n, A, x, e): rubi.append(3216) return Dist((b + S(2)*c*sin(d + e*x))**(-S(2)*n)*(a + b*sin(d + e*x) + c*sin(d + e*x)**S(2))**n, Int((A + B*sin(d + e*x))*(b + S(2)*c*sin(d + e*x))**(S(2)*n), x), x) rule3216 = ReplacementRule(pattern3216, replacement3216) pattern3217 = Pattern(Integral((A_ + WC('B', S(1))*cos(x_*WC('e', S(1)) + WC('d', S(0))))*(a_ + WC('b', S(1))*cos(x_*WC('e', S(1)) + WC('d', S(0))) + WC('c', S(1))*cos(x_*WC('e', S(1)) + WC('d', S(0)))**S(2))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons34, cons35, cons45, cons23) def replacement3217(B, b, d, c, a, n, A, x, e): rubi.append(3217) return Dist((b + S(2)*c*cos(d + e*x))**(-S(2)*n)*(a + b*cos(d + e*x) + c*cos(d + e*x)**S(2))**n, Int((A + B*cos(d + e*x))*(b + S(2)*c*cos(d + e*x))**(S(2)*n), x), x) rule3217 = ReplacementRule(pattern3217, replacement3217) def With3218(B, b, d, a, c, A, x, e): q = Rt(-S(4)*a*c + b**S(2), S(2)) rubi.append(3218) return Dist(B - (-S(2)*A*c + B*b)/q, Int(S(1)/(b + S(2)*c*sin(d + e*x) - q), x), x) + Dist(B + (-S(2)*A*c + B*b)/q, Int(S(1)/(b + S(2)*c*sin(d + e*x) + q), x), x) pattern3218 = Pattern(Integral((A_ + WC('B', S(1))*sin(x_*WC('e', S(1)) + WC('d', S(0))))/(WC('a', S(0)) + WC('b', S(1))*sin(x_*WC('e', S(1)) + WC('d', S(0))) + WC('c', S(1))*sin(x_*WC('e', S(1)) + WC('d', S(0)))**S(2)), x_), cons2, cons3, cons7, cons27, cons48, cons34, cons35, cons226) rule3218 = ReplacementRule(pattern3218, With3218) def With3219(B, b, d, c, a, A, x, e): q = Rt(-S(4)*a*c + b**S(2), S(2)) rubi.append(3219) return Dist(B - (-S(2)*A*c + B*b)/q, Int(S(1)/(b + S(2)*c*cos(d + e*x) - q), x), x) + Dist(B + (-S(2)*A*c + B*b)/q, Int(S(1)/(b + S(2)*c*cos(d + e*x) + q), x), x) pattern3219 = Pattern(Integral((A_ + WC('B', S(1))*cos(x_*WC('e', S(1)) + WC('d', S(0))))/(WC('a', S(0)) + WC('b', S(1))*cos(x_*WC('e', S(1)) + WC('d', S(0))) + WC('c', S(1))*cos(x_*WC('e', S(1)) + WC('d', S(0)))**S(2)), x_), cons2, cons3, cons7, cons27, cons48, cons34, cons35, cons226) rule3219 = ReplacementRule(pattern3219, With3219) pattern3220 = Pattern(Integral((A_ + WC('B', S(1))*sin(x_*WC('e', S(1)) + WC('d', S(0))))*(WC('a', S(0)) + WC('b', S(1))*sin(x_*WC('e', S(1)) + WC('d', S(0))) + WC('c', S(1))*sin(x_*WC('e', S(1)) + WC('d', S(0)))**S(2))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons34, cons35, cons226, cons85) def replacement3220(B, b, d, a, c, n, A, x, e): rubi.append(3220) return Int(ExpandTrig((A + B*sin(d + e*x))*(a + b*sin(d + e*x) + c*sin(d + e*x)**S(2))**n, x), x) rule3220 = ReplacementRule(pattern3220, replacement3220) pattern3221 = Pattern(Integral((A_ + WC('B', S(1))*cos(x_*WC('e', S(1)) + WC('d', S(0))))*(WC('a', S(0)) + WC('b', S(1))*cos(x_*WC('e', S(1)) + WC('d', S(0))) + WC('c', S(1))*cos(x_*WC('e', S(1)) + WC('d', S(0)))**S(2))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons34, cons35, cons226, cons85) def replacement3221(B, b, d, c, a, n, A, x, e): rubi.append(3221) return Int(ExpandTrig((A + B*cos(d + e*x))*(a + b*cos(d + e*x) + c*cos(d + e*x)**S(2))**n, x), x) rule3221 = ReplacementRule(pattern3221, replacement3221) pattern3222 = Pattern(Integral((x_*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))), x_), cons7, cons27, cons48, cons125, cons31, cons168) def replacement3222(m, f, d, c, x, e): rubi.append(3222) return Dist(d*m/f, Int((c + d*x)**(m + S(-1))*cos(e + f*x), x), x) - Simp((c + d*x)**m*cos(e + f*x)/f, x) rule3222 = ReplacementRule(pattern3222, replacement3222) pattern3223 = Pattern(Integral((x_*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))), x_), cons7, cons27, cons48, cons125, cons31, cons168) def replacement3223(m, f, d, c, x, e): rubi.append(3223) return -Dist(d*m/f, Int((c + d*x)**(m + S(-1))*sin(e + f*x), x), x) + Simp((c + d*x)**m*sin(e + f*x)/f, x) rule3223 = ReplacementRule(pattern3223, replacement3223) pattern3224 = Pattern(Integral((x_*WC('d', S(1)) + WC('c', S(0)))**m_*sin(x_*WC('f', S(1)) + WC('e', S(0))), x_), cons7, cons27, cons48, cons125, cons31, cons94) def replacement3224(m, f, d, c, x, e): rubi.append(3224) return -Dist(f/(d*(m + S(1))), Int((c + d*x)**(m + S(1))*cos(e + f*x), x), x) + Simp((c + d*x)**(m + S(1))*sin(e + f*x)/(d*(m + S(1))), x) rule3224 = ReplacementRule(pattern3224, replacement3224) pattern3225 = Pattern(Integral((x_*WC('d', S(1)) + WC('c', S(0)))**m_*cos(x_*WC('f', S(1)) + WC('e', S(0))), x_), cons7, cons27, cons48, cons125, cons31, cons94) def replacement3225(m, f, d, c, x, e): rubi.append(3225) return Dist(f/(d*(m + S(1))), Int((c + d*x)**(m + S(1))*sin(e + f*x), x), x) + Simp((c + d*x)**(m + S(1))*cos(e + f*x)/(d*(m + S(1))), x) rule3225 = ReplacementRule(pattern3225, replacement3225) pattern3226 = Pattern(Integral(sin(x_*WC('f', S(1)) + WC('e', S(0)))/(x_*WC('d', S(1)) + WC('c', S(0))), x_), cons7, cons27, cons48, cons125, cons1116) def replacement3226(f, d, c, x, e): rubi.append(3226) return Simp(SinIntegral(e + f*x)/d, x) rule3226 = ReplacementRule(pattern3226, replacement3226) pattern3227 = Pattern(Integral(cos(x_*WC('f', S(1)) + WC('e', S(0)))/(x_*WC('d', S(1)) + WC('c', S(0))), x_), cons7, cons27, cons48, cons125, cons1116) def replacement3227(f, d, c, x, e): rubi.append(3227) return Simp(CosIntegral(e + f*x)/d, x) rule3227 = ReplacementRule(pattern3227, replacement3227) pattern3228 = Pattern(Integral(sin(x_*WC('f', S(1)) + WC('e', S(0)))/(x_*WC('d', S(1)) + WC('c', S(0))), x_), cons7, cons27, cons48, cons125, cons176) def replacement3228(f, d, c, x, e): rubi.append(3228) return Dist(sin((-c*f + d*e)/d), Int(cos(c*f/d + f*x)/(c + d*x), x), x) + Dist(cos((-c*f + d*e)/d), Int(sin(c*f/d + f*x)/(c + d*x), x), x) rule3228 = ReplacementRule(pattern3228, replacement3228) pattern3229 = Pattern(Integral(cos(x_*WC('f', S(1)) + WC('e', S(0)))/(x_*WC('d', S(1)) + WC('c', S(0))), x_), cons7, cons27, cons48, cons125, cons176) def replacement3229(f, d, c, x, e): rubi.append(3229) return -Dist(sin((-c*f + d*e)/d), Int(sin(c*f/d + f*x)/(c + d*x), x), x) + Dist(cos((-c*f + d*e)/d), Int(cos(c*f/d + f*x)/(c + d*x), x), x) rule3229 = ReplacementRule(pattern3229, replacement3229) pattern3230 = Pattern(Integral(sin(x_*WC('f', S(1)) + WC('e', S(0)))/sqrt(x_*WC('d', S(1)) + WC('c', S(0))), x_), cons7, cons27, cons48, cons125, cons1116) def replacement3230(f, d, c, x, e): rubi.append(3230) return Dist(S(2)/d, Subst(Int(sin(f*x**S(2)/d), x), x, sqrt(c + d*x)), x) rule3230 = ReplacementRule(pattern3230, replacement3230) pattern3231 = Pattern(Integral(cos(x_*WC('f', S(1)) + WC('e', S(0)))/sqrt(x_*WC('d', S(1)) + WC('c', S(0))), x_), cons7, cons27, cons48, cons125, cons1116) def replacement3231(f, d, c, x, e): rubi.append(3231) return Dist(S(2)/d, Subst(Int(cos(f*x**S(2)/d), x), x, sqrt(c + d*x)), x) rule3231 = ReplacementRule(pattern3231, replacement3231) pattern3232 = Pattern(Integral(sin(x_*WC('f', S(1)) + WC('e', S(0)))/sqrt(x_*WC('d', S(1)) + WC('c', S(0))), x_), cons7, cons27, cons48, cons125, cons176) def replacement3232(f, d, c, x, e): rubi.append(3232) return Dist(sin((-c*f + d*e)/d), Int(cos(c*f/d + f*x)/sqrt(c + d*x), x), x) + Dist(cos((-c*f + d*e)/d), Int(sin(c*f/d + f*x)/sqrt(c + d*x), x), x) rule3232 = ReplacementRule(pattern3232, replacement3232) pattern3233 = Pattern(Integral(cos(x_*WC('f', S(1)) + WC('e', S(0)))/sqrt(x_*WC('d', S(1)) + WC('c', S(0))), x_), cons7, cons27, cons48, cons125, cons176) def replacement3233(f, d, c, x, e): rubi.append(3233) return -Dist(sin((-c*f + d*e)/d), Int(sin(c*f/d + f*x)/sqrt(c + d*x), x), x) + Dist(cos((-c*f + d*e)/d), Int(cos(c*f/d + f*x)/sqrt(c + d*x), x), x) rule3233 = ReplacementRule(pattern3233, replacement3233) pattern3234 = Pattern(Integral((x_*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))), x_), cons7, cons27, cons48, cons125, cons21, cons1488) def replacement3234(m, f, d, c, x, e): rubi.append(3234) return Dist(I/S(2), Int((c + d*x)**m*exp(-I*(e + f*x)), x), x) - Dist(I/S(2), Int((c + d*x)**m*exp(I*(e + f*x)), x), x) rule3234 = ReplacementRule(pattern3234, replacement3234) pattern3235 = Pattern(Integral((x_*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))), x_), cons7, cons27, cons48, cons125, cons21, cons1488) def replacement3235(m, f, d, c, x, e): rubi.append(3235) return Dist(S(1)/2, Int((c + d*x)**m*exp(-I*(e + f*x)), x), x) + Dist(S(1)/2, Int((c + d*x)**m*exp(I*(e + f*x)), x), x) rule3235 = ReplacementRule(pattern3235, replacement3235) pattern3236 = Pattern(Integral((WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(x_*WC('d', S(1)) + WC('c', S(0))), x_), cons3, cons7, cons27, cons48, cons125, cons87, cons165) def replacement3236(f, b, d, c, n, x, e): rubi.append(3236) return Dist(b**S(2)*(n + S(-1))/n, Int((b*sin(e + f*x))**(n + S(-2))*(c + d*x), x), x) + Simp(d*(b*sin(e + f*x))**n/(f**S(2)*n**S(2)), x) - Simp(b*(b*sin(e + f*x))**(n + S(-1))*(c + d*x)*cos(e + f*x)/(f*n), x) rule3236 = ReplacementRule(pattern3236, replacement3236) pattern3237 = Pattern(Integral((WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(x_*WC('d', S(1)) + WC('c', S(0))), x_), cons3, cons7, cons27, cons48, cons125, cons87, cons165) def replacement3237(f, b, d, c, n, x, e): rubi.append(3237) return Dist(b**S(2)*(n + S(-1))/n, Int((b*cos(e + f*x))**(n + S(-2))*(c + d*x), x), x) + Simp(d*(b*cos(e + f*x))**n/(f**S(2)*n**S(2)), x) + Simp(b*(b*cos(e + f*x))**(n + S(-1))*(c + d*x)*sin(e + f*x)/(f*n), x) rule3237 = ReplacementRule(pattern3237, replacement3237) pattern3238 = Pattern(Integral((WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(x_*WC('d', S(1)) + WC('c', S(0)))**m_, x_), cons3, cons7, cons27, cons48, cons125, cons93, cons165, cons166) def replacement3238(m, f, b, d, c, n, x, e): rubi.append(3238) return Dist(b**S(2)*(n + S(-1))/n, Int((b*sin(e + f*x))**(n + S(-2))*(c + d*x)**m, x), x) - Dist(d**S(2)*m*(m + S(-1))/(f**S(2)*n**S(2)), Int((b*sin(e + f*x))**n*(c + d*x)**(m + S(-2)), x), x) - Simp(b*(b*sin(e + f*x))**(n + S(-1))*(c + d*x)**m*cos(e + f*x)/(f*n), x) + Simp(d*m*(b*sin(e + f*x))**n*(c + d*x)**(m + S(-1))/(f**S(2)*n**S(2)), x) rule3238 = ReplacementRule(pattern3238, replacement3238) pattern3239 = Pattern(Integral((WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(x_*WC('d', S(1)) + WC('c', S(0)))**m_, x_), cons3, cons7, cons27, cons48, cons125, cons93, cons165, cons166) def replacement3239(m, f, b, d, c, n, x, e): rubi.append(3239) return Dist(b**S(2)*(n + S(-1))/n, Int((b*cos(e + f*x))**(n + S(-2))*(c + d*x)**m, x), x) - Dist(d**S(2)*m*(m + S(-1))/(f**S(2)*n**S(2)), Int((b*cos(e + f*x))**n*(c + d*x)**(m + S(-2)), x), x) + Simp(b*(b*cos(e + f*x))**(n + S(-1))*(c + d*x)**m*sin(e + f*x)/(f*n), x) + Simp(d*m*(b*cos(e + f*x))**n*(c + d*x)**(m + S(-1))/(f**S(2)*n**S(2)), x) rule3239 = ReplacementRule(pattern3239, replacement3239) pattern3240 = Pattern(Integral((x_*WC('d', S(1)) + WC('c', S(0)))**m_*sin(x_*WC('f', S(1)) + WC('e', S(0)))**n_, x_), cons7, cons27, cons48, cons125, cons21, cons85, cons165, cons1489) def replacement3240(m, f, d, c, n, x, e): rubi.append(3240) return Int(ExpandTrigReduce((c + d*x)**m, sin(e + f*x)**n, x), x) rule3240 = ReplacementRule(pattern3240, replacement3240) pattern3241 = Pattern(Integral((x_*WC('d', S(1)) + WC('c', S(0)))**m_*cos(x_*WC('f', S(1)) + WC('e', S(0)))**n_, x_), cons7, cons27, cons48, cons125, cons21, cons85, cons165, cons1489) def replacement3241(m, f, d, c, n, x, e): rubi.append(3241) return Int(ExpandTrigReduce((c + d*x)**m, cos(e + f*x)**n, x), x) rule3241 = ReplacementRule(pattern3241, replacement3241) pattern3242 = Pattern(Integral((x_*WC('d', S(1)) + WC('c', S(0)))**m_*sin(x_*WC('f', S(1)) + WC('e', S(0)))**n_, x_), cons7, cons27, cons48, cons125, cons21, cons85, cons165, cons31, cons245) def replacement3242(m, f, d, c, n, x, e): rubi.append(3242) return -Dist(f*n/(d*(m + S(1))), Int(ExpandTrigReduce((c + d*x)**(m + S(1)), sin(e + f*x)**(n + S(-1))*cos(e + f*x), x), x), x) + Simp((c + d*x)**(m + S(1))*sin(e + f*x)**n/(d*(m + S(1))), x) rule3242 = ReplacementRule(pattern3242, replacement3242) pattern3243 = Pattern(Integral((x_*WC('d', S(1)) + WC('c', S(0)))**m_*cos(x_*WC('f', S(1)) + WC('e', S(0)))**n_, x_), cons7, cons27, cons48, cons125, cons21, cons85, cons165, cons31, cons245) def replacement3243(m, f, d, c, n, x, e): rubi.append(3243) return Dist(f*n/(d*(m + S(1))), Int(ExpandTrigReduce((c + d*x)**(m + S(1)), sin(e + f*x)*cos(e + f*x)**(n + S(-1)), x), x), x) + Simp((c + d*x)**(m + S(1))*cos(e + f*x)**n/(d*(m + S(1))), x) rule3243 = ReplacementRule(pattern3243, replacement3243) pattern3244 = Pattern(Integral((WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(x_*WC('d', S(1)) + WC('c', S(0)))**m_, x_), cons3, cons7, cons27, cons48, cons125, cons93, cons165, cons247) def replacement3244(m, f, b, d, c, n, x, e): rubi.append(3244) return -Dist(f**S(2)*n**S(2)/(d**S(2)*(m + S(1))*(m + S(2))), Int((b*sin(e + f*x))**n*(c + d*x)**(m + S(2)), x), x) + Dist(b**S(2)*f**S(2)*n*(n + S(-1))/(d**S(2)*(m + S(1))*(m + S(2))), Int((b*sin(e + f*x))**(n + S(-2))*(c + d*x)**(m + S(2)), x), x) + Simp((b*sin(e + f*x))**n*(c + d*x)**(m + S(1))/(d*(m + S(1))), x) - Simp(b*f*n*(b*sin(e + f*x))**(n + S(-1))*(c + d*x)**(m + S(2))*cos(e + f*x)/(d**S(2)*(m + S(1))*(m + S(2))), x) rule3244 = ReplacementRule(pattern3244, replacement3244) pattern3245 = Pattern(Integral((WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(x_*WC('d', S(1)) + WC('c', S(0)))**m_, x_), cons3, cons7, cons27, cons48, cons125, cons93, cons165, cons247) def replacement3245(m, f, b, d, c, n, x, e): rubi.append(3245) return -Dist(f**S(2)*n**S(2)/(d**S(2)*(m + S(1))*(m + S(2))), Int((b*cos(e + f*x))**n*(c + d*x)**(m + S(2)), x), x) + Dist(b**S(2)*f**S(2)*n*(n + S(-1))/(d**S(2)*(m + S(1))*(m + S(2))), Int((b*cos(e + f*x))**(n + S(-2))*(c + d*x)**(m + S(2)), x), x) + Simp((b*cos(e + f*x))**n*(c + d*x)**(m + S(1))/(d*(m + S(1))), x) + Simp(b*f*n*(b*cos(e + f*x))**(n + S(-1))*(c + d*x)**(m + S(2))*sin(e + f*x)/(d**S(2)*(m + S(1))*(m + S(2))), x) rule3245 = ReplacementRule(pattern3245, replacement3245) pattern3246 = Pattern(Integral((WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(x_*WC('d', S(1)) + WC('c', S(0))), x_), cons3, cons7, cons27, cons48, cons125, cons87, cons89, cons1442) def replacement3246(f, b, d, c, n, x, e): rubi.append(3246) return Dist((n + S(2))/(b**S(2)*(n + S(1))), Int((b*sin(e + f*x))**(n + S(2))*(c + d*x), x), x) - Simp(d*(b*sin(e + f*x))**(n + S(2))/(b**S(2)*f**S(2)*(n + S(1))*(n + S(2))), x) + Simp((b*sin(e + f*x))**(n + S(1))*(c + d*x)*cos(e + f*x)/(b*f*(n + S(1))), x) rule3246 = ReplacementRule(pattern3246, replacement3246) pattern3247 = Pattern(Integral((WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(x_*WC('d', S(1)) + WC('c', S(0))), x_), cons3, cons7, cons27, cons48, cons125, cons87, cons89, cons1442) def replacement3247(f, b, d, c, n, x, e): rubi.append(3247) return Dist((n + S(2))/(b**S(2)*(n + S(1))), Int((b*cos(e + f*x))**(n + S(2))*(c + d*x), x), x) - Simp(d*(b*cos(e + f*x))**(n + S(2))/(b**S(2)*f**S(2)*(n + S(1))*(n + S(2))), x) - Simp((b*cos(e + f*x))**(n + S(1))*(c + d*x)*sin(e + f*x)/(b*f*(n + S(1))), x) rule3247 = ReplacementRule(pattern3247, replacement3247) pattern3248 = Pattern(Integral((WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(x_*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1)), x_), cons3, cons7, cons27, cons48, cons125, cons93, cons89, cons1442, cons166) def replacement3248(m, f, b, d, c, n, x, e): rubi.append(3248) return Dist((n + S(2))/(b**S(2)*(n + S(1))), Int((b*sin(e + f*x))**(n + S(2))*(c + d*x)**m, x), x) + Dist(d**S(2)*m*(m + S(-1))/(b**S(2)*f**S(2)*(n + S(1))*(n + S(2))), Int((b*sin(e + f*x))**(n + S(2))*(c + d*x)**(m + S(-2)), x), x) + Simp((b*sin(e + f*x))**(n + S(1))*(c + d*x)**m*cos(e + f*x)/(b*f*(n + S(1))), x) - Simp(d*m*(b*sin(e + f*x))**(n + S(2))*(c + d*x)**(m + S(-1))/(b**S(2)*f**S(2)*(n + S(1))*(n + S(2))), x) rule3248 = ReplacementRule(pattern3248, replacement3248) pattern3249 = Pattern(Integral((WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(x_*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1)), x_), cons3, cons7, cons27, cons48, cons125, cons93, cons89, cons1442, cons166) def replacement3249(m, f, b, d, c, n, x, e): rubi.append(3249) return Dist((n + S(2))/(b**S(2)*(n + S(1))), Int((b*cos(e + f*x))**(n + S(2))*(c + d*x)**m, x), x) + Dist(d**S(2)*m*(m + S(-1))/(b**S(2)*f**S(2)*(n + S(1))*(n + S(2))), Int((b*cos(e + f*x))**(n + S(2))*(c + d*x)**(m + S(-2)), x), x) - Simp((b*cos(e + f*x))**(n + S(1))*(c + d*x)**m*sin(e + f*x)/(b*f*(n + S(1))), x) - Simp(d*m*(b*cos(e + f*x))**(n + S(2))*(c + d*x)**(m + S(-1))/(b**S(2)*f**S(2)*(n + S(1))*(n + S(2))), x) rule3249 = ReplacementRule(pattern3249, replacement3249) pattern3250 = Pattern(Integral((a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1))*(x_*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons148, cons1490) def replacement3250(m, f, b, d, c, n, a, x, e): rubi.append(3250) return Int(ExpandIntegrand((c + d*x)**m, (a + b*sin(e + f*x))**n, x), x) rule3250 = ReplacementRule(pattern3250, replacement3250) pattern3251 = Pattern(Integral((a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1))*(x_*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons148, cons1490) def replacement3251(m, f, b, d, c, n, a, x, e): rubi.append(3251) return Int(ExpandIntegrand((c + d*x)**m, (a + b*cos(e + f*x))**n, x), x) rule3251 = ReplacementRule(pattern3251, replacement3251) pattern3252 = Pattern(Integral((a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1))*(x_*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons1265, cons85) def replacement3252(m, f, b, d, c, n, a, x, e): rubi.append(3252) return Dist((S(2)*a)**n, Int((c + d*x)**m*cos(-Pi*a/(S(4)*b) + e/S(2) + f*x/S(2))**(S(2)*n), x), x) rule3252 = ReplacementRule(pattern3252, replacement3252) pattern3253 = Pattern(Integral((a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(x_*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons1265, cons808, cons1491) def replacement3253(m, f, b, d, c, a, n, x, e): rubi.append(3253) return Dist((S(2)*a)**IntPart(n)*(a + b*sin(e + f*x))**FracPart(n)*cos(-Pi*a/(S(4)*b) + e/S(2) + f*x/S(2))**(-S(2)*FracPart(n)), Int((c + d*x)**m*cos(-Pi*a/(S(4)*b) + e/S(2) + f*x/S(2))**(S(2)*n), x), x) rule3253 = ReplacementRule(pattern3253, replacement3253) pattern3254 = Pattern(Integral((a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1))*(x_*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons1492, cons85) def replacement3254(m, f, b, d, c, n, a, x, e): rubi.append(3254) return Dist((S(2)*a)**n, Int((c + d*x)**m*cos(e/S(2) + f*x/S(2))**(S(2)*n), x), x) rule3254 = ReplacementRule(pattern3254, replacement3254) pattern3255 = Pattern(Integral((a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1))*(x_*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons1454, cons85) def replacement3255(m, f, b, d, c, n, a, x, e): rubi.append(3255) return Dist((S(2)*a)**n, Int((c + d*x)**m*sin(e/S(2) + f*x/S(2))**(S(2)*n), x), x) rule3255 = ReplacementRule(pattern3255, replacement3255) pattern3256 = Pattern(Integral((a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(x_*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons1492, cons808, cons1491) def replacement3256(m, f, b, d, c, a, n, x, e): rubi.append(3256) return Dist((S(2)*a)**IntPart(n)*(a + b*cos(e + f*x))**FracPart(n)*cos(e/S(2) + f*x/S(2))**(-S(2)*FracPart(n)), Int((c + d*x)**m*cos(e/S(2) + f*x/S(2))**(S(2)*n), x), x) rule3256 = ReplacementRule(pattern3256, replacement3256) pattern3257 = Pattern(Integral((a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(x_*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons1454, cons808, cons1491) def replacement3257(m, f, b, d, c, a, n, x, e): rubi.append(3257) return Dist((S(2)*a)**IntPart(n)*(a + b*cos(e + f*x))**FracPart(n)*sin(e/S(2) + f*x/S(2))**(-S(2)*FracPart(n)), Int((c + d*x)**m*sin(e/S(2) + f*x/S(2))**(S(2)*n), x), x) rule3257 = ReplacementRule(pattern3257, replacement3257) pattern3258 = Pattern(Integral((x_*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1))/(a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons1267, cons62) def replacement3258(m, f, b, d, c, a, x, e): rubi.append(3258) return Dist(S(2), Int((c + d*x)**m*exp(I*(e + f*x))/(S(2)*a*exp(I*(e + f*x)) - I*b*exp(S(2)*I*(e + f*x)) + I*b), x), x) rule3258 = ReplacementRule(pattern3258, replacement3258) pattern3259 = Pattern(Integral((x_*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1))/(a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons1267, cons62) def replacement3259(m, f, b, d, c, a, x, e): rubi.append(3259) return Dist(S(2), Int((c + d*x)**m*exp(I*(e + f*x))/(S(2)*a*exp(I*(e + f*x)) + b*exp(S(2)*I*(e + f*x)) + b), x), x) rule3259 = ReplacementRule(pattern3259, replacement3259) pattern3260 = Pattern(Integral((x_*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1))/(a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**S(2), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons1267, cons62) def replacement3260(m, f, b, d, c, a, x, e): rubi.append(3260) return Dist(a/(a**S(2) - b**S(2)), Int((c + d*x)**m/(a + b*sin(e + f*x)), x), x) - Dist(b*d*m/(f*(a**S(2) - b**S(2))), Int((c + d*x)**(m + S(-1))*cos(e + f*x)/(a + b*sin(e + f*x)), x), x) + Simp(b*(c + d*x)**m*cos(e + f*x)/(f*(a + b*sin(e + f*x))*(a**S(2) - b**S(2))), x) rule3260 = ReplacementRule(pattern3260, replacement3260) pattern3261 = Pattern(Integral((x_*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1))/(a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**S(2), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons1267, cons62) def replacement3261(m, f, b, d, c, a, x, e): rubi.append(3261) return Dist(a/(a**S(2) - b**S(2)), Int((c + d*x)**m/(a + b*cos(e + f*x)), x), x) + Dist(b*d*m/(f*(a**S(2) - b**S(2))), Int((c + d*x)**(m + S(-1))*sin(e + f*x)/(a + b*cos(e + f*x)), x), x) - Simp(b*(c + d*x)**m*sin(e + f*x)/(f*(a + b*cos(e + f*x))*(a**S(2) - b**S(2))), x) rule3261 = ReplacementRule(pattern3261, replacement3261) pattern3262 = Pattern(Integral((a_ + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(x_*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons1267, cons1493, cons62) def replacement3262(m, f, b, d, c, a, n, x, e): rubi.append(3262) return Dist(a/(a**S(2) - b**S(2)), Int((a + b*sin(e + f*x))**(n + S(1))*(c + d*x)**m, x), x) - Dist(b*(n + S(2))/((a**S(2) - b**S(2))*(n + S(1))), Int((a + b*sin(e + f*x))**(n + S(1))*(c + d*x)**m*sin(e + f*x), x), x) + Dist(b*d*m/(f*(a**S(2) - b**S(2))*(n + S(1))), Int((a + b*sin(e + f*x))**(n + S(1))*(c + d*x)**(m + S(-1))*cos(e + f*x), x), x) - Simp(b*(a + b*sin(e + f*x))**(n + S(1))*(c + d*x)**m*cos(e + f*x)/(f*(a**S(2) - b**S(2))*(n + S(1))), x) rule3262 = ReplacementRule(pattern3262, replacement3262) pattern3263 = Pattern(Integral((a_ + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(x_*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons1267, cons1493, cons62) def replacement3263(m, f, b, d, c, a, n, x, e): rubi.append(3263) return Dist(a/(a**S(2) - b**S(2)), Int((a + b*cos(e + f*x))**(n + S(1))*(c + d*x)**m, x), x) - Dist(b*(n + S(2))/((a**S(2) - b**S(2))*(n + S(1))), Int((a + b*cos(e + f*x))**(n + S(1))*(c + d*x)**m*cos(e + f*x), x), x) - Dist(b*d*m/(f*(a**S(2) - b**S(2))*(n + S(1))), Int((a + b*cos(e + f*x))**(n + S(1))*(c + d*x)**(m + S(-1))*sin(e + f*x), x), x) + Simp(b*(a + b*cos(e + f*x))**(n + S(1))*(c + d*x)**m*sin(e + f*x)/(f*(a**S(2) - b**S(2))*(n + S(1))), x) rule3263 = ReplacementRule(pattern3263, replacement3263) pattern3264 = Pattern(Integral(u_**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*sin(v_))**WC('n', S(1)), x_), cons2, cons3, cons21, cons4, cons810, cons811) def replacement3264(v, u, m, b, a, n, x): rubi.append(3264) return Int((a + b*sin(ExpandToSum(v, x)))**n*ExpandToSum(u, x)**m, x) rule3264 = ReplacementRule(pattern3264, replacement3264) pattern3265 = Pattern(Integral(u_**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*cos(v_))**WC('n', S(1)), x_), cons2, cons3, cons21, cons4, cons810, cons811) def replacement3265(v, u, m, b, a, n, x): rubi.append(3265) return Int((a + b*cos(ExpandToSum(v, x)))**n*ExpandToSum(u, x)**m, x) rule3265 = ReplacementRule(pattern3265, replacement3265) pattern3266 = Pattern(Integral((x_*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons4, cons1360) def replacement3266(m, f, b, d, c, a, n, x, e): rubi.append(3266) return Int((a + b*sin(e + f*x))**n*(c + d*x)**m, x) rule3266 = ReplacementRule(pattern3266, replacement3266) pattern3267 = Pattern(Integral((x_*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons4, cons1360) def replacement3267(m, f, b, d, a, n, c, x, e): rubi.append(3267) return Int((a + b*cos(e + f*x))**n*(c + d*x)**m, x) rule3267 = ReplacementRule(pattern3267, replacement3267) pattern3268 = Pattern(Integral((a_ + x_**n_*WC('b', S(1)))**WC('p', S(1))*sin(x_*WC('d', S(1)) + WC('c', S(0))), x_), cons2, cons3, cons7, cons27, cons4, cons128) def replacement3268(p, b, d, c, a, n, x): rubi.append(3268) return Int(ExpandIntegrand(sin(c + d*x), (a + b*x**n)**p, x), x) rule3268 = ReplacementRule(pattern3268, replacement3268) pattern3269 = Pattern(Integral((a_ + x_**n_*WC('b', S(1)))**WC('p', S(1))*cos(x_*WC('d', S(1)) + WC('c', S(0))), x_), cons2, cons3, cons7, cons27, cons4, cons128) def replacement3269(p, b, d, c, a, n, x): rubi.append(3269) return Int(ExpandIntegrand(cos(c + d*x), (a + b*x**n)**p, x), x) rule3269 = ReplacementRule(pattern3269, replacement3269) pattern3270 = Pattern(Integral((a_ + x_**n_*WC('b', S(1)))**p_*sin(x_*WC('d', S(1)) + WC('c', S(0))), x_), cons2, cons3, cons7, cons27, cons38, cons148, cons137, cons744) def replacement3270(p, b, d, c, a, n, x): rubi.append(3270) return -Dist(d/(b*n*(p + S(1))), Int(x**(-n + S(1))*(a + b*x**n)**(p + S(1))*cos(c + d*x), x), x) - Dist((-n + S(1))/(b*n*(p + S(1))), Int(x**(-n)*(a + b*x**n)**(p + S(1))*sin(c + d*x), x), x) + Simp(x**(-n + S(1))*(a + b*x**n)**(p + S(1))*sin(c + d*x)/(b*n*(p + S(1))), x) rule3270 = ReplacementRule(pattern3270, replacement3270) pattern3271 = Pattern(Integral((a_ + x_**n_*WC('b', S(1)))**p_*cos(x_*WC('d', S(1)) + WC('c', S(0))), x_), cons2, cons3, cons7, cons27, cons38, cons148, cons137, cons744) def replacement3271(p, b, d, c, a, n, x): rubi.append(3271) return Dist(d/(b*n*(p + S(1))), Int(x**(-n + S(1))*(a + b*x**n)**(p + S(1))*sin(c + d*x), x), x) - Dist((-n + S(1))/(b*n*(p + S(1))), Int(x**(-n)*(a + b*x**n)**(p + S(1))*cos(c + d*x), x), x) + Simp(x**(-n + S(1))*(a + b*x**n)**(p + S(1))*cos(c + d*x)/(b*n*(p + S(1))), x) rule3271 = ReplacementRule(pattern3271, replacement3271) pattern3272 = Pattern(Integral((a_ + x_**n_*WC('b', S(1)))**p_*sin(x_*WC('d', S(1)) + WC('c', S(0))), x_), cons2, cons3, cons7, cons27, cons63, cons148, cons1494) def replacement3272(p, b, d, c, a, n, x): rubi.append(3272) return Int(ExpandIntegrand(sin(c + d*x), (a + b*x**n)**p, x), x) rule3272 = ReplacementRule(pattern3272, replacement3272) pattern3273 = Pattern(Integral((a_ + x_**n_*WC('b', S(1)))**p_*cos(x_*WC('d', S(1)) + WC('c', S(0))), x_), cons2, cons3, cons7, cons27, cons63, cons148, cons1494) def replacement3273(p, b, d, c, a, n, x): rubi.append(3273) return Int(ExpandIntegrand(cos(c + d*x), (a + b*x**n)**p, x), x) rule3273 = ReplacementRule(pattern3273, replacement3273) pattern3274 = Pattern(Integral((a_ + x_**n_*WC('b', S(1)))**p_*sin(x_*WC('d', S(1)) + WC('c', S(0))), x_), cons2, cons3, cons7, cons27, cons63, cons196) def replacement3274(p, b, d, c, a, n, x): rubi.append(3274) return Int(x**(n*p)*(a*x**(-n) + b)**p*sin(c + d*x), x) rule3274 = ReplacementRule(pattern3274, replacement3274) pattern3275 = Pattern(Integral((a_ + x_**n_*WC('b', S(1)))**p_*cos(x_*WC('d', S(1)) + WC('c', S(0))), x_), cons2, cons3, cons7, cons27, cons63, cons196) def replacement3275(p, b, d, c, a, n, x): rubi.append(3275) return Int(x**(n*p)*(a*x**(-n) + b)**p*cos(c + d*x), x) rule3275 = ReplacementRule(pattern3275, replacement3275) pattern3276 = Pattern(Integral((a_ + x_**n_*WC('b', S(1)))**p_*sin(x_*WC('d', S(1)) + WC('c', S(0))), x_), cons2, cons3, cons7, cons27, cons4, cons5, cons1495) def replacement3276(p, b, d, c, a, n, x): rubi.append(3276) return Int((a + b*x**n)**p*sin(c + d*x), x) rule3276 = ReplacementRule(pattern3276, replacement3276) pattern3277 = Pattern(Integral((a_ + x_**n_*WC('b', S(1)))**p_*cos(x_*WC('d', S(1)) + WC('c', S(0))), x_), cons2, cons3, cons7, cons27, cons4, cons5, cons1495) def replacement3277(p, b, d, c, a, n, x): rubi.append(3277) return Int((a + b*x**n)**p*cos(c + d*x), x) rule3277 = ReplacementRule(pattern3277, replacement3277) pattern3278 = Pattern(Integral((x_*WC('e', S(1)))**WC('m', S(1))*(a_ + x_**n_*WC('b', S(1)))**WC('p', S(1))*sin(x_*WC('d', S(1)) + WC('c', S(0))), x_), cons2, cons3, cons7, cons27, cons48, cons21, cons4, cons128) def replacement3278(p, m, b, d, c, a, n, x, e): rubi.append(3278) return Int(ExpandIntegrand(sin(c + d*x), (e*x)**m*(a + b*x**n)**p, x), x) rule3278 = ReplacementRule(pattern3278, replacement3278) pattern3279 = Pattern(Integral((x_*WC('e', S(1)))**WC('m', S(1))*(a_ + x_**n_*WC('b', S(1)))**WC('p', S(1))*cos(x_*WC('d', S(1)) + WC('c', S(0))), x_), cons2, cons3, cons7, cons27, cons48, cons21, cons4, cons128) def replacement3279(p, m, b, d, c, a, n, x, e): rubi.append(3279) return Int(ExpandIntegrand(cos(c + d*x), (e*x)**m*(a + b*x**n)**p, x), x) rule3279 = ReplacementRule(pattern3279, replacement3279) pattern3280 = Pattern(Integral((x_*WC('e', S(1)))**WC('m', S(1))*(a_ + x_**n_*WC('b', S(1)))**p_*sin(x_*WC('d', S(1)) + WC('c', S(0))), x_), cons2, cons3, cons7, cons27, cons48, cons21, cons4, cons38, cons53, cons13, cons137, cons596) def replacement3280(p, m, b, d, c, a, n, x, e): rubi.append(3280) return -Dist(d*e**m/(b*n*(p + S(1))), Int((a + b*x**n)**(p + S(1))*cos(c + d*x), x), x) + Simp(e**m*(a + b*x**n)**(p + S(1))*sin(c + d*x)/(b*n*(p + S(1))), x) rule3280 = ReplacementRule(pattern3280, replacement3280) pattern3281 = Pattern(Integral((x_*WC('e', S(1)))**WC('m', S(1))*(a_ + x_**n_*WC('b', S(1)))**p_*cos(x_*WC('d', S(1)) + WC('c', S(0))), x_), cons2, cons3, cons7, cons27, cons48, cons21, cons4, cons38, cons53, cons13, cons137, cons596) def replacement3281(p, m, b, d, c, a, n, x, e): rubi.append(3281) return Dist(d*e**m/(b*n*(p + S(1))), Int((a + b*x**n)**(p + S(1))*sin(c + d*x), x), x) + Simp(e**m*(a + b*x**n)**(p + S(1))*cos(c + d*x)/(b*n*(p + S(1))), x) rule3281 = ReplacementRule(pattern3281, replacement3281) pattern3282 = Pattern(Integral(x_**WC('m', S(1))*(a_ + x_**n_*WC('b', S(1)))**p_*sin(x_*WC('d', S(1)) + WC('c', S(0))), x_), cons2, cons3, cons7, cons27, cons38, cons148, cons31, cons137, cons1496) def replacement3282(p, m, b, d, c, a, n, x): rubi.append(3282) return -Dist(d/(b*n*(p + S(1))), Int(x**(m - n + S(1))*(a + b*x**n)**(p + S(1))*cos(c + d*x), x), x) - Dist((m - n + S(1))/(b*n*(p + S(1))), Int(x**(m - n)*(a + b*x**n)**(p + S(1))*sin(c + d*x), x), x) + Simp(x**(m - n + S(1))*(a + b*x**n)**(p + S(1))*sin(c + d*x)/(b*n*(p + S(1))), x) rule3282 = ReplacementRule(pattern3282, replacement3282) pattern3283 = Pattern(Integral(x_**WC('m', S(1))*(a_ + x_**n_*WC('b', S(1)))**p_*cos(x_*WC('d', S(1)) + WC('c', S(0))), x_), cons2, cons3, cons7, cons27, cons38, cons148, cons31, cons137, cons1496) def replacement3283(p, m, b, d, c, a, n, x): rubi.append(3283) return Dist(d/(b*n*(p + S(1))), Int(x**(m - n + S(1))*(a + b*x**n)**(p + S(1))*sin(c + d*x), x), x) - Dist((m - n + S(1))/(b*n*(p + S(1))), Int(x**(m - n)*(a + b*x**n)**(p + S(1))*cos(c + d*x), x), x) + Simp(x**(m - n + S(1))*(a + b*x**n)**(p + S(1))*cos(c + d*x)/(b*n*(p + S(1))), x) rule3283 = ReplacementRule(pattern3283, replacement3283) pattern3284 = Pattern(Integral(x_**WC('m', S(1))*(a_ + x_**n_*WC('b', S(1)))**p_*sin(x_*WC('d', S(1)) + WC('c', S(0))), x_), cons2, cons3, cons7, cons27, cons63, cons17, cons148, cons1494) def replacement3284(p, m, b, d, c, a, n, x): rubi.append(3284) return Int(ExpandIntegrand(sin(c + d*x), x**m*(a + b*x**n)**p, x), x) rule3284 = ReplacementRule(pattern3284, replacement3284) pattern3285 = Pattern(Integral(x_**WC('m', S(1))*(a_ + x_**n_*WC('b', S(1)))**p_*cos(x_*WC('d', S(1)) + WC('c', S(0))), x_), cons2, cons3, cons7, cons27, cons63, cons17, cons148, cons1494) def replacement3285(p, m, b, d, c, a, n, x): rubi.append(3285) return Int(ExpandIntegrand(cos(c + d*x), x**m*(a + b*x**n)**p, x), x) rule3285 = ReplacementRule(pattern3285, replacement3285) pattern3286 = Pattern(Integral(x_**WC('m', S(1))*(a_ + x_**n_*WC('b', S(1)))**p_*sin(x_*WC('d', S(1)) + WC('c', S(0))), x_), cons2, cons3, cons7, cons27, cons21, cons63, cons196) def replacement3286(p, m, b, d, c, a, n, x): rubi.append(3286) return Int(x**(m + n*p)*(a*x**(-n) + b)**p*sin(c + d*x), x) rule3286 = ReplacementRule(pattern3286, replacement3286) pattern3287 = Pattern(Integral(x_**WC('m', S(1))*(a_ + x_**n_*WC('b', S(1)))**p_*cos(x_*WC('d', S(1)) + WC('c', S(0))), x_), cons2, cons3, cons7, cons27, cons21, cons63, cons196) def replacement3287(p, m, b, d, c, a, n, x): rubi.append(3287) return Int(x**(m + n*p)*(a*x**(-n) + b)**p*cos(c + d*x), x) rule3287 = ReplacementRule(pattern3287, replacement3287) pattern3288 = Pattern(Integral((x_*WC('e', S(1)))**WC('m', S(1))*(a_ + x_**n_*WC('b', S(1)))**WC('p', S(1))*sin(x_*WC('d', S(1)) + WC('c', S(0))), x_), cons2, cons3, cons7, cons27, cons48, cons21, cons4, cons5, cons1497) def replacement3288(p, m, b, d, c, a, n, x, e): rubi.append(3288) return Int((e*x)**m*(a + b*x**n)**p*sin(c + d*x), x) rule3288 = ReplacementRule(pattern3288, replacement3288) pattern3289 = Pattern(Integral((x_*WC('e', S(1)))**WC('m', S(1))*(a_ + x_**n_*WC('b', S(1)))**WC('p', S(1))*cos(x_*WC('d', S(1)) + WC('c', S(0))), x_), cons2, cons3, cons7, cons27, cons48, cons21, cons4, cons5, cons1497) def replacement3289(p, m, b, d, c, a, n, x, e): rubi.append(3289) return Int((e*x)**m*(a + b*x**n)**p*cos(c + d*x), x) rule3289 = ReplacementRule(pattern3289, replacement3289) pattern3290 = Pattern(Integral(sin(x_**S(2)*WC('d', S(1))), x_), cons27, cons27) def replacement3290(d, x): rubi.append(3290) return Simp(sqrt(S(2))*sqrt(Pi)*FresnelS(sqrt(S(2))*x*sqrt(S(1)/Pi)*Rt(d, S(2)))/(S(2)*Rt(d, S(2))), x) rule3290 = ReplacementRule(pattern3290, replacement3290) pattern3291 = Pattern(Integral(cos(x_**S(2)*WC('d', S(1))), x_), cons27, cons27) def replacement3291(d, x): rubi.append(3291) return Simp(sqrt(S(2))*sqrt(Pi)*FresnelC(sqrt(S(2))*x*sqrt(S(1)/Pi)*Rt(d, S(2)))/(S(2)*Rt(d, S(2))), x) rule3291 = ReplacementRule(pattern3291, replacement3291) pattern3292 = Pattern(Integral(sin(c_ + x_**S(2)*WC('d', S(1))), x_), cons7, cons27, cons1261) def replacement3292(d, c, x): rubi.append(3292) return Dist(sin(c), Int(cos(d*x**S(2)), x), x) + Dist(cos(c), Int(sin(d*x**S(2)), x), x) rule3292 = ReplacementRule(pattern3292, replacement3292) pattern3293 = Pattern(Integral(cos(c_ + x_**S(2)*WC('d', S(1))), x_), cons7, cons27, cons1261) def replacement3293(d, c, x): rubi.append(3293) return -Dist(sin(c), Int(sin(d*x**S(2)), x), x) + Dist(cos(c), Int(cos(d*x**S(2)), x), x) rule3293 = ReplacementRule(pattern3293, replacement3293) pattern3294 = Pattern(Integral(sin(x_**n_*WC('d', S(1)) + WC('c', S(0))), x_), cons7, cons27, cons85, cons744) def replacement3294(d, c, n, x): rubi.append(3294) return Dist(I/S(2), Int(exp(-I*c - I*d*x**n), x), x) - Dist(I/S(2), Int(exp(I*c + I*d*x**n), x), x) rule3294 = ReplacementRule(pattern3294, replacement3294) pattern3295 = Pattern(Integral(cos(x_**n_*WC('d', S(1)) + WC('c', S(0))), x_), cons7, cons27, cons85, cons744) def replacement3295(d, c, n, x): rubi.append(3295) return Dist(S(1)/2, Int(exp(-I*c - I*d*x**n), x), x) + Dist(S(1)/2, Int(exp(I*c + I*d*x**n), x), x) rule3295 = ReplacementRule(pattern3295, replacement3295) pattern3296 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*sin(x_**n_*WC('d', S(1)) + WC('c', S(0))))**p_, x_), cons2, cons3, cons7, cons27, cons376, cons165, cons146) def replacement3296(p, b, d, c, a, n, x): rubi.append(3296) return Int(ExpandTrigReduce((a + b*sin(c + d*x**n))**p, x), x) rule3296 = ReplacementRule(pattern3296, replacement3296) pattern3297 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*cos(x_**n_*WC('d', S(1)) + WC('c', S(0))))**p_, x_), cons2, cons3, cons7, cons27, cons376, cons165, cons146) def replacement3297(p, b, d, a, c, n, x): rubi.append(3297) return Int(ExpandTrigReduce((a + b*cos(c + d*x**n))**p, x), x) rule3297 = ReplacementRule(pattern3297, replacement3297) pattern3298 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*sin(x_**n_*WC('d', S(1)) + WC('c', S(0))))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons38, cons196) def replacement3298(p, b, d, c, a, n, x): rubi.append(3298) return -Subst(Int((a + b*sin(c + d*x**(-n)))**p/x**S(2), x), x, S(1)/x) rule3298 = ReplacementRule(pattern3298, replacement3298) pattern3299 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*cos(x_**n_*WC('d', S(1)) + WC('c', S(0))))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons38, cons196) def replacement3299(p, b, d, a, c, n, x): rubi.append(3299) return -Subst(Int((a + b*cos(c + d*x**(-n)))**p/x**S(2), x), x, S(1)/x) rule3299 = ReplacementRule(pattern3299, replacement3299) def With3300(p, b, d, c, a, n, x): k = Denominator(n) rubi.append(3300) return Dist(k, Subst(Int(x**(k + S(-1))*(a + b*sin(c + d*x**(k*n)))**p, x), x, x**(S(1)/k)), x) pattern3300 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*sin(x_**n_*WC('d', S(1)) + WC('c', S(0))))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons38, cons489) rule3300 = ReplacementRule(pattern3300, With3300) def With3301(p, b, d, a, c, n, x): k = Denominator(n) rubi.append(3301) return Dist(k, Subst(Int(x**(k + S(-1))*(a + b*cos(c + d*x**(k*n)))**p, x), x, x**(S(1)/k)), x) pattern3301 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*cos(x_**n_*WC('d', S(1)) + WC('c', S(0))))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons38, cons489) rule3301 = ReplacementRule(pattern3301, With3301) pattern3302 = Pattern(Integral(sin(x_**n_*WC('d', S(1)) + WC('c', S(0))), x_), cons7, cons27, cons4, cons1498) def replacement3302(d, c, n, x): rubi.append(3302) return Dist(I/S(2), Int(exp(-I*c - I*d*x**n), x), x) - Dist(I/S(2), Int(exp(I*c + I*d*x**n), x), x) rule3302 = ReplacementRule(pattern3302, replacement3302) pattern3303 = Pattern(Integral(cos(x_**n_*WC('d', S(1)) + WC('c', S(0))), x_), cons7, cons27, cons4, cons1498) def replacement3303(d, c, n, x): rubi.append(3303) return Dist(S(1)/2, Int(exp(-I*c - I*d*x**n), x), x) + Dist(S(1)/2, Int(exp(I*c + I*d*x**n), x), x) rule3303 = ReplacementRule(pattern3303, replacement3303) pattern3304 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*sin(x_**n_*WC('d', S(1)) + WC('c', S(0))))**p_, x_), cons2, cons3, cons7, cons27, cons4, cons128) def replacement3304(p, b, d, c, a, n, x): rubi.append(3304) return Int(ExpandTrigReduce((a + b*sin(c + d*x**n))**p, x), x) rule3304 = ReplacementRule(pattern3304, replacement3304) pattern3305 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*cos(x_**n_*WC('d', S(1)) + WC('c', S(0))))**p_, x_), cons2, cons3, cons7, cons27, cons4, cons128) def replacement3305(p, b, d, a, c, n, x): rubi.append(3305) return Int(ExpandTrigReduce((a + b*cos(c + d*x**n))**p, x), x) rule3305 = ReplacementRule(pattern3305, replacement3305) pattern3306 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*sin(u_**n_*WC('d', S(1)) + WC('c', S(0))))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons4, cons38, cons68, cons69) def replacement3306(p, u, b, d, c, a, n, x): rubi.append(3306) return Dist(S(1)/Coefficient(u, x, S(1)), Subst(Int((a + b*sin(c + d*x**n))**p, x), x, u), x) rule3306 = ReplacementRule(pattern3306, replacement3306) pattern3307 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*cos(u_**n_*WC('d', S(1)) + WC('c', S(0))))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons4, cons38, cons68, cons69) def replacement3307(p, u, b, d, a, c, n, x): rubi.append(3307) return Dist(S(1)/Coefficient(u, x, S(1)), Subst(Int((a + b*cos(c + d*x**n))**p, x), x, u), x) rule3307 = ReplacementRule(pattern3307, replacement3307) pattern3308 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*sin(u_**n_*WC('d', S(1)) + WC('c', S(0))))**p_, x_), cons2, cons3, cons7, cons27, cons4, cons5, cons68) def replacement3308(p, u, b, d, c, a, n, x): rubi.append(3308) return Int((a + b*sin(c + d*u**n))**p, x) rule3308 = ReplacementRule(pattern3308, replacement3308) pattern3309 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*cos(u_**n_*WC('d', S(1)) + WC('c', S(0))))**p_, x_), cons2, cons3, cons7, cons27, cons4, cons5, cons68) def replacement3309(p, u, b, d, a, c, n, x): rubi.append(3309) return Int((a + b*cos(c + d*u**n))**p, x) rule3309 = ReplacementRule(pattern3309, replacement3309) pattern3310 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*sin(u_))**WC('p', S(1)), x_), cons2, cons3, cons5, cons823, cons824) def replacement3310(p, u, b, a, x): rubi.append(3310) return Int((a + b*sin(ExpandToSum(u, x)))**p, x) rule3310 = ReplacementRule(pattern3310, replacement3310) pattern3311 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*cos(u_))**WC('p', S(1)), x_), cons2, cons3, cons5, cons823, cons824) def replacement3311(p, u, b, a, x): rubi.append(3311) return Int((a + b*cos(ExpandToSum(u, x)))**p, x) rule3311 = ReplacementRule(pattern3311, replacement3311) pattern3312 = Pattern(Integral(sin(x_**n_*WC('d', S(1)))/x_, x_), cons27, cons4, cons1499) def replacement3312(d, x, n): rubi.append(3312) return Simp(SinIntegral(d*x**n)/n, x) rule3312 = ReplacementRule(pattern3312, replacement3312) pattern3313 = Pattern(Integral(cos(x_**n_*WC('d', S(1)))/x_, x_), cons27, cons4, cons1499) def replacement3313(d, x, n): rubi.append(3313) return Simp(CosIntegral(d*x**n)/n, x) rule3313 = ReplacementRule(pattern3313, replacement3313) pattern3314 = Pattern(Integral(sin(c_ + x_**n_*WC('d', S(1)))/x_, x_), cons7, cons27, cons4, cons1498) def replacement3314(d, x, n, c): rubi.append(3314) return Dist(sin(c), Int(cos(d*x**n)/x, x), x) + Dist(cos(c), Int(sin(d*x**n)/x, x), x) rule3314 = ReplacementRule(pattern3314, replacement3314) pattern3315 = Pattern(Integral(cos(c_ + x_**n_*WC('d', S(1)))/x_, x_), cons7, cons27, cons4, cons1498) def replacement3315(d, c, n, x): rubi.append(3315) return -Dist(sin(c), Int(sin(d*x**n)/x, x), x) + Dist(cos(c), Int(cos(d*x**n)/x, x), x) rule3315 = ReplacementRule(pattern3315, replacement3315) def With3316(p, m, b, d, c, a, n, x): if isinstance(x, (int, Integer, float, Float)): return False mn = (m + S(1))/n if And(IntegerQ(mn), Or(Equal(p, S(1)), Greater(mn, S(0)))): return True return False pattern3316 = Pattern(Integral(x_**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*sin(x_**n_*WC('d', S(1)) + WC('c', S(0))))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons21, cons4, cons38, CustomConstraint(With3316)) def replacement3316(p, m, b, d, c, a, n, x): mn = (m + S(1))/n rubi.append(3316) return Dist(S(1)/n, Subst(Int(x**(mn + S(-1))*(a + b*sin(c + d*x))**p, x), x, x**n), x) rule3316 = ReplacementRule(pattern3316, replacement3316) def With3317(p, m, b, d, a, c, n, x): if isinstance(x, (int, Integer, float, Float)): return False mn = (m + S(1))/n if And(IntegerQ(mn), Or(Equal(p, S(1)), Greater(mn, S(0)))): return True return False pattern3317 = Pattern(Integral(x_**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*cos(x_**n_*WC('d', S(1)) + WC('c', S(0))))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons21, cons4, cons38, CustomConstraint(With3317)) def replacement3317(p, m, b, d, a, c, n, x): mn = (m + S(1))/n rubi.append(3317) return Dist(S(1)/n, Subst(Int(x**(mn + S(-1))*(a + b*cos(c + d*x))**p, x), x, x**n), x) rule3317 = ReplacementRule(pattern3317, replacement3317) def With3318(p, m, b, d, c, a, n, x, e): if isinstance(x, (int, Integer, float, Float)): return False mn = (m + S(1))/n if And(IntegerQ(mn), Or(Equal(p, S(1)), Greater(mn, S(0)))): return True return False pattern3318 = Pattern(Integral((e_*x_)**m_*(WC('a', S(0)) + WC('b', S(1))*sin(x_**n_*WC('d', S(1)) + WC('c', S(0))))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons21, cons4, cons38, CustomConstraint(With3318)) def replacement3318(p, m, b, d, c, a, n, x, e): mn = (m + S(1))/n rubi.append(3318) return Dist(e**IntPart(m)*x**(-FracPart(m))*(e*x)**FracPart(m), Int(x**m*(a + b*sin(c + d*x**n))**p, x), x) rule3318 = ReplacementRule(pattern3318, replacement3318) def With3319(p, m, b, d, a, c, n, x, e): if isinstance(x, (int, Integer, float, Float)): return False mn = (m + S(1))/n if And(IntegerQ(mn), Or(Equal(p, S(1)), Greater(mn, S(0)))): return True return False pattern3319 = Pattern(Integral((e_*x_)**m_*(WC('a', S(0)) + WC('b', S(1))*cos(x_**n_*WC('d', S(1)) + WC('c', S(0))))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons21, cons4, cons38, CustomConstraint(With3319)) def replacement3319(p, m, b, d, a, c, n, x, e): mn = (m + S(1))/n rubi.append(3319) return Dist(e**IntPart(m)*x**(-FracPart(m))*(e*x)**FracPart(m), Int(x**m*(a + b*cos(c + d*x**n))**p, x), x) rule3319 = ReplacementRule(pattern3319, replacement3319) pattern3320 = Pattern(Integral(x_**WC('m', S(1))*sin(x_**n_*WC('b', S(1)) + WC('a', S(0))), x_), cons2, cons3, cons21, cons4, cons1500) def replacement3320(m, b, a, n, x): rubi.append(3320) return Dist(S(2)/n, Subst(Int(sin(a + b*x**S(2)), x), x, x**(n/S(2))), x) rule3320 = ReplacementRule(pattern3320, replacement3320) pattern3321 = Pattern(Integral(x_**WC('m', S(1))*cos(x_**n_*WC('b', S(1)) + WC('a', S(0))), x_), cons2, cons3, cons21, cons4, cons1500) def replacement3321(m, b, a, n, x): rubi.append(3321) return Dist(S(2)/n, Subst(Int(cos(a + b*x**S(2)), x), x, x**(n/S(2))), x) rule3321 = ReplacementRule(pattern3321, replacement3321) pattern3322 = Pattern(Integral((x_*WC('e', S(1)))**WC('m', S(1))*sin(x_**n_*WC('d', S(1)) + WC('c', S(0))), x_), cons7, cons27, cons48, cons148, cons31, cons1501) def replacement3322(m, d, c, n, x, e): rubi.append(3322) return Dist(e**n*(m - n + S(1))/(d*n), Int((e*x)**(m - n)*cos(c + d*x**n), x), x) - Simp(e**(n + S(-1))*(e*x)**(m - n + S(1))*cos(c + d*x**n)/(d*n), x) rule3322 = ReplacementRule(pattern3322, replacement3322) pattern3323 = Pattern(Integral((x_*WC('e', S(1)))**WC('m', S(1))*cos(x_**n_*WC('d', S(1)) + WC('c', S(0))), x_), cons7, cons27, cons48, cons148, cons31, cons1501) def replacement3323(m, d, c, n, x, e): rubi.append(3323) return -Dist(e**n*(m - n + S(1))/(d*n), Int((e*x)**(m - n)*sin(c + d*x**n), x), x) + Simp(e**(n + S(-1))*(e*x)**(m - n + S(1))*sin(c + d*x**n)/(d*n), x) rule3323 = ReplacementRule(pattern3323, replacement3323) pattern3324 = Pattern(Integral((x_*WC('e', S(1)))**m_*sin(x_**n_*WC('d', S(1)) + WC('c', S(0))), x_), cons7, cons27, cons48, cons148, cons31, cons94) def replacement3324(m, d, c, n, x, e): rubi.append(3324) return -Dist(d*e**(-n)*n/(m + S(1)), Int((e*x)**(m + n)*cos(c + d*x**n), x), x) + Simp((e*x)**(m + S(1))*sin(c + d*x**n)/(e*(m + S(1))), x) rule3324 = ReplacementRule(pattern3324, replacement3324) pattern3325 = Pattern(Integral((x_*WC('e', S(1)))**m_*cos(x_**n_*WC('d', S(1)) + WC('c', S(0))), x_), cons7, cons27, cons48, cons148, cons31, cons94) def replacement3325(m, d, c, n, x, e): rubi.append(3325) return Dist(d*e**(-n)*n/(m + S(1)), Int((e*x)**(m + n)*sin(c + d*x**n), x), x) + Simp((e*x)**(m + S(1))*cos(c + d*x**n)/(e*(m + S(1))), x) rule3325 = ReplacementRule(pattern3325, replacement3325) pattern3326 = Pattern(Integral((x_*WC('e', S(1)))**WC('m', S(1))*sin(x_**n_*WC('d', S(1)) + WC('c', S(0))), x_), cons7, cons27, cons48, cons21, cons148) def replacement3326(m, d, c, n, x, e): rubi.append(3326) return Dist(I/S(2), Int((e*x)**m*exp(-I*c - I*d*x**n), x), x) - Dist(I/S(2), Int((e*x)**m*exp(I*c + I*d*x**n), x), x) rule3326 = ReplacementRule(pattern3326, replacement3326) pattern3327 = Pattern(Integral((x_*WC('e', S(1)))**WC('m', S(1))*cos(x_**n_*WC('d', S(1)) + WC('c', S(0))), x_), cons7, cons27, cons48, cons21, cons148) def replacement3327(m, d, c, n, x, e): rubi.append(3327) return Dist(S(1)/2, Int((e*x)**m*exp(-I*c - I*d*x**n), x), x) + Dist(S(1)/2, Int((e*x)**m*exp(I*c + I*d*x**n), x), x) rule3327 = ReplacementRule(pattern3327, replacement3327) pattern3328 = Pattern(Integral(x_**WC('m', S(1))*sin(x_**n_*WC('b', S(1)) + WC('a', S(0)))**p_, x_), cons2, cons3, cons376, cons1255, cons146, cons1502) def replacement3328(p, m, b, a, n, x): rubi.append(3328) return Dist(b*n*p/(n + S(-1)), Int(sin(a + b*x**n)**(p + S(-1))*cos(a + b*x**n), x), x) - Simp(x**(-n + S(1))*sin(a + b*x**n)**p/(n + S(-1)), x) rule3328 = ReplacementRule(pattern3328, replacement3328) pattern3329 = Pattern(Integral(x_**WC('m', S(1))*cos(x_**n_*WC('b', S(1)) + WC('a', S(0)))**p_, x_), cons2, cons3, cons376, cons1255, cons146, cons1502) def replacement3329(p, m, b, a, n, x): rubi.append(3329) return -Dist(b*n*p/(n + S(-1)), Int(sin(a + b*x**n)*cos(a + b*x**n)**(p + S(-1)), x), x) - Simp(x**(-n + S(1))*cos(a + b*x**n)**p/(n + S(-1)), x) rule3329 = ReplacementRule(pattern3329, replacement3329) pattern3330 = Pattern(Integral(x_**WC('m', S(1))*sin(x_**n_*WC('b', S(1)) + WC('a', S(0)))**p_, x_), cons2, cons3, cons21, cons4, cons56, cons13, cons146) def replacement3330(p, m, b, a, n, x): rubi.append(3330) return Dist((p + S(-1))/p, Int(x**m*sin(a + b*x**n)**(p + S(-2)), x), x) + Simp(sin(a + b*x**n)**p/(b**S(2)*n*p**S(2)), x) - Simp(x**n*sin(a + b*x**n)**(p + S(-1))*cos(a + b*x**n)/(b*n*p), x) rule3330 = ReplacementRule(pattern3330, replacement3330) pattern3331 = Pattern(Integral(x_**WC('m', S(1))*cos(x_**n_*WC('b', S(1)) + WC('a', S(0)))**p_, x_), cons2, cons3, cons21, cons4, cons56, cons13, cons146) def replacement3331(p, m, b, a, n, x): rubi.append(3331) return Dist((p + S(-1))/p, Int(x**m*cos(a + b*x**n)**(p + S(-2)), x), x) + Simp(cos(a + b*x**n)**p/(b**S(2)*n*p**S(2)), x) + Simp(x**n*sin(a + b*x**n)*cos(a + b*x**n)**(p + S(-1))/(b*n*p), x) rule3331 = ReplacementRule(pattern3331, replacement3331) pattern3332 = Pattern(Integral(x_**WC('m', S(1))*sin(x_**n_*WC('b', S(1)) + WC('a', S(0)))**p_, x_), cons2, cons3, cons150, cons13, cons146, cons1503) def replacement3332(p, m, b, a, n, x): rubi.append(3332) return Dist((p + S(-1))/p, Int(x**m*sin(a + b*x**n)**(p + S(-2)), x), x) - Dist((m - S(2)*n + S(1))*(m - n + S(1))/(b**S(2)*n**S(2)*p**S(2)), Int(x**(m - S(2)*n)*sin(a + b*x**n)**p, x), x) + Simp(x**(m - S(2)*n + S(1))*(m - n + S(1))*sin(a + b*x**n)**p/(b**S(2)*n**S(2)*p**S(2)), x) - Simp(x**(m - n + S(1))*sin(a + b*x**n)**(p + S(-1))*cos(a + b*x**n)/(b*n*p), x) rule3332 = ReplacementRule(pattern3332, replacement3332) pattern3333 = Pattern(Integral(x_**WC('m', S(1))*cos(x_**n_*WC('b', S(1)) + WC('a', S(0)))**p_, x_), cons2, cons3, cons150, cons13, cons146, cons1503) def replacement3333(p, m, b, a, n, x): rubi.append(3333) return Dist((p + S(-1))/p, Int(x**m*cos(a + b*x**n)**(p + S(-2)), x), x) - Dist((m - S(2)*n + S(1))*(m - n + S(1))/(b**S(2)*n**S(2)*p**S(2)), Int(x**(m - S(2)*n)*cos(a + b*x**n)**p, x), x) + Simp(x**(m - S(2)*n + S(1))*(m - n + S(1))*cos(a + b*x**n)**p/(b**S(2)*n**S(2)*p**S(2)), x) + Simp(x**(m - n + S(1))*sin(a + b*x**n)*cos(a + b*x**n)**(p + S(-1))/(b*n*p), x) rule3333 = ReplacementRule(pattern3333, replacement3333) pattern3334 = Pattern(Integral(x_**WC('m', S(1))*sin(x_**n_*WC('b', S(1)) + WC('a', S(0)))**p_, x_), cons2, cons3, cons150, cons13, cons146, cons1504, cons683) def replacement3334(p, m, b, a, n, x): rubi.append(3334) return -Dist(b**S(2)*n**S(2)*p**S(2)/((m + S(1))*(m + n + S(1))), Int(x**(m + S(2)*n)*sin(a + b*x**n)**p, x), x) + Dist(b**S(2)*n**S(2)*p*(p + S(-1))/((m + S(1))*(m + n + S(1))), Int(x**(m + S(2)*n)*sin(a + b*x**n)**(p + S(-2)), x), x) + Simp(x**(m + S(1))*sin(a + b*x**n)**p/(m + S(1)), x) - Simp(b*n*p*x**(m + n + S(1))*sin(a + b*x**n)**(p + S(-1))*cos(a + b*x**n)/((m + S(1))*(m + n + S(1))), x) rule3334 = ReplacementRule(pattern3334, replacement3334) pattern3335 = Pattern(Integral(x_**WC('m', S(1))*cos(x_**n_*WC('b', S(1)) + WC('a', S(0)))**p_, x_), cons2, cons3, cons150, cons13, cons146, cons1504, cons683) def replacement3335(p, m, b, a, n, x): rubi.append(3335) return -Dist(b**S(2)*n**S(2)*p**S(2)/((m + S(1))*(m + n + S(1))), Int(x**(m + S(2)*n)*cos(a + b*x**n)**p, x), x) + Dist(b**S(2)*n**S(2)*p*(p + S(-1))/((m + S(1))*(m + n + S(1))), Int(x**(m + S(2)*n)*cos(a + b*x**n)**(p + S(-2)), x), x) + Simp(x**(m + S(1))*cos(a + b*x**n)**p/(m + S(1)), x) + Simp(b*n*p*x**(m + n + S(1))*sin(a + b*x**n)*cos(a + b*x**n)**(p + S(-1))/((m + S(1))*(m + n + S(1))), x) rule3335 = ReplacementRule(pattern3335, replacement3335) def With3336(p, m, b, d, c, a, n, x, e): k = Denominator(m) rubi.append(3336) return Dist(k/e, Subst(Int(x**(k*(m + S(1)) + S(-1))*(a + b*sin(c + d*e**(-n)*x**(k*n)))**p, x), x, (e*x)**(S(1)/k)), x) pattern3336 = Pattern(Integral((x_*WC('e', S(1)))**m_*(WC('a', S(0)) + WC('b', S(1))*sin(x_**n_*WC('d', S(1)) + WC('c', S(0))))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons38, cons148, cons367) rule3336 = ReplacementRule(pattern3336, With3336) def With3337(p, m, b, d, a, c, n, x, e): k = Denominator(m) rubi.append(3337) return Dist(k/e, Subst(Int(x**(k*(m + S(1)) + S(-1))*(a + b*cos(c + d*e**(-n)*x**(k*n)))**p, x), x, (e*x)**(S(1)/k)), x) pattern3337 = Pattern(Integral((x_*WC('e', S(1)))**m_*(WC('a', S(0)) + WC('b', S(1))*cos(x_**n_*WC('d', S(1)) + WC('c', S(0))))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons38, cons148, cons367) rule3337 = ReplacementRule(pattern3337, With3337) pattern3338 = Pattern(Integral((x_*WC('e', S(1)))**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*sin(x_**n_*WC('d', S(1)) + WC('c', S(0))))**p_, x_), cons2, cons3, cons7, cons27, cons48, cons21, cons38, cons148, cons146) def replacement3338(p, m, b, d, c, a, n, x, e): rubi.append(3338) return Int(ExpandTrigReduce((e*x)**m, (a + b*sin(c + d*x**n))**p, x), x) rule3338 = ReplacementRule(pattern3338, replacement3338) pattern3339 = Pattern(Integral((x_*WC('e', S(1)))**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*cos(x_**n_*WC('d', S(1)) + WC('c', S(0))))**p_, x_), cons2, cons3, cons7, cons27, cons48, cons21, cons38, cons148, cons146) def replacement3339(p, m, b, d, a, c, n, x, e): rubi.append(3339) return Int(ExpandTrigReduce((e*x)**m, (a + b*cos(c + d*x**n))**p, x), x) rule3339 = ReplacementRule(pattern3339, replacement3339) pattern3340 = Pattern(Integral(x_**WC('m', S(1))*sin(x_**n_*WC('b', S(1)) + WC('a', S(0)))**p_, x_), cons2, cons3, cons21, cons4, cons56, cons13, cons137, cons1505) def replacement3340(p, m, b, a, n, x): rubi.append(3340) return Dist((p + S(2))/(p + S(1)), Int(x**m*sin(a + b*x**n)**(p + S(2)), x), x) - Simp(sin(a + b*x**n)**(p + S(2))/(b**S(2)*n*(p + S(1))*(p + S(2))), x) + Simp(x**n*sin(a + b*x**n)**(p + S(1))*cos(a + b*x**n)/(b*n*(p + S(1))), x) rule3340 = ReplacementRule(pattern3340, replacement3340) pattern3341 = Pattern(Integral(x_**WC('m', S(1))*cos(x_**n_*WC('b', S(1)) + WC('a', S(0)))**p_, x_), cons2, cons3, cons21, cons4, cons56, cons13, cons137, cons1505) def replacement3341(p, m, b, a, n, x): rubi.append(3341) return Dist((p + S(2))/(p + S(1)), Int(x**m*cos(a + b*x**n)**(p + S(2)), x), x) - Simp(cos(a + b*x**n)**(p + S(2))/(b**S(2)*n*(p + S(1))*(p + S(2))), x) - Simp(x**n*sin(a + b*x**n)*cos(a + b*x**n)**(p + S(1))/(b*n*(p + S(1))), x) rule3341 = ReplacementRule(pattern3341, replacement3341) pattern3342 = Pattern(Integral(x_**WC('m', S(1))*sin(x_**n_*WC('b', S(1)) + WC('a', S(0)))**p_, x_), cons2, cons3, cons150, cons13, cons137, cons1505, cons1503) def replacement3342(p, m, b, a, n, x): rubi.append(3342) return Dist((p + S(2))/(p + S(1)), Int(x**m*sin(a + b*x**n)**(p + S(2)), x), x) + Dist((m - S(2)*n + S(1))*(m - n + S(1))/(b**S(2)*n**S(2)*(p + S(1))*(p + S(2))), Int(x**(m - S(2)*n)*sin(a + b*x**n)**(p + S(2)), x), x) + Simp(x**(m - n + S(1))*sin(a + b*x**n)**(p + S(1))*cos(a + b*x**n)/(b*n*(p + S(1))), x) - Simp(x**(m - S(2)*n + S(1))*(m - n + S(1))*sin(a + b*x**n)**(p + S(2))/(b**S(2)*n**S(2)*(p + S(1))*(p + S(2))), x) rule3342 = ReplacementRule(pattern3342, replacement3342) pattern3343 = Pattern(Integral(x_**WC('m', S(1))*cos(x_**n_*WC('b', S(1)) + WC('a', S(0)))**p_, x_), cons2, cons3, cons150, cons13, cons137, cons1505, cons1503) def replacement3343(p, m, b, a, n, x): rubi.append(3343) return Dist((p + S(2))/(p + S(1)), Int(x**m*cos(a + b*x**n)**(p + S(2)), x), x) + Dist((m - S(2)*n + S(1))*(m - n + S(1))/(b**S(2)*n**S(2)*(p + S(1))*(p + S(2))), Int(x**(m - S(2)*n)*cos(a + b*x**n)**(p + S(2)), x), x) - Simp(x**(m - n + S(1))*sin(a + b*x**n)*cos(a + b*x**n)**(p + S(1))/(b*n*(p + S(1))), x) - Simp(x**(m - S(2)*n + S(1))*(m - n + S(1))*cos(a + b*x**n)**(p + S(2))/(b**S(2)*n**S(2)*(p + S(1))*(p + S(2))), x) rule3343 = ReplacementRule(pattern3343, replacement3343) pattern3344 = Pattern(Integral(x_**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*sin(x_**n_*WC('d', S(1)) + WC('c', S(0))))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons38, cons196, cons17) def replacement3344(p, m, b, d, c, a, n, x): rubi.append(3344) return -Subst(Int(x**(-m + S(-2))*(a + b*sin(c + d*x**(-n)))**p, x), x, S(1)/x) rule3344 = ReplacementRule(pattern3344, replacement3344) pattern3345 = Pattern(Integral(x_**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*cos(x_**n_*WC('d', S(1)) + WC('c', S(0))))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons38, cons196, cons17) def replacement3345(p, m, b, d, a, c, n, x): rubi.append(3345) return -Subst(Int(x**(-m + S(-2))*(a + b*cos(c + d*x**(-n)))**p, x), x, S(1)/x) rule3345 = ReplacementRule(pattern3345, replacement3345) def With3346(p, m, b, d, c, a, n, x, e): k = Denominator(m) rubi.append(3346) return -Dist(k/e, Subst(Int(x**(-k*(m + S(1)) + S(-1))*(a + b*sin(c + d*e**(-n)*x**(-k*n)))**p, x), x, (e*x)**(-S(1)/k)), x) pattern3346 = Pattern(Integral((x_*WC('e', S(1)))**m_*(WC('a', S(0)) + WC('b', S(1))*sin(x_**n_*WC('d', S(1)) + WC('c', S(0))))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons38, cons196, cons367) rule3346 = ReplacementRule(pattern3346, With3346) def With3347(p, m, b, d, a, c, n, x, e): k = Denominator(m) rubi.append(3347) return -Dist(k/e, Subst(Int(x**(-k*(m + S(1)) + S(-1))*(a + b*cos(c + d*e**(-n)*x**(-k*n)))**p, x), x, (e*x)**(-S(1)/k)), x) pattern3347 = Pattern(Integral((x_*WC('e', S(1)))**m_*(WC('a', S(0)) + WC('b', S(1))*cos(x_**n_*WC('d', S(1)) + WC('c', S(0))))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons38, cons196, cons367) rule3347 = ReplacementRule(pattern3347, With3347) pattern3348 = Pattern(Integral((x_*WC('e', S(1)))**m_*(WC('a', S(0)) + WC('b', S(1))*sin(x_**n_*WC('d', S(1)) + WC('c', S(0))))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons21, cons38, cons196, cons356) def replacement3348(p, m, b, d, c, a, n, x, e): rubi.append(3348) return -Dist((e*x)**m*(S(1)/x)**m, Subst(Int(x**(-m + S(-2))*(a + b*sin(c + d*x**(-n)))**p, x), x, S(1)/x), x) rule3348 = ReplacementRule(pattern3348, replacement3348) pattern3349 = Pattern(Integral((x_*WC('e', S(1)))**m_*(WC('a', S(0)) + WC('b', S(1))*cos(x_**n_*WC('d', S(1)) + WC('c', S(0))))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons21, cons38, cons196, cons356) def replacement3349(p, m, b, d, a, c, n, x, e): rubi.append(3349) return -Dist((e*x)**m*(S(1)/x)**m, Subst(Int(x**(-m + S(-2))*(a + b*cos(c + d*x**(-n)))**p, x), x, S(1)/x), x) rule3349 = ReplacementRule(pattern3349, replacement3349) def With3350(p, m, b, d, c, a, n, x): k = Denominator(n) rubi.append(3350) return Dist(k, Subst(Int(x**(k*(m + S(1)) + S(-1))*(a + b*sin(c + d*x**(k*n)))**p, x), x, x**(S(1)/k)), x) pattern3350 = Pattern(Integral(x_**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*sin(x_**n_*WC('d', S(1)) + WC('c', S(0))))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons21, cons38, cons489) rule3350 = ReplacementRule(pattern3350, With3350) def With3351(p, m, b, d, a, c, n, x): k = Denominator(n) rubi.append(3351) return Dist(k, Subst(Int(x**(k*(m + S(1)) + S(-1))*(a + b*cos(c + d*x**(k*n)))**p, x), x, x**(S(1)/k)), x) pattern3351 = Pattern(Integral(x_**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*cos(x_**n_*WC('d', S(1)) + WC('c', S(0))))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons21, cons38, cons489) rule3351 = ReplacementRule(pattern3351, With3351) pattern3352 = Pattern(Integral((e_*x_)**m_*(WC('a', S(0)) + WC('b', S(1))*sin(x_**n_*WC('d', S(1)) + WC('c', S(0))))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons21, cons38, cons489) def replacement3352(p, m, b, d, c, a, n, x, e): rubi.append(3352) return Dist(e**IntPart(m)*x**(-FracPart(m))*(e*x)**FracPart(m), Int(x**m*(a + b*sin(c + d*x**n))**p, x), x) rule3352 = ReplacementRule(pattern3352, replacement3352) pattern3353 = Pattern(Integral((e_*x_)**m_*(WC('a', S(0)) + WC('b', S(1))*cos(x_**n_*WC('d', S(1)) + WC('c', S(0))))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons21, cons38, cons489) def replacement3353(p, m, b, d, a, c, n, x, e): rubi.append(3353) return Dist(e**IntPart(m)*x**(-FracPart(m))*(e*x)**FracPart(m), Int(x**m*(a + b*cos(c + d*x**n))**p, x), x) rule3353 = ReplacementRule(pattern3353, replacement3353) pattern3354 = Pattern(Integral(x_**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*sin(x_**n_*WC('d', S(1)) + WC('c', S(0))))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons21, cons4, cons38, cons66, cons854, cons23) def replacement3354(p, m, b, d, c, a, n, x): rubi.append(3354) return Dist(S(1)/(m + S(1)), Subst(Int((a + b*sin(c + d*x**(n/(m + S(1)))))**p, x), x, x**(m + S(1))), x) rule3354 = ReplacementRule(pattern3354, replacement3354) pattern3355 = Pattern(Integral(x_**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*cos(x_**n_*WC('d', S(1)) + WC('c', S(0))))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons21, cons4, cons38, cons66, cons854, cons23) def replacement3355(p, m, b, d, a, c, n, x): rubi.append(3355) return Dist(S(1)/(m + S(1)), Subst(Int((a + b*cos(c + d*x**(n/(m + S(1)))))**p, x), x, x**(m + S(1))), x) rule3355 = ReplacementRule(pattern3355, replacement3355) pattern3356 = Pattern(Integral((e_*x_)**m_*(WC('a', S(0)) + WC('b', S(1))*sin(x_**n_*WC('d', S(1)) + WC('c', S(0))))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons21, cons4, cons38, cons66, cons854, cons23) def replacement3356(p, m, b, d, c, a, n, x, e): rubi.append(3356) return Dist(e**IntPart(m)*x**(-FracPart(m))*(e*x)**FracPart(m), Int(x**m*(a + b*sin(c + d*x**n))**p, x), x) rule3356 = ReplacementRule(pattern3356, replacement3356) pattern3357 = Pattern(Integral((e_*x_)**m_*(WC('a', S(0)) + WC('b', S(1))*cos(x_**n_*WC('d', S(1)) + WC('c', S(0))))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons21, cons4, cons38, cons66, cons854, cons23) def replacement3357(p, m, b, d, a, c, n, x, e): rubi.append(3357) return Dist(e**IntPart(m)*x**(-FracPart(m))*(e*x)**FracPart(m), Int(x**m*(a + b*cos(c + d*x**n))**p, x), x) rule3357 = ReplacementRule(pattern3357, replacement3357) pattern3358 = Pattern(Integral((x_*WC('e', S(1)))**WC('m', S(1))*sin(x_**n_*WC('d', S(1)) + WC('c', S(0))), x_), cons7, cons27, cons48, cons21, cons4, cons1506) def replacement3358(m, d, c, n, x, e): rubi.append(3358) return Dist(I/S(2), Int((e*x)**m*exp(-I*c - I*d*x**n), x), x) - Dist(I/S(2), Int((e*x)**m*exp(I*c + I*d*x**n), x), x) rule3358 = ReplacementRule(pattern3358, replacement3358) pattern3359 = Pattern(Integral((x_*WC('e', S(1)))**WC('m', S(1))*cos(x_**n_*WC('d', S(1)) + WC('c', S(0))), x_), cons7, cons27, cons48, cons21, cons4, cons1506) def replacement3359(m, d, c, n, x, e): rubi.append(3359) return Dist(S(1)/2, Int((e*x)**m*exp(-I*c - I*d*x**n), x), x) + Dist(S(1)/2, Int((e*x)**m*exp(I*c + I*d*x**n), x), x) rule3359 = ReplacementRule(pattern3359, replacement3359) pattern3360 = Pattern(Integral((x_*WC('e', S(1)))**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*sin(x_**n_*WC('d', S(1)) + WC('c', S(0))))**p_, x_), cons2, cons3, cons7, cons27, cons48, cons21, cons4, cons128) def replacement3360(p, m, b, d, c, a, n, x, e): rubi.append(3360) return Int(ExpandTrigReduce((e*x)**m, (a + b*sin(c + d*x**n))**p, x), x) rule3360 = ReplacementRule(pattern3360, replacement3360) pattern3361 = Pattern(Integral((x_*WC('e', S(1)))**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*cos(x_**n_*WC('d', S(1)) + WC('c', S(0))))**p_, x_), cons2, cons3, cons7, cons27, cons48, cons21, cons4, cons128) def replacement3361(p, m, b, d, a, c, n, x, e): rubi.append(3361) return Int(ExpandTrigReduce((e*x)**m, (a + b*cos(c + d*x**n))**p, x), x) rule3361 = ReplacementRule(pattern3361, replacement3361) pattern3362 = Pattern(Integral(x_**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*sin(u_**n_*WC('d', S(1)) + WC('c', S(0))))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons4, cons5, cons68, cons69, cons17) def replacement3362(p, u, m, b, d, c, a, n, x): rubi.append(3362) return Dist(Coefficient(u, x, S(1))**(-m + S(-1)), Subst(Int((a + b*sin(c + d*x**n))**p*(x - Coefficient(u, x, S(0)))**m, x), x, u), x) rule3362 = ReplacementRule(pattern3362, replacement3362) pattern3363 = Pattern(Integral(x_**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*cos(u_**n_*WC('d', S(1)) + WC('c', S(0))))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons4, cons5, cons68, cons69, cons17) def replacement3363(p, u, m, b, d, a, c, n, x): rubi.append(3363) return Dist(Coefficient(u, x, S(1))**(-m + S(-1)), Subst(Int((a + b*cos(c + d*x**n))**p*(x - Coefficient(u, x, S(0)))**m, x), x, u), x) rule3363 = ReplacementRule(pattern3363, replacement3363) pattern3364 = Pattern(Integral((x_*WC('e', S(1)))**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*sin(u_**n_*WC('d', S(1)) + WC('c', S(0))))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons21, cons4, cons5, cons68) def replacement3364(p, u, m, b, d, c, a, n, x, e): rubi.append(3364) return Int((e*x)**m*(a + b*sin(c + d*u**n))**p, x) rule3364 = ReplacementRule(pattern3364, replacement3364) pattern3365 = Pattern(Integral((x_*WC('e', S(1)))**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*cos(u_**n_*WC('d', S(1)) + WC('c', S(0))))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons21, cons4, cons5, cons68) def replacement3365(p, u, m, b, d, a, c, n, x, e): rubi.append(3365) return Int((e*x)**m*(a + b*cos(c + d*u**n))**p, x) rule3365 = ReplacementRule(pattern3365, replacement3365) pattern3366 = Pattern(Integral((e_*x_)**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*sin(u_))**WC('p', S(1)), x_), cons2, cons3, cons48, cons21, cons5, cons823, cons824) def replacement3366(p, u, m, b, a, x, e): rubi.append(3366) return Int((e*x)**m*(a + b*sin(ExpandToSum(u, x)))**p, x) rule3366 = ReplacementRule(pattern3366, replacement3366) pattern3367 = Pattern(Integral((e_*x_)**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*cos(u_))**WC('p', S(1)), x_), cons2, cons3, cons48, cons21, cons5, cons823, cons824) def replacement3367(p, u, m, b, a, x, e): rubi.append(3367) return Int((e*x)**m*(a + b*cos(ExpandToSum(u, x)))**p, x) rule3367 = ReplacementRule(pattern3367, replacement3367) pattern3368 = Pattern(Integral(x_**WC('m', S(1))*sin(x_**WC('n', S(1))*WC('b', S(1)) + WC('a', S(0)))**WC('p', S(1))*cos(x_**WC('n', S(1))*WC('b', S(1)) + WC('a', S(0))), x_), cons2, cons3, cons21, cons4, cons5, cons53, cons54) def replacement3368(p, m, b, a, n, x): rubi.append(3368) return Simp(sin(a + b*x**n)**(p + S(1))/(b*n*(p + S(1))), x) rule3368 = ReplacementRule(pattern3368, replacement3368) pattern3369 = Pattern(Integral(x_**WC('m', S(1))*sin(x_**WC('n', S(1))*WC('b', S(1)) + WC('a', S(0)))*cos(x_**WC('n', S(1))*WC('b', S(1)) + WC('a', S(0)))**WC('p', S(1)), x_), cons2, cons3, cons21, cons4, cons5, cons53, cons54) def replacement3369(p, m, b, a, n, x): rubi.append(3369) return -Simp(cos(a + b*x**n)**(p + S(1))/(b*n*(p + S(1))), x) rule3369 = ReplacementRule(pattern3369, replacement3369) pattern3370 = Pattern(Integral(x_**WC('m', S(1))*sin(x_**WC('n', S(1))*WC('b', S(1)) + WC('a', S(0)))**WC('p', S(1))*cos(x_**WC('n', S(1))*WC('b', S(1)) + WC('a', S(0))), x_), cons2, cons3, cons5, cons93, cons1501, cons54) def replacement3370(p, m, b, a, n, x): rubi.append(3370) return -Dist((m - n + S(1))/(b*n*(p + S(1))), Int(x**(m - n)*sin(a + b*x**n)**(p + S(1)), x), x) + Simp(x**(m - n + S(1))*sin(a + b*x**n)**(p + S(1))/(b*n*(p + S(1))), x) rule3370 = ReplacementRule(pattern3370, replacement3370) pattern3371 = Pattern(Integral(x_**WC('m', S(1))*sin(x_**WC('n', S(1))*WC('b', S(1)) + WC('a', S(0)))*cos(x_**WC('n', S(1))*WC('b', S(1)) + WC('a', S(0)))**WC('p', S(1)), x_), cons2, cons3, cons5, cons93, cons1501, cons54) def replacement3371(p, m, b, a, n, x): rubi.append(3371) return Dist((m - n + S(1))/(b*n*(p + S(1))), Int(x**(m - n)*cos(a + b*x**n)**(p + S(1)), x), x) - Simp(x**(m - n + S(1))*cos(a + b*x**n)**(p + S(1))/(b*n*(p + S(1))), x) rule3371 = ReplacementRule(pattern3371, replacement3371) pattern3372 = Pattern(Integral(sin(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0))), x_), cons2, cons3, cons7, cons45) def replacement3372(x, c, a, b): rubi.append(3372) return Int(sin((b + S(2)*c*x)**S(2)/(S(4)*c)), x) rule3372 = ReplacementRule(pattern3372, replacement3372) pattern3373 = Pattern(Integral(cos(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0))), x_), cons2, cons3, cons7, cons45) def replacement3373(x, c, a, b): rubi.append(3373) return Int(cos((b + S(2)*c*x)**S(2)/(S(4)*c)), x) rule3373 = ReplacementRule(pattern3373, replacement3373) pattern3374 = Pattern(Integral(sin(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0))), x_), cons2, cons3, cons7, cons226) def replacement3374(x, c, a, b): rubi.append(3374) return -Dist(sin((-S(4)*a*c + b**S(2))/(S(4)*c)), Int(cos((b + S(2)*c*x)**S(2)/(S(4)*c)), x), x) + Dist(cos((-S(4)*a*c + b**S(2))/(S(4)*c)), Int(sin((b + S(2)*c*x)**S(2)/(S(4)*c)), x), x) rule3374 = ReplacementRule(pattern3374, replacement3374) pattern3375 = Pattern(Integral(cos(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0))), x_), cons2, cons3, cons7, cons226) def replacement3375(x, c, a, b): rubi.append(3375) return Dist(sin((-S(4)*a*c + b**S(2))/(S(4)*c)), Int(sin((b + S(2)*c*x)**S(2)/(S(4)*c)), x), x) + Dist(cos((-S(4)*a*c + b**S(2))/(S(4)*c)), Int(cos((b + S(2)*c*x)**S(2)/(S(4)*c)), x), x) rule3375 = ReplacementRule(pattern3375, replacement3375) pattern3376 = Pattern(Integral(sin(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0)))**n_, x_), cons2, cons3, cons7, cons85, cons165) def replacement3376(b, c, a, n, x): rubi.append(3376) return Int(ExpandTrigReduce(sin(a + b*x + c*x**S(2))**n, x), x) rule3376 = ReplacementRule(pattern3376, replacement3376) pattern3377 = Pattern(Integral(cos(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0)))**n_, x_), cons2, cons3, cons7, cons85, cons165) def replacement3377(b, c, a, n, x): rubi.append(3377) return Int(ExpandTrigReduce(cos(a + b*x + c*x**S(2))**n, x), x) rule3377 = ReplacementRule(pattern3377, replacement3377) pattern3378 = Pattern(Integral(sin(v_)**WC('n', S(1)), x_), cons148, cons818, cons1131) def replacement3378(v, x, n): rubi.append(3378) return Int(sin(ExpandToSum(v, x))**n, x) rule3378 = ReplacementRule(pattern3378, replacement3378) pattern3379 = Pattern(Integral(cos(v_)**WC('n', S(1)), x_), cons148, cons818, cons1131) def replacement3379(v, x, n): rubi.append(3379) return Int(cos(ExpandToSum(v, x))**n, x) rule3379 = ReplacementRule(pattern3379, replacement3379) pattern3380 = Pattern(Integral((d_ + x_*WC('e', S(1)))*sin(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0))), x_), cons2, cons3, cons7, cons27, cons48, cons47) def replacement3380(b, d, c, a, x, e): rubi.append(3380) return -Simp(e*cos(a + b*x + c*x**S(2))/(S(2)*c), x) rule3380 = ReplacementRule(pattern3380, replacement3380) pattern3381 = Pattern(Integral((d_ + x_*WC('e', S(1)))*cos(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0))), x_), cons2, cons3, cons7, cons27, cons48, cons47) def replacement3381(b, d, c, a, x, e): rubi.append(3381) return Simp(e*sin(a + b*x + c*x**S(2))/(S(2)*c), x) rule3381 = ReplacementRule(pattern3381, replacement3381) pattern3382 = Pattern(Integral((x_*WC('e', S(1)) + WC('d', S(0)))*sin(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0))), x_), cons2, cons3, cons7, cons27, cons48, cons239) def replacement3382(b, d, c, a, x, e): rubi.append(3382) return Dist((-b*e + S(2)*c*d)/(S(2)*c), Int(sin(a + b*x + c*x**S(2)), x), x) - Simp(e*cos(a + b*x + c*x**S(2))/(S(2)*c), x) rule3382 = ReplacementRule(pattern3382, replacement3382) pattern3383 = Pattern(Integral((x_*WC('e', S(1)) + WC('d', S(0)))*cos(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0))), x_), cons2, cons3, cons7, cons27, cons48, cons239) def replacement3383(b, d, c, a, x, e): rubi.append(3383) return Dist((-b*e + S(2)*c*d)/(S(2)*c), Int(cos(a + b*x + c*x**S(2)), x), x) + Simp(e*sin(a + b*x + c*x**S(2))/(S(2)*c), x) rule3383 = ReplacementRule(pattern3383, replacement3383) pattern3384 = Pattern(Integral((x_*WC('e', S(1)) + WC('d', S(0)))**m_*sin(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0))), x_), cons2, cons3, cons7, cons27, cons48, cons31, cons166, cons1132) def replacement3384(m, b, d, c, a, x, e): rubi.append(3384) return Dist(e**S(2)*(m + S(-1))/(S(2)*c), Int((d + e*x)**(m + S(-2))*cos(a + b*x + c*x**S(2)), x), x) - Simp(e*(d + e*x)**(m + S(-1))*cos(a + b*x + c*x**S(2))/(S(2)*c), x) rule3384 = ReplacementRule(pattern3384, replacement3384) pattern3385 = Pattern(Integral((x_*WC('e', S(1)) + WC('d', S(0)))**m_*cos(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0))), x_), cons2, cons3, cons7, cons27, cons48, cons31, cons166, cons1132) def replacement3385(m, b, d, c, a, x, e): rubi.append(3385) return -Dist(e**S(2)*(m + S(-1))/(S(2)*c), Int((d + e*x)**(m + S(-2))*sin(a + b*x + c*x**S(2)), x), x) + Simp(e*(d + e*x)**(m + S(-1))*sin(a + b*x + c*x**S(2))/(S(2)*c), x) rule3385 = ReplacementRule(pattern3385, replacement3385) pattern3386 = Pattern(Integral((x_*WC('e', S(1)) + WC('d', S(0)))**m_*sin(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0))), x_), cons2, cons3, cons7, cons27, cons48, cons31, cons166, cons1133) def replacement3386(m, b, d, c, a, x, e): rubi.append(3386) return -Dist((b*e - S(2)*c*d)/(S(2)*c), Int((d + e*x)**(m + S(-1))*sin(a + b*x + c*x**S(2)), x), x) + Dist(e**S(2)*(m + S(-1))/(S(2)*c), Int((d + e*x)**(m + S(-2))*cos(a + b*x + c*x**S(2)), x), x) - Simp(e*(d + e*x)**(m + S(-1))*cos(a + b*x + c*x**S(2))/(S(2)*c), x) rule3386 = ReplacementRule(pattern3386, replacement3386) pattern3387 = Pattern(Integral((x_*WC('e', S(1)) + WC('d', S(0)))**m_*cos(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0))), x_), cons2, cons3, cons7, cons27, cons48, cons31, cons166, cons1133) def replacement3387(m, b, d, c, a, x, e): rubi.append(3387) return -Dist((b*e - S(2)*c*d)/(S(2)*c), Int((d + e*x)**(m + S(-1))*cos(a + b*x + c*x**S(2)), x), x) - Dist(e**S(2)*(m + S(-1))/(S(2)*c), Int((d + e*x)**(m + S(-2))*sin(a + b*x + c*x**S(2)), x), x) + Simp(e*(d + e*x)**(m + S(-1))*sin(a + b*x + c*x**S(2))/(S(2)*c), x) rule3387 = ReplacementRule(pattern3387, replacement3387) pattern3388 = Pattern(Integral((x_*WC('e', S(1)) + WC('d', S(0)))**m_*sin(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0))), x_), cons2, cons3, cons7, cons27, cons48, cons31, cons94, cons1132) def replacement3388(m, b, d, c, a, x, e): rubi.append(3388) return -Dist(S(2)*c/(e**S(2)*(m + S(1))), Int((d + e*x)**(m + S(2))*cos(a + b*x + c*x**S(2)), x), x) + Simp((d + e*x)**(m + S(1))*sin(a + b*x + c*x**S(2))/(e*(m + S(1))), x) rule3388 = ReplacementRule(pattern3388, replacement3388) pattern3389 = Pattern(Integral((x_*WC('e', S(1)) + WC('d', S(0)))**m_*cos(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0))), x_), cons2, cons3, cons7, cons27, cons48, cons31, cons94, cons1132) def replacement3389(m, b, d, c, a, x, e): rubi.append(3389) return Dist(S(2)*c/(e**S(2)*(m + S(1))), Int((d + e*x)**(m + S(2))*sin(a + b*x + c*x**S(2)), x), x) + Simp((d + e*x)**(m + S(1))*cos(a + b*x + c*x**S(2))/(e*(m + S(1))), x) rule3389 = ReplacementRule(pattern3389, replacement3389) pattern3390 = Pattern(Integral((x_*WC('e', S(1)) + WC('d', S(0)))**m_*sin(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0))), x_), cons2, cons3, cons7, cons27, cons48, cons31, cons94, cons1133) def replacement3390(m, b, d, c, a, x, e): rubi.append(3390) return -Dist(S(2)*c/(e**S(2)*(m + S(1))), Int((d + e*x)**(m + S(2))*cos(a + b*x + c*x**S(2)), x), x) - Dist((b*e - S(2)*c*d)/(e**S(2)*(m + S(1))), Int((d + e*x)**(m + S(1))*cos(a + b*x + c*x**S(2)), x), x) + Simp((d + e*x)**(m + S(1))*sin(a + b*x + c*x**S(2))/(e*(m + S(1))), x) rule3390 = ReplacementRule(pattern3390, replacement3390) pattern3391 = Pattern(Integral((x_*WC('e', S(1)) + WC('d', S(0)))**m_*cos(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0))), x_), cons2, cons3, cons7, cons27, cons48, cons31, cons94, cons1133) def replacement3391(m, b, d, c, a, x, e): rubi.append(3391) return Dist(S(2)*c/(e**S(2)*(m + S(1))), Int((d + e*x)**(m + S(2))*sin(a + b*x + c*x**S(2)), x), x) + Dist((b*e - S(2)*c*d)/(e**S(2)*(m + S(1))), Int((d + e*x)**(m + S(1))*sin(a + b*x + c*x**S(2)), x), x) + Simp((d + e*x)**(m + S(1))*cos(a + b*x + c*x**S(2))/(e*(m + S(1))), x) rule3391 = ReplacementRule(pattern3391, replacement3391) pattern3392 = Pattern(Integral((x_*WC('e', S(1)) + WC('d', S(0)))**WC('m', S(1))*sin(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0))), x_), cons2, cons3, cons7, cons27, cons48, cons21, cons1507) def replacement3392(m, b, d, a, c, x, e): rubi.append(3392) return Int((d + e*x)**m*sin(a + b*x + c*x**S(2)), x) rule3392 = ReplacementRule(pattern3392, replacement3392) pattern3393 = Pattern(Integral((x_*WC('e', S(1)) + WC('d', S(0)))**WC('m', S(1))*cos(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0))), x_), cons2, cons3, cons7, cons27, cons48, cons21, cons1507) def replacement3393(m, b, d, c, a, x, e): rubi.append(3393) return Int((d + e*x)**m*cos(a + b*x + c*x**S(2)), x) rule3393 = ReplacementRule(pattern3393, replacement3393) pattern3394 = Pattern(Integral((x_*WC('e', S(1)) + WC('d', S(0)))**WC('m', S(1))*sin(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0)))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons21, cons85, cons165) def replacement3394(m, b, d, a, c, n, x, e): rubi.append(3394) return Int(ExpandTrigReduce((d + e*x)**m, sin(a + b*x + c*x**S(2))**n, x), x) rule3394 = ReplacementRule(pattern3394, replacement3394) pattern3395 = Pattern(Integral((x_*WC('e', S(1)) + WC('d', S(0)))**WC('m', S(1))*cos(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0)))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons21, cons85, cons165) def replacement3395(m, b, d, c, a, n, x, e): rubi.append(3395) return Int(ExpandTrigReduce((d + e*x)**m, cos(a + b*x + c*x**S(2))**n, x), x) rule3395 = ReplacementRule(pattern3395, replacement3395) pattern3396 = Pattern(Integral(u_**WC('m', S(1))*sin(v_)**WC('n', S(1)), x_), cons21, cons148, cons68, cons818, cons819) def replacement3396(v, u, m, n, x): rubi.append(3396) return Int(ExpandToSum(u, x)**m*sin(ExpandToSum(v, x))**n, x) rule3396 = ReplacementRule(pattern3396, replacement3396) pattern3397 = Pattern(Integral(u_**WC('m', S(1))*cos(v_)**WC('n', S(1)), x_), cons21, cons148, cons68, cons818, cons819) def replacement3397(v, u, m, n, x): rubi.append(3397) return Int(ExpandToSum(u, x)**m*cos(ExpandToSum(v, x))**n, x) rule3397 = ReplacementRule(pattern3397, replacement3397) return [rule2164, rule2165, rule2166, rule2167, rule2168, rule2169, rule2170, rule2171, rule2172, rule2173, rule2174, rule2175, rule2176, rule2177, rule2178, rule2179, rule2180, rule2181, rule2182, rule2183, rule2184, rule2185, rule2186, rule2187, rule2188, rule2189, rule2190, rule2191, rule2192, rule2193, rule2194, rule2195, rule2196, rule2197, rule2198, rule2199, rule2200, rule2201, rule2202, rule2203, rule2204, rule2205, rule2206, rule2207, rule2208, rule2209, rule2210, rule2211, rule2212, rule2213, rule2214, rule2215, rule2216, rule2217, rule2218, rule2219, rule2220, rule2221, rule2222, rule2223, rule2224, rule2225, rule2226, rule2227, rule2228, rule2229, rule2230, rule2231, rule2232, rule2233, rule2234, rule2235, rule2236, rule2237, rule2238, rule2239, rule2240, rule2241, rule2242, rule2243, rule2244, rule2245, rule2246, rule2247, rule2248, rule2249, rule2250, rule2251, rule2252, rule2253, rule2254, rule2255, rule2256, rule2257, rule2258, rule2259, rule2260, rule2261, rule2262, rule2263, rule2264, rule2265, rule2266, rule2267, rule2268, rule2269, rule2270, rule2271, rule2272, rule2273, rule2274, rule2275, rule2276, rule2277, rule2278, rule2279, rule2280, rule2281, rule2282, rule2283, rule2284, rule2285, rule2286, rule2287, rule2288, rule2289, rule2290, rule2291, rule2292, rule2293, rule2294, rule2295, rule2296, rule2297, rule2298, rule2299, rule2300, rule2301, rule2302, rule2303, rule2304, rule2305, rule2306, rule2307, rule2308, rule2309, rule2310, rule2311, rule2312, rule2313, rule2314, rule2315, rule2316, rule2317, rule2318, rule2319, rule2320, rule2321, rule2322, rule2323, rule2324, rule2325, rule2326, rule2327, rule2328, rule2329, rule2330, rule2331, rule2332, rule2333, rule2334, rule2335, rule2336, rule2337, rule2338, rule2339, rule2340, rule2341, rule2342, rule2343, rule2344, rule2345, rule2346, rule2347, rule2348, rule2349, rule2350, rule2351, rule2352, rule2353, rule2354, rule2355, rule2356, rule2357, rule2358, rule2359, rule2360, rule2361, rule2362, rule2363, rule2364, rule2365, rule2366, rule2367, rule2368, rule2369, rule2370, rule2371, rule2372, rule2373, rule2374, rule2375, rule2376, rule2377, rule2378, rule2379, rule2380, rule2381, rule2382, rule2383, rule2384, rule2385, rule2386, rule2387, rule2388, rule2389, rule2390, rule2391, rule2392, rule2393, rule2394, rule2395, rule2396, rule2397, rule2398, rule2399, rule2400, rule2401, rule2402, rule2403, rule2404, rule2405, rule2406, rule2407, rule2408, rule2409, rule2410, rule2411, rule2412, rule2413, rule2414, rule2415, rule2416, rule2417, rule2418, rule2419, rule2420, rule2421, rule2422, rule2423, rule2424, rule2425, rule2426, rule2427, rule2428, rule2429, rule2430, rule2431, rule2432, rule2433, rule2434, rule2435, rule2436, rule2437, rule2438, rule2439, rule2440, rule2441, rule2442, rule2443, rule2444, rule2445, rule2446, rule2447, rule2448, rule2449, rule2450, rule2451, rule2452, rule2453, rule2454, rule2455, rule2456, rule2457, rule2458, rule2459, rule2460, rule2461, rule2462, rule2463, rule2464, rule2465, rule2466, rule2467, rule2468, rule2469, rule2470, rule2471, rule2472, rule2473, rule2474, rule2475, rule2476, rule2477, rule2478, rule2479, rule2480, rule2481, rule2482, rule2483, rule2484, rule2485, rule2486, rule2487, rule2488, rule2489, rule2490, rule2491, rule2492, rule2493, rule2494, rule2495, rule2496, rule2497, rule2498, rule2499, rule2500, rule2501, rule2502, rule2503, rule2504, rule2505, rule2506, rule2507, rule2508, rule2509, rule2510, rule2511, rule2512, rule2513, rule2514, rule2515, rule2516, rule2517, rule2518, rule2519, rule2520, rule2521, rule2522, rule2523, rule2524, rule2525, rule2526, rule2527, rule2528, rule2529, rule2530, rule2531, rule2532, rule2533, rule2534, rule2535, rule2536, rule2537, rule2538, rule2539, rule2540, rule2541, rule2542, rule2543, rule2544, rule2545, rule2546, rule2547, rule2548, rule2549, rule2550, rule2551, rule2552, rule2553, rule2554, rule2555, rule2556, rule2557, rule2558, rule2559, rule2560, rule2561, rule2562, rule2563, rule2564, rule2565, rule2566, rule2567, rule2568, rule2569, rule2570, rule2571, rule2572, rule2573, rule2574, rule2575, rule2576, rule2577, rule2578, rule2579, rule2580, rule2581, rule2582, rule2583, rule2584, rule2585, rule2586, rule2587, rule2588, rule2589, rule2590, rule2591, rule2592, rule2593, rule2594, rule2595, rule2596, rule2597, rule2598, rule2599, rule2600, rule2601, rule2602, rule2603, rule2604, rule2605, rule2606, rule2607, rule2608, rule2609, rule2610, rule2611, rule2612, rule2613, rule2614, rule2615, rule2616, rule2617, rule2618, rule2619, rule2620, rule2621, rule2622, rule2623, rule2624, rule2625, rule2626, rule2627, rule2628, rule2629, rule2630, rule2631, rule2632, rule2633, rule2634, rule2635, rule2636, rule2637, rule2638, rule2639, rule2640, rule2641, rule2642, rule2643, rule2644, rule2645, rule2646, rule2647, rule2648, rule2649, rule2650, rule2651, rule2652, rule2653, rule2654, rule2655, rule2656, rule2657, rule2658, rule2659, rule2660, rule2661, rule2662, rule2663, rule2664, rule2665, rule2666, rule2667, rule2668, rule2669, rule2670, rule2671, rule2672, rule2673, rule2674, rule2675, rule2676, rule2677, rule2678, rule2679, rule2680, rule2681, rule2682, rule2683, rule2684, rule2685, rule2686, rule2687, rule2688, rule2689, rule2690, rule2691, rule2692, rule2693, rule2694, rule2695, rule2696, rule2697, rule2698, rule2699, rule2700, rule2701, rule2702, rule2703, rule2704, rule2705, rule2706, rule2707, rule2708, rule2709, rule2710, rule2711, rule2712, rule2713, rule2714, rule2715, rule2716, rule2717, rule2718, rule2719, rule2720, rule2721, rule2722, rule2723, rule2724, rule2725, rule2726, rule2727, rule2728, rule2729, rule2730, rule2731, rule2732, rule2733, rule2734, rule2735, rule2736, rule2737, rule2738, rule2739, rule2740, rule2741, rule2742, rule2743, rule2744, rule2745, rule2746, rule2747, rule2748, rule2749, rule2750, rule2751, rule2752, rule2753, rule2754, rule2755, rule2756, rule2757, rule2758, rule2759, rule2760, rule2761, rule2762, rule2763, rule2764, rule2765, rule2766, rule2767, rule2768, rule2769, rule2770, rule2771, rule2772, rule2773, rule2774, rule2775, rule2776, rule2777, rule2778, rule2779, rule2780, rule2781, rule2782, rule2783, rule2784, rule2785, rule2786, rule2787, rule2788, rule2789, rule2790, rule2791, rule2792, rule2793, rule2794, rule2795, rule2796, rule2797, rule2798, rule2799, rule2800, rule2801, rule2802, rule2803, rule2804, rule2805, rule2806, rule2807, rule2808, rule2809, rule2810, rule2811, rule2812, rule2813, rule2814, rule2815, rule2816, rule2817, rule2818, rule2819, rule2820, rule2821, rule2822, rule2823, rule2824, rule2825, rule2826, rule2827, rule2828, rule2829, rule2830, rule2831, rule2832, rule2833, rule2834, rule2835, rule2836, rule2837, rule2838, rule2839, rule2840, rule2841, rule2842, rule2843, rule2844, rule2845, rule2846, rule2847, rule2848, rule2849, rule2850, rule2851, rule2852, rule2853, rule2854, rule2855, rule2856, rule2857, rule2858, rule2859, rule2860, rule2861, rule2862, rule2863, rule2864, rule2865, rule2866, rule2867, rule2868, rule2869, rule2870, rule2871, rule2872, rule2873, rule2874, rule2875, rule2876, rule2877, rule2878, rule2879, rule2880, rule2881, rule2882, rule2883, rule2884, rule2885, rule2886, rule2887, rule2888, rule2889, rule2890, rule2891, rule2892, rule2893, rule2894, rule2895, rule2896, rule2897, rule2898, rule2899, rule2900, rule2901, rule2902, rule2903, rule2904, rule2905, rule2906, rule2907, rule2908, rule2909, rule2910, rule2911, rule2912, rule2913, rule2914, rule2915, rule2916, rule2917, rule2918, rule2919, rule2920, rule2921, rule2922, rule2923, rule2924, rule2925, rule2926, rule2927, rule2928, rule2929, rule2930, rule2931, rule2932, rule2933, rule2934, rule2935, rule2936, rule2937, rule2938, rule2939, rule2940, rule2941, rule2942, rule2943, rule2944, rule2945, rule2946, rule2947, rule2948, rule2949, rule2950, rule2951, rule2952, rule2953, rule2954, rule2955, rule2956, rule2957, rule2958, rule2959, rule2960, rule2961, rule2962, rule2963, rule2964, rule2965, rule2966, rule2967, rule2968, rule2969, rule2970, rule2971, rule2972, rule2973, rule2974, rule2975, rule2976, rule2977, rule2978, rule2979, rule2980, rule2981, rule2982, rule2983, rule2984, rule2985, rule2986, rule2987, rule2988, rule2989, rule2990, rule2991, rule2992, rule2993, rule2994, rule2995, rule2996, rule2997, rule2998, rule2999, rule3000, rule3001, rule3002, rule3003, rule3004, rule3005, rule3006, rule3007, rule3008, rule3009, rule3010, rule3011, rule3012, rule3013, rule3014, rule3015, rule3016, rule3017, rule3018, rule3019, rule3020, rule3021, rule3022, rule3023, rule3024, rule3025, rule3026, rule3027, rule3028, rule3029, rule3030, rule3031, rule3032, rule3033, rule3034, rule3035, rule3036, rule3037, rule3038, rule3039, rule3040, rule3041, rule3042, rule3043, rule3044, rule3045, rule3046, rule3047, rule3048, rule3049, rule3050, rule3051, rule3052, rule3053, rule3054, rule3055, rule3056, rule3057, rule3058, rule3059, rule3060, rule3061, rule3062, rule3063, rule3064, rule3065, rule3066, rule3067, rule3068, rule3069, rule3070, rule3071, rule3072, rule3073, rule3074, rule3075, rule3076, rule3077, rule3078, rule3079, rule3080, rule3081, rule3082, rule3083, rule3084, rule3085, rule3086, rule3087, rule3088, rule3089, rule3090, rule3091, rule3092, rule3093, rule3094, rule3095, rule3096, rule3097, rule3098, rule3099, rule3100, rule3101, rule3102, rule3103, rule3104, rule3105, rule3106, rule3107, rule3108, rule3109, rule3110, rule3111, rule3112, rule3113, rule3114, rule3115, rule3116, rule3117, rule3118, rule3119, rule3120, rule3121, rule3122, rule3123, rule3124, rule3125, rule3126, rule3127, rule3128, rule3129, rule3130, rule3131, rule3132, rule3133, rule3134, rule3135, rule3136, rule3137, rule3138, rule3139, rule3140, rule3141, rule3142, rule3143, rule3144, rule3145, rule3146, rule3147, rule3148, rule3149, rule3150, rule3151, rule3152, rule3153, rule3154, rule3155, rule3156, rule3157, rule3158, rule3159, rule3160, rule3161, rule3162, rule3163, rule3164, rule3165, rule3166, rule3167, rule3168, rule3169, rule3170, rule3171, rule3172, rule3173, rule3174, rule3175, rule3176, rule3177, rule3178, rule3179, rule3180, rule3181, rule3182, rule3183, rule3184, rule3185, rule3186, rule3187, rule3188, rule3189, rule3190, rule3191, rule3192, rule3193, rule3194, rule3195, rule3196, rule3197, rule3198, rule3199, rule3200, rule3201, rule3202, rule3203, rule3204, rule3205, rule3206, rule3207, rule3208, rule3209, rule3210, rule3211, rule3212, rule3213, rule3214, rule3215, rule3216, rule3217, rule3218, rule3219, rule3220, rule3221, rule3222, rule3223, rule3224, rule3225, rule3226, rule3227, rule3228, rule3229, rule3230, rule3231, rule3232, rule3233, rule3234, rule3235, rule3236, rule3237, rule3238, rule3239, rule3240, rule3241, rule3242, rule3243, rule3244, rule3245, rule3246, rule3247, rule3248, rule3249, rule3250, rule3251, rule3252, rule3253, rule3254, rule3255, rule3256, rule3257, rule3258, rule3259, rule3260, rule3261, rule3262, rule3263, rule3264, rule3265, rule3266, rule3267, rule3268, rule3269, rule3270, rule3271, rule3272, rule3273, rule3274, rule3275, rule3276, rule3277, rule3278, rule3279, rule3280, rule3281, rule3282, rule3283, rule3284, rule3285, rule3286, rule3287, rule3288, rule3289, rule3290, rule3291, rule3292, rule3293, rule3294, rule3295, rule3296, rule3297, rule3298, rule3299, rule3300, rule3301, rule3302, rule3303, rule3304, rule3305, rule3306, rule3307, rule3308, rule3309, rule3310, rule3311, rule3312, rule3313, rule3314, rule3315, rule3316, rule3317, rule3318, rule3319, rule3320, rule3321, rule3322, rule3323, rule3324, rule3325, rule3326, rule3327, rule3328, rule3329, rule3330, rule3331, rule3332, rule3333, rule3334, rule3335, rule3336, rule3337, rule3338, rule3339, rule3340, rule3341, rule3342, rule3343, rule3344, rule3345, rule3346, rule3347, rule3348, rule3349, rule3350, rule3351, rule3352, rule3353, rule3354, rule3355, rule3356, rule3357, rule3358, rule3359, rule3360, rule3361, rule3362, rule3363, rule3364, rule3365, rule3366, rule3367, rule3368, rule3369, rule3370, rule3371, rule3372, rule3373, rule3374, rule3375, rule3376, rule3377, rule3378, rule3379, rule3380, rule3381, rule3382, rule3383, rule3384, rule3385, rule3386, rule3387, rule3388, rule3389, rule3390, rule3391, rule3392, rule3393, rule3394, rule3395, rule3396, rule3397, ]
614ae478a3f078e7f8701a6a682f48dbb7c64bf5d441839652a73f8eaa4c1226
''' This code is automatically generated. Never edit it manually. For details of generating the code see `rubi_parsing_guide.md` in `parsetools`. ''' from sympy.external import import_module matchpy = import_module("matchpy") from sympy.utilities.decorator import doctest_depends_on if matchpy: from matchpy import Pattern, ReplacementRule, CustomConstraint, is_match from sympy.integrals.rubi.utility_function import ( Int, Sum, Set, With, Module, Scan, MapAnd, FalseQ, ZeroQ, NegativeQ, NonzeroQ, FreeQ, NFreeQ, List, Log, PositiveQ, PositiveIntegerQ, NegativeIntegerQ, IntegerQ, IntegersQ, ComplexNumberQ, PureComplexNumberQ, RealNumericQ, PositiveOrZeroQ, NegativeOrZeroQ, FractionOrNegativeQ, NegQ, Equal, Unequal, IntPart, FracPart, RationalQ, ProductQ, SumQ, NonsumQ, Subst, First, Rest, SqrtNumberQ, SqrtNumberSumQ, LinearQ, Sqrt, ArcCosh, Coefficient, Denominator, Hypergeometric2F1, Not, Simplify, FractionalPart, IntegerPart, AppellF1, EllipticPi, EllipticE, EllipticF, ArcTan, ArcCot, ArcCoth, ArcTanh, ArcSin, ArcSinh, ArcCos, ArcCsc, ArcSec, ArcCsch, ArcSech, Sinh, Tanh, Cosh, Sech, Csch, Coth, LessEqual, Less, Greater, GreaterEqual, FractionQ, IntLinearcQ, Expand, IndependentQ, PowerQ, IntegerPowerQ, PositiveIntegerPowerQ, FractionalPowerQ, AtomQ, ExpQ, LogQ, Head, MemberQ, TrigQ, SinQ, CosQ, TanQ, CotQ, SecQ, CscQ, Sin, Cos, Tan, Cot, Sec, Csc, HyperbolicQ, SinhQ, CoshQ, TanhQ, CothQ, SechQ, CschQ, InverseTrigQ, SinCosQ, SinhCoshQ, LeafCount, Numerator, NumberQ, NumericQ, Length, ListQ, Im, Re, InverseHyperbolicQ, InverseFunctionQ, TrigHyperbolicFreeQ, InverseFunctionFreeQ, RealQ, EqQ, FractionalPowerFreeQ, ComplexFreeQ, PolynomialQ, FactorSquareFree, PowerOfLinearQ, Exponent, QuadraticQ, LinearPairQ, BinomialParts, TrinomialParts, PolyQ, EvenQ, OddQ, PerfectSquareQ, NiceSqrtAuxQ, NiceSqrtQ, Together, PosAux, PosQ, CoefficientList, ReplaceAll, ExpandLinearProduct, GCD, ContentFactor, NumericFactor, NonnumericFactors, MakeAssocList, GensymSubst, KernelSubst, ExpandExpression, Apart, SmartApart, MatchQ, PolynomialQuotientRemainder, FreeFactors, NonfreeFactors, RemoveContentAux, RemoveContent, FreeTerms, NonfreeTerms, ExpandAlgebraicFunction, CollectReciprocals, ExpandCleanup, AlgebraicFunctionQ, Coeff, LeadTerm, RemainingTerms, LeadFactor, RemainingFactors, LeadBase, LeadDegree, Numer, Denom, hypergeom, Expon, MergeMonomials, PolynomialDivide, BinomialQ, TrinomialQ, GeneralizedBinomialQ, GeneralizedTrinomialQ, FactorSquareFreeList, PerfectPowerTest, SquareFreeFactorTest, RationalFunctionQ, RationalFunctionFactors, NonrationalFunctionFactors, Reverse, RationalFunctionExponents, RationalFunctionExpand, ExpandIntegrand, SimplerQ, SimplerSqrtQ, SumSimplerQ, BinomialDegree, TrinomialDegree, CancelCommonFactors, SimplerIntegrandQ, GeneralizedBinomialDegree, GeneralizedBinomialParts, GeneralizedTrinomialDegree, GeneralizedTrinomialParts, MonomialQ, MonomialSumQ, MinimumMonomialExponent, MonomialExponent, LinearMatchQ, PowerOfLinearMatchQ, QuadraticMatchQ, CubicMatchQ, BinomialMatchQ, TrinomialMatchQ, GeneralizedBinomialMatchQ, GeneralizedTrinomialMatchQ, QuotientOfLinearsMatchQ, PolynomialTermQ, PolynomialTerms, NonpolynomialTerms, PseudoBinomialParts, NormalizePseudoBinomial, PseudoBinomialPairQ, PseudoBinomialQ, PolynomialGCD, PolyGCD, AlgebraicFunctionFactors, NonalgebraicFunctionFactors, QuotientOfLinearsP, QuotientOfLinearsParts, QuotientOfLinearsQ, Flatten, Sort, AbsurdNumberQ, AbsurdNumberFactors, NonabsurdNumberFactors, SumSimplerAuxQ, Prepend, Drop, CombineExponents, FactorInteger, FactorAbsurdNumber, SubstForInverseFunction, SubstForFractionalPower, SubstForFractionalPowerOfQuotientOfLinears, FractionalPowerOfQuotientOfLinears, SubstForFractionalPowerQ, SubstForFractionalPowerAuxQ, FractionalPowerOfSquareQ, FractionalPowerSubexpressionQ, Apply, FactorNumericGcd, MergeableFactorQ, MergeFactor, MergeFactors, TrigSimplifyQ, TrigSimplify, TrigSimplifyRecur, Order, FactorOrder, Smallest, OrderedQ, MinimumDegree, PositiveFactors, Sign, NonpositiveFactors, PolynomialInAuxQ, PolynomialInQ, ExponentInAux, ExponentIn, PolynomialInSubstAux, PolynomialInSubst, Distrib, DistributeDegree, FunctionOfPower, DivideDegreesOfFactors, MonomialFactor, FullSimplify, FunctionOfLinearSubst, FunctionOfLinear, NormalizeIntegrand, NormalizeIntegrandAux, NormalizeIntegrandFactor, NormalizeIntegrandFactorBase, NormalizeTogether, NormalizeLeadTermSigns, AbsorbMinusSign, NormalizeSumFactors, SignOfFactor, NormalizePowerOfLinear, SimplifyIntegrand, SimplifyTerm, TogetherSimplify, SmartSimplify, SubstForExpn, ExpandToSum, UnifySum, UnifyTerms, UnifyTerm, CalculusQ, FunctionOfInverseLinear, PureFunctionOfSinhQ, PureFunctionOfTanhQ, PureFunctionOfCoshQ, IntegerQuotientQ, OddQuotientQ, EvenQuotientQ, FindTrigFactor, FunctionOfSinhQ, FunctionOfCoshQ, OddHyperbolicPowerQ, FunctionOfTanhQ, FunctionOfTanhWeight, FunctionOfHyperbolicQ, SmartNumerator, SmartDenominator, SubstForAux, ActivateTrig, ExpandTrig, TrigExpand, SubstForTrig, SubstForHyperbolic, InertTrigFreeQ, LCM, SubstForFractionalPowerOfLinear, FractionalPowerOfLinear, InverseFunctionOfLinear, InertTrigQ, InertReciprocalQ, DeactivateTrig, FixInertTrigFunction, DeactivateTrigAux, PowerOfInertTrigSumQ, PiecewiseLinearQ, KnownTrigIntegrandQ, KnownSineIntegrandQ, KnownTangentIntegrandQ, KnownCotangentIntegrandQ, KnownSecantIntegrandQ, TryPureTanSubst, TryTanhSubst, TryPureTanhSubst, AbsurdNumberGCD, AbsurdNumberGCDList, ExpandTrigExpand, ExpandTrigReduce, ExpandTrigReduceAux, NormalizeTrig, TrigToExp, ExpandTrigToExp, TrigReduce, FunctionOfTrig, AlgebraicTrigFunctionQ, FunctionOfHyperbolic, FunctionOfQ, FunctionOfExpnQ, PureFunctionOfSinQ, PureFunctionOfCosQ, PureFunctionOfTanQ, PureFunctionOfCotQ, FunctionOfCosQ, FunctionOfSinQ, OddTrigPowerQ, FunctionOfTanQ, FunctionOfTanWeight, FunctionOfTrigQ, FunctionOfDensePolynomialsQ, FunctionOfLog, PowerVariableExpn, PowerVariableDegree, PowerVariableSubst, EulerIntegrandQ, FunctionOfSquareRootOfQuadratic, SquareRootOfQuadraticSubst, Divides, EasyDQ, ProductOfLinearPowersQ, Rt, NthRoot, AtomBaseQ, SumBaseQ, NegSumBaseQ, AllNegTermQ, SomeNegTermQ, TrigSquareQ, RtAux, TrigSquare, IntSum, IntTerm, Map2, ConstantFactor, SameQ, ReplacePart, CommonFactors, MostMainFactorPosition, FunctionOfExponentialQ, FunctionOfExponential, FunctionOfExponentialFunction, FunctionOfExponentialFunctionAux, FunctionOfExponentialTest, FunctionOfExponentialTestAux, stdev, rubi_test, If, IntQuadraticQ, IntBinomialQ, RectifyTangent, RectifyCotangent, Inequality, Condition, Simp, SimpHelp, SplitProduct, SplitSum, SubstFor, SubstForAux, FresnelS, FresnelC, Erfc, Erfi, Gamma, FunctionOfTrigOfLinearQ, ElementaryFunctionQ, Complex, UnsameQ, _SimpFixFactor, SimpFixFactor, _FixSimplify, FixSimplify, _SimplifyAntiderivativeSum, SimplifyAntiderivativeSum, _SimplifyAntiderivative, SimplifyAntiderivative, _TrigSimplifyAux, TrigSimplifyAux, Cancel, Part, PolyLog, D, Dist, Sum_doit, PolynomialQuotient, Floor, PolynomialRemainder, Factor, PolyLog, CosIntegral, SinIntegral, LogIntegral, SinhIntegral, CoshIntegral, Rule, Erf, PolyGamma, ExpIntegralEi, ExpIntegralE, LogGamma , UtilityOperator, Factorial, Zeta, ProductLog, DerivativeDivides, HypergeometricPFQ, IntHide, OneQ, Null, rubi_exp as exp, rubi_log as log, Discriminant, Negative, Quotient ) from sympy import (Integral, S, sqrt, And, Or, Integer, Float, Mod, I, Abs, simplify, Mul, Add, Pow, sign, EulerGamma) from sympy.integrals.rubi.symbol import WC from sympy.core.symbol import symbols, Symbol from sympy.functions import (sin, cos, tan, cot, csc, sec, sqrt, erf) from sympy.functions.elementary.hyperbolic import (acosh, asinh, atanh, acoth, acsch, asech, cosh, sinh, tanh, coth, sech, csch) from sympy.functions.elementary.trigonometric import (atan, acsc, asin, acot, acos, asec, atan2) from sympy import pi as Pi A_, B_, C_, F_, G_, H_, a_, b_, c_, d_, e_, f_, g_, h_, i_, j_, k_, l_, m_, n_, p_, q_, r_, t_, u_, v_, s_, w_, x_, y_, z_ = [WC(i) for i in 'ABCFGHabcdefghijklmnpqrtuvswxyz'] a1_, a2_, b1_, b2_, c1_, c2_, d1_, d2_, n1_, n2_, e1_, e2_, f1_, f2_, g1_, g2_, n1_, n2_, n3_, Pq_, Pm_, Px_, Qm_, Qr_, Qx_, jn_, mn_, non2_, RFx_, RGx_ = [WC(i) for i in ['a1', 'a2', 'b1', 'b2', 'c1', 'c2', 'd1', 'd2', 'n1', 'n2', 'e1', 'e2', 'f1', 'f2', 'g1', 'g2', 'n1', 'n2', 'n3', 'Pq', 'Pm', 'Px', 'Qm', 'Qr', 'Qx', 'jn', 'mn', 'non2', 'RFx', 'RGx']] i, ii , Pqq, Q, R, r, C, k, u = symbols('i ii Pqq Q R r C k u') _UseGamma = False ShowSteps = False StepCounter = None def logarithms(rubi): from sympy.integrals.rubi.constraints import cons1156, cons7, cons27, cons48, cons125, cons5, cons50, cons87, cons88, cons2, cons3, cons1157, cons415, cons1158, cons1159, cons89, cons543, cons1160, cons208, cons209, cons584, cons4, cons66, cons21, cons1161, cons1162, cons1163, cons1164, cons1165, cons1166, cons1167, cons1168, cons1169, cons148, cons1170, cons1171, cons62, cons93, cons168, cons810, cons811, cons222, cons1172, cons224, cons796, cons79, cons1173, cons17, cons1174, cons1175, cons1176, cons1177, cons1178, cons1179, cons1180, cons1181, cons1182, cons1183, cons1184, cons1185, cons1186, cons1187, cons1188, cons1189, cons1190, cons797, cons1191, cons52, cons925, cons1192, cons1193, cons1194, cons1195, cons1196, cons1197, cons1198, cons1199, cons38, cons552, cons1200, cons1201, cons1202, cons25, cons652, cons1203, cons71, cons128, cons1204, cons1205, cons1206, cons1207, cons1208, cons146, cons1209, cons1210, cons13, cons163, cons1211, cons137, cons1212, cons1213, cons1214, cons1215, cons1216, cons1217, cons1218, cons1219, cons1220, cons1221, cons1222, cons70, cons1223, cons1224, cons806, cons840, cons1225, cons1226, cons68, cons1125, cons1227, cons1228, cons1229, cons1230, cons463, cons1231, cons1232, cons1233, cons1234, cons1235, cons1236, cons31, cons1099, cons1237, cons1055, cons515, cons816, cons817, cons1238, cons1239, cons1240, cons1241, cons1242, cons1243, cons1244, cons1245, cons34, cons35, cons1246, cons1247, cons1248 pattern2006 = Pattern(Integral(log(((x_*WC('f', S(1)) + WC('e', S(0)))**WC('p', S(1))*WC('d', S(1)))**WC('q', S(1))*WC('c', S(1))), x_), cons7, cons27, cons48, cons125, cons5, cons50, cons1156) def replacement2006(p, f, d, c, x, q, e): rubi.append(2006) return Simp((e + f*x)*log(c*(d*(e + f*x)**p)**q)/f, x) - Simp(p*q*x, x) rule2006 = ReplacementRule(pattern2006, replacement2006) pattern2007 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*log(((x_*WC('f', S(1)) + WC('e', S(0)))**WC('p', S(1))*WC('d', S(1)))**WC('q', S(1))*WC('c', S(1))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons5, cons50, cons87, cons88) def replacement2007(p, f, b, d, a, c, n, x, q, e): rubi.append(2007) return -Dist(b*n*p*q, Int((a + b*log(c*(d*(e + f*x)**p)**q))**(n + S(-1)), x), x) + Simp((a + b*log(c*(d*(e + f*x)**p)**q))**n*(e + f*x)/f, x) rule2007 = ReplacementRule(pattern2007, replacement2007) pattern2008 = Pattern(Integral(S(1)/log((x_*WC('f', S(1)) + WC('e', S(0)))*WC('d', S(1))), x_), cons27, cons48, cons125, cons1157) def replacement2008(d, x, f, e): rubi.append(2008) return Simp(LogIntegral(d*(e + f*x))/(d*f), x) rule2008 = ReplacementRule(pattern2008, replacement2008) pattern2009 = Pattern(Integral(S(1)/(WC('a', S(0)) + WC('b', S(1))*log(((x_*WC('f', S(1)) + WC('e', S(0)))**WC('p', S(1))*WC('d', S(1)))**WC('q', S(1))*WC('c', S(1)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons5, cons50, cons415) def replacement2009(p, f, b, d, a, c, x, q, e): rubi.append(2009) return Simp((c*(d*(e + f*x)**p)**q)**(-S(1)/(p*q))*(e + f*x)*ExpIntegralEi((a + b*log(c*(d*(e + f*x)**p)**q))/(b*p*q))*exp(-a/(b*p*q))/(b*f*p*q), x) rule2009 = ReplacementRule(pattern2009, replacement2009) pattern2010 = Pattern(Integral(S(1)/sqrt(WC('a', S(0)) + WC('b', S(1))*log(((x_*WC('f', S(1)) + WC('e', S(0)))**WC('p', S(1))*WC('d', S(1)))**WC('q', S(1))*WC('c', S(1)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons5, cons50, cons1158) def replacement2010(p, f, b, d, a, c, x, q, e): rubi.append(2010) return Simp(sqrt(Pi)*(c*(d*(e + f*x)**p)**q)**(-S(1)/(p*q))*(e + f*x)*Erfi(sqrt(a + b*log(c*(d*(e + f*x)**p)**q))/Rt(b*p*q, S(2)))*Rt(b*p*q, S(2))*exp(-a/(b*p*q))/(b*f*p*q), x) rule2010 = ReplacementRule(pattern2010, replacement2010) pattern2011 = Pattern(Integral(S(1)/sqrt(WC('a', S(0)) + WC('b', S(1))*log(((x_*WC('f', S(1)) + WC('e', S(0)))**WC('p', S(1))*WC('d', S(1)))**WC('q', S(1))*WC('c', S(1)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons5, cons50, cons1159) def replacement2011(p, f, b, d, a, c, x, q, e): rubi.append(2011) return Simp(sqrt(Pi)*(c*(d*(e + f*x)**p)**q)**(-S(1)/(p*q))*(e + f*x)*Erf(sqrt(a + b*log(c*(d*(e + f*x)**p)**q))/Rt(-b*p*q, S(2)))*Rt(-b*p*q, S(2))*exp(-a/(b*p*q))/(b*f*p*q), x) rule2011 = ReplacementRule(pattern2011, replacement2011) pattern2012 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*log(((x_*WC('f', S(1)) + WC('e', S(0)))**WC('p', S(1))*WC('d', S(1)))**WC('q', S(1))*WC('c', S(1))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons5, cons50, cons87, cons89) def replacement2012(p, f, b, d, a, c, n, x, q, e): rubi.append(2012) return -Dist(S(1)/(b*p*q*(n + S(1))), Int((a + b*log(c*(d*(e + f*x)**p)**q))**(n + S(1)), x), x) + Simp((a + b*log(c*(d*(e + f*x)**p)**q))**(n + S(1))*(e + f*x)/(b*f*p*q*(n + S(1))), x) rule2012 = ReplacementRule(pattern2012, replacement2012) pattern2013 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*log(((x_*WC('f', S(1)) + WC('e', S(0)))**WC('p', S(1))*WC('d', S(1)))**WC('q', S(1))*WC('c', S(1))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons5, cons50, cons543) def replacement2013(p, f, b, d, a, c, n, x, q, e): rubi.append(2013) return Simp((c*(d*(e + f*x)**p)**q)**(-S(1)/(p*q))*(-(a + b*log(c*(d*(e + f*x)**p)**q))/(b*p*q))**(-n)*(a + b*log(c*(d*(e + f*x)**p)**q))**n*(e + f*x)*Gamma(n + S(1), -(a + b*log(c*(d*(e + f*x)**p)**q))/(b*p*q))*exp(-a/(b*p*q))/f, x) rule2013 = ReplacementRule(pattern2013, replacement2013) pattern2014 = Pattern(Integral(S(1)/((x_*WC('h', S(1)) + WC('g', S(0)))*(WC('a', S(0)) + WC('b', S(1))*log(((x_*WC('f', S(1)) + WC('e', S(0)))**WC('p', S(1))*WC('d', S(1)))**WC('q', S(1))*WC('c', S(1))))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons209, cons5, cons50, cons1160) def replacement2014(p, f, b, g, d, a, c, x, h, q, e): rubi.append(2014) return Simp(log(RemoveContent(a + b*log(c*(d*(e + f*x)**p)**q), x))/(b*h*p*q), x) rule2014 = ReplacementRule(pattern2014, replacement2014) pattern2015 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*log(((x_*WC('f', S(1)) + WC('e', S(0)))**WC('p', S(1))*WC('d', S(1)))**WC('q', S(1))*WC('c', S(1))))**WC('n', S(1))/(x_*WC('h', S(1)) + WC('g', S(0))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons209, cons4, cons5, cons50, cons1160, cons584) def replacement2015(p, f, b, g, d, a, c, n, x, h, q, e): rubi.append(2015) return Simp((a + b*log(c*(d*(e + f*x)**p)**q))**(n + S(1))/(b*h*p*q*(n + S(1))), x) rule2015 = ReplacementRule(pattern2015, replacement2015) pattern2016 = Pattern(Integral((x_*WC('h', S(1)) + WC('g', S(0)))**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*log(((x_*WC('f', S(1)) + WC('e', S(0)))**WC('p', S(1))*WC('d', S(1)))**WC('q', S(1))*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons209, cons21, cons5, cons50, cons1160, cons66, cons87, cons88) def replacement2016(p, m, f, b, g, d, a, c, n, x, h, q, e): rubi.append(2016) return -Dist(b*n*p*q/(m + S(1)), Int((a + b*log(c*(d*(e + f*x)**p)**q))**(n + S(-1))*(g + h*x)**m, x), x) + Simp((a + b*log(c*(d*(e + f*x)**p)**q))**n*(g + h*x)**(m + S(1))/(h*(m + S(1))), x) rule2016 = ReplacementRule(pattern2016, replacement2016) pattern2017 = Pattern(Integral((x_*WC('h', S(1)) + WC('g', S(0)))**WC('m', S(1))/log((x_*WC('f', S(1)) + WC('e', S(0)))**WC('p', S(1))*WC('d', S(1))), x_), cons27, cons48, cons125, cons208, cons209, cons21, cons5, cons1161, cons1160, cons1162) def replacement2017(p, m, f, g, d, x, h, e): rubi.append(2017) return Simp((h/f)**(p + S(-1))*LogIntegral(d*(e + f*x)**p)/(d*f*p), x) rule2017 = ReplacementRule(pattern2017, replacement2017) pattern2018 = Pattern(Integral((x_*WC('h', S(1)) + WC('g', S(0)))**m_/log((x_*WC('f', S(1)) + WC('e', S(0)))**WC('p', S(1))*WC('d', S(1))), x_), cons27, cons48, cons125, cons208, cons209, cons21, cons5, cons1161, cons1160, cons1163) def replacement2018(p, m, f, g, d, x, h, e): rubi.append(2018) return Dist((e + f*x)**(-p + S(1))*(g + h*x)**(p + S(-1)), Int((e + f*x)**(p + S(-1))/log(d*(e + f*x)**p), x), x) rule2018 = ReplacementRule(pattern2018, replacement2018) pattern2019 = Pattern(Integral((x_*WC('h', S(1)) + WC('g', S(0)))**WC('m', S(1))/(WC('a', S(0)) + WC('b', S(1))*log(((x_*WC('f', S(1)) + WC('e', S(0)))**WC('p', S(1))*WC('d', S(1)))**WC('q', S(1))*WC('c', S(1)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons209, cons21, cons5, cons50, cons1160, cons66) def replacement2019(p, m, f, b, g, d, a, c, x, h, q, e): rubi.append(2019) return Simp((c*(d*(e + f*x)**p)**q)**(-(m + S(1))/(p*q))*(g + h*x)**(m + S(1))*ExpIntegralEi((a + b*log(c*(d*(e + f*x)**p)**q))*(m + S(1))/(b*p*q))*exp(-a*(m + S(1))/(b*p*q))/(b*h*p*q), x) rule2019 = ReplacementRule(pattern2019, replacement2019) pattern2020 = Pattern(Integral((x_*WC('h', S(1)) + WC('g', S(0)))**WC('m', S(1))/sqrt(WC('a', S(0)) + WC('b', S(1))*log(((x_*WC('f', S(1)) + WC('e', S(0)))**WC('p', S(1))*WC('d', S(1)))**WC('q', S(1))*WC('c', S(1)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons209, cons21, cons5, cons50, cons1160, cons66, cons1164) def replacement2020(p, m, f, b, g, d, a, c, x, h, q, e): rubi.append(2020) return Simp(sqrt(Pi)*(c*(d*(e + f*x)**p)**q)**(-(m + S(1))/(p*q))*(g + h*x)**(m + S(1))*Erfi(sqrt(a + b*log(c*(d*(e + f*x)**p)**q))*Rt((m + S(1))/(b*p*q), S(2)))*exp(-a*(m + S(1))/(b*p*q))/(b*h*p*q*Rt((m + S(1))/(b*p*q), S(2))), x) rule2020 = ReplacementRule(pattern2020, replacement2020) pattern2021 = Pattern(Integral((x_*WC('h', S(1)) + WC('g', S(0)))**WC('m', S(1))/sqrt(WC('a', S(0)) + WC('b', S(1))*log(((x_*WC('f', S(1)) + WC('e', S(0)))**WC('p', S(1))*WC('d', S(1)))**WC('q', S(1))*WC('c', S(1)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons209, cons21, cons5, cons50, cons1160, cons66, cons1165) def replacement2021(p, m, f, b, g, d, a, c, x, h, q, e): rubi.append(2021) return Simp(sqrt(Pi)*(c*(d*(e + f*x)**p)**q)**(-(m + S(1))/(p*q))*(g + h*x)**(m + S(1))*Erf(sqrt(a + b*log(c*(d*(e + f*x)**p)**q))*Rt(-(m + S(1))/(b*p*q), S(2)))*exp(-a*(m + S(1))/(b*p*q))/(b*h*p*q*Rt(-(m + S(1))/(b*p*q), S(2))), x) rule2021 = ReplacementRule(pattern2021, replacement2021) pattern2022 = Pattern(Integral((x_*WC('h', S(1)) + WC('g', S(0)))**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*log(((x_*WC('f', S(1)) + WC('e', S(0)))**WC('p', S(1))*WC('d', S(1)))**WC('q', S(1))*WC('c', S(1))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons209, cons21, cons5, cons50, cons1160, cons66, cons87, cons89) def replacement2022(p, m, f, b, g, d, a, c, n, x, h, q, e): rubi.append(2022) return -Dist((m + S(1))/(b*p*q*(n + S(1))), Int((a + b*log(c*(d*(e + f*x)**p)**q))**(n + S(1))*(g + h*x)**m, x), x) + Simp((a + b*log(c*(d*(e + f*x)**p)**q))**(n + S(1))*(g + h*x)**(m + S(1))/(b*h*p*q*(n + S(1))), x) rule2022 = ReplacementRule(pattern2022, replacement2022) pattern2023 = Pattern(Integral((x_*WC('h', S(1)) + WC('g', S(0)))**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*log(((x_*WC('f', S(1)) + WC('e', S(0)))**WC('p', S(1))*WC('d', S(1)))**WC('q', S(1))*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons209, cons21, cons4, cons5, cons1160, cons66) def replacement2023(p, m, f, b, g, d, a, c, n, x, h, q, e): rubi.append(2023) return Simp((c*(d*(e + f*x)**p)**q)**(-(m + S(1))/(p*q))*(-(a + b*log(c*(d*(e + f*x)**p)**q))*(m + S(1))/(b*p*q))**(-n)*(a + b*log(c*(d*(e + f*x)**p)**q))**n*(g + h*x)**(m + S(1))*Gamma(n + S(1), -(a + b*log(c*(d*(e + f*x)**p)**q))*(m + S(1))/(b*p*q))*exp(-a*(m + S(1))/(b*p*q))/(h*(m + S(1))), x) rule2023 = ReplacementRule(pattern2023, replacement2023) pattern2024 = Pattern(Integral(log((x_*WC('f', S(1)) + WC('e', S(0)))*WC('c', S(1)))/(x_*WC('h', S(1)) + WC('g', S(0))), x_), cons7, cons48, cons125, cons208, cons209, cons1166) def replacement2024(f, g, c, x, h, e): rubi.append(2024) return -Simp(PolyLog(S(2), -(g + h*x)*Together(c*f/h))/h, x) rule2024 = ReplacementRule(pattern2024, replacement2024) pattern2025 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*log((x_*WC('f', S(1)) + WC('e', S(0)))*WC('c', S(1))))/(x_*WC('h', S(1)) + WC('g', S(0))), x_), cons2, cons3, cons7, cons48, cons125, cons208, cons209, cons1167, cons1168) def replacement2025(f, b, g, a, c, x, h, e): rubi.append(2025) return Dist(b, Int(log(-h*(e + f*x)/(-e*h + f*g))/(g + h*x), x), x) + Simp((a + b*log(c*(e - f*g/h)))*log(g + h*x)/h, x) rule2025 = ReplacementRule(pattern2025, replacement2025) pattern2026 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*log(((x_*WC('f', S(1)) + WC('e', S(0)))**WC('p', S(1))*WC('d', S(1)))**WC('q', S(1))*WC('c', S(1))))**WC('n', S(1))/(x_*WC('h', S(1)) + WC('g', S(0))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons209, cons5, cons50, cons1169, cons148) def replacement2026(p, f, b, g, d, a, c, n, x, h, q, e): rubi.append(2026) return -Dist(b*f*n*p*q/h, Int((a + b*log(c*(d*(e + f*x)**p)**q))**(n + S(-1))*log(f*(g + h*x)/(-e*h + f*g))/(e + f*x), x), x) + Simp((a + b*log(c*(d*(e + f*x)**p)**q))**n*log(f*(g + h*x)/(-e*h + f*g))/h, x) rule2026 = ReplacementRule(pattern2026, replacement2026) pattern2027 = Pattern(Integral((x_*WC('h', S(1)) + WC('g', S(0)))**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*log(((x_*WC('f', S(1)) + WC('e', S(0)))**WC('p', S(1))*WC('d', S(1)))**WC('q', S(1))*WC('c', S(1)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons209, cons21, cons5, cons50, cons1169, cons66) def replacement2027(p, m, f, b, g, d, a, c, x, h, q, e): rubi.append(2027) return -Dist(b*f*p*q/(h*(m + S(1))), Int((g + h*x)**(m + S(1))/(e + f*x), x), x) + Simp((a + b*log(c*(d*(e + f*x)**p)**q))*(g + h*x)**(m + S(1))/(h*(m + S(1))), x) rule2027 = ReplacementRule(pattern2027, replacement2027) pattern2028 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*log(((x_*WC('f', S(1)) + WC('e', S(0)))**WC('p', S(1))*WC('d', S(1)))**WC('q', S(1))*WC('c', S(1))))**n_/(x_*WC('h', S(1)) + WC('g', S(0)))**S(2), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons209, cons5, cons50, cons1169, cons87, cons88) def replacement2028(p, f, b, g, d, a, c, n, x, h, q, e): rubi.append(2028) return -Dist(b*f*n*p*q/(-e*h + f*g), Int((a + b*log(c*(d*(e + f*x)**p)**q))**(n + S(-1))/(g + h*x), x), x) + Simp((a + b*log(c*(d*(e + f*x)**p)**q))**n*(e + f*x)/((g + h*x)*(-e*h + f*g)), x) rule2028 = ReplacementRule(pattern2028, replacement2028) pattern2029 = Pattern(Integral((x_*WC('h', S(1)) + WC('g', S(0)))**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*log(((x_*WC('f', S(1)) + WC('e', S(0)))**WC('p', S(1))*WC('d', S(1)))**WC('q', S(1))*WC('c', S(1))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons209, cons21, cons5, cons50, cons1169, cons87, cons88, cons66, cons1170, cons1171) def replacement2029(p, m, f, b, g, d, a, c, n, x, h, q, e): rubi.append(2029) return -Dist(b*f*n*p*q/(h*(m + S(1))), Int((a + b*log(c*(d*(e + f*x)**p)**q))**(n + S(-1))*(g + h*x)**(m + S(1))/(e + f*x), x), x) + Simp((a + b*log(c*(d*(e + f*x)**p)**q))**n*(g + h*x)**(m + S(1))/(h*(m + S(1))), x) rule2029 = ReplacementRule(pattern2029, replacement2029) pattern2030 = Pattern(Integral((x_*WC('h', S(1)) + WC('g', S(0)))**WC('m', S(1))/(WC('a', S(0)) + WC('b', S(1))*log(((x_*WC('f', S(1)) + WC('e', S(0)))**WC('p', S(1))*WC('d', S(1)))**WC('q', S(1))*WC('c', S(1)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons209, cons5, cons50, cons1169, cons62) def replacement2030(p, m, f, b, g, d, a, c, x, h, q, e): rubi.append(2030) return Int(ExpandIntegrand((g + h*x)**m/(a + b*log(c*(d*(e + f*x)**p)**q)), x), x) rule2030 = ReplacementRule(pattern2030, replacement2030) pattern2031 = Pattern(Integral((x_*WC('h', S(1)) + WC('g', S(0)))**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*log(((x_*WC('f', S(1)) + WC('e', S(0)))**WC('p', S(1))*WC('d', S(1)))**WC('q', S(1))*WC('c', S(1))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons209, cons5, cons50, cons1169, cons93, cons89, cons168) def replacement2031(p, m, f, b, g, d, a, c, n, x, h, q, e): rubi.append(2031) return -Dist((m + S(1))/(b*p*q*(n + S(1))), Int((a + b*log(c*(d*(e + f*x)**p)**q))**(n + S(1))*(g + h*x)**m, x), x) + Dist(m*(-e*h + f*g)/(b*f*p*q*(n + S(1))), Int((a + b*log(c*(d*(e + f*x)**p)**q))**(n + S(1))*(g + h*x)**(m + S(-1)), x), x) + Simp((a + b*log(c*(d*(e + f*x)**p)**q))**(n + S(1))*(e + f*x)*(g + h*x)**m/(b*f*p*q*(n + S(1))), x) rule2031 = ReplacementRule(pattern2031, replacement2031) pattern2032 = Pattern(Integral((x_*WC('h', S(1)) + WC('g', S(0)))**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*log(((x_*WC('f', S(1)) + WC('e', S(0)))**WC('p', S(1))*WC('d', S(1)))**WC('q', S(1))*WC('c', S(1))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons209, cons4, cons5, cons50, cons1169, cons62) def replacement2032(p, m, f, b, g, d, a, c, n, x, h, q, e): rubi.append(2032) return Int(ExpandIntegrand((a + b*log(c*(d*(e + f*x)**p)**q))**n*(g + h*x)**m, x), x) rule2032 = ReplacementRule(pattern2032, replacement2032) pattern2033 = Pattern(Integral(u_**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*log((v_**p_*WC('d', S(1)))**WC('q', S(1))*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons21, cons4, cons5, cons50, cons810, cons811) def replacement2033(v, p, u, m, b, d, a, c, n, x, q): rubi.append(2033) return Int((a + b*log(c*(d*ExpandToSum(v, x)**p)**q))**n*ExpandToSum(u, x)**m, x) rule2033 = ReplacementRule(pattern2033, replacement2033) pattern2034 = Pattern(Integral((x_*WC('h', S(1)) + WC('g', S(0)))**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*log(((x_*WC('f', S(1)) + WC('e', S(0)))**WC('p', S(1))*WC('d', S(1)))**WC('q', S(1))*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons209, cons21, cons4, cons5, cons50, cons222) def replacement2034(p, m, f, b, g, d, a, c, n, x, h, q, e): rubi.append(2034) return Int((a + b*log(c*(d*(e + f*x)**p)**q))**n*(g + h*x)**m, x) rule2034 = ReplacementRule(pattern2034, replacement2034) pattern2035 = Pattern(Integral(log(WC('c', S(1))/(x_*WC('f', S(1)) + WC('e', S(0))))/((x_*WC('h', S(1)) + WC('g', S(0)))*(x_*WC('j', S(1)) + WC('i', S(0)))), x_), cons7, cons48, cons125, cons208, cons209, cons224, cons796, cons1160, cons1172) def replacement2035(j, f, g, i, c, x, h, e): rubi.append(2035) return Simp(f*PolyLog(S(2), f*(i + j*x)/(j*(e + f*x)))/(h*(-e*j + f*i)), x) rule2035 = ReplacementRule(pattern2035, replacement2035) pattern2036 = Pattern(Integral((a_ + WC('b', S(1))*log(WC('c', S(1))/(x_*WC('f', S(1)) + WC('e', S(0)))))/((x_*WC('h', S(1)) + WC('g', S(0)))*(x_*WC('j', S(1)) + WC('i', S(0)))), x_), cons2, cons3, cons7, cons48, cons125, cons208, cons209, cons224, cons796, cons1160, cons1172) def replacement2036(j, f, b, g, i, c, a, x, h, e): rubi.append(2036) return Dist(a, Int(S(1)/((g + h*x)*(i + j*x)), x), x) + Dist(b, Int(log(c/(e + f*x))/((g + h*x)*(i + j*x)), x), x) rule2036 = ReplacementRule(pattern2036, replacement2036) def With2037(p, j, m, f, b, g, i, d, a, c, x, h, q, e): u = IntHide((i + j*x)**m/(g + h*x), x) rubi.append(2037) return -Dist(b*h*p*q, Int(SimplifyIntegrand(u/(g + h*x), x), x), x) + Dist(a + b*log(c*(d*(e + f*x)**p)**q), u, x) pattern2037 = Pattern(Integral((x_*WC('j', S(1)) + WC('i', S(0)))**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*log(((x_*WC('f', S(1)) + WC('e', S(0)))**WC('p', S(1))*WC('d', S(1)))**WC('q', S(1))*WC('c', S(1))))/(x_*WC('h', S(1)) + WC('g', S(0))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons209, cons224, cons796, cons5, cons50, cons1160, cons79) rule2037 = ReplacementRule(pattern2037, With2037) pattern2038 = Pattern(Integral((x_*WC('j', S(1)) + WC('i', S(0)))**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*log((x_*WC('f', S(1)) + WC('e', S(0)))*WC('c', S(1))))**WC('n', S(1))/(x_*WC('h', S(1)) + WC('g', S(0))), x_), cons2, cons3, cons7, cons48, cons125, cons208, cons209, cons224, cons796, cons4, cons1160, cons62, cons1173) def replacement2038(j, m, f, b, g, i, a, c, n, x, h, e): rubi.append(2038) return Dist(c**(-m)*f**(-m)/h, Subst(Int((a + b*x)**n*(-c*e*j + c*f*i + j*exp(x))**m, x), x, log(c*(e + f*x))), x) rule2038 = ReplacementRule(pattern2038, replacement2038) def With2039(p, j, m, f, b, g, i, d, a, c, n, x, h, q, e): if isinstance(x, (int, Integer, float, Float)): return False u = ExpandIntegrand((a + b*log(c*(d*(e + f*x)**p)**q))**n, (i + j*x)**m/(g + h*x), x) if SumQ(u): return True return False pattern2039 = Pattern(Integral((x_*WC('j', S(1)) + WC('i', S(0)))**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*log(((x_*WC('f', S(1)) + WC('e', S(0)))**WC('p', S(1))*WC('d', S(1)))**WC('q', S(1))*WC('c', S(1))))**WC('n', S(1))/(x_*WC('h', S(1)) + WC('g', S(0))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons209, cons224, cons796, cons5, cons50, cons17, cons148, CustomConstraint(With2039)) def replacement2039(p, j, m, f, b, g, i, d, a, c, n, x, h, q, e): u = ExpandIntegrand((a + b*log(c*(d*(e + f*x)**p)**q))**n, (i + j*x)**m/(g + h*x), x) rubi.append(2039) return Int(u, x) rule2039 = ReplacementRule(pattern2039, replacement2039) pattern2040 = Pattern(Integral((x_*WC('j', S(1)) + WC('i', S(0)))**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*log(((x_*WC('f', S(1)) + WC('e', S(0)))**WC('p', S(1))*WC('d', S(1)))**WC('q', S(1))*WC('c', S(1))))**WC('n', S(1))/(x_*WC('h', S(1)) + WC('g', S(0))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons209, cons224, cons796, cons21, cons4, cons5, cons50, cons1174) def replacement2040(p, j, m, f, b, g, i, d, a, c, n, x, h, q, e): rubi.append(2040) return Int((a + b*log(c*(d*(e + f*x)**p)**q))**n*(i + j*x)**m/(g + h*x), x) rule2040 = ReplacementRule(pattern2040, replacement2040) pattern2041 = Pattern(Integral(log(WC('c', S(1))/(x_*WC('f', S(1)) + WC('e', S(0))))/(g_ + x_**S(2)*WC('h', S(1))), x_), cons7, cons48, cons125, cons208, cons209, cons1175, cons1176) def replacement2041(f, g, c, x, h, e): rubi.append(2041) return -Simp(f*PolyLog(S(2), (-e + f*x)/(e + f*x))/(S(2)*e*h), x) rule2041 = ReplacementRule(pattern2041, replacement2041) pattern2042 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*log(WC('c', S(1))/(x_*WC('f', S(1)) + WC('e', S(0)))))/(g_ + x_**S(2)*WC('h', S(1))), x_), cons7, cons48, cons125, cons208, cons209, cons1175, cons1177, cons1178) def replacement2042(f, b, g, a, c, x, h, e): rubi.append(2042) return Dist(b, Int(log(S(2)*e/(e + f*x))/(g + h*x**S(2)), x), x) + Dist(a + b*log(c/(S(2)*e)), Int(S(1)/(g + h*x**S(2)), x), x) rule2042 = ReplacementRule(pattern2042, replacement2042) pattern2043 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*log(((x_*WC('f', S(1)) + WC('e', S(0)))**WC('p', S(1))*WC('d', S(1)))**WC('q', S(1))*WC('c', S(1))))/(x_**S(2)*WC('i', S(1)) + x_*WC('h', S(1)) + WC('g', S(0))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons209, cons224, cons5, cons50, cons1179) def replacement2043(p, f, b, g, i, d, a, c, x, h, q, e): rubi.append(2043) return Dist(e*f, Int((a + b*log(c*(d*(e + f*x)**p)**q))/((e + f*x)*(e*i*x + f*g)), x), x) rule2043 = ReplacementRule(pattern2043, replacement2043) pattern2044 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*log(((e_ + x_*WC('f', S(1)))**WC('p', S(1))*WC('d', S(1)))**WC('q', S(1))*WC('c', S(1))))/(g_ + x_**S(2)*WC('i', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons224, cons5, cons50, cons1180) def replacement2044(p, f, b, g, i, d, a, c, x, q, e): rubi.append(2044) return Dist(e*f, Int((a + b*log(c*(d*(e + f*x)**p)**q))/((e + f*x)*(e*i*x + f*g)), x), x) rule2044 = ReplacementRule(pattern2044, replacement2044) def With2045(p, f, b, g, d, a, c, x, h, q, e): u = IntHide(S(1)/sqrt(g + h*x**S(2)), x) rubi.append(2045) return -Dist(b*f*p*q, Int(SimplifyIntegrand(u/(e + f*x), x), x), x) + Simp(u*(a + b*log(c*(d*(e + f*x)**p)**q)), x) pattern2045 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*log(((x_*WC('f', S(1)) + WC('e', S(0)))**WC('p', S(1))*WC('d', S(1)))**WC('q', S(1))*WC('c', S(1))))/sqrt(g_ + x_**S(2)*WC('h', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons209, cons5, cons50, cons1181) rule2045 = ReplacementRule(pattern2045, With2045) def With2046(p, f, b, d, h1, a, c, h2, g2, x, g1, q, e): u = IntHide(S(1)/sqrt(g1*g2 + h1*h2*x**S(2)), x) rubi.append(2046) return -Dist(b*f*p*q, Int(SimplifyIntegrand(u/(e + f*x), x), x), x) + Simp(u*(a + b*log(c*(d*(e + f*x)**p)**q)), x) pattern2046 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*log(((x_*WC('f', S(1)) + WC('e', S(0)))**WC('p', S(1))*WC('d', S(1)))**WC('q', S(1))*WC('c', S(1))))/(sqrt(g1_ + x_*WC('h1', S(1)))*sqrt(g2_ + x_*WC('h2', S(1)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons1185, cons1186, cons1187, cons1188, cons5, cons50, cons1182, cons1183, cons1184) rule2046 = ReplacementRule(pattern2046, With2046) pattern2047 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*log(((x_*WC('f', S(1)) + WC('e', S(0)))**WC('p', S(1))*WC('d', S(1)))**WC('q', S(1))*WC('c', S(1))))/sqrt(g_ + x_**S(2)*WC('h', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons209, cons5, cons50, cons1189) def replacement2047(p, f, b, g, d, a, c, x, h, q, e): rubi.append(2047) return Dist(sqrt(S(1) + h*x**S(2)/g)/sqrt(g + h*x**S(2)), Int((a + b*log(c*(d*(e + f*x)**p)**q))/sqrt(S(1) + h*x**S(2)/g), x), x) rule2047 = ReplacementRule(pattern2047, replacement2047) pattern2048 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*log(((x_*WC('f', S(1)) + WC('e', S(0)))**WC('p', S(1))*WC('d', S(1)))**WC('q', S(1))*WC('c', S(1))))/(sqrt(g1_ + x_*WC('h1', S(1)))*sqrt(g2_ + x_*WC('h2', S(1)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons1185, cons1186, cons1187, cons1188, cons5, cons50, cons1182) def replacement2048(p, f, b, d, h1, a, c, h2, g2, x, g1, q, e): rubi.append(2048) return Dist(sqrt(S(1) + h1*h2*x**S(2)/(g1*g2))/(sqrt(g1 + h1*x)*sqrt(g2 + h2*x)), Int((a + b*log(c*(d*(e + f*x)**p)**q))/sqrt(S(1) + h1*h2*x**S(2)/(g1*g2)), x), x) rule2048 = ReplacementRule(pattern2048, replacement2048) pattern2049 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*log(((x_*WC('f', S(1)) + WC('e', S(0)))**WC('p', S(1))*WC('d', S(1)))**WC('q', S(1))*WC('c', S(1))))**WC('n', S(1))*log((x_*WC('k', S(1)) + WC('j', S(0)))*WC('i', S(1)))/(x_*WC('h', S(1)) + WC('g', S(0))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons209, cons224, cons796, cons797, cons5, cons50, cons87, cons88, cons1190) def replacement2049(p, j, k, f, b, g, i, d, a, c, n, x, h, q, e): rubi.append(2049) return Dist(b*f*n*p*q/h, Int((a + b*log(c*(d*(e + f*x)**p)**q))**(n + S(-1))*PolyLog(S(2), Together(-i*(j + k*x) + S(1)))/(e + f*x), x), x) - Simp((a + b*log(c*(d*(e + f*x)**p)**q))**n*PolyLog(S(2), Together(-i*(j + k*x) + S(1)))/h, x) rule2049 = ReplacementRule(pattern2049, replacement2049) pattern2050 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*log(((x_*WC('f', S(1)) + WC('e', S(0)))**WC('p', S(1))*WC('d', S(1)))**WC('q', S(1))*WC('c', S(1))))**WC('n', S(1))*log((x_*WC('k', S(1)) + WC('j', S(0)))**WC('m', S(1))*WC('i', S(1)) + S(1))/(x_*WC('h', S(1)) + WC('g', S(0))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons209, cons224, cons796, cons797, cons21, cons5, cons50, cons87, cons88, cons1191) def replacement2050(p, j, k, m, f, b, g, i, d, a, c, n, x, h, q, e): rubi.append(2050) return Dist(b*f*n*p*q/(h*m), Int((a + b*log(c*(d*(e + f*x)**p)**q))**(n + S(-1))*PolyLog(S(2), -i*(j + k*x)**m)/(e + f*x), x), x) - Simp((a + b*log(c*(d*(e + f*x)**p)**q))**n*PolyLog(S(2), -i*(j + k*x)**m)/(h*m), x) rule2050 = ReplacementRule(pattern2050, replacement2050) pattern2051 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*log(((x_*WC('f', S(1)) + WC('e', S(0)))**WC('p', S(1))*WC('d', S(1)))**WC('q', S(1))*WC('c', S(1))))**WC('n', S(1))*PolyLog(r_, (x_*WC('k', S(1)) + WC('j', S(0)))**WC('m', S(1))*WC('i', S(1)))/(x_*WC('h', S(1)) + WC('g', S(0))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons209, cons224, cons796, cons797, cons21, cons5, cons50, cons52, cons87, cons88, cons1191) def replacement2051(p, j, k, m, f, b, g, r, i, d, a, c, n, x, h, q, e): rubi.append(2051) return -Dist(b*f*n*p*q/(h*m), Int((a + b*log(c*(d*(e + f*x)**p)**q))**(n + S(-1))*PolyLog(r + S(1), i*(j + k*x)**m)/(e + f*x), x), x) + Simp((a + b*log(c*(d*(e + f*x)**p)**q))**n*PolyLog(r + S(1), i*(j + k*x)**m)/(h*m), x) rule2051 = ReplacementRule(pattern2051, replacement2051) def With2052(p, m, f, b, g, Px, d, a, c, x, h, q, e, F): u = IntHide(Px*F(g + h*x)**m, x) rubi.append(2052) return -Dist(b*f*p*q, Int(SimplifyIntegrand(u/(e + f*x), x), x), x) + Dist(a + b*log(c*(d*(e + f*x)**p)**q), u, x) pattern2052 = Pattern(Integral(F_**(x_*WC('h', S(1)) + WC('g', S(0)))*(WC('a', S(0)) + WC('b', S(1))*log(((x_*WC('f', S(1)) + WC('e', S(0)))**WC('p', S(1))*WC('d', S(1)))**WC('q', S(1))*WC('c', S(1))))*WC('Px', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons209, cons5, cons50, cons925, cons62, cons1192) rule2052 = ReplacementRule(pattern2052, With2052) pattern2053 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*log(((e_ + x_**m_*WC('f', S(1)))**WC('p', S(1))*WC('d', S(1)))**WC('q', S(1))*WC('c', S(1))))**WC('n', S(1))/x_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons4, cons5, cons50, cons148) def replacement2053(p, m, f, b, d, a, c, n, x, q, e): rubi.append(2053) return Dist(S(1)/m, Subst(Int((a + b*log(c*(d*(e + f*x)**p)**q))**n/x, x), x, x**m), x) rule2053 = ReplacementRule(pattern2053, replacement2053) pattern2054 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*log(((x_**m_*(f_ + x_**WC('r', S(1))*WC('e', S(1))))**WC('p', S(1))*WC('d', S(1)))**WC('q', S(1))*WC('c', S(1))))**WC('n', S(1))/x_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons4, cons5, cons50, cons1193, cons148) def replacement2054(p, m, f, b, r, d, a, c, n, x, q, e): rubi.append(2054) return Dist(S(1)/m, Subst(Int((a + b*log(c*(d*(e + f*x)**p)**q))**n/x, x), x, x**m), x) rule2054 = ReplacementRule(pattern2054, replacement2054) pattern2055 = Pattern(Integral(x_**WC('r1', S(1))*(WC('a', S(0)) + WC('b', S(1))*log(((x_**r_*WC('f', S(1)) + WC('e', S(0)))**WC('p', S(1))*WC('d', S(1)))**WC('q', S(1))*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons4, cons5, cons50, cons52, cons1194) def replacement2055(p, r1, f, b, r, d, a, c, n, x, q, e): rubi.append(2055) return Dist(S(1)/r, Subst(Int((a + b*log(c*(d*(e + f*x)**p)**q))**n, x), x, x**r), x) rule2055 = ReplacementRule(pattern2055, replacement2055) pattern2056 = Pattern(Integral(x_**WC('r1', S(1))*(x_**r_*WC('h', S(1)) + WC('g', S(0)))**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*log(((x_**r_*WC('f', S(1)) + WC('e', S(0)))**WC('p', S(1))*WC('d', S(1)))**WC('q', S(1))*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons209, cons21, cons4, cons5, cons50, cons52, cons1194) def replacement2056(p, r1, m, f, b, g, r, d, a, c, n, x, h, q, e): rubi.append(2056) return Dist(S(1)/r, Subst(Int((a + b*log(c*(d*(e + f*x)**p)**q))**n*(g + h*x)**m, x), x, x**r), x) rule2056 = ReplacementRule(pattern2056, replacement2056) def With2057(b, d, a, n, c, x, e): u = IntHide(S(1)/(d + e*x**S(2)), x) rubi.append(2057) return -Dist(b*n, Int(u/x, x), x) + Dist(a + b*log(c*x**n), u, x) pattern2057 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*log(x_**WC('n', S(1))*WC('c', S(1))))/(d_ + x_**S(2)*WC('e', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons4, cons1195) rule2057 = ReplacementRule(pattern2057, With2057) pattern2058 = Pattern(Integral(log((x_**mn_*WC('b', S(1)) + WC('a', S(0)))*WC('c', S(1)))/(x_*(d_ + x_**WC('n', S(1))*WC('e', S(1)))), x_), cons2, cons3, cons7, cons27, cons48, cons4, cons1196, cons1197) def replacement2058(mn, b, d, c, n, a, x, e): rubi.append(2058) return Simp(PolyLog(S(2), -Together(b*c*x**(-n)*(d + e*x**n)/d))/(d*n), x) rule2058 = ReplacementRule(pattern2058, replacement2058) pattern2059 = Pattern(Integral(log(x_**mn_*(x_**WC('n', S(1))*WC('a', S(1)) + WC('b', S(0)))*WC('c', S(1)))/(x_*(d_ + x_**WC('n', S(1))*WC('e', S(1)))), x_), cons2, cons3, cons7, cons27, cons48, cons4, cons1196, cons1197) def replacement2059(mn, b, d, c, n, a, x, e): rubi.append(2059) return Simp(PolyLog(S(2), -Together(b*c*x**(-n)*(d + e*x**n)/d))/(d*n), x) rule2059 = ReplacementRule(pattern2059, replacement2059) pattern2060 = Pattern(Integral(Px_*(WC('a', S(0)) + WC('b', S(1))*log(((x_*WC('f', S(1)) + WC('e', S(0)))**WC('p', S(1))*WC('d', S(1)))**WC('q', S(1))*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons4, cons5, cons50, cons925) def replacement2060(p, f, b, Px, d, a, c, n, x, q, e): rubi.append(2060) return Int(ExpandIntegrand(Px*(a + b*log(c*(d*(e + f*x)**p)**q))**n, x), x) rule2060 = ReplacementRule(pattern2060, replacement2060) def With2061(p, RFx, f, b, d, a, c, n, x, q, e): if isinstance(x, (int, Integer, float, Float)): return False u = ExpandIntegrand((a + b*log(c*(d*(e + f*x)**p)**q))**n, RFx, x) if SumQ(u): return True return False pattern2061 = Pattern(Integral(RFx_*(WC('a', S(0)) + WC('b', S(1))*log(((x_*WC('f', S(1)) + WC('e', S(0)))**WC('p', S(1))*WC('d', S(1)))**WC('q', S(1))*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons5, cons50, cons1198, cons148, CustomConstraint(With2061)) def replacement2061(p, RFx, f, b, d, a, c, n, x, q, e): u = ExpandIntegrand((a + b*log(c*(d*(e + f*x)**p)**q))**n, RFx, x) rubi.append(2061) return Int(u, x) rule2061 = ReplacementRule(pattern2061, replacement2061) def With2062(p, RFx, f, b, d, a, c, n, x, q, e): if isinstance(x, (int, Integer, float, Float)): return False u = ExpandIntegrand(RFx*(a + b*log(c*(d*(e + f*x)**p)**q))**n, x) if SumQ(u): return True return False pattern2062 = Pattern(Integral(RFx_*(WC('a', S(0)) + WC('b', S(1))*log(((x_*WC('f', S(1)) + WC('e', S(0)))**WC('p', S(1))*WC('d', S(1)))**WC('q', S(1))*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons5, cons50, cons1198, cons148, CustomConstraint(With2062)) def replacement2062(p, RFx, f, b, d, a, c, n, x, q, e): u = ExpandIntegrand(RFx*(a + b*log(c*(d*(e + f*x)**p)**q))**n, x) rubi.append(2062) return Int(u, x) rule2062 = ReplacementRule(pattern2062, replacement2062) pattern2063 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*log(((x_**S(2)*WC('g', S(1)) + x_*WC('f', S(1)) + WC('e', S(0)))**WC('p', S(1))*WC('d', S(1)))**WC('q', S(1))*WC('c', S(1))))**WC('n', S(1))*WC('u', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons50, cons4, cons1199, cons38) def replacement2063(p, u, f, g, b, d, a, c, n, x, q, e): rubi.append(2063) return Int(u*(a + b*log(c*(S(4)**(-p)*d*g**(-p)*(f + S(2)*g*x)**(S(2)*p))**q))**n, x) rule2063 = ReplacementRule(pattern2063, replacement2063) pattern2064 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*log((v_**WC('p', S(1))*WC('d', S(1)))**WC('q', S(1))*WC('c', S(1))))**WC('n', S(1))*WC('u', S(1)), x_), cons2, cons3, cons7, cons27, cons4, cons5, cons50, cons552, cons1200) def replacement2064(v, p, u, b, d, a, c, n, x, q): rubi.append(2064) return Int(u*(a + b*log(c*(d*ExpandToSum(v, x)**p)**q))**n, x) rule2064 = ReplacementRule(pattern2064, replacement2064) pattern2065 = Pattern(Integral(log(((x_**WC('n', S(1))*WC('c', S(1)))**p_*WC('b', S(1)))**q_*WC('a', S(1)))**WC('r', S(1)), x_), cons2, cons3, cons7, cons4, cons5, cons50, cons52, cons1201) def replacement2065(p, b, r, c, a, n, x, q): rubi.append(2065) return Subst(Int(log(x**(n*p*q))**r, x), x**(n*p*q), a*(b*(c*x**n)**p)**q) rule2065 = ReplacementRule(pattern2065, replacement2065) pattern2066 = Pattern(Integral(x_**WC('m', S(1))*log(((x_**WC('n', S(1))*WC('c', S(1)))**p_*WC('b', S(1)))**q_*WC('a', S(1)))**WC('r', S(1)), x_), cons2, cons3, cons7, cons21, cons4, cons5, cons50, cons52, cons66, cons1202) def replacement2066(p, m, b, r, c, a, n, x, q): rubi.append(2066) return Subst(Int(x**m*log(x**(n*p*q))**r, x), x**(n*p*q), a*(b*(c*x**n)**p)**q) rule2066 = ReplacementRule(pattern2066, replacement2066) pattern2067 = Pattern(Integral(WC('u', S(1))*log(((x_*WC('b', S(1)) + WC('a', S(0)))*WC('e1', S(1))/(x_*WC('d', S(1)) + WC('c', S(0))))**WC('n', S(1))*WC('e', S(1)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons4, cons5, cons652, cons25) def replacement2067(p, u, b, d, c, a, n, e1, x, e): rubi.append(2067) return Dist(log(e*(b*e1/d)**n)**p, Int(u, x), x) rule2067 = ReplacementRule(pattern2067, replacement2067) pattern2068 = Pattern(Integral(log(((x_*WC('b', S(1)) + WC('a', S(0)))**WC('n1', S(1))*(x_*WC('d', S(1)) + WC('c', S(0)))**n2_*WC('e1', S(1)))**WC('n', S(1))*WC('e', S(1)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons4, cons652, cons1204, cons1203, cons71, cons128) def replacement2068(p, n1, b, n2, d, a, c, n, e1, x, e): rubi.append(2068) return -Dist(n*n1*p*(-a*d + b*c)/b, Int(log(e*(e1*(a + b*x)**n1*(c + d*x)**(-n1))**n)**(p + S(-1))/(c + d*x), x), x) + Simp((a + b*x)*log(e*(e1*(a + b*x)**n1*(c + d*x)**(-n1))**n)**p/b, x) rule2068 = ReplacementRule(pattern2068, replacement2068) pattern2069 = Pattern(Integral(log((x_*WC('b', S(1)) + WC('a', S(0)))*WC('e', S(1))/(x_*WC('d', S(1)) + WC('c', S(0))))/(x_*WC('g', S(1)) + WC('f', S(0))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons71, cons1205, cons1206) def replacement2069(f, b, g, d, c, a, x, e): rubi.append(2069) return Simp(PolyLog(S(2), Together(-a*e + c)/(c + d*x))/g, x) rule2069 = ReplacementRule(pattern2069, replacement2069) pattern2070 = Pattern(Integral(log(((x_*WC('b', S(1)) + WC('a', S(0)))**WC('n1', S(1))*(x_*WC('d', S(1)) + WC('c', S(0)))**n2_*WC('e1', S(1)))**WC('n', S(1))*WC('e', S(1)))**WC('p', S(1))/(x_*WC('g', S(1)) + WC('f', S(0))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons4, cons652, cons1204, cons1203, cons71, cons1205, cons128) def replacement2070(p, n1, b, f, g, n2, d, a, c, n, e1, x, e): rubi.append(2070) return Dist(n*n1*p*(-a*d + b*c)/g, Int(log(e*(e1*(a + b*x)**n1*(c + d*x)**(-n1))**n)**(p + S(-1))*log((-a*d + b*c)/(b*(c + d*x)))/((a + b*x)*(c + d*x)), x), x) - Simp(log(e*(e1*(a + b*x)**n1*(c + d*x)**(-n1))**n)**p*log((-a*d + b*c)/(b*(c + d*x)))/g, x) rule2070 = ReplacementRule(pattern2070, replacement2070) pattern2071 = Pattern(Integral(log(((x_*WC('b', S(1)) + WC('a', S(0)))**WC('n1', S(1))*(x_*WC('d', S(1)) + WC('c', S(0)))**n2_*WC('e1', S(1)))**WC('n', S(1))*WC('e', S(1)))**WC('p', S(1))/(x_*WC('g', S(1)) + WC('f', S(0))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons4, cons652, cons1204, cons1203, cons71, cons1207, cons128) def replacement2071(p, n1, b, f, g, n2, d, a, c, n, e1, x, e): rubi.append(2071) return Dist(n*n1*p*(-a*d + b*c)/g, Int(log(e*(e1*(a + b*x)**n1*(c + d*x)**(-n1))**n)**(p + S(-1))*log(-(-a*d + b*c)/(d*(a + b*x)))/((a + b*x)*(c + d*x)), x), x) - Simp(log(e*(e1*(a + b*x)**n1*(c + d*x)**(-n1))**n)**p*log(-(-a*d + b*c)/(d*(a + b*x)))/g, x) rule2071 = ReplacementRule(pattern2071, replacement2071) pattern2072 = Pattern(Integral(log(((x_*WC('b', S(1)) + WC('a', S(0)))**WC('n1', S(1))*(x_*WC('d', S(1)) + WC('c', S(0)))**n2_*WC('e1', S(1)))**WC('n', S(1))*WC('e', S(1)))/(x_*WC('g', S(1)) + WC('f', S(0))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons4, cons652, cons1204, cons1203, cons71, cons1208) def replacement2072(n1, b, f, g, n2, d, a, c, n, e1, x, e): rubi.append(2072) return -Dist(n*n1*(-a*d + b*c)/g, Int(log(f + g*x)/((a + b*x)*(c + d*x)), x), x) + Simp(log(e*(e1*(a + b*x)**n1*(c + d*x)**(-n1))**n)*log(f + g*x)/g, x) rule2072 = ReplacementRule(pattern2072, replacement2072) pattern2073 = Pattern(Integral(log(((x_*WC('b', S(1)) + WC('a', S(0)))**WC('n1', S(1))*(x_*WC('d', S(1)) + WC('c', S(0)))**n2_*WC('e1', S(1)))**WC('n', S(1))*WC('e', S(1)))**p_/(x_*WC('g', S(1)) + WC('f', S(0))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons4, cons652, cons1204, cons1203, cons71, cons1208, cons38, cons146) def replacement2073(p, n1, b, f, g, n2, d, a, c, n, e1, x, e): rubi.append(2073) return Dist(d/g, Int(log(e*(e1*(a + b*x)**n1*(c + d*x)**(-n1))**n)**p/(c + d*x), x), x) - Dist((-c*g + d*f)/g, Int(log(e*(e1*(a + b*x)**n1*(c + d*x)**(-n1))**n)**p/((c + d*x)*(f + g*x)), x), x) rule2073 = ReplacementRule(pattern2073, replacement2073) pattern2074 = Pattern(Integral(S(1)/((x_*WC('g', S(1)) + WC('f', S(0)))**S(2)*log((x_*WC('b', S(1)) + WC('a', S(0)))*WC('e', S(1))/(x_*WC('d', S(1)) + WC('c', S(0))))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons71, cons1205) def replacement2074(f, b, g, d, c, a, x, e): rubi.append(2074) return Simp(d**S(2)*LogIntegral(e*(a + b*x)/(c + d*x))/(e*g**S(2)*(-a*d + b*c)), x) rule2074 = ReplacementRule(pattern2074, replacement2074) pattern2075 = Pattern(Integral(S(1)/((x_*WC('g', S(1)) + WC('f', S(0)))**S(2)*log(((x_*WC('b', S(1)) + WC('a', S(0)))**WC('n1', S(1))*(x_*WC('d', S(1)) + WC('c', S(0)))**n2_*WC('e1', S(1)))**WC('n', S(1))*WC('e', S(1)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons4, cons652, cons1204, cons1203, cons71, cons1205) def replacement2075(n1, b, f, g, n2, d, a, c, n, e1, x, e): rubi.append(2075) return Simp(d**S(2)*(e*(e1*(a + b*x)**n1*(c + d*x)**n2)**n)**(-S(1)/(n*n1))*(a + b*x)*ExpIntegralEi(log(e*(e1*(a + b*x)**n1*(c + d*x)**(-n1))**n)/(n*n1))/(g**S(2)*n*n1*(c + d*x)*(-a*d + b*c)), x) rule2075 = ReplacementRule(pattern2075, replacement2075) pattern2076 = Pattern(Integral(S(1)/((x_*WC('g', S(1)) + WC('f', S(0)))**S(2)*log(((x_*WC('b', S(1)) + WC('a', S(0)))**WC('n1', S(1))*(x_*WC('d', S(1)) + WC('c', S(0)))**n2_*WC('e1', S(1)))**WC('n', S(1))*WC('e', S(1)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons4, cons652, cons1204, cons1203, cons71, cons1207) def replacement2076(n1, b, f, g, n2, d, a, c, n, e1, x, e): rubi.append(2076) return Simp(b**S(2)*(e*(e1*(a + b*x)**n1*(c + d*x)**n2)**n)**(S(1)/(n*n1))*(c + d*x)*ExpIntegralEi(-log(e*(e1*(a + b*x)**n1*(c + d*x)**(-n1))**n)/(n*n1))/(g**S(2)*n*n1*(a + b*x)*(-a*d + b*c)), x) rule2076 = ReplacementRule(pattern2076, replacement2076) pattern2077 = Pattern(Integral(log(((x_*WC('b', S(1)) + WC('a', S(0)))**WC('n1', S(1))*(x_*WC('d', S(1)) + WC('c', S(0)))**n2_*WC('e1', S(1)))**WC('n', S(1))*WC('e', S(1)))**WC('p', S(1))/(x_*WC('g', S(1)) + WC('f', S(0)))**S(2), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons4, cons652, cons1204, cons1203, cons71, cons1209, cons128) def replacement2077(p, n1, b, f, g, n2, d, a, c, n, e1, x, e): rubi.append(2077) return -Dist(n*n1*p*(-a*d + b*c)/(-a*g + b*f), Int(log(e*(e1*(a + b*x)**n1*(c + d*x)**(-n1))**n)**(p + S(-1))/((c + d*x)*(f + g*x)), x), x) + Simp((a + b*x)*log(e*(e1*(a + b*x)**n1*(c + d*x)**(-n1))**n)**p/((f + g*x)*(-a*g + b*f)), x) rule2077 = ReplacementRule(pattern2077, replacement2077) pattern2078 = Pattern(Integral(log(((x_*WC('b', S(1)) + WC('a', S(0)))**WC('n1', S(1))*(x_*WC('d', S(1)) + WC('c', S(0)))**n2_*WC('e1', S(1)))**WC('n', S(1))*WC('e', S(1)))**WC('p', S(1))/(x_*WC('g', S(1)) + WC('f', S(0)))**S(2), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons4, cons652, cons1204, cons1203, cons71, cons1208, cons128) def replacement2078(p, n1, b, f, g, n2, d, a, c, n, e1, x, e): rubi.append(2078) return -Dist(n*n1*p*(-a*d + b*c)/(-c*g + d*f), Int(log(e*(e1*(a + b*x)**n1*(c + d*x)**(-n1))**n)**(p + S(-1))/((a + b*x)*(f + g*x)), x), x) + Simp((c + d*x)*log(e*(e1*(a + b*x)**n1*(c + d*x)**(-n1))**n)**p/((f + g*x)*(-c*g + d*f)), x) rule2078 = ReplacementRule(pattern2078, replacement2078) pattern2079 = Pattern(Integral(log(((x_*WC('b', S(1)) + WC('a', S(0)))**WC('n1', S(1))*(x_*WC('d', S(1)) + WC('c', S(0)))**n2_*WC('e1', S(1)))**WC('n', S(1))*WC('e', S(1)))**p_/(x_*WC('g', S(1)) + WC('f', S(0)))**S(3), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons4, cons5, cons652, cons1204, cons1203, cons71, cons1209, cons1205) def replacement2079(p, n1, b, f, g, n2, d, a, c, n, e1, x, e): rubi.append(2079) return Dist(b/(-a*g + b*f), Int(log(e*(e1*(a + b*x)**n1*(c + d*x)**(-n1))**n)**p/(f + g*x)**S(2), x), x) - Dist(g/(-a*g + b*f), Int((a + b*x)*log(e*(e1*(a + b*x)**n1*(c + d*x)**(-n1))**n)**p/(f + g*x)**S(3), x), x) rule2079 = ReplacementRule(pattern2079, replacement2079) pattern2080 = Pattern(Integral(log(((x_*WC('b', S(1)) + WC('a', S(0)))**WC('n1', S(1))*(x_*WC('d', S(1)) + WC('c', S(0)))**n2_*WC('e1', S(1)))**WC('n', S(1))*WC('e', S(1)))**p_/(x_*WC('g', S(1)) + WC('f', S(0)))**S(3), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons4, cons5, cons652, cons1204, cons1203, cons71, cons1208, cons1207) def replacement2080(p, n1, b, f, g, n2, d, a, c, n, e1, x, e): rubi.append(2080) return Dist(d/(-c*g + d*f), Int(log(e*(e1*(a + b*x)**n1*(c + d*x)**(-n1))**n)**p/(f + g*x)**S(2), x), x) - Dist(g/(-c*g + d*f), Int((c + d*x)*log(e*(e1*(a + b*x)**n1*(c + d*x)**(-n1))**n)**p/(f + g*x)**S(3), x), x) rule2080 = ReplacementRule(pattern2080, replacement2080) pattern2081 = Pattern(Integral((x_*WC('g', S(1)) + WC('f', S(0)))**WC('m', S(1))*log(((x_*WC('b', S(1)) + WC('a', S(0)))**WC('n1', S(1))*(x_*WC('d', S(1)) + WC('c', S(0)))**n2_*WC('e1', S(1)))**WC('n', S(1))*WC('e', S(1)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons4, cons652, cons1204, cons1203, cons71, cons128, cons17, cons66) def replacement2081(p, m, n1, b, f, g, n2, d, a, c, n, e1, x, e): rubi.append(2081) return -Dist(n*n1*p*(-a*d + b*c)/(g*(m + S(1))), Int((f + g*x)**(m + S(1))*log(e*(e1*(a + b*x)**n1*(c + d*x)**(-n1))**n)**(p + S(-1))/((a + b*x)*(c + d*x)), x), x) + Simp((f + g*x)**(m + S(1))*log(e*(e1*(a + b*x)**n1*(c + d*x)**(-n1))**n)**p/(g*(m + S(1))), x) rule2081 = ReplacementRule(pattern2081, replacement2081) pattern2082 = Pattern(Integral((x_*WC('b', S(1)) + WC('a', S(0)))**WC('m', S(1))*(x_*WC('d', S(1)) + WC('c', S(0)))**WC('m2', S(1))*log(u_**n_*WC('e', S(1)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons4, cons1211, cons1210, cons71, cons66, cons13, cons163) def replacement2082(p, u, m2, m, b, d, a, c, n, x, e): rubi.append(2082) return -Dist(n*p/(m + S(1)), Int((a + b*x)**m*(c + d*x)**(-m + S(-2))*log(e*u**n)**(p + S(-1)), x), x) + Simp((a + b*x)**(m + S(1))*(c + d*x)**(-m + S(-1))*log(e*u**n)**p/((m + S(1))*(-a*d + b*c)), x) rule2082 = ReplacementRule(pattern2082, replacement2082) pattern2083 = Pattern(Integral((x_*WC('b', S(1)) + WC('a', S(0)))**WC('m', S(1))*(x_*WC('d', S(1)) + WC('c', S(0)))**WC('m2', S(1))*log(u_)**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons1211, cons1210, cons71, cons66, cons13, cons163) def replacement2083(p, u, m2, m, b, d, a, c, x): rubi.append(2083) return -Dist(p/(m + S(1)), Int((a + b*x)**m*(c + d*x)**(-m + S(-2))*log(u)**(p + S(-1)), x), x) + Simp((a + b*x)**(m + S(1))*(c + d*x)**(-m + S(-1))*log(u)**p/((m + S(1))*(-a*d + b*c)), x) rule2083 = ReplacementRule(pattern2083, replacement2083) pattern2084 = Pattern(Integral((x_*WC('b', S(1)) + WC('a', S(0)))**WC('m', S(1))*(x_*WC('d', S(1)) + WC('c', S(0)))**WC('m2', S(1))/log(u_**n_*WC('e', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons4, cons1211, cons1210, cons71, cons66) def replacement2084(u, m2, m, b, d, a, c, n, x, e): rubi.append(2084) return Simp((e*u**n)**(-(m + S(1))/n)*(a + b*x)**(m + S(1))*(c + d*x)**(-m + S(-1))*ExpIntegralEi((m + S(1))*log(e*u**n)/n)/(n*(-a*d + b*c)), x) rule2084 = ReplacementRule(pattern2084, replacement2084) pattern2085 = Pattern(Integral((x_*WC('b', S(1)) + WC('a', S(0)))**WC('m', S(1))*(x_*WC('d', S(1)) + WC('c', S(0)))**WC('m2', S(1))/log(u_), x_), cons2, cons3, cons7, cons27, cons1211, cons1210, cons71, cons66) def replacement2085(u, m2, m, b, d, a, c, x): rubi.append(2085) return Simp(u**(-m + S(-1))*(a + b*x)**(m + S(1))*(c + d*x)**(-m + S(-1))*ExpIntegralEi((m + S(1))*log(u))/(-a*d + b*c), x) rule2085 = ReplacementRule(pattern2085, replacement2085) pattern2086 = Pattern(Integral((x_*WC('b', S(1)) + WC('a', S(0)))**WC('m', S(1))*(x_*WC('d', S(1)) + WC('c', S(0)))**WC('m2', S(1))*log(u_**n_*WC('e', S(1)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons4, cons1211, cons1210, cons71, cons66, cons13, cons137) def replacement2086(p, u, m2, m, b, d, a, c, n, x, e): rubi.append(2086) return -Dist((m + S(1))/(n*(p + S(1))), Int((a + b*x)**m*(c + d*x)**(-m + S(-2))*log(e*u**n)**(p + S(1)), x), x) + Simp((a + b*x)**(m + S(1))*(c + d*x)**(-m + S(-1))*log(e*u**n)**(p + S(1))/(n*(p + S(1))*(-a*d + b*c)), x) rule2086 = ReplacementRule(pattern2086, replacement2086) pattern2087 = Pattern(Integral((x_*WC('b', S(1)) + WC('a', S(0)))**WC('m', S(1))*(x_*WC('d', S(1)) + WC('c', S(0)))**WC('m2', S(1))*log(u_)**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons1211, cons1210, cons71, cons66, cons13, cons137) def replacement2087(p, u, m2, m, b, d, a, c, x): rubi.append(2087) return -Dist((m + S(1))/(p + S(1)), Int((a + b*x)**m*(c + d*x)**(-m + S(-2))*log(u)**(p + S(1)), x), x) + Simp((a + b*x)**(m + S(1))*(c + d*x)**(-m + S(-1))*log(u)**(p + S(1))/((p + S(1))*(-a*d + b*c)), x) rule2087 = ReplacementRule(pattern2087, replacement2087) pattern2088 = Pattern(Integral(log(((x_*WC('b', S(1)) + WC('a', S(0)))**WC('n1', S(1))*(x_*WC('d', S(1)) + WC('c', S(0)))**n2_*WC('e1', S(1)))**WC('n', S(1))*WC('e', S(1)))**WC('p', S(1))/((x_*WC('d', S(1)) + WC('c', S(0)))*(x_*WC('g', S(1)) + WC('f', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons4, cons652, cons1204, cons1203, cons71, cons1209, cons1205) def replacement2088(p, n1, b, f, g, n2, d, a, c, n, e1, x, e): rubi.append(2088) return Dist(d/g, Int(log(e*(e1*(a + b*x)**n1*(c + d*x)**(-n1))**n)**p/(c + d*x)**S(2), x), x) rule2088 = ReplacementRule(pattern2088, replacement2088) pattern2089 = Pattern(Integral(log((x_*WC('b', S(1)) + WC('a', S(0)))*WC('e', S(1))/(x_*WC('d', S(1)) + WC('c', S(0))))/((x_*WC('d', S(1)) + WC('c', S(0)))*(x_*WC('g', S(1)) + WC('f', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons71, cons1209, cons1208, cons1212) def replacement2089(f, b, g, d, c, a, x, e): rubi.append(2089) return Simp(PolyLog(S(2), -(f + g*x)*(a*e - c)/(f*(c + d*x)))/(-c*g + d*f), x) rule2089 = ReplacementRule(pattern2089, replacement2089) pattern2090 = Pattern(Integral(log(((x_*WC('b', S(1)) + WC('a', S(0)))**WC('n1', S(1))*(x_*WC('d', S(1)) + WC('c', S(0)))**n2_*WC('e1', S(1)))**WC('n', S(1))*WC('e', S(1)))**WC('p', S(1))/((x_*WC('d', S(1)) + WC('c', S(0)))*(x_*WC('g', S(1)) + WC('f', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons4, cons652, cons1204, cons1203, cons71, cons1209, cons1208, cons128) def replacement2090(p, n1, b, f, g, n2, d, a, c, n, e1, x, e): rubi.append(2090) return Dist(n*n1*p*(-a*d + b*c)/(-c*g + d*f), Int(log(e*(e1*(a + b*x)**n1*(c + d*x)**(-n1))**n)**(p + S(-1))*log((f + g*x)*(-a*d + b*c)/((c + d*x)*(-a*g + b*f)))/((a + b*x)*(c + d*x)), x), x) - Simp(log(e*(e1*(a + b*x)**n1*(c + d*x)**(-n1))**n)**p*log((f + g*x)*(-a*d + b*c)/((c + d*x)*(-a*g + b*f)))/(-c*g + d*f), x) rule2090 = ReplacementRule(pattern2090, replacement2090) pattern2091 = Pattern(Integral(log((x_*WC('b', S(1)) + WC('a', S(0)))*WC('e', S(1))/(x_*WC('d', S(1)) + WC('c', S(0))))/(f_ + x_**S(2)*WC('g', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons1213, cons1214) def replacement2091(g, b, f, d, c, a, x, e): rubi.append(2091) return Simp(c*PolyLog(S(2), -(c - d*x)*(a*e - c)/(c*(c + d*x)))/(S(2)*d*f), x) rule2091 = ReplacementRule(pattern2091, replacement2091) pattern2092 = Pattern(Integral(log(((x_*WC('b', S(1)) + WC('a', S(0)))**WC('n1', S(1))*(x_*WC('d', S(1)) + WC('c', S(0)))**n2_*WC('e1', S(1)))**WC('n', S(1))*WC('e', S(1)))**WC('p', S(1))/(x_**S(2)*WC('h', S(1)) + x_*WC('g', S(1)) + WC('f', S(0))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons209, cons4, cons5, cons652, cons1204, cons1203, cons71, cons1215) def replacement2092(p, n1, b, f, g, n2, d, a, c, n, e1, x, h, e): rubi.append(2092) return Dist(d**S(2), Int(log(e*(e1*(a + b*x)**n1*(c + d*x)**(-n1))**n)**p/((c + d*x)*(-c*h + d*g + d*h*x)), x), x) rule2092 = ReplacementRule(pattern2092, replacement2092) pattern2093 = Pattern(Integral(log(((x_*WC('b', S(1)) + WC('a', S(0)))**WC('n1', S(1))*(x_*WC('d', S(1)) + WC('c', S(0)))**n2_*WC('e1', S(1)))**WC('n', S(1))*WC('e', S(1)))**WC('p', S(1))/(x_**S(2)*WC('h', S(1)) + WC('f', S(0))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons209, cons4, cons5, cons652, cons1204, cons1203, cons71, cons1216) def replacement2093(p, n1, b, f, n2, d, a, c, n, e1, x, h, e): rubi.append(2093) return -Dist(d**S(2)/h, Int(log(e*(e1*(a + b*x)**n1*(c + d*x)**(-n1))**n)**p/((c - d*x)*(c + d*x)), x), x) rule2093 = ReplacementRule(pattern2093, replacement2093) pattern2094 = Pattern(Integral(log(((x_*WC('b', S(1)) + WC('a', S(0)))**WC('n1', S(1))*(x_*WC('d', S(1)) + WC('c', S(0)))**n2_*WC('e1', S(1)))**WC('n', S(1))*WC('e', S(1)))**WC('p', S(1))/((x_*WC('d', S(1)) + WC('c', S(0)))*(x_*WC('g', S(1)) + WC('f', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons4, cons5, cons652, cons1204, cons1203, cons71, cons1208, cons1207) def replacement2094(p, n1, b, f, g, n2, d, a, c, n, e1, x, e): rubi.append(2094) return Dist(b/(g*n*n1*(-a*d + b*c)), Subst(Int(x**p, x), x, log(e*(e1*(a + b*x)**n1*(c + d*x)**(-n1))**n)), x) rule2094 = ReplacementRule(pattern2094, replacement2094) pattern2095 = Pattern(Integral(log(v_)*log(u_**n_*WC('e', S(1)))**WC('p', S(1))/((x_*WC('b', S(1)) + WC('a', S(0)))*(x_*WC('d', S(1)) + WC('c', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons4, cons1217, cons1211, cons71, cons13, cons163) def replacement2095(v, p, u, b, d, c, a, n, x, e): rubi.append(2095) return Dist(n*p, Int(PolyLog(S(2), Together(-v + S(1)))*log(e*u**n)**(p + S(-1))/((a + b*x)*(c + d*x)), x), x) - Simp(PolyLog(S(2), Together(-v + S(1)))*log(e*u**n)**p/(-a*d + b*c), x) rule2095 = ReplacementRule(pattern2095, replacement2095) pattern2096 = Pattern(Integral(log(u_)**WC('p', S(1))*log(v_)/((x_*WC('b', S(1)) + WC('a', S(0)))*(x_*WC('d', S(1)) + WC('c', S(0)))), x_), cons2, cons3, cons7, cons27, cons1217, cons1211, cons71, cons13, cons163) def replacement2096(v, p, u, b, d, c, a, x): rubi.append(2096) return Dist(p, Int(PolyLog(S(2), Together(-v + S(1)))*log(u)**(p + S(-1))/((a + b*x)*(c + d*x)), x), x) - Simp(PolyLog(S(2), Together(-v + S(1)))*log(u)**p/(-a*d + b*c), x) rule2096 = ReplacementRule(pattern2096, replacement2096) def With2097(v, p, u, b, d, c, a, n, x, e): f = (-v + S(1))/u rubi.append(2097) return Dist(f/(n*(p + S(1))), Int(log(e*u**n)**(p + S(1))/((c + d*x)*(-a*f - b*f + c + d)), x), x) + Simp(log(v)*log(e*u**n)**(p + S(1))/(n*(p + S(1))*(-a*d + b*c)), x) pattern2097 = Pattern(Integral(log(v_)*log(u_**n_*WC('e', S(1)))**p_/((x_*WC('b', S(1)) + WC('a', S(0)))*(x_*WC('d', S(1)) + WC('c', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons4, cons1217, cons1211, cons71, cons13, cons137) rule2097 = ReplacementRule(pattern2097, With2097) def With2098(v, p, u, b, d, c, a, x): f = (-v + S(1))/u rubi.append(2098) return Dist(f/(p + S(1)), Int(log(u)**(p + S(1))/((c + d*x)*(-a*f - b*f + c + d)), x), x) + Simp(log(u)**(p + S(1))*log(v)/((p + S(1))*(-a*d + b*c)), x) pattern2098 = Pattern(Integral(log(u_)**p_*log(v_)/((x_*WC('b', S(1)) + WC('a', S(0)))*(x_*WC('d', S(1)) + WC('c', S(0)))), x_), cons2, cons3, cons7, cons27, cons1217, cons1211, cons71, cons13, cons137) rule2098 = ReplacementRule(pattern2098, With2098) pattern2099 = Pattern(Integral(log(v_)*log(u_**n_*WC('e', S(1)))**WC('p', S(1))/((x_*WC('b', S(1)) + WC('a', S(0)))*(x_*WC('d', S(1)) + WC('c', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons4, cons1218, cons1211, cons71, cons13, cons163) def replacement2099(v, p, u, b, d, c, a, n, x, e): rubi.append(2099) return -Dist(n*p, Int(PolyLog(S(2), Together(-v + S(1)))*log(e*u**n)**(p + S(-1))/((a + b*x)*(c + d*x)), x), x) + Simp(PolyLog(S(2), Together(-v + S(1)))*log(e*u**n)**p/(-a*d + b*c), x) rule2099 = ReplacementRule(pattern2099, replacement2099) pattern2100 = Pattern(Integral(log(u_)**WC('p', S(1))*log(v_)/((x_*WC('b', S(1)) + WC('a', S(0)))*(x_*WC('d', S(1)) + WC('c', S(0)))), x_), cons2, cons3, cons7, cons27, cons1218, cons1211, cons71, cons13, cons163) def replacement2100(v, p, u, b, d, c, a, x): rubi.append(2100) return -Dist(p, Int(PolyLog(S(2), Together(-v + S(1)))*log(u)**(p + S(-1))/((a + b*x)*(c + d*x)), x), x) + Simp(PolyLog(S(2), Together(-v + S(1)))*log(u)**p/(-a*d + b*c), x) rule2100 = ReplacementRule(pattern2100, replacement2100) def With2101(v, p, u, b, d, c, a, n, x, e): f = u*(-v + S(1)) rubi.append(2101) return -Dist(f/(n*(p + S(1))), Int(log(e*u**n)**(p + S(1))/((a + b*x)*(a + b - c*f - d*f)), x), x) + Simp(log(v)*log(e*u**n)**(p + S(1))/(n*(p + S(1))*(-a*d + b*c)), x) pattern2101 = Pattern(Integral(log(v_)*log(u_**n_*WC('e', S(1)))**p_/((x_*WC('b', S(1)) + WC('a', S(0)))*(x_*WC('d', S(1)) + WC('c', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons4, cons1218, cons1211, cons71, cons13, cons137) rule2101 = ReplacementRule(pattern2101, With2101) def With2102(v, p, u, b, d, c, a, x): f = u*(-v + S(1)) rubi.append(2102) return -Dist(f/(p + S(1)), Int(log(u)**(p + S(1))/((a + b*x)*(a + b - c*f - d*f)), x), x) + Simp(log(u)**(p + S(1))*log(v)/((p + S(1))*(-a*d + b*c)), x) pattern2102 = Pattern(Integral(log(u_)**p_*log(v_)/((x_*WC('b', S(1)) + WC('a', S(0)))*(x_*WC('d', S(1)) + WC('c', S(0)))), x_), cons2, cons3, cons7, cons27, cons1218, cons1211, cons71, cons13, cons137) rule2102 = ReplacementRule(pattern2102, With2102) pattern2103 = Pattern(Integral(PolyLog(q_, v_)*log(u_**n_*WC('e', S(1)))**p_/((x_*WC('b', S(1)) + WC('a', S(0)))*(x_*WC('d', S(1)) + WC('c', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons4, cons50, cons1219, cons1211, cons71, cons13, cons146) def replacement2103(v, p, u, b, d, c, a, n, x, q, e): rubi.append(2103) return -Dist(n*p, Int(PolyLog(q + S(1), v)*log(e*u**n)**(p + S(-1))/((a + b*x)*(c + d*x)), x), x) + Simp(PolyLog(q + S(1), v)*log(e*u**n)**p/(-a*d + b*c), x) rule2103 = ReplacementRule(pattern2103, replacement2103) pattern2104 = Pattern(Integral(PolyLog(q_, v_)*log(u_)**p_/((x_*WC('b', S(1)) + WC('a', S(0)))*(x_*WC('d', S(1)) + WC('c', S(0)))), x_), cons2, cons3, cons7, cons27, cons50, cons1219, cons1211, cons71, cons13, cons146) def replacement2104(v, p, u, b, d, c, a, x, q): rubi.append(2104) return -Dist(p, Int(PolyLog(q + S(1), v)*log(u)**(p + S(-1))/((a + b*x)*(c + d*x)), x), x) + Simp(PolyLog(q + S(1), v)*log(u)**p/(-a*d + b*c), x) rule2104 = ReplacementRule(pattern2104, replacement2104) pattern2105 = Pattern(Integral(PolyLog(q_, v_)*log(u_**n_*WC('e', S(1)))**p_/((x_*WC('b', S(1)) + WC('a', S(0)))*(x_*WC('d', S(1)) + WC('c', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons4, cons50, cons1219, cons1211, cons71, cons13, cons137) def replacement2105(v, p, u, b, d, c, a, n, x, q, e): rubi.append(2105) return -Dist(S(1)/(n*(p + S(1))), Int(PolyLog(q + S(-1), v)*log(e*u**n)**(p + S(1))/((a + b*x)*(c + d*x)), x), x) + Simp(PolyLog(q, v)*log(e*u**n)**(p + S(1))/(n*(p + S(1))*(-a*d + b*c)), x) rule2105 = ReplacementRule(pattern2105, replacement2105) pattern2106 = Pattern(Integral(PolyLog(q_, v_)*log(u_)**p_/((x_*WC('b', S(1)) + WC('a', S(0)))*(x_*WC('d', S(1)) + WC('c', S(0)))), x_), cons2, cons3, cons7, cons27, cons50, cons1219, cons1211, cons71, cons13, cons137) def replacement2106(v, p, u, b, d, c, a, x, q): rubi.append(2106) return -Dist(S(1)/(p + S(1)), Int(PolyLog(q + S(-1), v)*log(u)**(p + S(1))/((a + b*x)*(c + d*x)), x), x) + Simp(PolyLog(q, v)*log(u)**(p + S(1))/((p + S(1))*(-a*d + b*c)), x) rule2106 = ReplacementRule(pattern2106, replacement2106) pattern2107 = Pattern(Integral(PolyLog(q_, v_)*log(u_**n_*WC('e', S(1)))**p_/((x_*WC('b', S(1)) + WC('a', S(0)))*(x_*WC('d', S(1)) + WC('c', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons4, cons50, cons1220, cons1211, cons71, cons13, cons146) def replacement2107(v, p, u, b, d, c, a, n, x, q, e): rubi.append(2107) return Dist(n*p, Int(PolyLog(q + S(1), v)*log(e*u**n)**(p + S(-1))/((a + b*x)*(c + d*x)), x), x) - Simp(PolyLog(q + S(1), v)*log(e*u**n)**p/(-a*d + b*c), x) rule2107 = ReplacementRule(pattern2107, replacement2107) pattern2108 = Pattern(Integral(PolyLog(q_, v_)*log(u_)**p_/((x_*WC('b', S(1)) + WC('a', S(0)))*(x_*WC('d', S(1)) + WC('c', S(0)))), x_), cons2, cons3, cons7, cons27, cons50, cons1220, cons1211, cons71, cons13, cons146) def replacement2108(v, p, u, b, d, c, a, x, q): rubi.append(2108) return Dist(p, Int(PolyLog(q + S(1), v)*log(u)**(p + S(-1))/((a + b*x)*(c + d*x)), x), x) - Simp(PolyLog(q + S(1), v)*log(u)**p/(-a*d + b*c), x) rule2108 = ReplacementRule(pattern2108, replacement2108) pattern2109 = Pattern(Integral(PolyLog(q_, v_)*log(u_**n_*WC('e', S(1)))**p_/((x_*WC('b', S(1)) + WC('a', S(0)))*(x_*WC('d', S(1)) + WC('c', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons4, cons50, cons1220, cons1211, cons71, cons13, cons137) def replacement2109(v, p, u, b, d, c, a, n, x, q, e): rubi.append(2109) return Dist(S(1)/(n*(p + S(1))), Int(PolyLog(q + S(-1), v)*log(e*u**n)**(p + S(1))/((a + b*x)*(c + d*x)), x), x) + Simp(PolyLog(q, v)*log(e*u**n)**(p + S(1))/(n*(p + S(1))*(-a*d + b*c)), x) rule2109 = ReplacementRule(pattern2109, replacement2109) pattern2110 = Pattern(Integral(PolyLog(q_, v_)*log(u_)**p_/((x_*WC('b', S(1)) + WC('a', S(0)))*(x_*WC('d', S(1)) + WC('c', S(0)))), x_), cons2, cons3, cons7, cons27, cons50, cons1220, cons1211, cons71, cons13, cons137) def replacement2110(v, p, u, b, d, c, a, x, q): rubi.append(2110) return Dist(S(1)/(p + S(1)), Int(PolyLog(q + S(-1), v)*log(u)**(p + S(1))/((a + b*x)*(c + d*x)), x), x) + Simp(PolyLog(q, v)*log(u)**(p + S(1))/((p + S(1))*(-a*d + b*c)), x) rule2110 = ReplacementRule(pattern2110, replacement2110) pattern2111 = Pattern(Integral(WC('u', S(1))*log(((x_*WC('b', S(1)) + WC('a', S(0)))**WC('n1', S(1))*(x_*WC('d', S(1)) + WC('c', S(0)))**n2_*WC('e1', S(1)))**WC('n', S(1))*WC('e', S(1)))**WC('p', S(1))/(x_**S(2)*WC('h', S(1)) + x_*WC('g', S(1)) + WC('f', S(0))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons209, cons4, cons5, cons652, cons1204, cons1203, cons71, cons1221, cons1222) def replacement2111(p, u, n1, b, f, g, n2, d, a, c, n, e1, x, h, e): rubi.append(2111) return Dist(b*d/h, Int(u*log(e*(e1*(a + b*x)**n1*(c + d*x)**(-n1))**n)**p/((a + b*x)*(c + d*x)), x), x) rule2111 = ReplacementRule(pattern2111, replacement2111) pattern2112 = Pattern(Integral(WC('u', S(1))*log(((x_*WC('b', S(1)) + WC('a', S(0)))**WC('n1', S(1))*(x_*WC('d', S(1)) + WC('c', S(0)))**n2_*WC('e1', S(1)))**WC('n', S(1))*WC('e', S(1)))**WC('p', S(1))/(x_**S(2)*WC('h', S(1)) + WC('f', S(0))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons209, cons4, cons5, cons652, cons1204, cons1203, cons71, cons1221, cons70) def replacement2112(p, u, n1, b, f, n2, d, a, c, n, e1, x, h, e): rubi.append(2112) return Dist(b*d/h, Int(u*log(e*(e1*(a + b*x)**n1*(c + d*x)**(-n1))**n)**p/((a + b*x)*(c + d*x)), x), x) rule2112 = ReplacementRule(pattern2112, replacement2112) def With2113(n1, b, g, n2, f, d, a, c, n, e1, x, h, e): u = IntHide(S(1)/(f + g*x + h*x**S(2)), x) rubi.append(2113) return -Dist(n*(-a*d + b*c), Int(u/((a + b*x)*(c + d*x)), x), x) + Simp(u*log(e*(e1*(a + b*x)**n1*(c + d*x)**n2)**n), x) pattern2113 = Pattern(Integral(log(((x_*WC('b', S(1)) + WC('a', S(0)))**WC('n1', S(1))*(x_*WC('d', S(1)) + WC('c', S(0)))**n2_*WC('e1', S(1)))**WC('n', S(1))*WC('e', S(1)))/(f_ + x_**S(2)*WC('h', S(1)) + x_*WC('g', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons652, cons125, cons208, cons209, cons4, cons1204, cons1203) rule2113 = ReplacementRule(pattern2113, With2113) def With2114(n1, b, n2, f, d, a, c, n, e1, x, h, e): u = IntHide(S(1)/(f + h*x**S(2)), x) rubi.append(2114) return -Dist(n*(-a*d + b*c), Int(u/((a + b*x)*(c + d*x)), x), x) + Simp(u*log(e*(e1*(a + b*x)**n1*(c + d*x)**n2)**n), x) pattern2114 = Pattern(Integral(log(((x_*WC('b', S(1)) + WC('a', S(0)))**WC('n1', S(1))*(x_*WC('d', S(1)) + WC('c', S(0)))**n2_*WC('e1', S(1)))**WC('n', S(1))*WC('e', S(1)))/(f_ + x_**S(2)*WC('h', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons652, cons125, cons209, cons4, cons1204, cons1203) rule2114 = ReplacementRule(pattern2114, With2114) def With2115(p, RFx, n1, b, n2, d, a, c, n, e1, x, e): if isinstance(x, (int, Integer, float, Float)): return False u = ExpandIntegrand(log(e*(e1*(a + b*x)**n1*(c + d*x)**n2)**n)**p, RFx, x) if SumQ(u): return True return False pattern2115 = Pattern(Integral(RFx_*log(((x_*WC('b', S(1)) + WC('a', S(0)))**WC('n1', S(1))*(x_*WC('d', S(1)) + WC('c', S(0)))**n2_*WC('e1', S(1)))**WC('n', S(1))*WC('e', S(1)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons4, cons652, cons1204, cons1203, cons1198, cons128, CustomConstraint(With2115)) def replacement2115(p, RFx, n1, b, n2, d, a, c, n, e1, x, e): u = ExpandIntegrand(log(e*(e1*(a + b*x)**n1*(c + d*x)**n2)**n)**p, RFx, x) rubi.append(2115) return Int(u, x) rule2115 = ReplacementRule(pattern2115, replacement2115) def With2116(v, x, p, u): if isinstance(x, (int, Integer, float, Float)): return False lst = QuotientOfLinearsParts(v, x) if Not(And(OneQ(p), ZeroQ(Part(lst, S(3))))): return True return False pattern2116 = Pattern(Integral(WC('u', S(1))*log(v_)**WC('p', S(1)), x_), cons5, cons1223, cons1224, CustomConstraint(With2116)) def replacement2116(v, x, p, u): lst = QuotientOfLinearsParts(v, x) rubi.append(2116) return Int(u*log((x*Part(lst, S(2)) + Part(lst, S(1)))/(x*Part(lst, S(4)) + Part(lst, S(3))))**p, x) rule2116 = ReplacementRule(pattern2116, replacement2116) pattern2117 = Pattern(Integral(log((x_**n_*WC('b', S(1)) + WC('a', S(0)))**WC('p', S(1))*WC('c', S(1))), x_), cons2, cons3, cons7, cons4, cons5, cons806) def replacement2117(p, b, c, a, n, x): rubi.append(2117) return -Dist(b*n*p, Int(x**n/(a + b*x**n), x), x) + Simp(x*log(c*(a + b*x**n)**p), x) rule2117 = ReplacementRule(pattern2117, replacement2117) pattern2118 = Pattern(Integral(log(v_**WC('p', S(1))*WC('c', S(1))), x_), cons7, cons5, cons840, cons1225) def replacement2118(v, c, p, x): rubi.append(2118) return Int(log(c*ExpandToSum(v, x)**p), x) rule2118 = ReplacementRule(pattern2118, replacement2118) pattern2119 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*log((x_**n_*WC('e', S(1)) + WC('d', S(0)))**WC('p', S(1))*WC('c', S(1))))/(x_*WC('g', S(1)) + WC('f', S(0))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons4, cons5, cons1226) def replacement2119(p, f, b, g, d, a, c, n, x, e): rubi.append(2119) return -Dist(b*e*n*p/g, Int(x**(n + S(-1))*log(f + g*x)/(d + e*x**n), x), x) + Simp((a + b*log(c*(d + e*x**n)**p))*log(f + g*x)/g, x) rule2119 = ReplacementRule(pattern2119, replacement2119) pattern2120 = Pattern(Integral((x_*WC('g', S(1)) + WC('f', S(0)))**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*log((x_**n_*WC('e', S(1)) + WC('d', S(0)))**WC('p', S(1))*WC('c', S(1)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons21, cons4, cons5, cons66) def replacement2120(p, m, f, b, g, d, a, c, n, x, e): rubi.append(2120) return -Dist(b*e*n*p/(g*(m + S(1))), Int(x**(n + S(-1))*(f + g*x)**(m + S(1))/(d + e*x**n), x), x) + Simp((a + b*log(c*(d + e*x**n)**p))*(f + g*x)**(m + S(1))/(g*(m + S(1))), x) rule2120 = ReplacementRule(pattern2120, replacement2120) pattern2121 = Pattern(Integral(u_**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*log(v_**WC('p', S(1))*WC('c', S(1)))), x_), cons2, cons3, cons7, cons21, cons5, cons68, cons840, cons1125) def replacement2121(v, p, u, m, b, a, c, x): rubi.append(2121) return Int((a + b*log(c*ExpandToSum(v, x)**p))*ExpandToSum(u, x)**m, x) rule2121 = ReplacementRule(pattern2121, replacement2121) def With2122(p, m, f, g, b, d, c, a, n, x, e): w = IntHide(asin(f + g*x)**m, x) rubi.append(2122) return -Dist(b*e*n*p, Int(SimplifyIntegrand(w*x**(n + S(-1))/(d + e*x**n), x), x), x) + Dist(a + b*log(c*(d + e*x**n)**p), w, x) pattern2122 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*log((x_**n_*WC('e', S(1)) + WC('d', S(0)))**WC('p', S(1))*WC('c', S(1))))*asin(x_*WC('g', S(1)) + WC('f', S(0)))**WC('m', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons4, cons5, cons62) rule2122 = ReplacementRule(pattern2122, With2122) def With2123(p, f, b, g, d, a, c, x, e): u = IntHide(S(1)/(f + g*x**S(2)), x) rubi.append(2123) return -Dist(S(2)*b*e*p, Int(u*x/(d + e*x**S(2)), x), x) + Simp(u*(a + b*log(c*(d + e*x**S(2))**p)), x) pattern2123 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*log((x_**S(2)*WC('e', S(1)) + WC('d', S(0)))**WC('p', S(1))*WC('c', S(1))))/(x_**S(2)*WC('g', S(1)) + WC('f', S(0))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons5, cons1227) rule2123 = ReplacementRule(pattern2123, With2123) pattern2124 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*log((d_ + x_**S(2)*WC('e', S(1)))**WC('p', S(1))*WC('c', S(1))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons5, cons148) def replacement2124(p, b, d, a, c, n, x, e): rubi.append(2124) return -Dist(S(2)*b*e*n*p, Int(x**S(2)*(a + b*log(c*(d + e*x**S(2))**p))**(n + S(-1))/(d + e*x**S(2)), x), x) + Simp(x*(a + b*log(c*(d + e*x**S(2))**p))**n, x) rule2124 = ReplacementRule(pattern2124, replacement2124) pattern2125 = Pattern(Integral(x_**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*log((d_ + x_**S(2)*WC('e', S(1)))**WC('p', S(1))*WC('c', S(1))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons5, cons148, cons1228) def replacement2125(p, m, b, d, a, c, n, x, e): rubi.append(2125) return Dist(S(1)/2, Subst(Int(x**(m/S(2) + S(-1)/2)*(a + b*log(c*(d + e*x)**p))**n, x), x, x**S(2)), x) rule2125 = ReplacementRule(pattern2125, replacement2125) pattern2126 = Pattern(Integral(x_**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*log((d_ + x_**S(2)*WC('e', S(1)))**WC('p', S(1))*WC('c', S(1))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons21, cons5, cons148, cons1229) def replacement2126(p, m, b, d, a, c, n, x, e): rubi.append(2126) return -Dist(S(2)*b*e*n*p/(m + S(1)), Int(x**(m + S(2))*(a + b*log(c*(d + e*x**S(2))**p))**(n + S(-1))/(d + e*x**S(2)), x), x) + Simp(x**(m + S(1))*(a + b*log(c*(d + e*x**S(2))**p))**n/(m + S(1)), x) rule2126 = ReplacementRule(pattern2126, replacement2126) def With2127(v, x, u): if isinstance(x, (int, Integer, float, Float)): return False try: w = DerivativeDivides(v, u*(-v + S(1)), x) res = Not(FalseQ(w)) except (TypeError, AttributeError): return False if res: return True return False pattern2127 = Pattern(Integral(u_*log(v_), x_), CustomConstraint(With2127)) def replacement2127(v, x, u): w = DerivativeDivides(v, u*(-v + S(1)), x) rubi.append(2127) return Simp(w*PolyLog(S(2), Together(-v + S(1))), x) rule2127 = ReplacementRule(pattern2127, replacement2127) def With2128(v, w, u, b, a, x): if isinstance(x, (int, Integer, float, Float)): return False try: z = DerivativeDivides(v, w*(-v + S(1)), x) res = Not(FalseQ(z)) except (TypeError, AttributeError): return False if res: return True return False pattern2128 = Pattern(Integral(w_*(WC('a', S(0)) + WC('b', S(1))*log(u_))*log(v_), x_), cons2, cons3, cons1230, CustomConstraint(With2128)) def replacement2128(v, w, u, b, a, x): z = DerivativeDivides(v, w*(-v + S(1)), x) rubi.append(2128) return -Dist(b, Int(SimplifyIntegrand(z*D(u, x)*PolyLog(S(2), Together(-v + S(1)))/u, x), x), x) + Simp(z*(a + b*log(u))*PolyLog(S(2), Together(-v + S(1))), x) rule2128 = ReplacementRule(pattern2128, replacement2128) pattern2129 = Pattern(Integral(log((a_ + (x_*WC('e', S(1)) + WC('d', S(0)))**n_*WC('b', S(1)))**WC('p', S(1))*WC('c', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons5, cons87, cons463) def replacement2129(p, b, d, c, a, n, x, e): rubi.append(2129) return -Dist(b*n*p, Int(S(1)/(a*(d + e*x)**(-n) + b), x), x) + Simp((d + e*x)*log(c*(a + b*(d + e*x)**n)**p)/e, x) rule2129 = ReplacementRule(pattern2129, replacement2129) pattern2130 = Pattern(Integral(log((a_ + (x_*WC('e', S(1)) + WC('d', S(0)))**WC('n', S(1))*WC('b', S(1)))**WC('p', S(1))*WC('c', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons4, cons5, cons1231) def replacement2130(p, b, d, c, n, a, x, e): rubi.append(2130) return Dist(a*n*p, Int(S(1)/(a + b*(d + e*x)**n), x), x) + Simp((d + e*x)*log(c*(a + b*(d + e*x)**n)**p)/e, x) - Simp(n*p*x, x) rule2130 = ReplacementRule(pattern2130, replacement2130) pattern2131 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*log((d_ + WC('e', S(1))/(x_*WC('g', S(1)) + WC('f', S(0))))**WC('p', S(1))*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons5, cons148) def replacement2131(p, f, g, b, d, a, c, n, x, e): rubi.append(2131) return -Dist(b*e*n*p/(d*g), Subst(Int((a + b*log(c*(d + e*x)**p))**(n + S(-1))/x, x), x, S(1)/(f + g*x)), x) + Simp((a + b*log(c*(d + e/(f + g*x))**p))**n*(d*(f + g*x) + e)/(d*g), x) rule2131 = ReplacementRule(pattern2131, replacement2131) pattern2132 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*log(RFx_**WC('p', S(1))*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons5, cons1198, cons148) def replacement2132(p, RFx, b, a, c, n, x): rubi.append(2132) return -Dist(b*n*p, Int(SimplifyIntegrand(x*(a + b*log(RFx**p*c))**(n + S(-1))*D(RFx, x)/RFx, x), x), x) + Simp(x*(a + b*log(RFx**p*c))**n, x) rule2132 = ReplacementRule(pattern2132, replacement2132) pattern2133 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*log(RFx_**WC('p', S(1))*WC('c', S(1))))**WC('n', S(1))/(x_*WC('e', S(1)) + WC('d', S(0))), x_), cons2, cons3, cons7, cons27, cons48, cons5, cons1198, cons148) def replacement2133(p, RFx, b, d, a, c, n, x, e): rubi.append(2133) return -Dist(b*n*p/e, Int((a + b*log(RFx**p*c))**(n + S(-1))*D(RFx, x)*log(d + e*x)/RFx, x), x) + Simp((a + b*log(RFx**p*c))**n*log(d + e*x)/e, x) rule2133 = ReplacementRule(pattern2133, replacement2133) pattern2134 = Pattern(Integral((x_*WC('e', S(1)) + WC('d', S(0)))**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*log(RFx_**WC('p', S(1))*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons21, cons5, cons1198, cons148, cons1232, cons66) def replacement2134(p, RFx, m, b, d, a, c, n, x, e): rubi.append(2134) return -Dist(b*n*p/(e*(m + S(1))), Int(SimplifyIntegrand((a + b*log(RFx**p*c))**(n + S(-1))*(d + e*x)**(m + S(1))*D(RFx, x)/RFx, x), x), x) + Simp((a + b*log(RFx**p*c))**n*(d + e*x)**(m + S(1))/(e*(m + S(1))), x) rule2134 = ReplacementRule(pattern2134, replacement2134) def With2135(RFx, d, c, n, x, e): u = IntHide(S(1)/(d + e*x**S(2)), x) rubi.append(2135) return -Dist(n, Int(SimplifyIntegrand(u*D(RFx, x)/RFx, x), x), x) + Simp(u*log(RFx**n*c), x) pattern2135 = Pattern(Integral(log(RFx_**WC('n', S(1))*WC('c', S(1)))/(d_ + x_**S(2)*WC('e', S(1))), x_), cons7, cons27, cons48, cons4, cons1198, cons1233) rule2135 = ReplacementRule(pattern2135, With2135) def With2136(Px, c, n, Qx, x): u = IntHide(S(1)/Qx, x) rubi.append(2136) return -Dist(n, Int(SimplifyIntegrand(u*D(Px, x)/Px, x), x), x) + Simp(u*log(Px**n*c), x) pattern2136 = Pattern(Integral(log(Px_**WC('n', S(1))*WC('c', S(1)))/Qx_, x_), cons7, cons4, cons1234, cons1235) rule2136 = ReplacementRule(pattern2136, With2136) def With2137(p, RFx, b, a, c, n, RGx, x): if isinstance(x, (int, Integer, float, Float)): return False u = ExpandIntegrand((a + b*log(RFx**p*c))**n, RGx, x) if SumQ(u): return True return False pattern2137 = Pattern(Integral(RGx_*(WC('a', S(0)) + WC('b', S(1))*log(RFx_**WC('p', S(1))*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons5, cons1198, cons1236, cons148, CustomConstraint(With2137)) def replacement2137(p, RFx, b, a, c, n, RGx, x): u = ExpandIntegrand((a + b*log(RFx**p*c))**n, RGx, x) rubi.append(2137) return Int(u, x) rule2137 = ReplacementRule(pattern2137, replacement2137) def With2138(p, RFx, b, a, c, n, RGx, x): if isinstance(x, (int, Integer, float, Float)): return False u = ExpandIntegrand(RGx*(a + b*log(RFx**p*c))**n, x) if SumQ(u): return True return False pattern2138 = Pattern(Integral(RGx_*(WC('a', S(0)) + WC('b', S(1))*log(RFx_**WC('p', S(1))*WC('c', S(1))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons5, cons1198, cons1236, cons148, CustomConstraint(With2138)) def replacement2138(p, RFx, b, a, c, n, RGx, x): u = ExpandIntegrand(RGx*(a + b*log(RFx**p*c))**n, x) rubi.append(2138) return Int(u, x) rule2138 = ReplacementRule(pattern2138, replacement2138) def With2139(RFx, u, b, a, x): if isinstance(x, (int, Integer, float, Float)): return False try: lst = SubstForFractionalPowerOfLinear(RFx*(a + b*log(u)), x) res = Not(FalseQ(lst)) except (TypeError, AttributeError): return False if res: return True return False pattern2139 = Pattern(Integral(RFx_*(WC('a', S(0)) + WC('b', S(1))*log(u_)), x_), cons2, cons3, cons1198, CustomConstraint(With2139)) def replacement2139(RFx, u, b, a, x): lst = SubstForFractionalPowerOfLinear(RFx*(a + b*log(u)), x) rubi.append(2139) return Dist(Part(lst, S(2))*Part(lst, S(4)), Subst(Int(Part(lst, S(1)), x), x, Part(lst, S(3))**(S(1)/Part(lst, S(2)))), x) rule2139 = ReplacementRule(pattern2139, replacement2139) pattern2140 = Pattern(Integral((x_*WC('g', S(1)) + WC('f', S(0)))**WC('m', S(1))*log((F_**((x_*WC('b', S(1)) + WC('a', S(0)))*WC('c', S(1))))**WC('n', S(1))*WC('e', S(1)) + S(1)), x_), cons1099, cons2, cons3, cons7, cons48, cons125, cons208, cons4, cons31, cons168) def replacement2140(m, f, b, g, c, n, a, x, F, e): rubi.append(2140) return Dist(g*m/(b*c*n*log(F)), Int((f + g*x)**(m + S(-1))*PolyLog(S(2), -e*(F**(c*(a + b*x)))**n), x), x) - Simp((f + g*x)**m*PolyLog(S(2), -e*(F**(c*(a + b*x)))**n)/(b*c*n*log(F)), x) rule2140 = ReplacementRule(pattern2140, replacement2140) pattern2141 = Pattern(Integral((x_*WC('g', S(1)) + WC('f', S(0)))**WC('m', S(1))*log(d_ + (F_**((x_*WC('b', S(1)) + WC('a', S(0)))*WC('c', S(1))))**WC('n', S(1))*WC('e', S(1))), x_), cons1099, cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons4, cons31, cons168, cons1237) def replacement2141(m, f, b, g, d, c, n, a, x, F, e): rubi.append(2141) return Int((f + g*x)**m*log(S(1) + e*(F**(c*(a + b*x)))**n/d), x) - Simp((f + g*x)**(m + S(1))*log(S(1) + e*(F**(c*(a + b*x)))**n/d)/(g*(m + S(1))), x) + Simp((f + g*x)**(m + S(1))*log(d + e*(F**(c*(a + b*x)))**n)/(g*(m + S(1))), x) rule2141 = ReplacementRule(pattern2141, replacement2141) pattern2142 = Pattern(Integral(log(x_*WC('e', S(1)) + sqrt(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0)))*WC('f', S(1)) + WC('d', S(0))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons1055) def replacement2142(f, b, d, a, c, x, e): rubi.append(2142) return Dist(f**S(2)*(-S(4)*a*c + b**S(2))/S(2), Int(x/(-f*sqrt(a + b*x + c*x**S(2))*(-S(2)*a*e + b*d + x*(-b*e + S(2)*c*d)) + (-b*f**S(2) + S(2)*d*e)*(a + b*x + c*x**S(2))), x), x) + Simp(x*log(d + e*x + f*sqrt(a + b*x + c*x**S(2))), x) rule2142 = ReplacementRule(pattern2142, replacement2142) pattern2143 = Pattern(Integral(log(x_*WC('e', S(1)) + sqrt(x_**S(2)*WC('c', S(1)) + WC('a', S(0)))*WC('f', S(1)) + WC('d', S(0))), x_), cons2, cons7, cons27, cons48, cons125, cons1055) def replacement2143(f, d, a, c, x, e): rubi.append(2143) return -Dist(a*c*f**S(2), Int(x/(d*e*(a + c*x**S(2)) + f*sqrt(a + c*x**S(2))*(a*e - c*d*x)), x), x) + Simp(x*log(d + e*x + f*sqrt(a + c*x**S(2))), x) rule2143 = ReplacementRule(pattern2143, replacement2143) pattern2144 = Pattern(Integral((x_*WC('g', S(1)))**WC('m', S(1))*log(x_*WC('e', S(1)) + sqrt(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0)))*WC('f', S(1)) + WC('d', S(0))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons21, cons1055, cons66, cons515) def replacement2144(m, f, b, g, d, a, c, x, e): rubi.append(2144) return Dist(f**S(2)*(-S(4)*a*c + b**S(2))/(S(2)*g*(m + S(1))), Int((g*x)**(m + S(1))/(-f*sqrt(a + b*x + c*x**S(2))*(-S(2)*a*e + b*d + x*(-b*e + S(2)*c*d)) + (-b*f**S(2) + S(2)*d*e)*(a + b*x + c*x**S(2))), x), x) + Simp((g*x)**(m + S(1))*log(d + e*x + f*sqrt(a + b*x + c*x**S(2)))/(g*(m + S(1))), x) rule2144 = ReplacementRule(pattern2144, replacement2144) pattern2145 = Pattern(Integral((x_*WC('g', S(1)))**WC('m', S(1))*log(x_*WC('e', S(1)) + sqrt(x_**S(2)*WC('c', S(1)) + WC('a', S(0)))*WC('f', S(1)) + WC('d', S(0))), x_), cons2, cons7, cons27, cons48, cons125, cons208, cons21, cons1055, cons66, cons515) def replacement2145(m, f, g, d, a, c, x, e): rubi.append(2145) return -Dist(a*c*f**S(2)/(g*(m + S(1))), Int((g*x)**(m + S(1))/(d*e*(a + c*x**S(2)) + f*sqrt(a + c*x**S(2))*(a*e - c*d*x)), x), x) + Simp((g*x)**(m + S(1))*log(d + e*x + f*sqrt(a + c*x**S(2)))/(g*(m + S(1))), x) rule2145 = ReplacementRule(pattern2145, replacement2145) pattern2146 = Pattern(Integral(WC('v', S(1))*log(sqrt(u_)*WC('f', S(1)) + x_*WC('e', S(1)) + WC('d', S(0))), x_), cons27, cons48, cons125, cons816, cons817, cons1238) def replacement2146(v, u, f, d, x, e): rubi.append(2146) return Int(v*log(d + e*x + f*sqrt(ExpandToSum(u, x))), x) rule2146 = ReplacementRule(pattern2146, replacement2146) pattern2147 = Pattern(Integral(log(u_), x_), cons1230) def replacement2147(x, u): rubi.append(2147) return -Int(SimplifyIntegrand(x*D(u, x)/u, x), x) + Simp(x*log(u), x) rule2147 = ReplacementRule(pattern2147, replacement2147) pattern2148 = Pattern(Integral(log(u_)/(x_*WC('b', S(1)) + WC('a', S(0))), x_), cons2, cons3, cons1239, cons1240) def replacement2148(x, a, b, u): rubi.append(2148) return -Dist(S(1)/b, Int(SimplifyIntegrand(D(u, x)*log(a + b*x)/u, x), x), x) + Simp(log(u)*log(a + b*x)/b, x) rule2148 = ReplacementRule(pattern2148, replacement2148) pattern2149 = Pattern(Integral((x_*WC('b', S(1)) + WC('a', S(0)))**WC('m', S(1))*log(u_), x_), cons2, cons3, cons21, cons1230, cons66) def replacement2149(u, m, b, a, x): rubi.append(2149) return -Dist(S(1)/(b*(m + S(1))), Int(SimplifyIntegrand((a + b*x)**(m + S(1))*D(u, x)/u, x), x), x) + Simp((a + b*x)**(m + S(1))*log(u)/(b*(m + S(1))), x) rule2149 = ReplacementRule(pattern2149, replacement2149) def With2150(x, Qx, u): v = IntHide(S(1)/Qx, x) rubi.append(2150) return -Int(SimplifyIntegrand(v*D(u, x)/u, x), x) + Simp(v*log(u), x) pattern2150 = Pattern(Integral(log(u_)/Qx_, x_), cons1241, cons1230) rule2150 = ReplacementRule(pattern2150, With2150) pattern2151 = Pattern(Integral(u_**(x_*WC('a', S(1)))*log(u_), x_), cons2, cons1230) def replacement2151(x, a, u): rubi.append(2151) return -Int(SimplifyIntegrand(u**(a*x + S(-1))*x*D(u, x), x), x) + Simp(u**(a*x)/a, x) rule2151 = ReplacementRule(pattern2151, replacement2151) def With2152(v, x, u): if isinstance(x, (int, Integer, float, Float)): return False w = IntHide(v, x) if InverseFunctionFreeQ(w, x): return True return False pattern2152 = Pattern(Integral(v_*log(u_), x_), cons1230, CustomConstraint(With2152)) def replacement2152(v, x, u): w = IntHide(v, x) rubi.append(2152) return Dist(log(u), w, x) - Int(SimplifyIntegrand(w*D(u, x)/u, x), x) rule2152 = ReplacementRule(pattern2152, replacement2152) pattern2153 = Pattern(Integral(log(v_)*log(w_), x_), cons1242, cons1243) def replacement2153(v, w, x): rubi.append(2153) return -Int(SimplifyIntegrand(x*D(v, x)*log(w)/v, x), x) - Int(SimplifyIntegrand(x*D(w, x)*log(v)/w, x), x) + Simp(x*log(v)*log(w), x) rule2153 = ReplacementRule(pattern2153, replacement2153) def With2154(v, w, u, x): if isinstance(x, (int, Integer, float, Float)): return False z = IntHide(u, x) if InverseFunctionFreeQ(z, x): return True return False pattern2154 = Pattern(Integral(u_*log(v_)*log(w_), x_), cons1242, cons1243, CustomConstraint(With2154)) def replacement2154(v, w, u, x): z = IntHide(u, x) rubi.append(2154) return Dist(log(v)*log(w), z, x) - Int(SimplifyIntegrand(z*D(v, x)*log(w)/v, x), x) - Int(SimplifyIntegrand(z*D(w, x)*log(v)/w, x), x) rule2154 = ReplacementRule(pattern2154, replacement2154) pattern2155 = Pattern(Integral(log(WC('a', S(1))*log(x_**WC('n', S(1))*WC('b', S(1)))**WC('p', S(1))), x_), cons2, cons3, cons4, cons5, cons1244) def replacement2155(p, b, a, n, x): rubi.append(2155) return -Dist(n*p, Int(S(1)/log(b*x**n), x), x) + Simp(x*log(a*log(b*x**n)**p), x) rule2155 = ReplacementRule(pattern2155, replacement2155) pattern2156 = Pattern(Integral(log(WC('a', S(1))*log(x_**WC('n', S(1))*WC('b', S(1)))**WC('p', S(1)))/x_, x_), cons2, cons3, cons4, cons5, cons1244) def replacement2156(p, b, a, n, x): rubi.append(2156) return Simp((-p + log(a*log(b*x**n)**p))*log(b*x**n)/n, x) rule2156 = ReplacementRule(pattern2156, replacement2156) pattern2157 = Pattern(Integral(x_**WC('m', S(1))*log(WC('a', S(1))*log(x_**WC('n', S(1))*WC('b', S(1)))**WC('p', S(1))), x_), cons2, cons3, cons21, cons4, cons5, cons66) def replacement2157(p, m, b, a, n, x): rubi.append(2157) return -Dist(n*p/(m + S(1)), Int(x**m/log(b*x**n), x), x) + Simp(x**(m + S(1))*log(a*log(b*x**n)**p)/(m + S(1)), x) rule2157 = ReplacementRule(pattern2157, replacement2157) pattern2158 = Pattern(Integral((WC('A', S(0)) + WC('B', S(1))*log(x_*WC('d', S(1)) + WC('c', S(0))))/sqrt(a_ + WC('b', S(1))*log(x_*WC('d', S(1)) + WC('c', S(0)))), x_), cons2, cons3, cons7, cons27, cons34, cons35, cons1245) def replacement2158(B, b, d, c, a, x, A): rubi.append(2158) return Dist(B/b, Int(sqrt(a + b*log(c + d*x)), x), x) + Dist((A*b - B*a)/b, Int(S(1)/sqrt(a + b*log(c + d*x)), x), x) rule2158 = ReplacementRule(pattern2158, replacement2158) pattern2159 = Pattern(Integral(f_**(WC('a', S(1))*log(u_)), x_), cons2, cons125, cons1246) def replacement2159(x, a, f, u): rubi.append(2159) return Int(u**(a*log(f)), x) rule2159 = ReplacementRule(pattern2159, replacement2159) def With2160(x, u): if isinstance(x, (int, Integer, float, Float)): return False try: lst = FunctionOfLog(u*x, x) res = Not(FalseQ(lst)) except (TypeError, AttributeError): return False if res: return True return False pattern2160 = Pattern(Integral(u_, x_), cons1247, CustomConstraint(With2160)) def replacement2160(x, u): lst = FunctionOfLog(u*x, x) rubi.append(2160) return Dist(S(1)/Part(lst, S(3)), Subst(Int(Part(lst, S(1)), x), x, log(Part(lst, S(2)))), x) rule2160 = ReplacementRule(pattern2160, replacement2160) pattern2161 = Pattern(Integral(WC('u', S(1))*log(Gamma(v_)), x_)) def replacement2161(v, x, u): rubi.append(2161) return Dist(-LogGamma(v) + log(Gamma(v)), Int(u, x), x) + Int(u*LogGamma(v), x) rule2161 = ReplacementRule(pattern2161, replacement2161) pattern2162 = Pattern(Integral((w_*WC('a', S(1)) + w_*WC('b', S(1))*log(v_)**WC('n', S(1)))**WC('p', S(1))*WC('u', S(1)), x_), cons2, cons3, cons4, cons38) def replacement2162(v, w, p, u, b, a, n, x): rubi.append(2162) return Int(u*w**p*(a + b*log(v)**n)**p, x) rule2162 = ReplacementRule(pattern2162, replacement2162) pattern2163 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*log(((x_*WC('f', S(1)) + WC('e', S(0)))**WC('p', S(1))*WC('d', S(1)))**WC('q', S(1))*WC('c', S(1))))**n_*WC('u', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons4, cons5, cons50, cons1248) def replacement2163(p, u, f, b, d, a, c, n, x, q, e): rubi.append(2163) return Int(u*(a + b*log(c*(d*(e + f*x)**p)**q))**n, x) rule2163 = ReplacementRule(pattern2163, replacement2163) return [rule2006, rule2007, rule2008, rule2009, rule2010, rule2011, rule2012, rule2013, rule2014, rule2015, rule2016, rule2017, rule2018, rule2019, rule2020, rule2021, rule2022, rule2023, rule2024, rule2025, rule2026, rule2027, rule2028, rule2029, rule2030, rule2031, rule2032, rule2033, rule2034, rule2035, rule2036, rule2037, rule2038, rule2039, rule2040, rule2041, rule2042, rule2043, rule2044, rule2045, rule2046, rule2047, rule2048, rule2049, rule2050, rule2051, rule2052, rule2053, rule2054, rule2055, rule2056, rule2057, rule2058, rule2059, rule2060, rule2061, rule2062, rule2063, rule2064, rule2065, rule2066, rule2067, rule2068, rule2069, rule2070, rule2071, rule2072, rule2073, rule2074, rule2075, rule2076, rule2077, rule2078, rule2079, rule2080, rule2081, rule2082, rule2083, rule2084, rule2085, rule2086, rule2087, rule2088, rule2089, rule2090, rule2091, rule2092, rule2093, rule2094, rule2095, rule2096, rule2097, rule2098, rule2099, rule2100, rule2101, rule2102, rule2103, rule2104, rule2105, rule2106, rule2107, rule2108, rule2109, rule2110, rule2111, rule2112, rule2113, rule2114, rule2115, rule2116, rule2117, rule2118, rule2119, rule2120, rule2121, rule2122, rule2123, rule2124, rule2125, rule2126, rule2127, rule2128, rule2129, rule2130, rule2131, rule2132, rule2133, rule2134, rule2135, rule2136, rule2137, rule2138, rule2139, rule2140, rule2141, rule2142, rule2143, rule2144, rule2145, rule2146, rule2147, rule2148, rule2149, rule2150, rule2151, rule2152, rule2153, rule2154, rule2155, rule2156, rule2157, rule2158, rule2159, rule2160, rule2161, rule2162, rule2163, ]
b8abda9dc2cbb0c543ffc3df7c4ac241bd7960ff079a67688b17942eb39da8d9
''' This code is automatically generated. Never edit it manually. For details of generating the code see `rubi_parsing_guide.md` in `parsetools`. ''' from sympy.external import import_module matchpy = import_module("matchpy") from sympy.utilities.decorator import doctest_depends_on if matchpy: from matchpy import Pattern, ReplacementRule, CustomConstraint, is_match from sympy.integrals.rubi.utility_function import ( Int, Sum, Set, With, Module, Scan, MapAnd, FalseQ, ZeroQ, NegativeQ, NonzeroQ, FreeQ, NFreeQ, List, Log, PositiveQ, PositiveIntegerQ, NegativeIntegerQ, IntegerQ, IntegersQ, ComplexNumberQ, PureComplexNumberQ, RealNumericQ, PositiveOrZeroQ, NegativeOrZeroQ, FractionOrNegativeQ, NegQ, Equal, Unequal, IntPart, FracPart, RationalQ, ProductQ, SumQ, NonsumQ, Subst, First, Rest, SqrtNumberQ, SqrtNumberSumQ, LinearQ, Sqrt, ArcCosh, Coefficient, Denominator, Hypergeometric2F1, Not, Simplify, FractionalPart, IntegerPart, AppellF1, EllipticPi, EllipticE, EllipticF, ArcTan, ArcCot, ArcCoth, ArcTanh, ArcSin, ArcSinh, ArcCos, ArcCsc, ArcSec, ArcCsch, ArcSech, Sinh, Tanh, Cosh, Sech, Csch, Coth, LessEqual, Less, Greater, GreaterEqual, FractionQ, IntLinearcQ, Expand, IndependentQ, PowerQ, IntegerPowerQ, PositiveIntegerPowerQ, FractionalPowerQ, AtomQ, ExpQ, LogQ, Head, MemberQ, TrigQ, SinQ, CosQ, TanQ, CotQ, SecQ, CscQ, Sin, Cos, Tan, Cot, Sec, Csc, HyperbolicQ, SinhQ, CoshQ, TanhQ, CothQ, SechQ, CschQ, InverseTrigQ, SinCosQ, SinhCoshQ, LeafCount, Numerator, NumberQ, NumericQ, Length, ListQ, Im, Re, InverseHyperbolicQ, InverseFunctionQ, TrigHyperbolicFreeQ, InverseFunctionFreeQ, RealQ, EqQ, FractionalPowerFreeQ, ComplexFreeQ, PolynomialQ, FactorSquareFree, PowerOfLinearQ, Exponent, QuadraticQ, LinearPairQ, BinomialParts, TrinomialParts, PolyQ, EvenQ, OddQ, PerfectSquareQ, NiceSqrtAuxQ, NiceSqrtQ, Together, PosAux, PosQ, CoefficientList, ReplaceAll, ExpandLinearProduct, GCD, ContentFactor, NumericFactor, NonnumericFactors, MakeAssocList, GensymSubst, KernelSubst, ExpandExpression, Apart, SmartApart, MatchQ, PolynomialQuotientRemainder, FreeFactors, NonfreeFactors, RemoveContentAux, RemoveContent, FreeTerms, NonfreeTerms, ExpandAlgebraicFunction, CollectReciprocals, ExpandCleanup, AlgebraicFunctionQ, Coeff, LeadTerm, RemainingTerms, LeadFactor, RemainingFactors, LeadBase, LeadDegree, Numer, Denom, hypergeom, Expon, MergeMonomials, PolynomialDivide, BinomialQ, TrinomialQ, GeneralizedBinomialQ, GeneralizedTrinomialQ, FactorSquareFreeList, PerfectPowerTest, SquareFreeFactorTest, RationalFunctionQ, RationalFunctionFactors, NonrationalFunctionFactors, Reverse, RationalFunctionExponents, RationalFunctionExpand, ExpandIntegrand, SimplerQ, SimplerSqrtQ, SumSimplerQ, BinomialDegree, TrinomialDegree, CancelCommonFactors, SimplerIntegrandQ, GeneralizedBinomialDegree, GeneralizedBinomialParts, GeneralizedTrinomialDegree, GeneralizedTrinomialParts, MonomialQ, MonomialSumQ, MinimumMonomialExponent, MonomialExponent, LinearMatchQ, PowerOfLinearMatchQ, QuadraticMatchQ, CubicMatchQ, BinomialMatchQ, TrinomialMatchQ, GeneralizedBinomialMatchQ, GeneralizedTrinomialMatchQ, QuotientOfLinearsMatchQ, PolynomialTermQ, PolynomialTerms, NonpolynomialTerms, PseudoBinomialParts, NormalizePseudoBinomial, PseudoBinomialPairQ, PseudoBinomialQ, PolynomialGCD, PolyGCD, AlgebraicFunctionFactors, NonalgebraicFunctionFactors, QuotientOfLinearsP, QuotientOfLinearsParts, QuotientOfLinearsQ, Flatten, Sort, AbsurdNumberQ, AbsurdNumberFactors, NonabsurdNumberFactors, SumSimplerAuxQ, Prepend, Drop, CombineExponents, FactorInteger, FactorAbsurdNumber, SubstForInverseFunction, SubstForFractionalPower, SubstForFractionalPowerOfQuotientOfLinears, FractionalPowerOfQuotientOfLinears, SubstForFractionalPowerQ, SubstForFractionalPowerAuxQ, FractionalPowerOfSquareQ, FractionalPowerSubexpressionQ, Apply, FactorNumericGcd, MergeableFactorQ, MergeFactor, MergeFactors, TrigSimplifyQ, TrigSimplify, TrigSimplifyRecur, Order, FactorOrder, Smallest, OrderedQ, MinimumDegree, PositiveFactors, Sign, NonpositiveFactors, PolynomialInAuxQ, PolynomialInQ, ExponentInAux, ExponentIn, PolynomialInSubstAux, PolynomialInSubst, Distrib, DistributeDegree, FunctionOfPower, DivideDegreesOfFactors, MonomialFactor, FullSimplify, FunctionOfLinearSubst, FunctionOfLinear, NormalizeIntegrand, NormalizeIntegrandAux, NormalizeIntegrandFactor, NormalizeIntegrandFactorBase, NormalizeTogether, NormalizeLeadTermSigns, AbsorbMinusSign, NormalizeSumFactors, SignOfFactor, NormalizePowerOfLinear, SimplifyIntegrand, SimplifyTerm, TogetherSimplify, SmartSimplify, SubstForExpn, ExpandToSum, UnifySum, UnifyTerms, UnifyTerm, CalculusQ, FunctionOfInverseLinear, PureFunctionOfSinhQ, PureFunctionOfTanhQ, PureFunctionOfCoshQ, IntegerQuotientQ, OddQuotientQ, EvenQuotientQ, FindTrigFactor, FunctionOfSinhQ, FunctionOfCoshQ, OddHyperbolicPowerQ, FunctionOfTanhQ, FunctionOfTanhWeight, FunctionOfHyperbolicQ, SmartNumerator, SmartDenominator, SubstForAux, ActivateTrig, ExpandTrig, TrigExpand, SubstForTrig, SubstForHyperbolic, InertTrigFreeQ, LCM, SubstForFractionalPowerOfLinear, FractionalPowerOfLinear, InverseFunctionOfLinear, InertTrigQ, InertReciprocalQ, DeactivateTrig, FixInertTrigFunction, DeactivateTrigAux, PowerOfInertTrigSumQ, PiecewiseLinearQ, KnownTrigIntegrandQ, KnownSineIntegrandQ, KnownTangentIntegrandQ, KnownCotangentIntegrandQ, KnownSecantIntegrandQ, TryPureTanSubst, TryTanhSubst, TryPureTanhSubst, AbsurdNumberGCD, AbsurdNumberGCDList, ExpandTrigExpand, ExpandTrigReduce, ExpandTrigReduceAux, NormalizeTrig, TrigToExp, ExpandTrigToExp, TrigReduce, FunctionOfTrig, AlgebraicTrigFunctionQ, FunctionOfHyperbolic, FunctionOfQ, FunctionOfExpnQ, PureFunctionOfSinQ, PureFunctionOfCosQ, PureFunctionOfTanQ, PureFunctionOfCotQ, FunctionOfCosQ, FunctionOfSinQ, OddTrigPowerQ, FunctionOfTanQ, FunctionOfTanWeight, FunctionOfTrigQ, FunctionOfDensePolynomialsQ, FunctionOfLog, PowerVariableExpn, PowerVariableDegree, PowerVariableSubst, EulerIntegrandQ, FunctionOfSquareRootOfQuadratic, SquareRootOfQuadraticSubst, Divides, EasyDQ, ProductOfLinearPowersQ, Rt, NthRoot, AtomBaseQ, SumBaseQ, NegSumBaseQ, AllNegTermQ, SomeNegTermQ, TrigSquareQ, RtAux, TrigSquare, IntSum, IntTerm, Map2, ConstantFactor, SameQ, ReplacePart, CommonFactors, MostMainFactorPosition, FunctionOfExponentialQ, FunctionOfExponential, FunctionOfExponentialFunction, FunctionOfExponentialFunctionAux, FunctionOfExponentialTest, FunctionOfExponentialTestAux, stdev, rubi_test, If, IntQuadraticQ, IntBinomialQ, RectifyTangent, RectifyCotangent, Inequality, Condition, Simp, SimpHelp, SplitProduct, SplitSum, SubstFor, SubstForAux, FresnelS, FresnelC, Erfc, Erfi, Gamma, FunctionOfTrigOfLinearQ, ElementaryFunctionQ, Complex, UnsameQ, _SimpFixFactor, SimpFixFactor, _FixSimplify, FixSimplify, _SimplifyAntiderivativeSum, SimplifyAntiderivativeSum, _SimplifyAntiderivative, SimplifyAntiderivative, _TrigSimplifyAux, TrigSimplifyAux, Cancel, Part, PolyLog, D, Dist, Sum_doit, PolynomialQuotient, Floor, PolynomialRemainder, Factor, PolyLog, CosIntegral, SinIntegral, LogIntegral, SinhIntegral, CoshIntegral, Rule, Erf, PolyGamma, ExpIntegralEi, ExpIntegralE, LogGamma , UtilityOperator, Factorial, Zeta, ProductLog, DerivativeDivides, HypergeometricPFQ, IntHide, OneQ, Null, rubi_exp as exp, rubi_log as log, Discriminant, Negative, Quotient ) from sympy import (Integral, S, sqrt, And, Or, Integer, Float, Mod, I, Abs, simplify, Mul, Add, Pow, sign, EulerGamma) from sympy.integrals.rubi.symbol import WC from sympy.core.symbol import symbols, Symbol from sympy.functions import (sin, cos, tan, cot, csc, sec, sqrt, erf) from sympy.functions.elementary.hyperbolic import (acosh, asinh, atanh, acoth, acsch, asech, cosh, sinh, tanh, coth, sech, csch) from sympy.functions.elementary.trigonometric import (atan, acsc, asin, acot, acos, asec, atan2) from sympy import pi as Pi A_, B_, C_, F_, G_, H_, a_, b_, c_, d_, e_, f_, g_, h_, i_, j_, k_, l_, m_, n_, p_, q_, r_, t_, u_, v_, s_, w_, x_, y_, z_ = [WC(i) for i in 'ABCFGHabcdefghijklmnpqrtuvswxyz'] a1_, a2_, b1_, b2_, c1_, c2_, d1_, d2_, n1_, n2_, e1_, e2_, f1_, f2_, g1_, g2_, n1_, n2_, n3_, Pq_, Pm_, Px_, Qm_, Qr_, Qx_, jn_, mn_, non2_, RFx_, RGx_ = [WC(i) for i in ['a1', 'a2', 'b1', 'b2', 'c1', 'c2', 'd1', 'd2', 'n1', 'n2', 'e1', 'e2', 'f1', 'f2', 'g1', 'g2', 'n1', 'n2', 'n3', 'Pq', 'Pm', 'Px', 'Qm', 'Qr', 'Qx', 'jn', 'mn', 'non2', 'RFx', 'RGx']] i, ii , Pqq, Q, R, r, C, k, u = symbols('i ii Pqq Q R r C k u') _UseGamma = False ShowSteps = False StepCounter = None def trinomial_products(rubi): from sympy.integrals.rubi.constraints import cons46, cons87, cons463, cons38, cons2, cons3, cons7, cons489, cons5, cons45, cons147, cons664, cons4, cons665, cons584, cons666, cons13, cons163, cons667, cons314, cons668, cons462, cons196, cons669, cons670, cons146, cons671, cons672, cons338, cons137, cons226, cons128, cons246, cons673, cons674, cons413, cons675, cons293, cons676, cons677, cons484, cons177, cons678, cons679, cons680, cons585, cons681, cons68, cons69, cons53, cons21, cons501, cons27, cons63, cons502, cons682, cons155, cons683, cons684, cons225, cons56, cons243, cons148, cons244, cons685, cons17, cons686, cons687, cons510, cons688, cons689, cons690, cons529, cons31, cons530, cons691, cons94, cons367, cons356, cons500, cons692, cons693, cons694, cons695, cons696, cons697, cons698, cons699, cons700, cons701, cons541, cons23, cons702, cons552, cons553, cons554, cons220, cons48, cons50, cons703, cons704, cons256, cons257, cons279, cons221, cons280, cons395, cons396, cons705, cons706, cons707, cons708, cons709, cons85, cons710, cons711, cons712, cons713, cons586, cons386, cons149, cons714, cons43, cons715, cons448, cons716, cons400, cons717, cons718, cons719, cons347, cons564, cons720, cons268, cons721, cons722, cons723, cons724, cons725, cons726, cons727, cons728, cons125, cons208, cons52, cons593, cons729, cons730, cons731, cons652, cons732, cons654, cons34, cons35, cons733, cons18, cons734, cons464, cons735, cons168, cons267, cons736, cons737, cons738, cons739, cons740, cons81, cons434, cons741, cons742, cons743, cons744, cons611, cons403, cons745, cons746, cons747, cons748, cons749, cons750, cons751, cons752, cons753, cons754, cons755, cons756, cons757, cons758, cons759, cons760, cons606, cons761, cons762, cons763, cons764, cons765, cons766, cons767, cons768, cons769, cons770, cons771, cons772, cons773, cons774, cons775, cons776, cons777, cons778, cons779, cons780, cons781, cons782, cons783, cons784, cons785, cons786, cons787, cons788, cons789, cons790, cons791, cons792, cons793, cons794, cons795, cons796, cons797 pattern1076 = Pattern(Integral((a_ + x_**n_*WC('b', S(1)) + x_**WC('n2', S(1))*WC('c', S(1)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons46, cons87, cons463, cons38) def replacement1076(p, b, n2, c, a, n, x): rubi.append(1076) return Int(x**(S(2)*n*p)*(a*x**(-S(2)*n) + b*x**(-n) + c)**p, x) rule1076 = ReplacementRule(pattern1076, replacement1076) def With1077(p, b, n2, c, a, n, x): k = Denominator(n) rubi.append(1077) return Dist(k, Subst(Int(x**(k + S(-1))*(a + b*x**(k*n) + c*x**(S(2)*k*n))**p, x), x, x**(S(1)/k)), x) pattern1077 = Pattern(Integral((a_ + x_**n_*WC('b', S(1)) + x_**WC('n2', S(1))*WC('c', S(1)))**p_, x_), cons2, cons3, cons7, cons5, cons46, cons489) rule1077 = ReplacementRule(pattern1077, With1077) pattern1078 = Pattern(Integral((a_ + x_**n_*WC('b', S(1)) + x_**WC('n2', S(1))*WC('c', S(1)))**p_, x_), cons2, cons3, cons7, cons4, cons5, cons46, cons45, cons147, cons664) def replacement1078(p, b, n2, c, a, n, x): rubi.append(1078) return Simp(x*(S(2)*a + b*x**n)*(a + b*x**n + c*x**(S(2)*n))**p/(S(2)*a), x) rule1078 = ReplacementRule(pattern1078, replacement1078) pattern1079 = Pattern(Integral((a_ + x_**n_*WC('b', S(1)) + x_**WC('n2', S(1))*WC('c', S(1)))**p_, x_), cons2, cons3, cons7, cons4, cons5, cons46, cons45, cons147, cons665, cons584) def replacement1079(p, b, n2, c, a, n, x): rubi.append(1079) return -Simp(x*(a + b*x**n + c*x**(S(2)*n))**(p + S(1))/(a*(S(2)*p + S(1))), x) + Simp(x*(S(2)*a + b*x**n)*(a + b*x**n + c*x**(S(2)*n))**p/(S(2)*a*(n + S(1))), x) rule1079 = ReplacementRule(pattern1079, replacement1079) pattern1080 = Pattern(Integral((a_ + x_**n_*WC('b', S(1)) + x_**WC('n2', S(1))*WC('c', S(1)))**p_, x_), cons2, cons3, cons7, cons4, cons46, cons45, cons666, cons13, cons163, cons667) def replacement1080(p, b, n2, c, a, n, x): rubi.append(1080) return Dist(sqrt(a + b*x**n + c*x**(S(2)*n))/(b + S(2)*c*x**n), Int((b + S(2)*c*x**n)*(a + b*x**n + c*x**(S(2)*n))**(p + S(-1)/2), x), x) rule1080 = ReplacementRule(pattern1080, replacement1080) pattern1081 = Pattern(Integral((a_ + x_**n_*WC('b', S(1)) + x_**WC('n2', S(1))*WC('c', S(1)))**p_, x_), cons2, cons3, cons7, cons4, cons46, cons45, cons666, cons13, cons163, cons314) def replacement1081(p, b, n2, c, a, n, x): rubi.append(1081) return Dist((S(4)*c)**(-IntPart(p))*(b + S(2)*c*x**n)**(-S(2)*FracPart(p))*(a + b*x**n + c*x**(S(2)*n))**FracPart(p), Int((b + S(2)*c*x**n)**(S(2)*p), x), x) rule1081 = ReplacementRule(pattern1081, replacement1081) pattern1082 = Pattern(Integral(sqrt(a_ + x_**n2_*WC('c', S(1)) + x_**n_*WC('b', S(1))), x_), cons2, cons3, cons7, cons4, cons46, cons45, cons584, cons668, cons462) def replacement1082(b, n2, c, n, a, x): rubi.append(1082) return Simp(x*sqrt(a + b*x**n + c*x**(S(2)*n))/(n + S(1)), x) + Simp(b*n*x*sqrt(a + b*x**n + c*x**(S(2)*n))/((b + S(2)*c*x**n)*(n + S(1))), x) rule1082 = ReplacementRule(pattern1082, replacement1082) pattern1083 = Pattern(Integral((a_ + x_**n_*WC('b', S(1)) + x_**WC('n2', S(1))*WC('c', S(1)))**p_, x_), cons2, cons3, cons7, cons5, cons46, cons45, cons147, cons196) def replacement1083(p, b, n2, c, a, n, x): rubi.append(1083) return -Subst(Int((a + b*x**(-n) + c*x**(-S(2)*n))**p/x**S(2), x), x, S(1)/x) rule1083 = ReplacementRule(pattern1083, replacement1083) pattern1084 = Pattern(Integral((a_ + x_**n_*WC('b', S(1)) + x_**WC('n2', S(1))*WC('c', S(1)))**p_, x_), cons2, cons3, cons7, cons4, cons46, cons45, cons147, cons669, cons670, cons13, cons146) def replacement1084(p, b, n2, c, a, n, x): rubi.append(1084) return Dist(S(2)*a*n**S(2)*p*(S(2)*p + S(-1))/((S(2)*n*p + S(1))*(n*(S(2)*p + S(-1)) + S(1))), Int((a + b*x**n + c*x**(S(2)*n))**(p + S(-1)), x), x) + Simp(x*(a + b*x**n + c*x**(S(2)*n))**p/(S(2)*n*p + S(1)), x) + Simp(n*p*x*(S(2)*a + b*x**n)*(a + b*x**n + c*x**(S(2)*n))**(p + S(-1))/((S(2)*n*p + S(1))*(n*(S(2)*p + S(-1)) + S(1))), x) rule1084 = ReplacementRule(pattern1084, replacement1084) pattern1085 = Pattern(Integral((a_ + x_**n_*WC('b', S(1)) + x_**WC('n2', S(1))*WC('c', S(1)))**p_, x_), cons2, cons3, cons7, cons4, cons46, cons45, cons147, cons671, cons672, cons338, cons137) def replacement1085(p, b, n2, c, a, n, x): rubi.append(1085) return Dist((S(2)*n*(p + S(1)) + S(1))*(n*(S(2)*p + S(1)) + S(1))/(S(2)*a*n**S(2)*(p + S(1))*(S(2)*p + S(1))), Int((a + b*x**n + c*x**(S(2)*n))**(p + S(1)), x), x) - Simp(x*(S(2)*a + b*x**n)*(a + b*x**n + c*x**(S(2)*n))**p/(S(2)*a*n*(S(2)*p + S(1))), x) - Simp(x*(n*(S(2)*p + S(1)) + S(1))*(a + b*x**n + c*x**(S(2)*n))**(p + S(1))/(S(2)*a*n**S(2)*(p + S(1))*(S(2)*p + S(1))), x) rule1085 = ReplacementRule(pattern1085, replacement1085) pattern1086 = Pattern(Integral((a_ + x_**n_*WC('b', S(1)) + x_**WC('n2', S(1))*WC('c', S(1)))**p_, x_), cons2, cons3, cons7, cons4, cons5, cons46, cons45, cons147) def replacement1086(p, b, n2, c, a, n, x): rubi.append(1086) return Dist(c**(-IntPart(p))*(b/S(2) + c*x**n)**(-S(2)*FracPart(p))*(a + b*x**n + c*x**(S(2)*n))**FracPart(p), Int((b/S(2) + c*x**n)**(S(2)*p), x), x) rule1086 = ReplacementRule(pattern1086, replacement1086) pattern1087 = Pattern(Integral((a_ + x_**n_*WC('b', S(1)) + x_**WC('n2', S(1))*WC('c', S(1)))**p_, x_), cons2, cons3, cons7, cons5, cons46, cons196) def replacement1087(p, b, n2, c, a, n, x): rubi.append(1087) return -Subst(Int((a + b*x**(-n) + c*x**(-S(2)*n))**p/x**S(2), x), x, S(1)/x) rule1087 = ReplacementRule(pattern1087, replacement1087) pattern1088 = Pattern(Integral((a_ + x_**n_*WC('b', S(1)) + x_**WC('n2', S(1))*WC('c', S(1)))**p_, x_), cons2, cons3, cons7, cons4, cons46, cons226, cons128) def replacement1088(p, b, n2, c, a, n, x): rubi.append(1088) return Int(ExpandIntegrand((a + b*x**n + c*x**(S(2)*n))**p, x), x) rule1088 = ReplacementRule(pattern1088, replacement1088) pattern1089 = Pattern(Integral((a_ + x_**n_*WC('b', S(1)) + x_**WC('n2', S(1))*WC('c', S(1)))**p_, x_), cons2, cons3, cons7, cons4, cons46, cons226, cons13, cons163, cons669, cons246, cons673) def replacement1089(p, b, n2, c, a, n, x): rubi.append(1089) return Dist(n*p/(S(2)*n*p + S(1)), Int((S(2)*a + b*x**n)*(a + b*x**n + c*x**(S(2)*n))**(p + S(-1)), x), x) + Simp(x*(a + b*x**n + c*x**(S(2)*n))**p/(S(2)*n*p + S(1)), x) rule1089 = ReplacementRule(pattern1089, replacement1089) pattern1090 = Pattern(Integral((a_ + x_**n_*WC('b', S(1)) + x_**WC('n2', S(1))*WC('c', S(1)))**p_, x_), cons2, cons3, cons7, cons4, cons46, cons226, cons13, cons137, cons246, cons673) def replacement1090(p, b, n2, c, a, n, x): rubi.append(1090) return Dist(S(1)/(a*n*(p + S(1))*(-S(4)*a*c + b**S(2))), Int((a + b*x**n + c*x**(S(2)*n))**(p + S(1))*(-S(2)*a*c + b**S(2) + b*c*x**n*(n*(S(2)*p + S(3)) + S(1)) + n*(p + S(1))*(-S(4)*a*c + b**S(2))), x), x) - Simp(x*(a + b*x**n + c*x**(S(2)*n))**(p + S(1))*(-S(2)*a*c + b**S(2) + b*c*x**n)/(a*n*(p + S(1))*(-S(4)*a*c + b**S(2))), x) rule1090 = ReplacementRule(pattern1090, replacement1090) def With1091(b, n2, c, n, a, x): q = Rt(a/c, S(2)) r = Rt(-b/c + S(2)*q, S(2)) rubi.append(1091) return Dist(1/(2*c*q*r), Int((r - x**(n/2))/(q - r*x**(n/2) + x**n), x), x) + Dist(1/(2*c*q*r), Int((r + x**(n/2))/(q + r*x**(n/2) + x**n), x), x) pattern1091 = Pattern(Integral(S(1)/(a_ + x_**n2_*WC('c', S(1)) + x_**n_*WC('b', S(1))), x_), cons2, cons3, cons7, cons46, cons226, cons674, cons413) rule1091 = ReplacementRule(pattern1091, With1091) def With1092(b, n2, c, n, a, x): q = Rt(-S(4)*a*c + b**S(2), S(2)) rubi.append(1092) return Dist(c/q, Int(S(1)/(b/S(2) + c*x**n - q/S(2)), x), x) - Dist(c/q, Int(S(1)/(b/S(2) + c*x**n + q/S(2)), x), x) pattern1092 = Pattern(Integral(S(1)/(a_ + x_**n2_*WC('c', S(1)) + x_**n_*WC('b', S(1))), x_), cons2, cons3, cons7, cons46, cons226) rule1092 = ReplacementRule(pattern1092, With1092) def With1093(x, c, b, a): q = Rt(-S(4)*a*c + b**S(2), S(2)) rubi.append(1093) return Dist(S(2)*sqrt(-c), Int(S(1)/(sqrt(-b - S(2)*c*x**S(2) + q)*sqrt(b + S(2)*c*x**S(2) + q)), x), x) pattern1093 = Pattern(Integral(S(1)/sqrt(a_ + x_**S(4)*WC('c', S(1)) + x_**S(2)*WC('b', S(1))), x_), cons2, cons3, cons7, cons675, cons293) rule1093 = ReplacementRule(pattern1093, With1093) def With1094(x, c, b, a): q = Rt(c/a, S(4)) rubi.append(1094) return Simp(sqrt((a + b*x**S(2) + c*x**S(4))/(a*(q**S(2)*x**S(2) + S(1))**S(2)))*(q**S(2)*x**S(2) + S(1))*EllipticF(S(2)*ArcTan(q*x), -b*q**S(2)/(S(4)*c) + S(1)/2)/(S(2)*q*sqrt(a + b*x**S(2) + c*x**S(4))), x) pattern1094 = Pattern(Integral(S(1)/sqrt(a_ + x_**S(4)*WC('c', S(1)) + x_**S(2)*WC('b', S(1))), x_), cons2, cons3, cons7, cons675, cons676, cons677) rule1094 = ReplacementRule(pattern1094, With1094) def With1095(x, c, b, a): if isinstance(x, (int, Integer, float, Float)): return False q = Rt(-S(4)*a*c + b**S(2), S(2)) if IntegerQ(q): return True return False pattern1095 = Pattern(Integral(S(1)/sqrt(a_ + x_**S(4)*WC('c', S(1)) + x_**S(2)*WC('b', S(1))), x_), cons2, cons3, cons7, cons675, cons484, cons177, CustomConstraint(With1095)) def replacement1095(x, c, b, a): q = Rt(-S(4)*a*c + b**S(2), S(2)) rubi.append(1095) return Simp(sqrt((S(2)*a + x**S(2)*(b + q))/q)*sqrt(-S(2)*a - x**S(2)*(b - q))*EllipticF(asin(sqrt(S(2))*x/sqrt((S(2)*a + x**S(2)*(b + q))/q)), (b + q)/(S(2)*q))/(S(2)*sqrt(-a)*sqrt(a + b*x**S(2) + c*x**S(4))), x) rule1095 = ReplacementRule(pattern1095, replacement1095) def With1096(x, c, b, a): q = Rt(-S(4)*a*c + b**S(2), S(2)) rubi.append(1096) return Simp(sqrt((S(2)*a + x**S(2)*(b + q))/q)*sqrt((S(2)*a + x**S(2)*(b - q))/(S(2)*a + x**S(2)*(b + q)))*EllipticF(asin(sqrt(S(2))*x/sqrt((S(2)*a + x**S(2)*(b + q))/q)), (b + q)/(S(2)*q))/(S(2)*sqrt(a/(S(2)*a + x**S(2)*(b + q)))*sqrt(a + b*x**S(2) + c*x**S(4))), x) pattern1096 = Pattern(Integral(S(1)/sqrt(a_ + x_**S(4)*WC('c', S(1)) + x_**S(2)*WC('b', S(1))), x_), cons2, cons3, cons7, cons675, cons484, cons177) rule1096 = ReplacementRule(pattern1096, With1096) def With1097(x, c, b, a): if isinstance(x, (int, Integer, float, Float)): return False q = Rt(-S(4)*a*c + b**S(2), S(2)) if And(PosQ((b + q)/a), Not(And(PosQ((b - q)/a), SimplerSqrtQ((b - q)/(S(2)*a), (b + q)/(S(2)*a))))): return True return False pattern1097 = Pattern(Integral(S(1)/sqrt(a_ + x_**S(4)*WC('c', S(1)) + x_**S(2)*WC('b', S(1))), x_), cons2, cons3, cons7, cons675, CustomConstraint(With1097)) def replacement1097(x, c, b, a): q = Rt(-S(4)*a*c + b**S(2), S(2)) rubi.append(1097) return Simp(sqrt((S(2)*a + x**S(2)*(b - q))/(S(2)*a + x**S(2)*(b + q)))*(S(2)*a + x**S(2)*(b + q))*EllipticF(ArcTan(x*Rt((b + q)/(S(2)*a), S(2))), S(2)*q/(b + q))/(S(2)*a*sqrt(a + b*x**S(2) + c*x**S(4))*Rt((b + q)/(S(2)*a), S(2))), x) rule1097 = ReplacementRule(pattern1097, replacement1097) def With1098(x, c, b, a): if isinstance(x, (int, Integer, float, Float)): return False q = Rt(-S(4)*a*c + b**S(2), S(2)) if PosQ((b - q)/a): return True return False pattern1098 = Pattern(Integral(S(1)/sqrt(a_ + x_**S(4)*WC('c', S(1)) + x_**S(2)*WC('b', S(1))), x_), cons2, cons3, cons7, cons675, CustomConstraint(With1098)) def replacement1098(x, c, b, a): q = Rt(-S(4)*a*c + b**S(2), S(2)) rubi.append(1098) return Simp(sqrt((S(2)*a + x**S(2)*(b + q))/(S(2)*a + x**S(2)*(b - q)))*(S(2)*a + x**S(2)*(b - q))*EllipticF(ArcTan(x*Rt((b - q)/(S(2)*a), S(2))), -S(2)*q/(b - q))/(S(2)*a*sqrt(a + b*x**S(2) + c*x**S(4))*Rt((b - q)/(S(2)*a), S(2))), x) rule1098 = ReplacementRule(pattern1098, replacement1098) def With1099(x, c, b, a): if isinstance(x, (int, Integer, float, Float)): return False q = Rt(-S(4)*a*c + b**S(2), S(2)) if And(NegQ((b + q)/a), Not(And(NegQ((b - q)/a), SimplerSqrtQ(-(b - q)/(S(2)*a), -(b + q)/(S(2)*a))))): return True return False pattern1099 = Pattern(Integral(S(1)/sqrt(a_ + x_**S(4)*WC('c', S(1)) + x_**S(2)*WC('b', S(1))), x_), cons2, cons3, cons7, cons675, CustomConstraint(With1099)) def replacement1099(x, c, b, a): q = Rt(-S(4)*a*c + b**S(2), S(2)) rubi.append(1099) return Simp(sqrt(S(1) + x**S(2)*(b - q)/(S(2)*a))*sqrt(S(1) + x**S(2)*(b + q)/(S(2)*a))*EllipticF(asin(x*Rt(-(b + q)/(S(2)*a), S(2))), (b - q)/(b + q))/(sqrt(a + b*x**S(2) + c*x**S(4))*Rt(-(b + q)/(S(2)*a), S(2))), x) rule1099 = ReplacementRule(pattern1099, replacement1099) def With1100(x, c, b, a): if isinstance(x, (int, Integer, float, Float)): return False q = Rt(-S(4)*a*c + b**S(2), S(2)) if NegQ((b - q)/a): return True return False pattern1100 = Pattern(Integral(S(1)/sqrt(a_ + x_**S(4)*WC('c', S(1)) + x_**S(2)*WC('b', S(1))), x_), cons2, cons3, cons7, cons675, CustomConstraint(With1100)) def replacement1100(x, c, b, a): q = Rt(-S(4)*a*c + b**S(2), S(2)) rubi.append(1100) return Simp(sqrt(S(1) + x**S(2)*(b - q)/(S(2)*a))*sqrt(S(1) + x**S(2)*(b + q)/(S(2)*a))*EllipticF(asin(x*Rt(-(b - q)/(S(2)*a), S(2))), (b + q)/(b - q))/(sqrt(a + b*x**S(2) + c*x**S(4))*Rt(-(b - q)/(S(2)*a), S(2))), x) rule1100 = ReplacementRule(pattern1100, replacement1100) def With1101(x, c, b, a): q = Rt(c/a, S(4)) rubi.append(1101) return Simp(sqrt((a + b*x**S(2) + c*x**S(4))/(a*(q**S(2)*x**S(2) + S(1))**S(2)))*(q**S(2)*x**S(2) + S(1))*EllipticF(S(2)*ArcTan(q*x), -b*q**S(2)/(S(4)*c) + S(1)/2)/(S(2)*q*sqrt(a + b*x**S(2) + c*x**S(4))), x) pattern1101 = Pattern(Integral(S(1)/sqrt(a_ + x_**S(4)*WC('c', S(1)) + x_**S(2)*WC('b', S(1))), x_), cons2, cons3, cons7, cons226, cons678) rule1101 = ReplacementRule(pattern1101, With1101) def With1102(x, c, b, a): q = Rt(-S(4)*a*c + b**S(2), S(2)) rubi.append(1102) return Dist(sqrt(S(2)*c*x**S(2)/(b - q) + S(1))*sqrt(S(2)*c*x**S(2)/(b + q) + S(1))/sqrt(a + b*x**S(2) + c*x**S(4)), Int(S(1)/(sqrt(S(2)*c*x**S(2)/(b - q) + S(1))*sqrt(S(2)*c*x**S(2)/(b + q) + S(1))), x), x) pattern1102 = Pattern(Integral(S(1)/sqrt(a_ + x_**S(4)*WC('c', S(1)) + x_**S(2)*WC('b', S(1))), x_), cons2, cons3, cons7, cons226, cons679) rule1102 = ReplacementRule(pattern1102, With1102) pattern1103 = Pattern(Integral((a_ + x_**n_*WC('b', S(1)) + x_**WC('n2', S(1))*WC('c', S(1)))**p_, x_), cons2, cons3, cons7, cons4, cons5, cons680) def replacement1103(p, b, n2, c, a, n, x): rubi.append(1103) return Dist(a**IntPart(p)*(S(2)*c*x**n/(b - Rt(-S(4)*a*c + b**S(2), S(2))) + S(1))**(-FracPart(p))*(S(2)*c*x**n/(b + Rt(-S(4)*a*c + b**S(2), S(2))) + S(1))**(-FracPart(p))*(a + b*x**n + c*x**(S(2)*n))**FracPart(p), Int((S(2)*c*x**n/(b - sqrt(-S(4)*a*c + b**S(2))) + S(1))**p*(S(2)*c*x**n/(b + sqrt(-S(4)*a*c + b**S(2))) + S(1))**p, x), x) rule1103 = ReplacementRule(pattern1103, replacement1103) pattern1104 = Pattern(Integral((a_ + x_**mn_*WC('b', S(1)) + x_**WC('n', S(1))*WC('c', S(1)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons4, cons585, cons38, cons681) def replacement1104(mn, p, b, c, n, a, x): rubi.append(1104) return Int(x**(-n*p)*(a*x**n + b + c*x**(S(2)*n))**p, x) rule1104 = ReplacementRule(pattern1104, replacement1104) pattern1105 = Pattern(Integral((a_ + x_**mn_*WC('b', S(1)) + x_**WC('n', S(1))*WC('c', S(1)))**p_, x_), cons2, cons3, cons7, cons4, cons5, cons585, cons147, cons681) def replacement1105(mn, p, b, c, n, a, x): rubi.append(1105) return Dist(x**(n*FracPart(p))*(a + b*x**(-n) + c*x**n)**FracPart(p)*(a*x**n + b + c*x**(S(2)*n))**(-FracPart(p)), Int(x**(-n*p)*(a*x**n + b + c*x**(S(2)*n))**p, x), x) rule1105 = ReplacementRule(pattern1105, replacement1105) pattern1106 = Pattern(Integral((a_ + u_**n_*WC('b', S(1)) + u_**WC('n2', S(1))*WC('c', S(1)))**p_, x_), cons2, cons3, cons7, cons4, cons5, cons46, cons68, cons69) def replacement1106(p, u, b, n2, c, a, n, x): rubi.append(1106) return Dist(S(1)/Coefficient(u, x, S(1)), Subst(Int((a + b*x**n + c*x**(S(2)*n))**p, x), x, u), x) rule1106 = ReplacementRule(pattern1106, replacement1106) pattern1107 = Pattern(Integral(x_**WC('m', S(1))*(a_ + x_**n_*WC('b', S(1)) + x_**WC('n2', S(1))*WC('c', S(1)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons21, cons4, cons5, cons680, cons53) def replacement1107(p, m, b, n2, c, a, n, x): rubi.append(1107) return Dist(S(1)/n, Subst(Int((a + b*x + c*x**S(2))**p, x), x, x**n), x) rule1107 = ReplacementRule(pattern1107, replacement1107) pattern1108 = Pattern(Integral((x_*WC('d', S(1)))**WC('m', S(1))*(a_ + x_**n_*WC('b', S(1)) + x_**WC('n2', S(1))*WC('c', S(1)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons21, cons4, cons680, cons128, cons501) def replacement1108(p, m, b, n2, d, c, a, n, x): rubi.append(1108) return Int(ExpandIntegrand((d*x)**m*(a + b*x**n + c*x**(S(2)*n))**p, x), x) rule1108 = ReplacementRule(pattern1108, replacement1108) pattern1109 = Pattern(Integral(x_**WC('m', S(1))*(a_ + x_**n_*WC('b', S(1)) + x_**WC('n2', S(1))*WC('c', S(1)))**p_, x_), cons2, cons3, cons7, cons21, cons4, cons680, cons63, cons502) def replacement1109(p, m, b, n2, c, a, n, x): rubi.append(1109) return Int(x**(m + S(2)*n*p)*(a*x**(-S(2)*n) + b*x**(-n) + c)**p, x) rule1109 = ReplacementRule(pattern1109, replacement1109) pattern1110 = Pattern(Integral(sqrt(a_ + x_**n_*WC('b', S(1)) + x_**WC('n2', S(1))*WC('c', S(1)))/x_, x_), cons2, cons3, cons7, cons4, cons680, cons45) def replacement1110(b, n2, c, a, n, x): rubi.append(1110) return Simp(sqrt(a + b*x**n + c*x**(S(2)*n))/n, x) + Simp(b*sqrt(a + b*x**n + c*x**(S(2)*n))*log(x)/(b + S(2)*c*x**n), x) rule1110 = ReplacementRule(pattern1110, replacement1110) pattern1111 = Pattern(Integral((a_ + x_**n_*WC('b', S(1)) + x_**WC('n2', S(1))*WC('c', S(1)))**p_/x_, x_), cons2, cons3, cons7, cons4, cons680, cons45, cons13, cons146) def replacement1111(p, b, n2, c, a, n, x): rubi.append(1111) return Dist(a, Int((a + b*x**n + c*x**(S(2)*n))**(p + S(-1))/x, x), x) + Simp((a + b*x**n + c*x**(S(2)*n))**p/(S(2)*n*p), x) + Simp((S(2)*a + b*x**n)*(a + b*x**n + c*x**(S(2)*n))**(p + S(-1))/(S(2)*n*(S(2)*p + S(-1))), x) rule1111 = ReplacementRule(pattern1111, replacement1111) pattern1112 = Pattern(Integral((a_ + x_**n_*WC('b', S(1)) + x_**WC('n2', S(1))*WC('c', S(1)))**p_/x_, x_), cons2, cons3, cons7, cons4, cons680, cons45, cons13, cons137) def replacement1112(p, b, n2, c, a, n, x): rubi.append(1112) return Dist(S(1)/a, Int((a + b*x**n + c*x**(S(2)*n))**(p + S(1))/x, x), x) - Simp((a + b*x**n + c*x**(S(2)*n))**(p + S(1))/(S(2)*a*n*(p + S(1))), x) - Simp((S(2)*a + b*x**n)*(a + b*x**n + c*x**(S(2)*n))**p/(S(2)*a*n*(S(2)*p + S(1))), x) rule1112 = ReplacementRule(pattern1112, replacement1112) pattern1113 = Pattern(Integral((a_ + x_**n_*WC('b', S(1)) + x_**WC('n2', S(1))*WC('c', S(1)))**p_/x_, x_), cons2, cons3, cons7, cons4, cons5, cons680, cons45, cons147) def replacement1113(p, b, n2, c, a, n, x): rubi.append(1113) return Dist(c**(-IntPart(p))*(b/S(2) + c*x**n)**(-S(2)*FracPart(p))*(a + b*x**n + c*x**(S(2)*n))**FracPart(p), Int((b/S(2) + c*x**n)**(S(2)*p)/x, x), x) rule1113 = ReplacementRule(pattern1113, replacement1113) pattern1114 = Pattern(Integral((x_*WC('d', S(1)))**WC('m', S(1))*(a_ + x_**n_*WC('b', S(1)) + x_**WC('n2', S(1))*WC('c', S(1)))**p_, x_), cons2, cons3, cons7, cons27, cons21, cons4, cons5, cons680, cons45, cons682) def replacement1114(p, m, b, n2, d, c, a, n, x): rubi.append(1114) return Simp((d*x)**(m + S(1))*(b + S(2)*c*x**n)*(a + b*x**n + c*x**(S(2)*n))**p/(b*d*(m + S(1))), x) rule1114 = ReplacementRule(pattern1114, replacement1114) pattern1115 = Pattern(Integral((x_*WC('d', S(1)))**WC('m', S(1))*sqrt(a_ + x_**n_*WC('b', S(1)) + x_**WC('n2', S(1))*WC('c', S(1))), x_), cons2, cons3, cons7, cons27, cons21, cons4, cons680, cons45, cons155) def replacement1115(m, b, n2, d, c, a, n, x): rubi.append(1115) return Dist(sqrt(a + b*x**n + c*x**(S(2)*n))/(b + S(2)*c*x**n), Int((d*x)**m*(b + S(2)*c*x**n), x), x) rule1115 = ReplacementRule(pattern1115, replacement1115) pattern1116 = Pattern(Integral((x_*WC('d', S(1)))**WC('m', S(1))*sqrt(a_ + x_**n_*WC('b', S(1)) + x_**WC('n2', S(1))*WC('c', S(1))), x_), cons2, cons3, cons7, cons27, cons21, cons4, cons680, cons45, cons683) def replacement1116(m, b, n2, d, c, a, n, x): rubi.append(1116) return Simp((d*x)**(m + S(1))*sqrt(a + b*x**n + c*x**(S(2)*n))/(d*(m + n + S(1))), x) + Simp(b*n*(d*x)**(m + S(1))*sqrt(a + b*x**n + c*x**(S(2)*n))/(d*(b + S(2)*c*x**n)*(m + S(1))*(m + n + S(1))), x) rule1116 = ReplacementRule(pattern1116, replacement1116) pattern1117 = Pattern(Integral(x_**WC('m', S(1))/sqrt(a_ + x_**n_*WC('b', S(1)) + x_**WC('n2', S(1))*WC('c', S(1))), x_), cons2, cons3, cons7, cons21, cons4, cons680, cons45, cons155) def replacement1117(m, b, n2, c, a, n, x): rubi.append(1117) return -Dist(b/(S(2)*a), Int(S(1)/(x*sqrt(a + b*x**n + c*x**(S(2)*n))), x), x) - Simp(x**(m + S(1))*sqrt(a + b*x**n + c*x**(S(2)*n))/(a*n), x) rule1117 = ReplacementRule(pattern1117, replacement1117) pattern1118 = Pattern(Integral((x_*WC('d', S(1)))**WC('m', S(1))*(a_ + x_**n_*WC('b', S(1)) + x_**WC('n2', S(1))*WC('c', S(1)))**p_, x_), cons2, cons3, cons7, cons27, cons21, cons4, cons5, cons680, cons45, cons684, cons225) def replacement1118(p, m, b, n2, d, c, a, n, x): rubi.append(1118) return -Simp((d*x)**(m + S(1))*(S(2)*a + b*x**n)*(a + b*x**n + c*x**(S(2)*n))**p/(S(2)*a*d*n*(S(2)*p + S(1))), x) + Simp((d*x)**(m + S(1))*(a + b*x**n + c*x**(S(2)*n))**(p + S(1))/(S(2)*a*d*n*(p + S(1))*(S(2)*p + S(1))), x) rule1118 = ReplacementRule(pattern1118, replacement1118) pattern1119 = Pattern(Integral(x_**WC('m', S(1))*(a_ + x_**n_*WC('b', S(1)) + x_**WC('n2', S(1))*WC('c', S(1)))**p_, x_), cons2, cons3, cons7, cons21, cons4, cons5, cons680, cons45, cons56, cons243) def replacement1119(p, m, b, n2, c, a, n, x): rubi.append(1119) return -Dist(b/(S(2)*c), Int(x**(n + S(-1))*(a + b*x**n + c*x**(S(2)*n))**p, x), x) + Simp((a + b*x**n + c*x**(S(2)*n))**(p + S(1))/(S(2)*c*n*(p + S(1))), x) rule1119 = ReplacementRule(pattern1119, replacement1119) pattern1120 = Pattern(Integral((x_*WC('d', S(1)))**WC('m', S(1))*(a_ + x_**n_*WC('b', S(1)) + x_**WC('n2', S(1))*WC('c', S(1)))**p_, x_), cons2, cons3, cons7, cons27, cons680, cons45, cons148, cons244, cons146, cons685, cons246, cons17) def replacement1120(p, m, b, n2, d, c, a, n, x): rubi.append(1120) return -Dist(b*d**(-n)*n**S(2)*p*(S(2)*p + S(-1))/((m + S(1))*(m + S(2)*n*p + S(1))), Int((d*x)**(m + n)*(a + b*x**n + c*x**(S(2)*n))**(p + S(-1)), x), x) + Simp((d*x)**(m + S(1))*(a + b*x**n + c*x**(S(2)*n))**p/(d*(m + S(2)*n*p + S(1))), x) + Simp(n*p*(d*x)**(m + S(1))*(S(2)*a + b*x**n)*(a + b*x**n + c*x**(S(2)*n))**(p + S(-1))/(d*(m + S(1))*(m + S(2)*n*p + S(1))), x) rule1120 = ReplacementRule(pattern1120, replacement1120) pattern1121 = Pattern(Integral((x_*WC('d', S(1)))**WC('m', S(1))*(a_ + x_**n_*WC('b', S(1)) + x_**WC('n2', S(1))*WC('c', S(1)))**p_, x_), cons2, cons3, cons7, cons27, cons680, cons45, cons148, cons244, cons146, cons686, cons687, cons246, cons17) def replacement1121(p, m, b, n2, d, c, a, n, x): rubi.append(1121) return Dist(S(2)*c*d**(-S(2)*n)*n**S(2)*p*(S(2)*p + S(-1))/((m + S(1))*(m + n + S(1))), Int((d*x)**(m + S(2)*n)*(a + b*x**n + c*x**(S(2)*n))**(p + S(-1)), x), x) + Simp((d*x)**(m + S(1))*(a + b*x**n + c*x**(S(2)*n))**p*(m - n*(S(2)*p + S(-1)) + S(1))/(d*(m + S(1))*(m + n + S(1))), x) + Simp(n*p*(d*x)**(m + S(1))*(S(2)*a + b*x**n)*(a + b*x**n + c*x**(S(2)*n))**(p + S(-1))/(d*(m + S(1))*(m + n + S(1))), x) rule1121 = ReplacementRule(pattern1121, replacement1121) pattern1122 = Pattern(Integral((x_*WC('d', S(1)))**WC('m', S(1))*(a_ + x_**n_*WC('b', S(1)) + x_**WC('n2', S(1))*WC('c', S(1)))**p_, x_), cons2, cons3, cons7, cons27, cons21, cons680, cons45, cons148, cons13, cons146, cons510, cons688, cons687, cons689, cons246) def replacement1122(p, m, b, n2, d, c, a, n, x): rubi.append(1122) return Dist(S(2)*a*n**S(2)*p*(S(2)*p + S(-1))/((m + S(2)*n*p + S(1))*(m + n*(S(2)*p + S(-1)) + S(1))), Int((d*x)**m*(a + b*x**n + c*x**(S(2)*n))**(p + S(-1)), x), x) + Simp((d*x)**(m + S(1))*(a + b*x**n + c*x**(S(2)*n))**p/(d*(m + S(2)*n*p + S(1))), x) + Simp(n*p*(d*x)**(m + S(1))*(S(2)*a + b*x**n)*(a + b*x**n + c*x**(S(2)*n))**(p + S(-1))/(d*(m + S(2)*n*p + S(1))*(m + n*(S(2)*p + S(-1)) + S(1))), x) rule1122 = ReplacementRule(pattern1122, replacement1122) pattern1123 = Pattern(Integral((x_*WC('d', S(1)))**WC('m', S(1))*(a_ + x_**n_*WC('b', S(1)) + x_**WC('n2', S(1))*WC('c', S(1)))**p_, x_), cons2, cons3, cons7, cons27, cons680, cons45, cons148, cons244, cons137, cons690, cons246) def replacement1123(p, m, b, n2, d, c, a, n, x): rubi.append(1123) return -Dist(d**n*(m - n + S(1))*(m + n*(S(2)*p + S(1)) + S(1))/(b*n**S(2)*(p + S(1))*(S(2)*p + S(1))), Int((d*x)**(m - n)*(a + b*x**n + c*x**(S(2)*n))**(p + S(1)), x), x) - Simp((d*x)**(m + S(1))*(b + S(2)*c*x**n)*(a + b*x**n + c*x**(S(2)*n))**p/(b*d*n*(S(2)*p + S(1))), x) + Simp(d**(n + S(-1))*(d*x)**(m - n + S(1))*(a + b*x**n + c*x**(S(2)*n))**(p + S(1))*(m + n*(S(2)*p + S(1)) + S(1))/(b*n**S(2)*(p + S(1))*(S(2)*p + S(1))), x) rule1123 = ReplacementRule(pattern1123, replacement1123) pattern1124 = Pattern(Integral((x_*WC('d', S(1)))**WC('m', S(1))*(a_ + x_**n_*WC('b', S(1)) + x_**WC('n2', S(1))*WC('c', S(1)))**p_, x_), cons2, cons3, cons7, cons27, cons680, cons45, cons148, cons244, cons137, cons529, cons246) def replacement1124(p, m, b, n2, d, c, a, n, x): rubi.append(1124) return Dist(d**(S(2)*n)*(m - S(2)*n + S(1))*(m - n + S(1))/(S(2)*c*n**S(2)*(p + S(1))*(S(2)*p + S(1))), Int((d*x)**(m - S(2)*n)*(a + b*x**n + c*x**(S(2)*n))**(p + S(1)), x), x) - Simp(d**(S(2)*n + S(-1))*(d*x)**(m - S(2)*n + S(1))*(S(2)*a + b*x**n)*(a + b*x**n + c*x**(S(2)*n))**p/(S(2)*c*n*(S(2)*p + S(1))), x) - Simp(d**(S(2)*n + S(-1))*(d*x)**(m - S(2)*n + S(1))*(a + b*x**n + c*x**(S(2)*n))**(p + S(1))*(m - S(2)*n*p - S(3)*n + S(1))/(S(2)*c*n**S(2)*(p + S(1))*(S(2)*p + S(1))), x) rule1124 = ReplacementRule(pattern1124, replacement1124) pattern1125 = Pattern(Integral((x_*WC('d', S(1)))**WC('m', S(1))*(a_ + x_**n_*WC('b', S(1)) + x_**WC('n2', S(1))*WC('c', S(1)))**p_, x_), cons2, cons3, cons7, cons27, cons21, cons680, cons45, cons148, cons244, cons137, cons246) def replacement1125(p, m, b, n2, d, c, a, n, x): rubi.append(1125) return Dist((m + S(2)*n*(p + S(1)) + S(1))*(m + n*(S(2)*p + S(1)) + S(1))/(S(2)*a*n**S(2)*(p + S(1))*(S(2)*p + S(1))), Int((d*x)**m*(a + b*x**n + c*x**(S(2)*n))**(p + S(1)), x), x) - Simp((d*x)**(m + S(1))*(S(2)*a + b*x**n)*(a + b*x**n + c*x**(S(2)*n))**p/(S(2)*a*d*n*(S(2)*p + S(1))), x) - Simp((d*x)**(m + S(1))*(a + b*x**n + c*x**(S(2)*n))**(p + S(1))*(m + n*(S(2)*p + S(1)) + S(1))/(S(2)*a*d*n**S(2)*(p + S(1))*(S(2)*p + S(1))), x) rule1125 = ReplacementRule(pattern1125, replacement1125) pattern1126 = Pattern(Integral((x_*WC('d', S(1)))**WC('m', S(1))*(a_ + x_**n_*WC('b', S(1)) + x_**WC('n2', S(1))*WC('c', S(1)))**p_, x_), cons2, cons3, cons7, cons27, cons5, cons680, cons45, cons148, cons31, cons530, cons510, cons691) def replacement1126(p, m, b, n2, d, c, a, n, x): rubi.append(1126) return -Dist(b*d**n*(m - n + S(1))/(S(2)*c*(m + S(2)*n*p + S(1))), Int((d*x)**(m - n)*(a + b*x**n + c*x**(S(2)*n))**p, x), x) + Simp(d**(n + S(-1))*(d*x)**(m - n + S(1))*(b + S(2)*c*x**n)*(a + b*x**n + c*x**(S(2)*n))**p/(S(2)*c*(m + S(2)*n*p + S(1))), x) rule1126 = ReplacementRule(pattern1126, replacement1126) pattern1127 = Pattern(Integral((x_*WC('d', S(1)))**WC('m', S(1))*(a_ + x_**n_*WC('b', S(1)) + x_**WC('n2', S(1))*WC('c', S(1)))**p_, x_), cons2, cons3, cons7, cons27, cons5, cons680, cons45, cons148, cons31, cons94, cons691) def replacement1127(p, m, b, n2, d, c, a, n, x): rubi.append(1127) return -Dist(S(2)*c*d**(-n)*(m + n*(S(2)*p + S(1)) + S(1))/(b*(m + S(1))), Int((d*x)**(m + n)*(a + b*x**n + c*x**(S(2)*n))**p, x), x) + Simp((d*x)**(m + S(1))*(b + S(2)*c*x**n)*(a + b*x**n + c*x**(S(2)*n))**p/(b*d*(m + S(1))), x) rule1127 = ReplacementRule(pattern1127, replacement1127) pattern1128 = Pattern(Integral(x_**WC('m', S(1))*(a_ + x_**n_*WC('b', S(1)) + x_**WC('n2', S(1))*WC('c', S(1)))**p_, x_), cons2, cons3, cons7, cons5, cons680, cons45, cons196, cons17) def replacement1128(p, m, b, n2, c, a, n, x): rubi.append(1128) return -Subst(Int(x**(-m + S(-2))*(a + b*x**(-n) + c*x**(-S(2)*n))**p, x), x, S(1)/x) rule1128 = ReplacementRule(pattern1128, replacement1128) def With1129(p, m, b, n2, d, c, a, n, x): k = Denominator(m) rubi.append(1129) return -Dist(k/d, Subst(Int(x**(-k*(m + S(1)) + S(-1))*(a + b*d**(-n)*x**(-k*n) + c*d**(-S(2)*n)*x**(-S(2)*k*n))**p, x), x, (d*x)**(-S(1)/k)), x) pattern1129 = Pattern(Integral((x_*WC('d', S(1)))**WC('m', S(1))*(a_ + x_**n_*WC('b', S(1)) + x_**WC('n2', S(1))*WC('c', S(1)))**p_, x_), cons2, cons3, cons7, cons27, cons5, cons680, cons45, cons196, cons367) rule1129 = ReplacementRule(pattern1129, With1129) pattern1130 = Pattern(Integral((x_*WC('d', S(1)))**m_*(a_ + x_**n_*WC('b', S(1)) + x_**WC('n2', S(1))*WC('c', S(1)))**p_, x_), cons2, cons3, cons7, cons27, cons21, cons5, cons680, cons45, cons196, cons356) def replacement1130(p, m, b, n2, d, c, a, n, x): rubi.append(1130) return -Dist(d**IntPart(m)*(d*x)**FracPart(m)*(S(1)/x)**FracPart(m), Subst(Int(x**(-m + S(-2))*(a + b*x**(-n) + c*x**(-S(2)*n))**p, x), x, S(1)/x), x) rule1130 = ReplacementRule(pattern1130, replacement1130) pattern1131 = Pattern(Integral((x_*WC('d', S(1)))**WC('m', S(1))*(a_ + x_**n_*WC('b', S(1)) + x_**WC('n2', S(1))*WC('c', S(1)))**p_, x_), cons2, cons3, cons7, cons27, cons21, cons4, cons5, cons680, cons45, cons147) def replacement1131(p, m, b, n2, d, c, a, n, x): rubi.append(1131) return Dist(c**(-IntPart(p))*(b/S(2) + c*x**n)**(-S(2)*FracPart(p))*(a + b*x**n + c*x**(S(2)*n))**FracPart(p), Int((d*x)**m*(b/S(2) + c*x**n)**(S(2)*p), x), x) rule1131 = ReplacementRule(pattern1131, replacement1131) pattern1132 = Pattern(Integral(x_**WC('m', S(1))*(a_ + x_**n_*WC('b', S(1)) + x_**WC('n2', S(1))*WC('c', S(1)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons21, cons4, cons5, cons680, cons226, cons500) def replacement1132(p, m, b, n2, c, a, n, x): rubi.append(1132) return Dist(S(1)/n, Subst(Int(x**(S(-1) + (m + S(1))/n)*(a + b*x + c*x**S(2))**p, x), x, x**n), x) rule1132 = ReplacementRule(pattern1132, replacement1132) pattern1133 = Pattern(Integral((d_*x_)**WC('m', S(1))*(a_ + x_**n_*WC('b', S(1)) + x_**WC('n2', S(1))*WC('c', S(1)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons21, cons4, cons5, cons680, cons226, cons500) def replacement1133(p, m, b, n2, d, c, a, n, x): rubi.append(1133) return Dist(d**IntPart(m)*x**(-FracPart(m))*(d*x)**FracPart(m), Int(x**m*(a + b*x**n + c*x**(S(2)*n))**p, x), x) rule1133 = ReplacementRule(pattern1133, replacement1133) def With1134(p, m, b, n2, c, a, n, x): if isinstance(x, (int, Integer, float, Float)): return False k = GCD(m + S(1), n) if Unequal(k, S(1)): return True return False pattern1134 = Pattern(Integral(x_**WC('m', S(1))*(a_ + x_**n_*WC('b', S(1)) + x_**WC('n2', S(1))*WC('c', S(1)))**p_, x_), cons2, cons3, cons7, cons5, cons680, cons226, cons148, cons17, CustomConstraint(With1134)) def replacement1134(p, m, b, n2, c, a, n, x): k = GCD(m + S(1), n) rubi.append(1134) return Dist(S(1)/k, Subst(Int(x**(S(-1) + (m + S(1))/k)*(a + b*x**(n/k) + c*x**(S(2)*n/k))**p, x), x, x**k), x) rule1134 = ReplacementRule(pattern1134, replacement1134) def With1135(p, m, b, n2, d, c, a, n, x): k = Denominator(m) rubi.append(1135) return Dist(k/d, Subst(Int(x**(k*(m + S(1)) + S(-1))*(a + b*d**(-n)*x**(k*n) + c*d**(-S(2)*n)*x**(S(2)*k*n))**p, x), x, (d*x)**(S(1)/k)), x) pattern1135 = Pattern(Integral((x_*WC('d', S(1)))**m_*(a_ + x_**n_*WC('b', S(1)) + x_**WC('n2', S(1))*WC('c', S(1)))**p_, x_), cons2, cons3, cons7, cons27, cons5, cons680, cons226, cons148, cons367, cons38) rule1135 = ReplacementRule(pattern1135, With1135) pattern1136 = Pattern(Integral((x_*WC('d', S(1)))**WC('m', S(1))*(a_ + x_**n_*WC('b', S(1)) + x_**WC('n2', S(1))*WC('c', S(1)))**p_, x_), cons2, cons3, cons7, cons27, cons680, cons226, cons148, cons244, cons163, cons530, cons692, cons693, cons694) def replacement1136(p, m, b, n2, d, c, a, n, x): rubi.append(1136) return -Dist(d**n*n*p/(c*(m + S(2)*n*p + S(1))*(m + n*(S(2)*p + S(-1)) + S(1))), Int((d*x)**(m - n)*(a + b*x**n + c*x**(S(2)*n))**(p + S(-1))*Simp(a*b*(m - n + S(1)) - x**n*(S(2)*a*c*(m + n*(S(2)*p + S(-1)) + S(1)) - b**S(2)*(m + n*(p + S(-1)) + S(1))), x), x), x) + Simp(d**(n + S(-1))*(d*x)**(m - n + S(1))*(b*n*p + c*x**n*(m + n*(S(2)*p + S(-1)) + S(1)))*(a + b*x**n + c*x**(S(2)*n))**p/(c*(m + S(2)*n*p + S(1))*(m + n*(S(2)*p + S(-1)) + S(1))), x) rule1136 = ReplacementRule(pattern1136, replacement1136) pattern1137 = Pattern(Integral((x_*WC('d', S(1)))**WC('m', S(1))*(a_ + x_**n_*WC('b', S(1)) + x_**WC('n2', S(1))*WC('c', S(1)))**p_, x_), cons2, cons3, cons7, cons27, cons680, cons226, cons148, cons244, cons163, cons94, cons694) def replacement1137(p, m, b, n2, d, c, a, n, x): rubi.append(1137) return -Dist(d**(-n)*n*p/(m + S(1)), Int((d*x)**(m + n)*(b + S(2)*c*x**n)*(a + b*x**n + c*x**(S(2)*n))**(p + S(-1)), x), x) + Simp((d*x)**(m + S(1))*(a + b*x**n + c*x**(S(2)*n))**p/(d*(m + S(1))), x) rule1137 = ReplacementRule(pattern1137, replacement1137) pattern1138 = Pattern(Integral((x_*WC('d', S(1)))**WC('m', S(1))*(a_ + x_**n_*WC('b', S(1)) + x_**WC('n2', S(1))*WC('c', S(1)))**p_, x_), cons2, cons3, cons7, cons27, cons21, cons680, cons226, cons148, cons13, cons163, cons510, cons694) def replacement1138(p, m, b, n2, d, c, a, n, x): rubi.append(1138) return Dist(n*p/(m + S(2)*n*p + S(1)), Int((d*x)**m*(S(2)*a + b*x**n)*(a + b*x**n + c*x**(S(2)*n))**(p + S(-1)), x), x) + Simp((d*x)**(m + S(1))*(a + b*x**n + c*x**(S(2)*n))**p/(d*(m + S(2)*n*p + S(1))), x) rule1138 = ReplacementRule(pattern1138, replacement1138) pattern1139 = Pattern(Integral((x_*WC('d', S(1)))**WC('m', S(1))*(a_ + x_**n_*WC('b', S(1)) + x_**WC('n2', S(1))*WC('c', S(1)))**p_, x_), cons2, cons3, cons7, cons27, cons680, cons226, cons148, cons244, cons137, cons690, cons694) def replacement1139(p, m, b, n2, d, c, a, n, x): rubi.append(1139) return -Dist(d**n/(n*(p + S(1))*(-S(4)*a*c + b**S(2))), Int((d*x)**(m - n)*(b*(m - n + S(1)) + S(2)*c*x**n*(m + S(2)*n*(p + S(1)) + S(1)))*(a + b*x**n + c*x**(S(2)*n))**(p + S(1)), x), x) + Simp(d**(n + S(-1))*(d*x)**(m - n + S(1))*(b + S(2)*c*x**n)*(a + b*x**n + c*x**(S(2)*n))**(p + S(1))/(n*(p + S(1))*(-S(4)*a*c + b**S(2))), x) rule1139 = ReplacementRule(pattern1139, replacement1139) pattern1140 = Pattern(Integral((x_*WC('d', S(1)))**WC('m', S(1))*(a_ + x_**n_*WC('b', S(1)) + x_**WC('n2', S(1))*WC('c', S(1)))**p_, x_), cons2, cons3, cons7, cons27, cons680, cons226, cons148, cons244, cons137, cons529, cons694) def replacement1140(p, m, b, n2, d, c, a, n, x): rubi.append(1140) return Dist(d**(S(2)*n)/(n*(p + S(1))*(-S(4)*a*c + b**S(2))), Int((d*x)**(m - S(2)*n)*(S(2)*a*(m - S(2)*n + S(1)) + b*x**n*(m + n*(S(2)*p + S(1)) + S(1)))*(a + b*x**n + c*x**(S(2)*n))**(p + S(1)), x), x) - Simp(d**(S(2)*n + S(-1))*(d*x)**(m - S(2)*n + S(1))*(S(2)*a + b*x**n)*(a + b*x**n + c*x**(S(2)*n))**(p + S(1))/(n*(p + S(1))*(-S(4)*a*c + b**S(2))), x) rule1140 = ReplacementRule(pattern1140, replacement1140) pattern1141 = Pattern(Integral((x_*WC('d', S(1)))**WC('m', S(1))*(a_ + x_**n_*WC('b', S(1)) + x_**WC('n2', S(1))*WC('c', S(1)))**p_, x_), cons2, cons3, cons7, cons27, cons21, cons680, cons226, cons148, cons13, cons137, cons694) def replacement1141(p, m, b, n2, d, c, a, n, x): rubi.append(1141) return Dist(S(1)/(a*n*(p + S(1))*(-S(4)*a*c + b**S(2))), Int((d*x)**m*(a + b*x**n + c*x**(S(2)*n))**(p + S(1))*Simp(-S(2)*a*c*(m + S(2)*n*(p + S(1)) + S(1)) + b**S(2)*(m + n*(p + S(1)) + S(1)) + b*c*x**n*(m + S(2)*n*p + S(3)*n + S(1)), x), x), x) - Simp((d*x)**(m + S(1))*(a + b*x**n + c*x**(S(2)*n))**(p + S(1))*(-S(2)*a*c + b**S(2) + b*c*x**n)/(a*d*n*(p + S(1))*(-S(4)*a*c + b**S(2))), x) rule1141 = ReplacementRule(pattern1141, replacement1141) pattern1142 = Pattern(Integral((x_*WC('d', S(1)))**WC('m', S(1))*(a_ + x_**n_*WC('b', S(1)) + x_**WC('n2', S(1))*WC('c', S(1)))**p_, x_), cons2, cons3, cons7, cons27, cons5, cons680, cons226, cons148, cons31, cons529, cons510, cons694) def replacement1142(p, m, b, n2, d, c, a, n, x): rubi.append(1142) return -Dist(d**(S(2)*n)/(c*(m + S(2)*n*p + S(1))), Int((d*x)**(m - S(2)*n)*(a + b*x**n + c*x**(S(2)*n))**p*Simp(a*(m - S(2)*n + S(1)) + b*x**n*(m + n*(p + S(-1)) + S(1)), x), x), x) + Simp(d**(S(2)*n + S(-1))*(d*x)**(m - S(2)*n + S(1))*(a + b*x**n + c*x**(S(2)*n))**(p + S(1))/(c*(m + S(2)*n*p + S(1))), x) rule1142 = ReplacementRule(pattern1142, replacement1142) pattern1143 = Pattern(Integral((x_*WC('d', S(1)))**m_*(a_ + x_**n_*WC('b', S(1)) + x_**WC('n2', S(1))*WC('c', S(1)))**p_, x_), cons2, cons3, cons7, cons27, cons5, cons680, cons226, cons148, cons31, cons94, cons694) def replacement1143(p, m, b, n2, d, c, a, n, x): rubi.append(1143) return -Dist(d**(-n)/(a*(m + S(1))), Int((d*x)**(m + n)*(b*(m + n*(p + S(1)) + S(1)) + c*x**n*(m + S(2)*n*(p + S(1)) + S(1)))*(a + b*x**n + c*x**(S(2)*n))**p, x), x) + Simp((d*x)**(m + S(1))*(a + b*x**n + c*x**(S(2)*n))**(p + S(1))/(a*d*(m + S(1))), x) rule1143 = ReplacementRule(pattern1143, replacement1143) pattern1144 = Pattern(Integral((x_*WC('d', S(1)))**m_/(a_ + x_**n_*WC('b', S(1)) + x_**WC('n2', S(1))*WC('c', S(1))), x_), cons2, cons3, cons7, cons27, cons680, cons226, cons148, cons31, cons94) def replacement1144(m, b, n2, d, c, a, n, x): rubi.append(1144) return -Dist(d**(-n)/a, Int((d*x)**(m + n)*(b + c*x**n)/(a + b*x**n + c*x**(S(2)*n)), x), x) + Simp((d*x)**(m + S(1))/(a*d*(m + S(1))), x) rule1144 = ReplacementRule(pattern1144, replacement1144) pattern1145 = Pattern(Integral(x_**m_/(a_ + x_**n_*WC('b', S(1)) + x_**WC('n2', S(1))*WC('c', S(1))), x_), cons2, cons3, cons7, cons680, cons226, cons148, cons17, cons695) def replacement1145(m, b, n2, c, a, n, x): rubi.append(1145) return Int(PolynomialDivide(x**m, a + b*x**n + c*x**(S(2)*n), x), x) rule1145 = ReplacementRule(pattern1145, replacement1145) pattern1146 = Pattern(Integral((x_*WC('d', S(1)))**m_/(a_ + x_**n_*WC('b', S(1)) + x_**WC('n2', S(1))*WC('c', S(1))), x_), cons2, cons3, cons7, cons27, cons680, cons226, cons148, cons31, cons529) def replacement1146(m, b, n2, d, c, a, n, x): rubi.append(1146) return -Dist(d**(S(2)*n)/c, Int((d*x)**(m - S(2)*n)*(a + b*x**n)/(a + b*x**n + c*x**(S(2)*n)), x), x) + Simp(d**(S(2)*n + S(-1))*(d*x)**(m - S(2)*n + S(1))/(c*(m - S(2)*n + S(1))), x) rule1146 = ReplacementRule(pattern1146, replacement1146) def With1147(x, c, b, a): q = Rt(a/c, S(2)) rubi.append(1147) return -Dist(S(1)/2, Int((q - x**S(2))/(a + b*x**S(2) + c*x**S(4)), x), x) + Dist(S(1)/2, Int((q + x**S(2))/(a + b*x**S(2) + c*x**S(4)), x), x) pattern1147 = Pattern(Integral(x_**S(2)/(a_ + x_**S(4)*WC('c', S(1)) + x_**S(2)*WC('b', S(1))), x_), cons2, cons3, cons7, cons696, cons697) rule1147 = ReplacementRule(pattern1147, With1147) def With1148(m, b, n2, c, a, n, x): q = Rt(a/c, S(2)) r = Rt(-b/c + S(2)*q, S(2)) rubi.append(1148) return -Dist(1/(2*c*r), Int(x**(m - 3*n/2)*(q - r*x**(n/2))/(q - r*x**(n/2) + x**n), x), x) + Dist(1/(2*c*r), Int(x**(m - 3*n/2)*(q + r*x**(n/2))/(q + r*x**(n/2) + x**n), x), x) pattern1148 = Pattern(Integral(x_**WC('m', S(1))/(a_ + x_**n_*WC('b', S(1)) + x_**WC('n2', S(1))*WC('c', S(1))), x_), cons2, cons3, cons7, cons46, cons226, cons698, cons699, cons413) rule1148 = ReplacementRule(pattern1148, With1148) def With1149(m, b, n2, c, a, n, x): q = Rt(a/c, S(2)) r = Rt(-b/c + S(2)*q, S(2)) rubi.append(1149) return Dist(1/(2*c*r), Int(x**(m - n/2)/(q - r*x**(n/2) + x**n), x), x) - Dist(1/(2*c*r), Int(x**(m - n/2)/(q + r*x**(n/2) + x**n), x), x) pattern1149 = Pattern(Integral(x_**WC('m', S(1))/(a_ + x_**n_*WC('b', S(1)) + x_**WC('n2', S(1))*WC('c', S(1))), x_), cons2, cons3, cons7, cons46, cons226, cons698, cons700, cons413) rule1149 = ReplacementRule(pattern1149, With1149) def With1150(m, b, n2, d, c, a, n, x): q = Rt(-S(4)*a*c + b**S(2), S(2)) rubi.append(1150) return -Dist(d**n*(b/q + S(-1))/S(2), Int((d*x)**(m - n)/(b/S(2) + c*x**n - q/S(2)), x), x) + Dist(d**n*(b/q + S(1))/S(2), Int((d*x)**(m - n)/(b/S(2) + c*x**n + q/S(2)), x), x) pattern1150 = Pattern(Integral((x_*WC('d', S(1)))**m_/(a_ + x_**n_*WC('b', S(1)) + x_**WC('n2', S(1))*WC('c', S(1))), x_), cons2, cons3, cons7, cons27, cons680, cons226, cons148, cons31, cons701) rule1150 = ReplacementRule(pattern1150, With1150) def With1151(m, b, n2, d, c, a, n, x): q = Rt(-S(4)*a*c + b**S(2), S(2)) rubi.append(1151) return Dist(c/q, Int((d*x)**m/(b/S(2) + c*x**n - q/S(2)), x), x) - Dist(c/q, Int((d*x)**m/(b/S(2) + c*x**n + q/S(2)), x), x) pattern1151 = Pattern(Integral((x_*WC('d', S(1)))**WC('m', S(1))/(a_ + x_**n_*WC('b', S(1)) + x_**WC('n2', S(1))*WC('c', S(1))), x_), cons2, cons3, cons7, cons27, cons21, cons680, cons226, cons148) rule1151 = ReplacementRule(pattern1151, With1151) def With1152(x, c, b, a): q = Rt(-S(4)*a*c + b**S(2), S(2)) rubi.append(1152) return Dist(S(2)*sqrt(-c), Int(x**S(2)/(sqrt(-b - S(2)*c*x**S(2) + q)*sqrt(b + S(2)*c*x**S(2) + q)), x), x) pattern1152 = Pattern(Integral(x_**S(2)/sqrt(a_ + x_**S(4)*WC('c', S(1)) + x_**S(2)*WC('b', S(1))), x_), cons2, cons3, cons7, cons675, cons293) rule1152 = ReplacementRule(pattern1152, With1152) def With1153(x, c, b, a): q = Rt(c/a, S(2)) rubi.append(1153) return -Dist(S(1)/q, Int((-q*x**S(2) + S(1))/sqrt(a + b*x**S(2) + c*x**S(4)), x), x) + Dist(S(1)/q, Int(S(1)/sqrt(a + b*x**S(2) + c*x**S(4)), x), x) pattern1153 = Pattern(Integral(x_**S(2)/sqrt(a_ + x_**S(4)*WC('c', S(1)) + x_**S(2)*WC('b', S(1))), x_), cons2, cons3, cons7, cons675, cons676, cons677) rule1153 = ReplacementRule(pattern1153, With1153) def With1154(x, c, b, a): q = Rt(-S(4)*a*c + b**S(2), S(2)) rubi.append(1154) return Dist(S(1)/(S(2)*c), Int((b + S(2)*c*x**S(2) - q)/sqrt(a + b*x**S(2) + c*x**S(4)), x), x) - Dist((b - q)/(S(2)*c), Int(S(1)/sqrt(a + b*x**S(2) + c*x**S(4)), x), x) pattern1154 = Pattern(Integral(x_**S(2)/sqrt(a_ + x_**S(4)*WC('c', S(1)) + x_**S(2)*WC('b', S(1))), x_), cons2, cons3, cons7, cons675, cons484, cons177) rule1154 = ReplacementRule(pattern1154, With1154) def With1155(x, c, b, a): if isinstance(x, (int, Integer, float, Float)): return False q = Rt(-S(4)*a*c + b**S(2), S(2)) if And(PosQ((b + q)/a), Not(And(PosQ((b - q)/a), SimplerSqrtQ((b - q)/(S(2)*a), (b + q)/(S(2)*a))))): return True return False pattern1155 = Pattern(Integral(x_**S(2)/sqrt(a_ + x_**S(4)*WC('c', S(1)) + x_**S(2)*WC('b', S(1))), x_), cons2, cons3, cons7, cons675, CustomConstraint(With1155)) def replacement1155(x, c, b, a): q = Rt(-S(4)*a*c + b**S(2), S(2)) rubi.append(1155) return Simp(x*(b + S(2)*c*x**S(2) + q)/(S(2)*c*sqrt(a + b*x**S(2) + c*x**S(4))), x) - Simp(sqrt((S(2)*a + x**S(2)*(b - q))/(S(2)*a + x**S(2)*(b + q)))*(S(2)*a + x**S(2)*(b + q))*EllipticE(ArcTan(x*Rt((b + q)/(S(2)*a), S(2))), S(2)*q/(b + q))*Rt((b + q)/(S(2)*a), S(2))/(S(2)*c*sqrt(a + b*x**S(2) + c*x**S(4))), x) rule1155 = ReplacementRule(pattern1155, replacement1155) def With1156(x, c, b, a): if isinstance(x, (int, Integer, float, Float)): return False q = Rt(-S(4)*a*c + b**S(2), S(2)) if PosQ((b - q)/a): return True return False pattern1156 = Pattern(Integral(x_**S(2)/sqrt(a_ + x_**S(4)*WC('c', S(1)) + x_**S(2)*WC('b', S(1))), x_), cons2, cons3, cons7, cons675, CustomConstraint(With1156)) def replacement1156(x, c, b, a): q = Rt(-S(4)*a*c + b**S(2), S(2)) rubi.append(1156) return Simp(x*(b + S(2)*c*x**S(2) - q)/(S(2)*c*sqrt(a + b*x**S(2) + c*x**S(4))), x) - Simp(sqrt((S(2)*a + x**S(2)*(b + q))/(S(2)*a + x**S(2)*(b - q)))*(S(2)*a + x**S(2)*(b - q))*EllipticE(ArcTan(x*Rt((b - q)/(S(2)*a), S(2))), -S(2)*q/(b - q))*Rt((b - q)/(S(2)*a), S(2))/(S(2)*c*sqrt(a + b*x**S(2) + c*x**S(4))), x) rule1156 = ReplacementRule(pattern1156, replacement1156) def With1157(x, c, b, a): if isinstance(x, (int, Integer, float, Float)): return False q = Rt(-S(4)*a*c + b**S(2), S(2)) if And(NegQ((b + q)/a), Not(And(NegQ((b - q)/a), SimplerSqrtQ(-(b - q)/(S(2)*a), -(b + q)/(S(2)*a))))): return True return False pattern1157 = Pattern(Integral(x_**S(2)/sqrt(a_ + x_**S(4)*WC('c', S(1)) + x_**S(2)*WC('b', S(1))), x_), cons2, cons3, cons7, cons675, CustomConstraint(With1157)) def replacement1157(x, c, b, a): q = Rt(-S(4)*a*c + b**S(2), S(2)) rubi.append(1157) return Dist(S(1)/(S(2)*c), Int((b + S(2)*c*x**S(2) + q)/sqrt(a + b*x**S(2) + c*x**S(4)), x), x) - Dist((b + q)/(S(2)*c), Int(S(1)/sqrt(a + b*x**S(2) + c*x**S(4)), x), x) rule1157 = ReplacementRule(pattern1157, replacement1157) def With1158(x, c, b, a): if isinstance(x, (int, Integer, float, Float)): return False q = Rt(-S(4)*a*c + b**S(2), S(2)) if NegQ((b - q)/a): return True return False pattern1158 = Pattern(Integral(x_**S(2)/sqrt(a_ + x_**S(4)*WC('c', S(1)) + x_**S(2)*WC('b', S(1))), x_), cons2, cons3, cons7, cons675, CustomConstraint(With1158)) def replacement1158(x, c, b, a): q = Rt(-S(4)*a*c + b**S(2), S(2)) rubi.append(1158) return Dist(S(1)/(S(2)*c), Int((b + S(2)*c*x**S(2) - q)/sqrt(a + b*x**S(2) + c*x**S(4)), x), x) - Dist((b - q)/(S(2)*c), Int(S(1)/sqrt(a + b*x**S(2) + c*x**S(4)), x), x) rule1158 = ReplacementRule(pattern1158, replacement1158) def With1159(x, c, b, a): q = Rt(c/a, S(2)) rubi.append(1159) return -Dist(S(1)/q, Int((-q*x**S(2) + S(1))/sqrt(a + b*x**S(2) + c*x**S(4)), x), x) + Dist(S(1)/q, Int(S(1)/sqrt(a + b*x**S(2) + c*x**S(4)), x), x) pattern1159 = Pattern(Integral(x_**S(2)/sqrt(a_ + x_**S(4)*WC('c', S(1)) + x_**S(2)*WC('b', S(1))), x_), cons2, cons3, cons7, cons226, cons678) rule1159 = ReplacementRule(pattern1159, With1159) def With1160(x, c, b, a): q = Rt(-S(4)*a*c + b**S(2), S(2)) rubi.append(1160) return Dist(sqrt(S(2)*c*x**S(2)/(b - q) + S(1))*sqrt(S(2)*c*x**S(2)/(b + q) + S(1))/sqrt(a + b*x**S(2) + c*x**S(4)), Int(x**S(2)/(sqrt(S(2)*c*x**S(2)/(b - q) + S(1))*sqrt(S(2)*c*x**S(2)/(b + q) + S(1))), x), x) pattern1160 = Pattern(Integral(x_**S(2)/sqrt(a_ + x_**S(4)*WC('c', S(1)) + x_**S(2)*WC('b', S(1))), x_), cons2, cons3, cons7, cons226, cons679) rule1160 = ReplacementRule(pattern1160, With1160) pattern1161 = Pattern(Integral(x_**WC('m', S(1))*(a_ + x_**n_*WC('b', S(1)) + x_**WC('n2', S(1))*WC('c', S(1)))**p_, x_), cons2, cons3, cons7, cons5, cons680, cons226, cons196, cons17) def replacement1161(p, m, b, n2, c, a, n, x): rubi.append(1161) return -Subst(Int(x**(-m + S(-2))*(a + b*x**(-n) + c*x**(-S(2)*n))**p, x), x, S(1)/x) rule1161 = ReplacementRule(pattern1161, replacement1161) def With1162(p, m, b, n2, d, c, a, n, x): k = Denominator(m) rubi.append(1162) return -Dist(k/d, Subst(Int(x**(-k*(m + S(1)) + S(-1))*(a + b*d**(-n)*x**(-k*n) + c*d**(-S(2)*n)*x**(-S(2)*k*n))**p, x), x, (d*x)**(-S(1)/k)), x) pattern1162 = Pattern(Integral((x_*WC('d', S(1)))**WC('m', S(1))*(a_ + x_**n_*WC('b', S(1)) + x_**WC('n2', S(1))*WC('c', S(1)))**p_, x_), cons2, cons3, cons7, cons27, cons5, cons680, cons226, cons196, cons367) rule1162 = ReplacementRule(pattern1162, With1162) pattern1163 = Pattern(Integral((x_*WC('d', S(1)))**m_*(a_ + x_**n_*WC('b', S(1)) + x_**WC('n2', S(1))*WC('c', S(1)))**p_, x_), cons2, cons3, cons7, cons27, cons21, cons5, cons680, cons226, cons196, cons356) def replacement1163(p, m, b, n2, d, c, a, n, x): rubi.append(1163) return -Dist(d**IntPart(m)*(d*x)**FracPart(m)*(S(1)/x)**FracPart(m), Subst(Int(x**(-m + S(-2))*(a + b*x**(-n) + c*x**(-S(2)*n))**p, x), x, S(1)/x), x) rule1163 = ReplacementRule(pattern1163, replacement1163) def With1164(p, m, b, n2, c, a, n, x): k = Denominator(n) rubi.append(1164) return Dist(k, Subst(Int(x**(k*(m + S(1)) + S(-1))*(a + b*x**(k*n) + c*x**(S(2)*k*n))**p, x), x, x**(S(1)/k)), x) pattern1164 = Pattern(Integral(x_**WC('m', S(1))*(a_ + x_**n_*WC('b', S(1)) + x_**WC('n2', S(1))*WC('c', S(1)))**p_, x_), cons2, cons3, cons7, cons21, cons5, cons680, cons226, cons489) rule1164 = ReplacementRule(pattern1164, With1164) pattern1165 = Pattern(Integral((d_*x_)**m_*(a_ + x_**n_*WC('b', S(1)) + x_**WC('n2', S(1))*WC('c', S(1)))**p_, x_), cons2, cons3, cons7, cons27, cons21, cons5, cons680, cons226, cons489) def replacement1165(p, m, b, n2, d, c, a, n, x): rubi.append(1165) return Dist(d**IntPart(m)*x**(-FracPart(m))*(d*x)**FracPart(m), Int(x**m*(a + b*x**n + c*x**(S(2)*n))**p, x), x) rule1165 = ReplacementRule(pattern1165, replacement1165) pattern1166 = Pattern(Integral(x_**WC('m', S(1))*(a_ + x_**n_*WC('b', S(1)) + x_**WC('n2', S(1))*WC('c', S(1)))**p_, x_), cons2, cons3, cons7, cons21, cons4, cons5, cons680, cons226, cons541, cons23) def replacement1166(p, m, b, n2, c, a, n, x): rubi.append(1166) return Dist(S(1)/(m + S(1)), Subst(Int((a + b*x**(n/(m + S(1))) + c*x**(S(2)*n/(m + S(1))))**p, x), x, x**(m + S(1))), x) rule1166 = ReplacementRule(pattern1166, replacement1166) pattern1167 = Pattern(Integral((d_*x_)**m_*(a_ + x_**n_*WC('b', S(1)) + x_**WC('n2', S(1))*WC('c', S(1)))**p_, x_), cons2, cons3, cons7, cons27, cons21, cons4, cons5, cons680, cons226, cons541, cons23) def replacement1167(p, m, b, n2, d, c, a, n, x): rubi.append(1167) return Dist(d**IntPart(m)*x**(-FracPart(m))*(d*x)**FracPart(m), Int(x**m*(a + b*x**n + c*x**(S(2)*n))**p, x), x) rule1167 = ReplacementRule(pattern1167, replacement1167) def With1168(m, b, n2, d, c, a, n, x): q = Rt(-S(4)*a*c + b**S(2), S(2)) rubi.append(1168) return Dist(S(2)*c/q, Int((d*x)**m/(b + S(2)*c*x**n - q), x), x) - Dist(S(2)*c/q, Int((d*x)**m/(b + S(2)*c*x**n + q), x), x) pattern1168 = Pattern(Integral((x_*WC('d', S(1)))**WC('m', S(1))/(a_ + x_**n_*WC('b', S(1)) + x_**WC('n2', S(1))*WC('c', S(1))), x_), cons2, cons3, cons7, cons27, cons21, cons4, cons680, cons226) rule1168 = ReplacementRule(pattern1168, With1168) pattern1169 = Pattern(Integral((x_*WC('d', S(1)))**WC('m', S(1))*(a_ + x_**n_*WC('b', S(1)) + x_**WC('n2', S(1))*WC('c', S(1)))**p_, x_), cons2, cons3, cons7, cons27, cons21, cons4, cons680, cons226, cons702) def replacement1169(p, m, b, n2, d, c, a, n, x): rubi.append(1169) return Dist(S(1)/(a*n*(p + S(1))*(-S(4)*a*c + b**S(2))), Int((d*x)**m*(a + b*x**n + c*x**(S(2)*n))**(p + S(1))*Simp(-S(2)*a*c*(m + S(2)*n*(p + S(1)) + S(1)) + b**S(2)*(m + n*(p + S(1)) + S(1)) + b*c*x**n*(m + S(2)*n*p + S(3)*n + S(1)), x), x), x) - Simp((d*x)**(m + S(1))*(a + b*x**n + c*x**(S(2)*n))**(p + S(1))*(-S(2)*a*c + b**S(2) + b*c*x**n)/(a*d*n*(p + S(1))*(-S(4)*a*c + b**S(2))), x) rule1169 = ReplacementRule(pattern1169, replacement1169) pattern1170 = Pattern(Integral((x_*WC('d', S(1)))**WC('m', S(1))*(a_ + x_**n_*WC('b', S(1)) + x_**WC('n2', S(1))*WC('c', S(1)))**p_, x_), cons2, cons3, cons7, cons27, cons21, cons4, cons5, cons680) def replacement1170(p, m, b, n2, d, c, a, n, x): rubi.append(1170) return Dist(a**IntPart(p)*(S(2)*c*x**n/(b - Rt(-S(4)*a*c + b**S(2), S(2))) + S(1))**(-FracPart(p))*(S(2)*c*x**n/(b + Rt(-S(4)*a*c + b**S(2), S(2))) + S(1))**(-FracPart(p))*(a + b*x**n + c*x**(S(2)*n))**FracPart(p), Int((d*x)**m*(S(2)*c*x**n/(b - sqrt(-S(4)*a*c + b**S(2))) + S(1))**p*(S(2)*c*x**n/(b + sqrt(-S(4)*a*c + b**S(2))) + S(1))**p, x), x) rule1170 = ReplacementRule(pattern1170, replacement1170) pattern1171 = Pattern(Integral(x_**WC('m', S(1))*(a_ + x_**mn_*WC('b', S(1)) + x_**WC('n', S(1))*WC('c', S(1)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons21, cons4, cons585, cons38, cons681) def replacement1171(mn, p, m, b, c, n, a, x): rubi.append(1171) return Int(x**(m - n*p)*(a*x**n + b + c*x**(S(2)*n))**p, x) rule1171 = ReplacementRule(pattern1171, replacement1171) pattern1172 = Pattern(Integral(x_**WC('m', S(1))*(a_ + x_**mn_*WC('b', S(1)) + x_**WC('n', S(1))*WC('c', S(1)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons21, cons4, cons5, cons585, cons147, cons681) def replacement1172(mn, p, m, b, c, n, a, x): rubi.append(1172) return Dist(x**(n*FracPart(p))*(a + b*x**(-n) + c*x**n)**FracPart(p)*(a*x**n + b + c*x**(S(2)*n))**(-FracPart(p)), Int(x**(m - n*p)*(a*x**n + b + c*x**(S(2)*n))**p, x), x) rule1172 = ReplacementRule(pattern1172, replacement1172) pattern1173 = Pattern(Integral((d_*x_)**WC('m', S(1))*(a_ + x_**mn_*WC('b', S(1)) + x_**WC('n', S(1))*WC('c', S(1)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons21, cons4, cons5, cons585) def replacement1173(mn, p, m, b, d, c, n, a, x): rubi.append(1173) return Dist(d**IntPart(m)*x**(-FracPart(m))*(d*x)**FracPart(m), Int(x**m*(a + b*x**(-n) + c*x**n)**p, x), x) rule1173 = ReplacementRule(pattern1173, replacement1173) pattern1174 = Pattern(Integral(x_**WC('m', S(1))*(v_**n_*WC('b', S(1)) + v_**WC('n2', S(1))*WC('c', S(1)) + WC('a', S(0)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons4, cons5, cons680, cons552, cons17, cons553) def replacement1174(v, p, m, b, n2, a, c, n, x): rubi.append(1174) return Dist(Coefficient(v, x, S(1))**(-m + S(-1)), Subst(Int(SimplifyIntegrand((x - Coefficient(v, x, S(0)))**m*(a + b*x**n + c*x**(S(2)*n))**p, x), x), x, v), x) rule1174 = ReplacementRule(pattern1174, replacement1174) pattern1175 = Pattern(Integral(u_**WC('m', S(1))*(v_**n_*WC('b', S(1)) + v_**WC('n2', S(1))*WC('c', S(1)) + WC('a', S(0)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons21, cons4, cons5, cons680, cons554) def replacement1175(v, p, u, m, b, n2, c, a, n, x): rubi.append(1175) return Dist(u**m*v**(-m)/Coefficient(v, x, S(1)), Subst(Int(x**m*(a + b*x**n + c*x**(S(2)*n))**p, x), x, v), x) rule1175 = ReplacementRule(pattern1175, replacement1175) pattern1176 = Pattern(Integral((d_ + x_**n_*WC('e', S(1)))**WC('q', S(1))*(a_ + x_**n_*WC('b', S(1)) + x_**WC('n2', S(1))*WC('c', S(1)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons4, cons46, cons220, cons502) def replacement1176(p, b, n2, d, c, a, n, x, q, e): rubi.append(1176) return Int(x**(n*(S(2)*p + q))*(d*x**(-n) + e)**q*(a*x**(-S(2)*n) + b*x**(-n) + c)**p, x) rule1176 = ReplacementRule(pattern1176, replacement1176) pattern1177 = Pattern(Integral((a_ + x_**WC('n2', S(1))*WC('c', S(1)))**WC('p', S(1))*(d_ + x_**n_*WC('e', S(1)))**WC('q', S(1)), x_), cons2, cons7, cons27, cons48, cons4, cons46, cons220, cons502) def replacement1177(p, n2, d, c, a, n, x, q, e): rubi.append(1177) return Int(x**(n*(S(2)*p + q))*(a*x**(-S(2)*n) + c)**p*(d*x**(-n) + e)**q, x) rule1177 = ReplacementRule(pattern1177, replacement1177) pattern1178 = Pattern(Integral((d_ + x_**n_*WC('e', S(1)))**WC('q', S(1))*(x_**n2_*WC('c', S(1)) + x_**n_*WC('b', S(1)) + WC('a', S(0)))**p_, x_), cons2, cons3, cons7, cons27, cons48, cons5, cons50, cons46, cons196) def replacement1178(p, b, n2, d, c, a, n, x, q, e): rubi.append(1178) return -Subst(Int((d + e*x**(-n))**q*(a + b*x**(-n) + c*x**(-S(2)*n))**p/x**S(2), x), x, S(1)/x) rule1178 = ReplacementRule(pattern1178, replacement1178) pattern1179 = Pattern(Integral((a_ + x_**n2_*WC('c', S(1)))**p_*(d_ + x_**n_*WC('e', S(1)))**WC('q', S(1)), x_), cons2, cons7, cons27, cons48, cons5, cons50, cons46, cons196) def replacement1179(p, n2, d, c, n, a, x, q, e): rubi.append(1179) return -Subst(Int((a + c*x**(-S(2)*n))**p*(d + e*x**(-n))**q/x**S(2), x), x, S(1)/x) rule1179 = ReplacementRule(pattern1179, replacement1179) def With1180(p, b, n2, d, a, c, n, x, q, e): g = Denominator(n) rubi.append(1180) return Dist(g, Subst(Int(x**(g + S(-1))*(d + e*x**(g*n))**q*(a + b*x**(g*n) + c*x**(S(2)*g*n))**p, x), x, x**(S(1)/g)), x) pattern1180 = Pattern(Integral((d_ + x_**n_*WC('e', S(1)))**WC('q', S(1))*(x_**n_*WC('b', S(1)) + x_**WC('n2', S(1))*WC('c', S(1)) + WC('a', S(0)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons5, cons50, cons46, cons489) rule1180 = ReplacementRule(pattern1180, With1180) def With1181(p, n2, d, c, a, n, x, q, e): g = Denominator(n) rubi.append(1181) return Dist(g, Subst(Int(x**(g + S(-1))*(a + c*x**(S(2)*g*n))**p*(d + e*x**(g*n))**q, x), x, x**(S(1)/g)), x) pattern1181 = Pattern(Integral((a_ + x_**WC('n2', S(1))*WC('c', S(1)))**WC('p', S(1))*(d_ + x_**n_*WC('e', S(1)))**WC('q', S(1)), x_), cons2, cons7, cons27, cons48, cons5, cons50, cons46, cons489) rule1181 = ReplacementRule(pattern1181, With1181) pattern1182 = Pattern(Integral((d_ + x_**n_*WC('e', S(1)))*(x_**n2_*WC('c', S(1)) + x_**n_*WC('b', S(1)))**p_, x_), cons3, cons7, cons27, cons48, cons4, cons5, cons46, cons147, cons664) def replacement1182(p, b, n2, d, c, n, x, e): rubi.append(1182) return Dist(e/c, Int(x**(-n)*(b*x**n + c*x**(S(2)*n))**(p + S(1)), x), x) + Simp(x**(-S(2)*n*(p + S(1)))*(b*e - c*d)*(b*x**n + c*x**(S(2)*n))**(p + S(1))/(b*c*n*(p + S(1))), x) rule1182 = ReplacementRule(pattern1182, replacement1182) pattern1183 = Pattern(Integral((d_ + x_**n_*WC('e', S(1)))*(x_**n2_*WC('c', S(1)) + x_**n_*WC('b', S(1)))**p_, x_), cons3, cons7, cons27, cons48, cons4, cons5, cons46, cons147, cons671, cons703) def replacement1183(p, b, n2, d, c, n, x, e): rubi.append(1183) return Simp(e*x**(-n + S(1))*(b*x**n + c*x**(S(2)*n))**(p + S(1))/(c*(n*(S(2)*p + S(1)) + S(1))), x) rule1183 = ReplacementRule(pattern1183, replacement1183) pattern1184 = Pattern(Integral((d_ + x_**n_*WC('e', S(1)))*(x_**n2_*WC('c', S(1)) + x_**n_*WC('b', S(1)))**p_, x_), cons3, cons7, cons27, cons48, cons4, cons5, cons46, cons147, cons671, cons704) def replacement1184(p, b, n2, d, c, n, x, e): rubi.append(1184) return -Dist((b*e*(n*p + S(1)) - c*d*(n*(S(2)*p + S(1)) + S(1)))/(c*(n*(S(2)*p + S(1)) + S(1))), Int((b*x**n + c*x**(S(2)*n))**p, x), x) + Simp(e*x**(-n + S(1))*(b*x**n + c*x**(S(2)*n))**(p + S(1))/(c*(n*(S(2)*p + S(1)) + S(1))), x) rule1184 = ReplacementRule(pattern1184, replacement1184) pattern1185 = Pattern(Integral((d_ + x_**n_*WC('e', S(1)))**WC('q', S(1))*(x_**n2_*WC('c', S(1)) + x_**n_*WC('b', S(1)))**p_, x_), cons3, cons7, cons27, cons48, cons4, cons5, cons50, cons46, cons147) def replacement1185(p, b, n2, d, c, n, x, q, e): rubi.append(1185) return Dist(x**(-n*FracPart(p))*(b + c*x**n)**(-FracPart(p))*(b*x**n + c*x**(S(2)*n))**FracPart(p), Int(x**(n*p)*(b + c*x**n)**p*(d + e*x**n)**q, x), x) rule1185 = ReplacementRule(pattern1185, replacement1185) pattern1186 = Pattern(Integral((d_ + x_**n_*WC('e', S(1)))**WC('q', S(1))*(a_ + x_**n2_*WC('c', S(1)) + x_**n_*WC('b', S(1)))**p_, x_), cons2, cons3, cons7, cons27, cons48, cons4, cons5, cons50, cons46, cons45, cons147) def replacement1186(p, b, n2, d, c, n, a, x, q, e): rubi.append(1186) return Dist((S(4)*c)**(-IntPart(p))*(b + S(2)*c*x**n)**(-S(2)*FracPart(p))*(a + b*x**n + c*x**(S(2)*n))**FracPart(p), Int((b + S(2)*c*x**n)**(S(2)*p)*(d + e*x**n)**q, x), x) rule1186 = ReplacementRule(pattern1186, replacement1186) pattern1187 = Pattern(Integral((d_ + x_**n_*WC('e', S(1)))**WC('q', S(1))*(a_ + x_**n2_*WC('c', S(1)) + x_**n_*WC('b', S(1)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons4, cons50, cons46, cons226, cons256, cons38) def replacement1187(p, b, n2, d, c, n, a, x, q, e): rubi.append(1187) return Int((d + e*x**n)**(p + q)*(a/d + c*x**n/e)**p, x) rule1187 = ReplacementRule(pattern1187, replacement1187) pattern1188 = Pattern(Integral((a_ + x_**n2_*WC('c', S(1)))**WC('p', S(1))*(d_ + x_**n_*WC('e', S(1)))**WC('q', S(1)), x_), cons2, cons7, cons27, cons48, cons4, cons50, cons46, cons257, cons38) def replacement1188(p, n2, d, c, n, a, x, q, e): rubi.append(1188) return Int((d + e*x**n)**(p + q)*(a/d + c*x**n/e)**p, x) rule1188 = ReplacementRule(pattern1188, replacement1188) pattern1189 = Pattern(Integral((d_ + x_**n_*WC('e', S(1)))**q_*(a_ + x_**n2_*WC('c', S(1)) + x_**n_*WC('b', S(1)))**p_, x_), cons2, cons3, cons7, cons27, cons48, cons4, cons5, cons50, cons46, cons226, cons256, cons147) def replacement1189(p, b, n2, d, c, n, a, x, q, e): rubi.append(1189) return Dist((d + e*x**n)**(-FracPart(p))*(a/d + c*x**n/e)**(-FracPart(p))*(a + b*x**n + c*x**(S(2)*n))**FracPart(p), Int((d + e*x**n)**(p + q)*(a/d + c*x**n/e)**p, x), x) rule1189 = ReplacementRule(pattern1189, replacement1189) pattern1190 = Pattern(Integral((a_ + x_**n2_*WC('c', S(1)))**p_*(d_ + x_**n_*WC('e', S(1)))**q_, x_), cons2, cons7, cons27, cons48, cons4, cons5, cons50, cons46, cons257, cons147) def replacement1190(p, n2, d, c, n, a, x, q, e): rubi.append(1190) return Dist((a + c*x**(S(2)*n))**FracPart(p)*(d + e*x**n)**(-FracPart(p))*(a/d + c*x**n/e)**(-FracPart(p)), Int((d + e*x**n)**(p + q)*(a/d + c*x**n/e)**p, x), x) rule1190 = ReplacementRule(pattern1190, replacement1190) pattern1191 = Pattern(Integral((d_ + x_**n_*WC('e', S(1)))**WC('q', S(1))*(a_ + x_**n2_*WC('c', S(1)) + x_**n_*WC('b', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons4, cons46, cons226, cons279, cons221) def replacement1191(b, n2, d, c, n, a, x, q, e): rubi.append(1191) return Int(ExpandIntegrand((d + e*x**n)**q*(a + b*x**n + c*x**(S(2)*n)), x), x) rule1191 = ReplacementRule(pattern1191, replacement1191) pattern1192 = Pattern(Integral((a_ + x_**n2_*WC('c', S(1)))*(d_ + x_**n_*WC('e', S(1)))**WC('q', S(1)), x_), cons2, cons7, cons27, cons48, cons4, cons46, cons280, cons221) def replacement1192(n2, d, c, n, a, x, q, e): rubi.append(1192) return Int(ExpandIntegrand((a + c*x**(S(2)*n))*(d + e*x**n)**q, x), x) rule1192 = ReplacementRule(pattern1192, replacement1192) pattern1193 = Pattern(Integral((d_ + x_**n_*WC('e', S(1)))**q_*(a_ + x_**n2_*WC('c', S(1)) + x_**n_*WC('b', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons4, cons46, cons226, cons279, cons395, cons396) def replacement1193(b, n2, d, c, n, a, x, q, e): rubi.append(1193) return Dist(S(1)/(d*e**S(2)*n*(q + S(1))), Int((d + e*x**n)**(q + S(1))*Simp(a*e**S(2)*(n*(q + S(1)) + S(1)) - b*d*e + c*d**S(2) + c*d*e*n*x**n*(q + S(1)), x), x), x) - Simp(x*(d + e*x**n)**(q + S(1))*(a*e**S(2) - b*d*e + c*d**S(2))/(d*e**S(2)*n*(q + S(1))), x) rule1193 = ReplacementRule(pattern1193, replacement1193) pattern1194 = Pattern(Integral((a_ + x_**n2_*WC('c', S(1)))*(d_ + x_**n_*WC('e', S(1)))**q_, x_), cons2, cons7, cons27, cons48, cons4, cons46, cons280, cons395, cons396) def replacement1194(n2, d, c, n, a, x, q, e): rubi.append(1194) return Dist(S(1)/(d*e**S(2)*n*(q + S(1))), Int((d + e*x**n)**(q + S(1))*Simp(a*e**S(2)*(n*(q + S(1)) + S(1)) + c*d**S(2) + c*d*e*n*x**n*(q + S(1)), x), x), x) - Simp(x*(d + e*x**n)**(q + S(1))*(a*e**S(2) + c*d**S(2))/(d*e**S(2)*n*(q + S(1))), x) rule1194 = ReplacementRule(pattern1194, replacement1194) pattern1195 = Pattern(Integral((d_ + x_**n_*WC('e', S(1)))**q_*(a_ + x_**n2_*WC('c', S(1)) + x_**n_*WC('b', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons4, cons50, cons46, cons226, cons279) def replacement1195(b, n2, d, c, n, a, x, q, e): rubi.append(1195) return Dist(S(1)/(e*(n*(q + S(2)) + S(1))), Int((d + e*x**n)**q*(a*e*(n*(q + S(2)) + S(1)) - x**n*(-b*e*(n*(q + S(2)) + S(1)) + c*d*(n + S(1)))), x), x) + Simp(c*x**(n + S(1))*(d + e*x**n)**(q + S(1))/(e*(n*(q + S(2)) + S(1))), x) rule1195 = ReplacementRule(pattern1195, replacement1195) pattern1196 = Pattern(Integral((a_ + x_**n2_*WC('c', S(1)))*(d_ + x_**n_*WC('e', S(1)))**q_, x_), cons2, cons7, cons27, cons48, cons4, cons50, cons46, cons280) def replacement1196(n2, d, c, n, a, x, q, e): rubi.append(1196) return Dist(S(1)/(e*(n*(q + S(2)) + S(1))), Int((d + e*x**n)**q*(a*e*(n*(q + S(2)) + S(1)) - c*d*x**n*(n + S(1))), x), x) + Simp(c*x**(n + S(1))*(d + e*x**n)**(q + S(1))/(e*(n*(q + S(2)) + S(1))), x) rule1196 = ReplacementRule(pattern1196, replacement1196) def With1197(n2, d, c, n, a, x, e): q = Rt(S(2)*d*e, S(2)) rubi.append(1197) return Dist(e**S(2)/(S(2)*c), Int(S(1)/(d + e*x**n - q*x**(n/S(2))), x), x) + Dist(e**S(2)/(S(2)*c), Int(S(1)/(d + e*x**n + q*x**(n/S(2))), x), x) pattern1197 = Pattern(Integral((d_ + x_**n_*WC('e', S(1)))/(a_ + x_**n2_*WC('c', S(1))), x_), cons2, cons7, cons27, cons48, cons46, cons705, cons674, cons706) rule1197 = ReplacementRule(pattern1197, With1197) def With1198(n2, d, c, n, a, x, e): q = Rt(-S(2)*d*e, S(2)) rubi.append(1198) return Dist(d/(S(2)*a), Int((d - q*x**(n/S(2)))/(d - e*x**n - q*x**(n/S(2))), x), x) + Dist(d/(S(2)*a), Int((d + q*x**(n/S(2)))/(d - e*x**n + q*x**(n/S(2))), x), x) pattern1198 = Pattern(Integral((d_ + x_**n_*WC('e', S(1)))/(a_ + x_**n2_*WC('c', S(1))), x_), cons2, cons7, cons27, cons48, cons46, cons705, cons674, cons707) rule1198 = ReplacementRule(pattern1198, With1198) def With1199(d, c, a, x, e): q = Rt(a*c, S(2)) rubi.append(1199) return Dist((-a*e + d*q)/(S(2)*a*c), Int((-c*x**S(2) + q)/(a + c*x**S(4)), x), x) + Dist((a*e + d*q)/(S(2)*a*c), Int((c*x**S(2) + q)/(a + c*x**S(4)), x), x) pattern1199 = Pattern(Integral((d_ + x_**S(2)*WC('e', S(1)))/(a_ + x_**S(4)*WC('c', S(1))), x_), cons2, cons7, cons27, cons48, cons280, cons708, cons697) rule1199 = ReplacementRule(pattern1199, With1199) def With1200(n2, d, c, n, a, x, e): q = Rt(a/c, S(4)) rubi.append(1200) return Dist(sqrt(S(2))/(S(4)*c*q**S(3)), Int((sqrt(S(2))*d*q - x**(n/S(2))*(d - e*q**S(2)))/(q**S(2) - sqrt(S(2))*q*x**(n/S(2)) + x**n), x), x) + Dist(sqrt(S(2))/(S(4)*c*q**S(3)), Int((sqrt(S(2))*d*q + x**(n/S(2))*(d - e*q**S(2)))/(q**S(2) + sqrt(S(2))*q*x**(n/S(2)) + x**n), x), x) pattern1200 = Pattern(Integral((d_ + x_**n_*WC('e', S(1)))/(a_ + x_**n2_*WC('c', S(1))), x_), cons2, cons7, cons27, cons48, cons46, cons280, cons708, cons674, cons697) rule1200 = ReplacementRule(pattern1200, With1200) def With1201(d, c, a, x, e): q = Rt(c/a, S(6)) rubi.append(1201) return Dist(S(1)/(S(6)*a*q**S(2)), Int((S(2)*d*q**S(2) - x*(sqrt(S(3))*d*q**S(3) - e))/(q**S(2)*x**S(2) - sqrt(S(3))*q*x + S(1)), x), x) + Dist(S(1)/(S(6)*a*q**S(2)), Int((S(2)*d*q**S(2) + x*(sqrt(S(3))*d*q**S(3) + e))/(q**S(2)*x**S(2) + sqrt(S(3))*q*x + S(1)), x), x) + Dist(S(1)/(S(3)*a*q**S(2)), Int((d*q**S(2) - e*x)/(q**S(2)*x**S(2) + S(1)), x), x) pattern1201 = Pattern(Integral((d_ + x_**S(3)*WC('e', S(1)))/(a_ + x_**S(6)*WC('c', S(1))), x_), cons2, cons7, cons27, cons48, cons280, cons678) rule1201 = ReplacementRule(pattern1201, With1201) def With1202(n2, d, c, n, a, x, e): q = Rt(-a/c, S(2)) rubi.append(1202) return Dist(d/S(2) - e*q/S(2), Int(S(1)/(a - c*q*x**n), x), x) + Dist(d/S(2) + e*q/S(2), Int(S(1)/(a + c*q*x**n), x), x) pattern1202 = Pattern(Integral((d_ + x_**n_*WC('e', S(1)))/(a_ + x_**n2_*WC('c', S(1))), x_), cons2, cons7, cons27, cons48, cons4, cons46, cons280, cons709, cons85) rule1202 = ReplacementRule(pattern1202, With1202) pattern1203 = Pattern(Integral((d_ + x_**n_*WC('e', S(1)))/(a_ + x_**n2_*WC('c', S(1))), x_), cons2, cons7, cons27, cons48, cons4, cons46, cons280, cons710) def replacement1203(n2, d, c, n, a, x, e): rubi.append(1203) return Dist(d, Int(S(1)/(a + c*x**(S(2)*n)), x), x) + Dist(e, Int(x**n/(a + c*x**(S(2)*n)), x), x) rule1203 = ReplacementRule(pattern1203, replacement1203) def With1204(b, n2, d, c, n, a, x, e): q = Rt(-b/c + S(2)*d/e, S(2)) rubi.append(1204) return Dist(e**S(2)/(S(2)*c), Int(S(1)/(d - e*q*x**(n/S(2)) + e*x**n), x), x) + Dist(e**S(2)/(S(2)*c), Int(S(1)/(d + e*q*x**(n/S(2)) + e*x**n), x), x) pattern1204 = Pattern(Integral((d_ + x_**n_*WC('e', S(1)))/(a_ + x_**n2_*WC('c', S(1)) + x_**n_*WC('b', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons46, cons226, cons705, cons674, cons711) rule1204 = ReplacementRule(pattern1204, With1204) def With1205(b, n2, d, c, n, a, x, e): q = Rt(-S(4)*a*c + b**S(2), S(2)) rubi.append(1205) return Dist(e/S(2) - (-b*e + S(2)*c*d)/(S(2)*q), Int(S(1)/(b/S(2) + c*x**n + q/S(2)), x), x) + Dist(e/S(2) + (-b*e + S(2)*c*d)/(S(2)*q), Int(S(1)/(b/S(2) + c*x**n - q/S(2)), x), x) pattern1205 = Pattern(Integral((d_ + x_**n_*WC('e', S(1)))/(a_ + x_**n2_*WC('c', S(1)) + x_**n_*WC('b', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons4, cons46, cons226, cons705, cons674, cons675) rule1205 = ReplacementRule(pattern1205, With1205) def With1206(b, n2, d, c, n, a, x, e): q = Rt(a/c, S(2)) r = Rt(-b/c + S(2)*q, S(2)) rubi.append(1206) return Dist(1/(2*c*q*r), Int((d*r - x**(n/2)*(d - e*q))/(q - r*x**(n/2) + x**n), x), x) + Dist(1/(2*c*q*r), Int((d*r + x**(n/2)*(d - e*q))/(q + r*x**(n/2) + x**n), x), x) pattern1206 = Pattern(Integral((d_ + x_**n_*WC('e', S(1)))/(a_ + x_**n2_*WC('c', S(1)) + x_**n_*WC('b', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons46, cons226, cons705, cons674, cons712) rule1206 = ReplacementRule(pattern1206, With1206) def With1207(b, n2, d, c, n, a, x, e): q = Rt(-S(4)*a*c + b**S(2), S(2)) rubi.append(1207) return Dist(e/S(2) - (-b*e + S(2)*c*d)/(S(2)*q), Int(S(1)/(b/S(2) + c*x**n + q/S(2)), x), x) + Dist(e/S(2) + (-b*e + S(2)*c*d)/(S(2)*q), Int(S(1)/(b/S(2) + c*x**n - q/S(2)), x), x) pattern1207 = Pattern(Integral((d_ + x_**n_*WC('e', S(1)))/(a_ + x_**n2_*WC('c', S(1)) + x_**n_*WC('b', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons4, cons46, cons226, cons279, cons713) rule1207 = ReplacementRule(pattern1207, With1207) def With1208(b, n2, d, c, n, a, x, e): q = Rt(a/c, S(2)) r = Rt(-b/c + S(2)*q, S(2)) rubi.append(1208) return Dist(1/(2*c*q*r), Int((d*r - x**(n/2)*(d - e*q))/(q - r*x**(n/2) + x**n), x), x) + Dist(1/(2*c*q*r), Int((d*r + x**(n/2)*(d - e*q))/(q + r*x**(n/2) + x**n), x), x) pattern1208 = Pattern(Integral((d_ + x_**n_*WC('e', S(1)))/(a_ + x_**n2_*WC('c', S(1)) + x_**n_*WC('b', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons46, cons226, cons279, cons674, cons413) rule1208 = ReplacementRule(pattern1208, With1208) pattern1209 = Pattern(Integral((d_ + x_**n_*WC('e', S(1)))**q_/(a_ + x_**n2_*WC('c', S(1)) + x_**n_*WC('b', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons4, cons46, cons226, cons279, cons586) def replacement1209(b, n2, d, c, n, a, x, q, e): rubi.append(1209) return Int(ExpandIntegrand((d + e*x**n)**q/(a + b*x**n + c*x**(S(2)*n)), x), x) rule1209 = ReplacementRule(pattern1209, replacement1209) pattern1210 = Pattern(Integral((d_ + x_**n_*WC('e', S(1)))**q_/(a_ + x_**n2_*WC('c', S(1))), x_), cons2, cons7, cons27, cons48, cons4, cons46, cons280, cons586) def replacement1210(n2, d, c, n, a, x, q, e): rubi.append(1210) return Int(ExpandIntegrand((d + e*x**n)**q/(a + c*x**(S(2)*n)), x), x) rule1210 = ReplacementRule(pattern1210, replacement1210) pattern1211 = Pattern(Integral((d_ + x_**n_*WC('e', S(1)))**q_/(a_ + x_**n2_*WC('c', S(1)) + x_**n_*WC('b', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons4, cons46, cons226, cons279, cons386, cons395, cons396) def replacement1211(b, n2, d, c, n, a, x, q, e): rubi.append(1211) return Dist(e**S(2)/(a*e**S(2) - b*d*e + c*d**S(2)), Int((d + e*x**n)**q, x), x) + Dist(S(1)/(a*e**S(2) - b*d*e + c*d**S(2)), Int((d + e*x**n)**(q + S(1))*(-b*e + c*d - c*e*x**n)/(a + b*x**n + c*x**(S(2)*n)), x), x) rule1211 = ReplacementRule(pattern1211, replacement1211) pattern1212 = Pattern(Integral((d_ + x_**n_*WC('e', S(1)))**q_/(a_ + x_**n2_*WC('c', S(1))), x_), cons2, cons7, cons27, cons48, cons4, cons46, cons280, cons386, cons395, cons396) def replacement1212(n2, d, c, n, a, x, q, e): rubi.append(1212) return Dist(c/(a*e**S(2) + c*d**S(2)), Int((d - e*x**n)*(d + e*x**n)**(q + S(1))/(a + c*x**(S(2)*n)), x), x) + Dist(e**S(2)/(a*e**S(2) + c*d**S(2)), Int((d + e*x**n)**q, x), x) rule1212 = ReplacementRule(pattern1212, replacement1212) def With1213(b, n2, d, c, n, a, x, q, e): r = Rt(-S(4)*a*c + b**S(2), S(2)) rubi.append(1213) return Dist(S(2)*c/r, Int((d + e*x**n)**q/(b + S(2)*c*x**n - r), x), x) - Dist(S(2)*c/r, Int((d + e*x**n)**q/(b + S(2)*c*x**n + r), x), x) pattern1213 = Pattern(Integral((d_ + x_**n_*WC('e', S(1)))**q_/(a_ + x_**n2_*WC('c', S(1)) + x_**n_*WC('b', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons4, cons50, cons46, cons226, cons279, cons386) rule1213 = ReplacementRule(pattern1213, With1213) def With1214(n2, d, c, n, a, x, q, e): r = Rt(-a*c, S(2)) rubi.append(1214) return -Dist(c/(S(2)*r), Int((d + e*x**n)**q/(-c*x**n + r), x), x) - Dist(c/(S(2)*r), Int((d + e*x**n)**q/(c*x**n + r), x), x) pattern1214 = Pattern(Integral((d_ + x_**n_*WC('e', S(1)))**q_/(a_ + x_**n2_*WC('c', S(1))), x_), cons2, cons7, cons27, cons48, cons4, cons50, cons46, cons280, cons386) rule1214 = ReplacementRule(pattern1214, With1214) pattern1215 = Pattern(Integral((d_ + x_**n_*WC('e', S(1)))*(a_ + x_**n2_*WC('c', S(1)) + x_**n_*WC('b', S(1)))**p_, x_), cons2, cons3, cons7, cons27, cons48, cons4, cons46, cons226, cons149, cons163, cons669, cons714, cons246, cons673) def replacement1215(p, b, n2, d, c, n, a, x, e): rubi.append(1215) return Dist(n*p/(c*(S(2)*n*p + S(1))*(S(2)*n*p + n + S(1))), Int((a + b*x**n + c*x**(S(2)*n))**(p + S(-1))*Simp(-a*b*e + S(2)*a*c*d*(S(2)*n*p + n + S(1)) + x**n*(S(2)*a*c*e*(S(2)*n*p + S(1)) - b**S(2)*e*(n*p + S(1)) + b*c*d*(S(2)*n*p + n + S(1))), x), x), x) + Simp(x*(a + b*x**n + c*x**(S(2)*n))**p*(b*e*n*p + c*d*(S(2)*n*p + n + S(1)) + c*e*x**n*(S(2)*n*p + S(1)))/(c*(S(2)*n*p + S(1))*(S(2)*n*p + n + S(1))), x) rule1215 = ReplacementRule(pattern1215, replacement1215) pattern1216 = Pattern(Integral((a_ + x_**n2_*WC('c', S(1)))**p_*(d_ + x_**n_*WC('e', S(1))), x_), cons2, cons7, cons27, cons48, cons4, cons46, cons149, cons163, cons669, cons714, cons246, cons673) def replacement1216(p, n2, d, c, n, a, x, e): rubi.append(1216) return Dist(S(2)*a*n*p/((S(2)*n*p + S(1))*(S(2)*n*p + n + S(1))), Int((a + c*x**(S(2)*n))**(p + S(-1))*(d*(S(2)*n*p + n + S(1)) + e*x**n*(S(2)*n*p + S(1))), x), x) + Simp(x*(a + c*x**(S(2)*n))**p*(d*(S(2)*n*p + n + S(1)) + e*x**n*(S(2)*n*p + S(1)))/((S(2)*n*p + S(1))*(S(2)*n*p + n + S(1))), x) rule1216 = ReplacementRule(pattern1216, replacement1216) pattern1217 = Pattern(Integral((d_ + x_**n_*WC('e', S(1)))*(a_ + x_**n2_*WC('c', S(1)) + x_**n_*WC('b', S(1)))**p_, x_), cons2, cons3, cons7, cons27, cons48, cons4, cons46, cons226, cons13, cons137, cons246, cons673) def replacement1217(p, b, n2, d, c, n, a, x, e): rubi.append(1217) return Dist(S(1)/(a*n*(p + S(1))*(-S(4)*a*c + b**S(2))), Int((a + b*x**n + c*x**(S(2)*n))**(p + S(1))*Simp(-a*b*e - S(2)*a*c*d*(S(2)*n*p + S(2)*n + S(1)) + b**S(2)*d*(n*p + n + S(1)) + c*x**n*(-S(2)*a*e + b*d)*(S(2)*n*p + S(3)*n + S(1)), x), x), x) - Simp(x*(a + b*x**n + c*x**(S(2)*n))**(p + S(1))*(-a*b*e - S(2)*a*c*d + b**S(2)*d + c*x**n*(-S(2)*a*e + b*d))/(a*n*(p + S(1))*(-S(4)*a*c + b**S(2))), x) rule1217 = ReplacementRule(pattern1217, replacement1217) pattern1218 = Pattern(Integral((a_ + x_**n2_*WC('c', S(1)))**p_*(d_ + x_**n_*WC('e', S(1))), x_), cons2, cons7, cons27, cons48, cons4, cons46, cons13, cons137, cons246, cons673) def replacement1218(p, n2, d, c, n, a, x, e): rubi.append(1218) return Dist(S(1)/(S(2)*a*n*(p + S(1))), Int((a + c*x**(S(2)*n))**(p + S(1))*(d*(S(2)*n*p + S(2)*n + S(1)) + e*x**n*(S(2)*n*p + S(3)*n + S(1))), x), x) - Simp(x*(a + c*x**(S(2)*n))**(p + S(1))*(d + e*x**n)/(S(2)*a*n*(p + S(1))), x) rule1218 = ReplacementRule(pattern1218, replacement1218) def With1219(b, d, c, a, x, e): q = Rt(-S(4)*a*c + b**S(2), S(2)) rubi.append(1219) return Dist(S(2)*sqrt(-c), Int((d + e*x**S(2))/(sqrt(-b - S(2)*c*x**S(2) + q)*sqrt(b + S(2)*c*x**S(2) + q)), x), x) pattern1219 = Pattern(Integral((d_ + x_**S(2)*WC('e', S(1)))/sqrt(a_ + x_**S(4)*WC('c', S(1)) + x_**S(2)*WC('b', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons675, cons293) rule1219 = ReplacementRule(pattern1219, With1219) def With1220(d, c, a, x, e): q = Rt(-a*c, S(2)) rubi.append(1220) return Dist(sqrt(-c), Int((d + e*x**S(2))/(sqrt(-c*x**S(2) + q)*sqrt(c*x**S(2) + q)), x), x) pattern1220 = Pattern(Integral((d_ + x_**S(2)*WC('e', S(1)))/sqrt(a_ + x_**S(4)*WC('c', S(1))), x_), cons2, cons7, cons27, cons48, cons43, cons293) rule1220 = ReplacementRule(pattern1220, With1220) def With1221(b, d, c, a, x, e): if isinstance(x, (int, Integer, float, Float)): return False q = Rt(c/a, S(4)) if ZeroQ(d*q**S(2) + e): return True return False pattern1221 = Pattern(Integral((d_ + x_**S(2)*WC('e', S(1)))/sqrt(a_ + x_**S(4)*WC('c', S(1)) + x_**S(2)*WC('b', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons675, cons676, cons677, CustomConstraint(With1221)) def replacement1221(b, d, c, a, x, e): q = Rt(c/a, S(4)) rubi.append(1221) return -Simp(d*x*sqrt(a + b*x**S(2) + c*x**S(4))/(a*(q**S(2)*x**S(2) + S(1))), x) + Simp(d*sqrt((a + b*x**S(2) + c*x**S(4))/(a*(q**S(2)*x**S(2) + S(1))**S(2)))*(q**S(2)*x**S(2) + S(1))*EllipticE(S(2)*ArcTan(q*x), -b*q**S(2)/(S(4)*c) + S(1)/2)/(q*sqrt(a + b*x**S(2) + c*x**S(4))), x) rule1221 = ReplacementRule(pattern1221, replacement1221) def With1222(b, d, c, a, x, e): if isinstance(x, (int, Integer, float, Float)): return False q = Rt(c/a, S(2)) if NonzeroQ(d*q + e): return True return False pattern1222 = Pattern(Integral((d_ + x_**S(2)*WC('e', S(1)))/sqrt(a_ + x_**S(4)*WC('c', S(1)) + x_**S(2)*WC('b', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons675, cons676, cons677, CustomConstraint(With1222)) def replacement1222(b, d, c, a, x, e): q = Rt(c/a, S(2)) rubi.append(1222) return -Dist(e/q, Int((-q*x**S(2) + S(1))/sqrt(a + b*x**S(2) + c*x**S(4)), x), x) + Dist((d*q + e)/q, Int(S(1)/sqrt(a + b*x**S(2) + c*x**S(4)), x), x) rule1222 = ReplacementRule(pattern1222, replacement1222) def With1223(b, d, c, a, x, e): if isinstance(x, (int, Integer, float, Float)): return False q = Rt(-S(4)*a*c + b**S(2), S(2)) if ZeroQ(S(2)*c*d - e*(b - q)): return True return False pattern1223 = Pattern(Integral((d_ + x_**S(2)*WC('e', S(1)))/sqrt(a_ + x_**S(4)*WC('c', S(1)) + x_**S(2)*WC('b', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons675, cons484, cons177, CustomConstraint(With1223)) def replacement1223(b, d, c, a, x, e): q = Rt(-S(4)*a*c + b**S(2), S(2)) rubi.append(1223) return Simp(e*x*(b + S(2)*c*x**S(2) + q)/(S(2)*c*sqrt(a + b*x**S(2) + c*x**S(4))), x) - Simp(e*q*sqrt((S(2)*a + x**S(2)*(b + q))/q)*sqrt((S(2)*a + x**S(2)*(b - q))/(S(2)*a + x**S(2)*(b + q)))*EllipticE(asin(sqrt(S(2))*x/sqrt((S(2)*a + x**S(2)*(b + q))/q)), (b + q)/(S(2)*q))/(S(2)*c*sqrt(a/(S(2)*a + x**S(2)*(b + q)))*sqrt(a + b*x**S(2) + c*x**S(4))), x) rule1223 = ReplacementRule(pattern1223, replacement1223) def With1224(d, c, a, x, e): if isinstance(x, (int, Integer, float, Float)): return False q = Rt(-a*c, S(2)) if And(ZeroQ(c*d + e*q), IntegerQ(q)): return True return False pattern1224 = Pattern(Integral((d_ + x_**S(2)*WC('e', S(1)))/sqrt(a_ + x_**S(4)*WC('c', S(1))), x_), cons2, cons7, cons27, cons48, cons484, cons177, CustomConstraint(With1224)) def replacement1224(d, c, a, x, e): q = Rt(-a*c, S(2)) rubi.append(1224) return Simp(e*x*(c*x**S(2) + q)/(c*sqrt(a + c*x**S(4))), x) - Simp(sqrt(S(2))*e*q*sqrt((a + q*x**S(2))/q)*sqrt(-a + q*x**S(2))*EllipticE(asin(sqrt(S(2))*x/sqrt((a + q*x**S(2))/q)), S(1)/2)/(c*sqrt(-a)*sqrt(a + c*x**S(4))), x) rule1224 = ReplacementRule(pattern1224, replacement1224) def With1225(d, c, a, x, e): if isinstance(x, (int, Integer, float, Float)): return False q = Rt(-a*c, S(2)) if ZeroQ(c*d + e*q): return True return False pattern1225 = Pattern(Integral((d_ + x_**S(2)*WC('e', S(1)))/sqrt(a_ + x_**S(4)*WC('c', S(1))), x_), cons2, cons7, cons27, cons48, cons484, cons177, CustomConstraint(With1225)) def replacement1225(d, c, a, x, e): q = Rt(-a*c, S(2)) rubi.append(1225) return Simp(e*x*(c*x**S(2) + q)/(c*sqrt(a + c*x**S(4))), x) - Simp(sqrt(S(2))*e*q*sqrt((a + q*x**S(2))/q)*sqrt((a - q*x**S(2))/(a + q*x**S(2)))*EllipticE(asin(sqrt(S(2))*x/sqrt((a + q*x**S(2))/q)), S(1)/2)/(c*sqrt(a/(a + q*x**S(2)))*sqrt(a + c*x**S(4))), x) rule1225 = ReplacementRule(pattern1225, replacement1225) def With1226(b, d, c, a, x, e): if isinstance(x, (int, Integer, float, Float)): return False q = Rt(-S(4)*a*c + b**S(2), S(2)) if NonzeroQ(S(2)*c*d - e*(b - q)): return True return False pattern1226 = Pattern(Integral((d_ + x_**S(2)*WC('e', S(1)))/sqrt(a_ + x_**S(4)*WC('c', S(1)) + x_**S(2)*WC('b', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons675, cons484, cons177, CustomConstraint(With1226)) def replacement1226(b, d, c, a, x, e): q = Rt(-S(4)*a*c + b**S(2), S(2)) rubi.append(1226) return Dist(e/(S(2)*c), Int((b + S(2)*c*x**S(2) - q)/sqrt(a + b*x**S(2) + c*x**S(4)), x), x) + Dist((S(2)*c*d - e*(b - q))/(S(2)*c), Int(S(1)/sqrt(a + b*x**S(2) + c*x**S(4)), x), x) rule1226 = ReplacementRule(pattern1226, replacement1226) def With1227(d, c, a, x, e): if isinstance(x, (int, Integer, float, Float)): return False q = Rt(-a*c, S(2)) if NonzeroQ(c*d + e*q): return True return False pattern1227 = Pattern(Integral((d_ + x_**S(2)*WC('e', S(1)))/sqrt(a_ + x_**S(4)*WC('c', S(1))), x_), cons2, cons7, cons27, cons48, cons484, cons177, CustomConstraint(With1227)) def replacement1227(d, c, a, x, e): q = Rt(-a*c, S(2)) rubi.append(1227) return -Dist(e/c, Int((-c*x**S(2) + q)/sqrt(a + c*x**S(4)), x), x) + Dist((c*d + e*q)/c, Int(S(1)/sqrt(a + c*x**S(4)), x), x) rule1227 = ReplacementRule(pattern1227, replacement1227) def With1228(b, d, c, a, x, e): if isinstance(x, (int, Integer, float, Float)): return False q = Rt(-S(4)*a*c + b**S(2), S(2)) if Or(PosQ((b + q)/a), PosQ((b - q)/a)): return True return False pattern1228 = Pattern(Integral((d_ + x_**S(2)*WC('e', S(1)))/sqrt(a_ + x_**S(4)*WC('c', S(1)) + x_**S(2)*WC('b', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons675, CustomConstraint(With1228)) def replacement1228(b, d, c, a, x, e): q = Rt(-S(4)*a*c + b**S(2), S(2)) rubi.append(1228) return Dist(d, Int(S(1)/sqrt(a + b*x**S(2) + c*x**S(4)), x), x) + Dist(e, Int(x**S(2)/sqrt(a + b*x**S(2) + c*x**S(4)), x), x) rule1228 = ReplacementRule(pattern1228, replacement1228) pattern1229 = Pattern(Integral((d_ + x_**S(2)*WC('e', S(1)))/sqrt(a_ + x_**S(4)*WC('c', S(1))), x_), cons2, cons7, cons27, cons48, cons715) def replacement1229(d, c, a, x, e): rubi.append(1229) return Dist(d, Int(S(1)/sqrt(a + c*x**S(4)), x), x) + Dist(e, Int(x**S(2)/sqrt(a + c*x**S(4)), x), x) rule1229 = ReplacementRule(pattern1229, replacement1229) def With1230(b, d, c, a, x, e): if isinstance(x, (int, Integer, float, Float)): return False q = Rt(-S(4)*a*c + b**S(2), S(2)) if And(NegQ((b + q)/a), ZeroQ(S(2)*c*d - e*(b + q)), Not(SimplerSqrtQ(-(b - q)/(S(2)*a), -(b + q)/(S(2)*a)))): return True return False pattern1230 = Pattern(Integral((d_ + x_**S(2)*WC('e', S(1)))/sqrt(a_ + x_**S(4)*WC('c', S(1)) + x_**S(2)*WC('b', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons675, CustomConstraint(With1230)) def replacement1230(b, d, c, a, x, e): q = Rt(-S(4)*a*c + b**S(2), S(2)) rubi.append(1230) return -Simp(a*e*sqrt(S(1) + x**S(2)*(b - q)/(S(2)*a))*sqrt(S(1) + x**S(2)*(b + q)/(S(2)*a))*EllipticE(asin(x*Rt(-(b + q)/(S(2)*a), S(2))), (b - q)/(b + q))*Rt(-(b + q)/(S(2)*a), S(2))/(c*sqrt(a + b*x**S(2) + c*x**S(4))), x) rule1230 = ReplacementRule(pattern1230, replacement1230) def With1231(b, d, c, a, x, e): if isinstance(x, (int, Integer, float, Float)): return False q = Rt(-S(4)*a*c + b**S(2), S(2)) if And(NegQ((b + q)/a), NonzeroQ(S(2)*c*d - e*(b + q)), Not(SimplerSqrtQ(-(b - q)/(S(2)*a), -(b + q)/(S(2)*a)))): return True return False pattern1231 = Pattern(Integral((d_ + x_**S(2)*WC('e', S(1)))/sqrt(a_ + x_**S(4)*WC('c', S(1)) + x_**S(2)*WC('b', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons675, CustomConstraint(With1231)) def replacement1231(b, d, c, a, x, e): q = Rt(-S(4)*a*c + b**S(2), S(2)) rubi.append(1231) return Dist(e/(S(2)*c), Int((b + S(2)*c*x**S(2) + q)/sqrt(a + b*x**S(2) + c*x**S(4)), x), x) + Dist((S(2)*c*d - e*(b + q))/(S(2)*c), Int(S(1)/sqrt(a + b*x**S(2) + c*x**S(4)), x), x) rule1231 = ReplacementRule(pattern1231, replacement1231) def With1232(b, d, c, a, x, e): if isinstance(x, (int, Integer, float, Float)): return False q = Rt(-S(4)*a*c + b**S(2), S(2)) if And(NegQ((b - q)/a), ZeroQ(S(2)*c*d - e*(b - q))): return True return False pattern1232 = Pattern(Integral((d_ + x_**S(2)*WC('e', S(1)))/sqrt(a_ + x_**S(4)*WC('c', S(1)) + x_**S(2)*WC('b', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons675, CustomConstraint(With1232)) def replacement1232(b, d, c, a, x, e): q = Rt(-S(4)*a*c + b**S(2), S(2)) rubi.append(1232) return -Simp(a*e*sqrt(S(1) + x**S(2)*(b - q)/(S(2)*a))*sqrt(S(1) + x**S(2)*(b + q)/(S(2)*a))*EllipticE(asin(x*Rt(-(b - q)/(S(2)*a), S(2))), (b + q)/(b - q))*Rt(-(b - q)/(S(2)*a), S(2))/(c*sqrt(a + b*x**S(2) + c*x**S(4))), x) rule1232 = ReplacementRule(pattern1232, replacement1232) def With1233(b, d, c, a, x, e): if isinstance(x, (int, Integer, float, Float)): return False q = Rt(-S(4)*a*c + b**S(2), S(2)) if And(NegQ((b - q)/a), NonzeroQ(S(2)*c*d - e*(b - q))): return True return False pattern1233 = Pattern(Integral((d_ + x_**S(2)*WC('e', S(1)))/sqrt(a_ + x_**S(4)*WC('c', S(1)) + x_**S(2)*WC('b', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons675, CustomConstraint(With1233)) def replacement1233(b, d, c, a, x, e): q = Rt(-S(4)*a*c + b**S(2), S(2)) rubi.append(1233) return Dist(e/(S(2)*c), Int((b + S(2)*c*x**S(2) - q)/sqrt(a + b*x**S(2) + c*x**S(4)), x), x) + Dist((S(2)*c*d - e*(b - q))/(S(2)*c), Int(S(1)/sqrt(a + b*x**S(2) + c*x**S(4)), x), x) rule1233 = ReplacementRule(pattern1233, replacement1233) def With1234(b, d, c, a, x, e): if isinstance(x, (int, Integer, float, Float)): return False q = Rt(c/a, S(4)) if ZeroQ(d*q**S(2) + e): return True return False pattern1234 = Pattern(Integral((d_ + x_**S(2)*WC('e', S(1)))/sqrt(a_ + x_**S(4)*WC('c', S(1)) + x_**S(2)*WC('b', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons226, cons678, CustomConstraint(With1234)) def replacement1234(b, d, c, a, x, e): q = Rt(c/a, S(4)) rubi.append(1234) return -Simp(d*x*sqrt(a + b*x**S(2) + c*x**S(4))/(a*(q**S(2)*x**S(2) + S(1))), x) + Simp(d*sqrt((a + b*x**S(2) + c*x**S(4))/(a*(q**S(2)*x**S(2) + S(1))**S(2)))*(q**S(2)*x**S(2) + S(1))*EllipticE(S(2)*ArcTan(q*x), -b*q**S(2)/(S(4)*c) + S(1)/2)/(q*sqrt(a + b*x**S(2) + c*x**S(4))), x) rule1234 = ReplacementRule(pattern1234, replacement1234) def With1235(d, c, a, x, e): if isinstance(x, (int, Integer, float, Float)): return False q = Rt(c/a, S(4)) if ZeroQ(d*q**S(2) + e): return True return False pattern1235 = Pattern(Integral((d_ + x_**S(2)*WC('e', S(1)))/sqrt(a_ + x_**S(4)*WC('c', S(1))), x_), cons2, cons7, cons27, cons48, cons678, CustomConstraint(With1235)) def replacement1235(d, c, a, x, e): q = Rt(c/a, S(4)) rubi.append(1235) return -Simp(d*x*sqrt(a + c*x**S(4))/(a*(q**S(2)*x**S(2) + S(1))), x) + Simp(d*sqrt((a + c*x**S(4))/(a*(q**S(2)*x**S(2) + S(1))**S(2)))*(q**S(2)*x**S(2) + S(1))*EllipticE(S(2)*ArcTan(q*x), S(1)/2)/(q*sqrt(a + c*x**S(4))), x) rule1235 = ReplacementRule(pattern1235, replacement1235) def With1236(b, d, c, a, x, e): if isinstance(x, (int, Integer, float, Float)): return False q = Rt(c/a, S(2)) if NonzeroQ(d*q + e): return True return False pattern1236 = Pattern(Integral((d_ + x_**S(2)*WC('e', S(1)))/sqrt(a_ + x_**S(4)*WC('c', S(1)) + x_**S(2)*WC('b', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons226, cons678, CustomConstraint(With1236)) def replacement1236(b, d, c, a, x, e): q = Rt(c/a, S(2)) rubi.append(1236) return -Dist(e/q, Int((-q*x**S(2) + S(1))/sqrt(a + b*x**S(2) + c*x**S(4)), x), x) + Dist((d*q + e)/q, Int(S(1)/sqrt(a + b*x**S(2) + c*x**S(4)), x), x) rule1236 = ReplacementRule(pattern1236, replacement1236) def With1237(d, c, a, x, e): if isinstance(x, (int, Integer, float, Float)): return False q = Rt(c/a, S(2)) if NonzeroQ(d*q + e): return True return False pattern1237 = Pattern(Integral((d_ + x_**S(2)*WC('e', S(1)))/sqrt(a_ + x_**S(4)*WC('c', S(1))), x_), cons2, cons7, cons27, cons48, cons678, CustomConstraint(With1237)) def replacement1237(d, c, a, x, e): q = Rt(c/a, S(2)) rubi.append(1237) return -Dist(e/q, Int((-q*x**S(2) + S(1))/sqrt(a + c*x**S(4)), x), x) + Dist((d*q + e)/q, Int(S(1)/sqrt(a + c*x**S(4)), x), x) rule1237 = ReplacementRule(pattern1237, replacement1237) pattern1238 = Pattern(Integral((d_ + x_**S(2)*WC('e', S(1)))/sqrt(a_ + x_**S(4)*WC('c', S(1))), x_), cons2, cons7, cons27, cons48, cons679, cons257, cons43) def replacement1238(d, c, a, x, e): rubi.append(1238) return Dist(d/sqrt(a), Int(sqrt(S(1) + e*x**S(2)/d)/sqrt(S(1) - e*x**S(2)/d), x), x) rule1238 = ReplacementRule(pattern1238, replacement1238) pattern1239 = Pattern(Integral((d_ + x_**S(2)*WC('e', S(1)))/sqrt(a_ + x_**S(4)*WC('c', S(1))), x_), cons2, cons7, cons27, cons48, cons679, cons257, cons448) def replacement1239(d, c, a, x, e): rubi.append(1239) return Dist(sqrt(S(1) + c*x**S(4)/a)/sqrt(a + c*x**S(4)), Int((d + e*x**S(2))/sqrt(S(1) + c*x**S(4)/a), x), x) rule1239 = ReplacementRule(pattern1239, replacement1239) def With1240(d, c, a, x, e): q = Rt(-c/a, S(2)) rubi.append(1240) return Dist(e/q, Int((q*x**S(2) + S(1))/sqrt(a + c*x**S(4)), x), x) + Dist((d*q - e)/q, Int(S(1)/sqrt(a + c*x**S(4)), x), x) pattern1240 = Pattern(Integral((d_ + x_**S(2)*WC('e', S(1)))/sqrt(a_ + x_**S(4)*WC('c', S(1))), x_), cons2, cons7, cons27, cons48, cons679, cons280) rule1240 = ReplacementRule(pattern1240, With1240) def With1241(b, d, c, a, x, e): q = Rt(-S(4)*a*c + b**S(2), S(2)) rubi.append(1241) return Dist(sqrt(S(2)*c*x**S(2)/(b - q) + S(1))*sqrt(S(2)*c*x**S(2)/(b + q) + S(1))/sqrt(a + b*x**S(2) + c*x**S(4)), Int((d + e*x**S(2))/(sqrt(S(2)*c*x**S(2)/(b - q) + S(1))*sqrt(S(2)*c*x**S(2)/(b + q) + S(1))), x), x) pattern1241 = Pattern(Integral((d_ + x_**S(2)*WC('e', S(1)))/sqrt(a_ + x_**S(4)*WC('c', S(1)) + x_**S(2)*WC('b', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons226, cons679) rule1241 = ReplacementRule(pattern1241, With1241) pattern1242 = Pattern(Integral((d_ + x_**n_*WC('e', S(1)))*(a_ + x_**n2_*WC('c', S(1)) + x_**n_*WC('b', S(1)))**p_, x_), cons2, cons3, cons7, cons27, cons48, cons4, cons46, cons226) def replacement1242(p, b, n2, d, c, n, a, x, e): rubi.append(1242) return Int(ExpandIntegrand((d + e*x**n)*(a + b*x**n + c*x**(S(2)*n))**p, x), x) rule1242 = ReplacementRule(pattern1242, replacement1242) pattern1243 = Pattern(Integral((a_ + x_**n2_*WC('c', S(1)))**p_*(d_ + x_**n_*WC('e', S(1))), x_), cons2, cons7, cons27, cons48, cons4, cons46) def replacement1243(p, n2, d, c, n, a, x, e): rubi.append(1243) return Int(ExpandIntegrand((a + c*x**(S(2)*n))**p*(d + e*x**n), x), x) rule1243 = ReplacementRule(pattern1243, replacement1243) pattern1244 = Pattern(Integral((d_ + x_**n_*WC('e', S(1)))**q_*(a_ + x_**n2_*WC('c', S(1)) + x_**n_*WC('b', S(1)))**p_, x_), cons2, cons3, cons7, cons27, cons48, cons4, cons50, cons46, cons226, cons128, cons716, cons148, cons400) def replacement1244(p, b, n2, d, c, n, a, x, q, e): rubi.append(1244) return Int((d + e*x**n)**q*ExpandToSum(-c**p*d*x**(S(2)*n*p - n)*(S(2)*n*p - n + S(1))/(e*(S(2)*n*p + n*q + S(1))) - c**p*x**(S(2)*n*p) + (a + b*x**n + c*x**(S(2)*n))**p, x), x) + Simp(c**p*x**(S(2)*n*p - n + S(1))*(d + e*x**n)**(q + S(1))/(e*(S(2)*n*p + n*q + S(1))), x) rule1244 = ReplacementRule(pattern1244, replacement1244) pattern1245 = Pattern(Integral((a_ + x_**n2_*WC('c', S(1)))**p_*(d_ + x_**n_*WC('e', S(1)))**q_, x_), cons2, cons7, cons27, cons48, cons4, cons50, cons46, cons128, cons716, cons148, cons400) def replacement1245(p, n2, d, c, n, a, x, q, e): rubi.append(1245) return Int((d + e*x**n)**q*ExpandToSum(-c**p*d*x**(S(2)*n*p - n)*(S(2)*n*p - n + S(1))/(e*(S(2)*n*p + n*q + S(1))) - c**p*x**(S(2)*n*p) + (a + c*x**(S(2)*n))**p, x), x) + Simp(c**p*x**(S(2)*n*p - n + S(1))*(d + e*x**n)**(q + S(1))/(e*(S(2)*n*p + n*q + S(1))), x) rule1245 = ReplacementRule(pattern1245, replacement1245) pattern1246 = Pattern(Integral(sqrt(a_ + x_**S(4)*WC('c', S(1)) + x_**S(2)*WC('b', S(1)))/(d_ + x_**S(2)*WC('e', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons226, cons279) def replacement1246(b, d, c, a, x, e): rubi.append(1246) return -Dist(e**(S(-2)), Int((-b*e + c*d - c*e*x**S(2))/sqrt(a + b*x**S(2) + c*x**S(4)), x), x) + Dist((a*e**S(2) - b*d*e + c*d**S(2))/e**S(2), Int(S(1)/((d + e*x**S(2))*sqrt(a + b*x**S(2) + c*x**S(4))), x), x) rule1246 = ReplacementRule(pattern1246, replacement1246) pattern1247 = Pattern(Integral(sqrt(a_ + x_**S(4)*WC('c', S(1)))/(d_ + x_**S(2)*WC('e', S(1))), x_), cons2, cons7, cons27, cons48, cons280) def replacement1247(d, c, a, x, e): rubi.append(1247) return -Dist(c/e**S(2), Int((d - e*x**S(2))/sqrt(a + c*x**S(4)), x), x) + Dist((a*e**S(2) + c*d**S(2))/e**S(2), Int(S(1)/(sqrt(a + c*x**S(4))*(d + e*x**S(2))), x), x) rule1247 = ReplacementRule(pattern1247, replacement1247) def With1248(b, d, c, a, x, e): q = Rt(-S(4)*a*c + b**S(2), S(2)) rubi.append(1248) return -Dist(e**(S(-4)), Int(Simp(-c**S(2)*e**S(3)*x**S(6) + c*e**S(2)*x**S(4)*(-S(2)*b*e + c*d) - S(2)*c*(a*e**S(2) - b*d*e + c*d**S(2))**S(2)/(S(2)*c*d - e*(b + q)) - e*x**S(2)*(b**S(2)*e**S(2) + c**S(2)*d**S(2) - S(2)*c*e*(-a*e + b*d)) + (-b*e + c*d)*(S(2)*a*e**S(2) - b*d*e + c*d**S(2)), x)/sqrt(a + b*x**S(2) + c*x**S(4)), x), x) - Dist((a*e**S(2) - b*d*e + c*d**S(2))**S(2)/(e**S(3)*(S(2)*c*d - e*(b + q))), Int((b + S(2)*c*x**S(2) + q)/((d + e*x**S(2))*sqrt(a + b*x**S(2) + c*x**S(4))), x), x) pattern1248 = Pattern(Integral((a_ + x_**S(4)*WC('c', S(1)) + x_**S(2)*WC('b', S(1)))**(S(3)/2)/(d_ + x_**S(2)*WC('e', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons226, cons279, cons675) rule1248 = ReplacementRule(pattern1248, With1248) def With1249(d, c, a, x, e): q = Rt(-a*c, S(2)) rubi.append(1249) return -Dist(c/e**S(4), Int(Simp(c*d*e**S(2)*x**S(4) - c*e**S(3)*x**S(6) + d*(S(2)*a*e**S(2) + c*d**S(2)) - e*x**S(2)*(S(2)*a*e**S(2) + c*d**S(2)) - (a*e**S(2) + c*d**S(2))**S(2)/(c*d - e*q), x)/sqrt(a + c*x**S(4)), x), x) - Dist((a*e**S(2) + c*d**S(2))**S(2)/(e**S(3)*(c*d - e*q)), Int((c*x**S(2) + q)/(sqrt(a + c*x**S(4))*(d + e*x**S(2))), x), x) pattern1249 = Pattern(Integral((a_ + x_**S(4)*WC('c', S(1)))**(S(3)/2)/(d_ + x_**S(2)*WC('e', S(1))), x_), cons2, cons7, cons27, cons48, cons280, cons715) rule1249 = ReplacementRule(pattern1249, With1249) pattern1250 = Pattern(Integral((a_ + x_**S(4)*WC('c', S(1)) + x_**S(2)*WC('b', S(1)))**p_/(d_ + x_**S(2)*WC('e', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons226, cons279, cons717) def replacement1250(p, b, d, c, a, x, e): rubi.append(1250) return Dist(a, Int((a + b*x**S(2) + c*x**S(4))**(p + S(-1))/(d + e*x**S(2)), x), x) + Dist(b, Int(x**S(2)*(a + b*x**S(2) + c*x**S(4))**(p + S(-1))/(d + e*x**S(2)), x), x) + Dist(c, Int(x**S(4)*(a + b*x**S(2) + c*x**S(4))**(p + S(-1))/(d + e*x**S(2)), x), x) rule1250 = ReplacementRule(pattern1250, replacement1250) pattern1251 = Pattern(Integral((a_ + x_**S(4)*WC('c', S(1)))**p_/(d_ + x_**S(2)*WC('e', S(1))), x_), cons2, cons7, cons27, cons48, cons280, cons717) def replacement1251(p, d, c, a, x, e): rubi.append(1251) return Dist(a, Int((a + c*x**S(4))**(p + S(-1))/(d + e*x**S(2)), x), x) + Dist(c, Int(x**S(4)*(a + c*x**S(4))**(p + S(-1))/(d + e*x**S(2)), x), x) rule1251 = ReplacementRule(pattern1251, replacement1251) def With1252(b, d, c, a, x, e): q = Rt(-S(4)*a*c + b**S(2), S(2)) rubi.append(1252) return Dist(S(2)*sqrt(-c), Int(S(1)/((d + e*x**S(2))*sqrt(-b - S(2)*c*x**S(2) + q)*sqrt(b + S(2)*c*x**S(2) + q)), x), x) pattern1252 = Pattern(Integral(S(1)/((d_ + x_**S(2)*WC('e', S(1)))*sqrt(a_ + x_**S(4)*WC('c', S(1)) + x_**S(2)*WC('b', S(1)))), x_), cons2, cons3, cons7, cons27, cons48, cons675, cons293) rule1252 = ReplacementRule(pattern1252, With1252) def With1253(d, c, a, x, e): q = Rt(-a*c, S(2)) rubi.append(1253) return Dist(sqrt(-c), Int(S(1)/((d + e*x**S(2))*sqrt(-c*x**S(2) + q)*sqrt(c*x**S(2) + q)), x), x) pattern1253 = Pattern(Integral(S(1)/(sqrt(a_ + x_**S(4)*WC('c', S(1)))*(d_ + x_**S(2)*WC('e', S(1)))), x_), cons2, cons7, cons27, cons48, cons43, cons293) rule1253 = ReplacementRule(pattern1253, With1253) def With1254(b, d, c, a, x, e): q = Rt(-S(4)*a*c + b**S(2), S(2)) rubi.append(1254) return Dist(S(2)*c/(S(2)*c*d - e*(b - q)), Int(S(1)/sqrt(a + b*x**S(2) + c*x**S(4)), x), x) - Dist(e/(S(2)*c*d - e*(b - q)), Int((b + S(2)*c*x**S(2) - q)/((d + e*x**S(2))*sqrt(a + b*x**S(2) + c*x**S(4))), x), x) pattern1254 = Pattern(Integral(S(1)/((d_ + x_**S(2)*WC('e', S(1)))*sqrt(a_ + x_**S(4)*WC('c', S(1)) + x_**S(2)*WC('b', S(1)))), x_), cons2, cons3, cons7, cons27, cons48, cons675, cons718) rule1254 = ReplacementRule(pattern1254, With1254) def With1255(d, c, a, x, e): q = Rt(-a*c, S(2)) rubi.append(1255) return Dist(c/(c*d + e*q), Int(S(1)/sqrt(a + c*x**S(4)), x), x) + Dist(e/(c*d + e*q), Int((-c*x**S(2) + q)/(sqrt(a + c*x**S(4))*(d + e*x**S(2))), x), x) pattern1255 = Pattern(Integral(S(1)/(sqrt(a_ + x_**S(4)*WC('c', S(1)))*(d_ + x_**S(2)*WC('e', S(1)))), x_), cons2, cons7, cons27, cons48, cons715, cons718) rule1255 = ReplacementRule(pattern1255, With1255) def With1256(b, d, c, a, x, e): if isinstance(x, (int, Integer, float, Float)): return False q = Rt(c/a, S(4)) if NonzeroQ(-d*q**S(2) + e): return True return False pattern1256 = Pattern(Integral(S(1)/((d_ + x_**S(2)*WC('e', S(1)))*sqrt(a_ + x_**S(4)*WC('c', S(1)) + x_**S(2)*WC('b', S(1)))), x_), cons2, cons3, cons7, cons27, cons48, cons226, cons279, cons678, CustomConstraint(With1256)) def replacement1256(b, d, c, a, x, e): q = Rt(c/a, S(4)) rubi.append(1256) return -Dist(q**S(2)/(-d*q**S(2) + e), Int(S(1)/sqrt(a + b*x**S(2) + c*x**S(4)), x), x) + Simp(ArcTan(x*sqrt((a*e**S(2) - b*d*e + c*d**S(2))/(d*e))/sqrt(a + b*x**S(2) + c*x**S(4)))/(S(2)*d*sqrt((a*e**S(2) - b*d*e + c*d**S(2))/(d*e))), x) + Simp(sqrt((a + b*x**S(2) + c*x**S(4))/(a*(q**S(2)*x**S(2) + S(1))**S(2)))*(d*q**S(2) + e)*(q**S(2)*x**S(2) + S(1))*EllipticPi(-(-d*q**S(2) + e)**S(2)/(S(4)*d*e*q**S(2)), S(2)*ArcTan(q*x), -b*q**S(2)/(S(4)*c) + S(1)/2)/(S(4)*d*q*(-d*q**S(2) + e)*sqrt(a + b*x**S(2) + c*x**S(4))), x) rule1256 = ReplacementRule(pattern1256, replacement1256) def With1257(d, c, a, x, e): if isinstance(x, (int, Integer, float, Float)): return False q = Rt(c/a, S(4)) if NonzeroQ(-d*q**S(2) + e): return True return False pattern1257 = Pattern(Integral(S(1)/(sqrt(a_ + x_**S(4)*WC('c', S(1)))*(d_ + x_**S(2)*WC('e', S(1)))), x_), cons2, cons7, cons27, cons48, cons280, cons678, CustomConstraint(With1257)) def replacement1257(d, c, a, x, e): q = Rt(c/a, S(4)) rubi.append(1257) return -Dist(q**S(2)/(-d*q**S(2) + e), Int(S(1)/sqrt(a + c*x**S(4)), x), x) + Simp(ArcTan(x*sqrt((a*e**S(2) + c*d**S(2))/(d*e))/sqrt(a + c*x**S(4)))/(S(2)*d*sqrt((a*e**S(2) + c*d**S(2))/(d*e))), x) + Simp(sqrt((a + c*x**S(4))/(a*(q**S(2)*x**S(2) + S(1))**S(2)))*(d*q**S(2) + e)*(q**S(2)*x**S(2) + S(1))*EllipticPi(-(-d*q**S(2) + e)**S(2)/(S(4)*d*e*q**S(2)), S(2)*ArcTan(q*x), S(1)/2)/(S(4)*d*q*sqrt(a + c*x**S(4))*(-d*q**S(2) + e)), x) rule1257 = ReplacementRule(pattern1257, replacement1257) def With1258(d, c, a, x, e): q = Rt(-c/a, S(4)) rubi.append(1258) return Simp(EllipticPi(-e/(d*q**S(2)), asin(q*x), S(-1))/(sqrt(a)*d*q), x) pattern1258 = Pattern(Integral(S(1)/(sqrt(a_ + x_**S(4)*WC('c', S(1)))*(d_ + x_**S(2)*WC('e', S(1)))), x_), cons2, cons7, cons27, cons48, cons679, cons43) rule1258 = ReplacementRule(pattern1258, With1258) pattern1259 = Pattern(Integral(S(1)/(sqrt(a_ + x_**S(4)*WC('c', S(1)))*(d_ + x_**S(2)*WC('e', S(1)))), x_), cons2, cons7, cons27, cons48, cons679, cons448) def replacement1259(d, c, a, x, e): rubi.append(1259) return Dist(sqrt(S(1) + c*x**S(4)/a)/sqrt(a + c*x**S(4)), Int(S(1)/(sqrt(S(1) + c*x**S(4)/a)*(d + e*x**S(2))), x), x) rule1259 = ReplacementRule(pattern1259, replacement1259) def With1260(b, d, c, a, x, e): q = Rt(-S(4)*a*c + b**S(2), S(2)) rubi.append(1260) return Dist(sqrt(S(2)*c*x**S(2)/(b - q) + S(1))*sqrt(S(2)*c*x**S(2)/(b + q) + S(1))/sqrt(a + b*x**S(2) + c*x**S(4)), Int(S(1)/((d + e*x**S(2))*sqrt(S(2)*c*x**S(2)/(b - q) + S(1))*sqrt(S(2)*c*x**S(2)/(b + q) + S(1))), x), x) pattern1260 = Pattern(Integral(S(1)/((d_ + x_**S(2)*WC('e', S(1)))*sqrt(a_ + x_**S(4)*WC('c', S(1)) + x_**S(2)*WC('b', S(1)))), x_), cons2, cons3, cons7, cons27, cons48, cons226, cons679) rule1260 = ReplacementRule(pattern1260, With1260) pattern1261 = Pattern(Integral((a_ + x_**S(4)*WC('c', S(1)) + x_**S(2)*WC('b', S(1)))**p_/(d_ + x_**S(2)*WC('e', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons226, cons279, cons719) def replacement1261(p, b, d, c, a, x, e): rubi.append(1261) return -Dist(S(1)/(S(2)*a*(p + S(1))*(-S(4)*a*c + b**S(2))*(a*e**S(2) - b*d*e + c*d**S(2))), Int((a + b*x**S(2) + c*x**S(4))**(p + S(1))*Simp(-a*b*c*d*e*(S(8)*p + S(11)) + S(2)*a*c*(S(4)*a*e**S(2)*(p + S(1)) + c*d**S(2)*(S(4)*p + S(5))) + b**S(3)*d*e*(S(2)*p + S(3)) - b**S(2)*(S(2)*a*e**S(2)*(p + S(1)) + c*d**S(2)*(S(2)*p + S(3))) - c*e*x**S(4)*(S(4)*p + S(7))*(S(2)*a*c*e - b**S(2)*e + b*c*d) - x**S(2)*(S(4)*a*c**S(2)*d*e - b**S(3)*e**S(2)*(S(2)*p + S(3)) - S(2)*b**S(2)*c*d*e*(p + S(2)) + b*c*(a*e**S(2)*(S(8)*p + S(11)) + c*d**S(2)*(S(4)*p + S(7)))), x)/(d + e*x**S(2)), x), x) - Simp(x*(a + b*x**S(2) + c*x**S(4))**(p + S(1))*(S(3)*a*b*c*e - S(2)*a*c**S(2)*d - b**S(3)*e + b**S(2)*c*d + c*x**S(2)*(S(2)*a*c*e - b**S(2)*e + b*c*d))/(S(2)*a*(p + S(1))*(-S(4)*a*c + b**S(2))*(a*e**S(2) - b*d*e + c*d**S(2))), x) rule1261 = ReplacementRule(pattern1261, replacement1261) pattern1262 = Pattern(Integral((a_ + x_**S(4)*WC('c', S(1)))**p_/(d_ + x_**S(2)*WC('e', S(1))), x_), cons2, cons7, cons27, cons48, cons280, cons719) def replacement1262(p, d, c, a, x, e): rubi.append(1262) return -Dist(-S(1)/(S(8)*a**S(2)*c*(p + S(1))*(a*e**S(2) + c*d**S(2))), Int((a + c*x**S(4))**(p + S(1))*Simp(-S(4)*a*c**S(2)*d*e*x**S(2) - S(2)*a*c**S(2)*e**S(2)*x**S(4)*(S(4)*p + S(7)) + S(2)*a*c*(S(4)*a*e**S(2)*(p + S(1)) + c*d**S(2)*(S(4)*p + S(5))), x)/(d + e*x**S(2)), x), x) - Simp(-x*(a + c*x**S(4))**(p + S(1))*(-S(2)*a*c**S(2)*d + S(2)*a*c**S(2)*e*x**S(2))/(S(8)*a**S(2)*c*(p + S(1))*(a*e**S(2) + c*d**S(2))), x) rule1262 = ReplacementRule(pattern1262, replacement1262) pattern1263 = Pattern(Integral(S(1)/((d_ + x_**S(2)*WC('e', S(1)))**S(2)*sqrt(a_ + x_**S(4)*WC('c', S(1)) + x_**S(2)*WC('b', S(1)))), x_), cons2, cons3, cons7, cons27, cons48, cons226, cons279) def replacement1263(b, d, c, a, x, e): rubi.append(1263) return -Dist(c/(S(2)*d*(a*e**S(2) - b*d*e + c*d**S(2))), Int((d + e*x**S(2))/sqrt(a + b*x**S(2) + c*x**S(4)), x), x) + Dist((a*e**S(2) - S(2)*b*d*e + S(3)*c*d**S(2))/(S(2)*d*(a*e**S(2) - b*d*e + c*d**S(2))), Int(S(1)/((d + e*x**S(2))*sqrt(a + b*x**S(2) + c*x**S(4))), x), x) + Simp(e**S(2)*x*sqrt(a + b*x**S(2) + c*x**S(4))/(S(2)*d*(d + e*x**S(2))*(a*e**S(2) - b*d*e + c*d**S(2))), x) rule1263 = ReplacementRule(pattern1263, replacement1263) pattern1264 = Pattern(Integral(S(1)/(sqrt(a_ + x_**S(4)*WC('c', S(1)))*(d_ + x_**S(2)*WC('e', S(1)))**S(2)), x_), cons2, cons7, cons27, cons48, cons280) def replacement1264(d, c, a, x, e): rubi.append(1264) return -Dist(c/(S(2)*d*(a*e**S(2) + c*d**S(2))), Int((d + e*x**S(2))/sqrt(a + c*x**S(4)), x), x) + Dist((a*e**S(2) + S(3)*c*d**S(2))/(S(2)*d*(a*e**S(2) + c*d**S(2))), Int(S(1)/(sqrt(a + c*x**S(4))*(d + e*x**S(2))), x), x) + Simp(e**S(2)*x*sqrt(a + c*x**S(4))/(S(2)*d*(d + e*x**S(2))*(a*e**S(2) + c*d**S(2))), x) rule1264 = ReplacementRule(pattern1264, replacement1264) def With1265(p, b, d, c, a, x, q, e): r = Rt(-S(4)*a*c + b**S(2), S(2)) rubi.append(1265) return Dist(a**IntPart(p)*(S(2)*c*x**S(2)/(b - r) + S(1))**(-FracPart(p))*(S(2)*c*x**S(2)/(b + r) + S(1))**(-FracPart(p))*(a + b*x**S(2) + c*x**S(4))**FracPart(p), Int((d + e*x**S(2))**q*(S(2)*c*x**S(2)/(b - r) + S(1))**p*(S(2)*c*x**S(2)/(b + r) + S(1))**p, x), x) pattern1265 = Pattern(Integral((d_ + x_**S(2)*WC('e', S(1)))**q_*(a_ + x_**S(4)*WC('c', S(1)) + x_**S(2)*WC('b', S(1)))**p_, x_), cons2, cons3, cons7, cons27, cons48, cons50, cons226, cons279, cons347, cons564) rule1265 = ReplacementRule(pattern1265, With1265) def With1266(p, d, c, a, x, q, e): r = Rt(-a*c, S(2)) rubi.append(1266) return Dist(a**IntPart(p)*(a + c*x**S(4))**FracPart(p)*(-c*x**S(2)/r + S(1))**(-FracPart(p))*(c*x**S(2)/r + S(1))**(-FracPart(p)), Int((d + e*x**S(2))**q*(-c*x**S(2)/r + S(1))**p*(c*x**S(2)/r + S(1))**p, x), x) pattern1266 = Pattern(Integral((a_ + x_**S(4)*WC('c', S(1)))**p_*(d_ + x_**S(2)*WC('e', S(1)))**q_, x_), cons2, cons7, cons27, cons48, cons50, cons280, cons347, cons564) rule1266 = ReplacementRule(pattern1266, With1266) pattern1267 = Pattern(Integral(S(1)/(sqrt(d_ + x_**S(2)*WC('e', S(1)))*sqrt(a_ + x_**S(4)*WC('c', S(1)) + x_**S(2)*WC('b', S(1)))), x_), cons2, cons3, cons7, cons27, cons48, cons720, cons43, cons268) def replacement1267(b, d, c, a, x, e): rubi.append(1267) return Simp(EllipticF(S(2)*asin(x*Rt(-e/d, S(2))), b*d/(S(4)*a*e))/(S(2)*sqrt(a)*sqrt(d)*Rt(-e/d, S(2))), x) rule1267 = ReplacementRule(pattern1267, replacement1267) pattern1268 = Pattern(Integral(S(1)/(sqrt(d_ + x_**S(2)*WC('e', S(1)))*sqrt(a_ + x_**S(4)*WC('c', S(1)) + x_**S(2)*WC('b', S(1)))), x_), cons2, cons3, cons7, cons27, cons48, cons720, cons721) def replacement1268(b, d, c, a, x, e): rubi.append(1268) return Dist(sqrt((a + b*x**S(2) + c*x**S(4))/a)*sqrt((d + e*x**S(2))/d)/(sqrt(d + e*x**S(2))*sqrt(a + b*x**S(2) + c*x**S(4))), Int(S(1)/(sqrt(S(1) + e*x**S(2)/d)*sqrt(S(1) + b*x**S(2)/a + c*x**S(4)/a)), x), x) rule1268 = ReplacementRule(pattern1268, replacement1268) pattern1269 = Pattern(Integral(sqrt(a_ + x_**S(4)*WC('c', S(1)) + x_**S(2)*WC('b', S(1)))/sqrt(d_ + x_**S(2)*WC('e', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons720, cons43, cons268) def replacement1269(b, d, c, a, x, e): rubi.append(1269) return Simp(sqrt(a)*EllipticE(S(2)*asin(x*Rt(-e/d, S(2))), b*d/(S(4)*a*e))/(S(2)*sqrt(d)*Rt(-e/d, S(2))), x) rule1269 = ReplacementRule(pattern1269, replacement1269) pattern1270 = Pattern(Integral(sqrt(a_ + x_**S(4)*WC('c', S(1)) + x_**S(2)*WC('b', S(1)))/sqrt(d_ + x_**S(2)*WC('e', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons720, cons721) def replacement1270(b, d, c, a, x, e): rubi.append(1270) return Dist(sqrt((d + e*x**S(2))/d)*sqrt(a + b*x**S(2) + c*x**S(4))/(sqrt((a + b*x**S(2) + c*x**S(4))/a)*sqrt(d + e*x**S(2))), Int(sqrt(S(1) + b*x**S(2)/a + c*x**S(4)/a)/sqrt(S(1) + e*x**S(2)/d), x), x) rule1270 = ReplacementRule(pattern1270, replacement1270) pattern1271 = Pattern(Integral((d_ + x_**n_*WC('e', S(1)))**q_*(a_ + x_**n2_*WC('c', S(1)) + x_**n_*WC('b', S(1)))**p_, x_), cons2, cons3, cons7, cons27, cons48, cons4, cons5, cons50, cons46, cons226, cons279, cons722) def replacement1271(p, b, n2, d, c, n, a, x, q, e): rubi.append(1271) return Int(ExpandIntegrand((d + e*x**n)**q*(a + b*x**n + c*x**(S(2)*n))**p, x), x) rule1271 = ReplacementRule(pattern1271, replacement1271) pattern1272 = Pattern(Integral((a_ + x_**n2_*WC('c', S(1)))**p_*(d_ + x_**n_*WC('e', S(1)))**q_, x_), cons2, cons7, cons27, cons48, cons4, cons5, cons50, cons46, cons280, cons722) def replacement1272(p, n2, d, c, n, a, x, q, e): rubi.append(1272) return Int(ExpandIntegrand((a + c*x**(S(2)*n))**p*(d + e*x**n)**q, x), x) rule1272 = ReplacementRule(pattern1272, replacement1272) pattern1273 = Pattern(Integral((a_ + x_**n2_*WC('c', S(1)))**p_*(d_ + x_**n_*WC('e', S(1)))**q_, x_), cons2, cons7, cons27, cons48, cons4, cons5, cons46, cons280, cons564, cons723) def replacement1273(p, n2, d, c, n, a, x, q, e): rubi.append(1273) return Int(ExpandIntegrand((a + c*x**(S(2)*n))**p, (d/(d**S(2) - e**S(2)*x**(S(2)*n)) - e*x**n/(d**S(2) - e**S(2)*x**(S(2)*n)))**(-q), x), x) rule1273 = ReplacementRule(pattern1273, replacement1273) pattern1274 = Pattern(Integral((d_ + x_**n_*WC('e', S(1)))**q_*(a_ + x_**n2_*WC('c', S(1)) + x_**n_*WC('b', S(1)))**p_, x_), cons2, cons3, cons7, cons27, cons48, cons4, cons5, cons50, cons46, cons724) def replacement1274(p, b, n2, d, c, n, a, x, q, e): rubi.append(1274) return Int((d + e*x**n)**q*(a + b*x**n + c*x**(S(2)*n))**p, x) rule1274 = ReplacementRule(pattern1274, replacement1274) pattern1275 = Pattern(Integral((a_ + x_**n2_*WC('c', S(1)))**p_*(d_ + x_**n_*WC('e', S(1)))**q_, x_), cons2, cons7, cons27, cons48, cons4, cons5, cons50, cons46, cons724) def replacement1275(p, n2, d, c, n, a, x, q, e): rubi.append(1275) return Int((a + c*x**(S(2)*n))**p*(d + e*x**n)**q, x) rule1275 = ReplacementRule(pattern1275, replacement1275) pattern1276 = Pattern(Integral((d_ + u_**n_*WC('e', S(1)))**WC('q', S(1))*(a_ + u_**n2_*WC('c', S(1)) + u_**n_*WC('b', S(1)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons4, cons5, cons50, cons46, cons68, cons69) def replacement1276(p, u, b, n2, d, c, n, a, x, q, e): rubi.append(1276) return Dist(S(1)/Coefficient(u, x, S(1)), Subst(Int((d + e*x**n)**q*(a + b*x**n + c*x**(S(2)*n))**p, x), x, u), x) rule1276 = ReplacementRule(pattern1276, replacement1276) pattern1277 = Pattern(Integral((a_ + u_**n2_*WC('c', S(1)))**WC('p', S(1))*(d_ + u_**n_*WC('e', S(1)))**WC('q', S(1)), x_), cons2, cons7, cons27, cons48, cons4, cons5, cons50, cons46, cons68, cons69) def replacement1277(p, u, n2, d, c, n, a, x, q, e): rubi.append(1277) return Dist(S(1)/Coefficient(u, x, S(1)), Subst(Int((a + c*x**(S(2)*n))**p*(d + e*x**n)**q, x), x, u), x) rule1277 = ReplacementRule(pattern1277, replacement1277) pattern1278 = Pattern(Integral((d_ + x_**WC('mn', S(1))*WC('e', S(1)))**WC('q', S(1))*(x_**WC('n', S(1))*WC('b', S(1)) + x_**WC('n2', S(1))*WC('c', S(1)) + WC('a', S(0)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons4, cons5, cons680, cons585, cons586) def replacement1278(mn, p, b, n2, d, a, n, c, x, q, e): rubi.append(1278) return Int(x**(-n*q)*(d*x**n + e)**q*(a + b*x**n + c*x**(S(2)*n))**p, x) rule1278 = ReplacementRule(pattern1278, replacement1278) pattern1279 = Pattern(Integral((a_ + x_**WC('n2', S(1))*WC('c', S(1)))**WC('p', S(1))*(d_ + x_**WC('mn', S(1))*WC('e', S(1)))**WC('q', S(1)), x_), cons2, cons7, cons27, cons48, cons726, cons5, cons725, cons586) def replacement1279(mn, p, n2, d, c, a, x, q, e): rubi.append(1279) return Int(x**(mn*q)*(a + c*x**n2)**p*(d*x**(-mn) + e)**q, x) rule1279 = ReplacementRule(pattern1279, replacement1279) pattern1280 = Pattern(Integral((d_ + x_**WC('mn', S(1))*WC('e', S(1)))**q_*(x_**WC('n', S(1))*WC('b', S(1)) + x_**WC('n2', S(1))*WC('c', S(1)) + WC('a', S(0)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons4, cons50, cons680, cons585, cons386, cons38) def replacement1280(mn, p, b, n2, d, a, n, c, x, q, e): rubi.append(1280) return Int(x**(S(2)*n*p)*(d + e*x**(-n))**q*(a*x**(-S(2)*n) + b*x**(-n) + c)**p, x) rule1280 = ReplacementRule(pattern1280, replacement1280) pattern1281 = Pattern(Integral((a_ + x_**WC('n2', S(1))*WC('c', S(1)))**WC('p', S(1))*(d_ + x_**WC('mn', S(1))*WC('e', S(1)))**q_, x_), cons2, cons7, cons27, cons48, cons726, cons50, cons725, cons386, cons38) def replacement1281(mn, p, n2, d, c, a, x, q, e): rubi.append(1281) return Int(x**(-S(2)*mn*p)*(d + e*x**mn)**q*(a*x**(S(2)*mn) + c)**p, x) rule1281 = ReplacementRule(pattern1281, replacement1281) pattern1282 = Pattern(Integral((d_ + x_**WC('mn', S(1))*WC('e', S(1)))**q_*(x_**WC('n', S(1))*WC('b', S(1)) + x_**WC('n2', S(1))*WC('c', S(1)) + WC('a', S(0)))**p_, x_), cons2, cons3, cons7, cons27, cons48, cons4, cons5, cons50, cons680, cons585, cons386, cons147, cons681) def replacement1282(mn, p, b, n2, d, a, n, c, x, q, e): rubi.append(1282) return Dist(x**(n*FracPart(q))*(d + e*x**(-n))**FracPart(q)*(d*x**n + e)**(-FracPart(q)), Int(x**(-n*q)*(d*x**n + e)**q*(a + b*x**n + c*x**(S(2)*n))**p, x), x) rule1282 = ReplacementRule(pattern1282, replacement1282) pattern1283 = Pattern(Integral((a_ + x_**WC('n2', S(1))*WC('c', S(1)))**p_*(d_ + x_**WC('mn', S(1))*WC('e', S(1)))**q_, x_), cons2, cons7, cons27, cons48, cons726, cons5, cons50, cons725, cons386, cons147, cons727) def replacement1283(mn, p, n2, d, c, a, x, q, e): rubi.append(1283) return Dist(x**(-mn*FracPart(q))*(d + e*x**mn)**FracPart(q)*(d*x**(-mn) + e)**(-FracPart(q)), Int(x**(mn*q)*(a + c*x**n2)**p*(d*x**(-mn) + e)**q, x), x) rule1283 = ReplacementRule(pattern1283, replacement1283) pattern1284 = Pattern(Integral((d_ + x_**WC('mn', S(1))*WC('e', S(1)))**q_*(x_**WC('n', S(1))*WC('b', S(1)) + x_**WC('n2', S(1))*WC('c', S(1)) + WC('a', S(0)))**p_, x_), cons2, cons3, cons7, cons27, cons48, cons4, cons50, cons680, cons585, cons386, cons147, cons502) def replacement1284(mn, p, b, n2, d, a, n, c, x, q, e): rubi.append(1284) return Dist(x**(-S(2)*n*FracPart(p))*(a + b*x**n + c*x**(S(2)*n))**FracPart(p)*(a*x**(-S(2)*n) + b*x**(-n) + c)**(-FracPart(p)), Int(x**(S(2)*n*p)*(d + e*x**(-n))**q*(a*x**(-S(2)*n) + b*x**(-n) + c)**p, x), x) rule1284 = ReplacementRule(pattern1284, replacement1284) pattern1285 = Pattern(Integral((a_ + x_**WC('n2', S(1))*WC('c', S(1)))**p_*(d_ + x_**WC('mn', S(1))*WC('e', S(1)))**q_, x_), cons2, cons7, cons27, cons48, cons726, cons50, cons725, cons386, cons147, cons728) def replacement1285(mn, p, n2, d, c, a, x, q, e): rubi.append(1285) return Dist(x**(-n2*FracPart(p))*(a + c*x**n2)**FracPart(p)*(a*x**(S(2)*mn) + c)**(-FracPart(p)), Int(x**(n2*p)*(d + e*x**mn)**q*(a*x**(S(2)*mn) + c)**p, x), x) rule1285 = ReplacementRule(pattern1285, replacement1285) pattern1286 = Pattern(Integral((d_ + x_**n_*WC('e', S(1)))**WC('q', S(1))*(a_ + x_**mn_*WC('b', S(1)) + x_**WC('n', S(1))*WC('c', S(1)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons4, cons50, cons585, cons38) def replacement1286(mn, p, b, d, c, n, a, x, q, e): rubi.append(1286) return Int(x**(-n*p)*(d + e*x**n)**q*(a*x**n + b + c*x**(S(2)*n))**p, x) rule1286 = ReplacementRule(pattern1286, replacement1286) pattern1287 = Pattern(Integral((d_ + x_**n_*WC('e', S(1)))**WC('q', S(1))*(a_ + x_**mn_*WC('b', S(1)) + x_**WC('n', S(1))*WC('c', S(1)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons4, cons5, cons50, cons585, cons147) def replacement1287(mn, p, b, d, c, n, a, x, q, e): rubi.append(1287) return Dist(x**(n*FracPart(p))*(a + b*x**(-n) + c*x**n)**FracPart(p)*(a*x**n + b + c*x**(S(2)*n))**(-FracPart(p)), Int(x**(-n*p)*(d + e*x**n)**q*(a*x**n + b + c*x**(S(2)*n))**p, x), x) rule1287 = ReplacementRule(pattern1287, replacement1287) pattern1288 = Pattern(Integral((d_ + x_**n_*WC('e', S(1)))**WC('q', S(1))*(f_ + x_**n_*WC('g', S(1)))**WC('r', S(1))*(a_ + x_**n2_*WC('c', S(1)) + x_**n_*WC('b', S(1)))**p_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons4, cons5, cons50, cons52, cons46, cons45, cons147) def replacement1288(p, g, b, r, f, n2, d, c, n, a, x, q, e): rubi.append(1288) return Dist((S(4)*c)**(-IntPart(p))*(b + S(2)*c*x**n)**(-S(2)*FracPart(p))*(a + b*x**n + c*x**(S(2)*n))**FracPart(p), Int((b + S(2)*c*x**n)**(S(2)*p)*(d + e*x**n)**q*(f + g*x**n)**r, x), x) rule1288 = ReplacementRule(pattern1288, replacement1288) pattern1289 = Pattern(Integral((d_ + x_**n_*WC('e', S(1)))**WC('q', S(1))*(f_ + x_**n_*WC('g', S(1)))**WC('r', S(1))*(a_ + x_**n2_*WC('c', S(1)) + x_**n_*WC('b', S(1)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons4, cons50, cons52, cons46, cons226, cons256, cons38) def replacement1289(p, g, b, r, f, n2, d, c, n, a, x, q, e): rubi.append(1289) return Int((d + e*x**n)**(p + q)*(f + g*x**n)**r*(a/d + c*x**n/e)**p, x) rule1289 = ReplacementRule(pattern1289, replacement1289) pattern1290 = Pattern(Integral((a_ + x_**n2_*WC('c', S(1)))**WC('p', S(1))*(d_ + x_**n_*WC('e', S(1)))**WC('q', S(1))*(f_ + x_**n_*WC('g', S(1)))**WC('r', S(1)), x_), cons2, cons7, cons27, cons48, cons125, cons208, cons4, cons50, cons52, cons46, cons257, cons38) def replacement1290(p, g, f, r, n2, d, c, n, a, x, q, e): rubi.append(1290) return Int((d + e*x**n)**(p + q)*(f + g*x**n)**r*(a/d + c*x**n/e)**p, x) rule1290 = ReplacementRule(pattern1290, replacement1290) pattern1291 = Pattern(Integral((d_ + x_**n_*WC('e', S(1)))**WC('q', S(1))*(f_ + x_**n_*WC('g', S(1)))**WC('r', S(1))*(a_ + x_**n2_*WC('c', S(1)) + x_**n_*WC('b', S(1)))**p_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons4, cons5, cons50, cons52, cons46, cons226, cons256, cons147) def replacement1291(p, g, b, r, f, n2, d, c, n, a, x, q, e): rubi.append(1291) return Dist((d + e*x**n)**(-FracPart(p))*(a/d + c*x**n/e)**(-FracPart(p))*(a + b*x**n + c*x**(S(2)*n))**FracPart(p), Int((d + e*x**n)**(p + q)*(f + g*x**n)**r*(a/d + c*x**n/e)**p, x), x) rule1291 = ReplacementRule(pattern1291, replacement1291) pattern1292 = Pattern(Integral((a_ + x_**n2_*WC('c', S(1)))**p_*(d_ + x_**n_*WC('e', S(1)))**WC('q', S(1))*(f_ + x_**n_*WC('g', S(1)))**WC('r', S(1)), x_), cons2, cons7, cons27, cons48, cons125, cons208, cons4, cons5, cons50, cons52, cons46, cons257, cons147) def replacement1292(p, g, f, r, n2, d, c, n, a, x, q, e): rubi.append(1292) return Dist((a + c*x**(S(2)*n))**FracPart(p)*(d + e*x**n)**(-FracPart(p))*(a/d + c*x**n/e)**(-FracPart(p)), Int((d + e*x**n)**(p + q)*(f + g*x**n)**r*(a/d + c*x**n/e)**p, x), x) rule1292 = ReplacementRule(pattern1292, replacement1292) def With1293(f, b, g, d, c, a, x, e): if isinstance(x, (int, Integer, float, Float)): return False q = Rt(-S(4)*a*c + b**S(2), S(2)) if NonzeroQ(S(2)*c*f - g*(b - q)): return True return False pattern1293 = Pattern(Integral((x_**S(2)*WC('g', S(1)) + WC('f', S(0)))/((d_ + x_**S(2)*WC('e', S(1)))*sqrt(a_ + x_**S(4)*WC('c', S(1)) + x_**S(2)*WC('b', S(1)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons675, cons279, cons718, CustomConstraint(With1293)) def replacement1293(f, b, g, d, c, a, x, e): q = Rt(-S(4)*a*c + b**S(2), S(2)) rubi.append(1293) return Dist((S(2)*c*f - g*(b - q))/(S(2)*c*d - e*(b - q)), Int(S(1)/sqrt(a + b*x**S(2) + c*x**S(4)), x), x) - Dist((-d*g + e*f)/(S(2)*c*d - e*(b - q)), Int((b + S(2)*c*x**S(2) - q)/((d + e*x**S(2))*sqrt(a + b*x**S(2) + c*x**S(4))), x), x) rule1293 = ReplacementRule(pattern1293, replacement1293) def With1294(g, f, d, c, a, x, e): if isinstance(x, (int, Integer, float, Float)): return False q = Rt(-a*c, S(2)) if NonzeroQ(c*f + g*q): return True return False pattern1294 = Pattern(Integral((f_ + x_**S(2)*WC('g', S(1)))/(sqrt(a_ + x_**S(4)*WC('c', S(1)))*(d_ + x_**S(2)*WC('e', S(1)))), x_), cons2, cons7, cons27, cons48, cons125, cons208, cons715, cons280, cons718, CustomConstraint(With1294)) def replacement1294(g, f, d, c, a, x, e): q = Rt(-a*c, S(2)) rubi.append(1294) return Dist((c*f + g*q)/(c*d + e*q), Int(S(1)/sqrt(a + c*x**S(4)), x), x) + Dist((-d*g + e*f)/(c*d + e*q), Int((-c*x**S(2) + q)/(sqrt(a + c*x**S(4))*(d + e*x**S(2))), x), x) rule1294 = ReplacementRule(pattern1294, replacement1294) pattern1295 = Pattern(Integral((d1_ + x_**WC('non2', S(1))*WC('e1', S(1)))**WC('q', S(1))*(d2_ + x_**WC('non2', S(1))*WC('e2', S(1)))**WC('q', S(1))*(x_**n2_*WC('c', S(1)) + x_**n_*WC('b', S(1)) + WC('a', S(0)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons731, cons652, cons732, cons654, cons4, cons5, cons50, cons46, cons593, cons729, cons730) def replacement1295(p, d2, b, n2, e2, a, c, non2, d1, e1, n, x, q): rubi.append(1295) return Int((d1*d2 + e1*e2*x**n)**q*(a + b*x**n + c*x**(S(2)*n))**p, x) rule1295 = ReplacementRule(pattern1295, replacement1295) pattern1296 = Pattern(Integral((d1_ + x_**WC('non2', S(1))*WC('e1', S(1)))**WC('q', S(1))*(d2_ + x_**WC('non2', S(1))*WC('e2', S(1)))**WC('q', S(1))*(x_**n2_*WC('c', S(1)) + x_**n_*WC('b', S(1)) + WC('a', S(0)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons731, cons652, cons732, cons654, cons4, cons5, cons50, cons46, cons593, cons729) def replacement1296(p, d2, b, n2, e2, a, c, non2, d1, e1, n, x, q): rubi.append(1296) return Dist((d1 + e1*x**(n/S(2)))**FracPart(q)*(d2 + e2*x**(n/S(2)))**FracPart(q)*(d1*d2 + e1*e2*x**n)**(-FracPart(q)), Int((d1*d2 + e1*e2*x**n)**q*(a + b*x**n + c*x**(S(2)*n))**p, x), x) rule1296 = ReplacementRule(pattern1296, replacement1296) pattern1297 = Pattern(Integral((A_ + x_**WC('m', S(1))*WC('B', S(1)))*(d_ + x_**n_*WC('e', S(1)))**WC('q', S(1))*(a_ + x_**n2_*WC('c', S(1)) + x_**n_*WC('b', S(1)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons34, cons35, cons21, cons4, cons5, cons50, cons46, cons53) def replacement1297(B, p, m, b, n2, d, c, n, a, A, x, q, e): rubi.append(1297) return Dist(A, Int((d + e*x**n)**q*(a + b*x**n + c*x**(S(2)*n))**p, x), x) + Dist(B, Int(x**m*(d + e*x**n)**q*(a + b*x**n + c*x**(S(2)*n))**p, x), x) rule1297 = ReplacementRule(pattern1297, replacement1297) pattern1298 = Pattern(Integral((A_ + x_**WC('m', S(1))*WC('B', S(1)))*(a_ + x_**n2_*WC('c', S(1)))**WC('p', S(1))*(d_ + x_**n_*WC('e', S(1)))**WC('q', S(1)), x_), cons2, cons7, cons27, cons48, cons34, cons35, cons21, cons4, cons5, cons50, cons46, cons53) def replacement1298(B, p, m, n2, d, c, n, a, A, x, q, e): rubi.append(1298) return Dist(A, Int((a + c*x**(S(2)*n))**p*(d + e*x**n)**q, x), x) + Dist(B, Int(x**m*(a + c*x**(S(2)*n))**p*(d + e*x**n)**q, x), x) rule1298 = ReplacementRule(pattern1298, replacement1298) pattern1299 = Pattern(Integral((x_*WC('f', S(1)))**WC('m', S(1))*(x_**n_*WC('e', S(1)))**q_*(a_ + x_**n_*WC('b', S(1)) + x_**WC('n2', S(1))*WC('c', S(1)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons48, cons125, cons21, cons4, cons5, cons50, cons46, cons733, cons500) def replacement1299(p, m, f, b, n2, c, n, a, x, q, e): rubi.append(1299) return Dist(e**(S(1) - (m + S(1))/n)*f**m/n, Subst(Int((e*x)**(q + S(-1) + (m + S(1))/n)*(a + b*x + c*x**S(2))**p, x), x, x**n), x) rule1299 = ReplacementRule(pattern1299, replacement1299) pattern1300 = Pattern(Integral((x_*WC('f', S(1)))**WC('m', S(1))*(x_**n_*WC('e', S(1)))**q_*(a_ + x_**WC('n2', S(1))*WC('c', S(1)))**WC('p', S(1)), x_), cons2, cons7, cons48, cons125, cons21, cons4, cons5, cons50, cons46, cons733, cons500) def replacement1300(p, m, f, n2, c, n, a, x, q, e): rubi.append(1300) return Dist(e**(S(1) - (m + S(1))/n)*f**m/n, Subst(Int((e*x)**(q + S(-1) + (m + S(1))/n)*(a + c*x**S(2))**p, x), x, x**n), x) rule1300 = ReplacementRule(pattern1300, replacement1300) pattern1301 = Pattern(Integral((x_*WC('f', S(1)))**WC('m', S(1))*(x_**n_*WC('e', S(1)))**q_*(a_ + x_**n_*WC('b', S(1)) + x_**WC('n2', S(1))*WC('c', S(1)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons48, cons125, cons21, cons4, cons5, cons50, cons46, cons733, cons501) def replacement1301(p, m, f, b, n2, c, n, a, x, q, e): rubi.append(1301) return Dist(e**IntPart(q)*f**m*x**(-n*FracPart(q))*(e*x**n)**FracPart(q), Int(x**(m + n*q)*(a + b*x**n + c*x**(S(2)*n))**p, x), x) rule1301 = ReplacementRule(pattern1301, replacement1301) pattern1302 = Pattern(Integral((x_*WC('f', S(1)))**WC('m', S(1))*(x_**n_*WC('e', S(1)))**q_*(a_ + x_**WC('n2', S(1))*WC('c', S(1)))**WC('p', S(1)), x_), cons2, cons7, cons48, cons125, cons21, cons4, cons5, cons50, cons46, cons733, cons501) def replacement1302(p, m, f, n2, c, n, a, x, q, e): rubi.append(1302) return Dist(e**IntPart(q)*f**m*x**(-n*FracPart(q))*(e*x**n)**FracPart(q), Int(x**(m + n*q)*(a + c*x**(S(2)*n))**p, x), x) rule1302 = ReplacementRule(pattern1302, replacement1302) pattern1303 = Pattern(Integral((f_*x_)**WC('m', S(1))*(x_**n_*WC('e', S(1)))**q_*(a_ + x_**n_*WC('b', S(1)) + x_**WC('n2', S(1))*WC('c', S(1)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons48, cons125, cons21, cons4, cons5, cons50, cons46, cons18) def replacement1303(p, m, f, b, n2, c, n, a, x, q, e): rubi.append(1303) return Dist(f**IntPart(m)*x**(-FracPart(m))*(f*x)**FracPart(m), Int(x**m*(e*x**n)**q*(a + b*x**n + c*x**(S(2)*n))**p, x), x) rule1303 = ReplacementRule(pattern1303, replacement1303) pattern1304 = Pattern(Integral((f_*x_)**WC('m', S(1))*(x_**n_*WC('e', S(1)))**q_*(a_ + x_**WC('n2', S(1))*WC('c', S(1)))**WC('p', S(1)), x_), cons2, cons7, cons48, cons125, cons21, cons4, cons5, cons50, cons46, cons18) def replacement1304(p, m, f, n2, c, n, a, x, q, e): rubi.append(1304) return Dist(f**IntPart(m)*x**(-FracPart(m))*(f*x)**FracPart(m), Int(x**m*(e*x**n)**q*(a + c*x**(S(2)*n))**p, x), x) rule1304 = ReplacementRule(pattern1304, replacement1304) pattern1305 = Pattern(Integral(x_**WC('m', S(1))*(d_ + x_**n_*WC('e', S(1)))**WC('q', S(1))*(a_ + x_**n_*WC('b', S(1)) + x_**WC('n2', S(1))*WC('c', S(1)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons21, cons4, cons5, cons50, cons46, cons53) def replacement1305(p, m, b, n2, d, c, a, n, x, q, e): rubi.append(1305) return Dist(S(1)/n, Subst(Int((d + e*x)**q*(a + b*x + c*x**S(2))**p, x), x, x**n), x) rule1305 = ReplacementRule(pattern1305, replacement1305) pattern1306 = Pattern(Integral(x_**WC('m', S(1))*(a_ + x_**WC('n2', S(1))*WC('c', S(1)))**WC('p', S(1))*(d_ + x_**n_*WC('e', S(1)))**WC('q', S(1)), x_), cons2, cons7, cons27, cons48, cons21, cons4, cons5, cons50, cons46, cons53) def replacement1306(p, m, n2, d, c, a, n, x, q, e): rubi.append(1306) return Dist(S(1)/n, Subst(Int((a + c*x**S(2))**p*(d + e*x)**q, x), x, x**n), x) rule1306 = ReplacementRule(pattern1306, replacement1306) pattern1307 = Pattern(Integral(x_**WC('m', S(1))*(d_ + x_**n_*WC('e', S(1)))**WC('q', S(1))*(a_ + x_**n_*WC('b', S(1)) + x_**WC('n2', S(1))*WC('c', S(1)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons21, cons4, cons46, cons220, cons502) def replacement1307(p, m, b, n2, d, c, a, n, x, q, e): rubi.append(1307) return Int(x**(m + n*(S(2)*p + q))*(d*x**(-n) + e)**q*(a*x**(-S(2)*n) + b*x**(-n) + c)**p, x) rule1307 = ReplacementRule(pattern1307, replacement1307) pattern1308 = Pattern(Integral(x_**WC('m', S(1))*(a_ + x_**WC('n2', S(1))*WC('c', S(1)))**WC('p', S(1))*(d_ + x_**n_*WC('e', S(1)))**WC('q', S(1)), x_), cons2, cons7, cons27, cons48, cons21, cons4, cons46, cons220, cons502) def replacement1308(p, m, n2, d, c, a, n, x, q, e): rubi.append(1308) return Int(x**(m + n*(S(2)*p + q))*(a*x**(-S(2)*n) + c)**p*(d*x**(-n) + e)**q, x) rule1308 = ReplacementRule(pattern1308, replacement1308) pattern1309 = Pattern(Integral(x_**WC('m', S(1))*(d_ + x_**n_*WC('e', S(1)))**WC('q', S(1))*(a_ + x_**n_*WC('b', S(1)) + x_**WC('n2', S(1))*WC('c', S(1)))**p_, x_), cons2, cons3, cons7, cons27, cons48, cons5, cons50, cons46, cons45, cons147, cons734) def replacement1309(p, m, b, n2, d, c, a, n, x, q, e): rubi.append(1309) return Dist(S(1)/n, Subst(Int(x**(S(-1) + (m + S(1))/n)*(d + e*x)**q*(a + b*x + c*x**S(2))**p, x), x, x**n), x) rule1309 = ReplacementRule(pattern1309, replacement1309) pattern1310 = Pattern(Integral((x_*WC('f', S(1)))**WC('m', S(1))*(d_ + x_**n_*WC('e', S(1)))**WC('q', S(1))*(a_ + x_**n_*WC('b', S(1)) + x_**WC('n2', S(1))*WC('c', S(1)))**p_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons4, cons5, cons50, cons46, cons45, cons147) def replacement1310(p, m, f, b, n2, d, c, a, n, x, q, e): rubi.append(1310) return Dist(c**(-IntPart(p))*(b/S(2) + c*x**n)**(-S(2)*FracPart(p))*(a + b*x**n + c*x**(S(2)*n))**FracPart(p), Int((f*x)**m*(b/S(2) + c*x**n)**(S(2)*p)*(d + e*x**n)**q, x), x) rule1310 = ReplacementRule(pattern1310, replacement1310) pattern1311 = Pattern(Integral(x_**WC('m', S(1))*(d_ + x_**n_*WC('e', S(1)))**WC('q', S(1))*(a_ + x_**n_*WC('b', S(1)) + x_**WC('n2', S(1))*WC('c', S(1)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons21, cons4, cons5, cons50, cons46, cons500) def replacement1311(p, m, b, n2, d, c, a, n, x, q, e): rubi.append(1311) return Dist(S(1)/n, Subst(Int(x**(S(-1) + (m + S(1))/n)*(d + e*x)**q*(a + b*x + c*x**S(2))**p, x), x, x**n), x) rule1311 = ReplacementRule(pattern1311, replacement1311) pattern1312 = Pattern(Integral(x_**WC('m', S(1))*(a_ + x_**WC('n2', S(1))*WC('c', S(1)))**WC('p', S(1))*(d_ + x_**n_*WC('e', S(1)))**WC('q', S(1)), x_), cons2, cons7, cons27, cons48, cons21, cons4, cons5, cons50, cons46, cons500) def replacement1312(p, m, n2, d, c, a, n, x, q, e): rubi.append(1312) return Dist(S(1)/n, Subst(Int(x**(S(-1) + (m + S(1))/n)*(a + c*x**S(2))**p*(d + e*x)**q, x), x, x**n), x) rule1312 = ReplacementRule(pattern1312, replacement1312) pattern1313 = Pattern(Integral((f_*x_)**WC('m', S(1))*(d_ + x_**n_*WC('e', S(1)))**WC('q', S(1))*(a_ + x_**n_*WC('b', S(1)) + x_**WC('n2', S(1))*WC('c', S(1)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons4, cons5, cons50, cons46, cons500) def replacement1313(p, m, f, b, n2, d, c, a, n, x, q, e): rubi.append(1313) return Dist(f**IntPart(m)*x**(-FracPart(m))*(f*x)**FracPart(m), Int(x**m*(d + e*x**n)**q*(a + b*x**n + c*x**(S(2)*n))**p, x), x) rule1313 = ReplacementRule(pattern1313, replacement1313) pattern1314 = Pattern(Integral((f_*x_)**WC('m', S(1))*(a_ + x_**WC('n2', S(1))*WC('c', S(1)))**WC('p', S(1))*(d_ + x_**n_*WC('e', S(1)))**WC('q', S(1)), x_), cons2, cons7, cons27, cons48, cons125, cons21, cons4, cons5, cons50, cons46, cons500) def replacement1314(p, m, f, n2, d, c, a, n, x, q, e): rubi.append(1314) return Dist(f**IntPart(m)*x**(-FracPart(m))*(f*x)**FracPart(m), Int(x**m*(a + c*x**(S(2)*n))**p*(d + e*x**n)**q, x), x) rule1314 = ReplacementRule(pattern1314, replacement1314) pattern1315 = Pattern(Integral((x_*WC('f', S(1)))**WC('m', S(1))*(d_ + x_**n_*WC('e', S(1)))**WC('q', S(1))*(a_ + x_**n2_*WC('c', S(1)) + x_**n_*WC('b', S(1)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons4, cons50, cons46, cons226, cons256, cons38) def replacement1315(p, m, f, b, n2, d, c, n, a, x, q, e): rubi.append(1315) return Int((f*x)**m*(d + e*x**n)**(p + q)*(a/d + c*x**n/e)**p, x) rule1315 = ReplacementRule(pattern1315, replacement1315) pattern1316 = Pattern(Integral((x_*WC('f', S(1)))**WC('m', S(1))*(a_ + x_**n2_*WC('c', S(1)))**WC('p', S(1))*(d_ + x_**n_*WC('e', S(1)))**WC('q', S(1)), x_), cons2, cons7, cons27, cons48, cons125, cons50, cons21, cons4, cons50, cons46, cons257, cons38) def replacement1316(p, m, f, n2, d, c, n, a, x, q, e): rubi.append(1316) return Int((f*x)**m*(d + e*x**n)**(p + q)*(a/d + c*x**n/e)**p, x) rule1316 = ReplacementRule(pattern1316, replacement1316) pattern1317 = Pattern(Integral((x_*WC('f', S(1)))**WC('m', S(1))*(d_ + x_**n_*WC('e', S(1)))**q_*(a_ + x_**n2_*WC('c', S(1)) + x_**n_*WC('b', S(1)))**p_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons4, cons5, cons50, cons46, cons226, cons256, cons147) def replacement1317(p, m, f, b, n2, d, c, n, a, x, q, e): rubi.append(1317) return Dist((d + e*x**n)**(-FracPart(p))*(a/d + c*x**n/e)**(-FracPart(p))*(a + b*x**n + c*x**(S(2)*n))**FracPart(p), Int((f*x)**m*(d + e*x**n)**(p + q)*(a/d + c*x**n/e)**p, x), x) rule1317 = ReplacementRule(pattern1317, replacement1317) pattern1318 = Pattern(Integral((x_*WC('f', S(1)))**WC('m', S(1))*(a_ + x_**n2_*WC('c', S(1)))**p_*(d_ + x_**n_*WC('e', S(1)))**q_, x_), cons2, cons7, cons27, cons48, cons125, cons21, cons4, cons5, cons50, cons46, cons257, cons147) def replacement1318(p, m, f, n2, d, c, n, a, x, q, e): rubi.append(1318) return Dist((a + c*x**(S(2)*n))**FracPart(p)*(d + e*x**n)**(-FracPart(p))*(a/d + c*x**n/e)**(-FracPart(p)), Int((f*x)**m*(d + e*x**n)**(p + q)*(a/d + c*x**n/e)**p, x), x) rule1318 = ReplacementRule(pattern1318, replacement1318) pattern1319 = Pattern(Integral(x_**WC('m', S(1))*(d_ + x_**n_*WC('e', S(1)))**q_*(a_ + x_**n_*WC('b', S(1)) + x_**WC('n2', S(1))*WC('c', S(1)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons46, cons226, cons464, cons735, cons396, cons168) def replacement1319(p, m, b, n2, d, c, a, n, x, q, e): rubi.append(1319) return Dist(e**(-S(2)*p - (m - Mod(m, n))/n)/(n*(q + S(1))), Int(x**Mod(m, n)*(d + e*x**n)**(q + S(1))*ExpandToSum(Together((e**(S(2)*p + (m - Mod(m, n))/n)*n*x**(m - Mod(m, n))*(q + S(1))*(a + b*x**n + c*x**(S(2)*n))**p - (-d)**(S(-1) + (m - Mod(m, n))/n)*(d*(Mod(m, n) + S(1)) + e*x**n*(n*(q + S(1)) + Mod(m, n) + S(1)))*(a*e**S(2) - b*d*e + c*d**S(2))**p)/(d + e*x**n)), x), x), x) + Simp(e**(-S(2)*p - (m - Mod(m, n))/n)*x**(Mod(m, n) + S(1))*(-d)**(S(-1) + (m - Mod(m, n))/n)*(d + e*x**n)**(q + S(1))*(a*e**S(2) - b*d*e + c*d**S(2))**p/(n*(q + S(1))), x) rule1319 = ReplacementRule(pattern1319, replacement1319) pattern1320 = Pattern(Integral(x_**WC('m', S(1))*(a_ + x_**WC('n2', S(1))*WC('c', S(1)))**WC('p', S(1))*(d_ + x_**n_*WC('e', S(1)))**q_, x_), cons2, cons7, cons27, cons48, cons46, cons464, cons735, cons396, cons168) def replacement1320(p, m, n2, d, c, a, n, x, q, e): rubi.append(1320) return Dist(e**(-S(2)*p - (m - Mod(m, n))/n)/(n*(q + S(1))), Int(x**Mod(m, n)*(d + e*x**n)**(q + S(1))*ExpandToSum(Together((e**(S(2)*p + (m - Mod(m, n))/n)*n*x**(m - Mod(m, n))*(a + c*x**(S(2)*n))**p*(q + S(1)) - (-d)**(S(-1) + (m - Mod(m, n))/n)*(a*e**S(2) + c*d**S(2))**p*(d*(Mod(m, n) + S(1)) + e*x**n*(n*(q + S(1)) + Mod(m, n) + S(1))))/(d + e*x**n)), x), x), x) + Simp(e**(-S(2)*p - (m - Mod(m, n))/n)*x**(Mod(m, n) + S(1))*(-d)**(S(-1) + (m - Mod(m, n))/n)*(d + e*x**n)**(q + S(1))*(a*e**S(2) + c*d**S(2))**p/(n*(q + S(1))), x) rule1320 = ReplacementRule(pattern1320, replacement1320) pattern1321 = Pattern(Integral(x_**m_*(d_ + x_**n_*WC('e', S(1)))**q_*(a_ + x_**n_*WC('b', S(1)) + x_**WC('n2', S(1))*WC('c', S(1)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons46, cons226, cons464, cons735, cons396, cons267) def replacement1321(p, m, b, n2, d, c, a, n, x, q, e): rubi.append(1321) return Dist(e**(-S(2)*p)*(-d)**(S(-1) + (m - Mod(m, n))/n)/(n*(q + S(1))), Int(x**m*(d + e*x**n)**(q + S(1))*ExpandToSum(Together((e**(S(2)*p)*n*(-d)**(S(1) - (m - Mod(m, n))/n)*(q + S(1))*(a + b*x**n + c*x**(S(2)*n))**p - e**(-(m - Mod(m, n))/n)*x**(-m + Mod(m, n))*(d*(Mod(m, n) + S(1)) + e*x**n*(n*(q + S(1)) + Mod(m, n) + S(1)))*(a*e**S(2) - b*d*e + c*d**S(2))**p)/(d + e*x**n)), x), x), x) + Simp(e**(-S(2)*p - (m - Mod(m, n))/n)*x**(Mod(m, n) + S(1))*(-d)**(S(-1) + (m - Mod(m, n))/n)*(d + e*x**n)**(q + S(1))*(a*e**S(2) - b*d*e + c*d**S(2))**p/(n*(q + S(1))), x) rule1321 = ReplacementRule(pattern1321, replacement1321) pattern1322 = Pattern(Integral(x_**m_*(a_ + x_**WC('n2', S(1))*WC('c', S(1)))**WC('p', S(1))*(d_ + x_**n_*WC('e', S(1)))**q_, x_), cons2, cons7, cons27, cons48, cons46, cons464, cons735, cons396, cons267) def replacement1322(p, m, n2, d, c, a, n, x, q, e): rubi.append(1322) return Dist(e**(-S(2)*p)*(-d)**(S(-1) + (m - Mod(m, n))/n)/(n*(q + S(1))), Int(x**m*(d + e*x**n)**(q + S(1))*ExpandToSum(Together((e**(S(2)*p)*n*(-d)**(S(1) - (m - Mod(m, n))/n)*(a + c*x**(S(2)*n))**p*(q + S(1)) - e**(-(m - Mod(m, n))/n)*x**(-m + Mod(m, n))*(a*e**S(2) + c*d**S(2))**p*(d*(Mod(m, n) + S(1)) + e*x**n*(n*(q + S(1)) + Mod(m, n) + S(1))))/(d + e*x**n)), x), x), x) + Simp(e**(-S(2)*p - (m - Mod(m, n))/n)*x**(Mod(m, n) + S(1))*(-d)**(S(-1) + (m - Mod(m, n))/n)*(d + e*x**n)**(q + S(1))*(a*e**S(2) + c*d**S(2))**p/(n*(q + S(1))), x) rule1322 = ReplacementRule(pattern1322, replacement1322) pattern1323 = Pattern(Integral((x_*WC('f', S(1)))**WC('m', S(1))*(d_ + x_**n_*WC('e', S(1)))**WC('q', S(1))*(a_ + x_**n_*WC('b', S(1)) + x_**WC('n2', S(1))*WC('c', S(1)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons50, cons46, cons226, cons464, cons736, cons386, cons737) def replacement1323(p, m, f, b, n2, d, c, a, n, x, q, e): rubi.append(1323) return Dist(S(1)/(e*(m + S(2)*n*p + n*q + S(1))), Int((f*x)**m*(d + e*x**n)**q*ExpandToSum(-c**p*d*x**(S(2)*n*p - n)*(m + S(2)*n*p - n + S(1)) + e*(-c**p*x**(S(2)*n*p) + (a + b*x**n + c*x**(S(2)*n))**p)*(m + S(2)*n*p + n*q + S(1)), x), x), x) + Simp(c**p*f**(-S(2)*n*p + n + S(-1))*(f*x)**(m + S(2)*n*p - n + S(1))*(d + e*x**n)**(q + S(1))/(e*(m + S(2)*n*p + n*q + S(1))), x) rule1323 = ReplacementRule(pattern1323, replacement1323) pattern1324 = Pattern(Integral((x_*WC('f', S(1)))**WC('m', S(1))*(a_ + x_**WC('n2', S(1))*WC('c', S(1)))**WC('p', S(1))*(d_ + x_**n_*WC('e', S(1)))**WC('q', S(1)), x_), cons2, cons7, cons27, cons48, cons125, cons21, cons50, cons46, cons464, cons736, cons386, cons737) def replacement1324(p, m, f, n2, d, c, a, n, x, q, e): rubi.append(1324) return Dist(S(1)/(e*(m + S(2)*n*p + n*q + S(1))), Int((f*x)**m*(d + e*x**n)**q*ExpandToSum(-c**p*d*x**(S(2)*n*p - n)*(m + S(2)*n*p - n + S(1)) + e*(-c**p*x**(S(2)*n*p) + (a + c*x**(S(2)*n))**p)*(m + S(2)*n*p + n*q + S(1)), x), x), x) + Simp(c**p*f**(-S(2)*n*p + n + S(-1))*(f*x)**(m + S(2)*n*p - n + S(1))*(d + e*x**n)**(q + S(1))/(e*(m + S(2)*n*p + n*q + S(1))), x) rule1324 = ReplacementRule(pattern1324, replacement1324) pattern1325 = Pattern(Integral((x_*WC('f', S(1)))**WC('m', S(1))*(d_ + x_**n_*WC('e', S(1)))**WC('q', S(1))*(a_ + x_**n_*WC('b', S(1)) + x_**WC('n2', S(1))*WC('c', S(1)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons50, cons46, cons464) def replacement1325(p, m, f, b, n2, d, c, a, n, x, q, e): rubi.append(1325) return Int(ExpandIntegrand((f*x)**m*(d + e*x**n)**q*(a + b*x**n + c*x**(S(2)*n))**p, x), x) rule1325 = ReplacementRule(pattern1325, replacement1325) pattern1326 = Pattern(Integral((x_*WC('f', S(1)))**WC('m', S(1))*(a_ + x_**WC('n2', S(1))*WC('c', S(1)))**WC('p', S(1))*(d_ + x_**n_*WC('e', S(1)))**WC('q', S(1)), x_), cons2, cons7, cons27, cons48, cons125, cons21, cons50, cons46, cons46, cons464) def replacement1326(p, m, f, n2, d, c, a, n, x, q, e): rubi.append(1326) return Int(ExpandIntegrand((f*x)**m*(a + c*x**(S(2)*n))**p*(d + e*x**n)**q, x), x) rule1326 = ReplacementRule(pattern1326, replacement1326) def With1327(p, m, b, n2, d, c, a, n, x, q, e): if isinstance(x, (int, Integer, float, Float)): return False k = GCD(m + S(1), n) if Unequal(k, S(1)): return True return False pattern1327 = Pattern(Integral(x_**WC('m', S(1))*(d_ + x_**n_*WC('e', S(1)))**WC('q', S(1))*(a_ + x_**n_*WC('b', S(1)) + x_**WC('n2', S(1))*WC('c', S(1)))**p_, x_), cons2, cons3, cons7, cons27, cons48, cons5, cons50, cons46, cons226, cons148, cons17, CustomConstraint(With1327)) def replacement1327(p, m, b, n2, d, c, a, n, x, q, e): k = GCD(m + S(1), n) rubi.append(1327) return Dist(S(1)/k, Subst(Int(x**(S(-1) + (m + S(1))/k)*(d + e*x**(n/k))**q*(a + b*x**(n/k) + c*x**(S(2)*n/k))**p, x), x, x**k), x) rule1327 = ReplacementRule(pattern1327, replacement1327) def With1328(p, m, n2, d, c, a, n, x, q, e): if isinstance(x, (int, Integer, float, Float)): return False k = GCD(m + S(1), n) if Unequal(k, S(1)): return True return False pattern1328 = Pattern(Integral(x_**WC('m', S(1))*(a_ + x_**WC('n2', S(1))*WC('c', S(1)))**p_*(d_ + x_**n_*WC('e', S(1)))**WC('q', S(1)), x_), cons2, cons7, cons27, cons48, cons5, cons50, cons46, cons148, cons17, CustomConstraint(With1328)) def replacement1328(p, m, n2, d, c, a, n, x, q, e): k = GCD(m + S(1), n) rubi.append(1328) return Dist(S(1)/k, Subst(Int(x**(S(-1) + (m + S(1))/k)*(a + c*x**(S(2)*n/k))**p*(d + e*x**(n/k))**q, x), x, x**k), x) rule1328 = ReplacementRule(pattern1328, replacement1328) def With1329(p, m, f, b, n2, d, c, a, n, x, q, e): k = Denominator(m) rubi.append(1329) return Dist(k/f, Subst(Int(x**(k*(m + S(1)) + S(-1))*(d + e*f**(-n)*x**(k*n))**q*(a + b*f**(-n)*x**(k*n) + c*f**(-S(2)*n)*x**(S(2)*k*n))**p, x), x, (f*x)**(S(1)/k)), x) pattern1329 = Pattern(Integral((x_*WC('f', S(1)))**m_*(d_ + x_**n_*WC('e', S(1)))**WC('q', S(1))*(a_ + x_**n_*WC('b', S(1)) + x_**WC('n2', S(1))*WC('c', S(1)))**p_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons5, cons50, cons46, cons226, cons148, cons367, cons38) rule1329 = ReplacementRule(pattern1329, With1329) def With1330(p, m, f, n2, d, c, a, n, x, q, e): k = Denominator(m) rubi.append(1330) return Dist(k/f, Subst(Int(x**(k*(m + S(1)) + S(-1))*(a + c*x**(S(2)*k*n)/f)**p*(d + e*x**(k*n)/f)**q, x), x, (f*x)**(S(1)/k)), x) pattern1330 = Pattern(Integral((x_*WC('f', S(1)))**m_*(a_ + x_**WC('n2', S(1))*WC('c', S(1)))**p_*(d_ + x_**n_*WC('e', S(1)))**WC('q', S(1)), x_), cons2, cons7, cons27, cons48, cons125, cons5, cons50, cons46, cons148, cons367, cons38) rule1330 = ReplacementRule(pattern1330, With1330) pattern1331 = Pattern(Integral((x_*WC('f', S(1)))**WC('m', S(1))*(d_ + x_**n_*WC('e', S(1)))*(a_ + x_**n2_*WC('c', S(1)) + x_**n_*WC('b', S(1)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons46, cons226, cons148, cons244, cons163, cons94, cons738, cons694) def replacement1331(p, m, f, b, n2, d, c, n, a, x, e): rubi.append(1331) return Dist(f**(-n)*n*p/((m + S(1))*(m + n*(S(2)*p + S(1)) + S(1))), Int((f*x)**(m + n)*(a + b*x**n + c*x**(S(2)*n))**(p + S(-1))*Simp(S(2)*a*e*(m + S(1)) - b*d*(m + n*(S(2)*p + S(1)) + S(1)) + x**n*(b*e*(m + S(1)) - S(2)*c*d*(m + n*(S(2)*p + S(1)) + S(1))), x), x), x) + Simp((f*x)**(m + S(1))*(d*(m + n*(S(2)*p + S(1)) + S(1)) + e*x**n*(m + S(1)))*(a + b*x**n + c*x**(S(2)*n))**p/(f*(m + S(1))*(m + n*(S(2)*p + S(1)) + S(1))), x) rule1331 = ReplacementRule(pattern1331, replacement1331) pattern1332 = Pattern(Integral((x_*WC('f', S(1)))**WC('m', S(1))*(a_ + x_**n2_*WC('c', S(1)))**WC('p', S(1))*(d_ + x_**n_*WC('e', S(1))), x_), cons2, cons7, cons27, cons48, cons125, cons46, cons148, cons244, cons163, cons94, cons738, cons694) def replacement1332(p, m, f, n2, d, c, n, a, x, e): rubi.append(1332) return Dist(S(2)*f**(-n)*n*p/((m + S(1))*(m + n*(S(2)*p + S(1)) + S(1))), Int((f*x)**(m + n)*(a + c*x**(S(2)*n))**(p + S(-1))*(a*e*(m + S(1)) - c*d*x**n*(m + n*(S(2)*p + S(1)) + S(1))), x), x) + Simp((f*x)**(m + S(1))*(a + c*x**(S(2)*n))**p*(d*(m + n*(S(2)*p + S(1)) + S(1)) + e*x**n*(m + S(1)))/(f*(m + S(1))*(m + n*(S(2)*p + S(1)) + S(1))), x) rule1332 = ReplacementRule(pattern1332, replacement1332) pattern1333 = Pattern(Integral((x_*WC('f', S(1)))**WC('m', S(1))*(d_ + x_**n_*WC('e', S(1)))*(a_ + x_**n2_*WC('c', S(1)) + x_**n_*WC('b', S(1)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons46, cons226, cons148, cons13, cons163, cons510, cons739, cons694) def replacement1333(p, m, f, b, n2, d, c, n, a, x, e): rubi.append(1333) return Dist(n*p/(c*(m + S(2)*n*p + S(1))*(m + n*(S(2)*p + S(1)) + S(1))), Int((f*x)**m*(a + b*x**n + c*x**(S(2)*n))**(p + S(-1))*Simp(-a*b*e*(m + S(1)) + S(2)*a*c*d*(m + n*(S(2)*p + S(1)) + S(1)) + x**n*(S(2)*a*c*e*(m + S(2)*n*p + S(1)) - b**S(2)*e*(m + n*p + S(1)) + b*c*d*(m + n*(S(2)*p + S(1)) + S(1))), x), x), x) + Simp((f*x)**(m + S(1))*(a + b*x**n + c*x**(S(2)*n))**p*(b*e*n*p + c*d*(m + n*(S(2)*p + S(1)) + S(1)) + c*e*x**n*(m + S(2)*n*p + S(1)))/(c*f*(m + S(2)*n*p + S(1))*(m + n*(S(2)*p + S(1)) + S(1))), x) rule1333 = ReplacementRule(pattern1333, replacement1333) pattern1334 = Pattern(Integral((x_*WC('f', S(1)))**WC('m', S(1))*(a_ + x_**n2_*WC('c', S(1)))**WC('p', S(1))*(d_ + x_**n_*WC('e', S(1))), x_), cons2, cons7, cons27, cons48, cons125, cons21, cons46, cons148, cons13, cons163, cons510, cons739, cons694) def replacement1334(p, m, f, n2, d, c, n, a, x, e): rubi.append(1334) return Dist(S(2)*a*n*p/((m + S(2)*n*p + S(1))*(m + n*(S(2)*p + S(1)) + S(1))), Int((f*x)**m*(a + c*x**(S(2)*n))**(p + S(-1))*Simp(d*(m + n*(S(2)*p + S(1)) + S(1)) + e*x**n*(m + S(2)*n*p + S(1)), x), x), x) + Simp((f*x)**(m + S(1))*(a + c*x**(S(2)*n))**p*(c*d*(m + n*(S(2)*p + S(1)) + S(1)) + c*e*x**n*(m + S(2)*n*p + S(1)))/(c*f*(m + S(2)*n*p + S(1))*(m + n*(S(2)*p + S(1)) + S(1))), x) rule1334 = ReplacementRule(pattern1334, replacement1334) pattern1335 = Pattern(Integral((x_*WC('f', S(1)))**WC('m', S(1))*(d_ + x_**n_*WC('e', S(1)))*(a_ + x_**n2_*WC('c', S(1)) + x_**n_*WC('b', S(1)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons46, cons226, cons148, cons244, cons137, cons530, cons694) def replacement1335(p, m, f, b, n2, d, c, n, a, x, e): rubi.append(1335) return Dist(f**n/(n*(p + S(1))*(-S(4)*a*c + b**S(2))), Int((f*x)**(m - n)*(a + b*x**n + c*x**(S(2)*n))**(p + S(1))*Simp(x**n*(b*e - S(2)*c*d)*(m + S(2)*n*p + S(2)*n + S(1)) + (-S(2)*a*e + b*d)*(-m + n + S(-1)), x), x), x) + Simp(f**(n + S(-1))*(f*x)**(m - n + S(1))*(a + b*x**n + c*x**(S(2)*n))**(p + S(1))*(-S(2)*a*e + b*d - x**n*(b*e - S(2)*c*d))/(n*(p + S(1))*(-S(4)*a*c + b**S(2))), x) rule1335 = ReplacementRule(pattern1335, replacement1335) pattern1336 = Pattern(Integral((x_*WC('f', S(1)))**WC('m', S(1))*(a_ + x_**n2_*WC('c', S(1)))**WC('p', S(1))*(d_ + x_**n_*WC('e', S(1))), x_), cons2, cons7, cons27, cons48, cons125, cons46, cons148, cons244, cons137, cons530, cons694) def replacement1336(p, m, f, n2, d, c, n, a, x, e): rubi.append(1336) return Dist(f**n/(S(2)*a*c*n*(p + S(1))), Int((f*x)**(m - n)*(a + c*x**(S(2)*n))**(p + S(1))*(a*e*(-m + n + S(-1)) + c*d*x**n*(m + S(2)*n*p + S(2)*n + S(1))), x), x) + Simp(f**(n + S(-1))*(f*x)**(m - n + S(1))*(a + c*x**(S(2)*n))**(p + S(1))*(a*e - c*d*x**n)/(S(2)*a*c*n*(p + S(1))), x) rule1336 = ReplacementRule(pattern1336, replacement1336) pattern1337 = Pattern(Integral((x_*WC('f', S(1)))**WC('m', S(1))*(d_ + x_**n_*WC('e', S(1)))*(a_ + x_**n2_*WC('c', S(1)) + x_**n_*WC('b', S(1)))**p_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons46, cons226, cons148, cons13, cons137, cons694) def replacement1337(p, m, f, b, n2, d, c, n, a, x, e): rubi.append(1337) return Dist(S(1)/(a*n*(p + S(1))*(-S(4)*a*c + b**S(2))), Int((f*x)**m*(a + b*x**n + c*x**(S(2)*n))**(p + S(1))*Simp(-a*b*e*(m + S(1)) + c*x**n*(-S(2)*a*e + b*d)*(m + n*(S(2)*p + S(3)) + S(1)) + d*(-S(2)*a*c*(m + S(2)*n*(p + S(1)) + S(1)) + b**S(2)*(m + n*(p + S(1)) + S(1))), x), x), x) - Simp((f*x)**(m + S(1))*(a + b*x**n + c*x**(S(2)*n))**(p + S(1))*(-a*b*e + c*x**n*(-S(2)*a*e + b*d) + d*(-S(2)*a*c + b**S(2)))/(a*f*n*(p + S(1))*(-S(4)*a*c + b**S(2))), x) rule1337 = ReplacementRule(pattern1337, replacement1337) pattern1338 = Pattern(Integral((x_*WC('f', S(1)))**WC('m', S(1))*(a_ + x_**n2_*WC('c', S(1)))**p_*(d_ + x_**n_*WC('e', S(1))), x_), cons2, cons7, cons27, cons48, cons125, cons21, cons46, cons148, cons13, cons137, cons694) def replacement1338(p, m, f, n2, d, c, n, a, x, e): rubi.append(1338) return Dist(S(1)/(S(2)*a*n*(p + S(1))), Int((f*x)**m*(a + c*x**(S(2)*n))**(p + S(1))*Simp(d*(m + S(2)*n*(p + S(1)) + S(1)) + e*x**n*(m + n*(S(2)*p + S(3)) + S(1)), x), x), x) - Simp((f*x)**(m + S(1))*(a + c*x**(S(2)*n))**(p + S(1))*(d + e*x**n)/(S(2)*a*f*n*(p + S(1))), x) rule1338 = ReplacementRule(pattern1338, replacement1338) pattern1339 = Pattern(Integral((x_*WC('f', S(1)))**WC('m', S(1))*(d_ + x_**n_*WC('e', S(1)))*(a_ + x_**n2_*WC('c', S(1)) + x_**n_*WC('b', S(1)))**p_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons5, cons46, cons226, cons148, cons31, cons530, cons739, cons694) def replacement1339(p, m, f, b, n2, d, c, n, a, x, e): rubi.append(1339) return -Dist(f**n/(c*(m + n*(S(2)*p + S(1)) + S(1))), Int((f*x)**(m - n)*(a + b*x**n + c*x**(S(2)*n))**p*Simp(a*e*(m - n + S(1)) + x**n*(b*e*(m + n*p + S(1)) - c*d*(m + n*(S(2)*p + S(1)) + S(1))), x), x), x) + Simp(e*f**(n + S(-1))*(f*x)**(m - n + S(1))*(a + b*x**n + c*x**(S(2)*n))**(p + S(1))/(c*(m + n*(S(2)*p + S(1)) + S(1))), x) rule1339 = ReplacementRule(pattern1339, replacement1339) pattern1340 = Pattern(Integral((x_*WC('f', S(1)))**WC('m', S(1))*(a_ + x_**n2_*WC('c', S(1)))**p_*(d_ + x_**n_*WC('e', S(1))), x_), cons2, cons7, cons27, cons48, cons125, cons5, cons46, cons148, cons31, cons530, cons739, cons694) def replacement1340(p, m, f, n2, d, c, n, a, x, e): rubi.append(1340) return -Dist(f**n/(c*(m + n*(S(2)*p + S(1)) + S(1))), Int((f*x)**(m - n)*(a + c*x**(S(2)*n))**p*(a*e*(m - n + S(1)) - c*d*x**n*(m + n*(S(2)*p + S(1)) + S(1))), x), x) + Simp(e*f**(n + S(-1))*(f*x)**(m - n + S(1))*(a + c*x**(S(2)*n))**(p + S(1))/(c*(m + n*(S(2)*p + S(1)) + S(1))), x) rule1340 = ReplacementRule(pattern1340, replacement1340) pattern1341 = Pattern(Integral((x_*WC('f', S(1)))**WC('m', S(1))*(d_ + x_**n_*WC('e', S(1)))*(a_ + x_**n2_*WC('c', S(1)) + x_**n_*WC('b', S(1)))**p_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons5, cons46, cons226, cons148, cons31, cons94, cons694) def replacement1341(p, m, f, b, n2, d, c, n, a, x, e): rubi.append(1341) return Dist(f**(-n)/(a*(m + S(1))), Int((f*x)**(m + n)*(a + b*x**n + c*x**(S(2)*n))**p*Simp(a*e*(m + S(1)) - b*d*(m + n*(p + S(1)) + S(1)) - c*d*x**n*(m + S(2)*n*(p + S(1)) + S(1)), x), x), x) + Simp(d*(f*x)**(m + S(1))*(a + b*x**n + c*x**(S(2)*n))**(p + S(1))/(a*f*(m + S(1))), x) rule1341 = ReplacementRule(pattern1341, replacement1341) pattern1342 = Pattern(Integral((x_*WC('f', S(1)))**WC('m', S(1))*(a_ + x_**n2_*WC('c', S(1)))**p_*(d_ + x_**n_*WC('e', S(1))), x_), cons2, cons7, cons27, cons48, cons125, cons5, cons46, cons148, cons31, cons94, cons694) def replacement1342(p, m, f, n2, d, c, n, a, x, e): rubi.append(1342) return Dist(f**(-n)/(a*(m + S(1))), Int((f*x)**(m + n)*(a + c*x**(S(2)*n))**p*(a*e*(m + S(1)) - c*d*x**n*(m + S(2)*n*(p + S(1)) + S(1))), x), x) + Simp(d*(f*x)**(m + S(1))*(a + c*x**(S(2)*n))**(p + S(1))/(a*f*(m + S(1))), x) rule1342 = ReplacementRule(pattern1342, replacement1342) def With1343(m, f, b, n2, d, c, n, a, x, e): if isinstance(x, (int, Integer, float, Float)): return False q = Rt(a*c, S(2)) r = Rt(-b*c + S(2)*c*q, S(2)) if Not(NegativeQ(-b*c + S(2)*c*q)): return True return False pattern1343 = Pattern(Integral((x_*WC('f', S(1)))**m_*(d_ + x_**n_*WC('e', S(1)))/(a_ + x_**n2_*WC('c', S(1)) + x_**n_*WC('b', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons46, cons696, cons740, cons81, cons697, CustomConstraint(With1343)) def replacement1343(m, f, b, n2, d, c, n, a, x, e): q = Rt(a*c, S(2)) r = Rt(-b*c + S(2)*c*q, S(2)) rubi.append(1343) return Dist(c/(2*q*r), Int((f*x)**m*Simp(d*r - x**(n/2)*(c*d - e*q), x)/(c*x**n + q - r*x**(n/2)), x), x) + Dist(c/(2*q*r), Int((f*x)**m*Simp(d*r + x**(n/2)*(c*d - e*q), x)/(c*x**n + q + r*x**(n/2)), x), x) rule1343 = ReplacementRule(pattern1343, replacement1343) def With1344(m, f, n2, d, c, n, a, x, e): if isinstance(x, (int, Integer, float, Float)): return False q = Rt(a*c, S(2)) r = Rt(S(2)*c*q, S(2)) if Not(NegativeQ(S(2)*c*q)): return True return False pattern1344 = Pattern(Integral((x_*WC('f', S(1)))**m_*(d_ + x_**n_*WC('e', S(1)))/(a_ + x_**n2_*WC('c', S(1))), x_), cons2, cons7, cons27, cons48, cons125, cons46, cons434, cons740, cons81, CustomConstraint(With1344)) def replacement1344(m, f, n2, d, c, n, a, x, e): q = Rt(a*c, S(2)) r = Rt(S(2)*c*q, S(2)) rubi.append(1344) return Dist(c/(2*q*r), Int((f*x)**m*Simp(d*r - x**(n/2)*(c*d - e*q), x)/(c*x**n + q - r*x**(n/2)), x), x) + Dist(c/(2*q*r), Int((f*x)**m*Simp(d*r + x**(n/2)*(c*d - e*q), x)/(c*x**n + q + r*x**(n/2)), x), x) rule1344 = ReplacementRule(pattern1344, replacement1344) def With1345(m, f, b, d, c, a, x, e): r = Rt(c*(-b*e + S(2)*c*d)/e, S(2)) rubi.append(1345) return Dist(e/S(2), Int((f*x)**m/(c*d/e + c*x**S(2) - r*x), x), x) + Dist(e/S(2), Int((f*x)**m/(c*d/e + c*x**S(2) + r*x), x), x) pattern1345 = Pattern(Integral((x_*WC('f', S(1)))**WC('m', S(1))*(d_ + x_**S(2)*WC('e', S(1)))/(a_ + x_**S(4)*WC('c', S(1)) + x_**S(2)*WC('b', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons226, cons705, cons741, cons742) rule1345 = ReplacementRule(pattern1345, With1345) def With1346(m, f, d, c, a, x, e): r = Rt(S(2)*c**S(2)*d/e, S(2)) rubi.append(1346) return Dist(e/S(2), Int((f*x)**m/(c*d/e + c*x**S(2) - r*x), x), x) + Dist(e/S(2), Int((f*x)**m/(c*d/e + c*x**S(2) + r*x), x), x) pattern1346 = Pattern(Integral((x_*WC('f', S(1)))**WC('m', S(1))*(d_ + x_**S(2)*WC('e', S(1)))/(a_ + x_**S(4)*WC('c', S(1))), x_), cons2, cons7, cons27, cons48, cons125, cons21, cons705, cons741) rule1346 = ReplacementRule(pattern1346, With1346) def With1347(m, f, b, n2, d, c, n, a, x, e): if isinstance(x, (int, Integer, float, Float)): return False q = Rt(a*c, S(2)) r = Rt(-b*c + S(2)*c*q, S(2)) if Not(NegativeQ(-b*c + S(2)*c*q)): return True return False pattern1347 = Pattern(Integral((x_*WC('f', S(1)))**WC('m', S(1))*(d_ + x_**n_*WC('e', S(1)))/(a_ + x_**n2_*WC('c', S(1)) + x_**n_*WC('b', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons46, cons696, cons743, cons744, cons697, CustomConstraint(With1347)) def replacement1347(m, f, b, n2, d, c, n, a, x, e): q = Rt(a*c, S(2)) r = Rt(-b*c + S(2)*c*q, S(2)) rubi.append(1347) return Dist(c/(2*q*r), Int((f*x)**m*(d*r - x**(n/2)*(c*d - e*q))/(c*x**n + q - r*x**(n/2)), x), x) + Dist(c/(2*q*r), Int((f*x)**m*(d*r + x**(n/2)*(c*d - e*q))/(c*x**n + q + r*x**(n/2)), x), x) rule1347 = ReplacementRule(pattern1347, replacement1347) def With1348(m, f, n2, d, c, n, a, x, e): if isinstance(x, (int, Integer, float, Float)): return False q = Rt(a*c, S(2)) r = Rt(S(2)*c*q, S(2)) if Not(NegativeQ(S(2)*c*q)): return True return False pattern1348 = Pattern(Integral((x_*WC('f', S(1)))**WC('m', S(1))*(d_ + x_**n_*WC('e', S(1)))/(a_ + x_**n2_*WC('c', S(1))), x_), cons2, cons7, cons27, cons48, cons125, cons21, cons46, cons743, cons744, cons434, CustomConstraint(With1348)) def replacement1348(m, f, n2, d, c, n, a, x, e): q = Rt(a*c, S(2)) r = Rt(S(2)*c*q, S(2)) rubi.append(1348) return Dist(c/(2*q*r), Int((f*x)**m*(d*r - x**(n/2)*(c*d - e*q))/(c*x**n + q - r*x**(n/2)), x), x) + Dist(c/(2*q*r), Int((f*x)**m*(d*r + x**(n/2)*(c*d - e*q))/(c*x**n + q + r*x**(n/2)), x), x) rule1348 = ReplacementRule(pattern1348, replacement1348) def With1349(m, f, b, n2, d, c, n, a, x, e): q = Rt(-S(4)*a*c + b**S(2), S(2)) rubi.append(1349) return Dist(e/S(2) - (-b*e + S(2)*c*d)/(S(2)*q), Int((f*x)**m/(b/S(2) + c*x**n + q/S(2)), x), x) + Dist(e/S(2) + (-b*e + S(2)*c*d)/(S(2)*q), Int((f*x)**m/(b/S(2) + c*x**n - q/S(2)), x), x) pattern1349 = Pattern(Integral((x_*WC('f', S(1)))**WC('m', S(1))*(d_ + x_**n_*WC('e', S(1)))/(a_ + x_**n2_*WC('c', S(1)) + x_**n_*WC('b', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons46, cons226, cons148) rule1349 = ReplacementRule(pattern1349, With1349) def With1350(m, f, n2, d, c, n, a, x, e): q = Rt(-a*c, S(2)) rubi.append(1350) return Dist(-c*d/(S(2)*q) + e/S(2), Int((f*x)**m/(c*x**n + q), x), x) - Dist(c*d/(S(2)*q) + e/S(2), Int((f*x)**m/(-c*x**n + q), x), x) pattern1350 = Pattern(Integral((x_*WC('f', S(1)))**WC('m', S(1))*(d_ + x_**n_*WC('e', S(1)))/(a_ + x_**n2_*WC('c', S(1))), x_), cons2, cons7, cons27, cons48, cons125, cons21, cons46, cons148) rule1350 = ReplacementRule(pattern1350, With1350) pattern1351 = Pattern(Integral((x_*WC('f', S(1)))**WC('m', S(1))*(d_ + x_**n_*WC('e', S(1)))**WC('q', S(1))/(a_ + x_**n_*WC('b', S(1)) + x_**WC('n2', S(1))*WC('c', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons46, cons226, cons148, cons586, cons17) def replacement1351(m, f, b, n2, d, c, a, n, x, q, e): rubi.append(1351) return Int(ExpandIntegrand((f*x)**m*(d + e*x**n)**q/(a + b*x**n + c*x**(S(2)*n)), x), x) rule1351 = ReplacementRule(pattern1351, replacement1351) pattern1352 = Pattern(Integral((x_*WC('f', S(1)))**WC('m', S(1))*(d_ + x_**n_*WC('e', S(1)))**WC('q', S(1))/(a_ + x_**WC('n2', S(1))*WC('c', S(1))), x_), cons2, cons7, cons27, cons48, cons125, cons21, cons46, cons148, cons586, cons17) def replacement1352(m, f, n2, d, c, a, n, x, q, e): rubi.append(1352) return Int(ExpandIntegrand((f*x)**m*(d + e*x**n)**q/(a + c*x**(S(2)*n)), x), x) rule1352 = ReplacementRule(pattern1352, replacement1352) pattern1353 = Pattern(Integral((x_*WC('f', S(1)))**WC('m', S(1))*(d_ + x_**n_*WC('e', S(1)))**WC('q', S(1))/(a_ + x_**n_*WC('b', S(1)) + x_**WC('n2', S(1))*WC('c', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons46, cons226, cons148, cons586, cons18) def replacement1353(m, f, b, n2, d, c, a, n, x, q, e): rubi.append(1353) return Int(ExpandIntegrand((f*x)**m, (d + e*x**n)**q/(a + b*x**n + c*x**(S(2)*n)), x), x) rule1353 = ReplacementRule(pattern1353, replacement1353) pattern1354 = Pattern(Integral((x_*WC('f', S(1)))**WC('m', S(1))*(d_ + x_**n_*WC('e', S(1)))**WC('q', S(1))/(a_ + x_**WC('n2', S(1))*WC('c', S(1))), x_), cons2, cons7, cons27, cons48, cons125, cons21, cons46, cons148, cons586, cons18) def replacement1354(m, f, n2, d, c, a, n, x, q, e): rubi.append(1354) return Int(ExpandIntegrand((f*x)**m, (d + e*x**n)**q/(a + c*x**(S(2)*n)), x), x) rule1354 = ReplacementRule(pattern1354, replacement1354) pattern1355 = Pattern(Integral((x_*WC('f', S(1)))**WC('m', S(1))*(x_**n_*WC('e', S(1)) + WC('d', S(0)))**q_/(a_ + x_**n_*WC('b', S(1)) + x_**WC('n2', S(1))*WC('c', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons46, cons226, cons148, cons386, cons611, cons403, cons529) def replacement1355(m, f, b, n2, d, c, a, n, x, q, e): rubi.append(1355) return Dist(f**(S(2)*n)/c**S(2), Int((f*x)**(m - S(2)*n)*(d + e*x**n)**(q + S(-1))*(-b*e + c*d + c*e*x**n), x), x) - Dist(f**(S(2)*n)/c**S(2), Int((f*x)**(m - S(2)*n)*(d + e*x**n)**(q + S(-1))*Simp(a*(-b*e + c*d) + x**n*(a*c*e - b**S(2)*e + b*c*d), x)/(a + b*x**n + c*x**(S(2)*n)), x), x) rule1355 = ReplacementRule(pattern1355, replacement1355) pattern1356 = Pattern(Integral((x_*WC('f', S(1)))**WC('m', S(1))*(x_**n_*WC('e', S(1)) + WC('d', S(0)))**q_/(a_ + x_**WC('n2', S(1))*WC('c', S(1))), x_), cons2, cons7, cons27, cons48, cons125, cons50, cons46, cons148, cons386, cons31, cons529) def replacement1356(m, f, n2, d, c, a, n, x, q, e): rubi.append(1356) return Dist(f**(S(2)*n)/c, Int((f*x)**(m - S(2)*n)*(d + e*x**n)**q, x), x) - Dist(a*f**(S(2)*n)/c, Int((f*x)**(m - S(2)*n)*(d + e*x**n)**q/(a + c*x**(S(2)*n)), x), x) rule1356 = ReplacementRule(pattern1356, replacement1356) pattern1357 = Pattern(Integral((x_*WC('f', S(1)))**WC('m', S(1))*(x_**n_*WC('e', S(1)) + WC('d', S(0)))**q_/(a_ + x_**n_*WC('b', S(1)) + x_**WC('n2', S(1))*WC('c', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons46, cons226, cons148, cons386, cons611, cons403, cons690) def replacement1357(m, f, b, n2, d, c, a, n, x, q, e): rubi.append(1357) return -Dist(f**n/c, Int((f*x)**(m - n)*(d + e*x**n)**(q + S(-1))*Simp(a*e - x**n*(-b*e + c*d), x)/(a + b*x**n + c*x**(S(2)*n)), x), x) + Dist(e*f**n/c, Int((f*x)**(m - n)*(d + e*x**n)**(q + S(-1)), x), x) rule1357 = ReplacementRule(pattern1357, replacement1357) pattern1358 = Pattern(Integral((x_*WC('f', S(1)))**WC('m', S(1))*(x_**n_*WC('e', S(1)) + WC('d', S(0)))**q_/(a_ + x_**WC('n2', S(1))*WC('c', S(1))), x_), cons2, cons7, cons27, cons48, cons125, cons46, cons148, cons386, cons611, cons403, cons690) def replacement1358(m, f, n2, d, c, a, n, x, q, e): rubi.append(1358) return -Dist(f**n/c, Int((f*x)**(m - n)*(d + e*x**n)**(q + S(-1))*Simp(a*e - c*d*x**n, x)/(a + c*x**(S(2)*n)), x), x) + Dist(e*f**n/c, Int((f*x)**(m - n)*(d + e*x**n)**(q + S(-1)), x), x) rule1358 = ReplacementRule(pattern1358, replacement1358) pattern1359 = Pattern(Integral((x_*WC('f', S(1)))**m_*(x_**n_*WC('e', S(1)) + WC('d', S(0)))**q_/(a_ + x_**n_*WC('b', S(1)) + x_**WC('n2', S(1))*WC('c', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons46, cons226, cons148, cons386, cons611, cons403, cons267) def replacement1359(m, f, b, n2, d, c, a, n, x, q, e): rubi.append(1359) return Dist(d/a, Int((f*x)**m*(d + e*x**n)**(q + S(-1)), x), x) - Dist(f**(-n)/a, Int((f*x)**(m + n)*(d + e*x**n)**(q + S(-1))*Simp(-a*e + b*d + c*d*x**n, x)/(a + b*x**n + c*x**(S(2)*n)), x), x) rule1359 = ReplacementRule(pattern1359, replacement1359) pattern1360 = Pattern(Integral((x_*WC('f', S(1)))**m_*(x_**n_*WC('e', S(1)) + WC('d', S(0)))**q_/(a_ + x_**WC('n2', S(1))*WC('c', S(1))), x_), cons2, cons7, cons27, cons48, cons125, cons46, cons148, cons386, cons611, cons403, cons267) def replacement1360(m, f, n2, d, c, a, n, x, q, e): rubi.append(1360) return Dist(d/a, Int((f*x)**m*(d + e*x**n)**(q + S(-1)), x), x) + Dist(f**(-n)/a, Int((f*x)**(m + n)*(d + e*x**n)**(q + S(-1))*Simp(a*e - c*d*x**n, x)/(a + c*x**(S(2)*n)), x), x) rule1360 = ReplacementRule(pattern1360, replacement1360) pattern1361 = Pattern(Integral((x_*WC('f', S(1)))**WC('m', S(1))*(x_**n_*WC('e', S(1)) + WC('d', S(0)))**q_/(a_ + x_**n_*WC('b', S(1)) + x_**WC('n2', S(1))*WC('c', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons46, cons226, cons148, cons386, cons611, cons396, cons529) def replacement1361(m, f, b, n2, d, c, a, n, x, q, e): rubi.append(1361) return -Dist(f**(S(2)*n)/(a*e**S(2) - b*d*e + c*d**S(2)), Int((f*x)**(m - S(2)*n)*(d + e*x**n)**(q + S(1))*Simp(a*d + x**n*(-a*e + b*d), x)/(a + b*x**n + c*x**(S(2)*n)), x), x) + Dist(d**S(2)*f**(S(2)*n)/(a*e**S(2) - b*d*e + c*d**S(2)), Int((f*x)**(m - S(2)*n)*(d + e*x**n)**q, x), x) rule1361 = ReplacementRule(pattern1361, replacement1361) pattern1362 = Pattern(Integral((x_*WC('f', S(1)))**WC('m', S(1))*(x_**n_*WC('e', S(1)) + WC('d', S(0)))**q_/(a_ + x_**WC('n2', S(1))*WC('c', S(1))), x_), cons2, cons7, cons27, cons48, cons125, cons46, cons148, cons386, cons611, cons396, cons529) def replacement1362(m, f, n2, d, c, a, n, x, q, e): rubi.append(1362) return -Dist(a*f**(S(2)*n)/(a*e**S(2) + c*d**S(2)), Int((f*x)**(m - S(2)*n)*(d - e*x**n)*(d + e*x**n)**(q + S(1))/(a + c*x**(S(2)*n)), x), x) + Dist(d**S(2)*f**(S(2)*n)/(a*e**S(2) + c*d**S(2)), Int((f*x)**(m - S(2)*n)*(d + e*x**n)**q, x), x) rule1362 = ReplacementRule(pattern1362, replacement1362) pattern1363 = Pattern(Integral((x_*WC('f', S(1)))**WC('m', S(1))*(x_**n_*WC('e', S(1)) + WC('d', S(0)))**q_/(a_ + x_**n_*WC('b', S(1)) + x_**WC('n2', S(1))*WC('c', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons46, cons226, cons148, cons386, cons611, cons396, cons690) def replacement1363(m, f, b, n2, d, c, a, n, x, q, e): rubi.append(1363) return Dist(f**n/(a*e**S(2) - b*d*e + c*d**S(2)), Int((f*x)**(m - n)*(d + e*x**n)**(q + S(1))*Simp(a*e + c*d*x**n, x)/(a + b*x**n + c*x**(S(2)*n)), x), x) - Dist(d*e*f**n/(a*e**S(2) - b*d*e + c*d**S(2)), Int((f*x)**(m - n)*(d + e*x**n)**q, x), x) rule1363 = ReplacementRule(pattern1363, replacement1363) pattern1364 = Pattern(Integral((x_*WC('f', S(1)))**WC('m', S(1))*(x_**n_*WC('e', S(1)) + WC('d', S(0)))**q_/(a_ + x_**WC('n2', S(1))*WC('c', S(1))), x_), cons2, cons7, cons27, cons48, cons125, cons46, cons148, cons386, cons611, cons396, cons690) def replacement1364(m, f, n2, d, c, a, n, x, q, e): rubi.append(1364) return Dist(f**n/(a*e**S(2) + c*d**S(2)), Int((f*x)**(m - n)*(d + e*x**n)**(q + S(1))*Simp(a*e + c*d*x**n, x)/(a + c*x**(S(2)*n)), x), x) - Dist(d*e*f**n/(a*e**S(2) + c*d**S(2)), Int((f*x)**(m - n)*(d + e*x**n)**q, x), x) rule1364 = ReplacementRule(pattern1364, replacement1364) pattern1365 = Pattern(Integral((x_*WC('f', S(1)))**WC('m', S(1))*(d_ + x_**n_*WC('e', S(1)))**q_/(a_ + x_**n2_*WC('c', S(1)) + x_**n_*WC('b', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons46, cons226, cons148, cons386, cons395, cons396) def replacement1365(m, f, b, n2, d, c, n, a, x, q, e): rubi.append(1365) return Dist(e**S(2)/(a*e**S(2) - b*d*e + c*d**S(2)), Int((f*x)**m*(d + e*x**n)**q, x), x) + Dist(S(1)/(a*e**S(2) - b*d*e + c*d**S(2)), Int((f*x)**m*(d + e*x**n)**(q + S(1))*Simp(-b*e + c*d - c*e*x**n, x)/(a + b*x**n + c*x**(S(2)*n)), x), x) rule1365 = ReplacementRule(pattern1365, replacement1365) pattern1366 = Pattern(Integral((x_*WC('f', S(1)))**WC('m', S(1))*(d_ + x_**n_*WC('e', S(1)))**q_/(a_ + x_**n2_*WC('c', S(1))), x_), cons2, cons7, cons27, cons48, cons125, cons21, cons46, cons148, cons386, cons395, cons396) def replacement1366(m, f, n2, d, c, n, a, x, q, e): rubi.append(1366) return Dist(c/(a*e**S(2) + c*d**S(2)), Int((f*x)**m*(d - e*x**n)*(d + e*x**n)**(q + S(1))/(a + c*x**(S(2)*n)), x), x) + Dist(e**S(2)/(a*e**S(2) + c*d**S(2)), Int((f*x)**m*(d + e*x**n)**q, x), x) rule1366 = ReplacementRule(pattern1366, replacement1366) pattern1367 = Pattern(Integral((x_*WC('f', S(1)))**WC('m', S(1))*(d_ + x_**n_*WC('e', S(1)))**q_/(a_ + x_**n_*WC('b', S(1)) + x_**WC('n2', S(1))*WC('c', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons50, cons4, cons46, cons226, cons148, cons386, cons17) def replacement1367(m, f, b, n2, d, c, a, n, x, q, e): rubi.append(1367) return Int(ExpandIntegrand((d + e*x**n)**q, (f*x)**m/(a + b*x**n + c*x**(S(2)*n)), x), x) rule1367 = ReplacementRule(pattern1367, replacement1367) pattern1368 = Pattern(Integral((x_*WC('f', S(1)))**WC('m', S(1))*(d_ + x_**n_*WC('e', S(1)))**q_/(a_ + x_**WC('n2', S(1))*WC('c', S(1))), x_), cons2, cons7, cons27, cons48, cons125, cons50, cons4, cons46, cons148, cons386, cons17) def replacement1368(m, f, n2, d, c, a, n, x, q, e): rubi.append(1368) return Int(ExpandIntegrand((d + e*x**n)**q, (f*x)**m/(a + c*x**(S(2)*n)), x), x) rule1368 = ReplacementRule(pattern1368, replacement1368) pattern1369 = Pattern(Integral((x_*WC('f', S(1)))**WC('m', S(1))*(d_ + x_**n_*WC('e', S(1)))**q_/(a_ + x_**n_*WC('b', S(1)) + x_**WC('n2', S(1))*WC('c', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons50, cons4, cons46, cons226, cons148, cons386, cons18) def replacement1369(m, f, b, n2, d, c, a, n, x, q, e): rubi.append(1369) return Int(ExpandIntegrand((f*x)**m*(d + e*x**n)**q, S(1)/(a + b*x**n + c*x**(S(2)*n)), x), x) rule1369 = ReplacementRule(pattern1369, replacement1369) pattern1370 = Pattern(Integral((x_*WC('f', S(1)))**WC('m', S(1))*(d_ + x_**n_*WC('e', S(1)))**q_/(a_ + x_**WC('n2', S(1))*WC('c', S(1))), x_), cons2, cons7, cons27, cons48, cons125, cons21, cons50, cons4, cons46, cons148, cons386, cons18) def replacement1370(m, f, n2, d, c, a, n, x, q, e): rubi.append(1370) return Int(ExpandIntegrand((f*x)**m*(d + e*x**n)**q, S(1)/(a + c*x**(S(2)*n)), x), x) rule1370 = ReplacementRule(pattern1370, replacement1370) pattern1371 = Pattern(Integral((x_*WC('f', S(1)))**m_*(x_**n_*WC('b', S(1)) + x_**WC('n2', S(1))*WC('c', S(1)) + WC('a', S(0)))**WC('p', S(1))/(x_**n_*WC('e', S(1)) + WC('d', S(0))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons46, cons226, cons148, cons244, cons163, cons745) def replacement1371(p, m, f, b, n2, d, a, c, n, x, e): rubi.append(1371) return Dist(d**(S(-2)), Int((f*x)**m*(a*d + x**n*(-a*e + b*d))*(a + b*x**n + c*x**(S(2)*n))**(p + S(-1)), x), x) + Dist(f**(-S(2)*n)*(a*e**S(2) - b*d*e + c*d**S(2))/d**S(2), Int((f*x)**(m + S(2)*n)*(a + b*x**n + c*x**(S(2)*n))**(p + S(-1))/(d + e*x**n), x), x) rule1371 = ReplacementRule(pattern1371, replacement1371) pattern1372 = Pattern(Integral((x_*WC('f', S(1)))**m_*(a_ + x_**WC('n2', S(1))*WC('c', S(1)))**WC('p', S(1))/(x_**n_*WC('e', S(1)) + WC('d', S(0))), x_), cons2, cons7, cons27, cons48, cons125, cons46, cons148, cons244, cons163, cons745) def replacement1372(p, m, f, n2, d, c, a, n, x, e): rubi.append(1372) return Dist(a/d**S(2), Int((f*x)**m*(a + c*x**(S(2)*n))**(p + S(-1))*(d - e*x**n), x), x) + Dist(f**(-S(2)*n)*(a*e**S(2) + c*d**S(2))/d**S(2), Int((f*x)**(m + S(2)*n)*(a + c*x**(S(2)*n))**(p + S(-1))/(d + e*x**n), x), x) rule1372 = ReplacementRule(pattern1372, replacement1372) pattern1373 = Pattern(Integral((x_*WC('f', S(1)))**m_*(x_**n_*WC('b', S(1)) + x_**WC('n2', S(1))*WC('c', S(1)) + WC('a', S(0)))**WC('p', S(1))/(x_**n_*WC('e', S(1)) + WC('d', S(0))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons46, cons226, cons148, cons244, cons163, cons267) def replacement1373(p, m, f, b, n2, d, a, c, n, x, e): rubi.append(1373) return Dist(S(1)/(d*e), Int((f*x)**m*(a*e + c*d*x**n)*(a + b*x**n + c*x**(S(2)*n))**(p + S(-1)), x), x) - Dist(f**(-n)*(a*e**S(2) - b*d*e + c*d**S(2))/(d*e), Int((f*x)**(m + n)*(a + b*x**n + c*x**(S(2)*n))**(p + S(-1))/(d + e*x**n), x), x) rule1373 = ReplacementRule(pattern1373, replacement1373) pattern1374 = Pattern(Integral((x_*WC('f', S(1)))**m_*(a_ + x_**WC('n2', S(1))*WC('c', S(1)))**WC('p', S(1))/(x_**n_*WC('e', S(1)) + WC('d', S(0))), x_), cons2, cons7, cons27, cons48, cons125, cons46, cons148, cons244, cons163, cons267) def replacement1374(p, m, f, n2, d, c, a, n, x, e): rubi.append(1374) return Dist(S(1)/(d*e), Int((f*x)**m*(a + c*x**(S(2)*n))**(p + S(-1))*(a*e + c*d*x**n), x), x) - Dist(f**(-n)*(a*e**S(2) + c*d**S(2))/(d*e), Int((f*x)**(m + n)*(a + c*x**(S(2)*n))**(p + S(-1))/(d + e*x**n), x), x) rule1374 = ReplacementRule(pattern1374, replacement1374) pattern1375 = Pattern(Integral((x_*WC('f', S(1)))**WC('m', S(1))*(x_**n_*WC('b', S(1)) + x_**WC('n2', S(1))*WC('c', S(1)) + WC('a', S(0)))**p_/(x_**n_*WC('e', S(1)) + WC('d', S(0))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons46, cons226, cons148, cons244, cons137, cons746) def replacement1375(p, m, f, b, n2, d, c, a, n, x, e): rubi.append(1375) return -Dist(f**(S(2)*n)/(a*e**S(2) - b*d*e + c*d**S(2)), Int((f*x)**(m - S(2)*n)*(a*d + x**n*(-a*e + b*d))*(a + b*x**n + c*x**(S(2)*n))**p, x), x) + Dist(d**S(2)*f**(S(2)*n)/(a*e**S(2) - b*d*e + c*d**S(2)), Int((f*x)**(m - S(2)*n)*(a + b*x**n + c*x**(S(2)*n))**(p + S(1))/(d + e*x**n), x), x) rule1375 = ReplacementRule(pattern1375, replacement1375) pattern1376 = Pattern(Integral((x_*WC('f', S(1)))**WC('m', S(1))*(a_ + x_**WC('n2', S(1))*WC('c', S(1)))**p_/(x_**n_*WC('e', S(1)) + WC('d', S(0))), x_), cons2, cons7, cons27, cons48, cons125, cons46, cons148, cons244, cons137, cons746) def replacement1376(p, m, f, n2, d, c, a, n, x, e): rubi.append(1376) return -Dist(a*f**(S(2)*n)/(a*e**S(2) + c*d**S(2)), Int((f*x)**(m - S(2)*n)*(a + c*x**(S(2)*n))**p*(d - e*x**n), x), x) + Dist(d**S(2)*f**(S(2)*n)/(a*e**S(2) + c*d**S(2)), Int((f*x)**(m - S(2)*n)*(a + c*x**(S(2)*n))**(p + S(1))/(d + e*x**n), x), x) rule1376 = ReplacementRule(pattern1376, replacement1376) pattern1377 = Pattern(Integral((x_*WC('f', S(1)))**WC('m', S(1))*(x_**n_*WC('b', S(1)) + x_**WC('n2', S(1))*WC('c', S(1)) + WC('a', S(0)))**p_/(x_**n_*WC('e', S(1)) + WC('d', S(0))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons46, cons226, cons148, cons244, cons137, cons168) def replacement1377(p, m, f, b, n2, d, c, a, n, x, e): rubi.append(1377) return Dist(f**n/(a*e**S(2) - b*d*e + c*d**S(2)), Int((f*x)**(m - n)*(a*e + c*d*x**n)*(a + b*x**n + c*x**(S(2)*n))**p, x), x) - Dist(d*e*f**n/(a*e**S(2) - b*d*e + c*d**S(2)), Int((f*x)**(m - n)*(a + b*x**n + c*x**(S(2)*n))**(p + S(1))/(d + e*x**n), x), x) rule1377 = ReplacementRule(pattern1377, replacement1377) pattern1378 = Pattern(Integral((x_*WC('f', S(1)))**WC('m', S(1))*(a_ + x_**WC('n2', S(1))*WC('c', S(1)))**p_/(x_**n_*WC('e', S(1)) + WC('d', S(0))), x_), cons2, cons7, cons27, cons48, cons125, cons46, cons148, cons244, cons137, cons168) def replacement1378(p, m, f, n2, d, c, a, n, x, e): rubi.append(1378) return Dist(f**n/(a*e**S(2) + c*d**S(2)), Int((f*x)**(m - n)*(a + c*x**(S(2)*n))**p*(a*e + c*d*x**n), x), x) - Dist(d*e*f**n/(a*e**S(2) + c*d**S(2)), Int((f*x)**(m - n)*(a + c*x**(S(2)*n))**(p + S(1))/(d + e*x**n), x), x) rule1378 = ReplacementRule(pattern1378, replacement1378) pattern1379 = Pattern(Integral((x_*WC('f', S(1)))**WC('m', S(1))*(d_ + x_**n_*WC('e', S(1)))**WC('q', S(1))*(a_ + x_**n_*WC('b', S(1)) + x_**WC('n2', S(1))*WC('c', S(1)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons50, cons46, cons226, cons148, cons747) def replacement1379(p, m, f, b, n2, d, c, a, n, x, q, e): rubi.append(1379) return Int(ExpandIntegrand((a + b*x**n + c*x**(S(2)*n))**p, (f*x)**m*(d + e*x**n)**q, x), x) rule1379 = ReplacementRule(pattern1379, replacement1379) pattern1380 = Pattern(Integral((x_*WC('f', S(1)))**WC('m', S(1))*(a_ + x_**WC('n2', S(1))*WC('c', S(1)))**WC('p', S(1))*(d_ + x_**n_*WC('e', S(1)))**WC('q', S(1)), x_), cons2, cons7, cons27, cons48, cons125, cons21, cons50, cons46, cons148, cons747) def replacement1380(p, m, f, n2, d, c, a, n, x, q, e): rubi.append(1380) return Int(ExpandIntegrand((a + c*x**(S(2)*n))**p, (f*x)**m*(d + e*x**n)**q, x), x) rule1380 = ReplacementRule(pattern1380, replacement1380) pattern1381 = Pattern(Integral(x_**WC('m', S(1))*(d_ + x_**n_*WC('e', S(1)))**WC('q', S(1))*(a_ + x_**n_*WC('b', S(1)) + x_**WC('n2', S(1))*WC('c', S(1)))**p_, x_), cons2, cons3, cons7, cons27, cons48, cons5, cons50, cons46, cons226, cons196, cons17) def replacement1381(p, m, b, n2, d, c, a, n, x, q, e): rubi.append(1381) return -Subst(Int(x**(-m + S(-2))*(d + e*x**(-n))**q*(a + b*x**(-n) + c*x**(-S(2)*n))**p, x), x, S(1)/x) rule1381 = ReplacementRule(pattern1381, replacement1381) pattern1382 = Pattern(Integral(x_**WC('m', S(1))*(a_ + x_**WC('n2', S(1))*WC('c', S(1)))**p_*(d_ + x_**n_*WC('e', S(1)))**WC('q', S(1)), x_), cons2, cons7, cons27, cons48, cons5, cons50, cons46, cons196, cons17) def replacement1382(p, m, n2, d, c, a, n, x, q, e): rubi.append(1382) return -Subst(Int(x**(-m + S(-2))*(a + c*x**(-S(2)*n))**p*(d + e*x**(-n))**q, x), x, S(1)/x) rule1382 = ReplacementRule(pattern1382, replacement1382) def With1383(p, m, f, b, n2, d, c, a, n, x, q, e): g = Denominator(m) rubi.append(1383) return -Dist(g/f, Subst(Int(x**(-g*(m + S(1)) + S(-1))*(d + e*f**(-n)*x**(-g*n))**q*(a + b*f**(-n)*x**(-g*n) + c*f**(-S(2)*n)*x**(-S(2)*g*n))**p, x), x, (f*x)**(-S(1)/g)), x) pattern1383 = Pattern(Integral((x_*WC('f', S(1)))**WC('m', S(1))*(d_ + x_**n_*WC('e', S(1)))**WC('q', S(1))*(a_ + x_**n_*WC('b', S(1)) + x_**WC('n2', S(1))*WC('c', S(1)))**p_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons5, cons50, cons46, cons226, cons196, cons367) rule1383 = ReplacementRule(pattern1383, With1383) def With1384(p, m, f, n2, d, c, a, n, x, q, e): g = Denominator(m) rubi.append(1384) return -Dist(g/f, Subst(Int(x**(-g*(m + S(1)) + S(-1))*(a + c*f**(-S(2)*n)*x**(-S(2)*g*n))**p*(d + e*f**(-n)*x**(-g*n))**q, x), x, (f*x)**(-S(1)/g)), x) pattern1384 = Pattern(Integral((x_*WC('f', S(1)))**WC('m', S(1))*(a_ + x_**WC('n2', S(1))*WC('c', S(1)))**p_*(d_ + x_**n_*WC('e', S(1)))**WC('q', S(1)), x_), cons2, cons7, cons27, cons48, cons125, cons5, cons50, cons46, cons196, cons367) rule1384 = ReplacementRule(pattern1384, With1384) pattern1385 = Pattern(Integral((x_*WC('f', S(1)))**m_*(d_ + x_**n_*WC('e', S(1)))**WC('q', S(1))*(a_ + x_**n_*WC('b', S(1)) + x_**WC('n2', S(1))*WC('c', S(1)))**p_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons5, cons50, cons46, cons226, cons196, cons356) def replacement1385(p, m, f, b, n2, d, c, a, n, x, q, e): rubi.append(1385) return -Dist(f**IntPart(m)*(f*x)**FracPart(m)*(S(1)/x)**FracPart(m), Subst(Int(x**(-m + S(-2))*(d + e*x**(-n))**q*(a + b*x**(-n) + c*x**(-S(2)*n))**p, x), x, S(1)/x), x) rule1385 = ReplacementRule(pattern1385, replacement1385) pattern1386 = Pattern(Integral((x_*WC('f', S(1)))**m_*(a_ + x_**WC('n2', S(1))*WC('c', S(1)))**p_*(d_ + x_**n_*WC('e', S(1)))**WC('q', S(1)), x_), cons2, cons7, cons27, cons48, cons125, cons21, cons5, cons50, cons46, cons196, cons356) def replacement1386(p, m, f, n2, d, c, a, n, x, q, e): rubi.append(1386) return -Dist(f**IntPart(m)*(f*x)**FracPart(m)*(S(1)/x)**FracPart(m), Subst(Int(x**(-m + S(-2))*(a + c*x**(-S(2)*n))**p*(d + e*x**(-n))**q, x), x, S(1)/x), x) rule1386 = ReplacementRule(pattern1386, replacement1386) def With1387(p, m, b, n2, d, c, a, n, x, q, e): g = Denominator(n) rubi.append(1387) return Dist(g, Subst(Int(x**(g*(m + S(1)) + S(-1))*(d + e*x**(g*n))**q*(a + b*x**(g*n) + c*x**(S(2)*g*n))**p, x), x, x**(S(1)/g)), x) pattern1387 = Pattern(Integral(x_**WC('m', S(1))*(d_ + x_**n_*WC('e', S(1)))**WC('q', S(1))*(a_ + x_**n_*WC('b', S(1)) + x_**WC('n2', S(1))*WC('c', S(1)))**p_, x_), cons2, cons3, cons7, cons27, cons48, cons21, cons5, cons50, cons46, cons226, cons489) rule1387 = ReplacementRule(pattern1387, With1387) def With1388(p, m, n2, d, c, a, n, x, q, e): g = Denominator(n) rubi.append(1388) return Dist(g, Subst(Int(x**(g*(m + S(1)) + S(-1))*(a + c*x**(S(2)*g*n))**p*(d + e*x**(g*n))**q, x), x, x**(S(1)/g)), x) pattern1388 = Pattern(Integral(x_**WC('m', S(1))*(a_ + x_**WC('n2', S(1))*WC('c', S(1)))**p_*(d_ + x_**n_*WC('e', S(1)))**WC('q', S(1)), x_), cons2, cons7, cons27, cons48, cons21, cons5, cons50, cons46, cons489) rule1388 = ReplacementRule(pattern1388, With1388) pattern1389 = Pattern(Integral((f_*x_)**m_*(d_ + x_**n_*WC('e', S(1)))**WC('q', S(1))*(a_ + x_**n_*WC('b', S(1)) + x_**WC('n2', S(1))*WC('c', S(1)))**p_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons5, cons50, cons46, cons226, cons489) def replacement1389(p, m, f, b, n2, d, c, a, n, x, q, e): rubi.append(1389) return Dist(f**IntPart(m)*x**(-FracPart(m))*(f*x)**FracPart(m), Int(x**m*(d + e*x**n)**q*(a + b*x**n + c*x**(S(2)*n))**p, x), x) rule1389 = ReplacementRule(pattern1389, replacement1389) pattern1390 = Pattern(Integral((f_*x_)**m_*(a_ + x_**WC('n2', S(1))*WC('c', S(1)))**p_*(d_ + x_**n_*WC('e', S(1)))**WC('q', S(1)), x_), cons2, cons7, cons27, cons48, cons125, cons21, cons5, cons50, cons46, cons489) def replacement1390(p, m, f, n2, d, c, a, n, x, q, e): rubi.append(1390) return Dist(f**IntPart(m)*x**(-FracPart(m))*(f*x)**FracPart(m), Int(x**m*(a + c*x**(S(2)*n))**p*(d + e*x**n)**q, x), x) rule1390 = ReplacementRule(pattern1390, replacement1390) pattern1391 = Pattern(Integral(x_**WC('m', S(1))*(d_ + x_**n_*WC('e', S(1)))**WC('q', S(1))*(a_ + x_**n_*WC('b', S(1)) + x_**WC('n2', S(1))*WC('c', S(1)))**p_, x_), cons2, cons3, cons7, cons27, cons48, cons21, cons4, cons5, cons50, cons46, cons226, cons541, cons23) def replacement1391(p, m, b, n2, d, c, a, n, x, q, e): rubi.append(1391) return Dist(S(1)/(m + S(1)), Subst(Int((d + e*x**(n/(m + S(1))))**q*(a + b*x**(n/(m + S(1))) + c*x**(S(2)*n/(m + S(1))))**p, x), x, x**(m + S(1))), x) rule1391 = ReplacementRule(pattern1391, replacement1391) pattern1392 = Pattern(Integral(x_**WC('m', S(1))*(a_ + x_**WC('n2', S(1))*WC('c', S(1)))**p_*(d_ + x_**n_*WC('e', S(1)))**WC('q', S(1)), x_), cons2, cons7, cons27, cons48, cons21, cons4, cons5, cons50, cons46, cons541, cons23) def replacement1392(p, m, n2, d, c, a, n, x, q, e): rubi.append(1392) return Dist(S(1)/(m + S(1)), Subst(Int((a + c*x**(S(2)*n/(m + S(1))))**p*(d + e*x**(n/(m + S(1))))**q, x), x, x**(m + S(1))), x) rule1392 = ReplacementRule(pattern1392, replacement1392) pattern1393 = Pattern(Integral((f_*x_)**m_*(d_ + x_**n_*WC('e', S(1)))**WC('q', S(1))*(a_ + x_**n_*WC('b', S(1)) + x_**WC('n2', S(1))*WC('c', S(1)))**p_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons5, cons50, cons46, cons226, cons541, cons23) def replacement1393(p, m, f, b, n2, d, c, a, n, x, q, e): rubi.append(1393) return Dist(f**IntPart(m)*x**(-FracPart(m))*(f*x)**FracPart(m), Int(x**m*(d + e*x**n)**q*(a + b*x**n + c*x**(S(2)*n))**p, x), x) rule1393 = ReplacementRule(pattern1393, replacement1393) pattern1394 = Pattern(Integral((f_*x_)**m_*(a_ + x_**WC('n2', S(1))*WC('c', S(1)))**p_*(d_ + x_**n_*WC('e', S(1)))**WC('q', S(1)), x_), cons2, cons7, cons27, cons48, cons125, cons21, cons5, cons50, cons46, cons541, cons23) def replacement1394(p, m, f, n2, d, c, a, n, x, q, e): rubi.append(1394) return Dist(f**IntPart(m)*x**(-FracPart(m))*(f*x)**FracPart(m), Int(x**m*(a + c*x**(S(2)*n))**p*(d + e*x**n)**q, x), x) rule1394 = ReplacementRule(pattern1394, replacement1394) def With1395(m, f, b, n2, d, c, a, n, x, q, e): r = Rt(-S(4)*a*c + b**S(2), S(2)) rubi.append(1395) return Dist(S(2)*c/r, Int((f*x)**m*(d + e*x**n)**q/(b + S(2)*c*x**n - r), x), x) - Dist(S(2)*c/r, Int((f*x)**m*(d + e*x**n)**q/(b + S(2)*c*x**n + r), x), x) pattern1395 = Pattern(Integral((x_*WC('f', S(1)))**WC('m', S(1))*(d_ + x_**n_*WC('e', S(1)))**q_/(a_ + x_**n_*WC('b', S(1)) + x_**WC('n2', S(1))*WC('c', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons4, cons50, cons46, cons226) rule1395 = ReplacementRule(pattern1395, With1395) def With1396(m, f, n2, d, c, a, n, x, q, e): r = Rt(-a*c, S(2)) rubi.append(1396) return -Dist(c/(S(2)*r), Int((f*x)**m*(d + e*x**n)**q/(-c*x**n + r), x), x) - Dist(c/(S(2)*r), Int((f*x)**m*(d + e*x**n)**q/(c*x**n + r), x), x) pattern1396 = Pattern(Integral((x_*WC('f', S(1)))**WC('m', S(1))*(d_ + x_**n_*WC('e', S(1)))**q_/(a_ + x_**WC('n2', S(1))*WC('c', S(1))), x_), cons2, cons7, cons27, cons48, cons125, cons21, cons4, cons50, cons46) rule1396 = ReplacementRule(pattern1396, With1396) pattern1397 = Pattern(Integral((x_*WC('f', S(1)))**WC('m', S(1))*(d_ + x_**n_*WC('e', S(1)))*(a_ + x_**n2_*WC('c', S(1)) + x_**n_*WC('b', S(1)))**p_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons4, cons46, cons226, cons702) def replacement1397(p, m, f, b, n2, d, c, n, a, x, e): rubi.append(1397) return Dist(S(1)/(a*n*(p + S(1))*(-S(4)*a*c + b**S(2))), Int((f*x)**m*(a + b*x**n + c*x**(S(2)*n))**(p + S(1))*Simp(-a*b*e*(m + S(1)) + c*x**n*(-S(2)*a*e + b*d)*(m + n*(S(2)*p + S(3)) + S(1)) + d*(-S(2)*a*c*(m + S(2)*n*(p + S(1)) + S(1)) + b**S(2)*(m + n*(p + S(1)) + S(1))), x), x), x) - Simp((f*x)**(m + S(1))*(a + b*x**n + c*x**(S(2)*n))**(p + S(1))*(-a*b*e + c*x**n*(-S(2)*a*e + b*d) + d*(-S(2)*a*c + b**S(2)))/(a*f*n*(p + S(1))*(-S(4)*a*c + b**S(2))), x) rule1397 = ReplacementRule(pattern1397, replacement1397) pattern1398 = Pattern(Integral((x_*WC('f', S(1)))**WC('m', S(1))*(a_ + x_**n2_*WC('c', S(1)))**p_*(d_ + x_**n_*WC('e', S(1))), x_), cons2, cons7, cons27, cons48, cons125, cons21, cons4, cons46, cons702) def replacement1398(p, m, f, n2, d, c, n, a, x, e): rubi.append(1398) return Dist(S(1)/(S(2)*a*n*(p + S(1))), Int((f*x)**m*(a + c*x**(S(2)*n))**(p + S(1))*Simp(d*(m + S(2)*n*(p + S(1)) + S(1)) + e*x**n*(m + n*(S(2)*p + S(3)) + S(1)), x), x), x) - Simp((f*x)**(m + S(1))*(a + c*x**(S(2)*n))**(p + S(1))*(d + e*x**n)/(S(2)*a*f*n*(p + S(1))), x) rule1398 = ReplacementRule(pattern1398, replacement1398) pattern1399 = Pattern(Integral((x_*WC('f', S(1)))**WC('m', S(1))*(d_ + x_**n_*WC('e', S(1)))**WC('q', S(1))*(a_ + x_**n_*WC('b', S(1)) + x_**WC('n2', S(1))*WC('c', S(1)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons4, cons5, cons50, cons46, cons226, cons748) def replacement1399(p, m, f, b, n2, d, c, a, n, x, q, e): rubi.append(1399) return Int(ExpandIntegrand((f*x)**m*(d + e*x**n)**q*(a + b*x**n + c*x**(S(2)*n))**p, x), x) rule1399 = ReplacementRule(pattern1399, replacement1399) pattern1400 = Pattern(Integral((x_*WC('f', S(1)))**WC('m', S(1))*(a_ + x_**WC('n2', S(1))*WC('c', S(1)))**WC('p', S(1))*(d_ + x_**n_*WC('e', S(1)))**WC('q', S(1)), x_), cons2, cons7, cons27, cons48, cons125, cons21, cons4, cons5, cons50, cons46, cons748) def replacement1400(p, m, f, n2, d, c, a, n, x, q, e): rubi.append(1400) return Int(ExpandIntegrand((f*x)**m*(a + c*x**(S(2)*n))**p*(d + e*x**n)**q, x), x) rule1400 = ReplacementRule(pattern1400, replacement1400) pattern1401 = Pattern(Integral((x_*WC('f', S(1)))**WC('m', S(1))*(a_ + x_**n2_*WC('c', S(1)))**p_*(d_ + x_**n_*WC('e', S(1)))**q_, x_), cons2, cons7, cons27, cons48, cons125, cons21, cons4, cons5, cons50, cons46, cons564, cons733) def replacement1401(p, m, f, n2, d, c, n, a, x, q, e): rubi.append(1401) return Dist(f**m, Int(ExpandIntegrand(x**m*(a + c*x**(S(2)*n))**p, (d/(d**S(2) - e**S(2)*x**(S(2)*n)) - e*x**n/(d**S(2) - e**S(2)*x**(S(2)*n)))**(-q), x), x), x) rule1401 = ReplacementRule(pattern1401, replacement1401) pattern1402 = Pattern(Integral((x_*WC('f', S(1)))**m_*(a_ + x_**n2_*WC('c', S(1)))**p_*(d_ + x_**n_*WC('e', S(1)))**q_, x_), cons2, cons7, cons27, cons48, cons125, cons21, cons4, cons5, cons50, cons46, cons564, cons749) def replacement1402(p, m, f, n2, d, c, n, a, x, q, e): rubi.append(1402) return Dist(x**(-m)*(f*x)**m, Int(x**m*(a + c*x**(S(2)*n))**p*(d + e*x**n)**q, x), x) rule1402 = ReplacementRule(pattern1402, replacement1402) pattern1403 = Pattern(Integral((x_*WC('f', S(1)))**WC('m', S(1))*(d_ + x_**n_*WC('e', S(1)))**WC('q', S(1))*(a_ + x_**n_*WC('b', S(1)) + x_**WC('n2', S(1))*WC('c', S(1)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons4, cons5, cons50, cons46) def replacement1403(p, m, f, b, n2, d, c, a, n, x, q, e): rubi.append(1403) return Int((f*x)**m*(d + e*x**n)**q*(a + b*x**n + c*x**(S(2)*n))**p, x) rule1403 = ReplacementRule(pattern1403, replacement1403) pattern1404 = Pattern(Integral((x_*WC('f', S(1)))**WC('m', S(1))*(a_ + x_**WC('n2', S(1))*WC('c', S(1)))**WC('p', S(1))*(d_ + x_**n_*WC('e', S(1)))**WC('q', S(1)), x_), cons2, cons7, cons27, cons48, cons125, cons21, cons4, cons5, cons50, cons46) def replacement1404(p, m, f, n2, d, c, a, n, x, q, e): rubi.append(1404) return Int((f*x)**m*(a + c*x**(S(2)*n))**p*(d + e*x**n)**q, x) rule1404 = ReplacementRule(pattern1404, replacement1404) pattern1405 = Pattern(Integral(u_**WC('m', S(1))*(d_ + v_**n_*WC('e', S(1)))**WC('q', S(1))*(a_ + v_**n_*WC('b', S(1)) + v_**WC('n2', S(1))*WC('c', S(1)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons21, cons4, cons5, cons50, cons46, cons554) def replacement1405(v, p, u, m, b, n2, d, c, a, n, x, q, e): rubi.append(1405) return Dist(u**m*v**(-m)/Coefficient(v, x, S(1)), Subst(Int(x**m*(d + e*x**n)**q*(a + b*x**n + c*x**(S(2)*n))**p, x), x, v), x) rule1405 = ReplacementRule(pattern1405, replacement1405) pattern1406 = Pattern(Integral(u_**WC('m', S(1))*(a_ + v_**WC('n2', S(1))*WC('c', S(1)))**WC('p', S(1))*(d_ + v_**n_*WC('e', S(1)))**WC('q', S(1)), x_), cons2, cons7, cons27, cons48, cons21, cons4, cons5, cons46, cons554) def replacement1406(v, p, u, m, n2, d, c, a, n, x, q, e): rubi.append(1406) return Dist(u**m*v**(-m)/Coefficient(v, x, S(1)), Subst(Int(x**m*(a + c*x**(S(2)*n))**p*(d + e*x**n)**q, x), x, v), x) rule1406 = ReplacementRule(pattern1406, replacement1406) pattern1407 = Pattern(Integral(x_**WC('m', S(1))*(d_ + x_**WC('mn', S(1))*WC('e', S(1)))**WC('q', S(1))*(x_**WC('n', S(1))*WC('b', S(1)) + x_**WC('n2', S(1))*WC('c', S(1)) + WC('a', S(0)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons21, cons4, cons5, cons680, cons585, cons586) def replacement1407(mn, p, m, b, n2, d, a, n, c, x, q, e): rubi.append(1407) return Int(x**(m - n*q)*(d*x**n + e)**q*(a + b*x**n + c*x**(S(2)*n))**p, x) rule1407 = ReplacementRule(pattern1407, replacement1407) pattern1408 = Pattern(Integral(x_**WC('m', S(1))*(a_ + x_**WC('n2', S(1))*WC('c', S(1)))**WC('p', S(1))*(d_ + x_**WC('mn', S(1))*WC('e', S(1)))**WC('q', S(1)), x_), cons2, cons7, cons27, cons48, cons21, cons726, cons5, cons725, cons586) def replacement1408(mn, p, m, n2, d, c, a, x, q, e): rubi.append(1408) return Int(x**(m + mn*q)*(a + c*x**n2)**p*(d*x**(-mn) + e)**q, x) rule1408 = ReplacementRule(pattern1408, replacement1408) pattern1409 = Pattern(Integral(x_**WC('m', S(1))*(d_ + x_**WC('mn', S(1))*WC('e', S(1)))**q_*(x_**WC('n', S(1))*WC('b', S(1)) + x_**WC('n2', S(1))*WC('c', S(1)) + WC('a', S(0)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons21, cons4, cons50, cons680, cons585, cons386, cons38) def replacement1409(mn, p, m, b, n2, d, a, n, c, x, q, e): rubi.append(1409) return Int(x**(m + S(2)*n*p)*(d + e*x**(-n))**q*(a*x**(-S(2)*n) + b*x**(-n) + c)**p, x) rule1409 = ReplacementRule(pattern1409, replacement1409) pattern1410 = Pattern(Integral(x_**WC('m', S(1))*(a_ + x_**WC('n2', S(1))*WC('c', S(1)))**WC('p', S(1))*(d_ + x_**WC('mn', S(1))*WC('e', S(1)))**q_, x_), cons2, cons7, cons27, cons48, cons21, cons726, cons50, cons725, cons386, cons38) def replacement1410(mn, p, m, n2, d, c, a, x, q, e): rubi.append(1410) return Int(x**(m - S(2)*mn*p)*(d + e*x**mn)**q*(a*x**(S(2)*mn) + c)**p, x) rule1410 = ReplacementRule(pattern1410, replacement1410) pattern1411 = Pattern(Integral(x_**WC('m', S(1))*(d_ + x_**WC('mn', S(1))*WC('e', S(1)))**q_*(x_**WC('n', S(1))*WC('b', S(1)) + x_**WC('n2', S(1))*WC('c', S(1)) + WC('a', S(0)))**p_, x_), cons2, cons3, cons7, cons27, cons48, cons21, cons4, cons5, cons50, cons680, cons585, cons386, cons147) def replacement1411(mn, p, m, b, n2, d, a, n, c, x, q, e): rubi.append(1411) return Dist(x**(n*FracPart(q))*(d + e*x**(-n))**FracPart(q)*(d*x**n + e)**(-FracPart(q)), Int(x**(m - n*q)*(d*x**n + e)**q*(a + b*x**n + c*x**(S(2)*n))**p, x), x) rule1411 = ReplacementRule(pattern1411, replacement1411) pattern1412 = Pattern(Integral(x_**WC('m', S(1))*(a_ + x_**WC('n2', S(1))*WC('c', S(1)))**p_*(d_ + x_**WC('mn', S(1))*WC('e', S(1)))**q_, x_), cons2, cons7, cons27, cons48, cons21, cons726, cons5, cons50, cons725, cons386, cons147) def replacement1412(mn, p, m, n2, d, c, a, x, q, e): rubi.append(1412) return Dist(x**(-mn*FracPart(q))*(d + e*x**mn)**FracPart(q)*(d*x**(-mn) + e)**(-FracPart(q)), Int(x**(m + mn*q)*(a + c*x**n2)**p*(d*x**(-mn) + e)**q, x), x) rule1412 = ReplacementRule(pattern1412, replacement1412) pattern1413 = Pattern(Integral((f_*x_)**m_*(d_ + x_**WC('mn', S(1))*WC('e', S(1)))**WC('q', S(1))*(x_**WC('n', S(1))*WC('b', S(1)) + x_**WC('n2', S(1))*WC('c', S(1)) + WC('a', S(0)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons4, cons5, cons50, cons680, cons585) def replacement1413(mn, p, m, f, b, n2, d, a, n, c, x, q, e): rubi.append(1413) return Dist(f**IntPart(m)*x**(-FracPart(m))*(f*x)**FracPart(m), Int(x**m*(d + e*x**mn)**q*(a + b*x**n + c*x**(S(2)*n))**p, x), x) rule1413 = ReplacementRule(pattern1413, replacement1413) pattern1414 = Pattern(Integral((f_*x_)**m_*(a_ + x_**WC('n2', S(1))*WC('c', S(1)))**p_*(d_ + x_**WC('mn', S(1))*WC('e', S(1)))**WC('q', S(1)), x_), cons2, cons7, cons27, cons48, cons125, cons21, cons726, cons5, cons50, cons725) def replacement1414(mn, p, m, f, n2, d, c, a, x, q, e): rubi.append(1414) return Dist(f**IntPart(m)*x**(-FracPart(m))*(f*x)**FracPart(m), Int(x**m*(a + c*x**(S(2)*n))**p*(d + e*x**mn)**q, x), x) rule1414 = ReplacementRule(pattern1414, replacement1414) pattern1415 = Pattern(Integral(x_**WC('m', S(1))*(d_ + x_**n_*WC('e', S(1)))**WC('q', S(1))*(a_ + x_**mn_*WC('b', S(1)) + x_**WC('n', S(1))*WC('c', S(1)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons21, cons4, cons50, cons585, cons38) def replacement1415(mn, p, m, b, d, c, n, a, x, q, e): rubi.append(1415) return Int(x**(m - n*p)*(d + e*x**n)**q*(a*x**n + b + c*x**(S(2)*n))**p, x) rule1415 = ReplacementRule(pattern1415, replacement1415) pattern1416 = Pattern(Integral(x_**WC('m', S(1))*(d_ + x_**n_*WC('e', S(1)))**WC('q', S(1))*(a_ + x_**mn_*WC('b', S(1)) + x_**WC('n', S(1))*WC('c', S(1)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons21, cons4, cons5, cons50, cons585, cons147) def replacement1416(mn, p, m, b, d, c, n, a, x, q, e): rubi.append(1416) return Dist(x**(n*FracPart(p))*(a + b*x**(-n) + c*x**n)**FracPart(p)*(a*x**n + b + c*x**(S(2)*n))**(-FracPart(p)), Int(x**(m - n*p)*(d + e*x**n)**q*(a*x**n + b + c*x**(S(2)*n))**p, x), x) rule1416 = ReplacementRule(pattern1416, replacement1416) pattern1417 = Pattern(Integral((f_*x_)**WC('m', S(1))*(d_ + x_**n_*WC('e', S(1)))**WC('q', S(1))*(a_ + x_**mn_*WC('b', S(1)) + x_**WC('n', S(1))*WC('c', S(1)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons4, cons5, cons50, cons585) def replacement1417(mn, p, m, f, b, d, c, n, a, x, q, e): rubi.append(1417) return Dist(f**IntPart(m)*x**(-FracPart(m))*(f*x)**FracPart(m), Int(x**m*(d + e*x**n)**q*(a + b*x**(-n) + c*x**n)**p, x), x) rule1417 = ReplacementRule(pattern1417, replacement1417) pattern1418 = Pattern(Integral((x_*WC('f', S(1)))**WC('m', S(1))*(d1_ + x_**WC('non2', S(1))*WC('e1', S(1)))**WC('q', S(1))*(d2_ + x_**WC('non2', S(1))*WC('e2', S(1)))**WC('q', S(1))*(x_**n2_*WC('c', S(1)) + x_**n_*WC('b', S(1)) + WC('a', S(0)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons731, cons652, cons732, cons654, cons125, cons4, cons5, cons50, cons46, cons593, cons729, cons730) def replacement1418(p, d2, m, f, b, n2, e2, a, c, non2, d1, e1, n, x, q): rubi.append(1418) return Int((f*x)**m*(d1*d2 + e1*e2*x**n)**q*(a + b*x**n + c*x**(S(2)*n))**p, x) rule1418 = ReplacementRule(pattern1418, replacement1418) pattern1419 = Pattern(Integral((x_*WC('f', S(1)))**WC('m', S(1))*(d1_ + x_**WC('non2', S(1))*WC('e1', S(1)))**WC('q', S(1))*(d2_ + x_**WC('non2', S(1))*WC('e2', S(1)))**WC('q', S(1))*(x_**n2_*WC('c', S(1)) + x_**n_*WC('b', S(1)) + WC('a', S(0)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons731, cons652, cons732, cons654, cons125, cons4, cons5, cons50, cons46, cons593, cons729) def replacement1419(p, d2, m, f, b, n2, e2, a, c, non2, d1, e1, n, x, q): rubi.append(1419) return Dist((d1 + e1*x**(n/S(2)))**FracPart(q)*(d2 + e2*x**(n/S(2)))**FracPart(q)*(d1*d2 + e1*e2*x**n)**(-FracPart(q)), Int((f*x)**m*(d1*d2 + e1*e2*x**n)**q*(a + b*x**n + c*x**(S(2)*n))**p, x), x) rule1419 = ReplacementRule(pattern1419, replacement1419) pattern1420 = Pattern(Integral((x_**WC('n', S(1))*WC('b', S(1)) + x_**WC('q', S(1))*WC('a', S(1)) + x_**WC('r', S(1))*WC('c', S(1)))**p_, x_), cons2, cons3, cons7, cons4, cons5, cons750, cons751) def replacement1420(p, b, r, c, a, n, x, q): rubi.append(1420) return Int((x**n*(a + b + c))**p, x) rule1420 = ReplacementRule(pattern1420, replacement1420) pattern1421 = Pattern(Integral((x_**WC('n', S(1))*WC('b', S(1)) + x_**WC('q', S(1))*WC('a', S(1)) + x_**WC('r', S(1))*WC('c', S(1)))**p_, x_), cons2, cons3, cons7, cons4, cons50, cons752, cons753, cons38) def replacement1421(p, b, r, c, a, n, x, q): rubi.append(1421) return Int(x**(p*q)*(a + b*x**(n - q) + c*x**(S(2)*n - S(2)*q))**p, x) rule1421 = ReplacementRule(pattern1421, replacement1421) pattern1422 = Pattern(Integral(sqrt(x_**WC('n', S(1))*WC('b', S(1)) + x_**WC('q', S(1))*WC('a', S(1)) + x_**WC('r', S(1))*WC('c', S(1))), x_), cons2, cons3, cons7, cons4, cons50, cons752, cons753) def replacement1422(b, r, c, a, n, x, q): rubi.append(1422) return Dist(x**(-q/S(2))*sqrt(a*x**q + b*x**n + c*x**(S(2)*n - q))/sqrt(a + b*x**(n - q) + c*x**(S(2)*n - S(2)*q)), Int(x**(q/S(2))*sqrt(a + b*x**(n - q) + c*x**(S(2)*n - S(2)*q)), x), x) rule1422 = ReplacementRule(pattern1422, replacement1422) pattern1423 = Pattern(Integral(S(1)/sqrt(x_**WC('n', S(1))*WC('b', S(1)) + x_**WC('q', S(1))*WC('a', S(1)) + x_**WC('r', S(1))*WC('c', S(1))), x_), cons2, cons3, cons7, cons4, cons50, cons752, cons753) def replacement1423(b, r, c, a, n, x, q): rubi.append(1423) return Dist(x**(q/S(2))*sqrt(a + b*x**(n - q) + c*x**(S(2)*n - S(2)*q))/sqrt(a*x**q + b*x**n + c*x**(S(2)*n - q)), Int(x**(-q/S(2))/sqrt(a + b*x**(n - q) + c*x**(S(2)*n - S(2)*q)), x), x) rule1423 = ReplacementRule(pattern1423, replacement1423) pattern1424 = Pattern(Integral((x_**WC('n', S(1))*WC('b', S(1)) + x_**WC('q', S(1))*WC('a', S(1)) + x_**WC('r', S(1))*WC('c', S(1)))**p_, x_), cons2, cons3, cons7, cons4, cons50, cons752, cons753, cons147, cons226, cons13, cons163, cons754) def replacement1424(p, b, r, c, a, n, x, q): rubi.append(1424) return Dist(p*(n - q)/(p*(S(2)*n - q) + S(1)), Int(x**q*(S(2)*a + b*x**(n - q))*(a*x**q + b*x**n + c*x**(S(2)*n - q))**(p + S(-1)), x), x) + Simp(x*(a*x**q + b*x**n + c*x**(S(2)*n - q))**p/(p*(S(2)*n - q) + S(1)), x) rule1424 = ReplacementRule(pattern1424, replacement1424) pattern1425 = Pattern(Integral((x_**WC('n', S(1))*WC('b', S(1)) + x_**WC('q', S(1))*WC('a', S(1)) + x_**WC('r', S(1))*WC('c', S(1)))**p_, x_), cons2, cons3, cons7, cons4, cons50, cons752, cons753, cons147, cons226, cons13, cons137) def replacement1425(p, b, r, c, a, n, x, q): rubi.append(1425) return Dist(S(1)/(a*(n - q)*(p + S(1))*(-S(4)*a*c + b**S(2))), Int(x**(-q)*(a*x**q + b*x**n + c*x**(S(2)*n - q))**(p + S(1))*(b*c*x**(n - q)*(p*q + (n - q)*(S(2)*p + S(3)) + S(1)) + (n - q)*(p + S(1))*(-S(4)*a*c + b**S(2)) + (-S(2)*a*c + b**S(2))*(p*q + S(1))), x), x) - Simp(x**(-q + S(1))*(-S(2)*a*c + b**S(2) + b*c*x**(n - q))*(a*x**q + b*x**n + c*x**(S(2)*n - q))**(p + S(1))/(a*(n - q)*(p + S(1))*(-S(4)*a*c + b**S(2))), x) rule1425 = ReplacementRule(pattern1425, replacement1425) pattern1426 = Pattern(Integral((x_**WC('n', S(1))*WC('b', S(1)) + x_**WC('q', S(1))*WC('a', S(1)) + x_**WC('r', S(1))*WC('c', S(1)))**p_, x_), cons2, cons3, cons7, cons4, cons5, cons50, cons752, cons753, cons147) def replacement1426(p, b, r, c, a, n, x, q): rubi.append(1426) return Dist(x**(-p*q)*(a + b*x**(n - q) + c*x**(S(2)*n - S(2)*q))**(-p)*(a*x**q + b*x**n + c*x**(S(2)*n - q))**p, Int(x**(p*q)*(a + b*x**(n - q) + c*x**(S(2)*n - S(2)*q))**p, x), x) rule1426 = ReplacementRule(pattern1426, replacement1426) pattern1427 = Pattern(Integral((x_**WC('n', S(1))*WC('b', S(1)) + x_**WC('q', S(1))*WC('a', S(1)) + x_**WC('r', S(1))*WC('c', S(1)))**p_, x_), cons2, cons3, cons7, cons4, cons5, cons50, cons752) def replacement1427(p, b, r, c, a, n, x, q): rubi.append(1427) return Int((a*x**q + b*x**n + c*x**(S(2)*n - q))**p, x) rule1427 = ReplacementRule(pattern1427, replacement1427) pattern1428 = Pattern(Integral((u_**WC('n', S(1))*WC('b', S(1)) + u_**WC('q', S(1))*WC('a', S(1)) + u_**WC('r', S(1))*WC('c', S(1)))**p_, x_), cons2, cons3, cons7, cons4, cons5, cons50, cons752, cons68, cons69) def replacement1428(p, u, b, r, c, a, n, x, q): rubi.append(1428) return Dist(S(1)/Coefficient(u, x, S(1)), Subst(Int((a*x**q + b*x**n + c*x**(S(2)*n - q))**p, x), x, u), x) rule1428 = ReplacementRule(pattern1428, replacement1428) pattern1429 = Pattern(Integral(x_**WC('m', S(1))*(x_**WC('n', S(1))*WC('b', S(1)) + x_**WC('q', S(1))*WC('a', S(1)) + x_**WC('r', S(1))*WC('c', S(1)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons21, cons4, cons5, cons755, cons751) def replacement1429(p, m, b, r, a, n, c, x, q): rubi.append(1429) return Int(x**m*(x**n*(a + b + c))**p, x) rule1429 = ReplacementRule(pattern1429, replacement1429) pattern1430 = Pattern(Integral(x_**WC('m', S(1))*(x_**WC('n', S(1))*WC('b', S(1)) + x_**WC('q', S(1))*WC('a', S(1)) + x_**WC('r', S(1))*WC('c', S(1)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons21, cons4, cons50, cons752, cons38, cons753) def replacement1430(p, m, b, r, a, n, c, x, q): rubi.append(1430) return Int(x**(m + p*q)*(a + b*x**(n - q) + c*x**(S(2)*n - S(2)*q))**p, x) rule1430 = ReplacementRule(pattern1430, replacement1430) pattern1431 = Pattern(Integral(x_**WC('m', S(1))/sqrt(x_**WC('n', S(1))*WC('b', S(1)) + x_**WC('q', S(1))*WC('a', S(1)) + x_**WC('r', S(1))*WC('c', S(1))), x_), cons2, cons3, cons7, cons21, cons4, cons50, cons752, cons753, cons756) def replacement1431(m, b, r, a, n, c, x, q): rubi.append(1431) return Dist(x**(q/S(2))*sqrt(a + b*x**(n - q) + c*x**(S(2)*n - S(2)*q))/sqrt(a*x**q + b*x**n + c*x**(S(2)*n - q)), Int(x**(m - q/S(2))/sqrt(a + b*x**(n - q) + c*x**(S(2)*n - S(2)*q)), x), x) rule1431 = ReplacementRule(pattern1431, replacement1431) pattern1432 = Pattern(Integral(x_**WC('m', S(1))/(x_**WC('n', S(1))*WC('b', S(1)) + x_**WC('q', S(1))*WC('a', S(1)) + x_**WC('r', S(1))*WC('c', S(1)))**(S(3)/2), x_), cons2, cons3, cons7, cons4, cons757, cons758, cons759, cons226) def replacement1432(m, b, r, a, n, c, x, q): rubi.append(1432) return Simp(-S(2)*x**(n/S(2) + S(-1)/2)*(b + S(2)*c*x)/((-S(4)*a*c + b**S(2))*sqrt(a*x**(n + S(-1)) + b*x**n + c*x**(n + S(1)))), x) rule1432 = ReplacementRule(pattern1432, replacement1432) pattern1433 = Pattern(Integral(x_**WC('m', S(1))/(x_**WC('n', S(1))*WC('b', S(1)) + x_**WC('q', S(1))*WC('a', S(1)) + x_**WC('r', S(1))*WC('c', S(1)))**(S(3)/2), x_), cons2, cons3, cons7, cons4, cons760, cons758, cons759, cons226) def replacement1433(m, b, r, a, n, c, x, q): rubi.append(1433) return Simp(x**(n/S(2) + S(-1)/2)*(S(4)*a + S(2)*b*x)/((-S(4)*a*c + b**S(2))*sqrt(a*x**(n + S(-1)) + b*x**n + c*x**(n + S(1)))), x) rule1433 = ReplacementRule(pattern1433, replacement1433) pattern1434 = Pattern(Integral(x_**WC('m', S(1))*(x_**WC('n', S(1))*WC('b', S(1)) + x_**WC('q', S(1))*WC('a', S(1)) + x_**WC('r', S(1))*WC('c', S(1)))**p_, x_), cons2, cons3, cons7, cons752, cons753, cons147, cons226, cons148, cons606, cons761) def replacement1434(p, m, b, r, a, n, c, x, q): rubi.append(1434) return -Dist(b/(S(2)*c), Int(x**(m + S(-1))*(a*x**(n + S(-1)) + b*x**n + c*x**(n + S(1)))**p, x), x) + Simp(x**(m - n)*(a*x**(n + S(-1)) + b*x**n + c*x**(n + S(1)))**(p + S(1))/(S(2)*c*(p + S(1))), x) rule1434 = ReplacementRule(pattern1434, replacement1434) pattern1435 = Pattern(Integral(x_**WC('m', S(1))*(x_**WC('n', S(1))*WC('b', S(1)) + x_**WC('q', S(1))*WC('a', S(1)) + x_**WC('r', S(1))*WC('c', S(1)))**p_, x_), cons2, cons3, cons7, cons752, cons753, cons147, cons226, cons148, cons606, cons163, cons762) def replacement1435(p, m, b, r, a, n, c, x, q): rubi.append(1435) return -Dist(p*(-S(4)*a*c + b**S(2))/(S(2)*c*(S(2)*p + S(1))), Int(x**(m + q)*(a*x**q + b*x**n + c*x**(S(2)*n - q))**(p + S(-1)), x), x) + Simp(x**(m - n + q + S(1))*(b + S(2)*c*x**(n - q))*(a*x**q + b*x**n + c*x**(S(2)*n - q))**p/(S(2)*c*(n - q)*(S(2)*p + S(1))), x) rule1435 = ReplacementRule(pattern1435, replacement1435) pattern1436 = Pattern(Integral(x_**WC('m', S(1))*(x_**WC('n', S(1))*WC('b', S(1)) + x_**WC('q', S(1))*WC('a', S(1)) + x_**WC('r', S(1))*WC('c', S(1)))**p_, x_), cons2, cons3, cons7, cons752, cons753, cons147, cons226, cons148, cons606, cons163, cons763, cons764, cons765) def replacement1436(p, m, b, r, a, n, c, x, q): rubi.append(1436) return Dist(p*(n - q)/(c*(m + p*(S(2)*n - q) + S(1))*(m + p*q + (n - q)*(S(2)*p + S(-1)) + S(1))), Int(x**(m - n + S(2)*q)*(a*x**q + b*x**n + c*x**(S(2)*n - q))**(p + S(-1))*Simp(-a*b*(m - n + p*q + q + S(1)) + x**(n - q)*(S(2)*a*c*(m + p*q + (n - q)*(S(2)*p + S(-1)) + S(1)) - b**S(2)*(m + p*q + (n - q)*(p + S(-1)) + S(1))), x), x), x) + Simp(x**(m - n + q + S(1))*(b*p*(n - q) + c*x**(n - q)*(m + p*q + (n - q)*(S(2)*p + S(-1)) + S(1)))*(a*x**q + b*x**n + c*x**(S(2)*n - q))**p/(c*(m + p*(S(2)*n - q) + S(1))*(m + p*q + (n - q)*(S(2)*p + S(-1)) + S(1))), x) rule1436 = ReplacementRule(pattern1436, replacement1436) pattern1437 = Pattern(Integral(x_**WC('m', S(1))*(x_**WC('n', S(1))*WC('b', S(1)) + x_**WC('q', S(1))*WC('a', S(1)) + x_**WC('r', S(1))*WC('c', S(1)))**p_, x_), cons2, cons3, cons7, cons752, cons753, cons147, cons226, cons148, cons606, cons163, cons766, cons767) def replacement1437(p, m, b, r, a, n, c, x, q): rubi.append(1437) return -Dist(p*(n - q)/(m + p*q + S(1)), Int(x**(m + n)*(b + S(2)*c*x**(n - q))*(a*x**q + b*x**n + c*x**(S(2)*n - q))**(p + S(-1)), x), x) + Simp(x**(m + S(1))*(a*x**q + b*x**n + c*x**(S(2)*n - q))**p/(m + p*q + S(1)), x) rule1437 = ReplacementRule(pattern1437, replacement1437) pattern1438 = Pattern(Integral(x_**WC('m', S(1))*(x_**WC('n', S(1))*WC('b', S(1)) + x_**WC('q', S(1))*WC('a', S(1)) + x_**WC('r', S(1))*WC('c', S(1)))**p_, x_), cons2, cons3, cons7, cons752, cons753, cons147, cons226, cons148, cons606, cons163, cons768, cons764) def replacement1438(p, m, b, r, a, n, c, x, q): rubi.append(1438) return Dist(p*(n - q)/(m + p*(S(2)*n - q) + S(1)), Int(x**(m + q)*(S(2)*a + b*x**(n - q))*(a*x**q + b*x**n + c*x**(S(2)*n - q))**(p + S(-1)), x), x) + Simp(x**(m + S(1))*(a*x**q + b*x**n + c*x**(S(2)*n - q))**p/(m + p*(S(2)*n - q) + S(1)), x) rule1438 = ReplacementRule(pattern1438, replacement1438) pattern1439 = Pattern(Integral(x_**WC('m', S(1))*(x_**WC('n', S(1))*WC('b', S(1)) + x_**WC('q', S(1))*WC('a', S(1)) + x_**WC('r', S(1))*WC('c', S(1)))**p_, x_), cons2, cons3, cons7, cons752, cons753, cons147, cons226, cons148, cons606, cons137, cons769) def replacement1439(p, m, b, r, a, n, c, x, q): rubi.append(1439) return Dist((S(2)*a*c - b**S(2)*(p + S(2)))/(a*(p + S(1))*(-S(4)*a*c + b**S(2))), Int(x**(m - q)*(a*x**q + b*x**n + c*x**(S(2)*n - q))**(p + S(1)), x), x) - Simp(x**(m - q + S(1))*(-S(2)*a*c + b**S(2) + b*c*x**(n - q))*(a*x**q + b*x**n + c*x**(S(2)*n - q))**(p + S(1))/(a*(n - q)*(p + S(1))*(-S(4)*a*c + b**S(2))), x) rule1439 = ReplacementRule(pattern1439, replacement1439) pattern1440 = Pattern(Integral(x_**WC('m', S(1))*(x_**WC('n', S(1))*WC('b', S(1)) + x_**WC('q', S(1))*WC('a', S(1)) + x_**WC('r', S(1))*WC('c', S(1)))**p_, x_), cons2, cons3, cons7, cons752, cons753, cons147, cons226, cons148, cons606, cons137, cons770) def replacement1440(p, m, b, r, a, n, c, x, q): rubi.append(1440) return Dist(S(1)/((n - q)*(p + S(1))*(-S(4)*a*c + b**S(2))), Int(x**(m - S(2)*n + q)*(S(2)*a*(m - S(2)*n + p*q + S(2)*q + S(1)) + b*x**(n - q)*(m + p*q + (n - q)*(S(2)*p + S(1)) + S(1)))*(a*x**q + b*x**n + c*x**(S(2)*n - q))**(p + S(1)), x), x) - Simp(x**(m - S(2)*n + q + S(1))*(S(2)*a + b*x**(n - q))*(a*x**q + b*x**n + c*x**(S(2)*n - q))**(p + S(1))/((n - q)*(p + S(1))*(-S(4)*a*c + b**S(2))), x) rule1440 = ReplacementRule(pattern1440, replacement1440) pattern1441 = Pattern(Integral(x_**WC('m', S(1))*(x_**WC('n', S(1))*WC('b', S(1)) + x_**WC('q', S(1))*WC('a', S(1)) + x_**WC('r', S(1))*WC('c', S(1)))**p_, x_), cons2, cons3, cons7, cons752, cons753, cons147, cons226, cons148, cons606, cons137, cons771) def replacement1441(p, m, b, r, a, n, c, x, q): rubi.append(1441) return Dist(S(1)/(a*(n - q)*(p + S(1))*(-S(4)*a*c + b**S(2))), Int(x**(m - q)*(a*x**q + b*x**n + c*x**(S(2)*n - q))**(p + S(1))*(-S(2)*a*c*(m + p*q + S(2)*(n - q)*(p + S(1)) + S(1)) + b**S(2)*(m + p*q + (n - q)*(p + S(1)) + S(1)) + b*c*x**(n - q)*(m + p*q + (n - q)*(S(2)*p + S(3)) + S(1))), x), x) - Simp(x**(m - q + S(1))*(-S(2)*a*c + b**S(2) + b*c*x**(n - q))*(a*x**q + b*x**n + c*x**(S(2)*n - q))**(p + S(1))/(a*(n - q)*(p + S(1))*(-S(4)*a*c + b**S(2))), x) rule1441 = ReplacementRule(pattern1441, replacement1441) pattern1442 = Pattern(Integral(x_**WC('m', S(1))*(x_**WC('n', S(1))*WC('b', S(1)) + x_**WC('q', S(1))*WC('a', S(1)) + x_**WC('r', S(1))*WC('c', S(1)))**p_, x_), cons2, cons3, cons7, cons752, cons753, cons147, cons226, cons148, cons606, cons137, cons772) def replacement1442(p, m, b, r, a, n, c, x, q): rubi.append(1442) return -Dist(S(1)/((n - q)*(p + S(1))*(-S(4)*a*c + b**S(2))), Int(x**(m - n)*(b*(m - n + p*q + q + S(1)) + S(2)*c*x**(n - q)*(m + p*q + S(2)*(n - q)*(p + S(1)) + S(1)))*(a*x**q + b*x**n + c*x**(S(2)*n - q))**(p + S(1)), x), x) + Simp(x**(m - n + S(1))*(b + S(2)*c*x**(n - q))*(a*x**q + b*x**n + c*x**(S(2)*n - q))**(p + S(1))/((n - q)*(p + S(1))*(-S(4)*a*c + b**S(2))), x) rule1442 = ReplacementRule(pattern1442, replacement1442) pattern1443 = Pattern(Integral(x_**WC('m', S(1))*(x_**WC('n', S(1))*WC('b', S(1)) + x_**WC('q', S(1))*WC('a', S(1)) + x_**WC('r', S(1))*WC('c', S(1)))**p_, x_), cons2, cons3, cons7, cons752, cons753, cons147, cons226, cons148, cons606, cons773, cons774) def replacement1443(p, m, b, r, a, n, c, x, q): rubi.append(1443) return -Dist(b/(S(2)*c), Int(x**(m - n + q)*(a*x**q + b*x**n + c*x**(S(2)*n - q))**p, x), x) + Simp(x**(m - S(2)*n + q + S(1))*(a*x**q + b*x**n + c*x**(S(2)*n - q))**(p + S(1))/(S(2)*c*(n - q)*(p + S(1))), x) rule1443 = ReplacementRule(pattern1443, replacement1443) pattern1444 = Pattern(Integral(x_**WC('m', S(1))*(x_**WC('n', S(1))*WC('b', S(1)) + x_**WC('q', S(1))*WC('a', S(1)) + x_**WC('r', S(1))*WC('c', S(1)))**p_, x_), cons2, cons3, cons7, cons752, cons753, cons147, cons226, cons148, cons606, cons773, cons775) def replacement1444(p, m, b, r, a, n, c, x, q): rubi.append(1444) return -Dist(b/(S(2)*a), Int(x**(m + n - q)*(a*x**q + b*x**n + c*x**(S(2)*n - q))**p, x), x) - Simp(x**(m - q + S(1))*(a*x**q + b*x**n + c*x**(S(2)*n - q))**(p + S(1))/(S(2)*a*(n - q)*(p + S(1))), x) rule1444 = ReplacementRule(pattern1444, replacement1444) pattern1445 = Pattern(Integral(x_**WC('m', S(1))*(x_**WC('n', S(1))*WC('b', S(1)) + x_**WC('q', S(1))*WC('a', S(1)) + x_**WC('r', S(1))*WC('c', S(1)))**p_, x_), cons2, cons3, cons7, cons752, cons753, cons147, cons226, cons148, cons606, cons773, cons770) def replacement1445(p, m, b, r, a, n, c, x, q): rubi.append(1445) return -Dist(S(1)/(c*(m + p*q + S(2)*p*(n - q) + S(1))), Int(x**(m - S(2)*n + S(2)*q)*(a*(m - S(2)*n + p*q + S(2)*q + S(1)) + b*x**(n - q)*(m + p*q + (n - q)*(p + S(-1)) + S(1)))*(a*x**q + b*x**n + c*x**(S(2)*n - q))**p, x), x) + Simp(x**(m - S(2)*n + q + S(1))*(a*x**q + b*x**n + c*x**(S(2)*n - q))**(p + S(1))/(c*(m + p*q + S(2)*p*(n - q) + S(1))), x) rule1445 = ReplacementRule(pattern1445, replacement1445) pattern1446 = Pattern(Integral(x_**WC('m', S(1))*(x_**WC('n', S(1))*WC('b', S(1)) + x_**WC('q', S(1))*WC('a', S(1)) + x_**WC('r', S(1))*WC('c', S(1)))**p_, x_), cons2, cons3, cons7, cons752, cons753, cons147, cons226, cons148, cons606, cons773, cons776) def replacement1446(p, m, b, r, a, n, c, x, q): rubi.append(1446) return -Dist(S(1)/(a*(m + p*q + S(1))), Int(x**(m + n - q)*(b*(m + p*q + (n - q)*(p + S(1)) + S(1)) + c*x**(n - q)*(m + p*q + S(2)*(n - q)*(p + S(1)) + S(1)))*(a*x**q + b*x**n + c*x**(S(2)*n - q))**p, x), x) + Simp(x**(m - q + S(1))*(a*x**q + b*x**n + c*x**(S(2)*n - q))**(p + S(1))/(a*(m + p*q + S(1))), x) rule1446 = ReplacementRule(pattern1446, replacement1446) pattern1447 = Pattern(Integral(x_**WC('m', S(1))*(x_**WC('n', S(1))*WC('b', S(1)) + x_**WC('q', S(1))*WC('a', S(1)) + x_**WC('r', S(1))*WC('c', S(1)))**p_, x_), cons2, cons3, cons7, cons21, cons4, cons5, cons50, cons752, cons147, cons753) def replacement1447(p, m, b, r, a, n, c, x, q): rubi.append(1447) return Dist(x**(-p*q)*(a + b*x**(n - q) + c*x**(S(2)*n - S(2)*q))**(-p)*(a*x**q + b*x**n + c*x**(S(2)*n - q))**p, Int(x**(m + p*q)*(a + b*x**(n - q) + c*x**(S(2)*n - S(2)*q))**p, x), x) rule1447 = ReplacementRule(pattern1447, replacement1447) pattern1448 = Pattern(Integral(u_**WC('m', S(1))*(u_**WC('n', S(1))*WC('b', S(1)) + u_**WC('q', S(1))*WC('a', S(1)) + u_**WC('r', S(1))*WC('c', S(1)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons21, cons4, cons5, cons50, cons752, cons68, cons69) def replacement1448(p, u, m, b, r, a, n, c, x, q): rubi.append(1448) return Dist(S(1)/Coefficient(u, x, S(1)), Subst(Int(x**m*(a*x**q + b*x**n + c*x**(S(2)*n - q))**p, x), x, u), x) rule1448 = ReplacementRule(pattern1448, replacement1448) pattern1449 = Pattern(Integral((A_ + x_**WC('r', S(1))*WC('B', S(1)))*(x_**WC('j', S(1))*WC('c', S(1)) + x_**WC('n', S(1))*WC('b', S(1)) + x_**WC('q', S(1))*WC('a', S(1)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons34, cons35, cons4, cons50, cons777, cons778, cons38, cons753) def replacement1449(B, p, j, b, r, c, n, a, x, q, A): rubi.append(1449) return Int(x**(p*q)*(A + B*x**(n - q))*(a + b*x**(n - q) + c*x**(S(2)*n - S(2)*q))**p, x) rule1449 = ReplacementRule(pattern1449, replacement1449) pattern1450 = Pattern(Integral((A_ + x_**WC('j', S(1))*WC('B', S(1)))/sqrt(x_**WC('n', S(1))*WC('b', S(1)) + x_**WC('q', S(1))*WC('a', S(1)) + x_**WC('r', S(1))*WC('c', S(1))), x_), cons2, cons3, cons7, cons34, cons35, cons4, cons50, cons779, cons752, cons753, cons780, cons781) def replacement1450(B, j, b, r, a, n, c, x, q, A): rubi.append(1450) return Dist(x**(q/S(2))*sqrt(a + b*x**(n - q) + c*x**(S(2)*n - S(2)*q))/sqrt(a*x**q + b*x**n + c*x**(S(2)*n - q)), Int(x**(-q/S(2))*(A + B*x**(n - q))/sqrt(a + b*x**(n - q) + c*x**(S(2)*n - S(2)*q)), x), x) rule1450 = ReplacementRule(pattern1450, replacement1450) pattern1451 = Pattern(Integral((A_ + x_**WC('r', S(1))*WC('B', S(1)))*(x_**WC('j', S(1))*WC('c', S(1)) + x_**WC('n', S(1))*WC('b', S(1)) + x_**WC('q', S(1))*WC('a', S(1)))**p_, x_), cons2, cons3, cons7, cons34, cons35, cons4, cons50, cons777, cons778, cons147, cons226, cons13, cons163, cons754, cons782) def replacement1451(B, p, j, b, r, c, n, a, x, q, A): rubi.append(1451) return Dist(p*(n - q)/(c*(p*(S(2)*n - q) + S(1))*(p*q + (n - q)*(S(2)*p + S(1)) + S(1))), Int(x**q*(a*x**q + b*x**n + c*x**(S(2)*n - q))**(p + S(-1))*(S(2)*A*a*c*(p*q + (n - q)*(S(2)*p + S(1)) + S(1)) - B*a*b*(p*q + S(1)) + x**(n - q)*(A*b*c*(p*q + (n - q)*(S(2)*p + S(1)) + S(1)) + S(2)*B*a*c*(p*(S(2)*n - q) + S(1)) - B*b**S(2)*(p*q + p*(n - q) + S(1)))), x), x) + Simp(x*(a*x**q + b*x**n + c*x**(S(2)*n - q))**p*(A*c*(p*q + (n - q)*(S(2)*p + S(1)) + S(1)) + B*b*p*(n - q) + B*c*x**(n - q)*(p*(S(2)*n - q) + S(1)))/(c*(p*(S(2)*n - q) + S(1))*(p*q + (n - q)*(S(2)*p + S(1)) + S(1))), x) rule1451 = ReplacementRule(pattern1451, replacement1451) def With1452(B, p, j, r, c, a, x, q, A): if isinstance(x, (int, Integer, float, Float)): return False n = q + r if And(ZeroQ(j - S(2)*n + q), NonzeroQ(p*(S(2)*n - q) + S(1)), NonzeroQ(p*q + (n - q)*(S(2)*p + S(1)) + S(1))): return True return False pattern1452 = Pattern(Integral((A_ + x_**WC('r', S(1))*WC('B', S(1)))*(x_**WC('j', S(1))*WC('c', S(1)) + x_**WC('q', S(1))*WC('a', S(1)))**p_, x_), cons2, cons7, cons34, cons35, cons50, cons147, cons13, cons163, CustomConstraint(With1452)) def replacement1452(B, p, j, r, c, a, x, q, A): n = q + r rubi.append(1452) return Dist(p*(n - q)/((p*(S(2)*n - q) + S(1))*(p*q + (n - q)*(S(2)*p + S(1)) + S(1))), Int(x**q*(a*x**q + c*x**(S(2)*n - q))**(p + S(-1))*(S(2)*A*a*(p*q + (n - q)*(S(2)*p + S(1)) + S(1)) + S(2)*B*a*x**(n - q)*(p*(S(2)*n - q) + S(1))), x), x) + Simp(x*(A*(p*q + (n - q)*(S(2)*p + S(1)) + S(1)) + B*x**(n - q)*(p*(S(2)*n - q) + S(1)))*(a*x**q + c*x**(S(2)*n - q))**p/((p*(S(2)*n - q) + S(1))*(p*q + (n - q)*(S(2)*p + S(1)) + S(1))), x) rule1452 = ReplacementRule(pattern1452, replacement1452) pattern1453 = Pattern(Integral((A_ + x_**WC('r', S(1))*WC('B', S(1)))*(x_**WC('j', S(1))*WC('c', S(1)) + x_**WC('n', S(1))*WC('b', S(1)) + x_**WC('q', S(1))*WC('a', S(1)))**p_, x_), cons2, cons3, cons7, cons34, cons35, cons4, cons50, cons777, cons778, cons147, cons226, cons13, cons137) def replacement1453(B, p, j, b, r, c, n, a, x, q, A): rubi.append(1453) return Dist(S(1)/(a*(n - q)*(p + S(1))*(-S(4)*a*c + b**S(2))), Int(x**(-q)*(a*x**q + b*x**n + c*x**(S(2)*n - q))**(p + S(1))*(-S(2)*A*a*c*(p*q + S(2)*(n - q)*(p + S(1)) + S(1)) + A*b**S(2)*(p*q + (n - q)*(p + S(1)) + S(1)) - B*a*b*(p*q + S(1)) + c*x**(n - q)*(A*b - S(2)*B*a)*(p*q + (n - q)*(S(2)*p + S(3)) + S(1))), x), x) - Simp(x**(-q + S(1))*(a*x**q + b*x**n + c*x**(S(2)*n - q))**(p + S(1))*(-S(2)*A*a*c + A*b**S(2) - B*a*b + c*x**(n - q)*(A*b - S(2)*B*a))/(a*(n - q)*(p + S(1))*(-S(4)*a*c + b**S(2))), x) rule1453 = ReplacementRule(pattern1453, replacement1453) def With1454(B, p, j, r, c, a, x, q, A): if isinstance(x, (int, Integer, float, Float)): return False n = q + r if ZeroQ(j - S(2)*n + q): return True return False pattern1454 = Pattern(Integral((A_ + x_**WC('r', S(1))*WC('B', S(1)))*(x_**WC('j', S(1))*WC('c', S(1)) + x_**WC('q', S(1))*WC('a', S(1)))**p_, x_), cons2, cons7, cons34, cons35, cons50, cons147, cons13, cons137, CustomConstraint(With1454)) def replacement1454(B, p, j, r, c, a, x, q, A): n = q + r rubi.append(1454) return Dist(S(1)/(S(2)*a**S(2)*c*(n - q)*(p + S(1))), Int(x**(-q)*(a*x**q + c*x**(S(2)*n - q))**(p + S(1))*(A*a*c*(p*q + S(2)*(n - q)*(p + S(1)) + S(1)) + B*a*c*x**(n - q)*(p*q + (n - q)*(S(2)*p + S(3)) + S(1))), x), x) - Simp(x**(-q + S(1))*(a*x**q + c*x**(S(2)*n - q))**(p + S(1))*(A*a*c + B*a*c*x**(n - q))/(S(2)*a**S(2)*c*(n - q)*(p + S(1))), x) rule1454 = ReplacementRule(pattern1454, replacement1454) pattern1455 = Pattern(Integral((A_ + x_**WC('j', S(1))*WC('B', S(1)))*(x_**WC('n', S(1))*WC('b', S(1)) + x_**WC('q', S(1))*WC('a', S(1)) + x_**WC('r', S(1))*WC('c', S(1)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons34, cons35, cons4, cons5, cons50, cons779, cons752) def replacement1455(B, p, j, b, r, a, n, c, x, q, A): rubi.append(1455) return Int((A + B*x**(n - q))*(a*x**q + b*x**n + c*x**(S(2)*n - q))**p, x) rule1455 = ReplacementRule(pattern1455, replacement1455) pattern1456 = Pattern(Integral((A_ + u_**WC('j', S(1))*WC('B', S(1)))*(u_**WC('n', S(1))*WC('b', S(1)) + u_**WC('q', S(1))*WC('a', S(1)) + u_**WC('r', S(1))*WC('c', S(1)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons34, cons35, cons4, cons5, cons50, cons779, cons752, cons68, cons69) def replacement1456(B, p, u, j, b, r, a, n, c, x, q, A): rubi.append(1456) return Dist(S(1)/Coefficient(u, x, S(1)), Subst(Int((A + B*x**(n - q))*(a*x**q + b*x**n + c*x**(S(2)*n - q))**p, x), x, u), x) rule1456 = ReplacementRule(pattern1456, replacement1456) pattern1457 = Pattern(Integral(x_**WC('m', S(1))*(A_ + x_**WC('r', S(1))*WC('B', S(1)))*(x_**WC('j', S(1))*WC('c', S(1)) + x_**WC('n', S(1))*WC('b', S(1)) + x_**WC('q', S(1))*WC('a', S(1)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons34, cons35, cons21, cons4, cons50, cons777, cons778, cons38, cons753) def replacement1457(B, p, j, m, b, r, c, n, a, x, q, A): rubi.append(1457) return Int(x**(m + p*q)*(A + B*x**(n - q))*(a + b*x**(n - q) + c*x**(S(2)*n - S(2)*q))**p, x) rule1457 = ReplacementRule(pattern1457, replacement1457) pattern1458 = Pattern(Integral(x_**WC('m', S(1))*(A_ + x_**WC('r', S(1))*WC('B', S(1)))*(x_**WC('j', S(1))*WC('c', S(1)) + x_**WC('n', S(1))*WC('b', S(1)) + x_**WC('q', S(1))*WC('a', S(1)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons34, cons35, cons777, cons778, cons147, cons226, cons148, cons606, cons163, cons783, cons784, cons785) def replacement1458(B, p, j, m, b, r, c, n, a, x, q, A): rubi.append(1458) return Dist(p*(n - q)/((m + p*q + S(1))*(m + p*q + (n - q)*(S(2)*p + S(1)) + S(1))), Int(x**(m + n)*(a*x**q + b*x**n + c*x**(S(2)*n - q))**(p + S(-1))*Simp(-A*b*(m + p*q + (n - q)*(S(2)*p + S(1)) + S(1)) + S(2)*B*a*(m + p*q + S(1)) + x**(n - q)*(-S(2)*A*c*(m + p*q + (n - q)*(S(2)*p + S(1)) + S(1)) + B*b*(m + p*q + S(1))), x), x), x) + Simp(x**(m + S(1))*(A*(m + p*q + (n - q)*(S(2)*p + S(1)) + S(1)) + B*x**(n - q)*(m + p*q + S(1)))*(a*x**q + b*x**n + c*x**(S(2)*n - q))**p/((m + p*q + S(1))*(m + p*q + (n - q)*(S(2)*p + S(1)) + S(1))), x) rule1458 = ReplacementRule(pattern1458, replacement1458) def With1459(B, p, j, m, r, c, a, x, q, A): if isinstance(x, (int, Integer, float, Float)): return False n = q + r if And(ZeroQ(j - S(2)*n + q), PositiveIntegerQ(n), LessEqual(m + p*q, -n + q), Unequal(m + p*q + S(1), S(0)), Unequal(m + p*q + (n - q)*(S(2)*p + S(1)) + S(1), S(0))): return True return False pattern1459 = Pattern(Integral(x_**WC('m', S(1))*(A_ + x_**WC('r', S(1))*WC('B', S(1)))*(x_**WC('j', S(1))*WC('c', S(1)) + x_**WC('q', S(1))*WC('a', S(1)))**WC('p', S(1)), x_), cons2, cons7, cons34, cons35, cons147, cons606, cons163, CustomConstraint(With1459)) def replacement1459(B, p, j, m, r, c, a, x, q, A): n = q + r rubi.append(1459) return Dist(S(2)*p*(n - q)/((m + p*q + S(1))*(m + p*q + (n - q)*(S(2)*p + S(1)) + S(1))), Int(x**(m + n)*(a*x**q + c*x**(S(2)*n - q))**(p + S(-1))*Simp(-A*c*x**(n - q)*(m + p*q + (n - q)*(S(2)*p + S(1)) + S(1)) + B*a*(m + p*q + S(1)), x), x), x) + Simp(x**(m + S(1))*(A*(m + p*q + (n - q)*(S(2)*p + S(1)) + S(1)) + B*x**(n - q)*(m + p*q + S(1)))*(a*x**q + c*x**(S(2)*n - q))**p/((m + p*q + S(1))*(m + p*q + (n - q)*(S(2)*p + S(1)) + S(1))), x) rule1459 = ReplacementRule(pattern1459, replacement1459) pattern1460 = Pattern(Integral(x_**WC('m', S(1))*(A_ + x_**WC('r', S(1))*WC('B', S(1)))*(x_**WC('j', S(1))*WC('c', S(1)) + x_**WC('n', S(1))*WC('b', S(1)) + x_**WC('q', S(1))*WC('a', S(1)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons34, cons35, cons777, cons778, cons147, cons226, cons148, cons606, cons137, cons786) def replacement1460(B, p, j, m, b, r, c, n, a, x, q, A): rubi.append(1460) return Dist(S(1)/((n - q)*(p + S(1))*(-S(4)*a*c + b**S(2))), Int(x**(m - n)*(a*x**q + b*x**n + c*x**(S(2)*n - q))**(p + S(1))*Simp(x**(n - q)*(-S(2)*A*c + B*b)*(m + p*q + S(2)*(n - q)*(p + S(1)) + S(1)) + (-A*b + S(2)*B*a)*(m - n + p*q + q + S(1)), x), x), x) + Simp(x**(m - n + S(1))*(A*b - S(2)*B*a - x**(n - q)*(-S(2)*A*c + B*b))*(a*x**q + b*x**n + c*x**(S(2)*n - q))**(p + S(1))/((n - q)*(p + S(1))*(-S(4)*a*c + b**S(2))), x) rule1460 = ReplacementRule(pattern1460, replacement1460) def With1461(B, p, j, m, r, c, a, x, q, A): if isinstance(x, (int, Integer, float, Float)): return False n = q + r if And(ZeroQ(j - S(2)*n + q), PositiveIntegerQ(n), Greater(m + p*q, n - q + S(-1))): return True return False pattern1461 = Pattern(Integral(x_**WC('m', S(1))*(A_ + x_**WC('r', S(1))*WC('B', S(1)))*(x_**WC('j', S(1))*WC('c', S(1)) + x_**WC('q', S(1))*WC('a', S(1)))**WC('p', S(1)), x_), cons2, cons7, cons34, cons35, cons147, cons606, cons137, CustomConstraint(With1461)) def replacement1461(B, p, j, m, r, c, a, x, q, A): n = q + r rubi.append(1461) return -Dist(S(1)/(S(2)*a*c*(n - q)*(p + S(1))), Int(x**(m - n)*(a*x**q + c*x**(S(2)*n - q))**(p + S(1))*Simp(-A*c*x**(n - q)*(m + p*q + S(2)*(n - q)*(p + S(1)) + S(1)) + B*a*(m - n + p*q + q + S(1)), x), x), x) + Simp(x**(m - n + S(1))*(a*x**q + c*x**(S(2)*n - q))**(p + S(1))*(-A*c*x**(n - q) + B*a)/(S(2)*a*c*(n - q)*(p + S(1))), x) rule1461 = ReplacementRule(pattern1461, replacement1461) pattern1462 = Pattern(Integral(x_**WC('m', S(1))*(A_ + x_**WC('r', S(1))*WC('B', S(1)))*(x_**WC('j', S(1))*WC('c', S(1)) + x_**WC('n', S(1))*WC('b', S(1)) + x_**WC('q', S(1))*WC('a', S(1)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons34, cons35, cons777, cons778, cons147, cons226, cons148, cons606, cons163, cons787, cons764, cons785) def replacement1462(B, p, j, m, b, r, c, n, a, x, q, A): rubi.append(1462) return Dist(p*(n - q)/(c*(m + p*(S(2)*n - q) + S(1))*(m + p*q + (n - q)*(S(2)*p + S(1)) + S(1))), Int(x**(m + q)*(a*x**q + b*x**n + c*x**(S(2)*n - q))**(p + S(-1))*Simp(S(2)*A*a*c*(m + p*q + (n - q)*(S(2)*p + S(1)) + S(1)) - B*a*b*(m + p*q + S(1)) + x**(n - q)*(A*b*c*(m + p*q + (n - q)*(S(2)*p + S(1)) + S(1)) + S(2)*B*a*c*(m + p*q + S(2)*p*(n - q) + S(1)) - B*b**S(2)*(m + p*q + p*(n - q) + S(1))), x), x), x) + Simp(x**(m + S(1))*(a*x**q + b*x**n + c*x**(S(2)*n - q))**p*(A*c*(m + p*q + (n - q)*(S(2)*p + S(1)) + S(1)) + B*b*p*(n - q) + B*c*x**(n - q)*(m + p*q + S(2)*p*(n - q) + S(1)))/(c*(m + p*(S(2)*n - q) + S(1))*(m + p*q + (n - q)*(S(2)*p + S(1)) + S(1))), x) rule1462 = ReplacementRule(pattern1462, replacement1462) def With1463(B, p, j, m, r, c, a, x, q, A): if isinstance(x, (int, Integer, float, Float)): return False n = q + r if And(ZeroQ(j - S(2)*n + q), PositiveIntegerQ(n), Greater(m + p*q, -n + q), Unequal(m + p*q + S(2)*p*(n - q) + S(1), S(0)), Unequal(m + p*q + (n - q)*(S(2)*p + S(1)) + S(1), S(0)), Unequal(m + S(1), n)): return True return False pattern1463 = Pattern(Integral(x_**WC('m', S(1))*(A_ + x_**WC('r', S(1))*WC('B', S(1)))*(x_**WC('j', S(1))*WC('c', S(1)) + x_**WC('q', S(1))*WC('a', S(1)))**WC('p', S(1)), x_), cons2, cons7, cons34, cons35, cons147, cons606, cons163, CustomConstraint(With1463)) def replacement1463(B, p, j, m, r, c, a, x, q, A): n = q + r rubi.append(1463) return Dist(p*(n - q)/((m + p*(S(2)*n - q) + S(1))*(m + p*q + (n - q)*(S(2)*p + S(1)) + S(1))), Int(x**(m + q)*(a*x**q + c*x**(S(2)*n - q))**(p + S(-1))*Simp(S(2)*A*a*(m + p*q + (n - q)*(S(2)*p + S(1)) + S(1)) + S(2)*B*a*x**(n - q)*(m + p*q + S(2)*p*(n - q) + S(1)), x), x), x) + Simp(x**(m + S(1))*(A*(m + p*q + (n - q)*(S(2)*p + S(1)) + S(1)) + B*x**(n - q)*(m + p*q + S(2)*p*(n - q) + S(1)))*(a*x**q + c*x**(S(2)*n - q))**p/((m + p*(S(2)*n - q) + S(1))*(m + p*q + (n - q)*(S(2)*p + S(1)) + S(1))), x) rule1463 = ReplacementRule(pattern1463, replacement1463) pattern1464 = Pattern(Integral(x_**WC('m', S(1))*(A_ + x_**WC('r', S(1))*WC('B', S(1)))*(x_**WC('j', S(1))*WC('c', S(1)) + x_**WC('n', S(1))*WC('b', S(1)) + x_**WC('q', S(1))*WC('a', S(1)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons34, cons35, cons777, cons778, cons147, cons226, cons148, cons606, cons137, cons788) def replacement1464(B, p, j, m, b, r, c, n, a, x, q, A): rubi.append(1464) return Dist(S(1)/(a*(n - q)*(p + S(1))*(-S(4)*a*c + b**S(2))), Int(x**(m - q)*(a*x**q + b*x**n + c*x**(S(2)*n - q))**(p + S(1))*Simp(-S(2)*A*a*c*(m + p*q + S(2)*(n - q)*(p + S(1)) + S(1)) + A*b**S(2)*(m + p*q + (n - q)*(p + S(1)) + S(1)) - B*a*b*(m + p*q + S(1)) + c*x**(n - q)*(A*b - S(2)*B*a)*(m + p*q + (n - q)*(S(2)*p + S(3)) + S(1)), x), x), x) - Simp(x**(m - q + S(1))*(a*x**q + b*x**n + c*x**(S(2)*n - q))**(p + S(1))*(-S(2)*A*a*c + A*b**S(2) - B*a*b + c*x**(n - q)*(A*b - S(2)*B*a))/(a*(n - q)*(p + S(1))*(-S(4)*a*c + b**S(2))), x) rule1464 = ReplacementRule(pattern1464, replacement1464) def With1465(B, p, j, m, r, c, a, x, q, A): if isinstance(x, (int, Integer, float, Float)): return False n = q + r if And(ZeroQ(j - S(2)*n + q), PositiveIntegerQ(n), Less(m + p*q, n - q + S(-1))): return True return False pattern1465 = Pattern(Integral(x_**WC('m', S(1))*(A_ + x_**WC('r', S(1))*WC('B', S(1)))*(x_**WC('j', S(1))*WC('c', S(1)) + x_**WC('q', S(1))*WC('a', S(1)))**WC('p', S(1)), x_), cons2, cons7, cons34, cons35, cons147, cons606, cons137, CustomConstraint(With1465)) def replacement1465(B, p, j, m, r, c, a, x, q, A): n = q + r rubi.append(1465) return Dist(S(1)/(S(2)*a*c*(n - q)*(p + S(1))), Int(x**(m - q)*(a*x**q + c*x**(S(2)*n - q))**(p + S(1))*Simp(A*c*(m + p*q + S(2)*(n - q)*(p + S(1)) + S(1)) + B*c*x**(n - q)*(m + p*q + (n - q)*(S(2)*p + S(3)) + S(1)), x), x), x) - Simp(x**(m - q + S(1))*(A*c + B*c*x**(n - q))*(a*x**q + c*x**(S(2)*n - q))**(p + S(1))/(S(2)*a*c*(n - q)*(p + S(1))), x) rule1465 = ReplacementRule(pattern1465, replacement1465) pattern1466 = Pattern(Integral(x_**WC('m', S(1))*(A_ + x_**WC('r', S(1))*WC('B', S(1)))*(x_**WC('j', S(1))*WC('c', S(1)) + x_**WC('n', S(1))*WC('b', S(1)) + x_**WC('q', S(1))*WC('a', S(1)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons34, cons35, cons777, cons778, cons147, cons226, cons148, cons606, cons773, cons789, cons785) def replacement1466(B, p, j, m, b, r, c, n, a, x, q, A): rubi.append(1466) return -Dist(S(1)/(c*(m + p*q + (n - q)*(S(2)*p + S(1)) + S(1))), Int(x**(m - n + q)*(a*x**q + b*x**n + c*x**(S(2)*n - q))**p*Simp(B*a*(m - n + p*q + q + S(1)) + x**(n - q)*(-A*c*(m + p*q + (n - q)*(S(2)*p + S(1)) + S(1)) + B*b*(m + p*q + p*(n - q) + S(1))), x), x), x) + Simp(B*x**(m - n + S(1))*(a*x**q + b*x**n + c*x**(S(2)*n - q))**(p + S(1))/(c*(m + p*q + (n - q)*(S(2)*p + S(1)) + S(1))), x) rule1466 = ReplacementRule(pattern1466, replacement1466) def With1467(B, p, j, m, r, c, a, x, q, A): if isinstance(x, (int, Integer, float, Float)): return False n = q + r if And(ZeroQ(j - S(2)*n + q), PositiveIntegerQ(n), GreaterEqual(m + p*q, n - q + S(-1)), Unequal(m + p*q + (n - q)*(S(2)*p + S(1)) + S(1), S(0))): return True return False pattern1467 = Pattern(Integral(x_**WC('m', S(1))*(A_ + x_**WC('r', S(1))*WC('B', S(1)))*(x_**WC('j', S(1))*WC('c', S(1)) + x_**WC('q', S(1))*WC('a', S(1)))**WC('p', S(1)), x_), cons2, cons7, cons34, cons35, cons147, cons606, cons773, CustomConstraint(With1467)) def replacement1467(B, p, j, m, r, c, a, x, q, A): n = q + r rubi.append(1467) return -Dist(S(1)/(c*(m + p*q + (n - q)*(S(2)*p + S(1)) + S(1))), Int(x**(m - n + q)*(a*x**q + c*x**(S(2)*n - q))**p*Simp(-A*c*x**(n - q)*(m + p*q + (n - q)*(S(2)*p + S(1)) + S(1)) + B*a*(m - n + p*q + q + S(1)), x), x), x) + Simp(B*x**(m - n + S(1))*(a*x**q + c*x**(S(2)*n - q))**(p + S(1))/(c*(m + p*q + (n - q)*(S(2)*p + S(1)) + S(1))), x) rule1467 = ReplacementRule(pattern1467, replacement1467) pattern1468 = Pattern(Integral(x_**WC('m', S(1))*(A_ + x_**WC('r', S(1))*WC('B', S(1)))*(x_**WC('j', S(1))*WC('c', S(1)) + x_**WC('n', S(1))*WC('b', S(1)) + x_**WC('q', S(1))*WC('a', S(1)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons34, cons35, cons777, cons778, cons147, cons226, cons148, cons606, cons790, cons783, cons784) def replacement1468(B, p, j, m, b, r, c, n, a, x, q, A): rubi.append(1468) return Dist(S(1)/(a*(m + p*q + S(1))), Int(x**(m + n - q)*(a*x**q + b*x**n + c*x**(S(2)*n - q))**p*Simp(-A*b*(m + p*q + (n - q)*(p + S(1)) + S(1)) - A*c*x**(n - q)*(m + p*q + S(2)*(n - q)*(p + S(1)) + S(1)) + B*a*(m + p*q + S(1)), x), x), x) + Simp(A*x**(m - q + S(1))*(a*x**q + b*x**n + c*x**(S(2)*n - q))**(p + S(1))/(a*(m + p*q + S(1))), x) rule1468 = ReplacementRule(pattern1468, replacement1468) def With1469(B, p, j, m, r, c, a, x, q, A): if isinstance(x, (int, Integer, float, Float)): return False n = q + r if And(ZeroQ(j - S(2)*n + q), PositiveIntegerQ(n), Or(Inequality(S(-1), LessEqual, p, Less, S(0)), Equal(m + p*q + (n - q)*(S(2)*p + S(1)) + S(1), S(0))), LessEqual(m + p*q, -n + q), Unequal(m + p*q + S(1), S(0))): return True return False pattern1469 = Pattern(Integral(x_**WC('m', S(1))*(A_ + x_**WC('r', S(1))*WC('B', S(1)))*(x_**WC('j', S(1))*WC('c', S(1)) + x_**WC('q', S(1))*WC('a', S(1)))**WC('p', S(1)), x_), cons2, cons7, cons34, cons35, cons147, cons606, CustomConstraint(With1469)) def replacement1469(B, p, j, m, r, c, a, x, q, A): n = q + r rubi.append(1469) return Dist(S(1)/(a*(m + p*q + S(1))), Int(x**(m + n - q)*(a*x**q + c*x**(S(2)*n - q))**p*Simp(-A*c*x**(n - q)*(m + p*q + S(2)*(n - q)*(p + S(1)) + S(1)) + B*a*(m + p*q + S(1)), x), x), x) + Simp(A*x**(m - q + S(1))*(a*x**q + c*x**(S(2)*n - q))**(p + S(1))/(a*(m + p*q + S(1))), x) rule1469 = ReplacementRule(pattern1469, replacement1469) pattern1470 = Pattern(Integral(x_**WC('m', S(1))*(A_ + x_**WC('j', S(1))*WC('B', S(1)))/sqrt(x_**WC('n', S(1))*WC('b', S(1)) + x_**WC('q', S(1))*WC('a', S(1)) + x_**WC('r', S(1))*WC('c', S(1))), x_), cons2, cons3, cons7, cons34, cons35, cons21, cons4, cons50, cons779, cons752, cons753, cons791, cons780, cons792) def replacement1470(B, j, m, b, r, a, n, c, x, q, A): rubi.append(1470) return Dist(x**(q/S(2))*sqrt(a + b*x**(n - q) + c*x**(S(2)*n - S(2)*q))/sqrt(a*x**q + b*x**n + c*x**(S(2)*n - q)), Int(x**(m - q/S(2))*(A + B*x**(n - q))/sqrt(a + b*x**(n - q) + c*x**(S(2)*n - S(2)*q)), x), x) rule1470 = ReplacementRule(pattern1470, replacement1470) pattern1471 = Pattern(Integral(x_**WC('m', S(1))*(A_ + x_**q_*WC('B', S(1)))*(x_**WC('j', S(1))*WC('a', S(1)) + x_**WC('k', S(1))*WC('b', S(1)) + x_**WC('n', S(1))*WC('c', S(1)))**p_, x_), cons2, cons3, cons7, cons34, cons35, cons796, cons797, cons21, cons5, cons793, cons794, cons147, cons795) def replacement1471(B, p, j, k, m, b, a, c, n, x, q, A): rubi.append(1471) return Dist(x**(-j*p)*(a + b*x**(-j + k) + c*x**(-S(2)*j + S(2)*k))**(-p)*(a*x**j + b*x**k + c*x**n)**p, Int(x**(j*p + m)*(A + B*x**(-j + k))*(a + b*x**(-j + k) + c*x**(-S(2)*j + S(2)*k))**p, x), x) rule1471 = ReplacementRule(pattern1471, replacement1471) pattern1472 = Pattern(Integral(u_**WC('m', S(1))*(A_ + u_**WC('j', S(1))*WC('B', S(1)))*(u_**WC('n', S(1))*WC('b', S(1)) + u_**WC('q', S(1))*WC('a', S(1)) + u_**WC('r', S(1))*WC('c', S(1)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons34, cons35, cons21, cons4, cons5, cons50, cons779, cons752, cons68, cons69) def replacement1472(B, p, u, j, m, b, r, a, n, c, x, q, A): rubi.append(1472) return Dist(S(1)/Coefficient(u, x, S(1)), Subst(Int(x**m*(A + B*x**(n - q))*(a*x**q + b*x**n + c*x**(S(2)*n - q))**p, x), x, u), x) rule1472 = ReplacementRule(pattern1472, replacement1472) return [rule1076, rule1077, rule1078, rule1079, rule1080, rule1081, rule1082, rule1083, rule1084, rule1085, rule1086, rule1087, rule1088, rule1089, rule1090, rule1091, rule1092, rule1093, rule1094, rule1095, rule1096, rule1097, rule1098, rule1099, rule1100, rule1101, rule1102, rule1103, rule1104, rule1105, rule1106, rule1107, rule1108, rule1109, rule1110, rule1111, rule1112, rule1113, rule1114, rule1115, rule1116, rule1117, rule1118, rule1119, rule1120, rule1121, rule1122, rule1123, rule1124, rule1125, rule1126, rule1127, rule1128, rule1129, rule1130, rule1131, rule1132, rule1133, rule1134, rule1135, rule1136, rule1137, rule1138, rule1139, rule1140, rule1141, rule1142, rule1143, rule1144, rule1145, rule1146, rule1147, rule1148, rule1149, rule1150, rule1151, rule1152, rule1153, rule1154, rule1155, rule1156, rule1157, rule1158, rule1159, rule1160, rule1161, rule1162, rule1163, rule1164, rule1165, rule1166, rule1167, rule1168, rule1169, rule1170, rule1171, rule1172, rule1173, rule1174, rule1175, rule1176, rule1177, rule1178, rule1179, rule1180, rule1181, rule1182, rule1183, rule1184, rule1185, rule1186, rule1187, rule1188, rule1189, rule1190, rule1191, rule1192, rule1193, rule1194, rule1195, rule1196, rule1197, rule1198, rule1199, rule1200, rule1201, rule1202, rule1203, rule1204, rule1205, rule1206, rule1207, rule1208, rule1209, rule1210, rule1211, rule1212, rule1213, rule1214, rule1215, rule1216, rule1217, rule1218, rule1219, rule1220, rule1221, rule1222, rule1223, rule1224, rule1225, rule1226, rule1227, rule1228, rule1229, rule1230, rule1231, rule1232, rule1233, rule1234, rule1235, rule1236, rule1237, rule1238, rule1239, rule1240, rule1241, rule1242, rule1243, rule1244, rule1245, rule1246, rule1247, rule1248, rule1249, rule1250, rule1251, rule1252, rule1253, rule1254, rule1255, rule1256, rule1257, rule1258, rule1259, rule1260, rule1261, rule1262, rule1263, rule1264, rule1265, rule1266, rule1267, rule1268, rule1269, rule1270, rule1271, rule1272, rule1273, rule1274, rule1275, rule1276, rule1277, rule1278, rule1279, rule1280, rule1281, rule1282, rule1283, rule1284, rule1285, rule1286, rule1287, rule1288, rule1289, rule1290, rule1291, rule1292, rule1293, rule1294, rule1295, rule1296, rule1297, rule1298, rule1299, rule1300, rule1301, rule1302, rule1303, rule1304, rule1305, rule1306, rule1307, rule1308, rule1309, rule1310, rule1311, rule1312, rule1313, rule1314, rule1315, rule1316, rule1317, rule1318, rule1319, rule1320, rule1321, rule1322, rule1323, rule1324, rule1325, rule1326, rule1327, rule1328, rule1329, rule1330, rule1331, rule1332, rule1333, rule1334, rule1335, rule1336, rule1337, rule1338, rule1339, rule1340, rule1341, rule1342, rule1343, rule1344, rule1345, rule1346, rule1347, rule1348, rule1349, rule1350, rule1351, rule1352, rule1353, rule1354, rule1355, rule1356, rule1357, rule1358, rule1359, rule1360, rule1361, rule1362, rule1363, rule1364, rule1365, rule1366, rule1367, rule1368, rule1369, rule1370, rule1371, rule1372, rule1373, rule1374, rule1375, rule1376, rule1377, rule1378, rule1379, rule1380, rule1381, rule1382, rule1383, rule1384, rule1385, rule1386, rule1387, rule1388, rule1389, rule1390, rule1391, rule1392, rule1393, rule1394, rule1395, rule1396, rule1397, rule1398, rule1399, rule1400, rule1401, rule1402, rule1403, rule1404, rule1405, rule1406, rule1407, rule1408, rule1409, rule1410, rule1411, rule1412, rule1413, rule1414, rule1415, rule1416, rule1417, rule1418, rule1419, rule1420, rule1421, rule1422, rule1423, rule1424, rule1425, rule1426, rule1427, rule1428, rule1429, rule1430, rule1431, rule1432, rule1433, rule1434, rule1435, rule1436, rule1437, rule1438, rule1439, rule1440, rule1441, rule1442, rule1443, rule1444, rule1445, rule1446, rule1447, rule1448, rule1449, rule1450, rule1451, rule1452, rule1453, rule1454, rule1455, rule1456, rule1457, rule1458, rule1459, rule1460, rule1461, rule1462, rule1463, rule1464, rule1465, rule1466, rule1467, rule1468, rule1469, rule1470, rule1471, rule1472, ]
3bb45004e105dba442e97b3aefa71dc943b3f3e72398f9f5b90159e7c2e0d997
''' This code is automatically generated. Never edit it manually. For details of generating the code see `rubi_parsing_guide.md` in `parsetools`. ''' from sympy.external import import_module matchpy = import_module("matchpy") from sympy.utilities.decorator import doctest_depends_on if matchpy: from matchpy import Pattern, ReplacementRule, CustomConstraint, is_match from sympy.integrals.rubi.utility_function import ( Int, Sum, Set, With, Module, Scan, MapAnd, FalseQ, ZeroQ, NegativeQ, NonzeroQ, FreeQ, NFreeQ, List, Log, PositiveQ, PositiveIntegerQ, NegativeIntegerQ, IntegerQ, IntegersQ, ComplexNumberQ, PureComplexNumberQ, RealNumericQ, PositiveOrZeroQ, NegativeOrZeroQ, FractionOrNegativeQ, NegQ, Equal, Unequal, IntPart, FracPart, RationalQ, ProductQ, SumQ, NonsumQ, Subst, First, Rest, SqrtNumberQ, SqrtNumberSumQ, LinearQ, Sqrt, ArcCosh, Coefficient, Denominator, Hypergeometric2F1, Not, Simplify, FractionalPart, IntegerPart, AppellF1, EllipticPi, EllipticE, EllipticF, ArcTan, ArcCot, ArcCoth, ArcTanh, ArcSin, ArcSinh, ArcCos, ArcCsc, ArcSec, ArcCsch, ArcSech, Sinh, Tanh, Cosh, Sech, Csch, Coth, LessEqual, Less, Greater, GreaterEqual, FractionQ, IntLinearcQ, Expand, IndependentQ, PowerQ, IntegerPowerQ, PositiveIntegerPowerQ, FractionalPowerQ, AtomQ, ExpQ, LogQ, Head, MemberQ, TrigQ, SinQ, CosQ, TanQ, CotQ, SecQ, CscQ, Sin, Cos, Tan, Cot, Sec, Csc, HyperbolicQ, SinhQ, CoshQ, TanhQ, CothQ, SechQ, CschQ, InverseTrigQ, SinCosQ, SinhCoshQ, LeafCount, Numerator, NumberQ, NumericQ, Length, ListQ, Im, Re, InverseHyperbolicQ, InverseFunctionQ, TrigHyperbolicFreeQ, InverseFunctionFreeQ, RealQ, EqQ, FractionalPowerFreeQ, ComplexFreeQ, PolynomialQ, FactorSquareFree, PowerOfLinearQ, Exponent, QuadraticQ, LinearPairQ, BinomialParts, TrinomialParts, PolyQ, EvenQ, OddQ, PerfectSquareQ, NiceSqrtAuxQ, NiceSqrtQ, Together, PosAux, PosQ, CoefficientList, ReplaceAll, ExpandLinearProduct, GCD, ContentFactor, NumericFactor, NonnumericFactors, MakeAssocList, GensymSubst, KernelSubst, ExpandExpression, Apart, SmartApart, MatchQ, PolynomialQuotientRemainder, FreeFactors, NonfreeFactors, RemoveContentAux, RemoveContent, FreeTerms, NonfreeTerms, ExpandAlgebraicFunction, CollectReciprocals, ExpandCleanup, AlgebraicFunctionQ, Coeff, LeadTerm, RemainingTerms, LeadFactor, RemainingFactors, LeadBase, LeadDegree, Numer, Denom, hypergeom, Expon, MergeMonomials, PolynomialDivide, BinomialQ, TrinomialQ, GeneralizedBinomialQ, GeneralizedTrinomialQ, FactorSquareFreeList, PerfectPowerTest, SquareFreeFactorTest, RationalFunctionQ, RationalFunctionFactors, NonrationalFunctionFactors, Reverse, RationalFunctionExponents, RationalFunctionExpand, ExpandIntegrand, SimplerQ, SimplerSqrtQ, SumSimplerQ, BinomialDegree, TrinomialDegree, CancelCommonFactors, SimplerIntegrandQ, GeneralizedBinomialDegree, GeneralizedBinomialParts, GeneralizedTrinomialDegree, GeneralizedTrinomialParts, MonomialQ, MonomialSumQ, MinimumMonomialExponent, MonomialExponent, LinearMatchQ, PowerOfLinearMatchQ, QuadraticMatchQ, CubicMatchQ, BinomialMatchQ, TrinomialMatchQ, GeneralizedBinomialMatchQ, GeneralizedTrinomialMatchQ, QuotientOfLinearsMatchQ, PolynomialTermQ, PolynomialTerms, NonpolynomialTerms, PseudoBinomialParts, NormalizePseudoBinomial, PseudoBinomialPairQ, PseudoBinomialQ, PolynomialGCD, PolyGCD, AlgebraicFunctionFactors, NonalgebraicFunctionFactors, QuotientOfLinearsP, QuotientOfLinearsParts, QuotientOfLinearsQ, Flatten, Sort, AbsurdNumberQ, AbsurdNumberFactors, NonabsurdNumberFactors, SumSimplerAuxQ, Prepend, Drop, CombineExponents, FactorInteger, FactorAbsurdNumber, SubstForInverseFunction, SubstForFractionalPower, SubstForFractionalPowerOfQuotientOfLinears, FractionalPowerOfQuotientOfLinears, SubstForFractionalPowerQ, SubstForFractionalPowerAuxQ, FractionalPowerOfSquareQ, FractionalPowerSubexpressionQ, Apply, FactorNumericGcd, MergeableFactorQ, MergeFactor, MergeFactors, TrigSimplifyQ, TrigSimplify, TrigSimplifyRecur, Order, FactorOrder, Smallest, OrderedQ, MinimumDegree, PositiveFactors, Sign, NonpositiveFactors, PolynomialInAuxQ, PolynomialInQ, ExponentInAux, ExponentIn, PolynomialInSubstAux, PolynomialInSubst, Distrib, DistributeDegree, FunctionOfPower, DivideDegreesOfFactors, MonomialFactor, FullSimplify, FunctionOfLinearSubst, FunctionOfLinear, NormalizeIntegrand, NormalizeIntegrandAux, NormalizeIntegrandFactor, NormalizeIntegrandFactorBase, NormalizeTogether, NormalizeLeadTermSigns, AbsorbMinusSign, NormalizeSumFactors, SignOfFactor, NormalizePowerOfLinear, SimplifyIntegrand, SimplifyTerm, TogetherSimplify, SmartSimplify, SubstForExpn, ExpandToSum, UnifySum, UnifyTerms, UnifyTerm, CalculusQ, FunctionOfInverseLinear, PureFunctionOfSinhQ, PureFunctionOfTanhQ, PureFunctionOfCoshQ, IntegerQuotientQ, OddQuotientQ, EvenQuotientQ, FindTrigFactor, FunctionOfSinhQ, FunctionOfCoshQ, OddHyperbolicPowerQ, FunctionOfTanhQ, FunctionOfTanhWeight, FunctionOfHyperbolicQ, SmartNumerator, SmartDenominator, SubstForAux, ActivateTrig, ExpandTrig, TrigExpand, SubstForTrig, SubstForHyperbolic, InertTrigFreeQ, LCM, SubstForFractionalPowerOfLinear, FractionalPowerOfLinear, InverseFunctionOfLinear, InertTrigQ, InertReciprocalQ, DeactivateTrig, FixInertTrigFunction, DeactivateTrigAux, PowerOfInertTrigSumQ, PiecewiseLinearQ, KnownTrigIntegrandQ, KnownSineIntegrandQ, KnownTangentIntegrandQ, KnownCotangentIntegrandQ, KnownSecantIntegrandQ, TryPureTanSubst, TryTanhSubst, TryPureTanhSubst, AbsurdNumberGCD, AbsurdNumberGCDList, ExpandTrigExpand, ExpandTrigReduce, ExpandTrigReduceAux, NormalizeTrig, TrigToExp, ExpandTrigToExp, TrigReduce, FunctionOfTrig, AlgebraicTrigFunctionQ, FunctionOfHyperbolic, FunctionOfQ, FunctionOfExpnQ, PureFunctionOfSinQ, PureFunctionOfCosQ, PureFunctionOfTanQ, PureFunctionOfCotQ, FunctionOfCosQ, FunctionOfSinQ, OddTrigPowerQ, FunctionOfTanQ, FunctionOfTanWeight, FunctionOfTrigQ, FunctionOfDensePolynomialsQ, FunctionOfLog, PowerVariableExpn, PowerVariableDegree, PowerVariableSubst, EulerIntegrandQ, FunctionOfSquareRootOfQuadratic, SquareRootOfQuadraticSubst, Divides, EasyDQ, ProductOfLinearPowersQ, Rt, NthRoot, AtomBaseQ, SumBaseQ, NegSumBaseQ, AllNegTermQ, SomeNegTermQ, TrigSquareQ, RtAux, TrigSquare, IntSum, IntTerm, Map2, ConstantFactor, SameQ, ReplacePart, CommonFactors, MostMainFactorPosition, FunctionOfExponentialQ, FunctionOfExponential, FunctionOfExponentialFunction, FunctionOfExponentialFunctionAux, FunctionOfExponentialTest, FunctionOfExponentialTestAux, stdev, rubi_test, If, IntQuadraticQ, IntBinomialQ, RectifyTangent, RectifyCotangent, Inequality, Condition, Simp, SimpHelp, SplitProduct, SplitSum, SubstFor, SubstForAux, FresnelS, FresnelC, Erfc, Erfi, Gamma, FunctionOfTrigOfLinearQ, ElementaryFunctionQ, Complex, UnsameQ, _SimpFixFactor, SimpFixFactor, _FixSimplify, FixSimplify, _SimplifyAntiderivativeSum, SimplifyAntiderivativeSum, _SimplifyAntiderivative, SimplifyAntiderivative, _TrigSimplifyAux, TrigSimplifyAux, Cancel, Part, PolyLog, D, Dist, Sum_doit, PolynomialQuotient, Floor, PolynomialRemainder, Factor, PolyLog, CosIntegral, SinIntegral, LogIntegral, SinhIntegral, CoshIntegral, Rule, Erf, PolyGamma, ExpIntegralEi, ExpIntegralE, LogGamma , UtilityOperator, Factorial, Zeta, ProductLog, DerivativeDivides, HypergeometricPFQ, IntHide, OneQ, Null, rubi_exp as exp, rubi_log as log, Discriminant, Negative, Quotient ) from sympy import (Integral, S, sqrt, And, Or, Integer, Float, Mod, I, Abs, simplify, Mul, Add, Pow, sign, EulerGamma) from sympy.integrals.rubi.symbol import WC from sympy.core.symbol import symbols, Symbol from sympy.functions import (sin, cos, tan, cot, csc, sec, sqrt, erf) from sympy.functions.elementary.hyperbolic import (acosh, asinh, atanh, acoth, acsch, asech, cosh, sinh, tanh, coth, sech, csch) from sympy.functions.elementary.trigonometric import (atan, acsc, asin, acot, acos, asec, atan2) from sympy import pi as Pi A_, B_, C_, F_, G_, H_, a_, b_, c_, d_, e_, f_, g_, h_, i_, j_, k_, l_, m_, n_, p_, q_, r_, t_, u_, v_, s_, w_, x_, y_, z_ = [WC(i) for i in 'ABCFGHabcdefghijklmnpqrtuvswxyz'] a1_, a2_, b1_, b2_, c1_, c2_, d1_, d2_, n1_, n2_, e1_, e2_, f1_, f2_, g1_, g2_, n1_, n2_, n3_, Pq_, Pm_, Px_, Qm_, Qr_, Qx_, jn_, mn_, non2_, RFx_, RGx_ = [WC(i) for i in ['a1', 'a2', 'b1', 'b2', 'c1', 'c2', 'd1', 'd2', 'n1', 'n2', 'e1', 'e2', 'f1', 'f2', 'g1', 'g2', 'n1', 'n2', 'n3', 'Pq', 'Pm', 'Px', 'Qm', 'Qr', 'Qx', 'jn', 'mn', 'non2', 'RFx', 'RGx']] i, ii , Pqq, Q, R, r, C, k, u = symbols('i ii Pqq Q R r C k u') _UseGamma = False ShowSteps = False StepCounter = None def secant(rubi): from sympy.integrals.rubi.constraints import cons1581, cons1502, cons2, cons3, cons48, cons125, cons21, cons4, cons1582, cons1512, cons1583, cons18, cons93, cons166, cons89, cons1170, cons94, cons165, cons31, cons1584, cons87, cons1359, cons23, cons1255, cons1258, cons674, cons7, cons27, cons808, cons1261, cons1585, cons1264, cons1265, cons1586, cons543, cons43, cons448, cons1267, cons744, cons1587, cons1254, cons62, cons1423, cons515, cons1320, cons1321, cons1588, cons1589, cons1590, cons1330, cons111, cons155, cons1591, cons1519, cons1336, cons1592, cons463, cons85, cons1593, cons77, cons168, cons272, cons1333, cons1594, cons1334, cons1595, cons1325, cons1596, cons1597, cons1598, cons1599, cons1553, cons1600, cons1357, cons1601, cons1602, cons1603, cons1604, cons17, cons208, cons5, cons1274, cons1605, cons1606, cons1308, cons147, cons1228, cons1507, cons148, cons1515, cons1607, cons196, cons1311, cons1608, cons1609, cons1580, cons70, cons1610, cons1611, cons79, cons1612, cons1613, cons1304, cons71, cons1412, cons1409, cons1323, cons1322, cons1614, cons80, cons1360, cons1421, cons1315, cons1231, cons1615, cons1314, cons1266, cons1616, cons150, cons1617, cons1618, cons1619, cons1620, cons1621, cons38, cons1622, cons1415, cons380, cons1428, cons34, cons35, cons1245, cons1569, cons1623, cons1624, cons1625, cons1626, cons1627, cons32, cons1549, cons1628, cons1629, cons346, cons88, cons1327, cons1630, cons1631, cons1256, cons1632, cons375, cons33, cons36, cons1433, cons1633, cons1634, cons1431, cons1635, cons1636, cons1637, cons1638, cons1639, cons1640, cons683, cons1641, cons1642, cons1643, cons1454, cons1478, cons54, cons1480, cons1479, cons1481, cons376, cons46, cons45, cons226, cons1644, cons528, cons810, cons811, cons1573, cons1495, cons68, cons69, cons823, cons824, cons1574, cons1576, cons1497, cons1577, cons1645 pattern3917 = Pattern(Integral((WC('a', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons48, cons125, cons21, cons4, cons1581, cons1502) def replacement3917(m, f, b, a, n, x, e): rubi.append(3917) return Simp(a*b*(a/sin(e + f*x))**(m + S(-1))*(b/cos(e + f*x))**(n + S(-1))/(f*(n + S(-1))), x) rule3917 = ReplacementRule(pattern3917, replacement3917) pattern3918 = Pattern(Integral((S(1)/sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(S(1)/cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1)), x_), cons48, cons125, cons1582) def replacement3918(m, f, n, x, e): rubi.append(3918) return Dist(S(1)/f, Subst(Int(x**(-m)*(x**S(2) + S(1))**(m/S(2) + n/S(2) + S(-1)), x), x, tan(e + f*x)), x) rule3918 = ReplacementRule(pattern3918, replacement3918) pattern3919 = Pattern(Integral((WC('a', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(S(1)/cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1)), x_), cons2, cons48, cons125, cons21, cons1512, cons1583, cons18) def replacement3919(m, f, a, n, x, e): rubi.append(3919) return -Dist(a**(-n + S(1))/f, Subst(Int((a*x)**(m + n + S(-1))*(x**S(2) + S(-1))**(-n/S(2) + S(-1)/2), x), x, S(1)/sin(e + f*x)), x) rule3919 = ReplacementRule(pattern3919, replacement3919) pattern3920 = Pattern(Integral((WC('a', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(S(1)/sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1)), x_), cons2, cons48, cons125, cons21, cons1512, cons1583, cons18) def replacement3920(m, f, a, n, x, e): rubi.append(3920) return Dist(a**(-n + S(1))/f, Subst(Int((a*x)**(m + n + S(-1))*(x**S(2) + S(-1))**(-n/S(2) + S(-1)/2), x), x, S(1)/cos(e + f*x)), x) rule3920 = ReplacementRule(pattern3920, replacement3920) pattern3921 = Pattern(Integral((WC('a', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons48, cons125, cons93, cons166, cons89, cons1170) def replacement3921(m, f, b, a, n, x, e): rubi.append(3921) return Dist(a**S(2)*(n + S(1))/(b**S(2)*(m + S(-1))), Int((a/sin(e + f*x))**(m + S(-2))*(b/cos(e + f*x))**(n + S(2)), x), x) - Simp(a*(a/sin(e + f*x))**(m + S(-1))*(b/cos(e + f*x))**(n + S(1))/(b*f*(m + S(-1))), x) rule3921 = ReplacementRule(pattern3921, replacement3921) pattern3922 = Pattern(Integral((WC('a', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons48, cons125, cons93, cons94, cons165, cons1170) def replacement3922(m, f, b, a, n, x, e): rubi.append(3922) return Dist(b**S(2)*(m + S(1))/(a**S(2)*(n + S(-1))), Int((a/sin(e + f*x))**(m + S(2))*(b/cos(e + f*x))**(n + S(-2)), x), x) + Simp(b*(a/sin(e + f*x))**(m + S(1))*(b/cos(e + f*x))**(n + S(-1))/(a*f*(n + S(-1))), x) rule3922 = ReplacementRule(pattern3922, replacement3922) pattern3923 = Pattern(Integral((WC('a', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1)), x_), cons2, cons3, cons48, cons125, cons4, cons31, cons166, cons1170, cons1584) def replacement3923(m, f, b, a, n, x, e): rubi.append(3923) return Dist(a**S(2)*(m + n + S(-2))/(m + S(-1)), Int((a/sin(e + f*x))**(m + S(-2))*(b/cos(e + f*x))**n, x), x) - Simp(a*b*(a/sin(e + f*x))**(m + S(-1))*(b/cos(e + f*x))**(n + S(-1))/(f*(m + S(-1))), x) rule3923 = ReplacementRule(pattern3923, replacement3923) pattern3924 = Pattern(Integral((WC('a', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons48, cons125, cons21, cons87, cons165, cons1170) def replacement3924(m, f, b, a, n, x, e): rubi.append(3924) return Dist(b**S(2)*(m + n + S(-2))/(n + S(-1)), Int((a/sin(e + f*x))**m*(b/cos(e + f*x))**(n + S(-2)), x), x) + Simp(a*b*(a/sin(e + f*x))**(m + S(-1))*(b/cos(e + f*x))**(n + S(-1))/(f*(n + S(-1))), x) rule3924 = ReplacementRule(pattern3924, replacement3924) pattern3925 = Pattern(Integral((WC('a', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1)), x_), cons2, cons3, cons48, cons125, cons4, cons31, cons94, cons1359, cons1170) def replacement3925(m, f, b, a, n, x, e): rubi.append(3925) return Dist((m + S(1))/(a**S(2)*(m + n)), Int((a/sin(e + f*x))**(m + S(2))*(b/cos(e + f*x))**n, x), x) + Simp(b*(a/sin(e + f*x))**(m + S(1))*(b/cos(e + f*x))**(n + S(-1))/(a*f*(m + n)), x) rule3925 = ReplacementRule(pattern3925, replacement3925) pattern3926 = Pattern(Integral((WC('a', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons48, cons125, cons21, cons87, cons89, cons1359, cons1170) def replacement3926(m, f, b, a, n, x, e): rubi.append(3926) return Dist((n + S(1))/(b**S(2)*(m + n)), Int((a/sin(e + f*x))**m*(b/cos(e + f*x))**(n + S(2)), x), x) - Simp(a*(a/sin(e + f*x))**(m + S(-1))*(b/cos(e + f*x))**(n + S(1))/(b*f*(m + n)), x) rule3926 = ReplacementRule(pattern3926, replacement3926) pattern3927 = Pattern(Integral((WC('a', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons48, cons125, cons21, cons4, cons23, cons1255) def replacement3927(m, f, b, a, n, x, e): rubi.append(3927) return Dist((a/sin(e + f*x))**m*(b/cos(e + f*x))**n*tan(e + f*x)**(-n), Int(tan(e + f*x)**n, x), x) rule3927 = ReplacementRule(pattern3927, replacement3927) pattern3928 = Pattern(Integral((WC('a', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons48, cons125, cons21, cons4, cons1258) def replacement3928(m, f, b, a, n, x, e): rubi.append(3928) return Dist((a/sin(e + f*x))**m*(a*sin(e + f*x))**m*(b/cos(e + f*x))**n*(b*cos(e + f*x))**n, Int((a*sin(e + f*x))**(-m)*(b*cos(e + f*x))**(-n), x), x) rule3928 = ReplacementRule(pattern3928, replacement3928) pattern3929 = Pattern(Integral((S(1)/cos(x_*WC('d', S(1)) + WC('c', S(0))))**n_, x_), cons7, cons27, cons674) def replacement3929(d, c, n, x): rubi.append(3929) return Dist(S(1)/d, Subst(Int(ExpandIntegrand((x**S(2) + S(1))**(n/S(2) + S(-1)), x), x), x, tan(c + d*x)), x) rule3929 = ReplacementRule(pattern3929, replacement3929) pattern3930 = Pattern(Integral((S(1)/sin(x_*WC('d', S(1)) + WC('c', S(0))))**n_, x_), cons7, cons27, cons674) def replacement3930(d, c, n, x): rubi.append(3930) return -Dist(S(1)/d, Subst(Int(ExpandIntegrand((x**S(2) + S(1))**(n/S(2) + S(-1)), x), x), x, S(1)/tan(c + d*x)), x) rule3930 = ReplacementRule(pattern3930, replacement3930) pattern3931 = Pattern(Integral((WC('b', S(1))/cos(x_*WC('d', S(1)) + WC('c', S(0))))**n_, x_), cons3, cons7, cons27, cons165, cons808) def replacement3931(b, d, c, n, x): rubi.append(3931) return Dist(b**S(2)*(n + S(-2))/(n + S(-1)), Int((b/cos(c + d*x))**(n + S(-2)), x), x) + Simp(b*(b/cos(c + d*x))**(n + S(-1))*sin(c + d*x)/(d*(n + S(-1))), x) rule3931 = ReplacementRule(pattern3931, replacement3931) pattern3932 = Pattern(Integral((WC('b', S(1))/sin(x_*WC('d', S(1)) + WC('c', S(0))))**n_, x_), cons3, cons7, cons27, cons165, cons808) def replacement3932(b, d, c, n, x): rubi.append(3932) return Dist(b**S(2)*(n + S(-2))/(n + S(-1)), Int((b/sin(c + d*x))**(n + S(-2)), x), x) - Simp(b*(b/sin(c + d*x))**(n + S(-1))*cos(c + d*x)/(d*(n + S(-1))), x) rule3932 = ReplacementRule(pattern3932, replacement3932) pattern3933 = Pattern(Integral((WC('b', S(1))/cos(x_*WC('d', S(1)) + WC('c', S(0))))**n_, x_), cons3, cons7, cons27, cons89, cons808) def replacement3933(b, d, c, n, x): rubi.append(3933) return Dist((n + S(1))/(b**S(2)*n), Int((b/cos(c + d*x))**(n + S(2)), x), x) - Simp((b/cos(c + d*x))**(n + S(1))*sin(c + d*x)/(b*d*n), x) rule3933 = ReplacementRule(pattern3933, replacement3933) pattern3934 = Pattern(Integral((WC('b', S(1))/sin(x_*WC('d', S(1)) + WC('c', S(0))))**n_, x_), cons3, cons7, cons27, cons89, cons808) def replacement3934(b, d, c, n, x): rubi.append(3934) return Dist((n + S(1))/(b**S(2)*n), Int((b/sin(c + d*x))**(n + S(2)), x), x) + Simp((b/sin(c + d*x))**(n + S(1))*cos(c + d*x)/(b*d*n), x) rule3934 = ReplacementRule(pattern3934, replacement3934) pattern3935 = Pattern(Integral(S(1)/cos(x_*WC('d', S(1)) + WC('c', S(0))), x_), cons7, cons27, cons1261) def replacement3935(d, c, x): rubi.append(3935) return Simp(atanh(sin(c + d*x))/d, x) rule3935 = ReplacementRule(pattern3935, replacement3935) pattern3936 = Pattern(Integral(S(1)/sin(x_*WC('d', S(1)) + WC('c', S(0))), x_), cons7, cons27, cons1261) def replacement3936(d, c, x): rubi.append(3936) return -Simp(atanh(cos(c + d*x))/d, x) rule3936 = ReplacementRule(pattern3936, replacement3936) pattern3937 = Pattern(Integral((WC('b', S(1))/cos(x_*WC('d', S(1)) + WC('c', S(0))))**n_, x_), cons3, cons7, cons27, cons1585) def replacement3937(b, d, c, n, x): rubi.append(3937) return Dist((b/cos(c + d*x))**n*cos(c + d*x)**n, Int(cos(c + d*x)**(-n), x), x) rule3937 = ReplacementRule(pattern3937, replacement3937) pattern3938 = Pattern(Integral((WC('b', S(1))/sin(x_*WC('d', S(1)) + WC('c', S(0))))**n_, x_), cons3, cons7, cons27, cons1585) def replacement3938(b, d, c, n, x): rubi.append(3938) return Dist((b/sin(c + d*x))**n*sin(c + d*x)**n, Int(sin(c + d*x)**(-n), x), x) rule3938 = ReplacementRule(pattern3938, replacement3938) pattern3939 = Pattern(Integral((WC('b', S(1))/cos(x_*WC('d', S(1)) + WC('c', S(0))))**n_, x_), cons3, cons7, cons27, cons4, cons23) def replacement3939(b, d, c, n, x): rubi.append(3939) return Simp((cos(c + d*x)/b)**(n + S(-1))*(b/cos(c + d*x))**(n + S(-1))*Int((cos(c + d*x)/b)**(-n), x), x) rule3939 = ReplacementRule(pattern3939, replacement3939) pattern3940 = Pattern(Integral((WC('b', S(1))/sin(x_*WC('d', S(1)) + WC('c', S(0))))**n_, x_), cons3, cons7, cons27, cons4, cons23) def replacement3940(b, d, c, n, x): rubi.append(3940) return Simp((sin(c + d*x)/b)**(n + S(-1))*(b/sin(c + d*x))**(n + S(-1))*Int((sin(c + d*x)/b)**(-n), x), x) rule3940 = ReplacementRule(pattern3940, replacement3940) pattern3941 = Pattern(Integral((a_ + WC('b', S(1))/cos(x_*WC('d', S(1)) + WC('c', S(0))))**S(2), x_), cons2, cons3, cons7, cons27, cons1264) def replacement3941(b, d, c, a, x): rubi.append(3941) return Dist(b**S(2), Int(cos(c + d*x)**(S(-2)), x), x) + Dist(S(2)*a*b, Int(S(1)/cos(c + d*x), x), x) + Simp(a**S(2)*x, x) rule3941 = ReplacementRule(pattern3941, replacement3941) pattern3942 = Pattern(Integral((a_ + WC('b', S(1))/sin(x_*WC('d', S(1)) + WC('c', S(0))))**S(2), x_), cons2, cons3, cons7, cons27, cons1264) def replacement3942(b, d, c, a, x): rubi.append(3942) return Dist(b**S(2), Int(sin(c + d*x)**(S(-2)), x), x) + Dist(S(2)*a*b, Int(S(1)/sin(c + d*x), x), x) + Simp(a**S(2)*x, x) rule3942 = ReplacementRule(pattern3942, replacement3942) pattern3943 = Pattern(Integral(sqrt(a_ + WC('b', S(1))/cos(x_*WC('d', S(1)) + WC('c', S(0)))), x_), cons2, cons3, cons7, cons27, cons1265) def replacement3943(b, d, c, a, x): rubi.append(3943) return Dist(S(2)*b/d, Subst(Int(S(1)/(a + x**S(2)), x), x, b*tan(c + d*x)/sqrt(a + b/cos(c + d*x))), x) rule3943 = ReplacementRule(pattern3943, replacement3943) pattern3944 = Pattern(Integral(sqrt(a_ + WC('b', S(1))/sin(x_*WC('d', S(1)) + WC('c', S(0)))), x_), cons2, cons3, cons7, cons27, cons1265) def replacement3944(b, d, c, a, x): rubi.append(3944) return Dist(-S(2)*b/d, Subst(Int(S(1)/(a + x**S(2)), x), x, b/(sqrt(a + b/sin(c + d*x))*tan(c + d*x))), x) rule3944 = ReplacementRule(pattern3944, replacement3944) pattern3945 = Pattern(Integral((a_ + WC('b', S(1))/cos(x_*WC('d', S(1)) + WC('c', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons1265, cons87, cons165, cons808) def replacement3945(b, d, c, a, n, x): rubi.append(3945) return Dist(a/(n + S(-1)), Int((a + b/cos(c + d*x))**(n + S(-2))*(a*(n + S(-1)) + b*(S(3)*n + S(-4))/cos(c + d*x)), x), x) + Simp(b**S(2)*(a + b/cos(c + d*x))**(n + S(-2))*tan(c + d*x)/(d*(n + S(-1))), x) rule3945 = ReplacementRule(pattern3945, replacement3945) pattern3946 = Pattern(Integral((a_ + WC('b', S(1))/sin(x_*WC('d', S(1)) + WC('c', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons1265, cons87, cons165, cons808) def replacement3946(b, d, c, a, n, x): rubi.append(3946) return Dist(a/(n + S(-1)), Int((a + b/sin(c + d*x))**(n + S(-2))*(a*(n + S(-1)) + b*(S(3)*n + S(-4))/sin(c + d*x)), x), x) - Simp(b**S(2)*(a + b/sin(c + d*x))**(n + S(-2))/(d*(n + S(-1))*tan(c + d*x)), x) rule3946 = ReplacementRule(pattern3946, replacement3946) pattern3947 = Pattern(Integral(S(1)/sqrt(a_ + WC('b', S(1))/cos(x_*WC('d', S(1)) + WC('c', S(0)))), x_), cons2, cons3, cons7, cons27, cons1265) def replacement3947(b, d, c, a, x): rubi.append(3947) return Dist(S(1)/a, Int(sqrt(a + b/cos(c + d*x)), x), x) - Dist(b/a, Int(S(1)/(sqrt(a + b/cos(c + d*x))*cos(c + d*x)), x), x) rule3947 = ReplacementRule(pattern3947, replacement3947) pattern3948 = Pattern(Integral(S(1)/sqrt(a_ + WC('b', S(1))/sin(x_*WC('d', S(1)) + WC('c', S(0)))), x_), cons2, cons3, cons7, cons27, cons1265) def replacement3948(b, d, c, a, x): rubi.append(3948) return Dist(S(1)/a, Int(sqrt(a + b/sin(c + d*x)), x), x) - Dist(b/a, Int(S(1)/(sqrt(a + b/sin(c + d*x))*sin(c + d*x)), x), x) rule3948 = ReplacementRule(pattern3948, replacement3948) pattern3949 = Pattern(Integral((a_ + WC('b', S(1))/cos(x_*WC('d', S(1)) + WC('c', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons1265, cons87, cons1586, cons808) def replacement3949(b, d, c, a, n, x): rubi.append(3949) return Dist(S(1)/(a**S(2)*(S(2)*n + S(1))), Int((a + b/cos(c + d*x))**(n + S(1))*(a*(S(2)*n + S(1)) - b*(n + S(1))/cos(c + d*x)), x), x) + Simp((a + b/cos(c + d*x))**n*tan(c + d*x)/(d*(S(2)*n + S(1))), x) rule3949 = ReplacementRule(pattern3949, replacement3949) pattern3950 = Pattern(Integral((a_ + WC('b', S(1))/sin(x_*WC('d', S(1)) + WC('c', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons1265, cons87, cons1586, cons808) def replacement3950(b, d, c, a, n, x): rubi.append(3950) return Dist(S(1)/(a**S(2)*(S(2)*n + S(1))), Int((a + b/sin(c + d*x))**(n + S(1))*(a*(S(2)*n + S(1)) - b*(n + S(1))/sin(c + d*x)), x), x) - Simp((a + b/sin(c + d*x))**n/(d*(S(2)*n + S(1))*tan(c + d*x)), x) rule3950 = ReplacementRule(pattern3950, replacement3950) pattern3951 = Pattern(Integral((a_ + WC('b', S(1))/cos(x_*WC('d', S(1)) + WC('c', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons4, cons1265, cons543, cons43) def replacement3951(b, d, c, a, n, x): rubi.append(3951) return -Dist(a**n*tan(c + d*x)/(d*sqrt(S(1) - S(1)/cos(c + d*x))*sqrt(S(1) + S(1)/cos(c + d*x))), Subst(Int((S(1) + b*x/a)**(n + S(-1)/2)/(x*sqrt(S(1) - b*x/a)), x), x, S(1)/cos(c + d*x)), x) rule3951 = ReplacementRule(pattern3951, replacement3951) pattern3952 = Pattern(Integral((a_ + WC('b', S(1))/sin(x_*WC('d', S(1)) + WC('c', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons4, cons1265, cons543, cons43) def replacement3952(b, d, c, a, n, x): rubi.append(3952) return Dist(a**n/(d*sqrt(S(1) - S(1)/sin(c + d*x))*sqrt(S(1) + S(1)/sin(c + d*x))*tan(c + d*x)), Subst(Int((S(1) + b*x/a)**(n + S(-1)/2)/(x*sqrt(S(1) - b*x/a)), x), x, S(1)/sin(c + d*x)), x) rule3952 = ReplacementRule(pattern3952, replacement3952) pattern3953 = Pattern(Integral((a_ + WC('b', S(1))/cos(x_*WC('d', S(1)) + WC('c', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons4, cons1265, cons543, cons448) def replacement3953(b, d, c, a, n, x): rubi.append(3953) return Dist(a**IntPart(n)*(S(1) + b/(a*cos(c + d*x)))**(-FracPart(n))*(a + b/cos(c + d*x))**FracPart(n), Int((S(1) + b/(a*cos(c + d*x)))**n, x), x) rule3953 = ReplacementRule(pattern3953, replacement3953) pattern3954 = Pattern(Integral((a_ + WC('b', S(1))/sin(x_*WC('d', S(1)) + WC('c', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons4, cons1265, cons543, cons448) def replacement3954(b, d, c, a, n, x): rubi.append(3954) return Dist(a**IntPart(n)*(S(1) + b/(a*sin(c + d*x)))**(-FracPart(n))*(a + b/sin(c + d*x))**FracPart(n), Int((S(1) + b/(a*sin(c + d*x)))**n, x), x) rule3954 = ReplacementRule(pattern3954, replacement3954) pattern3955 = Pattern(Integral(sqrt(a_ + WC('b', S(1))/cos(x_*WC('d', S(1)) + WC('c', S(0)))), x_), cons2, cons3, cons7, cons27, cons1267) def replacement3955(b, d, c, a, x): rubi.append(3955) return Simp(-S(2)*sqrt(b*(S(1) + S(1)/cos(c + d*x))/(a + b/cos(c + d*x)))*sqrt(-b*(S(1) - S(1)/cos(c + d*x))/(a + b/cos(c + d*x)))*(a + b/cos(c + d*x))*EllipticPi(a/(a + b), asin(Rt(a + b, S(2))/sqrt(a + b/cos(c + d*x))), (a - b)/(a + b))/(d*Rt(a + b, S(2))*tan(c + d*x)), x) rule3955 = ReplacementRule(pattern3955, replacement3955) pattern3956 = Pattern(Integral(sqrt(a_ + WC('b', S(1))/sin(x_*WC('d', S(1)) + WC('c', S(0)))), x_), cons2, cons3, cons7, cons27, cons1267) def replacement3956(b, d, c, a, x): rubi.append(3956) return Simp(S(2)*sqrt(b*(S(1) + S(1)/sin(c + d*x))/(a + b/sin(c + d*x)))*sqrt(-b*(S(1) - S(1)/sin(c + d*x))/(a + b/sin(c + d*x)))*(a + b/sin(c + d*x))*EllipticPi(a/(a + b), asin(Rt(a + b, S(2))/sqrt(a + b/sin(c + d*x))), (a - b)/(a + b))*tan(c + d*x)/(d*Rt(a + b, S(2))), x) rule3956 = ReplacementRule(pattern3956, replacement3956) pattern3957 = Pattern(Integral((a_ + WC('b', S(1))/cos(x_*WC('d', S(1)) + WC('c', S(0))))**(S(3)/2), x_), cons2, cons3, cons7, cons27, cons1267) def replacement3957(b, d, c, a, x): rubi.append(3957) return Dist(b**S(2), Int((S(1) + S(1)/cos(c + d*x))/(sqrt(a + b/cos(c + d*x))*cos(c + d*x)), x), x) + Int((a**S(2) + b*(S(2)*a - b)/cos(c + d*x))/sqrt(a + b/cos(c + d*x)), x) rule3957 = ReplacementRule(pattern3957, replacement3957) pattern3958 = Pattern(Integral((a_ + WC('b', S(1))/sin(x_*WC('d', S(1)) + WC('c', S(0))))**(S(3)/2), x_), cons2, cons3, cons7, cons27, cons1267) def replacement3958(b, d, c, a, x): rubi.append(3958) return Dist(b**S(2), Int((S(1) + S(1)/sin(c + d*x))/(sqrt(a + b/sin(c + d*x))*sin(c + d*x)), x), x) + Int((a**S(2) + b*(S(2)*a - b)/sin(c + d*x))/sqrt(a + b/sin(c + d*x)), x) rule3958 = ReplacementRule(pattern3958, replacement3958) pattern3959 = Pattern(Integral((a_ + WC('b', S(1))/cos(x_*WC('d', S(1)) + WC('c', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons1267, cons87, cons744, cons808) def replacement3959(b, d, c, a, n, x): rubi.append(3959) return Dist(S(1)/(n + S(-1)), Int((a + b/cos(c + d*x))**(n + S(-3))*Simp(a**S(3)*(n + S(-1)) + a*b**S(2)*(S(3)*n + S(-4))/cos(c + d*x)**S(2) + b*(S(3)*a**S(2)*(n + S(-1)) + b**S(2)*(n + S(-2)))/cos(c + d*x), x), x), x) + Simp(b**S(2)*(a + b/cos(c + d*x))**(n + S(-2))*tan(c + d*x)/(d*(n + S(-1))), x) rule3959 = ReplacementRule(pattern3959, replacement3959) pattern3960 = Pattern(Integral((a_ + WC('b', S(1))/sin(x_*WC('d', S(1)) + WC('c', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons1267, cons87, cons744, cons808) def replacement3960(b, d, c, a, n, x): rubi.append(3960) return Dist(S(1)/(n + S(-1)), Int((a + b/sin(c + d*x))**(n + S(-3))*Simp(a**S(3)*(n + S(-1)) + a*b**S(2)*(S(3)*n + S(-4))/sin(c + d*x)**S(2) + b*(S(3)*a**S(2)*(n + S(-1)) + b**S(2)*(n + S(-2)))/sin(c + d*x), x), x), x) - Simp(b**S(2)*(a + b/sin(c + d*x))**(n + S(-2))/(d*(n + S(-1))*tan(c + d*x)), x) rule3960 = ReplacementRule(pattern3960, replacement3960) pattern3961 = Pattern(Integral(S(1)/(a_ + WC('b', S(1))/cos(x_*WC('d', S(1)) + WC('c', S(0)))), x_), cons2, cons3, cons7, cons27, cons1267) def replacement3961(b, d, c, a, x): rubi.append(3961) return -Dist(S(1)/a, Int(S(1)/(a*cos(c + d*x)/b + S(1)), x), x) + Simp(x/a, x) rule3961 = ReplacementRule(pattern3961, replacement3961) pattern3962 = Pattern(Integral(S(1)/(a_ + WC('b', S(1))/sin(x_*WC('d', S(1)) + WC('c', S(0)))), x_), cons2, cons3, cons7, cons27, cons1267) def replacement3962(b, d, c, a, x): rubi.append(3962) return -Dist(S(1)/a, Int(S(1)/(a*sin(c + d*x)/b + S(1)), x), x) + Simp(x/a, x) rule3962 = ReplacementRule(pattern3962, replacement3962) pattern3963 = Pattern(Integral(S(1)/sqrt(a_ + WC('b', S(1))/cos(x_*WC('d', S(1)) + WC('c', S(0)))), x_), cons2, cons3, cons7, cons27, cons1267) def replacement3963(b, d, c, a, x): rubi.append(3963) return Simp(-S(2)*sqrt(b*(S(1) - S(1)/cos(c + d*x))/(a + b))*sqrt(-b*(S(1) + S(1)/cos(c + d*x))/(a - b))*EllipticPi((a + b)/a, asin(sqrt(a + b/cos(c + d*x))/Rt(a + b, S(2))), (a + b)/(a - b))*Rt(a + b, S(2))/(a*d*tan(c + d*x)), x) rule3963 = ReplacementRule(pattern3963, replacement3963) pattern3964 = Pattern(Integral(S(1)/sqrt(a_ + WC('b', S(1))/sin(x_*WC('d', S(1)) + WC('c', S(0)))), x_), cons2, cons3, cons7, cons27, cons1267) def replacement3964(b, d, c, a, x): rubi.append(3964) return Simp(S(2)*sqrt(b*(S(1) - S(1)/sin(c + d*x))/(a + b))*sqrt(-b*(S(1) + S(1)/sin(c + d*x))/(a - b))*EllipticPi((a + b)/a, asin(sqrt(a + b/sin(c + d*x))/Rt(a + b, S(2))), (a + b)/(a - b))*Rt(a + b, S(2))*tan(c + d*x)/(a*d), x) rule3964 = ReplacementRule(pattern3964, replacement3964) pattern3965 = Pattern(Integral((a_ + WC('b', S(1))/cos(x_*WC('d', S(1)) + WC('c', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons1267, cons87, cons89, cons808) def replacement3965(b, d, c, a, n, x): rubi.append(3965) return Dist(S(1)/(a*(a**S(2) - b**S(2))*(n + S(1))), Int((a + b/cos(c + d*x))**(n + S(1))*Simp(-a*b*(n + S(1))/cos(c + d*x) + b**S(2)*(n + S(2))/cos(c + d*x)**S(2) + (a**S(2) - b**S(2))*(n + S(1)), x), x), x) - Simp(b**S(2)*(a + b/cos(c + d*x))**(n + S(1))*tan(c + d*x)/(a*d*(a**S(2) - b**S(2))*(n + S(1))), x) rule3965 = ReplacementRule(pattern3965, replacement3965) pattern3966 = Pattern(Integral((a_ + WC('b', S(1))/sin(x_*WC('d', S(1)) + WC('c', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons1267, cons87, cons89, cons808) def replacement3966(b, d, c, a, n, x): rubi.append(3966) return Dist(S(1)/(a*(a**S(2) - b**S(2))*(n + S(1))), Int((a + b/sin(c + d*x))**(n + S(1))*Simp(-a*b*(n + S(1))/sin(c + d*x) + b**S(2)*(n + S(2))/sin(c + d*x)**S(2) + (a**S(2) - b**S(2))*(n + S(1)), x), x), x) + Simp(b**S(2)*(a + b/sin(c + d*x))**(n + S(1))/(a*d*(a**S(2) - b**S(2))*(n + S(1))*tan(c + d*x)), x) rule3966 = ReplacementRule(pattern3966, replacement3966) pattern3967 = Pattern(Integral((a_ + WC('b', S(1))/cos(x_*WC('d', S(1)) + WC('c', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons4, cons1267, cons543) def replacement3967(b, d, c, a, n, x): rubi.append(3967) return Int((a + b/cos(c + d*x))**n, x) rule3967 = ReplacementRule(pattern3967, replacement3967) pattern3968 = Pattern(Integral((a_ + WC('b', S(1))/sin(x_*WC('d', S(1)) + WC('c', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons4, cons1267, cons543) def replacement3968(b, d, c, a, n, x): rubi.append(3968) return Int((a + b/sin(c + d*x))**n, x) rule3968 = ReplacementRule(pattern3968, replacement3968) pattern3969 = Pattern(Integral((WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1))*(a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons27, cons48, cons125, cons4, cons1587) def replacement3969(f, b, d, a, n, x, e): rubi.append(3969) return Dist(a, Int((d/cos(e + f*x))**n, x), x) + Dist(b/d, Int((d/cos(e + f*x))**(n + S(1)), x), x) rule3969 = ReplacementRule(pattern3969, replacement3969) pattern3970 = Pattern(Integral((WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1))*(a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons27, cons48, cons125, cons4, cons1587) def replacement3970(f, b, d, a, n, x, e): rubi.append(3970) return Dist(a, Int((d/sin(e + f*x))**n, x), x) + Dist(b/d, Int((d/sin(e + f*x))**(n + S(1)), x), x) rule3970 = ReplacementRule(pattern3970, replacement3970) pattern3971 = Pattern(Integral((WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1))*(a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**S(2), x_), cons2, cons3, cons27, cons48, cons125, cons4, cons1587) def replacement3971(f, b, d, a, n, x, e): rubi.append(3971) return Dist(S(2)*a*b/d, Int((d/cos(e + f*x))**(n + S(1)), x), x) + Int((d/cos(e + f*x))**n*(a**S(2) + b**S(2)/cos(e + f*x)**S(2)), x) rule3971 = ReplacementRule(pattern3971, replacement3971) pattern3972 = Pattern(Integral((WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1))*(a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**S(2), x_), cons2, cons3, cons27, cons48, cons125, cons4, cons1587) def replacement3972(f, b, d, a, n, x, e): rubi.append(3972) return Dist(S(2)*a*b/d, Int((d/sin(e + f*x))**(n + S(1)), x), x) + Int((d/sin(e + f*x))**n*(a**S(2) + b**S(2)/sin(e + f*x)**S(2)), x) rule3972 = ReplacementRule(pattern3972, replacement3972) pattern3973 = Pattern(Integral(S(1)/((a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))*cos(x_*WC('f', S(1)) + WC('e', S(0)))**S(2)), x_), cons2, cons3, cons48, cons125, cons1254) def replacement3973(f, b, a, x, e): rubi.append(3973) return Dist(S(1)/b, Int(S(1)/cos(e + f*x), x), x) - Dist(a/b, Int(S(1)/((a + b/cos(e + f*x))*cos(e + f*x)), x), x) rule3973 = ReplacementRule(pattern3973, replacement3973) pattern3974 = Pattern(Integral(S(1)/((a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))*sin(x_*WC('f', S(1)) + WC('e', S(0)))**S(2)), x_), cons2, cons3, cons48, cons125, cons1254) def replacement3974(f, b, a, x, e): rubi.append(3974) return Dist(S(1)/b, Int(S(1)/sin(e + f*x), x), x) - Dist(a/b, Int(S(1)/((a + b/sin(e + f*x))*sin(e + f*x)), x), x) rule3974 = ReplacementRule(pattern3974, replacement3974) pattern3975 = Pattern(Integral(S(1)/((a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))*cos(x_*WC('f', S(1)) + WC('e', S(0)))**S(3)), x_), cons2, cons3, cons48, cons125, cons1254) def replacement3975(f, b, a, x, e): rubi.append(3975) return -Dist(a/b, Int(S(1)/((a + b/cos(e + f*x))*cos(e + f*x)**S(2)), x), x) + Simp(tan(e + f*x)/(b*f), x) rule3975 = ReplacementRule(pattern3975, replacement3975) pattern3976 = Pattern(Integral(S(1)/((a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))*sin(x_*WC('f', S(1)) + WC('e', S(0)))**S(3)), x_), cons2, cons3, cons48, cons125, cons1254) def replacement3976(f, b, a, x, e): rubi.append(3976) return -Dist(a/b, Int(S(1)/((a + b/sin(e + f*x))*sin(e + f*x)**S(2)), x), x) - Simp(S(1)/(b*f*tan(e + f*x)), x) rule3976 = ReplacementRule(pattern3976, replacement3976) pattern3977 = Pattern(Integral((WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1))*(a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_, x_), cons2, cons3, cons27, cons48, cons125, cons21, cons4, cons1265, cons62, cons87) def replacement3977(m, f, b, d, a, n, x, e): rubi.append(3977) return Int(ExpandTrig((d/cos(e + f*x))**n*(a + b/cos(e + f*x))**m, x), x) rule3977 = ReplacementRule(pattern3977, replacement3977) pattern3978 = Pattern(Integral((WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1))*(a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_, x_), cons2, cons3, cons27, cons48, cons125, cons21, cons4, cons1265, cons62, cons87) def replacement3978(m, f, b, d, a, n, x, e): rubi.append(3978) return Int(ExpandTrig((d/sin(e + f*x))**n*(a + b/sin(e + f*x))**m, x), x) rule3978 = ReplacementRule(pattern3978, replacement3978) pattern3979 = Pattern(Integral(sqrt(a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))/cos(x_*WC('f', S(1)) + WC('e', S(0))), x_), cons2, cons3, cons48, cons125, cons1265) def replacement3979(f, b, a, x, e): rubi.append(3979) return Simp(S(2)*b*tan(e + f*x)/(f*sqrt(a + b/cos(e + f*x))), x) rule3979 = ReplacementRule(pattern3979, replacement3979) pattern3980 = Pattern(Integral(sqrt(a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))/sin(x_*WC('f', S(1)) + WC('e', S(0))), x_), cons2, cons3, cons48, cons125, cons1265) def replacement3980(f, b, a, x, e): rubi.append(3980) return Simp(-S(2)*b/(f*sqrt(a + b/sin(e + f*x))*tan(e + f*x)), x) rule3980 = ReplacementRule(pattern3980, replacement3980) pattern3981 = Pattern(Integral((a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_/cos(x_*WC('f', S(1)) + WC('e', S(0))), x_), cons2, cons3, cons48, cons125, cons1265, cons31, cons1423, cons515) def replacement3981(m, f, b, a, x, e): rubi.append(3981) return Dist(a*(S(2)*m + S(-1))/m, Int((a + b/cos(e + f*x))**(m + S(-1))/cos(e + f*x), x), x) + Simp(b*(a + b/cos(e + f*x))**(m + S(-1))*tan(e + f*x)/(f*m), x) rule3981 = ReplacementRule(pattern3981, replacement3981) pattern3982 = Pattern(Integral((a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_/sin(x_*WC('f', S(1)) + WC('e', S(0))), x_), cons2, cons3, cons48, cons125, cons1265, cons31, cons1423, cons515) def replacement3982(m, f, b, a, x, e): rubi.append(3982) return Dist(a*(S(2)*m + S(-1))/m, Int((a + b/sin(e + f*x))**(m + S(-1))/sin(e + f*x), x), x) - Simp(b*(a + b/sin(e + f*x))**(m + S(-1))/(f*m*tan(e + f*x)), x) rule3982 = ReplacementRule(pattern3982, replacement3982) pattern3983 = Pattern(Integral(S(1)/((a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))*cos(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons48, cons125, cons1265) def replacement3983(f, b, a, x, e): rubi.append(3983) return Simp(tan(e + f*x)/(f*(a/cos(e + f*x) + b)), x) rule3983 = ReplacementRule(pattern3983, replacement3983) pattern3984 = Pattern(Integral(S(1)/((a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))*sin(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons48, cons125, cons1265) def replacement3984(f, b, a, x, e): rubi.append(3984) return -Simp(S(1)/(f*(a/sin(e + f*x) + b)*tan(e + f*x)), x) rule3984 = ReplacementRule(pattern3984, replacement3984) pattern3985 = Pattern(Integral(S(1)/(sqrt(a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))*cos(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons48, cons125, cons1265) def replacement3985(f, b, a, x, e): rubi.append(3985) return Dist(S(2)/f, Subst(Int(S(1)/(S(2)*a + x**S(2)), x), x, b*tan(e + f*x)/sqrt(a + b/cos(e + f*x))), x) rule3985 = ReplacementRule(pattern3985, replacement3985) pattern3986 = Pattern(Integral(S(1)/(sqrt(a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))*sin(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons48, cons125, cons1265) def replacement3986(f, b, a, x, e): rubi.append(3986) return Dist(-S(2)/f, Subst(Int(S(1)/(S(2)*a + x**S(2)), x), x, b/(sqrt(a + b/sin(e + f*x))*tan(e + f*x))), x) rule3986 = ReplacementRule(pattern3986, replacement3986) pattern3987 = Pattern(Integral((a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_/cos(x_*WC('f', S(1)) + WC('e', S(0))), x_), cons2, cons3, cons48, cons125, cons1265, cons31, cons1320, cons515) def replacement3987(m, f, b, a, x, e): rubi.append(3987) return Dist((m + S(1))/(a*(S(2)*m + S(1))), Int((a + b/cos(e + f*x))**(m + S(1))/cos(e + f*x), x), x) - Simp(b*(a + b/cos(e + f*x))**m*tan(e + f*x)/(a*f*(S(2)*m + S(1))), x) rule3987 = ReplacementRule(pattern3987, replacement3987) pattern3988 = Pattern(Integral((a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_/sin(x_*WC('f', S(1)) + WC('e', S(0))), x_), cons2, cons3, cons48, cons125, cons1265, cons31, cons1320, cons515) def replacement3988(m, f, b, a, x, e): rubi.append(3988) return Dist((m + S(1))/(a*(S(2)*m + S(1))), Int((a + b/sin(e + f*x))**(m + S(1))/sin(e + f*x), x), x) + Simp(b*(a + b/sin(e + f*x))**m/(a*f*(S(2)*m + S(1))*tan(e + f*x)), x) rule3988 = ReplacementRule(pattern3988, replacement3988) pattern3989 = Pattern(Integral((a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_/cos(x_*WC('f', S(1)) + WC('e', S(0)))**S(2), x_), cons2, cons3, cons48, cons125, cons1265, cons31, cons1320) def replacement3989(m, f, b, a, x, e): rubi.append(3989) return Dist(m/(b*(S(2)*m + S(1))), Int((a + b/cos(e + f*x))**(m + S(1))/cos(e + f*x), x), x) + Simp((a + b/cos(e + f*x))**m*tan(e + f*x)/(f*(S(2)*m + S(1))), x) rule3989 = ReplacementRule(pattern3989, replacement3989) pattern3990 = Pattern(Integral((a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_/sin(x_*WC('f', S(1)) + WC('e', S(0)))**S(2), x_), cons2, cons3, cons48, cons125, cons1265, cons31, cons1320) def replacement3990(m, f, b, a, x, e): rubi.append(3990) return Dist(m/(b*(S(2)*m + S(1))), Int((a + b/sin(e + f*x))**(m + S(1))/sin(e + f*x), x), x) - Simp((a + b/sin(e + f*x))**m/(f*(S(2)*m + S(1))*tan(e + f*x)), x) rule3990 = ReplacementRule(pattern3990, replacement3990) pattern3991 = Pattern(Integral((a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_/cos(x_*WC('f', S(1)) + WC('e', S(0)))**S(2), x_), cons2, cons3, cons48, cons125, cons21, cons1265, cons1321) def replacement3991(m, f, b, a, x, e): rubi.append(3991) return Dist(a*m/(b*(m + S(1))), Int((a + b/cos(e + f*x))**m/cos(e + f*x), x), x) + Simp((a + b/cos(e + f*x))**m*tan(e + f*x)/(f*(m + S(1))), x) rule3991 = ReplacementRule(pattern3991, replacement3991) pattern3992 = Pattern(Integral((a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_/sin(x_*WC('f', S(1)) + WC('e', S(0)))**S(2), x_), cons2, cons3, cons48, cons125, cons21, cons1265, cons1321) def replacement3992(m, f, b, a, x, e): rubi.append(3992) return Dist(a*m/(b*(m + S(1))), Int((a + b/sin(e + f*x))**m/sin(e + f*x), x), x) - Simp((a + b/sin(e + f*x))**m/(f*(m + S(1))*tan(e + f*x)), x) rule3992 = ReplacementRule(pattern3992, replacement3992) pattern3993 = Pattern(Integral((a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_/cos(x_*WC('f', S(1)) + WC('e', S(0)))**S(3), x_), cons2, cons3, cons48, cons125, cons1265, cons31, cons1320) def replacement3993(m, f, b, a, x, e): rubi.append(3993) return -Dist(S(1)/(a**S(2)*(S(2)*m + S(1))), Int((a + b/cos(e + f*x))**(m + S(1))*(a*m - b*(S(2)*m + S(1))/cos(e + f*x))/cos(e + f*x), x), x) - Simp(b*(a + b/cos(e + f*x))**m*tan(e + f*x)/(a*f*(S(2)*m + S(1))), x) rule3993 = ReplacementRule(pattern3993, replacement3993) pattern3994 = Pattern(Integral((a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_/sin(x_*WC('f', S(1)) + WC('e', S(0)))**S(3), x_), cons2, cons3, cons48, cons125, cons1265, cons31, cons1320) def replacement3994(m, f, b, a, x, e): rubi.append(3994) return -Dist(S(1)/(a**S(2)*(S(2)*m + S(1))), Int((a + b/sin(e + f*x))**(m + S(1))*(a*m - b*(S(2)*m + S(1))/sin(e + f*x))/sin(e + f*x), x), x) + Simp(b*(a + b/sin(e + f*x))**m/(a*f*(S(2)*m + S(1))*tan(e + f*x)), x) rule3994 = ReplacementRule(pattern3994, replacement3994) pattern3995 = Pattern(Integral((a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_/cos(x_*WC('f', S(1)) + WC('e', S(0)))**S(3), x_), cons2, cons3, cons48, cons125, cons21, cons1265, cons1321) def replacement3995(m, f, b, a, x, e): rubi.append(3995) return Dist(S(1)/(b*(m + S(2))), Int((a + b/cos(e + f*x))**m*(-a/cos(e + f*x) + b*(m + S(1)))/cos(e + f*x), x), x) + Simp((a + b/cos(e + f*x))**(m + S(1))*tan(e + f*x)/(b*f*(m + S(2))), x) rule3995 = ReplacementRule(pattern3995, replacement3995) pattern3996 = Pattern(Integral((a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_/sin(x_*WC('f', S(1)) + WC('e', S(0)))**S(3), x_), cons2, cons3, cons48, cons125, cons21, cons1265, cons1321) def replacement3996(m, f, b, a, x, e): rubi.append(3996) return Dist(S(1)/(b*(m + S(2))), Int((a + b/sin(e + f*x))**m*(-a/sin(e + f*x) + b*(m + S(1)))/sin(e + f*x), x), x) - Simp((a + b/sin(e + f*x))**(m + S(1))/(b*f*(m + S(2))*tan(e + f*x)), x) rule3996 = ReplacementRule(pattern3996, replacement3996) pattern3997 = Pattern(Integral(sqrt(WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))*sqrt(a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons27, cons48, cons125, cons1265, cons1588) def replacement3997(f, b, d, a, x, e): rubi.append(3997) return Dist(S(2)*a*sqrt(a*d/b)/(b*f), Subst(Int(S(1)/sqrt(S(1) + x**S(2)/a), x), x, b*tan(e + f*x)/sqrt(a + b/cos(e + f*x))), x) rule3997 = ReplacementRule(pattern3997, replacement3997) pattern3998 = Pattern(Integral(sqrt(WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))*sqrt(a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons27, cons48, cons125, cons1265, cons1588) def replacement3998(f, b, d, a, x, e): rubi.append(3998) return Dist(-S(2)*a*sqrt(a*d/b)/(b*f), Subst(Int(S(1)/sqrt(S(1) + x**S(2)/a), x), x, b/(sqrt(a + b/sin(e + f*x))*tan(e + f*x))), x) rule3998 = ReplacementRule(pattern3998, replacement3998) pattern3999 = Pattern(Integral(sqrt(WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))*sqrt(a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons27, cons48, cons125, cons1265, cons1589) def replacement3999(f, b, d, a, x, e): rubi.append(3999) return Dist(S(2)*b*d/f, Subst(Int(S(1)/(b - d*x**S(2)), x), x, b*tan(e + f*x)/(sqrt(d/cos(e + f*x))*sqrt(a + b/cos(e + f*x)))), x) rule3999 = ReplacementRule(pattern3999, replacement3999) pattern4000 = Pattern(Integral(sqrt(WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))*sqrt(a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons27, cons48, cons125, cons1265, cons1589) def replacement4000(f, b, d, a, x, e): rubi.append(4000) return Dist(-S(2)*b*d/f, Subst(Int(S(1)/(b - d*x**S(2)), x), x, b/(sqrt(d/sin(e + f*x))*sqrt(a + b/sin(e + f*x))*tan(e + f*x))), x) rule4000 = ReplacementRule(pattern4000, replacement4000) pattern4001 = Pattern(Integral((WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_*sqrt(a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons27, cons48, cons125, cons1265, cons87, cons165, cons808) def replacement4001(f, b, d, a, n, x, e): rubi.append(4001) return Dist(S(2)*a*d*(n + S(-1))/(b*(S(2)*n + S(-1))), Int((d/cos(e + f*x))**(n + S(-1))*sqrt(a + b/cos(e + f*x)), x), x) + Simp(S(2)*b*d*(d/cos(e + f*x))**(n + S(-1))*tan(e + f*x)/(f*sqrt(a + b/cos(e + f*x))*(S(2)*n + S(-1))), x) rule4001 = ReplacementRule(pattern4001, replacement4001) pattern4002 = Pattern(Integral((WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_*sqrt(a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons27, cons48, cons125, cons1265, cons87, cons165, cons808) def replacement4002(f, b, d, a, n, x, e): rubi.append(4002) return Dist(S(2)*a*d*(n + S(-1))/(b*(S(2)*n + S(-1))), Int((d/sin(e + f*x))**(n + S(-1))*sqrt(a + b/sin(e + f*x)), x), x) + Simp(-S(2)*b*d*(d/sin(e + f*x))**(n + S(-1))/(f*sqrt(a + b/sin(e + f*x))*(S(2)*n + S(-1))*tan(e + f*x)), x) rule4002 = ReplacementRule(pattern4002, replacement4002) pattern4003 = Pattern(Integral(sqrt(a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))/sqrt(WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons27, cons48, cons125, cons1265) def replacement4003(f, b, d, a, x, e): rubi.append(4003) return Simp(S(2)*a*tan(e + f*x)/(f*sqrt(d/cos(e + f*x))*sqrt(a + b/cos(e + f*x))), x) rule4003 = ReplacementRule(pattern4003, replacement4003) pattern4004 = Pattern(Integral(sqrt(a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))/sqrt(WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons27, cons48, cons125, cons1265) def replacement4004(f, b, d, a, x, e): rubi.append(4004) return Simp(-S(2)*a/(f*sqrt(d/sin(e + f*x))*sqrt(a + b/sin(e + f*x))*tan(e + f*x)), x) rule4004 = ReplacementRule(pattern4004, replacement4004) pattern4005 = Pattern(Integral((WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_*sqrt(a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons27, cons48, cons125, cons1265, cons87, cons1590, cons808) def replacement4005(f, b, d, a, n, x, e): rubi.append(4005) return Dist(a*(S(2)*n + S(1))/(S(2)*b*d*n), Int((d/cos(e + f*x))**(n + S(1))*sqrt(a + b/cos(e + f*x)), x), x) - Simp(a*(d/cos(e + f*x))**n*tan(e + f*x)/(f*n*sqrt(a + b/cos(e + f*x))), x) rule4005 = ReplacementRule(pattern4005, replacement4005) pattern4006 = Pattern(Integral((WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_*sqrt(a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons27, cons48, cons125, cons1265, cons87, cons1590, cons808) def replacement4006(f, b, d, a, n, x, e): rubi.append(4006) return Dist(a*(S(2)*n + S(1))/(S(2)*b*d*n), Int((d/sin(e + f*x))**(n + S(1))*sqrt(a + b/sin(e + f*x)), x), x) + Simp(a*(d/sin(e + f*x))**n/(f*n*sqrt(a + b/sin(e + f*x))*tan(e + f*x)), x) rule4006 = ReplacementRule(pattern4006, replacement4006) pattern4007 = Pattern(Integral((WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_*sqrt(a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons27, cons48, cons125, cons4, cons1265) def replacement4007(f, b, d, a, n, x, e): rubi.append(4007) return -Dist(a**S(2)*d*tan(e + f*x)/(f*sqrt(a - b/cos(e + f*x))*sqrt(a + b/cos(e + f*x))), Subst(Int((d*x)**(n + S(-1))/sqrt(a - b*x), x), x, S(1)/cos(e + f*x)), x) rule4007 = ReplacementRule(pattern4007, replacement4007) pattern4008 = Pattern(Integral((WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_*sqrt(a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons27, cons48, cons125, cons4, cons1265) def replacement4008(f, b, d, a, n, x, e): rubi.append(4008) return Dist(a**S(2)*d/(f*sqrt(a - b/sin(e + f*x))*sqrt(a + b/sin(e + f*x))*tan(e + f*x)), Subst(Int((d*x)**(n + S(-1))/sqrt(a - b*x), x), x, S(1)/sin(e + f*x)), x) rule4008 = ReplacementRule(pattern4008, replacement4008) pattern4009 = Pattern(Integral(sqrt(WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))/sqrt(a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons27, cons48, cons125, cons1265, cons1330, cons43) def replacement4009(f, b, d, a, x, e): rubi.append(4009) return Dist(sqrt(S(2))*sqrt(a)/(b*f), Subst(Int(S(1)/sqrt(x**S(2) + S(1)), x), x, b*tan(e + f*x)/(a + b/cos(e + f*x))), x) rule4009 = ReplacementRule(pattern4009, replacement4009) pattern4010 = Pattern(Integral(sqrt(WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))/sqrt(a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons27, cons48, cons125, cons1265, cons1330, cons43) def replacement4010(f, b, d, a, x, e): rubi.append(4010) return -Dist(sqrt(S(2))*sqrt(a)/(b*f), Subst(Int(S(1)/sqrt(x**S(2) + S(1)), x), x, b/((a + b/sin(e + f*x))*tan(e + f*x))), x) rule4010 = ReplacementRule(pattern4010, replacement4010) pattern4011 = Pattern(Integral(sqrt(WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))/sqrt(a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons27, cons48, cons125, cons1265) def replacement4011(f, b, d, a, x, e): rubi.append(4011) return Dist(S(2)*b*d/(a*f), Subst(Int(S(1)/(S(2)*b - d*x**S(2)), x), x, b*tan(e + f*x)/(sqrt(d/cos(e + f*x))*sqrt(a + b/cos(e + f*x)))), x) rule4011 = ReplacementRule(pattern4011, replacement4011) pattern4012 = Pattern(Integral(sqrt(WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))/sqrt(a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons27, cons48, cons125, cons1265) def replacement4012(f, b, d, a, x, e): rubi.append(4012) return Dist(-S(2)*b*d/(a*f), Subst(Int(S(1)/(S(2)*b - d*x**S(2)), x), x, b/(sqrt(d/sin(e + f*x))*sqrt(a + b/sin(e + f*x))*tan(e + f*x))), x) rule4012 = ReplacementRule(pattern4012, replacement4012) pattern4013 = Pattern(Integral((WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_, x_), cons2, cons3, cons27, cons48, cons125, cons21, cons4, cons1265, cons1255, cons31, cons1423, cons515) def replacement4013(m, f, b, d, a, n, x, e): rubi.append(4013) return Dist(b*(S(2)*m + S(-1))/(d*m), Int((d/cos(e + f*x))**(n + S(1))*(a + b/cos(e + f*x))**(m + S(-1)), x), x) + Simp(a*(d/cos(e + f*x))**n*(a + b/cos(e + f*x))**(m + S(-1))*tan(e + f*x)/(f*m), x) rule4013 = ReplacementRule(pattern4013, replacement4013) pattern4014 = Pattern(Integral((WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_, x_), cons2, cons3, cons27, cons48, cons125, cons21, cons4, cons1265, cons1255, cons31, cons1423, cons515) def replacement4014(m, f, b, d, a, n, x, e): rubi.append(4014) return Dist(b*(S(2)*m + S(-1))/(d*m), Int((d/sin(e + f*x))**(n + S(1))*(a + b/sin(e + f*x))**(m + S(-1)), x), x) - Simp(a*(d/sin(e + f*x))**n*(a + b/sin(e + f*x))**(m + S(-1))/(f*m*tan(e + f*x)), x) rule4014 = ReplacementRule(pattern4014, replacement4014) pattern4015 = Pattern(Integral((WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_, x_), cons2, cons3, cons27, cons48, cons125, cons21, cons4, cons1265, cons1255, cons31, cons1320, cons515) def replacement4015(m, f, b, d, a, n, x, e): rubi.append(4015) return Dist(d*(m + S(1))/(b*(S(2)*m + S(1))), Int((d/cos(e + f*x))**(n + S(-1))*(a + b/cos(e + f*x))**(m + S(1)), x), x) - Simp(b*d*(d/cos(e + f*x))**(n + S(-1))*(a + b/cos(e + f*x))**m*tan(e + f*x)/(a*f*(S(2)*m + S(1))), x) rule4015 = ReplacementRule(pattern4015, replacement4015) pattern4016 = Pattern(Integral((WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_, x_), cons2, cons3, cons27, cons48, cons125, cons21, cons4, cons1265, cons1255, cons31, cons1320, cons515) def replacement4016(m, f, b, d, a, n, x, e): rubi.append(4016) return Dist(d*(m + S(1))/(b*(S(2)*m + S(1))), Int((d/sin(e + f*x))**(n + S(-1))*(a + b/sin(e + f*x))**(m + S(1)), x), x) + Simp(b*d*(d/sin(e + f*x))**(n + S(-1))*(a + b/sin(e + f*x))**m/(a*f*(S(2)*m + S(1))*tan(e + f*x)), x) rule4016 = ReplacementRule(pattern4016, replacement4016) pattern4017 = Pattern(Integral((WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_, x_), cons2, cons3, cons27, cons48, cons125, cons1265, cons93, cons111, cons1320) def replacement4017(m, f, b, d, a, n, x, e): rubi.append(4017) return Dist(m/(a*(S(2)*m + S(1))), Int((d/cos(e + f*x))**n*(a + b/cos(e + f*x))**(m + S(1)), x), x) + Simp((d/cos(e + f*x))**n*(a + b/cos(e + f*x))**m*tan(e + f*x)/(f*(S(2)*m + S(1))), x) rule4017 = ReplacementRule(pattern4017, replacement4017) pattern4018 = Pattern(Integral((WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_, x_), cons2, cons3, cons27, cons48, cons125, cons1265, cons93, cons111, cons1320) def replacement4018(m, f, b, d, a, n, x, e): rubi.append(4018) return Dist(m/(a*(S(2)*m + S(1))), Int((d/sin(e + f*x))**n*(a + b/sin(e + f*x))**(m + S(1)), x), x) - Simp((d/sin(e + f*x))**n*(a + b/sin(e + f*x))**m/(f*(S(2)*m + S(1))*tan(e + f*x)), x) rule4018 = ReplacementRule(pattern4018, replacement4018) pattern4019 = Pattern(Integral((WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_, x_), cons2, cons3, cons27, cons48, cons125, cons21, cons4, cons1265, cons155, cons1321) def replacement4019(m, f, b, d, a, n, x, e): rubi.append(4019) return Dist(a*m/(b*d*(m + S(1))), Int((d/cos(e + f*x))**(n + S(1))*(a + b/cos(e + f*x))**m, x), x) + Simp((d/cos(e + f*x))**n*(a + b/cos(e + f*x))**m*tan(e + f*x)/(f*(m + S(1))), x) rule4019 = ReplacementRule(pattern4019, replacement4019) pattern4020 = Pattern(Integral((WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_, x_), cons2, cons3, cons27, cons48, cons125, cons21, cons4, cons1265, cons155, cons1321) def replacement4020(m, f, b, d, a, n, x, e): rubi.append(4020) return Dist(a*m/(b*d*(m + S(1))), Int((d/sin(e + f*x))**(n + S(1))*(a + b/sin(e + f*x))**m, x), x) - Simp((d/sin(e + f*x))**n*(a + b/sin(e + f*x))**m/(f*(m + S(1))*tan(e + f*x)), x) rule4020 = ReplacementRule(pattern4020, replacement4020) pattern4021 = Pattern(Integral((WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_, x_), cons2, cons3, cons27, cons48, cons125, cons1265, cons93, cons166, cons1591, cons515) def replacement4021(m, f, b, d, a, n, x, e): rubi.append(4021) return -Dist(a/(d*n), Int((d/cos(e + f*x))**(n + S(1))*(a + b/cos(e + f*x))**(m + S(-2))*(-a*(m + S(2)*n + S(-1))/cos(e + f*x) + b*(m - S(2)*n + S(-2))), x), x) - Simp(b**S(2)*(d/cos(e + f*x))**n*(a + b/cos(e + f*x))**(m + S(-2))*tan(e + f*x)/(f*n), x) rule4021 = ReplacementRule(pattern4021, replacement4021) pattern4022 = Pattern(Integral((WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_, x_), cons2, cons3, cons27, cons48, cons125, cons1265, cons93, cons166, cons1591, cons515) def replacement4022(m, f, b, d, a, n, x, e): rubi.append(4022) return -Dist(a/(d*n), Int((d/sin(e + f*x))**(n + S(1))*(a + b/sin(e + f*x))**(m + S(-2))*(-a*(m + S(2)*n + S(-1))/sin(e + f*x) + b*(m - S(2)*n + S(-2))), x), x) + Simp(b**S(2)*(d/sin(e + f*x))**n*(a + b/sin(e + f*x))**(m + S(-2))/(f*n*tan(e + f*x)), x) rule4022 = ReplacementRule(pattern4022, replacement4022) pattern4023 = Pattern(Integral((WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_, x_), cons2, cons3, cons27, cons48, cons125, cons4, cons1265, cons31, cons166, cons1519, cons515) def replacement4023(m, f, b, d, a, n, x, e): rubi.append(4023) return Dist(b/(m + n + S(-1)), Int((d/cos(e + f*x))**n*(a + b/cos(e + f*x))**(m + S(-2))*(a*(S(3)*m + S(2)*n + S(-4))/cos(e + f*x) + b*(m + S(2)*n + S(-1))), x), x) + Simp(b**S(2)*(d/cos(e + f*x))**n*(a + b/cos(e + f*x))**(m + S(-2))*tan(e + f*x)/(f*(m + n + S(-1))), x) rule4023 = ReplacementRule(pattern4023, replacement4023) pattern4024 = Pattern(Integral((WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_, x_), cons2, cons3, cons27, cons48, cons125, cons4, cons1265, cons31, cons166, cons1519, cons515) def replacement4024(m, f, b, d, a, n, x, e): rubi.append(4024) return Dist(b/(m + n + S(-1)), Int((d/sin(e + f*x))**n*(a + b/sin(e + f*x))**(m + S(-2))*(a*(S(3)*m + S(2)*n + S(-4))/sin(e + f*x) + b*(m + S(2)*n + S(-1))), x), x) - Simp(b**S(2)*(d/sin(e + f*x))**n*(a + b/sin(e + f*x))**(m + S(-2))/(f*(m + n + S(-1))*tan(e + f*x)), x) rule4024 = ReplacementRule(pattern4024, replacement4024) pattern4025 = Pattern(Integral((WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_, x_), cons2, cons3, cons27, cons48, cons125, cons1265, cons93, cons94, cons1336, cons1592) def replacement4025(m, f, b, d, a, n, x, e): rubi.append(4025) return -Dist(d/(a*b*(S(2)*m + S(1))), Int((d/cos(e + f*x))**(n + S(-1))*(a + b/cos(e + f*x))**(m + S(1))*(a*(n + S(-1)) - b*(m + n)/cos(e + f*x)), x), x) - Simp(b*d*(d/cos(e + f*x))**(n + S(-1))*(a + b/cos(e + f*x))**m*tan(e + f*x)/(a*f*(S(2)*m + S(1))), x) rule4025 = ReplacementRule(pattern4025, replacement4025) pattern4026 = Pattern(Integral((WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_, x_), cons2, cons3, cons27, cons48, cons125, cons1265, cons93, cons94, cons1336, cons1592) def replacement4026(m, f, b, d, a, n, x, e): rubi.append(4026) return -Dist(d/(a*b*(S(2)*m + S(1))), Int((d/sin(e + f*x))**(n + S(-1))*(a + b/sin(e + f*x))**(m + S(1))*(a*(n + S(-1)) - b*(m + n)/sin(e + f*x)), x), x) + Simp(b*d*(d/sin(e + f*x))**(n + S(-1))*(a + b/sin(e + f*x))**m/(a*f*(S(2)*m + S(1))*tan(e + f*x)), x) rule4026 = ReplacementRule(pattern4026, replacement4026) pattern4027 = Pattern(Integral((WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_, x_), cons2, cons3, cons27, cons48, cons125, cons1265, cons93, cons94, cons744, cons1592) def replacement4027(m, f, b, d, a, n, x, e): rubi.append(4027) return Dist(d**S(2)/(a*b*(S(2)*m + S(1))), Int((d/cos(e + f*x))**(n + S(-2))*(a + b/cos(e + f*x))**(m + S(1))*(a*(m - n + S(2))/cos(e + f*x) + b*(n + S(-2))), x), x) + Simp(d**S(2)*(d/cos(e + f*x))**(n + S(-2))*(a + b/cos(e + f*x))**m*tan(e + f*x)/(f*(S(2)*m + S(1))), x) rule4027 = ReplacementRule(pattern4027, replacement4027) pattern4028 = Pattern(Integral((WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_, x_), cons2, cons3, cons27, cons48, cons125, cons1265, cons93, cons94, cons744, cons1592) def replacement4028(m, f, b, d, a, n, x, e): rubi.append(4028) return Dist(d**S(2)/(a*b*(S(2)*m + S(1))), Int((d/sin(e + f*x))**(n + S(-2))*(a + b/sin(e + f*x))**(m + S(1))*(a*(m - n + S(2))/sin(e + f*x) + b*(n + S(-2))), x), x) - Simp(d**S(2)*(d/sin(e + f*x))**(n + S(-2))*(a + b/sin(e + f*x))**m/(f*(S(2)*m + S(1))*tan(e + f*x)), x) rule4028 = ReplacementRule(pattern4028, replacement4028) pattern4029 = Pattern(Integral((WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_, x_), cons2, cons3, cons27, cons48, cons125, cons4, cons1265, cons31, cons94, cons1592) def replacement4029(m, f, b, d, a, n, x, e): rubi.append(4029) return Dist(S(1)/(a**S(2)*(S(2)*m + S(1))), Int((d/cos(e + f*x))**n*(a + b/cos(e + f*x))**(m + S(1))*(a*(S(2)*m + n + S(1)) - b*(m + n + S(1))/cos(e + f*x)), x), x) + Simp((d/cos(e + f*x))**n*(a + b/cos(e + f*x))**m*tan(e + f*x)/(f*(S(2)*m + S(1))), x) rule4029 = ReplacementRule(pattern4029, replacement4029) pattern4030 = Pattern(Integral((WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_, x_), cons2, cons3, cons27, cons48, cons125, cons4, cons1265, cons31, cons94, cons1592) def replacement4030(m, f, b, d, a, n, x, e): rubi.append(4030) return Dist(S(1)/(a**S(2)*(S(2)*m + S(1))), Int((d/sin(e + f*x))**n*(a + b/sin(e + f*x))**(m + S(1))*(a*(S(2)*m + n + S(1)) - b*(m + n + S(1))/sin(e + f*x)), x), x) - Simp((d/sin(e + f*x))**n*(a + b/sin(e + f*x))**m/(f*(S(2)*m + S(1))*tan(e + f*x)), x) rule4030 = ReplacementRule(pattern4030, replacement4030) pattern4031 = Pattern(Integral((WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_/(a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons27, cons48, cons125, cons1265, cons87, cons165) def replacement4031(f, b, d, a, n, x, e): rubi.append(4031) return -Dist(d**S(2)/(a*b), Int((d/cos(e + f*x))**(n + S(-2))*(-a*(n + S(-1))/cos(e + f*x) + b*(n + S(-2))), x), x) - Simp(d**S(2)*(d/cos(e + f*x))**(n + S(-2))*tan(e + f*x)/(f*(a + b/cos(e + f*x))), x) rule4031 = ReplacementRule(pattern4031, replacement4031) pattern4032 = Pattern(Integral((WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_/(a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons27, cons48, cons125, cons1265, cons87, cons165) def replacement4032(f, b, d, a, n, x, e): rubi.append(4032) return -Dist(d**S(2)/(a*b), Int((d/sin(e + f*x))**(n + S(-2))*(-a*(n + S(-1))/sin(e + f*x) + b*(n + S(-2))), x), x) + Simp(d**S(2)*(d/sin(e + f*x))**(n + S(-2))/(f*(a + b/sin(e + f*x))*tan(e + f*x)), x) rule4032 = ReplacementRule(pattern4032, replacement4032) pattern4033 = Pattern(Integral((WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_/(a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons27, cons48, cons125, cons1265, cons87, cons463) def replacement4033(f, b, d, a, n, x, e): rubi.append(4033) return -Dist(a**(S(-2)), Int((d/cos(e + f*x))**n*(a*(n + S(-1)) - b*n/cos(e + f*x)), x), x) - Simp((d/cos(e + f*x))**n*tan(e + f*x)/(f*(a + b/cos(e + f*x))), x) rule4033 = ReplacementRule(pattern4033, replacement4033) pattern4034 = Pattern(Integral((WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_/(a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons27, cons48, cons125, cons1265, cons87, cons463) def replacement4034(f, b, d, a, n, x, e): rubi.append(4034) return -Dist(a**(S(-2)), Int((d/sin(e + f*x))**n*(a*(n + S(-1)) - b*n/sin(e + f*x)), x), x) + Simp((d/sin(e + f*x))**n/(f*(a + b/sin(e + f*x))*tan(e + f*x)), x) rule4034 = ReplacementRule(pattern4034, replacement4034) pattern4035 = Pattern(Integral((WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_/(a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons27, cons48, cons125, cons4, cons1265) def replacement4035(f, b, d, a, n, x, e): rubi.append(4035) return Dist(d*(n + S(-1))/(a*b), Int((d/cos(e + f*x))**(n + S(-1))*(a - b/cos(e + f*x)), x), x) + Simp(b*d*(d/cos(e + f*x))**(n + S(-1))*tan(e + f*x)/(a*f*(a + b/cos(e + f*x))), x) rule4035 = ReplacementRule(pattern4035, replacement4035) pattern4036 = Pattern(Integral((WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_/(a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons27, cons48, cons125, cons4, cons1265) def replacement4036(f, b, d, a, n, x, e): rubi.append(4036) return Dist(d*(n + S(-1))/(a*b), Int((d/sin(e + f*x))**(n + S(-1))*(a - b/sin(e + f*x)), x), x) - Simp(b*d*(d/sin(e + f*x))**(n + S(-1))/(a*f*(a + b/sin(e + f*x))*tan(e + f*x)), x) rule4036 = ReplacementRule(pattern4036, replacement4036) pattern4037 = Pattern(Integral((WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**(S(3)/2)/sqrt(a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons27, cons48, cons125, cons1265) def replacement4037(f, b, d, a, x, e): rubi.append(4037) return Dist(d/b, Int(sqrt(d/cos(e + f*x))*sqrt(a + b/cos(e + f*x)), x), x) - Dist(a*d/b, Int(sqrt(d/cos(e + f*x))/sqrt(a + b/cos(e + f*x)), x), x) rule4037 = ReplacementRule(pattern4037, replacement4037) pattern4038 = Pattern(Integral((WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**(S(3)/2)/sqrt(a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons27, cons48, cons125, cons1265) def replacement4038(f, b, d, a, x, e): rubi.append(4038) return Dist(d/b, Int(sqrt(d/sin(e + f*x))*sqrt(a + b/sin(e + f*x)), x), x) - Dist(a*d/b, Int(sqrt(d/sin(e + f*x))/sqrt(a + b/sin(e + f*x)), x), x) rule4038 = ReplacementRule(pattern4038, replacement4038) pattern4039 = Pattern(Integral((WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_/sqrt(a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons27, cons48, cons125, cons1265, cons87, cons744, cons808) def replacement4039(f, b, d, a, n, x, e): rubi.append(4039) return Dist(d**S(2)/(b*(S(2)*n + S(-3))), Int((d/cos(e + f*x))**(n + S(-2))*(-a/cos(e + f*x) + S(2)*b*(n + S(-2)))/sqrt(a + b/cos(e + f*x)), x), x) + Simp(S(2)*d**S(2)*(d/cos(e + f*x))**(n + S(-2))*tan(e + f*x)/(f*sqrt(a + b/cos(e + f*x))*(S(2)*n + S(-3))), x) rule4039 = ReplacementRule(pattern4039, replacement4039) pattern4040 = Pattern(Integral((WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_/sqrt(a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons27, cons48, cons125, cons1265, cons87, cons744, cons808) def replacement4040(f, b, d, a, n, x, e): rubi.append(4040) return Dist(d**S(2)/(b*(S(2)*n + S(-3))), Int((d/sin(e + f*x))**(n + S(-2))*(-a/sin(e + f*x) + S(2)*b*(n + S(-2)))/sqrt(a + b/sin(e + f*x)), x), x) + Simp(-S(2)*d**S(2)*(d/sin(e + f*x))**(n + S(-2))/(f*sqrt(a + b/sin(e + f*x))*(S(2)*n + S(-3))*tan(e + f*x)), x) rule4040 = ReplacementRule(pattern4040, replacement4040) pattern4041 = Pattern(Integral((WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_/sqrt(a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons27, cons48, cons125, cons1265, cons87, cons463, cons808) def replacement4041(f, b, d, a, n, x, e): rubi.append(4041) return Dist(S(1)/(S(2)*b*d*n), Int((d/cos(e + f*x))**(n + S(1))*(a + b*(S(2)*n + S(1))/cos(e + f*x))/sqrt(a + b/cos(e + f*x)), x), x) - Simp((d/cos(e + f*x))**n*tan(e + f*x)/(f*n*sqrt(a + b/cos(e + f*x))), x) rule4041 = ReplacementRule(pattern4041, replacement4041) pattern4042 = Pattern(Integral((WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_/sqrt(a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons27, cons48, cons125, cons1265, cons87, cons463, cons808) def replacement4042(f, b, d, a, n, x, e): rubi.append(4042) return Dist(S(1)/(S(2)*b*d*n), Int((d/sin(e + f*x))**(n + S(1))*(a + b*(S(2)*n + S(1))/sin(e + f*x))/sqrt(a + b/sin(e + f*x)), x), x) + Simp((d/sin(e + f*x))**n/(f*n*sqrt(a + b/sin(e + f*x))*tan(e + f*x)), x) rule4042 = ReplacementRule(pattern4042, replacement4042) pattern4043 = Pattern(Integral((WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_, x_), cons2, cons3, cons27, cons48, cons125, cons21, cons1265, cons87, cons744, cons1519, cons85) def replacement4043(m, f, b, d, a, n, x, e): rubi.append(4043) return Dist(d**S(2)/(b*(m + n + S(-1))), Int((d/cos(e + f*x))**(n + S(-2))*(a + b/cos(e + f*x))**m*(a*m/cos(e + f*x) + b*(n + S(-2))), x), x) + Simp(d**S(2)*(d/cos(e + f*x))**(n + S(-2))*(a + b/cos(e + f*x))**m*tan(e + f*x)/(f*(m + n + S(-1))), x) rule4043 = ReplacementRule(pattern4043, replacement4043) pattern4044 = Pattern(Integral((WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_, x_), cons2, cons3, cons27, cons48, cons125, cons21, cons1265, cons87, cons744, cons1519, cons85) def replacement4044(m, f, b, d, a, n, x, e): rubi.append(4044) return Dist(d**S(2)/(b*(m + n + S(-1))), Int((d/sin(e + f*x))**(n + S(-2))*(a + b/sin(e + f*x))**m*(a*m/sin(e + f*x) + b*(n + S(-2))), x), x) - Simp(d**S(2)*(d/sin(e + f*x))**(n + S(-2))*(a + b/sin(e + f*x))**m/(f*(m + n + S(-1))*tan(e + f*x)), x) rule4044 = ReplacementRule(pattern4044, replacement4044) pattern4045 = Pattern(Integral((WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_, x_), cons2, cons3, cons27, cons48, cons125, cons21, cons4, cons1265, cons18, cons43, cons23, cons1588) def replacement4045(m, f, b, d, a, n, x, e): rubi.append(4045) return Dist(a**(-n + S(2))*(a*d/b)**n*tan(e + f*x)/(f*sqrt(a - b/cos(e + f*x))*sqrt(a + b/cos(e + f*x))), Subst(Int((a - x)**(n + S(-1))*(S(2)*a - x)**(m + S(-1)/2)/sqrt(x), x), x, a - b/cos(e + f*x)), x) rule4045 = ReplacementRule(pattern4045, replacement4045) pattern4046 = Pattern(Integral((WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_, x_), cons2, cons3, cons27, cons48, cons125, cons21, cons4, cons1265, cons18, cons43, cons23, cons1588) def replacement4046(m, f, b, d, a, n, x, e): rubi.append(4046) return -Dist(a**(-n + S(2))*(a*d/b)**n/(f*sqrt(a - b/sin(e + f*x))*sqrt(a + b/sin(e + f*x))*tan(e + f*x)), Subst(Int((a - x)**(n + S(-1))*(S(2)*a - x)**(m + S(-1)/2)/sqrt(x), x), x, a - b/sin(e + f*x)), x) rule4046 = ReplacementRule(pattern4046, replacement4046) pattern4047 = Pattern(Integral((WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_, x_), cons2, cons3, cons27, cons48, cons125, cons21, cons4, cons1265, cons18, cons43, cons23, cons1593) def replacement4047(m, f, b, d, a, n, x, e): rubi.append(4047) return Dist(a**(-n + S(1))*(-a*d/b)**n*tan(e + f*x)/(f*sqrt(a - b/cos(e + f*x))*sqrt(a + b/cos(e + f*x))), Subst(Int(x**(m + S(-1)/2)*(a - x)**(n + S(-1))/sqrt(S(2)*a - x), x), x, a + b/cos(e + f*x)), x) rule4047 = ReplacementRule(pattern4047, replacement4047) pattern4048 = Pattern(Integral((WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_, x_), cons2, cons3, cons27, cons48, cons125, cons21, cons4, cons1265, cons18, cons43, cons23, cons1593) def replacement4048(m, f, b, d, a, n, x, e): rubi.append(4048) return -Dist(a**(-n + S(1))*(-a*d/b)**n/(f*sqrt(a - b/sin(e + f*x))*sqrt(a + b/sin(e + f*x))*tan(e + f*x)), Subst(Int(x**(m + S(-1)/2)*(a - x)**(n + S(-1))/sqrt(S(2)*a - x), x), x, a + b/sin(e + f*x)), x) rule4048 = ReplacementRule(pattern4048, replacement4048) pattern4049 = Pattern(Integral((WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1))*(a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_, x_), cons2, cons3, cons27, cons48, cons125, cons21, cons4, cons1265, cons18, cons43) def replacement4049(m, f, b, d, a, n, x, e): rubi.append(4049) return -Dist(a**S(2)*d*tan(e + f*x)/(f*sqrt(a - b/cos(e + f*x))*sqrt(a + b/cos(e + f*x))), Subst(Int((d*x)**(n + S(-1))*(a + b*x)**(m + S(-1)/2)/sqrt(a - b*x), x), x, S(1)/cos(e + f*x)), x) rule4049 = ReplacementRule(pattern4049, replacement4049) pattern4050 = Pattern(Integral((WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1))*(a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_, x_), cons2, cons3, cons27, cons48, cons125, cons21, cons4, cons1265, cons18, cons43) def replacement4050(m, f, b, d, a, n, x, e): rubi.append(4050) return Dist(a**S(2)*d/(f*sqrt(a - b/sin(e + f*x))*sqrt(a + b/sin(e + f*x))*tan(e + f*x)), Subst(Int((d*x)**(n + S(-1))*(a + b*x)**(m + S(-1)/2)/sqrt(a - b*x), x), x, S(1)/sin(e + f*x)), x) rule4050 = ReplacementRule(pattern4050, replacement4050) pattern4051 = Pattern(Integral((WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1))*(a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_, x_), cons2, cons3, cons27, cons48, cons125, cons21, cons4, cons1265, cons18, cons448) def replacement4051(m, f, b, d, a, n, x, e): rubi.append(4051) return Dist(a**IntPart(m)*(S(1) + b/(a*cos(e + f*x)))**(-FracPart(m))*(a + b/cos(e + f*x))**FracPart(m), Int((d/cos(e + f*x))**n*(S(1) + b/(a*cos(e + f*x)))**m, x), x) rule4051 = ReplacementRule(pattern4051, replacement4051) pattern4052 = Pattern(Integral((WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1))*(a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_, x_), cons2, cons3, cons27, cons48, cons125, cons21, cons4, cons1265, cons18, cons448) def replacement4052(m, f, b, d, a, n, x, e): rubi.append(4052) return Dist(a**IntPart(m)*(S(1) + b/(a*sin(e + f*x)))**(-FracPart(m))*(a + b/sin(e + f*x))**FracPart(m), Int((d/sin(e + f*x))**n*(S(1) + b/(a*sin(e + f*x)))**m, x), x) rule4052 = ReplacementRule(pattern4052, replacement4052) pattern4053 = Pattern(Integral(sqrt(a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))/cos(x_*WC('f', S(1)) + WC('e', S(0))), x_), cons2, cons3, cons48, cons125, cons1267) def replacement4053(f, b, a, x, e): rubi.append(4053) return Dist(b, Int((S(1) + S(1)/cos(e + f*x))/(sqrt(a + b/cos(e + f*x))*cos(e + f*x)), x), x) + Dist(a - b, Int(S(1)/(sqrt(a + b/cos(e + f*x))*cos(e + f*x)), x), x) rule4053 = ReplacementRule(pattern4053, replacement4053) pattern4054 = Pattern(Integral(sqrt(a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))/sin(x_*WC('f', S(1)) + WC('e', S(0))), x_), cons2, cons3, cons48, cons125, cons1267) def replacement4054(f, b, a, x, e): rubi.append(4054) return Dist(b, Int((S(1) + S(1)/sin(e + f*x))/(sqrt(a + b/sin(e + f*x))*sin(e + f*x)), x), x) + Dist(a - b, Int(S(1)/(sqrt(a + b/sin(e + f*x))*sin(e + f*x)), x), x) rule4054 = ReplacementRule(pattern4054, replacement4054) pattern4055 = Pattern(Integral((a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_/cos(x_*WC('f', S(1)) + WC('e', S(0))), x_), cons2, cons3, cons48, cons125, cons1267, cons31, cons166, cons515) def replacement4055(m, f, b, a, x, e): rubi.append(4055) return Dist(S(1)/m, Int((a + b/cos(e + f*x))**(m + S(-2))*(a**S(2)*m + a*b*(S(2)*m + S(-1))/cos(e + f*x) + b**S(2)*(m + S(-1)))/cos(e + f*x), x), x) + Simp(b*(a + b/cos(e + f*x))**(m + S(-1))*tan(e + f*x)/(f*m), x) rule4055 = ReplacementRule(pattern4055, replacement4055) pattern4056 = Pattern(Integral((a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_/sin(x_*WC('f', S(1)) + WC('e', S(0))), x_), cons2, cons3, cons48, cons125, cons1267, cons31, cons166, cons515) def replacement4056(m, f, b, a, x, e): rubi.append(4056) return Dist(S(1)/m, Int((a + b/sin(e + f*x))**(m + S(-2))*(a**S(2)*m + a*b*(S(2)*m + S(-1))/sin(e + f*x) + b**S(2)*(m + S(-1)))/sin(e + f*x), x), x) - Simp(b*(a + b/sin(e + f*x))**(m + S(-1))/(f*m*tan(e + f*x)), x) rule4056 = ReplacementRule(pattern4056, replacement4056) pattern4057 = Pattern(Integral(S(1)/((a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))*cos(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons48, cons125, cons1267) def replacement4057(f, b, a, x, e): rubi.append(4057) return Dist(S(1)/b, Int(S(1)/(a*cos(e + f*x)/b + S(1)), x), x) rule4057 = ReplacementRule(pattern4057, replacement4057) pattern4058 = Pattern(Integral(S(1)/((a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))*sin(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons48, cons125, cons1267) def replacement4058(f, b, a, x, e): rubi.append(4058) return Dist(S(1)/b, Int(S(1)/(a*sin(e + f*x)/b + S(1)), x), x) rule4058 = ReplacementRule(pattern4058, replacement4058) pattern4059 = Pattern(Integral(S(1)/(sqrt(a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))*cos(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons48, cons125, cons1267) def replacement4059(f, b, a, x, e): rubi.append(4059) return Simp(S(2)*sqrt(b*(S(1) - S(1)/cos(e + f*x))/(a + b))*sqrt(-b*(S(1) + S(1)/cos(e + f*x))/(a - b))*EllipticF(asin(sqrt(a + b/cos(e + f*x))/Rt(a + b, S(2))), (a + b)/(a - b))*Rt(a + b, S(2))/(b*f*tan(e + f*x)), x) rule4059 = ReplacementRule(pattern4059, replacement4059) pattern4060 = Pattern(Integral(S(1)/(sqrt(a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))*sin(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons48, cons125, cons1267) def replacement4060(f, b, a, x, e): rubi.append(4060) return Simp(-S(2)*sqrt(b*(S(1) - S(1)/sin(e + f*x))/(a + b))*sqrt(-b*(S(1) + S(1)/sin(e + f*x))/(a - b))*EllipticF(asin(sqrt(a + b/sin(e + f*x))/Rt(a + b, S(2))), (a + b)/(a - b))*Rt(a + b, S(2))*tan(e + f*x)/(b*f), x) rule4060 = ReplacementRule(pattern4060, replacement4060) pattern4061 = Pattern(Integral((a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_/cos(x_*WC('f', S(1)) + WC('e', S(0))), x_), cons2, cons3, cons48, cons125, cons1267, cons31, cons94, cons515) def replacement4061(m, f, b, a, x, e): rubi.append(4061) return Dist(S(1)/((a**S(2) - b**S(2))*(m + S(1))), Int((a + b/cos(e + f*x))**(m + S(1))*(a*(m + S(1)) - b*(m + S(2))/cos(e + f*x))/cos(e + f*x), x), x) + Simp(b*(a + b/cos(e + f*x))**(m + S(1))*tan(e + f*x)/(f*(a**S(2) - b**S(2))*(m + S(1))), x) rule4061 = ReplacementRule(pattern4061, replacement4061) pattern4062 = Pattern(Integral((a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_/sin(x_*WC('f', S(1)) + WC('e', S(0))), x_), cons2, cons3, cons48, cons125, cons1267, cons31, cons94, cons515) def replacement4062(m, f, b, a, x, e): rubi.append(4062) return Dist(S(1)/((a**S(2) - b**S(2))*(m + S(1))), Int((a + b/sin(e + f*x))**(m + S(1))*(a*(m + S(1)) - b*(m + S(2))/sin(e + f*x))/sin(e + f*x), x), x) - Simp(b*(a + b/sin(e + f*x))**(m + S(1))/(f*(a**S(2) - b**S(2))*(m + S(1))*tan(e + f*x)), x) rule4062 = ReplacementRule(pattern4062, replacement4062) pattern4063 = Pattern(Integral((a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_/cos(x_*WC('f', S(1)) + WC('e', S(0))), x_), cons2, cons3, cons48, cons125, cons21, cons1267, cons77) def replacement4063(m, f, b, a, x, e): rubi.append(4063) return -Dist(tan(e + f*x)/(f*sqrt(S(1) - S(1)/cos(e + f*x))*sqrt(S(1) + S(1)/cos(e + f*x))), Subst(Int((a + b*x)**m/(sqrt(-x + S(1))*sqrt(x + S(1))), x), x, S(1)/cos(e + f*x)), x) rule4063 = ReplacementRule(pattern4063, replacement4063) pattern4064 = Pattern(Integral((a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_/sin(x_*WC('f', S(1)) + WC('e', S(0))), x_), cons2, cons3, cons48, cons125, cons21, cons1267, cons77) def replacement4064(m, f, b, a, x, e): rubi.append(4064) return Dist(S(1)/(f*sqrt(S(1) - S(1)/sin(e + f*x))*sqrt(S(1) + S(1)/sin(e + f*x))*tan(e + f*x)), Subst(Int((a + b*x)**m/(sqrt(-x + S(1))*sqrt(x + S(1))), x), x, S(1)/sin(e + f*x)), x) rule4064 = ReplacementRule(pattern4064, replacement4064) pattern4065 = Pattern(Integral((a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_/cos(x_*WC('f', S(1)) + WC('e', S(0)))**S(2), x_), cons2, cons3, cons48, cons125, cons1267, cons31, cons168) def replacement4065(m, f, b, a, x, e): rubi.append(4065) return Dist(m/(m + S(1)), Int((a + b/cos(e + f*x))**(m + S(-1))*(a/cos(e + f*x) + b)/cos(e + f*x), x), x) + Simp((a + b/cos(e + f*x))**m*tan(e + f*x)/(f*(m + S(1))), x) rule4065 = ReplacementRule(pattern4065, replacement4065) pattern4066 = Pattern(Integral((a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_/sin(x_*WC('f', S(1)) + WC('e', S(0)))**S(2), x_), cons2, cons3, cons48, cons125, cons1267, cons31, cons168) def replacement4066(m, f, b, a, x, e): rubi.append(4066) return Dist(m/(m + S(1)), Int((a + b/sin(e + f*x))**(m + S(-1))*(a/sin(e + f*x) + b)/sin(e + f*x), x), x) - Simp((a + b/sin(e + f*x))**m/(f*(m + S(1))*tan(e + f*x)), x) rule4066 = ReplacementRule(pattern4066, replacement4066) pattern4067 = Pattern(Integral((a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_/cos(x_*WC('f', S(1)) + WC('e', S(0)))**S(2), x_), cons2, cons3, cons48, cons125, cons1267, cons31, cons94) def replacement4067(m, f, b, a, x, e): rubi.append(4067) return -Dist(S(1)/((a**S(2) - b**S(2))*(m + S(1))), Int((a + b/cos(e + f*x))**(m + S(1))*(-a*(m + S(2))/cos(e + f*x) + b*(m + S(1)))/cos(e + f*x), x), x) - Simp(a*(a + b/cos(e + f*x))**(m + S(1))*tan(e + f*x)/(f*(a**S(2) - b**S(2))*(m + S(1))), x) rule4067 = ReplacementRule(pattern4067, replacement4067) pattern4068 = Pattern(Integral((a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_/sin(x_*WC('f', S(1)) + WC('e', S(0)))**S(2), x_), cons2, cons3, cons48, cons125, cons1267, cons31, cons94) def replacement4068(m, f, b, a, x, e): rubi.append(4068) return -Dist(S(1)/((a**S(2) - b**S(2))*(m + S(1))), Int((a + b/sin(e + f*x))**(m + S(1))*(-a*(m + S(2))/sin(e + f*x) + b*(m + S(1)))/sin(e + f*x), x), x) + Simp(a*(a + b/sin(e + f*x))**(m + S(1))/(f*(a**S(2) - b**S(2))*(m + S(1))*tan(e + f*x)), x) rule4068 = ReplacementRule(pattern4068, replacement4068) pattern4069 = Pattern(Integral(S(1)/(sqrt(a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))*cos(x_*WC('f', S(1)) + WC('e', S(0)))**S(2)), x_), cons2, cons3, cons48, cons125, cons1267) def replacement4069(f, b, a, x, e): rubi.append(4069) return -Int(S(1)/(sqrt(a + b/cos(e + f*x))*cos(e + f*x)), x) + Int((S(1) + S(1)/cos(e + f*x))/(sqrt(a + b/cos(e + f*x))*cos(e + f*x)), x) rule4069 = ReplacementRule(pattern4069, replacement4069) pattern4070 = Pattern(Integral(S(1)/(sqrt(a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))*sin(x_*WC('f', S(1)) + WC('e', S(0)))**S(2)), x_), cons2, cons3, cons48, cons125, cons1267) def replacement4070(f, b, a, x, e): rubi.append(4070) return -Int(S(1)/(sqrt(a + b/sin(e + f*x))*sin(e + f*x)), x) + Int((S(1) + S(1)/sin(e + f*x))/(sqrt(a + b/sin(e + f*x))*sin(e + f*x)), x) rule4070 = ReplacementRule(pattern4070, replacement4070) pattern4071 = Pattern(Integral((a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_/cos(x_*WC('f', S(1)) + WC('e', S(0)))**S(2), x_), cons2, cons3, cons48, cons125, cons21, cons1267) def replacement4071(m, f, b, a, x, e): rubi.append(4071) return Dist(S(1)/b, Int((a + b/cos(e + f*x))**(m + S(1))/cos(e + f*x), x), x) - Dist(a/b, Int((a + b/cos(e + f*x))**m/cos(e + f*x), x), x) rule4071 = ReplacementRule(pattern4071, replacement4071) pattern4072 = Pattern(Integral((a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_/sin(x_*WC('f', S(1)) + WC('e', S(0)))**S(2), x_), cons2, cons3, cons48, cons125, cons21, cons1267) def replacement4072(m, f, b, a, x, e): rubi.append(4072) return Dist(S(1)/b, Int((a + b/sin(e + f*x))**(m + S(1))/sin(e + f*x), x), x) - Dist(a/b, Int((a + b/sin(e + f*x))**m/sin(e + f*x), x), x) rule4072 = ReplacementRule(pattern4072, replacement4072) pattern4073 = Pattern(Integral((a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_/cos(x_*WC('f', S(1)) + WC('e', S(0)))**S(3), x_), cons2, cons3, cons48, cons125, cons1267, cons31, cons94) def replacement4073(m, f, b, a, x, e): rubi.append(4073) return Dist(S(1)/(b*(a**S(2) - b**S(2))*(m + S(1))), Int((a + b/cos(e + f*x))**(m + S(1))*Simp(a*b*(m + S(1)) - (a**S(2) + b**S(2)*(m + S(1)))/cos(e + f*x), x)/cos(e + f*x), x), x) + Simp(a**S(2)*(a + b/cos(e + f*x))**(m + S(1))*tan(e + f*x)/(b*f*(a**S(2) - b**S(2))*(m + S(1))), x) rule4073 = ReplacementRule(pattern4073, replacement4073) pattern4074 = Pattern(Integral((a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_/sin(x_*WC('f', S(1)) + WC('e', S(0)))**S(3), x_), cons2, cons3, cons48, cons125, cons1267, cons31, cons94) def replacement4074(m, f, b, a, x, e): rubi.append(4074) return Dist(S(1)/(b*(a**S(2) - b**S(2))*(m + S(1))), Int((a + b/sin(e + f*x))**(m + S(1))*Simp(a*b*(m + S(1)) - (a**S(2) + b**S(2)*(m + S(1)))/sin(e + f*x), x)/sin(e + f*x), x), x) - Simp(a**S(2)*(a + b/sin(e + f*x))**(m + S(1))/(b*f*(a**S(2) - b**S(2))*(m + S(1))*tan(e + f*x)), x) rule4074 = ReplacementRule(pattern4074, replacement4074) pattern4075 = Pattern(Integral((a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_/cos(x_*WC('f', S(1)) + WC('e', S(0)))**S(3), x_), cons2, cons3, cons48, cons125, cons21, cons1267, cons272) def replacement4075(m, f, b, a, x, e): rubi.append(4075) return Dist(S(1)/(b*(m + S(2))), Int((a + b/cos(e + f*x))**m*(-a/cos(e + f*x) + b*(m + S(1)))/cos(e + f*x), x), x) + Simp((a + b/cos(e + f*x))**(m + S(1))*tan(e + f*x)/(b*f*(m + S(2))), x) rule4075 = ReplacementRule(pattern4075, replacement4075) pattern4076 = Pattern(Integral((a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_/sin(x_*WC('f', S(1)) + WC('e', S(0)))**S(3), x_), cons2, cons3, cons48, cons125, cons21, cons1267, cons272) def replacement4076(m, f, b, a, x, e): rubi.append(4076) return Dist(S(1)/(b*(m + S(2))), Int((a + b/sin(e + f*x))**m*(-a/sin(e + f*x) + b*(m + S(1)))/sin(e + f*x), x), x) - Simp((a + b/sin(e + f*x))**(m + S(1))/(b*f*(m + S(2))*tan(e + f*x)), x) rule4076 = ReplacementRule(pattern4076, replacement4076) pattern4077 = Pattern(Integral((WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_, x_), cons2, cons3, cons27, cons48, cons125, cons1267, cons93, cons1333, cons1594) def replacement4077(m, f, b, d, a, n, x, e): rubi.append(4077) return -Dist(S(1)/(d*n), Int((d/cos(e + f*x))**(n + S(1))*(a + b/cos(e + f*x))**(m + S(-3))*Simp(a**S(2)*b*(m - S(2)*n + S(-2)) - a*(a**S(2)*(n + S(1)) + S(3)*b**S(2)*n)/cos(e + f*x) - b*(a**S(2)*(m + n + S(-1)) + b**S(2)*n)/cos(e + f*x)**S(2), x), x), x) - Simp(a**S(2)*(d/cos(e + f*x))**n*(a + b/cos(e + f*x))**(m + S(-2))*tan(e + f*x)/(f*n), x) rule4077 = ReplacementRule(pattern4077, replacement4077) pattern4078 = Pattern(Integral((WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_, x_), cons2, cons3, cons27, cons48, cons125, cons1267, cons93, cons1333, cons1594) def replacement4078(m, f, b, d, a, n, x, e): rubi.append(4078) return -Dist(S(1)/(d*n), Int((d/sin(e + f*x))**(n + S(1))*(a + b/sin(e + f*x))**(m + S(-3))*Simp(a**S(2)*b*(m - S(2)*n + S(-2)) - a*(a**S(2)*(n + S(1)) + S(3)*b**S(2)*n)/sin(e + f*x) - b*(a**S(2)*(m + n + S(-1)) + b**S(2)*n)/sin(e + f*x)**S(2), x), x), x) + Simp(a**S(2)*(d/sin(e + f*x))**n*(a + b/sin(e + f*x))**(m + S(-2))/(f*n*tan(e + f*x)), x) rule4078 = ReplacementRule(pattern4078, replacement4078) pattern4079 = Pattern(Integral((WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_, x_), cons2, cons3, cons27, cons48, cons125, cons4, cons1267, cons31, cons1333, cons1334, cons1595) def replacement4079(m, f, b, d, a, n, x, e): rubi.append(4079) return Dist(S(1)/(d*(m + n + S(-1))), Int((d/cos(e + f*x))**n*(a + b/cos(e + f*x))**(m + S(-3))*Simp(a**S(3)*d*(m + n + S(-1)) + a*b**S(2)*d*n + a*b**S(2)*d*(S(3)*m + S(2)*n + S(-4))/cos(e + f*x)**S(2) + b*(S(3)*a**S(2)*d*(m + n + S(-1)) + b**S(2)*d*(m + n + S(-2)))/cos(e + f*x), x), x), x) + Simp(b**S(2)*(d/cos(e + f*x))**n*(a + b/cos(e + f*x))**(m + S(-2))*tan(e + f*x)/(f*(m + n + S(-1))), x) rule4079 = ReplacementRule(pattern4079, replacement4079) pattern4080 = Pattern(Integral((WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_, x_), cons2, cons3, cons27, cons48, cons125, cons4, cons1267, cons31, cons1333, cons1334, cons1595) def replacement4080(m, f, b, d, a, n, x, e): rubi.append(4080) return Dist(S(1)/(d*(m + n + S(-1))), Int((d/sin(e + f*x))**n*(a + b/sin(e + f*x))**(m + S(-3))*Simp(a**S(3)*d*(m + n + S(-1)) + a*b**S(2)*d*n + a*b**S(2)*d*(S(3)*m + S(2)*n + S(-4))/sin(e + f*x)**S(2) + b*(S(3)*a**S(2)*d*(m + n + S(-1)) + b**S(2)*d*(m + n + S(-2)))/sin(e + f*x), x), x), x) - Simp(b**S(2)*(d/sin(e + f*x))**n*(a + b/sin(e + f*x))**(m + S(-2))/(f*(m + n + S(-1))*tan(e + f*x)), x) rule4080 = ReplacementRule(pattern4080, replacement4080) pattern4081 = Pattern(Integral((WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_, x_), cons2, cons3, cons27, cons48, cons125, cons1267, cons93, cons94, cons1325, cons1170) def replacement4081(m, f, b, d, a, n, x, e): rubi.append(4081) return Dist(S(1)/((a**S(2) - b**S(2))*(m + S(1))), Int((d/cos(e + f*x))**(n + S(-1))*(a + b/cos(e + f*x))**(m + S(1))*Simp(a*d*(m + S(1))/cos(e + f*x) + b*d*(n + S(-1)) - b*d*(m + n + S(1))/cos(e + f*x)**S(2), x), x), x) + Simp(b*d*(d/cos(e + f*x))**(n + S(-1))*(a + b/cos(e + f*x))**(m + S(1))*tan(e + f*x)/(f*(a**S(2) - b**S(2))*(m + S(1))), x) rule4081 = ReplacementRule(pattern4081, replacement4081) pattern4082 = Pattern(Integral((WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_, x_), cons2, cons3, cons27, cons48, cons125, cons1267, cons93, cons94, cons1325, cons1170) def replacement4082(m, f, b, d, a, n, x, e): rubi.append(4082) return Dist(S(1)/((a**S(2) - b**S(2))*(m + S(1))), Int((d/sin(e + f*x))**(n + S(-1))*(a + b/sin(e + f*x))**(m + S(1))*Simp(a*d*(m + S(1))/sin(e + f*x) + b*d*(n + S(-1)) - b*d*(m + n + S(1))/sin(e + f*x)**S(2), x), x), x) - Simp(b*d*(d/sin(e + f*x))**(n + S(-1))*(a + b/sin(e + f*x))**(m + S(1))/(f*(a**S(2) - b**S(2))*(m + S(1))*tan(e + f*x)), x) rule4082 = ReplacementRule(pattern4082, replacement4082) pattern4083 = Pattern(Integral((WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_, x_), cons2, cons3, cons27, cons48, cons125, cons1267, cons93, cons94, cons1336, cons1170) def replacement4083(m, f, b, d, a, n, x, e): rubi.append(4083) return -Dist(d**S(2)/((a**S(2) - b**S(2))*(m + S(1))), Int((d/cos(e + f*x))**(n + S(-2))*(a + b/cos(e + f*x))**(m + S(1))*(-a*(m + n)/cos(e + f*x)**S(2) + a*(n + S(-2)) + b*(m + S(1))/cos(e + f*x)), x), x) - Simp(a*d**S(2)*(d/cos(e + f*x))**(n + S(-2))*(a + b/cos(e + f*x))**(m + S(1))*tan(e + f*x)/(f*(a**S(2) - b**S(2))*(m + S(1))), x) rule4083 = ReplacementRule(pattern4083, replacement4083) pattern4084 = Pattern(Integral((WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_, x_), cons2, cons3, cons27, cons48, cons125, cons1267, cons93, cons94, cons1336, cons1170) def replacement4084(m, f, b, d, a, n, x, e): rubi.append(4084) return -Dist(d**S(2)/((a**S(2) - b**S(2))*(m + S(1))), Int((d/sin(e + f*x))**(n + S(-2))*(a + b/sin(e + f*x))**(m + S(1))*(-a*(m + n)/sin(e + f*x)**S(2) + a*(n + S(-2)) + b*(m + S(1))/sin(e + f*x)), x), x) + Simp(a*d**S(2)*(d/sin(e + f*x))**(n + S(-2))*(a + b/sin(e + f*x))**(m + S(1))/(f*(a**S(2) - b**S(2))*(m + S(1))*tan(e + f*x)), x) rule4084 = ReplacementRule(pattern4084, replacement4084) pattern4085 = Pattern(Integral((WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_, x_), cons2, cons3, cons27, cons48, cons125, cons1267, cons93, cons94, cons1596) def replacement4085(m, f, b, d, a, n, x, e): rubi.append(4085) return Dist(d**S(3)/(b*(a**S(2) - b**S(2))*(m + S(1))), Int((d/cos(e + f*x))**(n + S(-3))*(a + b/cos(e + f*x))**(m + S(1))*Simp(a**S(2)*(n + S(-3)) + a*b*(m + S(1))/cos(e + f*x) - (a**S(2)*(n + S(-2)) + b**S(2)*(m + S(1)))/cos(e + f*x)**S(2), x), x), x) + Simp(a**S(2)*d**S(3)*(d/cos(e + f*x))**(n + S(-3))*(a + b/cos(e + f*x))**(m + S(1))*tan(e + f*x)/(b*f*(a**S(2) - b**S(2))*(m + S(1))), x) rule4085 = ReplacementRule(pattern4085, replacement4085) pattern4086 = Pattern(Integral((WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_, x_), cons2, cons3, cons27, cons48, cons125, cons1267, cons93, cons94, cons1596) def replacement4086(m, f, b, d, a, n, x, e): rubi.append(4086) return Dist(d**S(3)/(b*(a**S(2) - b**S(2))*(m + S(1))), Int((d/sin(e + f*x))**(n + S(-3))*(a + b/sin(e + f*x))**(m + S(1))*Simp(a**S(2)*(n + S(-3)) + a*b*(m + S(1))/sin(e + f*x) - (a**S(2)*(n + S(-2)) + b**S(2)*(m + S(1)))/sin(e + f*x)**S(2), x), x), x) - Simp(a**S(2)*d**S(3)*(d/sin(e + f*x))**(n + S(-3))*(a + b/sin(e + f*x))**(m + S(1))/(b*f*(a**S(2) - b**S(2))*(m + S(1))*tan(e + f*x)), x) rule4086 = ReplacementRule(pattern4086, replacement4086) pattern4087 = Pattern(Integral((WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_, x_), cons2, cons3, cons27, cons48, cons125, cons1267, cons1597) def replacement4087(m, f, b, d, a, n, x, e): rubi.append(4087) return -Dist(S(1)/(a*d*n), Int((d/cos(e + f*x))**(n + S(1))*(a + b/cos(e + f*x))**m*Simp(-a*(n + S(1))/cos(e + f*x) + b*(m + n + S(1)) - b*(m + n + S(2))/cos(e + f*x)**S(2), x), x), x) - Simp((d/cos(e + f*x))**n*(a + b/cos(e + f*x))**(m + S(1))*tan(e + f*x)/(a*f*n), x) rule4087 = ReplacementRule(pattern4087, replacement4087) pattern4088 = Pattern(Integral((WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_, x_), cons2, cons3, cons27, cons48, cons125, cons1267, cons1597) def replacement4088(m, f, b, d, a, n, x, e): rubi.append(4088) return -Dist(S(1)/(a*d*n), Int((d/sin(e + f*x))**(n + S(1))*(a + b/sin(e + f*x))**m*Simp(-a*(n + S(1))/sin(e + f*x) + b*(m + n + S(1)) - b*(m + n + S(2))/sin(e + f*x)**S(2), x), x), x) + Simp((d/sin(e + f*x))**n*(a + b/sin(e + f*x))**(m + S(1))/(a*f*n*tan(e + f*x)), x) rule4088 = ReplacementRule(pattern4088, replacement4088) pattern4089 = Pattern(Integral((WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_, x_), cons2, cons3, cons27, cons48, cons125, cons4, cons1267, cons31, cons94, cons1170) def replacement4089(m, f, b, d, a, n, x, e): rubi.append(4089) return Dist(S(1)/(a*(a**S(2) - b**S(2))*(m + S(1))), Int((d/cos(e + f*x))**n*(a + b/cos(e + f*x))**(m + S(1))*(a**S(2)*(m + S(1)) - a*b*(m + S(1))/cos(e + f*x) - b**S(2)*(m + n + S(1)) + b**S(2)*(m + n + S(2))/cos(e + f*x)**S(2)), x), x) - Simp(b**S(2)*(d/cos(e + f*x))**n*(a + b/cos(e + f*x))**(m + S(1))*tan(e + f*x)/(a*f*(a**S(2) - b**S(2))*(m + S(1))), x) rule4089 = ReplacementRule(pattern4089, replacement4089) pattern4090 = Pattern(Integral((WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_, x_), cons2, cons3, cons27, cons48, cons125, cons4, cons1267, cons31, cons94, cons1170) def replacement4090(m, f, b, d, a, n, x, e): rubi.append(4090) return Dist(S(1)/(a*(a**S(2) - b**S(2))*(m + S(1))), Int((d/sin(e + f*x))**n*(a + b/sin(e + f*x))**(m + S(1))*(a**S(2)*(m + S(1)) - a*b*(m + S(1))/sin(e + f*x) - b**S(2)*(m + n + S(1)) + b**S(2)*(m + n + S(2))/sin(e + f*x)**S(2)), x), x) + Simp(b**S(2)*(d/sin(e + f*x))**n*(a + b/sin(e + f*x))**(m + S(1))/(a*f*(a**S(2) - b**S(2))*(m + S(1))*tan(e + f*x)), x) rule4090 = ReplacementRule(pattern4090, replacement4090) pattern4091 = Pattern(Integral(sqrt(WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))/(a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons27, cons48, cons125, cons1267) def replacement4091(f, b, d, a, x, e): rubi.append(4091) return Dist(sqrt(d/cos(e + f*x))*sqrt(d*cos(e + f*x))/d, Int(sqrt(d*cos(e + f*x))/(a*cos(e + f*x) + b), x), x) rule4091 = ReplacementRule(pattern4091, replacement4091) pattern4092 = Pattern(Integral(sqrt(WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))/(a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons27, cons48, cons125, cons1267) def replacement4092(f, b, d, a, x, e): rubi.append(4092) return Dist(sqrt(d/sin(e + f*x))*sqrt(d*sin(e + f*x))/d, Int(sqrt(d*sin(e + f*x))/(a*sin(e + f*x) + b), x), x) rule4092 = ReplacementRule(pattern4092, replacement4092) pattern4093 = Pattern(Integral((WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**(S(3)/2)/(a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons27, cons48, cons125, cons1267) def replacement4093(f, b, d, a, x, e): rubi.append(4093) return Dist(d*sqrt(d/cos(e + f*x))*sqrt(d*cos(e + f*x)), Int(S(1)/(sqrt(d*cos(e + f*x))*(a*cos(e + f*x) + b)), x), x) rule4093 = ReplacementRule(pattern4093, replacement4093) pattern4094 = Pattern(Integral((WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**(S(3)/2)/(a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons27, cons48, cons125, cons1267) def replacement4094(f, b, d, a, x, e): rubi.append(4094) return Dist(d*sqrt(d/sin(e + f*x))*sqrt(d*sin(e + f*x)), Int(S(1)/(sqrt(d*sin(e + f*x))*(a*sin(e + f*x) + b)), x), x) rule4094 = ReplacementRule(pattern4094, replacement4094) pattern4095 = Pattern(Integral((WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**(S(5)/2)/(a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons27, cons48, cons125, cons1267) def replacement4095(f, b, d, a, x, e): rubi.append(4095) return Dist(d/b, Int((d/cos(e + f*x))**(S(3)/2), x), x) - Dist(a*d/b, Int((d/cos(e + f*x))**(S(3)/2)/(a + b/cos(e + f*x)), x), x) rule4095 = ReplacementRule(pattern4095, replacement4095) pattern4096 = Pattern(Integral((WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**(S(5)/2)/(a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons27, cons48, cons125, cons1267) def replacement4096(f, b, d, a, x, e): rubi.append(4096) return Dist(d/b, Int((d/sin(e + f*x))**(S(3)/2), x), x) - Dist(a*d/b, Int((d/sin(e + f*x))**(S(3)/2)/(a + b/sin(e + f*x)), x), x) rule4096 = ReplacementRule(pattern4096, replacement4096) pattern4097 = Pattern(Integral((WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_/(a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons27, cons48, cons125, cons1267, cons87, cons1598) def replacement4097(f, b, d, a, n, x, e): rubi.append(4097) return Dist(d**S(3)/(b*(n + S(-2))), Int((d/cos(e + f*x))**(n + S(-3))*Simp(a*(n + S(-3)) - a*(n + S(-2))/cos(e + f*x)**S(2) + b*(n + S(-3))/cos(e + f*x), x)/(a + b/cos(e + f*x)), x), x) + Simp(d**S(3)*(d/cos(e + f*x))**(n + S(-3))*tan(e + f*x)/(b*f*(n + S(-2))), x) rule4097 = ReplacementRule(pattern4097, replacement4097) pattern4098 = Pattern(Integral((WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_/(a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons27, cons48, cons125, cons1267, cons87, cons1598) def replacement4098(f, b, d, a, n, x, e): rubi.append(4098) return Dist(d**S(3)/(b*(n + S(-2))), Int((d/sin(e + f*x))**(n + S(-3))*Simp(a*(n + S(-3)) - a*(n + S(-2))/sin(e + f*x)**S(2) + b*(n + S(-3))/sin(e + f*x), x)/(a + b/sin(e + f*x)), x), x) - Simp(d**S(3)*(d/sin(e + f*x))**(n + S(-3))/(b*f*(n + S(-2))*tan(e + f*x)), x) rule4098 = ReplacementRule(pattern4098, replacement4098) pattern4099 = Pattern(Integral(S(1)/(sqrt(WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))*(a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))), x_), cons2, cons3, cons27, cons48, cons125, cons1267) def replacement4099(f, b, d, a, x, e): rubi.append(4099) return Dist(a**(S(-2)), Int((a - b/cos(e + f*x))/sqrt(d/cos(e + f*x)), x), x) + Dist(b**S(2)/(a**S(2)*d**S(2)), Int((d/cos(e + f*x))**(S(3)/2)/(a + b/cos(e + f*x)), x), x) rule4099 = ReplacementRule(pattern4099, replacement4099) pattern4100 = Pattern(Integral(S(1)/(sqrt(WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))*(a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))), x_), cons2, cons3, cons27, cons48, cons125, cons1267) def replacement4100(f, b, d, a, x, e): rubi.append(4100) return Dist(a**(S(-2)), Int((a - b/sin(e + f*x))/sqrt(d/sin(e + f*x)), x), x) + Dist(b**S(2)/(a**S(2)*d**S(2)), Int((d/sin(e + f*x))**(S(3)/2)/(a + b/sin(e + f*x)), x), x) rule4100 = ReplacementRule(pattern4100, replacement4100) pattern4101 = Pattern(Integral((WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_/(a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons27, cons48, cons125, cons1267, cons87, cons1586, cons808) def replacement4101(f, b, d, a, n, x, e): rubi.append(4101) return -Dist(S(1)/(a*d*n), Int((d/cos(e + f*x))**(n + S(1))*Simp(-a*(n + S(1))/cos(e + f*x) + b*n - b*(n + S(1))/cos(e + f*x)**S(2), x)/(a + b/cos(e + f*x)), x), x) - Simp((d/cos(e + f*x))**n*tan(e + f*x)/(a*f*n), x) rule4101 = ReplacementRule(pattern4101, replacement4101) pattern4102 = Pattern(Integral((WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_/(a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons27, cons48, cons125, cons1267, cons87, cons1586, cons808) def replacement4102(f, b, d, a, n, x, e): rubi.append(4102) return -Dist(S(1)/(a*d*n), Int((d/sin(e + f*x))**(n + S(1))*Simp(-a*(n + S(1))/sin(e + f*x) + b*n - b*(n + S(1))/sin(e + f*x)**S(2), x)/(a + b/sin(e + f*x)), x), x) + Simp((d/sin(e + f*x))**n/(a*f*n*tan(e + f*x)), x) rule4102 = ReplacementRule(pattern4102, replacement4102) pattern4103 = Pattern(Integral(sqrt(WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))*sqrt(a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons27, cons48, cons125, cons1267) def replacement4103(f, b, d, a, x, e): rubi.append(4103) return Dist(a, Int(sqrt(d/cos(e + f*x))/sqrt(a + b/cos(e + f*x)), x), x) + Dist(b/d, Int((d/cos(e + f*x))**(S(3)/2)/sqrt(a + b/cos(e + f*x)), x), x) rule4103 = ReplacementRule(pattern4103, replacement4103) pattern4104 = Pattern(Integral(sqrt(WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))*sqrt(a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons27, cons48, cons125, cons1267) def replacement4104(f, b, d, a, x, e): rubi.append(4104) return Dist(a, Int(sqrt(d/sin(e + f*x))/sqrt(a + b/sin(e + f*x)), x), x) + Dist(b/d, Int((d/sin(e + f*x))**(S(3)/2)/sqrt(a + b/sin(e + f*x)), x), x) rule4104 = ReplacementRule(pattern4104, replacement4104) pattern4105 = Pattern(Integral((WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_*sqrt(a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons27, cons48, cons125, cons1267, cons87, cons165, cons808) def replacement4105(f, b, d, a, n, x, e): rubi.append(4105) return Dist(d**S(2)/(S(2)*n + S(-1)), Int((d/cos(e + f*x))**(n + S(-2))*Simp(S(2)*a*(n + S(-2)) + a/cos(e + f*x)**S(2) + b*(S(2)*n + S(-3))/cos(e + f*x), x)/sqrt(a + b/cos(e + f*x)), x), x) + Simp(S(2)*d*(d/cos(e + f*x))**(n + S(-1))*sqrt(a + b/cos(e + f*x))*sin(e + f*x)/(f*(S(2)*n + S(-1))), x) rule4105 = ReplacementRule(pattern4105, replacement4105) pattern4106 = Pattern(Integral((WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_*sqrt(a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons27, cons48, cons125, cons1267, cons87, cons165, cons808) def replacement4106(f, b, d, a, n, x, e): rubi.append(4106) return Dist(d**S(2)/(S(2)*n + S(-1)), Int((d/sin(e + f*x))**(n + S(-2))*Simp(S(2)*a*(n + S(-2)) + a/sin(e + f*x)**S(2) + b*(S(2)*n + S(-3))/sin(e + f*x), x)/sqrt(a + b/sin(e + f*x)), x), x) + Simp(-S(2)*d*(d/sin(e + f*x))**(n + S(-1))*sqrt(a + b/sin(e + f*x))*cos(e + f*x)/(f*(S(2)*n + S(-1))), x) rule4106 = ReplacementRule(pattern4106, replacement4106) pattern4107 = Pattern(Integral(sqrt(a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))/sqrt(WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons27, cons48, cons125, cons1267) def replacement4107(f, b, d, a, x, e): rubi.append(4107) return Dist(sqrt(a + b/cos(e + f*x))/(sqrt(d/cos(e + f*x))*sqrt(a*cos(e + f*x) + b)), Int(sqrt(a*cos(e + f*x) + b), x), x) rule4107 = ReplacementRule(pattern4107, replacement4107) pattern4108 = Pattern(Integral(sqrt(a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))/sqrt(WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons27, cons48, cons125, cons1267) def replacement4108(f, b, d, a, x, e): rubi.append(4108) return Dist(sqrt(a + b/sin(e + f*x))/(sqrt(d/sin(e + f*x))*sqrt(a*sin(e + f*x) + b)), Int(sqrt(a*sin(e + f*x) + b), x), x) rule4108 = ReplacementRule(pattern4108, replacement4108) pattern4109 = Pattern(Integral((WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_*sqrt(a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons27, cons48, cons125, cons1267, cons87, cons1586, cons808) def replacement4109(f, b, d, a, n, x, e): rubi.append(4109) return -Dist(S(1)/(S(2)*d*n), Int((d/cos(e + f*x))**(n + S(1))*Simp(-S(2)*a*(n + S(1))/cos(e + f*x) - b*(S(2)*n + S(3))/cos(e + f*x)**S(2) + b, x)/sqrt(a + b/cos(e + f*x)), x), x) - Simp((d/cos(e + f*x))**n*sqrt(a + b/cos(e + f*x))*tan(e + f*x)/(f*n), x) rule4109 = ReplacementRule(pattern4109, replacement4109) pattern4110 = Pattern(Integral((WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_*sqrt(a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons27, cons48, cons125, cons1267, cons87, cons1586, cons808) def replacement4110(f, b, d, a, n, x, e): rubi.append(4110) return -Dist(S(1)/(S(2)*d*n), Int((d/sin(e + f*x))**(n + S(1))*Simp(-S(2)*a*(n + S(1))/sin(e + f*x) - b*(S(2)*n + S(3))/sin(e + f*x)**S(2) + b, x)/sqrt(a + b/sin(e + f*x)), x), x) + Simp((d/sin(e + f*x))**n*sqrt(a + b/sin(e + f*x))/(f*n*tan(e + f*x)), x) rule4110 = ReplacementRule(pattern4110, replacement4110) pattern4111 = Pattern(Integral(sqrt(WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))/sqrt(a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons27, cons48, cons125, cons1267) def replacement4111(f, b, d, a, x, e): rubi.append(4111) return Dist(sqrt(d/cos(e + f*x))*sqrt(a*cos(e + f*x) + b)/sqrt(a + b/cos(e + f*x)), Int(S(1)/sqrt(a*cos(e + f*x) + b), x), x) rule4111 = ReplacementRule(pattern4111, replacement4111) pattern4112 = Pattern(Integral(sqrt(WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))/sqrt(a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons27, cons48, cons125, cons1267) def replacement4112(f, b, d, a, x, e): rubi.append(4112) return Dist(sqrt(d/sin(e + f*x))*sqrt(a*sin(e + f*x) + b)/sqrt(a + b/sin(e + f*x)), Int(S(1)/sqrt(a*sin(e + f*x) + b), x), x) rule4112 = ReplacementRule(pattern4112, replacement4112) pattern4113 = Pattern(Integral((WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**(S(3)/2)/sqrt(a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons27, cons48, cons125, cons1267) def replacement4113(f, b, d, a, x, e): rubi.append(4113) return Dist(d*sqrt(d/cos(e + f*x))*sqrt(a*cos(e + f*x) + b)/sqrt(a + b/cos(e + f*x)), Int(S(1)/(sqrt(a*cos(e + f*x) + b)*cos(e + f*x)), x), x) rule4113 = ReplacementRule(pattern4113, replacement4113) pattern4114 = Pattern(Integral((WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**(S(3)/2)/sqrt(a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons27, cons48, cons125, cons1267) def replacement4114(f, b, d, a, x, e): rubi.append(4114) return Dist(d*sqrt(d/sin(e + f*x))*sqrt(a*sin(e + f*x) + b)/sqrt(a + b/sin(e + f*x)), Int(S(1)/(sqrt(a*sin(e + f*x) + b)*sin(e + f*x)), x), x) rule4114 = ReplacementRule(pattern4114, replacement4114) pattern4115 = Pattern(Integral((WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_/sqrt(a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons27, cons48, cons125, cons1267, cons87, cons744, cons808) def replacement4115(f, b, d, a, n, x, e): rubi.append(4115) return Dist(d**S(3)/(b*(S(2)*n + S(-3))), Int((d/cos(e + f*x))**(n + S(-3))*Simp(S(2)*a*(n + S(-3)) - S(2)*a*(n + S(-2))/cos(e + f*x)**S(2) + b*(S(2)*n + S(-5))/cos(e + f*x), x)/sqrt(a + b/cos(e + f*x)), x), x) + Simp(S(2)*d**S(2)*(d/cos(e + f*x))**(n + S(-2))*sqrt(a + b/cos(e + f*x))*sin(e + f*x)/(b*f*(S(2)*n + S(-3))), x) rule4115 = ReplacementRule(pattern4115, replacement4115) pattern4116 = Pattern(Integral((WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_/sqrt(a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons27, cons48, cons125, cons1267, cons87, cons744, cons808) def replacement4116(f, b, d, a, n, x, e): rubi.append(4116) return Dist(d**S(3)/(b*(S(2)*n + S(-3))), Int((d/sin(e + f*x))**(n + S(-3))*Simp(S(2)*a*(n + S(-3)) - S(2)*a*(n + S(-2))/sin(e + f*x)**S(2) + b*(S(2)*n + S(-5))/sin(e + f*x), x)/sqrt(a + b/sin(e + f*x)), x), x) + Simp(-S(2)*d**S(2)*(d/sin(e + f*x))**(n + S(-2))*sqrt(a + b/sin(e + f*x))*cos(e + f*x)/(b*f*(S(2)*n + S(-3))), x) rule4116 = ReplacementRule(pattern4116, replacement4116) pattern4117 = Pattern(Integral(cos(x_*WC('f', S(1)) + WC('e', S(0)))/sqrt(a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons48, cons125, cons1267) def replacement4117(f, b, a, x, e): rubi.append(4117) return -Dist(b/(S(2)*a), Int((S(1) + cos(e + f*x)**(S(-2)))/sqrt(a + b/cos(e + f*x)), x), x) + Simp(sqrt(a + b/cos(e + f*x))*sin(e + f*x)/(a*f), x) rule4117 = ReplacementRule(pattern4117, replacement4117) pattern4118 = Pattern(Integral(sin(x_*WC('f', S(1)) + WC('e', S(0)))/sqrt(a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons48, cons125, cons1267) def replacement4118(f, b, a, x, e): rubi.append(4118) return -Dist(b/(S(2)*a), Int((S(1) + sin(e + f*x)**(S(-2)))/sqrt(a + b/sin(e + f*x)), x), x) - Simp(sqrt(a + b/sin(e + f*x))*cos(e + f*x)/(a*f), x) rule4118 = ReplacementRule(pattern4118, replacement4118) pattern4119 = Pattern(Integral(S(1)/(sqrt(WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))*sqrt(a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))), x_), cons2, cons3, cons27, cons48, cons125, cons1267) def replacement4119(f, b, d, a, x, e): rubi.append(4119) return Dist(S(1)/a, Int(sqrt(a + b/cos(e + f*x))/sqrt(d/cos(e + f*x)), x), x) - Dist(b/(a*d), Int(sqrt(d/cos(e + f*x))/sqrt(a + b/cos(e + f*x)), x), x) rule4119 = ReplacementRule(pattern4119, replacement4119) pattern4120 = Pattern(Integral(S(1)/(sqrt(WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))*sqrt(a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))), x_), cons2, cons3, cons27, cons48, cons125, cons1267) def replacement4120(f, b, d, a, x, e): rubi.append(4120) return Dist(S(1)/a, Int(sqrt(a + b/sin(e + f*x))/sqrt(d/sin(e + f*x)), x), x) - Dist(b/(a*d), Int(sqrt(d/sin(e + f*x))/sqrt(a + b/sin(e + f*x)), x), x) rule4120 = ReplacementRule(pattern4120, replacement4120) pattern4121 = Pattern(Integral((WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_/sqrt(a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons27, cons48, cons125, cons1267, cons87, cons89, cons808) def replacement4121(f, b, d, a, n, x, e): rubi.append(4121) return Dist(S(1)/(S(2)*a*d*n), Int((d/cos(e + f*x))**(n + S(1))*Simp(S(2)*a*(n + S(1))/cos(e + f*x) - b*(S(2)*n + S(1)) + b*(S(2)*n + S(3))/cos(e + f*x)**S(2), x)/sqrt(a + b/cos(e + f*x)), x), x) - Simp((d/cos(e + f*x))**(n + S(1))*sqrt(a + b/cos(e + f*x))*sin(e + f*x)/(a*d*f*n), x) rule4121 = ReplacementRule(pattern4121, replacement4121) pattern4122 = Pattern(Integral((WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_/sqrt(a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons27, cons48, cons125, cons1267, cons87, cons89, cons808) def replacement4122(f, b, d, a, n, x, e): rubi.append(4122) return Dist(S(1)/(S(2)*a*d*n), Int((d/sin(e + f*x))**(n + S(1))*Simp(S(2)*a*(n + S(1))/sin(e + f*x) - b*(S(2)*n + S(1)) + b*(S(2)*n + S(3))/sin(e + f*x)**S(2), x)/sqrt(a + b/sin(e + f*x)), x), x) + Simp((d/sin(e + f*x))**(n + S(1))*sqrt(a + b/sin(e + f*x))*cos(e + f*x)/(a*d*f*n), x) rule4122 = ReplacementRule(pattern4122, replacement4122) pattern4123 = Pattern(Integral((WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**(S(3)/2), x_), cons2, cons3, cons27, cons48, cons125, cons1267, cons87, cons1586, cons1599) def replacement4123(f, b, d, a, n, x, e): rubi.append(4123) return Dist(S(1)/(S(2)*d*n), Int((d/cos(e + f*x))**(n + S(1))*Simp(a*b*(S(2)*n + S(-1)) + a*b*(S(2)*n + S(3))/cos(e + f*x)**S(2) + S(2)*(a**S(2)*(n + S(1)) + b**S(2)*n)/cos(e + f*x), x)/sqrt(a + b/cos(e + f*x)), x), x) - Simp(a*(d/cos(e + f*x))**n*sqrt(a + b/cos(e + f*x))*tan(e + f*x)/(f*n), x) rule4123 = ReplacementRule(pattern4123, replacement4123) pattern4124 = Pattern(Integral((WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**(S(3)/2), x_), cons2, cons3, cons27, cons48, cons125, cons1267, cons87, cons1586, cons1599) def replacement4124(f, b, d, a, n, x, e): rubi.append(4124) return Dist(S(1)/(S(2)*d*n), Int((d/sin(e + f*x))**(n + S(1))*Simp(a*b*(S(2)*n + S(-1)) + a*b*(S(2)*n + S(3))/sin(e + f*x)**S(2) + S(2)*(a**S(2)*(n + S(1)) + b**S(2)*n)/sin(e + f*x), x)/sqrt(a + b/sin(e + f*x)), x), x) + Simp(a*(d/sin(e + f*x))**n*sqrt(a + b/sin(e + f*x))/(f*n*tan(e + f*x)), x) rule4124 = ReplacementRule(pattern4124, replacement4124) pattern4125 = Pattern(Integral((WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_, x_), cons2, cons3, cons27, cons48, cons125, cons21, cons1267, cons87, cons1598, cons1553, cons1600) def replacement4125(m, f, b, d, a, n, x, e): rubi.append(4125) return Dist(d**S(3)/(b*(m + n + S(-1))), Int((d/cos(e + f*x))**(n + S(-3))*(a + b/cos(e + f*x))**m*Simp(a*(n + S(-3)) - a*(n + S(-2))/cos(e + f*x)**S(2) + b*(m + n + S(-2))/cos(e + f*x), x), x), x) + Simp(d**S(3)*(d/cos(e + f*x))**(n + S(-3))*(a + b/cos(e + f*x))**(m + S(1))*tan(e + f*x)/(b*f*(m + n + S(-1))), x) rule4125 = ReplacementRule(pattern4125, replacement4125) pattern4126 = Pattern(Integral((WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_, x_), cons2, cons3, cons27, cons48, cons125, cons21, cons1267, cons87, cons1598, cons1553, cons1600) def replacement4126(m, f, b, d, a, n, x, e): rubi.append(4126) return Dist(d**S(3)/(b*(m + n + S(-1))), Int((d/sin(e + f*x))**(n + S(-3))*(a + b/sin(e + f*x))**m*Simp(a*(n + S(-3)) - a*(n + S(-2))/sin(e + f*x)**S(2) + b*(m + n + S(-2))/sin(e + f*x), x), x), x) - Simp(d**S(3)*(d/sin(e + f*x))**(n + S(-3))*(a + b/sin(e + f*x))**(m + S(1))/(b*f*(m + n + S(-1))*tan(e + f*x)), x) rule4126 = ReplacementRule(pattern4126, replacement4126) pattern4127 = Pattern(Integral((WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_, x_), cons2, cons3, cons27, cons48, cons125, cons1267, cons93, cons1357, cons1601, cons1519, cons1334) def replacement4127(m, f, b, d, a, n, x, e): rubi.append(4127) return Dist(d/(m + n + S(-1)), Int((d/cos(e + f*x))**(n + S(-1))*(a + b/cos(e + f*x))**(m + S(-2))*Simp(a*b*(n + S(-1)) + a*b*(S(2)*m + n + S(-2))/cos(e + f*x)**S(2) + (a**S(2)*(m + n + S(-1)) + b**S(2)*(m + n + S(-2)))/cos(e + f*x), x), x), x) + Simp(b*d*(d/cos(e + f*x))**(n + S(-1))*(a + b/cos(e + f*x))**(m + S(-1))*tan(e + f*x)/(f*(m + n + S(-1))), x) rule4127 = ReplacementRule(pattern4127, replacement4127) pattern4128 = Pattern(Integral((WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_, x_), cons2, cons3, cons27, cons48, cons125, cons1267, cons93, cons1357, cons1601, cons1519, cons1334) def replacement4128(m, f, b, d, a, n, x, e): rubi.append(4128) return Dist(d/(m + n + S(-1)), Int((d/sin(e + f*x))**(n + S(-1))*(a + b/sin(e + f*x))**(m + S(-2))*Simp(a*b*(n + S(-1)) + a*b*(S(2)*m + n + S(-2))/sin(e + f*x)**S(2) + (a**S(2)*(m + n + S(-1)) + b**S(2)*(m + n + S(-2)))/sin(e + f*x), x), x), x) - Simp(b*d*(d/sin(e + f*x))**(n + S(-1))*(a + b/sin(e + f*x))**(m + S(-1))/(f*(m + n + S(-1))*tan(e + f*x)), x) rule4128 = ReplacementRule(pattern4128, replacement4128) pattern4129 = Pattern(Integral((WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_, x_), cons2, cons3, cons27, cons48, cons125, cons1267, cons93, cons1602, cons1603, cons1519, cons1553) def replacement4129(m, f, b, d, a, n, x, e): rubi.append(4129) return Dist(d**S(2)/(b*(m + n + S(-1))), Int((d/cos(e + f*x))**(n + S(-2))*(a + b/cos(e + f*x))**(m + S(-1))*Simp(a*b*m/cos(e + f*x)**S(2) + a*b*(n + S(-2)) + b**S(2)*(m + n + S(-2))/cos(e + f*x), x), x), x) + Simp(d**S(2)*(d/cos(e + f*x))**(n + S(-2))*(a + b/cos(e + f*x))**m*tan(e + f*x)/(f*(m + n + S(-1))), x) rule4129 = ReplacementRule(pattern4129, replacement4129) pattern4130 = Pattern(Integral((WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_, x_), cons2, cons3, cons27, cons48, cons125, cons1267, cons93, cons1602, cons1603, cons1519, cons1553) def replacement4130(m, f, b, d, a, n, x, e): rubi.append(4130) return Dist(d**S(2)/(b*(m + n + S(-1))), Int((d/sin(e + f*x))**(n + S(-2))*(a + b/sin(e + f*x))**(m + S(-1))*Simp(a*b*m/sin(e + f*x)**S(2) + a*b*(n + S(-2)) + b**S(2)*(m + n + S(-2))/sin(e + f*x), x), x), x) - Simp(d**S(2)*(d/sin(e + f*x))**(n + S(-2))*(a + b/sin(e + f*x))**m/(f*(m + n + S(-1))*tan(e + f*x)), x) rule4130 = ReplacementRule(pattern4130, replacement4130) pattern4131 = Pattern(Integral((a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**(S(3)/2)/sqrt(WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons27, cons48, cons125, cons1267) def replacement4131(f, b, d, a, x, e): rubi.append(4131) return Dist(a, Int(sqrt(a + b/cos(e + f*x))/sqrt(d/cos(e + f*x)), x), x) + Dist(b/d, Int(sqrt(d/cos(e + f*x))*sqrt(a + b/cos(e + f*x)), x), x) rule4131 = ReplacementRule(pattern4131, replacement4131) pattern4132 = Pattern(Integral((a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**(S(3)/2)/sqrt(WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons27, cons48, cons125, cons1267) def replacement4132(f, b, d, a, x, e): rubi.append(4132) return Dist(a, Int(sqrt(a + b/sin(e + f*x))/sqrt(d/sin(e + f*x)), x), x) + Dist(b/d, Int(sqrt(d/sin(e + f*x))*sqrt(a + b/sin(e + f*x)), x), x) rule4132 = ReplacementRule(pattern4132, replacement4132) pattern4133 = Pattern(Integral((WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_, x_), cons2, cons3, cons27, cons48, cons125, cons4, cons62) def replacement4133(m, f, b, d, a, n, x, e): rubi.append(4133) return Dist(a, Int((d/cos(e + f*x))**n*(a + b/cos(e + f*x))**(m + S(-1)), x), x) + Dist(b/d, Int((d/cos(e + f*x))**(n + S(1))*(a + b/cos(e + f*x))**(m + S(-1)), x), x) rule4133 = ReplacementRule(pattern4133, replacement4133) pattern4134 = Pattern(Integral((WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_, x_), cons2, cons3, cons27, cons48, cons125, cons4, cons62) def replacement4134(m, f, b, d, a, n, x, e): rubi.append(4134) return Dist(a, Int((d/sin(e + f*x))**n*(a + b/sin(e + f*x))**(m + S(-1)), x), x) + Dist(b/d, Int((d/sin(e + f*x))**(n + S(1))*(a + b/sin(e + f*x))**(m + S(-1)), x), x) rule4134 = ReplacementRule(pattern4134, replacement4134) pattern4135 = Pattern(Integral((WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1))*(a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1)), x_), cons2, cons3, cons27, cons48, cons125, cons21, cons4, cons1604) def replacement4135(m, f, b, d, a, n, x, e): rubi.append(4135) return Int((d/cos(e + f*x))**n*(a + b/cos(e + f*x))**m, x) rule4135 = ReplacementRule(pattern4135, replacement4135) pattern4136 = Pattern(Integral((WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1))*(a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1)), x_), cons2, cons3, cons27, cons48, cons125, cons21, cons4, cons1604) def replacement4136(m, f, b, d, a, n, x, e): rubi.append(4136) return Int((d/sin(e + f*x))**n*(a + b/sin(e + f*x))**m, x) rule4136 = ReplacementRule(pattern4136, replacement4136) pattern4137 = Pattern(Integral((WC('g', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('p', S(1))*(a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1)), x_), cons2, cons3, cons48, cons125, cons208, cons5, cons17) def replacement4137(p, m, f, b, g, a, x, e): rubi.append(4137) return Int((g*sin(e + f*x))**p*(a*cos(e + f*x) + b)**m*cos(e + f*x)**(-m), x) rule4137 = ReplacementRule(pattern4137, replacement4137) pattern4138 = Pattern(Integral((WC('g', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('p', S(1))*(a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1)), x_), cons2, cons3, cons48, cons125, cons208, cons5, cons17) def replacement4138(p, m, f, b, g, a, x, e): rubi.append(4138) return Int((g*cos(e + f*x))**p*(a*sin(e + f*x) + b)**m*sin(e + f*x)**(-m), x) rule4138 = ReplacementRule(pattern4138, replacement4138) pattern4139 = Pattern(Integral((a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*sin(x_*WC('f', S(1)) + WC('e', S(0)))**WC('p', S(1)), x_), cons2, cons3, cons48, cons125, cons21, cons1274, cons1265) def replacement4139(p, m, f, b, a, x, e): rubi.append(4139) return Dist(b**(-p + S(1))/f, Subst(Int(x**(-p + S(-1))*(-a + b*x)**(p/S(2) + S(-1)/2)*(a + b*x)**(m + p/S(2) + S(-1)/2), x), x, S(1)/cos(e + f*x)), x) rule4139 = ReplacementRule(pattern4139, replacement4139) pattern4140 = Pattern(Integral((a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*cos(x_*WC('f', S(1)) + WC('e', S(0)))**WC('p', S(1)), x_), cons2, cons3, cons48, cons125, cons21, cons1274, cons1265) def replacement4140(p, m, f, b, a, x, e): rubi.append(4140) return -Dist(b**(-p + S(1))/f, Subst(Int(x**(-p + S(-1))*(-a + b*x)**(p/S(2) + S(-1)/2)*(a + b*x)**(m + p/S(2) + S(-1)/2), x), x, S(1)/sin(e + f*x)), x) rule4140 = ReplacementRule(pattern4140, replacement4140) pattern4141 = Pattern(Integral((a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*sin(x_*WC('f', S(1)) + WC('e', S(0)))**WC('p', S(1)), x_), cons2, cons3, cons48, cons125, cons21, cons1274, cons1267) def replacement4141(p, m, f, b, a, x, e): rubi.append(4141) return Dist(S(1)/f, Subst(Int(x**(-p + S(-1))*(a + b*x)**m*(x + S(-1))**(p/S(2) + S(-1)/2)*(x + S(1))**(p/S(2) + S(-1)/2), x), x, S(1)/cos(e + f*x)), x) rule4141 = ReplacementRule(pattern4141, replacement4141) pattern4142 = Pattern(Integral((a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*cos(x_*WC('f', S(1)) + WC('e', S(0)))**WC('p', S(1)), x_), cons2, cons3, cons48, cons125, cons21, cons1274, cons1267) def replacement4142(p, m, f, b, a, x, e): rubi.append(4142) return -Dist(S(1)/f, Subst(Int(x**(-p + S(-1))*(a + b*x)**m*(x + S(-1))**(p/S(2) + S(-1)/2)*(x + S(1))**(p/S(2) + S(-1)/2), x), x, S(1)/sin(e + f*x)), x) rule4142 = ReplacementRule(pattern4142, replacement4142) pattern4143 = Pattern(Integral((a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_/sin(x_*WC('f', S(1)) + WC('e', S(0)))**S(2), x_), cons2, cons3, cons48, cons125, cons21, cons1605) def replacement4143(m, f, b, a, x, e): rubi.append(4143) return Dist(b*m, Int((a + b/cos(e + f*x))**(m + S(-1))/cos(e + f*x), x), x) - Simp((a + b/cos(e + f*x))**m/(f*tan(e + f*x)), x) rule4143 = ReplacementRule(pattern4143, replacement4143) pattern4144 = Pattern(Integral((a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_/cos(x_*WC('f', S(1)) + WC('e', S(0)))**S(2), x_), cons2, cons3, cons48, cons125, cons21, cons1605) def replacement4144(m, f, b, a, x, e): rubi.append(4144) return Dist(b*m, Int((a + b/sin(e + f*x))**(m + S(-1))/sin(e + f*x), x), x) + Simp((a + b/sin(e + f*x))**m*tan(e + f*x)/f, x) rule4144 = ReplacementRule(pattern4144, replacement4144) pattern4145 = Pattern(Integral((WC('g', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('p', S(1))*(a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_, x_), cons2, cons3, cons48, cons125, cons208, cons21, cons5, cons1606) def replacement4145(p, m, f, b, g, a, x, e): rubi.append(4145) return Dist((a + b/cos(e + f*x))**FracPart(m)*(a*cos(e + f*x) + b)**(-FracPart(m))*cos(e + f*x)**FracPart(m), Int((g*sin(e + f*x))**p*(a*cos(e + f*x) + b)**m*cos(e + f*x)**(-m), x), x) rule4145 = ReplacementRule(pattern4145, replacement4145) pattern4146 = Pattern(Integral((WC('g', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('p', S(1))*(a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_, x_), cons2, cons3, cons48, cons125, cons208, cons21, cons5, cons1606) def replacement4146(p, m, f, b, g, a, x, e): rubi.append(4146) return Dist((a + b/sin(e + f*x))**FracPart(m)*(a*sin(e + f*x) + b)**(-FracPart(m))*sin(e + f*x)**FracPart(m), Int((g*cos(e + f*x))**p*(a*sin(e + f*x) + b)**m*sin(e + f*x)**(-m), x), x) rule4146 = ReplacementRule(pattern4146, replacement4146) pattern4147 = Pattern(Integral((WC('g', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('p', S(1))*(a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1)), x_), cons2, cons3, cons48, cons125, cons208, cons21, cons5, cons1308) def replacement4147(p, m, f, b, g, a, x, e): rubi.append(4147) return Int((g*sin(e + f*x))**p*(a + b/cos(e + f*x))**m, x) rule4147 = ReplacementRule(pattern4147, replacement4147) pattern4148 = Pattern(Integral((WC('g', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('p', S(1))*(a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1)), x_), cons2, cons3, cons48, cons125, cons208, cons21, cons5, cons1308) def replacement4148(p, m, f, b, g, a, x, e): rubi.append(4148) return Int((g*cos(e + f*x))**p*(a + b/sin(e + f*x))**m, x) rule4148 = ReplacementRule(pattern4148, replacement4148) pattern4149 = Pattern(Integral((WC('g', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**p_*(a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1)), x_), cons2, cons3, cons48, cons125, cons208, cons21, cons5, cons147) def replacement4149(p, m, f, b, g, a, x, e): rubi.append(4149) return Dist((g/sin(e + f*x))**p*(g*sin(e + f*x))**p, Int((g*sin(e + f*x))**(-p)*(a + b/cos(e + f*x))**m, x), x) rule4149 = ReplacementRule(pattern4149, replacement4149) pattern4150 = Pattern(Integral((WC('g', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**p_*(a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1)), x_), cons2, cons3, cons48, cons125, cons208, cons21, cons5, cons147) def replacement4150(p, m, f, b, g, a, x, e): rubi.append(4150) return Dist((g/cos(e + f*x))**p*(g*cos(e + f*x))**p, Int((g*cos(e + f*x))**(-p)*(a + b/sin(e + f*x))**m, x), x) rule4150 = ReplacementRule(pattern4150, replacement4150) pattern4151 = Pattern(Integral((a_ + WC('b', S(1))/cos(x_*WC('d', S(1)) + WC('c', S(0))))**WC('n', S(1))*tan(x_*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1)), x_), cons2, cons3, cons7, cons27, cons1228, cons1265, cons85) def replacement4151(m, b, d, c, n, a, x): rubi.append(4151) return -Dist(a**(-m + n + S(1))*b**(-n)/d, Subst(Int(x**(-m - n)*(a - b*x)**(m/S(2) + S(-1)/2)*(a + b*x)**(m/S(2) + n + S(-1)/2), x), x, cos(c + d*x)), x) rule4151 = ReplacementRule(pattern4151, replacement4151) pattern4152 = Pattern(Integral((a_ + WC('b', S(1))/sin(x_*WC('d', S(1)) + WC('c', S(0))))**WC('n', S(1))*(S(1)/tan(x_*WC('d', S(1)) + WC('c', S(0))))**WC('m', S(1)), x_), cons2, cons3, cons7, cons27, cons1228, cons1265, cons85) def replacement4152(m, b, d, c, n, a, x): rubi.append(4152) return Dist(a**(-m + n + S(1))*b**(-n)/d, Subst(Int(x**(-m - n)*(a - b*x)**(m/S(2) + S(-1)/2)*(a + b*x)**(m/S(2) + n + S(-1)/2), x), x, sin(c + d*x)), x) rule4152 = ReplacementRule(pattern4152, replacement4152) pattern4153 = Pattern(Integral((a_ + WC('b', S(1))/cos(x_*WC('d', S(1)) + WC('c', S(0))))**n_*tan(x_*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1)), x_), cons2, cons3, cons7, cons27, cons4, cons1228, cons1265, cons23) def replacement4153(m, b, d, c, a, n, x): rubi.append(4153) return Dist(b**(-m + S(1))/d, Subst(Int((-a + b*x)**(m/S(2) + S(-1)/2)*(a + b*x)**(m/S(2) + n + S(-1)/2)/x, x), x, S(1)/cos(c + d*x)), x) rule4153 = ReplacementRule(pattern4153, replacement4153) pattern4154 = Pattern(Integral((a_ + WC('b', S(1))/sin(x_*WC('d', S(1)) + WC('c', S(0))))**n_*(S(1)/tan(x_*WC('d', S(1)) + WC('c', S(0))))**WC('m', S(1)), x_), cons2, cons3, cons7, cons27, cons4, cons1228, cons1265, cons23) def replacement4154(m, b, d, c, a, n, x): rubi.append(4154) return -Dist(b**(-m + S(1))/d, Subst(Int((-a + b*x)**(m/S(2) + S(-1)/2)*(a + b*x)**(m/S(2) + n + S(-1)/2)/x, x), x, S(1)/sin(c + d*x)), x) rule4154 = ReplacementRule(pattern4154, replacement4154) pattern4155 = Pattern(Integral((WC('e', S(1))*tan(x_*WC('d', S(1)) + WC('c', S(0))))**m_*(a_ + WC('b', S(1))/cos(x_*WC('d', S(1)) + WC('c', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons31, cons166) def replacement4155(m, b, d, c, a, x, e): rubi.append(4155) return -Dist(e**S(2)/m, Int((e*tan(c + d*x))**(m + S(-2))*(a*m + b*(m + S(-1))/cos(c + d*x)), x), x) + Simp(e*(e*tan(c + d*x))**(m + S(-1))*(a*m + b*(m + S(-1))/cos(c + d*x))/(d*m*(m + S(-1))), x) rule4155 = ReplacementRule(pattern4155, replacement4155) pattern4156 = Pattern(Integral((WC('e', S(1))/tan(x_*WC('d', S(1)) + WC('c', S(0))))**m_*(a_ + WC('b', S(1))/sin(x_*WC('d', S(1)) + WC('c', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons31, cons166) def replacement4156(m, b, d, c, a, x, e): rubi.append(4156) return -Dist(e**S(2)/m, Int((e/tan(c + d*x))**(m + S(-2))*(a*m + b*(m + S(-1))/sin(c + d*x)), x), x) - Simp(e*(e/tan(c + d*x))**(m + S(-1))*(a*m + b*(m + S(-1))/sin(c + d*x))/(d*m*(m + S(-1))), x) rule4156 = ReplacementRule(pattern4156, replacement4156) pattern4157 = Pattern(Integral((WC('e', S(1))*tan(x_*WC('d', S(1)) + WC('c', S(0))))**m_*(a_ + WC('b', S(1))/cos(x_*WC('d', S(1)) + WC('c', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons31, cons94) def replacement4157(m, b, d, c, a, x, e): rubi.append(4157) return -Dist(S(1)/(e**S(2)*(m + S(1))), Int((e*tan(c + d*x))**(m + S(2))*(a*(m + S(1)) + b*(m + S(2))/cos(c + d*x)), x), x) + Simp((e*tan(c + d*x))**(m + S(1))*(a + b/cos(c + d*x))/(d*e*(m + S(1))), x) rule4157 = ReplacementRule(pattern4157, replacement4157) pattern4158 = Pattern(Integral((WC('e', S(1))/tan(x_*WC('d', S(1)) + WC('c', S(0))))**m_*(a_ + WC('b', S(1))/sin(x_*WC('d', S(1)) + WC('c', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons31, cons94) def replacement4158(m, b, d, c, a, x, e): rubi.append(4158) return -Dist(S(1)/(e**S(2)*(m + S(1))), Int((e/tan(c + d*x))**(m + S(2))*(a*(m + S(1)) + b*(m + S(2))/sin(c + d*x)), x), x) - Simp((e/tan(c + d*x))**(m + S(1))*(a + b/sin(c + d*x))/(d*e*(m + S(1))), x) rule4158 = ReplacementRule(pattern4158, replacement4158) pattern4159 = Pattern(Integral((a_ + WC('b', S(1))/cos(x_*WC('d', S(1)) + WC('c', S(0))))/tan(x_*WC('d', S(1)) + WC('c', S(0))), x_), cons2, cons3, cons7, cons27, cons1264) def replacement4159(b, d, c, a, x): rubi.append(4159) return Int((a*cos(c + d*x) + b)/sin(c + d*x), x) rule4159 = ReplacementRule(pattern4159, replacement4159) pattern4160 = Pattern(Integral((a_ + WC('b', S(1))/sin(x_*WC('d', S(1)) + WC('c', S(0))))*tan(x_*WC('d', S(1)) + WC('c', S(0))), x_), cons2, cons3, cons7, cons27, cons1264) def replacement4160(b, d, c, a, x): rubi.append(4160) return Int((a*sin(c + d*x) + b)/cos(c + d*x), x) rule4160 = ReplacementRule(pattern4160, replacement4160) pattern4161 = Pattern(Integral((WC('e', S(1))*tan(x_*WC('d', S(1)) + WC('c', S(0))))**WC('m', S(1))*(a_ + WC('b', S(1))/cos(x_*WC('d', S(1)) + WC('c', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons21, cons1507) def replacement4161(m, b, d, c, a, x, e): rubi.append(4161) return Dist(a, Int((e*tan(c + d*x))**m, x), x) + Dist(b, Int((e*tan(c + d*x))**m/cos(c + d*x), x), x) rule4161 = ReplacementRule(pattern4161, replacement4161) pattern4162 = Pattern(Integral((WC('e', S(1))/tan(x_*WC('d', S(1)) + WC('c', S(0))))**WC('m', S(1))*(a_ + WC('b', S(1))/sin(x_*WC('d', S(1)) + WC('c', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons21, cons1507) def replacement4162(m, b, d, c, a, x, e): rubi.append(4162) return Dist(a, Int((e/tan(c + d*x))**m, x), x) + Dist(b, Int((e/tan(c + d*x))**m/sin(c + d*x), x), x) rule4162 = ReplacementRule(pattern4162, replacement4162) pattern4163 = Pattern(Integral((a_ + WC('b', S(1))/cos(x_*WC('d', S(1)) + WC('c', S(0))))**n_*tan(x_*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1)), x_), cons2, cons3, cons7, cons27, cons4, cons1228, cons1267) def replacement4163(m, b, d, c, a, n, x): rubi.append(4163) return Dist((S(-1))**(m/S(2) + S(-1)/2)*b**(-m + S(1))/d, Subst(Int((a + x)**n*(b**S(2) - x**S(2))**(m/S(2) + S(-1)/2)/x, x), x, b/cos(c + d*x)), x) rule4163 = ReplacementRule(pattern4163, replacement4163) pattern4164 = Pattern(Integral((a_ + WC('b', S(1))/sin(x_*WC('d', S(1)) + WC('c', S(0))))**n_*(S(1)/tan(x_*WC('d', S(1)) + WC('c', S(0))))**WC('m', S(1)), x_), cons2, cons3, cons7, cons27, cons4, cons1228, cons1267) def replacement4164(m, b, d, c, a, n, x): rubi.append(4164) return -Dist((S(-1))**(m/S(2) + S(-1)/2)*b**(-m + S(1))/d, Subst(Int((a + x)**n*(b**S(2) - x**S(2))**(m/S(2) + S(-1)/2)/x, x), x, b/sin(c + d*x)), x) rule4164 = ReplacementRule(pattern4164, replacement4164) pattern4165 = Pattern(Integral((WC('e', S(1))*tan(x_*WC('d', S(1)) + WC('c', S(0))))**m_*(a_ + WC('b', S(1))/cos(x_*WC('d', S(1)) + WC('c', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons21, cons148) def replacement4165(m, b, d, c, a, n, x, e): rubi.append(4165) return Int(ExpandIntegrand((e*tan(c + d*x))**m, (a + b/cos(c + d*x))**n, x), x) rule4165 = ReplacementRule(pattern4165, replacement4165) pattern4166 = Pattern(Integral((WC('e', S(1))/tan(x_*WC('d', S(1)) + WC('c', S(0))))**m_*(a_ + WC('b', S(1))/sin(x_*WC('d', S(1)) + WC('c', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons21, cons148) def replacement4166(m, b, d, c, a, n, x, e): rubi.append(4166) return Int(ExpandIntegrand((e/tan(c + d*x))**m, (a + b/sin(c + d*x))**n, x), x) rule4166 = ReplacementRule(pattern4166, replacement4166) pattern4167 = Pattern(Integral((a_ + WC('b', S(1))/cos(x_*WC('d', S(1)) + WC('c', S(0))))**WC('n', S(1))*tan(x_*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1)), x_), cons2, cons3, cons7, cons27, cons1265, cons1515, cons1607) def replacement4167(m, b, d, c, n, a, x): rubi.append(4167) return Dist(S(2)*a**(m/S(2) + n + S(1)/2)/d, Subst(Int(x**m*(a*x**S(2) + S(2))**(m/S(2) + n + S(-1)/2)/(a*x**S(2) + S(1)), x), x, tan(c + d*x)/sqrt(a + b/cos(c + d*x))), x) rule4167 = ReplacementRule(pattern4167, replacement4167) pattern4168 = Pattern(Integral((a_ + WC('b', S(1))/sin(x_*WC('d', S(1)) + WC('c', S(0))))**WC('n', S(1))*(S(1)/tan(x_*WC('d', S(1)) + WC('c', S(0))))**WC('m', S(1)), x_), cons2, cons3, cons7, cons27, cons1265, cons1515, cons1607) def replacement4168(m, b, d, c, n, a, x): rubi.append(4168) return Dist(-S(2)*a**(m/S(2) + n + S(1)/2)/d, Subst(Int(x**m*(a*x**S(2) + S(2))**(m/S(2) + n + S(-1)/2)/(a*x**S(2) + S(1)), x), x, S(1)/(sqrt(a + b/sin(c + d*x))*tan(c + d*x))), x) rule4168 = ReplacementRule(pattern4168, replacement4168) pattern4169 = Pattern(Integral((WC('e', S(1))*tan(x_*WC('d', S(1)) + WC('c', S(0))))**m_*(a_ + WC('b', S(1))/cos(x_*WC('d', S(1)) + WC('c', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons21, cons1265, cons196) def replacement4169(m, b, d, c, a, n, x, e): rubi.append(4169) return Dist(a**(S(2)*n)*e**(-S(2)*n), Int((e*tan(c + d*x))**(m + S(2)*n)*(-a + b/cos(c + d*x))**(-n), x), x) rule4169 = ReplacementRule(pattern4169, replacement4169) pattern4170 = Pattern(Integral((WC('e', S(1))/tan(x_*WC('d', S(1)) + WC('c', S(0))))**m_*(a_ + WC('b', S(1))/sin(x_*WC('d', S(1)) + WC('c', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons21, cons1265, cons196) def replacement4170(m, b, d, c, a, n, x, e): rubi.append(4170) return Dist(a**(S(2)*n)*e**(-S(2)*n), Int((e/tan(c + d*x))**(m + S(2)*n)*(-a + b/sin(c + d*x))**(-n), x), x) rule4170 = ReplacementRule(pattern4170, replacement4170) pattern4171 = Pattern(Integral((WC('e', S(1))*tan(x_*WC('d', S(1)) + WC('c', S(0))))**m_*(a_ + WC('b', S(1))/cos(x_*WC('d', S(1)) + WC('c', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons21, cons4, cons1265, cons23) def replacement4171(m, b, d, c, a, n, x, e): rubi.append(4171) return Simp(S(2)**(m + n + S(1))*(a/(a + b/cos(c + d*x)))**(m + n + S(1))*(e*tan(c + d*x))**(m + S(1))*(a + b/cos(c + d*x))**n*AppellF1(m/S(2) + S(1)/2, m + n, S(1), m/S(2) + S(3)/2, -(a - b/cos(c + d*x))/(a + b/cos(c + d*x)), (a - b/cos(c + d*x))/(a + b/cos(c + d*x)))/(d*e*(m + S(1))), x) rule4171 = ReplacementRule(pattern4171, replacement4171) pattern4172 = Pattern(Integral((WC('e', S(1))/tan(x_*WC('d', S(1)) + WC('c', S(0))))**m_*(a_ + WC('b', S(1))/sin(x_*WC('d', S(1)) + WC('c', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons21, cons4, cons1265, cons23) def replacement4172(m, b, d, c, a, n, x, e): rubi.append(4172) return -Simp(S(2)**(m + n + S(1))*(a/(a + b/sin(c + d*x)))**(m + n + S(1))*(e/tan(c + d*x))**(m + S(1))*(a + b/sin(c + d*x))**n*AppellF1(m/S(2) + S(1)/2, m + n, S(1), m/S(2) + S(3)/2, -(a - b/sin(c + d*x))/(a + b/sin(c + d*x)), (a - b/sin(c + d*x))/(a + b/sin(c + d*x)))/(d*e*(m + S(1))), x) rule4172 = ReplacementRule(pattern4172, replacement4172) pattern4173 = Pattern(Integral(sqrt(WC('e', S(1))*tan(x_*WC('d', S(1)) + WC('c', S(0))))/(a_ + WC('b', S(1))/cos(x_*WC('d', S(1)) + WC('c', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons1267) def replacement4173(b, d, c, a, x, e): rubi.append(4173) return Dist(S(1)/a, Int(sqrt(e*tan(c + d*x)), x), x) - Dist(b/a, Int(sqrt(e*tan(c + d*x))/(a*cos(c + d*x) + b), x), x) rule4173 = ReplacementRule(pattern4173, replacement4173) pattern4174 = Pattern(Integral(sqrt(WC('e', S(1))/tan(x_*WC('d', S(1)) + WC('c', S(0))))/(a_ + WC('b', S(1))/sin(x_*WC('d', S(1)) + WC('c', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons1267) def replacement4174(b, d, c, a, x, e): rubi.append(4174) return Dist(S(1)/a, Int(sqrt(e/tan(c + d*x)), x), x) - Dist(b/a, Int(sqrt(e/tan(c + d*x))/(a*sin(c + d*x) + b), x), x) rule4174 = ReplacementRule(pattern4174, replacement4174) pattern4175 = Pattern(Integral((WC('e', S(1))*tan(x_*WC('d', S(1)) + WC('c', S(0))))**m_/(a_ + WC('b', S(1))/cos(x_*WC('d', S(1)) + WC('c', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons1267, cons1311) def replacement4175(m, b, d, c, a, x, e): rubi.append(4175) return -Dist(e**S(2)/b**S(2), Int((e*tan(c + d*x))**(m + S(-2))*(a - b/cos(c + d*x)), x), x) + Dist(e**S(2)*(a**S(2) - b**S(2))/b**S(2), Int((e*tan(c + d*x))**(m + S(-2))/(a + b/cos(c + d*x)), x), x) rule4175 = ReplacementRule(pattern4175, replacement4175) pattern4176 = Pattern(Integral((WC('e', S(1))/tan(x_*WC('d', S(1)) + WC('c', S(0))))**m_/(a_ + WC('b', S(1))/sin(x_*WC('d', S(1)) + WC('c', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons1267, cons1311) def replacement4176(m, b, d, c, a, x, e): rubi.append(4176) return -Dist(e**S(2)/b**S(2), Int((e/tan(c + d*x))**(m + S(-2))*(a - b/sin(c + d*x)), x), x) + Dist(e**S(2)*(a**S(2) - b**S(2))/b**S(2), Int((e/tan(c + d*x))**(m + S(-2))/(a + b/sin(c + d*x)), x), x) rule4176 = ReplacementRule(pattern4176, replacement4176) pattern4177 = Pattern(Integral(S(1)/(sqrt(WC('e', S(1))*tan(x_*WC('d', S(1)) + WC('c', S(0))))*(a_ + WC('b', S(1))/cos(x_*WC('d', S(1)) + WC('c', S(0))))), x_), cons2, cons3, cons7, cons27, cons48, cons1267) def replacement4177(b, d, c, a, x, e): rubi.append(4177) return Dist(S(1)/a, Int(S(1)/sqrt(e*tan(c + d*x)), x), x) - Dist(b/a, Int(S(1)/(sqrt(e*tan(c + d*x))*(a*cos(c + d*x) + b)), x), x) rule4177 = ReplacementRule(pattern4177, replacement4177) pattern4178 = Pattern(Integral(S(1)/(sqrt(WC('e', S(1))/tan(x_*WC('d', S(1)) + WC('c', S(0))))*(a_ + WC('b', S(1))/sin(x_*WC('d', S(1)) + WC('c', S(0))))), x_), cons2, cons3, cons7, cons27, cons48, cons1267) def replacement4178(b, d, c, a, x, e): rubi.append(4178) return Dist(S(1)/a, Int(S(1)/sqrt(e/tan(c + d*x)), x), x) - Dist(b/a, Int(S(1)/(sqrt(e/tan(c + d*x))*(a*sin(c + d*x) + b)), x), x) rule4178 = ReplacementRule(pattern4178, replacement4178) pattern4179 = Pattern(Integral((WC('e', S(1))*tan(x_*WC('d', S(1)) + WC('c', S(0))))**m_/(a_ + WC('b', S(1))/cos(x_*WC('d', S(1)) + WC('c', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons1267, cons1608) def replacement4179(m, b, d, c, a, x, e): rubi.append(4179) return Dist(b**S(2)/(e**S(2)*(a**S(2) - b**S(2))), Int((e*tan(c + d*x))**(m + S(2))/(a + b/cos(c + d*x)), x), x) + Dist(S(1)/(a**S(2) - b**S(2)), Int((e*tan(c + d*x))**m*(a - b/cos(c + d*x)), x), x) rule4179 = ReplacementRule(pattern4179, replacement4179) pattern4180 = Pattern(Integral((WC('e', S(1))/tan(x_*WC('d', S(1)) + WC('c', S(0))))**m_/(a_ + WC('b', S(1))/sin(x_*WC('d', S(1)) + WC('c', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons1267, cons1608) def replacement4180(m, b, d, c, a, x, e): rubi.append(4180) return Dist(b**S(2)/(e**S(2)*(a**S(2) - b**S(2))), Int((e/tan(c + d*x))**(m + S(2))/(a + b/sin(c + d*x)), x), x) + Dist(S(1)/(a**S(2) - b**S(2)), Int((e/tan(c + d*x))**m*(a - b/sin(c + d*x)), x), x) rule4180 = ReplacementRule(pattern4180, replacement4180) pattern4181 = Pattern(Integral((a_ + WC('b', S(1))/cos(x_*WC('d', S(1)) + WC('c', S(0))))**n_*tan(x_*WC('d', S(1)) + WC('c', S(0)))**S(2), x_), cons2, cons3, cons7, cons27, cons1267) def replacement4181(b, d, c, a, n, x): rubi.append(4181) return Int((S(-1) + cos(c + d*x)**(S(-2)))*(a + b/cos(c + d*x))**n, x) rule4181 = ReplacementRule(pattern4181, replacement4181) pattern4182 = Pattern(Integral((a_ + WC('b', S(1))/sin(x_*WC('d', S(1)) + WC('c', S(0))))**n_/tan(x_*WC('d', S(1)) + WC('c', S(0)))**S(2), x_), cons2, cons3, cons7, cons27, cons1267) def replacement4182(b, d, c, a, n, x): rubi.append(4182) return Int((S(-1) + sin(c + d*x)**(S(-2)))*(a + b/sin(c + d*x))**n, x) rule4182 = ReplacementRule(pattern4182, replacement4182) pattern4183 = Pattern(Integral((WC('e', S(1))*tan(x_*WC('d', S(1)) + WC('c', S(0))))**m_*(a_ + WC('b', S(1))/cos(x_*WC('d', S(1)) + WC('c', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons21, cons1267, cons148) def replacement4183(m, b, d, c, a, n, x, e): rubi.append(4183) return Int(ExpandIntegrand((e*tan(c + d*x))**m, (a + b/cos(c + d*x))**n, x), x) rule4183 = ReplacementRule(pattern4183, replacement4183) pattern4184 = Pattern(Integral((WC('e', S(1))/tan(x_*WC('d', S(1)) + WC('c', S(0))))**m_*(a_ + WC('b', S(1))/sin(x_*WC('d', S(1)) + WC('c', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons21, cons1267, cons148) def replacement4184(m, b, d, c, a, n, x, e): rubi.append(4184) return Int(ExpandIntegrand((e/tan(c + d*x))**m, (a + b/sin(c + d*x))**n, x), x) rule4184 = ReplacementRule(pattern4184, replacement4184) pattern4185 = Pattern(Integral((a_ + WC('b', S(1))/cos(x_*WC('d', S(1)) + WC('c', S(0))))**n_*tan(x_*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1)), x_), cons2, cons3, cons7, cons27, cons1267, cons85, cons17, cons1609) def replacement4185(m, b, d, c, a, n, x): rubi.append(4185) return Int((a*cos(c + d*x) + b)**n*sin(c + d*x)**m*cos(c + d*x)**(-m - n), x) rule4185 = ReplacementRule(pattern4185, replacement4185) pattern4186 = Pattern(Integral((a_ + WC('b', S(1))/sin(x_*WC('d', S(1)) + WC('c', S(0))))**n_*(S(1)/tan(x_*WC('d', S(1)) + WC('c', S(0))))**WC('m', S(1)), x_), cons2, cons3, cons7, cons27, cons1267, cons85, cons17, cons1609) def replacement4186(m, b, d, c, a, n, x): rubi.append(4186) return Int((a*sin(c + d*x) + b)**n*sin(c + d*x)**(-m - n)*cos(c + d*x)**m, x) rule4186 = ReplacementRule(pattern4186, replacement4186) pattern4187 = Pattern(Integral((WC('e', S(1))*tan(x_*WC('d', S(1)) + WC('c', S(0))))**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))/cos(x_*WC('d', S(1)) + WC('c', S(0))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons21, cons4, cons1580) def replacement4187(m, b, d, c, a, n, x, e): rubi.append(4187) return Int((e*tan(c + d*x))**m*(a + b/cos(c + d*x))**n, x) rule4187 = ReplacementRule(pattern4187, replacement4187) pattern4188 = Pattern(Integral((WC('e', S(1))/tan(x_*WC('d', S(1)) + WC('c', S(0))))**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))/sin(x_*WC('d', S(1)) + WC('c', S(0))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons21, cons4, cons1580) def replacement4188(m, b, d, a, n, c, x, e): rubi.append(4188) return Int((e/tan(c + d*x))**m*(a + b/sin(c + d*x))**n, x) rule4188 = ReplacementRule(pattern4188, replacement4188) pattern4189 = Pattern(Integral((WC('e', S(1))*tan(x_*WC('d', S(1)) + WC('c', S(0)))**p_)**m_*(a_ + WC('b', S(1))/cos(x_*WC('d', S(1)) + WC('c', S(0))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons21, cons4, cons5, cons18) def replacement4189(p, m, b, d, c, n, a, x, e): rubi.append(4189) return Dist((e*tan(c + d*x))**(-m*p)*(e*tan(c + d*x)**p)**m, Int((e*tan(c + d*x))**(m*p)*(a + b/cos(c + d*x))**n, x), x) rule4189 = ReplacementRule(pattern4189, replacement4189) pattern4190 = Pattern(Integral(((S(1)/tan(x_*WC('d', S(1)) + WC('c', S(0))))**p_*WC('e', S(1)))**m_*(a_ + WC('b', S(1))/sin(x_*WC('d', S(1)) + WC('c', S(0))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons21, cons4, cons5, cons18) def replacement4190(p, m, b, d, c, n, a, x, e): rubi.append(4190) return Dist((e*(S(1)/tan(c + d*x))**p)**m*(e/tan(c + d*x))**(-m*p), Int((e/tan(c + d*x))**(m*p)*(a + b/sin(c + d*x))**n, x), x) rule4190 = ReplacementRule(pattern4190, replacement4190) pattern4191 = Pattern(Integral((a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(c_ + WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons4, cons70, cons1265, cons62, cons196, cons1610) def replacement4191(m, f, b, d, a, c, n, x, e): rubi.append(4191) return Dist(c**n, Int(ExpandTrig((S(1) + d/(c*cos(e + f*x)))**n, (a + b/cos(e + f*x))**m, x), x), x) rule4191 = ReplacementRule(pattern4191, replacement4191) pattern4192 = Pattern(Integral((a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(c_ + WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons4, cons70, cons1265, cons62, cons196, cons1610) def replacement4192(m, f, b, d, a, c, n, x, e): rubi.append(4192) return Dist(c**n, Int(ExpandTrig((S(1) + d/(c*sin(e + f*x)))**n, (a + b/sin(e + f*x))**m, x), x), x) rule4192 = ReplacementRule(pattern4192, replacement4192) pattern4193 = Pattern(Integral((a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(c_ + WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons4, cons70, cons1265, cons17, cons87, cons1611) def replacement4193(m, f, b, d, a, n, c, x, e): rubi.append(4193) return Dist((-a*c)**m, Int((c + d/cos(e + f*x))**(-m + n)*tan(e + f*x)**(S(2)*m), x), x) rule4193 = ReplacementRule(pattern4193, replacement4193) pattern4194 = Pattern(Integral((a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(c_ + WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons4, cons70, cons1265, cons17, cons87, cons1611) def replacement4194(m, f, b, d, a, n, c, x, e): rubi.append(4194) return Dist((-a*c)**m, Int((c + d/sin(e + f*x))**(-m + n)*(S(1)/tan(e + f*x))**(S(2)*m), x), x) rule4194 = ReplacementRule(pattern4194, replacement4194) pattern4195 = Pattern(Integral((a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(c_ + WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons70, cons1265, cons79) def replacement4195(m, f, b, d, a, c, x, e): rubi.append(4195) return Dist((-a*c)**(m + S(1)/2)*tan(e + f*x)/(sqrt(a + b/cos(e + f*x))*sqrt(c + d/cos(e + f*x))), Int(tan(e + f*x)**(S(2)*m), x), x) rule4195 = ReplacementRule(pattern4195, replacement4195) pattern4196 = Pattern(Integral((a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(c_ + WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons70, cons1265, cons79) def replacement4196(m, f, b, d, a, c, x, e): rubi.append(4196) return Dist((-a*c)**(m + S(1)/2)/(sqrt(a + b/sin(e + f*x))*sqrt(c + d/sin(e + f*x))*tan(e + f*x)), Int((S(1)/tan(e + f*x))**(S(2)*m), x), x) rule4196 = ReplacementRule(pattern4196, replacement4196) pattern4197 = Pattern(Integral(sqrt(a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))*(c_ + WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons70, cons1265, cons87, cons1612) def replacement4197(f, b, d, a, n, c, x, e): rubi.append(4197) return Dist(c, Int(sqrt(a + b/cos(e + f*x))*(c + d/cos(e + f*x))**(n + S(-1)), x), x) + Simp(-S(2)*a*c*(c + d/cos(e + f*x))**(n + S(-1))*tan(e + f*x)/(f*sqrt(a + b/cos(e + f*x))*(S(2)*n + S(-1))), x) rule4197 = ReplacementRule(pattern4197, replacement4197) pattern4198 = Pattern(Integral(sqrt(a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))*(c_ + WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons70, cons1265, cons87, cons1612) def replacement4198(f, b, d, a, n, c, x, e): rubi.append(4198) return Dist(c, Int(sqrt(a + b/sin(e + f*x))*(c + d/sin(e + f*x))**(n + S(-1)), x), x) + Simp(S(2)*a*c*(c + d/sin(e + f*x))**(n + S(-1))/(f*sqrt(a + b/sin(e + f*x))*(S(2)*n + S(-1))*tan(e + f*x)), x) rule4198 = ReplacementRule(pattern4198, replacement4198) pattern4199 = Pattern(Integral(sqrt(a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))*(c_ + WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons70, cons1265, cons87, cons1590) def replacement4199(f, b, d, a, c, n, x, e): rubi.append(4199) return Dist(S(1)/c, Int(sqrt(a + b/cos(e + f*x))*(c + d/cos(e + f*x))**(n + S(1)), x), x) + Simp(S(2)*a*(c + d/cos(e + f*x))**n*tan(e + f*x)/(f*sqrt(a + b/cos(e + f*x))*(S(2)*n + S(1))), x) rule4199 = ReplacementRule(pattern4199, replacement4199) pattern4200 = Pattern(Integral(sqrt(a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))*(c_ + WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons70, cons1265, cons87, cons1590) def replacement4200(f, b, d, a, c, n, x, e): rubi.append(4200) return Dist(S(1)/c, Int(sqrt(a + b/sin(e + f*x))*(c + d/sin(e + f*x))**(n + S(1)), x), x) + Simp(-S(2)*a*(c + d/sin(e + f*x))**n/(f*sqrt(a + b/sin(e + f*x))*(S(2)*n + S(1))*tan(e + f*x)), x) rule4200 = ReplacementRule(pattern4200, replacement4200) pattern4201 = Pattern(Integral((a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**(S(3)/2)*(c_ + WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons70, cons1265, cons87, cons1590) def replacement4201(f, b, d, a, n, c, x, e): rubi.append(4201) return Dist(a/c, Int(sqrt(a + b/cos(e + f*x))*(c + d/cos(e + f*x))**(n + S(1)), x), x) + Simp(S(4)*a**S(2)*(c + d/cos(e + f*x))**n*tan(e + f*x)/(f*sqrt(a + b/cos(e + f*x))*(S(2)*n + S(1))), x) rule4201 = ReplacementRule(pattern4201, replacement4201) pattern4202 = Pattern(Integral((a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**(S(3)/2)*(c_ + WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons70, cons1265, cons87, cons1590) def replacement4202(f, b, d, a, n, c, x, e): rubi.append(4202) return Dist(a/c, Int(sqrt(a + b/sin(e + f*x))*(c + d/sin(e + f*x))**(n + S(1)), x), x) + Simp(-S(4)*a**S(2)*(c + d/sin(e + f*x))**n/(f*sqrt(a + b/sin(e + f*x))*(S(2)*n + S(1))*tan(e + f*x)), x) rule4202 = ReplacementRule(pattern4202, replacement4202) pattern4203 = Pattern(Integral((a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**(S(3)/2)*(c_ + WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons4, cons70, cons1265, cons1613) def replacement4203(f, b, d, a, n, c, x, e): rubi.append(4203) return Dist(a, Int(sqrt(a + b/cos(e + f*x))*(c + d/cos(e + f*x))**n, x), x) + Simp(S(2)*a**S(2)*(c + d/cos(e + f*x))**n*tan(e + f*x)/(f*sqrt(a + b/cos(e + f*x))*(S(2)*n + S(1))), x) rule4203 = ReplacementRule(pattern4203, replacement4203) pattern4204 = Pattern(Integral((a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**(S(3)/2)*(c_ + WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons4, cons70, cons1265, cons1613) def replacement4204(f, b, d, a, n, c, x, e): rubi.append(4204) return Dist(a, Int(sqrt(a + b/sin(e + f*x))*(c + d/sin(e + f*x))**n, x), x) + Simp(-S(2)*a**S(2)*(c + d/sin(e + f*x))**n/(f*sqrt(a + b/sin(e + f*x))*(S(2)*n + S(1))*tan(e + f*x)), x) rule4204 = ReplacementRule(pattern4204, replacement4204) pattern4205 = Pattern(Integral((a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**(S(5)/2)*(c_ + WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons70, cons1265, cons87, cons1590) def replacement4205(f, b, d, a, n, c, x, e): rubi.append(4205) return Dist(a**S(2)/c**S(2), Int(sqrt(a + b/cos(e + f*x))*(c + d/cos(e + f*x))**(n + S(2)), x), x) + Simp(S(8)*a**S(3)*(c + d/cos(e + f*x))**n*tan(e + f*x)/(f*sqrt(a + b/cos(e + f*x))*(S(2)*n + S(1))), x) rule4205 = ReplacementRule(pattern4205, replacement4205) pattern4206 = Pattern(Integral((a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**(S(5)/2)*(c_ + WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons70, cons1265, cons87, cons1590) def replacement4206(f, b, d, a, n, c, x, e): rubi.append(4206) return Dist(a**S(2)/c**S(2), Int(sqrt(a + b/sin(e + f*x))*(c + d/sin(e + f*x))**(n + S(2)), x), x) + Simp(-S(8)*a**S(3)*(c + d/sin(e + f*x))**n/(f*sqrt(a + b/sin(e + f*x))*(S(2)*n + S(1))*tan(e + f*x)), x) rule4206 = ReplacementRule(pattern4206, replacement4206) pattern4207 = Pattern(Integral((a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(c_ + WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons70, cons1265, cons1304, cons1255) def replacement4207(m, f, b, d, a, c, n, x, e): rubi.append(4207) return Dist(a*c*tan(e + f*x)/(f*sqrt(a + b/cos(e + f*x))*sqrt(c + d/cos(e + f*x))), Subst(Int(x**(-m - n)*(a*x + b)**(m + S(-1)/2)*(c*x + d)**(n + S(-1)/2), x), x, cos(e + f*x)), x) rule4207 = ReplacementRule(pattern4207, replacement4207) pattern4208 = Pattern(Integral((a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(c_ + WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons70, cons1265, cons1304, cons1255) def replacement4208(m, f, b, d, a, c, n, x, e): rubi.append(4208) return -Dist(a*c/(f*sqrt(a + b/sin(e + f*x))*sqrt(c + d/sin(e + f*x))*tan(e + f*x)), Subst(Int(x**(-m - n)*(a*x + b)**(m + S(-1)/2)*(c*x + d)**(n + S(-1)/2), x), x, sin(e + f*x)), x) rule4208 = ReplacementRule(pattern4208, replacement4208) pattern4209 = Pattern(Integral((a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(c_ + WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons4, cons70, cons1265) def replacement4209(m, f, b, d, a, n, c, x, e): rubi.append(4209) return -Dist(a*c*tan(e + f*x)/(f*sqrt(a + b/cos(e + f*x))*sqrt(c + d/cos(e + f*x))), Subst(Int((a + b*x)**(m + S(-1)/2)*(c + d*x)**(n + S(-1)/2)/x, x), x, S(1)/cos(e + f*x)), x) rule4209 = ReplacementRule(pattern4209, replacement4209) pattern4210 = Pattern(Integral((a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(c_ + WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons4, cons70, cons1265) def replacement4210(m, f, b, d, a, n, c, x, e): rubi.append(4210) return Dist(a*c/(f*sqrt(a + b/sin(e + f*x))*sqrt(c + d/sin(e + f*x))*tan(e + f*x)), Subst(Int((a + b*x)**(m + S(-1)/2)*(c + d*x)**(n + S(-1)/2)/x, x), x, S(1)/sin(e + f*x)), x) rule4210 = ReplacementRule(pattern4210, replacement4210) pattern4211 = Pattern(Integral((a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))*(c_ + WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons70) def replacement4211(f, b, d, a, c, x, e): rubi.append(4211) return Dist(b*d, Int(cos(e + f*x)**(S(-2)), x), x) + Simp(a*c*x, x) rule4211 = ReplacementRule(pattern4211, replacement4211) pattern4212 = Pattern(Integral((a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))*(c_ + WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons70) def replacement4212(f, b, d, a, c, x, e): rubi.append(4212) return Dist(b*d, Int(sin(e + f*x)**(S(-2)), x), x) + Simp(a*c*x, x) rule4212 = ReplacementRule(pattern4212, replacement4212) pattern4213 = Pattern(Integral((a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))*(c_ + WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1412) def replacement4213(f, b, d, a, c, x, e): rubi.append(4213) return Dist(b*d, Int(cos(e + f*x)**(S(-2)), x), x) + Dist(a*d + b*c, Int(S(1)/cos(e + f*x), x), x) + Simp(a*c*x, x) rule4213 = ReplacementRule(pattern4213, replacement4213) pattern4214 = Pattern(Integral((a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))*(c_ + WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1412) def replacement4214(f, b, d, a, c, x, e): rubi.append(4214) return Dist(b*d, Int(sin(e + f*x)**(S(-2)), x), x) + Dist(a*d + b*c, Int(S(1)/sin(e + f*x), x), x) + Simp(a*c*x, x) rule4214 = ReplacementRule(pattern4214, replacement4214) pattern4215 = Pattern(Integral(sqrt(a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))*(c_ + WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1265) def replacement4215(f, b, d, a, c, x, e): rubi.append(4215) return Dist(c, Int(sqrt(a + b/cos(e + f*x)), x), x) + Dist(d, Int(sqrt(a + b/cos(e + f*x))/cos(e + f*x), x), x) rule4215 = ReplacementRule(pattern4215, replacement4215) pattern4216 = Pattern(Integral(sqrt(a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))*(c_ + WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1265) def replacement4216(f, b, d, a, c, x, e): rubi.append(4216) return Dist(c, Int(sqrt(a + b/sin(e + f*x)), x), x) + Dist(d, Int(sqrt(a + b/sin(e + f*x))/sin(e + f*x), x), x) rule4216 = ReplacementRule(pattern4216, replacement4216) pattern4217 = Pattern(Integral(sqrt(a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))*(c_ + WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1267) def replacement4217(f, b, d, a, c, x, e): rubi.append(4217) return Dist(a*c, Int(S(1)/sqrt(a + b/cos(e + f*x)), x), x) + Int((a*d + b*c + b*d/cos(e + f*x))/(sqrt(a + b/cos(e + f*x))*cos(e + f*x)), x) rule4217 = ReplacementRule(pattern4217, replacement4217) pattern4218 = Pattern(Integral(sqrt(a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))*(c_ + WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1267) def replacement4218(f, b, d, a, c, x, e): rubi.append(4218) return Dist(a*c, Int(S(1)/sqrt(a + b/sin(e + f*x)), x), x) + Int((a*d + b*c + b*d/sin(e + f*x))/(sqrt(a + b/sin(e + f*x))*sin(e + f*x)), x) rule4218 = ReplacementRule(pattern4218, replacement4218) pattern4219 = Pattern(Integral((a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(c_ + WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons31, cons166, cons1265, cons515) def replacement4219(m, f, b, d, a, c, x, e): rubi.append(4219) return Dist(S(1)/m, Int((a + b/cos(e + f*x))**(m + S(-1))*Simp(a*c*m + (a*d*(S(2)*m + S(-1)) + b*c*m)/cos(e + f*x), x), x), x) + Simp(b*d*(a + b/cos(e + f*x))**(m + S(-1))*tan(e + f*x)/(f*m), x) rule4219 = ReplacementRule(pattern4219, replacement4219) pattern4220 = Pattern(Integral((a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(c_ + WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons31, cons166, cons1265, cons515) def replacement4220(m, f, b, d, a, c, x, e): rubi.append(4220) return Dist(S(1)/m, Int((a + b/sin(e + f*x))**(m + S(-1))*Simp(a*c*m + (a*d*(S(2)*m + S(-1)) + b*c*m)/sin(e + f*x), x), x), x) - Simp(b*d*(a + b/sin(e + f*x))**(m + S(-1))/(f*m*tan(e + f*x)), x) rule4220 = ReplacementRule(pattern4220, replacement4220) pattern4221 = Pattern(Integral((a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(c_ + WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons31, cons166, cons1267, cons515) def replacement4221(m, f, b, d, a, c, x, e): rubi.append(4221) return Dist(S(1)/m, Int((a + b/cos(e + f*x))**(m + S(-2))*Simp(a**S(2)*c*m + b*(a*d*(S(2)*m + S(-1)) + b*c*m)/cos(e + f*x)**S(2) + (a**S(2)*d*m + S(2)*a*b*c*m + b**S(2)*d*(m + S(-1)))/cos(e + f*x), x), x), x) + Simp(b*d*(a + b/cos(e + f*x))**(m + S(-1))*tan(e + f*x)/(f*m), x) rule4221 = ReplacementRule(pattern4221, replacement4221) pattern4222 = Pattern(Integral((a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(c_ + WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons31, cons166, cons1267, cons515) def replacement4222(m, f, b, d, a, c, x, e): rubi.append(4222) return Dist(S(1)/m, Int((a + b/sin(e + f*x))**(m + S(-2))*Simp(a**S(2)*c*m + b*(a*d*(S(2)*m + S(-1)) + b*c*m)/sin(e + f*x)**S(2) + (a**S(2)*d*m + S(2)*a*b*c*m + b**S(2)*d*(m + S(-1)))/sin(e + f*x), x), x), x) - Simp(b*d*(a + b/sin(e + f*x))**(m + S(-1))/(f*m*tan(e + f*x)), x) rule4222 = ReplacementRule(pattern4222, replacement4222) pattern4223 = Pattern(Integral((c_ + WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))/(a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71) def replacement4223(f, b, d, a, c, x, e): rubi.append(4223) return -Dist((-a*d + b*c)/a, Int(S(1)/((a + b/cos(e + f*x))*cos(e + f*x)), x), x) + Simp(c*x/a, x) rule4223 = ReplacementRule(pattern4223, replacement4223) pattern4224 = Pattern(Integral((c_ + WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))/(a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71) def replacement4224(f, b, d, a, c, x, e): rubi.append(4224) return -Dist((-a*d + b*c)/a, Int(S(1)/((a + b/sin(e + f*x))*sin(e + f*x)), x), x) + Simp(c*x/a, x) rule4224 = ReplacementRule(pattern4224, replacement4224) pattern4225 = Pattern(Integral((c_ + WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))/sqrt(a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1265) def replacement4225(f, b, d, a, c, x, e): rubi.append(4225) return Dist(c/a, Int(sqrt(a + b/cos(e + f*x)), x), x) - Dist((-a*d + b*c)/a, Int(S(1)/(sqrt(a + b/cos(e + f*x))*cos(e + f*x)), x), x) rule4225 = ReplacementRule(pattern4225, replacement4225) pattern4226 = Pattern(Integral((c_ + WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))/sqrt(a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1265) def replacement4226(f, b, d, a, c, x, e): rubi.append(4226) return Dist(c/a, Int(sqrt(a + b/sin(e + f*x)), x), x) - Dist((-a*d + b*c)/a, Int(S(1)/(sqrt(a + b/sin(e + f*x))*sin(e + f*x)), x), x) rule4226 = ReplacementRule(pattern4226, replacement4226) pattern4227 = Pattern(Integral((c_ + WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))/sqrt(a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1267) def replacement4227(f, b, d, a, c, x, e): rubi.append(4227) return Dist(c, Int(S(1)/sqrt(a + b/cos(e + f*x)), x), x) + Dist(d, Int(S(1)/(sqrt(a + b/cos(e + f*x))*cos(e + f*x)), x), x) rule4227 = ReplacementRule(pattern4227, replacement4227) pattern4228 = Pattern(Integral((c_ + WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))/sqrt(a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1267) def replacement4228(f, b, d, a, c, x, e): rubi.append(4228) return Dist(c, Int(S(1)/sqrt(a + b/sin(e + f*x)), x), x) + Dist(d, Int(S(1)/(sqrt(a + b/sin(e + f*x))*sin(e + f*x)), x), x) rule4228 = ReplacementRule(pattern4228, replacement4228) pattern4229 = Pattern(Integral((a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(c_ + WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons31, cons94, cons1265, cons515) def replacement4229(m, f, b, d, a, c, x, e): rubi.append(4229) return Dist(S(1)/(a**S(2)*(S(2)*m + S(1))), Int((a + b/cos(e + f*x))**(m + S(1))*Simp(a*c*(S(2)*m + S(1)) - (m + S(1))*(-a*d + b*c)/cos(e + f*x), x), x), x) + Simp((a + b/cos(e + f*x))**m*(-a*d + b*c)*tan(e + f*x)/(b*f*(S(2)*m + S(1))), x) rule4229 = ReplacementRule(pattern4229, replacement4229) pattern4230 = Pattern(Integral((a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(c_ + WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons31, cons94, cons1265, cons515) def replacement4230(m, f, b, d, a, c, x, e): rubi.append(4230) return Dist(S(1)/(a**S(2)*(S(2)*m + S(1))), Int((a + b/sin(e + f*x))**(m + S(1))*Simp(a*c*(S(2)*m + S(1)) - (m + S(1))*(-a*d + b*c)/sin(e + f*x), x), x), x) - Simp((a + b/sin(e + f*x))**m*(-a*d + b*c)/(b*f*(S(2)*m + S(1))*tan(e + f*x)), x) rule4230 = ReplacementRule(pattern4230, replacement4230) pattern4231 = Pattern(Integral((a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(c_ + WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons31, cons94, cons1267, cons515) def replacement4231(m, f, b, d, a, c, x, e): rubi.append(4231) return Dist(S(1)/(a*(a**S(2) - b**S(2))*(m + S(1))), Int((a + b/cos(e + f*x))**(m + S(1))*Simp(-a*(m + S(1))*(-a*d + b*c)/cos(e + f*x) + b*(m + S(2))*(-a*d + b*c)/cos(e + f*x)**S(2) + c*(a**S(2) - b**S(2))*(m + S(1)), x), x), x) - Simp(b*(a + b/cos(e + f*x))**(m + S(1))*(-a*d + b*c)*tan(e + f*x)/(a*f*(a**S(2) - b**S(2))*(m + S(1))), x) rule4231 = ReplacementRule(pattern4231, replacement4231) pattern4232 = Pattern(Integral((a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(c_ + WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons31, cons94, cons1267, cons515) def replacement4232(m, f, b, d, a, c, x, e): rubi.append(4232) return Dist(S(1)/(a*(a**S(2) - b**S(2))*(m + S(1))), Int((a + b/sin(e + f*x))**(m + S(1))*Simp(-a*(m + S(1))*(-a*d + b*c)/sin(e + f*x) + b*(m + S(2))*(-a*d + b*c)/sin(e + f*x)**S(2) + c*(a**S(2) - b**S(2))*(m + S(1)), x), x), x) + Simp(b*(a + b/sin(e + f*x))**(m + S(1))*(-a*d + b*c)/(a*f*(a**S(2) - b**S(2))*(m + S(1))*tan(e + f*x)), x) rule4232 = ReplacementRule(pattern4232, replacement4232) pattern4233 = Pattern(Integral((a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(c_ + WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons71, cons77) def replacement4233(m, f, b, d, a, c, x, e): rubi.append(4233) return Dist(c, Int((a + b/cos(e + f*x))**m, x), x) + Dist(d, Int((a + b/cos(e + f*x))**m/cos(e + f*x), x), x) rule4233 = ReplacementRule(pattern4233, replacement4233) pattern4234 = Pattern(Integral((a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(c_ + WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons71, cons77) def replacement4234(m, f, b, d, a, c, x, e): rubi.append(4234) return Dist(c, Int((a + b/sin(e + f*x))**m, x), x) + Dist(d, Int((a + b/sin(e + f*x))**m/sin(e + f*x), x), x) rule4234 = ReplacementRule(pattern4234, replacement4234) pattern4235 = Pattern(Integral(sqrt(a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))/(c_ + WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1409) def replacement4235(f, b, d, a, c, x, e): rubi.append(4235) return Dist(S(1)/c, Int(sqrt(a + b/cos(e + f*x)), x), x) - Dist(d/c, Int(sqrt(a + b/cos(e + f*x))/((c + d/cos(e + f*x))*cos(e + f*x)), x), x) rule4235 = ReplacementRule(pattern4235, replacement4235) pattern4236 = Pattern(Integral(sqrt(a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))/(c_ + WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1409) def replacement4236(f, b, d, a, c, x, e): rubi.append(4236) return Dist(S(1)/c, Int(sqrt(a + b/sin(e + f*x)), x), x) - Dist(d/c, Int(sqrt(a + b/sin(e + f*x))/((c + d/sin(e + f*x))*sin(e + f*x)), x), x) rule4236 = ReplacementRule(pattern4236, replacement4236) pattern4237 = Pattern(Integral(sqrt(a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))/(c_ + WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1267, cons1323) def replacement4237(f, b, d, a, c, x, e): rubi.append(4237) return Dist(a/c, Int(S(1)/sqrt(a + b/cos(e + f*x)), x), x) + Dist((-a*d + b*c)/c, Int(S(1)/(sqrt(a + b/cos(e + f*x))*(c + d/cos(e + f*x))*cos(e + f*x)), x), x) rule4237 = ReplacementRule(pattern4237, replacement4237) pattern4238 = Pattern(Integral(sqrt(a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))/(c_ + WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1267, cons1323) def replacement4238(f, b, d, a, c, x, e): rubi.append(4238) return Dist(a/c, Int(S(1)/sqrt(a + b/sin(e + f*x)), x), x) + Dist((-a*d + b*c)/c, Int(S(1)/(sqrt(a + b/sin(e + f*x))*(c + d/sin(e + f*x))*sin(e + f*x)), x), x) rule4238 = ReplacementRule(pattern4238, replacement4238) pattern4239 = Pattern(Integral((a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**(S(3)/2)/(c_ + WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1409) def replacement4239(f, b, d, a, c, x, e): rubi.append(4239) return Dist(a/c, Int(sqrt(a + b/cos(e + f*x)), x), x) + Dist((-a*d + b*c)/c, Int(sqrt(a + b/cos(e + f*x))/((c + d/cos(e + f*x))*cos(e + f*x)), x), x) rule4239 = ReplacementRule(pattern4239, replacement4239) pattern4240 = Pattern(Integral((a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**(S(3)/2)/(c_ + WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1409) def replacement4240(f, b, d, a, c, x, e): rubi.append(4240) return Dist(a/c, Int(sqrt(a + b/sin(e + f*x)), x), x) + Dist((-a*d + b*c)/c, Int(sqrt(a + b/sin(e + f*x))/((c + d/sin(e + f*x))*sin(e + f*x)), x), x) rule4240 = ReplacementRule(pattern4240, replacement4240) pattern4241 = Pattern(Integral((a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**(S(3)/2)/(c_ + WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1267, cons1323) def replacement4241(f, b, d, a, c, x, e): rubi.append(4241) return Dist(S(1)/(c*d), Int((a**S(2)*d + b**S(2)*c/cos(e + f*x))/sqrt(a + b/cos(e + f*x)), x), x) - Dist((-a*d + b*c)**S(2)/(c*d), Int(S(1)/(sqrt(a + b/cos(e + f*x))*(c + d/cos(e + f*x))*cos(e + f*x)), x), x) rule4241 = ReplacementRule(pattern4241, replacement4241) pattern4242 = Pattern(Integral((a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**(S(3)/2)/(c_ + WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1267, cons1323) def replacement4242(f, b, d, a, c, x, e): rubi.append(4242) return Dist(S(1)/(c*d), Int((a**S(2)*d + b**S(2)*c/sin(e + f*x))/sqrt(a + b/sin(e + f*x)), x), x) - Dist((-a*d + b*c)**S(2)/(c*d), Int(S(1)/(sqrt(a + b/sin(e + f*x))*(c + d/sin(e + f*x))*sin(e + f*x)), x), x) rule4242 = ReplacementRule(pattern4242, replacement4242) pattern4243 = Pattern(Integral(S(1)/(sqrt(a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))*(c_ + WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1409) def replacement4243(f, b, d, a, c, x, e): rubi.append(4243) return Dist(S(1)/(c*(-a*d + b*c)), Int((-a*d + b*c - b*d/cos(e + f*x))/sqrt(a + b/cos(e + f*x)), x), x) + Dist(d**S(2)/(c*(-a*d + b*c)), Int(sqrt(a + b/cos(e + f*x))/((c + d/cos(e + f*x))*cos(e + f*x)), x), x) rule4243 = ReplacementRule(pattern4243, replacement4243) pattern4244 = Pattern(Integral(S(1)/(sqrt(a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))*(c_ + WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1409) def replacement4244(f, b, d, a, c, x, e): rubi.append(4244) return Dist(S(1)/(c*(-a*d + b*c)), Int((-a*d + b*c - b*d/sin(e + f*x))/sqrt(a + b/sin(e + f*x)), x), x) + Dist(d**S(2)/(c*(-a*d + b*c)), Int(sqrt(a + b/sin(e + f*x))/((c + d/sin(e + f*x))*sin(e + f*x)), x), x) rule4244 = ReplacementRule(pattern4244, replacement4244) pattern4245 = Pattern(Integral(S(1)/(sqrt(a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))*(c_ + WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1267) def replacement4245(f, b, d, a, c, x, e): rubi.append(4245) return Dist(S(1)/c, Int(S(1)/sqrt(a + b/cos(e + f*x)), x), x) - Dist(d/c, Int(S(1)/(sqrt(a + b/cos(e + f*x))*(c + d/cos(e + f*x))*cos(e + f*x)), x), x) rule4245 = ReplacementRule(pattern4245, replacement4245) pattern4246 = Pattern(Integral(S(1)/(sqrt(a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))*(c_ + WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1267) def replacement4246(f, b, d, a, c, x, e): rubi.append(4246) return Dist(S(1)/c, Int(S(1)/sqrt(a + b/sin(e + f*x)), x), x) - Dist(d/c, Int(S(1)/(sqrt(a + b/sin(e + f*x))*(c + d/sin(e + f*x))*sin(e + f*x)), x), x) rule4246 = ReplacementRule(pattern4246, replacement4246) pattern4247 = Pattern(Integral(sqrt(a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))*sqrt(c_ + WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1265, cons1322) def replacement4247(f, b, d, a, c, x, e): rubi.append(4247) return Dist(sqrt(a + b/cos(e + f*x))*sqrt(c + d/cos(e + f*x))/tan(e + f*x), Int(tan(e + f*x), x), x) rule4247 = ReplacementRule(pattern4247, replacement4247) pattern4248 = Pattern(Integral(sqrt(a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))*sqrt(c_ + WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1265, cons1322) def replacement4248(f, b, d, a, c, x, e): rubi.append(4248) return Dist(sqrt(a + b/sin(e + f*x))*sqrt(c + d/sin(e + f*x))*tan(e + f*x), Int(S(1)/tan(e + f*x), x), x) rule4248 = ReplacementRule(pattern4248, replacement4248) pattern4249 = Pattern(Integral(sqrt(a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))*sqrt(c_ + WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71) def replacement4249(f, b, d, a, c, x, e): rubi.append(4249) return Dist(c, Int(sqrt(a + b/cos(e + f*x))/sqrt(c + d/cos(e + f*x)), x), x) + Dist(d, Int(sqrt(a + b/cos(e + f*x))/(sqrt(c + d/cos(e + f*x))*cos(e + f*x)), x), x) rule4249 = ReplacementRule(pattern4249, replacement4249) pattern4250 = Pattern(Integral(sqrt(a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))*sqrt(c_ + WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71) def replacement4250(f, b, d, a, c, x, e): rubi.append(4250) return Dist(c, Int(sqrt(a + b/sin(e + f*x))/sqrt(c + d/sin(e + f*x)), x), x) + Dist(d, Int(sqrt(a + b/sin(e + f*x))/(sqrt(c + d/sin(e + f*x))*sin(e + f*x)), x), x) rule4250 = ReplacementRule(pattern4250, replacement4250) pattern4251 = Pattern(Integral(sqrt(a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))/sqrt(c_ + WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1265, cons1322) def replacement4251(f, b, d, a, c, x, e): rubi.append(4251) return Dist(S(1)/c, Int(sqrt(a + b/cos(e + f*x))*sqrt(c + d/cos(e + f*x)), x), x) - Dist(d/c, Int(sqrt(a + b/cos(e + f*x))/(sqrt(c + d/cos(e + f*x))*cos(e + f*x)), x), x) rule4251 = ReplacementRule(pattern4251, replacement4251) pattern4252 = Pattern(Integral(sqrt(a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))/sqrt(c_ + WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1265, cons1322) def replacement4252(f, b, d, a, c, x, e): rubi.append(4252) return Dist(S(1)/c, Int(sqrt(a + b/sin(e + f*x))*sqrt(c + d/sin(e + f*x)), x), x) - Dist(d/c, Int(sqrt(a + b/sin(e + f*x))/(sqrt(c + d/sin(e + f*x))*sin(e + f*x)), x), x) rule4252 = ReplacementRule(pattern4252, replacement4252) pattern4253 = Pattern(Integral(sqrt(a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))/sqrt(c_ + WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1265, cons1323) def replacement4253(f, b, d, a, c, x, e): rubi.append(4253) return Dist(S(2)*a/f, Subst(Int(S(1)/(a*c*x**S(2) + S(1)), x), x, tan(e + f*x)/(sqrt(a + b/cos(e + f*x))*sqrt(c + d/cos(e + f*x)))), x) rule4253 = ReplacementRule(pattern4253, replacement4253) pattern4254 = Pattern(Integral(sqrt(a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))/sqrt(c_ + WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1265, cons1323) def replacement4254(f, b, d, a, c, x, e): rubi.append(4254) return Dist(-S(2)*a/f, Subst(Int(S(1)/(a*c*x**S(2) + S(1)), x), x, S(1)/(sqrt(a + b/sin(e + f*x))*sqrt(c + d/sin(e + f*x))*tan(e + f*x))), x) rule4254 = ReplacementRule(pattern4254, replacement4254) pattern4255 = Pattern(Integral(sqrt(a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))/sqrt(c_ + WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1267, cons1322) def replacement4255(f, b, d, a, c, x, e): rubi.append(4255) return Dist(a/c, Int(sqrt(c + d/cos(e + f*x))/sqrt(a + b/cos(e + f*x)), x), x) + Dist((-a*d + b*c)/c, Int(S(1)/(sqrt(a + b/cos(e + f*x))*sqrt(c + d/cos(e + f*x))*cos(e + f*x)), x), x) rule4255 = ReplacementRule(pattern4255, replacement4255) pattern4256 = Pattern(Integral(sqrt(a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))/sqrt(c_ + WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1267, cons1322) def replacement4256(f, b, d, a, c, x, e): rubi.append(4256) return Dist(a/c, Int(sqrt(c + d/sin(e + f*x))/sqrt(a + b/sin(e + f*x)), x), x) + Dist((-a*d + b*c)/c, Int(S(1)/(sqrt(a + b/sin(e + f*x))*sqrt(c + d/sin(e + f*x))*sin(e + f*x)), x), x) rule4256 = ReplacementRule(pattern4256, replacement4256) pattern4257 = Pattern(Integral(sqrt(a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))/sqrt(c_ + WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1267, cons1323) def replacement4257(f, b, d, a, c, x, e): rubi.append(4257) return Simp(-S(2)*sqrt((S(1) + S(1)/cos(e + f*x))*(-a*d + b*c)/((a + b/cos(e + f*x))*(c - d)))*sqrt(-(S(1) - S(1)/cos(e + f*x))*(-a*d + b*c)/((a + b/cos(e + f*x))*(c + d)))*(a + b/cos(e + f*x))*EllipticPi(a*(c + d)/(c*(a + b)), asin(sqrt(c + d/cos(e + f*x))*Rt((a + b)/(c + d), S(2))/sqrt(a + b/cos(e + f*x))), (a - b)*(c + d)/((a + b)*(c - d)))/(c*f*Rt((a + b)/(c + d), S(2))*tan(e + f*x)), x) rule4257 = ReplacementRule(pattern4257, replacement4257) pattern4258 = Pattern(Integral(sqrt(a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))/sqrt(c_ + WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1267, cons1323) def replacement4258(f, b, d, a, c, x, e): rubi.append(4258) return Simp(S(2)*sqrt((S(1) + S(1)/sin(e + f*x))*(-a*d + b*c)/((a + b/sin(e + f*x))*(c - d)))*sqrt(-(S(1) - S(1)/sin(e + f*x))*(-a*d + b*c)/((a + b/sin(e + f*x))*(c + d)))*(a + b/sin(e + f*x))*EllipticPi(a*(c + d)/(c*(a + b)), asin(sqrt(c + d/sin(e + f*x))*Rt((a + b)/(c + d), S(2))/sqrt(a + b/sin(e + f*x))), (a - b)*(c + d)/((a + b)*(c - d)))*tan(e + f*x)/(c*f*Rt((a + b)/(c + d), S(2))), x) rule4258 = ReplacementRule(pattern4258, replacement4258) pattern4259 = Pattern(Integral(S(1)/(sqrt(a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))*sqrt(c_ + WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1265, cons1322) def replacement4259(f, b, d, a, c, x, e): rubi.append(4259) return Dist(tan(e + f*x)/(sqrt(a + b/cos(e + f*x))*sqrt(c + d/cos(e + f*x))), Int(S(1)/tan(e + f*x), x), x) rule4259 = ReplacementRule(pattern4259, replacement4259) pattern4260 = Pattern(Integral(S(1)/(sqrt(a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))*sqrt(c_ + WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1265, cons1322) def replacement4260(f, b, d, a, c, x, e): rubi.append(4260) return Dist(S(1)/(sqrt(a + b/sin(e + f*x))*sqrt(c + d/sin(e + f*x))*tan(e + f*x)), Int(tan(e + f*x), x), x) rule4260 = ReplacementRule(pattern4260, replacement4260) pattern4261 = Pattern(Integral(S(1)/(sqrt(a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))*sqrt(c_ + WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71) def replacement4261(f, b, d, a, c, x, e): rubi.append(4261) return Dist(S(1)/a, Int(sqrt(a + b/cos(e + f*x))/sqrt(c + d/cos(e + f*x)), x), x) - Dist(b/a, Int(S(1)/(sqrt(a + b/cos(e + f*x))*sqrt(c + d/cos(e + f*x))*cos(e + f*x)), x), x) rule4261 = ReplacementRule(pattern4261, replacement4261) pattern4262 = Pattern(Integral(S(1)/(sqrt(a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))*sqrt(c_ + WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71) def replacement4262(f, b, d, a, c, x, e): rubi.append(4262) return Dist(S(1)/a, Int(sqrt(a + b/sin(e + f*x))/sqrt(c + d/sin(e + f*x)), x), x) - Dist(b/a, Int(S(1)/(sqrt(a + b/sin(e + f*x))*sqrt(c + d/sin(e + f*x))*sin(e + f*x)), x), x) rule4262 = ReplacementRule(pattern4262, replacement4262) pattern4263 = Pattern(Integral(sqrt(a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))/(c_ + WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**(S(3)/2), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1323) def replacement4263(f, b, d, a, c, x, e): rubi.append(4263) return Dist(S(1)/c, Int(sqrt(a + b/cos(e + f*x))/sqrt(c + d/cos(e + f*x)), x), x) - Dist(d/c, Int(sqrt(a + b/cos(e + f*x))/((c + d/cos(e + f*x))**(S(3)/2)*cos(e + f*x)), x), x) rule4263 = ReplacementRule(pattern4263, replacement4263) pattern4264 = Pattern(Integral(sqrt(a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))/(c_ + WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**(S(3)/2), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1323) def replacement4264(f, b, d, a, c, x, e): rubi.append(4264) return Dist(S(1)/c, Int(sqrt(a + b/sin(e + f*x))/sqrt(c + d/sin(e + f*x)), x), x) - Dist(d/c, Int(sqrt(a + b/sin(e + f*x))/((c + d/sin(e + f*x))**(S(3)/2)*sin(e + f*x)), x), x) rule4264 = ReplacementRule(pattern4264, replacement4264) pattern4265 = Pattern(Integral((a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(c_ + WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons4, cons71, cons1265, cons1323, cons1304) def replacement4265(m, f, b, d, a, n, c, x, e): rubi.append(4265) return -Dist(a**S(2)*tan(e + f*x)/(f*sqrt(a - b/cos(e + f*x))*sqrt(a + b/cos(e + f*x))), Subst(Int((a + b*x)**(m + S(-1)/2)*(c + d*x)**n/(x*sqrt(a - b*x)), x), x, S(1)/cos(e + f*x)), x) rule4265 = ReplacementRule(pattern4265, replacement4265) pattern4266 = Pattern(Integral((a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(c_ + WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons4, cons71, cons1265, cons1323, cons1304) def replacement4266(m, f, b, d, a, n, c, x, e): rubi.append(4266) return Dist(a**S(2)*cos(e + f*x)/(f*sqrt(a - b/sin(e + f*x))*sqrt(a + b/sin(e + f*x))), Subst(Int((a + b*x)**(m + S(-1)/2)*(c + d*x)**n/(x*sqrt(a - b*x)), x), x, S(1)/sin(e + f*x)), x) rule4266 = ReplacementRule(pattern4266, replacement4266) pattern4267 = Pattern(Integral((a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(c_ + WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons4, cons71, cons17, cons85, cons1614) def replacement4267(m, f, b, d, a, c, n, x, e): rubi.append(4267) return Int((a*cos(e + f*x) + b)**m*(c*cos(e + f*x) + d)**n*cos(e + f*x)**(-m - n), x) rule4267 = ReplacementRule(pattern4267, replacement4267) pattern4268 = Pattern(Integral((a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(c_ + WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons4, cons71, cons17, cons85, cons1614) def replacement4268(m, f, b, d, a, c, n, x, e): rubi.append(4268) return Int((a*sin(e + f*x) + b)**m*(c*sin(e + f*x) + d)**n*sin(e + f*x)**(-m - n), x) rule4268 = ReplacementRule(pattern4268, replacement4268) pattern4269 = Pattern(Integral((a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(c_ + WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons4, cons71, cons79, cons80, cons1614) def replacement4269(m, f, b, d, a, c, n, x, e): rubi.append(4269) return Dist(sqrt(a + b/cos(e + f*x))*sqrt(c*cos(e + f*x) + d)/(sqrt(c + d/cos(e + f*x))*sqrt(a*cos(e + f*x) + b)), Int((a*cos(e + f*x) + b)**m*(c*cos(e + f*x) + d)**n*cos(e + f*x)**(-m - n), x), x) rule4269 = ReplacementRule(pattern4269, replacement4269) pattern4270 = Pattern(Integral((a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(c_ + WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons4, cons71, cons79, cons80, cons1614) def replacement4270(m, f, b, d, a, c, n, x, e): rubi.append(4270) return Dist(sqrt(a + b/sin(e + f*x))*sqrt(c*sin(e + f*x) + d)/(sqrt(c + d/sin(e + f*x))*sqrt(a*sin(e + f*x) + b)), Int((a*sin(e + f*x) + b)**m*(c*sin(e + f*x) + d)**n*sin(e + f*x)**(-m - n), x), x) rule4270 = ReplacementRule(pattern4270, replacement4270) pattern4271 = Pattern(Integral((a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(c_ + WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons4, cons71, cons1255, cons77) def replacement4271(m, f, b, d, a, c, n, x, e): rubi.append(4271) return Dist((a + b/cos(e + f*x))**m*(c + d/cos(e + f*x))**n*(a*cos(e + f*x) + b)**(-m)*(c*cos(e + f*x) + d)**(-n)*cos(e + f*x)**(m + n), Int((a*cos(e + f*x) + b)**m*(c*cos(e + f*x) + d)**n*cos(e + f*x)**(-m - n), x), x) rule4271 = ReplacementRule(pattern4271, replacement4271) pattern4272 = Pattern(Integral((a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(c_ + WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons4, cons71, cons1255, cons77) def replacement4272(m, f, b, d, a, c, n, x, e): rubi.append(4272) return Dist((a + b/sin(e + f*x))**m*(c + d/sin(e + f*x))**n*(a*sin(e + f*x) + b)**(-m)*(c*sin(e + f*x) + d)**(-n)*sin(e + f*x)**(m + n), Int((a*sin(e + f*x) + b)**m*(c*sin(e + f*x) + d)**n*sin(e + f*x)**(-m - n), x), x) rule4272 = ReplacementRule(pattern4272, replacement4272) pattern4273 = Pattern(Integral((a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(c_ + WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons4, cons148) def replacement4273(m, f, b, d, a, c, n, x, e): rubi.append(4273) return Int(ExpandTrig((a + b/cos(e + f*x))**m, (c + d/cos(e + f*x))**n, x), x) rule4273 = ReplacementRule(pattern4273, replacement4273) pattern4274 = Pattern(Integral((a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(c_ + WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons4, cons148) def replacement4274(m, f, b, d, a, c, n, x, e): rubi.append(4274) return Int(ExpandTrig((a + b/sin(e + f*x))**m, (c + d/sin(e + f*x))**n, x), x) rule4274 = ReplacementRule(pattern4274, replacement4274) pattern4275 = Pattern(Integral((a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(c_ + WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons4, cons1360) def replacement4275(m, f, b, d, a, n, c, x, e): rubi.append(4275) return Int((a + b/cos(e + f*x))**m*(c + d/cos(e + f*x))**n, x) rule4275 = ReplacementRule(pattern4275, replacement4275) pattern4276 = Pattern(Integral((a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(c_ + WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons4, cons1360) def replacement4276(m, f, b, d, a, n, c, x, e): rubi.append(4276) return Int((a + b/sin(e + f*x))**m*(c + d/sin(e + f*x))**n, x) rule4276 = ReplacementRule(pattern4276, replacement4276) pattern4277 = Pattern(Integral((WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(WC('a', S(0)) + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1)), x_), cons2, cons3, cons27, cons48, cons125, cons4, cons23, cons17) def replacement4277(m, f, b, d, a, n, x, e): rubi.append(4277) return Dist(d**m, Int((d*cos(e + f*x))**(-m + n)*(a*cos(e + f*x) + b)**m, x), x) rule4277 = ReplacementRule(pattern4277, replacement4277) pattern4278 = Pattern(Integral((WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(WC('a', S(0)) + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1)), x_), cons2, cons3, cons27, cons48, cons125, cons4, cons23, cons17) def replacement4278(m, f, b, d, a, n, x, e): rubi.append(4278) return Dist(d**m, Int((d*sin(e + f*x))**(-m + n)*(a*sin(e + f*x) + b)**m, x), x) rule4278 = ReplacementRule(pattern4278, replacement4278) pattern4279 = Pattern(Integral(((WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**p_*WC('c', S(1)))**n_*(WC('a', S(0)) + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons4, cons5, cons23) def replacement4279(p, m, f, b, d, c, a, n, x, e): rubi.append(4279) return Dist(c**IntPart(n)*(c*(d/cos(e + f*x))**p)**FracPart(n)*(d/cos(e + f*x))**(-p*FracPart(n)), Int((d/cos(e + f*x))**(n*p)*(a + b/cos(e + f*x))**m, x), x) rule4279 = ReplacementRule(pattern4279, replacement4279) pattern4280 = Pattern(Integral(((WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**p_*WC('c', S(1)))**n_*(WC('a', S(0)) + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons4, cons5, cons23) def replacement4280(p, m, f, b, d, a, c, n, x, e): rubi.append(4280) return Dist(c**IntPart(n)*(c*(d/sin(e + f*x))**p)**FracPart(n)*(d/sin(e + f*x))**(-p*FracPart(n)), Int((d*cos(e + f*x))**(n*p)*(a + b*cos(e + f*x))**m, x), x) rule4280 = ReplacementRule(pattern4280, replacement4280) pattern4281 = Pattern(Integral((a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(c_ + WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons4, cons70, cons1265, cons155, cons1421) def replacement4281(m, f, b, d, a, n, c, x, e): rubi.append(4281) return -Simp(b*(a + b/cos(e + f*x))**m*(c + d/cos(e + f*x))**n*tan(e + f*x)/(a*f*(S(2)*m + S(1))), x) rule4281 = ReplacementRule(pattern4281, replacement4281) pattern4282 = Pattern(Integral((a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(c_ + WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons4, cons70, cons1265, cons155, cons1421) def replacement4282(m, f, b, d, a, n, c, x, e): rubi.append(4282) return Simp(b*(a + b/sin(e + f*x))**m*(c + d/sin(e + f*x))**n/(a*f*(S(2)*m + S(1))*tan(e + f*x)), x) rule4282 = ReplacementRule(pattern4282, replacement4282) pattern4283 = Pattern(Integral((a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(c_ + WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons4, cons70, cons1265, cons1315, cons1421, cons1231, cons1615) def replacement4283(m, f, b, d, a, n, c, x, e): rubi.append(4283) return Dist((m + n + S(1))/(a*(S(2)*m + S(1))), Int((a + b/cos(e + f*x))**(m + S(1))*(c + d/cos(e + f*x))**n/cos(e + f*x), x), x) - Simp(b*(a + b/cos(e + f*x))**m*(c + d/cos(e + f*x))**n*tan(e + f*x)/(a*f*(S(2)*m + S(1))), x) rule4283 = ReplacementRule(pattern4283, replacement4283) pattern4284 = Pattern(Integral((a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(c_ + WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons4, cons70, cons1265, cons1315, cons1421, cons1231, cons1615) def replacement4284(m, f, b, d, a, n, c, x, e): rubi.append(4284) return Dist((m + n + S(1))/(a*(S(2)*m + S(1))), Int((a + b/sin(e + f*x))**(m + S(1))*(c + d/sin(e + f*x))**n/sin(e + f*x), x), x) + Simp(b*(a + b/sin(e + f*x))**m*(c + d/sin(e + f*x))**n/(a*f*(S(2)*m + S(1))*tan(e + f*x)), x) rule4284 = ReplacementRule(pattern4284, replacement4284) pattern4285 = Pattern(Integral(sqrt(c_ + WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))/(sqrt(a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))*cos(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons70, cons1265) def replacement4285(f, b, d, a, c, x, e): rubi.append(4285) return -Simp(a*c*log(S(1) + b/(a*cos(e + f*x)))*tan(e + f*x)/(b*f*sqrt(a + b/cos(e + f*x))*sqrt(c + d/cos(e + f*x))), x) rule4285 = ReplacementRule(pattern4285, replacement4285) pattern4286 = Pattern(Integral(sqrt(c_ + WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))/(sqrt(a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))*sin(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons70, cons1265) def replacement4286(f, b, d, a, c, x, e): rubi.append(4286) return Simp(a*c*log(S(1) + b/(a*sin(e + f*x)))/(b*f*sqrt(a + b/sin(e + f*x))*sqrt(c + d/sin(e + f*x))*tan(e + f*x)), x) rule4286 = ReplacementRule(pattern4286, replacement4286) pattern4287 = Pattern(Integral((a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*sqrt(c_ + WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))/cos(x_*WC('f', S(1)) + WC('e', S(0))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons70, cons1265, cons1314) def replacement4287(m, f, b, d, a, c, x, e): rubi.append(4287) return Simp(-S(2)*a*c*(a + b/cos(e + f*x))**m*tan(e + f*x)/(b*f*sqrt(c + d/cos(e + f*x))*(S(2)*m + S(1))), x) rule4287 = ReplacementRule(pattern4287, replacement4287) pattern4288 = Pattern(Integral((a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*sqrt(c_ + WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))/sin(x_*WC('f', S(1)) + WC('e', S(0))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons70, cons1265, cons1314) def replacement4288(m, f, b, d, a, c, x, e): rubi.append(4288) return Simp(S(2)*a*c*(a + b/sin(e + f*x))**m/(b*f*sqrt(c + d/sin(e + f*x))*(S(2)*m + S(1))*tan(e + f*x)), x) rule4288 = ReplacementRule(pattern4288, replacement4288) pattern4289 = Pattern(Integral((a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(c_ + WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons70, cons1265, cons1266, cons31, cons1320) def replacement4289(m, f, b, d, a, n, c, x, e): rubi.append(4289) return -Dist(d*(S(2)*n + S(-1))/(b*(S(2)*m + S(1))), Int((a + b/cos(e + f*x))**(m + S(1))*(c + d/cos(e + f*x))**(n + S(-1))/cos(e + f*x), x), x) + Simp(-S(2)*a*c*(a + b/cos(e + f*x))**m*(c + d/cos(e + f*x))**(n + S(-1))*tan(e + f*x)/(b*f*(S(2)*m + S(1))), x) rule4289 = ReplacementRule(pattern4289, replacement4289) pattern4290 = Pattern(Integral((a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(c_ + WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons70, cons1265, cons1266, cons31, cons1320) def replacement4290(m, f, b, d, a, n, c, x, e): rubi.append(4290) return -Dist(d*(S(2)*n + S(-1))/(b*(S(2)*m + S(1))), Int((a + b/sin(e + f*x))**(m + S(1))*(c + d/sin(e + f*x))**(n + S(-1))/sin(e + f*x), x), x) + Simp(S(2)*a*c*(a + b/sin(e + f*x))**m*(c + d/sin(e + f*x))**(n + S(-1))/(b*f*(S(2)*m + S(1))*tan(e + f*x)), x) rule4290 = ReplacementRule(pattern4290, replacement4290) pattern4291 = Pattern(Integral((a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(c_ + WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_/cos(x_*WC('f', S(1)) + WC('e', S(0))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons70, cons1265, cons1266, cons1321, cons1616) def replacement4291(m, f, b, d, a, c, n, x, e): rubi.append(4291) return Dist(c*(S(2)*n + S(-1))/(m + n), Int((a + b/cos(e + f*x))**m*(c + d/cos(e + f*x))**(n + S(-1))/cos(e + f*x), x), x) + Simp(d*(a + b/cos(e + f*x))**m*(c + d/cos(e + f*x))**(n + S(-1))*tan(e + f*x)/(f*(m + n)), x) rule4291 = ReplacementRule(pattern4291, replacement4291) pattern4292 = Pattern(Integral((a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(c_ + WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_/sin(x_*WC('f', S(1)) + WC('e', S(0))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons70, cons1265, cons1266, cons1321, cons1616) def replacement4292(m, f, b, d, a, c, n, x, e): rubi.append(4292) return Dist(c*(S(2)*n + S(-1))/(m + n), Int((a + b/sin(e + f*x))**m*(c + d/sin(e + f*x))**(n + S(-1))/sin(e + f*x), x), x) - Simp(d*(a + b/sin(e + f*x))**m*(c + d/sin(e + f*x))**(n + S(-1))/(f*(m + n)*tan(e + f*x)), x) rule4292 = ReplacementRule(pattern4292, replacement4292) pattern4293 = Pattern(Integral((c_ + WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1))/(sqrt(a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))*cos(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons70, cons1265, cons148) def replacement4293(f, b, d, a, n, c, x, e): rubi.append(4293) return Dist(S(2)*c, Int((c + d/cos(e + f*x))**(n + S(-1))/(sqrt(a + b/cos(e + f*x))*cos(e + f*x)), x), x) + Simp(S(2)*d*(c + d/cos(e + f*x))**(n + S(-1))*tan(e + f*x)/(f*sqrt(a + b/cos(e + f*x))*(S(2)*n + S(-1))), x) rule4293 = ReplacementRule(pattern4293, replacement4293) pattern4294 = Pattern(Integral((c_ + WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1))/(sqrt(a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))*sin(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons70, cons1265, cons148) def replacement4294(f, b, d, a, n, c, x, e): rubi.append(4294) return Dist(S(2)*c, Int((c + d/sin(e + f*x))**(n + S(-1))/(sqrt(a + b/sin(e + f*x))*sin(e + f*x)), x), x) + Simp(-S(2)*d*(c + d/sin(e + f*x))**(n + S(-1))/(f*sqrt(a + b/sin(e + f*x))*(S(2)*n + S(-1))*tan(e + f*x)), x) rule4294 = ReplacementRule(pattern4294, replacement4294) pattern4295 = Pattern(Integral((a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(c_ + WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons70, cons1265, cons148, cons1320, cons515) def replacement4295(m, f, b, d, a, n, c, x, e): rubi.append(4295) return -Dist(d*(S(2)*n + S(-1))/(b*(S(2)*m + S(1))), Int((a + b/cos(e + f*x))**(m + S(1))*(c + d/cos(e + f*x))**(n + S(-1))/cos(e + f*x), x), x) + Simp(-S(2)*a*c*(a + b/cos(e + f*x))**m*(c + d/cos(e + f*x))**(n + S(-1))*tan(e + f*x)/(b*f*(S(2)*m + S(1))), x) rule4295 = ReplacementRule(pattern4295, replacement4295) pattern4296 = Pattern(Integral((a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(c_ + WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons70, cons1265, cons148, cons1320, cons515) def replacement4296(m, f, b, d, a, n, c, x, e): rubi.append(4296) return -Dist(d*(S(2)*n + S(-1))/(b*(S(2)*m + S(1))), Int((a + b/sin(e + f*x))**(m + S(1))*(c + d/sin(e + f*x))**(n + S(-1))/sin(e + f*x), x), x) + Simp(S(2)*a*c*(a + b/sin(e + f*x))**m*(c + d/sin(e + f*x))**(n + S(-1))/(b*f*(S(2)*m + S(1))*tan(e + f*x)), x) rule4296 = ReplacementRule(pattern4296, replacement4296) pattern4297 = Pattern(Integral((a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(c_ + WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons4, cons70, cons1265, cons150, cons1617, cons1618) def replacement4297(m, f, b, d, a, n, c, x, e): rubi.append(4297) return Dist((-a*c)**m, Int(ExpandTrig(tan(e + f*x)**(S(2)*m)/cos(e + f*x), (c + d/cos(e + f*x))**(-m + n), x), x), x) rule4297 = ReplacementRule(pattern4297, replacement4297) pattern4298 = Pattern(Integral((a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(c_ + WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons4, cons70, cons1265, cons150, cons1617, cons1618) def replacement4298(m, f, b, d, a, n, c, x, e): rubi.append(4298) return Dist((-a*c)**m, Int(ExpandTrig((S(1)/tan(e + f*x))**(S(2)*m)/sin(e + f*x), (c + d/sin(e + f*x))**(-m + n), x), x), x) rule4298 = ReplacementRule(pattern4298, replacement4298) pattern4299 = Pattern(Integral((a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(c_ + WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_/cos(x_*WC('f', S(1)) + WC('e', S(0))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons70, cons1265, cons79) def replacement4299(m, f, b, d, a, c, x, e): rubi.append(4299) return Dist((-a*c)**(m + S(1)/2)*tan(e + f*x)/(sqrt(a + b/cos(e + f*x))*sqrt(c + d/cos(e + f*x))), Int(tan(e + f*x)**(S(2)*m)/cos(e + f*x), x), x) rule4299 = ReplacementRule(pattern4299, replacement4299) pattern4300 = Pattern(Integral((a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(c_ + WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_/sin(x_*WC('f', S(1)) + WC('e', S(0))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons70, cons1265, cons79) def replacement4300(m, f, b, d, a, c, x, e): rubi.append(4300) return Dist((-a*c)**(m + S(1)/2)/(sqrt(a + b/sin(e + f*x))*sqrt(c + d/sin(e + f*x))*tan(e + f*x)), Int((S(1)/tan(e + f*x))**(S(2)*m)/sin(e + f*x), x), x) rule4300 = ReplacementRule(pattern4300, replacement4300) pattern4301 = Pattern(Integral((a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(c_ + WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_/cos(x_*WC('f', S(1)) + WC('e', S(0))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons4, cons70, cons1265, cons1619) def replacement4301(m, f, b, d, a, c, n, x, e): rubi.append(4301) return Dist((m + n + S(1))/(a*(S(2)*m + S(1))), Int((a + b/cos(e + f*x))**(m + S(1))*(c + d/cos(e + f*x))**n/cos(e + f*x), x), x) - Simp(b*(a + b/cos(e + f*x))**m*(c + d/cos(e + f*x))**n*tan(e + f*x)/(a*f*(S(2)*m + S(1))), x) rule4301 = ReplacementRule(pattern4301, replacement4301) pattern4302 = Pattern(Integral((a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(c_ + WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_/sin(x_*WC('f', S(1)) + WC('e', S(0))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons4, cons70, cons1265, cons1619) def replacement4302(m, f, b, d, a, c, n, x, e): rubi.append(4302) return Dist((m + n + S(1))/(a*(S(2)*m + S(1))), Int((a + b/sin(e + f*x))**(m + S(1))*(c + d/sin(e + f*x))**n/sin(e + f*x), x), x) + Simp(b*(a + b/sin(e + f*x))**m*(c + d/sin(e + f*x))**n/(a*f*(S(2)*m + S(1))*tan(e + f*x)), x) rule4302 = ReplacementRule(pattern4302, replacement4302) pattern4303 = Pattern(Integral((a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(c_ + WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_/cos(x_*WC('f', S(1)) + WC('e', S(0))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons4, cons70, cons1265) def replacement4303(m, f, b, d, a, c, n, x, e): rubi.append(4303) return -Dist(a*c*tan(e + f*x)/(f*sqrt(a + b/cos(e + f*x))*sqrt(c + d/cos(e + f*x))), Subst(Int((a + b*x)**(m + S(-1)/2)*(c + d*x)**(n + S(-1)/2), x), x, S(1)/cos(e + f*x)), x) rule4303 = ReplacementRule(pattern4303, replacement4303) pattern4304 = Pattern(Integral((a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(c_ + WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_/sin(x_*WC('f', S(1)) + WC('e', S(0))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons4, cons70, cons1265) def replacement4304(m, f, b, d, a, c, n, x, e): rubi.append(4304) return Dist(a*c/(f*sqrt(a + b/sin(e + f*x))*sqrt(c + d/sin(e + f*x))*tan(e + f*x)), Subst(Int((a + b*x)**(m + S(-1)/2)*(c + d*x)**(n + S(-1)/2), x), x, S(1)/sin(e + f*x)), x) rule4304 = ReplacementRule(pattern4304, replacement4304) pattern4305 = Pattern(Integral((WC('g', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('p', S(1))*(a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(c_ + WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons4, cons5, cons70, cons1265, cons150, cons1617, cons1618) def replacement4305(p, m, f, g, b, d, a, n, c, x, e): rubi.append(4305) return Dist((-a*c)**m, Int(ExpandTrig((g/cos(e + f*x))**p*tan(e + f*x)**(S(2)*m), (c + d/cos(e + f*x))**(-m + n), x), x), x) rule4305 = ReplacementRule(pattern4305, replacement4305) pattern4306 = Pattern(Integral((WC('g', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('p', S(1))*(a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(c_ + WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons4, cons5, cons70, cons1265, cons150, cons1617, cons1618) def replacement4306(p, m, f, b, g, d, a, n, c, x, e): rubi.append(4306) return Dist((-a*c)**m, Int(ExpandTrig((g/sin(e + f*x))**p*(S(1)/tan(e + f*x))**(S(2)*m), (c + d/sin(e + f*x))**(-m + n), x), x), x) rule4306 = ReplacementRule(pattern4306, replacement4306) pattern4307 = Pattern(Integral((WC('g', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('p', S(1))*(a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(c_ + WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons5, cons70, cons1265, cons79) def replacement4307(p, m, f, g, b, d, a, c, x, e): rubi.append(4307) return Dist((-a*c)**(m + S(1)/2)*tan(e + f*x)/(sqrt(a + b/cos(e + f*x))*sqrt(c + d/cos(e + f*x))), Int((g/cos(e + f*x))**p*tan(e + f*x)**(S(2)*m), x), x) rule4307 = ReplacementRule(pattern4307, replacement4307) pattern4308 = Pattern(Integral((WC('g', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('p', S(1))*(a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(c_ + WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons5, cons70, cons1265, cons79) def replacement4308(p, m, f, b, g, d, a, c, x, e): rubi.append(4308) return Dist((-a*c)**(m + S(1)/2)/(sqrt(a + b/sin(e + f*x))*sqrt(c + d/sin(e + f*x))*tan(e + f*x)), Int((g/sin(e + f*x))**p*(S(1)/tan(e + f*x))**(S(2)*m), x), x) rule4308 = ReplacementRule(pattern4308, replacement4308) pattern4309 = Pattern(Integral((WC('g', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('p', S(1))*(a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(c_ + WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons21, cons4, cons5, cons70, cons1265) def replacement4309(p, m, f, g, b, d, a, c, n, x, e): rubi.append(4309) return -Dist(a*c*g*tan(e + f*x)/(f*sqrt(a + b/cos(e + f*x))*sqrt(c + d/cos(e + f*x))), Subst(Int((g*x)**(p + S(-1))*(a + b*x)**(m + S(-1)/2)*(c + d*x)**(n + S(-1)/2), x), x, S(1)/cos(e + f*x)), x) rule4309 = ReplacementRule(pattern4309, replacement4309) pattern4310 = Pattern(Integral((WC('g', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('p', S(1))*(a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(c_ + WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons21, cons4, cons5, cons70, cons1265) def replacement4310(p, m, f, b, g, d, a, c, n, x, e): rubi.append(4310) return Dist(a*c*g/(f*sqrt(a + b/sin(e + f*x))*sqrt(c + d/sin(e + f*x))*tan(e + f*x)), Subst(Int((g*x)**(p + S(-1))*(a + b*x)**(m + S(-1)/2)*(c + d*x)**(n + S(-1)/2), x), x, S(1)/sin(e + f*x)), x) rule4310 = ReplacementRule(pattern4310, replacement4310) pattern4311 = Pattern(Integral(sqrt(WC('g', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))*sqrt(a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))/(c_ + WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons71, cons1265) def replacement4311(f, g, b, d, a, c, x, e): rubi.append(4311) return Dist(S(2)*b*g/f, Subst(Int(S(1)/(a*d + b*c - c*g*x**S(2)), x), x, b*tan(e + f*x)/(sqrt(g/cos(e + f*x))*sqrt(a + b/cos(e + f*x)))), x) rule4311 = ReplacementRule(pattern4311, replacement4311) pattern4312 = Pattern(Integral(sqrt(WC('g', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))*sqrt(a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))/(c_ + WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons71, cons1265) def replacement4312(f, b, g, d, a, c, x, e): rubi.append(4312) return Dist(-S(2)*b*g/f, Subst(Int(S(1)/(a*d + b*c - c*g*x**S(2)), x), x, b/(sqrt(g/sin(e + f*x))*sqrt(a + b/sin(e + f*x))*tan(e + f*x))), x) rule4312 = ReplacementRule(pattern4312, replacement4312) pattern4313 = Pattern(Integral(sqrt(WC('g', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))*sqrt(a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))/(c_ + WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons71, cons1267) def replacement4313(f, g, b, d, a, c, x, e): rubi.append(4313) return Dist(a/c, Int(sqrt(g/cos(e + f*x))/sqrt(a + b/cos(e + f*x)), x), x) + Dist((-a*d + b*c)/(c*g), Int((g/cos(e + f*x))**(S(3)/2)/(sqrt(a + b/cos(e + f*x))*(c + d/cos(e + f*x))), x), x) rule4313 = ReplacementRule(pattern4313, replacement4313) pattern4314 = Pattern(Integral(sqrt(WC('g', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))*sqrt(a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))/(c_ + WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons71, cons1267) def replacement4314(f, b, g, d, a, c, x, e): rubi.append(4314) return Dist(a/c, Int(sqrt(g/sin(e + f*x))/sqrt(a + b/sin(e + f*x)), x), x) + Dist((-a*d + b*c)/(c*g), Int((g/sin(e + f*x))**(S(3)/2)/(sqrt(a + b/sin(e + f*x))*(c + d/sin(e + f*x))), x), x) rule4314 = ReplacementRule(pattern4314, replacement4314) pattern4315 = Pattern(Integral(sqrt(a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))/((c_ + WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))*cos(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1265) def replacement4315(f, b, d, a, c, x, e): rubi.append(4315) return Dist(S(2)*b/f, Subst(Int(S(1)/(a*d + b*c + d*x**S(2)), x), x, b*tan(e + f*x)/sqrt(a + b/cos(e + f*x))), x) rule4315 = ReplacementRule(pattern4315, replacement4315) pattern4316 = Pattern(Integral(sqrt(a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))/((c_ + WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))*sin(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1265) def replacement4316(f, b, d, a, c, x, e): rubi.append(4316) return Dist(-S(2)*b/f, Subst(Int(S(1)/(a*d + b*c + d*x**S(2)), x), x, b/(sqrt(a + b/sin(e + f*x))*tan(e + f*x))), x) rule4316 = ReplacementRule(pattern4316, replacement4316) pattern4317 = Pattern(Integral(sqrt(a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))/((c_ + WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))*cos(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1267, cons1322) def replacement4317(f, b, d, a, c, x, e): rubi.append(4317) return Simp(sqrt(c/(c + d/cos(e + f*x)))*sqrt(a + b/cos(e + f*x))*EllipticE(asin(c*tan(e + f*x)/(c + d/cos(e + f*x))), -(-a*d + b*c)/(a*d + b*c))/(d*f*sqrt(c*d*(a + b/cos(e + f*x))/((c + d/cos(e + f*x))*(a*d + b*c)))), x) rule4317 = ReplacementRule(pattern4317, replacement4317) pattern4318 = Pattern(Integral(sqrt(a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))/((c_ + WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))*sin(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1267, cons1322) def replacement4318(f, b, d, a, c, x, e): rubi.append(4318) return -Simp(sqrt(c/(c + d/sin(e + f*x)))*sqrt(a + b/sin(e + f*x))*EllipticE(asin(c/((c + d/sin(e + f*x))*tan(e + f*x))), -(-a*d + b*c)/(a*d + b*c))/(d*f*sqrt(c*d*(a + b/sin(e + f*x))/((c + d/sin(e + f*x))*(a*d + b*c)))), x) rule4318 = ReplacementRule(pattern4318, replacement4318) pattern4319 = Pattern(Integral(sqrt(a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))/((c_ + WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))*cos(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1267, cons1323) def replacement4319(f, b, d, a, c, x, e): rubi.append(4319) return Dist(b/d, Int(S(1)/(sqrt(a + b/cos(e + f*x))*cos(e + f*x)), x), x) - Dist((-a*d + b*c)/d, Int(S(1)/(sqrt(a + b/cos(e + f*x))*(c + d/cos(e + f*x))*cos(e + f*x)), x), x) rule4319 = ReplacementRule(pattern4319, replacement4319) pattern4320 = Pattern(Integral(sqrt(a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))/((c_ + WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))*sin(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1267, cons1323) def replacement4320(f, b, d, a, c, x, e): rubi.append(4320) return Dist(b/d, Int(S(1)/(sqrt(a + b/sin(e + f*x))*sin(e + f*x)), x), x) - Dist((-a*d + b*c)/d, Int(S(1)/(sqrt(a + b/sin(e + f*x))*(c + d/sin(e + f*x))*sin(e + f*x)), x), x) rule4320 = ReplacementRule(pattern4320, replacement4320) pattern4321 = Pattern(Integral((WC('g', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**(S(3)/2)*sqrt(a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))/(c_ + WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons71, cons1265) def replacement4321(f, g, b, d, a, c, x, e): rubi.append(4321) return Dist(g/d, Int(sqrt(g/cos(e + f*x))*sqrt(a + b/cos(e + f*x)), x), x) - Dist(c*g/d, Int(sqrt(g/cos(e + f*x))*sqrt(a + b/cos(e + f*x))/(c + d/cos(e + f*x)), x), x) rule4321 = ReplacementRule(pattern4321, replacement4321) pattern4322 = Pattern(Integral((WC('g', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**(S(3)/2)*sqrt(a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))/(c_ + WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons71, cons1265) def replacement4322(f, b, g, d, a, c, x, e): rubi.append(4322) return Dist(g/d, Int(sqrt(g/sin(e + f*x))*sqrt(a + b/sin(e + f*x)), x), x) - Dist(c*g/d, Int(sqrt(g/sin(e + f*x))*sqrt(a + b/sin(e + f*x))/(c + d/sin(e + f*x)), x), x) rule4322 = ReplacementRule(pattern4322, replacement4322) pattern4323 = Pattern(Integral((WC('g', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**(S(3)/2)*sqrt(a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))/(c_ + WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons71, cons1267) def replacement4323(f, g, b, d, a, c, x, e): rubi.append(4323) return Dist(b/d, Int((g/cos(e + f*x))**(S(3)/2)/sqrt(a + b/cos(e + f*x)), x), x) - Dist((-a*d + b*c)/d, Int((g/cos(e + f*x))**(S(3)/2)/(sqrt(a + b/cos(e + f*x))*(c + d/cos(e + f*x))), x), x) rule4323 = ReplacementRule(pattern4323, replacement4323) pattern4324 = Pattern(Integral((WC('g', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**(S(3)/2)*sqrt(a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))/(c_ + WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons71, cons1267) def replacement4324(f, b, g, d, a, c, x, e): rubi.append(4324) return Dist(b/d, Int((g/sin(e + f*x))**(S(3)/2)/sqrt(a + b/sin(e + f*x)), x), x) - Dist((-a*d + b*c)/d, Int((g/sin(e + f*x))**(S(3)/2)/(sqrt(a + b/sin(e + f*x))*(c + d/sin(e + f*x))), x), x) rule4324 = ReplacementRule(pattern4324, replacement4324) pattern4325 = Pattern(Integral(S(1)/(sqrt(a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))*(c_ + WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))*cos(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1409) def replacement4325(f, b, d, a, c, x, e): rubi.append(4325) return Dist(b/(-a*d + b*c), Int(S(1)/(sqrt(a + b/cos(e + f*x))*cos(e + f*x)), x), x) - Dist(d/(-a*d + b*c), Int(sqrt(a + b/cos(e + f*x))/((c + d/cos(e + f*x))*cos(e + f*x)), x), x) rule4325 = ReplacementRule(pattern4325, replacement4325) pattern4326 = Pattern(Integral(S(1)/(sqrt(a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))*(c_ + WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))*sin(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1409) def replacement4326(f, b, d, a, c, x, e): rubi.append(4326) return Dist(b/(-a*d + b*c), Int(S(1)/(sqrt(a + b/sin(e + f*x))*sin(e + f*x)), x), x) - Dist(d/(-a*d + b*c), Int(sqrt(a + b/sin(e + f*x))/((c + d/sin(e + f*x))*sin(e + f*x)), x), x) rule4326 = ReplacementRule(pattern4326, replacement4326) pattern4327 = Pattern(Integral(S(1)/(sqrt(a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))*(c_ + WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))*cos(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1267, cons1323) def replacement4327(f, b, d, a, c, x, e): rubi.append(4327) return Simp(S(2)*sqrt((a + b/cos(e + f*x))/(a + b))*EllipticPi(S(2)*d/(c + d), asin(sqrt(S(2))*sqrt(S(1) - S(1)/cos(e + f*x))/S(2)), S(2)*b/(a + b))*tan(e + f*x)/(f*sqrt(-tan(e + f*x)**S(2))*sqrt(a + b/cos(e + f*x))*(c + d)), x) rule4327 = ReplacementRule(pattern4327, replacement4327) pattern4328 = Pattern(Integral(S(1)/(sqrt(a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))*(c_ + WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))*sin(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1267, cons1323) def replacement4328(f, b, d, a, c, x, e): rubi.append(4328) return Simp(-S(2)*sqrt((a + b/sin(e + f*x))/(a + b))*EllipticPi(S(2)*d/(c + d), asin(sqrt(S(2))*sqrt(S(1) - S(1)/sin(e + f*x))/S(2)), S(2)*b/(a + b))/(f*sqrt(-S(1)/tan(e + f*x)**S(2))*sqrt(a + b/sin(e + f*x))*(c + d)*tan(e + f*x)), x) rule4328 = ReplacementRule(pattern4328, replacement4328) pattern4329 = Pattern(Integral((WC('g', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**(S(3)/2)/(sqrt(a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))*(c_ + WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons71, cons1265) def replacement4329(f, g, b, d, a, c, x, e): rubi.append(4329) return -Dist(a*g/(-a*d + b*c), Int(sqrt(g/cos(e + f*x))/sqrt(a + b/cos(e + f*x)), x), x) + Dist(c*g/(-a*d + b*c), Int(sqrt(g/cos(e + f*x))*sqrt(a + b/cos(e + f*x))/(c + d/cos(e + f*x)), x), x) rule4329 = ReplacementRule(pattern4329, replacement4329) pattern4330 = Pattern(Integral((WC('g', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**(S(3)/2)/(sqrt(a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))*(c_ + WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons71, cons1265) def replacement4330(f, b, g, d, a, c, x, e): rubi.append(4330) return -Dist(a*g/(-a*d + b*c), Int(sqrt(g/sin(e + f*x))/sqrt(a + b/sin(e + f*x)), x), x) + Dist(c*g/(-a*d + b*c), Int(sqrt(g/sin(e + f*x))*sqrt(a + b/sin(e + f*x))/(c + d/sin(e + f*x)), x), x) rule4330 = ReplacementRule(pattern4330, replacement4330) pattern4331 = Pattern(Integral((WC('g', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**(S(3)/2)/(sqrt(a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))*(c_ + WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons71, cons1267) def replacement4331(f, g, b, d, a, c, x, e): rubi.append(4331) return Dist(g*sqrt(g/cos(e + f*x))*sqrt(a*cos(e + f*x) + b)/sqrt(a + b/cos(e + f*x)), Int(S(1)/(sqrt(a*cos(e + f*x) + b)*(c*cos(e + f*x) + d)), x), x) rule4331 = ReplacementRule(pattern4331, replacement4331) pattern4332 = Pattern(Integral((WC('g', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**(S(3)/2)/(sqrt(a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))*(c_ + WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons71, cons1267) def replacement4332(f, b, g, d, a, c, x, e): rubi.append(4332) return Dist(g*sqrt(g/sin(e + f*x))*sqrt(a*sin(e + f*x) + b)/sqrt(a + b/sin(e + f*x)), Int(S(1)/(sqrt(a*sin(e + f*x) + b)*(c*sin(e + f*x) + d)), x), x) rule4332 = ReplacementRule(pattern4332, replacement4332) pattern4333 = Pattern(Integral(S(1)/(sqrt(a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))*(c_ + WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))*cos(x_*WC('f', S(1)) + WC('e', S(0)))**S(2)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1409) def replacement4333(f, b, d, a, c, x, e): rubi.append(4333) return -Dist(a/(-a*d + b*c), Int(S(1)/(sqrt(a + b/cos(e + f*x))*cos(e + f*x)), x), x) + Dist(c/(-a*d + b*c), Int(sqrt(a + b/cos(e + f*x))/((c + d/cos(e + f*x))*cos(e + f*x)), x), x) rule4333 = ReplacementRule(pattern4333, replacement4333) pattern4334 = Pattern(Integral(S(1)/(sqrt(a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))*(c_ + WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))*sin(x_*WC('f', S(1)) + WC('e', S(0)))**S(2)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1409) def replacement4334(f, b, d, a, c, x, e): rubi.append(4334) return -Dist(a/(-a*d + b*c), Int(S(1)/(sqrt(a + b/sin(e + f*x))*sin(e + f*x)), x), x) + Dist(c/(-a*d + b*c), Int(sqrt(a + b/sin(e + f*x))/((c + d/sin(e + f*x))*sin(e + f*x)), x), x) rule4334 = ReplacementRule(pattern4334, replacement4334) pattern4335 = Pattern(Integral(S(1)/(sqrt(a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))*(c_ + WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))*cos(x_*WC('f', S(1)) + WC('e', S(0)))**S(2)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1267, cons1323) def replacement4335(f, b, d, a, c, x, e): rubi.append(4335) return Dist(S(1)/d, Int(S(1)/(sqrt(a + b/cos(e + f*x))*cos(e + f*x)), x), x) - Dist(c/d, Int(S(1)/(sqrt(a + b/cos(e + f*x))*(c + d/cos(e + f*x))*cos(e + f*x)), x), x) rule4335 = ReplacementRule(pattern4335, replacement4335) pattern4336 = Pattern(Integral(S(1)/(sqrt(a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))*(c_ + WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))*sin(x_*WC('f', S(1)) + WC('e', S(0)))**S(2)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1267, cons1323) def replacement4336(f, b, d, a, c, x, e): rubi.append(4336) return Dist(S(1)/d, Int(S(1)/(sqrt(a + b/sin(e + f*x))*sin(e + f*x)), x), x) - Dist(c/d, Int(S(1)/(sqrt(a + b/sin(e + f*x))*(c + d/sin(e + f*x))*sin(e + f*x)), x), x) rule4336 = ReplacementRule(pattern4336, replacement4336) pattern4337 = Pattern(Integral((WC('g', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**(S(5)/2)/(sqrt(a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))*(c_ + WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons71, cons1265) def replacement4337(f, g, b, d, a, c, x, e): rubi.append(4337) return Dist(g**S(2)/(d*(-a*d + b*c)), Int(sqrt(g/cos(e + f*x))*(a*c + (-a*d + b*c)/cos(e + f*x))/sqrt(a + b/cos(e + f*x)), x), x) - Dist(c**S(2)*g**S(2)/(d*(-a*d + b*c)), Int(sqrt(g/cos(e + f*x))*sqrt(a + b/cos(e + f*x))/(c + d/cos(e + f*x)), x), x) rule4337 = ReplacementRule(pattern4337, replacement4337) pattern4338 = Pattern(Integral((WC('g', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**(S(5)/2)/(sqrt(a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))*(c_ + WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons71, cons1265) def replacement4338(f, b, g, d, a, c, x, e): rubi.append(4338) return Dist(g**S(2)/(d*(-a*d + b*c)), Int(sqrt(g/sin(e + f*x))*(a*c + (-a*d + b*c)/sin(e + f*x))/sqrt(a + b/sin(e + f*x)), x), x) - Dist(c**S(2)*g**S(2)/(d*(-a*d + b*c)), Int(sqrt(g/sin(e + f*x))*sqrt(a + b/sin(e + f*x))/(c + d/sin(e + f*x)), x), x) rule4338 = ReplacementRule(pattern4338, replacement4338) pattern4339 = Pattern(Integral((WC('g', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**(S(5)/2)/(sqrt(a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))*(c_ + WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons71, cons1267) def replacement4339(f, g, b, d, a, c, x, e): rubi.append(4339) return Dist(g/d, Int((g/cos(e + f*x))**(S(3)/2)/sqrt(a + b/cos(e + f*x)), x), x) - Dist(c*g/d, Int((g/cos(e + f*x))**(S(3)/2)/(sqrt(a + b/cos(e + f*x))*(c + d/cos(e + f*x))), x), x) rule4339 = ReplacementRule(pattern4339, replacement4339) pattern4340 = Pattern(Integral((WC('g', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**(S(5)/2)/(sqrt(a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))*(c_ + WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons71, cons1267) def replacement4340(f, b, g, d, a, c, x, e): rubi.append(4340) return Dist(g/d, Int((g/sin(e + f*x))**(S(3)/2)/sqrt(a + b/sin(e + f*x)), x), x) - Dist(c*g/d, Int((g/sin(e + f*x))**(S(3)/2)/(sqrt(a + b/sin(e + f*x))*(c + d/sin(e + f*x))), x), x) rule4340 = ReplacementRule(pattern4340, replacement4340) pattern4341 = Pattern(Integral(sqrt(a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))/(sqrt(c_ + WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))*cos(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1265, cons1323) def replacement4341(f, b, d, a, c, x, e): rubi.append(4341) return Dist(S(2)*b/f, Subst(Int(S(1)/(-b*d*x**S(2) + S(1)), x), x, tan(e + f*x)/(sqrt(a + b/cos(e + f*x))*sqrt(c + d/cos(e + f*x)))), x) rule4341 = ReplacementRule(pattern4341, replacement4341) pattern4342 = Pattern(Integral(sqrt(a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))/(sqrt(c_ + WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))*sin(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1265, cons1323) def replacement4342(f, b, d, a, c, x, e): rubi.append(4342) return Dist(-S(2)*b/f, Subst(Int(S(1)/(-b*d*x**S(2) + S(1)), x), x, S(1)/(sqrt(a + b/sin(e + f*x))*sqrt(c + d/sin(e + f*x))*tan(e + f*x))), x) rule4342 = ReplacementRule(pattern4342, replacement4342) pattern4343 = Pattern(Integral(sqrt(a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))/(sqrt(c_ + WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))*cos(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1267, cons1322) def replacement4343(f, b, d, a, c, x, e): rubi.append(4343) return Dist(b/d, Int(sqrt(c + d/cos(e + f*x))/(sqrt(a + b/cos(e + f*x))*cos(e + f*x)), x), x) - Dist((-a*d + b*c)/d, Int(S(1)/(sqrt(a + b/cos(e + f*x))*sqrt(c + d/cos(e + f*x))*cos(e + f*x)), x), x) rule4343 = ReplacementRule(pattern4343, replacement4343) pattern4344 = Pattern(Integral(sqrt(a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))/(sqrt(c_ + WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))*sin(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1267, cons1322) def replacement4344(f, b, d, a, c, x, e): rubi.append(4344) return Dist(b/d, Int(sqrt(c + d/sin(e + f*x))/(sqrt(a + b/sin(e + f*x))*sin(e + f*x)), x), x) - Dist((-a*d + b*c)/d, Int(S(1)/(sqrt(a + b/sin(e + f*x))*sqrt(c + d/sin(e + f*x))*sin(e + f*x)), x), x) rule4344 = ReplacementRule(pattern4344, replacement4344) pattern4345 = Pattern(Integral(sqrt(a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))/(sqrt(c_ + WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))*cos(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1267, cons1323) def replacement4345(f, b, d, a, c, x, e): rubi.append(4345) return Simp(S(2)*sqrt((S(1) + S(1)/cos(e + f*x))*(-a*d + b*c)/((a + b/cos(e + f*x))*(c - d)))*sqrt(-(S(1) - S(1)/cos(e + f*x))*(-a*d + b*c)/((a + b/cos(e + f*x))*(c + d)))*(a + b/cos(e + f*x))*EllipticPi(b*(c + d)/(d*(a + b)), asin(sqrt((a + b)/(c + d))*sqrt(c + d/cos(e + f*x))/sqrt(a + b/cos(e + f*x))), (a - b)*(c + d)/((a + b)*(c - d)))/(d*f*sqrt((a + b)/(c + d))*tan(e + f*x)), x) rule4345 = ReplacementRule(pattern4345, replacement4345) pattern4346 = Pattern(Integral(sqrt(a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))/(sqrt(c_ + WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))*sin(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1267, cons1323) def replacement4346(f, b, d, a, c, x, e): rubi.append(4346) return Simp(-S(2)*sqrt((S(1) + S(1)/sin(e + f*x))*(-a*d + b*c)/((a + b/sin(e + f*x))*(c - d)))*sqrt(-(S(1) - S(1)/sin(e + f*x))*(-a*d + b*c)/((a + b/sin(e + f*x))*(c + d)))*(a + b/sin(e + f*x))*EllipticPi(b*(c + d)/(d*(a + b)), asin(sqrt((a + b)/(c + d))*sqrt(c + d/sin(e + f*x))/sqrt(a + b/sin(e + f*x))), (a - b)*(c + d)/((a + b)*(c - d)))*tan(e + f*x)/(d*f*sqrt((a + b)/(c + d))), x) rule4346 = ReplacementRule(pattern4346, replacement4346) pattern4347 = Pattern(Integral(S(1)/(sqrt(a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))*sqrt(c_ + WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))*cos(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1265, cons1323) def replacement4347(f, b, d, a, c, x, e): rubi.append(4347) return Dist(S(2)*a/(b*f), Subst(Int(S(1)/(x**S(2)*(a*c - b*d) + S(2)), x), x, tan(e + f*x)/(sqrt(a + b/cos(e + f*x))*sqrt(c + d/cos(e + f*x)))), x) rule4347 = ReplacementRule(pattern4347, replacement4347) pattern4348 = Pattern(Integral(S(1)/(sqrt(a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))*sqrt(c_ + WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))*sin(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1265, cons1323) def replacement4348(f, b, d, a, c, x, e): rubi.append(4348) return Dist(-S(2)*a/(b*f), Subst(Int(S(1)/(x**S(2)*(a*c - b*d) + S(2)), x), x, S(1)/(sqrt(a + b/sin(e + f*x))*sqrt(c + d/sin(e + f*x))*tan(e + f*x))), x) rule4348 = ReplacementRule(pattern4348, replacement4348) pattern4349 = Pattern(Integral(S(1)/(sqrt(a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))*sqrt(c_ + WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))*cos(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1267, cons1323) def replacement4349(f, b, d, a, c, x, e): rubi.append(4349) return Simp(S(2)*sqrt((S(1) - S(1)/cos(e + f*x))*(-a*d + b*c)/((a + b)*(c + d/cos(e + f*x))))*sqrt(-(S(1) + S(1)/cos(e + f*x))*(-a*d + b*c)/((a - b)*(c + d/cos(e + f*x))))*(c + d/cos(e + f*x))*EllipticF(asin(sqrt(a + b/cos(e + f*x))*Rt((c + d)/(a + b), S(2))/sqrt(c + d/cos(e + f*x))), (a + b)*(c - d)/((a - b)*(c + d)))/(f*(-a*d + b*c)*Rt((c + d)/(a + b), S(2))*tan(e + f*x)), x) rule4349 = ReplacementRule(pattern4349, replacement4349) pattern4350 = Pattern(Integral(S(1)/(sqrt(a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))*sqrt(c_ + WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))*sin(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1267, cons1323) def replacement4350(f, b, d, a, c, x, e): rubi.append(4350) return Simp(-S(2)*sqrt((S(1) - S(1)/sin(e + f*x))*(-a*d + b*c)/((a + b)*(c + d/sin(e + f*x))))*sqrt(-(S(1) + S(1)/sin(e + f*x))*(-a*d + b*c)/((a - b)*(c + d/sin(e + f*x))))*(c + d/sin(e + f*x))*EllipticF(asin(sqrt(a + b/sin(e + f*x))*Rt((c + d)/(a + b), S(2))/sqrt(c + d/sin(e + f*x))), (a + b)*(c - d)/((a - b)*(c + d)))*tan(e + f*x)/(f*(-a*d + b*c)*Rt((c + d)/(a + b), S(2))), x) rule4350 = ReplacementRule(pattern4350, replacement4350) pattern4351 = Pattern(Integral(S(1)/(sqrt(a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))*sqrt(c_ + WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))*cos(x_*WC('f', S(1)) + WC('e', S(0)))**S(2)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71) def replacement4351(f, b, d, a, c, x, e): rubi.append(4351) return Dist(S(1)/b, Int(sqrt(a + b/cos(e + f*x))/(sqrt(c + d/cos(e + f*x))*cos(e + f*x)), x), x) - Dist(a/b, Int(S(1)/(sqrt(a + b/cos(e + f*x))*sqrt(c + d/cos(e + f*x))*cos(e + f*x)), x), x) rule4351 = ReplacementRule(pattern4351, replacement4351) pattern4352 = Pattern(Integral(S(1)/(sqrt(a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))*sqrt(c_ + WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))*sin(x_*WC('f', S(1)) + WC('e', S(0)))**S(2)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71) def replacement4352(f, b, d, a, c, x, e): rubi.append(4352) return Dist(S(1)/b, Int(sqrt(a + b/sin(e + f*x))/(sqrt(c + d/sin(e + f*x))*sin(e + f*x)), x), x) - Dist(a/b, Int(S(1)/(sqrt(a + b/sin(e + f*x))*sqrt(c + d/sin(e + f*x))*sin(e + f*x)), x), x) rule4352 = ReplacementRule(pattern4352, replacement4352) pattern4353 = Pattern(Integral(sqrt(a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))/((c_ + WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**(S(3)/2)*cos(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1267, cons1323) def replacement4353(f, b, d, a, c, x, e): rubi.append(4353) return Dist((a - b)/(c - d), Int(S(1)/(sqrt(a + b/cos(e + f*x))*sqrt(c + d/cos(e + f*x))*cos(e + f*x)), x), x) + Dist((-a*d + b*c)/(c - d), Int((S(1) + S(1)/cos(e + f*x))/(sqrt(a + b/cos(e + f*x))*(c + d/cos(e + f*x))**(S(3)/2)*cos(e + f*x)), x), x) rule4353 = ReplacementRule(pattern4353, replacement4353) pattern4354 = Pattern(Integral(sqrt(a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))/((c_ + WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**(S(3)/2)*sin(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1267, cons1323) def replacement4354(f, b, d, a, c, x, e): rubi.append(4354) return Dist((a - b)/(c - d), Int(S(1)/(sqrt(a + b/sin(e + f*x))*sqrt(c + d/sin(e + f*x))*sin(e + f*x)), x), x) + Dist((-a*d + b*c)/(c - d), Int((S(1) + S(1)/sin(e + f*x))/(sqrt(a + b/sin(e + f*x))*(c + d/sin(e + f*x))**(S(3)/2)*sin(e + f*x)), x), x) rule4354 = ReplacementRule(pattern4354, replacement4354) pattern4355 = Pattern(Integral((WC('g', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('p', S(1))*(a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(c_ + WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons21, cons4, cons5, cons71, cons1265, cons1323, cons1620) def replacement4355(p, m, f, g, b, d, a, c, n, x, e): rubi.append(4355) return -Dist(a**S(2)*g*tan(e + f*x)/(f*sqrt(a - b/cos(e + f*x))*sqrt(a + b/cos(e + f*x))), Subst(Int((g*x)**(p + S(-1))*(a + b*x)**(m + S(-1)/2)*(c + d*x)**n/sqrt(a - b*x), x), x, S(1)/cos(e + f*x)), x) rule4355 = ReplacementRule(pattern4355, replacement4355) pattern4356 = Pattern(Integral((WC('g', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('p', S(1))*(a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(c_ + WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons21, cons4, cons5, cons71, cons1265, cons1323, cons1620) def replacement4356(p, m, f, b, g, d, a, c, n, x, e): rubi.append(4356) return Dist(a**S(2)*g/(f*sqrt(a - b/sin(e + f*x))*sqrt(a + b/sin(e + f*x))*tan(e + f*x)), Subst(Int((g*x)**(p + S(-1))*(a + b*x)**(m + S(-1)/2)*(c + d*x)**n/sqrt(a - b*x), x), x, S(1)/sin(e + f*x)), x) rule4356 = ReplacementRule(pattern4356, replacement4356) pattern4357 = Pattern(Integral((WC('g', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('p', S(1))*(a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(c_ + WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons5, cons71, cons17, cons85) def replacement4357(p, m, f, g, b, d, a, c, n, x, e): rubi.append(4357) return Dist(g**(-m - n), Int((g/cos(e + f*x))**(m + n + p)*(a*cos(e + f*x) + b)**m*(c*cos(e + f*x) + d)**n, x), x) rule4357 = ReplacementRule(pattern4357, replacement4357) pattern4358 = Pattern(Integral((WC('g', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('p', S(1))*(a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(c_ + WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons5, cons71, cons17, cons85) def replacement4358(p, m, f, b, g, d, a, c, n, x, e): rubi.append(4358) return Dist(g**(-m - n), Int((g/sin(e + f*x))**(m + n + p)*(a*sin(e + f*x) + b)**m*(c*sin(e + f*x) + d)**n, x), x) rule4358 = ReplacementRule(pattern4358, replacement4358) pattern4359 = Pattern(Integral((WC('g', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('p', S(1))*(a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(c_ + WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons4, cons5, cons71, cons1621, cons17) def replacement4359(p, m, f, g, b, d, a, c, n, x, e): rubi.append(4359) return Dist(g**(-m)*(g/cos(e + f*x))**(m + p)*(c + d/cos(e + f*x))**n*(c*cos(e + f*x) + d)**(-n), Int((a*cos(e + f*x) + b)**m*(c*cos(e + f*x) + d)**n, x), x) rule4359 = ReplacementRule(pattern4359, replacement4359) pattern4360 = Pattern(Integral((WC('g', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('p', S(1))*(a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(c_ + WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons4, cons5, cons71, cons1621, cons17) def replacement4360(p, m, f, b, g, d, a, c, n, x, e): rubi.append(4360) return Dist(g**(-m)*(g/sin(e + f*x))**(m + p)*(c + d/sin(e + f*x))**n*(c*sin(e + f*x) + d)**(-n), Int((a*sin(e + f*x) + b)**m*(c*sin(e + f*x) + d)**n, x), x) rule4360 = ReplacementRule(pattern4360, replacement4360) pattern4361 = Pattern(Integral((WC('g', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('p', S(1))*(a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(c_ + WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons21, cons4, cons5, cons71, cons1621, cons18) def replacement4361(p, m, f, g, b, d, a, c, n, x, e): rubi.append(4361) return Dist((g/cos(e + f*x))**p*(a + b/cos(e + f*x))**m*(c + d/cos(e + f*x))**n*(a*cos(e + f*x) + b)**(-m)*(c*cos(e + f*x) + d)**(-n), Int((a*cos(e + f*x) + b)**m*(c*cos(e + f*x) + d)**n, x), x) rule4361 = ReplacementRule(pattern4361, replacement4361) pattern4362 = Pattern(Integral((WC('g', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('p', S(1))*(a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(c_ + WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons21, cons4, cons5, cons71, cons1621, cons18) def replacement4362(p, m, f, b, g, d, a, c, n, x, e): rubi.append(4362) return Dist((g/sin(e + f*x))**p*(a + b/sin(e + f*x))**m*(c + d/sin(e + f*x))**n*(a*sin(e + f*x) + b)**(-m)*(c*sin(e + f*x) + d)**(-n), Int((a*sin(e + f*x) + b)**m*(c*sin(e + f*x) + d)**n, x), x) rule4362 = ReplacementRule(pattern4362, replacement4362) pattern4363 = Pattern(Integral((a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(c_ + WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(S(1)/cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons4, cons71, cons1304, cons1607, cons38, cons1622) def replacement4363(p, m, f, b, d, a, c, n, x, e): rubi.append(4363) return Dist(sqrt(a + b/cos(e + f*x))*sqrt(c*cos(e + f*x) + d)/(sqrt(c + d/cos(e + f*x))*sqrt(a*cos(e + f*x) + b)), Int((a*cos(e + f*x) + b)**m*(c*cos(e + f*x) + d)**n*cos(e + f*x)**(-m - n - p), x), x) rule4363 = ReplacementRule(pattern4363, replacement4363) pattern4364 = Pattern(Integral((a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(c_ + WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(S(1)/sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons4, cons71, cons1304, cons1607, cons38, cons1622) def replacement4364(p, m, f, b, d, a, c, n, x, e): rubi.append(4364) return Dist(sqrt(a + b/sin(e + f*x))*sqrt(c*sin(e + f*x) + d)/(sqrt(c + d/sin(e + f*x))*sqrt(a*sin(e + f*x) + b)), Int((a*sin(e + f*x) + b)**m*(c*sin(e + f*x) + d)**n*sin(e + f*x)**(-m - n - p), x), x) rule4364 = ReplacementRule(pattern4364, replacement4364) pattern4365 = Pattern(Integral((WC('g', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('p', S(1))*(a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(c_ + WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons21, cons4, cons5, cons71, cons1415) def replacement4365(p, m, f, g, b, d, a, c, n, x, e): rubi.append(4365) return Int(ExpandTrig((g/cos(e + f*x))**p*(a + b/cos(e + f*x))**m*(c + d/cos(e + f*x))**n, x), x) rule4365 = ReplacementRule(pattern4365, replacement4365) pattern4366 = Pattern(Integral((WC('g', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('p', S(1))*(a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(c_ + WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons21, cons4, cons5, cons71, cons1415) def replacement4366(p, m, f, b, g, d, a, c, n, x, e): rubi.append(4366) return Int(ExpandTrig((g/sin(e + f*x))**p*(a + b/sin(e + f*x))**m*(c + d/sin(e + f*x))**n, x), x) rule4366 = ReplacementRule(pattern4366, replacement4366) pattern4367 = Pattern(Integral((WC('g', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons21, cons4, cons5, cons380) def replacement4367(p, m, f, g, b, d, a, c, n, x, e): rubi.append(4367) return Int((g/cos(e + f*x))**p*(a + b/cos(e + f*x))**m*(c + d/cos(e + f*x))**n, x) rule4367 = ReplacementRule(pattern4367, replacement4367) pattern4368 = Pattern(Integral((WC('g', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons21, cons4, cons5, cons380) def replacement4368(p, m, f, b, g, d, c, a, n, x, e): rubi.append(4368) return Int((g/sin(e + f*x))**p*(a + b/sin(e + f*x))**m*(c + d/sin(e + f*x))**n, x) rule4368 = ReplacementRule(pattern4368, replacement4368) pattern4369 = Pattern(Integral((A_ + WC('B', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))/(sqrt(a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))*(c_ + WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**(S(3)/2)*cos(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons71, cons1267, cons1323, cons1428) def replacement4369(B, f, b, d, a, c, A, x, e): rubi.append(4369) return Simp(S(2)*A*sqrt((S(1) - S(1)/cos(e + f*x))*(-a*d + b*c)/((a + b)*(c + d/cos(e + f*x))))*(S(1) + S(1)/cos(e + f*x))*EllipticE(asin(sqrt(a + b/cos(e + f*x))*Rt((c + d)/(a + b), S(2))/sqrt(c + d/cos(e + f*x))), (a + b)*(c - d)/((a - b)*(c + d)))/(f*sqrt(-(S(1) + S(1)/cos(e + f*x))*(-a*d + b*c)/((a - b)*(c + d/cos(e + f*x))))*(-a*d + b*c)*Rt((c + d)/(a + b), S(2))*tan(e + f*x)), x) rule4369 = ReplacementRule(pattern4369, replacement4369) pattern4370 = Pattern(Integral((A_ + WC('B', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))/(sqrt(a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))*(c_ + WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**(S(3)/2)*sin(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons71, cons1267, cons1323, cons1428) def replacement4370(B, f, b, d, a, c, A, x, e): rubi.append(4370) return Simp(-S(2)*A*sqrt((S(1) - S(1)/sin(e + f*x))*(-a*d + b*c)/((a + b)*(c + d/sin(e + f*x))))*(S(1) + S(1)/sin(e + f*x))*EllipticE(asin(sqrt(a + b/sin(e + f*x))*Rt((c + d)/(a + b), S(2))/sqrt(c + d/sin(e + f*x))), (a + b)*(c - d)/((a - b)*(c + d)))*tan(e + f*x)/(f*sqrt(-(S(1) + S(1)/sin(e + f*x))*(-a*d + b*c)/((a - b)*(c + d/sin(e + f*x))))*(-a*d + b*c)*Rt((c + d)/(a + b), S(2))), x) rule4370 = ReplacementRule(pattern4370, replacement4370) pattern4371 = Pattern(Integral((WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(A_ + WC('B', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))*(a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons27, cons48, cons125, cons34, cons35, cons1245, cons87, cons1586) def replacement4371(B, f, b, d, a, n, A, x, e): rubi.append(4371) return Dist(S(1)/(d*n), Int((d/cos(e + f*x))**(n + S(1))*Simp(n*(A*b + B*a) + (A*a*(n + S(1)) + B*b*n)/cos(e + f*x), x), x), x) - Simp(A*a*(d/cos(e + f*x))**n*tan(e + f*x)/(f*n), x) rule4371 = ReplacementRule(pattern4371, replacement4371) pattern4372 = Pattern(Integral((WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(A_ + WC('B', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))*(a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons27, cons48, cons125, cons34, cons35, cons1245, cons87, cons1586) def replacement4372(B, f, b, d, a, n, A, x, e): rubi.append(4372) return Dist(S(1)/(d*n), Int((d/sin(e + f*x))**(n + S(1))*Simp(n*(A*b + B*a) + (A*a*(n + S(1)) + B*b*n)/sin(e + f*x), x), x), x) + Simp(A*a*(d/sin(e + f*x))**n/(f*n*tan(e + f*x)), x) rule4372 = ReplacementRule(pattern4372, replacement4372) pattern4373 = Pattern(Integral((WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1))*(A_ + WC('B', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))*(a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons27, cons48, cons125, cons34, cons35, cons1245, cons1569) def replacement4373(B, f, b, d, a, n, A, x, e): rubi.append(4373) return Dist(S(1)/(n + S(1)), Int((d/cos(e + f*x))**n*Simp(A*a*(n + S(1)) + B*b*n + (n + S(1))*(A*b + B*a)/cos(e + f*x), x), x), x) + Simp(B*b*(d/cos(e + f*x))**n*tan(e + f*x)/(f*(n + S(1))), x) rule4373 = ReplacementRule(pattern4373, replacement4373) pattern4374 = Pattern(Integral((WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1))*(A_ + WC('B', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))*(a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons27, cons48, cons125, cons34, cons35, cons1245, cons1569) def replacement4374(B, f, b, d, a, n, A, x, e): rubi.append(4374) return Dist(S(1)/(n + S(1)), Int((d/sin(e + f*x))**n*Simp(A*a*(n + S(1)) + B*b*n + (n + S(1))*(A*b + B*a)/sin(e + f*x), x), x), x) - Simp(B*b*(d/sin(e + f*x))**n/(f*(n + S(1))*tan(e + f*x)), x) rule4374 = ReplacementRule(pattern4374, replacement4374) pattern4375 = Pattern(Integral((A_ + WC('B', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))/((a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))*cos(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons48, cons125, cons34, cons35, cons1245) def replacement4375(B, f, b, a, A, x, e): rubi.append(4375) return Dist(B/b, Int(S(1)/cos(e + f*x), x), x) + Dist((A*b - B*a)/b, Int(S(1)/((a + b/cos(e + f*x))*cos(e + f*x)), x), x) rule4375 = ReplacementRule(pattern4375, replacement4375) pattern4376 = Pattern(Integral((A_ + WC('B', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))/((a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))*sin(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons48, cons125, cons34, cons35, cons1245) def replacement4376(B, f, b, a, A, x, e): rubi.append(4376) return Dist(B/b, Int(S(1)/sin(e + f*x), x), x) + Dist((A*b - B*a)/b, Int(S(1)/((a + b/sin(e + f*x))*sin(e + f*x)), x), x) rule4376 = ReplacementRule(pattern4376, replacement4376) pattern4377 = Pattern(Integral((A_ + WC('B', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))*(a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_/cos(x_*WC('f', S(1)) + WC('e', S(0))), x_), cons2, cons3, cons34, cons35, cons48, cons125, cons21, cons1245, cons1265, cons1623) def replacement4377(B, m, f, b, a, A, x, e): rubi.append(4377) return Simp(B*(a + b/cos(e + f*x))**m*tan(e + f*x)/(f*(m + S(1))), x) rule4377 = ReplacementRule(pattern4377, replacement4377) pattern4378 = Pattern(Integral((A_ + WC('B', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))*(a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_/sin(x_*WC('f', S(1)) + WC('e', S(0))), x_), cons2, cons3, cons34, cons35, cons48, cons125, cons21, cons1245, cons1265, cons1623) def replacement4378(B, m, f, b, a, A, x, e): rubi.append(4378) return -Simp(B*(a + b/sin(e + f*x))**m/(f*(m + S(1))*tan(e + f*x)), x) rule4378 = ReplacementRule(pattern4378, replacement4378) pattern4379 = Pattern(Integral((A_ + WC('B', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))*(a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_/cos(x_*WC('f', S(1)) + WC('e', S(0))), x_), cons2, cons3, cons34, cons35, cons48, cons125, cons1245, cons1265, cons1624, cons31, cons1320) def replacement4379(B, m, f, b, a, A, x, e): rubi.append(4379) return Dist((A*b*(m + S(1)) + B*a*m)/(a*b*(S(2)*m + S(1))), Int((a + b/cos(e + f*x))**(m + S(1))/cos(e + f*x), x), x) - Simp((a + b/cos(e + f*x))**m*(A*b - B*a)*tan(e + f*x)/(a*f*(S(2)*m + S(1))), x) rule4379 = ReplacementRule(pattern4379, replacement4379) pattern4380 = Pattern(Integral((A_ + WC('B', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))*(a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_/sin(x_*WC('f', S(1)) + WC('e', S(0))), x_), cons2, cons3, cons34, cons35, cons48, cons125, cons1245, cons1265, cons1624, cons31, cons1320) def replacement4380(B, m, f, b, a, A, x, e): rubi.append(4380) return Dist((A*b*(m + S(1)) + B*a*m)/(a*b*(S(2)*m + S(1))), Int((a + b/sin(e + f*x))**(m + S(1))/sin(e + f*x), x), x) + Simp((a + b/sin(e + f*x))**m*(A*b - B*a)/(a*f*(S(2)*m + S(1))*tan(e + f*x)), x) rule4380 = ReplacementRule(pattern4380, replacement4380) pattern4381 = Pattern(Integral((A_ + WC('B', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))*(a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_/cos(x_*WC('f', S(1)) + WC('e', S(0))), x_), cons2, cons3, cons34, cons35, cons48, cons125, cons21, cons1245, cons1265, cons1624, cons1321) def replacement4381(B, m, f, b, a, A, x, e): rubi.append(4381) return Dist((A*b*(m + S(1)) + B*a*m)/(b*(m + S(1))), Int((a + b/cos(e + f*x))**m/cos(e + f*x), x), x) + Simp(B*(a + b/cos(e + f*x))**m*tan(e + f*x)/(f*(m + S(1))), x) rule4381 = ReplacementRule(pattern4381, replacement4381) pattern4382 = Pattern(Integral((A_ + WC('B', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))*(a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_/sin(x_*WC('f', S(1)) + WC('e', S(0))), x_), cons2, cons3, cons34, cons35, cons48, cons125, cons21, cons1245, cons1265, cons1624, cons1321) def replacement4382(B, m, f, b, a, A, x, e): rubi.append(4382) return Dist((A*b*(m + S(1)) + B*a*m)/(b*(m + S(1))), Int((a + b/sin(e + f*x))**m/sin(e + f*x), x), x) - Simp(B*(a + b/sin(e + f*x))**m/(f*(m + S(1))*tan(e + f*x)), x) rule4382 = ReplacementRule(pattern4382, replacement4382) pattern4383 = Pattern(Integral((A_ + WC('B', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))*(a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_/cos(x_*WC('f', S(1)) + WC('e', S(0))), x_), cons2, cons3, cons34, cons35, cons48, cons125, cons1245, cons1267, cons31, cons168) def replacement4383(B, m, f, b, a, A, x, e): rubi.append(4383) return Dist(S(1)/(m + S(1)), Int((a + b/cos(e + f*x))**(m + S(-1))*Simp(A*a*(m + S(1)) + B*b*m + (A*b*(m + S(1)) + B*a*m)/cos(e + f*x), x)/cos(e + f*x), x), x) + Simp(B*(a + b/cos(e + f*x))**m*tan(e + f*x)/(f*(m + S(1))), x) rule4383 = ReplacementRule(pattern4383, replacement4383) pattern4384 = Pattern(Integral((A_ + WC('B', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))*(a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_/sin(x_*WC('f', S(1)) + WC('e', S(0))), x_), cons2, cons3, cons34, cons35, cons48, cons125, cons1245, cons1267, cons31, cons168) def replacement4384(B, m, f, b, a, A, x, e): rubi.append(4384) return Dist(S(1)/(m + S(1)), Int((a + b/sin(e + f*x))**(m + S(-1))*Simp(A*a*(m + S(1)) + B*b*m + (A*b*(m + S(1)) + B*a*m)/sin(e + f*x), x)/sin(e + f*x), x), x) - Simp(B*(a + b/sin(e + f*x))**m/(f*(m + S(1))*tan(e + f*x)), x) rule4384 = ReplacementRule(pattern4384, replacement4384) pattern4385 = Pattern(Integral((A_ + WC('B', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))*(a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_/cos(x_*WC('f', S(1)) + WC('e', S(0))), x_), cons2, cons3, cons34, cons35, cons48, cons125, cons1245, cons1267, cons31, cons94) def replacement4385(B, m, f, b, a, A, x, e): rubi.append(4385) return Dist(S(1)/((a**S(2) - b**S(2))*(m + S(1))), Int((a + b/cos(e + f*x))**(m + S(1))*Simp((m + S(1))*(A*a - B*b) - (m + S(2))*(A*b - B*a)/cos(e + f*x), x)/cos(e + f*x), x), x) + Simp((a + b/cos(e + f*x))**(m + S(1))*(A*b - B*a)*tan(e + f*x)/(f*(a**S(2) - b**S(2))*(m + S(1))), x) rule4385 = ReplacementRule(pattern4385, replacement4385) pattern4386 = Pattern(Integral((A_ + WC('B', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))*(a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_/sin(x_*WC('f', S(1)) + WC('e', S(0))), x_), cons2, cons3, cons34, cons35, cons48, cons125, cons1245, cons1267, cons31, cons94) def replacement4386(B, m, f, b, a, A, x, e): rubi.append(4386) return Dist(S(1)/((a**S(2) - b**S(2))*(m + S(1))), Int((a + b/sin(e + f*x))**(m + S(1))*Simp((m + S(1))*(A*a - B*b) - (m + S(2))*(A*b - B*a)/sin(e + f*x), x)/sin(e + f*x), x), x) - Simp((a + b/sin(e + f*x))**(m + S(1))*(A*b - B*a)/(f*(a**S(2) - b**S(2))*(m + S(1))*tan(e + f*x)), x) rule4386 = ReplacementRule(pattern4386, replacement4386) pattern4387 = Pattern(Integral((A_ + WC('B', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))/(sqrt(a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))*cos(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons48, cons125, cons34, cons35, cons1267, cons1625) def replacement4387(B, f, b, a, A, x, e): rubi.append(4387) return Simp(S(2)*sqrt(b*(S(1) - S(1)/cos(e + f*x))/(a + b))*sqrt(-b*(S(1) + S(1)/cos(e + f*x))/(a - b))*(A*b - B*a)*EllipticE(asin(sqrt(a + b/cos(e + f*x))/Rt(a + B*b/A, S(2))), (A*a + B*b)/(A*a - B*b))*Rt(a + B*b/A, S(2))/(b**S(2)*f*tan(e + f*x)), x) rule4387 = ReplacementRule(pattern4387, replacement4387) pattern4388 = Pattern(Integral((A_ + WC('B', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))/(sqrt(a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))*sin(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons48, cons125, cons34, cons35, cons1267, cons1625) def replacement4388(B, f, b, a, A, x, e): rubi.append(4388) return Simp(-S(2)*sqrt(b*(S(1) - S(1)/sin(e + f*x))/(a + b))*sqrt(-b*(S(1) + S(1)/sin(e + f*x))/(a - b))*(A*b - B*a)*EllipticE(asin(sqrt(a + b/sin(e + f*x))/Rt(a + B*b/A, S(2))), (A*a + B*b)/(A*a - B*b))*Rt(a + B*b/A, S(2))*tan(e + f*x)/(b**S(2)*f), x) rule4388 = ReplacementRule(pattern4388, replacement4388) pattern4389 = Pattern(Integral((A_ + WC('B', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))/(sqrt(a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))*cos(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons48, cons125, cons34, cons35, cons1267, cons1626) def replacement4389(B, f, b, a, A, x, e): rubi.append(4389) return Dist(B, Int((S(1) + S(1)/cos(e + f*x))/(sqrt(a + b/cos(e + f*x))*cos(e + f*x)), x), x) + Dist(A - B, Int(S(1)/(sqrt(a + b/cos(e + f*x))*cos(e + f*x)), x), x) rule4389 = ReplacementRule(pattern4389, replacement4389) pattern4390 = Pattern(Integral((A_ + WC('B', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))/(sqrt(a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))*sin(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons48, cons125, cons34, cons35, cons1267, cons1626) def replacement4390(B, f, b, a, A, x, e): rubi.append(4390) return Dist(B, Int((S(1) + S(1)/sin(e + f*x))/(sqrt(a + b/sin(e + f*x))*sin(e + f*x)), x), x) + Dist(A - B, Int(S(1)/(sqrt(a + b/sin(e + f*x))*sin(e + f*x)), x), x) rule4390 = ReplacementRule(pattern4390, replacement4390) pattern4391 = Pattern(Integral((A_ + WC('B', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))*(a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_/cos(x_*WC('f', S(1)) + WC('e', S(0))), x_), cons2, cons3, cons34, cons35, cons48, cons125, cons1245, cons1267, cons1625, cons77) def replacement4391(B, m, f, b, a, A, x, e): rubi.append(4391) return Simp(-S(2)*sqrt(S(2))*A*sqrt((A + B/cos(e + f*x))/A)*(A*(a + b/cos(e + f*x))/(A*a + B*b))**(-m)*(A - B/cos(e + f*x))*(a + b/cos(e + f*x))**m*AppellF1(S(1)/2, S(-1)/2, -m, S(3)/2, (A - B/cos(e + f*x))/(S(2)*A), b*(A - B/cos(e + f*x))/(A*b + B*a))/(B*f*tan(e + f*x)), x) rule4391 = ReplacementRule(pattern4391, replacement4391) pattern4392 = Pattern(Integral((A_ + WC('B', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))*(a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_/sin(x_*WC('f', S(1)) + WC('e', S(0))), x_), cons2, cons3, cons34, cons35, cons48, cons125, cons1245, cons1267, cons1625, cons77) def replacement4392(B, m, f, b, a, A, x, e): rubi.append(4392) return Simp(S(2)*sqrt(S(2))*A*sqrt((A + B/sin(e + f*x))/A)*(A*(a + b/sin(e + f*x))/(A*a + B*b))**(-m)*(A - B/sin(e + f*x))*(a + b/sin(e + f*x))**m*AppellF1(S(1)/2, S(-1)/2, -m, S(3)/2, (A - B/sin(e + f*x))/(S(2)*A), b*(A - B/sin(e + f*x))/(A*b + B*a))*tan(e + f*x)/(B*f), x) rule4392 = ReplacementRule(pattern4392, replacement4392) pattern4393 = Pattern(Integral((A_ + WC('B', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))*(a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_/cos(x_*WC('f', S(1)) + WC('e', S(0))), x_), cons2, cons3, cons34, cons35, cons48, cons125, cons21, cons1245, cons1267) def replacement4393(B, m, f, b, a, A, x, e): rubi.append(4393) return Dist(B/b, Int((a + b/cos(e + f*x))**(m + S(1))/cos(e + f*x), x), x) + Dist((A*b - B*a)/b, Int((a + b/cos(e + f*x))**m/cos(e + f*x), x), x) rule4393 = ReplacementRule(pattern4393, replacement4393) pattern4394 = Pattern(Integral((A_ + WC('B', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))*(a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_/sin(x_*WC('f', S(1)) + WC('e', S(0))), x_), cons2, cons3, cons34, cons35, cons48, cons125, cons21, cons1245, cons1267) def replacement4394(B, m, f, b, a, A, x, e): rubi.append(4394) return Dist(B/b, Int((a + b/sin(e + f*x))**(m + S(1))/sin(e + f*x), x), x) + Dist((A*b - B*a)/b, Int((a + b/sin(e + f*x))**m/sin(e + f*x), x), x) rule4394 = ReplacementRule(pattern4394, replacement4394) pattern4395 = Pattern(Integral((A_ + WC('B', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))*(a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_/cos(x_*WC('f', S(1)) + WC('e', S(0)))**S(2), x_), cons2, cons3, cons48, cons125, cons34, cons35, cons1245, cons1265, cons31, cons1320) def replacement4395(B, m, f, b, a, A, x, e): rubi.append(4395) return Dist(S(1)/(b**S(2)*(S(2)*m + S(1))), Int((a + b/cos(e + f*x))**(m + S(1))*Simp(A*b*m - B*a*m + B*b*(S(2)*m + S(1))/cos(e + f*x), x)/cos(e + f*x), x), x) + Simp((a + b/cos(e + f*x))**m*(A*b - B*a)*tan(e + f*x)/(b*f*(S(2)*m + S(1))), x) rule4395 = ReplacementRule(pattern4395, replacement4395) pattern4396 = Pattern(Integral((A_ + WC('B', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))*(a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_/sin(x_*WC('f', S(1)) + WC('e', S(0)))**S(2), x_), cons2, cons3, cons48, cons125, cons34, cons35, cons1245, cons1265, cons31, cons1320) def replacement4396(B, m, f, b, a, A, x, e): rubi.append(4396) return Dist(S(1)/(b**S(2)*(S(2)*m + S(1))), Int((a + b/sin(e + f*x))**(m + S(1))*Simp(A*b*m - B*a*m + B*b*(S(2)*m + S(1))/sin(e + f*x), x)/sin(e + f*x), x), x) - Simp((a + b/sin(e + f*x))**m*(A*b - B*a)/(b*f*(S(2)*m + S(1))*tan(e + f*x)), x) rule4396 = ReplacementRule(pattern4396, replacement4396) pattern4397 = Pattern(Integral((A_ + WC('B', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))*(a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_/cos(x_*WC('f', S(1)) + WC('e', S(0)))**S(2), x_), cons2, cons3, cons48, cons125, cons34, cons35, cons1245, cons1267, cons31, cons94) def replacement4397(B, m, f, b, a, A, x, e): rubi.append(4397) return -Dist(S(1)/(b*(a**S(2) - b**S(2))*(m + S(1))), Int((a + b/cos(e + f*x))**(m + S(1))*Simp(b*(m + S(1))*(A*b - B*a) - (A*a*b*(m + S(2)) - B*(a**S(2) + b**S(2)*(m + S(1))))/cos(e + f*x), x)/cos(e + f*x), x), x) - Simp(a*(a + b/cos(e + f*x))**(m + S(1))*(A*b - B*a)*tan(e + f*x)/(b*f*(a**S(2) - b**S(2))*(m + S(1))), x) rule4397 = ReplacementRule(pattern4397, replacement4397) pattern4398 = Pattern(Integral((A_ + WC('B', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))*(a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_/sin(x_*WC('f', S(1)) + WC('e', S(0)))**S(2), x_), cons2, cons3, cons48, cons125, cons34, cons35, cons1245, cons1267, cons31, cons94) def replacement4398(B, m, f, b, a, A, x, e): rubi.append(4398) return -Dist(S(1)/(b*(a**S(2) - b**S(2))*(m + S(1))), Int((a + b/sin(e + f*x))**(m + S(1))*Simp(b*(m + S(1))*(A*b - B*a) - (A*a*b*(m + S(2)) - B*(a**S(2) + b**S(2)*(m + S(1))))/sin(e + f*x), x)/sin(e + f*x), x), x) + Simp(a*(a + b/sin(e + f*x))**(m + S(1))*(A*b - B*a)/(b*f*(a**S(2) - b**S(2))*(m + S(1))*tan(e + f*x)), x) rule4398 = ReplacementRule(pattern4398, replacement4398) pattern4399 = Pattern(Integral((A_ + WC('B', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))*(a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_/cos(x_*WC('f', S(1)) + WC('e', S(0)))**S(2), x_), cons2, cons3, cons48, cons125, cons34, cons35, cons21, cons1245, cons272) def replacement4399(B, m, f, b, a, A, x, e): rubi.append(4399) return Dist(S(1)/(b*(m + S(2))), Int((a + b/cos(e + f*x))**m*Simp(B*b*(m + S(1)) + (A*b*(m + S(2)) - B*a)/cos(e + f*x), x)/cos(e + f*x), x), x) + Simp(B*(a + b/cos(e + f*x))**(m + S(1))*tan(e + f*x)/(b*f*(m + S(2))), x) rule4399 = ReplacementRule(pattern4399, replacement4399) pattern4400 = Pattern(Integral((A_ + WC('B', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))*(a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_/sin(x_*WC('f', S(1)) + WC('e', S(0)))**S(2), x_), cons2, cons3, cons48, cons125, cons34, cons35, cons21, cons1245, cons272) def replacement4400(B, m, f, b, a, A, x, e): rubi.append(4400) return Dist(S(1)/(b*(m + S(2))), Int((a + b/sin(e + f*x))**m*Simp(B*b*(m + S(1)) + (A*b*(m + S(2)) - B*a)/sin(e + f*x), x)/sin(e + f*x), x), x) - Simp(B*(a + b/sin(e + f*x))**(m + S(1))/(b*f*(m + S(2))*tan(e + f*x)), x) rule4400 = ReplacementRule(pattern4400, replacement4400) pattern4401 = Pattern(Integral((WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(A_ + WC('B', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))*(a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_, x_), cons2, cons3, cons27, cons48, cons125, cons34, cons35, cons21, cons4, cons1245, cons1265, cons155, cons1627) def replacement4401(B, m, f, b, d, a, n, A, x, e): rubi.append(4401) return -Simp(A*(d/cos(e + f*x))**n*(a + b/cos(e + f*x))**m*tan(e + f*x)/(f*n), x) rule4401 = ReplacementRule(pattern4401, replacement4401) pattern4402 = Pattern(Integral((WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(A_ + WC('B', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))*(a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_, x_), cons2, cons3, cons27, cons48, cons125, cons34, cons35, cons21, cons4, cons1245, cons1265, cons155, cons1627) def replacement4402(B, m, f, b, d, a, n, A, x, e): rubi.append(4402) return Simp(A*(d/sin(e + f*x))**n*(a + b/sin(e + f*x))**m/(f*n*tan(e + f*x)), x) rule4402 = ReplacementRule(pattern4402, replacement4402) pattern4403 = Pattern(Integral((WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(A_ + WC('B', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))*(a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_, x_), cons2, cons3, cons27, cons48, cons125, cons34, cons35, cons4, cons1245, cons1265, cons155, cons31, cons32) def replacement4403(B, m, f, b, d, a, n, A, x, e): rubi.append(4403) return Dist((A*a*m + B*b*(m + S(1)))/(a**S(2)*(S(2)*m + S(1))), Int((d/cos(e + f*x))**n*(a + b/cos(e + f*x))**(m + S(1)), x), x) + Simp((d/cos(e + f*x))**n*(a + b/cos(e + f*x))**m*(A*b - B*a)*tan(e + f*x)/(b*f*(S(2)*m + S(1))), x) rule4403 = ReplacementRule(pattern4403, replacement4403) pattern4404 = Pattern(Integral((WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(A_ + WC('B', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))*(a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_, x_), cons2, cons3, cons27, cons48, cons125, cons34, cons35, cons4, cons1245, cons1265, cons155, cons31, cons32) def replacement4404(B, m, f, b, d, a, n, A, x, e): rubi.append(4404) return Dist((A*a*m + B*b*(m + S(1)))/(a**S(2)*(S(2)*m + S(1))), Int((d/sin(e + f*x))**n*(a + b/sin(e + f*x))**(m + S(1)), x), x) - Simp((d/sin(e + f*x))**n*(a + b/sin(e + f*x))**m*(A*b - B*a)/(b*f*(S(2)*m + S(1))*tan(e + f*x)), x) rule4404 = ReplacementRule(pattern4404, replacement4404) pattern4405 = Pattern(Integral((WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(A_ + WC('B', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))*(a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_, x_), cons2, cons3, cons27, cons48, cons125, cons34, cons35, cons21, cons4, cons1245, cons1265, cons155, cons1549) def replacement4405(B, m, f, b, d, a, n, A, x, e): rubi.append(4405) return -Dist((A*a*m - B*b*n)/(b*d*n), Int((d/cos(e + f*x))**(n + S(1))*(a + b/cos(e + f*x))**m, x), x) - Simp(A*(d/cos(e + f*x))**n*(a + b/cos(e + f*x))**m*tan(e + f*x)/(f*n), x) rule4405 = ReplacementRule(pattern4405, replacement4405) pattern4406 = Pattern(Integral((WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(A_ + WC('B', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))*(a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_, x_), cons2, cons3, cons27, cons48, cons125, cons34, cons35, cons21, cons4, cons1245, cons1265, cons155, cons1549) def replacement4406(B, m, f, b, d, a, n, A, x, e): rubi.append(4406) return -Dist((A*a*m - B*b*n)/(b*d*n), Int((d/sin(e + f*x))**(n + S(1))*(a + b/sin(e + f*x))**m, x), x) + Simp(A*(d/sin(e + f*x))**n*(a + b/sin(e + f*x))**m/(f*n*tan(e + f*x)), x) rule4406 = ReplacementRule(pattern4406, replacement4406) pattern4407 = Pattern(Integral((WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(A_ + WC('B', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))*sqrt(a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons27, cons48, cons125, cons34, cons35, cons4, cons1245, cons1265, cons1628) def replacement4407(B, f, b, d, a, n, A, x, e): rubi.append(4407) return Simp(S(2)*B*b*(d/cos(e + f*x))**n*tan(e + f*x)/(f*sqrt(a + b/cos(e + f*x))*(S(2)*n + S(1))), x) rule4407 = ReplacementRule(pattern4407, replacement4407) pattern4408 = Pattern(Integral((WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(A_ + WC('B', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))*sqrt(a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons27, cons48, cons125, cons34, cons35, cons4, cons1245, cons1265, cons1628) def replacement4408(B, f, b, d, a, n, A, x, e): rubi.append(4408) return Simp(-S(2)*B*b*(d/sin(e + f*x))**n/(f*sqrt(a + b/sin(e + f*x))*(S(2)*n + S(1))*tan(e + f*x)), x) rule4408 = ReplacementRule(pattern4408, replacement4408) pattern4409 = Pattern(Integral((WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(A_ + WC('B', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))*sqrt(a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons27, cons48, cons125, cons34, cons35, cons1245, cons1265, cons1629, cons87, cons463) def replacement4409(B, f, b, d, a, n, A, x, e): rubi.append(4409) return Dist((A*b*(S(2)*n + S(1)) + S(2)*B*a*n)/(S(2)*a*d*n), Int((d/cos(e + f*x))**(n + S(1))*sqrt(a + b/cos(e + f*x)), x), x) - Simp(A*b**S(2)*(d/cos(e + f*x))**n*tan(e + f*x)/(a*f*n*sqrt(a + b/cos(e + f*x))), x) rule4409 = ReplacementRule(pattern4409, replacement4409) pattern4410 = Pattern(Integral((WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(A_ + WC('B', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))*sqrt(a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons27, cons48, cons125, cons34, cons35, cons1245, cons1265, cons1629, cons87, cons463) def replacement4410(B, f, b, d, a, n, A, x, e): rubi.append(4410) return Dist((A*b*(S(2)*n + S(1)) + S(2)*B*a*n)/(S(2)*a*d*n), Int((d/sin(e + f*x))**(n + S(1))*sqrt(a + b/sin(e + f*x)), x), x) + Simp(A*b**S(2)*(d/sin(e + f*x))**n/(a*f*n*sqrt(a + b/sin(e + f*x))*tan(e + f*x)), x) rule4410 = ReplacementRule(pattern4410, replacement4410) pattern4411 = Pattern(Integral((WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(A_ + WC('B', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))*sqrt(a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons27, cons48, cons125, cons34, cons35, cons4, cons1245, cons1265, cons1629, cons1231) def replacement4411(B, f, b, d, a, n, A, x, e): rubi.append(4411) return Dist((A*b*(S(2)*n + S(1)) + S(2)*B*a*n)/(b*(S(2)*n + S(1))), Int((d/cos(e + f*x))**n*sqrt(a + b/cos(e + f*x)), x), x) + Simp(S(2)*B*b*(d/cos(e + f*x))**n*tan(e + f*x)/(f*sqrt(a + b/cos(e + f*x))*(S(2)*n + S(1))), x) rule4411 = ReplacementRule(pattern4411, replacement4411) pattern4412 = Pattern(Integral((WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(A_ + WC('B', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))*sqrt(a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons27, cons48, cons125, cons34, cons35, cons4, cons1245, cons1265, cons1629, cons1231) def replacement4412(B, f, b, d, a, n, A, x, e): rubi.append(4412) return Dist((A*b*(S(2)*n + S(1)) + S(2)*B*a*n)/(b*(S(2)*n + S(1))), Int((d/sin(e + f*x))**n*sqrt(a + b/sin(e + f*x)), x), x) + Simp(-S(2)*B*b*(d/sin(e + f*x))**n/(f*sqrt(a + b/sin(e + f*x))*(S(2)*n + S(1))*tan(e + f*x)), x) rule4412 = ReplacementRule(pattern4412, replacement4412) pattern4413 = Pattern(Integral((WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(A_ + WC('B', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))*(a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_, x_), cons2, cons3, cons27, cons48, cons125, cons34, cons35, cons1245, cons1265, cons93, cons1423, cons89) def replacement4413(B, m, f, b, d, a, n, A, x, e): rubi.append(4413) return -Dist(b/(a*d*n), Int((d/cos(e + f*x))**(n + S(1))*(a + b/cos(e + f*x))**(m + S(-1))*Simp(A*a*(m - n + S(-1)) - B*b*n - (A*b*(m + n) + B*a*n)/cos(e + f*x), x), x), x) - Simp(A*a*(d/cos(e + f*x))**n*(a + b/cos(e + f*x))**(m + S(-1))*tan(e + f*x)/(f*n), x) rule4413 = ReplacementRule(pattern4413, replacement4413) pattern4414 = Pattern(Integral((WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(A_ + WC('B', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))*(a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_, x_), cons2, cons3, cons27, cons48, cons125, cons34, cons35, cons1245, cons1265, cons93, cons1423, cons89) def replacement4414(B, m, f, b, d, a, n, A, x, e): rubi.append(4414) return -Dist(b/(a*d*n), Int((d/sin(e + f*x))**(n + S(1))*(a + b/sin(e + f*x))**(m + S(-1))*Simp(A*a*(m - n + S(-1)) - B*b*n - (A*b*(m + n) + B*a*n)/sin(e + f*x), x), x), x) + Simp(A*a*(d/sin(e + f*x))**n*(a + b/sin(e + f*x))**(m + S(-1))/(f*n*tan(e + f*x)), x) rule4414 = ReplacementRule(pattern4414, replacement4414) pattern4415 = Pattern(Integral((WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(A_ + WC('B', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))*(a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_, x_), cons2, cons3, cons27, cons48, cons125, cons34, cons35, cons4, cons1245, cons1265, cons31, cons1423, cons346) def replacement4415(B, m, f, b, d, a, n, A, x, e): rubi.append(4415) return Dist(S(1)/(d*(m + n)), Int((d/cos(e + f*x))**n*(a + b/cos(e + f*x))**(m + S(-1))*Simp(A*a*d*(m + n) + B*b*d*n + (A*b*d*(m + n) + B*a*d*(S(2)*m + n + S(-1)))/cos(e + f*x), x), x), x) + Simp(B*b*(d/cos(e + f*x))**n*(a + b/cos(e + f*x))**(m + S(-1))*tan(e + f*x)/(f*(m + n)), x) rule4415 = ReplacementRule(pattern4415, replacement4415) pattern4416 = Pattern(Integral((WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(A_ + WC('B', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))*(a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_, x_), cons2, cons3, cons27, cons48, cons125, cons34, cons35, cons4, cons1245, cons1265, cons31, cons1423, cons346) def replacement4416(B, m, f, b, d, a, n, A, x, e): rubi.append(4416) return Dist(S(1)/(d*(m + n)), Int((d/sin(e + f*x))**n*(a + b/sin(e + f*x))**(m + S(-1))*Simp(A*a*d*(m + n) + B*b*d*n + (A*b*d*(m + n) + B*a*d*(S(2)*m + n + S(-1)))/sin(e + f*x), x), x), x) - Simp(B*b*(d/sin(e + f*x))**n*(a + b/sin(e + f*x))**(m + S(-1))/(f*(m + n)*tan(e + f*x)), x) rule4416 = ReplacementRule(pattern4416, replacement4416) pattern4417 = Pattern(Integral((WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(A_ + WC('B', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))*(a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_, x_), cons2, cons3, cons27, cons48, cons125, cons34, cons35, cons1245, cons1265, cons93, cons1320, cons88) def replacement4417(B, m, f, b, d, a, n, A, x, e): rubi.append(4417) return -Dist(S(1)/(a*b*(S(2)*m + S(1))), Int((d/cos(e + f*x))**(n + S(-1))*(a + b/cos(e + f*x))**(m + S(1))*Simp(A*a*d*(n + S(-1)) - B*b*d*(n + S(-1)) - d*(A*b*(m + n) + B*a*(m - n + S(1)))/cos(e + f*x), x), x), x) - Simp(d*(d/cos(e + f*x))**(n + S(-1))*(a + b/cos(e + f*x))**m*(A*b - B*a)*tan(e + f*x)/(a*f*(S(2)*m + S(1))), x) rule4417 = ReplacementRule(pattern4417, replacement4417) pattern4418 = Pattern(Integral((WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(A_ + WC('B', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))*(a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_, x_), cons2, cons3, cons27, cons48, cons125, cons34, cons35, cons1245, cons1265, cons93, cons1320, cons88) def replacement4418(B, m, f, b, d, a, n, A, x, e): rubi.append(4418) return -Dist(S(1)/(a*b*(S(2)*m + S(1))), Int((d/sin(e + f*x))**(n + S(-1))*(a + b/sin(e + f*x))**(m + S(1))*Simp(A*a*d*(n + S(-1)) - B*b*d*(n + S(-1)) - d*(A*b*(m + n) + B*a*(m - n + S(1)))/sin(e + f*x), x), x), x) + Simp(d*(d/sin(e + f*x))**(n + S(-1))*(a + b/sin(e + f*x))**m*(A*b - B*a)/(a*f*(S(2)*m + S(1))*tan(e + f*x)), x) rule4418 = ReplacementRule(pattern4418, replacement4418) pattern4419 = Pattern(Integral((WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(A_ + WC('B', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))*(a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_, x_), cons2, cons3, cons27, cons48, cons125, cons34, cons35, cons4, cons1245, cons1265, cons31, cons1320, cons1327) def replacement4419(B, m, f, b, d, a, n, A, x, e): rubi.append(4419) return -Dist(S(1)/(a**S(2)*(S(2)*m + S(1))), Int((d/cos(e + f*x))**n*(a + b/cos(e + f*x))**(m + S(1))*Simp(-A*a*(S(2)*m + n + S(1)) + B*b*n + (A*b - B*a)*(m + n + S(1))/cos(e + f*x), x), x), x) + Simp((d/cos(e + f*x))**n*(a + b/cos(e + f*x))**m*(A*b - B*a)*tan(e + f*x)/(b*f*(S(2)*m + S(1))), x) rule4419 = ReplacementRule(pattern4419, replacement4419) pattern4420 = Pattern(Integral((WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(A_ + WC('B', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))*(a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_, x_), cons2, cons3, cons27, cons48, cons125, cons34, cons35, cons4, cons1245, cons1265, cons31, cons1320, cons1327) def replacement4420(B, m, f, b, d, a, n, A, x, e): rubi.append(4420) return -Dist(S(1)/(a**S(2)*(S(2)*m + S(1))), Int((d/sin(e + f*x))**n*(a + b/sin(e + f*x))**(m + S(1))*Simp(-A*a*(S(2)*m + n + S(1)) + B*b*n + (A*b - B*a)*(m + n + S(1))/sin(e + f*x), x), x), x) - Simp((d/sin(e + f*x))**n*(a + b/sin(e + f*x))**m*(A*b - B*a)/(b*f*(S(2)*m + S(1))*tan(e + f*x)), x) rule4420 = ReplacementRule(pattern4420, replacement4420) pattern4421 = Pattern(Integral((WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(A_ + WC('B', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))*(a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_, x_), cons2, cons3, cons27, cons48, cons125, cons34, cons35, cons21, cons1245, cons1265, cons87, cons165) def replacement4421(B, m, f, b, d, a, n, A, x, e): rubi.append(4421) return Dist(d/(b*(m + n)), Int((d/cos(e + f*x))**(n + S(-1))*(a + b/cos(e + f*x))**m*Simp(B*b*(n + S(-1)) + (A*b*(m + n) + B*a*m)/cos(e + f*x), x), x), x) + Simp(B*d*(d/cos(e + f*x))**(n + S(-1))*(a + b/cos(e + f*x))**m*tan(e + f*x)/(f*(m + n)), x) rule4421 = ReplacementRule(pattern4421, replacement4421) pattern4422 = Pattern(Integral((WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(A_ + WC('B', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))*(a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_, x_), cons2, cons3, cons27, cons48, cons125, cons34, cons35, cons21, cons1245, cons1265, cons87, cons165) def replacement4422(B, m, f, b, d, a, n, A, x, e): rubi.append(4422) return Dist(d/(b*(m + n)), Int((d/sin(e + f*x))**(n + S(-1))*(a + b/sin(e + f*x))**m*Simp(B*b*(n + S(-1)) + (A*b*(m + n) + B*a*m)/sin(e + f*x), x), x), x) - Simp(B*d*(d/sin(e + f*x))**(n + S(-1))*(a + b/sin(e + f*x))**m/(f*(m + n)*tan(e + f*x)), x) rule4422 = ReplacementRule(pattern4422, replacement4422) pattern4423 = Pattern(Integral((WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(A_ + WC('B', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))*(a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_, x_), cons2, cons3, cons27, cons48, cons125, cons34, cons35, cons21, cons1245, cons1265, cons87, cons463) def replacement4423(B, m, f, b, d, a, n, A, x, e): rubi.append(4423) return -Dist(S(1)/(b*d*n), Int((d/cos(e + f*x))**(n + S(1))*(a + b/cos(e + f*x))**m*Simp(A*a*m - A*b*(m + n + S(1))/cos(e + f*x) - B*b*n, x), x), x) - Simp(A*(d/cos(e + f*x))**n*(a + b/cos(e + f*x))**m*tan(e + f*x)/(f*n), x) rule4423 = ReplacementRule(pattern4423, replacement4423) pattern4424 = Pattern(Integral((WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(A_ + WC('B', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))*(a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_, x_), cons2, cons3, cons27, cons48, cons125, cons34, cons35, cons21, cons1245, cons1265, cons87, cons463) def replacement4424(B, m, f, b, d, a, n, A, x, e): rubi.append(4424) return -Dist(S(1)/(b*d*n), Int((d/sin(e + f*x))**(n + S(1))*(a + b/sin(e + f*x))**m*Simp(A*a*m - A*b*(m + n + S(1))/sin(e + f*x) - B*b*n, x), x), x) + Simp(A*(d/sin(e + f*x))**n*(a + b/sin(e + f*x))**m/(f*n*tan(e + f*x)), x) rule4424 = ReplacementRule(pattern4424, replacement4424) pattern4425 = Pattern(Integral((WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(A_ + WC('B', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))*(a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_, x_), cons2, cons3, cons27, cons48, cons125, cons34, cons35, cons21, cons1245, cons1265) def replacement4425(B, m, f, b, d, a, n, A, x, e): rubi.append(4425) return Dist(B/b, Int((d/cos(e + f*x))**n*(a + b/cos(e + f*x))**(m + S(1)), x), x) + Dist((A*b - B*a)/b, Int((d/cos(e + f*x))**n*(a + b/cos(e + f*x))**m, x), x) rule4425 = ReplacementRule(pattern4425, replacement4425) pattern4426 = Pattern(Integral((WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(A_ + WC('B', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))*(a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_, x_), cons2, cons3, cons27, cons48, cons125, cons34, cons35, cons21, cons1245, cons1265) def replacement4426(B, m, f, b, d, a, n, A, x, e): rubi.append(4426) return Dist(B/b, Int((d/sin(e + f*x))**n*(a + b/sin(e + f*x))**(m + S(1)), x), x) + Dist((A*b - B*a)/b, Int((d/sin(e + f*x))**n*(a + b/sin(e + f*x))**m, x), x) rule4426 = ReplacementRule(pattern4426, replacement4426) pattern4427 = Pattern(Integral((WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(A_ + WC('B', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))*(a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_, x_), cons2, cons3, cons27, cons48, cons125, cons34, cons35, cons1245, cons1267, cons93, cons166, cons1586) def replacement4427(B, m, f, b, d, a, n, A, x, e): rubi.append(4427) return Dist(S(1)/(d*n), Int((d/cos(e + f*x))**(n + S(1))*(a + b/cos(e + f*x))**(m + S(-2))*Simp(a*(-A*b*(m - n + S(-1)) + B*a*n) + b*(A*a*(m + n) + B*b*n)/cos(e + f*x)**S(2) + (A*(a**S(2)*(n + S(1)) + b**S(2)*n) + S(2)*B*a*b*n)/cos(e + f*x), x), x), x) - Simp(A*a*(d/cos(e + f*x))**n*(a + b/cos(e + f*x))**(m + S(-1))*tan(e + f*x)/(f*n), x) rule4427 = ReplacementRule(pattern4427, replacement4427) pattern4428 = Pattern(Integral((WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(A_ + WC('B', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))*(a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_, x_), cons2, cons3, cons27, cons48, cons125, cons34, cons35, cons1245, cons1267, cons93, cons166, cons1586) def replacement4428(B, m, f, b, d, a, n, A, x, e): rubi.append(4428) return Dist(S(1)/(d*n), Int((d/sin(e + f*x))**(n + S(1))*(a + b/sin(e + f*x))**(m + S(-2))*Simp(a*(-A*b*(m - n + S(-1)) + B*a*n) + b*(A*a*(m + n) + B*b*n)/sin(e + f*x)**S(2) + (A*(a**S(2)*(n + S(1)) + b**S(2)*n) + S(2)*B*a*b*n)/sin(e + f*x), x), x), x) + Simp(A*a*(d/sin(e + f*x))**n*(a + b/sin(e + f*x))**(m + S(-1))/(f*n*tan(e + f*x)), x) rule4428 = ReplacementRule(pattern4428, replacement4428) pattern4429 = Pattern(Integral((WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(A_ + WC('B', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))*(a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_, x_), cons2, cons3, cons27, cons48, cons125, cons34, cons35, cons4, cons1245, cons1267, cons31, cons166, cons1630) def replacement4429(B, m, f, b, d, a, n, A, x, e): rubi.append(4429) return Dist(S(1)/(m + n), Int((d/cos(e + f*x))**n*(a + b/cos(e + f*x))**(m + S(-2))*Simp(A*a**S(2)*(m + n) + B*a*b*n + b*(A*b*(m + n) + B*a*(S(2)*m + n + S(-1)))/cos(e + f*x)**S(2) + (B*b**S(2)*(m + n + S(-1)) + a*(m + n)*(S(2)*A*b + B*a))/cos(e + f*x), x), x), x) + Simp(B*b*(d/cos(e + f*x))**n*(a + b/cos(e + f*x))**(m + S(-1))*tan(e + f*x)/(f*(m + n)), x) rule4429 = ReplacementRule(pattern4429, replacement4429) pattern4430 = Pattern(Integral((WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(A_ + WC('B', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))*(a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_, x_), cons2, cons3, cons27, cons48, cons125, cons34, cons35, cons4, cons1245, cons1267, cons31, cons166, cons1630) def replacement4430(B, m, f, b, d, a, n, A, x, e): rubi.append(4430) return Dist(S(1)/(m + n), Int((d/sin(e + f*x))**n*(a + b/sin(e + f*x))**(m + S(-2))*Simp(A*a**S(2)*(m + n) + B*a*b*n + b*(A*b*(m + n) + B*a*(S(2)*m + n + S(-1)))/sin(e + f*x)**S(2) + (B*b**S(2)*(m + n + S(-1)) + a*(m + n)*(S(2)*A*b + B*a))/sin(e + f*x), x), x), x) - Simp(B*b*(d/sin(e + f*x))**n*(a + b/sin(e + f*x))**(m + S(-1))/(f*(m + n)*tan(e + f*x)), x) rule4430 = ReplacementRule(pattern4430, replacement4430) pattern4431 = Pattern(Integral((WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(A_ + WC('B', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))*(a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_, x_), cons2, cons3, cons27, cons48, cons125, cons34, cons35, cons1245, cons1267, cons93, cons94, cons1325) def replacement4431(B, m, f, b, d, a, n, A, x, e): rubi.append(4431) return Dist(S(1)/((a**S(2) - b**S(2))*(m + S(1))), Int((d/cos(e + f*x))**(n + S(-1))*(a + b/cos(e + f*x))**(m + S(1))*Simp(d*(m + S(1))*(A*a - B*b)/cos(e + f*x) + d*(n + S(-1))*(A*b - B*a) - d*(A*b - B*a)*(m + n + S(1))/cos(e + f*x)**S(2), x), x), x) + Simp(d*(d/cos(e + f*x))**(n + S(-1))*(a + b/cos(e + f*x))**(m + S(1))*(A*b - B*a)*tan(e + f*x)/(f*(a**S(2) - b**S(2))*(m + S(1))), x) rule4431 = ReplacementRule(pattern4431, replacement4431) pattern4432 = Pattern(Integral((WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(A_ + WC('B', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))*(a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_, x_), cons2, cons3, cons27, cons48, cons125, cons34, cons35, cons1245, cons1267, cons93, cons94, cons1325) def replacement4432(B, m, f, b, d, a, n, A, x, e): rubi.append(4432) return Dist(S(1)/((a**S(2) - b**S(2))*(m + S(1))), Int((d/sin(e + f*x))**(n + S(-1))*(a + b/sin(e + f*x))**(m + S(1))*Simp(d*(m + S(1))*(A*a - B*b)/sin(e + f*x) + d*(n + S(-1))*(A*b - B*a) - d*(A*b - B*a)*(m + n + S(1))/sin(e + f*x)**S(2), x), x), x) - Simp(d*(d/sin(e + f*x))**(n + S(-1))*(a + b/sin(e + f*x))**(m + S(1))*(A*b - B*a)/(f*(a**S(2) - b**S(2))*(m + S(1))*tan(e + f*x)), x) rule4432 = ReplacementRule(pattern4432, replacement4432) pattern4433 = Pattern(Integral((WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(A_ + WC('B', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))*(a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_, x_), cons2, cons3, cons27, cons48, cons125, cons34, cons35, cons1245, cons1267, cons93, cons94, cons165) def replacement4433(B, m, f, b, d, a, n, A, x, e): rubi.append(4433) return -Dist(d/(b*(a**S(2) - b**S(2))*(m + S(1))), Int((d/cos(e + f*x))**(n + S(-2))*(a + b/cos(e + f*x))**(m + S(1))*Simp(a*d*(n + S(-2))*(A*b - B*a) + b*d*(m + S(1))*(A*b - B*a)/cos(e + f*x) - (A*a*b*d*(m + n) - B*d*(a**S(2)*(n + S(-1)) + b**S(2)*(m + S(1))))/cos(e + f*x)**S(2), x), x), x) - Simp(a*d**S(2)*(d/cos(e + f*x))**(n + S(-2))*(a + b/cos(e + f*x))**(m + S(1))*(A*b - B*a)*tan(e + f*x)/(b*f*(a**S(2) - b**S(2))*(m + S(1))), x) rule4433 = ReplacementRule(pattern4433, replacement4433) pattern4434 = Pattern(Integral((WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(A_ + WC('B', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))*(a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_, x_), cons2, cons3, cons27, cons48, cons125, cons34, cons35, cons1245, cons1267, cons93, cons94, cons165) def replacement4434(B, m, f, b, d, a, n, A, x, e): rubi.append(4434) return -Dist(d/(b*(a**S(2) - b**S(2))*(m + S(1))), Int((d/sin(e + f*x))**(n + S(-2))*(a + b/sin(e + f*x))**(m + S(1))*Simp(a*d*(n + S(-2))*(A*b - B*a) + b*d*(m + S(1))*(A*b - B*a)/sin(e + f*x) - (A*a*b*d*(m + n) - B*d*(a**S(2)*(n + S(-1)) + b**S(2)*(m + S(1))))/sin(e + f*x)**S(2), x), x), x) + Simp(a*d**S(2)*(d/sin(e + f*x))**(n + S(-2))*(a + b/sin(e + f*x))**(m + S(1))*(A*b - B*a)/(b*f*(a**S(2) - b**S(2))*(m + S(1))*tan(e + f*x)), x) rule4434 = ReplacementRule(pattern4434, replacement4434) pattern4435 = Pattern(Integral((WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(A_ + WC('B', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))*(a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_, x_), cons2, cons3, cons27, cons48, cons125, cons34, cons35, cons4, cons1245, cons1267, cons31, cons94, cons1631) def replacement4435(B, m, f, b, d, a, n, A, x, e): rubi.append(4435) return Dist(S(1)/(a*(a**S(2) - b**S(2))*(m + S(1))), Int((d/cos(e + f*x))**n*(a + b/cos(e + f*x))**(m + S(1))*Simp(A*(a**S(2)*(m + S(1)) - b**S(2)*(m + n + S(1))) + B*a*b*n - a*(m + S(1))*(A*b - B*a)/cos(e + f*x) + b*(A*b - B*a)*(m + n + S(2))/cos(e + f*x)**S(2), x), x), x) - Simp(b*(d/cos(e + f*x))**n*(a + b/cos(e + f*x))**(m + S(1))*(A*b - B*a)*tan(e + f*x)/(a*f*(a**S(2) - b**S(2))*(m + S(1))), x) rule4435 = ReplacementRule(pattern4435, replacement4435) pattern4436 = Pattern(Integral((WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(A_ + WC('B', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))*(a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_, x_), cons2, cons3, cons27, cons48, cons125, cons34, cons35, cons4, cons1245, cons1267, cons31, cons94, cons1631) def replacement4436(B, m, f, b, d, a, n, A, x, e): rubi.append(4436) return Dist(S(1)/(a*(a**S(2) - b**S(2))*(m + S(1))), Int((d/sin(e + f*x))**n*(a + b/sin(e + f*x))**(m + S(1))*Simp(A*(a**S(2)*(m + S(1)) - b**S(2)*(m + n + S(1))) + B*a*b*n - a*(m + S(1))*(A*b - B*a)/sin(e + f*x) + b*(A*b - B*a)*(m + n + S(2))/sin(e + f*x)**S(2), x), x), x) + Simp(b*(d/sin(e + f*x))**n*(a + b/sin(e + f*x))**(m + S(1))*(A*b - B*a)/(a*f*(a**S(2) - b**S(2))*(m + S(1))*tan(e + f*x)), x) rule4436 = ReplacementRule(pattern4436, replacement4436) pattern4437 = Pattern(Integral((WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(A_ + WC('B', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))*(a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_, x_), cons2, cons3, cons27, cons48, cons125, cons34, cons35, cons1245, cons1267, cons93, cons1256, cons88) def replacement4437(B, m, f, b, d, a, n, A, x, e): rubi.append(4437) return Dist(d/(m + n), Int((d/cos(e + f*x))**(n + S(-1))*(a + b/cos(e + f*x))**(m + S(-1))*Simp(B*a*(n + S(-1)) + (A*a*(m + n) + B*b*(m + n + S(-1)))/cos(e + f*x) + (A*b*(m + n) + B*a*m)/cos(e + f*x)**S(2), x), x), x) + Simp(B*d*(d/cos(e + f*x))**(n + S(-1))*(a + b/cos(e + f*x))**m*tan(e + f*x)/(f*(m + n)), x) rule4437 = ReplacementRule(pattern4437, replacement4437) pattern4438 = Pattern(Integral((WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(A_ + WC('B', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))*(a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_, x_), cons2, cons3, cons27, cons48, cons125, cons34, cons35, cons1245, cons1267, cons93, cons1256, cons88) def replacement4438(B, m, f, b, d, a, n, A, x, e): rubi.append(4438) return Dist(d/(m + n), Int((d/sin(e + f*x))**(n + S(-1))*(a + b/sin(e + f*x))**(m + S(-1))*Simp(B*a*(n + S(-1)) + (A*a*(m + n) + B*b*(m + n + S(-1)))/sin(e + f*x) + (A*b*(m + n) + B*a*m)/sin(e + f*x)**S(2), x), x), x) - Simp(B*d*(d/sin(e + f*x))**(n + S(-1))*(a + b/sin(e + f*x))**m/(f*(m + n)*tan(e + f*x)), x) rule4438 = ReplacementRule(pattern4438, replacement4438) pattern4439 = Pattern(Integral((WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(A_ + WC('B', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))*(a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_, x_), cons2, cons3, cons27, cons48, cons125, cons34, cons35, cons1245, cons1267, cons93, cons1256, cons1586) def replacement4439(B, m, f, b, d, a, n, A, x, e): rubi.append(4439) return -Dist(S(1)/(d*n), Int((d/cos(e + f*x))**(n + S(1))*(a + b/cos(e + f*x))**(m + S(-1))*Simp(A*b*m - A*b*(m + n + S(1))/cos(e + f*x)**S(2) - B*a*n - (A*a*(n + S(1)) + B*b*n)/cos(e + f*x), x), x), x) - Simp(A*(d/cos(e + f*x))**n*(a + b/cos(e + f*x))**m*tan(e + f*x)/(f*n), x) rule4439 = ReplacementRule(pattern4439, replacement4439) pattern4440 = Pattern(Integral((WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(A_ + WC('B', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))*(a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_, x_), cons2, cons3, cons27, cons48, cons125, cons34, cons35, cons1245, cons1267, cons93, cons1256, cons1586) def replacement4440(B, m, f, b, d, a, n, A, x, e): rubi.append(4440) return -Dist(S(1)/(d*n), Int((d/sin(e + f*x))**(n + S(1))*(a + b/sin(e + f*x))**(m + S(-1))*Simp(A*b*m - A*b*(m + n + S(1))/sin(e + f*x)**S(2) - B*a*n - (A*a*(n + S(1)) + B*b*n)/sin(e + f*x), x), x), x) + Simp(A*(d/sin(e + f*x))**n*(a + b/sin(e + f*x))**m/(f*n*tan(e + f*x)), x) rule4440 = ReplacementRule(pattern4440, replacement4440) pattern4441 = Pattern(Integral((WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(A_ + WC('B', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))*(a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_, x_), cons2, cons3, cons27, cons48, cons125, cons34, cons35, cons21, cons1245, cons1267, cons87, cons165, cons1359, cons1632) def replacement4441(B, m, f, b, d, a, n, A, x, e): rubi.append(4441) return Dist(d**S(2)/(b*(m + n)), Int((d/cos(e + f*x))**(n + S(-2))*(a + b/cos(e + f*x))**m*Simp(B*a*(n + S(-2)) + B*b*(m + n + S(-1))/cos(e + f*x) + (A*b*(m + n) - B*a*(n + S(-1)))/cos(e + f*x)**S(2), x), x), x) + Simp(B*d**S(2)*(d/cos(e + f*x))**(n + S(-2))*(a + b/cos(e + f*x))**(m + S(1))*tan(e + f*x)/(b*f*(m + n)), x) rule4441 = ReplacementRule(pattern4441, replacement4441) pattern4442 = Pattern(Integral((WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(A_ + WC('B', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))*(a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_, x_), cons2, cons3, cons27, cons48, cons125, cons34, cons35, cons21, cons1245, cons1267, cons87, cons165, cons1359, cons1632) def replacement4442(B, m, f, b, d, a, n, A, x, e): rubi.append(4442) return Dist(d**S(2)/(b*(m + n)), Int((d/sin(e + f*x))**(n + S(-2))*(a + b/sin(e + f*x))**m*Simp(B*a*(n + S(-2)) + B*b*(m + n + S(-1))/sin(e + f*x) + (A*b*(m + n) - B*a*(n + S(-1)))/sin(e + f*x)**S(2), x), x), x) - Simp(B*d**S(2)*(d/sin(e + f*x))**(n + S(-2))*(a + b/sin(e + f*x))**(m + S(1))/(b*f*(m + n)*tan(e + f*x)), x) rule4442 = ReplacementRule(pattern4442, replacement4442) pattern4443 = Pattern(Integral((WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(A_ + WC('B', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))*(a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_, x_), cons2, cons3, cons27, cons48, cons125, cons34, cons35, cons21, cons1245, cons1267, cons87, cons1586) def replacement4443(B, m, f, b, d, a, n, A, x, e): rubi.append(4443) return Dist(S(1)/(a*d*n), Int((d/cos(e + f*x))**(n + S(1))*(a + b/cos(e + f*x))**m*Simp(A*a*(n + S(1))/cos(e + f*x) - A*b*(m + n + S(1)) + A*b*(m + n + S(2))/cos(e + f*x)**S(2) + B*a*n, x), x), x) - Simp(A*(d/cos(e + f*x))**n*(a + b/cos(e + f*x))**(m + S(1))*tan(e + f*x)/(a*f*n), x) rule4443 = ReplacementRule(pattern4443, replacement4443) pattern4444 = Pattern(Integral((WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(A_ + WC('B', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))*(a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_, x_), cons2, cons3, cons27, cons48, cons125, cons34, cons35, cons21, cons1245, cons1267, cons87, cons1586) def replacement4444(B, m, f, b, d, a, n, A, x, e): rubi.append(4444) return Dist(S(1)/(a*d*n), Int((d/sin(e + f*x))**(n + S(1))*(a + b/sin(e + f*x))**m*Simp(A*a*(n + S(1))/sin(e + f*x) - A*b*(m + n + S(1)) + A*b*(m + n + S(2))/sin(e + f*x)**S(2) + B*a*n, x), x), x) + Simp(A*(d/sin(e + f*x))**n*(a + b/sin(e + f*x))**(m + S(1))/(a*f*n*tan(e + f*x)), x) rule4444 = ReplacementRule(pattern4444, replacement4444) pattern4445 = Pattern(Integral((A_ + WC('B', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))/(sqrt(WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))*sqrt(a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))), x_), cons2, cons3, cons27, cons48, cons125, cons34, cons35, cons1245, cons1267) def replacement4445(B, f, b, d, a, A, x, e): rubi.append(4445) return Dist(A/a, Int(sqrt(a + b/cos(e + f*x))/sqrt(d/cos(e + f*x)), x), x) - Dist((A*b - B*a)/(a*d), Int(sqrt(d/cos(e + f*x))/sqrt(a + b/cos(e + f*x)), x), x) rule4445 = ReplacementRule(pattern4445, replacement4445) pattern4446 = Pattern(Integral((A_ + WC('B', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))/(sqrt(WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))*sqrt(a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))), x_), cons2, cons3, cons27, cons48, cons125, cons34, cons35, cons1245, cons1267) def replacement4446(B, f, b, d, a, A, x, e): rubi.append(4446) return Dist(A/a, Int(sqrt(a + b/sin(e + f*x))/sqrt(d/sin(e + f*x)), x), x) - Dist((A*b - B*a)/(a*d), Int(sqrt(d/sin(e + f*x))/sqrt(a + b/sin(e + f*x)), x), x) rule4446 = ReplacementRule(pattern4446, replacement4446) pattern4447 = Pattern(Integral(sqrt(WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))*(A_ + WC('B', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))/sqrt(a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons27, cons48, cons125, cons34, cons35, cons1245, cons1267) def replacement4447(B, f, b, d, a, A, x, e): rubi.append(4447) return Dist(A, Int(sqrt(d/cos(e + f*x))/sqrt(a + b/cos(e + f*x)), x), x) + Dist(B/d, Int((d/cos(e + f*x))**(S(3)/2)/sqrt(a + b/cos(e + f*x)), x), x) rule4447 = ReplacementRule(pattern4447, replacement4447) pattern4448 = Pattern(Integral(sqrt(WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))*(A_ + WC('B', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))/sqrt(a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons27, cons48, cons125, cons34, cons35, cons1245, cons1267) def replacement4448(B, f, b, d, a, A, x, e): rubi.append(4448) return Dist(A, Int(sqrt(d/sin(e + f*x))/sqrt(a + b/sin(e + f*x)), x), x) + Dist(B/d, Int((d/sin(e + f*x))**(S(3)/2)/sqrt(a + b/sin(e + f*x)), x), x) rule4448 = ReplacementRule(pattern4448, replacement4448) pattern4449 = Pattern(Integral((A_ + WC('B', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))*sqrt(a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))/sqrt(WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons27, cons48, cons125, cons34, cons35, cons1245, cons1267) def replacement4449(B, f, b, d, a, A, x, e): rubi.append(4449) return Dist(A, Int(sqrt(a + b/cos(e + f*x))/sqrt(d/cos(e + f*x)), x), x) + Dist(B/d, Int(sqrt(d/cos(e + f*x))*sqrt(a + b/cos(e + f*x)), x), x) rule4449 = ReplacementRule(pattern4449, replacement4449) pattern4450 = Pattern(Integral((A_ + WC('B', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))*sqrt(a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))/sqrt(WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons27, cons48, cons125, cons34, cons35, cons1245, cons1267) def replacement4450(B, f, b, d, a, A, x, e): rubi.append(4450) return Dist(A, Int(sqrt(a + b/sin(e + f*x))/sqrt(d/sin(e + f*x)), x), x) + Dist(B/d, Int(sqrt(d/sin(e + f*x))*sqrt(a + b/sin(e + f*x)), x), x) rule4450 = ReplacementRule(pattern4450, replacement4450) pattern4451 = Pattern(Integral((WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(A_ + WC('B', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))/(a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons27, cons48, cons125, cons34, cons35, cons4, cons1245, cons1267) def replacement4451(B, f, b, d, a, n, A, x, e): rubi.append(4451) return Dist(A/a, Int((d/cos(e + f*x))**n, x), x) - Dist((A*b - B*a)/(a*d), Int((d/cos(e + f*x))**(n + S(1))/(a + b/cos(e + f*x)), x), x) rule4451 = ReplacementRule(pattern4451, replacement4451) pattern4452 = Pattern(Integral((WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(A_ + WC('B', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))/(a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons27, cons48, cons125, cons34, cons35, cons4, cons1245, cons1267) def replacement4452(B, f, b, d, a, n, A, x, e): rubi.append(4452) return Dist(A/a, Int((d/sin(e + f*x))**n, x), x) - Dist((A*b - B*a)/(a*d), Int((d/sin(e + f*x))**(n + S(1))/(a + b/sin(e + f*x)), x), x) rule4452 = ReplacementRule(pattern4452, replacement4452) pattern4453 = Pattern(Integral((WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1))*(A_ + WC('B', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))*(a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_, x_), cons2, cons3, cons27, cons48, cons125, cons34, cons35, cons21, cons4, cons1245, cons1267) def replacement4453(B, m, f, b, d, a, n, A, x, e): rubi.append(4453) return Int((d/cos(e + f*x))**n*(A + B/cos(e + f*x))*(a + b/cos(e + f*x))**m, x) rule4453 = ReplacementRule(pattern4453, replacement4453) pattern4454 = Pattern(Integral((WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1))*(A_ + WC('B', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))*(a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_, x_), cons2, cons3, cons27, cons48, cons125, cons34, cons35, cons21, cons4, cons1245, cons1267) def replacement4454(B, m, f, b, d, a, n, A, x, e): rubi.append(4454) return Int((d/sin(e + f*x))**n*(A + B/sin(e + f*x))*(a + b/sin(e + f*x))**m, x) rule4454 = ReplacementRule(pattern4454, replacement4454) pattern4455 = Pattern(Integral((a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(c_ + WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1))*(WC('A', S(0)) + WC('B', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons4, cons5, cons70, cons1265, cons375) def replacement4455(B, p, e, m, f, b, d, a, n, c, x, A): rubi.append(4455) return Dist((-a*c)**m, Int((A*cos(e + f*x) + B)**p*(c*cos(e + f*x) + d)**(-m + n)*sin(e + f*x)**(S(2)*m)*cos(e + f*x)**(-m - n - p), x), x) rule4455 = ReplacementRule(pattern4455, replacement4455) pattern4456 = Pattern(Integral((a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(c_ + WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1))*(WC('A', S(0)) + WC('B', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons4, cons5, cons70, cons1265, cons375) def replacement4456(B, p, m, f, b, d, a, n, c, A, x, e): rubi.append(4456) return Dist((-a*c)**m, Int((A*sin(e + f*x) + B)**p*(c*sin(e + f*x) + d)**(-m + n)*sin(e + f*x)**(-m - n - p)*cos(e + f*x)**(S(2)*m), x), x) rule4456 = ReplacementRule(pattern4456, replacement4456) pattern4457 = Pattern(Integral((a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(WC('A', S(0)) + WC('B', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))) + WC('C', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0)))**S(2)), x_), cons2, cons3, cons48, cons125, cons34, cons35, cons36, cons21, cons33) def replacement4457(B, C, e, m, f, b, a, x, A): rubi.append(4457) return Dist(b**(S(-2)), Int((a + b/cos(e + f*x))**(m + S(1))*Simp(B*b - C*a + C*b/cos(e + f*x), x), x), x) rule4457 = ReplacementRule(pattern4457, replacement4457) pattern4458 = Pattern(Integral((a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(WC('A', S(0)) + WC('B', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))) + WC('C', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0)))**S(2)), x_), cons2, cons3, cons48, cons125, cons34, cons35, cons36, cons21, cons33) def replacement4458(B, C, m, f, b, a, A, x, e): rubi.append(4458) return Dist(b**(S(-2)), Int((a + b/sin(e + f*x))**(m + S(1))*Simp(B*b - C*a + C*b/sin(e + f*x), x), x), x) rule4458 = ReplacementRule(pattern4458, replacement4458) pattern4459 = Pattern(Integral((a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(WC('A', S(0)) + WC('C', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0)))**S(2)), x_), cons2, cons3, cons48, cons125, cons34, cons36, cons21, cons1433) def replacement4459(C, e, m, f, b, a, x, A): rubi.append(4459) return Dist(C/b**S(2), Int((a + b/cos(e + f*x))**(m + S(1))*Simp(-a + b/cos(e + f*x), x), x), x) rule4459 = ReplacementRule(pattern4459, replacement4459) pattern4460 = Pattern(Integral((a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(WC('A', S(0)) + WC('C', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0)))**S(2)), x_), cons2, cons3, cons48, cons125, cons34, cons36, cons21, cons1433) def replacement4460(C, m, f, b, a, A, x, e): rubi.append(4460) return Dist(C/b**S(2), Int((a + b/sin(e + f*x))**(m + S(1))*Simp(-a + b/sin(e + f*x), x), x), x) rule4460 = ReplacementRule(pattern4460, replacement4460) pattern4461 = Pattern(Integral((WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(A_ + WC('C', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0)))**S(2)), x_), cons3, cons48, cons125, cons34, cons36, cons21, cons1633) def replacement4461(C, m, f, b, A, x, e): rubi.append(4461) return -Simp(A*(b/cos(e + f*x))**m*tan(e + f*x)/(f*m), x) rule4461 = ReplacementRule(pattern4461, replacement4461) pattern4462 = Pattern(Integral((WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(A_ + WC('C', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0)))**S(2)), x_), cons3, cons48, cons125, cons34, cons36, cons21, cons1633) def replacement4462(C, m, f, b, A, x, e): rubi.append(4462) return Simp(A*(b/sin(e + f*x))**m/(f*m*tan(e + f*x)), x) rule4462 = ReplacementRule(pattern4462, replacement4462) pattern4463 = Pattern(Integral((WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(A_ + WC('C', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0)))**S(2)), x_), cons3, cons48, cons125, cons34, cons36, cons1634, cons31, cons32) def replacement4463(C, m, f, b, A, x, e): rubi.append(4463) return Dist((A*(m + S(1)) + C*m)/(b**S(2)*m), Int((b/cos(e + f*x))**(m + S(2)), x), x) - Simp(A*(b/cos(e + f*x))**m*tan(e + f*x)/(f*m), x) rule4463 = ReplacementRule(pattern4463, replacement4463) pattern4464 = Pattern(Integral((WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(A_ + WC('C', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0)))**S(2)), x_), cons3, cons48, cons125, cons34, cons36, cons1634, cons31, cons32) def replacement4464(C, m, f, b, A, x, e): rubi.append(4464) return Dist((A*(m + S(1)) + C*m)/(b**S(2)*m), Int((b/sin(e + f*x))**(m + S(2)), x), x) + Simp(A*(b/sin(e + f*x))**m/(f*m*tan(e + f*x)), x) rule4464 = ReplacementRule(pattern4464, replacement4464) pattern4465 = Pattern(Integral((WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(A_ + WC('C', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0)))**S(2)), x_), cons3, cons48, cons125, cons34, cons36, cons21, cons1634, cons1549) def replacement4465(C, m, f, b, A, x, e): rubi.append(4465) return Dist((A*(m + S(1)) + C*m)/(m + S(1)), Int((b/cos(e + f*x))**m, x), x) + Simp(C*(b/cos(e + f*x))**m*tan(e + f*x)/(f*(m + S(1))), x) rule4465 = ReplacementRule(pattern4465, replacement4465) pattern4466 = Pattern(Integral((WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(A_ + WC('C', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0)))**S(2)), x_), cons3, cons48, cons125, cons34, cons36, cons21, cons1634, cons1549) def replacement4466(C, m, f, b, A, x, e): rubi.append(4466) return Dist((A*(m + S(1)) + C*m)/(m + S(1)), Int((b/sin(e + f*x))**m, x), x) - Simp(C*(b/sin(e + f*x))**m/(f*(m + S(1))*tan(e + f*x)), x) rule4466 = ReplacementRule(pattern4466, replacement4466) pattern4467 = Pattern(Integral((WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(WC('B', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))) + WC('C', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0)))**S(2)), x_), cons3, cons48, cons125, cons35, cons36, cons21, cons1431) def replacement4467(B, C, m, f, b, x, e): rubi.append(4467) return Dist(B/b, Int((b/cos(e + f*x))**(m + S(1)), x), x) + Dist(C/b**S(2), Int((b/cos(e + f*x))**(m + S(2)), x), x) rule4467 = ReplacementRule(pattern4467, replacement4467) pattern4468 = Pattern(Integral((WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(WC('B', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))) + WC('C', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0)))**S(2)), x_), cons3, cons48, cons125, cons35, cons36, cons21, cons1431) def replacement4468(B, C, m, f, b, x, e): rubi.append(4468) return Dist(B/b, Int((b/sin(e + f*x))**(m + S(1)), x), x) + Dist(C/b**S(2), Int((b/sin(e + f*x))**(m + S(2)), x), x) rule4468 = ReplacementRule(pattern4468, replacement4468) pattern4469 = Pattern(Integral((WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(A_ + WC('B', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))) + WC('C', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0)))**S(2)), x_), cons3, cons48, cons125, cons34, cons35, cons36, cons21, cons1635) def replacement4469(B, C, m, f, b, A, x, e): rubi.append(4469) return Dist(B/b, Int((b/cos(e + f*x))**(m + S(1)), x), x) + Int((b/cos(e + f*x))**m*(A + C/cos(e + f*x)**S(2)), x) rule4469 = ReplacementRule(pattern4469, replacement4469) pattern4470 = Pattern(Integral((WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(A_ + WC('B', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))) + WC('C', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0)))**S(2)), x_), cons3, cons48, cons125, cons34, cons35, cons36, cons21, cons1635) def replacement4470(B, C, m, f, b, A, x, e): rubi.append(4470) return Dist(B/b, Int((b/sin(e + f*x))**(m + S(1)), x), x) + Int((b/sin(e + f*x))**m*(A + C/sin(e + f*x)**S(2)), x) rule4470 = ReplacementRule(pattern4470, replacement4470) pattern4471 = Pattern(Integral((a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))*(WC('A', S(0)) + WC('B', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))) + WC('C', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0)))**S(2)), x_), cons2, cons3, cons48, cons125, cons34, cons35, cons36, cons1636) def replacement4471(B, C, e, f, b, a, x, A): rubi.append(4471) return Dist(S(1)/2, Int(Simp(S(2)*A*a + (S(2)*B*a + b*(S(2)*A + C))/cos(e + f*x) + S(2)*(B*b + C*a)/cos(e + f*x)**S(2), x), x), x) + Simp(C*b*tan(e + f*x)/(S(2)*f*cos(e + f*x)), x) rule4471 = ReplacementRule(pattern4471, replacement4471) pattern4472 = Pattern(Integral((a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))*(WC('A', S(0)) + WC('B', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))) + WC('C', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0)))**S(2)), x_), cons2, cons3, cons48, cons125, cons34, cons35, cons36, cons1636) def replacement4472(B, C, f, b, a, A, x, e): rubi.append(4472) return Dist(S(1)/2, Int(Simp(S(2)*A*a + (S(2)*B*a + b*(S(2)*A + C))/sin(e + f*x) + S(2)*(B*b + C*a)/sin(e + f*x)**S(2), x), x), x) - Simp(C*b/(S(2)*f*sin(e + f*x)*tan(e + f*x)), x) rule4472 = ReplacementRule(pattern4472, replacement4472) pattern4473 = Pattern(Integral((a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))*(WC('A', S(0)) + WC('C', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0)))**S(2)), x_), cons2, cons3, cons48, cons125, cons34, cons36, cons1637) def replacement4473(C, e, f, b, a, x, A): rubi.append(4473) return Dist(S(1)/2, Int(Simp(S(2)*A*a + S(2)*C*a/cos(e + f*x)**S(2) + b*(S(2)*A + C)/cos(e + f*x), x), x), x) + Simp(C*b*tan(e + f*x)/(S(2)*f*cos(e + f*x)), x) rule4473 = ReplacementRule(pattern4473, replacement4473) pattern4474 = Pattern(Integral((a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))*(WC('A', S(0)) + WC('C', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0)))**S(2)), x_), cons2, cons3, cons48, cons125, cons34, cons36, cons1637) def replacement4474(C, f, b, a, A, x, e): rubi.append(4474) return Dist(S(1)/2, Int(Simp(S(2)*A*a + S(2)*C*a/sin(e + f*x)**S(2) + b*(S(2)*A + C)/sin(e + f*x), x), x), x) - Simp(C*b/(S(2)*f*sin(e + f*x)*tan(e + f*x)), x) rule4474 = ReplacementRule(pattern4474, replacement4474) pattern4475 = Pattern(Integral((WC('A', S(0)) + WC('B', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))) + WC('C', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0)))**S(2))/(a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons48, cons125, cons34, cons35, cons36, cons1636) def replacement4475(B, C, e, f, b, a, x, A): rubi.append(4475) return Dist(S(1)/b, Int((A*b + (B*b - C*a)/cos(e + f*x))/(a + b/cos(e + f*x)), x), x) + Dist(C/b, Int(S(1)/cos(e + f*x), x), x) rule4475 = ReplacementRule(pattern4475, replacement4475) pattern4476 = Pattern(Integral((WC('A', S(0)) + WC('B', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))) + WC('C', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0)))**S(2))/(a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons48, cons125, cons34, cons35, cons36, cons1636) def replacement4476(B, C, f, b, a, A, x, e): rubi.append(4476) return Dist(S(1)/b, Int((A*b + (B*b - C*a)/sin(e + f*x))/(a + b/sin(e + f*x)), x), x) + Dist(C/b, Int(S(1)/sin(e + f*x), x), x) rule4476 = ReplacementRule(pattern4476, replacement4476) pattern4477 = Pattern(Integral((WC('A', S(0)) + WC('C', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0)))**S(2))/(a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons48, cons125, cons34, cons36, cons1637) def replacement4477(C, e, f, b, a, x, A): rubi.append(4477) return Dist(S(1)/b, Int((A*b - C*a/cos(e + f*x))/(a + b/cos(e + f*x)), x), x) + Dist(C/b, Int(S(1)/cos(e + f*x), x), x) rule4477 = ReplacementRule(pattern4477, replacement4477) pattern4478 = Pattern(Integral((WC('A', S(0)) + WC('C', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0)))**S(2))/(a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons48, cons125, cons34, cons36, cons1637) def replacement4478(C, f, b, a, A, x, e): rubi.append(4478) return Dist(S(1)/b, Int((A*b - C*a/sin(e + f*x))/(a + b/sin(e + f*x)), x), x) + Dist(C/b, Int(S(1)/sin(e + f*x), x), x) rule4478 = ReplacementRule(pattern4478, replacement4478) pattern4479 = Pattern(Integral((a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('A', S(0)) + WC('B', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))) + WC('C', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0)))**S(2)), x_), cons2, cons3, cons48, cons125, cons34, cons35, cons36, cons1265, cons31, cons1320) def replacement4479(B, C, e, m, f, b, a, x, A): rubi.append(4479) return Dist(S(1)/(a*b*(S(2)*m + S(1))), Int((a + b/cos(e + f*x))**(m + S(1))*Simp(A*b*(S(2)*m + S(1)) + (B*b*(m + S(1)) - a*(A*(m + S(1)) - C*m))/cos(e + f*x), x), x), x) + Simp((a + b/cos(e + f*x))**m*(A*a - B*b + C*a)*tan(e + f*x)/(a*f*(S(2)*m + S(1))), x) rule4479 = ReplacementRule(pattern4479, replacement4479) pattern4480 = Pattern(Integral((a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('A', S(0)) + WC('B', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))) + WC('C', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0)))**S(2)), x_), cons2, cons3, cons48, cons125, cons34, cons35, cons36, cons1265, cons31, cons1320) def replacement4480(B, C, m, f, b, a, A, x, e): rubi.append(4480) return Dist(S(1)/(a*b*(S(2)*m + S(1))), Int((a + b/sin(e + f*x))**(m + S(1))*Simp(A*b*(S(2)*m + S(1)) + (B*b*(m + S(1)) - a*(A*(m + S(1)) - C*m))/sin(e + f*x), x), x), x) - Simp((a + b/sin(e + f*x))**m*(A*a - B*b + C*a)/(a*f*(S(2)*m + S(1))*tan(e + f*x)), x) rule4480 = ReplacementRule(pattern4480, replacement4480) pattern4481 = Pattern(Integral((a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('A', S(0)) + WC('C', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0)))**S(2)), x_), cons2, cons3, cons48, cons125, cons34, cons36, cons1265, cons31, cons1320) def replacement4481(C, e, m, f, b, a, x, A): rubi.append(4481) return Dist(S(1)/(a*b*(S(2)*m + S(1))), Int((a + b/cos(e + f*x))**(m + S(1))*Simp(A*b*(S(2)*m + S(1)) - a*(A*(m + S(1)) - C*m)/cos(e + f*x), x), x), x) + Simp((A + C)*(a + b/cos(e + f*x))**m*tan(e + f*x)/(f*(S(2)*m + S(1))), x) rule4481 = ReplacementRule(pattern4481, replacement4481) pattern4482 = Pattern(Integral((a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('A', S(0)) + WC('C', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0)))**S(2)), x_), cons2, cons3, cons48, cons125, cons34, cons36, cons1265, cons31, cons1320) def replacement4482(C, m, f, b, a, A, x, e): rubi.append(4482) return Dist(S(1)/(a*b*(S(2)*m + S(1))), Int((a + b/sin(e + f*x))**(m + S(1))*Simp(A*b*(S(2)*m + S(1)) - a*(A*(m + S(1)) - C*m)/sin(e + f*x), x), x), x) - Simp((A + C)*(a + b/sin(e + f*x))**m/(f*(S(2)*m + S(1))*tan(e + f*x)), x) rule4482 = ReplacementRule(pattern4482, replacement4482) pattern4483 = Pattern(Integral((a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(WC('A', S(0)) + WC('B', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))) + WC('C', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0)))**S(2)), x_), cons2, cons3, cons48, cons125, cons34, cons35, cons36, cons21, cons1265, cons1321) def replacement4483(B, C, e, m, f, b, a, x, A): rubi.append(4483) return Dist(S(1)/(b*(m + S(1))), Int((a + b/cos(e + f*x))**m*Simp(A*b*(m + S(1)) + (B*b*(m + S(1)) + C*a*m)/cos(e + f*x), x), x), x) + Simp(C*(a + b/cos(e + f*x))**m*tan(e + f*x)/(f*(m + S(1))), x) rule4483 = ReplacementRule(pattern4483, replacement4483) pattern4484 = Pattern(Integral((a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(WC('A', S(0)) + WC('B', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))) + WC('C', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0)))**S(2)), x_), cons2, cons3, cons48, cons125, cons34, cons35, cons36, cons21, cons1265, cons1321) def replacement4484(B, C, m, f, b, a, A, x, e): rubi.append(4484) return Dist(S(1)/(b*(m + S(1))), Int((a + b/sin(e + f*x))**m*Simp(A*b*(m + S(1)) + (B*b*(m + S(1)) + C*a*m)/sin(e + f*x), x), x), x) - Simp(C*(a + b/sin(e + f*x))**m/(f*(m + S(1))*tan(e + f*x)), x) rule4484 = ReplacementRule(pattern4484, replacement4484) pattern4485 = Pattern(Integral((a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(WC('A', S(0)) + WC('C', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0)))**S(2)), x_), cons2, cons3, cons48, cons125, cons34, cons36, cons21, cons1265, cons1321) def replacement4485(C, e, m, f, b, a, x, A): rubi.append(4485) return Dist(S(1)/(b*(m + S(1))), Int((a + b/cos(e + f*x))**m*Simp(A*b*(m + S(1)) + C*a*m/cos(e + f*x), x), x), x) + Simp(C*(a + b/cos(e + f*x))**m*tan(e + f*x)/(f*(m + S(1))), x) rule4485 = ReplacementRule(pattern4485, replacement4485) pattern4486 = Pattern(Integral((a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(WC('A', S(0)) + WC('C', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0)))**S(2)), x_), cons2, cons3, cons48, cons125, cons34, cons36, cons21, cons1265, cons1321) def replacement4486(C, m, f, b, a, A, x, e): rubi.append(4486) return Dist(S(1)/(b*(m + S(1))), Int((a + b/sin(e + f*x))**m*Simp(A*b*(m + S(1)) + C*a*m/sin(e + f*x), x), x), x) - Simp(C*(a + b/sin(e + f*x))**m/(f*(m + S(1))*tan(e + f*x)), x) rule4486 = ReplacementRule(pattern4486, replacement4486) pattern4487 = Pattern(Integral((a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(WC('A', S(0)) + WC('B', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))) + WC('C', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0)))**S(2)), x_), cons2, cons3, cons48, cons125, cons34, cons35, cons36, cons1267, cons1638) def replacement4487(B, C, e, m, f, b, a, x, A): rubi.append(4487) return Dist(S(1)/(m + S(1)), Int((a + b/cos(e + f*x))**(m + S(-1))*Simp(A*a*(m + S(1)) + (B*b*(m + S(1)) + C*a*m)/cos(e + f*x)**S(2) + (C*b*m + (m + S(1))*(A*b + B*a))/cos(e + f*x), x), x), x) + Simp(C*(a + b/cos(e + f*x))**m*tan(e + f*x)/(f*(m + S(1))), x) rule4487 = ReplacementRule(pattern4487, replacement4487) pattern4488 = Pattern(Integral((a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(WC('A', S(0)) + WC('B', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))) + WC('C', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0)))**S(2)), x_), cons2, cons3, cons48, cons125, cons34, cons35, cons36, cons1267, cons1638) def replacement4488(B, C, m, f, b, a, A, x, e): rubi.append(4488) return Dist(S(1)/(m + S(1)), Int((a + b/sin(e + f*x))**(m + S(-1))*Simp(A*a*(m + S(1)) + (B*b*(m + S(1)) + C*a*m)/sin(e + f*x)**S(2) + (C*b*m + (m + S(1))*(A*b + B*a))/sin(e + f*x), x), x), x) - Simp(C*(a + b/sin(e + f*x))**m/(f*(m + S(1))*tan(e + f*x)), x) rule4488 = ReplacementRule(pattern4488, replacement4488) pattern4489 = Pattern(Integral((a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(WC('A', S(0)) + WC('C', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0)))**S(2)), x_), cons2, cons3, cons48, cons125, cons34, cons36, cons1267, cons1638) def replacement4489(C, e, m, f, b, a, x, A): rubi.append(4489) return Dist(S(1)/(m + S(1)), Int((a + b/cos(e + f*x))**(m + S(-1))*Simp(A*a*(m + S(1)) + C*a*m/cos(e + f*x)**S(2) + (A*b*(m + S(1)) + C*b*m)/cos(e + f*x), x), x), x) + Simp(C*(a + b/cos(e + f*x))**m*tan(e + f*x)/(f*(m + S(1))), x) rule4489 = ReplacementRule(pattern4489, replacement4489) pattern4490 = Pattern(Integral((a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(WC('A', S(0)) + WC('C', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0)))**S(2)), x_), cons2, cons3, cons48, cons125, cons34, cons36, cons1267, cons1638) def replacement4490(C, m, f, b, a, A, x, e): rubi.append(4490) return Dist(S(1)/(m + S(1)), Int((a + b/sin(e + f*x))**(m + S(-1))*Simp(A*a*(m + S(1)) + C*a*m/sin(e + f*x)**S(2) + (A*b*(m + S(1)) + C*b*m)/sin(e + f*x), x), x), x) - Simp(C*(a + b/sin(e + f*x))**m/(f*(m + S(1))*tan(e + f*x)), x) rule4490 = ReplacementRule(pattern4490, replacement4490) pattern4491 = Pattern(Integral((WC('A', S(0)) + WC('B', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))) + WC('C', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0)))**S(2))/sqrt(a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons48, cons125, cons34, cons35, cons36, cons1267) def replacement4491(B, C, e, f, b, a, x, A): rubi.append(4491) return Dist(C, Int((S(1) + S(1)/cos(e + f*x))/(sqrt(a + b/cos(e + f*x))*cos(e + f*x)), x), x) + Int((A + (B - C)/cos(e + f*x))/sqrt(a + b/cos(e + f*x)), x) rule4491 = ReplacementRule(pattern4491, replacement4491) pattern4492 = Pattern(Integral((WC('A', S(0)) + WC('B', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))) + WC('C', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0)))**S(2))/sqrt(a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons48, cons125, cons34, cons35, cons36, cons1267) def replacement4492(B, C, f, b, a, A, x, e): rubi.append(4492) return Dist(C, Int((S(1) + S(1)/sin(e + f*x))/(sqrt(a + b/sin(e + f*x))*sin(e + f*x)), x), x) + Int((A + (B - C)/sin(e + f*x))/sqrt(a + b/sin(e + f*x)), x) rule4492 = ReplacementRule(pattern4492, replacement4492) pattern4493 = Pattern(Integral((WC('A', S(0)) + WC('C', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0)))**S(2))/sqrt(a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons48, cons125, cons34, cons36, cons1267) def replacement4493(C, e, f, b, a, x, A): rubi.append(4493) return Dist(C, Int((S(1) + S(1)/cos(e + f*x))/(sqrt(a + b/cos(e + f*x))*cos(e + f*x)), x), x) + Int((A - C/cos(e + f*x))/sqrt(a + b/cos(e + f*x)), x) rule4493 = ReplacementRule(pattern4493, replacement4493) pattern4494 = Pattern(Integral((WC('A', S(0)) + WC('C', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0)))**S(2))/sqrt(a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons48, cons125, cons34, cons36, cons1267) def replacement4494(C, f, b, a, A, x, e): rubi.append(4494) return Dist(C, Int((S(1) + S(1)/sin(e + f*x))/(sqrt(a + b/sin(e + f*x))*sin(e + f*x)), x), x) + Int((A - C/sin(e + f*x))/sqrt(a + b/sin(e + f*x)), x) rule4494 = ReplacementRule(pattern4494, replacement4494) pattern4495 = Pattern(Integral((a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('A', S(0)) + WC('B', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))) + WC('C', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0)))**S(2)), x_), cons2, cons3, cons48, cons125, cons34, cons35, cons36, cons1267, cons515, cons94) def replacement4495(B, C, e, m, f, b, a, x, A): rubi.append(4495) return Dist(S(1)/(a*(a**S(2) - b**S(2))*(m + S(1))), Int((a + b/cos(e + f*x))**(m + S(1))*Simp(A*(a**S(2) - b**S(2))*(m + S(1)) - a*(m + S(1))*(A*b - B*a + C*b)/cos(e + f*x) + (m + S(2))*(A*b**S(2) - B*a*b + C*a**S(2))/cos(e + f*x)**S(2), x), x), x) - Simp((a + b/cos(e + f*x))**(m + S(1))*(A*b**S(2) - B*a*b + C*a**S(2))*tan(e + f*x)/(a*f*(a**S(2) - b**S(2))*(m + S(1))), x) rule4495 = ReplacementRule(pattern4495, replacement4495) pattern4496 = Pattern(Integral((a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('A', S(0)) + WC('B', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))) + WC('C', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0)))**S(2)), x_), cons2, cons3, cons48, cons125, cons34, cons35, cons36, cons1267, cons31, cons94) def replacement4496(B, C, m, f, b, a, A, x, e): rubi.append(4496) return Dist(S(1)/(a*(a**S(2) - b**S(2))*(m + S(1))), Int((a + b/sin(e + f*x))**(m + S(1))*Simp(A*(a**S(2) - b**S(2))*(m + S(1)) - a*(m + S(1))*(A*b - B*a + C*b)/sin(e + f*x) + (m + S(2))*(A*b**S(2) - B*a*b + C*a**S(2))/sin(e + f*x)**S(2), x), x), x) + Simp((a + b/sin(e + f*x))**(m + S(1))*(A*b**S(2) - B*a*b + C*a**S(2))/(a*f*(a**S(2) - b**S(2))*(m + S(1))*tan(e + f*x)), x) rule4496 = ReplacementRule(pattern4496, replacement4496) pattern4497 = Pattern(Integral((a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('A', S(0)) + WC('C', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0)))**S(2)), x_), cons2, cons3, cons48, cons125, cons34, cons36, cons1267, cons515, cons94) def replacement4497(C, e, m, f, b, a, x, A): rubi.append(4497) return Dist(S(1)/(a*(a**S(2) - b**S(2))*(m + S(1))), Int((a + b/cos(e + f*x))**(m + S(1))*Simp(A*(a**S(2) - b**S(2))*(m + S(1)) - a*b*(A + C)*(m + S(1))/cos(e + f*x) + (m + S(2))*(A*b**S(2) + C*a**S(2))/cos(e + f*x)**S(2), x), x), x) - Simp((a + b/cos(e + f*x))**(m + S(1))*(A*b**S(2) + C*a**S(2))*tan(e + f*x)/(a*f*(a**S(2) - b**S(2))*(m + S(1))), x) rule4497 = ReplacementRule(pattern4497, replacement4497) pattern4498 = Pattern(Integral((a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('A', S(0)) + WC('C', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0)))**S(2)), x_), cons2, cons3, cons48, cons125, cons34, cons36, cons1267, cons515, cons94) def replacement4498(C, m, f, b, a, A, x, e): rubi.append(4498) return Dist(S(1)/(a*(a**S(2) - b**S(2))*(m + S(1))), Int((a + b/sin(e + f*x))**(m + S(1))*Simp(A*(a**S(2) - b**S(2))*(m + S(1)) - a*b*(A + C)*(m + S(1))/sin(e + f*x) + (m + S(2))*(A*b**S(2) + C*a**S(2))/sin(e + f*x)**S(2), x), x), x) + Simp((a + b/sin(e + f*x))**(m + S(1))*(A*b**S(2) + C*a**S(2))/(a*f*(a**S(2) - b**S(2))*(m + S(1))*tan(e + f*x)), x) rule4498 = ReplacementRule(pattern4498, replacement4498) pattern4499 = Pattern(Integral((a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('A', S(0)) + WC('B', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))) + WC('C', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0)))**S(2)), x_), cons2, cons3, cons48, cons125, cons34, cons35, cons36, cons21, cons1267, cons77) def replacement4499(B, C, e, m, f, b, a, x, A): rubi.append(4499) return Dist(S(1)/b, Int((a + b/cos(e + f*x))**m*(A*b + (B*b - C*a)/cos(e + f*x)), x), x) + Dist(C/b, Int((a + b/cos(e + f*x))**(m + S(1))/cos(e + f*x), x), x) rule4499 = ReplacementRule(pattern4499, replacement4499) pattern4500 = Pattern(Integral((a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('A', S(0)) + WC('B', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))) + WC('C', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0)))**S(2)), x_), cons2, cons3, cons48, cons125, cons34, cons35, cons36, cons21, cons1267, cons77) def replacement4500(B, C, m, f, b, a, A, x, e): rubi.append(4500) return Dist(S(1)/b, Int((a + b/sin(e + f*x))**m*(A*b + (B*b - C*a)/sin(e + f*x)), x), x) + Dist(C/b, Int((a + b/sin(e + f*x))**(m + S(1))/sin(e + f*x), x), x) rule4500 = ReplacementRule(pattern4500, replacement4500) pattern4501 = Pattern(Integral((a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('A', S(0)) + WC('C', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0)))**S(2)), x_), cons2, cons3, cons48, cons125, cons34, cons36, cons21, cons1267, cons77) def replacement4501(C, e, m, f, b, a, x, A): rubi.append(4501) return Dist(S(1)/b, Int((a + b/cos(e + f*x))**m*(A*b - C*a/cos(e + f*x)), x), x) + Dist(C/b, Int((a + b/cos(e + f*x))**(m + S(1))/cos(e + f*x), x), x) rule4501 = ReplacementRule(pattern4501, replacement4501) pattern4502 = Pattern(Integral((a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('A', S(0)) + WC('C', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0)))**S(2)), x_), cons2, cons3, cons48, cons125, cons34, cons36, cons21, cons1267, cons77) def replacement4502(C, m, f, b, a, A, x, e): rubi.append(4502) return Dist(S(1)/b, Int((a + b/sin(e + f*x))**m*(A*b - C*a/sin(e + f*x)), x), x) + Dist(C/b, Int((a + b/sin(e + f*x))**(m + S(1))/sin(e + f*x), x), x) rule4502 = ReplacementRule(pattern4502, replacement4502) pattern4503 = Pattern(Integral((WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('A', S(0)) + WC('B', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))) + WC('C', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0)))**S(2)), x_), cons3, cons48, cons125, cons34, cons35, cons36, cons21, cons18) def replacement4503(B, C, e, m, f, b, x, A): rubi.append(4503) return Dist(b**S(2), Int((b*cos(e + f*x))**(m + S(-2))*(A*cos(e + f*x)**S(2) + B*cos(e + f*x) + C), x), x) rule4503 = ReplacementRule(pattern4503, replacement4503) pattern4504 = Pattern(Integral((WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('A', S(0)) + WC('B', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))) + WC('C', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0)))**S(2)), x_), cons3, cons48, cons125, cons34, cons35, cons36, cons21, cons18) def replacement4504(B, C, e, m, f, b, x, A): rubi.append(4504) return Dist(b**S(2), Int((b*sin(e + f*x))**(m + S(-2))*(A*sin(e + f*x)**S(2) + B*sin(e + f*x) + C), x), x) rule4504 = ReplacementRule(pattern4504, replacement4504) pattern4505 = Pattern(Integral((WC('b', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('A', S(0)) + WC('C', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0)))**S(2)), x_), cons3, cons48, cons125, cons34, cons36, cons21, cons18) def replacement4505(C, e, m, f, b, x, A): rubi.append(4505) return Dist(b**S(2), Int((b*cos(e + f*x))**(m + S(-2))*(A*cos(e + f*x)**S(2) + C), x), x) rule4505 = ReplacementRule(pattern4505, replacement4505) pattern4506 = Pattern(Integral((WC('b', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('A', S(0)) + WC('C', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0)))**S(2)), x_), cons3, cons48, cons125, cons34, cons36, cons21, cons18) def replacement4506(C, e, m, f, b, x, A): rubi.append(4506) return Dist(b**S(2), Int((b*sin(e + f*x))**(m + S(-2))*(A*sin(e + f*x)**S(2) + C), x), x) rule4506 = ReplacementRule(pattern4506, replacement4506) pattern4507 = Pattern(Integral(((WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**p_*WC('a', S(1)))**m_*(WC('A', S(0)) + WC('B', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))) + WC('C', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0)))**S(2)), x_), cons2, cons3, cons48, cons125, cons34, cons35, cons36, cons21, cons5, cons18) def replacement4507(B, C, e, p, m, f, b, a, x, A): rubi.append(4507) return Dist(a**IntPart(m)*(a*(b/cos(e + f*x))**p)**FracPart(m)*(b/cos(e + f*x))**(-p*FracPart(m)), Int((b/cos(e + f*x))**(m*p)*(A + B/cos(e + f*x) + C/cos(e + f*x)**S(2)), x), x) rule4507 = ReplacementRule(pattern4507, replacement4507) pattern4508 = Pattern(Integral(((WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**p_*WC('a', S(1)))**m_*(WC('A', S(0)) + WC('B', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))) + WC('C', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0)))**S(2)), x_), cons2, cons3, cons48, cons125, cons34, cons35, cons36, cons21, cons5, cons18) def replacement4508(B, C, e, p, m, f, b, a, x, A): rubi.append(4508) return Dist(a**IntPart(m)*(a*(b/sin(e + f*x))**p)**FracPart(m)*(b/sin(e + f*x))**(-p*FracPart(m)), Int((b/sin(e + f*x))**(m*p)*(A + B/sin(e + f*x) + C/sin(e + f*x)**S(2)), x), x) rule4508 = ReplacementRule(pattern4508, replacement4508) pattern4509 = Pattern(Integral(((WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**p_*WC('a', S(1)))**m_*(WC('A', S(0)) + WC('C', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0)))**S(2)), x_), cons2, cons3, cons48, cons125, cons34, cons36, cons21, cons5, cons18) def replacement4509(C, e, p, m, f, b, a, x, A): rubi.append(4509) return Dist(a**IntPart(m)*(a*(b/cos(e + f*x))**p)**FracPart(m)*(b/cos(e + f*x))**(-p*FracPart(m)), Int((b/cos(e + f*x))**(m*p)*(A + C/cos(e + f*x)**S(2)), x), x) rule4509 = ReplacementRule(pattern4509, replacement4509) pattern4510 = Pattern(Integral(((WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**p_*WC('a', S(1)))**m_*(WC('A', S(0)) + WC('C', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0)))**S(2)), x_), cons2, cons3, cons48, cons125, cons34, cons36, cons21, cons5, cons18) def replacement4510(C, e, p, m, f, b, a, x, A): rubi.append(4510) return Dist(a**IntPart(m)*(a*(b/sin(e + f*x))**p)**FracPart(m)*(b/sin(e + f*x))**(-p*FracPart(m)), Int((b/sin(e + f*x))**(m*p)*(A + C/sin(e + f*x)**S(2)), x), x) rule4510 = ReplacementRule(pattern4510, replacement4510) pattern4511 = Pattern(Integral((WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))*(WC('A', S(0)) + WC('B', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))) + WC('C', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0)))**S(2)), x_), cons2, cons3, cons27, cons48, cons125, cons34, cons35, cons36, cons87, cons89) def replacement4511(B, C, e, f, b, d, a, n, x, A): rubi.append(4511) return Dist(S(1)/(d*n), Int((d/cos(e + f*x))**(n + S(1))*Simp(C*b*n/cos(e + f*x)**S(2) + n*(A*b + B*a) + (A*a*(n + S(1)) + n*(B*b + C*a))/cos(e + f*x), x), x), x) - Simp(A*a*(d/cos(e + f*x))**n*tan(e + f*x)/(f*n), x) rule4511 = ReplacementRule(pattern4511, replacement4511) pattern4512 = Pattern(Integral((WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))*(WC('A', S(0)) + WC('B', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))) + WC('C', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0)))**S(2)), x_), cons2, cons3, cons27, cons48, cons125, cons34, cons35, cons36, cons87, cons89) def replacement4512(B, C, f, b, d, a, n, A, x, e): rubi.append(4512) return Dist(S(1)/(d*n), Int((d/sin(e + f*x))**(n + S(1))*Simp(C*b*n/sin(e + f*x)**S(2) + n*(A*b + B*a) + (A*a*(n + S(1)) + n*(B*b + C*a))/sin(e + f*x), x), x), x) + Simp(A*a*(d/sin(e + f*x))**n/(f*n*tan(e + f*x)), x) rule4512 = ReplacementRule(pattern4512, replacement4512) pattern4513 = Pattern(Integral((WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))*(WC('A', S(0)) + WC('C', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0)))**S(2)), x_), cons2, cons3, cons27, cons48, cons125, cons34, cons36, cons87, cons89) def replacement4513(C, e, f, b, d, a, n, x, A): rubi.append(4513) return Dist(S(1)/(d*n), Int((d/cos(e + f*x))**(n + S(1))*Simp(A*b*n + C*b*n/cos(e + f*x)**S(2) + a*(A*(n + S(1)) + C*n)/cos(e + f*x), x), x), x) - Simp(A*a*(d/cos(e + f*x))**n*tan(e + f*x)/(f*n), x) rule4513 = ReplacementRule(pattern4513, replacement4513) pattern4514 = Pattern(Integral((WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))*(WC('A', S(0)) + WC('C', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0)))**S(2)), x_), cons2, cons3, cons27, cons48, cons125, cons34, cons36, cons87, cons89) def replacement4514(C, f, b, d, a, n, A, x, e): rubi.append(4514) return Dist(S(1)/(d*n), Int((d/sin(e + f*x))**(n + S(1))*Simp(A*b*n + C*b*n/sin(e + f*x)**S(2) + a*(A*(n + S(1)) + C*n)/sin(e + f*x), x), x), x) + Simp(A*a*(d/sin(e + f*x))**n/(f*n*tan(e + f*x)), x) rule4514 = ReplacementRule(pattern4514, replacement4514) pattern4515 = Pattern(Integral((WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1))*(a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))*(WC('A', S(0)) + WC('B', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))) + WC('C', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0)))**S(2)), x_), cons2, cons3, cons27, cons48, cons125, cons34, cons35, cons36, cons4, cons346) def replacement4515(B, C, f, b, d, a, n, A, x, e): rubi.append(4515) return Dist(S(1)/(n + S(2)), Int((d/cos(e + f*x))**n*Simp(A*a*(n + S(2)) + (n + S(2))*(B*b + C*a)/cos(e + f*x)**S(2) + (B*a*(n + S(2)) + b*(A*(n + S(2)) + C*(n + S(1))))/cos(e + f*x), x), x), x) + Simp(C*b*(d/cos(e + f*x))**n*tan(e + f*x)/(f*(n + S(2))*cos(e + f*x)), x) rule4515 = ReplacementRule(pattern4515, replacement4515) pattern4516 = Pattern(Integral((WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1))*(a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))*(WC('A', S(0)) + WC('B', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))) + WC('C', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0)))**S(2)), x_), cons2, cons3, cons27, cons48, cons125, cons34, cons35, cons36, cons4, cons346) def replacement4516(B, C, f, b, d, a, n, A, x, e): rubi.append(4516) return Dist(S(1)/(n + S(2)), Int((d/sin(e + f*x))**n*Simp(A*a*(n + S(2)) + (n + S(2))*(B*b + C*a)/sin(e + f*x)**S(2) + (B*a*(n + S(2)) + b*(A*(n + S(2)) + C*(n + S(1))))/sin(e + f*x), x), x), x) - Simp(C*b*(d/sin(e + f*x))**n/(f*(n + S(2))*sin(e + f*x)*tan(e + f*x)), x) rule4516 = ReplacementRule(pattern4516, replacement4516) pattern4517 = Pattern(Integral((WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1))*(a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))*(WC('A', S(0)) + WC('C', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0)))**S(2)), x_), cons2, cons3, cons27, cons48, cons125, cons34, cons36, cons4, cons346) def replacement4517(C, f, b, d, a, n, A, x, e): rubi.append(4517) return Dist(S(1)/(n + S(2)), Int((d/cos(e + f*x))**n*Simp(A*a*(n + S(2)) + C*a*(n + S(2))/cos(e + f*x)**S(2) + b*(A*(n + S(2)) + C*(n + S(1)))/cos(e + f*x), x), x), x) + Simp(C*b*(d/cos(e + f*x))**n*tan(e + f*x)/(f*(n + S(2))*cos(e + f*x)), x) rule4517 = ReplacementRule(pattern4517, replacement4517) pattern4518 = Pattern(Integral((WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1))*(a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))*(WC('A', S(0)) + WC('C', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0)))**S(2)), x_), cons2, cons3, cons27, cons48, cons125, cons34, cons36, cons4, cons346) def replacement4518(C, f, b, d, a, n, A, x, e): rubi.append(4518) return Dist(S(1)/(n + S(2)), Int((d/sin(e + f*x))**n*Simp(A*a*(n + S(2)) + C*a*(n + S(2))/sin(e + f*x)**S(2) + b*(A*(n + S(2)) + C*(n + S(1)))/sin(e + f*x), x), x), x) - Simp(C*b*(d/sin(e + f*x))**n/(f*(n + S(2))*sin(e + f*x)*tan(e + f*x)), x) rule4518 = ReplacementRule(pattern4518, replacement4518) pattern4519 = Pattern(Integral((a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('A', S(0)) + WC('B', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))) + WC('C', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0)))**S(2))/cos(x_*WC('f', S(1)) + WC('e', S(0))), x_), cons2, cons3, cons48, cons125, cons34, cons35, cons36, cons31, cons94, cons1265) def replacement4519(B, C, e, m, f, b, a, x, A): rubi.append(4519) return -Dist(S(1)/(a*b*(S(2)*m + S(1))), Int((a + b/cos(e + f*x))**(m + S(1))*Simp(-S(2)*A*b*(m + S(1)) + B*a - C*b - (B*b*(m + S(2)) - a*(A*(m + S(2)) - C*(m + S(-1))))/cos(e + f*x), x)/cos(e + f*x), x), x) + Simp((a + b/cos(e + f*x))**m*(A*a - B*b + C*a)*tan(e + f*x)/(a*f*(S(2)*m + S(1))*cos(e + f*x)), x) rule4519 = ReplacementRule(pattern4519, replacement4519) pattern4520 = Pattern(Integral((a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('A', S(0)) + WC('B', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))) + WC('C', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0)))**S(2))/sin(x_*WC('f', S(1)) + WC('e', S(0))), x_), cons2, cons3, cons48, cons125, cons34, cons35, cons36, cons31, cons94, cons1265) def replacement4520(B, C, e, m, f, b, a, x, A): rubi.append(4520) return -Dist(S(1)/(a*b*(S(2)*m + S(1))), Int((a + b/sin(e + f*x))**(m + S(1))*Simp(-S(2)*A*b*(m + S(1)) + B*a - C*b - (B*b*(m + S(2)) - a*(A*(m + S(2)) - C*(m + S(-1))))/sin(e + f*x), x)/sin(e + f*x), x), x) - Simp((a + b/sin(e + f*x))**m*(A*a - B*b + C*a)/(a*f*(S(2)*m + S(1))*sin(e + f*x)*tan(e + f*x)), x) rule4520 = ReplacementRule(pattern4520, replacement4520) pattern4521 = Pattern(Integral((a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('A', S(0)) + WC('C', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0)))**S(2))/cos(x_*WC('f', S(1)) + WC('e', S(0))), x_), cons2, cons3, cons48, cons125, cons34, cons36, cons31, cons94, cons1265) def replacement4521(C, e, m, f, b, a, x, A): rubi.append(4521) return -Dist(S(1)/(a*b*(S(2)*m + S(1))), Int((a + b/cos(e + f*x))**(m + S(1))*Simp(-S(2)*A*b*(m + S(1)) - C*b + a*(A*(m + S(2)) - C*(m + S(-1)))/cos(e + f*x), x)/cos(e + f*x), x), x) + Simp((A + C)*(a + b/cos(e + f*x))**m*tan(e + f*x)/(f*(S(2)*m + S(1))*cos(e + f*x)), x) rule4521 = ReplacementRule(pattern4521, replacement4521) pattern4522 = Pattern(Integral((a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('A', S(0)) + WC('C', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0)))**S(2))/sin(x_*WC('f', S(1)) + WC('e', S(0))), x_), cons2, cons3, cons48, cons125, cons34, cons36, cons31, cons94, cons1265) def replacement4522(C, e, m, f, b, a, x, A): rubi.append(4522) return -Dist(S(1)/(a*b*(S(2)*m + S(1))), Int((a + b/sin(e + f*x))**(m + S(1))*Simp(-S(2)*A*b*(m + S(1)) - C*b + a*(A*(m + S(2)) - C*(m + S(-1)))/sin(e + f*x), x)/sin(e + f*x), x), x) - Simp((A + C)*(a + b/sin(e + f*x))**m/(f*(S(2)*m + S(1))*sin(e + f*x)*tan(e + f*x)), x) rule4522 = ReplacementRule(pattern4522, replacement4522) pattern4523 = Pattern(Integral((a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('A', S(0)) + WC('B', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))) + WC('C', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0)))**S(2))/cos(x_*WC('f', S(1)) + WC('e', S(0))), x_), cons2, cons3, cons48, cons125, cons34, cons35, cons36, cons31, cons94, cons1267) def replacement4523(B, C, e, m, f, b, a, x, A): rubi.append(4523) return Dist(S(1)/(b*(a**S(2) - b**S(2))*(m + S(1))), Int((a + b/cos(e + f*x))**(m + S(1))*Simp(b*(m + S(1))*(A*a - B*b + C*a) - (A*b**S(2) - B*a*b + C*a**S(2) + b*(m + S(1))*(A*b - B*a + C*b))/cos(e + f*x), x)/cos(e + f*x), x), x) + Simp((a + b/cos(e + f*x))**(m + S(1))*(A*b**S(2) - B*a*b + C*a**S(2))*tan(e + f*x)/(b*f*(a**S(2) - b**S(2))*(m + S(1))), x) rule4523 = ReplacementRule(pattern4523, replacement4523) pattern4524 = Pattern(Integral((a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('A', S(0)) + WC('B', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))) + WC('C', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0)))**S(2))/sin(x_*WC('f', S(1)) + WC('e', S(0))), x_), cons2, cons3, cons48, cons125, cons34, cons35, cons36, cons31, cons94, cons1267) def replacement4524(B, C, e, m, f, b, a, x, A): rubi.append(4524) return Dist(S(1)/(b*(a**S(2) - b**S(2))*(m + S(1))), Int((a + b/sin(e + f*x))**(m + S(1))*Simp(b*(m + S(1))*(A*a - B*b + C*a) - (A*b**S(2) - B*a*b + C*a**S(2) + b*(m + S(1))*(A*b - B*a + C*b))/sin(e + f*x), x)/sin(e + f*x), x), x) - Simp((a + b/sin(e + f*x))**(m + S(1))*(A*b**S(2) - B*a*b + C*a**S(2))/(b*f*(a**S(2) - b**S(2))*(m + S(1))*tan(e + f*x)), x) rule4524 = ReplacementRule(pattern4524, replacement4524) pattern4525 = Pattern(Integral((a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('A', S(0)) + WC('C', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0)))**S(2))/cos(x_*WC('f', S(1)) + WC('e', S(0))), x_), cons2, cons3, cons48, cons125, cons34, cons36, cons31, cons94, cons1267) def replacement4525(C, e, m, f, b, a, x, A): rubi.append(4525) return Dist(S(1)/(b*(a**S(2) - b**S(2))*(m + S(1))), Int((a + b/cos(e + f*x))**(m + S(1))*Simp(a*b*(A + C)*(m + S(1)) - (A*b**S(2) + C*a**S(2) + b*(m + S(1))*(A*b + C*b))/cos(e + f*x), x)/cos(e + f*x), x), x) + Simp((a + b/cos(e + f*x))**(m + S(1))*(A*b**S(2) + C*a**S(2))*tan(e + f*x)/(b*f*(a**S(2) - b**S(2))*(m + S(1))), x) rule4525 = ReplacementRule(pattern4525, replacement4525) pattern4526 = Pattern(Integral((a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('A', S(0)) + WC('C', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0)))**S(2))/sin(x_*WC('f', S(1)) + WC('e', S(0))), x_), cons2, cons3, cons48, cons125, cons34, cons36, cons31, cons94, cons1267) def replacement4526(C, e, m, f, b, a, x, A): rubi.append(4526) return Dist(S(1)/(b*(a**S(2) - b**S(2))*(m + S(1))), Int((a + b/sin(e + f*x))**(m + S(1))*Simp(a*b*(A + C)*(m + S(1)) - (A*b**S(2) + C*a**S(2) + b*(m + S(1))*(A*b + C*b))/sin(e + f*x), x)/sin(e + f*x), x), x) - Simp((a + b/sin(e + f*x))**(m + S(1))*(A*b**S(2) + C*a**S(2))/(b*f*(a**S(2) - b**S(2))*(m + S(1))*tan(e + f*x)), x) rule4526 = ReplacementRule(pattern4526, replacement4526) pattern4527 = Pattern(Integral((a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('A', S(0)) + WC('B', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))) + WC('C', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0)))**S(2))/cos(x_*WC('f', S(1)) + WC('e', S(0))), x_), cons2, cons3, cons48, cons125, cons34, cons35, cons36, cons21, cons272) def replacement4527(B, C, e, m, f, b, a, x, A): rubi.append(4527) return Dist(S(1)/(b*(m + S(2))), Int((a + b/cos(e + f*x))**m*Simp(A*b*(m + S(2)) + C*b*(m + S(1)) + (B*b*(m + S(2)) - C*a)/cos(e + f*x), x)/cos(e + f*x), x), x) + Simp(C*(a + b/cos(e + f*x))**(m + S(1))*tan(e + f*x)/(b*f*(m + S(2))), x) rule4527 = ReplacementRule(pattern4527, replacement4527) pattern4528 = Pattern(Integral((a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('A', S(0)) + WC('B', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))) + WC('C', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0)))**S(2))/sin(x_*WC('f', S(1)) + WC('e', S(0))), x_), cons2, cons3, cons48, cons125, cons34, cons35, cons36, cons21, cons272) def replacement4528(B, C, e, m, f, b, a, x, A): rubi.append(4528) return Dist(S(1)/(b*(m + S(2))), Int((a + b/sin(e + f*x))**m*Simp(A*b*(m + S(2)) + C*b*(m + S(1)) + (B*b*(m + S(2)) - C*a)/sin(e + f*x), x)/sin(e + f*x), x), x) - Simp(C*(a + b/sin(e + f*x))**(m + S(1))/(b*f*(m + S(2))*tan(e + f*x)), x) rule4528 = ReplacementRule(pattern4528, replacement4528) pattern4529 = Pattern(Integral((a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('A', S(0)) + WC('C', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0)))**S(2))/cos(x_*WC('f', S(1)) + WC('e', S(0))), x_), cons2, cons3, cons48, cons125, cons34, cons36, cons21, cons272) def replacement4529(C, e, m, f, b, a, x, A): rubi.append(4529) return Dist(S(1)/(b*(m + S(2))), Int((a + b/cos(e + f*x))**m*Simp(A*b*(m + S(2)) - C*a/cos(e + f*x) + C*b*(m + S(1)), x)/cos(e + f*x), x), x) + Simp(C*(a + b/cos(e + f*x))**(m + S(1))*tan(e + f*x)/(b*f*(m + S(2))), x) rule4529 = ReplacementRule(pattern4529, replacement4529) pattern4530 = Pattern(Integral((a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('A', S(0)) + WC('C', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0)))**S(2))/sin(x_*WC('f', S(1)) + WC('e', S(0))), x_), cons2, cons3, cons48, cons125, cons34, cons36, cons21, cons272) def replacement4530(C, e, m, f, b, a, x, A): rubi.append(4530) return Dist(S(1)/(b*(m + S(2))), Int((a + b/sin(e + f*x))**m*Simp(A*b*(m + S(2)) - C*a/sin(e + f*x) + C*b*(m + S(1)), x)/sin(e + f*x), x), x) - Simp(C*(a + b/sin(e + f*x))**(m + S(1))/(b*f*(m + S(2))*tan(e + f*x)), x) rule4530 = ReplacementRule(pattern4530, replacement4530) pattern4531 = Pattern(Integral((WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('A', S(0)) + WC('B', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))) + WC('C', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0)))**S(2)), x_), cons2, cons3, cons27, cons48, cons125, cons34, cons35, cons36, cons4, cons1265, cons31, cons1320) def replacement4531(B, C, e, m, f, b, d, a, n, x, A): rubi.append(4531) return -Dist(S(1)/(a*b*(S(2)*m + S(1))), Int((d/cos(e + f*x))**n*(a + b/cos(e + f*x))**(m + S(1))*Simp(-A*b*(S(2)*m + n + S(1)) + B*a*n - C*b*n - (B*b*(m + n + S(1)) - a*(A*(m + n + S(1)) - C*(m - n)))/cos(e + f*x), x), x), x) + Simp((d/cos(e + f*x))**n*(a + b/cos(e + f*x))**m*(A*a - B*b + C*a)*tan(e + f*x)/(a*f*(S(2)*m + S(1))), x) rule4531 = ReplacementRule(pattern4531, replacement4531) pattern4532 = Pattern(Integral((WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('A', S(0)) + WC('B', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))) + WC('C', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0)))**S(2)), x_), cons2, cons3, cons27, cons48, cons125, cons34, cons35, cons36, cons4, cons1265, cons31, cons1320) def replacement4532(B, C, m, f, b, d, a, n, A, x, e): rubi.append(4532) return -Dist(S(1)/(a*b*(S(2)*m + S(1))), Int((d/sin(e + f*x))**n*(a + b/sin(e + f*x))**(m + S(1))*Simp(-A*b*(S(2)*m + n + S(1)) + B*a*n - C*b*n - (B*b*(m + n + S(1)) - a*(A*(m + n + S(1)) - C*(m - n)))/sin(e + f*x), x), x), x) - Simp((d/sin(e + f*x))**n*(a + b/sin(e + f*x))**m*(A*a - B*b + C*a)/(a*f*(S(2)*m + S(1))*tan(e + f*x)), x) rule4532 = ReplacementRule(pattern4532, replacement4532) pattern4533 = Pattern(Integral((WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('A', S(0)) + WC('C', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0)))**S(2)), x_), cons2, cons3, cons27, cons48, cons125, cons34, cons36, cons4, cons1265, cons31, cons1320) def replacement4533(C, e, m, f, b, d, a, n, x, A): rubi.append(4533) return Dist(S(1)/(a*b*(S(2)*m + S(1))), Int((d/cos(e + f*x))**n*(a + b/cos(e + f*x))**(m + S(1))*Simp(A*b*(S(2)*m + n + S(1)) + C*b*n - a*(A*(m + n + S(1)) - C*(m - n))/cos(e + f*x), x), x), x) + Simp((d/cos(e + f*x))**n*(A + C)*(a + b/cos(e + f*x))**m*tan(e + f*x)/(f*(S(2)*m + S(1))), x) rule4533 = ReplacementRule(pattern4533, replacement4533) pattern4534 = Pattern(Integral((WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('A', S(0)) + WC('C', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0)))**S(2)), x_), cons2, cons3, cons27, cons48, cons125, cons34, cons36, cons4, cons1265, cons31, cons1320) def replacement4534(C, m, f, b, d, a, n, A, x, e): rubi.append(4534) return Dist(S(1)/(a*b*(S(2)*m + S(1))), Int((d/sin(e + f*x))**n*(a + b/sin(e + f*x))**(m + S(1))*Simp(A*b*(S(2)*m + n + S(1)) + C*b*n - a*(A*(m + n + S(1)) - C*(m - n))/sin(e + f*x), x), x), x) - Simp((d/sin(e + f*x))**n*(A + C)*(a + b/sin(e + f*x))**m/(f*(S(2)*m + S(1))*tan(e + f*x)), x) rule4534 = ReplacementRule(pattern4534, replacement4534) pattern4535 = Pattern(Integral((WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('A', S(0)) + WC('B', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))) + WC('C', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0)))**S(2)), x_), cons2, cons3, cons27, cons48, cons125, cons34, cons35, cons36, cons21, cons1265, cons1321, cons1639) def replacement4535(B, C, e, m, f, b, d, a, n, x, A): rubi.append(4535) return -Dist(S(1)/(b*d*n), Int((d/cos(e + f*x))**(n + S(1))*(a + b/cos(e + f*x))**m*Simp(A*a*m - B*b*n - b*(A*(m + n + S(1)) + C*n)/cos(e + f*x), x), x), x) - Simp(A*(d/cos(e + f*x))**n*(a + b/cos(e + f*x))**m*tan(e + f*x)/(f*n), x) rule4535 = ReplacementRule(pattern4535, replacement4535) pattern4536 = Pattern(Integral((WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('A', S(0)) + WC('B', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))) + WC('C', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0)))**S(2)), x_), cons2, cons3, cons27, cons48, cons125, cons34, cons35, cons36, cons21, cons1265, cons1321, cons1639) def replacement4536(B, C, m, f, b, d, a, n, A, x, e): rubi.append(4536) return -Dist(S(1)/(b*d*n), Int((d/sin(e + f*x))**(n + S(1))*(a + b/sin(e + f*x))**m*Simp(A*a*m - B*b*n - b*(A*(m + n + S(1)) + C*n)/sin(e + f*x), x), x), x) + Simp(A*(d/sin(e + f*x))**n*(a + b/sin(e + f*x))**m/(f*n*tan(e + f*x)), x) rule4536 = ReplacementRule(pattern4536, replacement4536) pattern4537 = Pattern(Integral((WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('A', S(0)) + WC('C', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0)))**S(2)), x_), cons2, cons3, cons27, cons48, cons125, cons34, cons36, cons21, cons1265, cons1321, cons1639) def replacement4537(C, e, m, f, b, d, a, n, x, A): rubi.append(4537) return -Dist(S(1)/(b*d*n), Int((d/cos(e + f*x))**(n + S(1))*(a + b/cos(e + f*x))**m*Simp(A*a*m - b*(A*(m + n + S(1)) + C*n)/cos(e + f*x), x), x), x) - Simp(A*(d/cos(e + f*x))**n*(a + b/cos(e + f*x))**m*tan(e + f*x)/(f*n), x) rule4537 = ReplacementRule(pattern4537, replacement4537) pattern4538 = Pattern(Integral((WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('A', S(0)) + WC('C', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0)))**S(2)), x_), cons2, cons3, cons27, cons48, cons125, cons34, cons36, cons21, cons1265, cons1321, cons1639) def replacement4538(C, m, f, b, d, a, n, A, x, e): rubi.append(4538) return -Dist(S(1)/(b*d*n), Int((d/sin(e + f*x))**(n + S(1))*(a + b/sin(e + f*x))**m*Simp(A*a*m - b*(A*(m + n + S(1)) + C*n)/sin(e + f*x), x), x), x) + Simp(A*(d/sin(e + f*x))**n*(a + b/sin(e + f*x))**m/(f*n*tan(e + f*x)), x) rule4538 = ReplacementRule(pattern4538, replacement4538) pattern4539 = Pattern(Integral((WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('A', S(0)) + WC('B', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))) + WC('C', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0)))**S(2)), x_), cons2, cons3, cons27, cons48, cons125, cons34, cons35, cons36, cons21, cons4, cons1265, cons1321, cons1640, cons683) def replacement4539(B, C, e, m, f, b, d, a, n, x, A): rubi.append(4539) return Dist(S(1)/(b*(m + n + S(1))), Int((d/cos(e + f*x))**n*(a + b/cos(e + f*x))**m*Simp(A*b*(m + n + S(1)) + C*b*n + (B*b*(m + n + S(1)) + C*a*m)/cos(e + f*x), x), x), x) + Simp(C*(d/cos(e + f*x))**n*(a + b/cos(e + f*x))**m*tan(e + f*x)/(f*(m + n + S(1))), x) rule4539 = ReplacementRule(pattern4539, replacement4539) pattern4540 = Pattern(Integral((WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('A', S(0)) + WC('B', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))) + WC('C', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0)))**S(2)), x_), cons2, cons3, cons27, cons48, cons125, cons34, cons35, cons36, cons21, cons4, cons1265, cons1321, cons1640, cons683) def replacement4540(B, C, m, f, b, d, a, n, A, x, e): rubi.append(4540) return Dist(S(1)/(b*(m + n + S(1))), Int((d/sin(e + f*x))**n*(a + b/sin(e + f*x))**m*Simp(A*b*(m + n + S(1)) + C*b*n + (B*b*(m + n + S(1)) + C*a*m)/sin(e + f*x), x), x), x) - Simp(C*(d/sin(e + f*x))**n*(a + b/sin(e + f*x))**m/(f*(m + n + S(1))*tan(e + f*x)), x) rule4540 = ReplacementRule(pattern4540, replacement4540) pattern4541 = Pattern(Integral((WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('A', S(0)) + WC('C', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0)))**S(2)), x_), cons2, cons3, cons27, cons48, cons125, cons34, cons36, cons21, cons4, cons1265, cons1321, cons1640, cons683) def replacement4541(C, e, m, f, b, d, a, n, x, A): rubi.append(4541) return Dist(S(1)/(b*(m + n + S(1))), Int((d/cos(e + f*x))**n*(a + b/cos(e + f*x))**m*Simp(A*b*(m + n + S(1)) + C*a*m/cos(e + f*x) + C*b*n, x), x), x) + Simp(C*(d/cos(e + f*x))**n*(a + b/cos(e + f*x))**m*tan(e + f*x)/(f*(m + n + S(1))), x) rule4541 = ReplacementRule(pattern4541, replacement4541) pattern4542 = Pattern(Integral((WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('A', S(0)) + WC('C', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0)))**S(2)), x_), cons2, cons3, cons27, cons48, cons125, cons34, cons36, cons21, cons4, cons1265, cons1321, cons1640, cons683) def replacement4542(C, m, f, b, d, a, n, A, x, e): rubi.append(4542) return Dist(S(1)/(b*(m + n + S(1))), Int((d/sin(e + f*x))**n*(a + b/sin(e + f*x))**m*Simp(A*b*(m + n + S(1)) + C*a*m/sin(e + f*x) + C*b*n, x), x), x) - Simp(C*(d/sin(e + f*x))**n*(a + b/sin(e + f*x))**m/(f*(m + n + S(1))*tan(e + f*x)), x) rule4542 = ReplacementRule(pattern4542, replacement4542) pattern4543 = Pattern(Integral((a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('A', S(0)) + WC('B', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))) + WC('C', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0)))**S(2))/cos(x_*WC('f', S(1)) + WC('e', S(0)))**S(2), x_), cons2, cons3, cons48, cons125, cons34, cons35, cons36, cons1267, cons31, cons94) def replacement4543(B, C, e, m, f, b, a, x, A): rubi.append(4543) return -Dist(S(1)/(b**S(2)*(a**S(2) - b**S(2))*(m + S(1))), Int((a + b/cos(e + f*x))**(m + S(1))*Simp(-C*b*(a**S(2) - b**S(2))*(m + S(1))/cos(e + f*x)**S(2) + b*(m + S(1))*(A*b**S(2) - a*(B*b - C*a)) + (B*b*(a**S(2) + b**S(2)*(m + S(1))) - a*(A*b**S(2)*(m + S(2)) + C*(a**S(2) + b**S(2)*(m + S(1)))))/cos(e + f*x), x)/cos(e + f*x), x), x) - Simp(a*(a + b/cos(e + f*x))**(m + S(1))*(A*b**S(2) - B*a*b + C*a**S(2))*tan(e + f*x)/(b**S(2)*f*(a**S(2) - b**S(2))*(m + S(1))), x) rule4543 = ReplacementRule(pattern4543, replacement4543) pattern4544 = Pattern(Integral((a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('A', S(0)) + WC('B', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))) + WC('C', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0)))**S(2))/sin(x_*WC('f', S(1)) + WC('e', S(0)))**S(2), x_), cons2, cons3, cons48, cons125, cons34, cons35, cons36, cons1267, cons31, cons94) def replacement4544(B, C, e, m, f, b, a, x, A): rubi.append(4544) return -Dist(S(1)/(b**S(2)*(a**S(2) - b**S(2))*(m + S(1))), Int((a + b/sin(e + f*x))**(m + S(1))*Simp(-C*b*(a**S(2) - b**S(2))*(m + S(1))/sin(e + f*x)**S(2) + b*(m + S(1))*(A*b**S(2) - a*(B*b - C*a)) + (B*b*(a**S(2) + b**S(2)*(m + S(1))) - a*(A*b**S(2)*(m + S(2)) + C*(a**S(2) + b**S(2)*(m + S(1)))))/sin(e + f*x), x)/sin(e + f*x), x), x) + Simp(a*(a + b/sin(e + f*x))**(m + S(1))*(A*b**S(2) - B*a*b + C*a**S(2))/(b**S(2)*f*(a**S(2) - b**S(2))*(m + S(1))*tan(e + f*x)), x) rule4544 = ReplacementRule(pattern4544, replacement4544) pattern4545 = Pattern(Integral((a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('A', S(0)) + WC('C', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0)))**S(2))/cos(x_*WC('f', S(1)) + WC('e', S(0)))**S(2), x_), cons2, cons3, cons48, cons125, cons34, cons36, cons1267, cons31, cons94) def replacement4545(C, e, m, f, b, a, x, A): rubi.append(4545) return -Dist(S(1)/(b**S(2)*(a**S(2) - b**S(2))*(m + S(1))), Int((a + b/cos(e + f*x))**(m + S(1))*Simp(-C*b*(a**S(2) - b**S(2))*(m + S(1))/cos(e + f*x)**S(2) - a*(A*b**S(2)*(m + S(2)) + C*(a**S(2) + b**S(2)*(m + S(1))))/cos(e + f*x) + b*(m + S(1))*(A*b**S(2) + C*a**S(2)), x)/cos(e + f*x), x), x) - Simp(a*(a + b/cos(e + f*x))**(m + S(1))*(A*b**S(2) + C*a**S(2))*tan(e + f*x)/(b**S(2)*f*(a**S(2) - b**S(2))*(m + S(1))), x) rule4545 = ReplacementRule(pattern4545, replacement4545) pattern4546 = Pattern(Integral((a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('A', S(0)) + WC('C', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0)))**S(2))/sin(x_*WC('f', S(1)) + WC('e', S(0)))**S(2), x_), cons2, cons3, cons48, cons125, cons34, cons36, cons1267, cons31, cons94) def replacement4546(C, e, m, f, b, a, x, A): rubi.append(4546) return -Dist(S(1)/(b**S(2)*(a**S(2) - b**S(2))*(m + S(1))), Int((a + b/sin(e + f*x))**(m + S(1))*Simp(-C*b*(a**S(2) - b**S(2))*(m + S(1))/sin(e + f*x)**S(2) - a*(A*b**S(2)*(m + S(2)) + C*(a**S(2) + b**S(2)*(m + S(1))))/sin(e + f*x) + b*(m + S(1))*(A*b**S(2) + C*a**S(2)), x)/sin(e + f*x), x), x) + Simp(a*(a + b/sin(e + f*x))**(m + S(1))*(A*b**S(2) + C*a**S(2))/(b**S(2)*f*(a**S(2) - b**S(2))*(m + S(1))*tan(e + f*x)), x) rule4546 = ReplacementRule(pattern4546, replacement4546) pattern4547 = Pattern(Integral((a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('A', S(0)) + WC('B', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))) + WC('C', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0)))**S(2))/cos(x_*WC('f', S(1)) + WC('e', S(0)))**S(2), x_), cons2, cons3, cons48, cons125, cons34, cons35, cons36, cons21, cons1267, cons272) def replacement4547(B, C, e, m, f, b, a, x, A): rubi.append(4547) return Dist(S(1)/(b*(m + S(3))), Int((a + b/cos(e + f*x))**m*Simp(C*a + b*(A*(m + S(3)) + C*(m + S(2)))/cos(e + f*x) - (-B*b*(m + S(3)) + S(2)*C*a)/cos(e + f*x)**S(2), x)/cos(e + f*x), x), x) + Simp(C*(a + b/cos(e + f*x))**(m + S(1))*tan(e + f*x)/(b*f*(m + S(3))*cos(e + f*x)), x) rule4547 = ReplacementRule(pattern4547, replacement4547) pattern4548 = Pattern(Integral((a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('A', S(0)) + WC('B', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))) + WC('C', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0)))**S(2))/sin(x_*WC('f', S(1)) + WC('e', S(0)))**S(2), x_), cons2, cons3, cons48, cons125, cons34, cons35, cons36, cons21, cons1267, cons272) def replacement4548(B, C, e, m, f, b, a, x, A): rubi.append(4548) return Dist(S(1)/(b*(m + S(3))), Int((a + b/sin(e + f*x))**m*Simp(C*a + b*(A*(m + S(3)) + C*(m + S(2)))/sin(e + f*x) - (-B*b*(m + S(3)) + S(2)*C*a)/sin(e + f*x)**S(2), x)/sin(e + f*x), x), x) - Simp(C*(a + b/sin(e + f*x))**(m + S(1))/(b*f*(m + S(3))*sin(e + f*x)*tan(e + f*x)), x) rule4548 = ReplacementRule(pattern4548, replacement4548) pattern4549 = Pattern(Integral((a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('A', S(0)) + WC('C', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0)))**S(2))/cos(x_*WC('f', S(1)) + WC('e', S(0)))**S(2), x_), cons2, cons3, cons48, cons125, cons34, cons36, cons21, cons1267, cons272) def replacement4549(C, e, m, f, b, a, x, A): rubi.append(4549) return Dist(S(1)/(b*(m + S(3))), Int((a + b/cos(e + f*x))**m*Simp(C*a - S(2)*C*a/cos(e + f*x)**S(2) + b*(A*(m + S(3)) + C*(m + S(2)))/cos(e + f*x), x)/cos(e + f*x), x), x) + Simp(C*(a + b/cos(e + f*x))**(m + S(1))*tan(e + f*x)/(b*f*(m + S(3))*cos(e + f*x)), x) rule4549 = ReplacementRule(pattern4549, replacement4549) pattern4550 = Pattern(Integral((a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('A', S(0)) + WC('C', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0)))**S(2))/sin(x_*WC('f', S(1)) + WC('e', S(0)))**S(2), x_), cons2, cons3, cons48, cons125, cons34, cons36, cons21, cons1267, cons272) def replacement4550(C, e, m, f, b, a, x, A): rubi.append(4550) return Dist(S(1)/(b*(m + S(3))), Int((a + b/sin(e + f*x))**m*Simp(C*a - S(2)*C*a/sin(e + f*x)**S(2) + b*(A*(m + S(3)) + C*(m + S(2)))/sin(e + f*x), x)/sin(e + f*x), x), x) - Simp(C*(a + b/sin(e + f*x))**(m + S(1))/(b*f*(m + S(3))*sin(e + f*x)*tan(e + f*x)), x) rule4550 = ReplacementRule(pattern4550, replacement4550) pattern4551 = Pattern(Integral((WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('A', S(0)) + WC('B', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))) + WC('C', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0)))**S(2)), x_), cons2, cons3, cons27, cons48, cons125, cons34, cons35, cons36, cons1267, cons93, cons168, cons1586) def replacement4551(B, C, e, m, f, b, d, a, n, x, A): rubi.append(4551) return -Dist(S(1)/(d*n), Int((d/cos(e + f*x))**(n + S(1))*(a + b/cos(e + f*x))**(m + S(-1))*Simp(A*b*m - B*a*n - b*(A*(m + n + S(1)) + C*n)/cos(e + f*x)**S(2) - (B*b*n + a*(A*(n + S(1)) + C*n))/cos(e + f*x), x), x), x) - Simp(A*(d/cos(e + f*x))**n*(a + b/cos(e + f*x))**m*tan(e + f*x)/(f*n), x) rule4551 = ReplacementRule(pattern4551, replacement4551) pattern4552 = Pattern(Integral((WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('A', S(0)) + WC('B', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))) + WC('C', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0)))**S(2)), x_), cons2, cons3, cons27, cons48, cons125, cons34, cons35, cons36, cons1267, cons93, cons168, cons1586) def replacement4552(B, C, m, f, b, d, a, n, A, x, e): rubi.append(4552) return -Dist(S(1)/(d*n), Int((d/sin(e + f*x))**(n + S(1))*(a + b/sin(e + f*x))**(m + S(-1))*Simp(A*b*m - B*a*n - b*(A*(m + n + S(1)) + C*n)/sin(e + f*x)**S(2) - (B*b*n + a*(A*(n + S(1)) + C*n))/sin(e + f*x), x), x), x) + Simp(A*(d/sin(e + f*x))**n*(a + b/sin(e + f*x))**m/(f*n*tan(e + f*x)), x) rule4552 = ReplacementRule(pattern4552, replacement4552) pattern4553 = Pattern(Integral((WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('A', S(0)) + WC('C', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0)))**S(2)), x_), cons2, cons3, cons27, cons48, cons125, cons34, cons36, cons1267, cons93, cons168, cons1586) def replacement4553(C, e, m, f, b, d, a, n, x, A): rubi.append(4553) return -Dist(S(1)/(d*n), Int((d/cos(e + f*x))**(n + S(1))*(a + b/cos(e + f*x))**(m + S(-1))*Simp(A*b*m - a*(A*(n + S(1)) + C*n)/cos(e + f*x) - b*(A*(m + n + S(1)) + C*n)/cos(e + f*x)**S(2), x), x), x) - Simp(A*(d/cos(e + f*x))**n*(a + b/cos(e + f*x))**m*tan(e + f*x)/(f*n), x) rule4553 = ReplacementRule(pattern4553, replacement4553) pattern4554 = Pattern(Integral((WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('A', S(0)) + WC('C', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0)))**S(2)), x_), cons2, cons3, cons27, cons48, cons125, cons34, cons36, cons1267, cons93, cons168, cons1586) def replacement4554(C, m, f, b, d, a, n, A, x, e): rubi.append(4554) return -Dist(S(1)/(d*n), Int((d/sin(e + f*x))**(n + S(1))*(a + b/sin(e + f*x))**(m + S(-1))*Simp(A*b*m - a*(A*(n + S(1)) + C*n)/sin(e + f*x) - b*(A*(m + n + S(1)) + C*n)/sin(e + f*x)**S(2), x), x), x) + Simp(A*(d/sin(e + f*x))**n*(a + b/sin(e + f*x))**m/(f*n*tan(e + f*x)), x) rule4554 = ReplacementRule(pattern4554, replacement4554) pattern4555 = Pattern(Integral((WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('A', S(0)) + WC('B', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))) + WC('C', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0)))**S(2)), x_), cons2, cons3, cons27, cons48, cons125, cons34, cons35, cons36, cons4, cons1267, cons31, cons168, cons1569) def replacement4555(B, C, e, m, f, b, d, a, n, x, A): rubi.append(4555) return Dist(S(1)/(m + n + S(1)), Int((d/cos(e + f*x))**n*(a + b/cos(e + f*x))**(m + S(-1))*Simp(A*a*(m + n + S(1)) + C*a*n + (B*b*(m + n + S(1)) + C*a*m)/cos(e + f*x)**S(2) + (C*b*(m + n) + (A*b + B*a)*(m + n + S(1)))/cos(e + f*x), x), x), x) + Simp(C*(d/cos(e + f*x))**n*(a + b/cos(e + f*x))**m*tan(e + f*x)/(f*(m + n + S(1))), x) rule4555 = ReplacementRule(pattern4555, replacement4555) pattern4556 = Pattern(Integral((WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('A', S(0)) + WC('B', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))) + WC('C', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0)))**S(2)), x_), cons2, cons3, cons27, cons48, cons125, cons34, cons35, cons36, cons4, cons1267, cons31, cons168, cons1569) def replacement4556(B, C, m, f, b, d, a, n, A, x, e): rubi.append(4556) return Dist(S(1)/(m + n + S(1)), Int((d/sin(e + f*x))**n*(a + b/sin(e + f*x))**(m + S(-1))*Simp(A*a*(m + n + S(1)) + C*a*n + (B*b*(m + n + S(1)) + C*a*m)/sin(e + f*x)**S(2) + (C*b*(m + n) + (A*b + B*a)*(m + n + S(1)))/sin(e + f*x), x), x), x) - Simp(C*(d/sin(e + f*x))**n*(a + b/sin(e + f*x))**m/(f*(m + n + S(1))*tan(e + f*x)), x) rule4556 = ReplacementRule(pattern4556, replacement4556) pattern4557 = Pattern(Integral((WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('A', S(0)) + WC('C', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0)))**S(2)), x_), cons2, cons3, cons27, cons48, cons125, cons34, cons36, cons4, cons1267, cons31, cons168, cons1569) def replacement4557(C, e, m, f, b, d, a, n, x, A): rubi.append(4557) return Dist(S(1)/(m + n + S(1)), Int((d/cos(e + f*x))**n*(a + b/cos(e + f*x))**(m + S(-1))*Simp(A*a*(m + n + S(1)) + C*a*m/cos(e + f*x)**S(2) + C*a*n + b*(A*(m + n + S(1)) + C*(m + n))/cos(e + f*x), x), x), x) + Simp(C*(d/cos(e + f*x))**n*(a + b/cos(e + f*x))**m*tan(e + f*x)/(f*(m + n + S(1))), x) rule4557 = ReplacementRule(pattern4557, replacement4557) pattern4558 = Pattern(Integral((WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('A', S(0)) + WC('C', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0)))**S(2)), x_), cons2, cons3, cons27, cons48, cons125, cons34, cons36, cons4, cons1267, cons31, cons168, cons1569) def replacement4558(C, m, f, b, d, a, n, A, x, e): rubi.append(4558) return Dist(S(1)/(m + n + S(1)), Int((d/sin(e + f*x))**n*(a + b/sin(e + f*x))**(m + S(-1))*Simp(A*a*(m + n + S(1)) + C*a*m/sin(e + f*x)**S(2) + C*a*n + b*(A*(m + n + S(1)) + C*(m + n))/sin(e + f*x), x), x), x) - Simp(C*(d/sin(e + f*x))**n*(a + b/sin(e + f*x))**m/(f*(m + n + S(1))*tan(e + f*x)), x) rule4558 = ReplacementRule(pattern4558, replacement4558) pattern4559 = Pattern(Integral((WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('A', S(0)) + WC('B', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))) + WC('C', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0)))**S(2)), x_), cons2, cons3, cons27, cons48, cons125, cons34, cons35, cons36, cons1267, cons93, cons94, cons88) def replacement4559(B, C, e, m, f, b, d, a, n, x, A): rubi.append(4559) return Dist(d/(b*(a**S(2) - b**S(2))*(m + S(1))), Int((d/cos(e + f*x))**(n + S(-1))*(a + b/cos(e + f*x))**(m + S(1))*Simp(A*b**S(2)*(n + S(-1)) - a*(n + S(-1))*(B*b - C*a) + b*(m + S(1))*(A*a - B*b + C*a)/cos(e + f*x) - (C*(a**S(2)*n + b**S(2)*(m + S(1))) + b*(A*b - B*a)*(m + n + S(1)))/cos(e + f*x)**S(2), x), x), x) + Simp(d*(d/cos(e + f*x))**(n + S(-1))*(a + b/cos(e + f*x))**(m + S(1))*(A*b**S(2) - B*a*b + C*a**S(2))*tan(e + f*x)/(b*f*(a**S(2) - b**S(2))*(m + S(1))), x) rule4559 = ReplacementRule(pattern4559, replacement4559) pattern4560 = Pattern(Integral((WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('A', S(0)) + WC('B', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))) + WC('C', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0)))**S(2)), x_), cons2, cons3, cons27, cons48, cons125, cons34, cons35, cons36, cons1267, cons93, cons94, cons88) def replacement4560(B, C, m, f, b, d, a, n, A, x, e): rubi.append(4560) return Dist(d/(b*(a**S(2) - b**S(2))*(m + S(1))), Int((d/sin(e + f*x))**(n + S(-1))*(a + b/sin(e + f*x))**(m + S(1))*Simp(A*b**S(2)*(n + S(-1)) - a*(n + S(-1))*(B*b - C*a) + b*(m + S(1))*(A*a - B*b + C*a)/sin(e + f*x) - (C*(a**S(2)*n + b**S(2)*(m + S(1))) + b*(A*b - B*a)*(m + n + S(1)))/sin(e + f*x)**S(2), x), x), x) - Simp(d*(d/sin(e + f*x))**(n + S(-1))*(a + b/sin(e + f*x))**(m + S(1))*(A*b**S(2) - B*a*b + C*a**S(2))/(b*f*(a**S(2) - b**S(2))*(m + S(1))*tan(e + f*x)), x) rule4560 = ReplacementRule(pattern4560, replacement4560) pattern4561 = Pattern(Integral((WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('A', S(0)) + WC('C', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0)))**S(2)), x_), cons2, cons3, cons27, cons48, cons125, cons34, cons36, cons1267, cons93, cons94, cons88) def replacement4561(C, e, m, f, b, d, a, n, x, A): rubi.append(4561) return Dist(d/(b*(a**S(2) - b**S(2))*(m + S(1))), Int((d/cos(e + f*x))**(n + S(-1))*(a + b/cos(e + f*x))**(m + S(1))*Simp(A*b**S(2)*(n + S(-1)) + C*a**S(2)*(n + S(-1)) + a*b*(A + C)*(m + S(1))/cos(e + f*x) - (A*b**S(2)*(m + n + S(1)) + C*(a**S(2)*n + b**S(2)*(m + S(1))))/cos(e + f*x)**S(2), x), x), x) + Simp(d*(d/cos(e + f*x))**(n + S(-1))*(a + b/cos(e + f*x))**(m + S(1))*(A*b**S(2) + C*a**S(2))*tan(e + f*x)/(b*f*(a**S(2) - b**S(2))*(m + S(1))), x) rule4561 = ReplacementRule(pattern4561, replacement4561) pattern4562 = Pattern(Integral((WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('A', S(0)) + WC('C', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0)))**S(2)), x_), cons2, cons3, cons27, cons48, cons125, cons34, cons36, cons1267, cons93, cons94, cons88) def replacement4562(C, m, f, b, d, a, n, A, x, e): rubi.append(4562) return Dist(d/(b*(a**S(2) - b**S(2))*(m + S(1))), Int((d/sin(e + f*x))**(n + S(-1))*(a + b/sin(e + f*x))**(m + S(1))*Simp(A*b**S(2)*(n + S(-1)) + C*a**S(2)*(n + S(-1)) + a*b*(A + C)*(m + S(1))/sin(e + f*x) - (A*b**S(2)*(m + n + S(1)) + C*(a**S(2)*n + b**S(2)*(m + S(1))))/sin(e + f*x)**S(2), x), x), x) - Simp(d*(d/sin(e + f*x))**(n + S(-1))*(a + b/sin(e + f*x))**(m + S(1))*(A*b**S(2) + C*a**S(2))/(b*f*(a**S(2) - b**S(2))*(m + S(1))*tan(e + f*x)), x) rule4562 = ReplacementRule(pattern4562, replacement4562) pattern4563 = Pattern(Integral((WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('A', S(0)) + WC('B', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))) + WC('C', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0)))**S(2)), x_), cons2, cons3, cons27, cons48, cons125, cons34, cons35, cons36, cons4, cons1267, cons31, cons94, cons1631) def replacement4563(B, C, e, m, f, b, d, a, n, x, A): rubi.append(4563) return Dist(S(1)/(a*(a**S(2) - b**S(2))*(m + S(1))), Int((d/cos(e + f*x))**n*(a + b/cos(e + f*x))**(m + S(1))*Simp(a*(m + S(1))*(A*a - B*b + C*a) - a*(m + S(1))*(A*b - B*a + C*b)/cos(e + f*x) - (m + n + S(1))*(A*b**S(2) - B*a*b + C*a**S(2)) + (m + n + S(2))*(A*b**S(2) - B*a*b + C*a**S(2))/cos(e + f*x)**S(2), x), x), x) - Simp((d/cos(e + f*x))**n*(a + b/cos(e + f*x))**(m + S(1))*(A*b**S(2) - B*a*b + C*a**S(2))*tan(e + f*x)/(a*f*(a**S(2) - b**S(2))*(m + S(1))), x) rule4563 = ReplacementRule(pattern4563, replacement4563) pattern4564 = Pattern(Integral((WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('A', S(0)) + WC('B', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))) + WC('C', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0)))**S(2)), x_), cons2, cons3, cons27, cons48, cons125, cons34, cons35, cons36, cons4, cons1267, cons31, cons94, cons1631) def replacement4564(B, C, m, f, b, d, a, n, A, x, e): rubi.append(4564) return Dist(S(1)/(a*(a**S(2) - b**S(2))*(m + S(1))), Int((d/sin(e + f*x))**n*(a + b/sin(e + f*x))**(m + S(1))*Simp(a*(m + S(1))*(A*a - B*b + C*a) - a*(m + S(1))*(A*b - B*a + C*b)/sin(e + f*x) - (m + n + S(1))*(A*b**S(2) - B*a*b + C*a**S(2)) + (m + n + S(2))*(A*b**S(2) - B*a*b + C*a**S(2))/sin(e + f*x)**S(2), x), x), x) + Simp((d/sin(e + f*x))**n*(a + b/sin(e + f*x))**(m + S(1))*(A*b**S(2) - B*a*b + C*a**S(2))/(a*f*(a**S(2) - b**S(2))*(m + S(1))*tan(e + f*x)), x) rule4564 = ReplacementRule(pattern4564, replacement4564) pattern4565 = Pattern(Integral((WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('A', S(0)) + WC('C', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0)))**S(2)), x_), cons2, cons3, cons27, cons48, cons125, cons34, cons36, cons4, cons1267, cons31, cons94, cons1631) def replacement4565(C, e, m, f, b, d, a, n, x, A): rubi.append(4565) return Dist(S(1)/(a*(a**S(2) - b**S(2))*(m + S(1))), Int((d/cos(e + f*x))**n*(a + b/cos(e + f*x))**(m + S(1))*Simp(a**S(2)*(A + C)*(m + S(1)) - a*b*(A + C)*(m + S(1))/cos(e + f*x) - (A*b**S(2) + C*a**S(2))*(m + n + S(1)) + (A*b**S(2) + C*a**S(2))*(m + n + S(2))/cos(e + f*x)**S(2), x), x), x) - Simp((d/cos(e + f*x))**n*(a + b/cos(e + f*x))**(m + S(1))*(A*b**S(2) + C*a**S(2))*tan(e + f*x)/(a*f*(a**S(2) - b**S(2))*(m + S(1))), x) rule4565 = ReplacementRule(pattern4565, replacement4565) pattern4566 = Pattern(Integral((WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('A', S(0)) + WC('C', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0)))**S(2)), x_), cons2, cons3, cons27, cons48, cons125, cons34, cons36, cons4, cons1267, cons31, cons94, cons1631) def replacement4566(C, m, f, b, d, a, n, A, x, e): rubi.append(4566) return Dist(S(1)/(a*(a**S(2) - b**S(2))*(m + S(1))), Int((d/sin(e + f*x))**n*(a + b/sin(e + f*x))**(m + S(1))*Simp(a**S(2)*(A + C)*(m + S(1)) - a*b*(A + C)*(m + S(1))/sin(e + f*x) - (A*b**S(2) + C*a**S(2))*(m + n + S(1)) + (A*b**S(2) + C*a**S(2))*(m + n + S(2))/sin(e + f*x)**S(2), x), x), x) + Simp((d/sin(e + f*x))**n*(a + b/sin(e + f*x))**(m + S(1))*(A*b**S(2) + C*a**S(2))/(a*f*(a**S(2) - b**S(2))*(m + S(1))*tan(e + f*x)), x) rule4566 = ReplacementRule(pattern4566, replacement4566) pattern4567 = Pattern(Integral((WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('A', S(0)) + WC('B', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))) + WC('C', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0)))**S(2)), x_), cons2, cons3, cons27, cons48, cons125, cons34, cons35, cons36, cons21, cons1267, cons87, cons88) def replacement4567(B, C, e, m, f, b, d, a, n, x, A): rubi.append(4567) return Dist(d/(b*(m + n + S(1))), Int((d/cos(e + f*x))**(n + S(-1))*(a + b/cos(e + f*x))**m*Simp(C*a*(n + S(-1)) + (A*b*(m + n + S(1)) + C*b*(m + n))/cos(e + f*x) + (B*b*(m + n + S(1)) - C*a*n)/cos(e + f*x)**S(2), x), x), x) + Simp(C*d*(d/cos(e + f*x))**(n + S(-1))*(a + b/cos(e + f*x))**(m + S(1))*tan(e + f*x)/(b*f*(m + n + S(1))), x) rule4567 = ReplacementRule(pattern4567, replacement4567) pattern4568 = Pattern(Integral((WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('A', S(0)) + WC('B', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))) + WC('C', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0)))**S(2)), x_), cons2, cons3, cons27, cons48, cons125, cons34, cons35, cons36, cons21, cons1267, cons87, cons88) def replacement4568(B, C, m, f, b, d, a, n, A, x, e): rubi.append(4568) return Dist(d/(b*(m + n + S(1))), Int((d/sin(e + f*x))**(n + S(-1))*(a + b/sin(e + f*x))**m*Simp(C*a*(n + S(-1)) + (A*b*(m + n + S(1)) + C*b*(m + n))/sin(e + f*x) + (B*b*(m + n + S(1)) - C*a*n)/sin(e + f*x)**S(2), x), x), x) - Simp(C*d*(d/sin(e + f*x))**(n + S(-1))*(a + b/sin(e + f*x))**(m + S(1))/(b*f*(m + n + S(1))*tan(e + f*x)), x) rule4568 = ReplacementRule(pattern4568, replacement4568) pattern4569 = Pattern(Integral((WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('A', S(0)) + WC('C', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0)))**S(2)), x_), cons2, cons3, cons27, cons48, cons125, cons34, cons36, cons21, cons1267, cons87, cons88) def replacement4569(C, e, m, f, b, d, a, n, x, A): rubi.append(4569) return Dist(d/(b*(m + n + S(1))), Int((d/cos(e + f*x))**(n + S(-1))*(a + b/cos(e + f*x))**m*Simp(-C*a*n/cos(e + f*x)**S(2) + C*a*(n + S(-1)) + (A*b*(m + n + S(1)) + C*b*(m + n))/cos(e + f*x), x), x), x) + Simp(C*d*(d/cos(e + f*x))**(n + S(-1))*(a + b/cos(e + f*x))**(m + S(1))*tan(e + f*x)/(b*f*(m + n + S(1))), x) rule4569 = ReplacementRule(pattern4569, replacement4569) pattern4570 = Pattern(Integral((WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('A', S(0)) + WC('C', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0)))**S(2)), x_), cons2, cons3, cons27, cons48, cons125, cons34, cons36, cons21, cons1267, cons87, cons88) def replacement4570(C, m, f, b, d, a, n, A, x, e): rubi.append(4570) return Dist(d/(b*(m + n + S(1))), Int((d/sin(e + f*x))**(n + S(-1))*(a + b/sin(e + f*x))**m*Simp(-C*a*n/sin(e + f*x)**S(2) + C*a*(n + S(-1)) + (A*b*(m + n + S(1)) + C*b*(m + n))/sin(e + f*x), x), x), x) - Simp(C*d*(d/sin(e + f*x))**(n + S(-1))*(a + b/sin(e + f*x))**(m + S(1))/(b*f*(m + n + S(1))*tan(e + f*x)), x) rule4570 = ReplacementRule(pattern4570, replacement4570) pattern4571 = Pattern(Integral((WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('A', S(0)) + WC('B', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))) + WC('C', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0)))**S(2)), x_), cons2, cons3, cons27, cons48, cons125, cons34, cons35, cons36, cons21, cons1267, cons87, cons1586) def replacement4571(B, C, e, m, f, b, d, a, n, x, A): rubi.append(4571) return Dist(S(1)/(a*d*n), Int((d/cos(e + f*x))**(n + S(1))*(a + b/cos(e + f*x))**m*Simp(-A*b*(m + n + S(1)) + A*b*(m + n + S(2))/cos(e + f*x)**S(2) + B*a*n + a*(A*n + A + C*n)/cos(e + f*x), x), x), x) - Simp(A*(d/cos(e + f*x))**n*(a + b/cos(e + f*x))**(m + S(1))*tan(e + f*x)/(a*f*n), x) rule4571 = ReplacementRule(pattern4571, replacement4571) pattern4572 = Pattern(Integral((WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('A', S(0)) + WC('B', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))) + WC('C', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0)))**S(2)), x_), cons2, cons3, cons27, cons48, cons125, cons34, cons35, cons36, cons21, cons1267, cons87, cons1586) def replacement4572(B, C, m, f, b, d, a, n, A, x, e): rubi.append(4572) return Dist(S(1)/(a*d*n), Int((d/sin(e + f*x))**(n + S(1))*(a + b/sin(e + f*x))**m*Simp(-A*b*(m + n + S(1)) + A*b*(m + n + S(2))/sin(e + f*x)**S(2) + B*a*n + a*(A*n + A + C*n)/sin(e + f*x), x), x), x) + Simp(A*(d/sin(e + f*x))**n*(a + b/sin(e + f*x))**(m + S(1))/(a*f*n*tan(e + f*x)), x) rule4572 = ReplacementRule(pattern4572, replacement4572) pattern4573 = Pattern(Integral((WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('A', S(0)) + WC('C', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0)))**S(2)), x_), cons2, cons3, cons27, cons48, cons125, cons34, cons36, cons21, cons1267, cons87, cons1586) def replacement4573(C, e, m, f, b, d, a, n, x, A): rubi.append(4573) return Dist(S(1)/(a*d*n), Int((d/cos(e + f*x))**(n + S(1))*(a + b/cos(e + f*x))**m*Simp(-A*b*(m + n + S(1)) + A*b*(m + n + S(2))/cos(e + f*x)**S(2) + a*(A*n + A + C*n)/cos(e + f*x), x), x), x) - Simp(A*(d/cos(e + f*x))**n*(a + b/cos(e + f*x))**(m + S(1))*tan(e + f*x)/(a*f*n), x) rule4573 = ReplacementRule(pattern4573, replacement4573) pattern4574 = Pattern(Integral((WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('A', S(0)) + WC('C', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0)))**S(2)), x_), cons2, cons3, cons27, cons48, cons125, cons34, cons36, cons21, cons1267, cons87, cons1586) def replacement4574(C, m, f, b, d, a, n, A, x, e): rubi.append(4574) return Dist(S(1)/(a*d*n), Int((d/sin(e + f*x))**(n + S(1))*(a + b/sin(e + f*x))**m*Simp(-A*b*(m + n + S(1)) + A*b*(m + n + S(2))/sin(e + f*x)**S(2) + a*(A*n + A + C*n)/sin(e + f*x), x), x), x) + Simp(A*(d/sin(e + f*x))**n*(a + b/sin(e + f*x))**(m + S(1))/(a*f*n*tan(e + f*x)), x) rule4574 = ReplacementRule(pattern4574, replacement4574) pattern4575 = Pattern(Integral((WC('A', S(0)) + WC('B', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))) + WC('C', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0)))**S(2))/(sqrt(WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))*(a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))), x_), cons2, cons3, cons27, cons48, cons125, cons34, cons35, cons36, cons1267) def replacement4575(B, C, e, f, b, d, a, x, A): rubi.append(4575) return Dist(a**(S(-2)), Int((A*a - (A*b - B*a)/cos(e + f*x))/sqrt(d/cos(e + f*x)), x), x) + Dist((A*b**S(2) - B*a*b + C*a**S(2))/(a**S(2)*d**S(2)), Int((d/cos(e + f*x))**(S(3)/2)/(a + b/cos(e + f*x)), x), x) rule4575 = ReplacementRule(pattern4575, replacement4575) pattern4576 = Pattern(Integral((WC('A', S(0)) + WC('B', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))) + WC('C', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0)))**S(2))/(sqrt(WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))*(a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))), x_), cons2, cons3, cons27, cons48, cons125, cons34, cons35, cons36, cons1267) def replacement4576(B, C, f, b, d, a, A, x, e): rubi.append(4576) return Dist(a**(S(-2)), Int((A*a - (A*b - B*a)/sin(e + f*x))/sqrt(d/sin(e + f*x)), x), x) + Dist((A*b**S(2) - B*a*b + C*a**S(2))/(a**S(2)*d**S(2)), Int((d/sin(e + f*x))**(S(3)/2)/(a + b/sin(e + f*x)), x), x) rule4576 = ReplacementRule(pattern4576, replacement4576) pattern4577 = Pattern(Integral((WC('A', S(0)) + WC('C', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0)))**S(2))/(sqrt(WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))*(a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))), x_), cons2, cons3, cons27, cons48, cons125, cons34, cons36, cons1267) def replacement4577(C, e, f, b, d, a, x, A): rubi.append(4577) return Dist(a**(S(-2)), Int((A*a - A*b/cos(e + f*x))/sqrt(d/cos(e + f*x)), x), x) + Dist((A*b**S(2) + C*a**S(2))/(a**S(2)*d**S(2)), Int((d/cos(e + f*x))**(S(3)/2)/(a + b/cos(e + f*x)), x), x) rule4577 = ReplacementRule(pattern4577, replacement4577) pattern4578 = Pattern(Integral((WC('A', S(0)) + WC('C', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0)))**S(2))/(sqrt(WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))*(a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))), x_), cons2, cons3, cons27, cons48, cons125, cons34, cons36, cons1267) def replacement4578(C, f, b, d, a, A, x, e): rubi.append(4578) return Dist(a**(S(-2)), Int((A*a - A*b/sin(e + f*x))/sqrt(d/sin(e + f*x)), x), x) + Dist((A*b**S(2) + C*a**S(2))/(a**S(2)*d**S(2)), Int((d/sin(e + f*x))**(S(3)/2)/(a + b/sin(e + f*x)), x), x) rule4578 = ReplacementRule(pattern4578, replacement4578) pattern4579 = Pattern(Integral((WC('A', S(0)) + WC('B', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))) + WC('C', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0)))**S(2))/(sqrt(WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))*sqrt(a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))), x_), cons2, cons3, cons27, cons48, cons125, cons34, cons35, cons36, cons1267) def replacement4579(B, C, e, f, b, d, a, x, A): rubi.append(4579) return Dist(C/d**S(2), Int((d/cos(e + f*x))**(S(3)/2)/sqrt(a + b/cos(e + f*x)), x), x) + Int((A + B/cos(e + f*x))/(sqrt(d/cos(e + f*x))*sqrt(a + b/cos(e + f*x))), x) rule4579 = ReplacementRule(pattern4579, replacement4579) pattern4580 = Pattern(Integral((WC('A', S(0)) + WC('B', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))) + WC('C', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0)))**S(2))/(sqrt(WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))*sqrt(a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))), x_), cons2, cons3, cons27, cons48, cons125, cons34, cons35, cons36, cons1267) def replacement4580(B, C, f, b, d, a, A, x, e): rubi.append(4580) return Dist(C/d**S(2), Int((d/sin(e + f*x))**(S(3)/2)/sqrt(a + b/sin(e + f*x)), x), x) + Int((A + B/sin(e + f*x))/(sqrt(d/sin(e + f*x))*sqrt(a + b/sin(e + f*x))), x) rule4580 = ReplacementRule(pattern4580, replacement4580) pattern4581 = Pattern(Integral((WC('A', S(0)) + WC('C', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0)))**S(2))/(sqrt(WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))*sqrt(a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))), x_), cons2, cons3, cons27, cons48, cons125, cons34, cons36, cons1267) def replacement4581(C, e, f, b, d, a, x, A): rubi.append(4581) return Dist(A, Int(S(1)/(sqrt(d/cos(e + f*x))*sqrt(a + b/cos(e + f*x))), x), x) + Dist(C/d**S(2), Int((d/cos(e + f*x))**(S(3)/2)/sqrt(a + b/cos(e + f*x)), x), x) rule4581 = ReplacementRule(pattern4581, replacement4581) pattern4582 = Pattern(Integral((WC('A', S(0)) + WC('C', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0)))**S(2))/(sqrt(WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))*sqrt(a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))), x_), cons2, cons3, cons27, cons48, cons125, cons34, cons36, cons1267) def replacement4582(C, f, b, d, a, A, x, e): rubi.append(4582) return Dist(A, Int(S(1)/(sqrt(d/sin(e + f*x))*sqrt(a + b/sin(e + f*x))), x), x) + Dist(C/d**S(2), Int((d/sin(e + f*x))**(S(3)/2)/sqrt(a + b/sin(e + f*x)), x), x) rule4582 = ReplacementRule(pattern4582, replacement4582) pattern4583 = Pattern(Integral((WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1))*(a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(WC('A', S(0)) + WC('B', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))) + WC('C', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0)))**S(2)), x_), cons2, cons3, cons27, cons48, cons125, cons34, cons35, cons36, cons21, cons4, cons1641) def replacement4583(B, C, m, f, b, d, a, n, A, x, e): rubi.append(4583) return Int((d/cos(e + f*x))**n*(a + b/cos(e + f*x))**m*(A + B/cos(e + f*x) + C/cos(e + f*x)**S(2)), x) rule4583 = ReplacementRule(pattern4583, replacement4583) pattern4584 = Pattern(Integral((WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1))*(a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(WC('A', S(0)) + WC('B', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))) + WC('C', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0)))**S(2)), x_), cons2, cons3, cons27, cons48, cons125, cons34, cons35, cons36, cons21, cons4, cons1641) def replacement4584(B, C, m, f, b, d, a, n, A, x, e): rubi.append(4584) return Int((d/sin(e + f*x))**n*(a + b/sin(e + f*x))**m*(A + B/sin(e + f*x) + C/sin(e + f*x)**S(2)), x) rule4584 = ReplacementRule(pattern4584, replacement4584) pattern4585 = Pattern(Integral((WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1))*(a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(WC('A', S(0)) + WC('C', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0)))**S(2)), x_), cons2, cons3, cons27, cons48, cons125, cons34, cons36, cons21, cons4, cons1642) def replacement4585(C, m, f, b, d, a, n, A, x, e): rubi.append(4585) return Int((d/cos(e + f*x))**n*(A + C/cos(e + f*x)**S(2))*(a + b/cos(e + f*x))**m, x) rule4585 = ReplacementRule(pattern4585, replacement4585) pattern4586 = Pattern(Integral((WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1))*(a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(WC('A', S(0)) + WC('C', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0)))**S(2)), x_), cons2, cons3, cons27, cons48, cons125, cons34, cons36, cons21, cons4, cons1642) def replacement4586(C, m, f, b, d, a, n, A, x, e): rubi.append(4586) return Int((d/sin(e + f*x))**n*(A + C/sin(e + f*x)**S(2))*(a + b/sin(e + f*x))**m, x) rule4586 = ReplacementRule(pattern4586, replacement4586) pattern4587 = Pattern(Integral((WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(WC('A', S(0)) + WC('B', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))) + WC('C', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0)))**S(2)), x_), cons2, cons3, cons27, cons48, cons125, cons34, cons35, cons36, cons4, cons23, cons17) def replacement4587(B, C, m, f, b, d, a, n, A, x, e): rubi.append(4587) return Dist(d**(m + S(2)), Int((d*cos(e + f*x))**(-m + n + S(-2))*(a*cos(e + f*x) + b)**m*(A*cos(e + f*x)**S(2) + B*cos(e + f*x) + C), x), x) rule4587 = ReplacementRule(pattern4587, replacement4587) pattern4588 = Pattern(Integral((WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(WC('A', S(0)) + WC('B', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))) + WC('C', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0)))**S(2)), x_), cons2, cons3, cons27, cons48, cons125, cons34, cons35, cons36, cons4, cons23, cons17) def replacement4588(B, C, m, f, b, d, a, n, A, x, e): rubi.append(4588) return Dist(d**(m + S(2)), Int((d*sin(e + f*x))**(-m + n + S(-2))*(a*sin(e + f*x) + b)**m*(A*sin(e + f*x)**S(2) + B*sin(e + f*x) + C), x), x) rule4588 = ReplacementRule(pattern4588, replacement4588) pattern4589 = Pattern(Integral((WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(WC('A', S(0)) + WC('C', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0)))**S(2)), x_), cons2, cons3, cons27, cons48, cons125, cons34, cons36, cons4, cons23, cons17) def replacement4589(C, m, f, b, d, a, n, A, x, e): rubi.append(4589) return Dist(d**(m + S(2)), Int((d*cos(e + f*x))**(-m + n + S(-2))*(A*cos(e + f*x)**S(2) + C)*(a*cos(e + f*x) + b)**m, x), x) rule4589 = ReplacementRule(pattern4589, replacement4589) pattern4590 = Pattern(Integral((WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(WC('A', S(0)) + WC('C', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0)))**S(2)), x_), cons2, cons3, cons27, cons48, cons125, cons34, cons36, cons4, cons23, cons17) def replacement4590(C, m, f, b, d, a, n, A, x, e): rubi.append(4590) return Dist(d**(m + S(2)), Int((d*sin(e + f*x))**(-m + n + S(-2))*(A*sin(e + f*x)**S(2) + C)*(a*sin(e + f*x) + b)**m, x), x) rule4590 = ReplacementRule(pattern4590, replacement4590) pattern4591 = Pattern(Integral(((WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**p_*WC('c', S(1)))**n_*(a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(WC('A', S(0)) + WC('B', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))) + WC('C', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0)))**S(2)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons36, cons21, cons4, cons5, cons23) def replacement4591(B, C, p, m, f, b, d, c, n, a, A, x, e): rubi.append(4591) return Dist(c**IntPart(n)*(c*(d/cos(e + f*x))**p)**FracPart(n)*(d/cos(e + f*x))**(-p*FracPart(n)), Int((d/cos(e + f*x))**(n*p)*(a + b/cos(e + f*x))**m*(A + B/cos(e + f*x) + C/cos(e + f*x)**S(2)), x), x) rule4591 = ReplacementRule(pattern4591, replacement4591) pattern4592 = Pattern(Integral(((WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**p_*WC('c', S(1)))**n_*(a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(WC('A', S(0)) + WC('B', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))) + WC('C', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0)))**S(2)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons36, cons21, cons4, cons5, cons23) def replacement4592(B, C, p, m, f, b, d, c, n, a, A, x, e): rubi.append(4592) return Dist(c**IntPart(n)*(c*(d/sin(e + f*x))**p)**FracPart(n)*(d/sin(e + f*x))**(-p*FracPart(n)), Int((d/sin(e + f*x))**(n*p)*(a + b/sin(e + f*x))**m*(A + B/sin(e + f*x) + C/sin(e + f*x)**S(2)), x), x) rule4592 = ReplacementRule(pattern4592, replacement4592) pattern4593 = Pattern(Integral(((WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**p_*WC('c', S(1)))**n_*(a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(WC('A', S(0)) + WC('C', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0)))**S(2)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons36, cons21, cons4, cons5, cons23) def replacement4593(C, p, m, f, b, d, c, n, a, A, x, e): rubi.append(4593) return Dist(c**IntPart(n)*(c*(d/cos(e + f*x))**p)**FracPart(n)*(d/cos(e + f*x))**(-p*FracPart(n)), Int((d/cos(e + f*x))**(n*p)*(A + C/cos(e + f*x)**S(2))*(a + b/cos(e + f*x))**m, x), x) rule4593 = ReplacementRule(pattern4593, replacement4593) pattern4594 = Pattern(Integral(((WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**p_*WC('c', S(1)))**n_*(a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(WC('A', S(0)) + WC('C', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0)))**S(2)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons36, cons21, cons4, cons5, cons23) def replacement4594(C, p, m, f, b, d, c, n, a, A, x, e): rubi.append(4594) return Dist(c**IntPart(n)*(c*(d/sin(e + f*x))**p)**FracPart(n)*(d/sin(e + f*x))**(-p*FracPart(n)), Int((d/sin(e + f*x))**(n*p)*(A + C/sin(e + f*x)**S(2))*(a + b/sin(e + f*x))**m, x), x) rule4594 = ReplacementRule(pattern4594, replacement4594) pattern4595 = Pattern(Integral((WC('b', S(1))/cos(x_*WC('d', S(1)) + WC('c', S(0)))**S(2))**n_, x_), cons3, cons7, cons27, cons4, cons1643) def replacement4595(b, d, c, n, x): rubi.append(4595) return Dist(b/d, Subst(Int((b*x**S(2) + b)**(n + S(-1)), x), x, tan(c + d*x)), x) rule4595 = ReplacementRule(pattern4595, replacement4595) pattern4596 = Pattern(Integral((WC('b', S(1))/sin(x_*WC('d', S(1)) + WC('c', S(0)))**S(2))**n_, x_), cons3, cons7, cons27, cons4, cons1643) def replacement4596(b, d, c, n, x): rubi.append(4596) return -Dist(b/d, Subst(Int((b*x**S(2) + b)**(n + S(-1)), x), x, S(1)/tan(c + d*x)), x) rule4596 = ReplacementRule(pattern4596, replacement4596) pattern4597 = Pattern(Integral((a_ + WC('b', S(1))/cos(x_*WC('d', S(1)) + WC('c', S(0)))**S(2))**p_, x_), cons2, cons3, cons7, cons27, cons5, cons1454) def replacement4597(p, b, d, c, a, x): rubi.append(4597) return Int((-a*tan(c + d*x)**S(2))**p, x) rule4597 = ReplacementRule(pattern4597, replacement4597) pattern4598 = Pattern(Integral((a_ + WC('b', S(1))/sin(x_*WC('d', S(1)) + WC('c', S(0)))**S(2))**p_, x_), cons2, cons3, cons7, cons27, cons5, cons1454) def replacement4598(p, b, d, c, a, x): rubi.append(4598) return Int((-a/tan(c + d*x)**S(2))**p, x) rule4598 = ReplacementRule(pattern4598, replacement4598) pattern4599 = Pattern(Integral(S(1)/(a_ + WC('b', S(1))/cos(x_*WC('d', S(1)) + WC('c', S(0)))**S(2)), x_), cons2, cons3, cons7, cons27, cons1478) def replacement4599(b, d, c, a, x): rubi.append(4599) return -Dist(b/a, Int(S(1)/(a*cos(c + d*x)**S(2) + b), x), x) + Simp(x/a, x) rule4599 = ReplacementRule(pattern4599, replacement4599) pattern4600 = Pattern(Integral(S(1)/(a_ + WC('b', S(1))/sin(x_*WC('d', S(1)) + WC('c', S(0)))**S(2)), x_), cons2, cons3, cons7, cons27, cons1478) def replacement4600(b, d, c, a, x): rubi.append(4600) return -Dist(b/a, Int(S(1)/(a*sin(c + d*x)**S(2) + b), x), x) + Simp(x/a, x) rule4600 = ReplacementRule(pattern4600, replacement4600) pattern4601 = Pattern(Integral((a_ + WC('b', S(1))/cos(x_*WC('d', S(1)) + WC('c', S(0)))**S(2))**p_, x_), cons2, cons3, cons7, cons27, cons5, cons1478, cons54) def replacement4601(p, b, d, c, a, x): rubi.append(4601) return Dist(S(1)/d, Subst(Int((a + b*x**S(2) + b)**p/(x**S(2) + S(1)), x), x, tan(c + d*x)), x) rule4601 = ReplacementRule(pattern4601, replacement4601) pattern4602 = Pattern(Integral((a_ + WC('b', S(1))/sin(x_*WC('d', S(1)) + WC('c', S(0)))**S(2))**p_, x_), cons2, cons3, cons7, cons27, cons5, cons1478, cons54) def replacement4602(p, b, d, c, a, x): rubi.append(4602) return -Dist(S(1)/d, Subst(Int((a + b*x**S(2) + b)**p/(x**S(2) + S(1)), x), x, S(1)/tan(c + d*x)), x) rule4602 = ReplacementRule(pattern4602, replacement4602) def With4603(p, m, b, d, c, a, n, x): f = FreeFactors(tan(c + d*x), x) rubi.append(4603) return Dist(f**(m + S(1))/d, Subst(Int(x**m*(f**S(2)*x**S(2) + S(1))**(-m/S(2) + S(-1))*ExpandToSum(a + b*(f**S(2)*x**S(2) + S(1))**(n/S(2)), x)**p, x), x, tan(c + d*x)/f), x) pattern4603 = Pattern(Integral((a_ + (S(1)/cos(x_*WC('d', S(1)) + WC('c', S(0))))**n_*WC('b', S(1)))**p_*sin(x_*WC('d', S(1)) + WC('c', S(0)))**m_, x_), cons2, cons3, cons7, cons27, cons5, cons1480, cons1479) rule4603 = ReplacementRule(pattern4603, With4603) def With4604(p, m, b, d, c, n, a, x): f = FreeFactors(S(1)/tan(c + d*x), x) rubi.append(4604) return -Dist(f**(m + S(1))/d, Subst(Int(x**m*(f**S(2)*x**S(2) + S(1))**(-m/S(2) + S(-1))*ExpandToSum(a + b*(f**S(2)*x**S(2) + S(1))**(n/S(2)), x)**p, x), x, S(1)/(f*tan(c + d*x))), x) pattern4604 = Pattern(Integral((a_ + (S(1)/sin(x_*WC('d', S(1)) + WC('c', S(0))))**n_*WC('b', S(1)))**p_*cos(x_*WC('d', S(1)) + WC('c', S(0)))**m_, x_), cons2, cons3, cons7, cons27, cons5, cons1480, cons1479) rule4604 = ReplacementRule(pattern4604, With4604) def With4605(p, m, b, d, c, a, n, x): f = FreeFactors(cos(c + d*x), x) rubi.append(4605) return -Dist(f/d, Subst(Int((f*x)**(-n*p)*(a*(f*x)**n + b)**p*(-f**S(2)*x**S(2) + S(1))**(m/S(2) + S(-1)/2), x), x, cos(c + d*x)/f), x) pattern4605 = Pattern(Integral((a_ + (S(1)/cos(x_*WC('d', S(1)) + WC('c', S(0))))**n_*WC('b', S(1)))**WC('p', S(1))*sin(x_*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1)), x_), cons2, cons3, cons7, cons27, cons1481, cons376) rule4605 = ReplacementRule(pattern4605, With4605) def With4606(p, m, b, d, c, n, a, x): f = FreeFactors(sin(c + d*x), x) rubi.append(4606) return Dist(f/d, Subst(Int((f*x)**(-n*p)*(a*(f*x)**n + b)**p*(-f**S(2)*x**S(2) + S(1))**(m/S(2) + S(-1)/2), x), x, sin(c + d*x)/f), x) pattern4606 = Pattern(Integral((a_ + (S(1)/sin(x_*WC('d', S(1)) + WC('c', S(0))))**n_*WC('b', S(1)))**WC('p', S(1))*cos(x_*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1)), x_), cons2, cons3, cons7, cons27, cons1481, cons376) rule4606 = ReplacementRule(pattern4606, With4606) def With4607(p, m, b, d, c, a, n, x): f = FreeFactors(tan(c + d*x), x) rubi.append(4607) return Dist(f/d, Subst(Int((f**S(2)*x**S(2) + S(1))**(m/S(2) + S(-1))*ExpandToSum(a + b*(f**S(2)*x**S(2) + S(1))**(n/S(2)), x)**p, x), x, tan(c + d*x)/f), x) pattern4607 = Pattern(Integral((a_ + (S(1)/cos(x_*WC('d', S(1)) + WC('c', S(0))))**n_*WC('b', S(1)))**p_*(S(1)/cos(x_*WC('d', S(1)) + WC('c', S(0))))**m_, x_), cons2, cons3, cons7, cons27, cons5, cons1480, cons1479) rule4607 = ReplacementRule(pattern4607, With4607) def With4608(p, m, b, d, c, n, a, x): f = FreeFactors(S(1)/tan(c + d*x), x) rubi.append(4608) return -Dist(f/d, Subst(Int((f**S(2)*x**S(2) + S(1))**(m/S(2) + S(-1))*ExpandToSum(a + b*(f**S(2)*x**S(2) + S(1))**(n/S(2)), x)**p, x), x, S(1)/(f*tan(c + d*x))), x) pattern4608 = Pattern(Integral((a_ + (S(1)/sin(x_*WC('d', S(1)) + WC('c', S(0))))**n_*WC('b', S(1)))**p_*(S(1)/sin(x_*WC('d', S(1)) + WC('c', S(0))))**m_, x_), cons2, cons3, cons7, cons27, cons5, cons1480, cons1479) rule4608 = ReplacementRule(pattern4608, With4608) def With4609(p, m, b, d, c, a, n, x): f = FreeFactors(sin(c + d*x), x) rubi.append(4609) return Dist(f/d, Subst(Int((-f**S(2)*x**S(2) + S(1))**(-m/S(2) - n*p/S(2) + S(-1)/2)*ExpandToSum(a*(-f**S(2)*x**S(2) + S(1))**(n/S(2)) + b, x)**p, x), x, sin(c + d*x)/f), x) pattern4609 = Pattern(Integral((a_ + (S(1)/cos(x_*WC('d', S(1)) + WC('c', S(0))))**n_*WC('b', S(1)))**p_*(S(1)/cos(x_*WC('d', S(1)) + WC('c', S(0))))**WC('m', S(1)), x_), cons2, cons3, cons7, cons27, cons1481, cons1479, cons38) rule4609 = ReplacementRule(pattern4609, With4609) def With4610(p, m, b, d, c, n, a, x): f = FreeFactors(cos(c + d*x), x) rubi.append(4610) return -Dist(f/d, Subst(Int((-f**S(2)*x**S(2) + S(1))**(-m/S(2) - n*p/S(2) + S(-1)/2)*ExpandToSum(a*(-f**S(2)*x**S(2) + S(1))**(n/S(2)) + b, x)**p, x), x, cos(c + d*x)/f), x) pattern4610 = Pattern(Integral((a_ + (S(1)/sin(x_*WC('d', S(1)) + WC('c', S(0))))**n_*WC('b', S(1)))**p_*(S(1)/sin(x_*WC('d', S(1)) + WC('c', S(0))))**WC('m', S(1)), x_), cons2, cons3, cons7, cons27, cons1481, cons1479, cons38) rule4610 = ReplacementRule(pattern4610, With4610) pattern4611 = Pattern(Integral((a_ + (S(1)/cos(x_*WC('d', S(1)) + WC('c', S(0))))**n_*WC('b', S(1)))**p_*(S(1)/cos(x_*WC('d', S(1)) + WC('c', S(0))))**WC('m', S(1)), x_), cons2, cons3, cons7, cons27, cons375) def replacement4611(p, m, b, d, c, a, n, x): rubi.append(4611) return Int(ExpandTrig((a + b*(S(1)/cos(c + d*x))**n)**p*(S(1)/cos(c + d*x))**m, x), x) rule4611 = ReplacementRule(pattern4611, replacement4611) pattern4612 = Pattern(Integral((a_ + (S(1)/sin(x_*WC('d', S(1)) + WC('c', S(0))))**n_*WC('b', S(1)))**p_*(S(1)/sin(x_*WC('d', S(1)) + WC('c', S(0))))**WC('m', S(1)), x_), cons2, cons3, cons7, cons27, cons375) def replacement4612(p, m, b, d, c, n, a, x): rubi.append(4612) return Int(ExpandTrig((a + b*(S(1)/sin(c + d*x))**n)**p*(S(1)/sin(c + d*x))**m, x), x) rule4612 = ReplacementRule(pattern4612, replacement4612) def With4613(p, m, b, d, c, a, n, x): f = FreeFactors(cos(c + d*x), x) rubi.append(4613) return -Dist(f**(-m - n*p + S(1))/d, Subst(Int(x**(-m - n*p)*(a*(f*x)**n + b)**p*(-f**S(2)*x**S(2) + S(1))**(m/S(2) + S(-1)/2), x), x, cos(c + d*x)/f), x) pattern4613 = Pattern(Integral((a_ + (S(1)/cos(x_*WC('d', S(1)) + WC('c', S(0))))**n_*WC('b', S(1)))**WC('p', S(1))*tan(x_*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1)), x_), cons2, cons3, cons7, cons27, cons4, cons1481, cons85, cons38) rule4613 = ReplacementRule(pattern4613, With4613) def With4614(p, m, b, d, c, n, a, x): f = FreeFactors(sin(c + d*x), x) rubi.append(4614) return Dist(f**(-m - n*p + S(1))/d, Subst(Int(x**(-m - n*p)*(a*(f*x)**n + b)**p*(-f**S(2)*x**S(2) + S(1))**(m/S(2) + S(-1)/2), x), x, sin(c + d*x)/f), x) pattern4614 = Pattern(Integral((a_ + (S(1)/sin(x_*WC('d', S(1)) + WC('c', S(0))))**n_*WC('b', S(1)))**WC('p', S(1))*(S(1)/tan(x_*WC('d', S(1)) + WC('c', S(0))))**WC('m', S(1)), x_), cons2, cons3, cons7, cons27, cons4, cons1481, cons85, cons38) rule4614 = ReplacementRule(pattern4614, With4614) def With4615(p, m, b, d, c, a, n, x): f = FreeFactors(tan(c + d*x), x) rubi.append(4615) return Dist(f**(m + S(1))/d, Subst(Int(x**m*ExpandToSum(a + b*(f**S(2)*x**S(2) + S(1))**(n/S(2)), x)**p/(f**S(2)*x**S(2) + S(1)), x), x, tan(c + d*x)/f), x) pattern4615 = Pattern(Integral((a_ + (S(1)/cos(x_*WC('d', S(1)) + WC('c', S(0))))**n_*WC('b', S(1)))**WC('p', S(1))*tan(x_*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1)), x_), cons2, cons3, cons7, cons27, cons1480, cons1479) rule4615 = ReplacementRule(pattern4615, With4615) def With4616(p, m, b, d, c, n, a, x): f = FreeFactors(S(1)/tan(c + d*x), x) rubi.append(4616) return -Dist(f**(m + S(1))/d, Subst(Int(x**m*ExpandToSum(a + b*(f**S(2)*x**S(2) + S(1))**(n/S(2)), x)**p/(f**S(2)*x**S(2) + S(1)), x), x, S(1)/(f*tan(c + d*x))), x) pattern4616 = Pattern(Integral((a_ + (S(1)/sin(x_*WC('d', S(1)) + WC('c', S(0))))**n_*WC('b', S(1)))**WC('p', S(1))*(S(1)/tan(x_*WC('d', S(1)) + WC('c', S(0))))**WC('m', S(1)), x_), cons2, cons3, cons7, cons27, cons1480, cons1479) rule4616 = ReplacementRule(pattern4616, With4616) pattern4617 = Pattern(Integral(((S(1)/cos(x_*WC('e', S(1)) + WC('d', S(0))))**WC('n', S(1))*WC('b', S(1)) + (S(1)/cos(x_*WC('e', S(1)) + WC('d', S(0))))**WC('n2', S(1))*WC('c', S(1)) + WC('a', S(0)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons4, cons46, cons45, cons38) def replacement4617(p, b, n2, d, a, n, c, x, e): rubi.append(4617) return Dist(S(4)**(-p)*c**(-p), Int((b + S(2)*c*(S(1)/cos(d + e*x))**n)**(S(2)*p), x), x) rule4617 = ReplacementRule(pattern4617, replacement4617) pattern4618 = Pattern(Integral(((S(1)/sin(x_*WC('e', S(1)) + WC('d', S(0))))**WC('n', S(1))*WC('b', S(1)) + (S(1)/sin(x_*WC('e', S(1)) + WC('d', S(0))))**WC('n2', S(1))*WC('c', S(1)) + WC('a', S(0)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons4, cons46, cons45, cons38) def replacement4618(p, b, n2, d, a, n, c, x, e): rubi.append(4618) return Dist(S(4)**(-p)*c**(-p), Int((b + S(2)*c*(S(1)/sin(d + e*x))**n)**(S(2)*p), x), x) rule4618 = ReplacementRule(pattern4618, replacement4618) pattern4619 = Pattern(Integral(((S(1)/cos(x_*WC('e', S(1)) + WC('d', S(0))))**WC('n', S(1))*WC('b', S(1)) + (S(1)/cos(x_*WC('e', S(1)) + WC('d', S(0))))**WC('n2', S(1))*WC('c', S(1)) + WC('a', S(0)))**p_, x_), cons2, cons3, cons7, cons27, cons48, cons4, cons5, cons46, cons45, cons147) def replacement4619(p, b, n2, d, a, n, c, x, e): rubi.append(4619) return Dist((b + S(2)*c*(S(1)/cos(d + e*x))**n)**(-S(2)*p)*(a + b*(S(1)/cos(d + e*x))**n + c*(S(1)/cos(d + e*x))**(S(2)*n))**p, Int(u*(b + S(2)*c*(S(1)/cos(d + e*x))**n)**(S(2)*p), x), x) rule4619 = ReplacementRule(pattern4619, replacement4619) pattern4620 = Pattern(Integral(((S(1)/sin(x_*WC('e', S(1)) + WC('d', S(0))))**WC('n', S(1))*WC('b', S(1)) + (S(1)/sin(x_*WC('e', S(1)) + WC('d', S(0))))**WC('n2', S(1))*WC('c', S(1)) + WC('a', S(0)))**p_, x_), cons2, cons3, cons7, cons27, cons48, cons4, cons5, cons46, cons45, cons147) def replacement4620(p, b, n2, d, a, n, c, x, e): rubi.append(4620) return Dist((b + S(2)*c*(S(1)/sin(d + e*x))**n)**(-S(2)*p)*(a + b*(S(1)/sin(d + e*x))**n + c*(S(1)/sin(d + e*x))**(S(2)*n))**p, Int(u*(b + S(2)*c*(S(1)/sin(d + e*x))**n)**(S(2)*p), x), x) rule4620 = ReplacementRule(pattern4620, replacement4620) def With4621(b, n2, d, a, n, c, x, e): q = Rt(-S(4)*a*c + b**S(2), S(2)) rubi.append(4621) return Dist(S(2)*c/q, Int(S(1)/(b + S(2)*c*(S(1)/cos(d + e*x))**n - q), x), x) - Dist(S(2)*c/q, Int(S(1)/(b + S(2)*c*(S(1)/cos(d + e*x))**n + q), x), x) pattern4621 = Pattern(Integral(S(1)/((S(1)/cos(x_*WC('e', S(1)) + WC('d', S(0))))**WC('n', S(1))*WC('b', S(1)) + (S(1)/cos(x_*WC('e', S(1)) + WC('d', S(0))))**WC('n2', S(1))*WC('c', S(1)) + WC('a', S(0))), x_), cons2, cons3, cons7, cons27, cons48, cons4, cons46, cons226) rule4621 = ReplacementRule(pattern4621, With4621) def With4622(b, n2, d, a, n, c, x, e): q = Rt(-S(4)*a*c + b**S(2), S(2)) rubi.append(4622) return Dist(S(2)*c/q, Int(S(1)/(b + S(2)*c*(S(1)/sin(d + e*x))**n - q), x), x) - Dist(S(2)*c/q, Int(S(1)/(b + S(2)*c*(S(1)/sin(d + e*x))**n + q), x), x) pattern4622 = Pattern(Integral(S(1)/((S(1)/sin(x_*WC('e', S(1)) + WC('d', S(0))))**WC('n', S(1))*WC('b', S(1)) + (S(1)/sin(x_*WC('e', S(1)) + WC('d', S(0))))**WC('n2', S(1))*WC('c', S(1)) + WC('a', S(0))), x_), cons2, cons3, cons7, cons27, cons48, cons4, cons46, cons226) rule4622 = ReplacementRule(pattern4622, With4622) def With4623(p, m, b, n2, d, a, n, c, x, e): f = FreeFactors(cos(d + e*x), x) rubi.append(4623) return -Dist(f/e, Subst(Int((f*x)**(-n*p)*(a*(f*x)**n + b)**p*(-f**S(2)*x**S(2) + S(1))**(m/S(2) + S(-1)/2), x), x, cos(d + e*x)/f), x) pattern4623 = Pattern(Integral(((S(1)/cos(x_*WC('e', S(1)) + WC('d', S(0))))**n2_*WC('c', S(1)) + (S(1)/cos(x_*WC('e', S(1)) + WC('d', S(0))))**WC('n', S(1))*WC('b', S(1)) + WC('a', S(0)))**WC('p', S(1))*sin(x_*WC('e', S(1)) + WC('d', S(0)))**WC('m', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons46, cons1481, cons376) rule4623 = ReplacementRule(pattern4623, With4623) def With4624(p, m, b, n2, d, a, n, c, x, e): f = FreeFactors(sin(d + e*x), x) rubi.append(4624) return Dist(f/e, Subst(Int((f*x)**(-n*p)*(a*(f*x)**n + b)**p*(-f**S(2)*x**S(2) + S(1))**(m/S(2) + S(-1)/2), x), x, sin(d + e*x)/f), x) pattern4624 = Pattern(Integral(((S(1)/sin(x_*WC('e', S(1)) + WC('d', S(0))))**n2_*WC('c', S(1)) + (S(1)/sin(x_*WC('e', S(1)) + WC('d', S(0))))**WC('n', S(1))*WC('b', S(1)) + WC('a', S(0)))**WC('p', S(1))*cos(x_*WC('e', S(1)) + WC('d', S(0)))**WC('m', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons46, cons1481, cons376) rule4624 = ReplacementRule(pattern4624, With4624) def With4625(p, m, b, n2, d, c, a, n, x, e): f = FreeFactors(tan(d + e*x), x) rubi.append(4625) return Dist(f**(m + S(1))/e, Subst(Int(x**m*(f**S(2)*x**S(2) + S(1))**(-m/S(2) + S(-1))*ExpandToSum(a + b*(f**S(2)*x**S(2) + S(1))**(n/S(2)) + c*(f**S(2)*x**S(2) + S(1))**n, x)**p, x), x, tan(d + e*x)/f), x) pattern4625 = Pattern(Integral(((S(1)/cos(x_*WC('e', S(1)) + WC('d', S(0))))**n2_*WC('c', S(1)) + (S(1)/cos(x_*WC('e', S(1)) + WC('d', S(0))))**n_*WC('b', S(1)) + WC('a', S(0)))**WC('p', S(1))*sin(x_*WC('e', S(1)) + WC('d', S(0)))**m_, x_), cons2, cons3, cons7, cons27, cons48, cons5, cons46, cons1480, cons1479) rule4625 = ReplacementRule(pattern4625, With4625) def With4626(p, m, b, n2, d, c, a, n, x, e): f = FreeFactors(S(1)/tan(d + e*x), x) rubi.append(4626) return -Dist(f**(m + S(1))/e, Subst(Int(x**m*(f**S(2)*x**S(2) + S(1))**(-m/S(2) + S(-1))*ExpandToSum(a + b*(f**S(2)*x**S(2) + S(1))**(n/S(2)) + c*(f**S(2)*x**S(2) + S(1))**n, x)**p, x), x, S(1)/(f*tan(d + e*x))), x) pattern4626 = Pattern(Integral(((S(1)/sin(x_*WC('e', S(1)) + WC('d', S(0))))**n2_*WC('c', S(1)) + (S(1)/sin(x_*WC('e', S(1)) + WC('d', S(0))))**n_*WC('b', S(1)) + WC('a', S(0)))**WC('p', S(1))*cos(x_*WC('e', S(1)) + WC('d', S(0)))**m_, x_), cons2, cons3, cons7, cons27, cons48, cons5, cons46, cons1480, cons1479) rule4626 = ReplacementRule(pattern4626, With4626) pattern4627 = Pattern(Integral(((S(1)/cos(x_*WC('e', S(1)) + WC('d', S(0))))**WC('n', S(1))*WC('b', S(1)) + (S(1)/cos(x_*WC('e', S(1)) + WC('d', S(0))))**WC('n2', S(1))*WC('c', S(1)) + WC('a', S(0)))**p_*(S(1)/cos(x_*WC('e', S(1)) + WC('d', S(0))))**WC('m', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons21, cons4, cons46, cons45, cons38) def replacement4627(p, m, b, n2, d, a, n, c, x, e): rubi.append(4627) return Dist(S(4)**(-p)*c**(-p), Int((b + S(2)*c*(S(1)/cos(d + e*x))**n)**(S(2)*p)*(S(1)/cos(d + e*x))**m, x), x) rule4627 = ReplacementRule(pattern4627, replacement4627) pattern4628 = Pattern(Integral(((S(1)/sin(x_*WC('e', S(1)) + WC('d', S(0))))**WC('n', S(1))*WC('b', S(1)) + (S(1)/sin(x_*WC('e', S(1)) + WC('d', S(0))))**WC('n2', S(1))*WC('c', S(1)) + WC('a', S(0)))**p_*(S(1)/sin(x_*WC('e', S(1)) + WC('d', S(0))))**WC('m', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons21, cons4, cons46, cons45, cons38) def replacement4628(p, m, b, n2, d, a, n, c, x, e): rubi.append(4628) return Dist(S(4)**(-p)*c**(-p), Int((b + S(2)*c*(S(1)/sin(d + e*x))**n)**(S(2)*p)*(S(1)/sin(d + e*x))**m, x), x) rule4628 = ReplacementRule(pattern4628, replacement4628) pattern4629 = Pattern(Integral(((S(1)/cos(x_*WC('e', S(1)) + WC('d', S(0))))**WC('n', S(1))*WC('b', S(1)) + (S(1)/cos(x_*WC('e', S(1)) + WC('d', S(0))))**WC('n2', S(1))*WC('c', S(1)) + WC('a', S(0)))**p_*(S(1)/cos(x_*WC('e', S(1)) + WC('d', S(0))))**WC('m', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons21, cons4, cons5, cons46, cons45, cons147) def replacement4629(p, m, b, n2, d, a, n, c, x, e): rubi.append(4629) return Dist((b + S(2)*c*(S(1)/cos(d + e*x))**n)**(-S(2)*p)*(a + b*(S(1)/cos(d + e*x))**n + c*(S(1)/cos(d + e*x))**(S(2)*n))**p, Int((b + S(2)*c*(S(1)/cos(d + e*x))**n)**(S(2)*p)*(S(1)/cos(d + e*x))**m, x), x) rule4629 = ReplacementRule(pattern4629, replacement4629) pattern4630 = Pattern(Integral(((S(1)/sin(x_*WC('e', S(1)) + WC('d', S(0))))**WC('n', S(1))*WC('b', S(1)) + (S(1)/sin(x_*WC('e', S(1)) + WC('d', S(0))))**WC('n2', S(1))*WC('c', S(1)) + WC('a', S(0)))**p_*(S(1)/sin(x_*WC('e', S(1)) + WC('d', S(0))))**WC('m', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons21, cons4, cons5, cons46, cons45, cons147) def replacement4630(p, m, b, n2, d, a, n, c, x, e): rubi.append(4630) return Dist((b + S(2)*c*(S(1)/sin(d + e*x))**n)**(-S(2)*p)*(a + b*(S(1)/sin(d + e*x))**n + c*(S(1)/sin(d + e*x))**(S(2)*n))**p, Int((b + S(2)*c*(S(1)/sin(d + e*x))**n)**(S(2)*p)*(S(1)/sin(d + e*x))**m, x), x) rule4630 = ReplacementRule(pattern4630, replacement4630) pattern4631 = Pattern(Integral(((S(1)/cos(x_*WC('e', S(1)) + WC('d', S(0))))**WC('n', S(1))*WC('b', S(1)) + (S(1)/cos(x_*WC('e', S(1)) + WC('d', S(0))))**WC('n2', S(1))*WC('c', S(1)) + WC('a', S(0)))**p_*(S(1)/cos(x_*WC('e', S(1)) + WC('d', S(0))))**WC('m', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons46, cons375) def replacement4631(p, m, b, n2, d, a, n, c, x, e): rubi.append(4631) return Int(ExpandTrig((a + b*(S(1)/cos(d + e*x))**n + c*(S(1)/cos(d + e*x))**(S(2)*n))**p*(S(1)/cos(d + e*x))**m, x), x) rule4631 = ReplacementRule(pattern4631, replacement4631) pattern4632 = Pattern(Integral(((S(1)/sin(x_*WC('e', S(1)) + WC('d', S(0))))**WC('n', S(1))*WC('b', S(1)) + (S(1)/sin(x_*WC('e', S(1)) + WC('d', S(0))))**WC('n2', S(1))*WC('c', S(1)) + WC('a', S(0)))**p_*(S(1)/sin(x_*WC('e', S(1)) + WC('d', S(0))))**WC('m', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons46, cons375) def replacement4632(p, m, b, n2, d, a, n, c, x, e): rubi.append(4632) return Int(ExpandTrig((a + b*(S(1)/sin(d + e*x))**n + c*(S(1)/sin(d + e*x))**(S(2)*n))**p*(S(1)/sin(d + e*x))**m, x), x) rule4632 = ReplacementRule(pattern4632, replacement4632) def With4633(p, m, b, n2, d, c, n, a, x, e): f = FreeFactors(cos(d + e*x), x) rubi.append(4633) return -Dist(f**(-m - n*p + S(1))/e, Subst(Int(x**(-m - S(2)*n*p)*(-f**S(2)*x**S(2) + S(1))**(m/S(2) + S(-1)/2)*(b*(f*x)**n + c*(f*x)**(S(2)*n) + c)**p, x), x, cos(d + e*x)/f), x) pattern4633 = Pattern(Integral((a_ + (S(1)/cos(x_*WC('e', S(1)) + WC('d', S(0))))**WC('n', S(1))*WC('b', S(1)) + (S(1)/cos(x_*WC('e', S(1)) + WC('d', S(0))))**WC('n2', S(1))*WC('c', S(1)))**WC('p', S(1))*tan(x_*WC('e', S(1)) + WC('d', S(0)))**WC('m', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons4, cons46, cons1481, cons85, cons38) rule4633 = ReplacementRule(pattern4633, With4633) def With4634(p, m, b, n2, d, c, n, a, x, e): f = FreeFactors(sin(d + e*x), x) rubi.append(4634) return Dist(f**(-m - n*p + S(1))/e, Subst(Int(x**(-m - S(2)*n*p)*(-f**S(2)*x**S(2) + S(1))**(m/S(2) + S(-1)/2)*(b*(f*x)**n + c*(f*x)**(S(2)*n) + c)**p, x), x, sin(d + e*x)/f), x) pattern4634 = Pattern(Integral((a_ + (S(1)/sin(x_*WC('e', S(1)) + WC('d', S(0))))**WC('n', S(1))*WC('b', S(1)) + (S(1)/cos(x_*WC('e', S(1)) + WC('d', S(0))))**WC('n2', S(1))*WC('c', S(1)))**WC('p', S(1))*(S(1)/tan(x_*WC('e', S(1)) + WC('d', S(0))))**WC('m', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons4, cons46, cons1481, cons85, cons38) rule4634 = ReplacementRule(pattern4634, With4634) def With4635(p, m, b, n2, d, c, a, n, x, e): f = FreeFactors(tan(d + e*x), x) rubi.append(4635) return Dist(f**(m + S(1))/e, Subst(Int(x**m*ExpandToSum(a + b*(f**S(2)*x**S(2) + S(1))**(n/S(2)) + c*(f**S(2)*x**S(2) + S(1))**n, x)**p/(f**S(2)*x**S(2) + S(1)), x), x, tan(d + e*x)/f), x) pattern4635 = Pattern(Integral((a_ + (S(1)/cos(x_*WC('e', S(1)) + WC('d', S(0))))**n_*WC('b', S(1)) + (S(1)/cos(x_*WC('e', S(1)) + WC('d', S(0))))**WC('n2', S(1))*WC('c', S(1)))**WC('p', S(1))*tan(x_*WC('e', S(1)) + WC('d', S(0)))**WC('m', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons46, cons1480, cons1479) rule4635 = ReplacementRule(pattern4635, With4635) def With4636(p, m, b, n2, d, c, n, a, x, e): f = FreeFactors(S(1)/tan(d + e*x), x) rubi.append(4636) return -Dist(f**(m + S(1))/e, Subst(Int(x**m*ExpandToSum(a + b*(f**S(2)*x**S(2) + S(1))**(n/S(2)) + c*(f**S(2)*x**S(2) + S(1))**n, x)**p/(f**S(2)*x**S(2) + S(1)), x), x, S(1)/(f*tan(d + e*x))), x) pattern4636 = Pattern(Integral((a_ + (S(1)/sin(x_*WC('e', S(1)) + WC('d', S(0))))**n_*WC('b', S(1)) + (S(1)/cos(x_*WC('e', S(1)) + WC('d', S(0))))**WC('n2', S(1))*WC('c', S(1)))**WC('p', S(1))*(S(1)/tan(x_*WC('e', S(1)) + WC('d', S(0))))**WC('m', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons46, cons1480, cons1479) rule4636 = ReplacementRule(pattern4636, With4636) pattern4637 = Pattern(Integral((A_ + WC('B', S(1))/cos(x_*WC('e', S(1)) + WC('d', S(0))))*(a_ + WC('b', S(1))/cos(x_*WC('e', S(1)) + WC('d', S(0))) + WC('c', S(1))/cos(x_*WC('e', S(1)) + WC('d', S(0)))**S(2))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons34, cons35, cons45, cons85) def replacement4637(B, b, d, c, a, n, A, x, e): rubi.append(4637) return Dist(S(4)**(-n)*c**(-n), Int((A + B/cos(d + e*x))*(b + S(2)*c/cos(d + e*x))**(S(2)*n), x), x) rule4637 = ReplacementRule(pattern4637, replacement4637) pattern4638 = Pattern(Integral((A_ + WC('B', S(1))/sin(x_*WC('e', S(1)) + WC('d', S(0))))*(a_ + WC('b', S(1))/sin(x_*WC('e', S(1)) + WC('d', S(0))) + WC('c', S(1))/sin(x_*WC('e', S(1)) + WC('d', S(0)))**S(2))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons34, cons35, cons45, cons85) def replacement4638(B, b, d, c, a, n, A, x, e): rubi.append(4638) return Dist(S(4)**(-n)*c**(-n), Int((A + B/sin(d + e*x))*(b + S(2)*c/sin(d + e*x))**(S(2)*n), x), x) rule4638 = ReplacementRule(pattern4638, replacement4638) pattern4639 = Pattern(Integral((A_ + WC('B', S(1))/cos(x_*WC('e', S(1)) + WC('d', S(0))))*(a_ + WC('b', S(1))/cos(x_*WC('e', S(1)) + WC('d', S(0))) + WC('c', S(1))/cos(x_*WC('e', S(1)) + WC('d', S(0)))**S(2))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons34, cons35, cons45, cons23) def replacement4639(B, b, d, c, a, n, A, x, e): rubi.append(4639) return Dist((b + S(2)*c/cos(d + e*x))**(-S(2)*n)*(a + b/cos(d + e*x) + c/cos(d + e*x)**S(2))**n, Int((A + B/cos(d + e*x))*(b + S(2)*c/cos(d + e*x))**(S(2)*n), x), x) rule4639 = ReplacementRule(pattern4639, replacement4639) pattern4640 = Pattern(Integral((A_ + WC('B', S(1))/sin(x_*WC('e', S(1)) + WC('d', S(0))))*(a_ + WC('b', S(1))/sin(x_*WC('e', S(1)) + WC('d', S(0))) + WC('c', S(1))/sin(x_*WC('e', S(1)) + WC('d', S(0)))**S(2))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons34, cons35, cons45, cons23) def replacement4640(B, b, d, c, a, n, A, x, e): rubi.append(4640) return Dist((b + S(2)*c/sin(d + e*x))**(-S(2)*n)*(a + b/sin(d + e*x) + c/sin(d + e*x)**S(2))**n, Int((A + B/sin(d + e*x))*(b + S(2)*c/sin(d + e*x))**(S(2)*n), x), x) rule4640 = ReplacementRule(pattern4640, replacement4640) def With4641(B, b, d, a, c, A, x, e): q = Rt(-S(4)*a*c + b**S(2), S(2)) rubi.append(4641) return Dist(B - (-S(2)*A*c + B*b)/q, Int(S(1)/(b + S(2)*c/cos(d + e*x) - q), x), x) + Dist(B + (-S(2)*A*c + B*b)/q, Int(S(1)/(b + S(2)*c/cos(d + e*x) + q), x), x) pattern4641 = Pattern(Integral((A_ + WC('B', S(1))/cos(x_*WC('e', S(1)) + WC('d', S(0))))/(WC('a', S(0)) + WC('b', S(1))/cos(x_*WC('e', S(1)) + WC('d', S(0))) + WC('c', S(1))/cos(x_*WC('e', S(1)) + WC('d', S(0)))**S(2)), x_), cons2, cons3, cons7, cons27, cons48, cons34, cons35, cons226) rule4641 = ReplacementRule(pattern4641, With4641) def With4642(B, b, d, c, a, A, x, e): q = Rt(-S(4)*a*c + b**S(2), S(2)) rubi.append(4642) return Dist(B - (-S(2)*A*c + B*b)/q, Int(S(1)/(b + S(2)*c/sin(d + e*x) - q), x), x) + Dist(B + (-S(2)*A*c + B*b)/q, Int(S(1)/(b + S(2)*c/sin(d + e*x) + q), x), x) pattern4642 = Pattern(Integral((A_ + WC('B', S(1))/sin(x_*WC('e', S(1)) + WC('d', S(0))))/(WC('a', S(0)) + WC('b', S(1))/sin(x_*WC('e', S(1)) + WC('d', S(0))) + WC('c', S(1))/sin(x_*WC('e', S(1)) + WC('d', S(0)))**S(2)), x_), cons2, cons3, cons7, cons27, cons48, cons34, cons35, cons226) rule4642 = ReplacementRule(pattern4642, With4642) pattern4643 = Pattern(Integral((A_ + WC('B', S(1))/cos(x_*WC('e', S(1)) + WC('d', S(0))))*(WC('a', S(0)) + WC('b', S(1))/cos(x_*WC('e', S(1)) + WC('d', S(0))) + WC('c', S(1))/cos(x_*WC('e', S(1)) + WC('d', S(0)))**S(2))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons34, cons35, cons226, cons85) def replacement4643(B, b, d, a, c, n, A, x, e): rubi.append(4643) return Int(ExpandTrig((A + B/cos(d + e*x))*(a + b/cos(d + e*x) + c/cos(d + e*x)**S(2))**n, x), x) rule4643 = ReplacementRule(pattern4643, replacement4643) pattern4644 = Pattern(Integral((A_ + WC('B', S(1))/sin(x_*WC('e', S(1)) + WC('d', S(0))))*(WC('a', S(0)) + WC('b', S(1))/sin(x_*WC('e', S(1)) + WC('d', S(0))) + WC('c', S(1))/sin(x_*WC('e', S(1)) + WC('d', S(0)))**S(2))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons34, cons35, cons226, cons85) def replacement4644(B, b, d, c, a, n, A, x, e): rubi.append(4644) return Int(ExpandTrig((A + B/sin(d + e*x))*(a + b/sin(d + e*x) + c/sin(d + e*x)**S(2))**n, x), x) rule4644 = ReplacementRule(pattern4644, replacement4644) pattern4645 = Pattern(Integral((x_*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))), x_), cons7, cons27, cons48, cons125, cons62) def replacement4645(m, f, d, c, x, e): rubi.append(4645) return -Dist(d*m/f, Int((c + d*x)**(m + S(-1))*log(-I*exp(I*(e + f*x)) + S(1)), x), x) + Dist(d*m/f, Int((c + d*x)**(m + S(-1))*log(I*exp(I*(e + f*x)) + S(1)), x), x) + Simp(-S(2)*I*(c + d*x)**m*ArcTan(exp(I*e + I*f*x))/f, x) rule4645 = ReplacementRule(pattern4645, replacement4645) pattern4646 = Pattern(Integral((x_*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))), x_), cons7, cons27, cons48, cons125, cons62) def replacement4646(m, f, d, c, x, e): rubi.append(4646) return -Dist(d*m/f, Int((c + d*x)**(m + S(-1))*log(-exp(I*(e + f*x)) + S(1)), x), x) + Dist(d*m/f, Int((c + d*x)**(m + S(-1))*log(exp(I*(e + f*x)) + S(1)), x), x) + Simp(-S(2)*(c + d*x)**m*atanh(exp(I*e + I*f*x))/f, x) rule4646 = ReplacementRule(pattern4646, replacement4646) pattern4647 = Pattern(Integral((x_*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0)))**S(2), x_), cons7, cons27, cons48, cons125, cons31, cons168) def replacement4647(m, f, d, c, x, e): rubi.append(4647) return -Dist(d*m/f, Int((c + d*x)**(m + S(-1))*tan(e + f*x), x), x) + Simp((c + d*x)**m*tan(e + f*x)/f, x) rule4647 = ReplacementRule(pattern4647, replacement4647) pattern4648 = Pattern(Integral((x_*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0)))**S(2), x_), cons7, cons27, cons48, cons125, cons31, cons168) def replacement4648(m, f, d, c, x, e): rubi.append(4648) return Dist(d*m/f, Int((c + d*x)**(m + S(-1))/tan(e + f*x), x), x) - Simp((c + d*x)**m/(f*tan(e + f*x)), x) rule4648 = ReplacementRule(pattern4648, replacement4648) pattern4649 = Pattern(Integral((WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(x_*WC('d', S(1)) + WC('c', S(0))), x_), cons3, cons7, cons27, cons48, cons125, cons87, cons165, cons1644) def replacement4649(f, b, d, c, n, x, e): rubi.append(4649) return Dist(b**S(2)*(n + S(-2))/(n + S(-1)), Int((b/cos(e + f*x))**(n + S(-2))*(c + d*x), x), x) - Simp(b**S(2)*d*(b/cos(e + f*x))**(n + S(-2))/(f**S(2)*(n + S(-2))*(n + S(-1))), x) + Simp(b**S(2)*(b/cos(e + f*x))**(n + S(-2))*(c + d*x)*tan(e + f*x)/(f*(n + S(-1))), x) rule4649 = ReplacementRule(pattern4649, replacement4649) pattern4650 = Pattern(Integral((WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(x_*WC('d', S(1)) + WC('c', S(0))), x_), cons3, cons7, cons27, cons48, cons125, cons87, cons165, cons1644) def replacement4650(f, b, d, c, n, x, e): rubi.append(4650) return Dist(b**S(2)*(n + S(-2))/(n + S(-1)), Int((b/sin(e + f*x))**(n + S(-2))*(c + d*x), x), x) - Simp(b**S(2)*d*(b/sin(e + f*x))**(n + S(-2))/(f**S(2)*(n + S(-2))*(n + S(-1))), x) - Simp(b**S(2)*(b/sin(e + f*x))**(n + S(-2))*(c + d*x)/(f*(n + S(-1))*tan(e + f*x)), x) rule4650 = ReplacementRule(pattern4650, replacement4650) pattern4651 = Pattern(Integral((WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(x_*WC('d', S(1)) + WC('c', S(0)))**m_, x_), cons3, cons7, cons27, cons48, cons125, cons93, cons165, cons1644, cons166) def replacement4651(m, f, b, d, c, n, x, e): rubi.append(4651) return Dist(b**S(2)*(n + S(-2))/(n + S(-1)), Int((b/cos(e + f*x))**(n + S(-2))*(c + d*x)**m, x), x) + Dist(b**S(2)*d**S(2)*m*(m + S(-1))/(f**S(2)*(n + S(-2))*(n + S(-1))), Int((b/cos(e + f*x))**(n + S(-2))*(c + d*x)**(m + S(-2)), x), x) + Simp(b**S(2)*(b/cos(e + f*x))**(n + S(-2))*(c + d*x)**m*tan(e + f*x)/(f*(n + S(-1))), x) - Simp(b**S(2)*d*m*(b/cos(e + f*x))**(n + S(-2))*(c + d*x)**(m + S(-1))/(f**S(2)*(n + S(-2))*(n + S(-1))), x) rule4651 = ReplacementRule(pattern4651, replacement4651) pattern4652 = Pattern(Integral((WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(x_*WC('d', S(1)) + WC('c', S(0)))**m_, x_), cons3, cons7, cons27, cons48, cons125, cons93, cons165, cons1644, cons166) def replacement4652(m, f, b, d, c, n, x, e): rubi.append(4652) return Dist(b**S(2)*(n + S(-2))/(n + S(-1)), Int((b/sin(e + f*x))**(n + S(-2))*(c + d*x)**m, x), x) + Dist(b**S(2)*d**S(2)*m*(m + S(-1))/(f**S(2)*(n + S(-2))*(n + S(-1))), Int((b/sin(e + f*x))**(n + S(-2))*(c + d*x)**(m + S(-2)), x), x) - Simp(b**S(2)*(b/sin(e + f*x))**(n + S(-2))*(c + d*x)**m/(f*(n + S(-1))*tan(e + f*x)), x) - Simp(b**S(2)*d*m*(b/sin(e + f*x))**(n + S(-2))*(c + d*x)**(m + S(-1))/(f**S(2)*(n + S(-2))*(n + S(-1))), x) rule4652 = ReplacementRule(pattern4652, replacement4652) pattern4653 = Pattern(Integral((WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(x_*WC('d', S(1)) + WC('c', S(0))), x_), cons3, cons7, cons27, cons48, cons125, cons87, cons89) def replacement4653(f, b, d, c, n, x, e): rubi.append(4653) return Dist((n + S(1))/(b**S(2)*n), Int((b/cos(e + f*x))**(n + S(2))*(c + d*x), x), x) + Simp(d*(b/cos(e + f*x))**n/(f**S(2)*n**S(2)), x) - Simp((b/cos(e + f*x))**(n + S(1))*(c + d*x)*sin(e + f*x)/(b*f*n), x) rule4653 = ReplacementRule(pattern4653, replacement4653) pattern4654 = Pattern(Integral((WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(x_*WC('d', S(1)) + WC('c', S(0))), x_), cons3, cons7, cons27, cons48, cons125, cons87, cons89) def replacement4654(f, b, d, c, n, x, e): rubi.append(4654) return Dist((n + S(1))/(b**S(2)*n), Int((b/sin(e + f*x))**(n + S(2))*(c + d*x), x), x) + Simp(d*(b/sin(e + f*x))**n/(f**S(2)*n**S(2)), x) + Simp((b/sin(e + f*x))**(n + S(1))*(c + d*x)*cos(e + f*x)/(b*f*n), x) rule4654 = ReplacementRule(pattern4654, replacement4654) pattern4655 = Pattern(Integral((WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(x_*WC('d', S(1)) + WC('c', S(0)))**m_, x_), cons3, cons7, cons27, cons48, cons125, cons93, cons89, cons166) def replacement4655(m, f, b, d, c, n, x, e): rubi.append(4655) return Dist((n + S(1))/(b**S(2)*n), Int((b/cos(e + f*x))**(n + S(2))*(c + d*x)**m, x), x) - Dist(d**S(2)*m*(m + S(-1))/(f**S(2)*n**S(2)), Int((b/cos(e + f*x))**n*(c + d*x)**(m + S(-2)), x), x) - Simp((b/cos(e + f*x))**(n + S(1))*(c + d*x)**m*sin(e + f*x)/(b*f*n), x) + Simp(d*m*(b/cos(e + f*x))**n*(c + d*x)**(m + S(-1))/(f**S(2)*n**S(2)), x) rule4655 = ReplacementRule(pattern4655, replacement4655) pattern4656 = Pattern(Integral((WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(x_*WC('d', S(1)) + WC('c', S(0)))**m_, x_), cons3, cons7, cons27, cons48, cons125, cons93, cons89, cons166) def replacement4656(m, f, b, d, c, n, x, e): rubi.append(4656) return Dist((n + S(1))/(b**S(2)*n), Int((b/sin(e + f*x))**(n + S(2))*(c + d*x)**m, x), x) - Dist(d**S(2)*m*(m + S(-1))/(f**S(2)*n**S(2)), Int((b/sin(e + f*x))**n*(c + d*x)**(m + S(-2)), x), x) + Simp((b/sin(e + f*x))**(n + S(1))*(c + d*x)**m*cos(e + f*x)/(b*f*n), x) + Simp(d*m*(b/sin(e + f*x))**n*(c + d*x)**(m + S(-1))/(f**S(2)*n**S(2)), x) rule4656 = ReplacementRule(pattern4656, replacement4656) pattern4657 = Pattern(Integral((WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(x_*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1)), x_), cons3, cons7, cons27, cons48, cons125, cons21, cons4, cons23) def replacement4657(m, f, b, d, c, n, x, e): rubi.append(4657) return Dist((b/cos(e + f*x))**n*(b*cos(e + f*x))**n, Int((b*cos(e + f*x))**(-n)*(c + d*x)**m, x), x) rule4657 = ReplacementRule(pattern4657, replacement4657) pattern4658 = Pattern(Integral((WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(x_*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1)), x_), cons3, cons7, cons27, cons48, cons125, cons21, cons4, cons23) def replacement4658(m, f, b, d, c, n, x, e): rubi.append(4658) return Dist((b/sin(e + f*x))**n*(b*sin(e + f*x))**n, Int((b*sin(e + f*x))**(-n)*(c + d*x)**m, x), x) rule4658 = ReplacementRule(pattern4658, replacement4658) pattern4659 = Pattern(Integral((a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1))*(x_*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons528) def replacement4659(m, f, b, d, c, n, a, x, e): rubi.append(4659) return Int(ExpandIntegrand((c + d*x)**m, (a + b/cos(e + f*x))**n, x), x) rule4659 = ReplacementRule(pattern4659, replacement4659) pattern4660 = Pattern(Integral((a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1))*(x_*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons528) def replacement4660(m, f, b, d, c, n, a, x, e): rubi.append(4660) return Int(ExpandIntegrand((c + d*x)**m, (a + b/sin(e + f*x))**n, x), x) rule4660 = ReplacementRule(pattern4660, replacement4660) pattern4661 = Pattern(Integral((a_ + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1))*(x_*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons196, cons62) def replacement4661(m, f, b, d, c, n, a, x, e): rubi.append(4661) return Int(ExpandIntegrand((c + d*x)**m, (a*cos(e + f*x) + b)**n*cos(e + f*x)**(-n), x), x) rule4661 = ReplacementRule(pattern4661, replacement4661) pattern4662 = Pattern(Integral((a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1))*(x_*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons196, cons62) def replacement4662(m, f, b, d, c, n, a, x, e): rubi.append(4662) return Int(ExpandIntegrand((c + d*x)**m, (a*sin(e + f*x) + b)**n*sin(e + f*x)**(-n), x), x) rule4662 = ReplacementRule(pattern4662, replacement4662) pattern4663 = Pattern(Integral(u_**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))/cos(v_))**WC('n', S(1)), x_), cons2, cons3, cons21, cons4, cons810, cons811) def replacement4663(v, u, m, b, a, n, x): rubi.append(4663) return Int((a + b/cos(ExpandToSum(v, x)))**n*ExpandToSum(u, x)**m, x) rule4663 = ReplacementRule(pattern4663, replacement4663) pattern4664 = Pattern(Integral(u_**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))/sin(v_))**WC('n', S(1)), x_), cons2, cons3, cons21, cons4, cons810, cons811) def replacement4664(v, u, m, b, a, n, x): rubi.append(4664) return Int((a + b/sin(ExpandToSum(v, x)))**n*ExpandToSum(u, x)**m, x) rule4664 = ReplacementRule(pattern4664, replacement4664) pattern4665 = Pattern(Integral((x_*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons4, cons1360) def replacement4665(m, f, b, d, c, a, n, x, e): rubi.append(4665) return Int((a + b/cos(e + f*x))**n*(c + d*x)**m, x) rule4665 = ReplacementRule(pattern4665, replacement4665) pattern4666 = Pattern(Integral((x_*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons4, cons1360) def replacement4666(m, f, b, d, a, n, c, x, e): rubi.append(4666) return Int((a + b/sin(e + f*x))**n*(c + d*x)**m, x) rule4666 = ReplacementRule(pattern4666, replacement4666) pattern4667 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))/cos(x_**n_*WC('d', S(1)) + WC('c', S(0))))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons5, cons1573, cons38) def replacement4667(p, b, d, c, a, n, x): rubi.append(4667) return Dist(S(1)/n, Subst(Int(x**(S(-1) + S(1)/n)*(a + b/cos(c + d*x))**p, x), x, x**n), x) rule4667 = ReplacementRule(pattern4667, replacement4667) pattern4668 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))/sin(x_**n_*WC('d', S(1)) + WC('c', S(0))))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons5, cons1573, cons38) def replacement4668(p, b, d, a, c, n, x): rubi.append(4668) return Dist(S(1)/n, Subst(Int(x**(S(-1) + S(1)/n)*(a + b/sin(c + d*x))**p, x), x, x**n), x) rule4668 = ReplacementRule(pattern4668, replacement4668) pattern4669 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))/cos(x_**n_*WC('d', S(1)) + WC('c', S(0))))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons4, cons5, cons1495) def replacement4669(p, b, d, c, a, n, x): rubi.append(4669) return Int((a + b/cos(c + d*x**n))**p, x) rule4669 = ReplacementRule(pattern4669, replacement4669) pattern4670 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))/sin(x_**n_*WC('d', S(1)) + WC('c', S(0))))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons4, cons5, cons1495) def replacement4670(p, b, d, a, c, n, x): rubi.append(4670) return Int((a + b/sin(c + d*x**n))**p, x) rule4670 = ReplacementRule(pattern4670, replacement4670) pattern4671 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))/cos(u_**n_*WC('d', S(1)) + WC('c', S(0))))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons4, cons5, cons68, cons69) def replacement4671(p, u, b, d, c, a, n, x): rubi.append(4671) return Dist(S(1)/Coefficient(u, x, S(1)), Subst(Int((a + b/cos(c + d*x**n))**p, x), x, u), x) rule4671 = ReplacementRule(pattern4671, replacement4671) pattern4672 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))/sin(u_**n_*WC('d', S(1)) + WC('c', S(0))))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons4, cons5, cons68, cons69) def replacement4672(p, u, b, d, a, c, n, x): rubi.append(4672) return Dist(S(1)/Coefficient(u, x, S(1)), Subst(Int((a + b/sin(c + d*x**n))**p, x), x, u), x) rule4672 = ReplacementRule(pattern4672, replacement4672) pattern4673 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))/cos(u_))**WC('p', S(1)), x_), cons2, cons3, cons5, cons823, cons824) def replacement4673(p, u, b, a, x): rubi.append(4673) return Int((a + b/cos(ExpandToSum(u, x)))**p, x) rule4673 = ReplacementRule(pattern4673, replacement4673) pattern4674 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))/sin(u_))**WC('p', S(1)), x_), cons2, cons3, cons5, cons823, cons824) def replacement4674(p, u, b, a, x): rubi.append(4674) return Int((a + b/sin(ExpandToSum(u, x)))**p, x) rule4674 = ReplacementRule(pattern4674, replacement4674) pattern4675 = Pattern(Integral(x_**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))/cos(x_**n_*WC('d', S(1)) + WC('c', S(0))))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons21, cons4, cons5, cons1574, cons38) def replacement4675(p, m, b, d, c, a, n, x): rubi.append(4675) return Dist(S(1)/n, Subst(Int(x**(S(-1) + (m + S(1))/n)*(a + b/cos(c + d*x))**p, x), x, x**n), x) rule4675 = ReplacementRule(pattern4675, replacement4675) pattern4676 = Pattern(Integral(x_**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))/sin(x_**n_*WC('d', S(1)) + WC('c', S(0))))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons21, cons4, cons5, cons1574, cons38) def replacement4676(p, m, b, d, a, c, n, x): rubi.append(4676) return Dist(S(1)/n, Subst(Int(x**(S(-1) + (m + S(1))/n)*(a + b/sin(c + d*x))**p, x), x, x**n), x) rule4676 = ReplacementRule(pattern4676, replacement4676) pattern4677 = Pattern(Integral(x_**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))/cos(x_**n_*WC('d', S(1)) + WC('c', S(0))))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons21, cons4, cons5, cons1576) def replacement4677(p, m, b, d, c, a, n, x): rubi.append(4677) return Int(x**m*(a + b/cos(c + d*x**n))**p, x) rule4677 = ReplacementRule(pattern4677, replacement4677) pattern4678 = Pattern(Integral(x_**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))/sin(x_**n_*WC('d', S(1)) + WC('c', S(0))))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons21, cons4, cons5, cons1576) def replacement4678(p, m, b, d, a, c, n, x): rubi.append(4678) return Int(x**m*(a + b/sin(c + d*x**n))**p, x) rule4678 = ReplacementRule(pattern4678, replacement4678) pattern4679 = Pattern(Integral((e_*x_)**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))/cos(x_**n_*WC('d', S(1)) + WC('c', S(0))))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons21, cons4, cons5, cons1497) def replacement4679(p, m, b, d, c, a, n, x, e): rubi.append(4679) return Dist(e**IntPart(m)*x**(-FracPart(m))*(e*x)**FracPart(m), Int(x**m*(a + b/cos(c + d*x**n))**p, x), x) rule4679 = ReplacementRule(pattern4679, replacement4679) pattern4680 = Pattern(Integral((e_*x_)**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))/sin(x_**n_*WC('d', S(1)) + WC('c', S(0))))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons21, cons4, cons5, cons1497) def replacement4680(p, m, b, d, a, c, n, x, e): rubi.append(4680) return Dist(e**IntPart(m)*x**(-FracPart(m))*(e*x)**FracPart(m), Int(x**m*(a + b/sin(c + d*x**n))**p, x), x) rule4680 = ReplacementRule(pattern4680, replacement4680) pattern4681 = Pattern(Integral((e_*x_)**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))/cos(u_))**WC('p', S(1)), x_), cons2, cons3, cons48, cons21, cons5, cons823, cons824) def replacement4681(p, u, m, b, a, x, e): rubi.append(4681) return Int((e*x)**m*(a + b/cos(ExpandToSum(u, x)))**p, x) rule4681 = ReplacementRule(pattern4681, replacement4681) pattern4682 = Pattern(Integral((e_*x_)**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))/sin(u_))**WC('p', S(1)), x_), cons2, cons3, cons48, cons21, cons5, cons823, cons824) def replacement4682(p, u, m, b, a, x, e): rubi.append(4682) return Int((e*x)**m*(a + b/sin(ExpandToSum(u, x)))**p, x) rule4682 = ReplacementRule(pattern4682, replacement4682) pattern4683 = Pattern(Integral(x_**WC('m', S(1))*(S(1)/cos(x_**WC('n', S(1))*WC('b', S(1)) + WC('a', S(0))))**p_*sin(x_**WC('n', S(1))*WC('b', S(1)) + WC('a', S(0))), x_), cons2, cons3, cons5, cons31, cons85, cons1577, cons1645) def replacement4683(p, m, b, a, n, x): rubi.append(4683) return -Dist((m - n + S(1))/(b*n*(p + S(-1))), Int(x**(m - n)*(S(1)/cos(a + b*x**n))**(p + S(-1)), x), x) + Simp(x**(m - n + S(1))*(S(1)/cos(a + b*x**n))**(p + S(-1))/(b*n*(p + S(-1))), x) rule4683 = ReplacementRule(pattern4683, replacement4683) pattern4684 = Pattern(Integral(x_**WC('m', S(1))*(S(1)/sin(x_**WC('n', S(1))*WC('b', S(1)) + WC('a', S(0))))**p_*cos(x_**WC('n', S(1))*WC('b', S(1)) + WC('a', S(0))), x_), cons2, cons3, cons5, cons31, cons85, cons1577, cons1645) def replacement4684(p, m, b, a, n, x): rubi.append(4684) return Dist((m - n + S(1))/(b*n*(p + S(-1))), Int(x**(m - n)*(S(1)/sin(a + b*x**n))**(p + S(-1)), x), x) - Simp(x**(m - n + S(1))*(S(1)/sin(a + b*x**n))**(p + S(-1))/(b*n*(p + S(-1))), x) rule4684 = ReplacementRule(pattern4684, replacement4684) return [rule3917, rule3918, rule3919, rule3920, rule3921, rule3922, rule3923, rule3924, rule3925, rule3926, rule3927, rule3928, rule3929, rule3930, rule3931, rule3932, rule3933, rule3934, rule3935, rule3936, rule3937, rule3938, rule3939, rule3940, rule3941, rule3942, rule3943, rule3944, rule3945, rule3946, rule3947, rule3948, rule3949, rule3950, rule3951, rule3952, rule3953, rule3954, rule3955, rule3956, rule3957, rule3958, rule3959, rule3960, rule3961, rule3962, rule3963, rule3964, rule3965, rule3966, rule3967, rule3968, rule3969, rule3970, rule3971, rule3972, rule3973, rule3974, rule3975, rule3976, rule3977, rule3978, rule3979, rule3980, rule3981, rule3982, rule3983, rule3984, rule3985, rule3986, rule3987, rule3988, rule3989, rule3990, rule3991, rule3992, rule3993, rule3994, rule3995, rule3996, rule3997, rule3998, rule3999, rule4000, rule4001, rule4002, rule4003, rule4004, rule4005, rule4006, rule4007, rule4008, rule4009, rule4010, rule4011, rule4012, rule4013, rule4014, rule4015, rule4016, rule4017, rule4018, rule4019, rule4020, rule4021, rule4022, rule4023, rule4024, rule4025, rule4026, rule4027, rule4028, rule4029, rule4030, rule4031, rule4032, rule4033, rule4034, rule4035, rule4036, rule4037, rule4038, rule4039, rule4040, rule4041, rule4042, rule4043, rule4044, rule4045, rule4046, rule4047, rule4048, rule4049, rule4050, rule4051, rule4052, rule4053, rule4054, rule4055, rule4056, rule4057, rule4058, rule4059, rule4060, rule4061, rule4062, rule4063, rule4064, rule4065, rule4066, rule4067, rule4068, rule4069, rule4070, rule4071, rule4072, rule4073, rule4074, rule4075, rule4076, rule4077, rule4078, rule4079, rule4080, rule4081, rule4082, rule4083, rule4084, rule4085, rule4086, rule4087, rule4088, rule4089, rule4090, rule4091, rule4092, rule4093, rule4094, rule4095, rule4096, rule4097, rule4098, rule4099, rule4100, rule4101, rule4102, rule4103, rule4104, rule4105, rule4106, rule4107, rule4108, rule4109, rule4110, rule4111, rule4112, rule4113, rule4114, rule4115, rule4116, rule4117, rule4118, rule4119, rule4120, rule4121, rule4122, rule4123, rule4124, rule4125, rule4126, rule4127, rule4128, rule4129, rule4130, rule4131, rule4132, rule4133, rule4134, rule4135, rule4136, rule4137, rule4138, rule4139, rule4140, rule4141, rule4142, rule4143, rule4144, rule4145, rule4146, rule4147, rule4148, rule4149, rule4150, rule4151, rule4152, rule4153, rule4154, rule4155, rule4156, rule4157, rule4158, rule4159, rule4160, rule4161, rule4162, rule4163, rule4164, rule4165, rule4166, rule4167, rule4168, rule4169, rule4170, rule4171, rule4172, rule4173, rule4174, rule4175, rule4176, rule4177, rule4178, rule4179, rule4180, rule4181, rule4182, rule4183, rule4184, rule4185, rule4186, rule4187, rule4188, rule4189, rule4190, rule4191, rule4192, rule4193, rule4194, rule4195, rule4196, rule4197, rule4198, rule4199, rule4200, rule4201, rule4202, rule4203, rule4204, rule4205, rule4206, rule4207, rule4208, rule4209, rule4210, rule4211, rule4212, rule4213, rule4214, rule4215, rule4216, rule4217, rule4218, rule4219, rule4220, rule4221, rule4222, rule4223, rule4224, rule4225, rule4226, rule4227, rule4228, rule4229, rule4230, rule4231, rule4232, rule4233, rule4234, rule4235, rule4236, rule4237, rule4238, rule4239, rule4240, rule4241, rule4242, rule4243, rule4244, rule4245, rule4246, rule4247, rule4248, rule4249, rule4250, rule4251, rule4252, rule4253, rule4254, rule4255, rule4256, rule4257, rule4258, rule4259, rule4260, rule4261, rule4262, rule4263, rule4264, rule4265, rule4266, rule4267, rule4268, rule4269, rule4270, rule4271, rule4272, rule4273, rule4274, rule4275, rule4276, rule4277, rule4278, rule4279, rule4280, rule4281, rule4282, rule4283, rule4284, rule4285, rule4286, rule4287, rule4288, rule4289, rule4290, rule4291, rule4292, rule4293, rule4294, rule4295, rule4296, rule4297, rule4298, rule4299, rule4300, rule4301, rule4302, rule4303, rule4304, rule4305, rule4306, rule4307, rule4308, rule4309, rule4310, rule4311, rule4312, rule4313, rule4314, rule4315, rule4316, rule4317, rule4318, rule4319, rule4320, rule4321, rule4322, rule4323, rule4324, rule4325, rule4326, rule4327, rule4328, rule4329, rule4330, rule4331, rule4332, rule4333, rule4334, rule4335, rule4336, rule4337, rule4338, rule4339, rule4340, rule4341, rule4342, rule4343, rule4344, rule4345, rule4346, rule4347, rule4348, rule4349, rule4350, rule4351, rule4352, rule4353, rule4354, rule4355, rule4356, rule4357, rule4358, rule4359, rule4360, rule4361, rule4362, rule4363, rule4364, rule4365, rule4366, rule4367, rule4368, rule4369, rule4370, rule4371, rule4372, rule4373, rule4374, rule4375, rule4376, rule4377, rule4378, rule4379, rule4380, rule4381, rule4382, rule4383, rule4384, rule4385, rule4386, rule4387, rule4388, rule4389, rule4390, rule4391, rule4392, rule4393, rule4394, rule4395, rule4396, rule4397, rule4398, rule4399, rule4400, rule4401, rule4402, rule4403, rule4404, rule4405, rule4406, rule4407, rule4408, rule4409, rule4410, rule4411, rule4412, rule4413, rule4414, rule4415, rule4416, rule4417, rule4418, rule4419, rule4420, rule4421, rule4422, rule4423, rule4424, rule4425, rule4426, rule4427, rule4428, rule4429, rule4430, rule4431, rule4432, rule4433, rule4434, rule4435, rule4436, rule4437, rule4438, rule4439, rule4440, rule4441, rule4442, rule4443, rule4444, rule4445, rule4446, rule4447, rule4448, rule4449, rule4450, rule4451, rule4452, rule4453, rule4454, rule4455, rule4456, rule4457, rule4458, rule4459, rule4460, rule4461, rule4462, rule4463, rule4464, rule4465, rule4466, rule4467, rule4468, rule4469, rule4470, rule4471, rule4472, rule4473, rule4474, rule4475, rule4476, rule4477, rule4478, rule4479, rule4480, rule4481, rule4482, rule4483, rule4484, rule4485, rule4486, rule4487, rule4488, rule4489, rule4490, rule4491, rule4492, rule4493, rule4494, rule4495, rule4496, rule4497, rule4498, rule4499, rule4500, rule4501, rule4502, rule4503, rule4504, rule4505, rule4506, rule4507, rule4508, rule4509, rule4510, rule4511, rule4512, rule4513, rule4514, rule4515, rule4516, rule4517, rule4518, rule4519, rule4520, rule4521, rule4522, rule4523, rule4524, rule4525, rule4526, rule4527, rule4528, rule4529, rule4530, rule4531, rule4532, rule4533, rule4534, rule4535, rule4536, rule4537, rule4538, rule4539, rule4540, rule4541, rule4542, rule4543, rule4544, rule4545, rule4546, rule4547, rule4548, rule4549, rule4550, rule4551, rule4552, rule4553, rule4554, rule4555, rule4556, rule4557, rule4558, rule4559, rule4560, rule4561, rule4562, rule4563, rule4564, rule4565, rule4566, rule4567, rule4568, rule4569, rule4570, rule4571, rule4572, rule4573, rule4574, rule4575, rule4576, rule4577, rule4578, rule4579, rule4580, rule4581, rule4582, rule4583, rule4584, rule4585, rule4586, rule4587, rule4588, rule4589, rule4590, rule4591, rule4592, rule4593, rule4594, rule4595, rule4596, rule4597, rule4598, rule4599, rule4600, rule4601, rule4602, rule4603, rule4604, rule4605, rule4606, rule4607, rule4608, rule4609, rule4610, rule4611, rule4612, rule4613, rule4614, rule4615, rule4616, rule4617, rule4618, rule4619, rule4620, rule4621, rule4622, rule4623, rule4624, rule4625, rule4626, rule4627, rule4628, rule4629, rule4630, rule4631, rule4632, rule4633, rule4634, rule4635, rule4636, rule4637, rule4638, rule4639, rule4640, rule4641, rule4642, rule4643, rule4644, rule4645, rule4646, rule4647, rule4648, rule4649, rule4650, rule4651, rule4652, rule4653, rule4654, rule4655, rule4656, rule4657, rule4658, rule4659, rule4660, rule4661, rule4662, rule4663, rule4664, rule4665, rule4666, rule4667, rule4668, rule4669, rule4670, rule4671, rule4672, rule4673, rule4674, rule4675, rule4676, rule4677, rule4678, rule4679, rule4680, rule4681, rule4682, rule4683, rule4684, ]
04cbf6a1e56c071357b5d1204da78a9c3352475421727852eba875b3e410294b
''' This code is automatically generated. Never edit it manually. For details of generating the code see `rubi_parsing_guide.md` in `parsetools`. ''' from sympy.external import import_module matchpy = import_module("matchpy") from sympy.utilities.decorator import doctest_depends_on if matchpy: from matchpy import Pattern, ReplacementRule, CustomConstraint, is_match from sympy.integrals.rubi.utility_function import ( Int, Sum, Set, With, Module, Scan, MapAnd, FalseQ, ZeroQ, NegativeQ, NonzeroQ, FreeQ, NFreeQ, List, Log, PositiveQ, PositiveIntegerQ, NegativeIntegerQ, IntegerQ, IntegersQ, ComplexNumberQ, PureComplexNumberQ, RealNumericQ, PositiveOrZeroQ, NegativeOrZeroQ, FractionOrNegativeQ, NegQ, Equal, Unequal, IntPart, FracPart, RationalQ, ProductQ, SumQ, NonsumQ, Subst, First, Rest, SqrtNumberQ, SqrtNumberSumQ, LinearQ, Sqrt, ArcCosh, Coefficient, Denominator, Hypergeometric2F1, Not, Simplify, FractionalPart, IntegerPart, AppellF1, EllipticPi, EllipticE, EllipticF, ArcTan, ArcCot, ArcCoth, ArcTanh, ArcSin, ArcSinh, ArcCos, ArcCsc, ArcSec, ArcCsch, ArcSech, Sinh, Tanh, Cosh, Sech, Csch, Coth, LessEqual, Less, Greater, GreaterEqual, FractionQ, IntLinearcQ, Expand, IndependentQ, PowerQ, IntegerPowerQ, PositiveIntegerPowerQ, FractionalPowerQ, AtomQ, ExpQ, LogQ, Head, MemberQ, TrigQ, SinQ, CosQ, TanQ, CotQ, SecQ, CscQ, Sin, Cos, Tan, Cot, Sec, Csc, HyperbolicQ, SinhQ, CoshQ, TanhQ, CothQ, SechQ, CschQ, InverseTrigQ, SinCosQ, SinhCoshQ, LeafCount, Numerator, NumberQ, NumericQ, Length, ListQ, Im, Re, InverseHyperbolicQ, InverseFunctionQ, TrigHyperbolicFreeQ, InverseFunctionFreeQ, RealQ, EqQ, FractionalPowerFreeQ, ComplexFreeQ, PolynomialQ, FactorSquareFree, PowerOfLinearQ, Exponent, QuadraticQ, LinearPairQ, BinomialParts, TrinomialParts, PolyQ, EvenQ, OddQ, PerfectSquareQ, NiceSqrtAuxQ, NiceSqrtQ, Together, PosAux, PosQ, CoefficientList, ReplaceAll, ExpandLinearProduct, GCD, ContentFactor, NumericFactor, NonnumericFactors, MakeAssocList, GensymSubst, KernelSubst, ExpandExpression, Apart, SmartApart, MatchQ, PolynomialQuotientRemainder, FreeFactors, NonfreeFactors, RemoveContentAux, RemoveContent, FreeTerms, NonfreeTerms, ExpandAlgebraicFunction, CollectReciprocals, ExpandCleanup, AlgebraicFunctionQ, Coeff, LeadTerm, RemainingTerms, LeadFactor, RemainingFactors, LeadBase, LeadDegree, Numer, Denom, hypergeom, Expon, MergeMonomials, PolynomialDivide, BinomialQ, TrinomialQ, GeneralizedBinomialQ, GeneralizedTrinomialQ, FactorSquareFreeList, PerfectPowerTest, SquareFreeFactorTest, RationalFunctionQ, RationalFunctionFactors, NonrationalFunctionFactors, Reverse, RationalFunctionExponents, RationalFunctionExpand, ExpandIntegrand, SimplerQ, SimplerSqrtQ, SumSimplerQ, BinomialDegree, TrinomialDegree, CancelCommonFactors, SimplerIntegrandQ, GeneralizedBinomialDegree, GeneralizedBinomialParts, GeneralizedTrinomialDegree, GeneralizedTrinomialParts, MonomialQ, MonomialSumQ, MinimumMonomialExponent, MonomialExponent, LinearMatchQ, PowerOfLinearMatchQ, QuadraticMatchQ, CubicMatchQ, BinomialMatchQ, TrinomialMatchQ, GeneralizedBinomialMatchQ, GeneralizedTrinomialMatchQ, QuotientOfLinearsMatchQ, PolynomialTermQ, PolynomialTerms, NonpolynomialTerms, PseudoBinomialParts, NormalizePseudoBinomial, PseudoBinomialPairQ, PseudoBinomialQ, PolynomialGCD, PolyGCD, AlgebraicFunctionFactors, NonalgebraicFunctionFactors, QuotientOfLinearsP, QuotientOfLinearsParts, QuotientOfLinearsQ, Flatten, Sort, AbsurdNumberQ, AbsurdNumberFactors, NonabsurdNumberFactors, SumSimplerAuxQ, Prepend, Drop, CombineExponents, FactorInteger, FactorAbsurdNumber, SubstForInverseFunction, SubstForFractionalPower, SubstForFractionalPowerOfQuotientOfLinears, FractionalPowerOfQuotientOfLinears, SubstForFractionalPowerQ, SubstForFractionalPowerAuxQ, FractionalPowerOfSquareQ, FractionalPowerSubexpressionQ, Apply, FactorNumericGcd, MergeableFactorQ, MergeFactor, MergeFactors, TrigSimplifyQ, TrigSimplify, TrigSimplifyRecur, Order, FactorOrder, Smallest, OrderedQ, MinimumDegree, PositiveFactors, Sign, NonpositiveFactors, PolynomialInAuxQ, PolynomialInQ, ExponentInAux, ExponentIn, PolynomialInSubstAux, PolynomialInSubst, Distrib, DistributeDegree, FunctionOfPower, DivideDegreesOfFactors, MonomialFactor, FullSimplify, FunctionOfLinearSubst, FunctionOfLinear, NormalizeIntegrand, NormalizeIntegrandAux, NormalizeIntegrandFactor, NormalizeIntegrandFactorBase, NormalizeTogether, NormalizeLeadTermSigns, AbsorbMinusSign, NormalizeSumFactors, SignOfFactor, NormalizePowerOfLinear, SimplifyIntegrand, SimplifyTerm, TogetherSimplify, SmartSimplify, SubstForExpn, ExpandToSum, UnifySum, UnifyTerms, UnifyTerm, CalculusQ, FunctionOfInverseLinear, PureFunctionOfSinhQ, PureFunctionOfTanhQ, PureFunctionOfCoshQ, IntegerQuotientQ, OddQuotientQ, EvenQuotientQ, FindTrigFactor, FunctionOfSinhQ, FunctionOfCoshQ, OddHyperbolicPowerQ, FunctionOfTanhQ, FunctionOfTanhWeight, FunctionOfHyperbolicQ, SmartNumerator, SmartDenominator, SubstForAux, ActivateTrig, ExpandTrig, TrigExpand, SubstForTrig, SubstForHyperbolic, InertTrigFreeQ, LCM, SubstForFractionalPowerOfLinear, FractionalPowerOfLinear, InverseFunctionOfLinear, InertTrigQ, InertReciprocalQ, DeactivateTrig, FixInertTrigFunction, DeactivateTrigAux, PowerOfInertTrigSumQ, PiecewiseLinearQ, KnownTrigIntegrandQ, KnownSineIntegrandQ, KnownTangentIntegrandQ, KnownCotangentIntegrandQ, KnownSecantIntegrandQ, TryPureTanSubst, TryTanhSubst, TryPureTanhSubst, AbsurdNumberGCD, AbsurdNumberGCDList, ExpandTrigExpand, ExpandTrigReduce, ExpandTrigReduceAux, NormalizeTrig, TrigToExp, ExpandTrigToExp, TrigReduce, FunctionOfTrig, AlgebraicTrigFunctionQ, FunctionOfHyperbolic, FunctionOfQ, FunctionOfExpnQ, PureFunctionOfSinQ, PureFunctionOfCosQ, PureFunctionOfTanQ, PureFunctionOfCotQ, FunctionOfCosQ, FunctionOfSinQ, OddTrigPowerQ, FunctionOfTanQ, FunctionOfTanWeight, FunctionOfTrigQ, FunctionOfDensePolynomialsQ, FunctionOfLog, PowerVariableExpn, PowerVariableDegree, PowerVariableSubst, EulerIntegrandQ, FunctionOfSquareRootOfQuadratic, SquareRootOfQuadraticSubst, Divides, EasyDQ, ProductOfLinearPowersQ, Rt, NthRoot, AtomBaseQ, SumBaseQ, NegSumBaseQ, AllNegTermQ, SomeNegTermQ, TrigSquareQ, RtAux, TrigSquare, IntSum, IntTerm, Map2, ConstantFactor, SameQ, ReplacePart, CommonFactors, MostMainFactorPosition, FunctionOfExponentialQ, FunctionOfExponential, FunctionOfExponentialFunction, FunctionOfExponentialFunctionAux, FunctionOfExponentialTest, FunctionOfExponentialTestAux, stdev, rubi_test, If, IntQuadraticQ, IntBinomialQ, RectifyTangent, RectifyCotangent, Inequality, Condition, Simp, SimpHelp, SplitProduct, SplitSum, SubstFor, SubstForAux, FresnelS, FresnelC, Erfc, Erfi, Gamma, FunctionOfTrigOfLinearQ, ElementaryFunctionQ, Complex, UnsameQ, _SimpFixFactor, SimpFixFactor, _FixSimplify, FixSimplify, _SimplifyAntiderivativeSum, SimplifyAntiderivativeSum, _SimplifyAntiderivative, SimplifyAntiderivative, _TrigSimplifyAux, TrigSimplifyAux, Cancel, Part, PolyLog, D, Dist, Sum_doit, PolynomialQuotient, Floor, PolynomialRemainder, Factor, PolyLog, CosIntegral, SinIntegral, LogIntegral, SinhIntegral, CoshIntegral, Rule, Erf, PolyGamma, ExpIntegralEi, ExpIntegralE, LogGamma , UtilityOperator, Factorial, Zeta, ProductLog, DerivativeDivides, HypergeometricPFQ, IntHide, OneQ, Null, rubi_exp as exp, rubi_log as log, Discriminant, Negative, Quotient ) from sympy import (Integral, S, sqrt, And, Or, Integer, Float, Mod, I, Abs, simplify, Mul, Add, Pow, sign, EulerGamma) from sympy.integrals.rubi.symbol import WC from sympy.core.symbol import symbols, Symbol from sympy.functions import (sin, cos, tan, cot, csc, sec, sqrt, erf) from sympy.functions.elementary.hyperbolic import (acosh, asinh, atanh, acoth, acsch, asech, cosh, sinh, tanh, coth, sech, csch) from sympy.functions.elementary.trigonometric import (atan, acsc, asin, acot, acos, asec, atan2) from sympy import pi as Pi A_, B_, C_, F_, G_, H_, a_, b_, c_, d_, e_, f_, g_, h_, i_, j_, k_, l_, m_, n_, p_, q_, r_, t_, u_, v_, s_, w_, x_, y_, z_ = [WC(i) for i in 'ABCFGHabcdefghijklmnpqrtuvswxyz'] a1_, a2_, b1_, b2_, c1_, c2_, d1_, d2_, n1_, n2_, e1_, e2_, f1_, f2_, g1_, g2_, n1_, n2_, n3_, Pq_, Pm_, Px_, Qm_, Qr_, Qx_, jn_, mn_, non2_, RFx_, RGx_ = [WC(i) for i in ['a1', 'a2', 'b1', 'b2', 'c1', 'c2', 'd1', 'd2', 'n1', 'n2', 'e1', 'e2', 'f1', 'f2', 'g1', 'g2', 'n1', 'n2', 'n3', 'Pq', 'Pm', 'Px', 'Qm', 'Qr', 'Qx', 'jn', 'mn', 'non2', 'RFx', 'RGx']] i, ii , Pqq, Q, R, r, C, k, u = symbols('i ii Pqq Q R r C k u') _UseGamma = False ShowSteps = False StepCounter = None def special_functions(rubi): from sympy.integrals.rubi.constraints import cons67, cons2, cons3, cons66, cons21, cons1264, cons7, cons27, cons17, cons166, cons1957, cons1958, cons94, cons261, cons1959, cons1832, cons62, cons1960, cons1961, cons1962, cons247, cons1963, cons1964, cons1965, cons1831, cons4, cons1255, cons18, cons1359, cons1966, cons1967, cons168, cons1968, cons1969, cons31, cons1970, cons1971, cons1972, cons800, cons87, cons88, cons5, cons50, cons89, cons383, cons48, cons1973, cons1974, cons1975, cons52, cons1976, cons1099, cons125, cons1243, cons13, cons137, cons1379, cons1977, cons1978, cons196, cons1979, cons1980, cons1981, cons150, cons463, cons1765, cons163, cons948, cons949, cons1982, cons1983, cons803, cons1984, cons1985, cons1986, cons1987, cons338, cons1988, cons1989, cons1990, cons1991, cons1992, cons1993, cons38, cons1994, cons347, cons1995, cons1996, cons1997, cons1998, cons1999, cons2000, cons2001 pattern6739 = Pattern(Integral(Erf(x_*WC('b', S(1)) + WC('a', S(0))), x_), cons2, cons3, cons67) def replacement6739(x, a, b): rubi.append(6739) return Simp(exp(-(a + b*x)**S(2))/(sqrt(Pi)*b), x) + Simp((a + b*x)*Erf(a + b*x)/b, x) rule6739 = ReplacementRule(pattern6739, replacement6739) pattern6740 = Pattern(Integral(Erfc(x_*WC('b', S(1)) + WC('a', S(0))), x_), cons2, cons3, cons67) def replacement6740(x, a, b): rubi.append(6740) return -Simp(exp(-(a + b*x)**S(2))/(sqrt(Pi)*b), x) + Simp((a + b*x)*Erfc(a + b*x)/b, x) rule6740 = ReplacementRule(pattern6740, replacement6740) pattern6741 = Pattern(Integral(Erfi(x_*WC('b', S(1)) + WC('a', S(0))), x_), cons2, cons3, cons67) def replacement6741(x, a, b): rubi.append(6741) return -Simp(exp((a + b*x)**S(2))/(sqrt(Pi)*b), x) + Simp((a + b*x)*Erfi(a + b*x)/b, x) rule6741 = ReplacementRule(pattern6741, replacement6741) pattern6742 = Pattern(Integral(Erf(x_*WC('b', S(1)))/x_, x_), cons3, cons3) def replacement6742(x, b): rubi.append(6742) return Simp(S(2)*b*x*HypergeometricPFQ(List(S(1)/2, S(1)/2), List(S(3)/2, S(3)/2), -b**S(2)*x**S(2))/sqrt(Pi), x) rule6742 = ReplacementRule(pattern6742, replacement6742) pattern6743 = Pattern(Integral(Erfc(x_*WC('b', S(1)))/x_, x_), cons3, cons3) def replacement6743(x, b): rubi.append(6743) return -Int(Erf(b*x)/x, x) + Simp(log(x), x) rule6743 = ReplacementRule(pattern6743, replacement6743) pattern6744 = Pattern(Integral(Erfi(x_*WC('b', S(1)))/x_, x_), cons3, cons3) def replacement6744(x, b): rubi.append(6744) return Simp(S(2)*b*x*HypergeometricPFQ(List(S(1)/2, S(1)/2), List(S(3)/2, S(3)/2), b**S(2)*x**S(2))/sqrt(Pi), x) rule6744 = ReplacementRule(pattern6744, replacement6744) pattern6745 = Pattern(Integral(x_**WC('m', S(1))*Erf(x_*WC('b', S(1)) + WC('a', S(0))), x_), cons2, cons3, cons21, cons66) def replacement6745(x, m, a, b): rubi.append(6745) return -Dist(S(2)*b/(sqrt(Pi)*(m + S(1))), Int(x**(m + S(1))*exp(-(a + b*x)**S(2)), x), x) + Simp(x**(m + S(1))*Erf(a + b*x)/(m + S(1)), x) rule6745 = ReplacementRule(pattern6745, replacement6745) pattern6746 = Pattern(Integral(x_**WC('m', S(1))*Erfc(x_*WC('b', S(1)) + WC('a', S(0))), x_), cons2, cons3, cons21, cons66) def replacement6746(x, m, a, b): rubi.append(6746) return Dist(S(2)*b/(sqrt(Pi)*(m + S(1))), Int(x**(m + S(1))*exp(-(a + b*x)**S(2)), x), x) + Simp(x**(m + S(1))*Erfc(a + b*x)/(m + S(1)), x) rule6746 = ReplacementRule(pattern6746, replacement6746) pattern6747 = Pattern(Integral(x_**WC('m', S(1))*Erfi(x_*WC('b', S(1)) + WC('a', S(0))), x_), cons2, cons3, cons21, cons66) def replacement6747(x, m, a, b): rubi.append(6747) return -Dist(S(2)*b/(sqrt(Pi)*(m + S(1))), Int(x**(m + S(1))*exp((a + b*x)**S(2)), x), x) + Simp(x**(m + S(1))*Erfi(a + b*x)/(m + S(1)), x) rule6747 = ReplacementRule(pattern6747, replacement6747) pattern6748 = Pattern(Integral(x_*Erf(x_*WC('b', S(1)) + WC('a', S(0)))*exp(x_**S(2)*WC('d', S(1)) + WC('c', S(0))), x_), cons2, cons3, cons7, cons27, cons1264) def replacement6748(b, d, c, a, x): rubi.append(6748) return -Dist(b/(sqrt(Pi)*d), Int(exp(-a**S(2) - S(2)*a*b*x + c - x**S(2)*(b**S(2) - d)), x), x) + Simp(Erf(a + b*x)*exp(c + d*x**S(2))/(S(2)*d), x) rule6748 = ReplacementRule(pattern6748, replacement6748) pattern6749 = Pattern(Integral(x_*Erfc(x_*WC('b', S(1)) + WC('a', S(0)))*exp(x_**S(2)*WC('d', S(1)) + WC('c', S(0))), x_), cons2, cons3, cons7, cons27, cons1264) def replacement6749(b, d, c, a, x): rubi.append(6749) return Dist(b/(sqrt(Pi)*d), Int(exp(-a**S(2) - S(2)*a*b*x + c - x**S(2)*(b**S(2) - d)), x), x) + Simp(Erfc(a + b*x)*exp(c + d*x**S(2))/(S(2)*d), x) rule6749 = ReplacementRule(pattern6749, replacement6749) pattern6750 = Pattern(Integral(x_*Erfi(x_*WC('b', S(1)) + WC('a', S(0)))*exp(x_**S(2)*WC('d', S(1)) + WC('c', S(0))), x_), cons2, cons3, cons7, cons27, cons1264) def replacement6750(b, d, c, a, x): rubi.append(6750) return -Dist(b/(sqrt(Pi)*d), Int(exp(a**S(2) + S(2)*a*b*x + c + x**S(2)*(b**S(2) + d)), x), x) + Simp(Erfi(a + b*x)*exp(c + d*x**S(2))/(S(2)*d), x) rule6750 = ReplacementRule(pattern6750, replacement6750) pattern6751 = Pattern(Integral(x_**m_*Erf(x_*WC('b', S(1)) + WC('a', S(0)))*exp(x_**S(2)*WC('d', S(1)) + WC('c', S(0))), x_), cons2, cons3, cons7, cons27, cons17, cons166) def replacement6751(m, b, d, c, a, x): rubi.append(6751) return -Dist((m + S(-1))/(S(2)*d), Int(x**(m + S(-2))*Erf(a + b*x)*exp(c + d*x**S(2)), x), x) - Dist(b/(sqrt(Pi)*d), Int(x**(m + S(-1))*exp(-a**S(2) - S(2)*a*b*x + c - x**S(2)*(b**S(2) - d)), x), x) + Simp(x**(m + S(-1))*Erf(a + b*x)*exp(c + d*x**S(2))/(S(2)*d), x) rule6751 = ReplacementRule(pattern6751, replacement6751) pattern6752 = Pattern(Integral(x_**m_*Erfc(x_*WC('b', S(1)) + WC('a', S(0)))*exp(x_**S(2)*WC('d', S(1)) + WC('c', S(0))), x_), cons2, cons3, cons7, cons27, cons17, cons166) def replacement6752(m, b, d, c, a, x): rubi.append(6752) return -Dist((m + S(-1))/(S(2)*d), Int(x**(m + S(-2))*Erfc(a + b*x)*exp(c + d*x**S(2)), x), x) + Dist(b/(sqrt(Pi)*d), Int(x**(m + S(-1))*exp(-a**S(2) - S(2)*a*b*x + c - x**S(2)*(b**S(2) - d)), x), x) + Simp(x**(m + S(-1))*Erfc(a + b*x)*exp(c + d*x**S(2))/(S(2)*d), x) rule6752 = ReplacementRule(pattern6752, replacement6752) pattern6753 = Pattern(Integral(x_**m_*Erfi(x_*WC('b', S(1)) + WC('a', S(0)))*exp(x_**S(2)*WC('d', S(1)) + WC('c', S(0))), x_), cons2, cons3, cons7, cons27, cons17, cons166) def replacement6753(m, b, d, c, a, x): rubi.append(6753) return -Dist((m + S(-1))/(S(2)*d), Int(x**(m + S(-2))*Erfi(a + b*x)*exp(c + d*x**S(2)), x), x) - Dist(b/(sqrt(Pi)*d), Int(x**(m + S(-1))*exp(a**S(2) + S(2)*a*b*x + c + x**S(2)*(b**S(2) + d)), x), x) + Simp(x**(m + S(-1))*Erfi(a + b*x)*exp(c + d*x**S(2))/(S(2)*d), x) rule6753 = ReplacementRule(pattern6753, replacement6753) pattern6754 = Pattern(Integral(Erf(x_*WC('b', S(1)))*exp(x_**S(2)*WC('d', S(1)) + WC('c', S(0)))/x_, x_), cons3, cons1957) def replacement6754(d, c, b, x): rubi.append(6754) return Simp(S(2)*b*x*HypergeometricPFQ(List(S(1)/2, S(1)), List(S(3)/2, S(3)/2), d*x**S(2))*exp(c)/sqrt(Pi), x) rule6754 = ReplacementRule(pattern6754, replacement6754) pattern6755 = Pattern(Integral(Erfc(x_*WC('b', S(1)))*exp(x_**S(2)*WC('d', S(1)) + WC('c', S(0)))/x_, x_), cons3, cons1957) def replacement6755(d, c, b, x): rubi.append(6755) return Int(exp(c + d*x**S(2))/x, x) - Int(Erf(b*x)*exp(c + d*x**S(2))/x, x) rule6755 = ReplacementRule(pattern6755, replacement6755) pattern6756 = Pattern(Integral(Erfi(x_*WC('b', S(1)))*exp(x_**S(2)*WC('d', S(1)) + WC('c', S(0)))/x_, x_), cons3, cons1958) def replacement6756(d, c, b, x): rubi.append(6756) return Simp(S(2)*b*x*HypergeometricPFQ(List(S(1)/2, S(1)), List(S(3)/2, S(3)/2), d*x**S(2))*exp(c)/sqrt(Pi), x) rule6756 = ReplacementRule(pattern6756, replacement6756) pattern6757 = Pattern(Integral(x_**m_*Erf(x_*WC('b', S(1)) + WC('a', S(0)))*exp(x_**S(2)*WC('d', S(1)) + WC('c', S(0))), x_), cons2, cons3, cons7, cons27, cons17, cons94) def replacement6757(m, b, d, c, a, x): rubi.append(6757) return -Dist(S(2)*d/(m + S(1)), Int(x**(m + S(2))*Erf(a + b*x)*exp(c + d*x**S(2)), x), x) - Dist(S(2)*b/(sqrt(Pi)*(m + S(1))), Int(x**(m + S(1))*exp(-a**S(2) - S(2)*a*b*x + c - x**S(2)*(b**S(2) - d)), x), x) + Simp(x**(m + S(1))*Erf(a + b*x)*exp(c + d*x**S(2))/(m + S(1)), x) rule6757 = ReplacementRule(pattern6757, replacement6757) pattern6758 = Pattern(Integral(x_**m_*Erfc(x_*WC('b', S(1)) + WC('a', S(0)))*exp(x_**S(2)*WC('d', S(1)) + WC('c', S(0))), x_), cons2, cons3, cons7, cons27, cons17, cons94) def replacement6758(m, b, d, c, a, x): rubi.append(6758) return -Dist(S(2)*d/(m + S(1)), Int(x**(m + S(2))*Erfc(a + b*x)*exp(c + d*x**S(2)), x), x) + Dist(S(2)*b/(sqrt(Pi)*(m + S(1))), Int(x**(m + S(1))*exp(-a**S(2) - S(2)*a*b*x + c - x**S(2)*(b**S(2) - d)), x), x) + Simp(x**(m + S(1))*Erfc(a + b*x)*exp(c + d*x**S(2))/(m + S(1)), x) rule6758 = ReplacementRule(pattern6758, replacement6758) pattern6759 = Pattern(Integral(x_**m_*Erfi(x_*WC('b', S(1)) + WC('a', S(0)))*exp(x_**S(2)*WC('d', S(1)) + WC('c', S(0))), x_), cons2, cons3, cons7, cons27, cons17, cons94) def replacement6759(m, b, d, c, a, x): rubi.append(6759) return -Dist(S(2)*d/(m + S(1)), Int(x**(m + S(2))*Erfi(a + b*x)*exp(c + d*x**S(2)), x), x) - Dist(S(2)*b/(sqrt(Pi)*(m + S(1))), Int(x**(m + S(1))*exp(a**S(2) + S(2)*a*b*x + c + x**S(2)*(b**S(2) + d)), x), x) + Simp(x**(m + S(1))*Erfi(a + b*x)*exp(c + d*x**S(2))/(m + S(1)), x) rule6759 = ReplacementRule(pattern6759, replacement6759) pattern6760 = Pattern(Integral(Erf(x_*WC('b', S(1)) + WC('a', S(0)))**S(2), x_), cons2, cons3, cons67) def replacement6760(x, a, b): rubi.append(6760) return -Dist(S(4)/sqrt(Pi), Int((a + b*x)*Erf(a + b*x)*exp(-(a + b*x)**S(2)), x), x) + Simp((a + b*x)*Erf(a + b*x)**S(2)/b, x) rule6760 = ReplacementRule(pattern6760, replacement6760) pattern6761 = Pattern(Integral(Erfc(x_*WC('b', S(1)) + WC('a', S(0)))**S(2), x_), cons2, cons3, cons67) def replacement6761(x, a, b): rubi.append(6761) return Dist(S(4)/sqrt(Pi), Int((a + b*x)*Erfc(a + b*x)*exp(-(a + b*x)**S(2)), x), x) + Simp((a + b*x)*Erfc(a + b*x)**S(2)/b, x) rule6761 = ReplacementRule(pattern6761, replacement6761) pattern6762 = Pattern(Integral(Erfi(x_*WC('b', S(1)) + WC('a', S(0)))**S(2), x_), cons2, cons3, cons67) def replacement6762(x, a, b): rubi.append(6762) return -Dist(S(4)/sqrt(Pi), Int((a + b*x)*Erfi(a + b*x)*exp((a + b*x)**S(2)), x), x) + Simp((a + b*x)*Erfi(a + b*x)**S(2)/b, x) rule6762 = ReplacementRule(pattern6762, replacement6762) pattern6763 = Pattern(Integral(x_**WC('m', S(1))*Erf(x_*WC('b', S(1)))**S(2), x_), cons3, cons17, cons261, cons1959) def replacement6763(x, m, b): rubi.append(6763) return -Dist(S(4)*b/(sqrt(Pi)*(m + S(1))), Int(x**(m + S(1))*Erf(b*x)*exp(-b**S(2)*x**S(2)), x), x) + Simp(x**(m + S(1))*Erf(b*x)**S(2)/(m + S(1)), x) rule6763 = ReplacementRule(pattern6763, replacement6763) pattern6764 = Pattern(Integral(x_**WC('m', S(1))*Erfc(x_*WC('b', S(1)))**S(2), x_), cons3, cons17, cons1832, cons1959) def replacement6764(x, m, b): rubi.append(6764) return Dist(S(4)*b/(sqrt(Pi)*(m + S(1))), Int(x**(m + S(1))*Erfc(b*x)*exp(-b**S(2)*x**S(2)), x), x) + Simp(x**(m + S(1))*Erfc(b*x)**S(2)/(m + S(1)), x) rule6764 = ReplacementRule(pattern6764, replacement6764) pattern6765 = Pattern(Integral(x_**WC('m', S(1))*Erfi(x_*WC('b', S(1)))**S(2), x_), cons3, cons17, cons1832, cons1959) def replacement6765(x, m, b): rubi.append(6765) return -Dist(S(4)*b/(sqrt(Pi)*(m + S(1))), Int(x**(m + S(1))*Erfi(b*x)*exp(b**S(2)*x**S(2)), x), x) + Simp(x**(m + S(1))*Erfi(b*x)**S(2)/(m + S(1)), x) rule6765 = ReplacementRule(pattern6765, replacement6765) pattern6766 = Pattern(Integral(x_**WC('m', S(1))*Erf(a_ + x_*WC('b', S(1)))**S(2), x_), cons2, cons3, cons62) def replacement6766(x, m, b, a): rubi.append(6766) return Dist(S(1)/b, Subst(Int((-a/b + x/b)**m*Erf(x)**S(2), x), x, a + b*x), x) rule6766 = ReplacementRule(pattern6766, replacement6766) pattern6767 = Pattern(Integral(x_**WC('m', S(1))*Erfc(a_ + x_*WC('b', S(1)))**S(2), x_), cons2, cons3, cons62) def replacement6767(x, m, b, a): rubi.append(6767) return Dist(S(1)/b, Subst(Int((-a/b + x/b)**m*Erfc(x)**S(2), x), x, a + b*x), x) rule6767 = ReplacementRule(pattern6767, replacement6767) pattern6768 = Pattern(Integral(x_**WC('m', S(1))*Erfi(a_ + x_*WC('b', S(1)))**S(2), x_), cons2, cons3, cons62) def replacement6768(x, m, b, a): rubi.append(6768) return Dist(S(1)/b, Subst(Int((-a/b + x/b)**m*Erfi(x)**S(2), x), x, a + b*x), x) rule6768 = ReplacementRule(pattern6768, replacement6768) pattern6769 = Pattern(Integral(FresnelS(x_*WC('b', S(1)) + WC('a', S(0))), x_), cons2, cons3, cons67) def replacement6769(x, a, b): rubi.append(6769) return Simp(cos(Pi*(a + b*x)**S(2)/S(2))/(Pi*b), x) + Simp((a + b*x)*FresnelS(a + b*x)/b, x) rule6769 = ReplacementRule(pattern6769, replacement6769) pattern6770 = Pattern(Integral(FresnelC(x_*WC('b', S(1)) + WC('a', S(0))), x_), cons2, cons3, cons67) def replacement6770(x, a, b): rubi.append(6770) return -Simp(sin(Pi*(a + b*x)**S(2)/S(2))/(Pi*b), x) + Simp((a + b*x)*FresnelC(a + b*x)/b, x) rule6770 = ReplacementRule(pattern6770, replacement6770) pattern6771 = Pattern(Integral(FresnelS(x_*WC('b', S(1)))/x_, x_), cons3, cons3) def replacement6771(x, b): rubi.append(6771) return Simp(I*b*x*HypergeometricPFQ(List(S(1)/2, S(1)/2), List(S(3)/2, S(3)/2), -I*Pi*b**S(2)*x**S(2)/S(2))/S(2), x) - Simp(I*b*x*HypergeometricPFQ(List(S(1)/2, S(1)/2), List(S(3)/2, S(3)/2), I*Pi*b**S(2)*x**S(2)/S(2))/S(2), x) rule6771 = ReplacementRule(pattern6771, replacement6771) pattern6772 = Pattern(Integral(FresnelC(x_*WC('b', S(1)))/x_, x_), cons3, cons3) def replacement6772(x, b): rubi.append(6772) return Simp(b*x*HypergeometricPFQ(List(S(1)/2, S(1)/2), List(S(3)/2, S(3)/2), -I*Pi*b**S(2)*x**S(2)/S(2))/S(2), x) + Simp(b*x*HypergeometricPFQ(List(S(1)/2, S(1)/2), List(S(3)/2, S(3)/2), I*Pi*b**S(2)*x**S(2)/S(2))/S(2), x) rule6772 = ReplacementRule(pattern6772, replacement6772) pattern6773 = Pattern(Integral(x_**WC('m', S(1))*FresnelS(x_*WC('b', S(1)) + WC('a', S(0))), x_), cons2, cons3, cons21, cons66) def replacement6773(x, m, a, b): rubi.append(6773) return -Dist(b/(m + S(1)), Int(x**(m + S(1))*sin(Pi*(a + b*x)**S(2)/S(2)), x), x) + Simp(x**(m + S(1))*FresnelS(a + b*x)/(m + S(1)), x) rule6773 = ReplacementRule(pattern6773, replacement6773) pattern6774 = Pattern(Integral(x_**WC('m', S(1))*FresnelC(x_*WC('b', S(1)) + WC('a', S(0))), x_), cons2, cons3, cons21, cons66) def replacement6774(x, m, a, b): rubi.append(6774) return -Dist(b/(m + S(1)), Int(x**(m + S(1))*cos(Pi*(a + b*x)**S(2)/S(2)), x), x) + Simp(x**(m + S(1))*FresnelC(a + b*x)/(m + S(1)), x) rule6774 = ReplacementRule(pattern6774, replacement6774) pattern6775 = Pattern(Integral(FresnelS(x_*WC('b', S(1)) + WC('a', S(0)))**S(2), x_), cons2, cons3, cons67) def replacement6775(x, a, b): rubi.append(6775) return -Dist(S(2), Int((a + b*x)*FresnelS(a + b*x)*sin(Pi*(a + b*x)**S(2)/S(2)), x), x) + Simp((a + b*x)*FresnelS(a + b*x)**S(2)/b, x) rule6775 = ReplacementRule(pattern6775, replacement6775) pattern6776 = Pattern(Integral(FresnelC(x_*WC('b', S(1)) + WC('a', S(0)))**S(2), x_), cons2, cons3, cons67) def replacement6776(x, a, b): rubi.append(6776) return -Dist(S(2), Int((a + b*x)*FresnelC(a + b*x)*cos(Pi*(a + b*x)**S(2)/S(2)), x), x) + Simp((a + b*x)*FresnelC(a + b*x)**S(2)/b, x) rule6776 = ReplacementRule(pattern6776, replacement6776) pattern6777 = Pattern(Integral(x_**m_*FresnelS(x_*WC('b', S(1)))**S(2), x_), cons3, cons17, cons1832, cons1960) def replacement6777(x, m, b): rubi.append(6777) return -Dist(S(2)*b/(m + S(1)), Int(x**(m + S(1))*FresnelS(b*x)*sin(Pi*b**S(2)*x**S(2)/S(2)), x), x) + Simp(x**(m + S(1))*FresnelS(b*x)**S(2)/(m + S(1)), x) rule6777 = ReplacementRule(pattern6777, replacement6777) pattern6778 = Pattern(Integral(x_**m_*FresnelC(x_*WC('b', S(1)))**S(2), x_), cons3, cons17, cons1832, cons1960) def replacement6778(x, m, b): rubi.append(6778) return -Dist(S(2)*b/(m + S(1)), Int(x**(m + S(1))*FresnelC(b*x)*cos(Pi*b**S(2)*x**S(2)/S(2)), x), x) + Simp(x**(m + S(1))*FresnelC(b*x)**S(2)/(m + S(1)), x) rule6778 = ReplacementRule(pattern6778, replacement6778) pattern6779 = Pattern(Integral(x_*FresnelS(x_*WC('b', S(1)))*sin(x_**S(2)*WC('c', S(1))), x_), cons3, cons7, cons1961) def replacement6779(x, c, b): rubi.append(6779) return Dist(S(1)/(S(2)*Pi*b), Int(sin(Pi*b**S(2)*x**S(2)), x), x) - Simp(FresnelS(b*x)*cos(Pi*b**S(2)*x**S(2)/S(2))/(Pi*b**S(2)), x) rule6779 = ReplacementRule(pattern6779, replacement6779) pattern6780 = Pattern(Integral(x_*FresnelC(x_*WC('b', S(1)))*cos(x_**S(2)*WC('c', S(1))), x_), cons3, cons7, cons1961) def replacement6780(x, c, b): rubi.append(6780) return -Dist(S(1)/(S(2)*Pi*b), Int(sin(Pi*b**S(2)*x**S(2)), x), x) + Simp(FresnelC(b*x)*sin(Pi*b**S(2)*x**S(2)/S(2))/(Pi*b**S(2)), x) rule6780 = ReplacementRule(pattern6780, replacement6780) pattern6781 = Pattern(Integral(x_**m_*FresnelS(x_*WC('b', S(1)))*sin(x_**S(2)*WC('c', S(1))), x_), cons3, cons7, cons1961, cons17, cons166, cons1962) def replacement6781(x, m, c, b): rubi.append(6781) return Dist(S(1)/(S(2)*Pi*b), Int(x**(m + S(-1))*sin(Pi*b**S(2)*x**S(2)), x), x) + Dist((m + S(-1))/(Pi*b**S(2)), Int(x**(m + S(-2))*FresnelS(b*x)*cos(Pi*b**S(2)*x**S(2)/S(2)), x), x) - Simp(x**(m + S(-1))*FresnelS(b*x)*cos(Pi*b**S(2)*x**S(2)/S(2))/(Pi*b**S(2)), x) rule6781 = ReplacementRule(pattern6781, replacement6781) pattern6782 = Pattern(Integral(x_**m_*FresnelC(x_*WC('b', S(1)))*cos(x_**S(2)*WC('c', S(1))), x_), cons3, cons7, cons1961, cons17, cons166, cons1962) def replacement6782(x, m, c, b): rubi.append(6782) return -Dist(S(1)/(S(2)*Pi*b), Int(x**(m + S(-1))*sin(Pi*b**S(2)*x**S(2)), x), x) - Dist((m + S(-1))/(Pi*b**S(2)), Int(x**(m + S(-2))*FresnelC(b*x)*sin(Pi*b**S(2)*x**S(2)/S(2)), x), x) + Simp(x**(m + S(-1))*FresnelC(b*x)*sin(Pi*b**S(2)*x**S(2)/S(2))/(Pi*b**S(2)), x) rule6782 = ReplacementRule(pattern6782, replacement6782) pattern6783 = Pattern(Integral(x_**m_*FresnelS(x_*WC('b', S(1)))*sin(x_**S(2)*WC('c', S(1))), x_), cons3, cons7, cons1961, cons17, cons247, cons1963) def replacement6783(x, m, c, b): rubi.append(6783) return Dist(b/(S(2)*m + S(2)), Int(x**(m + S(1))*cos(Pi*b**S(2)*x**S(2)), x), x) - Dist(Pi*b**S(2)/(m + S(1)), Int(x**(m + S(2))*FresnelS(b*x)*cos(Pi*b**S(2)*x**S(2)/S(2)), x), x) - Simp(b*x**(m + S(2))/(S(2)*(m + S(1))*(m + S(2))), x) + Simp(x**(m + S(1))*FresnelS(b*x)*sin(Pi*b**S(2)*x**S(2)/S(2))/(m + S(1)), x) rule6783 = ReplacementRule(pattern6783, replacement6783) pattern6784 = Pattern(Integral(x_**m_*FresnelC(x_*WC('b', S(1)))*cos(x_**S(2)*WC('c', S(1))), x_), cons3, cons7, cons1961, cons17, cons247, cons1963) def replacement6784(x, m, c, b): rubi.append(6784) return -Dist(b/(S(2)*m + S(2)), Int(x**(m + S(1))*cos(Pi*b**S(2)*x**S(2)), x), x) + Dist(Pi*b**S(2)/(m + S(1)), Int(x**(m + S(2))*FresnelC(b*x)*sin(Pi*b**S(2)*x**S(2)/S(2)), x), x) - Simp(b*x**(m + S(2))/(S(2)*(m + S(1))*(m + S(2))), x) + Simp(x**(m + S(1))*FresnelC(b*x)*cos(Pi*b**S(2)*x**S(2)/S(2))/(m + S(1)), x) rule6784 = ReplacementRule(pattern6784, replacement6784) pattern6785 = Pattern(Integral(x_*FresnelS(x_*WC('b', S(1)))*cos(x_**S(2)*WC('c', S(1))), x_), cons3, cons7, cons1961) def replacement6785(x, c, b): rubi.append(6785) return Dist(S(1)/(S(2)*Pi*b), Int(cos(Pi*b**S(2)*x**S(2)), x), x) - Simp(x/(S(2)*Pi*b), x) + Simp(FresnelS(b*x)*sin(Pi*b**S(2)*x**S(2)/S(2))/(Pi*b**S(2)), x) rule6785 = ReplacementRule(pattern6785, replacement6785) pattern6786 = Pattern(Integral(x_*FresnelC(x_*WC('b', S(1)))*sin(x_**S(2)*WC('c', S(1))), x_), cons3, cons7, cons1961) def replacement6786(x, c, b): rubi.append(6786) return Dist(S(1)/(S(2)*Pi*b), Int(cos(Pi*b**S(2)*x**S(2)), x), x) + Simp(x/(S(2)*Pi*b), x) - Simp(FresnelC(b*x)*cos(Pi*b**S(2)*x**S(2)/S(2))/(Pi*b**S(2)), x) rule6786 = ReplacementRule(pattern6786, replacement6786) pattern6787 = Pattern(Integral(x_**m_*FresnelS(x_*WC('b', S(1)))*cos(x_**S(2)*WC('c', S(1))), x_), cons3, cons7, cons1961, cons17, cons166, cons1964) def replacement6787(x, m, c, b): rubi.append(6787) return Dist(S(1)/(S(2)*Pi*b), Int(x**(m + S(-1))*cos(Pi*b**S(2)*x**S(2)), x), x) - Dist((m + S(-1))/(Pi*b**S(2)), Int(x**(m + S(-2))*FresnelS(b*x)*sin(Pi*b**S(2)*x**S(2)/S(2)), x), x) - Simp(x**m/(S(2)*Pi*b*m), x) + Simp(x**(m + S(-1))*FresnelS(b*x)*sin(Pi*b**S(2)*x**S(2)/S(2))/(Pi*b**S(2)), x) rule6787 = ReplacementRule(pattern6787, replacement6787) pattern6788 = Pattern(Integral(x_**m_*FresnelC(x_*WC('b', S(1)))*sin(x_**S(2)*WC('c', S(1))), x_), cons3, cons7, cons1961, cons17, cons166, cons1964) def replacement6788(x, m, c, b): rubi.append(6788) return Dist(S(1)/(S(2)*Pi*b), Int(x**(m + S(-1))*cos(Pi*b**S(2)*x**S(2)), x), x) + Dist((m + S(-1))/(Pi*b**S(2)), Int(x**(m + S(-2))*FresnelC(b*x)*cos(Pi*b**S(2)*x**S(2)/S(2)), x), x) + Simp(x**m/(S(2)*Pi*b*m), x) - Simp(x**(m + S(-1))*FresnelC(b*x)*cos(Pi*b**S(2)*x**S(2)/S(2))/(Pi*b**S(2)), x) rule6788 = ReplacementRule(pattern6788, replacement6788) pattern6789 = Pattern(Integral(x_**m_*FresnelS(x_*WC('b', S(1)))*cos(x_**S(2)*WC('c', S(1))), x_), cons3, cons7, cons1961, cons17, cons94, cons1965) def replacement6789(x, m, c, b): rubi.append(6789) return -Dist(b/(S(2)*m + S(2)), Int(x**(m + S(1))*sin(Pi*b**S(2)*x**S(2)), x), x) + Dist(Pi*b**S(2)/(m + S(1)), Int(x**(m + S(2))*FresnelS(b*x)*sin(Pi*b**S(2)*x**S(2)/S(2)), x), x) + Simp(x**(m + S(1))*FresnelS(b*x)*cos(Pi*b**S(2)*x**S(2)/S(2))/(m + S(1)), x) rule6789 = ReplacementRule(pattern6789, replacement6789) pattern6790 = Pattern(Integral(x_**m_*FresnelC(x_*WC('b', S(1)))*sin(x_**S(2)*WC('c', S(1))), x_), cons3, cons7, cons1961, cons17, cons94, cons1965) def replacement6790(x, m, c, b): rubi.append(6790) return -Dist(b/(S(2)*m + S(2)), Int(x**(m + S(1))*sin(Pi*b**S(2)*x**S(2)), x), x) - Dist(Pi*b**S(2)/(m + S(1)), Int(x**(m + S(2))*FresnelC(b*x)*cos(Pi*b**S(2)*x**S(2)/S(2)), x), x) + Simp(x**(m + S(1))*FresnelC(b*x)*sin(Pi*b**S(2)*x**S(2)/S(2))/(m + S(1)), x) rule6790 = ReplacementRule(pattern6790, replacement6790) pattern6791 = Pattern(Integral(ExpIntegralE(n_, x_*WC('b', S(1)) + WC('a', S(0))), x_), cons2, cons3, cons4, cons1831) def replacement6791(x, a, n, b): rubi.append(6791) return -Simp(ExpIntegralE(n + S(1), a + b*x)/b, x) rule6791 = ReplacementRule(pattern6791, replacement6791) pattern6792 = Pattern(Integral(x_**WC('m', S(1))*ExpIntegralE(n_, x_*WC('b', S(1))), x_), cons3, cons1255, cons62) def replacement6792(x, m, n, b): rubi.append(6792) return Dist(m/b, Int(x**(m + S(-1))*ExpIntegralE(n + S(1), b*x), x), x) - Simp(x**m*ExpIntegralE(n + S(1), b*x)/b, x) rule6792 = ReplacementRule(pattern6792, replacement6792) pattern6793 = Pattern(Integral(ExpIntegralE(S(1), x_*WC('b', S(1)))/x_, x_), cons3, cons3) def replacement6793(x, b): rubi.append(6793) return -Simp(EulerGamma*log(x), x) + Simp(b*x*HypergeometricPFQ(List(S(1), S(1), S(1)), List(S(2), S(2), S(2)), -b*x), x) - Simp(log(b*x)**S(2)/S(2), x) rule6793 = ReplacementRule(pattern6793, replacement6793) pattern6794 = Pattern(Integral(x_**m_*ExpIntegralE(n_, x_*WC('b', S(1))), x_), cons3, cons1255, cons17, cons94) def replacement6794(x, m, n, b): rubi.append(6794) return Dist(b/(m + S(1)), Int(x**(m + S(1))*ExpIntegralE(n + S(-1), b*x), x), x) + Simp(x**(m + S(1))*ExpIntegralE(n, b*x)/(m + S(1)), x) rule6794 = ReplacementRule(pattern6794, replacement6794) pattern6795 = Pattern(Integral(x_**m_*ExpIntegralE(n_, x_*WC('b', S(1))), x_), cons3, cons21, cons4, cons1255, cons18) def replacement6795(x, m, n, b): rubi.append(6795) return -Simp(x**(m + S(1))*HypergeometricPFQ(List(m + S(1), m + S(1)), List(m + S(2), m + S(2)), -b*x)/(m + S(1))**S(2), x) + Simp(x**m*(b*x)**(-m)*Gamma(m + S(1))*log(x)/b, x) rule6795 = ReplacementRule(pattern6795, replacement6795) pattern6796 = Pattern(Integral(x_**WC('m', S(1))*ExpIntegralE(n_, x_*WC('b', S(1))), x_), cons3, cons21, cons4, cons1359) def replacement6796(x, m, n, b): rubi.append(6796) return -Simp(x**(m + S(1))*ExpIntegralE(-m, b*x)/(m + n), x) + Simp(x**(m + S(1))*ExpIntegralE(n, b*x)/(m + n), x) rule6796 = ReplacementRule(pattern6796, replacement6796) pattern6797 = Pattern(Integral(x_**WC('m', S(1))*ExpIntegralE(n_, a_ + x_*WC('b', S(1))), x_), cons2, cons3, cons21, cons4, cons1966) def replacement6797(m, b, a, n, x): rubi.append(6797) return Dist(m/b, Int(x**(m + S(-1))*ExpIntegralE(n + S(1), a + b*x), x), x) - Simp(x**m*ExpIntegralE(n + S(1), a + b*x)/b, x) rule6797 = ReplacementRule(pattern6797, replacement6797) pattern6798 = Pattern(Integral(x_**WC('m', S(1))*ExpIntegralE(n_, a_ + x_*WC('b', S(1))), x_), cons2, cons3, cons21, cons1967, cons66) def replacement6798(m, b, a, n, x): rubi.append(6798) return Dist(b/(m + S(1)), Int(x**(m + S(1))*ExpIntegralE(n + S(-1), a + b*x), x), x) + Simp(x**(m + S(1))*ExpIntegralE(n, a + b*x)/(m + S(1)), x) rule6798 = ReplacementRule(pattern6798, replacement6798) pattern6799 = Pattern(Integral(ExpIntegralEi(x_*WC('b', S(1)) + WC('a', S(0))), x_), cons2, cons3, cons67) def replacement6799(x, a, b): rubi.append(6799) return -Simp(exp(a + b*x)/b, x) + Simp((a + b*x)*ExpIntegralEi(a + b*x)/b, x) rule6799 = ReplacementRule(pattern6799, replacement6799) pattern6800 = Pattern(Integral(x_**WC('m', S(1))*ExpIntegralEi(x_*WC('b', S(1)) + WC('a', S(0))), x_), cons2, cons3, cons21, cons66) def replacement6800(x, m, a, b): rubi.append(6800) return -Dist(b/(m + S(1)), Int(x**(m + S(1))*exp(a + b*x)/(a + b*x), x), x) + Simp(x**(m + S(1))*ExpIntegralEi(a + b*x)/(m + S(1)), x) rule6800 = ReplacementRule(pattern6800, replacement6800) pattern6801 = Pattern(Integral(ExpIntegralEi(x_*WC('b', S(1)) + WC('a', S(0)))**S(2), x_), cons2, cons3, cons67) def replacement6801(x, a, b): rubi.append(6801) return -Dist(S(2), Int(ExpIntegralEi(a + b*x)*exp(a + b*x), x), x) + Simp((a + b*x)*ExpIntegralEi(a + b*x)**S(2)/b, x) rule6801 = ReplacementRule(pattern6801, replacement6801) pattern6802 = Pattern(Integral(x_**WC('m', S(1))*ExpIntegralEi(x_*WC('b', S(1)))**S(2), x_), cons3, cons62) def replacement6802(x, m, b): rubi.append(6802) return -Dist(S(2)/(m + S(1)), Int(x**m*ExpIntegralEi(b*x)*exp(b*x), x), x) + Simp(x**(m + S(1))*ExpIntegralEi(b*x)**S(2)/(m + S(1)), x) rule6802 = ReplacementRule(pattern6802, replacement6802) pattern6803 = Pattern(Integral(x_**WC('m', S(1))*ExpIntegralEi(a_ + x_*WC('b', S(1)))**S(2), x_), cons2, cons3, cons62) def replacement6803(x, m, b, a): rubi.append(6803) return -Dist(a*m/(b*(m + S(1))), Int(x**(m + S(-1))*ExpIntegralEi(a + b*x)**S(2), x), x) - Dist(S(2)/(m + S(1)), Int(x**m*ExpIntegralEi(a + b*x)*exp(a + b*x), x), x) + Simp(x**(m + S(1))*ExpIntegralEi(a + b*x)**S(2)/(m + S(1)), x) + Simp(a*x**m*ExpIntegralEi(a + b*x)**S(2)/(b*(m + S(1))), x) rule6803 = ReplacementRule(pattern6803, replacement6803) pattern6804 = Pattern(Integral(ExpIntegralEi(x_*WC('d', S(1)) + WC('c', S(0)))*exp(x_*WC('b', S(1)) + WC('a', S(0))), x_), cons2, cons3, cons7, cons27, cons1264) def replacement6804(b, d, c, a, x): rubi.append(6804) return -Dist(d/b, Int(exp(a + c + x*(b + d))/(c + d*x), x), x) + Simp(ExpIntegralEi(c + d*x)*exp(a + b*x)/b, x) rule6804 = ReplacementRule(pattern6804, replacement6804) pattern6805 = Pattern(Integral(x_**WC('m', S(1))*ExpIntegralEi(x_*WC('d', S(1)) + WC('c', S(0)))*exp(x_*WC('b', S(1)) + WC('a', S(0))), x_), cons2, cons3, cons7, cons27, cons62) def replacement6805(m, b, d, c, a, x): rubi.append(6805) return -Dist(d/b, Int(x**m*exp(a + c + x*(b + d))/(c + d*x), x), x) - Dist(m/b, Int(x**(m + S(-1))*ExpIntegralEi(c + d*x)*exp(a + b*x), x), x) + Simp(x**m*ExpIntegralEi(c + d*x)*exp(a + b*x)/b, x) rule6805 = ReplacementRule(pattern6805, replacement6805) pattern6806 = Pattern(Integral(x_**m_*ExpIntegralEi(x_*WC('d', S(1)) + WC('c', S(0)))*exp(x_*WC('b', S(1)) + WC('a', S(0))), x_), cons2, cons3, cons7, cons27, cons17, cons94) def replacement6806(m, b, d, c, a, x): rubi.append(6806) return -Dist(b/(m + S(1)), Int(x**(m + S(1))*ExpIntegralEi(c + d*x)*exp(a + b*x), x), x) - Dist(d/(m + S(1)), Int(x**(m + S(1))*exp(a + c + x*(b + d))/(c + d*x), x), x) + Simp(x**(m + S(1))*ExpIntegralEi(c + d*x)*exp(a + b*x)/(m + S(1)), x) rule6806 = ReplacementRule(pattern6806, replacement6806) pattern6807 = Pattern(Integral(LogIntegral(x_*WC('b', S(1)) + WC('a', S(0))), x_), cons2, cons3, cons67) def replacement6807(x, a, b): rubi.append(6807) return -Simp(ExpIntegralEi(S(2)*log(a + b*x))/b, x) + Simp((a + b*x)*LogIntegral(a + b*x)/b, x) rule6807 = ReplacementRule(pattern6807, replacement6807) pattern6808 = Pattern(Integral(LogIntegral(x_*WC('b', S(1)))/x_, x_), cons3, cons3) def replacement6808(x, b): rubi.append(6808) return -Simp(b*x, x) + Simp(LogIntegral(b*x)*log(b*x), x) rule6808 = ReplacementRule(pattern6808, replacement6808) pattern6809 = Pattern(Integral(x_**WC('m', S(1))*LogIntegral(x_*WC('b', S(1)) + WC('a', S(0))), x_), cons2, cons3, cons21, cons66) def replacement6809(x, m, a, b): rubi.append(6809) return -Dist(b/(m + S(1)), Int(x**(m + S(1))/log(a + b*x), x), x) + Simp(x**(m + S(1))*LogIntegral(a + b*x)/(m + S(1)), x) rule6809 = ReplacementRule(pattern6809, replacement6809) pattern6810 = Pattern(Integral(SinIntegral(x_*WC('b', S(1)) + WC('a', S(0))), x_), cons2, cons3, cons67) def replacement6810(x, a, b): rubi.append(6810) return Simp(cos(a + b*x)/b, x) + Simp((a + b*x)*SinIntegral(a + b*x)/b, x) rule6810 = ReplacementRule(pattern6810, replacement6810) pattern6811 = Pattern(Integral(CosIntegral(x_*WC('b', S(1)) + WC('a', S(0))), x_), cons2, cons3, cons67) def replacement6811(x, a, b): rubi.append(6811) return -Simp(sin(a + b*x)/b, x) + Simp((a + b*x)*CosIntegral(a + b*x)/b, x) rule6811 = ReplacementRule(pattern6811, replacement6811) pattern6812 = Pattern(Integral(SinIntegral(x_*WC('b', S(1)))/x_, x_), cons3, cons3) def replacement6812(x, b): rubi.append(6812) return Simp(b*x*HypergeometricPFQ(List(S(1), S(1), S(1)), List(S(2), S(2), S(2)), -I*b*x)/S(2), x) + Simp(b*x*HypergeometricPFQ(List(S(1), S(1), S(1)), List(S(2), S(2), S(2)), I*b*x)/S(2), x) rule6812 = ReplacementRule(pattern6812, replacement6812) pattern6813 = Pattern(Integral(CosIntegral(x_*WC('b', S(1)))/x_, x_), cons3, cons3) def replacement6813(x, b): rubi.append(6813) return Simp(EulerGamma*log(x), x) - Simp(I*b*x*HypergeometricPFQ(List(S(1), S(1), S(1)), List(S(2), S(2), S(2)), -I*b*x)/S(2), x) + Simp(I*b*x*HypergeometricPFQ(List(S(1), S(1), S(1)), List(S(2), S(2), S(2)), I*b*x)/S(2), x) + Simp(log(b*x)**S(2)/S(2), x) rule6813 = ReplacementRule(pattern6813, replacement6813) pattern6814 = Pattern(Integral(x_**WC('m', S(1))*SinIntegral(x_*WC('b', S(1)) + WC('a', S(0))), x_), cons2, cons3, cons21, cons66) def replacement6814(x, m, b, a): rubi.append(6814) return -Dist(b/(m + S(1)), Int(x**(m + S(1))*sin(a + b*x)/(a + b*x), x), x) + Simp(x**(m + S(1))*SinIntegral(a + b*x)/(m + S(1)), x) rule6814 = ReplacementRule(pattern6814, replacement6814) pattern6815 = Pattern(Integral(x_**WC('m', S(1))*CosIntegral(x_*WC('b', S(1)) + WC('a', S(0))), x_), cons2, cons3, cons21, cons66) def replacement6815(x, m, a, b): rubi.append(6815) return -Dist(b/(m + S(1)), Int(x**(m + S(1))*cos(a + b*x)/(a + b*x), x), x) + Simp(x**(m + S(1))*CosIntegral(a + b*x)/(m + S(1)), x) rule6815 = ReplacementRule(pattern6815, replacement6815) pattern6816 = Pattern(Integral(SinIntegral(x_*WC('b', S(1)) + WC('a', S(0)))**S(2), x_), cons2, cons3, cons67) def replacement6816(x, a, b): rubi.append(6816) return -Dist(S(2), Int(SinIntegral(a + b*x)*sin(a + b*x), x), x) + Simp((a + b*x)*SinIntegral(a + b*x)**S(2)/b, x) rule6816 = ReplacementRule(pattern6816, replacement6816) pattern6817 = Pattern(Integral(CosIntegral(x_*WC('b', S(1)) + WC('a', S(0)))**S(2), x_), cons2, cons3, cons67) def replacement6817(x, a, b): rubi.append(6817) return -Dist(S(2), Int(CosIntegral(a + b*x)*cos(a + b*x), x), x) + Simp((a + b*x)*CosIntegral(a + b*x)**S(2)/b, x) rule6817 = ReplacementRule(pattern6817, replacement6817) pattern6818 = Pattern(Integral(x_**WC('m', S(1))*SinIntegral(x_*WC('b', S(1)))**S(2), x_), cons3, cons62) def replacement6818(x, m, b): rubi.append(6818) return -Dist(S(2)/(m + S(1)), Int(x**m*SinIntegral(b*x)*sin(b*x), x), x) + Simp(x**(m + S(1))*SinIntegral(b*x)**S(2)/(m + S(1)), x) rule6818 = ReplacementRule(pattern6818, replacement6818) pattern6819 = Pattern(Integral(x_**WC('m', S(1))*CosIntegral(x_*WC('b', S(1)))**S(2), x_), cons3, cons62) def replacement6819(x, m, b): rubi.append(6819) return -Dist(S(2)/(m + S(1)), Int(x**m*CosIntegral(b*x)*cos(b*x), x), x) + Simp(x**(m + S(1))*CosIntegral(b*x)**S(2)/(m + S(1)), x) rule6819 = ReplacementRule(pattern6819, replacement6819) pattern6820 = Pattern(Integral(x_**WC('m', S(1))*SinIntegral(a_ + x_*WC('b', S(1)))**S(2), x_), cons2, cons3, cons62) def replacement6820(x, m, b, a): rubi.append(6820) return -Dist(a*m/(b*(m + S(1))), Int(x**(m + S(-1))*SinIntegral(a + b*x)**S(2), x), x) - Dist(S(2)/(m + S(1)), Int(x**m*SinIntegral(a + b*x)*sin(a + b*x), x), x) + Simp(x**(m + S(1))*SinIntegral(a + b*x)**S(2)/(m + S(1)), x) + Simp(a*x**m*SinIntegral(a + b*x)**S(2)/(b*(m + S(1))), x) rule6820 = ReplacementRule(pattern6820, replacement6820) pattern6821 = Pattern(Integral(x_**WC('m', S(1))*CosIntegral(a_ + x_*WC('b', S(1)))**S(2), x_), cons2, cons3, cons62) def replacement6821(x, m, b, a): rubi.append(6821) return -Dist(a*m/(b*(m + S(1))), Int(x**(m + S(-1))*CosIntegral(a + b*x)**S(2), x), x) - Dist(S(2)/(m + S(1)), Int(x**m*CosIntegral(a + b*x)*cos(a + b*x), x), x) + Simp(x**(m + S(1))*CosIntegral(a + b*x)**S(2)/(m + S(1)), x) + Simp(a*x**m*CosIntegral(a + b*x)**S(2)/(b*(m + S(1))), x) rule6821 = ReplacementRule(pattern6821, replacement6821) pattern6822 = Pattern(Integral(SinIntegral(x_*WC('d', S(1)) + WC('c', S(0)))*sin(x_*WC('b', S(1)) + WC('a', S(0))), x_), cons2, cons3, cons7, cons27, cons1264) def replacement6822(b, d, c, a, x): rubi.append(6822) return Dist(d/b, Int(sin(c + d*x)*cos(a + b*x)/(c + d*x), x), x) - Simp(SinIntegral(c + d*x)*cos(a + b*x)/b, x) rule6822 = ReplacementRule(pattern6822, replacement6822) pattern6823 = Pattern(Integral(CosIntegral(x_*WC('d', S(1)) + WC('c', S(0)))*cos(x_*WC('b', S(1)) + WC('a', S(0))), x_), cons2, cons3, cons7, cons27, cons1264) def replacement6823(b, d, c, a, x): rubi.append(6823) return -Dist(d/b, Int(sin(a + b*x)*cos(c + d*x)/(c + d*x), x), x) + Simp(CosIntegral(c + d*x)*sin(a + b*x)/b, x) rule6823 = ReplacementRule(pattern6823, replacement6823) pattern6824 = Pattern(Integral(x_**WC('m', S(1))*SinIntegral(x_*WC('d', S(1)) + WC('c', S(0)))*sin(x_*WC('b', S(1)) + WC('a', S(0))), x_), cons2, cons3, cons7, cons27, cons62) def replacement6824(m, b, d, c, a, x): rubi.append(6824) return Dist(d/b, Int(x**m*sin(c + d*x)*cos(a + b*x)/(c + d*x), x), x) + Dist(m/b, Int(x**(m + S(-1))*SinIntegral(c + d*x)*cos(a + b*x), x), x) - Simp(x**m*SinIntegral(c + d*x)*cos(a + b*x)/b, x) rule6824 = ReplacementRule(pattern6824, replacement6824) pattern6825 = Pattern(Integral(x_**WC('m', S(1))*CosIntegral(x_*WC('d', S(1)) + WC('c', S(0)))*cos(x_*WC('b', S(1)) + WC('a', S(0))), x_), cons2, cons3, cons7, cons27, cons62) def replacement6825(m, b, d, c, a, x): rubi.append(6825) return -Dist(d/b, Int(x**m*sin(a + b*x)*cos(c + d*x)/(c + d*x), x), x) - Dist(m/b, Int(x**(m + S(-1))*CosIntegral(c + d*x)*sin(a + b*x), x), x) + Simp(x**m*CosIntegral(c + d*x)*sin(a + b*x)/b, x) rule6825 = ReplacementRule(pattern6825, replacement6825) pattern6826 = Pattern(Integral(x_**m_*SinIntegral(x_*WC('d', S(1)) + WC('c', S(0)))*sin(x_*WC('b', S(1)) + WC('a', S(0))), x_), cons2, cons3, cons7, cons27, cons17, cons94) def replacement6826(m, b, d, c, a, x): rubi.append(6826) return -Dist(b/(m + S(1)), Int(x**(m + S(1))*SinIntegral(c + d*x)*cos(a + b*x), x), x) - Dist(d/(m + S(1)), Int(x**(m + S(1))*sin(a + b*x)*sin(c + d*x)/(c + d*x), x), x) + Simp(x**(m + S(1))*SinIntegral(c + d*x)*sin(a + b*x)/(m + S(1)), x) rule6826 = ReplacementRule(pattern6826, replacement6826) pattern6827 = Pattern(Integral(x_**WC('m', S(1))*CosIntegral(x_*WC('d', S(1)) + WC('c', S(0)))*cos(x_*WC('b', S(1)) + WC('a', S(0))), x_), cons2, cons3, cons7, cons27, cons17, cons94) def replacement6827(m, b, d, c, a, x): rubi.append(6827) return Dist(b/(m + S(1)), Int(x**(m + S(1))*CosIntegral(c + d*x)*sin(a + b*x), x), x) - Dist(d/(m + S(1)), Int(x**(m + S(1))*cos(a + b*x)*cos(c + d*x)/(c + d*x), x), x) + Simp(x**(m + S(1))*CosIntegral(c + d*x)*cos(a + b*x)/(m + S(1)), x) rule6827 = ReplacementRule(pattern6827, replacement6827) pattern6828 = Pattern(Integral(SinIntegral(x_*WC('d', S(1)) + WC('c', S(0)))*cos(x_*WC('b', S(1)) + WC('a', S(0))), x_), cons2, cons3, cons7, cons27, cons1264) def replacement6828(b, d, c, a, x): rubi.append(6828) return -Dist(d/b, Int(sin(a + b*x)*sin(c + d*x)/(c + d*x), x), x) + Simp(SinIntegral(c + d*x)*sin(a + b*x)/b, x) rule6828 = ReplacementRule(pattern6828, replacement6828) pattern6829 = Pattern(Integral(CosIntegral(x_*WC('d', S(1)) + WC('c', S(0)))*sin(x_*WC('b', S(1)) + WC('a', S(0))), x_), cons2, cons3, cons7, cons27, cons1264) def replacement6829(b, d, c, a, x): rubi.append(6829) return Dist(d/b, Int(cos(a + b*x)*cos(c + d*x)/(c + d*x), x), x) - Simp(CosIntegral(c + d*x)*cos(a + b*x)/b, x) rule6829 = ReplacementRule(pattern6829, replacement6829) pattern6830 = Pattern(Integral(x_**WC('m', S(1))*SinIntegral(x_*WC('d', S(1)) + WC('c', S(0)))*cos(x_*WC('b', S(1)) + WC('a', S(0))), x_), cons2, cons3, cons7, cons27, cons62) def replacement6830(m, b, d, a, c, x): rubi.append(6830) return -Dist(d/b, Int(x**m*sin(a + b*x)*sin(c + d*x)/(c + d*x), x), x) - Dist(m/b, Int(x**(m + S(-1))*SinIntegral(c + d*x)*sin(a + b*x), x), x) + Simp(x**m*SinIntegral(c + d*x)*sin(a + b*x)/b, x) rule6830 = ReplacementRule(pattern6830, replacement6830) pattern6831 = Pattern(Integral(x_**WC('m', S(1))*CosIntegral(x_*WC('d', S(1)) + WC('c', S(0)))*sin(x_*WC('b', S(1)) + WC('a', S(0))), x_), cons2, cons3, cons7, cons27, cons62) def replacement6831(m, b, d, c, a, x): rubi.append(6831) return Dist(d/b, Int(x**m*cos(a + b*x)*cos(c + d*x)/(c + d*x), x), x) + Dist(m/b, Int(x**(m + S(-1))*CosIntegral(c + d*x)*cos(a + b*x), x), x) - Simp(x**m*CosIntegral(c + d*x)*cos(a + b*x)/b, x) rule6831 = ReplacementRule(pattern6831, replacement6831) pattern6832 = Pattern(Integral(x_**WC('m', S(1))*SinIntegral(x_*WC('d', S(1)) + WC('c', S(0)))*cos(x_*WC('b', S(1)) + WC('a', S(0))), x_), cons2, cons3, cons7, cons27, cons17, cons94) def replacement6832(m, b, d, a, c, x): rubi.append(6832) return Dist(b/(m + S(1)), Int(x**(m + S(1))*SinIntegral(c + d*x)*sin(a + b*x), x), x) - Dist(d/(m + S(1)), Int(x**(m + S(1))*sin(c + d*x)*cos(a + b*x)/(c + d*x), x), x) + Simp(x**(m + S(1))*SinIntegral(c + d*x)*cos(a + b*x)/(m + S(1)), x) rule6832 = ReplacementRule(pattern6832, replacement6832) pattern6833 = Pattern(Integral(x_**m_*CosIntegral(x_*WC('d', S(1)) + WC('c', S(0)))*sin(x_*WC('b', S(1)) + WC('a', S(0))), x_), cons2, cons3, cons7, cons27, cons17, cons94) def replacement6833(m, b, d, c, a, x): rubi.append(6833) return -Dist(b/(m + S(1)), Int(x**(m + S(1))*CosIntegral(c + d*x)*cos(a + b*x), x), x) - Dist(d/(m + S(1)), Int(x**(m + S(1))*sin(a + b*x)*cos(c + d*x)/(c + d*x), x), x) + Simp(x**(m + S(1))*CosIntegral(c + d*x)*sin(a + b*x)/(m + S(1)), x) rule6833 = ReplacementRule(pattern6833, replacement6833) pattern6834 = Pattern(Integral(SinhIntegral(x_*WC('b', S(1)) + WC('a', S(0))), x_), cons2, cons3, cons67) def replacement6834(x, a, b): rubi.append(6834) return -Simp(cosh(a + b*x)/b, x) + Simp((a + b*x)*SinhIntegral(a + b*x)/b, x) rule6834 = ReplacementRule(pattern6834, replacement6834) pattern6835 = Pattern(Integral(CoshIntegral(x_*WC('b', S(1)) + WC('a', S(0))), x_), cons2, cons3, cons67) def replacement6835(x, a, b): rubi.append(6835) return -Simp(sinh(a + b*x)/b, x) + Simp((a + b*x)*CoshIntegral(a + b*x)/b, x) rule6835 = ReplacementRule(pattern6835, replacement6835) pattern6836 = Pattern(Integral(SinhIntegral(x_*WC('b', S(1)))/x_, x_), cons3, cons3) def replacement6836(x, b): rubi.append(6836) return Simp(b*x*HypergeometricPFQ(List(S(1), S(1), S(1)), List(S(2), S(2), S(2)), -b*x)/S(2), x) + Simp(b*x*HypergeometricPFQ(List(S(1), S(1), S(1)), List(S(2), S(2), S(2)), b*x)/S(2), x) rule6836 = ReplacementRule(pattern6836, replacement6836) pattern6837 = Pattern(Integral(CoshIntegral(x_*WC('b', S(1)))/x_, x_), cons3, cons3) def replacement6837(x, b): rubi.append(6837) return Simp(EulerGamma*log(x), x) - Simp(b*x*HypergeometricPFQ(List(S(1), S(1), S(1)), List(S(2), S(2), S(2)), -b*x)/S(2), x) + Simp(b*x*HypergeometricPFQ(List(S(1), S(1), S(1)), List(S(2), S(2), S(2)), b*x)/S(2), x) + Simp(log(b*x)**S(2)/S(2), x) rule6837 = ReplacementRule(pattern6837, replacement6837) pattern6838 = Pattern(Integral(x_**WC('m', S(1))*SinhIntegral(x_*WC('b', S(1)) + WC('a', S(0))), x_), cons2, cons3, cons21, cons66) def replacement6838(x, m, b, a): rubi.append(6838) return -Dist(b/(m + S(1)), Int(x**(m + S(1))*sinh(a + b*x)/(a + b*x), x), x) + Simp(x**(m + S(1))*SinhIntegral(a + b*x)/(m + S(1)), x) rule6838 = ReplacementRule(pattern6838, replacement6838) pattern6839 = Pattern(Integral(x_**WC('m', S(1))*CoshIntegral(x_*WC('b', S(1)) + WC('a', S(0))), x_), cons2, cons3, cons21, cons66) def replacement6839(x, m, a, b): rubi.append(6839) return -Dist(b/(m + S(1)), Int(x**(m + S(1))*cosh(a + b*x)/(a + b*x), x), x) + Simp(x**(m + S(1))*CoshIntegral(a + b*x)/(m + S(1)), x) rule6839 = ReplacementRule(pattern6839, replacement6839) pattern6840 = Pattern(Integral(SinhIntegral(x_*WC('b', S(1)) + WC('a', S(0)))**S(2), x_), cons2, cons3, cons67) def replacement6840(x, a, b): rubi.append(6840) return -Dist(S(2), Int(SinhIntegral(a + b*x)*sinh(a + b*x), x), x) + Simp((a + b*x)*SinhIntegral(a + b*x)**S(2)/b, x) rule6840 = ReplacementRule(pattern6840, replacement6840) pattern6841 = Pattern(Integral(CoshIntegral(x_*WC('b', S(1)) + WC('a', S(0)))**S(2), x_), cons2, cons3, cons67) def replacement6841(x, a, b): rubi.append(6841) return -Dist(S(2), Int(CoshIntegral(a + b*x)*cosh(a + b*x), x), x) + Simp((a + b*x)*CoshIntegral(a + b*x)**S(2)/b, x) rule6841 = ReplacementRule(pattern6841, replacement6841) pattern6842 = Pattern(Integral(x_**WC('m', S(1))*SinhIntegral(x_*WC('b', S(1)))**S(2), x_), cons3, cons62) def replacement6842(x, m, b): rubi.append(6842) return -Dist(S(2)/(m + S(1)), Int(x**m*SinhIntegral(b*x)*sinh(b*x), x), x) + Simp(x**(m + S(1))*SinhIntegral(b*x)**S(2)/(m + S(1)), x) rule6842 = ReplacementRule(pattern6842, replacement6842) pattern6843 = Pattern(Integral(x_**WC('m', S(1))*CoshIntegral(x_*WC('b', S(1)))**S(2), x_), cons3, cons62) def replacement6843(x, m, b): rubi.append(6843) return -Dist(S(2)/(m + S(1)), Int(x**m*CoshIntegral(b*x)*cosh(b*x), x), x) + Simp(x**(m + S(1))*CoshIntegral(b*x)**S(2)/(m + S(1)), x) rule6843 = ReplacementRule(pattern6843, replacement6843) pattern6844 = Pattern(Integral(x_**WC('m', S(1))*SinhIntegral(a_ + x_*WC('b', S(1)))**S(2), x_), cons2, cons3, cons62) def replacement6844(x, m, b, a): rubi.append(6844) return -Dist(a*m/(b*(m + S(1))), Int(x**(m + S(-1))*SinhIntegral(a + b*x)**S(2), x), x) - Dist(S(2)/(m + S(1)), Int(x**m*SinhIntegral(a + b*x)*sinh(a + b*x), x), x) + Simp(x**(m + S(1))*SinhIntegral(a + b*x)**S(2)/(m + S(1)), x) + Simp(a*x**m*SinhIntegral(a + b*x)**S(2)/(b*(m + S(1))), x) rule6844 = ReplacementRule(pattern6844, replacement6844) pattern6845 = Pattern(Integral(x_**WC('m', S(1))*CoshIntegral(a_ + x_*WC('b', S(1)))**S(2), x_), cons2, cons3, cons62) def replacement6845(x, m, b, a): rubi.append(6845) return -Dist(a*m/(b*(m + S(1))), Int(x**(m + S(-1))*CoshIntegral(a + b*x)**S(2), x), x) - Dist(S(2)/(m + S(1)), Int(x**m*CoshIntegral(a + b*x)*cosh(a + b*x), x), x) + Simp(x**(m + S(1))*CoshIntegral(a + b*x)**S(2)/(m + S(1)), x) + Simp(a*x**m*CoshIntegral(a + b*x)**S(2)/(b*(m + S(1))), x) rule6845 = ReplacementRule(pattern6845, replacement6845) pattern6846 = Pattern(Integral(SinhIntegral(x_*WC('d', S(1)) + WC('c', S(0)))*sinh(x_*WC('b', S(1)) + WC('a', S(0))), x_), cons2, cons3, cons7, cons27, cons1264) def replacement6846(b, d, c, a, x): rubi.append(6846) return -Dist(d/b, Int(sinh(c + d*x)*cosh(a + b*x)/(c + d*x), x), x) + Simp(SinhIntegral(c + d*x)*cosh(a + b*x)/b, x) rule6846 = ReplacementRule(pattern6846, replacement6846) pattern6847 = Pattern(Integral(CoshIntegral(x_*WC('d', S(1)) + WC('c', S(0)))*cosh(x_*WC('b', S(1)) + WC('a', S(0))), x_), cons2, cons3, cons7, cons27, cons1264) def replacement6847(b, d, c, a, x): rubi.append(6847) return -Dist(d/b, Int(sinh(a + b*x)*cosh(c + d*x)/(c + d*x), x), x) + Simp(CoshIntegral(c + d*x)*sinh(a + b*x)/b, x) rule6847 = ReplacementRule(pattern6847, replacement6847) pattern6848 = Pattern(Integral(x_**WC('m', S(1))*SinhIntegral(x_*WC('d', S(1)) + WC('c', S(0)))*sinh(x_*WC('b', S(1)) + WC('a', S(0))), x_), cons2, cons3, cons7, cons27, cons17, cons168) def replacement6848(m, b, d, c, a, x): rubi.append(6848) return -Dist(d/b, Int(x**m*sinh(c + d*x)*cosh(a + b*x)/(c + d*x), x), x) - Dist(m/b, Int(x**(m + S(-1))*SinhIntegral(c + d*x)*cosh(a + b*x), x), x) + Simp(x**m*SinhIntegral(c + d*x)*cosh(a + b*x)/b, x) rule6848 = ReplacementRule(pattern6848, replacement6848) pattern6849 = Pattern(Integral(x_**WC('m', S(1))*CoshIntegral(x_*WC('d', S(1)) + WC('c', S(0)))*cosh(x_*WC('b', S(1)) + WC('a', S(0))), x_), cons2, cons3, cons7, cons27, cons17, cons168) def replacement6849(m, b, d, c, a, x): rubi.append(6849) return -Dist(d/b, Int(x**m*sinh(a + b*x)*cosh(c + d*x)/(c + d*x), x), x) - Dist(m/b, Int(x**(m + S(-1))*CoshIntegral(c + d*x)*sinh(a + b*x), x), x) + Simp(x**m*CoshIntegral(c + d*x)*sinh(a + b*x)/b, x) rule6849 = ReplacementRule(pattern6849, replacement6849) pattern6850 = Pattern(Integral(x_**m_*SinhIntegral(x_*WC('d', S(1)) + WC('c', S(0)))*sinh(x_*WC('b', S(1)) + WC('a', S(0))), x_), cons2, cons3, cons7, cons27, cons17, cons94) def replacement6850(m, b, d, c, a, x): rubi.append(6850) return -Dist(b/(m + S(1)), Int(x**(m + S(1))*SinhIntegral(c + d*x)*cosh(a + b*x), x), x) - Dist(d/(m + S(1)), Int(x**(m + S(1))*sinh(a + b*x)*sinh(c + d*x)/(c + d*x), x), x) + Simp(x**(m + S(1))*SinhIntegral(c + d*x)*sinh(a + b*x)/(m + S(1)), x) rule6850 = ReplacementRule(pattern6850, replacement6850) pattern6851 = Pattern(Integral(x_**WC('m', S(1))*CoshIntegral(x_*WC('d', S(1)) + WC('c', S(0)))*cosh(x_*WC('b', S(1)) + WC('a', S(0))), x_), cons2, cons3, cons7, cons27, cons17, cons94) def replacement6851(m, b, d, c, a, x): rubi.append(6851) return -Dist(b/(m + S(1)), Int(x**(m + S(1))*CoshIntegral(c + d*x)*sinh(a + b*x), x), x) - Dist(d/(m + S(1)), Int(x**(m + S(1))*cosh(a + b*x)*cosh(c + d*x)/(c + d*x), x), x) + Simp(x**(m + S(1))*CoshIntegral(c + d*x)*cosh(a + b*x)/(m + S(1)), x) rule6851 = ReplacementRule(pattern6851, replacement6851) pattern6852 = Pattern(Integral(SinhIntegral(x_*WC('d', S(1)) + WC('c', S(0)))*cosh(x_*WC('b', S(1)) + WC('a', S(0))), x_), cons2, cons3, cons7, cons27, cons1264) def replacement6852(b, d, c, a, x): rubi.append(6852) return -Dist(d/b, Int(sinh(a + b*x)*sinh(c + d*x)/(c + d*x), x), x) + Simp(SinhIntegral(c + d*x)*sinh(a + b*x)/b, x) rule6852 = ReplacementRule(pattern6852, replacement6852) pattern6853 = Pattern(Integral(CoshIntegral(x_*WC('d', S(1)) + WC('c', S(0)))*sinh(x_*WC('b', S(1)) + WC('a', S(0))), x_), cons2, cons3, cons7, cons27, cons1264) def replacement6853(b, d, c, a, x): rubi.append(6853) return -Dist(d/b, Int(cosh(a + b*x)*cosh(c + d*x)/(c + d*x), x), x) + Simp(CoshIntegral(c + d*x)*cosh(a + b*x)/b, x) rule6853 = ReplacementRule(pattern6853, replacement6853) pattern6854 = Pattern(Integral(x_**WC('m', S(1))*SinhIntegral(x_*WC('d', S(1)) + WC('c', S(0)))*cosh(x_*WC('b', S(1)) + WC('a', S(0))), x_), cons2, cons3, cons7, cons27, cons62) def replacement6854(m, b, d, a, c, x): rubi.append(6854) return -Dist(d/b, Int(x**m*sinh(a + b*x)*sinh(c + d*x)/(c + d*x), x), x) - Dist(m/b, Int(x**(m + S(-1))*SinhIntegral(c + d*x)*sinh(a + b*x), x), x) + Simp(x**m*SinhIntegral(c + d*x)*sinh(a + b*x)/b, x) rule6854 = ReplacementRule(pattern6854, replacement6854) pattern6855 = Pattern(Integral(x_**WC('m', S(1))*CoshIntegral(x_*WC('d', S(1)) + WC('c', S(0)))*sinh(x_*WC('b', S(1)) + WC('a', S(0))), x_), cons2, cons3, cons7, cons27, cons62) def replacement6855(m, b, d, c, a, x): rubi.append(6855) return -Dist(d/b, Int(x**m*cosh(a + b*x)*cosh(c + d*x)/(c + d*x), x), x) - Dist(m/b, Int(x**(m + S(-1))*CoshIntegral(c + d*x)*cosh(a + b*x), x), x) + Simp(x**m*CoshIntegral(c + d*x)*cosh(a + b*x)/b, x) rule6855 = ReplacementRule(pattern6855, replacement6855) pattern6856 = Pattern(Integral(x_**WC('m', S(1))*SinhIntegral(x_*WC('d', S(1)) + WC('c', S(0)))*cosh(x_*WC('b', S(1)) + WC('a', S(0))), x_), cons2, cons3, cons7, cons27, cons17, cons94) def replacement6856(m, b, d, a, c, x): rubi.append(6856) return -Dist(b/(m + S(1)), Int(x**(m + S(1))*SinhIntegral(c + d*x)*sinh(a + b*x), x), x) - Dist(d/(m + S(1)), Int(x**(m + S(1))*sinh(c + d*x)*cosh(a + b*x)/(c + d*x), x), x) + Simp(x**(m + S(1))*SinhIntegral(c + d*x)*cosh(a + b*x)/(m + S(1)), x) rule6856 = ReplacementRule(pattern6856, replacement6856) pattern6857 = Pattern(Integral(x_**m_*CoshIntegral(x_*WC('d', S(1)) + WC('c', S(0)))*sinh(x_*WC('b', S(1)) + WC('a', S(0))), x_), cons2, cons3, cons7, cons27, cons17, cons94) def replacement6857(m, b, d, c, a, x): rubi.append(6857) return -Dist(b/(m + S(1)), Int(x**(m + S(1))*CoshIntegral(c + d*x)*cosh(a + b*x), x), x) - Dist(d/(m + S(1)), Int(x**(m + S(1))*sinh(a + b*x)*cosh(c + d*x)/(c + d*x), x), x) + Simp(x**(m + S(1))*CoshIntegral(c + d*x)*sinh(a + b*x)/(m + S(1)), x) rule6857 = ReplacementRule(pattern6857, replacement6857) pattern6858 = Pattern(Integral(Gamma(n_, x_*WC('b', S(1)) + WC('a', S(0))), x_), cons2, cons3, cons67) def replacement6858(x, a, n, b): rubi.append(6858) return -Simp(Gamma(n + S(1), a + b*x)/b, x) + Simp((a + b*x)*Gamma(n, a + b*x)/b, x) rule6858 = ReplacementRule(pattern6858, replacement6858) pattern6859 = Pattern(Integral(Gamma(n_, b_*x_)/x_, x_), cons3, cons4, cons1968) def replacement6859(x, n, b): rubi.append(6859) return Simp(Gamma(n)*log(x), x) - Simp((b*x)**n*HypergeometricPFQ(List(n, n), List(n + S(1), n + S(1)), -b*x)/n**S(2), x) rule6859 = ReplacementRule(pattern6859, replacement6859) pattern6860 = Pattern(Integral(x_**WC('m', S(1))*Gamma(n_, b_*x_), x_), cons3, cons21, cons4, cons66) def replacement6860(x, m, n, b): rubi.append(6860) return Simp(x**(m + S(1))*Gamma(n, b*x)/(m + S(1)), x) - Simp(x**m*(b*x)**(-m)*Gamma(m + n + S(1), b*x)/(b*(m + S(1))), x) rule6860 = ReplacementRule(pattern6860, replacement6860) def With6861(m, b, a, n, x): _UseGamma = True rubi.append(6861) return Dist(b/(m + S(1)), Int(x**(m + S(1))*(a + b*x)**(n + S(-1))*exp(-a - b*x), x), x) + Simp(x**(m + S(1))*Gamma(n, a + b*x)/(m + S(1)), x) pattern6861 = Pattern(Integral(x_**WC('m', S(1))*Gamma(n_, a_ + x_*WC('b', S(1))), x_), cons2, cons3, cons21, cons4, cons1969, cons66) rule6861 = ReplacementRule(pattern6861, With6861) pattern6862 = Pattern(Integral(LogGamma(x_*WC('b', S(1)) + WC('a', S(0))), x_), cons2, cons3, cons67) def replacement6862(x, a, b): rubi.append(6862) return Simp(PolyGamma(S(-2), a + b*x)/b, x) rule6862 = ReplacementRule(pattern6862, replacement6862) pattern6863 = Pattern(Integral(x_**WC('m', S(1))*LogGamma(x_*WC('b', S(1)) + WC('a', S(0))), x_), cons2, cons3, cons31, cons168) def replacement6863(x, m, a, b): rubi.append(6863) return -Dist(m/b, Int(x**(m + S(-1))*PolyGamma(S(-2), a + b*x), x), x) + Simp(x**m*PolyGamma(S(-2), a + b*x)/b, x) rule6863 = ReplacementRule(pattern6863, replacement6863) pattern6864 = Pattern(Integral(PolyGamma(n_, x_*WC('b', S(1)) + WC('a', S(0))), x_), cons2, cons3, cons4, cons1831) def replacement6864(x, a, n, b): rubi.append(6864) return Simp(PolyGamma(n + S(-1), a + b*x)/b, x) rule6864 = ReplacementRule(pattern6864, replacement6864) pattern6865 = Pattern(Integral(x_**WC('m', S(1))*PolyGamma(n_, x_*WC('b', S(1)) + WC('a', S(0))), x_), cons2, cons3, cons4, cons31, cons168) def replacement6865(m, b, a, n, x): rubi.append(6865) return -Dist(m/b, Int(x**(m + S(-1))*PolyGamma(n + S(-1), a + b*x), x), x) + Simp(x**m*PolyGamma(n + S(-1), a + b*x)/b, x) rule6865 = ReplacementRule(pattern6865, replacement6865) pattern6866 = Pattern(Integral(x_**WC('m', S(1))*PolyGamma(n_, x_*WC('b', S(1)) + WC('a', S(0))), x_), cons2, cons3, cons4, cons31, cons94) def replacement6866(m, b, a, n, x): rubi.append(6866) return -Dist(b/(m + S(1)), Int(x**(m + S(1))*PolyGamma(n + S(1), a + b*x), x), x) + Simp(x**(m + S(1))*PolyGamma(n, a + b*x)/(m + S(1)), x) rule6866 = ReplacementRule(pattern6866, replacement6866) pattern6867 = Pattern(Integral(Gamma(x_*WC('b', S(1)) + WC('a', S(0)))**WC('n', S(1))*PolyGamma(S(0), x_*WC('b', S(1)) + WC('a', S(0))), x_), cons2, cons3, cons4, cons1831) def replacement6867(x, a, n, b): rubi.append(6867) return Simp(Gamma(a + b*x)**n/(b*n), x) rule6867 = ReplacementRule(pattern6867, replacement6867) pattern6868 = Pattern(Integral(Factorial(x_*WC('b', S(1)) + WC('a', S(0)))**WC('n', S(1))*PolyGamma(S(0), x_*WC('b', S(1)) + WC('c', S(0))), x_), cons2, cons3, cons7, cons4, cons1970) def replacement6868(b, c, a, n, x): rubi.append(6868) return Simp(Factorial(a + b*x)**n/(b*n), x) rule6868 = ReplacementRule(pattern6868, replacement6868) pattern6869 = Pattern(Integral(Zeta(S(2), x_*WC('b', S(1)) + WC('a', S(0))), x_), cons2, cons3, cons67) def replacement6869(x, a, b): rubi.append(6869) return Int(PolyGamma(S(1), a + b*x), x) rule6869 = ReplacementRule(pattern6869, replacement6869) pattern6870 = Pattern(Integral(Zeta(s_, x_*WC('b', S(1)) + WC('a', S(0))), x_), cons2, cons3, cons800, cons1971, cons1972) def replacement6870(x, a, b, s): rubi.append(6870) return -Simp(Zeta(s + S(-1), a + b*x)/(b*(s + S(-1))), x) rule6870 = ReplacementRule(pattern6870, replacement6870) pattern6871 = Pattern(Integral(x_**WC('m', S(1))*Zeta(S(2), x_*WC('b', S(1)) + WC('a', S(0))), x_), cons2, cons3, cons31) def replacement6871(x, m, b, a): rubi.append(6871) return Int(x**m*PolyGamma(S(1), a + b*x), x) rule6871 = ReplacementRule(pattern6871, replacement6871) pattern6872 = Pattern(Integral(x_**WC('m', S(1))*Zeta(s_, x_*WC('b', S(1)) + WC('a', S(0))), x_), cons2, cons3, cons800, cons1971, cons1972, cons31, cons168) def replacement6872(m, b, a, x, s): rubi.append(6872) return Dist(m/(b*(s + S(-1))), Int(x**(m + S(-1))*Zeta(s + S(-1), a + b*x), x), x) - Simp(x**m*Zeta(s + S(-1), a + b*x)/(b*(s + S(-1))), x) rule6872 = ReplacementRule(pattern6872, replacement6872) pattern6873 = Pattern(Integral(x_**WC('m', S(1))*Zeta(s_, x_*WC('b', S(1)) + WC('a', S(0))), x_), cons2, cons3, cons800, cons1971, cons1972, cons31, cons94) def replacement6873(m, b, a, x, s): rubi.append(6873) return Dist(b*s/(m + S(1)), Int(x**(m + S(1))*Zeta(s + S(1), a + b*x), x), x) + Simp(x**(m + S(1))*Zeta(s, a + b*x)/(m + S(1)), x) rule6873 = ReplacementRule(pattern6873, replacement6873) pattern6874 = Pattern(Integral(PolyLog(n_, (x_**WC('p', S(1))*WC('b', S(1)))**WC('q', S(1))*WC('a', S(1))), x_), cons2, cons3, cons5, cons50, cons87, cons88) def replacement6874(p, b, a, n, x, q): rubi.append(6874) return -Dist(p*q, Int(PolyLog(n + S(-1), a*(b*x**p)**q), x), x) + Simp(x*PolyLog(n, a*(b*x**p)**q), x) rule6874 = ReplacementRule(pattern6874, replacement6874) pattern6875 = Pattern(Integral(PolyLog(n_, (x_**WC('p', S(1))*WC('b', S(1)))**WC('q', S(1))*WC('a', S(1))), x_), cons2, cons3, cons5, cons50, cons87, cons89) def replacement6875(p, b, a, n, x, q): rubi.append(6875) return -Dist(S(1)/(p*q), Int(PolyLog(n + S(1), a*(b*x**p)**q), x), x) + Simp(x*PolyLog(n + S(1), a*(b*x**p)**q)/(p*q), x) rule6875 = ReplacementRule(pattern6875, replacement6875) pattern6876 = Pattern(Integral(PolyLog(n_, (x_*WC('b', S(1)) + WC('a', S(0)))**WC('p', S(1))*WC('c', S(1)))/(x_*WC('e', S(1)) + WC('d', S(0))), x_), cons2, cons3, cons7, cons27, cons48, cons4, cons5, cons383) def replacement6876(p, b, d, c, a, n, x, e): rubi.append(6876) return Simp(PolyLog(n + S(1), c*(a + b*x)**p)/(e*p), x) rule6876 = ReplacementRule(pattern6876, replacement6876) pattern6877 = Pattern(Integral(PolyLog(n_, (x_**WC('p', S(1))*WC('b', S(1)))**WC('q', S(1))*WC('a', S(1)))/x_, x_), cons2, cons3, cons4, cons5, cons50, cons1973) def replacement6877(p, b, a, n, x, q): rubi.append(6877) return Simp(PolyLog(n + S(1), a*(b*x**p)**q)/(p*q), x) rule6877 = ReplacementRule(pattern6877, replacement6877) pattern6878 = Pattern(Integral(x_**WC('m', S(1))*PolyLog(n_, (x_**WC('p', S(1))*WC('b', S(1)))**WC('q', S(1))*WC('a', S(1))), x_), cons2, cons3, cons21, cons5, cons50, cons66, cons87, cons88) def replacement6878(p, m, b, a, n, x, q): rubi.append(6878) return -Dist(p*q/(m + S(1)), Int(x**m*PolyLog(n + S(-1), a*(b*x**p)**q), x), x) + Simp(x**(m + S(1))*PolyLog(n, a*(b*x**p)**q)/(m + S(1)), x) rule6878 = ReplacementRule(pattern6878, replacement6878) pattern6879 = Pattern(Integral(x_**WC('m', S(1))*PolyLog(n_, (x_**WC('p', S(1))*WC('b', S(1)))**WC('q', S(1))*WC('a', S(1))), x_), cons2, cons3, cons21, cons5, cons50, cons66, cons87, cons89) def replacement6879(p, m, b, a, n, x, q): rubi.append(6879) return -Dist((m + S(1))/(p*q), Int(x**m*PolyLog(n + S(1), a*(b*x**p)**q), x), x) + Simp(x**(m + S(1))*PolyLog(n + S(1), a*(b*x**p)**q)/(p*q), x) rule6879 = ReplacementRule(pattern6879, replacement6879) pattern6880 = Pattern(Integral(PolyLog(n_, (x_**WC('p', S(1))*WC('b', S(1)))**WC('q', S(1))*WC('a', S(1)))*log(x_**WC('m', S(1))*WC('c', S(1)))**WC('r', S(1))/x_, x_), cons2, cons3, cons7, cons21, cons4, cons50, cons52, cons1974, cons1975) def replacement6880(p, m, b, r, c, a, n, x, q): rubi.append(6880) return -Dist(m*r/(p*q), Int(PolyLog(n + S(1), a*(b*x**p)**q)*log(c*x**m)**(r + S(-1))/x, x), x) + Simp(PolyLog(n + S(1), a*(b*x**p)**q)*log(c*x**m)**r/(p*q), x) rule6880 = ReplacementRule(pattern6880, replacement6880) pattern6881 = Pattern(Integral(PolyLog(n_, (x_*WC('b', S(1)) + WC('a', S(0)))**WC('p', S(1))*WC('c', S(1))), x_), cons2, cons3, cons7, cons5, cons87, cons88) def replacement6881(p, b, c, a, n, x): rubi.append(6881) return -Dist(p, Int(PolyLog(n + S(-1), c*(a + b*x)**p), x), x) + Dist(a*p, Int(PolyLog(n + S(-1), c*(a + b*x)**p)/(a + b*x), x), x) + Simp(x*PolyLog(n, c*(a + b*x)**p), x) rule6881 = ReplacementRule(pattern6881, replacement6881) pattern6882 = Pattern(Integral(x_**WC('m', S(1))*PolyLog(n_, (x_*WC('b', S(1)) + WC('a', S(0)))**WC('p', S(1))*WC('c', S(1))), x_), cons2, cons3, cons7, cons21, cons5, cons87, cons88, cons62) def replacement6882(p, m, b, c, a, n, x): rubi.append(6882) return -Dist(b*p/(m + S(1)), Int(x**(m + S(1))*PolyLog(n + S(-1), c*(a + b*x)**p)/(a + b*x), x), x) + Simp(x**(m + S(1))*PolyLog(n, c*(a + b*x)**p)/(m + S(1)), x) rule6882 = ReplacementRule(pattern6882, replacement6882) pattern6883 = Pattern(Integral(PolyLog(n_, (F_**((x_*WC('b', S(1)) + WC('a', S(0)))*WC('c', S(1))))**WC('p', S(1))*WC('d', S(1))), x_), cons1099, cons2, cons3, cons7, cons27, cons4, cons5, cons1976) def replacement6883(p, b, d, c, a, n, x, F): rubi.append(6883) return Simp(PolyLog(n + S(1), d*(F**(c*(a + b*x)))**p)/(b*c*p*log(F)), x) rule6883 = ReplacementRule(pattern6883, replacement6883) pattern6884 = Pattern(Integral((x_*WC('f', S(1)) + WC('e', S(0)))**WC('m', S(1))*PolyLog(n_, (F_**((x_*WC('b', S(1)) + WC('a', S(0)))*WC('c', S(1))))**WC('p', S(1))*WC('d', S(1))), x_), cons1099, cons2, cons3, cons7, cons27, cons48, cons125, cons4, cons5, cons31, cons168) def replacement6884(p, m, f, b, d, c, a, n, x, F, e): rubi.append(6884) return -Dist(f*m/(b*c*p*log(F)), Int((e + f*x)**(m + S(-1))*PolyLog(n + S(1), d*(F**(c*(a + b*x)))**p), x), x) + Simp((e + f*x)**m*PolyLog(n + S(1), d*(F**(c*(a + b*x)))**p)/(b*c*p*log(F)), x) rule6884 = ReplacementRule(pattern6884, replacement6884) def With6885(v, x, n, u): if isinstance(x, (int, Integer, float, Float)): return False try: w = DerivativeDivides(v, u*v, x) res = Not(FalseQ(w)) except (TypeError, AttributeError): return False if res: return True return False pattern6885 = Pattern(Integral(u_*PolyLog(n_, v_), x_), cons4, cons4, CustomConstraint(With6885)) def replacement6885(v, x, n, u): w = DerivativeDivides(v, u*v, x) rubi.append(6885) return Simp(w*PolyLog(n + S(1), v), x) rule6885 = ReplacementRule(pattern6885, replacement6885) def With6886(v, w, u, n, x): if isinstance(x, (int, Integer, float, Float)): return False try: z = DerivativeDivides(v, u*v, x) res = Not(FalseQ(z)) except (TypeError, AttributeError): return False if res: return True return False pattern6886 = Pattern(Integral(u_*PolyLog(n_, v_)*log(w_), x_), cons4, cons1243, CustomConstraint(With6886)) def replacement6886(v, w, u, n, x): z = DerivativeDivides(v, u*v, x) rubi.append(6886) return -Int(SimplifyIntegrand(z*D(w, x)*PolyLog(n + S(1), v)/w, x), x) + Simp(z*PolyLog(n + S(1), v)*log(w), x) rule6886 = ReplacementRule(pattern6886, replacement6886) pattern6887 = Pattern(Integral((ProductLog(x_*WC('b', S(1)) + WC('a', S(0)))*WC('c', S(1)))**p_, x_), cons2, cons3, cons7, cons13, cons137) def replacement6887(p, b, c, a, x): rubi.append(6887) return Dist(p/(c*(p + S(1))), Int((c*ProductLog(a + b*x))**(p + S(1))/(ProductLog(a + b*x) + S(1)), x), x) + Simp((c*ProductLog(a + b*x))**p*(a + b*x)/(b*(p + S(1))), x) rule6887 = ReplacementRule(pattern6887, replacement6887) pattern6888 = Pattern(Integral((ProductLog(x_*WC('b', S(1)) + WC('a', S(0)))*WC('c', S(1)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons1379) def replacement6888(p, b, c, a, x): rubi.append(6888) return -Dist(p, Int((c*ProductLog(a + b*x))**p/(ProductLog(a + b*x) + S(1)), x), x) + Simp((c*ProductLog(a + b*x))**p*(a + b*x)/b, x) rule6888 = ReplacementRule(pattern6888, replacement6888) pattern6889 = Pattern(Integral(x_**WC('m', S(1))*(ProductLog(a_ + x_*WC('b', S(1)))*WC('c', S(1)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons5, cons62) def replacement6889(p, m, b, c, a, x): rubi.append(6889) return Dist(S(1)/b, Subst(Int(ExpandIntegrand((c*ProductLog(x))**p, (-a/b + x/b)**m, x), x), x, a + b*x), x) rule6889 = ReplacementRule(pattern6889, replacement6889) pattern6890 = Pattern(Integral((ProductLog(x_**n_*WC('a', S(1)))*WC('c', S(1)))**WC('p', S(1)), x_), cons2, cons7, cons4, cons5, cons1977) def replacement6890(p, c, a, n, x): rubi.append(6890) return -Dist(n*p, Int((c*ProductLog(a*x**n))**p/(ProductLog(a*x**n) + S(1)), x), x) + Simp(x*(c*ProductLog(a*x**n))**p, x) rule6890 = ReplacementRule(pattern6890, replacement6890) pattern6891 = Pattern(Integral((ProductLog(x_**n_*WC('a', S(1)))*WC('c', S(1)))**WC('p', S(1)), x_), cons2, cons7, cons4, cons1978) def replacement6891(p, c, a, n, x): rubi.append(6891) return Dist(n*p/(c*(n*p + S(1))), Int((c*ProductLog(a*x**n))**(p + S(1))/(ProductLog(a*x**n) + S(1)), x), x) + Simp(x*(c*ProductLog(a*x**n))**p/(n*p + S(1)), x) rule6891 = ReplacementRule(pattern6891, replacement6891) pattern6892 = Pattern(Integral((ProductLog(x_**n_*WC('a', S(1)))*WC('c', S(1)))**WC('p', S(1)), x_), cons2, cons7, cons5, cons196) def replacement6892(p, c, a, n, x): rubi.append(6892) return -Subst(Int((c*ProductLog(a*x**(-n)))**p/x**S(2), x), x, S(1)/x) rule6892 = ReplacementRule(pattern6892, replacement6892) pattern6893 = Pattern(Integral(x_**WC('m', S(1))*(ProductLog(x_**WC('n', S(1))*WC('a', S(1)))*WC('c', S(1)))**WC('p', S(1)), x_), cons2, cons7, cons21, cons4, cons5, cons66, cons1979) def replacement6893(p, m, c, n, a, x): rubi.append(6893) return -Dist(n*p/(m + S(1)), Int(x**m*(c*ProductLog(a*x**n))**p/(ProductLog(a*x**n) + S(1)), x), x) + Simp(x**(m + S(1))*(c*ProductLog(a*x**n))**p/(m + S(1)), x) rule6893 = ReplacementRule(pattern6893, replacement6893) pattern6894 = Pattern(Integral(x_**WC('m', S(1))*(ProductLog(x_**WC('n', S(1))*WC('a', S(1)))*WC('c', S(1)))**WC('p', S(1)), x_), cons2, cons7, cons21, cons4, cons5, cons1980) def replacement6894(p, m, c, n, a, x): rubi.append(6894) return Dist(n*p/(c*(m + n*p + S(1))), Int(x**m*(c*ProductLog(a*x**n))**(p + S(1))/(ProductLog(a*x**n) + S(1)), x), x) + Simp(x**(m + S(1))*(c*ProductLog(a*x**n))**p/(m + n*p + S(1)), x) rule6894 = ReplacementRule(pattern6894, replacement6894) pattern6895 = Pattern(Integral(x_**WC('m', S(1))*(ProductLog(x_*WC('a', S(1)))*WC('c', S(1)))**WC('p', S(1)), x_), cons2, cons7, cons21, cons1981) def replacement6895(p, m, c, a, x): rubi.append(6895) return Dist(S(1)/c, Int(x**m*(c*ProductLog(a*x))**(p + S(1))/(ProductLog(a*x) + S(1)), x), x) + Int(x**m*(c*ProductLog(a*x))**p/(ProductLog(a*x) + S(1)), x) rule6895 = ReplacementRule(pattern6895, replacement6895) pattern6896 = Pattern(Integral(x_**WC('m', S(1))*(ProductLog(x_**n_*WC('a', S(1)))*WC('c', S(1)))**WC('p', S(1)), x_), cons2, cons7, cons5, cons150, cons463, cons66) def replacement6896(p, m, c, a, n, x): rubi.append(6896) return -Subst(Int(x**(-m + S(-2))*(c*ProductLog(a*x**(-n)))**p, x), x, S(1)/x) rule6896 = ReplacementRule(pattern6896, replacement6896) pattern6897 = Pattern(Integral(S(1)/(d_ + ProductLog(x_*WC('b', S(1)) + WC('a', S(0)))*WC('d', S(1))), x_), cons2, cons3, cons27, cons1765) def replacement6897(d, a, b, x): rubi.append(6897) return Simp((a + b*x)/(b*d*ProductLog(a + b*x)), x) rule6897 = ReplacementRule(pattern6897, replacement6897) pattern6898 = Pattern(Integral(ProductLog(x_*WC('b', S(1)) + WC('a', S(0)))/(d_ + ProductLog(x_*WC('b', S(1)) + WC('a', S(0)))*WC('d', S(1))), x_), cons2, cons3, cons27, cons1765) def replacement6898(d, a, b, x): rubi.append(6898) return -Int(S(1)/(d*ProductLog(a + b*x) + d), x) + Simp(d*x, x) rule6898 = ReplacementRule(pattern6898, replacement6898) pattern6899 = Pattern(Integral((ProductLog(x_*WC('b', S(1)) + WC('a', S(0)))*WC('c', S(1)))**p_/(d_ + ProductLog(x_*WC('b', S(1)) + WC('a', S(0)))*WC('d', S(1))), x_), cons2, cons3, cons7, cons27, cons13, cons163) def replacement6899(p, b, d, c, a, x): rubi.append(6899) return -Dist(c*p, Int((c*ProductLog(a + b*x))**(p + S(-1))/(d*ProductLog(a + b*x) + d), x), x) + Simp(c*(c*ProductLog(a + b*x))**(p + S(-1))*(a + b*x)/(b*d), x) rule6899 = ReplacementRule(pattern6899, replacement6899) pattern6900 = Pattern(Integral(S(1)/((d_ + ProductLog(x_*WC('b', S(1)) + WC('a', S(0)))*WC('d', S(1)))*ProductLog(x_*WC('b', S(1)) + WC('a', S(0)))), x_), cons2, cons3, cons27, cons1765) def replacement6900(d, a, b, x): rubi.append(6900) return Simp(ExpIntegralEi(ProductLog(a + b*x))/(b*d), x) rule6900 = ReplacementRule(pattern6900, replacement6900) pattern6901 = Pattern(Integral(S(1)/(sqrt(ProductLog(x_*WC('b', S(1)) + WC('a', S(0)))*WC('c', S(1)))*(d_ + ProductLog(x_*WC('b', S(1)) + WC('a', S(0)))*WC('d', S(1)))), x_), cons2, cons3, cons7, cons27, cons948) def replacement6901(b, d, c, a, x): rubi.append(6901) return Simp(Erfi(sqrt(c*ProductLog(a + b*x))/Rt(c, S(2)))*Rt(Pi*c, S(2))/(b*c*d), x) rule6901 = ReplacementRule(pattern6901, replacement6901) pattern6902 = Pattern(Integral(S(1)/(sqrt(ProductLog(x_*WC('b', S(1)) + WC('a', S(0)))*WC('c', S(1)))*(d_ + ProductLog(x_*WC('b', S(1)) + WC('a', S(0)))*WC('d', S(1)))), x_), cons2, cons3, cons7, cons27, cons949) def replacement6902(b, d, c, a, x): rubi.append(6902) return Simp(Erf(sqrt(c*ProductLog(a + b*x))/Rt(-c, S(2)))*Rt(-Pi*c, S(2))/(b*c*d), x) rule6902 = ReplacementRule(pattern6902, replacement6902) pattern6903 = Pattern(Integral((ProductLog(x_*WC('b', S(1)) + WC('a', S(0)))*WC('c', S(1)))**p_/(d_ + ProductLog(x_*WC('b', S(1)) + WC('a', S(0)))*WC('d', S(1))), x_), cons2, cons3, cons7, cons27, cons13, cons137) def replacement6903(p, b, d, c, a, x): rubi.append(6903) return -Dist(S(1)/(c*(p + S(1))), Int((c*ProductLog(a + b*x))**(p + S(1))/(d*ProductLog(a + b*x) + d), x), x) + Simp((c*ProductLog(a + b*x))**p*(a + b*x)/(b*d*(p + S(1))), x) rule6903 = ReplacementRule(pattern6903, replacement6903) pattern6904 = Pattern(Integral((ProductLog(x_*WC('b', S(1)) + WC('a', S(0)))*WC('c', S(1)))**WC('p', S(1))/(d_ + ProductLog(x_*WC('b', S(1)) + WC('a', S(0)))*WC('d', S(1))), x_), cons2, cons3, cons7, cons27, cons5, cons1982) def replacement6904(p, b, d, c, a, x): rubi.append(6904) return Simp((-ProductLog(a + b*x))**(-p)*(c*ProductLog(a + b*x))**p*Gamma(p + S(1), -ProductLog(a + b*x))/(b*d), x) rule6904 = ReplacementRule(pattern6904, replacement6904) pattern6905 = Pattern(Integral(x_**WC('m', S(1))/(d_ + ProductLog(a_ + x_*WC('b', S(1)))*WC('d', S(1))), x_), cons2, cons3, cons27, cons62) def replacement6905(m, b, d, a, x): rubi.append(6905) return Dist(S(1)/b, Subst(Int(ExpandIntegrand(S(1)/(d*ProductLog(x) + d), (-a/b + x/b)**m, x), x), x, a + b*x), x) rule6905 = ReplacementRule(pattern6905, replacement6905) pattern6906 = Pattern(Integral(x_**WC('m', S(1))*(ProductLog(a_ + x_*WC('b', S(1)))*WC('c', S(1)))**WC('p', S(1))/(d_ + ProductLog(a_ + x_*WC('b', S(1)))*WC('d', S(1))), x_), cons2, cons3, cons7, cons27, cons5, cons62) def replacement6906(p, m, b, d, c, a, x): rubi.append(6906) return Dist(S(1)/b, Subst(Int(ExpandIntegrand((c*ProductLog(x))**p/(d*ProductLog(x) + d), (-a/b + x/b)**m, x), x), x, a + b*x), x) rule6906 = ReplacementRule(pattern6906, replacement6906) pattern6907 = Pattern(Integral(S(1)/(d_ + ProductLog(x_**n_*WC('a', S(1)))*WC('d', S(1))), x_), cons2, cons27, cons196) def replacement6907(d, a, n, x): rubi.append(6907) return -Subst(Int(S(1)/(x**S(2)*(d*ProductLog(a*x**(-n)) + d)), x), x, S(1)/x) rule6907 = ReplacementRule(pattern6907, replacement6907) pattern6908 = Pattern(Integral((ProductLog(x_**WC('n', S(1))*WC('a', S(1)))*WC('c', S(1)))**WC('p', S(1))/(d_ + ProductLog(x_**WC('n', S(1))*WC('a', S(1)))*WC('d', S(1))), x_), cons2, cons7, cons27, cons4, cons5, cons1983) def replacement6908(p, d, c, n, a, x): rubi.append(6908) return Simp(c*x*(c*ProductLog(a*x**n))**(p + S(-1))/d, x) rule6908 = ReplacementRule(pattern6908, replacement6908) pattern6909 = Pattern(Integral(ProductLog(x_**WC('n', S(1))*WC('a', S(1)))**WC('p', S(1))/(d_ + ProductLog(x_**WC('n', S(1))*WC('a', S(1)))*WC('d', S(1))), x_), cons2, cons27, cons803, cons1984) def replacement6909(p, d, a, n, x): rubi.append(6909) return Simp(a**p*ExpIntegralEi(-p*ProductLog(a*x**n))/(d*n), x) rule6909 = ReplacementRule(pattern6909, replacement6909) pattern6910 = Pattern(Integral((ProductLog(x_**WC('n', S(1))*WC('a', S(1)))*WC('c', S(1)))**p_/(d_ + ProductLog(x_**WC('n', S(1))*WC('a', S(1)))*WC('d', S(1))), x_), cons2, cons7, cons27, cons803, cons1985, cons1986) def replacement6910(p, d, c, n, a, x): rubi.append(6910) return Simp(a**(-S(1)/n)*c**(-S(1)/n)*Erfi(sqrt(c*ProductLog(a*x**n))/Rt(c*n, S(2)))*Rt(Pi*c*n, S(2))/(d*n), x) rule6910 = ReplacementRule(pattern6910, replacement6910) pattern6911 = Pattern(Integral((ProductLog(x_**WC('n', S(1))*WC('a', S(1)))*WC('c', S(1)))**p_/(d_ + ProductLog(x_**WC('n', S(1))*WC('a', S(1)))*WC('d', S(1))), x_), cons2, cons7, cons27, cons803, cons1985, cons1987) def replacement6911(p, d, c, n, a, x): rubi.append(6911) return Simp(a**(-S(1)/n)*c**(-S(1)/n)*Erf(sqrt(c*ProductLog(a*x**n))/Rt(-c*n, S(2)))*Rt(-Pi*c*n, S(2))/(d*n), x) rule6911 = ReplacementRule(pattern6911, replacement6911) pattern6912 = Pattern(Integral((ProductLog(x_**WC('n', S(1))*WC('a', S(1)))*WC('c', S(1)))**WC('p', S(1))/(d_ + ProductLog(x_**WC('n', S(1))*WC('a', S(1)))*WC('d', S(1))), x_), cons2, cons7, cons27, cons338, cons88, cons1988) def replacement6912(p, d, c, n, a, x): rubi.append(6912) return -Dist(c*(n*(p + S(-1)) + S(1)), Int((c*ProductLog(a*x**n))**(p + S(-1))/(d*ProductLog(a*x**n) + d), x), x) + Simp(c*x*(c*ProductLog(a*x**n))**(p + S(-1))/d, x) rule6912 = ReplacementRule(pattern6912, replacement6912) pattern6913 = Pattern(Integral((ProductLog(x_**WC('n', S(1))*WC('a', S(1)))*WC('c', S(1)))**WC('p', S(1))/(d_ + ProductLog(x_**WC('n', S(1))*WC('a', S(1)))*WC('d', S(1))), x_), cons2, cons7, cons27, cons338, cons88, cons1989) def replacement6913(p, d, c, n, a, x): rubi.append(6913) return -Dist(S(1)/(c*(n*p + S(1))), Int((c*ProductLog(a*x**n))**(p + S(1))/(d*ProductLog(a*x**n) + d), x), x) + Simp(x*(c*ProductLog(a*x**n))**p/(d*(n*p + S(1))), x) rule6913 = ReplacementRule(pattern6913, replacement6913) pattern6914 = Pattern(Integral((ProductLog(x_**n_*WC('a', S(1)))*WC('c', S(1)))**WC('p', S(1))/(d_ + ProductLog(x_**n_*WC('a', S(1)))*WC('d', S(1))), x_), cons2, cons7, cons27, cons5, cons196) def replacement6914(p, d, c, a, n, x): rubi.append(6914) return -Subst(Int((c*ProductLog(a*x**(-n)))**p/(x**S(2)*(d*ProductLog(a*x**(-n)) + d)), x), x, S(1)/x) rule6914 = ReplacementRule(pattern6914, replacement6914) pattern6915 = Pattern(Integral(x_**WC('m', S(1))/(d_ + ProductLog(x_*WC('a', S(1)))*WC('d', S(1))), x_), cons2, cons27, cons31, cons168) def replacement6915(d, m, x, a): rubi.append(6915) return -Dist(m/(m + S(1)), Int(x**m/((d*ProductLog(a*x) + d)*ProductLog(a*x)), x), x) + Simp(x**(m + S(1))/(d*(m + S(1))*ProductLog(a*x)), x) rule6915 = ReplacementRule(pattern6915, replacement6915) pattern6916 = Pattern(Integral(S(1)/(x_*(d_ + ProductLog(x_*WC('a', S(1)))*WC('d', S(1)))), x_), cons2, cons27, cons1990) def replacement6916(d, a, x): rubi.append(6916) return Simp(log(ProductLog(a*x))/d, x) rule6916 = ReplacementRule(pattern6916, replacement6916) pattern6917 = Pattern(Integral(x_**WC('m', S(1))/(d_ + ProductLog(x_*WC('a', S(1)))*WC('d', S(1))), x_), cons2, cons27, cons31, cons94) def replacement6917(d, m, x, a): rubi.append(6917) return -Int(x**m*ProductLog(a*x)/(d*ProductLog(a*x) + d), x) + Simp(x**(m + S(1))/(d*(m + S(1))), x) rule6917 = ReplacementRule(pattern6917, replacement6917) pattern6918 = Pattern(Integral(x_**WC('m', S(1))/(d_ + ProductLog(x_*WC('a', S(1)))*WC('d', S(1))), x_), cons2, cons27, cons21, cons18) def replacement6918(d, m, x, a): rubi.append(6918) return Simp(x**m*(-(m + S(1))*ProductLog(a*x))**(-m)*Gamma(m + S(1), -(m + S(1))*ProductLog(a*x))*exp(-m*ProductLog(a*x))/(a*d*(m + S(1))), x) rule6918 = ReplacementRule(pattern6918, replacement6918) pattern6919 = Pattern(Integral(S(1)/(x_*(d_ + ProductLog(x_**WC('n', S(1))*WC('a', S(1)))*WC('d', S(1)))), x_), cons2, cons27, cons4, cons1991) def replacement6919(d, a, n, x): rubi.append(6919) return Simp(log(ProductLog(a*x**n))/(d*n), x) rule6919 = ReplacementRule(pattern6919, replacement6919) pattern6920 = Pattern(Integral(x_**WC('m', S(1))/(d_ + ProductLog(x_**n_*WC('a', S(1)))*WC('d', S(1))), x_), cons2, cons27, cons150, cons463, cons66) def replacement6920(m, d, a, n, x): rubi.append(6920) return -Subst(Int(x**(-m + S(-2))/(d*ProductLog(a*x**(-n)) + d), x), x, S(1)/x) rule6920 = ReplacementRule(pattern6920, replacement6920) pattern6921 = Pattern(Integral((ProductLog(x_**WC('n', S(1))*WC('a', S(1)))*WC('c', S(1)))**WC('p', S(1))/(x_*(d_ + ProductLog(x_**WC('n', S(1))*WC('a', S(1)))*WC('d', S(1)))), x_), cons2, cons7, cons27, cons4, cons5, cons1992) def replacement6921(p, d, c, n, a, x): rubi.append(6921) return Simp((c*ProductLog(a*x**n))**p/(d*n*p), x) rule6921 = ReplacementRule(pattern6921, replacement6921) pattern6922 = Pattern(Integral(x_**WC('m', S(1))*(ProductLog(x_**WC('n', S(1))*WC('a', S(1)))*WC('c', S(1)))**WC('p', S(1))/(d_ + ProductLog(x_**WC('n', S(1))*WC('a', S(1)))*WC('d', S(1))), x_), cons2, cons7, cons27, cons21, cons4, cons5, cons66, cons1993) def replacement6922(p, m, d, c, n, a, x): rubi.append(6922) return Simp(c*x**(m + S(1))*(c*ProductLog(a*x**n))**(p + S(-1))/(d*(m + S(1))), x) rule6922 = ReplacementRule(pattern6922, replacement6922) pattern6923 = Pattern(Integral(x_**WC('m', S(1))*ProductLog(x_**WC('n', S(1))*WC('a', S(1)))**WC('p', S(1))/(d_ + ProductLog(x_**WC('n', S(1))*WC('a', S(1)))*WC('d', S(1))), x_), cons2, cons27, cons21, cons4, cons38, cons1994) def replacement6923(p, m, d, a, n, x): rubi.append(6923) return Simp(a**p*ExpIntegralEi(-p*ProductLog(a*x**n))/(d*n), x) rule6923 = ReplacementRule(pattern6923, replacement6923) pattern6924 = Pattern(Integral(x_**WC('m', S(1))*(ProductLog(x_**WC('n', S(1))*WC('a', S(1)))*WC('c', S(1)))**p_/(d_ + ProductLog(x_**WC('n', S(1))*WC('a', S(1)))*WC('d', S(1))), x_), cons2, cons7, cons27, cons21, cons4, cons66, cons347, cons1995, cons1996) def replacement6924(p, m, d, c, n, a, x): rubi.append(6924) return Simp(a**(p + S(-1)/2)*c**(p + S(-1)/2)*Erf(sqrt(c*ProductLog(a*x**n))/Rt(c/(p + S(-1)/2), S(2)))*Rt(Pi*c/(p + S(-1)/2), S(2))/(d*n), x) rule6924 = ReplacementRule(pattern6924, replacement6924) pattern6925 = Pattern(Integral(x_**WC('m', S(1))*(ProductLog(x_**WC('n', S(1))*WC('a', S(1)))*WC('c', S(1)))**p_/(d_ + ProductLog(x_**WC('n', S(1))*WC('a', S(1)))*WC('d', S(1))), x_), cons2, cons7, cons27, cons21, cons4, cons66, cons347, cons1995, cons1997) def replacement6925(p, m, d, c, n, a, x): rubi.append(6925) return Simp(a**(p + S(-1)/2)*c**(p + S(-1)/2)*Erfi(sqrt(c*ProductLog(a*x**n))/Rt(-c/(p + S(-1)/2), S(2)))*Rt(-Pi*c/(p + S(-1)/2), S(2))/(d*n), x) rule6925 = ReplacementRule(pattern6925, replacement6925) pattern6926 = Pattern(Integral(x_**WC('m', S(1))*(ProductLog(x_**WC('n', S(1))*WC('a', S(1)))*WC('c', S(1)))**WC('p', S(1))/(d_ + ProductLog(x_**WC('n', S(1))*WC('a', S(1)))*WC('d', S(1))), x_), cons2, cons7, cons27, cons21, cons4, cons5, cons66, cons1998, cons1999) def replacement6926(p, m, d, c, n, a, x): rubi.append(6926) return -Dist(c*(m + n*(p + S(-1)) + S(1))/(m + S(1)), Int(x**m*(c*ProductLog(a*x**n))**(p + S(-1))/(d*ProductLog(a*x**n) + d), x), x) + Simp(c*x**(m + S(1))*(c*ProductLog(a*x**n))**(p + S(-1))/(d*(m + S(1))), x) rule6926 = ReplacementRule(pattern6926, replacement6926) pattern6927 = Pattern(Integral(x_**WC('m', S(1))*(ProductLog(x_**WC('n', S(1))*WC('a', S(1)))*WC('c', S(1)))**WC('p', S(1))/(d_ + ProductLog(x_**WC('n', S(1))*WC('a', S(1)))*WC('d', S(1))), x_), cons2, cons7, cons27, cons21, cons4, cons5, cons66, cons1998, cons2000) def replacement6927(p, m, d, c, n, a, x): rubi.append(6927) return -Dist((m + S(1))/(c*(m + n*p + S(1))), Int(x**m*(c*ProductLog(a*x**n))**(p + S(1))/(d*ProductLog(a*x**n) + d), x), x) + Simp(x**(m + S(1))*(c*ProductLog(a*x**n))**p/(d*(m + n*p + S(1))), x) rule6927 = ReplacementRule(pattern6927, replacement6927) pattern6928 = Pattern(Integral(x_**WC('m', S(1))*(ProductLog(x_*WC('a', S(1)))*WC('c', S(1)))**WC('p', S(1))/(d_ + ProductLog(x_*WC('a', S(1)))*WC('d', S(1))), x_), cons2, cons7, cons27, cons21, cons5, cons66) def replacement6928(p, m, d, c, a, x): rubi.append(6928) return Simp(x**m*(c*ProductLog(a*x))**p*(-(m + S(1))*ProductLog(a*x))**(-m - p)*Gamma(m + p + S(1), -(m + S(1))*ProductLog(a*x))*exp(-m*ProductLog(a*x))/(a*d*(m + S(1))), x) rule6928 = ReplacementRule(pattern6928, replacement6928) pattern6929 = Pattern(Integral(x_**WC('m', S(1))*(ProductLog(x_**WC('n', S(1))*WC('a', S(1)))*WC('c', S(1)))**WC('p', S(1))/(d_ + ProductLog(x_**WC('n', S(1))*WC('a', S(1)))*WC('d', S(1))), x_), cons2, cons7, cons27, cons5, cons66, cons150, cons463) def replacement6929(p, m, d, c, n, a, x): rubi.append(6929) return -Subst(Int(x**(-m + S(-2))*(c*ProductLog(a*x**(-n)))**p/(d*ProductLog(a*x**(-n)) + d), x), x, S(1)/x) rule6929 = ReplacementRule(pattern6929, replacement6929) pattern6930 = Pattern(Integral(u_, x_), cons2001) def replacement6930(x, u): rubi.append(6930) return Subst(Int(SimplifyIntegrand((x + S(1))*SubstFor(ProductLog(x), u, x)*exp(x), x), x), x, ProductLog(x)) rule6930 = ReplacementRule(pattern6930, replacement6930) return [rule6739, rule6740, rule6741, rule6742, rule6743, rule6744, rule6745, rule6746, rule6747, rule6748, rule6749, rule6750, rule6751, rule6752, rule6753, rule6754, rule6755, rule6756, rule6757, rule6758, rule6759, rule6760, rule6761, rule6762, rule6763, rule6764, rule6765, rule6766, rule6767, rule6768, rule6769, rule6770, rule6771, rule6772, rule6773, rule6774, rule6775, rule6776, rule6777, rule6778, rule6779, rule6780, rule6781, rule6782, rule6783, rule6784, rule6785, rule6786, rule6787, rule6788, rule6789, rule6790, rule6791, rule6792, rule6793, rule6794, rule6795, rule6796, rule6797, rule6798, rule6799, rule6800, rule6801, rule6802, rule6803, rule6804, rule6805, rule6806, rule6807, rule6808, rule6809, rule6810, rule6811, rule6812, rule6813, rule6814, rule6815, rule6816, rule6817, rule6818, rule6819, rule6820, rule6821, rule6822, rule6823, rule6824, rule6825, rule6826, rule6827, rule6828, rule6829, rule6830, rule6831, rule6832, rule6833, rule6834, rule6835, rule6836, rule6837, rule6838, rule6839, rule6840, rule6841, rule6842, rule6843, rule6844, rule6845, rule6846, rule6847, rule6848, rule6849, rule6850, rule6851, rule6852, rule6853, rule6854, rule6855, rule6856, rule6857, rule6858, rule6859, rule6860, rule6861, rule6862, rule6863, rule6864, rule6865, rule6866, rule6867, rule6868, rule6869, rule6870, rule6871, rule6872, rule6873, rule6874, rule6875, rule6876, rule6877, rule6878, rule6879, rule6880, rule6881, rule6882, rule6883, rule6884, rule6885, rule6886, rule6887, rule6888, rule6889, rule6890, rule6891, rule6892, rule6893, rule6894, rule6895, rule6896, rule6897, rule6898, rule6899, rule6900, rule6901, rule6902, rule6903, rule6904, rule6905, rule6906, rule6907, rule6908, rule6909, rule6910, rule6911, rule6912, rule6913, rule6914, rule6915, rule6916, rule6917, rule6918, rule6919, rule6920, rule6921, rule6922, rule6923, rule6924, rule6925, rule6926, rule6927, rule6928, rule6929, rule6930, ]
5e2abd8f8cdab5153884efa0a8afc39deccc7c37e82b88fddaeaa85f5fe23ab6
''' This code is automatically generated. Never edit it manually. For details of generating the code see `rubi_parsing_guide.md` in `parsetools`. ''' from sympy.external import import_module matchpy = import_module("matchpy") from sympy.utilities.decorator import doctest_depends_on if matchpy: from matchpy import Pattern, ReplacementRule, CustomConstraint, is_match from sympy.integrals.rubi.utility_function import ( Int, Sum, Set, With, Module, Scan, MapAnd, FalseQ, ZeroQ, NegativeQ, NonzeroQ, FreeQ, NFreeQ, List, Log, PositiveQ, PositiveIntegerQ, NegativeIntegerQ, IntegerQ, IntegersQ, ComplexNumberQ, PureComplexNumberQ, RealNumericQ, PositiveOrZeroQ, NegativeOrZeroQ, FractionOrNegativeQ, NegQ, Equal, Unequal, IntPart, FracPart, RationalQ, ProductQ, SumQ, NonsumQ, Subst, First, Rest, SqrtNumberQ, SqrtNumberSumQ, LinearQ, Sqrt, ArcCosh, Coefficient, Denominator, Hypergeometric2F1, Not, Simplify, FractionalPart, IntegerPart, AppellF1, EllipticPi, EllipticE, EllipticF, ArcTan, ArcCot, ArcCoth, ArcTanh, ArcSin, ArcSinh, ArcCos, ArcCsc, ArcSec, ArcCsch, ArcSech, Sinh, Tanh, Cosh, Sech, Csch, Coth, LessEqual, Less, Greater, GreaterEqual, FractionQ, IntLinearcQ, Expand, IndependentQ, PowerQ, IntegerPowerQ, PositiveIntegerPowerQ, FractionalPowerQ, AtomQ, ExpQ, LogQ, Head, MemberQ, TrigQ, SinQ, CosQ, TanQ, CotQ, SecQ, CscQ, Sin, Cos, Tan, Cot, Sec, Csc, HyperbolicQ, SinhQ, CoshQ, TanhQ, CothQ, SechQ, CschQ, InverseTrigQ, SinCosQ, SinhCoshQ, LeafCount, Numerator, NumberQ, NumericQ, Length, ListQ, Im, Re, InverseHyperbolicQ, InverseFunctionQ, TrigHyperbolicFreeQ, InverseFunctionFreeQ, RealQ, EqQ, FractionalPowerFreeQ, ComplexFreeQ, PolynomialQ, FactorSquareFree, PowerOfLinearQ, Exponent, QuadraticQ, LinearPairQ, BinomialParts, TrinomialParts, PolyQ, EvenQ, OddQ, PerfectSquareQ, NiceSqrtAuxQ, NiceSqrtQ, Together, PosAux, PosQ, CoefficientList, ReplaceAll, ExpandLinearProduct, GCD, ContentFactor, NumericFactor, NonnumericFactors, MakeAssocList, GensymSubst, KernelSubst, ExpandExpression, Apart, SmartApart, MatchQ, PolynomialQuotientRemainder, FreeFactors, NonfreeFactors, RemoveContentAux, RemoveContent, FreeTerms, NonfreeTerms, ExpandAlgebraicFunction, CollectReciprocals, ExpandCleanup, AlgebraicFunctionQ, Coeff, LeadTerm, RemainingTerms, LeadFactor, RemainingFactors, LeadBase, LeadDegree, Numer, Denom, hypergeom, Expon, MergeMonomials, PolynomialDivide, BinomialQ, TrinomialQ, GeneralizedBinomialQ, GeneralizedTrinomialQ, FactorSquareFreeList, PerfectPowerTest, SquareFreeFactorTest, RationalFunctionQ, RationalFunctionFactors, NonrationalFunctionFactors, Reverse, RationalFunctionExponents, RationalFunctionExpand, ExpandIntegrand, SimplerQ, SimplerSqrtQ, SumSimplerQ, BinomialDegree, TrinomialDegree, CancelCommonFactors, SimplerIntegrandQ, GeneralizedBinomialDegree, GeneralizedBinomialParts, GeneralizedTrinomialDegree, GeneralizedTrinomialParts, MonomialQ, MonomialSumQ, MinimumMonomialExponent, MonomialExponent, LinearMatchQ, PowerOfLinearMatchQ, QuadraticMatchQ, CubicMatchQ, BinomialMatchQ, TrinomialMatchQ, GeneralizedBinomialMatchQ, GeneralizedTrinomialMatchQ, QuotientOfLinearsMatchQ, PolynomialTermQ, PolynomialTerms, NonpolynomialTerms, PseudoBinomialParts, NormalizePseudoBinomial, PseudoBinomialPairQ, PseudoBinomialQ, PolynomialGCD, PolyGCD, AlgebraicFunctionFactors, NonalgebraicFunctionFactors, QuotientOfLinearsP, QuotientOfLinearsParts, QuotientOfLinearsQ, Flatten, Sort, AbsurdNumberQ, AbsurdNumberFactors, NonabsurdNumberFactors, SumSimplerAuxQ, Prepend, Drop, CombineExponents, FactorInteger, FactorAbsurdNumber, SubstForInverseFunction, SubstForFractionalPower, SubstForFractionalPowerOfQuotientOfLinears, FractionalPowerOfQuotientOfLinears, SubstForFractionalPowerQ, SubstForFractionalPowerAuxQ, FractionalPowerOfSquareQ, FractionalPowerSubexpressionQ, Apply, FactorNumericGcd, MergeableFactorQ, MergeFactor, MergeFactors, TrigSimplifyQ, TrigSimplify, TrigSimplifyRecur, Order, FactorOrder, Smallest, OrderedQ, MinimumDegree, PositiveFactors, Sign, NonpositiveFactors, PolynomialInAuxQ, PolynomialInQ, ExponentInAux, ExponentIn, PolynomialInSubstAux, PolynomialInSubst, Distrib, DistributeDegree, FunctionOfPower, DivideDegreesOfFactors, MonomialFactor, FullSimplify, FunctionOfLinearSubst, FunctionOfLinear, NormalizeIntegrand, NormalizeIntegrandAux, NormalizeIntegrandFactor, NormalizeIntegrandFactorBase, NormalizeTogether, NormalizeLeadTermSigns, AbsorbMinusSign, NormalizeSumFactors, SignOfFactor, NormalizePowerOfLinear, SimplifyIntegrand, SimplifyTerm, TogetherSimplify, SmartSimplify, SubstForExpn, ExpandToSum, UnifySum, UnifyTerms, UnifyTerm, CalculusQ, FunctionOfInverseLinear, PureFunctionOfSinhQ, PureFunctionOfTanhQ, PureFunctionOfCoshQ, IntegerQuotientQ, OddQuotientQ, EvenQuotientQ, FindTrigFactor, FunctionOfSinhQ, FunctionOfCoshQ, OddHyperbolicPowerQ, FunctionOfTanhQ, FunctionOfTanhWeight, FunctionOfHyperbolicQ, SmartNumerator, SmartDenominator, SubstForAux, ActivateTrig, ExpandTrig, TrigExpand, SubstForTrig, SubstForHyperbolic, InertTrigFreeQ, LCM, SubstForFractionalPowerOfLinear, FractionalPowerOfLinear, InverseFunctionOfLinear, InertTrigQ, InertReciprocalQ, DeactivateTrig, FixInertTrigFunction, DeactivateTrigAux, PowerOfInertTrigSumQ, PiecewiseLinearQ, KnownTrigIntegrandQ, KnownSineIntegrandQ, KnownTangentIntegrandQ, KnownCotangentIntegrandQ, KnownSecantIntegrandQ, TryPureTanSubst, TryTanhSubst, TryPureTanhSubst, AbsurdNumberGCD, AbsurdNumberGCDList, ExpandTrigExpand, ExpandTrigReduce, ExpandTrigReduceAux, NormalizeTrig, TrigToExp, ExpandTrigToExp, TrigReduce, FunctionOfTrig, AlgebraicTrigFunctionQ, FunctionOfHyperbolic, FunctionOfQ, FunctionOfExpnQ, PureFunctionOfSinQ, PureFunctionOfCosQ, PureFunctionOfTanQ, PureFunctionOfCotQ, FunctionOfCosQ, FunctionOfSinQ, OddTrigPowerQ, FunctionOfTanQ, FunctionOfTanWeight, FunctionOfTrigQ, FunctionOfDensePolynomialsQ, FunctionOfLog, PowerVariableExpn, PowerVariableDegree, PowerVariableSubst, EulerIntegrandQ, FunctionOfSquareRootOfQuadratic, SquareRootOfQuadraticSubst, Divides, EasyDQ, ProductOfLinearPowersQ, Rt, NthRoot, AtomBaseQ, SumBaseQ, NegSumBaseQ, AllNegTermQ, SomeNegTermQ, TrigSquareQ, RtAux, TrigSquare, IntSum, IntTerm, Map2, ConstantFactor, SameQ, ReplacePart, CommonFactors, MostMainFactorPosition, FunctionOfExponentialQ, FunctionOfExponential, FunctionOfExponentialFunction, FunctionOfExponentialFunctionAux, FunctionOfExponentialTest, FunctionOfExponentialTestAux, stdev, rubi_test, If, IntQuadraticQ, IntBinomialQ, RectifyTangent, RectifyCotangent, Inequality, Condition, Simp, SimpHelp, SplitProduct, SplitSum, SubstFor, SubstForAux, FresnelS, FresnelC, Erfc, Erfi, Gamma, FunctionOfTrigOfLinearQ, ElementaryFunctionQ, Complex, UnsameQ, _SimpFixFactor, SimpFixFactor, _FixSimplify, FixSimplify, _SimplifyAntiderivativeSum, SimplifyAntiderivativeSum, _SimplifyAntiderivative, SimplifyAntiderivative, _TrigSimplifyAux, TrigSimplifyAux, Cancel, Part, PolyLog, D, Dist, Sum_doit, PolynomialQuotient, Floor, PolynomialRemainder, Factor, PolyLog, CosIntegral, SinIntegral, LogIntegral, SinhIntegral, CoshIntegral, Rule, Erf, PolyGamma, ExpIntegralEi, ExpIntegralE, LogGamma , UtilityOperator, Factorial, Zeta, ProductLog, DerivativeDivides, HypergeometricPFQ, IntHide, OneQ, Null, rubi_exp as exp, rubi_log as log, Discriminant, Negative, Quotient ) from sympy import (Integral, S, sqrt, And, Or, Integer, Float, Mod, I, Abs, simplify, Mul, Add, Pow, sign, EulerGamma) from sympy.integrals.rubi.symbol import WC from sympy.core.symbol import symbols, Symbol from sympy.functions import (sin, cos, tan, cot, csc, sec, sqrt, erf) from sympy.functions.elementary.hyperbolic import (acosh, asinh, atanh, acoth, acsch, asech, cosh, sinh, tanh, coth, sech, csch) from sympy.functions.elementary.trigonometric import (atan, acsc, asin, acot, acos, asec, atan2) from sympy import pi as Pi A_, B_, C_, F_, G_, H_, a_, b_, c_, d_, e_, f_, g_, h_, i_, j_, k_, l_, m_, n_, p_, q_, r_, t_, u_, v_, s_, w_, x_, y_, z_ = [WC(i) for i in 'ABCFGHabcdefghijklmnpqrtuvswxyz'] a1_, a2_, b1_, b2_, c1_, c2_, d1_, d2_, n1_, n2_, e1_, e2_, f1_, f2_, g1_, g2_, n1_, n2_, n3_, Pq_, Pm_, Px_, Qm_, Qr_, Qx_, jn_, mn_, non2_, RFx_, RGx_ = [WC(i) for i in ['a1', 'a2', 'b1', 'b2', 'c1', 'c2', 'd1', 'd2', 'n1', 'n2', 'e1', 'e2', 'f1', 'f2', 'g1', 'g2', 'n1', 'n2', 'n3', 'Pq', 'Pm', 'Px', 'Qm', 'Qr', 'Qx', 'jn', 'mn', 'non2', 'RFx', 'RGx']] i, ii , Pqq, Q, R, r, C, k, u = symbols('i ii Pqq Q R r C k u') _UseGamma = False ShowSteps = False StepCounter = None def miscellaneous_algebraic(rubi): from sympy.integrals.rubi.constraints import cons798, cons2, cons3, cons7, cons50, cons4, cons5, cons17, cons21, cons799, cons27, cons48, cons125, cons52, cons800, cons25, cons801, cons802, cons149, cons803, cons500, cons804, cons648, cons805, cons806, cons18, cons46, cons807, cons808, cons68, cons809, cons810, cons811, cons812, cons813, cons814, cons815, cons816, cons817, cons818, cons819, cons820, cons821, cons452, cons822, cons823, cons824, cons825, cons826, cons827, cons828, cons829, cons830, cons831, cons832, cons833, cons834, cons835, cons836, cons837, cons838, cons839, cons840, cons841, cons842, cons843, cons844, cons845, cons846, cons847, cons848, cons849, cons850, cons851, cons852, cons208, cons209, cons64, cons853, cons66, cons854, cons855, cons464, cons856, cons857, cons858, cons53, cons13, cons137, cons859, cons860, cons148, cons244, cons163, cons861, cons521, cons862, cons863, cons864, cons84, cons865, cons34, cons35, cons866, cons468, cons469, cons867, cons868, cons36, cons869, cons870, cons871, cons872, cons873, cons874, cons875, cons876, cons877, cons878, cons879, cons880, cons881, cons882, cons883, cons884, cons885, cons886, cons887, cons888, cons889, cons890, cons891, cons892, cons893, cons894, cons895, cons896, cons897, cons898, cons899, cons900, cons901, cons902, cons903, cons904, cons674, cons905, cons481, cons906, cons907, cons482, cons908, cons909, cons910, cons911, cons912, cons913, cons914, cons915, cons916, cons85, cons31, cons94, cons917, cons196, cons367, cons356, cons489, cons541, cons23, cons918, cons554, cons919, cons552, cons55, cons494, cons57, cons58, cons59, cons60, cons920, cons921, cons922, cons923, cons924, cons595, cons71, cons925, cons586, cons87, cons128, cons926, cons927, cons928, cons929, cons930, cons45, cons314, cons226, cons931, cons932, cons933, cons934, cons935, cons936, cons937, cons938, cons939, cons940, cons941, cons942, cons943, cons944, cons945, cons946, cons282, cons947, cons63, cons719, cons948, cons949, cons950, cons73, cons951, cons702, cons147, cons952, cons953, cons796, cons954, cons955, cons956, cons957, cons958, cons959, cons960, cons961, cons962, cons963, cons964, cons965, cons966, cons69, cons967, cons968, cons969, cons970, cons971, cons972, cons973, cons974, cons975, cons512, cons976, cons977, cons978, cons979, cons980, cons667, cons981, cons982, cons797, cons983, cons984, cons985, cons986, cons987, cons988, cons93, cons88, cons989, cons990, cons991, cons992, cons993, cons994, cons995, cons996, cons997, cons998, cons38, cons999, cons1000, cons1001, cons1002, cons1003, cons1004, cons1005, cons1006, cons1007, cons1008, cons1009, cons1010, cons383, cons1011, cons1012, cons1013, cons1014, cons1015, cons1016, cons1017, cons1018, cons357, cons1019, cons246, cons1020, cons1021, cons1022, cons1023, cons1024, cons1025, cons1026, cons1027, cons1028, cons1029, cons1030, cons1031, cons1032, cons1033, cons1034, cons1035, cons1036, cons1037, cons1038, cons1039, cons1040, cons1041, cons1042, cons1043, cons297, cons1044, cons1045, cons1046, cons1047, cons1048, cons705, cons382, cons1049, cons1050, cons697, cons709, cons153, cons1051, cons1052, cons1053, cons1054, cons1055, cons1056, cons1057, cons1058, cons1059, cons224, cons1060, cons515, cons1061, cons1062, cons1063, cons1064, cons1065, cons1066, cons1067, cons1068, cons1069, cons1070, cons1071, cons43, cons479, cons480, cons1072, cons1073, cons1074, cons1075, cons1076, cons1077, cons1078, cons1079, cons1080, cons1081, cons1082, cons1083, cons1084, cons1085, cons1086, cons1087, cons1088, cons1089 pattern1473 = Pattern(Integral(((x_**n_*WC('c', S(1)))**q_*WC('b', S(1)) + WC('a', S(0)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons50, cons4, cons5, cons798) def replacement1473(p, b, c, a, n, x, q): rubi.append(1473) return Dist(x*(c*x**n)**(-S(1)/n), Subst(Int((a + b*x**(n*q))**p, x), x, (c*x**n)**(S(1)/n)), x) rule1473 = ReplacementRule(pattern1473, replacement1473) pattern1474 = Pattern(Integral(x_**WC('m', S(1))*((x_**n_*WC('c', S(1)))**q_*WC('b', S(1)) + WC('a', S(0)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons21, cons4, cons5, cons50, cons798, cons17) def replacement1474(p, m, b, c, a, n, x, q): rubi.append(1474) return Dist(x**(m + S(1))*(c*x**n)**(-(m + S(1))/n), Subst(Int(x**m*(a + b*x**(n*q))**p, x), x, (c*x**n)**(S(1)/n)), x) rule1474 = ReplacementRule(pattern1474, replacement1474) pattern1475 = Pattern(Integral(x_**WC('m', S(1))*((a_ + x_**WC('n', S(1))*WC('b', S(1)))**WC('r', S(1))*WC('e', S(1)))**p_*((c_ + x_**WC('n', S(1))*WC('d', S(1)))**s_*WC('f', S(1)))**q_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons4, cons5, cons50, cons52, cons800, cons799) def replacement1475(p, q, m, f, b, r, d, a, n, c, x, s, e): rubi.append(1475) return Dist((e*(a + b*x**n)**r)**p*(f*(c + d*x**n)**s)**q*(a + b*x**n)**(-p*r)*(c + d*x**n)**(-q*s), Int(x**m*(a + b*x**n)**(p*r)*(c + d*x**n)**(q*s), x), x) rule1475 = ReplacementRule(pattern1475, replacement1475) pattern1476 = Pattern(Integral(((x_**WC('n', S(1))*WC('b', S(1)) + WC('a', S(0)))*WC('e', S(1))/(c_ + x_**WC('n', S(1))*WC('d', S(1))))**p_*WC('u', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons4, cons5, cons25) def replacement1476(p, u, b, d, a, n, c, x, e): rubi.append(1476) return Dist((b*e/d)**p, Int(u, x), x) rule1476 = ReplacementRule(pattern1476, replacement1476) pattern1477 = Pattern(Integral(((x_**WC('n', S(1))*WC('b', S(1)) + WC('a', S(0)))*WC('e', S(1))/(c_ + x_**WC('n', S(1))*WC('d', S(1))))**p_*WC('u', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons4, cons5, cons801, cons802) def replacement1477(p, u, b, d, a, n, c, x, e): rubi.append(1477) return Int(u*(e*(a + b*x**n))**p*(c + d*x**n)**(-p), x) rule1477 = ReplacementRule(pattern1477, replacement1477) def With1478(p, b, d, a, n, c, x, e): q = Denominator(p) rubi.append(1478) return Dist(e*q*(-a*d + b*c)/n, Subst(Int(x**(q*(p + S(1)) + S(-1))*(-a*e + c*x**q)**(S(-1) + S(1)/n)*(b*e - d*x**q)**(S(-1) - S(1)/n), x), x, (e*(a + b*x**n)/(c + d*x**n))**(S(1)/q)), x) pattern1478 = Pattern(Integral(((x_**WC('n', S(1))*WC('b', S(1)) + WC('a', S(0)))*WC('e', S(1))/(c_ + x_**WC('n', S(1))*WC('d', S(1))))**p_, x_), cons2, cons3, cons7, cons27, cons48, cons149, cons803) rule1478 = ReplacementRule(pattern1478, With1478) def With1479(p, m, b, d, a, n, c, x, e): q = Denominator(p) rubi.append(1479) return Dist(e*q*(-a*d + b*c)/n, Subst(Int(x**(q*(p + S(1)) + S(-1))*(-a*e + c*x**q)**(S(-1) + (m + S(1))/n)*(b*e - d*x**q)**(S(-1) - (m + S(1))/n), x), x, (e*(a + b*x**n)/(c + d*x**n))**(S(1)/q)), x) pattern1479 = Pattern(Integral(x_**WC('m', S(1))*((x_**WC('n', S(1))*WC('b', S(1)) + WC('a', S(0)))*WC('e', S(1))/(c_ + x_**WC('n', S(1))*WC('d', S(1))))**p_, x_), cons2, cons3, cons7, cons27, cons48, cons21, cons4, cons149, cons500) rule1479 = ReplacementRule(pattern1479, With1479) def With1480(p, u, b, r, d, a, n, c, x, e): q = Denominator(p) rubi.append(1480) return Dist(e*q*(-a*d + b*c)/n, Subst(Int(SimplifyIntegrand(x**(q*(p + S(1)) + S(-1))*(-a*e + c*x**q)**(S(-1) + S(1)/n)*(b*e - d*x**q)**(S(-1) - S(1)/n)*ReplaceAll(u, Rule(x, (-a*e + c*x**q)**(S(1)/n)*(b*e - d*x**q)**(-S(1)/n)))**r, x), x), x, (e*(a + b*x**n)/(c + d*x**n))**(S(1)/q)), x) pattern1480 = Pattern(Integral(u_**WC('r', S(1))*((x_**WC('n', S(1))*WC('b', S(1)) + WC('a', S(0)))*WC('e', S(1))/(c_ + x_**WC('n', S(1))*WC('d', S(1))))**p_, x_), cons2, cons3, cons7, cons27, cons48, cons804, cons149, cons803, cons648) rule1480 = ReplacementRule(pattern1480, With1480) def With1481(p, u, m, b, r, d, a, n, c, x, e): q = Denominator(p) rubi.append(1481) return Dist(e*q*(-a*d + b*c)/n, Subst(Int(SimplifyIntegrand(x**(q*(p + S(1)) + S(-1))*(-a*e + c*x**q)**(S(-1) + (m + S(1))/n)*(b*e - d*x**q)**(S(-1) - (m + S(1))/n)*ReplaceAll(u, Rule(x, (-a*e + c*x**q)**(S(1)/n)*(b*e - d*x**q)**(-S(1)/n)))**r, x), x), x, (e*(a + b*x**n)/(c + d*x**n))**(S(1)/q)), x) pattern1481 = Pattern(Integral(u_**WC('r', S(1))*x_**WC('m', S(1))*((x_**WC('n', S(1))*WC('b', S(1)) + WC('a', S(0)))*WC('e', S(1))/(c_ + x_**WC('n', S(1))*WC('d', S(1))))**p_, x_), cons2, cons3, cons7, cons27, cons48, cons804, cons149, cons803, cons805) rule1481 = ReplacementRule(pattern1481, With1481) pattern1482 = Pattern(Integral(((WC('c', S(1))/x_)**n_*WC('b', S(1)) + WC('a', S(0)))**p_, x_), cons2, cons3, cons7, cons4, cons5, cons806) def replacement1482(p, b, c, a, n, x): rubi.append(1482) return -Dist(c, Subst(Int((a + b*x**n)**p/x**S(2), x), x, c/x), x) rule1482 = ReplacementRule(pattern1482, replacement1482) pattern1483 = Pattern(Integral(x_**WC('m', S(1))*((WC('c', S(1))/x_)**n_*WC('b', S(1)) + WC('a', S(0)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons4, cons5, cons17) def replacement1483(p, m, b, c, a, n, x): rubi.append(1483) return -Dist(c**(m + S(1)), Subst(Int(x**(-m + S(-2))*(a + b*x**n)**p, x), x, c/x), x) rule1483 = ReplacementRule(pattern1483, replacement1483) pattern1484 = Pattern(Integral((x_*WC('d', S(1)))**m_*((WC('c', S(1))/x_)**n_*WC('b', S(1)) + WC('a', S(0)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons21, cons4, cons5, cons18) def replacement1484(p, m, b, d, c, a, n, x): rubi.append(1484) return -Dist(c*(c/x)**m*(d*x)**m, Subst(Int(x**(-m + S(-2))*(a + b*x**n)**p, x), x, c/x), x) rule1484 = ReplacementRule(pattern1484, replacement1484) pattern1485 = Pattern(Integral(((WC('d', S(1))/x_)**n_*WC('b', S(1)) + (WC('d', S(1))/x_)**WC('n2', S(1))*WC('c', S(1)) + WC('a', S(0)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons4, cons5, cons46) def replacement1485(p, b, n2, d, a, c, n, x): rubi.append(1485) return -Dist(d, Subst(Int((a + b*x**n + c*x**(S(2)*n))**p/x**S(2), x), x, d/x), x) rule1485 = ReplacementRule(pattern1485, replacement1485) pattern1486 = Pattern(Integral(x_**WC('m', S(1))*(a_ + (WC('d', S(1))/x_)**n_*WC('b', S(1)) + (WC('d', S(1))/x_)**WC('n2', S(1))*WC('c', S(1)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons4, cons5, cons46, cons17) def replacement1486(p, m, b, n2, d, c, a, n, x): rubi.append(1486) return -Dist(d**(m + S(1)), Subst(Int(x**(-m + S(-2))*(a + b*x**n + c*x**(S(2)*n))**p, x), x, d/x), x) rule1486 = ReplacementRule(pattern1486, replacement1486) pattern1487 = Pattern(Integral((x_*WC('e', S(1)))**m_*(a_ + (WC('d', S(1))/x_)**n_*WC('b', S(1)) + (WC('d', S(1))/x_)**WC('n2', S(1))*WC('c', S(1)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons21, cons4, cons5, cons46, cons18) def replacement1487(p, m, b, n2, d, c, a, n, x, e): rubi.append(1487) return -Dist(d*(d/x)**m*(e*x)**m, Subst(Int(x**(-m + S(-2))*(a + b*x**n + c*x**(S(2)*n))**p, x), x, d/x), x) rule1487 = ReplacementRule(pattern1487, replacement1487) pattern1488 = Pattern(Integral((x_**WC('n2', S(1))*WC('c', S(1)) + (WC('d', S(1))/x_)**n_*WC('b', S(1)) + WC('a', S(0)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons4, cons5, cons807, cons808) def replacement1488(p, b, n2, d, c, a, n, x): rubi.append(1488) return -Dist(d, Subst(Int((a + b*x**n + c*d**(-S(2)*n)*x**(S(2)*n))**p/x**S(2), x), x, d/x), x) rule1488 = ReplacementRule(pattern1488, replacement1488) pattern1489 = Pattern(Integral(x_**WC('m', S(1))*(a_ + x_**WC('n2', S(1))*WC('c', S(1)) + (WC('d', S(1))/x_)**n_*WC('b', S(1)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons4, cons5, cons807, cons808, cons17) def replacement1489(p, m, b, n2, d, c, a, n, x): rubi.append(1489) return -Dist(d**(m + S(1)), Subst(Int(x**(-m + S(-2))*(a + b*x**n + c*d**(-S(2)*n)*x**(S(2)*n))**p, x), x, d/x), x) rule1489 = ReplacementRule(pattern1489, replacement1489) pattern1490 = Pattern(Integral((x_*WC('e', S(1)))**m_*(a_ + x_**WC('n2', S(1))*WC('c', S(1)) + (WC('d', S(1))/x_)**n_*WC('b', S(1)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons4, cons5, cons807, cons18, cons808) def replacement1490(p, m, b, n2, d, c, a, n, x, e): rubi.append(1490) return -Dist(d*(d/x)**m*(e*x)**m, Subst(Int(x**(-m + S(-2))*(a + b*x**n + c*d**(-S(2)*n)*x**(S(2)*n))**p, x), x, d/x), x) rule1490 = ReplacementRule(pattern1490, replacement1490) pattern1491 = Pattern(Integral(u_**m_, x_), cons21, cons68, cons809) def replacement1491(x, m, u): rubi.append(1491) return Int(ExpandToSum(u, x)**m, x) rule1491 = ReplacementRule(pattern1491, replacement1491) pattern1492 = Pattern(Integral(u_**WC('m', S(1))*v_**WC('n', S(1)), x_), cons21, cons4, cons810, cons811) def replacement1492(v, u, m, n, x): rubi.append(1492) return Int(ExpandToSum(u, x)**m*ExpandToSum(v, x)**n, x) rule1492 = ReplacementRule(pattern1492, replacement1492) pattern1493 = Pattern(Integral(u_**WC('m', S(1))*v_**WC('n', S(1))*w_**WC('p', S(1)), x_), cons21, cons4, cons5, cons812, cons813) def replacement1493(v, w, p, u, m, n, x): rubi.append(1493) return Int(ExpandToSum(u, x)**m*ExpandToSum(v, x)**n*ExpandToSum(w, x)**p, x) rule1493 = ReplacementRule(pattern1493, replacement1493) pattern1494 = Pattern(Integral(u_**WC('m', S(1))*v_**WC('n', S(1))*w_**WC('p', S(1))*z_**WC('q', S(1)), x_), cons21, cons4, cons5, cons50, cons814, cons815) def replacement1494(v, z, w, p, u, m, n, x, q): rubi.append(1494) return Int(ExpandToSum(u, x)**m*ExpandToSum(v, x)**n*ExpandToSum(w, x)**p*ExpandToSum(z, x)**q, x) rule1494 = ReplacementRule(pattern1494, replacement1494) pattern1495 = Pattern(Integral(u_**p_, x_), cons5, cons816, cons817) def replacement1495(x, p, u): rubi.append(1495) return Int(ExpandToSum(u, x)**p, x) rule1495 = ReplacementRule(pattern1495, replacement1495) pattern1496 = Pattern(Integral(u_**WC('m', S(1))*v_**WC('p', S(1)), x_), cons21, cons5, cons68, cons818, cons819) def replacement1496(v, p, u, m, x): rubi.append(1496) return Int(ExpandToSum(u, x)**m*ExpandToSum(v, x)**p, x) rule1496 = ReplacementRule(pattern1496, replacement1496) pattern1497 = Pattern(Integral(u_**WC('m', S(1))*v_**WC('n', S(1))*w_**WC('p', S(1)), x_), cons21, cons4, cons5, cons810, cons820, cons821) def replacement1497(v, w, p, u, m, n, x): rubi.append(1497) return Int(ExpandToSum(u, x)**m*ExpandToSum(v, x)**n*ExpandToSum(w, x)**p, x) rule1497 = ReplacementRule(pattern1497, replacement1497) pattern1498 = Pattern(Integral(u_**WC('p', S(1))*v_**WC('q', S(1)), x_), cons5, cons50, cons452, cons822) def replacement1498(v, p, u, x, q): rubi.append(1498) return Int(ExpandToSum(u, x)**p*ExpandToSum(v, x)**q, x) rule1498 = ReplacementRule(pattern1498, replacement1498) pattern1499 = Pattern(Integral(u_**p_, x_), cons5, cons823, cons824) def replacement1499(x, p, u): rubi.append(1499) return Int(ExpandToSum(u, x)**p, x) rule1499 = ReplacementRule(pattern1499, replacement1499) pattern1500 = Pattern(Integral(u_**WC('p', S(1))*(x_*WC('c', S(1)))**WC('m', S(1)), x_), cons7, cons21, cons5, cons823, cons824) def replacement1500(p, u, m, c, x): rubi.append(1500) return Int((c*x)**m*ExpandToSum(u, x)**p, x) rule1500 = ReplacementRule(pattern1500, replacement1500) pattern1501 = Pattern(Integral(u_**WC('p', S(1))*v_**WC('q', S(1)), x_), cons5, cons50, cons825, cons826, cons827) def replacement1501(v, p, u, x, q): rubi.append(1501) return Int(ExpandToSum(u, x)**p*ExpandToSum(v, x)**q, x) rule1501 = ReplacementRule(pattern1501, replacement1501) pattern1502 = Pattern(Integral(u_**WC('p', S(1))*v_**WC('q', S(1))*x_**WC('m', S(1)), x_), cons21, cons5, cons50, cons825, cons826, cons827) def replacement1502(v, p, u, m, x, q): rubi.append(1502) return Int(x**m*ExpandToSum(u, x)**p*ExpandToSum(v, x)**q, x) rule1502 = ReplacementRule(pattern1502, replacement1502) pattern1503 = Pattern(Integral(u_**WC('m', S(1))*v_**WC('p', S(1))*w_**WC('q', S(1)), x_), cons21, cons5, cons50, cons828, cons826, cons829, cons830) def replacement1503(v, w, p, u, m, x, q): rubi.append(1503) return Int(ExpandToSum(u, x)**m*ExpandToSum(v, x)**p*ExpandToSum(w, x)**q, x) rule1503 = ReplacementRule(pattern1503, replacement1503) pattern1504 = Pattern(Integral(u_**WC('p', S(1))*v_**WC('q', S(1))*x_**WC('m', S(1))*z_**WC('r', S(1)), x_), cons21, cons5, cons50, cons52, cons831, cons826, cons832, cons833) def replacement1504(v, z, p, u, m, r, x, q): rubi.append(1504) return Int(x**m*ExpandToSum(u, x)**p*ExpandToSum(v, x)**q*ExpandToSum(z, x)**r, x) rule1504 = ReplacementRule(pattern1504, replacement1504) pattern1505 = Pattern(Integral(u_**p_, x_), cons5, cons834, cons835) def replacement1505(x, p, u): rubi.append(1505) return Int(ExpandToSum(u, x)**p, x) rule1505 = ReplacementRule(pattern1505, replacement1505) pattern1506 = Pattern(Integral(u_**WC('p', S(1))*x_**WC('m', S(1)), x_), cons21, cons5, cons834, cons835) def replacement1506(x, m, p, u): rubi.append(1506) return Int(x**m*ExpandToSum(u, x)**p, x) rule1506 = ReplacementRule(pattern1506, replacement1506) pattern1507 = Pattern(Integral(u_**p_, x_), cons5, cons836, cons837) def replacement1507(x, p, u): rubi.append(1507) return Int(ExpandToSum(u, x)**p, x) rule1507 = ReplacementRule(pattern1507, replacement1507) pattern1508 = Pattern(Integral(u_**WC('p', S(1))*(x_*WC('d', S(1)))**WC('m', S(1)), x_), cons27, cons21, cons5, cons836, cons837) def replacement1508(p, u, m, d, x): rubi.append(1508) return Int((d*x)**m*ExpandToSum(u, x)**p, x) rule1508 = ReplacementRule(pattern1508, replacement1508) pattern1509 = Pattern(Integral(u_**WC('q', S(1))*v_**WC('p', S(1)), x_), cons5, cons50, cons823, cons838, cons839) def replacement1509(v, p, u, x, q): rubi.append(1509) return Int(ExpandToSum(u, x)**q*ExpandToSum(v, x)**p, x) rule1509 = ReplacementRule(pattern1509, replacement1509) pattern1510 = Pattern(Integral(u_**WC('q', S(1))*v_**WC('p', S(1)), x_), cons5, cons50, cons823, cons840, cons841) def replacement1510(v, p, u, x, q): rubi.append(1510) return Int(ExpandToSum(u, x)**q*ExpandToSum(v, x)**p, x) rule1510 = ReplacementRule(pattern1510, replacement1510) pattern1511 = Pattern(Integral(u_**WC('p', S(1))*x_**WC('m', S(1))*z_**WC('q', S(1)), x_), cons21, cons5, cons50, cons842, cons836, cons843) def replacement1511(z, p, u, m, x, q): rubi.append(1511) return Int(x**m*ExpandToSum(u, x)**p*ExpandToSum(z, x)**q, x) rule1511 = ReplacementRule(pattern1511, replacement1511) pattern1512 = Pattern(Integral(u_**WC('p', S(1))*x_**WC('m', S(1))*z_**WC('q', S(1)), x_), cons21, cons5, cons50, cons842, cons823, cons844) def replacement1512(z, p, u, m, x, q): rubi.append(1512) return Int(x**m*ExpandToSum(u, x)**p*ExpandToSum(z, x)**q, x) rule1512 = ReplacementRule(pattern1512, replacement1512) pattern1513 = Pattern(Integral(u_**p_, x_), cons5, cons845, cons846) def replacement1513(x, p, u): rubi.append(1513) return Int(ExpandToSum(u, x)**p, x) rule1513 = ReplacementRule(pattern1513, replacement1513) pattern1514 = Pattern(Integral(u_**WC('p', S(1))*x_**WC('m', S(1)), x_), cons21, cons5, cons845, cons846) def replacement1514(x, m, p, u): rubi.append(1514) return Int(x**m*ExpandToSum(u, x)**p, x) rule1514 = ReplacementRule(pattern1514, replacement1514) pattern1515 = Pattern(Integral(u_**WC('p', S(1))*z_, x_), cons5, cons842, cons845, cons847, cons848) def replacement1515(x, z, p, u): rubi.append(1515) return Int(ExpandToSum(u, x)**p*ExpandToSum(z, x), x) rule1515 = ReplacementRule(pattern1515, replacement1515) pattern1516 = Pattern(Integral(u_**WC('p', S(1))*x_**WC('m', S(1))*z_, x_), cons21, cons5, cons842, cons845, cons847, cons848) def replacement1516(z, p, u, m, x): rubi.append(1516) return Int(x**m*ExpandToSum(u, x)**p*ExpandToSum(z, x), x) rule1516 = ReplacementRule(pattern1516, replacement1516) pattern1517 = Pattern(Integral(x_**WC('m', S(1))*(e_ + x_**WC('n', S(1))*WC('h', S(1)) + x_**WC('q', S(1))*WC('f', S(1)) + x_**WC('r', S(1))*WC('g', S(1)))/(a_ + x_**WC('n', S(1))*WC('c', S(1)))**(S(3)/2), x_), cons2, cons7, cons48, cons125, cons208, cons209, cons21, cons4, cons849, cons850, cons851, cons852) def replacement1517(m, f, g, r, c, n, a, x, h, q, e): rubi.append(1517) return -Simp((S(2)*a*g + S(4)*a*h*x**(n/S(4)) - S(2)*c*f*x**(n/S(2)))/(a*c*n*sqrt(a + c*x**n)), x) rule1517 = ReplacementRule(pattern1517, replacement1517) pattern1518 = Pattern(Integral((d_*x_)**WC('m', S(1))*(e_ + x_**WC('n', S(1))*WC('h', S(1)) + x_**WC('q', S(1))*WC('f', S(1)) + x_**WC('r', S(1))*WC('g', S(1)))/(a_ + x_**WC('n', S(1))*WC('c', S(1)))**(S(3)/2), x_), cons2, cons7, cons27, cons48, cons125, cons208, cons209, cons21, cons4, cons851, cons849, cons850, cons852) def replacement1518(m, f, g, r, d, c, n, a, x, h, q, e): rubi.append(1518) return Dist(x**(-m)*(d*x)**m, Int(x**m*(e + f*x**(n/S(4)) + g*x**(S(3)*n/S(4)) + h*x**n)/(a + c*x**n)**(S(3)/2), x), x) rule1518 = ReplacementRule(pattern1518, replacement1518) def With1519(p, m, b, Pq, c, a, x): n = Denominator(p) rubi.append(1519) return Dist(n/b, Subst(Int(x**(n*p + n + S(-1))*(-a*c/b + c*x**n/b)**m*ReplaceAll(Pq, Rule(x, -a/b + x**n/b)), x), x, (a + b*x)**(S(1)/n)), x) pattern1519 = Pattern(Integral(Pq_*(x_*WC('c', S(1)))**m_*(a_ + x_*WC('b', S(1)))**p_, x_), cons2, cons3, cons7, cons21, cons64, cons149, cons853) rule1519 = ReplacementRule(pattern1519, With1519) pattern1520 = Pattern(Integral(Pq_*x_**WC('m', S(1))*(a_ + x_**n_*WC('b', S(1)))**WC('p', S(1)), x_), cons2, cons3, cons21, cons4, cons5, cons66, cons854, cons855) def replacement1520(p, m, b, Pq, a, n, x): rubi.append(1520) return Dist(S(1)/(m + S(1)), Subst(Int((a + b*x**(n/(m + S(1))))**p*SubstFor(x**(m + S(1)), Pq, x), x), x, x**(m + S(1))), x) rule1520 = ReplacementRule(pattern1520, replacement1520) pattern1521 = Pattern(Integral(Pq_*(a_ + x_**WC('n', S(1))*WC('b', S(1)))**p_, x_), cons2, cons3, cons64, cons464, cons856) def replacement1521(p, b, Pq, a, n, x): rubi.append(1521) return Int((a + b*x**n)**p*ExpandToSum(Pq - x**(n + S(-1))*Coeff(Pq, x, n + S(-1)), x), x) + Simp((a + b*x**n)**(p + S(1))*Coeff(Pq, x, n + S(-1))/(b*n*(p + S(1))), x) rule1521 = ReplacementRule(pattern1521, replacement1521) pattern1522 = Pattern(Integral(Pq_*(x_*WC('c', S(1)))**WC('m', S(1))*(a_ + x_**WC('n', S(1))*WC('b', S(1)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons21, cons4, cons64, cons857) def replacement1522(p, m, b, Pq, c, n, a, x): rubi.append(1522) return Int(ExpandIntegrand(Pq*(c*x)**m*(a + b*x**n)**p, x), x) rule1522 = ReplacementRule(pattern1522, replacement1522) pattern1523 = Pattern(Integral(Pq_*(a_ + x_**WC('n', S(1))*WC('b', S(1)))**WC('p', S(1)), x_), cons2, cons3, cons4, cons64, cons857) def replacement1523(p, b, Pq, a, n, x): rubi.append(1523) return Int(ExpandIntegrand(Pq*(a + b*x**n)**p, x), x) rule1523 = ReplacementRule(pattern1523, replacement1523) pattern1524 = Pattern(Integral(Pq_*x_**WC('m', S(1))*(a_ + x_**n_*WC('b', S(1)))**WC('p', S(1)), x_), cons2, cons3, cons21, cons4, cons5, cons858, cons500) def replacement1524(p, m, b, Pq, a, n, x): rubi.append(1524) return Dist(S(1)/n, Subst(Int(x**(S(-1) + (m + S(1))/n)*(a + b*x)**p*SubstFor(x**n, Pq, x), x), x, x**n), x) rule1524 = ReplacementRule(pattern1524, replacement1524) pattern1525 = Pattern(Integral(Pq_*(c_*x_)**WC('m', S(1))*(a_ + x_**n_*WC('b', S(1)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons21, cons4, cons5, cons858, cons500) def replacement1525(p, m, b, Pq, c, a, n, x): rubi.append(1525) return Dist(c**IntPart(m)*x**(-FracPart(m))*(c*x)**FracPart(m), Int(Pq*x**m*(a + b*x**n)**p, x), x) rule1525 = ReplacementRule(pattern1525, replacement1525) pattern1526 = Pattern(Integral(Pq_*x_**WC('m', S(1))*(a_ + x_**n_*WC('b', S(1)))**p_, x_), cons2, cons3, cons21, cons4, cons64, cons53, cons13, cons137) def replacement1526(p, m, b, Pq, a, n, x): rubi.append(1526) return -Dist(S(1)/(b*n*(p + S(1))), Int((a + b*x**n)**(p + S(1))*D(Pq, x), x), x) + Simp(Pq*(a + b*x**n)**(p + S(1))/(b*n*(p + S(1))), x) rule1526 = ReplacementRule(pattern1526, replacement1526) pattern1527 = Pattern(Integral(Pq_*(x_*WC('d', S(1)))**WC('m', S(1))*(a_ + x_**WC('n', S(1))*WC('b', S(1)))**p_, x_), cons2, cons3, cons27, cons21, cons4, cons5, cons64, cons859) def replacement1527(p, m, b, Pq, d, a, n, x): rubi.append(1527) return Dist(S(1)/d, Int((d*x)**(m + S(1))*(a + b*x**n)**p*ExpandToSum(Pq/x, x), x), x) rule1527 = ReplacementRule(pattern1527, replacement1527) pattern1528 = Pattern(Integral(Pq_*(a_ + x_**WC('n', S(1))*WC('b', S(1)))**p_, x_), cons2, cons3, cons4, cons5, cons64, cons859, cons860) def replacement1528(p, b, Pq, a, n, x): rubi.append(1528) return Int(x*(a + b*x**n)**p*ExpandToSum(Pq/x, x), x) rule1528 = ReplacementRule(pattern1528, replacement1528) def With1529(p, m, b, Pq, a, n, x): u = IntHide(Pq*x**m, x) rubi.append(1529) return -Dist(b*n*p, Int(x**(m + n)*(a + b*x**n)**(p + S(-1))*ExpandToSum(u*x**(-m + S(-1)), x), x), x) + Simp(u*(a + b*x**n)**p, x) pattern1529 = Pattern(Integral(Pq_*x_**WC('m', S(1))*(a_ + x_**WC('n', S(1))*WC('b', S(1)))**p_, x_), cons2, cons3, cons64, cons148, cons244, cons163, cons861) rule1529 = ReplacementRule(pattern1529, With1529) def With1530(p, m, b, Pq, c, n, a, x): q = Expon(Pq, x) i = Symbol('i') rubi.append(1530) return Dist(a*n*p, Int((c*x)**m*(a + b*x**n)**(p + S(-1))*Sum_doit(x**i*Coeff(Pq, x, i)/(i + m + n*p + S(1)), List(i, S(0), q)), x), x) + Simp((c*x)**m*(a + b*x**n)**p*Sum_doit(x**(i + S(1))*Coeff(Pq, x, i)/(i + m + n*p + S(1)), List(i, S(0), q)), x) pattern1530 = Pattern(Integral(Pq_*(x_*WC('c', S(1)))**WC('m', S(1))*(a_ + x_**WC('n', S(1))*WC('b', S(1)))**p_, x_), cons2, cons3, cons7, cons21, cons64, cons521, cons13, cons163) rule1530 = ReplacementRule(pattern1530, With1530) def With1531(p, b, Pq, a, n, x): q = Expon(Pq, x) i = Symbol('i') rubi.append(1531) return Dist(a*n*p, Int((a + b*x**n)**(p + S(-1))*Sum_doit(x**i*Coeff(Pq, x, i)/(i + n*p + S(1)), List(i, S(0), q)), x), x) + Simp((a + b*x**n)**p*Sum_doit(x**(i + S(1))*Coeff(Pq, x, i)/(i + n*p + S(1)), List(i, S(0), q)), x) pattern1531 = Pattern(Integral(Pq_*(a_ + x_**WC('n', S(1))*WC('b', S(1)))**p_, x_), cons2, cons3, cons64, cons521, cons13, cons163) rule1531 = ReplacementRule(pattern1531, With1531) def With1532(p, b, Pq, a, n, x): if isinstance(x, (int, Integer, float, Float)): return False q = Expon(Pq, x) i = Symbol('i') if Equal(q, n + S(-1)): return True return False pattern1532 = Pattern(Integral(Pq_*(a_ + x_**n_*WC('b', S(1)))**p_, x_), cons2, cons3, cons64, cons148, cons13, cons137, CustomConstraint(With1532)) def replacement1532(p, b, Pq, a, n, x): q = Expon(Pq, x) i = Symbol('i') rubi.append(1532) return Dist(S(1)/(a*n*(p + S(1))), Int((a + b*x**n)**(p + S(1))*Sum_doit(x**i*(i + n*(p + S(1)) + S(1))*Coeff(Pq, x, i), List(i, S(0), q + S(-1))), x), x) + Simp((a + b*x**n)**(p + S(1))*(a*Coeff(Pq, x, q) - b*x*ExpandToSum(Pq - x**q*Coeff(Pq, x, q), x))/(a*b*n*(p + S(1))), x) rule1532 = ReplacementRule(pattern1532, replacement1532) pattern1533 = Pattern(Integral(Pq_*(a_ + x_**WC('n', S(1))*WC('b', S(1)))**p_, x_), cons2, cons3, cons64, cons148, cons13, cons137, cons862) def replacement1533(p, b, Pq, a, n, x): rubi.append(1533) return Dist(S(1)/(a*n*(p + S(1))), Int((a + b*x**n)**(p + S(1))*ExpandToSum(Pq*n*(p + S(1)) + D(Pq*x, x), x), x), x) - Simp(Pq*x*(a + b*x**n)**(p + S(1))/(a*n*(p + S(1))), x) rule1533 = ReplacementRule(pattern1533, replacement1533) pattern1534 = Pattern(Integral((d_ + x_**S(4)*WC('g', S(1)) + x_**S(3)*WC('f', S(1)) + x_*WC('e', S(1)))/(a_ + x_**S(4)*WC('b', S(1)))**(S(3)/2), x_), cons2, cons3, cons27, cons48, cons125, cons208, cons863) def replacement1534(f, b, g, d, a, x, e): rubi.append(1534) return -Simp((S(2)*a*f + S(4)*a*g*x - S(2)*b*e*x**S(2))/(S(4)*a*b*sqrt(a + b*x**S(4))), x) rule1534 = ReplacementRule(pattern1534, replacement1534) pattern1535 = Pattern(Integral((d_ + x_**S(4)*WC('g', S(1)) + x_**S(3)*WC('f', S(1)))/(a_ + x_**S(4)*WC('b', S(1)))**(S(3)/2), x_), cons2, cons3, cons27, cons125, cons208, cons863) def replacement1535(f, b, g, d, a, x): rubi.append(1535) return -Simp((f + S(2)*g*x)/(S(2)*b*sqrt(a + b*x**S(4))), x) rule1535 = ReplacementRule(pattern1535, replacement1535) pattern1536 = Pattern(Integral((d_ + x_**S(4)*WC('g', S(1)) + x_*WC('e', S(1)))/(a_ + x_**S(4)*WC('b', S(1)))**(S(3)/2), x_), cons2, cons3, cons27, cons48, cons208, cons863) def replacement1536(g, b, d, a, x, e): rubi.append(1536) return -Simp(x*(S(2)*a*g - b*e*x)/(S(2)*a*b*sqrt(a + b*x**S(4))), x) rule1536 = ReplacementRule(pattern1536, replacement1536) pattern1537 = Pattern(Integral(x_**S(2)*(x_**S(4)*WC('h', S(1)) + x_*WC('f', S(1)) + WC('e', S(0)))/(a_ + x_**S(4)*WC('b', S(1)))**(S(3)/2), x_), cons2, cons3, cons48, cons125, cons209, cons864) def replacement1537(f, b, a, x, h, e): rubi.append(1537) return -Simp((f - S(2)*h*x**S(3))/(S(2)*b*sqrt(a + b*x**S(4))), x) rule1537 = ReplacementRule(pattern1537, replacement1537) pattern1538 = Pattern(Integral(x_**S(2)*(x_**S(4)*WC('h', S(1)) + WC('e', S(0)))/(a_ + x_**S(4)*WC('b', S(1)))**(S(3)/2), x_), cons2, cons3, cons48, cons209, cons864) def replacement1538(b, a, x, h, e): rubi.append(1538) return Simp(h*x**S(3)/(b*sqrt(a + b*x**S(4))), x) rule1538 = ReplacementRule(pattern1538, replacement1538) pattern1539 = Pattern(Integral((d_ + x_**S(6)*WC('h', S(1)) + x_**S(4)*WC('g', S(1)) + x_**S(3)*WC('f', S(1)) + x_**S(2)*WC('e', S(1)))/(a_ + x_**S(4)*WC('b', S(1)))**(S(3)/2), x_), cons2, cons3, cons27, cons48, cons125, cons208, cons209, cons864, cons863) def replacement1539(f, b, g, d, a, x, h, e): rubi.append(1539) return -Simp((a*f - S(2)*a*h*x**S(3) - S(2)*b*d*x)/(S(2)*a*b*sqrt(a + b*x**S(4))), x) rule1539 = ReplacementRule(pattern1539, replacement1539) pattern1540 = Pattern(Integral((d_ + x_**S(6)*WC('h', S(1)) + x_**S(4)*WC('g', S(1)) + x_**S(2)*WC('e', S(1)))/(a_ + x_**S(4)*WC('b', S(1)))**(S(3)/2), x_), cons2, cons3, cons27, cons48, cons208, cons209, cons864, cons863) def replacement1540(g, b, d, a, x, h, e): rubi.append(1540) return Simp(x*(a*h*x**S(2) + b*d)/(a*b*sqrt(a + b*x**S(4))), x) rule1540 = ReplacementRule(pattern1540, replacement1540) def With1541(p, b, Pq, a, n, x): if isinstance(x, (int, Integer, float, Float)): return False q = Expon(Pq, x) Q = PolynomialQuotient(Pq*b**(Floor((q + S(-1))/n) + S(1)), a + b*x**n, x) R = PolynomialRemainder(Pq*b**(Floor((q + S(-1))/n) + S(1)), a + b*x**n, x) if GreaterEqual(q, n): return True return False pattern1541 = Pattern(Integral(Pq_*(a_ + x_**WC('n', S(1))*WC('b', S(1)))**p_, x_), cons2, cons3, cons64, cons148, cons13, cons137, CustomConstraint(With1541)) def replacement1541(p, b, Pq, a, n, x): q = Expon(Pq, x) Q = PolynomialQuotient(Pq*b**(Floor((q + S(-1))/n) + S(1)), a + b*x**n, x) R = PolynomialRemainder(Pq*b**(Floor((q + S(-1))/n) + S(1)), a + b*x**n, x) rubi.append(1541) return Dist(b**(-Floor((q - 1)/n) - 1)/(a*n*(p + 1)), Int((a + b*x**n)**(p + 1)*ExpandToSum(Q*a*n*(p + 1) + R*n*(p + 1) + D(R*x, x), x), x), x) - Simp(R*b**(-Floor((q - 1)/n) - 1)*x*(a + b*x**n)**(p + 1)/(a*n*(p + 1)), x) rule1541 = ReplacementRule(pattern1541, replacement1541) def With1542(p, m, b, Pq, a, n, x): q = Expon(Pq, x) Q = PolynomialQuotient(Pq*a*b**(Floor((q + S(-1))/n) + S(1))*x**m, a + b*x**n, x) R = PolynomialRemainder(Pq*a*b**(Floor((q + S(-1))/n) + S(1))*x**m, a + b*x**n, x) rubi.append(1542) return Dist(b**(-Floor((q - 1)/n) - 1)/(a*n*(p + 1)), Int(x**m*(a + b*x**n)**(p + 1)*ExpandToSum(Q*n*x**(-m)*(p + 1) + Sum_doit(x**(i - m)*(i + n*(p + 1) + 1)*Coeff(R, x, i)/a, List(i, 0, n - 1)), x), x), x) - Simp(R*b**(-Floor((q - 1)/n) - 1)*x*(a + b*x**n)**(p + 1)/(a**2*n*(p + 1)), x) pattern1542 = Pattern(Integral(Pq_*x_**m_*(a_ + x_**WC('n', S(1))*WC('b', S(1)))**p_, x_), cons2, cons3, cons64, cons148, cons13, cons137, cons84) rule1542 = ReplacementRule(pattern1542, With1542) def With1543(p, m, b, Pq, a, n, x): if isinstance(x, (int, Integer, float, Float)): return False g = GCD(m + S(1), n) if Unequal(g, S(1)): return True return False pattern1543 = Pattern(Integral(Pq_*x_**WC('m', S(1))*(a_ + x_**n_*WC('b', S(1)))**p_, x_), cons2, cons3, cons5, cons858, cons148, cons17, CustomConstraint(With1543)) def replacement1543(p, m, b, Pq, a, n, x): g = GCD(m + S(1), n) rubi.append(1543) return Dist(S(1)/g, Subst(Int(x**(S(-1) + (m + S(1))/g)*(a + b*x**(n/g))**p*ReplaceAll(Pq, Rule(x, x**(S(1)/g))), x), x, x**g), x) rule1543 = ReplacementRule(pattern1543, replacement1543) pattern1544 = Pattern(Integral((A_ + x_*WC('B', S(1)))/(a_ + x_**S(3)*WC('b', S(1))), x_), cons2, cons3, cons34, cons35, cons865) def replacement1544(B, b, a, x, A): rubi.append(1544) return Dist(B**S(3)/b, Int(S(1)/(A**S(2) - A*B*x + B**S(2)*x**S(2)), x), x) rule1544 = ReplacementRule(pattern1544, replacement1544) def With1545(B, b, a, x, A): r = Numerator(Rt(a/b, S(3))) s = Denominator(Rt(a/b, S(3))) rubi.append(1545) return Dist(r/(S(3)*a*s), Int((r*(S(2)*A*s + B*r) + s*x*(-A*s + B*r))/(r**S(2) - r*s*x + s**S(2)*x**S(2)), x), x) - Dist(r*(-A*s + B*r)/(S(3)*a*s), Int(S(1)/(r + s*x), x), x) pattern1545 = Pattern(Integral((A_ + x_*WC('B', S(1)))/(a_ + x_**S(3)*WC('b', S(1))), x_), cons2, cons3, cons34, cons35, cons866, cons468) rule1545 = ReplacementRule(pattern1545, With1545) def With1546(B, b, a, x, A): r = Numerator(Rt(-a/b, S(3))) s = Denominator(Rt(-a/b, S(3))) rubi.append(1546) return -Dist(r/(S(3)*a*s), Int((r*(-S(2)*A*s + B*r) - s*x*(A*s + B*r))/(r**S(2) + r*s*x + s**S(2)*x**S(2)), x), x) + Dist(r*(A*s + B*r)/(S(3)*a*s), Int(S(1)/(r - s*x), x), x) pattern1546 = Pattern(Integral((A_ + x_*WC('B', S(1)))/(a_ + x_**S(3)*WC('b', S(1))), x_), cons2, cons3, cons34, cons35, cons866, cons469) rule1546 = ReplacementRule(pattern1546, With1546) pattern1547 = Pattern(Integral((A_ + x_**S(2)*WC('C', S(1)) + x_*WC('B', S(1)))/(a_ + x_**S(3)*WC('b', S(1))), x_), cons2, cons3, cons34, cons35, cons36, cons867, cons868) def replacement1547(B, C, b, a, x, A): rubi.append(1547) return -Dist(C**S(2)/b, Int(S(1)/(B - C*x), x), x) rule1547 = ReplacementRule(pattern1547, replacement1547) def With1548(B, C, b, a, x, A): q = a**(S(1)/3)/b**(S(1)/3) rubi.append(1548) return Dist(C/b, Int(S(1)/(q + x), x), x) + Dist((B + C*q)/b, Int(S(1)/(q**S(2) - q*x + x**S(2)), x), x) pattern1548 = Pattern(Integral((x_**S(2)*WC('C', S(1)) + x_*WC('B', S(1)) + WC('A', S(0)))/(a_ + x_**S(3)*WC('b', S(1))), x_), cons2, cons3, cons34, cons35, cons36, cons869) rule1548 = ReplacementRule(pattern1548, With1548) def With1549(B, C, b, a, x): q = a**(S(1)/3)/b**(S(1)/3) rubi.append(1549) return Dist(C/b, Int(S(1)/(q + x), x), x) + Dist((B + C*q)/b, Int(S(1)/(q**S(2) - q*x + x**S(2)), x), x) pattern1549 = Pattern(Integral(x_*(B_ + x_*WC('C', S(1)))/(a_ + x_**S(3)*WC('b', S(1))), x_), cons2, cons3, cons35, cons36, cons870) rule1549 = ReplacementRule(pattern1549, With1549) def With1550(C, b, a, x, A): q = a**(S(1)/3)/b**(S(1)/3) rubi.append(1550) return Dist(C/b, Int(S(1)/(q + x), x), x) + Dist(C*q/b, Int(S(1)/(q**S(2) - q*x + x**S(2)), x), x) pattern1550 = Pattern(Integral((A_ + x_**S(2)*WC('C', S(1)))/(a_ + x_**S(3)*WC('b', S(1))), x_), cons2, cons3, cons34, cons36, cons871) rule1550 = ReplacementRule(pattern1550, With1550) def With1551(B, C, b, a, x, A): q = (-a)**(S(1)/3)/(-b)**(S(1)/3) rubi.append(1551) return Dist(C/b, Int(S(1)/(q + x), x), x) + Dist((B + C*q)/b, Int(S(1)/(q**S(2) - q*x + x**S(2)), x), x) pattern1551 = Pattern(Integral((x_**S(2)*WC('C', S(1)) + x_*WC('B', S(1)) + WC('A', S(0)))/(a_ + x_**S(3)*WC('b', S(1))), x_), cons2, cons3, cons34, cons35, cons36, cons872) rule1551 = ReplacementRule(pattern1551, With1551) def With1552(B, C, b, a, x): q = (-a)**(S(1)/3)/(-b)**(S(1)/3) rubi.append(1552) return Dist(C/b, Int(S(1)/(q + x), x), x) + Dist((B + C*q)/b, Int(S(1)/(q**S(2) - q*x + x**S(2)), x), x) pattern1552 = Pattern(Integral(x_*(B_ + x_*WC('C', S(1)))/(a_ + x_**S(3)*WC('b', S(1))), x_), cons2, cons3, cons35, cons36, cons873) rule1552 = ReplacementRule(pattern1552, With1552) def With1553(C, b, a, x, A): q = (-a)**(S(1)/3)/(-b)**(S(1)/3) rubi.append(1553) return Dist(C/b, Int(S(1)/(q + x), x), x) + Dist(C*q/b, Int(S(1)/(q**S(2) - q*x + x**S(2)), x), x) pattern1553 = Pattern(Integral((A_ + x_**S(2)*WC('C', S(1)))/(a_ + x_**S(3)*WC('b', S(1))), x_), cons2, cons3, cons34, cons36, cons874) rule1553 = ReplacementRule(pattern1553, With1553) def With1554(B, C, b, a, x, A): q = (-a)**(S(1)/3)/b**(S(1)/3) rubi.append(1554) return -Dist(C/b, Int(S(1)/(q - x), x), x) + Dist((B - C*q)/b, Int(S(1)/(q**S(2) + q*x + x**S(2)), x), x) pattern1554 = Pattern(Integral((x_**S(2)*WC('C', S(1)) + x_*WC('B', S(1)) + WC('A', S(0)))/(a_ + x_**S(3)*WC('b', S(1))), x_), cons2, cons3, cons34, cons35, cons36, cons875) rule1554 = ReplacementRule(pattern1554, With1554) def With1555(B, C, b, a, x): q = (-a)**(S(1)/3)/b**(S(1)/3) rubi.append(1555) return -Dist(C/b, Int(S(1)/(q - x), x), x) + Dist((B - C*q)/b, Int(S(1)/(q**S(2) + q*x + x**S(2)), x), x) pattern1555 = Pattern(Integral(x_*(B_ + x_*WC('C', S(1)))/(a_ + x_**S(3)*WC('b', S(1))), x_), cons2, cons3, cons35, cons36, cons876) rule1555 = ReplacementRule(pattern1555, With1555) def With1556(C, b, a, x, A): q = (-a)**(S(1)/3)/b**(S(1)/3) rubi.append(1556) return -Dist(C/b, Int(S(1)/(q - x), x), x) - Dist(C*q/b, Int(S(1)/(q**S(2) + q*x + x**S(2)), x), x) pattern1556 = Pattern(Integral((A_ + x_**S(2)*WC('C', S(1)))/(a_ + x_**S(3)*WC('b', S(1))), x_), cons2, cons3, cons34, cons36, cons877) rule1556 = ReplacementRule(pattern1556, With1556) def With1557(B, C, b, a, x, A): q = a**(S(1)/3)/(-b)**(S(1)/3) rubi.append(1557) return -Dist(C/b, Int(S(1)/(q - x), x), x) + Dist((B - C*q)/b, Int(S(1)/(q**S(2) + q*x + x**S(2)), x), x) pattern1557 = Pattern(Integral((x_**S(2)*WC('C', S(1)) + x_*WC('B', S(1)) + WC('A', S(0)))/(a_ + x_**S(3)*WC('b', S(1))), x_), cons2, cons3, cons34, cons35, cons36, cons878) rule1557 = ReplacementRule(pattern1557, With1557) def With1558(B, C, b, a, x): q = a**(S(1)/3)/(-b)**(S(1)/3) rubi.append(1558) return -Dist(C/b, Int(S(1)/(q - x), x), x) + Dist((B - C*q)/b, Int(S(1)/(q**S(2) + q*x + x**S(2)), x), x) pattern1558 = Pattern(Integral(x_*(B_ + x_*WC('C', S(1)))/(a_ + x_**S(3)*WC('b', S(1))), x_), cons2, cons3, cons35, cons36, cons879) rule1558 = ReplacementRule(pattern1558, With1558) def With1559(C, b, a, x, A): q = a**(S(1)/3)/(-b)**(S(1)/3) rubi.append(1559) return -Dist(C/b, Int(S(1)/(q - x), x), x) - Dist(C*q/b, Int(S(1)/(q**S(2) + q*x + x**S(2)), x), x) pattern1559 = Pattern(Integral((A_ + x_**S(2)*WC('C', S(1)))/(a_ + x_**S(3)*WC('b', S(1))), x_), cons2, cons3, cons34, cons36, cons880) rule1559 = ReplacementRule(pattern1559, With1559) def With1560(B, C, b, a, x, A): q = (a/b)**(S(1)/3) rubi.append(1560) return Dist(C/b, Int(S(1)/(q + x), x), x) + Dist((B + C*q)/b, Int(S(1)/(q**S(2) - q*x + x**S(2)), x), x) pattern1560 = Pattern(Integral((x_**S(2)*WC('C', S(1)) + x_*WC('B', S(1)) + WC('A', S(0)))/(a_ + x_**S(3)*WC('b', S(1))), x_), cons2, cons3, cons34, cons35, cons36, cons881) rule1560 = ReplacementRule(pattern1560, With1560) def With1561(B, C, b, a, x): q = (a/b)**(S(1)/3) rubi.append(1561) return Dist(C/b, Int(S(1)/(q + x), x), x) + Dist((B + C*q)/b, Int(S(1)/(q**S(2) - q*x + x**S(2)), x), x) pattern1561 = Pattern(Integral(x_*(B_ + x_*WC('C', S(1)))/(a_ + x_**S(3)*WC('b', S(1))), x_), cons2, cons3, cons35, cons36, cons882) rule1561 = ReplacementRule(pattern1561, With1561) def With1562(C, b, a, x, A): q = (a/b)**(S(1)/3) rubi.append(1562) return Dist(C/b, Int(S(1)/(q + x), x), x) + Dist(C*q/b, Int(S(1)/(q**S(2) - q*x + x**S(2)), x), x) pattern1562 = Pattern(Integral((A_ + x_**S(2)*WC('C', S(1)))/(a_ + x_**S(3)*WC('b', S(1))), x_), cons2, cons3, cons34, cons36, cons883) rule1562 = ReplacementRule(pattern1562, With1562) def With1563(B, C, b, a, x, A): q = Rt(a/b, S(3)) rubi.append(1563) return Dist(C/b, Int(S(1)/(q + x), x), x) + Dist((B + C*q)/b, Int(S(1)/(q**S(2) - q*x + x**S(2)), x), x) pattern1563 = Pattern(Integral((x_**S(2)*WC('C', S(1)) + x_*WC('B', S(1)) + WC('A', S(0)))/(a_ + x_**S(3)*WC('b', S(1))), x_), cons2, cons3, cons34, cons35, cons36, cons884) rule1563 = ReplacementRule(pattern1563, With1563) def With1564(B, C, b, a, x): q = Rt(a/b, S(3)) rubi.append(1564) return Dist(C/b, Int(S(1)/(q + x), x), x) + Dist((B + C*q)/b, Int(S(1)/(q**S(2) - q*x + x**S(2)), x), x) pattern1564 = Pattern(Integral(x_*(B_ + x_*WC('C', S(1)))/(a_ + x_**S(3)*WC('b', S(1))), x_), cons2, cons3, cons35, cons36, cons885) rule1564 = ReplacementRule(pattern1564, With1564) def With1565(C, b, a, x, A): q = Rt(a/b, S(3)) rubi.append(1565) return Dist(C/b, Int(S(1)/(q + x), x), x) + Dist(C*q/b, Int(S(1)/(q**S(2) - q*x + x**S(2)), x), x) pattern1565 = Pattern(Integral((x_**S(2)*WC('C', S(1)) + WC('A', S(0)))/(a_ + x_**S(3)*WC('b', S(1))), x_), cons2, cons3, cons34, cons36, cons886) rule1565 = ReplacementRule(pattern1565, With1565) def With1566(B, C, b, a, x, A): q = (-a/b)**(S(1)/3) rubi.append(1566) return -Dist(C/b, Int(S(1)/(q - x), x), x) + Dist((B - C*q)/b, Int(S(1)/(q**S(2) + q*x + x**S(2)), x), x) pattern1566 = Pattern(Integral((x_**S(2)*WC('C', S(1)) + x_*WC('B', S(1)) + WC('A', S(0)))/(a_ + x_**S(3)*WC('b', S(1))), x_), cons2, cons3, cons34, cons35, cons36, cons887) rule1566 = ReplacementRule(pattern1566, With1566) def With1567(B, C, b, a, x): q = (-a/b)**(S(1)/3) rubi.append(1567) return -Dist(C/b, Int(S(1)/(q - x), x), x) + Dist((B - C*q)/b, Int(S(1)/(q**S(2) + q*x + x**S(2)), x), x) pattern1567 = Pattern(Integral(x_*(B_ + x_*WC('C', S(1)))/(a_ + x_**S(3)*WC('b', S(1))), x_), cons2, cons3, cons35, cons36, cons888) rule1567 = ReplacementRule(pattern1567, With1567) def With1568(C, b, a, x, A): q = (-a/b)**(S(1)/3) rubi.append(1568) return -Dist(C/b, Int(S(1)/(q - x), x), x) - Dist(C*q/b, Int(S(1)/(q**S(2) + q*x + x**S(2)), x), x) pattern1568 = Pattern(Integral((A_ + x_**S(2)*WC('C', S(1)))/(a_ + x_**S(3)*WC('b', S(1))), x_), cons2, cons3, cons34, cons36, cons889) rule1568 = ReplacementRule(pattern1568, With1568) def With1569(B, C, b, a, x, A): q = Rt(-a/b, S(3)) rubi.append(1569) return -Dist(C/b, Int(S(1)/(q - x), x), x) + Dist((B - C*q)/b, Int(S(1)/(q**S(2) + q*x + x**S(2)), x), x) pattern1569 = Pattern(Integral((x_**S(2)*WC('C', S(1)) + x_*WC('B', S(1)) + WC('A', S(0)))/(a_ + x_**S(3)*WC('b', S(1))), x_), cons2, cons3, cons34, cons35, cons36, cons890) rule1569 = ReplacementRule(pattern1569, With1569) def With1570(B, C, b, a, x): q = Rt(-a/b, S(3)) rubi.append(1570) return -Dist(C/b, Int(S(1)/(q - x), x), x) + Dist((B - C*q)/b, Int(S(1)/(q**S(2) + q*x + x**S(2)), x), x) pattern1570 = Pattern(Integral(x_*(B_ + x_*WC('C', S(1)))/(a_ + x_**S(3)*WC('b', S(1))), x_), cons2, cons3, cons35, cons36, cons891) rule1570 = ReplacementRule(pattern1570, With1570) def With1571(C, b, a, x, A): q = Rt(-a/b, S(3)) rubi.append(1571) return -Dist(C/b, Int(S(1)/(q - x), x), x) - Dist(C*q/b, Int(S(1)/(q**S(2) + q*x + x**S(2)), x), x) pattern1571 = Pattern(Integral((x_**S(2)*WC('C', S(1)) + WC('A', S(0)))/(a_ + x_**S(3)*WC('b', S(1))), x_), cons2, cons3, cons34, cons36, cons892) rule1571 = ReplacementRule(pattern1571, With1571) pattern1572 = Pattern(Integral((x_**S(2)*WC('C', S(1)) + x_*WC('B', S(1)) + WC('A', S(0)))/(a_ + x_**S(3)*WC('b', S(1))), x_), cons2, cons3, cons34, cons35, cons36, cons893) def replacement1572(B, C, b, a, x, A): rubi.append(1572) return Dist(C, Int(x**S(2)/(a + b*x**S(3)), x), x) + Int((A + B*x)/(a + b*x**S(3)), x) rule1572 = ReplacementRule(pattern1572, replacement1572) pattern1573 = Pattern(Integral(x_*(B_ + x_*WC('C', S(1)))/(a_ + x_**S(3)*WC('b', S(1))), x_), cons2, cons3, cons35, cons36, cons894) def replacement1573(B, C, b, a, x): rubi.append(1573) return Dist(B, Int(x/(a + b*x**S(3)), x), x) + Dist(C, Int(x**S(2)/(a + b*x**S(3)), x), x) rule1573 = ReplacementRule(pattern1573, replacement1573) pattern1574 = Pattern(Integral((A_ + x_**S(2)*WC('C', S(1)))/(a_ + x_**S(3)*WC('b', S(1))), x_), cons2, cons3, cons34, cons36, cons895) def replacement1574(C, b, a, x, A): rubi.append(1574) return Dist(A, Int(S(1)/(a + b*x**S(3)), x), x) + Dist(C, Int(x**S(2)/(a + b*x**S(3)), x), x) rule1574 = ReplacementRule(pattern1574, replacement1574) def With1575(B, C, b, a, x, A): q = (a/b)**(S(1)/3) rubi.append(1575) return Dist(q**S(2)/a, Int((A + C*q*x)/(q**S(2) - q*x + x**S(2)), x), x) pattern1575 = Pattern(Integral((x_**S(2)*WC('C', S(1)) + x_*WC('B', S(1)) + WC('A', S(0)))/(a_ + x_**S(3)*WC('b', S(1))), x_), cons2, cons3, cons34, cons35, cons36, cons896) rule1575 = ReplacementRule(pattern1575, With1575) def With1576(B, C, b, a, x): q = (a/b)**(S(1)/3) rubi.append(1576) return Dist(C*q**S(3)/a, Int(x/(q**S(2) - q*x + x**S(2)), x), x) pattern1576 = Pattern(Integral(x_*(x_*WC('C', S(1)) + WC('B', S(0)))/(a_ + x_**S(3)*WC('b', S(1))), x_), cons2, cons3, cons35, cons36, cons897) rule1576 = ReplacementRule(pattern1576, With1576) def With1577(C, b, a, x, A): q = (a/b)**(S(1)/3) rubi.append(1577) return Dist(q**S(2)/a, Int((A + C*q*x)/(q**S(2) - q*x + x**S(2)), x), x) pattern1577 = Pattern(Integral((A_ + x_**S(2)*WC('C', S(1)))/(a_ + x_**S(3)*WC('b', S(1))), x_), cons2, cons3, cons34, cons36, cons898) rule1577 = ReplacementRule(pattern1577, With1577) def With1578(B, C, b, a, x, A): q = (-a/b)**(S(1)/3) rubi.append(1578) return Dist(q/a, Int((A*q + x*(A + B*q))/(q**S(2) + q*x + x**S(2)), x), x) pattern1578 = Pattern(Integral((x_**S(2)*WC('C', S(1)) + x_*WC('B', S(1)) + WC('A', S(0)))/(a_ + x_**S(3)*WC('b', S(1))), x_), cons2, cons3, cons34, cons35, cons36, cons899) rule1578 = ReplacementRule(pattern1578, With1578) def With1579(B, C, b, a, x): q = (-a/b)**(S(1)/3) rubi.append(1579) return Dist(B*q**S(2)/a, Int(x/(q**S(2) + q*x + x**S(2)), x), x) pattern1579 = Pattern(Integral(x_*(B_ + x_*WC('C', S(1)))/(a_ + x_**S(3)*WC('b', S(1))), x_), cons2, cons3, cons35, cons36, cons900) rule1579 = ReplacementRule(pattern1579, With1579) def With1580(C, b, a, x, A): q = (-a/b)**(S(1)/3) rubi.append(1580) return Dist(A*q/a, Int((q + x)/(q**S(2) + q*x + x**S(2)), x), x) pattern1580 = Pattern(Integral((A_ + x_**S(2)*WC('C', S(1)))/(a_ + x_**S(3)*WC('b', S(1))), x_), cons2, cons3, cons34, cons36, cons901) rule1580 = ReplacementRule(pattern1580, With1580) def With1581(B, C, b, a, x, A): if isinstance(x, (int, Integer, float, Float)): return False q = (a/b)**(S(1)/3) if NonzeroQ(A - B*q + C*q**S(2)): return True return False pattern1581 = Pattern(Integral((x_**S(2)*WC('C', S(1)) + x_*WC('B', S(1)) + WC('A', S(0)))/(a_ + x_**S(3)*WC('b', S(1))), x_), cons2, cons3, cons34, cons35, cons36, cons866, cons902, cons903, CustomConstraint(With1581)) def replacement1581(B, C, b, a, x, A): q = (a/b)**(S(1)/3) rubi.append(1581) return Dist(q/(S(3)*a), Int((q*(S(2)*A + B*q - C*q**S(2)) - x*(A - B*q - S(2)*C*q**S(2)))/(q**S(2) - q*x + x**S(2)), x), x) + Dist(q*(A - B*q + C*q**S(2))/(S(3)*a), Int(S(1)/(q + x), x), x) rule1581 = ReplacementRule(pattern1581, replacement1581) def With1582(B, C, b, a, x): if isinstance(x, (int, Integer, float, Float)): return False q = (a/b)**(S(1)/3) if NonzeroQ(B*q - C*q**S(2)): return True return False pattern1582 = Pattern(Integral(x_*(B_ + x_*WC('C', S(1)))/(a_ + x_**S(3)*WC('b', S(1))), x_), cons2, cons3, cons35, cons36, cons902, cons903, CustomConstraint(With1582)) def replacement1582(B, C, b, a, x): q = (a/b)**(S(1)/3) rubi.append(1582) return Dist(q/(S(3)*a), Int((q*(B*q - C*q**S(2)) + x*(B*q + S(2)*C*q**S(2)))/(q**S(2) - q*x + x**S(2)), x), x) - Dist(q*(B*q - C*q**S(2))/(S(3)*a), Int(S(1)/(q + x), x), x) rule1582 = ReplacementRule(pattern1582, replacement1582) def With1583(C, b, a, x, A): if isinstance(x, (int, Integer, float, Float)): return False q = (a/b)**(S(1)/3) if NonzeroQ(A + C*q**S(2)): return True return False pattern1583 = Pattern(Integral((A_ + x_**S(2)*WC('C', S(1)))/(a_ + x_**S(3)*WC('b', S(1))), x_), cons2, cons3, cons34, cons36, cons902, cons903, CustomConstraint(With1583)) def replacement1583(C, b, a, x, A): q = (a/b)**(S(1)/3) rubi.append(1583) return Dist(q/(S(3)*a), Int((q*(S(2)*A - C*q**S(2)) - x*(A - S(2)*C*q**S(2)))/(q**S(2) - q*x + x**S(2)), x), x) + Dist(q*(A + C*q**S(2))/(S(3)*a), Int(S(1)/(q + x), x), x) rule1583 = ReplacementRule(pattern1583, replacement1583) def With1584(B, C, b, a, x, A): if isinstance(x, (int, Integer, float, Float)): return False q = (-a/b)**(S(1)/3) if NonzeroQ(A + B*q + C*q**S(2)): return True return False pattern1584 = Pattern(Integral((x_**S(2)*WC('C', S(1)) + x_*WC('B', S(1)) + WC('A', S(0)))/(a_ + x_**S(3)*WC('b', S(1))), x_), cons2, cons3, cons34, cons35, cons36, cons866, cons902, cons904, CustomConstraint(With1584)) def replacement1584(B, C, b, a, x, A): q = (-a/b)**(S(1)/3) rubi.append(1584) return Dist(q/(S(3)*a), Int((q*(S(2)*A - B*q - C*q**S(2)) + x*(A + B*q - S(2)*C*q**S(2)))/(q**S(2) + q*x + x**S(2)), x), x) + Dist(q*(A + B*q + C*q**S(2))/(S(3)*a), Int(S(1)/(q - x), x), x) rule1584 = ReplacementRule(pattern1584, replacement1584) def With1585(B, C, b, a, x): if isinstance(x, (int, Integer, float, Float)): return False q = (-a/b)**(S(1)/3) if NonzeroQ(B*q + C*q**S(2)): return True return False pattern1585 = Pattern(Integral(x_*(B_ + x_*WC('C', S(1)))/(a_ + x_**S(3)*WC('b', S(1))), x_), cons2, cons3, cons35, cons36, cons902, cons904, CustomConstraint(With1585)) def replacement1585(B, C, b, a, x): q = (-a/b)**(S(1)/3) rubi.append(1585) return Dist(q/(S(3)*a), Int((-q*(B*q + C*q**S(2)) + x*(B*q - S(2)*C*q**S(2)))/(q**S(2) + q*x + x**S(2)), x), x) + Dist(q*(B*q + C*q**S(2))/(S(3)*a), Int(S(1)/(q - x), x), x) rule1585 = ReplacementRule(pattern1585, replacement1585) def With1586(C, b, a, x, A): if isinstance(x, (int, Integer, float, Float)): return False q = (-a/b)**(S(1)/3) if NonzeroQ(A + C*q**S(2)): return True return False pattern1586 = Pattern(Integral((A_ + x_**S(2)*WC('C', S(1)))/(a_ + x_**S(3)*WC('b', S(1))), x_), cons2, cons3, cons34, cons36, cons902, cons904, CustomConstraint(With1586)) def replacement1586(C, b, a, x, A): q = (-a/b)**(S(1)/3) rubi.append(1586) return Dist(q/(S(3)*a), Int((q*(S(2)*A - C*q**S(2)) + x*(A - S(2)*C*q**S(2)))/(q**S(2) + q*x + x**S(2)), x), x) + Dist(q*(A + C*q**S(2))/(S(3)*a), Int(S(1)/(q - x), x), x) rule1586 = ReplacementRule(pattern1586, replacement1586) def With1587(m, b, Pq, c, a, n, x): if isinstance(x, (int, Integer, float, Float)): return False v = Sum_doit(c**(-ii)*(c*x)**(ii + m)*(x**(n/S(2))*Coeff(Pq, x, ii + n/S(2)) + Coeff(Pq, x, ii))/(a + b*x**n), List(ii, S(0), n/S(2) + S(-1))) if SumQ(v): return True return False pattern1587 = Pattern(Integral(Pq_*(x_*WC('c', S(1)))**WC('m', S(1))/(a_ + x_**n_*WC('b', S(1))), x_), cons2, cons3, cons7, cons21, cons64, cons674, cons905, CustomConstraint(With1587)) def replacement1587(m, b, Pq, c, a, n, x): v = Sum_doit(c**(-ii)*(c*x)**(ii + m)*(x**(n/S(2))*Coeff(Pq, x, ii + n/S(2)) + Coeff(Pq, x, ii))/(a + b*x**n), List(ii, S(0), n/S(2) + S(-1))) rubi.append(1587) return Int(v, x) rule1587 = ReplacementRule(pattern1587, replacement1587) def With1588(b, Pq, a, n, x): if isinstance(x, (int, Integer, float, Float)): return False v = Sum_doit(x**ii*(x**(n/S(2))*Coeff(Pq, x, ii + n/S(2)) + Coeff(Pq, x, ii))/(a + b*x**n), List(ii, S(0), n/S(2) + S(-1))) if SumQ(v): return True return False pattern1588 = Pattern(Integral(Pq_/(a_ + x_**n_*WC('b', S(1))), x_), cons2, cons3, cons64, cons674, cons905, CustomConstraint(With1588)) def replacement1588(b, Pq, a, n, x): v = Sum_doit(x**ii*(x**(n/S(2))*Coeff(Pq, x, ii + n/S(2)) + Coeff(Pq, x, ii))/(a + b*x**n), List(ii, S(0), n/S(2) + S(-1))) rubi.append(1588) return Int(v, x) rule1588 = ReplacementRule(pattern1588, replacement1588) def With1589(b, d, c, a, x): r = Numer(Rt(b/a, S(3))) s = Denom(Rt(b/a, S(3))) rubi.append(1589) return Simp(S(2)*d*s**S(3)*sqrt(a + b*x**S(3))/(a*r**S(2)*(r*x + s*(S(1) + sqrt(S(3))))), x) - Simp(S(3)**(S(1)/4)*d*s*sqrt((r**S(2)*x**S(2) - r*s*x + s**S(2))/(r*x + s*(S(1) + sqrt(S(3))))**S(2))*sqrt(-sqrt(S(3)) + S(2))*(r*x + s)*EllipticE(asin((r*x + s*(-sqrt(S(3)) + S(1)))/(r*x + s*(S(1) + sqrt(S(3))))), S(-7) - S(4)*sqrt(S(3)))/(r**S(2)*sqrt(s*(r*x + s)/(r*x + s*(S(1) + sqrt(S(3))))**S(2))*sqrt(a + b*x**S(3))), x) pattern1589 = Pattern(Integral((c_ + x_*WC('d', S(1)))/sqrt(a_ + x_**S(3)*WC('b', S(1))), x_), cons2, cons3, cons7, cons27, cons481, cons906) rule1589 = ReplacementRule(pattern1589, With1589) def With1590(b, d, c, a, x): r = Numer(Rt(b/a, S(3))) s = Denom(Rt(b/a, S(3))) rubi.append(1590) return Dist(d/r, Int((r*x + s*(-sqrt(S(3)) + S(1)))/sqrt(a + b*x**S(3)), x), x) + Dist((c*r - d*s*(-sqrt(S(3)) + S(1)))/r, Int(S(1)/sqrt(a + b*x**S(3)), x), x) pattern1590 = Pattern(Integral((c_ + x_*WC('d', S(1)))/sqrt(a_ + x_**S(3)*WC('b', S(1))), x_), cons2, cons3, cons7, cons27, cons481, cons907) rule1590 = ReplacementRule(pattern1590, With1590) def With1591(b, d, c, a, x): r = Numer(Rt(b/a, S(3))) s = Denom(Rt(b/a, S(3))) rubi.append(1591) return Simp(S(2)*d*s**S(3)*sqrt(a + b*x**S(3))/(a*r**S(2)*(r*x + s*(-sqrt(S(3)) + S(1)))), x) + Simp(S(3)**(S(1)/4)*d*s*sqrt((r**S(2)*x**S(2) - r*s*x + s**S(2))/(r*x + s*(-sqrt(S(3)) + S(1)))**S(2))*sqrt(sqrt(S(3)) + S(2))*(r*x + s)*EllipticE(asin((r*x + s*(S(1) + sqrt(S(3))))/(r*x + s*(-sqrt(S(3)) + S(1)))), S(-7) + S(4)*sqrt(S(3)))/(r**S(2)*sqrt(-s*(r*x + s)/(r*x + s*(-sqrt(S(3)) + S(1)))**S(2))*sqrt(a + b*x**S(3))), x) pattern1591 = Pattern(Integral((c_ + x_*WC('d', S(1)))/sqrt(a_ + x_**S(3)*WC('b', S(1))), x_), cons2, cons3, cons7, cons27, cons482, cons908) rule1591 = ReplacementRule(pattern1591, With1591) def With1592(b, d, c, a, x): r = Numer(Rt(b/a, S(3))) s = Denom(Rt(b/a, S(3))) rubi.append(1592) return Dist(d/r, Int((r*x + s*(S(1) + sqrt(S(3))))/sqrt(a + b*x**S(3)), x), x) + Dist((c*r - d*s*(S(1) + sqrt(S(3))))/r, Int(S(1)/sqrt(a + b*x**S(3)), x), x) pattern1592 = Pattern(Integral((c_ + x_*WC('d', S(1)))/sqrt(a_ + x_**S(3)*WC('b', S(1))), x_), cons2, cons3, cons7, cons27, cons482, cons909) rule1592 = ReplacementRule(pattern1592, With1592) def With1593(b, d, c, a, x): r = Numer(Rt(b/a, S(3))) s = Denom(Rt(b/a, S(3))) rubi.append(1593) return Simp(d*s**S(3)*x*(S(1) + sqrt(S(3)))*sqrt(a + b*x**S(6))/(S(2)*a*r**S(2)*(r*x**S(2)*(S(1) + sqrt(S(3))) + s)), x) - Simp(S(3)**(S(1)/4)*d*s*x*sqrt((r**S(2)*x**S(4) - r*s*x**S(2) + s**S(2))/(r*x**S(2)*(S(1) + sqrt(S(3))) + s)**S(2))*(r*x**S(2) + s)*EllipticE(acos((r*x**S(2)*(-sqrt(S(3)) + S(1)) + s)/(r*x**S(2)*(S(1) + sqrt(S(3))) + s)), sqrt(S(3))/S(4) + S(1)/2)/(S(2)*r**S(2)*sqrt(r*x**S(2)*(r*x**S(2) + s)/(r*x**S(2)*(S(1) + sqrt(S(3))) + s)**S(2))*sqrt(a + b*x**S(6))), x) pattern1593 = Pattern(Integral((c_ + x_**S(4)*WC('d', S(1)))/sqrt(a_ + x_**S(6)*WC('b', S(1))), x_), cons2, cons3, cons7, cons27, cons910) rule1593 = ReplacementRule(pattern1593, With1593) def With1594(b, d, c, a, x): q = Rt(b/a, S(3)) rubi.append(1594) return Dist(d/(S(2)*q**S(2)), Int((S(2)*q**S(2)*x**S(4) - sqrt(S(3)) + S(1))/sqrt(a + b*x**S(6)), x), x) + Dist((S(2)*c*q**S(2) - d*(-sqrt(S(3)) + S(1)))/(S(2)*q**S(2)), Int(S(1)/sqrt(a + b*x**S(6)), x), x) pattern1594 = Pattern(Integral((c_ + x_**S(4)*WC('d', S(1)))/sqrt(a_ + x_**S(6)*WC('b', S(1))), x_), cons2, cons3, cons7, cons27, cons911) rule1594 = ReplacementRule(pattern1594, With1594) pattern1595 = Pattern(Integral((c_ + x_**S(2)*WC('d', S(1)))/sqrt(a_ + x_**S(8)*WC('b', S(1))), x_), cons2, cons3, cons7, cons27, cons912) def replacement1595(b, d, c, a, x): rubi.append(1595) return -Simp(c*d*x**S(3)*sqrt(-(c - d*x**S(2))**S(2)/(c*d*x**S(2)))*sqrt(-d**S(2)*(a + b*x**S(8))/(b*c**S(2)*x**S(4)))*EllipticF(asin(sqrt((sqrt(S(2))*c**S(2) + S(2)*c*d*x**S(2) + sqrt(S(2))*d**S(2)*x**S(4))/(c*d*x**S(2)))/S(2)), S(-2) + S(2)*sqrt(S(2)))/(sqrt(sqrt(S(2)) + S(2))*sqrt(a + b*x**S(8))*(c - d*x**S(2))), x) rule1595 = ReplacementRule(pattern1595, replacement1595) pattern1596 = Pattern(Integral((c_ + x_**S(2)*WC('d', S(1)))/sqrt(a_ + x_**S(8)*WC('b', S(1))), x_), cons2, cons3, cons7, cons27, cons913) def replacement1596(b, d, c, a, x): rubi.append(1596) return -Dist((-c*Rt(b/a, S(4)) + d)/(S(2)*Rt(b/a, S(4))), Int((-x**S(2)*Rt(b/a, S(4)) + S(1))/sqrt(a + b*x**S(8)), x), x) + Dist((c*Rt(b/a, S(4)) + d)/(S(2)*Rt(b/a, S(4))), Int((x**S(2)*Rt(b/a, S(4)) + S(1))/sqrt(a + b*x**S(8)), x), x) rule1596 = ReplacementRule(pattern1596, replacement1596) pattern1597 = Pattern(Integral(Pq_/(x_*sqrt(a_ + x_**n_*WC('b', S(1)))), x_), cons2, cons3, cons64, cons148, cons914) def replacement1597(b, Pq, a, n, x): rubi.append(1597) return Dist(Coeff(Pq, x, S(0)), Int(S(1)/(x*sqrt(a + b*x**n)), x), x) + Int(ExpandToSum((Pq - Coeff(Pq, x, S(0)))/x, x)/sqrt(a + b*x**n), x) rule1597 = ReplacementRule(pattern1597, replacement1597) def With1598(p, m, b, Pq, c, a, n, x): q = Expon(Pq, x) j = Symbol('j') k = Symbol('k') rubi.append(1598) return Int(Sum_doit(c**(-j)*(c*x)**(j + m)*(a + b*x**n)**p*Sum_doit(x**(k*n/S(2))*Coeff(Pq, x, j + k*n/S(2)), List(k, S(0), S(1) + S(2)*(-j + q)/n)), List(j, S(0), n/S(2) + S(-1))), x) pattern1598 = Pattern(Integral(Pq_*(x_*WC('c', S(1)))**WC('m', S(1))*(a_ + x_**n_*WC('b', S(1)))**p_, x_), cons2, cons3, cons7, cons21, cons5, cons64, cons674, cons915) rule1598 = ReplacementRule(pattern1598, With1598) def With1599(p, b, Pq, a, n, x): q = Expon(Pq, x) j = Symbol('j') k = Symbol('k') rubi.append(1599) return Int(Sum_doit(x**j*(a + b*x**n)**p*Sum_doit(x**(k*n/S(2))*Coeff(Pq, x, j + k*n/S(2)), List(k, S(0), S(1) + S(2)*(-j + q)/n)), List(j, S(0), n/S(2) + S(-1))), x) pattern1599 = Pattern(Integral(Pq_*(a_ + x_**n_*WC('b', S(1)))**p_, x_), cons2, cons3, cons5, cons64, cons674, cons915) rule1599 = ReplacementRule(pattern1599, With1599) pattern1600 = Pattern(Integral(Pq_*(a_ + x_**n_*WC('b', S(1)))**p_, x_), cons2, cons3, cons5, cons64, cons148, cons916) def replacement1600(p, b, Pq, a, n, x): rubi.append(1600) return Dist(Coeff(Pq, x, n + S(-1)), Int(x**(n + S(-1))*(a + b*x**n)**p, x), x) + Int((a + b*x**n)**p*ExpandToSum(Pq - x**(n + S(-1))*Coeff(Pq, x, n + S(-1)), x), x) rule1600 = ReplacementRule(pattern1600, replacement1600) pattern1601 = Pattern(Integral(Pq_*(x_*WC('c', S(1)))**WC('m', S(1))/(a_ + x_**n_*WC('b', S(1))), x_), cons2, cons3, cons7, cons21, cons64, cons85) def replacement1601(m, b, Pq, c, a, n, x): rubi.append(1601) return Int(ExpandIntegrand(Pq*(c*x)**m/(a + b*x**n), x), x) rule1601 = ReplacementRule(pattern1601, replacement1601) pattern1602 = Pattern(Integral(Pq_/(a_ + x_**n_*WC('b', S(1))), x_), cons2, cons3, cons64, cons85) def replacement1602(b, Pq, a, n, x): rubi.append(1602) return Int(ExpandIntegrand(Pq/(a + b*x**n), x), x) rule1602 = ReplacementRule(pattern1602, replacement1602) def With1603(p, m, b, Pq, c, a, n, x): if isinstance(x, (int, Integer, float, Float)): return False Pq0 = Coeff(Pq, x, S(0)) if NonzeroQ(Pq0): return True return False pattern1603 = Pattern(Integral(Pq_*(x_*WC('c', S(1)))**m_*(a_ + x_**n_*WC('b', S(1)))**p_, x_), cons2, cons3, cons7, cons5, cons64, cons148, cons31, cons94, cons917, CustomConstraint(With1603)) def replacement1603(p, m, b, Pq, c, a, n, x): Pq0 = Coeff(Pq, x, S(0)) rubi.append(1603) return Dist(S(1)/(S(2)*a*c*(m + S(1))), Int((c*x)**(m + S(1))*(a + b*x**n)**p*ExpandToSum(-S(2)*Pq0*b*x**(n + S(-1))*(m + n*(p + S(1)) + S(1)) + S(2)*a*(Pq - Pq0)*(m + S(1))/x, x), x), x) + Simp(Pq0*(c*x)**(m + S(1))*(a + b*x**n)**(p + S(1))/(a*c*(m + S(1))), x) rule1603 = ReplacementRule(pattern1603, replacement1603) def With1604(p, m, b, Pq, c, a, n, x): if isinstance(x, (int, Integer, float, Float)): return False q = Expon(Pq, x) Pqq = Coeff(Pq, x, q) if And(NonzeroQ(m + n*p + q + S(1)), GreaterEqual(-n + q, S(0)), Or(IntegerQ(S(2)*p), IntegerQ(p + (q + S(1))/(S(2)*n)))): return True return False pattern1604 = Pattern(Integral(Pq_*(x_*WC('c', S(1)))**WC('m', S(1))*(a_ + x_**n_*WC('b', S(1)))**p_, x_), cons2, cons3, cons7, cons21, cons5, cons64, cons148, CustomConstraint(With1604)) def replacement1604(p, m, b, Pq, c, a, n, x): q = Expon(Pq, x) Pqq = Coeff(Pq, x, q) rubi.append(1604) return Dist(1/(b*(m + n*p + q + 1)), Int((c*x)**m*(a + b*x**n)**p*ExpandToSum(-Pqq*a*x**(-n + q)*(m - n + q + 1) + b*(Pq - Pqq*x**q)*(m + n*p + q + 1), x), x), x) + Simp(Pqq*c**(n - q - 1)*(c*x)**(m - n + q + 1)*(a + b*x**n)**(p + 1)/(b*(m + n*p + q + 1)), x) rule1604 = ReplacementRule(pattern1604, replacement1604) def With1605(p, b, Pq, a, n, x): if isinstance(x, (int, Integer, float, Float)): return False q = Expon(Pq, x) Pqq = Coeff(Pq, x, q) if And(NonzeroQ(n*p + q + S(1)), GreaterEqual(-n + q, S(0)), Or(IntegerQ(S(2)*p), IntegerQ(p + (q + S(1))/(S(2)*n)))): return True return False pattern1605 = Pattern(Integral(Pq_*(a_ + x_**n_*WC('b', S(1)))**p_, x_), cons2, cons3, cons5, cons64, cons148, CustomConstraint(With1605)) def replacement1605(p, b, Pq, a, n, x): q = Expon(Pq, x) Pqq = Coeff(Pq, x, q) rubi.append(1605) return Dist(1/(b*(n*p + q + 1)), Int((a + b*x**n)**p*ExpandToSum(-Pqq*a*x**(-n + q)*(-n + q + 1) + b*(Pq - Pqq*x**q)*(n*p + q + 1), x), x), x) + Simp(Pqq*x**(-n + q + 1)*(a + b*x**n)**(p + 1)/(b*(n*p + q + 1)), x) rule1605 = ReplacementRule(pattern1605, replacement1605) def With1606(p, m, b, Pq, a, n, x): q = Expon(Pq, x) rubi.append(1606) return -Subst(Int(x**(-m - q + S(-2))*(a + b*x**(-n))**p*ExpandToSum(x**q*ReplaceAll(Pq, Rule(x, S(1)/x)), x), x), x, S(1)/x) pattern1606 = Pattern(Integral(Pq_*x_**WC('m', S(1))*(a_ + x_**n_*WC('b', S(1)))**p_, x_), cons2, cons3, cons5, cons64, cons196, cons17) rule1606 = ReplacementRule(pattern1606, With1606) def With1607(p, m, b, Pq, c, a, n, x): g = Denominator(m) q = Expon(Pq, x) rubi.append(1607) return -Dist(g/c, Subst(Int(x**(-g*(m + q + S(1)) + S(-1))*(a + b*c**(-n)*x**(-g*n))**p*ExpandToSum(x**(g*q)*ReplaceAll(Pq, Rule(x, x**(-g)/c)), x), x), x, (c*x)**(-S(1)/g)), x) pattern1607 = Pattern(Integral(Pq_*(x_*WC('c', S(1)))**WC('m', S(1))*(a_ + x_**n_*WC('b', S(1)))**p_, x_), cons2, cons3, cons7, cons5, cons64, cons196, cons367) rule1607 = ReplacementRule(pattern1607, With1607) def With1608(p, m, b, Pq, c, a, n, x): q = Expon(Pq, x) rubi.append(1608) return -Dist((c*x)**m*(S(1)/x)**m, Subst(Int(x**(-m - q + S(-2))*(a + b*x**(-n))**p*ExpandToSum(x**q*ReplaceAll(Pq, Rule(x, S(1)/x)), x), x), x, S(1)/x), x) pattern1608 = Pattern(Integral(Pq_*(x_*WC('c', S(1)))**m_*(a_ + x_**n_*WC('b', S(1)))**p_, x_), cons2, cons3, cons7, cons21, cons5, cons64, cons196, cons356) rule1608 = ReplacementRule(pattern1608, With1608) def With1609(p, m, b, Pq, a, n, x): g = Denominator(n) rubi.append(1609) return Dist(g, Subst(Int(x**(g*(m + S(1)) + S(-1))*(a + b*x**(g*n))**p*ReplaceAll(Pq, Rule(x, x**g)), x), x, x**(S(1)/g)), x) pattern1609 = Pattern(Integral(Pq_*x_**WC('m', S(1))*(a_ + x_**n_*WC('b', S(1)))**p_, x_), cons2, cons3, cons21, cons5, cons64, cons489) rule1609 = ReplacementRule(pattern1609, With1609) def With1610(p, b, Pq, a, n, x): g = Denominator(n) rubi.append(1610) return Dist(g, Subst(Int(x**(g + S(-1))*(a + b*x**(g*n))**p*ReplaceAll(Pq, Rule(x, x**g)), x), x, x**(S(1)/g)), x) pattern1610 = Pattern(Integral(Pq_*(a_ + x_**n_*WC('b', S(1)))**p_, x_), cons2, cons3, cons5, cons64, cons489) rule1610 = ReplacementRule(pattern1610, With1610) pattern1611 = Pattern(Integral(Pq_*(c_*x_)**m_*(a_ + x_**n_*WC('b', S(1)))**p_, x_), cons2, cons3, cons7, cons21, cons5, cons64, cons489) def replacement1611(p, m, b, Pq, c, a, n, x): rubi.append(1611) return Dist(c**IntPart(m)*x**(-FracPart(m))*(c*x)**FracPart(m), Int(Pq*x**m*(a + b*x**n)**p, x), x) rule1611 = ReplacementRule(pattern1611, replacement1611) pattern1612 = Pattern(Integral(Pq_*x_**WC('m', S(1))*(a_ + x_**n_*WC('b', S(1)))**p_, x_), cons2, cons3, cons21, cons4, cons5, cons858, cons541, cons23) def replacement1612(p, m, b, Pq, a, n, x): rubi.append(1612) return Dist(S(1)/(m + S(1)), Subst(Int((a + b*x**(n/(m + S(1))))**p*ReplaceAll(SubstFor(x**n, Pq, x), Rule(x, x**(n/(m + S(1))))), x), x, x**(m + S(1))), x) rule1612 = ReplacementRule(pattern1612, replacement1612) pattern1613 = Pattern(Integral(Pq_*(c_*x_)**m_*(a_ + x_**n_*WC('b', S(1)))**p_, x_), cons2, cons3, cons7, cons21, cons4, cons5, cons858, cons541, cons23) def replacement1613(p, m, b, Pq, c, a, n, x): rubi.append(1613) return Dist(c**IntPart(m)*x**(-FracPart(m))*(c*x)**FracPart(m), Int(Pq*x**m*(a + b*x**n)**p, x), x) rule1613 = ReplacementRule(pattern1613, replacement1613) pattern1614 = Pattern(Integral((A_ + x_**WC('m', S(1))*WC('B', S(1)))*(a_ + x_**n_*WC('b', S(1)))**WC('p', S(1)), x_), cons2, cons3, cons34, cons35, cons21, cons4, cons5, cons53) def replacement1614(B, p, m, b, a, n, x, A): rubi.append(1614) return Dist(A, Int((a + b*x**n)**p, x), x) + Dist(B, Int(x**m*(a + b*x**n)**p, x), x) rule1614 = ReplacementRule(pattern1614, replacement1614) pattern1615 = Pattern(Integral(Pq_*(x_*WC('c', S(1)))**WC('m', S(1))*(a_ + x_**n_*WC('b', S(1)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons21, cons4, cons5, cons918) def replacement1615(p, m, b, Pq, c, a, n, x): rubi.append(1615) return Int(ExpandIntegrand(Pq*(c*x)**m*(a + b*x**n)**p, x), x) rule1615 = ReplacementRule(pattern1615, replacement1615) pattern1616 = Pattern(Integral(Pq_*(a_ + x_**n_*WC('b', S(1)))**WC('p', S(1)), x_), cons2, cons3, cons4, cons5, cons918) def replacement1616(p, b, Pq, a, n, x): rubi.append(1616) return Int(ExpandIntegrand(Pq*(a + b*x**n)**p, x), x) rule1616 = ReplacementRule(pattern1616, replacement1616) pattern1617 = Pattern(Integral(Pq_*u_**WC('m', S(1))*(a_ + v_**WC('n', S(1))*WC('b', S(1)))**p_, x_), cons2, cons3, cons21, cons4, cons5, cons554, cons919) def replacement1617(v, p, u, m, b, Pq, a, n, x): rubi.append(1617) return Dist(u**m*v**(-m)/Coeff(v, x, S(1)), Subst(Int(x**m*(a + b*x**n)**p*SubstFor(v, Pq, x), x), x, v), x) rule1617 = ReplacementRule(pattern1617, replacement1617) pattern1618 = Pattern(Integral(Pq_*(a_ + v_**WC('n', S(1))*WC('b', S(1)))**p_, x_), cons2, cons3, cons4, cons5, cons552, cons919) def replacement1618(v, p, b, Pq, a, n, x): rubi.append(1618) return Dist(S(1)/Coeff(v, x, S(1)), Subst(Int((a + b*x**n)**p*SubstFor(v, Pq, x), x), x, v), x) rule1618 = ReplacementRule(pattern1618, replacement1618) pattern1619 = Pattern(Integral(Pq_*(x_*WC('c', S(1)))**WC('m', S(1))*(a1_ + x_**WC('n', S(1))*WC('b1', S(1)))**WC('p', S(1))*(a2_ + x_**WC('n', S(1))*WC('b2', S(1)))**WC('p', S(1)), x_), cons57, cons58, cons59, cons60, cons7, cons21, cons4, cons5, cons64, cons55, cons494) def replacement1619(p, a2, m, b2, b1, Pq, c, n, x, a1): rubi.append(1619) return Int(Pq*(c*x)**m*(a1*a2 + b1*b2*x**(S(2)*n))**p, x) rule1619 = ReplacementRule(pattern1619, replacement1619) pattern1620 = Pattern(Integral(Pq_*(a1_ + x_**WC('n', S(1))*WC('b1', S(1)))**WC('p', S(1))*(a2_ + x_**WC('n', S(1))*WC('b2', S(1)))**WC('p', S(1)), x_), cons57, cons58, cons59, cons60, cons4, cons5, cons64, cons55, cons494) def replacement1620(p, a2, b2, Pq, b1, n, x, a1): rubi.append(1620) return Int(Pq*(a1*a2 + b1*b2*x**(S(2)*n))**p, x) rule1620 = ReplacementRule(pattern1620, replacement1620) pattern1621 = Pattern(Integral(Pq_*(x_*WC('c', S(1)))**WC('m', S(1))*(a1_ + x_**WC('n', S(1))*WC('b1', S(1)))**WC('p', S(1))*(a2_ + x_**WC('n', S(1))*WC('b2', S(1)))**WC('p', S(1)), x_), cons57, cons58, cons59, cons60, cons7, cons21, cons4, cons5, cons64, cons55) def replacement1621(p, a2, m, b2, b1, Pq, c, n, x, a1): rubi.append(1621) return Dist((a1 + b1*x**n)**FracPart(p)*(a2 + b2*x**n)**FracPart(p)*(a1*a2 + b1*b2*x**(S(2)*n))**(-FracPart(p)), Int(Pq*(c*x)**m*(a1*a2 + b1*b2*x**(S(2)*n))**p, x), x) rule1621 = ReplacementRule(pattern1621, replacement1621) pattern1622 = Pattern(Integral(Pq_*(a1_ + x_**WC('n', S(1))*WC('b1', S(1)))**WC('p', S(1))*(a2_ + x_**WC('n', S(1))*WC('b2', S(1)))**WC('p', S(1)), x_), cons57, cons58, cons59, cons60, cons4, cons5, cons64, cons55) def replacement1622(p, a2, b2, Pq, b1, n, x, a1): rubi.append(1622) return Dist((a1 + b1*x**n)**FracPart(p)*(a2 + b2*x**n)**FracPart(p)*(a1*a2 + b1*b2*x**(S(2)*n))**(-FracPart(p)), Int(Pq*(a1*a2 + b1*b2*x**(S(2)*n))**p, x), x) rule1622 = ReplacementRule(pattern1622, replacement1622) pattern1623 = Pattern(Integral((a_ + x_**WC('n', S(1))*WC('b', S(1)))**WC('p', S(1))*(c_ + x_**WC('n', S(1))*WC('d', S(1)))**WC('p', S(1))*(e_ + x_**WC('n', S(1))*WC('f', S(1)) + x_**WC('n2', S(1))*WC('g', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons4, cons5, cons46, cons920, cons921) def replacement1623(p, f, b, g, n2, d, a, n, c, x, e): rubi.append(1623) return Simp(e*x*(a + b*x**n)**(p + S(1))*(c + d*x**n)**(p + S(1))/(a*c), x) rule1623 = ReplacementRule(pattern1623, replacement1623) pattern1624 = Pattern(Integral((a_ + x_**WC('n', S(1))*WC('b', S(1)))**WC('p', S(1))*(c_ + x_**WC('n', S(1))*WC('d', S(1)))**WC('p', S(1))*(e_ + x_**WC('n2', S(1))*WC('g', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons208, cons4, cons5, cons46, cons922, cons921) def replacement1624(p, g, b, n2, d, a, n, c, x, e): rubi.append(1624) return Simp(e*x*(a + b*x**n)**(p + S(1))*(c + d*x**n)**(p + S(1))/(a*c), x) rule1624 = ReplacementRule(pattern1624, replacement1624) pattern1625 = Pattern(Integral((x_*WC('h', S(1)))**WC('m', S(1))*(a_ + x_**WC('n', S(1))*WC('b', S(1)))**WC('p', S(1))*(c_ + x_**WC('n', S(1))*WC('d', S(1)))**WC('p', S(1))*(e_ + x_**WC('n', S(1))*WC('f', S(1)) + x_**WC('n2', S(1))*WC('g', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons209, cons21, cons4, cons5, cons46, cons923, cons924, cons66) def replacement1625(p, m, f, b, g, n2, d, a, n, c, x, h, e): rubi.append(1625) return Simp(e*(h*x)**(m + S(1))*(a + b*x**n)**(p + S(1))*(c + d*x**n)**(p + S(1))/(a*c*h*(m + S(1))), x) rule1625 = ReplacementRule(pattern1625, replacement1625) pattern1626 = Pattern(Integral((x_*WC('h', S(1)))**WC('m', S(1))*(a_ + x_**WC('n', S(1))*WC('b', S(1)))**WC('p', S(1))*(c_ + x_**WC('n', S(1))*WC('d', S(1)))**WC('p', S(1))*(e_ + x_**WC('n2', S(1))*WC('g', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons208, cons209, cons21, cons4, cons5, cons46, cons595, cons924, cons66) def replacement1626(p, m, g, b, n2, d, a, n, c, x, h, e): rubi.append(1626) return Simp(e*(h*x)**(m + S(1))*(a + b*x**n)**(p + S(1))*(c + d*x**n)**(p + S(1))/(a*c*h*(m + S(1))), x) rule1626 = ReplacementRule(pattern1626, replacement1626) pattern1627 = Pattern(Integral((A_ + x_**WC('m', S(1))*WC('B', S(1)))*(c_ + x_**n_*WC('d', S(1)))**WC('q', S(1))*(x_**n_*WC('b', S(1)) + WC('a', S(0)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons34, cons35, cons21, cons4, cons5, cons50, cons71, cons53) def replacement1627(B, p, m, b, d, a, n, c, x, q, A): rubi.append(1627) return Dist(A, Int((a + b*x**n)**p*(c + d*x**n)**q, x), x) + Dist(B, Int(x**m*(a + b*x**n)**p*(c + d*x**n)**q, x), x) rule1627 = ReplacementRule(pattern1627, replacement1627) def With1628(p, b, Px, d, a, c, n, x, q): k = Denominator(n) rubi.append(1628) return Dist(k/d, Subst(Int(SimplifyIntegrand(x**(k + S(-1))*(a + b*x**(k*n))**p*ReplaceAll(Px, Rule(x, -c/d + x**k/d))**q, x), x), x, (c + d*x)**(S(1)/k)), x) pattern1628 = Pattern(Integral(Px_**WC('q', S(1))*((c_ + x_*WC('d', S(1)))**n_*WC('b', S(1)) + WC('a', S(0)))**p_, x_), cons2, cons3, cons7, cons27, cons5, cons925, cons586, cons87) rule1628 = ReplacementRule(pattern1628, With1628) pattern1629 = Pattern(Integral(Pq_*x_**WC('m', S(1))*(a_ + x_**n_*WC('b', S(1)) + x_**WC('n2', S(1))*WC('c', S(1)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons21, cons4, cons5, cons46, cons858, cons53) def replacement1629(p, m, b, n2, Pq, c, a, n, x): rubi.append(1629) return Dist(S(1)/n, Subst(Int((a + b*x + c*x**S(2))**p*SubstFor(x**n, Pq, x), x), x, x**n), x) rule1629 = ReplacementRule(pattern1629, replacement1629) pattern1630 = Pattern(Integral(Pq_*(x_*WC('d', S(1)))**WC('m', S(1))*(a_ + x_**WC('n', S(1))*WC('b', S(1)) + x_**WC('n2', S(1))*WC('c', S(1)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons21, cons4, cons46, cons64, cons128) def replacement1630(p, m, b, n2, Pq, d, c, n, a, x): rubi.append(1630) return Int(ExpandIntegrand(Pq*(d*x)**m*(a + b*x**n + c*x**(S(2)*n))**p, x), x) rule1630 = ReplacementRule(pattern1630, replacement1630) pattern1631 = Pattern(Integral(Pq_*(a_ + x_**WC('n', S(1))*WC('b', S(1)) + x_**WC('n2', S(1))*WC('c', S(1)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons4, cons46, cons64, cons128) def replacement1631(p, b, n2, Pq, c, n, a, x): rubi.append(1631) return Int(ExpandIntegrand(Pq*(a + b*x**n + c*x**(S(2)*n))**p, x), x) rule1631 = ReplacementRule(pattern1631, replacement1631) pattern1632 = Pattern(Integral((a_ + x_**WC('n', S(1))*WC('b', S(1)) + x_**WC('n2', S(1))*WC('c', S(1)))**WC('p', S(1))*(d_ + x_**WC('n', S(1))*WC('e', S(1)) + x_**WC('n2', S(1))*WC('f', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons4, cons5, cons46, cons926, cons927) def replacement1632(p, f, b, n2, d, c, n, a, x, e): rubi.append(1632) return Simp(d*x*(a + b*x**n + c*x**(S(2)*n))**(p + S(1))/a, x) rule1632 = ReplacementRule(pattern1632, replacement1632) pattern1633 = Pattern(Integral((d_ + x_**WC('n2', S(1))*WC('f', S(1)))*(a_ + x_**WC('n', S(1))*WC('b', S(1)) + x_**WC('n2', S(1))*WC('c', S(1)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons125, cons4, cons5, cons46, cons922, cons928) def replacement1633(p, f, b, n2, d, c, n, a, x): rubi.append(1633) return Simp(d*x*(a + b*x**n + c*x**(S(2)*n))**(p + S(1))/a, x) rule1633 = ReplacementRule(pattern1633, replacement1633) pattern1634 = Pattern(Integral((x_*WC('g', S(1)))**WC('m', S(1))*(a_ + x_**WC('n', S(1))*WC('b', S(1)) + x_**WC('n2', S(1))*WC('c', S(1)))**WC('p', S(1))*(d_ + x_**WC('n', S(1))*WC('e', S(1)) + x_**WC('n2', S(1))*WC('f', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons21, cons4, cons5, cons46, cons929, cons930, cons66) def replacement1634(p, m, g, b, n2, f, d, c, n, a, x, e): rubi.append(1634) return Simp(d*(g*x)**(m + S(1))*(a + b*x**n + c*x**(S(2)*n))**(p + S(1))/(a*g*(m + S(1))), x) rule1634 = ReplacementRule(pattern1634, replacement1634) pattern1635 = Pattern(Integral((x_*WC('g', S(1)))**WC('m', S(1))*(d_ + x_**WC('n2', S(1))*WC('f', S(1)))*(a_ + x_**WC('n', S(1))*WC('b', S(1)) + x_**WC('n2', S(1))*WC('c', S(1)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons125, cons208, cons21, cons4, cons5, cons46, cons595, cons928, cons66) def replacement1635(p, m, g, b, n2, f, d, c, n, a, x): rubi.append(1635) return Simp(d*(g*x)**(m + S(1))*(a + b*x**n + c*x**(S(2)*n))**(p + S(1))/(a*g*(m + S(1))), x) rule1635 = ReplacementRule(pattern1635, replacement1635) pattern1636 = Pattern(Integral(Pq_*(x_*WC('d', S(1)))**WC('m', S(1))*(a_ + x_**WC('n', S(1))*WC('b', S(1)) + x_**WC('n2', S(1))*WC('c', S(1)))**p_, x_), cons2, cons3, cons7, cons27, cons21, cons4, cons5, cons46, cons64, cons45, cons314) def replacement1636(p, m, b, n2, Pq, d, c, n, a, x): rubi.append(1636) return Dist((S(4)*c)**(-IntPart(p))*(b + S(2)*c*x**n)**(-S(2)*FracPart(p))*(a + b*x**n + c*x**(S(2)*n))**FracPart(p), Int(Pq*(d*x)**m*(b + S(2)*c*x**n)**(S(2)*p), x), x) rule1636 = ReplacementRule(pattern1636, replacement1636) pattern1637 = Pattern(Integral(Pq_*(a_ + x_**WC('n', S(1))*WC('b', S(1)) + x_**WC('n2', S(1))*WC('c', S(1)))**p_, x_), cons2, cons3, cons7, cons4, cons5, cons46, cons64, cons45, cons314) def replacement1637(p, b, n2, Pq, c, n, a, x): rubi.append(1637) return Dist((S(4)*c)**(-IntPart(p))*(b + S(2)*c*x**n)**(-S(2)*FracPart(p))*(a + b*x**n + c*x**(S(2)*n))**FracPart(p), Int(Pq*(b + S(2)*c*x**n)**(S(2)*p), x), x) rule1637 = ReplacementRule(pattern1637, replacement1637) pattern1638 = Pattern(Integral(Pq_*x_**WC('m', S(1))*(a_ + x_**n_*WC('b', S(1)) + x_**WC('n2', S(1))*WC('c', S(1)))**p_, x_), cons2, cons3, cons7, cons21, cons4, cons5, cons46, cons858, cons226, cons500) def replacement1638(p, m, b, n2, Pq, c, a, n, x): rubi.append(1638) return Dist(S(1)/n, Subst(Int(x**(S(-1) + (m + S(1))/n)*(a + b*x + c*x**S(2))**p*SubstFor(x**n, Pq, x), x), x, x**n), x) rule1638 = ReplacementRule(pattern1638, replacement1638) pattern1639 = Pattern(Integral(Pq_*(d_*x_)**WC('m', S(1))*(a_ + x_**n_*WC('b', S(1)) + x_**WC('n2', S(1))*WC('c', S(1)))**p_, x_), cons2, cons3, cons7, cons27, cons21, cons4, cons5, cons46, cons858, cons226, cons500) def replacement1639(p, m, b, n2, Pq, d, c, a, n, x): rubi.append(1639) return Dist(x**(-m)*(d*x)**m, Int(Pq*x**m*(a + b*x**n + c*x**(S(2)*n))**p, x), x) rule1639 = ReplacementRule(pattern1639, replacement1639) pattern1640 = Pattern(Integral(Pq_*(x_*WC('d', S(1)))**WC('m', S(1))*(a_ + x_**WC('n', S(1))*WC('b', S(1)) + x_**WC('n2', S(1))*WC('c', S(1)))**p_, x_), cons2, cons3, cons7, cons27, cons21, cons4, cons5, cons46, cons64, cons859) def replacement1640(p, m, b, n2, Pq, d, c, n, a, x): rubi.append(1640) return Dist(S(1)/d, Int((d*x)**(m + S(1))*(a + b*x**n + c*x**(S(2)*n))**p*ExpandToSum(Pq/x, x), x), x) rule1640 = ReplacementRule(pattern1640, replacement1640) pattern1641 = Pattern(Integral(Pq_*(a_ + x_**WC('n', S(1))*WC('b', S(1)) + x_**WC('n2', S(1))*WC('c', S(1)))**p_, x_), cons2, cons3, cons7, cons4, cons5, cons46, cons64, cons859, cons860) def replacement1641(p, b, n2, Pq, c, n, a, x): rubi.append(1641) return Int(x*(a + b*x**n + c*x**(S(2)*n))**p*ExpandToSum(Pq/x, x), x) rule1641 = ReplacementRule(pattern1641, replacement1641) pattern1642 = Pattern(Integral((a_ + x_**n_*WC('b', S(1)) + x_**WC('n2', S(1))*WC('c', S(1)))**WC('p', S(1))*(d_ + x_**n_*WC('e', S(1)) + x_**WC('n2', S(1))*WC('f', S(1)) + x_**WC('n3', S(1))*WC('g', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons4, cons5, cons46, cons931, cons226, cons932, cons933) def replacement1642(p, f, b, n2, g, d, n3, c, a, n, x, e): rubi.append(1642) return Simp(x*(S(3)*a*d - x**S(2)*(-a*e + S(2)*b*d*p + S(3)*b*d))*(a + b*x**S(2) + c*x**S(4))**(p + S(1))/(S(3)*a**S(2)), x) rule1642 = ReplacementRule(pattern1642, replacement1642) pattern1643 = Pattern(Integral((a_ + x_**n_*WC('b', S(1)) + x_**WC('n2', S(1))*WC('c', S(1)))**WC('p', S(1))*(d_ + x_**WC('n2', S(1))*WC('f', S(1)) + x_**WC('n3', S(1))*WC('g', S(1))), x_), cons2, cons3, cons7, cons27, cons125, cons208, cons4, cons5, cons46, cons931, cons226, cons934, cons935) def replacement1643(p, f, g, n2, b, d, n3, c, a, n, x): rubi.append(1643) return Simp(x*(S(3)*a*d - x**S(2)*(S(2)*b*d*p + S(3)*b*d))*(a + b*x**S(2) + c*x**S(4))**(p + S(1))/(S(3)*a**S(2)), x) rule1643 = ReplacementRule(pattern1643, replacement1643) pattern1644 = Pattern(Integral((a_ + x_**n_*WC('b', S(1)) + x_**WC('n2', S(1))*WC('c', S(1)))**WC('p', S(1))*(d_ + x_**n_*WC('e', S(1)) + x_**WC('n3', S(1))*WC('g', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons208, cons4, cons5, cons46, cons931, cons226, cons932, cons936) def replacement1644(p, g, b, n2, d, n3, c, a, n, x, e): rubi.append(1644) return Simp(x*(S(3)*a*d - x**S(2)*(-a*e + S(2)*b*d*p + S(3)*b*d))*(a + b*x**S(2) + c*x**S(4))**(p + S(1))/(S(3)*a**S(2)), x) rule1644 = ReplacementRule(pattern1644, replacement1644) pattern1645 = Pattern(Integral((d_ + x_**WC('n3', S(1))*WC('g', S(1)))*(a_ + x_**n_*WC('b', S(1)) + x_**WC('n2', S(1))*WC('c', S(1)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons208, cons4, cons5, cons46, cons931, cons226, cons934, cons937) def replacement1645(p, g, b, n2, d, n3, c, a, n, x): rubi.append(1645) return Simp(x*(S(3)*a*d - x**S(2)*(S(2)*b*d*p + S(3)*b*d))*(a + b*x**S(2) + c*x**S(4))**(p + S(1))/(S(3)*a**S(2)), x) rule1645 = ReplacementRule(pattern1645, replacement1645) pattern1646 = Pattern(Integral(x_**WC('m', S(1))*(e_ + x_**WC('q', S(1))*WC('f', S(1)) + x_**WC('r', S(1))*WC('g', S(1)) + x_**WC('s', S(1))*WC('h', S(1)))/(a_ + x_**WC('n', S(1))*WC('b', S(1)) + x_**WC('n2', S(1))*WC('c', S(1)))**(S(3)/2), x_), cons2, cons3, cons7, cons48, cons125, cons208, cons209, cons21, cons4, cons46, cons938, cons939, cons940, cons226, cons941, cons852) def replacement1646(s, m, f, b, n2, g, r, c, n, a, x, h, q, e): rubi.append(1646) return -Simp((S(2)*c*x**n*(-b*g + S(2)*c*f) + S(2)*c*(-S(2)*a*g + b*f) + S(2)*h*x**(n/S(2))*(-S(4)*a*c + b**S(2)))/(c*n*(-S(4)*a*c + b**S(2))*sqrt(a + b*x**n + c*x**(S(2)*n))), x) rule1646 = ReplacementRule(pattern1646, replacement1646) pattern1647 = Pattern(Integral((d_*x_)**WC('m', S(1))*(e_ + x_**WC('q', S(1))*WC('f', S(1)) + x_**WC('r', S(1))*WC('g', S(1)) + x_**WC('s', S(1))*WC('h', S(1)))/(a_ + x_**WC('n', S(1))*WC('b', S(1)) + x_**WC('n2', S(1))*WC('c', S(1)))**(S(3)/2), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons209, cons21, cons4, cons46, cons938, cons939, cons940, cons226, cons941, cons852) def replacement1647(s, m, f, b, n2, g, r, d, c, n, a, x, h, q, e): rubi.append(1647) return Dist(x**(-m)*(d*x)**m, Int(x**m*(e + f*x**(n/S(2)) + g*x**(S(3)*n/S(2)) + h*x**(S(2)*n))/(a + b*x**n + c*x**(S(2)*n))**(S(3)/2), x), x) rule1647 = ReplacementRule(pattern1647, replacement1647) def With1648(p, b, n2, Pq, c, a, n, x): if isinstance(x, (int, Integer, float, Float)): return False q = Expon(Pq, x) i = Symbol('i') if Less(q, S(2)*n): return True return False pattern1648 = Pattern(Integral(Pq_*(a_ + x_**n2_*WC('c', S(1)) + x_**n_*WC('b', S(1)))**p_, x_), cons2, cons3, cons7, cons46, cons64, cons226, cons148, cons13, cons137, CustomConstraint(With1648)) def replacement1648(p, b, n2, Pq, c, a, n, x): q = Expon(Pq, x) i = Symbol('i') rubi.append(1648) return Dist(S(1)/(a*n*(p + S(1))*(-S(4)*a*c + b**S(2))), Int((a + b*x**n + c*x**(S(2)*n))**(p + S(1))*Sum_doit(c*x**(i + n)*(-S(2)*a*Coeff(Pq, x, i + n) + b*Coeff(Pq, x, i))*(i + n*(S(2)*p + S(3)) + S(1)) + x**i*(-a*b*(i + S(1))*Coeff(Pq, x, i + n) + (-S(2)*a*c*(i + S(2)*n*(p + S(1)) + S(1)) + b**S(2)*(i + n*(p + S(1)) + S(1)))*Coeff(Pq, x, i)), List(i, S(0), n + S(-1))), x), x) - Simp(x*(a + b*x**n + c*x**(S(2)*n))**(p + S(1))*Sum_doit(c*x**(i + n)*(-S(2)*a*Coeff(Pq, x, i + n) + b*Coeff(Pq, x, i)) + x**i*(-a*b*Coeff(Pq, x, i + n) + (-S(2)*a*c + b**S(2))*Coeff(Pq, x, i)), List(i, S(0), n + S(-1)))/(a*n*(p + S(1))*(-S(4)*a*c + b**S(2))), x) rule1648 = ReplacementRule(pattern1648, replacement1648) pattern1649 = Pattern(Integral((d_ + x_**S(4)*WC('g', S(1)) + x_**S(3)*WC('f', S(1)) + x_*WC('e', S(1)))/(a_ + x_**S(4)*WC('c', S(1)) + x_**S(2)*WC('b', S(1)))**(S(3)/2), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons226, cons942) def replacement1649(f, b, g, d, c, a, x, e): rubi.append(1649) return -Simp((c*x**S(2)*(-b*f + S(2)*c*e) + c*(-S(2)*a*f + b*e) + g*x*(-S(4)*a*c + b**S(2)))/(c*(-S(4)*a*c + b**S(2))*sqrt(a + b*x**S(2) + c*x**S(4))), x) rule1649 = ReplacementRule(pattern1649, replacement1649) pattern1650 = Pattern(Integral((d_ + x_**S(4)*WC('g', S(1)) + x_**S(3)*WC('f', S(1)))/(a_ + x_**S(4)*WC('c', S(1)) + x_**S(2)*WC('b', S(1)))**(S(3)/2), x_), cons2, cons3, cons7, cons27, cons125, cons208, cons226, cons942) def replacement1650(f, b, g, d, c, a, x): rubi.append(1650) return Simp((S(2)*a*c*f + b*c*f*x**S(2) - g*x*(-S(4)*a*c + b**S(2)))/(c*(-S(4)*a*c + b**S(2))*sqrt(a + b*x**S(2) + c*x**S(4))), x) rule1650 = ReplacementRule(pattern1650, replacement1650) pattern1651 = Pattern(Integral((d_ + x_**S(4)*WC('g', S(1)) + x_*WC('e', S(1)))/(a_ + x_**S(4)*WC('c', S(1)) + x_**S(2)*WC('b', S(1)))**(S(3)/2), x_), cons2, cons3, cons7, cons27, cons48, cons208, cons226, cons942) def replacement1651(g, b, d, c, a, x, e): rubi.append(1651) return -Simp((b*c*e + S(2)*c**S(2)*e*x**S(2) + g*x*(-S(4)*a*c + b**S(2)))/(c*(-S(4)*a*c + b**S(2))*sqrt(a + b*x**S(2) + c*x**S(4))), x) rule1651 = ReplacementRule(pattern1651, replacement1651) pattern1652 = Pattern(Integral(x_**S(2)*(x_**S(4)*WC('h', S(1)) + x_**S(2)*WC('g', S(1)) + x_*WC('f', S(1)) + WC('e', S(0)))/(a_ + x_**S(4)*WC('c', S(1)) + x_**S(2)*WC('b', S(1)))**(S(3)/2), x_), cons2, cons3, cons7, cons48, cons125, cons208, cons209, cons226, cons943, cons944) def replacement1652(f, b, g, c, a, x, h, e): rubi.append(1652) return Simp((S(2)*a**S(2)*c*f + a*b*c*f*x**S(2) + a*h*x**S(3)*(-S(4)*a*c + b**S(2)))/(a*c*(-S(4)*a*c + b**S(2))*sqrt(a + b*x**S(2) + c*x**S(4))), x) rule1652 = ReplacementRule(pattern1652, replacement1652) pattern1653 = Pattern(Integral(x_**S(2)*(x_**S(4)*WC('h', S(1)) + x_**S(2)*WC('g', S(1)) + WC('e', S(0)))/(a_ + x_**S(4)*WC('c', S(1)) + x_**S(2)*WC('b', S(1)))**(S(3)/2), x_), cons2, cons3, cons7, cons48, cons208, cons209, cons226, cons943, cons944) def replacement1653(g, b, c, a, x, h, e): rubi.append(1653) return Simp(h*x**S(3)/(c*sqrt(a + b*x**S(2) + c*x**S(4))), x) rule1653 = ReplacementRule(pattern1653, replacement1653) pattern1654 = Pattern(Integral((d_ + x_**S(6)*WC('h', S(1)) + x_**S(4)*WC('g', S(1)) + x_**S(3)*WC('f', S(1)) + x_**S(2)*WC('e', S(1)))/(a_ + x_**S(4)*WC('c', S(1)) + x_**S(2)*WC('b', S(1)))**(S(3)/2), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons209, cons226, cons943, cons945) def replacement1654(f, b, g, d, c, a, x, h, e): rubi.append(1654) return Simp((S(2)*a**S(2)*c*f + a*b*c*f*x**S(2) + a*h*x**S(3)*(-S(4)*a*c + b**S(2)) + c*d*x*(-S(4)*a*c + b**S(2)))/(a*c*(-S(4)*a*c + b**S(2))*sqrt(a + b*x**S(2) + c*x**S(4))), x) rule1654 = ReplacementRule(pattern1654, replacement1654) pattern1655 = Pattern(Integral((d_ + x_**S(6)*WC('h', S(1)) + x_**S(3)*WC('f', S(1)) + x_**S(2)*WC('e', S(1)))/(a_ + x_**S(4)*WC('c', S(1)) + x_**S(2)*WC('b', S(1)))**(S(3)/2), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons209, cons226, cons943, cons946) def replacement1655(f, b, d, c, a, x, h, e): rubi.append(1655) return Simp((S(2)*a**S(2)*c*f + a*b*c*f*x**S(2) + a*h*x**S(3)*(-S(4)*a*c + b**S(2)) + c*d*x*(-S(4)*a*c + b**S(2)))/(a*c*(-S(4)*a*c + b**S(2))*sqrt(a + b*x**S(2) + c*x**S(4))), x) rule1655 = ReplacementRule(pattern1655, replacement1655) def With1656(p, b, n2, Pq, c, a, n, x): if isinstance(x, (int, Integer, float, Float)): return False q = Expon(Pq, x) Q = PolynomialQuotient(Pq*(b*c)**(Floor((q + S(-1))/n) + S(1)), a + b*x**n + c*x**(S(2)*n), x) R = PolynomialRemainder(Pq*(b*c)**(Floor((q + S(-1))/n) + S(1)), a + b*x**n + c*x**(S(2)*n), x) if GreaterEqual(q, S(2)*n): return True return False pattern1656 = Pattern(Integral(Pq_*(a_ + x_**n2_*WC('c', S(1)) + x_**n_*WC('b', S(1)))**p_, x_), cons2, cons3, cons7, cons46, cons64, cons226, cons148, cons13, cons137, CustomConstraint(With1656)) def replacement1656(p, b, n2, Pq, c, a, n, x): q = Expon(Pq, x) Q = PolynomialQuotient(Pq*(b*c)**(Floor((q + S(-1))/n) + S(1)), a + b*x**n + c*x**(S(2)*n), x) R = PolynomialRemainder(Pq*(b*c)**(Floor((q + S(-1))/n) + S(1)), a + b*x**n + c*x**(S(2)*n), x) rubi.append(1656) return Dist((b*c)**(-Floor((q - 1)/n) - 1)/(a*n*(p + 1)*(-4*a*c + b**2)), Int((a + b*x**n + c*x**(2*n))**(p + 1)*ExpandToSum(Q*a*n*(p + 1)*(-4*a*c + b**2) + Sum_doit(c*x**(i + n)*(-2*a*Coeff(R, x, i + n) + b*Coeff(R, x, i))*(i + n*(2*p + 3) + 1) + x**i*(-a*b*(i + 1)*Coeff(R, x, i + n) + (-2*a*c*(i + 2*n*(p + 1) + 1) + b**2*(i + n*(p + 1) + 1))*Coeff(R, x, i)), List(i, 0, n - 1)), x), x), x) - Simp(x*(b*c)**(-Floor((q - 1)/n) - 1)*(a + b*x**n + c*x**(2*n))**(p + 1)*Sum_doit(c*x**(i + n)*(-2*a*Coeff(R, x, i + n) + b*Coeff(R, x, i)) + x**i*(-a*b*Coeff(R, x, i + n) + (-2*a*c + b**2)*Coeff(R, x, i)), List(i, 0, n - 1))/(a*n*(p + 1)*(-4*a*c + b**2)), x) rule1656 = ReplacementRule(pattern1656, replacement1656) def With1657(p, m, b, n2, Pq, c, a, n, x): if isinstance(x, (int, Integer, float, Float)): return False q = Expon(Pq, x) Q = PolynomialQuotient(Pq*a*x**m*(b*c)**(Floor((q + S(-1))/n) + S(1)), a + b*x**n + c*x**(S(2)*n), x) R = PolynomialRemainder(Pq*a*x**m*(b*c)**(Floor((q + S(-1))/n) + S(1)), a + b*x**n + c*x**(S(2)*n), x) if GreaterEqual(q, S(2)*n): return True return False pattern1657 = Pattern(Integral(Pq_*x_**m_*(a_ + x_**n2_*WC('c', S(1)) + x_**n_*WC('b', S(1)))**p_, x_), cons2, cons3, cons7, cons46, cons64, cons226, cons148, cons13, cons137, cons84, CustomConstraint(With1657)) def replacement1657(p, m, b, n2, Pq, c, a, n, x): q = Expon(Pq, x) Q = PolynomialQuotient(Pq*a*x**m*(b*c)**(Floor((q + S(-1))/n) + S(1)), a + b*x**n + c*x**(S(2)*n), x) R = PolynomialRemainder(Pq*a*x**m*(b*c)**(Floor((q + S(-1))/n) + S(1)), a + b*x**n + c*x**(S(2)*n), x) rubi.append(1657) return Dist((b*c)**(-Floor((q - 1)/n) - 1)/(a*n*(p + 1)*(-4*a*c + b**2)), Int(x**m*(a + b*x**n + c*x**(2*n))**(p + 1)*ExpandToSum(Q*n*x**(-m)*(p + 1)*(-4*a*c + b**2) + Sum_doit(c*x**(i - m + n)*(-2*Coeff(R, x, i + n) + b*Coeff(R, x, i)/a)*(i + n*(2*p + 3) + 1) + x**(i - m)*(-b*(i + 1)*Coeff(R, x, i + n) + (-2*c*(i + 2*n*(p + 1) + 1) + b**2*(i + n*(p + 1) + 1)/a)*Coeff(R, x, i)), List(i, 0, n - 1)), x), x), x) - Simp(x*(b*c)**(-Floor((q - 1)/n) - 1)*(a + b*x**n + c*x**(2*n))**(p + 1)*Sum_doit(c*x**(i + n)*(-2*a*Coeff(R, x, i + n) + b*Coeff(R, x, i)) + x**i*(-a*b*Coeff(R, x, i + n) + (-2*a*c + b**2)*Coeff(R, x, i)), List(i, 0, n - 1))/(a**2*n*(p + 1)*(-4*a*c + b**2)), x) rule1657 = ReplacementRule(pattern1657, replacement1657) def With1658(p, m, b, n2, Pq, c, a, n, x): if isinstance(x, (int, Integer, float, Float)): return False g = GCD(m + S(1), n) if Unequal(g, S(1)): return True return False pattern1658 = Pattern(Integral(Pq_*x_**WC('m', S(1))*(a_ + x_**n2_*WC('c', S(1)) + x_**n_*WC('b', S(1)))**p_, x_), cons2, cons3, cons7, cons5, cons46, cons858, cons226, cons148, cons17, CustomConstraint(With1658)) def replacement1658(p, m, b, n2, Pq, c, a, n, x): g = GCD(m + S(1), n) rubi.append(1658) return Dist(S(1)/g, Subst(Int(x**(S(-1) + (m + S(1))/g)*(a + b*x**(n/g) + c*x**(S(2)*n/g))**p*ReplaceAll(Pq, Rule(x, x**(S(1)/g))), x), x, x**g), x) rule1658 = ReplacementRule(pattern1658, replacement1658) pattern1659 = Pattern(Integral(Pq_*(x_*WC('d', S(1)))**WC('m', S(1))/(a_ + x_**n2_*WC('c', S(1)) + x_**WC('n', S(1))*WC('b', S(1))), x_), cons2, cons3, cons7, cons27, cons21, cons46, cons858, cons226, cons148, cons282) def replacement1659(m, b, n2, Pq, d, c, n, a, x): rubi.append(1659) return Int(ExpandIntegrand(Pq*(d*x)**m/(a + b*x**n + c*x**(S(2)*n)), x), x) rule1659 = ReplacementRule(pattern1659, replacement1659) pattern1660 = Pattern(Integral(Pq_/(a_ + x_**n2_*WC('c', S(1)) + x_**WC('n', S(1))*WC('b', S(1))), x_), cons2, cons3, cons7, cons46, cons858, cons226, cons148, cons947) def replacement1660(b, n2, Pq, c, n, a, x): rubi.append(1660) return Int(ExpandIntegrand(Pq/(a + b*x**n + c*x**(S(2)*n)), x), x) rule1660 = ReplacementRule(pattern1660, replacement1660) def With1661(p, b, Pq, c, a, x): if isinstance(x, (int, Integer, float, Float)): return False q = Expon(Pq, x) Pqq = Coeff(Pq, x, q) if Equal(S(2)*p + q + S(1), S(0)): return True return False pattern1661 = Pattern(Integral(Pq_*(a_ + x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)))**p_, x_), cons2, cons3, cons7, cons64, cons226, cons63, CustomConstraint(With1661)) def replacement1661(p, b, Pq, c, a, x): q = Expon(Pq, x) Pqq = Coeff(Pq, x, q) rubi.append(1661) return Dist(S.Half, Int((a + b*x + c*x**2)**p*ExpandToSum(2*Pq - Pqq*c**p*(b + 2*c*x)*(a + b*x + c*x**2)**(-p - 1), x), x), x) + Simp(Pqq*c**p*log(a + b*x + c*x**2)/2, x) rule1661 = ReplacementRule(pattern1661, replacement1661) def With1662(p, b, Pq, c, a, x): if isinstance(x, (int, Integer, float, Float)): return False q = Expon(Pq, x) Pqq = Coeff(Pq, x, q) if Equal(S(2)*p + q + S(1), S(0)): return True return False pattern1662 = Pattern(Integral(Pq_*(a_ + x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)))**p_, x_), cons2, cons3, cons7, cons64, cons226, cons719, cons948, CustomConstraint(With1662)) def replacement1662(p, b, Pq, c, a, x): q = Expon(Pq, x) Pqq = Coeff(Pq, x, q) rubi.append(1662) return Int((a + b*x + c*x**2)**p*ExpandToSum(Pq - Pqq*c**(p + S.Half)*(a + b*x + c*x**2)**(-p - S.Half), x), x) + Simp(Pqq*c**p*atanh((b + 2*c*x)/(2*sqrt(a + b*x + c*x**2)*Rt(c, 2))), x) rule1662 = ReplacementRule(pattern1662, replacement1662) def With1663(p, b, Pq, c, a, x): if isinstance(x, (int, Integer, float, Float)): return False q = Expon(Pq, x) Pqq = Coeff(Pq, x, q) if Equal(S(2)*p + q + S(1), S(0)): return True return False pattern1663 = Pattern(Integral(Pq_*(a_ + x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)))**p_, x_), cons2, cons3, cons7, cons64, cons226, cons719, cons949, CustomConstraint(With1663)) def replacement1663(p, b, Pq, c, a, x): q = Expon(Pq, x) Pqq = Coeff(Pq, x, q) rubi.append(1663) return Int((a + b*x + c*x**2)**p*ExpandToSum(Pq - Pqq*(-c)**(p + S.Half)*(a + b*x + c*x**2)**(-p - S.Half), x), x) - Simp(Pqq*(-c)**p*ArcTan((b + 2*c*x)/(2*sqrt(a + b*x + c*x**2)*Rt(-c, 2))), x) rule1663 = ReplacementRule(pattern1663, replacement1663) def With1664(p, m, b, n2, Pq, d, c, n, a, x): if isinstance(x, (int, Integer, float, Float)): return False q = Expon(Pq, x) Pqq = Coeff(Pq, x, q) if And(GreaterEqual(q, S(2)*n), Unequal(m + S(2)*n*p + q + S(1), S(0)), Or(IntegerQ(S(2)*p), And(Equal(n, S(1)), IntegerQ(S(4)*p)), IntegerQ(p + (q + S(1))/(S(2)*n)))): return True return False pattern1664 = Pattern(Integral(Pq_*(x_*WC('d', S(1)))**WC('m', S(1))*(a_ + x_**n2_*WC('c', S(1)) + x_**WC('n', S(1))*WC('b', S(1)))**p_, x_), cons2, cons3, cons7, cons27, cons21, cons5, cons46, cons858, cons226, cons148, CustomConstraint(With1664)) def replacement1664(p, m, b, n2, Pq, d, c, n, a, x): q = Expon(Pq, x) Pqq = Coeff(Pq, x, q) rubi.append(1664) return Int((d*x)**m*(a + b*x**n + c*x**(2*n))**p*ExpandToSum(Pq - Pqq*x**q - Pqq*(a*x**(-2*n + q)*(m - 2*n + q + 1) + b*x**(-n + q)*(m + n*(p - 1) + q + 1))/(c*(m + 2*n*p + q + 1)), x), x) + Simp(Pqq*d**(2*n - q - 1)*(d*x)**(m - 2*n + q + 1)*(a + b*x**n + c*x**(2*n))**(p + 1)/(c*(m + 2*n*p + q + 1)), x) rule1664 = ReplacementRule(pattern1664, replacement1664) def With1665(p, b, n2, Pq, c, n, a, x): if isinstance(x, (int, Integer, float, Float)): return False q = Expon(Pq, x) Pqq = Coeff(Pq, x, q) if And(GreaterEqual(q, S(2)*n), Unequal(S(2)*n*p + q + S(1), S(0)), Or(IntegerQ(S(2)*p), And(Equal(n, S(1)), IntegerQ(S(4)*p)), IntegerQ(p + (q + S(1))/(S(2)*n)))): return True return False pattern1665 = Pattern(Integral(Pq_*(a_ + x_**n2_*WC('c', S(1)) + x_**WC('n', S(1))*WC('b', S(1)))**p_, x_), cons2, cons3, cons7, cons5, cons46, cons858, cons226, cons148, CustomConstraint(With1665)) def replacement1665(p, b, n2, Pq, c, n, a, x): q = Expon(Pq, x) Pqq = Coeff(Pq, x, q) rubi.append(1665) return Int((a + b*x**n + c*x**(2*n))**p*ExpandToSum(Pq - Pqq*x**q - Pqq*(a*x**(-2*n + q)*(-2*n + q + 1) + b*x**(-n + q)*(n*(p - 1) + q + 1))/(c*(2*n*p + q + 1)), x), x) + Simp(Pqq*x**(-2*n + q + 1)*(a + b*x**n + c*x**(2*n))**(p + 1)/(c*(2*n*p + q + 1)), x) rule1665 = ReplacementRule(pattern1665, replacement1665) def With1666(p, m, b, n2, Pq, d, c, a, n, x): q = Expon(Pq, x) j = Symbol('j') k = Symbol('k') rubi.append(1666) return Int(Sum_doit(d**(-j)*(d*x)**(j + m)*(a + b*x**n + c*x**(S(2)*n))**p*Sum_doit(x**(k*n)*Coeff(Pq, x, j + k*n), List(k, S(0), S(1) + (-j + q)/n)), List(j, S(0), n + S(-1))), x) pattern1666 = Pattern(Integral(Pq_*(x_*WC('d', S(1)))**WC('m', S(1))*(a_ + x_**n2_*WC('c', S(1)) + x_**n_*WC('b', S(1)))**p_, x_), cons2, cons3, cons7, cons27, cons21, cons5, cons46, cons64, cons226, cons148, cons950) rule1666 = ReplacementRule(pattern1666, With1666) def With1667(p, b, n2, Pq, c, a, n, x): q = Expon(Pq, x) j = Symbol('j') k = Symbol('k') rubi.append(1667) return Int(Sum_doit(x**j*(a + b*x**n + c*x**(S(2)*n))**p*Sum_doit(x**(k*n)*Coeff(Pq, x, j + k*n), List(k, S(0), S(1) + (-j + q)/n)), List(j, S(0), n + S(-1))), x) pattern1667 = Pattern(Integral(Pq_*(a_ + x_**n2_*WC('c', S(1)) + x_**n_*WC('b', S(1)))**p_, x_), cons2, cons3, cons7, cons5, cons46, cons64, cons226, cons148, cons950) rule1667 = ReplacementRule(pattern1667, With1667) pattern1668 = Pattern(Integral(Pq_*(x_*WC('d', S(1)))**WC('m', S(1))/(a_ + x_**WC('n', S(1))*WC('b', S(1)) + x_**WC('n2', S(1))*WC('c', S(1))), x_), cons2, cons3, cons7, cons27, cons21, cons46, cons64, cons226, cons148) def replacement1668(m, b, n2, Pq, d, c, n, a, x): rubi.append(1668) return Int(RationalFunctionExpand(Pq*(d*x)**m/(a + b*x**n + c*x**(S(2)*n)), x), x) rule1668 = ReplacementRule(pattern1668, replacement1668) pattern1669 = Pattern(Integral(Pq_/(a_ + x_**WC('n', S(1))*WC('b', S(1)) + x_**WC('n2', S(1))*WC('c', S(1))), x_), cons2, cons3, cons7, cons46, cons64, cons226, cons148) def replacement1669(b, n2, Pq, c, n, a, x): rubi.append(1669) return Int(RationalFunctionExpand(Pq/(a + b*x**n + c*x**(S(2)*n)), x), x) rule1669 = ReplacementRule(pattern1669, replacement1669) def With1670(p, m, b, n2, Pq, c, a, n, x): q = Expon(Pq, x) rubi.append(1670) return -Subst(Int(x**(-m - q + S(-2))*(a + b*x**(-n) + c*x**(-S(2)*n))**p*ExpandToSum(x**q*ReplaceAll(Pq, Rule(x, S(1)/x)), x), x), x, S(1)/x) pattern1670 = Pattern(Integral(Pq_*x_**WC('m', S(1))*(a_ + x_**n_*WC('b', S(1)) + x_**WC('n2', S(1))*WC('c', S(1)))**p_, x_), cons2, cons3, cons7, cons5, cons46, cons64, cons226, cons196, cons17) rule1670 = ReplacementRule(pattern1670, With1670) def With1671(p, m, b, n2, Pq, d, c, a, n, x): g = Denominator(m) q = Expon(Pq, x) rubi.append(1671) return -Dist(g/d, Subst(Int(x**(-g*(m + q + S(1)) + S(-1))*(a + b*d**(-n)*x**(-g*n) + c*d**(-S(2)*n)*x**(-S(2)*g*n))**p*ExpandToSum(x**(g*q)*ReplaceAll(Pq, Rule(x, x**(-g)/d)), x), x), x, (d*x)**(-S(1)/g)), x) pattern1671 = Pattern(Integral(Pq_*(x_*WC('d', S(1)))**WC('m', S(1))*(a_ + x_**n_*WC('b', S(1)) + x_**WC('n2', S(1))*WC('c', S(1)))**p_, x_), cons2, cons3, cons7, cons27, cons5, cons46, cons64, cons226, cons196, cons367) rule1671 = ReplacementRule(pattern1671, With1671) def With1672(p, m, b, n2, Pq, d, c, a, n, x): q = Expon(Pq, x) rubi.append(1672) return -Dist((d*x)**m*(S(1)/x)**m, Subst(Int(x**(-m - q + S(-2))*(a + b*x**(-n) + c*x**(-S(2)*n))**p*ExpandToSum(x**q*ReplaceAll(Pq, Rule(x, S(1)/x)), x), x), x, S(1)/x), x) pattern1672 = Pattern(Integral(Pq_*(x_*WC('d', S(1)))**m_*(a_ + x_**n_*WC('b', S(1)) + x_**WC('n2', S(1))*WC('c', S(1)))**p_, x_), cons2, cons3, cons7, cons27, cons21, cons5, cons46, cons64, cons226, cons196, cons356) rule1672 = ReplacementRule(pattern1672, With1672) def With1673(p, m, b, n2, Pq, c, a, n, x): g = Denominator(n) rubi.append(1673) return Dist(g, Subst(Int(x**(g*(m + S(1)) + S(-1))*(a + b*x**(g*n) + c*x**(S(2)*g*n))**p*ReplaceAll(Pq, Rule(x, x**g)), x), x, x**(S(1)/g)), x) pattern1673 = Pattern(Integral(Pq_*x_**WC('m', S(1))*(a_ + x_**n_*WC('b', S(1)) + x_**WC('n2', S(1))*WC('c', S(1)))**p_, x_), cons2, cons3, cons7, cons21, cons5, cons46, cons64, cons226, cons489) rule1673 = ReplacementRule(pattern1673, With1673) def With1674(p, b, n2, Pq, c, a, n, x): g = Denominator(n) rubi.append(1674) return Dist(g, Subst(Int(x**(g + S(-1))*(a + b*x**(g*n) + c*x**(S(2)*g*n))**p*ReplaceAll(Pq, Rule(x, x**g)), x), x, x**(S(1)/g)), x) pattern1674 = Pattern(Integral(Pq_*(a_ + x_**n_*WC('b', S(1)) + x_**WC('n2', S(1))*WC('c', S(1)))**p_, x_), cons2, cons3, cons7, cons5, cons46, cons64, cons226, cons489) rule1674 = ReplacementRule(pattern1674, With1674) pattern1675 = Pattern(Integral(Pq_*(d_*x_)**m_*(a_ + x_**n_*WC('b', S(1)) + x_**WC('n2', S(1))*WC('c', S(1)))**p_, x_), cons2, cons3, cons7, cons27, cons5, cons46, cons64, cons226, cons489, cons73) def replacement1675(p, m, b, n2, Pq, d, c, a, n, x): rubi.append(1675) return Dist(d**(m + S(-1)/2)*sqrt(d*x)/sqrt(x), Int(Pq*x**m*(a + b*x**n + c*x**(S(2)*n))**p, x), x) rule1675 = ReplacementRule(pattern1675, replacement1675) pattern1676 = Pattern(Integral(Pq_*(d_*x_)**m_*(a_ + x_**n_*WC('b', S(1)) + x_**WC('n2', S(1))*WC('c', S(1)))**p_, x_), cons2, cons3, cons7, cons27, cons5, cons46, cons64, cons226, cons489, cons951) def replacement1676(p, m, b, n2, Pq, d, c, a, n, x): rubi.append(1676) return Dist(d**(m + S(1)/2)*sqrt(x)/sqrt(d*x), Int(Pq*x**m*(a + b*x**n + c*x**(S(2)*n))**p, x), x) rule1676 = ReplacementRule(pattern1676, replacement1676) pattern1677 = Pattern(Integral(Pq_*(d_*x_)**m_*(a_ + x_**n_*WC('b', S(1)) + x_**WC('n2', S(1))*WC('c', S(1)))**p_, x_), cons2, cons3, cons7, cons27, cons21, cons5, cons46, cons64, cons226, cons489) def replacement1677(p, m, b, n2, Pq, d, c, a, n, x): rubi.append(1677) return Dist(x**(-m)*(d*x)**m, Int(Pq*x**m*(a + b*x**n + c*x**(S(2)*n))**p, x), x) rule1677 = ReplacementRule(pattern1677, replacement1677) pattern1678 = Pattern(Integral(Pq_*x_**WC('m', S(1))*(a_ + x_**n_*WC('b', S(1)) + x_**WC('n2', S(1))*WC('c', S(1)))**p_, x_), cons2, cons3, cons7, cons21, cons4, cons5, cons46, cons858, cons226, cons541, cons23) def replacement1678(p, m, b, n2, Pq, c, a, n, x): rubi.append(1678) return Dist(S(1)/(m + S(1)), Subst(Int((a + b*x**(n/(m + S(1))) + c*x**(S(2)*n/(m + S(1))))**p*ReplaceAll(SubstFor(x**n, Pq, x), Rule(x, x**(n/(m + S(1))))), x), x, x**(m + S(1))), x) rule1678 = ReplacementRule(pattern1678, replacement1678) pattern1679 = Pattern(Integral(Pq_*(d_*x_)**m_*(a_ + x_**n_*WC('b', S(1)) + x_**WC('n2', S(1))*WC('c', S(1)))**p_, x_), cons2, cons3, cons7, cons27, cons21, cons5, cons46, cons858, cons226, cons541, cons23) def replacement1679(p, m, b, n2, Pq, d, c, a, n, x): rubi.append(1679) return Dist(x**(-m)*(d*x)**m, Int(Pq*x**m*(a + b*x**n + c*x**(S(2)*n))**p, x), x) rule1679 = ReplacementRule(pattern1679, replacement1679) def With1680(m, b, n2, Pq, d, c, n, a, x): q = Rt(-S(4)*a*c + b**S(2), S(2)) rubi.append(1680) return Dist(S(2)*c/q, Int(Pq*(d*x)**m/(b + S(2)*c*x**n - q), x), x) - Dist(S(2)*c/q, Int(Pq*(d*x)**m/(b + S(2)*c*x**n + q), x), x) pattern1680 = Pattern(Integral(Pq_*(x_*WC('d', S(1)))**WC('m', S(1))/(a_ + x_**WC('n', S(1))*WC('b', S(1)) + x_**WC('n2', S(1))*WC('c', S(1))), x_), cons2, cons3, cons7, cons27, cons21, cons4, cons46, cons64, cons226) rule1680 = ReplacementRule(pattern1680, With1680) def With1681(b, n2, Pq, c, n, a, x): q = Rt(-S(4)*a*c + b**S(2), S(2)) rubi.append(1681) return Dist(S(2)*c/q, Int(Pq/(b + S(2)*c*x**n - q), x), x) - Dist(S(2)*c/q, Int(Pq/(b + S(2)*c*x**n + q), x), x) pattern1681 = Pattern(Integral(Pq_/(a_ + x_**WC('n', S(1))*WC('b', S(1)) + x_**WC('n2', S(1))*WC('c', S(1))), x_), cons2, cons3, cons7, cons4, cons46, cons64, cons226) rule1681 = ReplacementRule(pattern1681, With1681) pattern1682 = Pattern(Integral(Pq_*(x_*WC('d', S(1)))**WC('m', S(1))*(a_ + x_**WC('n', S(1))*WC('b', S(1)) + x_**WC('n2', S(1))*WC('c', S(1)))**p_, x_), cons2, cons3, cons7, cons27, cons21, cons4, cons46, cons64, cons702) def replacement1682(p, m, b, n2, Pq, d, c, n, a, x): rubi.append(1682) return Int(ExpandIntegrand(Pq*(d*x)**m*(a + b*x**n + c*x**(S(2)*n))**p, x), x) rule1682 = ReplacementRule(pattern1682, replacement1682) pattern1683 = Pattern(Integral(Pq_*(a_ + x_**WC('n', S(1))*WC('b', S(1)) + x_**WC('n2', S(1))*WC('c', S(1)))**p_, x_), cons2, cons3, cons7, cons4, cons46, cons64, cons702) def replacement1683(p, b, n2, Pq, c, n, a, x): rubi.append(1683) return Int(ExpandIntegrand(Pq*(a + b*x**n + c*x**(S(2)*n))**p, x), x) rule1683 = ReplacementRule(pattern1683, replacement1683) pattern1684 = Pattern(Integral(Pq_*(x_*WC('d', S(1)))**WC('m', S(1))*(a_ + x_**WC('n', S(1))*WC('b', S(1)) + x_**WC('n2', S(1))*WC('c', S(1)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons21, cons4, cons5, cons46, cons918) def replacement1684(p, m, b, n2, Pq, d, c, n, a, x): rubi.append(1684) return Int(Pq*(d*x)**m*(a + b*x**n + c*x**(S(2)*n))**p, x) rule1684 = ReplacementRule(pattern1684, replacement1684) pattern1685 = Pattern(Integral(Pq_*(a_ + x_**WC('n', S(1))*WC('b', S(1)) + x_**WC('n2', S(1))*WC('c', S(1)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons4, cons5, cons46, cons918) def replacement1685(p, b, n2, Pq, c, n, a, x): rubi.append(1685) return Int(Pq*(a + b*x**n + c*x**(S(2)*n))**p, x) rule1685 = ReplacementRule(pattern1685, replacement1685) pattern1686 = Pattern(Integral(Pq_*u_**WC('m', S(1))*(a_ + v_**n_*WC('b', S(1)) + v_**WC('n2', S(1))*WC('c', S(1)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons21, cons4, cons5, cons46, cons554, cons919) def replacement1686(v, p, u, m, b, n2, Pq, c, a, n, x): rubi.append(1686) return Dist(u**m*v**(-m)/Coefficient(v, x, S(1)), Subst(Int(x**m*(a + b*x**n + c*x**(S(2)*n))**p*SubstFor(v, Pq, x), x), x, v), x) rule1686 = ReplacementRule(pattern1686, replacement1686) pattern1687 = Pattern(Integral(Pq_*(a_ + v_**n_*WC('b', S(1)) + v_**WC('n2', S(1))*WC('c', S(1)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons4, cons5, cons46, cons552, cons919) def replacement1687(v, p, b, n2, Pq, c, a, n, x): rubi.append(1687) return Dist(S(1)/Coefficient(v, x, S(1)), Subst(Int((a + b*x**n + c*x**(S(2)*n))**p*SubstFor(v, Pq, x), x), x, v), x) rule1687 = ReplacementRule(pattern1687, replacement1687) pattern1688 = Pattern(Integral((x_**WC('j', S(1))*WC('a', S(1)) + x_**WC('n', S(1))*WC('b', S(1)))**p_, x_), cons2, cons3, cons796, cons4, cons5, cons147, cons952, cons953) def replacement1688(p, j, b, a, n, x): rubi.append(1688) return Simp(x**(-n + S(1))*(a*x**j + b*x**n)**(p + S(1))/(b*(-j + n)*(p + S(1))), x) rule1688 = ReplacementRule(pattern1688, replacement1688) pattern1689 = Pattern(Integral((x_**WC('j', S(1))*WC('a', S(1)) + x_**WC('n', S(1))*WC('b', S(1)))**p_, x_), cons2, cons3, cons796, cons4, cons147, cons952, cons954, cons13, cons137) def replacement1689(p, j, b, a, n, x): rubi.append(1689) return Dist((-j + n*p + n + S(1))/(a*(-j + n)*(p + S(1))), Int(x**(-j)*(a*x**j + b*x**n)**(p + S(1)), x), x) - Simp(x**(-j + S(1))*(a*x**j + b*x**n)**(p + S(1))/(a*(-j + n)*(p + S(1))), x) rule1689 = ReplacementRule(pattern1689, replacement1689) pattern1690 = Pattern(Integral((x_**WC('j', S(1))*WC('a', S(1)) + x_**WC('n', S(1))*WC('b', S(1)))**p_, x_), cons2, cons3, cons796, cons4, cons5, cons147, cons952, cons954, cons955) def replacement1690(p, j, b, a, n, x): rubi.append(1690) return -Dist(b*(-j + n*p + n + S(1))/(a*(j*p + S(1))), Int(x**(-j + n)*(a*x**j + b*x**n)**p, x), x) + Simp(x**(-j + S(1))*(a*x**j + b*x**n)**(p + S(1))/(a*(j*p + S(1))), x) rule1690 = ReplacementRule(pattern1690, replacement1690) pattern1691 = Pattern(Integral((x_**WC('j', S(1))*WC('a', S(1)) + x_**WC('n', S(1))*WC('b', S(1)))**p_, x_), cons2, cons3, cons147, cons956, cons957, cons163, cons958) def replacement1691(p, j, b, a, n, x): rubi.append(1691) return -Dist(b*p*(-j + n)/(j*p + S(1)), Int(x**n*(a*x**j + b*x**n)**(p + S(-1)), x), x) + Simp(x*(a*x**j + b*x**n)**p/(j*p + S(1)), x) rule1691 = ReplacementRule(pattern1691, replacement1691) pattern1692 = Pattern(Integral((x_**WC('j', S(1))*WC('a', S(1)) + x_**WC('n', S(1))*WC('b', S(1)))**p_, x_), cons2, cons3, cons147, cons956, cons957, cons163, cons959) def replacement1692(p, j, b, a, n, x): rubi.append(1692) return Dist(a*p*(-j + n)/(n*p + S(1)), Int(x**j*(a*x**j + b*x**n)**(p + S(-1)), x), x) + Simp(x*(a*x**j + b*x**n)**p/(n*p + S(1)), x) rule1692 = ReplacementRule(pattern1692, replacement1692) pattern1693 = Pattern(Integral((x_**WC('j', S(1))*WC('a', S(1)) + x_**WC('n', S(1))*WC('b', S(1)))**p_, x_), cons2, cons3, cons147, cons956, cons957, cons137, cons960) def replacement1693(p, j, b, a, n, x): rubi.append(1693) return -Dist((j*p + j - n + S(1))/(b*(-j + n)*(p + S(1))), Int(x**(-n)*(a*x**j + b*x**n)**(p + S(1)), x), x) + Simp(x**(-n + S(1))*(a*x**j + b*x**n)**(p + S(1))/(b*(-j + n)*(p + S(1))), x) rule1693 = ReplacementRule(pattern1693, replacement1693) pattern1694 = Pattern(Integral((x_**WC('j', S(1))*WC('a', S(1)) + x_**WC('n', S(1))*WC('b', S(1)))**p_, x_), cons2, cons3, cons147, cons956, cons957, cons137) def replacement1694(p, j, b, a, n, x): rubi.append(1694) return Dist((-j + n*p + n + S(1))/(a*(-j + n)*(p + S(1))), Int(x**(-j)*(a*x**j + b*x**n)**(p + S(1)), x), x) - Simp(x**(-j + S(1))*(a*x**j + b*x**n)**(p + S(1))/(a*(-j + n)*(p + S(1))), x) rule1694 = ReplacementRule(pattern1694, replacement1694) pattern1695 = Pattern(Integral((x_**WC('j', S(1))*WC('a', S(1)) + x_**WC('n', S(1))*WC('b', S(1)))**p_, x_), cons2, cons3, cons796, cons4, cons961, cons952, cons962) def replacement1695(p, j, b, a, n, x): rubi.append(1695) return Dist(a, Int(x**j*(a*x**j + b*x**n)**(p + S(-1)), x), x) + Simp(x*(a*x**j + b*x**n)**p/(p*(-j + n)), x) rule1695 = ReplacementRule(pattern1695, replacement1695) pattern1696 = Pattern(Integral(S(1)/sqrt(x_**S(2)*WC('a', S(1)) + x_**WC('n', S(1))*WC('b', S(1))), x_), cons2, cons3, cons4, cons963) def replacement1696(x, a, n, b): rubi.append(1696) return Dist(S(2)/(-n + S(2)), Subst(Int(S(1)/(-a*x**S(2) + S(1)), x), x, x/sqrt(a*x**S(2) + b*x**n)), x) rule1696 = ReplacementRule(pattern1696, replacement1696) pattern1697 = Pattern(Integral((x_**WC('j', S(1))*WC('a', S(1)) + x_**WC('n', S(1))*WC('b', S(1)))**p_, x_), cons2, cons3, cons796, cons4, cons719, cons952, cons962) def replacement1697(p, j, b, a, n, x): rubi.append(1697) return Dist((-j + n*p + n + S(1))/(a*(-j + n)*(p + S(1))), Int(x**(-j)*(a*x**j + b*x**n)**(p + S(1)), x), x) - Simp(x**(-j + S(1))*(a*x**j + b*x**n)**(p + S(1))/(a*(-j + n)*(p + S(1))), x) rule1697 = ReplacementRule(pattern1697, replacement1697) pattern1698 = Pattern(Integral(S(1)/sqrt(x_**WC('j', S(1))*WC('a', S(1)) + x_**WC('n', S(1))*WC('b', S(1))), x_), cons2, cons3, cons964, cons965) def replacement1698(j, b, a, n, x): rubi.append(1698) return -Dist(a*(-j + S(2)*n + S(-2))/(b*(n + S(-2))), Int(x**(j - n)/sqrt(a*x**j + b*x**n), x), x) + Simp(-S(2)*x**(-n + S(1))*sqrt(a*x**j + b*x**n)/(b*(n + S(-2))), x) rule1698 = ReplacementRule(pattern1698, replacement1698) pattern1699 = Pattern(Integral((x_**WC('j', S(1))*WC('a', S(1)) + x_**WC('n', S(1))*WC('b', S(1)))**p_, x_), cons2, cons3, cons796, cons4, cons5, cons147, cons952, cons966) def replacement1699(p, j, b, a, n, x): rubi.append(1699) return Dist(x**(-j*FracPart(p))*(a + b*x**(-j + n))**(-FracPart(p))*(a*x**j + b*x**n)**FracPart(p), Int(x**(j*p)*(a + b*x**(-j + n))**p, x), x) rule1699 = ReplacementRule(pattern1699, replacement1699) pattern1700 = Pattern(Integral((u_**WC('j', S(1))*WC('a', S(1)) + u_**WC('n', S(1))*WC('b', S(1)))**p_, x_), cons2, cons3, cons796, cons4, cons5, cons68, cons69) def replacement1700(p, u, j, b, a, n, x): rubi.append(1700) return Dist(S(1)/Coefficient(u, x, S(1)), Subst(Int((a*x**j + b*x**n)**p, x), x, u), x) rule1700 = ReplacementRule(pattern1700, replacement1700) pattern1701 = Pattern(Integral(x_**WC('m', S(1))*(x_**n_*WC('b', S(1)) + x_**WC('j', S(1))*WC('a', S(1)))**p_, x_), cons2, cons3, cons796, cons21, cons4, cons5, cons147, cons952, cons967, cons53) def replacement1701(p, j, m, b, a, n, x): rubi.append(1701) return Dist(S(1)/n, Subst(Int((a*x**(j/n) + b*x)**p, x), x, x**n), x) rule1701 = ReplacementRule(pattern1701, replacement1701) pattern1702 = Pattern(Integral((x_*WC('c', S(1)))**WC('m', S(1))*(x_**WC('j', S(1))*WC('a', S(1)) + x_**WC('n', S(1))*WC('b', S(1)))**p_, x_), cons2, cons3, cons7, cons796, cons21, cons4, cons5, cons147, cons952, cons968, cons969) def replacement1702(p, j, m, b, c, a, n, x): rubi.append(1702) return -Simp(c**(j + S(-1))*(c*x)**(-j + m + S(1))*(a*x**j + b*x**n)**(p + S(1))/(a*(-j + n)*(p + S(1))), x) rule1702 = ReplacementRule(pattern1702, replacement1702) pattern1703 = Pattern(Integral((x_*WC('c', S(1)))**WC('m', S(1))*(x_**WC('j', S(1))*WC('a', S(1)) + x_**WC('n', S(1))*WC('b', S(1)))**p_, x_), cons2, cons3, cons7, cons796, cons21, cons4, cons147, cons952, cons970, cons13, cons137, cons969) def replacement1703(p, j, m, b, c, a, n, x): rubi.append(1703) return Dist(c**j*(-j + m + n*p + n + S(1))/(a*(-j + n)*(p + S(1))), Int((c*x)**(-j + m)*(a*x**j + b*x**n)**(p + S(1)), x), x) - Simp(c**(j + S(-1))*(c*x)**(-j + m + S(1))*(a*x**j + b*x**n)**(p + S(1))/(a*(-j + n)*(p + S(1))), x) rule1703 = ReplacementRule(pattern1703, replacement1703) pattern1704 = Pattern(Integral((x_*WC('c', S(1)))**WC('m', S(1))*(x_**WC('j', S(1))*WC('a', S(1)) + x_**WC('n', S(1))*WC('b', S(1)))**p_, x_), cons2, cons3, cons7, cons796, cons21, cons4, cons5, cons147, cons952, cons970, cons971, cons972) def replacement1704(p, j, m, b, c, a, n, x): rubi.append(1704) return -Dist(b*c**(j - n)*(-j + m + n*p + n + S(1))/(a*(j*p + m + S(1))), Int((c*x)**(-j + m + n)*(a*x**j + b*x**n)**p, x), x) + Simp(c**(j + S(-1))*(c*x)**(-j + m + S(1))*(a*x**j + b*x**n)**(p + S(1))/(a*(j*p + m + S(1))), x) rule1704 = ReplacementRule(pattern1704, replacement1704) pattern1705 = Pattern(Integral((c_*x_)**WC('m', S(1))*(x_**WC('j', S(1))*WC('a', S(1)) + x_**WC('n', S(1))*WC('b', S(1)))**p_, x_), cons2, cons3, cons7, cons796, cons21, cons4, cons5, cons147, cons952, cons970) def replacement1705(p, j, m, b, a, n, c, x): rubi.append(1705) return Dist(c**IntPart(m)*x**(-FracPart(m))*(c*x)**FracPart(m), Int(x**m*(a*x**j + b*x**n)**p, x), x) rule1705 = ReplacementRule(pattern1705, replacement1705) pattern1706 = Pattern(Integral(x_**WC('m', S(1))*(x_**n_*WC('b', S(1)) + x_**WC('j', S(1))*WC('a', S(1)))**p_, x_), cons2, cons3, cons796, cons21, cons4, cons5, cons147, cons952, cons967, cons500, cons973) def replacement1706(p, j, m, b, a, n, x): rubi.append(1706) return Dist(S(1)/n, Subst(Int(x**(S(-1) + (m + S(1))/n)*(a*x**(j/n) + b*x)**p, x), x, x**n), x) rule1706 = ReplacementRule(pattern1706, replacement1706) pattern1707 = Pattern(Integral((c_*x_)**WC('m', S(1))*(x_**n_*WC('b', S(1)) + x_**WC('j', S(1))*WC('a', S(1)))**p_, x_), cons2, cons3, cons7, cons796, cons21, cons4, cons5, cons147, cons952, cons967, cons500, cons973) def replacement1707(p, j, m, b, c, a, n, x): rubi.append(1707) return Dist(c**IntPart(m)*x**(-FracPart(m))*(c*x)**FracPart(m), Int(x**m*(a*x**j + b*x**n)**p, x), x) rule1707 = ReplacementRule(pattern1707, replacement1707) pattern1708 = Pattern(Integral((x_*WC('c', S(1)))**m_*(x_**WC('j', S(1))*WC('a', S(1)) + x_**WC('n', S(1))*WC('b', S(1)))**p_, x_), cons2, cons3, cons7, cons147, cons974, cons957, cons972, cons163, cons975) def replacement1708(p, j, m, b, c, n, a, x): rubi.append(1708) return -Dist(b*c**(-n)*p*(-j + n)/(j*p + m + S(1)), Int((c*x)**(m + n)*(a*x**j + b*x**n)**(p + S(-1)), x), x) + Simp((c*x)**(m + S(1))*(a*x**j + b*x**n)**p/(c*(j*p + m + S(1))), x) rule1708 = ReplacementRule(pattern1708, replacement1708) pattern1709 = Pattern(Integral((x_*WC('c', S(1)))**WC('m', S(1))*(x_**WC('j', S(1))*WC('a', S(1)) + x_**WC('n', S(1))*WC('b', S(1)))**p_, x_), cons2, cons3, cons7, cons21, cons147, cons956, cons957, cons972, cons163, cons512) def replacement1709(p, j, m, b, c, a, n, x): rubi.append(1709) return Dist(a*c**(-j)*p*(-j + n)/(m + n*p + S(1)), Int((c*x)**(j + m)*(a*x**j + b*x**n)**(p + S(-1)), x), x) + Simp((c*x)**(m + S(1))*(a*x**j + b*x**n)**p/(c*(m + n*p + S(1))), x) rule1709 = ReplacementRule(pattern1709, replacement1709) pattern1710 = Pattern(Integral((x_*WC('c', S(1)))**WC('m', S(1))*(x_**WC('j', S(1))*WC('a', S(1)) + x_**WC('n', S(1))*WC('b', S(1)))**p_, x_), cons2, cons3, cons7, cons147, cons974, cons957, cons972, cons137, cons976) def replacement1710(p, j, m, b, c, a, n, x): rubi.append(1710) return -Dist(c**n*(j*p + j + m - n + S(1))/(b*(-j + n)*(p + S(1))), Int((c*x)**(m - n)*(a*x**j + b*x**n)**(p + S(1)), x), x) + Simp(c**(n + S(-1))*(c*x)**(m - n + S(1))*(a*x**j + b*x**n)**(p + S(1))/(b*(-j + n)*(p + S(1))), x) rule1710 = ReplacementRule(pattern1710, replacement1710) pattern1711 = Pattern(Integral((x_*WC('c', S(1)))**WC('m', S(1))*(x_**WC('j', S(1))*WC('a', S(1)) + x_**WC('n', S(1))*WC('b', S(1)))**p_, x_), cons2, cons3, cons7, cons21, cons147, cons956, cons957, cons972, cons137) def replacement1711(p, j, m, b, c, a, n, x): rubi.append(1711) return Dist(c**j*(-j + m + n*p + n + S(1))/(a*(-j + n)*(p + S(1))), Int((c*x)**(-j + m)*(a*x**j + b*x**n)**(p + S(1)), x), x) - Simp(c**(j + S(-1))*(c*x)**(-j + m + S(1))*(a*x**j + b*x**n)**(p + S(1))/(a*(-j + n)*(p + S(1))), x) rule1711 = ReplacementRule(pattern1711, replacement1711) pattern1712 = Pattern(Integral((x_*WC('c', S(1)))**WC('m', S(1))*(x_**WC('j', S(1))*WC('a', S(1)) + x_**WC('n', S(1))*WC('b', S(1)))**p_, x_), cons2, cons3, cons7, cons21, cons5, cons147, cons964, cons957, cons972, cons977, cons512) def replacement1712(p, j, m, b, c, a, n, x): rubi.append(1712) return -Dist(a*c**(-j + n)*(j*p + j + m - n + S(1))/(b*(m + n*p + S(1))), Int((c*x)**(j + m - n)*(a*x**j + b*x**n)**p, x), x) + Simp(c**(n + S(-1))*(c*x)**(m - n + S(1))*(a*x**j + b*x**n)**(p + S(1))/(b*(m + n*p + S(1))), x) rule1712 = ReplacementRule(pattern1712, replacement1712) pattern1713 = Pattern(Integral((x_*WC('c', S(1)))**WC('m', S(1))*(x_**WC('j', S(1))*WC('a', S(1)) + x_**WC('n', S(1))*WC('b', S(1)))**p_, x_), cons2, cons3, cons7, cons21, cons5, cons147, cons964, cons957, cons972, cons978) def replacement1713(p, j, m, b, c, a, n, x): rubi.append(1713) return -Dist(b*c**(j - n)*(-j + m + n*p + n + S(1))/(a*(j*p + m + S(1))), Int((c*x)**(-j + m + n)*(a*x**j + b*x**n)**p, x), x) + Simp(c**(j + S(-1))*(c*x)**(-j + m + S(1))*(a*x**j + b*x**n)**(p + S(1))/(a*(j*p + m + S(1))), x) rule1713 = ReplacementRule(pattern1713, replacement1713) pattern1714 = Pattern(Integral(x_**WC('m', S(1))*(x_**n_*WC('b', S(1)) + x_**WC('j', S(1))*WC('a', S(1)))**p_, x_), cons2, cons3, cons796, cons21, cons4, cons5, cons147, cons952, cons967, cons66, cons541, cons23) def replacement1714(p, j, m, b, a, n, x): rubi.append(1714) return Dist(S(1)/(m + S(1)), Subst(Int((a*x**(j/(m + S(1))) + b*x**(n/(m + S(1))))**p, x), x, x**(m + S(1))), x) rule1714 = ReplacementRule(pattern1714, replacement1714) pattern1715 = Pattern(Integral((c_*x_)**WC('m', S(1))*(x_**n_*WC('b', S(1)) + x_**WC('j', S(1))*WC('a', S(1)))**p_, x_), cons2, cons3, cons7, cons796, cons21, cons4, cons5, cons147, cons952, cons967, cons66, cons541, cons23) def replacement1715(p, j, m, b, c, a, n, x): rubi.append(1715) return Dist(c**IntPart(m)*x**(-FracPart(m))*(c*x)**FracPart(m), Int(x**m*(a*x**j + b*x**n)**p, x), x) rule1715 = ReplacementRule(pattern1715, replacement1715) pattern1716 = Pattern(Integral((x_*WC('c', S(1)))**WC('m', S(1))*(x_**WC('j', S(1))*WC('a', S(1)) + x_**WC('n', S(1))*WC('b', S(1)))**p_, x_), cons2, cons3, cons7, cons796, cons21, cons4, cons961, cons952, cons979, cons969) def replacement1716(p, j, m, b, c, a, n, x): rubi.append(1716) return Dist(a*c**(-j), Int((c*x)**(j + m)*(a*x**j + b*x**n)**(p + S(-1)), x), x) + Simp((c*x)**(m + S(1))*(a*x**j + b*x**n)**p/(c*p*(-j + n)), x) rule1716 = ReplacementRule(pattern1716, replacement1716) pattern1717 = Pattern(Integral(x_**WC('m', S(1))/sqrt(x_**WC('j', S(1))*WC('a', S(1)) + x_**WC('n', S(1))*WC('b', S(1))), x_), cons2, cons3, cons796, cons4, cons980, cons952) def replacement1717(j, m, b, a, n, x): rubi.append(1717) return Dist(-S(2)/(-j + n), Subst(Int(S(1)/(-a*x**S(2) + S(1)), x), x, x**(j/S(2))/sqrt(a*x**j + b*x**n)), x) rule1717 = ReplacementRule(pattern1717, replacement1717) pattern1718 = Pattern(Integral((x_*WC('c', S(1)))**WC('m', S(1))*(x_**WC('j', S(1))*WC('a', S(1)) + x_**WC('n', S(1))*WC('b', S(1)))**p_, x_), cons2, cons3, cons7, cons796, cons21, cons4, cons719, cons952, cons979, cons969) def replacement1718(p, j, m, b, c, a, n, x): rubi.append(1718) return Dist(c**j*(-j + m + n*p + n + S(1))/(a*(-j + n)*(p + S(1))), Int((c*x)**(-j + m)*(a*x**j + b*x**n)**(p + S(1)), x), x) - Simp(c**(j + S(-1))*(c*x)**(-j + m + S(1))*(a*x**j + b*x**n)**(p + S(1))/(a*(-j + n)*(p + S(1))), x) rule1718 = ReplacementRule(pattern1718, replacement1718) pattern1719 = Pattern(Integral((c_*x_)**WC('m', S(1))*(x_**n_*WC('b', S(1)) + x_**WC('j', S(1))*WC('a', S(1)))**p_, x_), cons2, cons3, cons7, cons796, cons21, cons4, cons5, cons667, cons952, cons979) def replacement1719(p, j, m, b, c, a, n, x): rubi.append(1719) return Dist(c**IntPart(m)*x**(-FracPart(m))*(c*x)**FracPart(m), Int(x**m*(a*x**j + b*x**n)**p, x), x) rule1719 = ReplacementRule(pattern1719, replacement1719) pattern1720 = Pattern(Integral((x_*WC('c', S(1)))**WC('m', S(1))*(x_**WC('j', S(1))*WC('a', S(1)) + x_**WC('n', S(1))*WC('b', S(1)))**p_, x_), cons2, cons3, cons7, cons796, cons21, cons4, cons5, cons147, cons952, cons966) def replacement1720(p, j, m, b, c, a, n, x): rubi.append(1720) return Dist(c**IntPart(m)*x**(-j*FracPart(p) - FracPart(m))*(c*x)**FracPart(m)*(a + b*x**(-j + n))**(-FracPart(p))*(a*x**j + b*x**n)**FracPart(p), Int(x**(j*p + m)*(a + b*x**(-j + n))**p, x), x) rule1720 = ReplacementRule(pattern1720, replacement1720) pattern1721 = Pattern(Integral(u_**WC('m', S(1))*(v_**WC('j', S(1))*WC('a', S(1)) + v_**WC('n', S(1))*WC('b', S(1)))**WC('p', S(1)), x_), cons2, cons3, cons796, cons21, cons4, cons5, cons554) def replacement1721(v, p, u, j, m, b, a, n, x): rubi.append(1721) return Dist(u**m*v**(-m)/Coefficient(v, x, S(1)), Subst(Int(x**m*(a*x**j + b*x**n)**p, x), x, v), x) rule1721 = ReplacementRule(pattern1721, replacement1721) pattern1722 = Pattern(Integral(x_**WC('m', S(1))*(c_ + x_**n_*WC('d', S(1)))**WC('q', S(1))*(x_**j_*WC('a', S(1)) + x_**WC('k', S(1))*WC('b', S(1)))**p_, x_), cons2, cons3, cons7, cons27, cons796, cons797, cons21, cons4, cons5, cons50, cons147, cons981, cons967, cons982, cons500, cons973) def replacement1722(p, j, k, m, b, d, a, c, n, x, q): rubi.append(1722) return Dist(S(1)/n, Subst(Int(x**(S(-1) + (m + S(1))/n)*(c + d*x)**q*(a*x**(j/n) + b*x**(k/n))**p, x), x, x**n), x) rule1722 = ReplacementRule(pattern1722, replacement1722) pattern1723 = Pattern(Integral((e_*x_)**WC('m', S(1))*(c_ + x_**WC('n', S(1))*WC('d', S(1)))**WC('q', S(1))*(x_**j_*WC('a', S(1)) + x_**WC('k', S(1))*WC('b', S(1)))**p_, x_), cons2, cons3, cons7, cons27, cons48, cons796, cons797, cons21, cons4, cons5, cons50, cons147, cons981, cons967, cons982, cons500, cons973) def replacement1723(p, j, k, m, b, d, a, n, c, x, q, e): rubi.append(1723) return Dist(e**IntPart(m)*x**(-FracPart(m))*(e*x)**FracPart(m), Int(x**m*(c + d*x**n)**q*(a*x**j + b*x**k)**p, x), x) rule1723 = ReplacementRule(pattern1723, replacement1723) pattern1724 = Pattern(Integral((x_*WC('e', S(1)))**WC('m', S(1))*(c_ + x_**WC('n', S(1))*WC('d', S(1)))*(x_**WC('jn', S(1))*WC('b', S(1)) + x_**WC('j', S(1))*WC('a', S(1)))**p_, x_), cons2, cons3, cons7, cons27, cons48, cons796, cons21, cons4, cons5, cons983, cons147, cons71, cons984, cons985, cons971) def replacement1724(p, j, m, b, d, a, n, jn, c, x, e): rubi.append(1724) return Simp(c*e**(j + S(-1))*(e*x)**(-j + m + S(1))*(a*x**j + b*x**(j + n))**(p + S(1))/(a*(j*p + m + S(1))), x) rule1724 = ReplacementRule(pattern1724, replacement1724) pattern1725 = Pattern(Integral((x_*WC('e', S(1)))**WC('m', S(1))*(c_ + x_**WC('n', S(1))*WC('d', S(1)))*(x_**WC('jn', S(1))*WC('b', S(1)) + x_**WC('j', S(1))*WC('a', S(1)))**p_, x_), cons2, cons3, cons7, cons27, cons48, cons796, cons21, cons4, cons983, cons147, cons71, cons986, cons137, cons987, cons988) def replacement1725(p, j, m, b, d, a, n, jn, c, x, e): rubi.append(1725) return -Dist(e**j*(a*d*(j*p + m + S(1)) - b*c*(m + n + p*(j + n) + S(1)))/(a*b*n*(p + S(1))), Int((e*x)**(-j + m)*(a*x**j + b*x**(j + n))**(p + S(1)), x), x) - Simp(e**(j + S(-1))*(e*x)**(-j + m + S(1))*(-a*d + b*c)*(a*x**j + b*x**(j + n))**(p + S(1))/(a*b*n*(p + S(1))), x) rule1725 = ReplacementRule(pattern1725, replacement1725) pattern1726 = Pattern(Integral((x_*WC('e', S(1)))**WC('m', S(1))*(c_ + x_**WC('n', S(1))*WC('d', S(1)))*(x_**WC('jn', S(1))*WC('b', S(1)) + x_**WC('j', S(1))*WC('a', S(1)))**p_, x_), cons2, cons3, cons7, cons27, cons48, cons796, cons5, cons983, cons147, cons71, cons93, cons88, cons989, cons990, cons971, cons991) def replacement1726(p, j, m, b, d, a, n, jn, c, x, e): rubi.append(1726) return Dist(e**(-n)*(a*d*(j*p + m + S(1)) - b*c*(m + n + p*(j + n) + S(1)))/(a*(j*p + m + S(1))), Int((e*x)**(m + n)*(a*x**j + b*x**(j + n))**p, x), x) + Simp(c*e**(j + S(-1))*(e*x)**(-j + m + S(1))*(a*x**j + b*x**(j + n))**(p + S(1))/(a*(j*p + m + S(1))), x) rule1726 = ReplacementRule(pattern1726, replacement1726) pattern1727 = Pattern(Integral((x_*WC('e', S(1)))**WC('m', S(1))*(c_ + x_**WC('n', S(1))*WC('d', S(1)))*(x_**WC('jn', S(1))*WC('b', S(1)) + x_**WC('j', S(1))*WC('a', S(1)))**p_, x_), cons2, cons3, cons7, cons27, cons48, cons796, cons21, cons4, cons5, cons983, cons147, cons71, cons992, cons988) def replacement1727(p, j, m, b, d, a, n, jn, c, x, e): rubi.append(1727) return -Dist((a*d*(j*p + m + S(1)) - b*c*(m + n + p*(j + n) + S(1)))/(b*(m + n + p*(j + n) + S(1))), Int((e*x)**m*(a*x**j + b*x**(j + n))**p, x), x) + Simp(d*e**(j + S(-1))*(e*x)**(-j + m + S(1))*(a*x**j + b*x**(j + n))**(p + S(1))/(b*(m + n + p*(j + n) + S(1))), x) rule1727 = ReplacementRule(pattern1727, replacement1727) pattern1728 = Pattern(Integral(x_**WC('m', S(1))*(c_ + x_**WC('n', S(1))*WC('d', S(1)))**WC('q', S(1))*(x_**j_*WC('a', S(1)) + x_**WC('k', S(1))*WC('b', S(1)))**p_, x_), cons2, cons3, cons7, cons27, cons796, cons797, cons21, cons4, cons5, cons50, cons147, cons981, cons967, cons982, cons66, cons541, cons23) def replacement1728(p, j, k, m, b, d, a, n, c, x, q): rubi.append(1728) return Dist(S(1)/(m + S(1)), Subst(Int((c + d*x**(n/(m + S(1))))**q*(a*x**(j/(m + S(1))) + b*x**(k/(m + S(1))))**p, x), x, x**(m + S(1))), x) rule1728 = ReplacementRule(pattern1728, replacement1728) pattern1729 = Pattern(Integral((e_*x_)**WC('m', S(1))*(c_ + x_**WC('n', S(1))*WC('d', S(1)))**WC('q', S(1))*(x_**j_*WC('a', S(1)) + x_**WC('k', S(1))*WC('b', S(1)))**p_, x_), cons2, cons3, cons7, cons27, cons48, cons796, cons797, cons21, cons4, cons5, cons50, cons147, cons981, cons967, cons982, cons66, cons541, cons23) def replacement1729(p, j, k, m, b, d, a, n, c, x, q, e): rubi.append(1729) return Dist(e**IntPart(m)*x**(-FracPart(m))*(e*x)**FracPart(m), Int(x**m*(c + d*x**n)**q*(a*x**j + b*x**k)**p, x), x) rule1729 = ReplacementRule(pattern1729, replacement1729) pattern1730 = Pattern(Integral((x_*WC('e', S(1)))**WC('m', S(1))*(c_ + x_**WC('n', S(1))*WC('d', S(1)))**WC('q', S(1))*(x_**WC('jn', S(1))*WC('b', S(1)) + x_**WC('j', S(1))*WC('a', S(1)))**p_, x_), cons2, cons3, cons7, cons27, cons48, cons796, cons21, cons4, cons5, cons50, cons983, cons147, cons71, cons993) def replacement1730(p, j, m, b, d, a, n, jn, c, x, q, e): rubi.append(1730) return Dist(e**IntPart(m)*x**(-j*FracPart(p) - FracPart(m))*(e*x)**FracPart(m)*(a + b*x**n)**(-FracPart(p))*(a*x**j + b*x**(j + n))**FracPart(p), Int(x**(j*p + m)*(a + b*x**n)**p*(c + d*x**n)**q, x), x) rule1730 = ReplacementRule(pattern1730, replacement1730) def With1731(p, j, b, Pq, a, n, x): d = Denominator(n) rubi.append(1731) return Dist(d, Subst(Int(x**(d + S(-1))*(a*x**(d*j) + b*x**(d*n))**p*ReplaceAll(SubstFor(x**n, Pq, x), Rule(x, x**(d*n))), x), x, x**(S(1)/d)), x) pattern1731 = Pattern(Integral(Pq_*(x_**n_*WC('b', S(1)) + x_**WC('j', S(1))*WC('a', S(1)))**p_, x_), cons2, cons3, cons796, cons4, cons5, cons858, cons147, cons952, cons964, cons967, cons994) rule1731 = ReplacementRule(pattern1731, With1731) pattern1732 = Pattern(Integral(Pq_*x_**WC('m', S(1))*(x_**n_*WC('b', S(1)) + x_**WC('j', S(1))*WC('a', S(1)))**p_, x_), cons2, cons3, cons796, cons21, cons4, cons5, cons858, cons147, cons952, cons967, cons500) def replacement1732(p, j, m, b, Pq, a, n, x): rubi.append(1732) return Dist(S(1)/n, Subst(Int(x**(S(-1) + (m + S(1))/n)*(a*x**(j/n) + b*x)**p*SubstFor(x**n, Pq, x), x), x, x**n), x) rule1732 = ReplacementRule(pattern1732, replacement1732) pattern1733 = Pattern(Integral(Pq_*(c_*x_)**WC('m', S(1))*(x_**n_*WC('b', S(1)) + x_**WC('j', S(1))*WC('a', S(1)))**p_, x_), cons2, cons3, cons7, cons796, cons4, cons5, cons858, cons147, cons952, cons967, cons500, cons31, cons995) def replacement1733(p, j, m, b, Pq, a, c, n, x): rubi.append(1733) return Dist(c**(Quotient(m, sign(m))*sign(m))*x**(-Mod(m, sign(m)))*(c*x)**Mod(m, sign(m)), Int(Pq*x**m*(a*x**j + b*x**n)**p, x), x) rule1733 = ReplacementRule(pattern1733, replacement1733) pattern1734 = Pattern(Integral(Pq_*(c_*x_)**WC('m', S(1))*(x_**n_*WC('b', S(1)) + x_**WC('j', S(1))*WC('a', S(1)))**p_, x_), cons2, cons3, cons7, cons796, cons21, cons4, cons5, cons858, cons147, cons952, cons967, cons500) def replacement1734(p, j, m, b, Pq, a, c, n, x): rubi.append(1734) return Dist(x**(-m)*(c*x)**m, Int(Pq*x**m*(a*x**j + b*x**n)**p, x), x) rule1734 = ReplacementRule(pattern1734, replacement1734) def With1735(p, j, m, b, Pq, a, n, x): if isinstance(x, (int, Integer, float, Float)): return False g = GCD(m + S(1), n) if Unequal(g, S(1)): return True return False pattern1735 = Pattern(Integral(Pq_*x_**WC('m', S(1))*(x_**n_*WC('b', S(1)) + x_**WC('j', S(1))*WC('a', S(1)))**p_, x_), cons2, cons3, cons5, cons858, cons147, cons996, cons17, CustomConstraint(With1735)) def replacement1735(p, j, m, b, Pq, a, n, x): g = GCD(m + S(1), n) rubi.append(1735) return Dist(S(1)/g, Subst(Int(x**(S(-1) + (m + S(1))/g)*(a*x**(j/g) + b*x**(n/g))**p*ReplaceAll(Pq, Rule(x, x**(S(1)/g))), x), x, x**g), x) rule1735 = ReplacementRule(pattern1735, replacement1735) def With1736(p, j, m, b, Pq, c, a, n, x): if isinstance(x, (int, Integer, float, Float)): return False q = Expon(Pq, x) Pqq = Coeff(Pq, x, q) if And(Greater(q, n + S(-1)), Unequal(m + n*p + q + S(1), S(0)), Or(IntegerQ(S(2)*p), IntegerQ(p + (q + S(1))/(S(2)*n)))): return True return False pattern1736 = Pattern(Integral(Pq_*(x_*WC('c', S(1)))**WC('m', S(1))*(x_**n_*WC('b', S(1)) + x_**WC('j', S(1))*WC('a', S(1)))**p_, x_), cons2, cons3, cons7, cons21, cons5, cons64, cons147, cons997, cons998, CustomConstraint(With1736)) def replacement1736(p, j, m, b, Pq, c, a, n, x): q = Expon(Pq, x) Pqq = Coeff(Pq, x, q) rubi.append(1736) return Int((c*x)**m*(a*x**j + b*x**n)**p*ExpandToSum(Pq - Pqq*a*x**(-n + q)*(m - n + q + 1)/(b*(m + n*p + q + 1)) - Pqq*x**q, x), x) + Simp(Pqq*c**(n - q - 1)*(c*x)**(m - n + q + 1)*(a*x**j + b*x**n)**(p + 1)/(b*(m + n*p + q + 1)), x) rule1736 = ReplacementRule(pattern1736, replacement1736) pattern1737 = Pattern(Integral(Pq_*x_**WC('m', S(1))*(x_**n_*WC('b', S(1)) + x_**WC('j', S(1))*WC('a', S(1)))**p_, x_), cons2, cons3, cons796, cons21, cons4, cons5, cons858, cons147, cons952, cons967, cons541, cons23) def replacement1737(p, j, m, b, Pq, a, n, x): rubi.append(1737) return Dist(S(1)/(m + S(1)), Subst(Int((a*x**(j/(m + S(1))) + b*x**(n/(m + S(1))))**p*ReplaceAll(SubstFor(x**n, Pq, x), Rule(x, x**(n/(m + S(1))))), x), x, x**(m + S(1))), x) rule1737 = ReplacementRule(pattern1737, replacement1737) pattern1738 = Pattern(Integral(Pq_*(c_*x_)**m_*(x_**n_*WC('b', S(1)) + x_**WC('j', S(1))*WC('a', S(1)))**p_, x_), cons2, cons3, cons7, cons796, cons4, cons5, cons858, cons147, cons952, cons967, cons541, cons23, cons31, cons995) def replacement1738(p, j, m, b, Pq, c, a, n, x): rubi.append(1738) return Dist(c**(Quotient(m, sign(m))*sign(m))*x**(-Mod(m, sign(m)))*(c*x)**Mod(m, sign(m)), Int(Pq*x**m*(a*x**j + b*x**n)**p, x), x) rule1738 = ReplacementRule(pattern1738, replacement1738) pattern1739 = Pattern(Integral(Pq_*(c_*x_)**m_*(x_**n_*WC('b', S(1)) + x_**WC('j', S(1))*WC('a', S(1)))**p_, x_), cons2, cons3, cons7, cons796, cons21, cons4, cons5, cons858, cons147, cons952, cons967, cons541, cons23) def replacement1739(p, j, m, b, Pq, c, a, n, x): rubi.append(1739) return Dist(x**(-m)*(c*x)**m, Int(Pq*x**m*(a*x**j + b*x**n)**p, x), x) rule1739 = ReplacementRule(pattern1739, replacement1739) pattern1740 = Pattern(Integral(Pq_*(x_*WC('c', S(1)))**WC('m', S(1))*(x_**n_*WC('b', S(1)) + x_**WC('j', S(1))*WC('a', S(1)))**p_, x_), cons2, cons3, cons7, cons796, cons21, cons4, cons5, cons918, cons147, cons952) def replacement1740(p, j, m, b, Pq, c, a, n, x): rubi.append(1740) return Int(ExpandIntegrand(Pq*(c*x)**m*(a*x**j + b*x**n)**p, x), x) rule1740 = ReplacementRule(pattern1740, replacement1740) pattern1741 = Pattern(Integral(Pq_*(x_**n_*WC('b', S(1)) + x_**WC('j', S(1))*WC('a', S(1)))**p_, x_), cons2, cons3, cons796, cons4, cons5, cons918, cons147, cons952) def replacement1741(p, j, b, Pq, a, n, x): rubi.append(1741) return Int(ExpandIntegrand(Pq*(a*x**j + b*x**n)**p, x), x) rule1741 = ReplacementRule(pattern1741, replacement1741) pattern1742 = Pattern(Integral((x_**S(3)*WC('d', S(1)) + x_*WC('b', S(1)) + WC('a', S(0)))**p_, x_), cons2, cons3, cons27, cons38, cons999) def replacement1742(p, b, d, a, x): rubi.append(1742) return Dist(S(3)**(-S(3)*p)*a**(-S(2)*p), Int((S(3)*a - b*x)**p*(S(3)*a + S(2)*b*x)**(S(2)*p), x), x) rule1742 = ReplacementRule(pattern1742, replacement1742) pattern1743 = Pattern(Integral((x_**S(3)*WC('d', S(1)) + x_*WC('b', S(1)) + WC('a', S(0)))**p_, x_), cons2, cons3, cons27, cons128, cons1000) def replacement1743(p, b, d, a, x): rubi.append(1743) return Int(ExpandToSum((a + b*x + d*x**S(3))**p, x), x) rule1743 = ReplacementRule(pattern1743, replacement1743) def With1744(p, b, d, a, x): if isinstance(x, (int, Integer, float, Float)): return False u = Factor(a + b*x + d*x**S(3)) if ProductQ(NonfreeFactors(u, x)): return True return False pattern1744 = Pattern(Integral((x_**S(3)*WC('d', S(1)) + x_*WC('b', S(1)) + WC('a', S(0)))**p_, x_), cons2, cons3, cons27, cons63, cons1000, CustomConstraint(With1744)) def replacement1744(p, b, d, a, x): u = Factor(a + b*x + d*x**S(3)) rubi.append(1744) return Dist(FreeFactors(u, x)**p, Int(DistributeDegree(NonfreeFactors(u, x), p), x), x) rule1744 = ReplacementRule(pattern1744, replacement1744) def With1745(p, b, d, a, x): r = Rt(-S(27)*a*d**S(2) + S(3)*sqrt(S(3))*d*sqrt(S(27)*a**S(2)*d**S(2) + S(4)*b**S(3)*d), S(3)) rubi.append(1745) return Dist(S(3)**(-S(3)*p)*d**(-S(2)*p), Int((-S(3)*d*x + S(2)**(S(1)/3)*(S(6)*b*d*(S(1) - sqrt(S(3))*I) - S(2)**(S(1)/3)*r**S(2)*(S(1) + sqrt(S(3))*I))/(S(4)*r))**p*(-S(3)*d*x + S(2)**(S(1)/3)*(S(6)*b*d*(S(1) + sqrt(S(3))*I) - S(2)**(S(1)/3)*r**S(2)*(S(1) - sqrt(S(3))*I))/(S(4)*r))**p*(S(3)*d*x + S(2)**(S(1)/3)*(S(6)*b*d - S(2)**(S(1)/3)*r**S(2))/(S(2)*r))**p, x), x) pattern1745 = Pattern(Integral((x_**S(3)*WC('d', S(1)) + x_*WC('b', S(1)) + WC('a', S(0)))**p_, x_), cons2, cons3, cons27, cons63, cons1000) rule1745 = ReplacementRule(pattern1745, With1745) pattern1746 = Pattern(Integral((x_**S(3)*WC('d', S(1)) + x_*WC('b', S(1)) + WC('a', S(0)))**p_, x_), cons2, cons3, cons27, cons5, cons147, cons999) def replacement1746(p, b, d, a, x): rubi.append(1746) return Dist((S(3)*a - b*x)**(-p)*(S(3)*a + S(2)*b*x)**(-S(2)*p)*(a + b*x + d*x**S(3))**p, Int((S(3)*a - b*x)**p*(S(3)*a + S(2)*b*x)**(S(2)*p), x), x) rule1746 = ReplacementRule(pattern1746, replacement1746) def With1747(p, b, d, a, x): if isinstance(x, (int, Integer, float, Float)): return False u = NonfreeFactors(Factor(a + b*x + d*x**S(3)), x) if ProductQ(u): return True return False pattern1747 = Pattern(Integral((x_**S(3)*WC('d', S(1)) + x_*WC('b', S(1)) + WC('a', S(0)))**p_, x_), cons2, cons3, cons27, cons5, cons147, cons1000, CustomConstraint(With1747)) def replacement1747(p, b, d, a, x): u = NonfreeFactors(Factor(a + b*x + d*x**S(3)), x) rubi.append(1747) return Dist((a + b*x + d*x**S(3))**p/DistributeDegree(u, p), Int(DistributeDegree(u, p), x), x) rule1747 = ReplacementRule(pattern1747, replacement1747) def With1748(p, b, d, a, x): r = Rt(-S(27)*a*d**S(2) + S(3)*sqrt(S(3))*d*sqrt(S(27)*a**S(2)*d**S(2) + S(4)*b**S(3)*d), S(3)) rubi.append(1748) return Dist((-S(3)*d*x + S(2)**(S(1)/3)*(S(6)*b*d*(S(1) - sqrt(S(3))*I) - S(2)**(S(1)/3)*r**S(2)*(S(1) + sqrt(S(3))*I))/(S(4)*r))**(-p)*(-S(3)*d*x + S(2)**(S(1)/3)*(S(6)*b*d*(S(1) + sqrt(S(3))*I) - S(2)**(S(1)/3)*r**S(2)*(S(1) - sqrt(S(3))*I))/(S(4)*r))**(-p)*(S(3)*d*x + S(2)**(S(1)/3)*(S(6)*b*d - S(2)**(S(1)/3)*r**S(2))/(S(2)*r))**(-p)*(a + b*x + d*x**S(3))**p, Int((-S(3)*d*x + S(2)**(S(1)/3)*(S(6)*b*d*(S(1) - sqrt(S(3))*I) - S(2)**(S(1)/3)*r**S(2)*(S(1) + sqrt(S(3))*I))/(S(4)*r))**p*(-S(3)*d*x + S(2)**(S(1)/3)*(S(6)*b*d*(S(1) + sqrt(S(3))*I) - S(2)**(S(1)/3)*r**S(2)*(S(1) - sqrt(S(3))*I))/(S(4)*r))**p*(S(3)*d*x + S(2)**(S(1)/3)*(S(6)*b*d - S(2)**(S(1)/3)*r**S(2))/(S(2)*r))**p, x), x) pattern1748 = Pattern(Integral((x_**S(3)*WC('d', S(1)) + x_*WC('b', S(1)) + WC('a', S(0)))**p_, x_), cons2, cons3, cons27, cons5, cons147, cons1000) rule1748 = ReplacementRule(pattern1748, With1748) pattern1749 = Pattern(Integral((x_*WC('f', S(1)) + WC('e', S(0)))**WC('m', S(1))*(x_**S(3)*WC('d', S(1)) + x_*WC('b', S(1)) + WC('a', S(0)))**p_, x_), cons2, cons3, cons27, cons48, cons125, cons21, cons38, cons999) def replacement1749(p, m, f, b, d, a, x, e): rubi.append(1749) return Dist(S(3)**(-S(3)*p)*a**(-S(2)*p), Int((S(3)*a - b*x)**p*(S(3)*a + S(2)*b*x)**(S(2)*p)*(e + f*x)**m, x), x) rule1749 = ReplacementRule(pattern1749, replacement1749) pattern1750 = Pattern(Integral((x_*WC('f', S(1)) + WC('e', S(0)))**WC('m', S(1))*(x_**S(3)*WC('d', S(1)) + x_*WC('b', S(1)) + WC('a', S(0)))**p_, x_), cons2, cons3, cons27, cons48, cons125, cons21, cons128, cons1000) def replacement1750(p, m, f, b, d, a, x, e): rubi.append(1750) return Int(ExpandIntegrand((e + f*x)**m*(a + b*x + d*x**S(3))**p, x), x) rule1750 = ReplacementRule(pattern1750, replacement1750) def With1751(p, m, f, b, d, a, x, e): if isinstance(x, (int, Integer, float, Float)): return False u = Factor(a + b*x + d*x**S(3)) if ProductQ(NonfreeFactors(u, x)): return True return False pattern1751 = Pattern(Integral((x_*WC('f', S(1)) + WC('e', S(0)))**WC('m', S(1))*(x_**S(3)*WC('d', S(1)) + x_*WC('b', S(1)) + WC('a', S(0)))**p_, x_), cons2, cons3, cons27, cons48, cons125, cons21, cons63, cons1000, CustomConstraint(With1751)) def replacement1751(p, m, f, b, d, a, x, e): u = Factor(a + b*x + d*x**S(3)) rubi.append(1751) return Dist(FreeFactors(u, x)**p, Int((e + f*x)**m*DistributeDegree(NonfreeFactors(u, x), p), x), x) rule1751 = ReplacementRule(pattern1751, replacement1751) def With1752(p, m, f, b, d, a, x, e): r = Rt(-S(27)*a*d**S(2) + S(3)*sqrt(S(3))*d*sqrt(S(27)*a**S(2)*d**S(2) + S(4)*b**S(3)*d), S(3)) rubi.append(1752) return Dist(S(3)**(-S(3)*p)*d**(-S(2)*p), Int((e + f*x)**m*(-S(3)*d*x + S(2)**(S(1)/3)*(S(6)*b*d*(S(1) - sqrt(S(3))*I) - S(2)**(S(1)/3)*r**S(2)*(S(1) + sqrt(S(3))*I))/(S(4)*r))**p*(-S(3)*d*x + S(2)**(S(1)/3)*(S(6)*b*d*(S(1) + sqrt(S(3))*I) - S(2)**(S(1)/3)*r**S(2)*(S(1) - sqrt(S(3))*I))/(S(4)*r))**p*(S(3)*d*x + S(2)**(S(1)/3)*(S(6)*b*d - S(2)**(S(1)/3)*r**S(2))/(S(2)*r))**p, x), x) pattern1752 = Pattern(Integral((x_*WC('f', S(1)) + WC('e', S(0)))**WC('m', S(1))*(x_**S(3)*WC('d', S(1)) + x_*WC('b', S(1)) + WC('a', S(0)))**p_, x_), cons2, cons3, cons27, cons48, cons125, cons21, cons63, cons1000) rule1752 = ReplacementRule(pattern1752, With1752) pattern1753 = Pattern(Integral((x_*WC('f', S(1)) + WC('e', S(0)))**WC('m', S(1))*(x_**S(3)*WC('d', S(1)) + x_*WC('b', S(1)) + WC('a', S(0)))**p_, x_), cons2, cons3, cons27, cons48, cons125, cons21, cons5, cons147, cons999) def replacement1753(p, m, f, b, d, a, x, e): rubi.append(1753) return Dist((S(3)*a - b*x)**(-p)*(S(3)*a + S(2)*b*x)**(-S(2)*p)*(a + b*x + d*x**S(3))**p, Int((S(3)*a - b*x)**p*(S(3)*a + S(2)*b*x)**(S(2)*p)*(e + f*x)**m, x), x) rule1753 = ReplacementRule(pattern1753, replacement1753) def With1754(p, m, f, b, d, a, x, e): if isinstance(x, (int, Integer, float, Float)): return False u = NonfreeFactors(Factor(a + b*x + d*x**S(3)), x) if ProductQ(u): return True return False pattern1754 = Pattern(Integral((x_*WC('f', S(1)) + WC('e', S(0)))**WC('m', S(1))*(x_**S(3)*WC('d', S(1)) + x_*WC('b', S(1)) + WC('a', S(0)))**p_, x_), cons2, cons3, cons27, cons48, cons125, cons21, cons5, cons147, cons1000, CustomConstraint(With1754)) def replacement1754(p, m, f, b, d, a, x, e): u = NonfreeFactors(Factor(a + b*x + d*x**S(3)), x) rubi.append(1754) return Dist((a + b*x + d*x**S(3))**p/DistributeDegree(u, p), Int((e + f*x)**m*DistributeDegree(u, p), x), x) rule1754 = ReplacementRule(pattern1754, replacement1754) def With1755(p, m, f, b, d, a, x, e): r = Rt(-S(27)*a*d**S(2) + S(3)*sqrt(S(3))*d*sqrt(S(27)*a**S(2)*d**S(2) + S(4)*b**S(3)*d), S(3)) rubi.append(1755) return Dist((-S(3)*d*x + S(2)**(S(1)/3)*(S(6)*b*d*(S(1) - sqrt(S(3))*I) - S(2)**(S(1)/3)*r**S(2)*(S(1) + sqrt(S(3))*I))/(S(4)*r))**(-p)*(-S(3)*d*x + S(2)**(S(1)/3)*(S(6)*b*d*(S(1) + sqrt(S(3))*I) - S(2)**(S(1)/3)*r**S(2)*(S(1) - sqrt(S(3))*I))/(S(4)*r))**(-p)*(S(3)*d*x + S(2)**(S(1)/3)*(S(6)*b*d - S(2)**(S(1)/3)*r**S(2))/(S(2)*r))**(-p)*(a + b*x + d*x**S(3))**p, Int((e + f*x)**m*(-S(3)*d*x + S(2)**(S(1)/3)*(S(6)*b*d*(S(1) - sqrt(S(3))*I) - S(2)**(S(1)/3)*r**S(2)*(S(1) + sqrt(S(3))*I))/(S(4)*r))**p*(-S(3)*d*x + S(2)**(S(1)/3)*(S(6)*b*d*(S(1) + sqrt(S(3))*I) - S(2)**(S(1)/3)*r**S(2)*(S(1) - sqrt(S(3))*I))/(S(4)*r))**p*(S(3)*d*x + S(2)**(S(1)/3)*(S(6)*b*d - S(2)**(S(1)/3)*r**S(2))/(S(2)*r))**p, x), x) pattern1755 = Pattern(Integral((x_*WC('f', S(1)) + WC('e', S(0)))**WC('m', S(1))*(x_**S(3)*WC('d', S(1)) + x_*WC('b', S(1)) + WC('a', S(0)))**p_, x_), cons2, cons3, cons27, cons48, cons125, cons21, cons5, cons147, cons1000) rule1755 = ReplacementRule(pattern1755, With1755) pattern1756 = Pattern(Integral((x_**S(3)*WC('d', S(1)) + x_**S(2)*WC('c', S(1)) + WC('a', S(0)))**p_, x_), cons2, cons7, cons27, cons38, cons1001) def replacement1756(p, d, a, c, x): rubi.append(1756) return -Dist(S(3)**(-S(3)*p)*d**(-S(2)*p), Int((c - S(3)*d*x)**p*(S(2)*c + S(3)*d*x)**(S(2)*p), x), x) rule1756 = ReplacementRule(pattern1756, replacement1756) pattern1757 = Pattern(Integral((x_**S(3)*WC('d', S(1)) + x_**S(2)*WC('c', S(1)) + WC('a', S(0)))**p_, x_), cons2, cons7, cons27, cons128, cons1002) def replacement1757(p, d, a, c, x): rubi.append(1757) return Int(ExpandToSum((a + c*x**S(2) + d*x**S(3))**p, x), x) rule1757 = ReplacementRule(pattern1757, replacement1757) def With1758(p, d, a, c, x): if isinstance(x, (int, Integer, float, Float)): return False u = Factor(a + c*x**S(2) + d*x**S(3)) if ProductQ(NonfreeFactors(u, x)): return True return False pattern1758 = Pattern(Integral((x_**S(3)*WC('d', S(1)) + x_**S(2)*WC('c', S(1)) + WC('a', S(0)))**p_, x_), cons2, cons7, cons27, cons63, cons1002, CustomConstraint(With1758)) def replacement1758(p, d, a, c, x): u = Factor(a + c*x**S(2) + d*x**S(3)) rubi.append(1758) return Dist(FreeFactors(u, x)**p, Int(DistributeDegree(NonfreeFactors(u, x), p), x), x) rule1758 = ReplacementRule(pattern1758, replacement1758) def With1759(p, d, a, c, x): r = Rt(-S(27)*a*d**S(2) - S(2)*c**S(3) + S(3)*sqrt(S(3))*d*sqrt(S(27)*a**S(2)*d**S(2) + S(4)*a*c**S(3)), S(3)) rubi.append(1759) return Dist(S(3)**(-S(3)*p)*d**(-S(2)*p), Int((c + S(3)*d*x - S(2)**(S(1)/3)*(S(2)*c**S(2) + S(2)**(S(1)/3)*r**S(2))/(S(2)*r))**p*(c + S(3)*d*x + S(2)**(S(1)/3)*(S(2)*c**S(2)*(S(1) - sqrt(S(3))*I) + S(2)**(S(1)/3)*r**S(2)*(S(1) + sqrt(S(3))*I))/(S(4)*r))**p*(c + S(3)*d*x + S(2)**(S(1)/3)*(S(2)*c**S(2)*(S(1) + sqrt(S(3))*I) + S(2)**(S(1)/3)*r**S(2)*(S(1) - sqrt(S(3))*I))/(S(4)*r))**p, x), x) pattern1759 = Pattern(Integral((x_**S(3)*WC('d', S(1)) + x_**S(2)*WC('c', S(1)) + WC('a', S(0)))**p_, x_), cons2, cons7, cons27, cons63, cons1002) rule1759 = ReplacementRule(pattern1759, With1759) pattern1760 = Pattern(Integral((x_**S(3)*WC('d', S(1)) + x_**S(2)*WC('c', S(1)) + WC('a', S(0)))**p_, x_), cons2, cons7, cons27, cons5, cons147, cons1001) def replacement1760(p, d, a, c, x): rubi.append(1760) return Dist((c - S(3)*d*x)**(-p)*(S(2)*c + S(3)*d*x)**(-S(2)*p)*(a + c*x**S(2) + d*x**S(3))**p, Int((c - S(3)*d*x)**p*(S(2)*c + S(3)*d*x)**(S(2)*p), x), x) rule1760 = ReplacementRule(pattern1760, replacement1760) def With1761(p, d, a, c, x): if isinstance(x, (int, Integer, float, Float)): return False u = NonfreeFactors(Factor(a + c*x**S(2) + d*x**S(3)), x) if ProductQ(u): return True return False pattern1761 = Pattern(Integral((x_**S(3)*WC('d', S(1)) + x_**S(2)*WC('c', S(1)) + WC('a', S(0)))**p_, x_), cons2, cons7, cons27, cons5, cons147, cons1002, CustomConstraint(With1761)) def replacement1761(p, d, a, c, x): u = NonfreeFactors(Factor(a + c*x**S(2) + d*x**S(3)), x) rubi.append(1761) return Dist((a + c*x**S(2) + d*x**S(3))**p/DistributeDegree(u, p), Int(DistributeDegree(u, p), x), x) rule1761 = ReplacementRule(pattern1761, replacement1761) def With1762(p, d, a, c, x): r = Rt(-S(27)*a*d**S(2) - S(2)*c**S(3) + S(3)*sqrt(S(3))*d*sqrt(S(27)*a**S(2)*d**S(2) + S(4)*a*c**S(3)), S(3)) rubi.append(1762) return Dist((a + c*x**S(2) + d*x**S(3))**p*(c + S(3)*d*x - S(2)**(S(1)/3)*(S(2)*c**S(2) + S(2)**(S(1)/3)*r**S(2))/(S(2)*r))**(-p)*(c + S(3)*d*x + S(2)**(S(1)/3)*(S(2)*c**S(2)*(S(1) - sqrt(S(3))*I) + S(2)**(S(1)/3)*r**S(2)*(S(1) + sqrt(S(3))*I))/(S(4)*r))**(-p)*(c + S(3)*d*x + S(2)**(S(1)/3)*(S(2)*c**S(2)*(S(1) + sqrt(S(3))*I) + S(2)**(S(1)/3)*r**S(2)*(S(1) - sqrt(S(3))*I))/(S(4)*r))**(-p), Int((c + S(3)*d*x - S(2)**(S(1)/3)*(S(2)*c**S(2) + S(2)**(S(1)/3)*r**S(2))/(S(2)*r))**p*(c + S(3)*d*x + S(2)**(S(1)/3)*(S(2)*c**S(2)*(S(1) - sqrt(S(3))*I) + S(2)**(S(1)/3)*r**S(2)*(S(1) + sqrt(S(3))*I))/(S(4)*r))**p*(c + S(3)*d*x + S(2)**(S(1)/3)*(S(2)*c**S(2)*(S(1) + sqrt(S(3))*I) + S(2)**(S(1)/3)*r**S(2)*(S(1) - sqrt(S(3))*I))/(S(4)*r))**p, x), x) pattern1762 = Pattern(Integral((x_**S(3)*WC('d', S(1)) + x_**S(2)*WC('c', S(1)) + WC('a', S(0)))**p_, x_), cons2, cons7, cons27, cons5, cons147, cons1002) rule1762 = ReplacementRule(pattern1762, With1762) pattern1763 = Pattern(Integral((x_*WC('f', S(1)) + WC('e', S(0)))**WC('m', S(1))*(x_**S(3)*WC('d', S(1)) + x_**S(2)*WC('c', S(1)) + WC('a', S(0)))**p_, x_), cons2, cons7, cons27, cons48, cons125, cons21, cons38, cons1001) def replacement1763(p, m, f, d, c, a, x, e): rubi.append(1763) return -Dist(S(3)**(-S(3)*p)*d**(-S(2)*p), Int((c - S(3)*d*x)**p*(S(2)*c + S(3)*d*x)**(S(2)*p)*(e + f*x)**m, x), x) rule1763 = ReplacementRule(pattern1763, replacement1763) pattern1764 = Pattern(Integral((x_*WC('f', S(1)) + WC('e', S(0)))**WC('m', S(1))*(x_**S(3)*WC('d', S(1)) + x_**S(2)*WC('c', S(1)) + WC('a', S(0)))**p_, x_), cons2, cons7, cons27, cons48, cons125, cons21, cons128, cons1002) def replacement1764(p, m, f, d, c, a, x, e): rubi.append(1764) return Int(ExpandIntegrand((e + f*x)**m*(a + c*x**S(2) + d*x**S(3))**p, x), x) rule1764 = ReplacementRule(pattern1764, replacement1764) def With1765(p, m, f, d, c, a, x, e): if isinstance(x, (int, Integer, float, Float)): return False u = Factor(a + c*x**S(2) + d*x**S(3)) if ProductQ(NonfreeFactors(u, x)): return True return False pattern1765 = Pattern(Integral((x_*WC('f', S(1)) + WC('e', S(0)))**WC('m', S(1))*(x_**S(3)*WC('d', S(1)) + x_**S(2)*WC('c', S(1)) + WC('a', S(0)))**p_, x_), cons2, cons7, cons27, cons48, cons125, cons21, cons63, cons1002, CustomConstraint(With1765)) def replacement1765(p, m, f, d, c, a, x, e): u = Factor(a + c*x**S(2) + d*x**S(3)) rubi.append(1765) return Dist(FreeFactors(u, x)**p, Int((e + f*x)**m*DistributeDegree(NonfreeFactors(u, x), p), x), x) rule1765 = ReplacementRule(pattern1765, replacement1765) def With1766(p, m, f, d, c, a, x, e): r = Rt(-S(27)*a*d**S(2) - S(2)*c**S(3) + S(3)*sqrt(S(3))*d*sqrt(S(27)*a**S(2)*d**S(2) + S(4)*a*c**S(3)), S(3)) rubi.append(1766) return Dist(S(3)**(-S(3)*p)*d**(-S(2)*p), Int((e + f*x)**m*(c + S(3)*d*x - S(2)**(S(1)/3)*(S(2)*c**S(2) + S(2)**(S(1)/3)*r**S(2))/(S(2)*r))**p*(c + S(3)*d*x + S(2)**(S(1)/3)*(S(2)*c**S(2)*(S(1) - sqrt(S(3))*I) + S(2)**(S(1)/3)*r**S(2)*(S(1) + sqrt(S(3))*I))/(S(4)*r))**p*(c + S(3)*d*x + S(2)**(S(1)/3)*(S(2)*c**S(2)*(S(1) + sqrt(S(3))*I) + S(2)**(S(1)/3)*r**S(2)*(S(1) - sqrt(S(3))*I))/(S(4)*r))**p, x), x) pattern1766 = Pattern(Integral((x_*WC('f', S(1)) + WC('e', S(0)))**WC('m', S(1))*(x_**S(3)*WC('d', S(1)) + x_**S(2)*WC('c', S(1)) + WC('a', S(0)))**p_, x_), cons2, cons7, cons27, cons48, cons125, cons21, cons63, cons1002) rule1766 = ReplacementRule(pattern1766, With1766) pattern1767 = Pattern(Integral((x_*WC('f', S(1)) + WC('e', S(0)))**WC('m', S(1))*(x_**S(3)*WC('d', S(1)) + x_**S(2)*WC('c', S(1)) + WC('a', S(0)))**p_, x_), cons2, cons7, cons27, cons48, cons125, cons21, cons5, cons147, cons1001) def replacement1767(p, m, f, d, c, a, x, e): rubi.append(1767) return Dist((c - S(3)*d*x)**(-p)*(S(2)*c + S(3)*d*x)**(-S(2)*p)*(a + c*x**S(2) + d*x**S(3))**p, Int((c - S(3)*d*x)**p*(S(2)*c + S(3)*d*x)**(S(2)*p)*(e + f*x)**m, x), x) rule1767 = ReplacementRule(pattern1767, replacement1767) def With1768(p, m, f, d, c, a, x, e): if isinstance(x, (int, Integer, float, Float)): return False u = NonfreeFactors(Factor(a + c*x**S(2) + d*x**S(3)), x) if ProductQ(u): return True return False pattern1768 = Pattern(Integral((x_*WC('f', S(1)) + WC('e', S(0)))**WC('m', S(1))*(x_**S(3)*WC('d', S(1)) + x_**S(2)*WC('c', S(1)) + WC('a', S(0)))**p_, x_), cons2, cons7, cons27, cons48, cons125, cons21, cons5, cons147, cons1002, CustomConstraint(With1768)) def replacement1768(p, m, f, d, c, a, x, e): u = NonfreeFactors(Factor(a + c*x**S(2) + d*x**S(3)), x) rubi.append(1768) return Dist((a + c*x**S(2) + d*x**S(3))**p/DistributeDegree(u, p), Int((e + f*x)**m*DistributeDegree(u, p), x), x) rule1768 = ReplacementRule(pattern1768, replacement1768) def With1769(p, m, f, d, c, a, x, e): r = Rt(-S(27)*a*d**S(2) - S(2)*c**S(3) + S(3)*sqrt(S(3))*d*sqrt(S(27)*a**S(2)*d**S(2) + S(4)*a*c**S(3)), S(3)) rubi.append(1769) return Dist((a + c*x**S(2) + d*x**S(3))**p*(c + S(3)*d*x - S(2)**(S(1)/3)*(S(2)*c**S(2) + S(2)**(S(1)/3)*r**S(2))/(S(2)*r))**(-p)*(c + S(3)*d*x + S(2)**(S(1)/3)*(S(2)*c**S(2)*(S(1) - sqrt(S(3))*I) + S(2)**(S(1)/3)*r**S(2)*(S(1) + sqrt(S(3))*I))/(S(4)*r))**(-p)*(c + S(3)*d*x + S(2)**(S(1)/3)*(S(2)*c**S(2)*(S(1) + sqrt(S(3))*I) + S(2)**(S(1)/3)*r**S(2)*(S(1) - sqrt(S(3))*I))/(S(4)*r))**(-p), Int((e + f*x)**m*(c + S(3)*d*x - S(2)**(S(1)/3)*(S(2)*c**S(2) + S(2)**(S(1)/3)*r**S(2))/(S(2)*r))**p*(c + S(3)*d*x + S(2)**(S(1)/3)*(S(2)*c**S(2)*(S(1) - sqrt(S(3))*I) + S(2)**(S(1)/3)*r**S(2)*(S(1) + sqrt(S(3))*I))/(S(4)*r))**p*(c + S(3)*d*x + S(2)**(S(1)/3)*(S(2)*c**S(2)*(S(1) + sqrt(S(3))*I) + S(2)**(S(1)/3)*r**S(2)*(S(1) - sqrt(S(3))*I))/(S(4)*r))**p, x), x) pattern1769 = Pattern(Integral((x_*WC('f', S(1)) + WC('e', S(0)))**WC('m', S(1))*(x_**S(3)*WC('d', S(1)) + x_**S(2)*WC('c', S(1)) + WC('a', S(0)))**p_, x_), cons2, cons7, cons27, cons48, cons125, cons21, cons5, cons147, cons1002) rule1769 = ReplacementRule(pattern1769, With1769) pattern1770 = Pattern(Integral((x_**S(3)*WC('d', S(1)) + x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0)))**p_, x_), cons2, cons3, cons7, cons27, cons38, cons1003, cons1004) def replacement1770(p, b, d, c, a, x): rubi.append(1770) return Dist(S(3)**(-p)*b**(-p)*c**(-p), Int((b + c*x)**(S(3)*p), x), x) rule1770 = ReplacementRule(pattern1770, replacement1770) pattern1771 = Pattern(Integral((x_**S(3)*WC('d', S(1)) + x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0)))**p_, x_), cons2, cons3, cons7, cons27, cons38, cons1003, cons1005) def replacement1771(p, b, d, c, a, x): rubi.append(1771) return Dist(S(3)**(-p)*b**(-p)*c**(-p), Subst(Int((S(3)*a*b*c - b**S(3) + c**S(3)*x**S(3))**p, x), x, c/(S(3)*d) + x), x) rule1771 = ReplacementRule(pattern1771, replacement1771) def With1772(p, b, d, c, a, x): r = Rt(-S(3)*b*c*d + c**S(3), S(3)) rubi.append(1772) return Dist(S(3)**(-p)*b**(-p)*c**(-p), Int((b + x*(c - r))**p*(b + x*(c + r*(S(1) - sqrt(S(3))*I)/S(2)))**p*(b + x*(c + r*(S(1) + sqrt(S(3))*I)/S(2)))**p, x), x) pattern1772 = Pattern(Integral((x_**S(3)*WC('d', S(1)) + x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0)))**p_, x_), cons2, cons3, cons7, cons27, cons38, cons1006, cons1004) rule1772 = ReplacementRule(pattern1772, With1772) pattern1773 = Pattern(Integral((x_**S(3)*WC('d', S(1)) + x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0)))**p_, x_), cons2, cons3, cons7, cons27, cons128, cons1006, cons1005) def replacement1773(p, b, d, c, a, x): rubi.append(1773) return Int(ExpandToSum((a + b*x + c*x**S(2) + d*x**S(3))**p, x), x) rule1773 = ReplacementRule(pattern1773, replacement1773) def With1774(p, b, d, c, a, x): if isinstance(x, (int, Integer, float, Float)): return False u = Factor(a + b*x + c*x**S(2) + d*x**S(3)) if ProductQ(NonfreeFactors(u, x)): return True return False pattern1774 = Pattern(Integral((x_**S(3)*WC('d', S(1)) + x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0)))**p_, x_), cons2, cons3, cons7, cons27, cons63, cons1006, cons1005, CustomConstraint(With1774)) def replacement1774(p, b, d, c, a, x): u = Factor(a + b*x + c*x**S(2) + d*x**S(3)) rubi.append(1774) return Dist(FreeFactors(u, x)**p, Int(DistributeDegree(NonfreeFactors(u, x), p), x), x) rule1774 = ReplacementRule(pattern1774, replacement1774) pattern1775 = Pattern(Integral((x_**S(3)*WC('d', S(1)) + x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0)))**p_, x_), cons2, cons3, cons7, cons27, cons63, cons1006, cons1005) def replacement1775(p, b, d, c, a, x): rubi.append(1775) return Dist(S(3)**(-S(3)*p)*d**(-S(2)*p), Subst(Int((S(27)*a*d**S(2) - S(9)*b*c*d + S(2)*c**S(3) + S(27)*d**S(3)*x**S(3) - S(9)*d*x*(-S(3)*b*d + c**S(2)))**p, x), x, c/(S(3)*d) + x), x) rule1775 = ReplacementRule(pattern1775, replacement1775) pattern1776 = Pattern(Integral((x_**S(3)*WC('d', S(1)) + x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0)))**p_, x_), cons2, cons3, cons7, cons27, cons5, cons147, cons1003, cons1004) def replacement1776(p, b, d, c, a, x): rubi.append(1776) return Dist((b + c*x)**(-S(3)*p)*(a + b*x + c*x**S(2) + d*x**S(3))**p, Int((b + c*x)**(S(3)*p), x), x) rule1776 = ReplacementRule(pattern1776, replacement1776) def With1777(p, b, d, c, a, x): r = Rt(-S(3)*a*b*c + b**S(3), S(3)) rubi.append(1777) return Dist((b + c*x - r)**(-p)*(b + c*x + r*(S(1) - sqrt(S(3))*I)/S(2))**(-p)*(b + c*x + r*(S(1) + sqrt(S(3))*I)/S(2))**(-p)*(a + b*x + c*x**S(2) + d*x**S(3))**p, Int((b + c*x - r)**p*(b + c*x + r*(S(1) - sqrt(S(3))*I)/S(2))**p*(b + c*x + r*(S(1) + sqrt(S(3))*I)/S(2))**p, x), x) pattern1777 = Pattern(Integral((x_**S(3)*WC('d', S(1)) + x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0)))**p_, x_), cons2, cons3, cons7, cons27, cons5, cons147, cons1003, cons1005) rule1777 = ReplacementRule(pattern1777, With1777) def With1778(p, b, d, c, a, x): r = Rt(-S(3)*b*c*d + c**S(3), S(3)) rubi.append(1778) return Dist((b + x*(c - r))**(-p)*(b + x*(c + r*(S(1) - sqrt(S(3))*I)/S(2)))**(-p)*(b + x*(c + r*(S(1) + sqrt(S(3))*I)/S(2)))**(-p)*(a + b*x + c*x**S(2) + d*x**S(3))**p, Int((b + x*(c - r))**p*(b + x*(c + r*(S(1) - sqrt(S(3))*I)/S(2)))**p*(b + x*(c + r*(S(1) + sqrt(S(3))*I)/S(2)))**p, x), x) pattern1778 = Pattern(Integral((x_**S(3)*WC('d', S(1)) + x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0)))**p_, x_), cons2, cons3, cons7, cons27, cons5, cons147, cons1006, cons1004) rule1778 = ReplacementRule(pattern1778, With1778) def With1779(p, b, d, c, a, x): if isinstance(x, (int, Integer, float, Float)): return False u = NonfreeFactors(Factor(a + b*x + c*x**S(2) + d*x**S(3)), x) if ProductQ(u): return True return False pattern1779 = Pattern(Integral((x_**S(3)*WC('d', S(1)) + x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0)))**p_, x_), cons2, cons3, cons7, cons27, cons5, cons147, cons1006, cons1005, CustomConstraint(With1779)) def replacement1779(p, b, d, c, a, x): u = NonfreeFactors(Factor(a + b*x + c*x**S(2) + d*x**S(3)), x) rubi.append(1779) return Dist((a + b*x + c*x**S(2) + d*x**S(3))**p/DistributeDegree(u, p), Int(DistributeDegree(u, p), x), x) rule1779 = ReplacementRule(pattern1779, replacement1779) def With1780(p, b, d, c, a, x): r = Rt(-S(27)*a*d**S(2) + S(9)*b*c*d - S(2)*c**S(3) + S(3)*sqrt(S(3))*d*sqrt(S(27)*a**S(2)*d**S(2) - S(18)*a*b*c*d + S(4)*a*c**S(3) + S(4)*b**S(3)*d - b**S(2)*c**S(2)), S(3)) rubi.append(1780) return Dist((c + S(3)*d*x - S(2)**(S(1)/3)*(-S(6)*b*d + S(2)*c**S(2) + S(2)**(S(1)/3)*r**S(2))/(S(2)*r))**(-p)*(c + S(3)*d*x + S(2)**(S(1)/3)*(-S(6)*b*d*(S(1) - sqrt(S(3))*I) + S(2)*c**S(2)*(S(1) - sqrt(S(3))*I) + S(2)**(S(1)/3)*I*r**S(2)*(sqrt(S(3)) - I))/(S(4)*r))**(-p)*(c + S(3)*d*x + S(2)**(S(1)/3)*(-S(6)*b*d*(S(1) + sqrt(S(3))*I) + S(2)*c**S(2)*(S(1) + sqrt(S(3))*I) - S(2)**(S(1)/3)*I*r**S(2)*(sqrt(S(3)) + I))/(S(4)*r))**(-p)*(a + b*x + c*x**S(2) + d*x**S(3))**p, Int((c + S(3)*d*x - S(2)**(S(1)/3)*(-S(6)*b*d + S(2)*c**S(2) + S(2)**(S(1)/3)*r**S(2))/(S(2)*r))**p*(c + S(3)*d*x + S(2)**(S(1)/3)*(-S(6)*b*d*(S(1) - sqrt(S(3))*I) + S(2)*c**S(2)*(S(1) - sqrt(S(3))*I) + S(2)**(S(1)/3)*I*r**S(2)*(sqrt(S(3)) - I))/(S(4)*r))**p*(c + S(3)*d*x + S(2)**(S(1)/3)*(-S(6)*b*d*(S(1) + sqrt(S(3))*I) + S(2)*c**S(2)*(S(1) + sqrt(S(3))*I) - S(2)**(S(1)/3)*I*r**S(2)*(sqrt(S(3)) + I))/(S(4)*r))**p, x), x) pattern1780 = Pattern(Integral((x_**S(3)*WC('d', S(1)) + x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0)))**p_, x_), cons2, cons3, cons7, cons27, cons5, cons147, cons1006, cons1005) rule1780 = ReplacementRule(pattern1780, With1780) pattern1781 = Pattern(Integral(u_**p_, x_), cons5, cons1007, cons1008) def replacement1781(x, p, u): rubi.append(1781) return Int(ExpandToSum(u, x)**p, x) rule1781 = ReplacementRule(pattern1781, replacement1781) pattern1782 = Pattern(Integral((x_*WC('f', S(1)) + WC('e', S(0)))**WC('m', S(1))*(x_**S(3)*WC('d', S(1)) + x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0)))**p_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons38, cons1003, cons1004) def replacement1782(p, m, f, b, d, a, c, x, e): rubi.append(1782) return Dist(S(3)**(-p)*b**(-p)*c**(-p), Int((b + c*x)**(S(3)*p)*(e + f*x)**m, x), x) rule1782 = ReplacementRule(pattern1782, replacement1782) def With1783(p, m, f, b, d, a, c, x, e): r = Rt(-S(3)*a*b*c + b**S(3), S(3)) rubi.append(1783) return Dist(S(3)**(-p)*b**(-p)*c**(-p), Int((e + f*x)**m*(b + c*x - r)**p*(b + c*x + r*(S(1) - sqrt(S(3))*I)/S(2))**p*(b + c*x + r*(S(1) + sqrt(S(3))*I)/S(2))**p, x), x) pattern1783 = Pattern(Integral((x_*WC('f', S(1)) + WC('e', S(0)))**WC('m', S(1))*(x_**S(3)*WC('d', S(1)) + x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0)))**p_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons38, cons1003, cons1005) rule1783 = ReplacementRule(pattern1783, With1783) def With1784(p, m, f, b, d, a, c, x, e): r = Rt(-S(3)*b*c*d + c**S(3), S(3)) rubi.append(1784) return Dist(S(3)**(-p)*b**(-p)*c**(-p), Int((b + x*(c - r))**p*(b + x*(c + r*(S(1) - sqrt(S(3))*I)/S(2)))**p*(b + x*(c + r*(S(1) + sqrt(S(3))*I)/S(2)))**p*(e + f*x)**m, x), x) pattern1784 = Pattern(Integral((x_*WC('f', S(1)) + WC('e', S(0)))**WC('m', S(1))*(x_**S(3)*WC('d', S(1)) + x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0)))**p_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons38, cons1006, cons1004) rule1784 = ReplacementRule(pattern1784, With1784) pattern1785 = Pattern(Integral((x_*WC('f', S(1)) + WC('e', S(0)))**WC('m', S(1))*(x_**S(3)*WC('d', S(1)) + x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0)))**p_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons128, cons1006, cons1005) def replacement1785(p, m, f, b, d, a, c, x, e): rubi.append(1785) return Int(ExpandIntegrand((e + f*x)**m*(a + b*x + c*x**S(2) + d*x**S(3))**p, x), x) rule1785 = ReplacementRule(pattern1785, replacement1785) def With1786(p, m, f, b, d, a, c, x, e): if isinstance(x, (int, Integer, float, Float)): return False u = Factor(a + b*x + c*x**S(2) + d*x**S(3)) if ProductQ(NonfreeFactors(u, x)): return True return False pattern1786 = Pattern(Integral((x_*WC('f', S(1)) + WC('e', S(0)))**WC('m', S(1))*(x_**S(3)*WC('d', S(1)) + x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0)))**p_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons63, cons1006, cons1005, CustomConstraint(With1786)) def replacement1786(p, m, f, b, d, a, c, x, e): u = Factor(a + b*x + c*x**S(2) + d*x**S(3)) rubi.append(1786) return Dist(FreeFactors(u, x)**p, Int((e + f*x)**m*DistributeDegree(NonfreeFactors(u, x), p), x), x) rule1786 = ReplacementRule(pattern1786, replacement1786) pattern1787 = Pattern(Integral((x_*WC('f', S(1)) + WC('e', S(0)))**WC('m', S(1))*(x_**S(3)*WC('d', S(1)) + x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0)))**p_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons63, cons1006, cons1005) def replacement1787(p, m, f, b, d, a, c, x, e): rubi.append(1787) return Dist(S(3)**(-S(3)*p)*d**(-S(2)*p), Subst(Int((S(27)*a*d**S(2) - S(9)*b*c*d + S(2)*c**S(3) + S(27)*d**S(3)*x**S(3) - S(9)*d*x*(-S(3)*b*d + c**S(2)))**p, x), x, c/(S(3)*d) + x), x) rule1787 = ReplacementRule(pattern1787, replacement1787) pattern1788 = Pattern(Integral((x_*WC('f', S(1)) + WC('e', S(0)))**WC('m', S(1))*(x_**S(3)*WC('d', S(1)) + x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0)))**p_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons5, cons147, cons1003, cons1004) def replacement1788(p, m, f, b, d, a, c, x, e): rubi.append(1788) return Dist((b + c*x)**(-S(3)*p)*(a + b*x + c*x**S(2) + d*x**S(3))**p, Int((b + c*x)**(S(3)*p)*(e + f*x)**m, x), x) rule1788 = ReplacementRule(pattern1788, replacement1788) def With1789(p, m, f, b, d, a, c, x, e): r = Rt(-S(3)*a*b*c + b**S(3), S(3)) rubi.append(1789) return Dist((b + c*x - r)**(-p)*(b + c*x + r*(S(1) - sqrt(S(3))*I)/S(2))**(-p)*(b + c*x + r*(S(1) + sqrt(S(3))*I)/S(2))**(-p)*(a + b*x + c*x**S(2) + d*x**S(3))**p, Int((e + f*x)**m*(b + c*x - r)**p*(b + c*x + r*(S(1) - sqrt(S(3))*I)/S(2))**p*(b + c*x + r*(S(1) + sqrt(S(3))*I)/S(2))**p, x), x) pattern1789 = Pattern(Integral((x_*WC('f', S(1)) + WC('e', S(0)))**WC('m', S(1))*(x_**S(3)*WC('d', S(1)) + x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0)))**p_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons5, cons147, cons1003, cons1005) rule1789 = ReplacementRule(pattern1789, With1789) def With1790(p, m, f, b, d, a, c, x, e): r = Rt(-S(3)*b*c*d + c**S(3), S(3)) rubi.append(1790) return Dist((b + x*(c - r))**(-p)*(b + x*(c + r*(S(1) - sqrt(S(3))*I)/S(2)))**(-p)*(b + x*(c + r*(S(1) + sqrt(S(3))*I)/S(2)))**(-p)*(a + b*x + c*x**S(2) + d*x**S(3))**p, Int((b + x*(c - r))**p*(b + x*(c + r*(S(1) - sqrt(S(3))*I)/S(2)))**p*(b + x*(c + r*(S(1) + sqrt(S(3))*I)/S(2)))**p*(e + f*x)**m, x), x) pattern1790 = Pattern(Integral((x_*WC('f', S(1)) + WC('e', S(0)))**WC('m', S(1))*(x_**S(3)*WC('d', S(1)) + x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0)))**p_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons5, cons147, cons1006, cons1004) rule1790 = ReplacementRule(pattern1790, With1790) def With1791(p, m, f, b, d, a, c, x, e): if isinstance(x, (int, Integer, float, Float)): return False u = NonfreeFactors(Factor(a + b*x + c*x**S(2) + d*x**S(3)), x) if ProductQ(u): return True return False pattern1791 = Pattern(Integral((x_*WC('f', S(1)) + WC('e', S(0)))**WC('m', S(1))*(x_**S(3)*WC('d', S(1)) + x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0)))**p_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons5, cons147, cons1006, cons1005, CustomConstraint(With1791)) def replacement1791(p, m, f, b, d, a, c, x, e): u = NonfreeFactors(Factor(a + b*x + c*x**S(2) + d*x**S(3)), x) rubi.append(1791) return Dist((a + b*x + c*x**S(2) + d*x**S(3))**p/DistributeDegree(u, p), Int((e + f*x)**m*DistributeDegree(u, p), x), x) rule1791 = ReplacementRule(pattern1791, replacement1791) def With1792(p, m, f, b, d, a, c, x, e): r = Rt(-S(27)*a*d**S(2) + S(9)*b*c*d - S(2)*c**S(3) + S(3)*sqrt(S(3))*d*sqrt(S(27)*a**S(2)*d**S(2) - S(18)*a*b*c*d + S(4)*a*c**S(3) + S(4)*b**S(3)*d - b**S(2)*c**S(2)), S(3)) rubi.append(1792) return Dist((c + S(3)*d*x - S(2)**(S(1)/3)*(-S(6)*b*d + S(2)*c**S(2) + S(2)**(S(1)/3)*r**S(2))/(S(2)*r))**(-p)*(c + S(3)*d*x + S(2)**(S(1)/3)*(-S(6)*b*d*(S(1) - sqrt(S(3))*I) + S(2)*c**S(2)*(S(1) - sqrt(S(3))*I) + S(2)**(S(1)/3)*I*r**S(2)*(sqrt(S(3)) - I))/(S(4)*r))**(-p)*(c + S(3)*d*x + S(2)**(S(1)/3)*(-S(6)*b*d*(S(1) + sqrt(S(3))*I) + S(2)*c**S(2)*(S(1) + sqrt(S(3))*I) - S(2)**(S(1)/3)*I*r**S(2)*(sqrt(S(3)) + I))/(S(4)*r))**(-p)*(a + b*x + c*x**S(2) + d*x**S(3))**p, Int((e + f*x)**m*(c + S(3)*d*x - S(2)**(S(1)/3)*(-S(6)*b*d + S(2)*c**S(2) + S(2)**(S(1)/3)*r**S(2))/(S(2)*r))**p*(c + S(3)*d*x + S(2)**(S(1)/3)*(-S(6)*b*d*(S(1) - sqrt(S(3))*I) + S(2)*c**S(2)*(S(1) - sqrt(S(3))*I) + S(2)**(S(1)/3)*I*r**S(2)*(sqrt(S(3)) - I))/(S(4)*r))**p*(c + S(3)*d*x + S(2)**(S(1)/3)*(-S(6)*b*d*(S(1) + sqrt(S(3))*I) + S(2)*c**S(2)*(S(1) + sqrt(S(3))*I) - S(2)**(S(1)/3)*I*r**S(2)*(sqrt(S(3)) + I))/(S(4)*r))**p, x), x) pattern1792 = Pattern(Integral((x_*WC('f', S(1)) + WC('e', S(0)))**WC('m', S(1))*(x_**S(3)*WC('d', S(1)) + x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0)))**p_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons5, cons147, cons1006, cons1005) rule1792 = ReplacementRule(pattern1792, With1792) pattern1793 = Pattern(Integral(u_**WC('m', S(1))*v_**WC('p', S(1)), x_), cons21, cons5, cons68, cons1009, cons1010) def replacement1793(v, p, u, m, x): rubi.append(1793) return Int(ExpandToSum(u, x)**m*ExpandToSum(v, x)**p, x) rule1793 = ReplacementRule(pattern1793, replacement1793) pattern1794 = Pattern(Integral((f_ + x_**S(2)*WC('g', S(1)))/((d_ + x_**S(2)*WC('d', S(1)) + x_*WC('e', S(1)))*sqrt(a_ + x_**S(4)*WC('a', S(1)) + x_**S(3)*WC('b', S(1)) + x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons383, cons1011, cons1012) def replacement1794(g, b, f, d, c, a, x, e): rubi.append(1794) return Simp(a*f*ArcTan((a*b*x**S(2) + a*b + x*(S(4)*a**S(2) - S(2)*a*c + b**S(2)))/(S(2)*sqrt(a*x**S(4) + a + b*x**S(3) + b*x + c*x**S(2))*Rt(a**S(2)*(S(2)*a - c), S(2))))/(d*Rt(a**S(2)*(S(2)*a - c), S(2))), x) rule1794 = ReplacementRule(pattern1794, replacement1794) pattern1795 = Pattern(Integral((f_ + x_**S(2)*WC('g', S(1)))/((d_ + x_**S(2)*WC('d', S(1)) + x_*WC('e', S(1)))*sqrt(a_ + x_**S(4)*WC('a', S(1)) + x_**S(3)*WC('b', S(1)) + x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons383, cons1011, cons1013) def replacement1795(g, b, f, d, c, a, x, e): rubi.append(1795) return -Simp(a*f*atanh((a*b*x**S(2) + a*b + x*(S(4)*a**S(2) - S(2)*a*c + b**S(2)))/(S(2)*sqrt(a*x**S(4) + a + b*x**S(3) + b*x + c*x**S(2))*Rt(-a**S(2)*(S(2)*a - c), S(2))))/(d*Rt(-a**S(2)*(S(2)*a - c), S(2))), x) rule1795 = ReplacementRule(pattern1795, replacement1795) pattern1796 = Pattern(Integral((x_**S(4)*WC('e', S(1)) + x_**S(3)*WC('d', S(1)) + x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0)))**p_, x_), cons2, cons3, cons7, cons27, cons48, cons5, cons1014, cons1015, cons1016) def replacement1796(p, b, d, c, a, x, e): rubi.append(1796) return Subst(Int(SimplifyIntegrand((a - b*d/(S(8)*e) + d**S(4)/(S(256)*e**S(3)) + e*x**S(4) + x**S(2)*(c - S(3)*d**S(2)/(S(8)*e)))**p, x), x), x, d/(S(4)*e) + x) rule1796 = ReplacementRule(pattern1796, replacement1796) def With1797(v, x, p): if isinstance(x, (int, Integer, float, Float)): return False a = Coefficient(v, x, S(0)) b = Coefficient(v, x, S(1)) c = Coefficient(v, x, S(2)) d = Coefficient(v, x, S(3)) e = Coefficient(v, x, S(4)) if And(ZeroQ(S(8)*b*e**S(2) - S(4)*c*d*e + d**S(3)), NonzeroQ(d)): return True return False pattern1797 = Pattern(Integral(v_**p_, x_), cons5, cons1017, cons1018, cons1015, cons1016, CustomConstraint(With1797)) def replacement1797(v, x, p): a = Coefficient(v, x, S(0)) b = Coefficient(v, x, S(1)) c = Coefficient(v, x, S(2)) d = Coefficient(v, x, S(3)) e = Coefficient(v, x, S(4)) rubi.append(1797) return Subst(Int(SimplifyIntegrand((a - b*d/(S(8)*e) + d**S(4)/(S(256)*e**S(3)) + e*x**S(4) + x**S(2)*(c - S(3)*d**S(2)/(S(8)*e)))**p, x), x), x, d/(S(4)*e) + x) rule1797 = ReplacementRule(pattern1797, replacement1797) pattern1798 = Pattern(Integral(u_*(x_**S(4)*WC('e', S(1)) + x_**S(3)*WC('d', S(1)) + x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0)))**p_, x_), cons2, cons3, cons7, cons27, cons48, cons5, cons804, cons1014, cons357) def replacement1798(p, u, b, d, c, a, x, e): rubi.append(1798) return Subst(Int(SimplifyIntegrand((a - b*d/(S(8)*e) + d**S(4)/(S(256)*e**S(3)) + e*x**S(4) + x**S(2)*(c - S(3)*d**S(2)/(S(8)*e)))**p*ReplaceAll(u, Rule(x, -d/(S(4)*e) + x)), x), x), x, d/(S(4)*e) + x) rule1798 = ReplacementRule(pattern1798, replacement1798) def With1799(v, x, p, u): if isinstance(x, (int, Integer, float, Float)): return False a = Coefficient(v, x, S(0)) b = Coefficient(v, x, S(1)) c = Coefficient(v, x, S(2)) d = Coefficient(v, x, S(3)) e = Coefficient(v, x, S(4)) if And(ZeroQ(S(8)*b*e**S(2) - S(4)*c*d*e + d**S(3)), NonzeroQ(d)): return True return False pattern1799 = Pattern(Integral(u_*v_**p_, x_), cons5, cons804, cons1017, cons1018, cons357, CustomConstraint(With1799)) def replacement1799(v, x, p, u): a = Coefficient(v, x, S(0)) b = Coefficient(v, x, S(1)) c = Coefficient(v, x, S(2)) d = Coefficient(v, x, S(3)) e = Coefficient(v, x, S(4)) rubi.append(1799) return Subst(Int(SimplifyIntegrand((a - b*d/(S(8)*e) + d**S(4)/(S(256)*e**S(3)) + e*x**S(4) + x**S(2)*(c - S(3)*d**S(2)/(S(8)*e)))**p*ReplaceAll(u, Rule(x, -d/(S(4)*e) + x)), x), x), x, d/(S(4)*e) + x) rule1799 = ReplacementRule(pattern1799, replacement1799) pattern1800 = Pattern(Integral((a_ + x_**S(4)*WC('e', S(1)) + x_**S(3)*WC('d', S(1)) + x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)))**p_, x_), cons2, cons3, cons7, cons27, cons48, cons1019, cons246) def replacement1800(p, b, d, c, a, x, e): rubi.append(1800) return Dist(-S(16)*a**S(2), Subst(Int((a*(S(256)*a**S(4)*x**S(4) + S(256)*a**S(3)*e - S(64)*a**S(2)*b*d - S(32)*a**S(2)*x**S(2)*(-S(8)*a*c + S(3)*b**S(2)) + S(16)*a*b**S(2)*c - S(3)*b**S(4))/(-S(4)*a*x + b)**S(4))**p/(-S(4)*a*x + b)**S(2), x), x, S(1)/x + b/(S(4)*a)), x) rule1800 = ReplacementRule(pattern1800, replacement1800) def With1801(v, x, p): if isinstance(x, (int, Integer, float, Float)): return False a = Coefficient(v, x, S(0)) b = Coefficient(v, x, S(1)) c = Coefficient(v, x, S(2)) d = Coefficient(v, x, S(3)) e = Coefficient(v, x, S(4)) if And(NonzeroQ(a), NonzeroQ(b), ZeroQ(S(8)*a**S(2)*d - S(4)*a*b*c + b**S(3))): return True return False pattern1801 = Pattern(Integral(v_**p_, x_), cons5, cons1017, cons1018, cons246, CustomConstraint(With1801)) def replacement1801(v, x, p): a = Coefficient(v, x, S(0)) b = Coefficient(v, x, S(1)) c = Coefficient(v, x, S(2)) d = Coefficient(v, x, S(3)) e = Coefficient(v, x, S(4)) rubi.append(1801) return Dist(-S(16)*a**S(2), Subst(Int((a*(S(256)*a**S(4)*x**S(4) + S(256)*a**S(3)*e - S(64)*a**S(2)*b*d - S(32)*a**S(2)*x**S(2)*(-S(8)*a*c + S(3)*b**S(2)) + S(16)*a*b**S(2)*c - S(3)*b**S(4))/(-S(4)*a*x + b)**S(4))**p/(-S(4)*a*x + b)**S(2), x), x, S(1)/x + b/(S(4)*a)), x) rule1801 = ReplacementRule(pattern1801, replacement1801) def With1802(B, C, e, b, D, d, c, a, x, A): q = sqrt(S(8)*a**S(2) - S(4)*a*c + b**S(2)) rubi.append(1802) return -Dist(S(1)/q, Int((A*b - A*q - S(2)*B*a + S(2)*D*a + x*(S(2)*A*a - S(2)*C*a + D*b - D*q))/(S(2)*a*x**S(2) + S(2)*a + x*(b - q)), x), x) + Dist(S(1)/q, Int((A*b + A*q - S(2)*B*a + S(2)*D*a + x*(S(2)*A*a - S(2)*C*a + D*b + D*q))/(S(2)*a*x**S(2) + S(2)*a + x*(b + q)), x), x) pattern1802 = Pattern(Integral((x_**S(3)*WC('D', S(1)) + x_**S(2)*WC('C', S(1)) + x_*WC('B', S(1)) + WC('A', S(0)))/(a_ + x_**S(4)*WC('e', S(1)) + x_**S(3)*WC('d', S(1)) + x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1))), x_), cons2, cons3, cons7, cons34, cons35, cons36, cons1023, cons1020, cons1021, cons1022) rule1802 = ReplacementRule(pattern1802, With1802) def With1803(B, e, b, D, d, c, a, x, A): q = sqrt(S(8)*a**S(2) - S(4)*a*c + b**S(2)) rubi.append(1803) return -Dist(S(1)/q, Int((A*b - A*q - S(2)*B*a + S(2)*D*a + x*(S(2)*A*a + D*b - D*q))/(S(2)*a*x**S(2) + S(2)*a + x*(b - q)), x), x) + Dist(S(1)/q, Int((A*b + A*q - S(2)*B*a + S(2)*D*a + x*(S(2)*A*a + D*b + D*q))/(S(2)*a*x**S(2) + S(2)*a + x*(b + q)), x), x) pattern1803 = Pattern(Integral((x_**S(3)*WC('D', S(1)) + x_*WC('B', S(1)) + WC('A', S(0)))/(a_ + x_**S(4)*WC('e', S(1)) + x_**S(3)*WC('d', S(1)) + x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1))), x_), cons2, cons3, cons7, cons34, cons35, cons1023, cons1020, cons1021, cons1022) rule1803 = ReplacementRule(pattern1803, With1803) def With1804(B, C, e, m, b, D, d, c, a, x, A): q = sqrt(S(8)*a**S(2) - S(4)*a*c + b**S(2)) rubi.append(1804) return -Dist(S(1)/q, Int(x**m*(A*b - A*q - S(2)*B*a + S(2)*D*a + x*(S(2)*A*a - S(2)*C*a + D*b - D*q))/(S(2)*a*x**S(2) + S(2)*a + x*(b - q)), x), x) + Dist(S(1)/q, Int(x**m*(A*b + A*q - S(2)*B*a + S(2)*D*a + x*(S(2)*A*a - S(2)*C*a + D*b + D*q))/(S(2)*a*x**S(2) + S(2)*a + x*(b + q)), x), x) pattern1804 = Pattern(Integral(x_**WC('m', S(1))*(x_**S(3)*WC('D', S(1)) + x_**S(2)*WC('C', S(1)) + x_*WC('B', S(1)) + WC('A', S(0)))/(a_ + x_**S(4)*WC('e', S(1)) + x_**S(3)*WC('d', S(1)) + x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1))), x_), cons2, cons3, cons7, cons34, cons35, cons36, cons1023, cons21, cons1020, cons1021, cons1022) rule1804 = ReplacementRule(pattern1804, With1804) def With1805(B, e, m, b, D, d, c, a, x, A): q = sqrt(S(8)*a**S(2) - S(4)*a*c + b**S(2)) rubi.append(1805) return -Dist(S(1)/q, Int(x**m*(A*b - A*q - S(2)*B*a + S(2)*D*a + x*(S(2)*A*a + D*b - D*q))/(S(2)*a*x**S(2) + S(2)*a + x*(b - q)), x), x) + Dist(S(1)/q, Int(x**m*(A*b + A*q - S(2)*B*a + S(2)*D*a + x*(S(2)*A*a + D*b + D*q))/(S(2)*a*x**S(2) + S(2)*a + x*(b + q)), x), x) pattern1805 = Pattern(Integral(x_**WC('m', S(1))*(x_**S(3)*WC('D', S(1)) + x_*WC('B', S(1)) + WC('A', S(0)))/(a_ + x_**S(4)*WC('e', S(1)) + x_**S(3)*WC('d', S(1)) + x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1))), x_), cons2, cons3, cons7, cons34, cons35, cons1023, cons21, cons1020, cons1021, cons1022) rule1805 = ReplacementRule(pattern1805, With1805) def With1806(B, C, e, b, d, c, a, x, A): q = Rt(C*(C*(-S(4)*c*e + d**S(2)) + S(2)*e*(-S(4)*A*e + B*d)), S(2)) rubi.append(1806) return Simp(-S(2)*C**S(2)*atanh((-B*e + C*d + S(2)*C*e*x)/q)/q, x) + Simp(S(2)*C**S(2)*atanh(C*(S(12)*A*B*e - S(4)*A*C*d - S(3)*B**S(2)*d + S(4)*B*C*c + S(8)*C**S(2)*e*x**S(3) + S(4)*C*x**S(2)*(-B*e + S(2)*C*d) + S(4)*C*x*(S(2)*A*e - B*d + S(2)*C*c))/(q*(-S(4)*A*C + B**S(2))))/q, x) pattern1806 = Pattern(Integral((x_**S(2)*WC('C', S(1)) + x_*WC('B', S(1)) + WC('A', S(0)))/(a_ + x_**S(4)*WC('e', S(1)) + x_**S(3)*WC('d', S(1)) + x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons34, cons35, cons36, cons1024, cons1025, cons1026) rule1806 = ReplacementRule(pattern1806, With1806) def With1807(C, e, b, d, c, a, x, A): q = Rt(C*(-S(8)*A*e**S(2) + C*(-S(4)*c*e + d**S(2))), S(2)) rubi.append(1807) return Simp(-S(2)*C**S(2)*atanh(C*(d + S(2)*e*x)/q)/q, x) + Simp(S(2)*C**S(2)*atanh(C*(A*d - S(2)*C*d*x**S(2) - S(2)*C*e*x**S(3) - S(2)*x*(A*e + C*c))/(A*q))/q, x) pattern1807 = Pattern(Integral((x_**S(2)*WC('C', S(1)) + WC('A', S(0)))/(a_ + x_**S(4)*WC('e', S(1)) + x_**S(3)*WC('d', S(1)) + x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons34, cons36, cons1027, cons1028, cons1029) rule1807 = ReplacementRule(pattern1807, With1807) def With1808(B, C, e, b, d, c, a, x, A): q = Rt(-C*(C*(-S(4)*c*e + d**S(2)) + S(2)*e*(-S(4)*A*e + B*d)), S(2)) rubi.append(1808) return Simp(S(2)*C**S(2)*ArcTan((-B*e + C*d + S(2)*C*e*x)/q)/q, x) - Simp(S(2)*C**S(2)*ArcTan(C*(S(12)*A*B*e - S(4)*A*C*d - S(3)*B**S(2)*d + S(4)*B*C*c + S(8)*C**S(2)*e*x**S(3) + S(4)*C*x**S(2)*(-B*e + S(2)*C*d) + S(4)*C*x*(S(2)*A*e - B*d + S(2)*C*c))/(q*(-S(4)*A*C + B**S(2))))/q, x) pattern1808 = Pattern(Integral((x_**S(2)*WC('C', S(1)) + x_*WC('B', S(1)) + WC('A', S(0)))/(a_ + x_**S(4)*WC('e', S(1)) + x_**S(3)*WC('d', S(1)) + x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons34, cons35, cons36, cons1024, cons1025, cons1030) rule1808 = ReplacementRule(pattern1808, With1808) def With1809(C, e, b, d, c, a, x, A): q = Rt(-C*(-S(8)*A*e**S(2) + C*(-S(4)*c*e + d**S(2))), S(2)) rubi.append(1809) return Simp(S(2)*C**S(2)*ArcTan((C*d + S(2)*C*e*x)/q)/q, x) - Simp(S(2)*C**S(2)*ArcTan(-C*(-A*d + S(2)*C*d*x**S(2) + S(2)*C*e*x**S(3) + S(2)*x*(A*e + C*c))/(A*q))/q, x) pattern1809 = Pattern(Integral((x_**S(2)*WC('C', S(1)) + WC('A', S(0)))/(a_ + x_**S(4)*WC('e', S(1)) + x_**S(3)*WC('d', S(1)) + x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons34, cons36, cons1027, cons1028, cons1031) rule1809 = ReplacementRule(pattern1809, With1809) pattern1810 = Pattern(Integral((x_**S(3)*WC('D', S(1)) + x_**S(2)*WC('C', S(1)) + x_*WC('B', S(1)) + WC('A', S(0)))/(a_ + x_**S(4)*WC('e', S(1)) + x_**S(3)*WC('d', S(1)) + x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons34, cons35, cons36, cons1023, cons1032, cons1033) def replacement1810(B, C, e, b, D, d, c, a, x, A): rubi.append(1810) return -Dist(S(1)/(S(4)*e), Int((-S(4)*A*e + D*b + x**S(2)*(-S(4)*C*e + S(3)*D*d) + S(2)*x*(-S(2)*B*e + D*c))/(a + b*x + c*x**S(2) + d*x**S(3) + e*x**S(4)), x), x) + Simp(D*log(a + b*x + c*x**S(2) + d*x**S(3) + e*x**S(4))/(S(4)*e), x) rule1810 = ReplacementRule(pattern1810, replacement1810) pattern1811 = Pattern(Integral((x_**S(3)*WC('D', S(1)) + x_*WC('B', S(1)) + WC('A', S(0)))/(a_ + x_**S(4)*WC('e', S(1)) + x_**S(3)*WC('d', S(1)) + x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons34, cons35, cons1023, cons1034, cons1035) def replacement1811(B, e, b, D, d, c, a, x, A): rubi.append(1811) return -Dist(S(1)/(S(4)*e), Int((-S(4)*A*e + D*b + S(3)*D*d*x**S(2) + S(2)*x*(-S(2)*B*e + D*c))/(a + b*x + c*x**S(2) + d*x**S(3) + e*x**S(4)), x), x) + Simp(D*log(a + b*x + c*x**S(2) + d*x**S(3) + e*x**S(4))/(S(4)*e), x) rule1811 = ReplacementRule(pattern1811, replacement1811) pattern1812 = Pattern(Integral(u_/(sqrt(x_*WC('b', S(1)) + WC('a', S(0)))*WC('e', S(1)) + sqrt(x_*WC('d', S(1)) + WC('c', S(0)))*WC('f', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1036) def replacement1812(u, f, b, d, c, a, x, e): rubi.append(1812) return -Dist(a/(f*(-a*d + b*c)), Int(u*sqrt(c + d*x)/x, x), x) + Dist(c/(e*(-a*d + b*c)), Int(u*sqrt(a + b*x)/x, x), x) rule1812 = ReplacementRule(pattern1812, replacement1812) pattern1813 = Pattern(Integral(u_/(sqrt(x_*WC('b', S(1)) + WC('a', S(0)))*WC('e', S(1)) + sqrt(x_*WC('d', S(1)) + WC('c', S(0)))*WC('f', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1037) def replacement1813(u, f, b, d, c, a, x, e): rubi.append(1813) return Dist(b/(f*(-a*d + b*c)), Int(u*sqrt(c + d*x), x), x) - Dist(d/(e*(-a*d + b*c)), Int(u*sqrt(a + b*x), x), x) rule1813 = ReplacementRule(pattern1813, replacement1813) pattern1814 = Pattern(Integral(u_/(sqrt(x_*WC('b', S(1)) + WC('a', S(0)))*WC('e', S(1)) + sqrt(x_*WC('d', S(1)) + WC('c', S(0)))*WC('f', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons1038, cons1039) def replacement1814(u, f, b, d, c, a, x, e): rubi.append(1814) return Dist(e, Int(u*sqrt(a + b*x)/(a*e**S(2) - c*f**S(2) + x*(b*e**S(2) - d*f**S(2))), x), x) - Dist(f, Int(u*sqrt(c + d*x)/(a*e**S(2) - c*f**S(2) + x*(b*e**S(2) - d*f**S(2))), x), x) rule1814 = ReplacementRule(pattern1814, replacement1814) pattern1815 = Pattern(Integral(WC('u', S(1))/(x_**WC('n', S(1))*WC('d', S(1)) + sqrt(x_**WC('p', S(1))*WC('b', S(1)) + WC('a', S(0)))*WC('c', S(1))), x_), cons2, cons3, cons7, cons27, cons4, cons1040, cons1041) def replacement1815(p, u, b, d, c, n, a, x): rubi.append(1815) return Dist(S(1)/(a*c), Int(u*sqrt(a + b*x**(S(2)*n)), x), x) - Dist(b/(a*d), Int(u*x**n, x), x) rule1815 = ReplacementRule(pattern1815, replacement1815) pattern1816 = Pattern(Integral(x_**WC('m', S(1))/(x_**WC('n', S(1))*WC('d', S(1)) + sqrt(x_**WC('p', S(1))*WC('b', S(1)) + WC('a', S(0)))*WC('c', S(1))), x_), cons2, cons3, cons7, cons27, cons21, cons4, cons1040, cons1042) def replacement1816(p, m, b, d, c, n, a, x): rubi.append(1816) return Dist(c, Int(x**m*sqrt(a + b*x**(S(2)*n))/(a*c**S(2) + x**(S(2)*n)*(b*c**S(2) - d**S(2))), x), x) - Dist(d, Int(x**(m + n)/(a*c**S(2) + x**(S(2)*n)*(b*c**S(2) - d**S(2))), x), x) rule1816 = ReplacementRule(pattern1816, replacement1816) def With1817(f, b, d, a, x, e): r = Numerator(Rt(a/b, S(3))) s = Denominator(Rt(a/b, S(3))) rubi.append(1817) return Dist(r/(S(3)*a), Int(S(1)/((r + s*x)*sqrt(d + e*x + f*x**S(2))), x), x) + Dist(r/(S(3)*a), Int((S(2)*r - s*x)/(sqrt(d + e*x + f*x**S(2))*(r**S(2) - r*s*x + s**S(2)*x**S(2))), x), x) pattern1817 = Pattern(Integral(S(1)/((a_ + x_**S(3)*WC('b', S(1)))*sqrt(x_**S(2)*WC('f', S(1)) + x_*WC('e', S(1)) + WC('d', S(0)))), x_), cons2, cons3, cons27, cons48, cons125, cons468) rule1817 = ReplacementRule(pattern1817, With1817) def With1818(f, b, d, a, x): r = Numerator(Rt(a/b, S(3))) s = Denominator(Rt(a/b, S(3))) rubi.append(1818) return Dist(r/(S(3)*a), Int(S(1)/(sqrt(d + f*x**S(2))*(r + s*x)), x), x) + Dist(r/(S(3)*a), Int((S(2)*r - s*x)/(sqrt(d + f*x**S(2))*(r**S(2) - r*s*x + s**S(2)*x**S(2))), x), x) pattern1818 = Pattern(Integral(S(1)/((a_ + x_**S(3)*WC('b', S(1)))*sqrt(x_**S(2)*WC('f', S(1)) + WC('d', S(0)))), x_), cons2, cons3, cons27, cons125, cons468) rule1818 = ReplacementRule(pattern1818, With1818) def With1819(f, b, d, a, x, e): r = Numerator(Rt(-a/b, S(3))) s = Denominator(Rt(-a/b, S(3))) rubi.append(1819) return Dist(r/(S(3)*a), Int(S(1)/((r - s*x)*sqrt(d + e*x + f*x**S(2))), x), x) + Dist(r/(S(3)*a), Int((S(2)*r + s*x)/(sqrt(d + e*x + f*x**S(2))*(r**S(2) + r*s*x + s**S(2)*x**S(2))), x), x) pattern1819 = Pattern(Integral(S(1)/((a_ + x_**S(3)*WC('b', S(1)))*sqrt(x_**S(2)*WC('f', S(1)) + x_*WC('e', S(1)) + WC('d', S(0)))), x_), cons2, cons3, cons27, cons48, cons125, cons469) rule1819 = ReplacementRule(pattern1819, With1819) def With1820(f, b, d, a, x): r = Numerator(Rt(-a/b, S(3))) s = Denominator(Rt(-a/b, S(3))) rubi.append(1820) return Dist(r/(S(3)*a), Int(S(1)/(sqrt(d + f*x**S(2))*(r - s*x)), x), x) + Dist(r/(S(3)*a), Int((S(2)*r + s*x)/(sqrt(d + f*x**S(2))*(r**S(2) + r*s*x + s**S(2)*x**S(2))), x), x) pattern1820 = Pattern(Integral(S(1)/((a_ + x_**S(3)*WC('b', S(1)))*sqrt(x_**S(2)*WC('f', S(1)) + WC('d', S(0)))), x_), cons2, cons3, cons27, cons125, cons469) rule1820 = ReplacementRule(pattern1820, With1820) pattern1821 = Pattern(Integral(S(1)/((d_ + x_*WC('e', S(1)))*sqrt(a_ + x_**S(4)*WC('c', S(1)) + x_**S(2)*WC('b', S(1)))), x_), cons2, cons3, cons7, cons27, cons48, cons1043) def replacement1821(b, d, c, a, x, e): rubi.append(1821) return Dist(d, Int(S(1)/((d**S(2) - e**S(2)*x**S(2))*sqrt(a + b*x**S(2) + c*x**S(4))), x), x) - Dist(e, Int(x/((d**S(2) - e**S(2)*x**S(2))*sqrt(a + b*x**S(2) + c*x**S(4))), x), x) rule1821 = ReplacementRule(pattern1821, replacement1821) pattern1822 = Pattern(Integral(S(1)/(sqrt(a_ + x_**S(4)*WC('c', S(1)))*(d_ + x_*WC('e', S(1)))), x_), cons2, cons7, cons27, cons48, cons297) def replacement1822(d, c, a, x, e): rubi.append(1822) return Dist(d, Int(S(1)/(sqrt(a + c*x**S(4))*(d**S(2) - e**S(2)*x**S(2))), x), x) - Dist(e, Int(x/(sqrt(a + c*x**S(4))*(d**S(2) - e**S(2)*x**S(2))), x), x) rule1822 = ReplacementRule(pattern1822, replacement1822) pattern1823 = Pattern(Integral(S(1)/((d_ + x_*WC('e', S(1)))**S(2)*sqrt(a_ + x_**S(4)*WC('c', S(1)) + x_**S(2)*WC('b', S(1)))), x_), cons2, cons3, cons7, cons27, cons48, cons1044, cons1045) def replacement1823(b, d, c, a, x, e): rubi.append(1823) return -Dist(c/(a*e**S(4) + b*d**S(2)*e**S(2) + c*d**S(4)), Int((d**S(2) - e**S(2)*x**S(2))/sqrt(a + b*x**S(2) + c*x**S(4)), x), x) - Simp(e**S(3)*sqrt(a + b*x**S(2) + c*x**S(4))/((d + e*x)*(a*e**S(4) + b*d**S(2)*e**S(2) + c*d**S(4))), x) rule1823 = ReplacementRule(pattern1823, replacement1823) pattern1824 = Pattern(Integral(S(1)/((d_ + x_*WC('e', S(1)))**S(2)*sqrt(a_ + x_**S(4)*WC('c', S(1)) + x_**S(2)*WC('b', S(1)))), x_), cons2, cons3, cons7, cons27, cons48, cons1044, cons1046) def replacement1824(b, d, c, a, x, e): rubi.append(1824) return -Dist(c/(a*e**S(4) + b*d**S(2)*e**S(2) + c*d**S(4)), Int((d**S(2) - e**S(2)*x**S(2))/sqrt(a + b*x**S(2) + c*x**S(4)), x), x) + Dist((b*d*e**S(2) + S(2)*c*d**S(3))/(a*e**S(4) + b*d**S(2)*e**S(2) + c*d**S(4)), Int(S(1)/((d + e*x)*sqrt(a + b*x**S(2) + c*x**S(4))), x), x) - Simp(e**S(3)*sqrt(a + b*x**S(2) + c*x**S(4))/((d + e*x)*(a*e**S(4) + b*d**S(2)*e**S(2) + c*d**S(4))), x) rule1824 = ReplacementRule(pattern1824, replacement1824) pattern1825 = Pattern(Integral(S(1)/(sqrt(a_ + x_**S(4)*WC('c', S(1)))*(d_ + x_*WC('e', S(1)))**S(2)), x_), cons2, cons7, cons27, cons48, cons1047) def replacement1825(d, c, a, x, e): rubi.append(1825) return -Dist(c/(a*e**S(4) + c*d**S(4)), Int((d**S(2) - e**S(2)*x**S(2))/sqrt(a + c*x**S(4)), x), x) + Dist(S(2)*c*d**S(3)/(a*e**S(4) + c*d**S(4)), Int(S(1)/(sqrt(a + c*x**S(4))*(d + e*x)), x), x) - Simp(e**S(3)*sqrt(a + c*x**S(4))/((d + e*x)*(a*e**S(4) + c*d**S(4))), x) rule1825 = ReplacementRule(pattern1825, replacement1825) pattern1826 = Pattern(Integral((A_ + x_**S(2)*WC('B', S(1)))/((d_ + x_**S(2)*WC('e', S(1)))*sqrt(a_ + x_**S(4)*WC('c', S(1)) + x_**S(2)*WC('b', S(1)))), x_), cons2, cons3, cons7, cons27, cons48, cons34, cons35, cons1048, cons705) def replacement1826(B, e, b, d, c, a, x, A): rubi.append(1826) return Dist(A, Subst(Int(S(1)/(d - x**S(2)*(-S(2)*a*e + b*d)), x), x, x/sqrt(a + b*x**S(2) + c*x**S(4))), x) rule1826 = ReplacementRule(pattern1826, replacement1826) pattern1827 = Pattern(Integral((A_ + x_**S(2)*WC('B', S(1)))/(sqrt(a_ + x_**S(4)*WC('c', S(1)))*(d_ + x_**S(2)*WC('e', S(1)))), x_), cons2, cons7, cons27, cons48, cons34, cons35, cons1048, cons705) def replacement1827(B, e, d, c, a, x, A): rubi.append(1827) return Dist(A, Subst(Int(S(1)/(S(2)*a*e*x**S(2) + d), x), x, x/sqrt(a + c*x**S(4))), x) rule1827 = ReplacementRule(pattern1827, replacement1827) pattern1828 = Pattern(Integral((A_ + x_**S(4)*WC('B', S(1)))/(sqrt(a_ + x_**S(4)*WC('c', S(1)) + x_**S(2)*WC('b', S(1)))*(d_ + x_**S(4)*WC('f', S(1)) + x_**S(2)*WC('e', S(1)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons382, cons1049) def replacement1828(B, f, b, d, c, a, A, x, e): rubi.append(1828) return Dist(A, Subst(Int(S(1)/(d - x**S(2)*(-a*e + b*d)), x), x, x/sqrt(a + b*x**S(2) + c*x**S(4))), x) rule1828 = ReplacementRule(pattern1828, replacement1828) pattern1829 = Pattern(Integral((A_ + x_**S(4)*WC('B', S(1)))/(sqrt(a_ + x_**S(4)*WC('c', S(1)))*(d_ + x_**S(4)*WC('f', S(1)) + x_**S(2)*WC('e', S(1)))), x_), cons2, cons7, cons27, cons48, cons125, cons34, cons35, cons382, cons1049) def replacement1829(B, e, f, d, c, a, x, A): rubi.append(1829) return Dist(A, Subst(Int(S(1)/(a*e*x**S(2) + d), x), x, x/sqrt(a + c*x**S(4))), x) rule1829 = ReplacementRule(pattern1829, replacement1829) pattern1830 = Pattern(Integral((A_ + x_**S(4)*WC('B', S(1)))/((d_ + x_**S(4)*WC('f', S(1)))*sqrt(a_ + x_**S(4)*WC('c', S(1)) + x_**S(2)*WC('b', S(1)))), x_), cons2, cons3, cons7, cons27, cons125, cons34, cons35, cons382, cons1049) def replacement1830(B, f, b, d, c, a, x, A): rubi.append(1830) return Dist(A, Subst(Int(S(1)/(-b*d*x**S(2) + d), x), x, x/sqrt(a + b*x**S(2) + c*x**S(4))), x) rule1830 = ReplacementRule(pattern1830, replacement1830) pattern1831 = Pattern(Integral(sqrt(a_ + x_**S(4)*WC('c', S(1)) + x_**S(2)*WC('b', S(1)))/(d_ + x_**S(4)*WC('e', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons1050, cons697) def replacement1831(b, d, c, a, x, e): rubi.append(1831) return Dist(a/d, Subst(Int(S(1)/(-S(2)*b*x**S(2) + x**S(4)*(-S(4)*a*c + b**S(2)) + S(1)), x), x, x/sqrt(a + b*x**S(2) + c*x**S(4))), x) rule1831 = ReplacementRule(pattern1831, replacement1831) def With1832(b, d, c, a, x, e): q = sqrt(-S(4)*a*c + b**S(2)) rubi.append(1832) return Simp(sqrt(S(2))*a*sqrt(-b + q)*atanh(sqrt(S(2))*x*sqrt(-b + q)*(b + S(2)*c*x**S(2) + q)/(S(4)*sqrt(a + b*x**S(2) + c*x**S(4))*Rt(-a*c, S(2))))/(S(4)*d*Rt(-a*c, S(2))), x) - Simp(sqrt(S(2))*a*sqrt(b + q)*ArcTan(sqrt(S(2))*x*sqrt(b + q)*(b + S(2)*c*x**S(2) - q)/(S(4)*sqrt(a + b*x**S(2) + c*x**S(4))*Rt(-a*c, S(2))))/(S(4)*d*Rt(-a*c, S(2))), x) pattern1832 = Pattern(Integral(sqrt(a_ + x_**S(4)*WC('c', S(1)) + x_**S(2)*WC('b', S(1)))/(d_ + x_**S(4)*WC('e', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons1050, cons709) rule1832 = ReplacementRule(pattern1832, With1832) pattern1833 = Pattern(Integral(S(1)/((a_ + x_*WC('b', S(1)))*sqrt(c_ + x_**S(2)*WC('d', S(1)))*sqrt(e_ + x_**S(2)*WC('f', S(1)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons153) def replacement1833(f, b, d, a, c, x, e): rubi.append(1833) return Dist(a, Int(S(1)/((a**S(2) - b**S(2)*x**S(2))*sqrt(c + d*x**S(2))*sqrt(e + f*x**S(2))), x), x) - Dist(b, Int(x/((a**S(2) - b**S(2)*x**S(2))*sqrt(c + d*x**S(2))*sqrt(e + f*x**S(2))), x), x) rule1833 = ReplacementRule(pattern1833, replacement1833) pattern1834 = Pattern(Integral((x_*WC('h', S(1)) + WC('g', S(0)))*sqrt(x_*WC('e', S(1)) + sqrt(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0)))*WC('f', S(1)) + WC('d', S(0))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons209, cons1051, cons1052) def replacement1834(g, f, b, d, a, c, x, h, e): rubi.append(1834) return Simp(S(2)*sqrt(d + e*x + f*sqrt(a + b*x + c*x**S(2)))*(S(9)*c**S(2)*f*g*h*x**S(2) + S(3)*c**S(2)*f*h**S(2)*x**S(3) + c*f*x*(a*h**S(2) - b*g*h + S(10)*c*g**S(2)) + f*(S(2)*a*b*h**S(2) - S(3)*a*c*g*h - S(2)*b**S(2)*g*h + S(5)*b*c*g**S(2)) - (-d*h + e*g)*sqrt(a + b*x + c*x**S(2))*(-S(2)*b*h + S(5)*c*g + c*h*x))/(S(15)*c**S(2)*f*(g + h*x)), x) rule1834 = ReplacementRule(pattern1834, replacement1834) pattern1835 = Pattern(Integral((u_ + (sqrt(v_)*WC('k', S(1)) + WC('j', S(0)))*WC('f', S(1)))**WC('n', S(1))*(x_*WC('h', S(1)) + WC('g', S(0)))**WC('m', S(1)), x_), cons125, cons208, cons209, cons796, cons797, cons21, cons4, cons68, cons818, cons1053, cons1054) def replacement1835(v, u, j, k, m, g, f, n, x, h): rubi.append(1835) return Int((g + h*x)**m*(f*k*sqrt(ExpandToSum(v, x)) + ExpandToSum(f*j + u, x))**n, x) rule1835 = ReplacementRule(pattern1835, replacement1835) pattern1836 = Pattern(Integral(((x_*WC('e', S(1)) + sqrt(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0)))*WC('f', S(1)) + WC('d', S(0)))**n_*WC('h', S(1)) + WC('g', S(0)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons209, cons4, cons1055, cons38) def replacement1836(p, g, f, b, d, a, c, n, x, h, e): rubi.append(1836) return Dist(S(2), Subst(Int((g + h*x**n)**p*(d**S(2)*e + e*x**S(2) - f**S(2)*(-a*e + b*d) - x*(-b*f**S(2) + S(2)*d*e))/(b*f**S(2) - S(2)*d*e + S(2)*e*x)**S(2), x), x, d + e*x + f*sqrt(a + b*x + c*x**S(2))), x) rule1836 = ReplacementRule(pattern1836, replacement1836) pattern1837 = Pattern(Integral(((x_*WC('e', S(1)) + sqrt(a_ + x_**S(2)*WC('c', S(1)))*WC('f', S(1)) + WC('d', S(0)))**n_*WC('h', S(1)) + WC('g', S(0)))**WC('p', S(1)), x_), cons2, cons7, cons27, cons48, cons125, cons208, cons209, cons4, cons1055, cons38) def replacement1837(p, g, f, d, c, a, n, x, h, e): rubi.append(1837) return Dist(S(1)/(S(2)*e), Subst(Int((g + h*x**n)**p*(a*f**S(2) + d**S(2) - S(2)*d*x + x**S(2))/(d - x)**S(2), x), x, d + e*x + f*sqrt(a + c*x**S(2))), x) rule1837 = ReplacementRule(pattern1837, replacement1837) pattern1838 = Pattern(Integral(((u_ + sqrt(v_)*WC('f', S(1)))**n_*WC('h', S(1)) + WC('g', S(0)))**WC('p', S(1)), x_), cons125, cons208, cons209, cons4, cons68, cons818, cons819, cons1056, cons38) def replacement1838(v, p, u, g, f, n, x, h): rubi.append(1838) return Int((g + h*(f*sqrt(ExpandToSum(v, x)) + ExpandToSum(u, x))**n)**p, x) rule1838 = ReplacementRule(pattern1838, replacement1838) pattern1839 = Pattern(Integral((x_*WC('e', S(1)) + sqrt(x_**S(2)*WC('c', S(1)) + WC('a', S(0)))*WC('f', S(1)))**WC('n', S(1))*(x_*WC('h', S(1)) + WC('g', S(0)))**WC('m', S(1)), x_), cons2, cons7, cons48, cons125, cons208, cons209, cons4, cons1055, cons17) def replacement1839(m, g, f, a, c, n, x, h, e): rubi.append(1839) return Dist(S(2)**(-m + S(-1))*e**(-m + S(-1)), Subst(Int(x**(-m + n + S(-2))*(a*f**S(2) + x**S(2))*(-a*f**S(2)*h + S(2)*e*g*x + h*x**S(2))**m, x), x, e*x + f*sqrt(a + c*x**S(2))), x) rule1839 = ReplacementRule(pattern1839, replacement1839) pattern1840 = Pattern(Integral(x_**WC('p', S(1))*(g_ + x_**S(2)*WC('i', S(1)))**WC('m', S(1))*(x_*WC('e', S(1)) + sqrt(a_ + x_**S(2)*WC('c', S(1)))*WC('f', S(1)))**WC('n', S(1)), x_), cons2, cons7, cons48, cons125, cons208, cons224, cons4, cons1055, cons1057, cons1058, cons1059) def replacement1840(p, m, f, g, i, c, n, a, x, e): rubi.append(1840) return Dist(S(2)**(-S(2)*m - p + S(-1))*e**(-p + S(-1))*f**(-S(2)*m)*(i/c)**m, Subst(Int(x**(-S(2)*m + n - p + S(-2))*(-a*f**S(2) + x**S(2))**p*(a*f**S(2) + x**S(2))**(S(2)*m + S(1)), x), x, e*x + f*sqrt(a + c*x**S(2))), x) rule1840 = ReplacementRule(pattern1840, replacement1840) pattern1841 = Pattern(Integral((x_*WC('e', S(1)) + sqrt(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0)))*WC('f', S(1)) + WC('d', S(0)))**WC('n', S(1))*(x_**S(2)*WC('i', S(1)) + x_*WC('h', S(1)) + WC('g', S(0)))**WC('m', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons209, cons224, cons4, cons1055, cons1057, cons1060, cons515, cons1059) def replacement1841(m, g, f, b, i, d, a, c, n, x, h, e): rubi.append(1841) return Dist(S(2)*f**(-S(2)*m)*(i/c)**m, Subst(Int(x**n*(b*f**S(2) - S(2)*d*e + S(2)*e*x)**(-S(2)*m + S(-2))*(d**S(2)*e + e*x**S(2) - f**S(2)*(-a*e + b*d) - x*(-b*f**S(2) + S(2)*d*e))**(S(2)*m + S(1)), x), x, d + e*x + f*sqrt(a + b*x + c*x**S(2))), x) rule1841 = ReplacementRule(pattern1841, replacement1841) pattern1842 = Pattern(Integral((g_ + x_**S(2)*WC('i', S(1)))**WC('m', S(1))*(x_*WC('e', S(1)) + sqrt(a_ + x_**S(2)*WC('c', S(1)))*WC('f', S(1)) + WC('d', S(0)))**WC('n', S(1)), x_), cons2, cons7, cons27, cons48, cons125, cons208, cons224, cons4, cons1055, cons1057, cons515, cons1059) def replacement1842(m, f, g, i, d, c, n, a, x, e): rubi.append(1842) return Dist(S(2)**(-S(2)*m + S(-1))*f**(-S(2)*m)*(i/c)**m/e, Subst(Int(x**n*(-d + x)**(-S(2)*m + S(-2))*(a*f**S(2) + d**S(2) - S(2)*d*x + x**S(2))**(S(2)*m + S(1)), x), x, d + e*x + f*sqrt(a + c*x**S(2))), x) rule1842 = ReplacementRule(pattern1842, replacement1842) pattern1843 = Pattern(Integral((x_*WC('e', S(1)) + sqrt(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0)))*WC('f', S(1)) + WC('d', S(0)))**WC('n', S(1))*(x_**S(2)*WC('i', S(1)) + x_*WC('h', S(1)) + WC('g', S(0)))**WC('m', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons209, cons224, cons4, cons1055, cons1057, cons1060, cons73, cons1061) def replacement1843(m, g, f, b, i, d, a, c, n, x, h, e): rubi.append(1843) return Dist((i/c)**(m + S(-1)/2)*sqrt(g + h*x + i*x**S(2))/sqrt(a + b*x + c*x**S(2)), Int((a + b*x + c*x**S(2))**m*(d + e*x + f*sqrt(a + b*x + c*x**S(2)))**n, x), x) rule1843 = ReplacementRule(pattern1843, replacement1843) pattern1844 = Pattern(Integral((g_ + x_**S(2)*WC('i', S(1)))**WC('m', S(1))*(x_*WC('e', S(1)) + sqrt(a_ + x_**S(2)*WC('c', S(1)))*WC('f', S(1)) + WC('d', S(0)))**WC('n', S(1)), x_), cons2, cons7, cons27, cons48, cons125, cons208, cons224, cons4, cons1055, cons1057, cons73, cons1061) def replacement1844(m, f, g, i, d, c, n, a, x, e): rubi.append(1844) return Dist((i/c)**(m + S(-1)/2)*sqrt(g + i*x**S(2))/sqrt(a + c*x**S(2)), Int((a + c*x**S(2))**m*(d + e*x + f*sqrt(a + c*x**S(2)))**n, x), x) rule1844 = ReplacementRule(pattern1844, replacement1844) pattern1845 = Pattern(Integral((x_*WC('e', S(1)) + sqrt(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0)))*WC('f', S(1)) + WC('d', S(0)))**WC('n', S(1))*(x_**S(2)*WC('i', S(1)) + x_*WC('h', S(1)) + WC('g', S(0)))**WC('m', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons209, cons224, cons4, cons1055, cons1057, cons1060, cons951, cons1061) def replacement1845(m, g, f, b, i, d, a, c, n, x, h, e): rubi.append(1845) return Dist((i/c)**(m + S(1)/2)*sqrt(a + b*x + c*x**S(2))/sqrt(g + h*x + i*x**S(2)), Int((a + b*x + c*x**S(2))**m*(d + e*x + f*sqrt(a + b*x + c*x**S(2)))**n, x), x) rule1845 = ReplacementRule(pattern1845, replacement1845) pattern1846 = Pattern(Integral((g_ + x_**S(2)*WC('i', S(1)))**WC('m', S(1))*(x_*WC('e', S(1)) + sqrt(a_ + x_**S(2)*WC('c', S(1)))*WC('f', S(1)) + WC('d', S(0)))**WC('n', S(1)), x_), cons2, cons7, cons27, cons48, cons125, cons208, cons224, cons4, cons1055, cons1057, cons951, cons1061) def replacement1846(m, f, g, i, d, c, n, a, x, e): rubi.append(1846) return Dist((i/c)**(m + S(1)/2)*sqrt(a + c*x**S(2))/sqrt(g + i*x**S(2)), Int((a + c*x**S(2))**m*(d + e*x + f*sqrt(a + c*x**S(2)))**n, x), x) rule1846 = ReplacementRule(pattern1846, replacement1846) pattern1847 = Pattern(Integral(w_**WC('m', S(1))*(u_ + (sqrt(v_)*WC('k', S(1)) + WC('j', S(0)))*WC('f', S(1)))**WC('n', S(1)), x_), cons125, cons796, cons797, cons21, cons4, cons68, cons1062, cons1063, cons1064) def replacement1847(v, w, u, j, k, m, f, n, x): rubi.append(1847) return Int((f*k*sqrt(ExpandToSum(v, x)) + ExpandToSum(f*j + u, x))**n*ExpandToSum(w, x)**m, x) rule1847 = ReplacementRule(pattern1847, replacement1847) pattern1848 = Pattern(Integral(S(1)/((a_ + x_**WC('n', S(1))*WC('b', S(1)))*sqrt(x_**S(2)*WC('c', S(1)) + (a_ + x_**WC('n', S(1))*WC('b', S(1)))**WC('p', S(1))*WC('d', S(1)))), x_), cons2, cons3, cons7, cons27, cons4, cons1065) def replacement1848(p, b, d, c, n, a, x): rubi.append(1848) return Dist(S(1)/a, Subst(Int(S(1)/(-c*x**S(2) + S(1)), x), x, x/sqrt(c*x**S(2) + d*(a + b*x**n)**(S(2)/n))), x) rule1848 = ReplacementRule(pattern1848, replacement1848) pattern1849 = Pattern(Integral(sqrt(a_ + sqrt(c_ + x_**S(2)*WC('d', S(1)))*WC('b', S(1))), x_), cons2, cons3, cons7, cons27, cons1066) def replacement1849(b, d, c, a, x): rubi.append(1849) return Simp(S(2)*a*x/sqrt(a + b*sqrt(c + d*x**S(2))), x) + Simp(S(2)*b**S(2)*d*x**S(3)/(S(3)*(a + b*sqrt(c + d*x**S(2)))**(S(3)/2)), x) rule1849 = ReplacementRule(pattern1849, replacement1849) pattern1850 = Pattern(Integral(sqrt(x_**S(2)*WC('a', S(1)) + x_*sqrt(c_ + x_**S(2)*WC('d', S(1)))*WC('b', S(1)))/(x_*sqrt(c_ + x_**S(2)*WC('d', S(1)))), x_), cons2, cons3, cons7, cons27, cons1067, cons1068) def replacement1850(b, d, c, a, x): rubi.append(1850) return Dist(sqrt(S(2))*b/a, Subst(Int(S(1)/sqrt(S(1) + x**S(2)/a), x), x, a*x + b*sqrt(c + d*x**S(2))), x) rule1850 = ReplacementRule(pattern1850, replacement1850) pattern1851 = Pattern(Integral(sqrt(x_*(x_*WC('a', S(1)) + sqrt(c_ + x_**S(2)*WC('d', S(1)))*WC('b', S(1)))*WC('e', S(1)))/(x_*sqrt(c_ + x_**S(2)*WC('d', S(1)))), x_), cons2, cons3, cons7, cons27, cons48, cons1067, cons1069) def replacement1851(b, d, a, c, x, e): rubi.append(1851) return Int(sqrt(a*e*x**S(2) + b*e*x*sqrt(c + d*x**S(2)))/(x*sqrt(c + d*x**S(2))), x) rule1851 = ReplacementRule(pattern1851, replacement1851) pattern1852 = Pattern(Integral(sqrt(x_**S(2)*WC('c', S(1)) + sqrt(a_ + x_**S(4)*WC('b', S(1)))*WC('d', S(1)))/sqrt(a_ + x_**S(4)*WC('b', S(1))), x_), cons2, cons3, cons7, cons27, cons1070) def replacement1852(b, d, c, a, x): rubi.append(1852) return Dist(d, Subst(Int(S(1)/(-S(2)*c*x**S(2) + S(1)), x), x, x/sqrt(c*x**S(2) + d*sqrt(a + b*x**S(4)))), x) rule1852 = ReplacementRule(pattern1852, replacement1852) pattern1853 = Pattern(Integral((x_*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1))*sqrt(x_**S(2)*WC('b', S(1)) + sqrt(a_ + x_**S(4)*WC('e', S(1))))/sqrt(a_ + x_**S(4)*WC('e', S(1))), x_), cons2, cons3, cons7, cons27, cons21, cons1071, cons43) def replacement1853(m, b, d, c, a, x, e): rubi.append(1853) return Dist(S(1)/2 - I/S(2), Int((c + d*x)**m/sqrt(sqrt(a) - I*b*x**S(2)), x), x) + Dist(S(1)/2 + I/S(2), Int((c + d*x)**m/sqrt(sqrt(a) + I*b*x**S(2)), x), x) rule1853 = ReplacementRule(pattern1853, replacement1853) def With1854(b, d, c, a, x): q = Rt(b/a, S(3)) rubi.append(1854) return Dist(d/(-c*q + d*(S(1) + sqrt(S(3)))), Int((q*x + S(1) + sqrt(S(3)))/(sqrt(a + b*x**S(3))*(c + d*x)), x), x) - Dist(q/(-c*q + d*(S(1) + sqrt(S(3)))), Int(S(1)/sqrt(a + b*x**S(3)), x), x) pattern1854 = Pattern(Integral(S(1)/(sqrt(a_ + x_**S(3)*WC('b', S(1)))*(c_ + x_*WC('d', S(1)))), x_), cons2, cons3, cons7, cons27, cons481, cons479) rule1854 = ReplacementRule(pattern1854, With1854) def With1855(b, d, c, a, x): q = Rt(-b/a, S(3)) rubi.append(1855) return Dist(d/(c*q + d*(S(1) + sqrt(S(3)))), Int((-q*x + S(1) + sqrt(S(3)))/(sqrt(a + b*x**S(3))*(c + d*x)), x), x) + Dist(q/(c*q + d*(S(1) + sqrt(S(3)))), Int(S(1)/sqrt(a + b*x**S(3)), x), x) pattern1855 = Pattern(Integral(S(1)/(sqrt(a_ + x_**S(3)*WC('b', S(1)))*(c_ + x_*WC('d', S(1)))), x_), cons2, cons3, cons7, cons27, cons481, cons480) rule1855 = ReplacementRule(pattern1855, With1855) def With1856(b, d, c, a, x): q = Rt(-b/a, S(3)) rubi.append(1856) return Dist(d/(c*q + d*(-sqrt(S(3)) + S(1))), Int((-q*x - sqrt(S(3)) + S(1))/(sqrt(a + b*x**S(3))*(c + d*x)), x), x) + Dist(q/(c*q + d*(-sqrt(S(3)) + S(1))), Int(S(1)/sqrt(a + b*x**S(3)), x), x) pattern1856 = Pattern(Integral(S(1)/(sqrt(a_ + x_**S(3)*WC('b', S(1)))*(c_ + x_*WC('d', S(1)))), x_), cons2, cons3, cons7, cons27, cons482, cons479) rule1856 = ReplacementRule(pattern1856, With1856) def With1857(b, d, c, a, x): q = Rt(b/a, S(3)) rubi.append(1857) return Dist(d/(-c*q + d*(-sqrt(S(3)) + S(1))), Int((q*x - sqrt(S(3)) + S(1))/(sqrt(a + b*x**S(3))*(c + d*x)), x), x) - Dist(q/(-c*q + d*(-sqrt(S(3)) + S(1))), Int(S(1)/sqrt(a + b*x**S(3)), x), x) pattern1857 = Pattern(Integral(S(1)/(sqrt(a_ + x_**S(3)*WC('b', S(1)))*(c_ + x_*WC('d', S(1)))), x_), cons2, cons3, cons7, cons27, cons482, cons480) rule1857 = ReplacementRule(pattern1857, With1857) def With1858(f, b, d, c, a, x, e): if isinstance(x, (int, Integer, float, Float)): return False q = Rt(b/a, S(3)) if ZeroQ(-e*q + f*(S(1) + sqrt(S(3)))): return True return False pattern1858 = Pattern(Integral((e_ + x_*WC('f', S(1)))/(sqrt(a_ + x_**S(3)*WC('b', S(1)))*(c_ + x_*WC('d', S(1)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons481, cons479, CustomConstraint(With1858)) def replacement1858(f, b, d, c, a, x, e): q = Rt(b/a, S(3)) rubi.append(1858) return Dist(S(4)*S(3)**(S(1)/4)*f*sqrt((q**S(2)*x**S(2) - q*x + S(1))/(q*x + S(1) + sqrt(S(3)))**S(2))*sqrt(-sqrt(S(3)) + S(2))*(q*x + S(1))/(q*sqrt((q*x + S(1))/(q*x + S(1) + sqrt(S(3)))**S(2))*sqrt(a + b*x**S(3))), Subst(Int(S(1)/(sqrt(-x**S(2) + S(1))*sqrt(x**S(2) - S(4)*sqrt(S(3)) + S(7))*(-c*q + d*(-sqrt(S(3)) + S(1)) + x*(-c*q + d*(S(1) + sqrt(S(3)))))), x), x, (-q*x + S(-1) + sqrt(S(3)))/(q*x + S(1) + sqrt(S(3)))), x) rule1858 = ReplacementRule(pattern1858, replacement1858) def With1859(f, b, d, c, a, x, e): if isinstance(x, (int, Integer, float, Float)): return False q = Rt(b/a, S(3)) if NonzeroQ(-e*q + f*(S(1) + sqrt(S(3)))): return True return False pattern1859 = Pattern(Integral((x_*WC('f', S(1)) + WC('e', S(0)))/(sqrt(a_ + x_**S(3)*WC('b', S(1)))*(c_ + x_*WC('d', S(1)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons481, cons479, CustomConstraint(With1859)) def replacement1859(f, b, d, c, a, x, e): q = Rt(b/a, S(3)) rubi.append(1859) return Dist((-c*f + d*e)/(-c*q + d*(S(1) + sqrt(S(3)))), Int((q*x + S(1) + sqrt(S(3)))/(sqrt(a + b*x**S(3))*(c + d*x)), x), x) + Dist((-e*q + f*(S(1) + sqrt(S(3))))/(-c*q + d*(S(1) + sqrt(S(3)))), Int(S(1)/sqrt(a + b*x**S(3)), x), x) rule1859 = ReplacementRule(pattern1859, replacement1859) def With1860(f, b, d, c, a, x, e): if isinstance(x, (int, Integer, float, Float)): return False q = Rt(-b/a, S(3)) if ZeroQ(e*q + f*(S(1) + sqrt(S(3)))): return True return False pattern1860 = Pattern(Integral((e_ + x_*WC('f', S(1)))/(sqrt(a_ + x_**S(3)*WC('b', S(1)))*(c_ + x_*WC('d', S(1)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons481, cons480, CustomConstraint(With1860)) def replacement1860(f, b, d, c, a, x, e): q = Rt(-b/a, S(3)) rubi.append(1860) return Dist(-S(4)*S(3)**(S(1)/4)*f*sqrt((q**S(2)*x**S(2) + q*x + S(1))/(-q*x + S(1) + sqrt(S(3)))**S(2))*sqrt(-sqrt(S(3)) + S(2))*(-q*x + S(1))/(q*sqrt((-q*x + S(1))/(-q*x + S(1) + sqrt(S(3)))**S(2))*sqrt(a + b*x**S(3))), Subst(Int(S(1)/(sqrt(-x**S(2) + S(1))*sqrt(x**S(2) - S(4)*sqrt(S(3)) + S(7))*(c*q + d*(-sqrt(S(3)) + S(1)) + x*(c*q + d*(S(1) + sqrt(S(3)))))), x), x, (q*x + S(-1) + sqrt(S(3)))/(-q*x + S(1) + sqrt(S(3)))), x) rule1860 = ReplacementRule(pattern1860, replacement1860) def With1861(f, b, d, c, a, x, e): if isinstance(x, (int, Integer, float, Float)): return False q = Rt(-b/a, S(3)) if NonzeroQ(e*q + f*(S(1) + sqrt(S(3)))): return True return False pattern1861 = Pattern(Integral((x_*WC('f', S(1)) + WC('e', S(0)))/(sqrt(a_ + x_**S(3)*WC('b', S(1)))*(c_ + x_*WC('d', S(1)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons481, cons480, CustomConstraint(With1861)) def replacement1861(f, b, d, c, a, x, e): q = Rt(-b/a, S(3)) rubi.append(1861) return Dist((-c*f + d*e)/(c*q + d*(S(1) + sqrt(S(3)))), Int((-q*x + S(1) + sqrt(S(3)))/(sqrt(a + b*x**S(3))*(c + d*x)), x), x) + Dist((e*q + f*(S(1) + sqrt(S(3))))/(c*q + d*(S(1) + sqrt(S(3)))), Int(S(1)/sqrt(a + b*x**S(3)), x), x) rule1861 = ReplacementRule(pattern1861, replacement1861) def With1862(f, b, d, c, a, x, e): if isinstance(x, (int, Integer, float, Float)): return False q = Rt(-b/a, S(3)) if ZeroQ(e*q + f*(-sqrt(S(3)) + S(1))): return True return False pattern1862 = Pattern(Integral((e_ + x_*WC('f', S(1)))/(sqrt(a_ + x_**S(3)*WC('b', S(1)))*(c_ + x_*WC('d', S(1)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons482, cons479, CustomConstraint(With1862)) def replacement1862(f, b, d, c, a, x, e): q = Rt(-b/a, S(3)) rubi.append(1862) return Dist(S(4)*S(3)**(S(1)/4)*f*sqrt((q**S(2)*x**S(2) + q*x + S(1))/(-q*x - sqrt(S(3)) + S(1))**S(2))*sqrt(sqrt(S(3)) + S(2))*(-q*x + S(1))/(q*sqrt(-(-q*x + S(1))/(-q*x - sqrt(S(3)) + S(1))**S(2))*sqrt(a + b*x**S(3))), Subst(Int(S(1)/(sqrt(-x**S(2) + S(1))*sqrt(x**S(2) + S(4)*sqrt(S(3)) + S(7))*(c*q + d*(S(1) + sqrt(S(3))) + x*(c*q + d*(-sqrt(S(3)) + S(1))))), x), x, (-q*x + S(1) + sqrt(S(3)))/(q*x + S(-1) + sqrt(S(3)))), x) rule1862 = ReplacementRule(pattern1862, replacement1862) def With1863(f, b, d, c, a, x, e): if isinstance(x, (int, Integer, float, Float)): return False q = Rt(-b/a, S(3)) if NonzeroQ(e*q + f*(-sqrt(S(3)) + S(1))): return True return False pattern1863 = Pattern(Integral((x_*WC('f', S(1)) + WC('e', S(0)))/(sqrt(a_ + x_**S(3)*WC('b', S(1)))*(c_ + x_*WC('d', S(1)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons482, cons479, CustomConstraint(With1863)) def replacement1863(f, b, d, c, a, x, e): q = Rt(-b/a, S(3)) rubi.append(1863) return Dist((-c*f + d*e)/(c*q + d*(-sqrt(S(3)) + S(1))), Int((-q*x - sqrt(S(3)) + S(1))/(sqrt(a + b*x**S(3))*(c + d*x)), x), x) + Dist((e*q + f*(-sqrt(S(3)) + S(1)))/(c*q + d*(-sqrt(S(3)) + S(1))), Int(S(1)/sqrt(a + b*x**S(3)), x), x) rule1863 = ReplacementRule(pattern1863, replacement1863) def With1864(f, b, d, c, a, x, e): if isinstance(x, (int, Integer, float, Float)): return False q = Rt(b/a, S(3)) if ZeroQ(-e*q + f*(-sqrt(S(3)) + S(1))): return True return False pattern1864 = Pattern(Integral((e_ + x_*WC('f', S(1)))/(sqrt(a_ + x_**S(3)*WC('b', S(1)))*(c_ + x_*WC('d', S(1)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons482, cons480, CustomConstraint(With1864)) def replacement1864(f, b, d, c, a, x, e): q = Rt(b/a, S(3)) rubi.append(1864) return Dist(-S(4)*S(3)**(S(1)/4)*f*sqrt((q**S(2)*x**S(2) - q*x + S(1))/(q*x - sqrt(S(3)) + S(1))**S(2))*sqrt(sqrt(S(3)) + S(2))*(q*x + S(1))/(q*sqrt(-(q*x + S(1))/(q*x - sqrt(S(3)) + S(1))**S(2))*sqrt(a + b*x**S(3))), Subst(Int(S(1)/(sqrt(-x**S(2) + S(1))*sqrt(x**S(2) + S(4)*sqrt(S(3)) + S(7))*(-c*q + d*(S(1) + sqrt(S(3))) + x*(-c*q + d*(-sqrt(S(3)) + S(1))))), x), x, (q*x + S(1) + sqrt(S(3)))/(-q*x + S(-1) + sqrt(S(3)))), x) rule1864 = ReplacementRule(pattern1864, replacement1864) def With1865(f, b, d, c, a, x, e): if isinstance(x, (int, Integer, float, Float)): return False q = Rt(b/a, S(3)) if NonzeroQ(-e*q + f*(-sqrt(S(3)) + S(1))): return True return False pattern1865 = Pattern(Integral((x_*WC('f', S(1)) + WC('e', S(0)))/(sqrt(a_ + x_**S(3)*WC('b', S(1)))*(c_ + x_*WC('d', S(1)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons482, cons480, CustomConstraint(With1865)) def replacement1865(f, b, d, c, a, x, e): q = Rt(b/a, S(3)) rubi.append(1865) return Dist((-c*f + d*e)/(-c*q + d*(-sqrt(S(3)) + S(1))), Int((q*x - sqrt(S(3)) + S(1))/(sqrt(a + b*x**S(3))*(c + d*x)), x), x) + Dist((-e*q + f*(-sqrt(S(3)) + S(1)))/(-c*q + d*(-sqrt(S(3)) + S(1))), Int(S(1)/sqrt(a + b*x**S(3)), x), x) rule1865 = ReplacementRule(pattern1865, replacement1865) pattern1866 = Pattern(Integral(x_**WC('m', S(1))/(c_ + x_**n_*WC('d', S(1)) + sqrt(a_ + x_**n_*WC('b', S(1)))*WC('e', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons21, cons4, cons1072, cons500) def replacement1866(m, b, d, c, n, a, x, e): rubi.append(1866) return Dist(S(1)/n, Subst(Int(x**(S(-1) + (m + S(1))/n)/(c + d*x + e*sqrt(a + b*x)), x), x, x**n), x) rule1866 = ReplacementRule(pattern1866, replacement1866) pattern1867 = Pattern(Integral(WC('u', S(1))/(c_ + x_**n_*WC('d', S(1)) + sqrt(a_ + x_**n_*WC('b', S(1)))*WC('e', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons4, cons1072) def replacement1867(u, b, d, c, n, a, x, e): rubi.append(1867) return Dist(c, Int(u/(-a*e**S(2) + c**S(2) + c*d*x**n), x), x) - Dist(a*e, Int(u/(sqrt(a + b*x**n)*(-a*e**S(2) + c**S(2) + c*d*x**n)), x), x) rule1867 = ReplacementRule(pattern1867, replacement1867) pattern1868 = Pattern(Integral((A_ + x_**n_*WC('B', S(1)))/(a_ + x_**S(2)*WC('b', S(1)) + x_**n2_*WC('d', S(1)) + x_**n_*WC('c', S(1))), x_), cons2, cons3, cons7, cons27, cons34, cons35, cons4, cons46, cons963, cons1073, cons1074) def replacement1868(B, b, n2, d, c, n, a, x, A): rubi.append(1868) return Dist(A**S(2)*(n + S(-1)), Subst(Int(S(1)/(A**S(2)*b*x**S(2)*(n + S(-1))**S(2) + a), x), x, x/(A*(n + S(-1)) - B*x**n)), x) rule1868 = ReplacementRule(pattern1868, replacement1868) pattern1869 = Pattern(Integral(x_**WC('m', S(1))*(A_ + x_**WC('n', S(1))*WC('B', S(1)))/(a_ + x_**n2_*WC('d', S(1)) + x_**WC('k', S(1))*WC('b', S(1)) + x_**WC('n', S(1))*WC('c', S(1))), x_), cons2, cons3, cons7, cons27, cons34, cons35, cons21, cons4, cons46, cons1075, cons1076, cons1077) def replacement1869(B, k, m, b, n2, d, c, n, a, x, A): rubi.append(1869) return Dist(A**S(2)*(m - n + S(1))/(m + S(1)), Subst(Int(S(1)/(A**S(2)*b*x**S(2)*(m - n + S(1))**S(2) + a), x), x, x**(m + S(1))/(A*(m - n + S(1)) + B*x**n*(m + S(1)))), x) rule1869 = ReplacementRule(pattern1869, replacement1869) pattern1870 = Pattern(Integral((a_ + x_**n2_*WC('c', S(1)) + x_**n_*WC('b', S(1)))**p_*(d_ + g_*x_**n3_ + x_**n2_*WC('f', S(1)) + x_**n_*WC('e', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons4, cons46, cons931, cons226, cons702) def replacement1870(p, f, b, n2, g, d, n3, c, a, n, x, e): rubi.append(1870) return -Dist(S(1)/(a*c*n*(p + S(1))*(-S(4)*a*c + b**S(2))), Int((a + b*x**n + c*x**(S(2)*n))**(p + S(1))*Simp(a*b*(a*g + c*e) - S(2)*a*c*(a*f - c*d*(S(2)*n*(p + S(1)) + S(1))) - b**S(2)*c*d*(n*p + n + S(1)) + x**n*(a*b**S(2)*g*(n*(p + S(2)) + S(1)) - S(2)*a*c*(a*g*(n + S(1)) - c*e*(n*(S(2)*p + S(3)) + S(1))) - b*c*(a*f + c*d)*(n*(S(2)*p + S(3)) + S(1))), x), x), x) - Simp(x*(a + b*x**n + c*x**(S(2)*n))**(p + S(1))*(-a*b*(a*g + c*e) - S(2)*a*c*(-a*f + c*d) + b**S(2)*c*d + x**n*(-a*b**S(2)*g - S(2)*a*c*(-a*g + c*e) + b*c*(a*f + c*d)))/(a*c*n*(p + S(1))*(-S(4)*a*c + b**S(2))), x) rule1870 = ReplacementRule(pattern1870, replacement1870) pattern1871 = Pattern(Integral((a_ + x_**n2_*WC('c', S(1)) + x_**n_*WC('b', S(1)))**p_*(d_ + x_**n2_*WC('f', S(1)) + x_**n_*WC('e', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons4, cons46, cons226, cons702) def replacement1871(p, f, b, n2, d, c, a, n, x, e): rubi.append(1871) return -Dist(S(1)/(a*n*(p + S(1))*(-S(4)*a*c + b**S(2))), Int((a + b*x**n + c*x**(S(2)*n))**(p + S(1))*Simp(a*b*e - S(2)*a*(a*f - c*d*(S(2)*n*(p + S(1)) + S(1))) - b**S(2)*d*(n*p + n + S(1)) - x**n*(-S(2)*a*c*e*(n*(S(2)*p + S(3)) + S(1)) + b*(a*f + c*d)*(n*(S(2)*p + S(3)) + S(1))), x), x), x) - Simp(x*(a + b*x**n + c*x**(S(2)*n))**(p + S(1))*(-a*b*e - S(2)*a*(-a*f + c*d) + b**S(2)*d + x**n*(-S(2)*a*c*e + b*(a*f + c*d)))/(a*n*(p + S(1))*(-S(4)*a*c + b**S(2))), x) rule1871 = ReplacementRule(pattern1871, replacement1871) pattern1872 = Pattern(Integral((a_ + x_**n2_*WC('c', S(1)) + x_**n_*WC('b', S(1)))**p_*(d_ + g_*x_**n3_ + x_**n_*WC('e', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons208, cons4, cons46, cons931, cons226, cons702) def replacement1872(p, g, b, n2, d, n3, c, a, n, x, e): rubi.append(1872) return -Dist(S(1)/(a*c*n*(p + S(1))*(-S(4)*a*c + b**S(2))), Int((a + b*x**n + c*x**(S(2)*n))**(p + S(1))*Simp(a*b*(a*g + c*e) + S(2)*a*c**S(2)*d*(S(2)*n*(p + S(1)) + S(1)) - b**S(2)*c*d*(n*p + n + S(1)) + x**n*(a*b**S(2)*g*(n*(p + S(2)) + S(1)) - S(2)*a*c*(a*g*(n + S(1)) - c*e*(n*(S(2)*p + S(3)) + S(1))) - b*c**S(2)*d*(n*(S(2)*p + S(3)) + S(1))), x), x), x) - Simp(x*(a + b*x**n + c*x**(S(2)*n))**(p + S(1))*(-a*b*(a*g + c*e) - S(2)*a*c**S(2)*d + b**S(2)*c*d + x**n*(-a*b**S(2)*g - S(2)*a*c*(-a*g + c*e) + b*c**S(2)*d))/(a*c*n*(p + S(1))*(-S(4)*a*c + b**S(2))), x) rule1872 = ReplacementRule(pattern1872, replacement1872) pattern1873 = Pattern(Integral((a_ + x_**n2_*WC('c', S(1)) + x_**n_*WC('b', S(1)))**p_*(d_ + g_*x_**n3_ + x_**n2_*WC('f', S(1))), x_), cons2, cons3, cons7, cons27, cons125, cons208, cons4, cons46, cons931, cons226, cons702) def replacement1873(p, f, b, n2, g, d, n3, c, a, n, x): rubi.append(1873) return -Dist(S(1)/(a*c*n*(p + S(1))*(-S(4)*a*c + b**S(2))), Int((a + b*x**n + c*x**(S(2)*n))**(p + S(1))*Simp(a**S(2)*b*g - S(2)*a*c*(a*f - c*d*(S(2)*n*(p + S(1)) + S(1))) - b**S(2)*c*d*(n*p + n + S(1)) + x**n*(-S(2)*a**S(2)*c*g*(n + S(1)) + a*b**S(2)*g*(n*(p + S(2)) + S(1)) - b*c*(a*f + c*d)*(n*(S(2)*p + S(3)) + S(1))), x), x), x) - Simp(x*(a + b*x**n + c*x**(S(2)*n))**(p + S(1))*(-a**S(2)*b*g - S(2)*a*c*(-a*f + c*d) + b**S(2)*c*d + x**n*(S(2)*a**S(2)*c*g - a*b**S(2)*g + b*c*(a*f + c*d)))/(a*c*n*(p + S(1))*(-S(4)*a*c + b**S(2))), x) rule1873 = ReplacementRule(pattern1873, replacement1873) pattern1874 = Pattern(Integral((d_ + x_**n2_*WC('f', S(1)))*(a_ + x_**n2_*WC('c', S(1)) + x_**n_*WC('b', S(1)))**p_, x_), cons2, cons3, cons7, cons27, cons125, cons4, cons46, cons226, cons702) def replacement1874(p, f, b, n2, d, c, a, n, x): rubi.append(1874) return Dist(S(1)/(a*n*(p + S(1))*(-S(4)*a*c + b**S(2))), Int((a + b*x**n + c*x**(S(2)*n))**(p + S(1))*Simp(S(2)*a*(a*f - c*d*(S(2)*n*(p + S(1)) + S(1))) + b**S(2)*d*(n*p + n + S(1)) + b*x**n*(a*f + c*d)*(n*(S(2)*p + S(3)) + S(1)), x), x), x) - Simp(x*(a + b*x**n + c*x**(S(2)*n))**(p + S(1))*(-S(2)*a*(-a*f + c*d) + b**S(2)*d + b*x**n*(a*f + c*d))/(a*n*(p + S(1))*(-S(4)*a*c + b**S(2))), x) rule1874 = ReplacementRule(pattern1874, replacement1874) pattern1875 = Pattern(Integral((d_ + g_*x_**n3_)*(a_ + x_**n2_*WC('c', S(1)) + x_**n_*WC('b', S(1)))**p_, x_), cons2, cons3, cons7, cons27, cons208, cons4, cons46, cons931, cons226, cons702) def replacement1875(p, g, b, n2, d, n3, c, n, a, x): rubi.append(1875) return -Dist(S(1)/(a*c*n*(p + S(1))*(-S(4)*a*c + b**S(2))), Int((a + b*x**n + c*x**(S(2)*n))**(p + S(1))*Simp(a**S(2)*b*g + S(2)*a*c**S(2)*d*(S(2)*n*(p + S(1)) + S(1)) - b**S(2)*c*d*(n*p + n + S(1)) + x**n*(-S(2)*a**S(2)*c*g*(n + S(1)) + a*b**S(2)*g*(n*(p + S(2)) + S(1)) - b*c**S(2)*d*(n*(S(2)*p + S(3)) + S(1))), x), x), x) - Simp(x*(a + b*x**n + c*x**(S(2)*n))**(p + S(1))*(-a**S(2)*b*g - S(2)*a*c**S(2)*d + b**S(2)*c*d + x**n*(S(2)*a**S(2)*c*g - a*b**S(2)*g + b*c**S(2)*d))/(a*c*n*(p + S(1))*(-S(4)*a*c + b**S(2))), x) rule1875 = ReplacementRule(pattern1875, replacement1875) pattern1876 = Pattern(Integral((a_ + x_**n2_*WC('c', S(1)))**p_*(d_ + g_*x_**n3_ + x_**n2_*WC('f', S(1)) + x_**n_*WC('e', S(1))), x_), cons2, cons7, cons27, cons48, cons125, cons208, cons4, cons46, cons931, cons702) def replacement1876(p, f, g, n2, d, n3, c, a, n, x, e): rubi.append(1876) return -Dist(-S(1)/(S(4)*a**S(2)*c**S(2)*n*(p + S(1))), Int((a + c*x**(S(2)*n))**(p + S(1))*Simp(-S(2)*a*c*x**n*(a*g*(n + S(1)) - c*e*(n*(S(2)*p + S(3)) + S(1))) - S(2)*a*c*(a*f - c*d*(S(2)*n*(p + S(1)) + S(1))), x), x), x) - Simp(-x*(a + c*x**(S(2)*n))**(p + S(1))*(-S(2)*a*c*x**n*(-a*g + c*e) - S(2)*a*c*(-a*f + c*d))/(S(4)*a**S(2)*c**S(2)*n*(p + S(1))), x) rule1876 = ReplacementRule(pattern1876, replacement1876) pattern1877 = Pattern(Integral((a_ + x_**n2_*WC('c', S(1)))**p_*(d_ + x_**n2_*WC('f', S(1)) + x_**n_*WC('e', S(1))), x_), cons2, cons7, cons27, cons48, cons125, cons4, cons46, cons702) def replacement1877(p, f, n2, d, c, a, n, x, e): rubi.append(1877) return -Dist(-S(1)/(S(4)*a**S(2)*c*n*(p + S(1))), Int((a + c*x**(S(2)*n))**(p + S(1))*Simp(S(2)*a*c*e*x**n*(n*(S(2)*p + S(3)) + S(1)) - S(2)*a*(a*f - c*d*(S(2)*n*(p + S(1)) + S(1))), x), x), x) - Simp(-x*(a + c*x**(S(2)*n))**(p + S(1))*(-S(2)*a*c*e*x**n - S(2)*a*(-a*f + c*d))/(S(4)*a**S(2)*c*n*(p + S(1))), x) rule1877 = ReplacementRule(pattern1877, replacement1877) pattern1878 = Pattern(Integral((a_ + x_**n2_*WC('c', S(1)))**p_*(d_ + g_*x_**n3_ + x_**n_*WC('e', S(1))), x_), cons2, cons7, cons27, cons48, cons208, cons4, cons46, cons931, cons702) def replacement1878(p, g, n2, d, n3, c, a, n, x, e): rubi.append(1878) return -Dist(-S(1)/(S(4)*a**S(2)*c**S(2)*n*(p + S(1))), Int((a + c*x**(S(2)*n))**(p + S(1))*Simp(S(2)*a*c**S(2)*d*(S(2)*n*(p + S(1)) + S(1)) - S(2)*a*c*x**n*(a*g*(n + S(1)) - c*e*(n*(S(2)*p + S(3)) + S(1))), x), x), x) - Simp(-x*(a + c*x**(S(2)*n))**(p + S(1))*(-S(2)*a*c**S(2)*d - S(2)*a*c*x**n*(-a*g + c*e))/(S(4)*a**S(2)*c**S(2)*n*(p + S(1))), x) rule1878 = ReplacementRule(pattern1878, replacement1878) def With1879(f, b, g, d, c, a, x, e): q = Rt((S(12)*a**S(2)*g**S(2) - a*c*f**S(2) + f*(-S(2)*a*b*g + S(3)*c**S(2)*d))/(c*g*(-a*f + S(3)*c*d)), S(2)) r = Rt((a*c*f**S(2) - f*(S(2)*a*b*g + S(3)*c**S(2)*d) + S(4)*g*(a**S(2)*g + b*c*d))/(c*g*(-a*f + S(3)*c*d)), S(2)) rubi.append(1879) return -Simp(c*ArcTan((r - S(2)*x)/q)/(g*q), x) + Simp(c*ArcTan((r + S(2)*x)/q)/(g*q), x) - Simp(c*ArcTan(x*(-a*f + S(3)*c*d)*(S(6)*a**S(2)*b*g**S(2) - S(2)*a**S(2)*c*f*g - a*b**S(2)*f*g + b*c**S(2)*d*f + c**S(2)*g*x**S(4)*(-a*f + S(3)*c*d) + c*x**S(2)*(S(2)*a**S(2)*g**S(2) - a*c*f**S(2) - b*c*d*g + S(3)*c**S(2)*d*f))/(g*q*(-S(2)*a**S(2)*g + b*c*d)*(S(4)*a**S(2)*g - a*b*f + b*c*d)))/(g*q), x) pattern1879 = Pattern(Integral((x_**S(4)*WC('c', S(1)) + x_**S(2)*WC('b', S(1)) + WC('a', S(0)))/(d_ + x_**S(6)*WC('g', S(1)) + x_**S(4)*WC('f', S(1)) + x_**S(2)*WC('e', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons1078, cons1079, cons1080, cons1081, cons1082, cons1083) rule1879 = ReplacementRule(pattern1879, With1879) def With1880(f, g, d, a, c, x, e): q = Rt((S(12)*a**S(2)*g**S(2) - a*c*f**S(2) + S(3)*c**S(2)*d*f)/(c*g*(-a*f + S(3)*c*d)), S(2)) r = Rt((S(4)*a**S(2)*g**S(2) + a*c*f**S(2) - S(3)*c**S(2)*d*f)/(c*g*(-a*f + S(3)*c*d)), S(2)) rubi.append(1880) return -Simp(c*ArcTan((r - S(2)*x)/q)/(g*q), x) + Simp(c*ArcTan((r + S(2)*x)/q)/(g*q), x) - Simp(c*ArcTan(c*x*(-a*f + S(3)*c*d)*(S(2)*a**S(2)*f*g - c*g*x**S(4)*(-a*f + S(3)*c*d) - x**S(2)*(S(2)*a**S(2)*g**S(2) - a*c*f**S(2) + S(3)*c**S(2)*d*f))/(S(8)*a**S(4)*g**S(3)*q))/(g*q), x) pattern1880 = Pattern(Integral((x_**S(4)*WC('c', S(1)) + WC('a', S(0)))/(d_ + x_**S(6)*WC('g', S(1)) + x_**S(4)*WC('f', S(1)) + x_**S(2)*WC('e', S(1))), x_), cons2, cons7, cons27, cons48, cons125, cons208, cons1084, cons1085, cons1080, cons1086) rule1880 = ReplacementRule(pattern1880, With1880) def With1881(v, x, p, u): if isinstance(x, (int, Integer, float, Float)): return False try: m = Exponent(u, x) n = Exponent(v, x) c = Coefficient(u, x, m)/((m + n*p + S(1))*Coefficient(v, x, n)) c = Coefficient(u, x, m)/((m + n*p + S(1))*Coefficient(v, x, n)) w = Apart(-c*x**(m - n)*(v*(m - n + S(1)) + x*(p + S(1))*D(v, x)) + u, x) res = And(Inequality(S(1), Less, n, LessEqual, m + S(1)), Less(m + n*p, S(-1)), FalseQ(DerivativeDivides(v, u, x))) except (TypeError, AttributeError): return False if res: return True return False pattern1881 = Pattern(Integral(u_*v_**p_, x_), cons13, cons137, cons804, cons1017, cons1087, cons1088, cons1089, CustomConstraint(With1881)) def replacement1881(v, x, p, u): m = Exponent(u, x) n = Exponent(v, x) c = Coefficient(u, x, m)/((m + n*p + S(1))*Coefficient(v, x, n)) c = Coefficient(u, x, m)/((m + n*p + S(1))*Coefficient(v, x, n)) w = Apart(-c*x**(m - n)*(v*(m - n + S(1)) + x*(p + S(1))*D(v, x)) + u, x) rubi.append(1881) return Simp(If(ZeroQ(w), c*v**(p + 1)*x**(m - n + 1), c*v**(p + 1)*x**(m - n + 1) + Int(v**p*w, x)), x) rule1881 = ReplacementRule(pattern1881, replacement1881) return [rule1473, rule1474, rule1475, rule1476, rule1477, rule1478, rule1479, rule1480, rule1481, rule1482, rule1483, rule1484, rule1485, rule1486, rule1487, rule1488, rule1489, rule1490, rule1491, rule1492, rule1493, rule1494, rule1495, rule1496, rule1497, rule1498, rule1499, rule1500, rule1501, rule1502, rule1503, rule1504, rule1505, rule1506, rule1507, rule1508, rule1509, rule1510, rule1511, rule1512, rule1513, rule1514, rule1515, rule1516, rule1517, rule1518, rule1519, rule1520, rule1521, rule1522, rule1523, rule1524, rule1525, rule1526, rule1527, rule1528, rule1529, rule1530, rule1531, rule1532, rule1533, rule1534, rule1535, rule1536, rule1537, rule1538, rule1539, rule1540, rule1541, rule1542, rule1543, rule1544, rule1545, rule1546, rule1547, rule1548, rule1549, rule1550, rule1551, rule1552, rule1553, rule1554, rule1555, rule1556, rule1557, rule1558, rule1559, rule1560, rule1561, rule1562, rule1563, rule1564, rule1565, rule1566, rule1567, rule1568, rule1569, rule1570, rule1571, rule1572, rule1573, rule1574, rule1575, rule1576, rule1577, rule1578, rule1579, rule1580, rule1581, rule1582, rule1583, rule1584, rule1585, rule1586, rule1587, rule1588, rule1589, rule1590, rule1591, rule1592, rule1593, rule1594, rule1595, rule1596, rule1597, rule1598, rule1599, rule1600, rule1601, rule1602, rule1603, rule1604, rule1605, rule1606, rule1607, rule1608, rule1609, rule1610, rule1611, rule1612, rule1613, rule1614, rule1615, rule1616, rule1617, rule1618, rule1619, rule1620, rule1621, rule1622, rule1623, rule1624, rule1625, rule1626, rule1627, rule1628, rule1629, rule1630, rule1631, rule1632, rule1633, rule1634, rule1635, rule1636, rule1637, rule1638, rule1639, rule1640, rule1641, rule1642, rule1643, rule1644, rule1645, rule1646, rule1647, rule1648, rule1649, rule1650, rule1651, rule1652, rule1653, rule1654, rule1655, rule1656, rule1657, rule1658, rule1659, rule1660, rule1661, rule1662, rule1663, rule1664, rule1665, rule1666, rule1667, rule1668, rule1669, rule1670, rule1671, rule1672, rule1673, rule1674, rule1675, rule1676, rule1677, rule1678, rule1679, rule1680, rule1681, rule1682, rule1683, rule1684, rule1685, rule1686, rule1687, rule1688, rule1689, rule1690, rule1691, rule1692, rule1693, rule1694, rule1695, rule1696, rule1697, rule1698, rule1699, rule1700, rule1701, rule1702, rule1703, rule1704, rule1705, rule1706, rule1707, rule1708, rule1709, rule1710, rule1711, rule1712, rule1713, rule1714, rule1715, rule1716, rule1717, rule1718, rule1719, rule1720, rule1721, rule1722, rule1723, rule1724, rule1725, rule1726, rule1727, rule1728, rule1729, rule1730, rule1731, rule1732, rule1733, rule1734, rule1735, rule1736, rule1737, rule1738, rule1739, rule1740, rule1741, rule1742, rule1743, rule1744, rule1745, rule1746, rule1747, rule1748, rule1749, rule1750, rule1751, rule1752, rule1753, rule1754, rule1755, rule1756, rule1757, rule1758, rule1759, rule1760, rule1761, rule1762, rule1763, rule1764, rule1765, rule1766, rule1767, rule1768, rule1769, rule1770, rule1771, rule1772, rule1773, rule1774, rule1775, rule1776, rule1777, rule1778, rule1779, rule1780, rule1781, rule1782, rule1783, rule1784, rule1785, rule1786, rule1787, rule1788, rule1789, rule1790, rule1791, rule1792, rule1793, rule1794, rule1795, rule1796, rule1797, rule1798, rule1799, rule1800, rule1801, rule1802, rule1803, rule1804, rule1805, rule1806, rule1807, rule1808, rule1809, rule1810, rule1811, rule1812, rule1813, rule1814, rule1815, rule1816, rule1817, rule1818, rule1819, rule1820, rule1821, rule1822, rule1823, rule1824, rule1825, rule1826, rule1827, rule1828, rule1829, rule1830, rule1831, rule1832, rule1833, rule1834, rule1835, rule1836, rule1837, rule1838, rule1839, rule1840, rule1841, rule1842, rule1843, rule1844, rule1845, rule1846, rule1847, rule1848, rule1849, rule1850, rule1851, rule1852, rule1853, rule1854, rule1855, rule1856, rule1857, rule1858, rule1859, rule1860, rule1861, rule1862, rule1863, rule1864, rule1865, rule1866, rule1867, rule1868, rule1869, rule1870, rule1871, rule1872, rule1873, rule1874, rule1875, rule1876, rule1877, rule1878, rule1879, rule1880, rule1881, ]
71d4bd69a78328045c28c9ebc67389e45b58e192a3056ddce46274439c890da8
''' This code is automatically generated. Never edit it manually. For details of generating the code see `rubi_parsing_guide.md` in `parsetools`. ''' from sympy.external import import_module matchpy = import_module("matchpy") from sympy.utilities.decorator import doctest_depends_on if matchpy: from matchpy import Pattern, ReplacementRule, CustomConstraint, is_match from sympy.integrals.rubi.utility_function import ( Int, Sum, Set, With, Module, Scan, MapAnd, FalseQ, ZeroQ, NegativeQ, NonzeroQ, FreeQ, NFreeQ, List, Log, PositiveQ, PositiveIntegerQ, NegativeIntegerQ, IntegerQ, IntegersQ, ComplexNumberQ, PureComplexNumberQ, RealNumericQ, PositiveOrZeroQ, NegativeOrZeroQ, FractionOrNegativeQ, NegQ, Equal, Unequal, IntPart, FracPart, RationalQ, ProductQ, SumQ, NonsumQ, Subst, First, Rest, SqrtNumberQ, SqrtNumberSumQ, LinearQ, Sqrt, ArcCosh, Coefficient, Denominator, Hypergeometric2F1, Not, Simplify, FractionalPart, IntegerPart, AppellF1, EllipticPi, EllipticE, EllipticF, ArcTan, ArcCot, ArcCoth, ArcTanh, ArcSin, ArcSinh, ArcCos, ArcCsc, ArcSec, ArcCsch, ArcSech, Sinh, Tanh, Cosh, Sech, Csch, Coth, LessEqual, Less, Greater, GreaterEqual, FractionQ, IntLinearcQ, Expand, IndependentQ, PowerQ, IntegerPowerQ, PositiveIntegerPowerQ, FractionalPowerQ, AtomQ, ExpQ, LogQ, Head, MemberQ, TrigQ, SinQ, CosQ, TanQ, CotQ, SecQ, CscQ, Sin, Cos, Tan, Cot, Sec, Csc, HyperbolicQ, SinhQ, CoshQ, TanhQ, CothQ, SechQ, CschQ, InverseTrigQ, SinCosQ, SinhCoshQ, LeafCount, Numerator, NumberQ, NumericQ, Length, ListQ, Im, Re, InverseHyperbolicQ, InverseFunctionQ, TrigHyperbolicFreeQ, InverseFunctionFreeQ, RealQ, EqQ, FractionalPowerFreeQ, ComplexFreeQ, PolynomialQ, FactorSquareFree, PowerOfLinearQ, Exponent, QuadraticQ, LinearPairQ, BinomialParts, TrinomialParts, PolyQ, EvenQ, OddQ, PerfectSquareQ, NiceSqrtAuxQ, NiceSqrtQ, Together, PosAux, PosQ, CoefficientList, ReplaceAll, ExpandLinearProduct, GCD, ContentFactor, NumericFactor, NonnumericFactors, MakeAssocList, GensymSubst, KernelSubst, ExpandExpression, Apart, SmartApart, MatchQ, PolynomialQuotientRemainder, FreeFactors, NonfreeFactors, RemoveContentAux, RemoveContent, FreeTerms, NonfreeTerms, ExpandAlgebraicFunction, CollectReciprocals, ExpandCleanup, AlgebraicFunctionQ, Coeff, LeadTerm, RemainingTerms, LeadFactor, RemainingFactors, LeadBase, LeadDegree, Numer, Denom, hypergeom, Expon, MergeMonomials, PolynomialDivide, BinomialQ, TrinomialQ, GeneralizedBinomialQ, GeneralizedTrinomialQ, FactorSquareFreeList, PerfectPowerTest, SquareFreeFactorTest, RationalFunctionQ, RationalFunctionFactors, NonrationalFunctionFactors, Reverse, RationalFunctionExponents, RationalFunctionExpand, ExpandIntegrand, SimplerQ, SimplerSqrtQ, SumSimplerQ, BinomialDegree, TrinomialDegree, CancelCommonFactors, SimplerIntegrandQ, GeneralizedBinomialDegree, GeneralizedBinomialParts, GeneralizedTrinomialDegree, GeneralizedTrinomialParts, MonomialQ, MonomialSumQ, MinimumMonomialExponent, MonomialExponent, LinearMatchQ, PowerOfLinearMatchQ, QuadraticMatchQ, CubicMatchQ, BinomialMatchQ, TrinomialMatchQ, GeneralizedBinomialMatchQ, GeneralizedTrinomialMatchQ, QuotientOfLinearsMatchQ, PolynomialTermQ, PolynomialTerms, NonpolynomialTerms, PseudoBinomialParts, NormalizePseudoBinomial, PseudoBinomialPairQ, PseudoBinomialQ, PolynomialGCD, PolyGCD, AlgebraicFunctionFactors, NonalgebraicFunctionFactors, QuotientOfLinearsP, QuotientOfLinearsParts, QuotientOfLinearsQ, Flatten, Sort, AbsurdNumberQ, AbsurdNumberFactors, NonabsurdNumberFactors, SumSimplerAuxQ, Prepend, Drop, CombineExponents, FactorInteger, FactorAbsurdNumber, SubstForInverseFunction, SubstForFractionalPower, SubstForFractionalPowerOfQuotientOfLinears, FractionalPowerOfQuotientOfLinears, SubstForFractionalPowerQ, SubstForFractionalPowerAuxQ, FractionalPowerOfSquareQ, FractionalPowerSubexpressionQ, Apply, FactorNumericGcd, MergeableFactorQ, MergeFactor, MergeFactors, TrigSimplifyQ, TrigSimplify, TrigSimplifyRecur, Order, FactorOrder, Smallest, OrderedQ, MinimumDegree, PositiveFactors, Sign, NonpositiveFactors, PolynomialInAuxQ, PolynomialInQ, ExponentInAux, ExponentIn, PolynomialInSubstAux, PolynomialInSubst, Distrib, DistributeDegree, FunctionOfPower, DivideDegreesOfFactors, MonomialFactor, FullSimplify, FunctionOfLinearSubst, FunctionOfLinear, NormalizeIntegrand, NormalizeIntegrandAux, NormalizeIntegrandFactor, NormalizeIntegrandFactorBase, NormalizeTogether, NormalizeLeadTermSigns, AbsorbMinusSign, NormalizeSumFactors, SignOfFactor, NormalizePowerOfLinear, SimplifyIntegrand, SimplifyTerm, TogetherSimplify, SmartSimplify, SubstForExpn, ExpandToSum, UnifySum, UnifyTerms, UnifyTerm, CalculusQ, FunctionOfInverseLinear, PureFunctionOfSinhQ, PureFunctionOfTanhQ, PureFunctionOfCoshQ, IntegerQuotientQ, OddQuotientQ, EvenQuotientQ, FindTrigFactor, FunctionOfSinhQ, FunctionOfCoshQ, OddHyperbolicPowerQ, FunctionOfTanhQ, FunctionOfTanhWeight, FunctionOfHyperbolicQ, SmartNumerator, SmartDenominator, SubstForAux, ActivateTrig, ExpandTrig, TrigExpand, SubstForTrig, SubstForHyperbolic, InertTrigFreeQ, LCM, SubstForFractionalPowerOfLinear, FractionalPowerOfLinear, InverseFunctionOfLinear, InertTrigQ, InertReciprocalQ, DeactivateTrig, FixInertTrigFunction, DeactivateTrigAux, PowerOfInertTrigSumQ, PiecewiseLinearQ, KnownTrigIntegrandQ, KnownSineIntegrandQ, KnownTangentIntegrandQ, KnownCotangentIntegrandQ, KnownSecantIntegrandQ, TryPureTanSubst, TryTanhSubst, TryPureTanhSubst, AbsurdNumberGCD, AbsurdNumberGCDList, ExpandTrigExpand, ExpandTrigReduce, ExpandTrigReduceAux, NormalizeTrig, TrigToExp, ExpandTrigToExp, TrigReduce, FunctionOfTrig, AlgebraicTrigFunctionQ, FunctionOfHyperbolic, FunctionOfQ, FunctionOfExpnQ, PureFunctionOfSinQ, PureFunctionOfCosQ, PureFunctionOfTanQ, PureFunctionOfCotQ, FunctionOfCosQ, FunctionOfSinQ, OddTrigPowerQ, FunctionOfTanQ, FunctionOfTanWeight, FunctionOfTrigQ, FunctionOfDensePolynomialsQ, FunctionOfLog, PowerVariableExpn, PowerVariableDegree, PowerVariableSubst, EulerIntegrandQ, FunctionOfSquareRootOfQuadratic, SquareRootOfQuadraticSubst, Divides, EasyDQ, ProductOfLinearPowersQ, Rt, NthRoot, AtomBaseQ, SumBaseQ, NegSumBaseQ, AllNegTermQ, SomeNegTermQ, TrigSquareQ, RtAux, TrigSquare, IntSum, IntTerm, Map2, ConstantFactor, SameQ, ReplacePart, CommonFactors, MostMainFactorPosition, FunctionOfExponentialQ, FunctionOfExponential, FunctionOfExponentialFunction, FunctionOfExponentialFunctionAux, FunctionOfExponentialTest, FunctionOfExponentialTestAux, stdev, rubi_test, If, IntQuadraticQ, IntBinomialQ, RectifyTangent, RectifyCotangent, Inequality, Condition, Simp, SimpHelp, SplitProduct, SplitSum, SubstFor, SubstForAux, FresnelS, FresnelC, Erfc, Erfi, Gamma, FunctionOfTrigOfLinearQ, ElementaryFunctionQ, Complex, UnsameQ, _SimpFixFactor, SimpFixFactor, _FixSimplify, FixSimplify, _SimplifyAntiderivativeSum, SimplifyAntiderivativeSum, _SimplifyAntiderivative, SimplifyAntiderivative, _TrigSimplifyAux, TrigSimplifyAux, Cancel, Part, PolyLog, D, Dist, Sum_doit, PolynomialQuotient, Floor, PolynomialRemainder, Factor, PolyLog, CosIntegral, SinIntegral, LogIntegral, SinhIntegral, CoshIntegral, Rule, Erf, PolyGamma, ExpIntegralEi, ExpIntegralE, LogGamma , UtilityOperator, Factorial, Zeta, ProductLog, DerivativeDivides, HypergeometricPFQ, IntHide, OneQ, Null, rubi_exp as exp, rubi_log as log, Discriminant, Negative, Quotient ) from sympy import (Integral, S, sqrt, And, Or, Integer, Float, Mod, I, Abs, simplify, Mul, Add, Pow, sign, EulerGamma) from sympy.integrals.rubi.symbol import WC from sympy.core.symbol import symbols, Symbol from sympy.functions import (sin, cos, tan, cot, csc, sec, sqrt, erf) from sympy.functions.elementary.hyperbolic import (acosh, asinh, atanh, acoth, acsch, asech, cosh, sinh, tanh, coth, sech, csch) from sympy.functions.elementary.trigonometric import (atan, acsc, asin, acot, acos, asec, atan2) from sympy import pi as Pi A_, B_, C_, F_, G_, H_, a_, b_, c_, d_, e_, f_, g_, h_, i_, j_, k_, l_, m_, n_, p_, q_, r_, t_, u_, v_, s_, w_, x_, y_, z_ = [WC(i) for i in 'ABCFGHabcdefghijklmnpqrtuvswxyz'] a1_, a2_, b1_, b2_, c1_, c2_, d1_, d2_, n1_, n2_, e1_, e2_, f1_, f2_, g1_, g2_, n1_, n2_, n3_, Pq_, Pm_, Px_, Qm_, Qr_, Qx_, jn_, mn_, non2_, RFx_, RGx_ = [WC(i) for i in ['a1', 'a2', 'b1', 'b2', 'c1', 'c2', 'd1', 'd2', 'n1', 'n2', 'e1', 'e2', 'f1', 'f2', 'g1', 'g2', 'n1', 'n2', 'n3', 'Pq', 'Pm', 'Px', 'Qm', 'Qr', 'Qx', 'jn', 'mn', 'non2', 'RFx', 'RGx']] i, ii , Pqq, Q, R, r, C, k, u = symbols('i ii Pqq Q R r C k u') _UseGamma = False ShowSteps = False StepCounter = None def integrand_simplification(rubi): from sympy.integrals.rubi.constraints import cons1, cons2, cons3, cons4, cons5, cons6, cons7, cons8, cons9, cons10, cons11, cons12, cons13, cons14, cons15, cons16, cons17, cons18, cons19, cons20, cons21, cons22, cons23, cons24, cons25, cons26, cons27, cons28, cons29, cons30, cons31, cons32, cons33, cons34, cons35, cons36, cons37, cons38, cons39, cons40, cons41, cons42, cons43, cons44, cons45, cons46, cons47, cons48, cons49, cons50, cons51, cons52, cons53, cons54, cons55, cons56, cons57, cons58, cons59, cons60, cons61, cons62, cons63, cons64, cons65 pattern1 = Pattern(Integral((a_ + x_**WC('n', S(1))*WC('b', S(1)))**WC('p', S(1))*WC('u', S(1)), x_), cons2, cons3, cons4, cons5, cons1) def replacement1(p, u, b, a, n, x): rubi.append(1) return Int(u*(b*x**n)**p, x) rule1 = ReplacementRule(pattern1, replacement1) pattern2 = Pattern(Integral((a_ + x_**WC('j', S(1))*WC('c', S(1)) + x_**WC('n', S(1))*WC('b', S(1)))**WC('p', S(1))*WC('u', S(1)), x_), cons2, cons3, cons7, cons4, cons5, cons6, cons1) def replacement2(p, u, j, b, c, n, a, x): rubi.append(2) return Int(u*(b*x**n + c*x**(S(2)*n))**p, x) rule2 = ReplacementRule(pattern2, replacement2) pattern3 = Pattern(Integral((x_**WC('j', S(1))*WC('c', S(1)) + x_**WC('n', S(1))*WC('b', S(1)) + WC('a', S(0)))**WC('p', S(1))*WC('u', S(1)), x_), cons2, cons3, cons7, cons4, cons5, cons6, cons8) def replacement3(p, u, j, b, a, c, n, x): rubi.append(3) return Int(u*(a + c*x**(S(2)*n))**p, x) rule3 = ReplacementRule(pattern3, replacement3) pattern4 = Pattern(Integral((x_**WC('j', S(1))*WC('c', S(1)) + x_**WC('n', S(1))*WC('b', S(1)) + WC('a', S(0)))**WC('p', S(1))*WC('u', S(1)), x_), cons2, cons3, cons7, cons4, cons5, cons6, cons9) def replacement4(p, u, j, b, a, c, n, x): rubi.append(4) return Int(u*(a + b*x**n)**p, x) rule4 = ReplacementRule(pattern4, replacement4) pattern5 = Pattern(Integral((v_*WC('a', S(1)) + v_*WC('b', S(1)) + WC('w', S(0)))**WC('p', S(1))*WC('u', S(1)), x_), cons2, cons3, cons10) def replacement5(v, w, p, u, b, a, x): rubi.append(5) return Int(u*(v*(a + b) + w)**p, x) rule5 = ReplacementRule(pattern5, replacement5) pattern6 = Pattern(Integral(Pm_**p_*WC('u', S(1)), x_), cons11, cons12, cons13) def replacement6(x, p, Pm, u): rubi.append(6) return Int(Pm**p*u, x) rule6 = ReplacementRule(pattern6, replacement6) pattern7 = Pattern(Integral(a_, x_), cons2, cons2) def replacement7(x, a): rubi.append(7) return Simp(a*x, x) rule7 = ReplacementRule(pattern7, replacement7) pattern8 = Pattern(Integral(a_*(b_ + x_*WC('c', S(1))), x_), cons2, cons3, cons7, cons14) def replacement8(x, c, b, a): rubi.append(8) return Simp(a*(b + c*x)**S(2)/(S(2)*c), x) rule8 = ReplacementRule(pattern8, replacement8) pattern9 = Pattern(Integral(-u_, x_)) def replacement9(x, u): rubi.append(9) return Dist(S(-1), Int(u, x), x) rule9 = ReplacementRule(pattern9, replacement9) pattern10 = Pattern(Integral(u_*Complex(S(0), a_), x_), cons2, cons15) def replacement10(x, a, u): rubi.append(10) return Dist(Complex(S(0), a), Int(u, x), x) rule10 = ReplacementRule(pattern10, replacement10) pattern11 = Pattern(Integral(a_*u_, x_), cons2, cons2) def replacement11(x, a, u): rubi.append(11) return Dist(a, Int(u, x), x) rule11 = ReplacementRule(pattern11, replacement11) pattern12 = Pattern(Integral(u_, x_), cons16) def replacement12(x, u): rubi.append(12) return Simp(IntSum(u, x), x) rule12 = ReplacementRule(pattern12, replacement12) pattern13 = Pattern(Integral(v_**WC('m', S(1))*(b_*v_)**n_*WC('u', S(1)), x_), cons3, cons4, cons17) def replacement13(v, u, m, b, n, x): rubi.append(13) return Dist(b**(-m), Int(u*(b*v)**(m + n), x), x) rule13 = ReplacementRule(pattern13, replacement13) pattern14 = Pattern(Integral((v_*WC('a', S(1)))**m_*(v_*WC('b', S(1)))**n_*WC('u', S(1)), x_), cons2, cons3, cons21, cons18, cons19, cons20) def replacement14(v, u, m, b, a, n, x): rubi.append(14) return Dist(a**(m + S(1)/2)*b**(n + S(-1)/2)*sqrt(b*v)/sqrt(a*v), Int(u*v**(m + n), x), x) rule14 = ReplacementRule(pattern14, replacement14) pattern15 = Pattern(Integral((v_*WC('a', S(1)))**m_*(v_*WC('b', S(1)))**n_*WC('u', S(1)), x_), cons2, cons3, cons21, cons18, cons22, cons20) def replacement15(v, u, m, b, a, n, x): rubi.append(15) return Dist(a**(m + S(-1)/2)*b**(n + S(1)/2)*sqrt(a*v)/sqrt(b*v), Int(u*v**(m + n), x), x) rule15 = ReplacementRule(pattern15, replacement15) pattern16 = Pattern(Integral((v_*WC('a', S(1)))**m_*(v_*WC('b', S(1)))**n_*WC('u', S(1)), x_), cons2, cons3, cons21, cons4, cons18, cons23, cons20) def replacement16(v, u, m, b, a, n, x): rubi.append(16) return Dist(a**(m + n)*(a*v)**(-n)*(b*v)**n, Int(u*v**(m + n), x), x) rule16 = ReplacementRule(pattern16, replacement16) pattern17 = Pattern(Integral((v_*WC('a', S(1)))**m_*(v_*WC('b', S(1)))**n_*WC('u', S(1)), x_), cons2, cons3, cons21, cons4, cons18, cons23, cons24) def replacement17(v, u, m, b, a, n, x): rubi.append(17) return Dist(a**(-IntPart(n))*b**IntPart(n)*(a*v)**(-FracPart(n))*(b*v)**FracPart(n), Int(u*(a*v)**(m + n), x), x) rule17 = ReplacementRule(pattern17, replacement17) pattern18 = Pattern(Integral((a_ + v_*WC('b', S(1)))**WC('m', S(1))*(c_ + v_*WC('d', S(1)))**WC('n', S(1))*WC('u', S(1)), x_), cons2, cons3, cons7, cons27, cons4, cons25, cons17, cons26) def replacement18(v, u, m, b, d, a, n, c, x): rubi.append(18) return Dist((b/d)**m, Int(u*(c + d*v)**(m + n), x), x) rule18 = ReplacementRule(pattern18, replacement18) pattern19 = Pattern(Integral((a_ + v_*WC('b', S(1)))**m_*(c_ + v_*WC('d', S(1)))**n_*WC('u', S(1)), x_), cons2, cons3, cons7, cons27, cons21, cons4, cons25, cons28, cons29) def replacement19(v, u, m, b, d, a, c, n, x): rubi.append(19) return Dist((b/d)**m, Int(u*(c + d*v)**(m + n), x), x) rule19 = ReplacementRule(pattern19, replacement19) pattern20 = Pattern(Integral((a_ + v_*WC('b', S(1)))**m_*(c_ + v_*WC('d', S(1)))**n_*WC('u', S(1)), x_), cons2, cons3, cons7, cons27, cons21, cons4, cons25, cons30) def replacement20(v, u, m, b, d, a, c, n, x): rubi.append(20) return Dist((a + b*v)**m*(c + d*v)**(-m), Int(u*(c + d*v)**(m + n), x), x) rule20 = ReplacementRule(pattern20, replacement20) pattern21 = Pattern(Integral((v_*WC('a', S(1)))**m_*(v_**S(2)*WC('c', S(1)) + v_*WC('b', S(1)))*WC('u', S(1)), x_), cons2, cons3, cons7, cons31, cons32) def replacement21(v, u, m, b, c, a, x): rubi.append(21) return Dist(S(1)/a, Int(u*(a*v)**(m + S(1))*(b + c*v), x), x) rule21 = ReplacementRule(pattern21, replacement21) pattern22 = Pattern(Integral((a_ + v_*WC('b', S(1)))**m_*(v_**S(2)*WC('C', S(1)) + v_*WC('B', S(1)) + WC('A', S(0)))*WC('u', S(1)), x_), cons2, cons3, cons34, cons35, cons36, cons33, cons31, cons32) def replacement22(B, v, C, u, m, b, a, x, A): rubi.append(22) return Dist(b**(S(-2)), Int(u*(a + b*v)**(m + S(1))*Simp(B*b - C*a + C*b*v, x), x), x) rule22 = ReplacementRule(pattern22, replacement22) pattern23 = Pattern(Integral((a_ + x_**WC('n', S(1))*WC('b', S(1)))**WC('m', S(1))*(c_ + x_**WC('q', S(1))*WC('d', S(1)))**WC('p', S(1))*WC('u', S(1)), x_), cons2, cons3, cons7, cons27, cons21, cons4, cons37, cons38, cons39, cons40) def replacement23(p, u, m, b, d, a, n, c, x, q): rubi.append(23) return Dist((d/a)**p, Int(u*x**(-n*p)*(a + b*x**n)**(m + p), x), x) rule23 = ReplacementRule(pattern23, replacement23) pattern24 = Pattern(Integral((a_ + x_**WC('n', S(1))*WC('b', S(1)))**WC('m', S(1))*(c_ + x_**j_*WC('d', S(1)))**WC('p', S(1))*WC('u', S(1)), x_), cons2, cons3, cons7, cons27, cons21, cons4, cons5, cons6, cons41, cons42, cons43, cons44) def replacement24(p, u, j, m, b, d, a, n, c, x): rubi.append(24) return Dist((-b**S(2)/d)**m, Int(u*(a - b*x**n)**(-m), x), x) rule24 = ReplacementRule(pattern24, replacement24) pattern25 = Pattern(Integral((a_ + x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)))**WC('p', S(1))*WC('u', S(1)), x_), cons2, cons3, cons7, cons45, cons38) def replacement25(p, u, b, c, a, x): rubi.append(25) return Int(S(2)**(-S(2)*p)*c**(-p)*u*(b + S(2)*c*x)**(S(2)*p), x) rule25 = ReplacementRule(pattern25, replacement25) pattern26 = Pattern(Integral((a_ + x_**n_*WC('b', S(1)) + x_**WC('n2', S(1))*WC('c', S(1)))**WC('p', S(1))*WC('u', S(1)), x_), cons2, cons3, cons7, cons4, cons46, cons45, cons38) def replacement26(p, u, b, n2, c, a, n, x): rubi.append(26) return Dist(c**(-p), Int(u*(b/S(2) + c*x**n)**(S(2)*p), x), x) rule26 = ReplacementRule(pattern26, replacement26) pattern27 = Pattern(Integral((d_ + x_*WC('e', S(1)))*(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons5, cons47) def replacement27(p, b, d, c, a, x, e): rubi.append(27) return Dist(d/b, Subst(Int(x**p, x), x, a + b*x + c*x**S(2)), x) rule27 = ReplacementRule(pattern27, replacement27) pattern28 = Pattern(Integral((x_**WC('p', S(1))*WC('a', S(1)) + x_**WC('q', S(1))*WC('b', S(1)))**WC('m', S(1))*WC('u', S(1)), x_), cons2, cons3, cons5, cons50, cons17, cons49) def replacement28(p, u, m, b, a, x, q): rubi.append(28) return Int(u*x**(m*p)*(a + b*x**(-p + q))**m, x) rule28 = ReplacementRule(pattern28, replacement28) pattern29 = Pattern(Integral((x_**WC('p', S(1))*WC('a', S(1)) + x_**WC('q', S(1))*WC('b', S(1)) + x_**WC('r', S(1))*WC('c', S(1)))**WC('m', S(1))*WC('u', S(1)), x_), cons2, cons3, cons7, cons5, cons50, cons52, cons17, cons49, cons51) def replacement29(p, u, m, b, r, a, c, x, q): rubi.append(29) return Int(u*x**(m*p)*(a + b*x**(-p + q) + c*x**(-p + r))**m, x) rule29 = ReplacementRule(pattern29, replacement29) pattern30 = Pattern(Integral(x_**WC('m', S(1))/(a_ + x_**n_*WC('b', S(1))), x_), cons2, cons3, cons21, cons4, cons53) def replacement30(m, b, a, n, x): rubi.append(30) return Simp(rubi_log(RemoveContent(a + b*x**n, x))/(b*n), x) rule30 = ReplacementRule(pattern30, replacement30) pattern31 = Pattern(Integral(x_**WC('m', S(1))*(a_ + x_**n_*WC('b', S(1)))**p_, x_), cons2, cons3, cons21, cons4, cons5, cons53, cons54) def replacement31(p, m, b, a, n, x): rubi.append(31) return Simp((a + b*x**n)**(p + S(1))/(b*n*(p + S(1))), x) rule31 = ReplacementRule(pattern31, replacement31) pattern32 = Pattern(Integral(x_**WC('m', S(1))*(a1_ + x_**WC('n', S(1))*WC('b1', S(1)))**p_*(a2_ + x_**WC('n', S(1))*WC('b2', S(1)))**p_, x_), cons57, cons58, cons59, cons60, cons21, cons4, cons5, cons55, cons56, cons54) def replacement32(p, a2, m, b2, b1, n, x, a1): rubi.append(32) return Simp((a1 + b1*x**n)**(p + S(1))*(a2 + b2*x**n)**(p + S(1))/(S(2)*b1*b2*n*(p + S(1))), x) rule32 = ReplacementRule(pattern32, replacement32) def With33(p, Pm, b, a, n, Qm, x): if isinstance(x, (int, Integer, float, Float)): return False m = Expon(Pm, x) if And(Equal(Expon(Qm, x), m + S(-1)), ZeroQ(-Qm*m*Coeff(Pm, x, m) + Coeff(Qm, x, m + S(-1))*D(Pm, x))): return True return False pattern33 = Pattern(Integral(Qm_*(Pm_**WC('n', S(1))*WC('b', S(1)) + WC('a', S(0)))**WC('p', S(1)), x_), cons2, cons3, cons4, cons5, cons11, cons61, CustomConstraint(With33)) def replacement33(p, Pm, b, a, n, Qm, x): m = Expon(Pm, x) rubi.append(33) return Dist(Coeff(Qm, x, m + S(-1))/(m*Coeff(Pm, x, m)), Subst(Int((a + b*x**n)**p, x), x, Pm), x) rule33 = ReplacementRule(pattern33, replacement33) def With34(p, Pm, b, n2, c, a, n, Qm, x): if isinstance(x, (int, Integer, float, Float)): return False m = Expon(Pm, x) if And(Equal(Expon(Qm, x), m + S(-1)), ZeroQ(-Qm*m*Coeff(Pm, x, m) + Coeff(Qm, x, m + S(-1))*D(Pm, x))): return True return False pattern34 = Pattern(Integral(Qm_*(Pm_**WC('n', S(1))*WC('b', S(1)) + Pm_**WC('n2', S(1))*WC('c', S(1)) + WC('a', S(0)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons4, cons5, cons46, cons11, cons61, CustomConstraint(With34)) def replacement34(p, Pm, b, n2, c, a, n, Qm, x): m = Expon(Pm, x) rubi.append(34) return Dist(Coeff(Qm, x, m + S(-1))/(m*Coeff(Pm, x, m)), Subst(Int((a + b*x**n + c*x**(S(2)*n))**p, x), x, Pm), x) rule34 = ReplacementRule(pattern34, replacement34) def With35(p, u, m, Pq, Qr, x): if isinstance(x, (int, Integer, float, Float)): return False gcd = PolyGCD(Pq, Qr, x) if NonzeroQ(gcd + S(-1)): return True return False pattern35 = Pattern(Integral(Pq_**m_*Qr_**p_*WC('u', S(1)), x_), cons62, cons63, cons64, cons65, CustomConstraint(With35)) def replacement35(p, u, m, Pq, Qr, x): gcd = PolyGCD(Pq, Qr, x) rubi.append(35) return Int(gcd**(m + p)*u*PolynomialQuotient(Pq, gcd, x)**m*PolynomialQuotient(Qr, gcd, x)**p, x) rule35 = ReplacementRule(pattern35, replacement35) def With36(p, u, Pq, Qr, x): if isinstance(x, (int, Integer, float, Float)): return False gcd = PolyGCD(Pq, Qr, x) if NonzeroQ(gcd + S(-1)): return True return False pattern36 = Pattern(Integral(Pq_*Qr_**p_*WC('u', S(1)), x_), cons63, cons64, cons65, CustomConstraint(With36)) def replacement36(p, u, Pq, Qr, x): gcd = PolyGCD(Pq, Qr, x) rubi.append(36) return Int(gcd**(p + S(1))*u*PolynomialQuotient(Pq, gcd, x)*PolynomialQuotient(Qr, gcd, x)**p, x) rule36 = ReplacementRule(pattern36, replacement36) return [rule1, rule2, rule3, rule4, rule5, rule6, rule7, rule8, rule9, rule10, rule11, rule12, rule13, rule14, rule15, rule16, rule17, rule18, rule19, rule20, rule21, rule22, rule23, rule24, rule25, rule26, rule27, rule28, rule29, rule30, rule31, rule32, rule33, rule34, rule35, rule36, ]
5b080cc982cc42d02752b10802d6684b6888a1bbd25ae9ca8921b6921ba83e57
''' This code is automatically generated. Never edit it manually. For details of generating the code see `rubi_parsing_guide.md` in `parsetools`. ''' from sympy.external import import_module matchpy = import_module("matchpy") from sympy.utilities.decorator import doctest_depends_on if matchpy: from matchpy import Pattern, ReplacementRule, CustomConstraint, is_match from sympy.integrals.rubi.utility_function import ( Int, Sum, Set, With, Module, Scan, MapAnd, FalseQ, ZeroQ, NegativeQ, NonzeroQ, FreeQ, NFreeQ, List, Log, PositiveQ, PositiveIntegerQ, NegativeIntegerQ, IntegerQ, IntegersQ, ComplexNumberQ, PureComplexNumberQ, RealNumericQ, PositiveOrZeroQ, NegativeOrZeroQ, FractionOrNegativeQ, NegQ, Equal, Unequal, IntPart, FracPart, RationalQ, ProductQ, SumQ, NonsumQ, Subst, First, Rest, SqrtNumberQ, SqrtNumberSumQ, LinearQ, Sqrt, ArcCosh, Coefficient, Denominator, Hypergeometric2F1, Not, Simplify, FractionalPart, IntegerPart, AppellF1, EllipticPi, EllipticE, EllipticF, ArcTan, ArcCot, ArcCoth, ArcTanh, ArcSin, ArcSinh, ArcCos, ArcCsc, ArcSec, ArcCsch, ArcSech, Sinh, Tanh, Cosh, Sech, Csch, Coth, LessEqual, Less, Greater, GreaterEqual, FractionQ, IntLinearcQ, Expand, IndependentQ, PowerQ, IntegerPowerQ, PositiveIntegerPowerQ, FractionalPowerQ, AtomQ, ExpQ, LogQ, Head, MemberQ, TrigQ, SinQ, CosQ, TanQ, CotQ, SecQ, CscQ, Sin, Cos, Tan, Cot, Sec, Csc, HyperbolicQ, SinhQ, CoshQ, TanhQ, CothQ, SechQ, CschQ, InverseTrigQ, SinCosQ, SinhCoshQ, LeafCount, Numerator, NumberQ, NumericQ, Length, ListQ, Im, Re, InverseHyperbolicQ, InverseFunctionQ, TrigHyperbolicFreeQ, InverseFunctionFreeQ, RealQ, EqQ, FractionalPowerFreeQ, ComplexFreeQ, PolynomialQ, FactorSquareFree, PowerOfLinearQ, Exponent, QuadraticQ, LinearPairQ, BinomialParts, TrinomialParts, PolyQ, EvenQ, OddQ, PerfectSquareQ, NiceSqrtAuxQ, NiceSqrtQ, Together, PosAux, PosQ, CoefficientList, ReplaceAll, ExpandLinearProduct, GCD, ContentFactor, NumericFactor, NonnumericFactors, MakeAssocList, GensymSubst, KernelSubst, ExpandExpression, Apart, SmartApart, MatchQ, PolynomialQuotientRemainder, FreeFactors, NonfreeFactors, RemoveContentAux, RemoveContent, FreeTerms, NonfreeTerms, ExpandAlgebraicFunction, CollectReciprocals, ExpandCleanup, AlgebraicFunctionQ, Coeff, LeadTerm, RemainingTerms, LeadFactor, RemainingFactors, LeadBase, LeadDegree, Numer, Denom, hypergeom, Expon, MergeMonomials, PolynomialDivide, BinomialQ, TrinomialQ, GeneralizedBinomialQ, GeneralizedTrinomialQ, FactorSquareFreeList, PerfectPowerTest, SquareFreeFactorTest, RationalFunctionQ, RationalFunctionFactors, NonrationalFunctionFactors, Reverse, RationalFunctionExponents, RationalFunctionExpand, ExpandIntegrand, SimplerQ, SimplerSqrtQ, SumSimplerQ, BinomialDegree, TrinomialDegree, CancelCommonFactors, SimplerIntegrandQ, GeneralizedBinomialDegree, GeneralizedBinomialParts, GeneralizedTrinomialDegree, GeneralizedTrinomialParts, MonomialQ, MonomialSumQ, MinimumMonomialExponent, MonomialExponent, LinearMatchQ, PowerOfLinearMatchQ, QuadraticMatchQ, CubicMatchQ, BinomialMatchQ, TrinomialMatchQ, GeneralizedBinomialMatchQ, GeneralizedTrinomialMatchQ, QuotientOfLinearsMatchQ, PolynomialTermQ, PolynomialTerms, NonpolynomialTerms, PseudoBinomialParts, NormalizePseudoBinomial, PseudoBinomialPairQ, PseudoBinomialQ, PolynomialGCD, PolyGCD, AlgebraicFunctionFactors, NonalgebraicFunctionFactors, QuotientOfLinearsP, QuotientOfLinearsParts, QuotientOfLinearsQ, Flatten, Sort, AbsurdNumberQ, AbsurdNumberFactors, NonabsurdNumberFactors, SumSimplerAuxQ, Prepend, Drop, CombineExponents, FactorInteger, FactorAbsurdNumber, SubstForInverseFunction, SubstForFractionalPower, SubstForFractionalPowerOfQuotientOfLinears, FractionalPowerOfQuotientOfLinears, SubstForFractionalPowerQ, SubstForFractionalPowerAuxQ, FractionalPowerOfSquareQ, FractionalPowerSubexpressionQ, Apply, FactorNumericGcd, MergeableFactorQ, MergeFactor, MergeFactors, TrigSimplifyQ, TrigSimplify, TrigSimplifyRecur, Order, FactorOrder, Smallest, OrderedQ, MinimumDegree, PositiveFactors, Sign, NonpositiveFactors, PolynomialInAuxQ, PolynomialInQ, ExponentInAux, ExponentIn, PolynomialInSubstAux, PolynomialInSubst, Distrib, DistributeDegree, FunctionOfPower, DivideDegreesOfFactors, MonomialFactor, FullSimplify, FunctionOfLinearSubst, FunctionOfLinear, NormalizeIntegrand, NormalizeIntegrandAux, NormalizeIntegrandFactor, NormalizeIntegrandFactorBase, NormalizeTogether, NormalizeLeadTermSigns, AbsorbMinusSign, NormalizeSumFactors, SignOfFactor, NormalizePowerOfLinear, SimplifyIntegrand, SimplifyTerm, TogetherSimplify, SmartSimplify, SubstForExpn, ExpandToSum, UnifySum, UnifyTerms, UnifyTerm, CalculusQ, FunctionOfInverseLinear, PureFunctionOfSinhQ, PureFunctionOfTanhQ, PureFunctionOfCoshQ, IntegerQuotientQ, OddQuotientQ, EvenQuotientQ, FindTrigFactor, FunctionOfSinhQ, FunctionOfCoshQ, OddHyperbolicPowerQ, FunctionOfTanhQ, FunctionOfTanhWeight, FunctionOfHyperbolicQ, SmartNumerator, SmartDenominator, SubstForAux, ActivateTrig, ExpandTrig, TrigExpand, SubstForTrig, SubstForHyperbolic, InertTrigFreeQ, LCM, SubstForFractionalPowerOfLinear, FractionalPowerOfLinear, InverseFunctionOfLinear, InertTrigQ, InertReciprocalQ, DeactivateTrig, FixInertTrigFunction, DeactivateTrigAux, PowerOfInertTrigSumQ, PiecewiseLinearQ, KnownTrigIntegrandQ, KnownSineIntegrandQ, KnownTangentIntegrandQ, KnownCotangentIntegrandQ, KnownSecantIntegrandQ, TryPureTanSubst, TryTanhSubst, TryPureTanhSubst, AbsurdNumberGCD, AbsurdNumberGCDList, ExpandTrigExpand, ExpandTrigReduce, ExpandTrigReduceAux, NormalizeTrig, TrigToExp, ExpandTrigToExp, TrigReduce, FunctionOfTrig, AlgebraicTrigFunctionQ, FunctionOfHyperbolic, FunctionOfQ, FunctionOfExpnQ, PureFunctionOfSinQ, PureFunctionOfCosQ, PureFunctionOfTanQ, PureFunctionOfCotQ, FunctionOfCosQ, FunctionOfSinQ, OddTrigPowerQ, FunctionOfTanQ, FunctionOfTanWeight, FunctionOfTrigQ, FunctionOfDensePolynomialsQ, FunctionOfLog, PowerVariableExpn, PowerVariableDegree, PowerVariableSubst, EulerIntegrandQ, FunctionOfSquareRootOfQuadratic, SquareRootOfQuadraticSubst, Divides, EasyDQ, ProductOfLinearPowersQ, Rt, NthRoot, AtomBaseQ, SumBaseQ, NegSumBaseQ, AllNegTermQ, SomeNegTermQ, TrigSquareQ, RtAux, TrigSquare, IntSum, IntTerm, Map2, ConstantFactor, SameQ, ReplacePart, CommonFactors, MostMainFactorPosition, FunctionOfExponentialQ, FunctionOfExponential, FunctionOfExponentialFunction, FunctionOfExponentialFunctionAux, FunctionOfExponentialTest, FunctionOfExponentialTestAux, stdev, rubi_test, If, IntQuadraticQ, IntBinomialQ, RectifyTangent, RectifyCotangent, Inequality, Condition, Simp, SimpHelp, SplitProduct, SplitSum, SubstFor, SubstForAux, FresnelS, FresnelC, Erfc, Erfi, Gamma, FunctionOfTrigOfLinearQ, ElementaryFunctionQ, Complex, UnsameQ, _SimpFixFactor, SimpFixFactor, _FixSimplify, FixSimplify, _SimplifyAntiderivativeSum, SimplifyAntiderivativeSum, _SimplifyAntiderivative, SimplifyAntiderivative, _TrigSimplifyAux, TrigSimplifyAux, Cancel, Part, PolyLog, D, Dist, Sum_doit, PolynomialQuotient, Floor, PolynomialRemainder, Factor, PolyLog, CosIntegral, SinIntegral, LogIntegral, SinhIntegral, CoshIntegral, Rule, Erf, PolyGamma, ExpIntegralEi, ExpIntegralE, LogGamma , UtilityOperator, Factorial, Zeta, ProductLog, DerivativeDivides, HypergeometricPFQ, IntHide, OneQ, Null, rubi_exp as exp, rubi_log as log, Discriminant, Negative, Quotient ) from sympy import (Integral, S, sqrt, And, Or, Integer, Float, Mod, I, Abs, simplify, Mul, Add, Pow, sign, EulerGamma) from sympy.integrals.rubi.symbol import WC from sympy.core.symbol import symbols, Symbol from sympy.functions import (sin, cos, tan, cot, csc, sec, sqrt, erf) from sympy.functions.elementary.hyperbolic import (acosh, asinh, atanh, acoth, acsch, asech, cosh, sinh, tanh, coth, sech, csch) from sympy.functions.elementary.trigonometric import (atan, acsc, asin, acot, acos, asec, atan2) from sympy import pi as Pi A_, B_, C_, F_, G_, H_, a_, b_, c_, d_, e_, f_, g_, h_, i_, j_, k_, l_, m_, n_, p_, q_, r_, t_, u_, v_, s_, w_, x_, y_, z_ = [WC(i) for i in 'ABCFGHabcdefghijklmnpqrtuvswxyz'] a1_, a2_, b1_, b2_, c1_, c2_, d1_, d2_, n1_, n2_, e1_, e2_, f1_, f2_, g1_, g2_, n1_, n2_, n3_, Pq_, Pm_, Px_, Qm_, Qr_, Qx_, jn_, mn_, non2_, RFx_, RGx_ = [WC(i) for i in ['a1', 'a2', 'b1', 'b2', 'c1', 'c2', 'd1', 'd2', 'n1', 'n2', 'e1', 'e2', 'f1', 'f2', 'g1', 'g2', 'n1', 'n2', 'n3', 'Pq', 'Pm', 'Px', 'Qm', 'Qr', 'Qx', 'jn', 'mn', 'non2', 'RFx', 'RGx']] i, ii , Pqq, Q, R, r, C, k, u = symbols('i ii Pqq Q R r C k u') _UseGamma = False ShowSteps = False StepCounter = None def miscellaneous_trig(rubi): from sympy.integrals.rubi.constraints import cons1646, cons18, cons2, cons3, cons7, cons27, cons21, cons4, cons34, cons35, cons36, cons1647, cons1648, cons1649, cons1650, cons1651, cons1652, cons1653, cons25, cons1654, cons1408, cons208, cons38, cons48, cons125, cons147, cons343, cons5, cons240, cons244, cons1333, cons137, cons1655, cons1288, cons166, cons319, cons1656, cons31, cons249, cons94, cons253, cons13, cons163, cons246, cons1278, cons1657, cons1658, cons1659, cons170, cons1660, cons1661, cons93, cons89, cons1662, cons162, cons88, cons1663, cons1664, cons85, cons128, cons1479, cons744, cons1482, cons1665, cons23, cons1666, cons1667, cons1668, cons1669, cons1247, cons1670, cons1671, cons1672, cons1673, cons555, cons1674, cons628, cons10, cons1675, cons1676, cons1677, cons66, cons1230, cons376, cons49, cons50, cons51, cons52, cons1678, cons1439, cons1679, cons1680, cons1681, cons1682, cons62, cons584, cons464, cons1683, cons168, cons1684, cons1685, cons1686, cons1687, cons1688, cons812, cons813, cons17, cons1689, cons1690, cons1691, cons1692, cons1099, cons1693, cons87, cons165, cons1694, cons1695, cons1395, cons1696, cons1442, cons1697, cons1502, cons963, cons1698, cons1644, cons1699, cons196, cons1700, cons1011, cons150, cons1551, cons1701, cons1702, cons209, cons224, cons1703, cons810, cons811, cons148, cons528, cons1704, cons1705, cons1706, cons1707, cons1708, cons54, cons1709, cons1710, cons146, cons1711, cons1505, cons1712, cons1713, cons1714, cons1715, cons1716, cons1717, cons1718, cons1719, cons1645, cons1720, cons1721, cons1722, cons1723, cons1724, cons338, cons53, cons627, cons71, cons1725, cons1726, cons1727, cons1728, cons1360, cons1478, cons463, cons1729, cons1730, cons1731, cons1732, cons1265, cons1267, cons1474, cons1481, cons1733 pattern4685 = Pattern(Integral(u_*(WC('c', S(1))*tan(x_*WC('b', S(1)) + WC('a', S(0))))**WC('m', S(1))*(WC('d', S(1))*sin(x_*WC('b', S(1)) + WC('a', S(0))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons21, cons4, cons1646, cons18) def replacement4685(u, m, b, d, c, a, n, x): rubi.append(4685) return Dist((c*tan(a + b*x))**m*(d*sin(a + b*x))**(-m)*(d*cos(a + b*x))**m, Int((d*sin(a + b*x))**(m + n)*(d*cos(a + b*x))**(-m)*ActivateTrig(u), x), x) rule4685 = ReplacementRule(pattern4685, replacement4685) pattern4686 = Pattern(Integral(u_*(WC('c', S(1))*tan(x_*WC('b', S(1)) + WC('a', S(0))))**WC('m', S(1))*(WC('d', S(1))*cos(x_*WC('b', S(1)) + WC('a', S(0))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons21, cons4, cons1646, cons18) def replacement4686(u, m, b, d, c, a, n, x): rubi.append(4686) return Dist((c*tan(a + b*x))**m*(d*sin(a + b*x))**(-m)*(d*cos(a + b*x))**m, Int((d*sin(a + b*x))**m*(d*cos(a + b*x))**(-m + n)*ActivateTrig(u), x), x) rule4686 = ReplacementRule(pattern4686, replacement4686) pattern4687 = Pattern(Integral(u_*(WC('c', S(1))/tan(x_*WC('b', S(1)) + WC('a', S(0))))**WC('m', S(1))*(WC('d', S(1))*sin(x_*WC('b', S(1)) + WC('a', S(0))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons21, cons4, cons1646, cons18) def replacement4687(u, m, b, d, c, a, n, x): rubi.append(4687) return Dist((c/tan(a + b*x))**m*(d*sin(a + b*x))**m*(d*cos(a + b*x))**(-m), Int((d*sin(a + b*x))**(-m + n)*(d*cos(a + b*x))**m*ActivateTrig(u), x), x) rule4687 = ReplacementRule(pattern4687, replacement4687) pattern4688 = Pattern(Integral(u_*(WC('c', S(1))/tan(x_*WC('b', S(1)) + WC('a', S(0))))**WC('m', S(1))*(WC('d', S(1))*cos(x_*WC('b', S(1)) + WC('a', S(0))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons21, cons4, cons1646, cons18) def replacement4688(u, m, b, d, c, a, n, x): rubi.append(4688) return Dist((c/tan(a + b*x))**m*(d*sin(a + b*x))**m*(d*cos(a + b*x))**(-m), Int((d*sin(a + b*x))**(-m)*(d*cos(a + b*x))**(m + n)*ActivateTrig(u), x), x) rule4688 = ReplacementRule(pattern4688, replacement4688) pattern4689 = Pattern(Integral(u_*(WC('c', S(1))/cos(x_*WC('b', S(1)) + WC('a', S(0))))**WC('m', S(1))*(WC('d', S(1))*cos(x_*WC('b', S(1)) + WC('a', S(0))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons21, cons4, cons1646) def replacement4689(u, m, b, d, c, a, n, x): rubi.append(4689) return Dist((c/sin(a + b*x))**m*(d*sin(a + b*x))**m, Int((d*sin(a + b*x))**(-m + n)*ActivateTrig(u), x), x) rule4689 = ReplacementRule(pattern4689, replacement4689) pattern4690 = Pattern(Integral(u_*(WC('c', S(1))*tan(x_*WC('b', S(1)) + WC('a', S(0))))**WC('m', S(1)), x_), cons2, cons3, cons7, cons21, cons18, cons1646) def replacement4690(u, m, b, c, a, x): rubi.append(4690) return Dist((c*sin(a + b*x))**(-m)*(c*cos(a + b*x))**m*(c*tan(a + b*x))**m, Int((c*sin(a + b*x))**m*(c*cos(a + b*x))**(-m)*ActivateTrig(u), x), x) rule4690 = ReplacementRule(pattern4690, replacement4690) pattern4691 = Pattern(Integral(u_*(WC('c', S(1))/tan(x_*WC('b', S(1)) + WC('a', S(0))))**WC('m', S(1)), x_), cons2, cons3, cons7, cons21, cons18, cons1646) def replacement4691(u, m, b, c, a, x): rubi.append(4691) return Dist((c*sin(a + b*x))**m*(c*cos(a + b*x))**(-m)*(c/tan(a + b*x))**m, Int((c*sin(a + b*x))**(-m)*(c*cos(a + b*x))**m*ActivateTrig(u), x), x) rule4691 = ReplacementRule(pattern4691, replacement4691) pattern4692 = Pattern(Integral(u_*(WC('c', S(1))/cos(x_*WC('b', S(1)) + WC('a', S(0))))**WC('m', S(1)), x_), cons2, cons3, cons7, cons21, cons18, cons1646) def replacement4692(u, m, b, c, a, x): rubi.append(4692) return Dist((c/cos(a + b*x))**m*(c*cos(a + b*x))**m, Int((c*cos(a + b*x))**(-m)*ActivateTrig(u), x), x) rule4692 = ReplacementRule(pattern4692, replacement4692) pattern4693 = Pattern(Integral(u_*(WC('c', S(1))/sin(x_*WC('b', S(1)) + WC('a', S(0))))**WC('m', S(1)), x_), cons2, cons3, cons7, cons21, cons18, cons1646) def replacement4693(u, m, b, c, a, x): rubi.append(4693) return Dist((c/sin(a + b*x))**m*(c*sin(a + b*x))**m, Int((c*sin(a + b*x))**(-m)*ActivateTrig(u), x), x) rule4693 = ReplacementRule(pattern4693, replacement4693) pattern4694 = Pattern(Integral(u_*(WC('c', S(1))*sin(x_*WC('b', S(1)) + WC('a', S(0))))**WC('n', S(1))*(A_ + WC('B', S(1))/sin(x_*WC('b', S(1)) + WC('a', S(0)))), x_), cons2, cons3, cons7, cons34, cons35, cons4, cons1646) def replacement4694(B, u, b, c, a, n, x, A): rubi.append(4694) return Dist(c, Int((c*sin(a + b*x))**(n + S(-1))*(A*sin(a + b*x) + B)*ActivateTrig(u), x), x) rule4694 = ReplacementRule(pattern4694, replacement4694) pattern4695 = Pattern(Integral(u_*(WC('c', S(1))*cos(x_*WC('b', S(1)) + WC('a', S(0))))**WC('n', S(1))*(A_ + WC('B', S(1))/cos(x_*WC('b', S(1)) + WC('a', S(0)))), x_), cons2, cons3, cons7, cons34, cons35, cons4, cons1646) def replacement4695(B, u, b, c, a, n, x, A): rubi.append(4695) return Dist(c, Int((c*cos(a + b*x))**(n + S(-1))*(A*cos(a + b*x) + B)*ActivateTrig(u), x), x) rule4695 = ReplacementRule(pattern4695, replacement4695) pattern4696 = Pattern(Integral(u_*(A_ + WC('B', S(1))/sin(x_*WC('b', S(1)) + WC('a', S(0)))), x_), cons2, cons3, cons34, cons35, cons1646) def replacement4696(B, u, b, a, x, A): rubi.append(4696) return Int((A*sin(a + b*x) + B)*ActivateTrig(u)/sin(a + b*x), x) rule4696 = ReplacementRule(pattern4696, replacement4696) pattern4697 = Pattern(Integral(u_*(A_ + WC('B', S(1))/cos(x_*WC('b', S(1)) + WC('a', S(0)))), x_), cons2, cons3, cons34, cons35, cons1646) def replacement4697(B, u, b, a, x, A): rubi.append(4697) return Int((A*cos(a + b*x) + B)*ActivateTrig(u)/cos(a + b*x), x) rule4697 = ReplacementRule(pattern4697, replacement4697) pattern4698 = Pattern(Integral((WC('c', S(1))*sin(x_*WC('b', S(1)) + WC('a', S(0))))**WC('n', S(1))*(WC('A', S(0)) + WC('B', S(1))/sin(x_*WC('b', S(1)) + WC('a', S(0))) + WC('C', S(1))/sin(x_*WC('b', S(1)) + WC('a', S(0)))**S(2))*WC('u', S(1)), x_), cons2, cons3, cons7, cons34, cons35, cons36, cons4, cons1646) def replacement4698(B, C, u, b, a, c, n, x, A): rubi.append(4698) return Dist(c**S(2), Int((c*sin(a + b*x))**(n + S(-2))*(A*sin(a + b*x)**S(2) + B*sin(a + b*x) + C)*ActivateTrig(u), x), x) rule4698 = ReplacementRule(pattern4698, replacement4698) pattern4699 = Pattern(Integral((WC('c', S(1))*cos(x_*WC('b', S(1)) + WC('a', S(0))))**WC('n', S(1))*(WC('A', S(0)) + WC('B', S(1))/cos(x_*WC('b', S(1)) + WC('a', S(0))) + WC('C', S(1))/cos(x_*WC('b', S(1)) + WC('a', S(0)))**S(2))*WC('u', S(1)), x_), cons2, cons3, cons7, cons34, cons35, cons36, cons4, cons1646) def replacement4699(B, C, u, b, c, a, n, x, A): rubi.append(4699) return Dist(c**S(2), Int((c*cos(a + b*x))**(n + S(-2))*(A*cos(a + b*x)**S(2) + B*cos(a + b*x) + C)*ActivateTrig(u), x), x) rule4699 = ReplacementRule(pattern4699, replacement4699) pattern4700 = Pattern(Integral((WC('c', S(1))*sin(x_*WC('b', S(1)) + WC('a', S(0))))**WC('n', S(1))*(A_ + WC('C', S(1))/sin(x_*WC('b', S(1)) + WC('a', S(0)))**S(2))*WC('u', S(1)), x_), cons2, cons3, cons7, cons34, cons36, cons4, cons1646) def replacement4700(C, u, b, c, a, n, x, A): rubi.append(4700) return Dist(c**S(2), Int((c*sin(a + b*x))**(n + S(-2))*(A*sin(a + b*x)**S(2) + C)*ActivateTrig(u), x), x) rule4700 = ReplacementRule(pattern4700, replacement4700) pattern4701 = Pattern(Integral((WC('c', S(1))*cos(x_*WC('b', S(1)) + WC('a', S(0))))**WC('n', S(1))*(A_ + WC('C', S(1))/cos(x_*WC('b', S(1)) + WC('a', S(0)))**S(2))*WC('u', S(1)), x_), cons2, cons3, cons7, cons34, cons36, cons4, cons1646) def replacement4701(C, u, b, c, a, n, x, A): rubi.append(4701) return Dist(c**S(2), Int((c*cos(a + b*x))**(n + S(-2))*(A*cos(a + b*x)**S(2) + C)*ActivateTrig(u), x), x) rule4701 = ReplacementRule(pattern4701, replacement4701) pattern4702 = Pattern(Integral(u_*(WC('A', S(0)) + WC('B', S(1))/sin(x_*WC('b', S(1)) + WC('a', S(0))) + WC('C', S(1))/sin(x_*WC('b', S(1)) + WC('a', S(0)))**S(2)), x_), cons2, cons3, cons34, cons35, cons36, cons1646) def replacement4702(B, C, u, b, a, x, A): rubi.append(4702) return Int((A*sin(a + b*x)**S(2) + B*sin(a + b*x) + C)*ActivateTrig(u)/sin(a + b*x)**S(2), x) rule4702 = ReplacementRule(pattern4702, replacement4702) pattern4703 = Pattern(Integral(u_*(WC('A', S(0)) + WC('B', S(1))/cos(x_*WC('b', S(1)) + WC('a', S(0))) + WC('C', S(1))/cos(x_*WC('b', S(1)) + WC('a', S(0)))**S(2)), x_), cons2, cons3, cons34, cons35, cons36, cons1646) def replacement4703(B, C, u, b, a, x, A): rubi.append(4703) return Int((A*cos(a + b*x)**S(2) + B*cos(a + b*x) + C)*ActivateTrig(u)/cos(a + b*x)**S(2), x) rule4703 = ReplacementRule(pattern4703, replacement4703) pattern4704 = Pattern(Integral(u_*(A_ + WC('C', S(1))/sin(x_*WC('b', S(1)) + WC('a', S(0)))**S(2)), x_), cons2, cons3, cons34, cons36, cons1646) def replacement4704(C, u, b, a, x, A): rubi.append(4704) return Int((A*sin(a + b*x)**S(2) + C)*ActivateTrig(u)/sin(a + b*x)**S(2), x) rule4704 = ReplacementRule(pattern4704, replacement4704) pattern4705 = Pattern(Integral(u_*(A_ + WC('C', S(1))/cos(x_*WC('b', S(1)) + WC('a', S(0)))**S(2)), x_), cons2, cons3, cons34, cons36, cons1646) def replacement4705(C, u, b, a, x, A): rubi.append(4705) return Int((A*cos(a + b*x)**S(2) + C)*ActivateTrig(u)/cos(a + b*x)**S(2), x) rule4705 = ReplacementRule(pattern4705, replacement4705) pattern4706 = Pattern(Integral(u_*(WC('A', S(0)) + WC('B', S(1))*sin(x_*WC('b', S(1)) + WC('a', S(0))) + WC('C', S(1))/sin(x_*WC('b', S(1)) + WC('a', S(0)))), x_), cons2, cons3, cons34, cons35, cons36, cons1647) def replacement4706(B, C, u, b, a, x, A): rubi.append(4706) return Int((A*sin(a + b*x) + B*sin(a + b*x)**S(2) + C)*ActivateTrig(u)/sin(a + b*x), x) rule4706 = ReplacementRule(pattern4706, replacement4706) pattern4707 = Pattern(Integral(u_*(WC('A', S(0)) + WC('B', S(1))*cos(x_*WC('b', S(1)) + WC('a', S(0))) + WC('C', S(1))/cos(x_*WC('b', S(1)) + WC('a', S(0)))), x_), cons2, cons3, cons34, cons35, cons36, cons1647) def replacement4707(B, C, u, b, a, x, A): rubi.append(4707) return Int((A*cos(a + b*x) + B*cos(a + b*x)**S(2) + C)*ActivateTrig(u)/cos(a + b*x), x) rule4707 = ReplacementRule(pattern4707, replacement4707) pattern4708 = Pattern(Integral(u_*(WC('A', S(1))*sin(x_*WC('b', S(1)) + WC('a', S(0)))**WC('n', S(1)) + WC('B', S(1))*sin(x_*WC('b', S(1)) + WC('a', S(0)))**n1_ + WC('C', S(1))*sin(x_*WC('b', S(1)) + WC('a', S(0)))**n2_), x_), cons2, cons3, cons34, cons35, cons36, cons4, cons1648, cons1649) def replacement4708(B, C, u, n1, b, n2, a, n, x, A): rubi.append(4708) return Int((A + B*sin(a + b*x) + C*sin(a + b*x)**S(2))*ActivateTrig(u)*sin(a + b*x)**n, x) rule4708 = ReplacementRule(pattern4708, replacement4708) pattern4709 = Pattern(Integral(u_*(WC('A', S(1))*cos(x_*WC('b', S(1)) + WC('a', S(0)))**WC('n', S(1)) + WC('B', S(1))*cos(x_*WC('b', S(1)) + WC('a', S(0)))**n1_ + WC('C', S(1))*cos(x_*WC('b', S(1)) + WC('a', S(0)))**n2_), x_), cons2, cons3, cons34, cons35, cons36, cons4, cons1648, cons1649) def replacement4709(B, C, u, n1, b, n2, a, n, x, A): rubi.append(4709) return Int((A + B*cos(a + b*x) + C*cos(a + b*x)**S(2))*ActivateTrig(u)*cos(a + b*x)**n, x) rule4709 = ReplacementRule(pattern4709, replacement4709) pattern4710 = Pattern(Integral(u_*(WC('c', S(1))/tan(x_*WC('b', S(1)) + WC('a', S(0))))**WC('m', S(1))*(WC('d', S(1))*tan(x_*WC('b', S(1)) + WC('a', S(0))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons21, cons4, cons1650) def replacement4710(u, m, b, d, c, a, n, x): rubi.append(4710) return Dist((c/tan(a + b*x))**m*(d*tan(a + b*x))**m, Int((d*tan(a + b*x))**(-m + n)*ActivateTrig(u), x), x) rule4710 = ReplacementRule(pattern4710, replacement4710) pattern4711 = Pattern(Integral(u_*(WC('c', S(1))*tan(x_*WC('b', S(1)) + WC('a', S(0))))**WC('m', S(1))*(WC('d', S(1))*cos(x_*WC('b', S(1)) + WC('a', S(0))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons21, cons4, cons1651) def replacement4711(u, m, b, d, c, a, n, x): rubi.append(4711) return Dist((c*tan(a + b*x))**m*(d*sin(a + b*x))**(-m)*(d*cos(a + b*x))**m, Int((d*sin(a + b*x))**m*(d*cos(a + b*x))**(-m + n)*ActivateTrig(u), x), x) rule4711 = ReplacementRule(pattern4711, replacement4711) pattern4712 = Pattern(Integral(u_*(WC('c', S(1))/tan(x_*WC('b', S(1)) + WC('a', S(0))))**WC('m', S(1)), x_), cons2, cons3, cons7, cons21, cons18, cons1650) def replacement4712(u, m, b, c, a, x): rubi.append(4712) return Dist((c/tan(a + b*x))**m*(c*tan(a + b*x))**m, Int((c*tan(a + b*x))**(-m)*ActivateTrig(u), x), x) rule4712 = ReplacementRule(pattern4712, replacement4712) pattern4713 = Pattern(Integral(u_*(WC('c', S(1))*tan(x_*WC('b', S(1)) + WC('a', S(0))))**WC('m', S(1)), x_), cons2, cons3, cons7, cons21, cons18, cons1651) def replacement4713(u, m, b, c, a, x): rubi.append(4713) return Dist((c/tan(a + b*x))**m*(c*tan(a + b*x))**m, Int((c/tan(a + b*x))**(-m)*ActivateTrig(u), x), x) rule4713 = ReplacementRule(pattern4713, replacement4713) pattern4714 = Pattern(Integral(u_*(WC('c', S(1))*tan(x_*WC('b', S(1)) + WC('a', S(0))))**WC('n', S(1))*(A_ + WC('B', S(1))/tan(x_*WC('b', S(1)) + WC('a', S(0)))), x_), cons2, cons3, cons7, cons34, cons35, cons4, cons1650) def replacement4714(B, u, b, c, a, n, x, A): rubi.append(4714) return Dist(c, Int((c*tan(a + b*x))**(n + S(-1))*(A*tan(a + b*x) + B)*ActivateTrig(u), x), x) rule4714 = ReplacementRule(pattern4714, replacement4714) pattern4715 = Pattern(Integral(u_*(WC('c', S(1))/tan(x_*WC('b', S(1)) + WC('a', S(0))))**WC('n', S(1))*(A_ + WC('B', S(1))*tan(x_*WC('b', S(1)) + WC('a', S(0)))), x_), cons2, cons3, cons7, cons34, cons35, cons4, cons1651) def replacement4715(B, u, b, c, a, n, x, A): rubi.append(4715) return Dist(c, Int((c/tan(a + b*x))**(n + S(-1))*(A/tan(a + b*x) + B)*ActivateTrig(u), x), x) rule4715 = ReplacementRule(pattern4715, replacement4715) pattern4716 = Pattern(Integral(u_*(A_ + WC('B', S(1))/tan(x_*WC('b', S(1)) + WC('a', S(0)))), x_), cons2, cons3, cons34, cons35, cons1650) def replacement4716(B, u, b, a, x, A): rubi.append(4716) return Int((A*tan(a + b*x) + B)*ActivateTrig(u)/tan(a + b*x), x) rule4716 = ReplacementRule(pattern4716, replacement4716) pattern4717 = Pattern(Integral(u_*(A_ + WC('B', S(1))*tan(x_*WC('b', S(1)) + WC('a', S(0)))), x_), cons2, cons3, cons34, cons35, cons1651) def replacement4717(B, u, b, a, x, A): rubi.append(4717) return Int((A/tan(a + b*x) + B)*ActivateTrig(u)*tan(a + b*x), x) rule4717 = ReplacementRule(pattern4717, replacement4717) pattern4718 = Pattern(Integral((WC('c', S(1))*tan(x_*WC('b', S(1)) + WC('a', S(0))))**WC('n', S(1))*(WC('A', S(0)) + WC('B', S(1))/tan(x_*WC('b', S(1)) + WC('a', S(0))) + WC('C', S(1))/tan(x_*WC('b', S(1)) + WC('a', S(0)))**S(2))*WC('u', S(1)), x_), cons2, cons3, cons7, cons34, cons35, cons36, cons4, cons1650) def replacement4718(B, C, u, b, a, c, n, x, A): rubi.append(4718) return Dist(c**S(2), Int((c*tan(a + b*x))**(n + S(-2))*(A*tan(a + b*x)**S(2) + B*tan(a + b*x) + C)*ActivateTrig(u), x), x) rule4718 = ReplacementRule(pattern4718, replacement4718) pattern4719 = Pattern(Integral((WC('c', S(1))/tan(x_*WC('b', S(1)) + WC('a', S(0))))**WC('n', S(1))*(WC('A', S(0)) + WC('B', S(1))*tan(x_*WC('b', S(1)) + WC('a', S(0))) + WC('C', S(1))*tan(x_*WC('b', S(1)) + WC('a', S(0)))**S(2))*WC('u', S(1)), x_), cons2, cons3, cons7, cons34, cons35, cons36, cons4, cons1651) def replacement4719(B, C, u, b, c, a, n, x, A): rubi.append(4719) return Dist(c**S(2), Int((c/tan(a + b*x))**(n + S(-2))*(A/tan(a + b*x)**S(2) + B/tan(a + b*x) + C)*ActivateTrig(u), x), x) rule4719 = ReplacementRule(pattern4719, replacement4719) pattern4720 = Pattern(Integral((WC('c', S(1))*tan(x_*WC('b', S(1)) + WC('a', S(0))))**WC('n', S(1))*(A_ + WC('C', S(1))/tan(x_*WC('b', S(1)) + WC('a', S(0)))**S(2))*WC('u', S(1)), x_), cons2, cons3, cons7, cons34, cons36, cons4, cons1650) def replacement4720(C, u, b, c, a, n, x, A): rubi.append(4720) return Dist(c**S(2), Int((c*tan(a + b*x))**(n + S(-2))*(A*tan(a + b*x)**S(2) + C)*ActivateTrig(u), x), x) rule4720 = ReplacementRule(pattern4720, replacement4720) pattern4721 = Pattern(Integral((WC('c', S(1))/tan(x_*WC('b', S(1)) + WC('a', S(0))))**WC('n', S(1))*(A_ + WC('C', S(1))*tan(x_*WC('b', S(1)) + WC('a', S(0)))**S(2))*WC('u', S(1)), x_), cons2, cons3, cons7, cons34, cons36, cons4, cons1651) def replacement4721(C, u, b, c, a, n, x, A): rubi.append(4721) return Dist(c**S(2), Int((c/tan(a + b*x))**(n + S(-2))*(A/tan(a + b*x)**S(2) + C)*ActivateTrig(u), x), x) rule4721 = ReplacementRule(pattern4721, replacement4721) pattern4722 = Pattern(Integral(u_*(WC('A', S(0)) + WC('B', S(1))/tan(x_*WC('b', S(1)) + WC('a', S(0))) + WC('C', S(1))/tan(x_*WC('b', S(1)) + WC('a', S(0)))**S(2)), x_), cons2, cons3, cons34, cons35, cons36, cons1650) def replacement4722(B, C, u, b, a, x, A): rubi.append(4722) return Int((A*tan(a + b*x)**S(2) + B*tan(a + b*x) + C)*ActivateTrig(u)/tan(a + b*x)**S(2), x) rule4722 = ReplacementRule(pattern4722, replacement4722) pattern4723 = Pattern(Integral(u_*(WC('A', S(0)) + WC('B', S(1))*tan(x_*WC('b', S(1)) + WC('a', S(0))) + WC('C', S(1))*tan(x_*WC('b', S(1)) + WC('a', S(0)))**S(2)), x_), cons2, cons3, cons34, cons35, cons36, cons1651) def replacement4723(B, C, u, b, a, x, A): rubi.append(4723) return Int((A/tan(a + b*x)**S(2) + B/tan(a + b*x) + C)*ActivateTrig(u)*tan(a + b*x)**S(2), x) rule4723 = ReplacementRule(pattern4723, replacement4723) pattern4724 = Pattern(Integral(u_*(A_ + WC('C', S(1))/tan(x_*WC('b', S(1)) + WC('a', S(0)))**S(2)), x_), cons2, cons3, cons34, cons36, cons1650) def replacement4724(C, u, b, a, x, A): rubi.append(4724) return Int((A*tan(a + b*x)**S(2) + C)*ActivateTrig(u)/tan(a + b*x)**S(2), x) rule4724 = ReplacementRule(pattern4724, replacement4724) pattern4725 = Pattern(Integral(u_*(A_ + WC('C', S(1))*tan(x_*WC('b', S(1)) + WC('a', S(0)))**S(2)), x_), cons2, cons3, cons34, cons36, cons1651) def replacement4725(C, u, b, a, x, A): rubi.append(4725) return Int((A/tan(a + b*x)**S(2) + C)*ActivateTrig(u)*tan(a + b*x)**S(2), x) rule4725 = ReplacementRule(pattern4725, replacement4725) pattern4726 = Pattern(Integral(u_*(WC('A', S(0)) + WC('B', S(1))*tan(x_*WC('b', S(1)) + WC('a', S(0))) + WC('C', S(1))/tan(x_*WC('b', S(1)) + WC('a', S(0)))), x_), cons2, cons3, cons34, cons35, cons36, cons1647) def replacement4726(B, C, u, b, a, x, A): rubi.append(4726) return Int((A*tan(a + b*x) + B*tan(a + b*x)**S(2) + C)*ActivateTrig(u)/tan(a + b*x), x) rule4726 = ReplacementRule(pattern4726, replacement4726) pattern4727 = Pattern(Integral(u_*(WC('A', S(1))*tan(x_*WC('b', S(1)) + WC('a', S(0)))**WC('n', S(1)) + WC('B', S(1))*tan(x_*WC('b', S(1)) + WC('a', S(0)))**n1_ + WC('C', S(1))*tan(x_*WC('b', S(1)) + WC('a', S(0)))**n2_), x_), cons2, cons3, cons34, cons35, cons36, cons4, cons1648, cons1649) def replacement4727(B, C, u, n1, b, n2, a, n, x, A): rubi.append(4727) return Int((A + B*tan(a + b*x) + C*tan(a + b*x)**S(2))*ActivateTrig(u)*tan(a + b*x)**n, x) rule4727 = ReplacementRule(pattern4727, replacement4727) pattern4728 = Pattern(Integral(u_*((S(1)/tan(x_*WC('b', S(1)) + WC('a', S(0))))**n1_*WC('B', S(1)) + (S(1)/tan(x_*WC('b', S(1)) + WC('a', S(0))))**n2_*WC('C', S(1)) + (S(1)/tan(x_*WC('b', S(1)) + WC('a', S(0))))**WC('n', S(1))*WC('A', S(1))), x_), cons2, cons3, cons34, cons35, cons36, cons4, cons1648, cons1649) def replacement4728(B, C, u, n1, b, n2, a, n, x, A): rubi.append(4728) return Int((A + B/tan(a + b*x) + C/tan(a + b*x)**S(2))*(S(1)/tan(a + b*x))**n*ActivateTrig(u), x) rule4728 = ReplacementRule(pattern4728, replacement4728) pattern4729 = Pattern(Integral(u_*(WC('c', S(1))*sin(x_*WC('b', S(1)) + WC('a', S(0))))**WC('m', S(1))*(WC('d', S(1))/sin(x_*WC('b', S(1)) + WC('a', S(0))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons21, cons4, cons1652) def replacement4729(u, m, b, d, c, a, n, x): rubi.append(4729) return Dist((c*sin(a + b*x))**m*(d/sin(a + b*x))**m, Int((d/sin(a + b*x))**(-m + n)*ActivateTrig(u), x), x) rule4729 = ReplacementRule(pattern4729, replacement4729) pattern4730 = Pattern(Integral(u_*(WC('c', S(1))*cos(x_*WC('b', S(1)) + WC('a', S(0))))**WC('m', S(1))*(WC('d', S(1))/cos(x_*WC('b', S(1)) + WC('a', S(0))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons21, cons4, cons1652) def replacement4730(u, m, b, d, c, a, n, x): rubi.append(4730) return Dist((c*cos(a + b*x))**m*(d/cos(a + b*x))**m, Int((d/cos(a + b*x))**(-m + n)*ActivateTrig(u), x), x) rule4730 = ReplacementRule(pattern4730, replacement4730) pattern4731 = Pattern(Integral(u_*(WC('c', S(1))*tan(x_*WC('b', S(1)) + WC('a', S(0))))**WC('m', S(1))*(WC('d', S(1))/cos(x_*WC('b', S(1)) + WC('a', S(0))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons21, cons4, cons1652, cons18) def replacement4731(u, m, b, d, c, a, n, x): rubi.append(4731) return Dist((c*tan(a + b*x))**m*(d/sin(a + b*x))**m*(d/cos(a + b*x))**(-m), Int((d/sin(a + b*x))**(-m)*(d/cos(a + b*x))**(m + n)*ActivateTrig(u), x), x) rule4731 = ReplacementRule(pattern4731, replacement4731) pattern4732 = Pattern(Integral(u_*(WC('c', S(1))*tan(x_*WC('b', S(1)) + WC('a', S(0))))**WC('m', S(1))*(WC('d', S(1))/sin(x_*WC('b', S(1)) + WC('a', S(0))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons21, cons4, cons1652, cons18) def replacement4732(u, m, b, d, c, a, n, x): rubi.append(4732) return Dist((c*tan(a + b*x))**m*(d/sin(a + b*x))**m*(d/cos(a + b*x))**(-m), Int((d/sin(a + b*x))**(-m + n)*(d/cos(a + b*x))**m*ActivateTrig(u), x), x) rule4732 = ReplacementRule(pattern4732, replacement4732) pattern4733 = Pattern(Integral(u_*(WC('c', S(1))/tan(x_*WC('b', S(1)) + WC('a', S(0))))**WC('m', S(1))*(WC('d', S(1))/cos(x_*WC('b', S(1)) + WC('a', S(0))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons21, cons4, cons1652, cons18) def replacement4733(u, m, b, d, c, a, n, x): rubi.append(4733) return Dist((c/tan(a + b*x))**m*(d/sin(a + b*x))**(-m)*(d/cos(a + b*x))**m, Int((d/sin(a + b*x))**m*(d/cos(a + b*x))**(-m + n)*ActivateTrig(u), x), x) rule4733 = ReplacementRule(pattern4733, replacement4733) pattern4734 = Pattern(Integral(u_*(WC('c', S(1))/tan(x_*WC('b', S(1)) + WC('a', S(0))))**WC('m', S(1))*(WC('d', S(1))/sin(x_*WC('b', S(1)) + WC('a', S(0))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons21, cons4, cons1652, cons18) def replacement4734(u, m, b, d, c, a, n, x): rubi.append(4734) return Dist((c/tan(a + b*x))**m*(d/sin(a + b*x))**(-m)*(d/cos(a + b*x))**m, Int((d/sin(a + b*x))**(m + n)*(d/cos(a + b*x))**(-m)*ActivateTrig(u), x), x) rule4734 = ReplacementRule(pattern4734, replacement4734) pattern4735 = Pattern(Integral(u_*(WC('c', S(1))*sin(x_*WC('b', S(1)) + WC('a', S(0))))**WC('m', S(1)), x_), cons2, cons3, cons7, cons21, cons18, cons1652) def replacement4735(u, m, b, c, a, x): rubi.append(4735) return Dist((c/sin(a + b*x))**m*(c*sin(a + b*x))**m, Int((c/sin(a + b*x))**(-m)*ActivateTrig(u), x), x) rule4735 = ReplacementRule(pattern4735, replacement4735) pattern4736 = Pattern(Integral(u_*(WC('c', S(1))*cos(x_*WC('b', S(1)) + WC('a', S(0))))**WC('m', S(1)), x_), cons2, cons3, cons7, cons21, cons18, cons1652) def replacement4736(u, m, b, c, a, x): rubi.append(4736) return Dist((c/cos(a + b*x))**m*(c*cos(a + b*x))**m, Int((c/cos(a + b*x))**(-m)*ActivateTrig(u), x), x) rule4736 = ReplacementRule(pattern4736, replacement4736) pattern4737 = Pattern(Integral(u_*(WC('c', S(1))*tan(x_*WC('b', S(1)) + WC('a', S(0))))**WC('m', S(1)), x_), cons2, cons3, cons7, cons21, cons18, cons1652) def replacement4737(u, m, b, c, a, x): rubi.append(4737) return Dist((c/sin(a + b*x))**m*(c/cos(a + b*x))**(-m)*(c*tan(a + b*x))**m, Int((c/sin(a + b*x))**(-m)*(c/cos(a + b*x))**m*ActivateTrig(u), x), x) rule4737 = ReplacementRule(pattern4737, replacement4737) pattern4738 = Pattern(Integral(u_*(WC('c', S(1))/tan(x_*WC('b', S(1)) + WC('a', S(0))))**WC('m', S(1)), x_), cons2, cons3, cons7, cons21, cons18, cons1652) def replacement4738(u, m, b, c, a, x): rubi.append(4738) return Dist((c/sin(a + b*x))**(-m)*(c/cos(a + b*x))**m*(c/tan(a + b*x))**m, Int((c/sin(a + b*x))**m*(c/cos(a + b*x))**(-m)*ActivateTrig(u), x), x) rule4738 = ReplacementRule(pattern4738, replacement4738) pattern4739 = Pattern(Integral(u_*(WC('c', S(1))/cos(x_*WC('b', S(1)) + WC('a', S(0))))**WC('n', S(1))*(A_ + WC('B', S(1))*cos(x_*WC('b', S(1)) + WC('a', S(0)))), x_), cons2, cons3, cons7, cons34, cons35, cons4, cons1652) def replacement4739(B, u, b, c, a, n, x, A): rubi.append(4739) return Dist(c, Int((c/cos(a + b*x))**(n + S(-1))*(A/cos(a + b*x) + B)*ActivateTrig(u), x), x) rule4739 = ReplacementRule(pattern4739, replacement4739) pattern4740 = Pattern(Integral(u_*(WC('c', S(1))/sin(x_*WC('b', S(1)) + WC('a', S(0))))**WC('n', S(1))*(A_ + WC('B', S(1))*sin(x_*WC('b', S(1)) + WC('a', S(0)))), x_), cons2, cons3, cons7, cons34, cons35, cons4, cons1652) def replacement4740(B, u, b, c, a, n, x, A): rubi.append(4740) return Dist(c, Int((c/sin(a + b*x))**(n + S(-1))*(A/sin(a + b*x) + B)*ActivateTrig(u), x), x) rule4740 = ReplacementRule(pattern4740, replacement4740) pattern4741 = Pattern(Integral(u_*(A_ + WC('B', S(1))*cos(x_*WC('b', S(1)) + WC('a', S(0)))), x_), cons2, cons3, cons34, cons35, cons1652) def replacement4741(B, u, b, a, x, A): rubi.append(4741) return Int((A/cos(a + b*x) + B)*ActivateTrig(u)*cos(a + b*x), x) rule4741 = ReplacementRule(pattern4741, replacement4741) pattern4742 = Pattern(Integral(u_*(A_ + WC('B', S(1))*sin(x_*WC('b', S(1)) + WC('a', S(0)))), x_), cons2, cons3, cons34, cons35, cons1652) def replacement4742(B, u, b, a, x, A): rubi.append(4742) return Int((A/sin(a + b*x) + B)*ActivateTrig(u)*sin(a + b*x), x) rule4742 = ReplacementRule(pattern4742, replacement4742) pattern4743 = Pattern(Integral((WC('c', S(1))/cos(x_*WC('b', S(1)) + WC('a', S(0))))**WC('n', S(1))*(WC('A', S(0)) + WC('B', S(1))*cos(x_*WC('b', S(1)) + WC('a', S(0))) + WC('C', S(1))*cos(x_*WC('b', S(1)) + WC('a', S(0)))**S(2))*WC('u', S(1)), x_), cons2, cons3, cons7, cons34, cons35, cons36, cons4, cons1652) def replacement4743(B, C, u, b, a, c, n, x, A): rubi.append(4743) return Dist(c**S(2), Int((c/cos(a + b*x))**(n + S(-2))*(A/cos(a + b*x)**S(2) + B/cos(a + b*x) + C)*ActivateTrig(u), x), x) rule4743 = ReplacementRule(pattern4743, replacement4743) pattern4744 = Pattern(Integral((WC('c', S(1))/sin(x_*WC('b', S(1)) + WC('a', S(0))))**WC('n', S(1))*(WC('A', S(0)) + WC('B', S(1))*sin(x_*WC('b', S(1)) + WC('a', S(0))) + WC('C', S(1))*sin(x_*WC('b', S(1)) + WC('a', S(0)))**S(2))*WC('u', S(1)), x_), cons2, cons3, cons7, cons34, cons35, cons36, cons4, cons1652) def replacement4744(B, C, u, b, c, a, n, x, A): rubi.append(4744) return Dist(c**S(2), Int((c/sin(a + b*x))**(n + S(-2))*(A/sin(a + b*x)**S(2) + B/sin(a + b*x) + C)*ActivateTrig(u), x), x) rule4744 = ReplacementRule(pattern4744, replacement4744) pattern4745 = Pattern(Integral((WC('c', S(1))/cos(x_*WC('b', S(1)) + WC('a', S(0))))**WC('n', S(1))*(A_ + WC('C', S(1))*cos(x_*WC('b', S(1)) + WC('a', S(0)))**S(2))*WC('u', S(1)), x_), cons2, cons3, cons7, cons34, cons36, cons4, cons1652) def replacement4745(C, u, b, c, a, n, x, A): rubi.append(4745) return Dist(c**S(2), Int((c/cos(a + b*x))**(n + S(-2))*(A/cos(a + b*x)**S(2) + C)*ActivateTrig(u), x), x) rule4745 = ReplacementRule(pattern4745, replacement4745) pattern4746 = Pattern(Integral((WC('c', S(1))/sin(x_*WC('b', S(1)) + WC('a', S(0))))**WC('n', S(1))*(A_ + WC('C', S(1))*sin(x_*WC('b', S(1)) + WC('a', S(0)))**S(2))*WC('u', S(1)), x_), cons2, cons3, cons7, cons34, cons36, cons4, cons1652) def replacement4746(C, u, b, c, a, n, x, A): rubi.append(4746) return Dist(c**S(2), Int((c/sin(a + b*x))**(n + S(-2))*(A/sin(a + b*x)**S(2) + C)*ActivateTrig(u), x), x) rule4746 = ReplacementRule(pattern4746, replacement4746) pattern4747 = Pattern(Integral(u_*(WC('A', S(0)) + WC('B', S(1))*cos(x_*WC('b', S(1)) + WC('a', S(0))) + WC('C', S(1))*cos(x_*WC('b', S(1)) + WC('a', S(0)))**S(2)), x_), cons2, cons3, cons34, cons35, cons36, cons1652) def replacement4747(B, C, u, b, a, x, A): rubi.append(4747) return Int((A/cos(a + b*x)**S(2) + B/cos(a + b*x) + C)*ActivateTrig(u)*cos(a + b*x)**S(2), x) rule4747 = ReplacementRule(pattern4747, replacement4747) pattern4748 = Pattern(Integral(u_*(WC('A', S(0)) + WC('B', S(1))*sin(x_*WC('b', S(1)) + WC('a', S(0))) + WC('C', S(1))*sin(x_*WC('b', S(1)) + WC('a', S(0)))**S(2)), x_), cons2, cons3, cons34, cons35, cons36, cons1652) def replacement4748(B, C, u, b, a, x, A): rubi.append(4748) return Int((A/sin(a + b*x)**S(2) + B/sin(a + b*x) + C)*ActivateTrig(u)*sin(a + b*x)**S(2), x) rule4748 = ReplacementRule(pattern4748, replacement4748) pattern4749 = Pattern(Integral(u_*(A_ + WC('C', S(1))*cos(x_*WC('b', S(1)) + WC('a', S(0)))**S(2)), x_), cons2, cons3, cons34, cons36, cons1652) def replacement4749(C, u, b, a, x, A): rubi.append(4749) return Int((A/cos(a + b*x)**S(2) + C)*ActivateTrig(u)*cos(a + b*x)**S(2), x) rule4749 = ReplacementRule(pattern4749, replacement4749) pattern4750 = Pattern(Integral(u_*(A_ + WC('C', S(1))*sin(x_*WC('b', S(1)) + WC('a', S(0)))**S(2)), x_), cons2, cons3, cons34, cons36, cons1652) def replacement4750(C, u, b, a, x, A): rubi.append(4750) return Int((A/sin(a + b*x)**S(2) + C)*ActivateTrig(u)*sin(a + b*x)**S(2), x) rule4750 = ReplacementRule(pattern4750, replacement4750) pattern4751 = Pattern(Integral(u_*((S(1)/cos(x_*WC('b', S(1)) + WC('a', S(0))))**n1_*WC('B', S(1)) + (S(1)/cos(x_*WC('b', S(1)) + WC('a', S(0))))**n2_*WC('C', S(1)) + (S(1)/cos(x_*WC('b', S(1)) + WC('a', S(0))))**WC('n', S(1))*WC('A', S(1))), x_), cons2, cons3, cons34, cons35, cons36, cons4, cons1648, cons1649) def replacement4751(B, C, u, n1, b, n2, a, n, x, A): rubi.append(4751) return Int((A + B/cos(a + b*x) + C/cos(a + b*x)**S(2))*(S(1)/cos(a + b*x))**n*ActivateTrig(u), x) rule4751 = ReplacementRule(pattern4751, replacement4751) pattern4752 = Pattern(Integral(u_*((S(1)/sin(x_*WC('b', S(1)) + WC('a', S(0))))**n1_*WC('B', S(1)) + (S(1)/sin(x_*WC('b', S(1)) + WC('a', S(0))))**n2_*WC('C', S(1)) + (S(1)/sin(x_*WC('b', S(1)) + WC('a', S(0))))**WC('n', S(1))*WC('A', S(1))), x_), cons2, cons3, cons34, cons35, cons36, cons4, cons1648, cons1649) def replacement4752(B, C, u, n1, b, n2, a, n, x, A): rubi.append(4752) return Int((A + B/sin(a + b*x) + C/sin(a + b*x)**S(2))*(S(1)/sin(a + b*x))**n*ActivateTrig(u), x) rule4752 = ReplacementRule(pattern4752, replacement4752) pattern4753 = Pattern(Integral(sin(x_*WC('b', S(1)) + WC('a', S(0)))*sin(x_*WC('d', S(1)) + WC('c', S(0))), x_), cons2, cons3, cons7, cons27, cons1653) def replacement4753(b, d, c, a, x): rubi.append(4753) return Simp(sin(a - c + x*(b - d))/(S(2)*b - S(2)*d), x) - Simp(sin(a + c + x*(b + d))/(S(2)*b + S(2)*d), x) rule4753 = ReplacementRule(pattern4753, replacement4753) pattern4754 = Pattern(Integral(cos(x_*WC('b', S(1)) + WC('a', S(0)))*cos(x_*WC('d', S(1)) + WC('c', S(0))), x_), cons2, cons3, cons7, cons27, cons1653) def replacement4754(b, d, c, a, x): rubi.append(4754) return Simp(sin(a - c + x*(b - d))/(S(2)*b - S(2)*d), x) + Simp(sin(a + c + x*(b + d))/(S(2)*b + S(2)*d), x) rule4754 = ReplacementRule(pattern4754, replacement4754) pattern4755 = Pattern(Integral(sin(x_*WC('b', S(1)) + WC('a', S(0)))*cos(x_*WC('d', S(1)) + WC('c', S(0))), x_), cons2, cons3, cons7, cons27, cons1653) def replacement4755(b, d, c, a, x): rubi.append(4755) return -Simp(cos(a - c + x*(b - d))/(S(2)*b - S(2)*d), x) - Simp(cos(a + c + x*(b + d))/(S(2)*b + S(2)*d), x) rule4755 = ReplacementRule(pattern4755, replacement4755) pattern4756 = Pattern(Integral((WC('g', S(1))*sin(x_*WC('d', S(1)) + WC('c', S(0))))**p_*cos(x_*WC('b', S(1)) + WC('a', S(0)))**S(2), x_), cons2, cons3, cons7, cons27, cons208, cons25, cons1654, cons1408) def replacement4756(p, g, b, d, c, a, x): rubi.append(4756) return Dist(S(1)/2, Int((g*sin(c + d*x))**p, x), x) + Dist(S(1)/2, Int((g*sin(c + d*x))**p*cos(c + d*x), x), x) rule4756 = ReplacementRule(pattern4756, replacement4756) pattern4757 = Pattern(Integral((WC('g', S(1))*sin(x_*WC('d', S(1)) + WC('c', S(0))))**p_*sin(x_*WC('b', S(1)) + WC('a', S(0)))**S(2), x_), cons2, cons3, cons7, cons27, cons208, cons25, cons1654, cons1408) def replacement4757(p, g, b, d, c, a, x): rubi.append(4757) return Dist(S(1)/2, Int((g*sin(c + d*x))**p, x), x) - Dist(S(1)/2, Int((g*sin(c + d*x))**p*cos(c + d*x), x), x) rule4757 = ReplacementRule(pattern4757, replacement4757) pattern4758 = Pattern(Integral((WC('e', S(1))*cos(x_*WC('b', S(1)) + WC('a', S(0))))**WC('m', S(1))*sin(x_*WC('d', S(1)) + WC('c', S(0)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons21, cons25, cons1654, cons38) def replacement4758(p, m, b, d, a, c, x, e): rubi.append(4758) return Dist(S(2)**p*e**(-p), Int((e*cos(a + b*x))**(m + p)*sin(a + b*x)**p, x), x) rule4758 = ReplacementRule(pattern4758, replacement4758) pattern4759 = Pattern(Integral((WC('f', S(1))*sin(x_*WC('b', S(1)) + WC('a', S(0))))**WC('n', S(1))*sin(x_*WC('d', S(1)) + WC('c', S(0)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons125, cons4, cons25, cons1654, cons38) def replacement4759(p, f, b, d, c, a, n, x): rubi.append(4759) return Dist(S(2)**p*f**(-p), Int((f*sin(a + b*x))**(n + p)*cos(a + b*x)**p, x), x) rule4759 = ReplacementRule(pattern4759, replacement4759) pattern4760 = Pattern(Integral((WC('e', S(1))*cos(x_*WC('b', S(1)) + WC('a', S(0))))**m_*(WC('g', S(1))*sin(x_*WC('d', S(1)) + WC('c', S(0))))**p_, x_), cons2, cons3, cons7, cons27, cons48, cons208, cons21, cons5, cons25, cons1654, cons147, cons343) def replacement4760(p, m, g, b, d, c, a, x, e): rubi.append(4760) return Simp(e**S(2)*(e*cos(a + b*x))**(m + S(-2))*(g*sin(c + d*x))**(p + S(1))/(S(2)*b*g*(p + S(1))), x) rule4760 = ReplacementRule(pattern4760, replacement4760) pattern4761 = Pattern(Integral((WC('e', S(1))*sin(x_*WC('b', S(1)) + WC('a', S(0))))**m_*(WC('g', S(1))*sin(x_*WC('d', S(1)) + WC('c', S(0))))**p_, x_), cons2, cons3, cons7, cons27, cons48, cons208, cons21, cons5, cons25, cons1654, cons147, cons343) def replacement4761(p, m, g, b, d, c, a, x, e): rubi.append(4761) return -Simp(e**S(2)*(e*sin(a + b*x))**(m + S(-2))*(g*sin(c + d*x))**(p + S(1))/(S(2)*b*g*(p + S(1))), x) rule4761 = ReplacementRule(pattern4761, replacement4761) pattern4762 = Pattern(Integral((WC('e', S(1))*cos(x_*WC('b', S(1)) + WC('a', S(0))))**WC('m', S(1))*(WC('g', S(1))*sin(x_*WC('d', S(1)) + WC('c', S(0))))**p_, x_), cons2, cons3, cons7, cons27, cons48, cons208, cons21, cons5, cons25, cons1654, cons147, cons240) def replacement4762(p, m, g, b, d, a, c, x, e): rubi.append(4762) return -Simp((e*cos(a + b*x))**m*(g*sin(c + d*x))**(p + S(1))/(b*g*m), x) rule4762 = ReplacementRule(pattern4762, replacement4762) pattern4763 = Pattern(Integral((WC('e', S(1))*sin(x_*WC('b', S(1)) + WC('a', S(0))))**WC('m', S(1))*(WC('g', S(1))*sin(x_*WC('d', S(1)) + WC('c', S(0))))**p_, x_), cons2, cons3, cons7, cons27, cons48, cons208, cons21, cons5, cons25, cons1654, cons147, cons240) def replacement4763(p, m, g, b, d, a, c, x, e): rubi.append(4763) return Simp((e*sin(a + b*x))**m*(g*sin(c + d*x))**(p + S(1))/(b*g*m), x) rule4763 = ReplacementRule(pattern4763, replacement4763) pattern4764 = Pattern(Integral((WC('e', S(1))*cos(x_*WC('b', S(1)) + WC('a', S(0))))**m_*(WC('g', S(1))*sin(x_*WC('d', S(1)) + WC('c', S(0))))**p_, x_), cons2, cons3, cons7, cons27, cons48, cons208, cons25, cons1654, cons147, cons244, cons1333, cons137, cons1655, cons1288) def replacement4764(p, m, g, b, d, c, a, x, e): rubi.append(4764) return Dist(e**S(4)*(m + p + S(-1))/(S(4)*g**S(2)*(p + S(1))), Int((e*cos(a + b*x))**(m + S(-4))*(g*sin(c + d*x))**(p + S(2)), x), x) + Simp(e**S(2)*(e*cos(a + b*x))**(m + S(-2))*(g*sin(c + d*x))**(p + S(1))/(S(2)*b*g*(p + S(1))), x) rule4764 = ReplacementRule(pattern4764, replacement4764) pattern4765 = Pattern(Integral((WC('e', S(1))*sin(x_*WC('b', S(1)) + WC('a', S(0))))**m_*(WC('g', S(1))*sin(x_*WC('d', S(1)) + WC('c', S(0))))**p_, x_), cons2, cons3, cons7, cons27, cons48, cons208, cons25, cons1654, cons147, cons244, cons1333, cons137, cons1655, cons1288) def replacement4765(p, m, g, b, d, c, a, x, e): rubi.append(4765) return Dist(e**S(4)*(m + p + S(-1))/(S(4)*g**S(2)*(p + S(1))), Int((e*sin(a + b*x))**(m + S(-4))*(g*sin(c + d*x))**(p + S(2)), x), x) - Simp(e**S(2)*(e*sin(a + b*x))**(m + S(-2))*(g*sin(c + d*x))**(p + S(1))/(S(2)*b*g*(p + S(1))), x) rule4765 = ReplacementRule(pattern4765, replacement4765) pattern4766 = Pattern(Integral((WC('e', S(1))*cos(x_*WC('b', S(1)) + WC('a', S(0))))**m_*(WC('g', S(1))*sin(x_*WC('d', S(1)) + WC('c', S(0))))**p_, x_), cons2, cons3, cons7, cons27, cons48, cons208, cons25, cons1654, cons147, cons244, cons166, cons137, cons319, cons1656, cons1288) def replacement4766(p, m, g, b, d, c, a, x, e): rubi.append(4766) return Dist(e**S(2)*(m + S(2)*p + S(2))/(S(4)*g**S(2)*(p + S(1))), Int((e*cos(a + b*x))**(m + S(-2))*(g*sin(c + d*x))**(p + S(2)), x), x) + Simp((e*cos(a + b*x))**m*(g*sin(c + d*x))**(p + S(1))/(S(2)*b*g*(p + S(1))), x) rule4766 = ReplacementRule(pattern4766, replacement4766) pattern4767 = Pattern(Integral((WC('e', S(1))*sin(x_*WC('b', S(1)) + WC('a', S(0))))**m_*(WC('g', S(1))*sin(x_*WC('d', S(1)) + WC('c', S(0))))**p_, x_), cons2, cons3, cons7, cons27, cons48, cons208, cons25, cons1654, cons147, cons244, cons166, cons137, cons319, cons1656, cons1288) def replacement4767(p, m, g, b, d, c, a, x, e): rubi.append(4767) return Dist(e**S(2)*(m + S(2)*p + S(2))/(S(4)*g**S(2)*(p + S(1))), Int((e*sin(a + b*x))**(m + S(-2))*(g*sin(c + d*x))**(p + S(2)), x), x) - Simp((e*sin(a + b*x))**m*(g*sin(c + d*x))**(p + S(1))/(S(2)*b*g*(p + S(1))), x) rule4767 = ReplacementRule(pattern4767, replacement4767) pattern4768 = Pattern(Integral((WC('e', S(1))*cos(x_*WC('b', S(1)) + WC('a', S(0))))**m_*(WC('g', S(1))*sin(x_*WC('d', S(1)) + WC('c', S(0))))**p_, x_), cons2, cons3, cons7, cons27, cons48, cons208, cons5, cons25, cons1654, cons147, cons31, cons166, cons249, cons1288) def replacement4768(p, m, g, b, d, c, a, x, e): rubi.append(4768) return Dist(e**S(2)*(m + p + S(-1))/(m + S(2)*p), Int((e*cos(a + b*x))**(m + S(-2))*(g*sin(c + d*x))**p, x), x) + Simp(e**S(2)*(e*cos(a + b*x))**(m + S(-2))*(g*sin(c + d*x))**(p + S(1))/(S(2)*b*g*(m + S(2)*p)), x) rule4768 = ReplacementRule(pattern4768, replacement4768) pattern4769 = Pattern(Integral((WC('e', S(1))*sin(x_*WC('b', S(1)) + WC('a', S(0))))**m_*(WC('g', S(1))*sin(x_*WC('d', S(1)) + WC('c', S(0))))**p_, x_), cons2, cons3, cons7, cons27, cons48, cons208, cons5, cons25, cons1654, cons147, cons31, cons166, cons249, cons1288) def replacement4769(p, m, g, b, d, c, a, x, e): rubi.append(4769) return Dist(e**S(2)*(m + p + S(-1))/(m + S(2)*p), Int((e*sin(a + b*x))**(m + S(-2))*(g*sin(c + d*x))**p, x), x) - Simp(e**S(2)*(e*sin(a + b*x))**(m + S(-2))*(g*sin(c + d*x))**(p + S(1))/(S(2)*b*g*(m + S(2)*p)), x) rule4769 = ReplacementRule(pattern4769, replacement4769) pattern4770 = Pattern(Integral((WC('e', S(1))*cos(x_*WC('b', S(1)) + WC('a', S(0))))**m_*(WC('g', S(1))*sin(x_*WC('d', S(1)) + WC('c', S(0))))**p_, x_), cons2, cons3, cons7, cons27, cons48, cons208, cons5, cons25, cons1654, cons147, cons31, cons94, cons319, cons253, cons1288) def replacement4770(p, m, g, b, d, c, a, x, e): rubi.append(4770) return Dist((m + S(2)*p + S(2))/(e**S(2)*(m + p + S(1))), Int((e*cos(a + b*x))**(m + S(2))*(g*sin(c + d*x))**p, x), x) - Simp((e*cos(a + b*x))**m*(g*sin(c + d*x))**(p + S(1))/(S(2)*b*g*(m + p + S(1))), x) rule4770 = ReplacementRule(pattern4770, replacement4770) pattern4771 = Pattern(Integral((WC('e', S(1))*sin(x_*WC('b', S(1)) + WC('a', S(0))))**m_*(WC('g', S(1))*sin(x_*WC('d', S(1)) + WC('c', S(0))))**p_, x_), cons2, cons3, cons7, cons27, cons48, cons208, cons5, cons25, cons1654, cons147, cons31, cons94, cons319, cons253, cons1288) def replacement4771(p, m, g, b, d, c, a, x, e): rubi.append(4771) return Dist((m + S(2)*p + S(2))/(e**S(2)*(m + p + S(1))), Int((e*sin(a + b*x))**(m + S(2))*(g*sin(c + d*x))**p, x), x) + Simp((e*sin(a + b*x))**m*(g*sin(c + d*x))**(p + S(1))/(S(2)*b*g*(m + p + S(1))), x) rule4771 = ReplacementRule(pattern4771, replacement4771) pattern4772 = Pattern(Integral((WC('g', S(1))*sin(x_*WC('d', S(1)) + WC('c', S(0))))**p_*cos(x_*WC('b', S(1)) + WC('a', S(0))), x_), cons2, cons3, cons7, cons27, cons208, cons25, cons1654, cons147, cons13, cons163, cons246) def replacement4772(p, g, b, d, c, a, x): rubi.append(4772) return Dist(S(2)*g*p/(S(2)*p + S(1)), Int((g*sin(c + d*x))**(p + S(-1))*sin(a + b*x), x), x) + Simp(S(2)*(g*sin(c + d*x))**p*sin(a + b*x)/(d*(S(2)*p + S(1))), x) rule4772 = ReplacementRule(pattern4772, replacement4772) pattern4773 = Pattern(Integral((WC('g', S(1))*sin(x_*WC('d', S(1)) + WC('c', S(0))))**p_*sin(x_*WC('b', S(1)) + WC('a', S(0))), x_), cons2, cons3, cons7, cons27, cons208, cons25, cons1654, cons147, cons13, cons163, cons246) def replacement4773(p, g, b, d, c, a, x): rubi.append(4773) return Dist(S(2)*g*p/(S(2)*p + S(1)), Int((g*sin(c + d*x))**(p + S(-1))*cos(a + b*x), x), x) + Simp(-S(2)*(g*sin(c + d*x))**p*cos(a + b*x)/(d*(S(2)*p + S(1))), x) rule4773 = ReplacementRule(pattern4773, replacement4773) pattern4774 = Pattern(Integral((WC('g', S(1))*sin(x_*WC('d', S(1)) + WC('c', S(0))))**p_*cos(x_*WC('b', S(1)) + WC('a', S(0))), x_), cons2, cons3, cons7, cons27, cons208, cons25, cons1654, cons147, cons13, cons137, cons246) def replacement4774(p, g, b, d, c, a, x): rubi.append(4774) return Dist((S(2)*p + S(3))/(S(2)*g*(p + S(1))), Int((g*sin(c + d*x))**(p + S(1))*sin(a + b*x), x), x) + Simp((g*sin(c + d*x))**(p + S(1))*cos(a + b*x)/(S(2)*b*g*(p + S(1))), x) rule4774 = ReplacementRule(pattern4774, replacement4774) pattern4775 = Pattern(Integral((WC('g', S(1))*sin(x_*WC('d', S(1)) + WC('c', S(0))))**p_*sin(x_*WC('b', S(1)) + WC('a', S(0))), x_), cons2, cons3, cons7, cons27, cons208, cons25, cons1654, cons147, cons13, cons137, cons246) def replacement4775(p, g, b, d, c, a, x): rubi.append(4775) return Dist((S(2)*p + S(3))/(S(2)*g*(p + S(1))), Int((g*sin(c + d*x))**(p + S(1))*cos(a + b*x), x), x) - Simp((g*sin(c + d*x))**(p + S(1))*sin(a + b*x)/(S(2)*b*g*(p + S(1))), x) rule4775 = ReplacementRule(pattern4775, replacement4775) pattern4776 = Pattern(Integral(cos(x_*WC('b', S(1)) + WC('a', S(0)))/sqrt(sin(x_*WC('d', S(1)) + WC('c', S(0)))), x_), cons2, cons3, cons7, cons27, cons25, cons1654) def replacement4776(b, d, c, a, x): rubi.append(4776) return Simp(log(sin(a + b*x) + sqrt(sin(c + d*x)) + cos(a + b*x))/d, x) - Simp(-asin(sin(a + b*x) - cos(a + b*x))/d, x) rule4776 = ReplacementRule(pattern4776, replacement4776) pattern4777 = Pattern(Integral(sin(x_*WC('b', S(1)) + WC('a', S(0)))/sqrt(sin(x_*WC('d', S(1)) + WC('c', S(0)))), x_), cons2, cons3, cons7, cons27, cons25, cons1654) def replacement4777(b, d, c, a, x): rubi.append(4777) return -Simp(log(sin(a + b*x) + sqrt(sin(c + d*x)) + cos(a + b*x))/d, x) - Simp(-asin(sin(a + b*x) - cos(a + b*x))/d, x) rule4777 = ReplacementRule(pattern4777, replacement4777) pattern4778 = Pattern(Integral((WC('g', S(1))*sin(x_*WC('d', S(1)) + WC('c', S(0))))**p_/cos(x_*WC('b', S(1)) + WC('a', S(0))), x_), cons2, cons3, cons7, cons27, cons208, cons5, cons25, cons1654, cons147, cons246) def replacement4778(p, g, b, d, c, a, x): rubi.append(4778) return Dist(S(2)*g, Int((g*sin(c + d*x))**(p + S(-1))*sin(a + b*x), x), x) rule4778 = ReplacementRule(pattern4778, replacement4778) pattern4779 = Pattern(Integral((WC('g', S(1))*sin(x_*WC('d', S(1)) + WC('c', S(0))))**p_/sin(x_*WC('b', S(1)) + WC('a', S(0))), x_), cons2, cons3, cons7, cons27, cons208, cons5, cons25, cons1654, cons147, cons246) def replacement4779(p, g, b, d, c, a, x): rubi.append(4779) return Dist(S(2)*g, Int((g*sin(c + d*x))**(p + S(-1))*cos(a + b*x), x), x) rule4779 = ReplacementRule(pattern4779, replacement4779) pattern4780 = Pattern(Integral((WC('e', S(1))*cos(x_*WC('b', S(1)) + WC('a', S(0))))**WC('m', S(1))*(WC('g', S(1))*sin(x_*WC('d', S(1)) + WC('c', S(0))))**p_, x_), cons2, cons3, cons7, cons27, cons48, cons208, cons21, cons5, cons25, cons1654, cons147) def replacement4780(p, m, g, b, d, a, c, x, e): rubi.append(4780) return Dist((e*cos(a + b*x))**(-p)*(g*sin(c + d*x))**p*sin(a + b*x)**(-p), Int((e*cos(a + b*x))**(m + p)*sin(a + b*x)**p, x), x) rule4780 = ReplacementRule(pattern4780, replacement4780) pattern4781 = Pattern(Integral((WC('f', S(1))*sin(x_*WC('b', S(1)) + WC('a', S(0))))**WC('n', S(1))*(WC('g', S(1))*sin(x_*WC('d', S(1)) + WC('c', S(0))))**p_, x_), cons2, cons3, cons7, cons27, cons125, cons208, cons4, cons5, cons25, cons1654, cons147) def replacement4781(p, g, f, b, d, a, n, c, x): rubi.append(4781) return Dist((f*sin(a + b*x))**(-p)*(g*sin(c + d*x))**p*cos(a + b*x)**(-p), Int((f*sin(a + b*x))**(n + p)*cos(a + b*x)**p, x), x) rule4781 = ReplacementRule(pattern4781, replacement4781) pattern4782 = Pattern(Integral((WC('g', S(1))*sin(x_*WC('d', S(1)) + WC('c', S(0))))**p_*sin(x_*WC('b', S(1)) + WC('a', S(0)))**S(2)*cos(x_*WC('b', S(1)) + WC('a', S(0)))**S(2), x_), cons2, cons3, cons7, cons27, cons208, cons25, cons1654, cons1408) def replacement4782(p, g, b, d, c, a, x): rubi.append(4782) return Dist(S(1)/4, Int((g*sin(c + d*x))**p, x), x) - Dist(S(1)/4, Int((g*sin(c + d*x))**p*cos(c + d*x)**S(2), x), x) rule4782 = ReplacementRule(pattern4782, replacement4782) pattern4783 = Pattern(Integral((WC('e', S(1))*cos(x_*WC('b', S(1)) + WC('a', S(0))))**WC('m', S(1))*(WC('f', S(1))*sin(x_*WC('b', S(1)) + WC('a', S(0))))**WC('n', S(1))*sin(x_*WC('d', S(1)) + WC('c', S(0)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons4, cons25, cons1654, cons38) def replacement4783(p, m, f, b, d, a, n, c, x, e): rubi.append(4783) return Dist(S(2)**p*e**(-p)*f**(-p), Int((e*cos(a + b*x))**(m + p)*(f*sin(a + b*x))**(n + p), x), x) rule4783 = ReplacementRule(pattern4783, replacement4783) pattern4784 = Pattern(Integral((WC('e', S(1))*cos(x_*WC('b', S(1)) + WC('a', S(0))))**WC('m', S(1))*(WC('f', S(1))*sin(x_*WC('b', S(1)) + WC('a', S(0))))**WC('n', S(1))*(WC('g', S(1))*sin(x_*WC('d', S(1)) + WC('c', S(0))))**p_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons21, cons4, cons5, cons25, cons1654, cons147, cons1278) def replacement4784(p, m, f, b, g, d, a, n, c, x, e): rubi.append(4784) return Simp(e*(e*cos(a + b*x))**(m + S(-1))*(f*sin(a + b*x))**(n + S(1))*(g*sin(c + d*x))**p/(b*f*(n + p + S(1))), x) rule4784 = ReplacementRule(pattern4784, replacement4784) pattern4785 = Pattern(Integral((WC('e', S(1))*sin(x_*WC('b', S(1)) + WC('a', S(0))))**m_*(WC('f', S(1))*cos(x_*WC('b', S(1)) + WC('a', S(0))))**n_*(WC('g', S(1))*sin(x_*WC('d', S(1)) + WC('c', S(0))))**p_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons21, cons4, cons5, cons25, cons1654, cons147, cons1278) def replacement4785(p, m, f, b, g, d, a, c, n, x, e): rubi.append(4785) return -Simp(e*(e*sin(a + b*x))**(m + S(-1))*(f*cos(a + b*x))**(n + S(1))*(g*sin(c + d*x))**p/(b*f*(n + p + S(1))), x) rule4785 = ReplacementRule(pattern4785, replacement4785) pattern4786 = Pattern(Integral((WC('e', S(1))*cos(x_*WC('b', S(1)) + WC('a', S(0))))**WC('m', S(1))*(WC('f', S(1))*sin(x_*WC('b', S(1)) + WC('a', S(0))))**WC('n', S(1))*(WC('g', S(1))*sin(x_*WC('d', S(1)) + WC('c', S(0))))**p_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons21, cons4, cons5, cons25, cons1654, cons147, cons1657, cons253) def replacement4786(p, m, f, b, g, d, a, n, c, x, e): rubi.append(4786) return -Simp((e*cos(a + b*x))**(m + S(1))*(f*sin(a + b*x))**(n + S(1))*(g*sin(c + d*x))**p/(b*e*f*(m + p + S(1))), x) rule4786 = ReplacementRule(pattern4786, replacement4786) pattern4787 = Pattern(Integral((WC('e', S(1))*cos(x_*WC('b', S(1)) + WC('a', S(0))))**m_*(WC('f', S(1))*sin(x_*WC('b', S(1)) + WC('a', S(0))))**n_*(WC('g', S(1))*sin(x_*WC('d', S(1)) + WC('c', S(0))))**p_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons4, cons25, cons1654, cons147, cons244, cons1658, cons137, cons1659, cons170) def replacement4787(p, m, f, b, g, d, a, c, n, x, e): rubi.append(4787) return Dist(e**S(4)*(m + p + S(-1))/(S(4)*g**S(2)*(n + p + S(1))), Int((e*cos(a + b*x))**(m + S(-4))*(f*sin(a + b*x))**n*(g*sin(c + d*x))**(p + S(2)), x), x) + Simp(e**S(2)*(e*cos(a + b*x))**(m + S(-2))*(f*sin(a + b*x))**n*(g*sin(c + d*x))**(p + S(1))/(S(2)*b*g*(n + p + S(1))), x) rule4787 = ReplacementRule(pattern4787, replacement4787) pattern4788 = Pattern(Integral((WC('e', S(1))*sin(x_*WC('b', S(1)) + WC('a', S(0))))**m_*(WC('f', S(1))*cos(x_*WC('b', S(1)) + WC('a', S(0))))**n_*(WC('g', S(1))*sin(x_*WC('d', S(1)) + WC('c', S(0))))**p_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons4, cons25, cons1654, cons147, cons244, cons1658, cons137, cons1659, cons170) def replacement4788(p, m, f, b, g, d, a, c, n, x, e): rubi.append(4788) return Dist(e**S(4)*(m + p + S(-1))/(S(4)*g**S(2)*(n + p + S(1))), Int((e*sin(a + b*x))**(m + S(-4))*(f*cos(a + b*x))**n*(g*sin(c + d*x))**(p + S(2)), x), x) - Simp(e**S(2)*(e*sin(a + b*x))**(m + S(-2))*(f*cos(a + b*x))**n*(g*sin(c + d*x))**(p + S(1))/(S(2)*b*g*(n + p + S(1))), x) rule4788 = ReplacementRule(pattern4788, replacement4788) pattern4789 = Pattern(Integral((WC('e', S(1))*cos(x_*WC('b', S(1)) + WC('a', S(0))))**m_*(WC('f', S(1))*sin(x_*WC('b', S(1)) + WC('a', S(0))))**WC('n', S(1))*(WC('g', S(1))*sin(x_*WC('d', S(1)) + WC('c', S(0))))**p_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons4, cons25, cons1654, cons147, cons244, cons166, cons137, cons1660, cons1659, cons170, cons1661) def replacement4789(p, m, f, b, g, d, a, n, c, x, e): rubi.append(4789) return Dist(e**S(2)*(m + n + S(2)*p + S(2))/(S(4)*g**S(2)*(n + p + S(1))), Int((e*cos(a + b*x))**(m + S(-2))*(f*sin(a + b*x))**n*(g*sin(c + d*x))**(p + S(2)), x), x) + Simp((e*cos(a + b*x))**m*(f*sin(a + b*x))**n*(g*sin(c + d*x))**(p + S(1))/(S(2)*b*g*(n + p + S(1))), x) rule4789 = ReplacementRule(pattern4789, replacement4789) pattern4790 = Pattern(Integral((WC('e', S(1))*sin(x_*WC('b', S(1)) + WC('a', S(0))))**m_*(WC('f', S(1))*cos(x_*WC('b', S(1)) + WC('a', S(0))))**WC('n', S(1))*(WC('g', S(1))*sin(x_*WC('d', S(1)) + WC('c', S(0))))**p_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons4, cons25, cons1654, cons147, cons244, cons166, cons137, cons1660, cons1659, cons170, cons1661) def replacement4790(p, m, f, b, g, d, a, n, c, x, e): rubi.append(4790) return Dist(e**S(2)*(m + n + S(2)*p + S(2))/(S(4)*g**S(2)*(n + p + S(1))), Int((e*sin(a + b*x))**(m + S(-2))*(f*cos(a + b*x))**n*(g*sin(c + d*x))**(p + S(2)), x), x) - Simp((e*sin(a + b*x))**m*(f*cos(a + b*x))**n*(g*sin(c + d*x))**(p + S(1))/(S(2)*b*g*(n + p + S(1))), x) rule4790 = ReplacementRule(pattern4790, replacement4790) pattern4791 = Pattern(Integral((WC('e', S(1))*cos(x_*WC('b', S(1)) + WC('a', S(0))))**m_*(WC('f', S(1))*sin(x_*WC('b', S(1)) + WC('a', S(0))))**n_*(WC('g', S(1))*sin(x_*WC('d', S(1)) + WC('c', S(0))))**p_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons5, cons25, cons1654, cons147, cons93, cons166, cons89, cons1659, cons170) def replacement4791(p, m, f, b, g, d, a, c, n, x, e): rubi.append(4791) return Dist(e**S(2)*(m + p + S(-1))/(f**S(2)*(n + p + S(1))), Int((e*cos(a + b*x))**(m + S(-2))*(f*sin(a + b*x))**(n + S(2))*(g*sin(c + d*x))**p, x), x) + Simp(e*(e*cos(a + b*x))**(m + S(-1))*(f*sin(a + b*x))**(n + S(1))*(g*sin(c + d*x))**p/(b*f*(n + p + S(1))), x) rule4791 = ReplacementRule(pattern4791, replacement4791) pattern4792 = Pattern(Integral((WC('e', S(1))*sin(x_*WC('b', S(1)) + WC('a', S(0))))**m_*(WC('f', S(1))*cos(x_*WC('b', S(1)) + WC('a', S(0))))**n_*(WC('g', S(1))*sin(x_*WC('d', S(1)) + WC('c', S(0))))**p_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons5, cons25, cons1654, cons147, cons93, cons166, cons89, cons1659, cons170) def replacement4792(p, m, f, b, g, d, a, c, n, x, e): rubi.append(4792) return Dist(e**S(2)*(m + p + S(-1))/(f**S(2)*(n + p + S(1))), Int((e*sin(a + b*x))**(m + S(-2))*(f*cos(a + b*x))**(n + S(2))*(g*sin(c + d*x))**p, x), x) - Simp(e*(e*sin(a + b*x))**(m + S(-1))*(f*cos(a + b*x))**(n + S(1))*(g*sin(c + d*x))**p/(b*f*(n + p + S(1))), x) rule4792 = ReplacementRule(pattern4792, replacement4792) pattern4793 = Pattern(Integral((WC('e', S(1))*cos(x_*WC('b', S(1)) + WC('a', S(0))))**m_*(WC('f', S(1))*sin(x_*WC('b', S(1)) + WC('a', S(0))))**WC('n', S(1))*(WC('g', S(1))*sin(x_*WC('d', S(1)) + WC('c', S(0))))**p_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons4, cons5, cons25, cons1654, cons147, cons31, cons166, cons1662, cons170) def replacement4793(p, m, f, b, g, d, a, n, c, x, e): rubi.append(4793) return Dist(e**S(2)*(m + p + S(-1))/(m + n + S(2)*p), Int((e*cos(a + b*x))**(m + S(-2))*(f*sin(a + b*x))**n*(g*sin(c + d*x))**p, x), x) + Simp(e*(e*cos(a + b*x))**(m + S(-1))*(f*sin(a + b*x))**(n + S(1))*(g*sin(c + d*x))**p/(b*f*(m + n + S(2)*p)), x) rule4793 = ReplacementRule(pattern4793, replacement4793) pattern4794 = Pattern(Integral((WC('e', S(1))*sin(x_*WC('b', S(1)) + WC('a', S(0))))**m_*(WC('f', S(1))*cos(x_*WC('b', S(1)) + WC('a', S(0))))**WC('n', S(1))*(WC('g', S(1))*sin(x_*WC('d', S(1)) + WC('c', S(0))))**p_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons4, cons5, cons25, cons1654, cons147, cons31, cons166, cons1662, cons170) def replacement4794(p, m, f, b, g, d, a, n, c, x, e): rubi.append(4794) return Dist(e**S(2)*(m + p + S(-1))/(m + n + S(2)*p), Int((e*sin(a + b*x))**(m + S(-2))*(f*cos(a + b*x))**n*(g*sin(c + d*x))**p, x), x) - Simp(e*(e*sin(a + b*x))**(m + S(-1))*(f*cos(a + b*x))**(n + S(1))*(g*sin(c + d*x))**p/(b*f*(m + n + S(2)*p)), x) rule4794 = ReplacementRule(pattern4794, replacement4794) pattern4795 = Pattern(Integral((WC('e', S(1))*cos(x_*WC('b', S(1)) + WC('a', S(0))))**m_*(WC('f', S(1))*sin(x_*WC('b', S(1)) + WC('a', S(0))))**WC('n', S(1))*(WC('g', S(1))*sin(x_*WC('d', S(1)) + WC('c', S(0))))**p_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons25, cons1654, cons147, cons162, cons94, cons88, cons163, cons1662, cons170) def replacement4795(p, m, f, b, g, d, a, n, c, x, e): rubi.append(4795) return Dist(S(2)*f*g*(n + p + S(-1))/(e*(m + n + S(2)*p)), Int((e*cos(a + b*x))**(m + S(1))*(f*sin(a + b*x))**(n + S(-1))*(g*sin(c + d*x))**(p + S(-1)), x), x) - Simp(f*(e*cos(a + b*x))**(m + S(1))*(f*sin(a + b*x))**(n + S(-1))*(g*sin(c + d*x))**p/(b*e*(m + n + S(2)*p)), x) rule4795 = ReplacementRule(pattern4795, replacement4795) pattern4796 = Pattern(Integral((WC('e', S(1))*sin(x_*WC('b', S(1)) + WC('a', S(0))))**m_*(WC('f', S(1))*cos(x_*WC('b', S(1)) + WC('a', S(0))))**WC('n', S(1))*(WC('g', S(1))*sin(x_*WC('d', S(1)) + WC('c', S(0))))**p_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons25, cons1654, cons147, cons162, cons94, cons88, cons163, cons1662, cons170) def replacement4796(p, m, f, b, g, d, a, n, c, x, e): rubi.append(4796) return Dist(S(2)*f*g*(n + p + S(-1))/(e*(m + n + S(2)*p)), Int((e*sin(a + b*x))**(m + S(1))*(f*cos(a + b*x))**(n + S(-1))*(g*sin(c + d*x))**(p + S(-1)), x), x) + Simp(f*(e*sin(a + b*x))**(m + S(1))*(f*cos(a + b*x))**(n + S(-1))*(g*sin(c + d*x))**p/(b*e*(m + n + S(2)*p)), x) rule4796 = ReplacementRule(pattern4796, replacement4796) pattern4797 = Pattern(Integral((WC('e', S(1))*cos(x_*WC('b', S(1)) + WC('a', S(0))))**m_*(WC('f', S(1))*sin(x_*WC('b', S(1)) + WC('a', S(0))))**WC('n', S(1))*(WC('g', S(1))*sin(x_*WC('d', S(1)) + WC('c', S(0))))**p_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons25, cons1654, cons147, cons162, cons94, cons88, cons137, cons1660, cons253, cons170) def replacement4797(p, m, f, b, g, d, a, n, c, x, e): rubi.append(4797) return Dist(f*(m + n + S(2)*p + S(2))/(S(2)*e*g*(m + p + S(1))), Int((e*cos(a + b*x))**(m + S(1))*(f*sin(a + b*x))**(n + S(-1))*(g*sin(c + d*x))**(p + S(1)), x), x) - Simp((e*cos(a + b*x))**(m + S(1))*(f*sin(a + b*x))**(n + S(1))*(g*sin(c + d*x))**p/(b*e*f*(m + p + S(1))), x) rule4797 = ReplacementRule(pattern4797, replacement4797) pattern4798 = Pattern(Integral((WC('e', S(1))*sin(x_*WC('b', S(1)) + WC('a', S(0))))**m_*(WC('f', S(1))*cos(x_*WC('b', S(1)) + WC('a', S(0))))**WC('n', S(1))*(WC('g', S(1))*sin(x_*WC('d', S(1)) + WC('c', S(0))))**p_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons25, cons1654, cons147, cons162, cons94, cons88, cons137, cons1660, cons253, cons170) def replacement4798(p, m, f, b, g, d, a, n, c, x, e): rubi.append(4798) return Dist(f*(m + n + S(2)*p + S(2))/(S(2)*e*g*(m + p + S(1))), Int((e*sin(a + b*x))**(m + S(1))*(f*cos(a + b*x))**(n + S(-1))*(g*sin(c + d*x))**(p + S(1)), x), x) + Simp((e*sin(a + b*x))**(m + S(1))*(f*cos(a + b*x))**(n + S(1))*(g*sin(c + d*x))**p/(b*e*f*(m + p + S(1))), x) rule4798 = ReplacementRule(pattern4798, replacement4798) pattern4799 = Pattern(Integral((WC('e', S(1))*cos(x_*WC('b', S(1)) + WC('a', S(0))))**m_*(WC('f', S(1))*sin(x_*WC('b', S(1)) + WC('a', S(0))))**WC('n', S(1))*(WC('g', S(1))*sin(x_*WC('d', S(1)) + WC('c', S(0))))**p_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons4, cons5, cons25, cons1654, cons147, cons31, cons94, cons1660, cons253, cons170) def replacement4799(p, m, f, b, g, d, a, n, c, x, e): rubi.append(4799) return Dist((m + n + S(2)*p + S(2))/(e**S(2)*(m + p + S(1))), Int((e*cos(a + b*x))**(m + S(2))*(f*sin(a + b*x))**n*(g*sin(c + d*x))**p, x), x) - Simp((e*cos(a + b*x))**(m + S(1))*(f*sin(a + b*x))**(n + S(1))*(g*sin(c + d*x))**p/(b*e*f*(m + p + S(1))), x) rule4799 = ReplacementRule(pattern4799, replacement4799) pattern4800 = Pattern(Integral((WC('e', S(1))*sin(x_*WC('b', S(1)) + WC('a', S(0))))**m_*(WC('f', S(1))*cos(x_*WC('b', S(1)) + WC('a', S(0))))**WC('n', S(1))*(WC('g', S(1))*sin(x_*WC('d', S(1)) + WC('c', S(0))))**p_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons4, cons5, cons25, cons1654, cons147, cons31, cons94, cons1660, cons253, cons170) def replacement4800(p, m, f, b, g, d, a, n, c, x, e): rubi.append(4800) return Dist((m + n + S(2)*p + S(2))/(e**S(2)*(m + p + S(1))), Int((e*sin(a + b*x))**(m + S(2))*(f*cos(a + b*x))**n*(g*sin(c + d*x))**p, x), x) + Simp((e*sin(a + b*x))**(m + S(1))*(f*cos(a + b*x))**(n + S(1))*(g*sin(c + d*x))**p/(b*e*f*(m + p + S(1))), x) rule4800 = ReplacementRule(pattern4800, replacement4800) pattern4801 = Pattern(Integral((WC('e', S(1))*cos(x_*WC('b', S(1)) + WC('a', S(0))))**WC('m', S(1))*(WC('f', S(1))*sin(x_*WC('b', S(1)) + WC('a', S(0))))**WC('n', S(1))*(WC('g', S(1))*sin(x_*WC('d', S(1)) + WC('c', S(0))))**p_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons21, cons4, cons5, cons25, cons1654, cons147) def replacement4801(p, m, f, b, g, d, a, n, c, x, e): rubi.append(4801) return Dist((e*cos(a + b*x))**(-p)*(f*sin(a + b*x))**(-p)*(g*sin(c + d*x))**p, Int((e*cos(a + b*x))**(m + p)*(f*sin(a + b*x))**(n + p), x), x) rule4801 = ReplacementRule(pattern4801, replacement4801) pattern4802 = Pattern(Integral((WC('e', S(1))*cos(x_*WC('b', S(1)) + WC('a', S(0))))**WC('m', S(1))*sin(x_*WC('d', S(1)) + WC('c', S(0))), x_), cons2, cons3, cons7, cons27, cons48, cons21, cons25, cons1663) def replacement4802(m, b, d, a, c, x, e): rubi.append(4802) return -Simp((e*cos(a + b*x))**(m + S(1))*(m + S(2))*cos((a + b*x)*(m + S(1)))/(d*e*(m + S(1))), x) rule4802 = ReplacementRule(pattern4802, replacement4802) pattern4803 = Pattern(Integral((F_**(x_*WC('d', S(1)) + WC('c', S(0)))*WC('b', S(1)) + a_)**p_, x_), cons2, cons3, cons7, cons27, cons1664, cons85, cons128) def replacement4803(p, b, d, c, a, n, x, F): rubi.append(4803) return Int((a + b*F(c + d*x)**n)**p, x) rule4803 = ReplacementRule(pattern4803, replacement4803) pattern4804 = Pattern(Integral(S(1)/(F_**(x_*WC('d', S(1)) + WC('c', S(0)))*WC('b', S(1)) + a_), x_), cons2, cons3, cons7, cons27, cons1664, cons1479, cons744) def replacement4804(b, d, c, a, n, x, F): rubi.append(4804) return Dist(S(2)/(a*n), Sum_doit(Int(S(1)/(S(1) - (S(-1))**(-S(4)*k/n)*F(c + d*x)**S(2)/Rt(-a/b, n/S(2))), x), List(k, S(1), n/S(2))), x) rule4804 = ReplacementRule(pattern4804, replacement4804) pattern4805 = Pattern(Integral(S(1)/(F_**(x_*WC('d', S(1)) + WC('c', S(0)))*WC('b', S(1)) + a_), x_), cons2, cons3, cons7, cons27, cons1664, cons1482, cons744) def replacement4805(b, d, c, a, n, x, F): rubi.append(4805) return Int(ExpandTrig(S(1)/(a + b*F(c + d*x)**n), x), x) rule4805 = ReplacementRule(pattern4805, replacement4805) pattern4806 = Pattern(Integral(G_**(x_*WC('d', S(1)) + WC('c', S(0)))/(F_**(x_*WC('d', S(1)) + WC('c', S(0)))*WC('b', S(1)) + a_), x_), cons2, cons3, cons7, cons27, cons21, cons1665, cons85, cons744) def replacement4806(m, b, G, d, c, a, n, x, F): rubi.append(4806) return Int(ExpandTrig(G(c + d*x)**m, S(1)/(a + b*F(c + d*x)**n), x), x) rule4806 = ReplacementRule(pattern4806, replacement4806) def With4807(p, d, a, c, n, x, F): v = ActivateTrig(F(c + d*x)) rubi.append(4807) return Dist(a**IntPart(n)*(a*v**p)**FracPart(n)*(v/NonfreeFactors(v, x))**(p*IntPart(n))*NonfreeFactors(v, x)**(-p*FracPart(n)), Int(NonfreeFactors(v, x)**(n*p), x), x) pattern4807 = Pattern(Integral((F_**(x_*WC('d', S(1)) + WC('c', S(0)))*WC('a', S(1)))**n_, x_), cons2, cons7, cons27, cons4, cons5, cons1664, cons23, cons38) rule4807 = ReplacementRule(pattern4807, With4807) def With4808(p, b, d, c, a, n, x, F): v = ActivateTrig(F(c + d*x)) rubi.append(4808) return Dist(a**IntPart(n)*(a*(b*v)**p)**FracPart(n)*(b*v)**(-p*FracPart(n)), Int((b*v)**(n*p), x), x) pattern4808 = Pattern(Integral(((F_*(x_*WC('d', S(1)) + WC('c', S(0)))*WC('b', S(1)))**p_*WC('a', S(1)))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons4, cons5, cons1664, cons23, cons147) rule4808 = ReplacementRule(pattern4808, With4808) def With4809(u, b, c, a, x, F): if isinstance(x, (int, Integer, float, Float)): return False d = FreeFactors(sin(c*(a + b*x)), x) if FunctionOfQ(sin(c*(a + b*x))/d, u, x, True): return True return False pattern4809 = Pattern(Integral(F_*u_*(x_*WC('b', S(1)) + WC('a', S(0)))*WC('c', S(1)), x_), cons2, cons3, cons7, cons1666, CustomConstraint(With4809)) def replacement4809(u, b, c, a, x, F): d = FreeFactors(sin(c*(a + b*x)), x) rubi.append(4809) return Dist(d/(b*c), Subst(Int(SubstFor(S(1), sin(c*(a + b*x))/d, u, x), x), x, sin(c*(a + b*x))/d), x) rule4809 = ReplacementRule(pattern4809, replacement4809) def With4810(u, b, c, a, x, F): if isinstance(x, (int, Integer, float, Float)): return False d = FreeFactors(cos(c*(a + b*x)), x) if FunctionOfQ(cos(c*(a + b*x))/d, u, x, True): return True return False pattern4810 = Pattern(Integral(F_*u_*(x_*WC('b', S(1)) + WC('a', S(0)))*WC('c', S(1)), x_), cons2, cons3, cons7, cons1667, CustomConstraint(With4810)) def replacement4810(u, b, c, a, x, F): d = FreeFactors(cos(c*(a + b*x)), x) rubi.append(4810) return -Dist(d/(b*c), Subst(Int(SubstFor(S(1), cos(c*(a + b*x))/d, u, x), x), x, cos(c*(a + b*x))/d), x) rule4810 = ReplacementRule(pattern4810, replacement4810) def With4811(u, b, c, a, x, F): if isinstance(x, (int, Integer, float, Float)): return False d = FreeFactors(sin(c*(a + b*x)), x) if FunctionOfQ(sin(c*(a + b*x))/d, u, x, True): return True return False pattern4811 = Pattern(Integral(F_*u_*(x_*WC('b', S(1)) + WC('a', S(0)))*WC('c', S(1)), x_), cons2, cons3, cons7, cons1668, CustomConstraint(With4811)) def replacement4811(u, b, c, a, x, F): d = FreeFactors(sin(c*(a + b*x)), x) rubi.append(4811) return Dist(S(1)/(b*c), Subst(Int(SubstFor(S(1)/x, sin(c*(a + b*x))/d, u, x), x), x, sin(c*(a + b*x))/d), x) rule4811 = ReplacementRule(pattern4811, replacement4811) def With4812(u, b, c, a, x, F): if isinstance(x, (int, Integer, float, Float)): return False d = FreeFactors(cos(c*(a + b*x)), x) if FunctionOfQ(cos(c*(a + b*x))/d, u, x, True): return True return False pattern4812 = Pattern(Integral(F_*u_*(x_*WC('b', S(1)) + WC('a', S(0)))*WC('c', S(1)), x_), cons2, cons3, cons7, cons1669, CustomConstraint(With4812)) def replacement4812(u, b, c, a, x, F): d = FreeFactors(cos(c*(a + b*x)), x) rubi.append(4812) return -Dist(S(1)/(b*c), Subst(Int(SubstFor(S(1)/x, cos(c*(a + b*x))/d, u, x), x), x, cos(c*(a + b*x))/d), x) rule4812 = ReplacementRule(pattern4812, replacement4812) def With4813(u, b, c, a, x, F): if isinstance(x, (int, Integer, float, Float)): return False d = FreeFactors(tan(c*(a + b*x)), x) if FunctionOfQ(tan(c*(a + b*x))/d, u, x, True): return True return False pattern4813 = Pattern(Integral(F_**((x_*WC('b', S(1)) + WC('a', S(0)))*WC('c', S(1)))*u_, x_), cons2, cons3, cons7, cons1247, cons1670, CustomConstraint(With4813)) def replacement4813(u, b, c, a, x, F): d = FreeFactors(tan(c*(a + b*x)), x) rubi.append(4813) return Dist(d/(b*c), Subst(Int(SubstFor(S(1), tan(c*(a + b*x))/d, u, x), x), x, tan(c*(a + b*x))/d), x) rule4813 = ReplacementRule(pattern4813, replacement4813) def With4814(u, b, c, a, x): if isinstance(x, (int, Integer, float, Float)): return False d = FreeFactors(tan(c*(a + b*x)), x) if FunctionOfQ(tan(c*(a + b*x))/d, u, x, True): return True return False pattern4814 = Pattern(Integral(u_/cos((x_*WC('b', S(1)) + WC('a', S(0)))*WC('c', S(1)))**S(2), x_), cons2, cons3, cons7, cons1247, CustomConstraint(With4814)) def replacement4814(u, b, c, a, x): d = FreeFactors(tan(c*(a + b*x)), x) rubi.append(4814) return Dist(d/(b*c), Subst(Int(SubstFor(S(1), tan(c*(a + b*x))/d, u, x), x), x, tan(c*(a + b*x))/d), x) rule4814 = ReplacementRule(pattern4814, replacement4814) def With4815(u, b, c, a, x, F): if isinstance(x, (int, Integer, float, Float)): return False d = FreeFactors(S(1)/tan(c*(a + b*x)), x) if FunctionOfQ(S(1)/(d*tan(c*(a + b*x))), u, x, True): return True return False pattern4815 = Pattern(Integral(F_**((x_*WC('b', S(1)) + WC('a', S(0)))*WC('c', S(1)))*u_, x_), cons2, cons3, cons7, cons1247, cons1671, CustomConstraint(With4815)) def replacement4815(u, b, c, a, x, F): d = FreeFactors(S(1)/tan(c*(a + b*x)), x) rubi.append(4815) return -Dist(d/(b*c), Subst(Int(SubstFor(S(1), S(1)/(d*tan(c*(a + b*x))), u, x), x), x, S(1)/(d*tan(c*(a + b*x)))), x) rule4815 = ReplacementRule(pattern4815, replacement4815) def With4816(u, b, c, a, x): if isinstance(x, (int, Integer, float, Float)): return False d = FreeFactors(S(1)/tan(c*(a + b*x)), x) if FunctionOfQ(S(1)/(d*tan(c*(a + b*x))), u, x, True): return True return False pattern4816 = Pattern(Integral(u_/sin((x_*WC('b', S(1)) + WC('a', S(0)))*WC('c', S(1)))**S(2), x_), cons2, cons3, cons7, cons1247, CustomConstraint(With4816)) def replacement4816(u, b, c, a, x): d = FreeFactors(S(1)/tan(c*(a + b*x)), x) rubi.append(4816) return -Dist(d/(b*c), Subst(Int(SubstFor(S(1), S(1)/(d*tan(c*(a + b*x))), u, x), x), x, S(1)/(d*tan(c*(a + b*x)))), x) rule4816 = ReplacementRule(pattern4816, replacement4816) def With4817(u, b, c, n, a, x, F): if isinstance(x, (int, Integer, float, Float)): return False d = FreeFactors(tan(c*(a + b*x)), x) if And(FunctionOfQ(tan(c*(a + b*x))/d, u, x, True), TryPureTanSubst((S(1)/tan(c*(a + b*x)))**n*ActivateTrig(u), x)): return True return False pattern4817 = Pattern(Integral(F_**((x_*WC('b', S(1)) + WC('a', S(0)))*WC('c', S(1)))*u_, x_), cons2, cons3, cons7, cons85, cons1668, CustomConstraint(With4817)) def replacement4817(u, b, c, n, a, x, F): d = FreeFactors(tan(c*(a + b*x)), x) rubi.append(4817) return Dist(d**(-n + S(1))/(b*c), Subst(Int(SubstFor(x**(-n)/(d**S(2)*x**S(2) + S(1)), tan(c*(a + b*x))/d, u, x), x), x, tan(c*(a + b*x))/d), x) rule4817 = ReplacementRule(pattern4817, replacement4817) def With4818(u, b, c, n, a, x, F): if isinstance(x, (int, Integer, float, Float)): return False d = FreeFactors(S(1)/tan(c*(a + b*x)), x) if And(FunctionOfQ(S(1)/(d*tan(c*(a + b*x))), u, x, True), TryPureTanSubst(ActivateTrig(u)*tan(c*(a + b*x))**n, x)): return True return False pattern4818 = Pattern(Integral(F_**((x_*WC('b', S(1)) + WC('a', S(0)))*WC('c', S(1)))*u_, x_), cons2, cons3, cons7, cons85, cons1669, CustomConstraint(With4818)) def replacement4818(u, b, c, n, a, x, F): d = FreeFactors(S(1)/tan(c*(a + b*x)), x) rubi.append(4818) return -Dist(d**(-n + S(1))/(b*c), Subst(Int(SubstFor(x**(-n)/(d**S(2)*x**S(2) + S(1)), S(1)/(d*tan(c*(a + b*x))), u, x), x), x, S(1)/(d*tan(c*(a + b*x)))), x) rule4818 = ReplacementRule(pattern4818, replacement4818) def With4819(x, u): if isinstance(x, (int, Integer, float, Float)): return False try: v = FunctionOfTrig(u, x) d = FreeFactors(S(1)/tan(v), x) res = And(Not(FalseQ(v)), FunctionOfQ(NonfreeFactors(S(1)/tan(v), x), u, x, True), TryPureTanSubst(ActivateTrig(u), x)) except (TypeError, AttributeError): return False if res: return True return False pattern4819 = Pattern(Integral(u_, x_), CustomConstraint(With4819)) def replacement4819(x, u): v = FunctionOfTrig(u, x) d = FreeFactors(S(1)/tan(v), x) rubi.append(4819) return Simp(With(List(Set(d, FreeFactors(S(1)/tan(v), x))), Dist(-d/Coefficient(v, x, S(1)), Subst(Int(SubstFor(S(1)/(d**S(2)*x**S(2) + S(1)), S(1)/(d*tan(v)), u, x), x), x, S(1)/(d*tan(v))), x)), x) rule4819 = ReplacementRule(pattern4819, replacement4819) def With4820(x, u): if isinstance(x, (int, Integer, float, Float)): return False try: v = FunctionOfTrig(u, x) d = FreeFactors(tan(v), x) res = And(Not(FalseQ(v)), FunctionOfQ(NonfreeFactors(tan(v), x), u, x, True), TryPureTanSubst(ActivateTrig(u), x)) except (TypeError, AttributeError): return False if res: return True return False pattern4820 = Pattern(Integral(u_, x_), CustomConstraint(With4820)) def replacement4820(x, u): v = FunctionOfTrig(u, x) d = FreeFactors(tan(v), x) rubi.append(4820) return Simp(With(List(Set(d, FreeFactors(tan(v), x))), Dist(d/Coefficient(v, x, S(1)), Subst(Int(SubstFor(S(1)/(d**S(2)*x**S(2) + S(1)), tan(v)/d, u, x), x), x, tan(v)/d), x)), x) rule4820 = ReplacementRule(pattern4820, replacement4820) pattern4821 = Pattern(Integral(F_**(x_*WC('b', S(1)) + WC('a', S(0)))*G_**(x_*WC('d', S(1)) + WC('c', S(0))), x_), cons2, cons3, cons7, cons27, cons1672, cons1673, cons555) def replacement4821(p, b, G, d, c, a, x, q, F): rubi.append(4821) return Int(ExpandTrigReduce(ActivateTrig(F(a + b*x)**p*G(c + d*x)**q), x), x) rule4821 = ReplacementRule(pattern4821, replacement4821) pattern4822 = Pattern(Integral(F_**(x_*WC('b', S(1)) + WC('a', S(0)))*G_**(x_*WC('d', S(1)) + WC('c', S(0)))*H_**(x_*WC('f', S(1)) + WC('e', S(0))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons1672, cons1673, cons1674, cons628) def replacement4822(p, f, b, r, G, d, c, a, H, x, q, e, F): rubi.append(4822) return Int(ExpandTrigReduce(ActivateTrig(F(a + b*x)**p*G(c + d*x)**q*H(e + f*x)**r), x), x) rule4822 = ReplacementRule(pattern4822, replacement4822) def With4823(u, b, c, a, x, F): if isinstance(x, (int, Integer, float, Float)): return False d = FreeFactors(sin(c*(a + b*x)), x) if FunctionOfQ(sin(c*(a + b*x))/d, u, x): return True return False pattern4823 = Pattern(Integral(F_*u_*(x_*WC('b', S(1)) + WC('a', S(0)))*WC('c', S(1)), x_), cons2, cons3, cons7, cons1666, CustomConstraint(With4823)) def replacement4823(u, b, c, a, x, F): d = FreeFactors(sin(c*(a + b*x)), x) rubi.append(4823) return Dist(d/(b*c), Subst(Int(SubstFor(S(1), sin(c*(a + b*x))/d, u, x), x), x, sin(c*(a + b*x))/d), x) rule4823 = ReplacementRule(pattern4823, replacement4823) def With4824(u, b, c, a, x, F): if isinstance(x, (int, Integer, float, Float)): return False d = FreeFactors(cos(c*(a + b*x)), x) if FunctionOfQ(cos(c*(a + b*x))/d, u, x): return True return False pattern4824 = Pattern(Integral(F_*u_*(x_*WC('b', S(1)) + WC('a', S(0)))*WC('c', S(1)), x_), cons2, cons3, cons7, cons1667, CustomConstraint(With4824)) def replacement4824(u, b, c, a, x, F): d = FreeFactors(cos(c*(a + b*x)), x) rubi.append(4824) return -Dist(d/(b*c), Subst(Int(SubstFor(S(1), cos(c*(a + b*x))/d, u, x), x), x, cos(c*(a + b*x))/d), x) rule4824 = ReplacementRule(pattern4824, replacement4824) def With4825(u, b, c, a, x, F): if isinstance(x, (int, Integer, float, Float)): return False d = FreeFactors(sin(c*(a + b*x)), x) if FunctionOfQ(sin(c*(a + b*x))/d, u, x): return True return False pattern4825 = Pattern(Integral(F_*u_*(x_*WC('b', S(1)) + WC('a', S(0)))*WC('c', S(1)), x_), cons2, cons3, cons7, cons1668, CustomConstraint(With4825)) def replacement4825(u, b, c, a, x, F): d = FreeFactors(sin(c*(a + b*x)), x) rubi.append(4825) return Dist(S(1)/(b*c), Subst(Int(SubstFor(S(1)/x, sin(c*(a + b*x))/d, u, x), x), x, sin(c*(a + b*x))/d), x) rule4825 = ReplacementRule(pattern4825, replacement4825) def With4826(u, b, c, a, x, F): if isinstance(x, (int, Integer, float, Float)): return False d = FreeFactors(cos(c*(a + b*x)), x) if FunctionOfQ(cos(c*(a + b*x))/d, u, x): return True return False pattern4826 = Pattern(Integral(F_*u_*(x_*WC('b', S(1)) + WC('a', S(0)))*WC('c', S(1)), x_), cons2, cons3, cons7, cons1669, CustomConstraint(With4826)) def replacement4826(u, b, c, a, x, F): d = FreeFactors(cos(c*(a + b*x)), x) rubi.append(4826) return -Dist(S(1)/(b*c), Subst(Int(SubstFor(S(1)/x, cos(c*(a + b*x))/d, u, x), x), x, cos(c*(a + b*x))/d), x) rule4826 = ReplacementRule(pattern4826, replacement4826) def With4827(u, b, c, a, n, x, F): if isinstance(x, (int, Integer, float, Float)): return False d = FreeFactors(sin(c*(a + b*x)), x) if FunctionOfQ(sin(c*(a + b*x))/d, u, x): return True return False pattern4827 = Pattern(Integral(F_**((x_*WC('b', S(1)) + WC('a', S(0)))*WC('c', S(1)))*u_, x_), cons2, cons3, cons7, cons1482, cons1247, cons1666, CustomConstraint(With4827)) def replacement4827(u, b, c, a, n, x, F): d = FreeFactors(sin(c*(a + b*x)), x) rubi.append(4827) return Dist(d/(b*c), Subst(Int(SubstFor((-d**S(2)*x**S(2) + S(1))**(n/S(2) + S(-1)/2), sin(c*(a + b*x))/d, u, x), x), x, sin(c*(a + b*x))/d), x) rule4827 = ReplacementRule(pattern4827, replacement4827) def With4828(u, b, c, a, n, x, F): if isinstance(x, (int, Integer, float, Float)): return False d = FreeFactors(sin(c*(a + b*x)), x) if FunctionOfQ(sin(c*(a + b*x))/d, u, x): return True return False pattern4828 = Pattern(Integral(F_**((x_*WC('b', S(1)) + WC('a', S(0)))*WC('c', S(1)))*u_, x_), cons2, cons3, cons7, cons1482, cons1247, cons1670, CustomConstraint(With4828)) def replacement4828(u, b, c, a, n, x, F): d = FreeFactors(sin(c*(a + b*x)), x) rubi.append(4828) return Dist(d/(b*c), Subst(Int(SubstFor((-d**S(2)*x**S(2) + S(1))**(-n/S(2) + S(-1)/2), sin(c*(a + b*x))/d, u, x), x), x, sin(c*(a + b*x))/d), x) rule4828 = ReplacementRule(pattern4828, replacement4828) def With4829(u, b, c, a, n, x, F): if isinstance(x, (int, Integer, float, Float)): return False d = FreeFactors(cos(c*(a + b*x)), x) if FunctionOfQ(cos(c*(a + b*x))/d, u, x): return True return False pattern4829 = Pattern(Integral(F_**((x_*WC('b', S(1)) + WC('a', S(0)))*WC('c', S(1)))*u_, x_), cons2, cons3, cons7, cons1482, cons1247, cons1667, CustomConstraint(With4829)) def replacement4829(u, b, c, a, n, x, F): d = FreeFactors(cos(c*(a + b*x)), x) rubi.append(4829) return -Dist(d/(b*c), Subst(Int(SubstFor((-d**S(2)*x**S(2) + S(1))**(n/S(2) + S(-1)/2), cos(c*(a + b*x))/d, u, x), x), x, cos(c*(a + b*x))/d), x) rule4829 = ReplacementRule(pattern4829, replacement4829) def With4830(u, b, c, a, n, x, F): if isinstance(x, (int, Integer, float, Float)): return False d = FreeFactors(cos(c*(a + b*x)), x) if FunctionOfQ(cos(c*(a + b*x))/d, u, x): return True return False pattern4830 = Pattern(Integral(F_**((x_*WC('b', S(1)) + WC('a', S(0)))*WC('c', S(1)))*u_, x_), cons2, cons3, cons7, cons1482, cons1247, cons1671, CustomConstraint(With4830)) def replacement4830(u, b, c, a, n, x, F): d = FreeFactors(cos(c*(a + b*x)), x) rubi.append(4830) return -Dist(d/(b*c), Subst(Int(SubstFor((-d**S(2)*x**S(2) + S(1))**(-n/S(2) + S(-1)/2), cos(c*(a + b*x))/d, u, x), x), x, cos(c*(a + b*x))/d), x) rule4830 = ReplacementRule(pattern4830, replacement4830) def With4831(u, b, c, a, n, x, F): if isinstance(x, (int, Integer, float, Float)): return False d = FreeFactors(sin(c*(a + b*x)), x) if FunctionOfQ(sin(c*(a + b*x))/d, u, x): return True return False pattern4831 = Pattern(Integral(F_**((x_*WC('b', S(1)) + WC('a', S(0)))*WC('c', S(1)))*u_, x_), cons2, cons3, cons7, cons1482, cons1247, cons1668, CustomConstraint(With4831)) def replacement4831(u, b, c, a, n, x, F): d = FreeFactors(sin(c*(a + b*x)), x) rubi.append(4831) return Dist(d**(-n + S(1))/(b*c), Subst(Int(SubstFor(x**(-n)*(-d**S(2)*x**S(2) + S(1))**(n/S(2) + S(-1)/2), sin(c*(a + b*x))/d, u, x), x), x, sin(c*(a + b*x))/d), x) rule4831 = ReplacementRule(pattern4831, replacement4831) def With4832(u, b, c, a, n, x, F): if isinstance(x, (int, Integer, float, Float)): return False d = FreeFactors(cos(c*(a + b*x)), x) if FunctionOfQ(cos(c*(a + b*x))/d, u, x): return True return False pattern4832 = Pattern(Integral(F_**((x_*WC('b', S(1)) + WC('a', S(0)))*WC('c', S(1)))*u_, x_), cons2, cons3, cons7, cons1482, cons1247, cons1669, CustomConstraint(With4832)) def replacement4832(u, b, c, a, n, x, F): d = FreeFactors(cos(c*(a + b*x)), x) rubi.append(4832) return -Dist(d**(-n + S(1))/(b*c), Subst(Int(SubstFor(x**(-n)*(-d**S(2)*x**S(2) + S(1))**(n/S(2) + S(-1)/2), cos(c*(a + b*x))/d, u, x), x), x, cos(c*(a + b*x))/d), x) rule4832 = ReplacementRule(pattern4832, replacement4832) def With4833(v, u, b, d, c, n, a, x, F): if isinstance(x, (int, Integer, float, Float)): return False e = FreeFactors(sin(c*(a + b*x)), x) if FunctionOfQ(sin(c*(a + b*x))/e, u, x): return True return False pattern4833 = Pattern(Integral(u_*(F_**((x_*WC('b', S(1)) + WC('a', S(0)))*WC('c', S(1)))*WC('d', S(1)) + v_), x_), cons2, cons3, cons7, cons27, cons10, cons1482, cons1247, cons1666, CustomConstraint(With4833)) def replacement4833(v, u, b, d, c, n, a, x, F): e = FreeFactors(sin(c*(a + b*x)), x) rubi.append(4833) return Dist(d, Int(ActivateTrig(u)*cos(c*(a + b*x))**n, x), x) + Int(ActivateTrig(u*v), x) rule4833 = ReplacementRule(pattern4833, replacement4833) def With4834(v, u, b, d, c, n, a, x, F): if isinstance(x, (int, Integer, float, Float)): return False e = FreeFactors(cos(c*(a + b*x)), x) if FunctionOfQ(cos(c*(a + b*x))/e, u, x): return True return False pattern4834 = Pattern(Integral(u_*(F_**((x_*WC('b', S(1)) + WC('a', S(0)))*WC('c', S(1)))*WC('d', S(1)) + v_), x_), cons2, cons3, cons7, cons27, cons10, cons1482, cons1247, cons1667, CustomConstraint(With4834)) def replacement4834(v, u, b, d, c, n, a, x, F): e = FreeFactors(cos(c*(a + b*x)), x) rubi.append(4834) return Dist(d, Int(ActivateTrig(u)*sin(c*(a + b*x))**n, x), x) + Int(ActivateTrig(u*v), x) rule4834 = ReplacementRule(pattern4834, replacement4834) def With4835(x, u): if isinstance(x, (int, Integer, float, Float)): return False try: v = FunctionOfTrig(u, x) d = FreeFactors(sin(v), x) res = And(Not(FalseQ(v)), FunctionOfQ(NonfreeFactors(sin(v), x), u/cos(v), x)) except (TypeError, AttributeError): return False if res: return True return False pattern4835 = Pattern(Integral(u_, x_), CustomConstraint(With4835)) def replacement4835(x, u): v = FunctionOfTrig(u, x) d = FreeFactors(sin(v), x) rubi.append(4835) return Simp(With(List(Set(d, FreeFactors(sin(v), x))), Dist(d/Coefficient(v, x, S(1)), Subst(Int(SubstFor(S(1), sin(v)/d, u/cos(v), x), x), x, sin(v)/d), x)), x) rule4835 = ReplacementRule(pattern4835, replacement4835) def With4836(x, u): if isinstance(x, (int, Integer, float, Float)): return False try: v = FunctionOfTrig(u, x) d = FreeFactors(cos(v), x) res = And(Not(FalseQ(v)), FunctionOfQ(NonfreeFactors(cos(v), x), u/sin(v), x)) except (TypeError, AttributeError): return False if res: return True return False pattern4836 = Pattern(Integral(u_, x_), CustomConstraint(With4836)) def replacement4836(x, u): v = FunctionOfTrig(u, x) d = FreeFactors(cos(v), x) rubi.append(4836) return Simp(With(List(Set(d, FreeFactors(cos(v), x))), Dist(-d/Coefficient(v, x, S(1)), Subst(Int(SubstFor(S(1), cos(v)/d, u/sin(v), x), x), x, cos(v)/d), x)), x) rule4836 = ReplacementRule(pattern4836, replacement4836) pattern4837 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*cos(x_*WC('e', S(1)) + WC('d', S(0)))**S(2) + WC('c', S(1))*sin(x_*WC('e', S(1)) + WC('d', S(0)))**S(2))**WC('p', S(1))*WC('u', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons5, cons1675) def replacement4837(p, u, b, d, a, c, x, e): rubi.append(4837) return Dist((a + c)**p, Int(ActivateTrig(u), x), x) rule4837 = ReplacementRule(pattern4837, replacement4837) pattern4838 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*tan(x_*WC('e', S(1)) + WC('d', S(0)))**S(2) + WC('c', S(1))/cos(x_*WC('e', S(1)) + WC('d', S(0)))**S(2))**WC('p', S(1))*WC('u', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons5, cons1676) def replacement4838(p, u, b, d, a, c, x, e): rubi.append(4838) return Dist((a + c)**p, Int(ActivateTrig(u), x), x) rule4838 = ReplacementRule(pattern4838, replacement4838) pattern4839 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))/tan(x_*WC('e', S(1)) + WC('d', S(0)))**S(2) + WC('c', S(1))/sin(x_*WC('e', S(1)) + WC('d', S(0)))**S(2))**WC('p', S(1))*WC('u', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons5, cons1676) def replacement4839(p, u, b, d, c, a, x, e): rubi.append(4839) return Dist((a + c)**p, Int(ActivateTrig(u), x), x) rule4839 = ReplacementRule(pattern4839, replacement4839) def With4840(y, x, u): if isinstance(x, (int, Integer, float, Float)): return False try: q = DerivativeDivides(ActivateTrig(y), ActivateTrig(u), x) res = Not(FalseQ(q)) except (TypeError, AttributeError): return False if res: return True return False pattern4840 = Pattern(Integral(u_/y_, x_), cons1677, CustomConstraint(With4840)) def replacement4840(y, x, u): q = DerivativeDivides(ActivateTrig(y), ActivateTrig(u), x) rubi.append(4840) return Simp(q*log(RemoveContent(ActivateTrig(y), x)), x) rule4840 = ReplacementRule(pattern4840, replacement4840) def With4841(y, w, u, x): if isinstance(x, (int, Integer, float, Float)): return False try: q = DerivativeDivides(ActivateTrig(w*y), ActivateTrig(u), x) res = Not(FalseQ(q)) except (TypeError, AttributeError): return False if res: return True return False pattern4841 = Pattern(Integral(u_/(w_*y_), x_), cons1677, CustomConstraint(With4841)) def replacement4841(y, w, u, x): q = DerivativeDivides(ActivateTrig(w*y), ActivateTrig(u), x) rubi.append(4841) return Simp(q*log(RemoveContent(ActivateTrig(w*y), x)), x) rule4841 = ReplacementRule(pattern4841, replacement4841) def With4842(y, m, u, x): if isinstance(x, (int, Integer, float, Float)): return False try: q = DerivativeDivides(ActivateTrig(y), ActivateTrig(u), x) res = Not(FalseQ(q)) except (TypeError, AttributeError): return False if res: return True return False pattern4842 = Pattern(Integral(u_*y_**WC('m', S(1)), x_), cons21, cons66, cons1677, CustomConstraint(With4842)) def replacement4842(y, m, u, x): q = DerivativeDivides(ActivateTrig(y), ActivateTrig(u), x) rubi.append(4842) return Simp(q*ActivateTrig(y**(m + S(1)))/(m + S(1)), x) rule4842 = ReplacementRule(pattern4842, replacement4842) def With4843(z, y, u, m, n, x): if isinstance(x, (int, Integer, float, Float)): return False try: q = DerivativeDivides(ActivateTrig(y*z), ActivateTrig(u*z**(-m + n)), x) res = Not(FalseQ(q)) except (TypeError, AttributeError): return False if res: return True return False pattern4843 = Pattern(Integral(u_*y_**WC('m', S(1))*z_**WC('n', S(1)), x_), cons21, cons4, cons66, cons1677, CustomConstraint(With4843)) def replacement4843(z, y, u, m, n, x): q = DerivativeDivides(ActivateTrig(y*z), ActivateTrig(u*z**(-m + n)), x) rubi.append(4843) return Simp(q*ActivateTrig(y**(m + S(1))*z**(m + S(1)))/(m + S(1)), x) rule4843 = ReplacementRule(pattern4843, replacement4843) def With4844(p, u, d, a, c, n, x, F): v = ActivateTrig(F(c + d*x)) rubi.append(4844) return Dist(a**IntPart(n)*(a*v**p)**FracPart(n)*(v/NonfreeFactors(v, x))**(p*IntPart(n))*NonfreeFactors(v, x)**(-p*FracPart(n)), Int(ActivateTrig(u)*NonfreeFactors(v, x)**(n*p), x), x) pattern4844 = Pattern(Integral((F_**(x_*WC('d', S(1)) + WC('c', S(0)))*WC('a', S(1)))**n_*WC('u', S(1)), x_), cons2, cons7, cons27, cons4, cons5, cons1664, cons23, cons38) rule4844 = ReplacementRule(pattern4844, With4844) def With4845(p, u, b, d, c, a, n, x, F): v = ActivateTrig(F(c + d*x)) rubi.append(4845) return Dist(a**IntPart(n)*(a*(b*v)**p)**FracPart(n)*(b*v)**(-p*FracPart(n)), Int((b*v)**(n*p)*ActivateTrig(u), x), x) pattern4845 = Pattern(Integral(((F_*(x_*WC('d', S(1)) + WC('c', S(0)))*WC('b', S(1)))**p_*WC('a', S(1)))**WC('n', S(1))*WC('u', S(1)), x_), cons2, cons3, cons7, cons27, cons4, cons5, cons1664, cons23, cons147) rule4845 = ReplacementRule(pattern4845, With4845) def With4846(x, u): if isinstance(x, (int, Integer, float, Float)): return False try: v = FunctionOfTrig(u, x) d = FreeFactors(tan(v), x) res = And(Not(FalseQ(v)), FunctionOfQ(NonfreeFactors(tan(v), x), u, x)) except (TypeError, AttributeError): return False if res: return True return False pattern4846 = Pattern(Integral(u_, x_), cons1230, CustomConstraint(With4846)) def replacement4846(x, u): v = FunctionOfTrig(u, x) d = FreeFactors(tan(v), x) rubi.append(4846) return Dist(d/Coefficient(v, x, 1), Subst(Int(SubstFor(1/(d**2*x**2 + 1), tan(v)/d, u, x), x), x, tan(v)/d), x) rule4846 = ReplacementRule(pattern4846, replacement4846) pattern4847 = Pattern(Integral(((S(1)/cos(x_*WC('d', S(1)) + WC('c', S(0))))**WC('n', S(1))*WC('b', S(1)) + WC('a', S(1))*tan(x_*WC('d', S(1)) + WC('c', S(0)))**WC('n', S(1)))**p_*WC('u', S(1)), x_), cons2, cons3, cons7, cons27, cons376) def replacement4847(p, u, b, d, c, n, a, x): rubi.append(4847) return Int((a*sin(c + d*x)**n + b)**p*(S(1)/cos(c + d*x))**(n*p)*ActivateTrig(u), x) rule4847 = ReplacementRule(pattern4847, replacement4847) pattern4848 = Pattern(Integral(((S(1)/sin(x_*WC('d', S(1)) + WC('c', S(0))))**WC('n', S(1))*WC('b', S(1)) + (S(1)/tan(x_*WC('d', S(1)) + WC('c', S(0))))**WC('n', S(1))*WC('a', S(1)))**p_*WC('u', S(1)), x_), cons2, cons3, cons7, cons27, cons376) def replacement4848(p, u, b, d, c, n, a, x): rubi.append(4848) return Int((a*cos(c + d*x)**n + b)**p*(S(1)/sin(c + d*x))**(n*p)*ActivateTrig(u), x) rule4848 = ReplacementRule(pattern4848, replacement4848) pattern4849 = Pattern(Integral(u_*(F_**(x_*WC('d', S(1)) + WC('c', S(0)))*a_ + F_**(x_*WC('d', S(1)) + WC('c', S(0)))*WC('b', S(1)))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons5, cons50, cons1664, cons85, cons49) def replacement4849(p, u, b, d, c, n, a, x, q, F): rubi.append(4849) return Int(ActivateTrig(u*(a + b*F(c + d*x)**(-p + q))**n*F(c + d*x)**(n*p)), x) rule4849 = ReplacementRule(pattern4849, replacement4849) pattern4850 = Pattern(Integral(u_*(F_**(x_*WC('e', S(1)) + WC('d', S(0)))*a_ + F_**(x_*WC('e', S(1)) + WC('d', S(0)))*WC('b', S(1)) + F_**(x_*WC('e', S(1)) + WC('d', S(0)))*WC('c', S(1)))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons5, cons50, cons52, cons1664, cons85, cons49, cons51) def replacement4850(p, u, b, r, d, c, n, a, x, q, e, F): rubi.append(4850) return Int(ActivateTrig(u*(a + b*F(d + e*x)**(-p + q) + c*F(d + e*x)**(-p + r))**n*F(d + e*x)**(n*p)), x) rule4850 = ReplacementRule(pattern4850, replacement4850) pattern4851 = Pattern(Integral(u_*(F_**(x_*WC('e', S(1)) + WC('d', S(0)))*WC('b', S(1)) + F_**(x_*WC('e', S(1)) + WC('d', S(0)))*WC('c', S(1)) + a_)**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons5, cons50, cons1664, cons85, cons1678) def replacement4851(p, u, b, d, c, n, a, x, q, e, F): rubi.append(4851) return Int(ActivateTrig(u*(a*F(d + e*x)**(-p) + b + c*F(d + e*x)**(-p + q))**n*F(d + e*x)**(n*p)), x) rule4851 = ReplacementRule(pattern4851, replacement4851) pattern4852 = Pattern(Integral((WC('a', S(1))*cos(x_*WC('d', S(1)) + WC('c', S(0))) + WC('b', S(1))*sin(x_*WC('d', S(1)) + WC('c', S(0))))**WC('n', S(1))*WC('u', S(1)), x_), cons2, cons3, cons7, cons27, cons4, cons1439) def replacement4852(u, b, d, c, a, n, x): rubi.append(4852) return Int((a*exp(-a*(c + d*x)/b))**n*ActivateTrig(u), x) rule4852 = ReplacementRule(pattern4852, replacement4852) pattern4853 = Pattern(Integral(u_, x_), cons1679) def replacement4853(x, u): rubi.append(4853) return Int(TrigSimplify(u), x) rule4853 = ReplacementRule(pattern4853, replacement4853) def With4854(v, p, u, a, x): uu = ActivateTrig(u) vv = ActivateTrig(v) rubi.append(4854) return Dist(a**IntPart(p)*vv**(-FracPart(p))*(a*vv)**FracPart(p), Int(uu*vv**p, x), x) pattern4854 = Pattern(Integral((a_*v_)**p_*WC('u', S(1)), x_), cons2, cons5, cons147, cons1680) rule4854 = ReplacementRule(pattern4854, With4854) def With4855(v, p, u, m, x): uu = ActivateTrig(u) vv = ActivateTrig(v) rubi.append(4855) return Dist(vv**(-m*FracPart(p))*(vv**m)**FracPart(p), Int(uu*vv**(m*p), x), x) pattern4855 = Pattern(Integral((v_**m_)**p_*WC('u', S(1)), x_), cons21, cons5, cons147, cons1680) rule4855 = ReplacementRule(pattern4855, With4855) def With4856(v, w, p, u, m, n, x): uu = ActivateTrig(u) vv = ActivateTrig(v) ww = ActivateTrig(w) rubi.append(4856) return Dist(vv**(-m*FracPart(p))*ww**(-n*FracPart(p))*(vv**m*ww**n)**FracPart(p), Int(uu*vv**(m*p)*ww**(n*p), x), x) pattern4856 = Pattern(Integral((v_**WC('m', S(1))*w_**WC('n', S(1)))**p_*WC('u', S(1)), x_), cons21, cons4, cons5, cons147, cons1681) rule4856 = ReplacementRule(pattern4856, With4856) def With4857(x, u): if isinstance(x, (int, Integer, float, Float)): return False v = ExpandTrig(u, x) if SumQ(v): return True return False pattern4857 = Pattern(Integral(u_, x_), cons1677, CustomConstraint(With4857)) def replacement4857(x, u): v = ExpandTrig(u, x) rubi.append(4857) return Int(v, x) rule4857 = ReplacementRule(pattern4857, replacement4857) def With4858(x, u): if isinstance(x, (int, Integer, float, Float)): return False try: w = With(List(Set(ShowSteps, False), Set(StepCounter, Null)), Int(SubstFor(S(1)/(x**S(2)*FreeFactors(tan(FunctionOfTrig(u, x)/S(2)), x)**S(2) + S(1)), tan(FunctionOfTrig(u, x)/S(2))/FreeFactors(tan(FunctionOfTrig(u, x)/S(2)), x), u, x), x)) v = FunctionOfTrig(u, x) d = FreeFactors(tan(v/S(2)), x) res = FreeQ(w, Int) except (TypeError, AttributeError): return False if res: return True return False pattern4858 = Pattern(Integral(u_, x_), cons1230, cons1682, CustomConstraint(With4858)) def replacement4858(x, u): w = With(List(Set(ShowSteps, False), Set(StepCounter, Null)), Int(SubstFor(S(1)/(x**S(2)*FreeFactors(tan(FunctionOfTrig(u, x)/S(2)), x)**S(2) + S(1)), tan(FunctionOfTrig(u, x)/S(2))/FreeFactors(tan(FunctionOfTrig(u, x)/S(2)), x), u, x), x)) v = FunctionOfTrig(u, x) d = FreeFactors(tan(v/S(2)), x) rubi.append(4858) return Simp(Dist(2*d/Coefficient(v, x, 1), Subst(Int(SubstFor(1/(d**2*x**2 + 1), tan(v/2)/d, u, x), x), x, tan(v/2)/d), x), x) rule4858 = ReplacementRule(pattern4858, replacement4858) def With4859(x, u): v = ActivateTrig(u) rubi.append(4859) return Int(v, x) pattern4859 = Pattern(Integral(u_, x_), cons1677) rule4859 = ReplacementRule(pattern4859, With4859) pattern4860 = Pattern(Integral((x_*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1))*sin(x_*WC('b', S(1)) + WC('a', S(0)))**WC('n', S(1))*cos(x_*WC('b', S(1)) + WC('a', S(0))), x_), cons2, cons3, cons7, cons27, cons4, cons62, cons584) def replacement4860(m, b, d, c, a, n, x): rubi.append(4860) return -Dist(d*m/(b*(n + S(1))), Int((c + d*x)**(m + S(-1))*sin(a + b*x)**(n + S(1)), x), x) + Simp((c + d*x)**m*sin(a + b*x)**(n + S(1))/(b*(n + S(1))), x) rule4860 = ReplacementRule(pattern4860, replacement4860) pattern4861 = Pattern(Integral((x_*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1))*sin(x_*WC('b', S(1)) + WC('a', S(0)))*cos(x_*WC('b', S(1)) + WC('a', S(0)))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons4, cons62, cons584) def replacement4861(m, b, d, c, a, n, x): rubi.append(4861) return Dist(d*m/(b*(n + S(1))), Int((c + d*x)**(m + S(-1))*cos(a + b*x)**(n + S(1)), x), x) - Simp((c + d*x)**m*cos(a + b*x)**(n + S(1))/(b*(n + S(1))), x) rule4861 = ReplacementRule(pattern4861, replacement4861) pattern4862 = Pattern(Integral((x_*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1))*sin(x_*WC('b', S(1)) + WC('a', S(0)))**WC('n', S(1))*cos(x_*WC('b', S(1)) + WC('a', S(0)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons21, cons464) def replacement4862(p, m, b, d, c, a, n, x): rubi.append(4862) return Int(ExpandTrigReduce((c + d*x)**m, sin(a + b*x)**n*cos(a + b*x)**p, x), x) rule4862 = ReplacementRule(pattern4862, replacement4862) pattern4863 = Pattern(Integral((x_*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1))*sin(x_*WC('b', S(1)) + WC('a', S(0)))**WC('n', S(1))*tan(x_*WC('b', S(1)) + WC('a', S(0)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons21, cons464) def replacement4863(p, m, b, d, c, a, n, x): rubi.append(4863) return -Int((c + d*x)**m*sin(a + b*x)**n*tan(a + b*x)**(p + S(-2)), x) + Int((c + d*x)**m*sin(a + b*x)**(n + S(-2))*tan(a + b*x)**p, x) rule4863 = ReplacementRule(pattern4863, replacement4863) pattern4864 = Pattern(Integral((x_*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1))*(S(1)/tan(x_*WC('b', S(1)) + WC('a', S(0))))**WC('p', S(1))*cos(x_*WC('b', S(1)) + WC('a', S(0)))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons21, cons464) def replacement4864(p, m, b, d, c, a, n, x): rubi.append(4864) return Int((c + d*x)**m*(S(1)/tan(a + b*x))**p*cos(a + b*x)**(n + S(-2)), x) - Int((c + d*x)**m*(S(1)/tan(a + b*x))**(p + S(-2))*cos(a + b*x)**n, x) rule4864 = ReplacementRule(pattern4864, replacement4864) pattern4865 = Pattern(Integral((x_*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1))*(S(1)/cos(x_*WC('b', S(1)) + WC('a', S(0))))**WC('n', S(1))*tan(x_*WC('b', S(1)) + WC('a', S(0)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons4, cons1683, cons31, cons168) def replacement4865(p, m, b, d, c, a, n, x): rubi.append(4865) return -Dist(d*m/(b*n), Int((c + d*x)**(m + S(-1))*(S(1)/cos(a + b*x))**n, x), x) + Simp((c + d*x)**m*(S(1)/cos(a + b*x))**n/(b*n), x) rule4865 = ReplacementRule(pattern4865, replacement4865) pattern4866 = Pattern(Integral((x_*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1))*(S(1)/sin(x_*WC('b', S(1)) + WC('a', S(0))))**WC('n', S(1))*(S(1)/tan(x_*WC('b', S(1)) + WC('a', S(0))))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons4, cons1683, cons31, cons168) def replacement4866(p, m, b, d, c, a, n, x): rubi.append(4866) return Dist(d*m/(b*n), Int((c + d*x)**(m + S(-1))*(S(1)/sin(a + b*x))**n, x), x) - Simp((c + d*x)**m*(S(1)/sin(a + b*x))**n/(b*n), x) rule4866 = ReplacementRule(pattern4866, replacement4866) pattern4867 = Pattern(Integral((x_*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1))*tan(x_*WC('b', S(1)) + WC('a', S(0)))**WC('n', S(1))/cos(x_*WC('b', S(1)) + WC('a', S(0)))**S(2), x_), cons2, cons3, cons7, cons27, cons4, cons62, cons584) def replacement4867(m, b, d, c, a, n, x): rubi.append(4867) return -Dist(d*m/(b*(n + S(1))), Int((c + d*x)**(m + S(-1))*tan(a + b*x)**(n + S(1)), x), x) + Simp((c + d*x)**m*tan(a + b*x)**(n + S(1))/(b*(n + S(1))), x) rule4867 = ReplacementRule(pattern4867, replacement4867) pattern4868 = Pattern(Integral((x_*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1))*(S(1)/tan(x_*WC('b', S(1)) + WC('a', S(0))))**WC('n', S(1))/sin(x_*WC('b', S(1)) + WC('a', S(0)))**S(2), x_), cons2, cons3, cons7, cons27, cons4, cons62, cons584) def replacement4868(m, b, d, c, a, n, x): rubi.append(4868) return Dist(d*m/(b*(n + S(1))), Int((c + d*x)**(m + S(-1))*(S(1)/tan(a + b*x))**(n + S(1)), x), x) - Simp((c + d*x)**m*(S(1)/tan(a + b*x))**(n + S(1))/(b*(n + S(1))), x) rule4868 = ReplacementRule(pattern4868, replacement4868) pattern4869 = Pattern(Integral((x_*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1))*tan(x_*WC('b', S(1)) + WC('a', S(0)))**p_/cos(x_*WC('b', S(1)) + WC('a', S(0))), x_), cons2, cons3, cons7, cons27, cons21, cons1408) def replacement4869(p, m, b, d, c, a, x): rubi.append(4869) return Int((c + d*x)**m*tan(a + b*x)**(p + S(-2))/cos(a + b*x)**S(3), x) - Int((c + d*x)**m*tan(a + b*x)**(p + S(-2))/cos(a + b*x), x) rule4869 = ReplacementRule(pattern4869, replacement4869) pattern4870 = Pattern(Integral((x_*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1))*(S(1)/cos(x_*WC('b', S(1)) + WC('a', S(0))))**WC('n', S(1))*tan(x_*WC('b', S(1)) + WC('a', S(0)))**p_, x_), cons2, cons3, cons7, cons27, cons21, cons4, cons1408) def replacement4870(p, m, b, d, c, a, n, x): rubi.append(4870) return -Int((c + d*x)**m*(S(1)/cos(a + b*x))**n*tan(a + b*x)**(p + S(-2)), x) + Int((c + d*x)**m*(S(1)/cos(a + b*x))**(n + S(2))*tan(a + b*x)**(p + S(-2)), x) rule4870 = ReplacementRule(pattern4870, replacement4870) pattern4871 = Pattern(Integral((x_*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1))*(S(1)/tan(x_*WC('b', S(1)) + WC('a', S(0))))**p_/sin(x_*WC('b', S(1)) + WC('a', S(0))), x_), cons2, cons3, cons7, cons27, cons21, cons1408) def replacement4871(p, m, b, d, c, a, x): rubi.append(4871) return Int((c + d*x)**m*(S(1)/tan(a + b*x))**(p + S(-2))/sin(a + b*x)**S(3), x) - Int((c + d*x)**m*(S(1)/tan(a + b*x))**(p + S(-2))/sin(a + b*x), x) rule4871 = ReplacementRule(pattern4871, replacement4871) pattern4872 = Pattern(Integral((x_*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1))*(S(1)/sin(x_*WC('b', S(1)) + WC('a', S(0))))**WC('n', S(1))*(S(1)/tan(x_*WC('b', S(1)) + WC('a', S(0))))**p_, x_), cons2, cons3, cons7, cons27, cons21, cons4, cons1408) def replacement4872(p, m, b, d, c, a, n, x): rubi.append(4872) return -Int((c + d*x)**m*(S(1)/sin(a + b*x))**n*(S(1)/tan(a + b*x))**(p + S(-2)), x) + Int((c + d*x)**m*(S(1)/sin(a + b*x))**(n + S(2))*(S(1)/tan(a + b*x))**(p + S(-2)), x) rule4872 = ReplacementRule(pattern4872, replacement4872) def With4873(p, m, b, d, c, a, n, x): u = IntHide((S(1)/cos(a + b*x))**n*tan(a + b*x)**p, x) rubi.append(4873) return -Dist(d*m, Int(u*(c + d*x)**(m + S(-1)), x), x) + Dist((c + d*x)**m, u, x) pattern4873 = Pattern(Integral((x_*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1))*(S(1)/cos(x_*WC('b', S(1)) + WC('a', S(0))))**WC('n', S(1))*tan(x_*WC('b', S(1)) + WC('a', S(0)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons4, cons5, cons62, cons1684) rule4873 = ReplacementRule(pattern4873, With4873) def With4874(p, m, b, d, c, a, n, x): u = IntHide((S(1)/sin(a + b*x))**n*(S(1)/tan(a + b*x))**p, x) rubi.append(4874) return -Dist(d*m, Int(u*(c + d*x)**(m + S(-1)), x), x) + Dist((c + d*x)**m, u, x) pattern4874 = Pattern(Integral((x_*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1))*(S(1)/sin(x_*WC('b', S(1)) + WC('a', S(0))))**WC('n', S(1))*(S(1)/tan(x_*WC('b', S(1)) + WC('a', S(0))))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons4, cons5, cons62, cons1684) rule4874 = ReplacementRule(pattern4874, With4874) pattern4875 = Pattern(Integral((x_*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1))*(S(1)/sin(x_*WC('b', S(1)) + WC('a', S(0))))**WC('n', S(1))*(S(1)/cos(x_*WC('b', S(1)) + WC('a', S(0))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons31, cons85) def replacement4875(m, b, d, c, a, n, x): rubi.append(4875) return Dist(S(2)**n, Int((c + d*x)**m*(S(1)/sin(S(2)*a + S(2)*b*x))**n, x), x) rule4875 = ReplacementRule(pattern4875, replacement4875) def With4876(p, m, b, d, c, a, n, x): u = IntHide((S(1)/sin(a + b*x))**n*(S(1)/cos(a + b*x))**p, x) rubi.append(4876) return -Dist(d*m, Int(u*(c + d*x)**(m + S(-1)), x), x) + Dist((c + d*x)**m, u, x) pattern4876 = Pattern(Integral((x_*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1))*(S(1)/sin(x_*WC('b', S(1)) + WC('a', S(0))))**WC('n', S(1))*(S(1)/cos(x_*WC('b', S(1)) + WC('a', S(0))))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons376, cons31, cons168, cons1685) rule4876 = ReplacementRule(pattern4876, With4876) pattern4877 = Pattern(Integral(F_**v_*G_**w_*u_**WC('m', S(1)), x_), cons21, cons4, cons5, cons1686, cons1687, cons1688, cons812, cons813) def replacement4877(v, w, p, u, m, G, n, x, F): rubi.append(4877) return Int(ExpandToSum(u, x)**m*F(ExpandToSum(v, x))**n*G(ExpandToSum(v, x))**p, x) rule4877 = ReplacementRule(pattern4877, replacement4877) pattern4878 = Pattern(Integral((a_ + WC('b', S(1))*sin(x_*WC('d', S(1)) + WC('c', S(0))))**WC('n', S(1))*(x_*WC('f', S(1)) + WC('e', S(0)))**WC('m', S(1))*cos(x_*WC('d', S(1)) + WC('c', S(0))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons4, cons62, cons584) def replacement4878(m, f, b, d, c, n, a, x, e): rubi.append(4878) return -Dist(f*m/(b*d*(n + S(1))), Int((a + b*sin(c + d*x))**(n + S(1))*(e + f*x)**(m + S(-1)), x), x) + Simp((a + b*sin(c + d*x))**(n + S(1))*(e + f*x)**m/(b*d*(n + S(1))), x) rule4878 = ReplacementRule(pattern4878, replacement4878) pattern4879 = Pattern(Integral((a_ + WC('b', S(1))*cos(x_*WC('d', S(1)) + WC('c', S(0))))**WC('n', S(1))*(x_*WC('f', S(1)) + WC('e', S(0)))**WC('m', S(1))*sin(x_*WC('d', S(1)) + WC('c', S(0))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons4, cons62, cons584) def replacement4879(m, f, b, d, c, n, a, x, e): rubi.append(4879) return Dist(f*m/(b*d*(n + S(1))), Int((a + b*cos(c + d*x))**(n + S(1))*(e + f*x)**(m + S(-1)), x), x) - Simp((a + b*cos(c + d*x))**(n + S(1))*(e + f*x)**m/(b*d*(n + S(1))), x) rule4879 = ReplacementRule(pattern4879, replacement4879) pattern4880 = Pattern(Integral((a_ + WC('b', S(1))*tan(x_*WC('d', S(1)) + WC('c', S(0))))**WC('n', S(1))*(x_*WC('f', S(1)) + WC('e', S(0)))**WC('m', S(1))/cos(x_*WC('d', S(1)) + WC('c', S(0)))**S(2), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons4, cons62, cons584) def replacement4880(m, f, b, d, c, n, a, x, e): rubi.append(4880) return -Dist(f*m/(b*d*(n + S(1))), Int((a + b*tan(c + d*x))**(n + S(1))*(e + f*x)**(m + S(-1)), x), x) + Simp((a + b*tan(c + d*x))**(n + S(1))*(e + f*x)**m/(b*d*(n + S(1))), x) rule4880 = ReplacementRule(pattern4880, replacement4880) pattern4881 = Pattern(Integral((a_ + WC('b', S(1))/tan(x_*WC('d', S(1)) + WC('c', S(0))))**WC('n', S(1))*(x_*WC('f', S(1)) + WC('e', S(0)))**WC('m', S(1))/sin(x_*WC('d', S(1)) + WC('c', S(0)))**S(2), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons4, cons62, cons584) def replacement4881(m, f, b, d, c, n, a, x, e): rubi.append(4881) return Dist(f*m/(b*d*(n + S(1))), Int((a + b/tan(c + d*x))**(n + S(1))*(e + f*x)**(m + S(-1)), x), x) - Simp((a + b/tan(c + d*x))**(n + S(1))*(e + f*x)**m/(b*d*(n + S(1))), x) rule4881 = ReplacementRule(pattern4881, replacement4881) pattern4882 = Pattern(Integral((a_ + WC('b', S(1))/cos(x_*WC('d', S(1)) + WC('c', S(0))))**WC('n', S(1))*(x_*WC('f', S(1)) + WC('e', S(0)))**WC('m', S(1))*tan(x_*WC('d', S(1)) + WC('c', S(0)))/cos(x_*WC('d', S(1)) + WC('c', S(0))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons4, cons62, cons584) def replacement4882(m, f, b, d, c, n, a, x, e): rubi.append(4882) return -Dist(f*m/(b*d*(n + S(1))), Int((a + b/cos(c + d*x))**(n + S(1))*(e + f*x)**(m + S(-1)), x), x) + Simp((a + b/cos(c + d*x))**(n + S(1))*(e + f*x)**m/(b*d*(n + S(1))), x) rule4882 = ReplacementRule(pattern4882, replacement4882) pattern4883 = Pattern(Integral((a_ + WC('b', S(1))/sin(x_*WC('d', S(1)) + WC('c', S(0))))**WC('n', S(1))*(x_*WC('f', S(1)) + WC('e', S(0)))**WC('m', S(1))/(sin(x_*WC('d', S(1)) + WC('c', S(0)))*tan(x_*WC('d', S(1)) + WC('c', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons4, cons62, cons584) def replacement4883(m, f, b, d, c, n, a, x, e): rubi.append(4883) return Dist(f*m/(b*d*(n + S(1))), Int((a + b/sin(c + d*x))**(n + S(1))*(e + f*x)**(m + S(-1)), x), x) - Simp((a + b/sin(c + d*x))**(n + S(1))*(e + f*x)**m/(b*d*(n + S(1))), x) rule4883 = ReplacementRule(pattern4883, replacement4883) pattern4884 = Pattern(Integral((x_*WC('f', S(1)) + WC('e', S(0)))**WC('m', S(1))*sin(x_*WC('b', S(1)) + WC('a', S(0)))**WC('p', S(1))*sin(x_*WC('d', S(1)) + WC('c', S(0)))**WC('q', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons555, cons17) def replacement4884(p, m, f, b, d, a, c, x, q, e): rubi.append(4884) return Int(ExpandTrigReduce((e + f*x)**m, sin(a + b*x)**p*sin(c + d*x)**q, x), x) rule4884 = ReplacementRule(pattern4884, replacement4884) pattern4885 = Pattern(Integral((x_*WC('f', S(1)) + WC('e', S(0)))**WC('m', S(1))*cos(x_*WC('b', S(1)) + WC('a', S(0)))**WC('p', S(1))*cos(x_*WC('d', S(1)) + WC('c', S(0)))**WC('q', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons555, cons17) def replacement4885(p, m, f, b, d, c, a, x, q, e): rubi.append(4885) return Int(ExpandTrigReduce((e + f*x)**m, cos(a + b*x)**p*cos(c + d*x)**q, x), x) rule4885 = ReplacementRule(pattern4885, replacement4885) pattern4886 = Pattern(Integral((x_*WC('f', S(1)) + WC('e', S(0)))**WC('m', S(1))*sin(x_*WC('b', S(1)) + WC('a', S(0)))**WC('p', S(1))*cos(x_*WC('d', S(1)) + WC('c', S(0)))**WC('q', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons555) def replacement4886(p, m, f, b, d, c, a, x, q, e): rubi.append(4886) return Int(ExpandTrigReduce((e + f*x)**m, sin(a + b*x)**p*cos(c + d*x)**q, x), x) rule4886 = ReplacementRule(pattern4886, replacement4886) pattern4887 = Pattern(Integral(F_**(x_*WC('b', S(1)) + WC('a', S(0)))*G_**(x_*WC('d', S(1)) + WC('c', S(0)))*(x_*WC('f', S(1)) + WC('e', S(0)))**WC('m', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons1689, cons1690, cons555, cons25, cons1691) def replacement4887(p, m, f, b, G, d, a, c, x, q, e, F): rubi.append(4887) return Int(ExpandTrigExpand((e + f*x)**m*G(c + d*x)**q, F, c + d*x, p, b/d, x), x) rule4887 = ReplacementRule(pattern4887, replacement4887) pattern4888 = Pattern(Integral(F_**((x_*WC('b', S(1)) + WC('a', S(0)))*WC('c', S(1)))*sin(x_*WC('e', S(1)) + WC('d', S(0))), x_), cons1099, cons2, cons3, cons7, cons27, cons48, cons1692) def replacement4888(b, d, c, a, x, F, e): rubi.append(4888) return -Simp(F**(c*(a + b*x))*e*cos(d + e*x)/(b**S(2)*c**S(2)*log(F)**S(2) + e**S(2)), x) + Simp(F**(c*(a + b*x))*b*c*log(F)*sin(d + e*x)/(b**S(2)*c**S(2)*log(F)**S(2) + e**S(2)), x) rule4888 = ReplacementRule(pattern4888, replacement4888) pattern4889 = Pattern(Integral(F_**((x_*WC('b', S(1)) + WC('a', S(0)))*WC('c', S(1)))*cos(x_*WC('e', S(1)) + WC('d', S(0))), x_), cons1099, cons2, cons3, cons7, cons27, cons48, cons1692) def replacement4889(b, d, c, a, x, F, e): rubi.append(4889) return Simp(F**(c*(a + b*x))*e*sin(d + e*x)/(b**S(2)*c**S(2)*log(F)**S(2) + e**S(2)), x) + Simp(F**(c*(a + b*x))*b*c*log(F)*cos(d + e*x)/(b**S(2)*c**S(2)*log(F)**S(2) + e**S(2)), x) rule4889 = ReplacementRule(pattern4889, replacement4889) pattern4890 = Pattern(Integral(F_**((x_*WC('b', S(1)) + WC('a', S(0)))*WC('c', S(1)))*sin(x_*WC('e', S(1)) + WC('d', S(0)))**n_, x_), cons1099, cons2, cons3, cons7, cons27, cons48, cons1693, cons87, cons165) def replacement4890(b, d, c, a, n, x, F, e): rubi.append(4890) return Dist(e**S(2)*n*(n + S(-1))/(b**S(2)*c**S(2)*log(F)**S(2) + e**S(2)*n**S(2)), Int(F**(c*(a + b*x))*sin(d + e*x)**(n + S(-2)), x), x) + Simp(F**(c*(a + b*x))*b*c*log(F)*sin(d + e*x)**n/(b**S(2)*c**S(2)*log(F)**S(2) + e**S(2)*n**S(2)), x) - Simp(F**(c*(a + b*x))*e*n*sin(d + e*x)**(n + S(-1))*cos(d + e*x)/(b**S(2)*c**S(2)*log(F)**S(2) + e**S(2)*n**S(2)), x) rule4890 = ReplacementRule(pattern4890, replacement4890) pattern4891 = Pattern(Integral(F_**((x_*WC('b', S(1)) + WC('a', S(0)))*WC('c', S(1)))*cos(x_*WC('e', S(1)) + WC('d', S(0)))**m_, x_), cons1099, cons2, cons3, cons7, cons27, cons48, cons1694, cons31, cons166) def replacement4891(m, b, d, c, a, x, F, e): rubi.append(4891) return Dist(e**S(2)*m*(m + S(-1))/(b**S(2)*c**S(2)*log(F)**S(2) + e**S(2)*m**S(2)), Int(F**(c*(a + b*x))*cos(d + e*x)**(m + S(-2)), x), x) + Simp(F**(c*(a + b*x))*b*c*log(F)*cos(d + e*x)**m/(b**S(2)*c**S(2)*log(F)**S(2) + e**S(2)*m**S(2)), x) + Simp(F**(c*(a + b*x))*e*m*sin(d + e*x)*cos(d + e*x)**(m + S(-1))/(b**S(2)*c**S(2)*log(F)**S(2) + e**S(2)*m**S(2)), x) rule4891 = ReplacementRule(pattern4891, replacement4891) pattern4892 = Pattern(Integral(F_**((x_*WC('b', S(1)) + WC('a', S(0)))*WC('c', S(1)))*sin(x_*WC('e', S(1)) + WC('d', S(0)))**n_, x_), cons1099, cons2, cons3, cons7, cons27, cons48, cons4, cons1695, cons584, cons1395) def replacement4892(b, d, c, a, n, x, F, e): rubi.append(4892) return Simp(F**(c*(a + b*x))*sin(d + e*x)**(n + S(1))*cos(d + e*x)/(e*(n + S(1))), x) - Simp(F**(c*(a + b*x))*b*c*log(F)*sin(d + e*x)**(n + S(2))/(e**S(2)*(n + S(1))*(n + S(2))), x) rule4892 = ReplacementRule(pattern4892, replacement4892) pattern4893 = Pattern(Integral(F_**((x_*WC('b', S(1)) + WC('a', S(0)))*WC('c', S(1)))*cos(x_*WC('e', S(1)) + WC('d', S(0)))**n_, x_), cons1099, cons2, cons3, cons7, cons27, cons48, cons4, cons1695, cons584, cons1395) def replacement4893(b, d, c, a, n, x, F, e): rubi.append(4893) return -Simp(F**(c*(a + b*x))*sin(d + e*x)*cos(d + e*x)**(n + S(1))/(e*(n + S(1))), x) - Simp(F**(c*(a + b*x))*b*c*log(F)*cos(d + e*x)**(n + S(2))/(e**S(2)*(n + S(1))*(n + S(2))), x) rule4893 = ReplacementRule(pattern4893, replacement4893) pattern4894 = Pattern(Integral(F_**((x_*WC('b', S(1)) + WC('a', S(0)))*WC('c', S(1)))*sin(x_*WC('e', S(1)) + WC('d', S(0)))**n_, x_), cons1099, cons2, cons3, cons7, cons27, cons48, cons1696, cons87, cons89, cons1442) def replacement4894(b, d, c, a, n, x, F, e): rubi.append(4894) return Dist((b**S(2)*c**S(2)*log(F)**S(2) + e**S(2)*(n + S(2))**S(2))/(e**S(2)*(n + S(1))*(n + S(2))), Int(F**(c*(a + b*x))*sin(d + e*x)**(n + S(2)), x), x) + Simp(F**(c*(a + b*x))*sin(d + e*x)**(n + S(1))*cos(d + e*x)/(e*(n + S(1))), x) - Simp(F**(c*(a + b*x))*b*c*log(F)*sin(d + e*x)**(n + S(2))/(e**S(2)*(n + S(1))*(n + S(2))), x) rule4894 = ReplacementRule(pattern4894, replacement4894) pattern4895 = Pattern(Integral(F_**((x_*WC('b', S(1)) + WC('a', S(0)))*WC('c', S(1)))*cos(x_*WC('e', S(1)) + WC('d', S(0)))**n_, x_), cons1099, cons2, cons3, cons7, cons27, cons48, cons1696, cons87, cons89, cons1442) def replacement4895(b, d, c, a, n, x, F, e): rubi.append(4895) return Dist((b**S(2)*c**S(2)*log(F)**S(2) + e**S(2)*(n + S(2))**S(2))/(e**S(2)*(n + S(1))*(n + S(2))), Int(F**(c*(a + b*x))*cos(d + e*x)**(n + S(2)), x), x) - Simp(F**(c*(a + b*x))*sin(d + e*x)*cos(d + e*x)**(n + S(1))/(e*(n + S(1))), x) - Simp(F**(c*(a + b*x))*b*c*log(F)*cos(d + e*x)**(n + S(2))/(e**S(2)*(n + S(1))*(n + S(2))), x) rule4895 = ReplacementRule(pattern4895, replacement4895) pattern4896 = Pattern(Integral(F_**((x_*WC('b', S(1)) + WC('a', S(0)))*WC('c', S(1)))*sin(x_*WC('e', S(1)) + WC('d', S(0)))**n_, x_), cons1099, cons2, cons3, cons7, cons27, cons48, cons4, cons23) def replacement4896(b, d, c, a, n, x, F, e): rubi.append(4896) return Dist((exp(S(2)*I*(d + e*x)) + S(-1))**(-n)*exp(I*n*(d + e*x))*sin(d + e*x)**n, Int(F**(c*(a + b*x))*(exp(S(2)*I*(d + e*x)) + S(-1))**n*exp(-I*n*(d + e*x)), x), x) rule4896 = ReplacementRule(pattern4896, replacement4896) pattern4897 = Pattern(Integral(F_**((x_*WC('b', S(1)) + WC('a', S(0)))*WC('c', S(1)))*cos(x_*WC('e', S(1)) + WC('d', S(0)))**n_, x_), cons1099, cons2, cons3, cons7, cons27, cons48, cons4, cons23) def replacement4897(b, d, c, a, n, x, F, e): rubi.append(4897) return Dist((exp(S(2)*I*(d + e*x)) + S(1))**(-n)*exp(I*n*(d + e*x))*cos(d + e*x)**n, Int(F**(c*(a + b*x))*(exp(S(2)*I*(d + e*x)) + S(1))**n*exp(-I*n*(d + e*x)), x), x) rule4897 = ReplacementRule(pattern4897, replacement4897) pattern4898 = Pattern(Integral(F_**((x_*WC('b', S(1)) + WC('a', S(0)))*WC('c', S(1)))*tan(x_*WC('e', S(1)) + WC('d', S(0)))**WC('n', S(1)), x_), cons1099, cons2, cons3, cons7, cons27, cons48, cons85) def replacement4898(b, d, c, a, n, x, F, e): rubi.append(4898) return Dist(I**n, Int(ExpandIntegrand(F**(c*(a + b*x))*(-exp(S(2)*I*(d + e*x)) + S(1))**n*(exp(S(2)*I*(d + e*x)) + S(1))**(-n), x), x), x) rule4898 = ReplacementRule(pattern4898, replacement4898) pattern4899 = Pattern(Integral(F_**((x_*WC('b', S(1)) + WC('a', S(0)))*WC('c', S(1)))*(S(1)/tan(x_*WC('e', S(1)) + WC('d', S(0))))**WC('n', S(1)), x_), cons1099, cons2, cons3, cons7, cons27, cons48, cons85) def replacement4899(b, d, c, n, a, x, F, e): rubi.append(4899) return Dist((-I)**n, Int(ExpandIntegrand(F**(c*(a + b*x))*(-exp(S(2)*I*(d + e*x)) + S(1))**(-n)*(exp(S(2)*I*(d + e*x)) + S(1))**n, x), x), x) rule4899 = ReplacementRule(pattern4899, replacement4899) pattern4900 = Pattern(Integral(F_**((x_*WC('b', S(1)) + WC('a', S(0)))*WC('c', S(1)))*(S(1)/cos(x_*WC('e', S(1)) + WC('d', S(0))))**n_, x_), cons1099, cons2, cons3, cons7, cons27, cons48, cons1693, cons87, cons89) def replacement4900(b, d, c, a, n, x, F, e): rubi.append(4900) return Dist(e**S(2)*n*(n + S(1))/(b**S(2)*c**S(2)*log(F)**S(2) + e**S(2)*n**S(2)), Int(F**(c*(a + b*x))*(S(1)/cos(d + e*x))**(n + S(2)), x), x) + Simp(F**(c*(a + b*x))*b*c*(S(1)/cos(d + e*x))**n*log(F)/(b**S(2)*c**S(2)*log(F)**S(2) + e**S(2)*n**S(2)), x) - Simp(F**(c*(a + b*x))*e*n*(S(1)/cos(d + e*x))**(n + S(1))*sin(d + e*x)/(b**S(2)*c**S(2)*log(F)**S(2) + e**S(2)*n**S(2)), x) rule4900 = ReplacementRule(pattern4900, replacement4900) pattern4901 = Pattern(Integral(F_**((x_*WC('b', S(1)) + WC('a', S(0)))*WC('c', S(1)))*(S(1)/sin(x_*WC('e', S(1)) + WC('d', S(0))))**n_, x_), cons1099, cons2, cons3, cons7, cons27, cons48, cons1693, cons87, cons89) def replacement4901(b, d, c, a, n, x, F, e): rubi.append(4901) return Dist(e**S(2)*n*(n + S(1))/(b**S(2)*c**S(2)*log(F)**S(2) + e**S(2)*n**S(2)), Int(F**(c*(a + b*x))*(S(1)/sin(d + e*x))**(n + S(2)), x), x) + Simp(F**(c*(a + b*x))*b*c*(S(1)/sin(d + e*x))**n*log(F)/(b**S(2)*c**S(2)*log(F)**S(2) + e**S(2)*n**S(2)), x) + Simp(F**(c*(a + b*x))*e*n*(S(1)/sin(d + e*x))**(n + S(1))*cos(d + e*x)/(b**S(2)*c**S(2)*log(F)**S(2) + e**S(2)*n**S(2)), x) rule4901 = ReplacementRule(pattern4901, replacement4901) pattern4902 = Pattern(Integral(F_**((x_*WC('b', S(1)) + WC('a', S(0)))*WC('c', S(1)))*(S(1)/cos(x_*WC('e', S(1)) + WC('d', S(0))))**n_, x_), cons1099, cons2, cons3, cons7, cons27, cons48, cons4, cons1697, cons1502, cons963) def replacement4902(b, d, c, a, n, x, F, e): rubi.append(4902) return Simp(F**(c*(a + b*x))*(S(1)/cos(d + e*x))**(n + S(-1))*sin(d + e*x)/(e*(n + S(-1))), x) - Simp(F**(c*(a + b*x))*b*c*(S(1)/cos(d + e*x))**(n + S(-2))*log(F)/(e**S(2)*(n + S(-2))*(n + S(-1))), x) rule4902 = ReplacementRule(pattern4902, replacement4902) pattern4903 = Pattern(Integral(F_**((x_*WC('b', S(1)) + WC('a', S(0)))*WC('c', S(1)))*(S(1)/sin(x_*WC('e', S(1)) + WC('d', S(0))))**n_, x_), cons1099, cons2, cons3, cons7, cons27, cons48, cons4, cons1697, cons1502, cons963) def replacement4903(b, d, c, a, n, x, F, e): rubi.append(4903) return Simp(F**(c*(a + b*x))*(S(1)/sin(d + e*x))**(n + S(-1))*cos(d + e*x)/(e*(n + S(-1))), x) - Simp(F**(c*(a + b*x))*b*c*(S(1)/sin(d + e*x))**(n + S(-2))*log(F)/(e**S(2)*(n + S(-2))*(n + S(-1))), x) rule4903 = ReplacementRule(pattern4903, replacement4903) pattern4904 = Pattern(Integral(F_**((x_*WC('b', S(1)) + WC('a', S(0)))*WC('c', S(1)))*(S(1)/cos(x_*WC('e', S(1)) + WC('d', S(0))))**n_, x_), cons1099, cons2, cons3, cons7, cons27, cons48, cons1698, cons87, cons165, cons1644) def replacement4904(b, d, c, a, n, x, F, e): rubi.append(4904) return Dist((b**S(2)*c**S(2)*log(F)**S(2) + e**S(2)*(n + S(-2))**S(2))/(e**S(2)*(n + S(-2))*(n + S(-1))), Int(F**(c*(a + b*x))*(S(1)/cos(d + e*x))**(n + S(-2)), x), x) + Simp(F**(c*(a + b*x))*(S(1)/cos(d + e*x))**(n + S(-1))*sin(d + e*x)/(e*(n + S(-1))), x) - Simp(F**(c*(a + b*x))*b*c*(S(1)/cos(d + e*x))**(n + S(-2))*log(F)/(e**S(2)*(n + S(-2))*(n + S(-1))), x) rule4904 = ReplacementRule(pattern4904, replacement4904) pattern4905 = Pattern(Integral(F_**((x_*WC('b', S(1)) + WC('a', S(0)))*WC('c', S(1)))*(S(1)/sin(x_*WC('e', S(1)) + WC('d', S(0))))**n_, x_), cons1099, cons2, cons3, cons7, cons27, cons48, cons1698, cons87, cons165, cons1644) def replacement4905(b, d, c, a, n, x, F, e): rubi.append(4905) return Dist((b**S(2)*c**S(2)*log(F)**S(2) + e**S(2)*(n + S(-2))**S(2))/(e**S(2)*(n + S(-2))*(n + S(-1))), Int(F**(c*(a + b*x))*(S(1)/sin(d + e*x))**(n + S(-2)), x), x) - Simp(F**(c*(a + b*x))*(S(1)/sin(d + e*x))**(n + S(-1))*cos(d + e*x)/(e*(n + S(-1))), x) - Simp(F**(c*(a + b*x))*b*c*(S(1)/sin(d + e*x))**(n + S(-2))*log(F)/(e**S(2)*(n + S(-2))*(n + S(-1))), x) rule4905 = ReplacementRule(pattern4905, replacement4905) pattern4906 = Pattern(Integral(F_**((x_*WC('b', S(1)) + WC('a', S(0)))*WC('c', S(1)))*(S(1)/cos(x_*WC('e', S(1)) + WC('d', S(0))))**WC('n', S(1)), x_), cons1099, cons2, cons3, cons7, cons27, cons48, cons85) def replacement4906(b, d, c, a, n, x, F, e): rubi.append(4906) return Simp(S(2)**n*F**(c*(a + b*x))*Hypergeometric2F1(n, -I*b*c*log(F)/(S(2)*e) + n/S(2), -I*b*c*log(F)/(S(2)*e) + n/S(2) + S(1), -exp(S(2)*I*(d + e*x)))*exp(I*n*(d + e*x))/(b*c*log(F) + I*e*n), x) rule4906 = ReplacementRule(pattern4906, replacement4906) pattern4907 = Pattern(Integral(F_**((x_*WC('b', S(1)) + WC('a', S(0)))*WC('c', S(1)))*(S(1)/sin(x_*WC('e', S(1)) + WC('d', S(0))))**WC('n', S(1)), x_), cons1099, cons2, cons3, cons7, cons27, cons48, cons85) def replacement4907(b, d, c, n, a, x, F, e): rubi.append(4907) return Simp(F**(c*(a + b*x))*(-S(2)*I)**n*Hypergeometric2F1(n, -I*b*c*log(F)/(S(2)*e) + n/S(2), -I*b*c*log(F)/(S(2)*e) + n/S(2) + S(1), exp(S(2)*I*(d + e*x)))*exp(I*n*(d + e*x))/(b*c*log(F) + I*e*n), x) rule4907 = ReplacementRule(pattern4907, replacement4907) pattern4908 = Pattern(Integral(F_**((x_*WC('b', S(1)) + WC('a', S(0)))*WC('c', S(1)))*(S(1)/cos(x_*WC('e', S(1)) + WC('d', S(0))))**WC('n', S(1)), x_), cons1099, cons2, cons3, cons7, cons27, cons48, cons23) def replacement4908(b, d, c, a, n, x, F, e): rubi.append(4908) return Dist((exp(S(2)*I*(d + e*x)) + S(1))**n*(S(1)/cos(d + e*x))**n*exp(-I*n*(d + e*x)), Int(SimplifyIntegrand(F**(c*(a + b*x))*(exp(S(2)*I*(d + e*x)) + S(1))**(-n)*exp(I*n*(d + e*x)), x), x), x) rule4908 = ReplacementRule(pattern4908, replacement4908) pattern4909 = Pattern(Integral(F_**((x_*WC('b', S(1)) + WC('a', S(0)))*WC('c', S(1)))*(S(1)/sin(x_*WC('e', S(1)) + WC('d', S(0))))**WC('n', S(1)), x_), cons1099, cons2, cons3, cons7, cons27, cons48, cons23) def replacement4909(b, d, c, n, a, x, F, e): rubi.append(4909) return Dist((S(1) - exp(-S(2)*I*(d + e*x)))**n*(S(1)/sin(d + e*x))**n*exp(I*n*(d + e*x)), Int(SimplifyIntegrand(F**(c*(a + b*x))*(S(1) - exp(-S(2)*I*(d + e*x)))**(-n)*exp(-I*n*(d + e*x)), x), x), x) rule4909 = ReplacementRule(pattern4909, replacement4909) pattern4910 = Pattern(Integral(F_**((x_*WC('b', S(1)) + WC('a', S(0)))*WC('c', S(1)))*(f_ + WC('g', S(1))*sin(x_*WC('e', S(1)) + WC('d', S(0))))**WC('n', S(1)), x_), cons1099, cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons1699, cons196) def replacement4910(g, b, f, d, c, a, n, x, F, e): rubi.append(4910) return Dist(S(2)**n*f**n, Int(F**(c*(a + b*x))*cos(-Pi*f/(S(4)*g) + d/S(2) + e*x/S(2))**(S(2)*n), x), x) rule4910 = ReplacementRule(pattern4910, replacement4910) pattern4911 = Pattern(Integral(F_**((x_*WC('b', S(1)) + WC('a', S(0)))*WC('c', S(1)))*(f_ + WC('g', S(1))*cos(x_*WC('e', S(1)) + WC('d', S(0))))**WC('n', S(1)), x_), cons1099, cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons1700, cons196) def replacement4911(g, b, f, d, c, n, a, x, F, e): rubi.append(4911) return Dist(S(2)**n*f**n, Int(F**(c*(a + b*x))*cos(d/S(2) + e*x/S(2))**(S(2)*n), x), x) rule4911 = ReplacementRule(pattern4911, replacement4911) pattern4912 = Pattern(Integral(F_**((x_*WC('b', S(1)) + WC('a', S(0)))*WC('c', S(1)))*(f_ + WC('g', S(1))*cos(x_*WC('e', S(1)) + WC('d', S(0))))**WC('n', S(1)), x_), cons1099, cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons1011, cons196) def replacement4912(g, b, f, d, c, n, a, x, F, e): rubi.append(4912) return Dist(S(2)**n*f**n, Int(F**(c*(a + b*x))*sin(d/S(2) + e*x/S(2))**(S(2)*n), x), x) rule4912 = ReplacementRule(pattern4912, replacement4912) pattern4913 = Pattern(Integral(F_**((x_*WC('b', S(1)) + WC('a', S(0)))*WC('c', S(1)))*(f_ + WC('g', S(1))*sin(x_*WC('e', S(1)) + WC('d', S(0))))**WC('n', S(1))*cos(x_*WC('e', S(1)) + WC('d', S(0)))**WC('m', S(1)), x_), cons1099, cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons1699, cons150, cons1551) def replacement4913(m, g, b, f, d, c, a, n, x, F, e): rubi.append(4913) return Dist(g**n, Int(F**(c*(a + b*x))*(-tan(-Pi*f/(S(4)*g) + d/S(2) + e*x/S(2)))**m, x), x) rule4913 = ReplacementRule(pattern4913, replacement4913) pattern4914 = Pattern(Integral(F_**((x_*WC('b', S(1)) + WC('a', S(0)))*WC('c', S(1)))*(f_ + WC('g', S(1))*cos(x_*WC('e', S(1)) + WC('d', S(0))))**WC('n', S(1))*sin(x_*WC('e', S(1)) + WC('d', S(0)))**WC('m', S(1)), x_), cons1099, cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons1700, cons150, cons1551) def replacement4914(m, g, b, f, d, c, n, a, x, F, e): rubi.append(4914) return Dist(f**n, Int(F**(c*(a + b*x))*tan(d/S(2) + e*x/S(2))**m, x), x) rule4914 = ReplacementRule(pattern4914, replacement4914) pattern4915 = Pattern(Integral(F_**((x_*WC('b', S(1)) + WC('a', S(0)))*WC('c', S(1)))*(f_ + WC('g', S(1))*cos(x_*WC('e', S(1)) + WC('d', S(0))))**WC('n', S(1))*sin(x_*WC('e', S(1)) + WC('d', S(0)))**WC('m', S(1)), x_), cons1099, cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons1011, cons150, cons1551) def replacement4915(m, g, b, f, d, c, n, a, x, F, e): rubi.append(4915) return Dist(f**n, Int(F**(c*(a + b*x))*(S(1)/tan(d/S(2) + e*x/S(2)))**m, x), x) rule4915 = ReplacementRule(pattern4915, replacement4915) pattern4916 = Pattern(Integral(F_**((x_*WC('b', S(1)) + WC('a', S(0)))*WC('c', S(1)))*(h_ + WC('i', S(1))*cos(x_*WC('e', S(1)) + WC('d', S(0))))/(f_ + WC('g', S(1))*sin(x_*WC('e', S(1)) + WC('d', S(0)))), x_), cons1099, cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons209, cons224, cons1699, cons1701, cons1702) def replacement4916(g, b, f, i, d, c, a, x, h, F, e): rubi.append(4916) return Dist(S(2)*i, Int(F**(c*(a + b*x))*cos(d + e*x)/(f + g*sin(d + e*x)), x), x) + Int(F**(c*(a + b*x))*(h - i*cos(d + e*x))/(f + g*sin(d + e*x)), x) rule4916 = ReplacementRule(pattern4916, replacement4916) pattern4917 = Pattern(Integral(F_**((x_*WC('b', S(1)) + WC('a', S(0)))*WC('c', S(1)))*(h_ + WC('i', S(1))*sin(x_*WC('e', S(1)) + WC('d', S(0))))/(f_ + WC('g', S(1))*cos(x_*WC('e', S(1)) + WC('d', S(0)))), x_), cons1099, cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons209, cons224, cons1699, cons1701, cons1703) def replacement4917(g, b, f, i, d, c, a, x, h, F, e): rubi.append(4917) return Dist(S(2)*i, Int(F**(c*(a + b*x))*sin(d + e*x)/(f + g*cos(d + e*x)), x), x) + Int(F**(c*(a + b*x))*(h - i*sin(d + e*x))/(f + g*cos(d + e*x)), x) rule4917 = ReplacementRule(pattern4917, replacement4917) pattern4918 = Pattern(Integral(F_**(u_*WC('c', S(1)))*G_**v_, x_), cons1099, cons7, cons4, cons1687, cons810, cons811) def replacement4918(v, u, G, c, n, x, F): rubi.append(4918) return Int(F**(c*ExpandToSum(u, x))*G(ExpandToSum(v, x))**n, x) rule4918 = ReplacementRule(pattern4918, replacement4918) def With4919(m, b, d, c, a, n, x, F, e): u = IntHide(F**(c*(a + b*x))*sin(d + e*x)**n, x) rubi.append(4919) return -Dist(m, Int(u*x**(m + S(-1)), x), x) + Dist(x**m, u, x) pattern4919 = Pattern(Integral(F_**((x_*WC('b', S(1)) + WC('a', S(0)))*WC('c', S(1)))*x_**WC('m', S(1))*sin(x_*WC('e', S(1)) + WC('d', S(0)))**WC('n', S(1)), x_), cons1099, cons2, cons3, cons7, cons27, cons48, cons31, cons168, cons148) rule4919 = ReplacementRule(pattern4919, With4919) def With4920(m, b, d, c, n, a, x, F, e): u = IntHide(F**(c*(a + b*x))*cos(d + e*x)**n, x) rubi.append(4920) return -Dist(m, Int(u*x**(m + S(-1)), x), x) + Dist(x**m, u, x) pattern4920 = Pattern(Integral(F_**((x_*WC('b', S(1)) + WC('a', S(0)))*WC('c', S(1)))*x_**WC('m', S(1))*cos(x_*WC('e', S(1)) + WC('d', S(0)))**WC('n', S(1)), x_), cons1099, cons2, cons3, cons7, cons27, cons48, cons31, cons168, cons148) rule4920 = ReplacementRule(pattern4920, With4920) pattern4921 = Pattern(Integral(F_**((x_*WC('b', S(1)) + WC('a', S(0)))*WC('c', S(1)))*sin(x_*WC('e', S(1)) + WC('d', S(0)))**WC('m', S(1))*cos(x_*WC('g', S(1)) + WC('f', S(0)))**WC('n', S(1)), x_), cons1099, cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons528) def replacement4921(m, f, g, b, d, c, n, a, x, F, e): rubi.append(4921) return Int(ExpandTrigReduce(F**(c*(a + b*x)), sin(d + e*x)**m*cos(f + g*x)**n, x), x) rule4921 = ReplacementRule(pattern4921, replacement4921) pattern4922 = Pattern(Integral(F_**((x_*WC('b', S(1)) + WC('a', S(0)))*WC('c', S(1)))*x_**WC('p', S(1))*sin(x_*WC('e', S(1)) + WC('d', S(0)))**WC('m', S(1))*cos(x_*WC('g', S(1)) + WC('f', S(0)))**WC('n', S(1)), x_), cons1099, cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons1704) def replacement4922(p, m, f, g, b, d, c, n, a, x, F, e): rubi.append(4922) return Int(ExpandTrigReduce(F**(c*(a + b*x))*x**p, sin(d + e*x)**m*cos(f + g*x)**n, x), x) rule4922 = ReplacementRule(pattern4922, replacement4922) pattern4923 = Pattern(Integral(F_**((x_*WC('b', S(1)) + WC('a', S(0)))*WC('c', S(1)))*G_**(x_*WC('e', S(1)) + WC('d', S(0)))*H_**(x_*WC('e', S(1)) + WC('d', S(0))), x_), cons1099, cons2, cons3, cons7, cons27, cons48, cons528, cons1687, cons1705) def replacement4923(m, b, G, d, c, a, n, H, x, F, e): rubi.append(4923) return Int(ExpandTrigToExp(F**(c*(a + b*x)), G(d + e*x)**m*H(d + e*x)**n, x), x) rule4923 = ReplacementRule(pattern4923, replacement4923) pattern4924 = Pattern(Integral(F_**u_*sin(v_)**WC('n', S(1)), x_), cons1099, cons1706, cons1707, cons148) def replacement4924(v, u, n, x, F): rubi.append(4924) return Int(ExpandTrigToExp(F**u, sin(v)**n, x), x) rule4924 = ReplacementRule(pattern4924, replacement4924) pattern4925 = Pattern(Integral(F_**u_*cos(v_)**WC('n', S(1)), x_), cons1099, cons1706, cons1707, cons148) def replacement4925(v, u, n, x, F): rubi.append(4925) return Int(ExpandTrigToExp(F**u, cos(v)**n, x), x) rule4925 = ReplacementRule(pattern4925, replacement4925) pattern4926 = Pattern(Integral(F_**u_*sin(v_)**WC('m', S(1))*cos(v_)**WC('n', S(1)), x_), cons1099, cons1706, cons1707, cons528) def replacement4926(v, u, m, n, x, F): rubi.append(4926) return Int(ExpandTrigToExp(F**u, sin(v)**m*cos(v)**n, x), x) rule4926 = ReplacementRule(pattern4926, replacement4926) pattern4927 = Pattern(Integral(sin(WC('a', S(0)) + WC('b', S(1))*log(x_**WC('n', S(1))*WC('c', S(1))))**p_, x_), cons2, cons3, cons7, cons4, cons5, cons1708, cons54) def replacement4927(p, b, a, n, c, x): rubi.append(4927) return Simp(x*(p + S(2))*sin(a + b*log(c*x**n))**(p + S(2))/(p + S(1)), x) + Simp(x*sin(a + b*log(c*x**n))**(p + S(2))/(b*n*(p + S(1))*tan(a + b*log(c*x**n))), x) rule4927 = ReplacementRule(pattern4927, replacement4927) pattern4928 = Pattern(Integral(cos(WC('a', S(0)) + WC('b', S(1))*log(x_**WC('n', S(1))*WC('c', S(1))))**p_, x_), cons2, cons3, cons7, cons4, cons5, cons1708, cons54) def replacement4928(p, b, a, n, c, x): rubi.append(4928) return Simp(x*(p + S(2))*cos(a + b*log(c*x**n))**(p + S(2))/(p + S(1)), x) - Simp(x*cos(a + b*log(c*x**n))**(p + S(2))*tan(a + b*log(c*x**n))/(b*n*(p + S(1))), x) rule4928 = ReplacementRule(pattern4928, replacement4928) pattern4929 = Pattern(Integral(sin(WC('a', S(0)) + WC('b', S(1))*log(x_**WC('n', S(1))*WC('c', S(1))))**WC('p', S(1)), x_), cons2, cons3, cons7, cons4, cons128, cons1709) def replacement4929(p, b, a, n, c, x): rubi.append(4929) return Int(ExpandIntegrand((-(c*x**n)**(S(1)/(n*p))*exp(-a*b*n*p)/(S(2)*b*n*p) + (c*x**n)**(-S(1)/(n*p))*exp(a*b*n*p)/(S(2)*b*n*p))**p, x), x) rule4929 = ReplacementRule(pattern4929, replacement4929) pattern4930 = Pattern(Integral(cos(WC('a', S(0)) + WC('b', S(1))*log(x_**WC('n', S(1))*WC('c', S(1))))**WC('p', S(1)), x_), cons2, cons3, cons7, cons4, cons128, cons1709) def replacement4930(p, b, a, n, c, x): rubi.append(4930) return Int(ExpandIntegrand((-(c*x**n)**(S(1)/(n*p))*exp(-a*b*n*p)/S(2) + (c*x**n)**(-S(1)/(n*p))*exp(a*b*n*p)/S(2))**p, x), x) rule4930 = ReplacementRule(pattern4930, replacement4930) pattern4931 = Pattern(Integral(sin(WC('a', S(0)) + WC('b', S(1))*log(x_**WC('n', S(1))*WC('c', S(1)))), x_), cons2, cons3, cons7, cons4, cons1710) def replacement4931(b, a, n, c, x): rubi.append(4931) return Simp(x*sin(a + b*log(c*x**n))/(b**S(2)*n**S(2) + S(1)), x) - Simp(b*n*x*cos(a + b*log(c*x**n))/(b**S(2)*n**S(2) + S(1)), x) rule4931 = ReplacementRule(pattern4931, replacement4931) pattern4932 = Pattern(Integral(cos(WC('a', S(0)) + WC('b', S(1))*log(x_**WC('n', S(1))*WC('c', S(1)))), x_), cons2, cons3, cons7, cons4, cons1710) def replacement4932(b, a, n, c, x): rubi.append(4932) return Simp(x*cos(a + b*log(c*x**n))/(b**S(2)*n**S(2) + S(1)), x) + Simp(b*n*x*sin(a + b*log(c*x**n))/(b**S(2)*n**S(2) + S(1)), x) rule4932 = ReplacementRule(pattern4932, replacement4932) pattern4933 = Pattern(Integral(sin(WC('a', S(0)) + WC('b', S(1))*log(x_**WC('n', S(1))*WC('c', S(1))))**p_, x_), cons2, cons3, cons7, cons4, cons13, cons146, cons1711) def replacement4933(p, b, a, n, c, x): rubi.append(4933) return Dist(b**S(2)*n**S(2)*p*(p + S(-1))/(b**S(2)*n**S(2)*p**S(2) + S(1)), Int(sin(a + b*log(c*x**n))**(p + S(-2)), x), x) + Simp(x*sin(a + b*log(c*x**n))**p/(b**S(2)*n**S(2)*p**S(2) + S(1)), x) - Simp(b*n*p*x*sin(a + b*log(c*x**n))**(p + S(-1))*cos(a + b*log(c*x**n))/(b**S(2)*n**S(2)*p**S(2) + S(1)), x) rule4933 = ReplacementRule(pattern4933, replacement4933) pattern4934 = Pattern(Integral(cos(WC('a', S(0)) + WC('b', S(1))*log(x_**WC('n', S(1))*WC('c', S(1))))**p_, x_), cons2, cons3, cons7, cons4, cons13, cons146, cons1711) def replacement4934(p, b, a, n, c, x): rubi.append(4934) return Dist(b**S(2)*n**S(2)*p*(p + S(-1))/(b**S(2)*n**S(2)*p**S(2) + S(1)), Int(cos(a + b*log(c*x**n))**(p + S(-2)), x), x) + Simp(x*cos(a + b*log(c*x**n))**p/(b**S(2)*n**S(2)*p**S(2) + S(1)), x) + Simp(b*n*p*x*sin(a + b*log(c*x**n))*cos(a + b*log(c*x**n))**(p + S(-1))/(b**S(2)*n**S(2)*p**S(2) + S(1)), x) rule4934 = ReplacementRule(pattern4934, replacement4934) pattern4935 = Pattern(Integral(sin(WC('a', S(0)) + WC('b', S(1))*log(x_**WC('n', S(1))*WC('c', S(1))))**p_, x_), cons2, cons3, cons7, cons4, cons13, cons137, cons1505, cons1712) def replacement4935(p, b, a, n, c, x): rubi.append(4935) return Dist((b**S(2)*n**S(2)*(p + S(2))**S(2) + S(1))/(b**S(2)*n**S(2)*(p + S(1))*(p + S(2))), Int(sin(a + b*log(c*x**n))**(p + S(2)), x), x) - Simp(x*sin(a + b*log(c*x**n))**(p + S(2))/(b**S(2)*n**S(2)*(p + S(1))*(p + S(2))), x) + Simp(x*sin(a + b*log(c*x**n))**(p + S(2))/(b*n*(p + S(1))*tan(a + b*log(c*x**n))), x) rule4935 = ReplacementRule(pattern4935, replacement4935) pattern4936 = Pattern(Integral(cos(WC('a', S(0)) + WC('b', S(1))*log(x_**WC('n', S(1))*WC('c', S(1))))**p_, x_), cons2, cons3, cons7, cons4, cons13, cons137, cons1505, cons1712) def replacement4936(p, b, a, n, c, x): rubi.append(4936) return Dist((b**S(2)*n**S(2)*(p + S(2))**S(2) + S(1))/(b**S(2)*n**S(2)*(p + S(1))*(p + S(2))), Int(cos(a + b*log(c*x**n))**(p + S(2)), x), x) - Simp(x*cos(a + b*log(c*x**n))**(p + S(2))/(b**S(2)*n**S(2)*(p + S(1))*(p + S(2))), x) - Simp(x*cos(a + b*log(c*x**n))**(p + S(2))*tan(a + b*log(c*x**n))/(b*n*(p + S(1))), x) rule4936 = ReplacementRule(pattern4936, replacement4936) pattern4937 = Pattern(Integral(sin(WC('a', S(0)) + WC('b', S(1))*log(x_**WC('n', S(1))*WC('c', S(1))))**p_, x_), cons2, cons3, cons7, cons4, cons5, cons1711) def replacement4937(p, b, a, n, c, x): rubi.append(4937) return Simp(x*(-S(2)*(c*x**n)**(S(2)*I*b)*exp(S(2)*I*a) + S(2))**(-p)*(-I*(c*x**n)**(I*b)*exp(I*a) + I*(c*x**n)**(-I*b)*exp(-I*a))**p*Hypergeometric2F1(-p, -I*(-I*b*n*p + S(1))/(S(2)*b*n), S(1) - I*(-I*b*n*p + S(1))/(S(2)*b*n), (c*x**n)**(S(2)*I*b)*exp(S(2)*I*a))/(-I*b*n*p + S(1)), x) rule4937 = ReplacementRule(pattern4937, replacement4937) pattern4938 = Pattern(Integral(cos(WC('a', S(0)) + WC('b', S(1))*log(x_**WC('n', S(1))*WC('c', S(1))))**p_, x_), cons2, cons3, cons7, cons4, cons5, cons1711) def replacement4938(p, b, a, n, c, x): rubi.append(4938) return Simp(x*((c*x**n)**(I*b)*exp(I*a) + (c*x**n)**(-I*b)*exp(-I*a))**p*(S(2)*(c*x**n)**(S(2)*I*b)*exp(S(2)*I*a) + S(2))**(-p)*Hypergeometric2F1(-p, -I*(-I*b*n*p + S(1))/(S(2)*b*n), S(1) - I*(-I*b*n*p + S(1))/(S(2)*b*n), -(c*x**n)**(S(2)*I*b)*exp(S(2)*I*a))/(-I*b*n*p + S(1)), x) rule4938 = ReplacementRule(pattern4938, replacement4938) pattern4939 = Pattern(Integral(x_**WC('m', S(1))*sin(WC('a', S(0)) + WC('b', S(1))*log(x_**WC('n', S(1))*WC('c', S(1))))**p_, x_), cons2, cons3, cons7, cons21, cons4, cons5, cons1713, cons54, cons66) def replacement4939(p, m, b, c, n, a, x): rubi.append(4939) return Simp(x**(m + S(1))*(p + S(2))*sin(a + b*log(c*x**n))**(p + S(2))/((m + S(1))*(p + S(1))), x) + Simp(x**(m + S(1))*sin(a + b*log(c*x**n))**(p + S(2))/(b*n*(p + S(1))*tan(a + b*log(c*x**n))), x) rule4939 = ReplacementRule(pattern4939, replacement4939) pattern4940 = Pattern(Integral(x_**WC('m', S(1))*cos(WC('a', S(0)) + WC('b', S(1))*log(x_**WC('n', S(1))*WC('c', S(1))))**p_, x_), cons2, cons3, cons7, cons21, cons4, cons5, cons1713, cons54, cons66) def replacement4940(p, m, b, a, n, c, x): rubi.append(4940) return Simp(x**(m + S(1))*(p + S(2))*cos(a + b*log(c*x**n))**(p + S(2))/((m + S(1))*(p + S(1))), x) - Simp(x**(m + S(1))*cos(a + b*log(c*x**n))**(p + S(2))*tan(a + b*log(c*x**n))/(b*n*(p + S(1))), x) rule4940 = ReplacementRule(pattern4940, replacement4940) pattern4941 = Pattern(Integral(x_**WC('m', S(1))*sin(WC('a', S(0)) + WC('b', S(1))*log(x_**WC('n', S(1))*WC('c', S(1))))**WC('p', S(1)), x_), cons2, cons3, cons7, cons21, cons4, cons128, cons1714) def replacement4941(p, m, b, c, n, a, x): rubi.append(4941) return Dist(S(2)**(-p), Int(ExpandIntegrand(x**m*(-(c*x**n)**((m + S(1))/(n*p))*(m + S(1))*exp(-a*b*n*p/(m + S(1)))/(b*n*p) + (c*x**n)**(-(m + S(1))/(n*p))*(m + S(1))*exp(a*b*n*p/(m + S(1)))/(b*n*p))**p, x), x), x) rule4941 = ReplacementRule(pattern4941, replacement4941) pattern4942 = Pattern(Integral(x_**WC('m', S(1))*cos(WC('a', S(0)) + WC('b', S(1))*log(x_**WC('n', S(1))*WC('c', S(1))))**WC('p', S(1)), x_), cons2, cons3, cons7, cons21, cons4, cons128, cons1714) def replacement4942(p, m, b, a, n, c, x): rubi.append(4942) return Dist(S(2)**(-p), Int(ExpandIntegrand(x**m*(-(c*x**n)**((m + S(1))/(n*p))*exp(-a*b*n*p/(m + S(1))) + (c*x**n)**(-(m + S(1))/(n*p))*exp(a*b*n*p/(m + S(1))))**p, x), x), x) rule4942 = ReplacementRule(pattern4942, replacement4942) pattern4943 = Pattern(Integral(x_**WC('m', S(1))*sin(WC('a', S(0)) + WC('b', S(1))*log(x_**WC('n', S(1))*WC('c', S(1)))), x_), cons2, cons3, cons7, cons21, cons4, cons1715) def replacement4943(m, b, c, n, a, x): rubi.append(4943) return Simp(x**(m + S(1))*(m + S(1))*sin(a + b*log(c*x**n))/(b**S(2)*n**S(2) + (m + S(1))**S(2)), x) - Simp(b*n*x**(m + S(1))*cos(a + b*log(c*x**n))/(b**S(2)*n**S(2) + (m + S(1))**S(2)), x) rule4943 = ReplacementRule(pattern4943, replacement4943) pattern4944 = Pattern(Integral(x_**WC('m', S(1))*cos(WC('a', S(0)) + WC('b', S(1))*log(x_**WC('n', S(1))*WC('c', S(1)))), x_), cons2, cons3, cons7, cons21, cons4, cons1715) def replacement4944(m, b, a, n, c, x): rubi.append(4944) return Simp(x**(m + S(1))*(m + S(1))*cos(a + b*log(c*x**n))/(b**S(2)*n**S(2) + (m + S(1))**S(2)), x) + Simp(b*n*x**(m + S(1))*sin(a + b*log(c*x**n))/(b**S(2)*n**S(2) + (m + S(1))**S(2)), x) rule4944 = ReplacementRule(pattern4944, replacement4944) pattern4945 = Pattern(Integral(x_**WC('m', S(1))*sin(WC('a', S(0)) + WC('b', S(1))*log(x_**WC('n', S(1))*WC('c', S(1))))**p_, x_), cons2, cons3, cons7, cons21, cons4, cons13, cons146, cons1716) def replacement4945(p, m, b, c, n, a, x): rubi.append(4945) return Dist(b**S(2)*n**S(2)*p*(p + S(-1))/(b**S(2)*n**S(2)*p**S(2) + (m + S(1))**S(2)), Int(x**m*sin(a + b*log(c*x**n))**(p + S(-2)), x), x) + Simp(x**(m + S(1))*(m + S(1))*sin(a + b*log(c*x**n))**p/(b**S(2)*n**S(2)*p**S(2) + (m + S(1))**S(2)), x) - Simp(b*n*p*x**(m + S(1))*sin(a + b*log(c*x**n))**(p + S(-1))*cos(a + b*log(c*x**n))/(b**S(2)*n**S(2)*p**S(2) + (m + S(1))**S(2)), x) rule4945 = ReplacementRule(pattern4945, replacement4945) pattern4946 = Pattern(Integral(x_**WC('m', S(1))*cos(WC('a', S(0)) + WC('b', S(1))*log(x_**WC('n', S(1))*WC('c', S(1))))**p_, x_), cons2, cons3, cons7, cons21, cons4, cons13, cons146, cons1716) def replacement4946(p, m, b, a, n, c, x): rubi.append(4946) return Dist(b**S(2)*n**S(2)*p*(p + S(-1))/(b**S(2)*n**S(2)*p**S(2) + (m + S(1))**S(2)), Int(x**m*cos(a + b*log(c*x**n))**(p + S(-2)), x), x) + Simp(x**(m + S(1))*(m + S(1))*cos(a + b*log(c*x**n))**p/(b**S(2)*n**S(2)*p**S(2) + (m + S(1))**S(2)), x) + Simp(b*n*p*x**(m + S(1))*sin(a + b*log(c*x**n))*cos(a + b*log(c*x**n))**(p + S(-1))/(b**S(2)*n**S(2)*p**S(2) + (m + S(1))**S(2)), x) rule4946 = ReplacementRule(pattern4946, replacement4946) pattern4947 = Pattern(Integral(x_**WC('m', S(1))*sin(WC('a', S(0)) + WC('b', S(1))*log(x_**WC('n', S(1))*WC('c', S(1))))**p_, x_), cons2, cons3, cons7, cons21, cons4, cons13, cons137, cons1505, cons1717) def replacement4947(p, m, b, c, n, a, x): rubi.append(4947) return Dist((b**S(2)*n**S(2)*(p + S(2))**S(2) + (m + S(1))**S(2))/(b**S(2)*n**S(2)*(p + S(1))*(p + S(2))), Int(x**m*sin(a + b*log(c*x**n))**(p + S(2)), x), x) + Simp(x**(m + S(1))*sin(a + b*log(c*x**n))**(p + S(2))/(b*n*(p + S(1))*tan(a + b*log(c*x**n))), x) - Simp(x**(m + S(1))*(m + S(1))*sin(a + b*log(c*x**n))**(p + S(2))/(b**S(2)*n**S(2)*(p + S(1))*(p + S(2))), x) rule4947 = ReplacementRule(pattern4947, replacement4947) pattern4948 = Pattern(Integral(x_**WC('m', S(1))*cos(WC('a', S(0)) + WC('b', S(1))*log(x_**WC('n', S(1))*WC('c', S(1))))**p_, x_), cons2, cons3, cons7, cons21, cons4, cons13, cons137, cons1505, cons1717) def replacement4948(p, m, b, a, n, c, x): rubi.append(4948) return Dist((b**S(2)*n**S(2)*(p + S(2))**S(2) + (m + S(1))**S(2))/(b**S(2)*n**S(2)*(p + S(1))*(p + S(2))), Int(x**m*cos(a + b*log(c*x**n))**(p + S(2)), x), x) - Simp(x**(m + S(1))*cos(a + b*log(c*x**n))**(p + S(2))*tan(a + b*log(c*x**n))/(b*n*(p + S(1))), x) - Simp(x**(m + S(1))*(m + S(1))*cos(a + b*log(c*x**n))**(p + S(2))/(b**S(2)*n**S(2)*(p + S(1))*(p + S(2))), x) rule4948 = ReplacementRule(pattern4948, replacement4948) pattern4949 = Pattern(Integral(x_**WC('m', S(1))*sin(WC('a', S(0)) + WC('b', S(1))*log(x_**WC('n', S(1))*WC('c', S(1))))**p_, x_), cons2, cons3, cons7, cons21, cons4, cons5, cons1716) def replacement4949(p, m, b, c, n, a, x): rubi.append(4949) return Simp(x**(m + S(1))*(-S(2)*(c*x**n)**(S(2)*I*b)*exp(S(2)*I*a) + S(2))**(-p)*(-I*(c*x**n)**(I*b)*exp(I*a) + I*(c*x**n)**(-I*b)*exp(-I*a))**p*Hypergeometric2F1(-p, -I*(-I*b*n*p + m + S(1))/(S(2)*b*n), S(1) - I*(-I*b*n*p + m + S(1))/(S(2)*b*n), (c*x**n)**(S(2)*I*b)*exp(S(2)*I*a))/(-I*b*n*p + m + S(1)), x) rule4949 = ReplacementRule(pattern4949, replacement4949) pattern4950 = Pattern(Integral(x_**WC('m', S(1))*cos(WC('a', S(0)) + WC('b', S(1))*log(x_**WC('n', S(1))*WC('c', S(1))))**p_, x_), cons2, cons3, cons7, cons21, cons4, cons5, cons1716) def replacement4950(p, m, b, a, n, c, x): rubi.append(4950) return Simp(x**(m + S(1))*((c*x**n)**(I*b)*exp(I*a) + (c*x**n)**(-I*b)*exp(-I*a))**p*(S(2)*(c*x**n)**(S(2)*I*b)*exp(S(2)*I*a) + S(2))**(-p)*Hypergeometric2F1(-p, -I*(-I*b*n*p + m + S(1))/(S(2)*b*n), S(1) - I*(-I*b*n*p + m + S(1))/(S(2)*b*n), -(c*x**n)**(S(2)*I*b)*exp(S(2)*I*a))/(-I*b*n*p + m + S(1)), x) rule4950 = ReplacementRule(pattern4950, replacement4950) pattern4951 = Pattern(Integral(S(1)/cos(WC('a', S(0)) + WC('b', S(1))*log(x_**WC('n', S(1))*WC('c', S(1)))), x_), cons2, cons3, cons7, cons4, cons1718) def replacement4951(b, a, n, c, x): rubi.append(4951) return Dist(S(2)*exp(a*b*n), Int((c*x**n)**(S(1)/n)/((c*x**n)**(S(2)/n) + exp(S(2)*a*b*n)), x), x) rule4951 = ReplacementRule(pattern4951, replacement4951) pattern4952 = Pattern(Integral(S(1)/sin(WC('a', S(0)) + WC('b', S(1))*log(x_**WC('n', S(1))*WC('c', S(1)))), x_), cons2, cons3, cons7, cons4, cons1718) def replacement4952(b, a, n, c, x): rubi.append(4952) return Dist(S(2)*b*n*exp(a*b*n), Int((c*x**n)**(S(1)/n)/(-(c*x**n)**(S(2)/n) + exp(S(2)*a*b*n)), x), x) rule4952 = ReplacementRule(pattern4952, replacement4952) pattern4953 = Pattern(Integral((S(1)/cos(WC('a', S(0)) + WC('b', S(1))*log(x_**WC('n', S(1))*WC('c', S(1)))))**p_, x_), cons2, cons3, cons7, cons4, cons5, cons1719, cons1645) def replacement4953(p, b, a, n, c, x): rubi.append(4953) return Simp(x*(p + S(-2))*(S(1)/cos(a + b*log(c*x**n)))**(p + S(-2))/(p + S(-1)), x) + Simp(x*(S(1)/cos(a + b*log(c*x**n)))**(p + S(-2))*tan(a + b*log(c*x**n))/(b*n*(p + S(-1))), x) rule4953 = ReplacementRule(pattern4953, replacement4953) pattern4954 = Pattern(Integral((S(1)/sin(WC('a', S(0)) + WC('b', S(1))*log(x_**WC('n', S(1))*WC('c', S(1)))))**p_, x_), cons2, cons3, cons7, cons4, cons5, cons1719, cons1645) def replacement4954(p, b, a, n, c, x): rubi.append(4954) return Simp(x*(p + S(-2))*(S(1)/sin(a + b*log(c*x**n)))**(p + S(-2))/(p + S(-1)), x) - Simp(x*(S(1)/sin(a + b*log(c*x**n)))**(p + S(-2))/(b*n*(p + S(-1))*tan(a + b*log(c*x**n))), x) rule4954 = ReplacementRule(pattern4954, replacement4954) pattern4955 = Pattern(Integral((S(1)/cos(WC('a', S(0)) + WC('b', S(1))*log(x_**WC('n', S(1))*WC('c', S(1)))))**p_, x_), cons2, cons3, cons7, cons4, cons13, cons146, cons1720, cons1721) def replacement4955(p, b, a, n, c, x): rubi.append(4955) return Dist((b**S(2)*n**S(2)*(p + S(-2))**S(2) + S(1))/(b**S(2)*n**S(2)*(p + S(-2))*(p + S(-1))), Int((S(1)/cos(a + b*log(c*x**n)))**(p + S(-2)), x), x) - Simp(x*(S(1)/cos(a + b*log(c*x**n)))**(p + S(-2))/(b**S(2)*n**S(2)*(p + S(-2))*(p + S(-1))), x) + Simp(x*(S(1)/cos(a + b*log(c*x**n)))**(p + S(-2))*tan(a + b*log(c*x**n))/(b*n*(p + S(-1))), x) rule4955 = ReplacementRule(pattern4955, replacement4955) pattern4956 = Pattern(Integral((S(1)/sin(WC('a', S(0)) + WC('b', S(1))*log(x_**WC('n', S(1))*WC('c', S(1)))))**p_, x_), cons2, cons3, cons7, cons4, cons13, cons146, cons1720, cons1721) def replacement4956(p, b, a, n, c, x): rubi.append(4956) return Dist((b**S(2)*n**S(2)*(p + S(-2))**S(2) + S(1))/(b**S(2)*n**S(2)*(p + S(-2))*(p + S(-1))), Int((S(1)/sin(a + b*log(c*x**n)))**(p + S(-2)), x), x) - Simp(x*(S(1)/sin(a + b*log(c*x**n)))**(p + S(-2))/(b**S(2)*n**S(2)*(p + S(-2))*(p + S(-1))), x) - Simp(x*(S(1)/sin(a + b*log(c*x**n)))**(p + S(-2))/(b*n*(p + S(-1))*tan(a + b*log(c*x**n))), x) rule4956 = ReplacementRule(pattern4956, replacement4956) pattern4957 = Pattern(Integral((S(1)/cos(WC('a', S(0)) + WC('b', S(1))*log(x_**WC('n', S(1))*WC('c', S(1)))))**p_, x_), cons2, cons3, cons7, cons4, cons13, cons137, cons1711) def replacement4957(p, b, a, n, c, x): rubi.append(4957) return Dist(b**S(2)*n**S(2)*p*(p + S(1))/(b**S(2)*n**S(2)*p**S(2) + S(1)), Int((S(1)/cos(a + b*log(c*x**n)))**(p + S(2)), x), x) + Simp(x*(S(1)/cos(a + b*log(c*x**n)))**p/(b**S(2)*n**S(2)*p**S(2) + S(1)), x) - Simp(b*n*p*x*(S(1)/cos(a + b*log(c*x**n)))**(p + S(1))*sin(a + b*log(c*x**n))/(b**S(2)*n**S(2)*p**S(2) + S(1)), x) rule4957 = ReplacementRule(pattern4957, replacement4957) pattern4958 = Pattern(Integral((S(1)/sin(WC('a', S(0)) + WC('b', S(1))*log(x_**WC('n', S(1))*WC('c', S(1)))))**p_, x_), cons2, cons3, cons7, cons4, cons13, cons137, cons1711) def replacement4958(p, b, a, n, c, x): rubi.append(4958) return Dist(b**S(2)*n**S(2)*p*(p + S(1))/(b**S(2)*n**S(2)*p**S(2) + S(1)), Int((S(1)/sin(a + b*log(c*x**n)))**(p + S(2)), x), x) + Simp(x*(S(1)/sin(a + b*log(c*x**n)))**p/(b**S(2)*n**S(2)*p**S(2) + S(1)), x) + Simp(b*n*p*x*(S(1)/sin(a + b*log(c*x**n)))**(p + S(1))*cos(a + b*log(c*x**n))/(b**S(2)*n**S(2)*p**S(2) + S(1)), x) rule4958 = ReplacementRule(pattern4958, replacement4958) pattern4959 = Pattern(Integral((S(1)/cos(WC('a', S(0)) + WC('b', S(1))*log(x_**WC('n', S(1))*WC('c', S(1)))))**WC('p', S(1)), x_), cons2, cons3, cons7, cons4, cons5, cons1711) def replacement4959(p, b, a, n, c, x): rubi.append(4959) return Simp(x*((c*x**n)**(I*b)*exp(I*a)/((c*x**n)**(S(2)*I*b)*exp(S(2)*I*a) + S(1)))**p*(S(2)*(c*x**n)**(S(2)*I*b)*exp(S(2)*I*a) + S(2))**p*Hypergeometric2F1(p, -I*(I*b*n*p + S(1))/(S(2)*b*n), S(1) - I*(I*b*n*p + S(1))/(S(2)*b*n), -(c*x**n)**(S(2)*I*b)*exp(S(2)*I*a))/(I*b*n*p + S(1)), x) rule4959 = ReplacementRule(pattern4959, replacement4959) pattern4960 = Pattern(Integral((S(1)/sin(WC('a', S(0)) + WC('b', S(1))*log(x_**WC('n', S(1))*WC('c', S(1)))))**WC('p', S(1)), x_), cons2, cons3, cons7, cons4, cons5, cons1711) def replacement4960(p, b, a, n, c, x): rubi.append(4960) return Simp(x*(-I*(c*x**n)**(I*b)*exp(I*a)/(-(c*x**n)**(S(2)*I*b)*exp(S(2)*I*a) + S(1)))**p*(-S(2)*(c*x**n)**(S(2)*I*b)*exp(S(2)*I*a) + S(2))**p*Hypergeometric2F1(p, -I*(I*b*n*p + S(1))/(S(2)*b*n), S(1) - I*(I*b*n*p + S(1))/(S(2)*b*n), (c*x**n)**(S(2)*I*b)*exp(S(2)*I*a))/(I*b*n*p + S(1)), x) rule4960 = ReplacementRule(pattern4960, replacement4960) pattern4961 = Pattern(Integral(x_**WC('m', S(1))/cos(WC('a', S(0)) + WC('b', S(1))*log(x_**WC('n', S(1))*WC('c', S(1)))), x_), cons2, cons3, cons7, cons21, cons4, cons1722) def replacement4961(m, b, c, n, a, x): rubi.append(4961) return Dist(S(2)*exp(a*b*n/(m + S(1))), Int(x**m*(c*x**n)**((m + S(1))/n)/((c*x**n)**(S(2)*(m + S(1))/n) + exp(S(2)*a*b*n/(m + S(1)))), x), x) rule4961 = ReplacementRule(pattern4961, replacement4961) pattern4962 = Pattern(Integral(x_**WC('m', S(1))/sin(WC('a', S(0)) + WC('b', S(1))*log(x_**WC('n', S(1))*WC('c', S(1)))), x_), cons2, cons3, cons7, cons21, cons4, cons1722) def replacement4962(m, b, a, n, c, x): rubi.append(4962) return Dist(S(2)*b*n*exp(a*b*n/(m + S(1)))/(m + S(1)), Int(x**m*(c*x**n)**((m + S(1))/n)/(-(c*x**n)**(S(2)*(m + S(1))/n) + exp(S(2)*a*b*n/(m + S(1)))), x), x) rule4962 = ReplacementRule(pattern4962, replacement4962) pattern4963 = Pattern(Integral(x_**WC('m', S(1))*(S(1)/cos(WC('a', S(0)) + WC('b', S(1))*log(x_**WC('n', S(1))*WC('c', S(1)))))**p_, x_), cons2, cons3, cons7, cons21, cons4, cons5, cons1723, cons66, cons1645) def replacement4963(p, m, b, c, n, a, x): rubi.append(4963) return Simp(x**(m + S(1))*(p + S(-2))*(S(1)/cos(a + b*log(c*x**n)))**(p + S(-2))/((m + S(1))*(p + S(-1))), x) + Simp(x**(m + S(1))*(S(1)/cos(a + b*log(c*x**n)))**(p + S(-2))*tan(a + b*log(c*x**n))/(b*n*(p + S(-1))), x) rule4963 = ReplacementRule(pattern4963, replacement4963) pattern4964 = Pattern(Integral(x_**WC('m', S(1))*(S(1)/sin(WC('a', S(0)) + WC('b', S(1))*log(x_**WC('n', S(1))*WC('c', S(1)))))**p_, x_), cons2, cons3, cons7, cons21, cons4, cons5, cons1723, cons66, cons1645) def replacement4964(p, m, b, a, n, c, x): rubi.append(4964) return Simp(x**(m + S(1))*(p + S(-2))*(S(1)/sin(a + b*log(c*x**n)))**(p + S(-2))/((m + S(1))*(p + S(-1))), x) - Simp(x**(m + S(1))*(S(1)/sin(a + b*log(c*x**n)))**(p + S(-2))/(b*n*(p + S(-1))*tan(a + b*log(c*x**n))), x) rule4964 = ReplacementRule(pattern4964, replacement4964) pattern4965 = Pattern(Integral(x_**WC('m', S(1))*(S(1)/cos(WC('a', S(0)) + WC('b', S(1))*log(x_**WC('n', S(1))*WC('c', S(1)))))**p_, x_), cons2, cons3, cons7, cons21, cons4, cons13, cons146, cons1720, cons1724) def replacement4965(p, m, b, c, n, a, x): rubi.append(4965) return Dist((b**S(2)*n**S(2)*(p + S(-2))**S(2) + (m + S(1))**S(2))/(b**S(2)*n**S(2)*(p + S(-2))*(p + S(-1))), Int(x**m*(S(1)/cos(a + b*log(c*x**n)))**(p + S(-2)), x), x) + Simp(x**(m + S(1))*(S(1)/cos(a + b*log(c*x**n)))**(p + S(-2))*tan(a + b*log(c*x**n))/(b*n*(p + S(-1))), x) - Simp(x**(m + S(1))*(m + S(1))*(S(1)/cos(a + b*log(c*x**n)))**(p + S(-2))/(b**S(2)*n**S(2)*(p + S(-2))*(p + S(-1))), x) rule4965 = ReplacementRule(pattern4965, replacement4965) pattern4966 = Pattern(Integral(x_**WC('m', S(1))*(S(1)/sin(WC('a', S(0)) + WC('b', S(1))*log(x_**WC('n', S(1))*WC('c', S(1)))))**p_, x_), cons2, cons3, cons7, cons21, cons4, cons13, cons146, cons1720, cons1724) def replacement4966(p, m, b, a, n, c, x): rubi.append(4966) return Dist((b**S(2)*n**S(2)*(p + S(-2))**S(2) + (m + S(1))**S(2))/(b**S(2)*n**S(2)*(p + S(-2))*(p + S(-1))), Int(x**m*(S(1)/sin(a + b*log(c*x**n)))**(p + S(-2)), x), x) - Simp(x**(m + S(1))*(S(1)/sin(a + b*log(c*x**n)))**(p + S(-2))/(b*n*(p + S(-1))*tan(a + b*log(c*x**n))), x) - Simp(x**(m + S(1))*(m + S(1))*(S(1)/sin(a + b*log(c*x**n)))**(p + S(-2))/(b**S(2)*n**S(2)*(p + S(-2))*(p + S(-1))), x) rule4966 = ReplacementRule(pattern4966, replacement4966) pattern4967 = Pattern(Integral(x_**WC('m', S(1))*(S(1)/cos(WC('a', S(0)) + WC('b', S(1))*log(x_**WC('n', S(1))*WC('c', S(1)))))**p_, x_), cons2, cons3, cons7, cons21, cons4, cons13, cons137, cons1716) def replacement4967(p, m, b, c, n, a, x): rubi.append(4967) return Dist(b**S(2)*n**S(2)*p*(p + S(1))/(b**S(2)*n**S(2)*p**S(2) + (m + S(1))**S(2)), Int(x**m*(S(1)/cos(a + b*log(c*x**n)))**(p + S(2)), x), x) + Simp(x**(m + S(1))*(m + S(1))*(S(1)/cos(a + b*log(c*x**n)))**p/(b**S(2)*n**S(2)*p**S(2) + (m + S(1))**S(2)), x) - Simp(b*n*p*x**(m + S(1))*(S(1)/cos(a + b*log(c*x**n)))**(p + S(1))*sin(a + b*log(c*x**n))/(b**S(2)*n**S(2)*p**S(2) + (m + S(1))**S(2)), x) rule4967 = ReplacementRule(pattern4967, replacement4967) pattern4968 = Pattern(Integral(x_**WC('m', S(1))*(S(1)/sin(WC('a', S(0)) + WC('b', S(1))*log(x_**WC('n', S(1))*WC('c', S(1)))))**p_, x_), cons2, cons3, cons7, cons21, cons4, cons13, cons137, cons1716) def replacement4968(p, m, b, a, n, c, x): rubi.append(4968) return Dist(b**S(2)*n**S(2)*p*(p + S(1))/(b**S(2)*n**S(2)*p**S(2) + (m + S(1))**S(2)), Int(x**m*(S(1)/sin(a + b*log(c*x**n)))**(p + S(2)), x), x) + Simp(x**(m + S(1))*(m + S(1))*(S(1)/sin(a + b*log(c*x**n)))**p/(b**S(2)*n**S(2)*p**S(2) + (m + S(1))**S(2)), x) + Simp(b*n*p*x**(m + S(1))*(S(1)/sin(a + b*log(c*x**n)))**(p + S(1))*cos(a + b*log(c*x**n))/(b**S(2)*n**S(2)*p**S(2) + (m + S(1))**S(2)), x) rule4968 = ReplacementRule(pattern4968, replacement4968) pattern4969 = Pattern(Integral(x_**WC('m', S(1))*(S(1)/cos(WC('a', S(0)) + WC('b', S(1))*log(x_**WC('n', S(1))*WC('c', S(1)))))**WC('p', S(1)), x_), cons2, cons3, cons7, cons21, cons4, cons5, cons1716) def replacement4969(p, m, b, c, n, a, x): rubi.append(4969) return Simp(x**(m + S(1))*((c*x**n)**(I*b)*exp(I*a)/((c*x**n)**(S(2)*I*b)*exp(S(2)*I*a) + S(1)))**p*(S(2)*(c*x**n)**(S(2)*I*b)*exp(S(2)*I*a) + S(2))**p*Hypergeometric2F1(p, -I*(I*b*n*p + m + S(1))/(S(2)*b*n), S(1) - I*(I*b*n*p + m + S(1))/(S(2)*b*n), -(c*x**n)**(S(2)*I*b)*exp(S(2)*I*a))/(I*b*n*p + m + S(1)), x) rule4969 = ReplacementRule(pattern4969, replacement4969) pattern4970 = Pattern(Integral(x_**WC('m', S(1))*(S(1)/sin(WC('a', S(0)) + WC('b', S(1))*log(x_**WC('n', S(1))*WC('c', S(1)))))**WC('p', S(1)), x_), cons2, cons3, cons7, cons21, cons4, cons5, cons1716) def replacement4970(p, m, b, a, n, c, x): rubi.append(4970) return Simp(x**(m + S(1))*(-I*(c*x**n)**(I*b)*exp(I*a)/(-(c*x**n)**(S(2)*I*b)*exp(S(2)*I*a) + S(1)))**p*(-S(2)*(c*x**n)**(S(2)*I*b)*exp(S(2)*I*a) + S(2))**p*Hypergeometric2F1(p, -I*(I*b*n*p + m + S(1))/(S(2)*b*n), S(1) - I*(I*b*n*p + m + S(1))/(S(2)*b*n), (c*x**n)**(S(2)*I*b)*exp(S(2)*I*a))/(I*b*n*p + m + S(1)), x) rule4970 = ReplacementRule(pattern4970, replacement4970) pattern4971 = Pattern(Integral(log(x_*WC('b', S(1)))**WC('p', S(1))*sin(x_*WC('a', S(1))*log(x_*WC('b', S(1)))**WC('p', S(1))), x_), cons2, cons3, cons13, cons163) def replacement4971(x, a, p, b): rubi.append(4971) return -Dist(p, Int(log(b*x)**(p + S(-1))*sin(a*x*log(b*x)**p), x), x) - Simp(cos(a*x*log(b*x)**p)/a, x) rule4971 = ReplacementRule(pattern4971, replacement4971) pattern4972 = Pattern(Integral(log(x_*WC('b', S(1)))**WC('p', S(1))*cos(x_*WC('a', S(1))*log(x_*WC('b', S(1)))**WC('p', S(1))), x_), cons2, cons3, cons13, cons163) def replacement4972(x, a, p, b): rubi.append(4972) return -Dist(p, Int(log(b*x)**(p + S(-1))*cos(a*x*log(b*x)**p), x), x) + Simp(sin(a*x*log(b*x)**p)/a, x) rule4972 = ReplacementRule(pattern4972, replacement4972) pattern4973 = Pattern(Integral(log(x_*WC('b', S(1)))**WC('p', S(1))*sin(x_**n_*WC('a', S(1))*log(x_*WC('b', S(1)))**WC('p', S(1))), x_), cons2, cons3, cons338, cons163) def replacement4973(p, b, a, n, x): rubi.append(4973) return -Dist(p/n, Int(log(b*x)**(p + S(-1))*sin(a*x**n*log(b*x)**p), x), x) - Dist((n + S(-1))/(a*n), Int(x**(-n)*cos(a*x**n*log(b*x)**p), x), x) - Simp(x**(-n + S(1))*cos(a*x**n*log(b*x)**p)/(a*n), x) rule4973 = ReplacementRule(pattern4973, replacement4973) pattern4974 = Pattern(Integral(log(x_*WC('b', S(1)))**WC('p', S(1))*cos(x_**n_*WC('a', S(1))*log(x_*WC('b', S(1)))**WC('p', S(1))), x_), cons2, cons3, cons338, cons163) def replacement4974(p, b, a, n, x): rubi.append(4974) return -Dist(p/n, Int(log(b*x)**(p + S(-1))*cos(a*x**n*log(b*x)**p), x), x) + Dist((n + S(-1))/(a*n), Int(x**(-n)*sin(a*x**n*log(b*x)**p), x), x) + Simp(x**(-n + S(1))*sin(a*x**n*log(b*x)**p)/(a*n), x) rule4974 = ReplacementRule(pattern4974, replacement4974) pattern4975 = Pattern(Integral(x_**WC('m', S(1))*log(x_*WC('b', S(1)))**WC('p', S(1))*sin(x_**WC('n', S(1))*WC('a', S(1))*log(x_*WC('b', S(1)))**WC('p', S(1))), x_), cons2, cons3, cons21, cons4, cons53, cons13, cons163) def replacement4975(p, m, b, a, n, x): rubi.append(4975) return -Dist(p/n, Int(x**m*log(b*x)**(p + S(-1))*sin(a*x**n*log(b*x)**p), x), x) - Simp(cos(a*x**n*log(b*x)**p)/(a*n), x) rule4975 = ReplacementRule(pattern4975, replacement4975) pattern4976 = Pattern(Integral(x_**WC('m', S(1))*log(x_*WC('b', S(1)))**WC('p', S(1))*cos(x_**WC('n', S(1))*WC('a', S(1))*log(x_*WC('b', S(1)))**WC('p', S(1))), x_), cons2, cons3, cons21, cons4, cons53, cons13, cons163) def replacement4976(p, m, b, a, n, x): rubi.append(4976) return -Dist(p/n, Int(x**m*log(b*x)**(p + S(-1))*cos(a*x**n*log(b*x)**p), x), x) + Simp(sin(a*x**n*log(b*x)**p)/(a*n), x) rule4976 = ReplacementRule(pattern4976, replacement4976) pattern4977 = Pattern(Integral(x_**WC('m', S(1))*log(x_*WC('b', S(1)))**WC('p', S(1))*sin(x_**WC('n', S(1))*WC('a', S(1))*log(x_*WC('b', S(1)))**WC('p', S(1))), x_), cons2, cons3, cons21, cons4, cons13, cons163, cons627) def replacement4977(p, m, b, a, n, x): rubi.append(4977) return -Dist(p/n, Int(x**m*log(b*x)**(p + S(-1))*sin(a*x**n*log(b*x)**p), x), x) + Dist((m - n + S(1))/(a*n), Int(x**(m - n)*cos(a*x**n*log(b*x)**p), x), x) - Simp(x**(m - n + S(1))*cos(a*x**n*log(b*x)**p)/(a*n), x) rule4977 = ReplacementRule(pattern4977, replacement4977) pattern4978 = Pattern(Integral(x_**m_*log(x_*WC('b', S(1)))**WC('p', S(1))*cos(x_**WC('n', S(1))*WC('a', S(1))*log(x_*WC('b', S(1)))**WC('p', S(1))), x_), cons2, cons3, cons21, cons4, cons13, cons163, cons627) def replacement4978(p, m, b, a, n, x): rubi.append(4978) return -Dist(p/n, Int(x**m*log(b*x)**(p + S(-1))*cos(a*x**n*log(b*x)**p), x), x) - Dist((m - n + S(1))/(a*n), Int(x**(m - n)*sin(a*x**n*log(b*x)**p), x), x) + Simp(x**(m - n + S(1))*sin(a*x**n*log(b*x)**p)/(a*n), x) rule4978 = ReplacementRule(pattern4978, replacement4978) pattern4979 = Pattern(Integral(sin(WC('a', S(1))/(x_*WC('d', S(1)) + WC('c', S(0))))**WC('n', S(1)), x_), cons2, cons7, cons27, cons148) def replacement4979(d, a, n, c, x): rubi.append(4979) return -Dist(S(1)/d, Subst(Int(sin(a*x)**n/x**S(2), x), x, S(1)/(c + d*x)), x) rule4979 = ReplacementRule(pattern4979, replacement4979) pattern4980 = Pattern(Integral(cos(WC('a', S(1))/(x_*WC('d', S(1)) + WC('c', S(0))))**WC('n', S(1)), x_), cons2, cons7, cons27, cons148) def replacement4980(d, a, n, c, x): rubi.append(4980) return -Dist(S(1)/d, Subst(Int(cos(a*x)**n/x**S(2), x), x, S(1)/(c + d*x)), x) rule4980 = ReplacementRule(pattern4980, replacement4980) pattern4981 = Pattern(Integral(sin((x_*WC('b', S(1)) + WC('a', S(0)))*WC('e', S(1))/(x_*WC('d', S(1)) + WC('c', S(0))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons148, cons71) def replacement4981(b, d, c, a, n, x, e): rubi.append(4981) return -Dist(S(1)/d, Subst(Int(sin(b*e/d - e*x*(-a*d + b*c)/d)**n/x**S(2), x), x, S(1)/(c + d*x)), x) rule4981 = ReplacementRule(pattern4981, replacement4981) pattern4982 = Pattern(Integral(cos((x_*WC('b', S(1)) + WC('a', S(0)))*WC('e', S(1))/(x_*WC('d', S(1)) + WC('c', S(0))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons148, cons71) def replacement4982(b, d, c, a, n, x, e): rubi.append(4982) return -Dist(S(1)/d, Subst(Int(cos(b*e/d - e*x*(-a*d + b*c)/d)**n/x**S(2), x), x, S(1)/(c + d*x)), x) rule4982 = ReplacementRule(pattern4982, replacement4982) def With4983(x, n, u): lst = QuotientOfLinearsParts(u, x) rubi.append(4983) return Int(sin((x*Part(lst, S(2)) + Part(lst, S(1)))/(x*Part(lst, S(4)) + Part(lst, S(3))))**n, x) pattern4983 = Pattern(Integral(sin(u_)**WC('n', S(1)), x_), cons148, cons1725) rule4983 = ReplacementRule(pattern4983, With4983) def With4984(x, n, u): lst = QuotientOfLinearsParts(u, x) rubi.append(4984) return Int(cos((x*Part(lst, S(2)) + Part(lst, S(1)))/(x*Part(lst, S(4)) + Part(lst, S(3))))**n, x) pattern4984 = Pattern(Integral(cos(u_)**WC('n', S(1)), x_), cons148, cons1725) rule4984 = ReplacementRule(pattern4984, With4984) pattern4985 = Pattern(Integral(WC('u', S(1))*sin(v_)**WC('p', S(1))*sin(w_)**WC('q', S(1)), x_), cons1688) def replacement4985(v, w, p, u, x, q): rubi.append(4985) return Int(u*sin(v)**(p + q), x) rule4985 = ReplacementRule(pattern4985, replacement4985) pattern4986 = Pattern(Integral(WC('u', S(1))*cos(v_)**WC('p', S(1))*cos(w_)**WC('q', S(1)), x_), cons1688) def replacement4986(v, w, p, u, x, q): rubi.append(4986) return Int(u*cos(v)**(p + q), x) rule4986 = ReplacementRule(pattern4986, replacement4986) pattern4987 = Pattern(Integral(sin(v_)**WC('p', S(1))*sin(w_)**WC('q', S(1)), x_), cons1726, cons555) def replacement4987(v, w, p, x, q): rubi.append(4987) return Int(ExpandTrigReduce(sin(v)**p*sin(w)**q, x), x) rule4987 = ReplacementRule(pattern4987, replacement4987) pattern4988 = Pattern(Integral(cos(v_)**WC('p', S(1))*cos(w_)**WC('q', S(1)), x_), cons1726, cons555) def replacement4988(v, w, p, x, q): rubi.append(4988) return Int(ExpandTrigReduce(cos(v)**p*cos(w)**q, x), x) rule4988 = ReplacementRule(pattern4988, replacement4988) pattern4989 = Pattern(Integral(x_**WC('m', S(1))*sin(v_)**WC('p', S(1))*sin(w_)**WC('q', S(1)), x_), cons1727, cons1726) def replacement4989(v, w, p, m, x, q): rubi.append(4989) return Int(ExpandTrigReduce(x**m, sin(v)**p*sin(w)**q, x), x) rule4989 = ReplacementRule(pattern4989, replacement4989) pattern4990 = Pattern(Integral(x_**WC('m', S(1))*cos(v_)**WC('p', S(1))*cos(w_)**WC('q', S(1)), x_), cons1727, cons1726) def replacement4990(v, w, p, m, x, q): rubi.append(4990) return Int(ExpandTrigReduce(x**m, cos(v)**p*cos(w)**q, x), x) rule4990 = ReplacementRule(pattern4990, replacement4990) pattern4991 = Pattern(Integral(WC('u', S(1))*sin(v_)**WC('p', S(1))*cos(w_)**WC('p', S(1)), x_), cons1688, cons38) def replacement4991(v, w, p, u, x): rubi.append(4991) return Dist(S(2)**(-p), Int(u*sin(S(2)*v)**p, x), x) rule4991 = ReplacementRule(pattern4991, replacement4991) pattern4992 = Pattern(Integral(sin(v_)**WC('p', S(1))*cos(w_)**WC('q', S(1)), x_), cons555, cons1726) def replacement4992(v, w, p, x, q): rubi.append(4992) return Int(ExpandTrigReduce(sin(v)**p*cos(w)**q, x), x) rule4992 = ReplacementRule(pattern4992, replacement4992) pattern4993 = Pattern(Integral(x_**WC('m', S(1))*sin(v_)**WC('p', S(1))*cos(w_)**WC('q', S(1)), x_), cons1727, cons1726) def replacement4993(v, w, p, m, x, q): rubi.append(4993) return Int(ExpandTrigReduce(x**m, sin(v)**p*cos(w)**q, x), x) rule4993 = ReplacementRule(pattern4993, replacement4993) pattern4994 = Pattern(Integral(sin(v_)*tan(w_)**WC('n', S(1)), x_), cons87, cons88, cons1728) def replacement4994(v, w, n, x): rubi.append(4994) return Dist(cos(v - w), Int(tan(w)**(n + S(-1))/cos(w), x), x) - Int(cos(v)*tan(w)**(n + S(-1)), x) rule4994 = ReplacementRule(pattern4994, replacement4994) pattern4995 = Pattern(Integral((S(1)/tan(w_))**WC('n', S(1))*cos(v_), x_), cons87, cons88, cons1728) def replacement4995(v, w, n, x): rubi.append(4995) return Dist(cos(v - w), Int((S(1)/tan(w))**(n + S(-1))/sin(w), x), x) - Int((S(1)/tan(w))**(n + S(-1))*sin(v), x) rule4995 = ReplacementRule(pattern4995, replacement4995) pattern4996 = Pattern(Integral((S(1)/tan(w_))**WC('n', S(1))*sin(v_), x_), cons87, cons88, cons1728) def replacement4996(v, w, n, x): rubi.append(4996) return Dist(sin(v - w), Int((S(1)/tan(w))**(n + S(-1))/sin(w), x), x) + Int((S(1)/tan(w))**(n + S(-1))*cos(v), x) rule4996 = ReplacementRule(pattern4996, replacement4996) pattern4997 = Pattern(Integral(cos(v_)*tan(w_)**WC('n', S(1)), x_), cons87, cons88, cons1728) def replacement4997(v, w, n, x): rubi.append(4997) return -Dist(sin(v - w), Int(tan(w)**(n + S(-1))/cos(w), x), x) + Int(sin(v)*tan(w)**(n + S(-1)), x) rule4997 = ReplacementRule(pattern4997, replacement4997) pattern4998 = Pattern(Integral((S(1)/cos(w_))**WC('n', S(1))*sin(v_), x_), cons87, cons88, cons1728) def replacement4998(v, w, n, x): rubi.append(4998) return Dist(sin(v - w), Int((S(1)/cos(w))**(n + S(-1)), x), x) + Dist(cos(v - w), Int((S(1)/cos(w))**(n + S(-1))*tan(w), x), x) rule4998 = ReplacementRule(pattern4998, replacement4998) pattern4999 = Pattern(Integral((S(1)/sin(w_))**WC('n', S(1))*cos(v_), x_), cons87, cons88, cons1728) def replacement4999(v, w, n, x): rubi.append(4999) return -Dist(sin(v - w), Int((S(1)/sin(w))**(n + S(-1)), x), x) + Dist(cos(v - w), Int((S(1)/sin(w))**(n + S(-1))/tan(w), x), x) rule4999 = ReplacementRule(pattern4999, replacement4999) pattern5000 = Pattern(Integral((S(1)/sin(w_))**WC('n', S(1))*sin(v_), x_), cons87, cons88, cons1728) def replacement5000(v, w, n, x): rubi.append(5000) return Dist(sin(v - w), Int((S(1)/sin(w))**(n + S(-1))/tan(w), x), x) + Dist(cos(v - w), Int((S(1)/sin(w))**(n + S(-1)), x), x) rule5000 = ReplacementRule(pattern5000, replacement5000) pattern5001 = Pattern(Integral((S(1)/cos(w_))**WC('n', S(1))*cos(v_), x_), cons87, cons88, cons1728) def replacement5001(v, w, n, x): rubi.append(5001) return -Dist(sin(v - w), Int((S(1)/cos(w))**(n + S(-1))*tan(w), x), x) + Dist(cos(v - w), Int((S(1)/cos(w))**(n + S(-1)), x), x) rule5001 = ReplacementRule(pattern5001, replacement5001) pattern5002 = Pattern(Integral((a_ + WC('b', S(1))*sin(x_*WC('d', S(1)) + WC('c', S(0)))*cos(x_*WC('d', S(1)) + WC('c', S(0))))**WC('n', S(1))*(x_*WC('f', S(1)) + WC('e', S(0)))**WC('m', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons4, cons1360) def replacement5002(m, f, b, d, c, n, a, x, e): rubi.append(5002) return Int((a + b*sin(S(2)*c + S(2)*d*x)/S(2))**n*(e + f*x)**m, x) rule5002 = ReplacementRule(pattern5002, replacement5002) pattern5003 = Pattern(Integral(x_**WC('m', S(1))*(a_ + WC('b', S(1))*sin(x_*WC('d', S(1)) + WC('c', S(0)))**S(2))**n_, x_), cons2, cons3, cons7, cons27, cons1478, cons150, cons168, cons463, cons1729) def replacement5003(m, b, d, c, a, n, x): rubi.append(5003) return Dist(S(2)**(-n), Int(x**m*(S(2)*a - b*cos(S(2)*c + S(2)*d*x) + b)**n, x), x) rule5003 = ReplacementRule(pattern5003, replacement5003) pattern5004 = Pattern(Integral(x_**WC('m', S(1))*(a_ + WC('b', S(1))*cos(x_*WC('d', S(1)) + WC('c', S(0)))**S(2))**n_, x_), cons2, cons3, cons7, cons27, cons1478, cons150, cons168, cons463, cons1729) def replacement5004(m, b, d, c, a, n, x): rubi.append(5004) return Dist(S(2)**(-n), Int(x**m*(S(2)*a + b*cos(S(2)*c + S(2)*d*x) + b)**n, x), x) rule5004 = ReplacementRule(pattern5004, replacement5004) pattern5005 = Pattern(Integral((x_*WC('f', S(1)) + WC('e', S(0)))**WC('m', S(1))*sin((c_ + x_*WC('d', S(1)))**n_*WC('b', S(1)) + WC('a', S(0)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons4, cons62, cons13) def replacement5005(p, m, f, b, d, a, c, n, x, e): rubi.append(5005) return Dist(d**(-m + S(-1)), Subst(Int((-c*f + d*e + f*x)**m*sin(a + b*x**n)**p, x), x, c + d*x), x) rule5005 = ReplacementRule(pattern5005, replacement5005) pattern5006 = Pattern(Integral((x_*WC('f', S(1)) + WC('e', S(0)))**WC('m', S(1))*cos((c_ + x_*WC('d', S(1)))**n_*WC('b', S(1)) + WC('a', S(0)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons4, cons62, cons13) def replacement5006(p, m, f, b, d, a, c, n, x, e): rubi.append(5006) return Dist(d**(-m + S(-1)), Subst(Int((-c*f + d*e + f*x)**m*cos(a + b*x**n)**p, x), x, c + d*x), x) rule5006 = ReplacementRule(pattern5006, replacement5006) pattern5007 = Pattern(Integral((x_*WC('g', S(1)) + WC('f', S(0)))**WC('m', S(1))/(WC('a', S(0)) + WC('b', S(1))*cos(x_*WC('e', S(1)) + WC('d', S(0)))**S(2) + WC('c', S(1))*sin(x_*WC('e', S(1)) + WC('d', S(0)))**S(2)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons62, cons1478, cons1730) def replacement5007(m, f, g, b, d, a, c, x, e): rubi.append(5007) return Dist(S(2), Int((f + g*x)**m/(S(2)*a + b + c + (b - c)*cos(S(2)*d + S(2)*e*x)), x), x) rule5007 = ReplacementRule(pattern5007, replacement5007) pattern5008 = Pattern(Integral((x_*WC('g', S(1)) + WC('f', S(0)))**WC('m', S(1))/((b_ + WC('c', S(1))*tan(x_*WC('e', S(1)) + WC('d', S(0)))**S(2))*cos(x_*WC('e', S(1)) + WC('d', S(0)))**S(2)), x_), cons3, cons7, cons27, cons48, cons125, cons208, cons62) def replacement5008(m, f, g, b, d, c, x, e): rubi.append(5008) return Dist(S(2), Int((f + g*x)**m/(b + c + (b - c)*cos(S(2)*d + S(2)*e*x)), x), x) rule5008 = ReplacementRule(pattern5008, replacement5008) pattern5009 = Pattern(Integral((x_*WC('g', S(1)) + WC('f', S(0)))**WC('m', S(1))/((WC('a', S(1))/cos(x_*WC('e', S(1)) + WC('d', S(0)))**S(2) + WC('b', S(0)) + WC('c', S(1))*tan(x_*WC('e', S(1)) + WC('d', S(0)))**S(2))*cos(x_*WC('e', S(1)) + WC('d', S(0)))**S(2)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons62, cons1478, cons1730) def replacement5009(m, f, g, b, d, a, c, x, e): rubi.append(5009) return Dist(S(2), Int((f + g*x)**m/(S(2)*a + b + c + (b - c)*cos(S(2)*d + S(2)*e*x)), x), x) rule5009 = ReplacementRule(pattern5009, replacement5009) pattern5010 = Pattern(Integral((x_*WC('g', S(1)) + WC('f', S(0)))**WC('m', S(1))/((c_ + WC('b', S(1))/tan(x_*WC('e', S(1)) + WC('d', S(0)))**S(2))*sin(x_*WC('e', S(1)) + WC('d', S(0)))**S(2)), x_), cons3, cons7, cons27, cons48, cons125, cons208, cons62) def replacement5010(m, f, b, g, d, c, x, e): rubi.append(5010) return Dist(S(2), Int((f + g*x)**m/(b + c + (b - c)*cos(S(2)*d + S(2)*e*x)), x), x) rule5010 = ReplacementRule(pattern5010, replacement5010) pattern5011 = Pattern(Integral((x_*WC('g', S(1)) + WC('f', S(0)))**WC('m', S(1))/((WC('a', S(1))/sin(x_*WC('e', S(1)) + WC('d', S(0)))**S(2) + WC('b', S(1))/tan(x_*WC('e', S(1)) + WC('d', S(0)))**S(2) + WC('c', S(0)))*sin(x_*WC('e', S(1)) + WC('d', S(0)))**S(2)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons62, cons1478, cons1730) def replacement5011(m, f, b, g, d, c, a, x, e): rubi.append(5011) return Dist(S(2), Int((f + g*x)**m/(S(2)*a + b + c + (b - c)*cos(S(2)*d + S(2)*e*x)), x), x) rule5011 = ReplacementRule(pattern5011, replacement5011) pattern5012 = Pattern(Integral((x_*WC('f', S(1)) + WC('e', S(0)))**WC('m', S(1))*cos(x_*WC('d', S(1)) + WC('c', S(0)))/(a_ + WC('b', S(1))*sin(x_*WC('d', S(1)) + WC('c', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons62, cons1731) def replacement5012(m, f, b, d, c, a, x, e): rubi.append(5012) return Int((e + f*x)**m*exp(I*(c + d*x))/(a - I*b*exp(I*(c + d*x)) - Rt(a**S(2) - b**S(2), S(2))), x) + Int((e + f*x)**m*exp(I*(c + d*x))/(a - I*b*exp(I*(c + d*x)) + Rt(a**S(2) - b**S(2), S(2))), x) - Simp(I*(e + f*x)**(m + S(1))/(b*f*(m + S(1))), x) rule5012 = ReplacementRule(pattern5012, replacement5012) pattern5013 = Pattern(Integral((x_*WC('f', S(1)) + WC('e', S(0)))**WC('m', S(1))*sin(x_*WC('d', S(1)) + WC('c', S(0)))/(a_ + WC('b', S(1))*cos(x_*WC('d', S(1)) + WC('c', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons62, cons1731) def replacement5013(m, f, b, d, c, a, x, e): rubi.append(5013) return -Dist(I, Int((e + f*x)**m*exp(I*(c + d*x))/(a + b*exp(I*(c + d*x)) - Rt(a**S(2) - b**S(2), S(2))), x), x) - Dist(I, Int((e + f*x)**m*exp(I*(c + d*x))/(a + b*exp(I*(c + d*x)) + Rt(a**S(2) - b**S(2), S(2))), x), x) + Simp(I*(e + f*x)**(m + S(1))/(b*f*(m + S(1))), x) rule5013 = ReplacementRule(pattern5013, replacement5013) pattern5014 = Pattern(Integral((x_*WC('f', S(1)) + WC('e', S(0)))**WC('m', S(1))*cos(x_*WC('d', S(1)) + WC('c', S(0)))/(a_ + WC('b', S(1))*sin(x_*WC('d', S(1)) + WC('c', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons62, cons1732) def replacement5014(m, f, b, d, c, a, x, e): rubi.append(5014) return Dist(I, Int((e + f*x)**m*exp(I*(c + d*x))/(I*a + b*exp(I*(c + d*x)) - Rt(-a**S(2) + b**S(2), S(2))), x), x) + Dist(I, Int((e + f*x)**m*exp(I*(c + d*x))/(I*a + b*exp(I*(c + d*x)) + Rt(-a**S(2) + b**S(2), S(2))), x), x) - Simp(I*(e + f*x)**(m + S(1))/(b*f*(m + S(1))), x) rule5014 = ReplacementRule(pattern5014, replacement5014) pattern5015 = Pattern(Integral((x_*WC('f', S(1)) + WC('e', S(0)))**WC('m', S(1))*sin(x_*WC('d', S(1)) + WC('c', S(0)))/(a_ + WC('b', S(1))*cos(x_*WC('d', S(1)) + WC('c', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons62, cons1732) def replacement5015(m, f, b, d, c, a, x, e): rubi.append(5015) return Int((e + f*x)**m*exp(I*(c + d*x))/(I*a + I*b*exp(I*(c + d*x)) - Rt(-a**S(2) + b**S(2), S(2))), x) + Int((e + f*x)**m*exp(I*(c + d*x))/(I*a + I*b*exp(I*(c + d*x)) + Rt(-a**S(2) + b**S(2), S(2))), x) + Simp(I*(e + f*x)**(m + S(1))/(b*f*(m + S(1))), x) rule5015 = ReplacementRule(pattern5015, replacement5015) pattern5016 = Pattern(Integral((x_*WC('f', S(1)) + WC('e', S(0)))**WC('m', S(1))*cos(x_*WC('d', S(1)) + WC('c', S(0)))**n_/(a_ + WC('b', S(1))*sin(x_*WC('d', S(1)) + WC('c', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons62, cons85, cons165, cons1265) def replacement5016(m, f, b, d, c, n, a, x, e): rubi.append(5016) return Dist(S(1)/a, Int((e + f*x)**m*cos(c + d*x)**(n + S(-2)), x), x) - Dist(S(1)/b, Int((e + f*x)**m*sin(c + d*x)*cos(c + d*x)**(n + S(-2)), x), x) rule5016 = ReplacementRule(pattern5016, replacement5016) pattern5017 = Pattern(Integral((x_*WC('f', S(1)) + WC('e', S(0)))**WC('m', S(1))*sin(x_*WC('d', S(1)) + WC('c', S(0)))**n_/(a_ + WC('b', S(1))*cos(x_*WC('d', S(1)) + WC('c', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons62, cons85, cons165, cons1265) def replacement5017(m, f, b, d, c, a, n, x, e): rubi.append(5017) return Dist(S(1)/a, Int((e + f*x)**m*sin(c + d*x)**(n + S(-2)), x), x) - Dist(S(1)/b, Int((e + f*x)**m*sin(c + d*x)**(n + S(-2))*cos(c + d*x), x), x) rule5017 = ReplacementRule(pattern5017, replacement5017) pattern5018 = Pattern(Integral((x_*WC('f', S(1)) + WC('e', S(0)))**WC('m', S(1))*cos(x_*WC('d', S(1)) + WC('c', S(0)))**n_/(a_ + WC('b', S(1))*sin(x_*WC('d', S(1)) + WC('c', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons62, cons85, cons165, cons1267) def replacement5018(m, f, b, d, c, n, a, x, e): rubi.append(5018) return -Dist(S(1)/b, Int((e + f*x)**m*sin(c + d*x)*cos(c + d*x)**(n + S(-2)), x), x) + Dist(a/b**S(2), Int((e + f*x)**m*cos(c + d*x)**(n + S(-2)), x), x) - Dist((a**S(2) - b**S(2))/b**S(2), Int((e + f*x)**m*cos(c + d*x)**(n + S(-2))/(a + b*sin(c + d*x)), x), x) rule5018 = ReplacementRule(pattern5018, replacement5018) pattern5019 = Pattern(Integral((x_*WC('f', S(1)) + WC('e', S(0)))**WC('m', S(1))*sin(x_*WC('d', S(1)) + WC('c', S(0)))**n_/(a_ + WC('b', S(1))*cos(x_*WC('d', S(1)) + WC('c', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons62, cons85, cons165, cons1267) def replacement5019(m, f, b, d, c, a, n, x, e): rubi.append(5019) return -Dist(S(1)/b, Int((e + f*x)**m*sin(c + d*x)**(n + S(-2))*cos(c + d*x), x), x) + Dist(a/b**S(2), Int((e + f*x)**m*sin(c + d*x)**(n + S(-2)), x), x) - Dist((a**S(2) - b**S(2))/b**S(2), Int((e + f*x)**m*sin(c + d*x)**(n + S(-2))/(a + b*cos(c + d*x)), x), x) rule5019 = ReplacementRule(pattern5019, replacement5019) pattern5020 = Pattern(Integral((A_ + WC('B', S(1))*sin(x_*WC('d', S(1)) + WC('c', S(0))))*(x_*WC('f', S(1)) + WC('e', S(0)))/(a_ + WC('b', S(1))*sin(x_*WC('d', S(1)) + WC('c', S(0))))**S(2), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons1474) def replacement5020(B, f, b, d, c, a, A, x, e): rubi.append(5020) return Dist(B*f/(a*d), Int(cos(c + d*x)/(a + b*sin(c + d*x)), x), x) - Simp(B*(e + f*x)*cos(c + d*x)/(a*d*(a + b*sin(c + d*x))), x) rule5020 = ReplacementRule(pattern5020, replacement5020) pattern5021 = Pattern(Integral((A_ + WC('B', S(1))*cos(x_*WC('d', S(1)) + WC('c', S(0))))*(x_*WC('f', S(1)) + WC('e', S(0)))/(a_ + WC('b', S(1))*cos(x_*WC('d', S(1)) + WC('c', S(0))))**S(2), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons1474) def replacement5021(B, f, b, d, c, a, A, x, e): rubi.append(5021) return -Dist(B*f/(a*d), Int(sin(c + d*x)/(a + b*cos(c + d*x)), x), x) + Simp(B*(e + f*x)*sin(c + d*x)/(a*d*(a + b*cos(c + d*x))), x) rule5021 = ReplacementRule(pattern5021, replacement5021) pattern5022 = Pattern(Integral((a_ + WC('b', S(1))*tan(v_))**WC('n', S(1))*(S(1)/cos(v_))**WC('m', S(1)), x_), cons2, cons3, cons150, cons1551, cons1481) def replacement5022(v, m, b, a, n, x): rubi.append(5022) return Int((a*cos(v) + b*sin(v))**n, x) rule5022 = ReplacementRule(pattern5022, replacement5022) pattern5023 = Pattern(Integral((a_ + WC('b', S(1))/tan(v_))**WC('n', S(1))*(S(1)/sin(v_))**WC('m', S(1)), x_), cons2, cons3, cons150, cons1551, cons1481) def replacement5023(v, m, b, a, n, x): rubi.append(5023) return Int((a*sin(v) + b*cos(v))**n, x) rule5023 = ReplacementRule(pattern5023, replacement5023) pattern5024 = Pattern(Integral(WC('u', S(1))*sin(x_*WC('b', S(1)) + WC('a', S(0)))**WC('m', S(1))*sin(x_*WC('d', S(1)) + WC('c', S(0)))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons528) def replacement5024(u, m, b, d, a, c, n, x): rubi.append(5024) return Int(ExpandTrigReduce(u, sin(a + b*x)**m*sin(c + d*x)**n, x), x) rule5024 = ReplacementRule(pattern5024, replacement5024) pattern5025 = Pattern(Integral(WC('u', S(1))*cos(x_*WC('b', S(1)) + WC('a', S(0)))**WC('m', S(1))*cos(x_*WC('d', S(1)) + WC('c', S(0)))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons528) def replacement5025(u, m, b, d, a, c, n, x): rubi.append(5025) return Int(ExpandTrigReduce(u, cos(a + b*x)**m*cos(c + d*x)**n, x), x) rule5025 = ReplacementRule(pattern5025, replacement5025) pattern5026 = Pattern(Integral(S(1)/(cos(c_ + x_*WC('d', S(1)))*cos(x_*WC('b', S(1)) + WC('a', S(0)))), x_), cons2, cons3, cons7, cons27, cons1733, cons71) def replacement5026(b, d, c, a, x): rubi.append(5026) return Dist(S(1)/sin((-a*d + b*c)/b), Int(tan(c + d*x), x), x) - Dist(S(1)/sin((-a*d + b*c)/d), Int(tan(a + b*x), x), x) rule5026 = ReplacementRule(pattern5026, replacement5026) pattern5027 = Pattern(Integral(S(1)/(sin(c_ + x_*WC('d', S(1)))*sin(x_*WC('b', S(1)) + WC('a', S(0)))), x_), cons2, cons3, cons7, cons27, cons1733, cons71) def replacement5027(b, d, c, a, x): rubi.append(5027) return Dist(S(1)/sin((-a*d + b*c)/b), Int(S(1)/tan(a + b*x), x), x) - Dist(S(1)/sin((-a*d + b*c)/d), Int(S(1)/tan(c + d*x), x), x) rule5027 = ReplacementRule(pattern5027, replacement5027) pattern5028 = Pattern(Integral(tan(c_ + x_*WC('d', S(1)))*tan(x_*WC('b', S(1)) + WC('a', S(0))), x_), cons2, cons3, cons7, cons27, cons1733, cons71) def replacement5028(b, d, c, a, x): rubi.append(5028) return Dist(b*cos((-a*d + b*c)/d)/d, Int(S(1)/(cos(a + b*x)*cos(c + d*x)), x), x) - Simp(b*x/d, x) rule5028 = ReplacementRule(pattern5028, replacement5028) pattern5029 = Pattern(Integral(S(1)/(tan(c_ + x_*WC('d', S(1)))*tan(x_*WC('b', S(1)) + WC('a', S(0)))), x_), cons2, cons3, cons7, cons27, cons1733, cons71) def replacement5029(b, d, c, a, x): rubi.append(5029) return Dist(cos((-a*d + b*c)/d), Int(S(1)/(sin(a + b*x)*sin(c + d*x)), x), x) - Simp(b*x/d, x) rule5029 = ReplacementRule(pattern5029, replacement5029) pattern5030 = Pattern(Integral((WC('a', S(1))*cos(v_) + WC('b', S(1))*sin(v_))**WC('n', S(1))*WC('u', S(1)), x_), cons2, cons3, cons4, cons1439) def replacement5030(v, u, b, a, n, x): rubi.append(5030) return Int(u*(a*exp(-a*v/b))**n, x) rule5030 = ReplacementRule(pattern5030, replacement5030) return [rule4685, rule4686, rule4687, rule4688, rule4689, rule4690, rule4691, rule4692, rule4693, rule4694, rule4695, rule4696, rule4697, rule4698, rule4699, rule4700, rule4701, rule4702, rule4703, rule4704, rule4705, rule4706, rule4707, rule4708, rule4709, rule4710, rule4711, rule4712, rule4713, rule4714, rule4715, rule4716, rule4717, rule4718, rule4719, rule4720, rule4721, rule4722, rule4723, rule4724, rule4725, rule4726, rule4727, rule4728, rule4729, rule4730, rule4731, rule4732, rule4733, rule4734, rule4735, rule4736, rule4737, rule4738, rule4739, rule4740, rule4741, rule4742, rule4743, rule4744, rule4745, rule4746, rule4747, rule4748, rule4749, rule4750, rule4751, rule4752, rule4753, rule4754, rule4755, rule4756, rule4757, rule4758, rule4759, rule4760, rule4761, rule4762, rule4763, rule4764, rule4765, rule4766, rule4767, rule4768, rule4769, rule4770, rule4771, rule4772, rule4773, rule4774, rule4775, rule4776, rule4777, rule4778, rule4779, rule4780, rule4781, rule4782, rule4783, rule4784, rule4785, rule4786, rule4787, rule4788, rule4789, rule4790, rule4791, rule4792, rule4793, rule4794, rule4795, rule4796, rule4797, rule4798, rule4799, rule4800, rule4801, rule4802, rule4803, rule4804, rule4805, rule4806, rule4807, rule4808, rule4809, rule4810, rule4811, rule4812, rule4813, rule4814, rule4815, rule4816, rule4817, rule4818, rule4819, rule4820, rule4821, rule4822, rule4823, rule4824, rule4825, rule4826, rule4827, rule4828, rule4829, rule4830, rule4831, rule4832, rule4833, rule4834, rule4835, rule4836, rule4837, rule4838, rule4839, rule4840, rule4841, rule4842, rule4843, rule4844, rule4845, rule4846, rule4847, rule4848, rule4849, rule4850, rule4851, rule4852, rule4853, rule4854, rule4855, rule4856, rule4857, rule4858, rule4859, rule4860, rule4861, rule4862, rule4863, rule4864, rule4865, rule4866, rule4867, rule4868, rule4869, rule4870, rule4871, rule4872, rule4873, rule4874, rule4875, rule4876, rule4877, rule4878, rule4879, rule4880, rule4881, rule4882, rule4883, rule4884, rule4885, rule4886, rule4887, rule4888, rule4889, rule4890, rule4891, rule4892, rule4893, rule4894, rule4895, rule4896, rule4897, rule4898, rule4899, rule4900, rule4901, rule4902, rule4903, rule4904, rule4905, rule4906, rule4907, rule4908, rule4909, rule4910, rule4911, rule4912, rule4913, rule4914, rule4915, rule4916, rule4917, rule4918, rule4919, rule4920, rule4921, rule4922, rule4923, rule4924, rule4925, rule4926, rule4927, rule4928, rule4929, rule4930, rule4931, rule4932, rule4933, rule4934, rule4935, rule4936, rule4937, rule4938, rule4939, rule4940, rule4941, rule4942, rule4943, rule4944, rule4945, rule4946, rule4947, rule4948, rule4949, rule4950, rule4951, rule4952, rule4953, rule4954, rule4955, rule4956, rule4957, rule4958, rule4959, rule4960, rule4961, rule4962, rule4963, rule4964, rule4965, rule4966, rule4967, rule4968, rule4969, rule4970, rule4971, rule4972, rule4973, rule4974, rule4975, rule4976, rule4977, rule4978, rule4979, rule4980, rule4981, rule4982, rule4983, rule4984, rule4985, rule4986, rule4987, rule4988, rule4989, rule4990, rule4991, rule4992, rule4993, rule4994, rule4995, rule4996, rule4997, rule4998, rule4999, rule5000, rule5001, rule5002, rule5003, rule5004, rule5005, rule5006, rule5007, rule5008, rule5009, rule5010, rule5011, rule5012, rule5013, rule5014, rule5015, rule5016, rule5017, rule5018, rule5019, rule5020, rule5021, rule5022, rule5023, rule5024, rule5025, rule5026, rule5027, rule5028, rule5029, rule5030, ]
cbf55f21a849209c3eaef41ecb66f7eacd9040ad30995ebed0599b7d2700b634
''' Parser for FullForm[Downvalues[]] of Mathematica rules. This parser is customised to parse the output in MatchPy rules format. Multiple `Constraints` are divided into individual `Constraints` because it helps the MatchPy's `ManyToOneReplacer` to backtrack earlier and improve the speed. Parsed output is formatted into readable format by using `sympify` and print the expression using `sstr`. This replaces `And`, `Mul`, 'Pow' by their respective symbols. Mathematica =========== To get the full form from Wolfram Mathematica, type: ``` ShowSteps = False Import["RubiLoader.m"] Export["output.txt", ToString@FullForm@DownValues@Int] ``` The file ``output.txt`` will then contain the rules in parseable format. References ========== [1] http://reference.wolfram.com/language/ref/FullForm.html [2] http://reference.wolfram.com/language/ref/DownValues.html [3] https://gist.github.com/Upabjojr/bc07c49262944f9c1eb0 ''' import re import os import inspect from sympy import sympify, Function, Set, Symbol from sympy.core.compatibility import string_types from sympy.printing import StrPrinter from sympy.utilities.misc import debug class RubiStrPrinter(StrPrinter): def _print_Not(self, expr): return "Not(%s)" % self._print(expr.args[0]) def rubi_printer(expr, **settings): return RubiStrPrinter(settings).doprint(expr) replacements = dict( # Mathematica equivalent functions in SymPy Times="Mul", Plus="Add", Power="Pow", Log='log', Exp='exp', Sqrt='sqrt', Cos='cos', Sin='sin', Tan='tan', Cot='1/tan', cot='1/tan', Sec='1/cos', sec='1/cos', Csc='1/sin', csc='1/sin', ArcSin='asin', ArcCos='acos', # ArcTan='atan', ArcCot='acot', ArcSec='asec', ArcCsc='acsc', Sinh='sinh', Cosh='cosh', Tanh='tanh', Coth='1/tanh', coth='1/tanh', Sech='1/cosh', sech='1/cosh', Csch='1/sinh', csch='1/sinh', ArcSinh='asinh', ArcCosh='acosh', ArcTanh='atanh', ArcCoth='acoth', ArcSech='asech', ArcCsch='acsch', Expand='expand', Im='im', Re='re', Flatten='flatten', Polylog='polylog', Cancel='cancel', #Gamma='gamma', TrigExpand='expand_trig', Sign='sign', Simplify='simplify', Defer='UnevaluatedExpr', Identity = 'S', Sum = 'Sum_doit', Module = 'With', Block = 'With', Null = 'None' ) temporary_variable_replacement = { # Temporarily rename because it can raise errors while sympifying 'gcd' : "_gcd", 'jn' : "_jn", } permanent_variable_replacement = { # Permamenely rename these variables r"\[ImaginaryI]" : 'ImaginaryI', "$UseGamma": '_UseGamma', } #these functions have different return type in different cases. So better to use a try and except in the constraints, when any of these appear f_diff_return_type = ['BinomialParts', 'BinomialDegree', 'TrinomialParts', 'GeneralizedBinomialParts', 'GeneralizedTrinomialParts', 'PseudoBinomialParts', 'PerfectPowerTest', 'SquareFreeFactorTest', 'SubstForFractionalPowerOfQuotientOfLinears', 'FractionalPowerOfQuotientOfLinears', 'InverseFunctionOfQuotientOfLinears', 'FractionalPowerOfSquareQ', 'FunctionOfLinear', 'FunctionOfInverseLinear', 'FunctionOfTrig', 'FindTrigFactor', 'FunctionOfLog', 'PowerVariableExpn', 'FunctionOfSquareRootOfQuadratic', 'SubstForFractionalPowerOfLinear', 'FractionalPowerOfLinear', 'InverseFunctionOfLinear', 'Divides', 'DerivativeDivides', 'TrigSquare', 'SplitProduct', 'SubstForFractionalPowerOfQuotientOfLinears', 'InverseFunctionOfQuotientOfLinears', 'FunctionOfHyperbolic', 'SplitSum'] def contains_diff_return_type(a): ''' This function returns whether an expression contains functions which have different return types in diiferent cases. ''' if isinstance(a, list): for i in a: if contains_diff_return_type(i): return True elif type(a) == Function('With') or type(a) == Function('Module'): for i in f_diff_return_type: if a.has(Function(i)): return True else: if a in f_diff_return_type: return True return False def parse_full_form(wmexpr): ''' Parses FullForm[Downvalues[]] generated by Mathematica ''' out = [] stack = [out] generator = re.finditer(r'[\[\],]', wmexpr) last_pos = 0 for match in generator: if match is None: break position = match.start() last_expr = wmexpr[last_pos:position].replace(',', '').replace(']', '').replace('[', '').strip() if match.group() == ',': if last_expr != '': stack[-1].append(last_expr) elif match.group() == ']': if last_expr != '': stack[-1].append(last_expr) stack.pop() current_pos = stack[-1] elif match.group() == '[': stack[-1].append([last_expr]) stack.append(stack[-1][-1]) last_pos = match.end() return out[0] def get_default_values(parsed, default_values={}): ''' Returns Optional variables and their values in the pattern ''' if not isinstance(parsed, list): return default_values if parsed[0] == "Times": # find Default arguments for "Times" for i in parsed[1:]: if i[0] == "Optional": default_values[(i[1][1])] = 1 if parsed[0] == "Plus": # find Default arguments for "Plus" for i in parsed[1:]: if i[0] == "Optional": default_values[(i[1][1])] = 0 if parsed[0] == "Power": # find Default arguments for "Power" for i in parsed[1:]: if i[0] == "Optional": default_values[(i[1][1])] = 1 if len(parsed) == 1: return default_values for i in parsed: default_values = get_default_values(i, default_values) return default_values def add_wildcards(string, optional={}): ''' Replaces `Pattern(variable)` by `variable` in `string`. Returns the free symbols present in the string. ''' symbols = [] # stores symbols present in the expression p = r'(Optional\(Pattern\((\w+), Blank\)\))' matches = re.findall(p, string) for i in matches: string = string.replace(i[0], "WC('{}', S({}))".format(i[1], optional[i[1]])) symbols.append(i[1]) p = r'(Pattern\((\w+), Blank\))' matches = re.findall(p, string) for i in matches: string = string.replace(i[0], i[1] + '_') symbols.append(i[1]) p = r'(Pattern\((\w+), Blank\(Symbol\)\))' matches = re.findall(p, string) for i in matches: string = string.replace(i[0], i[1] + '_') symbols.append(i[1]) return string, symbols def seperate_freeq(s, variables=[], x=None): ''' Returns list of symbols in FreeQ. ''' if s[0] == 'FreeQ': if len(s[1]) == 1: variables = [s[1]] else: variables = s[1][1:] x = s[2] else: for i in s[1:]: variables, x = seperate_freeq(i, variables, x) return variables, x return variables, x def parse_freeq(l, x, cons_index, cons_dict, cons_import, symbols=None): ''' Converts FreeQ constraints into MatchPy constraint ''' res = [] cons = '' for i in l: if isinstance(i, string_types): r = ' return FreeQ({}, {})'.format(i, x) # First it checks if a constraint is already present in `cons_dict`, If yes, use it else create a new one. if r not in cons_dict.values(): cons_index += 1 c = '\n def cons_f{}({}, {}):\n'.format(cons_index, i, x) c += r c += '\n\n cons{} = CustomConstraint({})\n'.format(cons_index, 'cons_f{}'.format(cons_index)) cons_name = 'cons{}'.format(cons_index) cons_dict[cons_name] = r else: c = '' cons_name = next(key for key, value in cons_dict.items() if value == r) elif isinstance(i, list): s = list(set(get_free_symbols(i, symbols))) s = ', '.join(s) r = ' return FreeQ({}, {})'.format(generate_sympy_from_parsed(i), x) if r not in cons_dict.values(): cons_index += 1 c = '\n def cons_f{}({}):\n'.format(cons_index, s) c += r c += '\n\n cons{} = CustomConstraint({})\n'.format(cons_index, 'cons_f{}'.format(cons_index)) cons_name = 'cons{}'.format(cons_index) cons_dict[cons_name] = r else: c = '' cons_name = next(key for key, value in cons_dict.items() if value == r) if cons_name not in cons_import: cons_import.append(cons_name) res.append(cons_name) cons += c if res != []: return ', ' + ', '.join(res), cons, cons_index return '', cons, cons_index def generate_sympy_from_parsed(parsed, wild=False, symbols=[], replace_Int=False): ''' Parses list into Python syntax. Parameters ========== wild : When set to True, the symbols are replaced as wild symbols. symbols : Symbols already present in the pattern. replace_Int: when set to True, `Int` is replaced by `Integral`(used to parse pattern). ''' out = "" if not isinstance(parsed, list): try: #return S(number) if parsed is Number float(parsed) return "S({})".format(parsed) except: pass if parsed in symbols: if wild: return parsed + '_' return parsed if parsed[0] == 'Rational': return 'S({})/S({})'.format(generate_sympy_from_parsed(parsed[1], wild=wild, symbols=symbols, replace_Int=replace_Int), generate_sympy_from_parsed(parsed[2], wild=wild, symbols=symbols, replace_Int=replace_Int)) if parsed[0] in replacements: out += replacements[parsed[0]] elif parsed[0] == 'Int' and replace_Int: out += 'Integral' else: out += parsed[0] if len(parsed) == 1: return out result = [generate_sympy_from_parsed(i, wild=wild, symbols=symbols, replace_Int=replace_Int) for i in parsed[1:]] if '' in result: result.remove('') out += "(" out += ", ".join(result) out += ")" return out def get_free_symbols(s, symbols, free_symbols=None): ''' Returns free_symbols present in `s`. ''' free_symbols = free_symbols or [] if not isinstance(s, list): if s in symbols: free_symbols.append(s) return free_symbols for i in s: free_symbols = get_free_symbols(i, symbols, free_symbols) return free_symbols def set_matchq_in_constraint(a, cons_index): ''' Takes care of the case, when a pattern matching has to be done inside a constraint. ''' lst = [] res = '' if isinstance(a, list): if a[0] == 'MatchQ': s = a optional = get_default_values(s, {}) r = generate_sympy_from_parsed(s, replace_Int=True) r, free_symbols = add_wildcards(r, optional=optional) free_symbols = list(set(free_symbols)) #remove common symbols r = sympify(r, locals={"Or": Function("Or"), "And": Function("And"), "Not":Function("Not")}) pattern = r.args[1].args[0] cons = r.args[1].args[1] pattern = rubi_printer(pattern, sympy_integers=True) pattern = setWC(pattern) res = ' def _cons_f_{}({}):\n return {}\n'.format(cons_index, ', '.join(free_symbols), cons) res += ' _cons_{} = CustomConstraint(_cons_f_{})\n'.format(cons_index, cons_index) res += ' pat = Pattern(UtilityOperator({}, x), _cons_{})\n'.format(pattern, cons_index) res += ' result_matchq = is_match(UtilityOperator({}, x), pat)'.format(r.args[0]) return "result_matchq", res else: for i in a: if isinstance(i, list): r = set_matchq_in_constraint(i, cons_index) lst.append(r[0]) res = r[1] else: lst.append(i) return (lst, res) def _divide_constriant(s, symbols, cons_index, cons_dict, cons_import): # Creates a CustomConstraint of the form `CustomConstraint(lambda a, x: FreeQ(a, x))` lambda_symbols = list(set(get_free_symbols(s, symbols, []))) r = generate_sympy_from_parsed(s) r = sympify(r, locals={"Or": Function("Or"), "And": Function("And"), "Not":Function("Not")}) if r.has(Function('MatchQ')): match_res = set_matchq_in_constraint(s, cons_index) res = match_res[1] res += '\n return {}'.format(rubi_printer(sympify(generate_sympy_from_parsed(match_res[0]), locals={"Or": Function("Or"), "And": Function("And"), "Not":Function("Not")}), sympy_integers = True)) elif contains_diff_return_type(s): res = ' try:\n return {}\n except (TypeError, AttributeError):\n return False'.format(rubi_printer(r, sympy_integers=True)) else: res = ' return {}'.format(rubi_printer(r, sympy_integers=True)) # First it checks if a constraint is already present in `cons_dict`, If yes, use it else create a new one. if not res in cons_dict.values(): cons_index += 1 cons = '\n def cons_f{}({}):\n'.format(cons_index, ', '.join(lambda_symbols)) if 'x' in lambda_symbols: cons += ' if isinstance(x, (int, Integer, float, Float)):\n return False\n' cons += res cons += '\n\n cons{} = CustomConstraint({})\n'.format(cons_index, 'cons_f{}'.format(cons_index)) cons_name = 'cons{}'.format(cons_index) cons_dict[cons_name] = res else: cons = '' cons_name = next(key for key, value in cons_dict.items() if value == res) if cons_name not in cons_import: cons_import.append(cons_name) return (cons_name, cons, cons_index) def divide_constraint(s, symbols, cons_index, cons_dict, cons_import): ''' Divides multiple constraints into smaller constraints. Parameters ========== s : constraint as list symbols : all the symbols present in the expression ''' result =[] cons = '' if s[0] == 'And': for i in s[1:]: if i[0]!= 'FreeQ': a = _divide_constriant(i, symbols, cons_index, cons_dict, cons_import) result.append(a[0]) cons += a[1] cons_index = a[2] else: a = _divide_constriant(s, symbols, cons_index, cons_dict, cons_import) result.append(a[0]) cons += a[1] cons_index = a[2] r = [''] for i in result: if i != '': r.append(i) return ', '.join(r),cons, cons_index def setWC(string): ''' Replaces `WC(a, b)` by `WC('a', S(b))` ''' p = r'(WC\((\w+), S\(([-+]?\d)\)\))' matches = re.findall(p, string) for i in matches: string = string.replace(i[0], "WC('{}', S({}))".format(i[1], i[2])) return string def process_return_type(a1, L): ''' Functions like `Set`, `With` and `CompoundExpression` has to be taken special care. ''' a = sympify(a1[1]) x ='' processed = False return_value = '' if type(a) == Function('With') or type(a) == Function('Module'): for i in a.args: for s in i.args: if isinstance(s, Set) and not s in L: x += '\n {} = {}'.format(s.args[0], rubi_printer(s.args[1], sympy_integers=True)) if not type(i) in (Function('List'), Function('CompoundExpression')) and not i.has(Function('CompoundExpression')): return_value = i processed = True elif type(i) ==Function('CompoundExpression'): return_value = i.args[-1] processed = True elif type(i.args[0]) == Function('CompoundExpression'): C = i.args[0] return_value = '{}({}, {})'.format(i.func, C.args[-1], i.args[1]) processed = True return x, return_value, processed def extract_set(s, L): ''' this function extracts all `Set` functions ''' lst = [] if isinstance(s, Set) and not s in L: lst.append(s) else: try: for i in s.args: lst += extract_set(i, L) except: #when s has no attribute args (like `bool`) pass return lst def replaceWith(s, symbols, index): ''' Replaces `With` and `Module by python functions` ''' return_type = None with_value = '' if type(s) == Function('With') or type(s) == Function('Module'): constraints = ' ' result = ' def With{}({}):'.format(index, ', '.join(symbols)) if type(s.args[0]) == Function('List'): # get all local variables of With and Module L = list(s.args[0].args) else: L = [s.args[0]] lst = [] for i in s.args[1:]: lst+=extract_set(i, L) L+=lst for i in L: # define local variables if isinstance(i, Set): with_value += '\n {} = {}'.format(i.args[0], rubi_printer(i.args[1], sympy_integers=True)) elif isinstance(i, Symbol): with_value += "\n {} = Symbol('{}')".format(i, i) #result += with_value if type(s.args[1]) == Function('CompoundExpression'): # Expand CompoundExpression C = s.args[1] result += with_value if isinstance(C.args[0], Set): result += '\n {} = {}'.format(C.args[0].args[0], C.args[0].args[1]) result += '\n rubi.append({})\n return {}'.format(index, rubi_printer(C.args[1], sympy_integers=True)) return result, constraints, return_type elif type(s.args[1]) == Function('Condition'): C = s.args[1] if len(C.args) == 2: if all(j in symbols for j in [str(i) for i in C.free_symbols]): result += with_value #constraints += 'CustomConstraint(lambda {}: {})'.format(', '.join([str(i) for i in C.free_symbols]), sstr(C.args[1], sympy_integers=True)) result += '\n rubi.append({})\n return {}'.format(index, rubi_printer(C.args[0], sympy_integers=True)) else: if 'x' in symbols: result += '\n if isinstance(x, (int, Integer, float, Float)):\n return False' if contains_diff_return_type(s): n_with_value = with_value.replace('\n', '\n ') result += '\n try:{}\n res = {}'.format(n_with_value, rubi_printer(C.args[1], sympy_integers=True)) result += '\n except (TypeError, AttributeError):\n return False' result += '\n if res:' else: result+=with_value result += '\n if {}:'.format(rubi_printer(C.args[1], sympy_integers=True)) return_type = (with_value, rubi_printer(C.args[0], sympy_integers=True)) return_type1 = process_return_type(return_type, L) if return_type1[2]: return_type = ( with_value+return_type1[0], rubi_printer(return_type1[1])) result += '\n return True' result += '\n return False' constraints = ', CustomConstraint(With{})'.format(index) return result, constraints, return_type elif type(s.args[1]) == Function('Module') or type(s.args[1]) == Function('With'): C = s.args[1] result += with_value return_type = (with_value, rubi_printer(C, sympy_integers=True)) return_type1 = process_return_type(return_type, L) if return_type1[2]: return_type = ( with_value+return_type1[0], rubi_printer(return_type1[1])) result+=return_type1[0] result+='\n rubi.append({})\n return {}'.format(index, rubi_printer(return_type1[1])) return result, constraints, None elif s.args[1].has(Function("CompoundExpression")): C = s.args[1].args[0] result += with_value if isinstance(C.args[0], Set): result += '\n {} = {}'.format(C.args[0].args[0], C.args[0].args[1]) result += '\n return {}({}, {})'.format(s.args[1].func, C.args[-1], s.args[1].args[1]) return result, constraints, None result += with_value result += '\n rubi.append({})\n return {}'.format(index, rubi_printer(s.args[1], sympy_integers=True)) return result, constraints, return_type else: return rubi_printer(s, sympy_integers=True), '', return_type def downvalues_rules(r, header, cons_dict, cons_index, index): ''' Function which generates parsed rules by substituting all possible combinations of default values. ''' rules = '[' parsed = '\n\n' cons = '' cons_import = [] # it contains name of constraints that need to be imported for rules. for i in r: debug('parsing rule {}'.format(r.index(i) + 1)) # Parse Pattern if i[1][1][0] == 'Condition': p = i[1][1][1].copy() else: p = i[1][1].copy() optional = get_default_values(p, {}) pattern = generate_sympy_from_parsed(p.copy(), replace_Int=True) pattern, free_symbols = add_wildcards(pattern, optional=optional) free_symbols = list(set(free_symbols)) #remove common symbols # Parse Transformed Expression and Constraints if i[2][0] == 'Condition': # parse rules without constraints separately constriant, constraint_def, cons_index = divide_constraint(i[2][2], free_symbols, cons_index, cons_dict, cons_import) # separate And constraints into individual constraints FreeQ_vars, FreeQ_x = seperate_freeq(i[2][2].copy()) # separate FreeQ into individual constraints transformed = generate_sympy_from_parsed(i[2][1].copy(), symbols=free_symbols) else: constriant = '' constraint_def = '' FreeQ_vars, FreeQ_x = [], [] transformed = generate_sympy_from_parsed(i[2].copy(), symbols=free_symbols) FreeQ_constraint, free_cons_def, cons_index = parse_freeq(FreeQ_vars, FreeQ_x, cons_index, cons_dict, cons_import, free_symbols) pattern = sympify(pattern, locals={"Or": Function("Or"), "And": Function("And"), "Not":Function("Not") }) pattern = rubi_printer(pattern, sympy_integers=True) pattern = setWC(pattern) transformed = sympify(transformed, locals={"Or": Function("Or"), "And": Function("And"), "Not":Function("Not") }) constraint_def = constraint_def + free_cons_def cons+=constraint_def index += 1 # below are certain if - else condition depending on various situation that may be encountered if type(transformed) == Function('With') or type(transformed) == Function('Module'): # define separate function when With appears transformed, With_constraints, return_type = replaceWith(transformed, free_symbols, index) if return_type is None: parsed += '{}'.format(transformed) parsed += '\n pattern' + str(index) +' = Pattern(' + pattern + '' + FreeQ_constraint + '' + constriant + ')' parsed += '\n ' + 'rule' + str(index) +' = ReplacementRule(' + 'pattern' + rubi_printer(index, sympy_integers=True) + ', With{}'.format(index) + ')\n' else: parsed += '{}'.format(transformed) parsed += '\n pattern' + str(index) +' = Pattern(' + pattern + '' + FreeQ_constraint + '' + constriant + With_constraints + ')' parsed += '\n def replacement{}({}):\n'.format(index, ', '.join(free_symbols)) + return_type[0] + '\n rubi.append({})\n return '.format(index) + return_type[1] parsed += '\n ' + 'rule' + str(index) +' = ReplacementRule(' + 'pattern' + rubi_printer(index, sympy_integers=True) + ', replacement{}'.format(index) + ')\n' else: transformed = rubi_printer(transformed, sympy_integers=True) parsed += ' pattern' + str(index) +' = Pattern(' + pattern + '' + FreeQ_constraint + '' + constriant + ')' parsed += '\n def replacement{}({}):\n rubi.append({})\n return '.format(index, ', '.join(free_symbols), index) + transformed parsed += '\n ' + 'rule' + str(index) +' = ReplacementRule(' + 'pattern' + rubi_printer(index, sympy_integers=True) + ', replacement{}'.format(index) + ')\n' rules += 'rule{}, '.format(index) rules += ']' parsed += ' return ' + rules +'\n' header += ' from sympy.integrals.rubi.constraints import ' + ', '.join(word for word in cons_import) parsed = header + parsed return parsed, cons_index, cons, index def rubi_rule_parser(fullform, header=None, module_name='rubi_object'): ''' Parses rules in MatchPy format. Parameters ========== fullform : FullForm of the rule as string. header : Header imports for the file. Uses default imports if None. module_name : name of RUBI module References ========== [1] http://reference.wolfram.com/language/ref/FullForm.html [2] http://reference.wolfram.com/language/ref/DownValues.html [3] https://gist.github.com/Upabjojr/bc07c49262944f9c1eb0 ''' if header is None: # use default header values path_header = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe()))) header = open(os.path.join(path_header, "header.py.txt"), "r").read() header = header.format(module_name) cons_dict = {} # dict keeps track of constraints that has been encountered, thus avoids repetition of constraints. cons_index =0 # for index of a constraint index = 0 # indicates the number of a rule. cons = '' # Temporarily rename these variables because it # can raise errors while sympifying for i in temporary_variable_replacement: fullform = fullform.replace(i, temporary_variable_replacement[i]) # Permanently rename these variables for i in permanent_variable_replacement: fullform = fullform.replace(i, permanent_variable_replacement[i]) rules = [] for i in parse_full_form(fullform): # separate all rules if i[0] == 'RuleDelayed': rules.append(i) parsed = downvalues_rules(rules, header, cons_dict, cons_index, index) result = parsed[0].strip() + '\n' cons_index = parsed[1] cons += parsed[2] index = parsed[3] # Replace temporary variables by actual values for i in temporary_variable_replacement: cons = cons.replace(temporary_variable_replacement[i], i) result = result.replace(temporary_variable_replacement[i], i) cons = "\n".join(header.split("\n")[:-2])+ '\n' + cons return result, cons
012525c5c64cf99172d9ffd2844ab0ee30a6a74747e760693af2d3704203f235
import sys from sympy.external import import_module matchpy = import_module("matchpy") if not matchpy: #bin/test will not execute any tests now disabled = True if sys.version_info[:2] < (3, 6): disabled = True from sympy.integrals.rubi.utility_function import (Int, Set, With, Module, Scan, MapAnd, FalseQ, ZeroQ, NegativeQ, NonzeroQ, FreeQ, NFreeQ, List, Log, PositiveQ, PositiveIntegerQ, NegativeIntegerQ, IntegerQ, IntegersQ, ComplexNumberQ, PureComplexNumberQ, RealNumericQ, PositiveOrZeroQ, NegativeOrZeroQ, FractionOrNegativeQ, NegQ, Equal, Unequal, IntPart, FracPart, RationalQ, ProductQ, SumQ, NonsumQ, Subst, First, Rest, SqrtNumberQ, SqrtNumberSumQ, LinearQ, Sqrt, ArcCosh, Coefficient, Denominator, Hypergeometric2F1, Not, Simplify, FractionalPart, IntegerPart, AppellF1, EllipticPi, PolynomialQuotient, EllipticE, EllipticF, ArcTan, ArcCot, ArcCoth, ArcTanh, ArcSin, ArcSinh, ArcCos, ArcCsc, ArcSec, ArcCsch, ArcSech, Sinh, Tanh, Cosh, Sech, Csch, Coth, LessEqual, Less, Greater, GreaterEqual, FractionQ, IntLinearcQ, Expand, IndependentQ, PowerQ, IntegerPowerQ, PositiveIntegerPowerQ, FractionalPowerQ, AtomQ, ExpQ, LogQ, Head, MemberQ, TrigQ, SinQ, CosQ, TanQ, CotQ, SecQ, CscQ, Sin, Cos, Tan, Cot, Sec, Csc, HyperbolicQ, SinhQ, CoshQ, TanhQ, CothQ, SechQ, CschQ, InverseTrigQ, SinCosQ, SinhCoshQ, LeafCount, Numerator, NumberQ, NumericQ, Length, ListQ, Im, Re, InverseHyperbolicQ, InverseFunctionQ, TrigHyperbolicFreeQ, InverseFunctionFreeQ, RealQ, EqQ, FractionalPowerFreeQ, ComplexFreeQ, PolynomialQ, FactorSquareFree, PowerOfLinearQ, Exponent, QuadraticQ, LinearPairQ, BinomialParts, TrinomialParts, PolyQ, EvenQ, OddQ, PerfectSquareQ, NiceSqrtAuxQ, NiceSqrtQ, Together, PosAux, PosQ, CoefficientList, ReplaceAll, ExpandLinearProduct, GCD, ContentFactor, NumericFactor, NonnumericFactors, MakeAssocList, GensymSubst, KernelSubst, ExpandExpression, Apart, SmartApart, MatchQ, PolynomialQuotientRemainder, FreeFactors, NonfreeFactors, RemoveContentAux, RemoveContent, FreeTerms, NonfreeTerms, ExpandAlgebraicFunction, CollectReciprocals, ExpandCleanup, AlgebraicFunctionQ, Coeff, LeadTerm, RemainingTerms, LeadFactor, RemainingFactors, LeadBase, LeadDegree, Numer, Denom, hypergeom, Expon, MergeMonomials, PolynomialDivide, BinomialQ, TrinomialQ, GeneralizedBinomialQ, GeneralizedTrinomialQ, FactorSquareFreeList, PerfectPowerTest, SquareFreeFactorTest, RationalFunctionQ, RationalFunctionFactors, NonrationalFunctionFactors, Reverse, RationalFunctionExponents, RationalFunctionExpand, ExpandIntegrand, SimplerQ, SimplerSqrtQ, SumSimplerQ, BinomialDegree, TrinomialDegree, CancelCommonFactors, SimplerIntegrandQ, GeneralizedBinomialDegree, GeneralizedBinomialParts, GeneralizedTrinomialDegree, GeneralizedTrinomialParts, MonomialQ, MonomialSumQ, MinimumMonomialExponent, MonomialExponent, LinearMatchQ, PowerOfLinearMatchQ, QuadraticMatchQ, CubicMatchQ, BinomialMatchQ, TrinomialMatchQ, GeneralizedBinomialMatchQ, GeneralizedTrinomialMatchQ, QuotientOfLinearsMatchQ, PolynomialTermQ, PolynomialTerms, NonpolynomialTerms, PseudoBinomialParts, NormalizePseudoBinomial, PseudoBinomialPairQ, PseudoBinomialQ, PolynomialGCD, PolyGCD, AlgebraicFunctionFactors, NonalgebraicFunctionFactors, QuotientOfLinearsP, QuotientOfLinearsParts, QuotientOfLinearsQ, Flatten, Sort, AbsurdNumberQ, AbsurdNumberFactors, NonabsurdNumberFactors, SumSimplerAuxQ, Prepend, Drop, CombineExponents, FactorInteger, FactorAbsurdNumber, SubstForInverseFunction, SubstForFractionalPower, SubstForFractionalPowerOfQuotientOfLinears, FractionalPowerOfQuotientOfLinears, SubstForFractionalPowerQ, SubstForFractionalPowerAuxQ, FractionalPowerOfSquareQ, FractionalPowerSubexpressionQ, Apply, FactorNumericGcd, MergeableFactorQ, MergeFactor, MergeFactors, TrigSimplifyQ, TrigSimplify, TrigSimplifyRecur, Order, FactorOrder, Smallest, OrderedQ, MinimumDegree, PositiveFactors, Sign, NonpositiveFactors, PolynomialInAuxQ, PolynomialInQ, ExponentInAux, ExponentIn, PolynomialInSubstAux, PolynomialInSubst, Distrib, DistributeDegree, FunctionOfPower, DivideDegreesOfFactors, MonomialFactor, FullSimplify, FunctionOfLinearSubst, FunctionOfLinear, NormalizeIntegrand, NormalizeIntegrandAux, NormalizeIntegrandFactor, NormalizeIntegrandFactorBase, NormalizeTogether, NormalizeLeadTermSigns, AbsorbMinusSign, NormalizeSumFactors, SignOfFactor, NormalizePowerOfLinear, SimplifyIntegrand, SimplifyTerm, TogetherSimplify, SmartSimplify, SubstForExpn, ExpandToSum, UnifySum, UnifyTerms, UnifyTerm, CalculusQ, FunctionOfInverseLinear, PureFunctionOfSinhQ, PureFunctionOfTanhQ, PureFunctionOfCoshQ, IntegerQuotientQ, OddQuotientQ, EvenQuotientQ, FindTrigFactor, FunctionOfSinhQ, FunctionOfCoshQ, OddHyperbolicPowerQ, FunctionOfTanhQ, FunctionOfTanhWeight, FunctionOfHyperbolicQ, SmartNumerator, SmartDenominator, SubstForAux, ActivateTrig, ExpandTrig, TrigExpand, SubstForTrig, SubstForHyperbolic, InertTrigFreeQ, LCM, SubstForFractionalPowerOfLinear, FractionalPowerOfLinear, InverseFunctionOfLinear, InertTrigQ, InertReciprocalQ, DeactivateTrig, FixInertTrigFunction, DeactivateTrigAux, PowerOfInertTrigSumQ, PiecewiseLinearQ, KnownTrigIntegrandQ, KnownSineIntegrandQ, KnownTangentIntegrandQ, KnownCotangentIntegrandQ, KnownSecantIntegrandQ, TryPureTanSubst, TryTanhSubst, TryPureTanhSubst, AbsurdNumberGCD, AbsurdNumberGCDList, ExpandTrigExpand, ExpandTrigReduce, ExpandTrigReduceAux, NormalizeTrig, TrigToExp, ExpandTrigToExp, TrigReduce, FunctionOfTrig, AlgebraicTrigFunctionQ, FunctionOfHyperbolic, FunctionOfQ, FunctionOfExpnQ, PureFunctionOfSinQ, PureFunctionOfCosQ, PureFunctionOfTanQ, PureFunctionOfCotQ, FunctionOfCosQ, FunctionOfSinQ, OddTrigPowerQ, FunctionOfTanQ, FunctionOfTanWeight, FunctionOfTrigQ, FunctionOfDensePolynomialsQ, FunctionOfLog, PowerVariableExpn, PowerVariableDegree, PowerVariableSubst, EulerIntegrandQ, FunctionOfSquareRootOfQuadratic, SquareRootOfQuadraticSubst, Divides, EasyDQ, ProductOfLinearPowersQ, Rt, NthRoot, AtomBaseQ, SumBaseQ, NegSumBaseQ, AllNegTermQ, SomeNegTermQ, TrigSquareQ, RtAux, TrigSquare, IntSum, IntTerm, Map2, ConstantFactor, SameQ, ReplacePart, CommonFactors, MostMainFactorPosition, FunctionOfExponentialQ, FunctionOfExponential, FunctionOfExponentialFunction, FunctionOfExponentialFunctionAux, FunctionOfExponentialTest, FunctionOfExponentialTestAux, stdev, rubi_test, If, IntQuadraticQ, IntBinomialQ, RectifyTangent, RectifyCotangent, Inequality, Condition, Simp, SimpHelp, SplitProduct, SplitSum, SubstFor, SubstForAux, FresnelS, FresnelC, Erfc, Erfi, Gamma, FunctionOfTrigOfLinearQ, ElementaryFunctionQ, Complex, UnsameQ, _SimpFixFactor, DerivativeDivides, SimpFixFactor, _FixSimplify, FixSimplify, _SimplifyAntiderivativeSum, SimplifyAntiderivativeSum, PureFunctionOfCothQ, _SimplifyAntiderivative, SimplifyAntiderivative, _TrigSimplifyAux, TrigSimplifyAux, Cancel, Part, PolyLog, D, Dist, IntegralFreeQ, Sum_doit, rubi_exp, rubi_log, rubi_log as log, PolynomialRemainder, CoprimeQ, Distribute, ProductLog, Floor, PolyGamma, process_trig, replace_pow_exp) from sympy.core.symbol import symbols, S from sympy.functions.elementary.trigonometric import atan, acsc, asin, acot, acos, asec, atan2 from sympy.functions.elementary.hyperbolic import acosh, asinh, atanh, acsch, cosh, sinh, tanh, coth, sech, csch, acoth from sympy.functions import (sin, cos, tan, cot, sec, csc, sqrt, log as sym_log) from sympy import (I, E, pi, hyper, Add, Wild, simplify, Symbol, exp, UnevaluatedExpr, Pow, li, Ei, expint, Si, Ci, Shi, Chi, loggamma, zeta, zoo, gamma, polylog, oo, polygamma) from sympy import Integral, nsimplify, Min A, B, a, b, c, d, e, f, g, h, y, z, m, n, p, q, u, v, w, F = symbols('A B a b c d e f g h y z m n p q u v w F', real=True, imaginary=False) x = Symbol('x') def test_ZeroQ(): e = b*(n*p + n + 1) d = a assert ZeroQ(a*e - b*d*(n*(p + S(1)) + S(1))) assert ZeroQ(S(0)) assert not ZeroQ(S(10)) assert not ZeroQ(S(-2)) assert ZeroQ(0, 2-2) assert ZeroQ([S(2), (4), S(0), S(8)]) == [False, False, True, False] assert ZeroQ([S(2), S(4), S(8)]) == [False, False, False] def test_NonzeroQ(): assert NonzeroQ(S(1)) == True def test_FreeQ(): l = [a*b, x, a + b] assert FreeQ(l, x) == False l = [a*b, a + b] assert FreeQ(l, x) == True def test_List(): assert List(a, b, c) == [a, b, c] def test_Log(): assert Log(a) == log(a) def test_PositiveIntegerQ(): assert PositiveIntegerQ(S(1)) assert not PositiveIntegerQ(S(-3)) assert not PositiveIntegerQ(S(0)) def test_NegativeIntegerQ(): assert not NegativeIntegerQ(S(1)) assert NegativeIntegerQ(S(-3)) assert not NegativeIntegerQ(S(0)) def test_PositiveQ(): assert PositiveQ(S(1)) assert not PositiveQ(S(-3)) assert not PositiveQ(S(0)) assert not PositiveQ(zoo) assert not PositiveQ(I) assert PositiveQ(b/(b*(b*c/(-a*d + b*c)) - a*(b*d/(-a*d + b*c)))) def test_IntegerQ(): assert IntegerQ(S(1)) assert not IntegerQ(S(-1.9)) assert not IntegerQ(S(0.0)) assert IntegerQ(S(-1)) def test_FracPart(): assert FracPart(S(10)) == 0 assert FracPart(S(10)+0.5) == 10.5 def test_IntPart(): assert IntPart(m*n) == 0 assert IntPart(S(10)) == 10 assert IntPart(1 + m) == 1 def test_NegQ(): assert NegQ(-S(3)) assert not NegQ(S(0)) assert not NegQ(S(0)) def test_RationalQ(): assert RationalQ(S(5)/6) assert RationalQ(S(5)/6, S(4)/5) assert not RationalQ(Sqrt(1.6)) assert not RationalQ(Sqrt(1.6), S(5)/6) assert not RationalQ(log(2)) def test_ArcCosh(): assert ArcCosh(x) == acosh(x) def test_LinearQ(): assert not LinearQ(a, x) assert LinearQ(3*x + y**2, x) assert not LinearQ(3*x + y**2, y) assert not LinearQ(S(3), x) def test_Sqrt(): assert Sqrt(x) == sqrt(x) assert Sqrt(25) == 5 def test_Util_Coefficient(): from sympy.integrals.rubi.utility_function import Util_Coefficient assert Util_Coefficient(a + b*x + c*x**3, x, a) == Util_Coefficient(a + b*x + c*x**3, x, a) assert Util_Coefficient(a + b*x + c*x**3, x, 4).doit() == 0 def test_Coefficient(): assert Coefficient(7 + 2*x + 4*x**3, x, 1) == 2 assert Coefficient(a + b*x + c*x**3, x, 0) == a assert Coefficient(a + b*x + c*x**3, x, 4) == 0 assert Coefficient(b*x + c*x**3, x, 3) == c assert Coefficient(x, x, -1) == 0 def test_Denominator(): assert Denominator((-S(1)/S(2) + I/3)) == 6 assert Denominator((-a/b)**3) == (b)**(3) assert Denominator(S(3)/2) == 2 assert Denominator(x/y) == y assert Denominator(S(4)/5) == 5 def test_Hypergeometric2F1(): assert Hypergeometric2F1(1, 2, 3, x) == hyper((1, 2), (3,), x) def test_ArcTan(): assert ArcTan(x) == atan(x) assert ArcTan(x, y) == atan2(x, y) def test_Not(): a = 10 assert Not(a == 2) def test_FractionalPart(): assert FractionalPart(S(3.0)) == 0.0 def test_IntegerPart(): assert IntegerPart(3.6) == 3 assert IntegerPart(-3.6) == -4 def test_AppellF1(): assert AppellF1(1,0,0.5,1,0.5,0.25).evalf() == 1.154700538379251529018298 assert AppellF1(a, b, c, d, e, f) == AppellF1(a, b, c, d, e, f) def test_Simplify(): assert Simplify(sin(x)**2 + cos(x)**2) == 1 assert Simplify((x**3 + x**2 - x - 1)/(x**2 + 2*x + 1)) == x - 1 def test_ArcTanh(): assert ArcTanh(a) == atanh(a) def test_ArcSin(): assert ArcSin(a) == asin(a) def test_ArcSinh(): assert ArcSinh(a) == asinh(a) def test_ArcCos(): assert ArcCos(a) == acos(a) def test_ArcCsc(): assert ArcCsc(a) == acsc(a) def test_ArcCsch(): assert ArcCsch(a) == acsch(a) def test_Equal(): assert Equal(a, a) assert not Equal(a, b) def test_LessEqual(): assert LessEqual(1, 2, 3) assert LessEqual(1, 1) assert not LessEqual(3, 2, 1) def test_With(): assert With(Set(x, 3), x + y) == 3 + y assert With(List(Set(x, 3), Set(y, c)), x + y) == 3 + c def test_Less(): assert Less(1, 2, 3) assert not Less(1, 1, 3) def test_Greater(): assert Greater(3, 2, 1) assert not Greater(3, 2, 2) def test_GreaterEqual(): assert GreaterEqual(3, 2, 1) assert GreaterEqual(3, 2, 2) assert not GreaterEqual(2, 3) def test_Unequal(): assert Unequal(1, 2) assert not Unequal(1, 1) def test_FractionQ(): assert not FractionQ(S('3')) assert FractionQ(S('3')/S('2')) def test_Expand(): assert Expand((1 + x)**10) == x**10 + 10*x**9 + 45*x**8 + 120*x**7 + 210*x**6 + 252*x**5 + 210*x**4 + 120*x**3 + 45*x**2 + 10*x + 1 def test_Scan(): assert list(Scan(sin, [a, b])) == [sin(a), sin(b)] def test_MapAnd(): assert MapAnd(PositiveQ, [S(1), S(2), S(3), S(0)]) == False assert MapAnd(PositiveQ, [S(1), S(2), S(3)]) == True def test_FalseQ(): assert FalseQ(True) == False assert FalseQ(False) == True def test_ComplexNumberQ(): assert ComplexNumberQ(1 + I*2, I) == True assert ComplexNumberQ(a + b, I) == False def test_Re(): assert Re(1 + I) == 1 def test_Im(): assert Im(1 + 2*I) == 2 assert Im(a*I) == a def test_PositiveOrZeroQ(): assert PositiveOrZeroQ(S(0)) == True assert PositiveOrZeroQ(S(1)) == True assert PositiveOrZeroQ(-S(1)) == False def test_RealNumericQ(): assert RealNumericQ(S(1)) == True assert RealNumericQ(-S(1)) == True def test_NegativeOrZeroQ(): assert NegativeOrZeroQ(S(0)) == True assert NegativeOrZeroQ(-S(1)) == True assert NegativeOrZeroQ(S(1)) == False def test_FractionOrNegativeQ(): assert FractionOrNegativeQ(S(1)/2) == True assert FractionOrNegativeQ(-S(1)) == True def test_ProductQ(): assert ProductQ(a*b) == True assert ProductQ(a + b) == False def test_SumQ(): assert SumQ(a*b) == False assert SumQ(a + b) == True def test_NonsumQ(): assert NonsumQ(a*b) == True assert NonsumQ(a + b) == False def test_SqrtNumberQ(): assert SqrtNumberQ(sqrt(2)) == True def test_IntLinearcQ(): assert IntLinearcQ(1, 2, 3, 4, 5, 6, x) == True assert IntLinearcQ(S(1)/100, S(2)/100, S(3)/100, S(4)/100, S(5)/100, S(6)/100, x) == False def test_IndependentQ(): assert IndependentQ(a + b*x, x) == False assert IndependentQ(a + b, x) == True def test_PowerQ(): assert PowerQ(a**b) == True assert PowerQ(a + b) == False def test_IntegerPowerQ(): assert IntegerPowerQ(a**2) == True assert IntegerPowerQ(a**0.5) == False def test_PositiveIntegerPowerQ(): assert PositiveIntegerPowerQ(a**3) == True assert PositiveIntegerPowerQ(a**(-2)) == False def test_FractionalPowerQ(): assert FractionalPowerQ(a**(S(2)/S(3))) assert FractionalPowerQ(a**sqrt(2)) == False def test_AtomQ(): assert AtomQ(x) assert not AtomQ(x+1) assert not AtomQ([a, b]) def test_ExpQ(): assert ExpQ(E**2) assert not ExpQ(2**E) def test_LogQ(): assert LogQ(log(x)) assert not LogQ(sin(x) + log(x)) def test_Head(): assert Head(sin(x)) == sin assert Head(log(x**3 + 3)) in (sym_log, log) def test_MemberQ(): assert MemberQ([a, b, c], b) assert MemberQ([sin, cos, log, tan], Head(sin(x))) assert MemberQ([[sin, cos], [tan, cot]], [sin, cos]) assert not MemberQ([[sin, cos], [tan, cot]], [sin, tan]) def test_TrigQ(): assert TrigQ(sin(x)) assert TrigQ(tan(x**2 + 2)) assert not TrigQ(sin(x) + tan(x)) def test_SinQ(): assert SinQ(sin(x)) assert not SinQ(tan(x)) def test_CosQ(): assert CosQ(cos(x)) assert not CosQ(csc(x)) def test_TanQ(): assert TanQ(tan(x)) assert not TanQ(cot(x)) def test_CotQ(): assert not CotQ(tan(x)) assert CotQ(cot(x)) def test_SecQ(): assert SecQ(sec(x)) assert not SecQ(csc(x)) def test_CscQ(): assert not CscQ(sec(x)) assert CscQ(csc(x)) def test_HyperbolicQ(): assert HyperbolicQ(sinh(x)) assert HyperbolicQ(cosh(x)) assert HyperbolicQ(tanh(x)) assert not HyperbolicQ(sinh(x) + cosh(x) + tanh(x)) def test_SinhQ(): assert SinhQ(sinh(x)) assert not SinhQ(cosh(x)) def test_CoshQ(): assert not CoshQ(sinh(x)) assert CoshQ(cosh(x)) def test_TanhQ(): assert TanhQ(tanh(x)) assert not TanhQ(coth(x)) def test_CothQ(): assert not CothQ(tanh(x)) assert CothQ(coth(x)) def test_SechQ(): assert SechQ(sech(x)) assert not SechQ(csch(x)) def test_CschQ(): assert not CschQ(sech(x)) assert CschQ(csch(x)) def test_InverseTrigQ(): assert InverseTrigQ(acot(x)) assert InverseTrigQ(asec(x)) assert not InverseTrigQ(acsc(x) + asec(x)) def test_SinCosQ(): assert SinCosQ(sin(x)) assert SinCosQ(cos(x)) assert SinCosQ(sec(x)) assert not SinCosQ(acsc(x)) def test_SinhCoshQ(): assert not SinhCoshQ(sin(x)) assert SinhCoshQ(cosh(x)) assert SinhCoshQ(sech(x)) assert SinhCoshQ(csch(x)) def test_LeafCount(): assert LeafCount(1 + a + x**2) == 6 def test_Numerator(): assert Numerator((-S(1)/S(2) + I/3)) == -3 + 2*I assert Numerator((-a/b)**3) == (-a)**(3) assert Numerator(S(3)/2) == 3 assert Numerator(x/y) == x def test_Length(): assert Length(a + b) == 2 assert Length(sin(a)*cos(a)) == 2 def test_ListQ(): assert ListQ([1, 2]) assert not ListQ(a) def test_InverseHyperbolicQ(): assert InverseHyperbolicQ(acosh(a)) def test_InverseFunctionQ(): assert InverseFunctionQ(log(a)) assert InverseFunctionQ(acos(a)) assert not InverseFunctionQ(a) assert InverseFunctionQ(acosh(a)) assert InverseFunctionQ(polylog(a, b)) def test_EqQ(): assert EqQ(a, a) assert not EqQ(a, b) def test_FactorSquareFree(): assert FactorSquareFree(x**5 - x**3 - x**2 + 1) == (x**3 + 2*x**2 + 2*x + 1)*(x - 1)**2 def test_FactorSquareFreeList(): assert FactorSquareFreeList(x**5-x**3-x**2 + 1) == [[1, 1], [x**3 + 2*x**2 + 2*x + 1, 1], [x - 1, 2]] assert FactorSquareFreeList(x**4 - 2*x**2 + 1) == [[1, 1], [x**2 - 1, 2]] def test_PerfectPowerTest(): assert not PerfectPowerTest(sqrt(x), x) assert not PerfectPowerTest(x**5-x**3-x**2 + 1, x) assert PerfectPowerTest(x**4 - 2*x**2 + 1, x) == (x**2 - 1)**2 def test_SquareFreeFactorTest(): assert not SquareFreeFactorTest(sqrt(x), x) assert SquareFreeFactorTest(x**5 - x**3 - x**2 + 1, x) == (x**3 + 2*x**2 + 2*x + 1)*(x - 1)**2 def test_Rest(): assert Rest([2, 3, 5, 7]) == [3, 5, 7] assert Rest(a + b + c) == b + c assert Rest(a*b*c) == b*c assert Rest(1/b) == -1 def test_First(): assert First([2, 3, 5, 7]) == 2 assert First(y**S(2)) == y assert First(a + b + c) == a assert First(a*b*c) == a def test_ComplexFreeQ(): assert ComplexFreeQ(a) assert not ComplexFreeQ(a + 2*I) def test_FractionalPowerFreeQ(): assert not FractionalPowerFreeQ(x**(S(2)/3)) assert FractionalPowerFreeQ(x) def test_Exponent(): assert Exponent(x**2 + x + 1 + 5, x, Min) == 0 assert Exponent(x**2 + x + 1 + 5, x, List) == [0, 1, 2] assert Exponent(x**2 + x + 1, x, List) == [0, 1, 2] assert Exponent(x**2 + 2*x + 1, x, List) == [0, 1, 2] assert Exponent(x**3 + x + 1, x) == 3 assert Exponent(x**2 + 2*x + 1, x) == 2 assert Exponent(x**3, x, List) == [3] assert Exponent(S(1), x) == 0 assert Exponent(x**(-3), x) == 0 def test_Expon(): assert Expon(x**2+2*x+1, x) == 2 assert Expon(x**3, x, List) == [3] def test_QuadraticQ(): assert not QuadraticQ([x**2+x+1, 5*x**2], x) assert QuadraticQ([x**2+x+1, 5*x**2+3*x+6], x) assert not QuadraticQ(x**2+1+x**3, x) assert QuadraticQ(x**2+1+x, x) assert not QuadraticQ(x**2, x) def test_BinomialQ(): assert BinomialQ(x**9, x) assert not BinomialQ((1 + x)**3, x) def test_BinomialParts(): assert BinomialParts(2 + x*(9*x), x) == [2, 9, 2] assert BinomialParts(x**9, x) == [0, 1, 9] assert BinomialParts(2*x**3, x) == [0, 2, 3] assert BinomialParts(2 + x, x) == [2, 1, 1] def test_BinomialDegree(): assert BinomialDegree(b + 2*c*x**n, x) == n assert BinomialDegree(2 + x*(9*x), x) == 2 assert BinomialDegree(x**9, x) == 9 def test_PolynomialQ(): assert not PolynomialQ(x*(-1 + x**2), (1 + x)**(S(1)/2)) assert not PolynomialQ((16*x + 1)/((x + 5)**2*(x**2 + x + 1)), 2*x) C = Symbol('C') assert not PolynomialQ(A + b*x + c*x**2, x**2) assert PolynomialQ(A + B*x + C*x**2) assert PolynomialQ(A + B*x**4 + C*x**2, x**2) assert PolynomialQ(x**3, x) assert not PolynomialQ(sqrt(x), x) def test_PolyQ(): assert PolyQ(-2*a*d**3*e**2 + x**6*(a*e**5 - b*d*e**4 + c*d**2*e**3)\ + x**4*(-2*a*d*e**4 + 2*b*d**2*e**3 - 2*c*d**3*e**2) + x**2*(2*a*d**2*e**3 - 2*b*d**3*e**2), x) assert not PolyQ(1/sqrt(a + b*x**2 - c*x**4), x**2) assert PolyQ(x, x, 1) assert PolyQ(x**2, x, 2) assert not PolyQ(x**3, x, 2) def test_EvenQ(): assert EvenQ(S(2)) assert not EvenQ(S(1)) def test_OddQ(): assert OddQ(S(1)) assert not OddQ(S(2)) def test_PerfectSquareQ(): assert PerfectSquareQ(S(4)) assert PerfectSquareQ(a**S(2)*b**S(4)) assert not PerfectSquareQ(S(1)/3) def test_NiceSqrtQ(): assert NiceSqrtQ(S(1)/3) assert not NiceSqrtQ(-S(1)) assert NiceSqrtQ(pi**2) assert NiceSqrtQ(pi**2*sin(4)**4) assert not NiceSqrtQ(pi**2*sin(4)**3) def test_Together(): assert Together(1/a + b/2) == (a*b + 2)/(2*a) def test_PosQ(): #assert not PosQ((b*e - c*d)/(c*e)) assert not PosQ(S(0)) assert PosQ(S(1)) assert PosQ(pi) assert PosQ(pi**3) assert PosQ((-pi)**4) assert PosQ(sin(1)**2*pi**4) def test_NumericQ(): assert NumericQ(sin(cos(2))) def test_NumberQ(): assert NumberQ(pi) def test_CoefficientList(): assert CoefficientList(1 + a*x, x) == [1, a] assert CoefficientList(1 + a*x**3, x) == [1, 0, 0, a] assert CoefficientList(sqrt(x), x) == [] def test_ReplaceAll(): assert ReplaceAll(x, {x: a}) == a assert ReplaceAll(a*x, {x: a + b}) == a*(a + b) assert ReplaceAll(a*x, {a: b, x: a + b}) == b*(a + b) def test_ExpandLinearProduct(): assert ExpandLinearProduct(log(x), x**2, a, b, x) == a**2*log(x)/b**2 - 2*a*(a + b*x)*log(x)/b**2 + (a + b*x)**2*log(x)/b**2 assert ExpandLinearProduct((a + b*x)**n, x**3, a, b, x) == -a**3*(a + b*x)**n/b**3 + 3*a**2*(a + b*x)**(n + 1)/b**3 - 3*a*(a + b*x)**(n + 2)/b**3 + (a + b*x)**(n + 3)/b**3 def test_PolynomialDivide(): assert PolynomialDivide((a*c - b*c*x)**2, (a + b*x)**2, x) == -4*a*b*c**2*x/(a + b*x)**2 + c**2 assert PolynomialDivide(x + x**2, x, x) == x + 1 assert PolynomialDivide((1 + x)**3, (1 + x)**2, x) == x + 1 assert PolynomialDivide((a + b*x)**3, x**3, x) == a*(a**2 + 3*a*b*x + 3*b**2*x**2)/x**3 + b**3 assert PolynomialDivide(x**3*(a + b*x), S(1), x) == b*x**4 + a*x**3 assert PolynomialDivide(x**6, (a + b*x)**2, x) == -a**5*(5*a + 6*b*x)/(b**6*(a + b*x)**2) + 5*a**4/b**6 - 4*a**3*x/b**5 + 3*a**2*x**2/b**4 - 2*a*x**3/b**3 + x**4/b**2 def test_MatchQ(): a_ = Wild('a', exclude=[x]) b_ = Wild('b', exclude=[x]) c_ = Wild('c', exclude=[x]) assert MatchQ(a*b + c, a_*b_ + c_, a_, b_, c_) == (a, b, c) def test_PolynomialQuotientRemainder(): assert PolynomialQuotientRemainder(x**2, x+a, x) == [-a + x, a**2] def test_FreeFactors(): assert FreeFactors(a, x) == a assert FreeFactors(x + a, x) == 1 assert FreeFactors(a*b*x, x) == a*b def test_NonfreeFactors(): assert NonfreeFactors(a, x) == 1 assert NonfreeFactors(x + a, x) == x + a assert NonfreeFactors(a*b*x, x) == x def test_FreeTerms(): assert FreeTerms(a, x) == a assert FreeTerms(x*a, x) == 0 assert FreeTerms(a*x + b, x) == b def test_NonfreeTerms(): assert NonfreeTerms(a, x) == 0 assert NonfreeTerms(a*x, x) == a*x assert NonfreeTerms(a*x + b, x) == a*x def test_RemoveContent(): assert RemoveContent(a + b*x, x) == a + b*x def test_ExpandAlgebraicFunction(): assert ExpandAlgebraicFunction((a + b)*x, x) == a*x + b*x assert ExpandAlgebraicFunction((a + b)**2*x, x)== a**2*x + 2*a*b*x + b**2*x assert ExpandAlgebraicFunction((a + b)**2*x**2, x) == a**2*x**2 + 2*a*b*x**2 + b**2*x**2 def test_CollectReciprocals(): assert CollectReciprocals(-1/(1 + 1*x) - 1/(1 - 1*x), x) == -2/(-x**2 + 1) assert CollectReciprocals(1/(1 + 1*x) - 1/(1 - 1*x), x) == -2*x/(-x**2 + 1) def test_ExpandCleanup(): assert ExpandCleanup(a + b, x) == a*(1 + b/a) assert ExpandCleanup(b**2/(a**2*(a + b*x)**2) + 1/(a**2*x**2) + 2*b**2/(a**3*(a + b*x)) - 2*b/(a**3*x), x) == b**2/(a**2*(a + b*x)**2) + 1/(a**2*x**2) + 2*b**2/(a**3*(a + b*x)) - 2*b/(a**3*x) def test_AlgebraicFunctionQ(): assert not AlgebraicFunctionQ(1/(a + c*x**(2*n)), x) assert AlgebraicFunctionQ(a, x) == True assert AlgebraicFunctionQ(a*b, x) == True assert AlgebraicFunctionQ(x**2, x) == True assert AlgebraicFunctionQ(x**2*a, x) == True assert AlgebraicFunctionQ(x**2 + a, x) == True assert AlgebraicFunctionQ(sin(x), x) == False assert AlgebraicFunctionQ([], x) == True assert AlgebraicFunctionQ([a, a*b], x) == True assert AlgebraicFunctionQ([sin(x)], x) == False def test_MonomialQ(): assert not MonomialQ(2*x**7 + 6, x) assert MonomialQ(2*x**7, x) assert not MonomialQ(2*x**7 + 5*x**3, x) assert not MonomialQ([2*x**7 + 6, 2*x**7], x) assert MonomialQ([2*x**7, 5*x**3], x) def test_MonomialSumQ(): assert MonomialSumQ(2*x**7 + 6, x) == True assert MonomialSumQ(x**2 + x**3 + 5*x, x) == True def test_MinimumMonomialExponent(): assert MinimumMonomialExponent(x**2 + 5*x**2 + 3*x**5, x) == 2 assert MinimumMonomialExponent(x**2 + 5*x**2 + 1, x) == 0 def test_MonomialExponent(): assert MonomialExponent(3*x**7, x) == 7 assert not MonomialExponent(3+x**3, x) def test_LinearMatchQ(): assert LinearMatchQ(2 + 3*x, x) assert LinearMatchQ(3*x, x) assert not LinearMatchQ(3*x**2, x) def test_SimplerQ(): a1, b1 = symbols('a1 b1') assert SimplerQ(a1, b1) assert SimplerQ(2*a, a + 2) assert SimplerQ(2, x) assert not SimplerQ(x**2, x) assert SimplerQ(2*x, x + 2 + 6*x**3) def test_GeneralizedTrinomialParts(): assert not GeneralizedTrinomialParts((7 + 2*x**6 + 3*x**12), x) assert GeneralizedTrinomialParts(x**2 + x**3 + x**4, x) == [1, 1, 1, 3, 2] assert not GeneralizedTrinomialParts(2*x + 3*x + 4*x, x) def test_TrinomialQ(): assert TrinomialQ((7 + 2*x**6 + 3*x**12), x) assert not TrinomialQ(x**2, x) def test_GeneralizedTrinomialDegree(): assert not GeneralizedTrinomialDegree((7 + 2*x**6 + 3*x**12), x) assert GeneralizedTrinomialDegree(x**2 + x**3 + x**4, x) == 1 def test_GeneralizedBinomialParts(): assert GeneralizedBinomialParts(3*x*(3 + x**6), x) == [9, 3, 7, 1] assert GeneralizedBinomialParts((3*x + x**7), x) == [3, 1, 7, 1] def test_GeneralizedBinomialDegree(): assert GeneralizedBinomialDegree(3*x*(3 + x**6), x) == 6 assert GeneralizedBinomialDegree((3*x + x**7), x) == 6 def test_PowerOfLinearQ(): assert PowerOfLinearQ((6*x), x) assert not PowerOfLinearQ((3 + 6*x**3), x) assert PowerOfLinearQ((3 + 6*x)**3, x) def test_LinearPairQ(): assert not LinearPairQ(6*x**2 + 4, 3*x**2 + 2, x) assert LinearPairQ(6*x + 4, 3*x + 2, x) assert not LinearPairQ(6*x, 3*x + 2, x) assert LinearPairQ(6*x, 3*x, x) def test_LeadTerm(): assert LeadTerm(a*b*c) == a*b*c assert LeadTerm(a + b + c) == a def test_RemainingTerms(): assert RemainingTerms(a*b*c) == a*b*c assert RemainingTerms(a + b + c) == b + c def test_LeadFactor(): assert LeadFactor(a*b*c) == a assert LeadFactor(a + b + c) == a + b + c assert LeadFactor(b*I) == I assert LeadFactor(c*a**b) == a**b assert LeadFactor(S(2)) == S(2) def test_RemainingFactors(): assert RemainingFactors(a*b*c) == b*c assert RemainingFactors(a + b + c) == 1 assert RemainingFactors(a*I) == a def test_LeadBase(): assert LeadBase(a**b) == a assert LeadBase(a**b*c) == a def test_LeadDegree(): assert LeadDegree(a**b) == b assert LeadDegree(a**b*c) == b def test_Numer(): assert Numer(a/b) == a assert Numer(a**(-2)) == 1 assert Numer(a**(-2)*a/b) == 1 def test_Denom(): assert Denom(a/b) == b assert Denom(a**(-2)) == a**2 assert Denom(a**(-2)*a/b) == a*b def test_Coeff(): assert Coeff(7 + 2*x + 4*x**3, x, 1) == 2 assert Coeff(a + b*x + c*x**3, x, 0) == a assert Coeff(a + b*x + c*x**3, x, 4) == 0 assert Coeff(b*x + c*x**3, x, 3) == c def test_MergeMonomials(): assert MergeMonomials(x**2*(1 + 1*x)**3*(1 + 1*x)**n, x) == x**2*(x + 1)**(n + 3) assert MergeMonomials(x**2*(1 + 1*x)**2*(1*(1 + 1*x)**1)**2, x) == x**2*(x + 1)**4 assert MergeMonomials(b**2/a**3, x) == b**2/a**3 def test_RationalFunctionQ(): assert RationalFunctionQ(a, x) assert RationalFunctionQ(x**2, x) assert RationalFunctionQ(x**3 + x**4, x) assert RationalFunctionQ(x**3*S(2), x) assert not RationalFunctionQ(x**3 + x**(0.5), x) assert not RationalFunctionQ(x**(S(2)/3)*(a + b*x)**2, x) def test_Apart(): assert Apart(1/(x**2*(a + b*x)**2), x) == b**2/(a**2*(a + b*x)**2) + 1/(a**2*x**2) + 2*b**2/(a**3*(a + b*x)) - 2*b/(a**3*x) assert Apart(x**(S(2)/3)*(a + b*x)**2, x) == x**(S(2)/3)*(a + b*x)**2 def test_RationalFunctionFactors(): assert RationalFunctionFactors(a, x) == a assert RationalFunctionFactors(sqrt(x), x) == 1 assert RationalFunctionFactors(x*x**3, x) == x*x**3 assert RationalFunctionFactors(x*sqrt(x), x) == 1 def test_NonrationalFunctionFactors(): assert NonrationalFunctionFactors(x, x) == 1 assert NonrationalFunctionFactors(sqrt(x), x) == sqrt(x) assert NonrationalFunctionFactors(sqrt(x)*log(x), x) == sqrt(x)*log(x) def test_Reverse(): assert Reverse([1, 2, 3]) == [3, 2, 1] assert Reverse(a**b) == b**a def test_RationalFunctionExponents(): assert RationalFunctionExponents(sqrt(x), x) == [0, 0] assert RationalFunctionExponents(a, x) == [0, 0] assert RationalFunctionExponents(x, x) == [1, 0] assert RationalFunctionExponents(x**(-1), x)== [0, 1] assert RationalFunctionExponents(x**(-1)*a, x) == [0, 1] assert RationalFunctionExponents(x**(-1) + a, x) == [1, 1] def test_PolynomialGCD(): assert PolynomialGCD(x**2 - 1, x**2 - 3*x + 2) == x - 1 def test_PolyGCD(): assert PolyGCD(x**2 - 1, x**2 - 3*x + 2, x) == x - 1 def test_AlgebraicFunctionFactors(): assert AlgebraicFunctionFactors(sin(x)*x, x) == x assert AlgebraicFunctionFactors(sin(x), x) == 1 assert AlgebraicFunctionFactors(x, x) == x def test_NonalgebraicFunctionFactors(): assert NonalgebraicFunctionFactors(sin(x)*x, x) == sin(x) assert NonalgebraicFunctionFactors(sin(x), x) == sin(x) assert NonalgebraicFunctionFactors(x, x) == 1 def test_QuotientOfLinearsP(): assert QuotientOfLinearsP((a + b*x)/(x), x) assert QuotientOfLinearsP(x*a, x) assert not QuotientOfLinearsP(x**2*a, x) assert not QuotientOfLinearsP(x**2 + a, x) assert QuotientOfLinearsP(x + a, x) assert QuotientOfLinearsP(x, x) assert QuotientOfLinearsP(1 + x, x) def test_QuotientOfLinearsParts(): assert QuotientOfLinearsParts((b*x)/(c), x) == [0, b/c, 1, 0] assert QuotientOfLinearsParts((b*x)/(c + x), x) == [0, b, c, 1] assert QuotientOfLinearsParts((b*x)/(c + d*x), x) == [0, b, c, d] assert QuotientOfLinearsParts((a + b*x)/(c + d*x), x) == [a, b, c, d] assert QuotientOfLinearsParts(x**2 + a, x) == [a + x**2, 0, 1, 0] assert QuotientOfLinearsParts(a/x, x) == [a, 0, 0, 1] assert QuotientOfLinearsParts(1/x, x) == [1, 0, 0, 1] assert QuotientOfLinearsParts(a*x + 1, x) == [1, a, 1, 0] assert QuotientOfLinearsParts(x, x) == [0, 1, 1, 0] assert QuotientOfLinearsParts(a, x) == [a, 0, 1, 0] def test_QuotientOfLinearsQ(): assert not QuotientOfLinearsQ((a + x), x) assert QuotientOfLinearsQ((a + x)/(x), x) assert QuotientOfLinearsQ((a + b*x)/(x), x) def test_Flatten(): assert Flatten([a, b, [c, [d, e]]]) == [a, b, c, d, e] def test_Sort(): assert Sort([b, a, c]) == [a, b, c] assert Sort([b, a, c], True) == [c, b, a] def test_AbsurdNumberQ(): assert AbsurdNumberQ(S(1)) assert not AbsurdNumberQ(a*x) assert not AbsurdNumberQ(a**(S(1)/2)) assert AbsurdNumberQ((S(1)/3)**(S(1)/3)) def test_AbsurdNumberFactors(): assert AbsurdNumberFactors(S(1)) == S(1) assert AbsurdNumberFactors((S(1)/3)**(S(1)/3)) == S(3)**(S(2)/3)/S(3) assert AbsurdNumberFactors(a) == S(1) def test_NonabsurdNumberFactors(): assert NonabsurdNumberFactors(a) == a assert NonabsurdNumberFactors(S(1)) == S(1) assert NonabsurdNumberFactors(a*S(2)) == a def test_NumericFactor(): assert NumericFactor(S(1)) == S(1) assert NumericFactor(1*I) == S(1) assert NumericFactor(S(1) + I) == S(1) assert NumericFactor(a**(S(1)/3)) == S(1) assert NumericFactor(a*S(3)) == S(3) assert NumericFactor(a + b) == S(1) def test_NonnumericFactors(): assert NonnumericFactors(S(3)) == S(1) assert NonnumericFactors(I) == I assert NonnumericFactors(S(3) + I) == S(3) + I assert NonnumericFactors((S(1)/3)**(S(1)/3)) == S(1) assert NonnumericFactors(log(a)) == log(a) def test_Prepend(): assert Prepend([1, 2, 3], [4, 5]) == [4, 5, 1, 2, 3] def test_SumSimplerQ(): assert not SumSimplerQ(S(4 + x),S(3 + x**3)) assert SumSimplerQ(S(4 + x), S(3 - x)) def test_SumSimplerAuxQ(): assert SumSimplerAuxQ(S(4 + x), S(3 - x)) assert not SumSimplerAuxQ(S(4), S(3)) def test_SimplerSqrtQ(): assert SimplerSqrtQ(S(2), S(16*x**3)) assert not SimplerSqrtQ(S(x*2), S(16)) assert not SimplerSqrtQ(S(-4), S(16)) assert SimplerSqrtQ(S(4), S(16)) assert not SimplerSqrtQ(S(4), S(0)) def test_TrinomialParts(): assert TrinomialParts((1 + 5*x**3)**2, x) == [1, 10, 25, 3] assert TrinomialParts(1 + 5*x**3 + 2*x**6, x) == [1, 5, 2, 3] assert TrinomialParts(((1 + 5*x**3)**2) + 6, x) == [7, 10, 25, 3] assert not TrinomialParts(1 + 5*x**3 + 2*x**5, x) def test_TrinomialDegree(): assert TrinomialDegree((7 + 2*x**6)**2, x) == 6 assert TrinomialDegree(1 + 5*x**3 + 2*x**6, x) == 3 assert not TrinomialDegree(1 + 5*x**3 + 2*x**5, x) def test_CubicMatchQ(): assert not CubicMatchQ(S(3 + x**6), x) assert CubicMatchQ(S(x**3), x) assert not CubicMatchQ(S(3), x) assert CubicMatchQ(S(3 + x**3), x) assert CubicMatchQ(S(3 + x**3 + 2*x), x) def test_BinomialMatchQ(): assert BinomialMatchQ(x, x) assert BinomialMatchQ(2 + 3*x**5, x) assert BinomialMatchQ(3*x**5, x) assert BinomialMatchQ(3*x, x) assert not BinomialMatchQ(x + x**2 + x**3, x) def test_TrinomialMatchQ(): assert not TrinomialMatchQ((5 + 2*x**6)**2, x) assert not TrinomialMatchQ((7 + 8*x**6), x) assert TrinomialMatchQ((7 + 2*x**6 + 3*x**3), x) assert TrinomialMatchQ(b*x**2 + c*x**4, x) def test_GeneralizedBinomialMatchQ(): assert not GeneralizedBinomialMatchQ((1 + x**4), x) assert GeneralizedBinomialMatchQ((3*x + x**7), x) def test_QuadraticMatchQ(): assert not QuadraticMatchQ((a + b*x)*(c + d*x), x) assert QuadraticMatchQ(x**2 + x, x) assert QuadraticMatchQ(x**2+1+x, x) assert QuadraticMatchQ(x**2, x) def test_PowerOfLinearMatchQ(): assert PowerOfLinearMatchQ(x, x) assert not PowerOfLinearMatchQ(S(6)**3, x) assert not PowerOfLinearMatchQ(S(6 + 3*x**2)**3, x) assert PowerOfLinearMatchQ(S(6 + 3*x)**3, x) def test_GeneralizedTrinomialMatchQ(): assert not GeneralizedTrinomialMatchQ(7 + 2*x**6 + 3*x**12, x) assert not GeneralizedTrinomialMatchQ(7 + 2*x**6 + 3*x**3, x) assert not GeneralizedTrinomialMatchQ(7 + 2*x**6 + 3*x**5, x) assert GeneralizedTrinomialMatchQ(x**2 + x**3 + x**4, x) def test_QuotientOfLinearsMatchQ(): assert QuotientOfLinearsMatchQ((1 + x)*(3 + 4*x**2)/(2 + 4*x), x) assert not QuotientOfLinearsMatchQ(x*(3 + 4*x**2)/(2 + 4*x**3), x) assert QuotientOfLinearsMatchQ(x*(3 + 4*x)/(2 + 4*x), x) assert QuotientOfLinearsMatchQ(2*(3 + 4*x)/(2 + 4*x), x) def test_PolynomialTermQ(): assert not PolynomialTermQ(S(3), x) assert PolynomialTermQ(3*x**6, x) assert not PolynomialTermQ(3*x**6+5*x, x) def test_PolynomialTerms(): assert PolynomialTerms(x + 6*x**3 + log(x), x) == 6*x**3 + x assert PolynomialTerms(x + 6*x**3 + 6*x, x) == 6*x**3 + 7*x assert PolynomialTerms(x + 6*x**3 + 6, x) == 6*x**3 + x def test_NonpolynomialTerms(): assert NonpolynomialTerms(x + 6*x**3 + log(x), x) == log(x) assert NonpolynomialTerms(x + 6*x**3 + 6*x, x) == 0 assert NonpolynomialTerms(x + 6*x**3 + 6, x) == 6 def test_PseudoBinomialQ(): assert PseudoBinomialQ(3 + 5*(x)**6, x) assert PseudoBinomialQ(3 + 5*(2 + 5*x)**6, x) def test_PseudoBinomialParts(): assert PseudoBinomialParts(3 + 7*(1 + x)**6, x) == [3, 1, 7**(S(1)/S(6)), 7**(S(1)/S(6)), 6] assert PseudoBinomialParts(3 + 7*(1 + x)**3, x) == [3, 1, 7**(S(1)/S(3)), 7**(S(1)/S(3)), 3] assert not PseudoBinomialParts(3 + 7*(1 + x)**2, x) assert PseudoBinomialParts(3 + 7*(x)**5, x) == [3, 1, 0, 7**(S(1)/S(5)), 5] def test_PseudoBinomialPairQ(): assert not PseudoBinomialPairQ(3 + 5*(x)**6,3 + (x)**6, x) assert not PseudoBinomialPairQ(3 + 5*(1 + x)**6,3 + (1 + x)**6, x) def test_NormalizePseudoBinomial(): assert NormalizePseudoBinomial(3 + 5*(1 + x)**6, x) == 3+(5**(S(1)/S(6))+5**(S(1)/S(6))*x)**S(6) assert NormalizePseudoBinomial(3 + 5*(x)**6, x) == 3+5*x**6 def test_CancelCommonFactors(): assert CancelCommonFactors(S(x*y*S(6))**S(6), S(x*y*S(6))) == [46656*x**6*y**6, 6*x*y] assert CancelCommonFactors(S(y*6)**S(6), S(x*y*S(6))) == [46656*y**6, 6*x*y] assert CancelCommonFactors(S(6), S(3)) == [6, 3] def test_SimplerIntegrandQ(): assert SimplerIntegrandQ(S(5), 4*x, x) assert not SimplerIntegrandQ(S(x + 5*x**3), S(x**2 + 3*x), x) assert SimplerIntegrandQ(S(x + 8), S(x**2 + 3*x), x) def test_Drop(): assert Drop([1, 2, 3, 4, 5, 6], [2, 4]) == [1, 5, 6] assert Drop([1, 2, 3, 4, 5, 6], -3) == [1, 2, 3] assert Drop([1, 2, 3, 4, 5, 6], 2) == [3, 4, 5, 6] assert Drop(a*b*c, 1) == b*c def test_SubstForInverseFunction(): assert SubstForInverseFunction(x, a, b, x) == b assert SubstForInverseFunction(a, a, b, x) == a assert SubstForInverseFunction(x**a, x**a, b, x) == x assert SubstForInverseFunction(a*x**a, a, b, x) == a*b**a def test_SubstForFractionalPower(): assert SubstForFractionalPower(a, b, n, c, x) == a assert SubstForFractionalPower(x, b, n, c, x) == c assert SubstForFractionalPower(a**(S(1)/2), a, n, b, x) == x**(n/2) def test_CombineExponents(): assert True def test_FractionalPowerOfSquareQ(): assert not FractionalPowerOfSquareQ(x) assert not FractionalPowerOfSquareQ((a + b)**(S(2)/S(3))) assert not FractionalPowerOfSquareQ((a + b)**(S(2)/S(3))*c) assert FractionalPowerOfSquareQ(((a + b*x)**(S(2)))**(S(1)/3)) == (a + b*x)**S(2) def test_FractionalPowerSubexpressionQ(): assert not FractionalPowerSubexpressionQ(x, a, x) assert FractionalPowerSubexpressionQ(x**(S(2)/S(3)), a, x) assert not FractionalPowerSubexpressionQ(b*a, a, x) def test_FactorNumericGcd(): assert FactorNumericGcd(5*a**2*e**4 + 2*a*b*d*e**3 + 2*a*c*d**2*e**2 + b**2*d**2*e**2 - 6*b*c*d**3*e + 21*c**2*d**4) ==\ 5*a**2*e**4 + 2*a*b*d*e**3 + 2*a*c*d**2*e**2 + b**2*d**2*e**2 - 6*b*c*d**3*e + 21*c**2*d**4 assert FactorNumericGcd(x**(S(2))) == x**S(2) assert FactorNumericGcd(log(x)) == log(x) assert FactorNumericGcd(log(x)*x) == x*log(x) assert FactorNumericGcd(log(x) + x**S(2)) == log(x) + x**S(2) def test_Apply(): assert Apply(List, [a, b, c]) == [a, b, c] def test_TrigSimplify(): assert TrigSimplify(a*sin(x)**2 + a*cos(x)**2 + v) == a + v assert TrigSimplify(a*sec(x)**2 - a*tan(x)**2 + v) == a + v assert TrigSimplify(a*csc(x)**2 - a*cot(x)**2 + v) == a + v assert TrigSimplify(S(1) - sin(x)**2) == cos(x)**2 assert TrigSimplify(1 + tan(x)**2) == sec(x)**2 assert TrigSimplify(1 + cot(x)**2) == csc(x)**2 assert TrigSimplify(-S(1) + sec(x)**2) == tan(x)**2 assert TrigSimplify(-1 + csc(x)**2) == cot(x)**2 def test_MergeFactors(): assert simplify(MergeFactors(b/(a - c)**3 , 8*c**3*(b*x + c)**(3/2)/(3*b**4) - 24*c**2*(b*x + c)**(5/2)/(5*b**4) + \ 24*c*(b*x + c)**(7/2)/(7*b**4) - 8*(b*x + c)**(9/2)/(9*b**4)) - (8*c**3*(b*x + c)**1.5/(3*b**3) - 24*c**2*(b*x + c)**2.5/(5*b**3) + \ 24*c*(b*x + c)**3.5/(7*b**3) - 8*(b*x + c)**4.5/(9*b**3))/(a - c)**3) == 0 assert MergeFactors(x, x) == x**2 assert MergeFactors(x*y, x) == x**2*y def test_FactorInteger(): assert FactorInteger(2434500) == [(2, 2), (3, 2), (5, 3), (541, 1)] def test_ContentFactor(): assert ContentFactor(a*b + a*c) == a*(b + c) def test_Order(): assert Order(a, b) == 1 assert Order(b, a) == -1 assert Order(a, a) == 0 def test_FactorOrder(): assert FactorOrder(1, 1) == 0 assert FactorOrder(1, 2) == -1 assert FactorOrder(2, 1) == 1 assert FactorOrder(a, b) == 1 def test_Smallest(): assert Smallest([2, 1, 3, 4]) == 1 assert Smallest(1, 2) == 1 assert Smallest(-1, -2) == -2 def test_MostMainFactorPosition(): assert MostMainFactorPosition([S(1), S(2), S(3)]) == 1 assert MostMainFactorPosition([S(1), S(7), S(3), S(4), S(5)]) == 2 def test_OrderedQ(): assert OrderedQ([a, b]) assert not OrderedQ([b, a]) def test_MinimumDegree(): assert MinimumDegree(S(1), S(2)) == 1 assert MinimumDegree(S(1), sqrt(2)) == 1 assert MinimumDegree(sqrt(2), S(1)) == 1 assert MinimumDegree(sqrt(3), sqrt(2)) == sqrt(2) assert MinimumDegree(sqrt(2), sqrt(2)) == sqrt(2) def test_PositiveFactors(): assert PositiveFactors(S(0)) == 1 assert PositiveFactors(-S(1)) == S(1) assert PositiveFactors(sqrt(2)) == sqrt(2) assert PositiveFactors(-log(2)) == log(2) assert PositiveFactors(sqrt(2)*S(-1)) == sqrt(2) def test_NonpositiveFactors(): assert NonpositiveFactors(S(0)) == 0 assert NonpositiveFactors(-S(1)) == -1 assert NonpositiveFactors(sqrt(2)) == 1 assert NonpositiveFactors(-log(2)) == -1 def test_Sign(): assert Sign(S(0)) == 0 assert Sign(S(1)) == 1 assert Sign(-S(1)) == -1 def test_PolynomialInQ(): v = log(x) assert PolynomialInQ(S(1), v, x) assert PolynomialInQ(v, v, x) assert PolynomialInQ(1 + v**2, v, x) assert PolynomialInQ(1 + a*v**2, v, x) assert not PolynomialInQ(sqrt(v), v, x) def test_ExponentIn(): v = log(x) assert ExponentIn(S(1), log(x), x) == 0 assert ExponentIn(S(1) + v, log(x), x) == 1 assert ExponentIn(S(1) + v + v**3, log(x), x) == 3 assert ExponentIn(S(2)*sqrt(v)*v**3, log(x), x) == 3.5 def test_PolynomialInSubst(): v = log(x) assert PolynomialInSubst(S(1) + log(x)**3, log(x), x) == 1 + x**3 assert PolynomialInSubst(S(1) + log(x), log(x), x) == x + 1 def test_Distrib(): assert Distrib(x, a) == x*a assert Distrib(x, a + b) == a*x + b*x def test_DistributeDegree(): assert DistributeDegree(x, m) == x**m assert DistributeDegree(x**a, m) == x**(a*m) assert DistributeDegree(a*b, m) == a**m * b**m def test_FunctionOfPower(): assert FunctionOfPower(a, x) == None assert FunctionOfPower(x, x) == 1 assert FunctionOfPower(x**3, x) == 3 assert FunctionOfPower(x**3*cos(x**6), x) == 3 def test_DivideDegreesOfFactors(): assert DivideDegreesOfFactors(a**b, S(3)) == a**(b/3) assert DivideDegreesOfFactors(a**b*c, S(3)) == a**(b/3)*c**(c/3) def test_MonomialFactor(): assert MonomialFactor(a, x) == [0, a] assert MonomialFactor(x, x) == [1, 1] assert MonomialFactor(x + y, x) == [0, x + y] assert MonomialFactor(log(x), x) == [0, log(x)] assert MonomialFactor(log(x)*x, x) == [1, log(x)] def test_NormalizeIntegrand(): assert NormalizeIntegrand((x**2 + 8), x) == x**2 + 8 assert NormalizeIntegrand((x**2 + 3*x)**2, x) == x**2*(x + 3)**2 assert NormalizeIntegrand(a**2*(a + b*x)**2, x) == a**2*(a + b*x)**2 assert NormalizeIntegrand(b**2/(a**2*(a + b*x)**2), x) == b**2/(a**2*(a + b*x)**2) def test_NormalizeIntegrandAux(): v = (6*A*a*c - 2*A*b**2 + B*a*b)/(a*x**2) - (6*A*a**2*c**2 - 10*A*a*b**2*c - 8*A*a*b*c**2*x + 2*A*b**4 + 2*A*b**3*c*x + 5*B*a**2*b*c + 4*B*a**2*c**2*x - B*a*b**3 - B*a*b**2*c*x)/(a**2*(a + b*x + c*x**2)) + (-2*A*b + B*a)*(4*a*c - b**2)/(a**2*x) assert NormalizeIntegrandAux(v, x) == (6*A*a*c - 2*A*b**2 + B*a*b)/(a*x**2) - (6*A*a**2*c**2 - 10*A*a*b**2*c + 2*A*b**4 + 5*B*a**2*b*c - B*a*b**3 + x*(-8*A*a*b*c**2 + 2*A*b**3*c + 4*B*a**2*c**2 - B*a*b**2*c))/(a**2*(a + b*x + c*x**2)) + (-2*A*b + B*a)*(4*a*c - b**2)/(a**2*x) assert NormalizeIntegrandAux((x**2 + 3*x)**2, x) == x**2*(x + 3)**2 assert NormalizeIntegrandAux((x**2 + 8), x) == x**2 + 8 def test_NormalizeIntegrandFactor(): assert NormalizeIntegrandFactor((3*x + x**3)**2, x) == x**2*(x**2 + 3)**2 assert NormalizeIntegrandFactor((x**2 + 8), x) == x**2 + 8 def test_NormalizeIntegrandFactorBase(): assert NormalizeIntegrandFactorBase((x**2 + 8)**3, x) == (x**2 + 8)**3 assert NormalizeIntegrandFactorBase((x**2 + 8), x) == x**2 + 8 assert NormalizeIntegrandFactorBase(a**2*(a + b*x)**2, x) == a**2*(a + b*x)**2 def test_AbsorbMinusSign(): assert AbsorbMinusSign((x + 2)**5*(x + 3)**5) == (-x - 3)**5*(x + 2)**5 assert AbsorbMinusSign((x + 2)**5*(x + 3)**2) == -(x + 2)**5*(x + 3)**2 def test_NormalizeLeadTermSigns(): assert NormalizeLeadTermSigns((-x + 3)*(x**2 + 3)) == (-x + 3)*(x**2 + 3) assert NormalizeLeadTermSigns(x + 3) == x + 3 def test_SignOfFactor(): assert SignOfFactor(S(-x + 3)) == [1, -x + 3] assert SignOfFactor(S(-x)) == [-1, x] def test_NormalizePowerOfLinear(): assert NormalizePowerOfLinear((x + 3)**5, x) == (x + 3)**5 assert NormalizePowerOfLinear(((x + 3)**2) + 3, x) == x**2 + 6*x + 12 def test_SimplifyIntegrand(): assert SimplifyIntegrand((x**2 + 3)**2, x) == (x**2 + 3)**2 assert SimplifyIntegrand(x**2 + 3 + (x**6) + 6, x) == x**6 + x**2 + 9 def test_SimplifyTerm(): assert SimplifyTerm(a**2/b**2, x) == a**2/b**2 assert SimplifyTerm(-6*x/5 + (5*x + 3)**2/25 - 9/25, x) == x**2 def test_togetherSimplify(): assert TogetherSimplify(-6*x/5 + (5*x + 3)**2/25 - 9/25) == x**2 def test_ExpandToSum(): qq = 6 Pqq = e**3 Pq = (d+e*x**2)**3 aa = 2 nn = 2 cc = 1 pp = -1/2 bb = 3 assert nsimplify(ExpandToSum(Pq - Pqq*x**qq - Pqq*(aa*x**(-2*nn + qq)*(-2*nn + qq + 1) + bb*x**(-nn + qq)*(nn*(pp - 1) + qq + 1))/(cc*(2*nn*pp + qq + 1)), x) - \ (d**3 + x**4*(3*d*e**2 - 2.4*e**3) + x**2*(3*d**2*e - 1.2*e**3))) == 0 assert ExpandToSum(x**2 + 3*x + 3, x**3 + 3, x) == x**3*(x**2 + 3*x + 3) + 3*x**2 + 9*x + 9 assert ExpandToSum(x**3 + 6, x) == x**3 + 6 assert ExpandToSum(S(x**2 + 3*x + 3)*3, x) == 3*x**2 + 9*x + 9 assert ExpandToSum((a + b*x), x) == a + b*x def test_UnifySum(): assert UnifySum((3 + x + 6*x**3 + sin(x)), x) == 6*x**3 + x + sin(x) + 3 assert UnifySum((3 + x + 6*x**3)*3, x) == 18*x**3 + 3*x + 9 def test_FunctionOfInverseLinear(): assert FunctionOfInverseLinear((x)/(a + b*x), x) == [a, b] assert FunctionOfInverseLinear((c + d*x)/(a + b*x), x) == [a, b] assert not FunctionOfInverseLinear(1/(a + b*x), x) def test_PureFunctionOfSinhQ(): v = log(x) f = sinh(v) assert PureFunctionOfSinhQ(f, v, x) assert not PureFunctionOfSinhQ(cosh(v), v, x) assert PureFunctionOfSinhQ(f**2, v, x) def test_PureFunctionOfTanhQ(): v = log(x) f = tanh(v) assert PureFunctionOfTanhQ(f, v, x) assert not PureFunctionOfTanhQ(cosh(v), v, x) assert PureFunctionOfTanhQ(f**2, v, x) def test_PureFunctionOfCoshQ(): v = log(x) f = cosh(v) assert PureFunctionOfCoshQ(f, v, x) assert not PureFunctionOfCoshQ(sinh(v), v, x) assert PureFunctionOfCoshQ(f**2, v, x) def test_IntegerQuotientQ(): u = S(2)*sin(x) v = sin(x) assert IntegerQuotientQ(u, v) assert IntegerQuotientQ(u, u) assert not IntegerQuotientQ(S(1), S(2)) def test_OddQuotientQ(): u = S(3)*sin(x) v = sin(x) assert OddQuotientQ(u, v) assert OddQuotientQ(u, u) assert not OddQuotientQ(S(1), S(2)) def test_EvenQuotientQ(): u = S(2)*sin(x) v = sin(x) assert EvenQuotientQ(u, v) assert not EvenQuotientQ(u, u) assert not EvenQuotientQ(S(1), S(2)) def test_FunctionOfSinhQ(): v = log(x) assert FunctionOfSinhQ(cos(sinh(v)), v, x) assert FunctionOfSinhQ(sinh(v), v, x) assert FunctionOfSinhQ(sinh(v)*cos(sinh(v)), v, x) def test_FunctionOfCoshQ(): v = log(x) assert FunctionOfCoshQ(cos(cosh(v)), v, x) assert FunctionOfCoshQ(cosh(v), v, x) assert FunctionOfCoshQ(cosh(v)*cos(cosh(v)), v, x) def test_FunctionOfTanhQ(): v = log(x) t = Tanh(v) c = Coth(v) assert FunctionOfTanhQ(t, v, x) assert FunctionOfTanhQ(c, v, x) assert FunctionOfTanhQ(t + c, v, x) assert FunctionOfTanhQ(t*c, v, x) assert not FunctionOfTanhQ(sin(x), v, x) def test_FunctionOfTanhWeight(): v = log(x) t = Tanh(v) c = Coth(v) assert FunctionOfTanhWeight(x, v, x) == 0 assert FunctionOfTanhWeight(sinh(v), v, x) == 0 assert FunctionOfTanhWeight(tanh(v), v, x) == 1 assert FunctionOfTanhWeight(coth(v), v, x) == -1 assert FunctionOfTanhWeight(t**2, v, x) == 1 assert FunctionOfTanhWeight(sinh(v)**2, v, x) == -1 assert FunctionOfTanhWeight(coth(v)*sinh(v)**2, v, x) == -2 def test_FunctionOfHyperbolicQ(): v = log(x) s = Sinh(v) t = Tanh(v) assert not FunctionOfHyperbolicQ(x, v, x) assert FunctionOfHyperbolicQ(s + t, v, x) assert FunctionOfHyperbolicQ(sinh(t), v, x) def test_SmartNumerator(): assert SmartNumerator(x**(-2)) == 1 assert SmartNumerator(x**(2)*a) == x**2*a def test_SmartDenominator(): assert SmartDenominator(x**(-2)) == x**2 assert SmartDenominator(x**(-2)*1/S(3)) == x**2*3 def test_SubstForAux(): v = log(x) assert SubstForAux(v, v, x) == x assert SubstForAux(v**2, v, x) == x**2 assert SubstForAux(x, v, x) == x assert SubstForAux(v**2, v**4, x) == sqrt(x) assert SubstForAux(v**2*v, v, x) == x**3 def test_SubstForTrig(): v = log(x) s, c, t = sin(v), cos(v), tan(v) assert SubstForTrig(cos(a/2 + b*x/2), x/sqrt(x**2 + 1), 1/sqrt(x**2 + 1), a/2 + b*x/2, x) == 1/sqrt(x**2 + 1) assert SubstForTrig(s, sin, cos, v, x) == sin assert SubstForTrig(t, sin(v), cos(v), v, x) == sin(log(x))/cos(log(x)) assert SubstForTrig(sin(2*v), sin(x), cos(x), v, x) == 2*sin(x)*cos(x) assert SubstForTrig(s*t, sin(x), cos(x), v, x) == sin(x)**2/cos(x) def test_SubstForHyperbolic(): v = log(x) s, c, t = sinh(v), cosh(v), tanh(v) assert SubstForHyperbolic(s, sinh(x), cosh(x), v, x) == sinh(x) assert SubstForHyperbolic(t, sinh(x), cosh(x), v, x) == sinh(x)/cosh(x) assert SubstForHyperbolic(sinh(2*v), sinh(x), cosh(x), v, x) == 2*sinh(x)*cosh(x) assert SubstForHyperbolic(s*t, sinh(x), cosh(x), v, x) == sinh(x)**2/cosh(x) def test_SubstForFractionalPowerOfLinear(): u = a + b*x assert not SubstForFractionalPowerOfLinear(u, x) assert not SubstForFractionalPowerOfLinear(u**(S(2)), x) assert SubstForFractionalPowerOfLinear(u**(S(1)/2), x) == [x**2, 2, a + b*x, 1/b] def test_InverseFunctionOfLinear(): u = a + b*x assert InverseFunctionOfLinear(log(u)*sin(x), x) == log(u) assert InverseFunctionOfLinear(log(u), x) == log(u) def test_InertTrigQ(): s = sin(x) c = cos(x) assert not InertTrigQ(sin(x), csc(x), cos(h)) assert InertTrigQ(sin(x), csc(x)) assert not InertTrigQ(s, c) assert InertTrigQ(c) def test_PowerOfInertTrigSumQ(): func = sin assert PowerOfInertTrigSumQ((1 + S(2)*(S(3)*func(x**2))**S(5))**3, func, x) assert PowerOfInertTrigSumQ((1 + 2*(S(3)*func(x**2))**3 + 4*(S(5)*func(x**2))**S(3))**2, func, x) def test_PiecewiseLinearQ(): assert PiecewiseLinearQ(a + b*x, x) assert not PiecewiseLinearQ(Log(c*sin(a)**S(3)), x) assert not PiecewiseLinearQ(x**3, x) assert PiecewiseLinearQ(atanh(tanh(a + b*x)), x) assert PiecewiseLinearQ(tanh(atanh(a + b*x)), x) assert not PiecewiseLinearQ(coth(atanh(a + b*x)), x) def test_KnownTrigIntegrandQ(): func = sin(a + b*x) assert KnownTrigIntegrandQ([sin], S(1), x) assert KnownTrigIntegrandQ([sin], (a + b*func)**m, x) assert KnownTrigIntegrandQ([sin], (a + b*func)**m*(1 + 2*func), x) assert KnownTrigIntegrandQ([sin], a + c*func**2, x) assert KnownTrigIntegrandQ([sin], a + b*func + c*func**2, x) assert KnownTrigIntegrandQ([sin], (a + b*func)**m*(c + d*func**2), x) assert KnownTrigIntegrandQ([sin], (a + b*func)**m*(c + d*func + e*func**2), x) assert not KnownTrigIntegrandQ([cos], (a + b*func)**m, x) def test_KnownSineIntegrandQ(): assert KnownSineIntegrandQ((a + b*sin(a + b*x))**m, x) def test_KnownTangentIntegrandQ(): assert KnownTangentIntegrandQ((a + b*tan(a + b*x))**m, x) def test_KnownCotangentIntegrandQ(): assert KnownCotangentIntegrandQ((a + b*cot(a + b*x))**m, x) def test_KnownSecantIntegrandQ(): assert KnownSecantIntegrandQ((a + b*sec(a + b*x))**m, x) def test_TryPureTanSubst(): assert TryPureTanSubst(atan(c*(a + b*tan(a + b*x))), x) assert TryPureTanSubst(atanh(c*(a + b*cot(a + b*x))), x) assert not TryPureTanSubst(tan(c*(a + b*cot(a + b*x))), x) def test_TryPureTanhSubst(): assert not TryPureTanhSubst(log(x), x) assert TryPureTanhSubst(sin(x), x) assert not TryPureTanhSubst(atanh(a*tanh(x)), x) assert not TryPureTanhSubst((a + b*x)**S(2), x) def test_TryTanhSubst(): assert not TryTanhSubst(log(x), x) assert not TryTanhSubst(a*(b + c)**3, x) assert not TryTanhSubst(1/(a + b*sinh(x)**S(3)), x) assert not TryTanhSubst(sinh(S(3)*x)*cosh(S(4)*x), x) assert not TryTanhSubst(a*(b*sech(x)**3)**c, x) def test_GeneralizedBinomialQ(): assert GeneralizedBinomialQ(a*x**q + b*x**n, x) assert not GeneralizedBinomialQ(a*x**q, x) def test_GeneralizedTrinomialQ(): assert not GeneralizedTrinomialQ(7 + 2*x**6 + 3*x**12, x) assert not GeneralizedTrinomialQ(a*x**q + c*x**(2*n-q), x) def test_SubstForFractionalPowerOfQuotientOfLinears(): assert SubstForFractionalPowerOfQuotientOfLinears(((a + b*x)/(c + d*x))**(S(3)/2), x) == [x**4/(b - d*x**2)**2, 2, (a + b*x)/(c + d*x), -a*d + b*c] def test_SubstForFractionalPowerQ(): assert SubstForFractionalPowerQ(x, sin(x), x) assert SubstForFractionalPowerQ(x**2, sin(x), x) assert not SubstForFractionalPowerQ(x**(S(3)/2), sin(x), x) assert SubstForFractionalPowerQ(sin(x)**(S(3)/2), sin(x), x) def test_AbsurdNumberGCD(): assert AbsurdNumberGCD(S(4)) == 4 assert AbsurdNumberGCD(S(4), S(8), S(12)) == 4 assert AbsurdNumberGCD(S(2), S(3), S(12)) == 1 def test_TrigReduce(): assert TrigReduce(cos(x)**2) == cos(2*x)/2 + 1/2 assert TrigReduce(cos(x)**2*sin(x)) == sin(x)/4 + sin(3*x)/4 assert TrigReduce(cos(x)**2+sin(x)) == sin(x) + cos(2*x)/2 + 1/2 assert TrigReduce(cos(x)**2*sin(x)**5) == 5*sin(x)/64 + sin(3*x)/64 - 3*sin(5*x)/64 + sin(7*x)/64 assert TrigReduce(2*sin(x)*cos(x) + 2*cos(x)**2) == sin(2*x) + cos(2*x) + 1 assert TrigReduce(sinh(a + b*x)**2) == cosh(2*a + 2*b*x)/2 - 1/2 assert TrigReduce(sinh(a + b*x)*cosh(a + b*x)) == sinh(2*a + 2*b*x)/2 def test_FunctionOfDensePolynomialsQ(): assert FunctionOfDensePolynomialsQ(x**2 + 3, x) assert not FunctionOfDensePolynomialsQ(x**2, x) assert not FunctionOfDensePolynomialsQ(x, x) assert FunctionOfDensePolynomialsQ(S(2), x) def test_PureFunctionOfSinQ(): v = log(x) f = sin(v) assert PureFunctionOfSinQ(f, v, x) assert not PureFunctionOfSinQ(cos(v), v, x) assert PureFunctionOfSinQ(f**2, v, x) def test_PureFunctionOfTanQ(): v = log(x) f = tan(v) assert PureFunctionOfTanQ(f, v, x) assert not PureFunctionOfTanQ(cos(v), v, x) assert PureFunctionOfTanQ(f**2, v, x) def test_PowerVariableSubst(): assert PowerVariableSubst((2*x)**3, 2, x) == 8*x**(3/2) assert PowerVariableSubst((2*x)**3, 2, x) == 8*x**(3/2) assert PowerVariableSubst((2*x), 2, x) == 2*x assert PowerVariableSubst((2*x)**3, 2, x) == 8*x**(3/2) assert PowerVariableSubst((2*x)**7, 2, x) == 128*x**(7/2) assert PowerVariableSubst((6+2*x)**7, 2, x) == (2*x + 6)**7 assert PowerVariableSubst((2*x)**7+3, 2, x) == 128*x**(7/2) + 3 def test_PowerVariableDegree(): assert PowerVariableDegree(S(2), 0, 2*x, x) == [0, 2*x] assert PowerVariableDegree((2*x)**2, 0, 2*x, x) == [2, 1] assert PowerVariableDegree(x**2, 0, 2*x, x) == [2, 1] assert PowerVariableDegree(S(4), 0, 2*x, x) == [0, 2*x] def test_PowerVariableExpn(): assert not PowerVariableExpn((x)**3, 2, x) assert not PowerVariableExpn((2*x)**3, 2, x) assert PowerVariableExpn((2*x)**2, 4, x) == [4*x**3, 2, 1] def test_FunctionOfQ(): assert FunctionOfQ(x**2, sqrt(-exp(2*x**2) + 1)*exp(x**2),x) assert not FunctionOfQ(S(x**3), x*2, x) assert FunctionOfQ(S(a), x*2, x) assert FunctionOfQ(S(3*x), x*2, x) def test_ExpandTrigExpand(): assert ExpandTrigExpand(1, cos(x), x**2, 2, 2, x) == 4*cos(x**2)**4 - 4*cos(x**2)**2 + 1 assert ExpandTrigExpand(1, cos(x) + sin(x), x**2, 2, 2, x) == 4*sin(x**2)**2*cos(x**2)**2 + 8*sin(x**2)*cos(x**2)**3 - 4*sin(x**2)*cos(x**2) + 4*cos(x**2)**4 - 4*cos(x**2)**2 + 1 def test_TrigToExp(): from sympy.integrals.rubi.utility_function import rubi_exp as exp assert TrigToExp(sin(x)) == -I*(exp(I*x) - exp(-I*x))/2 assert TrigToExp(cos(x)) == exp(I*x)/2 + exp(-I*x)/2 assert TrigToExp(cos(x)*tan(x**2)) == I*(exp(I*x)/2 + exp(-I*x)/2)*(-exp(I*x**2) + exp(-I*x**2))/(exp(I*x**2) + exp(-I*x**2)) assert TrigToExp(cos(x) + sin(x)**2) == -(exp(I*x) - exp(-I*x))**2/4 + exp(I*x)/2 + exp(-I*x)/2 assert Simplify(TrigToExp(cos(x)*tan(x**S(2))*sin(x)**S(2))-(-I*(exp(I*x)/S(2) + exp(-I*x)/S(2))*(exp(I*x) - exp(-I*x))**S(2)*(-exp(I*x**S(2)) + exp(-I*x**S(2)))/(S(4)*(exp(I*x**S(2)) + exp(-I*x**S(2)))))) == 0 def test_ExpandTrigReduce(): assert ExpandTrigReduce(2*cos(3 + x)**3, x) == 3*cos(x + 3)/2 + cos(3*x + 9)/2 assert ExpandTrigReduce(2*sin(x)**3+cos(2 + x), x) == 3*sin(x)/2 - sin(3*x)/2 + cos(x + 2) assert ExpandTrigReduce(cos(x + 3)**2, x) == cos(2*x + 6)/2 + 1/2 def test_NormalizeTrig(): assert NormalizeTrig(S(2*sin(2 + x)), x) == 2*sin(x + 2) assert NormalizeTrig(S(2*sin(2 + x)**3), x) == 2*sin(x + 2)**3 assert NormalizeTrig(S(2*sin((2 + x)**2)**3), x) == 2*sin(x**2 + 4*x + 4)**3 def test_FunctionOfTrigQ(): v = log(x) s = sin(v) t = tan(v) assert not FunctionOfTrigQ(x, v, x) assert FunctionOfTrigQ(s + t, v, x) assert FunctionOfTrigQ(sin(t), v, x) def test_RationalFunctionExpand(): assert RationalFunctionExpand(x**S(5)*(e + f*x)**n/(a + b*x**S(3)), x) == -a*x**2*(e + f*x)**n/(b*(a + b*x**3)) +\ e**2*(e + f*x)**n/(b*f**2) - 2*e*(e + f*x)**(n + 1)/(b*f**2) + (e + f*x)**(n + 2)/(b*f**2) assert RationalFunctionExpand(x**S(3)*(S(2)*x + 2)**S(2)/(2*x**2 + 1), x) == 2*x**3 + 4*x**2 + x + (- x + 2)/(2*x**2 + 1) - 2 assert RationalFunctionExpand((a + b*x + c*x**4)*log(x)**3, x) == a*log(x)**3 + b*x*log(x)**3 + c*x**4*log(x)**3 assert RationalFunctionExpand(a + b*x + c*x**4, x) == a + b*x + c*x**4 def test_SameQ(): assert SameQ(1, 1, 1) assert not SameQ(1, 1, 2) def test_Map2(): assert Map2(Add, [a, b, c], [x, y, z]) == [a + x, b + y, c + z] def test_ConstantFactor(): assert ConstantFactor(a + a*x**3, x) == [a, x**3 + 1] assert ConstantFactor(a, x) == [a, 1] assert ConstantFactor(x, x) == [1, x] assert ConstantFactor(x**S(3), x) == [1, x**3] assert ConstantFactor(x**(S(3)/2), x) == [1, x**(3/2)] assert ConstantFactor(a*x**3, x) == [a, x**3] assert ConstantFactor(a + x**3, x) == [1, a + x**3] def test_CommonFactors(): assert CommonFactors([a, a, a]) == [a, 1, 1, 1] assert CommonFactors([x*S(2), x**S(3)*S(2), sin(x)*x*S(2)]) == [2, x, x**3, x*sin(x)] assert CommonFactors([x, x**S(3), sin(x)*x]) == [1, x, x**3, x*sin(x)] assert CommonFactors([S(2), S(4), S(6)]) == [2, 1, 2, 3] def test_FunctionOfLinear(): f = sin(a + b*x) assert FunctionOfLinear(f, x) == [sin(x), a, b] assert FunctionOfLinear(a + b*x, x) == [x, a, b] assert not FunctionOfLinear(a, x) def test_FunctionOfExponentialQ(): assert FunctionOfExponentialQ(exp(x + exp(x) + exp(exp(x))), x) assert FunctionOfExponentialQ(a**(a + b*x), x) assert FunctionOfExponentialQ(a**(b*x), x) assert not FunctionOfExponentialQ(a**sin(a + b*x), x) def test_FunctionOfExponential(): assert FunctionOfExponential(a**(a + b*x), x) def test_FunctionOfExponentialFunction(): assert FunctionOfExponentialFunction(a**(a + b*x), x) == x assert FunctionOfExponentialFunction(S(2)*a**(a + b*x), x) == 2*x def test_FunctionOfTrig(): assert FunctionOfTrig(sin(x + 1), x + 1, x) == x + 1 assert FunctionOfTrig(sin(x), x) == x assert not FunctionOfTrig(cos(x**2 + 1), x) assert FunctionOfTrig(sin(a+b*x)**3, x) == a+b*x def test_AlgebraicTrigFunctionQ(): assert AlgebraicTrigFunctionQ(sin(x + 3), x) assert AlgebraicTrigFunctionQ(x, x) assert AlgebraicTrigFunctionQ(x + 1, x) assert AlgebraicTrigFunctionQ(sinh(x + 1), x) assert AlgebraicTrigFunctionQ(sinh(x + 1)**2, x) assert not AlgebraicTrigFunctionQ(sinh(x**2 + 1)**2, x) def test_FunctionOfHyperbolic(): assert FunctionOfTrig(sin(x + 1), x + 1, x) == x + 1 assert FunctionOfTrig(sin(x), x) == x assert not FunctionOfTrig(cos(x**2 + 1), x) def test_FunctionOfExpnQ(): assert FunctionOfExpnQ(x, x, x) == 1 assert FunctionOfExpnQ(x**2, x, x) == 2 assert FunctionOfExpnQ(x**2.1, x, x) == 1 assert not FunctionOfExpnQ(x, x**2, x) assert not FunctionOfExpnQ(x + 1, (x + 5)**2, x) assert not FunctionOfExpnQ(x + 1, (x + 1)**2, x) def test_PureFunctionOfCosQ(): v = log(x) f = cos(v) assert PureFunctionOfCosQ(f, v, x) assert not PureFunctionOfCosQ(sin(v), v, x) assert PureFunctionOfCosQ(f**2, v, x) def test_PureFunctionOfCotQ(): v = log(x) f = cot(v) assert PureFunctionOfCotQ(f, v, x) assert not PureFunctionOfCotQ(sin(v), v, x) assert PureFunctionOfCotQ(f**2, v, x) def test_FunctionOfSinQ(): v = log(x) assert FunctionOfSinQ(cos(sin(v)), v, x) assert FunctionOfSinQ(sin(v), v, x) assert FunctionOfSinQ(sin(v)*cos(sin(v)), v, x) def test_FunctionOfCosQ(): v = log(x) assert FunctionOfCosQ(cos(cos(v)), v, x) assert FunctionOfCosQ(cos(v), v, x) assert FunctionOfCosQ(cos(v)*cos(cos(v)), v, x) def test_FunctionOfTanQ(): v = log(x) t = tan(v) c = cot(v) assert FunctionOfTanQ(t, v, x) assert FunctionOfTanQ(c, v, x) assert FunctionOfTanQ(t + c, v, x) assert FunctionOfTanQ(t*c, v, x) assert not FunctionOfTanQ(sin(x), v, x) def test_FunctionOfTanWeight(): v = log(x) t = tan(v) c = cot(v) assert FunctionOfTanWeight(x, v, x) == 0 assert FunctionOfTanWeight(sin(v), v, x) == 0 assert FunctionOfTanWeight(tan(v), v, x) == 1 assert FunctionOfTanWeight(cot(v), v, x) == -1 assert FunctionOfTanWeight(t**2, v, x) == 1 assert FunctionOfTanWeight(sin(v)**2, v, x) == -1 assert FunctionOfTanWeight(cot(v)*sin(v)**2, v, x) == -2 def test_OddTrigPowerQ(): assert not OddTrigPowerQ(sin(x)**3, 1, x) assert OddTrigPowerQ(sin(3),1,x) assert OddTrigPowerQ(sin(3*x),x,x) assert OddTrigPowerQ(sin(3*x)**3,x,x) def test_FunctionOfLog(): assert not FunctionOfLog(x**2*(a + b*x)**3*exp(-a - b*x) ,False, False, x) assert FunctionOfLog(log(2*x**8)*2 + log(2*x**8) + 1, x) == [3*x + 1, 2*x**8, 8] assert FunctionOfLog(log(2*x)**2,x) == [x**2, 2*x, 1] assert FunctionOfLog(log(3*x**3)**2 + 1,x) == [x**2 + 1, 3*x**3, 3] assert FunctionOfLog(log(2*x**8)*2,x) == [2*x, 2*x**8, 8] assert not FunctionOfLog(2*sin(x)*2,x) def test_EulerIntegrandQ(): assert EulerIntegrandQ((2*x + 3*((x + 1)**3)**1.5)**(-3), x) assert not EulerIntegrandQ((2*x + (2*x**2)**2)**3, x) assert not EulerIntegrandQ(3*x**2 + 5*x + 1, x) def test_Divides(): assert not Divides(x, a*x**2, x) assert Divides(x, a*x, x) == a def test_EasyDQ(): assert EasyDQ(3*x**2, x) assert EasyDQ(3*x**3 - 6, x) assert EasyDQ(x**3, x) assert EasyDQ(sin(x**log(3)), x) def test_ProductOfLinearPowersQ(): assert ProductOfLinearPowersQ(S(1), x) assert ProductOfLinearPowersQ((x + 1)**3, x) assert not ProductOfLinearPowersQ((x**2 + 1)**3, x) assert ProductOfLinearPowersQ(x + 1, x) def test_Rt(): b = symbols('b') assert Rt(-b**2, 4) == (-b**2)**(S(1)/S(4)) assert Rt(x**2, 2) == x assert Rt(S(2 + 3*I), S(8)) == (2 + 3*I)**(1/8) assert Rt(x**2 + 4 + 4*x, 2) == x + 2 assert Rt(S(8), S(3)) == 2 assert Rt(S(16807), S(5)) == 7 def test_NthRoot(): assert NthRoot(S(14580), S(3)) == 9*2**(S(2)/S(3))*5**(S(1)/S(3)) assert NthRoot(9, 2) == 3.0 assert NthRoot(81, 2) == 9.0 assert NthRoot(81, 4) == 3.0 def test_AtomBaseQ(): assert not AtomBaseQ(x**2) assert AtomBaseQ(x**3) assert AtomBaseQ(x) assert AtomBaseQ(S(2)**3) assert not AtomBaseQ(sin(x)) def test_SumBaseQ(): assert not SumBaseQ((x + 1)**2) assert SumBaseQ((x + 1)**3) assert SumBaseQ((3*x+3)) assert not SumBaseQ(x) def test_NegSumBaseQ(): assert not NegSumBaseQ(-x + 1) assert NegSumBaseQ(x - 1) assert not NegSumBaseQ((x - 1)**2) assert NegSumBaseQ((x - 1)**3) def test_AllNegTermQ(): x = Symbol('x', negative=True) assert AllNegTermQ(x) assert not AllNegTermQ(x + 2) assert AllNegTermQ(x - 2) assert AllNegTermQ((x - 2)**3) assert not AllNegTermQ((x - 2)**2) def test_TrigSquareQ(): assert TrigSquareQ(sin(x)**2) assert TrigSquareQ(cos(x)**2) assert not TrigSquareQ(tan(x)**2) def test_Inequality(): assert not Inequality(S('0'), Less, m, LessEqual, S('1')) assert Inequality(S('0'), Less, S('1')) assert Inequality(S('0'), Less, S('1'), LessEqual, S('5')) def test_SplitProduct(): assert SplitProduct(OddQ, S(3)*x) == [3, x] assert not SplitProduct(OddQ, S(2)*x) def test_SplitSum(): assert SplitSum(FracPart, sin(x)) == [sin(x), 0] assert SplitSum(FracPart, sin(x) + S(2)) == [sin(x), S(2)] def test_Complex(): assert Complex(a, b) == a + I*b def test_SimpFixFactor(): assert SimpFixFactor((a*c + b*c)**S(4), x) == (a*c + b*c)**4 assert SimpFixFactor((a*Complex(0, c) + b*Complex(0, d))**S(3), x) == -I*(a*c + b*d)**3 assert SimpFixFactor((a*Complex(0, d) + b*Complex(0, e) + c*Complex(0, f))**S(2), x) == -(a*d + b*e + c*f)**2 assert SimpFixFactor((a + b*x**(-1/S(2))*x**S(3))**S(3), x) == (a + b*x**(5/2))**3 assert SimpFixFactor((a*c + b*c**S(2)*x**S(2))**S(3), x) == c**3*(a + b*c*x**2)**3 assert SimpFixFactor((a*c**S(2) + b*c**S(1)*x**S(2))**S(3), x) == c**3*(a*c + b*x**2)**3 assert SimpFixFactor(a*cos(x)**2 + a*sin(x)**2 + v, x) == a*cos(x)**2 + a*sin(x)**2 + v def test_SimplifyAntiderivative(): assert SimplifyAntiderivative(acoth(coth(x)), x) == x assert SimplifyAntiderivative(a*x, x) == a*x assert SimplifyAntiderivative(atanh(cot(x)), x) == atanh(2*sin(x)*cos(x))/2 assert SimplifyAntiderivative(a*cos(x)**2 + a*sin(x)**2 + v, x) == a*cos(x)**2 + a*sin(x)**2 def test_FixSimplify(): assert FixSimplify(x*Complex(0, a)*(v*Complex(0, b) + w)**S(3)) == a*x*(b*v - I*w)**3 def test_TrigSimplifyAux(): assert TrigSimplifyAux(a*cos(x)**2 + a*sin(x)**2 + v) == a + v assert TrigSimplifyAux(x**2) == x**2 def test_SubstFor(): assert SubstFor(x**2 + 1, tanh(x), x) == tanh(x) assert SubstFor(x**2, sinh(x), x) == sinh(sqrt(x)) def test_FresnelS(): assert FresnelS(oo) == 1/2 assert FresnelS(0) == 0 def test_FresnelC(): assert FresnelC(0) == 0 assert FresnelC(oo) == 1/2 def test_Erfc(): assert Erfc(0) == 1 assert Erfc(oo) == 0 def test_Erfi(): assert Erfi(oo) == oo assert Erfi(0) == 0 def test_Gamma(): assert Gamma(u) == gamma(u) def test_ElementaryFunctionQ(): assert ElementaryFunctionQ(x + y) assert ElementaryFunctionQ(sin(x + y)) assert ElementaryFunctionQ(E**(x*a)) def test_Util_Part(): from sympy.integrals.rubi.utility_function import Util_Part assert Util_Part(1, a + b).doit() == a assert Util_Part(c, a + b).doit() == Util_Part(c, a + b) def test_Part(): assert Part([1, 2, 3], 1) == 1 assert Part(a*b, 1) == a def test_PolyLog(): assert PolyLog(a, b) == polylog(a, b) def test_PureFunctionOfCothQ(): v = log(x) assert PureFunctionOfCothQ(coth(v), v, x) assert PureFunctionOfCothQ(a + coth(v), v, x) assert not PureFunctionOfCothQ(sin(v), v, x) def test_ExpandIntegrand(): assert ExpandIntegrand(sqrt(a + b*x**S(2) + c*x**S(4)), (f*x)**(S(3)/2)*(d + e*x**S(2)), x) == \ d*(f*x)**(3/2)*sqrt(a + b*x**2 + c*x**4) + e*(f*x)**(7/2)*sqrt(a + b*x**2 + c*x**4)/f**2 assert ExpandIntegrand((6*A*a*c - 2*A*b**2 + B*a*b - 2*c*x*(A*b - 2*B*a))/(x**2*(a + b*x + c*x**2)), x) == \ (6*A*a*c - 2*A*b**2 + B*a*b)/(a*x**2) + (-6*A*a**2*c**2 + 10*A*a*b**2*c - 2*A*b**4 - 5*B*a**2*b*c + B*a*b**3 + x*(8*A*a*b*c**2 - 2*A*b**3*c - 4*B*a**2*c**2 + B*a*b**2*c))/(a**2*(a + b*x + c*x**2)) + (-2*A*b + B*a)*(4*a*c - b**2)/(a**2*x) assert ExpandIntegrand(x**2*(e + f*x)**3*F**(a + b*(c + d*x)**1), x) == F**(a + b*(c + d*x))*e**2*(e + f*x)**3/f**2 - 2*F**(a + b*(c + d*x))*e*(e + f*x)**4/f**2 + F**(a + b*(c + d*x))*(e + f*x)**5/f**2 assert ExpandIntegrand((x)*(a + b*x)**2*f**(e*(c + d*x)**n), x) == a**2*f**(e*(c + d*x)**n)*x + 2*a*b*f**(e*(c + d*x)**n)*x**2 + b**2*f**(e*(c + d*x)**n)*x**3 assert ExpandIntegrand(sin(x)**3*(a + b*(1/sin(x)))**2, x) == a**2*sin(x)**3 + 2*a*b*sin(x)**2 + b**2*sin(x) assert ExpandIntegrand(x*(a + b*ArcSin(c + d*x))**n, x) == -c*(a + b*asin(c + d*x))**n/d + (a + b*asin(c + d*x))**n*(c + d*x)/d assert ExpandIntegrand((a + b*x)**S(3)*(A + B*x)/(c + d*x), x) == B*(a + b*x)**3/d + b*(a + b*x)**2*(A*d - B*c)/d**2 + b*(a + b*x)*(A*d - B*c)*(a*d - b*c)/d**3 + b*(A*d - B*c)*(a*d - b*c)**2/d**4 + (A*d - B*c)*(a*d - b*c)**3/(d**4*(c + d*x)) assert ExpandIntegrand((x**2)*(S(3)*x)**(S(1)/2), x) ==sqrt(3)*x**(5/2) assert ExpandIntegrand((x)*(sin(x))**(S(1)/2), x) == x*sqrt(sin(x)) assert ExpandIntegrand(x*(e + f*x)**2*F**(b*(c + d*x)), x) == -F**(b*(c + d*x))*e*(e + f*x)**2/f + F**(b*(c + d*x))*(e + f*x)**3/f assert ExpandIntegrand(x**m*(e + f*x)**2*F**(b*(c + d*x)**n), x) == F**(b*(c + d*x)**n)*e**2*x**m + 2*F**(b*(c + d*x)**n)*e*f*x*x**m + F**(b*(c + d*x)**n)*f**2*x**2*x**m assert simplify(ExpandIntegrand((S(1) - S(1)*x**S(2))**(-S(3)), x) - (-S(3)/(8*(x**2 - 1)) + S(3)/(16*(x + 1)**2) + S(1)/(S(8)*(x + 1)**3) + S(3)/(S(16)*(x - 1)**2) - S(1)/(S(8)*(x - 1)**3))) == 0 assert ExpandIntegrand(-S(1), 1/((-q - x)**3*(q - x)**3), x) == 1/(8*q**3*(q + x)**3) - 1/(8*q**3*(-q + x)**3) - 3/(8*q**4*(-q**2 + x**2)) + 3/(16*q**4*(q + x)**2) + 3/(16*q**4*(-q + x)**2) assert ExpandIntegrand((1 + 1*x)**(3)/(2 + 1*x), x) == x**2 + x + 1 - 1/(x + 2) assert ExpandIntegrand((c + d*x**1 + e*x**2)/(1 - x**3), x) == (c - (-1)**(S(1)/3)*d + (-1)**(S(2)/3)*e)/(-3*(-1)**(S(2)/3)*x + 3) + (c + (-1)**(S(2)/3)*d - (-1)**(S(1)/3)*e)/(3*(-1)**(S(1)/3)*x + 3) + (c + d + e)/(-3*x + 3) assert ExpandIntegrand((c + d*x**1 + e*x**2 + f*x**3)/(1 - x**4), x) == (c + I*d - e - I*f)/(4*I*x + 4) + (c - I*d - e + I*f)/(-4*I*x + 4) + (c - d + e - f)/(4*x + 4) + (c + d + e + f)/(-4*x + 4) assert ExpandIntegrand((d + e*(f + g*x))/(2 + 3*x + 1*x**2), x) == (-2*d - 2*e*f + 4*e*g)/(2*x + 4) + (2*d + 2*e*f - 2*e*g)/(2*x + 2) assert ExpandIntegrand(x/(a*x**3 + b*Sqrt(c + d*x**6)), x) == a*x**4/(-b**2*c + x**6*(a**2 - b**2*d)) + b*x*sqrt(c + d*x**6)/(b**2*c + x**6*(-a**2 + b**2*d)) assert simplify(ExpandIntegrand(x**1*(1 - x**4)**(-2), x) - (x/(S(4)*(x**2 + 1)) + x/(S(4)*(x**2 + 1)**2) - x/(S(4)*(x**2 - 1)) + x/(S(4)*(x**2 - 1)**2))) == 0 assert simplify(ExpandIntegrand((-1 + x**S(6))**(-3), x) - (S(3)/(S(8)*(x**6 - 1)) - S(3)/(S(16)*(x**S(3) + S(1))**S(2)) - S(1)/(S(8)*(x**S(3) + S(1))**S(3)) - S(3)/(S(16)*(x**S(3) - S(1))**S(2)) + S(1)/(S(8)*(x**S(3) - S(1))**S(3)))) == 0 assert simplify(ExpandIntegrand(u**1*(a + b*u**2 + c*u**4)**(-1), x)) == simplify(1/(2*b*(u + sqrt(-(a + c*u**4)/b))) - 1/(2*b*(-u + sqrt(-(a + c*u**4)/b)))) assert simplify(ExpandIntegrand((1 + 1*u + 1*u**2)**(-2), x) - (S(1)/(S(2)*(-u - 1)*(-u**2 - u - 1)) + S(1)/(S(4)*(-u - 1)*(u + sqrt(-u - 1))**2) + S(1)/(S(4)*(-u - 1)*(u - sqrt(-u - 1))**2))) == 0 assert ExpandIntegrand(x*(a + b*Log(c*(d*(e + f*x)**p)**q))**n, x) == -e*(a + b*log(c*(d*(e + f*x)**p)**q))**n/f + (a + b*log(c*(d*(e + f*x)**p)**q))**n*(e + f*x)/f assert ExpandIntegrand(x*f**(e*(c + d*x)*S(1)), x) == f**(e*(c + d*x))*x assert simplify(ExpandIntegrand((x)*(a + b*x)**m*Log(c*(d + e*x**n)**p), x) - (-a*(a + b*x)**m*log(c*(d + e*x**n)**p)/b + (a + b*x)**(m + S(1))*log(c*(d + e*x**n)**p)/b)) == 0 assert simplify(ExpandIntegrand(u*(a + b*F**v)**S(2)*(c + d*F**v)**S(-3), x) - (b**2*u/(d**2*(F**v*d + c)) + 2*b*u*(a*d - b*c)/(d**2*(F**v*d + c)**2) + u*(a*d - b*c)**2/(d**2*(F**v*d + c)**3))) == 0 assert ExpandIntegrand((S(1) + 1*x)**S(2)*f**(e*(1 + S(1)*x)**n)/(g + h*x), x) == f**(e*(x + 1)**n)*(x + 1)/h + f**(e*(x + 1)**n)*(-g + h)/h**2 + f**(e*(x + 1)**n)*(g - h)**2/(h**2*(g + h*x)) assert ExpandIntegrand((a*c - b*c*x)**2/(a + b*x)**2, x) == 4*a**2*c**2/(a + b*x)**2 - 4*a*c**2/(a + b*x) + c**2 assert simplify(ExpandIntegrand(x**2*(1 - 1*x**2)**(-2), x) - (1/(S(2)*(x**2 - 1)) + 1/(S(4)*(x + 1)**2) + 1/(S(4)*(x - 1)**2))) == 0 assert ExpandIntegrand((a + x)**2, x) == a**2 + 2*a*x + x**2 assert ExpandIntegrand((a + b*x)**S(2)/x**3, x) == a**2/x**3 + 2*a*b/x**2 + b**2/x assert ExpandIntegrand(1/(x**2*(a + b*x)**2), x) == b**2/(a**2*(a + b*x)**2) + 1/(a**2*x**2) + 2*b**2/(a**3*(a + b*x)) - 2*b/(a**3*x) assert ExpandIntegrand((1 + x)**3/x, x) == x**2 + 3*x + 3 + 1/x assert ExpandIntegrand((1 + 2*(3 + 4*x**2))/(2 + 3*x**2 + 1*x**4), x) == 18/(2*x**2 + 4) - 2/(2*x**2 + 2) assert ExpandIntegrand((c + d*x**2 + e*x**3)/(1 - 1*x**4), x) == (c - d - I*e)/(4*I*x + 4) + (c - d + I*e)/(-4*I*x + 4) + (c + d - e)/(4*x + 4) + (c + d + e)/(-4*x + 4) assert ExpandIntegrand((a + b*x)**2/(c + d*x), x) == b*(a + b*x)/d + b*(a*d - b*c)/d**2 + (a*d - b*c)**2/(d**2*(c + d*x)) assert ExpandIntegrand(x**2*(a + b*Log(c*(d*(e + f*x)**p)**q))**n, x) == e**2*(a + b*log(c*(d*(e + f*x)**p)**q))**n/f**2 - 2*e*(a + b*log(c*(d*(e + f*x)**p)**q))**n*(e + f*x)/f**2 + (a + b*log(c*(d*(e + f*x)**p)**q))**n*(e + f*x)**2/f**2 assert ExpandIntegrand(x*(1 + 2*x)**3*log(2*(1 + 1*x**2)**1), x) == 8*x**4*log(2*x**2 + 2) + 12*x**3*log(2*x**2 + 2) + 6*x**2*log(2*x**2 + 2) + x*log(2*x**2 + 2) assert ExpandIntegrand((1 + 1*x)**S(3)*f**(e*(1 + 1*x)**n)/(g + h*x), x) == f**(e*(x + 1)**n)*(x + 1)**2/h + f**(e*(x + 1)**n)*(-g + h)*(x + 1)/h**2 + f**(e*(x + 1)**n)*(-g + h)**2/h**3 - f**(e*(x + 1)**n)*(g - h)**3/(h**3*(g + h*x)) def test_Dist(): assert Dist(x, a + b, x) == a*x + b*x assert Dist(x, Integral(a + b , x), x) == x*Integral(a + b, x) assert Dist(3*x,(a+b), x) - Dist(2*x, (a+b), x) == a*x + b*x assert Dist(3*x,(a+b), x) + Dist(2*x, (a+b), x) == 5*a*x + 5*b*x assert Dist(x, c*Integral((a + b), x), x) == c*x*Integral(a + b, x) def test_IntegralFreeQ(): assert not IntegralFreeQ(Integral(a, x)) assert IntegralFreeQ(a + b) def test_OneQ(): from sympy.integrals.rubi.utility_function import OneQ assert OneQ(S(1)) assert not OneQ(S(2)) def test_DerivativeDivides(): assert not DerivativeDivides(x, x, x) assert not DerivativeDivides(a, x + y, b) assert DerivativeDivides(a + x, a, x) == a assert DerivativeDivides(a + b, x + y, b) == x + y def test_LogIntegral(): from sympy.integrals.rubi.utility_function import LogIntegral assert LogIntegral(a) == li(a) def test_SinIntegral(): from sympy.integrals.rubi.utility_function import SinIntegral assert SinIntegral(a) == Si(a) def test_CosIntegral(): from sympy.integrals.rubi.utility_function import CosIntegral assert CosIntegral(a) == Ci(a) def test_SinhIntegral(): from sympy.integrals.rubi.utility_function import SinhIntegral assert SinhIntegral(a) == Shi(a) def test_CoshIntegral(): from sympy.integrals.rubi.utility_function import CoshIntegral assert CoshIntegral(a) == Chi(a) def test_ExpIntegralEi(): from sympy.integrals.rubi.utility_function import ExpIntegralEi assert ExpIntegralEi(a) == Ei(a) def test_ExpIntegralE(): from sympy.integrals.rubi.utility_function import ExpIntegralE assert ExpIntegralE(a, z) == expint(a, z) def test_LogGamma(): from sympy.integrals.rubi.utility_function import LogGamma assert LogGamma(a) == loggamma(a) def test_Factorial(): from sympy.integrals.rubi.utility_function import Factorial assert Factorial(S(5)) == 120 def test_Zeta(): from sympy.integrals.rubi.utility_function import Zeta assert Zeta(a, z) == zeta(a, z) def test_HypergeometricPFQ(): from sympy.integrals.rubi.utility_function import HypergeometricPFQ assert HypergeometricPFQ([a, b], [c], z) == hyper([a, b], [c], z) def test_PolyGamma(): assert PolyGamma(S(2), S(3)) == polygamma(2, 3) def test_ProductLog(): from sympy import N assert N(ProductLog(S(5.0)), 5) == N(1.32672466524220, 5) assert N(ProductLog(S(2), S(3.5)), 5) == N(-1.14064876353898 + 10.8912237027092*I, 5) def test_PolynomialQuotient(): assert PolynomialQuotient(log((-a*d + b*c)/(b*(c + d*x)))/(c + d*x), a + b*x, e) == log((-a*d + b*c)/(b*(c + d*x)))/((a + b*x)*(c + d*x)) assert PolynomialQuotient(x**2, x + a, x) == -a + x def test_PolynomialRemainder(): assert PolynomialRemainder(log((-a*d + b*c)/(b*(c + d*x)))/(c + d*x), a + b*x, e) == 0 assert PolynomialRemainder(x**2, x + a, x) == a**2 def test_Floor(): assert Floor(S(7.5)) == 7 assert Floor(S(15.5), S(6)) == 12 def test_Factor(): from sympy.integrals.rubi.utility_function import Factor assert Factor(a*b + a*c) == a*(b + c) def test_Rule(): from sympy.integrals.rubi.utility_function import Rule assert Rule(x, S(5)) == {x: 5} def test_Distribute(): assert Distribute((a + b)*c + (a + b)*d, Add) == c*(a + b) + d*(a + b) assert Distribute((a + b)*(c + e), Add) == a*c + a*e + b*c + b*e def test_CoprimeQ(): assert CoprimeQ(S(7), S(5)) assert not CoprimeQ(S(6), S(3)) def test_Discriminant(): from sympy.integrals.rubi.utility_function import Discriminant assert Discriminant(a*x**2 + b*x + c, x) == b**2 - 4*a*c assert Discriminant(1/x, x) == Discriminant(1/x, x) def test_Sum_doit(): assert Sum_doit(2*x + 2, [x, 0, 1.7]) == 6 def test_DeactivateTrig(): assert DeactivateTrig(sec(a + b*x), x) == sec(a + b*x) def test_Negative(): from sympy.integrals.rubi.utility_function import Negative assert Negative(S(-2)) assert not Negative(S(0)) def test_Quotient(): from sympy.integrals.rubi.utility_function import Quotient assert Quotient(17, 5) == 3 def test_process_trig(): assert process_trig(x*cot(x)) == x/tan(x) assert process_trig(coth(x)*csc(x)) == S(1)/(tanh(x)*sin(x)) def test_replace_pow_exp(): assert replace_pow_exp(rubi_exp(S(5))) == exp(S(5)) def test_rubi_unevaluated_expr(): from sympy.integrals.rubi.utility_function import rubi_unevaluated_expr assert rubi_unevaluated_expr(a)*rubi_unevaluated_expr(b) == rubi_unevaluated_expr(b)*rubi_unevaluated_expr(a) def test_rubi_exp(): # class name in utility_function is `exp`. To avoid confusion `rubi_exp` has been used here assert isinstance(rubi_exp(a), Pow) def test_rubi_log(): # class name in utility_function is `log`. To avoid confusion `rubi_log` has been used here assert rubi_log(rubi_exp(S(a))) == a
8a2310632849c8155302b0eecbefe8b6db6dffde8af35617309bc9518a014f94
from sympy import (Add, Basic, Expr, S, Symbol, Wild, Float, Integer, Rational, I, sin, cos, tan, exp, log, nan, oo, sqrt, symbols, Integral, sympify, WildFunction, Poly, Function, Derivative, Number, pi, NumberSymbol, zoo, Piecewise, Mul, Pow, nsimplify, ratsimp, trigsimp, radsimp, powsimp, simplify, together, collect, factorial, apart, combsimp, factor, refine, cancel, Tuple, default_sort_key, DiracDelta, gamma, Dummy, Sum, E, exp_polar, expand, diff, O, Heaviside, Si, Max, UnevaluatedExpr, integrate, gammasimp) from sympy.core.expr import ExprBuilder from sympy.core.function import AppliedUndef from sympy.core.compatibility import range from sympy.physics.secondquant import FockState from sympy.physics.units import meter from sympy.utilities.pytest import raises, XFAIL from sympy.abc import a, b, c, n, t, u, x, y, z class DummyNumber(object): """ Minimal implementation of a number that works with SymPy. If one has a Number class (e.g. Sage Integer, or some other custom class) that one wants to work well with SymPy, one has to implement at least the methods of this class DummyNumber, resp. its subclasses I5 and F1_1. Basically, one just needs to implement either __int__() or __float__() and then one needs to make sure that the class works with Python integers and with itself. """ def __radd__(self, a): if isinstance(a, (int, float)): return a + self.number return NotImplemented def __truediv__(a, b): return a.__div__(b) def __rtruediv__(a, b): return a.__rdiv__(b) def __add__(self, a): if isinstance(a, (int, float, DummyNumber)): return self.number + a return NotImplemented def __rsub__(self, a): if isinstance(a, (int, float)): return a - self.number return NotImplemented def __sub__(self, a): if isinstance(a, (int, float, DummyNumber)): return self.number - a return NotImplemented def __rmul__(self, a): if isinstance(a, (int, float)): return a * self.number return NotImplemented def __mul__(self, a): if isinstance(a, (int, float, DummyNumber)): return self.number * a return NotImplemented def __rdiv__(self, a): if isinstance(a, (int, float)): return a / self.number return NotImplemented def __div__(self, a): if isinstance(a, (int, float, DummyNumber)): return self.number / a return NotImplemented def __rpow__(self, a): if isinstance(a, (int, float)): return a ** self.number return NotImplemented def __pow__(self, a): if isinstance(a, (int, float, DummyNumber)): return self.number ** a return NotImplemented def __pos__(self): return self.number def __neg__(self): return - self.number class I5(DummyNumber): number = 5 def __int__(self): return self.number class F1_1(DummyNumber): number = 1.1 def __float__(self): return self.number i5 = I5() f1_1 = F1_1() # basic sympy objects basic_objs = [ Rational(2), Float("1.3"), x, y, pow(x, y)*y, ] # all supported objects all_objs = basic_objs + [ 5, 5.5, i5, f1_1 ] def dotest(s): for x in all_objs: for y in all_objs: s(x, y) return True def test_basic(): def j(a, b): x = a x = +a x = -a x = a + b x = a - b x = a*b x = a/b x = a**b assert dotest(j) def test_ibasic(): def s(a, b): x = a x += b x = a x -= b x = a x *= b x = a x /= b assert dotest(s) def test_relational(): from sympy import Lt assert (pi < 3) is S.false assert (pi <= 3) is S.false assert (pi > 3) is S.true assert (pi >= 3) is S.true assert (-pi < 3) is S.true assert (-pi <= 3) is S.true assert (-pi > 3) is S.false assert (-pi >= 3) is S.false r = Symbol('r', real=True) assert (r - 2 < r - 3) is S.false assert Lt(x + I, x + I + 2).func == Lt # issue 8288 def test_relational_assumptions(): from sympy import Lt, Gt, Le, Ge m1 = Symbol("m1", nonnegative=False) m2 = Symbol("m2", positive=False) m3 = Symbol("m3", nonpositive=False) m4 = Symbol("m4", negative=False) assert (m1 < 0) == Lt(m1, 0) assert (m2 <= 0) == Le(m2, 0) assert (m3 > 0) == Gt(m3, 0) assert (m4 >= 0) == Ge(m4, 0) m1 = Symbol("m1", nonnegative=False, real=True) m2 = Symbol("m2", positive=False, real=True) m3 = Symbol("m3", nonpositive=False, real=True) m4 = Symbol("m4", negative=False, real=True) assert (m1 < 0) is S.true assert (m2 <= 0) is S.true assert (m3 > 0) is S.true assert (m4 >= 0) is S.true m1 = Symbol("m1", negative=True) m2 = Symbol("m2", nonpositive=True) m3 = Symbol("m3", positive=True) m4 = Symbol("m4", nonnegative=True) assert (m1 < 0) is S.true assert (m2 <= 0) is S.true assert (m3 > 0) is S.true assert (m4 >= 0) is S.true m1 = Symbol("m1", negative=False, real=True) m2 = Symbol("m2", nonpositive=False, real=True) m3 = Symbol("m3", positive=False, real=True) m4 = Symbol("m4", nonnegative=False, real=True) assert (m1 < 0) is S.false assert (m2 <= 0) is S.false assert (m3 > 0) is S.false assert (m4 >= 0) is S.false def test_relational_noncommutative(): from sympy import Lt, Gt, Le, Ge A, B = symbols('A,B', commutative=False) assert (A < B) == Lt(A, B) assert (A <= B) == Le(A, B) assert (A > B) == Gt(A, B) assert (A >= B) == Ge(A, B) def test_basic_nostr(): for obj in basic_objs: raises(TypeError, lambda: obj + '1') raises(TypeError, lambda: obj - '1') if obj == 2: assert obj * '1' == '11' else: raises(TypeError, lambda: obj * '1') raises(TypeError, lambda: obj / '1') raises(TypeError, lambda: obj ** '1') def test_series_expansion_for_uniform_order(): assert (1/x + y + x).series(x, 0, 0) == 1/x + O(1, x) assert (1/x + y + x).series(x, 0, 1) == 1/x + y + O(x) assert (1/x + 1 + x).series(x, 0, 0) == 1/x + O(1, x) assert (1/x + 1 + x).series(x, 0, 1) == 1/x + 1 + O(x) assert (1/x + x).series(x, 0, 0) == 1/x + O(1, x) assert (1/x + y + y*x + x).series(x, 0, 0) == 1/x + O(1, x) assert (1/x + y + y*x + x).series(x, 0, 1) == 1/x + y + O(x) def test_leadterm(): assert (3 + 2*x**(log(3)/log(2) - 1)).leadterm(x) == (3, 0) assert (1/x**2 + 1 + x + x**2).leadterm(x)[1] == -2 assert (1/x + 1 + x + x**2).leadterm(x)[1] == -1 assert (x**2 + 1/x).leadterm(x)[1] == -1 assert (1 + x**2).leadterm(x)[1] == 0 assert (x + 1).leadterm(x)[1] == 0 assert (x + x**2).leadterm(x)[1] == 1 assert (x**2).leadterm(x)[1] == 2 def test_as_leading_term(): assert (3 + 2*x**(log(3)/log(2) - 1)).as_leading_term(x) == 3 assert (1/x**2 + 1 + x + x**2).as_leading_term(x) == 1/x**2 assert (1/x + 1 + x + x**2).as_leading_term(x) == 1/x assert (x**2 + 1/x).as_leading_term(x) == 1/x assert (1 + x**2).as_leading_term(x) == 1 assert (x + 1).as_leading_term(x) == 1 assert (x + x**2).as_leading_term(x) == x assert (x**2).as_leading_term(x) == x**2 assert (x + oo).as_leading_term(x) == oo raises(ValueError, lambda: (x + 1).as_leading_term(1)) def test_leadterm2(): assert (x*cos(1)*cos(1 + sin(1)) + sin(1 + sin(1))).leadterm(x) == \ (sin(1 + sin(1)), 0) def test_leadterm3(): assert (y + z + x).leadterm(x) == (y + z, 0) def test_as_leading_term2(): assert (x*cos(1)*cos(1 + sin(1)) + sin(1 + sin(1))).as_leading_term(x) == \ sin(1 + sin(1)) def test_as_leading_term3(): assert (2 + pi + x).as_leading_term(x) == 2 + pi assert (2*x + pi*x + x**2).as_leading_term(x) == (2 + pi)*x def test_as_leading_term4(): # see issue 6843 n = Symbol('n', integer=True, positive=True) r = -n**3/(2*n**2 + 4*n + 2) - n**2/(n**2 + 2*n + 1) + \ n**2/(n + 1) - n/(2*n**2 + 4*n + 2) + n/(n*x + x) + 2*n/(n + 1) - \ 1 + 1/(n*x + x) + 1/(n + 1) - 1/x assert r.as_leading_term(x).cancel() == n/2 def test_as_leading_term_stub(): class foo(Function): pass assert foo(1/x).as_leading_term(x) == foo(1/x) assert foo(1).as_leading_term(x) == foo(1) raises(NotImplementedError, lambda: foo(x).as_leading_term(x)) def test_as_leading_term_deriv_integral(): # related to issue 11313 assert Derivative(x ** 3, x).as_leading_term(x) == 3*x**2 assert Derivative(x ** 3, y).as_leading_term(x) == 0 assert Integral(x ** 3, x).as_leading_term(x) == x**4/4 assert Integral(x ** 3, y).as_leading_term(x) == y*x**3 assert Derivative(exp(x), x).as_leading_term(x) == 1 assert Derivative(log(x), x).as_leading_term(x) == (1/x).as_leading_term(x) def test_atoms(): assert x.atoms() == {x} assert (1 + x).atoms() == {x, S(1)} assert (1 + 2*cos(x)).atoms(Symbol) == {x} assert (1 + 2*cos(x)).atoms(Symbol, Number) == {S(1), S(2), x} assert (2*(x**(y**x))).atoms() == {S(2), x, y} assert Rational(1, 2).atoms() == {S.Half} assert Rational(1, 2).atoms(Symbol) == set([]) assert sin(oo).atoms(oo) == set() assert Poly(0, x).atoms() == {S.Zero} assert Poly(1, x).atoms() == {S.One} assert Poly(x, x).atoms() == {x} assert Poly(x, x, y).atoms() == {x} assert Poly(x + y, x, y).atoms() == {x, y} assert Poly(x + y, x, y, z).atoms() == {x, y} assert Poly(x + y*t, x, y, z).atoms() == {t, x, y} assert (I*pi).atoms(NumberSymbol) == {pi} assert (I*pi).atoms(NumberSymbol, I) == \ (I*pi).atoms(I, NumberSymbol) == {pi, I} assert exp(exp(x)).atoms(exp) == {exp(exp(x)), exp(x)} assert (1 + x*(2 + y) + exp(3 + z)).atoms(Add) == \ {1 + x*(2 + y) + exp(3 + z), 2 + y, 3 + z} # issue 6132 f = Function('f') e = (f(x) + sin(x) + 2) assert e.atoms(AppliedUndef) == \ {f(x)} assert e.atoms(AppliedUndef, Function) == \ {f(x), sin(x)} assert e.atoms(Function) == \ {f(x), sin(x)} assert e.atoms(AppliedUndef, Number) == \ {f(x), S(2)} assert e.atoms(Function, Number) == \ {S(2), sin(x), f(x)} def test_is_polynomial(): k = Symbol('k', nonnegative=True, integer=True) assert Rational(2).is_polynomial(x, y, z) is True assert (S.Pi).is_polynomial(x, y, z) is True assert x.is_polynomial(x) is True assert x.is_polynomial(y) is True assert (x**2).is_polynomial(x) is True assert (x**2).is_polynomial(y) is True assert (x**(-2)).is_polynomial(x) is False assert (x**(-2)).is_polynomial(y) is True assert (2**x).is_polynomial(x) is False assert (2**x).is_polynomial(y) is True assert (x**k).is_polynomial(x) is False assert (x**k).is_polynomial(k) is False assert (x**x).is_polynomial(x) is False assert (k**k).is_polynomial(k) is False assert (k**x).is_polynomial(k) is False assert (x**(-k)).is_polynomial(x) is False assert ((2*x)**k).is_polynomial(x) is False assert (x**2 + 3*x - 8).is_polynomial(x) is True assert (x**2 + 3*x - 8).is_polynomial(y) is True assert (x**2 + 3*x - 8).is_polynomial() is True assert sqrt(x).is_polynomial(x) is False assert (sqrt(x)**3).is_polynomial(x) is False assert (x**2 + 3*x*sqrt(y) - 8).is_polynomial(x) is True assert (x**2 + 3*x*sqrt(y) - 8).is_polynomial(y) is False assert ((x**2)*(y**2) + x*(y**2) + y*x + exp(2)).is_polynomial() is True assert ((x**2)*(y**2) + x*(y**2) + y*x + exp(x)).is_polynomial() is False assert ( (x**2)*(y**2) + x*(y**2) + y*x + exp(2)).is_polynomial(x, y) is True assert ( (x**2)*(y**2) + x*(y**2) + y*x + exp(x)).is_polynomial(x, y) is False def test_is_rational_function(): assert Integer(1).is_rational_function() is True assert Integer(1).is_rational_function(x) is True assert Rational(17, 54).is_rational_function() is True assert Rational(17, 54).is_rational_function(x) is True assert (12/x).is_rational_function() is True assert (12/x).is_rational_function(x) is True assert (x/y).is_rational_function() is True assert (x/y).is_rational_function(x) is True assert (x/y).is_rational_function(x, y) is True assert (x**2 + 1/x/y).is_rational_function() is True assert (x**2 + 1/x/y).is_rational_function(x) is True assert (x**2 + 1/x/y).is_rational_function(x, y) is True assert (sin(y)/x).is_rational_function() is False assert (sin(y)/x).is_rational_function(y) is False assert (sin(y)/x).is_rational_function(x) is True assert (sin(y)/x).is_rational_function(x, y) is False assert (S.NaN).is_rational_function() is False assert (S.Infinity).is_rational_function() is False assert (-S.Infinity).is_rational_function() is False assert (S.ComplexInfinity).is_rational_function() is False def test_is_algebraic_expr(): assert sqrt(3).is_algebraic_expr(x) is True assert sqrt(3).is_algebraic_expr() is True eq = ((1 + x**2)/(1 - y**2))**(S(1)/3) assert eq.is_algebraic_expr(x) is True assert eq.is_algebraic_expr(y) is True assert (sqrt(x) + y**(S(2)/3)).is_algebraic_expr(x) is True assert (sqrt(x) + y**(S(2)/3)).is_algebraic_expr(y) is True assert (sqrt(x) + y**(S(2)/3)).is_algebraic_expr() is True assert (cos(y)/sqrt(x)).is_algebraic_expr() is False assert (cos(y)/sqrt(x)).is_algebraic_expr(x) is True assert (cos(y)/sqrt(x)).is_algebraic_expr(y) is False assert (cos(y)/sqrt(x)).is_algebraic_expr(x, y) is False def test_SAGE1(): #see https://github.com/sympy/sympy/issues/3346 class MyInt: def _sympy_(self): return Integer(5) m = MyInt() e = Rational(2)*m assert e == 10 raises(TypeError, lambda: Rational(2)*MyInt) def test_SAGE2(): class MyInt(object): def __int__(self): return 5 assert sympify(MyInt()) == 5 e = Rational(2)*MyInt() assert e == 10 raises(TypeError, lambda: Rational(2)*MyInt) def test_SAGE3(): class MySymbol: def __rmul__(self, other): return ('mys', other, self) o = MySymbol() e = x*o assert e == ('mys', x, o) def test_len(): e = x*y assert len(e.args) == 2 e = x + y + z assert len(e.args) == 3 def test_doit(): a = Integral(x**2, x) assert isinstance(a.doit(), Integral) is False assert isinstance(a.doit(integrals=True), Integral) is False assert isinstance(a.doit(integrals=False), Integral) is True assert (2*Integral(x, x)).doit() == x**2 def test_attribute_error(): raises(AttributeError, lambda: x.cos()) raises(AttributeError, lambda: x.sin()) raises(AttributeError, lambda: x.exp()) def test_args(): assert (x*y).args in ((x, y), (y, x)) assert (x + y).args in ((x, y), (y, x)) assert (x*y + 1).args in ((x*y, 1), (1, x*y)) assert sin(x*y).args == (x*y,) assert sin(x*y).args[0] == x*y assert (x**y).args == (x, y) assert (x**y).args[0] == x assert (x**y).args[1] == y def test_noncommutative_expand_issue_3757(): A, B, C = symbols('A,B,C', commutative=False) assert A*B - B*A != 0 assert (A*(A + B)*B).expand() == A**2*B + A*B**2 assert (A*(A + B + C)*B).expand() == A**2*B + A*B**2 + A*C*B def test_as_numer_denom(): a, b, c = symbols('a, b, c') assert nan.as_numer_denom() == (nan, 1) assert oo.as_numer_denom() == (oo, 1) assert (-oo).as_numer_denom() == (-oo, 1) assert zoo.as_numer_denom() == (zoo, 1) assert (-zoo).as_numer_denom() == (zoo, 1) assert x.as_numer_denom() == (x, 1) assert (1/x).as_numer_denom() == (1, x) assert (x/y).as_numer_denom() == (x, y) assert (x/2).as_numer_denom() == (x, 2) assert (x*y/z).as_numer_denom() == (x*y, z) assert (x/(y*z)).as_numer_denom() == (x, y*z) assert Rational(1, 2).as_numer_denom() == (1, 2) assert (1/y**2).as_numer_denom() == (1, y**2) assert (x/y**2).as_numer_denom() == (x, y**2) assert ((x**2 + 1)/y).as_numer_denom() == (x**2 + 1, y) assert (x*(y + 1)/y**7).as_numer_denom() == (x*(y + 1), y**7) assert (x**-2).as_numer_denom() == (1, x**2) assert (a/x + b/2/x + c/3/x).as_numer_denom() == \ (6*a + 3*b + 2*c, 6*x) assert (a/x + b/2/x + c/3/y).as_numer_denom() == \ (2*c*x + y*(6*a + 3*b), 6*x*y) assert (a/x + b/2/x + c/.5/x).as_numer_denom() == \ (2*a + b + 4.0*c, 2*x) # this should take no more than a few seconds assert int(log(Add(*[Dummy()/i/x for i in range(1, 705)] ).as_numer_denom()[1]/x).n(4)) == 705 for i in [S.Infinity, S.NegativeInfinity, S.ComplexInfinity]: assert (i + x/3).as_numer_denom() == \ (x + i, 3) assert (S.Infinity + x/3 + y/4).as_numer_denom() == \ (4*x + 3*y + S.Infinity, 12) assert (oo*x + zoo*y).as_numer_denom() == \ (zoo*y + oo*x, 1) A, B, C = symbols('A,B,C', commutative=False) assert (A*B*C**-1).as_numer_denom() == (A*B*C**-1, 1) assert (A*B*C**-1/x).as_numer_denom() == (A*B*C**-1, x) assert (C**-1*A*B).as_numer_denom() == (C**-1*A*B, 1) assert (C**-1*A*B/x).as_numer_denom() == (C**-1*A*B, x) assert ((A*B*C)**-1).as_numer_denom() == ((A*B*C)**-1, 1) assert ((A*B*C)**-1/x).as_numer_denom() == ((A*B*C)**-1, x) def test_trunc(): import math x, y = symbols('x y') assert math.trunc(2) == 2 assert math.trunc(4.57) == 4 assert math.trunc(-5.79) == -5 assert math.trunc(pi) == 3 assert math.trunc(log(7)) == 1 assert math.trunc(exp(5)) == 148 assert math.trunc(cos(pi)) == -1 assert math.trunc(sin(5)) == 0 raises(TypeError, lambda: math.trunc(x)) raises(TypeError, lambda: math.trunc(x + y**2)) raises(TypeError, lambda: math.trunc(oo)) def test_as_independent(): assert S.Zero.as_independent(x, as_Add=True) == (0, 0) assert S.Zero.as_independent(x, as_Add=False) == (0, 0) assert (2*x*sin(x) + y + x).as_independent(x) == (y, x + 2*x*sin(x)) assert (2*x*sin(x) + y + x).as_independent(y) == (x + 2*x*sin(x), y) assert (2*x*sin(x) + y + x).as_independent(x, y) == (0, y + x + 2*x*sin(x)) assert (x*sin(x)*cos(y)).as_independent(x) == (cos(y), x*sin(x)) assert (x*sin(x)*cos(y)).as_independent(y) == (x*sin(x), cos(y)) assert (x*sin(x)*cos(y)).as_independent(x, y) == (1, x*sin(x)*cos(y)) assert (sin(x)).as_independent(x) == (1, sin(x)) assert (sin(x)).as_independent(y) == (sin(x), 1) assert (2*sin(x)).as_independent(x) == (2, sin(x)) assert (2*sin(x)).as_independent(y) == (2*sin(x), 1) # issue 4903 = 1766b n1, n2, n3 = symbols('n1 n2 n3', commutative=False) assert (n1 + n1*n2).as_independent(n2) == (n1, n1*n2) assert (n2*n1 + n1*n2).as_independent(n2) == (0, n1*n2 + n2*n1) assert (n1*n2*n1).as_independent(n2) == (n1, n2*n1) assert (n1*n2*n1).as_independent(n1) == (1, n1*n2*n1) assert (3*x).as_independent(x, as_Add=True) == (0, 3*x) assert (3*x).as_independent(x, as_Add=False) == (3, x) assert (3 + x).as_independent(x, as_Add=True) == (3, x) assert (3 + x).as_independent(x, as_Add=False) == (1, 3 + x) # issue 5479 assert (3*x).as_independent(Symbol) == (3, x) # issue 5648 assert (n1*x*y).as_independent(x) == (n1*y, x) assert ((x + n1)*(x - y)).as_independent(x) == (1, (x + n1)*(x - y)) assert ((x + n1)*(x - y)).as_independent(y) == (x + n1, x - y) assert (DiracDelta(x - n1)*DiracDelta(x - y)).as_independent(x) \ == (1, DiracDelta(x - n1)*DiracDelta(x - y)) assert (x*y*n1*n2*n3).as_independent(n2) == (x*y*n1, n2*n3) assert (x*y*n1*n2*n3).as_independent(n1) == (x*y, n1*n2*n3) assert (x*y*n1*n2*n3).as_independent(n3) == (x*y*n1*n2, n3) assert (DiracDelta(x - n1)*DiracDelta(y - n1)*DiracDelta(x - n2)).as_independent(y) == \ (DiracDelta(x - n1)*DiracDelta(x - n2), DiracDelta(y - n1)) # issue 5784 assert (x + Integral(x, (x, 1, 2))).as_independent(x, strict=True) == \ (Integral(x, (x, 1, 2)), x) eq = Add(x, -x, 2, -3, evaluate=False) assert eq.as_independent(x) == (-1, Add(x, -x, evaluate=False)) eq = Mul(x, 1/x, 2, -3, evaluate=False) eq.as_independent(x) == (-6, Mul(x, 1/x, evaluate=False)) assert (x*y).as_independent(z, as_Add=True) == (x*y, 0) @XFAIL def test_call_2(): # TODO UndefinedFunction does not subclass Expr f = Function('f') assert (2*f)(x) == 2*f(x) def test_replace(): f = log(sin(x)) + tan(sin(x**2)) assert f.replace(sin, cos) == log(cos(x)) + tan(cos(x**2)) assert f.replace( sin, lambda a: sin(2*a)) == log(sin(2*x)) + tan(sin(2*x**2)) a = Wild('a') b = Wild('b') assert f.replace(sin(a), cos(a)) == log(cos(x)) + tan(cos(x**2)) assert f.replace( sin(a), lambda a: sin(2*a)) == log(sin(2*x)) + tan(sin(2*x**2)) # test exact assert (2*x).replace(a*x + b, b - a, exact=True) == 2*x assert (2*x).replace(a*x + b, b - a) == 2*x assert (2*x).replace(a*x + b, b - a, exact=False) == 2/x assert (2*x).replace(a*x + b, lambda a, b: b - a, exact=True) == 2*x assert (2*x).replace(a*x + b, lambda a, b: b - a) == 2*x assert (2*x).replace(a*x + b, lambda a, b: b - a, exact=False) == 2/x g = 2*sin(x**3) assert g.replace( lambda expr: expr.is_Number, lambda expr: expr**2) == 4*sin(x**9) assert cos(x).replace(cos, sin, map=True) == (sin(x), {cos(x): sin(x)}) assert sin(x).replace(cos, sin) == sin(x) cond, func = lambda x: x.is_Mul, lambda x: 2*x assert (x*y).replace(cond, func, map=True) == (2*x*y, {x*y: 2*x*y}) assert (x*(1 + x*y)).replace(cond, func, map=True) == \ (2*x*(2*x*y + 1), {x*(2*x*y + 1): 2*x*(2*x*y + 1), x*y: 2*x*y}) assert (y*sin(x)).replace(sin, lambda expr: sin(expr)/y, map=True) == \ (sin(x), {sin(x): sin(x)/y}) # if not simultaneous then y*sin(x) -> y*sin(x)/y = sin(x) -> sin(x)/y assert (y*sin(x)).replace(sin, lambda expr: sin(expr)/y, simultaneous=False) == sin(x)/y assert (x**2 + O(x**3)).replace(Pow, lambda b, e: b**e/e) == O(1, x) assert (x**2 + O(x**3)).replace(Pow, lambda b, e: b**e/e, simultaneous=False) == x**2/2 + O(x**3) assert (x*(x*y + 3)).replace(lambda x: x.is_Mul, lambda x: 2 + x) == \ x*(x*y + 5) + 2 e = (x*y + 1)*(2*x*y + 1) + 1 assert e.replace(cond, func, map=True) == ( 2*((2*x*y + 1)*(4*x*y + 1)) + 1, {2*x*y: 4*x*y, x*y: 2*x*y, (2*x*y + 1)*(4*x*y + 1): 2*((2*x*y + 1)*(4*x*y + 1))}) assert x.replace(x, y) == y assert (x + 1).replace(1, 2) == x + 2 # https://groups.google.com/forum/#!topic/sympy/8wCgeC95tz0 n1, n2, n3 = symbols('n1:4', commutative=False) f = Function('f') assert (n1*f(n2)).replace(f, lambda x: x) == n1*n2 assert (n3*f(n2)).replace(f, lambda x: x) == n3*n2 def test_find(): expr = (x + y + 2 + sin(3*x)) assert expr.find(lambda u: u.is_Integer) == {S(2), S(3)} assert expr.find(lambda u: u.is_Symbol) == {x, y} assert expr.find(lambda u: u.is_Integer, group=True) == {S(2): 1, S(3): 1} assert expr.find(lambda u: u.is_Symbol, group=True) == {x: 2, y: 1} assert expr.find(Integer) == {S(2), S(3)} assert expr.find(Symbol) == {x, y} assert expr.find(Integer, group=True) == {S(2): 1, S(3): 1} assert expr.find(Symbol, group=True) == {x: 2, y: 1} a = Wild('a') expr = sin(sin(x)) + sin(x) + cos(x) + x assert expr.find(lambda u: type(u) is sin) == {sin(x), sin(sin(x))} assert expr.find( lambda u: type(u) is sin, group=True) == {sin(x): 2, sin(sin(x)): 1} assert expr.find(sin(a)) == {sin(x), sin(sin(x))} assert expr.find(sin(a), group=True) == {sin(x): 2, sin(sin(x)): 1} assert expr.find(sin) == {sin(x), sin(sin(x))} assert expr.find(sin, group=True) == {sin(x): 2, sin(sin(x)): 1} def test_count(): expr = (x + y + 2 + sin(3*x)) assert expr.count(lambda u: u.is_Integer) == 2 assert expr.count(lambda u: u.is_Symbol) == 3 assert expr.count(Integer) == 2 assert expr.count(Symbol) == 3 assert expr.count(2) == 1 a = Wild('a') assert expr.count(sin) == 1 assert expr.count(sin(a)) == 1 assert expr.count(lambda u: type(u) is sin) == 1 f = Function('f') assert f(x).count(f(x)) == 1 assert f(x).diff(x).count(f(x)) == 1 assert f(x).diff(x).count(x) == 2 def test_has_basics(): f = Function('f') g = Function('g') p = Wild('p') assert sin(x).has(x) assert sin(x).has(sin) assert not sin(x).has(y) assert not sin(x).has(cos) assert f(x).has(x) assert f(x).has(f) assert not f(x).has(y) assert not f(x).has(g) assert f(x).diff(x).has(x) assert f(x).diff(x).has(f) assert f(x).diff(x).has(Derivative) assert not f(x).diff(x).has(y) assert not f(x).diff(x).has(g) assert not f(x).diff(x).has(sin) assert (x**2).has(Symbol) assert not (x**2).has(Wild) assert (2*p).has(Wild) assert not x.has() def test_has_multiple(): f = x**2*y + sin(2**t + log(z)) assert f.has(x) assert f.has(y) assert f.has(z) assert f.has(t) assert not f.has(u) assert f.has(x, y, z, t) assert f.has(x, y, z, t, u) i = Integer(4400) assert not i.has(x) assert (i*x**i).has(x) assert not (i*y**i).has(x) assert (i*y**i).has(x, y) assert not (i*y**i).has(x, z) def test_has_piecewise(): f = (x*y + 3/y)**(3 + 2) g = Function('g') h = Function('h') p = Piecewise((g(x), x < -1), (1, x <= 1), (f, True)) assert p.has(x) assert p.has(y) assert not p.has(z) assert p.has(1) assert p.has(3) assert not p.has(4) assert p.has(f) assert p.has(g) assert not p.has(h) def test_has_iterative(): A, B, C = symbols('A,B,C', commutative=False) f = x*gamma(x)*sin(x)*exp(x*y)*A*B*C*cos(x*A*B) assert f.has(x) assert f.has(x*y) assert f.has(x*sin(x)) assert not f.has(x*sin(y)) assert f.has(x*A) assert f.has(x*A*B) assert not f.has(x*A*C) assert f.has(x*A*B*C) assert not f.has(x*A*C*B) assert f.has(x*sin(x)*A*B*C) assert not f.has(x*sin(x)*A*C*B) assert not f.has(x*sin(y)*A*B*C) assert f.has(x*gamma(x)) assert not f.has(x + sin(x)) assert (x & y & z).has(x & z) def test_has_integrals(): f = Integral(x**2 + sin(x*y*z), (x, 0, x + y + z)) assert f.has(x + y) assert f.has(x + z) assert f.has(y + z) assert f.has(x*y) assert f.has(x*z) assert f.has(y*z) assert not f.has(2*x + y) assert not f.has(2*x*y) def test_has_tuple(): f = Function('f') g = Function('g') h = Function('h') assert Tuple(x, y).has(x) assert not Tuple(x, y).has(z) assert Tuple(f(x), g(x)).has(x) assert not Tuple(f(x), g(x)).has(y) assert Tuple(f(x), g(x)).has(f) assert Tuple(f(x), g(x)).has(f(x)) assert not Tuple(f, g).has(x) assert Tuple(f, g).has(f) assert not Tuple(f, g).has(h) assert Tuple(True).has(True) is True # .has(1) will also be True def test_has_units(): from sympy.physics.units import m, s assert (x*m/s).has(x) assert (x*m/s).has(y, z) is False def test_has_polys(): poly = Poly(x**2 + x*y*sin(z), x, y, t) assert poly.has(x) assert poly.has(x, y, z) assert poly.has(x, y, z, t) def test_has_physics(): assert FockState((x, y)).has(x) def test_as_poly_as_expr(): f = x**2 + 2*x*y assert f.as_poly().as_expr() == f assert f.as_poly(x, y).as_expr() == f assert (f + sin(x)).as_poly(x, y) is None p = Poly(f, x, y) assert p.as_poly() == p def test_nonzero(): assert bool(S.Zero) is False assert bool(S.One) is True assert bool(x) is True assert bool(x + y) is True assert bool(x - x) is False assert bool(x*y) is True assert bool(x*1) is True assert bool(x*0) is False def test_is_number(): assert Float(3.14).is_number is True assert Integer(737).is_number is True assert Rational(3, 2).is_number is True assert Rational(8).is_number is True assert x.is_number is False assert (2*x).is_number is False assert (x + y).is_number is False assert log(2).is_number is True assert log(x).is_number is False assert (2 + log(2)).is_number is True assert (8 + log(2)).is_number is True assert (2 + log(x)).is_number is False assert (8 + log(2) + x).is_number is False assert (1 + x**2/x - x).is_number is True assert Tuple(Integer(1)).is_number is False assert Add(2, x).is_number is False assert Mul(3, 4).is_number is True assert Pow(log(2), 2).is_number is True assert oo.is_number is True g = WildFunction('g') assert g.is_number is False assert (2*g).is_number is False assert (x**2).subs(x, 3).is_number is True # test extensibility of .is_number # on subinstances of Basic class A(Basic): pass a = A() assert a.is_number is False def test_as_coeff_add(): assert S(2).as_coeff_add() == (2, ()) assert S(3.0).as_coeff_add() == (0, (S(3.0),)) assert S(-3.0).as_coeff_add() == (0, (S(-3.0),)) assert x.as_coeff_add() == (0, (x,)) assert (x - 1).as_coeff_add() == (-1, (x,)) assert (x + 1).as_coeff_add() == (1, (x,)) assert (x + 2).as_coeff_add() == (2, (x,)) assert (x + y).as_coeff_add(y) == (x, (y,)) assert (3*x).as_coeff_add(y) == (3*x, ()) # don't do expansion e = (x + y)**2 assert e.as_coeff_add(y) == (0, (e,)) def test_as_coeff_mul(): assert S(2).as_coeff_mul() == (2, ()) assert S(3.0).as_coeff_mul() == (1, (S(3.0),)) assert S(-3.0).as_coeff_mul() == (-1, (S(3.0),)) assert S(-3.0).as_coeff_mul(rational=False) == (-S(3.0), ()) assert x.as_coeff_mul() == (1, (x,)) assert (-x).as_coeff_mul() == (-1, (x,)) assert (2*x).as_coeff_mul() == (2, (x,)) assert (x*y).as_coeff_mul(y) == (x, (y,)) assert (3 + x).as_coeff_mul() == (1, (3 + x,)) assert (3 + x).as_coeff_mul(y) == (3 + x, ()) # don't do expansion e = exp(x + y) assert e.as_coeff_mul(y) == (1, (e,)) e = 2**(x + y) assert e.as_coeff_mul(y) == (1, (e,)) assert (1.1*x).as_coeff_mul(rational=False) == (1.1, (x,)) assert (1.1*x).as_coeff_mul() == (1, (1.1, x)) assert (-oo*x).as_coeff_mul(rational=True) == (-1, (oo, x)) def test_as_coeff_exponent(): assert (3*x**4).as_coeff_exponent(x) == (3, 4) assert (2*x**3).as_coeff_exponent(x) == (2, 3) assert (4*x**2).as_coeff_exponent(x) == (4, 2) assert (6*x**1).as_coeff_exponent(x) == (6, 1) assert (3*x**0).as_coeff_exponent(x) == (3, 0) assert (2*x**0).as_coeff_exponent(x) == (2, 0) assert (1*x**0).as_coeff_exponent(x) == (1, 0) assert (0*x**0).as_coeff_exponent(x) == (0, 0) assert (-1*x**0).as_coeff_exponent(x) == (-1, 0) assert (-2*x**0).as_coeff_exponent(x) == (-2, 0) assert (2*x**3 + pi*x**3).as_coeff_exponent(x) == (2 + pi, 3) assert (x*log(2)/(2*x + pi*x)).as_coeff_exponent(x) == \ (log(2)/(2 + pi), 0) # issue 4784 D = Derivative f = Function('f') fx = D(f(x), x) assert fx.as_coeff_exponent(f(x)) == (fx, 0) def test_extractions(): assert ((x*y)**3).extract_multiplicatively(x**2 * y) == x*y**2 assert ((x*y)**3).extract_multiplicatively(x**4 * y) is None assert (2*x).extract_multiplicatively(2) == x assert (2*x).extract_multiplicatively(3) is None assert (2*x).extract_multiplicatively(-1) is None assert (Rational(1, 2)*x).extract_multiplicatively(3) == x/6 assert (sqrt(x)).extract_multiplicatively(x) is None assert (sqrt(x)).extract_multiplicatively(1/x) is None assert x.extract_multiplicatively(-x) is None assert (-2 - 4*I).extract_multiplicatively(-2) == 1 + 2*I assert (-2 - 4*I).extract_multiplicatively(3) is None assert (-2*x - 4*y - 8).extract_multiplicatively(-2) == x + 2*y + 4 assert (-2*x*y - 4*x**2*y).extract_multiplicatively(-2*y) == 2*x**2 + x assert (2*x*y + 4*x**2*y).extract_multiplicatively(2*y) == 2*x**2 + x assert (-4*y**2*x).extract_multiplicatively(-3*y) is None assert (2*x).extract_multiplicatively(1) == 2*x assert (-oo).extract_multiplicatively(5) == -oo assert (oo).extract_multiplicatively(5) == oo assert ((x*y)**3).extract_additively(1) is None assert (x + 1).extract_additively(x) == 1 assert (x + 1).extract_additively(2*x) is None assert (x + 1).extract_additively(-x) is None assert (-x + 1).extract_additively(2*x) is None assert (2*x + 3).extract_additively(x) == x + 3 assert (2*x + 3).extract_additively(2) == 2*x + 1 assert (2*x + 3).extract_additively(3) == 2*x assert (2*x + 3).extract_additively(-2) is None assert (2*x + 3).extract_additively(3*x) is None assert (2*x + 3).extract_additively(2*x) == 3 assert x.extract_additively(0) == x assert S(2).extract_additively(x) is None assert S(2.).extract_additively(2) == S.Zero assert S(2*x + 3).extract_additively(x + 1) == x + 2 assert S(2*x + 3).extract_additively(y + 1) is None assert S(2*x - 3).extract_additively(x + 1) is None assert S(2*x - 3).extract_additively(y + z) is None assert ((a + 1)*x*4 + y).extract_additively(x).expand() == \ 4*a*x + 3*x + y assert ((a + 1)*x*4 + 3*y).extract_additively(x + 2*y).expand() == \ 4*a*x + 3*x + y assert (y*(x + 1)).extract_additively(x + 1) is None assert ((y + 1)*(x + 1) + 3).extract_additively(x + 1) == \ y*(x + 1) + 3 assert ((x + y)*(x + 1) + x + y + 3).extract_additively(x + y) == \ x*(x + y) + 3 assert (x + y + 2*((x + y)*(x + 1)) + 3).extract_additively((x + y)*(x + 1)) == \ x + y + (x + 1)*(x + y) + 3 assert ((y + 1)*(x + 2*y + 1) + 3).extract_additively(y + 1) == \ (x + 2*y)*(y + 1) + 3 n = Symbol("n", integer=True) assert (Integer(-3)).could_extract_minus_sign() is True assert (-n*x + x).could_extract_minus_sign() != \ (n*x - x).could_extract_minus_sign() assert (x - y).could_extract_minus_sign() != \ (-x + y).could_extract_minus_sign() assert (1 - x - y).could_extract_minus_sign() is True assert (1 - x + y).could_extract_minus_sign() is False assert ((-x - x*y)/y).could_extract_minus_sign() is True assert (-(x + x*y)/y).could_extract_minus_sign() is True assert ((x + x*y)/(-y)).could_extract_minus_sign() is True assert ((x + x*y)/y).could_extract_minus_sign() is False assert (x*(-x - x**3)).could_extract_minus_sign() is True assert ((-x - y)/(x + y)).could_extract_minus_sign() is True class sign_invariant(Function, Expr): nargs = 1 def __neg__(self): return self foo = sign_invariant(x) assert foo == -foo assert foo.could_extract_minus_sign() is False # The results of each of these will vary on different machines, e.g. # the first one might be False and the other (then) is true or vice versa, # so both are included. assert ((-x - y)/(x - y)).could_extract_minus_sign() is False or \ ((-x - y)/(y - x)).could_extract_minus_sign() is False assert (x - y).could_extract_minus_sign() is False assert (-x + y).could_extract_minus_sign() is True def test_nan_extractions(): for r in (1, 0, I, nan): assert nan.extract_additively(r) is None assert nan.extract_multiplicatively(r) is None def test_coeff(): assert (x + 1).coeff(x + 1) == 1 assert (3*x).coeff(0) == 0 assert (z*(1 + x)*x**2).coeff(1 + x) == z*x**2 assert (1 + 2*x*x**(1 + x)).coeff(x*x**(1 + x)) == 2 assert (1 + 2*x**(y + z)).coeff(x**(y + z)) == 2 assert (3 + 2*x + 4*x**2).coeff(1) == 0 assert (3 + 2*x + 4*x**2).coeff(-1) == 0 assert (3 + 2*x + 4*x**2).coeff(x) == 2 assert (3 + 2*x + 4*x**2).coeff(x**2) == 4 assert (3 + 2*x + 4*x**2).coeff(x**3) == 0 assert (-x/8 + x*y).coeff(x) == -S(1)/8 + y assert (-x/8 + x*y).coeff(-x) == S(1)/8 assert (4*x).coeff(2*x) == 0 assert (2*x).coeff(2*x) == 1 assert (-oo*x).coeff(x*oo) == -1 assert (10*x).coeff(x, 0) == 0 assert (10*x).coeff(10*x, 0) == 0 n1, n2 = symbols('n1 n2', commutative=False) assert (n1*n2).coeff(n1) == 1 assert (n1*n2).coeff(n2) == n1 assert (n1*n2 + x*n1).coeff(n1) == 1 # 1*n1*(n2+x) assert (n2*n1 + x*n1).coeff(n1) == n2 + x assert (n2*n1 + x*n1**2).coeff(n1) == n2 assert (n1**x).coeff(n1) == 0 assert (n1*n2 + n2*n1).coeff(n1) == 0 assert (2*(n1 + n2)*n2).coeff(n1 + n2, right=1) == n2 assert (2*(n1 + n2)*n2).coeff(n1 + n2, right=0) == 2 f = Function('f') assert (2*f(x) + 3*f(x).diff(x)).coeff(f(x)) == 2 expr = z*(x + y)**2 expr2 = z*(x + y)**2 + z*(2*x + 2*y)**2 assert expr.coeff(z) == (x + y)**2 assert expr.coeff(x + y) == 0 assert expr2.coeff(z) == (x + y)**2 + (2*x + 2*y)**2 assert (x + y + 3*z).coeff(1) == x + y assert (-x + 2*y).coeff(-1) == x assert (x - 2*y).coeff(-1) == 2*y assert (3 + 2*x + 4*x**2).coeff(1) == 0 assert (-x - 2*y).coeff(2) == -y assert (x + sqrt(2)*x).coeff(sqrt(2)) == x assert (3 + 2*x + 4*x**2).coeff(x) == 2 assert (3 + 2*x + 4*x**2).coeff(x**2) == 4 assert (3 + 2*x + 4*x**2).coeff(x**3) == 0 assert (z*(x + y)**2).coeff((x + y)**2) == z assert (z*(x + y)**2).coeff(x + y) == 0 assert (2 + 2*x + (x + 1)*y).coeff(x + 1) == y assert (x + 2*y + 3).coeff(1) == x assert (x + 2*y + 3).coeff(x, 0) == 2*y + 3 assert (x**2 + 2*y + 3*x).coeff(x**2, 0) == 2*y + 3*x assert x.coeff(0, 0) == 0 assert x.coeff(x, 0) == 0 n, m, o, l = symbols('n m o l', commutative=False) assert n.coeff(n) == 1 assert y.coeff(n) == 0 assert (3*n).coeff(n) == 3 assert (2 + n).coeff(x*m) == 0 assert (2*x*n*m).coeff(x) == 2*n*m assert (2 + n).coeff(x*m*n + y) == 0 assert (2*x*n*m).coeff(3*n) == 0 assert (n*m + m*n*m).coeff(n) == 1 + m assert (n*m + m*n*m).coeff(n, right=True) == m # = (1 + m)*n*m assert (n*m + m*n).coeff(n) == 0 assert (n*m + o*m*n).coeff(m*n) == o assert (n*m + o*m*n).coeff(m*n, right=1) == 1 assert (n*m + n*m*n).coeff(n*m, right=1) == 1 + n # = n*m*(n + 1) assert (x*y).coeff(z, 0) == x*y def test_coeff2(): r, kappa = symbols('r, kappa') psi = Function("psi") g = 1/r**2 * (2*r*psi(r).diff(r, 1) + r**2 * psi(r).diff(r, 2)) g = g.expand() assert g.coeff((psi(r).diff(r))) == 2/r def test_coeff2_0(): r, kappa = symbols('r, kappa') psi = Function("psi") g = 1/r**2 * (2*r*psi(r).diff(r, 1) + r**2 * psi(r).diff(r, 2)) g = g.expand() assert g.coeff(psi(r).diff(r, 2)) == 1 def test_coeff_expand(): expr = z*(x + y)**2 expr2 = z*(x + y)**2 + z*(2*x + 2*y)**2 assert expr.coeff(z) == (x + y)**2 assert expr2.coeff(z) == (x + y)**2 + (2*x + 2*y)**2 def test_integrate(): assert x.integrate(x) == x**2/2 assert x.integrate((x, 0, 1)) == S(1)/2 def test_as_base_exp(): assert x.as_base_exp() == (x, S.One) assert (x*y*z).as_base_exp() == (x*y*z, S.One) assert (x + y + z).as_base_exp() == (x + y + z, S.One) assert ((x + y)**z).as_base_exp() == (x + y, z) def test_issue_4963(): assert hasattr(Mul(x, y), "is_commutative") assert hasattr(Mul(x, y, evaluate=False), "is_commutative") assert hasattr(Pow(x, y), "is_commutative") assert hasattr(Pow(x, y, evaluate=False), "is_commutative") expr = Mul(Pow(2, 2, evaluate=False), 3, evaluate=False) + 1 assert hasattr(expr, "is_commutative") def test_action_verbs(): assert nsimplify((1/(exp(3*pi*x/5) + 1))) == \ (1/(exp(3*pi*x/5) + 1)).nsimplify() assert ratsimp(1/x + 1/y) == (1/x + 1/y).ratsimp() assert trigsimp(log(x), deep=True) == (log(x)).trigsimp(deep=True) assert radsimp(1/(2 + sqrt(2))) == (1/(2 + sqrt(2))).radsimp() assert radsimp(1/(a + b*sqrt(c)), symbolic=False) == \ (1/(a + b*sqrt(c))).radsimp(symbolic=False) assert powsimp(x**y*x**z*y**z, combine='all') == \ (x**y*x**z*y**z).powsimp(combine='all') assert (x**t*y**t).powsimp(force=True) == (x*y)**t assert simplify(x**y*x**z*y**z) == (x**y*x**z*y**z).simplify() assert together(1/x + 1/y) == (1/x + 1/y).together() assert collect(a*x**2 + b*x**2 + a*x - b*x + c, x) == \ (a*x**2 + b*x**2 + a*x - b*x + c).collect(x) assert apart(y/(y + 2)/(y + 1), y) == (y/(y + 2)/(y + 1)).apart(y) assert combsimp(y/(x + 2)/(x + 1)) == (y/(x + 2)/(x + 1)).combsimp() assert gammasimp(gamma(x)/gamma(x-5)) == (gamma(x)/gamma(x-5)).gammasimp() assert factor(x**2 + 5*x + 6) == (x**2 + 5*x + 6).factor() assert refine(sqrt(x**2)) == sqrt(x**2).refine() assert cancel((x**2 + 5*x + 6)/(x + 2)) == ((x**2 + 5*x + 6)/(x + 2)).cancel() def test_as_powers_dict(): assert x.as_powers_dict() == {x: 1} assert (x**y*z).as_powers_dict() == {x: y, z: 1} assert Mul(2, 2, evaluate=False).as_powers_dict() == {S(2): S(2)} assert (x*y).as_powers_dict()[z] == 0 assert (x + y).as_powers_dict()[z] == 0 def test_as_coefficients_dict(): check = [S(1), x, y, x*y, 1] assert [Add(3*x, 2*x, y, 3).as_coefficients_dict()[i] for i in check] == \ [3, 5, 1, 0, 3] assert [Add(3*x, 2*x, y, 3, evaluate=False).as_coefficients_dict()[i] for i in check] == [3, 5, 1, 0, 3] assert [(3*x*y).as_coefficients_dict()[i] for i in check] == \ [0, 0, 0, 3, 0] assert [(3.0*x*y).as_coefficients_dict()[i] for i in check] == \ [0, 0, 0, 3.0, 0] assert (3.0*x*y).as_coefficients_dict()[3.0*x*y] == 0 def test_args_cnc(): A = symbols('A', commutative=False) assert (x + A).args_cnc() == \ [[], [x + A]] assert (x + a).args_cnc() == \ [[a + x], []] assert (x*a).args_cnc() == \ [[a, x], []] assert (x*y*A*(A + 1)).args_cnc(cset=True) == \ [{x, y}, [A, 1 + A]] assert Mul(x, x, evaluate=False).args_cnc(cset=True, warn=False) == \ [{x}, []] assert Mul(x, x**2, evaluate=False).args_cnc(cset=True, warn=False) == \ [{x, x**2}, []] raises(ValueError, lambda: Mul(x, x, evaluate=False).args_cnc(cset=True)) assert Mul(x, y, x, evaluate=False).args_cnc() == \ [[x, y, x], []] # always split -1 from leading number assert (-1.*x).args_cnc() == [[-1, 1.0, x], []] def test_new_rawargs(): n = Symbol('n', commutative=False) a = x + n assert a.is_commutative is False assert a._new_rawargs(x).is_commutative assert a._new_rawargs(x, y).is_commutative assert a._new_rawargs(x, n).is_commutative is False assert a._new_rawargs(x, y, n).is_commutative is False m = x*n assert m.is_commutative is False assert m._new_rawargs(x).is_commutative assert m._new_rawargs(n).is_commutative is False assert m._new_rawargs(x, y).is_commutative assert m._new_rawargs(x, n).is_commutative is False assert m._new_rawargs(x, y, n).is_commutative is False assert m._new_rawargs(x, n, reeval=False).is_commutative is False assert m._new_rawargs(S.One) is S.One def test_issue_5226(): assert Add(evaluate=False) == 0 assert Mul(evaluate=False) == 1 assert Mul(x + y, evaluate=False).is_Add def test_free_symbols(): # free_symbols should return the free symbols of an object assert S(1).free_symbols == set() assert (x).free_symbols == {x} assert Integral(x, (x, 1, y)).free_symbols == {y} assert (-Integral(x, (x, 1, y))).free_symbols == {y} assert meter.free_symbols == set() assert (meter**x).free_symbols == {x} def test_issue_5300(): x = Symbol('x', commutative=False) assert x*sqrt(2)/sqrt(6) == x*sqrt(3)/3 def test_floordiv(): from sympy.functions.elementary.integers import floor assert x // y == floor(x / y) def test_as_coeff_Mul(): assert S(0).as_coeff_Mul() == (S.One, S.Zero) assert Integer(3).as_coeff_Mul() == (Integer(3), Integer(1)) assert Rational(3, 4).as_coeff_Mul() == (Rational(3, 4), Integer(1)) assert Float(5.0).as_coeff_Mul() == (Float(5.0), Integer(1)) assert (Integer(3)*x).as_coeff_Mul() == (Integer(3), x) assert (Rational(3, 4)*x).as_coeff_Mul() == (Rational(3, 4), x) assert (Float(5.0)*x).as_coeff_Mul() == (Float(5.0), x) assert (Integer(3)*x*y).as_coeff_Mul() == (Integer(3), x*y) assert (Rational(3, 4)*x*y).as_coeff_Mul() == (Rational(3, 4), x*y) assert (Float(5.0)*x*y).as_coeff_Mul() == (Float(5.0), x*y) assert (x).as_coeff_Mul() == (S.One, x) assert (x*y).as_coeff_Mul() == (S.One, x*y) assert (-oo*x).as_coeff_Mul(rational=True) == (-1, oo*x) def test_as_coeff_Add(): assert Integer(3).as_coeff_Add() == (Integer(3), Integer(0)) assert Rational(3, 4).as_coeff_Add() == (Rational(3, 4), Integer(0)) assert Float(5.0).as_coeff_Add() == (Float(5.0), Integer(0)) assert (Integer(3) + x).as_coeff_Add() == (Integer(3), x) assert (Rational(3, 4) + x).as_coeff_Add() == (Rational(3, 4), x) assert (Float(5.0) + x).as_coeff_Add() == (Float(5.0), x) assert (Float(5.0) + x).as_coeff_Add(rational=True) == (0, Float(5.0) + x) assert (Integer(3) + x + y).as_coeff_Add() == (Integer(3), x + y) assert (Rational(3, 4) + x + y).as_coeff_Add() == (Rational(3, 4), x + y) assert (Float(5.0) + x + y).as_coeff_Add() == (Float(5.0), x + y) assert (x).as_coeff_Add() == (S.Zero, x) assert (x*y).as_coeff_Add() == (S.Zero, x*y) def test_expr_sorting(): f, g = symbols('f,g', cls=Function) exprs = [1/x**2, 1/x, sqrt(sqrt(x)), sqrt(x), x, sqrt(x)**3, x**2] assert sorted(exprs, key=default_sort_key) == exprs exprs = [x, 2*x, 2*x**2, 2*x**3, x**n, 2*x**n, sin(x), sin(x)**n, sin(x**2), cos(x), cos(x**2), tan(x)] assert sorted(exprs, key=default_sort_key) == exprs exprs = [x + 1, x**2 + x + 1, x**3 + x**2 + x + 1] assert sorted(exprs, key=default_sort_key) == exprs exprs = [S(4), x - 3*I/2, x + 3*I/2, x - 4*I + 1, x + 4*I + 1] assert sorted(exprs, key=default_sort_key) == exprs exprs = [f(1), f(2), f(3), f(1, 2, 3), g(1), g(2), g(3), g(1, 2, 3)] assert sorted(exprs, key=default_sort_key) == exprs exprs = [f(x), g(x), exp(x), sin(x), cos(x), factorial(x)] assert sorted(exprs, key=default_sort_key) == exprs exprs = [Tuple(x, y), Tuple(x, z), Tuple(x, y, z)] assert sorted(exprs, key=default_sort_key) == exprs exprs = [[3], [1, 2]] assert sorted(exprs, key=default_sort_key) == exprs exprs = [[1, 2], [2, 3]] assert sorted(exprs, key=default_sort_key) == exprs exprs = [[1, 2], [1, 2, 3]] assert sorted(exprs, key=default_sort_key) == exprs exprs = [{x: -y}, {x: y}] assert sorted(exprs, key=default_sort_key) == exprs exprs = [{1}, {1, 2}] assert sorted(exprs, key=default_sort_key) == exprs a, b = exprs = [Dummy('x'), Dummy('x')] assert sorted([b, a], key=default_sort_key) == exprs def test_as_ordered_factors(): f, g = symbols('f,g', cls=Function) assert x.as_ordered_factors() == [x] assert (2*x*x**n*sin(x)*cos(x)).as_ordered_factors() \ == [Integer(2), x, x**n, sin(x), cos(x)] args = [f(1), f(2), f(3), f(1, 2, 3), g(1), g(2), g(3), g(1, 2, 3)] expr = Mul(*args) assert expr.as_ordered_factors() == args A, B = symbols('A,B', commutative=False) assert (A*B).as_ordered_factors() == [A, B] assert (B*A).as_ordered_factors() == [B, A] def test_as_ordered_terms(): f, g = symbols('f,g', cls=Function) assert x.as_ordered_terms() == [x] assert (sin(x)**2*cos(x) + sin(x)*cos(x)**2 + 1).as_ordered_terms() \ == [sin(x)**2*cos(x), sin(x)*cos(x)**2, 1] args = [f(1), f(2), f(3), f(1, 2, 3), g(1), g(2), g(3), g(1, 2, 3)] expr = Add(*args) assert expr.as_ordered_terms() == args assert (1 + 4*sqrt(3)*pi*x).as_ordered_terms() == [4*pi*x*sqrt(3), 1] assert ( 2 + 3*I).as_ordered_terms() == [2, 3*I] assert (-2 + 3*I).as_ordered_terms() == [-2, 3*I] assert ( 2 - 3*I).as_ordered_terms() == [2, -3*I] assert (-2 - 3*I).as_ordered_terms() == [-2, -3*I] assert ( 4 + 3*I).as_ordered_terms() == [4, 3*I] assert (-4 + 3*I).as_ordered_terms() == [-4, 3*I] assert ( 4 - 3*I).as_ordered_terms() == [4, -3*I] assert (-4 - 3*I).as_ordered_terms() == [-4, -3*I] f = x**2*y**2 + x*y**4 + y + 2 assert f.as_ordered_terms(order="lex") == [x**2*y**2, x*y**4, y, 2] assert f.as_ordered_terms(order="grlex") == [x*y**4, x**2*y**2, y, 2] assert f.as_ordered_terms(order="rev-lex") == [2, y, x*y**4, x**2*y**2] assert f.as_ordered_terms(order="rev-grlex") == [2, y, x**2*y**2, x*y**4] k = symbols('k') assert k.as_ordered_terms(data=True) == ([(k, ((1.0, 0.0), (1,), ()))], [k]) def test_sort_key_atomic_expr(): from sympy.physics.units import m, s assert sorted([-m, s], key=lambda arg: arg.sort_key()) == [-m, s] def test_eval_interval(): assert exp(x)._eval_interval(*Tuple(x, 0, 1)) == exp(1) - exp(0) # issue 4199 # first subs and limit gives NaN a = x/y assert a._eval_interval(x, S(0), oo)._eval_interval(y, oo, S(0)) is S.NaN # second subs and limit gives NaN assert a._eval_interval(x, S(0), oo)._eval_interval(y, S(0), oo) is S.NaN # difference gives S.NaN a = x - y assert a._eval_interval(x, S(1), oo)._eval_interval(y, oo, S(1)) is S.NaN raises(ValueError, lambda: x._eval_interval(x, None, None)) a = -y*Heaviside(x - y) assert a._eval_interval(x, -oo, oo) == -y assert a._eval_interval(x, oo, -oo) == y def test_eval_interval_zoo(): # Test that limit is used when zoo is returned assert Si(1/x)._eval_interval(x, S(0), S(1)) == -pi/2 + Si(1) def test_primitive(): assert (3*(x + 1)**2).primitive() == (3, (x + 1)**2) assert (6*x + 2).primitive() == (2, 3*x + 1) assert (x/2 + 3).primitive() == (S(1)/2, x + 6) eq = (6*x + 2)*(x/2 + 3) assert eq.primitive()[0] == 1 eq = (2 + 2*x)**2 assert eq.primitive()[0] == 1 assert (4.0*x).primitive() == (1, 4.0*x) assert (4.0*x + y/2).primitive() == (S.Half, 8.0*x + y) assert (-2*x).primitive() == (2, -x) assert Add(5*z/7, 0.5*x, 3*y/2, evaluate=False).primitive() == \ (S(1)/14, 7.0*x + 21*y + 10*z) for i in [S.Infinity, S.NegativeInfinity, S.ComplexInfinity]: assert (i + x/3).primitive() == \ (S(1)/3, i + x) assert (S.Infinity + 2*x/3 + 4*y/7).primitive() == \ (S(1)/21, 14*x + 12*y + oo) assert S.Zero.primitive() == (S.One, S.Zero) def test_issue_5843(): a = 1 + x assert (2*a).extract_multiplicatively(a) == 2 assert (4*a).extract_multiplicatively(2*a) == 2 assert ((3*a)*(2*a)).extract_multiplicatively(a) == 6*a def test_is_constant(): from sympy.solvers.solvers import checksol Sum(x, (x, 1, 10)).is_constant() is True Sum(x, (x, 1, n)).is_constant() is False Sum(x, (x, 1, n)).is_constant(y) is True Sum(x, (x, 1, n)).is_constant(n) is False Sum(x, (x, 1, n)).is_constant(x) is True eq = a*cos(x)**2 + a*sin(x)**2 - a eq.is_constant() is True assert eq.subs({x: pi, a: 2}) == eq.subs({x: pi, a: 3}) == 0 assert x.is_constant() is False assert x.is_constant(y) is True assert checksol(x, x, Sum(x, (x, 1, n))) is False assert checksol(x, x, Sum(x, (x, 1, n))) is False f = Function('f') assert f(1).is_constant assert checksol(x, x, f(x)) is False assert Pow(x, S(0), evaluate=False).is_constant() is True # == 1 assert Pow(S(0), x, evaluate=False).is_constant() is False # == 0 or 1 assert (2**x).is_constant() is False assert Pow(S(2), S(3), evaluate=False).is_constant() is True z1, z2 = symbols('z1 z2', zero=True) assert (z1 + 2*z2).is_constant() is True assert meter.is_constant() is True assert (3*meter).is_constant() is True assert (x*meter).is_constant() is False assert Poly(3,x).is_constant() is True def test_equals(): assert (-3 - sqrt(5) + (-sqrt(10)/2 - sqrt(2)/2)**2).equals(0) assert (x**2 - 1).equals((x + 1)*(x - 1)) assert (cos(x)**2 + sin(x)**2).equals(1) assert (a*cos(x)**2 + a*sin(x)**2).equals(a) r = sqrt(2) assert (-1/(r + r*x) + 1/r/(1 + x)).equals(0) assert factorial(x + 1).equals((x + 1)*factorial(x)) assert sqrt(3).equals(2*sqrt(3)) is False assert (sqrt(5)*sqrt(3)).equals(sqrt(3)) is False assert (sqrt(5) + sqrt(3)).equals(0) is False assert (sqrt(5) + pi).equals(0) is False assert meter.equals(0) is False assert (3*meter**2).equals(0) is False eq = -(-1)**(S(3)/4)*6**(S(1)/4) + (-6)**(S(1)/4)*I if eq != 0: # if canonicalization makes this zero, skip the test assert eq.equals(0) assert sqrt(x).equals(0) is False # from integrate(x*sqrt(1 + 2*x), x); # diff is zero only when assumptions allow i = 2*sqrt(2)*x**(S(5)/2)*(1 + 1/(2*x))**(S(5)/2)/5 + \ 2*sqrt(2)*x**(S(3)/2)*(1 + 1/(2*x))**(S(5)/2)/(-6 - 3/x) ans = sqrt(2*x + 1)*(6*x**2 + x - 1)/15 diff = i - ans assert diff.equals(0) is False assert diff.subs(x, -S.Half/2) == 7*sqrt(2)/120 # there are regions for x for which the expression is True, for # example, when x < -1/2 or x > 0 the expression is zero p = Symbol('p', positive=True) assert diff.subs(x, p).equals(0) is True assert diff.subs(x, -1).equals(0) is True # prove via minimal_polynomial or self-consistency eq = sqrt(1 + sqrt(3)) + sqrt(3 + 3*sqrt(3)) - sqrt(10 + 6*sqrt(3)) assert eq.equals(0) q = 3**Rational(1, 3) + 3 p = expand(q**3)**Rational(1, 3) assert (p - q).equals(0) # issue 6829 # eq = q*x + q/4 + x**4 + x**3 + 2*x**2 - S(1)/3 # z = eq.subs(x, solve(eq, x)[0]) q = symbols('q') z = (q*(-sqrt(-2*(-(q - S(7)/8)**S(2)/8 - S(2197)/13824)**(S(1)/3) - S(13)/12)/2 - sqrt((2*q - S(7)/4)/sqrt(-2*(-(q - S(7)/8)**S(2)/8 - S(2197)/13824)**(S(1)/3) - S(13)/12) + 2*(-(q - S(7)/8)**S(2)/8 - S(2197)/13824)**(S(1)/3) - S(13)/6)/2 - S(1)/4) + q/4 + (-sqrt(-2*(-(q - S(7)/8)**S(2)/8 - S(2197)/13824)**(S(1)/3) - S(13)/12)/2 - sqrt((2*q - S(7)/4)/sqrt(-2*(-(q - S(7)/8)**S(2)/8 - S(2197)/13824)**(S(1)/3) - S(13)/12) + 2*(-(q - S(7)/8)**S(2)/8 - S(2197)/13824)**(S(1)/3) - S(13)/6)/2 - S(1)/4)**4 + (-sqrt(-2*(-(q - S(7)/8)**S(2)/8 - S(2197)/13824)**(S(1)/3) - S(13)/12)/2 - sqrt((2*q - S(7)/4)/sqrt(-2*(-(q - S(7)/8)**S(2)/8 - S(2197)/13824)**(S(1)/3) - S(13)/12) + 2*(-(q - S(7)/8)**S(2)/8 - S(2197)/13824)**(S(1)/3) - S(13)/6)/2 - S(1)/4)**3 + 2*(-sqrt(-2*(-(q - S(7)/8)**S(2)/8 - S(2197)/13824)**(S(1)/3) - S(13)/12)/2 - sqrt((2*q - S(7)/4)/sqrt(-2*(-(q - S(7)/8)**S(2)/8 - S(2197)/13824)**(S(1)/3) - S(13)/12) + 2*(-(q - S(7)/8)**S(2)/8 - S(2197)/13824)**(S(1)/3) - S(13)/6)/2 - S(1)/4)**2 - S(1)/3) assert z.equals(0) def test_random(): from sympy import posify, lucas assert posify(x)[0]._random() is not None assert lucas(n)._random(2, -2, 0, -1, 1) is None # issue 8662 assert Piecewise((Max(x, y), z))._random() is None def test_round(): from sympy.abc import x assert Float('0.1249999').round(2) == 0.12 d20 = 12345678901234567890 ans = S(d20).round(2) assert ans.is_Float and ans == d20 ans = S(d20).round(-2) assert ans.is_Float and ans == 12345678901234567900 assert S('1/7').round(4) == 0.1429 assert S('.[12345]').round(4) == 0.1235 assert S('.1349').round(2) == 0.13 n = S(12345) ans = n.round() assert ans.is_Float assert ans == n ans = n.round(1) assert ans.is_Float assert ans == n ans = n.round(4) assert ans.is_Float assert ans == n assert n.round(-1) == 12350 r = n.round(-4) assert r == 10000 # in fact, it should equal many values since __eq__ # compares at equal precision assert all(r == i for i in range(9984, 10049)) assert n.round(-5) == 0 assert (pi + sqrt(2)).round(2) == 4.56 assert (10*(pi + sqrt(2))).round(-1) == 50 raises(TypeError, lambda: round(x + 2, 2)) assert S(2.3).round(1) == 2.3 e = S(12.345).round(2) assert e == round(12.345, 2) assert type(e) is Float assert (Float(.3, 3) + 2*pi).round() == 7 assert (Float(.3, 3) + 2*pi*100).round() == 629 assert (Float(.03, 3) + 2*pi/100).round(5) == 0.09283 assert (Float(.03, 3) + 2*pi/100).round(4) == 0.0928 assert (pi + 2*E*I).round() == 3 + 5*I assert S.Zero.round() == 0 a = (Add(1, Float('1.' + '9'*27, ''), evaluate=0)) assert a.round(10) == Float('3.0000000000', '') assert a.round(25) == Float('3.0000000000000000000000000', '') assert a.round(26) == Float('3.00000000000000000000000000', '') assert a.round(27) == Float('2.999999999999999999999999999', '') assert a.round(30) == Float('2.999999999999999999999999999', '') raises(TypeError, lambda: x.round()) f = Function('f') raises(TypeError, lambda: f(1).round()) # exact magnitude of 10 assert str(S(1).round()) == '1.' assert str(S(100).round()) == '100.' # applied to real and imaginary portions assert (2*pi + E*I).round() == 6 + 3*I assert (2*pi + I/10).round() == 6 assert (pi/10 + 2*I).round() == 2*I # the lhs re and im parts are Float with dps of 2 # and those on the right have dps of 15 so they won't compare # equal unless we use string or compare components (which will # then coerce the floats to the same precision) or re-create # the floats assert str((pi/10 + E*I).round(2)) == '0.31 + 2.72*I' assert (pi/10 + E*I).round(2).as_real_imag() == (0.31, 2.72) assert (pi/10 + E*I).round(2) == Float(0.31, 2) + I*Float(2.72, 3) # issue 6914 assert (I**(I + 3)).round(3) == Float('-0.208', '')*I # issue 8720 assert S(-123.6).round() == -124. assert S(-1.5).round() == -2. assert S(-100.5).round() == -101. assert S(-1.5 - 10.5*I).round() == -2.0 - 11.0*I # issue 7961 assert str(S(0.006).round(2)) == '0.01' assert str(S(0.00106).round(4)) == '0.0011' # issue 8147 assert S.NaN.round() == S.NaN assert S.Infinity.round() == S.Infinity assert S.NegativeInfinity.round() == S.NegativeInfinity assert S.ComplexInfinity.round() == S.ComplexInfinity def test_held_expression_UnevaluatedExpr(): x = symbols("x") he = UnevaluatedExpr(1/x) e1 = x*he assert isinstance(e1, Mul) assert e1.args == (x, he) assert e1.doit() == 1 assert UnevaluatedExpr(Derivative(x, x)).doit(deep=False ) == Derivative(x, x) assert UnevaluatedExpr(Derivative(x, x)).doit() == 1 xx = Mul(x, x, evaluate=False) assert xx != x**2 ue2 = UnevaluatedExpr(xx) assert isinstance(ue2, UnevaluatedExpr) assert ue2.args == (xx,) assert ue2.doit() == x**2 assert ue2.doit(deep=False) == xx x2 = UnevaluatedExpr(2)*2 assert type(x2) is Mul assert x2.args == (2, UnevaluatedExpr(2)) def test_round_exception_nostr(): # Don't use the string form of the expression in the round exception, as # it's too slow s = Symbol('bad') try: s.round() except TypeError as e: assert 'bad' not in str(e) else: # Did not raise raise AssertionError("Did not raise") def test_extract_branch_factor(): assert exp_polar(2.0*I*pi).extract_branch_factor() == (1, 1) def test_identity_removal(): assert Add.make_args(x + 0) == (x,) assert Mul.make_args(x*1) == (x,) def test_float_0(): assert Float(0.0) + 1 == Float(1.0) @XFAIL def test_float_0_fail(): assert Float(0.0)*x == Float(0.0) assert (x + Float(0.0)).is_Add def test_issue_6325(): ans = (b**2 + z**2 - (b*(a + b*t) + z*(c + t*z))**2/( (a + b*t)**2 + (c + t*z)**2))/sqrt((a + b*t)**2 + (c + t*z)**2) e = sqrt((a + b*t)**2 + (c + z*t)**2) assert diff(e, t, 2) == ans e.diff(t, 2) == ans assert diff(e, t, 2, simplify=False) != ans def test_issue_7426(): f1 = a % c f2 = x % z assert f1.equals(f2) is None def test_issue_1112(): x = Symbol('x', positive=False) assert (x > 0) is S.false def test_issue_10161(): x = symbols('x', real=True) assert x*abs(x)*abs(x) == x**3 def test_issue_10755(): x = symbols('x') raises(TypeError, lambda: int(log(x))) raises(TypeError, lambda: log(x).round(2)) def test_issue_11877(): x = symbols('x') assert integrate(log(S(1)/2 - x), (x, 0, S(1)/2)) == -S(1)/2 -log(2)/2 def test_normal(): x = symbols('x') e = Mul(S.Half, 1 + x, evaluate=False) assert e.normal() == e def test_ExprBuilder(): eb = ExprBuilder(Mul) eb.args.extend([x, x]) assert eb.build() == x**2
a5bfe411021317080721997d3c4ed5f2719ee0a92f615ab9d1289c9f1acb971d
"""Test whether all elements of cls.args are instances of Basic. """ # NOTE: keep tests sorted by (module, class name) key. If a class can't # be instantiated, add it here anyway with @SKIP("abstract class) (see # e.g. Function). import os import re import io from sympy import (Basic, S, symbols, sqrt, sin, oo, Interval, exp, Lambda, pi, Eq, log, Function) from sympy.core.compatibility import range from sympy.utilities.pytest import XFAIL, SKIP x, y, z = symbols('x,y,z') def test_all_classes_are_tested(): this = os.path.split(__file__)[0] path = os.path.join(this, os.pardir, os.pardir) sympy_path = os.path.abspath(path) prefix = os.path.split(sympy_path)[0] + os.sep re_cls = re.compile(r"^class ([A-Za-z][A-Za-z0-9_]*)\s*\(", re.MULTILINE) modules = {} for root, dirs, files in os.walk(sympy_path): module = root.replace(prefix, "").replace(os.sep, ".") for file in files: if file.startswith(("_", "test_", "bench_")): continue if not file.endswith(".py"): continue with io.open(os.path.join(root, file), "r", encoding='utf-8') as f: text = f.read() submodule = module + '.' + file[:-3] names = re_cls.findall(text) if not names: continue try: mod = __import__(submodule, fromlist=names) except ImportError: continue def is_Basic(name): cls = getattr(mod, name) if hasattr(cls, '_sympy_deprecated_func'): cls = cls._sympy_deprecated_func return issubclass(cls, Basic) names = list(filter(is_Basic, names)) if names: modules[submodule] = names ns = globals() failed = [] for module, names in modules.items(): mod = module.replace('.', '__') for name in names: test = 'test_' + mod + '__' + name if test not in ns: failed.append(module + '.' + name) assert not failed, "Missing classes: %s. Please add tests for these to sympy/core/tests/test_args.py." % ", ".join(failed) def _test_args(obj): return all(isinstance(arg, Basic) for arg in obj.args) def test_sympy__assumptions__assume__AppliedPredicate(): from sympy.assumptions.assume import AppliedPredicate, Predicate from sympy import Q assert _test_args(AppliedPredicate(Predicate("test"), 2)) assert _test_args(Q.is_true(True)) def test_sympy__assumptions__assume__Predicate(): from sympy.assumptions.assume import Predicate assert _test_args(Predicate("test")) def test_sympy__assumptions__sathandlers__UnevaluatedOnFree(): from sympy.assumptions.sathandlers import UnevaluatedOnFree from sympy import Q assert _test_args(UnevaluatedOnFree(Q.positive)) assert _test_args(UnevaluatedOnFree(Q.positive(x))) assert _test_args(UnevaluatedOnFree(Q.positive(x * y))) def test_sympy__assumptions__sathandlers__AllArgs(): from sympy.assumptions.sathandlers import AllArgs from sympy import Q assert _test_args(AllArgs(Q.positive)) assert _test_args(AllArgs(Q.positive(x))) assert _test_args(AllArgs(Q.positive(x*y))) def test_sympy__assumptions__sathandlers__AnyArgs(): from sympy.assumptions.sathandlers import AnyArgs from sympy import Q assert _test_args(AnyArgs(Q.positive)) assert _test_args(AnyArgs(Q.positive(x))) assert _test_args(AnyArgs(Q.positive(x*y))) def test_sympy__assumptions__sathandlers__ExactlyOneArg(): from sympy.assumptions.sathandlers import ExactlyOneArg from sympy import Q assert _test_args(ExactlyOneArg(Q.positive)) assert _test_args(ExactlyOneArg(Q.positive(x))) assert _test_args(ExactlyOneArg(Q.positive(x*y))) def test_sympy__assumptions__sathandlers__CheckOldAssump(): from sympy.assumptions.sathandlers import CheckOldAssump from sympy import Q assert _test_args(CheckOldAssump(Q.positive)) assert _test_args(CheckOldAssump(Q.positive(x))) assert _test_args(CheckOldAssump(Q.positive(x*y))) def test_sympy__assumptions__sathandlers__CheckIsPrime(): from sympy.assumptions.sathandlers import CheckIsPrime from sympy import Q # Input must be a number assert _test_args(CheckIsPrime(Q.positive)) assert _test_args(CheckIsPrime(Q.positive(5))) @SKIP("abstract Class") def test_sympy__codegen__ast__AssignmentBase(): from sympy.codegen.ast import AssignmentBase assert _test_args(AssignmentBase(x, 1)) @SKIP("abstract Class") def test_sympy__codegen__ast__AugmentedAssignment(): from sympy.codegen.ast import AugmentedAssignment assert _test_args(AugmentedAssignment(x, 1)) def test_sympy__codegen__ast__AddAugmentedAssignment(): from sympy.codegen.ast import AddAugmentedAssignment assert _test_args(AddAugmentedAssignment(x, 1)) def test_sympy__codegen__ast__SubAugmentedAssignment(): from sympy.codegen.ast import SubAugmentedAssignment assert _test_args(SubAugmentedAssignment(x, 1)) def test_sympy__codegen__ast__MulAugmentedAssignment(): from sympy.codegen.ast import MulAugmentedAssignment assert _test_args(MulAugmentedAssignment(x, 1)) def test_sympy__codegen__ast__DivAugmentedAssignment(): from sympy.codegen.ast import DivAugmentedAssignment assert _test_args(DivAugmentedAssignment(x, 1)) def test_sympy__codegen__ast__ModAugmentedAssignment(): from sympy.codegen.ast import ModAugmentedAssignment assert _test_args(ModAugmentedAssignment(x, 1)) def test_sympy__codegen__ast__CodeBlock(): from sympy.codegen.ast import CodeBlock, Assignment assert _test_args(CodeBlock(Assignment(x, 1), Assignment(y, 2))) def test_sympy__codegen__ast__For(): from sympy.codegen.ast import For, CodeBlock, AddAugmentedAssignment from sympy import Range assert _test_args(For(x, Range(10), CodeBlock(AddAugmentedAssignment(y, 1)))) def test_sympy__codegen__ast__Token(): from sympy.codegen.ast import Token assert _test_args(Token()) def test_sympy__codegen__ast__ContinueToken(): from sympy.codegen.ast import ContinueToken assert _test_args(ContinueToken()) def test_sympy__codegen__ast__BreakToken(): from sympy.codegen.ast import BreakToken assert _test_args(BreakToken()) def test_sympy__codegen__ast__NoneToken(): from sympy.codegen.ast import NoneToken assert _test_args(NoneToken()) def test_sympy__codegen__ast__String(): from sympy.codegen.ast import String assert _test_args(String('foobar')) def test_sympy__codegen__ast__QuotedString(): from sympy.codegen.ast import QuotedString assert _test_args(QuotedString('foobar')) def test_sympy__codegen__ast__Comment(): from sympy.codegen.ast import Comment assert _test_args(Comment('this is a comment')) def test_sympy__codegen__ast__Node(): from sympy.codegen.ast import Node assert _test_args(Node()) assert _test_args(Node(attrs={1, 2, 3})) def test_sympy__codegen__ast__Type(): from sympy.codegen.ast import Type assert _test_args(Type('float128')) def test_sympy__codegen__ast__IntBaseType(): from sympy.codegen.ast import IntBaseType assert _test_args(IntBaseType('bigint')) def test_sympy__codegen__ast___SizedIntType(): from sympy.codegen.ast import _SizedIntType assert _test_args(_SizedIntType('int128', 128)) def test_sympy__codegen__ast__SignedIntType(): from sympy.codegen.ast import SignedIntType assert _test_args(SignedIntType('int128_with_sign', 128)) def test_sympy__codegen__ast__UnsignedIntType(): from sympy.codegen.ast import UnsignedIntType assert _test_args(UnsignedIntType('unt128', 128)) def test_sympy__codegen__ast__FloatBaseType(): from sympy.codegen.ast import FloatBaseType assert _test_args(FloatBaseType('positive_real')) def test_sympy__codegen__ast__FloatType(): from sympy.codegen.ast import FloatType assert _test_args(FloatType('float242', 242, nmant=142, nexp=99)) def test_sympy__codegen__ast__ComplexBaseType(): from sympy.codegen.ast import ComplexBaseType assert _test_args(ComplexBaseType('positive_cmplx')) def test_sympy__codegen__ast__ComplexType(): from sympy.codegen.ast import ComplexType assert _test_args(ComplexType('complex42', 42, nmant=15, nexp=5)) def test_sympy__codegen__ast__Attribute(): from sympy.codegen.ast import Attribute assert _test_args(Attribute('noexcept')) def test_sympy__codegen__ast__Variable(): from sympy.codegen.ast import Variable, Type, value_const assert _test_args(Variable(x)) assert _test_args(Variable(y, Type('float32'), {value_const})) assert _test_args(Variable(z, type=Type('float64'))) def test_sympy__codegen__ast__Pointer(): from sympy.codegen.ast import Pointer, Type, pointer_const assert _test_args(Pointer(x)) assert _test_args(Pointer(y, type=Type('float32'))) assert _test_args(Pointer(z, Type('float64'), {pointer_const})) def test_sympy__codegen__ast__Declaration(): from sympy.codegen.ast import Declaration, Variable, Type vx = Variable(x, type=Type('float')) assert _test_args(Declaration(vx)) def test_sympy__codegen__ast__While(): from sympy.codegen.ast import While, AddAugmentedAssignment assert _test_args(While(abs(x) < 1, [AddAugmentedAssignment(x, -1)])) def test_sympy__codegen__ast__Scope(): from sympy.codegen.ast import Scope, AddAugmentedAssignment assert _test_args(Scope([AddAugmentedAssignment(x, -1)])) def test_sympy__codegen__ast__Stream(): from sympy.codegen.ast import Stream assert _test_args(Stream('stdin')) def test_sympy__codegen__ast__Print(): from sympy.codegen.ast import Print assert _test_args(Print([x, y])) assert _test_args(Print([x, y], "%d %d")) def test_sympy__codegen__ast__FunctionPrototype(): from sympy.codegen.ast import FunctionPrototype, real, Declaration, Variable inp_x = Declaration(Variable(x, type=real)) assert _test_args(FunctionPrototype(real, 'pwer', [inp_x])) def test_sympy__codegen__ast__FunctionDefinition(): from sympy.codegen.ast import FunctionDefinition, real, Declaration, Variable, Assignment inp_x = Declaration(Variable(x, type=real)) assert _test_args(FunctionDefinition(real, 'pwer', [inp_x], [Assignment(x, x**2)])) def test_sympy__codegen__ast__Return(): from sympy.codegen.ast import Return assert _test_args(Return(x)) def test_sympy__codegen__ast__FunctionCall(): from sympy.codegen.ast import FunctionCall assert _test_args(FunctionCall('pwer', [x])) def test_sympy__codegen__ast__Element(): from sympy.codegen.ast import Element assert _test_args(Element('x', range(3))) def test_sympy__codegen__cnodes__CommaOperator(): from sympy.codegen.cnodes import CommaOperator assert _test_args(CommaOperator(1, 2)) def test_sympy__codegen__cnodes__goto(): from sympy.codegen.cnodes import goto assert _test_args(goto('early_exit')) def test_sympy__codegen__cnodes__Label(): from sympy.codegen.cnodes import Label assert _test_args(Label('early_exit')) def test_sympy__codegen__cnodes__PreDecrement(): from sympy.codegen.cnodes import PreDecrement assert _test_args(PreDecrement(x)) def test_sympy__codegen__cnodes__PostDecrement(): from sympy.codegen.cnodes import PostDecrement assert _test_args(PostDecrement(x)) def test_sympy__codegen__cnodes__PreIncrement(): from sympy.codegen.cnodes import PreIncrement assert _test_args(PreIncrement(x)) def test_sympy__codegen__cnodes__PostIncrement(): from sympy.codegen.cnodes import PostIncrement assert _test_args(PostIncrement(x)) def test_sympy__codegen__cnodes__struct(): from sympy.codegen.ast import real, Variable from sympy.codegen.cnodes import struct assert _test_args(struct(declarations=[ Variable(x, type=real), Variable(y, type=real) ])) def test_sympy__codegen__cnodes__union(): from sympy.codegen.ast import float32, int32, Variable from sympy.codegen.cnodes import union assert _test_args(union(declarations=[ Variable(x, type=float32), Variable(y, type=int32) ])) def test_sympy__codegen__cxxnodes__using(): from sympy.codegen.cxxnodes import using assert _test_args(using('std::vector')) assert _test_args(using('std::vector', 'vec')) def test_sympy__codegen__fnodes__Program(): from sympy.codegen.fnodes import Program assert _test_args(Program('foobar', [])) def test_sympy__codegen__fnodes__Module(): from sympy.codegen.fnodes import Module assert _test_args(Module('foobar', [], [])) def test_sympy__codegen__fnodes__Subroutine(): from sympy.codegen.fnodes import Subroutine x = symbols('x', real=True) assert _test_args(Subroutine('foo', [x], [])) def test_sympy__codegen__fnodes__GoTo(): from sympy.codegen.fnodes import GoTo assert _test_args(GoTo([10])) assert _test_args(GoTo([10, 20], x > 1)) def test_sympy__codegen__fnodes__FortranReturn(): from sympy.codegen.fnodes import FortranReturn assert _test_args(FortranReturn(10)) def test_sympy__codegen__fnodes__Extent(): from sympy.codegen.fnodes import Extent assert _test_args(Extent()) assert _test_args(Extent(None)) assert _test_args(Extent(':')) assert _test_args(Extent(-3, 4)) assert _test_args(Extent(x, y)) def test_sympy__codegen__fnodes__use_rename(): from sympy.codegen.fnodes import use_rename assert _test_args(use_rename('loc', 'glob')) def test_sympy__codegen__fnodes__use(): from sympy.codegen.fnodes import use assert _test_args(use('modfoo', only='bar')) def test_sympy__codegen__fnodes__SubroutineCall(): from sympy.codegen.fnodes import SubroutineCall assert _test_args(SubroutineCall('foo', ['bar', 'baz'])) def test_sympy__codegen__fnodes__Do(): from sympy.codegen.fnodes import Do assert _test_args(Do([], 'i', 1, 42)) def test_sympy__codegen__fnodes__ImpliedDoLoop(): from sympy.codegen.fnodes import ImpliedDoLoop assert _test_args(ImpliedDoLoop('i', 'i', 1, 42)) def test_sympy__codegen__fnodes__ArrayConstructor(): from sympy.codegen.fnodes import ArrayConstructor assert _test_args(ArrayConstructor([1, 2, 3])) from sympy.codegen.fnodes import ImpliedDoLoop idl = ImpliedDoLoop('i', 'i', 1, 42) assert _test_args(ArrayConstructor([1, idl, 3])) def test_sympy__codegen__fnodes__sum_(): from sympy.codegen.fnodes import sum_ assert _test_args(sum_('arr')) def test_sympy__codegen__fnodes__product_(): from sympy.codegen.fnodes import product_ assert _test_args(product_('arr')) @XFAIL def test_sympy__combinatorics__graycode__GrayCode(): from sympy.combinatorics.graycode import GrayCode # an integer is given and returned from GrayCode as the arg assert _test_args(GrayCode(3, start='100')) assert _test_args(GrayCode(3, rank=1)) def test_sympy__combinatorics__subsets__Subset(): from sympy.combinatorics.subsets import Subset assert _test_args(Subset([0, 1], [0, 1, 2, 3])) assert _test_args(Subset(['c', 'd'], ['a', 'b', 'c', 'd'])) @XFAIL def test_sympy__combinatorics__permutations__Permutation(): from sympy.combinatorics.permutations import Permutation assert _test_args(Permutation([0, 1, 2, 3])) def test_sympy__combinatorics__perm_groups__PermutationGroup(): from sympy.combinatorics.permutations import Permutation from sympy.combinatorics.perm_groups import PermutationGroup assert _test_args(PermutationGroup([Permutation([0, 1])])) def test_sympy__combinatorics__polyhedron__Polyhedron(): from sympy.combinatorics.permutations import Permutation from sympy.combinatorics.polyhedron import Polyhedron from sympy.abc import w, x, y, z pgroup = [Permutation([[0, 1, 2], [3]]), Permutation([[0, 1, 3], [2]]), Permutation([[0, 2, 3], [1]]), Permutation([[1, 2, 3], [0]]), Permutation([[0, 1], [2, 3]]), Permutation([[0, 2], [1, 3]]), Permutation([[0, 3], [1, 2]]), Permutation([[0, 1, 2, 3]])] corners = [w, x, y, z] faces = [(w, x, y), (w, y, z), (w, z, x), (x, y, z)] assert _test_args(Polyhedron(corners, faces, pgroup)) @XFAIL def test_sympy__combinatorics__prufer__Prufer(): from sympy.combinatorics.prufer import Prufer assert _test_args(Prufer([[0, 1], [0, 2], [0, 3]], 4)) def test_sympy__combinatorics__partitions__Partition(): from sympy.combinatorics.partitions import Partition assert _test_args(Partition([1])) @XFAIL def test_sympy__combinatorics__partitions__IntegerPartition(): from sympy.combinatorics.partitions import IntegerPartition assert _test_args(IntegerPartition([1])) def test_sympy__concrete__products__Product(): from sympy.concrete.products import Product assert _test_args(Product(x, (x, 0, 10))) assert _test_args(Product(x, (x, 0, y), (y, 0, 10))) @SKIP("abstract Class") def test_sympy__concrete__expr_with_limits__ExprWithLimits(): from sympy.concrete.expr_with_limits import ExprWithLimits assert _test_args(ExprWithLimits(x, (x, 0, 10))) assert _test_args(ExprWithLimits(x*y, (x, 0, 10.),(y,1.,3))) @SKIP("abstract Class") def test_sympy__concrete__expr_with_limits__AddWithLimits(): from sympy.concrete.expr_with_limits import AddWithLimits assert _test_args(AddWithLimits(x, (x, 0, 10))) assert _test_args(AddWithLimits(x*y, (x, 0, 10),(y,1,3))) @SKIP("abstract Class") def test_sympy__concrete__expr_with_intlimits__ExprWithIntLimits(): from sympy.concrete.expr_with_intlimits import ExprWithIntLimits assert _test_args(ExprWithIntLimits(x, (x, 0, 10))) assert _test_args(ExprWithIntLimits(x*y, (x, 0, 10),(y,1,3))) def test_sympy__concrete__summations__Sum(): from sympy.concrete.summations import Sum assert _test_args(Sum(x, (x, 0, 10))) assert _test_args(Sum(x, (x, 0, y), (y, 0, 10))) def test_sympy__core__add__Add(): from sympy.core.add import Add assert _test_args(Add(x, y, z, 2)) def test_sympy__core__basic__Atom(): from sympy.core.basic import Atom assert _test_args(Atom()) def test_sympy__core__basic__Basic(): from sympy.core.basic import Basic assert _test_args(Basic()) def test_sympy__core__containers__Dict(): from sympy.core.containers import Dict assert _test_args(Dict({x: y, y: z})) def test_sympy__core__containers__Tuple(): from sympy.core.containers import Tuple assert _test_args(Tuple(x, y, z, 2)) def test_sympy__core__expr__AtomicExpr(): from sympy.core.expr import AtomicExpr assert _test_args(AtomicExpr()) def test_sympy__core__expr__Expr(): from sympy.core.expr import Expr assert _test_args(Expr()) def test_sympy__core__expr__UnevaluatedExpr(): from sympy.core.expr import UnevaluatedExpr from sympy.abc import x assert _test_args(UnevaluatedExpr(x)) def test_sympy__core__function__Application(): from sympy.core.function import Application assert _test_args(Application(1, 2, 3)) def test_sympy__core__function__AppliedUndef(): from sympy.core.function import AppliedUndef assert _test_args(AppliedUndef(1, 2, 3)) def test_sympy__core__function__Derivative(): from sympy.core.function import Derivative assert _test_args(Derivative(2, x, y, 3)) @SKIP("abstract class") def test_sympy__core__function__Function(): pass def test_sympy__core__function__Lambda(): assert _test_args(Lambda((x, y), x + y + z)) def test_sympy__core__function__Subs(): from sympy.core.function import Subs assert _test_args(Subs(x + y, x, 2)) def test_sympy__core__function__WildFunction(): from sympy.core.function import WildFunction assert _test_args(WildFunction('f')) def test_sympy__core__mod__Mod(): from sympy.core.mod import Mod assert _test_args(Mod(x, 2)) def test_sympy__core__mul__Mul(): from sympy.core.mul import Mul assert _test_args(Mul(2, x, y, z)) def test_sympy__core__numbers__Catalan(): from sympy.core.numbers import Catalan assert _test_args(Catalan()) def test_sympy__core__numbers__ComplexInfinity(): from sympy.core.numbers import ComplexInfinity assert _test_args(ComplexInfinity()) def test_sympy__core__numbers__EulerGamma(): from sympy.core.numbers import EulerGamma assert _test_args(EulerGamma()) def test_sympy__core__numbers__Exp1(): from sympy.core.numbers import Exp1 assert _test_args(Exp1()) def test_sympy__core__numbers__Float(): from sympy.core.numbers import Float assert _test_args(Float(1.23)) def test_sympy__core__numbers__GoldenRatio(): from sympy.core.numbers import GoldenRatio assert _test_args(GoldenRatio()) def test_sympy__core__numbers__TribonacciConstant(): from sympy.core.numbers import TribonacciConstant assert _test_args(TribonacciConstant()) def test_sympy__core__numbers__Half(): from sympy.core.numbers import Half assert _test_args(Half()) def test_sympy__core__numbers__ImaginaryUnit(): from sympy.core.numbers import ImaginaryUnit assert _test_args(ImaginaryUnit()) def test_sympy__core__numbers__Infinity(): from sympy.core.numbers import Infinity assert _test_args(Infinity()) def test_sympy__core__numbers__Integer(): from sympy.core.numbers import Integer assert _test_args(Integer(7)) @SKIP("abstract class") def test_sympy__core__numbers__IntegerConstant(): pass def test_sympy__core__numbers__NaN(): from sympy.core.numbers import NaN assert _test_args(NaN()) def test_sympy__core__numbers__NegativeInfinity(): from sympy.core.numbers import NegativeInfinity assert _test_args(NegativeInfinity()) def test_sympy__core__numbers__NegativeOne(): from sympy.core.numbers import NegativeOne assert _test_args(NegativeOne()) def test_sympy__core__numbers__Number(): from sympy.core.numbers import Number assert _test_args(Number(1, 7)) def test_sympy__core__numbers__NumberSymbol(): from sympy.core.numbers import NumberSymbol assert _test_args(NumberSymbol()) def test_sympy__core__numbers__One(): from sympy.core.numbers import One assert _test_args(One()) def test_sympy__core__numbers__Pi(): from sympy.core.numbers import Pi assert _test_args(Pi()) def test_sympy__core__numbers__Rational(): from sympy.core.numbers import Rational assert _test_args(Rational(1, 7)) @SKIP("abstract class") def test_sympy__core__numbers__RationalConstant(): pass def test_sympy__core__numbers__Zero(): from sympy.core.numbers import Zero assert _test_args(Zero()) @SKIP("abstract class") def test_sympy__core__operations__AssocOp(): pass @SKIP("abstract class") def test_sympy__core__operations__LatticeOp(): pass def test_sympy__core__power__Pow(): from sympy.core.power import Pow assert _test_args(Pow(x, 2)) def test_sympy__algebras__quaternion__Quaternion(): from sympy.algebras.quaternion import Quaternion assert _test_args(Quaternion(x, 1, 2, 3)) def test_sympy__core__relational__Equality(): from sympy.core.relational import Equality assert _test_args(Equality(x, 2)) def test_sympy__core__relational__GreaterThan(): from sympy.core.relational import GreaterThan assert _test_args(GreaterThan(x, 2)) def test_sympy__core__relational__LessThan(): from sympy.core.relational import LessThan assert _test_args(LessThan(x, 2)) @SKIP("abstract class") def test_sympy__core__relational__Relational(): pass def test_sympy__core__relational__StrictGreaterThan(): from sympy.core.relational import StrictGreaterThan assert _test_args(StrictGreaterThan(x, 2)) def test_sympy__core__relational__StrictLessThan(): from sympy.core.relational import StrictLessThan assert _test_args(StrictLessThan(x, 2)) def test_sympy__core__relational__Unequality(): from sympy.core.relational import Unequality assert _test_args(Unequality(x, 2)) def test_sympy__sandbox__indexed_integrals__IndexedIntegral(): from sympy.tensor import IndexedBase, Idx from sympy.sandbox.indexed_integrals import IndexedIntegral A = IndexedBase('A') i, j = symbols('i j', integer=True) a1, a2 = symbols('a1:3', cls=Idx) assert _test_args(IndexedIntegral(A[a1], A[a2])) assert _test_args(IndexedIntegral(A[i], A[j])) def test_sympy__calculus__util__AccumulationBounds(): from sympy.calculus.util import AccumulationBounds assert _test_args(AccumulationBounds(0, 1)) def test_sympy__sets__ordinals__OmegaPower(): from sympy.sets.ordinals import OmegaPower assert _test_args(OmegaPower(1, 1)) def test_sympy__sets__ordinals__Ordinal(): from sympy.sets.ordinals import Ordinal, OmegaPower assert _test_args(Ordinal(OmegaPower(2, 1))) def test_sympy__sets__ordinals__OrdinalOmega(): from sympy.sets.ordinals import OrdinalOmega assert _test_args(OrdinalOmega()) def test_sympy__sets__ordinals__OrdinalZero(): from sympy.sets.ordinals import OrdinalZero assert _test_args(OrdinalZero()) def test_sympy__sets__sets__EmptySet(): from sympy.sets.sets import EmptySet assert _test_args(EmptySet()) def test_sympy__sets__sets__UniversalSet(): from sympy.sets.sets import UniversalSet assert _test_args(UniversalSet()) def test_sympy__sets__sets__FiniteSet(): from sympy.sets.sets import FiniteSet assert _test_args(FiniteSet(x, y, z)) def test_sympy__sets__sets__Interval(): from sympy.sets.sets import Interval assert _test_args(Interval(0, 1)) def test_sympy__sets__sets__ProductSet(): from sympy.sets.sets import ProductSet, Interval assert _test_args(ProductSet(Interval(0, 1), Interval(0, 1))) @SKIP("does it make sense to test this?") def test_sympy__sets__sets__Set(): from sympy.sets.sets import Set assert _test_args(Set()) def test_sympy__sets__sets__Intersection(): from sympy.sets.sets import Intersection, Interval assert _test_args(Intersection(Interval(0, 3), Interval(2, 4), evaluate=False)) def test_sympy__sets__sets__Union(): from sympy.sets.sets import Union, Interval assert _test_args(Union(Interval(0, 1), Interval(2, 3))) def test_sympy__sets__sets__Complement(): from sympy.sets.sets import Complement assert _test_args(Complement(Interval(0, 2), Interval(0, 1))) def test_sympy__sets__sets__SymmetricDifference(): from sympy.sets.sets import FiniteSet, SymmetricDifference assert _test_args(SymmetricDifference(FiniteSet(1, 2, 3), \ FiniteSet(2, 3, 4))) def test_sympy__core__trace__Tr(): from sympy.core.trace import Tr a, b = symbols('a b') assert _test_args(Tr(a + b)) def test_sympy__sets__setexpr__SetExpr(): from sympy.sets.setexpr import SetExpr assert _test_args(SetExpr(Interval(0, 1))) def test_sympy__sets__fancysets__Naturals(): from sympy.sets.fancysets import Naturals assert _test_args(Naturals()) def test_sympy__sets__fancysets__Naturals0(): from sympy.sets.fancysets import Naturals0 assert _test_args(Naturals0()) def test_sympy__sets__fancysets__Integers(): from sympy.sets.fancysets import Integers assert _test_args(Integers()) def test_sympy__sets__fancysets__Reals(): from sympy.sets.fancysets import Reals assert _test_args(Reals()) def test_sympy__sets__fancysets__Complexes(): from sympy.sets.fancysets import Complexes assert _test_args(Complexes()) def test_sympy__sets__fancysets__ComplexRegion(): from sympy.sets.fancysets import ComplexRegion from sympy import S from sympy.sets import Interval a = Interval(0, 1) b = Interval(2, 3) theta = Interval(0, 2*S.Pi) assert _test_args(ComplexRegion(a*b)) assert _test_args(ComplexRegion(a*theta, polar=True)) def test_sympy__sets__fancysets__ImageSet(): from sympy.sets.fancysets import ImageSet from sympy import S, Symbol x = Symbol('x') assert _test_args(ImageSet(Lambda(x, x**2), S.Naturals)) def test_sympy__sets__fancysets__Range(): from sympy.sets.fancysets import Range assert _test_args(Range(1, 5, 1)) def test_sympy__sets__conditionset__ConditionSet(): from sympy.sets.conditionset import ConditionSet from sympy import S, Symbol x = Symbol('x') assert _test_args(ConditionSet(x, Eq(x**2, 1), S.Reals)) def test_sympy__sets__contains__Contains(): from sympy.sets.fancysets import Range from sympy.sets.contains import Contains assert _test_args(Contains(x, Range(0, 10, 2))) # STATS from sympy.stats.crv_types import NormalDistribution nd = NormalDistribution(0, 1) from sympy.stats.frv_types import DieDistribution die = DieDistribution(6) def test_sympy__stats__crv__ContinuousDomain(): from sympy.stats.crv import ContinuousDomain assert _test_args(ContinuousDomain({x}, Interval(-oo, oo))) def test_sympy__stats__crv__SingleContinuousDomain(): from sympy.stats.crv import SingleContinuousDomain assert _test_args(SingleContinuousDomain(x, Interval(-oo, oo))) def test_sympy__stats__crv__ProductContinuousDomain(): from sympy.stats.crv import SingleContinuousDomain, ProductContinuousDomain D = SingleContinuousDomain(x, Interval(-oo, oo)) E = SingleContinuousDomain(y, Interval(0, oo)) assert _test_args(ProductContinuousDomain(D, E)) def test_sympy__stats__crv__ConditionalContinuousDomain(): from sympy.stats.crv import (SingleContinuousDomain, ConditionalContinuousDomain) D = SingleContinuousDomain(x, Interval(-oo, oo)) assert _test_args(ConditionalContinuousDomain(D, x > 0)) def test_sympy__stats__crv__ContinuousPSpace(): from sympy.stats.crv import ContinuousPSpace, SingleContinuousDomain D = SingleContinuousDomain(x, Interval(-oo, oo)) assert _test_args(ContinuousPSpace(D, nd)) def test_sympy__stats__crv__SingleContinuousPSpace(): from sympy.stats.crv import SingleContinuousPSpace assert _test_args(SingleContinuousPSpace(x, nd)) @SKIP("abstract class") def test_sympy__stats__crv__SingleContinuousDistribution(): pass def test_sympy__stats__drv__SingleDiscreteDomain(): from sympy.stats.drv import SingleDiscreteDomain assert _test_args(SingleDiscreteDomain(x, S.Naturals)) def test_sympy__stats__drv__ProductDiscreteDomain(): from sympy.stats.drv import SingleDiscreteDomain, ProductDiscreteDomain X = SingleDiscreteDomain(x, S.Naturals) Y = SingleDiscreteDomain(y, S.Integers) assert _test_args(ProductDiscreteDomain(X, Y)) def test_sympy__stats__drv__SingleDiscretePSpace(): from sympy.stats.drv import SingleDiscretePSpace from sympy.stats.drv_types import PoissonDistribution assert _test_args(SingleDiscretePSpace(x, PoissonDistribution(1))) def test_sympy__stats__drv__DiscretePSpace(): from sympy.stats.drv import DiscretePSpace, SingleDiscreteDomain density = Lambda(x, 2**(-x)) domain = SingleDiscreteDomain(x, S.Naturals) assert _test_args(DiscretePSpace(domain, density)) def test_sympy__stats__drv__ConditionalDiscreteDomain(): from sympy.stats.drv import ConditionalDiscreteDomain, SingleDiscreteDomain X = SingleDiscreteDomain(x, S.Naturals0) assert _test_args(ConditionalDiscreteDomain(X, x > 2)) def test_sympy__stats__joint_rv__JointPSpace(): from sympy.stats.joint_rv import JointPSpace, JointDistribution assert _test_args(JointPSpace('X', JointDistribution(1))) def test_sympy__stats__joint_rv__JointRandomSymbol(): from sympy.stats.joint_rv import JointRandomSymbol assert _test_args(JointRandomSymbol(x)) def test_sympy__stats__joint_rv__JointDistributionHandmade(): from sympy import Indexed from sympy.stats.joint_rv import JointDistributionHandmade x1, x2 = (Indexed('x', i) for i in (1, 2)) assert _test_args(JointDistributionHandmade(x1 + x2, S.Reals**2)) def test_sympy__stats__joint_rv__MarginalDistribution(): from sympy.stats.rv import RandomSymbol from sympy.stats.joint_rv import MarginalDistribution r = RandomSymbol(S('r')) assert _test_args(MarginalDistribution(r, (r,))) def test_sympy__stats__joint_rv__CompoundDistribution(): from sympy.stats.joint_rv import CompoundDistribution from sympy.stats.drv_types import PoissonDistribution r = PoissonDistribution(x) assert _test_args(CompoundDistribution(PoissonDistribution(r))) @SKIP("abstract class") def test_sympy__stats__drv__SingleDiscreteDistribution(): pass @SKIP("abstract class") def test_sympy__stats__drv__DiscreteDistribution(): pass @SKIP("abstract class") def test_sympy__stats__drv__DiscreteDomain(): pass def test_sympy__stats__rv__RandomDomain(): from sympy.stats.rv import RandomDomain from sympy.sets.sets import FiniteSet assert _test_args(RandomDomain(FiniteSet(x), FiniteSet(1, 2, 3))) def test_sympy__stats__rv__SingleDomain(): from sympy.stats.rv import SingleDomain from sympy.sets.sets import FiniteSet assert _test_args(SingleDomain(x, FiniteSet(1, 2, 3))) def test_sympy__stats__rv__ConditionalDomain(): from sympy.stats.rv import ConditionalDomain, RandomDomain from sympy.sets.sets import FiniteSet D = RandomDomain(FiniteSet(x), FiniteSet(1, 2)) assert _test_args(ConditionalDomain(D, x > 1)) def test_sympy__stats__rv__PSpace(): from sympy.stats.rv import PSpace, RandomDomain from sympy import FiniteSet D = RandomDomain(FiniteSet(x), FiniteSet(1, 2, 3, 4, 5, 6)) assert _test_args(PSpace(D, die)) @SKIP("abstract Class") def test_sympy__stats__rv__SinglePSpace(): pass def test_sympy__stats__rv__RandomSymbol(): from sympy.stats.rv import RandomSymbol from sympy.stats.crv import SingleContinuousPSpace A = SingleContinuousPSpace(x, nd) assert _test_args(RandomSymbol(x, A)) @SKIP("abstract Class") def test_sympy__stats__rv__ProductPSpace(): pass def test_sympy__stats__rv__IndependentProductPSpace(): from sympy.stats.rv import IndependentProductPSpace from sympy.stats.crv import SingleContinuousPSpace A = SingleContinuousPSpace(x, nd) B = SingleContinuousPSpace(y, nd) assert _test_args(IndependentProductPSpace(A, B)) def test_sympy__stats__rv__ProductDomain(): from sympy.stats.rv import ProductDomain, SingleDomain D = SingleDomain(x, Interval(-oo, oo)) E = SingleDomain(y, Interval(0, oo)) assert _test_args(ProductDomain(D, E)) def test_sympy__stats__symbolic_probability__Probability(): from sympy.stats.symbolic_probability import Probability from sympy.stats import Normal X = Normal('X', 0, 1) assert _test_args(Probability(X > 0)) def test_sympy__stats__symbolic_probability__Expectation(): from sympy.stats.symbolic_probability import Expectation from sympy.stats import Normal X = Normal('X', 0, 1) assert _test_args(Expectation(X > 0)) def test_sympy__stats__symbolic_probability__Covariance(): from sympy.stats.symbolic_probability import Covariance from sympy.stats import Normal X = Normal('X', 0, 1) Y = Normal('Y', 0, 3) assert _test_args(Covariance(X, Y)) def test_sympy__stats__symbolic_probability__Variance(): from sympy.stats.symbolic_probability import Variance from sympy.stats import Normal X = Normal('X', 0, 1) assert _test_args(Variance(X)) def test_sympy__stats__frv_types__DiscreteUniformDistribution(): from sympy.stats.frv_types import DiscreteUniformDistribution from sympy.core.containers import Tuple assert _test_args(DiscreteUniformDistribution(Tuple(*list(range(6))))) def test_sympy__stats__frv_types__DieDistribution(): assert _test_args(die) def test_sympy__stats__frv_types__BernoulliDistribution(): from sympy.stats.frv_types import BernoulliDistribution assert _test_args(BernoulliDistribution(S.Half, 0, 1)) def test_sympy__stats__frv_types__BinomialDistribution(): from sympy.stats.frv_types import BinomialDistribution assert _test_args(BinomialDistribution(5, S.Half, 1, 0)) def test_sympy__stats__frv_types__HypergeometricDistribution(): from sympy.stats.frv_types import HypergeometricDistribution assert _test_args(HypergeometricDistribution(10, 5, 3)) def test_sympy__stats__frv_types__RademacherDistribution(): from sympy.stats.frv_types import RademacherDistribution assert _test_args(RademacherDistribution()) def test_sympy__stats__frv__FiniteDomain(): from sympy.stats.frv import FiniteDomain assert _test_args(FiniteDomain({(x, 1), (x, 2)})) # x can be 1 or 2 def test_sympy__stats__frv__SingleFiniteDomain(): from sympy.stats.frv import SingleFiniteDomain assert _test_args(SingleFiniteDomain(x, {1, 2})) # x can be 1 or 2 def test_sympy__stats__frv__ProductFiniteDomain(): from sympy.stats.frv import SingleFiniteDomain, ProductFiniteDomain xd = SingleFiniteDomain(x, {1, 2}) yd = SingleFiniteDomain(y, {1, 2}) assert _test_args(ProductFiniteDomain(xd, yd)) def test_sympy__stats__frv__ConditionalFiniteDomain(): from sympy.stats.frv import SingleFiniteDomain, ConditionalFiniteDomain xd = SingleFiniteDomain(x, {1, 2}) assert _test_args(ConditionalFiniteDomain(xd, x > 1)) def test_sympy__stats__frv__FinitePSpace(): from sympy.stats.frv import FinitePSpace, SingleFiniteDomain xd = SingleFiniteDomain(x, {1, 2, 3, 4, 5, 6}) p = 1.0/6 xd = SingleFiniteDomain(x, {1, 2}) assert _test_args(FinitePSpace(xd, {(x, 1): S.Half, (x, 2): S.Half})) def test_sympy__stats__frv__SingleFinitePSpace(): from sympy.stats.frv import SingleFinitePSpace from sympy import Symbol assert _test_args(SingleFinitePSpace(Symbol('x'), die)) def test_sympy__stats__frv__ProductFinitePSpace(): from sympy.stats.frv import SingleFinitePSpace, ProductFinitePSpace from sympy import Symbol xp = SingleFinitePSpace(Symbol('x'), die) yp = SingleFinitePSpace(Symbol('y'), die) assert _test_args(ProductFinitePSpace(xp, yp)) @SKIP("abstract class") def test_sympy__stats__frv__SingleFiniteDistribution(): pass @SKIP("abstract class") def test_sympy__stats__crv__ContinuousDistribution(): pass def test_sympy__stats__frv_types__FiniteDistributionHandmade(): from sympy.stats.frv_types import FiniteDistributionHandmade assert _test_args(FiniteDistributionHandmade({1: 1})) def test_sympy__stats__crv__ContinuousDistributionHandmade(): from sympy.stats.crv import ContinuousDistributionHandmade from sympy import Symbol, Interval assert _test_args(ContinuousDistributionHandmade(Symbol('x'), Interval(0, 2))) def test_sympy__stats__drv__DiscreteDistributionHandmade(): from sympy.stats.drv import DiscreteDistributionHandmade assert _test_args(DiscreteDistributionHandmade(x, S.Naturals)) def test_sympy__stats__rv__Density(): from sympy.stats.rv import Density from sympy.stats.crv_types import Normal assert _test_args(Density(Normal('x', 0, 1))) def test_sympy__stats__crv_types__ArcsinDistribution(): from sympy.stats.crv_types import ArcsinDistribution assert _test_args(ArcsinDistribution(0, 1)) def test_sympy__stats__crv_types__BeniniDistribution(): from sympy.stats.crv_types import BeniniDistribution assert _test_args(BeniniDistribution(1, 1, 1)) def test_sympy__stats__crv_types__BetaDistribution(): from sympy.stats.crv_types import BetaDistribution assert _test_args(BetaDistribution(1, 1)) def test_sympy__stats__crv_types__BetaPrimeDistribution(): from sympy.stats.crv_types import BetaPrimeDistribution assert _test_args(BetaPrimeDistribution(1, 1)) def test_sympy__stats__crv_types__CauchyDistribution(): from sympy.stats.crv_types import CauchyDistribution assert _test_args(CauchyDistribution(0, 1)) def test_sympy__stats__crv_types__ChiDistribution(): from sympy.stats.crv_types import ChiDistribution assert _test_args(ChiDistribution(1)) def test_sympy__stats__crv_types__ChiNoncentralDistribution(): from sympy.stats.crv_types import ChiNoncentralDistribution assert _test_args(ChiNoncentralDistribution(1,1)) def test_sympy__stats__crv_types__ChiSquaredDistribution(): from sympy.stats.crv_types import ChiSquaredDistribution assert _test_args(ChiSquaredDistribution(1)) def test_sympy__stats__crv_types__DagumDistribution(): from sympy.stats.crv_types import DagumDistribution assert _test_args(DagumDistribution(1, 1, 1)) def test_sympy__stats__crv_types__ExponentialDistribution(): from sympy.stats.crv_types import ExponentialDistribution assert _test_args(ExponentialDistribution(1)) def test_sympy__stats__crv_types__FDistributionDistribution(): from sympy.stats.crv_types import FDistributionDistribution assert _test_args(FDistributionDistribution(1, 1)) def test_sympy__stats__crv_types__FisherZDistribution(): from sympy.stats.crv_types import FisherZDistribution assert _test_args(FisherZDistribution(1, 1)) def test_sympy__stats__crv_types__FrechetDistribution(): from sympy.stats.crv_types import FrechetDistribution assert _test_args(FrechetDistribution(1, 1, 1)) def test_sympy__stats__crv_types__GammaInverseDistribution(): from sympy.stats.crv_types import GammaInverseDistribution assert _test_args(GammaInverseDistribution(1, 1)) def test_sympy__stats__crv_types__GammaDistribution(): from sympy.stats.crv_types import GammaDistribution assert _test_args(GammaDistribution(1, 1)) def test_sympy__stats__crv_types__GumbelDistribution(): from sympy.stats.crv_types import GumbelDistribution assert _test_args(GumbelDistribution(1, 1)) def test_sympy__stats__crv_types__GompertzDistribution(): from sympy.stats.crv_types import GompertzDistribution assert _test_args(GompertzDistribution(1, 1)) def test_sympy__stats__crv_types__KumaraswamyDistribution(): from sympy.stats.crv_types import KumaraswamyDistribution assert _test_args(KumaraswamyDistribution(1, 1)) def test_sympy__stats__crv_types__LaplaceDistribution(): from sympy.stats.crv_types import LaplaceDistribution assert _test_args(LaplaceDistribution(0, 1)) def test_sympy__stats__crv_types__LogisticDistribution(): from sympy.stats.crv_types import LogisticDistribution assert _test_args(LogisticDistribution(0, 1)) def test_sympy__stats__crv_types__LogNormalDistribution(): from sympy.stats.crv_types import LogNormalDistribution assert _test_args(LogNormalDistribution(0, 1)) def test_sympy__stats__crv_types__MaxwellDistribution(): from sympy.stats.crv_types import MaxwellDistribution assert _test_args(MaxwellDistribution(1)) def test_sympy__stats__crv_types__NakagamiDistribution(): from sympy.stats.crv_types import NakagamiDistribution assert _test_args(NakagamiDistribution(1, 1)) def test_sympy__stats__crv_types__NormalDistribution(): from sympy.stats.crv_types import NormalDistribution assert _test_args(NormalDistribution(0, 1)) def test_sympy__stats__crv_types__ParetoDistribution(): from sympy.stats.crv_types import ParetoDistribution assert _test_args(ParetoDistribution(1, 1)) def test_sympy__stats__crv_types__QuadraticUDistribution(): from sympy.stats.crv_types import QuadraticUDistribution assert _test_args(QuadraticUDistribution(1, 2)) def test_sympy__stats__crv_types__RaisedCosineDistribution(): from sympy.stats.crv_types import RaisedCosineDistribution assert _test_args(RaisedCosineDistribution(1, 1)) def test_sympy__stats__crv_types__RayleighDistribution(): from sympy.stats.crv_types import RayleighDistribution assert _test_args(RayleighDistribution(1)) def test_sympy__stats__crv_types__ShiftedGompertzDistribution(): from sympy.stats.crv_types import ShiftedGompertzDistribution assert _test_args(ShiftedGompertzDistribution(1, 1)) def test_sympy__stats__crv_types__StudentTDistribution(): from sympy.stats.crv_types import StudentTDistribution assert _test_args(StudentTDistribution(1)) def test_sympy__stats__crv_types__TrapezoidalDistribution(): from sympy.stats.crv_types import TrapezoidalDistribution assert _test_args(TrapezoidalDistribution(1, 2, 3, 4)) def test_sympy__stats__crv_types__TriangularDistribution(): from sympy.stats.crv_types import TriangularDistribution assert _test_args(TriangularDistribution(-1, 0, 1)) def test_sympy__stats__crv_types__UniformDistribution(): from sympy.stats.crv_types import UniformDistribution assert _test_args(UniformDistribution(0, 1)) def test_sympy__stats__crv_types__UniformSumDistribution(): from sympy.stats.crv_types import UniformSumDistribution assert _test_args(UniformSumDistribution(1)) def test_sympy__stats__crv_types__VonMisesDistribution(): from sympy.stats.crv_types import VonMisesDistribution assert _test_args(VonMisesDistribution(1, 1)) def test_sympy__stats__crv_types__WeibullDistribution(): from sympy.stats.crv_types import WeibullDistribution assert _test_args(WeibullDistribution(1, 1)) def test_sympy__stats__crv_types__WignerSemicircleDistribution(): from sympy.stats.crv_types import WignerSemicircleDistribution assert _test_args(WignerSemicircleDistribution(1)) def test_sympy__stats__drv_types__GeometricDistribution(): from sympy.stats.drv_types import GeometricDistribution assert _test_args(GeometricDistribution(.5)) def test_sympy__stats__drv_types__LogarithmicDistribution(): from sympy.stats.drv_types import LogarithmicDistribution assert _test_args(LogarithmicDistribution(.5)) def test_sympy__stats__drv_types__NegativeBinomialDistribution(): from sympy.stats.drv_types import NegativeBinomialDistribution assert _test_args(NegativeBinomialDistribution(.5, .5)) def test_sympy__stats__drv_types__PoissonDistribution(): from sympy.stats.drv_types import PoissonDistribution assert _test_args(PoissonDistribution(1)) def test_sympy__stats__drv_types__YuleSimonDistribution(): from sympy.stats.drv_types import YuleSimonDistribution assert _test_args(YuleSimonDistribution(.5)) def test_sympy__stats__drv_types__ZetaDistribution(): from sympy.stats.drv_types import ZetaDistribution assert _test_args(ZetaDistribution(1.5)) def test_sympy__stats__joint_rv__JointDistribution(): from sympy.stats.joint_rv import JointDistribution assert _test_args(JointDistribution(1, 2, 3, 4)) def test_sympy__stats__joint_rv_types__MultivariateNormalDistribution(): from sympy.stats.joint_rv_types import MultivariateNormalDistribution assert _test_args( MultivariateNormalDistribution([0, 1], [[1, 0],[0, 1]])) def test_sympy__stats__joint_rv_types__MultivariateLaplaceDistribution(): from sympy.stats.joint_rv_types import MultivariateLaplaceDistribution assert _test_args(MultivariateLaplaceDistribution([0, 1], [[1, 0],[0, 1]])) def test_sympy__stats__joint_rv_types__MultivariateTDistribution(): from sympy.stats.joint_rv_types import MultivariateTDistribution assert _test_args(MultivariateTDistribution([0, 1], [[1, 0],[0, 1]], 1)) def test_sympy__stats__joint_rv_types__NormalGammaDistribution(): from sympy.stats.joint_rv_types import NormalGammaDistribution assert _test_args(NormalGammaDistribution(1, 2, 3, 4)) def test_sympy__core__symbol__Dummy(): from sympy.core.symbol import Dummy assert _test_args(Dummy('t')) def test_sympy__core__symbol__Symbol(): from sympy.core.symbol import Symbol assert _test_args(Symbol('t')) def test_sympy__core__symbol__Wild(): from sympy.core.symbol import Wild assert _test_args(Wild('x', exclude=[x])) @SKIP("abstract class") def test_sympy__functions__combinatorial__factorials__CombinatorialFunction(): pass def test_sympy__functions__combinatorial__factorials__FallingFactorial(): from sympy.functions.combinatorial.factorials import FallingFactorial assert _test_args(FallingFactorial(2, x)) def test_sympy__functions__combinatorial__factorials__MultiFactorial(): from sympy.functions.combinatorial.factorials import MultiFactorial assert _test_args(MultiFactorial(x)) def test_sympy__functions__combinatorial__factorials__RisingFactorial(): from sympy.functions.combinatorial.factorials import RisingFactorial assert _test_args(RisingFactorial(2, x)) def test_sympy__functions__combinatorial__factorials__binomial(): from sympy.functions.combinatorial.factorials import binomial assert _test_args(binomial(2, x)) def test_sympy__functions__combinatorial__factorials__subfactorial(): from sympy.functions.combinatorial.factorials import subfactorial assert _test_args(subfactorial(1)) def test_sympy__functions__combinatorial__factorials__factorial(): from sympy.functions.combinatorial.factorials import factorial assert _test_args(factorial(x)) def test_sympy__functions__combinatorial__factorials__factorial2(): from sympy.functions.combinatorial.factorials import factorial2 assert _test_args(factorial2(x)) def test_sympy__functions__combinatorial__numbers__bell(): from sympy.functions.combinatorial.numbers import bell assert _test_args(bell(x, y)) def test_sympy__functions__combinatorial__numbers__bernoulli(): from sympy.functions.combinatorial.numbers import bernoulli assert _test_args(bernoulli(x)) def test_sympy__functions__combinatorial__numbers__catalan(): from sympy.functions.combinatorial.numbers import catalan assert _test_args(catalan(x)) def test_sympy__functions__combinatorial__numbers__genocchi(): from sympy.functions.combinatorial.numbers import genocchi assert _test_args(genocchi(x)) def test_sympy__functions__combinatorial__numbers__euler(): from sympy.functions.combinatorial.numbers import euler assert _test_args(euler(x)) def test_sympy__functions__combinatorial__numbers__carmichael(): from sympy.functions.combinatorial.numbers import carmichael assert _test_args(carmichael(x)) def test_sympy__functions__combinatorial__numbers__fibonacci(): from sympy.functions.combinatorial.numbers import fibonacci assert _test_args(fibonacci(x)) def test_sympy__functions__combinatorial__numbers__tribonacci(): from sympy.functions.combinatorial.numbers import tribonacci assert _test_args(tribonacci(x)) def test_sympy__functions__combinatorial__numbers__harmonic(): from sympy.functions.combinatorial.numbers import harmonic assert _test_args(harmonic(x, 2)) def test_sympy__functions__combinatorial__numbers__lucas(): from sympy.functions.combinatorial.numbers import lucas assert _test_args(lucas(x)) def test_sympy__functions__combinatorial__numbers__partition(): from sympy.core.symbol import Symbol from sympy.functions.combinatorial.numbers import partition assert _test_args(partition(Symbol('a', integer=True))) def test_sympy__functions__elementary__complexes__Abs(): from sympy.functions.elementary.complexes import Abs assert _test_args(Abs(x)) def test_sympy__functions__elementary__complexes__adjoint(): from sympy.functions.elementary.complexes import adjoint assert _test_args(adjoint(x)) def test_sympy__functions__elementary__complexes__arg(): from sympy.functions.elementary.complexes import arg assert _test_args(arg(x)) def test_sympy__functions__elementary__complexes__conjugate(): from sympy.functions.elementary.complexes import conjugate assert _test_args(conjugate(x)) def test_sympy__functions__elementary__complexes__im(): from sympy.functions.elementary.complexes import im assert _test_args(im(x)) def test_sympy__functions__elementary__complexes__re(): from sympy.functions.elementary.complexes import re assert _test_args(re(x)) def test_sympy__functions__elementary__complexes__sign(): from sympy.functions.elementary.complexes import sign assert _test_args(sign(x)) def test_sympy__functions__elementary__complexes__polar_lift(): from sympy.functions.elementary.complexes import polar_lift assert _test_args(polar_lift(x)) def test_sympy__functions__elementary__complexes__periodic_argument(): from sympy.functions.elementary.complexes import periodic_argument assert _test_args(periodic_argument(x, y)) def test_sympy__functions__elementary__complexes__principal_branch(): from sympy.functions.elementary.complexes import principal_branch assert _test_args(principal_branch(x, y)) def test_sympy__functions__elementary__complexes__transpose(): from sympy.functions.elementary.complexes import transpose assert _test_args(transpose(x)) def test_sympy__functions__elementary__exponential__LambertW(): from sympy.functions.elementary.exponential import LambertW assert _test_args(LambertW(2)) @SKIP("abstract class") def test_sympy__functions__elementary__exponential__ExpBase(): pass def test_sympy__functions__elementary__exponential__exp(): from sympy.functions.elementary.exponential import exp assert _test_args(exp(2)) def test_sympy__functions__elementary__exponential__exp_polar(): from sympy.functions.elementary.exponential import exp_polar assert _test_args(exp_polar(2)) def test_sympy__functions__elementary__exponential__log(): from sympy.functions.elementary.exponential import log assert _test_args(log(2)) @SKIP("abstract class") def test_sympy__functions__elementary__hyperbolic__HyperbolicFunction(): pass @SKIP("abstract class") def test_sympy__functions__elementary__hyperbolic__ReciprocalHyperbolicFunction(): pass @SKIP("abstract class") def test_sympy__functions__elementary__hyperbolic__InverseHyperbolicFunction(): pass def test_sympy__functions__elementary__hyperbolic__acosh(): from sympy.functions.elementary.hyperbolic import acosh assert _test_args(acosh(2)) def test_sympy__functions__elementary__hyperbolic__acoth(): from sympy.functions.elementary.hyperbolic import acoth assert _test_args(acoth(2)) def test_sympy__functions__elementary__hyperbolic__asinh(): from sympy.functions.elementary.hyperbolic import asinh assert _test_args(asinh(2)) def test_sympy__functions__elementary__hyperbolic__atanh(): from sympy.functions.elementary.hyperbolic import atanh assert _test_args(atanh(2)) def test_sympy__functions__elementary__hyperbolic__asech(): from sympy.functions.elementary.hyperbolic import asech assert _test_args(asech(2)) def test_sympy__functions__elementary__hyperbolic__acsch(): from sympy.functions.elementary.hyperbolic import acsch assert _test_args(acsch(2)) def test_sympy__functions__elementary__hyperbolic__cosh(): from sympy.functions.elementary.hyperbolic import cosh assert _test_args(cosh(2)) def test_sympy__functions__elementary__hyperbolic__coth(): from sympy.functions.elementary.hyperbolic import coth assert _test_args(coth(2)) def test_sympy__functions__elementary__hyperbolic__csch(): from sympy.functions.elementary.hyperbolic import csch assert _test_args(csch(2)) def test_sympy__functions__elementary__hyperbolic__sech(): from sympy.functions.elementary.hyperbolic import sech assert _test_args(sech(2)) def test_sympy__functions__elementary__hyperbolic__sinh(): from sympy.functions.elementary.hyperbolic import sinh assert _test_args(sinh(2)) def test_sympy__functions__elementary__hyperbolic__tanh(): from sympy.functions.elementary.hyperbolic import tanh assert _test_args(tanh(2)) @SKIP("does this work at all?") def test_sympy__functions__elementary__integers__RoundFunction(): from sympy.functions.elementary.integers import RoundFunction assert _test_args(RoundFunction()) def test_sympy__functions__elementary__integers__ceiling(): from sympy.functions.elementary.integers import ceiling assert _test_args(ceiling(x)) def test_sympy__functions__elementary__integers__floor(): from sympy.functions.elementary.integers import floor assert _test_args(floor(x)) def test_sympy__functions__elementary__integers__frac(): from sympy.functions.elementary.integers import frac assert _test_args(frac(x)) def test_sympy__functions__elementary__miscellaneous__IdentityFunction(): from sympy.functions.elementary.miscellaneous import IdentityFunction assert _test_args(IdentityFunction()) def test_sympy__functions__elementary__miscellaneous__Max(): from sympy.functions.elementary.miscellaneous import Max assert _test_args(Max(x, 2)) def test_sympy__functions__elementary__miscellaneous__Min(): from sympy.functions.elementary.miscellaneous import Min assert _test_args(Min(x, 2)) @SKIP("abstract class") def test_sympy__functions__elementary__miscellaneous__MinMaxBase(): pass def test_sympy__functions__elementary__piecewise__ExprCondPair(): from sympy.functions.elementary.piecewise import ExprCondPair assert _test_args(ExprCondPair(1, True)) def test_sympy__functions__elementary__piecewise__Piecewise(): from sympy.functions.elementary.piecewise import Piecewise assert _test_args(Piecewise((1, x >= 0), (0, True))) @SKIP("abstract class") def test_sympy__functions__elementary__trigonometric__TrigonometricFunction(): pass @SKIP("abstract class") def test_sympy__functions__elementary__trigonometric__ReciprocalTrigonometricFunction(): pass @SKIP("abstract class") def test_sympy__functions__elementary__trigonometric__InverseTrigonometricFunction(): pass def test_sympy__functions__elementary__trigonometric__acos(): from sympy.functions.elementary.trigonometric import acos assert _test_args(acos(2)) def test_sympy__functions__elementary__trigonometric__acot(): from sympy.functions.elementary.trigonometric import acot assert _test_args(acot(2)) def test_sympy__functions__elementary__trigonometric__asin(): from sympy.functions.elementary.trigonometric import asin assert _test_args(asin(2)) def test_sympy__functions__elementary__trigonometric__asec(): from sympy.functions.elementary.trigonometric import asec assert _test_args(asec(2)) def test_sympy__functions__elementary__trigonometric__acsc(): from sympy.functions.elementary.trigonometric import acsc assert _test_args(acsc(2)) def test_sympy__functions__elementary__trigonometric__atan(): from sympy.functions.elementary.trigonometric import atan assert _test_args(atan(2)) def test_sympy__functions__elementary__trigonometric__atan2(): from sympy.functions.elementary.trigonometric import atan2 assert _test_args(atan2(2, 3)) def test_sympy__functions__elementary__trigonometric__cos(): from sympy.functions.elementary.trigonometric import cos assert _test_args(cos(2)) def test_sympy__functions__elementary__trigonometric__csc(): from sympy.functions.elementary.trigonometric import csc assert _test_args(csc(2)) def test_sympy__functions__elementary__trigonometric__cot(): from sympy.functions.elementary.trigonometric import cot assert _test_args(cot(2)) def test_sympy__functions__elementary__trigonometric__sin(): assert _test_args(sin(2)) def test_sympy__functions__elementary__trigonometric__sinc(): from sympy.functions.elementary.trigonometric import sinc assert _test_args(sinc(2)) def test_sympy__functions__elementary__trigonometric__sec(): from sympy.functions.elementary.trigonometric import sec assert _test_args(sec(2)) def test_sympy__functions__elementary__trigonometric__tan(): from sympy.functions.elementary.trigonometric import tan assert _test_args(tan(2)) @SKIP("abstract class") def test_sympy__functions__special__bessel__BesselBase(): pass @SKIP("abstract class") def test_sympy__functions__special__bessel__SphericalBesselBase(): pass @SKIP("abstract class") def test_sympy__functions__special__bessel__SphericalHankelBase(): pass def test_sympy__functions__special__bessel__besseli(): from sympy.functions.special.bessel import besseli assert _test_args(besseli(x, 1)) def test_sympy__functions__special__bessel__besselj(): from sympy.functions.special.bessel import besselj assert _test_args(besselj(x, 1)) def test_sympy__functions__special__bessel__besselk(): from sympy.functions.special.bessel import besselk assert _test_args(besselk(x, 1)) def test_sympy__functions__special__bessel__bessely(): from sympy.functions.special.bessel import bessely assert _test_args(bessely(x, 1)) def test_sympy__functions__special__bessel__hankel1(): from sympy.functions.special.bessel import hankel1 assert _test_args(hankel1(x, 1)) def test_sympy__functions__special__bessel__hankel2(): from sympy.functions.special.bessel import hankel2 assert _test_args(hankel2(x, 1)) def test_sympy__functions__special__bessel__jn(): from sympy.functions.special.bessel import jn assert _test_args(jn(0, x)) def test_sympy__functions__special__bessel__yn(): from sympy.functions.special.bessel import yn assert _test_args(yn(0, x)) def test_sympy__functions__special__bessel__hn1(): from sympy.functions.special.bessel import hn1 assert _test_args(hn1(0, x)) def test_sympy__functions__special__bessel__hn2(): from sympy.functions.special.bessel import hn2 assert _test_args(hn2(0, x)) def test_sympy__functions__special__bessel__AiryBase(): pass def test_sympy__functions__special__bessel__airyai(): from sympy.functions.special.bessel import airyai assert _test_args(airyai(2)) def test_sympy__functions__special__bessel__airybi(): from sympy.functions.special.bessel import airybi assert _test_args(airybi(2)) def test_sympy__functions__special__bessel__airyaiprime(): from sympy.functions.special.bessel import airyaiprime assert _test_args(airyaiprime(2)) def test_sympy__functions__special__bessel__airybiprime(): from sympy.functions.special.bessel import airybiprime assert _test_args(airybiprime(2)) def test_sympy__functions__special__elliptic_integrals__elliptic_k(): from sympy.functions.special.elliptic_integrals import elliptic_k as K assert _test_args(K(x)) def test_sympy__functions__special__elliptic_integrals__elliptic_f(): from sympy.functions.special.elliptic_integrals import elliptic_f as F assert _test_args(F(x, y)) def test_sympy__functions__special__elliptic_integrals__elliptic_e(): from sympy.functions.special.elliptic_integrals import elliptic_e as E assert _test_args(E(x)) assert _test_args(E(x, y)) def test_sympy__functions__special__elliptic_integrals__elliptic_pi(): from sympy.functions.special.elliptic_integrals import elliptic_pi as P assert _test_args(P(x, y)) assert _test_args(P(x, y, z)) def test_sympy__functions__special__delta_functions__DiracDelta(): from sympy.functions.special.delta_functions import DiracDelta assert _test_args(DiracDelta(x, 1)) def test_sympy__functions__special__singularity_functions__SingularityFunction(): from sympy.functions.special.singularity_functions import SingularityFunction assert _test_args(SingularityFunction(x, y, z)) def test_sympy__functions__special__delta_functions__Heaviside(): from sympy.functions.special.delta_functions import Heaviside assert _test_args(Heaviside(x)) def test_sympy__functions__special__error_functions__erf(): from sympy.functions.special.error_functions import erf assert _test_args(erf(2)) def test_sympy__functions__special__error_functions__erfc(): from sympy.functions.special.error_functions import erfc assert _test_args(erfc(2)) def test_sympy__functions__special__error_functions__erfi(): from sympy.functions.special.error_functions import erfi assert _test_args(erfi(2)) def test_sympy__functions__special__error_functions__erf2(): from sympy.functions.special.error_functions import erf2 assert _test_args(erf2(2, 3)) def test_sympy__functions__special__error_functions__erfinv(): from sympy.functions.special.error_functions import erfinv assert _test_args(erfinv(2)) def test_sympy__functions__special__error_functions__erfcinv(): from sympy.functions.special.error_functions import erfcinv assert _test_args(erfcinv(2)) def test_sympy__functions__special__error_functions__erf2inv(): from sympy.functions.special.error_functions import erf2inv assert _test_args(erf2inv(2, 3)) @SKIP("abstract class") def test_sympy__functions__special__error_functions__FresnelIntegral(): pass def test_sympy__functions__special__error_functions__fresnels(): from sympy.functions.special.error_functions import fresnels assert _test_args(fresnels(2)) def test_sympy__functions__special__error_functions__fresnelc(): from sympy.functions.special.error_functions import fresnelc assert _test_args(fresnelc(2)) def test_sympy__functions__special__error_functions__erfs(): from sympy.functions.special.error_functions import _erfs assert _test_args(_erfs(2)) def test_sympy__functions__special__error_functions__Ei(): from sympy.functions.special.error_functions import Ei assert _test_args(Ei(2)) def test_sympy__functions__special__error_functions__li(): from sympy.functions.special.error_functions import li assert _test_args(li(2)) def test_sympy__functions__special__error_functions__Li(): from sympy.functions.special.error_functions import Li assert _test_args(Li(2)) @SKIP("abstract class") def test_sympy__functions__special__error_functions__TrigonometricIntegral(): pass def test_sympy__functions__special__error_functions__Si(): from sympy.functions.special.error_functions import Si assert _test_args(Si(2)) def test_sympy__functions__special__error_functions__Ci(): from sympy.functions.special.error_functions import Ci assert _test_args(Ci(2)) def test_sympy__functions__special__error_functions__Shi(): from sympy.functions.special.error_functions import Shi assert _test_args(Shi(2)) def test_sympy__functions__special__error_functions__Chi(): from sympy.functions.special.error_functions import Chi assert _test_args(Chi(2)) def test_sympy__functions__special__error_functions__expint(): from sympy.functions.special.error_functions import expint assert _test_args(expint(y, x)) def test_sympy__functions__special__gamma_functions__gamma(): from sympy.functions.special.gamma_functions import gamma assert _test_args(gamma(x)) def test_sympy__functions__special__gamma_functions__loggamma(): from sympy.functions.special.gamma_functions import loggamma assert _test_args(loggamma(2)) def test_sympy__functions__special__gamma_functions__lowergamma(): from sympy.functions.special.gamma_functions import lowergamma assert _test_args(lowergamma(x, 2)) def test_sympy__functions__special__gamma_functions__polygamma(): from sympy.functions.special.gamma_functions import polygamma assert _test_args(polygamma(x, 2)) def test_sympy__functions__special__gamma_functions__uppergamma(): from sympy.functions.special.gamma_functions import uppergamma assert _test_args(uppergamma(x, 2)) def test_sympy__functions__special__beta_functions__beta(): from sympy.functions.special.beta_functions import beta assert _test_args(beta(x, x)) def test_sympy__functions__special__mathieu_functions__MathieuBase(): pass def test_sympy__functions__special__mathieu_functions__mathieus(): from sympy.functions.special.mathieu_functions import mathieus assert _test_args(mathieus(1, 1, 1)) def test_sympy__functions__special__mathieu_functions__mathieuc(): from sympy.functions.special.mathieu_functions import mathieuc assert _test_args(mathieuc(1, 1, 1)) def test_sympy__functions__special__mathieu_functions__mathieusprime(): from sympy.functions.special.mathieu_functions import mathieusprime assert _test_args(mathieusprime(1, 1, 1)) def test_sympy__functions__special__mathieu_functions__mathieucprime(): from sympy.functions.special.mathieu_functions import mathieucprime assert _test_args(mathieucprime(1, 1, 1)) @SKIP("abstract class") def test_sympy__functions__special__hyper__TupleParametersBase(): pass @SKIP("abstract class") def test_sympy__functions__special__hyper__TupleArg(): pass def test_sympy__functions__special__hyper__hyper(): from sympy.functions.special.hyper import hyper assert _test_args(hyper([1, 2, 3], [4, 5], x)) def test_sympy__functions__special__hyper__meijerg(): from sympy.functions.special.hyper import meijerg assert _test_args(meijerg([1, 2, 3], [4, 5], [6], [], x)) @SKIP("abstract class") def test_sympy__functions__special__hyper__HyperRep(): pass def test_sympy__functions__special__hyper__HyperRep_power1(): from sympy.functions.special.hyper import HyperRep_power1 assert _test_args(HyperRep_power1(x, y)) def test_sympy__functions__special__hyper__HyperRep_power2(): from sympy.functions.special.hyper import HyperRep_power2 assert _test_args(HyperRep_power2(x, y)) def test_sympy__functions__special__hyper__HyperRep_log1(): from sympy.functions.special.hyper import HyperRep_log1 assert _test_args(HyperRep_log1(x)) def test_sympy__functions__special__hyper__HyperRep_atanh(): from sympy.functions.special.hyper import HyperRep_atanh assert _test_args(HyperRep_atanh(x)) def test_sympy__functions__special__hyper__HyperRep_asin1(): from sympy.functions.special.hyper import HyperRep_asin1 assert _test_args(HyperRep_asin1(x)) def test_sympy__functions__special__hyper__HyperRep_asin2(): from sympy.functions.special.hyper import HyperRep_asin2 assert _test_args(HyperRep_asin2(x)) def test_sympy__functions__special__hyper__HyperRep_sqrts1(): from sympy.functions.special.hyper import HyperRep_sqrts1 assert _test_args(HyperRep_sqrts1(x, y)) def test_sympy__functions__special__hyper__HyperRep_sqrts2(): from sympy.functions.special.hyper import HyperRep_sqrts2 assert _test_args(HyperRep_sqrts2(x, y)) def test_sympy__functions__special__hyper__HyperRep_log2(): from sympy.functions.special.hyper import HyperRep_log2 assert _test_args(HyperRep_log2(x)) def test_sympy__functions__special__hyper__HyperRep_cosasin(): from sympy.functions.special.hyper import HyperRep_cosasin assert _test_args(HyperRep_cosasin(x, y)) def test_sympy__functions__special__hyper__HyperRep_sinasin(): from sympy.functions.special.hyper import HyperRep_sinasin assert _test_args(HyperRep_sinasin(x, y)) def test_sympy__functions__special__hyper__appellf1(): from sympy.functions.special.hyper import appellf1 a, b1, b2, c, x, y = symbols('a b1 b2 c x y') assert _test_args(appellf1(a, b1, b2, c, x, y)) @SKIP("abstract class") def test_sympy__functions__special__polynomials__OrthogonalPolynomial(): pass def test_sympy__functions__special__polynomials__jacobi(): from sympy.functions.special.polynomials import jacobi assert _test_args(jacobi(x, 2, 2, 2)) def test_sympy__functions__special__polynomials__gegenbauer(): from sympy.functions.special.polynomials import gegenbauer assert _test_args(gegenbauer(x, 2, 2)) def test_sympy__functions__special__polynomials__chebyshevt(): from sympy.functions.special.polynomials import chebyshevt assert _test_args(chebyshevt(x, 2)) def test_sympy__functions__special__polynomials__chebyshevt_root(): from sympy.functions.special.polynomials import chebyshevt_root assert _test_args(chebyshevt_root(3, 2)) def test_sympy__functions__special__polynomials__chebyshevu(): from sympy.functions.special.polynomials import chebyshevu assert _test_args(chebyshevu(x, 2)) def test_sympy__functions__special__polynomials__chebyshevu_root(): from sympy.functions.special.polynomials import chebyshevu_root assert _test_args(chebyshevu_root(3, 2)) def test_sympy__functions__special__polynomials__hermite(): from sympy.functions.special.polynomials import hermite assert _test_args(hermite(x, 2)) def test_sympy__functions__special__polynomials__legendre(): from sympy.functions.special.polynomials import legendre assert _test_args(legendre(x, 2)) def test_sympy__functions__special__polynomials__assoc_legendre(): from sympy.functions.special.polynomials import assoc_legendre assert _test_args(assoc_legendre(x, 0, y)) def test_sympy__functions__special__polynomials__laguerre(): from sympy.functions.special.polynomials import laguerre assert _test_args(laguerre(x, 2)) def test_sympy__functions__special__polynomials__assoc_laguerre(): from sympy.functions.special.polynomials import assoc_laguerre assert _test_args(assoc_laguerre(x, 0, y)) def test_sympy__functions__special__spherical_harmonics__Ynm(): from sympy.functions.special.spherical_harmonics import Ynm assert _test_args(Ynm(1, 1, x, y)) def test_sympy__functions__special__spherical_harmonics__Znm(): from sympy.functions.special.spherical_harmonics import Znm assert _test_args(Znm(1, 1, x, y)) def test_sympy__functions__special__tensor_functions__LeviCivita(): from sympy.functions.special.tensor_functions import LeviCivita assert _test_args(LeviCivita(x, y, 2)) def test_sympy__functions__special__tensor_functions__KroneckerDelta(): from sympy.functions.special.tensor_functions import KroneckerDelta assert _test_args(KroneckerDelta(x, y)) def test_sympy__functions__special__zeta_functions__dirichlet_eta(): from sympy.functions.special.zeta_functions import dirichlet_eta assert _test_args(dirichlet_eta(x)) def test_sympy__functions__special__zeta_functions__zeta(): from sympy.functions.special.zeta_functions import zeta assert _test_args(zeta(101)) def test_sympy__functions__special__zeta_functions__lerchphi(): from sympy.functions.special.zeta_functions import lerchphi assert _test_args(lerchphi(x, y, z)) def test_sympy__functions__special__zeta_functions__polylog(): from sympy.functions.special.zeta_functions import polylog assert _test_args(polylog(x, y)) def test_sympy__functions__special__zeta_functions__stieltjes(): from sympy.functions.special.zeta_functions import stieltjes assert _test_args(stieltjes(x, y)) def test_sympy__integrals__integrals__Integral(): from sympy.integrals.integrals import Integral assert _test_args(Integral(2, (x, 0, 1))) def test_sympy__integrals__risch__NonElementaryIntegral(): from sympy.integrals.risch import NonElementaryIntegral assert _test_args(NonElementaryIntegral(exp(-x**2), x)) @SKIP("abstract class") def test_sympy__integrals__transforms__IntegralTransform(): pass def test_sympy__integrals__transforms__MellinTransform(): from sympy.integrals.transforms import MellinTransform assert _test_args(MellinTransform(2, x, y)) def test_sympy__integrals__transforms__InverseMellinTransform(): from sympy.integrals.transforms import InverseMellinTransform assert _test_args(InverseMellinTransform(2, x, y, 0, 1)) def test_sympy__integrals__transforms__LaplaceTransform(): from sympy.integrals.transforms import LaplaceTransform assert _test_args(LaplaceTransform(2, x, y)) def test_sympy__integrals__transforms__InverseLaplaceTransform(): from sympy.integrals.transforms import InverseLaplaceTransform assert _test_args(InverseLaplaceTransform(2, x, y, 0)) @SKIP("abstract class") def test_sympy__integrals__transforms__FourierTypeTransform(): pass def test_sympy__integrals__transforms__InverseFourierTransform(): from sympy.integrals.transforms import InverseFourierTransform assert _test_args(InverseFourierTransform(2, x, y)) def test_sympy__integrals__transforms__FourierTransform(): from sympy.integrals.transforms import FourierTransform assert _test_args(FourierTransform(2, x, y)) @SKIP("abstract class") def test_sympy__integrals__transforms__SineCosineTypeTransform(): pass def test_sympy__integrals__transforms__InverseSineTransform(): from sympy.integrals.transforms import InverseSineTransform assert _test_args(InverseSineTransform(2, x, y)) def test_sympy__integrals__transforms__SineTransform(): from sympy.integrals.transforms import SineTransform assert _test_args(SineTransform(2, x, y)) def test_sympy__integrals__transforms__InverseCosineTransform(): from sympy.integrals.transforms import InverseCosineTransform assert _test_args(InverseCosineTransform(2, x, y)) def test_sympy__integrals__transforms__CosineTransform(): from sympy.integrals.transforms import CosineTransform assert _test_args(CosineTransform(2, x, y)) @SKIP("abstract class") def test_sympy__integrals__transforms__HankelTypeTransform(): pass def test_sympy__integrals__transforms__InverseHankelTransform(): from sympy.integrals.transforms import InverseHankelTransform assert _test_args(InverseHankelTransform(2, x, y, 0)) def test_sympy__integrals__transforms__HankelTransform(): from sympy.integrals.transforms import HankelTransform assert _test_args(HankelTransform(2, x, y, 0)) @XFAIL def test_sympy__liealgebras__cartan_type__CartanType_generator(): from sympy.liealgebras.cartan_type import CartanType_generator assert _test_args(CartanType_generator("A2")) @XFAIL def test_sympy__liealgebras__cartan_type__Standard_Cartan(): from sympy.liealgebras.cartan_type import Standard_Cartan assert _test_args(Standard_Cartan("A", 2)) @XFAIL def test_sympy__liealgebras__weyl_group__WeylGroup(): from sympy.liealgebras.weyl_group import WeylGroup assert _test_args(WeylGroup("B4")) @XFAIL def test_sympy__liealgebras__root_system__RootSystem(): from sympy.liealgebras.root_system import RootSystem assert _test_args(RootSystem("A2")) @XFAIL def test_sympy__liealgebras__type_a__TypeA(): from sympy.liealgebras.type_a import TypeA assert _test_args(TypeA(2)) @XFAIL def test_sympy__liealgebras__type_b__TypeB(): from sympy.liealgebras.type_b import TypeB assert _test_args(TypeB(4)) @XFAIL def test_sympy__liealgebras__type_c__TypeC(): from sympy.liealgebras.type_c import TypeC assert _test_args(TypeC(4)) @XFAIL def test_sympy__liealgebras__type_d__TypeD(): from sympy.liealgebras.type_d import TypeD assert _test_args(TypeD(4)) @XFAIL def test_sympy__liealgebras__type_e__TypeE(): from sympy.liealgebras.type_e import TypeE assert _test_args(TypeE(6)) @XFAIL def test_sympy__liealgebras__type_f__TypeF(): from sympy.liealgebras.type_f import TypeF assert _test_args(TypeF(4)) @XFAIL def test_sympy__liealgebras__type_g__TypeG(): from sympy.liealgebras.type_g import TypeG assert _test_args(TypeG(2)) def test_sympy__logic__boolalg__And(): from sympy.logic.boolalg import And assert _test_args(And(x, y, 1)) @SKIP("abstract class") def test_sympy__logic__boolalg__Boolean(): pass def test_sympy__logic__boolalg__BooleanFunction(): from sympy.logic.boolalg import BooleanFunction assert _test_args(BooleanFunction(1, 2, 3)) @SKIP("abstract class") def test_sympy__logic__boolalg__BooleanAtom(): pass def test_sympy__logic__boolalg__BooleanTrue(): from sympy.logic.boolalg import true assert _test_args(true) def test_sympy__logic__boolalg__BooleanFalse(): from sympy.logic.boolalg import false assert _test_args(false) def test_sympy__logic__boolalg__Equivalent(): from sympy.logic.boolalg import Equivalent assert _test_args(Equivalent(x, 2)) def test_sympy__logic__boolalg__ITE(): from sympy.logic.boolalg import ITE assert _test_args(ITE(x, y, 1)) def test_sympy__logic__boolalg__Implies(): from sympy.logic.boolalg import Implies assert _test_args(Implies(x, y)) def test_sympy__logic__boolalg__Nand(): from sympy.logic.boolalg import Nand assert _test_args(Nand(x, y, 1)) def test_sympy__logic__boolalg__Nor(): from sympy.logic.boolalg import Nor assert _test_args(Nor(x, y)) def test_sympy__logic__boolalg__Not(): from sympy.logic.boolalg import Not assert _test_args(Not(x)) def test_sympy__logic__boolalg__Or(): from sympy.logic.boolalg import Or assert _test_args(Or(x, y)) def test_sympy__logic__boolalg__Xor(): from sympy.logic.boolalg import Xor assert _test_args(Xor(x, y, 2)) def test_sympy__logic__boolalg__Xnor(): from sympy.logic.boolalg import Xnor assert _test_args(Xnor(x, y, 2)) def test_sympy__matrices__matrices__DeferredVector(): from sympy.matrices.matrices import DeferredVector assert _test_args(DeferredVector("X")) @SKIP("abstract class") def test_sympy__matrices__expressions__matexpr__MatrixBase(): pass def test_sympy__matrices__immutable__ImmutableDenseMatrix(): from sympy.matrices.immutable import ImmutableDenseMatrix m = ImmutableDenseMatrix([[1, 2], [3, 4]]) assert _test_args(m) assert _test_args(Basic(*list(m))) m = ImmutableDenseMatrix(1, 1, [1]) assert _test_args(m) assert _test_args(Basic(*list(m))) m = ImmutableDenseMatrix(2, 2, lambda i, j: 1) assert m[0, 0] is S.One m = ImmutableDenseMatrix(2, 2, lambda i, j: 1/(1 + i) + 1/(1 + j)) assert m[1, 1] is S.One # true div. will give 1.0 if i,j not sympified assert _test_args(m) assert _test_args(Basic(*list(m))) def test_sympy__matrices__immutable__ImmutableSparseMatrix(): from sympy.matrices.immutable import ImmutableSparseMatrix m = ImmutableSparseMatrix([[1, 2], [3, 4]]) assert _test_args(m) assert _test_args(Basic(*list(m))) m = ImmutableSparseMatrix(1, 1, {(0, 0): 1}) assert _test_args(m) assert _test_args(Basic(*list(m))) m = ImmutableSparseMatrix(1, 1, [1]) assert _test_args(m) assert _test_args(Basic(*list(m))) m = ImmutableSparseMatrix(2, 2, lambda i, j: 1) assert m[0, 0] is S.One m = ImmutableSparseMatrix(2, 2, lambda i, j: 1/(1 + i) + 1/(1 + j)) assert m[1, 1] is S.One # true div. will give 1.0 if i,j not sympified assert _test_args(m) assert _test_args(Basic(*list(m))) def test_sympy__matrices__expressions__slice__MatrixSlice(): from sympy.matrices.expressions.slice import MatrixSlice from sympy.matrices.expressions import MatrixSymbol X = MatrixSymbol('X', 4, 4) assert _test_args(MatrixSlice(X, (0, 2), (0, 2))) def test_sympy__matrices__expressions__applyfunc__ElementwiseApplyFunction(): from sympy.matrices.expressions.applyfunc import ElementwiseApplyFunction from sympy.matrices.expressions import MatrixSymbol X = MatrixSymbol("X", x, x) func = Lambda(x, x**2) assert _test_args(ElementwiseApplyFunction(func, X)) def test_sympy__matrices__expressions__blockmatrix__BlockDiagMatrix(): from sympy.matrices.expressions.blockmatrix import BlockDiagMatrix from sympy.matrices.expressions import MatrixSymbol X = MatrixSymbol('X', x, x) Y = MatrixSymbol('Y', y, y) assert _test_args(BlockDiagMatrix(X, Y)) def test_sympy__matrices__expressions__blockmatrix__BlockMatrix(): from sympy.matrices.expressions.blockmatrix import BlockMatrix from sympy.matrices.expressions import MatrixSymbol, ZeroMatrix X = MatrixSymbol('X', x, x) Y = MatrixSymbol('Y', y, y) Z = MatrixSymbol('Z', x, y) O = ZeroMatrix(y, x) assert _test_args(BlockMatrix([[X, Z], [O, Y]])) def test_sympy__matrices__expressions__inverse__Inverse(): from sympy.matrices.expressions.inverse import Inverse from sympy.matrices.expressions import MatrixSymbol assert _test_args(Inverse(MatrixSymbol('A', 3, 3))) def test_sympy__matrices__expressions__matadd__MatAdd(): from sympy.matrices.expressions.matadd import MatAdd from sympy.matrices.expressions import MatrixSymbol X = MatrixSymbol('X', x, y) Y = MatrixSymbol('Y', x, y) assert _test_args(MatAdd(X, Y)) def test_sympy__matrices__expressions__matexpr__Identity(): from sympy.matrices.expressions.matexpr import Identity assert _test_args(Identity(3)) def test_sympy__matrices__expressions__matexpr__GenericIdentity(): from sympy.matrices.expressions.matexpr import GenericIdentity assert _test_args(GenericIdentity()) @SKIP("abstract class") def test_sympy__matrices__expressions__matexpr__MatrixExpr(): pass def test_sympy__matrices__expressions__matexpr__MatrixElement(): from sympy.matrices.expressions.matexpr import MatrixSymbol, MatrixElement from sympy import S assert _test_args(MatrixElement(MatrixSymbol('A', 3, 5), S(2), S(3))) def test_sympy__matrices__expressions__matexpr__MatrixSymbol(): from sympy.matrices.expressions.matexpr import MatrixSymbol assert _test_args(MatrixSymbol('A', 3, 5)) def test_sympy__matrices__expressions__matexpr__ZeroMatrix(): from sympy.matrices.expressions.matexpr import ZeroMatrix assert _test_args(ZeroMatrix(3, 5)) def test_sympy__matrices__expressions__matexpr__GenericZeroMatrix(): from sympy.matrices.expressions.matexpr import GenericZeroMatrix assert _test_args(GenericZeroMatrix()) def test_sympy__matrices__expressions__matmul__MatMul(): from sympy.matrices.expressions.matmul import MatMul from sympy.matrices.expressions import MatrixSymbol X = MatrixSymbol('X', x, y) Y = MatrixSymbol('Y', y, x) assert _test_args(MatMul(X, Y)) def test_sympy__matrices__expressions__dotproduct__DotProduct(): from sympy.matrices.expressions.dotproduct import DotProduct from sympy.matrices.expressions import MatrixSymbol X = MatrixSymbol('X', x, 1) Y = MatrixSymbol('Y', x, 1) assert _test_args(DotProduct(X, Y)) def test_sympy__matrices__expressions__diagonal__DiagonalMatrix(): from sympy.matrices.expressions.diagonal import DiagonalMatrix from sympy.matrices.expressions import MatrixSymbol x = MatrixSymbol('x', 10, 1) assert _test_args(DiagonalMatrix(x)) def test_sympy__matrices__expressions__diagonal__DiagonalOf(): from sympy.matrices.expressions.diagonal import DiagonalOf from sympy.matrices.expressions import MatrixSymbol X = MatrixSymbol('x', 10, 10) assert _test_args(DiagonalOf(X)) def test_sympy__matrices__expressions__diagonal__DiagonalizeVector(): from sympy.matrices.expressions.diagonal import DiagonalizeVector from sympy.matrices.expressions import MatrixSymbol x = MatrixSymbol('x', 10, 1) assert _test_args(DiagonalizeVector(x)) def test_sympy__matrices__expressions__hadamard__HadamardProduct(): from sympy.matrices.expressions.hadamard import HadamardProduct from sympy.matrices.expressions import MatrixSymbol X = MatrixSymbol('X', x, y) Y = MatrixSymbol('Y', x, y) assert _test_args(HadamardProduct(X, Y)) def test_sympy__matrices__expressions__hadamard__HadamardPower(): from sympy.matrices.expressions.hadamard import HadamardPower from sympy.matrices.expressions import MatrixSymbol from sympy import Symbol X = MatrixSymbol('X', x, y) n = Symbol("n") assert _test_args(HadamardPower(X, n)) def test_sympy__matrices__expressions__kronecker__KroneckerProduct(): from sympy.matrices.expressions.kronecker import KroneckerProduct from sympy.matrices.expressions import MatrixSymbol X = MatrixSymbol('X', x, y) Y = MatrixSymbol('Y', x, y) assert _test_args(KroneckerProduct(X, Y)) def test_sympy__matrices__expressions__matpow__MatPow(): from sympy.matrices.expressions.matpow import MatPow from sympy.matrices.expressions import MatrixSymbol X = MatrixSymbol('X', x, x) assert _test_args(MatPow(X, 2)) def test_sympy__matrices__expressions__transpose__Transpose(): from sympy.matrices.expressions.transpose import Transpose from sympy.matrices.expressions import MatrixSymbol assert _test_args(Transpose(MatrixSymbol('A', 3, 5))) def test_sympy__matrices__expressions__adjoint__Adjoint(): from sympy.matrices.expressions.adjoint import Adjoint from sympy.matrices.expressions import MatrixSymbol assert _test_args(Adjoint(MatrixSymbol('A', 3, 5))) def test_sympy__matrices__expressions__trace__Trace(): from sympy.matrices.expressions.trace import Trace from sympy.matrices.expressions import MatrixSymbol assert _test_args(Trace(MatrixSymbol('A', 3, 3))) def test_sympy__matrices__expressions__determinant__Determinant(): from sympy.matrices.expressions.determinant import Determinant from sympy.matrices.expressions import MatrixSymbol assert _test_args(Determinant(MatrixSymbol('A', 3, 3))) def test_sympy__matrices__expressions__funcmatrix__FunctionMatrix(): from sympy.matrices.expressions.funcmatrix import FunctionMatrix from sympy import symbols i, j = symbols('i,j') assert _test_args(FunctionMatrix(3, 3, Lambda((i, j), i - j) )) def test_sympy__matrices__expressions__fourier__DFT(): from sympy.matrices.expressions.fourier import DFT from sympy import S assert _test_args(DFT(S(2))) def test_sympy__matrices__expressions__fourier__IDFT(): from sympy.matrices.expressions.fourier import IDFT from sympy import S assert _test_args(IDFT(S(2))) from sympy.matrices.expressions import MatrixSymbol X = MatrixSymbol('X', 10, 10) def test_sympy__matrices__expressions__factorizations__LofLU(): from sympy.matrices.expressions.factorizations import LofLU assert _test_args(LofLU(X)) def test_sympy__matrices__expressions__factorizations__UofLU(): from sympy.matrices.expressions.factorizations import UofLU assert _test_args(UofLU(X)) def test_sympy__matrices__expressions__factorizations__QofQR(): from sympy.matrices.expressions.factorizations import QofQR assert _test_args(QofQR(X)) def test_sympy__matrices__expressions__factorizations__RofQR(): from sympy.matrices.expressions.factorizations import RofQR assert _test_args(RofQR(X)) def test_sympy__matrices__expressions__factorizations__LofCholesky(): from sympy.matrices.expressions.factorizations import LofCholesky assert _test_args(LofCholesky(X)) def test_sympy__matrices__expressions__factorizations__UofCholesky(): from sympy.matrices.expressions.factorizations import UofCholesky assert _test_args(UofCholesky(X)) def test_sympy__matrices__expressions__factorizations__EigenVectors(): from sympy.matrices.expressions.factorizations import EigenVectors assert _test_args(EigenVectors(X)) def test_sympy__matrices__expressions__factorizations__EigenValues(): from sympy.matrices.expressions.factorizations import EigenValues assert _test_args(EigenValues(X)) def test_sympy__matrices__expressions__factorizations__UofSVD(): from sympy.matrices.expressions.factorizations import UofSVD assert _test_args(UofSVD(X)) def test_sympy__matrices__expressions__factorizations__VofSVD(): from sympy.matrices.expressions.factorizations import VofSVD assert _test_args(VofSVD(X)) def test_sympy__matrices__expressions__factorizations__SofSVD(): from sympy.matrices.expressions.factorizations import SofSVD assert _test_args(SofSVD(X)) @SKIP("abstract class") def test_sympy__matrices__expressions__factorizations__Factorization(): pass def test_sympy__physics__vector__frame__CoordinateSym(): from sympy.physics.vector import CoordinateSym from sympy.physics.vector import ReferenceFrame assert _test_args(CoordinateSym('R_x', ReferenceFrame('R'), 0)) def test_sympy__physics__paulialgebra__Pauli(): from sympy.physics.paulialgebra import Pauli assert _test_args(Pauli(1)) def test_sympy__physics__quantum__anticommutator__AntiCommutator(): from sympy.physics.quantum.anticommutator import AntiCommutator assert _test_args(AntiCommutator(x, y)) def test_sympy__physics__quantum__cartesian__PositionBra3D(): from sympy.physics.quantum.cartesian import PositionBra3D assert _test_args(PositionBra3D(x, y, z)) def test_sympy__physics__quantum__cartesian__PositionKet3D(): from sympy.physics.quantum.cartesian import PositionKet3D assert _test_args(PositionKet3D(x, y, z)) def test_sympy__physics__quantum__cartesian__PositionState3D(): from sympy.physics.quantum.cartesian import PositionState3D assert _test_args(PositionState3D(x, y, z)) def test_sympy__physics__quantum__cartesian__PxBra(): from sympy.physics.quantum.cartesian import PxBra assert _test_args(PxBra(x, y, z)) def test_sympy__physics__quantum__cartesian__PxKet(): from sympy.physics.quantum.cartesian import PxKet assert _test_args(PxKet(x, y, z)) def test_sympy__physics__quantum__cartesian__PxOp(): from sympy.physics.quantum.cartesian import PxOp assert _test_args(PxOp(x, y, z)) def test_sympy__physics__quantum__cartesian__XBra(): from sympy.physics.quantum.cartesian import XBra assert _test_args(XBra(x)) def test_sympy__physics__quantum__cartesian__XKet(): from sympy.physics.quantum.cartesian import XKet assert _test_args(XKet(x)) def test_sympy__physics__quantum__cartesian__XOp(): from sympy.physics.quantum.cartesian import XOp assert _test_args(XOp(x)) def test_sympy__physics__quantum__cartesian__YOp(): from sympy.physics.quantum.cartesian import YOp assert _test_args(YOp(x)) def test_sympy__physics__quantum__cartesian__ZOp(): from sympy.physics.quantum.cartesian import ZOp assert _test_args(ZOp(x)) def test_sympy__physics__quantum__cg__CG(): from sympy.physics.quantum.cg import CG from sympy import S assert _test_args(CG(S(3)/2, S(3)/2, S(1)/2, -S(1)/2, 1, 1)) def test_sympy__physics__quantum__cg__Wigner3j(): from sympy.physics.quantum.cg import Wigner3j assert _test_args(Wigner3j(6, 0, 4, 0, 2, 0)) def test_sympy__physics__quantum__cg__Wigner6j(): from sympy.physics.quantum.cg import Wigner6j assert _test_args(Wigner6j(1, 2, 3, 2, 1, 2)) def test_sympy__physics__quantum__cg__Wigner9j(): from sympy.physics.quantum.cg import Wigner9j assert _test_args(Wigner9j(2, 1, 1, S(3)/2, S(1)/2, 1, S(1)/2, S(1)/2, 0)) def test_sympy__physics__quantum__circuitplot__Mz(): from sympy.physics.quantum.circuitplot import Mz assert _test_args(Mz(0)) def test_sympy__physics__quantum__circuitplot__Mx(): from sympy.physics.quantum.circuitplot import Mx assert _test_args(Mx(0)) def test_sympy__physics__quantum__commutator__Commutator(): from sympy.physics.quantum.commutator import Commutator A, B = symbols('A,B', commutative=False) assert _test_args(Commutator(A, B)) def test_sympy__physics__quantum__constants__HBar(): from sympy.physics.quantum.constants import HBar assert _test_args(HBar()) def test_sympy__physics__quantum__dagger__Dagger(): from sympy.physics.quantum.dagger import Dagger from sympy.physics.quantum.state import Ket assert _test_args(Dagger(Dagger(Ket('psi')))) def test_sympy__physics__quantum__gate__CGate(): from sympy.physics.quantum.gate import CGate, Gate assert _test_args(CGate((0, 1), Gate(2))) def test_sympy__physics__quantum__gate__CGateS(): from sympy.physics.quantum.gate import CGateS, Gate assert _test_args(CGateS((0, 1), Gate(2))) def test_sympy__physics__quantum__gate__CNotGate(): from sympy.physics.quantum.gate import CNotGate assert _test_args(CNotGate(0, 1)) def test_sympy__physics__quantum__gate__Gate(): from sympy.physics.quantum.gate import Gate assert _test_args(Gate(0)) def test_sympy__physics__quantum__gate__HadamardGate(): from sympy.physics.quantum.gate import HadamardGate assert _test_args(HadamardGate(0)) def test_sympy__physics__quantum__gate__IdentityGate(): from sympy.physics.quantum.gate import IdentityGate assert _test_args(IdentityGate(0)) def test_sympy__physics__quantum__gate__OneQubitGate(): from sympy.physics.quantum.gate import OneQubitGate assert _test_args(OneQubitGate(0)) def test_sympy__physics__quantum__gate__PhaseGate(): from sympy.physics.quantum.gate import PhaseGate assert _test_args(PhaseGate(0)) def test_sympy__physics__quantum__gate__SwapGate(): from sympy.physics.quantum.gate import SwapGate assert _test_args(SwapGate(0, 1)) def test_sympy__physics__quantum__gate__TGate(): from sympy.physics.quantum.gate import TGate assert _test_args(TGate(0)) def test_sympy__physics__quantum__gate__TwoQubitGate(): from sympy.physics.quantum.gate import TwoQubitGate assert _test_args(TwoQubitGate(0)) def test_sympy__physics__quantum__gate__UGate(): from sympy.physics.quantum.gate import UGate from sympy.matrices.immutable import ImmutableDenseMatrix from sympy import Integer, Tuple assert _test_args( UGate(Tuple(Integer(1)), ImmutableDenseMatrix([[1, 0], [0, 2]]))) def test_sympy__physics__quantum__gate__XGate(): from sympy.physics.quantum.gate import XGate assert _test_args(XGate(0)) def test_sympy__physics__quantum__gate__YGate(): from sympy.physics.quantum.gate import YGate assert _test_args(YGate(0)) def test_sympy__physics__quantum__gate__ZGate(): from sympy.physics.quantum.gate import ZGate assert _test_args(ZGate(0)) @SKIP("TODO: sympy.physics") def test_sympy__physics__quantum__grover__OracleGate(): from sympy.physics.quantum.grover import OracleGate assert _test_args(OracleGate()) def test_sympy__physics__quantum__grover__WGate(): from sympy.physics.quantum.grover import WGate assert _test_args(WGate(1)) def test_sympy__physics__quantum__hilbert__ComplexSpace(): from sympy.physics.quantum.hilbert import ComplexSpace assert _test_args(ComplexSpace(x)) def test_sympy__physics__quantum__hilbert__DirectSumHilbertSpace(): from sympy.physics.quantum.hilbert import DirectSumHilbertSpace, ComplexSpace, FockSpace c = ComplexSpace(2) f = FockSpace() assert _test_args(DirectSumHilbertSpace(c, f)) def test_sympy__physics__quantum__hilbert__FockSpace(): from sympy.physics.quantum.hilbert import FockSpace assert _test_args(FockSpace()) def test_sympy__physics__quantum__hilbert__HilbertSpace(): from sympy.physics.quantum.hilbert import HilbertSpace assert _test_args(HilbertSpace()) def test_sympy__physics__quantum__hilbert__L2(): from sympy.physics.quantum.hilbert import L2 from sympy import oo, Interval assert _test_args(L2(Interval(0, oo))) def test_sympy__physics__quantum__hilbert__TensorPowerHilbertSpace(): from sympy.physics.quantum.hilbert import TensorPowerHilbertSpace, FockSpace f = FockSpace() assert _test_args(TensorPowerHilbertSpace(f, 2)) def test_sympy__physics__quantum__hilbert__TensorProductHilbertSpace(): from sympy.physics.quantum.hilbert import TensorProductHilbertSpace, FockSpace, ComplexSpace c = ComplexSpace(2) f = FockSpace() assert _test_args(TensorProductHilbertSpace(f, c)) def test_sympy__physics__quantum__innerproduct__InnerProduct(): from sympy.physics.quantum import Bra, Ket, InnerProduct b = Bra('b') k = Ket('k') assert _test_args(InnerProduct(b, k)) def test_sympy__physics__quantum__operator__DifferentialOperator(): from sympy.physics.quantum.operator import DifferentialOperator from sympy import Derivative, Function f = Function('f') assert _test_args(DifferentialOperator(1/x*Derivative(f(x), x), f(x))) def test_sympy__physics__quantum__operator__HermitianOperator(): from sympy.physics.quantum.operator import HermitianOperator assert _test_args(HermitianOperator('H')) def test_sympy__physics__quantum__operator__IdentityOperator(): from sympy.physics.quantum.operator import IdentityOperator assert _test_args(IdentityOperator(5)) def test_sympy__physics__quantum__operator__Operator(): from sympy.physics.quantum.operator import Operator assert _test_args(Operator('A')) def test_sympy__physics__quantum__operator__OuterProduct(): from sympy.physics.quantum.operator import OuterProduct from sympy.physics.quantum import Ket, Bra b = Bra('b') k = Ket('k') assert _test_args(OuterProduct(k, b)) def test_sympy__physics__quantum__operator__UnitaryOperator(): from sympy.physics.quantum.operator import UnitaryOperator assert _test_args(UnitaryOperator('U')) def test_sympy__physics__quantum__piab__PIABBra(): from sympy.physics.quantum.piab import PIABBra assert _test_args(PIABBra('B')) def test_sympy__physics__quantum__boson__BosonOp(): from sympy.physics.quantum.boson import BosonOp assert _test_args(BosonOp('a')) assert _test_args(BosonOp('a', False)) def test_sympy__physics__quantum__boson__BosonFockKet(): from sympy.physics.quantum.boson import BosonFockKet assert _test_args(BosonFockKet(1)) def test_sympy__physics__quantum__boson__BosonFockBra(): from sympy.physics.quantum.boson import BosonFockBra assert _test_args(BosonFockBra(1)) def test_sympy__physics__quantum__boson__BosonCoherentKet(): from sympy.physics.quantum.boson import BosonCoherentKet assert _test_args(BosonCoherentKet(1)) def test_sympy__physics__quantum__boson__BosonCoherentBra(): from sympy.physics.quantum.boson import BosonCoherentBra assert _test_args(BosonCoherentBra(1)) def test_sympy__physics__quantum__fermion__FermionOp(): from sympy.physics.quantum.fermion import FermionOp assert _test_args(FermionOp('c')) assert _test_args(FermionOp('c', False)) def test_sympy__physics__quantum__fermion__FermionFockKet(): from sympy.physics.quantum.fermion import FermionFockKet assert _test_args(FermionFockKet(1)) def test_sympy__physics__quantum__fermion__FermionFockBra(): from sympy.physics.quantum.fermion import FermionFockBra assert _test_args(FermionFockBra(1)) def test_sympy__physics__quantum__pauli__SigmaOpBase(): from sympy.physics.quantum.pauli import SigmaOpBase assert _test_args(SigmaOpBase()) def test_sympy__physics__quantum__pauli__SigmaX(): from sympy.physics.quantum.pauli import SigmaX assert _test_args(SigmaX()) def test_sympy__physics__quantum__pauli__SigmaY(): from sympy.physics.quantum.pauli import SigmaY assert _test_args(SigmaY()) def test_sympy__physics__quantum__pauli__SigmaZ(): from sympy.physics.quantum.pauli import SigmaZ assert _test_args(SigmaZ()) def test_sympy__physics__quantum__pauli__SigmaMinus(): from sympy.physics.quantum.pauli import SigmaMinus assert _test_args(SigmaMinus()) def test_sympy__physics__quantum__pauli__SigmaPlus(): from sympy.physics.quantum.pauli import SigmaPlus assert _test_args(SigmaPlus()) def test_sympy__physics__quantum__pauli__SigmaZKet(): from sympy.physics.quantum.pauli import SigmaZKet assert _test_args(SigmaZKet(0)) def test_sympy__physics__quantum__pauli__SigmaZBra(): from sympy.physics.quantum.pauli import SigmaZBra assert _test_args(SigmaZBra(0)) def test_sympy__physics__quantum__piab__PIABHamiltonian(): from sympy.physics.quantum.piab import PIABHamiltonian assert _test_args(PIABHamiltonian('P')) def test_sympy__physics__quantum__piab__PIABKet(): from sympy.physics.quantum.piab import PIABKet assert _test_args(PIABKet('K')) def test_sympy__physics__quantum__qexpr__QExpr(): from sympy.physics.quantum.qexpr import QExpr assert _test_args(QExpr(0)) def test_sympy__physics__quantum__qft__Fourier(): from sympy.physics.quantum.qft import Fourier assert _test_args(Fourier(0, 1)) def test_sympy__physics__quantum__qft__IQFT(): from sympy.physics.quantum.qft import IQFT assert _test_args(IQFT(0, 1)) def test_sympy__physics__quantum__qft__QFT(): from sympy.physics.quantum.qft import QFT assert _test_args(QFT(0, 1)) def test_sympy__physics__quantum__qft__RkGate(): from sympy.physics.quantum.qft import RkGate assert _test_args(RkGate(0, 1)) def test_sympy__physics__quantum__qubit__IntQubit(): from sympy.physics.quantum.qubit import IntQubit assert _test_args(IntQubit(0)) def test_sympy__physics__quantum__qubit__IntQubitBra(): from sympy.physics.quantum.qubit import IntQubitBra assert _test_args(IntQubitBra(0)) def test_sympy__physics__quantum__qubit__IntQubitState(): from sympy.physics.quantum.qubit import IntQubitState, QubitState assert _test_args(IntQubitState(QubitState(0, 1))) def test_sympy__physics__quantum__qubit__Qubit(): from sympy.physics.quantum.qubit import Qubit assert _test_args(Qubit(0, 0, 0)) def test_sympy__physics__quantum__qubit__QubitBra(): from sympy.physics.quantum.qubit import QubitBra assert _test_args(QubitBra('1', 0)) def test_sympy__physics__quantum__qubit__QubitState(): from sympy.physics.quantum.qubit import QubitState assert _test_args(QubitState(0, 1)) def test_sympy__physics__quantum__density__Density(): from sympy.physics.quantum.density import Density from sympy.physics.quantum.state import Ket assert _test_args(Density([Ket(0), 0.5], [Ket(1), 0.5])) @SKIP("TODO: sympy.physics.quantum.shor: Cmod Not Implemented") def test_sympy__physics__quantum__shor__CMod(): from sympy.physics.quantum.shor import CMod assert _test_args(CMod()) def test_sympy__physics__quantum__spin__CoupledSpinState(): from sympy.physics.quantum.spin import CoupledSpinState assert _test_args(CoupledSpinState(1, 0, (1, 1))) assert _test_args(CoupledSpinState(1, 0, (1, S(1)/2, S(1)/2))) assert _test_args(CoupledSpinState( 1, 0, (1, S(1)/2, S(1)/2), ((2, 3, S(1)/2), (1, 2, 1)) )) j, m, j1, j2, j3, j12, x = symbols('j m j1:4 j12 x') assert CoupledSpinState( j, m, (j1, j2, j3)).subs(j2, x) == CoupledSpinState(j, m, (j1, x, j3)) assert CoupledSpinState(j, m, (j1, j2, j3), ((1, 3, j12), (1, 2, j)) ).subs(j12, x) == \ CoupledSpinState(j, m, (j1, j2, j3), ((1, 3, x), (1, 2, j)) ) def test_sympy__physics__quantum__spin__J2Op(): from sympy.physics.quantum.spin import J2Op assert _test_args(J2Op('J')) def test_sympy__physics__quantum__spin__JminusOp(): from sympy.physics.quantum.spin import JminusOp assert _test_args(JminusOp('J')) def test_sympy__physics__quantum__spin__JplusOp(): from sympy.physics.quantum.spin import JplusOp assert _test_args(JplusOp('J')) def test_sympy__physics__quantum__spin__JxBra(): from sympy.physics.quantum.spin import JxBra assert _test_args(JxBra(1, 0)) def test_sympy__physics__quantum__spin__JxBraCoupled(): from sympy.physics.quantum.spin import JxBraCoupled assert _test_args(JxBraCoupled(1, 0, (1, 1))) def test_sympy__physics__quantum__spin__JxKet(): from sympy.physics.quantum.spin import JxKet assert _test_args(JxKet(1, 0)) def test_sympy__physics__quantum__spin__JxKetCoupled(): from sympy.physics.quantum.spin import JxKetCoupled assert _test_args(JxKetCoupled(1, 0, (1, 1))) def test_sympy__physics__quantum__spin__JxOp(): from sympy.physics.quantum.spin import JxOp assert _test_args(JxOp('J')) def test_sympy__physics__quantum__spin__JyBra(): from sympy.physics.quantum.spin import JyBra assert _test_args(JyBra(1, 0)) def test_sympy__physics__quantum__spin__JyBraCoupled(): from sympy.physics.quantum.spin import JyBraCoupled assert _test_args(JyBraCoupled(1, 0, (1, 1))) def test_sympy__physics__quantum__spin__JyKet(): from sympy.physics.quantum.spin import JyKet assert _test_args(JyKet(1, 0)) def test_sympy__physics__quantum__spin__JyKetCoupled(): from sympy.physics.quantum.spin import JyKetCoupled assert _test_args(JyKetCoupled(1, 0, (1, 1))) def test_sympy__physics__quantum__spin__JyOp(): from sympy.physics.quantum.spin import JyOp assert _test_args(JyOp('J')) def test_sympy__physics__quantum__spin__JzBra(): from sympy.physics.quantum.spin import JzBra assert _test_args(JzBra(1, 0)) def test_sympy__physics__quantum__spin__JzBraCoupled(): from sympy.physics.quantum.spin import JzBraCoupled assert _test_args(JzBraCoupled(1, 0, (1, 1))) def test_sympy__physics__quantum__spin__JzKet(): from sympy.physics.quantum.spin import JzKet assert _test_args(JzKet(1, 0)) def test_sympy__physics__quantum__spin__JzKetCoupled(): from sympy.physics.quantum.spin import JzKetCoupled assert _test_args(JzKetCoupled(1, 0, (1, 1))) def test_sympy__physics__quantum__spin__JzOp(): from sympy.physics.quantum.spin import JzOp assert _test_args(JzOp('J')) def test_sympy__physics__quantum__spin__Rotation(): from sympy.physics.quantum.spin import Rotation assert _test_args(Rotation(pi, 0, pi/2)) def test_sympy__physics__quantum__spin__SpinState(): from sympy.physics.quantum.spin import SpinState assert _test_args(SpinState(1, 0)) def test_sympy__physics__quantum__spin__WignerD(): from sympy.physics.quantum.spin import WignerD assert _test_args(WignerD(0, 1, 2, 3, 4, 5)) def test_sympy__physics__quantum__state__Bra(): from sympy.physics.quantum.state import Bra assert _test_args(Bra(0)) def test_sympy__physics__quantum__state__BraBase(): from sympy.physics.quantum.state import BraBase assert _test_args(BraBase(0)) def test_sympy__physics__quantum__state__Ket(): from sympy.physics.quantum.state import Ket assert _test_args(Ket(0)) def test_sympy__physics__quantum__state__KetBase(): from sympy.physics.quantum.state import KetBase assert _test_args(KetBase(0)) def test_sympy__physics__quantum__state__State(): from sympy.physics.quantum.state import State assert _test_args(State(0)) def test_sympy__physics__quantum__state__StateBase(): from sympy.physics.quantum.state import StateBase assert _test_args(StateBase(0)) def test_sympy__physics__quantum__state__TimeDepBra(): from sympy.physics.quantum.state import TimeDepBra assert _test_args(TimeDepBra('psi', 't')) def test_sympy__physics__quantum__state__TimeDepKet(): from sympy.physics.quantum.state import TimeDepKet assert _test_args(TimeDepKet('psi', 't')) def test_sympy__physics__quantum__state__TimeDepState(): from sympy.physics.quantum.state import TimeDepState assert _test_args(TimeDepState('psi', 't')) def test_sympy__physics__quantum__state__Wavefunction(): from sympy.physics.quantum.state import Wavefunction from sympy.functions import sin from sympy import Piecewise n = 1 L = 1 g = Piecewise((0, x < 0), (0, x > L), (sqrt(2//L)*sin(n*pi*x/L), True)) assert _test_args(Wavefunction(g, x)) def test_sympy__physics__quantum__tensorproduct__TensorProduct(): from sympy.physics.quantum.tensorproduct import TensorProduct assert _test_args(TensorProduct(x, y)) def test_sympy__physics__quantum__identitysearch__GateIdentity(): from sympy.physics.quantum.gate import X from sympy.physics.quantum.identitysearch import GateIdentity assert _test_args(GateIdentity(X(0), X(0))) def test_sympy__physics__quantum__sho1d__SHOOp(): from sympy.physics.quantum.sho1d import SHOOp assert _test_args(SHOOp('a')) def test_sympy__physics__quantum__sho1d__RaisingOp(): from sympy.physics.quantum.sho1d import RaisingOp assert _test_args(RaisingOp('a')) def test_sympy__physics__quantum__sho1d__LoweringOp(): from sympy.physics.quantum.sho1d import LoweringOp assert _test_args(LoweringOp('a')) def test_sympy__physics__quantum__sho1d__NumberOp(): from sympy.physics.quantum.sho1d import NumberOp assert _test_args(NumberOp('N')) def test_sympy__physics__quantum__sho1d__Hamiltonian(): from sympy.physics.quantum.sho1d import Hamiltonian assert _test_args(Hamiltonian('H')) def test_sympy__physics__quantum__sho1d__SHOState(): from sympy.physics.quantum.sho1d import SHOState assert _test_args(SHOState(0)) def test_sympy__physics__quantum__sho1d__SHOKet(): from sympy.physics.quantum.sho1d import SHOKet assert _test_args(SHOKet(0)) def test_sympy__physics__quantum__sho1d__SHOBra(): from sympy.physics.quantum.sho1d import SHOBra assert _test_args(SHOBra(0)) def test_sympy__physics__secondquant__AnnihilateBoson(): from sympy.physics.secondquant import AnnihilateBoson assert _test_args(AnnihilateBoson(0)) def test_sympy__physics__secondquant__AnnihilateFermion(): from sympy.physics.secondquant import AnnihilateFermion assert _test_args(AnnihilateFermion(0)) @SKIP("abstract class") def test_sympy__physics__secondquant__Annihilator(): pass def test_sympy__physics__secondquant__AntiSymmetricTensor(): from sympy.physics.secondquant import AntiSymmetricTensor i, j = symbols('i j', below_fermi=True) a, b = symbols('a b', above_fermi=True) assert _test_args(AntiSymmetricTensor('v', (a, i), (b, j))) def test_sympy__physics__secondquant__BosonState(): from sympy.physics.secondquant import BosonState assert _test_args(BosonState((0, 1))) @SKIP("abstract class") def test_sympy__physics__secondquant__BosonicOperator(): pass def test_sympy__physics__secondquant__Commutator(): from sympy.physics.secondquant import Commutator assert _test_args(Commutator(x, y)) def test_sympy__physics__secondquant__CreateBoson(): from sympy.physics.secondquant import CreateBoson assert _test_args(CreateBoson(0)) def test_sympy__physics__secondquant__CreateFermion(): from sympy.physics.secondquant import CreateFermion assert _test_args(CreateFermion(0)) @SKIP("abstract class") def test_sympy__physics__secondquant__Creator(): pass def test_sympy__physics__secondquant__Dagger(): from sympy.physics.secondquant import Dagger from sympy import I assert _test_args(Dagger(2*I)) def test_sympy__physics__secondquant__FermionState(): from sympy.physics.secondquant import FermionState assert _test_args(FermionState((0, 1))) def test_sympy__physics__secondquant__FermionicOperator(): from sympy.physics.secondquant import FermionicOperator assert _test_args(FermionicOperator(0)) def test_sympy__physics__secondquant__FockState(): from sympy.physics.secondquant import FockState assert _test_args(FockState((0, 1))) def test_sympy__physics__secondquant__FockStateBosonBra(): from sympy.physics.secondquant import FockStateBosonBra assert _test_args(FockStateBosonBra((0, 1))) def test_sympy__physics__secondquant__FockStateBosonKet(): from sympy.physics.secondquant import FockStateBosonKet assert _test_args(FockStateBosonKet((0, 1))) def test_sympy__physics__secondquant__FockStateBra(): from sympy.physics.secondquant import FockStateBra assert _test_args(FockStateBra((0, 1))) def test_sympy__physics__secondquant__FockStateFermionBra(): from sympy.physics.secondquant import FockStateFermionBra assert _test_args(FockStateFermionBra((0, 1))) def test_sympy__physics__secondquant__FockStateFermionKet(): from sympy.physics.secondquant import FockStateFermionKet assert _test_args(FockStateFermionKet((0, 1))) def test_sympy__physics__secondquant__FockStateKet(): from sympy.physics.secondquant import FockStateKet assert _test_args(FockStateKet((0, 1))) def test_sympy__physics__secondquant__InnerProduct(): from sympy.physics.secondquant import InnerProduct from sympy.physics.secondquant import FockStateKet, FockStateBra assert _test_args(InnerProduct(FockStateBra((0, 1)), FockStateKet((0, 1)))) def test_sympy__physics__secondquant__NO(): from sympy.physics.secondquant import NO, F, Fd assert _test_args(NO(Fd(x)*F(y))) def test_sympy__physics__secondquant__PermutationOperator(): from sympy.physics.secondquant import PermutationOperator assert _test_args(PermutationOperator(0, 1)) def test_sympy__physics__secondquant__SqOperator(): from sympy.physics.secondquant import SqOperator assert _test_args(SqOperator(0)) def test_sympy__physics__secondquant__TensorSymbol(): from sympy.physics.secondquant import TensorSymbol assert _test_args(TensorSymbol(x)) def test_sympy__physics__units__dimensions__Dimension(): from sympy.physics.units.dimensions import Dimension assert _test_args(Dimension("length", "L")) def test_sympy__physics__units__dimensions__DimensionSystem(): from sympy.physics.units.dimensions import DimensionSystem from sympy.physics.units.dimensions import length, time, velocity assert _test_args(DimensionSystem((length, time), (velocity,))) def test_sympy__physics__units__quantities__Quantity(): from sympy.physics.units.quantities import Quantity from sympy.physics.units import length assert _test_args(Quantity("dam")) def test_sympy__physics__units__prefixes__Prefix(): from sympy.physics.units.prefixes import Prefix assert _test_args(Prefix('kilo', 'k', 3)) def test_sympy__core__numbers__AlgebraicNumber(): from sympy.core.numbers import AlgebraicNumber assert _test_args(AlgebraicNumber(sqrt(2), [1, 2, 3])) def test_sympy__polys__polytools__GroebnerBasis(): from sympy.polys.polytools import GroebnerBasis assert _test_args(GroebnerBasis([x, y, z], x, y, z)) def test_sympy__polys__polytools__Poly(): from sympy.polys.polytools import Poly assert _test_args(Poly(2, x, y)) def test_sympy__polys__polytools__PurePoly(): from sympy.polys.polytools import PurePoly assert _test_args(PurePoly(2, x, y)) @SKIP('abstract class') def test_sympy__polys__rootoftools__RootOf(): pass def test_sympy__polys__rootoftools__ComplexRootOf(): from sympy.polys.rootoftools import ComplexRootOf assert _test_args(ComplexRootOf(x**3 + x + 1, 0)) def test_sympy__polys__rootoftools__RootSum(): from sympy.polys.rootoftools import RootSum assert _test_args(RootSum(x**3 + x + 1, sin)) def test_sympy__series__limits__Limit(): from sympy.series.limits import Limit assert _test_args(Limit(x, x, 0, dir='-')) def test_sympy__series__order__Order(): from sympy.series.order import Order assert _test_args(Order(1, x, y)) @SKIP('Abstract Class') def test_sympy__series__sequences__SeqBase(): pass def test_sympy__series__sequences__EmptySequence(): from sympy.series.sequences import EmptySequence assert _test_args(EmptySequence()) @SKIP('Abstract Class') def test_sympy__series__sequences__SeqExpr(): pass def test_sympy__series__sequences__SeqPer(): from sympy.series.sequences import SeqPer assert _test_args(SeqPer((1, 2, 3), (0, 10))) def test_sympy__series__sequences__SeqFormula(): from sympy.series.sequences import SeqFormula assert _test_args(SeqFormula(x**2, (0, 10))) def test_sympy__series__sequences__RecursiveSeq(): from sympy.series.sequences import RecursiveSeq y = Function("y") n = symbols("n") assert _test_args(RecursiveSeq(y(n - 1) + y(n - 2), y, n, (0, 1))) assert _test_args(RecursiveSeq(y(n - 1) + y(n - 2), y, n)) def test_sympy__series__sequences__SeqExprOp(): from sympy.series.sequences import SeqExprOp, sequence s1 = sequence((1, 2, 3)) s2 = sequence(x**2) assert _test_args(SeqExprOp(s1, s2)) def test_sympy__series__sequences__SeqAdd(): from sympy.series.sequences import SeqAdd, sequence s1 = sequence((1, 2, 3)) s2 = sequence(x**2) assert _test_args(SeqAdd(s1, s2)) def test_sympy__series__sequences__SeqMul(): from sympy.series.sequences import SeqMul, sequence s1 = sequence((1, 2, 3)) s2 = sequence(x**2) assert _test_args(SeqMul(s1, s2)) @SKIP('Abstract Class') def test_sympy__series__series_class__SeriesBase(): pass def test_sympy__series__fourier__FourierSeries(): from sympy.series.fourier import fourier_series assert _test_args(fourier_series(x, (x, -pi, pi))) def test_sympy__series__fourier__FiniteFourierSeries(): from sympy.series.fourier import fourier_series assert _test_args(fourier_series(sin(pi*x), (x, -1, 1))) def test_sympy__series__formal__FormalPowerSeries(): from sympy.series.formal import fps assert _test_args(fps(log(1 + x), x)) def test_sympy__simplify__hyperexpand__Hyper_Function(): from sympy.simplify.hyperexpand import Hyper_Function assert _test_args(Hyper_Function([2], [1])) def test_sympy__simplify__hyperexpand__G_Function(): from sympy.simplify.hyperexpand import G_Function assert _test_args(G_Function([2], [1], [], [])) @SKIP("abstract class") def test_sympy__tensor__array__ndim_array__ImmutableNDimArray(): pass def test_sympy__tensor__array__dense_ndim_array__ImmutableDenseNDimArray(): from sympy.tensor.array.dense_ndim_array import ImmutableDenseNDimArray densarr = ImmutableDenseNDimArray(range(10, 34), (2, 3, 4)) assert _test_args(densarr) def test_sympy__tensor__array__sparse_ndim_array__ImmutableSparseNDimArray(): from sympy.tensor.array.sparse_ndim_array import ImmutableSparseNDimArray sparr = ImmutableSparseNDimArray(range(10, 34), (2, 3, 4)) assert _test_args(sparr) def test_sympy__tensor__functions__TensorProduct(): from sympy.tensor.functions import TensorProduct tp = TensorProduct(3, 4, evaluate=False) assert _test_args(tp) def test_sympy__tensor__indexed__Idx(): from sympy.tensor.indexed import Idx assert _test_args(Idx('test')) assert _test_args(Idx(1, (0, 10))) def test_sympy__tensor__indexed__Indexed(): from sympy.tensor.indexed import Indexed, Idx assert _test_args(Indexed('A', Idx('i'), Idx('j'))) def test_sympy__tensor__indexed__IndexedBase(): from sympy.tensor.indexed import IndexedBase assert _test_args(IndexedBase('A', shape=(x, y))) assert _test_args(IndexedBase('A', 1)) assert _test_args(IndexedBase('A')[0, 1]) def test_sympy__tensor__tensor__TensorIndexType(): from sympy.tensor.tensor import TensorIndexType assert _test_args(TensorIndexType('Lorentz', metric=False)) def test_sympy__tensor__tensor__TensorSymmetry(): from sympy.tensor.tensor import TensorSymmetry, get_symmetric_group_sgs assert _test_args(TensorSymmetry(get_symmetric_group_sgs(2))) def test_sympy__tensor__tensor__TensorType(): from sympy.tensor.tensor import TensorIndexType, TensorSymmetry, get_symmetric_group_sgs, TensorType Lorentz = TensorIndexType('Lorentz', dummy_fmt='L') sym = TensorSymmetry(get_symmetric_group_sgs(1)) assert _test_args(TensorType([Lorentz], sym)) def test_sympy__tensor__tensor__TensorHead(): from sympy.tensor.tensor import TensorIndexType, TensorSymmetry, TensorType, get_symmetric_group_sgs, TensorHead Lorentz = TensorIndexType('Lorentz', dummy_fmt='L') sym = TensorSymmetry(get_symmetric_group_sgs(1)) S1 = TensorType([Lorentz], sym) assert _test_args(TensorHead('p', S1, 0)) def test_sympy__tensor__tensor__TensorIndex(): from sympy.tensor.tensor import TensorIndexType, TensorIndex Lorentz = TensorIndexType('Lorentz', dummy_fmt='L') assert _test_args(TensorIndex('i', Lorentz)) @SKIP("abstract class") def test_sympy__tensor__tensor__TensExpr(): pass def test_sympy__tensor__tensor__TensAdd(): from sympy.tensor.tensor import TensorIndexType, TensorSymmetry, TensorType, get_symmetric_group_sgs, tensor_indices, TensAdd Lorentz = TensorIndexType('Lorentz', dummy_fmt='L') a, b = tensor_indices('a,b', Lorentz) sym = TensorSymmetry(get_symmetric_group_sgs(1)) S1 = TensorType([Lorentz], sym) p, q = S1('p,q') t1 = p(a) t2 = q(a) assert _test_args(TensAdd(t1, t2)) def test_sympy__tensor__tensor__Tensor(): from sympy.core import S from sympy.tensor.tensor import TensorIndexType, TensorSymmetry, TensorType, get_symmetric_group_sgs, tensor_indices, TensMul Lorentz = TensorIndexType('Lorentz', dummy_fmt='L') a, b = tensor_indices('a,b', Lorentz) sym = TensorSymmetry(get_symmetric_group_sgs(1)) S1 = TensorType([Lorentz], sym) p = S1('p') assert _test_args(p(a)) def test_sympy__tensor__tensor__TensMul(): from sympy.core import S from sympy.tensor.tensor import TensorIndexType, TensorSymmetry, TensorType, get_symmetric_group_sgs, tensor_indices, TensMul Lorentz = TensorIndexType('Lorentz', dummy_fmt='L') a, b = tensor_indices('a,b', Lorentz) sym = TensorSymmetry(get_symmetric_group_sgs(1)) S1 = TensorType([Lorentz], sym) p = S1('p') q = S1('q') assert _test_args(3*p(a)*q(b)) def test_sympy__tensor__tensor__TensorElement(): from sympy.tensor.tensor import TensorIndexType, tensorhead, TensorElement L = TensorIndexType("L") A = tensorhead("A", [L, L], [[1], [1]]) telem = TensorElement(A(x, y), {x: 1}) assert _test_args(telem) def test_sympy__tensor__toperators__PartialDerivative(): from sympy.tensor.tensor import TensorIndexType, tensor_indices, tensorhead from sympy.tensor.toperators import PartialDerivative Lorentz = TensorIndexType('Lorentz', dummy_fmt='L') a, b = tensor_indices('a,b', Lorentz) A = tensorhead("A", [Lorentz], [[1]]) assert _test_args(PartialDerivative(A(a), A(b))) def test_as_coeff_add(): assert (7, (3*x, 4*x**2)) == (7 + 3*x + 4*x**2).as_coeff_add() def test_sympy__geometry__curve__Curve(): from sympy.geometry.curve import Curve assert _test_args(Curve((x, 1), (x, 0, 1))) def test_sympy__geometry__point__Point(): from sympy.geometry.point import Point assert _test_args(Point(0, 1)) def test_sympy__geometry__point__Point2D(): from sympy.geometry.point import Point2D assert _test_args(Point2D(0, 1)) def test_sympy__geometry__point__Point3D(): from sympy.geometry.point import Point3D assert _test_args(Point3D(0, 1, 2)) def test_sympy__geometry__ellipse__Ellipse(): from sympy.geometry.ellipse import Ellipse assert _test_args(Ellipse((0, 1), 2, 3)) def test_sympy__geometry__ellipse__Circle(): from sympy.geometry.ellipse import Circle assert _test_args(Circle((0, 1), 2)) def test_sympy__geometry__parabola__Parabola(): from sympy.geometry.parabola import Parabola from sympy.geometry.line import Line assert _test_args(Parabola((0, 0), Line((2, 3), (4, 3)))) @SKIP("abstract class") def test_sympy__geometry__line__LinearEntity(): pass def test_sympy__geometry__line__Line(): from sympy.geometry.line import Line assert _test_args(Line((0, 1), (2, 3))) def test_sympy__geometry__line__Ray(): from sympy.geometry.line import Ray assert _test_args(Ray((0, 1), (2, 3))) def test_sympy__geometry__line__Segment(): from sympy.geometry.line import Segment assert _test_args(Segment((0, 1), (2, 3))) @SKIP("abstract class") def test_sympy__geometry__line__LinearEntity2D(): pass def test_sympy__geometry__line__Line2D(): from sympy.geometry.line import Line2D assert _test_args(Line2D((0, 1), (2, 3))) def test_sympy__geometry__line__Ray2D(): from sympy.geometry.line import Ray2D assert _test_args(Ray2D((0, 1), (2, 3))) def test_sympy__geometry__line__Segment2D(): from sympy.geometry.line import Segment2D assert _test_args(Segment2D((0, 1), (2, 3))) @SKIP("abstract class") def test_sympy__geometry__line__LinearEntity3D(): pass def test_sympy__geometry__line__Line3D(): from sympy.geometry.line import Line3D assert _test_args(Line3D((0, 1, 1), (2, 3, 4))) def test_sympy__geometry__line__Segment3D(): from sympy.geometry.line import Segment3D assert _test_args(Segment3D((0, 1, 1), (2, 3, 4))) def test_sympy__geometry__line__Ray3D(): from sympy.geometry.line import Ray3D assert _test_args(Ray3D((0, 1, 1), (2, 3, 4))) def test_sympy__geometry__plane__Plane(): from sympy.geometry.plane import Plane assert _test_args(Plane((1, 1, 1), (-3, 4, -2), (1, 2, 3))) def test_sympy__geometry__polygon__Polygon(): from sympy.geometry.polygon import Polygon assert _test_args(Polygon((0, 1), (2, 3), (4, 5), (6, 7))) def test_sympy__geometry__polygon__RegularPolygon(): from sympy.geometry.polygon import RegularPolygon assert _test_args(RegularPolygon((0, 1), 2, 3, 4)) def test_sympy__geometry__polygon__Triangle(): from sympy.geometry.polygon import Triangle assert _test_args(Triangle((0, 1), (2, 3), (4, 5))) def test_sympy__geometry__entity__GeometryEntity(): from sympy.geometry.entity import GeometryEntity from sympy.geometry.point import Point assert _test_args(GeometryEntity(Point(1, 0), 1, [1, 2])) @SKIP("abstract class") def test_sympy__geometry__entity__GeometrySet(): pass def test_sympy__diffgeom__diffgeom__Manifold(): from sympy.diffgeom import Manifold assert _test_args(Manifold('name', 3)) def test_sympy__diffgeom__diffgeom__Patch(): from sympy.diffgeom import Manifold, Patch assert _test_args(Patch('name', Manifold('name', 3))) def test_sympy__diffgeom__diffgeom__CoordSystem(): from sympy.diffgeom import Manifold, Patch, CoordSystem assert _test_args(CoordSystem('name', Patch('name', Manifold('name', 3)))) @XFAIL def test_sympy__diffgeom__diffgeom__Point(): from sympy.diffgeom import Manifold, Patch, CoordSystem, Point assert _test_args(Point( CoordSystem('name', Patch('name', Manifold('name', 3))), [x, y])) def test_sympy__diffgeom__diffgeom__BaseScalarField(): from sympy.diffgeom import Manifold, Patch, CoordSystem, BaseScalarField cs = CoordSystem('name', Patch('name', Manifold('name', 3))) assert _test_args(BaseScalarField(cs, 0)) def test_sympy__diffgeom__diffgeom__BaseVectorField(): from sympy.diffgeom import Manifold, Patch, CoordSystem, BaseVectorField cs = CoordSystem('name', Patch('name', Manifold('name', 3))) assert _test_args(BaseVectorField(cs, 0)) def test_sympy__diffgeom__diffgeom__Differential(): from sympy.diffgeom import Manifold, Patch, CoordSystem, BaseScalarField, Differential cs = CoordSystem('name', Patch('name', Manifold('name', 3))) assert _test_args(Differential(BaseScalarField(cs, 0))) def test_sympy__diffgeom__diffgeom__Commutator(): from sympy.diffgeom import Manifold, Patch, CoordSystem, BaseVectorField, Commutator cs = CoordSystem('name', Patch('name', Manifold('name', 3))) cs1 = CoordSystem('name1', Patch('name', Manifold('name', 3))) v = BaseVectorField(cs, 0) v1 = BaseVectorField(cs1, 0) assert _test_args(Commutator(v, v1)) def test_sympy__diffgeom__diffgeom__TensorProduct(): from sympy.diffgeom import Manifold, Patch, CoordSystem, BaseScalarField, Differential, TensorProduct cs = CoordSystem('name', Patch('name', Manifold('name', 3))) d = Differential(BaseScalarField(cs, 0)) assert _test_args(TensorProduct(d, d)) def test_sympy__diffgeom__diffgeom__WedgeProduct(): from sympy.diffgeom import Manifold, Patch, CoordSystem, BaseScalarField, Differential, WedgeProduct cs = CoordSystem('name', Patch('name', Manifold('name', 3))) d = Differential(BaseScalarField(cs, 0)) d1 = Differential(BaseScalarField(cs, 1)) assert _test_args(WedgeProduct(d, d1)) def test_sympy__diffgeom__diffgeom__LieDerivative(): from sympy.diffgeom import Manifold, Patch, CoordSystem, BaseScalarField, Differential, BaseVectorField, LieDerivative cs = CoordSystem('name', Patch('name', Manifold('name', 3))) d = Differential(BaseScalarField(cs, 0)) v = BaseVectorField(cs, 0) assert _test_args(LieDerivative(v, d)) @XFAIL def test_sympy__diffgeom__diffgeom__BaseCovarDerivativeOp(): from sympy.diffgeom import Manifold, Patch, CoordSystem, BaseCovarDerivativeOp cs = CoordSystem('name', Patch('name', Manifold('name', 3))) assert _test_args(BaseCovarDerivativeOp(cs, 0, [[[0, ]*3, ]*3, ]*3)) def test_sympy__diffgeom__diffgeom__CovarDerivativeOp(): from sympy.diffgeom import Manifold, Patch, CoordSystem, BaseVectorField, CovarDerivativeOp cs = CoordSystem('name', Patch('name', Manifold('name', 3))) v = BaseVectorField(cs, 0) _test_args(CovarDerivativeOp(v, [[[0, ]*3, ]*3, ]*3)) def test_sympy__categories__baseclasses__Class(): from sympy.categories.baseclasses import Class assert _test_args(Class()) def test_sympy__categories__baseclasses__Object(): from sympy.categories import Object assert _test_args(Object("A")) @XFAIL def test_sympy__categories__baseclasses__Morphism(): from sympy.categories import Object, Morphism assert _test_args(Morphism(Object("A"), Object("B"))) def test_sympy__categories__baseclasses__IdentityMorphism(): from sympy.categories import Object, IdentityMorphism assert _test_args(IdentityMorphism(Object("A"))) def test_sympy__categories__baseclasses__NamedMorphism(): from sympy.categories import Object, NamedMorphism assert _test_args(NamedMorphism(Object("A"), Object("B"), "f")) def test_sympy__categories__baseclasses__CompositeMorphism(): from sympy.categories import Object, NamedMorphism, CompositeMorphism A = Object("A") B = Object("B") C = Object("C") f = NamedMorphism(A, B, "f") g = NamedMorphism(B, C, "g") assert _test_args(CompositeMorphism(f, g)) def test_sympy__categories__baseclasses__Diagram(): from sympy.categories import Object, NamedMorphism, Diagram A = Object("A") B = Object("B") C = Object("C") f = NamedMorphism(A, B, "f") d = Diagram([f]) assert _test_args(d) def test_sympy__categories__baseclasses__Category(): from sympy.categories import Object, NamedMorphism, Diagram, Category A = Object("A") B = Object("B") C = Object("C") f = NamedMorphism(A, B, "f") g = NamedMorphism(B, C, "g") d1 = Diagram([f, g]) d2 = Diagram([f]) K = Category("K", commutative_diagrams=[d1, d2]) assert _test_args(K) def test_sympy__ntheory__factor___totient(): from sympy.ntheory.factor_ import totient k = symbols('k', integer=True) t = totient(k) assert _test_args(t) def test_sympy__ntheory__factor___reduced_totient(): from sympy.ntheory.factor_ import reduced_totient k = symbols('k', integer=True) t = reduced_totient(k) assert _test_args(t) def test_sympy__ntheory__factor___divisor_sigma(): from sympy.ntheory.factor_ import divisor_sigma k = symbols('k', integer=True) n = symbols('n', integer=True) t = divisor_sigma(n, k) assert _test_args(t) def test_sympy__ntheory__factor___udivisor_sigma(): from sympy.ntheory.factor_ import udivisor_sigma k = symbols('k', integer=True) n = symbols('n', integer=True) t = udivisor_sigma(n, k) assert _test_args(t) def test_sympy__ntheory__factor___primenu(): from sympy.ntheory.factor_ import primenu n = symbols('n', integer=True) t = primenu(n) assert _test_args(t) def test_sympy__ntheory__factor___primeomega(): from sympy.ntheory.factor_ import primeomega n = symbols('n', integer=True) t = primeomega(n) assert _test_args(t) def test_sympy__ntheory__residue_ntheory__mobius(): from sympy.ntheory import mobius assert _test_args(mobius(2)) def test_sympy__ntheory__generate__primepi(): from sympy.ntheory import primepi n = symbols('n') t = primepi(n) assert _test_args(t) def test_sympy__physics__optics__waves__TWave(): from sympy.physics.optics import TWave A, f, phi = symbols('A, f, phi') assert _test_args(TWave(A, f, phi)) def test_sympy__physics__optics__gaussopt__BeamParameter(): from sympy.physics.optics import BeamParameter assert _test_args(BeamParameter(530e-9, 1, w=1e-3)) def test_sympy__physics__optics__medium__Medium(): from sympy.physics.optics import Medium assert _test_args(Medium('m')) def test_sympy__codegen__array_utils__CodegenArrayContraction(): from sympy.codegen.array_utils import CodegenArrayContraction from sympy import IndexedBase A = symbols("A", cls=IndexedBase) assert _test_args(CodegenArrayContraction(A, (0, 1))) def test_sympy__codegen__array_utils__CodegenArrayDiagonal(): from sympy.codegen.array_utils import CodegenArrayDiagonal from sympy import IndexedBase A = symbols("A", cls=IndexedBase) assert _test_args(CodegenArrayDiagonal(A, (0, 1))) def test_sympy__codegen__array_utils__CodegenArrayTensorProduct(): from sympy.codegen.array_utils import CodegenArrayTensorProduct from sympy import IndexedBase A, B = symbols("A B", cls=IndexedBase) assert _test_args(CodegenArrayTensorProduct(A, B)) def test_sympy__codegen__array_utils__CodegenArrayElementwiseAdd(): from sympy.codegen.array_utils import CodegenArrayElementwiseAdd from sympy import IndexedBase A, B = symbols("A B", cls=IndexedBase) assert _test_args(CodegenArrayElementwiseAdd(A, B)) def test_sympy__codegen__array_utils__CodegenArrayPermuteDims(): from sympy.codegen.array_utils import CodegenArrayPermuteDims from sympy import IndexedBase A = symbols("A", cls=IndexedBase) assert _test_args(CodegenArrayPermuteDims(A, (1, 0))) def test_sympy__codegen__ast__Assignment(): from sympy.codegen.ast import Assignment assert _test_args(Assignment(x, y)) def test_sympy__codegen__cfunctions__expm1(): from sympy.codegen.cfunctions import expm1 assert _test_args(expm1(x)) def test_sympy__codegen__cfunctions__log1p(): from sympy.codegen.cfunctions import log1p assert _test_args(log1p(x)) def test_sympy__codegen__cfunctions__exp2(): from sympy.codegen.cfunctions import exp2 assert _test_args(exp2(x)) def test_sympy__codegen__cfunctions__log2(): from sympy.codegen.cfunctions import log2 assert _test_args(log2(x)) def test_sympy__codegen__cfunctions__fma(): from sympy.codegen.cfunctions import fma assert _test_args(fma(x, y, z)) def test_sympy__codegen__cfunctions__log10(): from sympy.codegen.cfunctions import log10 assert _test_args(log10(x)) def test_sympy__codegen__cfunctions__Sqrt(): from sympy.codegen.cfunctions import Sqrt assert _test_args(Sqrt(x)) def test_sympy__codegen__cfunctions__Cbrt(): from sympy.codegen.cfunctions import Cbrt assert _test_args(Cbrt(x)) def test_sympy__codegen__cfunctions__hypot(): from sympy.codegen.cfunctions import hypot assert _test_args(hypot(x, y)) def test_sympy__codegen__fnodes__FFunction(): from sympy.codegen.fnodes import FFunction assert _test_args(FFunction('f')) def test_sympy__codegen__fnodes__F95Function(): from sympy.codegen.fnodes import F95Function assert _test_args(F95Function('f')) def test_sympy__codegen__fnodes__isign(): from sympy.codegen.fnodes import isign assert _test_args(isign(1, x)) def test_sympy__codegen__fnodes__dsign(): from sympy.codegen.fnodes import dsign assert _test_args(dsign(1, x)) def test_sympy__codegen__fnodes__cmplx(): from sympy.codegen.fnodes import cmplx assert _test_args(cmplx(x, y)) def test_sympy__codegen__fnodes__kind(): from sympy.codegen.fnodes import kind assert _test_args(kind(x)) def test_sympy__codegen__fnodes__merge(): from sympy.codegen.fnodes import merge assert _test_args(merge(1, 2, Eq(x, 0))) def test_sympy__codegen__fnodes___literal(): from sympy.codegen.fnodes import _literal assert _test_args(_literal(1)) def test_sympy__codegen__fnodes__literal_sp(): from sympy.codegen.fnodes import literal_sp assert _test_args(literal_sp(1)) def test_sympy__codegen__fnodes__literal_dp(): from sympy.codegen.fnodes import literal_dp assert _test_args(literal_dp(1)) def test_sympy__vector__coordsysrect__CoordSys3D(): from sympy.vector.coordsysrect import CoordSys3D assert _test_args(CoordSys3D('C')) def test_sympy__vector__point__Point(): from sympy.vector.point import Point assert _test_args(Point('P')) def test_sympy__vector__basisdependent__BasisDependent(): from sympy.vector.basisdependent import BasisDependent #These classes have been created to maintain an OOP hierarchy #for Vectors and Dyadics. Are NOT meant to be initialized def test_sympy__vector__basisdependent__BasisDependentMul(): from sympy.vector.basisdependent import BasisDependentMul #These classes have been created to maintain an OOP hierarchy #for Vectors and Dyadics. Are NOT meant to be initialized def test_sympy__vector__basisdependent__BasisDependentAdd(): from sympy.vector.basisdependent import BasisDependentAdd #These classes have been created to maintain an OOP hierarchy #for Vectors and Dyadics. Are NOT meant to be initialized def test_sympy__vector__basisdependent__BasisDependentZero(): from sympy.vector.basisdependent import BasisDependentZero #These classes have been created to maintain an OOP hierarchy #for Vectors and Dyadics. Are NOT meant to be initialized def test_sympy__vector__vector__BaseVector(): from sympy.vector.vector import BaseVector from sympy.vector.coordsysrect import CoordSys3D C = CoordSys3D('C') assert _test_args(BaseVector(0, C, ' ', ' ')) def test_sympy__vector__vector__VectorAdd(): from sympy.vector.vector import VectorAdd, VectorMul from sympy.vector.coordsysrect import CoordSys3D C = CoordSys3D('C') from sympy.abc import a, b, c, x, y, z v1 = a*C.i + b*C.j + c*C.k v2 = x*C.i + y*C.j + z*C.k assert _test_args(VectorAdd(v1, v2)) assert _test_args(VectorMul(x, v1)) def test_sympy__vector__vector__VectorMul(): from sympy.vector.vector import VectorMul from sympy.vector.coordsysrect import CoordSys3D C = CoordSys3D('C') from sympy.abc import a assert _test_args(VectorMul(a, C.i)) def test_sympy__vector__vector__VectorZero(): from sympy.vector.vector import VectorZero assert _test_args(VectorZero()) def test_sympy__vector__vector__Vector(): from sympy.vector.vector import Vector #Vector is never to be initialized using args pass def test_sympy__vector__vector__Cross(): from sympy.vector.vector import Cross from sympy.vector.coordsysrect import CoordSys3D C = CoordSys3D('C') _test_args(Cross(C.i, C.j)) def test_sympy__vector__vector__Dot(): from sympy.vector.vector import Dot from sympy.vector.coordsysrect import CoordSys3D C = CoordSys3D('C') _test_args(Dot(C.i, C.j)) def test_sympy__vector__dyadic__Dyadic(): from sympy.vector.dyadic import Dyadic #Dyadic is never to be initialized using args pass def test_sympy__vector__dyadic__BaseDyadic(): from sympy.vector.dyadic import BaseDyadic from sympy.vector.coordsysrect import CoordSys3D C = CoordSys3D('C') assert _test_args(BaseDyadic(C.i, C.j)) def test_sympy__vector__dyadic__DyadicMul(): from sympy.vector.dyadic import BaseDyadic, DyadicMul from sympy.vector.coordsysrect import CoordSys3D C = CoordSys3D('C') assert _test_args(DyadicMul(3, BaseDyadic(C.i, C.j))) def test_sympy__vector__dyadic__DyadicAdd(): from sympy.vector.dyadic import BaseDyadic, DyadicAdd from sympy.vector.coordsysrect import CoordSys3D C = CoordSys3D('C') assert _test_args(2 * DyadicAdd(BaseDyadic(C.i, C.i), BaseDyadic(C.i, C.j))) def test_sympy__vector__dyadic__DyadicZero(): from sympy.vector.dyadic import DyadicZero assert _test_args(DyadicZero()) def test_sympy__vector__deloperator__Del(): from sympy.vector.deloperator import Del assert _test_args(Del()) def test_sympy__vector__operators__Curl(): from sympy.vector.operators import Curl from sympy.vector.coordsysrect import CoordSys3D C = CoordSys3D('C') assert _test_args(Curl(C.i)) def test_sympy__vector__operators__Laplacian(): from sympy.vector.operators import Laplacian from sympy.vector.coordsysrect import CoordSys3D C = CoordSys3D('C') assert _test_args(Laplacian(C.i)) def test_sympy__vector__operators__Divergence(): from sympy.vector.operators import Divergence from sympy.vector.coordsysrect import CoordSys3D C = CoordSys3D('C') assert _test_args(Divergence(C.i)) def test_sympy__vector__operators__Gradient(): from sympy.vector.operators import Gradient from sympy.vector.coordsysrect import CoordSys3D C = CoordSys3D('C') assert _test_args(Gradient(C.x)) def test_sympy__vector__orienters__Orienter(): from sympy.vector.orienters import Orienter #Not to be initialized def test_sympy__vector__orienters__ThreeAngleOrienter(): from sympy.vector.orienters import ThreeAngleOrienter #Not to be initialized def test_sympy__vector__orienters__AxisOrienter(): from sympy.vector.orienters import AxisOrienter from sympy.vector.coordsysrect import CoordSys3D C = CoordSys3D('C') assert _test_args(AxisOrienter(x, C.i)) def test_sympy__vector__orienters__BodyOrienter(): from sympy.vector.orienters import BodyOrienter assert _test_args(BodyOrienter(x, y, z, '123')) def test_sympy__vector__orienters__SpaceOrienter(): from sympy.vector.orienters import SpaceOrienter assert _test_args(SpaceOrienter(x, y, z, '123')) def test_sympy__vector__orienters__QuaternionOrienter(): from sympy.vector.orienters import QuaternionOrienter a, b, c, d = symbols('a b c d') assert _test_args(QuaternionOrienter(a, b, c, d)) def test_sympy__vector__scalar__BaseScalar(): from sympy.vector.scalar import BaseScalar from sympy.vector.coordsysrect import CoordSys3D C = CoordSys3D('C') assert _test_args(BaseScalar(0, C, ' ', ' ')) def test_sympy__physics__wigner__Wigner3j(): from sympy.physics.wigner import Wigner3j assert _test_args(Wigner3j(0, 0, 0, 0, 0, 0)) def test_sympy__integrals__rubi__symbol__matchpyWC(): from sympy.integrals.rubi.symbol import matchpyWC assert _test_args(matchpyWC(1, True, 'a')) def test_sympy__integrals__rubi__utility_function__rubi_unevaluated_expr(): from sympy.integrals.rubi.utility_function import rubi_unevaluated_expr a = symbols('a') assert _test_args(rubi_unevaluated_expr(a)) def test_sympy__integrals__rubi__utility_function__rubi_exp(): from sympy.integrals.rubi.utility_function import rubi_exp assert _test_args(rubi_exp(5)) def test_sympy__integrals__rubi__utility_function__rubi_log(): from sympy.integrals.rubi.utility_function import rubi_log assert _test_args(rubi_log(5)) def test_sympy__integrals__rubi__utility_function__Int(): from sympy.integrals.rubi.utility_function import Int assert _test_args(Int(5, x)) def test_sympy__integrals__rubi__utility_function__Util_Coefficient(): from sympy.integrals.rubi.utility_function import Util_Coefficient a, x = symbols('a x') assert _test_args(Util_Coefficient(a, x)) def test_sympy__integrals__rubi__utility_function__Gamma(): from sympy.integrals.rubi.utility_function import Gamma assert _test_args(Gamma(5)) def test_sympy__integrals__rubi__utility_function__Util_Part(): from sympy.integrals.rubi.utility_function import Util_Part a, b = symbols('a b') assert _test_args(Util_Part(a + b, 0)) def test_sympy__integrals__rubi__utility_function__PolyGamma(): from sympy.integrals.rubi.utility_function import PolyGamma assert _test_args(PolyGamma(1, 1)) def test_sympy__integrals__rubi__utility_function__ProductLog(): from sympy.integrals.rubi.utility_function import ProductLog assert _test_args(ProductLog(1))
60a2c0ad8fcedca8bb8d4eeb442b26ee4f858d5010068aa3bfad52a9eda6d952
import decimal from sympy import (Rational, Symbol, Float, I, sqrt, cbrt, oo, nan, pi, E, Integer, S, factorial, Catalan, EulerGamma, GoldenRatio, TribonacciConstant, cos, exp, Number, zoo, log, Mul, Pow, Tuple, latex, Gt, Lt, Ge, Le, AlgebraicNumber, simplify, sin, fibonacci, RealField, sympify, srepr) from sympy.core.compatibility import long from sympy.core.power import integer_nthroot, isqrt, integer_log from sympy.core.logic import fuzzy_not from sympy.core.numbers import (igcd, ilcm, igcdex, seterr, igcd2, igcd_lehmer, mpf_norm, comp, mod_inverse) from sympy.core.mod import Mod from sympy.polys.domains.groundtypes import PythonRational from sympy.utilities.decorator import conserve_mpmath_dps from sympy.utilities.iterables import permutations from sympy.utilities.pytest import XFAIL, raises from mpmath import mpf from mpmath.rational import mpq import mpmath t = Symbol('t', real=False) def same_and_same_prec(a, b): # stricter matching for Floats return a == b and a._prec == b._prec def test_seterr(): seterr(divide=True) raises(ValueError, lambda: S.Zero/S.Zero) seterr(divide=False) assert S.Zero / S.Zero == S.NaN def test_mod(): x = Rational(1, 2) y = Rational(3, 4) z = Rational(5, 18043) assert x % x == 0 assert x % y == 1/S(2) assert x % z == 3/S(36086) assert y % x == 1/S(4) assert y % y == 0 assert y % z == 9/S(72172) assert z % x == 5/S(18043) assert z % y == 5/S(18043) assert z % z == 0 a = Float(2.6) assert (a % .2) == 0 assert (a % 2).round(15) == 0.6 assert (a % 0.5).round(15) == 0.1 p = Symbol('p', infinite=True) assert oo % oo == nan assert zoo % oo == nan assert 5 % oo == nan assert p % 5 == nan # In these two tests, if the precision of m does # not match the precision of the ans, then it is # likely that the change made now gives an answer # with degraded accuracy. r = Rational(500, 41) f = Float('.36', 3) m = r % f ans = Float(r % Rational(f), 3) assert m == ans and m._prec == ans._prec f = Float('8.36', 3) m = f % r ans = Float(Rational(f) % r, 3) assert m == ans and m._prec == ans._prec s = S.Zero assert s % float(1) == S.Zero # No rounding required since these numbers can be represented # exactly. assert Rational(3, 4) % Float(1.1) == 0.75 assert Float(1.5) % Rational(5, 4) == 0.25 assert Rational(5, 4).__rmod__(Float('1.5')) == 0.25 assert Float('1.5').__rmod__(Float('2.75')) == Float('1.25') assert 2.75 % Float('1.5') == Float('1.25') a = Integer(7) b = Integer(4) assert type(a % b) == Integer assert a % b == Integer(3) assert Integer(1) % Rational(2, 3) == Rational(1, 3) assert Rational(7, 5) % Integer(1) == Rational(2, 5) assert Integer(2) % 1.5 == 0.5 assert Integer(3).__rmod__(Integer(10)) == Integer(1) assert Integer(10) % 4 == Integer(2) assert 15 % Integer(4) == Integer(3) def test_divmod(): assert divmod(S(12), S(8)) == Tuple(1, 4) assert divmod(-S(12), S(8)) == Tuple(-2, 4) assert divmod(S(0), S(1)) == Tuple(0, 0) raises(ZeroDivisionError, lambda: divmod(S(0), S(0))) raises(ZeroDivisionError, lambda: divmod(S(1), S(0))) assert divmod(S(12), 8) == Tuple(1, 4) assert divmod(12, S(8)) == Tuple(1, 4) assert divmod(S("2"), S("3/2")) == Tuple(S("1"), S("1/2")) assert divmod(S("3/2"), S("2")) == Tuple(S("0"), S("3/2")) assert divmod(S("2"), S("3.5")) == Tuple(S("0"), S("2")) assert divmod(S("3.5"), S("2")) == Tuple(S("1"), S("1.5")) assert divmod(S("2"), S("1/3")) == Tuple(S("6"), S("0")) assert divmod(S("1/3"), S("2")) == Tuple(S("0"), S("1/3")) assert divmod(S("2"), S("0.1")) == Tuple(S("20"), S("0")) assert divmod(S("0.1"), S("2")) == Tuple(S("0"), S("0.1")) assert divmod(S("2"), 2) == Tuple(S("1"), S("0")) assert divmod(2, S("2")) == Tuple(S("1"), S("0")) assert divmod(S("2"), 1.5) == Tuple(S("1"), S("0.5")) assert divmod(1.5, S("2")) == Tuple(S("0"), S("1.5")) assert divmod(0.3, S("2")) == Tuple(S("0"), S("0.3")) assert divmod(S("3/2"), S("3.5")) == Tuple(S("0"), S("3/2")) assert divmod(S("3.5"), S("3/2")) == Tuple(S("2"), S("0.5")) assert divmod(S("3/2"), S("1/3")) == Tuple(S("4"), Float("1/6")) assert divmod(S("1/3"), S("3/2")) == Tuple(S("0"), S("1/3")) assert divmod(S("3/2"), S("0.1")) == Tuple(S("15"), S("0")) assert divmod(S("0.1"), S("3/2")) == Tuple(S("0"), S("0.1")) assert divmod(S("3/2"), 2) == Tuple(S("0"), S("3/2")) assert divmod(2, S("3/2")) == Tuple(S("1"), S("0.5")) assert divmod(S("3/2"), 1.5) == Tuple(S("1"), S("0")) assert divmod(1.5, S("3/2")) == Tuple(S("1"), S("0")) assert divmod(S("3/2"), 0.3) == Tuple(S("5"), S("0")) assert divmod(0.3, S("3/2")) == Tuple(S("0"), S("0.3")) assert divmod(S("1/3"), S("3.5")) == Tuple(S("0"), S("1/3")) assert divmod(S("3.5"), S("0.1")) == Tuple(S("35"), S("0")) assert divmod(S("0.1"), S("3.5")) == Tuple(S("0"), S("0.1")) assert divmod(S("3.5"), 2) == Tuple(S("1"), S("1.5")) assert divmod(2, S("3.5")) == Tuple(S("0"), S("2")) assert divmod(S("3.5"), 1.5) == Tuple(S("2"), S("0.5")) assert divmod(1.5, S("3.5")) == Tuple(S("0"), S("1.5")) assert divmod(0.3, S("3.5")) == Tuple(S("0"), S("0.3")) assert divmod(S("0.1"), S("1/3")) == Tuple(S("0"), S("0.1")) assert divmod(S("1/3"), 2) == Tuple(S("0"), S("1/3")) assert divmod(2, S("1/3")) == Tuple(S("6"), S("0")) assert divmod(S("1/3"), 1.5) == Tuple(S("0"), S("1/3")) assert divmod(0.3, S("1/3")) == Tuple(S("0"), S("0.3")) assert divmod(S("0.1"), 2) == Tuple(S("0"), S("0.1")) assert divmod(2, S("0.1")) == Tuple(S("20"), S("0")) assert divmod(S("0.1"), 1.5) == Tuple(S("0"), S("0.1")) assert divmod(1.5, S("0.1")) == Tuple(S("15"), S("0")) assert divmod(S("0.1"), 0.3) == Tuple(S("0"), S("0.1")) assert str(divmod(S("2"), 0.3)) == '(6, 0.2)' assert str(divmod(S("3.5"), S("1/3"))) == '(10, 0.166666666666667)' assert str(divmod(S("3.5"), 0.3)) == '(11, 0.2)' assert str(divmod(S("1/3"), S("0.1"))) == '(3, 0.0333333333333333)' assert str(divmod(1.5, S("1/3"))) == '(4, 0.166666666666667)' assert str(divmod(S("1/3"), 0.3)) == '(1, 0.0333333333333333)' assert str(divmod(0.3, S("0.1"))) == '(2, 0.1)' assert divmod(-3, S(2)) == (-2, 1) assert divmod(S(-3), S(2)) == (-2, 1) assert divmod(S(-3), 2) == (-2, 1) assert divmod(S(4), S(-3.1)) == Tuple(-2, -2.2) assert divmod(S(4), S(-2.1)) == divmod(4, -2.1) assert divmod(S(-8), S(-2.5) ) == Tuple(3 , -0.5) def test_igcd(): assert igcd(0, 0) == 0 assert igcd(0, 1) == 1 assert igcd(1, 0) == 1 assert igcd(0, 7) == 7 assert igcd(7, 0) == 7 assert igcd(7, 1) == 1 assert igcd(1, 7) == 1 assert igcd(-1, 0) == 1 assert igcd(0, -1) == 1 assert igcd(-1, -1) == 1 assert igcd(-1, 7) == 1 assert igcd(7, -1) == 1 assert igcd(8, 2) == 2 assert igcd(4, 8) == 4 assert igcd(8, 16) == 8 assert igcd(7, -3) == 1 assert igcd(-7, 3) == 1 assert igcd(-7, -3) == 1 assert igcd(*[10, 20, 30]) == 10 raises(TypeError, lambda: igcd()) raises(TypeError, lambda: igcd(2)) raises(ValueError, lambda: igcd(0, None)) raises(ValueError, lambda: igcd(1, 2.2)) for args in permutations((45.1, 1, 30)): raises(ValueError, lambda: igcd(*args)) for args in permutations((1, 2, None)): raises(ValueError, lambda: igcd(*args)) def test_igcd_lehmer(): a, b = fibonacci(10001), fibonacci(10000) # len(str(a)) == 2090 # small divisors, long Euclidean sequence assert igcd_lehmer(a, b) == 1 c = fibonacci(100) assert igcd_lehmer(a*c, b*c) == c # big divisor assert igcd_lehmer(a, 10**1000) == 1 # swapping argmument assert igcd_lehmer(1, 2) == igcd_lehmer(2, 1) def test_igcd2(): # short loop assert igcd2(2**100 - 1, 2**99 - 1) == 1 # Lehmer's algorithm a, b = int(fibonacci(10001)), int(fibonacci(10000)) assert igcd2(a, b) == 1 def test_ilcm(): assert ilcm(0, 0) == 0 assert ilcm(1, 0) == 0 assert ilcm(0, 1) == 0 assert ilcm(1, 1) == 1 assert ilcm(2, 1) == 2 assert ilcm(8, 2) == 8 assert ilcm(8, 6) == 24 assert ilcm(8, 7) == 56 assert ilcm(*[10, 20, 30]) == 60 raises(ValueError, lambda: ilcm(8.1, 7)) raises(ValueError, lambda: ilcm(8, 7.1)) raises(TypeError, lambda: ilcm(8)) def test_igcdex(): assert igcdex(2, 3) == (-1, 1, 1) assert igcdex(10, 12) == (-1, 1, 2) assert igcdex(100, 2004) == (-20, 1, 4) assert igcdex(0, 0) == (0, 1, 0) assert igcdex(1, 0) == (1, 0, 1) def _strictly_equal(a, b): return (a.p, a.q, type(a.p), type(a.q)) == \ (b.p, b.q, type(b.p), type(b.q)) def _test_rational_new(cls): """ Tests that are common between Integer and Rational. """ assert cls(0) is S.Zero assert cls(1) is S.One assert cls(-1) is S.NegativeOne # These look odd, but are similar to int(): assert cls('1') is S.One assert cls(u'-1') is S.NegativeOne i = Integer(10) assert _strictly_equal(i, cls('10')) assert _strictly_equal(i, cls(u'10')) assert _strictly_equal(i, cls(long(10))) assert _strictly_equal(i, cls(i)) raises(TypeError, lambda: cls(Symbol('x'))) def test_Integer_new(): """ Test for Integer constructor """ _test_rational_new(Integer) assert _strictly_equal(Integer(0.9), S.Zero) assert _strictly_equal(Integer(10.5), Integer(10)) raises(ValueError, lambda: Integer("10.5")) assert Integer(Rational('1.' + '9'*20)) == 1 def test_Rational_new(): """" Test for Rational constructor """ _test_rational_new(Rational) n1 = Rational(1, 2) assert n1 == Rational(Integer(1), 2) assert n1 == Rational(Integer(1), Integer(2)) assert n1 == Rational(1, Integer(2)) assert n1 == Rational(Rational(1, 2)) assert 1 == Rational(n1, n1) assert Rational(3, 2) == Rational(Rational(1, 2), Rational(1, 3)) assert Rational(3, 1) == Rational(1, Rational(1, 3)) n3_4 = Rational(3, 4) assert Rational('3/4') == n3_4 assert -Rational('-3/4') == n3_4 assert Rational('.76').limit_denominator(4) == n3_4 assert Rational(19, 25).limit_denominator(4) == n3_4 assert Rational('19/25').limit_denominator(4) == n3_4 assert Rational(1.0, 3) == Rational(1, 3) assert Rational(1, 3.0) == Rational(1, 3) assert Rational(Float(0.5)) == Rational(1, 2) assert Rational('1e2/1e-2') == Rational(10000) assert Rational('1 234') == Rational(1234) assert Rational('1/1 234') == Rational(1, 1234) assert Rational(-1, 0) == S.ComplexInfinity assert Rational(1, 0) == S.ComplexInfinity # Make sure Rational doesn't lose precision on Floats assert Rational(pi.evalf(100)).evalf(100) == pi.evalf(100) raises(TypeError, lambda: Rational('3**3')) raises(TypeError, lambda: Rational('1/2 + 2/3')) # handle fractions.Fraction instances try: import fractions assert Rational(fractions.Fraction(1, 2)) == Rational(1, 2) except ImportError: pass assert Rational(mpq(2, 6)) == Rational(1, 3) assert Rational(PythonRational(2, 6)) == Rational(1, 3) def test_Number_new(): """" Test for Number constructor """ # Expected behavior on numbers and strings assert Number(1) is S.One assert Number(2).__class__ is Integer assert Number(-622).__class__ is Integer assert Number(5, 3).__class__ is Rational assert Number(5.3).__class__ is Float assert Number('1') is S.One assert Number('2').__class__ is Integer assert Number('-622').__class__ is Integer assert Number('5/3').__class__ is Rational assert Number('5.3').__class__ is Float raises(ValueError, lambda: Number('cos')) raises(TypeError, lambda: Number(cos)) a = Rational(3, 5) assert Number(a) is a # Check idempotence on Numbers def test_Number_cmp(): n1 = Number(1) n2 = Number(2) n3 = Number(-3) assert n1 < n2 assert n1 <= n2 assert n3 < n1 assert n2 > n3 assert n2 >= n3 raises(TypeError, lambda: n1 < S.NaN) raises(TypeError, lambda: n1 <= S.NaN) raises(TypeError, lambda: n1 > S.NaN) raises(TypeError, lambda: n1 >= S.NaN) def test_Rational_cmp(): n1 = Rational(1, 4) n2 = Rational(1, 3) n3 = Rational(2, 4) n4 = Rational(2, -4) n5 = Rational(0) n6 = Rational(1) n7 = Rational(3) n8 = Rational(-3) assert n8 < n5 assert n5 < n6 assert n6 < n7 assert n8 < n7 assert n7 > n8 assert (n1 + 1)**n2 < 2 assert ((n1 + n6)/n7) < 1 assert n4 < n3 assert n2 < n3 assert n1 < n2 assert n3 > n1 assert not n3 < n1 assert not (Rational(-1) > 0) assert Rational(-1) < 0 raises(TypeError, lambda: n1 < S.NaN) raises(TypeError, lambda: n1 <= S.NaN) raises(TypeError, lambda: n1 > S.NaN) raises(TypeError, lambda: n1 >= S.NaN) def test_Float(): def eq(a, b): t = Float("1.0E-15") return (-t < a - b < t) a = Float(2) ** Float(3) assert eq(a.evalf(), Float(8)) assert eq((pi ** -1).evalf(), Float("0.31830988618379067")) a = Float(2) ** Float(4) assert eq(a.evalf(), Float(16)) assert (S(.3) == S(.5)) is False x_str = Float((0, '13333333333333', -52, 53)) x2_str = Float((0, '26666666666666', -53, 53)) x_hex = Float((0, long(0x13333333333333), -52, 53)) x_dec = Float((0, 5404319552844595, -52, 53)) assert x_str == x_hex == x_dec == Float(1.2) # This looses a binary digit of precision, so it isn't equal to the above, # but check that it normalizes correctly x2_hex = Float((0, long(0x13333333333333)*2, -53, 53)) assert x2_hex._mpf_ == (0, 5404319552844595, -52, 52) # XXX: Should this test also hold? # assert x2_hex._prec == 52 # x2_str and 1.2 are superficially the same assert str(x2_str) == str(Float(1.2)) # but are different at the mpf level assert Float(1.2)._mpf_ == (0, long(5404319552844595), -52, 53) assert x2_str._mpf_ == (0, long(10808639105689190), -53, 53) assert Float((0, long(0), -123, -1)) == Float('nan') assert Float((0, long(0), -456, -2)) == Float('inf') == Float('+inf') assert Float((1, long(0), -789, -3)) == Float('-inf') raises(ValueError, lambda: Float((0, 7, 1, 3), '')) assert Float('+inf').is_finite is False assert Float('+inf').is_negative is False assert Float('+inf').is_positive is True assert Float('+inf').is_infinite is True assert Float('+inf').is_zero is False assert Float('-inf').is_finite is False assert Float('-inf').is_negative is True assert Float('-inf').is_positive is False assert Float('-inf').is_infinite is True assert Float('-inf').is_zero is False assert Float('0.0').is_finite is True assert Float('0.0').is_negative is False assert Float('0.0').is_positive is False assert Float('0.0').is_infinite is False assert Float('0.0').is_zero is True # rationality properties assert Float(1).is_rational is None assert Float(1).is_irrational is None assert sqrt(2).n(15).is_rational is None assert sqrt(2).n(15).is_irrational is None # do not automatically evalf def teq(a): assert (a.evalf() == a) is False assert (a.evalf() != a) is True assert (a == a.evalf()) is False assert (a != a.evalf()) is True teq(pi) teq(2*pi) teq(cos(0.1, evaluate=False)) # long integer i = 12345678901234567890 assert same_and_same_prec(Float(12, ''), Float('12', '')) assert same_and_same_prec(Float(Integer(i), ''), Float(i, '')) assert same_and_same_prec(Float(i, ''), Float(str(i), 20)) assert same_and_same_prec(Float(str(i)), Float(i, '')) assert same_and_same_prec(Float(i), Float(i, '')) # inexact floats (repeating binary = denom not multiple of 2) # cannot have precision greater than 15 assert Float(.125, 22) == .125 assert Float(2.0, 22) == 2 assert float(Float('.12500000000000001', '')) == .125 raises(ValueError, lambda: Float(.12500000000000001, '')) # allow spaces Float('123 456.123 456') == Float('123456.123456') Integer('123 456') == Integer('123456') Rational('123 456.123 456') == Rational('123456.123456') assert Float(' .3e2') == Float('0.3e2') # allow underscore assert Float('1_23.4_56') == Float('123.456') assert Float('1_23.4_5_6', 12) == Float('123.456', 12) # ...but not in all cases (per Py 3.6) raises(ValueError, lambda: Float('_1')) raises(ValueError, lambda: Float('1_')) raises(ValueError, lambda: Float('1_.')) raises(ValueError, lambda: Float('1._')) raises(ValueError, lambda: Float('1__2')) # allow auto precision detection assert Float('.1', '') == Float(.1, 1) assert Float('.125', '') == Float(.125, 3) assert Float('.100', '') == Float(.1, 3) assert Float('2.0', '') == Float('2', 2) raises(ValueError, lambda: Float("12.3d-4", "")) raises(ValueError, lambda: Float(12.3, "")) raises(ValueError, lambda: Float('.')) raises(ValueError, lambda: Float('-.')) zero = Float('0.0') assert Float('-0') == zero assert Float('.0') == zero assert Float('-.0') == zero assert Float('-0.0') == zero assert Float(0.0) == zero assert Float(0) == zero assert Float(0, '') == Float('0', '') assert Float(1) == Float(1.0) assert Float(S.Zero) == zero assert Float(S.One) == Float(1.0) assert Float(decimal.Decimal('0.1'), 3) == Float('.1', 3) assert Float(decimal.Decimal('nan')) == S.NaN assert Float(decimal.Decimal('Infinity')) == S.Infinity assert Float(decimal.Decimal('-Infinity')) == S.NegativeInfinity assert '{0:.3f}'.format(Float(4.236622)) == '4.237' assert '{0:.35f}'.format(Float(pi.n(40), 40)) == \ '3.14159265358979323846264338327950288' assert Float(oo) == Float('+inf') assert Float(-oo) == Float('-inf') # unicode assert Float(u'0.73908513321516064100000000') == \ Float('0.73908513321516064100000000') assert Float(u'0.73908513321516064100000000', 28) == \ Float('0.73908513321516064100000000', 28) # binary precision # Decimal value 0.1 cannot be expressed precisely as a base 2 fraction a = Float(S(1)/10, dps=15) b = Float(S(1)/10, dps=16) p = Float(S(1)/10, precision=53) q = Float(S(1)/10, precision=54) assert a._mpf_ == p._mpf_ assert not a._mpf_ == q._mpf_ assert not b._mpf_ == q._mpf_ # Precision specifying errors raises(ValueError, lambda: Float("1.23", dps=3, precision=10)) raises(ValueError, lambda: Float("1.23", dps="", precision=10)) raises(ValueError, lambda: Float("1.23", dps=3, precision="")) raises(ValueError, lambda: Float("1.23", dps="", precision="")) # from NumberSymbol assert same_and_same_prec(Float(pi, 32), pi.evalf(32)) assert same_and_same_prec(Float(Catalan), Catalan.evalf()) @conserve_mpmath_dps def test_float_mpf(): import mpmath mpmath.mp.dps = 100 mp_pi = mpmath.pi() assert Float(mp_pi, 100) == Float(mp_pi._mpf_, 100) == pi.evalf(100) mpmath.mp.dps = 15 assert Float(mp_pi, 100) == Float(mp_pi._mpf_, 100) == pi.evalf(100) def test_Float_RealElement(): repi = RealField(dps=100)(pi.evalf(100)) # We still have to pass the precision because Float doesn't know what # RealElement is, but make sure it keeps full precision from the result. assert Float(repi, 100) == pi.evalf(100) def test_Float_default_to_highprec_from_str(): s = str(pi.evalf(128)) assert same_and_same_prec(Float(s), Float(s, '')) def test_Float_eval(): a = Float(3.2) assert (a**2).is_Float def test_Float_issue_2107(): a = Float(0.1, 10) b = Float("0.1", 10) assert a - a == 0 assert a + (-a) == 0 assert S.Zero + a - a == 0 assert S.Zero + a + (-a) == 0 assert b - b == 0 assert b + (-b) == 0 assert S.Zero + b - b == 0 assert S.Zero + b + (-b) == 0 def test_issue_14289(): from sympy.polys.numberfields import to_number_field a = 1 - sqrt(2) b = to_number_field(a) assert b.as_expr() == a assert b.minpoly(a).expand() == 0 def test_Float_from_tuple(): a = Float((0, '1L', 0, 1)) b = Float((0, '1', 0, 1)) assert a == b def test_Infinity(): assert oo != 1 assert 1*oo == oo assert 1 != oo assert oo != -oo assert oo != Symbol("x")**3 assert oo + 1 == oo assert 2 + oo == oo assert 3*oo + 2 == oo assert S.Half**oo == 0 assert S.Half**(-oo) == oo assert -oo*3 == -oo assert oo + oo == oo assert -oo + oo*(-5) == -oo assert 1/oo == 0 assert 1/(-oo) == 0 assert 8/oo == 0 assert oo % 2 == nan assert 2 % oo == nan assert oo/oo == nan assert oo/-oo == nan assert -oo/oo == nan assert -oo/-oo == nan assert oo - oo == nan assert oo - -oo == oo assert -oo - oo == -oo assert -oo - -oo == nan assert oo + -oo == nan assert -oo + oo == nan assert oo + oo == oo assert -oo + oo == nan assert oo + -oo == nan assert -oo + -oo == -oo assert oo*oo == oo assert -oo*oo == -oo assert oo*-oo == -oo assert -oo*-oo == oo assert oo/0 == oo assert -oo/0 == -oo assert 0/oo == 0 assert 0/-oo == 0 assert oo*0 == nan assert -oo*0 == nan assert 0*oo == nan assert 0*-oo == nan assert oo + 0 == oo assert -oo + 0 == -oo assert 0 + oo == oo assert 0 + -oo == -oo assert oo - 0 == oo assert -oo - 0 == -oo assert 0 - oo == -oo assert 0 - -oo == oo assert oo/2 == oo assert -oo/2 == -oo assert oo/-2 == -oo assert -oo/-2 == oo assert oo*2 == oo assert -oo*2 == -oo assert oo*-2 == -oo assert 2/oo == 0 assert 2/-oo == 0 assert -2/oo == 0 assert -2/-oo == 0 assert 2*oo == oo assert 2*-oo == -oo assert -2*oo == -oo assert -2*-oo == oo assert 2 + oo == oo assert 2 - oo == -oo assert -2 + oo == oo assert -2 - oo == -oo assert 2 + -oo == -oo assert 2 - -oo == oo assert -2 + -oo == -oo assert -2 - -oo == oo assert S(2) + oo == oo assert S(2) - oo == -oo assert oo/I == -oo*I assert -oo/I == oo*I assert oo*float(1) == Float('inf') and (oo*float(1)).is_Float assert -oo*float(1) == Float('-inf') and (-oo*float(1)).is_Float assert oo/float(1) == Float('inf') and (oo/float(1)).is_Float assert -oo/float(1) == Float('-inf') and (-oo/float(1)).is_Float assert oo*float(-1) == Float('-inf') and (oo*float(-1)).is_Float assert -oo*float(-1) == Float('inf') and (-oo*float(-1)).is_Float assert oo/float(-1) == Float('-inf') and (oo/float(-1)).is_Float assert -oo/float(-1) == Float('inf') and (-oo/float(-1)).is_Float assert oo + float(1) == Float('inf') and (oo + float(1)).is_Float assert -oo + float(1) == Float('-inf') and (-oo + float(1)).is_Float assert oo - float(1) == Float('inf') and (oo - float(1)).is_Float assert -oo - float(1) == Float('-inf') and (-oo - float(1)).is_Float assert float(1)*oo == Float('inf') and (float(1)*oo).is_Float assert float(1)*-oo == Float('-inf') and (float(1)*-oo).is_Float assert float(1)/oo == 0 assert float(1)/-oo == 0 assert float(-1)*oo == Float('-inf') and (float(-1)*oo).is_Float assert float(-1)*-oo == Float('inf') and (float(-1)*-oo).is_Float assert float(-1)/oo == 0 assert float(-1)/-oo == 0 assert float(1) + oo == Float('inf') assert float(1) + -oo == Float('-inf') assert float(1) - oo == Float('-inf') assert float(1) - -oo == Float('inf') assert Float('nan') == nan assert nan*1.0 == nan assert -1.0*nan == nan assert nan*oo == nan assert nan*-oo == nan assert nan/oo == nan assert nan/-oo == nan assert nan + oo == nan assert nan + -oo == nan assert nan - oo == nan assert nan - -oo == nan assert -oo * S.Zero == nan assert oo*nan == nan assert -oo*nan == nan assert oo/nan == nan assert -oo/nan == nan assert oo + nan == nan assert -oo + nan == nan assert oo - nan == nan assert -oo - nan == nan assert S.Zero * oo == nan assert oo.is_Rational is False assert isinstance(oo, Rational) is False assert S.One/oo == 0 assert -S.One/oo == 0 assert S.One/-oo == 0 assert -S.One/-oo == 0 assert S.One*oo == oo assert -S.One*oo == -oo assert S.One*-oo == -oo assert -S.One*-oo == oo assert S.One/nan == nan assert S.One - -oo == oo assert S.One + nan == nan assert S.One - nan == nan assert nan - S.One == nan assert nan/S.One == nan assert -oo - S.One == -oo def test_Infinity_2(): x = Symbol('x') assert oo*x != oo assert oo*(pi - 1) == oo assert oo*(1 - pi) == -oo assert (-oo)*x != -oo assert (-oo)*(pi - 1) == -oo assert (-oo)*(1 - pi) == oo assert (-1)**S.NaN is S.NaN assert oo - Float('inf') is S.NaN assert oo + Float('-inf') is S.NaN assert oo*0 is S.NaN assert oo/Float('inf') is S.NaN assert oo/Float('-inf') is S.NaN assert oo**S.NaN is S.NaN assert -oo + Float('inf') is S.NaN assert -oo - Float('-inf') is S.NaN assert -oo*S.NaN is S.NaN assert -oo*0 is S.NaN assert -oo/Float('inf') is S.NaN assert -oo/Float('-inf') is S.NaN assert -oo/S.NaN is S.NaN assert abs(-oo) == oo assert all((-oo)**i is S.NaN for i in (oo, -oo, S.NaN)) assert (-oo)**3 == -oo assert (-oo)**2 == oo assert abs(S.ComplexInfinity) == oo def test_Mul_Infinity_Zero(): assert 0*Float('inf') == nan assert 0*Float('-inf') == nan assert 0*Float('inf') == nan assert 0*Float('-inf') == nan assert Float('inf')*0 == nan assert Float('-inf')*0 == nan assert Float('inf')*0 == nan assert Float('-inf')*0 == nan assert Float(0)*Float('inf') == nan assert Float(0)*Float('-inf') == nan assert Float(0)*Float('inf') == nan assert Float(0)*Float('-inf') == nan assert Float('inf')*Float(0) == nan assert Float('-inf')*Float(0) == nan assert Float('inf')*Float(0) == nan assert Float('-inf')*Float(0) == nan def test_Div_By_Zero(): assert 1/S(0) == zoo assert 1/Float(0) == Float('inf') assert 0/S(0) == nan assert 0/Float(0) == nan assert S(0)/0 == nan assert Float(0)/0 == nan assert -1/S(0) == zoo assert -1/Float(0) == Float('-inf') def test_Infinity_inequations(): assert oo > pi assert not (oo < pi) assert exp(-3) < oo assert Float('+inf') > pi assert not (Float('+inf') < pi) assert exp(-3) < Float('+inf') raises(TypeError, lambda: oo < I) raises(TypeError, lambda: oo <= I) raises(TypeError, lambda: oo > I) raises(TypeError, lambda: oo >= I) raises(TypeError, lambda: -oo < I) raises(TypeError, lambda: -oo <= I) raises(TypeError, lambda: -oo > I) raises(TypeError, lambda: -oo >= I) raises(TypeError, lambda: I < oo) raises(TypeError, lambda: I <= oo) raises(TypeError, lambda: I > oo) raises(TypeError, lambda: I >= oo) raises(TypeError, lambda: I < -oo) raises(TypeError, lambda: I <= -oo) raises(TypeError, lambda: I > -oo) raises(TypeError, lambda: I >= -oo) assert oo > -oo and oo >= -oo assert (oo < -oo) == False and (oo <= -oo) == False assert -oo < oo and -oo <= oo assert (-oo > oo) == False and (-oo >= oo) == False assert (oo < oo) == False # issue 7775 assert (oo > oo) == False assert (-oo > -oo) == False and (-oo < -oo) == False assert oo >= oo and oo <= oo and -oo >= -oo and -oo <= -oo assert (-oo < -Float('inf')) == False assert (oo > Float('inf')) == False assert -oo >= -Float('inf') assert oo <= Float('inf') x = Symbol('x') b = Symbol('b', finite=True, real=True) assert (x < oo) == Lt(x, oo) # issue 7775 assert b < oo and b > -oo and b <= oo and b >= -oo assert oo > b and oo >= b and (oo < b) == False and (oo <= b) == False assert (-oo > b) == False and (-oo >= b) == False and -oo < b and -oo <= b assert (oo < x) == Lt(oo, x) and (oo > x) == Gt(oo, x) assert (oo <= x) == Le(oo, x) and (oo >= x) == Ge(oo, x) assert (-oo < x) == Lt(-oo, x) and (-oo > x) == Gt(-oo, x) assert (-oo <= x) == Le(-oo, x) and (-oo >= x) == Ge(-oo, x) def test_NaN(): assert nan == nan assert nan != 1 assert 1*nan == nan assert 1 != nan assert nan == -nan assert oo != Symbol("x")**3 assert nan + 1 == nan assert 2 + nan == nan assert 3*nan + 2 == nan assert -nan*3 == nan assert nan + nan == nan assert -nan + nan*(-5) == nan assert 1/nan == nan assert 1/(-nan) == nan assert 8/nan == nan raises(TypeError, lambda: nan > 0) raises(TypeError, lambda: nan < 0) raises(TypeError, lambda: nan >= 0) raises(TypeError, lambda: nan <= 0) raises(TypeError, lambda: 0 < nan) raises(TypeError, lambda: 0 > nan) raises(TypeError, lambda: 0 <= nan) raises(TypeError, lambda: 0 >= nan) assert S.One + nan == nan assert S.One - nan == nan assert S.One*nan == nan assert S.One/nan == nan assert nan - S.One == nan assert nan*S.One == nan assert nan + S.One == nan assert nan/S.One == nan assert nan**0 == 1 # as per IEEE 754 assert 1**nan == nan # IEEE 754 is not the best choice for symbolic work # test Pow._eval_power's handling of NaN assert Pow(nan, 0, evaluate=False)**2 == 1 def test_special_numbers(): assert isinstance(S.NaN, Number) is True assert isinstance(S.Infinity, Number) is True assert isinstance(S.NegativeInfinity, Number) is True assert S.NaN.is_number is True assert S.Infinity.is_number is True assert S.NegativeInfinity.is_number is True assert S.ComplexInfinity.is_number is True assert isinstance(S.NaN, Rational) is False assert isinstance(S.Infinity, Rational) is False assert isinstance(S.NegativeInfinity, Rational) is False assert S.NaN.is_rational is not True assert S.Infinity.is_rational is not True assert S.NegativeInfinity.is_rational is not True def test_powers(): assert integer_nthroot(1, 2) == (1, True) assert integer_nthroot(1, 5) == (1, True) assert integer_nthroot(2, 1) == (2, True) assert integer_nthroot(2, 2) == (1, False) assert integer_nthroot(2, 5) == (1, False) assert integer_nthroot(4, 2) == (2, True) assert integer_nthroot(123**25, 25) == (123, True) assert integer_nthroot(123**25 + 1, 25) == (123, False) assert integer_nthroot(123**25 - 1, 25) == (122, False) assert integer_nthroot(1, 1) == (1, True) assert integer_nthroot(0, 1) == (0, True) assert integer_nthroot(0, 3) == (0, True) assert integer_nthroot(10000, 1) == (10000, True) assert integer_nthroot(4, 2) == (2, True) assert integer_nthroot(16, 2) == (4, True) assert integer_nthroot(26, 2) == (5, False) assert integer_nthroot(1234567**7, 7) == (1234567, True) assert integer_nthroot(1234567**7 + 1, 7) == (1234567, False) assert integer_nthroot(1234567**7 - 1, 7) == (1234566, False) b = 25**1000 assert integer_nthroot(b, 1000) == (25, True) assert integer_nthroot(b + 1, 1000) == (25, False) assert integer_nthroot(b - 1, 1000) == (24, False) c = 10**400 c2 = c**2 assert integer_nthroot(c2, 2) == (c, True) assert integer_nthroot(c2 + 1, 2) == (c, False) assert integer_nthroot(c2 - 1, 2) == (c - 1, False) assert integer_nthroot(2, 10**10) == (1, False) p, r = integer_nthroot(int(factorial(10000)), 100) assert p % (10**10) == 5322420655 assert not r # Test that this is fast assert integer_nthroot(2, 10**10) == (1, False) # output should be int if possible assert type(integer_nthroot(2**61, 2)[0]) is int def test_integer_nthroot_overflow(): assert integer_nthroot(10**(50*50), 50) == (10**50, True) assert integer_nthroot(10**100000, 10000) == (10**10, True) def test_integer_log(): raises(ValueError, lambda: integer_log(2, 1)) raises(ValueError, lambda: integer_log(0, 2)) raises(ValueError, lambda: integer_log(1.1, 2)) raises(ValueError, lambda: integer_log(1, 2.2)) assert integer_log(1, 2) == (0, True) assert integer_log(1, 3) == (0, True) assert integer_log(2, 3) == (0, False) assert integer_log(3, 3) == (1, True) assert integer_log(3*2, 3) == (1, False) assert integer_log(3**2, 3) == (2, True) assert integer_log(3*4, 3) == (2, False) assert integer_log(3**3, 3) == (3, True) assert integer_log(27, 5) == (2, False) assert integer_log(2, 3) == (0, False) assert integer_log(-4, -2) == (2, False) assert integer_log(27, -3) == (3, False) assert integer_log(-49, 7) == (0, False) assert integer_log(-49, -7) == (2, False) def test_isqrt(): from math import sqrt as _sqrt limit = 17984395633462800708566937239551 assert int(_sqrt(limit)) == integer_nthroot(limit, 2)[0] assert int(_sqrt(limit + 1)) != integer_nthroot(limit + 1, 2)[0] assert isqrt(limit + 1) == integer_nthroot(limit + 1, 2)[0] assert isqrt(limit + 1 + S.Half) == integer_nthroot(limit + 1, 2)[0] def test_powers_Integer(): """Test Integer._eval_power""" # check infinity assert S(1) ** S.Infinity == S.NaN assert S(-1)** S.Infinity == S.NaN assert S(2) ** S.Infinity == S.Infinity assert S(-2)** S.Infinity == S.Infinity + S.Infinity * S.ImaginaryUnit assert S(0) ** S.Infinity == 0 # check Nan assert S(1) ** S.NaN == S.NaN assert S(-1) ** S.NaN == S.NaN # check for exact roots assert S(-1) ** Rational(6, 5) == - (-1)**(S(1)/5) assert sqrt(S(4)) == 2 assert sqrt(S(-4)) == I * 2 assert S(16) ** Rational(1, 4) == 2 assert S(-16) ** Rational(1, 4) == 2 * (-1)**Rational(1, 4) assert S(9) ** Rational(3, 2) == 27 assert S(-9) ** Rational(3, 2) == -27*I assert S(27) ** Rational(2, 3) == 9 assert S(-27) ** Rational(2, 3) == 9 * (S(-1) ** Rational(2, 3)) assert (-2) ** Rational(-2, 1) == Rational(1, 4) # not exact roots assert sqrt(-3) == I*sqrt(3) assert (3) ** (S(3)/2) == 3 * sqrt(3) assert (-3) ** (S(3)/2) == - 3 * sqrt(-3) assert (-3) ** (S(5)/2) == 9 * I * sqrt(3) assert (-3) ** (S(7)/2) == - I * 27 * sqrt(3) assert (2) ** (S(3)/2) == 2 * sqrt(2) assert (2) ** (S(-3)/2) == sqrt(2) / 4 assert (81) ** (S(2)/3) == 9 * (S(3) ** (S(2)/3)) assert (-81) ** (S(2)/3) == 9 * (S(-3) ** (S(2)/3)) assert (-3) ** Rational(-7, 3) == \ -(-1)**Rational(2, 3)*3**Rational(2, 3)/27 assert (-3) ** Rational(-2, 3) == \ -(-1)**Rational(1, 3)*3**Rational(1, 3)/3 # join roots assert sqrt(6) + sqrt(24) == 3*sqrt(6) assert sqrt(2) * sqrt(3) == sqrt(6) # separate symbols & constansts x = Symbol("x") assert sqrt(49 * x) == 7 * sqrt(x) assert sqrt((3 - sqrt(pi)) ** 2) == 3 - sqrt(pi) # check that it is fast for big numbers assert (2**64 + 1) ** Rational(4, 3) assert (2**64 + 1) ** Rational(17, 25) # negative rational power and negative base assert (-3) ** Rational(-7, 3) == \ -(-1)**Rational(2, 3)*3**Rational(2, 3)/27 assert (-3) ** Rational(-2, 3) == \ -(-1)**Rational(1, 3)*3**Rational(1, 3)/3 assert (-2) ** Rational(-10, 3) == \ (-1)**Rational(2, 3)*2**Rational(2, 3)/16 assert abs(Pow(-2, Rational(-10, 3)).n() - Pow(-2, Rational(-10, 3), evaluate=False).n()) < 1e-16 # negative base and rational power with some simplification assert (-8) ** Rational(2, 5) == \ 2*(-1)**Rational(2, 5)*2**Rational(1, 5) assert (-4) ** Rational(9, 5) == \ -8*(-1)**Rational(4, 5)*2**Rational(3, 5) assert S(1234).factors() == {617: 1, 2: 1} assert Rational(2*3, 3*5*7).factors() == {2: 1, 5: -1, 7: -1} # test that eval_power factors numbers bigger than # the current limit in factor_trial_division (2**15) from sympy import nextprime n = nextprime(2**15) assert sqrt(n**2) == n assert sqrt(n**3) == n*sqrt(n) assert sqrt(4*n) == 2*sqrt(n) # check that factors of base with powers sharing gcd with power are removed assert (2**4*3)**Rational(1, 6) == 2**Rational(2, 3)*3**Rational(1, 6) assert (2**4*3)**Rational(5, 6) == 8*2**Rational(1, 3)*3**Rational(5, 6) # check that bases sharing a gcd are exptracted assert 2**Rational(1, 3)*3**Rational(1, 4)*6**Rational(1, 5) == \ 2**Rational(8, 15)*3**Rational(9, 20) assert sqrt(8)*24**Rational(1, 3)*6**Rational(1, 5) == \ 4*2**Rational(7, 10)*3**Rational(8, 15) assert sqrt(8)*(-24)**Rational(1, 3)*(-6)**Rational(1, 5) == \ 4*(-3)**Rational(8, 15)*2**Rational(7, 10) assert 2**Rational(1, 3)*2**Rational(8, 9) == 2*2**Rational(2, 9) assert 2**Rational(2, 3)*6**Rational(1, 3) == 2*3**Rational(1, 3) assert 2**Rational(2, 3)*6**Rational(8, 9) == \ 2*2**Rational(5, 9)*3**Rational(8, 9) assert (-2)**Rational(2, S(3))*(-4)**Rational(1, S(3)) == -2*2**Rational(1, 3) assert 3*Pow(3, 2, evaluate=False) == 3**3 assert 3*Pow(3, -1/S(3), evaluate=False) == 3**(2/S(3)) assert (-2)**(1/S(3))*(-3)**(1/S(4))*(-5)**(5/S(6)) == \ -(-1)**Rational(5, 12)*2**Rational(1, 3)*3**Rational(1, 4) * \ 5**Rational(5, 6) assert Integer(-2)**Symbol('', even=True) == \ Integer(2)**Symbol('', even=True) assert (-1)**Float(.5) == 1.0*I def test_powers_Rational(): """Test Rational._eval_power""" # check infinity assert Rational(1, 2) ** S.Infinity == 0 assert Rational(3, 2) ** S.Infinity == S.Infinity assert Rational(-1, 2) ** S.Infinity == 0 assert Rational(-3, 2) ** S.Infinity == \ S.Infinity + S.Infinity * S.ImaginaryUnit # check Nan assert Rational(3, 4) ** S.NaN == S.NaN assert Rational(-2, 3) ** S.NaN == S.NaN # exact roots on numerator assert sqrt(Rational(4, 3)) == 2 * sqrt(3) / 3 assert Rational(4, 3) ** Rational(3, 2) == 8 * sqrt(3) / 9 assert sqrt(Rational(-4, 3)) == I * 2 * sqrt(3) / 3 assert Rational(-4, 3) ** Rational(3, 2) == - I * 8 * sqrt(3) / 9 assert Rational(27, 2) ** Rational(1, 3) == 3 * (2 ** Rational(2, 3)) / 2 assert Rational(5**3, 8**3) ** Rational(4, 3) == Rational(5**4, 8**4) # exact root on denominator assert sqrt(Rational(1, 4)) == Rational(1, 2) assert sqrt(Rational(1, -4)) == I * Rational(1, 2) assert sqrt(Rational(3, 4)) == sqrt(3) / 2 assert sqrt(Rational(3, -4)) == I * sqrt(3) / 2 assert Rational(5, 27) ** Rational(1, 3) == (5 ** Rational(1, 3)) / 3 # not exact roots assert sqrt(Rational(1, 2)) == sqrt(2) / 2 assert sqrt(Rational(-4, 7)) == I * sqrt(Rational(4, 7)) assert Rational(-3, 2)**Rational(-7, 3) == \ -4*(-1)**Rational(2, 3)*2**Rational(1, 3)*3**Rational(2, 3)/27 assert Rational(-3, 2)**Rational(-2, 3) == \ -(-1)**Rational(1, 3)*2**Rational(2, 3)*3**Rational(1, 3)/3 assert Rational(-3, 2)**Rational(-10, 3) == \ 8*(-1)**Rational(2, 3)*2**Rational(1, 3)*3**Rational(2, 3)/81 assert abs(Pow(Rational(-2, 3), Rational(-7, 4)).n() - Pow(Rational(-2, 3), Rational(-7, 4), evaluate=False).n()) < 1e-16 # negative integer power and negative rational base assert Rational(-2, 3) ** Rational(-2, 1) == Rational(9, 4) a = Rational(1, 10) assert a**Float(a, 2) == Float(a, 2)**Float(a, 2) assert Rational(-2, 3)**Symbol('', even=True) == \ Rational(2, 3)**Symbol('', even=True) def test_powers_Float(): assert str((S('-1/10')**S('3/10')).n()) == str(Float(-.1)**(.3)) def test_abs1(): assert Rational(1, 6) != Rational(-1, 6) assert abs(Rational(1, 6)) == abs(Rational(-1, 6)) def test_accept_int(): assert Float(4) == 4 def test_dont_accept_str(): assert Float("0.2") != "0.2" assert not (Float("0.2") == "0.2") def test_int(): a = Rational(5) assert int(a) == 5 a = Rational(9, 10) assert int(a) == int(-a) == 0 assert 1/(-1)**Rational(2, 3) == -(-1)**Rational(1, 3) assert int(pi) == 3 assert int(E) == 2 assert int(GoldenRatio) == 1 assert int(TribonacciConstant) == 2 # issue 10368 a = S(32442016954)/78058255275 assert type(int(a)) is type(int(-a)) is int def test_long(): a = Rational(5) assert long(a) == 5 a = Rational(9, 10) assert long(a) == long(-a) == 0 a = Integer(2**100) assert long(a) == a assert long(pi) == 3 assert long(E) == 2 assert long(GoldenRatio) == 1 assert long(TribonacciConstant) == 2 def test_real_bug(): x = Symbol("x") assert str(2.0*x*x) in ["(2.0*x)*x", "2.0*x**2", "2.00000000000000*x**2"] assert str(2.1*x*x) != "(2.0*x)*x" def test_bug_sqrt(): assert ((sqrt(Rational(2)) + 1)*(sqrt(Rational(2)) - 1)).expand() == 1 def test_pi_Pi(): "Test that pi (instance) is imported, but Pi (class) is not" from sympy import pi with raises(ImportError): from sympy import Pi def test_no_len(): # there should be no len for numbers raises(TypeError, lambda: len(Rational(2))) raises(TypeError, lambda: len(Rational(2, 3))) raises(TypeError, lambda: len(Integer(2))) def test_issue_3321(): assert sqrt(Rational(1, 5)) == sqrt(Rational(1, 5)) assert 5 * sqrt(Rational(1, 5)) == sqrt(5) def test_issue_3692(): assert ((-1)**Rational(1, 6)).expand(complex=True) == I/2 + sqrt(3)/2 assert ((-5)**Rational(1, 6)).expand(complex=True) == \ 5**Rational(1, 6)*I/2 + 5**Rational(1, 6)*sqrt(3)/2 assert ((-64)**Rational(1, 6)).expand(complex=True) == I + sqrt(3) def test_issue_3423(): x = Symbol("x") assert sqrt(x - 1).as_base_exp() == (x - 1, S.Half) assert sqrt(x - 1) != I*sqrt(1 - x) def test_issue_3449(): x = Symbol("x") assert sqrt(x - 1).subs(x, 5) == 2 def test_issue_13890(): x = Symbol("x") e = (-x/4 - S(1)/12)**x - 1 f = simplify(e) a = S(9)/5 assert abs(e.subs(x,a).evalf() - f.subs(x,a).evalf()) < 1e-15 def test_Integer_factors(): def F(i): return Integer(i).factors() assert F(1) == {} assert F(2) == {2: 1} assert F(3) == {3: 1} assert F(4) == {2: 2} assert F(5) == {5: 1} assert F(6) == {2: 1, 3: 1} assert F(7) == {7: 1} assert F(8) == {2: 3} assert F(9) == {3: 2} assert F(10) == {2: 1, 5: 1} assert F(11) == {11: 1} assert F(12) == {2: 2, 3: 1} assert F(13) == {13: 1} assert F(14) == {2: 1, 7: 1} assert F(15) == {3: 1, 5: 1} assert F(16) == {2: 4} assert F(17) == {17: 1} assert F(18) == {2: 1, 3: 2} assert F(19) == {19: 1} assert F(20) == {2: 2, 5: 1} assert F(21) == {3: 1, 7: 1} assert F(22) == {2: 1, 11: 1} assert F(23) == {23: 1} assert F(24) == {2: 3, 3: 1} assert F(25) == {5: 2} assert F(26) == {2: 1, 13: 1} assert F(27) == {3: 3} assert F(28) == {2: 2, 7: 1} assert F(29) == {29: 1} assert F(30) == {2: 1, 3: 1, 5: 1} assert F(31) == {31: 1} assert F(32) == {2: 5} assert F(33) == {3: 1, 11: 1} assert F(34) == {2: 1, 17: 1} assert F(35) == {5: 1, 7: 1} assert F(36) == {2: 2, 3: 2} assert F(37) == {37: 1} assert F(38) == {2: 1, 19: 1} assert F(39) == {3: 1, 13: 1} assert F(40) == {2: 3, 5: 1} assert F(41) == {41: 1} assert F(42) == {2: 1, 3: 1, 7: 1} assert F(43) == {43: 1} assert F(44) == {2: 2, 11: 1} assert F(45) == {3: 2, 5: 1} assert F(46) == {2: 1, 23: 1} assert F(47) == {47: 1} assert F(48) == {2: 4, 3: 1} assert F(49) == {7: 2} assert F(50) == {2: 1, 5: 2} assert F(51) == {3: 1, 17: 1} def test_Rational_factors(): def F(p, q, visual=None): return Rational(p, q).factors(visual=visual) assert F(2, 3) == {2: 1, 3: -1} assert F(2, 9) == {2: 1, 3: -2} assert F(2, 15) == {2: 1, 3: -1, 5: -1} assert F(6, 10) == {3: 1, 5: -1} def test_issue_4107(): assert pi*(E + 10) + pi*(-E - 10) != 0 assert pi*(E + 10**10) + pi*(-E - 10**10) != 0 assert pi*(E + 10**20) + pi*(-E - 10**20) != 0 assert pi*(E + 10**80) + pi*(-E - 10**80) != 0 assert (pi*(E + 10) + pi*(-E - 10)).expand() == 0 assert (pi*(E + 10**10) + pi*(-E - 10**10)).expand() == 0 assert (pi*(E + 10**20) + pi*(-E - 10**20)).expand() == 0 assert (pi*(E + 10**80) + pi*(-E - 10**80)).expand() == 0 def test_IntegerInteger(): a = Integer(4) b = Integer(a) assert a == b def test_Rational_gcd_lcm_cofactors(): assert Integer(4).gcd(2) == Integer(2) assert Integer(4).lcm(2) == Integer(4) assert Integer(4).gcd(Integer(2)) == Integer(2) assert Integer(4).lcm(Integer(2)) == Integer(4) a, b = 720**99911, 480**12342 assert Integer(a).lcm(b) == a*b/Integer(a).gcd(b) assert Integer(4).gcd(3) == Integer(1) assert Integer(4).lcm(3) == Integer(12) assert Integer(4).gcd(Integer(3)) == Integer(1) assert Integer(4).lcm(Integer(3)) == Integer(12) assert Rational(4, 3).gcd(2) == Rational(2, 3) assert Rational(4, 3).lcm(2) == Integer(4) assert Rational(4, 3).gcd(Integer(2)) == Rational(2, 3) assert Rational(4, 3).lcm(Integer(2)) == Integer(4) assert Integer(4).gcd(Rational(2, 9)) == Rational(2, 9) assert Integer(4).lcm(Rational(2, 9)) == Integer(4) assert Rational(4, 3).gcd(Rational(2, 9)) == Rational(2, 9) assert Rational(4, 3).lcm(Rational(2, 9)) == Rational(4, 3) assert Rational(4, 5).gcd(Rational(2, 9)) == Rational(2, 45) assert Rational(4, 5).lcm(Rational(2, 9)) == Integer(4) assert Rational(5, 9).lcm(Rational(3, 7)) == Rational(Integer(5).lcm(3),Integer(9).gcd(7)) assert Integer(4).cofactors(2) == (Integer(2), Integer(2), Integer(1)) assert Integer(4).cofactors(Integer(2)) == \ (Integer(2), Integer(2), Integer(1)) assert Integer(4).gcd(Float(2.0)) == S.One assert Integer(4).lcm(Float(2.0)) == Float(8.0) assert Integer(4).cofactors(Float(2.0)) == (S.One, Integer(4), Float(2.0)) assert Rational(1, 2).gcd(Float(2.0)) == S.One assert Rational(1, 2).lcm(Float(2.0)) == Float(1.0) assert Rational(1, 2).cofactors(Float(2.0)) == \ (S.One, Rational(1, 2), Float(2.0)) def test_Float_gcd_lcm_cofactors(): assert Float(2.0).gcd(Integer(4)) == S.One assert Float(2.0).lcm(Integer(4)) == Float(8.0) assert Float(2.0).cofactors(Integer(4)) == (S.One, Float(2.0), Integer(4)) assert Float(2.0).gcd(Rational(1, 2)) == S.One assert Float(2.0).lcm(Rational(1, 2)) == Float(1.0) assert Float(2.0).cofactors(Rational(1, 2)) == \ (S.One, Float(2.0), Rational(1, 2)) def test_issue_4611(): assert abs(pi._evalf(50) - 3.14159265358979) < 1e-10 assert abs(E._evalf(50) - 2.71828182845905) < 1e-10 assert abs(Catalan._evalf(50) - 0.915965594177219) < 1e-10 assert abs(EulerGamma._evalf(50) - 0.577215664901533) < 1e-10 assert abs(GoldenRatio._evalf(50) - 1.61803398874989) < 1e-10 assert abs(TribonacciConstant._evalf(50) - 1.83928675521416) < 1e-10 x = Symbol("x") assert (pi + x).evalf() == pi.evalf() + x assert (E + x).evalf() == E.evalf() + x assert (Catalan + x).evalf() == Catalan.evalf() + x assert (EulerGamma + x).evalf() == EulerGamma.evalf() + x assert (GoldenRatio + x).evalf() == GoldenRatio.evalf() + x assert (TribonacciConstant + x).evalf() == TribonacciConstant.evalf() + x @conserve_mpmath_dps def test_conversion_to_mpmath(): assert mpmath.mpmathify(Integer(1)) == mpmath.mpf(1) assert mpmath.mpmathify(Rational(1, 2)) == mpmath.mpf(0.5) assert mpmath.mpmathify(Float('1.23', 15)) == mpmath.mpf('1.23') assert mpmath.mpmathify(I) == mpmath.mpc(1j) assert mpmath.mpmathify(1 + 2*I) == mpmath.mpc(1 + 2j) assert mpmath.mpmathify(1.0 + 2*I) == mpmath.mpc(1 + 2j) assert mpmath.mpmathify(1 + 2.0*I) == mpmath.mpc(1 + 2j) assert mpmath.mpmathify(1.0 + 2.0*I) == mpmath.mpc(1 + 2j) assert mpmath.mpmathify(Rational(1, 2) + Rational(1, 2)*I) == mpmath.mpc(0.5 + 0.5j) assert mpmath.mpmathify(2*I) == mpmath.mpc(2j) assert mpmath.mpmathify(2.0*I) == mpmath.mpc(2j) assert mpmath.mpmathify(Rational(1, 2)*I) == mpmath.mpc(0.5j) mpmath.mp.dps = 100 assert mpmath.mpmathify(pi.evalf(100) + pi.evalf(100)*I) == mpmath.pi + mpmath.pi*mpmath.j assert mpmath.mpmathify(pi.evalf(100)*I) == mpmath.pi*mpmath.j def test_relational(): # real x = S(.1) assert (x != cos) is True assert (x == cos) is False # rational x = Rational(1, 3) assert (x != cos) is True assert (x == cos) is False # integer defers to rational so these tests are omitted # number symbol x = pi assert (x != cos) is True assert (x == cos) is False def test_Integer_as_index(): assert 'hello'[Integer(2):] == 'llo' def test_Rational_int(): assert int( Rational(7, 5)) == 1 assert int( Rational(1, 2)) == 0 assert int(-Rational(1, 2)) == 0 assert int(-Rational(7, 5)) == -1 def test_zoo(): b = Symbol('b', finite=True) nz = Symbol('nz', nonzero=True) p = Symbol('p', positive=True) n = Symbol('n', negative=True) im = Symbol('i', imaginary=True) c = Symbol('c', complex=True) pb = Symbol('pb', positive=True, finite=True) nb = Symbol('nb', negative=True, finite=True) imb = Symbol('ib', imaginary=True, finite=True) for i in [I, S.Infinity, S.NegativeInfinity, S.Zero, S.One, S.Pi, S.Half, S(3), log(3), b, nz, p, n, im, pb, nb, imb, c]: if i.is_finite and (i.is_real or i.is_imaginary): assert i + zoo is zoo assert i - zoo is zoo assert zoo + i is zoo assert zoo - i is zoo elif i.is_finite is not False: assert (i + zoo).is_Add assert (i - zoo).is_Add assert (zoo + i).is_Add assert (zoo - i).is_Add else: assert (i + zoo) is S.NaN assert (i - zoo) is S.NaN assert (zoo + i) is S.NaN assert (zoo - i) is S.NaN if fuzzy_not(i.is_zero) and (i.is_real or i.is_imaginary): assert i*zoo is zoo assert zoo*i is zoo elif i.is_zero: assert i*zoo is S.NaN assert zoo*i is S.NaN else: assert (i*zoo).is_Mul assert (zoo*i).is_Mul if fuzzy_not((1/i).is_zero) and (i.is_real or i.is_imaginary): assert zoo/i is zoo elif (1/i).is_zero: assert zoo/i is S.NaN elif i.is_zero: assert zoo/i is zoo else: assert (zoo/i).is_Mul assert (I*oo).is_Mul # allow directed infinity assert zoo + zoo is S.NaN assert zoo * zoo is zoo assert zoo - zoo is S.NaN assert zoo/zoo is S.NaN assert zoo**zoo is S.NaN assert zoo**0 is S.One assert zoo**2 is zoo assert 1/zoo is S.Zero assert Mul.flatten([S(-1), oo, S(0)]) == ([S.NaN], [], None) def test_issue_4122(): x = Symbol('x', nonpositive=True) assert (oo + x).is_Add x = Symbol('x', finite=True) assert (oo + x).is_Add # x could be imaginary x = Symbol('x', nonnegative=True) assert oo + x == oo x = Symbol('x', finite=True, real=True) assert oo + x == oo # similarly for negative infinity x = Symbol('x', nonnegative=True) assert (-oo + x).is_Add x = Symbol('x', finite=True) assert (-oo + x).is_Add x = Symbol('x', nonpositive=True) assert -oo + x == -oo x = Symbol('x', finite=True, real=True) assert -oo + x == -oo def test_GoldenRatio_expand(): assert GoldenRatio.expand(func=True) == S.Half + sqrt(5)/2 def test_TribonacciConstant_expand(): assert TribonacciConstant.expand(func=True) == \ (1 + cbrt(19 - 3*sqrt(33)) + cbrt(19 + 3*sqrt(33))) / 3 def test_as_content_primitive(): assert S.Zero.as_content_primitive() == (1, 0) assert S.Half.as_content_primitive() == (S.Half, 1) assert (-S.Half).as_content_primitive() == (S.Half, -1) assert S(3).as_content_primitive() == (3, 1) assert S(3.1).as_content_primitive() == (1, 3.1) def test_hashing_sympy_integers(): # Test for issue 5072 assert set([Integer(3)]) == set([int(3)]) assert hash(Integer(4)) == hash(int(4)) def test_issue_4172(): assert int((E**100).round()) == \ 26881171418161354484126255515800135873611119 assert int((pi**100).round()) == \ 51878483143196131920862615246303013562686760680406 assert int((Rational(1)/EulerGamma**100).round()) == \ 734833795660954410469466 @XFAIL def test_mpmath_issues(): from mpmath.libmp.libmpf import _normalize import mpmath.libmp as mlib rnd = mlib.round_nearest mpf = (0, long(0), -123, -1, 53, rnd) # nan assert _normalize(mpf, 53) != (0, long(0), 0, 0) mpf = (0, long(0), -456, -2, 53, rnd) # +inf assert _normalize(mpf, 53) != (0, long(0), 0, 0) mpf = (1, long(0), -789, -3, 53, rnd) # -inf assert _normalize(mpf, 53) != (0, long(0), 0, 0) from mpmath.libmp.libmpf import fnan assert mlib.mpf_eq(fnan, fnan) def test_Catalan_EulerGamma_prec(): n = GoldenRatio f = Float(n.n(), 5) assert f._mpf_ == (0, long(212079), -17, 18) assert f._prec == 20 assert n._as_mpf_val(20) == f._mpf_ n = EulerGamma f = Float(n.n(), 5) assert f._mpf_ == (0, long(302627), -19, 19) assert f._prec == 20 assert n._as_mpf_val(20) == f._mpf_ def test_Float_eq(): assert Float(.12, 3) != Float(.12, 4) assert Float(.12, 3) == .12 assert 0.12 == Float(.12, 3) assert Float('.12', 22) != .12 def test_int_NumberSymbols(): assert [int(i) for i in [pi, EulerGamma, E, GoldenRatio, Catalan]] == \ [3, 0, 2, 1, 0] def test_issue_6640(): from mpmath.libmp.libmpf import finf, fninf # fnan is not included because Float no longer returns fnan, # but otherwise, the same sort of test could apply assert Float(finf).is_zero is False assert Float(fninf).is_zero is False assert bool(Float(0)) is False def test_issue_6349(): assert Float('23.e3', '')._prec == 10 assert Float('23e3', '')._prec == 20 assert Float('23000', '')._prec == 20 assert Float('-23000', '')._prec == 20 def test_mpf_norm(): assert mpf_norm((1, 0, 1, 0), 10) == mpf('0')._mpf_ assert Float._new((1, 0, 1, 0), 10)._mpf_ == mpf('0')._mpf_ def test_latex(): assert latex(pi) == r"\pi" assert latex(E) == r"e" assert latex(GoldenRatio) == r"\phi" assert latex(TribonacciConstant) == r"\text{TribonacciConstant}" assert latex(EulerGamma) == r"\gamma" assert latex(oo) == r"\infty" assert latex(-oo) == r"-\infty" assert latex(zoo) == r"\tilde{\infty}" assert latex(nan) == r"\text{NaN}" assert latex(I) == r"i" def test_issue_7742(): assert -oo % 1 == nan def test_simplify_AlgebraicNumber(): A = AlgebraicNumber e = 3**(S(1)/6)*(3 + (135 + 78*sqrt(3))**(S(2)/3))/(45 + 26*sqrt(3))**(S(1)/3) assert simplify(A(e)) == A(12) # wester test_C20 e = (41 + 29*sqrt(2))**(S(1)/5) assert simplify(A(e)) == A(1 + sqrt(2)) # wester test_C21 e = (3 + 4*I)**(Rational(3, 2)) assert simplify(A(e)) == A(2 + 11*I) # issue 4401 def test_Float_idempotence(): x = Float('1.23', '') y = Float(x) z = Float(x, 15) assert same_and_same_prec(y, x) assert not same_and_same_prec(z, x) x = Float(10**20) y = Float(x) z = Float(x, 15) assert same_and_same_prec(y, x) assert not same_and_same_prec(z, x) def test_comp(): # sqrt(2) = 1.414213 5623730950... a = sqrt(2).n(7) assert comp(a, 1.41421346) is False assert comp(a, 1.41421347) assert comp(a, 1.41421366) assert comp(a, 1.41421367) is False assert comp(sqrt(2).n(2), '1.4') assert comp(sqrt(2).n(2), Float(1.4, 2), '') raises(ValueError, lambda: comp(sqrt(2).n(2), 1.4, '')) assert comp(sqrt(2).n(2), Float(1.4, 3), '') is False def test_issue_9491(): assert oo**zoo == nan def test_issue_10063(): assert 2**Float(3) == Float(8) def test_issue_10020(): assert oo**I is S.NaN assert oo**(1 + I) is S.ComplexInfinity assert oo**(-1 + I) is S.Zero assert (-oo)**I is S.NaN assert (-oo)**(-1 + I) is S.Zero assert oo**t == Pow(oo, t, evaluate=False) assert (-oo)**t == Pow(-oo, t, evaluate=False) def test_invert_numbers(): assert S(2).invert(5) == 3 assert S(2).invert(S(5)/2) == S.Half assert S(2).invert(5.) == 0.5 assert S(2).invert(S(5)) == 3 assert S(2.).invert(5) == 0.5 assert S(sqrt(2)).invert(5) == 1/sqrt(2) assert S(sqrt(2)).invert(sqrt(3)) == 1/sqrt(2) def test_mod_inverse(): assert mod_inverse(3, 11) == 4 assert mod_inverse(5, 11) == 9 assert mod_inverse(21124921, 521512) == 7713 assert mod_inverse(124215421, 5125) == 2981 assert mod_inverse(214, 12515) == 1579 assert mod_inverse(5823991, 3299) == 1442 assert mod_inverse(123, 44) == 39 assert mod_inverse(2, 5) == 3 assert mod_inverse(-2, 5) == 2 assert mod_inverse(2, -5) == -2 assert mod_inverse(-2, -5) == -3 assert mod_inverse(-3, -7) == -5 x = Symbol('x') assert S(2).invert(x) == S.Half raises(TypeError, lambda: mod_inverse(2, x)) raises(ValueError, lambda: mod_inverse(2, S.Half)) raises(ValueError, lambda: mod_inverse(2, cos(1)**2 + sin(1)**2)) def test_golden_ratio_rewrite_as_sqrt(): assert GoldenRatio.rewrite(sqrt) == S.Half + sqrt(5)*S.Half def test_tribonacci_constant_rewrite_as_sqrt(): assert TribonacciConstant.rewrite(sqrt) == \ (1 + cbrt(19 - 3*sqrt(33)) + cbrt(19 + 3*sqrt(33))) / 3 def test_comparisons_with_unknown_type(): class Foo(object): """ Class that is unaware of Basic, and relies on both classes returning the NotImplemented singleton for equivalence to evaluate to False. """ ni, nf, nr = Integer(3), Float(1.0), Rational(1, 3) foo = Foo() for n in ni, nf, nr, oo, -oo, zoo, nan: assert n != foo assert foo != n assert not n == foo assert not foo == n raises(TypeError, lambda: n < foo) raises(TypeError, lambda: foo > n) raises(TypeError, lambda: n > foo) raises(TypeError, lambda: foo < n) raises(TypeError, lambda: n <= foo) raises(TypeError, lambda: foo >= n) raises(TypeError, lambda: n >= foo) raises(TypeError, lambda: foo <= n) class Bar(object): """ Class that considers itself equal to any instance of Number except infinities and nans, and relies on sympy types returning the NotImplemented singleton for symmetric equality relations. """ def __eq__(self, other): if other in (oo, -oo, zoo, nan): return False if isinstance(other, Number): return True return NotImplemented def __ne__(self, other): return not self == other bar = Bar() for n in ni, nf, nr: assert n == bar assert bar == n assert not n != bar assert not bar != n for n in oo, -oo, zoo, nan: assert n != bar assert bar != n assert not n == bar assert not bar == n for n in ni, nf, nr, oo, -oo, zoo, nan: raises(TypeError, lambda: n < bar) raises(TypeError, lambda: bar > n) raises(TypeError, lambda: n > bar) raises(TypeError, lambda: bar < n) raises(TypeError, lambda: n <= bar) raises(TypeError, lambda: bar >= n) raises(TypeError, lambda: n >= bar) raises(TypeError, lambda: bar <= n) def test_NumberSymbol_comparison(): rpi = Rational('905502432259640373/288230376151711744') fpi = Float(float(pi)) assert (rpi == pi) == (pi == rpi) assert (rpi != pi) == (pi != rpi) assert (rpi < pi) == (pi > rpi) assert (rpi <= pi) == (pi >= rpi) assert (rpi > pi) == (pi < rpi) assert (rpi >= pi) == (pi <= rpi) assert (fpi == pi) == (pi == fpi) assert (fpi != pi) == (pi != fpi) assert (fpi < pi) == (pi > fpi) assert (fpi <= pi) == (pi >= fpi) assert (fpi > pi) == (pi < fpi) assert (fpi >= pi) == (pi <= fpi) def test_Integer_precision(): # Make sure Integer inputs for keyword args work assert Float('1.0', dps=Integer(15))._prec == 53 assert Float('1.0', precision=Integer(15))._prec == 15 assert type(Float('1.0', precision=Integer(15))._prec) == int assert sympify(srepr(Float('1.0', precision=15))) == Float('1.0', precision=15) def test_numpy_to_float(): from sympy.utilities.pytest import skip from sympy.external import import_module np = import_module('numpy') if not np: skip('numpy not installed. Abort numpy tests.') def check_prec_and_relerr(npval, ratval): prec = np.finfo(npval).nmant + 1 x = Float(npval) assert x._prec == prec y = Float(ratval, precision=prec) assert abs((x - y)/y) < 2**(-(prec + 1)) check_prec_and_relerr(np.float16(2.0/3), S(2)/3) check_prec_and_relerr(np.float32(2.0/3), S(2)/3) check_prec_and_relerr(np.float64(2.0/3), S(2)/3) # extended precision, on some arch/compilers: x = np.longdouble(2)/3 check_prec_and_relerr(x, S(2)/3) y = Float(x, precision=10) assert same_and_same_prec(y, Float(S(2)/3, precision=10)) raises(TypeError, lambda: Float(np.complex64(1+2j))) raises(TypeError, lambda: Float(np.complex128(1+2j))) def test_Integer_ceiling_floor(): a = Integer(4) assert(a.floor() == a) assert(a.ceiling() == a) def test_ComplexInfinity(): assert((zoo).floor() == zoo) assert((zoo).ceiling() == zoo) assert(zoo**zoo == S.NaN) def test_Infinity_floor_ceiling_power(): assert((oo).floor() == oo) assert((oo).ceiling() == oo) assert((oo)**S.NaN == S.NaN) assert((oo)**zoo == S.NaN) def test_One_power(): assert((S.One)**12 == S.One) assert((S.NegativeOne)**S.NaN == S.NaN) def test_NegativeInfinity(): assert((-oo).floor() == -oo) assert((-oo).ceiling() == -oo) assert((-oo)**11 == -oo) assert((-oo)**12 == oo) def test_issue_6133(): raises(TypeError, lambda: (-oo < None)) raises(TypeError, lambda: (S(-2) < None)) raises(TypeError, lambda: (oo < None)) raises(TypeError, lambda: (oo > None)) raises(TypeError, lambda: (S(2) < None))
5ba5e0553501189ccfd7bfd4e535246fcc58993080d65e929050b6d5ab66abc4
from sympy.utilities.pytest import XFAIL, raises, warns_deprecated_sympy from sympy import (S, Symbol, symbols, nan, oo, I, pi, Float, And, Or, Not, Implies, Xor, zoo, sqrt, Rational, simplify, Function, log, cos, sin, Add, floor, ceiling) from sympy.core.compatibility import range from sympy.core.relational import (Relational, Equality, Unequality, GreaterThan, LessThan, StrictGreaterThan, StrictLessThan, Rel, Eq, Lt, Le, Gt, Ge, Ne) from sympy.sets.sets import Interval, FiniteSet from itertools import combinations x, y, z, t = symbols('x,y,z,t') def test_rel_ne(): assert Relational(x, y, '!=') == Ne(x, y) # issue 6116 p = Symbol('p', positive=True) assert Ne(p, 0) is S.true def test_rel_subs(): e = Relational(x, y, '==') e = e.subs(x, z) assert isinstance(e, Equality) assert e.lhs == z assert e.rhs == y e = Relational(x, y, '>=') e = e.subs(x, z) assert isinstance(e, GreaterThan) assert e.lhs == z assert e.rhs == y e = Relational(x, y, '<=') e = e.subs(x, z) assert isinstance(e, LessThan) assert e.lhs == z assert e.rhs == y e = Relational(x, y, '>') e = e.subs(x, z) assert isinstance(e, StrictGreaterThan) assert e.lhs == z assert e.rhs == y e = Relational(x, y, '<') e = e.subs(x, z) assert isinstance(e, StrictLessThan) assert e.lhs == z assert e.rhs == y e = Eq(x, 0) assert e.subs(x, 0) is S.true assert e.subs(x, 1) is S.false def test_wrappers(): e = x + x**2 res = Relational(y, e, '==') assert Rel(y, x + x**2, '==') == res assert Eq(y, x + x**2) == res res = Relational(y, e, '<') assert Lt(y, x + x**2) == res res = Relational(y, e, '<=') assert Le(y, x + x**2) == res res = Relational(y, e, '>') assert Gt(y, x + x**2) == res res = Relational(y, e, '>=') assert Ge(y, x + x**2) == res res = Relational(y, e, '!=') assert Ne(y, x + x**2) == res def test_Eq(): assert Eq(x, x) # issue 5719 with warns_deprecated_sympy(): assert Eq(x) == Eq(x, 0) # issue 6116 p = Symbol('p', positive=True) assert Eq(p, 0) is S.false # issue 13348 assert Eq(True, 1) is S.false def test_rel_Infinity(): # NOTE: All of these are actually handled by sympy.core.Number, and do # not create Relational objects. assert (oo > oo) is S.false assert (oo > -oo) is S.true assert (oo > 1) is S.true assert (oo < oo) is S.false assert (oo < -oo) is S.false assert (oo < 1) is S.false assert (oo >= oo) is S.true assert (oo >= -oo) is S.true assert (oo >= 1) is S.true assert (oo <= oo) is S.true assert (oo <= -oo) is S.false assert (oo <= 1) is S.false assert (-oo > oo) is S.false assert (-oo > -oo) is S.false assert (-oo > 1) is S.false assert (-oo < oo) is S.true assert (-oo < -oo) is S.false assert (-oo < 1) is S.true assert (-oo >= oo) is S.false assert (-oo >= -oo) is S.true assert (-oo >= 1) is S.false assert (-oo <= oo) is S.true assert (-oo <= -oo) is S.true assert (-oo <= 1) is S.true def test_bool(): assert Eq(0, 0) is S.true assert Eq(1, 0) is S.false assert Ne(0, 0) is S.false assert Ne(1, 0) is S.true assert Lt(0, 1) is S.true assert Lt(1, 0) is S.false assert Le(0, 1) is S.true assert Le(1, 0) is S.false assert Le(0, 0) is S.true assert Gt(1, 0) is S.true assert Gt(0, 1) is S.false assert Ge(1, 0) is S.true assert Ge(0, 1) is S.false assert Ge(1, 1) is S.true assert Eq(I, 2) is S.false assert Ne(I, 2) is S.true raises(TypeError, lambda: Gt(I, 2)) raises(TypeError, lambda: Ge(I, 2)) raises(TypeError, lambda: Lt(I, 2)) raises(TypeError, lambda: Le(I, 2)) a = Float('.000000000000000000001', '') b = Float('.0000000000000000000001', '') assert Eq(pi + a, pi + b) is S.false def test_rich_cmp(): assert (x < y) == Lt(x, y) assert (x <= y) == Le(x, y) assert (x > y) == Gt(x, y) assert (x >= y) == Ge(x, y) def test_doit(): from sympy import Symbol p = Symbol('p', positive=True) n = Symbol('n', negative=True) np = Symbol('np', nonpositive=True) nn = Symbol('nn', nonnegative=True) assert Gt(p, 0).doit() is S.true assert Gt(p, 1).doit() == Gt(p, 1) assert Ge(p, 0).doit() is S.true assert Le(p, 0).doit() is S.false assert Lt(n, 0).doit() is S.true assert Le(np, 0).doit() is S.true assert Gt(nn, 0).doit() == Gt(nn, 0) assert Lt(nn, 0).doit() is S.false assert Eq(x, 0).doit() == Eq(x, 0) def test_new_relational(): x = Symbol('x') assert Eq(x, 0) == Relational(x, 0) # None ==> Equality assert Eq(x, 0) == Relational(x, 0, '==') assert Eq(x, 0) == Relational(x, 0, 'eq') assert Eq(x, 0) == Equality(x, 0) assert Eq(x, 0) != Relational(x, 1) # None ==> Equality assert Eq(x, 0) != Relational(x, 1, '==') assert Eq(x, 0) != Relational(x, 1, 'eq') assert Eq(x, 0) != Equality(x, 1) assert Eq(x, -1) == Relational(x, -1) # None ==> Equality assert Eq(x, -1) == Relational(x, -1, '==') assert Eq(x, -1) == Relational(x, -1, 'eq') assert Eq(x, -1) == Equality(x, -1) assert Eq(x, -1) != Relational(x, 1) # None ==> Equality assert Eq(x, -1) != Relational(x, 1, '==') assert Eq(x, -1) != Relational(x, 1, 'eq') assert Eq(x, -1) != Equality(x, 1) assert Ne(x, 0) == Relational(x, 0, '!=') assert Ne(x, 0) == Relational(x, 0, '<>') assert Ne(x, 0) == Relational(x, 0, 'ne') assert Ne(x, 0) == Unequality(x, 0) assert Ne(x, 0) != Relational(x, 1, '!=') assert Ne(x, 0) != Relational(x, 1, '<>') assert Ne(x, 0) != Relational(x, 1, 'ne') assert Ne(x, 0) != Unequality(x, 1) assert Ge(x, 0) == Relational(x, 0, '>=') assert Ge(x, 0) == Relational(x, 0, 'ge') assert Ge(x, 0) == GreaterThan(x, 0) assert Ge(x, 1) != Relational(x, 0, '>=') assert Ge(x, 1) != Relational(x, 0, 'ge') assert Ge(x, 1) != GreaterThan(x, 0) assert (x >= 1) == Relational(x, 1, '>=') assert (x >= 1) == Relational(x, 1, 'ge') assert (x >= 1) == GreaterThan(x, 1) assert (x >= 0) != Relational(x, 1, '>=') assert (x >= 0) != Relational(x, 1, 'ge') assert (x >= 0) != GreaterThan(x, 1) assert Le(x, 0) == Relational(x, 0, '<=') assert Le(x, 0) == Relational(x, 0, 'le') assert Le(x, 0) == LessThan(x, 0) assert Le(x, 1) != Relational(x, 0, '<=') assert Le(x, 1) != Relational(x, 0, 'le') assert Le(x, 1) != LessThan(x, 0) assert (x <= 1) == Relational(x, 1, '<=') assert (x <= 1) == Relational(x, 1, 'le') assert (x <= 1) == LessThan(x, 1) assert (x <= 0) != Relational(x, 1, '<=') assert (x <= 0) != Relational(x, 1, 'le') assert (x <= 0) != LessThan(x, 1) assert Gt(x, 0) == Relational(x, 0, '>') assert Gt(x, 0) == Relational(x, 0, 'gt') assert Gt(x, 0) == StrictGreaterThan(x, 0) assert Gt(x, 1) != Relational(x, 0, '>') assert Gt(x, 1) != Relational(x, 0, 'gt') assert Gt(x, 1) != StrictGreaterThan(x, 0) assert (x > 1) == Relational(x, 1, '>') assert (x > 1) == Relational(x, 1, 'gt') assert (x > 1) == StrictGreaterThan(x, 1) assert (x > 0) != Relational(x, 1, '>') assert (x > 0) != Relational(x, 1, 'gt') assert (x > 0) != StrictGreaterThan(x, 1) assert Lt(x, 0) == Relational(x, 0, '<') assert Lt(x, 0) == Relational(x, 0, 'lt') assert Lt(x, 0) == StrictLessThan(x, 0) assert Lt(x, 1) != Relational(x, 0, '<') assert Lt(x, 1) != Relational(x, 0, 'lt') assert Lt(x, 1) != StrictLessThan(x, 0) assert (x < 1) == Relational(x, 1, '<') assert (x < 1) == Relational(x, 1, 'lt') assert (x < 1) == StrictLessThan(x, 1) assert (x < 0) != Relational(x, 1, '<') assert (x < 0) != Relational(x, 1, 'lt') assert (x < 0) != StrictLessThan(x, 1) # finally, some fuzz testing from random import randint from sympy.core.compatibility import unichr for i in range(100): while 1: strtype, length = (unichr, 65535) if randint(0, 1) else (chr, 255) relation_type = strtype(randint(0, length)) if randint(0, 1): relation_type += strtype(randint(0, length)) if relation_type not in ('==', 'eq', '!=', '<>', 'ne', '>=', 'ge', '<=', 'le', '>', 'gt', '<', 'lt', ':=', '+=', '-=', '*=', '/=', '%='): break raises(ValueError, lambda: Relational(x, 1, relation_type)) assert all(Relational(x, 0, op).rel_op == '==' for op in ('eq', '==')) assert all(Relational(x, 0, op).rel_op == '!=' for op in ('ne', '<>', '!=')) assert all(Relational(x, 0, op).rel_op == '>' for op in ('gt', '>')) assert all(Relational(x, 0, op).rel_op == '<' for op in ('lt', '<')) assert all(Relational(x, 0, op).rel_op == '>=' for op in ('ge', '>=')) assert all(Relational(x, 0, op).rel_op == '<=' for op in ('le', '<=')) def test_relational_bool_output(): # https://github.com/sympy/sympy/issues/5931 raises(TypeError, lambda: bool(x > 3)) raises(TypeError, lambda: bool(x >= 3)) raises(TypeError, lambda: bool(x < 3)) raises(TypeError, lambda: bool(x <= 3)) raises(TypeError, lambda: bool(Eq(x, 3))) raises(TypeError, lambda: bool(Ne(x, 3))) def test_relational_logic_symbols(): # See issue 6204 assert (x < y) & (z < t) == And(x < y, z < t) assert (x < y) | (z < t) == Or(x < y, z < t) assert ~(x < y) == Not(x < y) assert (x < y) >> (z < t) == Implies(x < y, z < t) assert (x < y) << (z < t) == Implies(z < t, x < y) assert (x < y) ^ (z < t) == Xor(x < y, z < t) assert isinstance((x < y) & (z < t), And) assert isinstance((x < y) | (z < t), Or) assert isinstance(~(x < y), GreaterThan) assert isinstance((x < y) >> (z < t), Implies) assert isinstance((x < y) << (z < t), Implies) assert isinstance((x < y) ^ (z < t), (Or, Xor)) def test_univariate_relational_as_set(): assert (x > 0).as_set() == Interval(0, oo, True, True) assert (x >= 0).as_set() == Interval(0, oo) assert (x < 0).as_set() == Interval(-oo, 0, True, True) assert (x <= 0).as_set() == Interval(-oo, 0) assert Eq(x, 0).as_set() == FiniteSet(0) assert Ne(x, 0).as_set() == Interval(-oo, 0, True, True) + \ Interval(0, oo, True, True) assert (x**2 >= 4).as_set() == Interval(-oo, -2) + Interval(2, oo) @XFAIL def test_multivariate_relational_as_set(): assert (x*y >= 0).as_set() == Interval(0, oo)*Interval(0, oo) + \ Interval(-oo, 0)*Interval(-oo, 0) def test_Not(): assert Not(Equality(x, y)) == Unequality(x, y) assert Not(Unequality(x, y)) == Equality(x, y) assert Not(StrictGreaterThan(x, y)) == LessThan(x, y) assert Not(StrictLessThan(x, y)) == GreaterThan(x, y) assert Not(GreaterThan(x, y)) == StrictLessThan(x, y) assert Not(LessThan(x, y)) == StrictGreaterThan(x, y) def test_evaluate(): assert str(Eq(x, x, evaluate=False)) == 'Eq(x, x)' assert Eq(x, x, evaluate=False).doit() == S.true assert str(Ne(x, x, evaluate=False)) == 'Ne(x, x)' assert Ne(x, x, evaluate=False).doit() == S.false assert str(Ge(x, x, evaluate=False)) == 'x >= x' assert str(Le(x, x, evaluate=False)) == 'x <= x' assert str(Gt(x, x, evaluate=False)) == 'x > x' assert str(Lt(x, x, evaluate=False)) == 'x < x' def assert_all_ineq_raise_TypeError(a, b): raises(TypeError, lambda: a > b) raises(TypeError, lambda: a >= b) raises(TypeError, lambda: a < b) raises(TypeError, lambda: a <= b) raises(TypeError, lambda: b > a) raises(TypeError, lambda: b >= a) raises(TypeError, lambda: b < a) raises(TypeError, lambda: b <= a) def assert_all_ineq_give_class_Inequality(a, b): """All inequality operations on `a` and `b` result in class Inequality.""" from sympy.core.relational import _Inequality as Inequality assert isinstance(a > b, Inequality) assert isinstance(a >= b, Inequality) assert isinstance(a < b, Inequality) assert isinstance(a <= b, Inequality) assert isinstance(b > a, Inequality) assert isinstance(b >= a, Inequality) assert isinstance(b < a, Inequality) assert isinstance(b <= a, Inequality) def test_imaginary_compare_raises_TypeError(): # See issue #5724 assert_all_ineq_raise_TypeError(I, x) def test_complex_compare_not_real(): # two cases which are not real y = Symbol('y', imaginary=True) z = Symbol('z', complex=True, real=False) for w in (y, z): assert_all_ineq_raise_TypeError(2, w) # some cases which should remain un-evaluated t = Symbol('t') x = Symbol('x', real=True) z = Symbol('z', complex=True) for w in (x, z, t): assert_all_ineq_give_class_Inequality(2, w) def test_imaginary_and_inf_compare_raises_TypeError(): # See pull request #7835 y = Symbol('y', imaginary=True) assert_all_ineq_raise_TypeError(oo, y) assert_all_ineq_raise_TypeError(-oo, y) def test_complex_pure_imag_not_ordered(): raises(TypeError, lambda: 2*I < 3*I) # more generally x = Symbol('x', real=True, nonzero=True) y = Symbol('y', imaginary=True) z = Symbol('z', complex=True) assert_all_ineq_raise_TypeError(I, y) t = I*x # an imaginary number, should raise errors assert_all_ineq_raise_TypeError(2, t) t = -I*y # a real number, so no errors assert_all_ineq_give_class_Inequality(2, t) t = I*z # unknown, should be unevaluated assert_all_ineq_give_class_Inequality(2, t) def test_x_minus_y_not_same_as_x_lt_y(): """ A consequence of pull request #7792 is that `x - y < 0` and `x < y` are not synonymous. """ x = I + 2 y = I + 3 raises(TypeError, lambda: x < y) assert x - y < 0 ineq = Lt(x, y, evaluate=False) raises(TypeError, lambda: ineq.doit()) assert ineq.lhs - ineq.rhs < 0 t = Symbol('t', imaginary=True) x = 2 + t y = 3 + t ineq = Lt(x, y, evaluate=False) raises(TypeError, lambda: ineq.doit()) assert ineq.lhs - ineq.rhs < 0 # this one should give error either way x = I + 2 y = 2*I + 3 raises(TypeError, lambda: x < y) raises(TypeError, lambda: x - y < 0) def test_nan_equality_exceptions(): # See issue #7774 import random assert Equality(nan, nan) is S.false assert Unequality(nan, nan) is S.true # See issue #7773 A = (x, S(0), S(1)/3, pi, oo, -oo) assert Equality(nan, random.choice(A)) is S.false assert Equality(random.choice(A), nan) is S.false assert Unequality(nan, random.choice(A)) is S.true assert Unequality(random.choice(A), nan) is S.true def test_nan_inequality_raise_errors(): # See discussion in pull request #7776. We test inequalities with # a set including examples of various classes. for q in (x, S(0), S(10), S(1)/3, pi, S(1.3), oo, -oo, nan): assert_all_ineq_raise_TypeError(q, nan) def test_nan_complex_inequalities(): # Comparisons of NaN with non-real raise errors, we're not too # fussy whether its the NaN error or complex error. for r in (I, zoo, Symbol('z', imaginary=True)): assert_all_ineq_raise_TypeError(r, nan) def test_complex_infinity_inequalities(): raises(TypeError, lambda: zoo > 0) raises(TypeError, lambda: zoo >= 0) raises(TypeError, lambda: zoo < 0) raises(TypeError, lambda: zoo <= 0) def test_inequalities_symbol_name_same(): """Using the operator and functional forms should give same results.""" # We test all combinations from a set # FIXME: could replace with random selection after test passes A = (x, y, S(0), S(1)/3, pi, oo, -oo) for a in A: for b in A: assert Gt(a, b) == (a > b) assert Lt(a, b) == (a < b) assert Ge(a, b) == (a >= b) assert Le(a, b) == (a <= b) for b in (y, S(0), S(1)/3, pi, oo, -oo): assert Gt(x, b, evaluate=False) == (x > b) assert Lt(x, b, evaluate=False) == (x < b) assert Ge(x, b, evaluate=False) == (x >= b) assert Le(x, b, evaluate=False) == (x <= b) for b in (y, S(0), S(1)/3, pi, oo, -oo): assert Gt(b, x, evaluate=False) == (b > x) assert Lt(b, x, evaluate=False) == (b < x) assert Ge(b, x, evaluate=False) == (b >= x) assert Le(b, x, evaluate=False) == (b <= x) def test_inequalities_symbol_name_same_complex(): """Using the operator and functional forms should give same results. With complex non-real numbers, both should raise errors. """ # FIXME: could replace with random selection after test passes for a in (x, S(0), S(1)/3, pi, oo): raises(TypeError, lambda: Gt(a, I)) raises(TypeError, lambda: a > I) raises(TypeError, lambda: Lt(a, I)) raises(TypeError, lambda: a < I) raises(TypeError, lambda: Ge(a, I)) raises(TypeError, lambda: a >= I) raises(TypeError, lambda: Le(a, I)) raises(TypeError, lambda: a <= I) def test_inequalities_cant_sympify_other(): # see issue 7833 from operator import gt, lt, ge, le bar = "foo" for a in (x, S(0), S(1)/3, pi, I, zoo, oo, -oo, nan): for op in (lt, gt, le, ge): raises(TypeError, lambda: op(a, bar)) def test_ineq_avoid_wild_symbol_flip(): # see issue #7951, we try to avoid this internally, e.g., by using # __lt__ instead of "<". from sympy.core.symbol import Wild p = symbols('p', cls=Wild) # x > p might flip, but Gt should not: assert Gt(x, p) == Gt(x, p, evaluate=False) # Previously failed as 'p > x': e = Lt(x, y).subs({y: p}) assert e == Lt(x, p, evaluate=False) # Previously failed as 'p <= x': e = Ge(x, p).doit() assert e == Ge(x, p, evaluate=False) def test_issue_8245(): a = S("6506833320952669167898688709329/5070602400912917605986812821504") q = a.n(10) assert (a == q) is True assert (a != q) is False assert (a > q) == False assert (a < q) == False assert (a >= q) == True assert (a <= q) == True a = sqrt(2) r = Rational(str(a.n(30))) assert (r == a) is False assert (r != a) is True assert (r > a) == True assert (r < a) == False assert (r >= a) == True assert (r <= a) == False a = sqrt(2) r = Rational(str(a.n(29))) assert (r == a) is False assert (r != a) is True assert (r > a) == False assert (r < a) == True assert (r >= a) == False assert (r <= a) == True assert Eq(log(cos(2)**2 + sin(2)**2), 0) == True def test_issue_8449(): p = Symbol('p', nonnegative=True) assert Lt(-oo, p) assert Ge(-oo, p) is S.false assert Gt(oo, -p) assert Le(oo, -p) is S.false def test_simplify_relational(): assert simplify(x*(y + 1) - x*y - x + 1 < x) == (x > 1) r = S(1) < x # canonical operations are not the same as simplification, # so if there is no simplification, canonicalization will # be done unless the measure forbids it assert simplify(r) == r.canonical assert simplify(r, ratio=0) != r.canonical # this is not a random test; in _eval_simplify # this will simplify to S.false and that is the # reason for the 'if r.is_Relational' in Relational's # _eval_simplify routine assert simplify(-(2**(3*pi/2) + 6**pi)**(1/pi) + 2*(2**(pi/2) + 3**pi)**(1/pi) < 0) is S.false # canonical at least for f in (Eq, Ne): f(y, x).simplify() == f(x, y) f(x - 1, 0).simplify() == f(x, 1) f(x - 1, x).simplify() == S.false f(2*x - 1, x).simplify() == f(x, 1) f(2*x, 4).simplify() == f(x, 2) z = cos(1)**2 + sin(1)**2 - 1 # z.is_zero is None f(z*x, 0).simplify() == f(z*x, 0) def test_equals(): w, x, y, z = symbols('w:z') f = Function('f') assert Eq(x, 1).equals(Eq(x*(y + 1) - x*y - x + 1, x)) assert Eq(x, y).equals(x < y, True) == False assert Eq(x, f(1)).equals(Eq(x, f(2)), True) == f(1) - f(2) assert Eq(f(1), y).equals(Eq(f(2), y), True) == f(1) - f(2) assert Eq(x, f(1)).equals(Eq(f(2), x), True) == f(1) - f(2) assert Eq(f(1), x).equals(Eq(x, f(2)), True) == f(1) - f(2) assert Eq(w, x).equals(Eq(y, z), True) == False assert Eq(f(1), f(2)).equals(Eq(f(3), f(4)), True) == f(1) - f(3) assert (x < y).equals(y > x, True) == True assert (x < y).equals(y >= x, True) == False assert (x < y).equals(z < y, True) == False assert (x < y).equals(x < z, True) == False assert (x < f(1)).equals(x < f(2), True) == f(1) - f(2) assert (f(1) < x).equals(f(2) < x, True) == f(1) - f(2) def test_reversed(): assert (x < y).reversed == (y > x) assert (x <= y).reversed == (y >= x) assert Eq(x, y, evaluate=False).reversed == Eq(y, x, evaluate=False) assert Ne(x, y, evaluate=False).reversed == Ne(y, x, evaluate=False) assert (x >= y).reversed == (y <= x) assert (x > y).reversed == (y < x) def test_canonical(): c = [i.canonical for i in ( x + y < z, x + 2 > 3, x < 2, S(2) > x, x**2 > -x/y, Gt(3, 2, evaluate=False) )] assert [i.canonical for i in c] == c assert [i.reversed.canonical for i in c] == c assert not any(i.lhs.is_Number and not i.rhs.is_Number for i in c) c = [i.reversed.func(i.rhs, i.lhs, evaluate=False).canonical for i in c] assert [i.canonical for i in c] == c assert [i.reversed.canonical for i in c] == c assert not any(i.lhs.is_Number and not i.rhs.is_Number for i in c) @XFAIL def test_issue_8444_nonworkingtests(): x = symbols('x', real=True) assert (x <= oo) == (x >= -oo) == True x = symbols('x') assert x >= floor(x) assert (x < floor(x)) == False assert x <= ceiling(x) assert (x > ceiling(x)) == False def test_issue_8444_workingtests(): x = symbols('x') assert Gt(x, floor(x)) == Gt(x, floor(x), evaluate=False) assert Ge(x, floor(x)) == Ge(x, floor(x), evaluate=False) assert Lt(x, ceiling(x)) == Lt(x, ceiling(x), evaluate=False) assert Le(x, ceiling(x)) == Le(x, ceiling(x), evaluate=False) i = symbols('i', integer=True) assert (i > floor(i)) == False assert (i < ceiling(i)) == False def test_issue_10304(): d = cos(1)**2 + sin(1)**2 - 1 assert d.is_comparable is False # if this fails, find a new d e = 1 + d*I assert simplify(Eq(e, 0)) is S.false def test_issue_10401(): x = symbols('x') fin = symbols('inf', finite=True) inf = symbols('inf', infinite=True) inf2 = symbols('inf2', infinite=True) zero = symbols('z', zero=True) nonzero = symbols('nz', zero=False, finite=True) assert Eq(1/(1/x + 1), 1).func is Eq assert Eq(1/(1/x + 1), 1).subs(x, S.ComplexInfinity) is S.true assert Eq(1/(1/fin + 1), 1) is S.false T, F = S.true, S.false assert Eq(fin, inf) is F assert Eq(inf, inf2) is T and inf != inf2 assert Eq(inf/inf2, 0) is F assert Eq(inf/fin, 0) is F assert Eq(fin/inf, 0) is T assert Eq(zero/nonzero, 0) is T and ((zero/nonzero) != 0) assert Eq(inf, -inf) is F assert Eq(fin/(fin + 1), 1) is S.false o = symbols('o', odd=True) assert Eq(o, 2*o) is S.false p = symbols('p', positive=True) assert Eq(p/(p - 1), 1) is F def test_issue_10633(): assert Eq(True, False) == False assert Eq(False, True) == False assert Eq(True, True) == True assert Eq(False, False) == True def test_issue_10927(): x = symbols('x') assert str(Eq(x, oo)) == 'Eq(x, oo)' assert str(Eq(x, -oo)) == 'Eq(x, -oo)' def test_issues_13081_12583_12534(): # 13081 r = Rational('905502432259640373/288230376151711744') assert (r < pi) is S.false assert (r > pi) is S.true # 12583 v = sqrt(2) u = sqrt(v) + 2/sqrt(10 - 8/sqrt(2 - v) + 4*v*(1/sqrt(2 - v) - 1)) assert (u >= 0) is S.true # 12534; Rational vs NumberSymbol # here are some precisions for which Rational forms # at a lower and higher precision bracket the value of pi # e.g. for p = 20: # Rational(pi.n(p + 1)).n(25) = 3.14159265358979323846 2834 # pi.n(25) = 3.14159265358979323846 2643 # Rational(pi.n(p )).n(25) = 3.14159265358979323846 1987 assert [p for p in range(20, 50) if (Rational(pi.n(p)) < pi) and (pi < Rational(pi.n(p + 1)))] == [20, 24, 27, 33, 37, 43, 48] # pick one such precision and affirm that the reversed operation # gives the opposite result, i.e. if x < y is true then x > y # must be false p = 20 # Rational vs NumberSymbol G = [Rational(pi.n(i)) > pi for i in (p, p + 1)] L = [Rational(pi.n(i)) < pi for i in (p, p + 1)] assert G == [False, True] assert all(i is not j for i, j in zip(L, G)) # Float vs NumberSymbol G = [pi.n(i) > pi for i in (p, p + 1)] L = [pi.n(i) < pi for i in (p, p + 1)] assert G == [False, True] assert all(i is not j for i, j in zip(L, G)) # Float vs Float G = [pi.n(p) > pi.n(p + 1)] L = [pi.n(p) < pi.n(p + 1)] assert G == [True] assert all(i is not j for i, j in zip(L, G)) # Float vs Rational # the rational form is less than the floating representation # at the same precision assert [i for i in range(15, 50) if Rational(pi.n(i)) > pi.n(i)] == [] # this should be the same if we reverse the relational assert [i for i in range(15, 50) if pi.n(i) < Rational(pi.n(i))] == [] def test_binary_symbols(): ans = set([x]) for f in Eq, Ne: for t in S.true, S.false: eq = f(x, S.true) assert eq.binary_symbols == ans assert eq.reversed.binary_symbols == ans assert f(x, 1).binary_symbols == set() def test_rel_args(): # can't have Boolean args; this is automatic with Python 3 # so this test and the __lt__, etc..., definitions in # relational.py and boolalg.py which are marked with /// # can be removed. for op in ['<', '<=', '>', '>=']: for b in (S.true, x < 1, And(x, y)): for v in (0.1, 1, 2**32, t, S(1)): raises(TypeError, lambda: Relational(b, v, op)) def test_Equality_rewrite_as_Add(): eq = Eq(x + y, y - x) assert eq.rewrite(Add) == 2*x assert eq.rewrite(Add, evaluate=None).args == (x, x, y, -y) assert eq.rewrite(Add, evaluate=False).args == (x, y, x, -y) def test_issue_15847(): a = Ne(x*(x+y), x**2 + x*y) assert simplify(a) == False def test_negated_property(): eq = Eq(x, y) assert eq.negated == Ne(x, y) eq = Ne(x, y) assert eq.negated == Eq(x, y) eq = Ge(x + y, y - x) assert eq.negated == Lt(x + y, y - x) for f in (Eq, Ne, Ge, Gt, Le, Lt): assert f(x, y).negated.negated == f(x, y) def test_reversedsign_property(): eq = Eq(x, y) assert eq.reversedsign == Eq(-x, -y) eq = Ne(x, y) assert eq.reversedsign == Ne(-x, -y) eq = Ge(x + y, y - x) assert eq.reversedsign == Le(-x - y, x - y) for f in (Eq, Ne, Ge, Gt, Le, Lt): assert f(x, y).reversedsign.reversedsign == f(x, y) for f in (Eq, Ne, Ge, Gt, Le, Lt): assert f(-x, y).reversedsign.reversedsign == f(-x, y) for f in (Eq, Ne, Ge, Gt, Le, Lt): assert f(x, -y).reversedsign.reversedsign == f(x, -y) for f in (Eq, Ne, Ge, Gt, Le, Lt): assert f(-x, -y).reversedsign.reversedsign == f(-x, -y) def test_reversed_reversedsign_property(): for f in (Eq, Ne, Ge, Gt, Le, Lt): assert f(x, y).reversed.reversedsign == f(x, y).reversedsign.reversed for f in (Eq, Ne, Ge, Gt, Le, Lt): assert f(-x, y).reversed.reversedsign == f(-x, y).reversedsign.reversed for f in (Eq, Ne, Ge, Gt, Le, Lt): assert f(x, -y).reversed.reversedsign == f(x, -y).reversedsign.reversed for f in (Eq, Ne, Ge, Gt, Le, Lt): assert f(-x, -y).reversed.reversedsign == \ f(-x, -y).reversedsign.reversed def test_improved_canonical(): def test_different_forms(listofforms): for form1, form2 in combinations(listofforms, 2): assert form1.canonical == form2.canonical def generate_forms(expr): return [expr, expr.reversed, expr.reversedsign, expr.reversed.reversedsign] test_different_forms(generate_forms(x > -y)) test_different_forms(generate_forms(x >= -y)) test_different_forms(generate_forms(Eq(x, -y))) test_different_forms(generate_forms(Ne(x, -y))) test_different_forms(generate_forms(pi < x)) test_different_forms(generate_forms(pi - 5*y < -x + 2*y**2 - 7)) assert (pi >= x).canonical == (x <= pi)
e3fa52f52e96676032c4b089ed1a0f5f8d033ae0d3b5948c67a615b9a00a2645
"""Tests for tools and arithmetics for monomials of distributed polynomials. """ from sympy.polys.monomials import ( itermonomials, monomial_count, monomial_mul, monomial_div, monomial_gcd, monomial_lcm, monomial_max, monomial_min, monomial_divides, monomial_pow, Monomial, ) from sympy.polys.polyerrors import ExactQuotientFailed from sympy.abc import a, b, c, x, y, z from sympy.core import S, symbols from sympy.utilities.pytest import raises def test_monomials(): assert itermonomials([], -1) == set() assert itermonomials([], 0) == {S(1)} assert itermonomials([], 1) == {S(1)} assert itermonomials([], 2) == {S(1)} assert itermonomials([], 3) == {S(1)} assert itermonomials([x], -1) == set() assert itermonomials([x], 0) == {S(1)} assert itermonomials([x], 1) == {S(1), x} assert itermonomials([x], 2) == {S(1), x, x**2} assert itermonomials([x], 3) == {S(1), x, x**2, x**3} assert itermonomials([x, y], 0) == {S(1)} assert itermonomials([x, y], 1) == {S(1), x, y} assert itermonomials([x, y], 2) == {S(1), x, y, x**2, y**2, x*y} assert itermonomials([x, y], 3) == \ {S(1), x, y, x**2, x**3, y**2, y**3, x*y, x*y**2, y*x**2} i, j, k = symbols('i j k', commutative=False) assert itermonomials([i, j, k], 0) == {S(1)} assert itermonomials([i, j, k], 1) == {S(1), i, j, k} assert itermonomials([i, j, k], 2) == \ {S(1), i, j, k, i**2, j**2, k**2, i*j, i*k, j*i, j*k, k*i, k*j} assert itermonomials([i, j, k], 3) == \ {S(1), i, j, k, i**2, j**2, k**2, i*j, i*k, j*i, j*k, k*i, k*j, i**3, j**3, k**3, i**2 * j, i**2 * k, j * i**2, k * i**2, j**2 * i, j**2 * k, i * j**2, k * j**2, k**2 * i, k**2 * j, i * k**2, j * k**2, i*j*i, i*k*i, j*i*j, j*k*j, k*i*k, k*j*k, i*j*k, i*k*j, j*i*k, j*k*i, k*i*j, k*j*i, } assert itermonomials([x, i, j], 0) == {S(1)} assert itermonomials([x, i, j], 1) == {S(1), x, i, j} assert itermonomials([x, i, j], 2) == {S(1), x, i, j, x*i, x*j, i*j, j*i, x**2, i**2, j**2} assert itermonomials([x, i, j], 3) == \ {S(1), x, i, j, x*i, x*j, i*j, j*i, x**2, i**2, j**2, x**3, i**3, j**3, x**2 * i, x**2 * j, x * i**2, j * i**2, i**2 * j, i*j*i, x * j**2, i * j**2, j**2 * i, j*i*j, x * i * j, x * j * i, } def test_monomial_count(): assert monomial_count(2, 2) == 6 assert monomial_count(2, 3) == 10 def test_monomial_mul(): assert monomial_mul((3, 4, 1), (1, 2, 0)) == (4, 6, 1) def test_monomial_div(): assert monomial_div((3, 4, 1), (1, 2, 0)) == (2, 2, 1) def test_monomial_gcd(): assert monomial_gcd((3, 4, 1), (1, 2, 0)) == (1, 2, 0) def test_monomial_lcm(): assert monomial_lcm((3, 4, 1), (1, 2, 0)) == (3, 4, 1) def test_monomial_max(): assert monomial_max((3, 4, 5), (0, 5, 1), (6, 3, 9)) == (6, 5, 9) def test_monomial_pow(): assert monomial_pow((1, 2, 3), 3) == (3, 6, 9) def test_monomial_min(): assert monomial_min((3, 4, 5), (0, 5, 1), (6, 3, 9)) == (0, 3, 1) def test_monomial_divides(): assert monomial_divides((1, 2, 3), (4, 5, 6)) is True assert monomial_divides((1, 2, 3), (0, 5, 6)) is False def test_Monomial(): m = Monomial((3, 4, 1), (x, y, z)) n = Monomial((1, 2, 0), (x, y, z)) assert m.as_expr() == x**3*y**4*z assert n.as_expr() == x**1*y**2 assert m.as_expr(a, b, c) == a**3*b**4*c assert n.as_expr(a, b, c) == a**1*b**2 assert m.exponents == (3, 4, 1) assert m.gens == (x, y, z) assert n.exponents == (1, 2, 0) assert n.gens == (x, y, z) assert m == (3, 4, 1) assert n != (3, 4, 1) assert m != (1, 2, 0) assert n == (1, 2, 0) assert (m == 1) is False assert m[0] == m[-3] == 3 assert m[1] == m[-2] == 4 assert m[2] == m[-1] == 1 assert n[0] == n[-3] == 1 assert n[1] == n[-2] == 2 assert n[2] == n[-1] == 0 assert m[:2] == (3, 4) assert n[:2] == (1, 2) assert m*n == Monomial((4, 6, 1)) assert m/n == Monomial((2, 2, 1)) assert m*(1, 2, 0) == Monomial((4, 6, 1)) assert m/(1, 2, 0) == Monomial((2, 2, 1)) assert m.gcd(n) == Monomial((1, 2, 0)) assert m.lcm(n) == Monomial((3, 4, 1)) assert m.gcd((1, 2, 0)) == Monomial((1, 2, 0)) assert m.lcm((1, 2, 0)) == Monomial((3, 4, 1)) assert m**0 == Monomial((0, 0, 0)) assert m**1 == m assert m**2 == Monomial((6, 8, 2)) assert m**3 == Monomial((9, 12, 3)) raises(ExactQuotientFailed, lambda: m/Monomial((5, 2, 0))) mm = Monomial((1, 2, 3)) raises(ValueError, lambda: mm.as_expr()) assert str(mm) == 'Monomial((1, 2, 3))' assert str(m) == 'x**3*y**4*z**1' raises(NotImplementedError, lambda: m*1) raises(NotImplementedError, lambda: m/1) raises(ValueError, lambda: m**-1) raises(TypeError, lambda: m.gcd(3)) raises(TypeError, lambda: m.lcm(3))
3893394d89af30c906df0f7723fb5163479cc38cf4e93824fe41fa755e990583
from sympy import Add, Basic, symbols, Symbol from sympy.unify.core import Compound, Variable from sympy.unify.usympy import (deconstruct, construct, unify, is_associative, is_commutative) from sympy.abc import x, y, z, n from sympy.utilities.pytest import XFAIL def test_deconstruct(): expr = Basic(1, 2, 3) expected = Compound(Basic, (1, 2, 3)) assert deconstruct(expr) == expected assert deconstruct(1) == 1 assert deconstruct(x) == x assert deconstruct(x, variables=(x,)) == Variable(x) assert deconstruct(Add(1, x, evaluate=False)) == Compound(Add, (1, x)) assert deconstruct(Add(1, x, evaluate=False), variables=(x,)) == \ Compound(Add, (1, Variable(x))) def test_construct(): expr = Compound(Basic, (1, 2, 3)) expected = Basic(1, 2, 3) assert construct(expr) == expected def test_nested(): expr = Basic(1, Basic(2), 3) cmpd = Compound(Basic, (1, Compound(Basic, (2,)), 3)) assert deconstruct(expr) == cmpd assert construct(cmpd) == expr def test_unify(): expr = Basic(1, 2, 3) a, b, c = map(Symbol, 'abc') pattern = Basic(a, b, c) assert list(unify(expr, pattern, {}, (a, b, c))) == [{a: 1, b: 2, c: 3}] assert list(unify(expr, pattern, variables=(a, b, c))) == \ [{a: 1, b: 2, c: 3}] def test_unify_variables(): assert list(unify(Basic(1, 2), Basic(1, x), {}, variables=(x,))) == [{x: 2}] def test_s_input(): expr = Basic(1, 2) a, b = map(Symbol, 'ab') pattern = Basic(a, b) assert list(unify(expr, pattern, {}, (a, b))) == [{a: 1, b: 2}] assert list(unify(expr, pattern, {a: 5}, (a, b))) == [] def iterdicteq(a, b): a = tuple(a) b = tuple(b) return len(a) == len(b) and all(x in b for x in a) def test_unify_commutative(): expr = Add(1, 2, 3, evaluate=False) a, b, c = map(Symbol, 'abc') pattern = Add(a, b, c, evaluate=False) result = tuple(unify(expr, pattern, {}, (a, b, c))) expected = ({a: 1, b: 2, c: 3}, {a: 1, b: 3, c: 2}, {a: 2, b: 1, c: 3}, {a: 2, b: 3, c: 1}, {a: 3, b: 1, c: 2}, {a: 3, b: 2, c: 1}) assert iterdicteq(result, expected) def test_unify_iter(): expr = Add(1, 2, 3, evaluate=False) a, b, c = map(Symbol, 'abc') pattern = Add(a, c, evaluate=False) assert is_associative(deconstruct(pattern)) assert is_commutative(deconstruct(pattern)) result = list(unify(expr, pattern, {}, (a, c))) expected = [{a: 1, c: Add(2, 3, evaluate=False)}, {a: 1, c: Add(3, 2, evaluate=False)}, {a: 2, c: Add(1, 3, evaluate=False)}, {a: 2, c: Add(3, 1, evaluate=False)}, {a: 3, c: Add(1, 2, evaluate=False)}, {a: 3, c: Add(2, 1, evaluate=False)}, {a: Add(1, 2, evaluate=False), c: 3}, {a: Add(2, 1, evaluate=False), c: 3}, {a: Add(1, 3, evaluate=False), c: 2}, {a: Add(3, 1, evaluate=False), c: 2}, {a: Add(2, 3, evaluate=False), c: 1}, {a: Add(3, 2, evaluate=False), c: 1}] assert iterdicteq(result, expected) def test_hard_match(): from sympy import sin, cos expr = sin(x) + cos(x)**2 p, q = map(Symbol, 'pq') pattern = sin(p) + cos(p)**2 assert list(unify(expr, pattern, {}, (p, q))) == [{p: x}] def test_matrix(): from sympy import MatrixSymbol X = MatrixSymbol('X', n, n) Y = MatrixSymbol('Y', 2, 2) Z = MatrixSymbol('Z', 2, 3) assert list(unify(X, Y, {}, variables=[n, Symbol('X')])) == [{Symbol('X'): Symbol('Y'), n: 2}] assert list(unify(X, Z, {}, variables=[n, Symbol('X')])) == [] def test_non_frankenAdds(): # the is_commutative property used to fail because of Basic.__new__ # This caused is_commutative and str calls to fail expr = x+y*2 rebuilt = construct(deconstruct(expr)) # Ensure that we can run these commands without causing an error str(rebuilt) rebuilt.is_commutative def test_FiniteSet_commutivity(): from sympy import FiniteSet a, b, c, x, y = symbols('a,b,c,x,y') s = FiniteSet(a, b, c) t = FiniteSet(x, y) variables = (x, y) assert {x: FiniteSet(a, c), y: b} in tuple(unify(s, t, variables=variables)) def test_FiniteSet_complex(): from sympy import FiniteSet a, b, c, x, y, z = symbols('a,b,c,x,y,z') expr = FiniteSet(Basic(1, x), y, Basic(x, z)) pattern = FiniteSet(a, Basic(x, b)) variables = a, b expected = tuple([{b: 1, a: FiniteSet(y, Basic(x, z))}, {b: z, a: FiniteSet(y, Basic(1, x))}]) assert iterdicteq(unify(expr, pattern, variables=variables), expected) @XFAIL def test_and(): variables = x, y str(list(unify((x>0) & (z<3), pattern, variables=variables))) def test_Union(): from sympy import Interval assert list(unify(Interval(0, 1) + Interval(10, 11), Interval(0, 1) + Interval(12, 13), variables=(Interval(12, 13),))) def test_is_commutative(): assert is_commutative(deconstruct(x+y)) assert is_commutative(deconstruct(x*y)) assert not is_commutative(deconstruct(x**y)) def test_commutative_in_commutative(): from sympy.abc import a,b,c,d from sympy import sin, cos eq = sin(3)*sin(4)*sin(5) + 4*cos(3)*cos(4) pat = a*cos(b)*cos(c) + d*sin(b)*sin(c) assert next(unify(eq, pat, variables=(a,b,c,d)))
77bdce8d1bf1039176512d21f552f703a9e9ca11d1cba39d1a728c2b09e2e1d7
from sympy import Abs, Rational, Float, S, Symbol, symbols, cos, pi, sqrt, oo from sympy.functions.elementary.trigonometric import tan from sympy.geometry import (Circle, Ellipse, GeometryError, Point, Point2D, \ Polygon, Ray, RegularPolygon, Segment, Triangle, \ are_similar,convex_hull, intersection, Line) from sympy.utilities.pytest import raises, slow, warns from sympy.utilities.randtest import verify_numerically from sympy.geometry.polygon import rad, deg from sympy import integrate def feq(a, b): """Test if two floating point values are 'equal'.""" t_float = Float("1.0E-10") return -t_float < a - b < t_float @slow def test_polygon(): x = Symbol('x', real=True) y = Symbol('y', real=True) q = Symbol('q', real=True) u = Symbol('u', real=True) v = Symbol('v', real=True) w = Symbol('w', real=True) x1 = Symbol('x1', real=True) half = Rational(1, 2) a, b, c = Point(0, 0), Point(2, 0), Point(3, 3) t = Triangle(a, b, c) assert Polygon(a, Point(1, 0), b, c) == t assert Polygon(Point(1, 0), b, c, a) == t assert Polygon(b, c, a, Point(1, 0)) == t # 2 "remove folded" tests assert Polygon(a, Point(3, 0), b, c) == t assert Polygon(a, b, Point(3, -1), b, c) == t # remove multiple collinear points assert Polygon(Point(-4, 15), Point(-11, 15), Point(-15, 15), Point(-15, 33/5), Point(-15, -87/10), Point(-15, -15), Point(-42/5, -15), Point(-2, -15), Point(7, -15), Point(15, -15), Point(15, -3), Point(15, 10), Point(15, 15)) == \ Polygon(Point(-15,-15), Point(15,-15), Point(15,15), Point(-15,15)) p1 = Polygon( Point(0, 0), Point(3, -1), Point(6, 0), Point(4, 5), Point(2, 3), Point(0, 3)) p2 = Polygon( Point(6, 0), Point(3, -1), Point(0, 0), Point(0, 3), Point(2, 3), Point(4, 5)) p3 = Polygon( Point(0, 0), Point(3, 0), Point(5, 2), Point(4, 4)) p4 = Polygon( Point(0, 0), Point(4, 4), Point(5, 2), Point(3, 0)) p5 = Polygon( Point(0, 0), Point(4, 4), Point(0, 4)) p6 = Polygon( Point(-11, 1), Point(-9, 6.6), Point(-4, -3), Point(-8.4, -8.7)) p7 = Polygon( Point(x, y), Point(q, u), Point(v, w)) p8 = Polygon( Point(x, y), Point(v, w), Point(q, u)) p9 = Polygon( Point(0, 0), Point(4, 4), Point(3, 0), Point(5, 2)) p10 = Polygon( Point(0, 2), Point(2, 2), Point(0, 0), Point(2, 0)) p11 = Polygon(Point(0, 0), 1, n=3) r = Ray(Point(-9,6.6), Point(-9,5.5)) # # General polygon # assert p1 == p2 assert len(p1.args) == 6 assert len(p1.sides) == 6 assert p1.perimeter == 5 + 2*sqrt(10) + sqrt(29) + sqrt(8) assert p1.area == 22 assert not p1.is_convex() assert Polygon((-1, 1), (2, -1), (2, 1), (-1, -1), (3, 0) ).is_convex() is False # ensure convex for both CW and CCW point specification assert p3.is_convex() assert p4.is_convex() dict5 = p5.angles assert dict5[Point(0, 0)] == pi / 4 assert dict5[Point(0, 4)] == pi / 2 assert p5.encloses_point(Point(x, y)) is None assert p5.encloses_point(Point(1, 3)) assert p5.encloses_point(Point(0, 0)) is False assert p5.encloses_point(Point(4, 0)) is False assert p1.encloses(Circle(Point(2.5,2.5),5)) is False assert p1.encloses(Ellipse(Point(2.5,2),5,6)) is False p5.plot_interval('x') == [x, 0, 1] assert p5.distance( Polygon(Point(10, 10), Point(14, 14), Point(10, 14))) == 6 * sqrt(2) assert p5.distance( Polygon(Point(1, 8), Point(5, 8), Point(8, 12), Point(1, 12))) == 4 with warns(UserWarning, \ match="Polygons may intersect producing erroneous output"): Polygon(Point(0, 0), Point(1, 0), Point(1, 1)).distance( Polygon(Point(0, 0), Point(0, 1), Point(1, 1))) assert hash(p5) == hash(Polygon(Point(0, 0), Point(4, 4), Point(0, 4))) assert hash(p1) == hash(p2) assert hash(p7) == hash(p8) assert hash(p3) != hash(p9) assert p5 == Polygon(Point(4, 4), Point(0, 4), Point(0, 0)) assert Polygon(Point(4, 4), Point(0, 4), Point(0, 0)) in p5 assert p5 != Point(0, 4) assert Point(0, 1) in p5 assert p5.arbitrary_point('t').subs(Symbol('t', real=True), 0) == \ Point(0, 0) raises(ValueError, lambda: Polygon( Point(x, 0), Point(0, y), Point(x, y)).arbitrary_point('x')) assert p6.intersection(r) == [Point(-9, -S(84)/13), Point(-9, S(33)/5)] assert p10.area == 0 assert p11 == RegularPolygon(Point(0, 0), 1, 3, 0) assert p11.vertices[0] == Point(1, 0) assert p11.args[0] == Point(0, 0) p11.spin(pi/2) assert p11.vertices[0] == Point(0, 1) # # Regular polygon # p1 = RegularPolygon(Point(0, 0), 10, 5) p2 = RegularPolygon(Point(0, 0), 5, 5) raises(GeometryError, lambda: RegularPolygon(Point(0, 0), Point(0, 1), Point(1, 1))) raises(GeometryError, lambda: RegularPolygon(Point(0, 0), 1, 2)) raises(ValueError, lambda: RegularPolygon(Point(0, 0), 1, 2.5)) assert p1 != p2 assert p1.interior_angle == 3*pi/5 assert p1.exterior_angle == 2*pi/5 assert p2.apothem == 5*cos(pi/5) assert p2.circumcenter == p1.circumcenter == Point(0, 0) assert p1.circumradius == p1.radius == 10 assert p2.circumcircle == Circle(Point(0, 0), 5) assert p2.incircle == Circle(Point(0, 0), p2.apothem) assert p2.inradius == p2.apothem == (5 * (1 + sqrt(5)) / 4) p2.spin(pi / 10) dict1 = p2.angles assert dict1[Point(0, 5)] == 3 * pi / 5 assert p1.is_convex() assert p1.rotation == 0 assert p1.encloses_point(Point(0, 0)) assert p1.encloses_point(Point(11, 0)) is False assert p2.encloses_point(Point(0, 4.9)) p1.spin(pi/3) assert p1.rotation == pi/3 assert p1.vertices[0] == Point(5, 5*sqrt(3)) for var in p1.args: if isinstance(var, Point): assert var == Point(0, 0) else: assert var == 5 or var == 10 or var == pi / 3 assert p1 != Point(0, 0) assert p1 != p5 # while spin works in place (notice that rotation is 2pi/3 below) # rotate returns a new object p1_old = p1 assert p1.rotate(pi/3) == RegularPolygon(Point(0, 0), 10, 5, 2*pi/3) assert p1 == p1_old assert p1.area == (-250*sqrt(5) + 1250)/(4*tan(pi/5)) assert p1.length == 20*sqrt(-sqrt(5)/8 + S(5)/8) assert p1.scale(2, 2) == \ RegularPolygon(p1.center, p1.radius*2, p1._n, p1.rotation) assert RegularPolygon((0, 0), 1, 4).scale(2, 3) == \ Polygon(Point(2, 0), Point(0, 3), Point(-2, 0), Point(0, -3)) assert repr(p1) == str(p1) # # Angles # angles = p4.angles assert feq(angles[Point(0, 0)].evalf(), Float("0.7853981633974483")) assert feq(angles[Point(4, 4)].evalf(), Float("1.2490457723982544")) assert feq(angles[Point(5, 2)].evalf(), Float("1.8925468811915388")) assert feq(angles[Point(3, 0)].evalf(), Float("2.3561944901923449")) angles = p3.angles assert feq(angles[Point(0, 0)].evalf(), Float("0.7853981633974483")) assert feq(angles[Point(4, 4)].evalf(), Float("1.2490457723982544")) assert feq(angles[Point(5, 2)].evalf(), Float("1.8925468811915388")) assert feq(angles[Point(3, 0)].evalf(), Float("2.3561944901923449")) # # Triangle # p1 = Point(0, 0) p2 = Point(5, 0) p3 = Point(0, 5) t1 = Triangle(p1, p2, p3) t2 = Triangle(p1, p2, Point(Rational(5, 2), sqrt(Rational(75, 4)))) t3 = Triangle(p1, Point(x1, 0), Point(0, x1)) s1 = t1.sides assert Triangle(p1, p2, p1) == Polygon(p1, p2, p1) == Segment(p1, p2) raises(GeometryError, lambda: Triangle(Point(0, 0))) # Basic stuff assert Triangle(p1, p1, p1) == p1 assert Triangle(p2, p2*2, p2*3) == Segment(p2, p2*3) assert t1.area == Rational(25, 2) assert t1.is_right() assert t2.is_right() is False assert t3.is_right() assert p1 in t1 assert t1.sides[0] in t1 assert Segment((0, 0), (1, 0)) in t1 assert Point(5, 5) not in t2 assert t1.is_convex() assert feq(t1.angles[p1].evalf(), pi.evalf()/2) assert t1.is_equilateral() is False assert t2.is_equilateral() assert t3.is_equilateral() is False assert are_similar(t1, t2) is False assert are_similar(t1, t3) assert are_similar(t2, t3) is False assert t1.is_similar(Point(0, 0)) is False assert t1.is_similar(t2) is False # Bisectors bisectors = t1.bisectors() assert bisectors[p1] == Segment( p1, Point(Rational(5, 2), Rational(5, 2))) assert t2.bisectors()[p2] == Segment( Point(5, 0), Point(Rational(5, 4), 5*sqrt(3)/4)) p4 = Point(0, x1) assert t3.bisectors()[p4] == Segment(p4, Point(x1*(sqrt(2) - 1), 0)) ic = (250 - 125*sqrt(2))/50 assert t1.incenter == Point(ic, ic) # Inradius assert t1.inradius == t1.incircle.radius == 5 - 5*sqrt(2)/2 assert t2.inradius == t2.incircle.radius == 5*sqrt(3)/6 assert t3.inradius == t3.incircle.radius == x1**2/((2 + sqrt(2))*Abs(x1)) # Exradius assert t1.exradii[t1.sides[2]] == 5*sqrt(2)/2 # Circumcircle assert t1.circumcircle.center == Point(2.5, 2.5) # Medians + Centroid m = t1.medians assert t1.centroid == Point(Rational(5, 3), Rational(5, 3)) assert m[p1] == Segment(p1, Point(Rational(5, 2), Rational(5, 2))) assert t3.medians[p1] == Segment(p1, Point(x1/2, x1/2)) assert intersection(m[p1], m[p2], m[p3]) == [t1.centroid] assert t1.medial == Triangle(Point(2.5, 0), Point(0, 2.5), Point(2.5, 2.5)) # Nine-point circle assert t1.nine_point_circle == Circle(Point(2.5, 0), Point(0, 2.5), Point(2.5, 2.5)) assert t1.nine_point_circle == Circle(Point(0, 0), Point(0, 2.5), Point(2.5, 2.5)) # Perpendicular altitudes = t1.altitudes assert altitudes[p1] == Segment(p1, Point(Rational(5, 2), Rational(5, 2))) assert altitudes[p2].equals(s1[0]) assert altitudes[p3] == s1[2] assert t1.orthocenter == p1 t = S('''Triangle( Point(100080156402737/5000000000000, 79782624633431/500000000000), Point(39223884078253/2000000000000, 156345163124289/1000000000000), Point(31241359188437/1250000000000, 338338270939941/1000000000000000))''') assert t.orthocenter == S('''Point(-780660869050599840216997''' '''79471538701955848721853/80368430960602242240789074233100000000000000,''' '''20151573611150265741278060334545897615974257/16073686192120448448157''' '''8148466200000000000)''') # Ensure assert len(intersection(*bisectors.values())) == 1 assert len(intersection(*altitudes.values())) == 1 assert len(intersection(*m.values())) == 1 # Distance p1 = Polygon( Point(0, 0), Point(1, 0), Point(1, 1), Point(0, 1)) p2 = Polygon( Point(0, Rational(5)/4), Point(1, Rational(5)/4), Point(1, Rational(9)/4), Point(0, Rational(9)/4)) p3 = Polygon( Point(1, 2), Point(2, 2), Point(2, 1)) p4 = Polygon( Point(1, 1), Point(Rational(6)/5, 1), Point(1, Rational(6)/5)) pt1 = Point(half, half) pt2 = Point(1, 1) '''Polygon to Point''' assert p1.distance(pt1) == half assert p1.distance(pt2) == 0 assert p2.distance(pt1) == Rational(3)/4 assert p3.distance(pt2) == sqrt(2)/2 '''Polygon to Polygon''' # p1.distance(p2) emits a warning with warns(UserWarning, \ match="Polygons may intersect producing erroneous output"): assert p1.distance(p2) == half/2 assert p1.distance(p3) == sqrt(2)/2 # p3.distance(p4) emits a warning with warns(UserWarning, \ match="Polygons may intersect producing erroneous output"): assert p3.distance(p4) == (sqrt(2)/2 - sqrt(Rational(2)/25)/2) def test_convex_hull(): p = [Point(-5, -1), Point(-2, 1), Point(-2, -1), Point(-1, -3), \ Point(0, 0), Point(1, 1), Point(2, 2), Point(2, -1), Point(3, 1), \ Point(4, -1), Point(6, 2)] ch = Polygon(p[0], p[3], p[9], p[10], p[6], p[1]) #test handling of duplicate points p.append(p[3]) #more than 3 collinear points another_p = [Point(-45, -85), Point(-45, 85), Point(-45, 26), \ Point(-45, -24)] ch2 = Segment(another_p[0], another_p[1]) assert convex_hull(*another_p) == ch2 assert convex_hull(*p) == ch assert convex_hull(p[0]) == p[0] assert convex_hull(p[0], p[1]) == Segment(p[0], p[1]) # no unique points assert convex_hull(*[p[-1]]*3) == p[-1] # collection of items assert convex_hull(*[Point(0, 0), \ Segment(Point(1, 0), Point(1, 1)), \ RegularPolygon(Point(2, 0), 2, 4)]) == \ Polygon(Point(0, 0), Point(2, -2), Point(4, 0), Point(2, 2)) def test_encloses(): # square with a dimpled left side s = Polygon(Point(0, 0), Point(1, 0), Point(1, 1), Point(0, 1), \ Point(S.Half, S.Half)) # the following is True if the polygon isn't treated as closing on itself assert s.encloses(Point(0, S.Half)) is False assert s.encloses(Point(S.Half, S.Half)) is False # it's a vertex assert s.encloses(Point(Rational(3, 4), S.Half)) is True def test_triangle_kwargs(): assert Triangle(sss=(3, 4, 5)) == \ Triangle(Point(0, 0), Point(3, 0), Point(3, 4)) assert Triangle(asa=(30, 2, 30)) == \ Triangle(Point(0, 0), Point(2, 0), Point(1, sqrt(3)/3)) assert Triangle(sas=(1, 45, 2)) == \ Triangle(Point(0, 0), Point(2, 0), Point(sqrt(2)/2, sqrt(2)/2)) assert Triangle(sss=(1, 2, 5)) is None assert deg(rad(180)) == 180 def test_transform(): pts = [Point(0, 0), Point(S(1)/2, S(1)/4), Point(1, 1)] pts_out = [Point(-4, -10), Point(-3, -S(37)/4), Point(-2, -7)] assert Triangle(*pts).scale(2, 3, (4, 5)) == Triangle(*pts_out) assert RegularPolygon((0, 0), 1, 4).scale(2, 3, (4, 5)) == \ Polygon(Point(-2, -10), Point(-4, -7), Point(-6, -10), Point(-4, -13)) def test_reflect(): x = Symbol('x', real=True) y = Symbol('y', real=True) b = Symbol('b') m = Symbol('m') l = Line((0, b), slope=m) p = Point(x, y) r = p.reflect(l) dp = l.perpendicular_segment(p).length dr = l.perpendicular_segment(r).length assert verify_numerically(dp, dr) t = Triangle((0, 0), (1, 0), (2, 3)) assert Polygon((1, 0), (2, 0), (2, 2)).reflect(Line((3, 0), slope=oo)) \ == Triangle(Point(5, 0), Point(4, 0), Point(4, 2)) assert Polygon((1, 0), (2, 0), (2, 2)).reflect(Line((0, 3), slope=oo)) \ == Triangle(Point(-1, 0), Point(-2, 0), Point(-2, 2)) assert Polygon((1, 0), (2, 0), (2, 2)).reflect(Line((0, 3), slope=0)) \ == Triangle(Point(1, 6), Point(2, 6), Point(2, 4)) assert Polygon((1, 0), (2, 0), (2, 2)).reflect(Line((3, 0), slope=0)) \ == Triangle(Point(1, 0), Point(2, 0), Point(2, -2)) def test_bisectors(): p1, p2, p3 = Point(0, 0), Point(1, 0), Point(0, 1) t = Triangle(p1, p2, p3) assert t.bisectors()[p2] == Segment(Point(1, 0), Point(0, sqrt(2) - 1)) def test_incenter(): assert Triangle(Point(0, 0), Point(1, 0), Point(0, 1)).incenter \ == Point(1 - sqrt(2)/2, 1 - sqrt(2)/2) def test_inradius(): assert Triangle(Point(0, 0), Point(4, 0), Point(0, 3)).inradius == 1 def test_incircle(): assert Triangle(Point(0, 0), Point(2, 0), Point(0, 2)).incircle \ == Circle(Point(2 - sqrt(2), 2 - sqrt(2)), 2 - sqrt(2)) def test_exradii(): t = Triangle(Point(0, 0), Point(6, 0), Point(0, 2)) assert t.exradii[t.sides[2]] == (-2 + sqrt(10)) def test_medians(): t = Triangle(Point(0, 0), Point(1, 0), Point(0, 1)) assert t.medians[Point(0, 0)] == Segment(Point(0, 0), Point(S(1)/2, S(1)/2)) def test_medial(): assert Triangle(Point(0, 0), Point(1, 0), Point(0, 1)).medial \ == Triangle(Point(S(1)/2, 0), Point(S(1)/2, S(1)/2), Point(0, S(1)/2)) def test_nine_point_circle(): assert Triangle(Point(0, 0), Point(1, 0), Point(0, 1)).nine_point_circle \ == Circle(Point2D(S(1)/4, S(1)/4), sqrt(2)/4) def test_eulerline(): assert Triangle(Point(0, 0), Point(1, 0), Point(0, 1)).eulerline \ == Line(Point2D(0, 0), Point2D(S(1)/2, S(1)/2)) assert Triangle(Point(0, 0), Point(10, 0), Point(5, 5*sqrt(3))).eulerline \ == Point2D(5, 5*sqrt(3)/3) assert Triangle(Point(4, -6), Point(4, -1), Point(-3, 3)).eulerline \ == Line(Point2D(S(64)/7, 3), Point2D(-S(29)/14, -S(7)/2)) def test_intersection(): poly1 = Triangle(Point(0, 0), Point(1, 0), Point(0, 1)) poly2 = Polygon(Point(0, 1), Point(-5, 0), Point(0, -4), Point(0, S(1)/5), Point(S(1)/2, -0.1), Point(1,0), Point(0, 1)) assert poly1.intersection(poly2) == [Point2D(S(1)/3, 0), Segment(Point(0, S(1)/5), Point(0, 0)), Segment(Point(1, 0), Point(0, 1))] assert poly2.intersection(poly1) == [Point(S(1)/3, 0), Segment(Point(0, 0), Point(0, S(1)/5)), Segment(Point(1, 0), Point(0, 1))] assert poly1.intersection(Point(0, 0)) == [Point(0, 0)] assert poly1.intersection(Point(-12, -43)) == [] assert poly2.intersection(Line((-12, 0), (12, 0))) == [Point(-5, 0), Point(0, 0),Point(S(1)/3, 0), Point(1, 0)] assert poly2.intersection(Line((-12, 12), (12, 12))) == [] assert poly2.intersection(Ray((-3,4), (1,0))) == [Segment(Point(1, 0), Point(0, 1))] assert poly2.intersection(Circle((0, -1), 1)) == [Point(0, -2), Point(0, 0)] assert poly1.intersection(poly1) == [Segment(Point(0, 0), Point(1, 0)), Segment(Point(0, 1), Point(0, 0)), Segment(Point(1, 0), Point(0, 1))] assert poly2.intersection(poly2) == [Segment(Point(-5, 0), Point(0, -4)), Segment(Point(0, -4), Point(0, S(1)/5)), Segment(Point(0, S(1)/5), Point(S(1)/2, -S(1)/10)), Segment(Point(0, 1), Point(-5, 0)), Segment(Point(S(1)/2, -S(1)/10), Point(1, 0)), Segment(Point(1, 0), Point(0, 1))] assert poly2.intersection(Triangle(Point(0, 1), Point(1, 0), Point(-1, 1))) \ == [Point(-S(5)/7, S(6)/7), Segment(Point2D(0, 1), Point(1, 0))] assert poly1.intersection(RegularPolygon((-12, -15), 3, 3)) == [] def test_parameter_value(): t = Symbol('t') sq = Polygon((0, 0), (0, 1), (1, 1), (1, 0)) assert sq.parameter_value((0.5, 1), t) == {t: S(3)/8} q = Polygon((0, 0), (2, 1), (2, 4), (4, 0)) assert q.parameter_value((4, 0), t) == {t: -6 + 3*sqrt(5)} # ~= 0.708 raises(ValueError, lambda: sq.parameter_value((5, 6), t)) def test_issue_12966(): poly = Polygon(Point(0, 0), Point(0, 10), Point(5, 10), Point(5, 5), Point(10, 5), Point(10, 0)) t = Symbol('t') pt = poly.arbitrary_point(t) DELTA = 5/poly.perimeter assert [pt.subs(t, DELTA*i) for i in range(int(1/DELTA))] == [ Point(0, 0), Point(0, 5), Point(0, 10), Point(5, 10), Point(5, 5), Point(10, 5), Point(10, 0), Point(5, 0)] def test_second_moment_of_area(): x, y = symbols('x, y') # triangle p1, p2, p3 = [(0, 0), (4, 0), (0, 2)] p = (0, 0) # equation of hypotenuse eq_y = (1-x/4)*2 I_yy = integrate((x**2) * (integrate(1, (y, 0, eq_y))), (x, 0, 4)) I_xx = integrate(1 * (integrate(y**2, (y, 0, eq_y))), (x, 0, 4)) I_xy = integrate(x * (integrate(y, (y, 0, eq_y))), (x, 0, 4)) triangle = Polygon(p1, p2, p3) assert (I_xx - triangle.second_moment_of_area(p)[0]) == 0 assert (I_yy - triangle.second_moment_of_area(p)[1]) == 0 assert (I_xy - triangle.second_moment_of_area(p)[2]) == 0 # rectangle p1, p2, p3, p4=[(0, 0), (4, 0), (4, 2), (0, 2)] I_yy = integrate((x**2) * integrate(1, (y, 0, 2)), (x, 0, 4)) I_xx = integrate(1 * integrate(y**2, (y, 0, 2)), (x, 0, 4)) I_xy = integrate(x * integrate(y, (y, 0, 2)), (x, 0, 4)) rectangle = Polygon(p1, p2, p3, p4) assert (I_xx - rectangle.second_moment_of_area(p)[0]) == 0 assert (I_yy - rectangle.second_moment_of_area(p)[1]) == 0 assert (I_xy - rectangle.second_moment_of_area(p)[2]) == 0
e0167d4739c5b12f09c2ec0502a4e1764cae32e26b40493f5cfc867356c7455f
from sympy import Rational, oo, sqrt, S from sympy import Line, Point, Point2D, Parabola, Segment2D, Ray2D from sympy import Circle, Ellipse, symbols, sign from sympy.utilities.pytest import raises def test_parabola_geom(): a, b = symbols('a b') p1 = Point(0, 0) p2 = Point(3, 7) p3 = Point(0, 4) p4 = Point(6, 0) p5 = Point(a, a) d1 = Line(Point(4, 0), Point(4, 9)) d2 = Line(Point(7, 6), Point(3, 6)) d3 = Line(Point(4, 0), slope=oo) d4 = Line(Point(7, 6), slope=0) d5 = Line(Point(b, a), slope=oo) d6 = Line(Point(a, b), slope=0) half = Rational(1, 2) pa1 = Parabola(None, d2) pa2 = Parabola(directrix=d1) pa3 = Parabola(p1, d1) pa4 = Parabola(p2, d2) pa5 = Parabola(p2, d4) pa6 = Parabola(p3, d2) pa7 = Parabola(p2, d1) pa8 = Parabola(p4, d1) pa9 = Parabola(p4, d3) pa10 = Parabola(p5, d5) pa11 = Parabola(p5, d6) raises(ValueError, lambda: Parabola(Point(7, 8, 9), Line(Point(6, 7), Point(7, 7)))) raises(NotImplementedError, lambda: Parabola(Point(7, 8), Line(Point(3, 7), Point(2, 9)))) raises(ValueError, lambda: Parabola(Point(0, 2), Line(Point(7, 2), Point(6, 2)))) raises(ValueError, lambda: Parabola(Point(7, 8), Point(3, 8))) # Basic Stuff assert pa1.focus == Point(0, 0) assert pa2 == pa3 assert pa4 != pa7 assert pa6 != pa7 assert pa6.focus == Point2D(0, 4) assert pa6.focal_length == 1 assert pa6.p_parameter == -1 assert pa6.vertex == Point2D(0, 5) assert pa6.eccentricity == 1 assert pa7.focus == Point2D(3, 7) assert pa7.focal_length == half assert pa7.p_parameter == -half assert pa7.vertex == Point2D(7*half, 7) assert pa4.focal_length == half assert pa4.p_parameter == half assert pa4.vertex == Point2D(3, 13*half) assert pa8.focal_length == 1 assert pa8.p_parameter == 1 assert pa8.vertex == Point2D(5, 0) assert pa4.focal_length == pa5.focal_length assert pa4.p_parameter == pa5.p_parameter assert pa4.vertex == pa5.vertex assert pa4.equation() == pa5.equation() assert pa8.focal_length == pa9.focal_length assert pa8.p_parameter == pa9.p_parameter assert pa8.vertex == pa9.vertex assert pa8.equation() == pa9.equation() assert pa10.focal_length == pa11.focal_length == sqrt((a - b) ** 2) / 2 # if a, b real == abs(a - b)/2 assert pa11.vertex == Point(*pa10.vertex[::-1]) == Point(a, a - sqrt((a - b)**2)*sign(a - b)/2) # change axis x->y, y->x on pa10 def test_parabola_intersection(): l1 = Line(Point(1, -2), Point(-1,-2)) l2 = Line(Point(1, 2), Point(-1,2)) l3 = Line(Point(1, 0), Point(-1,0)) p1 = Point(0,0) p2 = Point(0, -2) p3 = Point(120, -12) parabola1 = Parabola(p1, l1) # parabola with parabola assert parabola1.intersection(parabola1) == [parabola1] assert parabola1.intersection(Parabola(p1, l2)) == [Point2D(-2, 0), Point2D(2, 0)] assert parabola1.intersection(Parabola(p2, l3)) == [Point2D(0, -1)] assert parabola1.intersection(Parabola(Point(16, 0), l1)) == [Point2D(8, 15)] assert parabola1.intersection(Parabola(Point(0, 16), l1)) == [Point2D(-6, 8), Point2D(6, 8)] assert parabola1.intersection(Parabola(p3, l3)) == [] # parabola with point assert parabola1.intersection(p1) == [] assert parabola1.intersection(Point2D(0, -1)) == [Point2D(0, -1)] assert parabola1.intersection(Point2D(4, 3)) == [Point2D(4, 3)] # parabola with line assert parabola1.intersection(Line(Point2D(-7, 3), Point(12, 3))) == [Point2D(-4, 3), Point2D(4, 3)] assert parabola1.intersection(Line(Point(-4, -1), Point(4, -1))) == [Point(0, -1)] assert parabola1.intersection(Line(Point(2, 0), Point(0, -2))) == [Point2D(2, 0)] # parabola with segment assert parabola1.intersection(Segment2D((-4, -5), (4, 3))) == [Point2D(0, -1), Point2D(4, 3)] assert parabola1.intersection(Segment2D((0, -5), (0, 6))) == [Point2D(0, -1)] assert parabola1.intersection(Segment2D((-12, -65), (14, -68))) == [] # parabola with ray assert parabola1.intersection(Ray2D((-4, -5), (4, 3))) == [Point2D(0, -1), Point2D(4, 3)] assert parabola1.intersection(Ray2D((0, 7), (1, 14))) == [Point2D(14 + 2*sqrt(57), 105 + 14*sqrt(57))] assert parabola1.intersection(Ray2D((0, 7), (0, 14))) == [] # parabola with ellipse/circle assert parabola1.intersection(Circle(p1, 2)) == [Point2D(-2, 0), Point2D(2, 0)] assert parabola1.intersection(Circle(p2, 1)) == [Point2D(0, -1), Point2D(0, -1)] assert parabola1.intersection(Ellipse(p2, 2, 1)) == [Point2D(0, -1), Point2D(0, -1)] assert parabola1.intersection(Ellipse(Point(0, 19), 5, 7)) == [] assert parabola1.intersection(Ellipse((0, 3), 12, 4)) == \ [Point2D(0, -1), Point2D(0, -1), Point2D(-4*sqrt(17)/3, S(59)/9), Point2D(4*sqrt(17)/3, S(59)/9)]
ef91496f98495beba62d33ca9cc1f674f6f799adeca8ada11c9d004225b0c432
"""Utilities to deal with sympy.Matrix, numpy and scipy.sparse.""" from __future__ import print_function, division from sympy import MatrixBase, I, Expr, Integer from sympy.matrices import eye, zeros from sympy.external import import_module __all__ = [ 'numpy_ndarray', 'scipy_sparse_matrix', 'sympy_to_numpy', 'sympy_to_scipy_sparse', 'numpy_to_sympy', 'scipy_sparse_to_sympy', 'flatten_scalar', 'matrix_dagger', 'to_sympy', 'to_numpy', 'to_scipy_sparse', 'matrix_tensor_product', 'matrix_zeros' ] # Conditionally define the base classes for numpy and scipy.sparse arrays # for use in isinstance tests. np = import_module('numpy') if not np: class numpy_ndarray(object): pass else: numpy_ndarray = np.ndarray scipy = import_module('scipy', __import__kwargs={'fromlist': ['sparse']}) if not scipy: class scipy_sparse_matrix(object): pass sparse = None else: sparse = scipy.sparse # Try to find spmatrix. if hasattr(sparse, 'base'): # Newer versions have it under scipy.sparse.base. scipy_sparse_matrix = sparse.base.spmatrix elif hasattr(sparse, 'sparse'): # Older versions have it under scipy.sparse.sparse. scipy_sparse_matrix = sparse.sparse.spmatrix def sympy_to_numpy(m, **options): """Convert a sympy Matrix/complex number to a numpy matrix or scalar.""" if not np: raise ImportError dtype = options.get('dtype', 'complex') if isinstance(m, MatrixBase): return np.matrix(m.tolist(), dtype=dtype) elif isinstance(m, Expr): if m.is_Number or m.is_NumberSymbol or m == I: return complex(m) raise TypeError('Expected MatrixBase or complex scalar, got: %r' % m) def sympy_to_scipy_sparse(m, **options): """Convert a sympy Matrix/complex number to a numpy matrix or scalar.""" if not np or not sparse: raise ImportError dtype = options.get('dtype', 'complex') if isinstance(m, MatrixBase): return sparse.csr_matrix(np.matrix(m.tolist(), dtype=dtype)) elif isinstance(m, Expr): if m.is_Number or m.is_NumberSymbol or m == I: return complex(m) raise TypeError('Expected MatrixBase or complex scalar, got: %r' % m) def scipy_sparse_to_sympy(m, **options): """Convert a scipy.sparse matrix to a sympy matrix.""" return MatrixBase(m.todense()) def numpy_to_sympy(m, **options): """Convert a numpy matrix to a sympy matrix.""" return MatrixBase(m) def to_sympy(m, **options): """Convert a numpy/scipy.sparse matrix to a sympy matrix.""" if isinstance(m, MatrixBase): return m elif isinstance(m, numpy_ndarray): return numpy_to_sympy(m) elif isinstance(m, scipy_sparse_matrix): return scipy_sparse_to_sympy(m) elif isinstance(m, Expr): return m raise TypeError('Expected sympy/numpy/scipy.sparse matrix, got: %r' % m) def to_numpy(m, **options): """Convert a sympy/scipy.sparse matrix to a numpy matrix.""" dtype = options.get('dtype', 'complex') if isinstance(m, (MatrixBase, Expr)): return sympy_to_numpy(m, dtype=dtype) elif isinstance(m, numpy_ndarray): return m elif isinstance(m, scipy_sparse_matrix): return m.todense() raise TypeError('Expected sympy/numpy/scipy.sparse matrix, got: %r' % m) def to_scipy_sparse(m, **options): """Convert a sympy/numpy matrix to a scipy.sparse matrix.""" dtype = options.get('dtype', 'complex') if isinstance(m, (MatrixBase, Expr)): return sympy_to_scipy_sparse(m, dtype=dtype) elif isinstance(m, numpy_ndarray): if not sparse: raise ImportError return sparse.csr_matrix(m) elif isinstance(m, scipy_sparse_matrix): return m raise TypeError('Expected sympy/numpy/scipy.sparse matrix, got: %r' % m) def flatten_scalar(e): """Flatten a 1x1 matrix to a scalar, return larger matrices unchanged.""" if isinstance(e, MatrixBase): if e.shape == (1, 1): e = e[0] if isinstance(e, (numpy_ndarray, scipy_sparse_matrix)): if e.shape == (1, 1): e = complex(e[0, 0]) return e def matrix_dagger(e): """Return the dagger of a sympy/numpy/scipy.sparse matrix.""" if isinstance(e, MatrixBase): return e.H elif isinstance(e, (numpy_ndarray, scipy_sparse_matrix)): return e.conjugate().transpose() raise TypeError('Expected sympy/numpy/scipy.sparse matrix, got: %r' % e) # TODO: Move this into sympy.matricies. def _sympy_tensor_product(*matrices): """Compute the kronecker product of a sequence of sympy Matrices. """ from sympy.matrices.expressions.kronecker import matrix_kronecker_product return matrix_kronecker_product(*matrices) def _numpy_tensor_product(*product): """numpy version of tensor product of multiple arguments.""" if not np: raise ImportError answer = product[0] for item in product[1:]: answer = np.kron(answer, item) return answer def _scipy_sparse_tensor_product(*product): """scipy.sparse version of tensor product of multiple arguments.""" if not sparse: raise ImportError answer = product[0] for item in product[1:]: answer = sparse.kron(answer, item) # The final matrices will just be multiplied, so csr is a good final # sparse format. return sparse.csr_matrix(answer) def matrix_tensor_product(*product): """Compute the matrix tensor product of sympy/numpy/scipy.sparse matrices.""" if isinstance(product[0], MatrixBase): return _sympy_tensor_product(*product) elif isinstance(product[0], numpy_ndarray): return _numpy_tensor_product(*product) elif isinstance(product[0], scipy_sparse_matrix): return _scipy_sparse_tensor_product(*product) def _numpy_eye(n): """numpy version of complex eye.""" if not np: raise ImportError return np.matrix(np.eye(n, dtype='complex')) def _scipy_sparse_eye(n): """scipy.sparse version of complex eye.""" if not sparse: raise ImportError return sparse.eye(n, n, dtype='complex') def matrix_eye(n, **options): """Get the version of eye and tensor_product for a given format.""" format = options.get('format', 'sympy') if format == 'sympy': return eye(n) elif format == 'numpy': return _numpy_eye(n) elif format == 'scipy.sparse': return _scipy_sparse_eye(n) raise NotImplementedError('Invalid format: %r' % format) def _numpy_zeros(m, n, **options): """numpy version of zeros.""" dtype = options.get('dtype', 'float64') if not np: raise ImportError return np.zeros((m, n), dtype=dtype) def _scipy_sparse_zeros(m, n, **options): """scipy.sparse version of zeros.""" spmatrix = options.get('spmatrix', 'csr') dtype = options.get('dtype', 'float64') if not sparse: raise ImportError if spmatrix == 'lil': return sparse.lil_matrix((m, n), dtype=dtype) elif spmatrix == 'csr': return sparse.csr_matrix((m, n), dtype=dtype) def matrix_zeros(m, n, **options): """"Get a zeros matrix for a given format.""" format = options.get('format', 'sympy') dtype = options.get('dtype', 'float64') spmatrix = options.get('spmatrix', 'csr') if format == 'sympy': return zeros(m, n) elif format == 'numpy': return _numpy_zeros(m, n, **options) elif format == 'scipy.sparse': return _scipy_sparse_zeros(m, n, **options) raise NotImplementedError('Invaild format: %r' % format) def _numpy_matrix_to_zero(e): """Convert a numpy zero matrix to the zero scalar.""" if not np: raise ImportError test = np.zeros_like(e) if np.allclose(e, test): return 0.0 else: return e def _scipy_sparse_matrix_to_zero(e): """Convert a scipy.sparse zero matrix to the zero scalar.""" if not np: raise ImportError edense = e.todense() test = np.zeros_like(edense) if np.allclose(edense, test): return 0.0 else: return e def matrix_to_zero(e): """Convert a zero matrix to the scalar zero.""" if isinstance(e, MatrixBase): if zeros(*e.shape) == e: e = Integer(0) elif isinstance(e, numpy_ndarray): e = _numpy_matrix_to_zero(e) elif isinstance(e, scipy_sparse_matrix): e = _scipy_sparse_matrix_to_zero(e) return e
60121ed3d120a0fcf6668835e154a36c32089a5c390073e167b012094315746b
from sympy import Rational, pi, sqrt, S from sympy.physics.units.quantities import Quantity from sympy.physics.units.dimensions import (dimsys_default, Dimension, acceleration, action, amount_of_substance, capacitance, charge, conductance, current, energy, force, frequency, information, impedance, inductance, length, luminous_intensity, magnetic_density, magnetic_flux, mass, power, pressure, temperature, time, velocity, voltage) from sympy.physics.units.prefixes import ( centi, deci, kilo, micro, milli, nano, pico, kibi, mebi, gibi, tebi, pebi, exbi) One = S.One #### UNITS #### # Dimensionless: percent = percents = Quantity("percent", latex_repr=r"\%") percent.set_dimension(One) percent.set_scale_factor(Rational(1, 100)) permille = Quantity("permille") permille.set_dimension(One) permille.set_scale_factor(Rational(1, 1000)) # Angular units (dimensionless) rad = radian = radians = Quantity("radian", abbrev="rad") radian.set_dimension(One) radian.set_scale_factor(One) deg = degree = degrees = Quantity("degree", abbrev="deg", latex_repr=r"^\circ") degree.set_dimension(One) degree.set_scale_factor(pi/180) sr = steradian = steradians = Quantity("steradian", abbrev="sr") steradian.set_dimension(One) steradian.set_scale_factor(One) mil = angular_mil = angular_mils = Quantity("angular_mil", abbrev="mil") angular_mil.set_dimension(One) angular_mil.set_scale_factor(2*pi/6400) # Base units: m = meter = meters = Quantity("meter", abbrev="m") meter.set_dimension(length) meter.set_scale_factor(One) # NOTE: the `kilogram` has scale factor of 1 in SI. # The current state of the code assumes SI unit dimensions, in # the future this module will be modified in order to be unit system-neutral # (that is, support all kinds of unit systems). kg = kilogram = kilograms = Quantity("kilogram", abbrev="kg") kilogram.set_dimension(mass) kilogram.set_scale_factor(One) s = second = seconds = Quantity("second", abbrev="s") second.set_dimension(time) second.set_scale_factor(One) A = ampere = amperes = Quantity("ampere", abbrev='A') ampere.set_dimension(current) ampere.set_scale_factor(One) K = kelvin = kelvins = Quantity("kelvin", abbrev='K') kelvin.set_dimension(temperature) kelvin.set_scale_factor(One) mol = mole = moles = Quantity("mole", abbrev="mol") mole.set_dimension(amount_of_substance) mole.set_scale_factor(One) cd = candela = candelas = Quantity("candela", abbrev="cd") candela.set_dimension(luminous_intensity) candela.set_scale_factor(One) g = gram = grams = Quantity("gram", abbrev="g") gram.set_dimension(mass) gram.set_scale_factor(kilogram/kilo) mg = milligram = milligrams = Quantity("milligram", abbrev="mg") milligram.set_dimension(mass) milligram.set_scale_factor(milli*gram) ug = microgram = micrograms = Quantity("microgram", abbrev="ug", latex_repr=r"\mu\text{g}") microgram.set_dimension(mass) microgram.set_scale_factor(micro*gram) # derived units newton = newtons = N = Quantity("newton", abbrev="N") newton.set_dimension(force) newton.set_scale_factor(kilogram*meter/second**2) joule = joules = J = Quantity("joule", abbrev="J") joule.set_dimension(energy) joule.set_scale_factor(newton*meter) watt = watts = W = Quantity("watt", abbrev="W") watt.set_dimension(power) watt.set_scale_factor(joule/second) pascal = pascals = Pa = pa = Quantity("pascal", abbrev="Pa") pascal.set_dimension(pressure) pascal.set_scale_factor(newton/meter**2) hertz = hz = Hz = Quantity("hertz", abbrev="Hz") hertz.set_dimension(frequency) hertz.set_scale_factor(One) # MKSA extension to MKS: derived units coulomb = coulombs = C = Quantity("coulomb", abbrev='C') coulomb.set_dimension(charge) coulomb.set_scale_factor(One) volt = volts = v = V = Quantity("volt", abbrev='V') volt.set_dimension(voltage) volt.set_scale_factor(joule/coulomb) ohm = ohms = Quantity("ohm", abbrev='ohm', latex_repr=r"\Omega") ohm.set_dimension(impedance) ohm.set_scale_factor(volt/ampere) siemens = S = mho = mhos = Quantity("siemens", abbrev='S') siemens.set_dimension(conductance) siemens.set_scale_factor(ampere/volt) farad = farads = F = Quantity("farad", abbrev='F') farad.set_dimension(capacitance) farad.set_scale_factor(coulomb/volt) henry = henrys = H = Quantity("henry", abbrev='H') henry.set_dimension(inductance) henry.set_scale_factor(volt*second/ampere) tesla = teslas = T = Quantity("tesla", abbrev='T') tesla.set_dimension(magnetic_density) tesla.set_scale_factor(volt*second/meter**2) weber = webers = Wb = wb = Quantity("weber", abbrev='Wb') weber.set_dimension(magnetic_flux) weber.set_scale_factor(joule/ampere) # Other derived units: optical_power = dioptre = diopter = D = Quantity("dioptre") dioptre.set_dimension(1/length) dioptre.set_scale_factor(1/meter) lux = lx = Quantity("lux", abbrev="lx") lux.set_dimension(luminous_intensity/length**2) lux.set_scale_factor(steradian*candela/meter**2) # katal is the SI unit of catalytic activity katal = kat = Quantity("katal", abbrev="kat") katal.set_dimension(amount_of_substance/time) katal.set_scale_factor(mol/second) # gray is the SI unit of absorbed dose gray = Gy = Quantity("gray") gray.set_dimension(energy/mass) gray.set_scale_factor(meter**2/second**2) # becquerel is the SI unit of radioactivity becquerel = Bq = Quantity("becquerel", abbrev="Bq") becquerel.set_dimension(1/time) becquerel.set_scale_factor(1/second) # Common length units km = kilometer = kilometers = Quantity("kilometer", abbrev="km") kilometer.set_dimension(length) kilometer.set_scale_factor(kilo*meter) dm = decimeter = decimeters = Quantity("decimeter", abbrev="dm") decimeter.set_dimension(length) decimeter.set_scale_factor(deci*meter) cm = centimeter = centimeters = Quantity("centimeter", abbrev="cm") centimeter.set_dimension(length) centimeter.set_scale_factor(centi*meter) mm = millimeter = millimeters = Quantity("millimeter", abbrev="mm") millimeter.set_dimension(length) millimeter.set_scale_factor(milli*meter) um = micrometer = micrometers = micron = microns = \ Quantity("micrometer", abbrev="um", latex_repr=r'\mu\text{m}') micrometer.set_dimension(length) micrometer.set_scale_factor(micro*meter) nm = nanometer = nanometers = Quantity("nanometer", abbrev="nm") nanometer.set_dimension(length) nanometer.set_scale_factor(nano*meter) pm = picometer = picometers = Quantity("picometer", abbrev="pm") picometer.set_dimension(length) picometer.set_scale_factor(pico*meter) ft = foot = feet = Quantity("foot", abbrev="ft") foot.set_dimension(length) foot.set_scale_factor(Rational(3048, 10000)*meter) inch = inches = Quantity("inch") inch.set_dimension(length) inch.set_scale_factor(foot/12) yd = yard = yards = Quantity("yard", abbrev="yd") yard.set_dimension(length) yard.set_scale_factor(3*feet) mi = mile = miles = Quantity("mile") mile.set_dimension(length) mile.set_scale_factor(5280*feet) nmi = nautical_mile = nautical_miles = Quantity("nautical_mile") nautical_mile.set_dimension(length) nautical_mile.set_scale_factor(6076*feet) # Common volume and area units l = liter = liters = Quantity("liter") liter.set_dimension(length**3) liter.set_scale_factor(meter**3 / 1000) dl = deciliter = deciliters = Quantity("deciliter") deciliter.set_dimension(length**3) deciliter.set_scale_factor(liter / 10) cl = centiliter = centiliters = Quantity("centiliter") centiliter.set_dimension(length**3) centiliter.set_scale_factor(liter / 100) ml = milliliter = milliliters = Quantity("milliliter") milliliter.set_dimension(length**3) milliliter.set_scale_factor(liter / 1000) # Common time units ms = millisecond = milliseconds = Quantity("millisecond", abbrev="ms") millisecond.set_dimension(time) millisecond.set_scale_factor(milli*second) us = microsecond = microseconds = Quantity("microsecond", abbrev="us", latex_repr=r'\mu\text{s}') microsecond.set_dimension(time) microsecond.set_scale_factor(micro*second) ns = nanosecond = nanoseconds = Quantity("nanosecond", abbrev="ns") nanosecond.set_dimension(time) nanosecond.set_scale_factor(nano*second) ps = picosecond = picoseconds = Quantity("picosecond", abbrev="ps") picosecond.set_dimension(time) picosecond.set_scale_factor(pico*second) minute = minutes = Quantity("minute") minute.set_dimension(time) minute.set_scale_factor(60*second) h = hour = hours = Quantity("hour") hour.set_dimension(time) hour.set_scale_factor(60*minute) day = days = Quantity("day") day.set_dimension(time) day.set_scale_factor(24*hour) anomalistic_year = anomalistic_years = Quantity("anomalistic_year") anomalistic_year.set_dimension(time) anomalistic_year.set_scale_factor(365.259636*day) sidereal_year = sidereal_years = Quantity("sidereal_year") sidereal_year.set_dimension(time) sidereal_year.set_scale_factor(31558149.540) tropical_year = tropical_years = Quantity("tropical_year") tropical_year.set_dimension(time) tropical_year.set_scale_factor(365.24219*day) common_year = common_years = Quantity("common_year") common_year.set_dimension(time) common_year.set_scale_factor(365*day) julian_year = julian_years = Quantity("julian_year") julian_year.set_dimension(time) julian_year.set_scale_factor((365 + One/4)*day) draconic_year = draconic_years = Quantity("draconic_year") draconic_year.set_dimension(time) draconic_year.set_scale_factor(346.62*day) gaussian_year = gaussian_years = Quantity("gaussian_year") gaussian_year.set_dimension(time) gaussian_year.set_scale_factor(365.2568983*day) full_moon_cycle = full_moon_cycles = Quantity("full_moon_cycle") full_moon_cycle.set_dimension(time) full_moon_cycle.set_scale_factor(411.78443029*day) year = years = tropical_year #### CONSTANTS #### # Newton constant G = gravitational_constant = Quantity("gravitational_constant", abbrev="G") gravitational_constant.set_dimension(length**3*mass**-1*time**-2) gravitational_constant.set_scale_factor(6.67408e-11*m**3/(kg*s**2)) # speed of light c = speed_of_light = Quantity("speed_of_light", abbrev="c") speed_of_light.set_dimension(velocity) speed_of_light.set_scale_factor(299792458*meter/second) # Reduced Planck constant hbar = Quantity("hbar", abbrev="hbar") hbar.set_dimension(action) hbar.set_scale_factor(1.05457266e-34*joule*second) # Planck constant planck = Quantity("planck", abbrev="h") planck.set_dimension(action) planck.set_scale_factor(2*pi*hbar) # Electronvolt eV = electronvolt = electronvolts = Quantity("electronvolt", abbrev="eV") electronvolt.set_dimension(energy) electronvolt.set_scale_factor(1.60219e-19*joule) # Avogadro number avogadro_number = Quantity("avogadro_number") avogadro_number.set_dimension(One) avogadro_number.set_scale_factor(6.022140857e23) # Avogadro constant avogadro = avogadro_constant = Quantity("avogadro_constant") avogadro_constant.set_dimension(amount_of_substance**-1) avogadro_constant.set_scale_factor(avogadro_number / mol) # Boltzmann constant boltzmann = boltzmann_constant = Quantity("boltzmann_constant") boltzmann_constant.set_dimension(energy/temperature) boltzmann_constant.set_scale_factor(1.38064852e-23*joule/kelvin) # Stefan-Boltzmann constant stefan = stefan_boltzmann_constant = Quantity("stefan_boltzmann_constant") stefan_boltzmann_constant.set_dimension(energy*time**-1*length**-2*temperature**-4) stefan_boltzmann_constant.set_scale_factor(5.670367e-8*joule/(s*m**2*kelvin**4)) # Atomic mass amu = amus = atomic_mass_unit = atomic_mass_constant = Quantity("atomic_mass_constant") atomic_mass_constant.set_dimension(mass) atomic_mass_constant.set_scale_factor(1.660539040e-24*gram) # Molar gas constant R = molar_gas_constant = Quantity("molar_gas_constant", abbrev="R") molar_gas_constant.set_dimension(energy/(temperature * amount_of_substance)) molar_gas_constant.set_scale_factor(8.3144598*joule/kelvin/mol) # Faraday constant faraday_constant = Quantity("faraday_constant") faraday_constant.set_dimension(charge/amount_of_substance) faraday_constant.set_scale_factor(96485.33289*C/mol) # Josephson constant josephson_constant = Quantity("josephson_constant", abbrev="K_j") josephson_constant.set_dimension(frequency/voltage) josephson_constant.set_scale_factor(483597.8525e9*hertz/V) # Von Klitzing constant von_klitzing_constant = Quantity("von_klitzing_constant", abbrev="R_k") von_klitzing_constant.set_dimension(voltage/current) von_klitzing_constant.set_scale_factor(25812.8074555*ohm) # Acceleration due to gravity (on the Earth surface) gee = gees = acceleration_due_to_gravity = Quantity("acceleration_due_to_gravity", abbrev="g") acceleration_due_to_gravity.set_dimension(acceleration) acceleration_due_to_gravity.set_scale_factor(9.80665*meter/second**2) # magnetic constant: u0 = magnetic_constant = vacuum_permeability = Quantity("magnetic_constant") magnetic_constant.set_dimension(force/current**2) magnetic_constant.set_scale_factor(4*pi/10**7 * newton/ampere**2) # electric constat: e0 = electric_constant = vacuum_permittivity = Quantity("vacuum_permittivity") vacuum_permittivity.set_dimension(capacitance/length) vacuum_permittivity.set_scale_factor(1/(u0 * c**2)) # vacuum impedance: Z0 = vacuum_impedance = Quantity("vacuum_impedance", abbrev='Z_0', latex_repr=r'Z_{0}') vacuum_impedance.set_dimension(impedance) vacuum_impedance.set_scale_factor(u0 * c) # Coulomb's constant: coulomb_constant = coulombs_constant = electric_force_constant = \ Quantity("coulomb_constant", abbrev="k_e") coulomb_constant.set_dimension(force*length**2/charge**2) coulomb_constant.set_scale_factor(1/(4*pi*vacuum_permittivity)) atmosphere = atmospheres = atm = Quantity("atmosphere", abbrev="atm") atmosphere.set_dimension(pressure) atmosphere.set_scale_factor(101325 * pascal) kPa = kilopascal = Quantity("kilopascal", abbrev="kPa") kilopascal.set_dimension(pressure) kilopascal.set_scale_factor(kilo*Pa) bar = bars = Quantity("bar", abbrev="bar") bar.set_dimension(pressure) bar.set_scale_factor(100*kPa) pound = pounds = Quantity("pound") # exact pound.set_dimension(mass) pound.set_scale_factor(Rational(45359237, 100000000) * kg) psi = Quantity("psi") psi.set_dimension(pressure) psi.set_scale_factor(pound * gee / inch ** 2) dHg0 = 13.5951 # approx value at 0 C mmHg = torr = Quantity("mmHg") mmHg.set_dimension(pressure) mmHg.set_scale_factor(dHg0 * acceleration_due_to_gravity * kilogram / meter**2) mmu = mmus = milli_mass_unit = Quantity("milli_mass_unit") milli_mass_unit.set_dimension(mass) milli_mass_unit.set_scale_factor(atomic_mass_unit/1000) quart = quarts = Quantity("quart") quart.set_dimension(length**3) quart.set_scale_factor(Rational(231, 4) * inch**3) # Other convenient units and magnitudes ly = lightyear = lightyears = Quantity("lightyear", abbrev="ly") lightyear.set_dimension(length) lightyear.set_scale_factor(speed_of_light*julian_year) au = astronomical_unit = astronomical_units = Quantity("astronomical_unit", abbrev="AU") astronomical_unit.set_dimension(length) astronomical_unit.set_scale_factor(149597870691*meter) # Fundamental Planck units: planck_mass = Quantity("planck_mass", abbrev="m_P", latex_repr=r'm_\text{P}') planck_mass.set_dimension(mass) planck_mass.set_scale_factor(sqrt(hbar*speed_of_light/G)) planck_time = Quantity("planck_time", abbrev="t_P", latex_repr=r't_\text{P}') planck_time.set_dimension(time) planck_time.set_scale_factor(sqrt(hbar*G/speed_of_light**5)) planck_temperature = Quantity("planck_temperature", abbrev="T_P", latex_repr=r'T_\text{P}') planck_temperature.set_dimension(temperature) planck_temperature.set_scale_factor(sqrt(hbar*speed_of_light**5/G/boltzmann**2)) planck_length = Quantity("planck_length", abbrev="l_P", latex_repr=r'l_\text{P}') planck_length.set_dimension(length) planck_length.set_scale_factor(sqrt(hbar*G/speed_of_light**3)) planck_charge = Quantity("planck_charge", abbrev="q_P", latex_repr=r'q_\text{P}') planck_charge.set_dimension(charge) planck_charge.set_scale_factor(sqrt(4*pi*electric_constant*hbar*speed_of_light)) # Derived Planck units: planck_area = Quantity("planck_area") planck_area.set_dimension(length**2) planck_area.set_scale_factor(planck_length**2) planck_volume = Quantity("planck_volume") planck_volume.set_dimension(length**3) planck_volume.set_scale_factor(planck_length**3) planck_momentum = Quantity("planck_momentum") planck_momentum.set_dimension(mass*velocity) planck_momentum.set_scale_factor(planck_mass * speed_of_light) planck_energy = Quantity("planck_energy", abbrev="E_P", latex_repr=r'E_\text{P}') planck_energy.set_dimension(energy) planck_energy.set_scale_factor(planck_mass * speed_of_light**2) planck_force = Quantity("planck_force", abbrev="F_P", latex_repr=r'F_\text{P}') planck_force.set_dimension(force) planck_force.set_scale_factor(planck_energy / planck_length) planck_power = Quantity("planck_power", abbrev="P_P", latex_repr=r'P_\text{P}') planck_power.set_dimension(power) planck_power.set_scale_factor(planck_energy / planck_time) planck_density = Quantity("planck_density", abbrev="rho_P", latex_repr=r'\rho_\text{P}') planck_density.set_dimension(mass/length**3) planck_density.set_scale_factor(planck_mass / planck_length**3) planck_energy_density = Quantity("planck_energy_density", abbrev="rho^E_P") planck_energy_density.set_dimension(energy / length**3) planck_energy_density.set_scale_factor(planck_energy / planck_length**3) planck_intensity = Quantity("planck_intensity", abbrev="I_P", latex_repr=r'I_\text{P}') planck_intensity.set_dimension(mass * time**(-3)) planck_intensity.set_scale_factor(planck_energy_density * speed_of_light) planck_angular_frequency = Quantity("planck_angular_frequency", abbrev="omega_P", latex_repr=r'\omega_\text{P}') planck_angular_frequency.set_dimension(1 / time) planck_angular_frequency.set_scale_factor(1 / planck_time) planck_pressure = Quantity("planck_pressure", abbrev="p_P", latex_repr=r'p_\text{P}') planck_pressure.set_dimension(pressure) planck_pressure.set_scale_factor(planck_force / planck_length**2) planck_current = Quantity("planck_current", abbrev="I_P", latex_repr=r'I_\text{P}') planck_current.set_dimension(current) planck_current.set_scale_factor(planck_charge / planck_time) planck_voltage = Quantity("planck_voltage", abbrev="V_P", latex_repr=r'V_\text{P}') planck_voltage.set_dimension(voltage) planck_voltage.set_scale_factor(planck_energy / planck_charge) planck_impedance = Quantity("planck_impedance", abbrev="Z_P", latex_repr=r'Z_\text{P}') planck_impedance.set_dimension(impedance) planck_impedance.set_scale_factor(planck_voltage / planck_current) planck_acceleration = Quantity("planck_acceleration", abbrev="a_P", latex_repr=r'a_\text{P}') planck_acceleration.set_dimension(acceleration) planck_acceleration.set_scale_factor(speed_of_light / planck_time) # Information theory units: bit = bits = Quantity("bit") bit.set_dimension(information) bit.set_scale_factor(One) byte = bytes = Quantity("byte") byte.set_dimension(information) byte.set_scale_factor(8*bit) kibibyte = kibibytes = Quantity("kibibyte") kibibyte.set_dimension(information) kibibyte.set_scale_factor(kibi*byte) mebibyte = mebibytes = Quantity("mebibyte") mebibyte.set_dimension(information) mebibyte.set_scale_factor(mebi*byte) gibibyte = gibibytes = Quantity("gibibyte") gibibyte.set_dimension(information) gibibyte.set_scale_factor(gibi*byte) tebibyte = tebibytes = Quantity("tebibyte") tebibyte.set_dimension(information) tebibyte.set_scale_factor(tebi*byte) pebibyte = pebibytes = Quantity("pebibyte") pebibyte.set_dimension(information) pebibyte.set_scale_factor(pebi*byte) exbibyte = exbibytes = Quantity("exbibyte") exbibyte.set_dimension(information) exbibyte.set_scale_factor(exbi*byte) # Older units for radioactivity curie = Ci = Quantity("curie", abbrev="Ci") curie.set_dimension(1/time) curie.set_scale_factor(37000000000*becquerel) rutherford = Rd = Quantity("rutherford", abbrev="Rd") rutherford.set_dimension(1/time) rutherford.set_scale_factor(1000000*becquerel) # check that scale factors are the right SI dimensions: for _scale_factor, _dimension in zip( Quantity.SI_quantity_scale_factors.values(), Quantity.SI_quantity_dimension_map.values()): dimex = Quantity.get_dimensional_expr(_scale_factor) if dimex != 1: if not dimsys_default.equivalent_dims(_dimension, Dimension(dimex)): raise ValueError("quantity value and dimension mismatch") del _scale_factor, _dimension
09712b76f8010af32a09016e52da4a4caf0603b7d513ee98e71eb746e66d30b5
""" Unit system for physical quantities; include definition of constants. """ from __future__ import division from sympy.utilities.exceptions import SymPyDeprecationWarning from .dimensions import DimensionSystem class UnitSystem(object): """ UnitSystem represents a coherent set of units. A unit system is basically a dimension system with notions of scales. Many of the methods are defined in the same way. It is much better if all base units have a symbol. """ def __init__(self, base, units=(), name="", descr=""): self.name = name self.descr = descr # construct the associated dimension system base_dims = [u.dimension for u in base] derived_dims = [u.dimension for u in units if u.dimension not in base_dims] self._system = DimensionSystem(base_dims, derived_dims) if not self.is_consistent: raise ValueError("UnitSystem is not consistent") self._units = tuple(set(base) | set(units)) # create a dict linkin # this is possible since we have already verified that the base units # form a coherent system base_dict = dict((u.dimension, u) for u in base) # order the base units in the same order than the dimensions in the # associated system, in order to ensure that we get always the same self._base_units = tuple(base_dict[d] for d in self._system.base_dims) def __str__(self): """ Return the name of the system. If it does not exist, then it makes a list of symbols (or names) of the base dimensions. """ if self.name != "": return self.name else: return "UnitSystem((%s))" % ", ".join( str(d) for d in self._base_units) def __repr__(self): return '<UnitSystem: %s>' % repr(self._base_units) def extend(self, base, units=(), name="", description=""): """Extend the current system into a new one. Take the base and normal units of the current system to merge them to the base and normal units given in argument. If not provided, name and description are overridden by empty strings. """ base = self._base_units + tuple(base) units = self._units + tuple(units) return UnitSystem(base, units, name, description) def print_unit_base(self, unit): """ Useless method. DO NOT USE, use instead ``convert_to``. Give the string expression of a unit in term of the basis. Units are displayed by decreasing power. """ SymPyDeprecationWarning( deprecated_since_version="1.2", issue=13336, feature="print_unit_base", useinstead="convert_to", ).warn() from sympy.physics.units import convert_to return convert_to(unit, self._base_units) @property def dim(self): """ Give the dimension of the system. That is return the number of units forming the basis. """ return self._system.dim @property def is_consistent(self): """ Check if the underlying dimension system is consistent. """ # test is performed in DimensionSystem return self._system.is_consistent
fde34f1112e31d54c8c933cb5a6c57f1c3706d0188015f42a80ade5e6f484066
""" Definition of physical dimensions. Unit systems will be constructed on top of these dimensions. Most of the examples in the doc use MKS system and are presented from the computer point of view: from a human point, adding length to time is not legal in MKS but it is in natural system; for a computer in natural system there is no time dimension (but a velocity dimension instead) - in the basis - so the question of adding time to length has no meaning. """ from __future__ import division import collections from sympy import Integer, Matrix, S, Symbol, sympify, Basic, Tuple, Dict, default_sort_key from sympy.core.compatibility import reduce, string_types from sympy.core.expr import Expr from sympy.core.power import Pow from sympy.utilities.exceptions import SymPyDeprecationWarning class Dimension(Expr): """ This class represent the dimension of a physical quantities. The ``Dimension`` constructor takes as parameters a name and an optional symbol. For example, in classical mechanics we know that time is different from temperature and dimensions make this difference (but they do not provide any measure of these quantites. >>> from sympy.physics.units import Dimension >>> length = Dimension('length') >>> length Dimension(length) >>> time = Dimension('time') >>> time Dimension(time) Dimensions can be composed using multiplication, division and exponentiation (by a number) to give new dimensions. Addition and subtraction is defined only when the two objects are the same dimension. >>> velocity = length / time >>> velocity Dimension(length/time) It is possible to use a dimension system object to get the dimensionsal dependencies of a dimension, for example the dimension system used by the SI units convention can be used: >>> from sympy.physics.units.dimensions import dimsys_SI >>> dimsys_SI.get_dimensional_dependencies(velocity) {'length': 1, 'time': -1} >>> length + length Dimension(length) >>> l2 = length**2 >>> l2 Dimension(length**2) >>> dimsys_SI.get_dimensional_dependencies(l2) {'length': 2} """ _op_priority = 13.0 _dimensional_dependencies = dict() is_commutative = True is_number = False # make sqrt(M**2) --> M is_positive = True is_real = True def __new__(cls, name, symbol=None): if isinstance(name, string_types): name = Symbol(name) else: name = sympify(name) if not isinstance(name, Expr): raise TypeError("Dimension name needs to be a valid math expression") if isinstance(symbol, string_types): symbol = Symbol(symbol) elif symbol is not None: assert isinstance(symbol, Symbol) if symbol is not None: obj = Expr.__new__(cls, name, symbol) else: obj = Expr.__new__(cls, name) obj._name = name obj._symbol = symbol return obj @property def name(self): return self._name @property def symbol(self): return self._symbol def __hash__(self): return Expr.__hash__(self) def __eq__(self, other): if isinstance(other, Dimension): return self.name == other.name return False def __str__(self): """ Display the string representation of the dimension. """ if self.symbol is None: return "Dimension(%s)" % (self.name) else: return "Dimension(%s, %s)" % (self.name, self.symbol) def __repr__(self): return self.__str__() def __neg__(self): return self def _register_as_base_dim(self): SymPyDeprecationWarning( deprecated_since_version="1.2", issue=13336, feature="do not call ._register_as_base_dim()", useinstead="DimensionSystem" ).warn() if not self.name.is_Symbol: raise TypeError("Base dimensions need to have symbolic name") name = self.name if name in dimsys_default.dimensional_dependencies: raise IndexError("already in dependencies dict") # Horrible code: d = dict(dimsys_default.dimensional_dependencies) d[name] = Dict({name: 1}) dimsys_default._args = (dimsys_default.args[:2] + (Dict(d),)) def __add__(self, other): from sympy.physics.units.quantities import Quantity other = sympify(other) if isinstance(other, Basic): if other.has(Quantity): other = Dimension(Quantity.get_dimensional_expr(other)) if isinstance(other, Dimension) and self == other: return self return super(Dimension, self).__add__(other) return self def __radd__(self, other): return self + other def __sub__(self, other): # there is no notion of ordering (or magnitude) among dimension, # subtraction is equivalent to addition when the operation is legal return self + other def __rsub__(self, other): # there is no notion of ordering (or magnitude) among dimension, # subtraction is equivalent to addition when the operation is legal return self + other def __pow__(self, other): return self._eval_power(other) def _eval_power(self, other): other = sympify(other) return Dimension(self.name**other) def __mul__(self, other): from sympy.physics.units.quantities import Quantity if isinstance(other, Basic): if other.has(Quantity): other = Dimension(Quantity.get_dimensional_expr(other)) if isinstance(other, Dimension): return Dimension(self.name*other.name) if not other.free_symbols: # other.is_number cannot be used return self return super(Dimension, self).__mul__(other) return self def __rmul__(self, other): return self*other def __div__(self, other): return self*Pow(other, -1) def __rdiv__(self, other): return other * pow(self, -1) __truediv__ = __div__ __rtruediv__ = __rdiv__ def get_dimensional_dependencies(self, mark_dimensionless=False): SymPyDeprecationWarning( deprecated_since_version="1.2", issue=13336, feature="do not call", useinstead="DimensionSystem" ).warn() name = self.name dimdep = dimsys_default.get_dimensional_dependencies(name) if mark_dimensionless and dimdep == {}: return {'dimensionless': 1} return {str(i): j for i, j in dimdep.items()} @classmethod def _from_dimensional_dependencies(cls, dependencies): return reduce(lambda x, y: x * y, ( Dimension(d)**e for d, e in dependencies.items() )) @classmethod def _get_dimensional_dependencies_for_name(cls, name): SymPyDeprecationWarning( deprecated_since_version="1.2", issue=13336, feature="do not call from `Dimension` objects.", useinstead="DimensionSystem" ).warn() return dimsys_default.get_dimensional_dependencies(name) @property def is_dimensionless(self, dimensional_dependencies=None): """ Check if the dimension object really has a dimension. A dimension should have at least one component with non-zero power. """ if self.name == 1: return True if dimensional_dependencies is None: SymPyDeprecationWarning( deprecated_since_version="1.2", issue=13336, feature="wrong class", ).warn() dimensional_dependencies=dimsys_default return dimensional_dependencies.get_dimensional_dependencies(self) == {} def has_integer_powers(self, dim_sys): """ Check if the dimension object has only integer powers. All the dimension powers should be integers, but rational powers may appear in intermediate steps. This method may be used to check that the final result is well-defined. """ for dpow in dim_sys.get_dimensional_dependencies(self).values(): if not isinstance(dpow, (int, Integer)): return False return True # base dimensions (MKS) length = Dimension(name="length", symbol="L") mass = Dimension(name="mass", symbol="M") time = Dimension(name="time", symbol="T") # base dimensions (MKSA not in MKS) current = Dimension(name='current', symbol='I') # other base dimensions: temperature = Dimension("temperature", "T") amount_of_substance = Dimension("amount_of_substance") luminous_intensity = Dimension("luminous_intensity") # derived dimensions (MKS) velocity = Dimension(name="velocity") acceleration = Dimension(name="acceleration") momentum = Dimension(name="momentum") force = Dimension(name="force", symbol="F") energy = Dimension(name="energy", symbol="E") power = Dimension(name="power") pressure = Dimension(name="pressure") frequency = Dimension(name="frequency", symbol="f") action = Dimension(name="action", symbol="A") volume = Dimension("volume") # derived dimensions (MKSA not in MKS) voltage = Dimension(name='voltage', symbol='U') impedance = Dimension(name='impedance', symbol='Z') conductance = Dimension(name='conductance', symbol='G') capacitance = Dimension(name='capacitance') inductance = Dimension(name='inductance') charge = Dimension(name='charge', symbol='Q') magnetic_density = Dimension(name='magnetic_density', symbol='B') magnetic_flux = Dimension(name='magnetic_flux') # Dimensions in information theory: information = Dimension(name='information') # Create dimensions according the the base units in MKSA. # For other unit systems, they can be derived by transforming the base # dimensional dependency dictionary. class DimensionSystem(Basic): r""" DimensionSystem represents a coherent set of dimensions. The constructor takes three parameters: - base dimensions; - derived dimensions: these are defined in terms of the base dimensions (for example velocity is defined from the division of length by time); - dependency of dimensions: how the derived dimensions depend on the base dimensions. Optionally either the ``derived_dims`` or the ``dimensional_dependencies`` may be omitted. """ def __new__(cls, base_dims, derived_dims=[], dimensional_dependencies={}, name=None, descr=None): dimensional_dependencies = dict(dimensional_dependencies) if (name is not None) or (descr is not None): SymPyDeprecationWarning( deprecated_since_version="1.2", issue=13336, useinstead="do not define a `name` or `descr`", ).warn() def parse_dim(dim): if isinstance(dim, string_types): dim = Dimension(Symbol(dim)) elif isinstance(dim, Dimension): pass elif isinstance(dim, Symbol): dim = Dimension(dim) else: raise TypeError("%s wrong type" % dim) return dim base_dims = [parse_dim(i) for i in base_dims] derived_dims = [parse_dim(i) for i in derived_dims] for dim in base_dims: dim = dim.name if (dim in dimensional_dependencies and (len(dimensional_dependencies[dim]) != 1 or dimensional_dependencies[dim].get(dim, None) != 1)): raise IndexError("Repeated value in base dimensions") dimensional_dependencies[dim] = Dict({dim: 1}) def parse_dim_name(dim): if isinstance(dim, Dimension): return dim.name elif isinstance(dim, string_types): return Symbol(dim) elif isinstance(dim, Symbol): return dim else: raise TypeError("unrecognized type %s for %s" % (type(dim), dim)) for dim in dimensional_dependencies.keys(): dim = parse_dim(dim) if (dim not in derived_dims) and (dim not in base_dims): derived_dims.append(dim) def parse_dict(d): return Dict({parse_dim_name(i): j for i, j in d.items()}) # Make sure everything is a SymPy type: dimensional_dependencies = {parse_dim_name(i): parse_dict(j) for i, j in dimensional_dependencies.items()} for dim in derived_dims: if dim in base_dims: raise ValueError("Dimension %s both in base and derived" % dim) if dim.name not in dimensional_dependencies: # TODO: should this raise a warning? dimensional_dependencies[dim] = Dict({dim.name: 1}) base_dims.sort(key=default_sort_key) derived_dims.sort(key=default_sort_key) base_dims = Tuple(*base_dims) derived_dims = Tuple(*derived_dims) dimensional_dependencies = Dict({i: Dict(j) for i, j in dimensional_dependencies.items()}) obj = Basic.__new__(cls, base_dims, derived_dims, dimensional_dependencies) return obj @property def base_dims(self): return self.args[0] @property def derived_dims(self): return self.args[1] @property def dimensional_dependencies(self): return self.args[2] def _get_dimensional_dependencies_for_name(self, name): if name.is_Symbol: return dict(self.dimensional_dependencies.get(name, {})) if name.is_Number: return {} get_for_name = dimsys_default._get_dimensional_dependencies_for_name if name.is_Mul: ret = collections.defaultdict(int) dicts = [get_for_name(i) for i in name.args] for d in dicts: for k, v in d.items(): ret[k] += v return {k: v for (k, v) in ret.items() if v != 0} if name.is_Pow: dim = get_for_name(name.base) return {k: v*name.exp for (k, v) in dim.items()} if name.is_Function: args = (Dimension._from_dimensional_dependencies( get_for_name(arg)) for arg in name.args) result = name.func(*args) if isinstance(result, Dimension): return dimsys_default.get_dimensional_dependencies(result) elif result.func == name.func: return {} else: return get_for_name(result) def get_dimensional_dependencies(self, name, mark_dimensionless=False): if isinstance(name, Dimension): name = name.name if isinstance(name, string_types): name = Symbol(name) dimdep = self._get_dimensional_dependencies_for_name(name) if mark_dimensionless and dimdep == {}: return {'dimensionless': 1} return {str(i): j for i, j in dimdep.items()} def equivalent_dims(self, dim1, dim2): deps1 = self.get_dimensional_dependencies(dim1) deps2 = self.get_dimensional_dependencies(dim2) return deps1 == deps2 def extend(self, new_base_dims, new_derived_dims=[], new_dim_deps={}, name=None, description=None): if (name is not None) or (description is not None): SymPyDeprecationWarning( deprecated_since_version="1.2", issue=13336, feature="name and descriptions of DimensionSystem", useinstead="do not specify `name` or `description`", ).warn() deps = dict(self.dimensional_dependencies) deps.update(new_dim_deps) return DimensionSystem( tuple(self.base_dims) + tuple(new_base_dims), tuple(self.derived_dims) + tuple(new_derived_dims), deps ) @staticmethod def sort_dims(dims): """ Useless method, kept for compatibility with previous versions. DO NOT USE. Sort dimensions given in argument using their str function. This function will ensure that we get always the same tuple for a given set of dimensions. """ SymPyDeprecationWarning( deprecated_since_version="1.2", issue=13336, feature="sort_dims", useinstead="sorted(..., key=default_sort_key)", ).warn() return tuple(sorted(dims, key=str)) def __getitem__(self, key): """ Useless method, kept for compatibility with previous versions. DO NOT USE. Shortcut to the get_dim method, using key access. """ SymPyDeprecationWarning( deprecated_since_version="1.2", issue=13336, feature="the get [ ] operator", useinstead="the dimension definition", ).warn() d = self.get_dim(key) #TODO: really want to raise an error? if d is None: raise KeyError(key) return d def __call__(self, unit): """ Useless method, kept for compatibility with previous versions. DO NOT USE. Wrapper to the method print_dim_base """ SymPyDeprecationWarning( deprecated_since_version="1.2", issue=13336, feature="call DimensionSystem", useinstead="the dimension definition", ).warn() return self.print_dim_base(unit) def is_dimensionless(self, dimension): """ Check if the dimension object really has a dimension. A dimension should have at least one component with non-zero power. """ if dimension.name == 1: return True return self.get_dimensional_dependencies(dimension) == {} @property def list_can_dims(self): """ Useless method, kept for compatibility with previous versions. DO NOT USE. List all canonical dimension names. """ dimset = set([]) for i in self.base_dims: dimset.update(set(dimsys_default.get_dimensional_dependencies(i).keys())) return tuple(sorted(dimset, key=str)) @property def inv_can_transf_matrix(self): """ Useless method, kept for compatibility with previous versions. DO NOT USE. Compute the inverse transformation matrix from the base to the canonical dimension basis. It corresponds to the matrix where columns are the vector of base dimensions in canonical basis. This matrix will almost never be used because dimensions are always defined with respect to the canonical basis, so no work has to be done to get them in this basis. Nonetheless if this matrix is not square (or not invertible) it means that we have chosen a bad basis. """ matrix = reduce(lambda x, y: x.row_join(y), [self.dim_can_vector(d) for d in self.base_dims]) return matrix @property def can_transf_matrix(self): """ Useless method, kept for compatibility with previous versions. DO NOT USE. Return the canonical transformation matrix from the canonical to the base dimension basis. It is the inverse of the matrix computed with inv_can_transf_matrix(). """ #TODO: the inversion will fail if the system is inconsistent, for # example if the matrix is not a square return reduce(lambda x, y: x.row_join(y), [self.dim_can_vector(d) for d in sorted(self.base_dims, key=str)] ).inv() def dim_can_vector(self, dim): """ Useless method, kept for compatibility with previous versions. DO NOT USE. Dimensional representation in terms of the canonical base dimensions. """ vec = [] for d in self.list_can_dims: vec.append(dimsys_default.get_dimensional_dependencies(dim).get(d, 0)) return Matrix(vec) def dim_vector(self, dim): """ Useless method, kept for compatibility with previous versions. DO NOT USE. Vector representation in terms of the base dimensions. """ return self.can_transf_matrix * Matrix(self.dim_can_vector(dim)) def print_dim_base(self, dim): """ Give the string expression of a dimension in term of the basis symbols. """ dims = self.dim_vector(dim) symbols = [i.symbol if i.symbol is not None else i.name for i in self.base_dims] res = S.One for (s, p) in zip(symbols, dims): res *= s**p return res @property def dim(self): """ Useless method, kept for compatibility with previous versions. DO NOT USE. Give the dimension of the system. That is return the number of dimensions forming the basis. """ return len(self.base_dims) @property def is_consistent(self): """ Useless method, kept for compatibility with previous versions. DO NOT USE. Check if the system is well defined. """ # not enough or too many base dimensions compared to independent # dimensions # in vector language: the set of vectors do not form a basis return self.inv_can_transf_matrix.is_square dimsys_MKS = DimensionSystem([ # Dimensional dependencies for MKS base dimensions length, mass, time, ], dimensional_dependencies=dict( # Dimensional dependencies for derived dimensions velocity=dict(length=1, time=-1), acceleration=dict(length=1, time=-2), momentum=dict(mass=1, length=1, time=-1), force=dict(mass=1, length=1, time=-2), energy=dict(mass=1, length=2, time=-2), power=dict(length=2, mass=1, time=-3), pressure=dict(mass=1, length=-1, time=-2), frequency=dict(time=-1), action=dict(length=2, mass=1, time=-1), volume=dict(length=3), )) dimsys_MKSA = dimsys_MKS.extend([ # Dimensional dependencies for base dimensions (MKSA not in MKS) current, ], new_dim_deps=dict( # Dimensional dependencies for derived dimensions voltage=dict(mass=1, length=2, current=-1, time=-3), impedance=dict(mass=1, length=2, current=-2, time=-3), conductance=dict(mass=-1, length=-2, current=2, time=3), capacitance=dict(mass=-1, length=-2, current=2, time=4), inductance=dict(mass=1, length=2, current=-2, time=-2), charge=dict(current=1, time=1), magnetic_density=dict(mass=1, current=-1, time=-2), magnetic_flux=dict(length=2, mass=1, current=-1, time=-2), )) dimsys_SI = dimsys_MKSA.extend( [ # Dimensional dependencies for other base dimensions: temperature, amount_of_substance, luminous_intensity, ]) dimsys_default = dimsys_SI.extend( [information], )
c91c1c7198fcc3ab63b20bc2204b0046096664edcc7313af023bfac114816d61
""" Several methods to simplify expressions involving unit objects. """ from __future__ import division from sympy.utilities.exceptions import SymPyDeprecationWarning from sympy import Add, Mul, Pow, Tuple, sympify from sympy.core.compatibility import reduce, Iterable, ordered from sympy.physics.units.dimensions import Dimension, dimsys_default from sympy.physics.units.prefixes import Prefix from sympy.physics.units.quantities import Quantity from sympy.utilities.iterables import sift def dim_simplify(expr): """ NOTE: this function could be deprecated in the future. Simplify expression by recursively evaluating the dimension arguments. This function proceeds to a very rough dimensional analysis. It tries to simplify expression with dimensions, and it deletes all what multiplies a dimension without being a dimension. This is necessary to avoid strange behavior when Add(L, L) be transformed into Mul(2, L). """ SymPyDeprecationWarning( deprecated_since_version="1.2", feature="dimensional simplification function", issue=13336, useinstead="don't use", ).warn() _, expr = Quantity._collect_factor_and_dimension(expr) return expr def _get_conversion_matrix_for_expr(expr, target_units): from sympy import Matrix expr_dim = Dimension(Quantity.get_dimensional_expr(expr)) dim_dependencies = dimsys_default.get_dimensional_dependencies(expr_dim, mark_dimensionless=True) target_dims = [Dimension(Quantity.get_dimensional_expr(x)) for x in target_units] canon_dim_units = {i for x in target_dims for i in dimsys_default.get_dimensional_dependencies(x, mark_dimensionless=True)} canon_expr_units = {i for i in dim_dependencies} if not canon_expr_units.issubset(canon_dim_units): return None canon_dim_units = sorted(canon_dim_units) camat = Matrix([[dimsys_default.get_dimensional_dependencies(i, mark_dimensionless=True).get(j, 0) for i in target_dims] for j in canon_dim_units]) exprmat = Matrix([dim_dependencies.get(k, 0) for k in canon_dim_units]) res_exponents = camat.solve_least_squares(exprmat, method=None) return res_exponents def convert_to(expr, target_units): """ Convert ``expr`` to the same expression with all of its units and quantities represented as factors of ``target_units``, whenever the dimension is compatible. ``target_units`` may be a single unit/quantity, or a collection of units/quantities. Examples ======== >>> from sympy.physics.units import speed_of_light, meter, gram, second, day >>> from sympy.physics.units import mile, newton, kilogram, atomic_mass_constant >>> from sympy.physics.units import kilometer, centimeter >>> from sympy.physics.units import convert_to >>> convert_to(mile, kilometer) 25146*kilometer/15625 >>> convert_to(mile, kilometer).n() 1.609344*kilometer >>> convert_to(speed_of_light, meter/second) 299792458*meter/second >>> convert_to(day, second) 86400*second >>> 3*newton 3*newton >>> convert_to(3*newton, kilogram*meter/second**2) 3*kilogram*meter/second**2 >>> convert_to(atomic_mass_constant, gram) 1.66053904e-24*gram Conversion to multiple units: >>> convert_to(speed_of_light, [meter, second]) 299792458*meter/second >>> convert_to(3*newton, [centimeter, gram, second]) 300000*centimeter*gram/second**2 Conversion to Planck units: >>> from sympy.physics.units import gravitational_constant, hbar >>> convert_to(atomic_mass_constant, [gravitational_constant, speed_of_light, hbar]).n() 7.62950196312651e-20*gravitational_constant**(-0.5)*hbar**0.5*speed_of_light**0.5 """ if not isinstance(target_units, (Iterable, Tuple)): target_units = [target_units] if isinstance(expr, Add): return Add.fromiter(convert_to(i, target_units) for i in expr.args) expr = sympify(expr) if not isinstance(expr, Quantity) and expr.has(Quantity): expr = expr.replace(lambda x: isinstance(x, Quantity), lambda x: x.convert_to(target_units)) def get_total_scale_factor(expr): if isinstance(expr, Mul): return reduce(lambda x, y: x * y, [get_total_scale_factor(i) for i in expr.args]) elif isinstance(expr, Pow): return get_total_scale_factor(expr.base) ** expr.exp elif isinstance(expr, Quantity): return expr.scale_factor return expr depmat = _get_conversion_matrix_for_expr(expr, target_units) if depmat is None: return expr expr_scale_factor = get_total_scale_factor(expr) return expr_scale_factor * Mul.fromiter((1/get_total_scale_factor(u) * u) ** p for u, p in zip(target_units, depmat)) def quantity_simplify(expr): """Return an equivalent expression in which prefixes are replaced with numerical values and all units of a given dimension are the unified in a canonical manner. Examples ======== >>> from sympy.physics.units.util import quantity_simplify >>> from sympy.physics.units.prefixes import kilo >>> from sympy.physics.units import foot, inch >>> quantity_simplify(kilo*foot*inch) 250*foot**2/3 >>> quantity_simplify(foot - 6*inch) foot/2 """ if expr.is_Atom or not expr.has(Prefix, Quantity): return expr # replace all prefixes with numerical values p = expr.atoms(Prefix) expr = expr.xreplace({p: p.scale_factor for p in p}) # replace all quantities of given dimension with a canonical # quantity, chosen from those in the expression d = sift(expr.atoms(Quantity), lambda i: i.dimension) for k in d: if len(d[k]) == 1: continue v = list(ordered(d[k])) ref = v[0]/v[0].scale_factor expr = expr.xreplace({vi: ref*vi.scale_factor for vi in v[1:]}) return expr def check_dimensions(expr): """Return expr if there are not unitless values added to dimensional quantities, else raise a ValueError.""" from sympy.solvers.solveset import _term_factors # the case of adding a number to a dimensional quantity # is ignored for the sake of SymPy core routines, so this # function will raise an error now if such an addend is # found. # Also, when doing substitutions, multiplicative constants # might be introduced, so remove those now adds = expr.atoms(Add) DIM_OF = dimsys_default.get_dimensional_dependencies for a in adds: deset = set() for ai in a.args: if ai.is_number: deset.add(()) continue dims = [] skip = False for i in Mul.make_args(ai): if i.has(Quantity): i = Dimension(Quantity.get_dimensional_expr(i)) if i.has(Dimension): dims.extend(DIM_OF(i).items()) elif i.free_symbols: skip = True break if not skip: deset.add(tuple(sorted(dims))) if len(deset) > 1: raise ValueError( "addends have incompatible dimensions") # clear multiplicative constants on Dimensions which may be # left after substitution reps = {} for m in expr.atoms(Mul): if any(isinstance(i, Dimension) for i in m.args): reps[m] = m.func(*[ i for i in m.args if not i.is_number]) return expr.xreplace(reps)
1c6d58caa137cededca6f99c902842105b7cdfa9221ab7b28042fad3f658f4c6
""" Physical quantities. """ from __future__ import division from sympy import (Abs, Add, AtomicExpr, Derivative, Function, Mul, Pow, S, Symbol, sympify) from sympy.core.compatibility import string_types from sympy.physics.units import Dimension, dimensions from sympy.physics.units.prefixes import Prefix from sympy.utilities.exceptions import SymPyDeprecationWarning class Quantity(AtomicExpr): """ Physical quantity: can be a unit of measure, a constant or a generic quantity. """ is_commutative = True is_real = True is_number = False is_nonzero = True _diff_wrt = True def __new__(cls, name, abbrev=None, dimension=None, scale_factor=None, latex_repr=None, pretty_unicode_repr=None, pretty_ascii_repr=None, mathml_presentation_repr=None, **assumptions): if not isinstance(name, Symbol): name = Symbol(name) # For Quantity(name, dim, scale, abbrev) to work like in the # old version of Sympy: if not isinstance(abbrev, string_types) and not \ isinstance(abbrev, Symbol): dimension, scale_factor, abbrev = abbrev, dimension, scale_factor if dimension is not None: SymPyDeprecationWarning( deprecated_since_version="1.3", issue=14319, feature="Quantity arguments", useinstead="SI_quantity_dimension_map", ).warn() if scale_factor is not None: SymPyDeprecationWarning( deprecated_since_version="1.3", issue=14319, feature="Quantity arguments", useinstead="SI_quantity_scale_factors", ).warn() if abbrev is None: abbrev = name elif isinstance(abbrev, string_types): abbrev = Symbol(abbrev) obj = AtomicExpr.__new__(cls, name, abbrev) obj._name = name obj._abbrev = abbrev obj._latex_repr = latex_repr obj._unicode_repr = pretty_unicode_repr obj._ascii_repr = pretty_ascii_repr obj._mathml_repr = mathml_presentation_repr if dimension is not None: # TODO: remove after deprecation: obj.set_dimension(dimension) if scale_factor is not None: # TODO: remove after deprecation: obj.set_scale_factor(scale_factor) return obj ### Currently only SI is supported: ### # Dimensional representations for the SI units: SI_quantity_dimension_map = {} # Scale factors in SI units: SI_quantity_scale_factors = {} def set_dimension(self, dimension, unit_system="SI"): from sympy.physics.units.dimensions import dimsys_default, DimensionSystem if unit_system != "SI": # TODO: add support for more units and dimension systems: raise NotImplementedError("Currently only SI is supported") dim_sys = dimsys_default if not isinstance(dimension, dimensions.Dimension): if dimension == 1: dimension = Dimension(1) else: raise ValueError("expected dimension or 1") else: for dim_sym in dimension.name.atoms(Dimension): if dim_sym not in [i.name for i in dim_sys._dimensional_dependencies]: raise ValueError("Dimension %s is not registered in the " "dimensional dependency tree." % dim_sym) Quantity.SI_quantity_dimension_map[self] = dimension def set_scale_factor(self, scale_factor, unit_system="SI"): if unit_system != "SI": # TODO: add support for more units and dimension systems: raise NotImplementedError("Currently only SI is supported") scale_factor = sympify(scale_factor) # replace all prefixes by their ratio to canonical units: scale_factor = scale_factor.replace(lambda x: isinstance(x, Prefix), lambda x: x.scale_factor) # replace all quantities by their ratio to canonical units: scale_factor = scale_factor.replace(lambda x: isinstance(x, Quantity), lambda x: x.scale_factor) Quantity.SI_quantity_scale_factors[self] = scale_factor @property def name(self): return self._name @property def dimension(self): # TODO: add support for units other than SI: return Quantity.SI_quantity_dimension_map[self] @property def abbrev(self): """ Symbol representing the unit name. Prepend the abbreviation with the prefix symbol if it is defines. """ return self._abbrev @property def scale_factor(self): """ Overall magnitude of the quantity as compared to the canonical units. """ return Quantity.SI_quantity_scale_factors.get(self, S.One) def _eval_is_positive(self): return self.scale_factor.is_positive def _eval_is_constant(self): return self.scale_factor.is_constant() def _eval_Abs(self): scale_factor = Abs(self.scale_factor) if scale_factor == self.scale_factor: return self return None q = self.func(self.name, self.abbrev) def _eval_subs(self, old, new): if isinstance(new, Quantity) and self != old: return self @staticmethod def get_dimensional_expr(expr): if isinstance(expr, Mul): return Mul(*[Quantity.get_dimensional_expr(i) for i in expr.args]) elif isinstance(expr, Pow): return Quantity.get_dimensional_expr(expr.base) ** expr.exp elif isinstance(expr, Add): return Quantity.get_dimensional_expr(expr.args[0]) elif isinstance(expr, Derivative): dim = Quantity.get_dimensional_expr(expr.expr) for independent, count in expr.variable_count: dim /= Quantity.get_dimensional_expr(independent)**count return dim elif isinstance(expr, Function): args = [Quantity.get_dimensional_expr(arg) for arg in expr.args] if all(i == 1 for i in args): return S.One return expr.func(*args) elif isinstance(expr, Quantity): return expr.dimension.name return S.One @staticmethod def _collect_factor_and_dimension(expr): """Return tuple with factor expression and dimension expression.""" if isinstance(expr, Quantity): return expr.scale_factor, expr.dimension elif isinstance(expr, Mul): factor = 1 dimension = Dimension(1) for arg in expr.args: arg_factor, arg_dim = Quantity._collect_factor_and_dimension(arg) factor *= arg_factor dimension *= arg_dim return factor, dimension elif isinstance(expr, Pow): factor, dim = Quantity._collect_factor_and_dimension(expr.base) exp_factor, exp_dim = Quantity._collect_factor_and_dimension(expr.exp) if exp_dim.is_dimensionless: exp_dim = 1 return factor ** exp_factor, dim ** (exp_factor * exp_dim) elif isinstance(expr, Add): factor, dim = Quantity._collect_factor_and_dimension(expr.args[0]) for addend in expr.args[1:]: addend_factor, addend_dim = \ Quantity._collect_factor_and_dimension(addend) if dim != addend_dim: raise ValueError( 'Dimension of "{0}" is {1}, ' 'but it should be {2}'.format( addend, addend_dim.name, dim.name)) factor += addend_factor return factor, dim elif isinstance(expr, Derivative): factor, dim = Quantity._collect_factor_and_dimension(expr.args[0]) for independent, count in expr.variable_count: ifactor, idim = Quantity._collect_factor_and_dimension(independent) factor /= ifactor**count dim /= idim**count return factor, dim elif isinstance(expr, Function): fds = [Quantity._collect_factor_and_dimension( arg) for arg in expr.args] return (expr.func(*(f[0] for f in fds)), expr.func(*(d[1] for d in fds))) elif isinstance(expr, Dimension): return 1, expr else: return expr, Dimension(1) def _latex(self, printer): if self._latex_repr: return self._latex_repr else: return r'\text{{{}}}'.format(self.args[1] \ if len(self.args) >= 2 else self.args[0]) def convert_to(self, other): """ Convert the quantity to another quantity of same dimensions. Examples ======== >>> from sympy.physics.units import speed_of_light, meter, second >>> speed_of_light speed_of_light >>> speed_of_light.convert_to(meter/second) 299792458*meter/second >>> from sympy.physics.units import liter >>> liter.convert_to(meter**3) meter**3/1000 """ from .util import convert_to return convert_to(self, other) @property def free_symbols(self): """Return free symbols from quantity.""" return self.scale_factor.free_symbols
5aef15b61af882cc75cdaa6c0eeaf6593affb0cb3cac0be1793b60f7825482e2
from sympy.physics.secondquant import ( Dagger, Bd, VarBosonicBasis, BBra, B, BKet, FixedBosonicBasis, matrix_rep, apply_operators, InnerProduct, Commutator, KroneckerDelta, AnnihilateBoson, CreateBoson, BosonicOperator, F, Fd, FKet, BosonState, CreateFermion, AnnihilateFermion, evaluate_deltas, AntiSymmetricTensor, contraction, NO, wicks, PermutationOperator, simplify_index_permutations, _sort_anticommuting_fermions, _get_ordered_dummies, substitute_dummies, FockState, FockStateBosonKet, ContractionAppliesOnlyToFermions ) from sympy import (Dummy, expand, Function, I, Rational, simplify, sqrt, Sum, Symbol, symbols, srepr) from sympy.core.compatibility import range from sympy.utilities.pytest import XFAIL, slow, raises from sympy.printing.latex import latex def test_PermutationOperator(): p, q, r, s = symbols('p,q,r,s') f, g, h, i = map(Function, 'fghi') P = PermutationOperator assert P(p, q).get_permuted(f(p)*g(q)) == -f(q)*g(p) assert P(p, q).get_permuted(f(p, q)) == -f(q, p) assert P(p, q).get_permuted(f(p)) == f(p) expr = (f(p)*g(q)*h(r)*i(s) - f(q)*g(p)*h(r)*i(s) - f(p)*g(q)*h(s)*i(r) + f(q)*g(p)*h(s)*i(r)) perms = [P(p, q), P(r, s)] assert (simplify_index_permutations(expr, perms) == P(p, q)*P(r, s)*f(p)*g(q)*h(r)*i(s)) assert latex(P(p, q)) == 'P(pq)' def test_index_permutations_with_dummies(): a, b, c, d = symbols('a b c d') p, q, r, s = symbols('p q r s', cls=Dummy) f, g = map(Function, 'fg') P = PermutationOperator # No dummy substitution necessary expr = f(a, b, p, q) - f(b, a, p, q) assert simplify_index_permutations( expr, [P(a, b)]) == P(a, b)*f(a, b, p, q) # Cases where dummy substitution is needed expected = P(a, b)*substitute_dummies(f(a, b, p, q)) expr = f(a, b, p, q) - f(b, a, q, p) result = simplify_index_permutations(expr, [P(a, b)]) assert expected == substitute_dummies(result) expr = f(a, b, q, p) - f(b, a, p, q) result = simplify_index_permutations(expr, [P(a, b)]) assert expected == substitute_dummies(result) # A case where nothing can be done expr = f(a, b, q, p) - g(b, a, p, q) result = simplify_index_permutations(expr, [P(a, b)]) assert expr == result def test_dagger(): i, j, n, m = symbols('i,j,n,m') assert Dagger(1) == 1 assert Dagger(1.0) == 1.0 assert Dagger(2*I) == -2*I assert Dagger(Rational(1, 2)*I/3.0) == -Rational(1, 2)*I/3.0 assert Dagger(BKet([n])) == BBra([n]) assert Dagger(B(0)) == Bd(0) assert Dagger(Bd(0)) == B(0) assert Dagger(B(n)) == Bd(n) assert Dagger(Bd(n)) == B(n) assert Dagger(B(0) + B(1)) == Bd(0) + Bd(1) assert Dagger(n*m) == Dagger(n)*Dagger(m) # n, m commute assert Dagger(B(n)*B(m)) == Bd(m)*Bd(n) assert Dagger(B(n)**10) == Dagger(B(n))**10 assert Dagger('a') == Dagger(Symbol('a')) assert Dagger(Dagger('a')) == Symbol('a') def test_operator(): i, j = symbols('i,j') o = BosonicOperator(i) assert o.state == i assert o.is_symbolic o = BosonicOperator(1) assert o.state == 1 assert not o.is_symbolic def test_create(): i, j, n, m = symbols('i,j,n,m') o = Bd(i) assert latex(o) == "b^\\dagger_{i}" assert isinstance(o, CreateBoson) o = o.subs(i, j) assert o.atoms(Symbol) == {j} o = Bd(0) assert o.apply_operator(BKet([n])) == sqrt(n + 1)*BKet([n + 1]) o = Bd(n) assert o.apply_operator(BKet([n])) == o*BKet([n]) def test_annihilate(): i, j, n, m = symbols('i,j,n,m') o = B(i) assert latex(o) == "b_{i}" assert isinstance(o, AnnihilateBoson) o = o.subs(i, j) assert o.atoms(Symbol) == {j} o = B(0) assert o.apply_operator(BKet([n])) == sqrt(n)*BKet([n - 1]) o = B(n) assert o.apply_operator(BKet([n])) == o*BKet([n]) def test_basic_state(): i, j, n, m = symbols('i,j,n,m') s = BosonState([0, 1, 2, 3, 4]) assert len(s) == 5 assert s.args[0] == tuple(range(5)) assert s.up(0) == BosonState([1, 1, 2, 3, 4]) assert s.down(4) == BosonState([0, 1, 2, 3, 3]) for i in range(5): assert s.up(i).down(i) == s assert s.down(0) == 0 for i in range(5): assert s[i] == i s = BosonState([n, m]) assert s.down(0) == BosonState([n - 1, m]) assert s.up(0) == BosonState([n + 1, m]) @XFAIL def test_move1(): i, j = symbols('i,j') A, C = symbols('A,C', cls=Function) o = A(i)*C(j) # This almost works, but has a minus sign wrong assert move(o, 0, 1) == KroneckerDelta(i, j) + C(j)*A(i) @XFAIL def test_move2(): i, j = symbols('i,j') A, C = symbols('A,C', cls=Function) o = C(j)*A(i) # This almost works, but has a minus sign wrong assert move(o, 0, 1) == -KroneckerDelta(i, j) + A(i)*C(j) def test_basic_apply(): n = symbols("n") e = B(0)*BKet([n]) assert apply_operators(e) == sqrt(n)*BKet([n - 1]) e = Bd(0)*BKet([n]) assert apply_operators(e) == sqrt(n + 1)*BKet([n + 1]) def test_complex_apply(): n, m = symbols("n,m") o = Bd(0)*B(0)*Bd(1)*B(0) e = apply_operators(o*BKet([n, m])) answer = sqrt(n)*sqrt(m + 1)*(-1 + n)*BKet([-1 + n, 1 + m]) assert expand(e) == expand(answer) def test_number_operator(): n = symbols("n") o = Bd(0)*B(0) e = apply_operators(o*BKet([n])) assert e == n*BKet([n]) def test_inner_product(): i, j, k, l = symbols('i,j,k,l') s1 = BBra([0]) s2 = BKet([1]) assert InnerProduct(s1, Dagger(s1)) == 1 assert InnerProduct(s1, s2) == 0 s1 = BBra([i, j]) s2 = BKet([k, l]) r = InnerProduct(s1, s2) assert r == KroneckerDelta(i, k)*KroneckerDelta(j, l) def test_symbolic_matrix_elements(): n, m = symbols('n,m') s1 = BBra([n]) s2 = BKet([m]) o = B(0) e = apply_operators(s1*o*s2) assert e == sqrt(m)*KroneckerDelta(n, m - 1) def test_matrix_elements(): b = VarBosonicBasis(5) o = B(0) m = matrix_rep(o, b) for i in range(4): assert m[i, i + 1] == sqrt(i + 1) o = Bd(0) m = matrix_rep(o, b) for i in range(4): assert m[i + 1, i] == sqrt(i + 1) def test_fixed_bosonic_basis(): b = FixedBosonicBasis(2, 2) # assert b == [FockState((2, 0)), FockState((1, 1)), FockState((0, 2))] state = b.state(1) assert state == FockStateBosonKet((1, 1)) assert b.index(state) == 1 assert b.state(1) == b[1] assert len(b) == 3 assert str(b) == '[FockState((2, 0)), FockState((1, 1)), FockState((0, 2))]' assert repr(b) == '[FockState((2, 0)), FockState((1, 1)), FockState((0, 2))]' assert srepr(b) == '[FockState((2, 0)), FockState((1, 1)), FockState((0, 2))]' @slow def test_sho(): n, m = symbols('n,m') h_n = Bd(n)*B(n)*(n + Rational(1, 2)) H = Sum(h_n, (n, 0, 5)) o = H.doit(deep=False) b = FixedBosonicBasis(2, 6) m = matrix_rep(o, b) # We need to double check these energy values to make sure that they # are correct and have the proper degeneracies! diag = [1, 2, 3, 3, 4, 5, 4, 5, 6, 7, 5, 6, 7, 8, 9, 6, 7, 8, 9, 10, 11] for i in range(len(diag)): assert diag[i] == m[i, i] def test_commutation(): n, m = symbols("n,m", above_fermi=True) c = Commutator(B(0), Bd(0)) assert c == 1 c = Commutator(Bd(0), B(0)) assert c == -1 c = Commutator(B(n), Bd(0)) assert c == KroneckerDelta(n, 0) c = Commutator(B(0), B(0)) assert c == 0 c = Commutator(B(0), Bd(0)) e = simplify(apply_operators(c*BKet([n]))) assert e == BKet([n]) c = Commutator(B(0), B(1)) e = simplify(apply_operators(c*BKet([n, m]))) assert e == 0 c = Commutator(F(m), Fd(m)) assert c == +1 - 2*NO(Fd(m)*F(m)) c = Commutator(Fd(m), F(m)) assert c.expand() == -1 + 2*NO(Fd(m)*F(m)) C = Commutator X, Y, Z = symbols('X,Y,Z', commutative=False) assert C(C(X, Y), Z) != 0 assert C(C(X, Z), Y) != 0 assert C(Y, C(X, Z)) != 0 i, j, k, l = symbols('i,j,k,l', below_fermi=True) a, b, c, d = symbols('a,b,c,d', above_fermi=True) p, q, r, s = symbols('p,q,r,s') D = KroneckerDelta assert C(Fd(a), F(i)) == -2*NO(F(i)*Fd(a)) assert C(Fd(j), NO(Fd(a)*F(i))).doit(wicks=True) == -D(j, i)*Fd(a) assert C(Fd(a)*F(i), Fd(b)*F(j)).doit(wicks=True) == 0 c1 = Commutator(F(a), Fd(a)) assert Commutator.eval(c1, c1) == 0 c = Commutator(Fd(a)*F(i),Fd(b)*F(j)) assert latex(c) == r'\left[a^\dagger_{a} a_{i},a^\dagger_{b} a_{j}\right]' assert repr(c) == 'Commutator(CreateFermion(a)*AnnihilateFermion(i),CreateFermion(b)*AnnihilateFermion(j))' assert str(c) == '[CreateFermion(a)*AnnihilateFermion(i),CreateFermion(b)*AnnihilateFermion(j)]' def test_create_f(): i, j, n, m = symbols('i,j,n,m') o = Fd(i) assert isinstance(o, CreateFermion) o = o.subs(i, j) assert o.atoms(Symbol) == {j} o = Fd(1) assert o.apply_operator(FKet([n])) == FKet([1, n]) assert o.apply_operator(FKet([n])) == -FKet([n, 1]) o = Fd(n) assert o.apply_operator(FKet([])) == FKet([n]) vacuum = FKet([], fermi_level=4) assert vacuum == FKet([], fermi_level=4) i, j, k, l = symbols('i,j,k,l', below_fermi=True) a, b, c, d = symbols('a,b,c,d', above_fermi=True) p, q, r, s = symbols('p,q,r,s') assert Fd(i).apply_operator(FKet([i, j, k], 4)) == FKet([j, k], 4) assert Fd(a).apply_operator(FKet([i, b, k], 4)) == FKet([a, i, b, k], 4) assert Dagger(B(p)).apply_operator(q) == q*CreateBoson(p) assert repr(Fd(p)) == 'CreateFermion(p)' assert srepr(Fd(p)) == "CreateFermion(Symbol('p'))" assert latex(Fd(p)) == r'a^\dagger_{p}' def test_annihilate_f(): i, j, n, m = symbols('i,j,n,m') o = F(i) assert isinstance(o, AnnihilateFermion) o = o.subs(i, j) assert o.atoms(Symbol) == {j} o = F(1) assert o.apply_operator(FKet([1, n])) == FKet([n]) assert o.apply_operator(FKet([n, 1])) == -FKet([n]) o = F(n) assert o.apply_operator(FKet([n])) == FKet([]) i, j, k, l = symbols('i,j,k,l', below_fermi=True) a, b, c, d = symbols('a,b,c,d', above_fermi=True) p, q, r, s = symbols('p,q,r,s') assert F(i).apply_operator(FKet([i, j, k], 4)) == 0 assert F(a).apply_operator(FKet([i, b, k], 4)) == 0 assert F(l).apply_operator(FKet([i, j, k], 3)) == 0 assert F(l).apply_operator(FKet([i, j, k], 4)) == FKet([l, i, j, k], 4) assert str(F(p)) == 'f(p)' assert repr(F(p)) == 'AnnihilateFermion(p)' assert srepr(F(p)) == "AnnihilateFermion(Symbol('p'))" assert latex(F(p)) == 'a_{p}' def test_create_b(): i, j, n, m = symbols('i,j,n,m') o = Bd(i) assert isinstance(o, CreateBoson) o = o.subs(i, j) assert o.atoms(Symbol) == {j} o = Bd(0) assert o.apply_operator(BKet([n])) == sqrt(n + 1)*BKet([n + 1]) o = Bd(n) assert o.apply_operator(BKet([n])) == o*BKet([n]) def test_annihilate_b(): i, j, n, m = symbols('i,j,n,m') o = B(i) assert isinstance(o, AnnihilateBoson) o = o.subs(i, j) assert o.atoms(Symbol) == {j} o = B(0) def test_wicks(): p, q, r, s = symbols('p,q,r,s', above_fermi=True) # Testing for particles only str = F(p)*Fd(q) assert wicks(str) == NO(F(p)*Fd(q)) + KroneckerDelta(p, q) str = Fd(p)*F(q) assert wicks(str) == NO(Fd(p)*F(q)) str = F(p)*Fd(q)*F(r)*Fd(s) nstr = wicks(str) fasit = NO( KroneckerDelta(p, q)*KroneckerDelta(r, s) + KroneckerDelta(p, q)*AnnihilateFermion(r)*CreateFermion(s) + KroneckerDelta(r, s)*AnnihilateFermion(p)*CreateFermion(q) - KroneckerDelta(p, s)*AnnihilateFermion(r)*CreateFermion(q) - AnnihilateFermion(p)*AnnihilateFermion(r)*CreateFermion(q)*CreateFermion(s)) assert nstr == fasit assert (p*q*nstr).expand() == wicks(p*q*str) assert (nstr*p*q*2).expand() == wicks(str*p*q*2) # Testing CC equations particles and holes i, j, k, l = symbols('i j k l', below_fermi=True, cls=Dummy) a, b, c, d = symbols('a b c d', above_fermi=True, cls=Dummy) p, q, r, s = symbols('p q r s', cls=Dummy) assert (wicks(F(a)*NO(F(i)*F(j))*Fd(b)) == NO(F(a)*F(i)*F(j)*Fd(b)) + KroneckerDelta(a, b)*NO(F(i)*F(j))) assert (wicks(F(a)*NO(F(i)*F(j)*F(k))*Fd(b)) == NO(F(a)*F(i)*F(j)*F(k)*Fd(b)) - KroneckerDelta(a, b)*NO(F(i)*F(j)*F(k))) expr = wicks(Fd(i)*NO(Fd(j)*F(k))*F(l)) assert (expr == -KroneckerDelta(i, k)*NO(Fd(j)*F(l)) - KroneckerDelta(j, l)*NO(Fd(i)*F(k)) - KroneckerDelta(i, k)*KroneckerDelta(j, l) + KroneckerDelta(i, l)*NO(Fd(j)*F(k)) + NO(Fd(i)*Fd(j)*F(k)*F(l))) expr = wicks(F(a)*NO(F(b)*Fd(c))*Fd(d)) assert (expr == -KroneckerDelta(a, c)*NO(F(b)*Fd(d)) - KroneckerDelta(b, d)*NO(F(a)*Fd(c)) - KroneckerDelta(a, c)*KroneckerDelta(b, d) + KroneckerDelta(a, d)*NO(F(b)*Fd(c)) + NO(F(a)*F(b)*Fd(c)*Fd(d))) def test_NO(): i, j, k, l = symbols('i j k l', below_fermi=True) a, b, c, d = symbols('a b c d', above_fermi=True) p, q, r, s = symbols('p q r s', cls=Dummy) assert (NO(Fd(p)*F(q) + Fd(a)*F(b)) == NO(Fd(p)*F(q)) + NO(Fd(a)*F(b))) assert (NO(Fd(i)*NO(F(j)*Fd(a))) == NO(Fd(i)*F(j)*Fd(a))) assert NO(1) == 1 assert NO(i) == i assert (NO(Fd(a)*Fd(b)*(F(c) + F(d))) == NO(Fd(a)*Fd(b)*F(c)) + NO(Fd(a)*Fd(b)*F(d))) assert NO(Fd(a)*F(b))._remove_brackets() == Fd(a)*F(b) assert NO(F(j)*Fd(i))._remove_brackets() == F(j)*Fd(i) assert (NO(Fd(p)*F(q)).subs(Fd(p), Fd(a) + Fd(i)) == NO(Fd(a)*F(q)) + NO(Fd(i)*F(q))) assert (NO(Fd(p)*F(q)).subs(F(q), F(a) + F(i)) == NO(Fd(p)*F(a)) + NO(Fd(p)*F(i))) expr = NO(Fd(p)*F(q))._remove_brackets() assert wicks(expr) == NO(expr) assert NO(Fd(a)*F(b)) == - NO(F(b)*Fd(a)) no = NO(Fd(a)*F(i)*F(b)*Fd(j)) l1 = [ ind for ind in no.iter_q_creators() ] assert l1 == [0, 1] l2 = [ ind for ind in no.iter_q_annihilators() ] assert l2 == [3, 2] no = NO(Fd(a)*Fd(i)) assert no.has_q_creators == 1 assert no.has_q_annihilators == -1 assert str(no) == ':CreateFermion(a)*CreateFermion(i):' assert repr(no) == 'NO(CreateFermion(a)*CreateFermion(i))' assert latex(no) == r'\left\{a^\dagger_{a} a^\dagger_{i}\right\}' raises(NotImplementedError, lambda: NO(Bd(p)*F(q))) def test_sorting(): i, j = symbols('i,j', below_fermi=True) a, b = symbols('a,b', above_fermi=True) p, q = symbols('p,q') # p, q assert _sort_anticommuting_fermions([Fd(p), F(q)]) == ([Fd(p), F(q)], 0) assert _sort_anticommuting_fermions([F(p), Fd(q)]) == ([Fd(q), F(p)], 1) # i, p assert _sort_anticommuting_fermions([F(p), Fd(i)]) == ([F(p), Fd(i)], 0) assert _sort_anticommuting_fermions([Fd(i), F(p)]) == ([F(p), Fd(i)], 1) assert _sort_anticommuting_fermions([Fd(p), Fd(i)]) == ([Fd(p), Fd(i)], 0) assert _sort_anticommuting_fermions([Fd(i), Fd(p)]) == ([Fd(p), Fd(i)], 1) assert _sort_anticommuting_fermions([F(p), F(i)]) == ([F(i), F(p)], 1) assert _sort_anticommuting_fermions([F(i), F(p)]) == ([F(i), F(p)], 0) assert _sort_anticommuting_fermions([Fd(p), F(i)]) == ([F(i), Fd(p)], 1) assert _sort_anticommuting_fermions([F(i), Fd(p)]) == ([F(i), Fd(p)], 0) # a, p assert _sort_anticommuting_fermions([F(p), Fd(a)]) == ([Fd(a), F(p)], 1) assert _sort_anticommuting_fermions([Fd(a), F(p)]) == ([Fd(a), F(p)], 0) assert _sort_anticommuting_fermions([Fd(p), Fd(a)]) == ([Fd(a), Fd(p)], 1) assert _sort_anticommuting_fermions([Fd(a), Fd(p)]) == ([Fd(a), Fd(p)], 0) assert _sort_anticommuting_fermions([F(p), F(a)]) == ([F(p), F(a)], 0) assert _sort_anticommuting_fermions([F(a), F(p)]) == ([F(p), F(a)], 1) assert _sort_anticommuting_fermions([Fd(p), F(a)]) == ([Fd(p), F(a)], 0) assert _sort_anticommuting_fermions([F(a), Fd(p)]) == ([Fd(p), F(a)], 1) # i, a assert _sort_anticommuting_fermions([F(i), Fd(j)]) == ([F(i), Fd(j)], 0) assert _sort_anticommuting_fermions([Fd(j), F(i)]) == ([F(i), Fd(j)], 1) assert _sort_anticommuting_fermions([Fd(a), Fd(i)]) == ([Fd(a), Fd(i)], 0) assert _sort_anticommuting_fermions([Fd(i), Fd(a)]) == ([Fd(a), Fd(i)], 1) assert _sort_anticommuting_fermions([F(a), F(i)]) == ([F(i), F(a)], 1) assert _sort_anticommuting_fermions([F(i), F(a)]) == ([F(i), F(a)], 0) def test_contraction(): i, j, k, l = symbols('i,j,k,l', below_fermi=True) a, b, c, d = symbols('a,b,c,d', above_fermi=True) p, q, r, s = symbols('p,q,r,s') assert contraction(Fd(i), F(j)) == KroneckerDelta(i, j) assert contraction(F(a), Fd(b)) == KroneckerDelta(a, b) assert contraction(F(a), Fd(i)) == 0 assert contraction(Fd(a), F(i)) == 0 assert contraction(F(i), Fd(a)) == 0 assert contraction(Fd(i), F(a)) == 0 assert contraction(Fd(i), F(p)) == KroneckerDelta(i, p) restr = evaluate_deltas(contraction(Fd(p), F(q))) assert restr.is_only_below_fermi restr = evaluate_deltas(contraction(F(p), Fd(q))) assert restr.is_only_above_fermi raises(ContractionAppliesOnlyToFermions, lambda: contraction(B(a), Fd(b))) def test_evaluate_deltas(): i, j, k = symbols('i,j,k') r = KroneckerDelta(i, j) * KroneckerDelta(j, k) assert evaluate_deltas(r) == KroneckerDelta(i, k) r = KroneckerDelta(i, 0) * KroneckerDelta(j, k) assert evaluate_deltas(r) == KroneckerDelta(i, 0) * KroneckerDelta(j, k) r = KroneckerDelta(1, j) * KroneckerDelta(j, k) assert evaluate_deltas(r) == KroneckerDelta(1, k) r = KroneckerDelta(j, 2) * KroneckerDelta(k, j) assert evaluate_deltas(r) == KroneckerDelta(2, k) r = KroneckerDelta(i, 0) * KroneckerDelta(i, j) * KroneckerDelta(j, 1) assert evaluate_deltas(r) == 0 r = (KroneckerDelta(0, i) * KroneckerDelta(0, j) * KroneckerDelta(1, j) * KroneckerDelta(1, j)) assert evaluate_deltas(r) == 0 def test_Tensors(): i, j, k, l = symbols('i j k l', below_fermi=True, cls=Dummy) a, b, c, d = symbols('a b c d', above_fermi=True, cls=Dummy) p, q, r, s = symbols('p q r s') AT = AntiSymmetricTensor assert AT('t', (a, b), (i, j)) == -AT('t', (b, a), (i, j)) assert AT('t', (a, b), (i, j)) == AT('t', (b, a), (j, i)) assert AT('t', (a, b), (i, j)) == -AT('t', (a, b), (j, i)) assert AT('t', (a, a), (i, j)) == 0 assert AT('t', (a, b), (i, i)) == 0 assert AT('t', (a, b, c), (i, j)) == -AT('t', (b, a, c), (i, j)) assert AT('t', (a, b, c), (i, j, k)) == AT('t', (b, a, c), (i, k, j)) tabij = AT('t', (a, b), (i, j)) assert tabij.has(a) assert tabij.has(b) assert tabij.has(i) assert tabij.has(j) assert tabij.subs(b, c) == AT('t', (a, c), (i, j)) assert (2*tabij).subs(i, c) == 2*AT('t', (a, b), (c, j)) assert tabij.symbol == Symbol('t') assert latex(tabij) == 't^{ab}_{ij}' assert str(tabij) == 't((_a, _b),(_i, _j))' assert AT('t', (a, a), (i, j)).subs(a, b) == AT('t', (b, b), (i, j)) assert AT('t', (a, i), (a, j)).subs(a, b) == AT('t', (b, i), (b, j)) def test_fully_contracted(): i, j, k, l = symbols('i j k l', below_fermi=True) a, b, c, d = symbols('a b c d', above_fermi=True) p, q, r, s = symbols('p q r s', cls=Dummy) Fock = (AntiSymmetricTensor('f', (p,), (q,))* NO(Fd(p)*F(q))) V = (AntiSymmetricTensor('v', (p, q), (r, s))* NO(Fd(p)*Fd(q)*F(s)*F(r)))/4 Fai = wicks(NO(Fd(i)*F(a))*Fock, keep_only_fully_contracted=True, simplify_kronecker_deltas=True) assert Fai == AntiSymmetricTensor('f', (a,), (i,)) Vabij = wicks(NO(Fd(i)*Fd(j)*F(b)*F(a))*V, keep_only_fully_contracted=True, simplify_kronecker_deltas=True) assert Vabij == AntiSymmetricTensor('v', (a, b), (i, j)) def test_substitute_dummies_without_dummies(): i, j = symbols('i,j') assert substitute_dummies(att(i, j) + 2) == att(i, j) + 2 assert substitute_dummies(att(i, j) + 1) == att(i, j) + 1 def test_substitute_dummies_NO_operator(): i, j = symbols('i j', cls=Dummy) assert substitute_dummies(att(i, j)*NO(Fd(i)*F(j)) - att(j, i)*NO(Fd(j)*F(i))) == 0 def test_substitute_dummies_SQ_operator(): i, j = symbols('i j', cls=Dummy) assert substitute_dummies(att(i, j)*Fd(i)*F(j) - att(j, i)*Fd(j)*F(i)) == 0 def test_substitute_dummies_new_indices(): i, j = symbols('i j', below_fermi=True, cls=Dummy) a, b = symbols('a b', above_fermi=True, cls=Dummy) p, q = symbols('p q', cls=Dummy) f = Function('f') assert substitute_dummies(f(i, a, p) - f(j, b, q), new_indices=True) == 0 def test_substitute_dummies_substitution_order(): i, j, k, l = symbols('i j k l', below_fermi=True, cls=Dummy) f = Function('f') from sympy.utilities.iterables import variations for permut in variations([i, j, k, l], 4): assert substitute_dummies(f(*permut) - f(i, j, k, l)) == 0 def test_dummy_order_inner_outer_lines_VT1T1T1(): ii = symbols('i', below_fermi=True) aa = symbols('a', above_fermi=True) k, l = symbols('k l', below_fermi=True, cls=Dummy) c, d = symbols('c d', above_fermi=True, cls=Dummy) v = Function('v') t = Function('t') dums = _get_ordered_dummies # Coupled-Cluster T1 terms with V*T1*T1*T1 # t^{a}_{k} t^{c}_{i} t^{d}_{l} v^{lk}_{dc} exprs = [ # permut v and t <=> swapping internal lines, equivalent # irrespective of symmetries in v v(k, l, c, d)*t(c, ii)*t(d, l)*t(aa, k), v(l, k, c, d)*t(c, ii)*t(d, k)*t(aa, l), v(k, l, d, c)*t(d, ii)*t(c, l)*t(aa, k), v(l, k, d, c)*t(d, ii)*t(c, k)*t(aa, l), ] for permut in exprs[1:]: assert dums(exprs[0]) != dums(permut) assert substitute_dummies(exprs[0]) == substitute_dummies(permut) def test_dummy_order_inner_outer_lines_VT1T1T1T1(): ii, jj = symbols('i j', below_fermi=True) aa, bb = symbols('a b', above_fermi=True) k, l = symbols('k l', below_fermi=True, cls=Dummy) c, d = symbols('c d', above_fermi=True, cls=Dummy) v = Function('v') t = Function('t') dums = _get_ordered_dummies # Coupled-Cluster T2 terms with V*T1*T1*T1*T1 exprs = [ # permut t <=> swapping external lines, not equivalent # except if v has certain symmetries. v(k, l, c, d)*t(c, ii)*t(d, jj)*t(aa, k)*t(bb, l), v(k, l, c, d)*t(c, jj)*t(d, ii)*t(aa, k)*t(bb, l), v(k, l, c, d)*t(c, ii)*t(d, jj)*t(bb, k)*t(aa, l), v(k, l, c, d)*t(c, jj)*t(d, ii)*t(bb, k)*t(aa, l), ] for permut in exprs[1:]: assert dums(exprs[0]) != dums(permut) assert substitute_dummies(exprs[0]) != substitute_dummies(permut) exprs = [ # permut v <=> swapping external lines, not equivalent # except if v has certain symmetries. # # Note that in contrast to above, these permutations have identical # dummy order. That is because the proximity to external indices # has higher influence on the canonical dummy ordering than the # position of a dummy on the factors. In fact, the terms here are # similar in structure as the result of the dummy substitions above. v(k, l, c, d)*t(c, ii)*t(d, jj)*t(aa, k)*t(bb, l), v(l, k, c, d)*t(c, ii)*t(d, jj)*t(aa, k)*t(bb, l), v(k, l, d, c)*t(c, ii)*t(d, jj)*t(aa, k)*t(bb, l), v(l, k, d, c)*t(c, ii)*t(d, jj)*t(aa, k)*t(bb, l), ] for permut in exprs[1:]: assert dums(exprs[0]) == dums(permut) assert substitute_dummies(exprs[0]) != substitute_dummies(permut) exprs = [ # permut t and v <=> swapping internal lines, equivalent. # Canonical dummy order is different, and a consistent # substitution reveals the equivalence. v(k, l, c, d)*t(c, ii)*t(d, jj)*t(aa, k)*t(bb, l), v(k, l, d, c)*t(c, jj)*t(d, ii)*t(aa, k)*t(bb, l), v(l, k, c, d)*t(c, ii)*t(d, jj)*t(bb, k)*t(aa, l), v(l, k, d, c)*t(c, jj)*t(d, ii)*t(bb, k)*t(aa, l), ] for permut in exprs[1:]: assert dums(exprs[0]) != dums(permut) assert substitute_dummies(exprs[0]) == substitute_dummies(permut) def test_equivalent_internal_lines_VT1T1(): i, j, k, l = symbols('i j k l', below_fermi=True, cls=Dummy) a, b, c, d = symbols('a b c d', above_fermi=True, cls=Dummy) v = Function('v') t = Function('t') dums = _get_ordered_dummies exprs = [ # permute v. Different dummy order. Not equivalent. v(i, j, a, b)*t(a, i)*t(b, j), v(j, i, a, b)*t(a, i)*t(b, j), v(i, j, b, a)*t(a, i)*t(b, j), ] for permut in exprs[1:]: assert dums(exprs[0]) != dums(permut) assert substitute_dummies(exprs[0]) != substitute_dummies(permut) exprs = [ # permute v. Different dummy order. Equivalent v(i, j, a, b)*t(a, i)*t(b, j), v(j, i, b, a)*t(a, i)*t(b, j), ] for permut in exprs[1:]: assert dums(exprs[0]) != dums(permut) assert substitute_dummies(exprs[0]) == substitute_dummies(permut) exprs = [ # permute t. Same dummy order, not equivalent. v(i, j, a, b)*t(a, i)*t(b, j), v(i, j, a, b)*t(b, i)*t(a, j), ] for permut in exprs[1:]: assert dums(exprs[0]) == dums(permut) assert substitute_dummies(exprs[0]) != substitute_dummies(permut) exprs = [ # permute v and t. Different dummy order, equivalent v(i, j, a, b)*t(a, i)*t(b, j), v(j, i, a, b)*t(a, j)*t(b, i), v(i, j, b, a)*t(b, i)*t(a, j), v(j, i, b, a)*t(b, j)*t(a, i), ] for permut in exprs[1:]: assert dums(exprs[0]) != dums(permut) assert substitute_dummies(exprs[0]) == substitute_dummies(permut) def test_equivalent_internal_lines_VT2conjT2(): # this diagram requires special handling in TCE i, j, k, l, m, n = symbols('i j k l m n', below_fermi=True, cls=Dummy) a, b, c, d, e, f = symbols('a b c d e f', above_fermi=True, cls=Dummy) p1, p2, p3, p4 = symbols('p1 p2 p3 p4', above_fermi=True, cls=Dummy) h1, h2, h3, h4 = symbols('h1 h2 h3 h4', below_fermi=True, cls=Dummy) from sympy.utilities.iterables import variations v = Function('v') t = Function('t') dums = _get_ordered_dummies # v(abcd)t(abij)t(ijcd) template = v(p1, p2, p3, p4)*t(p1, p2, i, j)*t(i, j, p3, p4) permutator = variations([a, b, c, d], 4) base = template.subs(zip([p1, p2, p3, p4], next(permutator))) for permut in permutator: subslist = zip([p1, p2, p3, p4], permut) expr = template.subs(subslist) assert dums(base) != dums(expr) assert substitute_dummies(expr) == substitute_dummies(base) template = v(p1, p2, p3, p4)*t(p1, p2, j, i)*t(j, i, p3, p4) permutator = variations([a, b, c, d], 4) base = template.subs(zip([p1, p2, p3, p4], next(permutator))) for permut in permutator: subslist = zip([p1, p2, p3, p4], permut) expr = template.subs(subslist) assert dums(base) != dums(expr) assert substitute_dummies(expr) == substitute_dummies(base) # v(abcd)t(abij)t(jicd) template = v(p1, p2, p3, p4)*t(p1, p2, i, j)*t(j, i, p3, p4) permutator = variations([a, b, c, d], 4) base = template.subs(zip([p1, p2, p3, p4], next(permutator))) for permut in permutator: subslist = zip([p1, p2, p3, p4], permut) expr = template.subs(subslist) assert dums(base) != dums(expr) assert substitute_dummies(expr) == substitute_dummies(base) template = v(p1, p2, p3, p4)*t(p1, p2, j, i)*t(i, j, p3, p4) permutator = variations([a, b, c, d], 4) base = template.subs(zip([p1, p2, p3, p4], next(permutator))) for permut in permutator: subslist = zip([p1, p2, p3, p4], permut) expr = template.subs(subslist) assert dums(base) != dums(expr) assert substitute_dummies(expr) == substitute_dummies(base) def test_equivalent_internal_lines_VT2conjT2_ambiguous_order(): # These diagrams invokes _determine_ambiguous() because the # dummies can not be ordered unambiguously by the key alone i, j, k, l, m, n = symbols('i j k l m n', below_fermi=True, cls=Dummy) a, b, c, d, e, f = symbols('a b c d e f', above_fermi=True, cls=Dummy) p1, p2, p3, p4 = symbols('p1 p2 p3 p4', above_fermi=True, cls=Dummy) h1, h2, h3, h4 = symbols('h1 h2 h3 h4', below_fermi=True, cls=Dummy) from sympy.utilities.iterables import variations v = Function('v') t = Function('t') dums = _get_ordered_dummies # v(abcd)t(abij)t(cdij) template = v(p1, p2, p3, p4)*t(p1, p2, i, j)*t(p3, p4, i, j) permutator = variations([a, b, c, d], 4) base = template.subs(zip([p1, p2, p3, p4], next(permutator))) for permut in permutator: subslist = zip([p1, p2, p3, p4], permut) expr = template.subs(subslist) assert dums(base) != dums(expr) assert substitute_dummies(expr) == substitute_dummies(base) template = v(p1, p2, p3, p4)*t(p1, p2, j, i)*t(p3, p4, i, j) permutator = variations([a, b, c, d], 4) base = template.subs(zip([p1, p2, p3, p4], next(permutator))) for permut in permutator: subslist = zip([p1, p2, p3, p4], permut) expr = template.subs(subslist) assert dums(base) != dums(expr) assert substitute_dummies(expr) == substitute_dummies(base) def test_equivalent_internal_lines_VT2(): i, j, k, l = symbols('i j k l', below_fermi=True, cls=Dummy) a, b, c, d = symbols('a b c d', above_fermi=True, cls=Dummy) v = Function('v') t = Function('t') dums = _get_ordered_dummies exprs = [ # permute v. Same dummy order, not equivalent. # # This test show that the dummy order may not be sensitive to all # index permutations. The following expressions have identical # structure as the resulting terms from of the dummy subsitutions # in the test above. Here, all expressions have the same dummy # order, so they cannot be simplified by means of dummy # substitution. In order to simplify further, it is necessary to # exploit symmetries in the objects, for instance if t or v is # antisymmetric. v(i, j, a, b)*t(a, b, i, j), v(j, i, a, b)*t(a, b, i, j), v(i, j, b, a)*t(a, b, i, j), v(j, i, b, a)*t(a, b, i, j), ] for permut in exprs[1:]: assert dums(exprs[0]) == dums(permut) assert substitute_dummies(exprs[0]) != substitute_dummies(permut) exprs = [ # permute t. v(i, j, a, b)*t(a, b, i, j), v(i, j, a, b)*t(b, a, i, j), v(i, j, a, b)*t(a, b, j, i), v(i, j, a, b)*t(b, a, j, i), ] for permut in exprs[1:]: assert dums(exprs[0]) != dums(permut) assert substitute_dummies(exprs[0]) != substitute_dummies(permut) exprs = [ # permute v and t. Relabelling of dummies should be equivalent. v(i, j, a, b)*t(a, b, i, j), v(j, i, a, b)*t(a, b, j, i), v(i, j, b, a)*t(b, a, i, j), v(j, i, b, a)*t(b, a, j, i), ] for permut in exprs[1:]: assert dums(exprs[0]) != dums(permut) assert substitute_dummies(exprs[0]) == substitute_dummies(permut) def test_internal_external_VT2T2(): ii, jj = symbols('i j', below_fermi=True) aa, bb = symbols('a b', above_fermi=True) k, l = symbols('k l', below_fermi=True, cls=Dummy) c, d = symbols('c d', above_fermi=True, cls=Dummy) v = Function('v') t = Function('t') dums = _get_ordered_dummies exprs = [ v(k, l, c, d)*t(aa, c, ii, k)*t(bb, d, jj, l), v(l, k, c, d)*t(aa, c, ii, l)*t(bb, d, jj, k), v(k, l, d, c)*t(aa, d, ii, k)*t(bb, c, jj, l), v(l, k, d, c)*t(aa, d, ii, l)*t(bb, c, jj, k), ] for permut in exprs[1:]: assert dums(exprs[0]) != dums(permut) assert substitute_dummies(exprs[0]) == substitute_dummies(permut) exprs = [ v(k, l, c, d)*t(aa, c, ii, k)*t(d, bb, jj, l), v(l, k, c, d)*t(aa, c, ii, l)*t(d, bb, jj, k), v(k, l, d, c)*t(aa, d, ii, k)*t(c, bb, jj, l), v(l, k, d, c)*t(aa, d, ii, l)*t(c, bb, jj, k), ] for permut in exprs[1:]: assert dums(exprs[0]) != dums(permut) assert substitute_dummies(exprs[0]) == substitute_dummies(permut) exprs = [ v(k, l, c, d)*t(c, aa, ii, k)*t(bb, d, jj, l), v(l, k, c, d)*t(c, aa, ii, l)*t(bb, d, jj, k), v(k, l, d, c)*t(d, aa, ii, k)*t(bb, c, jj, l), v(l, k, d, c)*t(d, aa, ii, l)*t(bb, c, jj, k), ] for permut in exprs[1:]: assert dums(exprs[0]) != dums(permut) assert substitute_dummies(exprs[0]) == substitute_dummies(permut) def test_internal_external_pqrs(): ii, jj = symbols('i j') aa, bb = symbols('a b') k, l = symbols('k l', cls=Dummy) c, d = symbols('c d', cls=Dummy) v = Function('v') t = Function('t') dums = _get_ordered_dummies exprs = [ v(k, l, c, d)*t(aa, c, ii, k)*t(bb, d, jj, l), v(l, k, c, d)*t(aa, c, ii, l)*t(bb, d, jj, k), v(k, l, d, c)*t(aa, d, ii, k)*t(bb, c, jj, l), v(l, k, d, c)*t(aa, d, ii, l)*t(bb, c, jj, k), ] for permut in exprs[1:]: assert dums(exprs[0]) != dums(permut) assert substitute_dummies(exprs[0]) == substitute_dummies(permut) def test_dummy_order_well_defined(): aa, bb = symbols('a b', above_fermi=True) k, l, m = symbols('k l m', below_fermi=True, cls=Dummy) c, d = symbols('c d', above_fermi=True, cls=Dummy) p, q = symbols('p q', cls=Dummy) A = Function('A') B = Function('B') C = Function('C') dums = _get_ordered_dummies # We go through all key components in the order of increasing priority, # and consider only fully orderable expressions. Non-orderable expressions # are tested elsewhere. # pos in first factor determines sort order assert dums(A(k, l)*B(l, k)) == [k, l] assert dums(A(l, k)*B(l, k)) == [l, k] assert dums(A(k, l)*B(k, l)) == [k, l] assert dums(A(l, k)*B(k, l)) == [l, k] # factors involving the index assert dums(A(k, l)*B(l, m)*C(k, m)) == [l, k, m] assert dums(A(k, l)*B(l, m)*C(m, k)) == [l, k, m] assert dums(A(l, k)*B(l, m)*C(k, m)) == [l, k, m] assert dums(A(l, k)*B(l, m)*C(m, k)) == [l, k, m] assert dums(A(k, l)*B(m, l)*C(k, m)) == [l, k, m] assert dums(A(k, l)*B(m, l)*C(m, k)) == [l, k, m] assert dums(A(l, k)*B(m, l)*C(k, m)) == [l, k, m] assert dums(A(l, k)*B(m, l)*C(m, k)) == [l, k, m] # same, but with factor order determined by non-dummies assert dums(A(k, aa, l)*A(l, bb, m)*A(bb, k, m)) == [l, k, m] assert dums(A(k, aa, l)*A(l, bb, m)*A(bb, m, k)) == [l, k, m] assert dums(A(k, aa, l)*A(m, bb, l)*A(bb, k, m)) == [l, k, m] assert dums(A(k, aa, l)*A(m, bb, l)*A(bb, m, k)) == [l, k, m] assert dums(A(l, aa, k)*A(l, bb, m)*A(bb, k, m)) == [l, k, m] assert dums(A(l, aa, k)*A(l, bb, m)*A(bb, m, k)) == [l, k, m] assert dums(A(l, aa, k)*A(m, bb, l)*A(bb, k, m)) == [l, k, m] assert dums(A(l, aa, k)*A(m, bb, l)*A(bb, m, k)) == [l, k, m] # index range assert dums(A(p, c, k)*B(p, c, k)) == [k, c, p] assert dums(A(p, k, c)*B(p, c, k)) == [k, c, p] assert dums(A(c, k, p)*B(p, c, k)) == [k, c, p] assert dums(A(c, p, k)*B(p, c, k)) == [k, c, p] assert dums(A(k, c, p)*B(p, c, k)) == [k, c, p] assert dums(A(k, p, c)*B(p, c, k)) == [k, c, p] assert dums(B(p, c, k)*A(p, c, k)) == [k, c, p] assert dums(B(p, k, c)*A(p, c, k)) == [k, c, p] assert dums(B(c, k, p)*A(p, c, k)) == [k, c, p] assert dums(B(c, p, k)*A(p, c, k)) == [k, c, p] assert dums(B(k, c, p)*A(p, c, k)) == [k, c, p] assert dums(B(k, p, c)*A(p, c, k)) == [k, c, p] def test_dummy_order_ambiguous(): aa, bb = symbols('a b', above_fermi=True) i, j, k, l, m = symbols('i j k l m', below_fermi=True, cls=Dummy) a, b, c, d, e = symbols('a b c d e', above_fermi=True, cls=Dummy) p, q = symbols('p q', cls=Dummy) p1, p2, p3, p4 = symbols('p1 p2 p3 p4', above_fermi=True, cls=Dummy) p5, p6, p7, p8 = symbols('p5 p6 p7 p8', above_fermi=True, cls=Dummy) h1, h2, h3, h4 = symbols('h1 h2 h3 h4', below_fermi=True, cls=Dummy) h5, h6, h7, h8 = symbols('h5 h6 h7 h8', below_fermi=True, cls=Dummy) A = Function('A') B = Function('B') from sympy.utilities.iterables import variations # A*A*A*A*B -- ordering of p5 and p4 is used to figure out the rest template = A(p1, p2)*A(p4, p1)*A(p2, p3)*A(p3, p5)*B(p5, p4) permutator = variations([a, b, c, d, e], 5) base = template.subs(zip([p1, p2, p3, p4, p5], next(permutator))) for permut in permutator: subslist = zip([p1, p2, p3, p4, p5], permut) expr = template.subs(subslist) assert substitute_dummies(expr) == substitute_dummies(base) # A*A*A*A*A -- an arbitrary index is assigned and the rest are figured out template = A(p1, p2)*A(p4, p1)*A(p2, p3)*A(p3, p5)*A(p5, p4) permutator = variations([a, b, c, d, e], 5) base = template.subs(zip([p1, p2, p3, p4, p5], next(permutator))) for permut in permutator: subslist = zip([p1, p2, p3, p4, p5], permut) expr = template.subs(subslist) assert substitute_dummies(expr) == substitute_dummies(base) # A*A*A -- ordering of p5 and p4 is used to figure out the rest template = A(p1, p2, p4, p1)*A(p2, p3, p3, p5)*A(p5, p4) permutator = variations([a, b, c, d, e], 5) base = template.subs(zip([p1, p2, p3, p4, p5], next(permutator))) for permut in permutator: subslist = zip([p1, p2, p3, p4, p5], permut) expr = template.subs(subslist) assert substitute_dummies(expr) == substitute_dummies(base) def atv(*args): return AntiSymmetricTensor('v', args[:2], args[2:] ) def att(*args): if len(args) == 4: return AntiSymmetricTensor('t', args[:2], args[2:] ) elif len(args) == 2: return AntiSymmetricTensor('t', (args[0],), (args[1],)) def test_dummy_order_inner_outer_lines_VT1T1T1_AT(): ii = symbols('i', below_fermi=True) aa = symbols('a', above_fermi=True) k, l = symbols('k l', below_fermi=True, cls=Dummy) c, d = symbols('c d', above_fermi=True, cls=Dummy) # Coupled-Cluster T1 terms with V*T1*T1*T1 # t^{a}_{k} t^{c}_{i} t^{d}_{l} v^{lk}_{dc} exprs = [ # permut v and t <=> swapping internal lines, equivalent # irrespective of symmetries in v atv(k, l, c, d)*att(c, ii)*att(d, l)*att(aa, k), atv(l, k, c, d)*att(c, ii)*att(d, k)*att(aa, l), atv(k, l, d, c)*att(d, ii)*att(c, l)*att(aa, k), atv(l, k, d, c)*att(d, ii)*att(c, k)*att(aa, l), ] for permut in exprs[1:]: assert substitute_dummies(exprs[0]) == substitute_dummies(permut) def test_dummy_order_inner_outer_lines_VT1T1T1T1_AT(): ii, jj = symbols('i j', below_fermi=True) aa, bb = symbols('a b', above_fermi=True) k, l = symbols('k l', below_fermi=True, cls=Dummy) c, d = symbols('c d', above_fermi=True, cls=Dummy) # Coupled-Cluster T2 terms with V*T1*T1*T1*T1 # non-equivalent substitutions (change of sign) exprs = [ # permut t <=> swapping external lines atv(k, l, c, d)*att(c, ii)*att(d, jj)*att(aa, k)*att(bb, l), atv(k, l, c, d)*att(c, jj)*att(d, ii)*att(aa, k)*att(bb, l), atv(k, l, c, d)*att(c, ii)*att(d, jj)*att(bb, k)*att(aa, l), ] for permut in exprs[1:]: assert substitute_dummies(exprs[0]) == -substitute_dummies(permut) # equivalent substitutions exprs = [ atv(k, l, c, d)*att(c, ii)*att(d, jj)*att(aa, k)*att(bb, l), # permut t <=> swapping external lines atv(k, l, c, d)*att(c, jj)*att(d, ii)*att(bb, k)*att(aa, l), ] for permut in exprs[1:]: assert substitute_dummies(exprs[0]) == substitute_dummies(permut) def test_equivalent_internal_lines_VT1T1_AT(): i, j, k, l = symbols('i j k l', below_fermi=True, cls=Dummy) a, b, c, d = symbols('a b c d', above_fermi=True, cls=Dummy) exprs = [ # permute v. Different dummy order. Not equivalent. atv(i, j, a, b)*att(a, i)*att(b, j), atv(j, i, a, b)*att(a, i)*att(b, j), atv(i, j, b, a)*att(a, i)*att(b, j), ] for permut in exprs[1:]: assert substitute_dummies(exprs[0]) != substitute_dummies(permut) exprs = [ # permute v. Different dummy order. Equivalent atv(i, j, a, b)*att(a, i)*att(b, j), atv(j, i, b, a)*att(a, i)*att(b, j), ] for permut in exprs[1:]: assert substitute_dummies(exprs[0]) == substitute_dummies(permut) exprs = [ # permute t. Same dummy order, not equivalent. atv(i, j, a, b)*att(a, i)*att(b, j), atv(i, j, a, b)*att(b, i)*att(a, j), ] for permut in exprs[1:]: assert substitute_dummies(exprs[0]) != substitute_dummies(permut) exprs = [ # permute v and t. Different dummy order, equivalent atv(i, j, a, b)*att(a, i)*att(b, j), atv(j, i, a, b)*att(a, j)*att(b, i), atv(i, j, b, a)*att(b, i)*att(a, j), atv(j, i, b, a)*att(b, j)*att(a, i), ] for permut in exprs[1:]: assert substitute_dummies(exprs[0]) == substitute_dummies(permut) def test_equivalent_internal_lines_VT2conjT2_AT(): # this diagram requires special handling in TCE i, j, k, l, m, n = symbols('i j k l m n', below_fermi=True, cls=Dummy) a, b, c, d, e, f = symbols('a b c d e f', above_fermi=True, cls=Dummy) p1, p2, p3, p4 = symbols('p1 p2 p3 p4', above_fermi=True, cls=Dummy) h1, h2, h3, h4 = symbols('h1 h2 h3 h4', below_fermi=True, cls=Dummy) from sympy.utilities.iterables import variations # atv(abcd)att(abij)att(ijcd) template = atv(p1, p2, p3, p4)*att(p1, p2, i, j)*att(i, j, p3, p4) permutator = variations([a, b, c, d], 4) base = template.subs(zip([p1, p2, p3, p4], next(permutator))) for permut in permutator: subslist = zip([p1, p2, p3, p4], permut) expr = template.subs(subslist) assert substitute_dummies(expr) == substitute_dummies(base) template = atv(p1, p2, p3, p4)*att(p1, p2, j, i)*att(j, i, p3, p4) permutator = variations([a, b, c, d], 4) base = template.subs(zip([p1, p2, p3, p4], next(permutator))) for permut in permutator: subslist = zip([p1, p2, p3, p4], permut) expr = template.subs(subslist) assert substitute_dummies(expr) == substitute_dummies(base) # atv(abcd)att(abij)att(jicd) template = atv(p1, p2, p3, p4)*att(p1, p2, i, j)*att(j, i, p3, p4) permutator = variations([a, b, c, d], 4) base = template.subs(zip([p1, p2, p3, p4], next(permutator))) for permut in permutator: subslist = zip([p1, p2, p3, p4], permut) expr = template.subs(subslist) assert substitute_dummies(expr) == substitute_dummies(base) template = atv(p1, p2, p3, p4)*att(p1, p2, j, i)*att(i, j, p3, p4) permutator = variations([a, b, c, d], 4) base = template.subs(zip([p1, p2, p3, p4], next(permutator))) for permut in permutator: subslist = zip([p1, p2, p3, p4], permut) expr = template.subs(subslist) assert substitute_dummies(expr) == substitute_dummies(base) def test_equivalent_internal_lines_VT2conjT2_ambiguous_order_AT(): # These diagrams invokes _determine_ambiguous() because the # dummies can not be ordered unambiguously by the key alone i, j, k, l, m, n = symbols('i j k l m n', below_fermi=True, cls=Dummy) a, b, c, d, e, f = symbols('a b c d e f', above_fermi=True, cls=Dummy) p1, p2, p3, p4 = symbols('p1 p2 p3 p4', above_fermi=True, cls=Dummy) h1, h2, h3, h4 = symbols('h1 h2 h3 h4', below_fermi=True, cls=Dummy) from sympy.utilities.iterables import variations # atv(abcd)att(abij)att(cdij) template = atv(p1, p2, p3, p4)*att(p1, p2, i, j)*att(p3, p4, i, j) permutator = variations([a, b, c, d], 4) base = template.subs(zip([p1, p2, p3, p4], next(permutator))) for permut in permutator: subslist = zip([p1, p2, p3, p4], permut) expr = template.subs(subslist) assert substitute_dummies(expr) == substitute_dummies(base) template = atv(p1, p2, p3, p4)*att(p1, p2, j, i)*att(p3, p4, i, j) permutator = variations([a, b, c, d], 4) base = template.subs(zip([p1, p2, p3, p4], next(permutator))) for permut in permutator: subslist = zip([p1, p2, p3, p4], permut) expr = template.subs(subslist) assert substitute_dummies(expr) == substitute_dummies(base) def test_equivalent_internal_lines_VT2_AT(): i, j, k, l = symbols('i j k l', below_fermi=True, cls=Dummy) a, b, c, d = symbols('a b c d', above_fermi=True, cls=Dummy) exprs = [ # permute v. Same dummy order, not equivalent. atv(i, j, a, b)*att(a, b, i, j), atv(j, i, a, b)*att(a, b, i, j), atv(i, j, b, a)*att(a, b, i, j), ] for permut in exprs[1:]: assert substitute_dummies(exprs[0]) != substitute_dummies(permut) exprs = [ # permute t. atv(i, j, a, b)*att(a, b, i, j), atv(i, j, a, b)*att(b, a, i, j), atv(i, j, a, b)*att(a, b, j, i), ] for permut in exprs[1:]: assert substitute_dummies(exprs[0]) != substitute_dummies(permut) exprs = [ # permute v and t. Relabelling of dummies should be equivalent. atv(i, j, a, b)*att(a, b, i, j), atv(j, i, a, b)*att(a, b, j, i), atv(i, j, b, a)*att(b, a, i, j), atv(j, i, b, a)*att(b, a, j, i), ] for permut in exprs[1:]: assert substitute_dummies(exprs[0]) == substitute_dummies(permut) def test_internal_external_VT2T2_AT(): ii, jj = symbols('i j', below_fermi=True) aa, bb = symbols('a b', above_fermi=True) k, l = symbols('k l', below_fermi=True, cls=Dummy) c, d = symbols('c d', above_fermi=True, cls=Dummy) exprs = [ atv(k, l, c, d)*att(aa, c, ii, k)*att(bb, d, jj, l), atv(l, k, c, d)*att(aa, c, ii, l)*att(bb, d, jj, k), atv(k, l, d, c)*att(aa, d, ii, k)*att(bb, c, jj, l), atv(l, k, d, c)*att(aa, d, ii, l)*att(bb, c, jj, k), ] for permut in exprs[1:]: assert substitute_dummies(exprs[0]) == substitute_dummies(permut) exprs = [ atv(k, l, c, d)*att(aa, c, ii, k)*att(d, bb, jj, l), atv(l, k, c, d)*att(aa, c, ii, l)*att(d, bb, jj, k), atv(k, l, d, c)*att(aa, d, ii, k)*att(c, bb, jj, l), atv(l, k, d, c)*att(aa, d, ii, l)*att(c, bb, jj, k), ] for permut in exprs[1:]: assert substitute_dummies(exprs[0]) == substitute_dummies(permut) exprs = [ atv(k, l, c, d)*att(c, aa, ii, k)*att(bb, d, jj, l), atv(l, k, c, d)*att(c, aa, ii, l)*att(bb, d, jj, k), atv(k, l, d, c)*att(d, aa, ii, k)*att(bb, c, jj, l), atv(l, k, d, c)*att(d, aa, ii, l)*att(bb, c, jj, k), ] for permut in exprs[1:]: assert substitute_dummies(exprs[0]) == substitute_dummies(permut) def test_internal_external_pqrs_AT(): ii, jj = symbols('i j') aa, bb = symbols('a b') k, l = symbols('k l', cls=Dummy) c, d = symbols('c d', cls=Dummy) exprs = [ atv(k, l, c, d)*att(aa, c, ii, k)*att(bb, d, jj, l), atv(l, k, c, d)*att(aa, c, ii, l)*att(bb, d, jj, k), atv(k, l, d, c)*att(aa, d, ii, k)*att(bb, c, jj, l), atv(l, k, d, c)*att(aa, d, ii, l)*att(bb, c, jj, k), ] for permut in exprs[1:]: assert substitute_dummies(exprs[0]) == substitute_dummies(permut) def test_canonical_ordering_AntiSymmetricTensor(): v = symbols("v") virtual_indices = ('c', 'd') occupied_indices = ('k', 'l') c, d = symbols(('c','d'), above_fermi=True, cls=Dummy) k, l = symbols(('k','l'), below_fermi=True, cls=Dummy) # formerly, the left gave either the left or the right assert AntiSymmetricTensor(v, (k, l), (d, c) ) == -AntiSymmetricTensor(v, (l, k), (d, c))
14517edc24114c91f177c93f364e36a530035feceed13d9098f038be9844f48c
""" This module can be used to solve 2D beam bending problems with singularity functions in mechanics. """ from __future__ import print_function, division from sympy.core import S, Symbol, diff, symbols from sympy.solvers import linsolve from sympy.printing import sstr from sympy.functions import SingularityFunction, Piecewise, factorial from sympy.core import sympify from sympy.integrals import integrate from sympy.series import limit from sympy.plotting import plot from sympy.external import import_module from sympy.utilities.decorator import doctest_depends_on from sympy import lambdify matplotlib = import_module('matplotlib', __import__kwargs={'fromlist':['pyplot']}) numpy = import_module('numpy', __import__kwargs={'fromlist':['linspace']}) __doctest_requires__ = {('Beam.plot_loading_results',): ['matplotlib']} class Beam(object): """ A Beam is a structural element that is capable of withstanding load primarily by resisting against bending. Beams are characterized by their cross sectional profile(Second moment of area), their length and their material. .. note:: While solving a beam bending problem, a user should choose its own sign convention and should stick to it. The results will automatically follow the chosen sign convention. Examples ======== There is a beam of length 4 meters. A constant distributed load of 6 N/m is applied from half of the beam till the end. There are two simple supports below the beam, one at the starting point and another at the ending point of the beam. The deflection of the beam at the end is restricted. Using the sign convention of downwards forces being positive. >>> from sympy.physics.continuum_mechanics.beam import Beam >>> from sympy import symbols, Piecewise >>> E, I = symbols('E, I') >>> R1, R2 = symbols('R1, R2') >>> b = Beam(4, E, I) >>> b.apply_load(R1, 0, -1) >>> b.apply_load(6, 2, 0) >>> b.apply_load(R2, 4, -1) >>> b.bc_deflection = [(0, 0), (4, 0)] >>> b.boundary_conditions {'deflection': [(0, 0), (4, 0)], 'slope': []} >>> b.load R1*SingularityFunction(x, 0, -1) + R2*SingularityFunction(x, 4, -1) + 6*SingularityFunction(x, 2, 0) >>> b.solve_for_reaction_loads(R1, R2) >>> b.load -3*SingularityFunction(x, 0, -1) + 6*SingularityFunction(x, 2, 0) - 9*SingularityFunction(x, 4, -1) >>> b.shear_force() -3*SingularityFunction(x, 0, 0) + 6*SingularityFunction(x, 2, 1) - 9*SingularityFunction(x, 4, 0) >>> b.bending_moment() -3*SingularityFunction(x, 0, 1) + 3*SingularityFunction(x, 2, 2) - 9*SingularityFunction(x, 4, 1) >>> b.slope() (-3*SingularityFunction(x, 0, 2)/2 + SingularityFunction(x, 2, 3) - 9*SingularityFunction(x, 4, 2)/2 + 7)/(E*I) >>> b.deflection() (7*x - SingularityFunction(x, 0, 3)/2 + SingularityFunction(x, 2, 4)/4 - 3*SingularityFunction(x, 4, 3)/2)/(E*I) >>> b.deflection().rewrite(Piecewise) (7*x - Piecewise((x**3, x > 0), (0, True))/2 - 3*Piecewise(((x - 4)**3, x - 4 > 0), (0, True))/2 + Piecewise(((x - 2)**4, x - 2 > 0), (0, True))/4)/(E*I) """ def __init__(self, length, elastic_modulus, second_moment, variable=Symbol('x'), base_char='C'): """Initializes the class. Parameters ========== length : Sympifyable A Symbol or value representing the Beam's length. elastic_modulus : Sympifyable A SymPy expression representing the Beam's Modulus of Elasticity. It is a measure of the stiffness of the Beam material. It can also be a continuous function of position along the beam. second_moment : Sympifyable A SymPy expression representing the Beam's Second moment of area. It is a geometrical property of an area which reflects how its points are distributed with respect to its neutral axis. It can also be a continuous function of position along the beam. variable : Symbol, optional A Symbol object that will be used as the variable along the beam while representing the load, shear, moment, slope and deflection curve. By default, it is set to ``Symbol('x')``. base_char : String, optional A String that will be used as base character to generate sequential symbols for integration constants in cases where boundary conditions are not sufficient to solve them. """ self.length = length self.elastic_modulus = elastic_modulus self.second_moment = second_moment self.variable = variable self._base_char = base_char self._boundary_conditions = {'deflection': [], 'slope': []} self._load = 0 self._applied_loads = [] self._reaction_loads = {} self._composite_type = None self._hinge_position = None def __str__(self): str_sol = 'Beam({}, {}, {})'.format(sstr(self._length), sstr(self._elastic_modulus), sstr(self._second_moment)) return str_sol @property def reaction_loads(self): """ Returns the reaction forces in a dictionary.""" return self._reaction_loads @property def length(self): """Length of the Beam.""" return self._length @length.setter def length(self, l): self._length = sympify(l) @property def variable(self): """ A symbol that can be used as a variable along the length of the beam while representing load distribution, shear force curve, bending moment, slope curve and the deflection curve. By default, it is set to ``Symbol('x')``, but this property is mutable. Examples ======== >>> from sympy.physics.continuum_mechanics.beam import Beam >>> from sympy import symbols >>> E, I = symbols('E, I') >>> x, y, z = symbols('x, y, z') >>> b = Beam(4, E, I) >>> b.variable x >>> b.variable = y >>> b.variable y >>> b = Beam(4, E, I, z) >>> b.variable z """ return self._variable @variable.setter def variable(self, v): if isinstance(v, Symbol): self._variable = v else: raise TypeError("""The variable should be a Symbol object.""") @property def elastic_modulus(self): """Young's Modulus of the Beam. """ return self._elastic_modulus @elastic_modulus.setter def elastic_modulus(self, e): self._elastic_modulus = sympify(e) @property def second_moment(self): """Second moment of area of the Beam. """ return self._second_moment @second_moment.setter def second_moment(self, i): self._second_moment = sympify(i) @property def boundary_conditions(self): """ Returns a dictionary of boundary conditions applied on the beam. The dictionary has three kewwords namely moment, slope and deflection. The value of each keyword is a list of tuple, where each tuple contains loaction and value of a boundary condition in the format (location, value). Examples ======== There is a beam of length 4 meters. The bending moment at 0 should be 4 and at 4 it should be 0. The slope of the beam should be 1 at 0. The deflection should be 2 at 0. >>> from sympy.physics.continuum_mechanics.beam import Beam >>> from sympy import symbols >>> E, I = symbols('E, I') >>> b = Beam(4, E, I) >>> b.bc_deflection = [(0, 2)] >>> b.bc_slope = [(0, 1)] >>> b.boundary_conditions {'deflection': [(0, 2)], 'slope': [(0, 1)]} Here the deflection of the beam should be ``2`` at ``0``. Similarly, the slope of the beam should be ``1`` at ``0``. """ return self._boundary_conditions @property def bc_slope(self): return self._boundary_conditions['slope'] @bc_slope.setter def bc_slope(self, s_bcs): self._boundary_conditions['slope'] = s_bcs @property def bc_deflection(self): return self._boundary_conditions['deflection'] @bc_deflection.setter def bc_deflection(self, d_bcs): self._boundary_conditions['deflection'] = d_bcs def join(self, beam, via="fixed"): """ This method joins two beams to make a new composite beam system. Passed Beam class instance is attached to the right end of calling object. This method can be used to form beams having Discontinuous values of Elastic modulus or Second moment. Parameters ========== beam : Beam class object The Beam object which would be connected to the right of calling object. via : String States the way two Beam object would get connected - For axially fixed Beams, via="fixed" - For Beams connected via hinge, via="hinge" Examples ======== There is a cantilever beam of length 4 meters. For first 2 meters its moment of inertia is `1.5*I` and `I` for the other end. A pointload of magnitude 4 N is applied from the top at its free end. >>> from sympy.physics.continuum_mechanics.beam import Beam >>> from sympy import symbols >>> E, I = symbols('E, I') >>> R1, R2 = symbols('R1, R2') >>> b1 = Beam(2, E, 1.5*I) >>> b2 = Beam(2, E, I) >>> b = b1.join(b2, "fixed") >>> b.apply_load(20, 4, -1) >>> b.apply_load(R1, 0, -1) >>> b.apply_load(R2, 0, -2) >>> b.bc_slope = [(0, 0)] >>> b.bc_deflection = [(0, 0)] >>> b.solve_for_reaction_loads(R1, R2) >>> b.load 80*SingularityFunction(x, 0, -2) - 20*SingularityFunction(x, 0, -1) + 20*SingularityFunction(x, 4, -1) >>> b.slope() (((80*SingularityFunction(x, 0, 1) - 10*SingularityFunction(x, 0, 2) + 10*SingularityFunction(x, 4, 2))/I - 120/I)/E + 80.0/(E*I))*SingularityFunction(x, 2, 0) + 0.666666666666667*(80*SingularityFunction(x, 0, 1) - 10*SingularityFunction(x, 0, 2) + 10*SingularityFunction(x, 4, 2))*SingularityFunction(x, 0, 0)/(E*I) - 0.666666666666667*(80*SingularityFunction(x, 0, 1) - 10*SingularityFunction(x, 0, 2) + 10*SingularityFunction(x, 4, 2))*SingularityFunction(x, 2, 0)/(E*I) """ x = self.variable E = self.elastic_modulus new_length = self.length + beam.length if self.second_moment != beam.second_moment: new_second_moment = Piecewise((self.second_moment, x<=self.length), (beam.second_moment, x<=new_length)) else: new_second_moment = self.second_moment if via == "fixed": new_beam = Beam(new_length, E, new_second_moment, x) new_beam._composite_type = "fixed" return new_beam if via == "hinge": new_beam = Beam(new_length, E, new_second_moment, x) new_beam._composite_type = "hinge" new_beam._hinge_position = self.length return new_beam def apply_support(self, loc, type="fixed"): """ This method applies support to a particular beam object. Parameters ========== loc : Sympifyable Location of point at which support is applied. type : String Determines type of Beam support applied. To apply support structure with - zero degree of freedom, type = "fixed" - one degree of freedom, type = "pin" - two degrees of freedom, type = "roller" Examples ======== There is a beam of length 30 meters. A moment of magnitude 120 Nm is applied in the clockwise direction at the end of the beam. A pointload of magnitude 8 N is applied from the top of the beam at the starting point. There are two simple supports below the beam. One at the end and another one at a distance of 10 meters from the start. The deflection is restricted at both the supports. Using the sign convention of upward forces and clockwise moment being positive. >>> from sympy.physics.continuum_mechanics.beam import Beam >>> from sympy import symbols >>> E, I = symbols('E, I') >>> b = Beam(30, E, I) >>> b.apply_support(10, 'roller') >>> b.apply_support(30, 'roller') >>> b.apply_load(-8, 0, -1) >>> b.apply_load(120, 30, -2) >>> R_10, R_30 = symbols('R_10, R_30') >>> b.solve_for_reaction_loads(R_10, R_30) >>> b.load -8*SingularityFunction(x, 0, -1) + 6*SingularityFunction(x, 10, -1) + 120*SingularityFunction(x, 30, -2) + 2*SingularityFunction(x, 30, -1) >>> b.slope() (-4*SingularityFunction(x, 0, 2) + 3*SingularityFunction(x, 10, 2) + 120*SingularityFunction(x, 30, 1) + SingularityFunction(x, 30, 2) + 4000/3)/(E*I) """ if type == "pin" or type == "roller": reaction_load = Symbol('R_'+str(loc)) self.apply_load(reaction_load, loc, -1) self.bc_deflection.append((loc, 0)) else: reaction_load = Symbol('R_'+str(loc)) reaction_moment = Symbol('M_'+str(loc)) self.apply_load(reaction_load, loc, -1) self.apply_load(reaction_moment, loc, -2) self.bc_deflection.append((loc, 0)) self.bc_slope.append((loc, 0)) def apply_load(self, value, start, order, end=None): """ This method adds up the loads given to a particular beam object. Parameters ========== value : Sympifyable The magnitude of an applied load. start : Sympifyable The starting point of the applied load. For point moments and point forces this is the location of application. order : Integer The order of the applied load. - For moments, order = -2 - For point loads, order =-1 - For constant distributed load, order = 0 - For ramp loads, order = 1 - For parabolic ramp loads, order = 2 - ... so on. end : Sympifyable, optional An optional argument that can be used if the load has an end point within the length of the beam. Examples ======== There is a beam of length 4 meters. A moment of magnitude 3 Nm is applied in the clockwise direction at the starting point of the beam. A point load of magnitude 4 N is applied from the top of the beam at 2 meters from the starting point and a parabolic ramp load of magnitude 2 N/m is applied below the beam starting from 2 meters to 3 meters away from the starting point of the beam. >>> from sympy.physics.continuum_mechanics.beam import Beam >>> from sympy import symbols >>> E, I = symbols('E, I') >>> b = Beam(4, E, I) >>> b.apply_load(-3, 0, -2) >>> b.apply_load(4, 2, -1) >>> b.apply_load(-2, 2, 2, end=3) >>> b.load -3*SingularityFunction(x, 0, -2) + 4*SingularityFunction(x, 2, -1) - 2*SingularityFunction(x, 2, 2) + 2*SingularityFunction(x, 3, 0) + 4*SingularityFunction(x, 3, 1) + 2*SingularityFunction(x, 3, 2) """ x = self.variable value = sympify(value) start = sympify(start) order = sympify(order) self._applied_loads.append((value, start, order, end)) self._load += value*SingularityFunction(x, start, order) if end: if order.is_negative: msg = ("If 'end' is provided the 'order' of the load cannot " "be negative, i.e. 'end' is only valid for distributed " "loads.") raise ValueError(msg) # NOTE : A Taylor series can be used to define the summation of # singularity functions that subtract from the load past the end # point such that it evaluates to zero past 'end'. f = value * x**order for i in range(0, order + 1): self._load -= (f.diff(x, i).subs(x, end - start) * SingularityFunction(x, end, i) / factorial(i)) def remove_load(self, value, start, order, end=None): """ This method removes a particular load present on the beam object. Returns a ValueError if the load passed as an argument is not present on the beam. Parameters ========== value : Sympifyable The magnitude of an applied load. start : Sympifyable The starting point of the applied load. For point moments and point forces this is the location of application. order : Integer The order of the applied load. - For moments, order= -2 - For point loads, order=-1 - For constant distributed load, order=0 - For ramp loads, order=1 - For parabolic ramp loads, order=2 - ... so on. end : Sympifyable, optional An optional argument that can be used if the load has an end point within the length of the beam. Examples ======== There is a beam of length 4 meters. A moment of magnitude 3 Nm is applied in the clockwise direction at the starting point of the beam. A pointload of magnitude 4 N is applied from the top of the beam at 2 meters from the starting point and a parabolic ramp load of magnitude 2 N/m is applied below the beam starting from 2 meters to 3 meters away from the starting point of the beam. >>> from sympy.physics.continuum_mechanics.beam import Beam >>> from sympy import symbols >>> E, I = symbols('E, I') >>> b = Beam(4, E, I) >>> b.apply_load(-3, 0, -2) >>> b.apply_load(4, 2, -1) >>> b.apply_load(-2, 2, 2, end=3) >>> b.load -3*SingularityFunction(x, 0, -2) + 4*SingularityFunction(x, 2, -1) - 2*SingularityFunction(x, 2, 2) + 2*SingularityFunction(x, 3, 0) + 4*SingularityFunction(x, 3, 1) + 2*SingularityFunction(x, 3, 2) >>> b.remove_load(-2, 2, 2, end = 3) >>> b.load -3*SingularityFunction(x, 0, -2) + 4*SingularityFunction(x, 2, -1) """ x = self.variable value = sympify(value) start = sympify(start) order = sympify(order) if (value, start, order, end) in self._applied_loads: self._load -= value*SingularityFunction(x, start, order) self._applied_loads.remove((value, start, order, end)) else: msg = "No such load distribution exists on the beam object." raise ValueError(msg) if end: # TODO : This is essentially duplicate code wrt to apply_load, # would be better to move it to one location and both methods use # it. if order.is_negative: msg = ("If 'end' is provided the 'order' of the load cannot " "be negative, i.e. 'end' is only valid for distributed " "loads.") raise ValueError(msg) # NOTE : A Taylor series can be used to define the summation of # singularity functions that subtract from the load past the end # point such that it evaluates to zero past 'end'. f = value * x**order for i in range(0, order + 1): self._load += (f.diff(x, i).subs(x, end - start) * SingularityFunction(x, end, i) / factorial(i)) @property def load(self): """ Returns a Singularity Function expression which represents the load distribution curve of the Beam object. Examples ======== There is a beam of length 4 meters. A moment of magnitude 3 Nm is applied in the clockwise direction at the starting point of the beam. A point load of magnitude 4 N is applied from the top of the beam at 2 meters from the starting point and a parabolic ramp load of magnitude 2 N/m is applied below the beam starting from 3 meters away from the starting point of the beam. >>> from sympy.physics.continuum_mechanics.beam import Beam >>> from sympy import symbols >>> E, I = symbols('E, I') >>> b = Beam(4, E, I) >>> b.apply_load(-3, 0, -2) >>> b.apply_load(4, 2, -1) >>> b.apply_load(-2, 3, 2) >>> b.load -3*SingularityFunction(x, 0, -2) + 4*SingularityFunction(x, 2, -1) - 2*SingularityFunction(x, 3, 2) """ return self._load @property def applied_loads(self): """ Returns a list of all loads applied on the beam object. Each load in the list is a tuple of form (value, start, order, end). Examples ======== There is a beam of length 4 meters. A moment of magnitude 3 Nm is applied in the clockwise direction at the starting point of the beam. A pointload of magnitude 4 N is applied from the top of the beam at 2 meters from the starting point. Another pointload of magnitude 5 N is applied at same position. >>> from sympy.physics.continuum_mechanics.beam import Beam >>> from sympy import symbols >>> E, I = symbols('E, I') >>> b = Beam(4, E, I) >>> b.apply_load(-3, 0, -2) >>> b.apply_load(4, 2, -1) >>> b.apply_load(5, 2, -1) >>> b.load -3*SingularityFunction(x, 0, -2) + 9*SingularityFunction(x, 2, -1) >>> b.applied_loads [(-3, 0, -2, None), (4, 2, -1, None), (5, 2, -1, None)] """ return self._applied_loads def _solve_hinge_beams(self, *reactions): """Method to find integration constants and reactional variables in a composite beam connected via hinge. This method resolves the composite Beam into its sub-beams and then equations of shear force, bending moment, slope and deflection are evaluated for both of them separately. These equations are then solved for unknown reactions and integration constants using the boundary conditions applied on the Beam. Equal deflection of both sub-beams at the hinge joint gives us another equation to solve the system. Examples ======== A combined beam, with constant fkexural rigidity E*I, is formed by joining a Beam of length 2*l to the right of another Beam of length l. The whole beam is fixed at both of its both end. A point load of magnitude P is also applied from the top at a distance of 2*l from starting point. >>> from sympy.physics.continuum_mechanics.beam import Beam >>> from sympy import symbols >>> E, I = symbols('E, I') >>> l=symbols('l', positive=True) >>> b1=Beam(l ,E,I) >>> b2=Beam(2*l ,E,I) >>> b=b1.join(b2,"hinge") >>> M1, A1, M2, A2, P = symbols('M1 A1 M2 A2 P') >>> b.apply_load(A1,0,-1) >>> b.apply_load(M1,0,-2) >>> b.apply_load(P,2*l,-1) >>> b.apply_load(A2,3*l,-1) >>> b.apply_load(M2,3*l,-2) >>> b.bc_slope=[(0,0), (3*l, 0)] >>> b.bc_deflection=[(0,0), (3*l, 0)] >>> b.solve_for_reaction_loads(M1, A1, M2, A2) >>> b.reaction_loads {A1: -5*P/18, A2: -13*P/18, M1: 5*P*l/18, M2: -4*P*l/9} >>> b.slope() (5*P*l*SingularityFunction(x, 0, 1)/18 - 5*P*SingularityFunction(x, 0, 2)/36 + 5*P*SingularityFunction(x, l, 2)/36)*SingularityFunction(x, 0, 0)/(E*I) - (5*P*l*SingularityFunction(x, 0, 1)/18 - 5*P*SingularityFunction(x, 0, 2)/36 + 5*P*SingularityFunction(x, l, 2)/36)*SingularityFunction(x, l, 0)/(E*I) + (P*l**2/18 - 4*P*l*SingularityFunction(-l + x, 2*l, 1)/9 - 5*P*SingularityFunction(-l + x, 0, 2)/36 + P*SingularityFunction(-l + x, l, 2)/2 - 13*P*SingularityFunction(-l + x, 2*l, 2)/36)*SingularityFunction(x, l, 0)/(E*I) >>> b.deflection() (5*P*l*SingularityFunction(x, 0, 2)/36 - 5*P*SingularityFunction(x, 0, 3)/108 + 5*P*SingularityFunction(x, l, 3)/108)*SingularityFunction(x, 0, 0)/(E*I) - (5*P*l*SingularityFunction(x, 0, 2)/36 - 5*P*SingularityFunction(x, 0, 3)/108 + 5*P*SingularityFunction(x, l, 3)/108)*SingularityFunction(x, l, 0)/(E*I) + (5*P*l**3/54 + P*l**2*(-l + x)/18 - 2*P*l*SingularityFunction(-l + x, 2*l, 2)/9 - 5*P*SingularityFunction(-l + x, 0, 3)/108 + P*SingularityFunction(-l + x, l, 3)/6 - 13*P*SingularityFunction(-l + x, 2*l, 3)/108)*SingularityFunction(x, l, 0)/(E*I) """ x = self.variable l = self._hinge_position E = self._elastic_modulus I = self._second_moment if isinstance(I, Piecewise): I1 = I.args[0][0] I2 = I.args[1][0] else: I1 = I2 = I load_1 = 0 # Load equation on first segment of composite beam load_2 = 0 # Load equation on second segment of composite beam # Distributing load on both segments for load in self.applied_loads: if load[1] < l: load_1 += load[0]*SingularityFunction(x, load[1], load[2]) if load[2] == 0: load_1 -= load[0]*SingularityFunction(x, load[3], load[2]) elif load[2] > 0: load_1 -= load[0]*SingularityFunction(x, load[3], load[2]) + load[0]*SingularityFunction(x, load[3], 0) elif load[1] == l: load_1 += load[0]*SingularityFunction(x, load[1], load[2]) load_2 += load[0]*SingularityFunction(x, load[1] - l, load[2]) elif load[1] > l: load_2 += load[0]*SingularityFunction(x, load[1] - l, load[2]) if load[2] == 0: load_2 -= load[0]*SingularityFunction(x, load[3] - l, load[2]) elif load[2] > 0: load_2 -= load[0]*SingularityFunction(x, load[3] - l, load[2]) + load[0]*SingularityFunction(x, load[3] - l, 0) h = Symbol('h') # Force due to hinge load_1 += h*SingularityFunction(x, l, -1) load_2 -= h*SingularityFunction(x, 0, -1) eq = [] shear_1 = integrate(load_1, x) shear_curve_1 = limit(shear_1, x, l) eq.append(shear_curve_1) bending_1 = integrate(shear_1, x) moment_curve_1 = limit(bending_1, x, l) eq.append(moment_curve_1) shear_2 = integrate(load_2, x) shear_curve_2 = limit(shear_2, x, self.length - l) eq.append(shear_curve_2) bending_2 = integrate(shear_2, x) moment_curve_2 = limit(bending_2, x, self.length - l) eq.append(moment_curve_2) C1 = Symbol('C1') C2 = Symbol('C2') C3 = Symbol('C3') C4 = Symbol('C4') slope_1 = S(1)/(E*I1)*(integrate(bending_1, x) + C1) def_1 = S(1)/(E*I1)*(integrate((E*I)*slope_1, x) + C1*x + C2) slope_2 = S(1)/(E*I2)*(integrate(integrate(integrate(load_2, x), x), x) + C3) def_2 = S(1)/(E*I2)*(integrate((E*I)*slope_2, x) + C4) for position, value in self.bc_slope: if position<l: eq.append(slope_1.subs(x, position) - value) else: eq.append(slope_2.subs(x, position - l) - value) for position, value in self.bc_deflection: if position<l: eq.append(def_1.subs(x, position) - value) else: eq.append(def_2.subs(x, position - l) - value) eq.append(def_1.subs(x, l) - def_2.subs(x, 0)) # Deflection of both the segments at hinge would be equal constants = list(linsolve(eq, C1, C2, C3, C4, h, *reactions)) reaction_values = list(constants[0])[5:] self._reaction_loads = dict(zip(reactions, reaction_values)) self._load = self._load.subs(self._reaction_loads) # Substituting constants and reactional load and moments with their corresponding values slope_1 = slope_1.subs({C1: constants[0][0], h:constants[0][4]}).subs(self._reaction_loads) def_1 = def_1.subs({C1: constants[0][0], C2: constants[0][1], h:constants[0][4]}).subs(self._reaction_loads) slope_2 = slope_2.subs({x: x-l, C3: constants[0][2], h:constants[0][4]}).subs(self._reaction_loads) def_2 = def_2.subs({x: x-l,C3: constants[0][2], C4: constants[0][3], h:constants[0][4]}).subs(self._reaction_loads) self._hinge_beam_slope = slope_1*SingularityFunction(x, 0, 0) - slope_1*SingularityFunction(x, l, 0) + slope_2*SingularityFunction(x, l, 0) self._hinge_beam_deflection = def_1*SingularityFunction(x, 0, 0) - def_1*SingularityFunction(x, l, 0) + def_2*SingularityFunction(x, l, 0) def solve_for_reaction_loads(self, *reactions): """ Solves for the reaction forces. Examples ======== There is a beam of length 30 meters. A moment of magnitude 120 Nm is applied in the clockwise direction at the end of the beam. A pointload of magnitude 8 N is applied from the top of the beam at the starting point. There are two simple supports below the beam. One at the end and another one at a distance of 10 meters from the start. The deflection is restricted at both the supports. Using the sign convention of upward forces and clockwise moment being positive. >>> from sympy.physics.continuum_mechanics.beam import Beam >>> from sympy import symbols, linsolve, limit >>> E, I = symbols('E, I') >>> R1, R2 = symbols('R1, R2') >>> b = Beam(30, E, I) >>> b.apply_load(-8, 0, -1) >>> b.apply_load(R1, 10, -1) # Reaction force at x = 10 >>> b.apply_load(R2, 30, -1) # Reaction force at x = 30 >>> b.apply_load(120, 30, -2) >>> b.bc_deflection = [(10, 0), (30, 0)] >>> b.load R1*SingularityFunction(x, 10, -1) + R2*SingularityFunction(x, 30, -1) - 8*SingularityFunction(x, 0, -1) + 120*SingularityFunction(x, 30, -2) >>> b.solve_for_reaction_loads(R1, R2) >>> b.reaction_loads {R1: 6, R2: 2} >>> b.load -8*SingularityFunction(x, 0, -1) + 6*SingularityFunction(x, 10, -1) + 120*SingularityFunction(x, 30, -2) + 2*SingularityFunction(x, 30, -1) """ if self._composite_type == "hinge": return self._solve_hinge_beams(*reactions) x = self.variable l = self.length C3 = Symbol('C3') C4 = Symbol('C4') shear_curve = limit(self.shear_force(), x, l) moment_curve = limit(self.bending_moment(), x, l) slope_eqs = [] deflection_eqs = [] slope_curve = integrate(self.bending_moment(), x) + C3 for position, value in self._boundary_conditions['slope']: eqs = slope_curve.subs(x, position) - value slope_eqs.append(eqs) deflection_curve = integrate(slope_curve, x) + C4 for position, value in self._boundary_conditions['deflection']: eqs = deflection_curve.subs(x, position) - value deflection_eqs.append(eqs) solution = list((linsolve([shear_curve, moment_curve] + slope_eqs + deflection_eqs, (C3, C4) + reactions).args)[0]) solution = solution[2:] self._reaction_loads = dict(zip(reactions, solution)) self._load = self._load.subs(self._reaction_loads) def shear_force(self): """ Returns a Singularity Function expression which represents the shear force curve of the Beam object. Examples ======== There is a beam of length 30 meters. A moment of magnitude 120 Nm is applied in the clockwise direction at the end of the beam. A pointload of magnitude 8 N is applied from the top of the beam at the starting point. There are two simple supports below the beam. One at the end and another one at a distance of 10 meters from the start. The deflection is restricted at both the supports. Using the sign convention of upward forces and clockwise moment being positive. >>> from sympy.physics.continuum_mechanics.beam import Beam >>> from sympy import symbols >>> E, I = symbols('E, I') >>> R1, R2 = symbols('R1, R2') >>> b = Beam(30, E, I) >>> b.apply_load(-8, 0, -1) >>> b.apply_load(R1, 10, -1) >>> b.apply_load(R2, 30, -1) >>> b.apply_load(120, 30, -2) >>> b.bc_deflection = [(10, 0), (30, 0)] >>> b.solve_for_reaction_loads(R1, R2) >>> b.shear_force() -8*SingularityFunction(x, 0, 0) + 6*SingularityFunction(x, 10, 0) + 120*SingularityFunction(x, 30, -1) + 2*SingularityFunction(x, 30, 0) """ x = self.variable return integrate(self.load, x) def max_shear_force(self): """Returns maximum Shear force and its coordinate in the Beam object.""" from sympy import solve, Mul, Interval shear_curve = self.shear_force() x = self.variable terms = shear_curve.args singularity = [] # Points at which shear function changes for term in terms: if isinstance(term, Mul): term = term.args[-1] # SingularityFunction in the term singularity.append(term.args[1]) singularity.sort() singularity = list(set(singularity)) intervals = [] # List of Intervals with discrete value of shear force shear_values = [] # List of values of shear force in each interval for i, s in enumerate(singularity): if s == 0: continue try: shear_slope = Piecewise((float("nan"), x<=singularity[i-1]),(self._load.rewrite(Piecewise), x<s), (float("nan"), True)) points = solve(shear_slope, x) val = [] for point in points: val.append(shear_curve.subs(x, point)) points.extend([singularity[i-1], s]) val.extend([limit(shear_curve, x, singularity[i-1], '+'), limit(shear_curve, x, s, '-')]) val = list(map(abs, val)) max_shear = max(val) shear_values.append(max_shear) intervals.append(points[val.index(max_shear)]) # If shear force in a particular Interval has zero or constant # slope, then above block gives NotImplementedError as # solve can't represent Interval solutions. except NotImplementedError: initial_shear = limit(shear_curve, x, singularity[i-1], '+') final_shear = limit(shear_curve, x, s, '-') # If shear_curve has a constant slope(it is a line). if shear_curve.subs(x, (singularity[i-1] + s)/2) == (initial_shear + final_shear)/2 and initial_shear != final_shear: shear_values.extend([initial_shear, final_shear]) intervals.extend([singularity[i-1], s]) else: # shear_curve has same value in whole Interval shear_values.append(final_shear) intervals.append(Interval(singularity[i-1], s)) shear_values = list(map(abs, shear_values)) maximum_shear = max(shear_values) point = intervals[shear_values.index(maximum_shear)] return (point, maximum_shear) def bending_moment(self): """ Returns a Singularity Function expression which represents the bending moment curve of the Beam object. Examples ======== There is a beam of length 30 meters. A moment of magnitude 120 Nm is applied in the clockwise direction at the end of the beam. A pointload of magnitude 8 N is applied from the top of the beam at the starting point. There are two simple supports below the beam. One at the end and another one at a distance of 10 meters from the start. The deflection is restricted at both the supports. Using the sign convention of upward forces and clockwise moment being positive. >>> from sympy.physics.continuum_mechanics.beam import Beam >>> from sympy import symbols >>> E, I = symbols('E, I') >>> R1, R2 = symbols('R1, R2') >>> b = Beam(30, E, I) >>> b.apply_load(-8, 0, -1) >>> b.apply_load(R1, 10, -1) >>> b.apply_load(R2, 30, -1) >>> b.apply_load(120, 30, -2) >>> b.bc_deflection = [(10, 0), (30, 0)] >>> b.solve_for_reaction_loads(R1, R2) >>> b.bending_moment() -8*SingularityFunction(x, 0, 1) + 6*SingularityFunction(x, 10, 1) + 120*SingularityFunction(x, 30, 0) + 2*SingularityFunction(x, 30, 1) """ x = self.variable return integrate(self.shear_force(), x) def max_bmoment(self): """Returns maximum Shear force and its coordinate in the Beam object.""" from sympy import solve, Mul, Interval bending_curve = self.bending_moment() x = self.variable terms = bending_curve.args singularity = [] # Points at which bending moment changes for term in terms: if isinstance(term, Mul): term = term.args[-1] # SingularityFunction in the term singularity.append(term.args[1]) singularity.sort() singularity = list(set(singularity)) intervals = [] # List of Intervals with discrete value of bending moment moment_values = [] # List of values of bending moment in each interval for i, s in enumerate(singularity): if s == 0: continue try: moment_slope = Piecewise((float("nan"), x<=singularity[i-1]),(self.shear_force().rewrite(Piecewise), x<s), (float("nan"), True)) points = solve(moment_slope, x) val = [] for point in points: val.append(bending_curve.subs(x, point)) points.extend([singularity[i-1], s]) val.extend([limit(bending_curve, x, singularity[i-1], '+'), limit(bending_curve, x, s, '-')]) val = list(map(abs, val)) max_moment = max(val) moment_values.append(max_moment) intervals.append(points[val.index(max_moment)]) # If bending moment in a particular Interval has zero or constant # slope, then above block gives NotImplementedError as solve # can't represent Interval solutions. except NotImplementedError: initial_moment = limit(bending_curve, x, singularity[i-1], '+') final_moment = limit(bending_curve, x, s, '-') # If bending_curve has a constant slope(it is a line). if bending_curve.subs(x, (singularity[i-1] + s)/2) == (initial_moment + final_moment)/2 and initial_moment != final_moment: moment_values.extend([initial_moment, final_moment]) intervals.extend([singularity[i-1], s]) else: # bending_curve has same value in whole Interval moment_values.append(final_moment) intervals.append(Interval(singularity[i-1], s)) moment_values = list(map(abs, moment_values)) maximum_moment = max(moment_values) point = intervals[moment_values.index(maximum_moment)] return (point, maximum_moment) def point_cflexure(self): """ Returns a Set of point(s) with zero bending moment and where bending moment curve of the beam object changes its sign from negative to positive or vice versa. Examples ======== There is is 10 meter long overhanging beam. There are two simple supports below the beam. One at the start and another one at a distance of 6 meters from the start. Point loads of magnitude 10KN and 20KN are applied at 2 meters and 4 meters from start respectively. A Uniformly distribute load of magnitude of magnitude 3KN/m is also applied on top starting from 6 meters away from starting point till end. Using the sign convention of upward forces and clockwise moment being positive. >>> from sympy.physics.continuum_mechanics.beam import Beam >>> from sympy import symbols >>> E, I = symbols('E, I') >>> b = Beam(10, E, I) >>> b.apply_load(-4, 0, -1) >>> b.apply_load(-46, 6, -1) >>> b.apply_load(10, 2, -1) >>> b.apply_load(20, 4, -1) >>> b.apply_load(3, 6, 0) >>> b.point_cflexure() [10/3] """ from sympy import solve, Piecewise # To restrict the range within length of the Beam moment_curve = Piecewise((float("nan"), self.variable<=0), (self.bending_moment(), self.variable<self.length), (float("nan"), True)) points = solve(moment_curve.rewrite(Piecewise), self.variable, domain=S.Reals) return points def slope(self): """ Returns a Singularity Function expression which represents the slope the elastic curve of the Beam object. Examples ======== There is a beam of length 30 meters. A moment of magnitude 120 Nm is applied in the clockwise direction at the end of the beam. A pointload of magnitude 8 N is applied from the top of the beam at the starting point. There are two simple supports below the beam. One at the end and another one at a distance of 10 meters from the start. The deflection is restricted at both the supports. Using the sign convention of upward forces and clockwise moment being positive. >>> from sympy.physics.continuum_mechanics.beam import Beam >>> from sympy import symbols >>> E, I = symbols('E, I') >>> R1, R2 = symbols('R1, R2') >>> b = Beam(30, E, I) >>> b.apply_load(-8, 0, -1) >>> b.apply_load(R1, 10, -1) >>> b.apply_load(R2, 30, -1) >>> b.apply_load(120, 30, -2) >>> b.bc_deflection = [(10, 0), (30, 0)] >>> b.solve_for_reaction_loads(R1, R2) >>> b.slope() (-4*SingularityFunction(x, 0, 2) + 3*SingularityFunction(x, 10, 2) + 120*SingularityFunction(x, 30, 1) + SingularityFunction(x, 30, 2) + 4000/3)/(E*I) """ x = self.variable E = self.elastic_modulus I = self.second_moment if self._composite_type == "hinge": return self._hinge_beam_slope if not self._boundary_conditions['slope']: return diff(self.deflection(), x) if isinstance(I, Piecewise) and self._composite_type == "fixed": args = I.args slope = 0 prev_slope = 0 prev_end = 0 for i in range(len(args)): if i != 0: prev_end = args[i-1][1].args[1] slope_value = S(1)/E*integrate(self.bending_moment()/args[i][0], (x, prev_end, x)) if i != len(args) - 1: slope += (prev_slope + slope_value)*SingularityFunction(x, prev_end, 0) - \ (prev_slope + slope_value)*SingularityFunction(x, args[i][1].args[1], 0) else: slope += (prev_slope + slope_value)*SingularityFunction(x, prev_end, 0) prev_slope = slope_value.subs(x, args[i][1].args[1]) return slope C3 = Symbol('C3') slope_curve = integrate(S(1)/(E*I)*self.bending_moment(), x) + C3 bc_eqs = [] for position, value in self._boundary_conditions['slope']: eqs = slope_curve.subs(x, position) - value bc_eqs.append(eqs) constants = list(linsolve(bc_eqs, C3)) slope_curve = slope_curve.subs({C3: constants[0][0]}) return slope_curve def deflection(self): """ Returns a Singularity Function expression which represents the elastic curve or deflection of the Beam object. Examples ======== There is a beam of length 30 meters. A moment of magnitude 120 Nm is applied in the clockwise direction at the end of the beam. A pointload of magnitude 8 N is applied from the top of the beam at the starting point. There are two simple supports below the beam. One at the end and another one at a distance of 10 meters from the start. The deflection is restricted at both the supports. Using the sign convention of upward forces and clockwise moment being positive. >>> from sympy.physics.continuum_mechanics.beam import Beam >>> from sympy import symbols >>> E, I = symbols('E, I') >>> R1, R2 = symbols('R1, R2') >>> b = Beam(30, E, I) >>> b.apply_load(-8, 0, -1) >>> b.apply_load(R1, 10, -1) >>> b.apply_load(R2, 30, -1) >>> b.apply_load(120, 30, -2) >>> b.bc_deflection = [(10, 0), (30, 0)] >>> b.solve_for_reaction_loads(R1, R2) >>> b.deflection() (4000*x/3 - 4*SingularityFunction(x, 0, 3)/3 + SingularityFunction(x, 10, 3) + 60*SingularityFunction(x, 30, 2) + SingularityFunction(x, 30, 3)/3 - 12000)/(E*I) """ x = self.variable E = self.elastic_modulus I = self.second_moment if self._composite_type == "hinge": return self._hinge_beam_deflection if not self._boundary_conditions['deflection'] and not self._boundary_conditions['slope']: if isinstance(I, Piecewise) and self._composite_type == "fixed": args = I.args prev_slope = 0 prev_def = 0 prev_end = 0 deflection = 0 for i in range(len(args)): if i != 0: prev_end = args[i-1][1].args[1] slope_value = S(1)/E*integrate(self.bending_moment()/args[i][0], (x, prev_end, x)) recent_segment_slope = prev_slope + slope_value deflection_value = integrate(recent_segment_slope, (x, prev_end, x)) if i != len(args) - 1: deflection += (prev_def + deflection_value)*SingularityFunction(x, prev_end, 0) \ - (prev_def + deflection_value)*SingularityFunction(x, args[i][1].args[1], 0) else: deflection += (prev_def + deflection_value)*SingularityFunction(x, prev_end, 0) prev_slope = slope_value.subs(x, args[i][1].args[1]) prev_def = deflection_value.subs(x, args[i][1].args[1]) return deflection base_char = self._base_char constants = symbols(base_char + '3:5') return S(1)/(E*I)*integrate(integrate(self.bending_moment(), x), x) + constants[0]*x + constants[1] elif not self._boundary_conditions['deflection']: base_char = self._base_char constant = symbols(base_char + '4') return integrate(self.slope(), x) + constant elif not self._boundary_conditions['slope'] and self._boundary_conditions['deflection']: if isinstance(I, Piecewise) and self._composite_type == "fixed": args = I.args prev_slope = 0 prev_def = 0 prev_end = 0 deflection = 0 for i in range(len(args)): if i != 0: prev_end = args[i-1][1].args[1] slope_value = S(1)/E*integrate(self.bending_moment()/args[i][0], (x, prev_end, x)) recent_segment_slope = prev_slope + slope_value deflection_value = integrate(recent_segment_slope, (x, prev_end, x)) if i != len(args) - 1: deflection += (prev_def + deflection_value)*SingularityFunction(x, prev_end, 0) \ - (prev_def + deflection_value)*SingularityFunction(x, args[i][1].args[1], 0) else: deflection += (prev_def + deflection_value)*SingularityFunction(x, prev_end, 0) prev_slope = slope_value.subs(x, args[i][1].args[1]) prev_def = deflection_value.subs(x, args[i][1].args[1]) return deflection base_char = self._base_char C3, C4 = symbols(base_char + '3:5') # Integration constants slope_curve = integrate(self.bending_moment(), x) + C3 deflection_curve = integrate(slope_curve, x) + C4 bc_eqs = [] for position, value in self._boundary_conditions['deflection']: eqs = deflection_curve.subs(x, position) - value bc_eqs.append(eqs) constants = list(linsolve(bc_eqs, (C3, C4))) deflection_curve = deflection_curve.subs({C3: constants[0][0], C4: constants[0][1]}) return S(1)/(E*I)*deflection_curve if isinstance(I, Piecewise) and self._composite_type == "fixed": args = I.args prev_slope = 0 prev_def = 0 prev_end = 0 deflection = 0 for i in range(len(args)): if i != 0: prev_end = args[i-1][1].args[1] slope_value = S(1)/E*integrate(self.bending_moment()/args[i][0], (x, prev_end, x)) recent_segment_slope = prev_slope + slope_value deflection_value = integrate(recent_segment_slope, (x, prev_end, x)) if i != len(args) - 1: deflection += (prev_def + deflection_value)*SingularityFunction(x, prev_end, 0) \ - (prev_def + deflection_value)*SingularityFunction(x, args[i][1].args[1], 0) else: deflection += (prev_def + deflection_value)*SingularityFunction(x, prev_end, 0) prev_slope = slope_value.subs(x, args[i][1].args[1]) prev_def = deflection_value.subs(x, args[i][1].args[1]) return deflection C4 = Symbol('C4') deflection_curve = integrate(self.slope(), x) + C4 bc_eqs = [] for position, value in self._boundary_conditions['deflection']: eqs = deflection_curve.subs(x, position) - value bc_eqs.append(eqs) constants = list(linsolve(bc_eqs, C4)) deflection_curve = deflection_curve.subs({C4: constants[0][0]}) return deflection_curve def max_deflection(self): """ Returns point of max deflection and its coresponding deflection value in a Beam object. """ from sympy import solve, Piecewise # To restrict the range within length of the Beam slope_curve = Piecewise((float("nan"), self.variable<=0), (self.slope(), self.variable<self.length), (float("nan"), True)) points = solve(slope_curve.rewrite(Piecewise), self.variable, domain=S.Reals) deflection_curve = self.deflection() deflections = [deflection_curve.subs(self.variable, x) for x in points] deflections = list(map(abs, deflections)) if len(deflections) != 0: max_def = max(deflections) return (points[deflections.index(max_def)], max_def) else: return None def plot_shear_force(self, subs=None): """ Returns a plot for Shear force present in the Beam object. Parameters ========== subs : dictionary Python dictionary containing Symbols as key and their corresponding values. Examples ======== There is a beam of length 8 meters. A constant distributed load of 10 KN/m is applied from half of the beam till the end. There are two simple supports below the beam, one at the starting point and another at the ending point of the beam. A pointload of magnitude 5 KN is also applied from top of the beam, at a distance of 4 meters from the starting point. Take E = 200 GPa and I = 400*(10**-6) meter**4. Using the sign convention of downwards forces being positive. .. plot:: :context: close-figs :format: doctest :include-source: True >>> from sympy.physics.continuum_mechanics.beam import Beam >>> from sympy import symbols >>> R1, R2 = symbols('R1, R2') >>> b = Beam(8, 200*(10**9), 400*(10**-6)) >>> b.apply_load(5000, 2, -1) >>> b.apply_load(R1, 0, -1) >>> b.apply_load(R2, 8, -1) >>> b.apply_load(10000, 4, 0, end=8) >>> b.bc_deflection = [(0, 0), (8, 0)] >>> b.solve_for_reaction_loads(R1, R2) >>> b.plot_shear_force() Plot object containing: [0]: cartesian line: -13750*SingularityFunction(x, 0, 0) + 5000*SingularityFunction(x, 2, 0) + 10000*SingularityFunction(x, 4, 1) - 31250*SingularityFunction(x, 8, 0) - 10000*SingularityFunction(x, 8, 1) for x over (0.0, 8.0) """ shear_force = self.shear_force() if subs is None: subs = {} for sym in shear_force.atoms(Symbol): if sym == self.variable: continue if sym not in subs: raise ValueError('Value of %s was not passed.' %sym) if self.length in subs: length = subs[self.length] else: length = self.length return plot(shear_force.subs(subs), (self.variable, 0, length), title='Shear Force', xlabel='position', ylabel='Value', line_color='g') def plot_bending_moment(self, subs=None): """ Returns a plot for Bending moment present in the Beam object. Parameters ========== subs : dictionary Python dictionary containing Symbols as key and their corresponding values. Examples ======== There is a beam of length 8 meters. A constant distributed load of 10 KN/m is applied from half of the beam till the end. There are two simple supports below the beam, one at the starting point and another at the ending point of the beam. A pointload of magnitude 5 KN is also applied from top of the beam, at a distance of 4 meters from the starting point. Take E = 200 GPa and I = 400*(10**-6) meter**4. Using the sign convention of downwards forces being positive. .. plot:: :context: close-figs :format: doctest :include-source: True >>> from sympy.physics.continuum_mechanics.beam import Beam >>> from sympy import symbols >>> R1, R2 = symbols('R1, R2') >>> b = Beam(8, 200*(10**9), 400*(10**-6)) >>> b.apply_load(5000, 2, -1) >>> b.apply_load(R1, 0, -1) >>> b.apply_load(R2, 8, -1) >>> b.apply_load(10000, 4, 0, end=8) >>> b.bc_deflection = [(0, 0), (8, 0)] >>> b.solve_for_reaction_loads(R1, R2) >>> b.plot_bending_moment() Plot object containing: [0]: cartesian line: -13750*SingularityFunction(x, 0, 1) + 5000*SingularityFunction(x, 2, 1) + 5000*SingularityFunction(x, 4, 2) - 31250*SingularityFunction(x, 8, 1) - 5000*SingularityFunction(x, 8, 2) for x over (0.0, 8.0) """ bending_moment = self.bending_moment() if subs is None: subs = {} for sym in bending_moment.atoms(Symbol): if sym == self.variable: continue if sym not in subs: raise ValueError('Value of %s was not passed.' %sym) if self.length in subs: length = subs[self.length] else: length = self.length return plot(bending_moment.subs(subs), (self.variable, 0, length), title='Bending Moment', xlabel='position', ylabel='Value', line_color='b') def plot_slope(self, subs=None): """ Returns a plot for slope of deflection curve of the Beam object. Parameters ========== subs : dictionary Python dictionary containing Symbols as key and their corresponding values. Examples ======== There is a beam of length 8 meters. A constant distributed load of 10 KN/m is applied from half of the beam till the end. There are two simple supports below the beam, one at the starting point and another at the ending point of the beam. A pointload of magnitude 5 KN is also applied from top of the beam, at a distance of 4 meters from the starting point. Take E = 200 GPa and I = 400*(10**-6) meter**4. Using the sign convention of downwards forces being positive. .. plot:: :context: close-figs :format: doctest :include-source: True >>> from sympy.physics.continuum_mechanics.beam import Beam >>> from sympy import symbols >>> R1, R2 = symbols('R1, R2') >>> b = Beam(8, 200*(10**9), 400*(10**-6)) >>> b.apply_load(5000, 2, -1) >>> b.apply_load(R1, 0, -1) >>> b.apply_load(R2, 8, -1) >>> b.apply_load(10000, 4, 0, end=8) >>> b.bc_deflection = [(0, 0), (8, 0)] >>> b.solve_for_reaction_loads(R1, R2) >>> b.plot_slope() Plot object containing: [0]: cartesian line: -8.59375e-5*SingularityFunction(x, 0, 2) + 3.125e-5*SingularityFunction(x, 2, 2) + 2.08333333333333e-5*SingularityFunction(x, 4, 3) - 0.0001953125*SingularityFunction(x, 8, 2) - 2.08333333333333e-5*SingularityFunction(x, 8, 3) + 0.00138541666666667 for x over (0.0, 8.0) """ slope = self.slope() if subs is None: subs = {} for sym in slope.atoms(Symbol): if sym == self.variable: continue if sym not in subs: raise ValueError('Value of %s was not passed.' %sym) if self.length in subs: length = subs[self.length] else: length = self.length return plot(slope.subs(subs), (self.variable, 0, length), title='Slope', xlabel='position', ylabel='Value', line_color='m') def plot_deflection(self, subs=None): """ Returns a plot for deflection curve of the Beam object. Parameters ========== subs : dictionary Python dictionary containing Symbols as key and their corresponding values. Examples ======== There is a beam of length 8 meters. A constant distributed load of 10 KN/m is applied from half of the beam till the end. There are two simple supports below the beam, one at the starting point and another at the ending point of the beam. A pointload of magnitude 5 KN is also applied from top of the beam, at a distance of 4 meters from the starting point. Take E = 200 GPa and I = 400*(10**-6) meter**4. Using the sign convention of downwards forces being positive. .. plot:: :context: close-figs :format: doctest :include-source: True >>> from sympy.physics.continuum_mechanics.beam import Beam >>> from sympy import symbols >>> R1, R2 = symbols('R1, R2') >>> b = Beam(8, 200*(10**9), 400*(10**-6)) >>> b.apply_load(5000, 2, -1) >>> b.apply_load(R1, 0, -1) >>> b.apply_load(R2, 8, -1) >>> b.apply_load(10000, 4, 0, end=8) >>> b.bc_deflection = [(0, 0), (8, 0)] >>> b.solve_for_reaction_loads(R1, R2) >>> b.plot_deflection() Plot object containing: [0]: cartesian line: 0.00138541666666667*x - 2.86458333333333e-5*SingularityFunction(x, 0, 3) + 1.04166666666667e-5*SingularityFunction(x, 2, 3) + 5.20833333333333e-6*SingularityFunction(x, 4, 4) - 6.51041666666667e-5*SingularityFunction(x, 8, 3) - 5.20833333333333e-6*SingularityFunction(x, 8, 4) for x over (0.0, 8.0) """ deflection = self.deflection() if subs is None: subs = {} for sym in deflection.atoms(Symbol): if sym == self.variable: continue if sym not in subs: raise ValueError('Value of %s was not passed.' %sym) if self.length in subs: length = subs[self.length] else: length = self.length return plot(deflection.subs(subs), (self.variable, 0, length), title='Deflection', xlabel='position', ylabel='Value', line_color='r') @doctest_depends_on(modules=('numpy', 'matplotlib',)) def plot_loading_results(self, subs=None): """ Returns Axes object containing subplots of Shear Force, Bending Moment, Slope and Deflection of the Beam object. Parameters ========== subs : dictionary Python dictionary containing Symbols as key and their corresponding values. .. note:: This method only works if numpy and matplotlib libraries are installed on the system. Examples ======== There is a beam of length 8 meters. A constant distributed load of 10 KN/m is applied from half of the beam till the end. There are two simple supports below the beam, one at the starting point and another at the ending point of the beam. A pointload of magnitude 5 KN is also applied from top of the beam, at a distance of 4 meters from the starting point. Take E = 200 GPa and I = 400*(10**-6) meter**4. Using the sign convention of downwards forces being positive. >>> from sympy.physics.continuum_mechanics.beam import Beam >>> from sympy import symbols >>> R1, R2 = symbols('R1, R2') >>> b = Beam(8, 200*(10**9), 400*(10**-6)) >>> b.apply_load(5000, 2, -1) >>> b.apply_load(R1, 0, -1) >>> b.apply_load(R2, 8, -1) >>> b.apply_load(10000, 4, 0, end=8) >>> b.bc_deflection = [(0, 0), (8, 0)] >>> b.solve_for_reaction_loads(R1, R2) >>> axes = b.plot_loading_results() """ if matplotlib is None: raise ImportError('Install matplotlib to use this method.') else: plt = matplotlib.pyplot if numpy is None: raise ImportError('Install numpy to use this method.') else: linspace = numpy.linspace variable = self.variable if subs is None: subs = {} for sym in self.deflection().atoms(Symbol): if sym == self.variable: continue if sym not in subs: raise ValueError('Value of %s was not passed.' % sym) if self.length in subs: length = subs[self.length] else: length = self.length # As we are using matplotlib directly in this method, we need to change # SymPy methods to numpy functions. shear = lambdify(variable, self.shear_force().subs(subs).rewrite(Piecewise), 'numpy') moment = lambdify(variable, self.bending_moment().subs(subs).rewrite(Piecewise), 'numpy') slope = lambdify(variable, self.slope().subs(subs).rewrite(Piecewise), 'numpy') deflection = lambdify(variable, self.deflection().subs(subs).rewrite(Piecewise), 'numpy') points = linspace(0, float(length), num=100*length) # Creating a grid for subplots with 2 rows and 2 columns fig, axs = plt.subplots(4, 1) # axs is a 2D-numpy array containing axes axs[0].plot(points, shear(points)) axs[0].set_title("Shear Force") axs[1].plot(points, moment(points)) axs[1].set_title("Bending Moment") axs[2].plot(points, slope(points)) axs[2].set_title("Slope") axs[3].plot(points, deflection(points)) axs[3].set_title("Deflection") fig.tight_layout() # For better spacing between subplots return axs class Beam3D(Beam): """ This class handles loads applied in any direction of a 3D space along with unequal values of Second moment along different axes. .. note:: While solving a beam bending problem, a user should choose its own sign convention and should stick to it. The results will automatically follow the chosen sign convention. This class assumes that any kind of distributed load/moment is applied through out the span of a beam. Examples ======== There is a beam of l meters long. A constant distributed load of magnitude q is applied along y-axis from start till the end of beam. A constant distributed moment of magnitude m is also applied along z-axis from start till the end of beam. Beam is fixed at both of its end. So, deflection of the beam at the both ends is restricted. >>> from sympy.physics.continuum_mechanics.beam import Beam3D >>> from sympy import symbols, simplify >>> l, E, G, I, A = symbols('l, E, G, I, A') >>> b = Beam3D(l, E, G, I, A) >>> x, q, m = symbols('x, q, m') >>> b.apply_load(q, 0, 0, dir="y") >>> b.apply_moment_load(m, 0, -1, dir="z") >>> b.shear_force() [0, -q*x, 0] >>> b.bending_moment() [0, 0, -m*x + q*x**2/2] >>> b.bc_slope = [(0, [0, 0, 0]), (l, [0, 0, 0])] >>> b.bc_deflection = [(0, [0, 0, 0]), (l, [0, 0, 0])] >>> b.solve_slope_deflection() >>> b.slope() [0, 0, l*x*(-l*q + 3*l*(A*G*l*(l*q - 2*m) + 12*E*I*q)/(2*(A*G*l**2 + 12*E*I)) + 3*m)/(6*E*I) + q*x**3/(6*E*I) + x**2*(-l*(A*G*l*(l*q - 2*m) + 12*E*I*q)/(2*(A*G*l**2 + 12*E*I)) - m)/(2*E*I)] >>> dx, dy, dz = b.deflection() >>> dx 0 >>> dz 0 >>> expectedy = ( ... -l**2*q*x**2/(12*E*I) + l**2*x**2*(A*G*l*(l*q - 2*m) + 12*E*I*q)/(8*E*I*(A*G*l**2 + 12*E*I)) ... + l*m*x**2/(4*E*I) - l*x**3*(A*G*l*(l*q - 2*m) + 12*E*I*q)/(12*E*I*(A*G*l**2 + 12*E*I)) - m*x**3/(6*E*I) ... + q*x**4/(24*E*I) + l*x*(A*G*l*(l*q - 2*m) + 12*E*I*q)/(2*A*G*(A*G*l**2 + 12*E*I)) - q*x**2/(2*A*G) ... ) >>> simplify(dy - expectedy) 0 References ========== .. [1] http://homes.civil.aau.dk/jc/FemteSemester/Beams3D.pdf """ def __init__(self, length, elastic_modulus, shear_modulus , second_moment, area, variable=Symbol('x')): """Initializes the class. Parameters ========== length : Sympifyable A Symbol or value representing the Beam's length. elastic_modulus : Sympifyable A SymPy expression representing the Beam's Modulus of Elasticity. It is a measure of the stiffness of the Beam material. shear_modulus : Sympifyable A SymPy expression representing the Beam's Modulus of rigidity. It is a measure of rigidity of the Beam material. second_moment : Sympifyable or list A list of two elements having SymPy expression representing the Beam's Second moment of area. First value represent Second moment across y-axis and second across z-axis. Single SymPy expression can be passed if both values are same area : Sympifyable A SymPy expression representing the Beam's cross-sectional area in a plane prependicular to length of the Beam. variable : Symbol, optional A Symbol object that will be used as the variable along the beam while representing the load, shear, moment, slope and deflection curve. By default, it is set to ``Symbol('x')``. """ super(Beam3D, self).__init__(length, elastic_modulus, second_moment, variable) self.shear_modulus = shear_modulus self.area = area self._load_vector = [0, 0, 0] self._moment_load_vector = [0, 0, 0] self._load_Singularity = [0, 0, 0] self._slope = [0, 0, 0] self._deflection = [0, 0, 0] @property def shear_modulus(self): """Young's Modulus of the Beam. """ return self._shear_modulus @shear_modulus.setter def shear_modulus(self, e): self._shear_modulus = sympify(e) @property def second_moment(self): """Second moment of area of the Beam. """ return self._second_moment @second_moment.setter def second_moment(self, i): if isinstance(i, list): i = [sympify(x) for x in i] self._second_moment = i else: self._second_moment = sympify(i) @property def area(self): """Cross-sectional area of the Beam. """ return self._area @area.setter def area(self, a): self._area = sympify(a) @property def load_vector(self): """ Returns a three element list representing the load vector. """ return self._load_vector @property def moment_load_vector(self): """ Returns a three element list representing moment loads on Beam. """ return self._moment_load_vector @property def boundary_conditions(self): """ Returns a dictionary of boundary conditions applied on the beam. The dictionary has two keywords namely slope and deflection. The value of each keyword is a list of tuple, where each tuple contains loaction and value of a boundary condition in the format (location, value). Further each value is a list corresponding to slope or deflection(s) values along three axes at that location. Examples ======== There is a beam of length 4 meters. The slope at 0 should be 4 along the x-axis and 0 along others. At the other end of beam, deflection along all the three axes should be zero. >>> from sympy.physics.continuum_mechanics.beam import Beam3D >>> from sympy import symbols >>> l, E, G, I, A, x = symbols('l, E, G, I, A, x') >>> b = Beam3D(30, E, G, I, A, x) >>> b.bc_slope = [(0, (4, 0, 0))] >>> b.bc_deflection = [(4, [0, 0, 0])] >>> b.boundary_conditions {'deflection': [(4, [0, 0, 0])], 'slope': [(0, (4, 0, 0))]} Here the deflection of the beam should be ``0`` along all the three axes at ``4``. Similarly, the slope of the beam should be ``4`` along x-axis and ``0`` along y and z axis at ``0``. """ return self._boundary_conditions def apply_load(self, value, start, order, dir="y"): """ This method adds up the force load to a particular beam object. Parameters ========== value : Sympifyable The magnitude of an applied load. dir : String Axis along which load is applied. order : Integer The order of the applied load. - For point loads, order=-1 - For constant distributed load, order=0 - For ramp loads, order=1 - For parabolic ramp loads, order=2 - ... so on. """ x = self.variable value = sympify(value) start = sympify(start) order = sympify(order) if dir == "x": if not order == -1: self._load_vector[0] += value self._load_Singularity[0] += value*SingularityFunction(x, start, order) elif dir == "y": if not order == -1: self._load_vector[1] += value self._load_Singularity[1] += value*SingularityFunction(x, start, order) else: if not order == -1: self._load_vector[2] += value self._load_Singularity[2] += value*SingularityFunction(x, start, order) def apply_moment_load(self, value, start, order, dir="y"): """ This method adds up the moment loads to a particular beam object. Parameters ========== value : Sympifyable The magnitude of an applied moment. dir : String Axis along which moment is applied. order : Integer The order of the applied load. - For point moments, order=-2 - For constant distributed moment, order=-1 - For ramp moments, order=0 - For parabolic ramp moments, order=1 - ... so on. """ x = self.variable value = sympify(value) start = sympify(start) order = sympify(order) if dir == "x": if not order == -2: self._moment_load_vector[0] += value self._load_Singularity[0] += value*SingularityFunction(x, start, order) elif dir == "y": if not order == -2: self._moment_load_vector[1] += value self._load_Singularity[0] += value*SingularityFunction(x, start, order) else: if not order == -2: self._moment_load_vector[2] += value self._load_Singularity[0] += value*SingularityFunction(x, start, order) def apply_support(self, loc, type="fixed"): if type == "pin" or type == "roller": reaction_load = Symbol('R_'+str(loc)) self._reaction_loads[reaction_load] = reaction_load self.bc_deflection.append((loc, [0, 0, 0])) else: reaction_load = Symbol('R_'+str(loc)) reaction_moment = Symbol('M_'+str(loc)) self._reaction_loads[reaction_load] = [reaction_load, reaction_moment] self.bc_deflection.append((loc, [0, 0, 0])) self.bc_slope.append((loc, [0, 0, 0])) def solve_for_reaction_loads(self, *reaction): """ Solves for the reaction forces. Examples ======== There is a beam of length 30 meters. It it supported by rollers at of its end. A constant distributed load of magnitude 8 N is applied from start till its end along y-axis. Another linear load having slope equal to 9 is applied along z-axis. >>> from sympy.physics.continuum_mechanics.beam import Beam3D >>> from sympy import symbols >>> l, E, G, I, A, x = symbols('l, E, G, I, A, x') >>> b = Beam3D(30, E, G, I, A, x) >>> b.apply_load(8, start=0, order=0, dir="y") >>> b.apply_load(9*x, start=0, order=0, dir="z") >>> b.bc_deflection = [(0, [0, 0, 0]), (30, [0, 0, 0])] >>> R1, R2, R3, R4 = symbols('R1, R2, R3, R4') >>> b.apply_load(R1, start=0, order=-1, dir="y") >>> b.apply_load(R2, start=30, order=-1, dir="y") >>> b.apply_load(R3, start=0, order=-1, dir="z") >>> b.apply_load(R4, start=30, order=-1, dir="z") >>> b.solve_for_reaction_loads(R1, R2, R3, R4) >>> b.reaction_loads {R1: -120, R2: -120, R3: -1350, R4: -2700} """ x = self.variable l = self.length q = self._load_Singularity shear_curves = [integrate(load, x) for load in q] moment_curves = [integrate(shear, x) for shear in shear_curves] for i in range(3): react = [r for r in reaction if (shear_curves[i].has(r) or moment_curves[i].has(r))] if len(react) == 0: continue shear_curve = limit(shear_curves[i], x, l) moment_curve = limit(moment_curves[i], x, l) sol = list((linsolve([shear_curve, moment_curve], react).args)[0]) sol_dict = dict(zip(react, sol)) reaction_loads = self._reaction_loads # Check if any of the evaluated rection exists in another direction # and if it exists then it should have same value. for key in sol_dict: if key in reaction_loads and sol_dict[key] != reaction_loads[key]: raise ValueError("Ambiguous solution for %s in different directions." % key) self._reaction_loads.update(sol_dict) def shear_force(self): """ Returns a list of three expressions which represents the shear force curve of the Beam object along all three axes. """ x = self.variable q = self._load_vector return [integrate(-q[0], x), integrate(-q[1], x), integrate(-q[2], x)] def axial_force(self): """ Returns expression of Axial shear force present inside the Beam object. """ return self.shear_force()[0] def bending_moment(self): """ Returns a list of three expressions which represents the bending moment curve of the Beam object along all three axes. """ x = self.variable m = self._moment_load_vector shear = self.shear_force() return [integrate(-m[0], x), integrate(-m[1] + shear[2], x), integrate(-m[2] - shear[1], x) ] def torsional_moment(self): """ Returns expression of Torsional moment present inside the Beam object. """ return self.bending_moment()[0] def solve_slope_deflection(self): from sympy import dsolve, Function, Derivative, Eq x = self.variable l = self.length E = self.elastic_modulus G = self.shear_modulus I = self.second_moment if isinstance(I, list): I_y, I_z = I[0], I[1] else: I_y = I_z = I A = self.area load = self._load_vector moment = self._moment_load_vector defl = Function('defl') theta = Function('theta') # Finding deflection along x-axis(and corresponding slope value by differentiating it) # Equation used: Derivative(E*A*Derivative(def_x(x), x), x) + load_x = 0 eq = Derivative(E*A*Derivative(defl(x), x), x) + load[0] def_x = dsolve(Eq(eq, 0), defl(x)).args[1] # Solving constants originated from dsolve C1 = Symbol('C1') C2 = Symbol('C2') constants = list((linsolve([def_x.subs(x, 0), def_x.subs(x, l)], C1, C2).args)[0]) def_x = def_x.subs({C1:constants[0], C2:constants[1]}) slope_x = def_x.diff(x) self._deflection[0] = def_x self._slope[0] = slope_x # Finding deflection along y-axis and slope across z-axis. System of equation involved: # 1: Derivative(E*I_z*Derivative(theta_z(x), x), x) + G*A*(Derivative(defl_y(x), x) - theta_z(x)) + moment_z = 0 # 2: Derivative(G*A*(Derivative(defl_y(x), x) - theta_z(x)), x) + load_y = 0 C_i = Symbol('C_i') # Substitute value of `G*A*(Derivative(defl_y(x), x) - theta_z(x))` from (2) in (1) eq1 = Derivative(E*I_z*Derivative(theta(x), x), x) + (integrate(-load[1], x) + C_i) + moment[2] slope_z = dsolve(Eq(eq1, 0)).args[1] # Solve for constants originated from using dsolve on eq1 constants = list((linsolve([slope_z.subs(x, 0), slope_z.subs(x, l)], C1, C2).args)[0]) slope_z = slope_z.subs({C1:constants[0], C2:constants[1]}) # Put value of slope obtained back in (2) to solve for `C_i` and find deflection across y-axis eq2 = G*A*(Derivative(defl(x), x)) + load[1]*x - C_i - G*A*slope_z def_y = dsolve(Eq(eq2, 0), defl(x)).args[1] # Solve for constants originated from using dsolve on eq2 constants = list((linsolve([def_y.subs(x, 0), def_y.subs(x, l)], C1, C_i).args)[0]) self._deflection[1] = def_y.subs({C1:constants[0], C_i:constants[1]}) self._slope[2] = slope_z.subs(C_i, constants[1]) # Finding deflection along z-axis and slope across y-axis. System of equation involved: # 1: Derivative(E*I_y*Derivative(theta_y(x), x), x) - G*A*(Derivative(defl_z(x), x) + theta_y(x)) + moment_y = 0 # 2: Derivative(G*A*(Derivative(defl_z(x), x) + theta_y(x)), x) + load_z = 0 # Substitute value of `G*A*(Derivative(defl_y(x), x) + theta_z(x))` from (2) in (1) eq1 = Derivative(E*I_y*Derivative(theta(x), x), x) + (integrate(load[2], x) - C_i) + moment[1] slope_y = dsolve(Eq(eq1, 0)).args[1] # Solve for constants originated from using dsolve on eq1 constants = list((linsolve([slope_y.subs(x, 0), slope_y.subs(x, l)], C1, C2).args)[0]) slope_y = slope_y.subs({C1:constants[0], C2:constants[1]}) # Put value of slope obtained back in (2) to solve for `C_i` and find deflection across z-axis eq2 = G*A*(Derivative(defl(x), x)) + load[2]*x - C_i + G*A*slope_y def_z = dsolve(Eq(eq2,0)).args[1] # Solve for constants originated from using dsolve on eq2 constants = list((linsolve([def_z.subs(x, 0), def_z.subs(x, l)], C1, C_i).args)[0]) self._deflection[2] = def_z.subs({C1:constants[0], C_i:constants[1]}) self._slope[1] = slope_y.subs(C_i, constants[1]) def slope(self): """ Returns a three element list representing slope of deflection curve along all the three axes. """ return self._slope def deflection(self): """ Returns a three element list representing deflection curve along all the three axes. """ return self._deflection
bc3e0e8c34b6e1e8cf85f1e950d04f2a25b0bbd997e97befbee9f4075d9ee576
""" **Contains** * refraction_angle * fresnel_coefficients * deviation * brewster_angle * critical_angle * lens_makers_formula * mirror_formula * lens_formula * hyperfocal_distance * transverse_magnification """ from __future__ import division __all__ = ['refraction_angle', 'deviation', 'fresnel_coefficients', 'brewster_angle', 'critical_angle', 'lens_makers_formula', 'mirror_formula', 'lens_formula', 'hyperfocal_distance', 'transverse_magnification' ] from sympy import Symbol, sympify, sqrt, Matrix, acos, oo, Limit, atan2, asin,\ cos, sin, tan, I, cancel from sympy.core.compatibility import is_sequence from sympy.geometry.line import Ray3D, Point3D from sympy.geometry.util import intersection from sympy.geometry.plane import Plane from .medium import Medium def refraction_angle(incident, medium1, medium2, normal=None, plane=None): """ This function calculates transmitted vector after refraction at planar surface. `medium1` and `medium2` can be `Medium` or any sympifiable object. If `incident` is an object of `Ray3D`, `normal` also has to be an instance of `Ray3D` in order to get the output as a `Ray3D`. Please note that if plane of separation is not provided and normal is an instance of `Ray3D`, normal will be assumed to be intersecting incident ray at the plane of separation. This will not be the case when `normal` is a `Matrix` or any other sequence. If `incident` is an instance of `Ray3D` and `plane` has not been provided and `normal` is not `Ray3D`, output will be a `Matrix`. Parameters ========== incident : Matrix, Ray3D, or sequence Incident vector medium1 : sympy.physics.optics.medium.Medium or sympifiable Medium 1 or its refractive index medium2 : sympy.physics.optics.medium.Medium or sympifiable Medium 2 or its refractive index normal : Matrix, Ray3D, or sequence Normal vector plane : Plane Plane of separation of the two media. Examples ======== >>> from sympy.physics.optics import refraction_angle >>> from sympy.geometry import Point3D, Ray3D, Plane >>> from sympy.matrices import Matrix >>> from sympy import symbols >>> n = Matrix([0, 0, 1]) >>> P = Plane(Point3D(0, 0, 0), normal_vector=[0, 0, 1]) >>> r1 = Ray3D(Point3D(-1, -1, 1), Point3D(0, 0, 0)) >>> refraction_angle(r1, 1, 1, n) Matrix([ [ 1], [ 1], [-1]]) >>> refraction_angle(r1, 1, 1, plane=P) Ray3D(Point3D(0, 0, 0), Point3D(1, 1, -1)) With different index of refraction of the two media >>> n1, n2 = symbols('n1, n2') >>> refraction_angle(r1, n1, n2, n) Matrix([ [ n1/n2], [ n1/n2], [-sqrt(3)*sqrt(-2*n1**2/(3*n2**2) + 1)]]) >>> refraction_angle(r1, n1, n2, plane=P) Ray3D(Point3D(0, 0, 0), Point3D(n1/n2, n1/n2, -sqrt(3)*sqrt(-2*n1**2/(3*n2**2) + 1))) """ # A flag to check whether to return Ray3D or not return_ray = False if plane is not None and normal is not None: raise ValueError("Either plane or normal is acceptable.") if not isinstance(incident, Matrix): if is_sequence(incident): _incident = Matrix(incident) elif isinstance(incident, Ray3D): _incident = Matrix(incident.direction_ratio) else: raise TypeError( "incident should be a Matrix, Ray3D, or sequence") else: _incident = incident # If plane is provided, get direction ratios of the normal # to the plane from the plane else go with `normal` param. if plane is not None: if not isinstance(plane, Plane): raise TypeError("plane should be an instance of geometry.plane.Plane") # If we have the plane, we can get the intersection # point of incident ray and the plane and thus return # an instance of Ray3D. if isinstance(incident, Ray3D): return_ray = True intersection_pt = plane.intersection(incident)[0] _normal = Matrix(plane.normal_vector) else: if not isinstance(normal, Matrix): if is_sequence(normal): _normal = Matrix(normal) elif isinstance(normal, Ray3D): _normal = Matrix(normal.direction_ratio) if isinstance(incident, Ray3D): intersection_pt = intersection(incident, normal) if len(intersection_pt) == 0: raise ValueError( "Normal isn't concurrent with the incident ray.") else: return_ray = True intersection_pt = intersection_pt[0] else: raise TypeError( "Normal should be a Matrix, Ray3D, or sequence") else: _normal = normal n1, n2 = None, None if isinstance(medium1, Medium): n1 = medium1.refractive_index else: n1 = sympify(medium1) if isinstance(medium2, Medium): n2 = medium2.refractive_index else: n2 = sympify(medium2) eta = n1/n2 # Relative index of refraction # Calculating magnitude of the vectors mag_incident = sqrt(sum([i**2 for i in _incident])) mag_normal = sqrt(sum([i**2 for i in _normal])) # Converting vectors to unit vectors by dividing # them with their magnitudes _incident /= mag_incident _normal /= mag_normal c1 = -_incident.dot(_normal) # cos(angle_of_incidence) cs2 = 1 - eta**2*(1 - c1**2) # cos(angle_of_refraction)**2 if cs2.is_negative: # This is the case of total internal reflection(TIR). return 0 drs = eta*_incident + (eta*c1 - sqrt(cs2))*_normal # Multiplying unit vector by its magnitude drs = drs*mag_incident if not return_ray: return drs else: return Ray3D(intersection_pt, direction_ratio=drs) def fresnel_coefficients(angle_of_incidence, medium1, medium2): """ This function uses Fresnel equations to calculate reflection and transmission coefficients. Those are obtained for both polarisations when the electric field vector is in the plane of incidence (labelled 'p') and when the electric field vector is perpendicular to the plane of incidence (labelled 's'). There are four real coefficients unless the incident ray reflects in total internal in which case there are two complex ones. Angle of incidence is the angle between the incident ray and the surface normal. ``medium1`` and ``medium2`` can be ``Medium`` or any sympifiable object. Parameters ========== angle_of_incidence : sympifiable medium1 : Medium or sympifiable Medium 1 or its refractive index medium2 : Medium or sympifiable Medium 2 or its refractive index Returns a list with four real Fresnel coefficients: [reflection p (TM), reflection s (TE), transmission p (TM), transmission s (TE)] If the ray is undergoes total internal reflection then returns a list of two complex Fresnel coefficients: [reflection p (TM), reflection s (TE)] Examples ======== >>> from sympy.physics.optics import fresnel_coefficients >>> fresnel_coefficients(0.3, 1, 2) [0.317843553417859, -0.348645229818821, 0.658921776708929, 0.651354770181179] >>> fresnel_coefficients(0.6, 2, 1) [-0.235625382192159 - 0.971843958291041*I, 0.816477005968898 - 0.577377951366403*I] References ========== https://en.wikipedia.org/wiki/Fresnel_equations """ if isinstance(medium1, Medium): n1 = medium1.refractive_index else: n1 = sympify(medium1) if isinstance(medium2, Medium): n2 = medium2.refractive_index else: n2 = sympify(medium2) angle_of_refraction = asin(n1*sin(angle_of_incidence)/n2) try: angle_of_total_internal_reflection_onset = critical_angle(n1, n2) except ValueError: angle_of_total_internal_reflection_onset = None if angle_of_total_internal_reflection_onset == None or\ angle_of_total_internal_reflection_onset > angle_of_incidence: R_s = -sin(angle_of_incidence - angle_of_refraction)\ /sin(angle_of_incidence + angle_of_refraction) R_p = tan(angle_of_incidence - angle_of_refraction)\ /tan(angle_of_incidence + angle_of_refraction) T_s = 2*sin(angle_of_refraction)*cos(angle_of_incidence)\ /sin(angle_of_incidence + angle_of_refraction) T_p = 2*sin(angle_of_refraction)*cos(angle_of_incidence)\ /(sin(angle_of_incidence + angle_of_refraction)\ *cos(angle_of_incidence - angle_of_refraction)) return [R_p, R_s, T_p, T_s] else: n = n2/n1 R_s = cancel((cos(angle_of_incidence)-\ I*sqrt(sin(angle_of_incidence)**2 - n**2))\ /(cos(angle_of_incidence)+\ I*sqrt(sin(angle_of_incidence)**2 - n**2))) R_p = cancel((n**2*cos(angle_of_incidence)-\ I*sqrt(sin(angle_of_incidence)**2 - n**2))\ /(n**2*cos(angle_of_incidence)+\ I*sqrt(sin(angle_of_incidence)**2 - n**2))) return [R_p, R_s] def deviation(incident, medium1, medium2, normal=None, plane=None): """ This function calculates the angle of deviation of a ray due to refraction at planar surface. Parameters ========== incident : Matrix, Ray3D, or sequence Incident vector medium1 : sympy.physics.optics.medium.Medium or sympifiable Medium 1 or its refractive index medium2 : sympy.physics.optics.medium.Medium or sympifiable Medium 2 or its refractive index normal : Matrix, Ray3D, or sequence Normal vector plane : Plane Plane of separation of the two media. Examples ======== >>> from sympy.physics.optics import deviation >>> from sympy.geometry import Point3D, Ray3D, Plane >>> from sympy.matrices import Matrix >>> from sympy import symbols >>> n1, n2 = symbols('n1, n2') >>> n = Matrix([0, 0, 1]) >>> P = Plane(Point3D(0, 0, 0), normal_vector=[0, 0, 1]) >>> r1 = Ray3D(Point3D(-1, -1, 1), Point3D(0, 0, 0)) >>> deviation(r1, 1, 1, n) 0 >>> deviation(r1, n1, n2, plane=P) -acos(-sqrt(-2*n1**2/(3*n2**2) + 1)) + acos(-sqrt(3)/3) """ refracted = refraction_angle(incident, medium1, medium2, normal=normal, plane=plane) if refracted != 0: if isinstance(refracted, Ray3D): refracted = Matrix(refracted.direction_ratio) if not isinstance(incident, Matrix): if is_sequence(incident): _incident = Matrix(incident) elif isinstance(incident, Ray3D): _incident = Matrix(incident.direction_ratio) else: raise TypeError( "incident should be a Matrix, Ray3D, or sequence") else: _incident = incident if plane is None: if not isinstance(normal, Matrix): if is_sequence(normal): _normal = Matrix(normal) elif isinstance(normal, Ray3D): _normal = Matrix(normal.direction_ratio) else: raise TypeError( "normal should be a Matrix, Ray3D, or sequence") else: _normal = normal else: _normal = Matrix(plane.normal_vector) mag_incident = sqrt(sum([i**2 for i in _incident])) mag_normal = sqrt(sum([i**2 for i in _normal])) mag_refracted = sqrt(sum([i**2 for i in refracted])) _incident /= mag_incident _normal /= mag_normal refracted /= mag_refracted i = acos(_incident.dot(_normal)) r = acos(refracted.dot(_normal)) return i - r def brewster_angle(medium1, medium2): """ This function calculates the Brewster's angle of incidence to Medium 2 from Medium 1 in radians. Parameters ========== medium 1 : Medium or sympifiable Refractive index of Medium 1 medium 2 : Medium or sympifiable Refractive index of Medium 1 Examples ======== >>> from sympy.physics.optics import brewster_angle >>> brewster_angle(1, 1.33) 0.926093295503462 """ if isinstance(medium1, Medium): n1 = medium1.refractive_index else: n1 = sympify(medium1) if isinstance(medium2, Medium): n2 = medium2.refractive_index else: n2 = sympify(medium2) return atan2(n2, n1) def critical_angle(medium1, medium2): """ This function calculates the critical angle of incidence (marking the onset of total internal) to Medium 2 from Medium 1 in radians. Parameters ========== medium 1 : Medium or sympifiable Refractive index of Medium 1 medium 2 : Medium or sympifiable Refractive index of Medium 1 Examples ======== >>> from sympy.physics.optics import critical_angle >>> critical_angle(1.33, 1) 0.850908514477849 """ if isinstance(medium1, Medium): n1 = medium1.refractive_index else: n1 = sympify(medium1) if isinstance(medium2, Medium): n2 = medium2.refractive_index else: n2 = sympify(medium2) if n2 > n1: raise ValueError('Total internal reflection impossible for n1 < n2') else: return asin(n2/n1) def lens_makers_formula(n_lens, n_surr, r1, r2): """ This function calculates focal length of a thin lens. It follows cartesian sign convention. Parameters ========== n_lens : Medium or sympifiable Index of refraction of lens. n_surr : Medium or sympifiable Index of reflection of surrounding. r1 : sympifiable Radius of curvature of first surface. r2 : sympifiable Radius of curvature of second surface. Examples ======== >>> from sympy.physics.optics import lens_makers_formula >>> lens_makers_formula(1.33, 1, 10, -10) 15.1515151515151 """ if isinstance(n_lens, Medium): n_lens = n_lens.refractive_index else: n_lens = sympify(n_lens) if isinstance(n_surr, Medium): n_surr = n_surr.refractive_index else: n_surr = sympify(n_surr) r1 = sympify(r1) r2 = sympify(r2) return 1/((n_lens - n_surr)/n_surr*(1/r1 - 1/r2)) def mirror_formula(focal_length=None, u=None, v=None): """ This function provides one of the three parameters when two of them are supplied. This is valid only for paraxial rays. Parameters ========== focal_length : sympifiable Focal length of the mirror. u : sympifiable Distance of object from the pole on the principal axis. v : sympifiable Distance of the image from the pole on the principal axis. Examples ======== >>> from sympy.physics.optics import mirror_formula >>> from sympy.abc import f, u, v >>> mirror_formula(focal_length=f, u=u) f*u/(-f + u) >>> mirror_formula(focal_length=f, v=v) f*v/(-f + v) >>> mirror_formula(u=u, v=v) u*v/(u + v) """ if focal_length and u and v: raise ValueError("Please provide only two parameters") focal_length = sympify(focal_length) u = sympify(u) v = sympify(v) if u == oo: _u = Symbol('u') if v == oo: _v = Symbol('v') if focal_length == oo: _f = Symbol('f') if focal_length is None: if u == oo and v == oo: return Limit(Limit(_v*_u/(_v + _u), _u, oo), _v, oo).doit() if u == oo: return Limit(v*_u/(v + _u), _u, oo).doit() if v == oo: return Limit(_v*u/(_v + u), _v, oo).doit() return v*u/(v + u) if u is None: if v == oo and focal_length == oo: return Limit(Limit(_v*_f/(_v - _f), _v, oo), _f, oo).doit() if v == oo: return Limit(_v*focal_length/(_v - focal_length), _v, oo).doit() if focal_length == oo: return Limit(v*_f/(v - _f), _f, oo).doit() return v*focal_length/(v - focal_length) if v is None: if u == oo and focal_length == oo: return Limit(Limit(_u*_f/(_u - _f), _u, oo), _f, oo).doit() if u == oo: return Limit(_u*focal_length/(_u - focal_length), _u, oo).doit() if focal_length == oo: return Limit(u*_f/(u - _f), _f, oo).doit() return u*focal_length/(u - focal_length) def lens_formula(focal_length=None, u=None, v=None): """ This function provides one of the three parameters when two of them are supplied. This is valid only for paraxial rays. Parameters ========== focal_length : sympifiable Focal length of the mirror. u : sympifiable Distance of object from the optical center on the principal axis. v : sympifiable Distance of the image from the optical center on the principal axis. Examples ======== >>> from sympy.physics.optics import lens_formula >>> from sympy.abc import f, u, v >>> lens_formula(focal_length=f, u=u) f*u/(f + u) >>> lens_formula(focal_length=f, v=v) f*v/(f - v) >>> lens_formula(u=u, v=v) u*v/(u - v) """ if focal_length and u and v: raise ValueError("Please provide only two parameters") focal_length = sympify(focal_length) u = sympify(u) v = sympify(v) if u == oo: _u = Symbol('u') if v == oo: _v = Symbol('v') if focal_length == oo: _f = Symbol('f') if focal_length is None: if u == oo and v == oo: return Limit(Limit(_v*_u/(_u - _v), _u, oo), _v, oo).doit() if u == oo: return Limit(v*_u/(_u - v), _u, oo).doit() if v == oo: return Limit(_v*u/(u - _v), _v, oo).doit() return v*u/(u - v) if u is None: if v == oo and focal_length == oo: return Limit(Limit(_v*_f/(_f - _v), _v, oo), _f, oo).doit() if v == oo: return Limit(_v*focal_length/(focal_length - _v), _v, oo).doit() if focal_length == oo: return Limit(v*_f/(_f - v), _f, oo).doit() return v*focal_length/(focal_length - v) if v is None: if u == oo and focal_length == oo: return Limit(Limit(_u*_f/(_u + _f), _u, oo), _f, oo).doit() if u == oo: return Limit(_u*focal_length/(_u + focal_length), _u, oo).doit() if focal_length == oo: return Limit(u*_f/(u + _f), _f, oo).doit() return u*focal_length/(u + focal_length) def hyperfocal_distance(f, N, c): """ Parameters ========== f: sympifiable Focal length of a given lens N: sympifiable F-number of a given lens c: sympifiable Circle of Confusion (CoC) of a given image format Example ======= >>> from sympy.physics.optics import hyperfocal_distance >>> from sympy.abc import f, N, c >>> round(hyperfocal_distance(f = 0.5, N = 8, c = 0.0033), 2) 9.47 """ f = sympify(f) N = sympify(N) c = sympify(c) return (1/(N * c))*(f**2) def transverse_magnification(si, so): """ Calculates the transverse magnification, which is the ratio of the image size to the object size. Parameters ========== so: sympifiable Lens-object distance si: sympifiable Lens-image distance Example ======= >>> from sympy.physics.optics import transverse_magnification >>> transverse_magnification(30, 15) -2 """ si = sympify(si) so = sympify(so) return (-(si/so))
ab826a98f089bb07cc32364224778d518b7e5061d4bc60fe255c682ee5180ee1
from sympy import I, Mul, latex, Matrix from sympy.physics.quantum import (Dagger, Commutator, AntiCommutator, qapply, Operator, represent) from sympy.physics.quantum.pauli import (SigmaOpBase, SigmaX, SigmaY, SigmaZ, SigmaMinus, SigmaPlus, qsimplify_pauli) from sympy.physics.quantum.pauli import SigmaZKet, SigmaZBra from sympy.utilities.pytest import raises sx, sy, sz = SigmaX(), SigmaY(), SigmaZ() sx1, sy1, sz1 = SigmaX(1), SigmaY(1), SigmaZ(1) sx2, sy2, sz2 = SigmaX(2), SigmaY(2), SigmaZ(2) sm, sp = SigmaMinus(), SigmaPlus() sm1, sp1 = SigmaMinus(1), SigmaPlus(1) A, B = Operator("A"), Operator("B") def test_pauli_operators_types(): assert isinstance(sx, SigmaOpBase) and isinstance(sx, SigmaX) assert isinstance(sy, SigmaOpBase) and isinstance(sy, SigmaY) assert isinstance(sz, SigmaOpBase) and isinstance(sz, SigmaZ) assert isinstance(sm, SigmaOpBase) and isinstance(sm, SigmaMinus) assert isinstance(sp, SigmaOpBase) and isinstance(sp, SigmaPlus) def test_pauli_operators_commutator(): assert Commutator(sx, sy).doit() == 2 * I * sz assert Commutator(sy, sz).doit() == 2 * I * sx assert Commutator(sz, sx).doit() == 2 * I * sy def test_pauli_operators_commutator_with_labels(): assert Commutator(sx1, sy1).doit() == 2 * I * sz1 assert Commutator(sy1, sz1).doit() == 2 * I * sx1 assert Commutator(sz1, sx1).doit() == 2 * I * sy1 assert Commutator(sx2, sy2).doit() == 2 * I * sz2 assert Commutator(sy2, sz2).doit() == 2 * I * sx2 assert Commutator(sz2, sx2).doit() == 2 * I * sy2 assert Commutator(sx1, sy2).doit() == 0 assert Commutator(sy1, sz2).doit() == 0 assert Commutator(sz1, sx2).doit() == 0 def test_pauli_operators_anticommutator(): assert AntiCommutator(sy, sz).doit() == 0 assert AntiCommutator(sz, sx).doit() == 0 assert AntiCommutator(sx, sm).doit() == 1 assert AntiCommutator(sx, sp).doit() == 1 def test_pauli_operators_adjoint(): assert Dagger(sx) == sx assert Dagger(sy) == sy assert Dagger(sz) == sz def test_pauli_operators_adjoint_with_labels(): assert Dagger(sx1) == sx1 assert Dagger(sy1) == sy1 assert Dagger(sz1) == sz1 assert Dagger(sx1) != sx2 assert Dagger(sy1) != sy2 assert Dagger(sz1) != sz2 def test_pauli_operators_multiplication(): assert qsimplify_pauli(sx * sx) == 1 assert qsimplify_pauli(sy * sy) == 1 assert qsimplify_pauli(sz * sz) == 1 assert qsimplify_pauli(sx * sy) == I * sz assert qsimplify_pauli(sy * sz) == I * sx assert qsimplify_pauli(sz * sx) == I * sy assert qsimplify_pauli(sy * sx) == - I * sz assert qsimplify_pauli(sz * sy) == - I * sx assert qsimplify_pauli(sx * sz) == - I * sy def test_pauli_operators_multiplication_with_labels(): assert qsimplify_pauli(sx1 * sx1) == 1 assert qsimplify_pauli(sy1 * sy1) == 1 assert qsimplify_pauli(sz1 * sz1) == 1 assert isinstance(sx1 * sx2, Mul) assert isinstance(sy1 * sy2, Mul) assert isinstance(sz1 * sz2, Mul) assert qsimplify_pauli(sx1 * sy1 * sx2 * sy2) == - sz1 * sz2 assert qsimplify_pauli(sy1 * sz1 * sz2 * sx2) == - sx1 * sy2 def test_pauli_states(): sx, sz = SigmaX(), SigmaZ() up = SigmaZKet(0) down = SigmaZKet(1) assert qapply(sx * up) == down assert qapply(sx * down) == up assert qapply(sz * up) == up assert qapply(sz * down) == - down up = SigmaZBra(0) down = SigmaZBra(1) assert qapply(up * sx, dagger=True) == down assert qapply(down * sx, dagger=True) == up assert qapply(up * sz, dagger=True) == up assert qapply(down * sz, dagger=True) == - down assert Dagger(SigmaZKet(0)) == SigmaZBra(0) assert Dagger(SigmaZBra(1)) == SigmaZKet(1) raises(ValueError, lambda: SigmaZBra(2)) raises(ValueError, lambda: SigmaZKet(2)) def test_use_name(): assert sm.use_name is False assert sm1.use_name is True assert sx.use_name is False assert sx1.use_name is True def test_printing(): assert latex(sx) == r'{\sigma_x}' assert latex(sx1) == r'{\sigma_x^{(1)}}' assert latex(sy) == r'{\sigma_y}' assert latex(sy1) == r'{\sigma_y^{(1)}}' assert latex(sz) == r'{\sigma_z}' assert latex(sz1) == r'{\sigma_z^{(1)}}' assert latex(sm) == r'{\sigma_-}' assert latex(sm1) == r'{\sigma_-^{(1)}}' assert latex(sp) == r'{\sigma_+}' assert latex(sp1) == r'{\sigma_+^{(1)}}' def test_represent(): represent(sx) == Matrix([[0, 1], [1, 0]]) represent(sy) == Matrix([[0, -I], [I, 0]]) represent(sz) == Matrix([[1, 0], [0, -1]]) represent(sm) == Matrix([[0, 0], [1, 0]]) represent(sp) == Matrix([[0, 1], [0, 0]])
324c6611beef855f6de8d0af041a0050c6b7c0b6f1ec6fa72ab5f02a371a0fad
""" MKS unit system. MKS stands for "meter, kilogram, second". """ from __future__ import division from sympy.physics.units import UnitSystem from sympy.physics.units.definitions import G, Hz, J, N, Pa, W, c, g, kg, m, s from sympy.physics.units.dimensions import ( acceleration, action, energy, force, frequency, momentum, power, pressure, velocity, dimsys_MKS) from sympy.physics.units.prefixes import PREFIXES, prefix_unit dims = (velocity, acceleration, momentum, force, energy, power, pressure, frequency, action) # dimension system _mks_dim = dimsys_MKS units = [m, g, s, J, N, W, Pa, Hz] all_units = [] # Prefixes of units like g, J, N etc get added using `prefix_unit` # in the for loop, but the actual units have to be added manually. all_units.extend([g, J, N, W, Pa, Hz]) for u in units: all_units.extend(prefix_unit(u, PREFIXES)) all_units.extend([G, c]) # unit system MKS = UnitSystem(base=(m, kg, s), units=all_units, name="MKS")
2facdd0057c4aec9b6171c8e3477a43331353f852bfb7b05236013aa50fd4a5f
""" MKS unit system. MKS stands for "meter, kilogram, second, ampere". """ from __future__ import division from sympy.physics.units.definitions import Z0, A, C, F, H, S, T, V, Wb, ohm from sympy.physics.units.dimensions import ( capacitance, charge, conductance, current, impedance, inductance, magnetic_density, magnetic_flux, voltage, dimsys_MKSA) from sympy.physics.units.prefixes import PREFIXES, prefix_unit from sympy.physics.units.systems.mks import MKS dims = (voltage, impedance, conductance, current, capacitance, inductance, charge, magnetic_density, magnetic_flux) # dimension system _mksa_dim = dimsys_MKSA units = [A, V, ohm, S, F, H, C, T, Wb] all_units = [] for u in units: all_units.extend(prefix_unit(u, PREFIXES)) all_units.extend([Z0]) MKSA = MKS.extend(base=(A,), units=all_units, name='MKSA')
d4d441e2ba2dd0185032608815c8e4c30b760ef0cb02d14e6eafd1a86ac7a944
""" SI unit system. Based on MKSA, which stands for "meter, kilogram, second, ampere". Added kelvin, candela and mole. """ from __future__ import division from sympy.physics.units.definitions import ( K, cd, lux, mol,hertz, newton, pascal, joule, watt, coulomb, volt, farad, ohm, siemens, weber, tesla, henry, candela, becquerel, gray, katal) from sympy.physics.units.dimensions import ( amount_of_substance, temperature, dimsys_SI, frequency, force, pressure, energy, power, charge, voltage, capacitance, conductance, magnetic_flux, magnetic_density, inductance, luminous_intensity) from sympy.physics.units.prefixes import PREFIXES, prefix_unit from sympy.physics.units.systems.mksa import MKSA derived_dims = (frequency, force, pressure, energy, power, charge, voltage, capacitance, conductance, magnetic_flux, magnetic_density, inductance, luminous_intensity) base_dims = (amount_of_substance, luminous_intensity, temperature) # dimension system _si_dim = dimsys_SI units = [mol, cd, K, lux, hertz, newton, pascal, joule, watt, coulomb, volt, farad, ohm, siemens, weber, tesla, henry, candela, lux, becquerel, gray, katal] all_units = [] for u in units: all_units.extend(prefix_unit(u, PREFIXES)) all_units.extend([mol, cd, K, lux]) SI = MKSA.extend(base=(mol, cd, K), units=all_units, name='SI')
0300bd5a353eb14d00201eb6b15e8b78ae559d99919bf35582d80ec5497bd36b
from __future__ import print_function, division import functools from sympy import Basic, Tuple, S from sympy.core.sympify import _sympify from sympy.tensor.array.mutable_ndim_array import MutableNDimArray from sympy.tensor.array.ndim_array import NDimArray, ImmutableNDimArray class DenseNDimArray(NDimArray): def __new__(self, *args, **kwargs): return ImmutableDenseNDimArray(*args, **kwargs) def __getitem__(self, index): """ Allows to get items from N-dim array. Examples ======== >>> from sympy import MutableDenseNDimArray >>> a = MutableDenseNDimArray([0, 1, 2, 3], (2, 2)) >>> a [[0, 1], [2, 3]] >>> a[0, 0] 0 >>> a[1, 1] 3 Symbolic index: >>> from sympy.abc import i, j >>> a[i, j] [[0, 1], [2, 3]][i, j] Replace `i` and `j` to get element `(1, 1)`: >>> a[i, j].subs({i: 1, j: 1}) 3 """ syindex = self._check_symbolic_index(index) if syindex is not None: return syindex if isinstance(index, tuple) and any([isinstance(i, slice) for i in index]): sl_factors, eindices = self._get_slice_data_for_array_access(index) array = [self._array[self._parse_index(i)] for i in eindices] nshape = [len(el) for i, el in enumerate(sl_factors) if isinstance(index[i], slice)] return type(self)(array, nshape) else: if isinstance(index, slice): return self._array[index] else: index = self._parse_index(index) return self._array[index] @classmethod def zeros(cls, *shape): list_length = functools.reduce(lambda x, y: x*y, shape, S.One) return cls._new(([0]*list_length,), shape) def tomatrix(self): """ Converts MutableDenseNDimArray to Matrix. Can convert only 2-dim array, else will raise error. Examples ======== >>> from sympy import MutableDenseNDimArray >>> a = MutableDenseNDimArray([1 for i in range(9)], (3, 3)) >>> b = a.tomatrix() >>> b Matrix([ [1, 1, 1], [1, 1, 1], [1, 1, 1]]) """ from sympy.matrices import Matrix if self.rank() != 2: raise ValueError('Dimensions must be of size of 2') return Matrix(self.shape[0], self.shape[1], self._array) def __iter__(self): return self._array.__iter__() def reshape(self, *newshape): """ Returns MutableDenseNDimArray instance with new shape. Elements number must be suitable to new shape. The only argument of method sets new shape. Examples ======== >>> from sympy import MutableDenseNDimArray >>> a = MutableDenseNDimArray([1, 2, 3, 4, 5, 6], (2, 3)) >>> a.shape (2, 3) >>> a [[1, 2, 3], [4, 5, 6]] >>> b = a.reshape(3, 2) >>> b.shape (3, 2) >>> b [[1, 2], [3, 4], [5, 6]] """ new_total_size = functools.reduce(lambda x,y: x*y, newshape) if new_total_size != self._loop_size: raise ValueError("Invalid reshape parameters " + newshape) # there is no `.func` as this class does not subtype `Basic`: return type(self)(self._array, newshape) class ImmutableDenseNDimArray(DenseNDimArray, ImmutableNDimArray): """ """ def __new__(cls, iterable, shape=None, **kwargs): return cls._new(iterable, shape, **kwargs) @classmethod def _new(cls, iterable, shape, **kwargs): from sympy.utilities.iterables import flatten shape, flat_list = cls._handle_ndarray_creation_inputs(iterable, shape, **kwargs) shape = Tuple(*map(_sympify, shape)) cls._check_special_bounds(flat_list, shape) flat_list = flatten(flat_list) flat_list = Tuple(*flat_list) self = Basic.__new__(cls, flat_list, shape, **kwargs) self._shape = shape self._array = list(flat_list) self._rank = len(shape) self._loop_size = functools.reduce(lambda x,y: x*y, shape, 1) return self def __setitem__(self, index, value): raise TypeError('immutable N-dim array') def as_mutable(self): return MutableDenseNDimArray(self) class MutableDenseNDimArray(DenseNDimArray, MutableNDimArray): def __new__(cls, iterable=None, shape=None, **kwargs): return cls._new(iterable, shape, **kwargs) @classmethod def _new(cls, iterable, shape, **kwargs): from sympy.utilities.iterables import flatten shape, flat_list = cls._handle_ndarray_creation_inputs(iterable, shape, **kwargs) flat_list = flatten(flat_list) self = object.__new__(cls) self._shape = shape self._array = list(flat_list) self._rank = len(shape) self._loop_size = functools.reduce(lambda x,y: x*y, shape) if shape else 0 return self def __setitem__(self, index, value): """Allows to set items to MutableDenseNDimArray. Examples ======== >>> from sympy import MutableDenseNDimArray >>> a = MutableDenseNDimArray.zeros(2, 2) >>> a[0,0] = 1 >>> a[1,1] = 1 >>> a [[1, 0], [0, 1]] """ if isinstance(index, tuple) and any([isinstance(i, slice) for i in index]): value, eindices, slice_offsets = self._get_slice_data_for_array_assignment(index, value) for i in eindices: other_i = [ind - j for ind, j in zip(i, slice_offsets) if j is not None] self._array[self._parse_index(i)] = value[other_i] else: index = self._parse_index(index) self._setter_iterable_check(value) value = _sympify(value) self._array[index] = value def as_immutable(self): return ImmutableDenseNDimArray(self) @property def free_symbols(self): return {i for j in self._array for i in j.free_symbols}
6aa85e9f2ec90e5ea13b8f1c52176fd378696c7219f8974d791170a78ae0d06f
from functools import wraps from sympy import Matrix, eye, Integer, expand, Indexed, Sum from sympy.combinatorics import Permutation from sympy.core import S, Rational, Symbol, Basic, Add from sympy.core.containers import Tuple from sympy.core.symbol import symbols from sympy.functions.elementary.miscellaneous import sqrt from sympy.printing.pretty.pretty import pretty from sympy.tensor.array import Array from sympy.tensor.tensor import TensorIndexType, tensor_indices, TensorSymmetry, \ get_symmetric_group_sgs, TensorType, TensorIndex, tensor_mul, TensAdd, \ riemann_cyclic_replace, riemann_cyclic, TensMul, tensorsymmetry, tensorhead, \ TensorManager, TensExpr, TensorHead, canon_bp from sympy.utilities.pytest import raises, XFAIL, ignore_warnings from sympy.utilities.exceptions import SymPyDeprecationWarning from sympy.core.compatibility import range from sympy.matrices import diag def filter_warnings_decorator(f): @wraps(f) def wrapper(): with ignore_warnings(SymPyDeprecationWarning): f() return wrapper def _is_equal(arg1, arg2): if isinstance(arg1, TensExpr): return arg1.equals(arg2) elif isinstance(arg2, TensExpr): return arg2.equals(arg1) return arg1 == arg2 #################### Tests from tensor_can.py ####################### def test_canonicalize_no_slot_sym(): # A_d0 * B^d0; T_c = A^d0*B_d0 Lorentz = TensorIndexType('Lorentz', dummy_fmt='L') a, b, d0, d1 = tensor_indices('a,b,d0,d1', Lorentz) sym1 = tensorsymmetry([1]) S1 = TensorType([Lorentz], sym1) A, B = S1('A,B') t = A(-d0)*B(d0) tc = t.canon_bp() assert str(tc) == 'A(L_0)*B(-L_0)' # A^a * B^b; T_c = T t = A(a)*B(b) tc = t.canon_bp() assert tc == t # B^b * A^a t1 = B(b)*A(a) tc = t1.canon_bp() assert str(tc) == 'A(a)*B(b)' # A symmetric # A^{b}_{d0}*A^{d0, a}; T_c = A^{a d0}*A{b}_{d0} sym2 = tensorsymmetry([1]*2) S2 = TensorType([Lorentz]*2, sym2) A = S2('A') t = A(b, -d0)*A(d0, a) tc = t.canon_bp() assert str(tc) == 'A(a, L_0)*A(b, -L_0)' # A^{d1}_{d0}*B^d0*C_d1 # T_c = A^{d0 d1}*B_d0*C_d1 B, C = S1('B,C') t = A(d1, -d0)*B(d0)*C(-d1) tc = t.canon_bp() assert str(tc) == 'A(L_0, L_1)*B(-L_0)*C(-L_1)' # A without symmetry # A^{d1}_{d0}*B^d0*C_d1 ord=[d0,-d0,d1,-d1]; g = [2,1,0,3,4,5] # T_c = A^{d0 d1}*B_d1*C_d0; can = [0,2,3,1,4,5] nsym2 = tensorsymmetry([1],[1]) NS2 = TensorType([Lorentz]*2, nsym2) A = NS2('A') B, C = S1('B, C') t = A(d1, -d0)*B(d0)*C(-d1) tc = t.canon_bp() assert str(tc) == 'A(L_0, L_1)*B(-L_1)*C(-L_0)' # A, B without symmetry # A^{d1}_{d0}*B_{d1}^{d0} # T_c = A^{d0 d1}*B_{d0 d1} B = NS2('B') t = A(d1, -d0)*B(-d1, d0) tc = t.canon_bp() assert str(tc) == 'A(L_0, L_1)*B(-L_0, -L_1)' # A_{d0}^{d1}*B_{d1}^{d0} # T_c = A^{d0 d1}*B_{d1 d0} t = A(-d0, d1)*B(-d1, d0) tc = t.canon_bp() assert str(tc) == 'A(L_0, L_1)*B(-L_1, -L_0)' # A, B, C without symmetry # A^{d1 d0}*B_{a d0}*C_{d1 b} # T_c=A^{d0 d1}*B_{a d1}*C_{d0 b} C = NS2('C') t = A(d1, d0)*B(-a, -d0)*C(-d1, -b) tc = t.canon_bp() assert str(tc) == 'A(L_0, L_1)*B(-a, -L_1)*C(-L_0, -b)' # A symmetric, B and C without symmetry # A^{d1 d0}*B_{a d0}*C_{d1 b} # T_c = A^{d0 d1}*B_{a d0}*C_{d1 b} A = S2('A') t = A(d1, d0)*B(-a, -d0)*C(-d1, -b) tc = t.canon_bp() assert str(tc) == 'A(L_0, L_1)*B(-a, -L_0)*C(-L_1, -b)' # A and C symmetric, B without symmetry # A^{d1 d0}*B_{a d0}*C_{d1 b} ord=[a,b,d0,-d0,d1,-d1] # T_c = A^{d0 d1}*B_{a d0}*C_{b d1} C = S2('C') t = A(d1, d0)*B(-a, -d0)*C(-d1, -b) tc = t.canon_bp() assert str(tc) == 'A(L_0, L_1)*B(-a, -L_0)*C(-b, -L_1)' def test_canonicalize_no_dummies(): Lorentz = TensorIndexType('Lorentz', dummy_fmt='L') a, b, c, d = tensor_indices('a, b, c, d', Lorentz) sym1 = tensorsymmetry([1]) sym2 = tensorsymmetry([1]*2) sym2a = tensorsymmetry([2]) # A commuting # A^c A^b A^a # T_c = A^a A^b A^c S1 = TensorType([Lorentz], sym1) A = S1('A') t = A(c)*A(b)*A(a) tc = t.canon_bp() assert str(tc) == 'A(a)*A(b)*A(c)' # A anticommuting # A^c A^b A^a # T_c = -A^a A^b A^c A = S1('A', 1) t = A(c)*A(b)*A(a) tc = t.canon_bp() assert str(tc) == '-A(a)*A(b)*A(c)' # A commuting and symmetric # A^{b,d}*A^{c,a} # T_c = A^{a c}*A^{b d} S2 = TensorType([Lorentz]*2, sym2) A = S2('A') t = A(b, d)*A(c, a) tc = t.canon_bp() assert str(tc) == 'A(a, c)*A(b, d)' # A anticommuting and symmetric # A^{b,d}*A^{c,a} # T_c = -A^{a c}*A^{b d} A = S2('A', 1) t = A(b, d)*A(c, a) tc = t.canon_bp() assert str(tc) == '-A(a, c)*A(b, d)' # A^{c,a}*A^{b,d} # T_c = A^{a c}*A^{b d} t = A(c, a)*A(b, d) tc = t.canon_bp() assert str(tc) == 'A(a, c)*A(b, d)' def test_tensorhead_construction_without_symmetry(): L = Lorentz = TensorIndexType('Lorentz') A1 = tensorhead('A', [L, L]) A2 = tensorhead('A', [L, L], [[1], [1]]) assert A1 == A2 A3 = tensorhead('A', [L, L], [[1, 1]]) # Symmetric assert A1 != A3 def test_no_metric_symmetry(): # no metric symmetry; A no symmetry # A^d1_d0 * A^d0_d1 # T_c = A^d0_d1 * A^d1_d0 Lorentz = TensorIndexType('Lorentz', metric=None, dummy_fmt='L') d0, d1, d2, d3 = tensor_indices('d:4', Lorentz) A = tensorhead('A', [Lorentz]*2, [[1], [1]]) t = A(d1, -d0)*A(d0, -d1) tc = t.canon_bp() assert str(tc) == 'A(L_0, -L_1)*A(L_1, -L_0)' # A^d1_d2 * A^d0_d3 * A^d2_d1 * A^d3_d0 # T_c = A^d0_d1 * A^d1_d0 * A^d2_d3 * A^d3_d2 t = A(d1, -d2)*A(d0, -d3)*A(d2,-d1)*A(d3,-d0) tc = t.canon_bp() assert str(tc) == 'A(L_0, -L_1)*A(L_1, -L_0)*A(L_2, -L_3)*A(L_3, -L_2)' # A^d0_d2 * A^d1_d3 * A^d3_d0 * A^d2_d1 # T_c = A^d0_d1 * A^d1_d2 * A^d2_d3 * A^d3_d0 t = A(d0, -d1)*A(d1, -d2)*A(d2, -d3)*A(d3,-d0) tc = t.canon_bp() assert str(tc) == 'A(L_0, -L_1)*A(L_1, -L_2)*A(L_2, -L_3)*A(L_3, -L_0)' def test_canonicalize1(): Lorentz = TensorIndexType('Lorentz', dummy_fmt='L') a, a0, a1, a2, a3, b, d0, d1, d2, d3 = \ tensor_indices('a,a0,a1,a2,a3,b,d0,d1,d2,d3', Lorentz) sym1 = tensorsymmetry([1]) base3, gens3 = get_symmetric_group_sgs(3) sym2 = tensorsymmetry([1]*2) sym2a = tensorsymmetry([2]) sym3 = tensorsymmetry([1]*3) sym3a = tensorsymmetry([3]) # A_d0*A^d0; ord = [d0,-d0] # T_c = A^d0*A_d0 S1 = TensorType([Lorentz], sym1) A = S1('A') t = A(-d0)*A(d0) tc = t.canon_bp() assert str(tc) == 'A(L_0)*A(-L_0)' # A commuting # A_d0*A_d1*A_d2*A^d2*A^d1*A^d0 # T_c = A^d0*A_d0*A^d1*A_d1*A^d2*A_d2 t = A(-d0)*A(-d1)*A(-d2)*A(d2)*A(d1)*A(d0) tc = t.canon_bp() assert str(tc) == 'A(L_0)*A(-L_0)*A(L_1)*A(-L_1)*A(L_2)*A(-L_2)' # A anticommuting # A_d0*A_d1*A_d2*A^d2*A^d1*A^d0 # T_c 0 A = S1('A', 1) t = A(-d0)*A(-d1)*A(-d2)*A(d2)*A(d1)*A(d0) tc = t.canon_bp() assert tc == 0 # A commuting symmetric # A^{d0 b}*A^a_d1*A^d1_d0 # T_c = A^{a d0}*A^{b d1}*A_{d0 d1} S2 = TensorType([Lorentz]*2, sym2) A = S2('A') t = A(d0, b)*A(a, -d1)*A(d1, -d0) tc = t.canon_bp() assert str(tc) == 'A(a, L_0)*A(b, L_1)*A(-L_0, -L_1)' # A, B commuting symmetric # A^{d0 b}*A^d1_d0*B^a_d1 # T_c = A^{b d0}*A_d0^d1*B^a_d1 B = S2('B') t = A(d0, b)*A(d1, -d0)*B(a, -d1) tc = t.canon_bp() assert str(tc) == 'A(b, L_0)*A(-L_0, L_1)*B(a, -L_1)' # A commuting symmetric # A^{d1 d0 b}*A^{a}_{d1 d0}; ord=[a,b, d0,-d0,d1,-d1] # T_c = A^{a d0 d1}*A^{b}_{d0 d1} S3 = TensorType([Lorentz]*3, sym3) A = S3('A') t = A(d1, d0, b)*A(a, -d1, -d0) tc = t.canon_bp() assert str(tc) == 'A(a, L_0, L_1)*A(b, -L_0, -L_1)' # A^{d3 d0 d2}*A^a0_{d1 d2}*A^d1_d3^a1*A^{a2 a3}_d0 # T_c = A^{a0 d0 d1}*A^a1_d0^d2*A^{a2 a3 d3}*A_{d1 d2 d3} t = A(d3, d0, d2)*A(a0, -d1, -d2)*A(d1, -d3, a1)*A(a2, a3, -d0) tc = t.canon_bp() assert str(tc) == 'A(a0, L_0, L_1)*A(a1, -L_0, L_2)*A(a2, a3, L_3)*A(-L_1, -L_2, -L_3)' # A commuting symmetric, B antisymmetric # A^{d0 d1 d2} * A_{d2 d3 d1} * B_d0^d3 # in this esxample and in the next three, # renaming dummy indices and using symmetry of A, # T = A^{d0 d1 d2} * A_{d0 d1 d3} * B_d2^d3 # can = 0 S2a = TensorType([Lorentz]*2, sym2a) A = S3('A') B = S2a('B') t = A(d0, d1, d2)*A(-d2, -d3, -d1)*B(-d0, d3) tc = t.canon_bp() assert tc == 0 # A anticommuting symmetric, B anticommuting # A^{d0 d1 d2} * A_{d2 d3 d1} * B_d0^d3 # T_c = A^{d0 d1 d2} * A_{d0 d1}^d3 * B_{d2 d3} A = S3('A', 1) B = S2a('B') t = A(d0, d1, d2)*A(-d2, -d3, -d1)*B(-d0, d3) tc = t.canon_bp() assert str(tc) == 'A(L_0, L_1, L_2)*A(-L_0, -L_1, L_3)*B(-L_2, -L_3)' # A anticommuting symmetric, B antisymmetric commuting, antisymmetric metric # A^{d0 d1 d2} * A_{d2 d3 d1} * B_d0^d3 # T_c = -A^{d0 d1 d2} * A_{d0 d1}^d3 * B_{d2 d3} Spinor = TensorIndexType('Spinor', metric=1, dummy_fmt='S') a, a0, a1, a2, a3, b, d0, d1, d2, d3 = \ tensor_indices('a,a0,a1,a2,a3,b,d0,d1,d2,d3', Spinor) S3 = TensorType([Spinor]*3, sym3) S2a = TensorType([Spinor]*2, sym2a) A = S3('A', 1) B = S2a('B') t = A(d0, d1, d2)*A(-d2, -d3, -d1)*B(-d0, d3) tc = t.canon_bp() assert str(tc) == '-A(S_0, S_1, S_2)*A(-S_0, -S_1, S_3)*B(-S_2, -S_3)' # A anticommuting symmetric, B antisymmetric anticommuting, # no metric symmetry # A^{d0 d1 d2} * A_{d2 d3 d1} * B_d0^d3 # T_c = A^{d0 d1 d2} * A_{d0 d1 d3} * B_d2^d3 Mat = TensorIndexType('Mat', metric=None, dummy_fmt='M') a, a0, a1, a2, a3, b, d0, d1, d2, d3 = \ tensor_indices('a,a0,a1,a2,a3,b,d0,d1,d2,d3', Mat) S3 = TensorType([Mat]*3, sym3) S2a = TensorType([Mat]*2, sym2a) A = S3('A', 1) B = S2a('B') t = A(d0, d1, d2)*A(-d2, -d3, -d1)*B(-d0, d3) tc = t.canon_bp() assert str(tc) == 'A(M_0, M_1, M_2)*A(-M_0, -M_1, -M_3)*B(-M_2, M_3)' # Gamma anticommuting # Gamma_{mu nu} * gamma^rho * Gamma^{nu mu alpha} # T_c = -Gamma^{mu nu} * gamma^rho * Gamma_{alpha mu nu} S1 = TensorType([Lorentz], sym1) S2a = TensorType([Lorentz]*2, sym2a) S3a = TensorType([Lorentz]*3, sym3a) alpha, beta, gamma, mu, nu, rho = \ tensor_indices('alpha,beta,gamma,mu,nu,rho', Lorentz) Gamma = S1('Gamma', 2) Gamma2 = S2a('Gamma', 2) Gamma3 = S3a('Gamma', 2) t = Gamma2(-mu,-nu)*Gamma(rho)*Gamma3(nu, mu, alpha) tc = t.canon_bp() assert str(tc) == '-Gamma(L_0, L_1)*Gamma(rho)*Gamma(alpha, -L_0, -L_1)' # Gamma_{mu nu} * Gamma^{gamma beta} * gamma_rho * Gamma^{nu mu alpha} # T_c = Gamma^{mu nu} * Gamma^{beta gamma} * gamma_rho * Gamma^alpha_{mu nu} t = Gamma2(mu, nu)*Gamma2(beta, gamma)*Gamma(-rho)*Gamma3(alpha, -mu, -nu) tc = t.canon_bp() assert str(tc) == 'Gamma(L_0, L_1)*Gamma(beta, gamma)*Gamma(-rho)*Gamma(alpha, -L_0, -L_1)' # f^a_{b,c} antisymmetric in b,c; A_mu^a no symmetry # f^c_{d a} * f_{c e b} * A_mu^d * A_nu^a * A^{nu e} * A^{mu b} # g = [8,11,5, 9,13,7, 1,10, 3,4, 2,12, 0,6, 14,15] # T_c = -f^{a b c} * f_a^{d e} * A^mu_b * A_{mu d} * A^nu_c * A_{nu e} Flavor = TensorIndexType('Flavor', dummy_fmt='F') a, b, c, d, e, ff = tensor_indices('a,b,c,d,e,f', Flavor) mu, nu = tensor_indices('mu,nu', Lorentz) sym_f = tensorsymmetry([1], [2]) S_f = TensorType([Flavor]*3, sym_f) sym_A = tensorsymmetry([1], [1]) S_A = TensorType([Lorentz, Flavor], sym_A) f = S_f('f') A = S_A('A') t = f(c, -d, -a)*f(-c, -e, -b)*A(-mu, d)*A(-nu, a)*A(nu, e)*A(mu, b) tc = t.canon_bp() assert str(tc) == '-f(F_0, F_1, F_2)*f(-F_0, F_3, F_4)*A(L_0, -F_1)*A(-L_0, -F_3)*A(L_1, -F_2)*A(-L_1, -F_4)' def test_bug_correction_tensor_indices(): # to make sure that tensor_indices does not return a list if creating # only one index: from sympy.tensor.tensor import tensor_indices, TensorIndexType, TensorIndex A = TensorIndexType("A") i = tensor_indices('i', A) assert not isinstance(i, (tuple, list)) assert isinstance(i, TensorIndex) def test_riemann_invariants(): Lorentz = TensorIndexType('Lorentz', dummy_fmt='L') d0, d1, d2, d3, d4, d5, d6, d7, d8, d9, d10, d11 = \ tensor_indices('d0:12', Lorentz) # R^{d0 d1}_{d1 d0}; ord = [d0,-d0,d1,-d1] # T_c = -R^{d0 d1}_{d0 d1} R = tensorhead('R', [Lorentz]*4, [[2, 2]]) t = R(d0, d1, -d1, -d0) tc = t.canon_bp() assert str(tc) == '-R(L_0, L_1, -L_0, -L_1)' # R_d11^d1_d0^d5 * R^{d6 d4 d0}_d5 * R_{d7 d2 d8 d9} * # R_{d10 d3 d6 d4} * R^{d2 d7 d11}_d1 * R^{d8 d9 d3 d10} # can = [0,2,4,6, 1,3,8,10, 5,7,12,14, 9,11,16,18, 13,15,20,22, # 17,19,21<F10,23, 24,25] # T_c = R^{d0 d1 d2 d3} * R_{d0 d1}^{d4 d5} * R_{d2 d3}^{d6 d7} * # R_{d4 d5}^{d8 d9} * R_{d6 d7}^{d10 d11} * R_{d8 d9 d10 d11} t = R(-d11,d1,-d0,d5)*R(d6,d4,d0,-d5)*R(-d7,-d2,-d8,-d9)* \ R(-d10,-d3,-d6,-d4)*R(d2,d7,d11,-d1)*R(d8,d9,d3,d10) tc = t.canon_bp() assert str(tc) == 'R(L_0, L_1, L_2, L_3)*R(-L_0, -L_1, L_4, L_5)*R(-L_2, -L_3, L_6, L_7)*R(-L_4, -L_5, L_8, L_9)*R(-L_6, -L_7, L_10, L_11)*R(-L_8, -L_9, -L_10, -L_11)' def test_riemann_products(): Lorentz = TensorIndexType('Lorentz', dummy_fmt='L') d0, d1, d2, d3, d4, d5, d6 = tensor_indices('d0:7', Lorentz) a0, a1, a2, a3, a4, a5 = tensor_indices('a0:6', Lorentz) a, b = tensor_indices('a,b', Lorentz) R = tensorhead('R', [Lorentz]*4, [[2, 2]]) # R^{a b d0}_d0 = 0 t = R(a, b, d0, -d0) tc = t.canon_bp() assert tc == 0 # R^{d0 b a}_d0 # T_c = -R^{a d0 b}_d0 t = R(d0, b, a, -d0) tc = t.canon_bp() assert str(tc) == '-R(a, L_0, b, -L_0)' # R^d1_d2^b_d0 * R^{d0 a}_d1^d2; ord=[a,b,d0,-d0,d1,-d1,d2,-d2] # T_c = -R^{a d0 d1 d2}* R^b_{d0 d1 d2} t = R(d1, -d2, b, -d0)*R(d0, a, -d1, d2) tc = t.canon_bp() assert str(tc) == '-R(a, L_0, L_1, L_2)*R(b, -L_0, -L_1, -L_2)' # A symmetric commuting # R^{d6 d5}_d2^d1 * R^{d4 d0 d2 d3} * A_{d6 d0} A_{d3 d1} * A_{d4 d5} # g = [12,10,5,2, 8,0,4,6, 13,1, 7,3, 9,11,14,15] # T_c = -R^{d0 d1 d2 d3} * R_d0^{d4 d5 d6} * A_{d1 d4}*A_{d2 d5}*A_{d3 d6} V = tensorhead('V', [Lorentz]*2, [[1]*2]) t = R(d6, d5, -d2, d1)*R(d4, d0, d2, d3)*V(-d6, -d0)*V(-d3, -d1)*V(-d4, -d5) tc = t.canon_bp() assert str(tc) == '-R(L_0, L_1, L_2, L_3)*R(-L_0, L_4, L_5, L_6)*V(-L_1, -L_4)*V(-L_2, -L_5)*V(-L_3, -L_6)' # R^{d2 a0 a2 d0} * R^d1_d2^{a1 a3} * R^{a4 a5}_{d0 d1} # T_c = R^{a0 d0 a2 d1}*R^{a1 a3}_d0^d2*R^{a4 a5}_{d1 d2} t = R(d2, a0, a2, d0)*R(d1, -d2, a1, a3)*R(a4, a5, -d0, -d1) tc = t.canon_bp() assert str(tc) == 'R(a0, L_0, a2, L_1)*R(a1, a3, -L_0, L_2)*R(a4, a5, -L_1, -L_2)' ###################################################################### def test_canonicalize2(): D = Symbol('D') Eucl = TensorIndexType('Eucl', metric=0, dim=D, dummy_fmt='E') i0,i1,i2,i3,i4,i5,i6,i7,i8,i9,i10,i11,i12,i13,i14 = \ tensor_indices('i0:15', Eucl) A = tensorhead('A', [Eucl]*3, [[3]]) # two examples from Cvitanovic, Group Theory page 59 # of identities for antisymmetric tensors of rank 3 # contracted according to the Kuratowski graph eq.(6.59) t = A(i0,i1,i2)*A(-i1,i3,i4)*A(-i3,i7,i5)*A(-i2,-i5,i6)*A(-i4,-i6,i8) t1 = t.canon_bp() assert t1 == 0 # eq.(6.60) #t = A(i0,i1,i2)*A(-i1,i3,i4)*A(-i2,i5,i6)*A(-i3,i7,i8)*A(-i6,-i7,i9)* # A(-i8,i10,i13)*A(-i5,-i10,i11)*A(-i4,-i11,i12)*A(-i3,-i12,i14) t = A(i0,i1,i2)*A(-i1,i3,i4)*A(-i2,i5,i6)*A(-i3,i7,i8)*A(-i6,-i7,i9)*\ A(-i8,i10,i13)*A(-i5,-i10,i11)*A(-i4,-i11,i12)*A(-i9,-i12,i14) t1 = t.canon_bp() assert t1 == 0 def test_canonicalize3(): D = Symbol('D') Spinor = TensorIndexType('Spinor', dim=D, metric=True, dummy_fmt='S') a0,a1,a2,a3,a4 = tensor_indices('a0:5', Spinor) C = Spinor.metric chi, psi = tensorhead('chi,psi', [Spinor], [[1]], 1) t = chi(a1)*psi(a0) t1 = t.canon_bp() assert t1 == t t = psi(a1)*chi(a0) t1 = t.canon_bp() assert t1 == -chi(a0)*psi(a1) class Metric(Basic): def __new__(cls, name, antisym, **kwargs): obj = Basic.__new__(cls, name, antisym, **kwargs) obj.name = name obj.antisym = antisym return obj def test_TensorIndexType(): D = Symbol('D') G = Metric('g', False) Lorentz = TensorIndexType('Lorentz', metric=G, dim=D, dummy_fmt='L') m0, m1, m2, m3, m4 = tensor_indices('m0:5', Lorentz) sym2 = tensorsymmetry([1]*2) sym2n = tensorsymmetry(*get_symmetric_group_sgs(2)) assert sym2 == sym2n g = Lorentz.metric assert str(g) == 'g(Lorentz,Lorentz)' assert Lorentz.eps_dim == Lorentz.dim TSpace = TensorIndexType('TSpace') i0, i1 = tensor_indices('i0 i1', TSpace) g = TSpace.metric A = tensorhead('A', [TSpace]*2, [[1]*2]) assert str(A(i0,-i0).canon_bp()) == 'A(TSpace_0, -TSpace_0)' def test_indices(): Lorentz = TensorIndexType('Lorentz', dummy_fmt='L') a, b, c, d = tensor_indices('a,b,c,d', Lorentz) assert a.tensor_index_type == Lorentz assert a != -a A, B = tensorhead('A B', [Lorentz]*2, [[1]*2]) t = A(a,b)*B(-b,c) indices = t.get_indices() L_0 = TensorIndex('L_0', Lorentz) assert indices == [a, L_0, -L_0, c] raises(ValueError, lambda: tensor_indices(3, Lorentz)) raises(ValueError, lambda: A(a,b,c)) def test_tensorsymmetry(): Lorentz = TensorIndexType('Lorentz', dummy_fmt='L') sym = tensorsymmetry([1]*2) sym1 = TensorSymmetry(get_symmetric_group_sgs(2)) assert sym == sym1 sym = tensorsymmetry([2]) sym1 = TensorSymmetry(get_symmetric_group_sgs(2, 1)) assert sym == sym1 sym2 = tensorsymmetry() assert sym2.base == Tuple() and sym2.generators == Tuple(Permutation(1)) raises(NotImplementedError, lambda: tensorsymmetry([2, 1])) def test_TensorType(): Lorentz = TensorIndexType('Lorentz', dummy_fmt='L') sym = tensorsymmetry([1]*2) A = tensorhead('A', [Lorentz]*2, [[1]*2]) assert A.typ == TensorType([Lorentz]*2, sym) assert A.types == [Lorentz] assert A.index_types == Tuple(*[Lorentz, Lorentz]) typ = TensorType([Lorentz]*2, sym) assert str(typ) == "TensorType(['Lorentz', 'Lorentz'])" raises(ValueError, lambda: typ(2)) def test_TensExpr(): Lorentz = TensorIndexType('Lorentz', dummy_fmt='L') a, b, c, d = tensor_indices('a,b,c,d', Lorentz) g = Lorentz.metric A, B = tensorhead('A B', [Lorentz]*2, [[1]*2]) raises(ValueError, lambda: g(c, d)/g(a, b)) raises(ValueError, lambda: S.One/g(a, b)) raises(ValueError, lambda: (A(c, d) + g(c, d))/g(a, b)) raises(ValueError, lambda: S.One/(A(c, d) + g(c, d))) raises(ValueError, lambda: A(a, b) + A(a, c)) t = A(a, b) + B(a, b) #raises(NotImplementedError, lambda: TensExpr.__mul__(t, 'a')) #raises(NotImplementedError, lambda: TensExpr.__add__(t, 'a')) #raises(NotImplementedError, lambda: TensExpr.__radd__(t, 'a')) #raises(NotImplementedError, lambda: TensExpr.__sub__(t, 'a')) #raises(NotImplementedError, lambda: TensExpr.__rsub__(t, 'a')) #raises(NotImplementedError, lambda: TensExpr.__div__(t, 'a')) #raises(NotImplementedError, lambda: TensExpr.__rdiv__(t, 'a')) with ignore_warnings(SymPyDeprecationWarning): # DO NOT REMOVE THIS AFTER DEPRECATION REMOVED: raises(ValueError, lambda: A(a, b)**2) raises(NotImplementedError, lambda: 2**A(a, b)) raises(NotImplementedError, lambda: abs(A(a, b))) def test_TensorHead(): # simple example of algebraic expression Lorentz = TensorIndexType('Lorentz', dummy_fmt='L') a,b = tensor_indices('a,b', Lorentz) # A, B symmetric A = tensorhead('A', [Lorentz]*2, [[1]*2]) assert A.rank == 2 assert A.symmetry == tensorsymmetry([1]*2) def test_add1(): assert TensAdd().args == () assert TensAdd().doit() == 0 # simple example of algebraic expression Lorentz = TensorIndexType('Lorentz', dummy_fmt='L') a,b,d0,d1,i,j,k = tensor_indices('a,b,d0,d1,i,j,k', Lorentz) # A, B symmetric A, B = tensorhead('A,B', [Lorentz]*2, [[1]*2]) t1 = A(b,-d0)*B(d0,a) assert TensAdd(t1).equals(t1) t2a = B(d0,a) + A(d0, a) t2 = A(b,-d0)*t2a assert str(t2) == 'A(b, -L_0)*(A(L_0, a) + B(L_0, a))' t2 = t2.expand() assert str(t2) == 'A(b, -L_0)*A(L_0, a) + A(b, -L_0)*B(L_0, a)' t2 = t2.canon_bp() assert str(t2) == 'A(a, L_0)*A(b, -L_0) + A(b, L_0)*B(a, -L_0)' t2b = t2 + t1 assert str(t2b) == 'A(a, L_0)*A(b, -L_0) + A(b, -L_0)*B(L_0, a) + A(b, L_0)*B(a, -L_0)' t2b = t2b.canon_bp() assert str(t2b) == '2*A(b, L_0)*B(a, -L_0) + A(a, L_0)*A(b, -L_0)' p, q, r = tensorhead('p,q,r', [Lorentz], [[1]]) t = q(d0)*2 assert str(t) == '2*q(d0)' t = 2*q(d0) assert str(t) == '2*q(d0)' t1 = p(d0) + 2*q(d0) assert str(t1) == '2*q(d0) + p(d0)' t2 = p(-d0) + 2*q(-d0) assert str(t2) == '2*q(-d0) + p(-d0)' t1 = p(d0) t3 = t1*t2 assert str(t3) == 'p(L_0)*(2*q(-L_0) + p(-L_0))' t3 = t3.expand() assert str(t3) == '2*p(L_0)*q(-L_0) + p(L_0)*p(-L_0)' t3 = t2*t1 t3 = t3.expand() assert str(t3) == '2*q(-L_0)*p(L_0) + p(-L_0)*p(L_0)' t3 = t3.canon_bp() assert str(t3) == '2*p(L_0)*q(-L_0) + p(L_0)*p(-L_0)' t1 = p(d0) + 2*q(d0) t3 = t1*t2 t3 = t3.canon_bp() assert str(t3) == '4*p(L_0)*q(-L_0) + 4*q(L_0)*q(-L_0) + p(L_0)*p(-L_0)' t1 = p(d0) - 2*q(d0) assert str(t1) == '-2*q(d0) + p(d0)' t2 = p(-d0) + 2*q(-d0) t3 = t1*t2 t3 = t3.canon_bp() assert t3 == p(d0)*p(-d0) - 4*q(d0)*q(-d0) t = p(i)*p(j)*(p(k) + q(k)) + p(i)*(p(j) + q(j))*(p(k) - 3*q(k)) t = t.canon_bp() assert t == 2*p(i)*p(j)*p(k) - 2*p(i)*p(j)*q(k) + p(i)*p(k)*q(j) - 3*p(i)*q(j)*q(k) t1 = (p(i) + q(i) + 2*r(i))*(p(j) - q(j)) t2 = (p(j) + q(j) + 2*r(j))*(p(i) - q(i)) t = t1 + t2 t = t.canon_bp() assert t == 2*p(i)*p(j) + 2*p(i)*r(j) + 2*p(j)*r(i) - 2*q(i)*q(j) - 2*q(i)*r(j) - 2*q(j)*r(i) t = p(i)*q(j)/2 assert 2*t == p(i)*q(j) t = (p(i) + q(i))/2 assert 2*t == p(i) + q(i) t = S.One - p(i)*p(-i) t = t.canon_bp() tz1 = t + p(-j)*p(j) assert tz1 != 1 tz1 = tz1.canon_bp() assert tz1.equals(1) t = S.One + p(i)*p(-i) assert (t - p(-j)*p(j)).canon_bp().equals(1) t = A(a, b) + B(a, b) assert t.rank == 2 t1 = t - A(a, b) - B(a, b) assert t1 == 0 t = 1 - (A(a, -a) + B(a, -a)) t1 = 1 + (A(a, -a) + B(a, -a)) assert (t + t1).expand().equals(2) t2 = 1 + A(a, -a) assert t1 != t2 assert t2 != TensMul.from_data(0, [], [], []) t = p(i) + q(i) raises(ValueError, lambda: t(i, j)) def test_special_eq_ne(): # test special equality cases: Lorentz = TensorIndexType('Lorentz', dummy_fmt='L') a,b,d0,d1,i,j,k = tensor_indices('a,b,d0,d1,i,j,k', Lorentz) # A, B symmetric A, B = tensorhead('A,B', [Lorentz]*2, [[1]*2]) p, q, r = tensorhead('p,q,r', [Lorentz], [[1]]) t = 0*A(a, b) assert _is_equal(t, 0) assert _is_equal(t, S.Zero) assert p(i) != A(a, b) assert A(a, -a) != A(a, b) assert 0*(A(a, b) + B(a, b)) == 0 assert 0*(A(a, b) + B(a, b)) == S.Zero assert 3*(A(a, b) - A(a, b)) == S.Zero assert p(i) + q(i) != A(a, b) assert p(i) + q(i) != A(a, b) + B(a, b) assert p(i) - p(i) == 0 assert p(i) - p(i) == S.Zero assert _is_equal(A(a, b), A(b, a)) def test_add2(): Lorentz = TensorIndexType('Lorentz', dummy_fmt='L') m, n, p, q = tensor_indices('m,n,p,q', Lorentz) R = tensorhead('R', [Lorentz]*4, [[2, 2]]) A = tensorhead('A', [Lorentz]*3, [[3]]) t1 = 2*R(m, n, p, q) - R(m, q, n, p) + R(m, p, n, q) t2 = t1*A(-n, -p, -q) t2 = t2.canon_bp() assert t2 == 0 t1 = S(2)/3*R(m,n,p,q) - S(1)/3*R(m,q,n,p) + S(1)/3*R(m,p,n,q) t2 = t1*A(-n, -p, -q) t2 = t2.canon_bp() assert t2 == 0 t = A(m, -m, n) + A(n, p, -p) t = t.canon_bp() assert t == 0 def test_add3(): Lorentz = TensorIndexType('Lorentz', dummy_fmt='L') i0, i1 = tensor_indices('i0:2', Lorentz) E, px, py, pz = symbols('E px py pz') A = tensorhead('A', [Lorentz], [[1]]) B = tensorhead('B', [Lorentz], [[1]]) expr1 = A(i0)*A(-i0) - (E**2 - px**2 - py**2 - pz**2) assert expr1.args == (px**2, py**2, pz**2, -E**2, A(i0)*A(-i0)) expr2 = E**2 - px**2 - py**2 - pz**2 - A(i0)*A(-i0) assert expr2.args == (E**2, -px**2, -py**2, -pz**2, -A(i0)*A(-i0)) expr3 = A(i0)*A(-i0) - E**2 + px**2 + py**2 + pz**2 assert expr3.args == (px**2, py**2, pz**2, -E**2, A(i0)*A(-i0)) expr4 = B(i1)*B(-i1) + 2*E**2 - 2*px**2 - 2*py**2 - 2*pz**2 - A(i0)*A(-i0) assert expr4.args == (-2*px**2, -2*py**2, -2*pz**2, 2*E**2, -A(i0)*A(-i0), B(i1)*B(-i1)) def test_mul(): from sympy.abc import x Lorentz = TensorIndexType('Lorentz', dummy_fmt='L') a, b, c, d = tensor_indices('a,b,c,d', Lorentz) sym = tensorsymmetry([1]*2) t = TensMul.from_data(S.One, [], [], []) assert str(t) == '1' A, B = tensorhead('A B', [Lorentz]*2, [[1]*2]) t = (1 + x)*A(a, b) assert str(t) == '(x + 1)*A(a, b)' assert t.index_types == [Lorentz, Lorentz] assert t.rank == 2 assert t.dum == [] assert t.coeff == 1 + x assert sorted(t.free) == [(a, 0), (b, 1)] assert t.components == [A] ts = A(a, b) assert str(ts) == 'A(a, b)' assert ts.index_types == [Lorentz, Lorentz] assert ts.rank == 2 assert ts.dum == [] assert ts.coeff == 1 assert sorted(ts.free) == [(a, 0), (b, 1)] assert ts.components == [A] t = A(-b, a)*B(-a, c)*A(-c, d) t1 = tensor_mul(*t.split()) assert t == t(-b, d) assert t == t1 assert tensor_mul(*[]) == TensMul.from_data(S.One, [], [], []) t = TensMul.from_data(1, [], [], []) zsym = tensorsymmetry() typ = TensorType([], zsym) C = typ('C') assert str(C()) == 'C' assert str(t) == '1' assert t == 1 raises(ValueError, lambda: A(a, b)*A(a, c)) t = A(a, b)*A(-a, c) raises(ValueError, lambda: t(a, b, c)) def test_substitute_indices(): Lorentz = TensorIndexType('Lorentz', dummy_fmt='L') i, j, k, l, m, n, p, q = tensor_indices('i,j,k,l,m,n,p,q', Lorentz) A, B = tensorhead('A,B', [Lorentz]*2, [[1]*2]) t = A(i, k)*B(-k, -j) t1 = t.substitute_indices((i, j), (j, k)) t1a = A(j, l)*B(-l, -k) assert t1 == t1a p = tensorhead('p', [Lorentz], [[1]]) t = p(i) t1 = t.substitute_indices((j, k)) assert t1 == t t1 = t.substitute_indices((i, j)) assert t1 == p(j) t1 = t.substitute_indices((i, -j)) assert t1 == p(-j) t1 = t.substitute_indices((-i, j)) assert t1 == p(-j) t1 = t.substitute_indices((-i, -j)) assert t1 == p(j) A_tmul = A(m, n) A_c = A_tmul(m, -m) assert _is_equal(A_c, A(n, -n)) ABm = A(i, j)*B(m, n) ABc1 = ABm(i, j, -i, -j) assert _is_equal(ABc1, A(i, -j)*B(-i, j)) ABc2 = ABm(i, -i, j, -j) assert _is_equal(ABc2, A(m, -m)*B(-n, n)) asum = A(i, j) + B(i, j) asc1 = asum(i, -i) assert _is_equal(asc1, A(i, -i) + B(i, -i)) assert A(i, -i) == A(i, -i)() assert canon_bp(A(i, -i) + B(-j, j) - (A(i, -i) + B(i, -i))()) == 0 assert _is_equal(A(i, j)*B(-j, k), (A(m, -j)*B(j, n))(i, k)) raises(ValueError, lambda: A(i, -i)(j, k)) def test_riemann_cyclic_replace(): Lorentz = TensorIndexType('Lorentz', dummy_fmt='L') m0, m1, m2, m3 = tensor_indices('m:4', Lorentz) symr = tensorsymmetry([2, 2]) R = tensorhead('R', [Lorentz]*4, [[2, 2]]) t = R(m0, m2, m1, m3) t1 = riemann_cyclic_replace(t) t1a = -S.One/3*R(m0, m3, m2, m1) + S.One/3*R(m0, m1, m2, m3) + Rational(2, 3)*R(m0, m2, m1, m3) assert t1 == t1a def test_riemann_cyclic(): Lorentz = TensorIndexType('Lorentz', dummy_fmt='L') i, j, k, l, m, n, p, q = tensor_indices('i,j,k,l,m,n,p,q', Lorentz) R = tensorhead('R', [Lorentz]*4, [[2, 2]]) t = R(i,j,k,l) + R(i,l,j,k) + R(i,k,l,j) - \ R(i,j,l,k) - R(i,l,k,j) - R(i,k,j,l) t2 = t*R(-i,-j,-k,-l) t3 = riemann_cyclic(t2) assert t3 == 0 t = R(i,j,k,l)*(R(-i,-j,-k,-l) - 2*R(-i,-k,-j,-l)) t1 = riemann_cyclic(t) assert t1 == 0 t = R(i,j,k,l) t1 = riemann_cyclic(t) assert t1 == -S(1)/3*R(i, l, j, k) + S(1)/3*R(i, k, j, l) + S(2)/3*R(i, j, k, l) t = R(i,j,k,l)*R(-k,-l,m,n)*(R(-m,-n,-i,-j) + 2*R(-m,-j,-n,-i)) t1 = riemann_cyclic(t) assert t1 == 0 @XFAIL def test_div(): Lorentz = TensorIndexType('Lorentz', dummy_fmt='L') m0,m1,m2,m3 = tensor_indices('m0:4', Lorentz) R = tensorhead('R', [Lorentz]*4, [[2, 2]]) t = R(m0,m1,-m1,m3) t1 = t/S(4) assert str(t1) == '(1/4)*R(m0, L_0, -L_0, m3)' t = t.canon_bp() assert not t1._is_canon_bp t1 = t*4 assert t1._is_canon_bp t1 = t1/4 assert t1._is_canon_bp def test_contract_metric1(): D = Symbol('D') Lorentz = TensorIndexType('Lorentz', dim=D, dummy_fmt='L') a, b, c, d, e = tensor_indices('a,b,c,d,e', Lorentz) g = Lorentz.metric p = tensorhead('p', [Lorentz], [[1]]) t = g(a, b)*p(-b) t1 = t.contract_metric(g) assert t1 == p(a) A, B = tensorhead('A,B', [Lorentz]*2, [[1]*2]) # case with g with all free indices t1 = A(a,b)*B(-b,c)*g(d, e) t2 = t1.contract_metric(g) assert t1 == t2 # case of g(d, -d) t1 = A(a,b)*B(-b,c)*g(-d, d) t2 = t1.contract_metric(g) assert t2 == D*A(a, d)*B(-d, c) # g with one free index t1 = A(a,b)*B(-b,-c)*g(c, d) t2 = t1.contract_metric(g) assert t2 == A(a, c)*B(-c, d) # g with both indices contracted with another tensor t1 = A(a,b)*B(-b,-c)*g(c, -a) t2 = t1.contract_metric(g) assert _is_equal(t2, A(a, b)*B(-b, -a)) t1 = A(a,b)*B(-b,-c)*g(c, d)*g(-a, -d) t2 = t1.contract_metric(g) assert _is_equal(t2, A(a,b)*B(-b,-a)) t1 = A(a,b)*g(-a,-b) t2 = t1.contract_metric(g) assert _is_equal(t2, A(a, -a)) assert not t2.free Lorentz = TensorIndexType('Lorentz', dummy_fmt='L') a, b = tensor_indices('a,b', Lorentz) g = Lorentz.metric raises(ValueError, lambda: g(a, -a).contract_metric(g)) # no dim def test_contract_metric2(): D = Symbol('D') Lorentz = TensorIndexType('Lorentz', dim=D, dummy_fmt='L') a, b, c, d, e, L_0 = tensor_indices('a,b,c,d,e,L_0', Lorentz) g = Lorentz.metric p, q = tensorhead('p,q', [Lorentz], [[1]]) t1 = g(a,b)*p(c)*p(-c) t2 = 3*g(-a,-b)*q(c)*q(-c) t = t1*t2 t = t.contract_metric(g) assert t == 3*D*p(a)*p(-a)*q(b)*q(-b) t1 = g(a,b)*p(c)*p(-c) t2 = 3*q(-a)*q(-b) t = t1*t2 t = t.contract_metric(g) t = t.canon_bp() assert t == 3*p(a)*p(-a)*q(b)*q(-b) t1 = 2*g(a,b)*p(c)*p(-c) t2 = - 3*g(-a,-b)*q(c)*q(-c) t = t1*t2 t = t.contract_metric(g) t = 6*g(a,b)*g(-a,-b)*p(c)*p(-c)*q(d)*q(-d) t = t.contract_metric(g) t1 = 2*g(a,b)*p(c)*p(-c) t2 = q(-a)*q(-b) + 3*g(-a,-b)*q(c)*q(-c) t = t1*t2 t = t.contract_metric(g) assert t == (2 + 6*D)*p(a)*p(-a)*q(b)*q(-b) t1 = p(a)*p(b) + p(a)*q(b) + 2*g(a,b)*p(c)*p(-c) t2 = q(-a)*q(-b) - g(-a,-b)*q(c)*q(-c) t = t1*t2 t = t.contract_metric(g) t1 = (1 - 2*D)*p(a)*p(-a)*q(b)*q(-b) + p(a)*q(-a)*p(b)*q(-b) assert canon_bp(t - t1) == 0 t = g(a,b)*g(c,d)*g(-b,-c) t1 = t.contract_metric(g) assert t1 == g(a, d) t1 = g(a,b)*g(c,d) + g(a,c)*g(b,d) + g(a,d)*g(b,c) t2 = t1.substitute_indices((a,-a),(b,-b),(c,-c),(d,-d)) t = t1*t2 t = t.contract_metric(g) assert t.equals(3*D**2 + 6*D) t = 2*p(a)*g(b,-b) t1 = t.contract_metric(g) assert t1.equals(2*D*p(a)) t = 2*p(a)*g(b,-a) t1 = t.contract_metric(g) assert t1 == 2*p(b) M = Symbol('M') t = (p(a)*p(b) + g(a, b)*M**2)*g(-a, -b) - D*M**2 t1 = t.contract_metric(g) assert t1 == p(a)*p(-a) A = tensorhead('A', [Lorentz]*2, [[1]*2]) t = A(a, b)*p(L_0)*g(-a, -b) t1 = t.contract_metric(g) assert str(t1) == 'A(L_1, -L_1)*p(L_0)' or str(t1) == 'A(-L_1, L_1)*p(L_0)' def test_metric_contract3(): D = Symbol('D') Spinor = TensorIndexType('Spinor', dim=D, metric=True, dummy_fmt='S') a0,a1,a2,a3,a4 = tensor_indices('a0:5', Spinor) C = Spinor.metric chi, psi = tensorhead('chi,psi', [Spinor], [[1]], 1) B = tensorhead('B', [Spinor]*2, [[1],[1]]) t = C(a0, -a0) t1 = t.contract_metric(C) assert t1.equals(-D) t = C(-a0, a0) t1 = t.contract_metric(C) assert t1.equals(D) t = C(a0,a1)*C(-a0,-a1) t1 = t.contract_metric(C) assert t1.equals(D) t = C(a1,a0)*C(-a0,-a1) t1 = t.contract_metric(C) assert t1.equals(-D) t = C(-a0,a1)*C(a0,-a1) t1 = t.contract_metric(C) assert t1.equals(-D) t = C(a1,-a0)*C(a0,-a1) t1 = t.contract_metric(C) assert t1.equals(D) t = C(a0,a1)*B(-a1,-a0) t1 = t.contract_metric(C) t1 = t1.canon_bp() assert _is_equal(t1, B(a0, -a0)) t = C(a1,a0)*B(-a1,-a0) t1 = t.contract_metric(C) assert _is_equal(t1, -B(a0, -a0)) t = C(a0,-a1)*B(a1,-a0) t1 = t.contract_metric(C) assert _is_equal(t1, -B(a0, -a0)) t = C(-a0,a1)*B(-a1,a0) t1 = t.contract_metric(C) assert _is_equal(t1, -B(a0, -a0)) t = C(-a0,-a1)*B(a1,a0) t1 = t.contract_metric(C) assert _is_equal(t1, B(a0, -a0)) t = C(-a1, a0)*B(a1,-a0) t1 = t.contract_metric(C) assert _is_equal(t1, B(a0, -a0)) t = C(a0,a1)*psi(-a1) t1 = t.contract_metric(C) assert _is_equal(t1, psi(a0)) t = C(a1,a0)*psi(-a1) t1 = t.contract_metric(C) assert _is_equal(t1, -psi(a0)) t = C(a0,a1)*chi(-a0)*psi(-a1) t1 = t.contract_metric(C) assert _is_equal(t1, -chi(a1)*psi(-a1)) t = C(a1,a0)*chi(-a0)*psi(-a1) t1 = t.contract_metric(C) assert _is_equal(t1, chi(a1)*psi(-a1)) t = C(-a1,a0)*chi(-a0)*psi(a1) t1 = t.contract_metric(C) assert _is_equal(t1, chi(-a1)*psi(a1)) t = C(a0, -a1)*chi(-a0)*psi(a1) t1 = t.contract_metric(C) assert _is_equal(t1, -chi(-a1)*psi(a1)) t = C(-a0,-a1)*chi(a0)*psi(a1) t1 = t.contract_metric(C) assert _is_equal(t1, chi(-a1)*psi(a1)) t = C(-a1,-a0)*chi(a0)*psi(a1) t1 = t.contract_metric(C) assert _is_equal(t1, -chi(-a1)*psi(a1)) t = C(-a1,-a0)*B(a0,a2)*psi(a1) t1 = t.contract_metric(C) assert _is_equal(t1, -B(-a1,a2)*psi(a1)) t = C(a1,a0)*B(-a2,-a0)*psi(-a1) t1 = t.contract_metric(C) assert _is_equal(t1, B(-a2,a1)*psi(-a1)) def test_epsilon(): Lorentz = TensorIndexType('Lorentz', dim=4, dummy_fmt='L') a, b, c, d, e = tensor_indices('a,b,c,d,e', Lorentz) g = Lorentz.metric epsilon = Lorentz.epsilon p, q, r, s = tensorhead('p,q,r,s', [Lorentz], [[1]]) t = epsilon(b,a,c,d) t1 = t.canon_bp() assert t1 == -epsilon(a,b,c,d) t = epsilon(c,b,d,a) t1 = t.canon_bp() assert t1 == epsilon(a,b,c,d) t = epsilon(c,a,d,b) t1 = t.canon_bp() assert t1 == -epsilon(a,b,c,d) t = epsilon(a,b,c,d)*p(-a)*q(-b) t1 = t.canon_bp() assert t1 == epsilon(c, d, a, b)*p(-a)*q(-b) t = epsilon(c,b,d,a)*p(-a)*q(-b) t1 = t.canon_bp() assert t1 == epsilon(c, d, a, b)*p(-a)*q(-b) t = epsilon(c,a,d,b)*p(-a)*q(-b) t1 = t.canon_bp() assert t1 == -epsilon(c, d, a, b)*p(-a)*q(-b) t = epsilon(c,a,d,b)*p(-a)*p(-b) t1 = t.canon_bp() assert t1 == 0 t = epsilon(c,a,d,b)*p(-a)*q(-b) + epsilon(a,b,c,d)*p(-b)*q(-a) t1 = t.canon_bp() assert t1 == -2*epsilon(c, d, a, b)*p(-a)*q(-b) # Test that epsilon can be create with a SymPy integer: Lorentz = TensorIndexType('Lorentz', dim=Integer(4), dummy_fmt='L') epsilon = Lorentz.epsilon assert isinstance(epsilon, TensorHead) def test_contract_delta1(): # see Group Theory by Cvitanovic page 9 n = Symbol('n') Color = TensorIndexType('Color', metric=None, dim=n, dummy_fmt='C') a, b, c, d, e, f = tensor_indices('a,b,c,d,e,f', Color) delta = Color.delta def idn(a, b, d, c): assert a.is_up and d.is_up assert not (b.is_up or c.is_up) return delta(a, c)*delta(d, b) def T(a, b, d, c): assert a.is_up and d.is_up assert not (b.is_up or c.is_up) return delta(a, b)*delta(d, c) def P1(a, b, c, d): return idn(a,b,c,d) - 1/n*T(a,b,c,d) def P2(a, b, c, d): return 1/n*T(a,b,c,d) t = P1(a, -b, e, -f)*P1(f, -e, d, -c) t1 = t.contract_delta(delta) assert canon_bp(t1 - P1(a, -b, d, -c)) == 0 t = P2(a, -b, e, -f)*P2(f, -e, d, -c) t1 = t.contract_delta(delta) assert t1 == P2(a, -b, d, -c) t = P1(a, -b, e, -f)*P2(f, -e, d, -c) t1 = t.contract_delta(delta) assert t1 == 0 t = P1(a, -b, b, -a) t1 = t.contract_delta(delta) assert t1.equals(n**2 - 1) def test_fun(): D = Symbol('D') Lorentz = TensorIndexType('Lorentz', dim=D, dummy_fmt='L') a,b,c,d,e = tensor_indices('a,b,c,d,e', Lorentz) g = Lorentz.metric p, q = tensorhead('p q', [Lorentz], [[1]]) t = q(c)*p(a)*q(b) + g(a,b)*g(c,d)*q(-d) assert t(a,b,c) == t assert canon_bp(t - t(b,a,c) - q(c)*p(a)*q(b) + q(c)*p(b)*q(a)) == 0 assert t(b,c,d) == q(d)*p(b)*q(c) + g(b,c)*g(d,e)*q(-e) t1 = t.fun_eval((a,b),(b,a)) assert canon_bp(t1 - q(c)*p(b)*q(a) - g(a,b)*g(c,d)*q(-d)) == 0 # check that g_{a b; c} = 0 # example taken from L. Brewin # "A brief introduction to Cadabra" arxiv:0903.2085 # dg_{a b c} = \partial_{a} g_{b c} is symmetric in b, c dg = tensorhead('dg', [Lorentz]*3, [[1], [1]*2]) # gamma^a_{b c} is the Christoffel symbol gamma = S.Half*g(a,d)*(dg(-b,-d,-c) + dg(-c,-b,-d) - dg(-d,-b,-c)) # t = g_{a b; c} t = dg(-c,-a,-b) - g(-a,-d)*gamma(d,-b,-c) - g(-b,-d)*gamma(d,-a,-c) t = t.contract_metric(g) assert t == 0 t = q(c)*p(a)*q(b) assert t(b,c,d) == q(d)*p(b)*q(c) def test_TensorManager(): Lorentz = TensorIndexType('Lorentz', dummy_fmt='L') LorentzH = TensorIndexType('LorentzH', dummy_fmt='LH') i, j = tensor_indices('i,j', Lorentz) ih, jh = tensor_indices('ih,jh', LorentzH) p, q = tensorhead('p q', [Lorentz], [[1]]) ph, qh = tensorhead('ph qh', [LorentzH], [[1]]) Gsymbol = Symbol('Gsymbol') GHsymbol = Symbol('GHsymbol') TensorManager.set_comm(Gsymbol, GHsymbol, 0) G = tensorhead('G', [Lorentz], [[1]], Gsymbol) assert TensorManager._comm_i2symbol[G.comm] == Gsymbol GH = tensorhead('GH', [LorentzH], [[1]], GHsymbol) ps = G(i)*p(-i) psh = GH(ih)*ph(-ih) t = ps + psh t1 = t*t assert canon_bp(t1 - ps*ps - 2*ps*psh - psh*psh) == 0 qs = G(i)*q(-i) qsh = GH(ih)*qh(-ih) assert _is_equal(ps*qsh, qsh*ps) assert not _is_equal(ps*qs, qs*ps) n = TensorManager.comm_symbols2i(Gsymbol) assert TensorManager.comm_i2symbol(n) == Gsymbol assert GHsymbol in TensorManager._comm_symbols2i raises(ValueError, lambda: TensorManager.set_comm(GHsymbol, 1, 2)) TensorManager.set_comms((Gsymbol,GHsymbol,0),(Gsymbol,1,1)) assert TensorManager.get_comm(n, 1) == TensorManager.get_comm(1, n) == 1 TensorManager.clear() assert TensorManager.comm == [{0:0, 1:0, 2:0}, {0:0, 1:1, 2:None}, {0:0, 1:None}] assert GHsymbol not in TensorManager._comm_symbols2i nh = TensorManager.comm_symbols2i(GHsymbol) assert GHsymbol in TensorManager._comm_symbols2i def test_hash(): D = Symbol('D') Lorentz = TensorIndexType('Lorentz', dim=D, dummy_fmt='L') a,b,c,d,e = tensor_indices('a,b,c,d,e', Lorentz) g = Lorentz.metric p, q = tensorhead('p q', [Lorentz], [[1]]) p_type = p.args[1] t1 = p(a)*q(b) t2 = p(a)*p(b) assert hash(t1) != hash(t2) t3 = p(a)*p(b) + g(a,b) t4 = p(a)*p(b) - g(a,b) assert hash(t3) != hash(t4) assert a.func(*a.args) == a assert Lorentz.func(*Lorentz.args) == Lorentz assert g.func(*g.args) == g assert p.func(*p.args) == p assert p_type.func(*p_type.args) == p_type assert p(a).func(*(p(a)).args) == p(a) assert t1.func(*t1.args) == t1 assert t2.func(*t2.args) == t2 assert t3.func(*t3.args) == t3 assert t4.func(*t4.args) == t4 assert hash(a.func(*a.args)) == hash(a) assert hash(Lorentz.func(*Lorentz.args)) == hash(Lorentz) assert hash(g.func(*g.args)) == hash(g) assert hash(p.func(*p.args)) == hash(p) assert hash(p_type.func(*p_type.args)) == hash(p_type) assert hash(p(a).func(*(p(a)).args)) == hash(p(a)) assert hash(t1.func(*t1.args)) == hash(t1) assert hash(t2.func(*t2.args)) == hash(t2) assert hash(t3.func(*t3.args)) == hash(t3) assert hash(t4.func(*t4.args)) == hash(t4) def check_all(obj): return all([isinstance(_, Basic) for _ in obj.args]) assert check_all(a) assert check_all(Lorentz) assert check_all(g) assert check_all(p) assert check_all(p_type) assert check_all(p(a)) assert check_all(t1) assert check_all(t2) assert check_all(t3) assert check_all(t4) tsymmetry = tensorsymmetry([2], [1], [1, 1, 1]) assert tsymmetry.func(*tsymmetry.args) == tsymmetry assert hash(tsymmetry.func(*tsymmetry.args)) == hash(tsymmetry) assert check_all(tsymmetry) ### TEST VALUED TENSORS ### def _get_valued_base_test_variables(): minkowski = Matrix(( (1, 0, 0, 0), (0, -1, 0, 0), (0, 0, -1, 0), (0, 0, 0, -1), )) Lorentz = TensorIndexType('Lorentz', dim=4) Lorentz.data = minkowski i0, i1, i2, i3, i4 = tensor_indices('i0:5', Lorentz) E, px, py, pz = symbols('E px py pz') A = tensorhead('A', [Lorentz], [[1]]) A.data = [E, px, py, pz] B = tensorhead('B', [Lorentz], [[1]], 'Gcomm') B.data = range(4) AB = tensorhead("AB", [Lorentz] * 2, [[1]]*2) AB.data = minkowski ba_matrix = Matrix(( (1, 2, 3, 4), (5, 6, 7, 8), (9, 0, -1, -2), (-3, -4, -5, -6), )) BA = tensorhead("BA", [Lorentz] * 2, [[1]]*2) BA.data = ba_matrix # Let's test the diagonal metric, with inverted Minkowski metric: LorentzD = TensorIndexType('LorentzD') LorentzD.data = [-1, 1, 1, 1] mu0, mu1, mu2 = tensor_indices('mu0:3', LorentzD) C = tensorhead('C', [LorentzD], [[1]]) C.data = [E, px, py, pz] ### non-diagonal metric ### ndm_matrix = ( (1, 1, 0,), (1, 0, 1), (0, 1, 0,), ) ndm = TensorIndexType("ndm") ndm.data = ndm_matrix n0, n1, n2 = tensor_indices('n0:3', ndm) NA = tensorhead('NA', [ndm], [[1]]) NA.data = range(10, 13) NB = tensorhead('NB', [ndm]*2, [[1]]*2) NB.data = [[i+j for j in range(10, 13)] for i in range(10, 13)] NC = tensorhead('NC', [ndm]*3, [[1]]*3) NC.data = [[[i+j+k for k in range(4, 7)] for j in range(1, 4)] for i in range(2, 5)] return (A, B, AB, BA, C, Lorentz, E, px, py, pz, LorentzD, mu0, mu1, mu2, ndm, n0, n1, n2, NA, NB, NC, minkowski, ba_matrix, ndm_matrix, i0, i1, i2, i3, i4) @filter_warnings_decorator def test_valued_tensor_iter(): (A, B, AB, BA, C, Lorentz, E, px, py, pz, LorentzD, mu0, mu1, mu2, ndm, n0, n1, n2, NA, NB, NC, minkowski, ba_matrix, ndm_matrix, i0, i1, i2, i3, i4) = _get_valued_base_test_variables() # iteration on VTensorHead assert list(A) == [E, px, py, pz] assert list(ba_matrix) == list(BA) # iteration on VTensMul assert list(A(i1)) == [E, px, py, pz] assert list(BA(i1, i2)) == list(ba_matrix) assert list(3 * BA(i1, i2)) == [3 * i for i in list(ba_matrix)] assert list(-5 * BA(i1, i2)) == [-5 * i for i in list(ba_matrix)] # iteration on VTensAdd # A(i1) + A(i1) assert list(A(i1) + A(i1)) == [2*E, 2*px, 2*py, 2*pz] assert BA(i1, i2) - BA(i1, i2) == 0 assert list(BA(i1, i2) - 2 * BA(i1, i2)) == [-i for i in list(ba_matrix)] @filter_warnings_decorator def test_valued_tensor_covariant_contravariant_elements(): (A, B, AB, BA, C, Lorentz, E, px, py, pz, LorentzD, mu0, mu1, mu2, ndm, n0, n1, n2, NA, NB, NC, minkowski, ba_matrix, ndm_matrix, i0, i1, i2, i3, i4) = _get_valued_base_test_variables() assert A(-i0)[0] == A(i0)[0] assert A(-i0)[1] == -A(i0)[1] assert AB(i0, i1)[1, 1] == -1 assert AB(i0, -i1)[1, 1] == 1 assert AB(-i0, -i1)[1, 1] == -1 assert AB(-i0, i1)[1, 1] == 1 @filter_warnings_decorator def test_valued_tensor_get_matrix(): (A, B, AB, BA, C, Lorentz, E, px, py, pz, LorentzD, mu0, mu1, mu2, ndm, n0, n1, n2, NA, NB, NC, minkowski, ba_matrix, ndm_matrix, i0, i1, i2, i3, i4) = _get_valued_base_test_variables() matab = AB(i0, i1).get_matrix() assert matab == Matrix([ [1, 0, 0, 0], [0, -1, 0, 0], [0, 0, -1, 0], [0, 0, 0, -1], ]) # when alternating contravariant/covariant with [1, -1, -1, -1] metric # it becomes the identity matrix: assert AB(i0, -i1).get_matrix() == eye(4) # covariant and contravariant forms: assert A(i0).get_matrix() == Matrix([E, px, py, pz]) assert A(-i0).get_matrix() == Matrix([E, -px, -py, -pz]) @filter_warnings_decorator def test_valued_tensor_contraction(): (A, B, AB, BA, C, Lorentz, E, px, py, pz, LorentzD, mu0, mu1, mu2, ndm, n0, n1, n2, NA, NB, NC, minkowski, ba_matrix, ndm_matrix, i0, i1, i2, i3, i4) = _get_valued_base_test_variables() assert (A(i0) * A(-i0)).data == E ** 2 - px ** 2 - py ** 2 - pz ** 2 assert (A(i0) * A(-i0)).data == A ** 2 assert (A(i0) * A(-i0)).data == A(i0) ** 2 assert (A(i0) * B(-i0)).data == -px - 2 * py - 3 * pz for i in range(4): for j in range(4): assert (A(i0) * B(-i1))[i, j] == [E, px, py, pz][i] * [0, -1, -2, -3][j] # test contraction on the alternative Minkowski metric: [-1, 1, 1, 1] assert (C(mu0) * C(-mu0)).data == -E ** 2 + px ** 2 + py ** 2 + pz ** 2 contrexp = A(i0) * AB(i1, -i0) assert A(i0).rank == 1 assert AB(i1, -i0).rank == 2 assert contrexp.rank == 1 for i in range(4): assert contrexp[i] == [E, px, py, pz][i] @filter_warnings_decorator def test_valued_tensor_self_contraction(): (A, B, AB, BA, C, Lorentz, E, px, py, pz, LorentzD, mu0, mu1, mu2, ndm, n0, n1, n2, NA, NB, NC, minkowski, ba_matrix, ndm_matrix, i0, i1, i2, i3, i4) = _get_valued_base_test_variables() assert AB(i0, -i0).data == 4 assert BA(i0, -i0).data == 2 @filter_warnings_decorator def test_valued_tensor_pow(): (A, B, AB, BA, C, Lorentz, E, px, py, pz, LorentzD, mu0, mu1, mu2, ndm, n0, n1, n2, NA, NB, NC, minkowski, ba_matrix, ndm_matrix, i0, i1, i2, i3, i4) = _get_valued_base_test_variables() assert C**2 == -E**2 + px**2 + py**2 + pz**2 assert C**1 == sqrt(-E**2 + px**2 + py**2 + pz**2) assert C(mu0)**2 == C**2 assert C(mu0)**1 == C**1 @filter_warnings_decorator def test_valued_tensor_expressions(): (A, B, AB, BA, C, Lorentz, E, px, py, pz, LorentzD, mu0, mu1, mu2, ndm, n0, n1, n2, NA, NB, NC, minkowski, ba_matrix, ndm_matrix, i0, i1, i2, i3, i4) = _get_valued_base_test_variables() x1, x2, x3 = symbols('x1:4') # test coefficient in contraction: rank2coeff = x1 * A(i3) * B(i2) assert rank2coeff[1, 1] == x1 * px assert rank2coeff[3, 3] == 3 * pz * x1 coeff_expr = ((x1 * A(i4)) * (B(-i4) / x2)).data assert coeff_expr.expand() == -px*x1/x2 - 2*py*x1/x2 - 3*pz*x1/x2 add_expr = A(i0) + B(i0) assert add_expr[0] == E assert add_expr[1] == px + 1 assert add_expr[2] == py + 2 assert add_expr[3] == pz + 3 sub_expr = A(i0) - B(i0) assert sub_expr[0] == E assert sub_expr[1] == px - 1 assert sub_expr[2] == py - 2 assert sub_expr[3] == pz - 3 assert (add_expr * B(-i0)).data == -px - 2*py - 3*pz - 14 expr1 = x1*A(i0) + x2*B(i0) expr2 = expr1 * B(i1) * (-4) expr3 = expr2 + 3*x3*AB(i0, i1) expr4 = expr3 / 2 assert expr4 * 2 == expr3 expr5 = (expr4 * BA(-i1, -i0)) assert expr5.data.expand() == 28*E*x1 + 12*px*x1 + 20*py*x1 + 28*pz*x1 + 136*x2 + 3*x3 @filter_warnings_decorator def test_valued_tensor_add_scalar(): (A, B, AB, BA, C, Lorentz, E, px, py, pz, LorentzD, mu0, mu1, mu2, ndm, n0, n1, n2, NA, NB, NC, minkowski, ba_matrix, ndm_matrix, i0, i1, i2, i3, i4) = _get_valued_base_test_variables() # one scalar summand after the contracted tensor expr1 = A(i0)*A(-i0) - (E**2 - px**2 - py**2 - pz**2) assert expr1.data == 0 # multiple scalar summands in front of the contracted tensor expr2 = E**2 - px**2 - py**2 - pz**2 - A(i0)*A(-i0) assert expr2.data == 0 # multiple scalar summands after the contracted tensor expr3 = A(i0)*A(-i0) - E**2 + px**2 + py**2 + pz**2 assert expr3.data == 0 # multiple scalar summands and multiple tensors expr4 = C(mu0)*C(-mu0) + 2*E**2 - 2*px**2 - 2*py**2 - 2*pz**2 - A(i0)*A(-i0) assert expr4.data == 0 @filter_warnings_decorator def test_noncommuting_components(): (A, B, AB, BA, C, Lorentz, E, px, py, pz, LorentzD, mu0, mu1, mu2, ndm, n0, n1, n2, NA, NB, NC, minkowski, ba_matrix, ndm_matrix, i0, i1, i2, i3, i4) = _get_valued_base_test_variables() euclid = TensorIndexType('Euclidean') euclid.data = [1, 1] i1, i2, i3 = tensor_indices('i1:4', euclid) a, b, c, d = symbols('a b c d', commutative=False) V1 = tensorhead('V1', [euclid] * 2, [[1]]*2) V1.data = [[a, b], (c, d)] V2 = tensorhead('V2', [euclid] * 2, [[1]]*2) V2.data = [[a, c], [b, d]] vtp = V1(i1, i2) * V2(-i2, -i1) assert vtp.data == a**2 + b**2 + c**2 + d**2 assert vtp.data != a**2 + 2*b*c + d**2 vtp2 = V1(i1, i2)*V1(-i2, -i1) assert vtp2.data == a**2 + b*c + c*b + d**2 assert vtp2.data != a**2 + 2*b*c + d**2 Vc = (b * V1(i1, -i1)).data assert Vc.expand() == b * a + b * d @filter_warnings_decorator def test_valued_non_diagonal_metric(): (A, B, AB, BA, C, Lorentz, E, px, py, pz, LorentzD, mu0, mu1, mu2, ndm, n0, n1, n2, NA, NB, NC, minkowski, ba_matrix, ndm_matrix, i0, i1, i2, i3, i4) = _get_valued_base_test_variables() mmatrix = Matrix(ndm_matrix) assert (NA(n0)*NA(-n0)).data == (NA(n0).get_matrix().T * mmatrix * NA(n0).get_matrix())[0, 0] @filter_warnings_decorator def test_valued_assign_numpy_ndarray(): (A, B, AB, BA, C, Lorentz, E, px, py, pz, LorentzD, mu0, mu1, mu2, ndm, n0, n1, n2, NA, NB, NC, minkowski, ba_matrix, ndm_matrix, i0, i1, i2, i3, i4) = _get_valued_base_test_variables() # this is needed to make sure that a numpy.ndarray can be assigned to a # tensor. arr = [E+1, px-1, py, pz] A.data = Array(arr) for i in range(4): assert A(i0).data[i] == arr[i] qx, qy, qz = symbols('qx qy qz') A(-i0).data = Array([E, qx, qy, qz]) for i in range(4): assert A(i0).data[i] == [E, -qx, -qy, -qz][i] assert A.data[i] == [E, -qx, -qy, -qz][i] # test on multi-indexed tensors. random_4x4_data = [[(i**3-3*i**2)%(j+7) for i in range(4)] for j in range(4)] AB(-i0, -i1).data = random_4x4_data for i in range(4): for j in range(4): assert AB(i0, i1).data[i, j] == random_4x4_data[i][j]*(-1 if i else 1)*(-1 if j else 1) assert AB(-i0, i1).data[i, j] == random_4x4_data[i][j]*(-1 if j else 1) assert AB(i0, -i1).data[i, j] == random_4x4_data[i][j]*(-1 if i else 1) assert AB(-i0, -i1).data[i, j] == random_4x4_data[i][j] AB(-i0, i1).data = random_4x4_data for i in range(4): for j in range(4): assert AB(i0, i1).data[i, j] == random_4x4_data[i][j]*(-1 if i else 1) assert AB(-i0, i1).data[i, j] == random_4x4_data[i][j] assert AB(i0, -i1).data[i, j] == random_4x4_data[i][j]*(-1 if i else 1)*(-1 if j else 1) assert AB(-i0, -i1).data[i, j] == random_4x4_data[i][j]*(-1 if j else 1) @filter_warnings_decorator def test_valued_metric_inverse(): (A, B, AB, BA, C, Lorentz, E, px, py, pz, LorentzD, mu0, mu1, mu2, ndm, n0, n1, n2, NA, NB, NC, minkowski, ba_matrix, ndm_matrix, i0, i1, i2, i3, i4) = _get_valued_base_test_variables() # let's assign some fancy matrix, just to verify it: # (this has no physical sense, it's just testing sympy); # it is symmetrical: md = [[2, 2, 2, 1], [2, 3, 1, 0], [2, 1, 2, 3], [1, 0, 3, 2]] Lorentz.data = md m = Matrix(md) metric = Lorentz.metric minv = m.inv() meye = eye(4) # the Kronecker Delta: KD = Lorentz.get_kronecker_delta() for i in range(4): for j in range(4): assert metric(i0, i1).data[i, j] == m[i, j] assert metric(-i0, -i1).data[i, j] == minv[i, j] assert metric(i0, -i1).data[i, j] == meye[i, j] assert metric(-i0, i1).data[i, j] == meye[i, j] assert metric(i0, i1)[i, j] == m[i, j] assert metric(-i0, -i1)[i, j] == minv[i, j] assert metric(i0, -i1)[i, j] == meye[i, j] assert metric(-i0, i1)[i, j] == meye[i, j] assert KD(i0, -i1)[i, j] == meye[i, j] @filter_warnings_decorator def test_valued_canon_bp_swapaxes(): (A, B, AB, BA, C, Lorentz, E, px, py, pz, LorentzD, mu0, mu1, mu2, ndm, n0, n1, n2, NA, NB, NC, minkowski, ba_matrix, ndm_matrix, i0, i1, i2, i3, i4) = _get_valued_base_test_variables() e1 = A(i1)*A(i0) e2 = e1.canon_bp() assert e2 == A(i0)*A(i1) for i in range(4): for j in range(4): assert e1[i, j] == e2[j, i] o1 = B(i2)*A(i1)*B(i0) o2 = o1.canon_bp() for i in range(4): for j in range(4): for k in range(4): assert o1[i, j, k] == o2[j, i, k] def test_pprint(): Lorentz = TensorIndexType('Lorentz') A = tensorhead('A', [Lorentz], [[1]]) assert pretty(A) == "A(Lorentz)" @filter_warnings_decorator def test_valued_components_with_wrong_symmetry(): IT = TensorIndexType('IT', dim=3) i0, i1, i2, i3 = tensor_indices('i0:4', IT) IT.data = [1, 1, 1] A_nosym = tensorhead('A', [IT]*2, [[1]]*2) A_sym = tensorhead('A', [IT]*2, [[1]*2]) A_antisym = tensorhead('A', [IT]*2, [[2]]) mat_nosym = Matrix([[1,2,3],[4,5,6],[7,8,9]]) mat_sym = mat_nosym + mat_nosym.T mat_antisym = mat_nosym - mat_nosym.T A_nosym.data = mat_nosym A_nosym.data = mat_sym A_nosym.data = mat_antisym def assign(A, dat): A.data = dat A_sym.data = mat_sym raises(ValueError, lambda: assign(A_sym, mat_nosym)) raises(ValueError, lambda: assign(A_sym, mat_antisym)) A_antisym.data = mat_antisym raises(ValueError, lambda: assign(A_antisym, mat_sym)) raises(ValueError, lambda: assign(A_antisym, mat_nosym)) A_sym.data = [[0, 0, 0], [0, 0, 0], [0, 0, 0]] A_antisym.data = [[0, 0, 0], [0, 0, 0], [0, 0, 0]] @filter_warnings_decorator def test_issue_10972_TensMul_data(): Lorentz = TensorIndexType('Lorentz', metric=False, dummy_fmt='i', dim=2) Lorentz.data = [-1, 1] mu, nu, alpha, beta = tensor_indices('\\mu, \\nu, \\alpha, \\beta', Lorentz) Vec = TensorType([Lorentz], tensorsymmetry([1])) A2 = TensorType([Lorentz] * 2, tensorsymmetry([2])) u = Vec('u') u.data = [1, 0] F = A2('F') F.data = [[0, 1], [-1, 0]] mul_1 = F(mu, alpha) * u(-alpha) * F(nu, beta) * u(-beta) assert (mul_1.data == Array([[0, 0], [0, 1]])) mul_2 = F(mu, alpha) * F(nu, beta) * u(-alpha) * u(-beta) assert (mul_2.data == mul_1.data) assert ((mul_1 + mul_1).data == 2 * mul_1.data) @filter_warnings_decorator def test_TensMul_data(): Lorentz = TensorIndexType('Lorentz', metric=False, dummy_fmt='L', dim=4) Lorentz.data = [-1, 1, 1, 1] mu, nu, alpha, beta = tensor_indices('\\mu, \\nu, \\alpha, \\beta', Lorentz) Vec = TensorType([Lorentz], tensorsymmetry([1])) A2 = TensorType([Lorentz] * 2, tensorsymmetry([2])) u = Vec('u') u.data = [1, 0, 0, 0] F = A2('F') Ex, Ey, Ez, Bx, By, Bz = symbols('E_x E_y E_z B_x B_y B_z') F.data = [ [0, Ex, Ey, Ez], [-Ex, 0, Bz, -By], [-Ey, -Bz, 0, Bx], [-Ez, By, -Bx, 0]] E = F(mu, nu) * u(-nu) assert ((E(mu) * E(nu)).data == Array([[0, 0, 0, 0], [0, Ex ** 2, Ex * Ey, Ex * Ez], [0, Ex * Ey, Ey ** 2, Ey * Ez], [0, Ex * Ez, Ey * Ez, Ez ** 2]]) ) assert ((E(mu) * E(nu)).canon_bp().data == (E(mu) * E(nu)).data) assert ((F(mu, alpha) * F(beta, nu) * u(-alpha) * u(-beta)).data == - (E(mu) * E(nu)).data ) assert ((F(alpha, mu) * F(beta, nu) * u(-alpha) * u(-beta)).data == (E(mu) * E(nu)).data ) S2 = TensorType([Lorentz] * 2, tensorsymmetry([1] * 2)) g = S2('g') g.data = Lorentz.data # tensor 'perp' is orthogonal to vector 'u' perp = u(mu) * u(nu) + g(mu, nu) mul_1 = u(-mu) * perp(mu, nu) assert (mul_1.data == Array([0, 0, 0, 0])) mul_2 = u(-mu) * perp(mu, alpha) * perp(nu, beta) assert (mul_2.data == Array.zeros(4, 4, 4)) Fperp = perp(mu, alpha) * perp(nu, beta) * F(-alpha, -beta) assert (Fperp.data[0, :] == Array([0, 0, 0, 0])) assert (Fperp.data[:, 0] == Array([0, 0, 0, 0])) mul_3 = u(-mu) * Fperp(mu, nu) assert (mul_3.data == Array([0, 0, 0, 0])) @filter_warnings_decorator def test_issue_11020_TensAdd_data(): Lorentz = TensorIndexType('Lorentz', metric=False, dummy_fmt='i', dim=2) Lorentz.data = [-1, 1] a, b, c, d = tensor_indices('a, b, c, d', Lorentz) i0, i1 = tensor_indices('i_0:2', Lorentz) Vec = TensorType([Lorentz], tensorsymmetry([1])) S2 = TensorType([Lorentz] * 2, tensorsymmetry([1] * 2)) # metric tensor g = S2('g') g.data = Lorentz.data u = Vec('u') u.data = [1, 0] add_1 = g(b, c) * g(d, i0) * u(-i0) - g(b, c) * u(d) assert (add_1.data == Array.zeros(2, 2, 2)) # Now let us replace index `d` with `a`: add_2 = g(b, c) * g(a, i0) * u(-i0) - g(b, c) * u(a) assert (add_2.data == Array.zeros(2, 2, 2)) # some more tests # perp is tensor orthogonal to u^\mu perp = u(a) * u(b) + g(a, b) mul_1 = u(-a) * perp(a, b) assert (mul_1.data == Array([0, 0])) mul_2 = u(-c) * perp(c, a) * perp(d, b) assert (mul_2.data == Array.zeros(2, 2, 2)) def test_index_iteration(): L = TensorIndexType("Lorentz", dummy_fmt="L") i0,i1,i2,i3,i4 = tensor_indices('i0:5', L) L0 = tensor_indices('L_0', L) L1 = tensor_indices('L_1', L) A = tensorhead("A", [L, L], [[1], [1]]) B = tensorhead("B", [L, L], [[1, 1]]) C = tensorhead("C", [L], [[1]]) e1 = A(i0, i2) e2 = A(i0, -i0) e3 = A(i0, i1)*B(i2, i3) e4 = A(i0, i1)*B(i2, -i1) e5 = A(i0, i1)*B(-i0, -i1) e6 = e1 + e4 assert list(e1._iterate_free_indices) == [(i0, (1, 0)), (i2, (1, 1))] assert list(e1._iterate_dummy_indices) == [] assert list(e1._iterate_indices) == [(i0, (1, 0)), (i2, (1, 1))] assert list(e2._iterate_free_indices) == [] assert list(e2._iterate_dummy_indices) == [(L0, (1, 0)), (-L0, (1, 1))] assert list(e2._iterate_indices) == [(L0, (1, 0)), (-L0, (1, 1))] assert list(e3._iterate_free_indices) == [(i0, (0, 1, 0)), (i1, (0, 1, 1)), (i2, (1, 1, 0)), (i3, (1, 1, 1))] assert list(e3._iterate_dummy_indices) == [] assert list(e3._iterate_indices) == [(i0, (0, 1, 0)), (i1, (0, 1, 1)), (i2, (1, 1, 0)), (i3, (1, 1, 1))] assert list(e4._iterate_free_indices) == [(i0, (0, 1, 0)), (i2, (1, 1, 0))] assert list(e4._iterate_dummy_indices) == [(L0, (0, 1, 1)), (-L0, (1, 1, 1))] assert list(e4._iterate_indices) == [(i0, (0, 1, 0)), (L0, (0, 1, 1)), (i2, (1, 1, 0)), (-L0, (1, 1, 1))] assert list(e5._iterate_free_indices) == [] assert list(e5._iterate_dummy_indices) == [(L0, (0, 1, 0)), (L1, (0, 1, 1)), (-L0, (1, 1, 0)), (-L1, (1, 1, 1))] assert list(e5._iterate_indices) == [(L0, (0, 1, 0)), (L1, (0, 1, 1)), (-L0, (1, 1, 0)), (-L1, (1, 1, 1))] assert list(e6._iterate_free_indices) == [(i0, (0, 1, 0)), (i2, (0, 1, 1)), (i0, (1, 0, 1, 0)), (i2, (1, 1, 1, 0))] assert list(e6._iterate_dummy_indices) == [(L0, (1, 0, 1, 1)), (-L0, (1, 1, 1, 1))] assert list(e6._iterate_indices) == [(i0, (0, 1, 0)), (i2, (0, 1, 1)), (i0, (1, 0, 1, 0)), (L0, (1, 0, 1, 1)), (i2, (1, 1, 1, 0)), (-L0, (1, 1, 1, 1))] assert e1.get_indices() == [i0, i2] assert e1.get_free_indices() == [i0, i2] assert e2.get_indices() == [L0, -L0] assert e2.get_free_indices() == [] assert e3.get_indices() == [i0, i1, i2, i3] assert e3.get_free_indices() == [i0, i1, i2, i3] assert e4.get_indices() == [i0, L0, i2, -L0] assert e4.get_free_indices() == [i0, i2] assert e5.get_indices() == [L0, L1, -L0, -L1] assert e5.get_free_indices() == [] def test_tensor_expand(): L = TensorIndexType("L") i, j, k = tensor_indices("i j k", L) i0 = tensor_indices("i0", L) L_0 = TensorIndex("L_0", L) L_1 = TensorIndex("L_1", L) A, B, C, D = tensorhead("A B C D", [L], [[1]]) H = tensorhead("H", [L, L], [[1], [1]]) assert isinstance(Add(A(i), B(i)), TensAdd) assert isinstance(expand(A(i)+B(i)), TensAdd) expr = A(i)*(A(-i)+B(-i)) assert expr.args == (A(L_0), A(-L_0) + B(-L_0)) assert expr != A(i)*A(-i) + A(i)*B(-i) assert expr.expand() == A(i)*A(-i) + A(i)*B(-i) assert str(expr) == "A(L_0)*(A(-L_0) + B(-L_0))" expr = A(i)*A(j) + A(i)*B(j) assert str(expr) == "A(i)*A(j) + A(i)*B(j)" expr = A(-i)*(A(i)*A(j) + A(i)*B(j)*C(k)*C(-k)) assert expr != A(-i)*A(i)*A(j) + A(-i)*A(i)*B(j)*C(k)*C(-k) assert expr.expand() == A(-i)*A(i)*A(j) + A(-i)*A(i)*B(j)*C(k)*C(-k) assert str(expr) == "A(-L_0)*(A(L_0)*A(j) + A(L_0)*B(j)*C(L_1)*C(-L_1))" assert str(expr.canon_bp()) == 'A(L_0)*A(-L_0)*B(j)*C(L_1)*C(-L_1) + A(j)*A(L_0)*A(-L_0)' expr = A(-i)*(2*A(i)*A(j) + A(i)*B(j)) assert expr.expand() == 2*A(-i)*A(i)*A(j) + A(-i)*A(i)*B(j) expr = 2*A(i)*A(-i) assert expr.coeff == 2 expr = A(i)*(B(j)*C(k) + C(j)*(A(k) + D(k))) assert str(expr) == "A(i)*(B(j)*C(k) + C(j)*(A(k) + D(k)))" assert str(expr.expand()) == "A(i)*B(j)*C(k) + A(i)*C(j)*A(k) + A(i)*C(j)*D(k)" assert isinstance(TensMul(3), TensMul) tm = TensMul(3).doit() assert tm == 3 assert isinstance(tm, Integer) p1 = B(j)*B(-j) + B(j)*C(-j) p2 = C(-i)*p1 p3 = A(i)*p2 expr = A(i)*(B(-i) + C(-i)*(B(j)*B(-j) + B(j)*C(-j))) assert expr.expand() == A(i)*B(-i) + A(i)*C(-i)*B(j)*B(-j) + A(i)*C(-i)*B(j)*C(-j) expr = C(-i)*(B(j)*B(-j) + B(j)*C(-j)) assert expr.expand() == C(-i)*B(j)*B(-j) + C(-i)*B(j)*C(-j) def test_tensor_alternative_construction(): L = TensorIndexType("L") i0, i1, i2, i3 = tensor_indices('i0:4', L) A = tensorhead("A", [L], [[1]]) x, y = symbols("x y") assert A(i0) == A(Symbol("i0")) assert A(-i0) == A(-Symbol("i0")) raises(TypeError, lambda: A(x+y)) raises(ValueError, lambda: A(2*x)) def test_tensor_replacement(): L = TensorIndexType("L") L2 = TensorIndexType("L2", dim=2) i, j, k, l = tensor_indices("i j k l", L) i0 = tensor_indices("i0", L) A, B, C, D = tensorhead("A B C D", [L], [[1]]) H = tensorhead("H", [L, L], [[1], [1]]) K = tensorhead("K", [L, L, L, L], [[1], [1], [1], [1]]) expr = H(i, j) repl = {H(i,-j): [[1,2],[3,4]], L: diag(1, -1)} assert expr._extract_data(repl) == ([i, j], Array([[1, -2], [3, -4]])) assert expr.replace_with_arrays(repl) == Array([[1, -2], [3, -4]]) assert expr.replace_with_arrays(repl, [i, j]) == Array([[1, -2], [3, -4]]) assert expr.replace_with_arrays(repl, [i, -j]) == Array([[1, 2], [3, 4]]) assert expr.replace_with_arrays(repl, [-i, j]) == Array([[1, -2], [-3, 4]]) assert expr.replace_with_arrays(repl, [-i, -j]) == Array([[1, 2], [-3, -4]]) assert expr.replace_with_arrays(repl, [j, i]) == Array([[1, 3], [-2, -4]]) assert expr.replace_with_arrays(repl, [j, -i]) == Array([[1, -3], [-2, 4]]) assert expr.replace_with_arrays(repl, [-j, i]) == Array([[1, 3], [2, 4]]) assert expr.replace_with_arrays(repl, [-j, -i]) == Array([[1, -3], [2, -4]]) # Test stability of optional parameter 'indices' assert expr.replace_with_arrays(repl) == Array([[1, -2], [3, -4]]) expr = H(i,j) repl = {H(i,j): [[1,2],[3,4]], L: diag(1, -1)} assert expr._extract_data(repl) == ([i, j], Array([[1, 2], [3, 4]])) assert expr.replace_with_arrays(repl) == Array([[1, 2], [3, 4]]) assert expr.replace_with_arrays(repl, [i, j]) == Array([[1, 2], [3, 4]]) assert expr.replace_with_arrays(repl, [i, -j]) == Array([[1, -2], [3, -4]]) assert expr.replace_with_arrays(repl, [-i, j]) == Array([[1, 2], [-3, -4]]) assert expr.replace_with_arrays(repl, [-i, -j]) == Array([[1, -2], [-3, 4]]) assert expr.replace_with_arrays(repl, [j, i]) == Array([[1, 3], [2, 4]]) assert expr.replace_with_arrays(repl, [j, -i]) == Array([[1, -3], [2, -4]]) assert expr.replace_with_arrays(repl, [-j, i]) == Array([[1, 3], [-2, -4]]) assert expr.replace_with_arrays(repl, [-j, -i]) == Array([[1, -3], [-2, 4]]) # Not the same indices: expr = H(i,k) repl = {H(i,j): [[1,2],[3,4]], L: diag(1, -1)} assert expr._extract_data(repl) == ([i, k], Array([[1, 2], [3, 4]])) expr = A(i)*A(-i) repl = {A(i): [1,2], L: diag(1, -1)} assert expr._extract_data(repl) == ([], -3) assert expr.replace_with_arrays(repl, []) == -3 expr = K(i, j, -j, k)*A(-i)*A(-k) repl = {A(i): [1, 2], K(i,j,k,l): Array([1]*2**4).reshape(2,2,2,2), L: diag(1, -1)} assert expr._extract_data(repl) expr = H(j, k) repl = {H(i,j): [[1,2],[3,4]], L: diag(1, -1)} raises(ValueError, lambda: expr._extract_data(repl)) expr = A(i) repl = {B(i): [1, 2]} raises(ValueError, lambda: expr._extract_data(repl)) expr = A(i) repl = {A(i): [[1, 2], [3, 4]]} raises(ValueError, lambda: expr._extract_data(repl)) # TensAdd: expr = A(k)*H(i, j) + B(k)*H(i, j) repl = {A(k): [1], B(k): [1], H(i, j): [[1, 2],[3,4]], L:diag(1,1)} assert expr._extract_data(repl) == ([k, i, j], Array([[[2, 4], [6, 8]]])) assert expr.replace_with_arrays(repl, [k, i, j]) == Array([[[2, 4], [6, 8]]]) assert expr.replace_with_arrays(repl, [k, j, i]) == Array([[[2, 6], [4, 8]]]) expr = A(k)*A(-k) + 100 repl = {A(k): [2, 3], L: diag(1, 1)} assert expr.replace_with_arrays(repl, []) == 113 ## Symmetrization: expr = H(i, j) + H(j, i) repl = {H(i, j): [[1, 2], [3, 4]]} assert expr._extract_data(repl) == ([i, j], Array([[2, 5], [5, 8]])) assert expr.replace_with_arrays(repl, [i, j]) == Array([[2, 5], [5, 8]]) assert expr.replace_with_arrays(repl, [j, i]) == Array([[2, 5], [5, 8]]) ## Anti-symmetrization: expr = H(i, j) - H(j, i) repl = {H(i, j): [[1, 2], [3, 4]]} assert expr.replace_with_arrays(repl, [i, j]) == Array([[0, -1], [1, 0]]) assert expr.replace_with_arrays(repl, [j, i]) == Array([[0, 1], [-1, 0]]) # Tensors with contractions in replacements: expr = K(i, j, k, -k) repl = {K(i, j, k, -k): [[1, 2], [3, 4]]} assert expr._extract_data(repl) == ([i, j], Array([[1, 2], [3, 4]])) expr = H(i, -i) repl = {H(i, -i): 42} assert expr._extract_data(repl) == ([], 42) # Replace with array, raise exception if indices are not compatible: expr = A(i)*A(j) repl = {A(i): [1, 2]} raises(ValueError, lambda: expr.replace_with_arrays(repl, [j])) # Raise exception if array dimension is not compatible: expr = A(i) repl = {A(i): [[1, 2]]} raises(ValueError, lambda: expr.replace_with_arrays(repl, [i])) # TensorIndexType with dimension, wrong dimension in replacement array: u1, u2, u3 = tensor_indices("u1:4", L2) U = tensorhead("U", [L2], [[1]]) expr = U(u1)*U(-u2) repl = {U(u1): [[1]]} raises(ValueError, lambda: expr.replace_with_arrays(repl, [u1, -u2])) def test_rewrite_tensor_to_Indexed(): L = TensorIndexType("L", dim=4) A = tensorhead("A", [L, L, L, L], [[1], [1], [1], [1]]) B = tensorhead("B", [L], [[1]]) i0, i1, i2, i3 = symbols("i0:4") L_0, L_1 = symbols("L_0:2") a1 = A(i0, i1, i2, i3) assert a1.rewrite(Indexed) == Indexed(Symbol("A"), i0, i1, i2, i3) a2 = A(i0, -i0, i2, i3) assert a2.rewrite(Indexed) == Sum(Indexed(Symbol("A"), L_0, L_0, i2, i3), (L_0, 0, 3)) a3 = a2 + A(i2, i3, i0, -i0) assert a3.rewrite(Indexed) == \ Sum(Indexed(Symbol("A"), L_0, L_0, i2, i3), (L_0, 0, 3)) +\ Sum(Indexed(Symbol("A"), i2, i3, L_0, L_0), (L_0, 0, 3)) b1 = B(-i0)*a1 assert b1.rewrite(Indexed) == Sum(Indexed(Symbol("B"), L_0)*Indexed(Symbol("A"), L_0, i1, i2, i3), (L_0, 0, 3)) b2 = B(-i3)*a2 assert b2.rewrite(Indexed) == Sum(Indexed(Symbol("B"), L_1)*Indexed(Symbol("A"), L_0, L_0, i2, L_1), (L_0, 0, 3), (L_1, 0, 3))
422e0695ff6bc4c77b346f1cdfe657e78095a9ddb194633cd61e007de6feacf7
import collections import random from sympy.assumptions import Q from sympy.core.add import Add from sympy.core.compatibility import range from sympy.core.function import (Function, diff) from sympy.core.numbers import (E, Float, I, Integer, oo, pi) from sympy.core.relational import (Eq, Lt) from sympy.core.singleton import S from sympy.core.symbol import (Symbol, symbols) from sympy.functions.elementary.complexes import Abs from sympy.functions.elementary.exponential import exp from sympy.functions.elementary.miscellaneous import (Max, Min, sqrt) from sympy.functions.elementary.piecewise import Piecewise from sympy.functions.elementary.trigonometric import (cos, sin, tan) from sympy.logic.boolalg import (And, Or) from sympy.matrices.common import (ShapeError, MatrixError, NonSquareMatrixError, _MinimalMatrix, MatrixShaping, MatrixProperties, MatrixOperations, MatrixArithmetic, MatrixSpecial) from sympy.matrices.matrices import (MatrixDeterminant, MatrixReductions, MatrixSubspaces, MatrixEigen, MatrixCalculus) from sympy.matrices import (Matrix, diag, eye, matrix_multiply_elementwise, ones, zeros, SparseMatrix) from sympy.polys.polytools import Poly from sympy.simplify.simplify import simplify from sympy.simplify.trigsimp import trigsimp from sympy.utilities.iterables import flatten from sympy.utilities.pytest import (raises, XFAIL, slow, skip, warns_deprecated_sympy) from sympy.abc import a, b, c, d, x, y, z # classes to test the basic matrix classes class ShapingOnlyMatrix(_MinimalMatrix, MatrixShaping): pass def eye_Shaping(n): return ShapingOnlyMatrix(n, n, lambda i, j: int(i == j)) def zeros_Shaping(n): return ShapingOnlyMatrix(n, n, lambda i, j: 0) class PropertiesOnlyMatrix(_MinimalMatrix, MatrixProperties): pass def eye_Properties(n): return PropertiesOnlyMatrix(n, n, lambda i, j: int(i == j)) def zeros_Properties(n): return PropertiesOnlyMatrix(n, n, lambda i, j: 0) class OperationsOnlyMatrix(_MinimalMatrix, MatrixOperations): pass def eye_Operations(n): return OperationsOnlyMatrix(n, n, lambda i, j: int(i == j)) def zeros_Operations(n): return OperationsOnlyMatrix(n, n, lambda i, j: 0) class ArithmeticOnlyMatrix(_MinimalMatrix, MatrixArithmetic): pass def eye_Arithmetic(n): return ArithmeticOnlyMatrix(n, n, lambda i, j: int(i == j)) def zeros_Arithmetic(n): return ArithmeticOnlyMatrix(n, n, lambda i, j: 0) class DeterminantOnlyMatrix(_MinimalMatrix, MatrixDeterminant): pass def eye_Determinant(n): return DeterminantOnlyMatrix(n, n, lambda i, j: int(i == j)) def zeros_Determinant(n): return DeterminantOnlyMatrix(n, n, lambda i, j: 0) class ReductionsOnlyMatrix(_MinimalMatrix, MatrixReductions): pass def eye_Reductions(n): return ReductionsOnlyMatrix(n, n, lambda i, j: int(i == j)) def zeros_Reductions(n): return ReductionsOnlyMatrix(n, n, lambda i, j: 0) class SpecialOnlyMatrix(_MinimalMatrix, MatrixSpecial): pass class SubspaceOnlyMatrix(_MinimalMatrix, MatrixSubspaces): pass class EigenOnlyMatrix(_MinimalMatrix, MatrixEigen): pass class CalculusOnlyMatrix(_MinimalMatrix, MatrixCalculus): pass def test__MinimalMatrix(): x = _MinimalMatrix(2, 3, [1, 2, 3, 4, 5, 6]) assert x.rows == 2 assert x.cols == 3 assert x[2] == 3 assert x[1, 1] == 5 assert list(x) == [1, 2, 3, 4, 5, 6] assert list(x[1, :]) == [4, 5, 6] assert list(x[:, 1]) == [2, 5] assert list(x[:, :]) == list(x) assert x[:, :] == x assert _MinimalMatrix(x) == x assert _MinimalMatrix([[1, 2, 3], [4, 5, 6]]) == x assert _MinimalMatrix(([1, 2, 3], [4, 5, 6])) == x assert _MinimalMatrix([(1, 2, 3), (4, 5, 6)]) == x assert _MinimalMatrix(((1, 2, 3), (4, 5, 6))) == x assert not (_MinimalMatrix([[1, 2], [3, 4], [5, 6]]) == x) # ShapingOnlyMatrix tests def test_vec(): m = ShapingOnlyMatrix(2, 2, [1, 3, 2, 4]) m_vec = m.vec() assert m_vec.cols == 1 for i in range(4): assert m_vec[i] == i + 1 def test_tolist(): lst = [[S.One, S.Half, x*y, S.Zero], [x, y, z, x**2], [y, -S.One, z*x, 3]] flat_lst = [S.One, S.Half, x*y, S.Zero, x, y, z, x**2, y, -S.One, z*x, 3] m = ShapingOnlyMatrix(3, 4, flat_lst) assert m.tolist() == lst def test_row_col_del(): e = ShapingOnlyMatrix(3, 3, [1, 2, 3, 4, 5, 6, 7, 8, 9]) raises(ValueError, lambda: e.row_del(5)) raises(ValueError, lambda: e.row_del(-5)) raises(ValueError, lambda: e.col_del(5)) raises(ValueError, lambda: e.col_del(-5)) assert e.row_del(2) == e.row_del(-1) == Matrix([[1, 2, 3], [4, 5, 6]]) assert e.col_del(2) == e.col_del(-1) == Matrix([[1, 2], [4, 5], [7, 8]]) assert e.row_del(1) == e.row_del(-2) == Matrix([[1, 2, 3], [7, 8, 9]]) assert e.col_del(1) == e.col_del(-2) == Matrix([[1, 3], [4, 6], [7, 9]]) def test_get_diag_blocks1(): a = Matrix([[1, 2], [2, 3]]) b = Matrix([[3, x], [y, 3]]) c = Matrix([[3, x, 3], [y, 3, z], [x, y, z]]) assert a.get_diag_blocks() == [a] assert b.get_diag_blocks() == [b] assert c.get_diag_blocks() == [c] def test_get_diag_blocks2(): a = Matrix([[1, 2], [2, 3]]) b = Matrix([[3, x], [y, 3]]) c = Matrix([[3, x, 3], [y, 3, z], [x, y, z]]) A, B, C, D = diag(a, b, b), diag(a, b, c), diag(a, c, b), diag(c, c, b) A = ShapingOnlyMatrix(A.rows, A.cols, A) B = ShapingOnlyMatrix(B.rows, B.cols, B) C = ShapingOnlyMatrix(C.rows, C.cols, C) D = ShapingOnlyMatrix(D.rows, D.cols, D) assert A.get_diag_blocks() == [a, b, b] assert B.get_diag_blocks() == [a, b, c] assert C.get_diag_blocks() == [a, c, b] assert D.get_diag_blocks() == [c, c, b] def test_shape(): m = ShapingOnlyMatrix(1, 2, [0, 0]) m.shape == (1, 2) def test_reshape(): m0 = eye_Shaping(3) assert m0.reshape(1, 9) == Matrix(1, 9, (1, 0, 0, 0, 1, 0, 0, 0, 1)) m1 = ShapingOnlyMatrix(3, 4, lambda i, j: i + j) assert m1.reshape( 4, 3) == Matrix(((0, 1, 2), (3, 1, 2), (3, 4, 2), (3, 4, 5))) assert m1.reshape(2, 6) == Matrix(((0, 1, 2, 3, 1, 2), (3, 4, 2, 3, 4, 5))) def test_row_col(): m = ShapingOnlyMatrix(3, 3, [1, 2, 3, 4, 5, 6, 7, 8, 9]) assert m.row(0) == Matrix(1, 3, [1, 2, 3]) assert m.col(0) == Matrix(3, 1, [1, 4, 7]) def test_row_join(): assert eye_Shaping(3).row_join(Matrix([7, 7, 7])) == \ Matrix([[1, 0, 0, 7], [0, 1, 0, 7], [0, 0, 1, 7]]) def test_col_join(): assert eye_Shaping(3).col_join(Matrix([[7, 7, 7]])) == \ Matrix([[1, 0, 0], [0, 1, 0], [0, 0, 1], [7, 7, 7]]) def test_row_insert(): r4 = Matrix([[4, 4, 4]]) for i in range(-4, 5): l = [1, 0, 0] l.insert(i, 4) assert flatten(eye_Shaping(3).row_insert(i, r4).col(0).tolist()) == l def test_col_insert(): c4 = Matrix([4, 4, 4]) for i in range(-4, 5): l = [0, 0, 0] l.insert(i, 4) assert flatten(zeros_Shaping(3).col_insert(i, c4).row(0).tolist()) == l # issue 13643 assert eye_Shaping(6).col_insert(3, Matrix([[2, 2], [2, 2], [2, 2], [2, 2], [2, 2], [2, 2]])) == \ Matrix([[1, 0, 0, 2, 2, 0, 0, 0], [0, 1, 0, 2, 2, 0, 0, 0], [0, 0, 1, 2, 2, 0, 0, 0], [0, 0, 0, 2, 2, 1, 0, 0], [0, 0, 0, 2, 2, 0, 1, 0], [0, 0, 0, 2, 2, 0, 0, 1]]) def test_extract(): m = ShapingOnlyMatrix(4, 3, lambda i, j: i*3 + j) assert m.extract([0, 1, 3], [0, 1]) == Matrix(3, 2, [0, 1, 3, 4, 9, 10]) assert m.extract([0, 3], [0, 0, 2]) == Matrix(2, 3, [0, 0, 2, 9, 9, 11]) assert m.extract(range(4), range(3)) == m raises(IndexError, lambda: m.extract([4], [0])) raises(IndexError, lambda: m.extract([0], [3])) def test_hstack(): m = ShapingOnlyMatrix(4, 3, lambda i, j: i*3 + j) m2 = ShapingOnlyMatrix(3, 4, lambda i, j: i*3 + j) assert m == m.hstack(m) assert m.hstack(m, m, m) == ShapingOnlyMatrix.hstack(m, m, m) == Matrix([ [0, 1, 2, 0, 1, 2, 0, 1, 2], [3, 4, 5, 3, 4, 5, 3, 4, 5], [6, 7, 8, 6, 7, 8, 6, 7, 8], [9, 10, 11, 9, 10, 11, 9, 10, 11]]) raises(ShapeError, lambda: m.hstack(m, m2)) assert Matrix.hstack() == Matrix() # test regression #12938 M1 = Matrix.zeros(0, 0) M2 = Matrix.zeros(0, 1) M3 = Matrix.zeros(0, 2) M4 = Matrix.zeros(0, 3) m = ShapingOnlyMatrix.hstack(M1, M2, M3, M4) assert m.rows == 0 and m.cols == 6 def test_vstack(): m = ShapingOnlyMatrix(4, 3, lambda i, j: i*3 + j) m2 = ShapingOnlyMatrix(3, 4, lambda i, j: i*3 + j) assert m == m.vstack(m) assert m.vstack(m, m, m) == ShapingOnlyMatrix.vstack(m, m, m) == Matrix([ [0, 1, 2], [3, 4, 5], [6, 7, 8], [9, 10, 11], [0, 1, 2], [3, 4, 5], [6, 7, 8], [9, 10, 11], [0, 1, 2], [3, 4, 5], [6, 7, 8], [9, 10, 11]]) raises(ShapeError, lambda: m.vstack(m, m2)) assert Matrix.vstack() == Matrix() # PropertiesOnlyMatrix tests def test_atoms(): m = PropertiesOnlyMatrix(2, 2, [1, 2, x, 1 - 1/x]) assert m.atoms() == {S(1), S(2), S(-1), x} assert m.atoms(Symbol) == {x} def test_free_symbols(): assert PropertiesOnlyMatrix([[x], [0]]).free_symbols == {x} def test_has(): A = PropertiesOnlyMatrix(((x, y), (2, 3))) assert A.has(x) assert not A.has(z) assert A.has(Symbol) A = PropertiesOnlyMatrix(((2, y), (2, 3))) assert not A.has(x) def test_is_anti_symmetric(): x = symbols('x') assert PropertiesOnlyMatrix(2, 1, [1, 2]).is_anti_symmetric() is False m = PropertiesOnlyMatrix(3, 3, [0, x**2 + 2*x + 1, y, -(x + 1)**2, 0, x*y, -y, -x*y, 0]) assert m.is_anti_symmetric() is True assert m.is_anti_symmetric(simplify=False) is False assert m.is_anti_symmetric(simplify=lambda x: x) is False m = PropertiesOnlyMatrix(3, 3, [x.expand() for x in m]) assert m.is_anti_symmetric(simplify=False) is True m = PropertiesOnlyMatrix(3, 3, [x.expand() for x in [S.One] + list(m)[1:]]) assert m.is_anti_symmetric() is False def test_diagonal_symmetrical(): m = PropertiesOnlyMatrix(2, 2, [0, 1, 1, 0]) assert not m.is_diagonal() assert m.is_symmetric() assert m.is_symmetric(simplify=False) m = PropertiesOnlyMatrix(2, 2, [1, 0, 0, 1]) assert m.is_diagonal() m = PropertiesOnlyMatrix(3, 3, diag(1, 2, 3)) assert m.is_diagonal() assert m.is_symmetric() m = PropertiesOnlyMatrix(3, 3, [1, 0, 0, 0, 2, 0, 0, 0, 3]) assert m == diag(1, 2, 3) m = PropertiesOnlyMatrix(2, 3, zeros(2, 3)) assert not m.is_symmetric() assert m.is_diagonal() m = PropertiesOnlyMatrix(((5, 0), (0, 6), (0, 0))) assert m.is_diagonal() m = PropertiesOnlyMatrix(((5, 0, 0), (0, 6, 0))) assert m.is_diagonal() m = Matrix(3, 3, [1, x**2 + 2*x + 1, y, (x + 1)**2, 2, 0, y, 0, 3]) assert m.is_symmetric() assert not m.is_symmetric(simplify=False) assert m.expand().is_symmetric(simplify=False) def test_is_hermitian(): a = PropertiesOnlyMatrix([[1, I], [-I, 1]]) assert a.is_hermitian a = PropertiesOnlyMatrix([[2*I, I], [-I, 1]]) assert a.is_hermitian is False a = PropertiesOnlyMatrix([[x, I], [-I, 1]]) assert a.is_hermitian is None a = PropertiesOnlyMatrix([[x, 1], [-I, 1]]) assert a.is_hermitian is False def test_is_Identity(): assert eye_Properties(3).is_Identity assert not PropertiesOnlyMatrix(zeros(3)).is_Identity assert not PropertiesOnlyMatrix(ones(3)).is_Identity # issue 6242 assert not PropertiesOnlyMatrix([[1, 0, 0]]).is_Identity def test_is_symbolic(): a = PropertiesOnlyMatrix([[x, x], [x, x]]) assert a.is_symbolic() is True a = PropertiesOnlyMatrix([[1, 2, 3, 4], [5, 6, 7, 8]]) assert a.is_symbolic() is False a = PropertiesOnlyMatrix([[1, 2, 3, 4], [5, 6, x, 8]]) assert a.is_symbolic() is True a = PropertiesOnlyMatrix([[1, x, 3]]) assert a.is_symbolic() is True a = PropertiesOnlyMatrix([[1, 2, 3]]) assert a.is_symbolic() is False a = PropertiesOnlyMatrix([[1], [x], [3]]) assert a.is_symbolic() is True a = PropertiesOnlyMatrix([[1], [2], [3]]) assert a.is_symbolic() is False def test_is_upper(): a = PropertiesOnlyMatrix([[1, 2, 3]]) assert a.is_upper is True a = PropertiesOnlyMatrix([[1], [2], [3]]) assert a.is_upper is False def test_is_lower(): a = PropertiesOnlyMatrix([[1, 2, 3]]) assert a.is_lower is False a = PropertiesOnlyMatrix([[1], [2], [3]]) assert a.is_lower is True def test_is_square(): m = PropertiesOnlyMatrix([[1], [1]]) m2 = PropertiesOnlyMatrix([[2, 2], [2, 2]]) assert not m.is_square assert m2.is_square def test_is_symmetric(): m = PropertiesOnlyMatrix(2, 2, [0, 1, 1, 0]) assert m.is_symmetric() m = PropertiesOnlyMatrix(2, 2, [0, 1, 0, 1]) assert not m.is_symmetric() def test_is_hessenberg(): A = PropertiesOnlyMatrix([[3, 4, 1], [2, 4, 5], [0, 1, 2]]) assert A.is_upper_hessenberg A = PropertiesOnlyMatrix(3, 3, [3, 2, 0, 4, 4, 1, 1, 5, 2]) assert A.is_lower_hessenberg A = PropertiesOnlyMatrix(3, 3, [3, 2, -1, 4, 4, 1, 1, 5, 2]) assert A.is_lower_hessenberg is False assert A.is_upper_hessenberg is False A = PropertiesOnlyMatrix([[3, 4, 1], [2, 4, 5], [3, 1, 2]]) assert not A.is_upper_hessenberg def test_is_zero(): assert PropertiesOnlyMatrix(0, 0, []).is_zero assert PropertiesOnlyMatrix([[0, 0], [0, 0]]).is_zero assert PropertiesOnlyMatrix(zeros(3, 4)).is_zero assert not PropertiesOnlyMatrix(eye(3)).is_zero assert PropertiesOnlyMatrix([[x, 0], [0, 0]]).is_zero == None assert PropertiesOnlyMatrix([[x, 1], [0, 0]]).is_zero == False a = Symbol('a', nonzero=True) assert PropertiesOnlyMatrix([[a, 0], [0, 0]]).is_zero == False def test_values(): assert set(PropertiesOnlyMatrix(2, 2, [0, 1, 2, 3] ).values()) == set([1, 2, 3]) x = Symbol('x', real=True) assert set(PropertiesOnlyMatrix(2, 2, [x, 0, 0, 1] ).values()) == set([x, 1]) # OperationsOnlyMatrix tests def test_applyfunc(): m0 = OperationsOnlyMatrix(eye(3)) assert m0.applyfunc(lambda x: 2*x) == eye(3)*2 assert m0.applyfunc(lambda x: 0) == zeros(3) assert m0.applyfunc(lambda x: 1) == ones(3) def test_adjoint(): dat = [[0, I], [1, 0]] ans = OperationsOnlyMatrix([[0, 1], [-I, 0]]) assert ans.adjoint() == Matrix(dat) def test_as_real_imag(): m1 = OperationsOnlyMatrix(2, 2, [1, 2, 3, 4]) m3 = OperationsOnlyMatrix(2, 2, [1 + S.ImaginaryUnit, 2 + 2*S.ImaginaryUnit, 3 + 3*S.ImaginaryUnit, 4 + 4*S.ImaginaryUnit]) a, b = m3.as_real_imag() assert a == m1 assert b == m1 def test_conjugate(): M = OperationsOnlyMatrix([[0, I, 5], [1, 2, 0]]) assert M.T == Matrix([[0, 1], [I, 2], [5, 0]]) assert M.C == Matrix([[0, -I, 5], [1, 2, 0]]) assert M.C == M.conjugate() assert M.H == M.T.C assert M.H == Matrix([[ 0, 1], [-I, 2], [ 5, 0]]) def test_doit(): a = OperationsOnlyMatrix([[Add(x, x, evaluate=False)]]) assert a[0] != 2*x assert a.doit() == Matrix([[2*x]]) def test_evalf(): a = OperationsOnlyMatrix(2, 1, [sqrt(5), 6]) assert all(a.evalf()[i] == a[i].evalf() for i in range(2)) assert all(a.evalf(2)[i] == a[i].evalf(2) for i in range(2)) assert all(a.n(2)[i] == a[i].n(2) for i in range(2)) def test_expand(): m0 = OperationsOnlyMatrix([[x*(x + y), 2], [((x + y)*y)*x, x*(y + x*(x + y))]]) # Test if expand() returns a matrix m1 = m0.expand() assert m1 == Matrix( [[x*y + x**2, 2], [x*y**2 + y*x**2, x*y + y*x**2 + x**3]]) a = Symbol('a', real=True) assert OperationsOnlyMatrix(1, 1, [exp(I*a)]).expand(complex=True) == \ Matrix([cos(a) + I*sin(a)]) def test_refine(): m0 = OperationsOnlyMatrix([[Abs(x)**2, sqrt(x**2)], [sqrt(x**2)*Abs(y)**2, sqrt(y**2)*Abs(x)**2]]) m1 = m0.refine(Q.real(x) & Q.real(y)) assert m1 == Matrix([[x**2, Abs(x)], [y**2*Abs(x), x**2*Abs(y)]]) m1 = m0.refine(Q.positive(x) & Q.positive(y)) assert m1 == Matrix([[x**2, x], [x*y**2, x**2*y]]) m1 = m0.refine(Q.negative(x) & Q.negative(y)) assert m1 == Matrix([[x**2, -x], [-x*y**2, -x**2*y]]) def test_replace(): F, G = symbols('F, G', cls=Function) K = OperationsOnlyMatrix(2, 2, lambda i, j: G(i+j)) M = OperationsOnlyMatrix(2, 2, lambda i, j: F(i+j)) N = M.replace(F, G) assert N == K def test_replace_map(): F, G = symbols('F, G', cls=Function) K = OperationsOnlyMatrix(2, 2, [(G(0), {F(0): G(0)}), (G(1), {F(1): G(1)}), (G(1), {F(1) \ : G(1)}), (G(2), {F(2): G(2)})]) M = OperationsOnlyMatrix(2, 2, lambda i, j: F(i+j)) N = M.replace(F, G, True) assert N == K def test_simplify(): n = Symbol('n') f = Function('f') M = OperationsOnlyMatrix([[ 1/x + 1/y, (x + x*y) / x ], [ (f(x) + y*f(x))/f(x), 2 * (1/n - cos(n * pi)/n) / pi ]]) assert M.simplify() == Matrix([[ (x + y)/(x * y), 1 + y ], [ 1 + y, 2*((1 - 1*cos(pi*n))/(pi*n)) ]]) eq = (1 + x)**2 M = OperationsOnlyMatrix([[eq]]) assert M.simplify() == Matrix([[eq]]) assert M.simplify(ratio=oo) == Matrix([[eq.simplify(ratio=oo)]]) def test_subs(): assert OperationsOnlyMatrix([[1, x], [x, 4]]).subs(x, 5) == Matrix([[1, 5], [5, 4]]) assert OperationsOnlyMatrix([[x, 2], [x + y, 4]]).subs([[x, -1], [y, -2]]) == \ Matrix([[-1, 2], [-3, 4]]) assert OperationsOnlyMatrix([[x, 2], [x + y, 4]]).subs([(x, -1), (y, -2)]) == \ Matrix([[-1, 2], [-3, 4]]) assert OperationsOnlyMatrix([[x, 2], [x + y, 4]]).subs({x: -1, y: -2}) == \ Matrix([[-1, 2], [-3, 4]]) assert OperationsOnlyMatrix([[x*y]]).subs({x: y - 1, y: x - 1}, simultaneous=True) == \ Matrix([[(x - 1)*(y - 1)]]) def test_trace(): M = OperationsOnlyMatrix([[1, 0, 0], [0, 5, 0], [0, 0, 8]]) assert M.trace() == 14 def test_xreplace(): assert OperationsOnlyMatrix([[1, x], [x, 4]]).xreplace({x: 5}) == \ Matrix([[1, 5], [5, 4]]) assert OperationsOnlyMatrix([[x, 2], [x + y, 4]]).xreplace({x: -1, y: -2}) == \ Matrix([[-1, 2], [-3, 4]]) def test_permute(): a = OperationsOnlyMatrix(3, 4, [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]) raises(IndexError, lambda: a.permute([[0, 5]])) b = a.permute_rows([[0, 2], [0, 1]]) assert a.permute([[0, 2], [0, 1]]) == b == Matrix([ [5, 6, 7, 8], [9, 10, 11, 12], [1, 2, 3, 4]]) b = a.permute_cols([[0, 2], [0, 1]]) assert a.permute([[0, 2], [0, 1]], orientation='cols') == b ==\ Matrix([ [ 2, 3, 1, 4], [ 6, 7, 5, 8], [10, 11, 9, 12]]) b = a.permute_cols([[0, 2], [0, 1]], direction='backward') assert a.permute([[0, 2], [0, 1]], orientation='cols', direction='backward') == b ==\ Matrix([ [ 3, 1, 2, 4], [ 7, 5, 6, 8], [11, 9, 10, 12]]) assert a.permute([1, 2, 0, 3]) == Matrix([ [5, 6, 7, 8], [9, 10, 11, 12], [1, 2, 3, 4]]) from sympy.combinatorics import Permutation assert a.permute(Permutation([1, 2, 0, 3])) == Matrix([ [5, 6, 7, 8], [9, 10, 11, 12], [1, 2, 3, 4]]) # ArithmeticOnlyMatrix tests def test_abs(): m = ArithmeticOnlyMatrix([[1, -2], [x, y]]) assert abs(m) == ArithmeticOnlyMatrix([[1, 2], [Abs(x), Abs(y)]]) def test_add(): m = ArithmeticOnlyMatrix([[1, 2, 3], [x, y, x], [2*y, -50, z*x]]) assert m + m == ArithmeticOnlyMatrix([[2, 4, 6], [2*x, 2*y, 2*x], [4*y, -100, 2*z*x]]) n = ArithmeticOnlyMatrix(1, 2, [1, 2]) raises(ShapeError, lambda: m + n) def test_multiplication(): a = ArithmeticOnlyMatrix(( (1, 2), (3, 1), (0, 6), )) b = ArithmeticOnlyMatrix(( (1, 2), (3, 0), )) raises(ShapeError, lambda: b*a) raises(TypeError, lambda: a*{}) c = a*b assert c[0, 0] == 7 assert c[0, 1] == 2 assert c[1, 0] == 6 assert c[1, 1] == 6 assert c[2, 0] == 18 assert c[2, 1] == 0 try: eval('c = a @ b') except SyntaxError: pass else: assert c[0, 0] == 7 assert c[0, 1] == 2 assert c[1, 0] == 6 assert c[1, 1] == 6 assert c[2, 0] == 18 assert c[2, 1] == 0 h = a.multiply_elementwise(c) assert h == matrix_multiply_elementwise(a, c) assert h[0, 0] == 7 assert h[0, 1] == 4 assert h[1, 0] == 18 assert h[1, 1] == 6 assert h[2, 0] == 0 assert h[2, 1] == 0 raises(ShapeError, lambda: a.multiply_elementwise(b)) c = b * Symbol("x") assert isinstance(c, ArithmeticOnlyMatrix) assert c[0, 0] == x assert c[0, 1] == 2*x assert c[1, 0] == 3*x assert c[1, 1] == 0 c2 = x * b assert c == c2 c = 5 * b assert isinstance(c, ArithmeticOnlyMatrix) assert c[0, 0] == 5 assert c[0, 1] == 2*5 assert c[1, 0] == 3*5 assert c[1, 1] == 0 try: eval('c = 5 @ b') except SyntaxError: pass else: assert isinstance(c, ArithmeticOnlyMatrix) assert c[0, 0] == 5 assert c[0, 1] == 2*5 assert c[1, 0] == 3*5 assert c[1, 1] == 0 def test_matmul(): a = Matrix([[1, 2], [3, 4]]) assert a.__matmul__(2) == NotImplemented assert a.__rmatmul__(2) == NotImplemented #This is done this way because @ is only supported in Python 3.5+ #To check 2@a case try: eval('2 @ a') except SyntaxError: pass except TypeError: #TypeError is raised in case of NotImplemented is returned pass #Check a@2 case try: eval('a @ 2') except SyntaxError: pass except TypeError: #TypeError is raised in case of NotImplemented is returned pass def test_power(): raises(NonSquareMatrixError, lambda: Matrix((1, 2))**2) A = ArithmeticOnlyMatrix([[2, 3], [4, 5]]) assert (A**5)[:] == (6140, 8097, 10796, 14237) A = ArithmeticOnlyMatrix([[2, 1, 3], [4, 2, 4], [6, 12, 1]]) assert (A**3)[:] == (290, 262, 251, 448, 440, 368, 702, 954, 433) assert A**0 == eye(3) assert A**1 == A assert (ArithmeticOnlyMatrix([[2]]) ** 100)[0, 0] == 2**100 assert ArithmeticOnlyMatrix([[1, 2], [3, 4]])**Integer(2) == ArithmeticOnlyMatrix([[7, 10], [15, 22]]) def test_neg(): n = ArithmeticOnlyMatrix(1, 2, [1, 2]) assert -n == ArithmeticOnlyMatrix(1, 2, [-1, -2]) def test_sub(): n = ArithmeticOnlyMatrix(1, 2, [1, 2]) assert n - n == ArithmeticOnlyMatrix(1, 2, [0, 0]) def test_div(): n = ArithmeticOnlyMatrix(1, 2, [1, 2]) assert n/2 == ArithmeticOnlyMatrix(1, 2, [S(1)/2, S(2)/2]) # DeterminantOnlyMatrix tests def test_det(): a = DeterminantOnlyMatrix(2, 3, [1, 2, 3, 4, 5, 6]) raises(NonSquareMatrixError, lambda: a.det()) z = zeros_Determinant(2) ey = eye_Determinant(2) assert z.det() == 0 assert ey.det() == 1 x = Symbol('x') a = DeterminantOnlyMatrix(0, 0, []) b = DeterminantOnlyMatrix(1, 1, [5]) c = DeterminantOnlyMatrix(2, 2, [1, 2, 3, 4]) d = DeterminantOnlyMatrix(3, 3, [1, 2, 3, 4, 5, 6, 7, 8, 8]) e = DeterminantOnlyMatrix(4, 4, [x, 1, 2, 3, 4, 5, 6, 7, 2, 9, 10, 11, 12, 13, 14, 14]) # the method keyword for `det` doesn't kick in until 4x4 matrices, # so there is no need to test all methods on smaller ones assert a.det() == 1 assert b.det() == 5 assert c.det() == -2 assert d.det() == 3 assert e.det() == 4*x - 24 assert e.det(method='bareiss') == 4*x - 24 assert e.det(method='berkowitz') == 4*x - 24 raises(ValueError, lambda: e.det(iszerofunc="test")) def test_adjugate(): x = Symbol('x') e = DeterminantOnlyMatrix(4, 4, [x, 1, 2, 3, 4, 5, 6, 7, 2, 9, 10, 11, 12, 13, 14, 14]) adj = Matrix([ [ 4, -8, 4, 0], [ 76, -14*x - 68, 14*x - 8, -4*x + 24], [-122, 17*x + 142, -21*x + 4, 8*x - 48], [ 48, -4*x - 72, 8*x, -4*x + 24]]) assert e.adjugate() == adj assert e.adjugate(method='bareiss') == adj assert e.adjugate(method='berkowitz') == adj a = DeterminantOnlyMatrix(2, 3, [1, 2, 3, 4, 5, 6]) raises(NonSquareMatrixError, lambda: a.adjugate()) def test_cofactor_and_minors(): x = Symbol('x') e = DeterminantOnlyMatrix(4, 4, [x, 1, 2, 3, 4, 5, 6, 7, 2, 9, 10, 11, 12, 13, 14, 14]) m = Matrix([ [ x, 1, 3], [ 2, 9, 11], [12, 13, 14]]) cm = Matrix([ [ 4, 76, -122, 48], [-8, -14*x - 68, 17*x + 142, -4*x - 72], [ 4, 14*x - 8, -21*x + 4, 8*x], [ 0, -4*x + 24, 8*x - 48, -4*x + 24]]) sub = Matrix([ [x, 1, 2], [4, 5, 6], [2, 9, 10]]) assert e.minor_submatrix(1, 2) == m assert e.minor_submatrix(-1, -1) == sub assert e.minor(1, 2) == -17*x - 142 assert e.cofactor(1, 2) == 17*x + 142 assert e.cofactor_matrix() == cm assert e.cofactor_matrix(method="bareiss") == cm assert e.cofactor_matrix(method="berkowitz") == cm raises(ValueError, lambda: e.cofactor(4, 5)) raises(ValueError, lambda: e.minor(4, 5)) raises(ValueError, lambda: e.minor_submatrix(4, 5)) a = DeterminantOnlyMatrix(2, 3, [1, 2, 3, 4, 5, 6]) assert a.minor_submatrix(0, 0) == Matrix([[5, 6]]) raises(ValueError, lambda: DeterminantOnlyMatrix(0, 0, []).minor_submatrix(0, 0)) raises(NonSquareMatrixError, lambda: a.cofactor(0, 0)) raises(NonSquareMatrixError, lambda: a.minor(0, 0)) raises(NonSquareMatrixError, lambda: a.cofactor_matrix()) def test_charpoly(): x, y = Symbol('x'), Symbol('y') m = DeterminantOnlyMatrix(3, 3, [1, 2, 3, 4, 5, 6, 7, 8, 9]) assert eye_Determinant(3).charpoly(x) == Poly((x - 1)**3, x) assert eye_Determinant(3).charpoly(y) == Poly((y - 1)**3, y) assert m.charpoly() == Poly(x**3 - 15*x**2 - 18*x, x) raises(NonSquareMatrixError, lambda: Matrix([[1], [2]]).charpoly()) # ReductionsOnlyMatrix tests def test_row_op(): e = eye_Reductions(3) raises(ValueError, lambda: e.elementary_row_op("abc")) raises(ValueError, lambda: e.elementary_row_op()) raises(ValueError, lambda: e.elementary_row_op('n->kn', row=5, k=5)) raises(ValueError, lambda: e.elementary_row_op('n->kn', row=-5, k=5)) raises(ValueError, lambda: e.elementary_row_op('n<->m', row1=1, row2=5)) raises(ValueError, lambda: e.elementary_row_op('n<->m', row1=5, row2=1)) raises(ValueError, lambda: e.elementary_row_op('n<->m', row1=-5, row2=1)) raises(ValueError, lambda: e.elementary_row_op('n<->m', row1=1, row2=-5)) raises(ValueError, lambda: e.elementary_row_op('n->n+km', row1=1, row2=5, k=5)) raises(ValueError, lambda: e.elementary_row_op('n->n+km', row1=5, row2=1, k=5)) raises(ValueError, lambda: e.elementary_row_op('n->n+km', row1=-5, row2=1, k=5)) raises(ValueError, lambda: e.elementary_row_op('n->n+km', row1=1, row2=-5, k=5)) raises(ValueError, lambda: e.elementary_row_op('n->n+km', row1=1, row2=1, k=5)) # test various ways to set arguments assert e.elementary_row_op("n->kn", 0, 5) == Matrix([[5, 0, 0], [0, 1, 0], [0, 0, 1]]) assert e.elementary_row_op("n->kn", 1, 5) == Matrix([[1, 0, 0], [0, 5, 0], [0, 0, 1]]) assert e.elementary_row_op("n->kn", row=1, k=5) == Matrix([[1, 0, 0], [0, 5, 0], [0, 0, 1]]) assert e.elementary_row_op("n->kn", row1=1, k=5) == Matrix([[1, 0, 0], [0, 5, 0], [0, 0, 1]]) assert e.elementary_row_op("n<->m", 0, 1) == Matrix([[0, 1, 0], [1, 0, 0], [0, 0, 1]]) assert e.elementary_row_op("n<->m", row1=0, row2=1) == Matrix([[0, 1, 0], [1, 0, 0], [0, 0, 1]]) assert e.elementary_row_op("n<->m", row=0, row2=1) == Matrix([[0, 1, 0], [1, 0, 0], [0, 0, 1]]) assert e.elementary_row_op("n->n+km", 0, 5, 1) == Matrix([[1, 5, 0], [0, 1, 0], [0, 0, 1]]) assert e.elementary_row_op("n->n+km", row=0, k=5, row2=1) == Matrix([[1, 5, 0], [0, 1, 0], [0, 0, 1]]) assert e.elementary_row_op("n->n+km", row1=0, k=5, row2=1) == Matrix([[1, 5, 0], [0, 1, 0], [0, 0, 1]]) # make sure the matrix doesn't change size a = ReductionsOnlyMatrix(2, 3, [0]*6) assert a.elementary_row_op("n->kn", 1, 5) == Matrix(2, 3, [0]*6) assert a.elementary_row_op("n<->m", 0, 1) == Matrix(2, 3, [0]*6) assert a.elementary_row_op("n->n+km", 0, 5, 1) == Matrix(2, 3, [0]*6) def test_col_op(): e = eye_Reductions(3) raises(ValueError, lambda: e.elementary_col_op("abc")) raises(ValueError, lambda: e.elementary_col_op()) raises(ValueError, lambda: e.elementary_col_op('n->kn', col=5, k=5)) raises(ValueError, lambda: e.elementary_col_op('n->kn', col=-5, k=5)) raises(ValueError, lambda: e.elementary_col_op('n<->m', col1=1, col2=5)) raises(ValueError, lambda: e.elementary_col_op('n<->m', col1=5, col2=1)) raises(ValueError, lambda: e.elementary_col_op('n<->m', col1=-5, col2=1)) raises(ValueError, lambda: e.elementary_col_op('n<->m', col1=1, col2=-5)) raises(ValueError, lambda: e.elementary_col_op('n->n+km', col1=1, col2=5, k=5)) raises(ValueError, lambda: e.elementary_col_op('n->n+km', col1=5, col2=1, k=5)) raises(ValueError, lambda: e.elementary_col_op('n->n+km', col1=-5, col2=1, k=5)) raises(ValueError, lambda: e.elementary_col_op('n->n+km', col1=1, col2=-5, k=5)) raises(ValueError, lambda: e.elementary_col_op('n->n+km', col1=1, col2=1, k=5)) # test various ways to set arguments assert e.elementary_col_op("n->kn", 0, 5) == Matrix([[5, 0, 0], [0, 1, 0], [0, 0, 1]]) assert e.elementary_col_op("n->kn", 1, 5) == Matrix([[1, 0, 0], [0, 5, 0], [0, 0, 1]]) assert e.elementary_col_op("n->kn", col=1, k=5) == Matrix([[1, 0, 0], [0, 5, 0], [0, 0, 1]]) assert e.elementary_col_op("n->kn", col1=1, k=5) == Matrix([[1, 0, 0], [0, 5, 0], [0, 0, 1]]) assert e.elementary_col_op("n<->m", 0, 1) == Matrix([[0, 1, 0], [1, 0, 0], [0, 0, 1]]) assert e.elementary_col_op("n<->m", col1=0, col2=1) == Matrix([[0, 1, 0], [1, 0, 0], [0, 0, 1]]) assert e.elementary_col_op("n<->m", col=0, col2=1) == Matrix([[0, 1, 0], [1, 0, 0], [0, 0, 1]]) assert e.elementary_col_op("n->n+km", 0, 5, 1) == Matrix([[1, 0, 0], [5, 1, 0], [0, 0, 1]]) assert e.elementary_col_op("n->n+km", col=0, k=5, col2=1) == Matrix([[1, 0, 0], [5, 1, 0], [0, 0, 1]]) assert e.elementary_col_op("n->n+km", col1=0, k=5, col2=1) == Matrix([[1, 0, 0], [5, 1, 0], [0, 0, 1]]) # make sure the matrix doesn't change size a = ReductionsOnlyMatrix(2, 3, [0]*6) assert a.elementary_col_op("n->kn", 1, 5) == Matrix(2, 3, [0]*6) assert a.elementary_col_op("n<->m", 0, 1) == Matrix(2, 3, [0]*6) assert a.elementary_col_op("n->n+km", 0, 5, 1) == Matrix(2, 3, [0]*6) def test_is_echelon(): zro = zeros_Reductions(3) ident = eye_Reductions(3) assert zro.is_echelon assert ident.is_echelon a = ReductionsOnlyMatrix(0, 0, []) assert a.is_echelon a = ReductionsOnlyMatrix(2, 3, [3, 2, 1, 0, 0, 6]) assert a.is_echelon a = ReductionsOnlyMatrix(2, 3, [0, 0, 6, 3, 2, 1]) assert not a.is_echelon x = Symbol('x') a = ReductionsOnlyMatrix(3, 1, [x, 0, 0]) assert a.is_echelon a = ReductionsOnlyMatrix(3, 1, [x, x, 0]) assert not a.is_echelon a = ReductionsOnlyMatrix(3, 3, [0, 0, 0, 1, 2, 3, 0, 0, 0]) assert not a.is_echelon def test_echelon_form(): # echelon form is not unique, but the result # must be row-equivalent to the original matrix # and it must be in echelon form. a = zeros_Reductions(3) e = eye_Reductions(3) # we can assume the zero matrix and the identity matrix shouldn't change assert a.echelon_form() == a assert e.echelon_form() == e a = ReductionsOnlyMatrix(0, 0, []) assert a.echelon_form() == a a = ReductionsOnlyMatrix(1, 1, [5]) assert a.echelon_form() == a # now we get to the real tests def verify_row_null_space(mat, rows, nulls): for v in nulls: assert all(t.is_zero for t in a_echelon*v) for v in rows: if not all(t.is_zero for t in v): assert not all(t.is_zero for t in a_echelon*v.transpose()) a = ReductionsOnlyMatrix(3, 3, [1, 2, 3, 4, 5, 6, 7, 8, 9]) nulls = [Matrix([ [ 1], [-2], [ 1]])] rows = [a[i, :] for i in range(a.rows)] a_echelon = a.echelon_form() assert a_echelon.is_echelon verify_row_null_space(a, rows, nulls) a = ReductionsOnlyMatrix(3, 3, [1, 2, 3, 4, 5, 6, 7, 8, 8]) nulls = [] rows = [a[i, :] for i in range(a.rows)] a_echelon = a.echelon_form() assert a_echelon.is_echelon verify_row_null_space(a, rows, nulls) a = ReductionsOnlyMatrix(3, 3, [2, 1, 3, 0, 0, 0, 2, 1, 3]) nulls = [Matrix([ [-S(1)/2], [ 1], [ 0]]), Matrix([ [-S(3)/2], [ 0], [ 1]])] rows = [a[i, :] for i in range(a.rows)] a_echelon = a.echelon_form() assert a_echelon.is_echelon verify_row_null_space(a, rows, nulls) # this one requires a row swap a = ReductionsOnlyMatrix(3, 3, [2, 1, 3, 0, 0, 0, 1, 1, 3]) nulls = [Matrix([ [ 0], [ -3], [ 1]])] rows = [a[i, :] for i in range(a.rows)] a_echelon = a.echelon_form() assert a_echelon.is_echelon verify_row_null_space(a, rows, nulls) a = ReductionsOnlyMatrix(3, 3, [0, 3, 3, 0, 2, 2, 0, 1, 1]) nulls = [Matrix([ [1], [0], [0]]), Matrix([ [ 0], [-1], [ 1]])] rows = [a[i, :] for i in range(a.rows)] a_echelon = a.echelon_form() assert a_echelon.is_echelon verify_row_null_space(a, rows, nulls) a = ReductionsOnlyMatrix(2, 3, [2, 2, 3, 3, 3, 0]) nulls = [Matrix([ [-1], [1], [0]])] rows = [a[i, :] for i in range(a.rows)] a_echelon = a.echelon_form() assert a_echelon.is_echelon verify_row_null_space(a, rows, nulls) def test_rref(): e = ReductionsOnlyMatrix(0, 0, []) assert e.rref(pivots=False) == e e = ReductionsOnlyMatrix(1, 1, [1]) a = ReductionsOnlyMatrix(1, 1, [5]) assert e.rref(pivots=False) == a.rref(pivots=False) == e a = ReductionsOnlyMatrix(3, 1, [1, 2, 3]) assert a.rref(pivots=False) == Matrix([[1], [0], [0]]) a = ReductionsOnlyMatrix(1, 3, [1, 2, 3]) assert a.rref(pivots=False) == Matrix([[1, 2, 3]]) a = ReductionsOnlyMatrix(3, 3, [1, 2, 3, 4, 5, 6, 7, 8, 9]) assert a.rref(pivots=False) == Matrix([ [1, 0, -1], [0, 1, 2], [0, 0, 0]]) a = ReductionsOnlyMatrix(3, 3, [1, 2, 3, 1, 2, 3, 1, 2, 3]) b = ReductionsOnlyMatrix(3, 3, [1, 2, 3, 0, 0, 0, 0, 0, 0]) c = ReductionsOnlyMatrix(3, 3, [0, 0, 0, 1, 2, 3, 0, 0, 0]) d = ReductionsOnlyMatrix(3, 3, [0, 0, 0, 0, 0, 0, 1, 2, 3]) assert a.rref(pivots=False) == \ b.rref(pivots=False) == \ c.rref(pivots=False) == \ d.rref(pivots=False) == b e = eye_Reductions(3) z = zeros_Reductions(3) assert e.rref(pivots=False) == e assert z.rref(pivots=False) == z a = ReductionsOnlyMatrix([ [ 0, 0, 1, 2, 2, -5, 3], [-1, 5, 2, 2, 1, -7, 5], [ 0, 0, -2, -3, -3, 8, -5], [-1, 5, 0, -1, -2, 1, 0]]) mat, pivot_offsets = a.rref() assert mat == Matrix([ [1, -5, 0, 0, 1, 1, -1], [0, 0, 1, 0, 0, -1, 1], [0, 0, 0, 1, 1, -2, 1], [0, 0, 0, 0, 0, 0, 0]]) assert pivot_offsets == (0, 2, 3) a = ReductionsOnlyMatrix([[S(1)/19, S(1)/5, 2, 3], [ 4, 5, 6, 7], [ 8, 9, 10, 11], [ 12, 13, 14, 15]]) assert a.rref(pivots=False) == Matrix([ [1, 0, 0, -S(76)/157], [0, 1, 0, -S(5)/157], [0, 0, 1, S(238)/157], [0, 0, 0, 0]]) x = Symbol('x') a = ReductionsOnlyMatrix(2, 3, [x, 1, 1, sqrt(x), x, 1]) for i, j in zip(a.rref(pivots=False), [1, 0, sqrt(x)*(-x + 1)/(-x**(S(5)/2) + x), 0, 1, 1/(sqrt(x) + x + 1)]): assert simplify(i - j).is_zero # SpecialOnlyMatrix tests def test_eye(): assert list(SpecialOnlyMatrix.eye(2, 2)) == [1, 0, 0, 1] assert list(SpecialOnlyMatrix.eye(2)) == [1, 0, 0, 1] assert type(SpecialOnlyMatrix.eye(2)) == SpecialOnlyMatrix assert type(SpecialOnlyMatrix.eye(2, cls=Matrix)) == Matrix def test_ones(): assert list(SpecialOnlyMatrix.ones(2, 2)) == [1, 1, 1, 1] assert list(SpecialOnlyMatrix.ones(2)) == [1, 1, 1, 1] assert SpecialOnlyMatrix.ones(2, 3) == Matrix([[1, 1, 1], [1, 1, 1]]) assert type(SpecialOnlyMatrix.ones(2)) == SpecialOnlyMatrix assert type(SpecialOnlyMatrix.ones(2, cls=Matrix)) == Matrix def test_zeros(): assert list(SpecialOnlyMatrix.zeros(2, 2)) == [0, 0, 0, 0] assert list(SpecialOnlyMatrix.zeros(2)) == [0, 0, 0, 0] assert SpecialOnlyMatrix.zeros(2, 3) == Matrix([[0, 0, 0], [0, 0, 0]]) assert type(SpecialOnlyMatrix.zeros(2)) == SpecialOnlyMatrix assert type(SpecialOnlyMatrix.zeros(2, cls=Matrix)) == Matrix def test_diag_make(): diag = SpecialOnlyMatrix.diag a = Matrix([[1, 2], [2, 3]]) b = Matrix([[3, x], [y, 3]]) c = Matrix([[3, x, 3], [y, 3, z], [x, y, z]]) assert diag(a, b, b) == Matrix([ [1, 2, 0, 0, 0, 0], [2, 3, 0, 0, 0, 0], [0, 0, 3, x, 0, 0], [0, 0, y, 3, 0, 0], [0, 0, 0, 0, 3, x], [0, 0, 0, 0, y, 3], ]) assert diag(a, b, c) == Matrix([ [1, 2, 0, 0, 0, 0, 0], [2, 3, 0, 0, 0, 0, 0], [0, 0, 3, x, 0, 0, 0], [0, 0, y, 3, 0, 0, 0], [0, 0, 0, 0, 3, x, 3], [0, 0, 0, 0, y, 3, z], [0, 0, 0, 0, x, y, z], ]) assert diag(a, c, b) == Matrix([ [1, 2, 0, 0, 0, 0, 0], [2, 3, 0, 0, 0, 0, 0], [0, 0, 3, x, 3, 0, 0], [0, 0, y, 3, z, 0, 0], [0, 0, x, y, z, 0, 0], [0, 0, 0, 0, 0, 3, x], [0, 0, 0, 0, 0, y, 3], ]) a = Matrix([x, y, z]) b = Matrix([[1, 2], [3, 4]]) c = Matrix([[5, 6]]) # this "wandering diagonal" is what makes this # a block diagonal where each block is independent # of the others assert diag(a, 7, b, c) == Matrix([ [x, 0, 0, 0, 0, 0], [y, 0, 0, 0, 0, 0], [z, 0, 0, 0, 0, 0], [0, 7, 0, 0, 0, 0], [0, 0, 1, 2, 0, 0], [0, 0, 3, 4, 0, 0], [0, 0, 0, 0, 5, 6]]) raises(ValueError, lambda: diag(a, 7, b, c, rows=5)) assert diag(1) == Matrix([[1]]) assert diag(1, rows=2) == Matrix([[1, 0], [0, 0]]) assert diag(1, cols=2) == Matrix([[1, 0], [0, 0]]) assert diag(1, rows=3, cols=2) == Matrix([[1, 0], [0, 0], [0, 0]]) assert diag(*[2, 3]) == Matrix([ [2, 0], [0, 3]]) assert diag(Matrix([2, 3])) == Matrix([ [2], [3]]) assert diag([1, [2, 3], 4], unpack=False) == \ diag([[1], [2, 3], [4]], unpack=False) == Matrix([ [1, 0], [2, 3], [4, 0]]) assert type(diag(1)) == SpecialOnlyMatrix assert type(diag(1, cls=Matrix)) == Matrix assert Matrix.diag([1, 2, 3]) == Matrix.diag(1, 2, 3) assert Matrix.diag([1, 2, 3], unpack=False).shape == (3, 1) assert Matrix.diag([[1, 2, 3]]).shape == (3, 1) assert Matrix.diag([[1, 2, 3]], unpack=False).shape == (1, 3) assert Matrix.diag([[[1, 2, 3]]]).shape == (1, 3) # kerning can be used to move the starting point assert Matrix.diag(ones(0, 2), 1, 2) == Matrix([ [0, 0, 1, 0], [0, 0, 0, 2]]) assert Matrix.diag(ones(2, 0), 1, 2) == Matrix([ [0, 0], [0, 0], [1, 0], [0, 2]]) def test_diagonal(): m = Matrix(3, 3, range(9)) d = m.diagonal() assert d == m.diagonal(0) assert tuple(d) == (0, 4, 8) assert tuple(m.diagonal(1)) == (1, 5) assert tuple(m.diagonal(-1)) == (3, 7) assert tuple(m.diagonal(2)) == (2,) assert type(m.diagonal()) == type(m) s = SparseMatrix(3, 3, {(1, 1): 1}) assert type(s.diagonal()) == type(s) assert type(m) != type(s) raises(ValueError, lambda: m.diagonal(3)) raises(ValueError, lambda: m.diagonal(-3)) raises(ValueError, lambda: m.diagonal(pi)) def test_jordan_block(): assert SpecialOnlyMatrix.jordan_block(3, 2) == SpecialOnlyMatrix.jordan_block(3, eigenvalue=2) \ == SpecialOnlyMatrix.jordan_block(size=3, eigenvalue=2) \ == SpecialOnlyMatrix.jordan_block(3, 2, band='upper') \ == SpecialOnlyMatrix.jordan_block( size=3, eigenval=2, eigenvalue=2) \ == Matrix([ [2, 1, 0], [0, 2, 1], [0, 0, 2]]) assert SpecialOnlyMatrix.jordan_block(3, 2, band='lower') == Matrix([ [2, 0, 0], [1, 2, 0], [0, 1, 2]]) # missing eigenvalue raises(ValueError, lambda: SpecialOnlyMatrix.jordan_block(2)) # non-integral size raises(ValueError, lambda: SpecialOnlyMatrix.jordan_block(3.5, 2)) # size not specified raises(ValueError, lambda: SpecialOnlyMatrix.jordan_block(eigenvalue=2)) # inconsistent eigenvalue raises(ValueError, lambda: SpecialOnlyMatrix.jordan_block( eigenvalue=2, eigenval=4)) # Deprecated feature with warns_deprecated_sympy(): assert (SpecialOnlyMatrix.jordan_block(cols=3, eigenvalue=2) == SpecialOnlyMatrix(3, 3, (2, 1, 0, 0, 2, 1, 0, 0, 2))) with warns_deprecated_sympy(): assert (SpecialOnlyMatrix.jordan_block(rows=3, eigenvalue=2) == SpecialOnlyMatrix(3, 3, (2, 1, 0, 0, 2, 1, 0, 0, 2))) with warns_deprecated_sympy(): assert SpecialOnlyMatrix.jordan_block(3, 2) == \ SpecialOnlyMatrix.jordan_block(cols=3, eigenvalue=2) == \ SpecialOnlyMatrix.jordan_block(rows=3, eigenvalue=2) with warns_deprecated_sympy(): assert SpecialOnlyMatrix.jordan_block( rows=4, cols=3, eigenvalue=2) == \ Matrix([ [2, 1, 0], [0, 2, 1], [0, 0, 2], [0, 0, 0]]) # Using alias keyword assert SpecialOnlyMatrix.jordan_block(size=3, eigenvalue=2) == \ SpecialOnlyMatrix.jordan_block(size=3, eigenval=2) # SubspaceOnlyMatrix tests def test_columnspace(): m = SubspaceOnlyMatrix([[ 1, 2, 0, 2, 5], [-2, -5, 1, -1, -8], [ 0, -3, 3, 4, 1], [ 3, 6, 0, -7, 2]]) basis = m.columnspace() assert basis[0] == Matrix([1, -2, 0, 3]) assert basis[1] == Matrix([2, -5, -3, 6]) assert basis[2] == Matrix([2, -1, 4, -7]) assert len(basis) == 3 assert Matrix.hstack(m, *basis).columnspace() == basis def test_rowspace(): m = SubspaceOnlyMatrix([[ 1, 2, 0, 2, 5], [-2, -5, 1, -1, -8], [ 0, -3, 3, 4, 1], [ 3, 6, 0, -7, 2]]) basis = m.rowspace() assert basis[0] == Matrix([[1, 2, 0, 2, 5]]) assert basis[1] == Matrix([[0, -1, 1, 3, 2]]) assert basis[2] == Matrix([[0, 0, 0, 5, 5]]) assert len(basis) == 3 def test_nullspace(): m = SubspaceOnlyMatrix([[ 1, 2, 0, 2, 5], [-2, -5, 1, -1, -8], [ 0, -3, 3, 4, 1], [ 3, 6, 0, -7, 2]]) basis = m.nullspace() assert basis[0] == Matrix([-2, 1, 1, 0, 0]) assert basis[1] == Matrix([-1, -1, 0, -1, 1]) # make sure the null space is really gets zeroed assert all(e.is_zero for e in m*basis[0]) assert all(e.is_zero for e in m*basis[1]) def test_orthogonalize(): m = Matrix([[1, 2], [3, 4]]) assert m.orthogonalize(Matrix([[2], [1]])) == [Matrix([[2], [1]])] assert m.orthogonalize(Matrix([[2], [1]]), normalize=True) == \ [Matrix([[2*sqrt(5)/5], [sqrt(5)/5]])] assert m.orthogonalize(Matrix([[1], [2]]), Matrix([[-1], [4]])) == \ [Matrix([[1], [2]]), Matrix([[-S(12)/5], [S(6)/5]])] assert m.orthogonalize(Matrix([[0], [0]]), Matrix([[-1], [4]])) == \ [Matrix([[-1], [4]])] assert m.orthogonalize(Matrix([[0], [0]])) == [] n = Matrix([[9, 1, 9], [3, 6, 10], [8, 5, 2]]) vecs = [Matrix([[-5], [1]]), Matrix([[-5], [2]]), Matrix([[-5], [-2]])] assert n.orthogonalize(*vecs) == \ [Matrix([[-5], [1]]), Matrix([[S(5)/26], [S(25)/26]])] vecs = [Matrix([0, 0, 0]), Matrix([1, 2, 3]), Matrix([1, 4, 5])] raises(ValueError, lambda: Matrix.orthogonalize(*vecs, rankcheck=True)) vecs = [Matrix([1, 2, 3]), Matrix([4, 5, 6]), Matrix([7, 8, 9])] raises(ValueError, lambda: Matrix.orthogonalize(*vecs, rankcheck=True)) # EigenOnlyMatrix tests def test_eigenvals(): M = EigenOnlyMatrix([[0, 1, 1], [1, 0, 0], [1, 1, 1]]) assert M.eigenvals() == {2*S.One: 1, -S.One: 1, S.Zero: 1} # if we cannot factor the char poly, we raise an error m = Matrix([ [3, 0, 0, 0, -3], [0, -3, -3, 0, 3], [0, 3, 0, 3, 0], [0, 0, 3, 0, 3], [3, 0, 0, 3, 0]]) raises(MatrixError, lambda: m.eigenvals()) def test_eigenvects(): M = EigenOnlyMatrix([[0, 1, 1], [1, 0, 0], [1, 1, 1]]) vecs = M.eigenvects() for val, mult, vec_list in vecs: assert len(vec_list) == 1 assert M*vec_list[0] == val*vec_list[0] def test_left_eigenvects(): M = EigenOnlyMatrix([[0, 1, 1], [1, 0, 0], [1, 1, 1]]) vecs = M.left_eigenvects() for val, mult, vec_list in vecs: assert len(vec_list) == 1 assert vec_list[0]*M == val*vec_list[0] def test_diagonalize(): m = EigenOnlyMatrix(2, 2, [0, -1, 1, 0]) raises(MatrixError, lambda: m.diagonalize(reals_only=True)) P, D = m.diagonalize() assert D.is_diagonal() assert D == Matrix([ [-I, 0], [ 0, I]]) # make sure we use floats out if floats are passed in m = EigenOnlyMatrix(2, 2, [0, .5, .5, 0]) P, D = m.diagonalize() assert all(isinstance(e, Float) for e in D.values()) assert all(isinstance(e, Float) for e in P.values()) _, D2 = m.diagonalize(reals_only=True) assert D == D2 def test_is_diagonalizable(): a, b, c = symbols('a b c') m = EigenOnlyMatrix(2, 2, [a, c, c, b]) assert m.is_symmetric() assert m.is_diagonalizable() assert not EigenOnlyMatrix(2, 2, [1, 1, 0, 1]).is_diagonalizable() m = EigenOnlyMatrix(2, 2, [0, -1, 1, 0]) assert m.is_diagonalizable() assert not m.is_diagonalizable(reals_only=True) def test_jordan_form(): m = Matrix(3, 2, [-3, 1, -3, 20, 3, 10]) raises(NonSquareMatrixError, lambda: m.jordan_form()) # the next two tests test the cases where the old # algorithm failed due to the fact that the block structure can # *NOT* be determined from algebraic and geometric multiplicity alone # This can be seen most easily when one lets compute the J.c.f. of a matrix that # is in J.c.f already. m = EigenOnlyMatrix(4, 4, [2, 1, 0, 0, 0, 2, 1, 0, 0, 0, 2, 0, 0, 0, 0, 2 ]) P, J = m.jordan_form() assert m == J m = EigenOnlyMatrix(4, 4, [2, 1, 0, 0, 0, 2, 0, 0, 0, 0, 2, 1, 0, 0, 0, 2 ]) P, J = m.jordan_form() assert m == J A = Matrix([[ 2, 4, 1, 0], [-4, 2, 0, 1], [ 0, 0, 2, 4], [ 0, 0, -4, 2]]) P, J = A.jordan_form() assert simplify(P*J*P.inv()) == A assert EigenOnlyMatrix(1, 1, [1]).jordan_form() == ( Matrix([1]), Matrix([1])) assert EigenOnlyMatrix(1, 1, [1]).jordan_form( calc_transform=False) == Matrix([1]) # make sure if we cannot factor the characteristic polynomial, we raise an error m = Matrix([[3, 0, 0, 0, -3], [0, -3, -3, 0, 3], [0, 3, 0, 3, 0], [0, 0, 3, 0, 3], [3, 0, 0, 3, 0]]) raises(MatrixError, lambda: m.jordan_form()) # make sure that if the input has floats, the output does too m = Matrix([ [ 0.6875, 0.125 + 0.1875*sqrt(3)], [0.125 + 0.1875*sqrt(3), 0.3125]]) P, J = m.jordan_form() assert all(isinstance(x, Float) or x == 0 for x in P) assert all(isinstance(x, Float) or x == 0 for x in J) def test_singular_values(): x = Symbol('x', real=True) A = EigenOnlyMatrix([[0, 1*I], [2, 0]]) # if singular values can be sorted, they should be in decreasing order assert A.singular_values() == [2, 1] A = eye(3) A[1, 1] = x A[2, 2] = 5 vals = A.singular_values() # since Abs(x) cannot be sorted, test set equality assert set(vals) == set([5, 1, Abs(x)]) A = EigenOnlyMatrix([[sin(x), cos(x)], [-cos(x), sin(x)]]) vals = [sv.trigsimp() for sv in A.singular_values()] assert vals == [S(1), S(1)] A = EigenOnlyMatrix([ [2, 4], [1, 3], [0, 0], [0, 0] ]) assert A.singular_values() == \ [sqrt(sqrt(221) + 15), sqrt(15 - sqrt(221))] assert A.T.singular_values() == \ [sqrt(sqrt(221) + 15), sqrt(15 - sqrt(221)), 0, 0] # CalculusOnlyMatrix tests @XFAIL def test_diff(): x, y = symbols('x y') m = CalculusOnlyMatrix(2, 1, [x, y]) # TODO: currently not working as ``_MinimalMatrix`` cannot be sympified: assert m.diff(x) == Matrix(2, 1, [1, 0]) def test_integrate(): x, y = symbols('x y') m = CalculusOnlyMatrix(2, 1, [x, y]) assert m.integrate(x) == Matrix(2, 1, [x**2/2, y*x]) def test_jacobian2(): rho, phi = symbols("rho,phi") X = CalculusOnlyMatrix(3, 1, [rho*cos(phi), rho*sin(phi), rho**2]) Y = CalculusOnlyMatrix(2, 1, [rho, phi]) J = Matrix([ [cos(phi), -rho*sin(phi)], [sin(phi), rho*cos(phi)], [ 2*rho, 0], ]) assert X.jacobian(Y) == J m = CalculusOnlyMatrix(2, 2, [1, 2, 3, 4]) m2 = CalculusOnlyMatrix(4, 1, [1, 2, 3, 4]) raises(TypeError, lambda: m.jacobian(Matrix([1, 2]))) raises(TypeError, lambda: m2.jacobian(m)) def test_limit(): x, y = symbols('x y') m = CalculusOnlyMatrix(2, 1, [1/x, y]) assert m.limit(x, 5) == Matrix(2, 1, [S(1)/5, y]) def test_issue_13774(): M = Matrix([[1, 2, 3], [4, 5, 6], [7, 8, 9]]) v = [1, 1, 1] raises(TypeError, lambda: M*v) raises(TypeError, lambda: v*M) def test___eq__(): assert (EigenOnlyMatrix( [[0, 1, 1], [1, 0, 0], [1, 1, 1]]) == {}) is False
83d968d70a10bcb31e0a373992a04b58b122e90b7fd97ed7ff87fc9fa4bf2da2
from sympy.matrices.sparsetools import _doktocsr, _csrtodok, banded from sympy import eye, ones, zeros, Matrix, SparseMatrix from sympy.utilities.pytest import raises def test_doktocsr(): a = SparseMatrix([[1, 2, 0, 0], [0, 3, 9, 0], [0, 1, 4, 0]]) b = SparseMatrix(4, 6, [10, 20, 0, 0, 0, 0, 0, 30, 0, 40, 0, 0, 0, 0, 50, 60, 70, 0, 0, 0, 0, 0, 0, 80]) c = SparseMatrix(4, 4, [0, 0, 0, 0, 0, 12, 0, 2, 15, 0, 12, 0, 0, 0, 0, 4]) d = SparseMatrix(10, 10, {(1, 1): 12, (3, 5): 7, (7, 8): 12}) e = SparseMatrix([[0, 0, 0], [1, 0, 2], [3, 0, 0]]) f = SparseMatrix(7, 8, {(2, 3): 5, (4, 5):12}) assert _doktocsr(a) == [[1, 2, 3, 9, 1, 4], [0, 1, 1, 2, 1, 2], [0, 2, 4, 6], [3, 4]] assert _doktocsr(b) == [[10, 20, 30, 40, 50, 60, 70, 80], [0, 1, 1, 3, 2, 3, 4, 5], [0, 2, 4, 7, 8], [4, 6]] assert _doktocsr(c) == [[12, 2, 15, 12, 4], [1, 3, 0, 2, 3], [0, 0, 2, 4, 5], [4, 4]] assert _doktocsr(d) == [[12, 7, 12], [1, 5, 8], [0, 0, 1, 1, 2, 2, 2, 2, 3, 3, 3], [10, 10]] assert _doktocsr(e) == [[1, 2, 3], [0, 2, 0], [0, 0, 2, 3], [3, 3]] assert _doktocsr(f) == [[5, 12], [3, 5], [0, 0, 0, 1, 1, 2, 2, 2], [7, 8]] def test_csrtodok(): h = [[5, 7, 5], [2, 1, 3], [0, 1, 1, 3], [3, 4]] g = [[12, 5, 4], [2, 4, 2], [0, 1, 2, 3], [3, 7]] i = [[1, 3, 12], [0, 2, 4], [0, 2, 3], [2, 5]] j = [[11, 15, 12, 15], [2, 4, 1, 2], [0, 1, 1, 2, 3, 4], [5, 8]] k = [[1, 3], [2, 1], [0, 1, 1, 2], [3, 3]] assert _csrtodok(h) == SparseMatrix(3, 4, {(0, 2): 5, (2, 1): 7, (2, 3): 5}) assert _csrtodok(g) == SparseMatrix(3, 7, {(0, 2): 12, (1, 4): 5, (2, 2): 4}) assert _csrtodok(i) == SparseMatrix([[1, 0, 3, 0, 0], [0, 0, 0, 0, 12]]) assert _csrtodok(j) == SparseMatrix(5, 8, {(0, 2): 11, (2, 4): 15, (3, 1): 12, (4, 2): 15}) assert _csrtodok(k) == SparseMatrix(3, 3, {(0, 2): 1, (2, 1): 3}) def test_banded(): raises(TypeError, lambda: banded()) raises(TypeError, lambda: banded(1)) raises(TypeError, lambda: banded(1, 2)) raises(TypeError, lambda: banded(1, 2, 3)) raises(TypeError, lambda: banded(1, 2, 3, 4)) raises(ValueError, lambda: banded({0: (1, 2)}, rows=1)) raises(ValueError, lambda: banded({0: (1, 2)}, cols=1)) raises(ValueError, lambda: banded(1, {0: (1, 2)})) raises(ValueError, lambda: banded(2, 1, {0: (1, 2)})) raises(ValueError, lambda: banded(1, 2, {0: (1, 2)})) assert isinstance(banded(2, 4, {}), SparseMatrix) assert banded(2, 4, {}) == zeros(2, 4) assert banded({0: 0, 1: 0}) == zeros(0) assert banded({0: Matrix([1, 2])}) == Matrix([1, 2]) assert banded({1: [1, 2, 3, 0], -1: [4, 5, 6]}) == \ banded({1: (1, 2, 3), -1: (4, 5, 6)}) == \ Matrix([ [0, 1, 0, 0], [4, 0, 2, 0], [0, 5, 0, 3], [0, 0, 6, 0]]) assert banded(3, 4, {-1: 1, 0: 2, 1: 3}) == \ Matrix([ [2, 3, 0, 0], [1, 2, 3, 0], [0, 1, 2, 3]]) s = lambda d: (1 + d)**2 assert banded(5, {0: s, 2: s}) == \ Matrix([ [1, 0, 1, 0, 0], [0, 4, 0, 4, 0], [0, 0, 9, 0, 9], [0, 0, 0, 16, 0], [0, 0, 0, 0, 25]]) assert banded(2, {0: 1}) == \ Matrix([ [1, 0], [0, 1]]) assert banded(2, 3, {0: 1}) == \ Matrix([ [1, 0, 0], [0, 1, 0]]) vert = Matrix([1, 2, 3]) assert banded({0: vert}, cols=3) == \ Matrix([ [1, 0, 0], [2, 1, 0], [3, 2, 1], [0, 3, 2], [0, 0, 3]]) assert banded(4, {0: ones(2)}) == \ Matrix([ [1, 1, 0, 0], [1, 1, 0, 0], [0, 0, 1, 1], [0, 0, 1, 1]]) raises(ValueError, lambda: banded({0: 2, 1: ones(2)}, rows=5)) assert banded({0: 2, 2: (ones(2),)*3}) == \ Matrix([ [2, 0, 1, 1, 0, 0, 0, 0], [0, 2, 1, 1, 0, 0, 0, 0], [0, 0, 2, 0, 1, 1, 0, 0], [0, 0, 0, 2, 1, 1, 0, 0], [0, 0, 0, 0, 2, 0, 1, 1], [0, 0, 0, 0, 0, 2, 1, 1]]) raises(ValueError, lambda: banded({0: (2,)*5, 1: (ones(2),)*3})) u2 = Matrix([[1, 1], [0, 1]]) assert banded({0: (2,)*5, 1: (u2,)*3}) == \ Matrix([ [2, 1, 1, 0, 0, 0, 0], [0, 2, 1, 0, 0, 0, 0], [0, 0, 2, 1, 1, 0, 0], [0, 0, 0, 2, 1, 0, 0], [0, 0, 0, 0, 2, 1, 1], [0, 0, 0, 0, 0, 0, 1]]) assert banded({0:(0, ones(2)), 2: 2}) == \ Matrix([ [0, 0, 2], [0, 1, 1], [0, 1, 1]]) raises(ValueError, lambda: banded({0: (0, ones(2)), 1: 2})) assert banded({0: 1}, cols=3) == banded({0: 1}, rows=3) == eye(3) assert banded({1: 1}, rows=3) == Matrix([ [0, 1, 0], [0, 0, 1], [0, 0, 0]])
840240cc507d655d329f58bfeb5372a2cb1b7f97891eb3792bc00ac31d59b499
import random from sympy import ( Abs, Add, E, Float, I, Integer, Max, Min, N, Poly, Pow, PurePoly, Rational, S, Symbol, cos, exp, expand_mul, oo, pi, signsimp, simplify, sin, sqrt, symbols, sympify, trigsimp, tan, sstr, diff, Function) from sympy.matrices.matrices import (ShapeError, MatrixError, NonSquareMatrixError, DeferredVector, _find_reasonable_pivot_naive, _simplify) from sympy.matrices import ( GramSchmidt, ImmutableMatrix, ImmutableSparseMatrix, Matrix, SparseMatrix, casoratian, diag, eye, hessian, matrix_multiply_elementwise, ones, randMatrix, rot_axis1, rot_axis2, rot_axis3, wronskian, zeros, MutableDenseMatrix, ImmutableDenseMatrix, MatrixSymbol) from sympy.core.compatibility import long, iterable, range, Hashable from sympy.core import Tuple, Wild from sympy.utilities.iterables import flatten, capture from sympy.utilities.pytest import raises, XFAIL, slow, skip, warns_deprecated_sympy from sympy.solvers import solve from sympy.assumptions import Q from sympy.tensor.array import Array from sympy.matrices.expressions import MatPow from sympy.abc import a, b, c, d, x, y, z, t # don't re-order this list classes = (Matrix, SparseMatrix, ImmutableMatrix, ImmutableSparseMatrix) def test_args(): for c, cls in enumerate(classes): m = cls.zeros(3, 2) # all should give back the same type of arguments, e.g. ints for shape assert m.shape == (3, 2) and all(type(i) is int for i in m.shape) assert m.rows == 3 and type(m.rows) is int assert m.cols == 2 and type(m.cols) is int if not c % 2: assert type(m._mat) in (list, tuple, Tuple) else: assert type(m._smat) is dict def test_division(): v = Matrix(1, 2, [x, y]) assert v.__div__(z) == Matrix(1, 2, [x/z, y/z]) assert v.__truediv__(z) == Matrix(1, 2, [x/z, y/z]) assert v/z == Matrix(1, 2, [x/z, y/z]) def test_sum(): m = Matrix([[1, 2, 3], [x, y, x], [2*y, -50, z*x]]) assert m + m == Matrix([[2, 4, 6], [2*x, 2*y, 2*x], [4*y, -100, 2*z*x]]) n = Matrix(1, 2, [1, 2]) raises(ShapeError, lambda: m + n) def test_abs(): m = Matrix(1, 2, [-3, x]) n = Matrix(1, 2, [3, Abs(x)]) assert abs(m) == n def test_addition(): a = Matrix(( (1, 2), (3, 1), )) b = Matrix(( (1, 2), (3, 0), )) assert a + b == a.add(b) == Matrix([[2, 4], [6, 1]]) def test_fancy_index_matrix(): for M in (Matrix, SparseMatrix): a = M(3, 3, range(9)) assert a == a[:, :] assert a[1, :] == Matrix(1, 3, [3, 4, 5]) assert a[:, 1] == Matrix([1, 4, 7]) assert a[[0, 1], :] == Matrix([[0, 1, 2], [3, 4, 5]]) assert a[[0, 1], 2] == a[[0, 1], [2]] assert a[2, [0, 1]] == a[[2], [0, 1]] assert a[:, [0, 1]] == Matrix([[0, 1], [3, 4], [6, 7]]) assert a[0, 0] == 0 assert a[0:2, :] == Matrix([[0, 1, 2], [3, 4, 5]]) assert a[:, 0:2] == Matrix([[0, 1], [3, 4], [6, 7]]) assert a[::2, 1] == a[[0, 2], 1] assert a[1, ::2] == a[1, [0, 2]] a = M(3, 3, range(9)) assert a[[0, 2, 1, 2, 1], :] == Matrix([ [0, 1, 2], [6, 7, 8], [3, 4, 5], [6, 7, 8], [3, 4, 5]]) assert a[:, [0,2,1,2,1]] == Matrix([ [0, 2, 1, 2, 1], [3, 5, 4, 5, 4], [6, 8, 7, 8, 7]]) a = SparseMatrix.zeros(3) a[1, 2] = 2 a[0, 1] = 3 a[2, 0] = 4 assert a.extract([1, 1], [2]) == Matrix([ [2], [2]]) assert a.extract([1, 0], [2, 2, 2]) == Matrix([ [2, 2, 2], [0, 0, 0]]) assert a.extract([1, 0, 1, 2], [2, 0, 1, 0]) == Matrix([ [2, 0, 0, 0], [0, 0, 3, 0], [2, 0, 0, 0], [0, 4, 0, 4]]) def test_multiplication(): a = Matrix(( (1, 2), (3, 1), (0, 6), )) b = Matrix(( (1, 2), (3, 0), )) c = a*b assert c[0, 0] == 7 assert c[0, 1] == 2 assert c[1, 0] == 6 assert c[1, 1] == 6 assert c[2, 0] == 18 assert c[2, 1] == 0 try: eval('c = a @ b') except SyntaxError: pass else: assert c[0, 0] == 7 assert c[0, 1] == 2 assert c[1, 0] == 6 assert c[1, 1] == 6 assert c[2, 0] == 18 assert c[2, 1] == 0 h = matrix_multiply_elementwise(a, c) assert h == a.multiply_elementwise(c) assert h[0, 0] == 7 assert h[0, 1] == 4 assert h[1, 0] == 18 assert h[1, 1] == 6 assert h[2, 0] == 0 assert h[2, 1] == 0 raises(ShapeError, lambda: matrix_multiply_elementwise(a, b)) c = b * Symbol("x") assert isinstance(c, Matrix) assert c[0, 0] == x assert c[0, 1] == 2*x assert c[1, 0] == 3*x assert c[1, 1] == 0 c2 = x * b assert c == c2 c = 5 * b assert isinstance(c, Matrix) assert c[0, 0] == 5 assert c[0, 1] == 2*5 assert c[1, 0] == 3*5 assert c[1, 1] == 0 try: eval('c = 5 @ b') except SyntaxError: pass else: assert isinstance(c, Matrix) assert c[0, 0] == 5 assert c[0, 1] == 2*5 assert c[1, 0] == 3*5 assert c[1, 1] == 0 def test_power(): raises(NonSquareMatrixError, lambda: Matrix((1, 2))**2) R = Rational A = Matrix([[2, 3], [4, 5]]) assert (A**-3)[:] == [R(-269)/8, R(153)/8, R(51)/2, R(-29)/2] assert (A**5)[:] == [6140, 8097, 10796, 14237] A = Matrix([[2, 1, 3], [4, 2, 4], [6, 12, 1]]) assert (A**3)[:] == [290, 262, 251, 448, 440, 368, 702, 954, 433] assert A**0 == eye(3) assert A**1 == A assert (Matrix([[2]]) ** 100)[0, 0] == 2**100 assert eye(2)**10000000 == eye(2) assert Matrix([[1, 2], [3, 4]])**Integer(2) == Matrix([[7, 10], [15, 22]]) A = Matrix([[33, 24], [48, 57]]) assert (A**(S(1)/2))[:] == [5, 2, 4, 7] A = Matrix([[0, 4], [-1, 5]]) assert (A**(S(1)/2))**2 == A assert Matrix([[1, 0], [1, 1]])**(S(1)/2) == Matrix([[1, 0], [S.Half, 1]]) assert Matrix([[1, 0], [1, 1]])**0.5 == Matrix([[1.0, 0], [0.5, 1.0]]) from sympy.abc import a, b, n assert Matrix([[1, a], [0, 1]])**n == Matrix([[1, a*n], [0, 1]]) assert Matrix([[b, a], [0, b]])**n == Matrix([[b**n, a*b**(n-1)*n], [0, b**n]]) assert Matrix([[a, 1, 0], [0, a, 1], [0, 0, a]])**n == Matrix([ [a**n, a**(n-1)*n, a**(n-2)*(n-1)*n/2], [0, a**n, a**(n-1)*n], [0, 0, a**n]]) assert Matrix([[a, 1, 0], [0, a, 0], [0, 0, b]])**n == Matrix([ [a**n, a**(n-1)*n, 0], [0, a**n, 0], [0, 0, b**n]]) A = Matrix([[1, 0], [1, 7]]) assert A._matrix_pow_by_jordan_blocks(3) == A._eval_pow_by_recursion(3) A = Matrix([[2]]) assert A**10 == Matrix([[2**10]]) == A._matrix_pow_by_jordan_blocks(10) == \ A._eval_pow_by_recursion(10) # testing a matrix that cannot be jordan blocked issue 11766 m = Matrix([[3, 0, 0, 0, -3], [0, -3, -3, 0, 3], [0, 3, 0, 3, 0], [0, 0, 3, 0, 3], [3, 0, 0, 3, 0]]) raises(MatrixError, lambda: m._matrix_pow_by_jordan_blocks(10)) # test issue 11964 raises(ValueError, lambda: Matrix([[1, 1], [3, 3]])._matrix_pow_by_jordan_blocks(-10)) A = Matrix([[0, 1, 0], [0, 0, 1], [0, 0, 0]]) # Nilpotent jordan block size 3 assert A**10.0 == Matrix([[0, 0, 0], [0, 0, 0], [0, 0, 0]]) raises(ValueError, lambda: A**2.1) raises(ValueError, lambda: A**(S(3)/2)) A = Matrix([[8, 1], [3, 2]]) assert A**10.0 == Matrix([[1760744107, 272388050], [817164150, 126415807]]) A = Matrix([[0, 0, 1], [0, 0, 1], [0, 0, 1]]) # Nilpotent jordan block size 1 assert A**10.2 == Matrix([[0, 0, 1], [0, 0, 1], [0, 0, 1]]) A = Matrix([[0, 1, 0], [0, 0, 1], [0, 0, 1]]) # Nilpotent jordan block size 2 assert A**10.0 == Matrix([[0, 0, 1], [0, 0, 1], [0, 0, 1]]) n = Symbol('n', integer=True) assert isinstance(A**n, MatPow) n = Symbol('n', integer=True, nonnegative=True) raises(ValueError, lambda: A**n) assert A**(n + 2) == Matrix([[0, 0, 1], [0, 0, 1], [0, 0, 1]]) raises(ValueError, lambda: A**(S(3)/2)) A = Matrix([[0, 0, 1], [3, 0, 1], [4, 3, 1]]) assert A**5.0 == Matrix([[168, 72, 89], [291, 144, 161], [572, 267, 329]]) assert A**5.0 == A**5 A = Matrix([[0, 1, 0],[-1, 0, 0],[0, 0, 0]]) n = Symbol("n") An = A**n assert An.subs(n, 2).doit() == A**2 raises(ValueError, lambda: An.subs(n, -2).doit()) assert An * An == A**(2*n) def test_creation(): raises(ValueError, lambda: Matrix(5, 5, range(20))) raises(ValueError, lambda: Matrix(5, -1, [])) raises(IndexError, lambda: Matrix((1, 2))[2]) with raises(IndexError): Matrix((1, 2))[1:2] = 5 with raises(IndexError): Matrix((1, 2))[3] = 5 assert Matrix() == Matrix([]) == Matrix([[]]) == Matrix(0, 0, []) # anything can go into a matrix (laplace_transform uses tuples) assert Matrix([[[], ()]]).tolist() == [[[], ()]] assert Matrix([[[], ()]]).T.tolist() == [[[]], [()]] a = Matrix([[x, 0], [0, 0]]) m = a assert m.cols == m.rows assert m.cols == 2 assert m[:] == [x, 0, 0, 0] b = Matrix(2, 2, [x, 0, 0, 0]) m = b assert m.cols == m.rows assert m.cols == 2 assert m[:] == [x, 0, 0, 0] assert a == b assert Matrix(b) == b c23 = Matrix(2, 3, range(1, 7)) c13 = Matrix(1, 3, range(7, 10)) c = Matrix([c23, c13]) assert c.cols == 3 assert c.rows == 3 assert c[:] == [1, 2, 3, 4, 5, 6, 7, 8, 9] assert Matrix(eye(2)) == eye(2) assert ImmutableMatrix(ImmutableMatrix(eye(2))) == ImmutableMatrix(eye(2)) assert ImmutableMatrix(c) == c.as_immutable() assert Matrix(ImmutableMatrix(c)) == ImmutableMatrix(c).as_mutable() assert c is not Matrix(c) dat = [[ones(3,2), ones(3,3)*2], [ones(2,3)*3, ones(2,2)*4]] M = Matrix(dat) assert M == Matrix([ [1, 1, 2, 2, 2], [1, 1, 2, 2, 2], [1, 1, 2, 2, 2], [3, 3, 3, 4, 4], [3, 3, 3, 4, 4]]) assert M.tolist() != dat # keep block form if evaluate=False assert Matrix(dat, evaluate=False).tolist() == dat A = MatrixSymbol("A", 2, 2) dat = [ones(2), A] assert Matrix(dat) == Matrix([ [ 1, 1], [ 1, 1], [A[0, 0], A[0, 1]], [A[1, 0], A[1, 1]]]) assert Matrix(dat, evaluate=False).tolist() == [[i] for i in dat] # 0-dim tolerance assert Matrix([ones(2), ones(0)]) == Matrix([ones(2)]) raises(ValueError, lambda: Matrix([ones(2), ones(0, 3)])) raises(ValueError, lambda: Matrix([ones(2), ones(3, 0)])) def test_irregular_block(): assert Matrix.irregular(3, ones(2,1), ones(3,3)*2, ones(2,2)*3, ones(1,1)*4, ones(2,2)*5, ones(1,2)*6, ones(1,2)*7) == Matrix([ [1, 2, 2, 2, 3, 3], [1, 2, 2, 2, 3, 3], [4, 2, 2, 2, 5, 5], [6, 6, 7, 7, 5, 5]]) def test_tolist(): lst = [[S.One, S.Half, x*y, S.Zero], [x, y, z, x**2], [y, -S.One, z*x, 3]] m = Matrix(lst) assert m.tolist() == lst def test_as_mutable(): assert zeros(0, 3).as_mutable() == zeros(0, 3) assert zeros(0, 3).as_immutable() == ImmutableMatrix(zeros(0, 3)) assert zeros(3, 0).as_immutable() == ImmutableMatrix(zeros(3, 0)) def test_determinant(): for M in [Matrix(), Matrix([[1]])]: assert ( M.det() == M._eval_det_bareiss() == M._eval_det_berkowitz() == M._eval_det_lu() == 1) M = Matrix(( (-3, 2), ( 8, -5) )) assert M.det(method="bareiss") == -1 assert M.det(method="berkowitz") == -1 assert M.det(method="lu") == -1 M = Matrix(( (x, 1), (y, 2*y) )) assert M.det(method="bareiss") == 2*x*y - y assert M.det(method="berkowitz") == 2*x*y - y assert M.det(method="lu") == 2*x*y - y M = Matrix(( (1, 1, 1), (1, 2, 3), (1, 3, 6) )) assert M.det(method="bareiss") == 1 assert M.det(method="berkowitz") == 1 assert M.det(method="lu") == 1 M = Matrix(( ( 3, -2, 0, 5), (-2, 1, -2, 2), ( 0, -2, 5, 0), ( 5, 0, 3, 4) )) assert M.det(method="bareiss") == -289 assert M.det(method="berkowitz") == -289 assert M.det(method="lu") == -289 M = Matrix(( ( 1, 2, 3, 4), ( 5, 6, 7, 8), ( 9, 10, 11, 12), (13, 14, 15, 16) )) assert M.det(method="bareiss") == 0 assert M.det(method="berkowitz") == 0 assert M.det(method="lu") == 0 M = Matrix(( (3, 2, 0, 0, 0), (0, 3, 2, 0, 0), (0, 0, 3, 2, 0), (0, 0, 0, 3, 2), (2, 0, 0, 0, 3) )) assert M.det(method="bareiss") == 275 assert M.det(method="berkowitz") == 275 assert M.det(method="lu") == 275 M = Matrix(( (1, 0, 1, 2, 12), (2, 0, 1, 1, 4), (2, 1, 1, -1, 3), (3, 2, -1, 1, 8), (1, 1, 1, 0, 6) )) assert M.det(method="bareiss") == -55 assert M.det(method="berkowitz") == -55 assert M.det(method="lu") == -55 M = Matrix(( (-5, 2, 3, 4, 5), ( 1, -4, 3, 4, 5), ( 1, 2, -3, 4, 5), ( 1, 2, 3, -2, 5), ( 1, 2, 3, 4, -1) )) assert M.det(method="bareiss") == 11664 assert M.det(method="berkowitz") == 11664 assert M.det(method="lu") == 11664 M = Matrix(( ( 2, 7, -1, 3, 2), ( 0, 0, 1, 0, 1), (-2, 0, 7, 0, 2), (-3, -2, 4, 5, 3), ( 1, 0, 0, 0, 1) )) assert M.det(method="bareiss") == 123 assert M.det(method="berkowitz") == 123 assert M.det(method="lu") == 123 M = Matrix(( (x, y, z), (1, 0, 0), (y, z, x) )) assert M.det(method="bareiss") == z**2 - x*y assert M.det(method="berkowitz") == z**2 - x*y assert M.det(method="lu") == z**2 - x*y # issue 13835 a = symbols('a') M = lambda n: Matrix([[i + a*j for i in range(n)] for j in range(n)]) assert M(5).det() == 0 assert M(6).det() == 0 assert M(7).det() == 0 def test_slicing(): m0 = eye(4) assert m0[:3, :3] == eye(3) assert m0[2:4, 0:2] == zeros(2) m1 = Matrix(3, 3, lambda i, j: i + j) assert m1[0, :] == Matrix(1, 3, (0, 1, 2)) assert m1[1:3, 1] == Matrix(2, 1, (2, 3)) m2 = Matrix([[0, 1, 2, 3], [4, 5, 6, 7], [8, 9, 10, 11], [12, 13, 14, 15]]) assert m2[:, -1] == Matrix(4, 1, [3, 7, 11, 15]) assert m2[-2:, :] == Matrix([[8, 9, 10, 11], [12, 13, 14, 15]]) def test_submatrix_assignment(): m = zeros(4) m[2:4, 2:4] = eye(2) assert m == Matrix(((0, 0, 0, 0), (0, 0, 0, 0), (0, 0, 1, 0), (0, 0, 0, 1))) m[:2, :2] = eye(2) assert m == eye(4) m[:, 0] = Matrix(4, 1, (1, 2, 3, 4)) assert m == Matrix(((1, 0, 0, 0), (2, 1, 0, 0), (3, 0, 1, 0), (4, 0, 0, 1))) m[:, :] = zeros(4) assert m == zeros(4) m[:, :] = [(1, 2, 3, 4), (5, 6, 7, 8), (9, 10, 11, 12), (13, 14, 15, 16)] assert m == Matrix(((1, 2, 3, 4), (5, 6, 7, 8), (9, 10, 11, 12), (13, 14, 15, 16))) m[:2, 0] = [0, 0] assert m == Matrix(((0, 2, 3, 4), (0, 6, 7, 8), (9, 10, 11, 12), (13, 14, 15, 16))) def test_extract(): m = Matrix(4, 3, lambda i, j: i*3 + j) assert m.extract([0, 1, 3], [0, 1]) == Matrix(3, 2, [0, 1, 3, 4, 9, 10]) assert m.extract([0, 3], [0, 0, 2]) == Matrix(2, 3, [0, 0, 2, 9, 9, 11]) assert m.extract(range(4), range(3)) == m raises(IndexError, lambda: m.extract([4], [0])) raises(IndexError, lambda: m.extract([0], [3])) def test_reshape(): m0 = eye(3) assert m0.reshape(1, 9) == Matrix(1, 9, (1, 0, 0, 0, 1, 0, 0, 0, 1)) m1 = Matrix(3, 4, lambda i, j: i + j) assert m1.reshape( 4, 3) == Matrix(((0, 1, 2), (3, 1, 2), (3, 4, 2), (3, 4, 5))) assert m1.reshape(2, 6) == Matrix(((0, 1, 2, 3, 1, 2), (3, 4, 2, 3, 4, 5))) def test_applyfunc(): m0 = eye(3) assert m0.applyfunc(lambda x: 2*x) == eye(3)*2 assert m0.applyfunc(lambda x: 0) == zeros(3) def test_expand(): m0 = Matrix([[x*(x + y), 2], [((x + y)*y)*x, x*(y + x*(x + y))]]) # Test if expand() returns a matrix m1 = m0.expand() assert m1 == Matrix( [[x*y + x**2, 2], [x*y**2 + y*x**2, x*y + y*x**2 + x**3]]) a = Symbol('a', real=True) assert Matrix([exp(I*a)]).expand(complex=True) == \ Matrix([cos(a) + I*sin(a)]) assert Matrix([[0, 1, 2], [0, 0, -1], [0, 0, 0]]).exp() == Matrix([ [1, 1, Rational(3, 2)], [0, 1, -1], [0, 0, 1]] ) def test_refine(): m0 = Matrix([[Abs(x)**2, sqrt(x**2)], [sqrt(x**2)*Abs(y)**2, sqrt(y**2)*Abs(x)**2]]) m1 = m0.refine(Q.real(x) & Q.real(y)) assert m1 == Matrix([[x**2, Abs(x)], [y**2*Abs(x), x**2*Abs(y)]]) m1 = m0.refine(Q.positive(x) & Q.positive(y)) assert m1 == Matrix([[x**2, x], [x*y**2, x**2*y]]) m1 = m0.refine(Q.negative(x) & Q.negative(y)) assert m1 == Matrix([[x**2, -x], [-x*y**2, -x**2*y]]) def test_random(): M = randMatrix(3, 3) M = randMatrix(3, 3, seed=3) assert M == randMatrix(3, 3, seed=3) M = randMatrix(3, 4, 0, 150) M = randMatrix(3, seed=4, symmetric=True) assert M == randMatrix(3, seed=4, symmetric=True) S = M.copy() S.simplify() assert S == M # doesn't fail when elements are Numbers, not int rng = random.Random(4) assert M == randMatrix(3, symmetric=True, prng=rng) # Ensure symmetry for size in (10, 11): # Test odd and even for percent in (100, 70, 30): M = randMatrix(size, symmetric=True, percent=percent, prng=rng) assert M == M.T M = randMatrix(10, min=1, percent=70) zero_count = 0 for i in range(M.shape[0]): for j in range(M.shape[1]): if M[i, j] == 0: zero_count += 1 assert zero_count == 30 def test_LUdecomp(): testmat = Matrix([[0, 2, 5, 3], [3, 3, 7, 4], [8, 4, 0, 2], [-2, 6, 3, 4]]) L, U, p = testmat.LUdecomposition() assert L.is_lower assert U.is_upper assert (L*U).permute_rows(p, 'backward') - testmat == zeros(4) testmat = Matrix([[6, -2, 7, 4], [0, 3, 6, 7], [1, -2, 7, 4], [-9, 2, 6, 3]]) L, U, p = testmat.LUdecomposition() assert L.is_lower assert U.is_upper assert (L*U).permute_rows(p, 'backward') - testmat == zeros(4) # non-square testmat = Matrix([[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12]]) L, U, p = testmat.LUdecomposition(rankcheck=False) assert L.is_lower assert U.is_upper assert (L*U).permute_rows(p, 'backward') - testmat == zeros(4, 3) # square and singular testmat = Matrix([[1, 2, 3], [2, 4, 6], [4, 5, 6]]) L, U, p = testmat.LUdecomposition(rankcheck=False) assert L.is_lower assert U.is_upper assert (L*U).permute_rows(p, 'backward') - testmat == zeros(3) M = Matrix(((1, x, 1), (2, y, 0), (y, 0, z))) L, U, p = M.LUdecomposition() assert L.is_lower assert U.is_upper assert (L*U).permute_rows(p, 'backward') - M == zeros(3) mL = Matrix(( (1, 0, 0), (2, 3, 0), )) assert mL.is_lower is True assert mL.is_upper is False mU = Matrix(( (1, 2, 3), (0, 4, 5), )) assert mU.is_lower is False assert mU.is_upper is True # test FF LUdecomp M = Matrix([[1, 3, 3], [3, 2, 6], [3, 2, 2]]) P, L, Dee, U = M.LUdecompositionFF() assert P*M == L*Dee.inv()*U M = Matrix([[1, 2, 3, 4], [3, -1, 2, 3], [3, 1, 3, -2], [6, -1, 0, 2]]) P, L, Dee, U = M.LUdecompositionFF() assert P*M == L*Dee.inv()*U M = Matrix([[0, 0, 1], [2, 3, 0], [3, 1, 4]]) P, L, Dee, U = M.LUdecompositionFF() assert P*M == L*Dee.inv()*U # issue 15794 M = Matrix( [[1, 2, 3], [4, 5, 6], [7, 8, 9]] ) raises(ValueError, lambda : M.LUdecomposition_Simple(rankcheck=True)) def test_LUsolve(): A = Matrix([[2, 3, 5], [3, 6, 2], [8, 3, 6]]) x = Matrix(3, 1, [3, 7, 5]) b = A*x soln = A.LUsolve(b) assert soln == x A = Matrix([[0, -1, 2], [5, 10, 7], [8, 3, 4]]) x = Matrix(3, 1, [-1, 2, 5]) b = A*x soln = A.LUsolve(b) assert soln == x A = Matrix([[2, 1], [1, 0], [1, 0]]) # issue 14548 b = Matrix([3, 1, 1]) assert A.LUsolve(b) == Matrix([1, 1]) b = Matrix([3, 1, 2]) # inconsistent raises(ValueError, lambda: A.LUsolve(b)) A = Matrix([[0, -1, 2], [5, 10, 7], [8, 3, 4], [2, 3, 5], [3, 6, 2], [8, 3, 6]]) x = Matrix([2, 1, -4]) b = A*x soln = A.LUsolve(b) assert soln == x A = Matrix([[0, -1, 2], [5, 10, 7]]) # underdetermined x = Matrix([-1, 2, 0]) b = A*x raises(NotImplementedError, lambda: A.LUsolve(b)) A = Matrix(4, 4, lambda i, j: 1/(i+j+1) if i != 3 else 0) b = Matrix.zeros(4, 1) raises(NotImplementedError, lambda: A.LUsolve(b)) def test_QRsolve(): A = Matrix([[2, 3, 5], [3, 6, 2], [8, 3, 6]]) x = Matrix(3, 1, [3, 7, 5]) b = A*x soln = A.QRsolve(b) assert soln == x x = Matrix([[1, 2], [3, 4], [5, 6]]) b = A*x soln = A.QRsolve(b) assert soln == x A = Matrix([[0, -1, 2], [5, 10, 7], [8, 3, 4]]) x = Matrix(3, 1, [-1, 2, 5]) b = A*x soln = A.QRsolve(b) assert soln == x x = Matrix([[7, 8], [9, 10], [11, 12]]) b = A*x soln = A.QRsolve(b) assert soln == x def test_inverse(): A = eye(4) assert A.inv() == eye(4) assert A.inv(method="LU") == eye(4) assert A.inv(method="ADJ") == eye(4) A = Matrix([[2, 3, 5], [3, 6, 2], [8, 3, 6]]) Ainv = A.inv() assert A*Ainv == eye(3) assert A.inv(method="LU") == Ainv assert A.inv(method="ADJ") == Ainv # test that immutability is not a problem cls = ImmutableMatrix m = cls([[48, 49, 31], [ 9, 71, 94], [59, 28, 65]]) assert all(type(m.inv(s)) is cls for s in 'GE ADJ LU'.split()) cls = ImmutableSparseMatrix m = cls([[48, 49, 31], [ 9, 71, 94], [59, 28, 65]]) assert all(type(m.inv(s)) is cls for s in 'CH LDL'.split()) def test_matrix_inverse_mod(): A = Matrix(2, 1, [1, 0]) raises(NonSquareMatrixError, lambda: A.inv_mod(2)) A = Matrix(2, 2, [1, 0, 0, 0]) raises(ValueError, lambda: A.inv_mod(2)) A = Matrix(2, 2, [1, 2, 3, 4]) Ai = Matrix(2, 2, [1, 1, 0, 1]) assert A.inv_mod(3) == Ai A = Matrix(2, 2, [1, 0, 0, 1]) assert A.inv_mod(2) == A A = Matrix(3, 3, [1, 2, 3, 4, 5, 6, 7, 8, 9]) raises(ValueError, lambda: A.inv_mod(5)) A = Matrix(3, 3, [5, 1, 3, 2, 6, 0, 2, 1, 1]) Ai = Matrix(3, 3, [6, 8, 0, 1, 5, 6, 5, 6, 4]) assert A.inv_mod(9) == Ai A = Matrix(3, 3, [1, 6, -3, 4, 1, -5, 3, -5, 5]) Ai = Matrix(3, 3, [4, 3, 3, 1, 2, 5, 1, 5, 1]) assert A.inv_mod(6) == Ai A = Matrix(3, 3, [1, 6, 1, 4, 1, 5, 3, 2, 5]) Ai = Matrix(3, 3, [6, 0, 3, 6, 6, 4, 1, 6, 1]) assert A.inv_mod(7) == Ai def test_util(): R = Rational v1 = Matrix(1, 3, [1, 2, 3]) v2 = Matrix(1, 3, [3, 4, 5]) assert v1.norm() == sqrt(14) assert v1.project(v2) == Matrix(1, 3, [R(39)/25, R(52)/25, R(13)/5]) assert Matrix.zeros(1, 2) == Matrix(1, 2, [0, 0]) assert ones(1, 2) == Matrix(1, 2, [1, 1]) assert v1.copy() == v1 # cofactor assert eye(3) == eye(3).cofactor_matrix() test = Matrix([[1, 3, 2], [2, 6, 3], [2, 3, 6]]) assert test.cofactor_matrix() == \ Matrix([[27, -6, -6], [-12, 2, 3], [-3, 1, 0]]) test = Matrix([[1, 2, 3], [4, 5, 6], [7, 8, 9]]) assert test.cofactor_matrix() == \ Matrix([[-3, 6, -3], [6, -12, 6], [-3, 6, -3]]) def test_jacobian_hessian(): L = Matrix(1, 2, [x**2*y, 2*y**2 + x*y]) syms = [x, y] assert L.jacobian(syms) == Matrix([[2*x*y, x**2], [y, 4*y + x]]) L = Matrix(1, 2, [x, x**2*y**3]) assert L.jacobian(syms) == Matrix([[1, 0], [2*x*y**3, x**2*3*y**2]]) f = x**2*y syms = [x, y] assert hessian(f, syms) == Matrix([[2*y, 2*x], [2*x, 0]]) f = x**2*y**3 assert hessian(f, syms) == \ Matrix([[2*y**3, 6*x*y**2], [6*x*y**2, 6*x**2*y]]) f = z + x*y**2 g = x**2 + 2*y**3 ans = Matrix([[0, 2*y], [2*y, 2*x]]) assert ans == hessian(f, Matrix([x, y])) assert ans == hessian(f, Matrix([x, y]).T) assert hessian(f, (y, x), [g]) == Matrix([ [ 0, 6*y**2, 2*x], [6*y**2, 2*x, 2*y], [ 2*x, 2*y, 0]]) def test_QR(): A = Matrix([[1, 2], [2, 3]]) Q, S = A.QRdecomposition() R = Rational assert Q == Matrix([ [ 5**R(-1, 2), (R(2)/5)*(R(1)/5)**R(-1, 2)], [2*5**R(-1, 2), (-R(1)/5)*(R(1)/5)**R(-1, 2)]]) assert S == Matrix([[5**R(1, 2), 8*5**R(-1, 2)], [0, (R(1)/5)**R(1, 2)]]) assert Q*S == A assert Q.T * Q == eye(2) A = Matrix([[1, 1, 1], [1, 1, 3], [2, 3, 4]]) Q, R = A.QRdecomposition() assert Q.T * Q == eye(Q.cols) assert R.is_upper assert A == Q*R def test_QR_non_square(): # Narrow (cols < rows) matrices A = Matrix([[9, 0, 26], [12, 0, -7], [0, 4, 4], [0, -3, -3]]) Q, R = A.QRdecomposition() assert Q.T * Q == eye(Q.cols) assert R.is_upper assert A == Q*R A = Matrix([[1, -1, 4], [1, 4, -2], [1, 4, 2], [1, -1, 0]]) Q, R = A.QRdecomposition() assert Q.T * Q == eye(Q.cols) assert R.is_upper assert A == Q*R A = Matrix(2, 1, [1, 2]) Q, R = A.QRdecomposition() assert Q.T * Q == eye(Q.cols) assert R.is_upper assert A == Q*R # Wide (cols > rows) matrices A = Matrix([[1, 2, 3], [4, 5, 6]]) Q, R = A.QRdecomposition() assert Q.T * Q == eye(Q.cols) assert R.is_upper assert A == Q*R A = Matrix([[1, 2, 3, 4], [1, 4, 9, 16], [1, 8, 27, 64]]) Q, R = A.QRdecomposition() assert Q.T * Q == eye(Q.cols) assert R.is_upper assert A == Q*R A = Matrix(1, 2, [1, 2]) Q, R = A.QRdecomposition() assert Q.T * Q == eye(Q.cols) assert R.is_upper assert A == Q*R def test_QR_trivial(): # Rank deficient matrices A = Matrix([[1, 2, 3], [4, 5, 6], [7, 8, 9]]) Q, R = A.QRdecomposition() assert Q.T * Q == eye(Q.cols) assert R.is_upper assert A == Q*R A = Matrix([[1, 1, 1], [2, 2, 2], [3, 3, 3], [4, 4, 4]]) Q, R = A.QRdecomposition() assert Q.T * Q == eye(Q.cols) assert R.is_upper assert A == Q*R A = Matrix([[1, 1, 1], [2, 2, 2], [3, 3, 3], [4, 4, 4]]).T Q, R = A.QRdecomposition() assert Q.T * Q == eye(Q.cols) assert R.is_upper assert A == Q*R # Zero rank matrices A = Matrix([[0, 0, 0]]) Q, R = A.QRdecomposition() assert Q.T * Q == eye(Q.cols) assert R.is_upper assert A == Q*R A = Matrix([[0, 0, 0]]).T Q, R = A.QRdecomposition() assert Q.T * Q == eye(Q.cols) assert R.is_upper assert A == Q*R A = Matrix([[0, 0, 0], [0, 0, 0]]) Q, R = A.QRdecomposition() assert Q.T * Q == eye(Q.cols) assert R.is_upper assert A == Q*R A = Matrix([[0, 0, 0], [0, 0, 0]]).T Q, R = A.QRdecomposition() assert Q.T * Q == eye(Q.cols) assert R.is_upper assert A == Q*R # Rank deficient matrices with zero norm from beginning columns A = Matrix([[0, 0, 0], [1, 2, 3]]).T Q, R = A.QRdecomposition() assert Q.T * Q == eye(Q.cols) assert R.is_upper assert A == Q*R A = Matrix([[0, 0, 0, 0], [1, 2, 3, 4], [0, 0, 0, 0]]).T Q, R = A.QRdecomposition() assert Q.T * Q == eye(Q.cols) assert R.is_upper assert A == Q*R A = Matrix([[0, 0, 0, 0], [1, 2, 3, 4], [0, 0, 0, 0], [2, 4, 6, 8]]).T Q, R = A.QRdecomposition() assert Q.T * Q == eye(Q.cols) assert R.is_upper assert A == Q*R A = Matrix([[0, 0, 0], [0, 0, 0], [0, 0, 0], [1, 2, 3]]).T Q, R = A.QRdecomposition() assert Q.T * Q == eye(Q.cols) assert R.is_upper assert A == Q*R def test_nullspace(): # first test reduced row-ech form R = Rational M = Matrix([[5, 7, 2, 1], [1, 6, 2, -1]]) out, tmp = M.rref() assert out == Matrix([[1, 0, -R(2)/23, R(13)/23], [0, 1, R(8)/23, R(-6)/23]]) M = Matrix([[-5, -1, 4, -3, -1], [ 1, -1, -1, 1, 0], [-1, 0, 0, 0, 0], [ 4, 1, -4, 3, 1], [-2, 0, 2, -2, -1]]) assert M*M.nullspace()[0] == Matrix(5, 1, [0]*5) M = Matrix([[ 1, 3, 0, 2, 6, 3, 1], [-2, -6, 0, -2, -8, 3, 1], [ 3, 9, 0, 0, 6, 6, 2], [-1, -3, 0, 1, 0, 9, 3]]) out, tmp = M.rref() assert out == Matrix([[1, 3, 0, 0, 2, 0, 0], [0, 0, 0, 1, 2, 0, 0], [0, 0, 0, 0, 0, 1, R(1)/3], [0, 0, 0, 0, 0, 0, 0]]) # now check the vectors basis = M.nullspace() assert basis[0] == Matrix([-3, 1, 0, 0, 0, 0, 0]) assert basis[1] == Matrix([0, 0, 1, 0, 0, 0, 0]) assert basis[2] == Matrix([-2, 0, 0, -2, 1, 0, 0]) assert basis[3] == Matrix([0, 0, 0, 0, 0, R(-1)/3, 1]) # issue 4797; just see that we can do it when rows > cols M = Matrix([[1, 2], [2, 4], [3, 6]]) assert M.nullspace() def test_columnspace(): M = Matrix([[ 1, 2, 0, 2, 5], [-2, -5, 1, -1, -8], [ 0, -3, 3, 4, 1], [ 3, 6, 0, -7, 2]]) # now check the vectors basis = M.columnspace() assert basis[0] == Matrix([1, -2, 0, 3]) assert basis[1] == Matrix([2, -5, -3, 6]) assert basis[2] == Matrix([2, -1, 4, -7]) #check by columnspace definition a, b, c, d, e = symbols('a b c d e') X = Matrix([a, b, c, d, e]) for i in range(len(basis)): eq=M*X-basis[i] assert len(solve(eq, X)) != 0 #check if rank-nullity theorem holds assert M.rank() == len(basis) assert len(M.nullspace()) + len(M.columnspace()) == M.cols def test_wronskian(): assert wronskian([cos(x), sin(x)], x) == cos(x)**2 + sin(x)**2 assert wronskian([exp(x), exp(2*x)], x) == exp(3*x) assert wronskian([exp(x), x], x) == exp(x) - x*exp(x) assert wronskian([1, x, x**2], x) == 2 w1 = -6*exp(x)*sin(x)*x + 6*cos(x)*exp(x)*x**2 - 6*exp(x)*cos(x)*x - \ exp(x)*cos(x)*x**3 + exp(x)*sin(x)*x**3 assert wronskian([exp(x), cos(x), x**3], x).expand() == w1 assert wronskian([exp(x), cos(x), x**3], x, method='berkowitz').expand() \ == w1 w2 = -x**3*cos(x)**2 - x**3*sin(x)**2 - 6*x*cos(x)**2 - 6*x*sin(x)**2 assert wronskian([sin(x), cos(x), x**3], x).expand() == w2 assert wronskian([sin(x), cos(x), x**3], x, method='berkowitz').expand() \ == w2 assert wronskian([], x) == 1 def test_eigen(): R = Rational assert eye(3).charpoly(x) == Poly((x - 1)**3, x) assert eye(3).charpoly(y) == Poly((y - 1)**3, y) M = Matrix([[1, 0, 0], [0, 1, 0], [0, 0, 1]]) assert M.eigenvals(multiple=False) == {S.One: 3} assert M.eigenvals(multiple=True) == [1, 1, 1] assert M.eigenvects() == ( [(1, 3, [Matrix([1, 0, 0]), Matrix([0, 1, 0]), Matrix([0, 0, 1])])]) assert M.left_eigenvects() == ( [(1, 3, [Matrix([[1, 0, 0]]), Matrix([[0, 1, 0]]), Matrix([[0, 0, 1]])])]) M = Matrix([[0, 1, 1], [1, 0, 0], [1, 1, 1]]) assert M.eigenvals() == {2*S.One: 1, -S.One: 1, S.Zero: 1} assert M.eigenvects() == ( [ (-1, 1, [Matrix([-1, 1, 0])]), ( 0, 1, [Matrix([0, -1, 1])]), ( 2, 1, [Matrix([R(2, 3), R(1, 3), 1])]) ]) assert M.left_eigenvects() == ( [ (-1, 1, [Matrix([[-2, 1, 1]])]), (0, 1, [Matrix([[-1, -1, 1]])]), (2, 1, [Matrix([[1, 1, 1]])]) ]) a = Symbol('a') M = Matrix([[a, 0], [0, 1]]) assert M.eigenvals() == {a: 1, S.One: 1} M = Matrix([[1, -1], [1, 3]]) assert M.eigenvects() == ([(2, 2, [Matrix(2, 1, [-1, 1])])]) assert M.left_eigenvects() == ([(2, 2, [Matrix([[1, 1]])])]) M = Matrix([[1, 2, 3], [4, 5, 6], [7, 8, 9]]) a = R(15, 2) b = 3*33**R(1, 2) c = R(13, 2) d = (R(33, 8) + 3*b/8) e = (R(33, 8) - 3*b/8) def NS(e, n): return str(N(e, n)) r = [ (a - b/2, 1, [Matrix([(12 + 24/(c - b/2))/((c - b/2)*e) + 3/(c - b/2), (6 + 12/(c - b/2))/e, 1])]), ( 0, 1, [Matrix([1, -2, 1])]), (a + b/2, 1, [Matrix([(12 + 24/(c + b/2))/((c + b/2)*d) + 3/(c + b/2), (6 + 12/(c + b/2))/d, 1])]), ] r1 = [(NS(r[i][0], 2), NS(r[i][1], 2), [NS(j, 2) for j in r[i][2][0]]) for i in range(len(r))] r = M.eigenvects() r2 = [(NS(r[i][0], 2), NS(r[i][1], 2), [NS(j, 2) for j in r[i][2][0]]) for i in range(len(r))] assert sorted(r1) == sorted(r2) eps = Symbol('eps', real=True) M = Matrix([[abs(eps), I*eps ], [-I*eps, abs(eps) ]]) assert M.eigenvects() == ( [ ( 0, 1, [Matrix([[-I*eps/abs(eps)], [1]])]), ( 2*abs(eps), 1, [ Matrix([[I*eps/abs(eps)], [1]]) ] ), ]) assert M.left_eigenvects() == ( [ (0, 1, [Matrix([[I*eps/Abs(eps), 1]])]), (2*Abs(eps), 1, [Matrix([[-I*eps/Abs(eps), 1]])]) ]) M = Matrix(3, 3, [1, 2, 0, 0, 3, 0, 2, -4, 2]) M._eigenvects = M.eigenvects(simplify=False) assert max(i.q for i in M._eigenvects[0][2][0]) > 1 M._eigenvects = M.eigenvects(simplify=True) assert max(i.q for i in M._eigenvects[0][2][0]) == 1 M = Matrix([[S(1)/4, 1], [1, 1]]) assert M.eigenvects(simplify=True) == [ (S(5)/8 - sqrt(73)/8, 1, [Matrix([[-sqrt(73)/8 - S(3)/8], [1]])]), (S(5)/8 + sqrt(73)/8, 1, [Matrix([[-S(3)/8 + sqrt(73)/8], [1]])])] assert M.eigenvects(simplify=False) ==[ (S(5)/8 - sqrt(73)/8, 1, [Matrix([[-1/(-S(3)/8 + sqrt(73)/8)], [ 1]])]), (S(5)/8 + sqrt(73)/8, 1, [Matrix([[-1/(-sqrt(73)/8 - S(3)/8)], [ 1]])])] m = Matrix([[1, .6, .6], [.6, .9, .9], [.9, .6, .6]]) evals = { S(5)/4 - sqrt(385)/20: 1, sqrt(385)/20 + S(5)/4: 1, S.Zero: 1} assert m.eigenvals() == evals nevals = list(sorted(m.eigenvals(rational=False).keys())) sevals = list(sorted(evals.keys())) assert all(abs(nevals[i] - sevals[i]) < 1e-9 for i in range(len(nevals))) # issue 10719 assert Matrix([]).eigenvals() == {} assert Matrix([]).eigenvects() == [] # issue 15119 raises(NonSquareMatrixError, lambda : Matrix([[1, 2], [0, 4], [0, 0]]).eigenvals()) raises(NonSquareMatrixError, lambda : Matrix([[1, 0], [3, 4], [5, 6]]).eigenvals()) raises(NonSquareMatrixError, lambda : Matrix([[1, 2, 3], [0, 5, 6]]).eigenvals()) raises(NonSquareMatrixError, lambda : Matrix([[1, 0, 0], [4, 5, 0]]).eigenvals()) raises(NonSquareMatrixError, lambda : Matrix([[1, 2, 3], [0, 5, 6]]).eigenvals(error_when_incomplete = False)) raises(NonSquareMatrixError, lambda : Matrix([[1, 0, 0], [4, 5, 0]]).eigenvals(error_when_incomplete = False)) # issue 15125 from sympy.core.function import count_ops q = Symbol("q", positive = True) m = Matrix([[-2, exp(-q), 1], [exp(q), -2, 1], [1, 1, -2]]) assert count_ops(m.eigenvals(simplify=False)) > count_ops(m.eigenvals(simplify=True)) assert count_ops(m.eigenvals(simplify=lambda x: x)) > count_ops(m.eigenvals(simplify=True)) assert isinstance(m.eigenvals(simplify=True, multiple=False), dict) assert isinstance(m.eigenvals(simplify=True, multiple=True), list) assert isinstance(m.eigenvals(simplify=lambda x: x, multiple=False), dict) assert isinstance(m.eigenvals(simplify=lambda x: x, multiple=True), list) def test_subs(): assert Matrix([[1, x], [x, 4]]).subs(x, 5) == Matrix([[1, 5], [5, 4]]) assert Matrix([[x, 2], [x + y, 4]]).subs([[x, -1], [y, -2]]) == \ Matrix([[-1, 2], [-3, 4]]) assert Matrix([[x, 2], [x + y, 4]]).subs([(x, -1), (y, -2)]) == \ Matrix([[-1, 2], [-3, 4]]) assert Matrix([[x, 2], [x + y, 4]]).subs({x: -1, y: -2}) == \ Matrix([[-1, 2], [-3, 4]]) assert Matrix([x*y]).subs({x: y - 1, y: x - 1}, simultaneous=True) == \ Matrix([(x - 1)*(y - 1)]) for cls in classes: assert Matrix([[2, 0], [0, 2]]) == cls.eye(2).subs(1, 2) def test_xreplace(): assert Matrix([[1, x], [x, 4]]).xreplace({x: 5}) == \ Matrix([[1, 5], [5, 4]]) assert Matrix([[x, 2], [x + y, 4]]).xreplace({x: -1, y: -2}) == \ Matrix([[-1, 2], [-3, 4]]) for cls in classes: assert Matrix([[2, 0], [0, 2]]) == cls.eye(2).xreplace({1: 2}) def test_simplify(): n = Symbol('n') f = Function('f') M = Matrix([[ 1/x + 1/y, (x + x*y) / x ], [ (f(x) + y*f(x))/f(x), 2 * (1/n - cos(n * pi)/n) / pi ]]) M.simplify() assert M == Matrix([[ (x + y)/(x * y), 1 + y ], [ 1 + y, 2*((1 - 1*cos(pi*n))/(pi*n)) ]]) eq = (1 + x)**2 M = Matrix([[eq]]) M.simplify() assert M == Matrix([[eq]]) M.simplify(ratio=oo) == M assert M == Matrix([[eq.simplify(ratio=oo)]]) def test_transpose(): M = Matrix([[1, 2, 3, 4, 5, 6, 7, 8, 9, 0], [1, 2, 3, 4, 5, 6, 7, 8, 9, 0]]) assert M.T == Matrix( [ [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [0, 0] ]) assert M.T.T == M assert M.T == M.transpose() def test_conjugate(): M = Matrix([[0, I, 5], [1, 2, 0]]) assert M.T == Matrix([[0, 1], [I, 2], [5, 0]]) assert M.C == Matrix([[0, -I, 5], [1, 2, 0]]) assert M.C == M.conjugate() assert M.H == M.T.C assert M.H == Matrix([[ 0, 1], [-I, 2], [ 5, 0]]) def test_conj_dirac(): raises(AttributeError, lambda: eye(3).D) M = Matrix([[1, I, I, I], [0, 1, I, I], [0, 0, 1, I], [0, 0, 0, 1]]) assert M.D == Matrix([[ 1, 0, 0, 0], [-I, 1, 0, 0], [-I, -I, -1, 0], [-I, -I, I, -1]]) def test_trace(): M = Matrix([[1, 0, 0], [0, 5, 0], [0, 0, 8]]) assert M.trace() == 14 def test_shape(): M = Matrix([[x, 0, 0], [0, y, 0]]) assert M.shape == (2, 3) def test_col_row_op(): M = Matrix([[x, 0, 0], [0, y, 0]]) M.row_op(1, lambda r, j: r + j + 1) assert M == Matrix([[x, 0, 0], [1, y + 2, 3]]) M.col_op(0, lambda c, j: c + y**j) assert M == Matrix([[x + 1, 0, 0], [1 + y, y + 2, 3]]) # neither row nor slice give copies that allow the original matrix to # be changed assert M.row(0) == Matrix([[x + 1, 0, 0]]) r1 = M.row(0) r1[0] = 42 assert M[0, 0] == x + 1 r1 = M[0, :-1] # also testing negative slice r1[0] = 42 assert M[0, 0] == x + 1 c1 = M.col(0) assert c1 == Matrix([x + 1, 1 + y]) c1[0] = 0 assert M[0, 0] == x + 1 c1 = M[:, 0] c1[0] = 42 assert M[0, 0] == x + 1 def test_zip_row_op(): for cls in classes[:2]: # XXX: immutable matrices don't support row ops M = cls.eye(3) M.zip_row_op(1, 0, lambda v, u: v + 2*u) assert M == cls([[1, 0, 0], [2, 1, 0], [0, 0, 1]]) M = cls.eye(3)*2 M[0, 1] = -1 M.zip_row_op(1, 0, lambda v, u: v + 2*u); M assert M == cls([[2, -1, 0], [4, 0, 0], [0, 0, 2]]) def test_issue_3950(): m = Matrix([1, 2, 3]) a = Matrix([1, 2, 3]) b = Matrix([2, 2, 3]) assert not (m in []) assert not (m in [1]) assert m != 1 assert m == a assert m != b def test_issue_3981(): class Index1(object): def __index__(self): return 1 class Index2(object): def __index__(self): return 2 index1 = Index1() index2 = Index2() m = Matrix([1, 2, 3]) assert m[index2] == 3 m[index2] = 5 assert m[2] == 5 m = Matrix([[1, 2, 3], [4, 5, 6]]) assert m[index1, index2] == 6 assert m[1, index2] == 6 assert m[index1, 2] == 6 m[index1, index2] = 4 assert m[1, 2] == 4 m[1, index2] = 6 assert m[1, 2] == 6 m[index1, 2] = 8 assert m[1, 2] == 8 def test_evalf(): a = Matrix([sqrt(5), 6]) assert all(a.evalf()[i] == a[i].evalf() for i in range(2)) assert all(a.evalf(2)[i] == a[i].evalf(2) for i in range(2)) assert all(a.n(2)[i] == a[i].n(2) for i in range(2)) def test_is_symbolic(): a = Matrix([[x, x], [x, x]]) assert a.is_symbolic() is True a = Matrix([[1, 2, 3, 4], [5, 6, 7, 8]]) assert a.is_symbolic() is False a = Matrix([[1, 2, 3, 4], [5, 6, x, 8]]) assert a.is_symbolic() is True a = Matrix([[1, x, 3]]) assert a.is_symbolic() is True a = Matrix([[1, 2, 3]]) assert a.is_symbolic() is False a = Matrix([[1], [x], [3]]) assert a.is_symbolic() is True a = Matrix([[1], [2], [3]]) assert a.is_symbolic() is False def test_is_upper(): a = Matrix([[1, 2, 3]]) assert a.is_upper is True a = Matrix([[1], [2], [3]]) assert a.is_upper is False a = zeros(4, 2) assert a.is_upper is True def test_is_lower(): a = Matrix([[1, 2, 3]]) assert a.is_lower is False a = Matrix([[1], [2], [3]]) assert a.is_lower is True def test_is_nilpotent(): a = Matrix(4, 4, [0, 2, 1, 6, 0, 0, 1, 2, 0, 0, 0, 3, 0, 0, 0, 0]) assert a.is_nilpotent() a = Matrix([[1, 0], [0, 1]]) assert not a.is_nilpotent() a = Matrix([]) assert a.is_nilpotent() def test_zeros_ones_fill(): n, m = 3, 5 a = zeros(n, m) a.fill( 5 ) b = 5 * ones(n, m) assert a == b assert a.rows == b.rows == 3 assert a.cols == b.cols == 5 assert a.shape == b.shape == (3, 5) assert zeros(2) == zeros(2, 2) assert ones(2) == ones(2, 2) assert zeros(2, 3) == Matrix(2, 3, [0]*6) assert ones(2, 3) == Matrix(2, 3, [1]*6) def test_empty_zeros(): a = zeros(0) assert a == Matrix() a = zeros(0, 2) assert a.rows == 0 assert a.cols == 2 a = zeros(2, 0) assert a.rows == 2 assert a.cols == 0 def test_issue_3749(): a = Matrix([[x**2, x*y], [x*sin(y), x*cos(y)]]) assert a.diff(x) == Matrix([[2*x, y], [sin(y), cos(y)]]) assert Matrix([ [x, -x, x**2], [exp(x), 1/x - exp(-x), x + 1/x]]).limit(x, oo) == \ Matrix([[oo, -oo, oo], [oo, 0, oo]]) assert Matrix([ [(exp(x) - 1)/x, 2*x + y*x, x**x ], [1/x, abs(x), abs(sin(x + 1))]]).limit(x, 0) == \ Matrix([[1, 0, 1], [oo, 0, sin(1)]]) assert a.integrate(x) == Matrix([ [Rational(1, 3)*x**3, y*x**2/2], [x**2*sin(y)/2, x**2*cos(y)/2]]) def test_inv_iszerofunc(): A = eye(4) A.col_swap(0, 1) for method in "GE", "LU": assert A.inv(method=method, iszerofunc=lambda x: x == 0) == \ A.inv(method="ADJ") def test_jacobian_metrics(): rho, phi = symbols("rho,phi") X = Matrix([rho*cos(phi), rho*sin(phi)]) Y = Matrix([rho, phi]) J = X.jacobian(Y) assert J == X.jacobian(Y.T) assert J == (X.T).jacobian(Y) assert J == (X.T).jacobian(Y.T) g = J.T*eye(J.shape[0])*J g = g.applyfunc(trigsimp) assert g == Matrix([[1, 0], [0, rho**2]]) def test_jacobian2(): rho, phi = symbols("rho,phi") X = Matrix([rho*cos(phi), rho*sin(phi), rho**2]) Y = Matrix([rho, phi]) J = Matrix([ [cos(phi), -rho*sin(phi)], [sin(phi), rho*cos(phi)], [ 2*rho, 0], ]) assert X.jacobian(Y) == J def test_issue_4564(): X = Matrix([exp(x + y + z), exp(x + y + z), exp(x + y + z)]) Y = Matrix([x, y, z]) for i in range(1, 3): for j in range(1, 3): X_slice = X[:i, :] Y_slice = Y[:j, :] J = X_slice.jacobian(Y_slice) assert J.rows == i assert J.cols == j for k in range(j): assert J[:, k] == X_slice def test_nonvectorJacobian(): X = Matrix([[exp(x + y + z), exp(x + y + z)], [exp(x + y + z), exp(x + y + z)]]) raises(TypeError, lambda: X.jacobian(Matrix([x, y, z]))) X = X[0, :] Y = Matrix([[x, y], [x, z]]) raises(TypeError, lambda: X.jacobian(Y)) raises(TypeError, lambda: X.jacobian(Matrix([ [x, y], [x, z] ]))) def test_vec(): m = Matrix([[1, 3], [2, 4]]) m_vec = m.vec() assert m_vec.cols == 1 for i in range(4): assert m_vec[i] == i + 1 def test_vech(): m = Matrix([[1, 2], [2, 3]]) m_vech = m.vech() assert m_vech.cols == 1 for i in range(3): assert m_vech[i] == i + 1 m_vech = m.vech(diagonal=False) assert m_vech[0] == 2 m = Matrix([[1, x*(x + y)], [y*x + x**2, 1]]) m_vech = m.vech(diagonal=False) assert m_vech[0] == x*(x + y) m = Matrix([[1, x*(x + y)], [y*x, 1]]) m_vech = m.vech(diagonal=False, check_symmetry=False) assert m_vech[0] == y*x def test_vech_errors(): m = Matrix([[1, 3]]) raises(ShapeError, lambda: m.vech()) m = Matrix([[1, 3], [2, 4]]) raises(ValueError, lambda: m.vech()) raises(ShapeError, lambda: Matrix([ [1, 3] ]).vech()) raises(ValueError, lambda: Matrix([ [1, 3], [2, 4] ]).vech()) def test_diag(): # mostly tested in testcommonmatrix.py assert diag([1, 2, 3]) == Matrix([1, 2, 3]) m = [1, 2, [3]] raises(ValueError, lambda: diag(m)) assert diag(m, strict=False) == Matrix([1, 2, 3]) def test_get_diag_blocks1(): a = Matrix([[1, 2], [2, 3]]) b = Matrix([[3, x], [y, 3]]) c = Matrix([[3, x, 3], [y, 3, z], [x, y, z]]) assert a.get_diag_blocks() == [a] assert b.get_diag_blocks() == [b] assert c.get_diag_blocks() == [c] def test_get_diag_blocks2(): a = Matrix([[1, 2], [2, 3]]) b = Matrix([[3, x], [y, 3]]) c = Matrix([[3, x, 3], [y, 3, z], [x, y, z]]) assert diag(a, b, b).get_diag_blocks() == [a, b, b] assert diag(a, b, c).get_diag_blocks() == [a, b, c] assert diag(a, c, b).get_diag_blocks() == [a, c, b] assert diag(c, c, b).get_diag_blocks() == [c, c, b] def test_inv_block(): a = Matrix([[1, 2], [2, 3]]) b = Matrix([[3, x], [y, 3]]) c = Matrix([[3, x, 3], [y, 3, z], [x, y, z]]) A = diag(a, b, b) assert A.inv(try_block_diag=True) == diag(a.inv(), b.inv(), b.inv()) A = diag(a, b, c) assert A.inv(try_block_diag=True) == diag(a.inv(), b.inv(), c.inv()) A = diag(a, c, b) assert A.inv(try_block_diag=True) == diag(a.inv(), c.inv(), b.inv()) A = diag(a, a, b, a, c, a) assert A.inv(try_block_diag=True) == diag( a.inv(), a.inv(), b.inv(), a.inv(), c.inv(), a.inv()) assert A.inv(try_block_diag=True, method="ADJ") == diag( a.inv(method="ADJ"), a.inv(method="ADJ"), b.inv(method="ADJ"), a.inv(method="ADJ"), c.inv(method="ADJ"), a.inv(method="ADJ")) def test_creation_args(): """ Check that matrix dimensions can be specified using any reasonable type (see issue 4614). """ raises(ValueError, lambda: zeros(3, -1)) raises(TypeError, lambda: zeros(1, 2, 3, 4)) assert zeros(long(3)) == zeros(3) assert zeros(Integer(3)) == zeros(3) raises(ValueError, lambda: zeros(3.)) assert eye(long(3)) == eye(3) assert eye(Integer(3)) == eye(3) raises(ValueError, lambda: eye(3.)) assert ones(long(3), Integer(4)) == ones(3, 4) raises(TypeError, lambda: Matrix(5)) raises(TypeError, lambda: Matrix(1, 2)) raises(ValueError, lambda: Matrix([1, [2]])) def test_diagonal_symmetrical(): m = Matrix(2, 2, [0, 1, 1, 0]) assert not m.is_diagonal() assert m.is_symmetric() assert m.is_symmetric(simplify=False) m = Matrix(2, 2, [1, 0, 0, 1]) assert m.is_diagonal() m = diag(1, 2, 3) assert m.is_diagonal() assert m.is_symmetric() m = Matrix(3, 3, [1, 0, 0, 0, 2, 0, 0, 0, 3]) assert m == diag(1, 2, 3) m = Matrix(2, 3, zeros(2, 3)) assert not m.is_symmetric() assert m.is_diagonal() m = Matrix(((5, 0), (0, 6), (0, 0))) assert m.is_diagonal() m = Matrix(((5, 0, 0), (0, 6, 0))) assert m.is_diagonal() m = Matrix(3, 3, [1, x**2 + 2*x + 1, y, (x + 1)**2, 2, 0, y, 0, 3]) assert m.is_symmetric() assert not m.is_symmetric(simplify=False) assert m.expand().is_symmetric(simplify=False) def test_diagonalization(): m = Matrix(3, 2, [-3, 1, -3, 20, 3, 10]) assert not m.is_diagonalizable() assert not m.is_symmetric() raises(NonSquareMatrixError, lambda: m.diagonalize()) # diagonalizable m = diag(1, 2, 3) (P, D) = m.diagonalize() assert P == eye(3) assert D == m m = Matrix(2, 2, [0, 1, 1, 0]) assert m.is_symmetric() assert m.is_diagonalizable() (P, D) = m.diagonalize() assert P.inv() * m * P == D m = Matrix(2, 2, [1, 0, 0, 3]) assert m.is_symmetric() assert m.is_diagonalizable() (P, D) = m.diagonalize() assert P.inv() * m * P == D assert P == eye(2) assert D == m m = Matrix(2, 2, [1, 1, 0, 0]) assert m.is_diagonalizable() (P, D) = m.diagonalize() assert P.inv() * m * P == D m = Matrix(3, 3, [1, 2, 0, 0, 3, 0, 2, -4, 2]) assert m.is_diagonalizable() (P, D) = m.diagonalize() assert P.inv() * m * P == D for i in P: assert i.as_numer_denom()[1] == 1 m = Matrix(2, 2, [1, 0, 0, 0]) assert m.is_diagonal() assert m.is_diagonalizable() (P, D) = m.diagonalize() assert P.inv() * m * P == D assert P == Matrix([[0, 1], [1, 0]]) # diagonalizable, complex only m = Matrix(2, 2, [0, 1, -1, 0]) assert not m.is_diagonalizable(True) raises(MatrixError, lambda: m.diagonalize(True)) assert m.is_diagonalizable() (P, D) = m.diagonalize() assert P.inv() * m * P == D # not diagonalizable m = Matrix(2, 2, [0, 1, 0, 0]) assert not m.is_diagonalizable() raises(MatrixError, lambda: m.diagonalize()) m = Matrix(3, 3, [-3, 1, -3, 20, 3, 10, 2, -2, 4]) assert not m.is_diagonalizable() raises(MatrixError, lambda: m.diagonalize()) # symbolic a, b, c, d = symbols('a b c d') m = Matrix(2, 2, [a, c, c, b]) assert m.is_symmetric() assert m.is_diagonalizable() def test_issue_15887(): # Mutable matrix should not use cache a = MutableDenseMatrix([[0, 1], [1, 0]]) assert a.is_diagonalizable() is True a[1, 0] = 0 assert a.is_diagonalizable() is False a = MutableDenseMatrix([[0, 1], [1, 0]]) a.diagonalize() a[1, 0] = 0 raises(MatrixError, lambda: a.diagonalize()) # Test deprecated cache and kwargs with warns_deprecated_sympy(): a._cache_eigenvects with warns_deprecated_sympy(): a._cache_is_diagonalizable with warns_deprecated_sympy(): a.is_diagonalizable(clear_cache=True) with warns_deprecated_sympy(): a.is_diagonalizable(clear_subproducts=True) @XFAIL def test_eigen_vects(): m = Matrix(2, 2, [1, 0, 0, I]) raises(NotImplementedError, lambda: m.is_diagonalizable(True)) # !!! bug because of eigenvects() or roots(x**2 + (-1 - I)*x + I, x) # see issue 5292 assert not m.is_diagonalizable(True) raises(MatrixError, lambda: m.diagonalize(True)) (P, D) = m.diagonalize(True) def test_jordan_form(): m = Matrix(3, 2, [-3, 1, -3, 20, 3, 10]) raises(NonSquareMatrixError, lambda: m.jordan_form()) # diagonalizable m = Matrix(3, 3, [7, -12, 6, 10, -19, 10, 12, -24, 13]) Jmust = Matrix(3, 3, [-1, 0, 0, 0, 1, 0, 0, 0, 1]) P, J = m.jordan_form() assert Jmust == J assert Jmust == m.diagonalize()[1] # m = Matrix(3, 3, [0, 6, 3, 1, 3, 1, -2, 2, 1]) # m.jordan_form() # very long # m.jordan_form() # # diagonalizable, complex only # Jordan cells # complexity: one of eigenvalues is zero m = Matrix(3, 3, [0, 1, 0, -4, 4, 0, -2, 1, 2]) # The blocks are ordered according to the value of their eigenvalues, # in order to make the matrix compatible with .diagonalize() Jmust = Matrix(3, 3, [2, 1, 0, 0, 2, 0, 0, 0, 2]) P, J = m.jordan_form() assert Jmust == J # complexity: all of eigenvalues are equal m = Matrix(3, 3, [2, 6, -15, 1, 1, -5, 1, 2, -6]) # Jmust = Matrix(3, 3, [-1, 0, 0, 0, -1, 1, 0, 0, -1]) # same here see 1456ff Jmust = Matrix(3, 3, [-1, 1, 0, 0, -1, 0, 0, 0, -1]) P, J = m.jordan_form() assert Jmust == J # complexity: two of eigenvalues are zero m = Matrix(3, 3, [4, -5, 2, 5, -7, 3, 6, -9, 4]) Jmust = Matrix(3, 3, [0, 1, 0, 0, 0, 0, 0, 0, 1]) P, J = m.jordan_form() assert Jmust == J m = Matrix(4, 4, [6, 5, -2, -3, -3, -1, 3, 3, 2, 1, -2, -3, -1, 1, 5, 5]) Jmust = Matrix(4, 4, [2, 1, 0, 0, 0, 2, 0, 0, 0, 0, 2, 1, 0, 0, 0, 2] ) P, J = m.jordan_form() assert Jmust == J m = Matrix(4, 4, [6, 2, -8, -6, -3, 2, 9, 6, 2, -2, -8, -6, -1, 0, 3, 4]) # Jmust = Matrix(4, 4, [2, 0, 0, 0, 0, 2, 1, 0, 0, 0, 2, 0, 0, 0, 0, -2]) # same here see 1456ff Jmust = Matrix(4, 4, [-2, 0, 0, 0, 0, 2, 1, 0, 0, 0, 2, 0, 0, 0, 0, 2]) P, J = m.jordan_form() assert Jmust == J m = Matrix(4, 4, [5, 4, 2, 1, 0, 1, -1, -1, -1, -1, 3, 0, 1, 1, -1, 2]) assert not m.is_diagonalizable() Jmust = Matrix(4, 4, [1, 0, 0, 0, 0, 2, 0, 0, 0, 0, 4, 1, 0, 0, 0, 4]) P, J = m.jordan_form() assert Jmust == J # checking for maximum precision to remain unchanged m = Matrix([[Float('1.0', precision=110), Float('2.0', precision=110)], [Float('3.14159265358979323846264338327', precision=110), Float('4.0', precision=110)]]) P, J = m.jordan_form() for term in J._mat: if isinstance(term, Float): assert term._prec == 110 def test_jordan_form_complex_issue_9274(): A = Matrix([[ 2, 4, 1, 0], [-4, 2, 0, 1], [ 0, 0, 2, 4], [ 0, 0, -4, 2]]) p = 2 - 4*I; q = 2 + 4*I; Jmust1 = Matrix([[p, 1, 0, 0], [0, p, 0, 0], [0, 0, q, 1], [0, 0, 0, q]]) Jmust2 = Matrix([[q, 1, 0, 0], [0, q, 0, 0], [0, 0, p, 1], [0, 0, 0, p]]) P, J = A.jordan_form() assert J == Jmust1 or J == Jmust2 assert simplify(P*J*P.inv()) == A def test_issue_10220(): # two non-orthogonal Jordan blocks with eigenvalue 1 M = Matrix([[1, 0, 0, 1], [0, 1, 1, 0], [0, 0, 1, 1], [0, 0, 0, 1]]) P, J = M.jordan_form() assert P == Matrix([[0, 1, 0, 1], [1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 0]]) assert J == Matrix([ [1, 1, 0, 0], [0, 1, 1, 0], [0, 0, 1, 0], [0, 0, 0, 1]]) def test_jordan_form_issue_15858(): A = Matrix([ [1, 1, 1, 0], [-2, -1, 0, -1], [0, 0, -1, -1], [0, 0, 2, 1]]) (P, J) = A.jordan_form() assert simplify(P) == Matrix([ [-I, -I/2, I, I/2], [-1 + I, 0, -1 - I, 0], [0, I*(-1 + I)/2, 0, I*(1 + I)/2], [0, 1, 0, 1]]) assert J == Matrix([ [-I, 1, 0, 0], [0, -I, 0, 0], [0, 0, I, 1], [0, 0, 0, I]]) def test_Matrix_berkowitz_charpoly(): UA, K_i, K_w = symbols('UA K_i K_w') A = Matrix([[-K_i - UA + K_i**2/(K_i + K_w), K_i*K_w/(K_i + K_w)], [ K_i*K_w/(K_i + K_w), -K_w + K_w**2/(K_i + K_w)]]) charpoly = A.charpoly(x) assert charpoly == \ Poly(x**2 + (K_i*UA + K_w*UA + 2*K_i*K_w)/(K_i + K_w)*x + K_i*K_w*UA/(K_i + K_w), x, domain='ZZ(K_i,K_w,UA)') assert type(charpoly) is PurePoly A = Matrix([[1, 3], [2, 0]]) assert A.charpoly() == A.charpoly(x) == PurePoly(x**2 - x - 6) A = Matrix([[1, 2], [x, 0]]) p = A.charpoly(x) assert p.gen != x assert p.as_expr().subs(p.gen, x) == x**2 - 3*x def test_exp(): m = Matrix([[3, 4], [0, -2]]) m_exp = Matrix([[exp(3), -4*exp(-2)/5 + 4*exp(3)/5], [0, exp(-2)]]) assert m.exp() == m_exp assert exp(m) == m_exp m = Matrix([[1, 0], [0, 1]]) assert m.exp() == Matrix([[E, 0], [0, E]]) assert exp(m) == Matrix([[E, 0], [0, E]]) m = Matrix([[1, -1], [1, 1]]) assert m.exp() == Matrix([[E*cos(1), -E*sin(1)], [E*sin(1), E*cos(1)]]) def test_has(): A = Matrix(((x, y), (2, 3))) assert A.has(x) assert not A.has(z) assert A.has(Symbol) A = A.subs(x, 2) assert not A.has(x) def test_LUdecomposition_Simple_iszerofunc(): # Test if callable passed to matrices.LUdecomposition_Simple() as iszerofunc keyword argument is used inside # matrices.LUdecomposition_Simple() magic_string = "I got passed in!" def goofyiszero(value): raise ValueError(magic_string) try: lu, p = Matrix([[1, 0], [0, 1]]).LUdecomposition_Simple(iszerofunc=goofyiszero) except ValueError as err: assert magic_string == err.args[0] return assert False def test_LUdecomposition_iszerofunc(): # Test if callable passed to matrices.LUdecomposition() as iszerofunc keyword argument is used inside # matrices.LUdecomposition_Simple() magic_string = "I got passed in!" def goofyiszero(value): raise ValueError(magic_string) try: l, u, p = Matrix([[1, 0], [0, 1]]).LUdecomposition(iszerofunc=goofyiszero) except ValueError as err: assert magic_string == err.args[0] return assert False def test_find_reasonable_pivot_naive_finds_guaranteed_nonzero1(): # Test if matrices._find_reasonable_pivot_naive() # finds a guaranteed non-zero pivot when the # some of the candidate pivots are symbolic expressions. # Keyword argument: simpfunc=None indicates that no simplifications # should be performed during the search. x = Symbol('x') column = Matrix(3, 1, [x, cos(x)**2 + sin(x)**2, Rational(1, 2)]) pivot_offset, pivot_val, pivot_assumed_nonzero, simplified =\ _find_reasonable_pivot_naive(column) assert pivot_val == Rational(1, 2) def test_find_reasonable_pivot_naive_finds_guaranteed_nonzero2(): # Test if matrices._find_reasonable_pivot_naive() # finds a guaranteed non-zero pivot when the # some of the candidate pivots are symbolic expressions. # Keyword argument: simpfunc=_simplify indicates that the search # should attempt to simplify candidate pivots. x = Symbol('x') column = Matrix(3, 1, [x, cos(x)**2+sin(x)**2+x**2, cos(x)**2+sin(x)**2]) pivot_offset, pivot_val, pivot_assumed_nonzero, simplified =\ _find_reasonable_pivot_naive(column, simpfunc=_simplify) assert pivot_val == 1 def test_find_reasonable_pivot_naive_simplifies(): # Test if matrices._find_reasonable_pivot_naive() # simplifies candidate pivots, and reports # their offsets correctly. x = Symbol('x') column = Matrix(3, 1, [x, cos(x)**2+sin(x)**2+x, cos(x)**2+sin(x)**2]) pivot_offset, pivot_val, pivot_assumed_nonzero, simplified =\ _find_reasonable_pivot_naive(column, simpfunc=_simplify) assert len(simplified) == 2 assert simplified[0][0] == 1 assert simplified[0][1] == 1+x assert simplified[1][0] == 2 assert simplified[1][1] == 1 def test_errors(): raises(ValueError, lambda: Matrix([[1, 2], [1]])) raises(IndexError, lambda: Matrix([[1, 2]])[1.2, 5]) raises(IndexError, lambda: Matrix([[1, 2]])[1, 5.2]) raises(ValueError, lambda: randMatrix(3, c=4, symmetric=True)) raises(ValueError, lambda: Matrix([1, 2]).reshape(4, 6)) raises(ShapeError, lambda: Matrix([[1, 2], [3, 4]]).copyin_matrix([1, 0], Matrix([1, 2]))) raises(TypeError, lambda: Matrix([[1, 2], [3, 4]]).copyin_list([0, 1], set([]))) raises(NonSquareMatrixError, lambda: Matrix([[1, 2, 3], [2, 3, 0]]).inv()) raises(ShapeError, lambda: Matrix(1, 2, [1, 2]).row_join(Matrix([[1, 2], [3, 4]]))) raises( ShapeError, lambda: Matrix([1, 2]).col_join(Matrix([[1, 2], [3, 4]]))) raises(ShapeError, lambda: Matrix([1]).row_insert(1, Matrix([[1, 2], [3, 4]]))) raises(ShapeError, lambda: Matrix([1]).col_insert(1, Matrix([[1, 2], [3, 4]]))) raises(NonSquareMatrixError, lambda: Matrix([1, 2]).trace()) raises(TypeError, lambda: Matrix([1]).applyfunc(1)) raises(ShapeError, lambda: Matrix([1]).LUsolve(Matrix([[1, 2], [3, 4]]))) raises(ValueError, lambda: Matrix([[1, 2], [3, 4]]).minor(4, 5)) raises(ValueError, lambda: Matrix([[1, 2], [3, 4]]).minor_submatrix(4, 5)) raises(TypeError, lambda: Matrix([1, 2, 3]).cross(1)) raises(TypeError, lambda: Matrix([1, 2, 3]).dot(1)) raises(ShapeError, lambda: Matrix([1, 2, 3]).dot(Matrix([1, 2]))) raises(ShapeError, lambda: Matrix([1, 2]).dot([])) raises(TypeError, lambda: Matrix([1, 2]).dot('a')) with warns_deprecated_sympy(): Matrix([[1, 2], [3, 4]]).dot(Matrix([[4, 3], [1, 2]])) raises(ShapeError, lambda: Matrix([1, 2]).dot([1, 2, 3])) raises(NonSquareMatrixError, lambda: Matrix([1, 2, 3]).exp()) raises(ShapeError, lambda: Matrix([[1, 2], [3, 4]]).normalized()) raises(ValueError, lambda: Matrix([1, 2]).inv(method='not a method')) raises(NonSquareMatrixError, lambda: Matrix([1, 2]).inverse_GE()) raises(ValueError, lambda: Matrix([[1, 2], [1, 2]]).inverse_GE()) raises(NonSquareMatrixError, lambda: Matrix([1, 2]).inverse_ADJ()) raises(ValueError, lambda: Matrix([[1, 2], [1, 2]]).inverse_ADJ()) raises(NonSquareMatrixError, lambda: Matrix([1, 2]).inverse_LU()) raises(NonSquareMatrixError, lambda: Matrix([1, 2]).is_nilpotent()) raises(NonSquareMatrixError, lambda: Matrix([1, 2]).det()) raises(ValueError, lambda: Matrix([[1, 2], [3, 4]]).det(method='Not a real method')) raises(ValueError, lambda: Matrix([[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12], [13, 14, 15, 16]]).det(iszerofunc="Not function")) raises(ValueError, lambda: Matrix([[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12], [13, 14, 15, 16]]).det(iszerofunc=False)) raises(ValueError, lambda: hessian(Matrix([[1, 2], [3, 4]]), Matrix([[1, 2], [2, 1]]))) raises(ValueError, lambda: hessian(Matrix([[1, 2], [3, 4]]), [])) raises(ValueError, lambda: hessian(Symbol('x')**2, 'a')) raises(IndexError, lambda: eye(3)[5, 2]) raises(IndexError, lambda: eye(3)[2, 5]) M = Matrix(((1, 2, 3, 4), (5, 6, 7, 8), (9, 10, 11, 12), (13, 14, 15, 16))) raises(ValueError, lambda: M.det('method=LU_decomposition()')) V = Matrix([[10, 10, 10]]) M = Matrix([[1, 2, 3], [2, 3, 4], [3, 4, 5]]) raises(ValueError, lambda: M.row_insert(4.7, V)) M = Matrix([[1, 2, 3], [2, 3, 4], [3, 4, 5]]) raises(ValueError, lambda: M.col_insert(-4.2, V)) def test_len(): assert len(Matrix()) == 0 assert len(Matrix([[1, 2]])) == len(Matrix([[1], [2]])) == 2 assert len(Matrix(0, 2, lambda i, j: 0)) == \ len(Matrix(2, 0, lambda i, j: 0)) == 0 assert len(Matrix([[0, 1, 2], [3, 4, 5]])) == 6 assert Matrix([1]) == Matrix([[1]]) assert not Matrix() assert Matrix() == Matrix([]) def test_integrate(): A = Matrix(((1, 4, x), (y, 2, 4), (10, 5, x**2))) assert A.integrate(x) == \ Matrix(((x, 4*x, x**2/2), (x*y, 2*x, 4*x), (10*x, 5*x, x**3/3))) assert A.integrate(y) == \ Matrix(((y, 4*y, x*y), (y**2/2, 2*y, 4*y), (10*y, 5*y, y*x**2))) def test_limit(): A = Matrix(((1, 4, sin(x)/x), (y, 2, 4), (10, 5, x**2 + 1))) assert A.limit(x, 0) == Matrix(((1, 4, 1), (y, 2, 4), (10, 5, 1))) def test_diff(): A = MutableDenseMatrix(((1, 4, x), (y, 2, 4), (10, 5, x**2 + 1))) assert isinstance(A.diff(x), type(A)) assert A.diff(x) == MutableDenseMatrix(((0, 0, 1), (0, 0, 0), (0, 0, 2*x))) assert A.diff(y) == MutableDenseMatrix(((0, 0, 0), (1, 0, 0), (0, 0, 0))) assert diff(A, x) == MutableDenseMatrix(((0, 0, 1), (0, 0, 0), (0, 0, 2*x))) assert diff(A, y) == MutableDenseMatrix(((0, 0, 0), (1, 0, 0), (0, 0, 0))) A_imm = A.as_immutable() assert isinstance(A_imm.diff(x), type(A_imm)) assert A_imm.diff(x) == ImmutableDenseMatrix(((0, 0, 1), (0, 0, 0), (0, 0, 2*x))) assert A_imm.diff(y) == ImmutableDenseMatrix(((0, 0, 0), (1, 0, 0), (0, 0, 0))) assert diff(A_imm, x) == ImmutableDenseMatrix(((0, 0, 1), (0, 0, 0), (0, 0, 2*x))) assert diff(A_imm, y) == ImmutableDenseMatrix(((0, 0, 0), (1, 0, 0), (0, 0, 0))) def test_diff_by_matrix(): # Derive matrix by matrix: A = MutableDenseMatrix([[x, y], [z, t]]) assert A.diff(A) == Array([[[[1, 0], [0, 0]], [[0, 1], [0, 0]]], [[[0, 0], [1, 0]], [[0, 0], [0, 1]]]]) assert diff(A, A) == Array([[[[1, 0], [0, 0]], [[0, 1], [0, 0]]], [[[0, 0], [1, 0]], [[0, 0], [0, 1]]]]) A_imm = A.as_immutable() assert A_imm.diff(A_imm) == Array([[[[1, 0], [0, 0]], [[0, 1], [0, 0]]], [[[0, 0], [1, 0]], [[0, 0], [0, 1]]]]) assert diff(A_imm, A_imm) == Array([[[[1, 0], [0, 0]], [[0, 1], [0, 0]]], [[[0, 0], [1, 0]], [[0, 0], [0, 1]]]]) # Derive a constant matrix: assert A.diff(a) == MutableDenseMatrix([[0, 0], [0, 0]]) B = ImmutableDenseMatrix([a, b]) assert A.diff(B) == Array.zeros(2, 1, 2, 2) assert A.diff(A) == Array([[[[1, 0], [0, 0]], [[0, 1], [0, 0]]], [[[0, 0], [1, 0]], [[0, 0], [0, 1]]]]) # Test diff with tuples: dB = B.diff([[a, b]]) assert dB.shape == (2, 2, 1) assert dB == Array([[[1], [0]], [[0], [1]]]) f = Function("f") fxyz = f(x, y, z) assert fxyz.diff([[x, y, z]]) == Array([fxyz.diff(x), fxyz.diff(y), fxyz.diff(z)]) assert fxyz.diff(([x, y, z], 2)) == Array([ [fxyz.diff(x, 2), fxyz.diff(x, y), fxyz.diff(x, z)], [fxyz.diff(x, y), fxyz.diff(y, 2), fxyz.diff(y, z)], [fxyz.diff(x, z), fxyz.diff(z, y), fxyz.diff(z, 2)], ]) expr = sin(x)*exp(y) assert expr.diff([[x, y]]) == Array([cos(x)*exp(y), sin(x)*exp(y)]) assert expr.diff(y, ((x, y),)) == Array([cos(x)*exp(y), sin(x)*exp(y)]) assert expr.diff(x, ((x, y),)) == Array([-sin(x)*exp(y), cos(x)*exp(y)]) assert expr.diff(((y, x),), [[x, y]]) == Array([[cos(x)*exp(y), -sin(x)*exp(y)], [sin(x)*exp(y), cos(x)*exp(y)]]) # Test different notations: fxyz.diff(x).diff(y).diff(x) == fxyz.diff(((x, y, z),), 3)[0, 1, 0] fxyz.diff(z).diff(y).diff(x) == fxyz.diff(((x, y, z),), 3)[2, 1, 0] fxyz.diff([[x, y, z]], ((z, y, x),)) == Array([[fxyz.diff(i).diff(j) for i in (x, y, z)] for j in (z, y, x)]) # Test scalar derived by matrix remains matrix: res = x.diff(Matrix([[x, y]])) assert isinstance(res, ImmutableDenseMatrix) assert res == Matrix([[1, 0]]) res = (x**3).diff(Matrix([[x, y]])) assert isinstance(res, ImmutableDenseMatrix) assert res == Matrix([[3*x**2, 0]]) def test_getattr(): A = Matrix(((1, 4, x), (y, 2, 4), (10, 5, x**2 + 1))) raises(AttributeError, lambda: A.nonexistantattribute) assert getattr(A, 'diff')(x) == Matrix(((0, 0, 1), (0, 0, 0), (0, 0, 2*x))) def test_hessenberg(): A = Matrix([[3, 4, 1], [2, 4, 5], [0, 1, 2]]) assert A.is_upper_hessenberg A = A.T assert A.is_lower_hessenberg A[0, -1] = 1 assert A.is_lower_hessenberg is False A = Matrix([[3, 4, 1], [2, 4, 5], [3, 1, 2]]) assert not A.is_upper_hessenberg A = zeros(5, 2) assert A.is_upper_hessenberg def test_cholesky(): raises(NonSquareMatrixError, lambda: Matrix((1, 2)).cholesky()) raises(ValueError, lambda: Matrix(((1, 2), (3, 4))).cholesky()) raises(ValueError, lambda: Matrix(((5 + I, 0), (0, 1))).cholesky()) raises(ValueError, lambda: Matrix(((1, 5), (5, 1))).cholesky()) raises(ValueError, lambda: Matrix(((1, 2), (3, 4))).cholesky(hermitian=False)) assert Matrix(((5 + I, 0), (0, 1))).cholesky(hermitian=False) == Matrix([ [sqrt(5 + I), 0], [0, 1]]) A = Matrix(((1, 5), (5, 1))) L = A.cholesky(hermitian=False) assert L == Matrix([[1, 0], [5, 2*sqrt(6)*I]]) assert L*L.T == A A = Matrix(((25, 15, -5), (15, 18, 0), (-5, 0, 11))) L = A.cholesky() assert L * L.T == A assert L.is_lower assert L == Matrix([[5, 0, 0], [3, 3, 0], [-1, 1, 3]]) A = Matrix(((4, -2*I, 2 + 2*I), (2*I, 2, -1 + I), (2 - 2*I, -1 - I, 11))) assert A.cholesky() == Matrix(((2, 0, 0), (I, 1, 0), (1 - I, 0, 3))) def test_LDLdecomposition(): raises(NonSquareMatrixError, lambda: Matrix((1, 2)).LDLdecomposition()) raises(ValueError, lambda: Matrix(((1, 2), (3, 4))).LDLdecomposition()) raises(ValueError, lambda: Matrix(((5 + I, 0), (0, 1))).LDLdecomposition()) raises(ValueError, lambda: Matrix(((1, 5), (5, 1))).LDLdecomposition()) raises(ValueError, lambda: Matrix(((1, 2), (3, 4))).LDLdecomposition(hermitian=False)) A = Matrix(((1, 5), (5, 1))) L, D = A.LDLdecomposition(hermitian=False) assert L * D * L.T == A A = Matrix(((25, 15, -5), (15, 18, 0), (-5, 0, 11))) L, D = A.LDLdecomposition() assert L * D * L.T == A assert L.is_lower assert L == Matrix([[1, 0, 0], [ S(3)/5, 1, 0], [S(-1)/5, S(1)/3, 1]]) assert D.is_diagonal() assert D == Matrix([[25, 0, 0], [0, 9, 0], [0, 0, 9]]) A = Matrix(((4, -2*I, 2 + 2*I), (2*I, 2, -1 + I), (2 - 2*I, -1 - I, 11))) L, D = A.LDLdecomposition() assert expand_mul(L * D * L.H) == A assert L == Matrix(((1, 0, 0), (I/2, 1, 0), (S(1)/2 - I/2, 0, 1))) assert D == Matrix(((4, 0, 0), (0, 1, 0), (0, 0, 9))) def test_cholesky_solve(): A = Matrix([[2, 3, 5], [3, 6, 2], [8, 3, 6]]) x = Matrix(3, 1, [3, 7, 5]) b = A*x soln = A.cholesky_solve(b) assert soln == x A = Matrix([[0, -1, 2], [5, 10, 7], [8, 3, 4]]) x = Matrix(3, 1, [-1, 2, 5]) b = A*x soln = A.cholesky_solve(b) assert soln == x A = Matrix(((1, 5), (5, 1))) x = Matrix((4, -3)) b = A*x soln = A.cholesky_solve(b) assert soln == x A = Matrix(((9, 3*I), (-3*I, 5))) x = Matrix((-2, 1)) b = A*x soln = A.cholesky_solve(b) assert expand_mul(soln) == x A = Matrix(((9*I, 3), (-3 + I, 5))) x = Matrix((2 + 3*I, -1)) b = A*x soln = A.cholesky_solve(b) assert expand_mul(soln) == x a00, a01, a11, b0, b1 = symbols('a00, a01, a11, b0, b1') A = Matrix(((a00, a01), (a01, a11))) b = Matrix((b0, b1)) x = A.cholesky_solve(b) assert simplify(A*x) == b def test_LDLsolve(): A = Matrix([[2, 3, 5], [3, 6, 2], [8, 3, 6]]) x = Matrix(3, 1, [3, 7, 5]) b = A*x soln = A.LDLsolve(b) assert soln == x A = Matrix([[0, -1, 2], [5, 10, 7], [8, 3, 4]]) x = Matrix(3, 1, [-1, 2, 5]) b = A*x soln = A.LDLsolve(b) assert soln == x A = Matrix(((9, 3*I), (-3*I, 5))) x = Matrix((-2, 1)) b = A*x soln = A.LDLsolve(b) assert expand_mul(soln) == x A = Matrix(((9*I, 3), (-3 + I, 5))) x = Matrix((2 + 3*I, -1)) b = A*x soln = A.LDLsolve(b) assert expand_mul(soln) == x A = Matrix(((9, 3), (3, 9))) x = Matrix((1, 1)) b = A * x soln = A.LDLsolve(b) assert expand_mul(soln) == x A = Matrix([[-5, -3, -4], [-3, -7, 7]]) x = Matrix([[8], [7], [-2]]) b = A * x raises(NotImplementedError, lambda: A.LDLsolve(b)) def test_lower_triangular_solve(): raises(NonSquareMatrixError, lambda: Matrix([1, 0]).lower_triangular_solve(Matrix([0, 1]))) raises(ShapeError, lambda: Matrix([[1, 0], [0, 1]]).lower_triangular_solve(Matrix([1]))) raises(ValueError, lambda: Matrix([[2, 1], [1, 2]]).lower_triangular_solve( Matrix([[1, 0], [0, 1]]))) A = Matrix([[1, 0], [0, 1]]) B = Matrix([[x, y], [y, x]]) C = Matrix([[4, 8], [2, 9]]) assert A.lower_triangular_solve(B) == B assert A.lower_triangular_solve(C) == C def test_upper_triangular_solve(): raises(NonSquareMatrixError, lambda: Matrix([1, 0]).upper_triangular_solve(Matrix([0, 1]))) raises(TypeError, lambda: Matrix([[1, 0], [0, 1]]).upper_triangular_solve(Matrix([1]))) raises(TypeError, lambda: Matrix([[2, 1], [1, 2]]).upper_triangular_solve( Matrix([[1, 0], [0, 1]]))) A = Matrix([[1, 0], [0, 1]]) B = Matrix([[x, y], [y, x]]) C = Matrix([[2, 4], [3, 8]]) assert A.upper_triangular_solve(B) == B assert A.upper_triangular_solve(C) == C def test_diagonal_solve(): raises(TypeError, lambda: Matrix([1, 1]).diagonal_solve(Matrix([1]))) A = Matrix([[1, 0], [0, 1]])*2 B = Matrix([[x, y], [y, x]]) assert A.diagonal_solve(B) == B/2 A = Matrix([[1, 0], [1, 2]]) raises(TypeError, lambda: A.diagonal_solve(B)) def test_matrix_norm(): # Vector Tests # Test columns and symbols x = Symbol('x', real=True) v = Matrix([cos(x), sin(x)]) assert trigsimp(v.norm(2)) == 1 assert v.norm(10) == Pow(cos(x)**10 + sin(x)**10, S(1)/10) # Test Rows A = Matrix([[5, Rational(3, 2)]]) assert A.norm() == Pow(25 + Rational(9, 4), S(1)/2) assert A.norm(oo) == max(A._mat) assert A.norm(-oo) == min(A._mat) # Matrix Tests # Intuitive test A = Matrix([[1, 1], [1, 1]]) assert A.norm(2) == 2 assert A.norm(-2) == 0 assert A.norm('frobenius') == 2 assert eye(10).norm(2) == eye(10).norm(-2) == 1 assert A.norm(oo) == 2 # Test with Symbols and more complex entries A = Matrix([[3, y, y], [x, S(1)/2, -pi]]) assert (A.norm('fro') == sqrt(S(37)/4 + 2*abs(y)**2 + pi**2 + x**2)) # Check non-square A = Matrix([[1, 2, -3], [4, 5, Rational(13, 2)]]) assert A.norm(2) == sqrt(S(389)/8 + sqrt(78665)/8) assert A.norm(-2) == S(0) assert A.norm('frobenius') == sqrt(389)/2 # Test properties of matrix norms # https://en.wikipedia.org/wiki/Matrix_norm#Definition # Two matrices A = Matrix([[1, 2], [3, 4]]) B = Matrix([[5, 5], [-2, 2]]) C = Matrix([[0, -I], [I, 0]]) D = Matrix([[1, 0], [0, -1]]) L = [A, B, C, D] alpha = Symbol('alpha', real=True) for order in ['fro', 2, -2]: # Zero Check assert zeros(3).norm(order) == S(0) # Check Triangle Inequality for all Pairs of Matrices for X in L: for Y in L: dif = (X.norm(order) + Y.norm(order) - (X + Y).norm(order)) assert (dif >= 0) # Scalar multiplication linearity for M in [A, B, C, D]: dif = simplify((alpha*M).norm(order) - abs(alpha) * M.norm(order)) assert dif == 0 # Test Properties of Vector Norms # https://en.wikipedia.org/wiki/Vector_norm # Two column vectors a = Matrix([1, 1 - 1*I, -3]) b = Matrix([S(1)/2, 1*I, 1]) c = Matrix([-1, -1, -1]) d = Matrix([3, 2, I]) e = Matrix([Integer(1e2), Rational(1, 1e2), 1]) L = [a, b, c, d, e] alpha = Symbol('alpha', real=True) for order in [1, 2, -1, -2, S.Infinity, S.NegativeInfinity, pi]: # Zero Check if order > 0: assert Matrix([0, 0, 0]).norm(order) == S(0) # Triangle inequality on all pairs if order >= 1: # Triangle InEq holds only for these norms for X in L: for Y in L: dif = (X.norm(order) + Y.norm(order) - (X + Y).norm(order)) assert simplify(dif >= 0) is S.true # Linear to scalar multiplication if order in [1, 2, -1, -2, S.Infinity, S.NegativeInfinity]: for X in L: dif = simplify((alpha*X).norm(order) - (abs(alpha) * X.norm(order))) assert dif == 0 # ord=1 M = Matrix(3, 3, [1, 3, 0, -2, -1, 0, 3, 9, 6]) assert M.norm(1) == 13 def test_condition_number(): x = Symbol('x', real=True) A = eye(3) A[0, 0] = 10 A[2, 2] = S(1)/10 assert A.condition_number() == 100 A[1, 1] = x assert A.condition_number() == Max(10, Abs(x)) / Min(S(1)/10, Abs(x)) M = Matrix([[cos(x), sin(x)], [-sin(x), cos(x)]]) Mc = M.condition_number() assert all(Float(1.).epsilon_eq(Mc.subs(x, val).evalf()) for val in [Rational(1, 5), Rational(1, 2), Rational(1, 10), pi/2, pi, 7*pi/4 ]) #issue 10782 assert Matrix([]).condition_number() == 0 def test_equality(): A = Matrix(((1, 2, 3), (4, 5, 6), (7, 8, 9))) B = Matrix(((9, 8, 7), (6, 5, 4), (3, 2, 1))) assert A == A[:, :] assert not A != A[:, :] assert not A == B assert A != B assert A != 10 assert not A == 10 # A SparseMatrix can be equal to a Matrix C = SparseMatrix(((1, 0, 0), (0, 1, 0), (0, 0, 1))) D = Matrix(((1, 0, 0), (0, 1, 0), (0, 0, 1))) assert C == D assert not C != D def test_col_join(): assert eye(3).col_join(Matrix([[7, 7, 7]])) == \ Matrix([[1, 0, 0], [0, 1, 0], [0, 0, 1], [7, 7, 7]]) def test_row_insert(): r4 = Matrix([[4, 4, 4]]) for i in range(-4, 5): l = [1, 0, 0] l.insert(i, 4) assert flatten(eye(3).row_insert(i, r4).col(0).tolist()) == l def test_col_insert(): c4 = Matrix([4, 4, 4]) for i in range(-4, 5): l = [0, 0, 0] l.insert(i, 4) assert flatten(zeros(3).col_insert(i, c4).row(0).tolist()) == l def test_normalized(): assert Matrix([3, 4]).normalized() == \ Matrix([Rational(3, 5), Rational(4, 5)]) # Zero vector trivial cases assert Matrix([0, 0, 0]).normalized() == Matrix([0, 0, 0]) # Machine precision error truncation trivial cases m = Matrix([0,0,1.e-100]) assert m.normalized( iszerofunc=lambda x: x.evalf(n=10, chop=True).is_zero ) == Matrix([0, 0, 0]) def test_print_nonzero(): assert capture(lambda: eye(3).print_nonzero()) == \ '[X ]\n[ X ]\n[ X]\n' assert capture(lambda: eye(3).print_nonzero('.')) == \ '[. ]\n[ . ]\n[ .]\n' def test_zeros_eye(): assert Matrix.eye(3) == eye(3) assert Matrix.zeros(3) == zeros(3) assert ones(3, 4) == Matrix(3, 4, [1]*12) i = Matrix([[1, 0], [0, 1]]) z = Matrix([[0, 0], [0, 0]]) for cls in classes: m = cls.eye(2) assert i == m # but m == i will fail if m is immutable assert i == eye(2, cls=cls) assert type(m) == cls m = cls.zeros(2) assert z == m assert z == zeros(2, cls=cls) assert type(m) == cls def test_is_zero(): assert Matrix().is_zero assert Matrix([[0, 0], [0, 0]]).is_zero assert zeros(3, 4).is_zero assert not eye(3).is_zero assert Matrix([[x, 0], [0, 0]]).is_zero == None assert SparseMatrix([[x, 0], [0, 0]]).is_zero == None assert ImmutableMatrix([[x, 0], [0, 0]]).is_zero == None assert ImmutableSparseMatrix([[x, 0], [0, 0]]).is_zero == None assert Matrix([[x, 1], [0, 0]]).is_zero == False a = Symbol('a', nonzero=True) assert Matrix([[a, 0], [0, 0]]).is_zero == False def test_rotation_matrices(): # This tests the rotation matrices by rotating about an axis and back. theta = pi/3 r3_plus = rot_axis3(theta) r3_minus = rot_axis3(-theta) r2_plus = rot_axis2(theta) r2_minus = rot_axis2(-theta) r1_plus = rot_axis1(theta) r1_minus = rot_axis1(-theta) assert r3_minus*r3_plus*eye(3) == eye(3) assert r2_minus*r2_plus*eye(3) == eye(3) assert r1_minus*r1_plus*eye(3) == eye(3) # Check the correctness of the trace of the rotation matrix assert r1_plus.trace() == 1 + 2*cos(theta) assert r2_plus.trace() == 1 + 2*cos(theta) assert r3_plus.trace() == 1 + 2*cos(theta) # Check that a rotation with zero angle doesn't change anything. assert rot_axis1(0) == eye(3) assert rot_axis2(0) == eye(3) assert rot_axis3(0) == eye(3) def test_DeferredVector(): assert str(DeferredVector("vector")[4]) == "vector[4]" assert sympify(DeferredVector("d")) == DeferredVector("d") raises(IndexError, lambda: DeferredVector("d")[-1]) assert str(DeferredVector("d")) == "d" assert repr(DeferredVector("test")) == "DeferredVector('test')" def test_DeferredVector_not_iterable(): assert not iterable(DeferredVector('X')) def test_DeferredVector_Matrix(): raises(TypeError, lambda: Matrix(DeferredVector("V"))) def test_GramSchmidt(): R = Rational m1 = Matrix(1, 2, [1, 2]) m2 = Matrix(1, 2, [2, 3]) assert GramSchmidt([m1, m2]) == \ [Matrix(1, 2, [1, 2]), Matrix(1, 2, [R(2)/5, R(-1)/5])] assert GramSchmidt([m1.T, m2.T]) == \ [Matrix(2, 1, [1, 2]), Matrix(2, 1, [R(2)/5, R(-1)/5])] # from wikipedia assert GramSchmidt([Matrix([3, 1]), Matrix([2, 2])], True) == [ Matrix([3*sqrt(10)/10, sqrt(10)/10]), Matrix([-sqrt(10)/10, 3*sqrt(10)/10])] def test_casoratian(): assert casoratian([1, 2, 3, 4], 1) == 0 assert casoratian([1, 2, 3, 4], 1, zero=False) == 0 def test_zero_dimension_multiply(): assert (Matrix()*zeros(0, 3)).shape == (0, 3) assert zeros(3, 0)*zeros(0, 3) == zeros(3, 3) assert zeros(0, 3)*zeros(3, 0) == Matrix() def test_slice_issue_2884(): m = Matrix(2, 2, range(4)) assert m[1, :] == Matrix([[2, 3]]) assert m[-1, :] == Matrix([[2, 3]]) assert m[:, 1] == Matrix([[1, 3]]).T assert m[:, -1] == Matrix([[1, 3]]).T raises(IndexError, lambda: m[2, :]) raises(IndexError, lambda: m[2, 2]) def test_slice_issue_3401(): assert zeros(0, 3)[:, -1].shape == (0, 1) assert zeros(3, 0)[0, :] == Matrix(1, 0, []) def test_copyin(): s = zeros(3, 3) s[3] = 1 assert s[:, 0] == Matrix([0, 1, 0]) assert s[3] == 1 assert s[3: 4] == [1] s[1, 1] = 42 assert s[1, 1] == 42 assert s[1, 1:] == Matrix([[42, 0]]) s[1, 1:] = Matrix([[5, 6]]) assert s[1, :] == Matrix([[1, 5, 6]]) s[1, 1:] = [[42, 43]] assert s[1, :] == Matrix([[1, 42, 43]]) s[0, 0] = 17 assert s[:, :1] == Matrix([17, 1, 0]) s[0, 0] = [1, 1, 1] assert s[:, 0] == Matrix([1, 1, 1]) s[0, 0] = Matrix([1, 1, 1]) assert s[:, 0] == Matrix([1, 1, 1]) s[0, 0] = SparseMatrix([1, 1, 1]) assert s[:, 0] == Matrix([1, 1, 1]) def test_invertible_check(): # sometimes a singular matrix will have a pivot vector shorter than # the number of rows in a matrix... assert Matrix([[1, 2], [1, 2]]).rref() == (Matrix([[1, 2], [0, 0]]), (0,)) raises(ValueError, lambda: Matrix([[1, 2], [1, 2]]).inv()) m = Matrix([ [-1, -1, 0], [ x, 1, 1], [ 1, x, -1], ]) assert len(m.rref()[1]) != m.rows # in addition, unless simplify=True in the call to rref, the identity # matrix will be returned even though m is not invertible assert m.rref()[0] != eye(3) assert m.rref(simplify=signsimp)[0] != eye(3) raises(ValueError, lambda: m.inv(method="ADJ")) raises(ValueError, lambda: m.inv(method="GE")) raises(ValueError, lambda: m.inv(method="LU")) def test_issue_3959(): x, y = symbols('x, y') e = x*y assert e.subs(x, Matrix([3, 5, 3])) == Matrix([3, 5, 3])*y def test_issue_5964(): assert str(Matrix([[1, 2], [3, 4]])) == 'Matrix([[1, 2], [3, 4]])' def test_issue_7604(): x, y = symbols(u"x y") assert sstr(Matrix([[x, 2*y], [y**2, x + 3]])) == \ 'Matrix([\n[ x, 2*y],\n[y**2, x + 3]])' def test_is_Identity(): assert eye(3).is_Identity assert eye(3).as_immutable().is_Identity assert not zeros(3).is_Identity assert not ones(3).is_Identity # issue 6242 assert not Matrix([[1, 0, 0]]).is_Identity # issue 8854 assert SparseMatrix(3,3, {(0,0):1, (1,1):1, (2,2):1}).is_Identity assert not SparseMatrix(2,3, range(6)).is_Identity assert not SparseMatrix(3,3, {(0,0):1, (1,1):1}).is_Identity assert not SparseMatrix(3,3, {(0,0):1, (1,1):1, (2,2):1, (0,1):2, (0,2):3}).is_Identity def test_dot(): assert ones(1, 3).dot(ones(3, 1)) == 3 assert ones(1, 3).dot([1, 1, 1]) == 3 assert Matrix([1, 2, 3]).dot(Matrix([1, 2, 3])) == 14 assert Matrix([1, 2, 3*I]).dot(Matrix([I, 2, 3*I])) == -5 + I assert Matrix([1, 2, 3*I]).dot(Matrix([I, 2, 3*I]), hermitian=False) == -5 + I assert Matrix([1, 2, 3*I]).dot(Matrix([I, 2, 3*I]), hermitian=True) == 13 + I assert Matrix([1, 2, 3*I]).dot(Matrix([I, 2, 3*I]), hermitian=True, conjugate_convention="physics") == 13 - I assert Matrix([1, 2, 3*I]).dot(Matrix([4, 5*I, 6]), hermitian=True, conjugate_convention="right") == 4 + 8*I assert Matrix([1, 2, 3*I]).dot(Matrix([4, 5*I, 6]), hermitian=True, conjugate_convention="left") == 4 - 8*I assert Matrix([I, 2*I]).dot(Matrix([I, 2*I]), hermitian=False, conjugate_convention="left") == -5 assert Matrix([I, 2*I]).dot(Matrix([I, 2*I]), conjugate_convention="left") == 5 raises(ValueError, lambda: Matrix([1, 2]).dot(Matrix([3, 4]), hermitian=True, conjugate_convention="test")) def test_dual(): B_x, B_y, B_z, E_x, E_y, E_z = symbols( 'B_x B_y B_z E_x E_y E_z', real=True) F = Matrix(( ( 0, E_x, E_y, E_z), (-E_x, 0, B_z, -B_y), (-E_y, -B_z, 0, B_x), (-E_z, B_y, -B_x, 0) )) Fd = Matrix(( ( 0, -B_x, -B_y, -B_z), (B_x, 0, E_z, -E_y), (B_y, -E_z, 0, E_x), (B_z, E_y, -E_x, 0) )) assert F.dual().equals(Fd) assert eye(3).dual().equals(zeros(3)) assert F.dual().dual().equals(-F) def test_anti_symmetric(): assert Matrix([1, 2]).is_anti_symmetric() is False m = Matrix(3, 3, [0, x**2 + 2*x + 1, y, -(x + 1)**2, 0, x*y, -y, -x*y, 0]) assert m.is_anti_symmetric() is True assert m.is_anti_symmetric(simplify=False) is False assert m.is_anti_symmetric(simplify=lambda x: x) is False # tweak to fail m[2, 1] = -m[2, 1] assert m.is_anti_symmetric() is False # untweak m[2, 1] = -m[2, 1] m = m.expand() assert m.is_anti_symmetric(simplify=False) is True m[0, 0] = 1 assert m.is_anti_symmetric() is False def test_normalize_sort_diogonalization(): A = Matrix(((1, 2), (2, 1))) P, Q = A.diagonalize(normalize=True) assert P*P.T == P.T*P == eye(P.cols) P, Q = A.diagonalize(normalize=True, sort=True) assert P*P.T == P.T*P == eye(P.cols) assert P*Q*P.inv() == A def test_issue_5321(): raises(ValueError, lambda: Matrix([[1, 2, 3], Matrix(0, 1, [])])) def test_issue_5320(): assert Matrix.hstack(eye(2), 2*eye(2)) == Matrix([ [1, 0, 2, 0], [0, 1, 0, 2] ]) assert Matrix.vstack(eye(2), 2*eye(2)) == Matrix([ [1, 0], [0, 1], [2, 0], [0, 2] ]) cls = SparseMatrix assert cls.hstack(cls(eye(2)), cls(2*eye(2))) == Matrix([ [1, 0, 2, 0], [0, 1, 0, 2] ]) def test_issue_11944(): A = Matrix([[1]]) AIm = sympify(A) assert Matrix.hstack(AIm, A) == Matrix([[1, 1]]) assert Matrix.vstack(AIm, A) == Matrix([[1], [1]]) def test_cross(): a = [1, 2, 3] b = [3, 4, 5] col = Matrix([-2, 4, -2]) row = col.T def test(M, ans): assert ans == M assert type(M) == cls for cls in classes: A = cls(a) B = cls(b) test(A.cross(B), col) test(A.cross(B.T), col) test(A.T.cross(B.T), row) test(A.T.cross(B), row) raises(ShapeError, lambda: Matrix(1, 2, [1, 1]).cross(Matrix(1, 2, [1, 1]))) def test_hash(): for cls in classes[-2:]: s = {cls.eye(1), cls.eye(1)} assert len(s) == 1 and s.pop() == cls.eye(1) # issue 3979 for cls in classes[:2]: assert not isinstance(cls.eye(1), Hashable) @XFAIL def test_issue_3979(): # when this passes, delete this and change the [1:2] # to [:2] in the test_hash above for issue 3979 cls = classes[0] raises(AttributeError, lambda: hash(cls.eye(1))) def test_adjoint(): dat = [[0, I], [1, 0]] ans = Matrix([[0, 1], [-I, 0]]) for cls in classes: assert ans == cls(dat).adjoint() def test_simplify_immutable(): from sympy import simplify, sin, cos assert simplify(ImmutableMatrix([[sin(x)**2 + cos(x)**2]])) == \ ImmutableMatrix([[1]]) def test_rank(): from sympy.abc import x m = Matrix([[1, 2], [x, 1 - 1/x]]) assert m.rank() == 2 n = Matrix(3, 3, range(1, 10)) assert n.rank() == 2 p = zeros(3) assert p.rank() == 0 def test_issue_11434(): ax, ay, bx, by, cx, cy, dx, dy, ex, ey, t0, t1 = \ symbols('a_x a_y b_x b_y c_x c_y d_x d_y e_x e_y t_0 t_1') M = Matrix([[ax, ay, ax*t0, ay*t0, 0], [bx, by, bx*t0, by*t0, 0], [cx, cy, cx*t0, cy*t0, 1], [dx, dy, dx*t0, dy*t0, 1], [ex, ey, 2*ex*t1 - ex*t0, 2*ey*t1 - ey*t0, 0]]) assert M.rank() == 4 def test_rank_regression_from_so(): # see: # https://stackoverflow.com/questions/19072700/why-does-sympy-give-me-the-wrong-answer-when-i-row-reduce-a-symbolic-matrix nu, lamb = symbols('nu, lambda') A = Matrix([[-3*nu, 1, 0, 0], [ 3*nu, -2*nu - 1, 2, 0], [ 0, 2*nu, (-1*nu) - lamb - 2, 3], [ 0, 0, nu + lamb, -3]]) expected_reduced = Matrix([[1, 0, 0, 1/(nu**2*(-lamb - nu))], [0, 1, 0, 3/(nu*(-lamb - nu))], [0, 0, 1, 3/(-lamb - nu)], [0, 0, 0, 0]]) expected_pivots = (0, 1, 2) reduced, pivots = A.rref() assert simplify(expected_reduced - reduced) == zeros(*A.shape) assert pivots == expected_pivots def test_replace(): from sympy import symbols, Function, Matrix F, G = symbols('F, G', cls=Function) K = Matrix(2, 2, lambda i, j: G(i+j)) M = Matrix(2, 2, lambda i, j: F(i+j)) N = M.replace(F, G) assert N == K def test_replace_map(): from sympy import symbols, Function, Matrix F, G = symbols('F, G', cls=Function) K = Matrix(2, 2, [(G(0), {F(0): G(0)}), (G(1), {F(1): G(1)}), (G(1), {F(1)\ : G(1)}), (G(2), {F(2): G(2)})]) M = Matrix(2, 2, lambda i, j: F(i+j)) N = M.replace(F, G, True) assert N == K def test_atoms(): m = Matrix([[1, 2], [x, 1 - 1/x]]) assert m.atoms() == {S(1),S(2),S(-1), x} assert m.atoms(Symbol) == {x} def test_pinv(): # Pseudoinverse of an invertible matrix is the inverse. A1 = Matrix([[a, b], [c, d]]) assert simplify(A1.pinv()) == simplify(A1.inv()) # Test the four properties of the pseudoinverse for various matrices. As = [Matrix([[13, 104], [2212, 3], [-3, 5]]), Matrix([[1, 7, 9], [11, 17, 19]]), Matrix([a, b])] for A in As: A_pinv = A.pinv() AAp = A * A_pinv ApA = A_pinv * A assert simplify(AAp * A) == A assert simplify(ApA * A_pinv) == A_pinv assert AAp.H == AAp assert ApA.H == ApA def test_pinv_solve(): # Fully determined system (unique result, identical to other solvers). A = Matrix([[1, 5], [7, 9]]) B = Matrix([12, 13]) assert A.pinv_solve(B) == A.cholesky_solve(B) assert A.pinv_solve(B) == A.LDLsolve(B) assert A.pinv_solve(B) == Matrix([sympify('-43/26'), sympify('71/26')]) assert A * A.pinv() * B == B # Fully determined, with two-dimensional B matrix. B = Matrix([[12, 13, 14], [15, 16, 17]]) assert A.pinv_solve(B) == A.cholesky_solve(B) assert A.pinv_solve(B) == A.LDLsolve(B) assert A.pinv_solve(B) == Matrix([[-33, -37, -41], [69, 75, 81]]) / 26 assert A * A.pinv() * B == B # Underdetermined system (infinite results). A = Matrix([[1, 0, 1], [0, 1, 1]]) B = Matrix([5, 7]) solution = A.pinv_solve(B) w = {} for s in solution.atoms(Symbol): # Extract dummy symbols used in the solution. w[s.name] = s assert solution == Matrix([[w['w0_0']/3 + w['w1_0']/3 - w['w2_0']/3 + 1], [w['w0_0']/3 + w['w1_0']/3 - w['w2_0']/3 + 3], [-w['w0_0']/3 - w['w1_0']/3 + w['w2_0']/3 + 4]]) assert A * A.pinv() * B == B # Overdetermined system (least squares results). A = Matrix([[1, 0], [0, 0], [0, 1]]) B = Matrix([3, 2, 1]) assert A.pinv_solve(B) == Matrix([3, 1]) # Proof the solution is not exact. assert A * A.pinv() * B != B def test_pinv_rank_deficient(): # Test the four properties of the pseudoinverse for various matrices. As = [Matrix([[1, 1, 1], [2, 2, 2]]), Matrix([[1, 0], [0, 0]]), Matrix([[1, 2], [2, 4], [3, 6]])] for A in As: A_pinv = A.pinv() AAp = A * A_pinv ApA = A_pinv * A assert simplify(AAp * A) == A assert simplify(ApA * A_pinv) == A_pinv assert AAp.H == AAp assert ApA.H == ApA # Test solving with rank-deficient matrices. A = Matrix([[1, 0], [0, 0]]) # Exact, non-unique solution. B = Matrix([3, 0]) solution = A.pinv_solve(B) w1 = solution.atoms(Symbol).pop() assert w1.name == 'w1_0' assert solution == Matrix([3, w1]) assert A * A.pinv() * B == B # Least squares, non-unique solution. B = Matrix([3, 1]) solution = A.pinv_solve(B) w1 = solution.atoms(Symbol).pop() assert w1.name == 'w1_0' assert solution == Matrix([3, w1]) assert A * A.pinv() * B != B @XFAIL def test_pinv_rank_deficient_when_diagonalization_fails(): # Test the four properties of the pseudoinverse for matrices when # diagonalization of A.H*A fails. As = [Matrix([ [61, 89, 55, 20, 71, 0], [62, 96, 85, 85, 16, 0], [69, 56, 17, 4, 54, 0], [10, 54, 91, 41, 71, 0], [ 7, 30, 10, 48, 90, 0], [0,0,0,0,0,0]])] for A in As: A_pinv = A.pinv() AAp = A * A_pinv ApA = A_pinv * A assert simplify(AAp * A) == A assert simplify(ApA * A_pinv) == A_pinv assert AAp.H == AAp assert ApA.H == ApA def test_gauss_jordan_solve(): # Square, full rank, unique solution A = Matrix([[1, 2, 3], [4, 5, 6], [7, 8, 10]]) b = Matrix([3, 6, 9]) sol, params = A.gauss_jordan_solve(b) assert sol == Matrix([[-1], [2], [0]]) assert params == Matrix(0, 1, []) # Square, full rank, unique solution, B has more columns than rows A = eye(3) B = Matrix([[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12]]) sol, params = A.gauss_jordan_solve(B) assert sol == B assert params == Matrix(0, 4, []) # Square, reduced rank, parametrized solution A = Matrix([[1, 2, 3], [4, 5, 6], [7, 8, 9]]) b = Matrix([3, 6, 9]) sol, params, freevar = A.gauss_jordan_solve(b, freevar=True) w = {} for s in sol.atoms(Symbol): # Extract dummy symbols used in the solution. w[s.name] = s assert sol == Matrix([[w['tau0'] - 1], [-2*w['tau0'] + 2], [w['tau0']]]) assert params == Matrix([[w['tau0']]]) assert freevar == [2] # Square, reduced rank, parametrized solution, B has two columns A = Matrix([[1, 2, 3], [4, 5, 6], [7, 8, 9]]) B = Matrix([[3, 4], [6, 8], [9, 12]]) sol, params, freevar = A.gauss_jordan_solve(B, freevar=True) w = {} for s in sol.atoms(Symbol): # Extract dummy symbols used in the solution. w[s.name] = s assert sol == Matrix([[w['tau0'] - 1, w['tau1'] - S(4)/3], [-2*w['tau0'] + 2, -2*w['tau1'] + S(8)/3], [w['tau0'], w['tau1']],]) assert params == Matrix([[w['tau0'], w['tau1']]]) assert freevar == [2] # Square, reduced rank, parametrized solution A = Matrix([[1, 2, 3], [2, 4, 6], [3, 6, 9]]) b = Matrix([0, 0, 0]) sol, params = A.gauss_jordan_solve(b) w = {} for s in sol.atoms(Symbol): w[s.name] = s assert sol == Matrix([[-2*w['tau0'] - 3*w['tau1']], [w['tau0']], [w['tau1']]]) assert params == Matrix([[w['tau0']], [w['tau1']]]) # Square, reduced rank, parametrized solution A = Matrix([[0, 0, 0], [0, 0, 0], [0, 0, 0]]) b = Matrix([0, 0, 0]) sol, params = A.gauss_jordan_solve(b) w = {} for s in sol.atoms(Symbol): w[s.name] = s assert sol == Matrix([[w['tau0']], [w['tau1']], [w['tau2']]]) assert params == Matrix([[w['tau0']], [w['tau1']], [w['tau2']]]) # Square, reduced rank, no solution A = Matrix([[1, 2, 3], [2, 4, 6], [3, 6, 9]]) b = Matrix([0, 0, 1]) raises(ValueError, lambda: A.gauss_jordan_solve(b)) # Rectangular, tall, full rank, unique solution A = Matrix([[1, 5, 3], [2, 1, 6], [1, 7, 9], [1, 4, 3]]) b = Matrix([0, 0, 1, 0]) sol, params = A.gauss_jordan_solve(b) assert sol == Matrix([[-S(1)/2], [0], [S(1)/6]]) assert params == Matrix(0, 1, []) # Rectangular, tall, full rank, unique solution, B has less columns than rows A = Matrix([[1, 5, 3], [2, 1, 6], [1, 7, 9], [1, 4, 3]]) B = Matrix([[0,0], [0, 0], [1, 2], [0, 0]]) sol, params = A.gauss_jordan_solve(B) assert sol == Matrix([[-S(1)/2, -S(2)/2], [0, 0], [S(1)/6, S(2)/6]]) assert params == Matrix(0, 2, []) # Rectangular, tall, full rank, no solution A = Matrix([[1, 5, 3], [2, 1, 6], [1, 7, 9], [1, 4, 3]]) b = Matrix([0, 0, 0, 1]) raises(ValueError, lambda: A.gauss_jordan_solve(b)) # Rectangular, tall, full rank, no solution, B has two columns (2nd has no solution) A = Matrix([[1, 5, 3], [2, 1, 6], [1, 7, 9], [1, 4, 3]]) B = Matrix([[0,0], [0, 0], [1, 0], [0, 1]]) raises(ValueError, lambda: A.gauss_jordan_solve(B)) # Rectangular, tall, full rank, no solution, B has two columns (1st has no solution) A = Matrix([[1, 5, 3], [2, 1, 6], [1, 7, 9], [1, 4, 3]]) B = Matrix([[0,0], [0, 0], [0, 1], [1, 0]]) raises(ValueError, lambda: A.gauss_jordan_solve(B)) # Rectangular, tall, reduced rank, parametrized solution A = Matrix([[1, 5, 3], [2, 10, 6], [3, 15, 9], [1, 4, 3]]) b = Matrix([0, 0, 0, 1]) sol, params = A.gauss_jordan_solve(b) w = {} for s in sol.atoms(Symbol): w[s.name] = s assert sol == Matrix([[-3*w['tau0'] + 5], [-1], [w['tau0']]]) assert params == Matrix([[w['tau0']]]) # Rectangular, tall, reduced rank, no solution A = Matrix([[1, 5, 3], [2, 10, 6], [3, 15, 9], [1, 4, 3]]) b = Matrix([0, 0, 1, 1]) raises(ValueError, lambda: A.gauss_jordan_solve(b)) # Rectangular, wide, full rank, parametrized solution A = Matrix([[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 1, 12]]) b = Matrix([1, 1, 1]) sol, params = A.gauss_jordan_solve(b) w = {} for s in sol.atoms(Symbol): w[s.name] = s assert sol == Matrix([[2*w['tau0'] - 1], [-3*w['tau0'] + 1], [0], [w['tau0']]]) assert params == Matrix([[w['tau0']]]) # Rectangular, wide, reduced rank, parametrized solution A = Matrix([[1, 2, 3, 4], [5, 6, 7, 8], [2, 4, 6, 8]]) b = Matrix([0, 1, 0]) sol, params = A.gauss_jordan_solve(b) w = {} for s in sol.atoms(Symbol): w[s.name] = s assert sol == Matrix([[w['tau0'] + 2*w['tau1'] + 1/S(2)], [-2*w['tau0'] - 3*w['tau1'] - 1/S(4)], [w['tau0']], [w['tau1']]]) assert params == Matrix([[w['tau0']], [w['tau1']]]) # watch out for clashing symbols x0, x1, x2, _x0 = symbols('_tau0 _tau1 _tau2 tau1') M = Matrix([[0, 1, 0, 0, 0, 0], [0, 0, 0, 1, 0, _x0]]) A = M[:, :-1] b = M[:, -1:] sol, params = A.gauss_jordan_solve(b) assert params == Matrix(3, 1, [x0, x1, x2]) assert sol == Matrix(5, 1, [x1, 0, x0, _x0, x2]) # Rectangular, wide, reduced rank, no solution A = Matrix([[1, 2, 3, 4], [5, 6, 7, 8], [2, 4, 6, 8]]) b = Matrix([1, 1, 1]) raises(ValueError, lambda: A.gauss_jordan_solve(b)) def test_solve(): A = Matrix([[1,2], [2,4]]) b = Matrix([[3], [4]]) raises(ValueError, lambda: A.solve(b)) #no solution b = Matrix([[ 4], [8]]) raises(ValueError, lambda: A.solve(b)) #infinite solution def test_issue_7201(): assert ones(0, 1) + ones(0, 1) == Matrix(0, 1, []) assert ones(1, 0) + ones(1, 0) == Matrix(1, 0, []) def test_free_symbols(): for M in ImmutableMatrix, ImmutableSparseMatrix, Matrix, SparseMatrix: assert M([[x], [0]]).free_symbols == {x} def test_from_ndarray(): """See issue 7465.""" try: from numpy import array except ImportError: skip('NumPy must be available to test creating matrices from ndarrays') assert Matrix(array([1, 2, 3])) == Matrix([1, 2, 3]) assert Matrix(array([[1, 2, 3]])) == Matrix([[1, 2, 3]]) assert Matrix(array([[1, 2, 3], [4, 5, 6]])) == \ Matrix([[1, 2, 3], [4, 5, 6]]) assert Matrix(array([x, y, z])) == Matrix([x, y, z]) raises(NotImplementedError, lambda: Matrix(array([[ [1, 2], [3, 4]], [[5, 6], [7, 8]]]))) def test_hermitian(): a = Matrix([[1, I], [-I, 1]]) assert a.is_hermitian a[0, 0] = 2*I assert a.is_hermitian is False a[0, 0] = x assert a.is_hermitian is None a[0, 1] = a[1, 0]*I assert a.is_hermitian is False def test_doit(): a = Matrix([[Add(x,x, evaluate=False)]]) assert a[0] != 2*x assert a.doit() == Matrix([[2*x]]) def test_issue_9457_9467_9876(): # for row_del(index) M = Matrix([[1, 2, 3], [2, 3, 4], [3, 4, 5]]) M.row_del(1) assert M == Matrix([[1, 2, 3], [3, 4, 5]]) N = Matrix([[1, 2, 3], [2, 3, 4], [3, 4, 5]]) N.row_del(-2) assert N == Matrix([[1, 2, 3], [3, 4, 5]]) O = Matrix([[1, 2, 3], [5, 6, 7], [9, 10, 11]]) O.row_del(-1) assert O == Matrix([[1, 2, 3], [5, 6, 7]]) P = Matrix([[1, 2, 3], [2, 3, 4], [3, 4, 5]]) raises(IndexError, lambda: P.row_del(10)) Q = Matrix([[1, 2, 3], [2, 3, 4], [3, 4, 5]]) raises(IndexError, lambda: Q.row_del(-10)) # for col_del(index) M = Matrix([[1, 2, 3], [2, 3, 4], [3, 4, 5]]) M.col_del(1) assert M == Matrix([[1, 3], [2, 4], [3, 5]]) N = Matrix([[1, 2, 3], [2, 3, 4], [3, 4, 5]]) N.col_del(-2) assert N == Matrix([[1, 3], [2, 4], [3, 5]]) P = Matrix([[1, 2, 3], [2, 3, 4], [3, 4, 5]]) raises(IndexError, lambda: P.col_del(10)) Q = Matrix([[1, 2, 3], [2, 3, 4], [3, 4, 5]]) raises(IndexError, lambda: Q.col_del(-10)) def test_issue_9422(): x, y = symbols('x y', commutative=False) a, b = symbols('a b') M = eye(2) M1 = Matrix(2, 2, [x, y, y, z]) assert y*x*M != x*y*M assert b*a*M == a*b*M assert x*M1 != M1*x assert a*M1 == M1*a assert y*x*M == Matrix([[y*x, 0], [0, y*x]]) def test_issue_10770(): M = Matrix([]) a = ['col_insert', 'row_join'], Matrix([9, 6, 3]) b = ['row_insert', 'col_join'], a[1].T c = ['row_insert', 'col_insert'], Matrix([[1, 2], [3, 4]]) for ops, m in (a, b, c): for op in ops: f = getattr(M, op) new = f(m) if 'join' in op else f(42, m) assert new == m and id(new) != id(m) def test_issue_10658(): A = Matrix([[1, 2, 3], [4, 5, 6], [7, 8, 9]]) assert A.extract([0, 1, 2], [True, True, False]) == \ Matrix([[1, 2], [4, 5], [7, 8]]) assert A.extract([0, 1, 2], [True, False, False]) == Matrix([[1], [4], [7]]) assert A.extract([True, False, False], [0, 1, 2]) == Matrix([[1, 2, 3]]) assert A.extract([True, False, True], [0, 1, 2]) == \ Matrix([[1, 2, 3], [7, 8, 9]]) assert A.extract([0, 1, 2], [False, False, False]) == Matrix(3, 0, []) assert A.extract([False, False, False], [0, 1, 2]) == Matrix(0, 3, []) assert A.extract([True, False, True], [False, True, False]) == \ Matrix([[2], [8]]) def test_opportunistic_simplification(): # this test relates to issue #10718, #9480, #11434 # issue #9480 m = Matrix([[-5 + 5*sqrt(2), -5], [-5*sqrt(2)/2 + 5, -5*sqrt(2)/2]]) assert m.rank() == 1 # issue #10781 m = Matrix([[3+3*sqrt(3)*I, -9],[4,-3+3*sqrt(3)*I]]) assert simplify(m.rref()[0] - Matrix([[1, -9/(3 + 3*sqrt(3)*I)], [0, 0]])) == zeros(2, 2) # issue #11434 ax,ay,bx,by,cx,cy,dx,dy,ex,ey,t0,t1 = symbols('a_x a_y b_x b_y c_x c_y d_x d_y e_x e_y t_0 t_1') m = Matrix([[ax,ay,ax*t0,ay*t0,0],[bx,by,bx*t0,by*t0,0],[cx,cy,cx*t0,cy*t0,1],[dx,dy,dx*t0,dy*t0,1],[ex,ey,2*ex*t1-ex*t0,2*ey*t1-ey*t0,0]]) assert m.rank() == 4 def test_partial_pivoting(): # example from https://en.wikipedia.org/wiki/Pivot_element # partial pivoting with back subsitution gives a perfect result # naive pivoting give an error ~1e-13, so anything better than # 1e-15 is good mm=Matrix([[0.003 ,59.14, 59.17],[ 5.291, -6.13,46.78]]) assert (mm.rref()[0] - Matrix([[1.0, 0, 10.0], [ 0, 1.0, 1.0]])).norm() < 1e-15 # issue #11549 m_mixed = Matrix([[6e-17, 1.0, 4],[ -1.0, 0, 8],[ 0, 0, 1]]) m_float = Matrix([[6e-17, 1.0, 4.],[ -1.0, 0., 8.],[ 0., 0., 1.]]) m_inv = Matrix([[ 0, -1.0, 8.0],[1.0, 6.0e-17, -4.0],[ 0, 0, 1]]) # this example is numerically unstable and involves a matrix with a norm >= 8, # this comparing the difference of the results with 1e-15 is numerically sound. assert (m_mixed.inv() - m_inv).norm() < 1e-15 assert (m_float.inv() - m_inv).norm() < 1e-15 def test_iszero_substitution(): """ When doing numerical computations, all elements that pass the iszerofunc test should be set to numerically zero if they aren't already. """ # Matrix from issue #9060 m = Matrix([[0.9, -0.1, -0.2, 0],[-0.8, 0.9, -0.4, 0],[-0.1, -0.8, 0.6, 0]]) m_rref = m.rref(iszerofunc=lambda x: abs(x)<6e-15)[0] m_correct = Matrix([[1.0, 0, -0.301369863013699, 0],[ 0, 1.0, -0.712328767123288, 0],[ 0, 0, 0, 0]]) m_diff = m_rref - m_correct assert m_diff.norm() < 1e-15 # if a zero-substitution wasn't made, this entry will be -1.11022302462516e-16 assert m_rref[2,2] == 0 def test_rank_decomposition(): a = Matrix(0, 0, []) c, f = a.rank_decomposition() assert f.is_echelon assert c.cols == f.rows == a.rank() assert c * f == a a = Matrix(1, 1, [5]) c, f = a.rank_decomposition() assert f.is_echelon assert c.cols == f.rows == a.rank() assert c * f == a a = Matrix(3, 3, [1, 2, 3, 1, 2, 3, 1, 2, 3]) c, f = a.rank_decomposition() assert f.is_echelon assert c.cols == f.rows == a.rank() assert c * f == a a = Matrix([ [0, 0, 1, 2, 2, -5, 3], [-1, 5, 2, 2, 1, -7, 5], [0, 0, -2, -3, -3, 8, -5], [-1, 5, 0, -1, -2, 1, 0]]) c, f = a.rank_decomposition() assert f.is_echelon assert c.cols == f.rows == a.rank() assert c * f == a @slow def test_issue_11238(): from sympy import Point xx = 8*tan(13*pi/45)/(tan(13*pi/45) + sqrt(3)) yy = (-8*sqrt(3)*tan(13*pi/45)**2 + 24*tan(13*pi/45))/(-3 + tan(13*pi/45)**2) p1 = Point(0, 0) p2 = Point(1, -sqrt(3)) p0 = Point(xx,yy) m1 = Matrix([p1 - simplify(p0), p2 - simplify(p0)]) m2 = Matrix([p1 - p0, p2 - p0]) m3 = Matrix([simplify(p1 - p0), simplify(p2 - p0)]) assert m1.rank(simplify=True) == 1 assert m2.rank(simplify=True) == 1 assert m3.rank(simplify=True) == 1 def test_as_real_imag(): m1 = Matrix(2,2,[1,2,3,4]) m2 = m1*S.ImaginaryUnit m3 = m1 + m2 for kls in classes: a,b = kls(m3).as_real_imag() assert list(a) == list(m1) assert list(b) == list(m1) def test_deprecated(): # Maintain tests for deprecated functions. We must capture # the deprecation warnings. When the deprecated functionality is # removed, the corresponding tests should be removed. m = Matrix(3, 3, [0, 1, 0, -4, 4, 0, -2, 1, 2]) P, Jcells = m.jordan_cells() assert Jcells[1] == Matrix(1, 1, [2]) assert Jcells[0] == Matrix(2, 2, [2, 1, 0, 2]) with warns_deprecated_sympy(): assert Matrix([[1,2],[3,4]]).dot(Matrix([[1,3],[4,5]])) == [10, 19, 14, 28] def test_issue_14489(): from sympy import Mod A = Matrix([-1, 1, 2]) B = Matrix([10, 20, -15]) assert Mod(A, 3) == Matrix([2, 1, 2]) assert Mod(B, 4) == Matrix([2, 0, 1]) def test_issue_14517(): M = Matrix([ [ 0, 10*I, 10*I, 0], [10*I, 0, 0, 10*I], [10*I, 0, 5 + 2*I, 10*I], [ 0, 10*I, 10*I, 5 + 2*I]]) ev = M.eigenvals() # test one random eigenvalue, the computation is a little slow test_ev = random.choice(list(ev.keys())) assert (M - test_ev*eye(4)).det() == 0 def test_issue_14943(): # Test that __array__ accepts the optional dtype argument try: from numpy import array except ImportError: skip('NumPy must be available to test creating matrices from ndarrays') M = Matrix([[1,2], [3,4]]) assert array(M, dtype=float).dtype.name == 'float64' def test_issue_8240(): # Eigenvalues of large triangular matrices n = 200 diagonal_variables = [Symbol('x%s' % i) for i in range(n)] M = [[0 for i in range(n)] for j in range(n)] for i in range(n): M[i][i] = diagonal_variables[i] M = Matrix(M) eigenvals = M.eigenvals() assert len(eigenvals) == n for i in range(n): assert eigenvals[diagonal_variables[i]] == 1 eigenvals = M.eigenvals(multiple=True) assert set(eigenvals) == set(diagonal_variables) # with multiplicity M = Matrix([[x, 0, 0], [1, y, 0], [2, 3, x]]) eigenvals = M.eigenvals() assert eigenvals == {x: 2, y: 1} eigenvals = M.eigenvals(multiple=True) assert len(eigenvals) == 3 assert eigenvals.count(x) == 2 assert eigenvals.count(y) == 1 def test_legacy_det(): # Minimal support for legacy keys for 'method' in det() # Partially copied from test_determinant() M = Matrix(( ( 3, -2, 0, 5), (-2, 1, -2, 2), ( 0, -2, 5, 0), ( 5, 0, 3, 4) )) assert M.det(method="bareis") == -289 assert M.det(method="det_lu") == -289 assert M.det(method="det_LU") == -289 M = Matrix(( (3, 2, 0, 0, 0), (0, 3, 2, 0, 0), (0, 0, 3, 2, 0), (0, 0, 0, 3, 2), (2, 0, 0, 0, 3) )) assert M.det(method="bareis") == 275 assert M.det(method="det_lu") == 275 assert M.det(method="Bareis") == 275 M = Matrix(( (1, 0, 1, 2, 12), (2, 0, 1, 1, 4), (2, 1, 1, -1, 3), (3, 2, -1, 1, 8), (1, 1, 1, 0, 6) )) assert M.det(method="bareis") == -55 assert M.det(method="det_lu") == -55 assert M.det(method="BAREISS") == -55 M = Matrix(( (-5, 2, 3, 4, 5), ( 1, -4, 3, 4, 5), ( 1, 2, -3, 4, 5), ( 1, 2, 3, -2, 5), ( 1, 2, 3, 4, -1) )) assert M.det(method="bareis") == 11664 assert M.det(method="det_lu") == 11664 assert M.det(method="BERKOWITZ") == 11664 M = Matrix(( ( 2, 7, -1, 3, 2), ( 0, 0, 1, 0, 1), (-2, 0, 7, 0, 2), (-3, -2, 4, 5, 3), ( 1, 0, 0, 0, 1) )) assert M.det(method="bareis") == 123 assert M.det(method="det_lu") == 123 assert M.det(method="LU") == 123 def test_case_6913(): m = MatrixSymbol('m', 1, 1) a = Symbol("a") a = m[0, 0]>0 assert str(a) == 'm[0, 0] > 0' def test_issue_15872(): A = Matrix([[1, 1, 1, 0], [-2, -1, 0, -1], [0, 0, -1, -1], [0, 0, 2, 1]]) B = A - Matrix.eye(4) * I assert B.rank() == 3 assert (B**2).rank() == 2 assert (B**3).rank() == 2 def test_issue_11948(): A = MatrixSymbol('A', 3, 3) a = Wild('a') assert A.match(a) == {a: A}
cf44c27b9f89ff9be2e3ffe8790aeaf65be29a8b8eed4727819a1c4f579accc7
from sympy.matrices.expressions import MatrixExpr from sympy import MatrixBase, Dummy, Lambda, Function, FunctionClass from sympy.matrices.expressions.diagonal import diagonalize_vector class ElementwiseApplyFunction(MatrixExpr): r""" Apply function to a matrix elementwise without evaluating. Examples ======== It can be created by calling ``.applyfunc(<function>)`` on a matrix expression: >>> from sympy.matrices.expressions import MatrixSymbol >>> from sympy.matrices.expressions.applyfunc import ElementwiseApplyFunction >>> from sympy import exp >>> X = MatrixSymbol("X", 3, 3) >>> X.applyfunc(exp) exp(X...) Otherwise using the class constructor: >>> from sympy import eye >>> expr = ElementwiseApplyFunction(exp, eye(3)) >>> expr exp(Matrix([ [1, 0, 0], [0, 1, 0], [0, 0, 1]])...) >>> expr.doit() Matrix([ [E, 1, 1], [1, E, 1], [1, 1, E]]) Notice the difference with the real mathematical functions: >>> exp(eye(3)) Matrix([ [E, 0, 0], [0, E, 0], [0, 0, E]]) """ def __new__(cls, function, expr): obj = MatrixExpr.__new__(cls, expr) if not isinstance(function, FunctionClass): d = Dummy("d") function = Lambda(d, function(d)) obj._function = function obj._expr = expr return obj def _hashable_content(self): return (self.function, self.expr) @property def function(self): return self._function @property def expr(self): return self._expr @property def shape(self): return self.expr.shape @property def func(self): # This strange construction is required by the assumptions: # (.func needs to be a class) class ElementwiseApplyFunction2(ElementwiseApplyFunction): def __new__(obj, expr): return ElementwiseApplyFunction(self.function, expr) return ElementwiseApplyFunction2 def doit(self, **kwargs): deep = kwargs.get("deep", True) expr = self.expr if deep: expr = expr.doit(**kwargs) if isinstance(expr, MatrixBase): return expr.applyfunc(self.function) else: return self def _entry(self, i, j, **kwargs): return self.function(self.expr._entry(i, j, **kwargs)) def _eval_derivative_matrix_lines(self, x): from sympy import HadamardProduct, hadamard_product, Mul, MatMul, Identity, Transpose from sympy.matrices.expressions.diagonal import diagonalize_vector from sympy.matrices.expressions.matmul import validate as matmul_validate from sympy.core.expr import ExprBuilder d = Dummy("d") function = self.function(d) fdiff = function.fdiff() if isinstance(fdiff, Function): fdiff = type(fdiff) else: fdiff = Lambda(d, fdiff) lr = self.expr._eval_derivative_matrix_lines(x) ewdiff = ElementwiseApplyFunction(fdiff, self.expr) if 1 in x.shape: # Vector: iscolumn = self.shape[1] == 1 ewdiff = diagonalize_vector(ewdiff) # TODO: check which axis is not 1 for i in lr: if iscolumn: ptr1 = i.first_pointer ptr2 = Identity(ewdiff.shape[0]) else: ptr1 = Identity(ewdiff.shape[1]) ptr2 = i.second_pointer # TODO: check if pointers point to two different lines: def mul(*args): return Mul.fromiter(args) def hadamard_or_mul(arg1, arg2): if arg1.shape == arg2.shape: return hadamard_product(arg1, arg2) elif arg1.shape[1] == arg2.shape[0]: return MatMul(arg1, arg2).doit() elif arg1.shape[0] == arg2.shape[0]: return MatMul(arg2.T, arg1).doit() raise NotImplementedError i._lines = [[hadamard_or_mul, [[mul, [ewdiff, ptr1]], ptr2]]] i._first_pointer_parent = i._lines[0][1][0][1] i._first_pointer_index = 1 i._second_pointer_parent = i._lines[0][1] i._second_pointer_index = 1 else: # Matrix case: for i in lr: ptr1 = i.first_pointer ptr2 = i.second_pointer newptr1 = Identity(ptr1.shape[1]) newptr2 = Identity(ptr2.shape[1]) subexpr1 = ExprBuilder( MatMul, [ptr1, ExprBuilder(diagonalize_vector, [newptr1])], validator=matmul_validate, ) subexpr2 = ExprBuilder( Transpose, [ExprBuilder( MatMul, [ ptr2, ExprBuilder(diagonalize_vector, [newptr2]) , ], )], validator=matmul_validate, ) # TODO: replace the expressions above with the following: # subexpr = ExprBuilder( # get_recognize([(1, 2, 8), (5, 6, 9)]), # [ptr1, newptr1, ptr2, newptr2, ewdiff] # ) # ... = recognize_matrix_expression(subexpr.build()).doit() i.first_pointer = subexpr1 i.second_pointer = subexpr2 i._first_pointer_parent = subexpr1.args[1].args i._first_pointer_index = 0 i._second_pointer_parent = subexpr2.args[0].args[1].args i._second_pointer_index = 0 # TODO: check if pointers point to two different lines: # Unify lines: l = i._lines # TODO: check nested fucntions, e.g. log(sin(...)), the second function should be a scalar one. i._lines = [ExprBuilder(MatMul, [l[0], ewdiff, l[1]], validator=matmul_validate)] return lr