Formula in example

edit

When the optimum is each   having   blue and   red points the formula should be  . I'm new to this topic so I am asking here first.