Guest User

Untitled

a guest
Jan 22nd, 2018
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.97 KB | None | 0 0
  1. Integrate[(Sin[n t/2]/Sin[t/2])^2, {t, 0, Pi}]~Table~{n, 10} // Timing
  2.  
  3. {2.17188, {π, 2π, 3π, 4π, 5π, 6π, 7π, 8π, 9π, 10π}}
  4.  
  5. Integrate[(Sin[n t/2]/Sin[t/2])^2, {t, 0, Pi},
  6. Assumptions -> n ∈ Integers] // Timing
  7. %[[-1]] ~ FunctionExpand ~ (Assumptions -> n ∈ Integers)
  8. % // FullSimplify
  9.  
  10. -(1/2) I E^(-I n π) (1 + E^(2 I n π) +
  11. 2 E^(I n π) n π Cot[n π] + n PolyGamma[0, 1/2 - n/2] -
  12. n PolyGamma[0, -(n/2)] + E^(2 I n π) n PolyGamma[0, n/2] -
  13. E^(2 I n π) n PolyGamma[0, (1 + n)/2])
  14.  
  15. f[e_] := Count[e, _PolyGamma, Infinity]
  16. Integrate[(Sin[n t/2]/Sin[t/2])^2 // TrigReduce, {t, 0, Pi}]
  17. FullSimplify[%, ComplexityFunction -> f]
  18. FullSimplify[%, n ∈ Integers]
  19.  
  20. $Version
  21.  
  22. (* "11.2.0 for Mac OS X x86 (64-bit) (September 11, 2017)" *)
  23.  
  24. Integrate[(Sin[n t/2]/Sin[t/2])^2, {t, 0, Pi}]~
  25. Table~{n, -5, 5} // AbsoluteTiming
  26.  
  27. (* {0.684515, {5 π, 4 π, 3 π, 2 π, π, 0, π, 2 π, 3 π, 4 π, 5 π}} *)
  28.  
  29. (int[n_] =
  30. Integrate[(Sin[n t/2]/Sin[t/2])^2 // TrigReduce, {t, 0, Pi}] //
  31. ComplexExpand // FullSimplify // FunctionExpand //
  32. FullSimplify) // AbsoluteTiming
  33.  
  34. (* {12.12901, (1/2)*(2 + n*Pi*Cot[(n*Pi)/2] -
  35. n*(PolyGamma[0, 1/2 - n/2] - 2*PolyGamma[0, n/2] +
  36. PolyGamma[0, (1 + n)/2]))*Sin[n*Pi]} *)
  37.  
  38. int[1]
  39.  
  40. (* Infinity::indet: Indeterminate expression 0 ComplexInfinity encountered.
  41.  
  42. Indeterminate *)
  43.  
  44. Table[Limit[int[n], n -> m], {m, -5, 5}]
  45.  
  46. (* {5 π, 4 π, 3 π, 2 π, π, 0, π, 2 π, 3 π, 4 π, 5 π} *)
  47.  
  48. (int[n_] = Integrate[(Sin[n t/2]/Sin[t/2])^2 // TrigReduce, {t, 0, Pi},
  49. Assumptions -> n [Element] Integers && n > 0]) // Timing
  50.  
  51. (* {10.094, -(1/2)
  52. I E^(-I n [Pi]) (1 + 2 E^(I n [Pi]) n [Pi] Cot[n [Pi]] +
  53. n PolyGamma[0, 1/2 - n/2] - n PolyGamma[0, -(n/2)] +
  54. E^(2 I n [Pi]) (1 + n PolyGamma[0, n/2] -
  55. n PolyGamma[0, (1 + n)/2]))} *)
  56.  
  57. Table[Limit[int[n], n -> j] // FullSimplify, {j, 0, 10}]
  58.  
  59. (* {0, Pi, 2 Pi, 3 Pi, 4 Pi, 5 Pi, 6 Pi, 7 Pi,
  60. 8 Pi, 9 Pi, 10 Pi} *)
Add Comment
Please, Sign In to add comment