Skip to content

Commit ff88511

Browse files
Added a demonstration
1 parent bcca2fb commit ff88511

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

math/quadratic_equations_complex_numbers.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,12 @@
88
*/
99

1010
#include <array>
11+
#include <cassert>
1112
#include <cmath>
1213
#include <complex>
1314
#include <exception>
15+
#include <iomanip>
16+
#include <iostream>
1417

1518
/// @brief Quadratic equation calculator.
1619
/// @param a quadratic coefficient.
@@ -71,3 +74,14 @@ std::array<std::complex<long double>, 2> quadraticEquation(long double a,
7174

7275
return solutions;
7376
}
77+
78+
int main() {
79+
std::array<std::complex<long double>, 2> aaa = quadraticEquation(1, 1, 1);
80+
std::cout << "The complex roots of x^2 + x + 1 are " << aaa[0] << " and "
81+
<< aaa[1]
82+
<< ".\nMore precisely, and with the inaccuracy of floating point "
83+
"numbers, "
84+
<< std::setprecision(100) << aaa[0] << " and " << aaa[1] << "\n";
85+
86+
return 0;
87+
}

0 commit comments

Comments
 (0)