This project demonstrates skills in API design, object-oriented programming (OOP), data structures, database integration, and testing. The API simplifies polynomial expressions, evaluates them for a given value of x, and caches results in a database to avoid redundant computations.
-
Simplify Polynomial Expressions
Accepts a polynomial string, simplifies it by combining like terms, and handles polynomial multiplication.- Example:
- Input:
2*x^2 + 3*x - 5 + x^2 + x - Output:
3*x^2 + 4*x - 5
- Input:
- Example:
-
Evaluate Simplified Polynomials
Evaluates a simplified polynomial at a specific value of (x).- Example:
- Input: Polynomial:
3*x^2 + 4*x - 5, (x = 2) - Output:
15
- Input: Polynomial:
- Example:
-
Database Caching
Stores all polynomial simplifications and evaluations in a PostgreSQL database.- Reuses cached results for identical inputs to improve efficiency.
- Java: 17+
- Gradle: 7.6.0+
- PostgreSQL: 14+ (Dockerized)
- Docker: 20.10+
git clone https://github.com/RomenKost/polynomial-processing-api.git
cd polynomial-processing-api docker-compose up The API will be available at: http://localhost:8089
Simplifies a polynomial expression.
{
"polynomial": "2*x^2 + 3*x - 5 + x^2 + x"
}{
"polynomial": "3*x^2 + 4*x - 5"
}The API also handle polynomial multiplication as well.
{
"polynomial": "(x + 2) * (x - 1)"
}{
"polynomial": "x^2 + x - 2"
}Evaluate a polynomial expression.
{
"polynomial": "3*x^2 + 4*x - 5",
"x": 2
}{
"result": 15
}./gradlew clean testStop the application and remove Docker containers:
docker-compose down