Run time error: arccos of invalid value in variable formula (../variable.cpp:3373)

Your input file is not correctly quoted (just look at it, does it look correct to you?) and thus very hard to read. Please have a close look at this post and follow its guidelines and suggestions more closely. It also explains how to correctly quote text so that the forum software will not interpret special characters a markup for formatting.

You appear to be doing some rather complex math. Have you checked that all intermediate results are within the necessary ranges to lead to valid results? According to the error message that does not seem to be the case.