This project is a tool for making numerical calculations. It is made for the semester project of Numerical Analysis course at Yıldız Technical University. The project requirements can be found here (The file is in Turkish).
The calculator asks for the numerical method first. User enters a number to choose the corresponding method. Implemented methods are:
- Bisection
- Regula-Falsi
- Newton-Rapshon
- Inverse of an NxN Matrix
- Gauss Elimination
- Gauss-Seidel
- Numerical Differentiation
- Simpson’s Rule (1/3 and 3/8 Rules)
- Trapezoidal Rule
- Gregory-Newton Interpolation without Variable Transformation
Then, depending on the selected method, the user is asked to enter a matrix or function. After that, program asks for needed parameters. And finally, the program starts the iterations. If it doesn't converge, it stops and prints final values to the user. (Convergence conditions are given by user so it can iterate endlessly.)
- Use only "x" for the variable, "+" for summation, "-" for subtraction, "*" for multiplication, "/" for division and "^" for power operations.
- For example,
$3x^2+5x+8$ has to be entered in a form like that:3*x^2+5*x+8 - If you are not sure, use brackets to indicate the priority of the terms.
- DO NOT use the SPACE character.
- You can use sin() for sine, cos() for cosine, tan() for tangent, cot() for cotangent, sec() for secant, csc() for cosecant. You can also use inverse trigonometric functions by adding arc at the beginning of the function. (e.g. arccos(), arctan()...)
- You can use log_(base)() or ln() for logarithm.
- You can use "pi" for
$\pi$ and "e" for$e$ . - Decimal numbers are supported. (1.25 etc.)
- Some Examples:
3*sin^(5*x)(x)
2*log_(0.5)(sin(x))
-e^(2*x+4)
More detailed explanation can be found here (The file is in Turkish).
Parsing the string is being done in 3 steps.
At this step, program splits the string by using "+" and "-" characters. It counts the opening and closing brackets to differentiate if it is a composite function or a new term. It creates an array of term strings without changing the order.
At this step, program determines the types of every term and creates the linked list of Term structs. Construction of the tree is explained below in the "Data Structure" part.
At this step, program parses the string inside of every bracket couple. This is being done with recursion so the program runs these 3 steps for every couple of brackets. For each of them, it creates a new branch in the tree and fills every struct in this step.