A C# console application providing computational tools for GCSE and Further Mathematics topics. The engine supports Pure Mathematics, Statistics, and Mechanics calculations with optional step-by-step explanations for educational purposes.
This project provides:
- Reliable implementations of common mathematical algorithms for students and educators
- A modular architecture suitable for extension with additional mathematical topics
- Step-by-step calculation breakdowns for learning and verification
- Students studying GCSE Maths/Further Maths or A-level Mathematics
- Educators requiring worked examples of mathematical procedures
- Developers seeking reference implementations of mathematical algorithms in C#
- Pythagoras Theorem: Calculate hypotenuse or missing sides in right triangles
- Trigonometry: Solve for missing sides and angles using SOH-CAH-TOA ratios
- Matrices: Addition, subtraction, scalar operations, multiplication, and determinant calculation (2×2)
- Averages: Mean, median, mode, and range for raw data and frequency tables
- Dispersion: Standard deviation, variance, and interquartile range
- Bivariate Analysis: Spearman's Rank correlation with ranked data processing
- Newton's Laws: F = ma calculations solving for force, mass, or acceleration
- Uniform Acceleration: SUVAT equation solvers for kinematics problems
All core calculations have optional step-by-step explanations available through dedicated "Tutor" classes. These return CalculationResult objects containing both the numeric answer and a formatted list of calculation steps.
MathsEngine/
├── Menu/ # Console interface organized by mathematical topic
│ ├── Pure/ # Menus for Pure Mathematics topics
│ ├── Statistics/ # Menus for Statistics topics
│ └── Mechanics/ # Menus for Mechanics topics
├── Modules/ # Core calculation logic
│ ├── Pure/ # Trigonometry, Matrices, Pythagoras implementations
│ ├── Statistics/ # Statistical calculation classes
│ ├── Mechanics/ # Dynamics and kinematics solvers
│ └── Explanations/ # Step-by-step wrappers for educational use
├── Utils/ # Input parsing, validation, and custom exceptions
├── Examples/ # Demonstration code for Explanations module
└── Program.cs # Application entry point
Separation of Concerns: User interface code (Menu/) is isolated from calculation logic (Modules/). This allows the calculation classes to be reused in different contexts (GUI, web service, unit tests) without modification.
Wrapper Pattern for Explanations: The Explanations module provides step-by-step breakdowns without modifying existing calculation classes. This maintains backward compatibility and keeps educational features optional.
Custom Exception Hierarchy: Domain-specific exceptions (e.g., IncompatibleMatrixMultiplicationException, HypotenuseNotLongestSideException) provide clearer error messages than generic .NET exceptions.
- .NET Framework 4.x or .NET 6+ SDK
- Visual Studio or compatible C# IDE
- Open
MathsEngine.slnin Visual Studio - Build the solution (Build → Build Solution)
- Run the project (F5 or Start)
- Navigate using numeric menu inputs
The application presents a hierarchical menu system:
- Select a category (Pure, Mechanics, Statistics)
- Select a specific topic (e.g., Trigonometry, Matrices)
- Select a calculation type
- Enter required values
- View result and return to menu
To use calculation classes directly:
using MathsEngine.Modules.Pure.Trigonometry;
// Basic calculation
double result = Trigonometry.CalculateMissingSide(
knownSideLength: 10,
angle: 30,
knownSideType: SideType.Adjacent,
sideToFind: SideType.Opposite
);
// With step-by-step explanation
using MathsEngine.Modules.Explanations.Pure;
var calculation = TrigonometryTutor.CalculateMissingSideWithSteps(
knownSideLength: 10,
angle: 30,
knownSideType: SideType.Adjacent,
sideToFind: SideType.Opposite
);
Console.WriteLine($"Answer: {calculation.Value}");
Console.WriteLine(calculation.GetStepsAsString());-
Create calculation class in
Modules/[Category]/:public static class NewTopicCalculator { public static double Calculate(double input) { /* ... */ } }
-
Create menu class in
Menu/[Category]/:internal class NewTopicMenu { public static void Menu() { /* ... */ } }
-
Add custom exceptions to
Utils/Exceptions.csif needed -
(Optional) Create explanation wrapper in
Modules/Explanations/[Category]/:public static class NewTopicTutor { public static CalculationResult CalculateWithSteps(double input) { var steps = new List<string>(); // Add step descriptions double value = NewTopicCalculator.Calculate(input); return new CalculationResult(value, steps); } }
-
Register in parent menu by adding a menu option
Tests are organized in the MathsEngine.Tests project. To add tests for new functionality:
- Create a test class matching the module structure
- Test calculation accuracy against known mathematical results
- Test edge cases (zero values, invalid inputs, boundary conditions)
- Verify custom exceptions are thrown correctly
Most calculation methods are stateless transformations (input → output). Static methods make this explicit and avoid unnecessary object instantiation.
MatrixBase uses instance methods because matrices are data objects with properties (dimensions, values). Operations on matrices are implemented in the static MatrixCalculator class.
Integrating step-by-step explanations into calculation classes would:
- Increase complexity for users who only need numeric results
- Mix presentation concerns with business logic
- Break backward compatibility
The wrapper pattern keeps explanations opt-in while reusing existing calculation code.
- Console-only interface (no graphical plotting or interactive visualization)
- No persistent storage of calculation history
- Limited to numeric computation (no symbolic algebra or equation solving)
- Matrix operations currently support 2×2 determinants only
MIT License (see LICENSE file)