# Illusion Joint Formula Analysis

## 1. Best Formula: Method B Joint PySR

### 1.1 Front Cylinder (alpha_F)

```
alpha_F = Cd_tot - (Cd_err + 5.4276643) - (-0.009783858)*(du_a_dt + u_a)
```

Simplified:
```
alpha_F = Cd_tot - Cd_err - 5.428 + 0.0098*(du_a_dt + u_a)
        = target_Cd - 5.428 + 0.0098*(du_a_dt + u_a)
```

### 1.2 Top Cylinder (alpha_T)

```
alpha_T = (Cd_err - (Cd_rear - Cl_err))*0.535 + 2.782
```

### 1.3 Physical Interpretation

**Front action** consists of three terms:

1. **target_Cd = Cd_tot - Cd_err**: Direct tracking of the target cylinder's drag coefficient. This is the dominant term — the controller outputs a cylinder rotation proportional to the desired drag. When the pinball's drag matches the target, Cd_err -> 0, and the controller simply tracks Cd_tot.

2. **-5.428**: Constant offset. Accounts for the difference in drag coefficient units/calibration between the pinball (3 cylinders) and the target (1 cylinder). The pinball generates inherently different drag magnitudes.

3. **0.0098*(du_a_dt + u_a)**: Small phase-lead correction from the cross-stream velocity asymmetry (u_a = u_top - u_bottom). This term fine-tunes the rotation timing to match the vortex shedding phase of the target cylinder. The derivative du_a_dt provides phase lead, improving timing accuracy.

**Top action** is error-state feedback:
- **Cd_err - (Cd_rear - Cl_err)**: Combines drag error with rear cylinder lift distribution. The Cd_rear term (total drag of top+bottom cylinders) captures how the rear pair is contributing to the overall drag mismatch.
- **+2.782**: Bias offset for the rear cylinders, which maintain a constant baseline rotation.
- **Bottom cylinder**: alpha_B = -Top composed with G-mirror (alpha_B = -top(G(x))).

## 2. Cross-Diameter Generalization Results

Joint formula CFD closed-loop performance across all tested target diameters:

| Diameter | Similarity | Formula Type | Status |
|:--------:|:----------:|:-----------:|--------|
| 0.5L | 0.854 | Joint | Generalization (unseen) |
| 0.6L | 0.939 | Joint | Generalization (unseen) |
| 0.75L | 0.978 | Joint | Trained (part of joint set) |
| 0.8L | 0.908 | Joint | Generalization (unseen) |
| 1.0L | 0.970 | Joint | Trained (part of joint set) |
| 1.2L | 0.849 | Joint | Generalization (unseen) |
| 1.5L | N/A | — | Non-SR regime (see Sec 4) |
| 2.0L | 0.676 | Joint | Generalization (unseen, degraded) |

## 3. Performance Trend Analysis

The joint formula maintains near-PPO performance (similarity > 0.9) within the approximate range **0.6L to 1.2L**, which represents roughly +/-20% of the training diameter range.

### 3.1 Within-Region Performance (0.6L-1.2L)

- Performance is highest near the training diameters (0.75L: 0.978, 1.0L: 0.970)
- Slight asymmetry: better performance for smaller-than-training (0.6L: 0.939) than larger-than-training (1.2L: 0.849)
- The formula captures the fundamental drag-error tracking mechanism, which is effective when the target wake is similar in character to the training wakes

### 3.2 Out-of-Region Degradation (0.5L, 2.0L)

- **0.5L (0.854)**: Moderate degradation. The target cylinder at half the pinball diameter produces very weak vortices that the pinball struggles to replicate with the current action scale.
- **2.0L (0.676)**: Severe degradation. The target cylinder at double diameter produces a wake that is physically beyond the pinball's ability to replicate. The pinball can generate the correct frequency structure but not the correct vortex strength and wake width.

## 4. The 1.5L Special Case

The 1.5L PPO policy achieves high similarity (0.945) but uses a fundamentally different control strategy:

### 4.1 Action Characteristics
- **High frequency**: dominant control frequency f=0.24 (control steps), which is 5.6x the target vortex shedding frequency
- **Anti-correlated**: action autocorrelation at lag-2 = -0.9 (switches direction every two steps)
- **Full amplitude**: uses the complete [-1, 1] action range
- **Low linearity**: all feature-action correlations < 0.33

### 4.2 Why Symbolic Regression Fails
- The current feature set (ILLUSION_PHASE, 10-dim) operates at the vortex shedding timescale (one measurement per shedding period)
- The 1.5L controller operates at 5.6x this frequency — the features cannot resolve the control dynamics
- PySR returns trivial solutions (alpha_F_lag1 * 0.01) because the fast action modulation appears as noise to the features

### 4.3 Nature of the Mechanism
The high-frequency modulation is not "bang-bang" control (actions saturate for only ~1% of steps). Rather, it is a **high-frequency periodic modulation** that likely exploits the pinball's rotational inertia to generate larger effective wake structures through rapid oscillation.

## 5. Individual Per-Diameter Formulas

For comparison, fitting PySR to each diameter individually yields:

**0.75L**:
```
alpha_F = -0.169 * (Cl_tot + dCl_tot_dt) - 1.240
```
Uses lift coefficient dynamics. CFD closed-loop: 0.979.

**1.0L**:
```
alpha_F = (du_a_dt + u_a + 26.5) * 0.0123
```
Uses phase-state (cross-stream velocity). CFD closed-loop: 0.957.

The structural difference between these individual formulas (lift-dominant vs phase-dominant) confirms that target diameter size changes the control mechanism. The joint formula bridges these by combining drag-tracking (dominant for both) with phase correction (stronger at 1.0L).

## 6. Joint Formula with Target Diameter Marker

When the target diameter is provided as an explicit feature, PySR discovers:

```
alpha_F = target_diameter * ((du_a_dt + u_a) * 0.0103 + 6.324) - 5.996
```

This formula explicitly uses the diameter to scale the phase correction term, demonstrating that the control law naturally incorporates the target size. The marker-based formula achieves R2=0.942 on the combined dataset.

## 7. Implications for Control Law Design

1. **Drag-error tracking is the universal mechanism**: All successful formulas include Cd_tot - Cd_err (or an equivalent drag-based term). This is the core feedback structure for the illusion task.

2. **Phase correction becomes important at intermediate diameters**: The du_a_dt + u_a term appears in both the 1.0L individual formula and the joint formula, suggesting phase alignment is critical when the target wake frequency is close to the pinball's natural frequency.

3. **Regime boundaries are predictable**: The formula degrades predictably with diameter deviation, defining clear applicability limits.

4. **Large-diameter illusion requires different physics**: The 1.5L case shows that when the required wake strength exceeds what drag-error tracking alone can provide, qualitatively different control strategies emerge.
