Given a function $f(x) \in C[0,1]$, we define the $n$th Bernstein Operator $T_n$ by
$(T_nf)(t) = \sum_{k=0}^n {{n}\choose{k}}f\left(\frac{k}{n}\right)t^k(1 - t)^{n - k}$.
I'm trying to code this in Mathematica, but I don't see how it can be done to take an unknown function as an argument. My current working code is
b[f[x_]_, n_, t_] := Sum[(n!/(k!*(n - k)!))*f(k/n)*t^k*(1 - t)^(n - k), {k, 0, n}]
but this doesn't seem to work. Can anyone offer a way to take an undefined function as an input?
Edit: Though the code below in the comments works spectacularly, the code also works as-is, so long as one remembers to change $f(k/n)$ to $f[k/n]$, so that Mathematica knows to evaluate $f$ at $k/n$.
bop[n_Integer, f_, t_] := Sum[Binomial[n, k] Function[t, f][k/n] t^k (1 - t)^(n - k), {k, 0, n}]
, and then trybop[5, Exp[t], t]
. $\endgroup$BernsteinBasis[]
is built-in, so you can modify my code to shorten it further. $\endgroup$