I have been working with Lagrange polynomials and I have some very complicated calculations such as $$(x-1)(x-2)(x-3)(x-4)(x-5)(x-22)$$ Can you suggest an (possibly give url) online application which will give out the answer. Also I have Wolfram Mathematica 8, but I do not know how to use it.

  • 2
    $\begingroup$ If only calculations were always as complicated as that! $\endgroup$ – Douglas B. Staple Apr 23 '13 at 17:22

The website Wolfram Alpha will do it for you. Just type, e.g.

$$\tt expand (x-1)*(x-2)*(x-3)*(x-4); $$

I typed that in, and here's what I got. Your expression will, of course, be a bit longer.

If you have a product, say

$$\prod_{n=1}^{10} \left(x-\frac{1}{n}\right) = \left(x-1\right)\left(x-\frac{1}{2}\right)\left(x-\frac{1}{3}\right)\cdots \left(x-\frac{1}{10}\right) $$

it'll even do that for you. Just type:

$$\tt expand \ \ (product \ (x-1/n) \ , \ n=1..10)$$

I did that, and here's what I got.

  • $\begingroup$ @ciceksizkakarot You're welcome! $\endgroup$ – Fly by Night Apr 23 '13 at 16:46
  • $\begingroup$ I believe that Mathematica has the same syntax, so you could equally type the same commands into there. $\endgroup$ – vadim123 Apr 23 '13 at 17:55
  • 1
    $\begingroup$ @vadim123 Wolfram does not seem to have a set syntax. I have never used Mathematica. I use Maple, and use Maple syntax, and it seems to understand it. In fact, you can type almost anything, e.g. $\tt product \ of \ (x-n) \ for \ n \ from \ 1 \ to \ 10$ and that'll also work. $\endgroup$ – Fly by Night Apr 23 '13 at 18:05
  • $\begingroup$ @vadim123 I have also used WolframAlpha with Maple syntax and it usually works, unlike Mathematica where I am pretty certain you must use Mathematica syntax. $\endgroup$ – Stefan Smith Apr 24 '13 at 1:13

It's an interesting problem. You can either expand it with any application (online or desktop) but if you want to know how to write it, you should check what is called the "Guelf expansion". It states that:

$$\displaystyle\prod_{i=1}^n(x-\lambda_i)=x^n+\sum_{k=1}^n\left((-1)^k x^{n-k}C_k(\lambda_1,\ldots,\lambda_n)\right)$$

Where $C_k$ is the sum of the products of all possible $k$-tuples from the set $\{\lambda_1,\ldots,\lambda_n\}$. There is exactly ${n \choose k}$ possible tuples for each $C_k$.

Example for $n=4$: $$P(x)=(x-a_1)(x-a_2)(x-a_3)(x-a_4)$$

The expanded polynomial is:


And the coefficients are given by:

$$\cases{C_1=a_1+a_2+a_3+a_4 \\ C_2=a_1a_2+a_1a_3+a_1a_4+a_2a_3+a_2a_4+a_3a_4 \\ C_3=a_1a_2a_3+a_1a_2a_4+a_1a_3a_4+a_2a_3a_4 \\ C_4=a_1a_2a_3a_4}$$

In your case you get:


$$\mbox{With}\space\cases{C_1=1+2+3+4+5+22 \\ C_2=1\cdot2+1\cdot3+1\cdot4+1\cdot5+1\cdot22+2\cdot3+\cdots \\ C_3=1\cdot2\cdot3+1\cdot2\cdot4+1\cdot2\cdot5+1\cdot2\cdot22+1\cdot3\cdot4+\cdots \\C_4=1\cdot2\cdot3\cdot4+1\cdot2\cdot3\cdot5+1\cdot2\cdot3\cdot22+\cdots \\ C_5=1\cdot2\cdot3\cdot4\cdot5+1\cdot2\cdot3\cdot4\cdot22+1\cdot3\cdot4\cdot5\cdot22+\cdots \\ C_6=1\cdot2\cdot3\cdot4\cdot5\cdot22}$$

Which gives you:

$$\cases{C_1=37 \\ C_2=415 \\ C_3=2095 \\C_4=5224 \\ C_5=6148 \\ C_6=2640}$$

And you indeed get:

$$P(x)=x^6-37 x^5+415 x^4-2095 x^3+5224 x^2-6148 x+2640$$

I agree this is quite a long procedure for big $n$ but up to $n=5$ or even $n=6$ it can be good to know. And especially if you don't have access to a computer (during exams for instance) ;)

  • $\begingroup$ Thanks, it really is good information, but I think to do this calculations with n=10,20. $\endgroup$ – ciceksiz kakarot Apr 23 '13 at 18:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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