Module:Infobox ET: Difference between revisions

Plumtree (talk | contribs)
mNo edit summary
Plumtree (talk | contribs)
m Testing convergents
Line 8: Line 8:


-- towards is one of: -1 (floor), 0 (nearest), 1 (ceil)
-- towards is one of: -1 (floor), 0 (nearest), 1 (ceil)
local function approximation(et, interval, towards, precomputed_approx)
local function approximation(et, interval, towards, precomputed_approx, convergement)
local approx = precomputed_approx or ET.approximate(et, interval, towards or 0)
local approx = precomputed_approx or ET.approximate(et, interval, towards or 0)
local tuning = et.size
local tuning = et.size
Line 15: Line 15:
end
end
local ratio = rat.new(approx, et.size)
local ratio = rat.new(approx, et.size)
local convergement_notice = ''
if convergement then
local converges = rat.converges(ratio, math.log(interval) / math.log(rat.as_float(et.equave)))
if converges then
convergement_notice = ' (' .. converges .. ')'
end
end
if rat.as_table(ratio)[1] ~= approx then
if rat.as_table(ratio)[1] ~= approx then
local link = rat.as_table(ratio)[2] .. et.suffix
local link = rat.as_table(ratio)[2] .. et.suffix
Line 26: Line 33:
end
end
local cents = u._round(ET.cents(et, approx), 6)
local cents = u._round(ET.cents(et, approx), 6)
return approx .. '\\' .. tuning .. ' (' .. cents .. '¢)' .. ratio
return approx .. '\\' .. tuning .. ' (' .. cents .. '¢)' .. ratio .. convergement_notice
end
end


Line 96: Line 103:
})
})
if not rat.eq(et.equave, rat.new(3, 2)) then
if not rat.eq(et.equave, rat.new(3, 2)) then
table.insert(infobox_data, {
if debug_mode then
'Fifth',
table.insert(infobox_data, {
approximation(et, 3/2)
'Fifth',
})
approximation(et, 3/2, nil, nil, true)
})
else
table.insert(infobox_data, {
'Fifth',
approximation(et, 3/2)
})
end
end
end
if not rat.eq(et.equave, 2) then
if not rat.eq(et.equave, 2) then