Chapter 3.4 - Functions Return Values
1 Return Value for Every (x)
Functions as we saw in the last blog post are written as f(x) = 2x + 3. While (y) can be substituted for f(x), an important distinction is that there can only be 1 (x, y) value pair, for every (x). If there is more than 1 value, then the equation cannot be described using a function. =(
This then excludes the equation for an ellipses or an inverted ellipses.
The mathematical equation for an ellipse is:
1 = x^2 / a + y^2 / b
As you can see in the equation, there will be two (2) (x, y) pairs for every value of (x).
x = [ 1, -1, ... ]
y = [ 1, -1, ... ]
Another function that is disqualified is :
x = y^2
However, y = x^2 is perfectly fine.
f(x) = x^2
Another property of functions is that they can contain sets of equations.
f(x) = [ return x, where x <= 0, return 0, where 0 < x < 2 return 1, where x >= 2 ]
Increasing or Decreasing
Functions are said to be Increasing or Decreasing based on how the return values trend.
For example:
When the values of increase, f(x) = [ 1, 2, 3, 4, 5, 6, ... n ], it is said that f(x) is increasing.
When the values of decrease, f(x) = [ -1, -2, -3, -4, -5, -6, ... -n ], it is said that f(x) is decreasing.
One to One
If two functions F(x[1]) and F(x[2]) produce the exact same results, they are said to be One to One. Or, expressed another way, when F (x[1]) = F (x[2]).
Remember (x) is a set of numbers, integers for the sake of argument.
if F(x) = x^2, then when x = -2 and x = 2, F(x) = 4.
Composite Functions
In the previous blog we showed that F(x) and G(x) can be combined. The output of one function becomes the input of another function.
Since f(x) and g(x) are defined, let’s see what they evaluate to when we expand the mathematical expression f ( g (x) ).
f (x) = x + 3 g(x) = x^2
f ( g (x) ) = f ( x^2 ) = x^2 + 3
These are considered composite functions. This type of expression is used all the time in programming.
Function Identities
Identity functions, like identity expression, take the value of X and return the value of X. This is similar to saying F(x) = x * 10, while G(x) = x / 10. If the functions are composited F( G(x)), the return would be x. The same holds true for G( F(x)).
F(x) = x * 10 G(x) = x / 10
F( G(x)) = F ( x / 10 ) = ( (x / 10) * 10) = x * (10 / 10) = x * 1 = x
G( F(x)) = G ( x*10 ) = ( (x *10) / 10) = x * (10 / 10) = x * 1 = x


















