<commit_before>use v6;
use Test;
plan 48;

# L<S29/Num/"=item exp">

=begin pod

Basic tests for the exp() builtin

=end pod

#?rakudo skip 'named args'
{
    is_approx(exp(:exponent(5)), 148.4131591025766, 'got the exponent of 5');
    is_approx(exp(:exponent(0)), 1, 'exp(:exponent(0)) == 1');

    is_approx(exp(:exponent(1i*pi)), -1, 'exp(:exponent(i pi)) == -1');
    is_approx(exp(:exponent(-1i*pi)), -1, 'exp(:exponent(-i pi)) == -1');
}

is_approx(exp(5), 148.4131591025766, 'got the exponent of 5');
is_approx(exp(0), 1, 'exp(0) == 1');

is_approx(exp(1i*pi), -1, 'exp(i pi) == -1');
is_approx(exp(-1i*pi), -1, 'exp(-i pi) == -1');

{
    for 1 .. 20 {
	    my $arg = 2.0 * pi / $_;
	    is_approx(exp(1i * $arg), cos($arg) + 1i * sin($arg), 'expi == cos + i sin No. ' ~ $_);
	    is_approx(exp(1i * $arg) * exp(-1i * $arg), 1, 'exp(ix) * exp(-ix) == 1 No. ' ~ $_);
    }
}
# vim: ft=perl6<commit_msg>Various exp(x) tests<commit_after>use v6;
use Test;
plan 53;

# L<S29/Num/"=item exp">

=begin pod

Basic tests for the exp() builtin

=end pod

#?rakudo skip 'named args'
{
    is_approx(exp(:exponent(5)), 148.4131591025766, 'got the exponent of 5');
    is_approx(exp(:exponent(0)), 1, 'exp(:exponent(0)) == 1');

    is_approx(exp(:exponent(1i*pi)), -1, 'exp(:exponent(i pi)) == -1');
    is_approx(exp(:exponent(-1i*pi)), -1, 'exp(:exponent(-i pi)) == -1');
}

is_approx(exp(5), 148.4131591025766, 'got the exponential of 5');
is_approx(exp(0), 1, 'exp(0) == 1');
is_approx(exp(-1),  0.3678794411714, '1/e is correct');
is(exp(Inf), 'Inf', 'exp(Inf) == Inf');
is(exp(-Inf), 0, 'exp(-Inf) == 0');
is(exp(NaN), NaN, 'exp(NaN) == NaN');
is_approx(exp(log(100)),100, 'e^(log(100))=100');

is_approx(exp(1i*pi), -1, 'exp(i pi) == -1');
is_approx(exp(-1i*pi), -1, 'exp(-i pi) == -1');

{
    for 1 .. 20 {
	    my $arg = 2.0 * pi / $_;
	    is_approx(exp(1i * $arg), cos($arg) + 1i * sin($arg), 'expi == cos + i sin No. ' ~ $_);
	    is_approx(exp(1i * $arg) * exp(-1i * $arg), 1, 'exp(ix) * exp(-ix) == 1 No. ' ~ $_);
    }
}
# vim: ft=perl6
{'fraction_non_alphanumeric': 0.25853658536585367, 'fraction_numerical': 0.08585365853658537, 'mean_word_length': 3.80327868852459, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, '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': '3982828', 'n_tokens_mistral': 1023, 'n_tokens_neox': 910, 'n_words': 204}