
(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 17 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 (cbrt (exp (acos (- 1.0 x)))))
(t_1 (cbrt (asin (- 1.0 x))))
(t_2 (cbrt (pow t_1 3.0))))
(+
(+ (log (pow t_0 2.0)) (log t_0))
(fma (- t_1) (pow t_1 2.0) (* t_2 (pow t_2 2.0))))))
double code(double x) {
double t_0 = cbrt(exp(acos((1.0 - x))));
double t_1 = cbrt(asin((1.0 - x)));
double t_2 = cbrt(pow(t_1, 3.0));
return (log(pow(t_0, 2.0)) + log(t_0)) + fma(-t_1, pow(t_1, 2.0), (t_2 * pow(t_2, 2.0)));
}
function code(x) t_0 = cbrt(exp(acos(Float64(1.0 - x)))) t_1 = cbrt(asin(Float64(1.0 - x))) t_2 = cbrt((t_1 ^ 3.0)) return Float64(Float64(log((t_0 ^ 2.0)) + log(t_0)) + fma(Float64(-t_1), (t_1 ^ 2.0), Float64(t_2 * (t_2 ^ 2.0)))) end
code[x_] := Block[{t$95$0 = N[Power[N[Exp[N[ArcCos[N[(1.0 - x), $MachinePrecision]], $MachinePrecision]], $MachinePrecision], 1/3], $MachinePrecision]}, Block[{t$95$1 = N[Power[N[ArcSin[N[(1.0 - x), $MachinePrecision]], $MachinePrecision], 1/3], $MachinePrecision]}, Block[{t$95$2 = N[Power[N[Power[t$95$1, 3.0], $MachinePrecision], 1/3], $MachinePrecision]}, N[(N[(N[Log[N[Power[t$95$0, 2.0], $MachinePrecision]], $MachinePrecision] + N[Log[t$95$0], $MachinePrecision]), $MachinePrecision] + N[((-t$95$1) * N[Power[t$95$1, 2.0], $MachinePrecision] + N[(t$95$2 * N[Power[t$95$2, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt[3]{e^{\cos^{-1} \left(1 - x\right)}}\\
t_1 := \sqrt[3]{\sin^{-1} \left(1 - x\right)}\\
t_2 := \sqrt[3]{{t\_1}^{3}}\\
\left(\log \left({t\_0}^{2}\right) + \log t\_0\right) + \mathsf{fma}\left(-t\_1, {t\_1}^{2}, t\_2 \cdot {t\_2}^{2}\right)
\end{array}
\end{array}
Initial program 6.7%
acos-asin6.7%
add-cube-cbrt4.9%
add-cube-cbrt6.7%
prod-diff6.7%
Applied egg-rr10.2%
unpow210.2%
cbrt-prod6.7%
unpow26.7%
rem-3cbrt-rft4.9%
fma-neg4.9%
add-cube-cbrt10.2%
metadata-eval10.2%
div-inv10.2%
acos-asin10.2%
add-log-exp10.2%
add-cube-cbrt10.2%
Applied egg-rr10.2%
add-cube-cbrt10.2%
pow310.2%
Applied egg-rr10.2%
add-cube-cbrt10.2%
pow310.2%
Applied egg-rr10.2%
(FPCore (x)
:precision binary64
(let* ((t_0 (cbrt (asin (- 1.0 x))))
(t_1 (pow t_0 2.0))
(t_2 (acos (- 1.0 x))))
(+
(+
(log (pow (cbrt (exp t_2)) 2.0))
(+ (exp (log1p (* t_2 0.3333333333333333))) -1.0))
(fma (- t_0) t_1 (* t_1 (cbrt (pow t_0 3.0)))))))
double code(double x) {
double t_0 = cbrt(asin((1.0 - x)));
double t_1 = pow(t_0, 2.0);
double t_2 = acos((1.0 - x));
return (log(pow(cbrt(exp(t_2)), 2.0)) + (exp(log1p((t_2 * 0.3333333333333333))) + -1.0)) + fma(-t_0, t_1, (t_1 * cbrt(pow(t_0, 3.0))));
}
function code(x) t_0 = cbrt(asin(Float64(1.0 - x))) t_1 = t_0 ^ 2.0 t_2 = acos(Float64(1.0 - x)) return Float64(Float64(log((cbrt(exp(t_2)) ^ 2.0)) + Float64(exp(log1p(Float64(t_2 * 0.3333333333333333))) + -1.0)) + fma(Float64(-t_0), t_1, Float64(t_1 * cbrt((t_0 ^ 3.0))))) end
code[x_] := Block[{t$95$0 = N[Power[N[ArcSin[N[(1.0 - x), $MachinePrecision]], $MachinePrecision], 1/3], $MachinePrecision]}, Block[{t$95$1 = N[Power[t$95$0, 2.0], $MachinePrecision]}, Block[{t$95$2 = N[ArcCos[N[(1.0 - x), $MachinePrecision]], $MachinePrecision]}, N[(N[(N[Log[N[Power[N[Power[N[Exp[t$95$2], $MachinePrecision], 1/3], $MachinePrecision], 2.0], $MachinePrecision]], $MachinePrecision] + N[(N[Exp[N[Log[1 + N[(t$95$2 * 0.3333333333333333), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision] + N[((-t$95$0) * t$95$1 + N[(t$95$1 * N[Power[N[Power[t$95$0, 3.0], $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt[3]{\sin^{-1} \left(1 - x\right)}\\
t_1 := {t\_0}^{2}\\
t_2 := \cos^{-1} \left(1 - x\right)\\
\left(\log \left({\left(\sqrt[3]{e^{t\_2}}\right)}^{2}\right) + \left(e^{\mathsf{log1p}\left(t\_2 \cdot 0.3333333333333333\right)} + -1\right)\right) + \mathsf{fma}\left(-t\_0, t\_1, t\_1 \cdot \sqrt[3]{{t\_0}^{3}}\right)
\end{array}
\end{array}
Initial program 6.7%
acos-asin6.7%
add-cube-cbrt4.9%
add-cube-cbrt6.7%
prod-diff6.7%
Applied egg-rr10.2%
unpow210.2%
cbrt-prod6.7%
unpow26.7%
rem-3cbrt-rft4.9%
fma-neg4.9%
add-cube-cbrt10.2%
metadata-eval10.2%
div-inv10.2%
acos-asin10.2%
add-log-exp10.2%
add-cube-cbrt10.2%
Applied egg-rr10.2%
add-cube-cbrt10.2%
pow310.2%
Applied egg-rr10.2%
expm1-log1p-u10.2%
expm1-undefine10.2%
pow1/310.2%
log-pow10.2%
add-log-exp10.2%
Applied egg-rr10.2%
Final simplification10.2%
(FPCore (x)
:precision binary64
(let* ((t_0 (cbrt (asin (- 1.0 x)))) (t_1 (acos (- 1.0 x))))
(+
(+ (log (pow (cbrt (exp t_1)) 2.0)) (* t_1 0.3333333333333333))
(fma (- t_0) (pow t_0 2.0) (* t_0 (pow (cbrt (pow t_0 3.0)) 2.0))))))
double code(double x) {
double t_0 = cbrt(asin((1.0 - x)));
double t_1 = acos((1.0 - x));
return (log(pow(cbrt(exp(t_1)), 2.0)) + (t_1 * 0.3333333333333333)) + fma(-t_0, pow(t_0, 2.0), (t_0 * pow(cbrt(pow(t_0, 3.0)), 2.0)));
}
function code(x) t_0 = cbrt(asin(Float64(1.0 - x))) t_1 = acos(Float64(1.0 - x)) return Float64(Float64(log((cbrt(exp(t_1)) ^ 2.0)) + Float64(t_1 * 0.3333333333333333)) + fma(Float64(-t_0), (t_0 ^ 2.0), Float64(t_0 * (cbrt((t_0 ^ 3.0)) ^ 2.0)))) end
code[x_] := Block[{t$95$0 = N[Power[N[ArcSin[N[(1.0 - x), $MachinePrecision]], $MachinePrecision], 1/3], $MachinePrecision]}, Block[{t$95$1 = N[ArcCos[N[(1.0 - x), $MachinePrecision]], $MachinePrecision]}, N[(N[(N[Log[N[Power[N[Power[N[Exp[t$95$1], $MachinePrecision], 1/3], $MachinePrecision], 2.0], $MachinePrecision]], $MachinePrecision] + N[(t$95$1 * 0.3333333333333333), $MachinePrecision]), $MachinePrecision] + N[((-t$95$0) * N[Power[t$95$0, 2.0], $MachinePrecision] + N[(t$95$0 * N[Power[N[Power[N[Power[t$95$0, 3.0], $MachinePrecision], 1/3], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt[3]{\sin^{-1} \left(1 - x\right)}\\
t_1 := \cos^{-1} \left(1 - x\right)\\
\left(\log \left({\left(\sqrt[3]{e^{t\_1}}\right)}^{2}\right) + t\_1 \cdot 0.3333333333333333\right) + \mathsf{fma}\left(-t\_0, {t\_0}^{2}, t\_0 \cdot {\left(\sqrt[3]{{t\_0}^{3}}\right)}^{2}\right)
\end{array}
\end{array}
Initial program 6.7%
acos-asin6.7%
add-cube-cbrt4.9%
add-cube-cbrt6.7%
prod-diff6.7%
Applied egg-rr10.2%
unpow210.2%
cbrt-prod6.7%
unpow26.7%
rem-3cbrt-rft4.9%
fma-neg4.9%
add-cube-cbrt10.2%
metadata-eval10.2%
div-inv10.2%
acos-asin10.2%
add-log-exp10.2%
add-cube-cbrt10.2%
Applied egg-rr10.2%
add-cube-cbrt10.2%
pow310.2%
Applied egg-rr10.2%
Taylor expanded in x around -inf 10.2%
mul-1-neg10.2%
sub-neg10.2%
unpow1/310.2%
exp-prod10.2%
*-commutative10.2%
rem-log-exp10.2%
*-commutative10.2%
Simplified10.2%
(FPCore (x)
:precision binary64
(let* ((t_0 (cbrt (asin (- 1.0 x)))) (t_1 (acos (- 1.0 x))))
(+
(fma (- t_0) (pow t_0 2.0) (* t_0 (pow (cbrt (pow t_0 3.0)) 2.0)))
(+ (log (cbrt (exp t_1))) (* t_1 0.6666666666666666)))))
double code(double x) {
double t_0 = cbrt(asin((1.0 - x)));
double t_1 = acos((1.0 - x));
return fma(-t_0, pow(t_0, 2.0), (t_0 * pow(cbrt(pow(t_0, 3.0)), 2.0))) + (log(cbrt(exp(t_1))) + (t_1 * 0.6666666666666666));
}
function code(x) t_0 = cbrt(asin(Float64(1.0 - x))) t_1 = acos(Float64(1.0 - x)) return Float64(fma(Float64(-t_0), (t_0 ^ 2.0), Float64(t_0 * (cbrt((t_0 ^ 3.0)) ^ 2.0))) + Float64(log(cbrt(exp(t_1))) + Float64(t_1 * 0.6666666666666666))) end
code[x_] := Block[{t$95$0 = N[Power[N[ArcSin[N[(1.0 - x), $MachinePrecision]], $MachinePrecision], 1/3], $MachinePrecision]}, Block[{t$95$1 = N[ArcCos[N[(1.0 - x), $MachinePrecision]], $MachinePrecision]}, N[(N[((-t$95$0) * N[Power[t$95$0, 2.0], $MachinePrecision] + N[(t$95$0 * N[Power[N[Power[N[Power[t$95$0, 3.0], $MachinePrecision], 1/3], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[Log[N[Power[N[Exp[t$95$1], $MachinePrecision], 1/3], $MachinePrecision]], $MachinePrecision] + N[(t$95$1 * 0.6666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt[3]{\sin^{-1} \left(1 - x\right)}\\
t_1 := \cos^{-1} \left(1 - x\right)\\
\mathsf{fma}\left(-t\_0, {t\_0}^{2}, t\_0 \cdot {\left(\sqrt[3]{{t\_0}^{3}}\right)}^{2}\right) + \left(\log \left(\sqrt[3]{e^{t\_1}}\right) + t\_1 \cdot 0.6666666666666666\right)
\end{array}
\end{array}
Initial program 6.7%
acos-asin6.7%
add-cube-cbrt4.9%
add-cube-cbrt6.7%
prod-diff6.7%
Applied egg-rr10.2%
unpow210.2%
cbrt-prod6.7%
unpow26.7%
rem-3cbrt-rft4.9%
fma-neg4.9%
add-cube-cbrt10.2%
metadata-eval10.2%
div-inv10.2%
acos-asin10.2%
add-log-exp10.2%
add-cube-cbrt10.2%
Applied egg-rr10.2%
add-cube-cbrt10.2%
pow310.2%
Applied egg-rr10.2%
unpow210.2%
log-prod10.2%
pow1/310.2%
log-pow10.2%
add-log-exp10.2%
pow1/310.2%
log-pow10.2%
add-log-exp10.2%
Applied egg-rr10.2%
distribute-rgt-out10.2%
metadata-eval10.2%
Simplified10.2%
Final simplification10.2%
(FPCore (x) :precision binary64 (let* ((t_0 (cbrt (asin (- 1.0 x)))) (t_1 (pow t_0 2.0))) (+ (acos (- 1.0 x)) (fma (- t_0) t_1 (* t_0 t_1)))))
double code(double x) {
double t_0 = cbrt(asin((1.0 - x)));
double t_1 = pow(t_0, 2.0);
return acos((1.0 - x)) + fma(-t_0, t_1, (t_0 * t_1));
}
function code(x) t_0 = cbrt(asin(Float64(1.0 - x))) t_1 = t_0 ^ 2.0 return Float64(acos(Float64(1.0 - x)) + fma(Float64(-t_0), t_1, Float64(t_0 * t_1))) end
code[x_] := Block[{t$95$0 = N[Power[N[ArcSin[N[(1.0 - x), $MachinePrecision]], $MachinePrecision], 1/3], $MachinePrecision]}, Block[{t$95$1 = N[Power[t$95$0, 2.0], $MachinePrecision]}, N[(N[ArcCos[N[(1.0 - x), $MachinePrecision]], $MachinePrecision] + N[((-t$95$0) * t$95$1 + N[(t$95$0 * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt[3]{\sin^{-1} \left(1 - x\right)}\\
t_1 := {t\_0}^{2}\\
\cos^{-1} \left(1 - x\right) + \mathsf{fma}\left(-t\_0, t\_1, t\_0 \cdot t\_1\right)
\end{array}
\end{array}
Initial program 6.7%
acos-asin6.7%
add-cube-cbrt4.9%
add-cube-cbrt6.7%
prod-diff6.7%
Applied egg-rr10.2%
unpow210.2%
cbrt-prod6.7%
unpow26.7%
rem-3cbrt-rft4.9%
fma-neg4.9%
add-cube-cbrt10.2%
metadata-eval10.2%
div-inv10.2%
acos-asin10.2%
add-log-exp10.2%
*-un-lft-identity10.2%
log-prod10.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.7%
acos-asin6.7%
*-un-lft-identity6.7%
add-sqr-sqrt10.1%
prod-diff10.1%
add-sqr-sqrt10.2%
fma-neg10.2%
*-un-lft-identity10.2%
acos-asin10.2%
add-sqr-sqrt10.1%
Applied egg-rr10.1%
add-sqr-sqrt10.2%
pow210.2%
Applied egg-rr10.2%
(FPCore (x) :precision binary64 (let* ((t_0 (asin (- 1.0 x))) (t_1 (sqrt t_0))) (+ (acos (- 1.0 x)) (fma (- t_1) (expm1 (log1p 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, expm1(log1p(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), expm1(log1p(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) * N[(Exp[N[Log[1 + t$95$1], $MachinePrecision]] - 1), $MachinePrecision] + 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, \mathsf{expm1}\left(\mathsf{log1p}\left(t\_1\right)\right), t\_0\right)
\end{array}
\end{array}
Initial program 6.7%
acos-asin6.7%
*-un-lft-identity6.7%
add-sqr-sqrt10.1%
prod-diff10.1%
add-sqr-sqrt10.2%
fma-neg10.2%
*-un-lft-identity10.2%
acos-asin10.2%
add-sqr-sqrt10.1%
Applied egg-rr10.1%
expm1-log1p-u10.2%
Applied egg-rr10.2%
(FPCore (x) :precision binary64 (let* ((t_0 (acos (- 1.0 x))) (t_1 (asin (- 1.0 x)))) (+ t_0 (fma (- (sqrt (- (* PI 0.5) t_0))) (sqrt t_1) t_1))))
double code(double x) {
double t_0 = acos((1.0 - x));
double t_1 = asin((1.0 - x));
return t_0 + fma(-sqrt(((((double) M_PI) * 0.5) - t_0)), sqrt(t_1), t_1);
}
function code(x) t_0 = acos(Float64(1.0 - x)) t_1 = asin(Float64(1.0 - x)) return Float64(t_0 + fma(Float64(-sqrt(Float64(Float64(pi * 0.5) - t_0))), sqrt(t_1), t_1)) end
code[x_] := Block[{t$95$0 = N[ArcCos[N[(1.0 - x), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[ArcSin[N[(1.0 - x), $MachinePrecision]], $MachinePrecision]}, N[(t$95$0 + N[((-N[Sqrt[N[(N[(Pi * 0.5), $MachinePrecision] - t$95$0), $MachinePrecision]], $MachinePrecision]) * N[Sqrt[t$95$1], $MachinePrecision] + t$95$1), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos^{-1} \left(1 - x\right)\\
t_1 := \sin^{-1} \left(1 - x\right)\\
t\_0 + \mathsf{fma}\left(-\sqrt{\pi \cdot 0.5 - t\_0}, \sqrt{t\_1}, t\_1\right)
\end{array}
\end{array}
Initial program 6.7%
acos-asin6.7%
*-un-lft-identity6.7%
add-sqr-sqrt10.1%
prod-diff10.1%
add-sqr-sqrt10.2%
fma-neg10.2%
*-un-lft-identity10.2%
acos-asin10.2%
add-sqr-sqrt10.1%
Applied egg-rr10.1%
asin-acos10.1%
div-inv10.1%
metadata-eval10.1%
Applied egg-rr10.1%
(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.7%
acos-asin6.7%
*-un-lft-identity6.7%
add-sqr-sqrt10.1%
prod-diff10.1%
add-sqr-sqrt10.2%
fma-neg10.2%
*-un-lft-identity10.2%
acos-asin10.2%
add-sqr-sqrt10.1%
Applied egg-rr10.1%
(FPCore (x) :precision binary64 (let* ((t_0 (asin (- 1.0 x)))) (if (<= x 5.5e-17) (+ t_0 (* PI 0.5)) (- (* PI 0.5) (cbrt (pow t_0 3.0))))))
double code(double x) {
double t_0 = asin((1.0 - x));
double tmp;
if (x <= 5.5e-17) {
tmp = t_0 + (((double) M_PI) * 0.5);
} else {
tmp = (((double) M_PI) * 0.5) - cbrt(pow(t_0, 3.0));
}
return tmp;
}
public static double code(double x) {
double t_0 = Math.asin((1.0 - x));
double tmp;
if (x <= 5.5e-17) {
tmp = t_0 + (Math.PI * 0.5);
} else {
tmp = (Math.PI * 0.5) - Math.cbrt(Math.pow(t_0, 3.0));
}
return tmp;
}
function code(x) t_0 = asin(Float64(1.0 - x)) tmp = 0.0 if (x <= 5.5e-17) tmp = Float64(t_0 + Float64(pi * 0.5)); else tmp = Float64(Float64(pi * 0.5) - cbrt((t_0 ^ 3.0))); end return tmp end
code[x_] := Block[{t$95$0 = N[ArcSin[N[(1.0 - x), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[x, 5.5e-17], N[(t$95$0 + N[(Pi * 0.5), $MachinePrecision]), $MachinePrecision], N[(N[(Pi * 0.5), $MachinePrecision] - N[Power[N[Power[t$95$0, 3.0], $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin^{-1} \left(1 - x\right)\\
\mathbf{if}\;x \leq 5.5 \cdot 10^{-17}:\\
\;\;\;\;t\_0 + \pi \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;\pi \cdot 0.5 - \sqrt[3]{{t\_0}^{3}}\\
\end{array}
\end{array}
if x < 5.50000000000000001e-17Initial program 3.9%
expm1-log1p-u3.9%
expm1-undefine3.9%
log1p-undefine3.9%
rem-exp-log3.9%
Applied egg-rr3.9%
add-exp-log3.9%
expm1-define3.9%
log1p-define3.9%
expm1-log1p-u3.9%
acos-asin3.9%
div-inv3.9%
metadata-eval3.9%
add-cube-cbrt7.5%
unpow27.5%
*-commutative7.5%
sub-neg7.5%
add-sqr-sqrt0.0%
sqrt-unprod6.5%
Applied egg-rr6.5%
if 5.50000000000000001e-17 < x Initial program 59.7%
acos-asin59.7%
sub-neg59.7%
div-inv59.7%
metadata-eval59.7%
Applied egg-rr59.7%
sub-neg59.7%
Simplified59.7%
add-cbrt-cube59.8%
pow359.9%
Applied egg-rr59.9%
Final simplification9.2%
(FPCore (x) :precision binary64 (let* ((t_0 (asin (- 1.0 x)))) (if (<= x 5.5e-17) (+ t_0 (* PI 0.5)) (- (* PI 0.5) (expm1 (log1p t_0))))))
double code(double x) {
double t_0 = asin((1.0 - x));
double tmp;
if (x <= 5.5e-17) {
tmp = t_0 + (((double) M_PI) * 0.5);
} else {
tmp = (((double) M_PI) * 0.5) - expm1(log1p(t_0));
}
return tmp;
}
public static double code(double x) {
double t_0 = Math.asin((1.0 - x));
double tmp;
if (x <= 5.5e-17) {
tmp = t_0 + (Math.PI * 0.5);
} else {
tmp = (Math.PI * 0.5) - Math.expm1(Math.log1p(t_0));
}
return tmp;
}
def code(x): t_0 = math.asin((1.0 - x)) tmp = 0 if x <= 5.5e-17: tmp = t_0 + (math.pi * 0.5) else: tmp = (math.pi * 0.5) - math.expm1(math.log1p(t_0)) return tmp
function code(x) t_0 = asin(Float64(1.0 - x)) tmp = 0.0 if (x <= 5.5e-17) tmp = Float64(t_0 + Float64(pi * 0.5)); else tmp = Float64(Float64(pi * 0.5) - expm1(log1p(t_0))); end return tmp end
code[x_] := Block[{t$95$0 = N[ArcSin[N[(1.0 - x), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[x, 5.5e-17], N[(t$95$0 + N[(Pi * 0.5), $MachinePrecision]), $MachinePrecision], N[(N[(Pi * 0.5), $MachinePrecision] - N[(Exp[N[Log[1 + t$95$0], $MachinePrecision]] - 1), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin^{-1} \left(1 - x\right)\\
\mathbf{if}\;x \leq 5.5 \cdot 10^{-17}:\\
\;\;\;\;t\_0 + \pi \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;\pi \cdot 0.5 - \mathsf{expm1}\left(\mathsf{log1p}\left(t\_0\right)\right)\\
\end{array}
\end{array}
if x < 5.50000000000000001e-17Initial program 3.9%
expm1-log1p-u3.9%
expm1-undefine3.9%
log1p-undefine3.9%
rem-exp-log3.9%
Applied egg-rr3.9%
add-exp-log3.9%
expm1-define3.9%
log1p-define3.9%
expm1-log1p-u3.9%
acos-asin3.9%
div-inv3.9%
metadata-eval3.9%
add-cube-cbrt7.5%
unpow27.5%
*-commutative7.5%
sub-neg7.5%
add-sqr-sqrt0.0%
sqrt-unprod6.5%
Applied egg-rr6.5%
if 5.50000000000000001e-17 < x Initial program 59.7%
acos-asin59.7%
sub-neg59.7%
div-inv59.7%
metadata-eval59.7%
Applied egg-rr59.7%
sub-neg59.7%
Simplified59.7%
expm1-log1p-u59.8%
Applied egg-rr59.8%
Final simplification9.2%
(FPCore (x) :precision binary64 (- (* PI 0.5) (pow (sqrt (asin (- 1.0 x))) 2.0)))
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.PI * 0.5) - Math.pow(Math.sqrt(Math.asin((1.0 - x))), 2.0);
}
def code(x): return (math.pi * 0.5) - math.pow(math.sqrt(math.asin((1.0 - x))), 2.0)
function code(x) return Float64(Float64(pi * 0.5) - (sqrt(asin(Float64(1.0 - x))) ^ 2.0)) end
function tmp = code(x) tmp = (pi * 0.5) - (sqrt(asin((1.0 - x))) ^ 2.0); end
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]
\begin{array}{l}
\\
\pi \cdot 0.5 - {\left(\sqrt{\sin^{-1} \left(1 - x\right)}\right)}^{2}
\end{array}
Initial program 6.7%
acos-asin6.7%
sub-neg6.7%
div-inv6.7%
metadata-eval6.7%
Applied egg-rr6.7%
sub-neg6.7%
Simplified6.7%
add-sqr-sqrt10.2%
pow210.2%
Applied egg-rr10.1%
(FPCore (x) :precision binary64 (- (* PI 0.5) (pow (cbrt (asin (- 1.0 x))) 3.0)))
double code(double x) {
return (((double) M_PI) * 0.5) - pow(cbrt(asin((1.0 - x))), 3.0);
}
public static double code(double x) {
return (Math.PI * 0.5) - Math.pow(Math.cbrt(Math.asin((1.0 - x))), 3.0);
}
function code(x) return Float64(Float64(pi * 0.5) - (cbrt(asin(Float64(1.0 - x))) ^ 3.0)) end
code[x_] := N[(N[(Pi * 0.5), $MachinePrecision] - N[Power[N[Power[N[ArcSin[N[(1.0 - x), $MachinePrecision]], $MachinePrecision], 1/3], $MachinePrecision], 3.0], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\pi \cdot 0.5 - {\left(\sqrt[3]{\sin^{-1} \left(1 - x\right)}\right)}^{3}
\end{array}
Initial program 6.7%
acos-asin6.7%
sub-neg6.7%
div-inv6.7%
metadata-eval6.7%
Applied egg-rr6.7%
sub-neg6.7%
Simplified6.7%
add-cube-cbrt10.2%
pow310.2%
Applied egg-rr10.1%
(FPCore (x) :precision binary64 (if (<= x 5.5e-17) (+ (asin (- 1.0 x)) (* PI 0.5)) (+ (+ 1.0 (acos (- 1.0 x))) -1.0)))
double code(double x) {
double tmp;
if (x <= 5.5e-17) {
tmp = asin((1.0 - x)) + (((double) M_PI) * 0.5);
} else {
tmp = (1.0 + acos((1.0 - x))) + -1.0;
}
return tmp;
}
public static double code(double x) {
double tmp;
if (x <= 5.5e-17) {
tmp = Math.asin((1.0 - x)) + (Math.PI * 0.5);
} else {
tmp = (1.0 + Math.acos((1.0 - x))) + -1.0;
}
return tmp;
}
def code(x): tmp = 0 if x <= 5.5e-17: tmp = math.asin((1.0 - x)) + (math.pi * 0.5) else: tmp = (1.0 + math.acos((1.0 - x))) + -1.0 return tmp
function code(x) tmp = 0.0 if (x <= 5.5e-17) tmp = Float64(asin(Float64(1.0 - x)) + Float64(pi * 0.5)); else tmp = Float64(Float64(1.0 + acos(Float64(1.0 - x))) + -1.0); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= 5.5e-17) tmp = asin((1.0 - x)) + (pi * 0.5); else tmp = (1.0 + acos((1.0 - x))) + -1.0; end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, 5.5e-17], N[(N[ArcSin[N[(1.0 - x), $MachinePrecision]], $MachinePrecision] + N[(Pi * 0.5), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 + N[ArcCos[N[(1.0 - x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 5.5 \cdot 10^{-17}:\\
\;\;\;\;\sin^{-1} \left(1 - x\right) + \pi \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;\left(1 + \cos^{-1} \left(1 - x\right)\right) + -1\\
\end{array}
\end{array}
if x < 5.50000000000000001e-17Initial program 3.9%
expm1-log1p-u3.9%
expm1-undefine3.9%
log1p-undefine3.9%
rem-exp-log3.9%
Applied egg-rr3.9%
add-exp-log3.9%
expm1-define3.9%
log1p-define3.9%
expm1-log1p-u3.9%
acos-asin3.9%
div-inv3.9%
metadata-eval3.9%
add-cube-cbrt7.5%
unpow27.5%
*-commutative7.5%
sub-neg7.5%
add-sqr-sqrt0.0%
sqrt-unprod6.5%
Applied egg-rr6.5%
if 5.50000000000000001e-17 < x Initial program 59.7%
expm1-log1p-u59.7%
expm1-undefine59.7%
log1p-undefine59.7%
rem-exp-log59.7%
Applied egg-rr59.7%
Final simplification9.2%
(FPCore (x) :precision binary64 (let* ((t_0 (asin (- 1.0 x)))) (if (<= x 5.5e-17) (+ t_0 (* PI 0.5)) (- (* PI 0.5) t_0))))
double code(double x) {
double t_0 = asin((1.0 - x));
double tmp;
if (x <= 5.5e-17) {
tmp = t_0 + (((double) M_PI) * 0.5);
} else {
tmp = (((double) M_PI) * 0.5) - t_0;
}
return tmp;
}
public static double code(double x) {
double t_0 = Math.asin((1.0 - x));
double tmp;
if (x <= 5.5e-17) {
tmp = t_0 + (Math.PI * 0.5);
} else {
tmp = (Math.PI * 0.5) - t_0;
}
return tmp;
}
def code(x): t_0 = math.asin((1.0 - x)) tmp = 0 if x <= 5.5e-17: tmp = t_0 + (math.pi * 0.5) else: tmp = (math.pi * 0.5) - t_0 return tmp
function code(x) t_0 = asin(Float64(1.0 - x)) tmp = 0.0 if (x <= 5.5e-17) tmp = Float64(t_0 + Float64(pi * 0.5)); else tmp = Float64(Float64(pi * 0.5) - t_0); end return tmp end
function tmp_2 = code(x) t_0 = asin((1.0 - x)); tmp = 0.0; if (x <= 5.5e-17) tmp = t_0 + (pi * 0.5); else tmp = (pi * 0.5) - t_0; end tmp_2 = tmp; end
code[x_] := Block[{t$95$0 = N[ArcSin[N[(1.0 - x), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[x, 5.5e-17], N[(t$95$0 + N[(Pi * 0.5), $MachinePrecision]), $MachinePrecision], N[(N[(Pi * 0.5), $MachinePrecision] - t$95$0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin^{-1} \left(1 - x\right)\\
\mathbf{if}\;x \leq 5.5 \cdot 10^{-17}:\\
\;\;\;\;t\_0 + \pi \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;\pi \cdot 0.5 - t\_0\\
\end{array}
\end{array}
if x < 5.50000000000000001e-17Initial program 3.9%
expm1-log1p-u3.9%
expm1-undefine3.9%
log1p-undefine3.9%
rem-exp-log3.9%
Applied egg-rr3.9%
add-exp-log3.9%
expm1-define3.9%
log1p-define3.9%
expm1-log1p-u3.9%
acos-asin3.9%
div-inv3.9%
metadata-eval3.9%
add-cube-cbrt7.5%
unpow27.5%
*-commutative7.5%
sub-neg7.5%
add-sqr-sqrt0.0%
sqrt-unprod6.5%
Applied egg-rr6.5%
if 5.50000000000000001e-17 < x Initial program 59.7%
acos-asin59.7%
sub-neg59.7%
div-inv59.7%
metadata-eval59.7%
Applied egg-rr59.7%
sub-neg59.7%
Simplified59.7%
Final simplification9.2%
(FPCore (x) :precision binary64 (if (<= x 5.5e-17) (+ (asin (- 1.0 x)) (* PI 0.5)) (acos (- 1.0 x))))
double code(double x) {
double tmp;
if (x <= 5.5e-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.5e-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.5e-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.5e-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.5e-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.5e-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.5 \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.50000000000000001e-17Initial program 3.9%
expm1-log1p-u3.9%
expm1-undefine3.9%
log1p-undefine3.9%
rem-exp-log3.9%
Applied egg-rr3.9%
add-exp-log3.9%
expm1-define3.9%
log1p-define3.9%
expm1-log1p-u3.9%
acos-asin3.9%
div-inv3.9%
metadata-eval3.9%
add-cube-cbrt7.5%
unpow27.5%
*-commutative7.5%
sub-neg7.5%
add-sqr-sqrt0.0%
sqrt-unprod6.5%
Applied egg-rr6.5%
if 5.50000000000000001e-17 < x Initial program 59.7%
Final simplification9.2%
(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.7%
(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 2024103
(FPCore (x)
:name "bug323 (missed optimization)"
:precision binary64
:pre (and (<= 0.0 x) (<= x 0.5))
:alt
(* 2.0 (asin (sqrt (/ x 2.0))))
(acos (- 1.0 x)))