| Alternative 1 | |
|---|---|
| Error | 58.8 |
| Cost | 26304 |
\[\left(\sin^{-1} \left(\sqrt{0.5 + x \cdot -0.5}\right) \cdot -2 + \pi \cdot -0.5\right) + \pi
\]
(FPCore (x) :precision binary64 (- (/ PI 2.0) (* 2.0 (asin (sqrt (/ (- 1.0 x) 2.0))))))
(FPCore (x)
:precision binary64
(if (<= x -1.65e-162)
(/ 1.0 (/ 1.0 (+ (* 0.5 PI) (* (asin (sqrt (+ 0.5 (* x -0.5)))) -2.0))))
(if (<= x 5.5e-17)
(+ (+ (* (asin (sqrt 0.5)) -2.0) (* PI -0.5)) PI)
(- (/ PI 2.0) (* 2.0 (asin (sqrt (/ (- 1.0 x) 2.0))))))))double code(double x) {
return (((double) M_PI) / 2.0) - (2.0 * asin(sqrt(((1.0 - x) / 2.0))));
}
double code(double x) {
double tmp;
if (x <= -1.65e-162) {
tmp = 1.0 / (1.0 / ((0.5 * ((double) M_PI)) + (asin(sqrt((0.5 + (x * -0.5)))) * -2.0)));
} else if (x <= 5.5e-17) {
tmp = ((asin(sqrt(0.5)) * -2.0) + (((double) M_PI) * -0.5)) + ((double) M_PI);
} else {
tmp = (((double) M_PI) / 2.0) - (2.0 * asin(sqrt(((1.0 - x) / 2.0))));
}
return tmp;
}
public static double code(double x) {
return (Math.PI / 2.0) - (2.0 * Math.asin(Math.sqrt(((1.0 - x) / 2.0))));
}
public static double code(double x) {
double tmp;
if (x <= -1.65e-162) {
tmp = 1.0 / (1.0 / ((0.5 * Math.PI) + (Math.asin(Math.sqrt((0.5 + (x * -0.5)))) * -2.0)));
} else if (x <= 5.5e-17) {
tmp = ((Math.asin(Math.sqrt(0.5)) * -2.0) + (Math.PI * -0.5)) + Math.PI;
} else {
tmp = (Math.PI / 2.0) - (2.0 * Math.asin(Math.sqrt(((1.0 - x) / 2.0))));
}
return tmp;
}
def code(x): return (math.pi / 2.0) - (2.0 * math.asin(math.sqrt(((1.0 - x) / 2.0))))
def code(x): tmp = 0 if x <= -1.65e-162: tmp = 1.0 / (1.0 / ((0.5 * math.pi) + (math.asin(math.sqrt((0.5 + (x * -0.5)))) * -2.0))) elif x <= 5.5e-17: tmp = ((math.asin(math.sqrt(0.5)) * -2.0) + (math.pi * -0.5)) + math.pi else: tmp = (math.pi / 2.0) - (2.0 * math.asin(math.sqrt(((1.0 - x) / 2.0)))) return tmp
function code(x) return Float64(Float64(pi / 2.0) - Float64(2.0 * asin(sqrt(Float64(Float64(1.0 - x) / 2.0))))) end
function code(x) tmp = 0.0 if (x <= -1.65e-162) tmp = Float64(1.0 / Float64(1.0 / Float64(Float64(0.5 * pi) + Float64(asin(sqrt(Float64(0.5 + Float64(x * -0.5)))) * -2.0)))); elseif (x <= 5.5e-17) tmp = Float64(Float64(Float64(asin(sqrt(0.5)) * -2.0) + Float64(pi * -0.5)) + pi); else tmp = Float64(Float64(pi / 2.0) - Float64(2.0 * asin(sqrt(Float64(Float64(1.0 - x) / 2.0))))); end return tmp end
function tmp = code(x) tmp = (pi / 2.0) - (2.0 * asin(sqrt(((1.0 - x) / 2.0)))); end
function tmp_2 = code(x) tmp = 0.0; if (x <= -1.65e-162) tmp = 1.0 / (1.0 / ((0.5 * pi) + (asin(sqrt((0.5 + (x * -0.5)))) * -2.0))); elseif (x <= 5.5e-17) tmp = ((asin(sqrt(0.5)) * -2.0) + (pi * -0.5)) + pi; else tmp = (pi / 2.0) - (2.0 * asin(sqrt(((1.0 - x) / 2.0)))); end tmp_2 = tmp; end
code[x_] := N[(N[(Pi / 2.0), $MachinePrecision] - N[(2.0 * N[ArcSin[N[Sqrt[N[(N[(1.0 - x), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
code[x_] := If[LessEqual[x, -1.65e-162], N[(1.0 / N[(1.0 / N[(N[(0.5 * Pi), $MachinePrecision] + N[(N[ArcSin[N[Sqrt[N[(0.5 + N[(x * -0.5), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] * -2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 5.5e-17], N[(N[(N[(N[ArcSin[N[Sqrt[0.5], $MachinePrecision]], $MachinePrecision] * -2.0), $MachinePrecision] + N[(Pi * -0.5), $MachinePrecision]), $MachinePrecision] + Pi), $MachinePrecision], N[(N[(Pi / 2.0), $MachinePrecision] - N[(2.0 * N[ArcSin[N[Sqrt[N[(N[(1.0 - x), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\frac{\pi}{2} - 2 \cdot \sin^{-1} \left(\sqrt{\frac{1 - x}{2}}\right)
\begin{array}{l}
\mathbf{if}\;x \leq -1.65 \cdot 10^{-162}:\\
\;\;\;\;\frac{1}{\frac{1}{0.5 \cdot \pi + \sin^{-1} \left(\sqrt{0.5 + x \cdot -0.5}\right) \cdot -2}}\\
\mathbf{elif}\;x \leq 5.5 \cdot 10^{-17}:\\
\;\;\;\;\left(\sin^{-1} \left(\sqrt{0.5}\right) \cdot -2 + \pi \cdot -0.5\right) + \pi\\
\mathbf{else}:\\
\;\;\;\;\frac{\pi}{2} - 2 \cdot \sin^{-1} \left(\sqrt{\frac{1 - x}{2}}\right)\\
\end{array}
Results
| Original | 59.7 |
|---|---|
| Target | 0.0 |
| Herbie | 58.3 |
if x < -1.65000000000000007e-162Initial program 56.5
Applied egg-rr56.5
if -1.65000000000000007e-162 < x < 5.50000000000000001e-17Initial program 62.2
Applied egg-rr60.2
Taylor expanded in x around 0 60.2
if 5.50000000000000001e-17 < x Initial program 25.7
Final simplification58.3
| Alternative 1 | |
|---|---|
| Error | 58.8 |
| Cost | 26304 |
| Alternative 2 | |
|---|---|
| Error | 59.7 |
| Cost | 20096 |
| Alternative 3 | |
|---|---|
| Error | 59.7 |
| Cost | 19840 |
| Alternative 4 | |
|---|---|
| Error | 61.4 |
| Cost | 19584 |
herbie shell --seed 2023066
(FPCore (x)
:name "Ian Simplification"
:precision binary64
:herbie-target
(asin x)
(- (/ PI 2.0) (* 2.0 (asin (sqrt (/ (- 1.0 x) 2.0))))))