Merge branch 'reduce-the-complexity-of-linear_algebra/src/polynom_for_points.py' of https://github.com/MaximSmolskiy/Python into reduce-the-complexity-of-linear_algebra/src/polynom_for_points.py

This commit is contained in:
MaximSmolskiy 2023-04-01 22:48:35 +03:00
commit 64449865ae
2 changed files with 11 additions and 2 deletions

View File

@ -717,6 +717,7 @@
* [Archimedes Principle](physics/archimedes_principle.py)
* [Casimir Effect](physics/casimir_effect.py)
* [Centripetal Force](physics/centripetal_force.py)
* [Grahams Law](physics/grahams_law.py)
* [Horizontal Projectile Motion](physics/horizontal_projectile_motion.py)
* [Hubble Parameter](physics/hubble_parameter.py)
* [Ideal Gas Law](physics/ideal_gas_law.py)

View File

@ -44,7 +44,13 @@ def points_to_polynomial(coordinates: list[list[int]]) -> str:
x = len(coordinates)
# put the x and x to the power values in a matrix
matrix: list[list[float]] = [[coordinates[count_of_line][0] ** (x - (count_in_line + 1)) for count_in_line in range(x)] for count_of_line in range(x)]
matrix: list[list[float]] = [
[
coordinates[count_of_line][0] ** (x - (count_in_line + 1))
for count_in_line in range(x)
]
for count_of_line in range(x)
]
# put the y values into a vector
vector: list[float] = [coordinates[count_of_line][1] for count_of_line in range(x)]
@ -65,7 +71,9 @@ def points_to_polynomial(coordinates: list[list[int]]) -> str:
zahlen += 1
# make solutions
solution: list[str] = [str(vector[count] / matrix[count][count]) for count in range(x)]
solution: list[str] = [
str(vector[count] / matrix[count][count]) for count in range(x)
]
solved = "f(x)="