Module:Rational: Difference between revisions
m Todo |
Unify the format for S-expressions |
||
| Line 174: | Line 174: | ||
end | end | ||
-- is it Sk*S(k+1) or Sk/S(k+1) or Sk^2*S(k+1) or Sk*S(k+1)^2? | -- is it Sk*S(k + 1) or Sk/S(k + 1) or 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] | ||
| Line 180: | Line 180: | ||
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(r1, r2)) then | ||
table.insert(expressions, "S" .. k .. " | table.insert(expressions, "S" .. k .. "⋅S" .. (k + 1)) | ||
end | end | ||
if p.eq(a, p.div(r1, r2)) then | if p.eq(a, p.div(r1, r2)) then | ||
table.insert(expressions, "S" .. k .. " / S" .. (k + 1)) | table.insert(expressions, "S" .. k .. "/S" .. (k + 1)) | ||
end | end | ||
if p.eq(a, p.mul(p.pow(r1, 2), r2)) then | if p.eq(a, p.mul(p.pow(r1, 2), r2)) then | ||
table.insert(expressions, "S" .. k .. "<sup>2</sup> | table.insert(expressions, "S" .. k .. "<sup>2</sup>⋅S" .. (k + 1)) | ||
end | end | ||
if p.eq(a, p.mul(r1, p.pow(r2, 2))) then | if p.eq(a, p.mul(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 | ||
end | end | ||
-- is it Sk/S(k+2)? | -- is it Sk/S(k + 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] | ||
| Line 200: | Line 200: | ||
if r1 and r2 then | if r1 and r2 then | ||
if p.eq(a, p.div(r1, r2)) then | if p.eq(a, p.div(r1, r2)) then | ||
table.insert(expressions, "S" .. k .. " / S" .. (k + 2)) | table.insert(expressions, "S" .. k .. "/S" .. (k + 2)) | ||
end | end | ||
end | end | ||
end | end | ||
-- is it S(k-1)*Sk*S(k+1)? | -- is it S(k - 1)*Sk*S(k + 1)? | ||
for _, k in ipairs(superparticular_indices) do | for _, k in ipairs(superparticular_indices) do | ||
local r1 = superparticular_ratios[k - 1] | local r1 = superparticular_ratios[k - 1] | ||
| Line 212: | Line 212: | ||
if r1 and r2 and r3 then | if r1 and r2 and r3 then | ||
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) .. " | table.insert(expressions, "S" .. (k - 1) .. "⋅S" .. k .. "⋅S" .. (k + 1)) | ||
end | end | ||
end | end | ||