Specifically, I need to solve for x given values of y, a, u and n using this equation:
y = sqrt(a^3 / u) * (x - n * sin(x))
But I haven’t even completed high school and I have no idea where to start. I found something called the Newton-Raphson method that seems to do what I want. Can I translate that method into C#? Is there a more performance-mindful way to do it?
Any help is super appreciated… I’ve been working on this for days and I still have no idea what I’m doing…
Edit: to future googlers, u/Romestus on reddit made this awesome script that solves the equation using Newton’s method. I hope it can help you too!
i believe for NR you need the derivative of the function as well.
that would be a second function you calculate by hand on paper.
this is a moderately complex function to take the derivative of!
fortunately it looks like it can be simplified a bit.
let’s replace all of sqrt(a^3/u) by a constant k.
so now
y = k * (x - n * sin(x)).
y = (k * x) - (k * n * sin(x)).
y' = [(k * x) - (k * n * sin(x))]'.
y' = (k * x)' - (k * n * sin(x))'.
y' = k - k * n * cos(x).
y' = k * (1 - n * cos(x)).
^----- that's your derivative, where k = sqrt(a^3/u).
Then you could either implement NR yourself,
or if you google C# Newton Raphson it looks like there’s a fair number of examples.