Ok, I'm trying to prepare myself for the CLM test for college placement, and have a question in regards to a specific type of math problem. Let me show you an example of the type of problem below:

f(x)=x^2

g(x)=3x+2

find (f(g(-2))

Solution steps

g(x)=3x+2

find g(-2)

replace x with -2

g(x) becomes 3(-2)+2=-4

g(-2)=-4

find (f(g(-2))

replace g(-2) with -4

f(-4)

replace x with g(-2)

f(g(-2))=(g(-2))^2

since g(-2)=-4, f(-4) is...

(-4)^2=16

Now, after seeing a couple examples of how to solve, I get how to do it, but not why it works the way it does.

My problem is with step 1, if I replaced the x=-2 with any other number, the equation changes. For example, if I gave a similar example, and used two different numbers for the variable:

8(x)=6(x)+10

If x=5

8(5)=6(5)+10

40=40 is a true statement

However, if x=8

8(8)=6(8)+10

64=58 is no longer a true statement

So, I'm at a loss as to why you are allowed to replace x on both sides with -2 in the original problem, based on the fact that depending on what you plug in, g will have to be altered for it to still be true. Is that just how it works, that all numbers are indefinitive and defined by whatever variable you are able to replace with any numbers given? If someone can help clarify this for me and help make sense of why this works the way it does, I would really appreciate it.