FTI.MathNET 1.4.0

dotnet add package FTI.MathNET --version 1.4.0
                    
NuGet\Install-Package FTI.MathNET -Version 1.4.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="FTI.MathNET" Version="1.4.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="FTI.MathNET" Version="1.4.0" />
                    
Directory.Packages.props
<PackageReference Include="FTI.MathNET" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add FTI.MathNET --version 1.4.0
                    
#r "nuget: FTI.MathNET, 1.4.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package FTI.MathNET@1.4.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=FTI.MathNET&version=1.4.0
                    
Install as a Cake Addin
#tool nuget:?package=FTI.MathNET&version=1.4.0
                    
Install as a Cake Tool

FTI.MathNET Library

NuGet License: MIT

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 n
  • GCD(params int[]) - Greatest Common Divisor
  • Isqrt(n) - Integer square root
  • LCM(params int[]) - Least Common Multiple
  • Perm(n, k) - Permutations

Floating-Point Manipulation

  • Ceil(x) - Ceiling function
  • Floor(x) - Floor function
  • Trunc(x) - Truncate to integer
  • Fabs(x) - Absolute value
  • Copysign(x, y) - Copy sign from y to magnitude of x
  • Frexp(x) - Extract mantissa and exponent
  • Ldexp(x, i) - x * 2^i
  • Modf(x) - Split into fractional and integer parts

Power and Logarithmic Functions

  • Exp(x) - e^x
  • Exp2(x) - 2^x
  • Expm1(x) - e^x - 1 (accurate for small x)
  • Log(x, base) - Logarithm to given base
  • Log1p(x) - ln(1 + x) (accurate for small x)
  • Log2(x) - Base-2 logarithm
  • Log10(x) - Base-10 logarithm
  • Pow(x, y) - x^y
  • Sqrt(x) - Square root
  • Cbrt(x) - Cube root

Trigonometric Functions

  • Sin(x), Cos(x), Tan(x) - Basic trig functions
  • Asin(x), Acos(x), Atan(x), Atan2(y, x) - Inverse trig functions
  • Degrees(x) - Convert radians to degrees
  • Radians(x) - Convert degrees to radians

Hyperbolic Functions

  • Sinh(x), Cosh(x), Tanh(x) - Hyperbolic functions
  • Asinh(x), Acosh(x), Atanh(x) - Inverse hyperbolic functions

Special Functions

  • Erf(x) - Error function
  • Erfc(x) - Complementary error function
  • Gamma(x) - Gamma function
  • LGamma(x) - Log of absolute value of Gamma function

Statistical and Vector Functions

  • Dist(p, q) - Euclidean distance between points
  • FSum(values) - Accurate floating-point sum
  • Hypot(coords) - Euclidean norm (magnitude)
  • Prod(values, start) - Product of values
  • SumProd(p, q) - Sum of products

Constants

  • Pi - π (3.14159...)
  • E - Euler's number (2.71828...)
  • Tau - τ = 2π (6.28318...)
  • Inf - Positive infinity
  • Nan - 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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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