## Problem Description and Formulation

The problem is a linear programming optimization problem. The goal is to maximize earnings from investments in two companies: the son's company and the friend's company.

### Variables

- $x$: The amount invested in the son's company.
- $y$: The amount invested in the friend's company.

### Objective Function

The objective is to maximize the total earnings from both investments. The earnings from the son's company are $0.08x$ (8% of $x$), and the earnings from the friend's company are $0.10y$ (10% of $y$). Therefore, the objective function to maximize is:

\[ \text{Maximize:} \quad 0.08x + 0.10y \]

### Constraints

1. **Total Investment Limit**: The total amount invested in both companies cannot exceed $50,000.
\[ x + y \leq 50000 \]

2. **Minimum Investment Ratio**: The amount invested in the son's company must be at least three times the amount invested in the friend's company.
\[ x \geq 3y \]

3. **Maximum Investment in Son's Company**: The amount invested in the son's company cannot exceed $40,000.
\[ x \leq 40000 \]

4. **Non-Negativity**: The investments in both companies cannot be negative.
\[ x \geq 0, y \geq 0 \]

## Gurobi Code

```python
import gurobi

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

    # Define variables
    x = model.addVar(name="son's_company_investment", lb=0)
    y = model.addVar(name="friend's_company_investment", lb=0)

    # Objective function: Maximize earnings
    model.setObjective(0.08 * x + 0.10 * y, gurobi.GRB.MAXIMIZE)

    # Constraints
    model.addConstr(x + y <= 50000, name="total_investment_limit")
    model.addConstr(x >= 3 * y, name="minimum_investment_ratio")
    model.addConstr(x <= 40000, name="maximum_investment_in_son_company")

    # Optimize
    model.optimize()

    # Print solution
    if model.status == gurobi.GRB.OPTIMAL:
        print(f"Optimal investment in son's company: ${x.varValue:.2f}")
        print(f"Optimal investment in friend's company: ${y.varValue:.2f}")
        print(f"Maximized earnings: ${0.08 * x.varValue + 0.10 * y.varValue:.2f}")
    else:
        print("No optimal solution found.")

if __name__ == "__main__":
    solve_investment_problem()
```