Example 1. The cubic functions that "best"
approximates:
x: -0.2, 1.3, 1.7, 3.2, 4.1, 4.6
y: 9.1, 17.5, 20.7, 25.4, 35.7, 51.2
I get: y = 1.207*x^3 - 6.3*x^2 + 12*x + 11.6
rounding of: 1.206848298078874*x^3 - 6.299120865024337*x^2 + 11.857283859719152*x + 11.552743903807526)
How to graphically represent what was obtained: see here.
The graph can also be drawn, in addition to with R, with Desmos:
Example 2. Average values of pressure (atm) corresponding to altitude (km) [values taken by NASA]:
km: 0, 1, 2, 4, 6, 8, 10, 15, 20, 30
atm: 1,0.886,0.785,0.608,0.465,0.35,0.26,0.115,0.069,0.012
P = -6.9e-05 * A^3 + 0.00482 * A^2 + -0.115 * A + 0.998
How to graphically represent what was obtained: see here.