C++ 中複數的 arg() 函式


複數是表示為 a + bi 的數字,其中 a 和 b 是實數。i是該數的虛部。

幅角是正軸與複數向量的夾角。對於複數

z = x + iy 用arg(z) 表示,

若要找到複數的幅角,則該複數頭的 complex 標標頭檔案中將具有一個名為arg() 的函式。

語法

arg(complex_number);

引數

該函式將一個複數作為輸入,以計算該複數的幅角。

返回值

該函式返回複數的幅角。

例項

 線上示例

#include<iostream>
#include<complex.h>
using namespace std;
int main (){
   double a = 12.0, b = 56.0;
   complex<double> complexnumber (a, b);
   cout<<"The argument of complex number "<<a<<" + i"<<b<< " is: ";
   cout<<arg(complexnumber)<<endl;
   return 0;
}

輸出

複數 12 + i56 的幅角是:1.3597

更新於:2019 年 10 月 24 日

瀏覽次數 559

開闢 職業生涯

完成課程獲得認證

開始使用
廣告