rbs 3.0.0.dev.2 → 3.0.0.dev.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/workflows/comments.yml +2 -1
- data/.github/workflows/ruby.yml +4 -0
- data/Gemfile.lock +11 -11
- data/Rakefile +2 -2
- data/Steepfile +1 -1
- data/core/array.rbs +573 -423
- data/core/basic_object.rbs +11 -39
- data/core/binding.rbs +1 -1
- data/core/builtin.rbs +8 -0
- data/core/class.rbs +37 -0
- data/core/comparable.rbs +7 -18
- data/core/complex.rbs +2 -2
- data/core/data.rbs +419 -0
- data/core/dir.rbs +52 -104
- data/core/encoding.rbs +22 -181
- data/core/enumerable.rbs +212 -175
- data/core/enumerator/product.rbs +96 -0
- data/core/enumerator.rbs +57 -8
- data/core/errors.rbs +8 -2
- data/core/exception.rbs +41 -0
- data/core/fiber.rbs +95 -12
- data/core/file.rbs +840 -275
- data/core/file_test.rbs +34 -19
- data/core/float.rbs +40 -96
- data/core/gc.rbs +15 -3
- data/core/hash.rbs +113 -175
- data/core/integer.rbs +85 -145
- data/core/io/buffer.rbs +187 -60
- data/core/io/wait.rbs +28 -16
- data/core/io.rbs +1859 -1389
- data/core/kernel.rbs +525 -961
- data/core/match_data.rbs +306 -142
- data/core/math.rbs +506 -234
- data/core/method.rbs +0 -24
- data/core/module.rbs +110 -17
- data/core/nil_class.rbs +2 -0
- data/core/numeric.rbs +76 -144
- data/core/object.rbs +88 -212
- data/core/proc.rbs +17 -5
- data/core/process.rbs +22 -5
- data/core/ractor.rbs +1 -1
- data/core/random.rbs +20 -3
- data/core/range.rbs +91 -89
- data/core/rational.rbs +2 -3
- data/core/rbs/unnamed/argf.rbs +177 -120
- data/core/rbs/unnamed/env_class.rbs +89 -163
- data/core/rbs/unnamed/random.rbs +36 -12
- data/core/refinement.rbs +8 -0
- data/core/regexp.rbs +462 -272
- data/core/ruby_vm.rbs +210 -0
- data/{stdlib/set/0 → core}/set.rbs +43 -47
- data/core/string.rbs +1403 -1332
- data/core/string_io.rbs +191 -107
- data/core/struct.rbs +67 -63
- data/core/symbol.rbs +187 -201
- data/core/thread.rbs +40 -35
- data/core/time.rbs +902 -826
- data/core/trace_point.rbs +55 -6
- data/core/unbound_method.rbs +48 -24
- data/docs/collection.md +4 -0
- data/docs/syntax.md +55 -0
- data/ext/rbs_extension/parser.c +5 -6
- data/lib/rbs/cli.rb +6 -1
- data/lib/rbs/collection/cleaner.rb +8 -1
- data/lib/rbs/collection/config/lockfile.rb +3 -1
- data/lib/rbs/collection/config/lockfile_generator.rb +16 -14
- data/lib/rbs/collection/config.rb +1 -1
- data/lib/rbs/collection/sources/git.rb +9 -2
- data/lib/rbs/collection/sources/local.rb +79 -0
- data/lib/rbs/collection/sources.rb +8 -1
- data/lib/rbs/environment.rb +6 -5
- data/lib/rbs/environment_loader.rb +3 -2
- data/lib/rbs/errors.rb +18 -0
- data/lib/rbs/locator.rb +26 -7
- data/lib/rbs/sorter.rb +2 -2
- data/lib/rbs/version.rb +1 -1
- data/sig/collection/sources.rbs +32 -3
- data/sig/environment.rbs +2 -3
- data/sig/locator.rbs +14 -2
- data/sig/shims/{abstract_syntax_tree.rbs → _abstract_syntax_tree.rbs} +0 -0
- data/stdlib/bigdecimal/0/big_decimal.rbs +16 -13
- data/stdlib/cgi/0/core.rbs +16 -0
- data/stdlib/coverage/0/coverage.rbs +50 -8
- data/stdlib/csv/0/csv.rbs +1 -1
- data/stdlib/date/0/date.rbs +856 -726
- data/stdlib/date/0/date_time.rbs +83 -210
- data/stdlib/erb/0/erb.rbs +13 -36
- data/stdlib/etc/0/etc.rbs +127 -20
- data/stdlib/fileutils/0/fileutils.rbs +1290 -381
- data/stdlib/logger/0/logger.rbs +466 -316
- data/stdlib/net-http/0/net-http.rbs +2211 -534
- data/stdlib/nkf/0/nkf.rbs +5 -5
- data/stdlib/objspace/0/objspace.rbs +31 -14
- data/stdlib/openssl/0/openssl.rbs +11 -7
- data/stdlib/optparse/0/optparse.rbs +20 -17
- data/stdlib/pathname/0/pathname.rbs +21 -4
- data/stdlib/pstore/0/pstore.rbs +378 -154
- data/stdlib/pty/0/pty.rbs +24 -8
- data/stdlib/ripper/0/ripper.rbs +1650 -0
- data/stdlib/socket/0/addrinfo.rbs +9 -15
- data/stdlib/socket/0/socket.rbs +36 -3
- data/stdlib/strscan/0/string_scanner.rbs +7 -5
- data/stdlib/tempfile/0/tempfile.rbs +104 -44
- data/stdlib/time/0/time.rbs +2 -2
- data/stdlib/uri/0/file.rbs +5 -0
- data/stdlib/uri/0/generic.rbs +2 -2
- data/stdlib/yaml/0/yaml.rbs +2 -2
- data/stdlib/zlib/0/zlib.rbs +1 -1
- metadata +8 -6
- data/core/deprecated.rbs +0 -9
- data/sig/shims/ripper.rbs +0 -8
data/core/math.rbs
CHANGED
|
@@ -1,64 +1,204 @@
|
|
|
1
1
|
# <!-- rdoc-file=math.c -->
|
|
2
|
-
#
|
|
3
|
-
# transcendental functions
|
|
4
|
-
# Ruby's floating point accuracy.
|
|
2
|
+
# Module Math provides methods for basic trigonometric, logarithmic, and
|
|
3
|
+
# transcendental functions, and for extracting roots.
|
|
5
4
|
#
|
|
6
|
-
#
|
|
5
|
+
# You can write its constants and method calls thus:
|
|
6
|
+
#
|
|
7
|
+
# Math::PI # => 3.141592653589793
|
|
8
|
+
# Math::E # => 2.718281828459045
|
|
9
|
+
# Math.sin(0.0) # => 0.0
|
|
10
|
+
# Math.cos(0.0) # => 1.0
|
|
11
|
+
#
|
|
12
|
+
# If you include module Math, you can write simpler forms:
|
|
13
|
+
#
|
|
14
|
+
# include Math
|
|
15
|
+
# PI # => 3.141592653589793
|
|
16
|
+
# E # => 2.718281828459045
|
|
17
|
+
# sin(0.0) # => 0.0
|
|
18
|
+
# cos(0.0) # => 1.0
|
|
19
|
+
#
|
|
20
|
+
# For simplicity, the examples here assume:
|
|
21
|
+
#
|
|
22
|
+
# include Math
|
|
23
|
+
# INFINITY = Float::INFINITY
|
|
24
|
+
#
|
|
25
|
+
# The domains and ranges for the methods are denoted by open or closed
|
|
26
|
+
# intervals, using, respectively, parentheses or square brackets:
|
|
27
|
+
#
|
|
28
|
+
# * An open interval does not include the endpoints:
|
|
29
|
+
#
|
|
30
|
+
# (-INFINITY, INFINITY)
|
|
31
|
+
#
|
|
32
|
+
# * A closed interval includes the endpoints:
|
|
33
|
+
#
|
|
34
|
+
# [-1.0, 1.0]
|
|
35
|
+
#
|
|
36
|
+
# * A half-open interval includes one endpoint, but not the other:
|
|
37
|
+
#
|
|
38
|
+
# [1.0, INFINITY)
|
|
39
|
+
#
|
|
40
|
+
#
|
|
41
|
+
# Many values returned by Math methods are numerical approximations. This is
|
|
42
|
+
# because many such values are, in mathematics, of infinite precision, while in
|
|
43
|
+
# numerical computation the precision is finite.
|
|
44
|
+
#
|
|
45
|
+
# Thus, in mathematics, *cos(π/2)* is exactly zero, but in our computation
|
|
46
|
+
# `cos(PI/2)` is a number very close to zero:
|
|
47
|
+
#
|
|
48
|
+
# cos(PI/2) # => 6.123031769111886e-17
|
|
49
|
+
#
|
|
50
|
+
# For very large and very small returned values, we have added formatted numbers
|
|
51
|
+
# for clarity:
|
|
52
|
+
#
|
|
53
|
+
# tan(PI/2) # => 1.633123935319537e+16 # 16331239353195370.0
|
|
54
|
+
# tan(PI) # => -1.2246467991473532e-16 # -0.0000000000000001
|
|
55
|
+
#
|
|
56
|
+
# See class Float for the constants that affect Ruby's floating-point
|
|
57
|
+
# arithmetic.
|
|
58
|
+
#
|
|
59
|
+
# ### What's Here
|
|
60
|
+
#
|
|
61
|
+
# #### Trigonometric Functions
|
|
62
|
+
#
|
|
63
|
+
# * ::cos: Returns the cosine of the given argument.
|
|
64
|
+
# * ::sin: Returns the sine of the given argument.
|
|
65
|
+
# * ::tan: Returns the tangent of the given argument.
|
|
66
|
+
#
|
|
67
|
+
#
|
|
68
|
+
# #### Inverse Trigonometric Functions
|
|
69
|
+
#
|
|
70
|
+
# * ::acos: Returns the arc cosine of the given argument.
|
|
71
|
+
# * ::asin: Returns the arc sine of the given argument.
|
|
72
|
+
# * ::atan: Returns the arc tangent of the given argument.
|
|
73
|
+
# * ::atan2: Returns the arg tangent of two given arguments.
|
|
74
|
+
#
|
|
75
|
+
#
|
|
76
|
+
# #### Hyperbolic Trigonometric Functions
|
|
77
|
+
#
|
|
78
|
+
# * ::cosh: Returns the hyperbolic cosine of the given argument.
|
|
79
|
+
# * ::sinh: Returns the hyperbolic sine of the given argument.
|
|
80
|
+
# * ::tanh: Returns the hyperbolic tangent of the given argument.
|
|
81
|
+
#
|
|
82
|
+
#
|
|
83
|
+
# #### Inverse Hyperbolic Trigonometric Functions
|
|
84
|
+
#
|
|
85
|
+
# * ::acosh: Returns the inverse hyperbolic cosine of the given argument.
|
|
86
|
+
# * ::asinh: Returns the inverse hyperbolic sine of the given argument.
|
|
87
|
+
# * ::atanh: Returns the inverse hyperbolic tangent of the given argument.
|
|
88
|
+
#
|
|
89
|
+
#
|
|
90
|
+
# #### Exponentiation and Logarithmic Functions
|
|
91
|
+
#
|
|
92
|
+
# * ::exp: Returns the value of a given value raised to a given power.
|
|
93
|
+
# * ::log: Returns the logarithm of a given value in a given base.
|
|
94
|
+
# * ::log10: Returns the base 10 logarithm of the given argument.
|
|
95
|
+
# * ::log2: Returns the base 2 logarithm of the given argument.
|
|
96
|
+
#
|
|
97
|
+
#
|
|
98
|
+
# #### Fraction and Exponent Functions
|
|
99
|
+
#
|
|
100
|
+
# * ::frexp: Returns the fraction and exponent of the given argument.
|
|
101
|
+
# * ::ldexp: Returns the value for a given fraction and exponent.
|
|
102
|
+
#
|
|
103
|
+
#
|
|
104
|
+
# #### Root Functions
|
|
105
|
+
#
|
|
106
|
+
# * ::cbrt: Returns the cube root of the given argument.
|
|
107
|
+
# * ::sqrt: Returns the square root of the given argument.
|
|
108
|
+
#
|
|
109
|
+
#
|
|
110
|
+
# #### Error Functions
|
|
111
|
+
#
|
|
112
|
+
# * ::erf: Returns the value of the Gauss error function for the given
|
|
113
|
+
# argument.
|
|
114
|
+
# * ::erfc: Returns the value of the complementary error function for the
|
|
115
|
+
# given argument.
|
|
116
|
+
#
|
|
117
|
+
#
|
|
118
|
+
# #### Gamma Functions
|
|
119
|
+
#
|
|
120
|
+
# * ::gamma: Returns the value of the gamma function for the given argument.
|
|
121
|
+
# * ::lgamma: Returns the value of the logarithmic gamma function for the
|
|
122
|
+
# given argument.
|
|
123
|
+
#
|
|
124
|
+
#
|
|
125
|
+
# #### Hypotenuse Function
|
|
126
|
+
#
|
|
127
|
+
# * ::hypot: Returns `sqrt(a**2 + b**2)` for the given `a` and `b`.
|
|
7
128
|
#
|
|
8
129
|
module Math
|
|
9
130
|
# <!--
|
|
10
131
|
# rdoc-file=math.c
|
|
11
|
-
# - Math.acos(x)
|
|
132
|
+
# - Math.acos(x) -> float
|
|
12
133
|
# -->
|
|
13
|
-
#
|
|
134
|
+
# Returns the [arc
|
|
135
|
+
# cosine](https://en.wikipedia.org/wiki/Inverse_trigonometric_functions) of `x`.
|
|
136
|
+
#
|
|
137
|
+
# * Domain: `[-1, 1]`.
|
|
138
|
+
# * Range: `[0, PI]`.
|
|
14
139
|
#
|
|
15
|
-
# Domain: [-1, 1]
|
|
16
140
|
#
|
|
17
|
-
#
|
|
141
|
+
# Examples:
|
|
18
142
|
#
|
|
19
|
-
#
|
|
143
|
+
# acos(-1.0) # => 3.141592653589793 # PI
|
|
144
|
+
# acos(0.0) # => 1.5707963267948966 # PI/2
|
|
145
|
+
# acos(1.0) # => 0.0
|
|
20
146
|
#
|
|
21
147
|
def self.acos: (Numeric x) -> Float
|
|
22
148
|
|
|
23
149
|
# <!--
|
|
24
150
|
# rdoc-file=math.c
|
|
25
|
-
# - Math.acosh(x)
|
|
151
|
+
# - Math.acosh(x) -> float
|
|
26
152
|
# -->
|
|
27
|
-
#
|
|
153
|
+
# Returns the [inverse hyperbolic
|
|
154
|
+
# cosine](https://en.wikipedia.org/wiki/Inverse_hyperbolic_functions) of `x`.
|
|
155
|
+
#
|
|
156
|
+
# * Domain: `[1, INFINITY]`.
|
|
157
|
+
# * Range: `[0, INFINITY]`.
|
|
28
158
|
#
|
|
29
|
-
# Domain: [1, INFINITY)
|
|
30
159
|
#
|
|
31
|
-
#
|
|
160
|
+
# Examples:
|
|
32
161
|
#
|
|
33
|
-
#
|
|
162
|
+
# acosh(1.0) # => 0.0
|
|
163
|
+
# acosh(INFINITY) # => Infinity
|
|
34
164
|
#
|
|
35
165
|
def self.acosh: (Numeric x) -> Float
|
|
36
166
|
|
|
37
167
|
# <!--
|
|
38
168
|
# rdoc-file=math.c
|
|
39
|
-
# - Math.asin(x)
|
|
169
|
+
# - Math.asin(x) -> float
|
|
40
170
|
# -->
|
|
41
|
-
#
|
|
171
|
+
# Returns the [arc
|
|
172
|
+
# sine](https://en.wikipedia.org/wiki/Inverse_trigonometric_functions) of `x`.
|
|
42
173
|
#
|
|
43
|
-
# Domain: [-1, -1]
|
|
174
|
+
# * Domain: `[-1, -1]`.
|
|
175
|
+
# * Range: `[-PI/2, PI/2]`.
|
|
44
176
|
#
|
|
45
|
-
# Codomain: [-PI/2, PI/2]
|
|
46
177
|
#
|
|
47
|
-
#
|
|
178
|
+
# Examples:
|
|
179
|
+
#
|
|
180
|
+
# asin(-1.0) # => -1.5707963267948966 # -PI/2
|
|
181
|
+
# asin(0.0) # => 0.0
|
|
182
|
+
# asin(1.0) # => 1.5707963267948966 # PI/2
|
|
48
183
|
#
|
|
49
184
|
def self.asin: (Numeric x) -> Float
|
|
50
185
|
|
|
51
186
|
# <!--
|
|
52
187
|
# rdoc-file=math.c
|
|
53
|
-
# - Math.asinh(x)
|
|
188
|
+
# - Math.asinh(x) -> float
|
|
54
189
|
# -->
|
|
55
|
-
#
|
|
190
|
+
# Returns the [inverse hyperbolic
|
|
191
|
+
# sine](https://en.wikipedia.org/wiki/Inverse_hyperbolic_functions) of `x`.
|
|
192
|
+
#
|
|
193
|
+
# * Domain: `[-INFINITY, INFINITY]`.
|
|
194
|
+
# * Range: `[-INFINITY, INFINITY]`.
|
|
56
195
|
#
|
|
57
|
-
# Domain: (-INFINITY, INFINITY)
|
|
58
196
|
#
|
|
59
|
-
#
|
|
197
|
+
# Examples:
|
|
60
198
|
#
|
|
61
|
-
#
|
|
199
|
+
# asinh(-INFINITY) # => -Infinity
|
|
200
|
+
# asinh(0.0) # => 0.0
|
|
201
|
+
# asinh(INFINITY) # => Infinity
|
|
62
202
|
#
|
|
63
203
|
def self.asinh: (Numeric x) -> Float
|
|
64
204
|
|
|
@@ -66,134 +206,155 @@ module Math
|
|
|
66
206
|
# rdoc-file=math.c
|
|
67
207
|
# - Math.atan(x) -> Float
|
|
68
208
|
# -->
|
|
69
|
-
#
|
|
209
|
+
# Returns the [arc
|
|
210
|
+
# tangent](https://en.wikipedia.org/wiki/Inverse_trigonometric_functions) of
|
|
211
|
+
# `x`.
|
|
212
|
+
#
|
|
213
|
+
# * Domain: `[-INFINITY, INFINITY]`.
|
|
214
|
+
# * Range: `[-PI/2, PI/2] `.
|
|
70
215
|
#
|
|
71
|
-
# Domain: (-INFINITY, INFINITY)
|
|
72
216
|
#
|
|
73
|
-
#
|
|
217
|
+
# Examples:
|
|
74
218
|
#
|
|
75
|
-
#
|
|
219
|
+
# atan(-INFINITY) # => -1.5707963267948966 # -PI2
|
|
220
|
+
# atan(-PI) # => -1.2626272556789115
|
|
221
|
+
# atan(-PI/2) # => -1.0038848218538872
|
|
222
|
+
# atan(0.0) # => 0.0
|
|
223
|
+
# atan(PI/2) # => 1.0038848218538872
|
|
224
|
+
# atan(PI) # => 1.2626272556789115
|
|
225
|
+
# atan(INFINITY) # => 1.5707963267948966 # PI/2
|
|
76
226
|
#
|
|
77
227
|
def self.atan: (Numeric x) -> Float
|
|
78
228
|
|
|
79
229
|
# <!--
|
|
80
230
|
# rdoc-file=math.c
|
|
81
|
-
# - Math.atan2(y, x)
|
|
231
|
+
# - Math.atan2(y, x) -> float
|
|
82
232
|
# -->
|
|
83
|
-
#
|
|
84
|
-
#
|
|
85
|
-
#
|
|
86
|
-
#
|
|
87
|
-
#
|
|
88
|
-
#
|
|
89
|
-
#
|
|
90
|
-
#
|
|
91
|
-
#
|
|
92
|
-
#
|
|
93
|
-
#
|
|
94
|
-
#
|
|
95
|
-
#
|
|
96
|
-
#
|
|
97
|
-
#
|
|
98
|
-
#
|
|
99
|
-
# Math.atan2(1.0, -1.0) #=> 2.356194490192345
|
|
100
|
-
# Math.atan2(0.0, -1.0) #=> 3.141592653589793
|
|
101
|
-
# Math.atan2(INFINITY, INFINITY) #=> 0.7853981633974483
|
|
102
|
-
# Math.atan2(INFINITY, -INFINITY) #=> 2.356194490192345
|
|
103
|
-
# Math.atan2(-INFINITY, INFINITY) #=> -0.7853981633974483
|
|
104
|
-
# Math.atan2(-INFINITY, -INFINITY) #=> -2.356194490192345
|
|
233
|
+
# Returns the [arc tangent](https://en.wikipedia.org/wiki/Atan2) of `y` and `x`
|
|
234
|
+
# in
|
|
235
|
+
# [radians](https://en.wikipedia.org/wiki/Trigonometric_functions#Radians_versus
|
|
236
|
+
# _degrees).
|
|
237
|
+
#
|
|
238
|
+
# * Domain of `y`: `[-INFINITY, INFINITY]`.
|
|
239
|
+
# * Domain of `x`: `[-INFINITY, INFINITY]`.
|
|
240
|
+
# * Range: `[-PI, PI]`.
|
|
241
|
+
#
|
|
242
|
+
#
|
|
243
|
+
# Examples:
|
|
244
|
+
#
|
|
245
|
+
# atan2(-1.0, -1.0) # => -2.356194490192345 # -3*PI/4
|
|
246
|
+
# atan2(-1.0, 0.0) # => -1.5707963267948966 # -PI/2
|
|
247
|
+
# atan2(-1.0, 1.0) # => -0.7853981633974483 # -PI/4
|
|
248
|
+
# atan2(0.0, -1.0) # => 3.141592653589793 # PI
|
|
105
249
|
#
|
|
106
250
|
def self.atan2: (Numeric y, Numeric x) -> Float
|
|
107
251
|
|
|
108
252
|
# <!--
|
|
109
253
|
# rdoc-file=math.c
|
|
110
|
-
# - Math.atanh(x)
|
|
254
|
+
# - Math.atanh(x) -> float
|
|
111
255
|
# -->
|
|
112
|
-
#
|
|
256
|
+
# Returns the [inverse hyperbolic
|
|
257
|
+
# tangent](https://en.wikipedia.org/wiki/Inverse_hyperbolic_functions) of `x`.
|
|
113
258
|
#
|
|
114
|
-
# Domain:
|
|
259
|
+
# * Domain: `[-1, 1]`.
|
|
260
|
+
# * Range: `[-INFINITY, INFINITY]`.
|
|
115
261
|
#
|
|
116
|
-
# Codomain: (-INFINITY, INFINITY)
|
|
117
262
|
#
|
|
118
|
-
#
|
|
263
|
+
# Examples:
|
|
264
|
+
#
|
|
265
|
+
# atanh(-1.0) # => -Infinity
|
|
266
|
+
# atanh(0.0) # => 0.0
|
|
267
|
+
# atanh(1.0) # => Infinity
|
|
119
268
|
#
|
|
120
269
|
def self.atanh: (Numeric x) -> Float
|
|
121
270
|
|
|
122
271
|
# <!--
|
|
123
272
|
# rdoc-file=math.c
|
|
124
|
-
# - Math.cbrt(x)
|
|
273
|
+
# - Math.cbrt(x) -> float
|
|
125
274
|
# -->
|
|
126
|
-
# Returns the cube root of `x`.
|
|
127
|
-
#
|
|
128
|
-
# Domain:
|
|
129
|
-
#
|
|
130
|
-
#
|
|
131
|
-
#
|
|
132
|
-
#
|
|
133
|
-
#
|
|
134
|
-
#
|
|
135
|
-
#
|
|
136
|
-
#
|
|
137
|
-
# #
|
|
138
|
-
# #
|
|
139
|
-
# #
|
|
140
|
-
# #
|
|
141
|
-
# #
|
|
142
|
-
# #
|
|
143
|
-
#
|
|
144
|
-
# #
|
|
145
|
-
# # [1, 1.0, 1.0]
|
|
146
|
-
# # [2, 1.25992104989487, 2.0]
|
|
147
|
-
# # [3, 1.44224957030741, 3.0]
|
|
148
|
-
# # [4, 1.5874010519682, 4.0]
|
|
149
|
-
# # [5, 1.7099759466767, 5.0]
|
|
150
|
-
# # [6, 1.81712059283214, 6.0]
|
|
151
|
-
# # [7, 1.91293118277239, 7.0]
|
|
152
|
-
# # [8, 2.0, 8.0]
|
|
153
|
-
# # [9, 2.0800838230519, 9.0]
|
|
275
|
+
# Returns the [cube root](https://en.wikipedia.org/wiki/Cube_root) of `x`.
|
|
276
|
+
#
|
|
277
|
+
# * Domain: `[-INFINITY, INFINITY]`.
|
|
278
|
+
# * Range: `[-INFINITY, INFINITY]`.
|
|
279
|
+
#
|
|
280
|
+
#
|
|
281
|
+
# Examples:
|
|
282
|
+
#
|
|
283
|
+
# cbrt(-INFINITY) # => -Infinity
|
|
284
|
+
# cbrt(-27.0) # => -3.0
|
|
285
|
+
# cbrt(-8.0) # => -2.0
|
|
286
|
+
# cbrt(-2.0) # => -1.2599210498948732
|
|
287
|
+
# cbrt(1.0) # => 1.0
|
|
288
|
+
# cbrt(0.0) # => 0.0
|
|
289
|
+
# cbrt(1.0) # => 1.0
|
|
290
|
+
# cbrt(2.0) # => 1.2599210498948732
|
|
291
|
+
# cbrt(8.0) # => 2.0
|
|
292
|
+
# cbrt(27.0) # => 3.0
|
|
293
|
+
# cbrt(INFINITY) # => Infinity
|
|
154
294
|
#
|
|
155
295
|
def self.cbrt: (Numeric x) -> Float
|
|
156
296
|
|
|
157
297
|
# <!--
|
|
158
298
|
# rdoc-file=math.c
|
|
159
|
-
# - Math.cos(x)
|
|
299
|
+
# - Math.cos(x) -> float
|
|
160
300
|
# -->
|
|
161
|
-
#
|
|
162
|
-
#
|
|
301
|
+
# Returns the [cosine](https://en.wikipedia.org/wiki/Sine_and_cosine) of `x` in
|
|
302
|
+
# [radians](https://en.wikipedia.org/wiki/Trigonometric_functions#Radians_versus
|
|
303
|
+
# _degrees).
|
|
163
304
|
#
|
|
164
|
-
# Domain: (-INFINITY, INFINITY)
|
|
305
|
+
# * Domain: `(-INFINITY, INFINITY)`.
|
|
306
|
+
# * Range: `[-1.0, 1.0]`.
|
|
165
307
|
#
|
|
166
|
-
# Codomain: [-1, 1]
|
|
167
308
|
#
|
|
168
|
-
#
|
|
309
|
+
# Examples:
|
|
310
|
+
#
|
|
311
|
+
# cos(-PI) # => -1.0
|
|
312
|
+
# cos(-PI/2) # => 6.123031769111886e-17 # 0.0000000000000001
|
|
313
|
+
# cos(0.0) # => 1.0
|
|
314
|
+
# cos(PI/2) # => 6.123031769111886e-17 # 0.0000000000000001
|
|
315
|
+
# cos(PI) # => -1.0
|
|
169
316
|
#
|
|
170
317
|
def self.cos: (Numeric x) -> Float
|
|
171
318
|
|
|
172
319
|
# <!--
|
|
173
320
|
# rdoc-file=math.c
|
|
174
|
-
# - Math.cosh(x)
|
|
321
|
+
# - Math.cosh(x) -> float
|
|
175
322
|
# -->
|
|
176
|
-
#
|
|
323
|
+
# Returns the [hyperbolic
|
|
324
|
+
# cosine](https://en.wikipedia.org/wiki/Hyperbolic_functions) of `x` in
|
|
325
|
+
# [radians](https://en.wikipedia.org/wiki/Trigonometric_functions#Radians_versus
|
|
326
|
+
# _degrees).
|
|
327
|
+
#
|
|
328
|
+
# * Domain: `[-INFINITY, INFINITY]`.
|
|
329
|
+
# * Range: `[1, INFINITY]`.
|
|
177
330
|
#
|
|
178
|
-
# Domain: (-INFINITY, INFINITY)
|
|
179
331
|
#
|
|
180
|
-
#
|
|
332
|
+
# Examples:
|
|
181
333
|
#
|
|
182
|
-
#
|
|
334
|
+
# cosh(-INFINITY) # => Infinity
|
|
335
|
+
# cosh(0.0) # => 1.0
|
|
336
|
+
# cosh(INFINITY) # => Infinity
|
|
183
337
|
#
|
|
184
338
|
def self.cosh: (Numeric x) -> Float
|
|
185
339
|
|
|
186
340
|
# <!--
|
|
187
341
|
# rdoc-file=math.c
|
|
188
|
-
# - Math.erf(x)
|
|
342
|
+
# - Math.erf(x) -> float
|
|
189
343
|
# -->
|
|
190
|
-
#
|
|
344
|
+
# Returns the value of the [Gauss error
|
|
345
|
+
# function](https://en.wikipedia.org/wiki/Error_function) for `x`.
|
|
191
346
|
#
|
|
192
|
-
# Domain:
|
|
347
|
+
# * Domain: `[-INFINITY, INFINITY]`.
|
|
348
|
+
# * Range: `[-1, 1]`.
|
|
193
349
|
#
|
|
194
|
-
# Codomain: (-1, 1)
|
|
195
350
|
#
|
|
196
|
-
#
|
|
351
|
+
# Examples:
|
|
352
|
+
#
|
|
353
|
+
# erf(-INFINITY) # => -1.0
|
|
354
|
+
# erf(0.0) # => 0.0
|
|
355
|
+
# erf(INFINITY) # => 1.0
|
|
356
|
+
#
|
|
357
|
+
# Related: Math.erfc.
|
|
197
358
|
#
|
|
198
359
|
def self.erf: (Numeric x) -> Float
|
|
199
360
|
|
|
@@ -201,92 +362,126 @@ module Math
|
|
|
201
362
|
# rdoc-file=math.c
|
|
202
363
|
# - Math.erfc(x) -> Float
|
|
203
364
|
# -->
|
|
204
|
-
#
|
|
365
|
+
# Returns the value of the [complementary error
|
|
366
|
+
# function](https://en.wikipedia.org/wiki/Error_function#Complementary_error_fun
|
|
367
|
+
# ction) for `x`.
|
|
368
|
+
#
|
|
369
|
+
# * Domain: `[-INFINITY, INFINITY]`.
|
|
370
|
+
# * Range: `[0, 2]`.
|
|
205
371
|
#
|
|
206
|
-
# Domain: (-INFINITY, INFINITY)
|
|
207
372
|
#
|
|
208
|
-
#
|
|
373
|
+
# Examples:
|
|
209
374
|
#
|
|
210
|
-
#
|
|
375
|
+
# erfc(-INFINITY) # => 2.0
|
|
376
|
+
# erfc(0.0) # => 1.0
|
|
377
|
+
# erfc(INFINITY) # => 0.0
|
|
378
|
+
#
|
|
379
|
+
# Related: Math.erf.
|
|
211
380
|
#
|
|
212
381
|
def self.erfc: (Numeric x) -> Float
|
|
213
382
|
|
|
214
383
|
# <!--
|
|
215
384
|
# rdoc-file=math.c
|
|
216
|
-
# - Math.exp(x)
|
|
385
|
+
# - Math.exp(x) -> float
|
|
217
386
|
# -->
|
|
218
|
-
# Returns e
|
|
387
|
+
# Returns `e` raised to the `x` power.
|
|
388
|
+
#
|
|
389
|
+
# * Domain: `[-INFINITY, INFINITY]`.
|
|
390
|
+
# * Range: `[0, INFINITY]`.
|
|
219
391
|
#
|
|
220
|
-
# Domain: (-INFINITY, INFINITY)
|
|
221
392
|
#
|
|
222
|
-
#
|
|
393
|
+
# Examples:
|
|
223
394
|
#
|
|
224
|
-
#
|
|
225
|
-
#
|
|
226
|
-
#
|
|
395
|
+
# exp(-INFINITY) # => 0.0
|
|
396
|
+
# exp(-1.0) # => 0.36787944117144233 # 1.0/E
|
|
397
|
+
# exp(0.0) # => 1.0
|
|
398
|
+
# exp(0.5) # => 1.6487212707001282 # sqrt(E)
|
|
399
|
+
# exp(1.0) # => 2.718281828459045 # E
|
|
400
|
+
# exp(2.0) # => 7.38905609893065 # E**2
|
|
401
|
+
# exp(INFINITY) # => Infinity
|
|
227
402
|
#
|
|
228
403
|
def self.exp: (Numeric x) -> Float
|
|
229
404
|
|
|
230
405
|
# <!--
|
|
231
406
|
# rdoc-file=math.c
|
|
232
|
-
# - Math.frexp(x)
|
|
407
|
+
# - Math.frexp(x) -> [fraction, exponent]
|
|
233
408
|
# -->
|
|
234
|
-
# Returns a
|
|
235
|
-
#
|
|
409
|
+
# Returns a 2-element array containing the normalized signed float `fraction`
|
|
410
|
+
# and integer `exponent` of `x` such that:
|
|
411
|
+
#
|
|
412
|
+
# x = fraction * 2**exponent
|
|
413
|
+
#
|
|
414
|
+
# See [IEEE 754 double-precision binary floating-point format:
|
|
415
|
+
# binary64](https://en.wikipedia.org/wiki/Double-precision_floating-point_format
|
|
416
|
+
# #IEEE_754_double-precision_binary_floating-point_format:_binary64).
|
|
417
|
+
#
|
|
418
|
+
# * Domain: `[-INFINITY, INFINITY]`.
|
|
419
|
+
# * Range `[-INFINITY, INFINITY]`.
|
|
420
|
+
#
|
|
421
|
+
#
|
|
422
|
+
# Examples:
|
|
236
423
|
#
|
|
237
|
-
#
|
|
238
|
-
#
|
|
424
|
+
# frexp(-INFINITY) # => [-Infinity, -1]
|
|
425
|
+
# frexp(-2.0) # => [-0.5, 2]
|
|
426
|
+
# frexp(-1.0) # => [-0.5, 1]
|
|
427
|
+
# frexp(0.0) # => [0.0, 0]
|
|
428
|
+
# frexp(1.0) # => [0.5, 1]
|
|
429
|
+
# frexp(2.0) # => [0.5, 2]
|
|
430
|
+
# frexp(INFINITY) # => [Infinity, -1]
|
|
431
|
+
#
|
|
432
|
+
# Related: Math.ldexp (inverse of Math.frexp).
|
|
239
433
|
#
|
|
240
434
|
def self.frexp: (Numeric x) -> [ Float, Integer ]
|
|
241
435
|
|
|
242
436
|
# <!--
|
|
243
437
|
# rdoc-file=math.c
|
|
244
|
-
# - Math.gamma(x)
|
|
438
|
+
# - Math.gamma(x) -> float
|
|
245
439
|
# -->
|
|
246
|
-
#
|
|
247
|
-
#
|
|
248
|
-
#
|
|
249
|
-
#
|
|
250
|
-
#
|
|
251
|
-
#
|
|
252
|
-
#
|
|
253
|
-
#
|
|
254
|
-
#
|
|
255
|
-
# #
|
|
256
|
-
# #
|
|
257
|
-
# #
|
|
258
|
-
#
|
|
259
|
-
# #
|
|
260
|
-
# #
|
|
261
|
-
# #
|
|
262
|
-
# #
|
|
263
|
-
# #
|
|
264
|
-
#
|
|
265
|
-
#
|
|
266
|
-
# # [14, 6227020800.0, 6227020800]
|
|
267
|
-
# # [15, 87178291200.0, 87178291200]
|
|
268
|
-
# # [16, 1307674368000.0, 1307674368000]
|
|
269
|
-
# # [17, 20922789888000.0, 20922789888000]
|
|
270
|
-
# # [18, 355687428096000.0, 355687428096000]
|
|
271
|
-
# # [19, 6.402373705728e+15, 6402373705728000]
|
|
272
|
-
# # [20, 1.21645100408832e+17, 121645100408832000]
|
|
273
|
-
# # [21, 2.43290200817664e+18, 2432902008176640000]
|
|
274
|
-
# # [22, 5.109094217170944e+19, 51090942171709440000]
|
|
275
|
-
# # [23, 1.1240007277776077e+21, 1124000727777607680000]
|
|
276
|
-
# # [24, 2.5852016738885062e+22, 25852016738884976640000]
|
|
277
|
-
# # [25, 6.204484017332391e+23, 620448401733239439360000]
|
|
278
|
-
# # [26, 1.5511210043330954e+25, 15511210043330985984000000]
|
|
440
|
+
# Returns the value of the [gamma
|
|
441
|
+
# function](https://en.wikipedia.org/wiki/Gamma_function) for `x`.
|
|
442
|
+
#
|
|
443
|
+
# * Domain: `(-INFINITY, INFINITY]` excluding negative integers.
|
|
444
|
+
# * Range: `[-INFINITY, INFINITY]`.
|
|
445
|
+
#
|
|
446
|
+
#
|
|
447
|
+
# Examples:
|
|
448
|
+
#
|
|
449
|
+
# gamma(-2.5) # => -0.9453087204829431
|
|
450
|
+
# gamma(-1.5) # => 2.3632718012073513
|
|
451
|
+
# gamma(-0.5) # => -3.5449077018110375
|
|
452
|
+
# gamma(0.0) # => Infinity
|
|
453
|
+
# gamma(1.0) # => 1.0
|
|
454
|
+
# gamma(2.0) # => 1.0
|
|
455
|
+
# gamma(3.0) # => 2.0
|
|
456
|
+
# gamma(4.0) # => 6.0
|
|
457
|
+
# gamma(5.0) # => 24.0
|
|
458
|
+
#
|
|
459
|
+
# Related: Math.lgamma.
|
|
279
460
|
#
|
|
280
461
|
def self.gamma: (Numeric x) -> Float
|
|
281
462
|
|
|
282
463
|
# <!--
|
|
283
464
|
# rdoc-file=math.c
|
|
284
|
-
# - Math.hypot(
|
|
465
|
+
# - Math.hypot(a, b) -> float
|
|
285
466
|
# -->
|
|
286
|
-
# Returns sqrt(
|
|
287
|
-
# sides `
|
|
467
|
+
# Returns `sqrt(a**2 + b**2)`, which is the length of the longest side `c` (the
|
|
468
|
+
# hypotenuse) of the right triangle whose other sides have lengths `a` and `b`.
|
|
288
469
|
#
|
|
289
|
-
#
|
|
470
|
+
# * Domain of `a`: `[-INFINITY, INFINITY]`.
|
|
471
|
+
# * Domain of +ab: `[-INFINITY, INFINITY]`.
|
|
472
|
+
# * Range: `[0, INFINITY]`.
|
|
473
|
+
#
|
|
474
|
+
#
|
|
475
|
+
# Examples:
|
|
476
|
+
#
|
|
477
|
+
# hypot(0.0, 1.0) # => 1.0
|
|
478
|
+
# hypot(1.0, 1.0) # => 1.4142135623730951 # sqrt(2.0)
|
|
479
|
+
# hypot(3.0, 4.0) # => 5.0
|
|
480
|
+
# hypot(5.0, 12.0) # => 13.0
|
|
481
|
+
# hypot(1.0, sqrt(3.0)) # => 1.9999999999999998 # Near 2.0
|
|
482
|
+
#
|
|
483
|
+
# Note that if either argument is `INFINITY` or `-INFINITY`, the result is
|
|
484
|
+
# `Infinity`.
|
|
290
485
|
#
|
|
291
486
|
def self.hypot: (Numeric x, Numeric y) -> Float
|
|
292
487
|
|
|
@@ -294,169 +489,246 @@ module Math
|
|
|
294
489
|
# rdoc-file=math.c
|
|
295
490
|
# - Math.ldexp(fraction, exponent) -> float
|
|
296
491
|
# -->
|
|
297
|
-
# Returns the value of `fraction
|
|
492
|
+
# Returns the value of `fraction * 2**exponent`.
|
|
493
|
+
#
|
|
494
|
+
# * Domain of `fraction`: `[0.0, 1.0)`.
|
|
495
|
+
# * Domain of `exponent`: `[0, 1024]` (larger values are equivalent to 1024).
|
|
496
|
+
#
|
|
497
|
+
#
|
|
498
|
+
# See [IEEE 754 double-precision binary floating-point format:
|
|
499
|
+
# binary64](https://en.wikipedia.org/wiki/Double-precision_floating-point_format
|
|
500
|
+
# #IEEE_754_double-precision_binary_floating-point_format:_binary64).
|
|
298
501
|
#
|
|
299
|
-
#
|
|
300
|
-
#
|
|
502
|
+
# Examples:
|
|
503
|
+
#
|
|
504
|
+
# ldexp(-INFINITY, -1) # => -Infinity
|
|
505
|
+
# ldexp(-0.5, 2) # => -2.0
|
|
506
|
+
# ldexp(-0.5, 1) # => -1.0
|
|
507
|
+
# ldexp(0.0, 0) # => 0.0
|
|
508
|
+
# ldexp(-0.5, 1) # => 1.0
|
|
509
|
+
# ldexp(-0.5, 2) # => 2.0
|
|
510
|
+
# ldexp(INFINITY, -1) # => Infinity
|
|
511
|
+
#
|
|
512
|
+
# Related: Math.frexp (inverse of Math.ldexp).
|
|
301
513
|
#
|
|
302
514
|
def self.ldexp: (Numeric fraction, Numeric exponent) -> Float
|
|
303
515
|
|
|
304
516
|
# <!--
|
|
305
517
|
# rdoc-file=math.c
|
|
306
|
-
# - Math.lgamma(x)
|
|
518
|
+
# - Math.lgamma(x) -> [float, -1 or 1]
|
|
307
519
|
# -->
|
|
308
|
-
#
|
|
520
|
+
# Returns a 2-element array equivalent to:
|
|
309
521
|
#
|
|
310
|
-
# Math.lgamma(x) is the same as
|
|
311
522
|
# [Math.log(Math.gamma(x).abs), Math.gamma(x) < 0 ? -1 : 1]
|
|
312
523
|
#
|
|
313
|
-
#
|
|
524
|
+
# See [logarithmic gamma
|
|
525
|
+
# function](https://en.wikipedia.org/wiki/Gamma_function#The_log-gamma_function)
|
|
526
|
+
# .
|
|
527
|
+
#
|
|
528
|
+
# * Domain: `(-INFINITY, INFINITY]`.
|
|
529
|
+
# * Range of first element: `(-INFINITY, INFINITY]`.
|
|
530
|
+
# * Second element is -1 or 1.
|
|
531
|
+
#
|
|
532
|
+
#
|
|
533
|
+
# Examples:
|
|
534
|
+
#
|
|
535
|
+
# lgamma(-4.0) # => [Infinity, -1]
|
|
536
|
+
# lgamma(-3.0) # => [Infinity, -1]
|
|
537
|
+
# lgamma(-2.0) # => [Infinity, -1]
|
|
538
|
+
# lgamma(-1.0) # => [Infinity, -1]
|
|
539
|
+
# lgamma(0.0) # => [Infinity, 1]
|
|
314
540
|
#
|
|
315
|
-
#
|
|
541
|
+
# lgamma(1.0) # => [0.0, 1]
|
|
542
|
+
# lgamma(2.0) # => [0.0, 1]
|
|
543
|
+
# lgamma(3.0) # => [0.6931471805599436, 1]
|
|
544
|
+
# lgamma(4.0) # => [1.7917594692280545, 1]
|
|
545
|
+
#
|
|
546
|
+
# lgamma(-2.5) # => [-0.05624371649767279, -1]
|
|
547
|
+
# lgamma(-1.5) # => [0.8600470153764797, 1]
|
|
548
|
+
# lgamma(-0.5) # => [1.265512123484647, -1]
|
|
549
|
+
# lgamma(0.5) # => [0.5723649429247004, 1]
|
|
550
|
+
# lgamma(1.5) # => [-0.12078223763524676, 1]
|
|
551
|
+
# lgamma(2.5) # => [0.2846828704729205, 1]
|
|
552
|
+
#
|
|
553
|
+
# Related: Math.gamma.
|
|
316
554
|
#
|
|
317
555
|
def self.lgamma: (Numeric x) -> [ Float, Integer ]
|
|
318
556
|
|
|
319
557
|
# <!--
|
|
320
558
|
# rdoc-file=math.c
|
|
321
|
-
# - Math.log(x)
|
|
322
|
-
# - Math.log(x, base) -> Float
|
|
559
|
+
# - Math.log(x, base = Math::E) -> Float
|
|
323
560
|
# -->
|
|
324
|
-
# Returns the
|
|
325
|
-
#
|
|
561
|
+
# Returns the base `base` [logarithm](https://en.wikipedia.org/wiki/Logarithm)
|
|
562
|
+
# of `x`.
|
|
563
|
+
#
|
|
564
|
+
# * Domain: `[0, INFINITY]`.
|
|
565
|
+
# * Range: `[-INFINITY, INFINITY)]`.
|
|
566
|
+
#
|
|
326
567
|
#
|
|
327
|
-
#
|
|
568
|
+
# Examples:
|
|
328
569
|
#
|
|
329
|
-
#
|
|
570
|
+
# log(0.0) # => -Infinity
|
|
571
|
+
# log(1.0) # => 0.0
|
|
572
|
+
# log(E) # => 1.0
|
|
573
|
+
# log(INFINITY) # => Infinity
|
|
330
574
|
#
|
|
331
|
-
#
|
|
332
|
-
#
|
|
333
|
-
#
|
|
334
|
-
#
|
|
335
|
-
#
|
|
575
|
+
# log(0.0, 2.0) # => -Infinity
|
|
576
|
+
# log(1.0, 2.0) # => 0.0
|
|
577
|
+
# log(2.0, 2.0) # => 1.0
|
|
578
|
+
#
|
|
579
|
+
# log(0.0, 10.0) # => -Infinity
|
|
580
|
+
# log(1.0, 10.0) # => 0.0
|
|
581
|
+
# log(10.0, 10.0) # => 1.0
|
|
336
582
|
#
|
|
337
583
|
def self.log: (Numeric x, ?Numeric base) -> Float
|
|
338
584
|
|
|
339
585
|
# <!--
|
|
340
586
|
# rdoc-file=math.c
|
|
341
|
-
# - Math.log10(x)
|
|
587
|
+
# - Math.log10(x) -> float
|
|
342
588
|
# -->
|
|
343
|
-
# Returns the base 10 logarithm of
|
|
589
|
+
# Returns the base 10 [logarithm](https://en.wikipedia.org/wiki/Logarithm) of
|
|
590
|
+
# `x`.
|
|
591
|
+
#
|
|
592
|
+
# * Domain: `[0, INFINITY]`.
|
|
593
|
+
# * Range: `[-INFINITY, INFINITY]`.
|
|
344
594
|
#
|
|
345
|
-
# Domain: (0, INFINITY)
|
|
346
595
|
#
|
|
347
|
-
#
|
|
596
|
+
# Examples:
|
|
348
597
|
#
|
|
349
|
-
#
|
|
350
|
-
#
|
|
351
|
-
#
|
|
598
|
+
# log10(0.0) # => -Infinity
|
|
599
|
+
# log10(1.0) # => 0.0
|
|
600
|
+
# log10(10.0) # => 1.0
|
|
601
|
+
# log10(INFINITY) # => Infinity
|
|
352
602
|
#
|
|
353
603
|
def self.log10: (Numeric x) -> Float
|
|
354
604
|
|
|
355
605
|
# <!--
|
|
356
606
|
# rdoc-file=math.c
|
|
357
|
-
# - Math.log2(x)
|
|
607
|
+
# - Math.log2(x) -> float
|
|
358
608
|
# -->
|
|
359
|
-
# Returns the base 2 logarithm of
|
|
609
|
+
# Returns the base 2 [logarithm](https://en.wikipedia.org/wiki/Logarithm) of
|
|
610
|
+
# `x`.
|
|
611
|
+
#
|
|
612
|
+
# * Domain: `[0, INFINITY]`.
|
|
613
|
+
# * Range: `[-INFINITY, INFINITY]`.
|
|
360
614
|
#
|
|
361
|
-
# Domain: (0, INFINITY)
|
|
362
615
|
#
|
|
363
|
-
#
|
|
616
|
+
# Examples:
|
|
364
617
|
#
|
|
365
|
-
#
|
|
366
|
-
#
|
|
367
|
-
#
|
|
368
|
-
#
|
|
618
|
+
# log2(0.0) # => -Infinity
|
|
619
|
+
# log2(1.0) # => 0.0
|
|
620
|
+
# log2(2.0) # => 1.0
|
|
621
|
+
# log2(INFINITY) # => Infinity
|
|
369
622
|
#
|
|
370
623
|
def self.log2: (Numeric x) -> Float
|
|
371
624
|
|
|
372
625
|
# <!--
|
|
373
626
|
# rdoc-file=math.c
|
|
374
|
-
# - Math.sin(x)
|
|
627
|
+
# - Math.sin(x) -> float
|
|
375
628
|
# -->
|
|
376
|
-
#
|
|
377
|
-
#
|
|
629
|
+
# Returns the [sine](https://en.wikipedia.org/wiki/Sine_and_cosine) of `x` in
|
|
630
|
+
# [radians](https://en.wikipedia.org/wiki/Trigonometric_functions#Radians_versus
|
|
631
|
+
# _degrees).
|
|
378
632
|
#
|
|
379
|
-
# Domain: (-INFINITY, INFINITY)
|
|
633
|
+
# * Domain: `(-INFINITY, INFINITY)`.
|
|
634
|
+
# * Range: `[-1.0, 1.0]`.
|
|
380
635
|
#
|
|
381
|
-
# Codomain: [-1, 1]
|
|
382
636
|
#
|
|
383
|
-
#
|
|
637
|
+
# Examples:
|
|
638
|
+
#
|
|
639
|
+
# sin(-PI) # => -1.2246063538223773e-16 # -0.0000000000000001
|
|
640
|
+
# sin(-PI/2) # => -1.0
|
|
641
|
+
# sin(0.0) # => 0.0
|
|
642
|
+
# sin(PI/2) # => 1.0
|
|
643
|
+
# sin(PI) # => 1.2246063538223773e-16 # 0.0000000000000001
|
|
384
644
|
#
|
|
385
645
|
def self.sin: (Numeric x) -> Float
|
|
386
646
|
|
|
387
647
|
# <!--
|
|
388
648
|
# rdoc-file=math.c
|
|
389
|
-
# - Math.sinh(x)
|
|
649
|
+
# - Math.sinh(x) -> float
|
|
390
650
|
# -->
|
|
391
|
-
#
|
|
651
|
+
# Returns the [hyperbolic
|
|
652
|
+
# sine](https://en.wikipedia.org/wiki/Hyperbolic_functions) of `x` in
|
|
653
|
+
# [radians](https://en.wikipedia.org/wiki/Trigonometric_functions#Radians_versus
|
|
654
|
+
# _degrees).
|
|
655
|
+
#
|
|
656
|
+
# * Domain: `[-INFINITY, INFINITY]`.
|
|
657
|
+
# * Range: `[-INFINITY, INFINITY]`.
|
|
392
658
|
#
|
|
393
|
-
# Domain: (-INFINITY, INFINITY)
|
|
394
659
|
#
|
|
395
|
-
#
|
|
660
|
+
# Examples:
|
|
396
661
|
#
|
|
397
|
-
#
|
|
662
|
+
# sinh(-INFINITY) # => -Infinity
|
|
663
|
+
# sinh(0.0) # => 0.0
|
|
664
|
+
# sinh(INFINITY) # => Infinity
|
|
398
665
|
#
|
|
399
666
|
def self.sinh: (Numeric x) -> Float
|
|
400
667
|
|
|
401
668
|
# <!--
|
|
402
669
|
# rdoc-file=math.c
|
|
403
|
-
# - Math.sqrt(x)
|
|
670
|
+
# - Math.sqrt(x) -> float
|
|
404
671
|
# -->
|
|
405
|
-
# Returns the non-negative square
|
|
406
|
-
#
|
|
407
|
-
# Domain: [0, INFINITY)
|
|
672
|
+
# Returns the principal (non-negative) [square
|
|
673
|
+
# root](https://en.wikipedia.org/wiki/Square_root) of `x`.
|
|
408
674
|
#
|
|
409
|
-
#
|
|
675
|
+
# * Domain: `[0, INFINITY]`.
|
|
676
|
+
# * Range: `[0, INFINITY]`.
|
|
410
677
|
#
|
|
411
|
-
# 0.upto(10) {|x|
|
|
412
|
-
# p [x, Math.sqrt(x), Math.sqrt(x)**2]
|
|
413
|
-
# }
|
|
414
|
-
# #=> [0, 0.0, 0.0]
|
|
415
|
-
# # [1, 1.0, 1.0]
|
|
416
|
-
# # [2, 1.4142135623731, 2.0]
|
|
417
|
-
# # [3, 1.73205080756888, 3.0]
|
|
418
|
-
# # [4, 2.0, 4.0]
|
|
419
|
-
# # [5, 2.23606797749979, 5.0]
|
|
420
|
-
# # [6, 2.44948974278318, 6.0]
|
|
421
|
-
# # [7, 2.64575131106459, 7.0]
|
|
422
|
-
# # [8, 2.82842712474619, 8.0]
|
|
423
|
-
# # [9, 3.0, 9.0]
|
|
424
|
-
# # [10, 3.16227766016838, 10.0]
|
|
425
678
|
#
|
|
426
|
-
#
|
|
427
|
-
# surprising results:
|
|
679
|
+
# Examples:
|
|
428
680
|
#
|
|
429
|
-
#
|
|
430
|
-
#
|
|
431
|
-
#
|
|
681
|
+
# sqrt(0.0) # => 0.0
|
|
682
|
+
# sqrt(0.5) # => 0.7071067811865476
|
|
683
|
+
# sqrt(1.0) # => 1.0
|
|
684
|
+
# sqrt(2.0) # => 1.4142135623730951
|
|
685
|
+
# sqrt(4.0) # => 2.0
|
|
686
|
+
# sqrt(9.0) # => 3.0
|
|
687
|
+
# sqrt(INFINITY) # => Infinity
|
|
432
688
|
#
|
|
433
689
|
def self.sqrt: (Numeric x) -> Float
|
|
434
690
|
|
|
435
691
|
# <!--
|
|
436
692
|
# rdoc-file=math.c
|
|
437
|
-
# - Math.tan(x)
|
|
693
|
+
# - Math.tan(x) -> float
|
|
438
694
|
# -->
|
|
439
|
-
#
|
|
695
|
+
# Returns the [tangent](https://en.wikipedia.org/wiki/Trigonometric_functions)
|
|
696
|
+
# of `x` in
|
|
697
|
+
# [radians](https://en.wikipedia.org/wiki/Trigonometric_functions#Radians_versus
|
|
698
|
+
# _degrees).
|
|
699
|
+
#
|
|
700
|
+
# * Domain: `(-INFINITY, INFINITY)`.
|
|
701
|
+
# * Range: `(-INFINITY, INFINITY)`.
|
|
440
702
|
#
|
|
441
|
-
# Domain: (-INFINITY, INFINITY)
|
|
442
703
|
#
|
|
443
|
-
#
|
|
704
|
+
# Examples:
|
|
444
705
|
#
|
|
445
|
-
#
|
|
706
|
+
# tan(-PI) # => 1.2246467991473532e-16 # -0.0000000000000001
|
|
707
|
+
# tan(-PI/2) # => -1.633123935319537e+16 # -16331239353195370.0
|
|
708
|
+
# tan(0.0) # => 0.0
|
|
709
|
+
# tan(PI/2) # => 1.633123935319537e+16 # 16331239353195370.0
|
|
710
|
+
# tan(PI) # => -1.2246467991473532e-16 # -0.0000000000000001
|
|
446
711
|
#
|
|
447
712
|
def self.tan: (Numeric x) -> Float
|
|
448
713
|
|
|
449
714
|
# <!--
|
|
450
715
|
# rdoc-file=math.c
|
|
451
|
-
# - Math.tanh(x)
|
|
716
|
+
# - Math.tanh(x) -> float
|
|
452
717
|
# -->
|
|
453
|
-
#
|
|
718
|
+
# Returns the [hyperbolic
|
|
719
|
+
# tangent](https://en.wikipedia.org/wiki/Hyperbolic_functions) of `x` in
|
|
720
|
+
# [radians](https://en.wikipedia.org/wiki/Trigonometric_functions#Radians_versus
|
|
721
|
+
# _degrees).
|
|
722
|
+
#
|
|
723
|
+
# * Domain: `[-INFINITY, INFINITY]`.
|
|
724
|
+
# * Range: `[-1, 1]`.
|
|
454
725
|
#
|
|
455
|
-
# Domain: (-INFINITY, INFINITY)
|
|
456
726
|
#
|
|
457
|
-
#
|
|
727
|
+
# Examples:
|
|
458
728
|
#
|
|
459
|
-
#
|
|
729
|
+
# tanh(-INFINITY) # => -1.0
|
|
730
|
+
# tanh(0.0) # => 0.0
|
|
731
|
+
# tanh(INFINITY) # => 1.0
|
|
460
732
|
#
|
|
461
733
|
def self.tanh: (Numeric x) -> Float
|
|
462
734
|
end
|