This C++ project is developed as part of the Introduction to Programming course at the Faculty of Mathematics and Informatics, Sofia University. It is a polynomial calculator capable of handling polynomials with rational coefficients, providing a wide range of mathematical operations and functionalities.
The polynomial calculator supports the following operations:
-
Addition of Polynomials
( P(x) + Q(x) ) -
Subtraction of Polynomials
( P(x) - Q(x) ) -
Multiplication of Polynomials
( P(x) \cdot Q(x) ) -
Division of Polynomials
- ( P(x) / Q(x) ), where ( Q(x) \neq 0 ) and ( \text{deg}(P(x)) \geq \text{deg}(Q(x)) ).
- Calculates both the quotient and remainder of the division.
-
Multiplication of a Polynomial by a Rational Number
-
Evaluation of a Polynomial
- Evaluate ( P(x) ) for a given rational number ( x ).
-
GCD (Greatest Common Divisor) of Two Polynomials
- Computed using the Euclidean algorithm.
-
Vieta's Formulas
- Analyze the relationships between the roots and coefficients of a polynomial.
-
Representation of a Polynomial in Terms of Powers of ( (x + a) )
-
Factorization of Polynomials
- If a polynomial is factorable, extract all rational roots.
Users can input polynomials with rational coefficients and perform various operations using an intuitive interface. The calculator is designed to be robust and efficient, making it a valuable tool for exploring polynomial arithmetic and analysis.
-
Addition: ( P(x) = 2x^2 + 3x + 1, Q(x) = x^2 - x + 2 )
Result: ( P(x) + Q(x) = 3x^2 + 2x + 3 ) -
Multiplication by a Rational Number:
( P(x) = x^2 + x, k = \frac{1}{2} )
Result: ( P(x) \cdot k = \frac{1}{2}x^2 + \frac{1}{2}x )
-
Division: ( P(x) = x^3 + 2x^2 + x + 1, Q(x) = x + 1 )
Quotient: ( x^2 + x + 1 )
Remainder: ( 0 ) -
Factorization:
( P(x) = x^2 - 3x + 2 )
Roots: ( x = 1, x = 2 )
Factorized form: ( P(x) = (x - 1)(x - 2) )
- Clone the repository:
git clone https://github.com/yourusername/polynomial-calculator.git
- Compile the code using a C++ compiler (e.g.,
g++
):g++ -o polynomial_calculator polynomial_calculator.cpp
- Run the executable:
./polynomial_calculator
- Support for complex coefficients.
- Graphical user interface (GUI) for better interaction.
- Extended factorization methods for irreducible polynomials.
This project is licensed under the MIT License.