小编Bum*_*zur的帖子

用理性指数计算复数

昨天我创建了这段可以计算z ^ n的代码,其中z是一个复数,n是任何正整数.

--snip--
float real = 0;
float imag = 0;

// d is the power the number is raised to [(x + yi)^d]
for (int n = 0; n <= d; n++) {
  if (n == 0) {
    real += pow(a, d);
  } else { // binomial theorem      
    switch (n % 4) {
      case 1: // i
        imag += bCo(d, n) * pow(a, d - n) * pow(b, n);
        break;
      case 2: // -1
        real -= bCo(d, n) …
Run Code Online (Sandbox Code Playgroud)

java math complex-numbers

5
推荐指数
2
解决办法
3315
查看次数

标签 统计

complex-numbers ×1

java ×1

math ×1