Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Catalog · How the catalog works

Random project

RootsFormula

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

View on GitHub

Anyone may press Interesting, signed in or not. It helps others find this project.

Member rating

No ratings yet.

Sign in to rate this project.

README

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)

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

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

XsN := PolySolveReal( Ks, X1 );

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

pascal
Ks1[3] * X^2 + Ks1[2] * X + Ks1[1] = 0
pascal
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)

pascal
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;

pascal
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)

pascal
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;

pascal
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