I haven't taken P & X out as integers as I can't get the program past the tan function in S but it would be something that I would have done if I found a solution to the problem I am having.
YSYS does need to be something other than 0 so should I change that to float?
@jonnin yes I am using ^ as a power function. What should I use instead?
for small powers, just multiply it times itself: x*x or x*x*x
math has pow(base, exp) eg pow(x,2) but its rigged for double powers which takes more math than a dumb multiply and is slower. Many of us have written integer power only pow functions to deal with that when we need speed.
c++ will NOT warn you if you used xor when you meant power. Its legal and it will compile and run, and you will get utter gibberish out.
11^2 is 9 for example
this is one place where you need to check any new language you use. some do it this way (xor) and some make it power (typically minor languages that are not suited for bitwise work anyway, but some major ones use it as power as well).
and, while we are on the subject.... trig is in radians in c++, you know this, right?
once you get it rolling, try a redo to eliminate redundant terms. tan(u)*tan(u) can be stored and reused rather than computed many times ... the compiler MAY figure that out and do it for you, but then again, it may not.