2
$\begingroup$

This is similar to the how-to-replace-variable-with-power question, but here it involves two variables with different power combinations.

This quesion arises from paper forward kinematics of the 6-6 Stewart platform. I’m trying to solve the forward kinematics problem with Mathematica. Mathematica really helped—I’ve nearly nailed it. However I’m stuck on the final key step.

enter image description here

enter image description here

enter image description here

I cannot eliminate $c1$ $c2$ with power {{8,0},{7,1},{6,2},...}.

ClearAll[c1, c2] phi3A29= U1 + {U2j0, U2j1, U2j2}.Table[c1^(2 - j) c2^j, {j, 0, 2}] + {U3j0, U3j1, U3j2, U3j3, U3j4}.Table[c1^(4 - j) c2^j, {j, 0, 4}] + {U4j0, U4j1, U4j2, U4j3, U4j4, U4j5, U4j6}. Table[c1^(6 - j) c2^j, {j, 0, 6}] + {U5j0, U5j1, U5j2, U5j3, U5j4, U5j5, U5j6, U5j7, U5j8}. Table[c1^(8 - j) c2^j, {j, 0, 8}] ruleA32= Thread[Table[c1^(4 - j) c2^j, {j, 0, 4}] -> Table[Symbol["H" <> ToString[j] <> ToString[jj]], {j, 0, 4}, {jj, 1, 3}] . {c1^2, c1 c2, c2^2}/E0]; ruleA32// MatrixForm nu = phi3A29 //. ruleA32// Together // Numerator co = CoefficientRules[nu, {c1, c2}]; co // Keys 

I supposed that $co$ should be $\{\{2,0\}, \{1,1\}, \{0,2\}, \{0,0\}\}$, which matches equation (34) in the paper, the order does not matter in $\{ \}$. I have a rough idea of what’s causing the issue, but I’d like to make better use of Mathematica to solve it. Could anyone help me out? Thanks in advance!

a rather simple (and maybe a bit clumsy) idea : manually write out a substitution rule for $c1^{8-j}c2^j$ using combinations of ${c1}^{4-j}{c2}^j$, $c1^2$ and $c2^2$.

$\endgroup$
1
  • 3
    $\begingroup$ Change Rule to a subtraction in ruleA32. Then do red = PolynomialReduce[phi3A29, ruleA32, c3, {c1, c2}, MonomialOrder -> EliminationOrder, CoefficientDomain -> RationalFunctions][[2]] $\endgroup$ Commented Jun 3 at 18:32

2 Answers 2

3
$\begingroup$

PolynomialReduce[] seems made to order:

nu = Last[PolynomialReduce[phi3A29, Subtract @@@ ruleA32, {c1, c2}, MonomialOrder -> DegreeLexicographic]]; co = CoefficientRules[nu, {c1, c2}]; co // Keys (* {{2, 0}, {1, 1}, {0, 2}, {0, 0}} *) 

An alternative is to use MonomialOrder -> DegreeReverseLexicographic, and it produces the same coefficient rules.

$\endgroup$
2
$\begingroup$

As far as I understand your question, you want to replace all c1^i c2^j.. terms with i+j==4 by your rules.

For a start, replace works purely structural, it does not make any evaluation. E.g. consider:

c (c+1) /. c^2->a c (1 + c) 

There is no c^2 to match. Now consider e.g. (For readability I replaced E[EmptyCircle] by E0):

phi3A29 //. ruleA32 ... (c2^2 (c1^2 H01 + c1 c2 H02 + c2^2 H03) U4j2)/E0 ... 

Here we have the same problem as above. However, you may use "Expand":

phi3A29 //. ruleA32 // Expand ... (c1^2 c2^2 H01 U4j2)/E0 + (c1 c2^3 H02 U4j2)/E0 + (c2^4 H03 U4j2)/E0 ... 

Now a second application of the rules will work:

... (phi3A29 //. ruleA32 // Expand ) //. ruleA32 (H01 (c1^2 H21 + c1 c2 H22 + c2^2 H23) U4j2)/E0^2 + (H02 (c1^2 H31 + c1 c2 H32 + c2^2 H33) U4j2)/E0^2 + (H03 (c1^2 H41 + c1 c2 H42 + c2^2 H43) U4j2)/E0^2 ... 

Note the braces. We need this because /. has a higher precedence as //.... Finally we would then have:

enter image description here

$\endgroup$
1
  • $\begingroup$ Thank you for your help — it might not quite solve the problem, but it reminded me of a rather simple (and maybe a bit clumsy) idea: I think I can manually write out a substitution rule for $c1^{8-j}c2^j$ using combinations of ${c1}^{4-j}{c2}^j$, $c1^2$ and $c2^2$. $\endgroup$ Commented Jun 3 at 13:13

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.