Module:Rational: Difference between revisions
m Safer parsing |
m find_S_expression() improved |
||
Line 164: | Line 164: | ||
end | end | ||
-- is it | -- is it Sk^2 * S(k+1) or Sk * S(k+1)^2? | ||
for _, k in ipairs(superparticular_indices) do | for _, k in ipairs(superparticular_indices) do | ||
local r1 = superparticular_ratios[k] | local r1 = superparticular_ratios[k] | ||
local r2 = superparticular_ratios[k + 1] | local r2 = superparticular_ratios[k + 1] | ||
if r1 and r2 then | if r1 and r2 then | ||
if p.eq(a, p.mul(r1, r2)) then | if p.eq(a, p.mul(p.pow(r1, 2), r2)) then | ||
table.insert(expressions, 'S' .. k .. ' × S' .. (k + 1)) | table.insert(expressions, 'S' .. k .. '<sup>2</sup> × S' .. (k + 1)) | ||
end | end | ||
if p.eq(a, p.div(r1, r2)) then | if p.eq(a, p.div(r1, p.pow(r2, 2))) then | ||
table.insert(expressions, 'S' .. k .. ' | table.insert(expressions, 'S' .. k .. ' * S' .. (k + 1) .. '<sup>2</sup>') | ||
end | end | ||
end | end | ||
Line 186: | Line 186: | ||
if p.eq(a, p.mul(r1, p.mul(r2, r3))) then | if p.eq(a, p.mul(r1, p.mul(r2, r3))) then | ||
table.insert(expressions, 'S' .. (k - 1) .. ' × S' .. k .. ' × S' .. (k + 1)) | table.insert(expressions, 'S' .. (k - 1) .. ' × S' .. k .. ' × S' .. (k + 1)) | ||
end | end | ||
end | end | ||
Line 207: | Line 196: | ||
local r2 = superparticular_ratios[k2] | local r2 = superparticular_ratios[k2] | ||
if k1 <= k2 and p.eq(a, p.mul(r1, r2)) then | if k1 <= k2 and p.eq(a, p.mul(r1, r2)) then | ||
table.insert(expressions, 'S' .. k1 .. ' × S' .. k2) | |||
end | end | ||
if k1 <= k2 and p.eq(a, p.div(r1, r2)) then | if k1 <= k2 and p.eq(a, p.div(r1, r2)) then | ||
table.insert(expressions, 'S' .. k1 .. ' / S' .. k2) | |||
end | end | ||
end | end |