I think your worksheet needs a little work. I suggest to go through it and check your definitions.
You have made f.s dependant on a, but called it up as it as f.s(i,a) in the definition of omegaP.n(a) and omegaM.n(a).
I personally try to keep away from using range variables and tend to use vectors.
Apart from the missing argument in function f.s there was a missing multiplication sign in a leter definition (so b was interpreted as unknown function instead of a varaible).
Hope the attached sheet is what you were trying to do.