Someone that works with symbolic variables?
Hi guys, I have a code that should give me some results. Unfortunately when I insert k>3, the program collapses and says there isn’t enought RAM to run it. I’m just texting to know if anyone has ever worked with symbolic variables before and can help me. If anyone knows how to work with this please I’ll be really glad to talk to you via email or Telegram.
function [S,Gnew,Enew] = BGroebner1(k)
M = 3*k + 1;
x = sym(‘x’);
r = sym(‘r’);
c = sym(‘c’, [1 M+1]);
% Define the sum of monomials with negative coefficients
CC = x;
for i = 1:M+1
CC = CC + c(1,i)*x^(-i);
end
sM = expand(CC^(3));
for i = M:1:3*M+3
sM = subs(sM, x^(-i), r);
end
sMnew = sM;
sMnew = subs(sMnew,r,0);
sMnew1 = expand(x^(M-1)*sMnew);
C =coeffs(sMnew1,x);
E =sym(‘E’,[1,M-1]);
for i= M-1:-1:1
E(1,M-i) = C(1,i);
end
% Calculate Groebner basis,
num_syms = M+1;
syms_cell = cell(1, num_syms);
for i = M+1:-1:1
syms_cell{i} = sym([‘c’, num2str(M+2-i)]);
end
c = [syms_cell{:}];
G = gbasis(E,c,"MonomialOrder",’Lexicographic’);
J = (M+1)*M;
sM1 = expand(CC^{M});
sMnew2 = expand(x^(J)*sM1);
E2 = coeffs(sMnew2,x);
EM = E2(J);
EM1=E2(J-1);
F= sym(‘F’);
Enew = [E,EM,EM1+F];
% Groebner basis with (E^M)_1, (E^M)_2 + F
Gnew = gbasis(Enew,[F c],"MonomialOrder",’Lexicographic’);
%% Calculate the solutions of the E_{1}, E_{2},…
eqn =sym(‘eqn’, [1 M-1]);
for i=1:1:M-1
eqn(i)= Enew(i)==0;
end
d = sym(‘c’, [1 M+1]);
S = vpasolve(eqn,d);
end
Looking forward your replies.Hi guys, I have a code that should give me some results. Unfortunately when I insert k>3, the program collapses and says there isn’t enought RAM to run it. I’m just texting to know if anyone has ever worked with symbolic variables before and can help me. If anyone knows how to work with this please I’ll be really glad to talk to you via email or Telegram.
function [S,Gnew,Enew] = BGroebner1(k)
M = 3*k + 1;
x = sym(‘x’);
r = sym(‘r’);
c = sym(‘c’, [1 M+1]);
% Define the sum of monomials with negative coefficients
CC = x;
for i = 1:M+1
CC = CC + c(1,i)*x^(-i);
end
sM = expand(CC^(3));
for i = M:1:3*M+3
sM = subs(sM, x^(-i), r);
end
sMnew = sM;
sMnew = subs(sMnew,r,0);
sMnew1 = expand(x^(M-1)*sMnew);
C =coeffs(sMnew1,x);
E =sym(‘E’,[1,M-1]);
for i= M-1:-1:1
E(1,M-i) = C(1,i);
end
% Calculate Groebner basis,
num_syms = M+1;
syms_cell = cell(1, num_syms);
for i = M+1:-1:1
syms_cell{i} = sym([‘c’, num2str(M+2-i)]);
end
c = [syms_cell{:}];
G = gbasis(E,c,"MonomialOrder",’Lexicographic’);
J = (M+1)*M;
sM1 = expand(CC^{M});
sMnew2 = expand(x^(J)*sM1);
E2 = coeffs(sMnew2,x);
EM = E2(J);
EM1=E2(J-1);
F= sym(‘F’);
Enew = [E,EM,EM1+F];
% Groebner basis with (E^M)_1, (E^M)_2 + F
Gnew = gbasis(Enew,[F c],"MonomialOrder",’Lexicographic’);
%% Calculate the solutions of the E_{1}, E_{2},…
eqn =sym(‘eqn’, [1 M-1]);
for i=1:1:M-1
eqn(i)= Enew(i)==0;
end
d = sym(‘c’, [1 M+1]);
S = vpasolve(eqn,d);
end
Looking forward your replies. Hi guys, I have a code that should give me some results. Unfortunately when I insert k>3, the program collapses and says there isn’t enought RAM to run it. I’m just texting to know if anyone has ever worked with symbolic variables before and can help me. If anyone knows how to work with this please I’ll be really glad to talk to you via email or Telegram.
function [S,Gnew,Enew] = BGroebner1(k)
M = 3*k + 1;
x = sym(‘x’);
r = sym(‘r’);
c = sym(‘c’, [1 M+1]);
% Define the sum of monomials with negative coefficients
CC = x;
for i = 1:M+1
CC = CC + c(1,i)*x^(-i);
end
sM = expand(CC^(3));
for i = M:1:3*M+3
sM = subs(sM, x^(-i), r);
end
sMnew = sM;
sMnew = subs(sMnew,r,0);
sMnew1 = expand(x^(M-1)*sMnew);
C =coeffs(sMnew1,x);
E =sym(‘E’,[1,M-1]);
for i= M-1:-1:1
E(1,M-i) = C(1,i);
end
% Calculate Groebner basis,
num_syms = M+1;
syms_cell = cell(1, num_syms);
for i = M+1:-1:1
syms_cell{i} = sym([‘c’, num2str(M+2-i)]);
end
c = [syms_cell{:}];
G = gbasis(E,c,"MonomialOrder",’Lexicographic’);
J = (M+1)*M;
sM1 = expand(CC^{M});
sMnew2 = expand(x^(J)*sM1);
E2 = coeffs(sMnew2,x);
EM = E2(J);
EM1=E2(J-1);
F= sym(‘F’);
Enew = [E,EM,EM1+F];
% Groebner basis with (E^M)_1, (E^M)_2 + F
Gnew = gbasis(Enew,[F c],"MonomialOrder",’Lexicographic’);
%% Calculate the solutions of the E_{1}, E_{2},…
eqn =sym(‘eqn’, [1 M-1]);
for i=1:1:M-1
eqn(i)= Enew(i)==0;
end
d = sym(‘c’, [1 M+1]);
S = vpasolve(eqn,d);
end
Looking forward your replies. symbolic, variables MATLAB Answers — New Questions