Where did you find these formulas?
Using the Companion, apply Do It to each block starting from the top down, working from right to left, to trace all the values going into each operation, to isolate where the NaN occurs.
I see 2 possibilities:
- division by 0, or
- acos of a number outside the range (-1 to 1).
P.S.
Please download and post each of those event block(s)/procedures here ...
(sample video)
P.P.S.

Trashing the input to a block destroys the debugging trail. It's like muddying the footprints at a crime scene. Use separate variable for input and output at each stage, so they will be untouched for later examination.
Also, switching your formula blocks from inline to external sockets will reveal their nesting, in case you made a mistake assembling your formula.
P.P.P.S
By the way, you are dealing with floating point numbers, which are inexact. So even if your formulas are perfect, they might be producing an input to acos() (which you don't show) with an absolute value a tiny amount over 1, say -1.000000000001, beyond what AI2 might be rounding. That would not be the fault of the acos() function.