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. n = 0
  26. while s2**-(2*n+1)/(2*n+1) > 10**(-6)/2:
  27. n += 1
  28. for j in range(n + 1):
  29. s3 += (math.pi/2)*numpy.sign(s2)-(-1)**n*s2**(-2*n-1)/(2*n+1)
  30. print(round(x,2), " ", s1+s3 ," ", 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   66.9055025753   1.7790701807420557
0.21   63.7743572648   1.7935267473931615
0.22   60.6423647742   1.8072298824942274
0.23   57.5095162688   1.8201720480035357
0.24   54.3758038223   1.832346510068393
0.25   51.2412203938   1.843747345734187
0.26   49.6765280022   1.8543694489197282
0.27   46.5401797645   1.8642085356484386
0.28   44.9737673158   1.8732611485253816
0.29   43.4064147962   1.8815246604505282
0.3   41.8382088489   1.8889972775590658