Код:
for i from 0 to 5 do
f := simplify(subs(A[i] = solveSys[1][i + 1], f));
end do
После этих строчек код в f получается вся цепочка преобразований, заключенная в 5 скобок f=(((((...=...=...=...=...))))). Как получить последнее значение f (после последнего равно)? f=...
-- 04.03.2021, 12:17 --Код:
restart;
f := x^2*A[3] + x*y*A[5] + y^2*A[4] + x*A[1] + y*A[2] + A[0];
2 2
f := x A[3] + x y A[5] + y A[4] + x A[1] + y A[2] + A[0]
a[0] := subs(x = -1, y = -1, f);
a[0] := A[0] - A[1] - A[2] + A[3] + A[4] + A[5]
a[1] := subs(x = 0, y = -1, f);
a[1] := A[0] - A[2] + A[4]
a[2] := subs(x = 1, y = -1, f);
a[2] := A[0] + A[1] - A[2] + A[3] + A[4] - A[5]
a[3] := subs(x = -1, y = 0, f);
a[3] := A[0] - A[1] + A[3]
a[4] := subs(x = 0, y = 0, f);
a[4] := A[0]
a[5] := subs(x = 1, y = 0, f);
a[5] := A[0] + A[1] + A[3]
a[6] := subs(x = -1, y = 1, f);
a[6] := A[0] - A[1] + A[2] + A[3] + A[4] - A[5]
a[7] := subs(x = 0, y = 1, f);
a[7] := A[0] + A[2] + A[4]
a[8] := subs(x = 1, y = 1, f);
a[8] := A[0] + A[1] + A[2] + A[3] + A[4] + A[5]
for i from 0 to 8 do
s[i] := (a[i] - z[i])^2;
end do;
2
s[0] := (A[0] - A[1] - A[2] + A[3] + A[4] + A[5] - z[0])
2
s[1] := (A[0] - A[2] + A[4] - z[1])
2
s[2] := (A[0] + A[1] - A[2] + A[3] + A[4] - A[5] - z[2])
2
s[3] := (A[0] - A[1] + A[3] - z[3])
2
s[4] := (A[0] - z[4])
2
s[5] := (A[0] + A[1] + A[3] - z[5])
2
s[6] := (A[0] - A[1] + A[2] + A[3] + A[4] - A[5] - z[6])
2
s[7] := (A[0] + A[2] + A[4] - z[7])
2
s[8] := (A[0] + A[1] + A[2] + A[3] + A[4] + A[5] - z[8])
S := sum(s[j], j = 0 .. 8);
2
S := (A[0] - A[1] - A[2] + A[3] + A[4] + A[5] - z[0])
2
+ (A[0] - A[2] + A[4] - z[1])
2
+ (A[0] + A[1] - A[2] + A[3] + A[4] - A[5] - z[2])
2 2
+ (A[0] - A[1] + A[3] - z[3]) + (A[0] - z[4])
2
+ (A[0] + A[1] + A[3] - z[5])
2
+ (A[0] - A[1] + A[2] + A[3] + A[4] - A[5] - z[6])
2
+ (A[0] + A[2] + A[4] - z[7])
2
+ (A[0] + A[1] + A[2] + A[3] + A[4] + A[5] - z[8])
for i from 0 to 5 do
d[i] := simplify(diff(S, A[i]));
end do;
d[0] := -2 z[8] - 2 z[7] - 2 z[6] - 2 z[5] - 2 z[4] - 2 z[3]
- 2 z[2] - 2 z[1] - 2 z[0] + 12 A[4] + 12 A[3] + 18 A[0]
d[1] := -2 z[8] + 2 z[6] - 2 z[5] + 2 z[3] - 2 z[2] + 2 z[0]
+ 12 A[1]
d[2] := -2 z[8] - 2 z[7] - 2 z[6] + 2 z[2] + 2 z[1] + 2 z[0]
+ 12 A[2]
d[3] := -2 z[8] - 2 z[6] - 2 z[5] - 2 z[3] - 2 z[2] - 2 z[0]
+ 8 A[4] + 12 A[3] + 12 A[0]
d[4] := -2 z[8] - 2 z[7] - 2 z[6] - 2 z[2] - 2 z[1] - 2 z[0]
+ 12 A[4] + 8 A[3] + 12 A[0]
d[5] := -2 z[8] + 2 z[6] + 2 z[2] - 2 z[0] + 8 A[5]
solveSys := solve([d[0], d[1], d[2], d[3], d[4], d[5]], [A[0], A[1], A[2], A[3], A[4], A[5]]);
[[ 1 1 2 2 1
solveSys := [[A[0] = - - z[8] - - z[6] + - z[5] + - z[3] - - z[2]
[[ 9 9 9 9 9
1 2 2 5
- - z[0] + - z[7] + - z[1] + - z[4],
9 9 9 9
1 1 1 1 1 1
A[1] = - z[8] - - z[6] + - z[5] - - z[3] + - z[2] - - z[0],
6 6 6 6 6 6
1 1 1 1 1 1
A[2] = - z[8] + - z[7] + - z[6] - - z[2] - - z[1] - - z[0], A[3
6 6 6 6 6 6
1 1 1 1 1 1
] = - z[8] - - z[7] + - z[6] + - z[2] - - z[1] + - z[0]
6 3 6 6 3 6
1 1 1 1 1 1
+ - z[5] - - z[4] + - z[3], A[4] = - z[8] + - z[7] + - z[6]
6 3 6 6 6 6
1 1 1 1 1 1
- - z[5] - - z[4] - - z[3] + - z[2] + - z[1] + - z[0],
3 3 3 6 6 6
1 1 1 1 ]]
A[5] = - z[8] - - z[6] - - z[2] + - z[0]]]
4 4 4 4 ]]
for i from 0 to 5 do f := simplify(subs(A[i] = solveSys[1][i + 1], f)); end do
вот весь код до этого