FTI.MathNET
1.4.0
dotnet add package FTI.MathNET --version 1.4.0
NuGet\Install-Package FTI.MathNET -Version 1.4.0
<PackageReference Include="FTI.MathNET" Version="1.4.0" />
<PackageVersion Include="FTI.MathNET" Version="1.4.0" />
<PackageReference Include="FTI.MathNET" />
paket add FTI.MathNET --version 1.4.0
#r "nuget: FTI.MathNET, 1.4.0"
#:package FTI.MathNET@1.4.0
#addin nuget:?package=FTI.MathNET&version=1.4.0
#tool nuget:?package=FTI.MathNET&version=1.4.0
FTI.MathNET Library
About
This 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.
Features
- Number-theoretic functions: Factorial, GCD, LCM, Combinations, Permutations
- Floating-point operations: Ceiling, Floor, Truncation, Absolute value
- Power and logarithmic functions: Exp, Log, Pow, Sqrt, Cbrt
- Trigonometric functions: Sin, Cos, Tan, Asin, Acos, Atan, Atan2
- Hyperbolic functions: Sinh, Cosh, Tanh, Asinh, Acosh, Atanh
- Special functions: Gamma, Error function, Complementary error function
- Statistical functions: Distance, Sum, Product, Hypot
- Mathematical constants: Pi, E, Tau, Infinity, NaN
Release Notes
Version 1.4.0 - Bug Fixes and Improvements
- BREAKING CHANGE:
- Fixed critical bug in
IsSqrt()
function integer division - Fixed
Fmod()
implementation to match C library behavior - Fixed
Frexp()
mantissa calculation for proper IEEE compliance - Added mathematical constants: Pi, E, Tau, Inf, Nan
- Improved error handling with proper domain validation
- Enhanced documentation with correct C# exception types
- Added comprehensive input validation for mathematical functions
Version 1.3.0 - Latest Stable Release
- Initial release of the MathNET library
- Provides basic mathematical functions
- Includes support for .NET Core 3.1, .NET 6.0, 7.0, 8.0, and 9.0
- Added dependency on Newtonsoft.Json version 13.0.1
- Comprehensive documentation and examples included
Target Frameworks
- .NET Core 3.1
- .NET 6.0
- .NET 7.0
- .NET 8.0
- .NET 9.0
Installation
Install FTI.MathNET via NuGet Package Manager:
dotnet add package FTI.MathNET
Or specify a version:
dotnet add package FTI.MathNET --version 1.4.0
Package Manager Console
Install-Package FTI.MathNET
Using Pre-Built DLLs
If you have the compiled DLL, reference it directly:
csc -reference:FTI.MathNET.dll Program.cs
Build from Source
dotnet restore
dotnet build
Usage
Basic Examples
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...
}
}
Advanced Usage
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
Function Categories
Number-Theoretic Functions
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)
- Permutations
Floating-Point Manipulation
Ceil(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 parts
Power and Logarithmic Functions
Exp(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 root
Trigonometric Functions
Sin(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 radians
Hyperbolic Functions
Sinh(x)
,Cosh(x)
,Tanh(x)
- Hyperbolic functionsAsinh(x)
,Acosh(x)
,Atanh(x)
- Inverse hyperbolic functions
Special Functions
Erf(x)
- Error functionErfc(x)
- Complementary error functionGamma(x)
- Gamma functionLGamma(x)
- Log of absolute value of Gamma function
Statistical and Vector Functions
Dist(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 products
Constants
Pi
- π (3.14159...)E
- Euler's number (2.71828...)Tau
- τ = 2π (6.28318...)Inf
- Positive infinityNan
- Not a Number
License
This project is licensed under the MIT License - see the LICENSE file for details.
Contributing
Feel free to contribute to this project by submitting issues or pull requests.
Support
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.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 is compatible. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
.NET Core | netcoreapp3.1 is compatible. |
-
.NETCoreApp 3.1
- Newtonsoft.Json (>= 13.0.1)
-
net6.0
- Newtonsoft.Json (>= 13.0.1)
-
net7.0
- Newtonsoft.Json (>= 13.0.1)
-
net8.0
- Newtonsoft.Json (>= 13.0.1)
-
net9.0
- Newtonsoft.Json (>= 13.0.1)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version 1.4.0 - Critical Bug Fixes and Improvements:
BREAKING CHANGES:
- Fix `IsSqrt` function
BUG FIXES:
- Fixed critical integer division bug in IsSqrt() function
- Fixed Fmod() implementation to match C library behavior (was using incorrect IEEERemainder)
- Fixed Frexp() mantissa calculation for proper IEEE 754 compliance
- Fixed Ulp() function bit manipulation logic
- Fixed Gamma() and LGamma() error handling for invalid inputs
ENHANCEMENTS:
- Added mathematical constants: Pi, E, Tau, Inf, Nan
- Improved error handling with proper domain validation for Log(), Sqrt()
- Enhanced documentation with correct C# exception types
- Added comprehensive input validation for all mathematical functions
- Removed redundant empty documentation blocks
TECHNICAL:
- Supports .NET Core 3.1, .NET 6.0, 7.0, 8.0, and 9.0
- Comprehensive test coverage for all 54+ mathematical functions
- Python math module compatibility for cross-language consistency
- Optimized performance with proper IEEE 754 standard compliance