2
$\begingroup$

An AIME competition question is:

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?

$\endgroup$
1
  • $\begingroup$ 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 $\endgroup$ Aug 6, 2021 at 15:09

3 Answers 3

2
$\begingroup$

Listing all your variables works:

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
$\endgroup$
1
  • $\begingroup$ Oh... thanks! ($\checkmark$) $\endgroup$ Aug 5, 2021 at 17:19
3
$\begingroup$

I think similar questions were asked and answered a lot.

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$

$\endgroup$
3
$\begingroup$
  • 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}

$\endgroup$
3
  • $\begingroup$ I like the completeness. Thanks. ($+1$) $\endgroup$ Aug 5, 2021 at 22:53
  • $\begingroup$ FindSequenceFunction[{3, 7, 16, 42, 20, 1316}] /@ Range[8] // Simplify $\endgroup$
    – cvgmt
    Aug 5, 2021 at 23:34
  • $\begingroup$ 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]. $\endgroup$
    – user64494
    Aug 6, 2021 at 5:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.