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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
//! Standard mathematical constants defined in the ECMAScript specification.
//!
//! Each constant represents a well-known mathematical value in double-precision floating point
//! format (`f64`). Both uppercase JavaScript-style names (e.g. `LN10`, `SQRT2`) and idiomatic
//! Rust snake-case aliases (e.g. `LN_10`, `SQRT_2`) are provided.
/// Euler's constant ($e$), the base of natural logarithms.
///
/// Mathematically defined as $e = \lim_{n \to \infty} (1 + 1/n)^n \approx 2.718281828459045$.
///
/// Mirrors JavaScript's `Math.E`.
///
/// # Examples
///
/// ```
/// use MathUtils::Math;
///
/// assert!((Math::E - 2.718281828459045).abs() < 1e-15);
/// assert_eq!(Math::log(Math::E), 1.0);
/// ```
pub const E: f64 = E;
/// Natural logarithm of 10 ($\ln(10)$).
///
/// The exponent to which $e$ must be raised to produce 10, approximately `2.302585092994046`.
///
/// Mirrors JavaScript's `Math.LN10`.
///
/// # Examples
///
/// ```
/// use MathUtils::Math;
///
/// assert!((Math::LN10 - 2.302585092994046).abs() < 1e-15);
/// assert_eq!(Math::log(10.0), Math::LN10);
/// ```
pub const LN10: f64 = LN_10;
/// Snake-case alias for [`LN10`].
pub const LN_10: f64 = LN_10;
/// Natural logarithm of 2 ($\ln(2)$).
///
/// The exponent to which $e$ must be raised to produce 2, approximately `0.6931471805599453`.
///
/// Mirrors JavaScript's `Math.LN2`.
///
/// # Examples
///
/// ```
/// use MathUtils::Math;
///
/// assert!((Math::LN2 - 0.6931471805599453).abs() < 1e-15);
/// assert_eq!(Math::log(2.0), Math::LN2);
/// ```
pub const LN2: f64 = LN_2;
/// Snake-case alias for [`LN2`].
pub const LN_2: f64 = LN_2;
/// Base-10 logarithm of Euler's constant $e$ ($\log_{10}(e)$).
///
/// Equivalent to $1 / \ln(10)$, approximately `0.4342944819032518`.
///
/// Mirrors JavaScript's `Math.LOG10E`.
///
/// # Examples
///
/// ```
/// use MathUtils::Math;
///
/// assert!((Math::LOG10E - 0.4342944819032518).abs() < 1e-15);
/// assert_eq!(Math::log10(Math::E), Math::LOG10E);
/// ```
pub const LOG10E: f64 = LOG10_E;
/// Snake-case alias for [`LOG10E`].
pub const LOG10_E: f64 = LOG10_E;
/// Base-2 logarithm of Euler's constant $e$ ($\log_2(e)$).
///
/// Equivalent to $1 / \ln(2)$, approximately `1.4426950408889634`.
///
/// Mirrors JavaScript's `Math.LOG2E`.
///
/// # Examples
///
/// ```
/// use MathUtils::Math;
///
/// assert!((Math::LOG2E - 1.4426950408889634).abs() < 1e-15);
/// assert_eq!(Math::log2(Math::E), Math::LOG2E);
/// ```
pub const LOG2E: f64 = LOG2_E;
/// Snake-case alias for [`LOG2E`].
pub const LOG2_E: f64 = LOG2_E;
/// Archimedes' constant ($\pi$), the ratio of a circle's circumference to its diameter.
///
/// Approximately `3.141592653589793`.
///
/// Mirrors JavaScript's `Math.PI`.
///
/// # Examples
///
/// ```
/// use MathUtils::Math;
///
/// assert!((Math::PI - 3.141592653589793).abs() < 1e-15);
/// assert!(Math::sin(Math::PI).abs() < 1e-15);
/// assert_eq!(Math::cos(Math::PI), -1.0);
/// ```
pub const PI: f64 = PI;
/// Square root of 1/2 ($\sqrt{1/2} = 1/\sqrt{2}$).
///
/// Approximately `0.7071067811865476`.
///
/// Mirrors JavaScript's `Math.SQRT1_2`.
///
/// # Examples
///
/// ```
/// use MathUtils::Math;
///
/// assert!((Math::SQRT1_2 - 0.7071067811865476).abs() < 1e-15);
/// assert_eq!(Math::sqrt(0.5), Math::SQRT1_2);
/// ```
pub const SQRT1_2: f64 = FRAC_1_SQRT_2;
/// Snake-case alias for [`SQRT1_2`].
pub const SQRT_1_2: f64 = FRAC_1_SQRT_2;
/// Square root of 2 ($\sqrt{2}$).
///
/// Approximately `1.4142135623730951`.
///
/// Mirrors JavaScript's `Math.SQRT2`.
///
/// # Examples
///
/// ```
/// use MathUtils::Math;
///
/// assert!((Math::SQRT2 - 1.4142135623730951).abs() < 1e-15);
/// assert_eq!(Math::sqrt(2.0), Math::SQRT2);
/// ```
pub const SQRT2: f64 = SQRT_2;
/// Snake-case alias for [`SQRT2`].
pub const SQRT_2: f64 = SQRT_2;