This repository has been archived on 2024-10-22. You can view files and clone it, but cannot push or open issues or pull requests.
OM/Claudio_Maggioni_4/gsppn.m

31 lines
539 B
Mathematica
Raw Normal View History

2021-05-25 08:41:07 +00:00
clc
2021-05-26 10:00:01 +00:00
syms l
2021-05-25 08:41:07 +00:00
X = [1/(3+l); (-1)/(1-l); (-1)/(2-l)]
a1 = (3+l)^2;
a2 = (1-l)^2;
a3 = (2-l)^2;
t1 = a2*a3
t2 = a1*a3
t3 = a1*a2
t4 = a1*a2*a3
2021-05-26 10:00:01 +00:00
c1 = (coeffs(t1, 'All'))
c2 = (coeffs(t2, 'All'))
c3 = (coeffs(t3, 'All'))
c4 = (coeffs(t4, 'All'))
2021-05-25 08:41:07 +00:00
2021-05-26 10:00:01 +00:00
ctot = coeffs(t1+t2+t3-t4, 'All')
2021-05-25 08:41:07 +00:00
sol = double(solve(t1+t2+t3-t4==0, l, 'Real', true))
for i=1:size(sol, 1)
Xi = double(subs(X,l,sol(i)))
Li = sol(i);
Ci = norm(Xi, 2)^2 - 1;
Yi = sum(Xi .* Xi .* [-3;1;2]) + sum(2 * Xi);
fprintf("lambda=%.03f ci=%g y=%g", Li, Ci, Yi);
end