Exemplo n.º 1
0
 def _eval_expand_complex(self, *args):
     if self[0].is_real:
         return self
     re, im = self[0].as_real_imag()
     denom = sinh(re)**2 + Basic.cos(im)**2
     return (sinh(re)*cosh(re) + \
         S.ImaginaryUnit*Basic.sin(im)*Basic.cos(im))/denom
Exemplo n.º 2
0
 def apothem(self):
     """
     Returns the apothem/inradius of the regular polygon (i.e., the
     radius of the inscribed circle).
     """
     n = self.__getitem__(2)
     return self.radius * Basic.cos(S.Pi/n)
Exemplo n.º 3
0
 def vertices(self):
     Polygon.vertices.__doc__
     points = []
     c, r, n = self[:]
     v = 2*S.Pi/n
     for k in xrange(0, n):
         points.append( Point(c[0] + r*Basic.cos(k*v), c[1] + r*Basic.sin(k*v)) )
     return points
Exemplo n.º 4
0
    def _eval_apply(self, arg):
        arg = Basic.sympify(arg)

        if isinstance(arg, Basic.Number):
            if isinstance(arg, Basic.NaN):
                return S.NaN
            elif isinstance(arg, Basic.Infinity):
                return S.Infinity
            elif isinstance(arg, Basic.NegativeInfinity):
                return S.Infinity
            elif isinstance(arg, Basic.Zero):
                return S.One
            elif arg.is_negative:
                return self(-arg)
        else:
            i_coeff = arg.as_coefficient(S.ImaginaryUnit)

            if i_coeff is not None:
                return Basic.cos(i_coeff)
            else:
                coeff, terms = arg.as_coeff_terms()

                if coeff.is_negative:
                    return self(-arg)
Exemplo n.º 5
0
 def _eval_apply(cls, n, k):
     if not 0 <= k < n:
         raise ValueError, "must have 0 <= k < n"
     return Basic.cos(S.Pi*(k+1)/(n+1))
Exemplo n.º 6
0
 def _eval_expand_complex(self, *args):
     if self[0].is_real:
         return self
     re, im = self[0].as_real_imag()
     return sinh(re)*Basic.cos(im) + cosh(re)*Basic.sin(im)*S.ImaginaryUnit
Exemplo n.º 7
0
 def _eval_expand_complex(self, *args):
     re, im = self[0].as_real_imag()
     cos, sin = Basic.cos(im), Basic.sin(im)
     return exp(re) * cos + S.ImaginaryUnit * exp(re) * sin
Exemplo n.º 8
0
 def arbitrary_point(self, parameter_name='t'):
     """Returns a symbolic point that is on the ellipse."""
     t = Basic.Symbol(parameter_name, real=True)
     return Point(
             self.center[0] + self.hradius*Basic.cos(t),
             self.center[1] + self.vradius*Basic.sin(t))