If you want to tinker with the outcome, you can use this in something like Jupyter:
import numpy as np
import matplotlib.pyplot as plt
from scipy.optimize import curve_fit
# Your data points
data_points = np.array([
[4.549, 99.559], [8.863, 99.284], [10.902, 99.091], [13.255, 98.926], [15.608, 98.706],
[20.314, 98.045], [24.235, 97.494], [28.471, 96.861], [31.765, 96.172], [35.529, 95.484],
[38.51, 94.713], [40.078, 94.328], [42.118, 93.887], [43.843, 93.226], [45.255, 92.923],
[46.353, 92.29], [47.451, 91.849], [48.549, 91.519], [49.333, 91.133], [50.118, 90.693],
[50.745, 90.142], [51.529, 89.757], [53.412, 88.545], [54.039, 88.325], [54.667, 87.884],
[56.235, 87.857], [57.647, 87.801], [59.686, 87.746], [62.667, 87.691], [67.373, 87.416],
[71.451, 87.251], [76, 87.086], [81.333, 86.893], [88.706, 86.562], [96.706, 86.287],
[103.451, 85.984], [108.157, 85.874], [115.294, 85.461]
])
# Split the data at x=54
split_index = np.argwhere(data_points[:, 0] >= 54)[0][0]
data_below_54 = data_points[:split_index]
data_above_54 = data_points[split_index:]
# Fit a cubic polynomial for x < 54
coeffs_below_54 = np.polyfit(data_below_54[:, 0], data_below_54[:, 1], 3)
# Fit a linear polynomial for x >= 54
coeffs_above_54 = np.polyfit(data_above_54[:, 0], data_above_54[:, 1], 1)
# Define the polynomial functions
poly_below_54 = np.poly1d(coeffs_below_54)
poly_above_54 = np.poly1d(coeffs_above_54)
# Create a range of x values for plotting the fit
x_range_below_54 = np.linspace(data_below_54[0, 0], data_below_54[-1, 0], 100)
x_range_above_54 = np.linspace(data_above_54[0, 0], data_above_54[-1, 0], 100)
# Plot the data
plt.figure(figsize=(10, 6))
plt.scatter(data_points[:, 0], data_points[:, 1], color='black', label='Data Points')
plt.plot(x_range_below_54, poly_below_54(x_range_below_54), label='Cubic Fit (x < 54)', color='blue')
plt.plot(x_range_above_54, poly_above_54(x_range_above_54), label='Linear Fit (x >= 54)', color='red')
plt.legend()
plt.xlabel('Return Temperature')
plt.ylabel('Efficiency')
plt.title('Return Water Temperature vs Efficiency for Condensing Boilers')
plt.grid(True)
plt.show()
print("Below 54:",poly_below_54)
print("Above 54:",poly_above_54)