1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
//! # Sophy ๐งฎ
//!
//! [](https://crates.io/crates/sophy)
//! [](https://docs.rs/sophy)
//! [](https://github.com/reinanbr/sophy/blob/main/LICENSE-MIT)
//! [](https://github.com/reinanbr/sophy/actions)
//!
//! **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`:
//!
//! ```toml
//! [dependencies]
//! sophy = "0.1.23"
//! ```
//!
//! ## ๐ Examples
//!
//! ### Newton-Raphson Root Finding
//!
//! Find the square root of 2 using Newton-Raphson method:
//!
//! ```rust
//! 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:
//!
//! ```rust
//! 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:
//!
//! ```rust
//! 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](https://github.com/reinanbr/sophy/blob/main/CONTRIBUTING.md) for details.
//!
//! ## ๐ License
//!
//! This project is dual-licensed under the [MIT License](https://opensource.org/licenses/MIT)
//! or [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0).