Since
f(0)f(π)f(3π)=a+b+c+d,=−a+b−c+d,=2a−2b−c−2d,
then
a+b−c+d=f(0)+32f(π)+34f(3π)≤3
if and only if f(0)=f(π)=f(3π)=1, that is, if a=1, b+d=1 and c=−1, then the equality holds. Let t=cosx, −1≤t≤1. Then
f(x)−1=cosx+bcos2x−cos3x+dcos4x−1=t+(1−d)(2t2−1)−(4t3−3t)+d(8t4−8t2+1)−1=2(1−t2)[−4dt2+2t+(d−1)]≤0,∀t∈[−1,1],
that is
4dt2−2t+(1−d)≥0,∀t∈(−1,1).
Taking t=1/2+ϵ, ∣ϵ∣<1/2, then ϵ[(2d−1)+4dϵ]≥0, ∣ϵ∣<1/2. So we see that d=21. If d=21, then
4dt2−2t+(1−d)=2t2−2t+1/2=2(t−1/2)2≥0.
So, the maximal number of a+b−c+d is 3, and (a,b,c,d)=(1,21,−1,21). □