The issue is obvious if you scan over the code. Pay careful attention to red coloring. It shows up in every use of the function Abs
, wherein brackets are not used to enclose the arguments.
There are probably numeric problems as well, since there appears to be a mix of exact and approximate methods. Might try wirking with NIntegrate[...]
rather than N[Integrate[...]]
for example. Or give exact input and use Integrate[...]
, and don't numericize until necessary. But this might be too slow.
The code as written is quite overly complicated, so it's really hard to say what else might be going on. First thing would be to make appropriate use of Table
and get rid of all the For
loops.