# Solving a system of four polynomial equations for an expression

Given $$a,b,x,y \in \mathbb{R}$$ and

$$a x + b y = 3, \quad a x^3 + b y^3 = 16$$

$$a x^2 + b y^2 = 7, \quad a x^4 + b y^4 =42$$

find

$$a x^5 + b y^5$$

The direct approach doesn't seem to work:

Solve[a x + b y == 3 \[And] a x^3 + b y^3 == 16 \[And]
a x^2 + b y^2 == 7 \[And] a x^4 + b y^4 == 42 \[And]
a x^5 + b y^5 == k,
{k}, Reals]


(Incidentally, the answer is $$20$$.)

What tricks or constraints or substitutions would allow Mathematica to solve this problem?

• One quick way: In[227]:= GroebnerBasis[{a*x + b*y - 3, a*x^3 + b*y^3 - 16, a*x^2 + b*y^2 - 7, a*x^4 + b*y^4 - 42, a*x^5 + b*y^5 - val}, val, {a, b, x, y}][[1]] Out[227]= -20 + val Aug 6, 2021 at 15:09

k /. Solve[
a x + b y == 3 \[And] a x^3 + b y^3 == 16 \[And]
a x^2 + b y^2 == 7 \[And] a x^4 + b y^4 == 42 \[And]
a x^5 + b y^5 == k, {a, b, x, y, k}, Reals][[1]] // Simplify


Also, not listing any variables causes it to treat all free symbols as variables:

k /. Solve[a x + b y == 3 \[And] a x^3 + b y^3 == 16 \[And]
a x^2 + b y^2 == 7 \[And] a x^4 + b y^4 == 42 \[And]
a x^5 + b y^5 == k, Reals] // Simplify

• Oh... thanks! ($\checkmark$) Aug 5, 2021 at 17:19

Simplify[a*x^5 + b*y^5,Assumptions -> a*x + b*y == 3 && a*x^3 + b*y^3 == 16 &&
a*x^2 + b*y^2 == 7 &&   a*x^4 + b*y^4 == 42]


$$20$$

• separate the variable and parametric.
Solve[a x + b y == 3 ∧ a x^3 + b y^3 == 16 ∧
a x^2 + b y^2 == 7 ∧ a x^4 + b y^4 == 42 ∧
a x^5 + b y^5 == k, {k}, {a, b, x, y}]

• useReduce
Reduce[a x + b y == 3 ∧ a x^3 + b y^3 == 16 ∧
a x^2 + b y^2 == 7 ∧ a x^4 + b y^4 == 42 ∧
a x^5 + b y^5 == k, {k}]

• use ForAll
ForAll[{a, b, x, y},
a x + b y == 3 ∧ a x^3 + b y^3 == 16 ∧
a x^2 + b y^2 == 7 ∧ a x^4 + b y^4 == 42, a x^5 + b y^5 == k]
Resolve[%] // Simplify


Appendix

we can calculate all the r[n]=a x^n + b y^n if we provide the initial condition r[1] == 3, r[2] == 7, r[3] == 16, r[4] == 42.

By the uniqueness of such r[n],we only need to find a sequence that satisfied such condition. Here we use the second order difference equation.

rsol = RSolve[{r[n + 2] == p*r[n + 1] + q*r[n]}, r, n][[1]];
sol = Solve[{r[1] == 3, r[2] == 7, r[3] == 16, r[4] == 42} /.
rsol][[1]];
r /. rsol /. sol
% /@ Range[8] // Simplify


$$\frac{2^{-n-1} \left(-14-2 \sqrt{87}\right)^n}{4263+457 \sqrt{87}}+\frac{1}{19} \left(49-\frac{19}{4263+457 \sqrt{87}}\right) 2^{-n-1} \left(2 \sqrt{87}-14\right)^n$$

{3, 7, 16, 42, 20, 1316, -17664, 297304}

• I like the completeness. Thanks. ($+1$) Aug 5, 2021 at 22:53
• FindSequenceFunction[{3, 7, 16, 42, 20, 1316}] /@ Range[8] // Simplify Aug 5, 2021 at 23:34
• Or shorter Reduce[a x + b y == 3 \[And] a x^3 + b y^3 == 16 \[And] a x^2 + b y^2 == 7 \[And] a x^4 + b y^4 == 42 \[And] a x^5 + b y^5 == k]. Aug 6, 2021 at 5:15