+ 2
Explain the question
def f(x): return(2*x+1) def g(x): return(x-1) print(g(f(2)-f(g(2)))
2 Answers
+ 3
This is a nested function which performs a specific equation with given parameters.
Equation of "g" :
---> x - 1
Equation of "f" :
---> (2 * x) + 1
Then we will just solve those each of those functions until we got only 2 numbers and evaluate.
- - - - - - - - - - - -
First, let's focus on the main equation which is:
g (f(2)) - f (g(2))
- - - - - - - - - - - -
# First solve the first term: g(f(2))
f(2) = 2 * 2 + 1
f(2) = 5
---> g(f(2)) --->g(5)
š
g(5) = 5 - 1
g(5) = 4
So now the first term is 4
- - - - - - - - - - - -
# Next is the second term: f(g(2))
g(2) = 2 - 1
g(2) = 1
---> f(g(2)) ---> f(1)
š
f(1) = 2 * 1 + 1
f(1) = 3
So now the second term is 3
- - - - - - - -
Therefore:
g(f(2)) ---> 4
f(g(2)) ---> 3
4 - 3
>> 1
If this is still not clear, then please feel free to ask. Thanks!
+ 2
ć Nicko12 ć thank you so much