1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

参考ページ

準備

オンラインコンパイラを使用します。

ソースコード

sample.c
#include <stdio.h>
#include <complex.h>

#define NUM_TERMS 100000

double complex riemann_zeta(double complex s) {
    double complex zeta = 0.0 + 0.0 * I;
    for (int n = 1; n <= NUM_TERMS; n++) {
        zeta += 1.0 / cpow(n, s);
    }
    return zeta;
}

int main() {
    double s_real = 0.5;
    double s_imag = 14.135;
    double complex s = s_real + s_imag * I;  // 複素数を代入
    double complex result = riemann_zeta(s);
    printf("ζ(%f + %fi) = %f + %fi\n", creal(s), cimag(s), creal(result), cimag(result));
    return 0;
}

実行結果

console
ζ(0.500000 + 14.135000i) = -12.479785 + 18.551166i

[Execution complete with exit code 0]
1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?