Q:

Get envelope of a set of functions? 

I'm new with mathematica and I'm trying to solve a problem. 
I have a set of functions in the same variable.  Let's say the domain is [0,2].  I would like to get an ordered list of the functions representing the "envelope".  I'll try to explain, I have these 4 linear functions red, orange, green, blue. 

And this is the plot of the maximum among all the functions. 

How can I get a list {red, orange, green, blue} saying which is the max function in each segment? 
Thanks

A:

Michael E2 is correct in that Max is remarkably capable with functions as well as values.  
Defining
f1[x_] := -2 x + 2
f2[x_] := -x + 1.5
f3[x_] := x - 0.5
f4[x_] := 2 x - 2

funcs = {f1[x], f2[x], f3[x], f4[x]};

We can use Max to get the function of the envelope:
m[x_] = PiecewiseExpand@Max[f1[x], f2[x], f3[x], f4[x]]

Plot[funcs, {x, 0, 2}, Epilog -> First@Plot[m[x], {x, 0, 2}, PlotStyle -> Directive[Dashed, Black]]]

Provided your functions are all linear we can safely solve for all the intersections and then examine which function is the largest in each region:
crossings = Union@N@Flatten[Outer[Solve[#1 == #2, x] &, funcs, funcs]][[;;, 2]];

Plot[funcs, {x, 0, 2}, Epilog -> {Line[{{#, -2}, {#, 2}}] & /@ crossings}]

Thus the different regions are bounded by:
regions =  Join[{x < crossings[[1]]}, (#[[1]] < x < #[[2]]) & /@ Partition[crossings, 2, 1], {crossings[[-1]] < x}]

{x < 0.5, 0.5 < x < 0.833333, 0.833333 < x < 1.,  1.  < x < 1.16667, 
   1.16667 < x < 1.5, 1.5 < x}

Within which the orderings are:
Reverse /@ (Ordering@Through[{f1, f2, f3, f4}[#]] & /@ MovingAverage[
Join[{crossings[[1]] - 1}, crossings, {crossings[[-1]] + 1}], 2])

{{1, 2, 3, 4}, {2, 1, 3, 4}, {2, 3, 1, 4}, {3, 2, 4, 1}, {3, 4, 2, 
    1}, {4, 3, 2, 1}}

