
(FPCore (Ce) :precision binary64 :pre TRUE (/ 0.5 (exp (* 2.0 Ce))))
double code(double Ce) {
return 0.5 / exp((2.0 * Ce));
}
real(8) function code(ce)
use fmin_fmax_functions
real(8), intent (in) :: ce
code = 0.5d0 / exp((2.0d0 * ce))
end function
public static double code(double Ce) {
return 0.5 / Math.exp((2.0 * Ce));
}
def code(Ce): return 0.5 / math.exp((2.0 * Ce))
function code(Ce) return Float64(0.5 / exp(Float64(2.0 * Ce))) end
function tmp = code(Ce) tmp = 0.5 / exp((2.0 * Ce)); end
code[Ce_] := N[(0.5 / N[Exp[N[(2.0 * Ce), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
f(Ce): Ce in [-inf, +inf] code: THEORY BEGIN f(Ce: real): real = (5e-1) / (exp(((2) * Ce))) END code
\frac{0.5}{e^{2 \cdot Ce}}
Herbie found 7 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (Ce) :precision binary64 :pre TRUE (/ 0.5 (exp (* 2.0 Ce))))
double code(double Ce) {
return 0.5 / exp((2.0 * Ce));
}
real(8) function code(ce)
use fmin_fmax_functions
real(8), intent (in) :: ce
code = 0.5d0 / exp((2.0d0 * ce))
end function
public static double code(double Ce) {
return 0.5 / Math.exp((2.0 * Ce));
}
def code(Ce): return 0.5 / math.exp((2.0 * Ce))
function code(Ce) return Float64(0.5 / exp(Float64(2.0 * Ce))) end
function tmp = code(Ce) tmp = 0.5 / exp((2.0 * Ce)); end
code[Ce_] := N[(0.5 / N[Exp[N[(2.0 * Ce), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
f(Ce): Ce in [-inf, +inf] code: THEORY BEGIN f(Ce: real): real = (5e-1) / (exp(((2) * Ce))) END code
\frac{0.5}{e^{2 \cdot Ce}}
(FPCore (Ce) :precision binary64 :pre TRUE (* (exp (* -2.0 Ce)) 0.5))
double code(double Ce) {
return exp((-2.0 * Ce)) * 0.5;
}
real(8) function code(ce)
use fmin_fmax_functions
real(8), intent (in) :: ce
code = exp(((-2.0d0) * ce)) * 0.5d0
end function
public static double code(double Ce) {
return Math.exp((-2.0 * Ce)) * 0.5;
}
def code(Ce): return math.exp((-2.0 * Ce)) * 0.5
function code(Ce) return Float64(exp(Float64(-2.0 * Ce)) * 0.5) end
function tmp = code(Ce) tmp = exp((-2.0 * Ce)) * 0.5; end
code[Ce_] := N[(N[Exp[N[(-2.0 * Ce), $MachinePrecision]], $MachinePrecision] * 0.5), $MachinePrecision]
f(Ce): Ce in [-inf, +inf] code: THEORY BEGIN f(Ce: real): real = (exp(((-2) * Ce))) * (5e-1) END code
e^{-2 \cdot Ce} \cdot 0.5
Initial program 100.0%
Applied rewrites100.0%
(FPCore (Ce) :precision binary64 :pre TRUE (if (<= (* 2.0 Ce) 0.2) (- (fma (fma -0.6666666666666666 Ce 1.0) (* Ce Ce) 0.5) Ce) 0.0))
double code(double Ce) {
double tmp;
if ((2.0 * Ce) <= 0.2) {
tmp = fma(fma(-0.6666666666666666, Ce, 1.0), (Ce * Ce), 0.5) - Ce;
} else {
tmp = 0.0;
}
return tmp;
}
function code(Ce) tmp = 0.0 if (Float64(2.0 * Ce) <= 0.2) tmp = Float64(fma(fma(-0.6666666666666666, Ce, 1.0), Float64(Ce * Ce), 0.5) - Ce); else tmp = 0.0; end return tmp end
code[Ce_] := If[LessEqual[N[(2.0 * Ce), $MachinePrecision], 0.2], N[(N[(N[(-0.6666666666666666 * Ce + 1.0), $MachinePrecision] * N[(Ce * Ce), $MachinePrecision] + 0.5), $MachinePrecision] - Ce), $MachinePrecision], 0.0]
f(Ce): Ce in [-inf, +inf] code: THEORY BEGIN f(Ce: real): real = LET tmp = IF (((2) * Ce) <= (200000000000000011102230246251565404236316680908203125e-54)) THEN ((((((-66666666666666662965923251249478198587894439697265625e-53) * Ce) + (1)) * (Ce * Ce)) + (5e-1)) - Ce) ELSE (0) ENDIF IN tmp END code
\begin{array}{l}
\mathbf{if}\;2 \cdot Ce \leq 0.2:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(-0.6666666666666666, Ce, 1\right), Ce \cdot Ce, 0.5\right) - Ce\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
if (*.f64 #s(literal 2 binary64) Ce) < 0.20000000000000001Initial program 100.0%
Taylor expanded in Ce around 0
Applied rewrites67.0%
Applied rewrites67.0%
if 0.20000000000000001 < (*.f64 #s(literal 2 binary64) Ce) Initial program 100.0%
Taylor expanded in Ce around 0
Applied rewrites66.2%
Taylor expanded in undef-var around zero
Applied rewrites34.3%
(FPCore (Ce) :precision binary64 :pre TRUE (if (<= (* 2.0 Ce) 0.2) (fma (fma (fma -0.6666666666666666 Ce 1.0) Ce -1.0) Ce 0.5) 0.0))
double code(double Ce) {
double tmp;
if ((2.0 * Ce) <= 0.2) {
tmp = fma(fma(fma(-0.6666666666666666, Ce, 1.0), Ce, -1.0), Ce, 0.5);
} else {
tmp = 0.0;
}
return tmp;
}
function code(Ce) tmp = 0.0 if (Float64(2.0 * Ce) <= 0.2) tmp = fma(fma(fma(-0.6666666666666666, Ce, 1.0), Ce, -1.0), Ce, 0.5); else tmp = 0.0; end return tmp end
code[Ce_] := If[LessEqual[N[(2.0 * Ce), $MachinePrecision], 0.2], N[(N[(N[(-0.6666666666666666 * Ce + 1.0), $MachinePrecision] * Ce + -1.0), $MachinePrecision] * Ce + 0.5), $MachinePrecision], 0.0]
f(Ce): Ce in [-inf, +inf] code: THEORY BEGIN f(Ce: real): real = LET tmp = IF (((2) * Ce) <= (200000000000000011102230246251565404236316680908203125e-54)) THEN (((((((-66666666666666662965923251249478198587894439697265625e-53) * Ce) + (1)) * Ce) + (-1)) * Ce) + (5e-1)) ELSE (0) ENDIF IN tmp END code
\begin{array}{l}
\mathbf{if}\;2 \cdot Ce \leq 0.2:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(-0.6666666666666666, Ce, 1\right), Ce, -1\right), Ce, 0.5\right)\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
if (*.f64 #s(literal 2 binary64) Ce) < 0.20000000000000001Initial program 100.0%
Taylor expanded in Ce around 0
Applied rewrites67.0%
Applied rewrites67.0%
if 0.20000000000000001 < (*.f64 #s(literal 2 binary64) Ce) Initial program 100.0%
Taylor expanded in Ce around 0
Applied rewrites66.2%
Taylor expanded in undef-var around zero
Applied rewrites34.3%
(FPCore (Ce) :precision binary64 :pre TRUE (if (<= (* 2.0 Ce) 0.2) (fma Ce Ce (- 0.5 Ce)) 0.0))
double code(double Ce) {
double tmp;
if ((2.0 * Ce) <= 0.2) {
tmp = fma(Ce, Ce, (0.5 - Ce));
} else {
tmp = 0.0;
}
return tmp;
}
function code(Ce) tmp = 0.0 if (Float64(2.0 * Ce) <= 0.2) tmp = fma(Ce, Ce, Float64(0.5 - Ce)); else tmp = 0.0; end return tmp end
code[Ce_] := If[LessEqual[N[(2.0 * Ce), $MachinePrecision], 0.2], N[(Ce * Ce + N[(0.5 - Ce), $MachinePrecision]), $MachinePrecision], 0.0]
f(Ce): Ce in [-inf, +inf] code: THEORY BEGIN f(Ce: real): real = LET tmp = IF (((2) * Ce) <= (200000000000000011102230246251565404236316680908203125e-54)) THEN ((Ce * Ce) + ((5e-1) - Ce)) ELSE (0) ENDIF IN tmp END code
\begin{array}{l}
\mathbf{if}\;2 \cdot Ce \leq 0.2:\\
\;\;\;\;\mathsf{fma}\left(Ce, Ce, 0.5 - Ce\right)\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
if (*.f64 #s(literal 2 binary64) Ce) < 0.20000000000000001Initial program 100.0%
Taylor expanded in Ce around 0
Applied rewrites66.9%
Applied rewrites66.9%
if 0.20000000000000001 < (*.f64 #s(literal 2 binary64) Ce) Initial program 100.0%
Taylor expanded in Ce around 0
Applied rewrites66.2%
Taylor expanded in undef-var around zero
Applied rewrites34.3%
(FPCore (Ce) :precision binary64 :pre TRUE (if (<= (* 2.0 Ce) 0.2) (- 0.5 Ce) 0.0))
double code(double Ce) {
double tmp;
if ((2.0 * Ce) <= 0.2) {
tmp = 0.5 - Ce;
} else {
tmp = 0.0;
}
return tmp;
}
real(8) function code(ce)
use fmin_fmax_functions
real(8), intent (in) :: ce
real(8) :: tmp
if ((2.0d0 * ce) <= 0.2d0) then
tmp = 0.5d0 - ce
else
tmp = 0.0d0
end if
code = tmp
end function
public static double code(double Ce) {
double tmp;
if ((2.0 * Ce) <= 0.2) {
tmp = 0.5 - Ce;
} else {
tmp = 0.0;
}
return tmp;
}
def code(Ce): tmp = 0 if (2.0 * Ce) <= 0.2: tmp = 0.5 - Ce else: tmp = 0.0 return tmp
function code(Ce) tmp = 0.0 if (Float64(2.0 * Ce) <= 0.2) tmp = Float64(0.5 - Ce); else tmp = 0.0; end return tmp end
function tmp_2 = code(Ce) tmp = 0.0; if ((2.0 * Ce) <= 0.2) tmp = 0.5 - Ce; else tmp = 0.0; end tmp_2 = tmp; end
code[Ce_] := If[LessEqual[N[(2.0 * Ce), $MachinePrecision], 0.2], N[(0.5 - Ce), $MachinePrecision], 0.0]
f(Ce): Ce in [-inf, +inf] code: THEORY BEGIN f(Ce: real): real = LET tmp = IF (((2) * Ce) <= (200000000000000011102230246251565404236316680908203125e-54)) THEN ((5e-1) - Ce) ELSE (0) ENDIF IN tmp END code
\begin{array}{l}
\mathbf{if}\;2 \cdot Ce \leq 0.2:\\
\;\;\;\;0.5 - Ce\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
if (*.f64 #s(literal 2 binary64) Ce) < 0.20000000000000001Initial program 100.0%
Taylor expanded in Ce around 0
Applied rewrites66.7%
Applied rewrites66.7%
if 0.20000000000000001 < (*.f64 #s(literal 2 binary64) Ce) Initial program 100.0%
Taylor expanded in Ce around 0
Applied rewrites66.2%
Taylor expanded in undef-var around zero
Applied rewrites34.3%
(FPCore (Ce) :precision binary64 :pre TRUE (if (<= (* 2.0 Ce) 169.95083588869068) 0.5 0.0))
double code(double Ce) {
double tmp;
if ((2.0 * Ce) <= 169.95083588869068) {
tmp = 0.5;
} else {
tmp = 0.0;
}
return tmp;
}
real(8) function code(ce)
use fmin_fmax_functions
real(8), intent (in) :: ce
real(8) :: tmp
if ((2.0d0 * ce) <= 169.95083588869068d0) then
tmp = 0.5d0
else
tmp = 0.0d0
end if
code = tmp
end function
public static double code(double Ce) {
double tmp;
if ((2.0 * Ce) <= 169.95083588869068) {
tmp = 0.5;
} else {
tmp = 0.0;
}
return tmp;
}
def code(Ce): tmp = 0 if (2.0 * Ce) <= 169.95083588869068: tmp = 0.5 else: tmp = 0.0 return tmp
function code(Ce) tmp = 0.0 if (Float64(2.0 * Ce) <= 169.95083588869068) tmp = 0.5; else tmp = 0.0; end return tmp end
function tmp_2 = code(Ce) tmp = 0.0; if ((2.0 * Ce) <= 169.95083588869068) tmp = 0.5; else tmp = 0.0; end tmp_2 = tmp; end
code[Ce_] := If[LessEqual[N[(2.0 * Ce), $MachinePrecision], 169.95083588869068], 0.5, 0.0]
f(Ce): Ce in [-inf, +inf] code: THEORY BEGIN f(Ce: real): real = LET tmp = IF (((2) * Ce) <= (1699508358886906762563739903271198272705078125e-43)) THEN (5e-1) ELSE (0) ENDIF IN tmp END code
\begin{array}{l}
\mathbf{if}\;2 \cdot Ce \leq 169.95083588869068:\\
\;\;\;\;0.5\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
if (*.f64 #s(literal 2 binary64) Ce) < 169.95083588869068Initial program 100.0%
Taylor expanded in Ce around 0
Applied rewrites66.2%
if 169.95083588869068 < (*.f64 #s(literal 2 binary64) Ce) Initial program 100.0%
Taylor expanded in Ce around 0
Applied rewrites66.2%
Taylor expanded in undef-var around zero
Applied rewrites34.3%
(FPCore (Ce) :precision binary64 :pre TRUE 0.5)
double code(double Ce) {
return 0.5;
}
real(8) function code(ce)
use fmin_fmax_functions
real(8), intent (in) :: ce
code = 0.5d0
end function
public static double code(double Ce) {
return 0.5;
}
def code(Ce): return 0.5
function code(Ce) return 0.5 end
function tmp = code(Ce) tmp = 0.5; end
code[Ce_] := 0.5
f(Ce): Ce in [-inf, +inf] code: THEORY BEGIN f(Ce: real): real = 5e-1 END code
0.5
Initial program 100.0%
Taylor expanded in Ce around 0
Applied rewrites66.2%
herbie shell --seed 2026050 +o generate:egglog
(FPCore (Ce)
:name "exact-inv-half-inv-exp"
:precision binary64
(/ 0.5 (exp (* 2.0 Ce))))