
(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 12 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.00088)
(- (log (- (hypot 1.0 x) x)))
(if (<= x 0.001)
(+ x (* -0.16666666666666666 (pow x 3.0)))
(log (+ x (hypot 1.0 x))))))
double code(double x) {
double tmp;
if (x <= -0.00088) {
tmp = -log((hypot(1.0, x) - x));
} else if (x <= 0.001) {
tmp = x + (-0.16666666666666666 * pow(x, 3.0));
} else {
tmp = log((x + hypot(1.0, x)));
}
return tmp;
}
public static double code(double x) {
double tmp;
if (x <= -0.00088) {
tmp = -Math.log((Math.hypot(1.0, x) - x));
} else if (x <= 0.001) {
tmp = x + (-0.16666666666666666 * Math.pow(x, 3.0));
} else {
tmp = Math.log((x + Math.hypot(1.0, x)));
}
return tmp;
}
def code(x): tmp = 0 if x <= -0.00088: tmp = -math.log((math.hypot(1.0, x) - x)) elif x <= 0.001: tmp = x + (-0.16666666666666666 * math.pow(x, 3.0)) else: tmp = math.log((x + math.hypot(1.0, x))) return tmp
function code(x) tmp = 0.0 if (x <= -0.00088) tmp = Float64(-log(Float64(hypot(1.0, x) - x))); elseif (x <= 0.001) tmp = Float64(x + Float64(-0.16666666666666666 * (x ^ 3.0))); else tmp = log(Float64(x + hypot(1.0, x))); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= -0.00088) tmp = -log((hypot(1.0, x) - x)); elseif (x <= 0.001) tmp = x + (-0.16666666666666666 * (x ^ 3.0)); else tmp = log((x + hypot(1.0, x))); end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, -0.00088], (-N[Log[N[(N[Sqrt[1.0 ^ 2 + x ^ 2], $MachinePrecision] - x), $MachinePrecision]], $MachinePrecision]), If[LessEqual[x, 0.001], N[(x + N[(-0.16666666666666666 * N[Power[x, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Log[N[(x + N[Sqrt[1.0 ^ 2 + x ^ 2], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -0.00088:\\
\;\;\;\;-\log \left(\mathsf{hypot}\left(1, x\right) - x\right)\\
\mathbf{elif}\;x \leq 0.001:\\
\;\;\;\;x + -0.16666666666666666 \cdot {x}^{3}\\
\mathbf{else}:\\
\;\;\;\;\log \left(x + \mathsf{hypot}\left(1, x\right)\right)\\
\end{array}
\end{array}
if x < -8.80000000000000031e-4Initial program 4.8%
sqr-neg4.8%
+-commutative4.8%
sqr-neg4.8%
hypot-1-def5.9%
Simplified5.9%
flip-+6.5%
frac-2neg6.5%
log-div6.5%
pow26.5%
hypot-1-def6.5%
hypot-1-def6.5%
add-sqr-sqrt6.5%
+-commutative6.5%
fma-define6.5%
Applied egg-rr6.5%
fma-undefine6.5%
unpow26.5%
associate--r+56.5%
+-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 -8.80000000000000031e-4 < x < 1e-3Initial 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 1e-3 < x Initial program 47.5%
sqr-neg47.5%
+-commutative47.5%
sqr-neg47.5%
hypot-1-def98.7%
Simplified98.7%
(FPCore (x)
:precision binary64
(if (<= x -1.25)
(log (/ -0.5 x))
(if (<= x 0.001)
(+ x (* -0.16666666666666666 (pow x 3.0)))
(log (+ x (hypot 1.0 x))))))
double code(double x) {
double tmp;
if (x <= -1.25) {
tmp = log((-0.5 / x));
} else if (x <= 0.001) {
tmp = x + (-0.16666666666666666 * pow(x, 3.0));
} else {
tmp = log((x + hypot(1.0, x)));
}
return tmp;
}
public static double code(double x) {
double tmp;
if (x <= -1.25) {
tmp = Math.log((-0.5 / x));
} else if (x <= 0.001) {
tmp = x + (-0.16666666666666666 * Math.pow(x, 3.0));
} else {
tmp = Math.log((x + Math.hypot(1.0, x)));
}
return tmp;
}
def code(x): tmp = 0 if x <= -1.25: tmp = math.log((-0.5 / x)) elif x <= 0.001: tmp = x + (-0.16666666666666666 * math.pow(x, 3.0)) else: tmp = math.log((x + math.hypot(1.0, x))) return tmp
function code(x) tmp = 0.0 if (x <= -1.25) tmp = log(Float64(-0.5 / x)); elseif (x <= 0.001) tmp = Float64(x + Float64(-0.16666666666666666 * (x ^ 3.0))); else tmp = log(Float64(x + hypot(1.0, x))); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= -1.25) tmp = log((-0.5 / x)); elseif (x <= 0.001) tmp = x + (-0.16666666666666666 * (x ^ 3.0)); else tmp = log((x + hypot(1.0, x))); end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, -1.25], N[Log[N[(-0.5 / x), $MachinePrecision]], $MachinePrecision], If[LessEqual[x, 0.001], N[(x + N[(-0.16666666666666666 * N[Power[x, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Log[N[(x + N[Sqrt[1.0 ^ 2 + x ^ 2], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.25:\\
\;\;\;\;\log \left(\frac{-0.5}{x}\right)\\
\mathbf{elif}\;x \leq 0.001:\\
\;\;\;\;x + -0.16666666666666666 \cdot {x}^{3}\\
\mathbf{else}:\\
\;\;\;\;\log \left(x + \mathsf{hypot}\left(1, x\right)\right)\\
\end{array}
\end{array}
if x < -1.25Initial program 4.8%
sqr-neg4.8%
+-commutative4.8%
sqr-neg4.8%
hypot-1-def5.9%
Simplified5.9%
Taylor expanded in x around -inf 98.7%
if -1.25 < x < 1e-3Initial 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 1e-3 < x Initial program 47.5%
sqr-neg47.5%
+-commutative47.5%
sqr-neg47.5%
hypot-1-def98.7%
Simplified98.7%
(FPCore (x)
:precision binary64
(if (<= x -1.25)
(log (/ -0.5 x))
(if (<= x 1.26)
(+ x (* -0.16666666666666666 (pow x 3.0)))
(- (log (/ 0.5 x))))))
double code(double x) {
double tmp;
if (x <= -1.25) {
tmp = log((-0.5 / x));
} else if (x <= 1.26) {
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.25d0)) then
tmp = log(((-0.5d0) / x))
else if (x <= 1.26d0) 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.25) {
tmp = Math.log((-0.5 / x));
} else if (x <= 1.26) {
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.25: tmp = math.log((-0.5 / x)) elif x <= 1.26: 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.25) tmp = log(Float64(-0.5 / x)); elseif (x <= 1.26) 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.25) tmp = log((-0.5 / x)); elseif (x <= 1.26) tmp = x + (-0.16666666666666666 * (x ^ 3.0)); else tmp = -log((0.5 / x)); end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, -1.25], N[Log[N[(-0.5 / x), $MachinePrecision]], $MachinePrecision], If[LessEqual[x, 1.26], 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.25:\\
\;\;\;\;\log \left(\frac{-0.5}{x}\right)\\
\mathbf{elif}\;x \leq 1.26:\\
\;\;\;\;x + -0.16666666666666666 \cdot {x}^{3}\\
\mathbf{else}:\\
\;\;\;\;-\log \left(\frac{0.5}{x}\right)\\
\end{array}
\end{array}
if x < -1.25Initial program 4.8%
sqr-neg4.8%
+-commutative4.8%
sqr-neg4.8%
hypot-1-def5.9%
Simplified5.9%
Taylor expanded in x around -inf 98.7%
if -1.25 < x < 1.26000000000000001Initial 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.26000000000000001 < x Initial program 47.5%
sqr-neg47.5%
+-commutative47.5%
sqr-neg47.5%
hypot-1-def98.7%
Simplified98.7%
flip-+2.6%
frac-2neg2.6%
log-div2.6%
pow22.6%
hypot-1-def2.6%
hypot-1-def2.6%
add-sqr-sqrt2.6%
+-commutative2.6%
fma-define2.6%
Applied egg-rr2.6%
fma-undefine2.6%
unpow22.6%
associate--r+3.9%
+-inverses5.6%
metadata-eval5.6%
metadata-eval5.6%
metadata-eval5.6%
neg-sub05.6%
neg-sub05.6%
associate--r-5.6%
neg-sub05.6%
+-commutative5.6%
sub-neg5.6%
Simplified5.6%
Taylor expanded in x around inf 98.2%
(FPCore (x) :precision binary64 (if (<= x -1.25) (log (/ -0.5 x)) (if (<= x 1.26) x (- (log (/ 0.5 x))))))
double code(double x) {
double tmp;
if (x <= -1.25) {
tmp = log((-0.5 / x));
} else if (x <= 1.26) {
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.25d0)) then
tmp = log(((-0.5d0) / x))
else if (x <= 1.26d0) 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.25) {
tmp = Math.log((-0.5 / x));
} else if (x <= 1.26) {
tmp = x;
} else {
tmp = -Math.log((0.5 / x));
}
return tmp;
}
def code(x): tmp = 0 if x <= -1.25: tmp = math.log((-0.5 / x)) elif x <= 1.26: tmp = x else: tmp = -math.log((0.5 / x)) return tmp
function code(x) tmp = 0.0 if (x <= -1.25) tmp = log(Float64(-0.5 / x)); elseif (x <= 1.26) 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.25) tmp = log((-0.5 / x)); elseif (x <= 1.26) tmp = x; else tmp = -log((0.5 / x)); end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, -1.25], N[Log[N[(-0.5 / x), $MachinePrecision]], $MachinePrecision], If[LessEqual[x, 1.26], x, (-N[Log[N[(0.5 / x), $MachinePrecision]], $MachinePrecision])]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.25:\\
\;\;\;\;\log \left(\frac{-0.5}{x}\right)\\
\mathbf{elif}\;x \leq 1.26:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;-\log \left(\frac{0.5}{x}\right)\\
\end{array}
\end{array}
if x < -1.25Initial program 4.8%
sqr-neg4.8%
+-commutative4.8%
sqr-neg4.8%
hypot-1-def5.9%
Simplified5.9%
Taylor expanded in x around -inf 98.7%
if -1.25 < x < 1.26000000000000001Initial program 7.5%
sqr-neg7.5%
+-commutative7.5%
sqr-neg7.5%
hypot-1-def7.6%
Simplified7.6%
Taylor expanded in x around 0 99.8%
if 1.26000000000000001 < x Initial program 47.5%
sqr-neg47.5%
+-commutative47.5%
sqr-neg47.5%
hypot-1-def98.7%
Simplified98.7%
flip-+2.6%
frac-2neg2.6%
log-div2.6%
pow22.6%
hypot-1-def2.6%
hypot-1-def2.6%
add-sqr-sqrt2.6%
+-commutative2.6%
fma-define2.6%
Applied egg-rr2.6%
fma-undefine2.6%
unpow22.6%
associate--r+3.9%
+-inverses5.6%
metadata-eval5.6%
metadata-eval5.6%
metadata-eval5.6%
neg-sub05.6%
neg-sub05.6%
associate--r-5.6%
neg-sub05.6%
+-commutative5.6%
sub-neg5.6%
Simplified5.6%
Taylor expanded in x around inf 98.2%
(FPCore (x) :precision binary64 (if (<= x -1.25) (log (/ -0.5 x)) (if (<= x 1.26) x (log (* x 2.0)))))
double code(double x) {
double tmp;
if (x <= -1.25) {
tmp = log((-0.5 / x));
} else if (x <= 1.26) {
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.25d0)) then
tmp = log(((-0.5d0) / x))
else if (x <= 1.26d0) 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.25) {
tmp = Math.log((-0.5 / x));
} else if (x <= 1.26) {
tmp = x;
} else {
tmp = Math.log((x * 2.0));
}
return tmp;
}
def code(x): tmp = 0 if x <= -1.25: tmp = math.log((-0.5 / x)) elif x <= 1.26: tmp = x else: tmp = math.log((x * 2.0)) return tmp
function code(x) tmp = 0.0 if (x <= -1.25) tmp = log(Float64(-0.5 / x)); elseif (x <= 1.26) tmp = x; else tmp = log(Float64(x * 2.0)); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= -1.25) tmp = log((-0.5 / x)); elseif (x <= 1.26) tmp = x; else tmp = log((x * 2.0)); end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, -1.25], N[Log[N[(-0.5 / x), $MachinePrecision]], $MachinePrecision], If[LessEqual[x, 1.26], x, N[Log[N[(x * 2.0), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.25:\\
\;\;\;\;\log \left(\frac{-0.5}{x}\right)\\
\mathbf{elif}\;x \leq 1.26:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;\log \left(x \cdot 2\right)\\
\end{array}
\end{array}
if x < -1.25Initial program 4.8%
sqr-neg4.8%
+-commutative4.8%
sqr-neg4.8%
hypot-1-def5.9%
Simplified5.9%
Taylor expanded in x around -inf 98.7%
if -1.25 < x < 1.26000000000000001Initial program 7.5%
sqr-neg7.5%
+-commutative7.5%
sqr-neg7.5%
hypot-1-def7.6%
Simplified7.6%
Taylor expanded in x around 0 99.8%
if 1.26000000000000001 < x Initial program 47.5%
sqr-neg47.5%
+-commutative47.5%
sqr-neg47.5%
hypot-1-def98.7%
Simplified98.7%
Taylor expanded in x around inf 96.9%
*-commutative96.9%
Simplified96.9%
(FPCore (x) :precision binary64 (if (<= x -8.0) -8.0 (if (<= x 1.26) x (log (* x 2.0)))))
double code(double x) {
double tmp;
if (x <= -8.0) {
tmp = -8.0;
} else if (x <= 1.26) {
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.26d0) 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.26) {
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.26: 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.26) 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.26) 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.26], 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.26:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;\log \left(x \cdot 2\right)\\
\end{array}
\end{array}
if x < -8Initial program 4.8%
sqr-neg4.8%
+-commutative4.8%
sqr-neg4.8%
hypot-1-def5.9%
Simplified5.9%
flip-+6.5%
frac-2neg6.5%
log-div6.5%
pow26.5%
hypot-1-def6.5%
hypot-1-def6.5%
add-sqr-sqrt6.5%
+-commutative6.5%
fma-define6.5%
Applied egg-rr6.5%
fma-undefine6.5%
unpow26.5%
associate--r+56.5%
+-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.4%
if -8 < x < 1.26000000000000001Initial program 7.5%
sqr-neg7.5%
+-commutative7.5%
sqr-neg7.5%
hypot-1-def7.6%
Simplified7.6%
Taylor expanded in x around 0 99.8%
if 1.26000000000000001 < x Initial program 47.5%
sqr-neg47.5%
+-commutative47.5%
sqr-neg47.5%
hypot-1-def98.7%
Simplified98.7%
Taylor expanded in x around inf 96.9%
*-commutative96.9%
Simplified96.9%
(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 4.8%
sqr-neg4.8%
+-commutative4.8%
sqr-neg4.8%
hypot-1-def5.9%
Simplified5.9%
flip-+6.5%
frac-2neg6.5%
log-div6.5%
pow26.5%
hypot-1-def6.5%
hypot-1-def6.5%
add-sqr-sqrt6.5%
+-commutative6.5%
fma-define6.5%
Applied egg-rr6.5%
fma-undefine6.5%
unpow26.5%
associate--r+56.5%
+-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.4%
if -1 < x Initial program 22.4%
sqr-neg22.4%
+-commutative22.4%
sqr-neg22.4%
hypot-1-def41.4%
Simplified41.4%
Taylor expanded in x around 0 16.3%
+-commutative16.3%
Simplified16.3%
*-un-lft-identity16.3%
log-prod16.3%
metadata-eval16.3%
+-commutative16.3%
log1p-define73.7%
Applied egg-rr73.7%
+-lft-identity73.7%
Simplified73.7%
(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 4.8%
sqr-neg4.8%
+-commutative4.8%
sqr-neg4.8%
hypot-1-def5.9%
Simplified5.9%
flip-+6.5%
frac-2neg6.5%
log-div6.5%
pow26.5%
hypot-1-def6.5%
hypot-1-def6.5%
add-sqr-sqrt6.5%
+-commutative6.5%
fma-define6.5%
Applied egg-rr6.5%
fma-undefine6.5%
unpow26.5%
associate--r+56.5%
+-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.4%
if -8 < x < 9Initial program 7.5%
sqr-neg7.5%
+-commutative7.5%
sqr-neg7.5%
hypot-1-def7.6%
Simplified7.6%
Taylor expanded in x around 0 99.8%
if 9 < x Initial program 47.5%
sqr-neg47.5%
+-commutative47.5%
sqr-neg47.5%
hypot-1-def98.7%
Simplified98.7%
flip-+2.6%
frac-2neg2.6%
log-div2.6%
pow22.6%
hypot-1-def2.6%
hypot-1-def2.6%
add-sqr-sqrt2.6%
+-commutative2.6%
fma-define2.6%
Applied egg-rr2.6%
fma-undefine2.6%
unpow22.6%
associate--r+3.9%
+-inverses5.6%
metadata-eval5.6%
metadata-eval5.6%
metadata-eval5.6%
neg-sub05.6%
neg-sub05.6%
associate--r-5.6%
neg-sub05.6%
+-commutative5.6%
sub-neg5.6%
Simplified5.6%
Taylor expanded in x around inf 98.2%
Applied egg-rr15.2%
(FPCore (x) :precision binary64 (if (<= x 1e-309) -8.0 9.0))
double code(double x) {
double tmp;
if (x <= 1e-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 <= 1d-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 <= 1e-309) {
tmp = -8.0;
} else {
tmp = 9.0;
}
return tmp;
}
def code(x): tmp = 0 if x <= 1e-309: tmp = -8.0 else: tmp = 9.0 return tmp
function code(x) tmp = 0.0 if (x <= 1e-309) tmp = -8.0; else tmp = 9.0; end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= 1e-309) tmp = -8.0; else tmp = 9.0; end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, 1e-309], -8.0, 9.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 10^{-309}:\\
\;\;\;\;-8\\
\mathbf{else}:\\
\;\;\;\;9\\
\end{array}
\end{array}
if x < 1.000000000000002e-309Initial program 6.2%
sqr-neg6.2%
+-commutative6.2%
sqr-neg6.2%
hypot-1-def6.8%
Simplified6.8%
flip-+7.0%
frac-2neg7.0%
log-div7.0%
pow27.0%
hypot-1-def7.0%
hypot-1-def7.0%
add-sqr-sqrt7.0%
+-commutative7.0%
fma-define7.0%
Applied egg-rr7.0%
fma-undefine7.0%
unpow27.0%
associate--r+31.0%
+-inverses51.9%
metadata-eval51.9%
metadata-eval51.9%
metadata-eval51.9%
neg-sub051.9%
neg-sub051.9%
associate--r-51.9%
neg-sub051.9%
+-commutative51.9%
sub-neg51.9%
Simplified51.9%
Taylor expanded in x around inf 0.0%
Applied egg-rr10.2%
if 1.000000000000002e-309 < x Initial program 30.2%
sqr-neg30.2%
+-commutative30.2%
sqr-neg30.2%
hypot-1-def59.2%
Simplified59.2%
flip-+4.7%
frac-2neg4.7%
log-div4.7%
pow24.7%
hypot-1-def4.7%
hypot-1-def4.7%
add-sqr-sqrt4.7%
+-commutative4.7%
fma-define4.7%
Applied egg-rr4.7%
fma-undefine4.7%
unpow24.7%
associate--r+5.5%
+-inverses6.4%
metadata-eval6.4%
metadata-eval6.4%
metadata-eval6.4%
neg-sub06.4%
neg-sub06.4%
associate--r-6.4%
neg-sub06.4%
+-commutative6.4%
sub-neg6.4%
Simplified6.4%
Taylor expanded in x around inf 56.7%
Applied egg-rr11.0%
(FPCore (x) :precision binary64 (if (<= x -1.2e-308) -8.0 4.0))
double code(double x) {
double tmp;
if (x <= -1.2e-308) {
tmp = -8.0;
} else {
tmp = 4.0;
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (x <= (-1.2d-308)) then
tmp = -8.0d0
else
tmp = 4.0d0
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (x <= -1.2e-308) {
tmp = -8.0;
} else {
tmp = 4.0;
}
return tmp;
}
def code(x): tmp = 0 if x <= -1.2e-308: tmp = -8.0 else: tmp = 4.0 return tmp
function code(x) tmp = 0.0 if (x <= -1.2e-308) tmp = -8.0; else tmp = 4.0; end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= -1.2e-308) tmp = -8.0; else tmp = 4.0; end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, -1.2e-308], -8.0, 4.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.2 \cdot 10^{-308}:\\
\;\;\;\;-8\\
\mathbf{else}:\\
\;\;\;\;4\\
\end{array}
\end{array}
if x < -1.1999999999999998e-308Initial program 6.2%
sqr-neg6.2%
+-commutative6.2%
sqr-neg6.2%
hypot-1-def6.8%
Simplified6.8%
flip-+7.0%
frac-2neg7.0%
log-div7.0%
pow27.0%
hypot-1-def7.0%
hypot-1-def7.0%
add-sqr-sqrt7.0%
+-commutative7.0%
fma-define7.0%
Applied egg-rr7.0%
fma-undefine7.0%
unpow27.0%
associate--r+31.0%
+-inverses51.9%
metadata-eval51.9%
metadata-eval51.9%
metadata-eval51.9%
neg-sub051.9%
neg-sub051.9%
associate--r-51.9%
neg-sub051.9%
+-commutative51.9%
sub-neg51.9%
Simplified51.9%
Taylor expanded in x around inf 0.0%
Applied egg-rr10.2%
if -1.1999999999999998e-308 < x Initial program 30.2%
sqr-neg30.2%
+-commutative30.2%
sqr-neg30.2%
hypot-1-def59.2%
Simplified59.2%
flip-+4.7%
frac-2neg4.7%
log-div4.7%
pow24.7%
hypot-1-def4.7%
hypot-1-def4.7%
add-sqr-sqrt4.7%
+-commutative4.7%
fma-define4.7%
Applied egg-rr4.7%
fma-undefine4.7%
unpow24.7%
associate--r+5.5%
+-inverses6.4%
metadata-eval6.4%
metadata-eval6.4%
metadata-eval6.4%
neg-sub06.4%
neg-sub06.4%
associate--r-6.4%
neg-sub06.4%
+-commutative6.4%
sub-neg6.4%
Simplified6.4%
Taylor expanded in x around inf 56.7%
Applied egg-rr10.8%
(FPCore (x) :precision binary64 (if (<= x -1.6e-308) -8.0 3.0))
double code(double x) {
double tmp;
if (x <= -1.6e-308) {
tmp = -8.0;
} else {
tmp = 3.0;
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (x <= (-1.6d-308)) then
tmp = -8.0d0
else
tmp = 3.0d0
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (x <= -1.6e-308) {
tmp = -8.0;
} else {
tmp = 3.0;
}
return tmp;
}
def code(x): tmp = 0 if x <= -1.6e-308: tmp = -8.0 else: tmp = 3.0 return tmp
function code(x) tmp = 0.0 if (x <= -1.6e-308) tmp = -8.0; else tmp = 3.0; end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= -1.6e-308) tmp = -8.0; else tmp = 3.0; end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, -1.6e-308], -8.0, 3.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.6 \cdot 10^{-308}:\\
\;\;\;\;-8\\
\mathbf{else}:\\
\;\;\;\;3\\
\end{array}
\end{array}
if x < -1.6000000000000001e-308Initial program 6.2%
sqr-neg6.2%
+-commutative6.2%
sqr-neg6.2%
hypot-1-def6.8%
Simplified6.8%
flip-+7.0%
frac-2neg7.0%
log-div7.0%
pow27.0%
hypot-1-def7.0%
hypot-1-def7.0%
add-sqr-sqrt7.0%
+-commutative7.0%
fma-define7.0%
Applied egg-rr7.0%
fma-undefine7.0%
unpow27.0%
associate--r+31.0%
+-inverses51.9%
metadata-eval51.9%
metadata-eval51.9%
metadata-eval51.9%
neg-sub051.9%
neg-sub051.9%
associate--r-51.9%
neg-sub051.9%
+-commutative51.9%
sub-neg51.9%
Simplified51.9%
Taylor expanded in x around inf 0.0%
Applied egg-rr10.2%
if -1.6000000000000001e-308 < x Initial program 30.2%
sqr-neg30.2%
+-commutative30.2%
sqr-neg30.2%
hypot-1-def59.2%
Simplified59.2%
flip-+4.7%
frac-2neg4.7%
log-div4.7%
pow24.7%
hypot-1-def4.7%
hypot-1-def4.7%
add-sqr-sqrt4.7%
+-commutative4.7%
fma-define4.7%
Applied egg-rr4.7%
fma-undefine4.7%
unpow24.7%
associate--r+5.5%
+-inverses6.4%
metadata-eval6.4%
metadata-eval6.4%
metadata-eval6.4%
neg-sub06.4%
neg-sub06.4%
associate--r-6.4%
neg-sub06.4%
+-commutative6.4%
sub-neg6.4%
Simplified6.4%
Taylor expanded in x around inf 56.7%
Applied egg-rr10.7%
(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 18.1%
sqr-neg18.1%
+-commutative18.1%
sqr-neg18.1%
hypot-1-def32.8%
Simplified32.8%
flip-+5.9%
frac-2neg5.9%
log-div5.8%
pow25.8%
hypot-1-def5.9%
hypot-1-def5.8%
add-sqr-sqrt5.9%
+-commutative5.9%
fma-define5.9%
Applied egg-rr5.9%
fma-undefine5.9%
unpow25.9%
associate--r+18.3%
+-inverses29.4%
metadata-eval29.4%
metadata-eval29.4%
metadata-eval29.4%
neg-sub029.4%
neg-sub029.4%
associate--r-29.4%
neg-sub029.4%
+-commutative29.4%
sub-neg29.4%
Simplified29.4%
Taylor expanded in x around inf 28.1%
Applied egg-rr6.1%
(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 2024150
(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)))))