Mathematica Asked by PowerConquerLi on February 16, 2021
In Mathematica, we can find the value of a determinant with the built-in function Det
. But how can I find the value of a determinant like this one?
$$
left|begin{array}{ccccc}1 & x & x^{2} & cdots & x^{n-1} 1 & a_{1} & a_{1}^{2} & cdots & a_{1}^{n-1} vdots & vdots & vdots & & vdots 1 & a_{n-1} & a_{n-1}^{2} & cdots & a_{n-1}^{n-1}end{array}right|
$$
Why should this not work? Maybe you have some syntax error? Here is an example:
n = 3;
(da = Transpose@
Table[Prepend[Array[Subscript[a, #] &, n - 1], x]^i, {i, 0,
n - 1}]) // MatrixForm
Det[da]
Answered by Daniel Huber on February 16, 2021
Making use of the observation that the OP is asking for a Vandermonde determinant:
With[{n = 5},
Product[a[i]-a[j], {i, 0, n - 1}, {j, 0, i - 1}] /. a[0] -> x]
(* (-x+a[1])(-x+a[2])(-a[1]+a[2])(-x+a[3])(-a[1]+a[3])(-a[2]+a[3])(-x+a[4])(-a[1]+a[4])(-a[2]+a[4])(-a[3]+a[4]) *)
This method is exponentially faster than actually building the matrix and calculating its determinant. Also, it is numerically more stable.
Answered by Roman on February 16, 2021
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP