I'm trying to create a program to solve a set of Kepler's Equation and I cannot isolate the single variable to use the expression in my program.
The Kepler Equation is $$M = E - \varepsilon \sin(E)$$
I will enter the values of $M$ and $\varepsilon$ and wish to find the value of $E$.
The website Wolfram Alpha could find a solution for this input $30(\frac{\pi}{180})=x-0.3 \sin(x)$
How can I find $E$?
EDIT:
I would like to propose this algorithm (Javascript) to solve the equation. It might require some adjustments depending on the programming language used. I did some basic tests with it, and would like feedback on it.
The following algorithm doesn't have an user input method and is treating the expression:
$0 = -x + \sin(-x)$
which is related to:
$x = \sin(-x)$
I used this algorithm to solve $E$ in Kepler's Equation rewriting it as (And swapping M and e for numerical constants, that in my case will be user inputs):
$0 = -M + E - e*sin(E)$
<script>
var start = Number.MIN_SAFE_INTEGER; end = Number.MAX_VALUE;
var result = null;
while(result === null) {
var resultStart = Math.abs(-start + Math.sin(-start));
var resultEnd = Math.abs(-end + Math.sin(-end));
if(resultStart === 0) {
result = start;
} else if (resultEnd === 0) {
result = end;
} else {
if (resultStart > resultEnd) {
var startOld = start;
start = (start+end)/2;
if(startOld === start) { // underflow
result = start;
}
} else {
var endOld = end;
end = (start+end)/2;
if(endOld === end) { // underflow
result = end;
}
}
}
}
console.log(result);
</script>