## Problem Description and Formulation

The problem is an optimization problem with two variables: 'milligrams of vitamin B2' and 'milligrams of magnesium'. The objective function to be minimized is:

\[ 9 \times (\text{milligrams of vitamin B2})^2 + 4 \times (\text{milligrams of vitamin B2}) \times (\text{milligrams of magnesium}) + 7 \times (\text{milligrams of magnesium})^2 + 8 \times (\text{milligrams of vitamin B2}) \]

The problem has several constraints based on the immune support index and digestive support index.

## Constraints

1. Immune support index for milligrams of vitamin B2: \(3 \times (\text{milligrams of vitamin B2}) \leq 148\)
2. Digestive support index for milligrams of vitamin B2: \(8 \times (\text{milligrams of vitamin B2}) \leq 76\)
3. Immune support index for milligrams of magnesium: \(2 \times (\text{milligrams of magnesium}) \leq 148\)
4. Digestive support index for milligrams of magnesium: \(1 \times (\text{milligrams of magnesium}) \leq 76\)
5. Total combined immune support index: \(3 \times (\text{milligrams of vitamin B2}) + 2 \times (\text{milligrams of magnesium}) \geq 55\)
6. Total combined digestive support index: \(8 \times (\text{milligrams of vitamin B2}) + 1 \times (\text{milligrams of magnesium}) \geq 21\)
7. Linear constraint: \(-3 \times (\text{milligrams of vitamin B2}) + 3 \times (\text{milligrams of magnesium}) \geq 0\)
8. Total combined immune support index upper bound: \(3 \times (\text{milligrams of vitamin B2}) + 2 \times (\text{milligrams of magnesium}) \leq 142\)
9. Total combined digestive support index upper bound: \((8 \times (\text{milligrams of vitamin B2}))^2 + (1 \times (\text{milligrams of magnesium}))^2 \leq 64\)

## Gurobi Code

```python
import gurobi

def optimize_vitamin_magnesium():
    # Create a new Gurobi model
    model = gurobi.Model()

    # Define variables
    vitamin_B2 = model.addVar(lb=-gurobi.GRB.INFINITY, ub=gurobi.GRB.INFINITY, name="vitamin_B2")
    magnesium = model.addVar(lb=-gurobi.GRB.INFINITY, ub=gurobi.GRB.INFINITY, name="magnesium")

    # Objective function
    model.setObjective(9 * vitamin_B2 ** 2 + 4 * vitamin_B2 * magnesium + 7 * magnesium ** 2 + 8 * vitamin_B2, gurobi.GRB.MINIMIZE)

    # Constraints
    model.addConstr(3 * vitamin_B2 <= 148, name="immune_support_vitamin_B2")
    model.addConstr(8 * vitamin_B2 <= 76, name="digestive_support_vitamin_B2")
    model.addConstr(2 * magnesium <= 148, name="immune_support_magnesium")
    model.addConstr(magnesium <= 76, name="digestive_support_magnesium")
    model.addConstr(3 * vitamin_B2 + 2 * magnesium >= 55, name="total_immune_support_min")
    model.addConstr(8 * vitamin_B2 + magnesium >= 21, name="total_digestive_support_min")
    model.addConstr(-3 * vitamin_B2 + 3 * magnesium >= 0, name="linear_constraint")
    model.addConstr(3 * vitamin_B2 + 2 * magnesium <= 142, name="total_immune_support_max")
    model.addConstr((8 * vitamin_B2) ** 2 + magnesium ** 2 <= 64, name="total_digestive_support_max")

    # Optimize
    model.optimize()

    # Print solution
    if model.status == gurobi.GRB.OPTIMAL:
        print("Optimal solution found.")
        print(f"Milligrams of vitamin B2: {vitamin_B2.varValue}")
        print(f"Milligrams of magnesium: {magnesium.varValue}")
        print(f"Objective function value: {model.objVal}")
    elif model.status == gurobi.GRB.INFEASIBLE:
        print("No feasible solution exists.")
    else:
        print("Optimization failed.")

optimize_vitamin_magnesium()
```