Difference between revisions of "ElemSymPoly"

From QETLAB
Jump to navigation Jump to search
(Create page ElemSymPoly)
 
m (Capitalize variables in syntax and argument descriptions)
 
(2 intermediate revisions by the same user not shown)
Line 3: Line 3:
 
|desc=Computes the elementary symmetric polynomial of a given set of numbers.
 
|desc=Computes the elementary symmetric polynomial of a given set of numbers.
 
|cat=[[List of functions#Miscellaneous|Miscellaneous]]
 
|cat=[[List of functions#Miscellaneous|Miscellaneous]]
|upd=August 22, 2024
+
|upd=August 23, 2024
 
|v=0.90}}
 
|v=0.90}}
 
<tt>'''ElemSymPoly'''</tt> is a [[List of functions|function]] that computes the ''k''<sup>th</sup> [https://en.wikipedia.org/wiki/Elementary_symmetric_polynomial elementary symmetric polynomial] of a given set of numbers.
 
<tt>'''ElemSymPoly'''</tt> is a [[List of functions|function]] that computes the ''k''<sup>th</sup> [https://en.wikipedia.org/wiki/Elementary_symmetric_polynomial elementary symmetric polynomial] of a given set of numbers.
  
 
==Syntax==
 
==Syntax==
* <tt>res = ElemSymPoly(x, k)</tt>
+
* <tt>RES = ElemSymPoly(X, K)</tt>
  
 
==Argument descriptions==
 
==Argument descriptions==
* <tt>x</tt>: A vector.
+
* <tt>X</tt>: A vector of length <tt>n</tt>.
* <tt>k</tt>: An integer denoting the degree of the terms in the elementary symmetric polynomial.
+
* <tt>K</tt>: An integer denoting the degree of the terms in the elementary symmetric polynomial. Must be between <tt>0</tt> and <tt>n</tt>, inclusive.
  
 
==Example==
 
==Example==
This function computes the sum of products of ''k'' distinct elements of a vector ''x''. For example, the 3<sup>rd</sup> elementary symmetric polynomial of the vector [1, 2, 3, 4] is computed by summing the distinct products of 3 elements, these products being 1x2x3, 1x2x4, 1x3x4, and 2x3x4.
+
This function computes the sum of products of ''k'' distinct elements of a vector ''x''. For example, the 3<sup>rd</sup> elementary symmetric polynomial of the vector [1, 2, 3, 4] is computed by summing the distinct products of 3 elements, these products being 1 x 2 x 3, 1 x 2 x 4, 1 x 3 x 4, and 2 x 3 x 4.
 
<syntaxhighlight>
 
<syntaxhighlight>
 
>> ElemSymPoly([1, 2, 3, 4], 3)
 
>> ElemSymPoly([1, 2, 3, 4], 3)
Line 23: Line 23:
 
     50
 
     50
 
</syntaxhighlight>
 
</syntaxhighlight>
 +
 +
==Notes==
 +
The 0<sup>th</sup> elementary symmetric polynomial is defined as S<sub>0</sub>(''x'') = 1.
  
 
{{SourceCode|name=ElemSymPoly}}
 
{{SourceCode|name=ElemSymPoly}}

Latest revision as of 14:07, 26 August 2024

ElemSymPoly
Computes the elementary symmetric polynomial of a given set of numbers.

Other toolboxes required none
Function category Miscellaneous

ElemSymPoly is a function that computes the kth elementary symmetric polynomial of a given set of numbers.

Syntax

  • RES = ElemSymPoly(X, K)

Argument descriptions

  • X: A vector of length n.
  • K: An integer denoting the degree of the terms in the elementary symmetric polynomial. Must be between 0 and n, inclusive.

Example

This function computes the sum of products of k distinct elements of a vector x. For example, the 3rd elementary symmetric polynomial of the vector [1, 2, 3, 4] is computed by summing the distinct products of 3 elements, these products being 1 x 2 x 3, 1 x 2 x 4, 1 x 3 x 4, and 2 x 3 x 4.

>> ElemSymPoly([1, 2, 3, 4], 3)

ans =

    50

Notes

The 0th elementary symmetric polynomial is defined as S0(x) = 1.

Source code

Click here to view this function's source code on github.