my code works when determinant is positive but it doesn’t work for as it is trying to calculate root of negative number