Quadratic Function Analyzer is a study project developed in C to practice programming fundamentals, string manipulation, memory management, and mathematical algorithms.
The project was created as an exercise to understand how a program can receive a quadratic function as a string and extract useful mathematical information from it.
For example, given:
7x^2-3x+5
the program can extract:
A = 7
B = -3
C = 5
and use these values to calculate:
Delta
Vertex X
Vertex Y
Root +
Root -
The main purpose of this project is learning and experimentation, rather than providing a production-ready mathematical library.
Honestly, you probably shouldn't.
This is a study project created to practice C programming, pointers, string manipulation, memory allocation, and basic parsing.
But, for some reason, you still want to use it, here is a quick guide.
The library works with a string representing a quadratic function:
char function[] = "7x^2-3x+5";From this string, you can extract the coefficients:
int a = GetA(function);
int b = GetB(function);
int c = GetC(function);Result:
A = 7
B = -3
C = 5
After obtaining A, B and C:
int delta = Delta(&a, &b, &c);int x = GetVerticeX(&a, &b);
int y = GetVerticeY(&delta, &a);The result represents:
(x, y)
Positive root:
int x1 = BaskharaPlus(&a, &b, &c, &delta);Negative root:
int x2 = BaskharaMinus(&a, &b, &c, &delta);You can also skip manually extracting the coefficients.
For example:
int delta = AutoDelta(function);Or calculate the roots directly:
int x1 = AutoBaskharaPlus(function);
int x2 = AutoBaskharaMinus(function);And the vertex:
int xv = AutoVerticeX(function);
int yv = AutoVerticeY(function);This allows a complete calculation with only the original function string:
char function[] = "7x^2-3x+5";
printf("Delta: %d\n", AutoDelta(function));
printf("Vertex X: %d\n", AutoVerticeX(function));
printf("Vertex Y: %d\n", AutoVerticeY(function));
printf("Root +: %d\n", AutoBaskharaPlus(function));
printf("Root -: %d\n", AutoBaskharaMinus(function));Note: The current implementation uses
intfor mathematical results, so fractional values are truncated. The parser also supports only a limited set of quadratic expression formats.
This project was created to practice:
- C programming fundamentals
- String manipulation
- Character analysis with
ctype.h - Dynamic memory allocation with
malloc()andfree() - Function decomposition
- Pointers
- Mathematical algorithms
- Parsing structured data from strings
- Working with the C standard library
The implementation intentionally remains simple so that the underlying programming concepts can be studied and understood.
- Software design