def root(self): """ >>> Matrix([[1, 2, 3], [4, 5, 6], [7, 8, 9]]).root().show() [1.0, 1.414213562373095, 1.7320508075688772] [2.0, 2.23606797749979, 2.449489742783178] [2.6457513110645907, 2.82842712474619, 3.0] """ return Matrix([[maths.sqrt(abs(self.content[row][column])) for column in range(self.columns)] for row in range(self.rows)])
def sqrt_inverse(self): """ >>> Matrix([[1, 2, 3], [4, 5, 6], [7, 8, 9]]).sqrt_inverse().show() [1.0, 0.7071067811865476, 0.5773502691896258] [0.5, 0.4472135954999579, 0.4082482904638631] [0.3779644730092272, 0.3535533905932738, 0.3333333333333333] """ return Matrix([[1.0 / maths.sqrt(abs(self.content[row][column])) if not (self.content[row][column]) == 0 else float("inf") for column in range(self.columns)] for row in range(self.rows)])
def test_sqrt(): x = 25 assert sqrt(x) == 5
# -*- coding: utf-8 -*- """ Created on Tue May 26 15:28:50 2020 @author: Lenovo """ #write a program to calculate area of an equilateral triangle? import maths x = float(input("enter side value:")) y = (maths.sqrt(3) / 4) * (x**2) print("area of equilateral triangle", y)
try: import maths print(maths.sqrt(9)) except ImportError as e: print(e)