
(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 8 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))
(* (* r w) (* (/ (fma v -0.25 0.375) (- 1.0 v)) (* r w)))))
-4.5))
double code(double v, double w, double r) {
return (3.0 + ((2.0 / (r * r)) - ((r * w) * ((fma(v, -0.25, 0.375) / (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(r * w) * Float64(Float64(fma(v, -0.25, 0.375) / Float64(1.0 - v)) * Float64(r * w))))) + -4.5) end
code[v_, w_, r_] := N[(N[(3.0 + N[(N[(2.0 / N[(r * r), $MachinePrecision]), $MachinePrecision] - N[(N[(r * w), $MachinePrecision] * N[(N[(N[(v * -0.25 + 0.375), $MachinePrecision] / N[(1.0 - v), $MachinePrecision]), $MachinePrecision] * N[(r * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -4.5), $MachinePrecision]
\begin{array}{l}
\\
\left(3 + \left(\frac{2}{r \cdot r} - \left(r \cdot w\right) \cdot \left(\frac{\mathsf{fma}\left(v, -0.25, 0.375\right)}{1 - v} \cdot \left(r \cdot w\right)\right)\right)\right) + -4.5
\end{array}
Initial program 83.1%
Simplified86.4%
associate-/r/86.4%
associate-*r*82.2%
swap-sqr99.8%
associate-*r*99.8%
+-commutative99.8%
distribute-rgt-in99.8%
*-commutative99.8%
associate-*l*99.8%
metadata-eval99.8%
metadata-eval99.8%
fma-udef99.8%
Applied egg-rr99.8%
Final simplification99.8%
(FPCore (v w r)
:precision binary64
(+
-4.5
(+
3.0
(-
(/ 2.0 (* r r))
(/
(* 0.125 (+ 3.0 (* v -2.0)))
(* (/ 1.0 (* r w)) (/ (- 1.0 v) (* r w))))))))
double code(double v, double w, double r) {
return -4.5 + (3.0 + ((2.0 / (r * r)) - ((0.125 * (3.0 + (v * -2.0))) / ((1.0 / (r * w)) * ((1.0 - v) / (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 = (-4.5d0) + (3.0d0 + ((2.0d0 / (r * r)) - ((0.125d0 * (3.0d0 + (v * (-2.0d0)))) / ((1.0d0 / (r * w)) * ((1.0d0 - v) / (r * w))))))
end function
public static double code(double v, double w, double r) {
return -4.5 + (3.0 + ((2.0 / (r * r)) - ((0.125 * (3.0 + (v * -2.0))) / ((1.0 / (r * w)) * ((1.0 - v) / (r * w))))));
}
def code(v, w, r): return -4.5 + (3.0 + ((2.0 / (r * r)) - ((0.125 * (3.0 + (v * -2.0))) / ((1.0 / (r * w)) * ((1.0 - v) / (r * w))))))
function code(v, w, r) return Float64(-4.5 + 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))))))) end
function tmp = code(v, w, r) tmp = -4.5 + (3.0 + ((2.0 / (r * r)) - ((0.125 * (3.0 + (v * -2.0))) / ((1.0 / (r * w)) * ((1.0 - v) / (r * w)))))); end
code[v_, w_, r_] := N[(-4.5 + 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]), $MachinePrecision]
\begin{array}{l}
\\
-4.5 + \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)
\end{array}
Initial program 83.1%
Simplified86.4%
associate-*r*97.9%
*-commutative97.9%
*-un-lft-identity97.9%
associate-*r*99.8%
times-frac99.8%
Applied egg-rr99.8%
Final simplification99.8%
(FPCore (v w r)
:precision binary64
(let* ((t_0 (/ 2.0 (* r r))))
(if (<= r 2e-48)
(+ (+ t_0 (* (* (* r w) (* r w)) -0.375)) -1.5)
(+
-4.5
(+
3.0
(- t_0 (* (* r w) (/ r (/ (- 1.0 v) (* w (+ 0.375 (* v -0.25))))))))))))
double code(double v, double w, double r) {
double t_0 = 2.0 / (r * r);
double tmp;
if (r <= 2e-48) {
tmp = (t_0 + (((r * w) * (r * w)) * -0.375)) + -1.5;
} else {
tmp = -4.5 + (3.0 + (t_0 - ((r * w) * (r / ((1.0 - v) / (w * (0.375 + (v * -0.25))))))));
}
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 (r <= 2d-48) then
tmp = (t_0 + (((r * w) * (r * w)) * (-0.375d0))) + (-1.5d0)
else
tmp = (-4.5d0) + (3.0d0 + (t_0 - ((r * w) * (r / ((1.0d0 - v) / (w * (0.375d0 + (v * (-0.25d0)))))))))
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 (r <= 2e-48) {
tmp = (t_0 + (((r * w) * (r * w)) * -0.375)) + -1.5;
} else {
tmp = -4.5 + (3.0 + (t_0 - ((r * w) * (r / ((1.0 - v) / (w * (0.375 + (v * -0.25))))))));
}
return tmp;
}
def code(v, w, r): t_0 = 2.0 / (r * r) tmp = 0 if r <= 2e-48: tmp = (t_0 + (((r * w) * (r * w)) * -0.375)) + -1.5 else: tmp = -4.5 + (3.0 + (t_0 - ((r * w) * (r / ((1.0 - v) / (w * (0.375 + (v * -0.25)))))))) return tmp
function code(v, w, r) t_0 = Float64(2.0 / Float64(r * r)) tmp = 0.0 if (r <= 2e-48) tmp = Float64(Float64(t_0 + Float64(Float64(Float64(r * w) * Float64(r * w)) * -0.375)) + -1.5); else tmp = Float64(-4.5 + Float64(3.0 + Float64(t_0 - Float64(Float64(r * w) * Float64(r / Float64(Float64(1.0 - v) / Float64(w * Float64(0.375 + Float64(v * -0.25))))))))); end return tmp end
function tmp_2 = code(v, w, r) t_0 = 2.0 / (r * r); tmp = 0.0; if (r <= 2e-48) tmp = (t_0 + (((r * w) * (r * w)) * -0.375)) + -1.5; else tmp = -4.5 + (3.0 + (t_0 - ((r * w) * (r / ((1.0 - v) / (w * (0.375 + (v * -0.25)))))))); end tmp_2 = tmp; end
code[v_, w_, r_] := Block[{t$95$0 = N[(2.0 / N[(r * r), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[r, 2e-48], N[(N[(t$95$0 + N[(N[(N[(r * w), $MachinePrecision] * N[(r * w), $MachinePrecision]), $MachinePrecision] * -0.375), $MachinePrecision]), $MachinePrecision] + -1.5), $MachinePrecision], N[(-4.5 + N[(3.0 + N[(t$95$0 - N[(N[(r * w), $MachinePrecision] * N[(r / N[(N[(1.0 - v), $MachinePrecision] / N[(w * N[(0.375 + N[(v * -0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{2}{r \cdot r}\\
\mathbf{if}\;r \leq 2 \cdot 10^{-48}:\\
\;\;\;\;\left(t_0 + \left(\left(r \cdot w\right) \cdot \left(r \cdot w\right)\right) \cdot -0.375\right) + -1.5\\
\mathbf{else}:\\
\;\;\;\;-4.5 + \left(3 + \left(t_0 - \left(r \cdot w\right) \cdot \frac{r}{\frac{1 - v}{w \cdot \left(0.375 + v \cdot -0.25\right)}}\right)\right)\\
\end{array}
\end{array}
if r < 1.9999999999999999e-48Initial program 81.5%
Simplified83.9%
Taylor expanded in v around 0 77.8%
*-commutative77.8%
unpow277.8%
unpow277.8%
swap-sqr93.9%
unpow293.9%
Simplified93.9%
unpow293.9%
Applied egg-rr93.9%
if 1.9999999999999999e-48 < r Initial program 88.1%
Simplified93.9%
associate-/r/93.9%
associate-*r*84.4%
swap-sqr99.8%
associate-*r*99.8%
+-commutative99.8%
distribute-rgt-in99.8%
*-commutative99.8%
associate-*l*99.8%
metadata-eval99.8%
metadata-eval99.8%
fma-udef99.8%
Applied egg-rr99.8%
Taylor expanded in r around 0 95.4%
associate-/l*99.8%
+-commutative99.8%
*-commutative99.8%
fma-udef99.8%
Simplified99.8%
Taylor expanded in w around 0 99.8%
Final simplification95.4%
(FPCore (v w r)
:precision binary64
(let* ((t_0 (/ 2.0 (* r r))))
(if (<= v -1.5)
(+ -4.5 (+ 3.0 (- t_0 (* (* r w) (/ r (+ (/ 4.0 w) (/ 2.0 (* v w))))))))
(if (<= v 1.0)
(+ -4.5 (+ 3.0 (- t_0 (* (* r w) (* w (* r 0.375))))))
(+ -4.5 (+ 3.0 (- t_0 (* (* r w) (/ r (/ 4.0 w))))))))))
double code(double v, double w, double r) {
double t_0 = 2.0 / (r * r);
double tmp;
if (v <= -1.5) {
tmp = -4.5 + (3.0 + (t_0 - ((r * w) * (r / ((4.0 / w) + (2.0 / (v * w)))))));
} else if (v <= 1.0) {
tmp = -4.5 + (3.0 + (t_0 - ((r * w) * (w * (r * 0.375)))));
} else {
tmp = -4.5 + (3.0 + (t_0 - ((r * w) * (r / (4.0 / 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 = 2.0d0 / (r * r)
if (v <= (-1.5d0)) then
tmp = (-4.5d0) + (3.0d0 + (t_0 - ((r * w) * (r / ((4.0d0 / w) + (2.0d0 / (v * w)))))))
else if (v <= 1.0d0) then
tmp = (-4.5d0) + (3.0d0 + (t_0 - ((r * w) * (w * (r * 0.375d0)))))
else
tmp = (-4.5d0) + (3.0d0 + (t_0 - ((r * w) * (r / (4.0d0 / w)))))
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 <= -1.5) {
tmp = -4.5 + (3.0 + (t_0 - ((r * w) * (r / ((4.0 / w) + (2.0 / (v * w)))))));
} else if (v <= 1.0) {
tmp = -4.5 + (3.0 + (t_0 - ((r * w) * (w * (r * 0.375)))));
} else {
tmp = -4.5 + (3.0 + (t_0 - ((r * w) * (r / (4.0 / w)))));
}
return tmp;
}
def code(v, w, r): t_0 = 2.0 / (r * r) tmp = 0 if v <= -1.5: tmp = -4.5 + (3.0 + (t_0 - ((r * w) * (r / ((4.0 / w) + (2.0 / (v * w))))))) elif v <= 1.0: tmp = -4.5 + (3.0 + (t_0 - ((r * w) * (w * (r * 0.375))))) else: tmp = -4.5 + (3.0 + (t_0 - ((r * w) * (r / (4.0 / w))))) return tmp
function code(v, w, r) t_0 = Float64(2.0 / Float64(r * r)) tmp = 0.0 if (v <= -1.5) tmp = Float64(-4.5 + Float64(3.0 + Float64(t_0 - Float64(Float64(r * w) * Float64(r / Float64(Float64(4.0 / w) + Float64(2.0 / Float64(v * w)))))))); elseif (v <= 1.0) tmp = Float64(-4.5 + Float64(3.0 + Float64(t_0 - Float64(Float64(r * w) * Float64(w * Float64(r * 0.375)))))); else tmp = Float64(-4.5 + Float64(3.0 + Float64(t_0 - Float64(Float64(r * w) * Float64(r / Float64(4.0 / w)))))); end return tmp end
function tmp_2 = code(v, w, r) t_0 = 2.0 / (r * r); tmp = 0.0; if (v <= -1.5) tmp = -4.5 + (3.0 + (t_0 - ((r * w) * (r / ((4.0 / w) + (2.0 / (v * w))))))); elseif (v <= 1.0) tmp = -4.5 + (3.0 + (t_0 - ((r * w) * (w * (r * 0.375))))); else tmp = -4.5 + (3.0 + (t_0 - ((r * w) * (r / (4.0 / w))))); end tmp_2 = tmp; end
code[v_, w_, r_] := Block[{t$95$0 = N[(2.0 / N[(r * r), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[v, -1.5], N[(-4.5 + N[(3.0 + N[(t$95$0 - N[(N[(r * w), $MachinePrecision] * N[(r / N[(N[(4.0 / w), $MachinePrecision] + N[(2.0 / N[(v * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[v, 1.0], N[(-4.5 + N[(3.0 + N[(t$95$0 - N[(N[(r * w), $MachinePrecision] * N[(w * N[(r * 0.375), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(-4.5 + N[(3.0 + N[(t$95$0 - N[(N[(r * w), $MachinePrecision] * N[(r / N[(4.0 / w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{2}{r \cdot r}\\
\mathbf{if}\;v \leq -1.5:\\
\;\;\;\;-4.5 + \left(3 + \left(t_0 - \left(r \cdot w\right) \cdot \frac{r}{\frac{4}{w} + \frac{2}{v \cdot w}}\right)\right)\\
\mathbf{elif}\;v \leq 1:\\
\;\;\;\;-4.5 + \left(3 + \left(t_0 - \left(r \cdot w\right) \cdot \left(w \cdot \left(r \cdot 0.375\right)\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;-4.5 + \left(3 + \left(t_0 - \left(r \cdot w\right) \cdot \frac{r}{\frac{4}{w}}\right)\right)\\
\end{array}
\end{array}
if v < -1.5Initial program 79.0%
Simplified84.9%
associate-/r/84.9%
associate-*r*79.5%
swap-sqr99.7%
associate-*r*99.8%
+-commutative99.8%
distribute-rgt-in99.8%
*-commutative99.8%
associate-*l*99.8%
metadata-eval99.8%
metadata-eval99.8%
fma-udef99.8%
Applied egg-rr99.8%
Taylor expanded in r around 0 78.1%
associate-/l*82.5%
+-commutative82.5%
*-commutative82.5%
fma-udef82.5%
Simplified82.5%
Taylor expanded in v around inf 99.0%
associate-*r/99.0%
metadata-eval99.0%
associate-*r/99.0%
metadata-eval99.0%
*-commutative99.0%
Simplified99.0%
if -1.5 < v < 1Initial program 83.7%
Simplified83.7%
associate-/r/83.7%
associate-*r*79.4%
swap-sqr99.9%
associate-*r*99.9%
+-commutative99.9%
distribute-rgt-in99.9%
*-commutative99.9%
associate-*l*99.9%
metadata-eval99.9%
metadata-eval99.9%
fma-udef99.9%
Applied egg-rr99.9%
Taylor expanded in v around 0 98.8%
associate-*r*98.9%
Simplified98.9%
if 1 < v Initial program 85.9%
Simplified92.6%
associate-/r/92.7%
associate-*r*89.7%
swap-sqr99.8%
associate-*r*99.8%
+-commutative99.8%
distribute-rgt-in99.8%
*-commutative99.8%
associate-*l*99.8%
metadata-eval99.8%
metadata-eval99.8%
fma-udef99.8%
Applied egg-rr99.8%
Taylor expanded in r around 0 89.9%
associate-/l*92.7%
+-commutative92.7%
*-commutative92.7%
fma-udef92.7%
Simplified92.7%
Taylor expanded in v around inf 99.9%
Final simplification99.2%
(FPCore (v w r)
:precision binary64
(let* ((t_0 (/ 2.0 (* r r))))
(if (or (<= v -1.25) (not (<= v 1.0)))
(+ -4.5 (+ 3.0 (- t_0 (* (* r w) (* w (* r 0.25))))))
(+ (+ t_0 (* (* (* r w) (* r w)) -0.375)) -1.5))))
double code(double v, double w, double r) {
double t_0 = 2.0 / (r * r);
double tmp;
if ((v <= -1.25) || !(v <= 1.0)) {
tmp = -4.5 + (3.0 + (t_0 - ((r * w) * (w * (r * 0.25)))));
} else {
tmp = (t_0 + (((r * w) * (r * w)) * -0.375)) + -1.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 <= (-1.25d0)) .or. (.not. (v <= 1.0d0))) then
tmp = (-4.5d0) + (3.0d0 + (t_0 - ((r * w) * (w * (r * 0.25d0)))))
else
tmp = (t_0 + (((r * w) * (r * w)) * (-0.375d0))) + (-1.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 <= -1.25) || !(v <= 1.0)) {
tmp = -4.5 + (3.0 + (t_0 - ((r * w) * (w * (r * 0.25)))));
} else {
tmp = (t_0 + (((r * w) * (r * w)) * -0.375)) + -1.5;
}
return tmp;
}
def code(v, w, r): t_0 = 2.0 / (r * r) tmp = 0 if (v <= -1.25) or not (v <= 1.0): tmp = -4.5 + (3.0 + (t_0 - ((r * w) * (w * (r * 0.25))))) else: tmp = (t_0 + (((r * w) * (r * w)) * -0.375)) + -1.5 return tmp
function code(v, w, r) t_0 = Float64(2.0 / Float64(r * r)) tmp = 0.0 if ((v <= -1.25) || !(v <= 1.0)) tmp = Float64(-4.5 + Float64(3.0 + Float64(t_0 - Float64(Float64(r * w) * Float64(w * Float64(r * 0.25)))))); else tmp = Float64(Float64(t_0 + Float64(Float64(Float64(r * w) * Float64(r * w)) * -0.375)) + -1.5); end return tmp end
function tmp_2 = code(v, w, r) t_0 = 2.0 / (r * r); tmp = 0.0; if ((v <= -1.25) || ~((v <= 1.0))) tmp = -4.5 + (3.0 + (t_0 - ((r * w) * (w * (r * 0.25))))); else tmp = (t_0 + (((r * w) * (r * w)) * -0.375)) + -1.5; end tmp_2 = tmp; end
code[v_, w_, r_] := Block[{t$95$0 = N[(2.0 / N[(r * r), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[v, -1.25], N[Not[LessEqual[v, 1.0]], $MachinePrecision]], N[(-4.5 + N[(3.0 + N[(t$95$0 - N[(N[(r * w), $MachinePrecision] * N[(w * N[(r * 0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(t$95$0 + N[(N[(N[(r * w), $MachinePrecision] * N[(r * w), $MachinePrecision]), $MachinePrecision] * -0.375), $MachinePrecision]), $MachinePrecision] + -1.5), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{2}{r \cdot r}\\
\mathbf{if}\;v \leq -1.25 \lor \neg \left(v \leq 1\right):\\
\;\;\;\;-4.5 + \left(3 + \left(t_0 - \left(r \cdot w\right) \cdot \left(w \cdot \left(r \cdot 0.25\right)\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\left(t_0 + \left(\left(r \cdot w\right) \cdot \left(r \cdot w\right)\right) \cdot -0.375\right) + -1.5\\
\end{array}
\end{array}
if v < -1.25 or 1 < v Initial program 82.6%
Simplified88.9%
associate-/r/89.0%
associate-*r*84.8%
swap-sqr99.8%
associate-*r*99.8%
+-commutative99.8%
distribute-rgt-in99.8%
*-commutative99.8%
associate-*l*99.8%
metadata-eval99.8%
metadata-eval99.8%
fma-udef99.8%
Applied egg-rr99.8%
Taylor expanded in v around inf 99.1%
associate-*r*99.1%
Simplified99.1%
if -1.25 < v < 1Initial program 83.7%
Simplified83.7%
Taylor expanded in v around 0 79.4%
*-commutative79.4%
unpow279.4%
unpow279.4%
swap-sqr98.8%
unpow298.8%
Simplified98.8%
unpow298.8%
Applied egg-rr98.8%
Final simplification99.0%
(FPCore (v w r)
:precision binary64
(let* ((t_0 (/ 2.0 (* r r))))
(if (or (<= v -1.2) (not (<= v 1.0)))
(+ -4.5 (+ 3.0 (- t_0 (* (* r w) (* w (* r 0.25))))))
(+ -4.5 (+ 3.0 (- t_0 (* (* r w) (* w (* r 0.375)))))))))
double code(double v, double w, double r) {
double t_0 = 2.0 / (r * r);
double tmp;
if ((v <= -1.2) || !(v <= 1.0)) {
tmp = -4.5 + (3.0 + (t_0 - ((r * w) * (w * (r * 0.25)))));
} else {
tmp = -4.5 + (3.0 + (t_0 - ((r * w) * (w * (r * 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) :: t_0
real(8) :: tmp
t_0 = 2.0d0 / (r * r)
if ((v <= (-1.2d0)) .or. (.not. (v <= 1.0d0))) then
tmp = (-4.5d0) + (3.0d0 + (t_0 - ((r * w) * (w * (r * 0.25d0)))))
else
tmp = (-4.5d0) + (3.0d0 + (t_0 - ((r * w) * (w * (r * 0.375d0)))))
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 <= -1.2) || !(v <= 1.0)) {
tmp = -4.5 + (3.0 + (t_0 - ((r * w) * (w * (r * 0.25)))));
} else {
tmp = -4.5 + (3.0 + (t_0 - ((r * w) * (w * (r * 0.375)))));
}
return tmp;
}
def code(v, w, r): t_0 = 2.0 / (r * r) tmp = 0 if (v <= -1.2) or not (v <= 1.0): tmp = -4.5 + (3.0 + (t_0 - ((r * w) * (w * (r * 0.25))))) else: tmp = -4.5 + (3.0 + (t_0 - ((r * w) * (w * (r * 0.375))))) return tmp
function code(v, w, r) t_0 = Float64(2.0 / Float64(r * r)) tmp = 0.0 if ((v <= -1.2) || !(v <= 1.0)) tmp = Float64(-4.5 + Float64(3.0 + Float64(t_0 - Float64(Float64(r * w) * Float64(w * Float64(r * 0.25)))))); else tmp = Float64(-4.5 + Float64(3.0 + Float64(t_0 - Float64(Float64(r * w) * Float64(w * Float64(r * 0.375)))))); end return tmp end
function tmp_2 = code(v, w, r) t_0 = 2.0 / (r * r); tmp = 0.0; if ((v <= -1.2) || ~((v <= 1.0))) tmp = -4.5 + (3.0 + (t_0 - ((r * w) * (w * (r * 0.25))))); else tmp = -4.5 + (3.0 + (t_0 - ((r * w) * (w * (r * 0.375))))); end tmp_2 = tmp; end
code[v_, w_, r_] := Block[{t$95$0 = N[(2.0 / N[(r * r), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[v, -1.2], N[Not[LessEqual[v, 1.0]], $MachinePrecision]], N[(-4.5 + N[(3.0 + N[(t$95$0 - N[(N[(r * w), $MachinePrecision] * N[(w * N[(r * 0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(-4.5 + N[(3.0 + N[(t$95$0 - N[(N[(r * w), $MachinePrecision] * N[(w * N[(r * 0.375), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{2}{r \cdot r}\\
\mathbf{if}\;v \leq -1.2 \lor \neg \left(v \leq 1\right):\\
\;\;\;\;-4.5 + \left(3 + \left(t_0 - \left(r \cdot w\right) \cdot \left(w \cdot \left(r \cdot 0.25\right)\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;-4.5 + \left(3 + \left(t_0 - \left(r \cdot w\right) \cdot \left(w \cdot \left(r \cdot 0.375\right)\right)\right)\right)\\
\end{array}
\end{array}
if v < -1.19999999999999996 or 1 < v Initial program 82.6%
Simplified88.9%
associate-/r/89.0%
associate-*r*84.8%
swap-sqr99.8%
associate-*r*99.8%
+-commutative99.8%
distribute-rgt-in99.8%
*-commutative99.8%
associate-*l*99.8%
metadata-eval99.8%
metadata-eval99.8%
fma-udef99.8%
Applied egg-rr99.8%
Taylor expanded in v around inf 99.1%
associate-*r*99.1%
Simplified99.1%
if -1.19999999999999996 < v < 1Initial program 83.7%
Simplified83.7%
associate-/r/83.7%
associate-*r*79.4%
swap-sqr99.9%
associate-*r*99.9%
+-commutative99.9%
distribute-rgt-in99.9%
*-commutative99.9%
associate-*l*99.9%
metadata-eval99.9%
metadata-eval99.9%
fma-udef99.9%
Applied egg-rr99.9%
Taylor expanded in v around 0 98.8%
associate-*r*98.9%
Simplified98.9%
Final simplification99.0%
(FPCore (v w r)
:precision binary64
(let* ((t_0 (/ 2.0 (* r r))))
(if (or (<= v -1.4) (not (<= v 1.0)))
(+ -4.5 (+ 3.0 (- t_0 (* (* r w) (/ r (/ 4.0 w))))))
(+ -4.5 (+ 3.0 (- t_0 (* (* r w) (* w (* r 0.375)))))))))
double code(double v, double w, double r) {
double t_0 = 2.0 / (r * r);
double tmp;
if ((v <= -1.4) || !(v <= 1.0)) {
tmp = -4.5 + (3.0 + (t_0 - ((r * w) * (r / (4.0 / w)))));
} else {
tmp = -4.5 + (3.0 + (t_0 - ((r * w) * (w * (r * 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) :: t_0
real(8) :: tmp
t_0 = 2.0d0 / (r * r)
if ((v <= (-1.4d0)) .or. (.not. (v <= 1.0d0))) then
tmp = (-4.5d0) + (3.0d0 + (t_0 - ((r * w) * (r / (4.0d0 / w)))))
else
tmp = (-4.5d0) + (3.0d0 + (t_0 - ((r * w) * (w * (r * 0.375d0)))))
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 <= -1.4) || !(v <= 1.0)) {
tmp = -4.5 + (3.0 + (t_0 - ((r * w) * (r / (4.0 / w)))));
} else {
tmp = -4.5 + (3.0 + (t_0 - ((r * w) * (w * (r * 0.375)))));
}
return tmp;
}
def code(v, w, r): t_0 = 2.0 / (r * r) tmp = 0 if (v <= -1.4) or not (v <= 1.0): tmp = -4.5 + (3.0 + (t_0 - ((r * w) * (r / (4.0 / w))))) else: tmp = -4.5 + (3.0 + (t_0 - ((r * w) * (w * (r * 0.375))))) return tmp
function code(v, w, r) t_0 = Float64(2.0 / Float64(r * r)) tmp = 0.0 if ((v <= -1.4) || !(v <= 1.0)) tmp = Float64(-4.5 + Float64(3.0 + Float64(t_0 - Float64(Float64(r * w) * Float64(r / Float64(4.0 / w)))))); else tmp = Float64(-4.5 + Float64(3.0 + Float64(t_0 - Float64(Float64(r * w) * Float64(w * Float64(r * 0.375)))))); end return tmp end
function tmp_2 = code(v, w, r) t_0 = 2.0 / (r * r); tmp = 0.0; if ((v <= -1.4) || ~((v <= 1.0))) tmp = -4.5 + (3.0 + (t_0 - ((r * w) * (r / (4.0 / w))))); else tmp = -4.5 + (3.0 + (t_0 - ((r * w) * (w * (r * 0.375))))); end tmp_2 = tmp; end
code[v_, w_, r_] := Block[{t$95$0 = N[(2.0 / N[(r * r), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[v, -1.4], N[Not[LessEqual[v, 1.0]], $MachinePrecision]], N[(-4.5 + N[(3.0 + N[(t$95$0 - N[(N[(r * w), $MachinePrecision] * N[(r / N[(4.0 / w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(-4.5 + N[(3.0 + N[(t$95$0 - N[(N[(r * w), $MachinePrecision] * N[(w * N[(r * 0.375), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{2}{r \cdot r}\\
\mathbf{if}\;v \leq -1.4 \lor \neg \left(v \leq 1\right):\\
\;\;\;\;-4.5 + \left(3 + \left(t_0 - \left(r \cdot w\right) \cdot \frac{r}{\frac{4}{w}}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;-4.5 + \left(3 + \left(t_0 - \left(r \cdot w\right) \cdot \left(w \cdot \left(r \cdot 0.375\right)\right)\right)\right)\\
\end{array}
\end{array}
if v < -1.3999999999999999 or 1 < v Initial program 82.6%
Simplified88.9%
associate-/r/89.0%
associate-*r*84.8%
swap-sqr99.8%
associate-*r*99.8%
+-commutative99.8%
distribute-rgt-in99.8%
*-commutative99.8%
associate-*l*99.8%
metadata-eval99.8%
metadata-eval99.8%
fma-udef99.8%
Applied egg-rr99.8%
Taylor expanded in r around 0 84.3%
associate-/l*87.8%
+-commutative87.8%
*-commutative87.8%
fma-udef87.8%
Simplified87.8%
Taylor expanded in v around inf 99.1%
if -1.3999999999999999 < v < 1Initial program 83.7%
Simplified83.7%
associate-/r/83.7%
associate-*r*79.4%
swap-sqr99.9%
associate-*r*99.9%
+-commutative99.9%
distribute-rgt-in99.9%
*-commutative99.9%
associate-*l*99.9%
metadata-eval99.9%
metadata-eval99.9%
fma-udef99.9%
Applied egg-rr99.9%
Taylor expanded in v around 0 98.8%
associate-*r*98.9%
Simplified98.9%
Final simplification99.0%
(FPCore (v w r) :precision binary64 (+ (+ (/ 2.0 (* r r)) (* (* (* r w) (* r w)) -0.375)) -1.5))
double code(double v, double w, double r) {
return ((2.0 / (r * r)) + (((r * w) * (r * w)) * -0.375)) + -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)) + (((r * w) * (r * w)) * (-0.375d0))) + (-1.5d0)
end function
public static double code(double v, double w, double r) {
return ((2.0 / (r * r)) + (((r * w) * (r * w)) * -0.375)) + -1.5;
}
def code(v, w, r): return ((2.0 / (r * r)) + (((r * w) * (r * w)) * -0.375)) + -1.5
function code(v, w, r) return Float64(Float64(Float64(2.0 / Float64(r * r)) + Float64(Float64(Float64(r * w) * Float64(r * w)) * -0.375)) + -1.5) end
function tmp = code(v, w, r) tmp = ((2.0 / (r * r)) + (((r * w) * (r * w)) * -0.375)) + -1.5; end
code[v_, w_, r_] := N[(N[(N[(2.0 / N[(r * r), $MachinePrecision]), $MachinePrecision] + N[(N[(N[(r * w), $MachinePrecision] * N[(r * w), $MachinePrecision]), $MachinePrecision] * -0.375), $MachinePrecision]), $MachinePrecision] + -1.5), $MachinePrecision]
\begin{array}{l}
\\
\left(\frac{2}{r \cdot r} + \left(\left(r \cdot w\right) \cdot \left(r \cdot w\right)\right) \cdot -0.375\right) + -1.5
\end{array}
Initial program 83.1%
Simplified86.4%
Taylor expanded in v around 0 77.6%
*-commutative77.6%
unpow277.6%
unpow277.6%
swap-sqr92.9%
unpow292.9%
Simplified92.9%
unpow292.9%
Applied egg-rr92.9%
Final simplification92.9%
herbie shell --seed 2023315
(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))