Module:Limits: Difference between revisions

Plumtree (talk | contribs)
m Bugfix
Plumtree (talk | contribs)
mNo edit summary
Line 3: Line 3:


-- multiply the ratio by a power of `equave` so that it lies within [1; equave)
-- multiply the ratio by a power of `equave` so that it lies within [1; equave)
local function canonical(a, equave)
function p.canonical(a, equave)
equave = equave or 2
equave = equave or 2
if type(a) == 'number' then
if type(a) == 'number' then
Line 24: Line 24:
for m = 1, q, 2 do
for m = 1, q, 2 do
local a = rat.new(n, m)
local a = rat.new(n, m)
a = canonical(a, equave)
a = p.canonical(a, equave)
local key = rat.as_ratio(a)
local key = rat.as_ratio(a)
ratios[key] = a
ratios[key] = a
Line 55: Line 55:
local c_approx = approximate(c)
local c_approx = approximate(c)
c = canonical(c, equave)
c = p.canonical(c, equave)
local c_key = rat.as_ratio(c)
local c_key = rat.as_ratio(c)
if ratios[c_key] then
if ratios[c_key] then