To solve the optimization problem described, we need to formulate it as a quadratic programming problem since the objective function and some of the constraints involve quadratic terms. We will use Gurobi, a powerful solver for linear and quadratic programming problems.

Given:
- Objective function: Minimize \(3.72 \times (\text{milligrams of vitamin K})^2 + 4.42 \times (\text{milligrams of vitamin K}) \times (\text{milligrams of vitamin B3}) + 7.14 \times (\text{milligrams of vitamin B3})^2 + 5.68 \times (\text{milligrams of vitamin K}) + 3.49 \times (\text{milligrams of vitamin B3})\)
- Constraints:
  1. \(8 \times (\text{milligrams of vitamin K}) + 8 \times (\text{milligrams of vitamin B3}) \geq 51\)
  2. \(8 \times (\text{milligrams of vitamin K}) + 8 \times (\text{milligrams of vitamin B3}) \leq 67\)
  3. \((\text{milligrams of vitamin K})^2 + (\text{milligrams of vitamin B3})^2 \geq 51\)
  4. \(-2 \times (\text{milligrams of vitamin K}) + 5 \times (\text{milligrams of vitamin B3}) \geq 0\)

Let \(x_1\) be the milligrams of vitamin K and \(x_2\) be the milligrams of vitamin B3.

The problem can be formulated as a quadratic program:

Minimize: \(3.72x_1^2 + 4.42x_1x_2 + 7.14x_2^2 + 5.68x_1 + 3.49x_2\)

Subject to:
- \(8x_1 + 8x_2 \geq 51\)
- \(8x_1 + 8x_2 \leq 67\)
- \(x_1^2 + x_2^2 \geq 51\)
- \(-2x_1 + 5x_2 \geq 0\)
- \(x_1 \in \mathbb{Z}\) (integer constraint for vitamin K)

Here's how you can implement this in Gurobi using Python:

```python
from gurobipy import *

# Create a new model
m = Model("Vitamin_Optimization")

# Add variables
x1 = m.addVar(vtype=GRB.INTEGER, name="milligrams_of_vitamin_K")
x2 = m.addVar(vtype=GRB.CONTINUOUS, name="milligrams_of_vitamin_B3")

# Set the objective function
m.setObjective(3.72*x1**2 + 4.42*x1*x2 + 7.14*x2**2 + 5.68*x1 + 3.49*x2, GRB.MINIMIZE)

# Add constraints
m.addConstr(8*x1 + 8*x2 >= 51, name="total_energy_stability_index_min")
m.addConstr(8*x1 + 8*x2 <= 67, name="total_energy_stability_index_max")
m.addConstr(x1**2 + x2**2 >= 51, name="squared_energy_stability_index_min")
m.addConstr(-2*x1 + 5*x2 >= 0, name="vitamin_balance")

# Optimize model
m.optimize()

# Print results
if m.status == GRB.OPTIMAL:
    print("Optimal solution found:")
    print("Milligrams of Vitamin K:", x1.x)
    print("Milligrams of Vitamin B3:", x2.x)
    print("Objective function value:", m.objVal)
else:
    print("No optimal solution found. Status:", m.status)
```