Add tasks for all the new languages
This commit is contained in:
parent
9dc3c2bb62
commit
bba7bfd280
13208 changed files with 134745 additions and 0 deletions
19
Task/Gamma-function/Sidef/gamma-function-1.sidef
Normal file
19
Task/Gamma-function/Sidef/gamma-function-1.sidef
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
var a = [ 1.00000_00000_00000_00000, 0.57721_56649_01532_86061, -0.65587_80715_20253_88108,
|
||||
-0.04200_26350_34095_23553, 0.16653_86113_82291_48950, -0.04219_77345_55544_33675,
|
||||
-0.00962_19715_27876_97356, 0.00721_89432_46663_09954, -0.00116_51675_91859_06511,
|
||||
-0.00021_52416_74114_95097, 0.00012_80502_82388_11619, -0.00002_01348_54780_78824,
|
||||
-0.00000_12504_93482_14267, 0.00000_11330_27231_98170, -0.00000_02056_33841_69776,
|
||||
0.00000_00061_16095_10448, 0.00000_00050_02007_64447, -0.00000_00011_81274_57049,
|
||||
0.00000_00001_04342_67117, 0.00000_00000_07782_26344, -0.00000_00000_03696_80562,
|
||||
0.00000_00000_00510_03703, -0.00000_00000_00020_58326, -0.00000_00000_00005_34812,
|
||||
0.00000_00000_00001_22678, -0.00000_00000_00000_11813, 0.00000_00000_00000_00119,
|
||||
0.00000_00000_00000_00141, -0.00000_00000_00000_00023, 0.00000_00000_00000_00002 ];
|
||||
|
||||
func gamma(x) {
|
||||
var y = (x - 1);
|
||||
1 / a.reverse.reduce {|sum, an| sum*y + an};
|
||||
}
|
||||
|
||||
for i in 1..10 {
|
||||
say ("%.14e" % gamma(i/3));
|
||||
}
|
||||
38
Task/Gamma-function/Sidef/gamma-function-2.sidef
Normal file
38
Task/Gamma-function/Sidef/gamma-function-2.sidef
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
func gamma(z) {
|
||||
var epsilon = 0.0000001
|
||||
func withinepsilon(x) {
|
||||
abs(x - abs(x)) <= epsilon
|
||||
}
|
||||
|
||||
var p = [
|
||||
676.5203681218851, -1259.1392167224028,
|
||||
771.32342877765313, -176.61502916214059,
|
||||
12.507343278686905, -0.13857109526572012,
|
||||
9.9843695780195716e-6, 1.5056327351493116e-7,
|
||||
]
|
||||
|
||||
var result;
|
||||
z = Complex(z)
|
||||
const pi = Complex.pi
|
||||
|
||||
if (z.real < 0.5) {
|
||||
result = (pi / (sin(pi * z) * gamma(Complex(1) - z)))
|
||||
}
|
||||
else {
|
||||
z -= 1
|
||||
var x = 0.99999999999980993
|
||||
|
||||
p.each_kv { |i, v|
|
||||
x += v/(z + i + 1)
|
||||
}
|
||||
|
||||
var t = (z + p.len - 0.5)
|
||||
result = (sqrt(pi*2) * t**(z+0.5) * exp(-t) * x)
|
||||
}
|
||||
|
||||
withinepsilon(result.im) ? result.real : result
|
||||
}
|
||||
|
||||
for i in 1..10 {
|
||||
say ("%.14e" % gamma(i/3));
|
||||
}
|
||||
11
Task/Gamma-function/Sidef/gamma-function-3.sidef
Normal file
11
Task/Gamma-function/Sidef/gamma-function-3.sidef
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
define e = Math.e;
|
||||
define pi = Math.pi;
|
||||
|
||||
func Γ(t) {
|
||||
t < 20 ? (__FUNC__(t + 1) / t)
|
||||
: (Math.sqrt(2*pi*t) * Math.pow(t/e + 1/(12*e*t), t) / t);
|
||||
}
|
||||
|
||||
for i in 1..10 {
|
||||
say ("%.14e" % Γ(i/3));
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue