?

Average Accuracy: 6.7% → 10.2%
Time: 13.3s
Precision: binary64
Cost: 78336

?

\[0 \leq x \land x \leq 0.5\]
\[\cos^{-1} \left(1 - x\right) \]
\[\begin{array}{l} t_0 := \sin^{-1} \left(1 - x\right)\\ \frac{0.0625 \cdot \left({\pi}^{2} \cdot {\pi}^{2}\right) - {t_0}^{4}}{\left(\pi - \cos^{-1} \left(1 - x\right)\right) \cdot \left({\pi}^{2} \cdot 0.25 + {t_0}^{2}\right)} \end{array} \]
(FPCore (x) :precision binary64 (acos (- 1.0 x)))
(FPCore (x)
 :precision binary64
 (let* ((t_0 (asin (- 1.0 x))))
   (/
    (- (* 0.0625 (* (pow PI 2.0) (pow PI 2.0))) (pow t_0 4.0))
    (* (- PI (acos (- 1.0 x))) (+ (* (pow PI 2.0) 0.25) (pow t_0 2.0))))))
double code(double x) {
	return acos((1.0 - x));
}
double code(double x) {
	double t_0 = asin((1.0 - x));
	return ((0.0625 * (pow(((double) M_PI), 2.0) * pow(((double) M_PI), 2.0))) - pow(t_0, 4.0)) / ((((double) M_PI) - acos((1.0 - x))) * ((pow(((double) M_PI), 2.0) * 0.25) + pow(t_0, 2.0)));
}
public static double code(double x) {
	return Math.acos((1.0 - x));
}
public static double code(double x) {
	double t_0 = Math.asin((1.0 - x));
	return ((0.0625 * (Math.pow(Math.PI, 2.0) * Math.pow(Math.PI, 2.0))) - Math.pow(t_0, 4.0)) / ((Math.PI - Math.acos((1.0 - x))) * ((Math.pow(Math.PI, 2.0) * 0.25) + Math.pow(t_0, 2.0)));
}
def code(x):
	return math.acos((1.0 - x))
def code(x):
	t_0 = math.asin((1.0 - x))
	return ((0.0625 * (math.pow(math.pi, 2.0) * math.pow(math.pi, 2.0))) - math.pow(t_0, 4.0)) / ((math.pi - math.acos((1.0 - x))) * ((math.pow(math.pi, 2.0) * 0.25) + math.pow(t_0, 2.0)))
function code(x)
	return acos(Float64(1.0 - x))
end
function code(x)
	t_0 = asin(Float64(1.0 - x))
	return Float64(Float64(Float64(0.0625 * Float64((pi ^ 2.0) * (pi ^ 2.0))) - (t_0 ^ 4.0)) / Float64(Float64(pi - acos(Float64(1.0 - x))) * Float64(Float64((pi ^ 2.0) * 0.25) + (t_0 ^ 2.0))))
end
function tmp = code(x)
	tmp = acos((1.0 - x));
end
function tmp = code(x)
	t_0 = asin((1.0 - x));
	tmp = ((0.0625 * ((pi ^ 2.0) * (pi ^ 2.0))) - (t_0 ^ 4.0)) / ((pi - acos((1.0 - x))) * (((pi ^ 2.0) * 0.25) + (t_0 ^ 2.0)));
end
code[x_] := N[ArcCos[N[(1.0 - x), $MachinePrecision]], $MachinePrecision]
code[x_] := Block[{t$95$0 = N[ArcSin[N[(1.0 - x), $MachinePrecision]], $MachinePrecision]}, N[(N[(N[(0.0625 * N[(N[Power[Pi, 2.0], $MachinePrecision] * N[Power[Pi, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[Power[t$95$0, 4.0], $MachinePrecision]), $MachinePrecision] / N[(N[(Pi - N[ArcCos[N[(1.0 - x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(N[(N[Power[Pi, 2.0], $MachinePrecision] * 0.25), $MachinePrecision] + N[Power[t$95$0, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\cos^{-1} \left(1 - x\right)
\begin{array}{l}
t_0 := \sin^{-1} \left(1 - x\right)\\
\frac{0.0625 \cdot \left({\pi}^{2} \cdot {\pi}^{2}\right) - {t_0}^{4}}{\left(\pi - \cos^{-1} \left(1 - x\right)\right) \cdot \left({\pi}^{2} \cdot 0.25 + {t_0}^{2}\right)}
\end{array}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original6.7%
Target100.0%
Herbie10.2%
\[2 \cdot \sin^{-1} \left(\sqrt{\frac{x}{2}}\right) \]

Derivation?

  1. Initial program 6.7%

    \[\cos^{-1} \left(1 - x\right) \]
  2. Applied egg-rr6.7%

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

    [Start]6.7

    \[ \cos^{-1} \left(1 - x\right) \]

    acos-asin [=>]6.7

    \[ \color{blue}{\frac{\pi}{2} - \sin^{-1} \left(1 - x\right)} \]

    sub-neg [=>]6.7

    \[ \color{blue}{\frac{\pi}{2} + \left(-\sin^{-1} \left(1 - x\right)\right)} \]

    div-inv [=>]6.7

    \[ \color{blue}{\pi \cdot \frac{1}{2}} + \left(-\sin^{-1} \left(1 - x\right)\right) \]

    metadata-eval [=>]6.7

    \[ \pi \cdot \color{blue}{0.5} + \left(-\sin^{-1} \left(1 - x\right)\right) \]
  3. Simplified6.7%

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

    [Start]6.7

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

    sub-neg [<=]6.7

    \[ \color{blue}{\pi \cdot 0.5 - \sin^{-1} \left(1 - x\right)} \]
  4. Applied egg-rr6.7%

    \[\leadsto \color{blue}{\frac{\left(0.25 \cdot {\pi}^{2}\right) \cdot \left(0.25 \cdot {\pi}^{2}\right) - {\sin^{-1} \left(1 - x\right)}^{2} \cdot {\sin^{-1} \left(1 - x\right)}^{2}}{\left(\pi - \cos^{-1} \left(1 - x\right)\right) \cdot \left({\sin^{-1} \left(1 - x\right)}^{2} + 0.25 \cdot {\pi}^{2}\right)}} \]
    Proof

    [Start]6.7

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

    flip-- [=>]6.7

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

    flip-- [=>]6.7

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

    associate-/l/ [=>]6.7

    \[ \color{blue}{\frac{\left(\left(\pi \cdot 0.5\right) \cdot \left(\pi \cdot 0.5\right)\right) \cdot \left(\left(\pi \cdot 0.5\right) \cdot \left(\pi \cdot 0.5\right)\right) - \left(\sin^{-1} \left(1 - x\right) \cdot \sin^{-1} \left(1 - x\right)\right) \cdot \left(\sin^{-1} \left(1 - x\right) \cdot \sin^{-1} \left(1 - x\right)\right)}{\left(\pi \cdot 0.5 + \sin^{-1} \left(1 - x\right)\right) \cdot \left(\left(\pi \cdot 0.5\right) \cdot \left(\pi \cdot 0.5\right) + \sin^{-1} \left(1 - x\right) \cdot \sin^{-1} \left(1 - x\right)\right)}} \]
  5. Simplified10.2%

    \[\leadsto \color{blue}{\frac{0.0625 \cdot \left({\pi}^{2} \cdot {\pi}^{2}\right) - {\sin^{-1} \left(1 - x\right)}^{4}}{\left(\pi - \cos^{-1} \left(1 - x\right)\right) \cdot \left(0.25 \cdot {\pi}^{2} + {\sin^{-1} \left(1 - x\right)}^{2}\right)}} \]
    Proof

    [Start]6.7

    \[ \frac{\left(0.25 \cdot {\pi}^{2}\right) \cdot \left(0.25 \cdot {\pi}^{2}\right) - {\sin^{-1} \left(1 - x\right)}^{2} \cdot {\sin^{-1} \left(1 - x\right)}^{2}}{\left(\pi - \cos^{-1} \left(1 - x\right)\right) \cdot \left({\sin^{-1} \left(1 - x\right)}^{2} + 0.25 \cdot {\pi}^{2}\right)} \]

    swap-sqr [=>]6.7

    \[ \frac{\color{blue}{\left(0.25 \cdot 0.25\right) \cdot \left({\pi}^{2} \cdot {\pi}^{2}\right)} - {\sin^{-1} \left(1 - x\right)}^{2} \cdot {\sin^{-1} \left(1 - x\right)}^{2}}{\left(\pi - \cos^{-1} \left(1 - x\right)\right) \cdot \left({\sin^{-1} \left(1 - x\right)}^{2} + 0.25 \cdot {\pi}^{2}\right)} \]

    metadata-eval [=>]6.7

    \[ \frac{\color{blue}{0.0625} \cdot \left({\pi}^{2} \cdot {\pi}^{2}\right) - {\sin^{-1} \left(1 - x\right)}^{2} \cdot {\sin^{-1} \left(1 - x\right)}^{2}}{\left(\pi - \cos^{-1} \left(1 - x\right)\right) \cdot \left({\sin^{-1} \left(1 - x\right)}^{2} + 0.25 \cdot {\pi}^{2}\right)} \]

    pow-sqr [=>]10.2

    \[ \frac{0.0625 \cdot \left({\pi}^{2} \cdot {\pi}^{2}\right) - \color{blue}{{\sin^{-1} \left(1 - x\right)}^{\left(2 \cdot 2\right)}}}{\left(\pi - \cos^{-1} \left(1 - x\right)\right) \cdot \left({\sin^{-1} \left(1 - x\right)}^{2} + 0.25 \cdot {\pi}^{2}\right)} \]

    metadata-eval [=>]10.2

    \[ \frac{0.0625 \cdot \left({\pi}^{2} \cdot {\pi}^{2}\right) - {\sin^{-1} \left(1 - x\right)}^{\color{blue}{4}}}{\left(\pi - \cos^{-1} \left(1 - x\right)\right) \cdot \left({\sin^{-1} \left(1 - x\right)}^{2} + 0.25 \cdot {\pi}^{2}\right)} \]

    +-commutative [=>]10.2

    \[ \frac{0.0625 \cdot \left({\pi}^{2} \cdot {\pi}^{2}\right) - {\sin^{-1} \left(1 - x\right)}^{4}}{\left(\pi - \cos^{-1} \left(1 - x\right)\right) \cdot \color{blue}{\left(0.25 \cdot {\pi}^{2} + {\sin^{-1} \left(1 - x\right)}^{2}\right)}} \]
  6. Final simplification10.2%

    \[\leadsto \frac{0.0625 \cdot \left({\pi}^{2} \cdot {\pi}^{2}\right) - {\sin^{-1} \left(1 - x\right)}^{4}}{\left(\pi - \cos^{-1} \left(1 - x\right)\right) \cdot \left({\pi}^{2} \cdot 0.25 + {\sin^{-1} \left(1 - x\right)}^{2}\right)} \]

Alternatives

Alternative 1
Accuracy10.2%
Cost78144
\[\begin{array}{l} t_0 := \sin^{-1} \left(1 - x\right)\\ \frac{{\pi}^{3} \cdot 0.125 - \mathsf{expm1}\left(\mathsf{log1p}\left({t_0}^{3}\right)\right)}{0.25 \cdot \left(\pi \cdot \pi\right) + t_0 \cdot \mathsf{fma}\left(\pi, 0.5, t_0\right)} \end{array} \]
Alternative 2
Accuracy10.2%
Cost71808
\[\begin{array}{l} t_0 := \sin^{-1} \left(1 - x\right)\\ \frac{0.125 \cdot e^{3 \cdot \log \pi} - {t_0}^{3}}{0.25 \cdot \left(\pi \cdot \pi\right) + t_0 \cdot \mathsf{fma}\left(\pi, 0.5, t_0\right)} \end{array} \]
Alternative 3
Accuracy10.2%
Cost26048
\[\pi \cdot 0.5 - {\left(\sqrt[3]{\sin^{-1} \left(1 - x\right)}\right)}^{3} \]
Alternative 4
Accuracy10.2%
Cost26048
\[\pi \cdot 0.5 - {\left(\sqrt{\sin^{-1} \left(1 - x\right)}\right)}^{2} \]
Alternative 5
Accuracy6.7%
Cost25920
\[3 \cdot \log \left(\sqrt[3]{e^{\cos^{-1} \left(1 - x\right)}}\right) \]
Alternative 6
Accuracy6.7%
Cost19648
\[\log \left(e^{\left(1 + \cos^{-1} \left(1 - x\right)\right) + -1}\right) \]
Alternative 7
Accuracy6.7%
Cost19648
\[\left(1 + \log \left(e^{\cos^{-1} \left(1 - x\right)}\right)\right) + -1 \]
Alternative 8
Accuracy6.7%
Cost6848
\[\left(1 + \cos^{-1} \left(1 - x\right)\right) + -1 \]
Alternative 9
Accuracy6.7%
Cost6592
\[\cos^{-1} \left(1 - x\right) \]

Error

Reproduce?

herbie shell --seed 2023136 
(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)))