Skip to content

Commit

Permalink
gh-35900: complex_dynamics, fix: mandelbrot_plot throws exception for…
Browse files Browse the repository at this point in the history
… z^2*(z-c) + c

    
to re-produce the crash:
R.<z,c> = CC[]
f = z^2*(z-c) + c
mandelbrot_plot(expand(f),parameter=c)
### 📚 Description

Essential, the modified function has a fast case and a slow case. It
tests which one it's working with in a way that will crash if it's the
slow case.

[The documentation](https://doc.sagemath.org/html/en/reference/dynamics/
sage/dynamics/complex_dynamics/mandel_julia.html#sage.dynamics.complex_d
ynamics.mandel_julia.mandelbrot_plot) strongly implies that this would
work, so no documentation change.
### 📝 Checklist

<!-- Put an `x` in all the boxes that apply. It should be `[x]` not `[x
]`. -->

- [x] I have created tests covering the changes.
    
URL: #35900
Reported by: Forrest Hilton
Reviewer(s): Alexander Galarraga
  • Loading branch information
Release Manager committed Jul 29, 2023
2 parents 66baa6a + 7906e88 commit f85e7b8
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/sage/dynamics/complex_dynamics/mandel_julia_helper.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -680,6 +680,15 @@ cpdef polynomial_mandelbrot(f, parameter=None, double x_center=0,
sage: f = z^4 - z + c
sage: polynomial_mandelbrot(f, pixel_count=100)
100x100px 24-bit RGB image
::
sage: from sage.dynamics.complex_dynamics.mandel_julia_helper import polynomial_mandelbrot
sage: B.<c> = CC[]
sage: R.<z> = B[]
sage: f = z^2*(z-c) + c
sage: polynomial_mandelbrot(f, pixel_count=100)
100x100px 24-bit RGB image
"""

cdef:
Expand Down Expand Up @@ -763,7 +772,7 @@ cpdef polynomial_mandelbrot(f, parameter=None, double x_center=0,
df = f.derivative(z).univariate_polynomial()
critical_pts = df.roots(multiplicities=False)
constant_c = True
except PariError:
except (PariError, TypeError):
constant_c = False

# If c is in the constant term of the polynomial, then the critical points
Expand Down

0 comments on commit f85e7b8

Please sign in to comment.