0

How can we solve below equation quickly with a computer free software? $$\left\{ \begin{array}{l} 1^5+1^4a+1^3b+1^2c+1d+e=1\\ 2^5+2^4a+2^3b+2^2c+2d+e=2\\ 3^5+3^4a+3^3b+3^2c+3d+e=3\\ 4^5+4^4a+4^3b+4^2c+4d+e=4\\ 5^5+5^4a+5^3b+5^2c+5d+e=5\\ \end{array} \right. $$

beetlej
  • 190

3 Answers3

2

If python is good for you, you can do it with following code:

#!/usr/bin/env python

import numpy as np
a = np.array([
    [1,   1,   1,   1,1],
    [2**4,2**3,2**2,2,1],
    [3**4,3**3,3**2,3,1],
    [4**4,4**3,4**2,4,1],
    [5**4,5**3,5**2,5,1]
])
b = np.array([
    [1-1**5],
    [2-2**5],
    [3-3**5],
    [4-4**5],
    [5-5**5]
])

result = np.linalg.solve(a,b)
print result

The output is: [[ -15.] [ 85.] [-225.] [ 275.] [-120.]]

which means the equation is:

$x^5-15x^4+85x^3-225x^2+275x-120 = 0$

lucky1928
  • 159
2

Indeed, any CAS solves it quickly. I tried Gröbner bases and obtained

$$ (a,b,c,d,e)=(-15,85,-225,275,-120). $$

On the other hand, the system explained itself immediately with this question.

Dietrich Burde
  • 130,978
1

This question is relatively hard to answer in such a small format. In essence what you have asked is how to solve $A\mathbf{x}=\mathbf{B}$ which is a humongous topic. For this particular scenario, involving a full-rank $5 \times 5$ matrix $A$, the solution is relatively fast. I would personally opt to use an LU Decomposition (process here), but you can also opt to use a number of other algorithms. Note, if you are to solve this numerically, which most programming solutions do, then you might run into some floating point errors, which are a common problem in scientific computing. However, you can get a more precise answer if you were to use a CAS like Mathematica. Finally, I will show you my implementation to solve this in Mathematica.

Mathematica

vecgen[n_] := {n^4, n^3, n^2, n^1, n^0};
A = {vecgen[1], vecgen[2], vecgen[3], vecgen[4], vecgen[5]};
x = {a, b, c, d, e};
B = {0, 2 - 2^5, 3 - 3^5, 4 - 4^5, 5 - 5^5};
Solve[A.x == B, x]
  • Never use Mathematica before, it's not free. which free software we can use? – beetlej Dec 05 '16 at 02:12
  • 1
    @beetlej Sage, python, octave, ... there's a lot of free software that can do basic matrix operations. In fact, lucky1928 gives some Python code in an answer below. –  Dec 05 '16 at 02:22