?

Average Error: 59.6 → 57.4
Time: 9.8s
Precision: binary64
Cost: 26048

?

\[0 \leq x \land x \leq 0.5\]
\[\cos^{-1} \left(1 - x\right) \]
\[\pi \cdot 0.5 - {\left(\sqrt{\sin^{-1} \left(1 - x\right)}\right)}^{2} \]
(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}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original59.6
Target0.0
Herbie57.4
\[2 \cdot \sin^{-1} \left(\sqrt{\frac{x}{2}}\right) \]

Derivation?

  1. Initial program 59.6

    \[\cos^{-1} \left(1 - x\right) \]
  2. Applied egg-rr59.6

    \[\leadsto \color{blue}{\pi \cdot 0.5 + \left(-\sin^{-1} \left(1 - x\right)\right)} \]
  3. Simplified59.6

    \[\leadsto \color{blue}{\pi \cdot 0.5 - \sin^{-1} \left(1 - x\right)} \]
    Proof

    [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)} \]
  4. Applied egg-rr57.4

    \[\leadsto \pi \cdot 0.5 - \color{blue}{{\left(\sqrt{\sin^{-1} \left(1 - x\right)}\right)}^{2}} \]
  5. Final simplification57.4

    \[\leadsto \pi \cdot 0.5 - {\left(\sqrt{\sin^{-1} \left(1 - x\right)}\right)}^{2} \]

Alternatives

Alternative 1
Error57.4
Cost26048
\[\pi \cdot 0.5 - {\left(\sqrt[3]{\sin^{-1} \left(1 - x\right)}\right)}^{3} \]
Alternative 2
Error57.4
Cost19840
\[\left({\left(\sqrt[3]{2 + \cos^{-1} \left(1 - x\right)}\right)}^{3} + -1\right) + -1 \]
Alternative 3
Error57.4
Cost19840
\[\left({\left(\sqrt{2 + \cos^{-1} \left(1 - x\right)}\right)}^{2} + -1\right) + -1 \]
Alternative 4
Error59.6
Cost13440
\[3 \cdot \left(\pi \cdot 0.16666666666666666 - \sin^{-1} \left(1 - x\right) \cdot 0.3333333333333333\right) \]
Alternative 5
Error59.6
Cost13184
\[\pi \cdot 0.5 - \sin^{-1} \left(1 - x\right) \]
Alternative 6
Error59.6
Cost6848
\[3 \cdot \left(\cos^{-1} \left(1 - x\right) \cdot 0.3333333333333333\right) \]
Alternative 7
Error59.6
Cost6592
\[\cos^{-1} \left(1 - x\right) \]

Error

Reproduce?

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)))