Problem 46833. Roots, Bloody Roots: part 1/2

Using curves or lines, we can easily spot roots from n-degree polynomials in 2D: wherever they cross the real line, we know there is a root. However, as we are well aware, roots can also be complex numbers. In this case, plotting curves no longer seem adequate since they won't be found at the real line. That's when coloring comes into place; by painting the 2D plane, we can visualize where complex or real roots are and get a sense of what's happening in a function.
In this problem, we will color the complex plane using the color space HSV. Imagine that there is a vector spawning from the origin to each point in the complex plane; horizontal axis imaginary and vertical axis real. Each vector has an angle α (from the real-line) and a norm β that defines a hue (H), and a brightness (V), respectively; for saturation (S), we assume a fixed value of 1, . H and V must range from 0 to 1, and to fit them into it, we will have to divide the angle by ,, and apply the cube root to the Min-max normalization of the distance, (the cube root allows a faster transition between low and high brightness).
Once we have the HSV value for a point at the complex plane, we can use the function hsv2rgb to find the RGB corresponding value implement it if it becomes unavailable in the future (read about it here). All RGB values must be rounded to 4 decimal places to obtain the following result:
All you have to do in this problem is to reproduce the above result for any matrix size, m x n x 3, given m and n as input. Moreover, the complex plane origin is always in the middle of the image origin. Notice that since the plane origin has the vector null, it will generate a black dot that brightens while going to the figure's edge.
Note-1: This problem is inspired by a 3Blue1Brown's video:, and I recommend that you watch his video if you haven't already. However, it is not required that you do to solve this problem.
This problem has two parts, since it may not be easy to do everything at once. And you are encouraged to use the code for this 1st part of the problem into the next: Problem 46963.
Note-2: This problem was last updated 21/08/2020; thanks to Alex's and Svyatoslav's feedback. All solutions were rescored. Please, let me know if anyone run into issues.

Solution Stats

22.22% Correct | 77.78% Incorrect
Last Solution submitted on May 29, 2024

Problem Comments

Solution Comments

Show comments

Problem Recent Solvers5

Suggested Problems

More from this Author5

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!