mirror of
https://github.com/TheAlgorithms/Python.git
synced 2025-02-25 10:28:39 +00:00
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:
commit
64449865ae
@ -717,6 +717,7 @@
|
|||||||
* [Archimedes Principle](physics/archimedes_principle.py)
|
* [Archimedes Principle](physics/archimedes_principle.py)
|
||||||
* [Casimir Effect](physics/casimir_effect.py)
|
* [Casimir Effect](physics/casimir_effect.py)
|
||||||
* [Centripetal Force](physics/centripetal_force.py)
|
* [Centripetal Force](physics/centripetal_force.py)
|
||||||
|
* [Grahams Law](physics/grahams_law.py)
|
||||||
* [Horizontal Projectile Motion](physics/horizontal_projectile_motion.py)
|
* [Horizontal Projectile Motion](physics/horizontal_projectile_motion.py)
|
||||||
* [Hubble Parameter](physics/hubble_parameter.py)
|
* [Hubble Parameter](physics/hubble_parameter.py)
|
||||||
* [Ideal Gas Law](physics/ideal_gas_law.py)
|
* [Ideal Gas Law](physics/ideal_gas_law.py)
|
||||||
|
@ -44,7 +44,13 @@ def points_to_polynomial(coordinates: list[list[int]]) -> str:
|
|||||||
x = len(coordinates)
|
x = len(coordinates)
|
||||||
|
|
||||||
# put the x and x to the power values in a matrix
|
# 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
|
# put the y values into a vector
|
||||||
vector: list[float] = [coordinates[count_of_line][1] for count_of_line in range(x)]
|
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
|
zahlen += 1
|
||||||
|
|
||||||
# make solutions
|
# 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)="
|
solved = "f(x)="
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user