Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import math
- print("Lab_4 / 16var")
- print("Task 1")
- while True:
- try:
- x = int(input("Enter x: "))
- n = int(input("Enter n: "))
- break
- except ValueError:
- print("Enter an integer")
- z = 0
- for i in range(1, n):
- if (i == 1):
- z = x
- elif (i % 2 == 0):
- print(i, "Even")
- z -= x ** i / i
- else:
- print(i, "Odd")
- z += x ** i / i
- print(z)
- print("Task 2")
- a = 2
- b = 4
- n = 16
- x = a
- count = 0
- print("count | x | F1(x) | F2(x)")
- while x <= b:
- count += 1
- f1 = x * math.cos(x / 2)
- f2 = x ** (1 / 3) + math.sqrt(2) * math.exp(-x)
- print(count, " | ", "%.3f" % x, "|", "%.8f" % f1, "|", "%.8f" % f2)
- x += (b - a) / n
Advertisement
Add Comment
Please, Sign In to add comment