This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Naive implementation of reduce normal form with some helper functions | |
from fractions import * | |
# helper functions | |
def row_sub(reduceby, reduceto, index): | |
""" | |
Take row to reduce and row to reduce by with the index of the element to | |
reduce to 0. Assume reduce by has value 1 in the index of reduceto. | |
""" | |
row_merged = [] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def newton(n, r, p = 0): | |
""" | |
(int(n), num(r), int(p)) -> float | |
Return the nth root of a positive number r displaying p correct decimals. | |
""" | |
x = 1 # start with guess = 1 | |
while True: | |
fx = x**n - r # function of this form solves all roots |
NewerOlder