
(FPCore (t) :precision binary64 (- (* 1.7e+308 t) 1.7e+308))
double code(double t) {
return (1.7e+308 * t) - 1.7e+308;
}
real(8) function code(t)
real(8), intent (in) :: t
code = (1.7d+308 * t) - 1.7d+308
end function
public static double code(double t) {
return (1.7e+308 * t) - 1.7e+308;
}
def code(t): return (1.7e+308 * t) - 1.7e+308
function code(t) return Float64(Float64(1.7e+308 * t) - 1.7e+308) end
function tmp = code(t) tmp = (1.7e+308 * t) - 1.7e+308; end
code[t_] := N[(N[(1.7e+308 * t), $MachinePrecision] - 1.7e+308), $MachinePrecision]
\begin{array}{l}
\\
1.7 \cdot 10^{+308} \cdot t - 1.7 \cdot 10^{+308}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 4 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (t) :precision binary64 (- (* 1.7e+308 t) 1.7e+308))
double code(double t) {
return (1.7e+308 * t) - 1.7e+308;
}
real(8) function code(t)
real(8), intent (in) :: t
code = (1.7d+308 * t) - 1.7d+308
end function
public static double code(double t) {
return (1.7e+308 * t) - 1.7e+308;
}
def code(t): return (1.7e+308 * t) - 1.7e+308
function code(t) return Float64(Float64(1.7e+308 * t) - 1.7e+308) end
function tmp = code(t) tmp = (1.7e+308 * t) - 1.7e+308; end
code[t_] := N[(N[(1.7e+308 * t), $MachinePrecision] - 1.7e+308), $MachinePrecision]
\begin{array}{l}
\\
1.7 \cdot 10^{+308} \cdot t - 1.7 \cdot 10^{+308}
\end{array}
(FPCore (t) :precision binary64 (fma 1.7e+308 t -1.7e+308))
double code(double t) {
return fma(1.7e+308, t, -1.7e+308);
}
function code(t) return fma(1.7e+308, t, -1.7e+308) end
code[t_] := N[(1.7e+308 * t + -1.7e+308), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(1.7 \cdot 10^{+308}, t, -1.7 \cdot 10^{+308}\right)
\end{array}
Initial program 33.7%
fma-neg99.6%
metadata-eval99.6%
Simplified99.6%
Final simplification99.6%
(FPCore (t) :precision binary64 (if (<= t 2.03) 1.7e+308 (* 1.7e+308 t)))
double code(double t) {
double tmp;
if (t <= 2.03) {
tmp = 1.7e+308;
} else {
tmp = 1.7e+308 * t;
}
return tmp;
}
real(8) function code(t)
real(8), intent (in) :: t
real(8) :: tmp
if (t <= 2.03d0) then
tmp = 1.7d+308
else
tmp = 1.7d+308 * t
end if
code = tmp
end function
public static double code(double t) {
double tmp;
if (t <= 2.03) {
tmp = 1.7e+308;
} else {
tmp = 1.7e+308 * t;
}
return tmp;
}
def code(t): tmp = 0 if t <= 2.03: tmp = 1.7e+308 else: tmp = 1.7e+308 * t return tmp
function code(t) tmp = 0.0 if (t <= 2.03) tmp = 1.7e+308; else tmp = Float64(1.7e+308 * t); end return tmp end
function tmp_2 = code(t) tmp = 0.0; if (t <= 2.03) tmp = 1.7e+308; else tmp = 1.7e+308 * t; end tmp_2 = tmp; end
code[t_] := If[LessEqual[t, 2.03], 1.7e+308, N[(1.7e+308 * t), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq 2.03:\\
\;\;\;\;1.7 \cdot 10^{+308}\\
\mathbf{else}:\\
\;\;\;\;1.7 \cdot 10^{+308} \cdot t\\
\end{array}
\end{array}
if t < 2.0299999999999998Initial program 22.6%
add-sqr-sqrt22.6%
pow222.6%
fma-neg99.1%
metadata-eval99.1%
Applied egg-rr99.1%
unpow299.1%
add-sqr-sqrt98.9%
associate-*l*99.0%
pow1/299.0%
sqrt-pow199.1%
metadata-eval99.1%
pow1/299.1%
sqrt-pow199.1%
pow1/299.1%
pow-prod-up99.4%
metadata-eval99.4%
metadata-eval99.4%
Applied egg-rr99.4%
fma-def22.6%
*-commutative22.6%
fma-udef99.4%
fma-def22.6%
*-commutative22.6%
fma-udef99.4%
Simplified99.4%
pow-prod-up99.6%
metadata-eval99.6%
pow199.6%
add-cube-cbrt97.7%
pow397.7%
add-cube-cbrt96.2%
pow396.2%
metadata-eval96.2%
metadata-eval96.2%
pow-prod-up96.2%
metadata-eval96.2%
pow196.2%
metadata-eval96.2%
pow-prod-down96.2%
Applied egg-rr96.2%
Taylor expanded in t around 0 25.0%
if 2.0299999999999998 < t Initial program 69.9%
Taylor expanded in t around inf 69.9%
Final simplification35.5%
(FPCore (t) :precision binary64 -1.7e+308)
double code(double t) {
return -1.7e+308;
}
real(8) function code(t)
real(8), intent (in) :: t
code = -1.7d+308
end function
public static double code(double t) {
return -1.7e+308;
}
def code(t): return -1.7e+308
function code(t) return -1.7e+308 end
function tmp = code(t) tmp = -1.7e+308; end
code[t_] := -1.7e+308
\begin{array}{l}
\\
-1.7 \cdot 10^{+308}
\end{array}
Initial program 33.7%
Taylor expanded in t around 0 0.0%
Final simplification0.0%
(FPCore (t) :precision binary64 1.7e+308)
double code(double t) {
return 1.7e+308;
}
real(8) function code(t)
real(8), intent (in) :: t
code = 1.7d+308
end function
public static double code(double t) {
return 1.7e+308;
}
def code(t): return 1.7e+308
function code(t) return 1.7e+308 end
function tmp = code(t) tmp = 1.7e+308; end
code[t_] := 1.7e+308
\begin{array}{l}
\\
1.7 \cdot 10^{+308}
\end{array}
Initial program 33.7%
add-sqr-sqrt33.7%
pow233.7%
fma-neg99.2%
metadata-eval99.2%
Applied egg-rr99.2%
unpow299.2%
add-sqr-sqrt99.0%
associate-*l*99.1%
pow1/299.1%
sqrt-pow199.2%
metadata-eval99.2%
pow1/299.2%
sqrt-pow199.2%
pow1/299.2%
pow-prod-up99.5%
metadata-eval99.5%
metadata-eval99.5%
Applied egg-rr99.5%
fma-def33.7%
*-commutative33.7%
fma-udef99.5%
fma-def33.7%
*-commutative33.7%
fma-udef99.5%
Simplified99.5%
pow-prod-up99.6%
metadata-eval99.6%
pow199.6%
add-cube-cbrt98.0%
pow398.0%
add-cube-cbrt96.7%
pow396.7%
metadata-eval96.7%
metadata-eval96.7%
pow-prod-up96.7%
metadata-eval96.7%
pow196.7%
metadata-eval96.7%
pow-prod-down96.7%
Applied egg-rr96.7%
Taylor expanded in t around 0 24.8%
Final simplification24.8%
(FPCore (t) :precision binary64 (fma 1.7e+308 t (- 1.7e+308)))
double code(double t) {
return fma(1.7e+308, t, -1.7e+308);
}
function code(t) return fma(1.7e+308, t, Float64(-1.7e+308)) end
code[t_] := N[(1.7e+308 * t + (-1.7e+308)), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(1.7 \cdot 10^{+308}, t, -1.7 \cdot 10^{+308}\right)
\end{array}
herbie shell --seed 2023299
(FPCore (t)
:name "fma_test2"
:precision binary64
:pre (and (<= 1.9 t) (<= t 2.1))
:herbie-target
(fma 1.7e+308 t (- 1.7e+308))
(- (* 1.7e+308 t) 1.7e+308))