簡體   English   中英

C ++中用於復數的三角函數和雙曲函數

[英]Trigonometric and hyperbolic functions for complex number in c++

iam在我自己的班級上處理加,減,乘,除2個復數的復數,除了這種行為外,它還獲得了復數的三角函數和雙曲函數,請您幫我實現此三角函數和雙曲函數

這是我的行為,包括正弦函數,這種實現是真的嗎?

無效complex :: get(){

cout<<"Real part is:"<<real<<"\n"<<"Imaginary part is:"<<imag<<"\n";

} void complex :: add(complex&sum,const complex&num1,const complex&num2){

sum.real=num1.real+num2.real;
sum.imag=num1.imag+num2.imag;

}

void complex :: sub(complex&subt,const complex&num1,const complex&num2){

subt.real=num1.real-num2.real;

subt.imag=num1.imag-num2.imag;

}

void complex :: multi(復雜&product,const復雜&num1,const復雜&num2)

{

product.real=(num1.real*num2.real)-(num1.imag*num2.imag);

product.imag=(num1.real*num2.imag)+(num1.imag*num2.real);

}

無效complex :: div(complex&divis,const complex&num1,const complex&num2)

{

divis.real =(((num1.real num2.real)+(num1.imag num2.imag))/(((num2.real num2.real)+(num2.imag num2.imag)));

divis.imag =(((num1.imag num2.real)-(num1.real num2.imag))/(((num2.real num2.real)+(num2.imag num2.imag));

}

復雜complex :: _ sin(void)

{復合a; 復雜溫度 temp.real = SIN(a.real)* COSH(a.imag); temp.imag = COS(a.real)*的sinh(a.imag);

return temp;

}

本頁討論如何輕松地用數字的實數部分和復雜部分定義觸發函數。

該頁面以sinh和cosh(以e定義,因此您可以使用exp函數)開頭,它允許您定義其他雙曲函數。

這聽起來像是作業,但在這種情況下,標准庫已經在<complex>標頭中為您完成了工作。

如果您真的想重新實現它們,請參閱Jacob的答案,其中將包含小的gorey細節。

由於三角函數和雙曲線函數是根據復數冪定義的,因此首先要實現歐拉的恆等式(僅使用實三角函數就可以產生復雜的結果)。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM