Yıldız Technical University
BLM1022 - Numerical Analysis
2024-2025 Spring Semester - 1st Year Term Project
This project is a comprehensive tool that implements fundamental numerical analysis methods using the C programming language. It's an interactive console application that can parse mathematical functions and perform calculations using 10 different numerical methods.
- Bisection Method - Root finding
- Regula-Falsi (False Position) Method - Root finding
- Newton-Raphson Method - Root finding
- Inverse Matrix - Linear equation systems
- Cholesky (LU Decomposition) Method - Matrix decomposition
- Gauss-Seidel Method - Iterative equation solving
- Numerical Differentiation - Forward, backward, and central difference
- Simpson's Rule - Numerical integration (1/3 and 3/8)
- Trapezoidal Rule - Numerical integration
- Gregory-Newton Interpolation - Polynomial interpolation
- Mathematical Expression Parser: Accepts and evaluates complex mathematical functions as strings
- Supported Functions:
- Trigonometric:
sin(x),cos(x),tan(x),cot(x) - Inverse Trigonometric:
arcsin(x),arccos(x),arctan(x),arccot(x) - Logarithmic:
log(x),log_n(x)(for any base n) - Exponential:
exp(x),e^x,2^x - Constants:
pi,e
- Trigonometric:
- Interactive User Interface: Menu-driven easy-to-use interface
- Detailed Iteration Information: Computation details at each step
- GCC or any C compiler
math.hlibrary support
gcc numerical_analysis.c -o numerical_analysis -lm./numerical_analysisFor Windows:
numerical_analysis.exeWhen you start the program, you'll be greeted with a menu:
---------------------------------------------------------
Quit: 0
Bisection: 1
Regula-Falsi: 2
Newton-Raphson: 3
Inverse Matrix: 4
Cholesky Method: 5
Gauss-Seidal: 6
Numerical differentiation: 7
Simpson's Rule: 8
Trapezoidal Rule: 9
Gregory-Newton: 10
---------------------------------------------------------
Which operation do you want to do? 1
Please enter your function:
> x^3 - 2*x - 5
Enter a value: 2
Enter b value: 3
Enter max error: 0.0001
Enter maximum iterations: 100
Which operation do you want to do? 7
Please enter your function:
> sin(x) + x^2
At what x value do you want to calculate the derivative? 1.5
What will be the h value? (recommended to be small like 0.0001) 0.0001
Which operation do you want to do? 8
Please enter your function:
> x^2 + 2*x + 1
Lower limit of the integration? 0
Upper limit of the integration? 2
How many parts do you want to split the integral into? 10
numerical_analysis.c- Main source codeexamples.pdf- Solved example problemsproject_report.pdf- Detailed project report and methodologyREADME.md- Project documentation
- Variable: Use
x - Exponentiation:
^operator (e.g.,x^2,2^x) - Multiplication/Division:
*and/ - Addition/Subtraction:
+and- - Parentheses:
(and)are supported - Trigonometric functions: Work in radians
- Special constants:
pi≈ 3.14159,e≈ 2.71828
x^3 - 2*x + 1sin(x) + cos(2*x)log(x) + x^2exp(x) - 3*x(x+1)*(x-2)/(x+3)
The program represents mathematical expressions using Abstract Syntax Tree (AST):
typedef enum {
NODE_CONSTANT, // Constant values
NODE_VARIABLE, // Variables (x)
NODE_OPERATOR, // +, -, *, /, ^
NODE_FUNCTION // sin, cos, log, etc.
} NodeType;Mathematical expressions are parsed using recursive descent parsing:
addsub_parser()- Addition/subtractionmuldiv_parser()- Multiplication/divisionexp_parser()- Exponentiationparse_primary()- Primary expressions (numbers, variables, functions)
- Maximum iterations: User-definable
- Error tolerance: Adjustable (e.g., 1e-6, 1e-10)
- Memory management: Dynamic memory allocation for flexible matrix sizes
- Numerical stability: Pivot selection and condition checking
- Functions work only with single variable (
x) - Trigonometric functions operate in radian mode
- Matrix operations require square matrices
- Gregory-Newton requires equally spaced points
The algorithms and methods used in this project are taken from standard numerical analysis sources:
- Numerical Analysis (Burden & Faires)
- Numerical Methods for Engineers (Chapra & Canale)
- BLM1022 Numerical Analysis Course Notes
Yıldız Technical University
Aziz Eren YILDIRIM
Computer Engineering - 1st Year
2024-2025 Spring Semester
This project is licensed under the MIT License. See the LICENSE file for details.
This is a student project. Feel free to open issues or submit pull requests for suggestions and improvements.
If you like this project, don't forget to give it a star! ⭐
Note: This project is for educational purposes and was developed as part of the Numerical Analysis course at Yıldız Technical University.