
(FPCore (Ce) :precision binary64 :pre TRUE (exp (* 2.0 Ce)))
double code(double Ce) {
return exp((2.0 * Ce));
}
real(8) function code(ce)
use fmin_fmax_functions
real(8), intent (in) :: ce
code = exp((2.0d0 * ce))
end function
public static double code(double Ce) {
return Math.exp((2.0 * Ce));
}
def code(Ce): return math.exp((2.0 * Ce))
function code(Ce) return exp(Float64(2.0 * Ce)) end
function tmp = code(Ce) tmp = exp((2.0 * Ce)); end
code[Ce_] := N[Exp[N[(2.0 * Ce), $MachinePrecision]], $MachinePrecision]
f(Ce): Ce in [-inf, +inf] code: THEORY BEGIN f(Ce: real): real = exp(((2) * Ce)) END code
e^{2 \cdot Ce}
Herbie found 7 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (Ce) :precision binary64 :pre TRUE (exp (* 2.0 Ce)))
double code(double Ce) {
return exp((2.0 * Ce));
}
real(8) function code(ce)
use fmin_fmax_functions
real(8), intent (in) :: ce
code = exp((2.0d0 * ce))
end function
public static double code(double Ce) {
return Math.exp((2.0 * Ce));
}
def code(Ce): return math.exp((2.0 * Ce))
function code(Ce) return exp(Float64(2.0 * Ce)) end
function tmp = code(Ce) tmp = exp((2.0 * Ce)); end
code[Ce_] := N[Exp[N[(2.0 * Ce), $MachinePrecision]], $MachinePrecision]
f(Ce): Ce in [-inf, +inf] code: THEORY BEGIN f(Ce: real): real = exp(((2) * Ce)) END code
e^{2 \cdot Ce}
(FPCore (Ce) :precision binary64 :pre TRUE (exp (+ Ce Ce)))
double code(double Ce) {
return exp((Ce + Ce));
}
real(8) function code(ce)
use fmin_fmax_functions
real(8), intent (in) :: ce
code = exp((ce + ce))
end function
public static double code(double Ce) {
return Math.exp((Ce + Ce));
}
def code(Ce): return math.exp((Ce + Ce))
function code(Ce) return exp(Float64(Ce + Ce)) end
function tmp = code(Ce) tmp = exp((Ce + Ce)); end
code[Ce_] := N[Exp[N[(Ce + Ce), $MachinePrecision]], $MachinePrecision]
f(Ce): Ce in [-inf, +inf] code: THEORY BEGIN f(Ce: real): real = exp((Ce + Ce)) END code
e^{Ce + Ce}
Initial program 100.0%
Applied rewrites100.0%
(FPCore (Ce) :precision binary64 :pre TRUE (if (<= (* 2.0 Ce) -2000000.0) 0.0 (fma (fma Ce Ce Ce) 2.0 1.0)))
double code(double Ce) {
double tmp;
if ((2.0 * Ce) <= -2000000.0) {
tmp = 0.0;
} else {
tmp = fma(fma(Ce, Ce, Ce), 2.0, 1.0);
}
return tmp;
}
function code(Ce) tmp = 0.0 if (Float64(2.0 * Ce) <= -2000000.0) tmp = 0.0; else tmp = fma(fma(Ce, Ce, Ce), 2.0, 1.0); end return tmp end
code[Ce_] := If[LessEqual[N[(2.0 * Ce), $MachinePrecision], -2000000.0], 0.0, N[(N[(Ce * Ce + Ce), $MachinePrecision] * 2.0 + 1.0), $MachinePrecision]]
f(Ce): Ce in [-inf, +inf] code: THEORY BEGIN f(Ce: real): real = LET tmp = IF (((2) * Ce) <= (-2e6)) THEN (0) ELSE ((((Ce * Ce) + Ce) * (2)) + (1)) ENDIF IN tmp END code
\begin{array}{l}
\mathbf{if}\;2 \cdot Ce \leq -2000000:\\
\;\;\;\;0\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(Ce, Ce, Ce\right), 2, 1\right)\\
\end{array}
if (*.f64 #s(literal 2 binary64) Ce) < -2e6Initial program 100.0%
Taylor expanded in Ce around 0
Applied rewrites51.3%
Applied rewrites51.3%
Taylor expanded in Ce around inf
Applied rewrites3.8%
Applied rewrites26.6%
if -2e6 < (*.f64 #s(literal 2 binary64) Ce) Initial program 100.0%
Taylor expanded in Ce around 0
Applied rewrites63.6%
Applied rewrites63.6%
(FPCore (Ce)
:precision binary64
:pre TRUE
(let* ((t_0 (exp (* 2.0 Ce))))
(if (<= t_0 0.001)
0.0
(if (<= t_0 2.0) (fma Ce 2.0 1.0) (* Ce Ce)))))double code(double Ce) {
double t_0 = exp((2.0 * Ce));
double tmp;
if (t_0 <= 0.001) {
tmp = 0.0;
} else if (t_0 <= 2.0) {
tmp = fma(Ce, 2.0, 1.0);
} else {
tmp = Ce * Ce;
}
return tmp;
}
function code(Ce) t_0 = exp(Float64(2.0 * Ce)) tmp = 0.0 if (t_0 <= 0.001) tmp = 0.0; elseif (t_0 <= 2.0) tmp = fma(Ce, 2.0, 1.0); else tmp = Float64(Ce * Ce); end return tmp end
code[Ce_] := Block[{t$95$0 = N[Exp[N[(2.0 * Ce), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[t$95$0, 0.001], 0.0, If[LessEqual[t$95$0, 2.0], N[(Ce * 2.0 + 1.0), $MachinePrecision], N[(Ce * Ce), $MachinePrecision]]]]
f(Ce): Ce in [-inf, +inf] code: THEORY BEGIN f(Ce: real): real = LET t_0 = (exp(((2) * Ce))) IN LET tmp_1 = IF (t_0 <= (2)) THEN ((Ce * (2)) + (1)) ELSE (Ce * Ce) ENDIF IN LET tmp = IF (t_0 <= (1000000000000000020816681711721685132943093776702880859375e-60)) THEN (0) ELSE tmp_1 ENDIF IN tmp END code
\begin{array}{l}
t_0 := e^{2 \cdot Ce}\\
\mathbf{if}\;t\_0 \leq 0.001:\\
\;\;\;\;0\\
\mathbf{elif}\;t\_0 \leq 2:\\
\;\;\;\;\mathsf{fma}\left(Ce, 2, 1\right)\\
\mathbf{else}:\\
\;\;\;\;Ce \cdot Ce\\
\end{array}
if (exp.f64 (*.f64 #s(literal 2 binary64) Ce)) < 1e-3Initial program 100.0%
Taylor expanded in Ce around 0
Applied rewrites51.3%
Applied rewrites51.3%
Taylor expanded in Ce around inf
Applied rewrites3.8%
Applied rewrites26.6%
if 1e-3 < (exp.f64 (*.f64 #s(literal 2 binary64) Ce)) < 2Initial program 100.0%
Taylor expanded in Ce around 0
Applied rewrites51.3%
Applied rewrites51.3%
if 2 < (exp.f64 (*.f64 #s(literal 2 binary64) Ce)) Initial program 100.0%
Taylor expanded in Ce around 0
Applied rewrites51.3%
Applied rewrites51.3%
Taylor expanded in Ce around inf
Applied rewrites3.8%
Applied rewrites16.2%
(FPCore (Ce) :precision binary64 :pre TRUE (let* ((t_0 (exp (* 2.0 Ce)))) (if (<= t_0 0.0) 0.0 (if (<= t_0 2.0) 1.0 (* Ce Ce)))))
double code(double Ce) {
double t_0 = exp((2.0 * Ce));
double tmp;
if (t_0 <= 0.0) {
tmp = 0.0;
} else if (t_0 <= 2.0) {
tmp = 1.0;
} else {
tmp = Ce * Ce;
}
return tmp;
}
real(8) function code(ce)
use fmin_fmax_functions
real(8), intent (in) :: ce
real(8) :: t_0
real(8) :: tmp
t_0 = exp((2.0d0 * ce))
if (t_0 <= 0.0d0) then
tmp = 0.0d0
else if (t_0 <= 2.0d0) then
tmp = 1.0d0
else
tmp = ce * ce
end if
code = tmp
end function
public static double code(double Ce) {
double t_0 = Math.exp((2.0 * Ce));
double tmp;
if (t_0 <= 0.0) {
tmp = 0.0;
} else if (t_0 <= 2.0) {
tmp = 1.0;
} else {
tmp = Ce * Ce;
}
return tmp;
}
def code(Ce): t_0 = math.exp((2.0 * Ce)) tmp = 0 if t_0 <= 0.0: tmp = 0.0 elif t_0 <= 2.0: tmp = 1.0 else: tmp = Ce * Ce return tmp
function code(Ce) t_0 = exp(Float64(2.0 * Ce)) tmp = 0.0 if (t_0 <= 0.0) tmp = 0.0; elseif (t_0 <= 2.0) tmp = 1.0; else tmp = Float64(Ce * Ce); end return tmp end
function tmp_2 = code(Ce) t_0 = exp((2.0 * Ce)); tmp = 0.0; if (t_0 <= 0.0) tmp = 0.0; elseif (t_0 <= 2.0) tmp = 1.0; else tmp = Ce * Ce; end tmp_2 = tmp; end
code[Ce_] := Block[{t$95$0 = N[Exp[N[(2.0 * Ce), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[t$95$0, 0.0], 0.0, If[LessEqual[t$95$0, 2.0], 1.0, N[(Ce * Ce), $MachinePrecision]]]]
f(Ce): Ce in [-inf, +inf] code: THEORY BEGIN f(Ce: real): real = LET t_0 = (exp(((2) * Ce))) IN LET tmp_1 = IF (t_0 <= (2)) THEN (1) ELSE (Ce * Ce) ENDIF IN LET tmp = IF (t_0 <= (0)) THEN (0) ELSE tmp_1 ENDIF IN tmp END code
\begin{array}{l}
t_0 := e^{2 \cdot Ce}\\
\mathbf{if}\;t\_0 \leq 0:\\
\;\;\;\;0\\
\mathbf{elif}\;t\_0 \leq 2:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;Ce \cdot Ce\\
\end{array}
if (exp.f64 (*.f64 #s(literal 2 binary64) Ce)) < 0.0Initial program 100.0%
Taylor expanded in Ce around 0
Applied rewrites51.3%
Applied rewrites51.3%
Taylor expanded in Ce around inf
Applied rewrites3.8%
Applied rewrites26.6%
if 0.0 < (exp.f64 (*.f64 #s(literal 2 binary64) Ce)) < 2Initial program 100.0%
Taylor expanded in Ce around 0
Applied rewrites50.4%
if 2 < (exp.f64 (*.f64 #s(literal 2 binary64) Ce)) Initial program 100.0%
Taylor expanded in Ce around 0
Applied rewrites51.3%
Applied rewrites51.3%
Taylor expanded in Ce around inf
Applied rewrites3.8%
Applied rewrites16.2%
(FPCore (Ce) :precision binary64 :pre TRUE (if (<= (* 2.0 Ce) -5.0) 0.0 (- Ce -1.0)))
double code(double Ce) {
double tmp;
if ((2.0 * Ce) <= -5.0) {
tmp = 0.0;
} else {
tmp = Ce - -1.0;
}
return tmp;
}
real(8) function code(ce)
use fmin_fmax_functions
real(8), intent (in) :: ce
real(8) :: tmp
if ((2.0d0 * ce) <= (-5.0d0)) then
tmp = 0.0d0
else
tmp = ce - (-1.0d0)
end if
code = tmp
end function
public static double code(double Ce) {
double tmp;
if ((2.0 * Ce) <= -5.0) {
tmp = 0.0;
} else {
tmp = Ce - -1.0;
}
return tmp;
}
def code(Ce): tmp = 0 if (2.0 * Ce) <= -5.0: tmp = 0.0 else: tmp = Ce - -1.0 return tmp
function code(Ce) tmp = 0.0 if (Float64(2.0 * Ce) <= -5.0) tmp = 0.0; else tmp = Float64(Ce - -1.0); end return tmp end
function tmp_2 = code(Ce) tmp = 0.0; if ((2.0 * Ce) <= -5.0) tmp = 0.0; else tmp = Ce - -1.0; end tmp_2 = tmp; end
code[Ce_] := If[LessEqual[N[(2.0 * Ce), $MachinePrecision], -5.0], 0.0, N[(Ce - -1.0), $MachinePrecision]]
f(Ce): Ce in [-inf, +inf] code: THEORY BEGIN f(Ce: real): real = LET tmp = IF (((2) * Ce) <= (-5)) THEN (0) ELSE (Ce - (-1)) ENDIF IN tmp END code
\begin{array}{l}
\mathbf{if}\;2 \cdot Ce \leq -5:\\
\;\;\;\;0\\
\mathbf{else}:\\
\;\;\;\;Ce - -1\\
\end{array}
if (*.f64 #s(literal 2 binary64) Ce) < -5Initial program 100.0%
Taylor expanded in Ce around 0
Applied rewrites51.3%
Applied rewrites51.3%
Taylor expanded in Ce around inf
Applied rewrites3.8%
Applied rewrites26.6%
if -5 < (*.f64 #s(literal 2 binary64) Ce) Initial program 100.0%
Taylor expanded in Ce around 0
Applied rewrites51.3%
Applied rewrites51.3%
Taylor expanded in Ce around 0
Applied rewrites50.8%
(FPCore (Ce) :precision binary64 :pre TRUE (if (<= (* 2.0 Ce) -2000000.0) 0.0 1.0))
double code(double Ce) {
double tmp;
if ((2.0 * Ce) <= -2000000.0) {
tmp = 0.0;
} else {
tmp = 1.0;
}
return tmp;
}
real(8) function code(ce)
use fmin_fmax_functions
real(8), intent (in) :: ce
real(8) :: tmp
if ((2.0d0 * ce) <= (-2000000.0d0)) then
tmp = 0.0d0
else
tmp = 1.0d0
end if
code = tmp
end function
public static double code(double Ce) {
double tmp;
if ((2.0 * Ce) <= -2000000.0) {
tmp = 0.0;
} else {
tmp = 1.0;
}
return tmp;
}
def code(Ce): tmp = 0 if (2.0 * Ce) <= -2000000.0: tmp = 0.0 else: tmp = 1.0 return tmp
function code(Ce) tmp = 0.0 if (Float64(2.0 * Ce) <= -2000000.0) tmp = 0.0; else tmp = 1.0; end return tmp end
function tmp_2 = code(Ce) tmp = 0.0; if ((2.0 * Ce) <= -2000000.0) tmp = 0.0; else tmp = 1.0; end tmp_2 = tmp; end
code[Ce_] := If[LessEqual[N[(2.0 * Ce), $MachinePrecision], -2000000.0], 0.0, 1.0]
f(Ce): Ce in [-inf, +inf] code: THEORY BEGIN f(Ce: real): real = LET tmp = IF (((2) * Ce) <= (-2e6)) THEN (0) ELSE (1) ENDIF IN tmp END code
\begin{array}{l}
\mathbf{if}\;2 \cdot Ce \leq -2000000:\\
\;\;\;\;0\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
if (*.f64 #s(literal 2 binary64) Ce) < -2e6Initial program 100.0%
Taylor expanded in Ce around 0
Applied rewrites51.3%
Applied rewrites51.3%
Taylor expanded in Ce around inf
Applied rewrites3.8%
Applied rewrites26.6%
if -2e6 < (*.f64 #s(literal 2 binary64) Ce) Initial program 100.0%
Taylor expanded in Ce around 0
Applied rewrites50.4%
(FPCore (Ce) :precision binary64 :pre TRUE 1.0)
double code(double Ce) {
return 1.0;
}
real(8) function code(ce)
use fmin_fmax_functions
real(8), intent (in) :: ce
code = 1.0d0
end function
public static double code(double Ce) {
return 1.0;
}
def code(Ce): return 1.0
function code(Ce) return 1.0 end
function tmp = code(Ce) tmp = 1.0; end
code[Ce_] := 1.0
f(Ce): Ce in [-inf, +inf] code: THEORY BEGIN f(Ce: real): real = 1 END code
1
Initial program 100.0%
Taylor expanded in Ce around 0
Applied rewrites50.4%
herbie shell --seed 2026050 +o generate:egglog
(FPCore (Ce)
:name "exact-inv-exp2Ce"
:precision binary64
(exp (* 2.0 Ce)))