#include <iostream>
#include <cmath>
// This is a simplified text-based representation. Graphical libraries
// like OpenGL, SDL, or plotting libraries like matplotlib (via a C++ wrapper)
// would be required for a true graphical output.
int main() {
// Define the bounds of the imaginary axis to display.
double minY = -5.0;
double maxY = 5.0;
// Define the resolution (number of lines to print).
int resolution = 21; // Higher number for finer detail
// Calculate the step size between each line.
double stepSize = (maxY - minY) / (resolution - 1);
// Calculate the values of the roots
double z1_imag = sqrt(3) + sqrt(5);
double z2_imag = sqrt(3) - sqrt(5);
std::cout << "Text-based Complex Plane (Imaginary Axis)" << std::endl;
std::cout << "-------------------------------------------" << std::endl;
for (int i = 0; i < resolution; ++i) {
double y = minY + i * stepSize;
// Print the imaginary axis
std::cout << "|";
//Mark the location of root 1
if (std::abs(y - z1_imag) < stepSize / 2) {
std::cout << " z1 ";
} else if (std::abs(y - z2_imag) < stepSize / 2) {
std::cout << " z2 ";
} else {
std::cout << " "; // 4 spaces to align with z1 and z2
}
std::cout << " " << y << "i" << std::endl;
}
std::cout << "-------------------------------------------" << std::endl;
std::cout << "z1 = " << z1_imag << "i" << std::endl;
std::cout << "z2 = " << z2_imag << "i" << std::endl;
return 0;
}