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 "MtxExpr.hpp"
#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");
}