Double summation + other defined variable

See this post for the approach.