cos(x)
- import math
- def funcos(esp, x):
- x = float(x)
- c1 = float(1)
- c2 = float(0)
- y = 1
- z = 2
- while(math.fabs(c1) > esp):
- c2 += c1
- c1 = (-1)*c1*x*x/y/z
- y += 2
- z += 2
- c2 += c1
- print(c2)
- esp = float(input('请输入esp:'))
- x = float(input('请输入x:'))
- funcos(esp, x)