
(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 (+ (+ 3.0 (/ 2.0 (* r r))) (- (* (* 0.125 (+ 3.0 (* -2.0 v))) (* (* r w) (/ w (/ (+ v -1.0) r)))) 4.5)))
double code(double v, double w, double r) {
return (3.0 + (2.0 / (r * r))) + (((0.125 * (3.0 + (-2.0 * v))) * ((r * w) * (w / ((v + -1.0) / r)))) - 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))) * ((r * w) * (w / ((v + (-1.0d0)) / r)))) - 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))) * ((r * w) * (w / ((v + -1.0) / r)))) - 4.5);
}
def code(v, w, r): return (3.0 + (2.0 / (r * r))) + (((0.125 * (3.0 + (-2.0 * v))) * ((r * w) * (w / ((v + -1.0) / r)))) - 4.5)
function code(v, w, r) return Float64(Float64(3.0 + Float64(2.0 / Float64(r * r))) + Float64(Float64(Float64(0.125 * Float64(3.0 + Float64(-2.0 * v))) * Float64(Float64(r * w) * Float64(w / Float64(Float64(v + -1.0) / r)))) - 4.5)) end
function tmp = code(v, w, r) tmp = (3.0 + (2.0 / (r * r))) + (((0.125 * (3.0 + (-2.0 * v))) * ((r * w) * (w / ((v + -1.0) / r)))) - 4.5); end
code[v_, w_, r_] := 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[(r * w), $MachinePrecision] * N[(w / N[(N[(v + -1.0), $MachinePrecision] / r), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 4.5), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(3 + \frac{2}{r \cdot r}\right) + \left(\left(0.125 \cdot \left(3 + -2 \cdot v\right)\right) \cdot \left(\left(r \cdot w\right) \cdot \frac{w}{\frac{v + -1}{r}}\right) - 4.5\right)
\end{array}
Initial program 85.5%
associate--l-85.5%
associate-*l*80.0%
sqr-neg80.0%
associate-*l*85.5%
associate-/l*87.7%
fma-define87.7%
Simplified87.7%
associate-/l*87.7%
*-commutative87.7%
associate-*r/86.9%
associate-*l*96.1%
associate-*r*99.0%
add-sqr-sqrt48.0%
associate-*l*48.0%
add-sqr-sqrt23.8%
sqrt-prod34.4%
sqrt-prod34.4%
sqrt-prod69.3%
*-commutative69.3%
sqrt-prod34.4%
*-commutative34.4%
sqrt-prod34.4%
sqrt-prod23.8%
add-sqr-sqrt48.0%
associate-*r*48.0%
add-sqr-sqrt99.0%
clear-num99.0%
un-div-inv99.0%
Applied egg-rr99.0%
Final simplification99.0%
(FPCore (v w r)
:precision binary64
(let* ((t_0 (+ 3.0 (/ 2.0 (* r r)))))
(if (<= r 1.5e-89)
(+ t_0 (- (/ (* (* r w) 0.375) (/ (/ -1.0 w) r)) 4.5))
(-
t_0
(+ 4.5 (/ (* r (* w (+ 0.375 (* v -0.25)))) (/ (- 1.0 v) (* r w))))))))
double code(double v, double w, double r) {
double t_0 = 3.0 + (2.0 / (r * r));
double tmp;
if (r <= 1.5e-89) {
tmp = t_0 + ((((r * w) * 0.375) / ((-1.0 / w) / r)) - 4.5);
} else {
tmp = t_0 - (4.5 + ((r * (w * (0.375 + (v * -0.25)))) / ((1.0 - v) / (r * 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) :: t_0
real(8) :: tmp
t_0 = 3.0d0 + (2.0d0 / (r * r))
if (r <= 1.5d-89) then
tmp = t_0 + ((((r * w) * 0.375d0) / (((-1.0d0) / w) / r)) - 4.5d0)
else
tmp = t_0 - (4.5d0 + ((r * (w * (0.375d0 + (v * (-0.25d0))))) / ((1.0d0 - v) / (r * w))))
end if
code = tmp
end function
public static double code(double v, double w, double r) {
double t_0 = 3.0 + (2.0 / (r * r));
double tmp;
if (r <= 1.5e-89) {
tmp = t_0 + ((((r * w) * 0.375) / ((-1.0 / w) / r)) - 4.5);
} else {
tmp = t_0 - (4.5 + ((r * (w * (0.375 + (v * -0.25)))) / ((1.0 - v) / (r * w))));
}
return tmp;
}
def code(v, w, r): t_0 = 3.0 + (2.0 / (r * r)) tmp = 0 if r <= 1.5e-89: tmp = t_0 + ((((r * w) * 0.375) / ((-1.0 / w) / r)) - 4.5) else: tmp = t_0 - (4.5 + ((r * (w * (0.375 + (v * -0.25)))) / ((1.0 - v) / (r * w)))) return tmp
function code(v, w, r) t_0 = Float64(3.0 + Float64(2.0 / Float64(r * r))) tmp = 0.0 if (r <= 1.5e-89) tmp = Float64(t_0 + Float64(Float64(Float64(Float64(r * w) * 0.375) / Float64(Float64(-1.0 / w) / r)) - 4.5)); else tmp = Float64(t_0 - Float64(4.5 + Float64(Float64(r * Float64(w * Float64(0.375 + Float64(v * -0.25)))) / Float64(Float64(1.0 - v) / Float64(r * w))))); end return tmp end
function tmp_2 = code(v, w, r) t_0 = 3.0 + (2.0 / (r * r)); tmp = 0.0; if (r <= 1.5e-89) tmp = t_0 + ((((r * w) * 0.375) / ((-1.0 / w) / r)) - 4.5); else tmp = t_0 - (4.5 + ((r * (w * (0.375 + (v * -0.25)))) / ((1.0 - v) / (r * w)))); end tmp_2 = tmp; end
code[v_, w_, r_] := Block[{t$95$0 = N[(3.0 + N[(2.0 / N[(r * r), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[r, 1.5e-89], N[(t$95$0 + N[(N[(N[(N[(r * w), $MachinePrecision] * 0.375), $MachinePrecision] / N[(N[(-1.0 / w), $MachinePrecision] / r), $MachinePrecision]), $MachinePrecision] - 4.5), $MachinePrecision]), $MachinePrecision], N[(t$95$0 - N[(4.5 + N[(N[(r * N[(w * N[(0.375 + N[(v * -0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[(1.0 - v), $MachinePrecision] / N[(r * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 3 + \frac{2}{r \cdot r}\\
\mathbf{if}\;r \leq 1.5 \cdot 10^{-89}:\\
\;\;\;\;t\_0 + \left(\frac{\left(r \cdot w\right) \cdot 0.375}{\frac{\frac{-1}{w}}{r}} - 4.5\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0 - \left(4.5 + \frac{r \cdot \left(w \cdot \left(0.375 + v \cdot -0.25\right)\right)}{\frac{1 - v}{r \cdot w}}\right)\\
\end{array}
\end{array}
if r < 1.5e-89Initial program 82.3%
associate--l-82.3%
associate-*l*77.3%
sqr-neg77.3%
associate-*l*82.3%
associate-/l*84.4%
fma-define84.4%
Simplified84.4%
associate-/l*84.4%
*-commutative84.4%
associate-*r/83.3%
associate-*l*94.9%
associate-*r*98.7%
add-sqr-sqrt25.3%
associate-*l*25.3%
add-sqr-sqrt12.4%
sqrt-prod21.3%
sqrt-prod21.3%
sqrt-prod71.4%
*-commutative71.4%
sqrt-prod21.3%
*-commutative21.3%
sqrt-prod21.3%
sqrt-prod12.4%
add-sqr-sqrt25.3%
associate-*r*25.3%
add-sqr-sqrt98.7%
clear-num98.7%
un-div-inv98.7%
Applied egg-rr98.7%
associate-*r*97.6%
clear-num97.6%
un-div-inv97.6%
distribute-rgt-in97.6%
metadata-eval97.6%
*-commutative97.6%
associate-*l*97.6%
metadata-eval97.6%
associate-/l/98.7%
Applied egg-rr98.7%
Taylor expanded in v around 0 85.2%
associate-/l/85.2%
Simplified85.2%
Taylor expanded in v around 0 95.7%
if 1.5e-89 < r Initial program 92.8%
associate--l-92.7%
associate-*l*86.2%
sqr-neg86.2%
associate-*l*92.7%
associate-/l*95.1%
fma-define95.0%
Simplified95.1%
associate-/l*95.1%
*-commutative95.1%
associate-*r/95.1%
associate-*l*98.6%
associate-*r*99.8%
add-sqr-sqrt99.8%
associate-*l*99.8%
add-sqr-sqrt49.8%
sqrt-prod64.3%
sqrt-prod64.3%
sqrt-prod64.3%
*-commutative64.3%
sqrt-prod64.3%
*-commutative64.3%
sqrt-prod64.3%
sqrt-prod49.8%
add-sqr-sqrt99.8%
associate-*r*99.8%
add-sqr-sqrt99.8%
clear-num99.8%
un-div-inv99.7%
Applied egg-rr99.7%
associate-*r*98.5%
clear-num98.5%
un-div-inv98.6%
distribute-rgt-in98.6%
metadata-eval98.6%
*-commutative98.6%
associate-*l*98.6%
metadata-eval98.6%
associate-/l/98.6%
Applied egg-rr98.6%
Taylor expanded in w around 0 98.6%
Final simplification96.6%
(FPCore (v w r) :precision binary64 (+ (+ 3.0 (/ 2.0 (* r r))) (- (/ (* (* r w) (+ 0.375 (* v -0.25))) (/ (+ v -1.0) (* r w))) 4.5)))
double code(double v, double w, double r) {
return (3.0 + (2.0 / (r * r))) + ((((r * w) * (0.375 + (v * -0.25))) / ((v + -1.0) / (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))) + ((((r * w) * (0.375d0 + (v * (-0.25d0)))) / ((v + (-1.0d0)) / (r * w))) - 4.5d0)
end function
public static double code(double v, double w, double r) {
return (3.0 + (2.0 / (r * r))) + ((((r * w) * (0.375 + (v * -0.25))) / ((v + -1.0) / (r * w))) - 4.5);
}
def code(v, w, r): return (3.0 + (2.0 / (r * r))) + ((((r * w) * (0.375 + (v * -0.25))) / ((v + -1.0) / (r * w))) - 4.5)
function code(v, w, r) return Float64(Float64(3.0 + Float64(2.0 / Float64(r * r))) + Float64(Float64(Float64(Float64(r * w) * Float64(0.375 + Float64(v * -0.25))) / Float64(Float64(v + -1.0) / Float64(r * w))) - 4.5)) end
function tmp = code(v, w, r) tmp = (3.0 + (2.0 / (r * r))) + ((((r * w) * (0.375 + (v * -0.25))) / ((v + -1.0) / (r * w))) - 4.5); end
code[v_, w_, r_] := N[(N[(3.0 + N[(2.0 / N[(r * r), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(N[(N[(r * w), $MachinePrecision] * N[(0.375 + N[(v * -0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[(v + -1.0), $MachinePrecision] / N[(r * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 4.5), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(3 + \frac{2}{r \cdot r}\right) + \left(\frac{\left(r \cdot w\right) \cdot \left(0.375 + v \cdot -0.25\right)}{\frac{v + -1}{r \cdot w}} - 4.5\right)
\end{array}
Initial program 85.5%
associate--l-85.5%
associate-*l*80.0%
sqr-neg80.0%
associate-*l*85.5%
associate-/l*87.7%
fma-define87.7%
Simplified87.7%
associate-/l*87.7%
*-commutative87.7%
associate-*r/86.9%
associate-*l*96.1%
associate-*r*99.0%
add-sqr-sqrt48.0%
associate-*l*48.0%
add-sqr-sqrt23.8%
sqrt-prod34.4%
sqrt-prod34.4%
sqrt-prod69.3%
*-commutative69.3%
sqrt-prod34.4%
*-commutative34.4%
sqrt-prod34.4%
sqrt-prod23.8%
add-sqr-sqrt48.0%
associate-*r*48.0%
add-sqr-sqrt99.0%
clear-num99.0%
un-div-inv99.0%
Applied egg-rr99.0%
associate-*r*97.9%
clear-num97.9%
un-div-inv97.9%
distribute-rgt-in97.9%
metadata-eval97.9%
*-commutative97.9%
associate-*l*97.9%
metadata-eval97.9%
associate-/l/98.7%
Applied egg-rr98.7%
Final simplification98.7%
(FPCore (v w r)
:precision binary64
(let* ((t_0 (/ 2.0 (* r r))))
(if (<= v -2.0)
(+ t_0 (- -1.5 (* (* (* r w) (* r w)) 0.25)))
(+ (+ 3.0 t_0) (- (/ (* (* r w) 0.375) (/ (/ -1.0 w) r)) 4.5)))))
double code(double v, double w, double r) {
double t_0 = 2.0 / (r * r);
double tmp;
if (v <= -2.0) {
tmp = t_0 + (-1.5 - (((r * w) * (r * w)) * 0.25));
} else {
tmp = (3.0 + t_0) + ((((r * w) * 0.375) / ((-1.0 / w) / r)) - 4.5);
}
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 * r)
if (v <= (-2.0d0)) then
tmp = t_0 + ((-1.5d0) - (((r * w) * (r * w)) * 0.25d0))
else
tmp = (3.0d0 + t_0) + ((((r * w) * 0.375d0) / (((-1.0d0) / w) / r)) - 4.5d0)
end if
code = tmp
end function
public static double code(double v, double w, double r) {
double t_0 = 2.0 / (r * r);
double tmp;
if (v <= -2.0) {
tmp = t_0 + (-1.5 - (((r * w) * (r * w)) * 0.25));
} else {
tmp = (3.0 + t_0) + ((((r * w) * 0.375) / ((-1.0 / w) / r)) - 4.5);
}
return tmp;
}
def code(v, w, r): t_0 = 2.0 / (r * r) tmp = 0 if v <= -2.0: tmp = t_0 + (-1.5 - (((r * w) * (r * w)) * 0.25)) else: tmp = (3.0 + t_0) + ((((r * w) * 0.375) / ((-1.0 / w) / r)) - 4.5) return tmp
function code(v, w, r) t_0 = Float64(2.0 / Float64(r * r)) tmp = 0.0 if (v <= -2.0) tmp = Float64(t_0 + Float64(-1.5 - Float64(Float64(Float64(r * w) * Float64(r * w)) * 0.25))); else tmp = Float64(Float64(3.0 + t_0) + Float64(Float64(Float64(Float64(r * w) * 0.375) / Float64(Float64(-1.0 / w) / r)) - 4.5)); end return tmp end
function tmp_2 = code(v, w, r) t_0 = 2.0 / (r * r); tmp = 0.0; if (v <= -2.0) tmp = t_0 + (-1.5 - (((r * w) * (r * w)) * 0.25)); else tmp = (3.0 + t_0) + ((((r * w) * 0.375) / ((-1.0 / w) / r)) - 4.5); end tmp_2 = tmp; end
code[v_, w_, r_] := Block[{t$95$0 = N[(2.0 / N[(r * r), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[v, -2.0], N[(t$95$0 + N[(-1.5 - N[(N[(N[(r * w), $MachinePrecision] * N[(r * w), $MachinePrecision]), $MachinePrecision] * 0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(3.0 + t$95$0), $MachinePrecision] + N[(N[(N[(N[(r * w), $MachinePrecision] * 0.375), $MachinePrecision] / N[(N[(-1.0 / w), $MachinePrecision] / r), $MachinePrecision]), $MachinePrecision] - 4.5), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{2}{r \cdot r}\\
\mathbf{if}\;v \leq -2:\\
\;\;\;\;t\_0 + \left(-1.5 - \left(\left(r \cdot w\right) \cdot \left(r \cdot w\right)\right) \cdot 0.25\right)\\
\mathbf{else}:\\
\;\;\;\;\left(3 + t\_0\right) + \left(\frac{\left(r \cdot w\right) \cdot 0.375}{\frac{\frac{-1}{w}}{r}} - 4.5\right)\\
\end{array}
\end{array}
if v < -2Initial program 87.5%
Simplified90.2%
Taylor expanded in v around inf 86.2%
*-commutative86.2%
*-commutative86.2%
unpow286.2%
unpow286.2%
swap-sqr99.1%
unpow299.1%
*-commutative99.1%
Simplified99.1%
*-commutative99.1%
pow299.1%
Applied egg-rr99.1%
if -2 < v Initial program 84.9%
associate--l-84.9%
associate-*l*79.8%
sqr-neg79.8%
associate-*l*84.9%
associate-/l*85.9%
fma-define85.9%
Simplified85.9%
associate-/l*85.9%
*-commutative85.9%
associate-*r/85.9%
associate-*l*95.9%
associate-*r*99.8%
add-sqr-sqrt48.1%
associate-*l*48.1%
add-sqr-sqrt22.0%
sqrt-prod32.4%
sqrt-prod32.4%
sqrt-prod66.3%
*-commutative66.3%
sqrt-prod32.4%
*-commutative32.4%
sqrt-prod32.4%
sqrt-prod22.0%
add-sqr-sqrt48.1%
associate-*r*48.1%
add-sqr-sqrt99.8%
clear-num99.8%
un-div-inv99.8%
Applied egg-rr99.8%
associate-*r*98.8%
clear-num98.8%
un-div-inv98.8%
distribute-rgt-in98.8%
metadata-eval98.8%
*-commutative98.8%
associate-*l*98.8%
metadata-eval98.8%
associate-/l/98.8%
Applied egg-rr98.8%
Taylor expanded in v around 0 84.1%
associate-/l/84.0%
Simplified84.0%
Taylor expanded in v around 0 97.7%
Final simplification98.1%
(FPCore (v w r)
:precision binary64
(let* ((t_0 (/ 2.0 (* r r))))
(if (<= v -5.0)
(+ t_0 (- -1.5 (* (* (* r w) (* r w)) 0.25)))
(+ (+ 3.0 t_0) (- (/ (* w (* r 0.375)) (/ (/ -1.0 w) r)) 4.5)))))
double code(double v, double w, double r) {
double t_0 = 2.0 / (r * r);
double tmp;
if (v <= -5.0) {
tmp = t_0 + (-1.5 - (((r * w) * (r * w)) * 0.25));
} else {
tmp = (3.0 + t_0) + (((w * (r * 0.375)) / ((-1.0 / w) / r)) - 4.5);
}
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 * r)
if (v <= (-5.0d0)) then
tmp = t_0 + ((-1.5d0) - (((r * w) * (r * w)) * 0.25d0))
else
tmp = (3.0d0 + t_0) + (((w * (r * 0.375d0)) / (((-1.0d0) / w) / r)) - 4.5d0)
end if
code = tmp
end function
public static double code(double v, double w, double r) {
double t_0 = 2.0 / (r * r);
double tmp;
if (v <= -5.0) {
tmp = t_0 + (-1.5 - (((r * w) * (r * w)) * 0.25));
} else {
tmp = (3.0 + t_0) + (((w * (r * 0.375)) / ((-1.0 / w) / r)) - 4.5);
}
return tmp;
}
def code(v, w, r): t_0 = 2.0 / (r * r) tmp = 0 if v <= -5.0: tmp = t_0 + (-1.5 - (((r * w) * (r * w)) * 0.25)) else: tmp = (3.0 + t_0) + (((w * (r * 0.375)) / ((-1.0 / w) / r)) - 4.5) return tmp
function code(v, w, r) t_0 = Float64(2.0 / Float64(r * r)) tmp = 0.0 if (v <= -5.0) tmp = Float64(t_0 + Float64(-1.5 - Float64(Float64(Float64(r * w) * Float64(r * w)) * 0.25))); else tmp = Float64(Float64(3.0 + t_0) + Float64(Float64(Float64(w * Float64(r * 0.375)) / Float64(Float64(-1.0 / w) / r)) - 4.5)); end return tmp end
function tmp_2 = code(v, w, r) t_0 = 2.0 / (r * r); tmp = 0.0; if (v <= -5.0) tmp = t_0 + (-1.5 - (((r * w) * (r * w)) * 0.25)); else tmp = (3.0 + t_0) + (((w * (r * 0.375)) / ((-1.0 / w) / r)) - 4.5); end tmp_2 = tmp; end
code[v_, w_, r_] := Block[{t$95$0 = N[(2.0 / N[(r * r), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[v, -5.0], N[(t$95$0 + N[(-1.5 - N[(N[(N[(r * w), $MachinePrecision] * N[(r * w), $MachinePrecision]), $MachinePrecision] * 0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(3.0 + t$95$0), $MachinePrecision] + N[(N[(N[(w * N[(r * 0.375), $MachinePrecision]), $MachinePrecision] / N[(N[(-1.0 / w), $MachinePrecision] / r), $MachinePrecision]), $MachinePrecision] - 4.5), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{2}{r \cdot r}\\
\mathbf{if}\;v \leq -5:\\
\;\;\;\;t\_0 + \left(-1.5 - \left(\left(r \cdot w\right) \cdot \left(r \cdot w\right)\right) \cdot 0.25\right)\\
\mathbf{else}:\\
\;\;\;\;\left(3 + t\_0\right) + \left(\frac{w \cdot \left(r \cdot 0.375\right)}{\frac{\frac{-1}{w}}{r}} - 4.5\right)\\
\end{array}
\end{array}
if v < -5Initial program 87.5%
Simplified90.2%
Taylor expanded in v around inf 86.2%
*-commutative86.2%
*-commutative86.2%
unpow286.2%
unpow286.2%
swap-sqr99.1%
unpow299.1%
*-commutative99.1%
Simplified99.1%
*-commutative99.1%
pow299.1%
Applied egg-rr99.1%
if -5 < v Initial program 84.9%
associate--l-84.9%
associate-*l*79.8%
sqr-neg79.8%
associate-*l*84.9%
associate-/l*85.9%
fma-define85.9%
Simplified85.9%
associate-/l*85.9%
*-commutative85.9%
associate-*r/85.9%
associate-*l*95.9%
associate-*r*99.8%
add-sqr-sqrt48.1%
associate-*l*48.1%
add-sqr-sqrt22.0%
sqrt-prod32.4%
sqrt-prod32.4%
sqrt-prod66.3%
*-commutative66.3%
sqrt-prod32.4%
*-commutative32.4%
sqrt-prod32.4%
sqrt-prod22.0%
add-sqr-sqrt48.1%
associate-*r*48.1%
add-sqr-sqrt99.8%
clear-num99.8%
un-div-inv99.8%
Applied egg-rr99.8%
associate-*r*98.8%
clear-num98.8%
un-div-inv98.8%
distribute-rgt-in98.8%
metadata-eval98.8%
*-commutative98.8%
associate-*l*98.8%
metadata-eval98.8%
associate-/l/98.8%
Applied egg-rr98.8%
Taylor expanded in v around 0 84.1%
associate-/l/84.0%
Simplified84.0%
Taylor expanded in v around 0 97.7%
associate-*r*97.8%
Simplified97.8%
Final simplification98.1%
(FPCore (v w r) :precision binary64 (+ (/ 2.0 (* r r)) (- -1.5 (* (* (* r w) (* r w)) 0.25))))
double code(double v, double w, double r) {
return (2.0 / (r * r)) + (-1.5 - (((r * w) * (r * w)) * 0.25));
}
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) * (r * w)) * 0.25d0))
end function
public static double code(double v, double w, double r) {
return (2.0 / (r * r)) + (-1.5 - (((r * w) * (r * w)) * 0.25));
}
def code(v, w, r): return (2.0 / (r * r)) + (-1.5 - (((r * w) * (r * w)) * 0.25))
function code(v, w, r) return Float64(Float64(2.0 / Float64(r * r)) + Float64(-1.5 - Float64(Float64(Float64(r * w) * Float64(r * w)) * 0.25))) end
function tmp = code(v, w, r) tmp = (2.0 / (r * r)) + (-1.5 - (((r * w) * (r * w)) * 0.25)); end
code[v_, w_, r_] := N[(N[(2.0 / N[(r * r), $MachinePrecision]), $MachinePrecision] + N[(-1.5 - N[(N[(N[(r * w), $MachinePrecision] * N[(r * w), $MachinePrecision]), $MachinePrecision] * 0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{2}{r \cdot r} + \left(-1.5 - \left(\left(r \cdot w\right) \cdot \left(r \cdot w\right)\right) \cdot 0.25\right)
\end{array}
Initial program 85.5%
Simplified86.9%
Taylor expanded in v around inf 78.8%
*-commutative78.8%
*-commutative78.8%
unpow278.8%
unpow278.8%
swap-sqr92.6%
unpow292.6%
*-commutative92.6%
Simplified92.6%
*-commutative92.6%
pow292.6%
Applied egg-rr92.6%
Final simplification92.6%
(FPCore (v w r) :precision binary64 (- (+ 3.0 (/ 2.0 (* r r))) 4.5))
double code(double v, double w, double r) {
return (3.0 + (2.0 / (r * r))) - 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))) - 4.5d0
end function
public static double code(double v, double w, double r) {
return (3.0 + (2.0 / (r * r))) - 4.5;
}
def code(v, w, r): return (3.0 + (2.0 / (r * r))) - 4.5
function code(v, w, r) return Float64(Float64(3.0 + Float64(2.0 / Float64(r * r))) - 4.5) end
function tmp = code(v, w, r) tmp = (3.0 + (2.0 / (r * r))) - 4.5; end
code[v_, w_, r_] := N[(N[(3.0 + N[(2.0 / N[(r * r), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 4.5), $MachinePrecision]
\begin{array}{l}
\\
\left(3 + \frac{2}{r \cdot r}\right) - 4.5
\end{array}
Initial program 85.5%
Simplified81.8%
Taylor expanded in r around 0 58.0%
Final simplification58.0%
herbie shell --seed 2024060
(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))