
(FPCore (Ce) :precision binary64 :pre TRUE (let* ((t_0 (exp (* 2.0 Ce)))) (+ (* 0.5 t_0) (/ 0.5 t_0))))
double code(double Ce) {
double t_0 = exp((2.0 * Ce));
return (0.5 * t_0) + (0.5 / t_0);
}
real(8) function code(ce)
use fmin_fmax_functions
real(8), intent (in) :: ce
real(8) :: t_0
t_0 = exp((2.0d0 * ce))
code = (0.5d0 * t_0) + (0.5d0 / t_0)
end function
public static double code(double Ce) {
double t_0 = Math.exp((2.0 * Ce));
return (0.5 * t_0) + (0.5 / t_0);
}
def code(Ce): t_0 = math.exp((2.0 * Ce)) return (0.5 * t_0) + (0.5 / t_0)
function code(Ce) t_0 = exp(Float64(2.0 * Ce)) return Float64(Float64(0.5 * t_0) + Float64(0.5 / t_0)) end
function tmp = code(Ce) t_0 = exp((2.0 * Ce)); tmp = (0.5 * t_0) + (0.5 / t_0); end
code[Ce_] := Block[{t$95$0 = N[Exp[N[(2.0 * Ce), $MachinePrecision]], $MachinePrecision]}, N[(N[(0.5 * t$95$0), $MachinePrecision] + N[(0.5 / t$95$0), $MachinePrecision]), $MachinePrecision]]
f(Ce): Ce in [-inf, +inf] code: THEORY BEGIN f(Ce: real): real = LET t_0 = (exp(((2) * Ce))) IN ((5e-1) * t_0) + ((5e-1) / t_0) END code
\begin{array}{l}
t_0 := e^{2 \cdot Ce}\\
0.5 \cdot t\_0 + \frac{0.5}{t\_0}
\end{array}
Herbie found 6 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (Ce) :precision binary64 :pre TRUE (let* ((t_0 (exp (* 2.0 Ce)))) (+ (* 0.5 t_0) (/ 0.5 t_0))))
double code(double Ce) {
double t_0 = exp((2.0 * Ce));
return (0.5 * t_0) + (0.5 / t_0);
}
real(8) function code(ce)
use fmin_fmax_functions
real(8), intent (in) :: ce
real(8) :: t_0
t_0 = exp((2.0d0 * ce))
code = (0.5d0 * t_0) + (0.5d0 / t_0)
end function
public static double code(double Ce) {
double t_0 = Math.exp((2.0 * Ce));
return (0.5 * t_0) + (0.5 / t_0);
}
def code(Ce): t_0 = math.exp((2.0 * Ce)) return (0.5 * t_0) + (0.5 / t_0)
function code(Ce) t_0 = exp(Float64(2.0 * Ce)) return Float64(Float64(0.5 * t_0) + Float64(0.5 / t_0)) end
function tmp = code(Ce) t_0 = exp((2.0 * Ce)); tmp = (0.5 * t_0) + (0.5 / t_0); end
code[Ce_] := Block[{t$95$0 = N[Exp[N[(2.0 * Ce), $MachinePrecision]], $MachinePrecision]}, N[(N[(0.5 * t$95$0), $MachinePrecision] + N[(0.5 / t$95$0), $MachinePrecision]), $MachinePrecision]]
f(Ce): Ce in [-inf, +inf] code: THEORY BEGIN f(Ce: real): real = LET t_0 = (exp(((2) * Ce))) IN ((5e-1) * t_0) + ((5e-1) / t_0) END code
\begin{array}{l}
t_0 := e^{2 \cdot Ce}\\
0.5 \cdot t\_0 + \frac{0.5}{t\_0}
\end{array}
(FPCore (Ce) :precision binary64 :pre TRUE (cosh (+ Ce Ce)))
double code(double Ce) {
return cosh((Ce + Ce));
}
real(8) function code(ce)
use fmin_fmax_functions
real(8), intent (in) :: ce
code = cosh((ce + ce))
end function
public static double code(double Ce) {
return Math.cosh((Ce + Ce));
}
def code(Ce): return math.cosh((Ce + Ce))
function code(Ce) return cosh(Float64(Ce + Ce)) end
function tmp = code(Ce) tmp = cosh((Ce + Ce)); end
code[Ce_] := N[Cosh[N[(Ce + Ce), $MachinePrecision]], $MachinePrecision]
f(Ce): Ce in [-inf, +inf] code: THEORY BEGIN f(Ce: real): real = ((1) / (2)) * ((exp((Ce + Ce))) + ((1) / (exp((Ce + Ce))))) END code
\cosh \left(Ce + Ce\right)
Initial program 100.0%
Applied rewrites100.0%
(FPCore (Ce) :precision binary64 :pre TRUE (+ (fma (- (fabs Ce) -1.0) (fabs Ce) 0.5) (/ 0.5 1.0)))
double code(double Ce) {
return fma((fabs(Ce) - -1.0), fabs(Ce), 0.5) + (0.5 / 1.0);
}
function code(Ce) return Float64(fma(Float64(abs(Ce) - -1.0), abs(Ce), 0.5) + Float64(0.5 / 1.0)) end
code[Ce_] := N[(N[(N[(N[Abs[Ce], $MachinePrecision] - -1.0), $MachinePrecision] * N[Abs[Ce], $MachinePrecision] + 0.5), $MachinePrecision] + N[(0.5 / 1.0), $MachinePrecision]), $MachinePrecision]
f(Ce): Ce in [-inf, +inf] code: THEORY BEGIN f(Ce: real): real = ((((abs(Ce)) - (-1)) * (abs(Ce))) + (5e-1)) + ((5e-1) / (1)) END code
\mathsf{fma}\left(\left|Ce\right| - -1, \left|Ce\right|, 0.5\right) + \frac{0.5}{1}
Initial program 100.0%
Taylor expanded in Ce around 0
Applied rewrites67.1%
Taylor expanded in Ce around 0
Applied rewrites82.7%
Applied rewrites82.7%
(FPCore (Ce) :precision binary64 :pre TRUE (+ (* 0.5 1.0) (fma (- Ce 1.0) Ce 0.5)))
double code(double Ce) {
return (0.5 * 1.0) + fma((Ce - 1.0), Ce, 0.5);
}
function code(Ce) return Float64(Float64(0.5 * 1.0) + fma(Float64(Ce - 1.0), Ce, 0.5)) end
code[Ce_] := N[(N[(0.5 * 1.0), $MachinePrecision] + N[(N[(Ce - 1.0), $MachinePrecision] * Ce + 0.5), $MachinePrecision]), $MachinePrecision]
f(Ce): Ce in [-inf, +inf] code: THEORY BEGIN f(Ce: real): real = ((5e-1) * (1)) + (((Ce - (1)) * Ce) + (5e-1)) END code
0.5 \cdot 1 + \mathsf{fma}\left(Ce - 1, Ce, 0.5\right)
Initial program 100.0%
Taylor expanded in Ce around 0
Applied rewrites67.1%
Taylor expanded in Ce around 0
Applied rewrites82.7%
Applied rewrites82.7%
(FPCore (Ce) :precision binary64 :pre TRUE (+ (* 0.5 1.0) (- (fma Ce Ce 0.5) Ce)))
double code(double Ce) {
return (0.5 * 1.0) + (fma(Ce, Ce, 0.5) - Ce);
}
function code(Ce) return Float64(Float64(0.5 * 1.0) + Float64(fma(Ce, Ce, 0.5) - Ce)) end
code[Ce_] := N[(N[(0.5 * 1.0), $MachinePrecision] + N[(N[(Ce * Ce + 0.5), $MachinePrecision] - Ce), $MachinePrecision]), $MachinePrecision]
f(Ce): Ce in [-inf, +inf] code: THEORY BEGIN f(Ce: real): real = ((5e-1) * (1)) + (((Ce * Ce) + (5e-1)) - Ce) END code
0.5 \cdot 1 + \left(\mathsf{fma}\left(Ce, Ce, 0.5\right) - Ce\right)
Initial program 100.0%
Taylor expanded in Ce around 0
Applied rewrites67.1%
Taylor expanded in Ce around 0
Applied rewrites82.7%
Applied rewrites82.7%
(FPCore (Ce) :precision binary64 :pre TRUE (+ (+ 0.5 (fabs Ce)) (/ 0.5 1.0)))
double code(double Ce) {
return (0.5 + fabs(Ce)) + (0.5 / 1.0);
}
real(8) function code(ce)
use fmin_fmax_functions
real(8), intent (in) :: ce
code = (0.5d0 + abs(ce)) + (0.5d0 / 1.0d0)
end function
public static double code(double Ce) {
return (0.5 + Math.abs(Ce)) + (0.5 / 1.0);
}
def code(Ce): return (0.5 + math.fabs(Ce)) + (0.5 / 1.0)
function code(Ce) return Float64(Float64(0.5 + abs(Ce)) + Float64(0.5 / 1.0)) end
function tmp = code(Ce) tmp = (0.5 + abs(Ce)) + (0.5 / 1.0); end
code[Ce_] := N[(N[(0.5 + N[Abs[Ce], $MachinePrecision]), $MachinePrecision] + N[(0.5 / 1.0), $MachinePrecision]), $MachinePrecision]
f(Ce): Ce in [-inf, +inf] code: THEORY BEGIN f(Ce: real): real = ((5e-1) + (abs(Ce))) + ((5e-1) / (1)) END code
\left(0.5 + \left|Ce\right|\right) + \frac{0.5}{1}
Initial program 100.0%
Taylor expanded in Ce around 0
Applied rewrites67.1%
Taylor expanded in Ce around 0
Applied rewrites67.0%
(FPCore (Ce) :precision binary64 :pre TRUE (+ 0.5 (/ 0.5 1.0)))
double code(double Ce) {
return 0.5 + (0.5 / 1.0);
}
real(8) function code(ce)
use fmin_fmax_functions
real(8), intent (in) :: ce
code = 0.5d0 + (0.5d0 / 1.0d0)
end function
public static double code(double Ce) {
return 0.5 + (0.5 / 1.0);
}
def code(Ce): return 0.5 + (0.5 / 1.0)
function code(Ce) return Float64(0.5 + Float64(0.5 / 1.0)) end
function tmp = code(Ce) tmp = 0.5 + (0.5 / 1.0); end
code[Ce_] := N[(0.5 + N[(0.5 / 1.0), $MachinePrecision]), $MachinePrecision]
f(Ce): Ce in [-inf, +inf] code: THEORY BEGIN f(Ce: real): real = (5e-1) + ((5e-1) / (1)) END code
0.5 + \frac{0.5}{1}
Initial program 100.0%
Taylor expanded in Ce around 0
Applied rewrites67.1%
Taylor expanded in Ce around 0
Applied rewrites67.1%
herbie shell --seed 2026050 +o generate:egglog
(FPCore (Ce)
:name "exact-inv-cosh-arg"
:precision binary64
(+ (* 0.5 (exp (* 2.0 Ce))) (/ 0.5 (exp (* 2.0 Ce)))))