Skip to content

We computed the real solution of the polynomial equation in real time.

Notifications You must be signed in to change notification settings

LUXOPHIA/RootsFormula

Repository files navigation

RootsFormula

"解の公式"を用いて、1~4次方程式の実数解をリアルタイムに計算しました。
Using the formula of solution, We computed the real solution of the linear/quadratic/cubic/quartic equation in real time.

###MOVIE

###▼ 1次方程式 (linear equation)

Ks1[2] * X + Ks1[1] = 0
var
   Ks  :TDouble2D;  //多項式の係数
   X1  :Double;     //
   XsN :Byte;       //解の個数 = 0~1

Ks[1] := 1;  // 1
Ks[2] := 2;  // X

XsN := PolySolveReal( Ks, X1 );

###▼ 2次方程式 (Quadratic equation)

Ks1[3] * X^2 + Ks1[2] * X + Ks1[1] = 0
var
   Ks  :TDouble2D;  //多項式の係数
   Xs  :Double;     //解の配列
   XsN :Byte;       //解の個数 = 0~2

Ks[1] := 1;  // 1
Ks[2] := 2;  // X
Ks[3] := 3;  // X^2

XsN := PolySolveReal( Ks, Xs );

###▼ 3次方程式 (Cubic equation)

Ks1[4] * X^3 + Ks1[3] * X^2 + Ks1[2] * X + Ks1[1] = 0

function PolySolveReal( const Ks_:TSingle4D; out Xs_:TSingle3D ) :Byte;
function PolySolveReal( const Ks_:TDouble4D; out Xs_:TDouble3D ) :Byte;

var
   Ks  :TDouble2D;  //多項式の係数
   Xs  :Double;     //解の配列
   XsN :Byte;       //解の個数 = 1 or 3

Ks[1] := 1;  // 1
Ks[2] := 2;  // X
Ks[3] := 3;  // X^2
Ks[4] := 4;  // X^3

XsN := PolySolveReal( Ks, Xs );

###▼ 4次方程式 (Quartic equation)

Ks1[5] * X^4 + Ks1[4] * X^3 + Ks1[3] * X^2 + Ks1[2] * X + Ks1[1] = 0

function PolySolveReal( const Ks_:TSingle5D; out Xs_:TSingle4D ) :Byte;
function PolySolveReal( const Ks_:TDouble5D; out Xs_:TDouble4D ) :Byte;

var
   Ks  :TDouble2D;  //多項式の係数
   Xs  :Double;     //解の配列
   XsN :Byte;       //解の個数 = 0~4

Ks[1] := 1;  // 1
Ks[2] := 2;  // X
Ks[3] := 3;  // X^2
Ks[4] := 4;  // X^3
Ks[5] := 5;  // X^4

XsN := PolySolveReal( Ks, Xs );

Delphi Starter

About

We computed the real solution of the polynomial equation in real time.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages