This file contains 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 main(): | |
current_msg_id = "" | |
ro_uuid_list = [] | |
ro_count = 0 | |
current_song_id = None | |
while True: | |
song_id, song_artist, song_name = get_song() | |
if song_id is None and song_artist is None and song_name is None: | |
song_id = current_song_id |
This file contains 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 secant(p, pOld, tol, iters): | |
iters -= 1 | |
pOld = p | |
pNew = p - (f(p))*(p - pOld) | |
if abs(pNew - p) < tol or iters == 0: | |
return pNew | |
else: | |
secant(pNew, pOld, tol) | |
def f(x): |
This file contains 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 secant(f, a, b, tol=1e-9, n=100): | |
fmt = "{:2} {:>13.10f} {:>13.10f} {:>13.10f}" | |
p1, p2 = float(a), float(b) | |
i = 1 | |
print fmt.format(1, p1, p2, f(p2)) | |
while abs(p1 - p2) > tol and i <= n: | |
p1, p2 = p2, p2 - (f(p2) * (p2 - p1)) / (f(p2) - f(p1)) | |
i += 1 | |
print fmt.format(i, p1, p2, f(p2)) | |
return p2 |