Math 4 Solver — Numerical Methods Toolkit
Projects
C++ Developer

Math 4 Solver — Numerical Methods Toolkit

Comprehensive numerical computation toolkit featuring symbolic differentiation, multiple root-finding algorithms (Bisection, Newton-Raphson, Newton-Jacobian), numerical integration methods (Trapezoidal, Simpson's), least squares curve fitting, and polynomial interpolation. Built with a custom infix-to-postfix expression parser supporting 13 mathematical functions including trigonometric, logarithmic, and inverse trigonometric operations.

2,180
lines Of Code
8+
numerical Methods
13
supported Functions
1e-7
tolerance
1000
max Data Points
The Challenge icon

The Challenge

Solving complex mathematical problems manually is time-consuming, error-prone, and often requires deep understanding of numerical methods. Students and engineers frequently need to find roots of non-linear equations that cannot be solved analytically, perform numerical differentiation and integration for functions without closed-form solutions, fit curves to experimental data points, interpolate values from discrete data sets, and understand step-by-step solutions for learning purposes. Traditional tools like MATLAB or Wolfram Alpha are either expensive, require internet connectivity, or don't provide detailed step-by-step breakdowns. There was a clear need for a lightweight, educational tool that combines multiple numerical methods in a single, accessible console application.

The Solution icon

The Solution

Architected a modular C++ application using object-oriented design with inheritance hierarchies. The system uses a custom infix-to-postfix conversion algorithm (similar to Shunting Yard) that converts mathematical expressions (like 'x^2-cos(x)+3*sin(x)') into postfix notation for efficient stack-based evaluation. The core architecture centers around a CommonFunctions base class that handles expression preprocessing (converting function names to single-character tokens), infix-to-postfix conversion with operator precedence rules for arithmetic, trigonometric, logarithmic, and power operations, postfix evaluation using stack-based algorithms that handle multi-digit numbers, variables (x, y), and 13 mathematical functions, and multi-digit number handling with special encoding using global vectors to store numbers >9 and negative values. The inheritance hierarchy includes CommonFunctions (base class for parsing and evaluation), Differentiation (symbolic differentiation engine), BisectionMethod (root finding via bisection with 1e-7 tolerance), jacobianMethod (systems of equations solver using 2x2 matrix inversion), newtonthodMethod (Newton-Raphson with max 20 iterations), NumericalIntegration (Trapezoidal and Simpson's Rule with error estimation using higher-order derivatives, default n=50), NumericalDifferentiation (numerical differentiation formulas), and standalone classes for leastSquavesCurveFitting (linear regression solving for coefficients a and b, parabolic fitting displaying table with x, x², x³, x⁴ terms without coefficient solving, exponential fitting using logarithmic transformation, power law fitting using log-log transformation), Lagrange (up to 1,000 data points with formatted table display), and divDifference (up to 100 data points with difference table output). The symbolic differentiation engine implements calculus rules (product, quotient, chain rule) and handles composite functions (e.g., cos(cos(x)) → -sin(cos(x)) * -sin(x)), power functions with variable bases and exponents, trigonometric and inverse trigonometric functions (sin, cos, tan, sec, csc, cot, arcsin, arccos, arctan), and logarithmic functions with arbitrary bases (ln, log). Designed a hierarchical CLI menu system with input validation, optional step-by-step solution display, and formatted ASCII table output for iterative methods with configurable precision (4, 6, 9, or 10 decimal places depending on the method).

The Impact icon

The Impact

The application successfully processes complex mathematical expressions efficiently, making it suitable for educational use and quick computations. The step-by-step solution feature has proven particularly valuable for students learning numerical methods, as it shows intermediate iterations and convergence behavior. The symbolic differentiation capability enables users to understand how derivatives are computed, not just the final result, setting it apart from black-box solutions like Wolfram Alpha. The modular architecture makes it easy to extend with additional numerical methods, and the expression parser's support for 13 functions (sin, cos, tan, sec, csc, cot, arcsin, arccos, arctan, ln, log, exp, root) makes it versatile for various mathematical domains. The codebase has been refactored for portability, removing Windows-specific dependencies to enable execution on online compilers like JDoodle, making it accessible to a wider audience without requiring local compilation setup.

Gallery

Math 4 Solver — Numerical Methods Toolkit - Image 1
Math 4 Solver — Numerical Methods Toolkit - Image 2
Math 4 Solver — Numerical Methods Toolkit - Image 3
Math 4 Solver — Numerical Methods Toolkit - Image 4

Technologies Used

C++
Object-Oriented Programming
Numerical Methods
Algorithm Design
Data Structures

Demo

Interactive Code Demo

Run this code in an interactive terminal. Click the button below to open the code editor and execute it.

Run Code in JDoodle

Opens in a new tab