Crate sophy

Crate sophy 

Source
Expand description

ยงSophy ๐Ÿงฎ

Crates.io Documentation License: MIT OR Apache-2.0 Build Status

Sophy is a lightweight, efficient, and extensible mathematical library written in pure Rust. It provides numerical methods, mathematical functions, and number utilities for scientific computing, educational tools, and general-purpose applications.

ยงโœจ Features

  • ๐Ÿ”ข Numerical Methods: Newton-Raphson root finding, integration, interpolation
  • ๐Ÿ“Š Mathematical Functions: Exponential, logarithmic, trigonometric functions
  • ๐Ÿงฎ Number Utilities: Base operations, number theory functions
  • ๐Ÿฆ€ Pure Rust: Memory-safe, zero-cost abstractions
  • ๐Ÿ“š Well Documented: Comprehensive documentation with examples
  • ๐Ÿงช Well Tested: Extensive test suite with high coverage

ยง๐Ÿš€ Quick Start

Add Sophy to your Cargo.toml:

[dependencies]
sophy = "0.1.23"

ยง๐Ÿ“– Examples

ยงNewton-Raphson Root Finding

Find the square root of 2 using Newton-Raphson method:

use sophy::methods::raphson::raphson;

// Define the function f(x) = xยฒ - 2
let f = |x: f64| x * x - 2.0;
// Define its derivative f'(x) = 2x
let df = |x: f64| 2.0 * x;

// Find the root starting from xโ‚€ = 1.0
let root = raphson(1.0, f, df, 1e-10, 100);

println!("โˆš2 โ‰ˆ {:.10}", root); // Output: โˆš2 โ‰ˆ 1.4142135624
assert!((root - std::f64::consts::SQRT_2).abs() < 1e-10);

ยงBase Number Operations

Work with mathematical constants and utilities:

use sophy::base::numbers::{PI, EULER, PHI};

println!("ฯ€ = {:.6}", PI);       // ฯ€ = 3.141593
println!("e = {:.6}", EULER);    // e = 2.718282
println!("ฯ† = {:.6}", PHI);      // ฯ† = 1.618034

ยงSpecial Mathematical Functions

Advanced mathematical functions for scientific computing:

use sophy::specials::{gamma, zeta, erf};

// Gamma function: ฮ“(5) = 4! = 24
let factorial_4 = gamma(5.0);

// Riemann zeta function: ฮถ(2) = ฯ€ยฒ/6
let zeta_2 = zeta(2.0);

// Error function for probability calculations
let error_val = erf(1.0);

ยง๐Ÿ—๏ธ Architecture

Sophy is organized into focused modules:

  • methods: Numerical methods for solving mathematical problems
  • base: Fundamental number operations and utilities
  • specials: Special mathematical functions (gamma, zeta, erf, etc.)

ยง๐Ÿ”ฌ Precision & Performance

Sophy uses f64 precision by default for optimal balance between accuracy and performance. All algorithms are implemented with numerical stability in mind.

ยง๐Ÿค Contributing

Contributions are welcome! Please see our contributing guide for details.

ยง๐Ÿ“œ License

This project is dual-licensed under the MIT License or Apache License 2.0.

Modulesยง

base
Base Mathematical Operations Module
methods
Numerical Methods Module
specials
Special Mathematical Functions Module