?

Average Error: 59.5 → 59.5
Time: 10.6s
Precision: binary64
Cost: 34368

?

\[0 \leq x \land x \leq 0.5\]
\[\cos^{-1} \left(1 - x\right) \]
\[\begin{array}{l} t_0 := -1 - \cos^{-1} \left(1 - x\right)\\ t_1 := \frac{1}{t_0}\\ \left(0 - t_1 \cdot \left(t_1 \cdot \left(\left(t_0 \cdot t_0\right) \cdot t_0\right)\right)\right) - 1 \end{array} \]
(FPCore (x) :precision binary64 (acos (- 1.0 x)))
(FPCore (x)
 :precision binary64
 (let* ((t_0 (- -1.0 (acos (- 1.0 x)))) (t_1 (/ 1.0 t_0)))
   (- (- 0.0 (* t_1 (* t_1 (* (* t_0 t_0) t_0)))) 1.0)))
double code(double x) {
	return acos((1.0 - x));
}
double code(double x) {
	double t_0 = -1.0 - acos((1.0 - x));
	double t_1 = 1.0 / t_0;
	return (0.0 - (t_1 * (t_1 * ((t_0 * t_0) * t_0)))) - 1.0;
}
real(8) function code(x)
    real(8), intent (in) :: x
    code = acos((1.0d0 - x))
end function
real(8) function code(x)
    real(8), intent (in) :: x
    real(8) :: t_0
    real(8) :: t_1
    t_0 = (-1.0d0) - acos((1.0d0 - x))
    t_1 = 1.0d0 / t_0
    code = (0.0d0 - (t_1 * (t_1 * ((t_0 * t_0) * t_0)))) - 1.0d0
end function
public static double code(double x) {
	return Math.acos((1.0 - x));
}
public static double code(double x) {
	double t_0 = -1.0 - Math.acos((1.0 - x));
	double t_1 = 1.0 / t_0;
	return (0.0 - (t_1 * (t_1 * ((t_0 * t_0) * t_0)))) - 1.0;
}
def code(x):
	return math.acos((1.0 - x))
def code(x):
	t_0 = -1.0 - math.acos((1.0 - x))
	t_1 = 1.0 / t_0
	return (0.0 - (t_1 * (t_1 * ((t_0 * t_0) * t_0)))) - 1.0
function code(x)
	return acos(Float64(1.0 - x))
end
function code(x)
	t_0 = Float64(-1.0 - acos(Float64(1.0 - x)))
	t_1 = Float64(1.0 / t_0)
	return Float64(Float64(0.0 - Float64(t_1 * Float64(t_1 * Float64(Float64(t_0 * t_0) * t_0)))) - 1.0)
end
function tmp = code(x)
	tmp = acos((1.0 - x));
end
function tmp = code(x)
	t_0 = -1.0 - acos((1.0 - x));
	t_1 = 1.0 / t_0;
	tmp = (0.0 - (t_1 * (t_1 * ((t_0 * t_0) * t_0)))) - 1.0;
end
code[x_] := N[ArcCos[N[(1.0 - x), $MachinePrecision]], $MachinePrecision]
code[x_] := Block[{t$95$0 = N[(-1.0 - N[ArcCos[N[(1.0 - x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(1.0 / t$95$0), $MachinePrecision]}, N[(N[(0.0 - N[(t$95$1 * N[(t$95$1 * N[(N[(t$95$0 * t$95$0), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 1.0), $MachinePrecision]]]
\cos^{-1} \left(1 - x\right)
\begin{array}{l}
t_0 := -1 - \cos^{-1} \left(1 - x\right)\\
t_1 := \frac{1}{t_0}\\
\left(0 - t_1 \cdot \left(t_1 \cdot \left(\left(t_0 \cdot t_0\right) \cdot t_0\right)\right)\right) - 1
\end{array}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

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

Derivation?

  1. Initial program 59.5

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

    \[\leadsto \color{blue}{\left(0 - \left(-1 - \cos^{-1} \left(1 - x\right)\right)\right) - 1} \]
  3. Applied egg-rr59.5

    \[\leadsto \left(0 - \color{blue}{\frac{1}{-1 - \cos^{-1} \left(1 - x\right)} \cdot \left(\left(-1 - \cos^{-1} \left(1 - x\right)\right) \cdot \left(-1 - \cos^{-1} \left(1 - x\right)\right)\right)}\right) - 1 \]
  4. Applied egg-rr59.5

    \[\leadsto \left(0 - \frac{1}{-1 - \cos^{-1} \left(1 - x\right)} \cdot \color{blue}{\left(\left(0 - \left(-1 - \left(-1 - \cos^{-1} \left(1 - x\right)\right) \cdot \left(-1 - \cos^{-1} \left(1 - x\right)\right)\right)\right) - 1\right)}\right) - 1 \]
  5. Applied egg-rr59.5

    \[\leadsto \left(0 - \frac{1}{-1 - \cos^{-1} \left(1 - x\right)} \cdot \color{blue}{\left(\frac{1}{-1 - \cos^{-1} \left(1 - x\right)} \cdot \left(\left(\left(-1 - \cos^{-1} \left(1 - x\right)\right) \cdot \left(-1 - \cos^{-1} \left(1 - x\right)\right)\right) \cdot \left(-1 - \cos^{-1} \left(1 - x\right)\right)\right)\right)}\right) - 1 \]
  6. Final simplification59.5

    \[\leadsto \left(0 - \frac{1}{-1 - \cos^{-1} \left(1 - x\right)} \cdot \left(\frac{1}{-1 - \cos^{-1} \left(1 - x\right)} \cdot \left(\left(\left(-1 - \cos^{-1} \left(1 - x\right)\right) \cdot \left(-1 - \cos^{-1} \left(1 - x\right)\right)\right) \cdot \left(-1 - \cos^{-1} \left(1 - x\right)\right)\right)\right)\right) - 1 \]

Alternatives

Alternative 1
Error59.5
Cost20928
\[\begin{array}{l} t_0 := -1 - \cos^{-1} \left(1 - x\right)\\ \left(0 - \frac{1}{t_0} \cdot \left(\left(1 + t_0 \cdot t_0\right) + -1\right)\right) - 1 \end{array} \]
Alternative 2
Error59.5
Cost20672
\[\begin{array}{l} t_0 := -1 - \cos^{-1} \left(1 - x\right)\\ \left(0 - \frac{1}{t_0} \cdot \left(t_0 \cdot t_0\right)\right) - 1 \end{array} \]
Alternative 3
Error59.5
Cost6848
\[\left(-1 + \cos^{-1} \left(1 - x\right)\right) + 1 \]
Alternative 4
Error59.5
Cost6592
\[\cos^{-1} \left(1 - x\right) \]

Error

Reproduce?

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