
(FPCore (x) :precision binary64 (acosh x))
double code(double x) {
return acosh(x);
}
def code(x): return math.acosh(x)
function code(x) return acosh(x) end
function tmp = code(x) tmp = acosh(x); end
code[x_] := N[ArcCosh[x], $MachinePrecision]
\cosh^{-1} x
Herbie found 3 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)
use fmin_fmax_functions
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]
\log \left(x + \sqrt{x \cdot x - 1}\right)
(FPCore (x) :precision binary64 (if (<= x 12000000000000.0) (* 0.0 1.0) (log (+ x x))))
double code(double x) {
double tmp;
if (x <= 12000000000000.0) {
tmp = 0.0 * 1.0;
} else {
tmp = log((x + x));
}
return tmp;
}
real(8) function code(x)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8) :: tmp
if (x <= 12000000000000.0d0) then
tmp = 0.0d0 * 1.0d0
else
tmp = log((x + x))
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (x <= 12000000000000.0) {
tmp = 0.0 * 1.0;
} else {
tmp = Math.log((x + x));
}
return tmp;
}
def code(x): tmp = 0 if x <= 12000000000000.0: tmp = 0.0 * 1.0 else: tmp = math.log((x + x)) return tmp
function code(x) tmp = 0.0 if (x <= 12000000000000.0) tmp = Float64(0.0 * 1.0); else tmp = log(Float64(x + x)); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= 12000000000000.0) tmp = 0.0 * 1.0; else tmp = log((x + x)); end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, 12000000000000.0], N[(0.0 * 1.0), $MachinePrecision], N[Log[N[(x + x), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\mathbf{if}\;x \leq 12000000000000:\\
\;\;\;\;0 \cdot 1\\
\mathbf{else}:\\
\;\;\;\;\log \left(x + x\right)\\
\end{array}
if x < 1.2e13Initial program 13.2%
lift-sqrt.f64N/A
lift--.f64N/A
lift-*.f64N/A
difference-of-sqr-1N/A
sqrt-prodN/A
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
fabs-subN/A
lower-fabs.f64N/A
lower--.f64N/A
lower-sqrt.f64N/A
add-flipN/A
fabs-subN/A
lower-fabs.f64N/A
lower--.f64N/A
metadata-eval73.1%
Applied rewrites73.1%
Taylor expanded in x around 0
lower-*.f64N/A
lower-+.f64N/A
lower-*.f643.4%
Applied rewrites3.4%
Taylor expanded in undef-var around zero
Applied rewrites76.1%
Taylor expanded in undef-var around zero
Applied rewrites76.1%
Taylor expanded in x around 0
Applied rewrites76.1%
if 1.2e13 < x Initial program 13.2%
Taylor expanded in x around -inf
lower-*.f641.3%
Applied rewrites1.3%
Taylor expanded in x around inf
lower-*.f6425.3%
Applied rewrites25.3%
lift-*.f64N/A
count-2-revN/A
lower-+.f6425.3%
Applied rewrites25.3%
(FPCore (x) :precision binary64 (if (<= x 12000000000000.0) (* 0.0 1.0) (acosh x)))
double code(double x) {
double tmp;
if (x <= 12000000000000.0) {
tmp = 0.0 * 1.0;
} else {
tmp = acosh(x);
}
return tmp;
}
def code(x): tmp = 0 if x <= 12000000000000.0: tmp = 0.0 * 1.0 else: tmp = math.acosh(x) return tmp
function code(x) tmp = 0.0 if (x <= 12000000000000.0) tmp = Float64(0.0 * 1.0); else tmp = acosh(x); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= 12000000000000.0) tmp = 0.0 * 1.0; else tmp = acosh(x); end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, 12000000000000.0], N[(0.0 * 1.0), $MachinePrecision], N[ArcCosh[x], $MachinePrecision]]
\begin{array}{l}
\mathbf{if}\;x \leq 12000000000000:\\
\;\;\;\;0 \cdot 1\\
\mathbf{else}:\\
\;\;\;\;\cosh^{-1} x\\
\end{array}
if x < 1.2e13Initial program 13.2%
lift-sqrt.f64N/A
lift--.f64N/A
lift-*.f64N/A
difference-of-sqr-1N/A
sqrt-prodN/A
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
fabs-subN/A
lower-fabs.f64N/A
lower--.f64N/A
lower-sqrt.f64N/A
add-flipN/A
fabs-subN/A
lower-fabs.f64N/A
lower--.f64N/A
metadata-eval73.1%
Applied rewrites73.1%
Taylor expanded in x around 0
lower-*.f64N/A
lower-+.f64N/A
lower-*.f643.4%
Applied rewrites3.4%
Taylor expanded in undef-var around zero
Applied rewrites76.1%
Taylor expanded in undef-var around zero
Applied rewrites76.1%
Taylor expanded in x around 0
Applied rewrites76.1%
if 1.2e13 < x Initial program 13.2%
lift-log.f64N/A
lift-+.f64N/A
lift-sqrt.f64N/A
lift--.f64N/A
lift-*.f64N/A
acosh-def-revN/A
lower-acosh.f6424.6%
Applied rewrites24.6%
(FPCore (x) :precision binary64 (* 0.0 1.0))
double code(double x) {
return 0.0 * 1.0;
}
real(8) function code(x)
use fmin_fmax_functions
real(8), intent (in) :: x
code = 0.0d0 * 1.0d0
end function
public static double code(double x) {
return 0.0 * 1.0;
}
def code(x): return 0.0 * 1.0
function code(x) return Float64(0.0 * 1.0) end
function tmp = code(x) tmp = 0.0 * 1.0; end
code[x_] := N[(0.0 * 1.0), $MachinePrecision]
0 \cdot 1
Initial program 13.2%
lift-sqrt.f64N/A
lift--.f64N/A
lift-*.f64N/A
difference-of-sqr-1N/A
sqrt-prodN/A
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
fabs-subN/A
lower-fabs.f64N/A
lower--.f64N/A
lower-sqrt.f64N/A
add-flipN/A
fabs-subN/A
lower-fabs.f64N/A
lower--.f64N/A
metadata-eval73.1%
Applied rewrites73.1%
Taylor expanded in x around 0
lower-*.f64N/A
lower-+.f64N/A
lower-*.f643.4%
Applied rewrites3.4%
Taylor expanded in undef-var around zero
Applied rewrites76.1%
Taylor expanded in undef-var around zero
Applied rewrites76.1%
Taylor expanded in x around 0
Applied rewrites76.1%
(FPCore (x) :precision binary64 (log (+ x (* (sqrt (- x 1.0)) (sqrt (+ x 1.0))))))
double code(double x) {
return log((x + (sqrt((x - 1.0)) * sqrt((x + 1.0)))));
}
real(8) function code(x)
use fmin_fmax_functions
real(8), intent (in) :: x
code = log((x + (sqrt((x - 1.0d0)) * sqrt((x + 1.0d0)))))
end function
public static double code(double x) {
return Math.log((x + (Math.sqrt((x - 1.0)) * Math.sqrt((x + 1.0)))));
}
def code(x): return math.log((x + (math.sqrt((x - 1.0)) * math.sqrt((x + 1.0)))))
function code(x) return log(Float64(x + Float64(sqrt(Float64(x - 1.0)) * sqrt(Float64(x + 1.0))))) end
function tmp = code(x) tmp = log((x + (sqrt((x - 1.0)) * sqrt((x + 1.0))))); end
code[x_] := N[Log[N[(x + N[(N[Sqrt[N[(x - 1.0), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(x + 1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\log \left(x + \sqrt{x - 1} \cdot \sqrt{x + 1}\right)
herbie shell --seed 2025313 -o setup:search
(FPCore (x)
:name "Rust f64::acosh"
:precision binary64
:pre (>= x 1.0)
:alt
(! :herbie-platform c (log (+ x (* (sqrt (- x 1)) (sqrt (+ x 1))))))
(log (+ x (sqrt (- (* x x) 1.0)))))