Код:
> a:=proc(a1,a2,a3,x) a1*cos(x)+a2*cos(2*x)+a3*cos(3*x) end proc;
a := proc(a1, a2, a3, x) a1*cos(x) + a2*cos(2*x) + a3*cos(3*x) end proc;
> FC:=proc(a1,a2,a3,n) evalf(Int(exp(I*(a(a1,a2,a3,x)+n*x)),x=-Pi..Pi)/(2*Pi)) end proc;
FC := proc(a1, a2, a3, n) evalf((Int(exp(I*(a(a1, a2, a3, x) + n*x)), x = -Pi .. Pi))/(2*Pi)) end proc;
> FM:=proc(a1,a2,a3) local A,i,j,k;A:=array(1..4);for k to 4 do A[k]:=FC(a1,a2,a3,k-1) end do;sum(sum((abs(A[i])-abs(A[j]))^2,j=1..i-1),i=2..4) end proc;
FM := proc(a1, a2, a3)
local A, i, j, k;
A := array(1 .. 4);
for k to 4 do A[k] := FC(a1, a2, a3, k - 1) end do;
sum(sum((abs(A[i]) - abs(A[j]))^2, j = 1 .. i - 1), i = 2 .. 4);
end proc;
> FM(1.2397215,1.5309297,0);
0.0077811308
> with(Optimization);
[ImportMPS, Interactive, LPSolve, LSSolve, Maximize, Minimize, NLPSolve,
QPSolve]
> Minimize(FM(x,y,z),initialpoint={x=1.2397215,y=1.5309297,z=0});
Error, (in Optimization:-NLPSolve) wrong number (or type) of arguments
Почему не хочет минимизировать? С другой функцией работает:
Код:
> FF:=proc(x,y,z)3*x^2+2*y^4+z*y^2-2*x+4*y+z^6-12*z end proc;
FF := proc(x, y, z) 3*x^2 + 2*y^4 + z*y^2 - 2*x + 4*y + z^6 - 12*z end proc;
> Minimize(FF(x,y,z),initialpoint={x=1.2397215,y=1.5309297,z=0});
[-13.5837606045537598, [x = 0.333333334104796986, z = 1.13983814611687517, y = -0.675063823297239906]]