Sorry, I was away from my computer and could not write up an answer right away. I think this is what you want:
Generate some data points that FindFit
can work with:
data = Table[{x, f[x]}, {x, 0, Pi, Pi/1000}];
Use FindFit
with the infinity norm (see the docs of NormFunction
for an example):
bestfit = FindFit[N@data, g[x], {c1, c2, c3, c4}, x, NormFunction -> (Norm[#1, Infinity] & )]
{c1 -> 0.880948, c2 -> -8.93938, c3 -> 6.25143, c4 -> -0.385789}
Notice that it is different when least squares is used:
FindFit[N@data, g[x], {c1, c2, c3, c4}, x]
{c1 -> 1.4222, c2 -> -10.3303, c3 -> 6.92248, c4 -> -0.409044}
Store the best-fit expression:
h = g[x] /. bestfit;
Compare:
Plot[{f[x], h}, {x, 0, Pi}]

NonLinearModelFit
in the docs. $\endgroup$FindFit
has an option calledNormFunction
, I think that is what you are after. $\endgroup$FindFit
andNonLinearModelFit
seem to require one to supply data points. Are you suggesting OP generate data points? $\endgroup$