
(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 7 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) (+ u t1)) (/ t1 (+ u t1))))
double code(double u, double v, double t1) {
return (-v / (u + t1)) * (t1 / (u + 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 / (u + t1)) * (t1 / (u + t1))
end function
public static double code(double u, double v, double t1) {
return (-v / (u + t1)) * (t1 / (u + t1));
}
def code(u, v, t1): return (-v / (u + t1)) * (t1 / (u + t1))
function code(u, v, t1) return Float64(Float64(Float64(-v) / Float64(u + t1)) * Float64(t1 / Float64(u + t1))) end
function tmp = code(u, v, t1) tmp = (-v / (u + t1)) * (t1 / (u + t1)); end
code[u_, v_, t1_] := N[(N[((-v) / N[(u + t1), $MachinePrecision]), $MachinePrecision] * N[(t1 / N[(u + t1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{-v}{u + t1} \cdot \frac{t1}{u + t1}
\end{array}
Initial program 69.5%
Taylor expanded in v around 0
mul-1-negN/A
associate-/l*N/A
*-commutativeN/A
distribute-rgt-neg-inN/A
lower-*.f64N/A
lower-/.f64N/A
lower-pow.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-neg.f6472.3
Applied rewrites72.3%
Applied rewrites98.6%
(FPCore (u v t1)
:precision binary64
(if (<= t1 -5.8e+25)
(/ (* -1.0 v) (+ (- u) t1))
(if (<= t1 1.1e+120)
(* (/ (- v) (* (+ u t1) (+ u t1))) t1)
(/ (- v) (+ u t1)))))
double code(double u, double v, double t1) {
double tmp;
if (t1 <= -5.8e+25) {
tmp = (-1.0 * v) / (-u + t1);
} else if (t1 <= 1.1e+120) {
tmp = (-v / ((u + t1) * (u + t1))) * t1;
} else {
tmp = -v / (u + t1);
}
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) :: tmp
if (t1 <= (-5.8d+25)) then
tmp = ((-1.0d0) * v) / (-u + t1)
else if (t1 <= 1.1d+120) then
tmp = (-v / ((u + t1) * (u + t1))) * t1
else
tmp = -v / (u + t1)
end if
code = tmp
end function
public static double code(double u, double v, double t1) {
double tmp;
if (t1 <= -5.8e+25) {
tmp = (-1.0 * v) / (-u + t1);
} else if (t1 <= 1.1e+120) {
tmp = (-v / ((u + t1) * (u + t1))) * t1;
} else {
tmp = -v / (u + t1);
}
return tmp;
}
def code(u, v, t1): tmp = 0 if t1 <= -5.8e+25: tmp = (-1.0 * v) / (-u + t1) elif t1 <= 1.1e+120: tmp = (-v / ((u + t1) * (u + t1))) * t1 else: tmp = -v / (u + t1) return tmp
function code(u, v, t1) tmp = 0.0 if (t1 <= -5.8e+25) tmp = Float64(Float64(-1.0 * v) / Float64(Float64(-u) + t1)); elseif (t1 <= 1.1e+120) tmp = Float64(Float64(Float64(-v) / Float64(Float64(u + t1) * Float64(u + t1))) * t1); else tmp = Float64(Float64(-v) / Float64(u + t1)); end return tmp end
function tmp_2 = code(u, v, t1) tmp = 0.0; if (t1 <= -5.8e+25) tmp = (-1.0 * v) / (-u + t1); elseif (t1 <= 1.1e+120) tmp = (-v / ((u + t1) * (u + t1))) * t1; else tmp = -v / (u + t1); end tmp_2 = tmp; end
code[u_, v_, t1_] := If[LessEqual[t1, -5.8e+25], N[(N[(-1.0 * v), $MachinePrecision] / N[((-u) + t1), $MachinePrecision]), $MachinePrecision], If[LessEqual[t1, 1.1e+120], N[(N[((-v) / N[(N[(u + t1), $MachinePrecision] * N[(u + t1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * t1), $MachinePrecision], N[((-v) / N[(u + t1), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t1 \leq -5.8 \cdot 10^{+25}:\\
\;\;\;\;\frac{-1 \cdot v}{\left(-u\right) + t1}\\
\mathbf{elif}\;t1 \leq 1.1 \cdot 10^{+120}:\\
\;\;\;\;\frac{-v}{\left(u + t1\right) \cdot \left(u + t1\right)} \cdot t1\\
\mathbf{else}:\\
\;\;\;\;\frac{-v}{u + t1}\\
\end{array}
\end{array}
if t1 < -5.7999999999999998e25Initial program 49.6%
Applied rewrites99.9%
Taylor expanded in u around 0
Applied rewrites96.5%
if -5.7999999999999998e25 < t1 < 1.1000000000000001e120Initial program 83.8%
Taylor expanded in v around 0
mul-1-negN/A
associate-/l*N/A
*-commutativeN/A
distribute-rgt-neg-inN/A
lower-*.f64N/A
lower-/.f64N/A
lower-pow.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-neg.f6488.1
Applied rewrites88.1%
Applied rewrites88.1%
if 1.1000000000000001e120 < t1 Initial program 38.7%
Taylor expanded in v around 0
mul-1-negN/A
associate-/l*N/A
*-commutativeN/A
distribute-rgt-neg-inN/A
lower-*.f64N/A
lower-/.f64N/A
lower-pow.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-neg.f6442.6
Applied rewrites42.6%
Applied rewrites99.9%
Taylor expanded in u around 0
Applied rewrites92.7%
Final simplification90.6%
(FPCore (u v t1) :precision binary64 (if (<= t1 -1.75e-62) (/ (* -1.0 v) (+ (- u) t1)) (if (<= t1 32000000000000.0) (* t1 (/ (/ (- v) u) u)) (/ (- v) (+ u t1)))))
double code(double u, double v, double t1) {
double tmp;
if (t1 <= -1.75e-62) {
tmp = (-1.0 * v) / (-u + t1);
} else if (t1 <= 32000000000000.0) {
tmp = t1 * ((-v / u) / u);
} else {
tmp = -v / (u + t1);
}
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) :: tmp
if (t1 <= (-1.75d-62)) then
tmp = ((-1.0d0) * v) / (-u + t1)
else if (t1 <= 32000000000000.0d0) then
tmp = t1 * ((-v / u) / u)
else
tmp = -v / (u + t1)
end if
code = tmp
end function
public static double code(double u, double v, double t1) {
double tmp;
if (t1 <= -1.75e-62) {
tmp = (-1.0 * v) / (-u + t1);
} else if (t1 <= 32000000000000.0) {
tmp = t1 * ((-v / u) / u);
} else {
tmp = -v / (u + t1);
}
return tmp;
}
def code(u, v, t1): tmp = 0 if t1 <= -1.75e-62: tmp = (-1.0 * v) / (-u + t1) elif t1 <= 32000000000000.0: tmp = t1 * ((-v / u) / u) else: tmp = -v / (u + t1) return tmp
function code(u, v, t1) tmp = 0.0 if (t1 <= -1.75e-62) tmp = Float64(Float64(-1.0 * v) / Float64(Float64(-u) + t1)); elseif (t1 <= 32000000000000.0) tmp = Float64(t1 * Float64(Float64(Float64(-v) / u) / u)); else tmp = Float64(Float64(-v) / Float64(u + t1)); end return tmp end
function tmp_2 = code(u, v, t1) tmp = 0.0; if (t1 <= -1.75e-62) tmp = (-1.0 * v) / (-u + t1); elseif (t1 <= 32000000000000.0) tmp = t1 * ((-v / u) / u); else tmp = -v / (u + t1); end tmp_2 = tmp; end
code[u_, v_, t1_] := If[LessEqual[t1, -1.75e-62], N[(N[(-1.0 * v), $MachinePrecision] / N[((-u) + t1), $MachinePrecision]), $MachinePrecision], If[LessEqual[t1, 32000000000000.0], N[(t1 * N[(N[((-v) / u), $MachinePrecision] / u), $MachinePrecision]), $MachinePrecision], N[((-v) / N[(u + t1), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t1 \leq -1.75 \cdot 10^{-62}:\\
\;\;\;\;\frac{-1 \cdot v}{\left(-u\right) + t1}\\
\mathbf{elif}\;t1 \leq 32000000000000:\\
\;\;\;\;t1 \cdot \frac{\frac{-v}{u}}{u}\\
\mathbf{else}:\\
\;\;\;\;\frac{-v}{u + t1}\\
\end{array}
\end{array}
if t1 < -1.7500000000000001e-62Initial program 62.8%
Applied rewrites99.7%
Taylor expanded in u around 0
Applied rewrites89.5%
if -1.7500000000000001e-62 < t1 < 3.2e13Initial program 79.8%
Taylor expanded in u around inf
mul-1-negN/A
*-commutativeN/A
unpow2N/A
times-fracN/A
distribute-lft-neg-inN/A
lower-*.f64N/A
distribute-frac-negN/A
mul-1-negN/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower-/.f6480.8
Applied rewrites80.8%
Applied rewrites77.6%
Applied rewrites79.7%
if 3.2e13 < t1 Initial program 58.1%
Taylor expanded in v around 0
mul-1-negN/A
associate-/l*N/A
*-commutativeN/A
distribute-rgt-neg-inN/A
lower-*.f64N/A
lower-/.f64N/A
lower-pow.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-neg.f6461.9
Applied rewrites61.9%
Applied rewrites99.9%
Taylor expanded in u around 0
Applied rewrites91.3%
Final simplification85.4%
(FPCore (u v t1) :precision binary64 (if (<= t1 -1.9e-63) (/ (* -1.0 v) (+ (- u) t1)) (if (<= t1 5.6e-136) (* (/ (- v) (* u u)) t1) (/ (- v) (+ u t1)))))
double code(double u, double v, double t1) {
double tmp;
if (t1 <= -1.9e-63) {
tmp = (-1.0 * v) / (-u + t1);
} else if (t1 <= 5.6e-136) {
tmp = (-v / (u * u)) * t1;
} else {
tmp = -v / (u + t1);
}
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) :: tmp
if (t1 <= (-1.9d-63)) then
tmp = ((-1.0d0) * v) / (-u + t1)
else if (t1 <= 5.6d-136) then
tmp = (-v / (u * u)) * t1
else
tmp = -v / (u + t1)
end if
code = tmp
end function
public static double code(double u, double v, double t1) {
double tmp;
if (t1 <= -1.9e-63) {
tmp = (-1.0 * v) / (-u + t1);
} else if (t1 <= 5.6e-136) {
tmp = (-v / (u * u)) * t1;
} else {
tmp = -v / (u + t1);
}
return tmp;
}
def code(u, v, t1): tmp = 0 if t1 <= -1.9e-63: tmp = (-1.0 * v) / (-u + t1) elif t1 <= 5.6e-136: tmp = (-v / (u * u)) * t1 else: tmp = -v / (u + t1) return tmp
function code(u, v, t1) tmp = 0.0 if (t1 <= -1.9e-63) tmp = Float64(Float64(-1.0 * v) / Float64(Float64(-u) + t1)); elseif (t1 <= 5.6e-136) tmp = Float64(Float64(Float64(-v) / Float64(u * u)) * t1); else tmp = Float64(Float64(-v) / Float64(u + t1)); end return tmp end
function tmp_2 = code(u, v, t1) tmp = 0.0; if (t1 <= -1.9e-63) tmp = (-1.0 * v) / (-u + t1); elseif (t1 <= 5.6e-136) tmp = (-v / (u * u)) * t1; else tmp = -v / (u + t1); end tmp_2 = tmp; end
code[u_, v_, t1_] := If[LessEqual[t1, -1.9e-63], N[(N[(-1.0 * v), $MachinePrecision] / N[((-u) + t1), $MachinePrecision]), $MachinePrecision], If[LessEqual[t1, 5.6e-136], N[(N[((-v) / N[(u * u), $MachinePrecision]), $MachinePrecision] * t1), $MachinePrecision], N[((-v) / N[(u + t1), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t1 \leq -1.9 \cdot 10^{-63}:\\
\;\;\;\;\frac{-1 \cdot v}{\left(-u\right) + t1}\\
\mathbf{elif}\;t1 \leq 5.6 \cdot 10^{-136}:\\
\;\;\;\;\frac{-v}{u \cdot u} \cdot t1\\
\mathbf{else}:\\
\;\;\;\;\frac{-v}{u + t1}\\
\end{array}
\end{array}
if t1 < -1.90000000000000009e-63Initial program 62.6%
Applied rewrites99.7%
Taylor expanded in u around 0
Applied rewrites88.5%
if -1.90000000000000009e-63 < t1 < 5.6000000000000002e-136Initial program 79.8%
Taylor expanded in v around 0
mul-1-negN/A
associate-/l*N/A
*-commutativeN/A
distribute-rgt-neg-inN/A
lower-*.f64N/A
lower-/.f64N/A
lower-pow.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-neg.f6485.8
Applied rewrites85.8%
Taylor expanded in u around inf
Applied rewrites80.9%
if 5.6000000000000002e-136 < t1 Initial program 63.4%
Taylor expanded in v around 0
mul-1-negN/A
associate-/l*N/A
*-commutativeN/A
distribute-rgt-neg-inN/A
lower-*.f64N/A
lower-/.f64N/A
lower-pow.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-neg.f6466.5
Applied rewrites66.5%
Applied rewrites99.9%
Taylor expanded in u around 0
Applied rewrites83.9%
Final simplification84.1%
(FPCore (u v t1) :precision binary64 (if (<= t1 -1.9e-63) (/ (* -1.0 v) (+ (- u) t1)) (if (<= t1 5.6e-136) (* (- v) (/ t1 (* u u))) (/ (- v) (+ u t1)))))
double code(double u, double v, double t1) {
double tmp;
if (t1 <= -1.9e-63) {
tmp = (-1.0 * v) / (-u + t1);
} else if (t1 <= 5.6e-136) {
tmp = -v * (t1 / (u * u));
} else {
tmp = -v / (u + t1);
}
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) :: tmp
if (t1 <= (-1.9d-63)) then
tmp = ((-1.0d0) * v) / (-u + t1)
else if (t1 <= 5.6d-136) then
tmp = -v * (t1 / (u * u))
else
tmp = -v / (u + t1)
end if
code = tmp
end function
public static double code(double u, double v, double t1) {
double tmp;
if (t1 <= -1.9e-63) {
tmp = (-1.0 * v) / (-u + t1);
} else if (t1 <= 5.6e-136) {
tmp = -v * (t1 / (u * u));
} else {
tmp = -v / (u + t1);
}
return tmp;
}
def code(u, v, t1): tmp = 0 if t1 <= -1.9e-63: tmp = (-1.0 * v) / (-u + t1) elif t1 <= 5.6e-136: tmp = -v * (t1 / (u * u)) else: tmp = -v / (u + t1) return tmp
function code(u, v, t1) tmp = 0.0 if (t1 <= -1.9e-63) tmp = Float64(Float64(-1.0 * v) / Float64(Float64(-u) + t1)); elseif (t1 <= 5.6e-136) tmp = Float64(Float64(-v) * Float64(t1 / Float64(u * u))); else tmp = Float64(Float64(-v) / Float64(u + t1)); end return tmp end
function tmp_2 = code(u, v, t1) tmp = 0.0; if (t1 <= -1.9e-63) tmp = (-1.0 * v) / (-u + t1); elseif (t1 <= 5.6e-136) tmp = -v * (t1 / (u * u)); else tmp = -v / (u + t1); end tmp_2 = tmp; end
code[u_, v_, t1_] := If[LessEqual[t1, -1.9e-63], N[(N[(-1.0 * v), $MachinePrecision] / N[((-u) + t1), $MachinePrecision]), $MachinePrecision], If[LessEqual[t1, 5.6e-136], N[((-v) * N[(t1 / N[(u * u), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[((-v) / N[(u + t1), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t1 \leq -1.9 \cdot 10^{-63}:\\
\;\;\;\;\frac{-1 \cdot v}{\left(-u\right) + t1}\\
\mathbf{elif}\;t1 \leq 5.6 \cdot 10^{-136}:\\
\;\;\;\;\left(-v\right) \cdot \frac{t1}{u \cdot u}\\
\mathbf{else}:\\
\;\;\;\;\frac{-v}{u + t1}\\
\end{array}
\end{array}
if t1 < -1.90000000000000009e-63Initial program 62.6%
Applied rewrites99.7%
Taylor expanded in u around 0
Applied rewrites88.5%
if -1.90000000000000009e-63 < t1 < 5.6000000000000002e-136Initial program 79.8%
Taylor expanded in u around inf
mul-1-negN/A
*-commutativeN/A
unpow2N/A
times-fracN/A
distribute-lft-neg-inN/A
lower-*.f64N/A
distribute-frac-negN/A
mul-1-negN/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower-/.f6485.5
Applied rewrites85.5%
Applied rewrites79.5%
if 5.6000000000000002e-136 < t1 Initial program 63.4%
Taylor expanded in v around 0
mul-1-negN/A
associate-/l*N/A
*-commutativeN/A
distribute-rgt-neg-inN/A
lower-*.f64N/A
lower-/.f64N/A
lower-pow.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-neg.f6466.5
Applied rewrites66.5%
Applied rewrites99.9%
Taylor expanded in u around 0
Applied rewrites83.9%
Final simplification83.5%
(FPCore (u v t1) :precision binary64 (/ (- v) (+ u t1)))
double code(double u, double v, double t1) {
return -v / (u + 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 / (u + t1)
end function
public static double code(double u, double v, double t1) {
return -v / (u + t1);
}
def code(u, v, t1): return -v / (u + t1)
function code(u, v, t1) return Float64(Float64(-v) / Float64(u + t1)) end
function tmp = code(u, v, t1) tmp = -v / (u + t1); end
code[u_, v_, t1_] := N[((-v) / N[(u + t1), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{-v}{u + t1}
\end{array}
Initial program 69.5%
Taylor expanded in v around 0
mul-1-negN/A
associate-/l*N/A
*-commutativeN/A
distribute-rgt-neg-inN/A
lower-*.f64N/A
lower-/.f64N/A
lower-pow.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-neg.f6472.3
Applied rewrites72.3%
Applied rewrites98.6%
Taylor expanded in u around 0
Applied rewrites66.2%
(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 69.5%
Taylor expanded in u around 0
associate-*r/N/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f6456.8
Applied rewrites56.8%
herbie shell --seed 2024326
(FPCore (u v t1)
:name "Rosa's DopplerBench"
:precision binary64
(/ (* (- t1) v) (* (+ t1 u) (+ t1 u))))