login  home  contents  what's new  discussion  bug reports help  links  subscribe  changes  refresh  edit

fricas
artanh:(Float) -> Float
Type: Void
fricas
artanh(x) ==
y := x
k := 1
for k in 1..precision() repeat
z := x^(2*k+1) / (2 * k + 1)
y := z + y
return y
Type: Void
fricas
ln2:() -> Float
Type: Void
fricas
ln2() == artanh(0.5) + artanh(1.0 / 7)
Type: Void
fricas
gamma:(NonNegativeInteger) -> Float
Type: Void
fricas
gamma(e) ==
precision(2 ^ e + 100)
n := 2.0 ^ e
eps := 1.0 / n
A := - e * ln2()
B := 1.0
U := A
V := 1.0
k := 1
repeat
B := B * n^2 / k^2
A := (A * n^2 / k + B) / k
if (A < eps) /\ (B < eps) then
return U / V
U := U + A
V := V + B
k := k + 1
Type: Void
fricas
fractions:(NonNegativeInteger, Integer) -> List(Integer)
Type: Void
fricas
fractions(e, n) ==
y := gamma(e)
l : List(Integer) := []
for i in 0..n repeat
f := floor(y)
l := cons(f, l)
y := y - f
if y > 0 then
y := 1 / y
reverse(l)
Type: Void

fricas
fractions(12, 1000)
fricas
Compiling function artanh with type Float -> Float
fricas
Compiling function ln2 with type () -> Float
fricas
Compiling function gamma with type NonNegativeInteger -> Float
fricas
Compiling function fractions with type (NonNegativeInteger,Integer)
-> List(Integer)
 (1)
Type: List(Integer)

 Subject:   Be Bold !! ( 14 subscribers )