## Problem Description and Formulation

The problem is a linear programming optimization problem. The dentist wants to maximize profit by investing in two toothpaste companies, A and B, with the following constraints:

- The total investment should not exceed $5000.
- At least 40% of the investment should be in toothpaste company A.
- At least $1000 should be invested in toothpaste company B.

Let's denote:
- \(x_A\) as the amount invested in toothpaste company A,
- \(x_B\) as the amount invested in toothpaste company B.

The objective function to maximize profit is:
\[ \text{Maximize:} \quad 0.12x_A + 0.14x_B \]

Subject to:
1. \( x_A + x_B \leq 5000 \) (Total investment not exceeding $5000)
2. \( x_A \geq 0.4(x_A + x_B) \) (At least 40% in toothpaste company A)
3. \( x_B \geq 1000 \) (At least $1000 in toothpaste company B)
4. \( x_A, x_B \geq 0 \) (Non-negativity constraint)

## Converting Constraints

- The second constraint can be rewritten as \( x_A \geq 0.4x_A + 0.4x_B \) or \( 0.6x_A \geq 0.4x_B \) or \( 1.5x_A \geq x_B \).

## Gurobi Code

```python
import gurobi

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

    # Define variables
    x_A = model.addVar(name="x_A", lb=0)  # Investment in A
    x_B = model.addVar(name="x_B", lb=0)  # Investment in B

    # Objective function: Maximize 0.12x_A + 0.14x_B
    model.setObjective(0.12 * x_A + 0.14 * x_B, gurobi.GRB.MAXIMIZE)

    # Constraints
    model.addConstr(x_A + x_B <= 5000, name="total_investment")
    model.addConstr(x_B >= 1000, name="min_investment_B")
    model.addConstr(1.5 * x_A >= x_B, name="min_percentage_A")

    # Optimize
    model.optimize()

    # Print solution
    if model.status == gurobi.GRB.OPTIMAL:
        print(f"Optimal investment in A: ${x_A.varValue:.2f}")
        print(f"Optimal investment in B: ${x_B.varValue:.2f}")
        print(f"Max Profit: ${model.objVal:.2f}")
    else:
        print("The problem is infeasible.")

solve_investment_problem()
```