| Alternative 1 | |
|---|---|
| Error | 57.4 |
| Cost | 26048 |
\[\pi \cdot 0.5 - {\left(\sqrt[3]{\sin^{-1} \left(1 - x\right)}\right)}^{3}
\]
(FPCore (x) :precision binary64 (acos (- 1.0 x)))
(FPCore (x) :precision binary64 (- (* PI 0.5) (pow (sqrt (asin (- 1.0 x))) 2.0)))
double code(double x) {
return acos((1.0 - x));
}
double code(double x) {
return (((double) M_PI) * 0.5) - pow(sqrt(asin((1.0 - x))), 2.0);
}
public static double code(double x) {
return Math.acos((1.0 - x));
}
public static double code(double x) {
return (Math.PI * 0.5) - Math.pow(Math.sqrt(Math.asin((1.0 - x))), 2.0);
}
def code(x): return math.acos((1.0 - x))
def code(x): return (math.pi * 0.5) - math.pow(math.sqrt(math.asin((1.0 - x))), 2.0)
function code(x) return acos(Float64(1.0 - x)) end
function code(x) return Float64(Float64(pi * 0.5) - (sqrt(asin(Float64(1.0 - x))) ^ 2.0)) end
function tmp = code(x) tmp = acos((1.0 - x)); end
function tmp = code(x) tmp = (pi * 0.5) - (sqrt(asin((1.0 - x))) ^ 2.0); end
code[x_] := N[ArcCos[N[(1.0 - x), $MachinePrecision]], $MachinePrecision]
code[x_] := N[(N[(Pi * 0.5), $MachinePrecision] - N[Power[N[Sqrt[N[ArcSin[N[(1.0 - x), $MachinePrecision]], $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]
\cos^{-1} \left(1 - x\right)
\pi \cdot 0.5 - {\left(\sqrt{\sin^{-1} \left(1 - x\right)}\right)}^{2}
Results
| Original | 59.6 |
|---|---|
| Target | 0.0 |
| Herbie | 57.4 |
Initial program 59.6
Applied egg-rr59.6
Simplified59.6
[Start]59.6 | \[ \pi \cdot 0.5 + \left(-\sin^{-1} \left(1 - x\right)\right)
\] |
|---|---|
sub-neg [<=]59.6 | \[ \color{blue}{\pi \cdot 0.5 - \sin^{-1} \left(1 - x\right)}
\] |
Applied egg-rr57.4
Final simplification57.4
| Alternative 1 | |
|---|---|
| Error | 57.4 |
| Cost | 26048 |
| Alternative 2 | |
|---|---|
| Error | 57.4 |
| Cost | 19840 |
| Alternative 3 | |
|---|---|
| Error | 57.4 |
| Cost | 19840 |
| Alternative 4 | |
|---|---|
| Error | 59.6 |
| Cost | 13440 |
| Alternative 5 | |
|---|---|
| Error | 59.6 |
| Cost | 13184 |
| Alternative 6 | |
|---|---|
| Error | 59.6 |
| Cost | 6848 |
| Alternative 7 | |
|---|---|
| Error | 59.6 |
| Cost | 6592 |
herbie shell --seed 2023060
(FPCore (x)
:name "bug323 (missed optimization)"
:precision binary64
:pre (and (<= 0.0 x) (<= x 0.5))
:herbie-target
(* 2.0 (asin (sqrt (/ x 2.0))))
(acos (- 1.0 x)))