In the last example, g is a function (it passes the vertical line test), but it is not injective (it does not pass the horizontal line test) and it is not surjective (there is no x value that maps to a y value of -5, for example). You can still compute the composition of g and f, however.