x005.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <cmath>
4 #include <complex>
5 #include <iomanip>
6 #include <iostream>
7 
8 namespace nmx::apps::x005 {
9 
13 inline void ex1() {
14  using namespace std::literals::complex_literals;
15  std::complex<double> z = 3. + 4.i;
16 
17  std::cout << "real part:" << std::real(z) << std::endl;
18  std::cout << "imaginary part:" << std::imag(z) << std::endl;
19 
20  std::cout << "absolute value:" << std::abs(z) << std::endl;
21  std::cout << "phase angle:" << std::arg(z) << std::endl;
22  std::cout << "norm:" << std::norm(z) << std::endl;
23 
24  std::cout << "complex conjugate:" << std::conj(z) << std::endl;
25  std::cout << "polar component:" << std::polar(5., 0.927295) << std::endl;
26 }
27 
31 inline void ex2() {
32  using namespace std::literals::complex_literals;
33  std::complex<double> z1 = 3. + 4i, z2 = 2. - 5i;
34  std::cout << "z1=" << z1 << ", z2=" << z2 << std::endl;
35 
36  std::cout << "z1+z2=" << z1 + z2 << std::endl;
37  std::cout << "z1-z2=" << z1 - z2 << std::endl;
38 
39  std::cout << "z1+conj(z2)=" << z1 + std::conj(z2) << std::endl;
40  std::cout << "z1-conj(z2)=" << z1 - std::conj(z2) << std::endl;
41 
42  std::cout << "z1/z2=" << z1 / z2 << std::endl;
43  std::cout << "z1^3+z2^2=" << std::pow(z1, 3) * std::pow(z2, 2) << std::endl;
44 }
45 
46 } // namespace nmx::apps::x005
void ex1()
ex1 Eigenschaften von komplexen Zahlen
Definition: x005.h:13
void ex2()
ex2 Rechnen mit komplexen Zahlen
Definition: x005.h:31