Skip to content

Commit 85e9f4a

Browse files
committed
Implemented choosing of initial approximation from the ends of the segment for newton method
1 parent 96c8903 commit 85e9f4a

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

lab1/newton.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
def derivativeF(x):
44
return 10 * x**4 + 6 * x - 2
55

6+
def derivative2F(x):
7+
return 40 * x**3 + 6
8+
69
def newton(x0, accuracy):
710
iteration = 1
811
while True:
@@ -13,4 +16,7 @@ def newton(x0, accuracy):
1316
iteration += 1
1417
return x0
1518

16-
newton(b, accuracy)
19+
if f(a) * derivative2F(a) > 0:
20+
newton(a, accuracy)
21+
elif f(b) * derivative2F(b) > 0:
22+
newton(b, accuracy)

lab1/record/index.pdf

1.09 KB
Binary file not shown.

0 commit comments

Comments
 (0)