fork(1) download
  1. import math
  2. import numpy
  3. print("x: f*: f:")
  4. x = 0.2
  5. for i in range(11):
  6. y = 3 * x + 0.6
  7. z = 1 - x**2
  8. g = 0.9 * x + 1
  9. s1 = 0
  10. s2 = 0
  11. s3 = 0
  12. n = 0
  13. while y**(2*n+1)/math.factorial(2*n+1) > 10**(-6)/2:
  14. n += 1
  15. for j in range(n + 1):
  16. s1 += (-1)**j*y**(2*j+1)/math.factorial(2*j+1)
  17. n = 0
  18. w = 1.0
  19. w2 = (1 + (g))/2.0
  20. while abs(w2-w)*g > 10**(-6)/1.92:
  21. w = w2
  22. w2 = (w+ g/w) / 2.0
  23.  
  24. s2 = w2/z
  25. while s2**-(2*n+1)/(2*n+1) > 10**(-6)/2:
  26. n += 1
  27. for j in range(n + 1):
  28. s3 += (-1)**n*s2**(-2*n-1)/(2*n+1)
  29. s_3 = (math.pi/2)*numpy.sign(s2)-s3
  30. print(round(x,2), " ", s1+s_3 ," ", math.atan((0.9*x+1)**0.5/(1-x**2))+math.sin(3*x+0.6))
  31. x += 0.01
Success #stdin #stdout 0.08s 92224KB
stdin
Standard input is empty
stdout
x:		f*:						f:
0.2   2.50285317667   1.7790701807420557
0.21   2.51330051976   1.7935267473931615
0.22   2.52290068279   1.8072298824942274
0.23   2.53164483101   1.8201720480035357
0.24   2.53952503805   1.832346510068393
0.25   2.5465342632   1.843747345734187
0.26   2.55263819836   1.8543694489197282
0.27   2.55788261421   1.8642085356484386
0.28   2.56226649229   1.8732611485253816
0.29   2.5657102995   1.8815246604505282
0.3   2.56830067898   1.8889972775590658