Similar idea to belisarius, except in V10 we can inactivate Integrate
to keep it from evaluating or even trying to evaluate:
h = Inactive[Integrate][g, {x, -Infinity, Infinity}]
It is not necessary in this example, as belisarius' answer shows, but one of its intended uses is to do algebra/calculus on integrals and derivatives. Inactive
can be removed easily with
Activate[h]
The function linearExpand
expands its argument according to linearity properties. Factors/terms that do not depend on x
are treated as constants (see update below for a more general approach).
Clear[linearExpand];
linearExpand[e_] := e //. {int : Inactive[Integrate][_Plus, _] :> Distribute[int],
Inactive[Integrate][integrand_Times, dom : {x_, _, _} | x_] :>
With[{dependencies = Internal`DependsOnQ[#, x] & /@ List @@ integrand},
Pick[integrand, dependencies, False] *
Inactive[Integrate][Pick[integrand, dependencies, True], dom]
]};
OP's sample problem:
Solve[D[h, #] == 0 & /@ cs // linearExpand, cs]

D[h, #] == 0 & /@ cs // linearExpand

For what it's worth...
...here's a general linearity expander. Considers factors that do not depend on x
, which may be a list of symbols, as constants.
linearExpand[e_, x_, head_] :=
e //. {op : head[arg_Plus, __] :> Distribute[op],
head[arg1_Times, rest__] :>
With[{dependencies = Internal`DependsOnQ[#, x] & /@ List @@ arg1},
Pick[arg1, dependencies, False] head[
Pick[arg1, dependencies, True], rest]
]};
Examples:
linearExpand[D[h, #] == 0 & /@ cs, x, Inactive[Integrate]]
(* same as above *)
linearExpand[foo[(a[x] + c b[y]) (2 a[x] - c b[y]) // Expand, randomarg], x, foo]
(* -c^2 b[y]^2 foo[1, randomarg] +
c b[y] foo[a[x], randomarg] +
2 foo[a[x]^2, randomarg] *)
linearExpand[foo[(a[x] + c b[y]) (2 a[x] - c b[y]) // Expand, randomarg], {x, y}, foo]
(* 2 foo[a[x]^2, randomarg] +
c foo[a[x] b[y], randomarg] -
c^2 foo[b[y]^2, randomarg] *)