Skip to main content
CompuChip's user avatar
CompuChip's user avatar
CompuChip's user avatar
CompuChip
  • Member for 10 years, 6 months
  • Last seen more than 2 years ago
awarded
comment
Why should I avoid the For loop in Mathematica?
"For does not localize the iterator i" -- that alone for me is a sufficient argument to avoid For. All the rest are good points, but mostly about style / readability whereas this one actually breaks the functional pattern (I strive to have as few assignments as possible in general) and may lead to hard-to-find bugs (as opposed to simple typo's that Mathematica will tell you about).
comment
Integrate gives wrong results
The answer about adding PrincipalValue also makes me suspect that the problem is a is treated as a complex number. So rather than a > 0, ElementQ[a, Reals] is probably sufficient :)