The Earth Similarity Index (ESI) is a measurement that expresses the strength of the physical resemblance of a certain celestial body and the planet Earth. It is a scale that goes from zero (no resemblance) to one (absolute resemblance). The Earth itself of course has an ESI of 1,0. As a starting base for the calculation of the ESI, the de easy scale (ES) formula is used: \[ \textrm{ES} = \prod_{i=1}^{n}\left(1 - \left|\frac{o_i - r_i}{o_i + r_i}\right|\right)^{\frac{w_i}{n}} \] This formula expresses the resemblance of an object $$o$$ and a reference object $$r$$ based on the values for $$n$$ properties. The value of object $$o$$ for the $$i$$th property ($$1 \leq i \leq n$$) is represented in the formula as $$o_i$$, and for the reference object $$r$$ as $$r_i$$. The value $$w_i$$ is a weight exponent for the $$i$$th property, that can be used to express the importance of this property with regard to other properties.
When calculating the ESI, the average radius of the celestial body is taken into account, as well as its density, escape velocity and surface temperature. This list of properties, their reference values, and their weight exponents as they are used in calculating the ESI are in the table below.
property | reference value | weight exponent |
---|---|---|
average radius | 1,0 $$\oplus$$ | 0,57 |
density | 1,0 $$\oplus$$ | 1,07 |
escape velocity | 1,0 $$\oplus$$ | 0,70 |
surface temperature | 288 K | 5,58 |
Here, the symbol $$\oplus$$ represents earth unities. In order to distinguish the physical resemblance, the ESI is sometimes divided in two separate components — the interior ESI and the surface ESI. For the interior ESI, only the average radius and the density are brought into account, while the surface ESI only brings the escape velocity and the surface temperature into account.
ESI values between 0,8 and 1,0 correspond with earth-like planets with an earthly, rocky composition that are able to hold an atmosphere under moderate circumstances. According to this measurement, there are no other earth-like planets or moons to be found in our solar system. Mars has the second highest ESI (0,70) next to the Earth itself. However, a number of exoplanets have been discovered with ESI values that fit within the category of earth-like planets. The highest ESI known (0,92) was found for the recently discovered planet Gliese 581 g1.
Write a function ES that determines the resemblance between an object $$o$$ and a reference object $$r$$ according to the easy scale. This value must be printed as a floating point number. The function has three parameters: i) a list with values $$o_i$$ ($$1 \leq i \leq n$$) for $$n$$ properties of the object $$o$$, ii) a list with the corresponding reference values $$r_i$$ for a reference object $$r$$, and iii) a list with weight exponents $$w_i$$. This last parameter is optional. If no argument is given for this parameter, all weight exponents get values 1,0 in the formula of the easy scale. The function may assume that lists are always given for the different parameters, but it does have to check whether all these lists have the same length. If this isn't the case, the function AssertionError must raise the text invalid arguments.
Use the function ES to write a function ESI. This function has four parameters: i) a parameter $$r$$ to which the average radius of a celestial body can be given, ii) a parameter $$d$$ for density, iii) a parameter $$v$$ for the escape velocity and iv) a parameter $$t$$ for the surface temperature. If a value can be given for each of the four parameters, the function should print the ESI value. If only the average radius and the density can be given, the interior ESI must be printed. If only the escape velocity and the surface temperature can be given, the surface ESI must be printed. For all other combinations of values that are given to the parameters, the function AssertionError must raise the text invalid arguments.
>>> ES([1.36, 1.22, 1.51, 278.0], [1.0, 1.0, 1.0, 288.0])
0.879229825878449
>>> ES([1.36, 1.22, 1.51, 278.0], [1.0, 1.0, 1.0, 288.0], [0.57, 1.07, 0.70, 5.58])
0.8903703266879102
>>> ES([1.36, 1.22, 1.51], [1.0, 1.0, 1.0, 288.0])
Traceback (most recent call last):
AssertionError: invalid arguments
>>> ESI(1.00, 1.00, 1.00, 288.0) # Earth
1.0
>>> ESI(r=0.53, d=0.71) # Mars (interior ESI)
0.8154483513183794
>>> ESI(v=0.38, t=440.0) # Mercury (surface ESI)
0.42223988785100186
>>> ESI(t=278.0, v=1.51, d=1.22, r=1.36) # Gliese 581g
0.8903703266879102
>>> ESI(d=1.22, r=1.36) # Gliese 581g (interior ESI)
0.9021231636588817
>>> ESI(t=278.0, v=1.51) # Gliese 581g (surface ESI)
0.878770605369469
>>> ESI(r=0.27, d=0.60, t=220.0) # Moon
Traceback (most recent call last):
AssertionError: invalid arguments