SpecialFunctions 1.0.2

dotnet add package SpecialFunctions --version 1.0.2
                    
NuGet\Install-Package SpecialFunctions -Version 1.0.2
                    
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="SpecialFunctions" Version="1.0.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="SpecialFunctions" Version="1.0.2" />
                    
Directory.Packages.props
<PackageReference Include="SpecialFunctions" />
                    
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 SpecialFunctions --version 1.0.2
                    
#r "nuget: SpecialFunctions, 1.0.2"
                    
#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 SpecialFunctions@1.0.2
                    
#: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=SpecialFunctions&version=1.0.2
                    
Install as a Cake Addin
#tool nuget:?package=SpecialFunctions&version=1.0.2
                    
Install as a Cake Tool

SpecialFunctions

A minimal C# library providing numerical implementations of common special functions, such as:

Airy Functions

  • airy(z: Complex)
  • airy(z: double)
  • airy(k: int, z: Complex)
  • airy(k: int, z: double)

Bessel Functions (First, Second, Modified, Hankel)

  • besselj(n: double, z: Complex)
  • besselj(n: double, z: double)
  • bessely(n: double, z: Complex)
  • bessely(n: double, z: double)
  • besseli(n: double, z: Complex)
  • besseli(n: double, z: double)
  • besselk(n: double, z: Complex)
  • besselk(n: double, z: double)
  • besselh(n: double, z: Complex)
  • besselh(n: double, k: int, z: Complex)

Spherical Bessel Functions

  • sbesselj(n: double, z: Complex)
  • sbesselj(n: double, z: double)
  • sbessely(n: double, z: Complex)
  • sbessely(n: double, z: double)
  • sbesselh(n: double, z: Complex)
  • sbesselh(n: double, k: int, z: Complex)

Beta and Log-Beta

  • beta(z: double, w: double)
  • betaln(z: double, w: double)

Error Functions

  • erf(x: double)
  • erfc(x: double)
  • erfinv(z: double)
  • erfcinv(z: double)

Legendre Functions

  • legendre0(n: int, x: double)
  • legendre(n: int, x: double)

Gamma Functions

  • gammaln(x: double)
  • gamma(x: double)

The package utilizes core numerical routines from Math.NET Numerics, with updated APIs for functions such as Bessel and error functions. It also includes Legendre polynomial implementations adapted from AminKH's Legendre Polynomials repository. The API is designed to closely mirror MATLAB’s structure and naming conventions, enabling a smooth transition for users familiar with MATLAB syntax. This compatibility facilitates rapid prototyping, intuitive function calls, and straightforward adaptation of existing MATLAB-based codebases to C#.

Installation

To install the package, use the .NET CLI:

dotnet add package SpecialFunctions

Supported Frameworks

The library supports the following frameworks:

  • .NET Framework 4.7.2 (net472)
  • .NET Framework 4.8.1 (net481)
  • .NET 8.0 (net8.0)
  • .NET 9.0 (net9.0)

Usage

using static SpecialFunctions.SF;
using System.Numerics;

double result = erf(1.0);
Complex bessel = besselj(1.5, new Complex(1.0, 0.5));

For detailed functionalities, please visit the manual page.

Build and Test

Prerequisites

To build and test this library from source, you will need the following:

  • .NET SDK: Version 8.0 or higher.
  • .NET Framework: Version 4.7.2 or higher. This is required for legacy hardware driver compatibility.

Building the Library

  1. Clone the repository:

    git clone https://github.com/jake-w-liu/SpecialFunctions.git
    cd SpecialFunctions
    
  2. Build the project:

    dotnet build
    

Running the Tests

To run the tests, use the following command:

dotnet test

Contributing

We welcome contributions from the community. Here are some ways you can contribute to the project.

Reporting Issues

If you find a bug or have a problem with the software, please open an issue on our GitHub repository.

When reporting an issue, please include the following information:

  • A clear and descriptive title.
  • A detailed description of the issue, including steps to reproduce it.
  • The version of the software you are using.
  • Any relevant error messages or logs.

Contributing Code

If you would like to contribute code to the project, please follow these.

  1. Fork the repository.
  2. Create a new branch for your feature or bug fix.
  3. Make your changes and commit them with a clear and descriptive commit message.
  4. Push your changes to your fork.
  5. Open a pull request to the main repository.

Please ensure that your code adheres to the existing coding style and that all tests pass.

Seeking Support

If you have a question or need help with the software, you can:

  • Open an issue on our GitHub repository.
  • Contact the maintainers directly.

We will do our best to respond to your request in a timely manner.

Notes

  • Most functions are overloaded for both real (double) and complex (System.Numerics.Complex) inputs.
  • Many implementations delegate to the Amos library for accurate numerical evaluation.
  • Ensure input values are valid to avoid NaN results.

License

MIT License.

Product Compatible and additional computed target framework versions.
.NET 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 Framework net472 is compatible.  net48 was computed.  net481 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 Downloads Last Updated
1.0.2 204 9/5/2025
1.0.1 279 6/9/2025
1.0.0 152 6/6/2025