You may expect the optimizer to completely omit calculating the first element, but unfortunately for you, the negativity check before the square root will never be optimized away, since it affects the whole program execution and thus *shouldn't* be omitted from the compiled program, even though you're only using the result of the second computation.
I would suggest building your functions the other way around, construct your simpler functions, and then build your composite function out of the simpler ones: f1(x) = sqrt(x) f2(x) = 2*x f(x) = [f1(x[1]), f2(x[2])] That should get you what you want. -E