
(FPCore (x) :precision binary64 (log (+ x (sqrt (+ (* x x) 1.0)))))
double code(double x) {
return log((x + sqrt(((x * x) + 1.0))));
}
real(8) function code(x)
real(8), intent (in) :: x
code = log((x + sqrt(((x * x) + 1.0d0))))
end function
public static double code(double x) {
return Math.log((x + Math.sqrt(((x * x) + 1.0))));
}
def code(x): return math.log((x + math.sqrt(((x * x) + 1.0))))
function code(x) return log(Float64(x + sqrt(Float64(Float64(x * x) + 1.0)))) end
function tmp = code(x) tmp = log((x + sqrt(((x * x) + 1.0)))); end
code[x_] := N[Log[N[(x + N[Sqrt[N[(N[(x * x), $MachinePrecision] + 1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\log \left(x + \sqrt{x \cdot x + 1}\right)
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 10 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x) :precision binary64 (log (+ x (sqrt (+ (* x x) 1.0)))))
double code(double x) {
return log((x + sqrt(((x * x) + 1.0))));
}
real(8) function code(x)
real(8), intent (in) :: x
code = log((x + sqrt(((x * x) + 1.0d0))))
end function
public static double code(double x) {
return Math.log((x + Math.sqrt(((x * x) + 1.0))));
}
def code(x): return math.log((x + math.sqrt(((x * x) + 1.0))))
function code(x) return log(Float64(x + sqrt(Float64(Float64(x * x) + 1.0)))) end
function tmp = code(x) tmp = log((x + sqrt(((x * x) + 1.0)))); end
code[x_] := N[Log[N[(x + N[Sqrt[N[(N[(x * x), $MachinePrecision] + 1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\log \left(x + \sqrt{x \cdot x + 1}\right)
\end{array}
(FPCore (x)
:precision binary64
(if (<= x -0.001)
(- (log (- (hypot 1.0 x) x)))
(if (<= x 1.25)
(+ x (* -0.16666666666666666 (pow x 3.0)))
(- (log (/ 0.5 x))))))
double code(double x) {
double tmp;
if (x <= -0.001) {
tmp = -log((hypot(1.0, x) - x));
} else if (x <= 1.25) {
tmp = x + (-0.16666666666666666 * pow(x, 3.0));
} else {
tmp = -log((0.5 / x));
}
return tmp;
}
public static double code(double x) {
double tmp;
if (x <= -0.001) {
tmp = -Math.log((Math.hypot(1.0, x) - x));
} else if (x <= 1.25) {
tmp = x + (-0.16666666666666666 * Math.pow(x, 3.0));
} else {
tmp = -Math.log((0.5 / x));
}
return tmp;
}
def code(x): tmp = 0 if x <= -0.001: tmp = -math.log((math.hypot(1.0, x) - x)) elif x <= 1.25: tmp = x + (-0.16666666666666666 * math.pow(x, 3.0)) else: tmp = -math.log((0.5 / x)) return tmp
function code(x) tmp = 0.0 if (x <= -0.001) tmp = Float64(-log(Float64(hypot(1.0, x) - x))); elseif (x <= 1.25) tmp = Float64(x + Float64(-0.16666666666666666 * (x ^ 3.0))); else tmp = Float64(-log(Float64(0.5 / x))); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= -0.001) tmp = -log((hypot(1.0, x) - x)); elseif (x <= 1.25) tmp = x + (-0.16666666666666666 * (x ^ 3.0)); else tmp = -log((0.5 / x)); end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, -0.001], (-N[Log[N[(N[Sqrt[1.0 ^ 2 + x ^ 2], $MachinePrecision] - x), $MachinePrecision]], $MachinePrecision]), If[LessEqual[x, 1.25], N[(x + N[(-0.16666666666666666 * N[Power[x, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], (-N[Log[N[(0.5 / x), $MachinePrecision]], $MachinePrecision])]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -0.001:\\
\;\;\;\;-\log \left(\mathsf{hypot}\left(1, x\right) - x\right)\\
\mathbf{elif}\;x \leq 1.25:\\
\;\;\;\;x + -0.16666666666666666 \cdot {x}^{3}\\
\mathbf{else}:\\
\;\;\;\;-\log \left(\frac{0.5}{x}\right)\\
\end{array}
\end{array}
if x < -1e-3Initial program 3.8%
sqr-neg3.8%
+-commutative3.8%
sqr-neg3.8%
hypot-1-def5.2%
Simplified5.2%
flip-+3.4%
frac-2neg3.4%
log-div3.4%
pow23.4%
hypot-1-def3.5%
hypot-1-def3.4%
add-sqr-sqrt4.7%
+-commutative4.7%
fma-define4.7%
Applied egg-rr4.7%
fma-undefine4.7%
unpow24.7%
associate--r+44.8%
+-inverses100.0%
metadata-eval100.0%
metadata-eval100.0%
metadata-eval100.0%
neg-sub0100.0%
neg-sub0100.0%
associate--r-100.0%
neg-sub0100.0%
+-commutative100.0%
sub-neg100.0%
Simplified100.0%
if -1e-3 < x < 1.25Initial program 7.5%
sqr-neg7.5%
+-commutative7.5%
sqr-neg7.5%
hypot-1-def7.6%
Simplified7.6%
Taylor expanded in x around 0 100.0%
distribute-rgt-in100.0%
*-lft-identity100.0%
associate-*l*100.0%
unpow2100.0%
unpow3100.0%
Simplified100.0%
if 1.25 < x Initial program 46.9%
sqr-neg46.9%
+-commutative46.9%
sqr-neg46.9%
hypot-1-def98.7%
Simplified98.7%
flip-+1.9%
frac-2neg1.9%
log-div1.9%
pow21.9%
hypot-1-def1.9%
hypot-1-def1.9%
add-sqr-sqrt1.9%
+-commutative1.9%
fma-define1.9%
Applied egg-rr1.9%
fma-undefine1.9%
unpow21.9%
associate--r+3.3%
+-inverses5.0%
metadata-eval5.0%
metadata-eval5.0%
metadata-eval5.0%
neg-sub05.0%
neg-sub05.0%
associate--r-5.0%
neg-sub05.0%
+-commutative5.0%
sub-neg5.0%
Simplified5.0%
Taylor expanded in x around inf 99.0%
(FPCore (x)
:precision binary64
(if (<= x -1.3)
(log (/ -0.5 x))
(if (<= x 1.25)
(+ x (* -0.16666666666666666 (pow x 3.0)))
(- (log (/ 0.5 x))))))
double code(double x) {
double tmp;
if (x <= -1.3) {
tmp = log((-0.5 / x));
} else if (x <= 1.25) {
tmp = x + (-0.16666666666666666 * pow(x, 3.0));
} else {
tmp = -log((0.5 / x));
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (x <= (-1.3d0)) then
tmp = log(((-0.5d0) / x))
else if (x <= 1.25d0) then
tmp = x + ((-0.16666666666666666d0) * (x ** 3.0d0))
else
tmp = -log((0.5d0 / x))
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (x <= -1.3) {
tmp = Math.log((-0.5 / x));
} else if (x <= 1.25) {
tmp = x + (-0.16666666666666666 * Math.pow(x, 3.0));
} else {
tmp = -Math.log((0.5 / x));
}
return tmp;
}
def code(x): tmp = 0 if x <= -1.3: tmp = math.log((-0.5 / x)) elif x <= 1.25: tmp = x + (-0.16666666666666666 * math.pow(x, 3.0)) else: tmp = -math.log((0.5 / x)) return tmp
function code(x) tmp = 0.0 if (x <= -1.3) tmp = log(Float64(-0.5 / x)); elseif (x <= 1.25) tmp = Float64(x + Float64(-0.16666666666666666 * (x ^ 3.0))); else tmp = Float64(-log(Float64(0.5 / x))); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= -1.3) tmp = log((-0.5 / x)); elseif (x <= 1.25) tmp = x + (-0.16666666666666666 * (x ^ 3.0)); else tmp = -log((0.5 / x)); end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, -1.3], N[Log[N[(-0.5 / x), $MachinePrecision]], $MachinePrecision], If[LessEqual[x, 1.25], N[(x + N[(-0.16666666666666666 * N[Power[x, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], (-N[Log[N[(0.5 / x), $MachinePrecision]], $MachinePrecision])]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.3:\\
\;\;\;\;\log \left(\frac{-0.5}{x}\right)\\
\mathbf{elif}\;x \leq 1.25:\\
\;\;\;\;x + -0.16666666666666666 \cdot {x}^{3}\\
\mathbf{else}:\\
\;\;\;\;-\log \left(\frac{0.5}{x}\right)\\
\end{array}
\end{array}
if x < -1.30000000000000004Initial program 3.8%
sqr-neg3.8%
+-commutative3.8%
sqr-neg3.8%
hypot-1-def5.2%
Simplified5.2%
Taylor expanded in x around -inf 98.8%
if -1.30000000000000004 < x < 1.25Initial program 7.5%
sqr-neg7.5%
+-commutative7.5%
sqr-neg7.5%
hypot-1-def7.6%
Simplified7.6%
Taylor expanded in x around 0 100.0%
distribute-rgt-in100.0%
*-lft-identity100.0%
associate-*l*100.0%
unpow2100.0%
unpow3100.0%
Simplified100.0%
if 1.25 < x Initial program 46.9%
sqr-neg46.9%
+-commutative46.9%
sqr-neg46.9%
hypot-1-def98.7%
Simplified98.7%
flip-+1.9%
frac-2neg1.9%
log-div1.9%
pow21.9%
hypot-1-def1.9%
hypot-1-def1.9%
add-sqr-sqrt1.9%
+-commutative1.9%
fma-define1.9%
Applied egg-rr1.9%
fma-undefine1.9%
unpow21.9%
associate--r+3.3%
+-inverses5.0%
metadata-eval5.0%
metadata-eval5.0%
metadata-eval5.0%
neg-sub05.0%
neg-sub05.0%
associate--r-5.0%
neg-sub05.0%
+-commutative5.0%
sub-neg5.0%
Simplified5.0%
Taylor expanded in x around inf 99.0%
(FPCore (x) :precision binary64 (if (<= x -1.3) (log (/ -0.5 x)) (if (<= x 1.25) x (- (log (/ 0.5 x))))))
double code(double x) {
double tmp;
if (x <= -1.3) {
tmp = log((-0.5 / x));
} else if (x <= 1.25) {
tmp = x;
} else {
tmp = -log((0.5 / x));
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (x <= (-1.3d0)) then
tmp = log(((-0.5d0) / x))
else if (x <= 1.25d0) then
tmp = x
else
tmp = -log((0.5d0 / x))
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (x <= -1.3) {
tmp = Math.log((-0.5 / x));
} else if (x <= 1.25) {
tmp = x;
} else {
tmp = -Math.log((0.5 / x));
}
return tmp;
}
def code(x): tmp = 0 if x <= -1.3: tmp = math.log((-0.5 / x)) elif x <= 1.25: tmp = x else: tmp = -math.log((0.5 / x)) return tmp
function code(x) tmp = 0.0 if (x <= -1.3) tmp = log(Float64(-0.5 / x)); elseif (x <= 1.25) tmp = x; else tmp = Float64(-log(Float64(0.5 / x))); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= -1.3) tmp = log((-0.5 / x)); elseif (x <= 1.25) tmp = x; else tmp = -log((0.5 / x)); end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, -1.3], N[Log[N[(-0.5 / x), $MachinePrecision]], $MachinePrecision], If[LessEqual[x, 1.25], x, (-N[Log[N[(0.5 / x), $MachinePrecision]], $MachinePrecision])]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.3:\\
\;\;\;\;\log \left(\frac{-0.5}{x}\right)\\
\mathbf{elif}\;x \leq 1.25:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;-\log \left(\frac{0.5}{x}\right)\\
\end{array}
\end{array}
if x < -1.30000000000000004Initial program 3.8%
sqr-neg3.8%
+-commutative3.8%
sqr-neg3.8%
hypot-1-def5.2%
Simplified5.2%
Taylor expanded in x around -inf 98.8%
if -1.30000000000000004 < x < 1.25Initial program 7.5%
sqr-neg7.5%
+-commutative7.5%
sqr-neg7.5%
hypot-1-def7.6%
Simplified7.6%
Taylor expanded in x around 0 99.5%
if 1.25 < x Initial program 46.9%
sqr-neg46.9%
+-commutative46.9%
sqr-neg46.9%
hypot-1-def98.7%
Simplified98.7%
flip-+1.9%
frac-2neg1.9%
log-div1.9%
pow21.9%
hypot-1-def1.9%
hypot-1-def1.9%
add-sqr-sqrt1.9%
+-commutative1.9%
fma-define1.9%
Applied egg-rr1.9%
fma-undefine1.9%
unpow21.9%
associate--r+3.3%
+-inverses5.0%
metadata-eval5.0%
metadata-eval5.0%
metadata-eval5.0%
neg-sub05.0%
neg-sub05.0%
associate--r-5.0%
neg-sub05.0%
+-commutative5.0%
sub-neg5.0%
Simplified5.0%
Taylor expanded in x around inf 99.0%
(FPCore (x) :precision binary64 (if (<= x -1.3) (log (/ -0.5 x)) (if (<= x 1.25) x (log (* x 2.0)))))
double code(double x) {
double tmp;
if (x <= -1.3) {
tmp = log((-0.5 / x));
} else if (x <= 1.25) {
tmp = x;
} else {
tmp = log((x * 2.0));
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (x <= (-1.3d0)) then
tmp = log(((-0.5d0) / x))
else if (x <= 1.25d0) then
tmp = x
else
tmp = log((x * 2.0d0))
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (x <= -1.3) {
tmp = Math.log((-0.5 / x));
} else if (x <= 1.25) {
tmp = x;
} else {
tmp = Math.log((x * 2.0));
}
return tmp;
}
def code(x): tmp = 0 if x <= -1.3: tmp = math.log((-0.5 / x)) elif x <= 1.25: tmp = x else: tmp = math.log((x * 2.0)) return tmp
function code(x) tmp = 0.0 if (x <= -1.3) tmp = log(Float64(-0.5 / x)); elseif (x <= 1.25) tmp = x; else tmp = log(Float64(x * 2.0)); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= -1.3) tmp = log((-0.5 / x)); elseif (x <= 1.25) tmp = x; else tmp = log((x * 2.0)); end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, -1.3], N[Log[N[(-0.5 / x), $MachinePrecision]], $MachinePrecision], If[LessEqual[x, 1.25], x, N[Log[N[(x * 2.0), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.3:\\
\;\;\;\;\log \left(\frac{-0.5}{x}\right)\\
\mathbf{elif}\;x \leq 1.25:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;\log \left(x \cdot 2\right)\\
\end{array}
\end{array}
if x < -1.30000000000000004Initial program 3.8%
sqr-neg3.8%
+-commutative3.8%
sqr-neg3.8%
hypot-1-def5.2%
Simplified5.2%
Taylor expanded in x around -inf 98.8%
if -1.30000000000000004 < x < 1.25Initial program 7.5%
sqr-neg7.5%
+-commutative7.5%
sqr-neg7.5%
hypot-1-def7.6%
Simplified7.6%
Taylor expanded in x around 0 99.5%
if 1.25 < x Initial program 46.9%
sqr-neg46.9%
+-commutative46.9%
sqr-neg46.9%
hypot-1-def98.7%
Simplified98.7%
Taylor expanded in x around inf 97.6%
*-commutative97.6%
Simplified97.6%
(FPCore (x) :precision binary64 (if (<= x -8.0) -8.0 (if (<= x 1.25) x (log (* x 2.0)))))
double code(double x) {
double tmp;
if (x <= -8.0) {
tmp = -8.0;
} else if (x <= 1.25) {
tmp = x;
} else {
tmp = log((x * 2.0));
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (x <= (-8.0d0)) then
tmp = -8.0d0
else if (x <= 1.25d0) then
tmp = x
else
tmp = log((x * 2.0d0))
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (x <= -8.0) {
tmp = -8.0;
} else if (x <= 1.25) {
tmp = x;
} else {
tmp = Math.log((x * 2.0));
}
return tmp;
}
def code(x): tmp = 0 if x <= -8.0: tmp = -8.0 elif x <= 1.25: tmp = x else: tmp = math.log((x * 2.0)) return tmp
function code(x) tmp = 0.0 if (x <= -8.0) tmp = -8.0; elseif (x <= 1.25) tmp = x; else tmp = log(Float64(x * 2.0)); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= -8.0) tmp = -8.0; elseif (x <= 1.25) tmp = x; else tmp = log((x * 2.0)); end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, -8.0], -8.0, If[LessEqual[x, 1.25], x, N[Log[N[(x * 2.0), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -8:\\
\;\;\;\;-8\\
\mathbf{elif}\;x \leq 1.25:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;\log \left(x \cdot 2\right)\\
\end{array}
\end{array}
if x < -8Initial program 2.2%
sqr-neg2.2%
+-commutative2.2%
sqr-neg2.2%
hypot-1-def3.6%
Simplified3.6%
flip-+1.8%
frac-2neg1.8%
log-div1.8%
pow21.8%
hypot-1-def1.8%
hypot-1-def1.8%
add-sqr-sqrt3.1%
+-commutative3.1%
fma-define3.1%
Applied egg-rr3.1%
fma-undefine3.1%
unpow23.1%
associate--r+43.9%
+-inverses100.0%
metadata-eval100.0%
metadata-eval100.0%
metadata-eval100.0%
neg-sub0100.0%
neg-sub0100.0%
associate--r-100.0%
neg-sub0100.0%
+-commutative100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in x around inf 0.0%
Applied egg-rr15.1%
if -8 < x < 1.25Initial program 8.2%
sqr-neg8.2%
+-commutative8.2%
sqr-neg8.2%
hypot-1-def8.2%
Simplified8.2%
Taylor expanded in x around 0 98.9%
if 1.25 < x Initial program 46.9%
sqr-neg46.9%
+-commutative46.9%
sqr-neg46.9%
hypot-1-def98.7%
Simplified98.7%
Taylor expanded in x around inf 97.6%
*-commutative97.6%
Simplified97.6%
(FPCore (x) :precision binary64 (if (<= x -1.0) -8.0 (log1p x)))
double code(double x) {
double tmp;
if (x <= -1.0) {
tmp = -8.0;
} else {
tmp = log1p(x);
}
return tmp;
}
public static double code(double x) {
double tmp;
if (x <= -1.0) {
tmp = -8.0;
} else {
tmp = Math.log1p(x);
}
return tmp;
}
def code(x): tmp = 0 if x <= -1.0: tmp = -8.0 else: tmp = math.log1p(x) return tmp
function code(x) tmp = 0.0 if (x <= -1.0) tmp = -8.0; else tmp = log1p(x); end return tmp end
code[x_] := If[LessEqual[x, -1.0], -8.0, N[Log[1 + x], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1:\\
\;\;\;\;-8\\
\mathbf{else}:\\
\;\;\;\;\mathsf{log1p}\left(x\right)\\
\end{array}
\end{array}
if x < -1Initial program 3.8%
sqr-neg3.8%
+-commutative3.8%
sqr-neg3.8%
hypot-1-def5.2%
Simplified5.2%
flip-+3.4%
frac-2neg3.4%
log-div3.4%
pow23.4%
hypot-1-def3.5%
hypot-1-def3.4%
add-sqr-sqrt4.7%
+-commutative4.7%
fma-define4.7%
Applied egg-rr4.7%
fma-undefine4.7%
unpow24.7%
associate--r+44.8%
+-inverses100.0%
metadata-eval100.0%
metadata-eval100.0%
metadata-eval100.0%
neg-sub0100.0%
neg-sub0100.0%
associate--r-100.0%
neg-sub0100.0%
+-commutative100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in x around inf 0.0%
Applied egg-rr15.1%
if -1 < x Initial program 22.1%
sqr-neg22.1%
+-commutative22.1%
sqr-neg22.1%
hypot-1-def41.1%
Simplified41.1%
Taylor expanded in x around 0 15.9%
+-commutative15.9%
Simplified15.9%
*-un-lft-identity15.9%
log-prod15.9%
metadata-eval15.9%
+-commutative15.9%
log1p-define73.8%
Applied egg-rr73.8%
+-lft-identity73.8%
Simplified73.8%
(FPCore (x) :precision binary64 (if (<= x -8.0) -8.0 (if (<= x 9.0) x 9.0)))
double code(double x) {
double tmp;
if (x <= -8.0) {
tmp = -8.0;
} else if (x <= 9.0) {
tmp = x;
} else {
tmp = 9.0;
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (x <= (-8.0d0)) then
tmp = -8.0d0
else if (x <= 9.0d0) then
tmp = x
else
tmp = 9.0d0
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (x <= -8.0) {
tmp = -8.0;
} else if (x <= 9.0) {
tmp = x;
} else {
tmp = 9.0;
}
return tmp;
}
def code(x): tmp = 0 if x <= -8.0: tmp = -8.0 elif x <= 9.0: tmp = x else: tmp = 9.0 return tmp
function code(x) tmp = 0.0 if (x <= -8.0) tmp = -8.0; elseif (x <= 9.0) tmp = x; else tmp = 9.0; end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= -8.0) tmp = -8.0; elseif (x <= 9.0) tmp = x; else tmp = 9.0; end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, -8.0], -8.0, If[LessEqual[x, 9.0], x, 9.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -8:\\
\;\;\;\;-8\\
\mathbf{elif}\;x \leq 9:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;9\\
\end{array}
\end{array}
if x < -8Initial program 2.2%
sqr-neg2.2%
+-commutative2.2%
sqr-neg2.2%
hypot-1-def3.6%
Simplified3.6%
flip-+1.8%
frac-2neg1.8%
log-div1.8%
pow21.8%
hypot-1-def1.8%
hypot-1-def1.8%
add-sqr-sqrt3.1%
+-commutative3.1%
fma-define3.1%
Applied egg-rr3.1%
fma-undefine3.1%
unpow23.1%
associate--r+43.9%
+-inverses100.0%
metadata-eval100.0%
metadata-eval100.0%
metadata-eval100.0%
neg-sub0100.0%
neg-sub0100.0%
associate--r-100.0%
neg-sub0100.0%
+-commutative100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in x around inf 0.0%
Applied egg-rr15.1%
if -8 < x < 9Initial program 8.2%
sqr-neg8.2%
+-commutative8.2%
sqr-neg8.2%
hypot-1-def8.2%
Simplified8.2%
Taylor expanded in x around 0 98.9%
if 9 < x Initial program 46.9%
sqr-neg46.9%
+-commutative46.9%
sqr-neg46.9%
hypot-1-def98.7%
Simplified98.7%
flip-+1.9%
frac-2neg1.9%
log-div1.9%
pow21.9%
hypot-1-def1.9%
hypot-1-def1.9%
add-sqr-sqrt1.9%
+-commutative1.9%
fma-define1.9%
Applied egg-rr1.9%
fma-undefine1.9%
unpow21.9%
associate--r+3.3%
+-inverses5.0%
metadata-eval5.0%
metadata-eval5.0%
metadata-eval5.0%
neg-sub05.0%
neg-sub05.0%
associate--r-5.0%
neg-sub05.0%
+-commutative5.0%
sub-neg5.0%
Simplified5.0%
Taylor expanded in x around inf 99.0%
Applied egg-rr15.4%
(FPCore (x) :precision binary64 (if (<= x 2e-309) -8.0 9.0))
double code(double x) {
double tmp;
if (x <= 2e-309) {
tmp = -8.0;
} else {
tmp = 9.0;
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (x <= 2d-309) then
tmp = -8.0d0
else
tmp = 9.0d0
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (x <= 2e-309) {
tmp = -8.0;
} else {
tmp = 9.0;
}
return tmp;
}
def code(x): tmp = 0 if x <= 2e-309: tmp = -8.0 else: tmp = 9.0 return tmp
function code(x) tmp = 0.0 if (x <= 2e-309) tmp = -8.0; else tmp = 9.0; end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= 2e-309) tmp = -8.0; else tmp = 9.0; end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, 2e-309], -8.0, 9.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 2 \cdot 10^{-309}:\\
\;\;\;\;-8\\
\mathbf{else}:\\
\;\;\;\;9\\
\end{array}
\end{array}
if x < 1.9999999999999988e-309Initial program 6.1%
sqr-neg6.1%
+-commutative6.1%
sqr-neg6.1%
hypot-1-def6.8%
Simplified6.8%
flip-+5.9%
frac-2neg5.9%
log-div5.9%
pow25.9%
hypot-1-def5.9%
hypot-1-def5.9%
add-sqr-sqrt6.5%
+-commutative6.5%
fma-define6.5%
Applied egg-rr6.5%
fma-undefine6.5%
unpow26.5%
associate--r+25.6%
+-inverses51.8%
metadata-eval51.8%
metadata-eval51.8%
metadata-eval51.8%
neg-sub051.8%
neg-sub051.8%
associate--r-51.8%
neg-sub051.8%
+-commutative51.8%
sub-neg51.8%
Simplified51.8%
Taylor expanded in x around inf 0.0%
Applied egg-rr10.1%
if 1.9999999999999988e-309 < x Initial program 28.7%
sqr-neg28.7%
+-commutative28.7%
sqr-neg28.7%
hypot-1-def56.8%
Simplified56.8%
flip-+4.1%
frac-2neg4.1%
log-div4.1%
pow24.1%
hypot-1-def4.1%
hypot-1-def4.1%
add-sqr-sqrt4.2%
+-commutative4.2%
fma-define4.2%
Applied egg-rr4.2%
fma-undefine4.2%
unpow24.2%
associate--r+4.9%
+-inverses5.8%
metadata-eval5.8%
metadata-eval5.8%
metadata-eval5.8%
neg-sub05.8%
neg-sub05.8%
associate--r-5.8%
neg-sub05.8%
+-commutative5.8%
sub-neg5.8%
Simplified5.8%
Taylor expanded in x around inf 54.9%
Applied egg-rr10.9%
(FPCore (x) :precision binary64 (if (<= x -5e-310) -8.0 8.0))
double code(double x) {
double tmp;
if (x <= -5e-310) {
tmp = -8.0;
} else {
tmp = 8.0;
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (x <= (-5d-310)) then
tmp = -8.0d0
else
tmp = 8.0d0
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (x <= -5e-310) {
tmp = -8.0;
} else {
tmp = 8.0;
}
return tmp;
}
def code(x): tmp = 0 if x <= -5e-310: tmp = -8.0 else: tmp = 8.0 return tmp
function code(x) tmp = 0.0 if (x <= -5e-310) tmp = -8.0; else tmp = 8.0; end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= -5e-310) tmp = -8.0; else tmp = 8.0; end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, -5e-310], -8.0, 8.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -5 \cdot 10^{-310}:\\
\;\;\;\;-8\\
\mathbf{else}:\\
\;\;\;\;8\\
\end{array}
\end{array}
if x < -4.999999999999985e-310Initial program 6.1%
sqr-neg6.1%
+-commutative6.1%
sqr-neg6.1%
hypot-1-def6.8%
Simplified6.8%
flip-+5.9%
frac-2neg5.9%
log-div5.9%
pow25.9%
hypot-1-def5.9%
hypot-1-def5.9%
add-sqr-sqrt6.5%
+-commutative6.5%
fma-define6.5%
Applied egg-rr6.5%
fma-undefine6.5%
unpow26.5%
associate--r+25.6%
+-inverses51.8%
metadata-eval51.8%
metadata-eval51.8%
metadata-eval51.8%
neg-sub051.8%
neg-sub051.8%
associate--r-51.8%
neg-sub051.8%
+-commutative51.8%
sub-neg51.8%
Simplified51.8%
Taylor expanded in x around inf 0.0%
Applied egg-rr10.1%
if -4.999999999999985e-310 < x Initial program 28.7%
sqr-neg28.7%
+-commutative28.7%
sqr-neg28.7%
hypot-1-def56.8%
Simplified56.8%
flip-+4.1%
frac-2neg4.1%
log-div4.1%
pow24.1%
hypot-1-def4.1%
hypot-1-def4.1%
add-sqr-sqrt4.2%
+-commutative4.2%
fma-define4.2%
Applied egg-rr4.2%
fma-undefine4.2%
unpow24.2%
associate--r+4.9%
+-inverses5.8%
metadata-eval5.8%
metadata-eval5.8%
metadata-eval5.8%
neg-sub05.8%
neg-sub05.8%
associate--r-5.8%
neg-sub05.8%
+-commutative5.8%
sub-neg5.8%
Simplified5.8%
Taylor expanded in x around inf 54.9%
Applied egg-rr10.8%
(FPCore (x) :precision binary64 -8.0)
double code(double x) {
return -8.0;
}
real(8) function code(x)
real(8), intent (in) :: x
code = -8.0d0
end function
public static double code(double x) {
return -8.0;
}
def code(x): return -8.0
function code(x) return -8.0 end
function tmp = code(x) tmp = -8.0; end
code[x_] := -8.0
\begin{array}{l}
\\
-8
\end{array}
Initial program 17.9%
sqr-neg17.9%
+-commutative17.9%
sqr-neg17.9%
hypot-1-def33.0%
Simplified33.0%
flip-+5.0%
frac-2neg5.0%
log-div5.0%
pow25.0%
hypot-1-def5.0%
hypot-1-def5.0%
add-sqr-sqrt5.3%
+-commutative5.3%
fma-define5.3%
Applied egg-rr5.3%
fma-undefine5.3%
unpow25.3%
associate--r+14.7%
+-inverses27.7%
metadata-eval27.7%
metadata-eval27.7%
metadata-eval27.7%
neg-sub027.7%
neg-sub027.7%
associate--r-27.7%
neg-sub027.7%
+-commutative27.7%
sub-neg27.7%
Simplified27.7%
Taylor expanded in x around inf 28.7%
Applied egg-rr5.8%
(FPCore (x) :precision binary64 (let* ((t_0 (sqrt (+ (* x x) 1.0)))) (if (< x 0.0) (log (/ -1.0 (- x t_0))) (log (+ x t_0)))))
double code(double x) {
double t_0 = sqrt(((x * x) + 1.0));
double tmp;
if (x < 0.0) {
tmp = log((-1.0 / (x - t_0)));
} else {
tmp = log((x + t_0));
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: t_0
real(8) :: tmp
t_0 = sqrt(((x * x) + 1.0d0))
if (x < 0.0d0) then
tmp = log(((-1.0d0) / (x - t_0)))
else
tmp = log((x + t_0))
end if
code = tmp
end function
public static double code(double x) {
double t_0 = Math.sqrt(((x * x) + 1.0));
double tmp;
if (x < 0.0) {
tmp = Math.log((-1.0 / (x - t_0)));
} else {
tmp = Math.log((x + t_0));
}
return tmp;
}
def code(x): t_0 = math.sqrt(((x * x) + 1.0)) tmp = 0 if x < 0.0: tmp = math.log((-1.0 / (x - t_0))) else: tmp = math.log((x + t_0)) return tmp
function code(x) t_0 = sqrt(Float64(Float64(x * x) + 1.0)) tmp = 0.0 if (x < 0.0) tmp = log(Float64(-1.0 / Float64(x - t_0))); else tmp = log(Float64(x + t_0)); end return tmp end
function tmp_2 = code(x) t_0 = sqrt(((x * x) + 1.0)); tmp = 0.0; if (x < 0.0) tmp = log((-1.0 / (x - t_0))); else tmp = log((x + t_0)); end tmp_2 = tmp; end
code[x_] := Block[{t$95$0 = N[Sqrt[N[(N[(x * x), $MachinePrecision] + 1.0), $MachinePrecision]], $MachinePrecision]}, If[Less[x, 0.0], N[Log[N[(-1.0 / N[(x - t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Log[N[(x + t$95$0), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{x \cdot x + 1}\\
\mathbf{if}\;x < 0:\\
\;\;\;\;\log \left(\frac{-1}{x - t\_0}\right)\\
\mathbf{else}:\\
\;\;\;\;\log \left(x + t\_0\right)\\
\end{array}
\end{array}
herbie shell --seed 2024129
(FPCore (x)
:name "Hyperbolic arcsine"
:precision binary64
:alt
(! :herbie-platform default (if (< x 0) (log (/ -1 (- x (sqrt (+ (* x x) 1))))) (log (+ x (sqrt (+ (* x x) 1))))))
(log (+ x (sqrt (+ (* x x) 1.0)))))