## Step 1: Define the symbolic variables
Let's define the symbolic variables for the problem:
- $x_1$ represents the amount invested in his son's company.
- $x_2$ represents the amount invested in his friend's company.

## Step 2: Translate the natural language description into a symbolic representation
The symbolic representation of the variables is:
- $x_1$ : amount invested in his son's company
- $x_2$ : amount invested in his friend's company

## Step 3: Define the objective function
The objective is to maximize earnings. The earnings from his son's company are $0.08x_1$ and from his friend's company are $0.10x_2$. Therefore, the objective function to maximize is:
\[ \text{Maximize:} \quad 0.08x_1 + 0.10x_2 \]

## 4: Define the constraints
The constraints based on the problem description are:
1. The total amount invested is $50,000: $ $x_1 + x_2 \leq 50000$
2. The amount invested in his son's company must be at least three times as much as the amount invested in his friend's company: $x_1 \geq 3x_2$
3. The amount invested in his son's company is at most $40,000: $ $x_1 \leq 40000$
4. Non-negativity constraints: $x_1 \geq 0, x_2 \geq 0$

## 5: Compile the symbolic representation
The symbolic representation of the problem is:
```json
{
'sym_variables': [('x1', 'amount invested in his son\'s company'), ('x2', 'amount invested in his friend\'s company')],
'objective_function': '0.08*x1 + 0.10*x2',
'constraints': [
'x1 + x2 <= 50000',
'x1 >= 3*x2',
'x1 <= 40000',
'x1 >= 0',
'x2 >= 0'
]
}
```

## 6: Write the Gurobi code
Now, let's write the Gurobi code in Python to solve this problem:
```python
import gurobi

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

    # Define the variables
    x1 = model.addVar(name="x1", lb=0, ub=40000)  # amount invested in his son's company
    x2 = model.addVar(name="x2", lb=0)  # amount invested in his friend's company

    # Objective function: maximize 0.08*x1 + 0.10*x2
    model.setObjective(0.08*x1 + 0.10*x2, gurobi.GRB.MAXIMIZE)

    # Constraints
    model.addConstr(x1 + x2 <= 50000, name="total_investment")
    model.addConstr(x1 >= 3*x2, name="son_friend_investment_ratio")
    model.addConstr(x1 <= 40000, name="son_investment_limit")

    # Solve the model
    model.optimize()

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

solve_investment_problem()
```