Module:Q-odd-limit intervals: Difference between revisions

ArrowHead294 (talk | contribs)
No edit summary
ArrowHead294 (talk | contribs)
No edit summary
Line 123: Line 123:
end
end


local function approx(steps, subgroup, monzo_list, t_title, approx_d, approx_v)
local function approx(steps, subgroup, monzo_list, t_title, approx_t)
local t_body_direct = {}
local t_body_direct = {}
local errlist_direct = {}
local errlist_direct = {}
Line 129: Line 129:
local errlist_val = {}
local errlist_val = {}
local val = {}
local val = {}
for i = 1, #subgroup do
for i = 1, #subgroup do
val[i] = utils._round_dec(steps*utils._log(subgroup[i], 2))
val[i] = utils._round_dec(steps*utils._log(subgroup[i], 2))
Line 181: Line 182:
t_body_val[i] = string.format("|-\n| %s\n| %s\n| %s", errlist_val[i].ratiocomp, errlist_val[i].error_abs_val, errlist_val[i].error_rel_val)
t_body_val[i] = string.format("|-\n| %s\n| %s\n| %s", errlist_val[i].ratiocomp, errlist_val[i].error_abs_val, errlist_val[i].error_rel_val)
end
end
 
return "{| class=\"wikitable center-all mw-collapsible mw-collapsed sortable\"\n" ..
local output = "{| class=\"wikitable center-all mw-collapsible mw-collapsed sortable\"\n" ..
"|+ style=\"white-space: nowrap;\" | " .. t_title .. approx_d .. "\n" ..
"|+ style=\"white-space: nowrap;\" | " .. t_title ..
"|-\n" ..
(approx_t == "direct" and " (approximated directly)" or " (approximated with val)") .. "\n" ..
"! class=\"unsortable\" | Interval and complement " ..
"!! Error (abs, [[Cent|¢]]) " ..
"!! Error (rel, [[Relative cent|%]])\n" ..
table.concat(t_body_direct, "\n") ..
"\n|}\n\n" ..
"{| class=\"wikitable center-all mw-collapsible mw-collapsed sortable\"\n" ..
"|+ style=\"white-space: nowrap;\" | " .. t_title .. approx_v .. "\n" ..
"|-\n" ..
"|-\n" ..
"! class=\"unsortable\" | Interval and complement " ..
"! class=\"unsortable\" | Interval and complement " ..
"!! Error (abs, [[Cent|¢]]) " ..
"!! Error (abs, [[Cent|¢]]) " ..
"!! Error (rel, [[Relative cent|%]])\n" ..
"!! Error (rel, [[Relative cent|%]])\n" ..
table.concat(t_body_val, "\n") ..
table.concat((approx_t == "direct" and t_body_direct or t_body_val), "\n") ..
"\n|}"
"\n|}"
return output
end
end


Line 211: Line 207:
local note = frame.args["note"]
local note = frame.args["note"]
local title = frame.args["title"]
local title = frame.args["title"]
local apx_d = " (approximated directly)"
local apx = string.lower(frame.args["apx"]:gsub("%s+", ""))
local apx_v = " (approximated with val)"
if title == nil or #title == 0 then
if title == nil or #title == 0 then
Line 236: Line 231:
end
end
end
end
out_str = out_str .. approx(steps, subgroup, monzo_list, title, apx_d, apx_v)
out_str = out_str .. approx(steps, subgroup, monzo_list, title, apx)
return out_str
return out_str
end
end


return p;
return p;