Module:JI ratios: Difference between revisions

Ganaram inukshuk (talk | contribs)
m as_text -> as_string
Ganaram inukshuk (talk | contribs)
Disable complements-only search again...
Line 7: Line 7:


-- TODO:
-- TODO:
-- Address complements-only option for int-limit search; this may require a
-- Address complements-only search option not working; this may require
-- different search algorithm
-- searching, then filtering out.


-- Template for handling multiple entry of JI ratios into a template, and for
-- Template for handling multiple entry of JI ratios into a template, and for
Line 50: Line 50:
-- - Whether it's within an int limit (required)
-- - Whether it's within an int limit (required)
-- - Whether it's below a tenney height (default height is infinity)
-- - Whether it's below a tenney height (default height is infinity)
-- - Whether its complement meets the above criteria (default is
-- NOTE: ratio is not of the form defined by module:rational, but equave is!
--  to include it regardless of whether its complement does)
function p.ratio_within_search(ratio, equave, fine_search_args)
function p.ratio_within_search(ratio, equave, fine_search_args)
local complement = rat.mul(rat.new(ratio[2], ratio[1]), equave)
local a, b = rat.as_pair(complement)
-- Ratio, complement, and equave as float
-- Ratio, complement, and equave as float
Line 68: Line 65:
local ratio_within_tenney_height = math.log(ratio[1] * ratio[2]) / math.log(2) <= tenney_height
local ratio_within_tenney_height = math.log(ratio[1] * ratio[2]) / math.log(2) <= tenney_height
local ratio_within_equave = ratio_as_float <= equave_as_float
local ratio_within_equave = ratio_as_float <= equave_as_float
local ratio_within_search = ratio_within_int_limit and ratio_within_tenney_height and ratio_within_equave
local comp_within_search = true
return ratio_within_int_limit and ratio_within_tenney_height and ratio_within_equave
if comps_only then
-- A ratio's complement will be necessarily less than or equal to the
-- equave, so no need to check if it's within the equave.
local comp_within_int_limit = math.max(a, b) <= int_limit
local comp_within_tenney_height = math.log(a * b) / math.log(2) <= tenney_height
comp_within_search = comp_within_int_limit and comp_within_tenney_height
end
return ratio_within_search and comp_within_search
end
end


Line 218: Line 205:
if gcd == 1 then
if gcd == 1 then
local ratio = {numerator, denominator}
local ratio = {numerator, denominator}
if p.ratio_within_search(ratio, equave, fine_search_args) then
if p.ratio_within_search(ratio, equave, fine_search_args) then
table.insert(ratios, ratio)
table.insert(ratios, ratio)
Line 232: Line 218:
ratios[i] = rat.new(ratios[i][1], ratios[i][2])
ratios[i] = rat.new(ratios[i][1], ratios[i][2])
end
end
-- Sort ratios
table.sort(ratios, rat.lt)
return ratios
return ratios
Line 426: Line 415:


local equave = rat.new(2,1)
local equave = rat.new(2,1)
local fine_search_args = {
local fine_search_args = p.parse_search_args("Subgroup: 2.3.5.7.13; Int Limit: 20; Complements Only: 1; Tenney Height: 100000000")
["Int Limit"]        = 27,
return p.ratios_as_string(p.search_by_args_within_equave(equave, fine_search_args))
["Tenney Height"]    = 1/0,
["Complements Only"] = true
}
return p.ratios_as_text(p.search_by_prime_limit_within_equave(7, equave, fine_search_args))
--return p.ratio_within_search({9,8}, equave, fine_search_args)
--return p.ratio_within_search({16,13}, equave, fine_search_args) and p.ratio_within_search({8,13}, equave, fine_search_args)
end
end


return p
return p