# Manually compute ARIMAX forecast

I need to forecast a phenomenon using an autoregressive model with an exogenous variable. I've estimated an ARIMA(1,0,0) model, but I can't understand how the forecasts are calculated.

Below is the dataset and the code used

# History data
y <- c(NA, 18.53499, 18.45049, 18.50638, 18.56233, 18.57174, 18.57489, 18.65894, 18.73435, 18.74276, 18.89068, 18.86537, 18.90476, 18.86128, 18.89691, 18.93336, 18.99445, 18.93349, 18.97266, 18.99395, 19.04327, 19.09495, 19.20510, 19.22705, 19.23720, 19.30036)
X <- c(NA, 20.84371, 20.87513, 20.95040, 21.01817, 21.07814, 21.13471, 21.17879, 21.26326, 21.32649, 21.44111, 21.49291, 21.50877, 21.49673, 21.49891, 21.48236, 21.45077, 21.44423, 21.48529, 21.57711, 21.66768, 21.73942, 21.84075, 21.81733, 21.86867, 21.98712)

# Forecast data
y_pred <- c(rep(NA, 10))
X_pred <- c(22.12033, 22.18879, 22.24636, 22.30394, 22.36263, 22.40278, 22.44473, 22.49994, 22.56897, 22.64044)

# Convert to ts object
history_data <- ts(cbind(y, X), start = 1998, end = 2022)
pred_data <- ts(cbind(y_pred, X_pred), start=2023)

# Estimate ARIMAX(1,0,0)
arima_model <- arima(
x=history_data[, "y"],
order=c(1,0,0),
xreg = history_data[, "X"],
include.mean=TRUE
)

The issue arises at the time of predictions. I have realized that the coefficients, multiplied by the autoregressive component and the exogenous component, do not match the forecast used by the predict function. I can't figure out what I am doing wrong or what the model code is doing without explicitly stating it!

Below are the values returned by the forecast and the calculation of the first prediction point done manually.

# Model forecast
pred_arima <- predict(arima_model, newxreg=pred_data[, "X_pred"])
pred_arima\$pred
# A Time Series: 19.4091463551622 19.4598067255605 19.5024085006676 19.5450176757704 etc

# Manual forecast for the first forecast point
# 3.02318504045974 + 0.54237200749617 * 19.30036 + 0.739999567606275 * 22.12033 = 29.8601946743666

I'm seeking help because if I calculate the forecast manually, I get significantly different values (For the first point and also for the subsequent ones): 19.4091463551622 (from the model) vs 29.8601946743666 (calculated manually). What am I doing wrong?