
(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 7 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 (+ (/ (/ 2.0 r) r) (+ -1.5 (/ -1.0 (/ (/ (- 1.0 v) (* (* r w) (* r w))) (fma v -0.25 0.375))))))
double code(double v, double w, double r) {
return ((2.0 / r) / r) + (-1.5 + (-1.0 / (((1.0 - v) / ((r * w) * (r * w))) / fma(v, -0.25, 0.375))));
}
function code(v, w, r) return Float64(Float64(Float64(2.0 / r) / r) + Float64(-1.5 + Float64(-1.0 / Float64(Float64(Float64(1.0 - v) / Float64(Float64(r * w) * Float64(r * w))) / fma(v, -0.25, 0.375))))) end
code[v_, w_, r_] := N[(N[(N[(2.0 / r), $MachinePrecision] / r), $MachinePrecision] + N[(-1.5 + N[(-1.0 / N[(N[(N[(1.0 - v), $MachinePrecision] / N[(N[(r * w), $MachinePrecision] * N[(r * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(v * -0.25 + 0.375), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{2}{r}}{r} + \left(-1.5 + \frac{-1}{\frac{\frac{1 - v}{\left(r \cdot w\right) \cdot \left(r \cdot w\right)}}{\mathsf{fma}\left(v, -0.25, 0.375\right)}}\right)
\end{array}
Initial program 83.9%
Simplified96.3%
*-commutative96.3%
clear-num96.3%
*-commutative96.3%
associate-*r*86.5%
un-div-inv86.5%
fma-udef86.5%
metadata-eval86.5%
associate-*l*86.5%
*-commutative86.5%
metadata-eval86.5%
distribute-rgt-in86.5%
+-commutative86.5%
clear-num86.5%
Applied egg-rr99.8%
unpow299.8%
Applied egg-rr99.8%
Final simplification99.8%
(FPCore (v w r)
:precision binary64
(+
(+
3.0
(-
(/ 2.0 (* r r))
(/
(* 0.125 (+ 3.0 (* v -2.0)))
(* (/ 1.0 (* r w)) (/ (- 1.0 v) (* r w))))))
-4.5))
double code(double v, double w, double r) {
return (3.0 + ((2.0 / (r * r)) - ((0.125 * (3.0 + (v * -2.0))) / ((1.0 / (r * w)) * ((1.0 - v) / (r * w)))))) + -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 + (v * (-2.0d0)))) / ((1.0d0 / (r * w)) * ((1.0d0 - v) / (r * w)))))) + (-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 + (v * -2.0))) / ((1.0 / (r * w)) * ((1.0 - v) / (r * w)))))) + -4.5;
}
def code(v, w, r): return (3.0 + ((2.0 / (r * r)) - ((0.125 * (3.0 + (v * -2.0))) / ((1.0 / (r * w)) * ((1.0 - v) / (r * w)))))) + -4.5
function code(v, w, r) return Float64(Float64(3.0 + Float64(Float64(2.0 / Float64(r * r)) - Float64(Float64(0.125 * Float64(3.0 + Float64(v * -2.0))) / Float64(Float64(1.0 / Float64(r * w)) * Float64(Float64(1.0 - v) / Float64(r * w)))))) + -4.5) end
function tmp = code(v, w, r) tmp = (3.0 + ((2.0 / (r * r)) - ((0.125 * (3.0 + (v * -2.0))) / ((1.0 / (r * w)) * ((1.0 - v) / (r * w)))))) + -4.5; end
code[v_, w_, r_] := N[(N[(3.0 + N[(N[(2.0 / N[(r * r), $MachinePrecision]), $MachinePrecision] - N[(N[(0.125 * N[(3.0 + N[(v * -2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[(1.0 / N[(r * w), $MachinePrecision]), $MachinePrecision] * N[(N[(1.0 - v), $MachinePrecision] / N[(r * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -4.5), $MachinePrecision]
\begin{array}{l}
\\
\left(3 + \left(\frac{2}{r \cdot r} - \frac{0.125 \cdot \left(3 + v \cdot -2\right)}{\frac{1}{r \cdot w} \cdot \frac{1 - v}{r \cdot w}}\right)\right) + -4.5
\end{array}
Initial program 83.9%
Simplified86.5%
associate-*r*96.3%
*-commutative96.3%
*-un-lft-identity96.3%
associate-*r*99.8%
times-frac99.8%
Applied egg-rr99.8%
Final simplification99.8%
(FPCore (v w r)
:precision binary64
(let* ((t_0 (/ 1.0 (* r w))))
(+
(/ (/ 2.0 r) r)
(+ -1.5 (/ -1.0 (/ (* (* t_0 t_0) (+ v -1.0)) (- -0.375 (* v -0.25))))))))
double code(double v, double w, double r) {
double t_0 = 1.0 / (r * w);
return ((2.0 / r) / r) + (-1.5 + (-1.0 / (((t_0 * t_0) * (v + -1.0)) / (-0.375 - (v * -0.25)))));
}
real(8) function code(v, w, r)
real(8), intent (in) :: v
real(8), intent (in) :: w
real(8), intent (in) :: r
real(8) :: t_0
t_0 = 1.0d0 / (r * w)
code = ((2.0d0 / r) / r) + ((-1.5d0) + ((-1.0d0) / (((t_0 * t_0) * (v + (-1.0d0))) / ((-0.375d0) - (v * (-0.25d0))))))
end function
public static double code(double v, double w, double r) {
double t_0 = 1.0 / (r * w);
return ((2.0 / r) / r) + (-1.5 + (-1.0 / (((t_0 * t_0) * (v + -1.0)) / (-0.375 - (v * -0.25)))));
}
def code(v, w, r): t_0 = 1.0 / (r * w) return ((2.0 / r) / r) + (-1.5 + (-1.0 / (((t_0 * t_0) * (v + -1.0)) / (-0.375 - (v * -0.25)))))
function code(v, w, r) t_0 = Float64(1.0 / Float64(r * w)) return Float64(Float64(Float64(2.0 / r) / r) + Float64(-1.5 + Float64(-1.0 / Float64(Float64(Float64(t_0 * t_0) * Float64(v + -1.0)) / Float64(-0.375 - Float64(v * -0.25)))))) end
function tmp = code(v, w, r) t_0 = 1.0 / (r * w); tmp = ((2.0 / r) / r) + (-1.5 + (-1.0 / (((t_0 * t_0) * (v + -1.0)) / (-0.375 - (v * -0.25))))); end
code[v_, w_, r_] := Block[{t$95$0 = N[(1.0 / N[(r * w), $MachinePrecision]), $MachinePrecision]}, N[(N[(N[(2.0 / r), $MachinePrecision] / r), $MachinePrecision] + N[(-1.5 + N[(-1.0 / N[(N[(N[(t$95$0 * t$95$0), $MachinePrecision] * N[(v + -1.0), $MachinePrecision]), $MachinePrecision] / N[(-0.375 - N[(v * -0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{1}{r \cdot w}\\
\frac{\frac{2}{r}}{r} + \left(-1.5 + \frac{-1}{\frac{\left(t_0 \cdot t_0\right) \cdot \left(v + -1\right)}{-0.375 - v \cdot -0.25}}\right)
\end{array}
\end{array}
Initial program 83.9%
Simplified96.3%
*-commutative96.3%
clear-num96.3%
*-commutative96.3%
associate-*r*86.5%
un-div-inv86.5%
fma-udef86.5%
metadata-eval86.5%
associate-*l*86.5%
*-commutative86.5%
metadata-eval86.5%
distribute-rgt-in86.5%
+-commutative86.5%
clear-num86.5%
Applied egg-rr99.8%
frac-2neg99.8%
div-inv99.8%
div-inv99.7%
distribute-lft-neg-in99.7%
pow-flip99.7%
metadata-eval99.7%
Applied egg-rr99.7%
associate-*r/99.8%
*-rgt-identity99.8%
*-commutative99.8%
neg-sub099.8%
associate--r-99.8%
metadata-eval99.8%
neg-sub099.8%
fma-udef99.8%
*-commutative99.8%
+-commutative99.8%
associate--r+99.8%
metadata-eval99.8%
*-commutative99.8%
Simplified99.8%
metadata-eval99.8%
pow-prod-up99.8%
unpow-199.8%
unpow-199.8%
Applied egg-rr99.8%
Final simplification99.8%
(FPCore (v w r)
:precision binary64
(let* ((t_0 (/ 2.0 (* r w))))
(if (<= v 2.3e+54)
(+ -1.5 (+ (/ 2.0 (* r r)) (* (* (* r w) (* r w)) -0.375)))
(+ (/ (/ 2.0 r) r) (+ -1.5 (/ -1.0 (* t_0 t_0)))))))
double code(double v, double w, double r) {
double t_0 = 2.0 / (r * w);
double tmp;
if (v <= 2.3e+54) {
tmp = -1.5 + ((2.0 / (r * r)) + (((r * w) * (r * w)) * -0.375));
} else {
tmp = ((2.0 / r) / r) + (-1.5 + (-1.0 / (t_0 * t_0)));
}
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) :: t_0
real(8) :: tmp
t_0 = 2.0d0 / (r * w)
if (v <= 2.3d+54) then
tmp = (-1.5d0) + ((2.0d0 / (r * r)) + (((r * w) * (r * w)) * (-0.375d0)))
else
tmp = ((2.0d0 / r) / r) + ((-1.5d0) + ((-1.0d0) / (t_0 * t_0)))
end if
code = tmp
end function
public static double code(double v, double w, double r) {
double t_0 = 2.0 / (r * w);
double tmp;
if (v <= 2.3e+54) {
tmp = -1.5 + ((2.0 / (r * r)) + (((r * w) * (r * w)) * -0.375));
} else {
tmp = ((2.0 / r) / r) + (-1.5 + (-1.0 / (t_0 * t_0)));
}
return tmp;
}
def code(v, w, r): t_0 = 2.0 / (r * w) tmp = 0 if v <= 2.3e+54: tmp = -1.5 + ((2.0 / (r * r)) + (((r * w) * (r * w)) * -0.375)) else: tmp = ((2.0 / r) / r) + (-1.5 + (-1.0 / (t_0 * t_0))) return tmp
function code(v, w, r) t_0 = Float64(2.0 / Float64(r * w)) tmp = 0.0 if (v <= 2.3e+54) tmp = Float64(-1.5 + Float64(Float64(2.0 / Float64(r * r)) + Float64(Float64(Float64(r * w) * Float64(r * w)) * -0.375))); else tmp = Float64(Float64(Float64(2.0 / r) / r) + Float64(-1.5 + Float64(-1.0 / Float64(t_0 * t_0)))); end return tmp end
function tmp_2 = code(v, w, r) t_0 = 2.0 / (r * w); tmp = 0.0; if (v <= 2.3e+54) tmp = -1.5 + ((2.0 / (r * r)) + (((r * w) * (r * w)) * -0.375)); else tmp = ((2.0 / r) / r) + (-1.5 + (-1.0 / (t_0 * t_0))); end tmp_2 = tmp; end
code[v_, w_, r_] := Block[{t$95$0 = N[(2.0 / N[(r * w), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[v, 2.3e+54], N[(-1.5 + N[(N[(2.0 / N[(r * r), $MachinePrecision]), $MachinePrecision] + N[(N[(N[(r * w), $MachinePrecision] * N[(r * w), $MachinePrecision]), $MachinePrecision] * -0.375), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(2.0 / r), $MachinePrecision] / r), $MachinePrecision] + N[(-1.5 + N[(-1.0 / N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{2}{r \cdot w}\\
\mathbf{if}\;v \leq 2.3 \cdot 10^{+54}:\\
\;\;\;\;-1.5 + \left(\frac{2}{r \cdot r} + \left(\left(r \cdot w\right) \cdot \left(r \cdot w\right)\right) \cdot -0.375\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{2}{r}}{r} + \left(-1.5 + \frac{-1}{t_0 \cdot t_0}\right)\\
\end{array}
\end{array}
if v < 2.29999999999999994e54Initial program 86.4%
Simplified86.4%
Taylor expanded in v around 0 82.7%
*-commutative82.7%
unpow282.7%
unpow282.7%
swap-sqr99.0%
unpow299.0%
Simplified99.0%
unpow299.8%
Applied egg-rr99.0%
if 2.29999999999999994e54 < v Initial program 75.8%
Simplified98.1%
*-commutative98.1%
clear-num98.1%
*-commutative98.1%
associate-*r*86.8%
un-div-inv86.8%
fma-udef86.8%
metadata-eval86.8%
associate-*l*86.8%
*-commutative86.8%
metadata-eval86.8%
distribute-rgt-in86.8%
+-commutative86.8%
clear-num86.9%
Applied egg-rr99.8%
Taylor expanded in v around inf 78.5%
unpow278.5%
unpow278.5%
swap-sqr99.7%
unpow299.7%
Simplified99.7%
add-sqr-sqrt99.7%
sqrt-div99.8%
metadata-eval99.8%
unpow299.8%
sqrt-prod63.1%
add-sqr-sqrt81.6%
sqrt-div81.6%
metadata-eval81.6%
unpow281.6%
sqrt-prod63.1%
add-sqr-sqrt99.8%
Applied egg-rr99.8%
Final simplification99.2%
(FPCore (v w r) :precision binary64 (if (<= v 6.2e+84) (+ -1.5 (+ (/ 2.0 (* r r)) (* (* (* r w) (* r w)) -0.375))) (+ -1.5 (+ (* (/ 2.0 r) (/ 1.0 r)) (* -0.25 (* r (* r (* w w))))))))
double code(double v, double w, double r) {
double tmp;
if (v <= 6.2e+84) {
tmp = -1.5 + ((2.0 / (r * r)) + (((r * w) * (r * w)) * -0.375));
} else {
tmp = -1.5 + (((2.0 / r) * (1.0 / r)) + (-0.25 * (r * (r * (w * w)))));
}
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 <= 6.2d+84) then
tmp = (-1.5d0) + ((2.0d0 / (r * r)) + (((r * w) * (r * w)) * (-0.375d0)))
else
tmp = (-1.5d0) + (((2.0d0 / r) * (1.0d0 / r)) + ((-0.25d0) * (r * (r * (w * w)))))
end if
code = tmp
end function
public static double code(double v, double w, double r) {
double tmp;
if (v <= 6.2e+84) {
tmp = -1.5 + ((2.0 / (r * r)) + (((r * w) * (r * w)) * -0.375));
} else {
tmp = -1.5 + (((2.0 / r) * (1.0 / r)) + (-0.25 * (r * (r * (w * w)))));
}
return tmp;
}
def code(v, w, r): tmp = 0 if v <= 6.2e+84: tmp = -1.5 + ((2.0 / (r * r)) + (((r * w) * (r * w)) * -0.375)) else: tmp = -1.5 + (((2.0 / r) * (1.0 / r)) + (-0.25 * (r * (r * (w * w))))) return tmp
function code(v, w, r) tmp = 0.0 if (v <= 6.2e+84) tmp = Float64(-1.5 + Float64(Float64(2.0 / Float64(r * r)) + Float64(Float64(Float64(r * w) * Float64(r * w)) * -0.375))); else tmp = Float64(-1.5 + Float64(Float64(Float64(2.0 / r) * Float64(1.0 / r)) + Float64(-0.25 * Float64(r * Float64(r * Float64(w * w)))))); end return tmp end
function tmp_2 = code(v, w, r) tmp = 0.0; if (v <= 6.2e+84) tmp = -1.5 + ((2.0 / (r * r)) + (((r * w) * (r * w)) * -0.375)); else tmp = -1.5 + (((2.0 / r) * (1.0 / r)) + (-0.25 * (r * (r * (w * w))))); end tmp_2 = tmp; end
code[v_, w_, r_] := If[LessEqual[v, 6.2e+84], N[(-1.5 + N[(N[(2.0 / N[(r * r), $MachinePrecision]), $MachinePrecision] + N[(N[(N[(r * w), $MachinePrecision] * N[(r * w), $MachinePrecision]), $MachinePrecision] * -0.375), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(-1.5 + N[(N[(N[(2.0 / r), $MachinePrecision] * N[(1.0 / r), $MachinePrecision]), $MachinePrecision] + N[(-0.25 * N[(r * N[(r * N[(w * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;v \leq 6.2 \cdot 10^{+84}:\\
\;\;\;\;-1.5 + \left(\frac{2}{r \cdot r} + \left(\left(r \cdot w\right) \cdot \left(r \cdot w\right)\right) \cdot -0.375\right)\\
\mathbf{else}:\\
\;\;\;\;-1.5 + \left(\frac{2}{r} \cdot \frac{1}{r} + -0.25 \cdot \left(r \cdot \left(r \cdot \left(w \cdot w\right)\right)\right)\right)\\
\end{array}
\end{array}
if v < 6.20000000000000006e84Initial program 85.7%
Simplified85.7%
Taylor expanded in v around 0 81.6%
*-commutative81.6%
unpow281.6%
unpow281.6%
swap-sqr98.6%
unpow298.6%
Simplified98.6%
unpow299.8%
Applied egg-rr98.6%
if 6.20000000000000006e84 < v Initial program 77.2%
Simplified89.2%
associate-/r*89.2%
div-inv89.1%
Applied egg-rr89.1%
Taylor expanded in v around inf 89.1%
Final simplification96.6%
(FPCore (v w r)
:precision binary64
(let* ((t_0 (* (* r w) 0.5)))
(if (<= v 3.2e+54)
(+ -1.5 (+ (/ 2.0 (* r r)) (* (* (* r w) (* r w)) -0.375)))
(+ (/ (/ 2.0 r) r) (- -1.5 (* t_0 t_0))))))
double code(double v, double w, double r) {
double t_0 = (r * w) * 0.5;
double tmp;
if (v <= 3.2e+54) {
tmp = -1.5 + ((2.0 / (r * r)) + (((r * w) * (r * w)) * -0.375));
} else {
tmp = ((2.0 / r) / r) + (-1.5 - (t_0 * t_0));
}
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) :: t_0
real(8) :: tmp
t_0 = (r * w) * 0.5d0
if (v <= 3.2d+54) then
tmp = (-1.5d0) + ((2.0d0 / (r * r)) + (((r * w) * (r * w)) * (-0.375d0)))
else
tmp = ((2.0d0 / r) / r) + ((-1.5d0) - (t_0 * t_0))
end if
code = tmp
end function
public static double code(double v, double w, double r) {
double t_0 = (r * w) * 0.5;
double tmp;
if (v <= 3.2e+54) {
tmp = -1.5 + ((2.0 / (r * r)) + (((r * w) * (r * w)) * -0.375));
} else {
tmp = ((2.0 / r) / r) + (-1.5 - (t_0 * t_0));
}
return tmp;
}
def code(v, w, r): t_0 = (r * w) * 0.5 tmp = 0 if v <= 3.2e+54: tmp = -1.5 + ((2.0 / (r * r)) + (((r * w) * (r * w)) * -0.375)) else: tmp = ((2.0 / r) / r) + (-1.5 - (t_0 * t_0)) return tmp
function code(v, w, r) t_0 = Float64(Float64(r * w) * 0.5) tmp = 0.0 if (v <= 3.2e+54) tmp = Float64(-1.5 + Float64(Float64(2.0 / Float64(r * r)) + Float64(Float64(Float64(r * w) * Float64(r * w)) * -0.375))); else tmp = Float64(Float64(Float64(2.0 / r) / r) + Float64(-1.5 - Float64(t_0 * t_0))); end return tmp end
function tmp_2 = code(v, w, r) t_0 = (r * w) * 0.5; tmp = 0.0; if (v <= 3.2e+54) tmp = -1.5 + ((2.0 / (r * r)) + (((r * w) * (r * w)) * -0.375)); else tmp = ((2.0 / r) / r) + (-1.5 - (t_0 * t_0)); end tmp_2 = tmp; end
code[v_, w_, r_] := Block[{t$95$0 = N[(N[(r * w), $MachinePrecision] * 0.5), $MachinePrecision]}, If[LessEqual[v, 3.2e+54], N[(-1.5 + N[(N[(2.0 / N[(r * r), $MachinePrecision]), $MachinePrecision] + N[(N[(N[(r * w), $MachinePrecision] * N[(r * w), $MachinePrecision]), $MachinePrecision] * -0.375), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(2.0 / r), $MachinePrecision] / r), $MachinePrecision] + N[(-1.5 - N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(r \cdot w\right) \cdot 0.5\\
\mathbf{if}\;v \leq 3.2 \cdot 10^{+54}:\\
\;\;\;\;-1.5 + \left(\frac{2}{r \cdot r} + \left(\left(r \cdot w\right) \cdot \left(r \cdot w\right)\right) \cdot -0.375\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{2}{r}}{r} + \left(-1.5 - t_0 \cdot t_0\right)\\
\end{array}
\end{array}
if v < 3.2e54Initial program 86.4%
Simplified86.4%
Taylor expanded in v around 0 82.7%
*-commutative82.7%
unpow282.7%
unpow282.7%
swap-sqr99.0%
unpow299.0%
Simplified99.0%
unpow299.8%
Applied egg-rr99.0%
if 3.2e54 < v Initial program 75.8%
Simplified98.1%
*-commutative98.1%
clear-num98.1%
*-commutative98.1%
associate-*r*86.8%
un-div-inv86.8%
fma-udef86.8%
metadata-eval86.8%
associate-*l*86.8%
*-commutative86.8%
metadata-eval86.8%
distribute-rgt-in86.8%
+-commutative86.8%
clear-num86.9%
Applied egg-rr99.8%
Taylor expanded in v around inf 78.5%
unpow278.5%
unpow278.5%
swap-sqr99.7%
unpow299.7%
Simplified99.7%
associate-/r/99.7%
add-sqr-sqrt99.7%
sqrt-prod99.7%
metadata-eval99.7%
metadata-eval99.7%
unpow299.7%
sqrt-prod63.1%
add-sqr-sqrt81.5%
sqrt-prod81.5%
metadata-eval81.5%
metadata-eval81.5%
unpow281.5%
sqrt-prod63.1%
add-sqr-sqrt99.7%
Applied egg-rr99.7%
Final simplification99.2%
(FPCore (v w r) :precision binary64 (+ -1.5 (+ (/ 2.0 (* r r)) (* (* (* r w) (* r w)) -0.375))))
double code(double v, double w, double r) {
return -1.5 + ((2.0 / (r * r)) + (((r * w) * (r * w)) * -0.375));
}
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)) + (((r * w) * (r * w)) * (-0.375d0)))
end function
public static double code(double v, double w, double r) {
return -1.5 + ((2.0 / (r * r)) + (((r * w) * (r * w)) * -0.375));
}
def code(v, w, r): return -1.5 + ((2.0 / (r * r)) + (((r * w) * (r * w)) * -0.375))
function code(v, w, r) return Float64(-1.5 + Float64(Float64(2.0 / Float64(r * r)) + Float64(Float64(Float64(r * w) * Float64(r * w)) * -0.375))) end
function tmp = code(v, w, r) tmp = -1.5 + ((2.0 / (r * r)) + (((r * w) * (r * w)) * -0.375)); end
code[v_, w_, r_] := N[(-1.5 + N[(N[(2.0 / N[(r * r), $MachinePrecision]), $MachinePrecision] + N[(N[(N[(r * w), $MachinePrecision] * N[(r * w), $MachinePrecision]), $MachinePrecision] * -0.375), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
-1.5 + \left(\frac{2}{r \cdot r} + \left(\left(r \cdot w\right) \cdot \left(r \cdot w\right)\right) \cdot -0.375\right)
\end{array}
Initial program 83.9%
Simplified86.5%
Taylor expanded in v around 0 79.2%
*-commutative79.2%
unpow279.2%
unpow279.2%
swap-sqr94.9%
unpow294.9%
Simplified94.9%
unpow299.8%
Applied egg-rr94.9%
Final simplification94.9%
herbie shell --seed 2023333
(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))