
(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 9 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 -4e+33)
(log (/ -0.5 x))
(if (<= x 0.028)
(+ x (* -0.16666666666666666 (pow x 3.0)))
(log (* x 2.0)))))
double code(double x) {
double tmp;
if (x <= -4e+33) {
tmp = log((-0.5 / x));
} else if (x <= 0.028) {
tmp = x + (-0.16666666666666666 * pow(x, 3.0));
} else {
tmp = log((x * 2.0));
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (x <= (-4d+33)) then
tmp = log(((-0.5d0) / x))
else if (x <= 0.028d0) then
tmp = x + ((-0.16666666666666666d0) * (x ** 3.0d0))
else
tmp = log((x * 2.0d0))
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (x <= -4e+33) {
tmp = Math.log((-0.5 / x));
} else if (x <= 0.028) {
tmp = x + (-0.16666666666666666 * Math.pow(x, 3.0));
} else {
tmp = Math.log((x * 2.0));
}
return tmp;
}
def code(x): tmp = 0 if x <= -4e+33: tmp = math.log((-0.5 / x)) elif x <= 0.028: tmp = x + (-0.16666666666666666 * math.pow(x, 3.0)) else: tmp = math.log((x * 2.0)) return tmp
function code(x) tmp = 0.0 if (x <= -4e+33) tmp = log(Float64(-0.5 / x)); elseif (x <= 0.028) tmp = Float64(x + Float64(-0.16666666666666666 * (x ^ 3.0))); else tmp = log(Float64(x * 2.0)); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= -4e+33) tmp = log((-0.5 / x)); elseif (x <= 0.028) tmp = x + (-0.16666666666666666 * (x ^ 3.0)); else tmp = log((x * 2.0)); end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, -4e+33], N[Log[N[(-0.5 / x), $MachinePrecision]], $MachinePrecision], If[LessEqual[x, 0.028], N[(x + N[(-0.16666666666666666 * N[Power[x, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Log[N[(x * 2.0), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -4 \cdot 10^{+33}:\\
\;\;\;\;\log \left(\frac{-0.5}{x}\right)\\
\mathbf{elif}\;x \leq 0.028:\\
\;\;\;\;x + -0.16666666666666666 \cdot {x}^{3}\\
\mathbf{else}:\\
\;\;\;\;\log \left(x \cdot 2\right)\\
\end{array}
\end{array}
if x < -3.9999999999999998e33Initial program 1.7%
Taylor expanded in x around -inf 100.0%
if -3.9999999999999998e33 < x < 0.0280000000000000006Initial program 9.7%
Taylor expanded in x around 0 98.2%
distribute-rgt-in98.2%
*-lft-identity98.2%
associate-*l*98.2%
unpow298.2%
unpow398.2%
Simplified98.2%
if 0.0280000000000000006 < x Initial program 63.0%
Taylor expanded in x around inf 96.9%
*-commutative96.9%
Simplified96.9%
(FPCore (x)
:precision binary64
(if (<= x -4e+33)
(log (/ -0.5 x))
(if (<= x 1.2e-23)
(*
x
(+
1.0
(*
(pow x 2.0)
(-
(* (pow x 2.0) (+ 0.075 (* (pow x 2.0) -0.044642857142857144)))
0.16666666666666666))))
(log (+ x (hypot 1.0 x))))))
double code(double x) {
double tmp;
if (x <= -4e+33) {
tmp = log((-0.5 / x));
} else if (x <= 1.2e-23) {
tmp = x * (1.0 + (pow(x, 2.0) * ((pow(x, 2.0) * (0.075 + (pow(x, 2.0) * -0.044642857142857144))) - 0.16666666666666666)));
} else {
tmp = log((x + hypot(1.0, x)));
}
return tmp;
}
public static double code(double x) {
double tmp;
if (x <= -4e+33) {
tmp = Math.log((-0.5 / x));
} else if (x <= 1.2e-23) {
tmp = x * (1.0 + (Math.pow(x, 2.0) * ((Math.pow(x, 2.0) * (0.075 + (Math.pow(x, 2.0) * -0.044642857142857144))) - 0.16666666666666666)));
} else {
tmp = Math.log((x + Math.hypot(1.0, x)));
}
return tmp;
}
def code(x): tmp = 0 if x <= -4e+33: tmp = math.log((-0.5 / x)) elif x <= 1.2e-23: tmp = x * (1.0 + (math.pow(x, 2.0) * ((math.pow(x, 2.0) * (0.075 + (math.pow(x, 2.0) * -0.044642857142857144))) - 0.16666666666666666))) else: tmp = math.log((x + math.hypot(1.0, x))) return tmp
function code(x) tmp = 0.0 if (x <= -4e+33) tmp = log(Float64(-0.5 / x)); elseif (x <= 1.2e-23) tmp = Float64(x * Float64(1.0 + Float64((x ^ 2.0) * Float64(Float64((x ^ 2.0) * Float64(0.075 + Float64((x ^ 2.0) * -0.044642857142857144))) - 0.16666666666666666)))); else tmp = log(Float64(x + hypot(1.0, x))); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= -4e+33) tmp = log((-0.5 / x)); elseif (x <= 1.2e-23) tmp = x * (1.0 + ((x ^ 2.0) * (((x ^ 2.0) * (0.075 + ((x ^ 2.0) * -0.044642857142857144))) - 0.16666666666666666))); else tmp = log((x + hypot(1.0, x))); end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, -4e+33], N[Log[N[(-0.5 / x), $MachinePrecision]], $MachinePrecision], If[LessEqual[x, 1.2e-23], N[(x * N[(1.0 + N[(N[Power[x, 2.0], $MachinePrecision] * N[(N[(N[Power[x, 2.0], $MachinePrecision] * N[(0.075 + N[(N[Power[x, 2.0], $MachinePrecision] * -0.044642857142857144), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 0.16666666666666666), $MachinePrecision]), $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 -4 \cdot 10^{+33}:\\
\;\;\;\;\log \left(\frac{-0.5}{x}\right)\\
\mathbf{elif}\;x \leq 1.2 \cdot 10^{-23}:\\
\;\;\;\;x \cdot \left(1 + {x}^{2} \cdot \left({x}^{2} \cdot \left(0.075 + {x}^{2} \cdot -0.044642857142857144\right) - 0.16666666666666666\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\log \left(x + \mathsf{hypot}\left(1, x\right)\right)\\
\end{array}
\end{array}
if x < -3.9999999999999998e33Initial program 1.7%
Taylor expanded in x around -inf 100.0%
if -3.9999999999999998e33 < x < 1.19999999999999998e-23Initial program 9.2%
Taylor expanded in x around 0 98.5%
if 1.19999999999999998e-23 < x Initial program 60.7%
sqr-neg60.7%
+-commutative60.7%
sqr-neg60.7%
hypot-1-def94.0%
Simplified94.0%
Final simplification97.6%
(FPCore (x)
:precision binary64
(if (<= x -4e+33)
(log (/ -0.5 x))
(if (<= x 1.2e-23)
(*
x
(+ 1.0 (* (pow x 2.0) (- (* (pow x 2.0) 0.075) 0.16666666666666666))))
(log (+ x (hypot 1.0 x))))))
double code(double x) {
double tmp;
if (x <= -4e+33) {
tmp = log((-0.5 / x));
} else if (x <= 1.2e-23) {
tmp = x * (1.0 + (pow(x, 2.0) * ((pow(x, 2.0) * 0.075) - 0.16666666666666666)));
} else {
tmp = log((x + hypot(1.0, x)));
}
return tmp;
}
public static double code(double x) {
double tmp;
if (x <= -4e+33) {
tmp = Math.log((-0.5 / x));
} else if (x <= 1.2e-23) {
tmp = x * (1.0 + (Math.pow(x, 2.0) * ((Math.pow(x, 2.0) * 0.075) - 0.16666666666666666)));
} else {
tmp = Math.log((x + Math.hypot(1.0, x)));
}
return tmp;
}
def code(x): tmp = 0 if x <= -4e+33: tmp = math.log((-0.5 / x)) elif x <= 1.2e-23: tmp = x * (1.0 + (math.pow(x, 2.0) * ((math.pow(x, 2.0) * 0.075) - 0.16666666666666666))) else: tmp = math.log((x + math.hypot(1.0, x))) return tmp
function code(x) tmp = 0.0 if (x <= -4e+33) tmp = log(Float64(-0.5 / x)); elseif (x <= 1.2e-23) tmp = Float64(x * Float64(1.0 + Float64((x ^ 2.0) * Float64(Float64((x ^ 2.0) * 0.075) - 0.16666666666666666)))); else tmp = log(Float64(x + hypot(1.0, x))); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= -4e+33) tmp = log((-0.5 / x)); elseif (x <= 1.2e-23) tmp = x * (1.0 + ((x ^ 2.0) * (((x ^ 2.0) * 0.075) - 0.16666666666666666))); else tmp = log((x + hypot(1.0, x))); end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, -4e+33], N[Log[N[(-0.5 / x), $MachinePrecision]], $MachinePrecision], If[LessEqual[x, 1.2e-23], N[(x * N[(1.0 + N[(N[Power[x, 2.0], $MachinePrecision] * N[(N[(N[Power[x, 2.0], $MachinePrecision] * 0.075), $MachinePrecision] - 0.16666666666666666), $MachinePrecision]), $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 -4 \cdot 10^{+33}:\\
\;\;\;\;\log \left(\frac{-0.5}{x}\right)\\
\mathbf{elif}\;x \leq 1.2 \cdot 10^{-23}:\\
\;\;\;\;x \cdot \left(1 + {x}^{2} \cdot \left({x}^{2} \cdot 0.075 - 0.16666666666666666\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\log \left(x + \mathsf{hypot}\left(1, x\right)\right)\\
\end{array}
\end{array}
if x < -3.9999999999999998e33Initial program 1.7%
Taylor expanded in x around -inf 100.0%
if -3.9999999999999998e33 < x < 1.19999999999999998e-23Initial program 9.2%
Taylor expanded in x around 0 98.5%
if 1.19999999999999998e-23 < x Initial program 60.7%
sqr-neg60.7%
+-commutative60.7%
sqr-neg60.7%
hypot-1-def94.0%
Simplified94.0%
Final simplification97.6%
(FPCore (x)
:precision binary64
(if (<= x -4e+33)
(log (/ -0.5 x))
(if (<= x 9.2e-17)
(+ x (* -0.16666666666666666 (pow x 3.0)))
(log (+ x (hypot 1.0 x))))))
double code(double x) {
double tmp;
if (x <= -4e+33) {
tmp = log((-0.5 / x));
} else if (x <= 9.2e-17) {
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 <= -4e+33) {
tmp = Math.log((-0.5 / x));
} else if (x <= 9.2e-17) {
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 <= -4e+33: tmp = math.log((-0.5 / x)) elif x <= 9.2e-17: 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 <= -4e+33) tmp = log(Float64(-0.5 / x)); elseif (x <= 9.2e-17) 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 <= -4e+33) tmp = log((-0.5 / x)); elseif (x <= 9.2e-17) 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, -4e+33], N[Log[N[(-0.5 / x), $MachinePrecision]], $MachinePrecision], If[LessEqual[x, 9.2e-17], 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 -4 \cdot 10^{+33}:\\
\;\;\;\;\log \left(\frac{-0.5}{x}\right)\\
\mathbf{elif}\;x \leq 9.2 \cdot 10^{-17}:\\
\;\;\;\;x + -0.16666666666666666 \cdot {x}^{3}\\
\mathbf{else}:\\
\;\;\;\;\log \left(x + \mathsf{hypot}\left(1, x\right)\right)\\
\end{array}
\end{array}
if x < -3.9999999999999998e33Initial program 1.7%
Taylor expanded in x around -inf 100.0%
if -3.9999999999999998e33 < x < 9.20000000000000035e-17Initial program 9.2%
Taylor expanded in x around 0 98.1%
distribute-rgt-in98.1%
*-lft-identity98.1%
associate-*l*98.1%
unpow298.1%
unpow398.1%
Simplified98.1%
if 9.20000000000000035e-17 < x Initial program 61.6%
sqr-neg61.6%
+-commutative61.6%
sqr-neg61.6%
hypot-1-def95.3%
Simplified95.3%
(FPCore (x)
:precision binary64
(if (<= x -4e+33)
(log (/ -0.5 x))
(if (<= x 4e-11)
(+ x (* -0.16666666666666666 (pow x 3.0)))
(+ (log 2.0) (log x)))))
double code(double x) {
double tmp;
if (x <= -4e+33) {
tmp = log((-0.5 / x));
} else if (x <= 4e-11) {
tmp = x + (-0.16666666666666666 * pow(x, 3.0));
} else {
tmp = log(2.0) + log(x);
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (x <= (-4d+33)) then
tmp = log(((-0.5d0) / x))
else if (x <= 4d-11) then
tmp = x + ((-0.16666666666666666d0) * (x ** 3.0d0))
else
tmp = log(2.0d0) + log(x)
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (x <= -4e+33) {
tmp = Math.log((-0.5 / x));
} else if (x <= 4e-11) {
tmp = x + (-0.16666666666666666 * Math.pow(x, 3.0));
} else {
tmp = Math.log(2.0) + Math.log(x);
}
return tmp;
}
def code(x): tmp = 0 if x <= -4e+33: tmp = math.log((-0.5 / x)) elif x <= 4e-11: tmp = x + (-0.16666666666666666 * math.pow(x, 3.0)) else: tmp = math.log(2.0) + math.log(x) return tmp
function code(x) tmp = 0.0 if (x <= -4e+33) tmp = log(Float64(-0.5 / x)); elseif (x <= 4e-11) tmp = Float64(x + Float64(-0.16666666666666666 * (x ^ 3.0))); else tmp = Float64(log(2.0) + log(x)); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= -4e+33) tmp = log((-0.5 / x)); elseif (x <= 4e-11) tmp = x + (-0.16666666666666666 * (x ^ 3.0)); else tmp = log(2.0) + log(x); end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, -4e+33], N[Log[N[(-0.5 / x), $MachinePrecision]], $MachinePrecision], If[LessEqual[x, 4e-11], N[(x + N[(-0.16666666666666666 * N[Power[x, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Log[2.0], $MachinePrecision] + N[Log[x], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -4 \cdot 10^{+33}:\\
\;\;\;\;\log \left(\frac{-0.5}{x}\right)\\
\mathbf{elif}\;x \leq 4 \cdot 10^{-11}:\\
\;\;\;\;x + -0.16666666666666666 \cdot {x}^{3}\\
\mathbf{else}:\\
\;\;\;\;\log 2 + \log x\\
\end{array}
\end{array}
if x < -3.9999999999999998e33Initial program 1.7%
Taylor expanded in x around -inf 100.0%
if -3.9999999999999998e33 < x < 3.99999999999999976e-11Initial program 9.4%
Taylor expanded in x around 0 98.1%
distribute-rgt-in98.1%
*-lft-identity98.1%
associate-*l*98.1%
unpow298.1%
unpow398.1%
Simplified98.1%
if 3.99999999999999976e-11 < x Initial program 62.8%
Taylor expanded in x around inf 96.6%
mul-1-neg96.6%
log-rec96.6%
remove-double-neg96.6%
Simplified96.6%
(FPCore (x) :precision binary64 (if (<= x -4e+33) (log (/ -0.5 x)) (if (<= x 1.25) x (log (* x 2.0)))))
double code(double x) {
double tmp;
if (x <= -4e+33) {
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 <= (-4d+33)) 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 <= -4e+33) {
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 <= -4e+33: 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 <= -4e+33) 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 <= -4e+33) 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, -4e+33], 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 -4 \cdot 10^{+33}:\\
\;\;\;\;\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 < -3.9999999999999998e33Initial program 1.7%
Taylor expanded in x around -inf 100.0%
if -3.9999999999999998e33 < x < 1.25Initial program 10.3%
Taylor expanded in x around 0 97.3%
if 1.25 < x Initial program 62.5%
Taylor expanded in x around inf 98.4%
*-commutative98.4%
Simplified98.4%
(FPCore (x) :precision binary64 (if (<= x 1.25) x (log (* x 2.0))))
double code(double x) {
double tmp;
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.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.25) {
tmp = x;
} else {
tmp = Math.log((x * 2.0));
}
return tmp;
}
def code(x): tmp = 0 if x <= 1.25: tmp = x else: tmp = math.log((x * 2.0)) return tmp
function code(x) tmp = 0.0 if (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.25) tmp = x; else tmp = log((x * 2.0)); end tmp_2 = tmp; end
code[x_] := 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.25:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;\log \left(x \cdot 2\right)\\
\end{array}
\end{array}
if x < 1.25Initial program 7.9%
Taylor expanded in x around 0 71.1%
if 1.25 < x Initial program 62.5%
Taylor expanded in x around inf 98.4%
*-commutative98.4%
Simplified98.4%
(FPCore (x) :precision binary64 (if (<= x -1.7e-9) x (log1p x)))
double code(double x) {
double tmp;
if (x <= -1.7e-9) {
tmp = x;
} else {
tmp = log1p(x);
}
return tmp;
}
public static double code(double x) {
double tmp;
if (x <= -1.7e-9) {
tmp = x;
} else {
tmp = Math.log1p(x);
}
return tmp;
}
def code(x): tmp = 0 if x <= -1.7e-9: tmp = x else: tmp = math.log1p(x) return tmp
function code(x) tmp = 0.0 if (x <= -1.7e-9) tmp = x; else tmp = log1p(x); end return tmp end
code[x_] := If[LessEqual[x, -1.7e-9], x, N[Log[1 + x], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.7 \cdot 10^{-9}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;\mathsf{log1p}\left(x\right)\\
\end{array}
\end{array}
if x < -1.6999999999999999e-9Initial program 8.9%
Taylor expanded in x around 0 10.4%
if -1.6999999999999999e-9 < x Initial program 25.0%
Taylor expanded in x around 0 14.7%
+-commutative14.7%
Simplified14.7%
*-un-lft-identity14.7%
log-prod14.7%
metadata-eval14.7%
+-commutative14.7%
log1p-define77.1%
Applied egg-rr77.1%
+-lft-identity77.1%
Simplified77.1%
(FPCore (x) :precision binary64 x)
double code(double x) {
return x;
}
real(8) function code(x)
real(8), intent (in) :: x
code = x
end function
public static double code(double x) {
return x;
}
def code(x): return x
function code(x) return x end
function tmp = code(x) tmp = x; end
code[x_] := x
\begin{array}{l}
\\
x
\end{array}
Initial program 21.1%
Taylor expanded in x around 0 55.2%
(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 2024107
(FPCore (x)
:name "Hyperbolic arcsine"
:precision binary64
:alt
(if (< x 0.0) (log (/ -1.0 (- x (sqrt (+ (* x x) 1.0))))) (log (+ x (sqrt (+ (* x x) 1.0)))))
(log (+ x (sqrt (+ (* x x) 1.0)))))