Continued fraction/Arithmetic/G(matrix ng, continued fraction n1, continued fraction n2): Difference between revisions
Continued fraction/Arithmetic/G(matrix ng, continued fraction n1, continued fraction n2) (view source)
Revision as of 13:58, 11 March 2023
, 1 year ago→{{header|ObjectIcon}}
Line 3,902:
procedure main ()
initial
show ("golden ratio", golden_ratio, "(1 + sqrt(5))/2")
Line 3,933 ⟶ 3,931:
procedure initialize_global_CF ()
/golden_ratio := CF (create generate_constant (1))
/silver_ratio := CF (create generate_constant (2))
/frac_13_11 := r2cf (13, 11)
/frac_22_7 := r2cf (22, 7)
/one := i2cf (1)
/two := i2cf (2)
/three := i2cf (3)
/four := i2cf (4)
/sqrt2 := cf_sub (silver_ratio, one)
return
end
Line 3,972 ⟶ 3,970:
local j, term
if *memo <= i then
if \terminated then
fail
else
{
every j := *memo to i do
if \ (term := @term_gen) then
put (memo, term)
Line 4,008:
public to_string (max_terms) # Make a human-readable string.
local s, i, done, term
static separators
initial separators := ["", ";", ","]
/max_terms := (\default_max_terms | 20)
Line 4,028 ⟶ 4,031:
else
{
s ||:=
i +:= 1
}
}
return s
end
Line 4,050 ⟶ 4,049:
public new (a12, a1, a2, a, b12, b1, b2, b)
▲ initial {
practically_infinite_number := 2^64▼
much_too_big_number := 2^512▼
▲ }
na12 := a12
na1 := a1
Line 4,119 ⟶ 4,114:
}
if \absorb_term_from === 'x' then
{
term := @xsource
new_a2 := a12; new_a := a1
Line 4,171 ⟶ 4,167:
if /cf then
# Generate only "
source := create generate_constant (&null)
else if type(cf) == "co-expression" then
Line 4,183 ⟶ 4,179:
private infinitized (term)
if abs (term) >= abs (practically_infinite_number) then
term := &null
Line 4,189 ⟶ 4,186:
private too_big (num)
if abs (num) < abs (much_too_big_number) then fail
return num
|