예제 #1
0
    def _element_constructor_(self, fun):
        """
        Coerce a given function (element of the symbolic ring)
        into a differential form of degree zero.

        EXAMPLES::

            sage: x, y, z = var('x, y, z')
            sage: U = CoordinatePatch((x, y, z))
            doctest:...: DeprecationWarning: Use Manifold instead.
            See http://trac.sagemath.org/24444 for details.
            sage: F = DifferentialForms(U); F
            doctest:...:  DeprecationWarning: For the set of differential forms of
             degree p, use U.diff_form_module(p), where U is the base manifold
             (type U.diff_form_module? for details).
            See http://trac.sagemath.org/24444 for details.
            Algebra of differential forms in the variables x, y, z
            sage: F(sin(x*y))    # indirect doctest
            doctest:...: DeprecationWarning: Use U.diff_form(degree) instead,
             where U is the base manifold (type U.diff_form? for details).
            See http://trac.sagemath.org/24444 for details.
            sin(x*y)

        """


        fun = SR(fun)
        if fun not in self:
            raise ValueError("Function not an element of this algebra of differential forms.")

        return DifferentialForm(self, 0, fun)
예제 #2
0
    def gen(self, i=0):
        """
        Return the `i^{th}` generator of ``self``.  This is a one-form,
        more precisely the exterior derivative of the i-th coordinate.

        INPUT:

        - ``i`` - integer (optional, default 0)


        EXAMPLES::

            sage: x, y, z = var('x, y, z')
            sage: U = CoordinatePatch((x, y, z)); U
            Open subset of R^3 with coordinates x, y, z
            sage: F = DifferentialForms(U); F
            Algebra of differential forms in the variables x, y, z
            sage: F.gen(0)
            dx
            sage: F.gen(1)
            dy
            sage: F.gen(2)
            dz

        """

        form = DifferentialForm(self, 0, self._patch.coordinate(i))
        return form.diff()
예제 #3
0
 def test_derivative(self):
     x = self.x
     y = self.y
     z = self.z
     logdf = LogarithmicDifferentialForm(1, [y * z, x * z, x * y],
                                         self.normal_logdf)
     form = DifferentialForm(self.normal_logdf.form_space, 2)
     logdf_der = LogarithmicDifferentialForm.create_from_form(
         form, self.normal_logdf)
     self.assertTrue(logdf_der.equals(logdf.derivative()))
예제 #4
0
 def test_creationA(self):
     x = self.normal_logdf.form_vars[0]
     y = self.normal_logdf.form_vars[1]
     z = self.normal_logdf.form_vars[2]
     logdf = LogarithmicDifferentialForm(2, [self.x, self.y, self.z],
                                         self.normal_logdf)
     form = DifferentialForm(self.normal_logdf.form_space, 2)
     form[0, 1] = 1 / (y * z)
     form[0, 2] = 1 / (x * z)
     form[1, 2] = 1 / (x * y)
     self.assertEqual(form, logdf.form)
예제 #5
0
 def __init__(self,degree,vec,differential_forms):
   self.vec = vec
   self.degree = degree
   self.diff_forms = differential_forms
   self.divisor = self.diff_forms.divisor
   sym_divisor = convert_polynomial_to_symbolic(self.divisor,self.diff_forms.form_vars)
   #Construct the p_forms version of self
   if degree==0:
     sym_poly = convert_polynomial_to_symbolic(self.vec[0],self.diff_forms.form_vars)
     self.form = DifferentialForm(self.diff_forms.form_space,degree,sym_poly/sym_divisor)
     return
   if degree==self.diff_forms.poly_ring.ngens():
     sym_poly = convert_polynomial_to_symbolic(self.vec[0],self.diff_forms.form_vars)
     self.form = DifferentialForm(self.diff_forms.form_space,degree)
     self.form[tuple(range(degree))] = sym_poly/sym_divisor
   else:
     self.form = DifferentialForm(self.diff_forms.form_space,degree)
     for i,v in enumerate(skew_iter(self.diff_forms.poly_ring.ngens(),degree)):
       sym_poly = convert_polynomial_to_symbolic(self.vec[i],self.diff_forms.form_vars)
       self.form[tuple(v)] = sym_poly/sym_divisor;
예제 #6
0
 def test_creation_B(self):
     x = self.whitney_logdf.form_vars[0]
     y = self.whitney_logdf.form_vars[1]
     z = self.whitney_logdf.form_vars[2]
     whitney = x**2 * y - z**2
     logdf = LogarithmicDifferentialForm(2, [self.x, self.y, self.z],
                                         self.whitney_logdf)
     form = DifferentialForm(self.normal_logdf.form_space, 2)
     form[0, 1] = x / whitney
     form[0, 2] = y / whitney
     form[1, 2] = z / whitney
     self.assertEqual(form, logdf.form)
예제 #7
0
 def test_interior_1_form(self):
     x = self.normal_logdf.form_vars[0]
     y = self.normal_logdf.form_vars[1]
     z = self.normal_logdf.form_vars[2]
     form = DifferentialForm(self.normal_logdf.form_space, 0,
                             (x + y + z) / (x * y * z))
     one = self.poly_ring.one()
     logdf = LogarithmicDifferentialForm(1, [one, one, one],
                                         self.normal_logdf)
     int_product = logdf.interior_product()
     logdf_form = LogarithmicDifferentialForm.create_from_form(
         form, self.normal_logdf)
     self.assertTrue(int_product.equals(logdf_form))
예제 #8
0
 def test_mul(self):
     x = self.normal_logdf.form_vars[0]
     y = self.normal_logdf.form_vars[1]
     z = self.normal_logdf.form_vars[2]
     logdf = LogarithmicDifferentialForm(2, [self.x, self.y, self.z],
                                         self.normal_logdf)
     form = DifferentialForm(self.normal_logdf.form_space, 2)
     form[0, 1] = -5 / (y * z)
     form[0, 2] = -5 / (x * z)
     form[1, 2] = -5 / (x * y)
     self.assertTrue((logdf * (-5)).equals((-5) * logdf))
     logdf_mul = LogarithmicDifferentialForm.create_from_form(
         form, self.normal_logdf)
     self.assertTrue((-5 * logdf).equals(logdf_mul))
예제 #9
0
 def test_create_from_0_form(self):
     x = self.normal_logdf.form_vars[0]
     y = self.normal_logdf.form_vars[1]
     z = self.normal_logdf.form_vars[2]
     xp = self.x
     yp = self.y
     zp = self.z
     logdf = LogarithmicDifferentialForm(0, [xp + yp + zp],
                                         self.normal_logdf)
     form = DifferentialForm(self.normal_logdf.form_space, 0,
                             (x + y + z) / (x * y * z))
     logdf_form = LogarithmicDifferentialForm.create_from_form(
         form, self.normal_logdf)
     self.assertTrue(logdf.equals(logdf_form))
예제 #10
0
 def test_sub(self):
     x = self.normal_logdf.form_vars[0]
     y = self.normal_logdf.form_vars[1]
     z = self.normal_logdf.form_vars[2]
     logdfA = LogarithmicDifferentialForm(2, [self.x, self.y, self.z],
                                          self.normal_logdf)
     logdfB = LogarithmicDifferentialForm(2, [self.z, self.y, self.x],
                                          self.normal_logdf)
     form = DifferentialForm(self.normal_logdf.form_space, 2)
     form[0, 1] = 1 / (y * z) - 1 / (x * y)
     form[0, 2] = 0
     form[1, 2] = 1 / (x * y) - 1 / (y * z)
     logdf_diff = LogarithmicDifferentialForm.create_from_form(
         form, self.normal_logdf)
     self.assertTrue(logdf_diff.equals(logdfA - logdfB))
예제 #11
0
 def interior_product(self):
   if self.degree==0:
     return LogarithmicDifferentialForm.make_zero(0,self.diff_forms)
   prod_form = DifferentialForm(self.diff_forms.form_space,self.degree-1)
   for v in skew_iter(self.diff_forms.poly_ring.ngens(),self.degree):
     for e_i,e in enumerate(v):
       partial_var = self.diff_forms.form_vars[e]
       partial_w = self.diff_forms.wieghts[e]
       partial = ((-1)**(e_i)) * self.form[tuple(v)] * partial_var * partial_w
       if self.degree>1:
         rest = [ e_other for e_other in v if e_other != e]
         prod_form[tuple(rest)] = prod_form[tuple(rest)] + partial
       else:
         prod_form = prod_form + partial
   return LogarithmicDifferentialForm.create_from_form(prod_form,self.diff_forms)
    def weight_integrand(self, simplify_factor=True):
        """
        Weight integrand as a rational function.

        The Jacobian determinant of some coordinate transformation.
        """
        def arg(x, y):
            return arctan(y / x)  # up to a constant, but it doesn't matter

        def phi(x, y, a, b):
            z = (a + I * b - x - I * y) * (a - I * b - x - I * y)
            w = z.real()
            q = z.imag()
            return arg(w, q).full_simplify()

        n = len(self.internal_vertices())
        coordinates = lambda v: SR.var(chr(97+2*(v-1)) + ',' + chr(97+2*(v-1)+1)) \
                                if v in self.internal_vertices() else \
                                [(0,0), (1,0)][self.ground_vertices().index(v)]
        internal_coordinates = sum(
            (list(coordinates(v)) for v in sorted(self.internal_vertices())),
            [])
        U = CoordinatePatch(internal_coordinates)
        F = DifferentialForms(U)
        psi = 0
        two_forms = []
        for v in self.internal_vertices():
            x, y = coordinates(v)
            outgoing_edges = self.outgoing_edges([v])
            left_target = filter(lambda (x, y, z): z == 'L',
                                 outgoing_edges)[0][1]
            right_target = filter(lambda (x, y, z): z == 'R',
                                  outgoing_edges)[0][1]
            one_forms = []
            for target in [left_target, right_target]:
                a, b = coordinates(target)
                one_form = DifferentialForm(F, 1)
                for v in internal_coordinates:
                    index = internal_coordinates.index(v)
                    one_form[index] = phi(x, y, a, b).diff(v)
                    if simplify_factor:
                        one_form[index] = SR(one_form[index]).full_simplify()
                one_forms.append(one_form)
            two_form = one_forms[0] * one_forms[1]
            two_forms.append(two_form)
        import operator
        two_n_form = reduce(operator.mul, two_forms, 1)
        return two_n_form[range(0, 2 * n)]
예제 #13
0
 def test_wedge(self):
     x = self.normal_logdf.form_vars[0]
     y = self.normal_logdf.form_vars[1]
     z = self.normal_logdf.form_vars[2]
     norm = self.x * self.y * self.z
     logdfA = LogarithmicDifferentialForm(
         1, [self.x * norm, self.y * norm, self.z * norm],
         self.normal_logdf)
     logdfB = LogarithmicDifferentialForm(1, [self.z, self.y, self.x],
                                          self.normal_logdf)
     form = DifferentialForm(self.normal_logdf.form_space, 2)
     form[0, 1] = 1 / z - 1 / x
     form[0, 2] = (x / (y * z)) - (z / (x * y))
     form[1, 2] = 1 / z - 1 / x
     logdf_wedge = LogarithmicDifferentialForm.create_from_form(
         form, self.normal_logdf)
     self.assertTrue(logdf_wedge.equals(logdfA.wedge(logdfB)))
예제 #14
0
 def test_create_from_form(self):
     x = self.normal_logdf.form_vars[0]
     y = self.normal_logdf.form_vars[1]
     z = self.normal_logdf.form_vars[2]
     xp = self.x
     yp = self.y
     zp = self.z
     logdf = LogarithmicDifferentialForm(
         2, [xp * yp - yp * zp, xp**2 - zp**2, xp * yp - yp * zp],
         self.normal_logdf)
     form = DifferentialForm(self.normal_logdf.form_space, 2)
     form[0, 1] = 1 / z - 1 / x
     form[0, 2] = (x / (y * z)) - (z / (x * y))
     form[1, 2] = 1 / z - 1 / x
     logdf_form = LogarithmicDifferentialForm.create_from_form(
         form, self.normal_logdf)
     self.assertTrue(logdf.equals(logdf_form))
예제 #15
0
 def test_interior(self):
     xp = self.x
     yp = self.y
     zp = self.z
     logdf = LogarithmicDifferentialForm(
         2, [xp**2, xp + 4 * yp + zp, xp**3 * zp**3], self.whitney_logdf)
     int_product = logdf.interior_product()
     x = self.normal_logdf.form_vars[0]
     y = self.normal_logdf.form_vars[1]
     z = self.normal_logdf.form_vars[2]
     whitney = x**2 * y - z**2
     form = DifferentialForm(self.normal_logdf.form_space, 1)
     form[0] = (-2 * x**2 * y - 2 * x * z - 8 * y * z - 2 * z**2) / whitney
     form[1] = (x**3 - 2 * x**3 * z**4) / whitney
     form[2] = (x**2 + 4 * x * y + x * z + 2 * x**3 * y * z**3) / whitney
     logdf_form = LogarithmicDifferentialForm.create_from_form(
         form, self.whitney_logdf)
     self.assertTrue(int_product.equals(logdf_form))
예제 #16
0
    def _element_constructor_(self, fun):
        """
        Coerce a given function (element of the symbolic ring)
        into a differential form of degree zero.

        EXAMPLES::

            sage: x, y, z = var('x, y, z')
            sage: U = CoordinatePatch((x, y, z))
            sage: F = DifferentialForms(U); F
            Algebra of differential forms in the variables x, y, z
            sage: F(sin(x*y))    # indirect doctest
            sin(x*y)

        """

        fun = SR(fun)
        if fun not in self:
            raise ValueError, \
                "Function not an element of this algebra of differential forms."

        return DifferentialForm(self, 0, fun)
예제 #17
0
    def gen(self, i=0):
        """
        Return the `i^{th}` generator of ``self``.  This is a one-form,
        more precisely the exterior derivative of the i-th coordinate.

        INPUT:

        - ``i`` - integer (optional, default 0)


        EXAMPLES::

            sage: x, y, z = var('x, y, z')
            sage: U = CoordinatePatch((x, y, z)); U
            doctest:...: DeprecationWarning: Use Manifold instead.
            See http://trac.sagemath.org/24444 for details.
            Open subset of R^3 with coordinates x, y, z
            sage: F = DifferentialForms(U); F
            doctest:...:  DeprecationWarning: For the set of differential forms of
             degree p, use U.diff_form_module(p), where U is the base manifold
             (type U.diff_form_module? for details).
            See http://trac.sagemath.org/24444 for details.
            Algebra of differential forms in the variables x, y, z
            sage: F.gen(0)
            doctest:...: DeprecationWarning: Use U.diff_form(degree) instead,
             where U is the base manifold (type U.diff_form? for details).
            See http://trac.sagemath.org/24444 for details.
            dx
            sage: F.gen(1)
            dy
            sage: F.gen(2)
            dz

        """

        form = DifferentialForm(self, 0, self._patch.coordinate(i))
        return form.diff()
예제 #18
0
def _get_sym_from_0_form(form,diff_forms):
  dz = DifferentialForm(diff_forms.form_space,1)
  dz[(0,)] = 1
  return form.wedge(dz)[(0,)]
예제 #19
0
 def make_zero(cls,p,diff_forms):
   zero_form = DifferentialForm(diff_forms.form_space,p)
   return LogarithmicDifferentialForm.create_from_form(zero_form,diff_forms)
예제 #20
0
 def test_creation_0_form(self):
     z = self.normal_logdf.form_vars[2]
     logdf = LogarithmicDifferentialForm(0, [self.x * self.y],
                                         self.normal_logdf)
     form = DifferentialForm(self.normal_logdf.form_space, 0, 1 / z)
     self.assertEqual(form, logdf.form)
예제 #21
0
 def test_unit(self):
     one = LogarithmicDifferentialForm.make_unit(self.normal_logdf)
     form = DifferentialForm(self.normal_logdf.form_space, 0, 1)
     one_form = LogarithmicDifferentialForm.create_from_form(
         form, self.normal_logdf)
     self.assertTrue(one.equals(one_form))