
(FPCore (u v t1) :precision binary64 (/ (* (- t1) v) (* (+ t1 u) (+ t1 u))))
double code(double u, double v, double t1) {
return (-t1 * v) / ((t1 + u) * (t1 + u));
}
real(8) function code(u, v, t1)
real(8), intent (in) :: u
real(8), intent (in) :: v
real(8), intent (in) :: t1
code = (-t1 * v) / ((t1 + u) * (t1 + u))
end function
public static double code(double u, double v, double t1) {
return (-t1 * v) / ((t1 + u) * (t1 + u));
}
def code(u, v, t1): return (-t1 * v) / ((t1 + u) * (t1 + u))
function code(u, v, t1) return Float64(Float64(Float64(-t1) * v) / Float64(Float64(t1 + u) * Float64(t1 + u))) end
function tmp = code(u, v, t1) tmp = (-t1 * v) / ((t1 + u) * (t1 + u)); end
code[u_, v_, t1_] := N[(N[((-t1) * v), $MachinePrecision] / N[(N[(t1 + u), $MachinePrecision] * N[(t1 + u), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left(-t1\right) \cdot v}{\left(t1 + u\right) \cdot \left(t1 + u\right)}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 8 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (u v t1) :precision binary64 (/ (* (- t1) v) (* (+ t1 u) (+ t1 u))))
double code(double u, double v, double t1) {
return (-t1 * v) / ((t1 + u) * (t1 + u));
}
real(8) function code(u, v, t1)
real(8), intent (in) :: u
real(8), intent (in) :: v
real(8), intent (in) :: t1
code = (-t1 * v) / ((t1 + u) * (t1 + u))
end function
public static double code(double u, double v, double t1) {
return (-t1 * v) / ((t1 + u) * (t1 + u));
}
def code(u, v, t1): return (-t1 * v) / ((t1 + u) * (t1 + u))
function code(u, v, t1) return Float64(Float64(Float64(-t1) * v) / Float64(Float64(t1 + u) * Float64(t1 + u))) end
function tmp = code(u, v, t1) tmp = (-t1 * v) / ((t1 + u) * (t1 + u)); end
code[u_, v_, t1_] := N[(N[((-t1) * v), $MachinePrecision] / N[(N[(t1 + u), $MachinePrecision] * N[(t1 + u), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left(-t1\right) \cdot v}{\left(t1 + u\right) \cdot \left(t1 + u\right)}
\end{array}
(FPCore (u v t1) :precision binary64 (/ (- v) (fma u (+ 2.0 (/ u t1)) t1)))
double code(double u, double v, double t1) {
return -v / fma(u, (2.0 + (u / t1)), t1);
}
function code(u, v, t1) return Float64(Float64(-v) / fma(u, Float64(2.0 + Float64(u / t1)), t1)) end
code[u_, v_, t1_] := N[((-v) / N[(u * N[(2.0 + N[(u / t1), $MachinePrecision]), $MachinePrecision] + t1), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{-v}{\mathsf{fma}\left(u, 2 + \frac{u}{t1}, t1\right)}
\end{array}
Initial program 76.7%
Taylor expanded in t1 around inf
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
+-commutativeN/A
+-commutativeN/A
unpow2N/A
unpow2N/A
times-fracN/A
distribute-rgt-outN/A
lower-fma.f64N/A
lower-/.f64N/A
lower-+.f64N/A
lower-/.f6455.4
Simplified55.4%
Taylor expanded in v around 0
mul-1-negN/A
lower-neg.f64N/A
lower-/.f64N/A
+-commutativeN/A
distribute-lft-inN/A
*-rgt-identityN/A
lower-fma.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-/.f6488.6
Simplified88.6%
Taylor expanded in u around 0
+-commutativeN/A
lower-fma.f64N/A
lower-+.f64N/A
lower-/.f6495.9
Simplified95.9%
Final simplification95.9%
(FPCore (u v t1)
:precision binary64
(let* ((t_1 (- (/ v (fma u 2.0 t1)))))
(if (<= t1 -4e+138)
t_1
(if (<= t1 7.8e+123) (/ (* v (- t1)) (* (+ u t1) (+ u t1))) t_1))))
double code(double u, double v, double t1) {
double t_1 = -(v / fma(u, 2.0, t1));
double tmp;
if (t1 <= -4e+138) {
tmp = t_1;
} else if (t1 <= 7.8e+123) {
tmp = (v * -t1) / ((u + t1) * (u + t1));
} else {
tmp = t_1;
}
return tmp;
}
function code(u, v, t1) t_1 = Float64(-Float64(v / fma(u, 2.0, t1))) tmp = 0.0 if (t1 <= -4e+138) tmp = t_1; elseif (t1 <= 7.8e+123) tmp = Float64(Float64(v * Float64(-t1)) / Float64(Float64(u + t1) * Float64(u + t1))); else tmp = t_1; end return tmp end
code[u_, v_, t1_] := Block[{t$95$1 = (-N[(v / N[(u * 2.0 + t1), $MachinePrecision]), $MachinePrecision])}, If[LessEqual[t1, -4e+138], t$95$1, If[LessEqual[t1, 7.8e+123], N[(N[(v * (-t1)), $MachinePrecision] / N[(N[(u + t1), $MachinePrecision] * N[(u + t1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := -\frac{v}{\mathsf{fma}\left(u, 2, t1\right)}\\
\mathbf{if}\;t1 \leq -4 \cdot 10^{+138}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t1 \leq 7.8 \cdot 10^{+123}:\\
\;\;\;\;\frac{v \cdot \left(-t1\right)}{\left(u + t1\right) \cdot \left(u + t1\right)}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if t1 < -4.0000000000000001e138 or 7.79999999999999986e123 < t1 Initial program 53.4%
Taylor expanded in t1 around inf
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
+-commutativeN/A
+-commutativeN/A
unpow2N/A
unpow2N/A
times-fracN/A
distribute-rgt-outN/A
lower-fma.f64N/A
lower-/.f64N/A
lower-+.f64N/A
lower-/.f6453.4
Simplified53.4%
Taylor expanded in v around 0
mul-1-negN/A
lower-neg.f64N/A
lower-/.f64N/A
+-commutativeN/A
distribute-lft-inN/A
*-rgt-identityN/A
lower-fma.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-/.f6495.9
Simplified95.9%
Taylor expanded in u around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f6492.0
Simplified92.0%
if -4.0000000000000001e138 < t1 < 7.79999999999999986e123Initial program 85.6%
Final simplification87.4%
(FPCore (u v t1)
:precision binary64
(let* ((t_1 (- (/ v (fma u 2.0 t1)))))
(if (<= t1 -5.8e-55)
t_1
(if (<= t1 3.9e-109) (/ v (/ (* u (- u)) t1)) t_1))))
double code(double u, double v, double t1) {
double t_1 = -(v / fma(u, 2.0, t1));
double tmp;
if (t1 <= -5.8e-55) {
tmp = t_1;
} else if (t1 <= 3.9e-109) {
tmp = v / ((u * -u) / t1);
} else {
tmp = t_1;
}
return tmp;
}
function code(u, v, t1) t_1 = Float64(-Float64(v / fma(u, 2.0, t1))) tmp = 0.0 if (t1 <= -5.8e-55) tmp = t_1; elseif (t1 <= 3.9e-109) tmp = Float64(v / Float64(Float64(u * Float64(-u)) / t1)); else tmp = t_1; end return tmp end
code[u_, v_, t1_] := Block[{t$95$1 = (-N[(v / N[(u * 2.0 + t1), $MachinePrecision]), $MachinePrecision])}, If[LessEqual[t1, -5.8e-55], t$95$1, If[LessEqual[t1, 3.9e-109], N[(v / N[(N[(u * (-u)), $MachinePrecision] / t1), $MachinePrecision]), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := -\frac{v}{\mathsf{fma}\left(u, 2, t1\right)}\\
\mathbf{if}\;t1 \leq -5.8 \cdot 10^{-55}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t1 \leq 3.9 \cdot 10^{-109}:\\
\;\;\;\;\frac{v}{\frac{u \cdot \left(-u\right)}{t1}}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if t1 < -5.8e-55 or 3.90000000000000023e-109 < t1 Initial program 72.2%
Taylor expanded in t1 around inf
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
+-commutativeN/A
+-commutativeN/A
unpow2N/A
unpow2N/A
times-fracN/A
distribute-rgt-outN/A
lower-fma.f64N/A
lower-/.f64N/A
lower-+.f64N/A
lower-/.f6470.9
Simplified70.9%
Taylor expanded in v around 0
mul-1-negN/A
lower-neg.f64N/A
lower-/.f64N/A
+-commutativeN/A
distribute-lft-inN/A
*-rgt-identityN/A
lower-fma.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-/.f6494.5
Simplified94.5%
Taylor expanded in u around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f6483.2
Simplified83.2%
if -5.8e-55 < t1 < 3.90000000000000023e-109Initial program 82.6%
Taylor expanded in t1 around inf
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
+-commutativeN/A
+-commutativeN/A
unpow2N/A
unpow2N/A
times-fracN/A
distribute-rgt-outN/A
lower-fma.f64N/A
lower-/.f64N/A
lower-+.f64N/A
lower-/.f6434.8
Simplified34.8%
Taylor expanded in v around 0
mul-1-negN/A
lower-neg.f64N/A
lower-/.f64N/A
+-commutativeN/A
distribute-lft-inN/A
*-rgt-identityN/A
lower-fma.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-/.f6480.7
Simplified80.7%
Taylor expanded in t1 around 0
lower-/.f64N/A
unpow2N/A
lower-*.f6482.2
Simplified82.2%
Final simplification82.8%
(FPCore (u v t1) :precision binary64 (let* ((t_1 (* t1 (/ v (* u (- u)))))) (if (<= u -8e-8) t_1 (if (<= u 4.7e+45) (- (/ v t1)) t_1))))
double code(double u, double v, double t1) {
double t_1 = t1 * (v / (u * -u));
double tmp;
if (u <= -8e-8) {
tmp = t_1;
} else if (u <= 4.7e+45) {
tmp = -(v / t1);
} else {
tmp = t_1;
}
return tmp;
}
real(8) function code(u, v, t1)
real(8), intent (in) :: u
real(8), intent (in) :: v
real(8), intent (in) :: t1
real(8) :: t_1
real(8) :: tmp
t_1 = t1 * (v / (u * -u))
if (u <= (-8d-8)) then
tmp = t_1
else if (u <= 4.7d+45) then
tmp = -(v / t1)
else
tmp = t_1
end if
code = tmp
end function
public static double code(double u, double v, double t1) {
double t_1 = t1 * (v / (u * -u));
double tmp;
if (u <= -8e-8) {
tmp = t_1;
} else if (u <= 4.7e+45) {
tmp = -(v / t1);
} else {
tmp = t_1;
}
return tmp;
}
def code(u, v, t1): t_1 = t1 * (v / (u * -u)) tmp = 0 if u <= -8e-8: tmp = t_1 elif u <= 4.7e+45: tmp = -(v / t1) else: tmp = t_1 return tmp
function code(u, v, t1) t_1 = Float64(t1 * Float64(v / Float64(u * Float64(-u)))) tmp = 0.0 if (u <= -8e-8) tmp = t_1; elseif (u <= 4.7e+45) tmp = Float64(-Float64(v / t1)); else tmp = t_1; end return tmp end
function tmp_2 = code(u, v, t1) t_1 = t1 * (v / (u * -u)); tmp = 0.0; if (u <= -8e-8) tmp = t_1; elseif (u <= 4.7e+45) tmp = -(v / t1); else tmp = t_1; end tmp_2 = tmp; end
code[u_, v_, t1_] := Block[{t$95$1 = N[(t1 * N[(v / N[(u * (-u)), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[u, -8e-8], t$95$1, If[LessEqual[u, 4.7e+45], (-N[(v / t1), $MachinePrecision]), t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := t1 \cdot \frac{v}{u \cdot \left(-u\right)}\\
\mathbf{if}\;u \leq -8 \cdot 10^{-8}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;u \leq 4.7 \cdot 10^{+45}:\\
\;\;\;\;-\frac{v}{t1}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if u < -8.0000000000000002e-8 or 4.70000000000000002e45 < u Initial program 86.2%
Taylor expanded in t1 around 0
mul-1-negN/A
associate-/l*N/A
distribute-rgt-neg-inN/A
mul-1-negN/A
lower-*.f64N/A
mul-1-negN/A
distribute-neg-frac2N/A
mul-1-negN/A
lower-/.f64N/A
mul-1-negN/A
unpow2N/A
distribute-rgt-neg-inN/A
lower-*.f64N/A
lower-neg.f6484.4
Simplified84.4%
if -8.0000000000000002e-8 < u < 4.70000000000000002e45Initial program 68.4%
Taylor expanded in t1 around inf
associate-*r/N/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f6480.5
Simplified80.5%
Final simplification82.3%
(FPCore (u v t1) :precision binary64 (/ (- v) (fma u (/ u t1) t1)))
double code(double u, double v, double t1) {
return -v / fma(u, (u / t1), t1);
}
function code(u, v, t1) return Float64(Float64(-v) / fma(u, Float64(u / t1), t1)) end
code[u_, v_, t1_] := N[((-v) / N[(u * N[(u / t1), $MachinePrecision] + t1), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{-v}{\mathsf{fma}\left(u, \frac{u}{t1}, t1\right)}
\end{array}
Initial program 76.7%
Taylor expanded in t1 around inf
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
+-commutativeN/A
+-commutativeN/A
unpow2N/A
unpow2N/A
times-fracN/A
distribute-rgt-outN/A
lower-fma.f64N/A
lower-/.f64N/A
lower-+.f64N/A
lower-/.f6455.4
Simplified55.4%
Taylor expanded in v around 0
mul-1-negN/A
lower-neg.f64N/A
lower-/.f64N/A
+-commutativeN/A
distribute-lft-inN/A
*-rgt-identityN/A
lower-fma.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-/.f6488.6
Simplified88.6%
Taylor expanded in u around 0
+-commutativeN/A
lower-fma.f64N/A
lower-+.f64N/A
lower-/.f6495.9
Simplified95.9%
Taylor expanded in u around inf
lower-/.f6494.5
Simplified94.5%
Final simplification94.5%
(FPCore (u v t1) :precision binary64 (let* ((t_1 (/ (* v -0.5) u))) (if (<= u -3.8e+79) t_1 (if (<= u 3.1e+105) (- (/ v t1)) t_1))))
double code(double u, double v, double t1) {
double t_1 = (v * -0.5) / u;
double tmp;
if (u <= -3.8e+79) {
tmp = t_1;
} else if (u <= 3.1e+105) {
tmp = -(v / t1);
} else {
tmp = t_1;
}
return tmp;
}
real(8) function code(u, v, t1)
real(8), intent (in) :: u
real(8), intent (in) :: v
real(8), intent (in) :: t1
real(8) :: t_1
real(8) :: tmp
t_1 = (v * (-0.5d0)) / u
if (u <= (-3.8d+79)) then
tmp = t_1
else if (u <= 3.1d+105) then
tmp = -(v / t1)
else
tmp = t_1
end if
code = tmp
end function
public static double code(double u, double v, double t1) {
double t_1 = (v * -0.5) / u;
double tmp;
if (u <= -3.8e+79) {
tmp = t_1;
} else if (u <= 3.1e+105) {
tmp = -(v / t1);
} else {
tmp = t_1;
}
return tmp;
}
def code(u, v, t1): t_1 = (v * -0.5) / u tmp = 0 if u <= -3.8e+79: tmp = t_1 elif u <= 3.1e+105: tmp = -(v / t1) else: tmp = t_1 return tmp
function code(u, v, t1) t_1 = Float64(Float64(v * -0.5) / u) tmp = 0.0 if (u <= -3.8e+79) tmp = t_1; elseif (u <= 3.1e+105) tmp = Float64(-Float64(v / t1)); else tmp = t_1; end return tmp end
function tmp_2 = code(u, v, t1) t_1 = (v * -0.5) / u; tmp = 0.0; if (u <= -3.8e+79) tmp = t_1; elseif (u <= 3.1e+105) tmp = -(v / t1); else tmp = t_1; end tmp_2 = tmp; end
code[u_, v_, t1_] := Block[{t$95$1 = N[(N[(v * -0.5), $MachinePrecision] / u), $MachinePrecision]}, If[LessEqual[u, -3.8e+79], t$95$1, If[LessEqual[u, 3.1e+105], (-N[(v / t1), $MachinePrecision]), t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{v \cdot -0.5}{u}\\
\mathbf{if}\;u \leq -3.8 \cdot 10^{+79}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;u \leq 3.1 \cdot 10^{+105}:\\
\;\;\;\;-\frac{v}{t1}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if u < -3.8000000000000002e79 or 3.10000000000000004e105 < u Initial program 84.7%
Taylor expanded in t1 around inf
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
+-commutativeN/A
+-commutativeN/A
unpow2N/A
unpow2N/A
times-fracN/A
distribute-rgt-outN/A
lower-fma.f64N/A
lower-/.f64N/A
lower-+.f64N/A
lower-/.f6453.6
Simplified53.6%
Taylor expanded in v around 0
mul-1-negN/A
lower-neg.f64N/A
lower-/.f64N/A
+-commutativeN/A
distribute-lft-inN/A
*-rgt-identityN/A
lower-fma.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-/.f6490.3
Simplified90.3%
Taylor expanded in u around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f6450.5
Simplified50.5%
Taylor expanded in u around inf
associate-*r/N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6445.6
Simplified45.6%
if -3.8000000000000002e79 < u < 3.10000000000000004e105Initial program 72.5%
Taylor expanded in t1 around inf
associate-*r/N/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f6470.5
Simplified70.5%
Final simplification62.0%
(FPCore (u v t1) :precision binary64 (- (/ v (fma u 2.0 t1))))
double code(double u, double v, double t1) {
return -(v / fma(u, 2.0, t1));
}
function code(u, v, t1) return Float64(-Float64(v / fma(u, 2.0, t1))) end
code[u_, v_, t1_] := (-N[(v / N[(u * 2.0 + t1), $MachinePrecision]), $MachinePrecision])
\begin{array}{l}
\\
-\frac{v}{\mathsf{fma}\left(u, 2, t1\right)}
\end{array}
Initial program 76.7%
Taylor expanded in t1 around inf
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
+-commutativeN/A
+-commutativeN/A
unpow2N/A
unpow2N/A
times-fracN/A
distribute-rgt-outN/A
lower-fma.f64N/A
lower-/.f64N/A
lower-+.f64N/A
lower-/.f6455.4
Simplified55.4%
Taylor expanded in v around 0
mul-1-negN/A
lower-neg.f64N/A
lower-/.f64N/A
+-commutativeN/A
distribute-lft-inN/A
*-rgt-identityN/A
lower-fma.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-/.f6488.6
Simplified88.6%
Taylor expanded in u around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f6463.1
Simplified63.1%
(FPCore (u v t1) :precision binary64 (- (/ v t1)))
double code(double u, double v, double t1) {
return -(v / t1);
}
real(8) function code(u, v, t1)
real(8), intent (in) :: u
real(8), intent (in) :: v
real(8), intent (in) :: t1
code = -(v / t1)
end function
public static double code(double u, double v, double t1) {
return -(v / t1);
}
def code(u, v, t1): return -(v / t1)
function code(u, v, t1) return Float64(-Float64(v / t1)) end
function tmp = code(u, v, t1) tmp = -(v / t1); end
code[u_, v_, t1_] := (-N[(v / t1), $MachinePrecision])
\begin{array}{l}
\\
-\frac{v}{t1}
\end{array}
Initial program 76.7%
Taylor expanded in t1 around inf
associate-*r/N/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f6453.9
Simplified53.9%
Final simplification53.9%
herbie shell --seed 2024215
(FPCore (u v t1)
:name "Rosa's DopplerBench"
:precision binary64
(/ (* (- t1) v) (* (+ t1 u) (+ t1 u))))