master
E. Almqvist 3 years ago
parent 4bfe05e5b8
commit 522c735cef
  1. 0
      mas/newton-raphsons/approx_method.py
  2. 17
      mas/newton-raphsons/user_method.py

@ -1,5 +1,4 @@
#!/usr/bin/python #!/usr/bin/python
import operator
def new_rap(x, func: str="0", der: str="0", iter=0): def new_rap(x, func: str="0", der: str="0", iter=0):
y_exper = func.replace("x", str(x)) y_exper = func.replace("x", str(x))
@ -12,22 +11,6 @@ def new_rap(x, func: str="0", der: str="0", iter=0):
new_x = x - (y / der) new_x = x - (y / der)
return new_x return new_x
# def new_rap(x, func=nullfunc, dx=0.1):
# new_x = None
# try:
# while x != new_x:
# y = func(x)
# der = derive(x, func, dx)
# new_x = x - y/der
# if new_x == x:
# return new_x
# else:
# x = new_x
# return x
# except ZeroDivisionError as error:
# print(f"{y=} {der=} {new_x=}")
# print(error)
def eval_func( func: str, x: float ): def eval_func( func: str, x: float ):
y_exper = func.replace("x", str(x)) y_exper = func.replace("x", str(x))
return eval(y_exper) return eval(y_exper)
Loading…
Cancel
Save