| Alternative 1 | |
|---|---|
| Error | 58.7 |
| Cost | 39616 |
\[\frac{\pi}{2} - 2 \cdot \left(\frac{1}{\sin^{-1} \left(\sqrt{\frac{1 - x}{2}}\right)} \cdot {\sin^{-1} \left(\sqrt{\left(1 - x\right) \cdot 0.5}\right)}^{2}\right)
\]
(FPCore (x) :precision binary64 (- (/ PI 2.0) (* 2.0 (asin (sqrt (/ (- 1.0 x) 2.0))))))
(FPCore (x) :precision binary64 (if (<= x -1.7e-162) (- (/ PI 2.0) (* 2.0 (asin (sqrt (/ (- 1.0 x) 2.0))))) (- (/ PI 2.0) (* 2.0 (- (+ 1.0 (asin (sqrt 0.5))) 1.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.7e-162) {
tmp = (((double) M_PI) / 2.0) - (2.0 * asin(sqrt(((1.0 - x) / 2.0))));
} else {
tmp = (((double) M_PI) / 2.0) - (2.0 * ((1.0 + asin(sqrt(0.5))) - 1.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.7e-162) {
tmp = (Math.PI / 2.0) - (2.0 * Math.asin(Math.sqrt(((1.0 - x) / 2.0))));
} else {
tmp = (Math.PI / 2.0) - (2.0 * ((1.0 + Math.asin(Math.sqrt(0.5))) - 1.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.7e-162: tmp = (math.pi / 2.0) - (2.0 * math.asin(math.sqrt(((1.0 - x) / 2.0)))) else: tmp = (math.pi / 2.0) - (2.0 * ((1.0 + math.asin(math.sqrt(0.5))) - 1.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.7e-162) tmp = Float64(Float64(pi / 2.0) - Float64(2.0 * asin(sqrt(Float64(Float64(1.0 - x) / 2.0))))); else tmp = Float64(Float64(pi / 2.0) - Float64(2.0 * Float64(Float64(1.0 + asin(sqrt(0.5))) - 1.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.7e-162) tmp = (pi / 2.0) - (2.0 * asin(sqrt(((1.0 - x) / 2.0)))); else tmp = (pi / 2.0) - (2.0 * ((1.0 + asin(sqrt(0.5))) - 1.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.7e-162], 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], N[(N[(Pi / 2.0), $MachinePrecision] - N[(2.0 * N[(N[(1.0 + N[ArcSin[N[Sqrt[0.5], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - 1.0), $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.7 \cdot 10^{-162}:\\
\;\;\;\;\frac{\pi}{2} - 2 \cdot \sin^{-1} \left(\sqrt{\frac{1 - x}{2}}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\pi}{2} - 2 \cdot \left(\left(1 + \sin^{-1} \left(\sqrt{0.5}\right)\right) - 1\right)\\
\end{array}
Results
| Original | 59.6 |
|---|---|
| Target | 0 |
| Herbie | 59.2 |
if x < -1.7e-162Initial program 56.3
if -1.7e-162 < x Initial program 60.8
Taylor expanded in x around 0 62.2
Applied egg-rr60.2
Final simplification59.2
| Alternative 1 | |
|---|---|
| Error | 58.7 |
| Cost | 39616 |
| Alternative 2 | |
|---|---|
| Error | 58.8 |
| Cost | 20096 |
| Alternative 3 | |
|---|---|
| Error | 59.6 |
| Cost | 19840 |
| Alternative 4 | |
|---|---|
| Error | 61.4 |
| Cost | 19584 |
herbie shell --seed 2023077
(FPCore (x)
:name "Ian Simplification"
:precision binary64
:herbie-target
(asin x)
(- (/ PI 2.0) (* 2.0 (asin (sqrt (/ (- 1.0 x) 2.0))))))