Coding Example: The Mandelbrot Set (NumPy approach)
In this lesson, we are going to look at two NumPy approaches to solve this case study!
We'll cover the following
Solution 1: NumPy Implementation
The trick is to search at each iteration values that have not yet diverged and update relevant information for these values and only these values. Because we start from Z = 0, we know that each value will be updated at least once (when they’re equal to 0, they have not yet diverged) and will stop being updated as soon as they’ve diverged. To do that, we’ll use NumPy fancy indexing with the less(x1,x2) function that return the truth value of (x1 < x2) element-wise.
Get hands-on with 1400+ tech skills courses.