It doesn't appear that you've shared all your code, as I get an error about n being undefined. Obviously, that will be true for S, B, H and U as well. I'll assume they are actually defined in your code.
Yout name-value pair for tolerance is incorrect as well. The correct name is AbsoluteTolerance. However, since you are just applying the default tolerance of +/- 0.0001, it is actually unnecessary.
Once I simplify everything to be just a test for forend, it works just fine. If you are still having the same issue, can you please share all of your code?
Here's a screenshot of the result of validating the simplified problem in Grader.