function x = ComputeBestRoot4(handle_f,x1,x2,x3,x4)
% x_i = arg min_{t \in {x1(i),x2(i),x3(i),x4(i)} }  f(t)
% with i = 1,..., n
% handle_f: R => R
% x1: n x 1
% x2: n x 1
% x3: n x 1
% x4: n x 1

dim = length(x1);
num = 4;
X = [x1 x2 x3 x4]';
f1 = handle_f(x1); 
f2 = handle_f(x2); 
f3 = handle_f(x3);
f4 = handle_f(x4);
F = [f1 f2 f3 f4];
[~,I]=min(F,[],2);
x = X(I + [1:num:dim*num]'-1);
x = reshape(x,dim,1);