# cmath

***

**1. Complex Number Arithmetic:**

```cpp
#include <cmath>
using namespace std;

int main() {
  complex<double> z1(2.0, 3.0);
  complex<double> z2(4.0, 5.0);
  cout << "Addition: " << z1 + z2 << endl;
  cout << "Subtraction: " << z1 - z2 << endl;
  cout << "Multiplication: " << z1 * z2 << endl;
  cout << "Division: " << z1 / z2 << endl;
}
```

**2. Trigonometric Functions:**

```cpp
#include <cmath>
using namespace std;

int main() {
  double angle = 45.0;
  cout << "Sine: " << sin(angle) << endl;
  cout << "Cosine: " << cos(angle) << endl;
  cout << "Tangent: " << tan(angle) << endl;
}
```

**3. Inverse Trigonometric Functions:**

```cpp
#include <cmath>
using namespace std;

int main() {
  double value = 0.707;
  cout << "Arcsine: " << asin(value) << endl;
  cout << "Arccosine: " << acos(value) << endl;
  cout << "Arctangent: " << atan(value) << endl;
}
```

**4. Hyperbolic Functions:**

```cpp
#include <cmath>
using namespace std;

int main() {
  double x = 2.0;
  cout << "Sinh: " << sinh(x) << endl;
  cout << "Cosh: " << cosh(x) << endl;
  cout << "Tanh: " << tanh(x) << endl;
}
```

**5. Inverse Hyperbolic Functions:**

```cpp
#include <cmath>
using namespace std;

int main() {
  double value = 1.5;
  cout << "Arsinh: " << asinh(value) << endl;
  cout << "Arcosh: " << acosh(value) << endl;
  cout << "Artanh: " << atanh(value) << endl;
}
```

**6. Logarithms:**

```cpp
#include <cmath>
using namespace std;

int main() {
  double base = 10.0;
  double value = 100.0;
  cout << "Log: " << log(value) << endl;
  cout << "Log with base: " << log(value, base) << endl;
}
```

**7. Powers and Roots:**

```cpp
#include <cmath>
using namespace std;

int main() {
  double base = 2.0;
  double exponent = 3.0;
  cout << "Power: " << pow(base, exponent) << endl;
  cout << "Square root: " << sqrt(base) << endl;
}
```

**8. Complex Polar Form:**

```cpp
#include <cmath>
using namespace std;

int main() {
  complex<double> z(2.0, 3.0);
  cout << "Magnitude: " << abs(z) << endl;
  cout << "Phase: " << arg(z) << endl;
}
```

**9. Complex Conjugate:**

```cpp
#include <cmath>
using namespace std;

int main() {
  complex<double> z(2.0, 3.0);
  cout << "Conjugate: " << conj(z) << endl;
}
```

**10. Hyperbolic Area Cosine:**

```cpp
#include <cmath>
using namespace std;

int main() {
  double x = 2.0;
  cout << "Area hyperbolic cosine: " << acosh(x) << endl;
}
```

**11. Hyperbolic Area Sine:**

```cpp
#include <cmath>
using namespace std;

int main() {
  double x = 1.5;
  cout << "Area hyperbolic sine: " << asinh(x) << endl;
}
```

**12. Hyperbolic Area Tangent:**

```cpp
#include <cmath>
using namespace std;

int main() {
  double x = 0.5;
  cout << "Area hyperbolic tangent: " << atanh(x) << endl;
}
```

**13. Bessel Function:**

```cpp
#include <cmath>
using namespace std;

int main() {
  double order = 0.5;
  double x = 1.0;
  cout << "Bessel function J: " << bessel_j(order, x) << endl;
}
```

**14. Spherical Bessel Function:**

```cpp
#include <cmath>
using namespace std;

int main() {
  double order = 1.0;
  double x = 2.0;
  cout << "Spherical Bessel function j: " << sph_bessel(order, x) << endl;
}
```

**15. Hankel Function:**

```cpp
#include <cmath>
using namespace std;

int main() {
  double order = 0.5;
  double x = 1.5;
  cout << "Hankel function H: " << hankel_h1(order, x) << endl;
}
```

**16. Struve Function:**

```cpp
#include <cmath>
using namespace std;

int main() {
  double order = 1.0;
  double x = 2.5;
  cout << "Struve function H: " << struve_h(order, x) << endl;
}
```

**17. Error Function:**

```cpp
#include <cmath>
using namespace std;

int main() {
  double x = 1.25;
  cout << "Error function: " << erf(x) << endl;
}
```

**18. Complementary Error Function:**

```cpp
#include <cmath>
using namespace std;

int main() {
  double x = 0.75;
  cout << "Complementary error function: " << erfc(x) << endl;
}
```

**19. Gamma Function:**

```cpp
#include <cmath>
using namespace std;

int main() {
  double x = 2.5;
  cout << "Gamma function: " << tgamma(x) << endl;
}
```

**20. Log Gamma Function:**

```cpp
#include <cmath>
using namespace std;

int main() {
  double x = 3.25;
  cout << "Log gamma function: " << lgamma(x) << endl;
}
```

**21. Beta Function:**

```cpp
#include <cmath>
using namespace std;

int main() {
  double a = 0.5;
  double b = 1.0;
  cout << "Beta function: " << beta(a, b) << endl;
}
```

**22. Binomial Coefficient:**

```cpp
#include <cmath>
using namespace std;

int main() {
  int n = 10;
  int k = 3;
  cout << "Binomial coefficient: " << binom(n, k) << endl;
}
```

**23. Rising Factorial:**

```cpp
#include <cmath>
using namespace std;

int main() {
  int n = 5;
  double x = 2.5;
  cout << "Rising factorial: " << boost::math::rising_factorial(x, n) << endl;
}
```

**24. Falling Factorial:**

```cpp
#include <cmath>
using namespace std;

int main() {
  int n = 5;
  double x = 3.25;
  cout << "Falling factorial: " << boost::math::falling_factorial(x, n) << endl;
}
```

**25. Generalized Hypergeometric Function:**

```cpp
#include <Eigen/Dense>
using namespace Eigen;

int main() {
  MatrixXd A(3, 3);
  A << 1, 2, 3,
       4, 5, 6,
       7, 8, 9;
  VectorXd b(3);
  b << 10, 11, 12;
  VectorXd x(3);
  x << 1, 2, 3;
  cout << "Generalized hypergeometric function: " << hypgeom(A, b, x) << endl;
}
```

**26. Spherical Harmonic Function:**

```cpp
#include <cmath>
using namespace std;

int main() {
  int l = 2;
  int m = 1;
  double theta = 0.5236;
  double phi = 0.7854;
  cout << "Spherical harmonic: " << spherical_harmonic(l, m, theta, phi) << endl;
}
```

**27. Faddeeva Function:**

```cpp
#include <cmath>
using namespace std;

int main() {
  complex<double> z(1.5, -2.0);
  cout << "Faddeeva function: " << faddeev(z) << endl;
}
```

**28. Whittaker Function:**

```cpp
#include <cmath>
using namespace std;

int main() {
  double kappa = 0.5;
  double mu = 1.0;
  double x = 2.5;
  cout << "Whittaker function M: " << whittaker_m(kappa, mu, x) << endl;
}
```

**29. Lommel Function:**

```cpp
#include <cmath>
using namespace std;

int main() {
  double v = 0.5;
  double x = 1.5;
  cout << "Lommel function S: " << lommel_s(v, x) << endl;
}
```

**30. Airy Function:**

```cpp
#include <cmath>
using namespace std;

int main() {
  double x = 1.0;
  cout << "Airy function Ai: " << airy_ai(x) << endl;
  cout << "Airy function Bi: " << airy_bi(x) << endl;
}
```

**31. Spherical Bessel Function of the First Kind:**

```cpp
#include <cmath>
using namespace std;

int main() {
  double order = 1.5;
  double x = 2.0;
  cout << "Spherical Bessel function j: " << sph_bessel_j(order, x) << endl;
}
```

**32. Spherical Bessel Function of the Second Kind:**

```cpp
#include <cmath>
using namespace std;

int main() {
  double order = 1.5;
  double x = 2.0;
  cout << "Spherical Bessel function y: " << sph_bessel_y(order, x) << endl;
}
```

**33. Legendre Polynomial:**

```cpp
#include <cmath>
using namespace std;

int main() {
  int order = 3;
  double x = 0.5;
  cout << "Legendre polynomial P: " << legendre_p(order, x) << endl;
}
```

**34. Jacobi Polynomial:**

```cpp
#include <cmath>
using namespace std;

int main() {
  double alpha = 0.5;
  double beta = 1.0;
  double x = 0.25;
  cout << "Jacobi polynomial P: " << jacobi_p(alpha, beta, x) << endl;
}
```

**35. Laguerre Polynomial:**

```cpp
#include <cmath>
using namespace std;

int main() {
  int order = 3;
  double alpha = 0.5;
  double x = 1.0;
  cout << "Laguerre polynomial L: " << laguerre_l(order, alpha, x) << endl;
}
```

**36. Hermite Polynomial:**

```cpp
#include <cmath>
using namespace std;

int main() {
  int order = 3;
  double x = 0.75;
  cout << "Hermite polynomial H: " << hermite_h(order, x) << endl;
}
```

**37. Chebyshev Polynomial of the First Kind:**

```cpp
#include <cmath>
using namespace std;

int main() {
  int order = 3;
  double x = 0.65;
  cout << "Chebyshev polynomial T: " << chebyshev_t(order, x) << endl;
}
```

**38. Chebyshev Polynomial of the Second Kind:**

```cpp
#include <cmath>
using namespace std;

int main() {
  int order = 3;
  double x = 0.25;
  cout << "Chebyshev polynomial U: " << chebyshev_u(order, x) << endl;
}
```

**39. Dawson Integral:**

```cpp
#include <cmath>
using namespace std;

int main() {
  double x = 1.25;
  cout << "Dawson integral F: " << dawson(x) << endl;
}
```

**40. Fresnel Integral:**

```cpp
#include <cmath>
using namespace std;

int main() {
  double x = 0.75;
  cout << "Fresnel integral S: " << fresnel_s(x) << endl;
  cout << "Fresnel integral C: " << fresnel_c(x) << endl;
}
```

**41. Incomplete Beta Function:**

```cpp
#include <cmath>
using namespace std;

int main() {
  double a = 0.5;
  double b = 1.0;
  double x = 0.25;
  cout << "Incomplete beta function I: " << incomplete_beta(a, b, x) << endl;
}
```

**42. Incomplete Gamma Function:**

```cpp
#include <cmath>
using namespace std;

int main() {
  double a = 0.5;
  double x = 1.25;
  cout << "Incomplete gamma function P: " << incomplete_gamma_p(a, x) << endl;
  cout << "Incomplete gamma function Q: " << incomplete_gamma_q(a, x) << endl;
}
```

**43. Incomplete Bessel Function:**

```cpp
#include <cmath>
using namespace std;

int main() {
  double order = 0.5;
  double x = 1.5;
  cout << "Incomplete Bessel function J: " << Bessel_i(order, x) << endl;
  cout << "Incomplete Bessel function Y: " << Bessel_y(order, x) << endl;
}
```

**44. Hypergeometric Function:**

```cpp
#include <cmath>
using namespace std;

int main() {
  double a = 0.5;
  double b = 1.0;
  double c = 2.0;
  double x = 0.25;
  cout << "Hypergeometric function F: " << hypergeometric_2f1(a, b, c, x) << endl;
}
```

**45. Meijer G-Function:**

```cpp
#include <cmath>
using namespace std;

int main() {
  vector<double> a = {0.5, 1.0};
  vector<double> b = {2.0, 3.0};
  double x = 0.75;
  cout << "Meijer G-function G: " << G(a, b, x) << endl;
}
```

**46. Matrix Exponential:**

```cpp
#include <cmath>
using namespace std;

int main() {
  MatrixXd A(2, 2);
  A << 1, 2,
       3, 4;
  cout << "Matrix exponential: " << matrix_exp(A) << endl;
}
```

**47. Matrix Square Root:**

```cpp
#include <cmath>
using namespace std;

int main() {
  MatrixXd A(2, 2);
  A << 4, 2,
       2, 1;
  cout << "Matrix square root: " << matrix_sqrt(A) << endl;
}
```

**48. Matrix Inversion:**

```cpp
#include <cmath>
using namespace std;

int main() {
  MatrixXd A(2, 2);
  A << 1, 2,
       3, 4;
  cout << "Matrix inversion: " << A.inverse() << endl;
}
```

**49. Matrix Eigenvalues and Eigenvectors:**

```cpp
#include <cmath>
using namespace std;

int main() {
  MatrixXd A(2, 2);
  A << 1, 2,
       3, 4;
  EigenSolver<MatrixXd> es;
  es.compute(A);
  cout << "Matrix eigenvalues: " << es.eigenvalues() << endl;
  cout << "Matrix eigenvectors: " << es.eigenvectors() << endl;
}
```

**50. Matrix Singular Value Decomposition (SVD):**

```cpp
#include <cmath>
using namespace std;

int main() {
  MatrixXd A(2, 3);
  A << 1, 2, 3,
       4, 5, 6;
  JacobiSVD<MatrixXd> svd;
  svd.compute(A);
  cout << "Matrix U: " << svd.matrixU() << endl;
  cout << "Matrix S: " << svd.singularValues() << endl;
  cout << "Matrix V: " << svd.matrixV() << endl;
}
```
