
(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;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(v, w, r)
use fmin_fmax_functions
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]
\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
Herbie found 11 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;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(v, w, r)
use fmin_fmax_functions
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]
\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
(FPCore (v w r)
:precision binary64
(let* ((t_0 (- 1.5 (/ 2.0 (* r r))))
(t_1 (* (* w 0.125) r))
(t_2 (- (fma t_1 (* 2.0 (* r w)) t_0))))
(if (<= v -2e+46)
t_2
(if (<= v 2.7e-13) (- (fma t_1 (* 3.0 (* r w)) t_0)) t_2))))double code(double v, double w, double r) {
double t_0 = 1.5 - (2.0 / (r * r));
double t_1 = (w * 0.125) * r;
double t_2 = -fma(t_1, (2.0 * (r * w)), t_0);
double tmp;
if (v <= -2e+46) {
tmp = t_2;
} else if (v <= 2.7e-13) {
tmp = -fma(t_1, (3.0 * (r * w)), t_0);
} else {
tmp = t_2;
}
return tmp;
}
function code(v, w, r) t_0 = Float64(1.5 - Float64(2.0 / Float64(r * r))) t_1 = Float64(Float64(w * 0.125) * r) t_2 = Float64(-fma(t_1, Float64(2.0 * Float64(r * w)), t_0)) tmp = 0.0 if (v <= -2e+46) tmp = t_2; elseif (v <= 2.7e-13) tmp = Float64(-fma(t_1, Float64(3.0 * Float64(r * w)), t_0)); else tmp = t_2; end return tmp end
code[v_, w_, r_] := Block[{t$95$0 = N[(1.5 - N[(2.0 / N[(r * r), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(w * 0.125), $MachinePrecision] * r), $MachinePrecision]}, Block[{t$95$2 = (-N[(t$95$1 * N[(2.0 * N[(r * w), $MachinePrecision]), $MachinePrecision] + t$95$0), $MachinePrecision])}, If[LessEqual[v, -2e+46], t$95$2, If[LessEqual[v, 2.7e-13], (-N[(t$95$1 * N[(3.0 * N[(r * w), $MachinePrecision]), $MachinePrecision] + t$95$0), $MachinePrecision]), t$95$2]]]]]
\begin{array}{l}
t_0 := 1.5 - \frac{2}{r \cdot r}\\
t_1 := \left(w \cdot 0.125\right) \cdot r\\
t_2 := -\mathsf{fma}\left(t\_1, 2 \cdot \left(r \cdot w\right), t\_0\right)\\
\mathbf{if}\;v \leq -2 \cdot 10^{+46}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;v \leq 2.7 \cdot 10^{-13}:\\
\;\;\;\;-\mathsf{fma}\left(t\_1, 3 \cdot \left(r \cdot w\right), t\_0\right)\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
if v < -2e46 or 2.7000000000000001e-13 < v Initial program 85.2%
lift--.f64N/A
sub-negate-revN/A
lower-neg.f64N/A
lift--.f64N/A
lift-+.f64N/A
associate--l+N/A
associate--r+N/A
lower--.f64N/A
metadata-evalN/A
lower--.f6485.2%
Applied rewrites90.4%
lift--.f64N/A
lift--.f64N/A
associate--r-N/A
+-commutativeN/A
Applied rewrites99.3%
Taylor expanded in v around inf
lower-*.f64N/A
lower-*.f6492.9%
Applied rewrites92.9%
if -2e46 < v < 2.7000000000000001e-13Initial program 85.2%
lift--.f64N/A
sub-negate-revN/A
lower-neg.f64N/A
lift--.f64N/A
lift-+.f64N/A
associate--l+N/A
associate--r+N/A
lower--.f64N/A
metadata-evalN/A
lower--.f6485.2%
Applied rewrites90.4%
lift--.f64N/A
lift--.f64N/A
associate--r-N/A
+-commutativeN/A
Applied rewrites99.3%
Taylor expanded in v around 0
lower-*.f64N/A
lower-*.f6493.5%
Applied rewrites93.5%
(FPCore (v w r)
:precision binary64
(let* ((t_0 (/ 2.0 (* (fabs r) (fabs r)))) (t_1 (* (* w 0.125) (fabs r))))
(if (<= (fabs r) 3.895e-43)
(- (fma t_1 (* 2.0 (* (fabs r) w)) (- 1.5 t_0)))
(+
t_0
(- (* (fma v 2.0 -3.0) (* (* t_1 w) (/ (fabs r) (- 1.0 v)))) 1.5)))))double code(double v, double w, double r) {
double t_0 = 2.0 / (fabs(r) * fabs(r));
double t_1 = (w * 0.125) * fabs(r);
double tmp;
if (fabs(r) <= 3.895e-43) {
tmp = -fma(t_1, (2.0 * (fabs(r) * w)), (1.5 - t_0));
} else {
tmp = t_0 + ((fma(v, 2.0, -3.0) * ((t_1 * w) * (fabs(r) / (1.0 - v)))) - 1.5);
}
return tmp;
}
function code(v, w, r) t_0 = Float64(2.0 / Float64(abs(r) * abs(r))) t_1 = Float64(Float64(w * 0.125) * abs(r)) tmp = 0.0 if (abs(r) <= 3.895e-43) tmp = Float64(-fma(t_1, Float64(2.0 * Float64(abs(r) * w)), Float64(1.5 - t_0))); else tmp = Float64(t_0 + Float64(Float64(fma(v, 2.0, -3.0) * Float64(Float64(t_1 * w) * Float64(abs(r) / Float64(1.0 - v)))) - 1.5)); end return tmp end
code[v_, w_, r_] := Block[{t$95$0 = N[(2.0 / N[(N[Abs[r], $MachinePrecision] * N[Abs[r], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(w * 0.125), $MachinePrecision] * N[Abs[r], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[Abs[r], $MachinePrecision], 3.895e-43], (-N[(t$95$1 * N[(2.0 * N[(N[Abs[r], $MachinePrecision] * w), $MachinePrecision]), $MachinePrecision] + N[(1.5 - t$95$0), $MachinePrecision]), $MachinePrecision]), N[(t$95$0 + N[(N[(N[(v * 2.0 + -3.0), $MachinePrecision] * N[(N[(t$95$1 * w), $MachinePrecision] * N[(N[Abs[r], $MachinePrecision] / N[(1.0 - v), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 1.5), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
t_0 := \frac{2}{\left|r\right| \cdot \left|r\right|}\\
t_1 := \left(w \cdot 0.125\right) \cdot \left|r\right|\\
\mathbf{if}\;\left|r\right| \leq 3.895 \cdot 10^{-43}:\\
\;\;\;\;-\mathsf{fma}\left(t\_1, 2 \cdot \left(\left|r\right| \cdot w\right), 1.5 - t\_0\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0 + \left(\mathsf{fma}\left(v, 2, -3\right) \cdot \left(\left(t\_1 \cdot w\right) \cdot \frac{\left|r\right|}{1 - v}\right) - 1.5\right)\\
\end{array}
if r < 3.8949999999999997e-43Initial program 85.2%
lift--.f64N/A
sub-negate-revN/A
lower-neg.f64N/A
lift--.f64N/A
lift-+.f64N/A
associate--l+N/A
associate--r+N/A
lower--.f64N/A
metadata-evalN/A
lower--.f6485.2%
Applied rewrites90.4%
lift--.f64N/A
lift--.f64N/A
associate--r-N/A
+-commutativeN/A
Applied rewrites99.3%
Taylor expanded in v around inf
lower-*.f64N/A
lower-*.f6492.9%
Applied rewrites92.9%
if 3.8949999999999997e-43 < r Initial program 85.2%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
lift-*.f64N/A
*-commutativeN/A
associate-*l*N/A
lower-*.f64N/A
lift--.f64N/A
lift-*.f64N/A
fp-cancel-sub-sign-invN/A
+-commutativeN/A
lower-fma.f64N/A
metadata-evalN/A
lower-*.f64N/A
lift-*.f64N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6487.7%
Applied rewrites87.7%
lift-*.f64N/A
*-commutativeN/A
lift-/.f64N/A
associate-*l/N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lift-*.f64N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6499.7%
Applied rewrites99.7%
Applied rewrites96.6%
(FPCore (v w r) :precision binary64 (- (- (+ 3.0 (/ 2.0 (* r r))) (* (fma -2.0 v 3.0) (* 0.125 (* (* w r) (/ 1.0 (/ (- 1.0 v) (* w r))))))) 4.5))
double code(double v, double w, double r) {
return ((3.0 + (2.0 / (r * r))) - (fma(-2.0, v, 3.0) * (0.125 * ((w * r) * (1.0 / ((1.0 - v) / (w * r))))))) - 4.5;
}
function code(v, w, r) return Float64(Float64(Float64(3.0 + Float64(2.0 / Float64(r * r))) - Float64(fma(-2.0, v, 3.0) * Float64(0.125 * Float64(Float64(w * r) * Float64(1.0 / Float64(Float64(1.0 - v) / Float64(w * r))))))) - 4.5) end
code[v_, w_, r_] := N[(N[(N[(3.0 + N[(2.0 / N[(r * r), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(N[(-2.0 * v + 3.0), $MachinePrecision] * N[(0.125 * N[(N[(w * r), $MachinePrecision] * N[(1.0 / N[(N[(1.0 - v), $MachinePrecision] / N[(w * r), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 4.5), $MachinePrecision]
\left(\left(3 + \frac{2}{r \cdot r}\right) - \mathsf{fma}\left(-2, v, 3\right) \cdot \left(0.125 \cdot \left(\left(w \cdot r\right) \cdot \frac{1}{\frac{1 - v}{w \cdot r}}\right)\right)\right) - 4.5
Initial program 85.2%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
lift-*.f64N/A
*-commutativeN/A
associate-*l*N/A
lower-*.f64N/A
lift--.f64N/A
lift-*.f64N/A
fp-cancel-sub-sign-invN/A
+-commutativeN/A
lower-fma.f64N/A
metadata-evalN/A
lower-*.f64N/A
lift-*.f64N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6487.7%
Applied rewrites87.7%
lift-*.f64N/A
*-commutativeN/A
lift-/.f64N/A
associate-*l/N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lift-*.f64N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6499.7%
Applied rewrites99.7%
lift-/.f64N/A
div-flipN/A
lower-unsound-/.f64N/A
lower-unsound-/.f6499.7%
Applied rewrites99.7%
(FPCore (v w r) :precision binary64 (- (- (+ 3.0 (/ 2.0 (* r r))) (* (fma -2.0 v 3.0) (* 0.125 (* (* w r) (/ (* w r) (- 1.0 v)))))) 4.5))
double code(double v, double w, double r) {
return ((3.0 + (2.0 / (r * r))) - (fma(-2.0, v, 3.0) * (0.125 * ((w * r) * ((w * r) / (1.0 - v)))))) - 4.5;
}
function code(v, w, r) return Float64(Float64(Float64(3.0 + Float64(2.0 / Float64(r * r))) - Float64(fma(-2.0, v, 3.0) * Float64(0.125 * Float64(Float64(w * r) * Float64(Float64(w * r) / Float64(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[(-2.0 * v + 3.0), $MachinePrecision] * N[(0.125 * N[(N[(w * r), $MachinePrecision] * N[(N[(w * r), $MachinePrecision] / N[(1.0 - v), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 4.5), $MachinePrecision]
\left(\left(3 + \frac{2}{r \cdot r}\right) - \mathsf{fma}\left(-2, v, 3\right) \cdot \left(0.125 \cdot \left(\left(w \cdot r\right) \cdot \frac{w \cdot r}{1 - v}\right)\right)\right) - 4.5
Initial program 85.2%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
lift-*.f64N/A
*-commutativeN/A
associate-*l*N/A
lower-*.f64N/A
lift--.f64N/A
lift-*.f64N/A
fp-cancel-sub-sign-invN/A
+-commutativeN/A
lower-fma.f64N/A
metadata-evalN/A
lower-*.f64N/A
lift-*.f64N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6487.7%
Applied rewrites87.7%
lift-*.f64N/A
*-commutativeN/A
lift-/.f64N/A
associate-*l/N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lift-*.f64N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6499.7%
Applied rewrites99.7%
(FPCore (v w r) :precision binary64 (- (fma (* (* w 0.125) r) (/ (fma v 2.0 -3.0) (/ (- v 1.0) (* w r))) (- 1.5 (/ 2.0 (* r r))))))
double code(double v, double w, double r) {
return -fma(((w * 0.125) * r), (fma(v, 2.0, -3.0) / ((v - 1.0) / (w * r))), (1.5 - (2.0 / (r * r))));
}
function code(v, w, r) return Float64(-fma(Float64(Float64(w * 0.125) * r), Float64(fma(v, 2.0, -3.0) / Float64(Float64(v - 1.0) / Float64(w * r))), Float64(1.5 - Float64(2.0 / Float64(r * r))))) end
code[v_, w_, r_] := (-N[(N[(N[(w * 0.125), $MachinePrecision] * r), $MachinePrecision] * N[(N[(v * 2.0 + -3.0), $MachinePrecision] / N[(N[(v - 1.0), $MachinePrecision] / N[(w * r), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(1.5 - N[(2.0 / N[(r * r), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision])
-\mathsf{fma}\left(\left(w \cdot 0.125\right) \cdot r, \frac{\mathsf{fma}\left(v, 2, -3\right)}{\frac{v - 1}{w \cdot r}}, 1.5 - \frac{2}{r \cdot r}\right)
Initial program 85.2%
lift--.f64N/A
sub-negate-revN/A
lower-neg.f64N/A
lift--.f64N/A
lift-+.f64N/A
associate--l+N/A
associate--r+N/A
lower--.f64N/A
metadata-evalN/A
lower--.f6485.2%
Applied rewrites90.4%
lift--.f64N/A
lift--.f64N/A
associate--r-N/A
+-commutativeN/A
Applied rewrites99.3%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
*-commutativeN/A
lift-*.f64N/A
div-flip-revN/A
lift-/.f64N/A
mult-flip-revN/A
lift-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
metadata-evalN/A
fp-cancel-sub-sign-invN/A
sub-negate-revN/A
lift-/.f64N/A
frac-2negN/A
distribute-frac-neg2N/A
distribute-neg-fracN/A
lift-/.f64N/A
frac-2neg-revN/A
lower-/.f64N/A
Applied rewrites99.7%
(FPCore (v w r)
:precision binary64
(let* ((t_0 (* (* w 0.125) (fabs r))))
(if (<= (fabs r) 1700.0)
(- (fma t_0 (* 2.0 (* (fabs r) w)) (- 1.5 (/ 2.0 (* (fabs r) (fabs r))))))
(- (fma t_0 (* (* (/ (fabs r) (- 1.0 v)) w) (fma v -2.0 3.0)) 1.5)))))double code(double v, double w, double r) {
double t_0 = (w * 0.125) * fabs(r);
double tmp;
if (fabs(r) <= 1700.0) {
tmp = -fma(t_0, (2.0 * (fabs(r) * w)), (1.5 - (2.0 / (fabs(r) * fabs(r)))));
} else {
tmp = -fma(t_0, (((fabs(r) / (1.0 - v)) * w) * fma(v, -2.0, 3.0)), 1.5);
}
return tmp;
}
function code(v, w, r) t_0 = Float64(Float64(w * 0.125) * abs(r)) tmp = 0.0 if (abs(r) <= 1700.0) tmp = Float64(-fma(t_0, Float64(2.0 * Float64(abs(r) * w)), Float64(1.5 - Float64(2.0 / Float64(abs(r) * abs(r)))))); else tmp = Float64(-fma(t_0, Float64(Float64(Float64(abs(r) / Float64(1.0 - v)) * w) * fma(v, -2.0, 3.0)), 1.5)); end return tmp end
code[v_, w_, r_] := Block[{t$95$0 = N[(N[(w * 0.125), $MachinePrecision] * N[Abs[r], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[Abs[r], $MachinePrecision], 1700.0], (-N[(t$95$0 * N[(2.0 * N[(N[Abs[r], $MachinePrecision] * w), $MachinePrecision]), $MachinePrecision] + N[(1.5 - N[(2.0 / N[(N[Abs[r], $MachinePrecision] * N[Abs[r], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), (-N[(t$95$0 * N[(N[(N[(N[Abs[r], $MachinePrecision] / N[(1.0 - v), $MachinePrecision]), $MachinePrecision] * w), $MachinePrecision] * N[(v * -2.0 + 3.0), $MachinePrecision]), $MachinePrecision] + 1.5), $MachinePrecision])]]
\begin{array}{l}
t_0 := \left(w \cdot 0.125\right) \cdot \left|r\right|\\
\mathbf{if}\;\left|r\right| \leq 1700:\\
\;\;\;\;-\mathsf{fma}\left(t\_0, 2 \cdot \left(\left|r\right| \cdot w\right), 1.5 - \frac{2}{\left|r\right| \cdot \left|r\right|}\right)\\
\mathbf{else}:\\
\;\;\;\;-\mathsf{fma}\left(t\_0, \left(\frac{\left|r\right|}{1 - v} \cdot w\right) \cdot \mathsf{fma}\left(v, -2, 3\right), 1.5\right)\\
\end{array}
if r < 1700Initial program 85.2%
lift--.f64N/A
sub-negate-revN/A
lower-neg.f64N/A
lift--.f64N/A
lift-+.f64N/A
associate--l+N/A
associate--r+N/A
lower--.f64N/A
metadata-evalN/A
lower--.f6485.2%
Applied rewrites90.4%
lift--.f64N/A
lift--.f64N/A
associate--r-N/A
+-commutativeN/A
Applied rewrites99.3%
Taylor expanded in v around inf
lower-*.f64N/A
lower-*.f6492.9%
Applied rewrites92.9%
if 1700 < r Initial program 85.2%
lift--.f64N/A
sub-negate-revN/A
lower-neg.f64N/A
lift--.f64N/A
lift-+.f64N/A
associate--l+N/A
associate--r+N/A
lower--.f64N/A
metadata-evalN/A
lower--.f6485.2%
Applied rewrites90.4%
lift--.f64N/A
lift--.f64N/A
associate--r-N/A
+-commutativeN/A
Applied rewrites99.3%
Taylor expanded in r around inf
Applied rewrites54.8%
(FPCore (v w r) :precision binary64 (- (fma (* (* w 0.125) r) (* (* (/ r (- 1.0 v)) w) (fma v -2.0 3.0)) (- 1.5 (/ 2.0 (* r r))))))
double code(double v, double w, double r) {
return -fma(((w * 0.125) * r), (((r / (1.0 - v)) * w) * fma(v, -2.0, 3.0)), (1.5 - (2.0 / (r * r))));
}
function code(v, w, r) return Float64(-fma(Float64(Float64(w * 0.125) * r), Float64(Float64(Float64(r / Float64(1.0 - v)) * w) * fma(v, -2.0, 3.0)), Float64(1.5 - Float64(2.0 / Float64(r * r))))) end
code[v_, w_, r_] := (-N[(N[(N[(w * 0.125), $MachinePrecision] * r), $MachinePrecision] * N[(N[(N[(r / N[(1.0 - v), $MachinePrecision]), $MachinePrecision] * w), $MachinePrecision] * N[(v * -2.0 + 3.0), $MachinePrecision]), $MachinePrecision] + N[(1.5 - N[(2.0 / N[(r * r), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision])
-\mathsf{fma}\left(\left(w \cdot 0.125\right) \cdot r, \left(\frac{r}{1 - v} \cdot w\right) \cdot \mathsf{fma}\left(v, -2, 3\right), 1.5 - \frac{2}{r \cdot r}\right)
Initial program 85.2%
lift--.f64N/A
sub-negate-revN/A
lower-neg.f64N/A
lift--.f64N/A
lift-+.f64N/A
associate--l+N/A
associate--r+N/A
lower--.f64N/A
metadata-evalN/A
lower--.f6485.2%
Applied rewrites90.4%
lift--.f64N/A
lift--.f64N/A
associate--r-N/A
+-commutativeN/A
Applied rewrites99.3%
(FPCore (v w r) :precision binary64 (- (fma (* (* w 0.125) r) (* 2.0 (* r w)) (- 1.5 (/ 2.0 (* r r))))))
double code(double v, double w, double r) {
return -fma(((w * 0.125) * r), (2.0 * (r * w)), (1.5 - (2.0 / (r * r))));
}
function code(v, w, r) return Float64(-fma(Float64(Float64(w * 0.125) * r), Float64(2.0 * Float64(r * w)), Float64(1.5 - Float64(2.0 / Float64(r * r))))) end
code[v_, w_, r_] := (-N[(N[(N[(w * 0.125), $MachinePrecision] * r), $MachinePrecision] * N[(2.0 * N[(r * w), $MachinePrecision]), $MachinePrecision] + N[(1.5 - N[(2.0 / N[(r * r), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision])
-\mathsf{fma}\left(\left(w \cdot 0.125\right) \cdot r, 2 \cdot \left(r \cdot w\right), 1.5 - \frac{2}{r \cdot r}\right)
Initial program 85.2%
lift--.f64N/A
sub-negate-revN/A
lower-neg.f64N/A
lift--.f64N/A
lift-+.f64N/A
associate--l+N/A
associate--r+N/A
lower--.f64N/A
metadata-evalN/A
lower--.f6485.2%
Applied rewrites90.4%
lift--.f64N/A
lift--.f64N/A
associate--r-N/A
+-commutativeN/A
Applied rewrites99.3%
Taylor expanded in v around inf
lower-*.f64N/A
lower-*.f6492.9%
Applied rewrites92.9%
(FPCore (v w r) :precision binary64 (- (* (- 1.0 (/ (/ 2.0 (* r r)) 1.5)) 1.5)))
double code(double v, double w, double r) {
return -((1.0 - ((2.0 / (r * r)) / 1.5)) * 1.5);
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(v, w, r)
use fmin_fmax_functions
real(8), intent (in) :: v
real(8), intent (in) :: w
real(8), intent (in) :: r
code = -((1.0d0 - ((2.0d0 / (r * r)) / 1.5d0)) * 1.5d0)
end function
public static double code(double v, double w, double r) {
return -((1.0 - ((2.0 / (r * r)) / 1.5)) * 1.5);
}
def code(v, w, r): return -((1.0 - ((2.0 / (r * r)) / 1.5)) * 1.5)
function code(v, w, r) return Float64(-Float64(Float64(1.0 - Float64(Float64(2.0 / Float64(r * r)) / 1.5)) * 1.5)) end
function tmp = code(v, w, r) tmp = -((1.0 - ((2.0 / (r * r)) / 1.5)) * 1.5); end
code[v_, w_, r_] := (-N[(N[(1.0 - N[(N[(2.0 / N[(r * r), $MachinePrecision]), $MachinePrecision] / 1.5), $MachinePrecision]), $MachinePrecision] * 1.5), $MachinePrecision])
-\left(1 - \frac{\frac{2}{r \cdot r}}{1.5}\right) \cdot 1.5
Initial program 85.2%
lift--.f64N/A
sub-negate-revN/A
lower-neg.f64N/A
lift--.f64N/A
lift-+.f64N/A
associate--l+N/A
associate--r+N/A
lower--.f64N/A
metadata-evalN/A
lower--.f6485.2%
Applied rewrites90.4%
Taylor expanded in w around 0
lower-/.f64N/A
lower-pow.f6458.0%
Applied rewrites58.0%
lift--.f64N/A
sub-to-multN/A
lower-unsound-*.f64N/A
Applied rewrites58.0%
(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;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(v, w, r)
use fmin_fmax_functions
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(2.0 / Float64(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[(2.0 / N[(r * r), $MachinePrecision]), $MachinePrecision] - 1.5), $MachinePrecision]
\frac{2}{r \cdot r} - 1.5
Initial program 85.2%
lift--.f64N/A
sub-negate-revN/A
lower-neg.f64N/A
lift--.f64N/A
lift-+.f64N/A
associate--l+N/A
associate--r+N/A
lower--.f64N/A
metadata-evalN/A
lower--.f6485.2%
Applied rewrites90.4%
Taylor expanded in w around 0
lower-/.f64N/A
lower-pow.f6458.0%
Applied rewrites58.0%
lift-neg.f64N/A
lift--.f64N/A
sub-negateN/A
lower--.f6458.0%
lift-pow.f64N/A
pow2N/A
lift-*.f6458.0%
Applied rewrites58.0%
(FPCore (v w r) :precision binary64 (/ 2.0 (* r r)))
double code(double v, double w, double r) {
return 2.0 / (r * r);
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(v, w, r)
use fmin_fmax_functions
real(8), intent (in) :: v
real(8), intent (in) :: w
real(8), intent (in) :: r
code = 2.0d0 / (r * r)
end function
public static double code(double v, double w, double r) {
return 2.0 / (r * r);
}
def code(v, w, r): return 2.0 / (r * r)
function code(v, w, r) return Float64(2.0 / Float64(r * r)) end
function tmp = code(v, w, r) tmp = 2.0 / (r * r); end
code[v_, w_, r_] := N[(2.0 / N[(r * r), $MachinePrecision]), $MachinePrecision]
\frac{2}{r \cdot r}
Initial program 85.2%
Taylor expanded in r around 0
lower-/.f64N/A
lower-pow.f6445.0%
Applied rewrites45.0%
lift-pow.f64N/A
pow2N/A
lift-*.f6445.0%
Applied rewrites45.0%
herbie shell --seed 2025191
(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))