first commit

This commit is contained in:
douboer
2025-09-17 16:08:16 +08:00
parent 9395faa6b2
commit 3ff47c11d5
1318 changed files with 117477 additions and 0 deletions

23
perl/Examples/Chap6/sine Normal file
View File

@@ -0,0 +1,23 @@
###
### sine
###
## Chapter 6 section 7
# Approximate sin(x) using the first n terms of the power series
sub approx_sin {
my $n = shift;
my $x = shift;
my ($denom, $c, $num, $total) = (1, 1, $x, 0);
while ($n--) {
$total += $num / $denom;
$num *= $x*$x * -1;
$denom *= ($c+1) * ($c+2);
$c += 2;
}
$total;
}
1;