
(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.00086)
(- (log (- (hypot 1.0 x) x)))
(if (<= x 0.00094)
(* x (+ 1.0 (* -0.16666666666666666 (* x x))))
(log (+ x (hypot 1.0 x))))))
double code(double x) {
double tmp;
if (x <= -0.00086) {
tmp = -log((hypot(1.0, x) - x));
} else if (x <= 0.00094) {
tmp = x * (1.0 + (-0.16666666666666666 * (x * x)));
} else {
tmp = log((x + hypot(1.0, x)));
}
return tmp;
}
public static double code(double x) {
double tmp;
if (x <= -0.00086) {
tmp = -Math.log((Math.hypot(1.0, x) - x));
} else if (x <= 0.00094) {
tmp = x * (1.0 + (-0.16666666666666666 * (x * x)));
} else {
tmp = Math.log((x + Math.hypot(1.0, x)));
}
return tmp;
}
def code(x): tmp = 0 if x <= -0.00086: tmp = -math.log((math.hypot(1.0, x) - x)) elif x <= 0.00094: tmp = x * (1.0 + (-0.16666666666666666 * (x * x))) else: tmp = math.log((x + math.hypot(1.0, x))) return tmp
function code(x) tmp = 0.0 if (x <= -0.00086) tmp = Float64(-log(Float64(hypot(1.0, x) - x))); elseif (x <= 0.00094) tmp = Float64(x * Float64(1.0 + Float64(-0.16666666666666666 * Float64(x * x)))); else tmp = log(Float64(x + hypot(1.0, x))); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= -0.00086) tmp = -log((hypot(1.0, x) - x)); elseif (x <= 0.00094) tmp = x * (1.0 + (-0.16666666666666666 * (x * x))); else tmp = log((x + hypot(1.0, x))); end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, -0.00086], (-N[Log[N[(N[Sqrt[1.0 ^ 2 + x ^ 2], $MachinePrecision] - x), $MachinePrecision]], $MachinePrecision]), If[LessEqual[x, 0.00094], N[(x * N[(1.0 + N[(-0.16666666666666666 * N[(x * x), $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 -0.00086:\\
\;\;\;\;-\log \left(\mathsf{hypot}\left(1, x\right) - x\right)\\
\mathbf{elif}\;x \leq 0.00094:\\
\;\;\;\;x \cdot \left(1 + -0.16666666666666666 \cdot \left(x \cdot x\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\log \left(x + \mathsf{hypot}\left(1, x\right)\right)\\
\end{array}
\end{array}
if x < -8.59999999999999979e-4Initial program 5.1%
sqr-neg5.1%
+-commutative5.1%
sqr-neg5.1%
hypot-1-def6.2%
Simplified6.2%
flip-+4.8%
frac-2neg4.8%
log-div4.8%
pow24.8%
hypot-1-def4.8%
hypot-1-def4.8%
add-sqr-sqrt5.4%
+-commutative5.4%
fma-define5.4%
Applied egg-rr5.4%
fma-undefine5.4%
unpow25.4%
associate--r+59.3%
+-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.59999999999999979e-4 < x < 9.39999999999999972e-4Initial program 7.9%
sqr-neg7.9%
+-commutative7.9%
sqr-neg7.9%
hypot-1-def7.9%
Simplified7.9%
Taylor expanded in x around 0 100.0%
unpow2100.0%
Applied egg-rr100.0%
if 9.39999999999999972e-4 < x Initial program 52.3%
sqr-neg52.3%
+-commutative52.3%
sqr-neg52.3%
hypot-1-def100.0%
Simplified100.0%
(FPCore (x)
:precision binary64
(if (<= x -1.26)
(log (/ -0.5 x))
(if (<= x 0.00094)
(* x (+ 1.0 (* -0.16666666666666666 (* x x))))
(log (+ x (hypot 1.0 x))))))
double code(double x) {
double tmp;
if (x <= -1.26) {
tmp = log((-0.5 / x));
} else if (x <= 0.00094) {
tmp = x * (1.0 + (-0.16666666666666666 * (x * x)));
} else {
tmp = log((x + hypot(1.0, x)));
}
return tmp;
}
public static double code(double x) {
double tmp;
if (x <= -1.26) {
tmp = Math.log((-0.5 / x));
} else if (x <= 0.00094) {
tmp = x * (1.0 + (-0.16666666666666666 * (x * x)));
} else {
tmp = Math.log((x + Math.hypot(1.0, x)));
}
return tmp;
}
def code(x): tmp = 0 if x <= -1.26: tmp = math.log((-0.5 / x)) elif x <= 0.00094: tmp = x * (1.0 + (-0.16666666666666666 * (x * x))) else: tmp = math.log((x + math.hypot(1.0, x))) return tmp
function code(x) tmp = 0.0 if (x <= -1.26) tmp = log(Float64(-0.5 / x)); elseif (x <= 0.00094) tmp = Float64(x * Float64(1.0 + Float64(-0.16666666666666666 * Float64(x * x)))); else tmp = log(Float64(x + hypot(1.0, x))); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= -1.26) tmp = log((-0.5 / x)); elseif (x <= 0.00094) tmp = x * (1.0 + (-0.16666666666666666 * (x * x))); else tmp = log((x + hypot(1.0, x))); end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, -1.26], N[Log[N[(-0.5 / x), $MachinePrecision]], $MachinePrecision], If[LessEqual[x, 0.00094], N[(x * N[(1.0 + N[(-0.16666666666666666 * N[(x * x), $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 -1.26:\\
\;\;\;\;\log \left(\frac{-0.5}{x}\right)\\
\mathbf{elif}\;x \leq 0.00094:\\
\;\;\;\;x \cdot \left(1 + -0.16666666666666666 \cdot \left(x \cdot x\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\log \left(x + \mathsf{hypot}\left(1, x\right)\right)\\
\end{array}
\end{array}
if x < -1.26000000000000001Initial program 3.4%
sqr-neg3.4%
+-commutative3.4%
sqr-neg3.4%
hypot-1-def4.4%
Simplified4.4%
Taylor expanded in x around -inf 99.3%
if -1.26000000000000001 < x < 9.39999999999999972e-4Initial program 8.6%
sqr-neg8.6%
+-commutative8.6%
sqr-neg8.6%
hypot-1-def8.6%
Simplified8.6%
Taylor expanded in x around 0 99.5%
unpow299.5%
Applied egg-rr99.5%
if 9.39999999999999972e-4 < x Initial program 52.3%
sqr-neg52.3%
+-commutative52.3%
sqr-neg52.3%
hypot-1-def100.0%
Simplified100.0%
(FPCore (x)
:precision binary64
(if (<= x -1.26)
(log (/ -0.5 x))
(if (<= x 1.25)
(* x (+ 1.0 (* -0.16666666666666666 (* x x))))
(- (log (/ 0.5 x))))))
double code(double x) {
double tmp;
if (x <= -1.26) {
tmp = log((-0.5 / x));
} else if (x <= 1.25) {
tmp = x * (1.0 + (-0.16666666666666666 * (x * 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.26d0)) then
tmp = log(((-0.5d0) / x))
else if (x <= 1.25d0) then
tmp = x * (1.0d0 + ((-0.16666666666666666d0) * (x * x)))
else
tmp = -log((0.5d0 / x))
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (x <= -1.26) {
tmp = Math.log((-0.5 / x));
} else if (x <= 1.25) {
tmp = x * (1.0 + (-0.16666666666666666 * (x * x)));
} else {
tmp = -Math.log((0.5 / x));
}
return tmp;
}
def code(x): tmp = 0 if x <= -1.26: tmp = math.log((-0.5 / x)) elif x <= 1.25: tmp = x * (1.0 + (-0.16666666666666666 * (x * x))) else: tmp = -math.log((0.5 / x)) return tmp
function code(x) tmp = 0.0 if (x <= -1.26) tmp = log(Float64(-0.5 / x)); elseif (x <= 1.25) tmp = Float64(x * Float64(1.0 + Float64(-0.16666666666666666 * Float64(x * x)))); else tmp = Float64(-log(Float64(0.5 / x))); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= -1.26) tmp = log((-0.5 / x)); elseif (x <= 1.25) tmp = x * (1.0 + (-0.16666666666666666 * (x * x))); else tmp = -log((0.5 / x)); end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, -1.26], N[Log[N[(-0.5 / x), $MachinePrecision]], $MachinePrecision], If[LessEqual[x, 1.25], N[(x * N[(1.0 + N[(-0.16666666666666666 * N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], (-N[Log[N[(0.5 / x), $MachinePrecision]], $MachinePrecision])]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.26:\\
\;\;\;\;\log \left(\frac{-0.5}{x}\right)\\
\mathbf{elif}\;x \leq 1.25:\\
\;\;\;\;x \cdot \left(1 + -0.16666666666666666 \cdot \left(x \cdot x\right)\right)\\
\mathbf{else}:\\
\;\;\;\;-\log \left(\frac{0.5}{x}\right)\\
\end{array}
\end{array}
if x < -1.26000000000000001Initial program 3.4%
sqr-neg3.4%
+-commutative3.4%
sqr-neg3.4%
hypot-1-def4.4%
Simplified4.4%
Taylor expanded in x around -inf 99.3%
if -1.26000000000000001 < x < 1.25Initial program 8.6%
sqr-neg8.6%
+-commutative8.6%
sqr-neg8.6%
hypot-1-def8.6%
Simplified8.6%
Taylor expanded in x around 0 99.5%
unpow299.5%
Applied egg-rr99.5%
if 1.25 < x Initial program 52.3%
sqr-neg52.3%
+-commutative52.3%
sqr-neg52.3%
hypot-1-def100.0%
Simplified100.0%
flip-+1.8%
frac-2neg1.8%
log-div1.8%
pow21.8%
hypot-1-def1.8%
hypot-1-def1.8%
add-sqr-sqrt1.9%
+-commutative1.9%
fma-define1.9%
Applied egg-rr1.9%
fma-undefine1.9%
unpow21.9%
associate--r+3.4%
+-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.2%
(FPCore (x)
:precision binary64
(if (<= x -1.26)
(log (/ -0.5 x))
(if (<= x 1.25)
(* x (+ 1.0 (* -0.16666666666666666 (* x x))))
(log (* x 2.0)))))
double code(double x) {
double tmp;
if (x <= -1.26) {
tmp = log((-0.5 / x));
} else if (x <= 1.25) {
tmp = x * (1.0 + (-0.16666666666666666 * (x * 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.26d0)) then
tmp = log(((-0.5d0) / x))
else if (x <= 1.25d0) then
tmp = x * (1.0d0 + ((-0.16666666666666666d0) * (x * x)))
else
tmp = log((x * 2.0d0))
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (x <= -1.26) {
tmp = Math.log((-0.5 / x));
} else if (x <= 1.25) {
tmp = x * (1.0 + (-0.16666666666666666 * (x * x)));
} else {
tmp = Math.log((x * 2.0));
}
return tmp;
}
def code(x): tmp = 0 if x <= -1.26: tmp = math.log((-0.5 / x)) elif x <= 1.25: tmp = x * (1.0 + (-0.16666666666666666 * (x * x))) else: tmp = math.log((x * 2.0)) return tmp
function code(x) tmp = 0.0 if (x <= -1.26) tmp = log(Float64(-0.5 / x)); elseif (x <= 1.25) tmp = Float64(x * Float64(1.0 + Float64(-0.16666666666666666 * Float64(x * x)))); else tmp = log(Float64(x * 2.0)); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= -1.26) tmp = log((-0.5 / x)); elseif (x <= 1.25) tmp = x * (1.0 + (-0.16666666666666666 * (x * x))); else tmp = log((x * 2.0)); end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, -1.26], N[Log[N[(-0.5 / x), $MachinePrecision]], $MachinePrecision], If[LessEqual[x, 1.25], N[(x * N[(1.0 + N[(-0.16666666666666666 * N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Log[N[(x * 2.0), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.26:\\
\;\;\;\;\log \left(\frac{-0.5}{x}\right)\\
\mathbf{elif}\;x \leq 1.25:\\
\;\;\;\;x \cdot \left(1 + -0.16666666666666666 \cdot \left(x \cdot x\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\log \left(x \cdot 2\right)\\
\end{array}
\end{array}
if x < -1.26000000000000001Initial program 3.4%
sqr-neg3.4%
+-commutative3.4%
sqr-neg3.4%
hypot-1-def4.4%
Simplified4.4%
Taylor expanded in x around -inf 99.3%
if -1.26000000000000001 < x < 1.25Initial program 8.6%
sqr-neg8.6%
+-commutative8.6%
sqr-neg8.6%
hypot-1-def8.6%
Simplified8.6%
Taylor expanded in x around 0 99.5%
unpow299.5%
Applied egg-rr99.5%
if 1.25 < x Initial program 52.3%
sqr-neg52.3%
+-commutative52.3%
sqr-neg52.3%
hypot-1-def100.0%
Simplified100.0%
Taylor expanded in x around inf 99.2%
*-commutative99.2%
Simplified99.2%
(FPCore (x)
:precision binary64
(if (<= x -2.3)
-8.0
(if (<= x 1.25)
(* x (+ 1.0 (* -0.16666666666666666 (* x x))))
(log (* x 2.0)))))
double code(double x) {
double tmp;
if (x <= -2.3) {
tmp = -8.0;
} else if (x <= 1.25) {
tmp = x * (1.0 + (-0.16666666666666666 * (x * x)));
} else {
tmp = log((x * 2.0));
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (x <= (-2.3d0)) then
tmp = -8.0d0
else if (x <= 1.25d0) then
tmp = x * (1.0d0 + ((-0.16666666666666666d0) * (x * x)))
else
tmp = log((x * 2.0d0))
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (x <= -2.3) {
tmp = -8.0;
} else if (x <= 1.25) {
tmp = x * (1.0 + (-0.16666666666666666 * (x * x)));
} else {
tmp = Math.log((x * 2.0));
}
return tmp;
}
def code(x): tmp = 0 if x <= -2.3: tmp = -8.0 elif x <= 1.25: tmp = x * (1.0 + (-0.16666666666666666 * (x * x))) else: tmp = math.log((x * 2.0)) return tmp
function code(x) tmp = 0.0 if (x <= -2.3) tmp = -8.0; elseif (x <= 1.25) tmp = Float64(x * Float64(1.0 + Float64(-0.16666666666666666 * Float64(x * x)))); else tmp = log(Float64(x * 2.0)); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= -2.3) tmp = -8.0; elseif (x <= 1.25) tmp = x * (1.0 + (-0.16666666666666666 * (x * x))); else tmp = log((x * 2.0)); end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, -2.3], -8.0, If[LessEqual[x, 1.25], N[(x * N[(1.0 + N[(-0.16666666666666666 * N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Log[N[(x * 2.0), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.3:\\
\;\;\;\;-8\\
\mathbf{elif}\;x \leq 1.25:\\
\;\;\;\;x \cdot \left(1 + -0.16666666666666666 \cdot \left(x \cdot x\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\log \left(x \cdot 2\right)\\
\end{array}
\end{array}
if x < -2.2999999999999998Initial program 3.4%
sqr-neg3.4%
+-commutative3.4%
sqr-neg3.4%
hypot-1-def4.4%
Simplified4.4%
flip-+3.1%
frac-2neg3.1%
log-div3.1%
pow23.1%
hypot-1-def3.1%
hypot-1-def3.1%
add-sqr-sqrt3.7%
+-commutative3.7%
fma-define3.7%
Applied egg-rr3.7%
fma-undefine3.7%
unpow23.7%
associate--r+58.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 -2.2999999999999998 < x < 1.25Initial program 8.6%
sqr-neg8.6%
+-commutative8.6%
sqr-neg8.6%
hypot-1-def8.6%
Simplified8.6%
Taylor expanded in x around 0 99.5%
unpow299.5%
Applied egg-rr99.5%
if 1.25 < x Initial program 52.3%
sqr-neg52.3%
+-commutative52.3%
sqr-neg52.3%
hypot-1-def100.0%
Simplified100.0%
Taylor expanded in x around inf 99.2%
*-commutative99.2%
Simplified99.2%
(FPCore (x) :precision binary64 (if (<= x -2.3) -8.0 (if (<= x 2.35) (* x (+ 1.0 (* -0.16666666666666666 (* x x)))) 9.0)))
double code(double x) {
double tmp;
if (x <= -2.3) {
tmp = -8.0;
} else if (x <= 2.35) {
tmp = x * (1.0 + (-0.16666666666666666 * (x * x)));
} else {
tmp = 9.0;
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (x <= (-2.3d0)) then
tmp = -8.0d0
else if (x <= 2.35d0) then
tmp = x * (1.0d0 + ((-0.16666666666666666d0) * (x * x)))
else
tmp = 9.0d0
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (x <= -2.3) {
tmp = -8.0;
} else if (x <= 2.35) {
tmp = x * (1.0 + (-0.16666666666666666 * (x * x)));
} else {
tmp = 9.0;
}
return tmp;
}
def code(x): tmp = 0 if x <= -2.3: tmp = -8.0 elif x <= 2.35: tmp = x * (1.0 + (-0.16666666666666666 * (x * x))) else: tmp = 9.0 return tmp
function code(x) tmp = 0.0 if (x <= -2.3) tmp = -8.0; elseif (x <= 2.35) tmp = Float64(x * Float64(1.0 + Float64(-0.16666666666666666 * Float64(x * x)))); else tmp = 9.0; end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= -2.3) tmp = -8.0; elseif (x <= 2.35) tmp = x * (1.0 + (-0.16666666666666666 * (x * x))); else tmp = 9.0; end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, -2.3], -8.0, If[LessEqual[x, 2.35], N[(x * N[(1.0 + N[(-0.16666666666666666 * N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 9.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.3:\\
\;\;\;\;-8\\
\mathbf{elif}\;x \leq 2.35:\\
\;\;\;\;x \cdot \left(1 + -0.16666666666666666 \cdot \left(x \cdot x\right)\right)\\
\mathbf{else}:\\
\;\;\;\;9\\
\end{array}
\end{array}
if x < -2.2999999999999998Initial program 3.4%
sqr-neg3.4%
+-commutative3.4%
sqr-neg3.4%
hypot-1-def4.4%
Simplified4.4%
flip-+3.1%
frac-2neg3.1%
log-div3.1%
pow23.1%
hypot-1-def3.1%
hypot-1-def3.1%
add-sqr-sqrt3.7%
+-commutative3.7%
fma-define3.7%
Applied egg-rr3.7%
fma-undefine3.7%
unpow23.7%
associate--r+58.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 -2.2999999999999998 < x < 2.35000000000000009Initial program 8.6%
sqr-neg8.6%
+-commutative8.6%
sqr-neg8.6%
hypot-1-def8.6%
Simplified8.6%
Taylor expanded in x around 0 99.5%
unpow299.5%
Applied egg-rr99.5%
if 2.35000000000000009 < x Initial program 52.3%
sqr-neg52.3%
+-commutative52.3%
sqr-neg52.3%
hypot-1-def100.0%
Simplified100.0%
flip-+1.8%
frac-2neg1.8%
log-div1.8%
pow21.8%
hypot-1-def1.8%
hypot-1-def1.8%
add-sqr-sqrt1.9%
+-commutative1.9%
fma-define1.9%
Applied egg-rr1.9%
fma-undefine1.9%
unpow21.9%
associate--r+3.4%
+-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.2%
Applied egg-rr15.3%
(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 3.4%
sqr-neg3.4%
+-commutative3.4%
sqr-neg3.4%
hypot-1-def4.4%
Simplified4.4%
flip-+3.1%
frac-2neg3.1%
log-div3.1%
pow23.1%
hypot-1-def3.1%
hypot-1-def3.1%
add-sqr-sqrt3.7%
+-commutative3.7%
fma-define3.7%
Applied egg-rr3.7%
fma-undefine3.7%
unpow23.7%
associate--r+58.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 8.6%
sqr-neg8.6%
+-commutative8.6%
sqr-neg8.6%
hypot-1-def8.6%
Simplified8.6%
Taylor expanded in x around 0 98.9%
if 9 < x Initial program 52.3%
sqr-neg52.3%
+-commutative52.3%
sqr-neg52.3%
hypot-1-def100.0%
Simplified100.0%
flip-+1.8%
frac-2neg1.8%
log-div1.8%
pow21.8%
hypot-1-def1.8%
hypot-1-def1.8%
add-sqr-sqrt1.9%
+-commutative1.9%
fma-define1.9%
Applied egg-rr1.9%
fma-undefine1.9%
unpow21.9%
associate--r+3.4%
+-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.2%
Applied egg-rr15.3%
(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 7.0%
sqr-neg7.0%
+-commutative7.0%
sqr-neg7.0%
hypot-1-def7.5%
Simplified7.5%
flip-+6.8%
frac-2neg6.8%
log-div6.8%
pow26.8%
hypot-1-def6.8%
hypot-1-def6.8%
add-sqr-sqrt7.0%
+-commutative7.0%
fma-define7.0%
Applied egg-rr7.0%
fma-undefine7.0%
unpow27.0%
associate--r+31.9%
+-inverses50.7%
metadata-eval50.7%
metadata-eval50.7%
metadata-eval50.7%
neg-sub050.7%
neg-sub050.7%
associate--r-50.7%
neg-sub050.7%
+-commutative50.7%
sub-neg50.7%
Simplified50.7%
Taylor expanded in x around inf 0.0%
Applied egg-rr9.9%
if 1.000000000000002e-309 < x Initial program 28.4%
sqr-neg28.4%
+-commutative28.4%
sqr-neg28.4%
hypot-1-def50.7%
Simplified50.7%
flip-+4.8%
frac-2neg4.8%
log-div4.8%
pow24.8%
hypot-1-def4.8%
hypot-1-def4.8%
add-sqr-sqrt4.8%
+-commutative4.8%
fma-define4.8%
Applied egg-rr4.8%
fma-undefine4.8%
unpow24.8%
associate--r+5.5%
+-inverses6.2%
metadata-eval6.2%
metadata-eval6.2%
metadata-eval6.2%
neg-sub06.2%
neg-sub06.2%
associate--r-6.2%
neg-sub06.2%
+-commutative6.2%
sub-neg6.2%
Simplified6.2%
Taylor expanded in x around inf 47.6%
Applied egg-rr10.0%
(FPCore (x) :precision binary64 (if (<= x -6e-309) -8.0 6.0))
double code(double x) {
double tmp;
if (x <= -6e-309) {
tmp = -8.0;
} else {
tmp = 6.0;
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (x <= (-6d-309)) then
tmp = -8.0d0
else
tmp = 6.0d0
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (x <= -6e-309) {
tmp = -8.0;
} else {
tmp = 6.0;
}
return tmp;
}
def code(x): tmp = 0 if x <= -6e-309: tmp = -8.0 else: tmp = 6.0 return tmp
function code(x) tmp = 0.0 if (x <= -6e-309) tmp = -8.0; else tmp = 6.0; end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= -6e-309) tmp = -8.0; else tmp = 6.0; end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, -6e-309], -8.0, 6.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -6 \cdot 10^{-309}:\\
\;\;\;\;-8\\
\mathbf{else}:\\
\;\;\;\;6\\
\end{array}
\end{array}
if x < -6.000000000000001e-309Initial program 7.0%
sqr-neg7.0%
+-commutative7.0%
sqr-neg7.0%
hypot-1-def7.5%
Simplified7.5%
flip-+6.8%
frac-2neg6.8%
log-div6.8%
pow26.8%
hypot-1-def6.8%
hypot-1-def6.8%
add-sqr-sqrt7.0%
+-commutative7.0%
fma-define7.0%
Applied egg-rr7.0%
fma-undefine7.0%
unpow27.0%
associate--r+31.9%
+-inverses50.7%
metadata-eval50.7%
metadata-eval50.7%
metadata-eval50.7%
neg-sub050.7%
neg-sub050.7%
associate--r-50.7%
neg-sub050.7%
+-commutative50.7%
sub-neg50.7%
Simplified50.7%
Taylor expanded in x around inf 0.0%
Applied egg-rr9.9%
if -6.000000000000001e-309 < x Initial program 28.4%
sqr-neg28.4%
+-commutative28.4%
sqr-neg28.4%
hypot-1-def50.7%
Simplified50.7%
flip-+4.8%
frac-2neg4.8%
log-div4.8%
pow24.8%
hypot-1-def4.8%
hypot-1-def4.8%
add-sqr-sqrt4.8%
+-commutative4.8%
fma-define4.8%
Applied egg-rr4.8%
fma-undefine4.8%
unpow24.8%
associate--r+5.5%
+-inverses6.2%
metadata-eval6.2%
metadata-eval6.2%
metadata-eval6.2%
neg-sub06.2%
neg-sub06.2%
associate--r-6.2%
neg-sub06.2%
+-commutative6.2%
sub-neg6.2%
Simplified6.2%
Taylor expanded in x around inf 47.6%
Applied egg-rr9.9%
(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.6%
sqr-neg18.6%
+-commutative18.6%
sqr-neg18.6%
hypot-1-def30.9%
Simplified30.9%
flip-+5.7%
frac-2neg5.7%
log-div5.7%
pow25.7%
hypot-1-def5.7%
hypot-1-def5.7%
add-sqr-sqrt5.8%
+-commutative5.8%
fma-define5.8%
Applied egg-rr5.8%
fma-undefine5.8%
unpow25.8%
associate--r+17.6%
+-inverses26.5%
metadata-eval26.5%
metadata-eval26.5%
metadata-eval26.5%
neg-sub026.5%
neg-sub026.5%
associate--r-26.5%
neg-sub026.5%
+-commutative26.5%
sub-neg26.5%
Simplified26.5%
Taylor expanded in x around inf 25.8%
Applied egg-rr5.6%
(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 2024177
(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)))))