My text editor says: 402 lines 26802 characters, which is below the max limit mentioned here in the docs
The maximum length of an expression is 65535 characters.
If your expression approaches this limit, you should consider whether there might be a shorter way to write it.
But it is throwing error “Failed to compile expression”
But as i was cutting down some lines, to test max limits, I found a different error: Failed to compile expression. 16: Compiler recursion too deep
Can you not just scale this in a calculation tag - it looks like a linear scale?
You could then use another simple expression that limits the output to between 256 and 768, if desired.