I was trying to test NMinimize on $$ \int_0^1 (a+b(cx+d))^2 dx $$, then I guess it should be minimized when the integrand equals 0. It works fine when the integrand is only (a+bx)^2, I use the code:
z1[x_, y_] := y[[1]]*x + y[[2]] ;
Y = Table[y[i], {i, 1, 2}];
h[Y_] := Integrate[(z1[x, Y])^2, {x, 0, 1}]
NMinimize[h[Y], Y, AccuracyGoal -> 20, PrecisionGoal -> 18,
WorkingPrecision -> 40]
And I get the output :
{3.550736290059893672842701884381905283185*10^-144, {y[1] ->
6.527544368345474836762769419275328411033*10^-72,
y[2] -> -3.263772184172737418381384709637664205517*10^-72}}
But when I do the composition, I was confused, what I wrote is:
z1[x_, y_] := y[[1]]*x + y[[2]] ;
z2[x_, y_] := y[[3]]*x + y[[4]];
z[x_, y_] := z1@z2@x;
Y = Table[y[i], {i, 1, 4}];
h[Y_] := Integrate[(z[x, Y])^2, {x, 0, 1}];
NMinimize[h[Y], Y, AccuracyGoal -> 20, PrecisionGoal -> 18,
WorkingPrecision -> 40]
Where the $z[x,y]$ gives
y[[2]] + y[[1]] (x y[[3]] + y[[4]])
and $h[Y]$ gives
y[[2]]^2 + y[[1]] y[[2]] y[[3]] + 1/3 y[[1]]^2 y[[3]]^2 +
2 y[[1]] y[[2]] y[[4]] + y[[1]]^2 y[[3]] y[[4]] + y[[1]]^2 y[[4]]^2
which seem fine, but the result of NMinimize is :
NMinimize[
y[[2]]^2 + y[[1]] y[[2]] y[[3]] + 1/3 y[[1]]^2 y[[3]]^2 +
2 y[[1]] y[[2]] y[[4]] + y[[1]]^2 y[[3]] y[[4]] +
y[[1]]^2 y[[4]]^2, {y[1], y[2], y[3], y[4]}, AccuracyGoal -> 20,
PrecisionGoal -> 18, WorkingPrecision -> 40]
I dont know why I cannot get an answer from it, thanks for any help !