From Daniel Lichtblau's answer, Working with symmetric polynomials, it's easy to do as much as is specified. I interpret "factor" to mean "write in terms of," but I'm not sure exactly what quadratic terms are implied.
subs = {q1 -> (k12^2 - k21^2), q2 -> (k22 - k11)^2, q3 -> (k12 + k21)^2};
polys = Subtract @@@ subs;
gb = GroebnerBasis[polys, {x, y}];
expr = (C1*
R*(10*k12*k21 - 20*k11*k22 - k21^2*Cos[4*t] + 10*k11^2 + 10*k12^2 +
3*k21^2 + 10*k22^2 - 4*k12*k21*Cos[2*t] - 2*k12*k21*Cos[4*t] +
4*k11*k21*Sin[2*t] + 2*k11*k21*Sin[4*t] - 4*k21*k22*Sin[2*t] -
2*k21*k22*Sin[4*t]))/32;
PolynomialReduce[expr, gb, {k11, k12, k21, k22}][[2]]
If you want Mathematica to find some way to express expr
in terms of quadratic expressions in the k
s, create a list qs
of the possible forms you would consider acceptable and create variables q[i]
, i = 1, ...
up to the number of forms in qs
. Then the above method will find a solution, but it won't be unique.
ks = {k11, k12, k21, k22};
qs = Flatten@
MapThread[{#1^2 - #2^2, #1^2 + #2^2, (#1 - #2)^2, (#1 + #2)^2} &,
Transpose@Subsets[ks, {2}]];
subs = Thread[Array[q, Length@qs] -> qs];
polys = Subtract @@@ subs;
gb = GroebnerBasis[polys, {x, y}];
expr = (C1*
R*(10*k12*k21 - 20*k11*k22 - k21^2*Cos[4*t] + 10*k11^2 +
10*k12^2 + 3*k21^2 + 10*k22^2 - 4*k12*k21*Cos[2*t] -
2*k12*k21*Cos[4*t] + 4*k11*k21*Sin[2*t] + 2*k11*k21*Sin[4*t] -
4*k21*k22*Sin[2*t] - 2*k21*k22*Sin[4*t]))/32;
quadReduced = PolynomialReduce[expr, gb, {k11, k12, k21, k22}~Join~Array[q, Length@qs]][[2]]
Use
quadReduce /. subs
to get expr
back.