
(FPCore (v w r) :precision binary64 (- (- (+ 3.0 (/ 2.0 (* r r))) (/ (* (* 0.125 (- 3.0 (* 2.0 v))) (* (* (* w w) r) r)) (- 1.0 v))) 4.5))
double code(double v, double w, double r) {
return ((3.0 + (2.0 / (r * r))) - (((0.125 * (3.0 - (2.0 * v))) * (((w * w) * r) * r)) / (1.0 - v))) - 4.5;
}
real(8) function code(v, w, r)
real(8), intent (in) :: v
real(8), intent (in) :: w
real(8), intent (in) :: r
code = ((3.0d0 + (2.0d0 / (r * r))) - (((0.125d0 * (3.0d0 - (2.0d0 * v))) * (((w * w) * r) * r)) / (1.0d0 - v))) - 4.5d0
end function
public static double code(double v, double w, double r) {
return ((3.0 + (2.0 / (r * r))) - (((0.125 * (3.0 - (2.0 * v))) * (((w * w) * r) * r)) / (1.0 - v))) - 4.5;
}
def code(v, w, r): return ((3.0 + (2.0 / (r * r))) - (((0.125 * (3.0 - (2.0 * v))) * (((w * w) * r) * r)) / (1.0 - v))) - 4.5
function code(v, w, r) return Float64(Float64(Float64(3.0 + Float64(2.0 / Float64(r * r))) - Float64(Float64(Float64(0.125 * Float64(3.0 - Float64(2.0 * v))) * Float64(Float64(Float64(w * w) * r) * r)) / Float64(1.0 - v))) - 4.5) end
function tmp = code(v, w, r) tmp = ((3.0 + (2.0 / (r * r))) - (((0.125 * (3.0 - (2.0 * v))) * (((w * w) * r) * r)) / (1.0 - v))) - 4.5; end
code[v_, w_, r_] := N[(N[(N[(3.0 + N[(2.0 / N[(r * r), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(N[(N[(0.125 * N[(3.0 - N[(2.0 * v), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[(N[(w * w), $MachinePrecision] * r), $MachinePrecision] * r), $MachinePrecision]), $MachinePrecision] / N[(1.0 - v), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 4.5), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(3 + \frac{2}{r \cdot r}\right) - \frac{\left(0.125 \cdot \left(3 - 2 \cdot v\right)\right) \cdot \left(\left(\left(w \cdot w\right) \cdot r\right) \cdot r\right)}{1 - v}\right) - 4.5
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 5 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (v w r) :precision binary64 (- (- (+ 3.0 (/ 2.0 (* r r))) (/ (* (* 0.125 (- 3.0 (* 2.0 v))) (* (* (* w w) r) r)) (- 1.0 v))) 4.5))
double code(double v, double w, double r) {
return ((3.0 + (2.0 / (r * r))) - (((0.125 * (3.0 - (2.0 * v))) * (((w * w) * r) * r)) / (1.0 - v))) - 4.5;
}
real(8) function code(v, w, r)
real(8), intent (in) :: v
real(8), intent (in) :: w
real(8), intent (in) :: r
code = ((3.0d0 + (2.0d0 / (r * r))) - (((0.125d0 * (3.0d0 - (2.0d0 * v))) * (((w * w) * r) * r)) / (1.0d0 - v))) - 4.5d0
end function
public static double code(double v, double w, double r) {
return ((3.0 + (2.0 / (r * r))) - (((0.125 * (3.0 - (2.0 * v))) * (((w * w) * r) * r)) / (1.0 - v))) - 4.5;
}
def code(v, w, r): return ((3.0 + (2.0 / (r * r))) - (((0.125 * (3.0 - (2.0 * v))) * (((w * w) * r) * r)) / (1.0 - v))) - 4.5
function code(v, w, r) return Float64(Float64(Float64(3.0 + Float64(2.0 / Float64(r * r))) - Float64(Float64(Float64(0.125 * Float64(3.0 - Float64(2.0 * v))) * Float64(Float64(Float64(w * w) * r) * r)) / Float64(1.0 - v))) - 4.5) end
function tmp = code(v, w, r) tmp = ((3.0 + (2.0 / (r * r))) - (((0.125 * (3.0 - (2.0 * v))) * (((w * w) * r) * r)) / (1.0 - v))) - 4.5; end
code[v_, w_, r_] := N[(N[(N[(3.0 + N[(2.0 / N[(r * r), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(N[(N[(0.125 * N[(3.0 - N[(2.0 * v), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[(N[(w * w), $MachinePrecision] * r), $MachinePrecision] * r), $MachinePrecision]), $MachinePrecision] / N[(1.0 - v), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 4.5), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(3 + \frac{2}{r \cdot r}\right) - \frac{\left(0.125 \cdot \left(3 - 2 \cdot v\right)\right) \cdot \left(\left(\left(w \cdot w\right) \cdot r\right) \cdot r\right)}{1 - v}\right) - 4.5
\end{array}
(FPCore (v w r) :precision binary64 (if (or (<= v -5400000000.0) (not (<= v 2e-47))) (+ -1.5 (+ (/ 2.0 (* r r)) (* (* r (* w (* r w))) -0.25))) (+ (/ (/ 2.0 r) r) (- -1.5 (* (* r w) (* r (* w 0.375)))))))
double code(double v, double w, double r) {
double tmp;
if ((v <= -5400000000.0) || !(v <= 2e-47)) {
tmp = -1.5 + ((2.0 / (r * r)) + ((r * (w * (r * w))) * -0.25));
} else {
tmp = ((2.0 / r) / r) + (-1.5 - ((r * w) * (r * (w * 0.375))));
}
return tmp;
}
real(8) function code(v, w, r)
real(8), intent (in) :: v
real(8), intent (in) :: w
real(8), intent (in) :: r
real(8) :: tmp
if ((v <= (-5400000000.0d0)) .or. (.not. (v <= 2d-47))) then
tmp = (-1.5d0) + ((2.0d0 / (r * r)) + ((r * (w * (r * w))) * (-0.25d0)))
else
tmp = ((2.0d0 / r) / r) + ((-1.5d0) - ((r * w) * (r * (w * 0.375d0))))
end if
code = tmp
end function
public static double code(double v, double w, double r) {
double tmp;
if ((v <= -5400000000.0) || !(v <= 2e-47)) {
tmp = -1.5 + ((2.0 / (r * r)) + ((r * (w * (r * w))) * -0.25));
} else {
tmp = ((2.0 / r) / r) + (-1.5 - ((r * w) * (r * (w * 0.375))));
}
return tmp;
}
def code(v, w, r): tmp = 0 if (v <= -5400000000.0) or not (v <= 2e-47): tmp = -1.5 + ((2.0 / (r * r)) + ((r * (w * (r * w))) * -0.25)) else: tmp = ((2.0 / r) / r) + (-1.5 - ((r * w) * (r * (w * 0.375)))) return tmp
function code(v, w, r) tmp = 0.0 if ((v <= -5400000000.0) || !(v <= 2e-47)) tmp = Float64(-1.5 + Float64(Float64(2.0 / Float64(r * r)) + Float64(Float64(r * Float64(w * Float64(r * w))) * -0.25))); else tmp = Float64(Float64(Float64(2.0 / r) / r) + Float64(-1.5 - Float64(Float64(r * w) * Float64(r * Float64(w * 0.375))))); end return tmp end
function tmp_2 = code(v, w, r) tmp = 0.0; if ((v <= -5400000000.0) || ~((v <= 2e-47))) tmp = -1.5 + ((2.0 / (r * r)) + ((r * (w * (r * w))) * -0.25)); else tmp = ((2.0 / r) / r) + (-1.5 - ((r * w) * (r * (w * 0.375)))); end tmp_2 = tmp; end
code[v_, w_, r_] := If[Or[LessEqual[v, -5400000000.0], N[Not[LessEqual[v, 2e-47]], $MachinePrecision]], N[(-1.5 + N[(N[(2.0 / N[(r * r), $MachinePrecision]), $MachinePrecision] + N[(N[(r * N[(w * N[(r * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * -0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(2.0 / r), $MachinePrecision] / r), $MachinePrecision] + N[(-1.5 - N[(N[(r * w), $MachinePrecision] * N[(r * N[(w * 0.375), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;v \leq -5400000000 \lor \neg \left(v \leq 2 \cdot 10^{-47}\right):\\
\;\;\;\;-1.5 + \left(\frac{2}{r \cdot r} + \left(r \cdot \left(w \cdot \left(r \cdot w\right)\right)\right) \cdot -0.25\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{2}{r}}{r} + \left(-1.5 - \left(r \cdot w\right) \cdot \left(r \cdot \left(w \cdot 0.375\right)\right)\right)\\
\end{array}
\end{array}
if v < -5.4e9 or 1.9999999999999999e-47 < v Initial program 87.1%
Simplified83.7%
Taylor expanded in v around inf 86.1%
*-commutative86.1%
*-commutative86.1%
unpow286.1%
unpow286.1%
swap-sqr99.7%
unpow299.7%
*-commutative99.7%
Simplified99.7%
unpow299.7%
*-commutative99.7%
associate-*r*99.8%
Applied egg-rr99.8%
if -5.4e9 < v < 1.9999999999999999e-47Initial program 83.7%
Simplified96.5%
frac-2neg96.5%
*-commutative96.5%
associate-*r*83.7%
div-inv83.7%
associate-*r*96.5%
*-commutative96.5%
associate-*r*99.8%
pow299.8%
*-commutative99.8%
Applied egg-rr99.8%
associate-*r/99.8%
*-rgt-identity99.8%
neg-sub099.8%
fma-udef99.8%
*-commutative99.8%
+-commutative99.8%
associate--r+99.8%
metadata-eval99.8%
*-commutative99.8%
distribute-neg-frac99.8%
neg-sub099.8%
associate--r-99.8%
metadata-eval99.8%
*-commutative99.8%
Simplified99.8%
associate-/r/99.8%
unpow299.8%
associate-*r*99.8%
sub-neg99.8%
distribute-rgt-neg-in99.8%
metadata-eval99.8%
Applied egg-rr99.8%
Taylor expanded in v around 0 99.8%
associate-*r*99.8%
Simplified99.8%
Taylor expanded in r around 0 99.8%
*-commutative99.8%
associate-*r*99.9%
Simplified99.9%
Final simplification99.8%
(FPCore (v w r) :precision binary64 (if (or (<= v -2250000000.0) (not (<= v 1.2e-46))) (+ -1.5 (+ (/ 2.0 (* r r)) (* (* r (* w (* r w))) -0.25))) (+ (/ (/ 2.0 r) r) (- -1.5 (* (* r w) (* (* r w) 0.375))))))
double code(double v, double w, double r) {
double tmp;
if ((v <= -2250000000.0) || !(v <= 1.2e-46)) {
tmp = -1.5 + ((2.0 / (r * r)) + ((r * (w * (r * w))) * -0.25));
} else {
tmp = ((2.0 / r) / r) + (-1.5 - ((r * w) * ((r * w) * 0.375)));
}
return tmp;
}
real(8) function code(v, w, r)
real(8), intent (in) :: v
real(8), intent (in) :: w
real(8), intent (in) :: r
real(8) :: tmp
if ((v <= (-2250000000.0d0)) .or. (.not. (v <= 1.2d-46))) then
tmp = (-1.5d0) + ((2.0d0 / (r * r)) + ((r * (w * (r * w))) * (-0.25d0)))
else
tmp = ((2.0d0 / r) / r) + ((-1.5d0) - ((r * w) * ((r * w) * 0.375d0)))
end if
code = tmp
end function
public static double code(double v, double w, double r) {
double tmp;
if ((v <= -2250000000.0) || !(v <= 1.2e-46)) {
tmp = -1.5 + ((2.0 / (r * r)) + ((r * (w * (r * w))) * -0.25));
} else {
tmp = ((2.0 / r) / r) + (-1.5 - ((r * w) * ((r * w) * 0.375)));
}
return tmp;
}
def code(v, w, r): tmp = 0 if (v <= -2250000000.0) or not (v <= 1.2e-46): tmp = -1.5 + ((2.0 / (r * r)) + ((r * (w * (r * w))) * -0.25)) else: tmp = ((2.0 / r) / r) + (-1.5 - ((r * w) * ((r * w) * 0.375))) return tmp
function code(v, w, r) tmp = 0.0 if ((v <= -2250000000.0) || !(v <= 1.2e-46)) tmp = Float64(-1.5 + Float64(Float64(2.0 / Float64(r * r)) + Float64(Float64(r * Float64(w * Float64(r * w))) * -0.25))); else tmp = Float64(Float64(Float64(2.0 / r) / r) + Float64(-1.5 - Float64(Float64(r * w) * Float64(Float64(r * w) * 0.375)))); end return tmp end
function tmp_2 = code(v, w, r) tmp = 0.0; if ((v <= -2250000000.0) || ~((v <= 1.2e-46))) tmp = -1.5 + ((2.0 / (r * r)) + ((r * (w * (r * w))) * -0.25)); else tmp = ((2.0 / r) / r) + (-1.5 - ((r * w) * ((r * w) * 0.375))); end tmp_2 = tmp; end
code[v_, w_, r_] := If[Or[LessEqual[v, -2250000000.0], N[Not[LessEqual[v, 1.2e-46]], $MachinePrecision]], N[(-1.5 + N[(N[(2.0 / N[(r * r), $MachinePrecision]), $MachinePrecision] + N[(N[(r * N[(w * N[(r * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * -0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(2.0 / r), $MachinePrecision] / r), $MachinePrecision] + N[(-1.5 - N[(N[(r * w), $MachinePrecision] * N[(N[(r * w), $MachinePrecision] * 0.375), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;v \leq -2250000000 \lor \neg \left(v \leq 1.2 \cdot 10^{-46}\right):\\
\;\;\;\;-1.5 + \left(\frac{2}{r \cdot r} + \left(r \cdot \left(w \cdot \left(r \cdot w\right)\right)\right) \cdot -0.25\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{2}{r}}{r} + \left(-1.5 - \left(r \cdot w\right) \cdot \left(\left(r \cdot w\right) \cdot 0.375\right)\right)\\
\end{array}
\end{array}
if v < -2.25e9 or 1.20000000000000007e-46 < v Initial program 87.1%
Simplified83.7%
Taylor expanded in v around inf 86.1%
*-commutative86.1%
*-commutative86.1%
unpow286.1%
unpow286.1%
swap-sqr99.7%
unpow299.7%
*-commutative99.7%
Simplified99.7%
unpow299.7%
*-commutative99.7%
associate-*r*99.8%
Applied egg-rr99.8%
if -2.25e9 < v < 1.20000000000000007e-46Initial program 83.7%
Simplified96.5%
frac-2neg96.5%
*-commutative96.5%
associate-*r*83.7%
div-inv83.7%
associate-*r*96.5%
*-commutative96.5%
associate-*r*99.8%
pow299.8%
*-commutative99.8%
Applied egg-rr99.8%
associate-*r/99.8%
*-rgt-identity99.8%
neg-sub099.8%
fma-udef99.8%
*-commutative99.8%
+-commutative99.8%
associate--r+99.8%
metadata-eval99.8%
*-commutative99.8%
distribute-neg-frac99.8%
neg-sub099.8%
associate--r-99.8%
metadata-eval99.8%
*-commutative99.8%
Simplified99.8%
associate-/r/99.8%
unpow299.8%
associate-*r*99.8%
sub-neg99.8%
distribute-rgt-neg-in99.8%
metadata-eval99.8%
Applied egg-rr99.8%
Taylor expanded in v around 0 99.8%
Final simplification99.8%
(FPCore (v w r) :precision binary64 (+ (/ (/ 2.0 r) r) (- -1.5 (* (* r w) (* (/ (+ -0.375 (* v 0.25)) (+ v -1.0)) (* r w))))))
double code(double v, double w, double r) {
return ((2.0 / r) / r) + (-1.5 - ((r * w) * (((-0.375 + (v * 0.25)) / (v + -1.0)) * (r * w))));
}
real(8) function code(v, w, r)
real(8), intent (in) :: v
real(8), intent (in) :: w
real(8), intent (in) :: r
code = ((2.0d0 / r) / r) + ((-1.5d0) - ((r * w) * ((((-0.375d0) + (v * 0.25d0)) / (v + (-1.0d0))) * (r * w))))
end function
public static double code(double v, double w, double r) {
return ((2.0 / r) / r) + (-1.5 - ((r * w) * (((-0.375 + (v * 0.25)) / (v + -1.0)) * (r * w))));
}
def code(v, w, r): return ((2.0 / r) / r) + (-1.5 - ((r * w) * (((-0.375 + (v * 0.25)) / (v + -1.0)) * (r * w))))
function code(v, w, r) return Float64(Float64(Float64(2.0 / r) / r) + Float64(-1.5 - Float64(Float64(r * w) * Float64(Float64(Float64(-0.375 + Float64(v * 0.25)) / Float64(v + -1.0)) * Float64(r * w))))) end
function tmp = code(v, w, r) tmp = ((2.0 / r) / r) + (-1.5 - ((r * w) * (((-0.375 + (v * 0.25)) / (v + -1.0)) * (r * w)))); end
code[v_, w_, r_] := N[(N[(N[(2.0 / r), $MachinePrecision] / r), $MachinePrecision] + N[(-1.5 - N[(N[(r * w), $MachinePrecision] * N[(N[(N[(-0.375 + N[(v * 0.25), $MachinePrecision]), $MachinePrecision] / N[(v + -1.0), $MachinePrecision]), $MachinePrecision] * N[(r * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{2}{r}}{r} + \left(-1.5 - \left(r \cdot w\right) \cdot \left(\frac{-0.375 + v \cdot 0.25}{v + -1} \cdot \left(r \cdot w\right)\right)\right)
\end{array}
Initial program 85.5%
Simplified98.3%
frac-2neg98.3%
*-commutative98.3%
associate-*r*87.2%
div-inv87.2%
associate-*r*98.3%
*-commutative98.3%
associate-*r*99.8%
pow299.8%
*-commutative99.8%
Applied egg-rr99.8%
associate-*r/99.8%
*-rgt-identity99.8%
neg-sub099.8%
fma-udef99.8%
*-commutative99.8%
+-commutative99.8%
associate--r+99.8%
metadata-eval99.8%
*-commutative99.8%
distribute-neg-frac99.8%
neg-sub099.8%
associate--r-99.8%
metadata-eval99.8%
*-commutative99.8%
Simplified99.8%
associate-/r/99.8%
unpow299.8%
associate-*r*99.8%
sub-neg99.8%
distribute-rgt-neg-in99.8%
metadata-eval99.8%
Applied egg-rr99.8%
Final simplification99.8%
(FPCore (v w r) :precision binary64 (+ -1.5 (+ (/ 2.0 (* r r)) (* -0.25 (* (* r w) (* r w))))))
double code(double v, double w, double r) {
return -1.5 + ((2.0 / (r * r)) + (-0.25 * ((r * w) * (r * w))));
}
real(8) function code(v, w, r)
real(8), intent (in) :: v
real(8), intent (in) :: w
real(8), intent (in) :: r
code = (-1.5d0) + ((2.0d0 / (r * r)) + ((-0.25d0) * ((r * w) * (r * w))))
end function
public static double code(double v, double w, double r) {
return -1.5 + ((2.0 / (r * r)) + (-0.25 * ((r * w) * (r * w))));
}
def code(v, w, r): return -1.5 + ((2.0 / (r * r)) + (-0.25 * ((r * w) * (r * w))))
function code(v, w, r) return Float64(-1.5 + Float64(Float64(2.0 / Float64(r * r)) + Float64(-0.25 * Float64(Float64(r * w) * Float64(r * w))))) end
function tmp = code(v, w, r) tmp = -1.5 + ((2.0 / (r * r)) + (-0.25 * ((r * w) * (r * w)))); end
code[v_, w_, r_] := N[(-1.5 + N[(N[(2.0 / N[(r * r), $MachinePrecision]), $MachinePrecision] + N[(-0.25 * N[(N[(r * w), $MachinePrecision] * N[(r * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
-1.5 + \left(\frac{2}{r \cdot r} + -0.25 \cdot \left(\left(r \cdot w\right) \cdot \left(r \cdot w\right)\right)\right)
\end{array}
Initial program 85.5%
Simplified81.4%
Taylor expanded in v around inf 80.4%
*-commutative80.4%
*-commutative80.4%
unpow280.4%
unpow280.4%
swap-sqr95.1%
unpow295.1%
*-commutative95.1%
Simplified95.1%
unpow295.1%
Applied egg-rr95.1%
Final simplification95.1%
(FPCore (v w r) :precision binary64 (+ (/ (/ 2.0 r) r) -1.5))
double code(double v, double w, double r) {
return ((2.0 / r) / r) + -1.5;
}
real(8) function code(v, w, r)
real(8), intent (in) :: v
real(8), intent (in) :: w
real(8), intent (in) :: r
code = ((2.0d0 / r) / r) + (-1.5d0)
end function
public static double code(double v, double w, double r) {
return ((2.0 / r) / r) + -1.5;
}
def code(v, w, r): return ((2.0 / r) / r) + -1.5
function code(v, w, r) return Float64(Float64(Float64(2.0 / r) / r) + -1.5) end
function tmp = code(v, w, r) tmp = ((2.0 / r) / r) + -1.5; end
code[v_, w_, r_] := N[(N[(N[(2.0 / r), $MachinePrecision] / r), $MachinePrecision] + -1.5), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{2}{r}}{r} + -1.5
\end{array}
Initial program 85.5%
Simplified98.3%
frac-2neg98.3%
*-commutative98.3%
associate-*r*87.2%
div-inv87.2%
associate-*r*98.3%
*-commutative98.3%
associate-*r*99.8%
pow299.8%
*-commutative99.8%
Applied egg-rr99.8%
associate-*r/99.8%
*-rgt-identity99.8%
neg-sub099.8%
fma-udef99.8%
*-commutative99.8%
+-commutative99.8%
associate--r+99.8%
metadata-eval99.8%
*-commutative99.8%
distribute-neg-frac99.8%
neg-sub099.8%
associate--r-99.8%
metadata-eval99.8%
*-commutative99.8%
Simplified99.8%
associate-/r/99.8%
unpow299.8%
associate-*r*99.8%
sub-neg99.8%
distribute-rgt-neg-in99.8%
metadata-eval99.8%
Applied egg-rr99.8%
Taylor expanded in r around 0 56.5%
Final simplification56.5%
herbie shell --seed 2024031
(FPCore (v w r)
:name "Rosa's TurbineBenchmark"
:precision binary64
(- (- (+ 3.0 (/ 2.0 (* r r))) (/ (* (* 0.125 (- 3.0 (* 2.0 v))) (* (* (* w w) r) r)) (- 1.0 v))) 4.5))