I don't do much algebra in Mathematica and was surprised to discover, while attempting to answer this question, that I had no idea how to factor out an expression from a polynomial.
The question was, given
τ = (1 + Sqrt[5])/2 (* golden ratio *)
and
coords = {{0,0,1},{0,1/2 (1+Sqrt[5]),-1},{1/2 (1+Sqrt[5]),1/2 (-1-Sqrt[5]),1/2 (1+Sqrt[5])},
{1/2 (-1-Sqrt[5]),0,1/2 (1+Sqrt[5])},{1/2 (1+Sqrt[5]),1,1/2 (-1-Sqrt[5])},{1/2 (-1-Sqrt[5]),
1/2 (3+Sqrt[5]),1/2 (-1-Sqrt[5])},{1/2 (3+Sqrt[5]),-1,0},{1,1/2 (-3-Sqrt[5]),
1/2 (3+Sqrt[5])},{1/2 (-3-Sqrt[5]),1/2 (1+Sqrt[5]),0},{-1,1/2 (-1-Sqrt[5]),1/2 (3+Sqrt[5])},
{1,1/2 (1+Sqrt[5]),1/2 (-3-Sqrt[5])},{-1,1/2 (3+Sqrt[5]),1/2 (-3-Sqrt[5])},{1/2 (3+Sqrt[5]),
1/2 (-1-Sqrt[5]),0},{1/2 (1+Sqrt[5]),1/2 (-3-Sqrt[5]),1/2 (1+Sqrt[5])},
{1/2 (-3-Sqrt[5]),1,0},{1/2 (-1-Sqrt[5]),-1,1/2 (1+Sqrt[5])},{1/2 (1+Sqrt[5]),
0,1/2 (-1-Sqrt[5])},{1/2 (-1-Sqrt[5]),1/2 (1+Sqrt[5]),1/2 (-1-Sqrt[5])},
{0,1/2 (-1-Sqrt[5]),1},{0,0,-1}}
how can coords
be expressed in terms of τ
.
I came up with
Map[
If[
AtomQ@#,
#,
(Simplify[#/τ]*HoldForm@τ) /. {
τ -> HoldForm@τ,
-τ -> HoldForm@-τ}] &,
coords, {2}]
but obviously this is not a generally robust solution, and it is ugly.
I assume there must be better ways to do this. This overlaps somewhat with the original question, but I am hoping for a more comprehensive explanation than that question requires.
coords /. (Sqrt[5]) -> (2 \[Tau] - 1) // Simplify
. Remember toClearAll[\[Tau]]
earlier. $\endgroup$GoldenRatio
relations. $\endgroup$\[Tau]
first. Then this ugly hack works:Map[(a \[Tau]^b /. First@FullSimplify[Quiet@Solve[a GoldenRatio^b == # && (a == 1 || a == 0 || a == -1) && b >= 0 && b \[Element] Integers, {a, b}, Reals], b \[Element] Integers && b >= 0]) &, coords, {2}]
$\endgroup$