Is it possible to pass functions into other functions in maths? I wanna be frank with you guys and say my mathematical education was a bit... bleh, so I'm teaching myself a lot of stuff lately, a question that has come up for me: "Is it possible to pass functions into other functions?"
Like say I have a function $g$ that takes $2$ parameters $f$ and $a$, where $f$ is a function, and $a$ is any natural or real number (doesn't really matter in this case), I'd then use both of those later in $g$'s definition... The function passed into $g$ would then slightly alter $g$'s behavior, making $g$ more general by letting me pass other functions into it whenever I'd need it.
Is this doable at all? And would there even be any use for this in mathematics?
Note that I'm aware of how Higher Order Functions work in programming, I just haven't gotten the faintest clue if or how they're used in maths
 A: Yes. Functions taking other functions as arguments are called higher-order functions. For example, g(f) might return a function 2*f(x) given a function f(x).
This has lots of uses in computer science and the rest of mathematics.
A: Note that you can interpret normal functions $f: \mathbb{R}\to\mathbb{R}$ like this all the time. If
$$f(x)=x^2-3x$$
then
$$f(g(x))=g(x)^2-3g(x)$$
which we can reinterpret as
$$f(g)=g^2-3g$$
where $g$ is now a function, rather than a number. In the final line $f$ is a function that takes a function $g$ as input and produces a function $g^2-3g$ as output. So the same function can be considered as capable of operating on multiple types in a totally unambiguous way (they're not really the same because they have different domains and codomains, but this can be made precise). You'll see more of this if you get into functional programming.
A: This is very common.
Examples of functions
that map (or convert)
functions into other functions are'"derivative"
and "indefinite integral",
which I will write as,
respectively,
$D$ and $\int$.
Both of these would take a function
(such as $x^2$)
and the variable of differentiation
or integration
(such as $x$)
and return their derivative or indefinite integral
with respect to that variable.
Then $D(x^2, x) = 2x$
and $\int(x^2, x) = x^3/3+c$
(where $c$ is an arbitrary constant).
Note that the variable is quite important.
If it is not the same as the variable used by the function,
you get results like
$D(x^2, y) = 0$
and $\int(x^2, y) = y\ x^2+c$.
A: Yes, it's doable, and it's useful too.
Take for example the following 'indefinite integral function', which I'll denote by $I$. It takes three arguments:


*

*A real number $a$

*A real number $b$, with $a < b$

*A real-valued function $f$ which is defined and bounded on the interval $a < x < b$


Then define
$$I(a,b,f) = \int_a^b f(x)\, dx$$
This is as good a function as any, and takes a function as an argument.
You can even have functions which both take in functions as arguments and spit out functions afterwards. For example, there is a function on the class of differentiable real functions defined by
$$\dfrac{d}{dx} : f \mapsto f'$$
It takes in a function $f$ and spits out its derivative.

For the nitpickers: some of the conditions given above aren't necessary, such as the stipulation that $a<b$ or even that $f$ be real-valued or whatever. But hopefully this is a simple example that illustrates the use of a function of the kind the OP wants.
A: You can define real function $f(x)$ on arbitrary set. The trick is that functions itself can be considered as set too. 
For example you can get this famous physical formula for action of mechanical system:
$$\mathcal{S}[\mathbf{q}(t)] = \int_{t_1}^{t_2} L[\mathbf{q}(t),\dot{\mathbf{q}}(t),t]\, dt$$ 
or geometical formula for arc length:
$$l = \int_{a}^{b} \sqrt { 1 + [f'(x)]^2 }\, dx. $$
This is called functional. It studies by functional analysis and calculus of variation. Real interest and applications have a linear functionals that statisfies:
$$\Phi[\mathbf f+\mathbf g] = \Phi[\mathbf f] + \Phi[\mathbf g]$$
$$\Phi[c\ \mathbf f] = c\ \Phi[\mathbf f]$$
This of course not only application of idea of "function from function" in math. There is also a Lambda calculus and concept of recursion which is more related to computers.
