Skip to content

Latest commit

 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

📐 Quadratic Function Analyzer

Language Status


📋 Description

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.

🤨 So... Why Would You Use This?

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.


📖 Quick Usage 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

Calculate Delta

After obtaining A, B and C:

int delta = Delta(&a, &b, &c);

Calculate the Vertex

int x = GetVerticeX(&a, &b);
int y = GetVerticeY(&delta, &a);

The result represents:

(x, y)

Calculate the Roots

Positive root:

int x1 = BaskharaPlus(&a, &b, &c, &delta);

Negative root:

int x2 = BaskharaMinus(&a, &b, &c, &delta);

Automatic Functions

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 int for mathematical results, so fractional values are truncated. The parser also supports only a limited set of quadratic expression formats.


🎯 Study Objectives

This project was created to practice:

  • C programming fundamentals
  • String manipulation
  • Character analysis with ctype.h
  • Dynamic memory allocation with malloc() and free()
  • 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

About

A C study project for parsing and analyzing quadratic functions, calculating coefficients, Delta, vertex coordinates, and roots.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Contributors

Languages