Group: alt.sci.physics.new-theories
From: dedanoe
Date: Monday, March 03, 2008 11:03 PM
Subject: Re: dedanoe's sponge comprexpander

On Mar 3, 8:46=A0pm, dedanoe wrote:
> aj te molam vidi sho nechini so mojot calculus. vo poveketo od
> sluchaevite toj e divergenten a i vo tie retki sluchai na
> konvergencija resheniata se povtorno loshi. pred da go startash .exe-
> to vidi go kodot vo .pas. ideata mi e da postavam ednakvost pomegu:
>
> Singular1 x Original x Specific x Singular2 =3D Result =3D Singular1 x
> Compression x Expansion x Singular2
>
> taka sho
> Original[3..5]=3DSpecific[1..2]=3DCompression[2..5]=3DExpansion[1]=3D1.
> znachi, od dva originala i tri specifiki pravam 1compresija i 4
> expanzii so namera da gi zapisham samo compresijata illy samo
> expanzijata pri sho mora da ima i povratni metodi za restavracija na
> originalite.
>
> /

i have now fully functional version of my sponge comprexpander:
/
the calculus converges in all directions: (de)compression,
(de)expansion and so...

-------the code------
unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls,
Forms,
Dialogs, StdCtrls, ExtCtrls;

type
TVector3 =3D array[1..3] of Real;
TVector5 =3D array[1..5] of Real;
TVector6 =3D array[1..6] of Real;
TForm1 =3D class(TForm)
GroupBox1: TGroupBox;
Edit1: TEdit;
Edit2: TEdit;
Edit3: TEdit;
Edit4: TEdit;
Edit5: TEdit;
Edit10: TEdit;
Edit9: TEdit;
Edit8: TEdit;
Edit7: TEdit;
Edit6: TEdit;
Edit11: TEdit;
Edit12: TEdit;
Edit13: TEdit;
Edit14: TEdit;
Edit15: TEdit;
Edit20: TEdit;
Edit19: TEdit;
Edit18: TEdit;
Edit17: TEdit;
Edit16: TEdit;
Edit21: TEdit;
Edit22: TEdit;
Edit23: TEdit;
Edit24: TEdit;
Edit25: TEdit;
GroupBox2: TGroupBox;
Edit26: TEdit;
Edit27: TEdit;
Edit28: TEdit;
Edit29: TEdit;
Edit30: TEdit;
Edit35: TEdit;
Edit34: TEdit;
Edit33: TEdit;
Edit32: TEdit;
Edit31: TEdit;
Edit36: TEdit;
Edit37: TEdit;
Edit38: TEdit;
Edit39: TEdit;
Edit40: TEdit;
Edit45: TEdit;
Edit44: TEdit;
Edit43: TEdit;
Edit42: TEdit;
Edit41: TEdit;
Edit46: TEdit;
Edit47: TEdit;
Edit48: TEdit;
Edit49: TEdit;
Edit50: TEdit;
GroupBox3: TGroupBox;
Button2: TButton;
Button3: TButton;
Button4: TButton;
GroupBox4: TGroupBox;
RadioGroup1: TRadioGroup;
Button1: TButton;
Timer1: TTimer;
Timer2: TTimer;
Timer3: TTimer;
Label1: TLabel;
Button5: TButton;
Timer4: TTimer;
Label2: TLabel;
procedure Timer4Timer(Sender: TObject);
procedure Button5Click(Sender: TObject);
procedure Timer2Timer(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
procedure Timer3Timer(Sender: TObject);
procedure Button4Click(Sender: TObject);
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
Singular1, Singular2,
Original, Specific,
Compression, Expansion: TVector5;
StartingTime, EndingTime: TDateTime;
end;

var
Form1: TForm1;

implementation

{$R *.dfm}

function Norm3(V: TVector3): Real;
begin
Result:=3D Sqrt(Sqr(V[1])
+ Sqr(V[2])
+ Sqr(V[3]));
end;

function Sc3(V1, V2: TVector3): Real;
begin
Result:=3D V1[1] * V2[1]
+ V1[2] * V2[2]
+ V1[3] * V2[3];
end;

function Sum3(V1, V2: TVector3): TVector3;
begin
Result[1]:=3D V1[1] + V2[1];
Result[2]:=3D V1[2] + V2[2];
Result[3]:=3D V1[3] + V2[3];
end;

function Ext3(V1: Real; V2: TVector3): TVector3;
begin
Result[1]:=3D V1 * V2[1];
Result[2]:=3D V1 * V2[2];
Result[3]:=3D V1 * V2[3];
end;

function Dif3(V1, V2: TVector3): TVector3;
begin
Result:=3D Sum3(V1, Ext3(-1, V2));
end;

function Norm5(V: TVector5): Real;
begin
Result:=3D Sqrt(Sqr(V[1])
+ Sqr(V[2])
+ Sqr(V[3])
+ Sqr(V[4])
+ Sqr(V[5]));
end;

function Sc5(V1, V2: TVector5): Real;
begin
Result:=3D V1[1] * V2[1]
+ V1[2] * V2[2]
+ V1[3] * V2[3]
+ V1[4] * V2[4]
+ V1[5] * V2[5];
end;

function Sum5(V1, V2: TVector5): TVector5;
begin
Result[1]:=3D V1[1] + V2[1];
Result[2]:=3D V1[2] + V2[2];
Result[3]:=3D V1[3] + V2[3];
Result[4]:=3D V1[4] + V2[4];
Result[5]:=3D V1[5] + V2[5];
end;

function Ext5(V1: Real; V2: TVector5): TVector5;
begin
Result[1]:=3D V1 * V2[1];
Result[2]:=3D V1 * V2[2];
Result[3]:=3D V1 * V2[3];
Result[4]:=3D V1 * V2[4];
Result[5]:=3D V1 * V2[5];
end;

function Dif5(V1, V2: TVector5): TVector5;
begin
Result:=3D Sum5(V1, Ext5(-1, V2));
end;

function Norm6(V: TVector6): Real;
begin
Result:=3D Sqrt(Sqr(V[1])
+ Sqr(V[2])
+ Sqr(V[3])
+ Sqr(V[4])
+ Sqr(V[5])
+ Sqr(V[6]));
end;

function Sc6(V1, V2: TVector6): Real;
begin
Result:=3D V1[1] * V2[1]
+ V1[2] * V2[2]
+ V1[3] * V2[3]
+ V1[4] * V2[4]
+ V1[5] * V2[5]
+ V1[6] * V2[6];
end;

function Sum6(V1, V2: TVector6): TVector6;
begin
Result[1]:=3D V1[1] + V2[1];
Result[2]:=3D V1[2] + V2[2];
Result[3]:=3D V1[3] + V2[3];
Result[4]:=3D V1[4] + V2[4];
Result[5]:=3D V1[5] + V2[5];
Result[6]:=3D V1[6] + V2[6];
end;

function Ext6(V1: Real; V2: TVector6): TVector6;
begin
Result[1]:=3D V1 * V2[1];
Result[2]:=3D V1 * V2[2];
Result[3]:=3D V1 * V2[3];
Result[4]:=3D V1 * V2[4];
Result[5]:=3D V1 * V2[5];
Result[6]:=3D V1 * V2[6];
end;

function Dif6(V1, V2: TVector6): TVector6;
begin
Result:=3D Sum6(V1, Ext6(-1, V2));
end;

function RNDSingular: TVector5;
begin
Randomize;
repeat
Result[1]:=3D 10 * (2 * Random - 1);
Result[2]:=3D 10 * (2 * Random - 1);
Result[3]:=3D 10 * (2 * Random - 1);
Result[4]:=3D 10 * (2 * Random - 1);
Result[5]:=3D 10 * (2 * Random - 1);
until Norm5(Result) <> 0;
Result:=3D Ext5(1/Norm5(Result), Result);
end;

function RNDSpecific: TVector5;
begin
Randomize;
repeat
Result[1]:=3D 1;
Result[2]:=3D 1;
Result[3]:=3D 10 * (2 * Random - 1);
Result[4]:=3D 10 * (2 * Random - 1);
Result[5]:=3D 10 * (2 * Random - 1);
until Norm5(Result) <> 0;
end;

function RNDOriginal: TVector5;
begin
Randomize;
repeat
Result[1]:=3D 10 * (2 * Random - 1);
Result[2]:=3D 10 * (2 * Random - 1);
Result[3]:=3D 1;
Result[4]:=3D 1;
Result[5]:=3D 1;
until Norm5(Result) <> 0;
end;

function RNDCompression: TVector5;
begin
Randomize;
repeat
Result[1]:=3D 10 * (2 * Random - 1);
Result[2]:=3D 1;
Result[3]:=3D 1;
Result[4]:=3D 1;
Result[5]:=3D 1;
until Norm5(Result) <> 0;
end;

function RNDExpansion: TVector5;
begin
Randomize;
repeat
Result[1]:=3D 1;
Result[2]:=3D 10 * (2 * Random - 1);
Result[3]:=3D 10 * (2 * Random - 1);
Result[4]:=3D 10 * (2 * Random - 1);
Result[5]:=3D 10 * (2 * Random - 1);
until Norm5(Result) <> 0;
end;

procedure (Sender: TObject);
begin
Singular1:=3D RNDSingular;
:=3D FloatToStr(Singular1[1]);
:=3D FloatToStr(Singular1[2]);
:=3D FloatToStr(Singular1[3]);
:=3D FloatToStr(Singular1[4]);
:=3D FloatToStr(Singular1[5]);
:=3D FloatToStr(Singular1[1]);
:=3D FloatToStr(Singular1[2]);
:=3D FloatToStr(Singular1[3]);
:=3D FloatToStr(Singular1[4]);
:=3D FloatToStr(Singular1[5]);
Specific:=3D RNDSpecific;
:=3D FloatToStr(Specific[1]);
:=3D FloatToStr(Specific[2]);
:=3D FloatToStr(Specific[3]);
:=3D FloatToStr(Specific[4]);
:=3D FloatToStr(Specific[5]);
Singular2:=3D RNDSingular;
:=3D FloatToStr(Singular2[1]);
:=3D FloatToStr(Singular2[2]);
:=3D FloatToStr(Singular2[3]);
:=3D FloatToStr(Singular2[4]);
:=3D FloatToStr(Singular2[5]);
:=3D FloatToStr(Singular2[1]);
:=3D FloatToStr(Singular2[2]);
:=3D FloatToStr(Singular2[3]);
:=3D FloatToStr(Singular2[4]);
:=3D FloatToStr(Singular2[5]);
case of
0: begin
Original:=3D RNDOriginal;
:=3D FloatToStr(Original[1]);
:=3D FloatToStr(Original[2]);
:=3D FloatToStr(Original[3]);
:=3D FloatToStr(Original[4]);
:=3D FloatToStr(Original[5]);
:=3D True;
:=3D False;
:=3D False;
:=3D True;
end;
1: begin
Compression:=3D RNDCompression;
:=3D FloatToStr(Compression[1]);
:=3D FloatToStr(Compression[2]);
:=3D FloatToStr(Compression[3]);
:=3D FloatToStr(Compression[4]);
:=3D FloatToStr(Compression[5]);
:=3D False;
:=3D True;
:=3D False;
:=3D True;
end;
2: begin
Expansion:=3D RNDExpansion;
:=3D FloatToStr(Expansion[1]);
:=3D FloatToStr(Expansion[2]);
:=3D FloatToStr(Expansion[3]);
:=3D FloatToStr(Expansion[4]);
:=3D FloatToStr(Expansion[5]);
:=3D False;
:=3D False;
:=3D True;
:=3D True;
end;
end;
end;

procedure (Sender: TObject);
begin
:=3D True;
:=3D True;
StartingTime:=3D Now;
end;

procedure (Sender: TObject);
begin
:=3D True;
:=3D True;
StartingTime:=3D Now;
end;

procedure (Sender: TObject);
begin
:=3D True;
:=3D True;
StartingTime:=3D Now;
end;

procedure (Sender: TObject);
begin
:=3D False;
:=3D False;
:=3D False;
:=3D False;
:=3D False;
:=3D False;
:=3D False;
:=3D False;
end;

function ProductIs(V1, V2, V3, V4: TVector5): TVector5;
begin
Result[1]:=3D V1[2] * V2[3] * V3[4] * V4[5] + V1[3] * V2[4] * V3[5] *
V4[1] + V1[4] * V2[5] * V3[1] * V4[2] + V1[5] * V2[1] * V3[2] * V4[3]
- V4[2] * V3[3] * V2[4] * V1[5] - V4[3] * V3[4] * V2[5] *
V1[1] - V4[4] * V3[5] * V2[1] * V1[2] - V4[5] * V3[1] * V2[2] * V1[3];
Result[2]:=3D V1[3] * V2[4] * V3[5] * V4[1] + V1[4] * V2[5] * V3[1] *
V4[2] + V1[5] * V2[1] * V3[2] * V4[3] + V1[1] * V2[2] * V3[3] * V4[4]
- V4[3] * V3[4] * V2[5] * V1[1] - V4[4] * V3[5] * V2[1] *
V1[2] - V4[5] * V3[1] * V2[2] * V1[3] - V4[1] * V3[2] * V2[3] * V1[4];
Result[3]:=3D V1[4] * V2[5] * V3[1] * V4[2] + V1[5] * V2[1] * V3[2] *
V4[3] + V1[1] * V2[2] * V3[3] * V4[4] + V1[2] * V2[3] * V3[4] * V4[5]
- V4[4] * V3[5] * V2[1] * V1[2] - V4[5] * V3[1] * V2[2] *
V1[3] - V4[1] * V3[2] * V2[3] * V1[4] - V4[2] * V3[3] * V2[4] * V1[5];
Result[4]:=3D V1[5] * V2[1] * V3[2] * V4[3] + V1[1] * V2[2] * V3[3] *
V4[4] + V1[2] * V2[3] * V3[4] * V4[5] + V1[3] * V2[4] * V3[5] * V4[1]
- V4[5] * V3[1] * V2[2] * V1[3] - V4[1] * V3[2] * V2[3] *
V1[4] - V4[2] * V3[3] * V2[4] * V1[5] - V4[3] * V3[4] * V2[5] * V1[1];
Result[5]:=3D V1[1] * V2[2] * V3[3] * V4[4] + V1[2] * V2[3] * V3[4] *
V4[5] + V1[3] * V2[4] * V3[5] * V4[1] + V1[4] * V2[5] * V3[1] * V4[2]
- V4[1] * V3[2] * V2[3] * V1[4] - V4[2] * V3[3] * V2[4] *
V1[5] - V4[3] * V3[4] * V2[5] * V1[1] - V4[4] * V3[5] * V2[1] * V1[2];
end;

procedure (Sender: TObject);
var Compression1, Compression2,
Expansion1, Expansion2,
Error1, Error2, V1, V2,
Product1, Product2: TVector5;

function Rationed(x1, x2, E1, E2: TVector5): TVector5;
var
Det, Det1, Det2: Extended;
M, M1, M2, Coor1, Coor2: array[1..2, 1..2] of Extended;
sys: array[1..2, 1..2] of TVector5;
begin
repeat
M1[1,1]:=3D Random - ;
M1[1,2]:=3D Random - ;
M1[2,1]:=3D Random - ;
M1[2,2]:=3D Random - ;
Det1:=3D M1[1, 1]*M1[2, 2] - M1[1, 2]*M1[2, 1];
M2[1,1]:=3D Random - ;
M2[1,2]:=3D Random - ;
M2[2,1]:=3D Random - ;
M2[2,2]:=3D Random - ;
Det2:=3D M2[1, 1]*M2[2, 2] - M2[1, 2]*M2[2, 1];
until Det1 * Det2 <> 0;

sys[1,1]:=3D Sum5(Ext5(M1[1,1], E1), Ext5(M1[1,2], E2));
sys[1,2]:=3D Sum5(Ext5(M1[2,1], E1), Ext5(M1[2,2], E2));
sys[2,1]:=3D Sum5(Ext5(M2[1,1], E1), Ext5(M2[1,2], E2));
sys[2,2]:=3D Sum5(Ext5(M2[2,1], E1), Ext5(M2[2,2], E2));

sys[1,1]:=3D Ext5(1/Norm5(sys[1,1]), sys[1,1]);
sys[1,2]:=3D Ext5(1/Norm5(sys[1,2]), sys[1,2]);
sys[2,1]:=3D Ext5(1/Norm5(sys[2,1]), sys[2,1]);
sys[2,2]:=3D Ext5(1/Norm5(sys[2,2]), sys[2,2]);

Coor1[1,1]:=3D Sc5(E1, sys[1,1]);
Coor1[1,2]:=3D Sc5(E1, sys[1,2]);
Coor1[2,1]:=3D Sc5(E1, sys[2,1]);
Coor1[2,2]:=3D Sc5(E1, sys[2,2]);

Coor2[1,1]:=3D Sc5(E2, sys[1,1]);
Coor2[1,2]:=3D Sc5(E2, sys[1,2]);
Coor2[2,1]:=3D Sc5(E2, sys[2,1]);
Coor2[2,2]:=3D Sc5(E2, sys[2,2]);

Det:=3D Coor2[1,1]*Coor2[2,2] - Coor2[1,2]*Coor2[2,1];

M[1,1]:=3D (Coor1[1,1]*Coor2[2,2] - Coor1[1,2]*Coor2[2,1])/Det;
M[1,2]:=3D (Coor2[1,1]*Coor1[1,2] - Coor2[1,2]*Coor1[1,1])/Det;
M[2,1]:=3D (Coor1[2,1]*Coor2[2,2] - Coor1[2,2]*Coor2[2,1])/Det;
M[2,2]:=3D (Coor2[1,1]*Coor1[2,2] - Coor2[1,2]*Coor1[2,1])/Det;

repeat
M1[1,1]:=3D Random - ;
M1[1,2]:=3D Random - ;
M1[2,1]:=3D Random - ;
M1[2,2]:=3D Random - ;
until M1[1, 1]*M1[2, 2] - M1[1, 2]*M1[2, 1] <> 0;
//creating a vector5 system
sys[1,1]:=3D Sum5(Ext5(M1[1,1], x1), Ext5(M1[1,2], x2));
sys[1,2]:=3D Sum5(Ext5(M1[2,1], x1), Ext5(M1[2,2], x2));
//|sys[1,1]| =3D |sys[1,2]| =3D 1
sys[1,1]:=3D Ext5(1/Norm5(sys[1,1]), sys[1,1]);
sys[1,2]:=3D Ext5(1/Norm5(sys[1,2]), sys[1,2]);
//aquiring the 1d-coordinates for x1-x2
Coor1[1,1]:=3D Sc5(Dif5(x1, x2), sys[1,1]);
Coor1[1,2]:=3D Sc5(Dif5(x1, x2), sys[1,2]);
//rotation and shrinking by M
Coor1[2,1]:=3D M[1,1]*Coor1[1,1] + M[1,2]*Coor1[1,2];
Coor1[2,2]:=3D M[2,1]*Coor1[1,1] + M[2,2]*Coor1[1,2];
//summing
Result:=3D Sum5(Ext5(Coor1[2,1], sys[1,1]),
Ext5(Coor1[2,2], sys[1,2]));
end;

begin
Product1:=3D ProductIs(Singular1, Original, Specific, Singular2);
:=3D FloatToStr(Product1[1]);
:=3D FloatToStr(Product1[2]);
:=3D FloatToStr(Product1[3]);
:=3D FloatToStr(Product1[4]);
:=3D FloatToStr(Product1[5]);
Compression1:=3D RNDCompression; Expansion1:=3D RNDExpansion;
Error1:=3D Dif5(ProductIs(Singular1, Compression1, Expansion1,
Singular2), Product1);
Compression2:=3D RNDCompression; Expansion2:=3D RNDExpansion;
Error2:=3D Dif5(ProductIs(Singular1, Compression2, Expansion2,
Singular2),
ProductIs(Singular1, Original, Specific, Singular2));
V1[1]:=3D Compression1[1]; V1[2]:=3D Expansion1[2]; V1[3]:=3D
Expansion1[3]; V1[4]:=3D Expansion1[4]; V1[5]:=3D Expansion1[5];
V2[1]:=3D Compression2[1]; V2[2]:=3D Expansion2[2]; V2[3]:=3D
Expansion2[3]; V2[4]:=3D Expansion2[4]; V2[5]:=3D Expansion2[5];
:=3D '|UpResult-DownResult| =3D ' +
FloatToStr(Norm5(Dif5(Error1, Error2)));
if Norm5(Error1) > Norm5(Error2) then begin
Product2:=3D ProductIs(Singular1, Compression1, Expansion1,
Singular2);
:=3D FloatToStr(Product2[1]);
:=3D FloatToStr(Product2[2]);
:=3D FloatToStr(Product2[3]);
:=3D FloatToStr(Product2[4]);
:=3D FloatToStr(Product2[5]);
V1:=3D Sum5(V1, Rationed(V1, V2, Error1, Error2));
end else if Norm5(Error2) > Norm5(Error1) then begin
Product2:=3D ProductIs(Singular1, Compression2, Expansion2,
Singular2);
:=3D FloatToStr(Product2[1]);
:=3D FloatToStr(Product2[2]);
:=3D FloatToStr(Product2[3]);
:=3D FloatToStr(Product2[4]);
:=3D FloatToStr(Product2[5]);
V2:=3D Sum5(V2, Rationed(V2, V1, Error2, Error1));
end;
:=3D FloatToStr(V1[1]);
:=3D FloatToStr(V1[2]);
:=3D FloatToStr(V1[3]);
:=3D FloatToStr(V1[4]);
:=3D FloatToStr(V1[5]);
if Abs(Norm5(Error1)-Norm5(Error2)) < 1E-10 then begin
:=3D False;
:=3D False;
:=3D False;
:=3D False;
Beep;
end;
end;

procedure (Sender: TObject);
var
Original1, Original2,
Expansion1, Expansion2,
Error1, Error2,
Product1, Product2: TVector5;
V1, V2: TVector6;

function Rationed(x1, x2: TVector6; E1, E2: TVector5): TVector6;
var
Det, Det1, Det2: Extended;
M, M1, M2, Coor1, Coor2: array[1..2, 1..2] of Extended;
sys: array[1..2, 1..2] of TVector5;
sys1: array[1..2] of TVector6;
begin
repeat
M1[1,1]:=3D Random - ;
M1[1,2]:=3D Random - ;
M1[2,1]:=3D Random - ;
M1[2,2]:=3D Random - ;
Det1:=3D M1[1, 1]*M1[2, 2] - M1[1, 2]*M1[2, 1];
M2[1,1]:=3D Random - ;
M2[1,2]:=3D Random - ;
M2[2,1]:=3D Random - ;
M2[2,2]:=3D Random - ;
Det2:=3D M2[1, 1]*M2[2, 2] - M2[1, 2]*M2[2, 1];
until Det1 * Det2 <> 0;

sys[1,1]:=3D Sum5(Ext5(M1[1,1], E1), Ext5(M1[1,2], E2));
sys[1,2]:=3D Sum5(Ext5(M1[2,1], E1), Ext5(M1[2,2], E2));
sys[2,1]:=3D Sum5(Ext5(M2[1,1], E1), Ext5(M2[1,2], E2));
sys[2,2]:=3D Sum5(Ext5(M2[2,1], E1), Ext5(M2[2,2], E2));

sys[1,1]:=3D Ext5(1/Norm5(sys[1,1]), sys[1,1]);
sys[1,2]:=3D Ext5(1/Norm5(sys[1,2]), sys[1,2]);
sys[2,1]:=3D Ext5(1/Norm5(sys[2,1]), sys[2,1]);
sys[2,2]:=3D Ext5(1/Norm5(sys[2,2]), sys[2,2]);

Coor1[1,1]:=3D Sc5(E1, sys[1,1]);
Coor1[1,2]:=3D Sc5(E1, sys[1,2]);
Coor1[2,1]:=3D Sc5(E1, sys[2,1]);
Coor1[2,2]:=3D Sc5(E1, sys[2,2]);

Coor2[1,1]:=3D Sc5(E2, sys[1,1]);
Coor2[1,2]:=3D Sc5(E2, sys[1,2]);
Coor2[2,1]:=3D Sc5(E2, sys[2,1]);
Coor2[2,2]:=3D Sc5(E2, sys[2,2]);

Det:=3D Coor2[1,1]*Coor2[2,2] - Coor2[1,2]*Coor2[2,1];

M[1,1]:=3D (Coor1[1,1]*Coor2[2,2] - Coor1[1,2]*Coor2[2,1])/Det;
M[1,2]:=3D (Coor2[1,1]*Coor1[1,2] - Coor2[1,2]*Coor1[1,1])/Det;
M[2,1]:=3D (Coor1[2,1]*Coor2[2,2] - Coor1[2,2]*Coor2[2,1])/Det;
M[2,2]:=3D (Coor2[1,1]*Coor1[2,2] - Coor2[1,2]*Coor1[2,1])/Det;

repeat
M1[1,1]:=3D Random - ;
M1[1,2]:=3D Random - ;
M1[2,1]:=3D Random - ;
M1[2,2]:=3D Random - ;
until M1[1, 1]*M1[2, 2] - M1[1, 2]*M1[2, 1] <> 0;
//creating a vector5 system
sys1[1]:=3D Sum6(Ext6(M1[1,1], x1), Ext6(M1[1,2], x2));
sys1[2]:=3D Sum6(Ext6(M1[2,1], x1), Ext6(M1[2,2], x2));
//|sys[1,1]| =3D |sys[1,2]| =3D 1
sys1[1]:=3D Ext6(1/Norm6(sys1[1]), sys1[1]);
sys1[2]:=3D Ext6(1/Norm6(sys1[2]), sys1[2]);
//aquiring the 1d-coordinates for x1-x2
Coor1[1,1]:=3D Sc6(Dif6(x1, x2), sys1[1]);
Coor1[1,2]:=3D Sc6(Dif6(x1, x2), sys1[2]);
//rotation and shrinking by M
Coor1[2,1]:=3D M[1,1]*Coor1[1,1] + M[1,2]*Coor1[1,2];
Coor1[2,2]:=3D M[2,1]*Coor1[1,1] + M[2,2]*Coor1[1,2];
//summing
Result:=3D Sum6(Ext6(Coor1[2,1], sys1[1]),
Ext6(Coor1[2,2], sys1[2]));
end;

begin
Original1:=3D RNDOriginal; Expansion1:=3D RNDExpansion;
Error1:=3D Dif5(ProductIs(Singular1, Original1, Specific, Singular2),
ProductIs(Singular1, Compression, Expansion1,
Singular2));
Original2:=3D RNDOriginal; Expansion2:=3D RNDExpansion;
Error2:=3D Dif5(ProductIs(Singular1, Original2, Specific, Singular2),
ProductIs(Singular1, Compression, Expansion2,
Singular2));
V1[1]:=3D Original1[1]; V1[2]:=3D Original1[2];
V1[3]:=3D Expansion1[2]; V1[4]:=3D Expansion1[3];
V1[5]:=3D Expansion1[4]; V1[6]:=3D Expansion1[5];
V2[1]:=3D Original2[1]; V2[2]:=3D Original2[2];
V2[3]:=3D Expansion2[2]; V2[4]:=3D Expansion2[3];
V2[5]:=3D Expansion2[4]; V2[6]:=3D Expansion2[5];
:=3D '|UpResult-DownResult| =3D ' +
FloatToStr(Norm5(Dif5(Error1, Error2)));
if Norm5(Error1) > Norm5(Error2) then begin
Product1:=3D ProductIs(Singular1, Original1, Specific, Singular2);
:=3D FloatToStr(Product1[1]);
:=3D FloatToStr(Product1[2]);
:=3D FloatToStr(Product1[3]);
:=3D FloatToStr(Product1[4]);
:=3D FloatToStr(Product1[5]);
Product2:=3D ProductIs(Singular1, Compression, Expansion1,
Singular2);
:=3D FloatToStr(Product2[1]);
:=3D FloatToStr(Product2[2]);
:=3D FloatToStr(Product2[3]);
:=3D FloatToStr(Product2[4]);
:=3D FloatToStr(Product2[5]);
V1:=3D Sum6(V2, Rationed(V1, V2, Error1, Error2));
:=3D FloatToStr(V1[1]);
:=3D FloatToStr(V1[2]);
:=3D FloatToStr(V1[3]);
:=3D FloatToStr(V1[4]);
:=3D FloatToStr(V1[5]);
:=3D FloatToStr(V1[6]);
end else if Norm5(Error1) < Norm5(Error2) then begin
Product1:=3D ProductIs(Singular1, Original2, Specific, Singular2);
:=3D FloatToStr(Product1[1]);
:=3D FloatToStr(Product1[2]);
:=3D FloatToStr(Product1[3]);
:=3D FloatToStr(Product1[4]);
:=3D FloatToStr(Product1[5]);
Product2:=3D ProductIs(Singular1, Compression, Expansion2,
Singular2);
:=3D FloatToStr(Product2[1]);
:=3D FloatToStr(Product2[2]);
:=3D FloatToStr(Product2[3]);
:=3D FloatToStr(Product2[4]);
:=3D FloatToStr(Product2[5]);
V2:=3D Sum6(V2, Rationed(V2, V1, Error2, Error1));
:=3D FloatToStr(V2[1]);
:=3D FloatToStr(V2[2]);
:=3D FloatToStr(V2[3]);
:=3D FloatToStr(V2[4]);
:=3D FloatToStr(V2[5]);
:=3D FloatToStr(V2[6]);
end;
if Abs(Norm5(Error1)-Norm5(Error2)) < 1E-10 then begin
:=3D False;
:=3D False;
:=3D False;
:=3D False;
Beep;
end;
end;

procedure (Sender: TObject);
var
Original1, Original2,
Compression1, Compression2,
Error1, Error2,
Product1, Product2: TVector5;
V1, V2: TVector3;

function Rationed(x1, x2: TVector3; E1, E2: TVector5): TVector3;
var
Det, Det1, Det2: Extended;
M, M1, M2, Coor1, Coor2: array[1..2, 1..2] of Extended;
sys: array[1..2, 1..2] of TVector5;
sys1: array[1..2] of TVector3;
begin
repeat
M1[1,1]:=3D Random - ;
M1[1,2]:=3D Random - ;
M1[2,1]:=3D Random - ;
M1[2,2]:=3D Random - ;
Det1:=3D M1[1, 1]*M1[2, 2] - M1[1, 2]*M1[2, 1];
M2[1,1]:=3D Random - ;
M2[1,2]:=3D Random - ;
M2[2,1]:=3D Random - ;
M2[2,2]:=3D Random - ;
Det2:=3D M2[1, 1]*M2[2, 2] - M2[1, 2]*M2[2, 1];
until Det1 * Det2 <> 0;

sys[1,1]:=3D Sum5(Ext5(M1[1,1], E1), Ext5(M1[1,2], E2));
sys[1,2]:=3D Sum5(Ext5(M1[2,1], E1), Ext5(M1[2,2], E2));
sys[2,1]:=3D Sum5(Ext5(M2[1,1], E1), Ext5(M2[1,2], E2));
sys[2,2]:=3D Sum5(Ext5(M2[2,1], E1), Ext5(M2[2,2], E2));

sys[1,1]:=3D Ext5(1/Norm5(sys[1,1]), sys[1,1]);
sys[1,2]:=3D Ext5(1/Norm5(sys[1,2]), sys[1,2]);
sys[2,1]:=3D Ext5(1/Norm5(sys[2,1]), sys[2,1]);
sys[2,2]:=3D Ext5(1/Norm5(sys[2,2]), sys[2,2]);

Coor1[1,1]:=3D Sc5(E1, sys[1,1]);
Coor1[1,2]:=3D Sc5(E1, sys[1,2]);
Coor1[2,1]:=3D Sc5(E1, sys[2,1]);
Coor1[2,2]:=3D Sc5(E1, sys[2,2]);

Coor2[1,1]:=3D Sc5(E2, sys[1,1]);
Coor2[1,2]:=3D Sc5(E2, sys[1,2]);
Coor2[2,1]:=3D Sc5(E2, sys[2,1]);
Coor2[2,2]:=3D Sc5(E2, sys[2,2]);

Det:=3D Coor2[1,1]*Coor2[2,2] - Coor2[1,2]*Coor2[2,1];

M[1,1]:=3D (Coor1[1,1]*Coor2[2,2] - Coor1[1,2]*Coor2[2,1])/Det;
M[1,2]:=3D (Coor2[1,1]*Coor1[1,2] - Coor2[1,2]*Coor1[1,1])/Det;
M[2,1]:=3D (Coor1[2,1]*Coor2[2,2] - Coor1[2,2]*Coor2[2,1])/Det;
M[2,2]:=3D (Coor2[1,1]*Coor1[2,2] - Coor2[1,2]*Coor1[2,1])/Det;

repeat
M1[1,1]:=3D Random - ;
M1[1,2]:=3D Random - ;
M1[2,1]:=3D Random - ;
M1[2,2]:=3D Random - ;
until M1[1, 1]*M1[2, 2] - M1[1, 2]*M1[2, 1] <> 0;
//creating a vector5 system
sys1[1]:=3D Sum3(Ext3(M1[1,1], x1), Ext3(M1[1,2], x2));
sys1[2]:=3D Sum3(Ext3(M1[2,1], x1), Ext3(M1[2,2], x2));
//|sys[1,1]| =3D |sys[1,2]| =3D 1
sys1[1]:=3D Ext3(1/Norm3(sys1[1]), sys1[1]);
sys1[2]:=3D Ext3(1/Norm3(sys1[2]), sys1[2]);
//aquiring the 1d-coordinates for x1-x2
Coor1[1,1]:=3D Sc3(Dif3(x1, x2), sys1[1]);
Coor1[1,2]:=3D Sc3(Dif3(x1, x2), sys1[2]);
//rotation and shrinking by M
Coor1[2,1]:=3D M[1,1]*Coor1[1,1] + M[1,2]*Coor1[1,2];
Coor1[2,2]:=3D M[2,1]*Coor1[1,1] + M[2,2]*Coor1[1,2];
//summing
Result:=3D Sum3(Ext3(Coor1[2,1], sys1[1]),
Ext3(Coor1[2,2], sys1[2]));
end;

begin
Original1:=3D RNDOriginal; Compression1:=3D RNDCompression;
Error1:=3D Dif5(ProductIs(Singular1, Original1, Specific, Singular2),
ProductIs(Singular1, Compression1, Expansion,
Singular2));
Original2:=3D RNDOriginal; Compression2:=3D RNDCompression;
Error2:=3D Dif5(ProductIs(Singular1, Original2, Specific, Singular2),
ProductIs(Singular1, Compression2, Expansion,
Singular2));
V1[1]:=3D Original1[1]; V1[2]:=3D Original1[2]; V1[3]:=3D Compression1[1];=

V2[1]:=3D Original2[1]; V2[2]:=3D Original2[2]; V2[3]:=3D Compression2[1];=

:=3D '|UpResult-DownResult| =3D ' +
FloatToStr(Norm5(Dif5(Error1, Error2)));
if Norm5(Error1) > Norm5(Error2) then begin
Product1:=3D ProductIs(Singular1, Original1, Specific, Singular2);
:=3D FloatToStr(Product1[1]);
:=3D FloatToStr(Product1[2]);
:=3D FloatToStr(Product1[3]);
:=3D FloatToStr(Product1[4]);
:=3D FloatToStr(Product1[5]);
Product2:=3D ProductIs(Singular1, Compression1, Expansion,
Singular2);
:=3D FloatToStr(Product2[1]);
:=3D FloatToStr(Product2[2]);
:=3D FloatToStr(Product2[3]);
:=3D FloatToStr(Product2[4]);
:=3D FloatToStr(Product2[5]);
V1:=3D Sum3(V2, Rationed(V1, V2, Error1, Error2));
:=3D FloatToStr(V1[1]);
:=3D FloatToStr(V1[2]);
:=3D FloatToStr(V1[3]);
end else if Norm5(Error1) < Norm5(Error2) then begin
Product1:=3D ProductIs(Singular1, Original2, Specific, Singular2);
:=3D FloatToStr(Product1[1]);
:=3D FloatToStr(Product1[2]);
:=3D FloatToStr(Product1[3]);
:=3D FloatToStr(Product1[4]);
:=3D FloatToStr(Product1[5]);
Product2:=3D ProductIs(Singular1, Compression2, Expansion,
Singular2);
:=3D FloatToStr(Product2[1]);
:=3D FloatToStr(Product2[2]);
:=3D FloatToStr(Product2[3]);
:=3D FloatToStr(Product2[4]);
:=3D FloatToStr(Product2[5]);
V2:=3D Sum3(V2, Rationed(V2, V1, Error2, Error1));
:=3D FloatToStr(V2[1]);
:=3D FloatToStr(V2[2]);
:=3D FloatToStr(V2[3]);
end;
if Abs(Norm5(Error1)-Norm5(Error2)) < 1E-10 then begin
:=3D False;
:=3D False;
:=3D False;
:=3D False;
Beep;
end;
end;

procedure (Sender: TObject);
begin
EndingTime:=3D Now;
:=3D 'Total time working: ' + DateTimeToStr(EndingTime -
StartingTime);
end;

end.