Exemple #1
0
 def __init__(self, J):
     """
     """
     R = J.base_ring()
     PP = ProjectiveSpace(3, R, ["X0", "X1", "X2", "X3"])
     X0, X1, X2, X3 = PP.gens()
     C = J.curve()
     f, h = C.hyperelliptic_polynomials()
     a12 = f[0]
     a10 = f[1]
     a8 = f[2]
     a6 = f[3]
     a4 = f[4]
     a2 = f[5]
     a0 = f[6]
     if h != 0:
         c6 = h[0]
         c4 = h[1]
         c2 = h[2]
         c0 = h[3]
         a12, a10, a8, a6, a4, a2, a0 = \
              (4*a12 + c6**2,
               4*a10 + 2*c4*c6,
               4*a8 + 2*c2*c6 + c4**2,
               4*a6 + 2*c0*c6 + 2*c2*c4,
               4*a4 + 2*c0*c4 + c2**2,
               4*a2 + 2*c0*c2,
               4*a0 + c0**2)
     F = \
       (-4*a8*a12 + a10**2)*X0**4 + \
       -4*a6*a12*X0**3*X1 + \
       -2*a6*a10*X0**3*X2 + \
       -4*a12*X0**3*X3 + \
       -4*a4*a12*X0**2*X1**2 + \
       (4*a2*a12 - 4*a4*a10)*X0**2*X1*X2 + \
       -2*a10*X0**2*X1*X3 + \
       (-4*a0*a12 + 2*a2*a10 - 4*a4*a8 + a6**2)*X0**2*X2**2 + \
       -4*a8*X0**2*X2*X3 + \
       -4*a2*a12*X0*X1**3 + \
       (8*a0*a12 - 4*a2*a10)*X0*X1**2*X2 + \
       (4*a0*a10 - 4*a2*a8)*X0*X1*X2**2 + \
       -2*a6*X0*X1*X2*X3 + \
       -2*a2*a6*X0*X2**3 + \
       -4*a4*X0*X2**2*X3 + \
       -4*X0*X2*X3**2 + \
       -4*a0*a12*X1**4 + \
       -4*a0*a10*X1**3*X2 + \
       -4*a0*a8*X1**2*X2**2 + \
       X1**2*X3**2 + \
       -4*a0*a6*X1*X2**3 + \
       -2*a2*X1*X2**2*X3 + \
       (-4*a0*a4 + a2**2)*X2**4 + \
       -4*a0*X2**3*X3
     AlgebraicScheme_subscheme_projective.__init__(self, PP, F)
     X, Y, Z = C.ambient_space().gens()
     if a0 == 0:
         a0 = a2
     phi = Hom(C, self)([0, Z**2, X * Z, a0 * X**2], Schemes())
     C._kummer_morphism = phi
     J._kummer_surface = self
Exemple #2
0
 def __init__(self,J):
     """
     """
     R = J.base_ring()
     PP = ProjectiveSpace(3,R,["X0","X1","X2","X3"])
     X0, X1, X2, X3 = PP.gens()
     C = J.curve()
     f, h = C.hyperelliptic_polynomials()
     a12 = f[0]; a10 = f[1]; a8 = f[2];
     a6 = f[3]; a4 = f[4]; a2 = f[5]; a0 = f[6]
     if h != 0:
         c6 = h[0]; c4 = h[1]; c2 = h[2]; c0 = h[3]
         a12, a10, a8, a6, a4, a2, a0 = \
              (4*a12 + c6**2,
               4*a10 + 2*c4*c6,
               4*a8 + 2*c2*c6 + c4**2,
               4*a6 + 2*c0*c6 + 2*c2*c4,
               4*a4 + 2*c0*c4 + c2**2,
               4*a2 + 2*c0*c2,
               4*a0 + c0**2)
     F = \
       (-4*a8*a12 + a10**2)*X0**4 + \
       -4*a6*a12*X0**3*X1 + \
       -2*a6*a10*X0**3*X2 + \
       -4*a12*X0**3*X3 + \
       -4*a4*a12*X0**2*X1**2 + \
       (4*a2*a12 - 4*a4*a10)*X0**2*X1*X2 + \
       -2*a10*X0**2*X1*X3 + \
       (-4*a0*a12 + 2*a2*a10 - 4*a4*a8 + a6**2)*X0**2*X2**2 + \
       -4*a8*X0**2*X2*X3 + \
       -4*a2*a12*X0*X1**3 + \
       (8*a0*a12 - 4*a2*a10)*X0*X1**2*X2 + \
       (4*a0*a10 - 4*a2*a8)*X0*X1*X2**2 + \
       -2*a6*X0*X1*X2*X3 + \
       -2*a2*a6*X0*X2**3 + \
       -4*a4*X0*X2**2*X3 + \
       -4*X0*X2*X3**2 + \
       -4*a0*a12*X1**4 + \
       -4*a0*a10*X1**3*X2 + \
       -4*a0*a8*X1**2*X2**2 + \
       X1**2*X3**2 + \
       -4*a0*a6*X1*X2**3 + \
       -2*a2*X1*X2**2*X3 + \
       (-4*a0*a4 + a2**2)*X2**4 + \
       -4*a0*X2**3*X3
     AlgebraicScheme_subscheme_projective.__init__(self, PP, F)
     X, Y, Z = C.ambient_space().gens()
     if a0 ==0:
         a0 = a2
     phi = Hom(C,self)([0,Z**2,X*Z,a0*X**2],Schemes())
     C._kummer_morphism = phi
     J._kummer_surface = self
Exemple #3
0
    def __init__(self, J):
        """
        EXAMPLES::

            sage: R.<x> = QQ[]
            sage: f = x^5 + x + 1
            sage: X = HyperellipticCurve(f)
            sage: J = Jacobian(X)
            sage: K = KummerSurface(J); K
            Closed subscheme of Projective Space of dimension 3 over Rational Field defined by:
            X0^4 - 4*X0*X1^3 + 4*X0^2*X1*X2 - 4*X0*X1^2*X2 + 2*X0^2*X2^2 + X2^4 - 4*X0^3*X3 - 2*X0^2*X1*X3 - 2*X1*X2^2*X3 + X1^2*X3^2 - 4*X0*X2*X3^2
        """
        R = J.base_ring()
        PP = ProjectiveSpace(3, R, ["X0", "X1", "X2", "X3"])
        X0, X1, X2, X3 = PP.gens()
        C = J.curve()
        f, h = C.hyperelliptic_polynomials()
        a12 = f[0]
        a10 = f[1]
        a8 = f[2]
        a6 = f[3]
        a4 = f[4]
        a2 = f[5]
        a0 = f[6]
        if h != 0:
            c6 = h[0]
            c4 = h[1]
            c2 = h[2]
            c0 = h[3]
            a12, a10, a8, a6, a4, a2, a0 = \
                 (4*a12 + c6**2,
                  4*a10 + 2*c4*c6,
                  4*a8 + 2*c2*c6 + c4**2,
                  4*a6 + 2*c0*c6 + 2*c2*c4,
                  4*a4 + 2*c0*c4 + c2**2,
                  4*a2 + 2*c0*c2,
                  4*a0 + c0**2)
        F = \
          (-4*a8*a12 + a10**2)*X0**4 + \
          -4*a6*a12*X0**3*X1 + \
          -2*a6*a10*X0**3*X2 + \
          -4*a12*X0**3*X3 + \
          -4*a4*a12*X0**2*X1**2 + \
          (4*a2*a12 - 4*a4*a10)*X0**2*X1*X2 + \
          -2*a10*X0**2*X1*X3 + \
          (-4*a0*a12 + 2*a2*a10 - 4*a4*a8 + a6**2)*X0**2*X2**2 + \
          -4*a8*X0**2*X2*X3 + \
          -4*a2*a12*X0*X1**3 + \
          (8*a0*a12 - 4*a2*a10)*X0*X1**2*X2 + \
          (4*a0*a10 - 4*a2*a8)*X0*X1*X2**2 + \
          -2*a6*X0*X1*X2*X3 + \
          -2*a2*a6*X0*X2**3 + \
          -4*a4*X0*X2**2*X3 + \
          -4*X0*X2*X3**2 + \
          -4*a0*a12*X1**4 + \
          -4*a0*a10*X1**3*X2 + \
          -4*a0*a8*X1**2*X2**2 + \
          X1**2*X3**2 + \
          -4*a0*a6*X1*X2**3 + \
          -2*a2*X1*X2**2*X3 + \
          (-4*a0*a4 + a2**2)*X2**4 + \
          -4*a0*X2**3*X3
        AlgebraicScheme_subscheme_projective.__init__(self, PP, F)
        X, Y, Z = C.ambient_space().gens()
        if a0 == 0:
            a0 = a2
        phi = Hom(C, self)([X.parent().zero(), Z**2, X*Z, a0*X**2], Schemes())
        C._kummer_morphism = phi
        J._kummer_surface = self
Exemple #4
0
def julia_plot(c=-1, **kwds):
    r"""
    Plots the Julia set of a given complex `c` value. Users can specify whether
    they would like to display the Mandelbrot side by side with the Julia set.

    The Julia set of a given `c` value is the set of complex numbers for which
    the function `Q_c(z)=z^2+c` is bounded under iteration. The Julia set can
    be visualized by plotting each point in the set in the complex plane.
    Julia sets are examples of fractals when plotted in the complex plane.

    ALGORITHM:

    Define the map `Q_c(z) = z^2 + c` for some `c \in \mathbb{C}`. For every
    `p \in \mathbb{C}`, if `|Q_{c}^{k}(p)| > 2` for some `k \geq 0`,
    then `Q_{c}^{n}(p) \to \infty`. Let `N` be the maximum number of iterations.
    Compute the first `N` points on the orbit of `p` under `Q_c`. If for
    any `k < N`, `|Q_{c}^{k}(p)| > 2`, we stop the iteration and assign a color
    to the point `p` based on how quickly `p` escaped to infinity under
    iteration of `Q_c`. If `|Q_{c}^{i}(p)| \leq 2` for all `i \leq N`, we assume
    `p` is in the Julia set and assign the point `p` the color black.

    INPUT:

    - ``c`` -- complex (optional - default: ``-1``), complex point `c` that
      determines the Julia set.

    kwds:

    - ``period`` -- list (optional - default: ``None``), returns the Julia set
      for a random `c` value with the given (formal) cycle structure.

    - ``mandelbrot`` -- boolean (optional - default: ``True``), when set to
      ``True``, an image of the Mandelbrot set is appended to the right of the
      Julia set.

    - ``point_color`` -- RGB color (optional - default: ``[255, 0, 0]``),
      color of the point `c` in the Mandelbrot set.

    - ``x_center`` -- double (optional - default: ``-1.0``), Real part
      of center point.

    - ``y_center`` -- double (optional - default: ``0.0``), Imaginary part
      of center point.

    - ``image_width`` -- double (optional - default: ``4.0``), width of image
      in the complex plane.

    - ``max_iteration`` -- long (optional - default: ``500``), maximum number
      of iterations the map `Q_c(z)`.

    - ``pixel_count`` -- long (optional - default: ``500``), side length of
      image in number of pixels.

    - ``base_color`` -- RGB color (optional - default: ``[40, 40, 40]``), color
      used to determine the coloring of set.

    - ``iteration_level`` -- long (optional - default: 1), number of iterations
      between each color level.

    - ``number_of_colors`` -- long (optional - default: 30), number of colors
      used to plot image.

    - ``interact`` -- boolean (optional - default: ``False``), controls whether
      plot will have interactive functionality.

    OUTPUT:

    24-bit RGB image of the Julia set in the complex plane.

    EXAMPLES::

        sage: julia_plot()
        1001x500px 24-bit RGB image

    To display only the Julia set, set ``mandelbrot`` to ``False``::

        sage: julia_plot(mandelbrot=False)
        500x500px 24-bit RGB image

    To display an interactive plot of the Julia set in the Notebook,
    set ``interact`` to ``True``::

        sage: julia_plot(interact=True)
        <html>...</html>

    To return the Julia set of a random `c` value with (formal) cycle structure
    `(2,3)`, set ``period = [2,3]``::

        sage: julia_plot(period=[2,3])
        1001x500px 24-bit RGB image

    To return all of the Julia sets of `c` values with (formal) cycle structure
    `(2,3)`::

        sage: period = [2,3] # not tested
        ....: R.<c> = QQ[]
        ....: P.<x,y> = ProjectiveSpace(R,1)
        ....: f = DynamicalSystem([x^2+c*y^2, y^2])
        ....: L = f.dynatomic_polynomial(period).subs({x:0,y:1}).roots(ring=CC)
        ....: c_values = [k[0] for k in L]
        ....: for c in c_values:
        ....:     julia_plot(c)
    """

    x_center = kwds.pop("x_center", 0.0)
    y_center = kwds.pop("y_center", 0.0)
    image_width = kwds.pop("image_width", 4.0)
    max_iteration = kwds.pop("max_iteration", 500)
    pixel_count = kwds.pop("pixel_count", 500)
    base_color = kwds.pop("base_color", [50, 50, 50])
    iteration_level = kwds.pop("iteration_level", 1)
    number_of_colors = kwds.pop("number_of_colors", 50)
    point_color = kwds.pop("point_color", [255, 0, 0])
    interacts = kwds.pop("interact", False)
    mandelbrot = kwds.pop("mandelbrot", True)
    period = kwds.pop("period", None)

    if not period is None:
        R = PolynomialRing(QQ, 'c')
        c = R.gen()
        P = ProjectiveSpace(R, 1, 'x,y')
        x,y = P.gens()
        f = DynamicalSystem([x**2+c*y**2, y**2])
        L = f.dynatomic_polynomial(period).subs({x:0,y:1}).roots(ring=CC)
        c = L[randint(0,len(L)-1)][0]

    c_real = CC(c).real()
    c_imag = CC(c).imag()

    if interacts:
        @interact(layout={'bottom':[['real_center'], ['im_center'], ['width']],
         'top':[['iterations'], ['level_sep'], ['color_num'], ['mandel'],
         ['cx'], ['cy']], 'right':[['image_color'], ['pt_color']]})
        def _(cx = input_box(c_real, '$Re(c)$'),
            cy = input_box(c_imag, '$Im(c)$'),
            real_center=input_box(x_center, 'Real Center'),
            im_center=input_box(y_center, 'Imaginary Center'),
            width=input_box(image_width, 'Width of Image'),
            iterations=input_box(max_iteration, 'Max Number of Iterations'),
            level_sep=input_box(iteration_level, 'Iterations between Colors'),
            color_num=input_box(number_of_colors, 'Number of Colors'),
            image_color=color_selector(default=Color([j/255 for j in base_color]),
             label="Image Color", hide_box=True),
            pt_color=color_selector(default=Color([j/255 for j in point_color]),
             label="Point Color", hide_box=True),
            mandel=checkbox(mandelbrot, label='Mandelbrot set')):

            if mandel:
                return julia_helper(cx, cy, real_center, im_center,
                 width, iterations, pixel_count, level_sep, color_num,
                 image_color, pt_color).show()

            else:
                return fast_julia_plot(cx, cy, real_center, im_center,
                 width, iterations, pixel_count, level_sep, color_num,
                 image_color).show()

    else:
        if mandelbrot:
            return julia_helper(c_real, c_imag, x_center, y_center,
             image_width, max_iteration, pixel_count, iteration_level,
             number_of_colors, base_color, point_color)

        else:
            return fast_julia_plot(c_real, c_imag, x_center, y_center,
             image_width, max_iteration, pixel_count, iteration_level,
             number_of_colors, base_color)