m2m模型翻译
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

296 lines
7.4 KiB

6 months ago
  1. # A collection of failing integrals from the issues.
  2. from sympy.core.numbers import (I, Rational, oo, pi)
  3. from sympy.core.singleton import S
  4. from sympy.core.symbol import symbols
  5. from sympy.functions.elementary.complexes import sign
  6. from sympy.functions.elementary.exponential import (exp, log)
  7. from sympy.functions.elementary.hyperbolic import (csch, sech, sinh)
  8. from sympy.functions.elementary.miscellaneous import sqrt
  9. from sympy.functions.elementary.piecewise import Piecewise
  10. from sympy.functions.elementary.trigonometric import (acos, atan, cos, sec, sin, tan)
  11. from sympy.functions.special.delta_functions import DiracDelta
  12. from sympy.functions.special.gamma_functions import gamma
  13. from sympy.integrals.integrals import (Integral, integrate)
  14. from sympy.testing.pytest import XFAIL, SKIP, slow, skip, ON_TRAVIS
  15. from sympy.abc import x, k, c, y, b, h, a, m, z, n, t
  16. @SKIP("Too slow for @slow")
  17. @XFAIL
  18. def test_issue_3880():
  19. # integrate_hyperexponential(Poly(t*2*(1 - t0**2)*t0*(x**3 + x**2), t), Poly((1 + t0**2)**2*2*(x**2 + x + 1), t), [Poly(1, x), Poly(1 + t0**2, t0), Poly(t, t)], [x, t0, t], [exp, tan])
  20. assert not integrate(exp(x)*cos(2*x)*sin(2*x) * (x**3 + x**2)/(2*(x**2 + x + 1)), x).has(Integral)
  21. @XFAIL
  22. def test_issue_4212():
  23. assert not integrate(sign(x), x).has(Integral)
  24. @XFAIL
  25. def test_issue_4491():
  26. # Can be solved via variable transformation x = y - 1
  27. assert not integrate(x*sqrt(x**2 + 2*x + 4), x).has(Integral)
  28. @XFAIL
  29. def test_issue_4511():
  30. # This works, but gives a complicated answer. The correct answer is x - cos(x).
  31. # If current answer is simplified, 1 - cos(x) + x is obtained.
  32. # The last one is what Maple gives. It is also quite slow.
  33. assert integrate(cos(x)**2 / (1 - sin(x))) in [x - cos(x), 1 - cos(x) + x,
  34. -2/(tan((S.Half)*x)**2 + 1) + x]
  35. @XFAIL
  36. def test_integrate_DiracDelta_fails():
  37. # issue 6427
  38. assert integrate(integrate(integrate(
  39. DiracDelta(x - y - z), (z, 0, oo)), (y, 0, 1)), (x, 0, 1)) == S.Half
  40. @XFAIL
  41. @slow
  42. def test_issue_4525():
  43. # Warning: takes a long time
  44. assert not integrate((x**m * (1 - x)**n * (a + b*x + c*x**2))/(1 + x**2), (x, 0, 1)).has(Integral)
  45. @XFAIL
  46. @slow
  47. def test_issue_4540():
  48. if ON_TRAVIS:
  49. skip("Too slow for travis.")
  50. # Note, this integral is probably nonelementary
  51. assert not integrate(
  52. (sin(1/x) - x*exp(x)) /
  53. ((-sin(1/x) + x*exp(x))*x + x*sin(1/x)), x).has(Integral)
  54. @XFAIL
  55. @slow
  56. def test_issue_4891():
  57. # Requires the hypergeometric function.
  58. assert not integrate(cos(x)**y, x).has(Integral)
  59. @XFAIL
  60. @slow
  61. def test_issue_1796a():
  62. assert not integrate(exp(2*b*x)*exp(-a*x**2), x).has(Integral)
  63. @XFAIL
  64. def test_issue_4895b():
  65. assert not integrate(exp(2*b*x)*exp(-a*x**2), (x, -oo, 0)).has(Integral)
  66. @XFAIL
  67. def test_issue_4895c():
  68. assert not integrate(exp(2*b*x)*exp(-a*x**2), (x, -oo, oo)).has(Integral)
  69. @XFAIL
  70. def test_issue_4895d():
  71. assert not integrate(exp(2*b*x)*exp(-a*x**2), (x, 0, oo)).has(Integral)
  72. @XFAIL
  73. @slow
  74. def test_issue_4941():
  75. if ON_TRAVIS:
  76. skip("Too slow for travis.")
  77. assert not integrate(sqrt(1 + sinh(x/20)**2), (x, -25, 25)).has(Integral)
  78. @XFAIL
  79. def test_issue_4992():
  80. # Nonelementary integral. Requires hypergeometric/Meijer-G handling.
  81. assert not integrate(log(x) * x**(k - 1) * exp(-x) / gamma(k), (x, 0, oo)).has(Integral)
  82. @XFAIL
  83. def test_issue_16396a():
  84. i = integrate(1/(1+sqrt(tan(x))), (x, pi/3, pi/6))
  85. assert not i.has(Integral)
  86. @XFAIL
  87. def test_issue_16396b():
  88. i = integrate(x*sin(x)/(1+cos(x)**2), (x, 0, pi))
  89. assert not i.has(Integral)
  90. @XFAIL
  91. def test_issue_16161():
  92. i = integrate(x*sec(x)**2, x)
  93. assert not i.has(Integral)
  94. # assert i == x*tan(x) + log(cos(x))
  95. @XFAIL
  96. def test_issue_16046():
  97. assert integrate(exp(exp(I*x)), [x, 0, 2*pi]) == 2*pi
  98. @XFAIL
  99. def test_issue_15925a():
  100. assert not integrate(sqrt((1+sin(x))**2+(cos(x))**2), (x, -pi/2, pi/2)).has(Integral)
  101. @XFAIL
  102. @slow
  103. def test_issue_15925b():
  104. if ON_TRAVIS:
  105. skip("Too slow for travis.")
  106. assert not integrate(sqrt((-12*cos(x)**2*sin(x))**2+(12*cos(x)*sin(x)**2)**2),
  107. (x, 0, pi/6)).has(Integral)
  108. @XFAIL
  109. def test_issue_15925b_manual():
  110. assert not integrate(sqrt((-12*cos(x)**2*sin(x))**2+(12*cos(x)*sin(x)**2)**2),
  111. (x, 0, pi/6), manual=True).has(Integral)
  112. @XFAIL
  113. @slow
  114. def test_issue_15227():
  115. if ON_TRAVIS:
  116. skip("Too slow for travis.")
  117. i = integrate(log(1-x)*log((1+x)**2)/x, (x, 0, 1))
  118. assert not i.has(Integral)
  119. # assert i == -5*zeta(3)/4
  120. @XFAIL
  121. @slow
  122. def test_issue_14716():
  123. i = integrate(log(x + 5)*cos(pi*x),(x, S.Half, 1))
  124. assert not i.has(Integral)
  125. # Mathematica can not solve it either, but
  126. # integrate(log(x + 5)*cos(pi*x),(x, S.Half, 1)).transform(x, y - 5).doit()
  127. # works
  128. # assert i == -log(Rational(11, 2))/pi - Si(pi*Rational(11, 2))/pi + Si(6*pi)/pi
  129. @XFAIL
  130. def test_issue_14709a():
  131. i = integrate(x*acos(1 - 2*x/h), (x, 0, h))
  132. assert not i.has(Integral)
  133. # assert i == 5*h**2*pi/16
  134. @slow
  135. @XFAIL
  136. def test_issue_14398():
  137. assert not integrate(exp(x**2)*cos(x), x).has(Integral)
  138. @XFAIL
  139. def test_issue_14074():
  140. i = integrate(log(sin(x)), (x, 0, pi/2))
  141. assert not i.has(Integral)
  142. # assert i == -pi*log(2)/2
  143. @XFAIL
  144. @slow
  145. def test_issue_14078b():
  146. i = integrate((atan(4*x)-atan(2*x))/x, (x, 0, oo))
  147. assert not i.has(Integral)
  148. # assert i == pi*log(2)/2
  149. @XFAIL
  150. def test_issue_13792():
  151. i = integrate(log(1/x) / (1 - x), (x, 0, 1))
  152. assert not i.has(Integral)
  153. # assert i in [polylog(2, -exp_polar(I*pi)), pi**2/6]
  154. @XFAIL
  155. def test_issue_11845a():
  156. assert not integrate(exp(y - x**3), (x, 0, 1)).has(Integral)
  157. @XFAIL
  158. def test_issue_11845b():
  159. assert not integrate(exp(-y - x**3), (x, 0, 1)).has(Integral)
  160. @XFAIL
  161. def test_issue_11813():
  162. assert not integrate((a - x)**Rational(-1, 2)*x, (x, 0, a)).has(Integral)
  163. @XFAIL
  164. def test_issue_11742():
  165. i = integrate(sqrt(-x**2 + 8*x + 48), (x, 4, 12))
  166. assert not i.has(Integral)
  167. # assert i == 16*pi
  168. @XFAIL
  169. def test_issue_11254a():
  170. assert not integrate(sech(x), (x, 0, 1)).has(Integral)
  171. @XFAIL
  172. def test_issue_11254b():
  173. assert not integrate(csch(x), (x, 0, 1)).has(Integral)
  174. @XFAIL
  175. def test_issue_10584():
  176. assert not integrate(sqrt(x**2 + 1/x**2), x).has(Integral)
  177. @XFAIL
  178. def test_issue_9723():
  179. assert not integrate(sqrt(x + sqrt(x))).has(Integral)
  180. @XFAIL
  181. def test_issue_9101():
  182. assert not integrate(log(x + sqrt(x**2 + y**2 + z**2)), z).has(Integral)
  183. @XFAIL
  184. def test_issue_7264():
  185. assert not integrate(exp(x)*sqrt(1 + exp(2*x))).has(Integral)
  186. @XFAIL
  187. def test_issue_7147():
  188. assert not integrate(x/sqrt(a*x**2 + b*x + c)**3, x).has(Integral)
  189. @XFAIL
  190. def test_issue_7109():
  191. assert not integrate(sqrt(a**2/(a**2 - x**2)), x).has(Integral)
  192. @XFAIL
  193. def test_integrate_Piecewise_rational_over_reals():
  194. f = Piecewise(
  195. (0, t - 478.515625*pi < 0),
  196. (13.2075145209219*pi/(0.000871222*t + 0.995)**2, t - 478.515625*pi >= 0))
  197. assert abs((integrate(f, (t, 0, oo)) - 15235.9375*pi).evalf()) <= 1e-7
  198. @XFAIL
  199. def test_issue_4311_slow():
  200. # Not slow when bypassing heurish
  201. assert not integrate(x*abs(9-x**2), x).has(Integral)
  202. @XFAIL
  203. def test_issue_20370():
  204. a = symbols('a', positive=True)
  205. assert integrate((1 + a * cos(x))**-1, (x, 0, 2 * pi)) == (2 * pi / sqrt(1 - a**2))