From Jason Turner

[c.math]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpbs9l08t_/{from.md → to.md} +174 -443
tmp/tmpbs9l08t_/{from.md → to.md} RENAMED
@@ -211,11 +211,11 @@ namespace std {
211
  float fabsf(float x);
212
  long double fabsl(long double x);
213
 
214
  float hypot(float x, float y); // see [library.c]
215
  double hypot(double x, double y);
216
- long double hypot(double x, double y); // see [library.c]
217
  float hypotf(float x, float y);
218
  long double hypotl(long double x, long double y);
219
 
220
  // [c.math.hypot3], three-dimensional hypotenuse
221
  float hypot(float x, float y, float z);
@@ -380,123 +380,128 @@ namespace std {
380
  double fma(double x, double y, double z);
381
  long double fma(long double x, long double y, long double z); // see [library.c]
382
  float fmaf(float x, float y, float z);
383
  long double fmal(long double x, long double y, long double z);
384
 
 
 
 
 
 
385
  // [c.math.fpclass], classification / comparison functions
386
  int fpclassify(float x);
387
  int fpclassify(double x);
388
  int fpclassify(long double x);
389
 
390
- int isfinite(float x);
391
- int isfinite(double x);
392
- int isfinite(long double x);
393
 
394
- int isinf(float x);
395
- int isinf(double x);
396
- int isinf(long double x);
397
 
398
- int isnan(float x);
399
- int isnan(double x);
400
- int isnan(long double x);
401
 
402
- int isnormal(float x);
403
- int isnormal(double x);
404
- int isnormal(long double x);
405
 
406
- int signbit(float x);
407
- int signbit(double x);
408
- int signbit(long double x);
409
 
410
- int isgreater(float x, float y);
411
- int isgreater(double x, double y);
412
- int isgreater(long double x, long double y);
413
 
414
- int isgreaterequal(float x, float y);
415
- int isgreaterequal(double x, double y);
416
- int isgreaterequal(long double x, long double y);
417
 
418
- int isless(float x, float y);
419
- int isless(double x, double y);
420
- int isless(long double x, long double y);
421
 
422
- int islessequal(float x, float y);
423
- int islessequal(double x, double y);
424
- int islessequal(long double x, long double y);
425
 
426
- int islessgreater(float x, float y);
427
- int islessgreater(double x, double y);
428
- int islessgreater(long double x, long double y);
429
 
430
- int isunordered(float x, float y);
431
- int isunordered(double x, double y);
432
- int isunordered(long double x, long double y);
433
 
434
  // [sf.cmath], mathematical special functions
435
 
436
- // [sf.cmath.assoc_laguerre], associated Laguerre polynomials
437
  double assoc_laguerre(unsigned n, unsigned m, double x);
438
  float assoc_laguerref(unsigned n, unsigned m, float x);
439
  long double assoc_laguerrel(unsigned n, unsigned m, long double x);
440
 
441
- // [sf.cmath.assoc_legendre], associated Legendre functions
442
  double assoc_legendre(unsigned l, unsigned m, double x);
443
  float assoc_legendref(unsigned l, unsigned m, float x);
444
  long double assoc_legendrel(unsigned l, unsigned m, long double x);
445
 
446
  // [sf.cmath.beta], beta function
447
  double beta(double x, double y);
448
  float betaf(float x, float y);
449
  long double betal(long double x, long double y);
450
 
451
- // [sf.cmath.comp_ellint_1], complete elliptic integral of the first kind
452
  double comp_ellint_1(double k);
453
  float comp_ellint_1f(float k);
454
  long double comp_ellint_1l(long double k);
455
 
456
- // [sf.cmath.comp_ellint_2], complete elliptic integral of the second kind
457
  double comp_ellint_2(double k);
458
  float comp_ellint_2f(float k);
459
  long double comp_ellint_2l(long double k);
460
 
461
- // [sf.cmath.comp_ellint_3], complete elliptic integral of the third kind
462
  double comp_ellint_3(double k, double nu);
463
  float comp_ellint_3f(float k, float nu);
464
  long double comp_ellint_3l(long double k, long double nu);
465
 
466
- // [sf.cmath.cyl_bessel_i], regular modified cylindrical Bessel functions
467
  double cyl_bessel_i(double nu, double x);
468
  float cyl_bessel_if(float nu, float x);
469
  long double cyl_bessel_il(long double nu, long double x);
470
 
471
- // [sf.cmath.cyl_bessel_j], cylindrical Bessel functions of the first kind
472
  double cyl_bessel_j(double nu, double x);
473
  float cyl_bessel_jf(float nu, float x);
474
  long double cyl_bessel_jl(long double nu, long double x);
475
 
476
- // [sf.cmath.cyl_bessel_k], irregular modified cylindrical Bessel functions
477
  double cyl_bessel_k(double nu, double x);
478
  float cyl_bessel_kf(float nu, float x);
479
  long double cyl_bessel_kl(long double nu, long double x);
480
 
481
- // [sf.cmath.cyl_neumann], cylindrical Neumann functions;
482
  // cylindrical Bessel functions of the second kind
483
  double cyl_neumann(double nu, double x);
484
  float cyl_neumannf(float nu, float x);
485
  long double cyl_neumannl(long double nu, long double x);
486
 
487
- // [sf.cmath.ellint_1], incomplete elliptic integral of the first kind
488
  double ellint_1(double k, double phi);
489
  float ellint_1f(float k, float phi);
490
  long double ellint_1l(long double k, long double phi);
491
 
492
- // [sf.cmath.ellint_2], incomplete elliptic integral of the second kind
493
  double ellint_2(double k, double phi);
494
  float ellint_2f(float k, float phi);
495
  long double ellint_2l(long double k, long double phi);
496
 
497
- // [sf.cmath.ellint_3], incomplete elliptic integral of the third kind
498
  double ellint_3(double k, double nu, double phi);
499
  float ellint_3f(float k, float nu, float phi);
500
  long double ellint_3l(long double k, long double nu, long double phi);
501
 
502
  // [sf.cmath.expint], exponential integral
@@ -517,27 +522,27 @@ namespace std {
517
  // [sf.cmath.legendre], Legendre polynomials
518
  double legendre(unsigned l, double x);
519
  float legendref(unsigned l, float x);
520
  long double legendrel(unsigned l, long double x);
521
 
522
- // [sf.cmath.riemann_zeta], Riemann zeta function
523
  double riemann_zeta(double x);
524
  float riemann_zetaf(float x);
525
  long double riemann_zetal(long double x);
526
 
527
- // [sf.cmath.sph_bessel], spherical Bessel functions of the first kind
528
  double sph_bessel(unsigned n, double x);
529
  float sph_besself(unsigned n, float x);
530
  long double sph_bessell(unsigned n, long double x);
531
 
532
- // [sf.cmath.sph_legendre], spherical associated Legendre functions
533
  double sph_legendre(unsigned l, unsigned m, double theta);
534
  float sph_legendref(unsigned l, unsigned m, float theta);
535
  long double sph_legendrel(unsigned l, unsigned m, long double theta);
536
 
537
- // [sf.cmath.sph_neumann], spherical Neumann functions;
538
- // spherical Bessel functions of the second kind:
539
  double sph_neumann(unsigned n, double x);
540
  float sph_neumannf(unsigned n, float x);
541
  long double sph_neumannl(unsigned n, long double x);
542
  }
543
  ```
@@ -546,38 +551,37 @@ The contents and meaning of the header `<cmath>` are the same as the C
546
  standard library header `<math.h>`, with the addition of a
547
  three-dimensional hypotenuse function ([[c.math.hypot3]]) and the
548
  mathematical special functions described in [[sf.cmath]].
549
 
550
  [*Note 1*: Several functions have additional overloads in this
551
- International Standard, but they have the same behavior as in the C
552
- standard library ([[library.c]]). — *end note*]
553
 
554
  For each set of overloaded functions within `<cmath>`, with the
555
  exception of `abs`, there shall be additional overloads sufficient to
556
  ensure:
557
 
558
- 1. If any argument of arithmetic type corresponding to a `double`
559
  parameter has type `long double`, then all arguments of arithmetic
560
- type ([[basic.fundamental]]) corresponding to `double` parameters
561
- are effectively cast to `long double`.
562
- 2. Otherwise, if any argument of arithmetic type corresponding to a
563
  `double` parameter has type `double` or an integer type, then all
564
- arguments of arithmetic type corresponding to `double` parameters
565
- are effectively cast to `double`.
566
- 3. Otherwise, all arguments of arithmetic type corresponding to
567
- `double` parameters have type `float`.
568
 
569
- [*Note 2*: `abs` is exempted from these rules in order to stay
570
  compatible with C. — *end note*]
571
 
572
  ISO C 7.12
573
 
574
  ### Absolute values <a id="c.math.abs">[[c.math.abs]]</a>
575
 
576
- [*Note 1*: The headers `<cstdlib>` ([[cstdlib.syn]]) and `<cmath>` (
577
- [[cmath.syn]]) declare the functions described in this
578
- subclause. — *end note*]
579
 
580
  ``` cpp
581
  int abs(int j);
582
  long int abs(long int j);
583
  long long int abs(long long int j);
@@ -590,16 +594,16 @@ long double abs(long double j);
590
  standard library for the functions `abs`, `labs`, `llabs`, `fabsf`,
591
  `fabs`, and `fabsl`.
592
 
593
  *Remarks:* If `abs()` is called with an argument of type `X` for which
594
  `is_unsigned_v<X>` is `true` and if `X` cannot be converted to `int` by
595
- integral promotion ([[conv.prom]]), the program is ill-formed.
596
 
597
  [*Note 1*: Arguments that can be promoted to `int` are permitted for
598
  compatibility with C. — *end note*]
599
 
600
- ISO C 7.12.7.2, 7.22.6.1
601
 
602
  ### Three-dimensional hypotenuse <a id="c.math.hypot3">[[c.math.hypot3]]</a>
603
 
604
  ``` cpp
605
  float hypot(float x, float y, float z);
@@ -607,10 +611,34 @@ double hypot(double x, double y, double z);
607
  long double hypot(long double x, long double y, long double z);
608
  ```
609
 
610
  *Returns:* $\sqrt{x^2+y^2+z^2}$.
611
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
612
  ### Classification / comparison functions <a id="c.math.fpclass">[[c.math.fpclass]]</a>
613
 
614
  The classification / comparison functions behave the same as the C
615
  macros with the corresponding names defined in the C standard library.
616
  Each function is overloaded for the three floating-point types.
@@ -627,54 +655,48 @@ a domain error for just those argument values for which:
627
  - the function description’s *Returns:* clause explicitly specifies a
628
  domain and those argument values fall outside the specified domain, or
629
  - the corresponding mathematical function value has a nonzero imaginary
630
  component, or
631
  - the corresponding mathematical function is not mathematically
632
- defined.[^18]
633
 
634
  Unless otherwise specified, each function is defined for all finite
635
  values, for negative infinity, and for positive infinity.
636
 
637
- #### Associated Laguerre polynomials <a id="sf.cmath.assoc_laguerre">[[sf.cmath.assoc_laguerre]]</a>
638
 
639
  ``` cpp
640
  double assoc_laguerre(unsigned n, unsigned m, double x);
641
  float assoc_laguerref(unsigned n, unsigned m, float x);
642
  long double assoc_laguerrel(unsigned n, unsigned m, long double x);
643
  ```
644
 
645
  *Effects:* These functions compute the associated Laguerre polynomials
646
  of their respective arguments `n`, `m`, and `x`.
647
 
648
- *Returns:* $$%
649
- \mathsf{L}_n^m(x) =
650
- (-1)^m \frac{\mathsf{d} ^ m}
651
- {\mathsf{d}x ^ m} \, \mathsf{L}_{n+m}(x),
652
- \quad \mbox{for $x \ge 0$}$$ where n is `n`, m is `m`, and x is
653
  `x`.
654
 
655
  *Remarks:* The effect of calling each of these functions is
656
  *implementation-defined* if `n >= 128` or if `m >= 128`.
657
 
658
- #### Associated Legendre functions <a id="sf.cmath.assoc_legendre">[[sf.cmath.assoc_legendre]]</a>
659
 
660
  ``` cpp
661
  double assoc_legendre(unsigned l, unsigned m, double x);
662
  float assoc_legendref(unsigned l, unsigned m, float x);
663
  long double assoc_legendrel(unsigned l, unsigned m, long double x);
664
  ```
665
 
666
  *Effects:* These functions compute the associated Legendre functions of
667
  their respective arguments `l`, `m`, and `x`.
668
 
669
- *Returns:* $$%
670
- \mathsf{P}_\ell^m(x) =
671
- (1 - x^2) ^ {m/2}
672
- \:
673
- \frac{ \mathsf{d} ^ m}
674
- { \mathsf{d}x ^ m} \, \mathsf{P}_\ell(x),
675
- \quad \mbox{for $|x| \le 1$}$$ where l is `l`, m is `m`, and x is
676
  `x`.
677
 
678
  *Remarks:* The effect of calling each of these functions is
679
  *implementation-defined* if `l >= 128`.
680
 
@@ -687,115 +709,105 @@ long double betal(long double x, long double y);
687
  ```
688
 
689
  *Effects:* These functions compute the beta function of their respective
690
  arguments `x` and `y`.
691
 
692
- *Returns:* $$%
693
- \mathsf{B}(x, y) =
694
- \frac{ \Gamma(x) \, \Gamma(y) }
695
- { \Gamma(x+y) },
696
- \quad \mbox{for $x > 0$,\, $y > 0$}$$ where x is `x` and y is
697
- `y`.
698
 
699
- #### Complete elliptic integral of the first kind <a id="sf.cmath.comp_ellint_1">[[sf.cmath.comp_ellint_1]]</a>
700
 
701
  ``` cpp
702
  double comp_ellint_1(double k);
703
  float comp_ellint_1f(float k);
704
  long double comp_ellint_1l(long double k);
705
  ```
706
 
707
  *Effects:* These functions compute the complete elliptic integral of the
708
  first kind of their respective arguments `k`.
709
 
710
- *Returns:* $$%
711
- \mathsf{K}(k) =
712
- \mathsf{F}(k, \pi / 2),
713
- \quad \mbox{for $|k| \le 1$}$$ where k is `k`.
714
 
715
- See also [[sf.cmath.ellint_1]].
716
 
717
- #### Complete elliptic integral of the second kind <a id="sf.cmath.comp_ellint_2">[[sf.cmath.comp_ellint_2]]</a>
718
 
719
  ``` cpp
720
  double comp_ellint_2(double k);
721
  float comp_ellint_2f(float k);
722
  long double comp_ellint_2l(long double k);
723
  ```
724
 
725
  *Effects:* These functions compute the complete elliptic integral of the
726
  second kind of their respective arguments `k`.
727
 
728
- *Returns:* $$%
729
- \mathsf{E}(k) =
730
- \mathsf{E}(k, \pi / 2),
731
- \quad \mbox{for $|k| \le 1$}$$ where k is `k`.
732
 
733
- See also [[sf.cmath.ellint_2]].
734
 
735
- #### Complete elliptic integral of the third kind <a id="sf.cmath.comp_ellint_3">[[sf.cmath.comp_ellint_3]]</a>
736
 
737
  ``` cpp
738
  double comp_ellint_3(double k, double nu);
739
  float comp_ellint_3f(float k, float nu);
740
  long double comp_ellint_3l(long double k, long double nu);
741
  ```
742
 
743
  *Effects:* These functions compute the complete elliptic integral of the
744
  third kind of their respective arguments `k` and `nu`.
745
 
746
- *Returns:* $$%
747
- \mathsf{\Pi}(\nu, k) = \mathsf{\Pi}(\nu, k, \pi / 2),
748
- \quad \mbox{for $|k| \le 1$}$$ where k is `k` and $\nu$ is `nu`.
749
 
750
- See also [[sf.cmath.ellint_3]].
751
 
752
- #### Regular modified cylindrical Bessel functions <a id="sf.cmath.cyl_bessel_i">[[sf.cmath.cyl_bessel_i]]</a>
753
 
754
  ``` cpp
755
  double cyl_bessel_i(double nu, double x);
756
  float cyl_bessel_if(float nu, float x);
757
  long double cyl_bessel_il(long double nu, long double x);
758
  ```
759
 
760
  *Effects:* These functions compute the regular modified cylindrical
761
  Bessel functions of their respective arguments `nu` and `x`.
762
 
763
- *Returns:* $$%
764
- \mathsf{I}_\nu(x) =
765
- i^{-\nu} \mathsf{J}_\nu(ix)
766
- =
767
- \sum_{k=0}^\infty \frac{(x/2)^{\nu+2k}}
768
- {k! \: \Gamma(\nu+k+1)},
769
- \quad \mbox{for $x \ge 0$}$$ where $\nu$ is `nu` and x is `x`.
770
 
771
  *Remarks:* The effect of calling each of these functions is
772
  *implementation-defined* if `nu >= 128`.
773
 
774
- See also [[sf.cmath.cyl_bessel_j]].
775
 
776
- #### Cylindrical Bessel functions of the first kind <a id="sf.cmath.cyl_bessel_j">[[sf.cmath.cyl_bessel_j]]</a>
777
 
778
  ``` cpp
779
  double cyl_bessel_j(double nu, double x);
780
  float cyl_bessel_jf(float nu, float x);
781
  long double cyl_bessel_jl(long double nu, long double x);
782
  ```
783
 
784
  *Effects:* These functions compute the cylindrical Bessel functions of
785
  the first kind of their respective arguments `nu` and `x`.
786
 
787
- *Returns:* $$%
788
- \mathsf{J}_\nu(x) =
789
- \sum_{k=0}^\infty \frac{(-1)^k (x/2)^{\nu+2k}}
790
- {k! \: \Gamma(\nu+k+1)},
791
- \quad \mbox{for $x \ge 0$}$$ where $\nu$ is `nu` and x is `x`.
792
 
793
  *Remarks:* The effect of calling each of these functions is
794
  *implementation-defined* if `nu >= 128`.
795
 
796
- #### Irregular modified cylindrical Bessel functions <a id="sf.cmath.cyl_bessel_k">[[sf.cmath.cyl_bessel_k]]</a>
797
 
798
  ``` cpp
799
  double cyl_bessel_k(double nu, double x);
800
  float cyl_bessel_kf(float nu, float x);
801
  long double cyl_bessel_kl(long double nu, long double x);
@@ -828,14 +840,14 @@ Bessel functions of their respective arguments `nu` and `x`.
828
  \right.$$ where $\nu$ is `nu` and x is `x`.
829
 
830
  *Remarks:* The effect of calling each of these functions is
831
  *implementation-defined* if `nu >= 128`.
832
 
833
- See also [[sf.cmath.cyl_bessel_i]], [[sf.cmath.cyl_bessel_j]],
834
- [[sf.cmath.cyl_neumann]].
835
 
836
- #### Cylindrical Neumann functions <a id="sf.cmath.cyl_neumann">[[sf.cmath.cyl_neumann]]</a>
837
 
838
  ``` cpp
839
  double cyl_neumann(double nu, double x);
840
  float cyl_neumannf(float nu, float x);
841
  long double cyl_neumannl(long double nu, long double x);
@@ -863,13 +875,13 @@ their respective arguments `nu` and `x`.
863
  \right.$$ where $\nu$ is `nu` and x is `x`.
864
 
865
  *Remarks:* The effect of calling each of these functions is
866
  *implementation-defined* if `nu >= 128`.
867
 
868
- See also [[sf.cmath.cyl_bessel_j]].
869
 
870
- #### Incomplete elliptic integral of the first kind <a id="sf.cmath.ellint_1">[[sf.cmath.ellint_1]]</a>
871
 
872
  ``` cpp
873
  double ellint_1(double k, double phi);
874
  float ellint_1f(float k, float phi);
875
  long double ellint_1l(long double k, long double phi);
@@ -877,17 +889,15 @@ long double ellint_1l(long double k, long double phi);
877
 
878
  *Effects:* These functions compute the incomplete elliptic integral of
879
  the first kind of their respective arguments `k` and `phi` (`phi`
880
  measured in radians).
881
 
882
- *Returns:* $$%
883
- \mathsf{F}(k, \phi) =
884
- \int_0^\phi \! \frac{\mathsf{d}\theta}
885
- {\sqrt{1 - k^2 \sin^2 \theta}},
886
- \quad \mbox{for $|k| \le 1$}$$ where k is `k` and φ is `phi`.
887
 
888
- #### Incomplete elliptic integral of the second kind <a id="sf.cmath.ellint_2">[[sf.cmath.ellint_2]]</a>
889
 
890
  ``` cpp
891
  double ellint_2(double k, double phi);
892
  float ellint_2f(float k, float phi);
893
  long double ellint_2l(long double k, long double phi);
@@ -895,16 +905,15 @@ long double ellint_2l(long double k, long double phi);
895
 
896
  *Effects:* These functions compute the incomplete elliptic integral of
897
  the second kind of their respective arguments `k` and `phi` (`phi`
898
  measured in radians).
899
 
900
- *Returns:* $$%
901
- \mathsf{E}(k, \phi) =
902
- \int_0^\phi \! \sqrt{1 - k^2 \sin^2 \theta} \, \mathsf{d}\theta,
903
- \quad \mbox{for $|k| \le 1$}$$ where k is `k` and φ is `phi`.
904
 
905
- #### Incomplete elliptic integral of the third kind <a id="sf.cmath.ellint_3">[[sf.cmath.ellint_3]]</a>
906
 
907
  ``` cpp
908
  double ellint_3(double k, double nu, double phi);
909
  float ellint_3f(float k, float nu, float phi);
910
  long double ellint_3l(long double k, long double nu, long double phi);
@@ -912,16 +921,13 @@ long double ellint_3l(long double k, long double nu, long double phi);
912
 
913
  *Effects:* These functions compute the incomplete elliptic integral of
914
  the third kind of their respective arguments `k`, `nu`, and `phi` (`phi`
915
  measured in radians).
916
 
917
- *Returns:* $$%
918
- \mathsf{\Pi}(\nu, k, \phi) =
919
- \int_0^\phi \! \frac{ \mathsf{d}\theta }
920
- { (1 - \nu \, \sin^2 \theta) \sqrt{1 - k^2 \sin^2 \theta} },
921
- \quad \mbox{for $|k| \le 1$}$$ where $\nu$ is `nu`, k is `k`, and
922
- φ is `phi`.
923
 
924
  #### Exponential integral <a id="sf.cmath.expint">[[sf.cmath.expint]]</a>
925
 
926
  ``` cpp
927
  double expint(double x);
@@ -967,15 +973,13 @@ long double laguerrel(unsigned n, long double x);
967
  ```
968
 
969
  *Effects:* These functions compute the Laguerre polynomials of their
970
  respective arguments `n` and `x`.
971
 
972
- *Returns:* $$%
973
- \mathsf{L}_n(x) =
974
- \frac{e^x}{n!} \frac{ \mathsf{d} ^ n}
975
- { \mathsf{d}x ^ n} \, (x^n e^{-x}),
976
- \quad \mbox{for $x \ge 0$}$$ where n is `n` and x is `x`.
977
 
978
  *Remarks:* The effect of calling each of these functions is
979
  *implementation-defined* if `n >= 128`.
980
 
981
  #### Legendre polynomials <a id="sf.cmath.legendre">[[sf.cmath.legendre]]</a>
@@ -987,22 +991,19 @@ long double legendrel(unsigned l, long double x);
987
  ```
988
 
989
  *Effects:* These functions compute the Legendre polynomials of their
990
  respective arguments `l` and `x`.
991
 
992
- *Returns:* $$%
993
- \mathsf{P}_\ell(x) =
994
- \frac{1}
995
- {2^\ell \, \ell!}
996
- \frac{ \mathsf{d} ^ \ell}
997
- { \mathsf{d}x ^ \ell} \, (x^2 - 1) ^ \ell,
998
- \quad \mbox{for $|x| \le 1$}$$ where l is `l` and x is `x`.
999
 
1000
  *Remarks:* The effect of calling each of these functions is
1001
  *implementation-defined* if `l >= 128`.
1002
 
1003
- #### Riemann zeta function <a id="sf.cmath.riemann_zeta">[[sf.cmath.riemann_zeta]]</a>
1004
 
1005
  ``` cpp
1006
  double riemann_zeta(double x);
1007
  float riemann_zetaf(float x);
1008
  long double riemann_zetal(long double x);
@@ -1032,32 +1033,31 @@ respective arguments `x`.
1032
  & \mbox{for $x < 0$}
1033
  \end{array}
1034
  \right.
1035
  \;$$ where x is `x`.
1036
 
1037
- #### Spherical Bessel functions of the first kind <a id="sf.cmath.sph_bessel">[[sf.cmath.sph_bessel]]</a>
1038
 
1039
  ``` cpp
1040
  double sph_bessel(unsigned n, double x);
1041
  float sph_besself(unsigned n, float x);
1042
  long double sph_bessell(unsigned n, long double x);
1043
  ```
1044
 
1045
  *Effects:* These functions compute the spherical Bessel functions of the
1046
  first kind of their respective arguments `n` and `x`.
1047
 
1048
- *Returns:* $$%
1049
- \mathsf{j}_n(x) =
1050
- (\pi/2x)^{1\!/\!2} \mathsf{J}_{n + 1\!/\!2}(x),
1051
- \quad \mbox{for $x \ge 0$}$$ where n is `n` and x is `x`.
1052
 
1053
  *Remarks:* The effect of calling each of these functions is
1054
  *implementation-defined* if `n >= 128`.
1055
 
1056
- See also [[sf.cmath.cyl_bessel_j]].
1057
 
1058
- #### Spherical associated Legendre functions <a id="sf.cmath.sph_legendre">[[sf.cmath.sph_legendre]]</a>
1059
 
1060
  ``` cpp
1061
  double sph_legendre(unsigned l, unsigned m, double theta);
1062
  float sph_legendref(unsigned l, unsigned m, float theta);
1063
  long double sph_legendrel(unsigned l, unsigned m, long double theta);
@@ -1065,30 +1065,23 @@ long double sph_legendrel(unsigned l, unsigned m, long double theta);
1065
 
1066
  *Effects:* These functions compute the spherical associated Legendre
1067
  functions of their respective arguments `l`, `m`, and `theta` (`theta`
1068
  measured in radians).
1069
 
1070
- *Returns:* $$%
1071
- \mathsf{Y}_\ell^m(\theta, 0)
1072
- \;$$ where $$%
1073
- \mathsf{Y}_\ell^m(\theta, \phi) =
1074
- (-1)^m \left[ \frac{(2 \ell + 1)}
1075
- {4 \pi}
1076
- \frac{(\ell - m)!}
1077
- {(\ell + m)!}
1078
- \right]^{1/2}
1079
- \mathsf{P}_\ell^m
1080
- ( \cos\theta ) e ^ {i m \phi},
1081
- \quad \mbox{for $|m| \le \ell$}$$ and l is `l`, m is `m`, and θ
1082
  is `theta`.
1083
 
1084
  *Remarks:* The effect of calling each of these functions is
1085
  *implementation-defined* if `l >= 128`.
1086
 
1087
- See also [[sf.cmath.assoc_legendre]].
1088
 
1089
- #### Spherical Neumann functions <a id="sf.cmath.sph_neumann">[[sf.cmath.sph_neumann]]</a>
1090
 
1091
  ``` cpp
1092
  double sph_neumann(unsigned n, double x);
1093
  float sph_neumannf(unsigned n, float x);
1094
  long double sph_neumannl(unsigned n, long double x);
@@ -1096,276 +1089,14 @@ long double sph_neumannl(unsigned n, long double x);
1096
 
1097
  *Effects:* These functions compute the spherical Neumann functions, also
1098
  known as the spherical Bessel functions of the second kind, of their
1099
  respective arguments `n` and `x`.
1100
 
1101
- *Returns:* $$%
1102
- \mathsf{n}_n(x) =
1103
- (\pi/2x)^{1\!/\!2} \mathsf{N}_{n + 1\!/\!2}(x),
1104
- \quad \mbox{for $x \ge 0$}$$ where n is `n` and x is `x`.
1105
 
1106
  *Remarks:* The effect of calling each of these functions is
1107
  *implementation-defined* if `n >= 128`.
1108
 
1109
- See also [[sf.cmath.cyl_neumann]].
1110
 
1111
- <!-- Link reference definitions -->
1112
- [accumulate]: #accumulate
1113
- [adjacent.difference]: #adjacent.difference
1114
- [algorithms]: algorithms.md#algorithms
1115
- [bad.alloc]: language.md#bad.alloc
1116
- [basic.fundamental]: basic.md#basic.fundamental
1117
- [basic.stc.thread]: basic.md#basic.stc.thread
1118
- [basic.types]: basic.md#basic.types
1119
- [c.math]: #c.math
1120
- [c.math.abs]: #c.math.abs
1121
- [c.math.fpclass]: #c.math.fpclass
1122
- [c.math.hypot3]: #c.math.hypot3
1123
- [c.math.rand]: #c.math.rand
1124
- [cfenv]: #cfenv
1125
- [cfenv.syn]: #cfenv.syn
1126
- [class.gslice]: #class.gslice
1127
- [class.gslice.overview]: #class.gslice.overview
1128
- [class.slice]: #class.slice
1129
- [class.slice.overview]: #class.slice.overview
1130
- [cmath.syn]: #cmath.syn
1131
- [cmplx.over]: #cmplx.over
1132
- [complex]: #complex
1133
- [complex.literals]: #complex.literals
1134
- [complex.member.ops]: #complex.member.ops
1135
- [complex.members]: #complex.members
1136
- [complex.numbers]: #complex.numbers
1137
- [complex.ops]: #complex.ops
1138
- [complex.special]: #complex.special
1139
- [complex.syn]: #complex.syn
1140
- [complex.transcendentals]: #complex.transcendentals
1141
- [complex.value.ops]: #complex.value.ops
1142
- [cons.slice]: #cons.slice
1143
- [conv.prom]: conv.md#conv.prom
1144
- [cpp.pragma]: cpp.md#cpp.pragma
1145
- [cstdlib.syn]: language.md#cstdlib.syn
1146
- [dcl.array]: dcl.md#dcl.array
1147
- [dcl.init]: dcl.md#dcl.init
1148
- [exclusive.scan]: #exclusive.scan
1149
- [function.objects]: utilities.md#function.objects
1150
- [gslice.access]: #gslice.access
1151
- [gslice.array.assign]: #gslice.array.assign
1152
- [gslice.array.comp.assign]: #gslice.array.comp.assign
1153
- [gslice.array.fill]: #gslice.array.fill
1154
- [gslice.cons]: #gslice.cons
1155
- [implimits]: limits.md#implimits
1156
- [inclusive.scan]: #inclusive.scan
1157
- [indirect.array.assign]: #indirect.array.assign
1158
- [indirect.array.comp.assign]: #indirect.array.comp.assign
1159
- [indirect.array.fill]: #indirect.array.fill
1160
- [inner.product]: #inner.product
1161
- [input.iterators]: iterators.md#input.iterators
1162
- [input.output]: input.md#input.output
1163
- [iostate.flags]: input.md#iostate.flags
1164
- [istream.formatted]: input.md#istream.formatted
1165
- [iterator.requirements.general]: iterators.md#iterator.requirements.general
1166
- [library.c]: library.md#library.c
1167
- [mask.array.assign]: #mask.array.assign
1168
- [mask.array.comp.assign]: #mask.array.comp.assign
1169
- [mask.array.fill]: #mask.array.fill
1170
- [numarray]: #numarray
1171
- [numeric.iota]: #numeric.iota
1172
- [numeric.ops]: #numeric.ops
1173
- [numeric.ops.gcd]: #numeric.ops.gcd
1174
- [numeric.ops.lcm]: #numeric.ops.lcm
1175
- [numeric.ops.overview]: #numeric.ops.overview
1176
- [numeric.requirements]: #numeric.requirements
1177
- [numerics]: #numerics
1178
- [numerics.defns]: #numerics.defns
1179
- [numerics.general]: #numerics.general
1180
- [output.iterators]: iterators.md#output.iterators
1181
- [partial.sum]: #partial.sum
1182
- [rand]: #rand
1183
- [rand.adapt]: #rand.adapt
1184
- [rand.adapt.disc]: #rand.adapt.disc
1185
- [rand.adapt.general]: #rand.adapt.general
1186
- [rand.adapt.ibits]: #rand.adapt.ibits
1187
- [rand.adapt.shuf]: #rand.adapt.shuf
1188
- [rand.device]: #rand.device
1189
- [rand.dist]: #rand.dist
1190
- [rand.dist.bern]: #rand.dist.bern
1191
- [rand.dist.bern.bernoulli]: #rand.dist.bern.bernoulli
1192
- [rand.dist.bern.bin]: #rand.dist.bern.bin
1193
- [rand.dist.bern.geo]: #rand.dist.bern.geo
1194
- [rand.dist.bern.negbin]: #rand.dist.bern.negbin
1195
- [rand.dist.general]: #rand.dist.general
1196
- [rand.dist.norm]: #rand.dist.norm
1197
- [rand.dist.norm.cauchy]: #rand.dist.norm.cauchy
1198
- [rand.dist.norm.chisq]: #rand.dist.norm.chisq
1199
- [rand.dist.norm.f]: #rand.dist.norm.f
1200
- [rand.dist.norm.lognormal]: #rand.dist.norm.lognormal
1201
- [rand.dist.norm.normal]: #rand.dist.norm.normal
1202
- [rand.dist.norm.t]: #rand.dist.norm.t
1203
- [rand.dist.pois]: #rand.dist.pois
1204
- [rand.dist.pois.exp]: #rand.dist.pois.exp
1205
- [rand.dist.pois.extreme]: #rand.dist.pois.extreme
1206
- [rand.dist.pois.gamma]: #rand.dist.pois.gamma
1207
- [rand.dist.pois.poisson]: #rand.dist.pois.poisson
1208
- [rand.dist.pois.weibull]: #rand.dist.pois.weibull
1209
- [rand.dist.samp]: #rand.dist.samp
1210
- [rand.dist.samp.discrete]: #rand.dist.samp.discrete
1211
- [rand.dist.samp.pconst]: #rand.dist.samp.pconst
1212
- [rand.dist.samp.plinear]: #rand.dist.samp.plinear
1213
- [rand.dist.uni]: #rand.dist.uni
1214
- [rand.dist.uni.int]: #rand.dist.uni.int
1215
- [rand.dist.uni.real]: #rand.dist.uni.real
1216
- [rand.eng]: #rand.eng
1217
- [rand.eng.lcong]: #rand.eng.lcong
1218
- [rand.eng.mers]: #rand.eng.mers
1219
- [rand.eng.sub]: #rand.eng.sub
1220
- [rand.predef]: #rand.predef
1221
- [rand.req]: #rand.req
1222
- [rand.req.adapt]: #rand.req.adapt
1223
- [rand.req.dist]: #rand.req.dist
1224
- [rand.req.eng]: #rand.req.eng
1225
- [rand.req.genl]: #rand.req.genl
1226
- [rand.req.seedseq]: #rand.req.seedseq
1227
- [rand.req.urng]: #rand.req.urng
1228
- [rand.synopsis]: #rand.synopsis
1229
- [rand.util]: #rand.util
1230
- [rand.util.canonical]: #rand.util.canonical
1231
- [rand.util.seedseq]: #rand.util.seedseq
1232
- [random.access.iterators]: iterators.md#random.access.iterators
1233
- [reduce]: #reduce
1234
- [res.on.data.races]: library.md#res.on.data.races
1235
- [sf.cmath]: #sf.cmath
1236
- [sf.cmath.assoc_laguerre]: #sf.cmath.assoc_laguerre
1237
- [sf.cmath.assoc_legendre]: #sf.cmath.assoc_legendre
1238
- [sf.cmath.beta]: #sf.cmath.beta
1239
- [sf.cmath.comp_ellint_1]: #sf.cmath.comp_ellint_1
1240
- [sf.cmath.comp_ellint_2]: #sf.cmath.comp_ellint_2
1241
- [sf.cmath.comp_ellint_3]: #sf.cmath.comp_ellint_3
1242
- [sf.cmath.cyl_bessel_i]: #sf.cmath.cyl_bessel_i
1243
- [sf.cmath.cyl_bessel_j]: #sf.cmath.cyl_bessel_j
1244
- [sf.cmath.cyl_bessel_k]: #sf.cmath.cyl_bessel_k
1245
- [sf.cmath.cyl_neumann]: #sf.cmath.cyl_neumann
1246
- [sf.cmath.ellint_1]: #sf.cmath.ellint_1
1247
- [sf.cmath.ellint_2]: #sf.cmath.ellint_2
1248
- [sf.cmath.ellint_3]: #sf.cmath.ellint_3
1249
- [sf.cmath.expint]: #sf.cmath.expint
1250
- [sf.cmath.hermite]: #sf.cmath.hermite
1251
- [sf.cmath.laguerre]: #sf.cmath.laguerre
1252
- [sf.cmath.legendre]: #sf.cmath.legendre
1253
- [sf.cmath.riemann_zeta]: #sf.cmath.riemann_zeta
1254
- [sf.cmath.sph_bessel]: #sf.cmath.sph_bessel
1255
- [sf.cmath.sph_legendre]: #sf.cmath.sph_legendre
1256
- [sf.cmath.sph_neumann]: #sf.cmath.sph_neumann
1257
- [slice.access]: #slice.access
1258
- [slice.arr.assign]: #slice.arr.assign
1259
- [slice.arr.comp.assign]: #slice.arr.comp.assign
1260
- [slice.arr.fill]: #slice.arr.fill
1261
- [strings]: strings.md#strings
1262
- [tab:RandomDistribution]: #tab:RandomDistribution
1263
- [tab:RandomEngine]: #tab:RandomEngine
1264
- [tab:SeedSequence]: #tab:SeedSequence
1265
- [tab:UniformRandomBitGenerator]: #tab:UniformRandomBitGenerator
1266
- [tab:copyassignable]: #tab:copyassignable
1267
- [tab:copyconstructible]: #tab:copyconstructible
1268
- [tab:equalitycomparable]: #tab:equalitycomparable
1269
- [tab:iterator.input.requirements]: iterators.md#tab:iterator.input.requirements
1270
- [tab:moveassignable]: #tab:moveassignable
1271
- [tab:moveconstructible]: #tab:moveconstructible
1272
- [tab:numerics.lib.summary]: #tab:numerics.lib.summary
1273
- [template.gslice.array]: #template.gslice.array
1274
- [template.gslice.array.overview]: #template.gslice.array.overview
1275
- [template.indirect.array]: #template.indirect.array
1276
- [template.indirect.array.overview]: #template.indirect.array.overview
1277
- [template.mask.array]: #template.mask.array
1278
- [template.mask.array.overview]: #template.mask.array.overview
1279
- [template.slice.array]: #template.slice.array
1280
- [template.slice.array.overview]: #template.slice.array.overview
1281
- [template.valarray]: #template.valarray
1282
- [template.valarray.overview]: #template.valarray.overview
1283
- [thread.thread.class]: thread.md#thread.thread.class
1284
- [transform.exclusive.scan]: #transform.exclusive.scan
1285
- [transform.inclusive.scan]: #transform.inclusive.scan
1286
- [transform.reduce]: #transform.reduce
1287
- [valarray.access]: #valarray.access
1288
- [valarray.assign]: #valarray.assign
1289
- [valarray.binary]: #valarray.binary
1290
- [valarray.cassign]: #valarray.cassign
1291
- [valarray.comparison]: #valarray.comparison
1292
- [valarray.cons]: #valarray.cons
1293
- [valarray.members]: #valarray.members
1294
- [valarray.nonmembers]: #valarray.nonmembers
1295
- [valarray.range]: #valarray.range
1296
- [valarray.special]: #valarray.special
1297
- [valarray.sub]: #valarray.sub
1298
- [valarray.syn]: #valarray.syn
1299
- [valarray.transcend]: #valarray.transcend
1300
- [valarray.unary]: #valarray.unary
1301
- [vector]: containers.md#vector
1302
-
1303
- [^1]: In other words, value types. These include arithmetic types,
1304
- pointers, the library class `complex`, and instantiations of
1305
- `valarray` for value types.
1306
-
1307
- [^2]: The name of this engine refers, in part, to a property of its
1308
- period: For properly-selected values of the parameters, the period
1309
- is closely related to a large Mersenne prime number.
1310
-
1311
- [^3]: The parameter is intended to allow an implementation to
1312
- differentiate between different sources of randomness.
1313
-
1314
- [^4]: If a device has n states whose respective probabilities are
1315
- P₀, …, Pₙ₋₁, the device entropy S is defined as
1316
- $S = - \sum_{i=0}^{n-1} P_i \cdot \log P_i$.
1317
-
1318
- [^5]: b is introduced to avoid any attempt to produce more bits of
1319
- randomness than can be held in `RealType`.
1320
-
1321
- [^6]: The distribution corresponding to this probability density
1322
- function is also known (with a possible change of variable) as the
1323
- Gumbel Type I, the log-Weibull, or the Fisher-Tippett Type I
1324
- distribution.
1325
-
1326
- [^7]: Annex  [[implimits]] recommends a minimum number of recursively
1327
- nested template instantiations. This requirement thus indirectly
1328
- suggests a minimum allowable complexity for valarray expressions.
1329
-
1330
- [^8]: The intent is to specify an array template that has the minimum
1331
- functionality necessary to address aliasing ambiguities and the
1332
- proliferation of temporaries. Thus, the `valarray` template is
1333
- neither a matrix class nor a field class. However, it is a very
1334
- useful building block for designing such classes.
1335
-
1336
- [^9]: This default constructor is essential, since arrays of `valarray`
1337
- may be useful. After initialization, the length of an empty array
1338
- can be increased with the `resize` member function.
1339
-
1340
- [^10]: This constructor is the preferred method for converting a C array
1341
- to a `valarray` object.
1342
-
1343
- [^11]: This copy constructor creates a distinct array rather than an
1344
- alias. Implementations in which arrays share storage are permitted,
1345
- but they shall implement a copy-on-reference mechanism to ensure
1346
- that arrays are conceptually distinct.
1347
-
1348
- [^12]: BLAS stands for *Basic Linear Algebra Subprograms.* C++programs
1349
- may instantiate this class. See, for example, Dongarra, Du Croz,
1350
- Duff, and Hammerling: *A set of Level 3 Basic Linear Algebra
1351
- Subprograms*; Technical Report MCS-P1-0888, Argonne National
1352
- Laboratory (USA), Mathematics and Computer Science Division, August,
1353
- 1988.
1354
-
1355
- [^13]: The use of fully closed ranges is intentional.
1356
-
1357
- [^14]: `accumulate` is similar to the APL reduction operator and Common
1358
- Lisp reduce function, but it avoids the difficulty of defining the
1359
- result of reduction on an empty sequence by always requiring an
1360
- initial value.
1361
-
1362
- [^15]: The use of fully closed ranges is intentional.
1363
-
1364
- [^16]: The use of fully closed ranges is intentional.
1365
-
1366
- [^17]: The use of fully closed ranges is intentional.
1367
-
1368
- [^18]: A mathematical function is mathematically defined for a given set
1369
- of argument values (a) if it is explicitly defined for that set of
1370
- argument values, or (b) if its limiting value exists and does not
1371
- depend on the direction of approach.
 
211
  float fabsf(float x);
212
  long double fabsl(long double x);
213
 
214
  float hypot(float x, float y); // see [library.c]
215
  double hypot(double x, double y);
216
+ long double hypot(long double x, long double y); // see [library.c]
217
  float hypotf(float x, float y);
218
  long double hypotl(long double x, long double y);
219
 
220
  // [c.math.hypot3], three-dimensional hypotenuse
221
  float hypot(float x, float y, float z);
 
380
  double fma(double x, double y, double z);
381
  long double fma(long double x, long double y, long double z); // see [library.c]
382
  float fmaf(float x, float y, float z);
383
  long double fmal(long double x, long double y, long double z);
384
 
385
+ // [c.math.lerp], linear interpolation
386
+ constexpr float lerp(float a, float b, float t) noexcept;
387
+ constexpr double lerp(double a, double b, double t) noexcept;
388
+ constexpr long double lerp(long double a, long double b, long double t) noexcept;
389
+
390
  // [c.math.fpclass], classification / comparison functions
391
  int fpclassify(float x);
392
  int fpclassify(double x);
393
  int fpclassify(long double x);
394
 
395
+ bool isfinite(float x);
396
+ bool isfinite(double x);
397
+ bool isfinite(long double x);
398
 
399
+ bool isinf(float x);
400
+ bool isinf(double x);
401
+ bool isinf(long double x);
402
 
403
+ bool isnan(float x);
404
+ bool isnan(double x);
405
+ bool isnan(long double x);
406
 
407
+ bool isnormal(float x);
408
+ bool isnormal(double x);
409
+ bool isnormal(long double x);
410
 
411
+ bool signbit(float x);
412
+ bool signbit(double x);
413
+ bool signbit(long double x);
414
 
415
+ bool isgreater(float x, float y);
416
+ bool isgreater(double x, double y);
417
+ bool isgreater(long double x, long double y);
418
 
419
+ bool isgreaterequal(float x, float y);
420
+ bool isgreaterequal(double x, double y);
421
+ bool isgreaterequal(long double x, long double y);
422
 
423
+ bool isless(float x, float y);
424
+ bool isless(double x, double y);
425
+ bool isless(long double x, long double y);
426
 
427
+ bool islessequal(float x, float y);
428
+ bool islessequal(double x, double y);
429
+ bool islessequal(long double x, long double y);
430
 
431
+ bool islessgreater(float x, float y);
432
+ bool islessgreater(double x, double y);
433
+ bool islessgreater(long double x, long double y);
434
 
435
+ bool isunordered(float x, float y);
436
+ bool isunordered(double x, double y);
437
+ bool isunordered(long double x, long double y);
438
 
439
  // [sf.cmath], mathematical special functions
440
 
441
+ // [sf.cmath.assoc.laguerre], associated Laguerre polynomials
442
  double assoc_laguerre(unsigned n, unsigned m, double x);
443
  float assoc_laguerref(unsigned n, unsigned m, float x);
444
  long double assoc_laguerrel(unsigned n, unsigned m, long double x);
445
 
446
+ // [sf.cmath.assoc.legendre], associated Legendre functions
447
  double assoc_legendre(unsigned l, unsigned m, double x);
448
  float assoc_legendref(unsigned l, unsigned m, float x);
449
  long double assoc_legendrel(unsigned l, unsigned m, long double x);
450
 
451
  // [sf.cmath.beta], beta function
452
  double beta(double x, double y);
453
  float betaf(float x, float y);
454
  long double betal(long double x, long double y);
455
 
456
+ // [sf.cmath.comp.ellint.1], complete elliptic integral of the first kind
457
  double comp_ellint_1(double k);
458
  float comp_ellint_1f(float k);
459
  long double comp_ellint_1l(long double k);
460
 
461
+ // [sf.cmath.comp.ellint.2], complete elliptic integral of the second kind
462
  double comp_ellint_2(double k);
463
  float comp_ellint_2f(float k);
464
  long double comp_ellint_2l(long double k);
465
 
466
+ // [sf.cmath.comp.ellint.3], complete elliptic integral of the third kind
467
  double comp_ellint_3(double k, double nu);
468
  float comp_ellint_3f(float k, float nu);
469
  long double comp_ellint_3l(long double k, long double nu);
470
 
471
+ // [sf.cmath.cyl.bessel.i], regular modified cylindrical Bessel functions
472
  double cyl_bessel_i(double nu, double x);
473
  float cyl_bessel_if(float nu, float x);
474
  long double cyl_bessel_il(long double nu, long double x);
475
 
476
+ // [sf.cmath.cyl.bessel.j], cylindrical Bessel functions of the first kind
477
  double cyl_bessel_j(double nu, double x);
478
  float cyl_bessel_jf(float nu, float x);
479
  long double cyl_bessel_jl(long double nu, long double x);
480
 
481
+ // [sf.cmath.cyl.bessel.k], irregular modified cylindrical Bessel functions
482
  double cyl_bessel_k(double nu, double x);
483
  float cyl_bessel_kf(float nu, float x);
484
  long double cyl_bessel_kl(long double nu, long double x);
485
 
486
+ // [sf.cmath.cyl.neumann], cylindrical Neumann functions;
487
  // cylindrical Bessel functions of the second kind
488
  double cyl_neumann(double nu, double x);
489
  float cyl_neumannf(float nu, float x);
490
  long double cyl_neumannl(long double nu, long double x);
491
 
492
+ // [sf.cmath.ellint.1], incomplete elliptic integral of the first kind
493
  double ellint_1(double k, double phi);
494
  float ellint_1f(float k, float phi);
495
  long double ellint_1l(long double k, long double phi);
496
 
497
+ // [sf.cmath.ellint.2], incomplete elliptic integral of the second kind
498
  double ellint_2(double k, double phi);
499
  float ellint_2f(float k, float phi);
500
  long double ellint_2l(long double k, long double phi);
501
 
502
+ // [sf.cmath.ellint.3], incomplete elliptic integral of the third kind
503
  double ellint_3(double k, double nu, double phi);
504
  float ellint_3f(float k, float nu, float phi);
505
  long double ellint_3l(long double k, long double nu, long double phi);
506
 
507
  // [sf.cmath.expint], exponential integral
 
522
  // [sf.cmath.legendre], Legendre polynomials
523
  double legendre(unsigned l, double x);
524
  float legendref(unsigned l, float x);
525
  long double legendrel(unsigned l, long double x);
526
 
527
+ // [sf.cmath.riemann.zeta], Riemann zeta function
528
  double riemann_zeta(double x);
529
  float riemann_zetaf(float x);
530
  long double riemann_zetal(long double x);
531
 
532
+ // [sf.cmath.sph.bessel], spherical Bessel functions of the first kind
533
  double sph_bessel(unsigned n, double x);
534
  float sph_besself(unsigned n, float x);
535
  long double sph_bessell(unsigned n, long double x);
536
 
537
+ // [sf.cmath.sph.legendre], spherical associated Legendre functions
538
  double sph_legendre(unsigned l, unsigned m, double theta);
539
  float sph_legendref(unsigned l, unsigned m, float theta);
540
  long double sph_legendrel(unsigned l, unsigned m, long double theta);
541
 
542
+ // [sf.cmath.sph.neumann], spherical Neumann functions;
543
+ // spherical Bessel functions of the second kind
544
  double sph_neumann(unsigned n, double x);
545
  float sph_neumannf(unsigned n, float x);
546
  long double sph_neumannl(unsigned n, long double x);
547
  }
548
  ```
 
551
  standard library header `<math.h>`, with the addition of a
552
  three-dimensional hypotenuse function ([[c.math.hypot3]]) and the
553
  mathematical special functions described in [[sf.cmath]].
554
 
555
  [*Note 1*: Several functions have additional overloads in this
556
+ document, but they have the same behavior as in the C standard library
557
+ [[library.c]]. — *end note*]
558
 
559
  For each set of overloaded functions within `<cmath>`, with the
560
  exception of `abs`, there shall be additional overloads sufficient to
561
  ensure:
562
 
563
+ - If any argument of arithmetic type corresponding to a `double`
564
  parameter has type `long double`, then all arguments of arithmetic
565
+ type [[basic.fundamental]] corresponding to `double` parameters are
566
+ effectively cast to `long double`.
567
+ - Otherwise, if any argument of arithmetic type corresponding to a
568
  `double` parameter has type `double` or an integer type, then all
569
+ arguments of arithmetic type corresponding to `double` parameters are
570
+ effectively cast to `double`.
571
+ - \[*Note 2*: Otherwise, all arguments of arithmetic type corresponding
572
+ to `double` parameters have type `float`. — *end note*]
573
 
574
+ [*Note 3*: `abs` is exempted from these rules in order to stay
575
  compatible with C. — *end note*]
576
 
577
  ISO C 7.12
578
 
579
  ### Absolute values <a id="c.math.abs">[[c.math.abs]]</a>
580
 
581
+ [*Note 1*: The headers `<cstdlib>` and `<cmath>` declare the functions
582
+ described in this subclause. *end note*]
 
583
 
584
  ``` cpp
585
  int abs(int j);
586
  long int abs(long int j);
587
  long long int abs(long long int j);
 
594
  standard library for the functions `abs`, `labs`, `llabs`, `fabsf`,
595
  `fabs`, and `fabsl`.
596
 
597
  *Remarks:* If `abs()` is called with an argument of type `X` for which
598
  `is_unsigned_v<X>` is `true` and if `X` cannot be converted to `int` by
599
+ integral promotion [[conv.prom]], the program is ill-formed.
600
 
601
  [*Note 1*: Arguments that can be promoted to `int` are permitted for
602
  compatibility with C. — *end note*]
603
 
604
+ See also: ISO C 7.12.7.2, 7.22.6.1
605
 
606
  ### Three-dimensional hypotenuse <a id="c.math.hypot3">[[c.math.hypot3]]</a>
607
 
608
  ``` cpp
609
  float hypot(float x, float y, float z);
 
611
  long double hypot(long double x, long double y, long double z);
612
  ```
613
 
614
  *Returns:* $\sqrt{x^2+y^2+z^2}$.
615
 
616
+ ### Linear interpolation <a id="c.math.lerp">[[c.math.lerp]]</a>
617
+
618
+ ``` cpp
619
+ constexpr float lerp(float a, float b, float t) noexcept;
620
+ constexpr double lerp(double a, double b, double t) noexcept;
621
+ constexpr long double lerp(long double a, long double b, long double t) noexcept;
622
+ ```
623
+
624
+ *Returns:* a+t(b-a).
625
+
626
+ *Remarks:* Let `r` be the value returned. If
627
+ `isfinite(a) && isfinite(b)`, then:
628
+
629
+ - If `t == 0`, then `r == a`.
630
+ - If `t == 1`, then `r == b`.
631
+ - If `t >= 0 && t <= 1`, then `isfinite(r)`.
632
+ - If `isfinite(t) && a == b`, then `r == a`.
633
+ - If `isfinite(t) || !isnan(t) && b-a != 0`, then `!isnan(r)`.
634
+
635
+ Let *`CMP`*`(x,y)` be `1` if `x > y`, `-1` if `x < y`, and `0`
636
+ otherwise. For any `t1` and `t2`, the product of
637
+ *`CMP`*`(lerp(a, b, t2), lerp(a, b, t1))`, *`CMP`*`(t2, t1)`, and
638
+ *`CMP`*`(b, a)` is non-negative.
639
+
640
  ### Classification / comparison functions <a id="c.math.fpclass">[[c.math.fpclass]]</a>
641
 
642
  The classification / comparison functions behave the same as the C
643
  macros with the corresponding names defined in the C standard library.
644
  Each function is overloaded for the three floating-point types.
 
655
  - the function description’s *Returns:* clause explicitly specifies a
656
  domain and those argument values fall outside the specified domain, or
657
  - the corresponding mathematical function value has a nonzero imaginary
658
  component, or
659
  - the corresponding mathematical function is not mathematically
660
+ defined.[^13]
661
 
662
  Unless otherwise specified, each function is defined for all finite
663
  values, for negative infinity, and for positive infinity.
664
 
665
+ #### Associated Laguerre polynomials <a id="sf.cmath.assoc.laguerre">[[sf.cmath.assoc.laguerre]]</a>
666
 
667
  ``` cpp
668
  double assoc_laguerre(unsigned n, unsigned m, double x);
669
  float assoc_laguerref(unsigned n, unsigned m, float x);
670
  long double assoc_laguerrel(unsigned n, unsigned m, long double x);
671
  ```
672
 
673
  *Effects:* These functions compute the associated Laguerre polynomials
674
  of their respective arguments `n`, `m`, and `x`.
675
 
676
+ *Returns:* $$\mathsf{L}_n^m(x) =
677
+ (-1)^m \frac{\mathsf{d} ^ m}{\mathsf{d}x ^ m} \, \mathsf{L}_{n+m}(x)
678
+ \text{ ,\quad for $x \ge 0$,}$$ where n is `n`, m is `m`, and x is
 
 
679
  `x`.
680
 
681
  *Remarks:* The effect of calling each of these functions is
682
  *implementation-defined* if `n >= 128` or if `m >= 128`.
683
 
684
+ #### Associated Legendre functions <a id="sf.cmath.assoc.legendre">[[sf.cmath.assoc.legendre]]</a>
685
 
686
  ``` cpp
687
  double assoc_legendre(unsigned l, unsigned m, double x);
688
  float assoc_legendref(unsigned l, unsigned m, float x);
689
  long double assoc_legendrel(unsigned l, unsigned m, long double x);
690
  ```
691
 
692
  *Effects:* These functions compute the associated Legendre functions of
693
  their respective arguments `l`, `m`, and `x`.
694
 
695
+ *Returns:* $$\mathsf{P}_\ell^m(x) = (1 - x^2) ^ {m/2} \:
696
+ \frac{\mathsf{d} ^ m}{\mathsf{d}x ^ m} \, \mathsf{P}_\ell(x)
697
+ \text{ ,\quad for $|x| \le 1$,}$$ where l is `l`, m is `m`, and x is
 
 
 
 
698
  `x`.
699
 
700
  *Remarks:* The effect of calling each of these functions is
701
  *implementation-defined* if `l >= 128`.
702
 
 
709
  ```
710
 
711
  *Effects:* These functions compute the beta function of their respective
712
  arguments `x` and `y`.
713
 
714
+ *Returns:*
715
+ $$\mathsf{B}(x, y) = \frac{\Gamma(x) \, \Gamma(y)}{\Gamma(x + y)}
716
+ \text{ ,\quad for $x > 0$,\, $y > 0$,}$$ where x is `x` and y is `y`.
 
 
 
717
 
718
+ #### Complete elliptic integral of the first kind <a id="sf.cmath.comp.ellint.1">[[sf.cmath.comp.ellint.1]]</a>
719
 
720
  ``` cpp
721
  double comp_ellint_1(double k);
722
  float comp_ellint_1f(float k);
723
  long double comp_ellint_1l(long double k);
724
  ```
725
 
726
  *Effects:* These functions compute the complete elliptic integral of the
727
  first kind of their respective arguments `k`.
728
 
729
+ *Returns:*
730
+ $$\mathsf{K}(k) = \mathsf{F}(k, \pi / 2) \text{ ,\quad for $|k| \le 1$,}$$
731
+ where k is `k`.
 
732
 
733
+ See also [[sf.cmath.ellint.1]].
734
 
735
+ #### Complete elliptic integral of the second kind <a id="sf.cmath.comp.ellint.2">[[sf.cmath.comp.ellint.2]]</a>
736
 
737
  ``` cpp
738
  double comp_ellint_2(double k);
739
  float comp_ellint_2f(float k);
740
  long double comp_ellint_2l(long double k);
741
  ```
742
 
743
  *Effects:* These functions compute the complete elliptic integral of the
744
  second kind of their respective arguments `k`.
745
 
746
+ *Returns:*
747
+ $$\mathsf{E}(k) = \mathsf{E}(k, \pi / 2) \text{ ,\quad for $|k| \le 1$,}$$
748
+ where k is `k`.
 
749
 
750
+ See also [[sf.cmath.ellint.2]].
751
 
752
+ #### Complete elliptic integral of the third kind <a id="sf.cmath.comp.ellint.3">[[sf.cmath.comp.ellint.3]]</a>
753
 
754
  ``` cpp
755
  double comp_ellint_3(double k, double nu);
756
  float comp_ellint_3f(float k, float nu);
757
  long double comp_ellint_3l(long double k, long double nu);
758
  ```
759
 
760
  *Effects:* These functions compute the complete elliptic integral of the
761
  third kind of their respective arguments `k` and `nu`.
762
 
763
+ *Returns:*
764
+ $$\mathsf{\Pi}(\nu, k) = \mathsf{\Pi}(\nu, k, \pi / 2) \text{ ,\quad for $|k| \le 1$,}$$
765
+ where k is `k` and $\nu$ is `nu`.
766
 
767
+ See also [[sf.cmath.ellint.3]].
768
 
769
+ #### Regular modified cylindrical Bessel functions <a id="sf.cmath.cyl.bessel.i">[[sf.cmath.cyl.bessel.i]]</a>
770
 
771
  ``` cpp
772
  double cyl_bessel_i(double nu, double x);
773
  float cyl_bessel_if(float nu, float x);
774
  long double cyl_bessel_il(long double nu, long double x);
775
  ```
776
 
777
  *Effects:* These functions compute the regular modified cylindrical
778
  Bessel functions of their respective arguments `nu` and `x`.
779
 
780
+ *Returns:* $$\mathsf{I}_\nu(x) =
781
+ i^{-\nu} \mathsf{J}_\nu(ix) =
782
+ \sum_{k=0}^\infty \frac{(x/2)^{\nu+2k}}{k! \: \Gamma(\nu+k+1)}
783
+ \text{ ,\quad for $x \ge 0$,}$$ where $\nu$ is `nu` and x is `x`.
 
 
 
784
 
785
  *Remarks:* The effect of calling each of these functions is
786
  *implementation-defined* if `nu >= 128`.
787
 
788
+ See also [[sf.cmath.cyl.bessel.j]].
789
 
790
+ #### Cylindrical Bessel functions of the first kind <a id="sf.cmath.cyl.bessel.j">[[sf.cmath.cyl.bessel.j]]</a>
791
 
792
  ``` cpp
793
  double cyl_bessel_j(double nu, double x);
794
  float cyl_bessel_jf(float nu, float x);
795
  long double cyl_bessel_jl(long double nu, long double x);
796
  ```
797
 
798
  *Effects:* These functions compute the cylindrical Bessel functions of
799
  the first kind of their respective arguments `nu` and `x`.
800
 
801
+ *Returns:* $$\mathsf{J}_\nu(x) =
802
+ \sum_{k=0}^\infty \frac{(-1)^k (x/2)^{\nu+2k}}{k! \: \Gamma(\nu+k+1)}
803
+ \text{ ,\quad for $x \ge 0$,}$$ where $\nu$ is `nu` and x is `x`.
 
 
804
 
805
  *Remarks:* The effect of calling each of these functions is
806
  *implementation-defined* if `nu >= 128`.
807
 
808
+ #### Irregular modified cylindrical Bessel functions <a id="sf.cmath.cyl.bessel.k">[[sf.cmath.cyl.bessel.k]]</a>
809
 
810
  ``` cpp
811
  double cyl_bessel_k(double nu, double x);
812
  float cyl_bessel_kf(float nu, float x);
813
  long double cyl_bessel_kl(long double nu, long double x);
 
840
  \right.$$ where $\nu$ is `nu` and x is `x`.
841
 
842
  *Remarks:* The effect of calling each of these functions is
843
  *implementation-defined* if `nu >= 128`.
844
 
845
+ See also [[sf.cmath.cyl.bessel.i]], [[sf.cmath.cyl.bessel.j]],
846
+ [[sf.cmath.cyl.neumann]].
847
 
848
+ #### Cylindrical Neumann functions <a id="sf.cmath.cyl.neumann">[[sf.cmath.cyl.neumann]]</a>
849
 
850
  ``` cpp
851
  double cyl_neumann(double nu, double x);
852
  float cyl_neumannf(float nu, float x);
853
  long double cyl_neumannl(long double nu, long double x);
 
875
  \right.$$ where $\nu$ is `nu` and x is `x`.
876
 
877
  *Remarks:* The effect of calling each of these functions is
878
  *implementation-defined* if `nu >= 128`.
879
 
880
+ See also [[sf.cmath.cyl.bessel.j]].
881
 
882
+ #### Incomplete elliptic integral of the first kind <a id="sf.cmath.ellint.1">[[sf.cmath.ellint.1]]</a>
883
 
884
  ``` cpp
885
  double ellint_1(double k, double phi);
886
  float ellint_1f(float k, float phi);
887
  long double ellint_1l(long double k, long double phi);
 
889
 
890
  *Effects:* These functions compute the incomplete elliptic integral of
891
  the first kind of their respective arguments `k` and `phi` (`phi`
892
  measured in radians).
893
 
894
+ *Returns:* $$\mathsf{F}(k, \phi) =
895
+ \int_0^\phi \! \frac{\mathsf{d}\theta}{\sqrt{1 - k^2 \sin^2 \theta}}
896
+ \text{ ,\quad for $|k| \le 1$,}$$ where k is `k` and φ is `phi`.
 
 
897
 
898
+ #### Incomplete elliptic integral of the second kind <a id="sf.cmath.ellint.2">[[sf.cmath.ellint.2]]</a>
899
 
900
  ``` cpp
901
  double ellint_2(double k, double phi);
902
  float ellint_2f(float k, float phi);
903
  long double ellint_2l(long double k, long double phi);
 
905
 
906
  *Effects:* These functions compute the incomplete elliptic integral of
907
  the second kind of their respective arguments `k` and `phi` (`phi`
908
  measured in radians).
909
 
910
+ *Returns:*
911
+ $$\mathsf{E}(k, \phi) = \int_0^\phi \! \sqrt{1 - k^2 \sin^2 \theta} \, \mathsf{d}\theta
912
+ \text{ ,\quad for $|k| \le 1$,}$$ where k is `k` and φ is `phi`.
 
913
 
914
+ #### Incomplete elliptic integral of the third kind <a id="sf.cmath.ellint.3">[[sf.cmath.ellint.3]]</a>
915
 
916
  ``` cpp
917
  double ellint_3(double k, double nu, double phi);
918
  float ellint_3f(float k, float nu, float phi);
919
  long double ellint_3l(long double k, long double nu, long double phi);
 
921
 
922
  *Effects:* These functions compute the incomplete elliptic integral of
923
  the third kind of their respective arguments `k`, `nu`, and `phi` (`phi`
924
  measured in radians).
925
 
926
+ *Returns:* $$\mathsf{\Pi}(\nu, k, \phi) = \int_0^\phi \!
927
+ \frac{ \mathsf{d}\theta }{ (1 - \nu \, \sin^2 \theta) \sqrt{1 - k^2 \sin^2 \theta} } \text{ ,\quad for $|k| \le 1$,}$$
928
+ where $\nu$ is `nu`, k is `k`, and φ is `phi`.
 
 
 
929
 
930
  #### Exponential integral <a id="sf.cmath.expint">[[sf.cmath.expint]]</a>
931
 
932
  ``` cpp
933
  double expint(double x);
 
973
  ```
974
 
975
  *Effects:* These functions compute the Laguerre polynomials of their
976
  respective arguments `n` and `x`.
977
 
978
+ *Returns:* $$\mathsf{L}_n(x) =
979
+ \frac{e^x}{n!} \frac{\mathsf{d}^n}{\mathsf{d}x^n} \, (x^n e^{-x})
980
+ \text{ ,\quad for $x \ge 0$,}$$ where n is `n` and x is `x`.
 
 
981
 
982
  *Remarks:* The effect of calling each of these functions is
983
  *implementation-defined* if `n >= 128`.
984
 
985
  #### Legendre polynomials <a id="sf.cmath.legendre">[[sf.cmath.legendre]]</a>
 
991
  ```
992
 
993
  *Effects:* These functions compute the Legendre polynomials of their
994
  respective arguments `l` and `x`.
995
 
996
+ *Returns:* $$\mathsf{P}_\ell(x) =
997
+ \frac{1}{2^\ell \, \ell!}
998
+ \frac{\mathsf{d}^\ell}{\mathsf{d}x^\ell} \, (x^2 - 1) ^ \ell
999
+ \text{ ,\quad for $|x| \le 1$,}$$ where l is `l` and x is `x`.
 
 
 
1000
 
1001
  *Remarks:* The effect of calling each of these functions is
1002
  *implementation-defined* if `l >= 128`.
1003
 
1004
+ #### Riemann zeta function <a id="sf.cmath.riemann.zeta">[[sf.cmath.riemann.zeta]]</a>
1005
 
1006
  ``` cpp
1007
  double riemann_zeta(double x);
1008
  float riemann_zetaf(float x);
1009
  long double riemann_zetal(long double x);
 
1033
  & \mbox{for $x < 0$}
1034
  \end{array}
1035
  \right.
1036
  \;$$ where x is `x`.
1037
 
1038
+ #### Spherical Bessel functions of the first kind <a id="sf.cmath.sph.bessel">[[sf.cmath.sph.bessel]]</a>
1039
 
1040
  ``` cpp
1041
  double sph_bessel(unsigned n, double x);
1042
  float sph_besself(unsigned n, float x);
1043
  long double sph_bessell(unsigned n, long double x);
1044
  ```
1045
 
1046
  *Effects:* These functions compute the spherical Bessel functions of the
1047
  first kind of their respective arguments `n` and `x`.
1048
 
1049
+ *Returns:*
1050
+ $$\mathsf{j}_n(x) = (\pi/2x)^{1\!/\!2} \mathsf{J}_{n + 1\!/\!2}(x) \text{ ,\quad for $x \ge 0$,}$$
1051
+ where n is `n` and x is `x`.
 
1052
 
1053
  *Remarks:* The effect of calling each of these functions is
1054
  *implementation-defined* if `n >= 128`.
1055
 
1056
+ See also [[sf.cmath.cyl.bessel.j]].
1057
 
1058
+ #### Spherical associated Legendre functions <a id="sf.cmath.sph.legendre">[[sf.cmath.sph.legendre]]</a>
1059
 
1060
  ``` cpp
1061
  double sph_legendre(unsigned l, unsigned m, double theta);
1062
  float sph_legendref(unsigned l, unsigned m, float theta);
1063
  long double sph_legendrel(unsigned l, unsigned m, long double theta);
 
1065
 
1066
  *Effects:* These functions compute the spherical associated Legendre
1067
  functions of their respective arguments `l`, `m`, and `theta` (`theta`
1068
  measured in radians).
1069
 
1070
+ *Returns:* $$\mathsf{Y}_\ell^m(\theta, 0)$$ where
1071
+ $$\mathsf{Y}_\ell^m(\theta, \phi) =
1072
+ (-1)^m \left[\frac{(2 \ell + 1)}{4 \pi} \frac{(\ell - m)!}{(\ell + m)!}\right]^{1/2}
1073
+ \mathsf{P}_\ell^m (\cos\theta) e^{i m \phi}
1074
+ \text{ ,\quad for $|m| \le \ell$,}$$ and l is `l`, m is `m`, and θ
 
 
 
 
 
 
 
1075
  is `theta`.
1076
 
1077
  *Remarks:* The effect of calling each of these functions is
1078
  *implementation-defined* if `l >= 128`.
1079
 
1080
+ See also [[sf.cmath.assoc.legendre]].
1081
 
1082
+ #### Spherical Neumann functions <a id="sf.cmath.sph.neumann">[[sf.cmath.sph.neumann]]</a>
1083
 
1084
  ``` cpp
1085
  double sph_neumann(unsigned n, double x);
1086
  float sph_neumannf(unsigned n, float x);
1087
  long double sph_neumannl(unsigned n, long double x);
 
1089
 
1090
  *Effects:* These functions compute the spherical Neumann functions, also
1091
  known as the spherical Bessel functions of the second kind, of their
1092
  respective arguments `n` and `x`.
1093
 
1094
+ *Returns:*
1095
+ $$\mathsf{n}_n(x) = (\pi/2x)^{1\!/\!2} \mathsf{N}_{n + 1\!/\!2}(x)
1096
+ \text{ ,\quad for $x \ge 0$,}$$ where n is `n` and x is `x`.
 
1097
 
1098
  *Remarks:* The effect of calling each of these functions is
1099
  *implementation-defined* if `n >= 128`.
1100
 
1101
+ See also [[sf.cmath.cyl.neumann]].
1102