LTSpice Syntax Error: function if(): requires exactly three arguments
In the past, during the LTspice IV version, there was a time when ambiguous definitions for .funcs were allowed. When I say &quot;ambiguous&quot; I mean that the manual says:

Syntax: .func ([args]) {}

but the equal sign and no curly braces were allowed, i.e. .func f(x)=x**2 instead of .func f(x) {x**2}. But probably due to the difficuly of parsing these lines with more complicated functions, Mike Engelhardt (the creator of the program) said that unless the user writes the functios &quot;by the book&quot;, all bets are off. It is still possible to have = definitions in LTspice XVII, but in the same unsupported manner.
This is what happens here. All the functions are defined with = and without {}, so the parser has problems deciphering the context. Once you search and replace all the = with { and all \n with }, you'll see it works. You will also need to modify the initial conditions to .ic V(XSV) = {xo}, because xo is not a numeric literal and needs evaluation (curly braces perform evaluation). When in doubt, best use the book.