<commit_before>#!/usr/bin/perl

# Calculate zeta(2n) using a closed-form formula.

# See also:
#   https://en.wikipedia.org/wiki/Riemann_zeta_function

use 5.010;
use strict;
use warnings;

use lib qw(../lib);
use experimental qw(signatures);
use Math::AnyNum qw(tau bernfrac factorial pi ipow2);

sub zeta_2n($n) {
    (-1)**($n + 1) * bernfrac(2 * $n) / factorial(2 * $n) * tau**(2 * $n) / 2;
}

for my $i (1 .. 30) {
    say "zeta(", 2 * $i, ") = ", zeta_2n($i);
}<commit_msg>modified:   examples/zeta_2n_fast.pl<commit_after>#!/usr/bin/perl

# Calculate zeta(2n) using a closed-form formula.

# See also:
#   https://en.wikipedia.org/wiki/Riemann_zeta_function

use 5.010;
use strict;
use warnings;

use lib qw(../lib);
use experimental qw(signatures);
use Math::AnyNum qw(tau bernfrac factorial);

sub zeta_2n($n) {
    (-1)**($n + 1) * bernfrac(2 * $n) / factorial(2 * $n) * tau**(2 * $n) / 2;
}

for my $i (1 .. 30) {
    say "zeta(", 2 * $i, ") = ", zeta_2n($i);
}
{'fraction_non_alphanumeric': 0.20267489711934156, 'fraction_numerical': 0.037037037037037035, 'mean_word_length': 3.546728971962617, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4116783', 'n_tokens_mistral': 439, 'n_tokens_neox': 411, 'n_words': 99}