summaryrefslogtreecommitdiff
path: root/devdocs/go/math%2Findex.html
blob: 158845f5b4593a6c2ee3b8467198f0561aabe4da (plain)
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
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
<h1> Package math  </h1>     <ul id="short-nav">
<li><code>import "math"</code></li>
<li><a href="#pkg-overview" class="overviewLink">Overview</a></li>
<li><a href="#pkg-index" class="indexLink">Index</a></li>
<li><a href="#pkg-examples" class="examplesLink">Examples</a></li>
<li><a href="#pkg-subdirectories">Subdirectories</a></li>
</ul>     <h2 id="pkg-overview">Overview </h2> <p>Package math provides basic constants and mathematical functions. </p>
<p>This package does not guarantee bit-identical results across architectures. </p>     <h2 id="pkg-index">Index </h2>  <ul id="manual-nav">
<li><a href="#pkg-constants">Constants</a></li>
<li><a href="#Abs">func Abs(x float64) float64</a></li>
<li><a href="#Acos">func Acos(x float64) float64</a></li>
<li><a href="#Acosh">func Acosh(x float64) float64</a></li>
<li><a href="#Asin">func Asin(x float64) float64</a></li>
<li><a href="#Asinh">func Asinh(x float64) float64</a></li>
<li><a href="#Atan">func Atan(x float64) float64</a></li>
<li><a href="#Atan2">func Atan2(y, x float64) float64</a></li>
<li><a href="#Atanh">func Atanh(x float64) float64</a></li>
<li><a href="#Cbrt">func Cbrt(x float64) float64</a></li>
<li><a href="#Ceil">func Ceil(x float64) float64</a></li>
<li><a href="#Copysign">func Copysign(f, sign float64) float64</a></li>
<li><a href="#Cos">func Cos(x float64) float64</a></li>
<li><a href="#Cosh">func Cosh(x float64) float64</a></li>
<li><a href="#Dim">func Dim(x, y float64) float64</a></li>
<li><a href="#Erf">func Erf(x float64) float64</a></li>
<li><a href="#Erfc">func Erfc(x float64) float64</a></li>
<li><a href="#Erfcinv">func Erfcinv(x float64) float64</a></li>
<li><a href="#Erfinv">func Erfinv(x float64) float64</a></li>
<li><a href="#Exp">func Exp(x float64) float64</a></li>
<li><a href="#Exp2">func Exp2(x float64) float64</a></li>
<li><a href="#Expm1">func Expm1(x float64) float64</a></li>
<li><a href="#FMA">func FMA(x, y, z float64) float64</a></li>
<li><a href="#Float32bits">func Float32bits(f float32) uint32</a></li>
<li><a href="#Float32frombits">func Float32frombits(b uint32) float32</a></li>
<li><a href="#Float64bits">func Float64bits(f float64) uint64</a></li>
<li><a href="#Float64frombits">func Float64frombits(b uint64) float64</a></li>
<li><a href="#Floor">func Floor(x float64) float64</a></li>
<li><a href="#Frexp">func Frexp(f float64) (frac float64, exp int)</a></li>
<li><a href="#Gamma">func Gamma(x float64) float64</a></li>
<li><a href="#Hypot">func Hypot(p, q float64) float64</a></li>
<li><a href="#Ilogb">func Ilogb(x float64) int</a></li>
<li><a href="#Inf">func Inf(sign int) float64</a></li>
<li><a href="#IsInf">func IsInf(f float64, sign int) bool</a></li>
<li><a href="#IsNaN">func IsNaN(f float64) (is bool)</a></li>
<li><a href="#J0">func J0(x float64) float64</a></li>
<li><a href="#J1">func J1(x float64) float64</a></li>
<li><a href="#Jn">func Jn(n int, x float64) float64</a></li>
<li><a href="#Ldexp">func Ldexp(frac float64, exp int) float64</a></li>
<li><a href="#Lgamma">func Lgamma(x float64) (lgamma float64, sign int)</a></li>
<li><a href="#Log">func Log(x float64) float64</a></li>
<li><a href="#Log10">func Log10(x float64) float64</a></li>
<li><a href="#Log1p">func Log1p(x float64) float64</a></li>
<li><a href="#Log2">func Log2(x float64) float64</a></li>
<li><a href="#Logb">func Logb(x float64) float64</a></li>
<li><a href="#Max">func Max(x, y float64) float64</a></li>
<li><a href="#Min">func Min(x, y float64) float64</a></li>
<li><a href="#Mod">func Mod(x, y float64) float64</a></li>
<li><a href="#Modf">func Modf(f float64) (int float64, frac float64)</a></li>
<li><a href="#NaN">func NaN() float64</a></li>
<li><a href="#Nextafter">func Nextafter(x, y float64) (r float64)</a></li>
<li><a href="#Nextafter32">func Nextafter32(x, y float32) (r float32)</a></li>
<li><a href="#Pow">func Pow(x, y float64) float64</a></li>
<li><a href="#Pow10">func Pow10(n int) float64</a></li>
<li><a href="#Remainder">func Remainder(x, y float64) float64</a></li>
<li><a href="#Round">func Round(x float64) float64</a></li>
<li><a href="#RoundToEven">func RoundToEven(x float64) float64</a></li>
<li><a href="#Signbit">func Signbit(x float64) bool</a></li>
<li><a href="#Sin">func Sin(x float64) float64</a></li>
<li><a href="#Sincos">func Sincos(x float64) (sin, cos float64)</a></li>
<li><a href="#Sinh">func Sinh(x float64) float64</a></li>
<li><a href="#Sqrt">func Sqrt(x float64) float64</a></li>
<li><a href="#Tan">func Tan(x float64) float64</a></li>
<li><a href="#Tanh">func Tanh(x float64) float64</a></li>
<li><a href="#Trunc">func Trunc(x float64) float64</a></li>
<li><a href="#Y0">func Y0(x float64) float64</a></li>
<li><a href="#Y1">func Y1(x float64) float64</a></li>
<li><a href="#Yn">func Yn(n int, x float64) float64</a></li>
</ul> <div id="pkg-examples"> <h3>Examples</h3>  <dl> <dd><a class="exampleLink" href="#example_Abs">Abs</a></dd> <dd><a class="exampleLink" href="#example_Acos">Acos</a></dd> <dd><a class="exampleLink" href="#example_Acosh">Acosh</a></dd> <dd><a class="exampleLink" href="#example_Asin">Asin</a></dd> <dd><a class="exampleLink" href="#example_Asinh">Asinh</a></dd> <dd><a class="exampleLink" href="#example_Atan">Atan</a></dd> <dd><a class="exampleLink" href="#example_Atan2">Atan2</a></dd> <dd><a class="exampleLink" href="#example_Atanh">Atanh</a></dd> <dd><a class="exampleLink" href="#example_Cbrt">Cbrt</a></dd> <dd><a class="exampleLink" href="#example_Ceil">Ceil</a></dd> <dd><a class="exampleLink" href="#example_Copysign">Copysign</a></dd> <dd><a class="exampleLink" href="#example_Cos">Cos</a></dd> <dd><a class="exampleLink" href="#example_Cosh">Cosh</a></dd> <dd><a class="exampleLink" href="#example_Dim">Dim</a></dd> <dd><a class="exampleLink" href="#example_Exp">Exp</a></dd> <dd><a class="exampleLink" href="#example_Exp2">Exp2</a></dd> <dd><a class="exampleLink" href="#example_Expm1">Expm1</a></dd> <dd><a class="exampleLink" href="#example_Floor">Floor</a></dd> <dd><a class="exampleLink" href="#example_Log">Log</a></dd> <dd><a class="exampleLink" href="#example_Log10">Log10</a></dd> <dd><a class="exampleLink" href="#example_Log2">Log2</a></dd> <dd><a class="exampleLink" href="#example_Mod">Mod</a></dd> <dd><a class="exampleLink" href="#example_Modf">Modf</a></dd> <dd><a class="exampleLink" href="#example_Pow">Pow</a></dd> <dd><a class="exampleLink" href="#example_Pow10">Pow10</a></dd> <dd><a class="exampleLink" href="#example_Remainder">Remainder</a></dd> <dd><a class="exampleLink" href="#example_Round">Round</a></dd> <dd><a class="exampleLink" href="#example_RoundToEven">RoundToEven</a></dd> <dd><a class="exampleLink" href="#example_Sin">Sin</a></dd> <dd><a class="exampleLink" href="#example_Sincos">Sincos</a></dd> <dd><a class="exampleLink" href="#example_Sinh">Sinh</a></dd> <dd><a class="exampleLink" href="#example_Sqrt">Sqrt</a></dd> <dd><a class="exampleLink" href="#example_Tan">Tan</a></dd> <dd><a class="exampleLink" href="#example_Tanh">Tanh</a></dd> <dd><a class="exampleLink" href="#example_Trunc">Trunc</a></dd> </dl> </div> <h3>Package files</h3> <p>  <span>abs.go</span> <span>acosh.go</span> <span>asin.go</span> <span>asinh.go</span> <span>atan.go</span> <span>atan2.go</span> <span>atanh.go</span> <span>bits.go</span> <span>cbrt.go</span> <span>const.go</span> <span>copysign.go</span> <span>dim.go</span> <span>dim_asm.go</span> <span>erf.go</span> <span>erfinv.go</span> <span>exp.go</span> <span>exp2_noasm.go</span> <span>exp_amd64.go</span> <span>exp_asm.go</span> <span>expm1.go</span> <span>floor.go</span> <span>floor_asm.go</span> <span>fma.go</span> <span>frexp.go</span> <span>gamma.go</span> <span>hypot.go</span> <span>hypot_asm.go</span> <span>j0.go</span> <span>j1.go</span> <span>jn.go</span> <span>ldexp.go</span> <span>lgamma.go</span> <span>log.go</span> <span>log10.go</span> <span>log1p.go</span> <span>log_asm.go</span> <span>logb.go</span> <span>mod.go</span> <span>modf.go</span> <span>modf_noasm.go</span> <span>nextafter.go</span> <span>pow.go</span> <span>pow10.go</span> <span>remainder.go</span> <span>signbit.go</span> <span>sin.go</span> <span>sincos.go</span> <span>sinh.go</span> <span>sqrt.go</span> <span>stubs.go</span> <span>tan.go</span> <span>tanh.go</span> <span>trig_reduce.go</span> <span>unsafe.go</span>  </p>   <h2 id="pkg-constants">Constants</h2> <p>Mathematical constants. </p>
<pre data-language="go">const (
    E   = 2.71828182845904523536028747135266249775724709369995957496696763 // https://oeis.org/A001113
    Pi  = 3.14159265358979323846264338327950288419716939937510582097494459 // https://oeis.org/A000796
    Phi = 1.61803398874989484820458683436563811772030917980576286213544862 // https://oeis.org/A001622

    Sqrt2   = 1.41421356237309504880168872420969807856967187537694807317667974 // https://oeis.org/A002193
    SqrtE   = 1.64872127070012814684865078781416357165377610071014801157507931 // https://oeis.org/A019774
    SqrtPi  = 1.77245385090551602729816748334114518279754945612238712821380779 // https://oeis.org/A002161
    SqrtPhi = 1.27201964951406896425242246173749149171560804184009624861664038 // https://oeis.org/A139339

    Ln2    = 0.693147180559945309417232121458176568075500134360255254120680009 // https://oeis.org/A002162
    Log2E  = 1 / Ln2
    Ln10   = 2.30258509299404568401799145468436420760110148862877297603332790 // https://oeis.org/A002392
    Log10E = 1 / Ln10
)</pre> <p>Floating-point limit values. Max is the largest finite value representable by the type. SmallestNonzero is the smallest positive, non-zero value representable by the type. </p>
<pre data-language="go">const (
    MaxFloat32             = 0x1p127 * (1 + (1 - 0x1p-23)) // 3.40282346638528859811704183484516925440e+38
    SmallestNonzeroFloat32 = 0x1p-126 * 0x1p-23            // 1.401298464324817070923729583289916131280e-45

    MaxFloat64             = 0x1p1023 * (1 + (1 - 0x1p-52)) // 1.79769313486231570814527423731704356798070e+308
    SmallestNonzeroFloat64 = 0x1p-1022 * 0x1p-52            // 4.9406564584124654417656879286822137236505980e-324
)</pre> <p>Integer limit values. </p>
<pre data-language="go">const (
    MaxInt    = 1&lt;&lt;(intSize-1) - 1  // MaxInt32 or MaxInt64 depending on intSize.
    MinInt    = -1 &lt;&lt; (intSize - 1) // MinInt32 or MinInt64 depending on intSize.
    MaxInt8   = 1&lt;&lt;7 - 1            // 127
    MinInt8   = -1 &lt;&lt; 7             // -128
    MaxInt16  = 1&lt;&lt;15 - 1           // 32767
    MinInt16  = -1 &lt;&lt; 15            // -32768
    MaxInt32  = 1&lt;&lt;31 - 1           // 2147483647
    MinInt32  = -1 &lt;&lt; 31            // -2147483648
    MaxInt64  = 1&lt;&lt;63 - 1           // 9223372036854775807
    MinInt64  = -1 &lt;&lt; 63            // -9223372036854775808
    MaxUint   = 1&lt;&lt;intSize - 1      // MaxUint32 or MaxUint64 depending on intSize.
    MaxUint8  = 1&lt;&lt;8 - 1            // 255
    MaxUint16 = 1&lt;&lt;16 - 1           // 65535
    MaxUint32 = 1&lt;&lt;32 - 1           // 4294967295
    MaxUint64 = 1&lt;&lt;64 - 1           // 18446744073709551615
)</pre> <h2 id="Abs">func <span>Abs</span>  </h2> <pre data-language="go">func Abs(x float64) float64</pre> <p>Abs returns the absolute value of x. </p>
<p>Special cases are: </p>
<pre data-language="go">Abs(±Inf) = +Inf
Abs(NaN) = NaN
</pre>    <h4 id="example_Abs"> <span class="text">Example</span>
</h4> <p>Code:</p> <pre class="code" data-language="go">x := math.Abs(-2)
fmt.Printf("%.1f\n", x)

y := math.Abs(2)
fmt.Printf("%.1f\n", y)
</pre> <p>Output:</p> <pre class="output" data-language="go">2.0
2.0
</pre>   <h2 id="Acos">func <span>Acos</span>  </h2> <pre data-language="go">func Acos(x float64) float64</pre> <p>Acos returns the arccosine, in radians, of x. </p>
<p>Special case is: </p>
<pre data-language="go">Acos(x) = NaN if x &lt; -1 or x &gt; 1
</pre>    <h4 id="example_Acos"> <span class="text">Example</span>
</h4> <p>Code:</p> <pre class="code" data-language="go">fmt.Printf("%.2f", math.Acos(1))
</pre> <p>Output:</p> <pre class="output" data-language="go">0.00
</pre>   <h2 id="Acosh">func <span>Acosh</span>  </h2> <pre data-language="go">func Acosh(x float64) float64</pre> <p>Acosh returns the inverse hyperbolic cosine of x. </p>
<p>Special cases are: </p>
<pre data-language="go">Acosh(+Inf) = +Inf
Acosh(x) = NaN if x &lt; 1
Acosh(NaN) = NaN
</pre>    <h4 id="example_Acosh"> <span class="text">Example</span>
</h4> <p>Code:</p> <pre class="code" data-language="go">fmt.Printf("%.2f", math.Acosh(1))
</pre> <p>Output:</p> <pre class="output" data-language="go">0.00
</pre>   <h2 id="Asin">func <span>Asin</span>  </h2> <pre data-language="go">func Asin(x float64) float64</pre> <p>Asin returns the arcsine, in radians, of x. </p>
<p>Special cases are: </p>
<pre data-language="go">Asin(±0) = ±0
Asin(x) = NaN if x &lt; -1 or x &gt; 1
</pre>    <h4 id="example_Asin"> <span class="text">Example</span>
</h4> <p>Code:</p> <pre class="code" data-language="go">fmt.Printf("%.2f", math.Asin(0))
</pre> <p>Output:</p> <pre class="output" data-language="go">0.00
</pre>   <h2 id="Asinh">func <span>Asinh</span>  </h2> <pre data-language="go">func Asinh(x float64) float64</pre> <p>Asinh returns the inverse hyperbolic sine of x. </p>
<p>Special cases are: </p>
<pre data-language="go">Asinh(±0) = ±0
Asinh(±Inf) = ±Inf
Asinh(NaN) = NaN
</pre>    <h4 id="example_Asinh"> <span class="text">Example</span>
</h4> <p>Code:</p> <pre class="code" data-language="go">fmt.Printf("%.2f", math.Asinh(0))
</pre> <p>Output:</p> <pre class="output" data-language="go">0.00
</pre>   <h2 id="Atan">func <span>Atan</span>  </h2> <pre data-language="go">func Atan(x float64) float64</pre> <p>Atan returns the arctangent, in radians, of x. </p>
<p>Special cases are: </p>
<pre data-language="go">Atan(±0) = ±0
Atan(±Inf) = ±Pi/2
</pre>    <h4 id="example_Atan"> <span class="text">Example</span>
</h4> <p>Code:</p> <pre class="code" data-language="go">fmt.Printf("%.2f", math.Atan(0))
</pre> <p>Output:</p> <pre class="output" data-language="go">0.00
</pre>   <h2 id="Atan2">func <span>Atan2</span>  </h2> <pre data-language="go">func Atan2(y, x float64) float64</pre> <p>Atan2 returns the arc tangent of y/x, using the signs of the two to determine the quadrant of the return value. </p>
<p>Special cases are (in order): </p>
<pre data-language="go">Atan2(y, NaN) = NaN
Atan2(NaN, x) = NaN
Atan2(+0, x&gt;=0) = +0
Atan2(-0, x&gt;=0) = -0
Atan2(+0, x&lt;=-0) = +Pi
Atan2(-0, x&lt;=-0) = -Pi
Atan2(y&gt;0, 0) = +Pi/2
Atan2(y&lt;0, 0) = -Pi/2
Atan2(+Inf, +Inf) = +Pi/4
Atan2(-Inf, +Inf) = -Pi/4
Atan2(+Inf, -Inf) = 3Pi/4
Atan2(-Inf, -Inf) = -3Pi/4
Atan2(y, +Inf) = 0
Atan2(y&gt;0, -Inf) = +Pi
Atan2(y&lt;0, -Inf) = -Pi
Atan2(+Inf, x) = +Pi/2
Atan2(-Inf, x) = -Pi/2
</pre>    <h4 id="example_Atan2"> <span class="text">Example</span>
</h4> <p>Code:</p> <pre class="code" data-language="go">fmt.Printf("%.2f", math.Atan2(0, 0))
</pre> <p>Output:</p> <pre class="output" data-language="go">0.00
</pre>   <h2 id="Atanh">func <span>Atanh</span>  </h2> <pre data-language="go">func Atanh(x float64) float64</pre> <p>Atanh returns the inverse hyperbolic tangent of x. </p>
<p>Special cases are: </p>
<pre data-language="go">Atanh(1) = +Inf
Atanh(±0) = ±0
Atanh(-1) = -Inf
Atanh(x) = NaN if x &lt; -1 or x &gt; 1
Atanh(NaN) = NaN
</pre>    <h4 id="example_Atanh"> <span class="text">Example</span>
</h4> <p>Code:</p> <pre class="code" data-language="go">fmt.Printf("%.2f", math.Atanh(0))
</pre> <p>Output:</p> <pre class="output" data-language="go">0.00
</pre>   <h2 id="Cbrt">func <span>Cbrt</span>  </h2> <pre data-language="go">func Cbrt(x float64) float64</pre> <p>Cbrt returns the cube root of x. </p>
<p>Special cases are: </p>
<pre data-language="go">Cbrt(±0) = ±0
Cbrt(±Inf) = ±Inf
Cbrt(NaN) = NaN
</pre>    <h4 id="example_Cbrt"> <span class="text">Example</span>
</h4> <p>Code:</p> <pre class="code" data-language="go">fmt.Printf("%.2f\n", math.Cbrt(8))
fmt.Printf("%.2f\n", math.Cbrt(27))
</pre> <p>Output:</p> <pre class="output" data-language="go">2.00
3.00
</pre>   <h2 id="Ceil">func <span>Ceil</span>  </h2> <pre data-language="go">func Ceil(x float64) float64</pre> <p>Ceil returns the least integer value greater than or equal to x. </p>
<p>Special cases are: </p>
<pre data-language="go">Ceil(±0) = ±0
Ceil(±Inf) = ±Inf
Ceil(NaN) = NaN
</pre>    <h4 id="example_Ceil"> <span class="text">Example</span>
</h4> <p>Code:</p> <pre class="code" data-language="go">c := math.Ceil(1.49)
fmt.Printf("%.1f", c)
</pre> <p>Output:</p> <pre class="output" data-language="go">2.0
</pre>   <h2 id="Copysign">func <span>Copysign</span>  </h2> <pre data-language="go">func Copysign(f, sign float64) float64</pre> <p>Copysign returns a value with the magnitude of f and the sign of sign. </p>   <h4 id="example_Copysign"> <span class="text">Example</span>
</h4> <p>Code:</p> <pre class="code" data-language="go">fmt.Printf("%.2f", math.Copysign(3.2, -1))
</pre> <p>Output:</p> <pre class="output" data-language="go">-3.20
</pre>   <h2 id="Cos">func <span>Cos</span>  </h2> <pre data-language="go">func Cos(x float64) float64</pre> <p>Cos returns the cosine of the radian argument x. </p>
<p>Special cases are: </p>
<pre data-language="go">Cos(±Inf) = NaN
Cos(NaN) = NaN
</pre>    <h4 id="example_Cos"> <span class="text">Example</span>
</h4> <p>Code:</p> <pre class="code" data-language="go">fmt.Printf("%.2f", math.Cos(math.Pi/2))
</pre> <p>Output:</p> <pre class="output" data-language="go">0.00
</pre>   <h2 id="Cosh">func <span>Cosh</span>  </h2> <pre data-language="go">func Cosh(x float64) float64</pre> <p>Cosh returns the hyperbolic cosine of x. </p>
<p>Special cases are: </p>
<pre data-language="go">Cosh(±0) = 1
Cosh(±Inf) = +Inf
Cosh(NaN) = NaN
</pre>    <h4 id="example_Cosh"> <span class="text">Example</span>
</h4> <p>Code:</p> <pre class="code" data-language="go">fmt.Printf("%.2f", math.Cosh(0))
</pre> <p>Output:</p> <pre class="output" data-language="go">1.00
</pre>   <h2 id="Dim">func <span>Dim</span>  </h2> <pre data-language="go">func Dim(x, y float64) float64</pre> <p>Dim returns the maximum of x-y or 0. </p>
<p>Special cases are: </p>
<pre data-language="go">Dim(+Inf, +Inf) = NaN
Dim(-Inf, -Inf) = NaN
Dim(x, NaN) = Dim(NaN, x) = NaN
</pre>    <h4 id="example_Dim"> <span class="text">Example</span>
</h4> <p>Code:</p> <pre class="code" data-language="go">fmt.Printf("%.2f\n", math.Dim(4, -2))
fmt.Printf("%.2f\n", math.Dim(-4, 2))
</pre> <p>Output:</p> <pre class="output" data-language="go">6.00
0.00
</pre>   <h2 id="Erf">func <span>Erf</span>  </h2> <pre data-language="go">func Erf(x float64) float64</pre> <p>Erf returns the error function of x. </p>
<p>Special cases are: </p>
<pre data-language="go">Erf(+Inf) = 1
Erf(-Inf) = -1
Erf(NaN) = NaN
</pre> <h2 id="Erfc">func <span>Erfc</span>  </h2> <pre data-language="go">func Erfc(x float64) float64</pre> <p>Erfc returns the complementary error function of x. </p>
<p>Special cases are: </p>
<pre data-language="go">Erfc(+Inf) = 0
Erfc(-Inf) = 2
Erfc(NaN) = NaN
</pre> <h2 id="Erfcinv">func <span>Erfcinv</span>  <span title="Added in Go 1.10">1.10</span> </h2> <pre data-language="go">func Erfcinv(x float64) float64</pre> <p>Erfcinv returns the inverse of <a href="#Erfc">Erfc</a>(x). </p>
<p>Special cases are: </p>
<pre data-language="go">Erfcinv(0) = +Inf
Erfcinv(2) = -Inf
Erfcinv(x) = NaN if x &lt; 0 or x &gt; 2
Erfcinv(NaN) = NaN
</pre> <h2 id="Erfinv">func <span>Erfinv</span>  <span title="Added in Go 1.10">1.10</span> </h2> <pre data-language="go">func Erfinv(x float64) float64</pre> <p>Erfinv returns the inverse error function of x. </p>
<p>Special cases are: </p>
<pre data-language="go">Erfinv(1) = +Inf
Erfinv(-1) = -Inf
Erfinv(x) = NaN if x &lt; -1 or x &gt; 1
Erfinv(NaN) = NaN
</pre> <h2 id="Exp">func <span>Exp</span>  </h2> <pre data-language="go">func Exp(x float64) float64</pre> <p>Exp returns e**x, the base-e exponential of x. </p>
<p>Special cases are: </p>
<pre data-language="go">Exp(+Inf) = +Inf
Exp(NaN) = NaN
</pre> <p>Very large values overflow to 0 or +Inf. Very small values underflow to 1. </p>   <h4 id="example_Exp"> <span class="text">Example</span>
</h4> <p>Code:</p> <pre class="code" data-language="go">fmt.Printf("%.2f\n", math.Exp(1))
fmt.Printf("%.2f\n", math.Exp(2))
fmt.Printf("%.2f\n", math.Exp(-1))
</pre> <p>Output:</p> <pre class="output" data-language="go">2.72
7.39
0.37
</pre>   <h2 id="Exp2">func <span>Exp2</span>  </h2> <pre data-language="go">func Exp2(x float64) float64</pre> <p>Exp2 returns 2**x, the base-2 exponential of x. </p>
<p>Special cases are the same as <a href="#Exp">Exp</a>. </p>   <h4 id="example_Exp2"> <span class="text">Example</span>
</h4> <p>Code:</p> <pre class="code" data-language="go">fmt.Printf("%.2f\n", math.Exp2(1))
fmt.Printf("%.2f\n", math.Exp2(-3))
</pre> <p>Output:</p> <pre class="output" data-language="go">2.00
0.12
</pre>   <h2 id="Expm1">func <span>Expm1</span>  </h2> <pre data-language="go">func Expm1(x float64) float64</pre> <p>Expm1 returns e**x - 1, the base-e exponential of x minus 1. It is more accurate than <a href="#Exp">Exp</a>(x) - 1 when x is near zero. </p>
<p>Special cases are: </p>
<pre data-language="go">Expm1(+Inf) = +Inf
Expm1(-Inf) = -1
Expm1(NaN) = NaN
</pre> <p>Very large values overflow to -1 or +Inf. </p>   <h4 id="example_Expm1"> <span class="text">Example</span>
</h4> <p>Code:</p> <pre class="code" data-language="go">fmt.Printf("%.6f\n", math.Expm1(0.01))
fmt.Printf("%.6f\n", math.Expm1(-1))
</pre> <p>Output:</p> <pre class="output" data-language="go">0.010050
-0.632121
</pre>   <h2 id="FMA">func <span>FMA</span>  <span title="Added in Go 1.14">1.14</span> </h2> <pre data-language="go">func FMA(x, y, z float64) float64</pre> <p>FMA returns x * y + z, computed with only one rounding. (That is, FMA returns the fused multiply-add of x, y, and z.) </p>
<h2 id="Float32bits">func <span>Float32bits</span>  </h2> <pre data-language="go">func Float32bits(f float32) uint32</pre> <p>Float32bits returns the IEEE 754 binary representation of f, with the sign bit of f and the result in the same bit position. Float32bits(Float32frombits(x)) == x. </p>
<h2 id="Float32frombits">func <span>Float32frombits</span>  </h2> <pre data-language="go">func Float32frombits(b uint32) float32</pre> <p>Float32frombits returns the floating-point number corresponding to the IEEE 754 binary representation b, with the sign bit of b and the result in the same bit position. Float32frombits(Float32bits(x)) == x. </p>
<h2 id="Float64bits">func <span>Float64bits</span>  </h2> <pre data-language="go">func Float64bits(f float64) uint64</pre> <p>Float64bits returns the IEEE 754 binary representation of f, with the sign bit of f and the result in the same bit position, and Float64bits(Float64frombits(x)) == x. </p>
<h2 id="Float64frombits">func <span>Float64frombits</span>  </h2> <pre data-language="go">func Float64frombits(b uint64) float64</pre> <p>Float64frombits returns the floating-point number corresponding to the IEEE 754 binary representation b, with the sign bit of b and the result in the same bit position. Float64frombits(Float64bits(x)) == x. </p>
<h2 id="Floor">func <span>Floor</span>  </h2> <pre data-language="go">func Floor(x float64) float64</pre> <p>Floor returns the greatest integer value less than or equal to x. </p>
<p>Special cases are: </p>
<pre data-language="go">Floor(±0) = ±0
Floor(±Inf) = ±Inf
Floor(NaN) = NaN
</pre>    <h4 id="example_Floor"> <span class="text">Example</span>
</h4> <p>Code:</p> <pre class="code" data-language="go">c := math.Floor(1.51)
fmt.Printf("%.1f", c)
</pre> <p>Output:</p> <pre class="output" data-language="go">1.0
</pre>   <h2 id="Frexp">func <span>Frexp</span>  </h2> <pre data-language="go">func Frexp(f float64) (frac float64, exp int)</pre> <p>Frexp breaks f into a normalized fraction and an integral power of two. It returns frac and exp satisfying f == frac × 2**exp, with the absolute value of frac in the interval [½, 1). </p>
<p>Special cases are: </p>
<pre data-language="go">Frexp(±0) = ±0, 0
Frexp(±Inf) = ±Inf, 0
Frexp(NaN) = NaN, 0
</pre> <h2 id="Gamma">func <span>Gamma</span>  </h2> <pre data-language="go">func Gamma(x float64) float64</pre> <p>Gamma returns the Gamma function of x. </p>
<p>Special cases are: </p>
<pre data-language="go">Gamma(+Inf) = +Inf
Gamma(+0) = +Inf
Gamma(-0) = -Inf
Gamma(x) = NaN for integer x &lt; 0
Gamma(-Inf) = NaN
Gamma(NaN) = NaN
</pre> <h2 id="Hypot">func <span>Hypot</span>  </h2> <pre data-language="go">func Hypot(p, q float64) float64</pre> <p>Hypot returns <a href="#Sqrt">Sqrt</a>(p*p + q*q), taking care to avoid unnecessary overflow and underflow. </p>
<p>Special cases are: </p>
<pre data-language="go">Hypot(±Inf, q) = +Inf
Hypot(p, ±Inf) = +Inf
Hypot(NaN, q) = NaN
Hypot(p, NaN) = NaN
</pre> <h2 id="Ilogb">func <span>Ilogb</span>  </h2> <pre data-language="go">func Ilogb(x float64) int</pre> <p>Ilogb returns the binary exponent of x as an integer. </p>
<p>Special cases are: </p>
<pre data-language="go">Ilogb(±Inf) = MaxInt32
Ilogb(0) = MinInt32
Ilogb(NaN) = MaxInt32
</pre> <h2 id="Inf">func <span>Inf</span>  </h2> <pre data-language="go">func Inf(sign int) float64</pre> <p>Inf returns positive infinity if sign &gt;= 0, negative infinity if sign &lt; 0. </p>
<h2 id="IsInf">func <span>IsInf</span>  </h2> <pre data-language="go">func IsInf(f float64, sign int) bool</pre> <p>IsInf reports whether f is an infinity, according to sign. If sign &gt; 0, IsInf reports whether f is positive infinity. If sign &lt; 0, IsInf reports whether f is negative infinity. If sign == 0, IsInf reports whether f is either infinity. </p>
<h2 id="IsNaN">func <span>IsNaN</span>  </h2> <pre data-language="go">func IsNaN(f float64) (is bool)</pre> <p>IsNaN reports whether f is an IEEE 754 “not-a-number” value. </p>
<h2 id="J0">func <span>J0</span>  </h2> <pre data-language="go">func J0(x float64) float64</pre> <p>J0 returns the order-zero Bessel function of the first kind. </p>
<p>Special cases are: </p>
<pre data-language="go">J0(±Inf) = 0
J0(0) = 1
J0(NaN) = NaN
</pre> <h2 id="J1">func <span>J1</span>  </h2> <pre data-language="go">func J1(x float64) float64</pre> <p>J1 returns the order-one Bessel function of the first kind. </p>
<p>Special cases are: </p>
<pre data-language="go">J1(±Inf) = 0
J1(NaN) = NaN
</pre> <h2 id="Jn">func <span>Jn</span>  </h2> <pre data-language="go">func Jn(n int, x float64) float64</pre> <p>Jn returns the order-n Bessel function of the first kind. </p>
<p>Special cases are: </p>
<pre data-language="go">Jn(n, ±Inf) = 0
Jn(n, NaN) = NaN
</pre> <h2 id="Ldexp">func <span>Ldexp</span>  </h2> <pre data-language="go">func Ldexp(frac float64, exp int) float64</pre> <p>Ldexp is the inverse of <a href="#Frexp">Frexp</a>. It returns frac × 2**exp. </p>
<p>Special cases are: </p>
<pre data-language="go">Ldexp(±0, exp) = ±0
Ldexp(±Inf, exp) = ±Inf
Ldexp(NaN, exp) = NaN
</pre> <h2 id="Lgamma">func <span>Lgamma</span>  </h2> <pre data-language="go">func Lgamma(x float64) (lgamma float64, sign int)</pre> <p>Lgamma returns the natural logarithm and sign (-1 or +1) of <a href="#Gamma">Gamma</a>(x). </p>
<p>Special cases are: </p>
<pre data-language="go">Lgamma(+Inf) = +Inf
Lgamma(0) = +Inf
Lgamma(-integer) = +Inf
Lgamma(-Inf) = -Inf
Lgamma(NaN) = NaN
</pre> <h2 id="Log">func <span>Log</span>  </h2> <pre data-language="go">func Log(x float64) float64</pre> <p>Log returns the natural logarithm of x. </p>
<p>Special cases are: </p>
<pre data-language="go">Log(+Inf) = +Inf
Log(0) = -Inf
Log(x &lt; 0) = NaN
Log(NaN) = NaN
</pre>    <h4 id="example_Log"> <span class="text">Example</span>
</h4> <p>Code:</p> <pre class="code" data-language="go">x := math.Log(1)
fmt.Printf("%.1f\n", x)

y := math.Log(2.7183)
fmt.Printf("%.1f\n", y)
</pre> <p>Output:</p> <pre class="output" data-language="go">0.0
1.0
</pre>   <h2 id="Log10">func <span>Log10</span>  </h2> <pre data-language="go">func Log10(x float64) float64</pre> <p>Log10 returns the decimal logarithm of x. The special cases are the same as for <a href="#Log">Log</a>. </p>   <h4 id="example_Log10"> <span class="text">Example</span>
</h4> <p>Code:</p> <pre class="code" data-language="go">fmt.Printf("%.1f", math.Log10(100))
</pre> <p>Output:</p> <pre class="output" data-language="go">2.0
</pre>   <h2 id="Log1p">func <span>Log1p</span>  </h2> <pre data-language="go">func Log1p(x float64) float64</pre> <p>Log1p returns the natural logarithm of 1 plus its argument x. It is more accurate than <a href="#Log">Log</a>(1 + x) when x is near zero. </p>
<p>Special cases are: </p>
<pre data-language="go">Log1p(+Inf) = +Inf
Log1p(±0) = ±0
Log1p(-1) = -Inf
Log1p(x &lt; -1) = NaN
Log1p(NaN) = NaN
</pre> <h2 id="Log2">func <span>Log2</span>  </h2> <pre data-language="go">func Log2(x float64) float64</pre> <p>Log2 returns the binary logarithm of x. The special cases are the same as for <a href="#Log">Log</a>. </p>   <h4 id="example_Log2"> <span class="text">Example</span>
</h4> <p>Code:</p> <pre class="code" data-language="go">fmt.Printf("%.1f", math.Log2(256))
</pre> <p>Output:</p> <pre class="output" data-language="go">8.0
</pre>   <h2 id="Logb">func <span>Logb</span>  </h2> <pre data-language="go">func Logb(x float64) float64</pre> <p>Logb returns the binary exponent of x. </p>
<p>Special cases are: </p>
<pre data-language="go">Logb(±Inf) = +Inf
Logb(0) = -Inf
Logb(NaN) = NaN
</pre> <h2 id="Max">func <span>Max</span>  </h2> <pre data-language="go">func Max(x, y float64) float64</pre> <p>Max returns the larger of x or y. </p>
<p>Special cases are: </p>
<pre data-language="go">Max(x, +Inf) = Max(+Inf, x) = +Inf
Max(x, NaN) = Max(NaN, x) = NaN
Max(+0, ±0) = Max(±0, +0) = +0
Max(-0, -0) = -0
</pre> <p>Note that this differs from the built-in function max when called with NaN and +Inf. </p>
<h2 id="Min">func <span>Min</span>  </h2> <pre data-language="go">func Min(x, y float64) float64</pre> <p>Min returns the smaller of x or y. </p>
<p>Special cases are: </p>
<pre data-language="go">Min(x, -Inf) = Min(-Inf, x) = -Inf
Min(x, NaN) = Min(NaN, x) = NaN
Min(-0, ±0) = Min(±0, -0) = -0
</pre> <p>Note that this differs from the built-in function min when called with NaN and -Inf. </p>
<h2 id="Mod">func <span>Mod</span>  </h2> <pre data-language="go">func Mod(x, y float64) float64</pre> <p>Mod returns the floating-point remainder of x/y. The magnitude of the result is less than y and its sign agrees with that of x. </p>
<p>Special cases are: </p>
<pre data-language="go">Mod(±Inf, y) = NaN
Mod(NaN, y) = NaN
Mod(x, 0) = NaN
Mod(x, ±Inf) = x
Mod(x, NaN) = NaN
</pre>    <h4 id="example_Mod"> <span class="text">Example</span>
</h4> <p>Code:</p> <pre class="code" data-language="go">c := math.Mod(7, 4)
fmt.Printf("%.1f", c)
</pre> <p>Output:</p> <pre class="output" data-language="go">3.0
</pre>   <h2 id="Modf">func <span>Modf</span>  </h2> <pre data-language="go">func Modf(f float64) (int float64, frac float64)</pre> <p>Modf returns integer and fractional floating-point numbers that sum to f. Both values have the same sign as f. </p>
<p>Special cases are: </p>
<pre data-language="go">Modf(±Inf) = ±Inf, NaN
Modf(NaN) = NaN, NaN
</pre>    <h4 id="example_Modf"> <span class="text">Example</span>
</h4> <p>Code:</p> <pre class="code" data-language="go">int, frac := math.Modf(3.14)
fmt.Printf("%.2f, %.2f\n", int, frac)

int, frac = math.Modf(-2.71)
fmt.Printf("%.2f, %.2f\n", int, frac)
</pre> <p>Output:</p> <pre class="output" data-language="go">3.00, 0.14
-2.00, -0.71
</pre>   <h2 id="NaN">func <span>NaN</span>  </h2> <pre data-language="go">func NaN() float64</pre> <p>NaN returns an IEEE 754 “not-a-number” value. </p>
<h2 id="Nextafter">func <span>Nextafter</span>  </h2> <pre data-language="go">func Nextafter(x, y float64) (r float64)</pre> <p>Nextafter returns the next representable float64 value after x towards y. </p>
<p>Special cases are: </p>
<pre data-language="go">Nextafter(x, x)   = x
Nextafter(NaN, y) = NaN
Nextafter(x, NaN) = NaN
</pre> <h2 id="Nextafter32">func <span>Nextafter32</span>  <span title="Added in Go 1.4">1.4</span> </h2> <pre data-language="go">func Nextafter32(x, y float32) (r float32)</pre> <p>Nextafter32 returns the next representable float32 value after x towards y. </p>
<p>Special cases are: </p>
<pre data-language="go">Nextafter32(x, x)   = x
Nextafter32(NaN, y) = NaN
Nextafter32(x, NaN) = NaN
</pre> <h2 id="Pow">func <span>Pow</span>  </h2> <pre data-language="go">func Pow(x, y float64) float64</pre> <p>Pow returns x**y, the base-x exponential of y. </p>
<p>Special cases are (in order): </p>
<pre data-language="go">Pow(x, ±0) = 1 for any x
Pow(1, y) = 1 for any y
Pow(x, 1) = x for any x
Pow(NaN, y) = NaN
Pow(x, NaN) = NaN
Pow(±0, y) = ±Inf for y an odd integer &lt; 0
Pow(±0, -Inf) = +Inf
Pow(±0, +Inf) = +0
Pow(±0, y) = +Inf for finite y &lt; 0 and not an odd integer
Pow(±0, y) = ±0 for y an odd integer &gt; 0
Pow(±0, y) = +0 for finite y &gt; 0 and not an odd integer
Pow(-1, ±Inf) = 1
Pow(x, +Inf) = +Inf for |x| &gt; 1
Pow(x, -Inf) = +0 for |x| &gt; 1
Pow(x, +Inf) = +0 for |x| &lt; 1
Pow(x, -Inf) = +Inf for |x| &lt; 1
Pow(+Inf, y) = +Inf for y &gt; 0
Pow(+Inf, y) = +0 for y &lt; 0
Pow(-Inf, y) = Pow(-0, -y)
Pow(x, y) = NaN for finite x &lt; 0 and finite non-integer y
</pre>    <h4 id="example_Pow"> <span class="text">Example</span>
</h4> <p>Code:</p> <pre class="code" data-language="go">c := math.Pow(2, 3)
fmt.Printf("%.1f", c)
</pre> <p>Output:</p> <pre class="output" data-language="go">8.0
</pre>   <h2 id="Pow10">func <span>Pow10</span>  </h2> <pre data-language="go">func Pow10(n int) float64</pre> <p>Pow10 returns 10**n, the base-10 exponential of n. </p>
<p>Special cases are: </p>
<pre data-language="go">Pow10(n) =    0 for n &lt; -323
Pow10(n) = +Inf for n &gt; 308
</pre>    <h4 id="example_Pow10"> <span class="text">Example</span>
</h4> <p>Code:</p> <pre class="code" data-language="go">c := math.Pow10(2)
fmt.Printf("%.1f", c)
</pre> <p>Output:</p> <pre class="output" data-language="go">100.0
</pre>   <h2 id="Remainder">func <span>Remainder</span>  </h2> <pre data-language="go">func Remainder(x, y float64) float64</pre> <p>Remainder returns the IEEE 754 floating-point remainder of x/y. </p>
<p>Special cases are: </p>
<pre data-language="go">Remainder(±Inf, y) = NaN
Remainder(NaN, y) = NaN
Remainder(x, 0) = NaN
Remainder(x, ±Inf) = x
Remainder(x, NaN) = NaN
</pre>    <h4 id="example_Remainder"> <span class="text">Example</span>
</h4> <p>Code:</p> <pre class="code" data-language="go">fmt.Printf("%.1f", math.Remainder(100, 30))
</pre> <p>Output:</p> <pre class="output" data-language="go">10.0
</pre>   <h2 id="Round">func <span>Round</span>  <span title="Added in Go 1.10">1.10</span> </h2> <pre data-language="go">func Round(x float64) float64</pre> <p>Round returns the nearest integer, rounding half away from zero. </p>
<p>Special cases are: </p>
<pre data-language="go">Round(±0) = ±0
Round(±Inf) = ±Inf
Round(NaN) = NaN
</pre>    <h4 id="example_Round"> <span class="text">Example</span>
</h4> <p>Code:</p> <pre class="code" data-language="go">p := math.Round(10.5)
fmt.Printf("%.1f\n", p)

n := math.Round(-10.5)
fmt.Printf("%.1f\n", n)
</pre> <p>Output:</p> <pre class="output" data-language="go">11.0
-11.0
</pre>   <h2 id="RoundToEven">func <span>RoundToEven</span>  <span title="Added in Go 1.10">1.10</span> </h2> <pre data-language="go">func RoundToEven(x float64) float64</pre> <p>RoundToEven returns the nearest integer, rounding ties to even. </p>
<p>Special cases are: </p>
<pre data-language="go">RoundToEven(±0) = ±0
RoundToEven(±Inf) = ±Inf
RoundToEven(NaN) = NaN
</pre>    <h4 id="example_RoundToEven"> <span class="text">Example</span>
</h4> <p>Code:</p> <pre class="code" data-language="go">u := math.RoundToEven(11.5)
fmt.Printf("%.1f\n", u)

d := math.RoundToEven(12.5)
fmt.Printf("%.1f\n", d)
</pre> <p>Output:</p> <pre class="output" data-language="go">12.0
12.0
</pre>   <h2 id="Signbit">func <span>Signbit</span>  </h2> <pre data-language="go">func Signbit(x float64) bool</pre> <p>Signbit reports whether x is negative or negative zero. </p>
<h2 id="Sin">func <span>Sin</span>  </h2> <pre data-language="go">func Sin(x float64) float64</pre> <p>Sin returns the sine of the radian argument x. </p>
<p>Special cases are: </p>
<pre data-language="go">Sin(±0) = ±0
Sin(±Inf) = NaN
Sin(NaN) = NaN
</pre>    <h4 id="example_Sin"> <span class="text">Example</span>
</h4> <p>Code:</p> <pre class="code" data-language="go">fmt.Printf("%.2f", math.Sin(math.Pi))
</pre> <p>Output:</p> <pre class="output" data-language="go">0.00
</pre>   <h2 id="Sincos">func <span>Sincos</span>  </h2> <pre data-language="go">func Sincos(x float64) (sin, cos float64)</pre> <p>Sincos returns Sin(x), Cos(x). </p>
<p>Special cases are: </p>
<pre data-language="go">Sincos(±0) = ±0, 1
Sincos(±Inf) = NaN, NaN
Sincos(NaN) = NaN, NaN
</pre>    <h4 id="example_Sincos"> <span class="text">Example</span>
</h4> <p>Code:</p> <pre class="code" data-language="go">sin, cos := math.Sincos(0)
fmt.Printf("%.2f, %.2f", sin, cos)
</pre> <p>Output:</p> <pre class="output" data-language="go">0.00, 1.00
</pre>   <h2 id="Sinh">func <span>Sinh</span>  </h2> <pre data-language="go">func Sinh(x float64) float64</pre> <p>Sinh returns the hyperbolic sine of x. </p>
<p>Special cases are: </p>
<pre data-language="go">Sinh(±0) = ±0
Sinh(±Inf) = ±Inf
Sinh(NaN) = NaN
</pre>    <h4 id="example_Sinh"> <span class="text">Example</span>
</h4> <p>Code:</p> <pre class="code" data-language="go">fmt.Printf("%.2f", math.Sinh(0))
</pre> <p>Output:</p> <pre class="output" data-language="go">0.00
</pre>   <h2 id="Sqrt">func <span>Sqrt</span>  </h2> <pre data-language="go">func Sqrt(x float64) float64</pre> <p>Sqrt returns the square root of x. </p>
<p>Special cases are: </p>
<pre data-language="go">Sqrt(+Inf) = +Inf
Sqrt(±0) = ±0
Sqrt(x &lt; 0) = NaN
Sqrt(NaN) = NaN
</pre>    <h4 id="example_Sqrt"> <span class="text">Example</span>
</h4> <p>Code:</p> <pre class="code" data-language="go">const (
    a = 3
    b = 4
)
c := math.Sqrt(a*a + b*b)
fmt.Printf("%.1f", c)
</pre> <p>Output:</p> <pre class="output" data-language="go">5.0
</pre>   <h2 id="Tan">func <span>Tan</span>  </h2> <pre data-language="go">func Tan(x float64) float64</pre> <p>Tan returns the tangent of the radian argument x. </p>
<p>Special cases are: </p>
<pre data-language="go">Tan(±0) = ±0
Tan(±Inf) = NaN
Tan(NaN) = NaN
</pre>    <h4 id="example_Tan"> <span class="text">Example</span>
</h4> <p>Code:</p> <pre class="code" data-language="go">fmt.Printf("%.2f", math.Tan(0))
</pre> <p>Output:</p> <pre class="output" data-language="go">0.00
</pre>   <h2 id="Tanh">func <span>Tanh</span>  </h2> <pre data-language="go">func Tanh(x float64) float64</pre> <p>Tanh returns the hyperbolic tangent of x. </p>
<p>Special cases are: </p>
<pre data-language="go">Tanh(±0) = ±0
Tanh(±Inf) = ±1
Tanh(NaN) = NaN
</pre>    <h4 id="example_Tanh"> <span class="text">Example</span>
</h4> <p>Code:</p> <pre class="code" data-language="go">fmt.Printf("%.2f", math.Tanh(0))
</pre> <p>Output:</p> <pre class="output" data-language="go">0.00
</pre>   <h2 id="Trunc">func <span>Trunc</span>  </h2> <pre data-language="go">func Trunc(x float64) float64</pre> <p>Trunc returns the integer value of x. </p>
<p>Special cases are: </p>
<pre data-language="go">Trunc(±0) = ±0
Trunc(±Inf) = ±Inf
Trunc(NaN) = NaN
</pre>    <h4 id="example_Trunc"> <span class="text">Example</span>
</h4> <p>Code:</p> <pre class="code" data-language="go">fmt.Printf("%.2f\n", math.Trunc(math.Pi))
fmt.Printf("%.2f\n", math.Trunc(-1.2345))
</pre> <p>Output:</p> <pre class="output" data-language="go">3.00
-1.00
</pre>   <h2 id="Y0">func <span>Y0</span>  </h2> <pre data-language="go">func Y0(x float64) float64</pre> <p>Y0 returns the order-zero Bessel function of the second kind. </p>
<p>Special cases are: </p>
<pre data-language="go">Y0(+Inf) = 0
Y0(0) = -Inf
Y0(x &lt; 0) = NaN
Y0(NaN) = NaN
</pre> <h2 id="Y1">func <span>Y1</span>  </h2> <pre data-language="go">func Y1(x float64) float64</pre> <p>Y1 returns the order-one Bessel function of the second kind. </p>
<p>Special cases are: </p>
<pre data-language="go">Y1(+Inf) = 0
Y1(0) = -Inf
Y1(x &lt; 0) = NaN
Y1(NaN) = NaN
</pre> <h2 id="Yn">func <span>Yn</span>  </h2> <pre data-language="go">func Yn(n int, x float64) float64</pre> <p>Yn returns the order-n Bessel function of the second kind. </p>
<p>Special cases are: </p>
<pre data-language="go">Yn(n, +Inf) = 0
Yn(n ≥ 0, 0) = -Inf
Yn(n &lt; 0, 0) = +Inf if n is odd, -Inf if n is even
Yn(n, x &lt; 0) = NaN
Yn(n, NaN) = NaN
</pre> <h2 id="pkg-subdirectories">Subdirectories</h2> <div class="pkg-dir"> <table> <tr> <th class="pkg-name">Name</th> <th class="pkg-synopsis">Synopsis</th> </tr> <tr> <td colspan="2"><a href="../index">..</a></td> </tr> <tr> <td class="pkg-name"> <a href="big/index">big</a> </td> <td class="pkg-synopsis"> Package big implements arbitrary-precision arithmetic (big numbers). </td> </tr> <tr> <td class="pkg-name"> <a href="bits/index">bits</a> </td> <td class="pkg-synopsis"> Package bits implements bit counting and manipulation functions for the predeclared unsigned integer types. </td> </tr> <tr> <td class="pkg-name"> <a href="cmplx/index">cmplx</a> </td> <td class="pkg-synopsis"> Package cmplx provides basic constants and mathematical functions for complex numbers. </td> </tr> <tr> <td class="pkg-name"> <a href="rand/index">rand</a> </td> <td class="pkg-synopsis"> Package rand implements pseudo-random number generators suitable for tasks such as simulation, but it should not be used for security-sensitive work. </td> </tr> <tr> <td class="pkg-name"> <a href="rand/v2/index">v2</a> </td> <td class="pkg-synopsis"> Package rand implements pseudo-random number generators suitable for tasks such as simulation, but it should not be used for security-sensitive work. </td> </tr> </table> </div><div class="_attribution">
  <p class="_attribution-p">
    &copy; Google, Inc.<br>Licensed under the Creative Commons Attribution License 3.0.<br>
    <a href="http://golang.org/pkg/math/" class="_attribution-link">http://golang.org/pkg/math/</a>
  </p>
</div>