A comprehensive mathematical library providing 54+ functions covering number theory, trigonometry, logarithms, statistical operations, and special functions. Compatible with Python's math module behavior and optimized for .NET performance.
$ dotnet add package FTI.MathNETThis package provides comprehensive mathematical functions with ease of use to implement logic with fewer lines of code. It delivers better performance and covers all essential mathematical operations similar to Python's math module.
IsSqrt() function integer divisionFmod() implementation to match C library behaviorFrexp() mantissa calculation for proper IEEE complianceInstall FTI.MathNET via NuGet Package Manager:
dotnet add package FTI.MathNET
Or specify a version:
dotnet add package FTI.MathNET --version 1.4.0
Install-Package FTI.MathNET
If you have the compiled DLL, reference it directly:
csc -reference:FTI.MathNET.dll Program.cs
dotnet restore
dotnet build
using FTI.MathNET;
class Program
{
static void Main(string[] args)
{
// Mathematical constants
Console.WriteLine($"Pi = {Maths.Pi}");
Console.WriteLine($"E = {Maths.E}");
Console.WriteLine($"Tau = {Maths.Tau}");
// Number theory functions
long factorial = Maths.Factorial(5);
Console.WriteLine($"Factorial(5) = {factorial}"); // 120
long combinations = Maths.Comb(10, 3);
Console.WriteLine($"C(10,3) = {combinations}"); // 120
int gcd = Maths.GCD(48, 18, 24);
Console.WriteLine($"GCD(48,18,24) = {gcd}"); // 6
// Power and root functions
double sqrt = Maths.Sqrt(16);
Console.WriteLine($"√16 = {sqrt}"); // 4
double cbrt = Maths.Cbrt(27);
Console.WriteLine($"∛27 = {cbrt}"); // 3
// Trigonometric functions
double sin = Maths.Sin(Maths.Pi / 2);
Console.WriteLine($"sin(π/2) = {sin}"); // 1
// Logarithmic functions
double log = Maths.Log(Math.E);
Console.WriteLine($"ln(e) = {log}"); // 1
double log10 = Maths.Log10(100);
Console.WriteLine($"log₁₀(100) = {log10}"); // 2
// Special functions
double gamma = Maths.Gamma(5);
Console.WriteLine($"Γ(5) = {gamma}"); // 24
// Statistical functions
double[] point1 = { 0, 0, 0 };
double[] point2 = { 3, 4, 5 };
double distance = Maths.Dist(point1, point2);
Console.WriteLine($"Distance = {distance}"); // 7.07...
// Vector operations
double[] coordinates = { 3, 4, 5 };
double magnitude = Maths.Hypot(coordinates);
Console.WriteLine($"Magnitude = {magnitude}"); // 7.07...
}
}
using FTI.MathNET;
// Working with collections
double[] values = { 1.1, 2.2, 3.3, 4.4, 5.5 };
double sum = Maths.FSum(values); // Accurate floating-point sum
double product = Maths.Prod(values); // Product of all values
// Angle conversions
double radians = Maths.Radians(45); // Convert 45° to radians
double degrees = Maths.Degrees(Maths.Pi / 4); // Convert π/4 to degrees
// Floating-point utilities
bool isClose = Maths.IsClose(0.1 + 0.2, 0.3); // true (handles floating-point precision)
bool isFinite = Maths.IsFinite(42.0); // true
bool isInf = Maths.IsInf(double.PositiveInfinity); // true
// IEEE 754 operations
double remainder = Maths.Remainder(10.5, 3.0);
(double mantissa, int exponent) = Maths.Frexp(8.0); // (0.5, 4)
double rebuilt = Maths.Ldexp(mantissa, exponent); // 8.0
Comb(n, k) - Combinations (n choose k)Factorial(n) - Factorial of nGCD(params int[]) - Greatest Common DivisorIsqrt(n) - Integer square rootLCM(params int[]) - Least Common MultiplePerm(n, k) - PermutationsCeil(x) - Ceiling functionFloor(x) - Floor functionTrunc(x) - Truncate to integerFabs(x) - Absolute valueCopysign(x, y) - Copy sign from y to magnitude of xFrexp(x) - Extract mantissa and exponentLdexp(x, i) - x * 2^iModf(x) - Split into fractional and integer partsExp(x) - e^xExp2(x) - 2^xExpm1(x) - e^x - 1 (accurate for small x)Log(x, base) - Logarithm to given baseLog1p(x) - ln(1 + x) (accurate for small x)Log2(x) - Base-2 logarithmLog10(x) - Base-10 logarithmPow(x, y) - x^ySqrt(x) - Square rootCbrt(x) - Cube rootSin(x), Cos(x), Tan(x) - Basic trig functionsAsin(x), Acos(x), Atan(x), Atan2(y, x) - Inverse trig functionsDegrees(x) - Convert radians to degreesRadians(x) - Convert degrees to radiansSinh(x), Cosh(x), Tanh(x) - Hyperbolic functionsAsinh(x), Acosh(x), Atanh(x) - Inverse hyperbolic functionsErf(x) - Error functionErfc(x) - Complementary error functionGamma(x) - Gamma functionLGamma(x) - Log of absolute value of Gamma functionDist(p, q) - Euclidean distance between pointsFSum(values) - Accurate floating-point sumHypot(coords) - Euclidean norm (magnitude)Prod(values, start) - Product of valuesSumProd(p, q) - Sum of productsPi - π (3.14159...)E - Euler's number (2.71828...)Tau - τ = 2π (6.28318...)Inf - Positive infinityNan - Not a NumberThis project is licensed under the MIT License - see the LICENSE file for details.
Feel free to contribute to this project by submitting issues or pull requests.
If you encounter any issues or need help, please create an issue on the GitHub repository.
Author: Soumyadip Majumder
Copyright: ©FTI, 2025 Soumyadip Majumder. All rights reserved.