%% Invariánsok annihilátorral (első próbálkozás)
%  
%  File: elso_probalkozas.m
%  Directory: 1_PhD_projects/01_demonstrative/01_invariansok
%  Author: Peter Polcz (ppolcz@gmail.com) 
%  
%  Created on 2019. March 31.
%
%%

f = @(x1,x2) [
    -3*x1*x2
    0.5*x1
    ];

lfrs x1 x2 
x = [ x1 ; x2 ];

Pi = @(x1,x2) [
    x1
    x2
    x1*x2
    ];
m = 3;

I = @(m) eye(m);

dx = f(x1,x2);

N_PI = @(x1,x2) [
    I(m)
    I(m)*x1
    I(m)*x2
    ];

d = @(lfr) diff(lfr,'x1') * dx(1) + diff(lfr,'x2') * dx(2);

d_N_PI_Pi = minlfr(d(N_PI(x1,x2)) * Pi(x1,x2) + N_PI(x1,x2) * d(Pi(x1,x2)));

C = P_constKerT_for_LFR(d_N_PI_Pi);

% itt tortenik a roundingolas !!
C_coeffs = rref(C);
C_coeffs = pround(C_coeffs, 5);

syms x1 x2 real
x = [ x1 ; x2 ];


N = C_coeffs * kron([1;x],eye(m))

% Invariánsok:

Invariansok = simplify(N * Pi)


