
(FPCore (x) :precision binary64 (acos (- 1.0 x)))
double code(double x) {
return acos((1.0 - x));
}
real(8) function code(x)
real(8), intent (in) :: x
code = acos((1.0d0 - x))
end function
public static double code(double x) {
return Math.acos((1.0 - x));
}
def code(x): return math.acos((1.0 - x))
function code(x) return acos(Float64(1.0 - x)) end
function tmp = code(x) tmp = acos((1.0 - x)); end
code[x_] := N[ArcCos[N[(1.0 - x), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\cos^{-1} \left(1 - x\right)
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 10 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x) :precision binary64 (acos (- 1.0 x)))
double code(double x) {
return acos((1.0 - x));
}
real(8) function code(x)
real(8), intent (in) :: x
code = acos((1.0d0 - x))
end function
public static double code(double x) {
return Math.acos((1.0 - x));
}
def code(x): return math.acos((1.0 - x))
function code(x) return acos(Float64(1.0 - x)) end
function tmp = code(x) tmp = acos((1.0 - x)); end
code[x_] := N[ArcCos[N[(1.0 - x), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\cos^{-1} \left(1 - x\right)
\end{array}
(FPCore (x)
:precision binary64
(let* ((t_0 (acos (- 1.0 x))) (t_1 (sqrt (asin (- 1.0 x)))))
(+
t_0
(fma (- t_1) t_1 (pow (expm1 (log1p (sqrt (- (* PI 0.5) t_0)))) 2.0)))))
double code(double x) {
double t_0 = acos((1.0 - x));
double t_1 = sqrt(asin((1.0 - x)));
return t_0 + fma(-t_1, t_1, pow(expm1(log1p(sqrt(((((double) M_PI) * 0.5) - t_0)))), 2.0));
}
function code(x) t_0 = acos(Float64(1.0 - x)) t_1 = sqrt(asin(Float64(1.0 - x))) return Float64(t_0 + fma(Float64(-t_1), t_1, (expm1(log1p(sqrt(Float64(Float64(pi * 0.5) - t_0)))) ^ 2.0))) end
code[x_] := Block[{t$95$0 = N[ArcCos[N[(1.0 - x), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Sqrt[N[ArcSin[N[(1.0 - x), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]}, N[(t$95$0 + N[((-t$95$1) * t$95$1 + N[Power[N[(Exp[N[Log[1 + N[Sqrt[N[(N[(Pi * 0.5), $MachinePrecision] - t$95$0), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]] - 1), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos^{-1} \left(1 - x\right)\\
t_1 := \sqrt{\sin^{-1} \left(1 - x\right)}\\
t_0 + \mathsf{fma}\left(-t_1, t_1, {\left(\mathsf{expm1}\left(\mathsf{log1p}\left(\sqrt{\pi \cdot 0.5 - t_0}\right)\right)\right)}^{2}\right)
\end{array}
\end{array}
Initial program 6.8%
acos-asin6.8%
*-un-lft-identity6.8%
add-sqr-sqrt10.2%
prod-diff10.2%
add-sqr-sqrt10.2%
fma-neg10.2%
*-un-lft-identity10.2%
acos-asin10.2%
add-sqr-sqrt10.2%
Applied egg-rr10.2%
add-sqr-sqrt10.2%
pow210.2%
Applied egg-rr10.2%
expm1-log1p-u10.2%
Applied egg-rr10.2%
asin-acos10.2%
div-inv10.2%
metadata-eval10.2%
Applied egg-rr10.2%
Final simplification10.2%
(FPCore (x) :precision binary64 (let* ((t_0 (sqrt (asin (- 1.0 x))))) (+ (acos (- 1.0 x)) (fma (- t_0) t_0 (pow (expm1 (log1p t_0)) 2.0)))))
double code(double x) {
double t_0 = sqrt(asin((1.0 - x)));
return acos((1.0 - x)) + fma(-t_0, t_0, pow(expm1(log1p(t_0)), 2.0));
}
function code(x) t_0 = sqrt(asin(Float64(1.0 - x))) return Float64(acos(Float64(1.0 - x)) + fma(Float64(-t_0), t_0, (expm1(log1p(t_0)) ^ 2.0))) end
code[x_] := Block[{t$95$0 = N[Sqrt[N[ArcSin[N[(1.0 - x), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]}, N[(N[ArcCos[N[(1.0 - x), $MachinePrecision]], $MachinePrecision] + N[((-t$95$0) * t$95$0 + N[Power[N[(Exp[N[Log[1 + t$95$0], $MachinePrecision]] - 1), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{\sin^{-1} \left(1 - x\right)}\\
\cos^{-1} \left(1 - x\right) + \mathsf{fma}\left(-t_0, t_0, {\left(\mathsf{expm1}\left(\mathsf{log1p}\left(t_0\right)\right)\right)}^{2}\right)
\end{array}
\end{array}
Initial program 6.8%
acos-asin6.8%
*-un-lft-identity6.8%
add-sqr-sqrt10.2%
prod-diff10.2%
add-sqr-sqrt10.2%
fma-neg10.2%
*-un-lft-identity10.2%
acos-asin10.2%
add-sqr-sqrt10.2%
Applied egg-rr10.2%
add-sqr-sqrt10.2%
pow210.2%
Applied egg-rr10.2%
expm1-log1p-u10.2%
Applied egg-rr10.2%
Final simplification10.2%
(FPCore (x) :precision binary64 (let* ((t_0 (sqrt (asin (- 1.0 x))))) (+ (acos (- 1.0 x)) (fma (- t_0) t_0 (pow t_0 2.0)))))
double code(double x) {
double t_0 = sqrt(asin((1.0 - x)));
return acos((1.0 - x)) + fma(-t_0, t_0, pow(t_0, 2.0));
}
function code(x) t_0 = sqrt(asin(Float64(1.0 - x))) return Float64(acos(Float64(1.0 - x)) + fma(Float64(-t_0), t_0, (t_0 ^ 2.0))) end
code[x_] := Block[{t$95$0 = N[Sqrt[N[ArcSin[N[(1.0 - x), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]}, N[(N[ArcCos[N[(1.0 - x), $MachinePrecision]], $MachinePrecision] + N[((-t$95$0) * t$95$0 + N[Power[t$95$0, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{\sin^{-1} \left(1 - x\right)}\\
\cos^{-1} \left(1 - x\right) + \mathsf{fma}\left(-t_0, t_0, {t_0}^{2}\right)
\end{array}
\end{array}
Initial program 6.8%
acos-asin6.8%
*-un-lft-identity6.8%
add-sqr-sqrt10.2%
prod-diff10.2%
add-sqr-sqrt10.2%
fma-neg10.2%
*-un-lft-identity10.2%
acos-asin10.2%
add-sqr-sqrt10.2%
Applied egg-rr10.2%
add-sqr-sqrt10.2%
pow210.2%
Applied egg-rr10.2%
Final simplification10.2%
(FPCore (x) :precision binary64 (let* ((t_0 (asin (- 1.0 x))) (t_1 (sqrt t_0))) (+ 1.0 (+ (+ (acos (- 1.0 x)) (fma (- t_1) t_1 t_0)) -1.0))))
double code(double x) {
double t_0 = asin((1.0 - x));
double t_1 = sqrt(t_0);
return 1.0 + ((acos((1.0 - x)) + fma(-t_1, t_1, t_0)) + -1.0);
}
function code(x) t_0 = asin(Float64(1.0 - x)) t_1 = sqrt(t_0) return Float64(1.0 + Float64(Float64(acos(Float64(1.0 - x)) + fma(Float64(-t_1), t_1, t_0)) + -1.0)) end
code[x_] := Block[{t$95$0 = N[ArcSin[N[(1.0 - x), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Sqrt[t$95$0], $MachinePrecision]}, N[(1.0 + N[(N[(N[ArcCos[N[(1.0 - x), $MachinePrecision]], $MachinePrecision] + N[((-t$95$1) * t$95$1 + t$95$0), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin^{-1} \left(1 - x\right)\\
t_1 := \sqrt{t_0}\\
1 + \left(\left(\cos^{-1} \left(1 - x\right) + \mathsf{fma}\left(-t_1, t_1, t_0\right)\right) + -1\right)
\end{array}
\end{array}
Initial program 6.8%
expm1-log1p-u6.8%
expm1-udef6.8%
log1p-udef6.8%
rem-exp-log6.8%
Applied egg-rr6.8%
associate--l+6.8%
add-exp-log6.8%
expm1-udef6.8%
+-commutative6.8%
expm1-udef6.8%
add-exp-log6.8%
sub-neg6.8%
metadata-eval6.8%
Applied egg-rr6.8%
acos-asin6.8%
*-un-lft-identity6.8%
add-sqr-sqrt10.2%
prod-diff10.2%
add-sqr-sqrt10.2%
fma-neg10.2%
*-un-lft-identity10.2%
acos-asin10.2%
add-sqr-sqrt10.2%
Applied egg-rr10.2%
Final simplification10.2%
(FPCore (x) :precision binary64 (let* ((t_0 (asin (- 1.0 x))) (t_1 (sqrt t_0))) (+ (acos (- 1.0 x)) (fma (- t_1) t_1 t_0))))
double code(double x) {
double t_0 = asin((1.0 - x));
double t_1 = sqrt(t_0);
return acos((1.0 - x)) + fma(-t_1, t_1, t_0);
}
function code(x) t_0 = asin(Float64(1.0 - x)) t_1 = sqrt(t_0) return Float64(acos(Float64(1.0 - x)) + fma(Float64(-t_1), t_1, t_0)) end
code[x_] := Block[{t$95$0 = N[ArcSin[N[(1.0 - x), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Sqrt[t$95$0], $MachinePrecision]}, N[(N[ArcCos[N[(1.0 - x), $MachinePrecision]], $MachinePrecision] + N[((-t$95$1) * t$95$1 + t$95$0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin^{-1} \left(1 - x\right)\\
t_1 := \sqrt{t_0}\\
\cos^{-1} \left(1 - x\right) + \mathsf{fma}\left(-t_1, t_1, t_0\right)
\end{array}
\end{array}
Initial program 6.8%
acos-asin6.8%
*-un-lft-identity6.8%
add-sqr-sqrt10.2%
prod-diff10.2%
add-sqr-sqrt10.2%
fma-neg10.2%
*-un-lft-identity10.2%
acos-asin10.2%
add-sqr-sqrt10.2%
Applied egg-rr10.2%
Final simplification10.2%
(FPCore (x) :precision binary64 (let* ((t_0 (asin (- 1.0 x)))) (- (* PI 0.5) (* (cbrt (pow t_0 2.0)) (cbrt t_0)))))
double code(double x) {
double t_0 = asin((1.0 - x));
return (((double) M_PI) * 0.5) - (cbrt(pow(t_0, 2.0)) * cbrt(t_0));
}
public static double code(double x) {
double t_0 = Math.asin((1.0 - x));
return (Math.PI * 0.5) - (Math.cbrt(Math.pow(t_0, 2.0)) * Math.cbrt(t_0));
}
function code(x) t_0 = asin(Float64(1.0 - x)) return Float64(Float64(pi * 0.5) - Float64(cbrt((t_0 ^ 2.0)) * cbrt(t_0))) end
code[x_] := Block[{t$95$0 = N[ArcSin[N[(1.0 - x), $MachinePrecision]], $MachinePrecision]}, N[(N[(Pi * 0.5), $MachinePrecision] - N[(N[Power[N[Power[t$95$0, 2.0], $MachinePrecision], 1/3], $MachinePrecision] * N[Power[t$95$0, 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin^{-1} \left(1 - x\right)\\
\pi \cdot 0.5 - \sqrt[3]{{t_0}^{2}} \cdot \sqrt[3]{t_0}
\end{array}
\end{array}
Initial program 6.8%
expm1-log1p-u6.8%
expm1-udef6.8%
log1p-udef6.8%
rem-exp-log6.8%
Applied egg-rr6.8%
associate--l+6.8%
add-exp-log6.8%
expm1-udef6.8%
add-exp-log6.8%
log1p-udef6.8%
log1p-expm1-u6.8%
add-exp-log6.8%
acos-asin6.8%
add-cube-cbrt10.1%
cancel-sign-sub-inv10.1%
div-inv10.1%
metadata-eval10.1%
pow210.1%
Applied egg-rr10.1%
unpow210.1%
cbrt-unprod10.2%
pow210.2%
Applied egg-rr10.2%
Final simplification10.2%
(FPCore (x)
:precision binary64
(let* ((t_0 (asin (- 1.0 x))) (t_1 (acos (- 1.0 x))) (t_2 (+ t_1 -1.0)))
(if (<= (- 1.0 x) 1.0)
(cbrt (pow t_1 3.0))
(/ (- 1.0 (* (+ -1.0 (+ t_1 (+ t_0 t_0))) t_2)) (- 1.0 t_2)))))
double code(double x) {
double t_0 = asin((1.0 - x));
double t_1 = acos((1.0 - x));
double t_2 = t_1 + -1.0;
double tmp;
if ((1.0 - x) <= 1.0) {
tmp = cbrt(pow(t_1, 3.0));
} else {
tmp = (1.0 - ((-1.0 + (t_1 + (t_0 + t_0))) * t_2)) / (1.0 - t_2);
}
return tmp;
}
public static double code(double x) {
double t_0 = Math.asin((1.0 - x));
double t_1 = Math.acos((1.0 - x));
double t_2 = t_1 + -1.0;
double tmp;
if ((1.0 - x) <= 1.0) {
tmp = Math.cbrt(Math.pow(t_1, 3.0));
} else {
tmp = (1.0 - ((-1.0 + (t_1 + (t_0 + t_0))) * t_2)) / (1.0 - t_2);
}
return tmp;
}
function code(x) t_0 = asin(Float64(1.0 - x)) t_1 = acos(Float64(1.0 - x)) t_2 = Float64(t_1 + -1.0) tmp = 0.0 if (Float64(1.0 - x) <= 1.0) tmp = cbrt((t_1 ^ 3.0)); else tmp = Float64(Float64(1.0 - Float64(Float64(-1.0 + Float64(t_1 + Float64(t_0 + t_0))) * t_2)) / Float64(1.0 - t_2)); end return tmp end
code[x_] := Block[{t$95$0 = N[ArcSin[N[(1.0 - x), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[ArcCos[N[(1.0 - x), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(t$95$1 + -1.0), $MachinePrecision]}, If[LessEqual[N[(1.0 - x), $MachinePrecision], 1.0], N[Power[N[Power[t$95$1, 3.0], $MachinePrecision], 1/3], $MachinePrecision], N[(N[(1.0 - N[(N[(-1.0 + N[(t$95$1 + N[(t$95$0 + t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * t$95$2), $MachinePrecision]), $MachinePrecision] / N[(1.0 - t$95$2), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin^{-1} \left(1 - x\right)\\
t_1 := \cos^{-1} \left(1 - x\right)\\
t_2 := t_1 + -1\\
\mathbf{if}\;1 - x \leq 1:\\
\;\;\;\;\sqrt[3]{{t_1}^{3}}\\
\mathbf{else}:\\
\;\;\;\;\frac{1 - \left(-1 + \left(t_1 + \left(t_0 + t_0\right)\right)\right) \cdot t_2}{1 - t_2}\\
\end{array}
\end{array}
if (-.f64 1 x) < 1Initial program 6.8%
add-cbrt-cube6.8%
pow36.8%
Applied egg-rr6.8%
if 1 < (-.f64 1 x) Initial program 6.8%
expm1-log1p-u6.8%
expm1-udef6.8%
log1p-udef6.8%
rem-exp-log6.8%
Applied egg-rr6.8%
associate--l+6.8%
add-exp-log6.8%
expm1-udef6.8%
flip-+6.8%
metadata-eval6.8%
expm1-udef6.8%
add-exp-log6.8%
expm1-udef6.8%
add-exp-log6.8%
sub-neg6.8%
metadata-eval6.8%
sub-neg6.8%
metadata-eval6.8%
Applied egg-rr6.8%
acos-asin6.8%
*-un-lft-identity6.8%
add-sqr-sqrt10.2%
prod-diff10.2%
add-sqr-sqrt10.2%
fma-neg10.2%
*-un-lft-identity10.2%
acos-asin10.2%
add-sqr-sqrt10.2%
Applied egg-rr10.2%
fma-udef10.2%
add-sqr-sqrt0.0%
sqrt-unprod6.8%
sqr-neg6.8%
add-sqr-sqrt6.8%
add-sqr-sqrt6.8%
Applied egg-rr6.8%
Final simplification6.8%
(FPCore (x) :precision binary64 (if (<= x 5.6e-17) (+ (asin (- 1.0 x)) (* PI 0.5)) (cbrt (pow (acos (- 1.0 x)) 3.0))))
double code(double x) {
double tmp;
if (x <= 5.6e-17) {
tmp = asin((1.0 - x)) + (((double) M_PI) * 0.5);
} else {
tmp = cbrt(pow(acos((1.0 - x)), 3.0));
}
return tmp;
}
public static double code(double x) {
double tmp;
if (x <= 5.6e-17) {
tmp = Math.asin((1.0 - x)) + (Math.PI * 0.5);
} else {
tmp = Math.cbrt(Math.pow(Math.acos((1.0 - x)), 3.0));
}
return tmp;
}
function code(x) tmp = 0.0 if (x <= 5.6e-17) tmp = Float64(asin(Float64(1.0 - x)) + Float64(pi * 0.5)); else tmp = cbrt((acos(Float64(1.0 - x)) ^ 3.0)); end return tmp end
code[x_] := If[LessEqual[x, 5.6e-17], N[(N[ArcSin[N[(1.0 - x), $MachinePrecision]], $MachinePrecision] + N[(Pi * 0.5), $MachinePrecision]), $MachinePrecision], N[Power[N[Power[N[ArcCos[N[(1.0 - x), $MachinePrecision]], $MachinePrecision], 3.0], $MachinePrecision], 1/3], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 5.6 \cdot 10^{-17}:\\
\;\;\;\;\sin^{-1} \left(1 - x\right) + \pi \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;\sqrt[3]{{\cos^{-1} \left(1 - x\right)}^{3}}\\
\end{array}
\end{array}
if x < 5.5999999999999998e-17Initial program 3.9%
expm1-log1p-u3.9%
expm1-udef3.9%
log1p-udef3.9%
rem-exp-log3.9%
Applied egg-rr3.9%
associate--l+3.9%
add-exp-log3.9%
expm1-udef3.9%
add-exp-log3.9%
log1p-udef3.9%
log1p-expm1-u3.9%
add-exp-log3.9%
acos-asin3.9%
add-sqr-sqrt7.4%
cancel-sign-sub-inv7.4%
div-inv7.4%
metadata-eval7.4%
add-sqr-sqrt0.0%
sqrt-unprod6.5%
sqr-neg6.5%
add-sqr-sqrt6.5%
add-sqr-sqrt6.5%
Applied egg-rr6.5%
if 5.5999999999999998e-17 < x Initial program 62.0%
add-cbrt-cube62.1%
pow362.1%
Applied egg-rr62.1%
Final simplification9.3%
(FPCore (x) :precision binary64 (if (<= x 5.6e-17) (+ (asin (- 1.0 x)) (* PI 0.5)) (acos (- 1.0 x))))
double code(double x) {
double tmp;
if (x <= 5.6e-17) {
tmp = asin((1.0 - x)) + (((double) M_PI) * 0.5);
} else {
tmp = acos((1.0 - x));
}
return tmp;
}
public static double code(double x) {
double tmp;
if (x <= 5.6e-17) {
tmp = Math.asin((1.0 - x)) + (Math.PI * 0.5);
} else {
tmp = Math.acos((1.0 - x));
}
return tmp;
}
def code(x): tmp = 0 if x <= 5.6e-17: tmp = math.asin((1.0 - x)) + (math.pi * 0.5) else: tmp = math.acos((1.0 - x)) return tmp
function code(x) tmp = 0.0 if (x <= 5.6e-17) tmp = Float64(asin(Float64(1.0 - x)) + Float64(pi * 0.5)); else tmp = acos(Float64(1.0 - x)); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= 5.6e-17) tmp = asin((1.0 - x)) + (pi * 0.5); else tmp = acos((1.0 - x)); end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, 5.6e-17], N[(N[ArcSin[N[(1.0 - x), $MachinePrecision]], $MachinePrecision] + N[(Pi * 0.5), $MachinePrecision]), $MachinePrecision], N[ArcCos[N[(1.0 - x), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 5.6 \cdot 10^{-17}:\\
\;\;\;\;\sin^{-1} \left(1 - x\right) + \pi \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;\cos^{-1} \left(1 - x\right)\\
\end{array}
\end{array}
if x < 5.5999999999999998e-17Initial program 3.9%
expm1-log1p-u3.9%
expm1-udef3.9%
log1p-udef3.9%
rem-exp-log3.9%
Applied egg-rr3.9%
associate--l+3.9%
add-exp-log3.9%
expm1-udef3.9%
add-exp-log3.9%
log1p-udef3.9%
log1p-expm1-u3.9%
add-exp-log3.9%
acos-asin3.9%
add-sqr-sqrt7.4%
cancel-sign-sub-inv7.4%
div-inv7.4%
metadata-eval7.4%
add-sqr-sqrt0.0%
sqrt-unprod6.5%
sqr-neg6.5%
add-sqr-sqrt6.5%
add-sqr-sqrt6.5%
Applied egg-rr6.5%
if 5.5999999999999998e-17 < x Initial program 62.0%
Final simplification9.3%
(FPCore (x) :precision binary64 (acos (- 1.0 x)))
double code(double x) {
return acos((1.0 - x));
}
real(8) function code(x)
real(8), intent (in) :: x
code = acos((1.0d0 - x))
end function
public static double code(double x) {
return Math.acos((1.0 - x));
}
def code(x): return math.acos((1.0 - x))
function code(x) return acos(Float64(1.0 - x)) end
function tmp = code(x) tmp = acos((1.0 - x)); end
code[x_] := N[ArcCos[N[(1.0 - x), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\cos^{-1} \left(1 - x\right)
\end{array}
Initial program 6.8%
Final simplification6.8%
(FPCore (x) :precision binary64 (* 2.0 (asin (sqrt (/ x 2.0)))))
double code(double x) {
return 2.0 * asin(sqrt((x / 2.0)));
}
real(8) function code(x)
real(8), intent (in) :: x
code = 2.0d0 * asin(sqrt((x / 2.0d0)))
end function
public static double code(double x) {
return 2.0 * Math.asin(Math.sqrt((x / 2.0)));
}
def code(x): return 2.0 * math.asin(math.sqrt((x / 2.0)))
function code(x) return Float64(2.0 * asin(sqrt(Float64(x / 2.0)))) end
function tmp = code(x) tmp = 2.0 * asin(sqrt((x / 2.0))); end
code[x_] := N[(2.0 * N[ArcSin[N[Sqrt[N[(x / 2.0), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
2 \cdot \sin^{-1} \left(\sqrt{\frac{x}{2}}\right)
\end{array}
herbie shell --seed 2023318
(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)))