Dew MtxVec NET
PolyCoeff Routines
Summary
Converts polynomial roots to coefficients.

Unit
Polynoms

Declaration
Procedure PolyCoeff(Roots, Coeff: TVec);

Description
The PolyCoeff procedure converts polynomial roots to coefficients. The following scheme is used to construct a coefficients from the roots:
P(x) = coeff[0]*x^n + coeff[1]*x^(n-1) + .. + coeff[n] = (x - roots[0])* .. *(x - roots[n-1]) n .. order of the polynomial
The length and complex property of the Coeff object are set automatically. The inverse to this routine is PolyRoots
Declaration
Procedure PolyCoeff(Mtx: TMtx; Coeff: TVec);

Description
Returns coefficients of the characteristic polynomial: det( Mtx - Lambda * I )
 See Also 
PolyRoots 

Example 1

Find coefficients of a polynomial with roots at 1,1 and 2.
uses MtxExpr, Math387, MtxVec, MtxVecEdit, Polynoms; procedure TForm1.Button1Click(Sender: TObject); var Roots, Coeff: Vector; begin // roots of the polynomial: (x - 1)*(x - 1)*(x - 2) Roots.SetIt(false,[1, 1, 2]); PolyCoeff(Roots,Coeff); // Coeff returns the coefficients of the polynomial [ 1,-4, 5,-2] // which can be written as: 1*x^3 + -4*x^2 + 5*x - 2 ViewValues(Coeff,'Coefficients'); end;
#include "MtxVecCPP.h" //MtxVecCPP.cpp must be included in the project #include "Polynoms.hpp" #include "MtxVecTee.hpp" void __fastcall TForm1::BitBtn1Click(TObject *Sender) { Vector Roots, Coeff; // roots of the polynomial: (x - 1)*(x - 1)*(x - 2) Roots->SetIt(false,OPENARRAY(double,(1, 1, 2))); PolyCoeff(Roots,Coeff); // Coeff returns the coefficients of the polynomial [ 1,-4, 5,-2] // which can be written as: 1*x^3 + -4*x^2 + 5*x - 2 ViewValues(Coeff,"Coefficients"); }
using Dew.Math; using Dew.Math.Units; using Dew.Math.Editors; namespace Dew.Examples { private void Example() { Vector Roots = new Vector(0); Vector Coeff = new Vector(0); // roots of the polynomial: (x - 1)*(x - 1)*(x - 2) Roots.SetIt(false, new double[] {1,1,2}); Polynoms.PolyCoeff(Roots,Coeff); // Coeff returns the coefficients of the polynomial [ 1,-4, 5,-2] // which can be written as: 1*x^3 + -4*x^2 + 5*x - 2 MtxVecEdit.ViewValues(Coeff,"Coefficients"); } }

Example 2

Find coefficients of a characteristic polynomial
uses MtxExpr, Math387, MtxVec, MtxVecEdit, Polynoms; var Coeff: Vector; A: Matrix; begin A.SetIt(3,3,false,[1, 4, -1, 2, 1, 5, 3, -2, 0]); PolyCoeff(A,Coeff); ViewValues(Coeff,'Coefficients'); end;
#include "MtxVecCPP.h" //MtxVecCPP.cpp must be included in the project #include "Polynoms.hpp" #include "MtxVecTee.hpp" void __fastcall TForm1::BitBtn1Click(TObject *Sender) { Vector Coeff; Matrix A; A->SetIt(3,3,false,OPENARRAY(double,(1, 4, -1, 2, 1, 5, 3, -2, 0))); PolyCoeff(A,Coeff); ViewValues(Coeff,"Coefficients"); }
using Dew.Math; using Dew.Math.Units; using Dew.Math.Editors; namespace Dew.Examples { private void Example() { Vector Coeff = new Vector(0); Matrix A = new Matrix(0,0); A.SetIt(3,3,false, new double[] {1, 4, -1, 2, 1, 5, 3, -2, 0}); Polynoms.PolyCoeff(A,Coeff); MtxVecEdit.ViewValues(Coeff,"Coefficients"); } }

Copyright 2008 Dew Research
http://www.dewresearch.com