
(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]
\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}
Herbie found 14 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]
\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)) 3.0) (fma (fma -0.25 v 0.375) (/ (* (* r w) (* r w)) (- 1.0 v)) 4.5)))
double code(double v, double w, double r) {
return ((2.0 / (r * r)) + 3.0) - fma(fma(-0.25, v, 0.375), (((r * w) * (r * w)) / (1.0 - v)), 4.5);
}
function code(v, w, r) return Float64(Float64(Float64(2.0 / Float64(r * r)) + 3.0) - fma(fma(-0.25, v, 0.375), Float64(Float64(Float64(r * w) * Float64(r * w)) / Float64(1.0 - v)), 4.5)) end
code[v_, w_, r_] := N[(N[(N[(2.0 / N[(r * r), $MachinePrecision]), $MachinePrecision] + 3.0), $MachinePrecision] - N[(N[(-0.25 * v + 0.375), $MachinePrecision] * N[(N[(N[(r * w), $MachinePrecision] * N[(r * w), $MachinePrecision]), $MachinePrecision] / N[(1.0 - v), $MachinePrecision]), $MachinePrecision] + 4.5), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(\frac{2}{r \cdot r} + 3\right) - \mathsf{fma}\left(\mathsf{fma}\left(-0.25, v, 0.375\right), \frac{\left(r \cdot w\right) \cdot \left(r \cdot w\right)}{1 - v}, 4.5\right)
\end{array}
Initial program 85.5%
Applied rewrites99.6%
Taylor expanded in v around 0
*-commutativeN/A
+-commutativeN/A
metadata-evalN/A
fp-cancel-sub-sign-invN/A
+-commutativeN/A
lower-fma.f6499.7
Applied rewrites99.7%
(FPCore (v w r) :precision binary64 (if (<= r 3000000.0) (- (/ (/ 2.0 r) r) (fma (* (* (* r r) 0.25) w) w 1.5)) (- 3.0 (fma (fma -0.25 v 0.375) (/ (* (* r w) (* r w)) (- 1.0 v)) 4.5))))
double code(double v, double w, double r) {
double tmp;
if (r <= 3000000.0) {
tmp = ((2.0 / r) / r) - fma((((r * r) * 0.25) * w), w, 1.5);
} else {
tmp = 3.0 - fma(fma(-0.25, v, 0.375), (((r * w) * (r * w)) / (1.0 - v)), 4.5);
}
return tmp;
}
function code(v, w, r) tmp = 0.0 if (r <= 3000000.0) tmp = Float64(Float64(Float64(2.0 / r) / r) - fma(Float64(Float64(Float64(r * r) * 0.25) * w), w, 1.5)); else tmp = Float64(3.0 - fma(fma(-0.25, v, 0.375), Float64(Float64(Float64(r * w) * Float64(r * w)) / Float64(1.0 - v)), 4.5)); end return tmp end
code[v_, w_, r_] := If[LessEqual[r, 3000000.0], N[(N[(N[(2.0 / r), $MachinePrecision] / r), $MachinePrecision] - N[(N[(N[(N[(r * r), $MachinePrecision] * 0.25), $MachinePrecision] * w), $MachinePrecision] * w + 1.5), $MachinePrecision]), $MachinePrecision], N[(3.0 - N[(N[(-0.25 * v + 0.375), $MachinePrecision] * N[(N[(N[(r * w), $MachinePrecision] * N[(r * w), $MachinePrecision]), $MachinePrecision] / N[(1.0 - v), $MachinePrecision]), $MachinePrecision] + 4.5), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;r \leq 3000000:\\
\;\;\;\;\frac{\frac{2}{r}}{r} - \mathsf{fma}\left(\left(\left(r \cdot r\right) \cdot 0.25\right) \cdot w, w, 1.5\right)\\
\mathbf{else}:\\
\;\;\;\;3 - \mathsf{fma}\left(\mathsf{fma}\left(-0.25, v, 0.375\right), \frac{\left(r \cdot w\right) \cdot \left(r \cdot w\right)}{1 - v}, 4.5\right)\\
\end{array}
\end{array}
if r < 3e6Initial program 85.5%
Taylor expanded in v around inf
lower--.f64N/A
associate-*r/N/A
metadata-evalN/A
pow2N/A
lift-/.f64N/A
lift-*.f64N/A
+-commutativeN/A
associate-*r*N/A
lower-fma.f64N/A
lower-*.f64N/A
pow2N/A
lift-*.f64N/A
pow2N/A
lift-*.f6479.0
Applied rewrites79.0%
lift-*.f64N/A
lift-fma.f64N/A
associate-*r*N/A
lower-fma.f64N/A
lift-*.f64N/A
lift-*.f64N/A
pow2N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
pow2N/A
lift-*.f6487.2
Applied rewrites87.2%
lift-*.f64N/A
lift-/.f64N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f6487.2
Applied rewrites87.2%
if 3e6 < r Initial program 85.5%
Applied rewrites99.6%
Taylor expanded in v around 0
*-commutativeN/A
+-commutativeN/A
metadata-evalN/A
fp-cancel-sub-sign-invN/A
+-commutativeN/A
lower-fma.f6499.7
Applied rewrites99.7%
Taylor expanded in r around inf
Applied rewrites56.4%
(FPCore (v w r) :precision binary64 (if (<= r 3000000.0) (- (/ (/ 2.0 r) r) (fma (* (* (* r r) 0.25) w) w 1.5)) (- 3.0 (fma (fma -0.25 v 0.375) (* (* w r) (/ (* w r) (- 1.0 v))) 4.5))))
double code(double v, double w, double r) {
double tmp;
if (r <= 3000000.0) {
tmp = ((2.0 / r) / r) - fma((((r * r) * 0.25) * w), w, 1.5);
} else {
tmp = 3.0 - fma(fma(-0.25, v, 0.375), ((w * r) * ((w * r) / (1.0 - v))), 4.5);
}
return tmp;
}
function code(v, w, r) tmp = 0.0 if (r <= 3000000.0) tmp = Float64(Float64(Float64(2.0 / r) / r) - fma(Float64(Float64(Float64(r * r) * 0.25) * w), w, 1.5)); else tmp = Float64(3.0 - fma(fma(-0.25, v, 0.375), Float64(Float64(w * r) * Float64(Float64(w * r) / Float64(1.0 - v))), 4.5)); end return tmp end
code[v_, w_, r_] := If[LessEqual[r, 3000000.0], N[(N[(N[(2.0 / r), $MachinePrecision] / r), $MachinePrecision] - N[(N[(N[(N[(r * r), $MachinePrecision] * 0.25), $MachinePrecision] * w), $MachinePrecision] * w + 1.5), $MachinePrecision]), $MachinePrecision], N[(3.0 - N[(N[(-0.25 * v + 0.375), $MachinePrecision] * N[(N[(w * r), $MachinePrecision] * N[(N[(w * r), $MachinePrecision] / N[(1.0 - v), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + 4.5), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;r \leq 3000000:\\
\;\;\;\;\frac{\frac{2}{r}}{r} - \mathsf{fma}\left(\left(\left(r \cdot r\right) \cdot 0.25\right) \cdot w, w, 1.5\right)\\
\mathbf{else}:\\
\;\;\;\;3 - \mathsf{fma}\left(\mathsf{fma}\left(-0.25, v, 0.375\right), \left(w \cdot r\right) \cdot \frac{w \cdot r}{1 - v}, 4.5\right)\\
\end{array}
\end{array}
if r < 3e6Initial program 85.5%
Taylor expanded in v around inf
lower--.f64N/A
associate-*r/N/A
metadata-evalN/A
pow2N/A
lift-/.f64N/A
lift-*.f64N/A
+-commutativeN/A
associate-*r*N/A
lower-fma.f64N/A
lower-*.f64N/A
pow2N/A
lift-*.f64N/A
pow2N/A
lift-*.f6479.0
Applied rewrites79.0%
lift-*.f64N/A
lift-fma.f64N/A
associate-*r*N/A
lower-fma.f64N/A
lift-*.f64N/A
lift-*.f64N/A
pow2N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
pow2N/A
lift-*.f6487.2
Applied rewrites87.2%
lift-*.f64N/A
lift-/.f64N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f6487.2
Applied rewrites87.2%
if 3e6 < r Initial program 85.5%
Applied rewrites99.6%
Taylor expanded in v around 0
*-commutativeN/A
+-commutativeN/A
metadata-evalN/A
fp-cancel-sub-sign-invN/A
+-commutativeN/A
lower-fma.f6499.7
Applied rewrites99.7%
Taylor expanded in r around inf
Applied rewrites56.4%
lift--.f64N/A
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
lower-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lower-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift--.f6456.4
Applied rewrites56.4%
(FPCore (v w r)
:precision binary64
(let* ((t_0 (/ 2.0 (* r r))))
(if (<= w 1.2e+17)
(- (- (+ 3.0 t_0) (* (* (* w (* w r)) r) 0.375)) 4.5)
(- t_0 (fma (* (* (* r r) 0.25) w) w 1.5)))))
double code(double v, double w, double r) {
double t_0 = 2.0 / (r * r);
double tmp;
if (w <= 1.2e+17) {
tmp = ((3.0 + t_0) - (((w * (w * r)) * r) * 0.375)) - 4.5;
} else {
tmp = t_0 - fma((((r * r) * 0.25) * w), w, 1.5);
}
return tmp;
}
function code(v, w, r) t_0 = Float64(2.0 / Float64(r * r)) tmp = 0.0 if (w <= 1.2e+17) tmp = Float64(Float64(Float64(3.0 + t_0) - Float64(Float64(Float64(w * Float64(w * r)) * r) * 0.375)) - 4.5); else tmp = Float64(t_0 - fma(Float64(Float64(Float64(r * r) * 0.25) * w), w, 1.5)); end return tmp end
code[v_, w_, r_] := Block[{t$95$0 = N[(2.0 / N[(r * r), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[w, 1.2e+17], N[(N[(N[(3.0 + t$95$0), $MachinePrecision] - N[(N[(N[(w * N[(w * r), $MachinePrecision]), $MachinePrecision] * r), $MachinePrecision] * 0.375), $MachinePrecision]), $MachinePrecision] - 4.5), $MachinePrecision], N[(t$95$0 - N[(N[(N[(N[(r * r), $MachinePrecision] * 0.25), $MachinePrecision] * w), $MachinePrecision] * w + 1.5), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{2}{r \cdot r}\\
\mathbf{if}\;w \leq 1.2 \cdot 10^{+17}:\\
\;\;\;\;\left(\left(3 + t\_0\right) - \left(\left(w \cdot \left(w \cdot r\right)\right) \cdot r\right) \cdot 0.375\right) - 4.5\\
\mathbf{else}:\\
\;\;\;\;t\_0 - \mathsf{fma}\left(\left(\left(r \cdot r\right) \cdot 0.25\right) \cdot w, w, 1.5\right)\\
\end{array}
\end{array}
if w < 1.2e17Initial program 85.5%
Taylor expanded in v around inf
lower-*.f6474.1
Applied rewrites74.1%
Taylor expanded in v around 0
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
pow2N/A
associate-*l*N/A
pow2N/A
lower-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lift-*.f64N/A
lower-*.f6490.7
lift-*.f64N/A
*-commutativeN/A
lower-*.f6490.7
Applied rewrites90.7%
if 1.2e17 < w Initial program 85.5%
Taylor expanded in v around inf
lower--.f64N/A
associate-*r/N/A
metadata-evalN/A
pow2N/A
lift-/.f64N/A
lift-*.f64N/A
+-commutativeN/A
associate-*r*N/A
lower-fma.f64N/A
lower-*.f64N/A
pow2N/A
lift-*.f64N/A
pow2N/A
lift-*.f6479.0
Applied rewrites79.0%
lift-*.f64N/A
lift-fma.f64N/A
associate-*r*N/A
lower-fma.f64N/A
lift-*.f64N/A
lift-*.f64N/A
pow2N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
pow2N/A
lift-*.f6487.2
Applied rewrites87.2%
(FPCore (v w r)
:precision binary64
(let* ((t_0 (/ 2.0 (* r r))))
(if (<= w 1.2e+17)
(- t_0 (fma (* (* w (* w r)) r) 0.375 1.5))
(- t_0 (fma (* (* (* r r) 0.25) w) w 1.5)))))
double code(double v, double w, double r) {
double t_0 = 2.0 / (r * r);
double tmp;
if (w <= 1.2e+17) {
tmp = t_0 - fma(((w * (w * r)) * r), 0.375, 1.5);
} else {
tmp = t_0 - fma((((r * r) * 0.25) * w), w, 1.5);
}
return tmp;
}
function code(v, w, r) t_0 = Float64(2.0 / Float64(r * r)) tmp = 0.0 if (w <= 1.2e+17) tmp = Float64(t_0 - fma(Float64(Float64(w * Float64(w * r)) * r), 0.375, 1.5)); else tmp = Float64(t_0 - fma(Float64(Float64(Float64(r * r) * 0.25) * w), w, 1.5)); end return tmp end
code[v_, w_, r_] := Block[{t$95$0 = N[(2.0 / N[(r * r), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[w, 1.2e+17], N[(t$95$0 - N[(N[(N[(w * N[(w * r), $MachinePrecision]), $MachinePrecision] * r), $MachinePrecision] * 0.375 + 1.5), $MachinePrecision]), $MachinePrecision], N[(t$95$0 - N[(N[(N[(N[(r * r), $MachinePrecision] * 0.25), $MachinePrecision] * w), $MachinePrecision] * w + 1.5), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{2}{r \cdot r}\\
\mathbf{if}\;w \leq 1.2 \cdot 10^{+17}:\\
\;\;\;\;t\_0 - \mathsf{fma}\left(\left(w \cdot \left(w \cdot r\right)\right) \cdot r, 0.375, 1.5\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0 - \mathsf{fma}\left(\left(\left(r \cdot r\right) \cdot 0.25\right) \cdot w, w, 1.5\right)\\
\end{array}
\end{array}
if w < 1.2e17Initial program 85.5%
Applied rewrites99.6%
Taylor expanded in v around 0
lower--.f64N/A
associate-*r/N/A
metadata-evalN/A
pow2N/A
lift-/.f64N/A
lift-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites90.7%
if 1.2e17 < w Initial program 85.5%
Taylor expanded in v around inf
lower--.f64N/A
associate-*r/N/A
metadata-evalN/A
pow2N/A
lift-/.f64N/A
lift-*.f64N/A
+-commutativeN/A
associate-*r*N/A
lower-fma.f64N/A
lower-*.f64N/A
pow2N/A
lift-*.f64N/A
pow2N/A
lift-*.f6479.0
Applied rewrites79.0%
lift-*.f64N/A
lift-fma.f64N/A
associate-*r*N/A
lower-fma.f64N/A
lift-*.f64N/A
lift-*.f64N/A
pow2N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
pow2N/A
lift-*.f6487.2
Applied rewrites87.2%
(FPCore (v w r)
:precision binary64
(let* ((t_0
(-
(-
(+ 3.0 (/ 2.0 (* r r)))
(/ (* (* 0.125 (- 3.0 (* 2.0 v))) (* (* (* w w) r) r)) (- 1.0 v)))
4.5)))
(if (<= t_0 (- INFINITY))
(* (* (* w (* w r)) r) -0.25)
(if (<= t_0 -1.0)
(- 3.0 (fma 0.375 (/ (* (* r w) (* r w)) (- 1.0 v)) 4.5))
(/ (fma -1.5 (* r r) 2.0) (* r r))))))
double code(double v, double w, double r) {
double t_0 = ((3.0 + (2.0 / (r * r))) - (((0.125 * (3.0 - (2.0 * v))) * (((w * w) * r) * r)) / (1.0 - v))) - 4.5;
double tmp;
if (t_0 <= -((double) INFINITY)) {
tmp = ((w * (w * r)) * r) * -0.25;
} else if (t_0 <= -1.0) {
tmp = 3.0 - fma(0.375, (((r * w) * (r * w)) / (1.0 - v)), 4.5);
} else {
tmp = fma(-1.5, (r * r), 2.0) / (r * r);
}
return tmp;
}
function code(v, w, r) t_0 = 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) tmp = 0.0 if (t_0 <= Float64(-Inf)) tmp = Float64(Float64(Float64(w * Float64(w * r)) * r) * -0.25); elseif (t_0 <= -1.0) tmp = Float64(3.0 - fma(0.375, Float64(Float64(Float64(r * w) * Float64(r * w)) / Float64(1.0 - v)), 4.5)); else tmp = Float64(fma(-1.5, Float64(r * r), 2.0) / Float64(r * r)); end return tmp end
code[v_, w_, r_] := Block[{t$95$0 = 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]}, If[LessEqual[t$95$0, (-Infinity)], N[(N[(N[(w * N[(w * r), $MachinePrecision]), $MachinePrecision] * r), $MachinePrecision] * -0.25), $MachinePrecision], If[LessEqual[t$95$0, -1.0], N[(3.0 - N[(0.375 * N[(N[(N[(r * w), $MachinePrecision] * N[(r * w), $MachinePrecision]), $MachinePrecision] / N[(1.0 - v), $MachinePrecision]), $MachinePrecision] + 4.5), $MachinePrecision]), $MachinePrecision], N[(N[(-1.5 * N[(r * r), $MachinePrecision] + 2.0), $MachinePrecision] / N[(r * r), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \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\\
\mathbf{if}\;t\_0 \leq -\infty:\\
\;\;\;\;\left(\left(w \cdot \left(w \cdot r\right)\right) \cdot r\right) \cdot -0.25\\
\mathbf{elif}\;t\_0 \leq -1:\\
\;\;\;\;3 - \mathsf{fma}\left(0.375, \frac{\left(r \cdot w\right) \cdot \left(r \cdot w\right)}{1 - v}, 4.5\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(-1.5, r \cdot r, 2\right)}{r \cdot r}\\
\end{array}
\end{array}
if (-.f64 (-.f64 (+.f64 #s(literal 3 binary64) (/.f64 #s(literal 2 binary64) (*.f64 r r))) (/.f64 (*.f64 (*.f64 #s(literal 1/8 binary64) (-.f64 #s(literal 3 binary64) (*.f64 #s(literal 2 binary64) v))) (*.f64 (*.f64 (*.f64 w w) r) r)) (-.f64 #s(literal 1 binary64) v))) #s(literal 9/2 binary64)) < -inf.0Initial program 85.5%
Taylor expanded in v around inf
lower--.f64N/A
associate-*r/N/A
metadata-evalN/A
pow2N/A
lift-/.f64N/A
lift-*.f64N/A
+-commutativeN/A
associate-*r*N/A
lower-fma.f64N/A
lower-*.f64N/A
pow2N/A
lift-*.f64N/A
pow2N/A
lift-*.f6479.0
Applied rewrites79.0%
Taylor expanded in w around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
pow2N/A
associate-*l*N/A
pow2N/A
lower-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lift-*.f64N/A
lower-*.f6437.8
lift-*.f64N/A
*-commutativeN/A
lower-*.f6437.8
Applied rewrites37.8%
if -inf.0 < (-.f64 (-.f64 (+.f64 #s(literal 3 binary64) (/.f64 #s(literal 2 binary64) (*.f64 r r))) (/.f64 (*.f64 (*.f64 #s(literal 1/8 binary64) (-.f64 #s(literal 3 binary64) (*.f64 #s(literal 2 binary64) v))) (*.f64 (*.f64 (*.f64 w w) r) r)) (-.f64 #s(literal 1 binary64) v))) #s(literal 9/2 binary64)) < -1Initial program 85.5%
Applied rewrites99.6%
Taylor expanded in v around 0
*-commutativeN/A
+-commutativeN/A
metadata-evalN/A
fp-cancel-sub-sign-invN/A
+-commutativeN/A
lower-fma.f6499.7
Applied rewrites99.7%
Taylor expanded in r around inf
Applied rewrites56.4%
Taylor expanded in v around 0
Applied rewrites42.0%
if -1 < (-.f64 (-.f64 (+.f64 #s(literal 3 binary64) (/.f64 #s(literal 2 binary64) (*.f64 r r))) (/.f64 (*.f64 (*.f64 #s(literal 1/8 binary64) (-.f64 #s(literal 3 binary64) (*.f64 #s(literal 2 binary64) v))) (*.f64 (*.f64 (*.f64 w w) r) r)) (-.f64 #s(literal 1 binary64) v))) #s(literal 9/2 binary64)) Initial program 85.5%
Taylor expanded in r around 0
lower-/.f64N/A
+-commutativeN/A
lower-fma.f64N/A
pow2N/A
lift-*.f64N/A
pow2N/A
lift-*.f6453.6
Applied rewrites53.6%
(FPCore (v w r) :precision binary64 (- (/ 2.0 (* r r)) (fma (* (* w (* w r)) r) 0.375 1.5)))
double code(double v, double w, double r) {
return (2.0 / (r * r)) - fma(((w * (w * r)) * r), 0.375, 1.5);
}
function code(v, w, r) return Float64(Float64(2.0 / Float64(r * r)) - fma(Float64(Float64(w * Float64(w * r)) * r), 0.375, 1.5)) end
code[v_, w_, r_] := N[(N[(2.0 / N[(r * r), $MachinePrecision]), $MachinePrecision] - N[(N[(N[(w * N[(w * r), $MachinePrecision]), $MachinePrecision] * r), $MachinePrecision] * 0.375 + 1.5), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{2}{r \cdot r} - \mathsf{fma}\left(\left(w \cdot \left(w \cdot r\right)\right) \cdot r, 0.375, 1.5\right)
\end{array}
Initial program 85.5%
Applied rewrites99.6%
Taylor expanded in v around 0
lower--.f64N/A
associate-*r/N/A
metadata-evalN/A
pow2N/A
lift-/.f64N/A
lift-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites90.7%
(FPCore (v w r)
:precision binary64
(let* ((t_0 (/ 2.0 (* r r))))
(if (<=
(-
(-
(+ 3.0 t_0)
(/ (* (* 0.125 (- 3.0 (* 2.0 v))) (* (* (* w w) r) r)) (- 1.0 v)))
4.5)
-1.5000000000276814)
(- (* (* (fma (* w w) 0.25 (/ 1.5 (* r r))) r) r))
(- t_0 1.5))))
double code(double v, double w, double r) {
double t_0 = 2.0 / (r * r);
double tmp;
if ((((3.0 + t_0) - (((0.125 * (3.0 - (2.0 * v))) * (((w * w) * r) * r)) / (1.0 - v))) - 4.5) <= -1.5000000000276814) {
tmp = -((fma((w * w), 0.25, (1.5 / (r * r))) * r) * r);
} else {
tmp = t_0 - 1.5;
}
return tmp;
}
function code(v, w, r) t_0 = Float64(2.0 / Float64(r * r)) tmp = 0.0 if (Float64(Float64(Float64(3.0 + t_0) - 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) <= -1.5000000000276814) tmp = Float64(-Float64(Float64(fma(Float64(w * w), 0.25, Float64(1.5 / Float64(r * r))) * r) * r)); else tmp = Float64(t_0 - 1.5); end return tmp end
code[v_, w_, r_] := Block[{t$95$0 = N[(2.0 / N[(r * r), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(N[(N[(3.0 + t$95$0), $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], -1.5000000000276814], (-N[(N[(N[(N[(w * w), $MachinePrecision] * 0.25 + N[(1.5 / N[(r * r), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * r), $MachinePrecision] * r), $MachinePrecision]), N[(t$95$0 - 1.5), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{2}{r \cdot r}\\
\mathbf{if}\;\left(\left(3 + t\_0\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 \leq -1.5000000000276814:\\
\;\;\;\;-\left(\mathsf{fma}\left(w \cdot w, 0.25, \frac{1.5}{r \cdot r}\right) \cdot r\right) \cdot r\\
\mathbf{else}:\\
\;\;\;\;t\_0 - 1.5\\
\end{array}
\end{array}
if (-.f64 (-.f64 (+.f64 #s(literal 3 binary64) (/.f64 #s(literal 2 binary64) (*.f64 r r))) (/.f64 (*.f64 (*.f64 #s(literal 1/8 binary64) (-.f64 #s(literal 3 binary64) (*.f64 #s(literal 2 binary64) v))) (*.f64 (*.f64 (*.f64 w w) r) r)) (-.f64 #s(literal 1 binary64) v))) #s(literal 9/2 binary64)) < -1.5000000000276814Initial program 85.5%
Taylor expanded in v around inf
lower--.f64N/A
associate-*r/N/A
metadata-evalN/A
pow2N/A
lift-/.f64N/A
lift-*.f64N/A
+-commutativeN/A
associate-*r*N/A
lower-fma.f64N/A
lower-*.f64N/A
pow2N/A
lift-*.f64N/A
pow2N/A
lift-*.f6479.0
Applied rewrites79.0%
Taylor expanded in r around inf
mul-1-negN/A
lower-neg.f64N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-fma.f64N/A
pow2N/A
lift-*.f64N/A
associate-*r/N/A
metadata-evalN/A
lower-/.f64N/A
pow2N/A
lift-*.f64N/A
pow2N/A
lift-*.f6442.7
Applied rewrites42.7%
lift-*.f64N/A
lift-*.f64N/A
lift-fma.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-fma.f64N/A
lift-*.f6444.5
Applied rewrites44.5%
if -1.5000000000276814 < (-.f64 (-.f64 (+.f64 #s(literal 3 binary64) (/.f64 #s(literal 2 binary64) (*.f64 r r))) (/.f64 (*.f64 (*.f64 #s(literal 1/8 binary64) (-.f64 #s(literal 3 binary64) (*.f64 #s(literal 2 binary64) v))) (*.f64 (*.f64 (*.f64 w w) r) r)) (-.f64 #s(literal 1 binary64) v))) #s(literal 9/2 binary64)) Initial program 85.5%
Taylor expanded in w around 0
lower--.f64N/A
associate-*r/N/A
metadata-evalN/A
pow2N/A
lift-/.f64N/A
lift-*.f6457.2
Applied rewrites57.2%
(FPCore (v w r)
:precision binary64
(let* ((t_0 (/ 2.0 (* r r))))
(if (<=
(-
(-
(+ 3.0 t_0)
(/ (* (* 0.125 (- 3.0 (* 2.0 v))) (* (* (* w w) r) r)) (- 1.0 v)))
4.5)
-5e+47)
(* (* (* w (* w r)) r) -0.25)
(- t_0 1.5))))
double code(double v, double w, double r) {
double t_0 = 2.0 / (r * r);
double tmp;
if ((((3.0 + t_0) - (((0.125 * (3.0 - (2.0 * v))) * (((w * w) * r) * r)) / (1.0 - v))) - 4.5) <= -5e+47) {
tmp = ((w * (w * r)) * r) * -0.25;
} else {
tmp = t_0 - 1.5;
}
return tmp;
}
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
real(8) :: t_0
real(8) :: tmp
t_0 = 2.0d0 / (r * r)
if ((((3.0d0 + t_0) - (((0.125d0 * (3.0d0 - (2.0d0 * v))) * (((w * w) * r) * r)) / (1.0d0 - v))) - 4.5d0) <= (-5d+47)) then
tmp = ((w * (w * r)) * r) * (-0.25d0)
else
tmp = t_0 - 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 ((((3.0 + t_0) - (((0.125 * (3.0 - (2.0 * v))) * (((w * w) * r) * r)) / (1.0 - v))) - 4.5) <= -5e+47) {
tmp = ((w * (w * r)) * r) * -0.25;
} else {
tmp = t_0 - 1.5;
}
return tmp;
}
def code(v, w, r): t_0 = 2.0 / (r * r) tmp = 0 if (((3.0 + t_0) - (((0.125 * (3.0 - (2.0 * v))) * (((w * w) * r) * r)) / (1.0 - v))) - 4.5) <= -5e+47: tmp = ((w * (w * r)) * r) * -0.25 else: tmp = t_0 - 1.5 return tmp
function code(v, w, r) t_0 = Float64(2.0 / Float64(r * r)) tmp = 0.0 if (Float64(Float64(Float64(3.0 + t_0) - 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) <= -5e+47) tmp = Float64(Float64(Float64(w * Float64(w * r)) * r) * -0.25); else tmp = Float64(t_0 - 1.5); end return tmp end
function tmp_2 = code(v, w, r) t_0 = 2.0 / (r * r); tmp = 0.0; if ((((3.0 + t_0) - (((0.125 * (3.0 - (2.0 * v))) * (((w * w) * r) * r)) / (1.0 - v))) - 4.5) <= -5e+47) tmp = ((w * (w * r)) * r) * -0.25; else tmp = t_0 - 1.5; end tmp_2 = tmp; end
code[v_, w_, r_] := Block[{t$95$0 = N[(2.0 / N[(r * r), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(N[(N[(3.0 + t$95$0), $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], -5e+47], N[(N[(N[(w * N[(w * r), $MachinePrecision]), $MachinePrecision] * r), $MachinePrecision] * -0.25), $MachinePrecision], N[(t$95$0 - 1.5), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{2}{r \cdot r}\\
\mathbf{if}\;\left(\left(3 + t\_0\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 \leq -5 \cdot 10^{+47}:\\
\;\;\;\;\left(\left(w \cdot \left(w \cdot r\right)\right) \cdot r\right) \cdot -0.25\\
\mathbf{else}:\\
\;\;\;\;t\_0 - 1.5\\
\end{array}
\end{array}
if (-.f64 (-.f64 (+.f64 #s(literal 3 binary64) (/.f64 #s(literal 2 binary64) (*.f64 r r))) (/.f64 (*.f64 (*.f64 #s(literal 1/8 binary64) (-.f64 #s(literal 3 binary64) (*.f64 #s(literal 2 binary64) v))) (*.f64 (*.f64 (*.f64 w w) r) r)) (-.f64 #s(literal 1 binary64) v))) #s(literal 9/2 binary64)) < -5.00000000000000022e47Initial program 85.5%
Taylor expanded in v around inf
lower--.f64N/A
associate-*r/N/A
metadata-evalN/A
pow2N/A
lift-/.f64N/A
lift-*.f64N/A
+-commutativeN/A
associate-*r*N/A
lower-fma.f64N/A
lower-*.f64N/A
pow2N/A
lift-*.f64N/A
pow2N/A
lift-*.f6479.0
Applied rewrites79.0%
Taylor expanded in w around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
pow2N/A
associate-*l*N/A
pow2N/A
lower-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lift-*.f64N/A
lower-*.f6437.8
lift-*.f64N/A
*-commutativeN/A
lower-*.f6437.8
Applied rewrites37.8%
if -5.00000000000000022e47 < (-.f64 (-.f64 (+.f64 #s(literal 3 binary64) (/.f64 #s(literal 2 binary64) (*.f64 r r))) (/.f64 (*.f64 (*.f64 #s(literal 1/8 binary64) (-.f64 #s(literal 3 binary64) (*.f64 #s(literal 2 binary64) v))) (*.f64 (*.f64 (*.f64 w w) r) r)) (-.f64 #s(literal 1 binary64) v))) #s(literal 9/2 binary64)) Initial program 85.5%
Taylor expanded in w around 0
lower--.f64N/A
associate-*r/N/A
metadata-evalN/A
pow2N/A
lift-/.f64N/A
lift-*.f6457.2
Applied rewrites57.2%
(FPCore (v w r)
:precision binary64
(let* ((t_0 (/ 2.0 (* r r))))
(if (<=
(-
(-
(+ 3.0 t_0)
(/ (* (* 0.125 (- 3.0 (* 2.0 v))) (* (* (* w w) r) r)) (- 1.0 v)))
4.5)
-5e+47)
(* (* -0.25 (* r r)) (* w w))
(- t_0 1.5))))
double code(double v, double w, double r) {
double t_0 = 2.0 / (r * r);
double tmp;
if ((((3.0 + t_0) - (((0.125 * (3.0 - (2.0 * v))) * (((w * w) * r) * r)) / (1.0 - v))) - 4.5) <= -5e+47) {
tmp = (-0.25 * (r * r)) * (w * w);
} else {
tmp = t_0 - 1.5;
}
return tmp;
}
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
real(8) :: t_0
real(8) :: tmp
t_0 = 2.0d0 / (r * r)
if ((((3.0d0 + t_0) - (((0.125d0 * (3.0d0 - (2.0d0 * v))) * (((w * w) * r) * r)) / (1.0d0 - v))) - 4.5d0) <= (-5d+47)) then
tmp = ((-0.25d0) * (r * r)) * (w * w)
else
tmp = t_0 - 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 ((((3.0 + t_0) - (((0.125 * (3.0 - (2.0 * v))) * (((w * w) * r) * r)) / (1.0 - v))) - 4.5) <= -5e+47) {
tmp = (-0.25 * (r * r)) * (w * w);
} else {
tmp = t_0 - 1.5;
}
return tmp;
}
def code(v, w, r): t_0 = 2.0 / (r * r) tmp = 0 if (((3.0 + t_0) - (((0.125 * (3.0 - (2.0 * v))) * (((w * w) * r) * r)) / (1.0 - v))) - 4.5) <= -5e+47: tmp = (-0.25 * (r * r)) * (w * w) else: tmp = t_0 - 1.5 return tmp
function code(v, w, r) t_0 = Float64(2.0 / Float64(r * r)) tmp = 0.0 if (Float64(Float64(Float64(3.0 + t_0) - 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) <= -5e+47) tmp = Float64(Float64(-0.25 * Float64(r * r)) * Float64(w * w)); else tmp = Float64(t_0 - 1.5); end return tmp end
function tmp_2 = code(v, w, r) t_0 = 2.0 / (r * r); tmp = 0.0; if ((((3.0 + t_0) - (((0.125 * (3.0 - (2.0 * v))) * (((w * w) * r) * r)) / (1.0 - v))) - 4.5) <= -5e+47) tmp = (-0.25 * (r * r)) * (w * w); else tmp = t_0 - 1.5; end tmp_2 = tmp; end
code[v_, w_, r_] := Block[{t$95$0 = N[(2.0 / N[(r * r), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(N[(N[(3.0 + t$95$0), $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], -5e+47], N[(N[(-0.25 * N[(r * r), $MachinePrecision]), $MachinePrecision] * N[(w * w), $MachinePrecision]), $MachinePrecision], N[(t$95$0 - 1.5), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{2}{r \cdot r}\\
\mathbf{if}\;\left(\left(3 + t\_0\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 \leq -5 \cdot 10^{+47}:\\
\;\;\;\;\left(-0.25 \cdot \left(r \cdot r\right)\right) \cdot \left(w \cdot w\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0 - 1.5\\
\end{array}
\end{array}
if (-.f64 (-.f64 (+.f64 #s(literal 3 binary64) (/.f64 #s(literal 2 binary64) (*.f64 r r))) (/.f64 (*.f64 (*.f64 #s(literal 1/8 binary64) (-.f64 #s(literal 3 binary64) (*.f64 #s(literal 2 binary64) v))) (*.f64 (*.f64 (*.f64 w w) r) r)) (-.f64 #s(literal 1 binary64) v))) #s(literal 9/2 binary64)) < -5.00000000000000022e47Initial program 85.5%
Taylor expanded in v around inf
lower--.f64N/A
associate-*r/N/A
metadata-evalN/A
pow2N/A
lift-/.f64N/A
lift-*.f64N/A
+-commutativeN/A
associate-*r*N/A
lower-fma.f64N/A
lower-*.f64N/A
pow2N/A
lift-*.f64N/A
pow2N/A
lift-*.f6479.0
Applied rewrites79.0%
Taylor expanded in r around inf
mul-1-negN/A
lower-neg.f64N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-fma.f64N/A
pow2N/A
lift-*.f64N/A
associate-*r/N/A
metadata-evalN/A
lower-/.f64N/A
pow2N/A
lift-*.f64N/A
pow2N/A
lift-*.f6442.7
Applied rewrites42.7%
Taylor expanded in w around inf
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
pow2N/A
lift-*.f64N/A
pow2N/A
lift-*.f6433.9
Applied rewrites33.9%
if -5.00000000000000022e47 < (-.f64 (-.f64 (+.f64 #s(literal 3 binary64) (/.f64 #s(literal 2 binary64) (*.f64 r r))) (/.f64 (*.f64 (*.f64 #s(literal 1/8 binary64) (-.f64 #s(literal 3 binary64) (*.f64 #s(literal 2 binary64) v))) (*.f64 (*.f64 (*.f64 w w) r) r)) (-.f64 #s(literal 1 binary64) v))) #s(literal 9/2 binary64)) Initial program 85.5%
Taylor expanded in w around 0
lower--.f64N/A
associate-*r/N/A
metadata-evalN/A
pow2N/A
lift-/.f64N/A
lift-*.f6457.2
Applied rewrites57.2%
(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]
\begin{array}{l}
\\
\frac{2}{r \cdot r} - 1.5
\end{array}
Initial program 85.5%
Taylor expanded in w around 0
lower--.f64N/A
associate-*r/N/A
metadata-evalN/A
pow2N/A
lift-/.f64N/A
lift-*.f6457.2
Applied rewrites57.2%
(FPCore (v w r) :precision binary64 (if (<= r 1.15) (/ (/ 2.0 r) r) -1.5))
double code(double v, double w, double r) {
double tmp;
if (r <= 1.15) {
tmp = (2.0 / r) / r;
} else {
tmp = -1.5;
}
return tmp;
}
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
real(8) :: tmp
if (r <= 1.15d0) then
tmp = (2.0d0 / r) / r
else
tmp = -1.5d0
end if
code = tmp
end function
public static double code(double v, double w, double r) {
double tmp;
if (r <= 1.15) {
tmp = (2.0 / r) / r;
} else {
tmp = -1.5;
}
return tmp;
}
def code(v, w, r): tmp = 0 if r <= 1.15: tmp = (2.0 / r) / r else: tmp = -1.5 return tmp
function code(v, w, r) tmp = 0.0 if (r <= 1.15) tmp = Float64(Float64(2.0 / r) / r); else tmp = -1.5; end return tmp end
function tmp_2 = code(v, w, r) tmp = 0.0; if (r <= 1.15) tmp = (2.0 / r) / r; else tmp = -1.5; end tmp_2 = tmp; end
code[v_, w_, r_] := If[LessEqual[r, 1.15], N[(N[(2.0 / r), $MachinePrecision] / r), $MachinePrecision], -1.5]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;r \leq 1.15:\\
\;\;\;\;\frac{\frac{2}{r}}{r}\\
\mathbf{else}:\\
\;\;\;\;-1.5\\
\end{array}
\end{array}
if r < 1.1499999999999999Initial program 85.5%
Taylor expanded in r around 0
pow2N/A
lift-/.f64N/A
lift-*.f6443.9
Applied rewrites43.9%
lift-*.f64N/A
lift-/.f64N/A
associate-/l/N/A
lift-/.f64N/A
lift-/.f6443.9
Applied rewrites43.9%
if 1.1499999999999999 < r Initial program 85.5%
Taylor expanded in r around 0
lower-/.f64N/A
+-commutativeN/A
lower-fma.f64N/A
pow2N/A
lift-*.f64N/A
pow2N/A
lift-*.f6453.6
Applied rewrites53.6%
Taylor expanded in r around inf
Applied rewrites14.3%
(FPCore (v w r) :precision binary64 (if (<= r 1.15) (/ 2.0 (* r r)) -1.5))
double code(double v, double w, double r) {
double tmp;
if (r <= 1.15) {
tmp = 2.0 / (r * r);
} else {
tmp = -1.5;
}
return tmp;
}
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
real(8) :: tmp
if (r <= 1.15d0) then
tmp = 2.0d0 / (r * r)
else
tmp = -1.5d0
end if
code = tmp
end function
public static double code(double v, double w, double r) {
double tmp;
if (r <= 1.15) {
tmp = 2.0 / (r * r);
} else {
tmp = -1.5;
}
return tmp;
}
def code(v, w, r): tmp = 0 if r <= 1.15: tmp = 2.0 / (r * r) else: tmp = -1.5 return tmp
function code(v, w, r) tmp = 0.0 if (r <= 1.15) tmp = Float64(2.0 / Float64(r * r)); else tmp = -1.5; end return tmp end
function tmp_2 = code(v, w, r) tmp = 0.0; if (r <= 1.15) tmp = 2.0 / (r * r); else tmp = -1.5; end tmp_2 = tmp; end
code[v_, w_, r_] := If[LessEqual[r, 1.15], N[(2.0 / N[(r * r), $MachinePrecision]), $MachinePrecision], -1.5]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;r \leq 1.15:\\
\;\;\;\;\frac{2}{r \cdot r}\\
\mathbf{else}:\\
\;\;\;\;-1.5\\
\end{array}
\end{array}
if r < 1.1499999999999999Initial program 85.5%
Taylor expanded in r around 0
pow2N/A
lift-/.f64N/A
lift-*.f6443.9
Applied rewrites43.9%
if 1.1499999999999999 < r Initial program 85.5%
Taylor expanded in r around 0
lower-/.f64N/A
+-commutativeN/A
lower-fma.f64N/A
pow2N/A
lift-*.f64N/A
pow2N/A
lift-*.f6453.6
Applied rewrites53.6%
Taylor expanded in r around inf
Applied rewrites14.3%
(FPCore (v w r) :precision binary64 -1.5)
double code(double v, double w, double r) {
return -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.5d0
end function
public static double code(double v, double w, double r) {
return -1.5;
}
def code(v, w, r): return -1.5
function code(v, w, r) return -1.5 end
function tmp = code(v, w, r) tmp = -1.5; end
code[v_, w_, r_] := -1.5
\begin{array}{l}
\\
-1.5
\end{array}
Initial program 85.5%
Taylor expanded in r around 0
lower-/.f64N/A
+-commutativeN/A
lower-fma.f64N/A
pow2N/A
lift-*.f64N/A
pow2N/A
lift-*.f6453.6
Applied rewrites53.6%
Taylor expanded in r around inf
Applied rewrites14.3%
herbie shell --seed 2025130
(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))