
(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 13 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}
r_m = (fabs.f64 r)
(FPCore (v w r_m)
:precision binary64
(let* ((t_0 (/ 2.0 (* r_m r_m))))
(if (<= r_m 2e+131)
(-
(fma
w
(* (* r_m r_m) (* (/ (fma (+ v v) 0.125 -0.375) (- v 1.0)) w))
(- 1.5 t_0)))
(-
(- t_0 -3.0)
(fma
(* (* (* (fma -2.0 v 3.0) 0.125) w) (* w r_m))
(/ r_m (- 1.0 v))
4.5)))))r_m = fabs(r);
double code(double v, double w, double r_m) {
double t_0 = 2.0 / (r_m * r_m);
double tmp;
if (r_m <= 2e+131) {
tmp = -fma(w, ((r_m * r_m) * ((fma((v + v), 0.125, -0.375) / (v - 1.0)) * w)), (1.5 - t_0));
} else {
tmp = (t_0 - -3.0) - fma((((fma(-2.0, v, 3.0) * 0.125) * w) * (w * r_m)), (r_m / (1.0 - v)), 4.5);
}
return tmp;
}
r_m = abs(r) function code(v, w, r_m) t_0 = Float64(2.0 / Float64(r_m * r_m)) tmp = 0.0 if (r_m <= 2e+131) tmp = Float64(-fma(w, Float64(Float64(r_m * r_m) * Float64(Float64(fma(Float64(v + v), 0.125, -0.375) / Float64(v - 1.0)) * w)), Float64(1.5 - t_0))); else tmp = Float64(Float64(t_0 - -3.0) - fma(Float64(Float64(Float64(fma(-2.0, v, 3.0) * 0.125) * w) * Float64(w * r_m)), Float64(r_m / Float64(1.0 - v)), 4.5)); end return tmp end
r_m = N[Abs[r], $MachinePrecision]
code[v_, w_, r$95$m_] := Block[{t$95$0 = N[(2.0 / N[(r$95$m * r$95$m), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[r$95$m, 2e+131], (-N[(w * N[(N[(r$95$m * r$95$m), $MachinePrecision] * N[(N[(N[(N[(v + v), $MachinePrecision] * 0.125 + -0.375), $MachinePrecision] / N[(v - 1.0), $MachinePrecision]), $MachinePrecision] * w), $MachinePrecision]), $MachinePrecision] + N[(1.5 - t$95$0), $MachinePrecision]), $MachinePrecision]), N[(N[(t$95$0 - -3.0), $MachinePrecision] - N[(N[(N[(N[(N[(-2.0 * v + 3.0), $MachinePrecision] * 0.125), $MachinePrecision] * w), $MachinePrecision] * N[(w * r$95$m), $MachinePrecision]), $MachinePrecision] * N[(r$95$m / N[(1.0 - v), $MachinePrecision]), $MachinePrecision] + 4.5), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
r_m = \left|r\right|
\\
\begin{array}{l}
t_0 := \frac{2}{r\_m \cdot r\_m}\\
\mathbf{if}\;r\_m \leq 2 \cdot 10^{+131}:\\
\;\;\;\;-\mathsf{fma}\left(w, \left(r\_m \cdot r\_m\right) \cdot \left(\frac{\mathsf{fma}\left(v + v, 0.125, -0.375\right)}{v - 1} \cdot w\right), 1.5 - t\_0\right)\\
\mathbf{else}:\\
\;\;\;\;\left(t\_0 - -3\right) - \mathsf{fma}\left(\left(\left(\mathsf{fma}\left(-2, v, 3\right) \cdot 0.125\right) \cdot w\right) \cdot \left(w \cdot r\_m\right), \frac{r\_m}{1 - v}, 4.5\right)\\
\end{array}
\end{array}
if r < 1.9999999999999998e131Initial program 85.5%
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.5
Applied rewrites90.0%
Applied rewrites97.0%
lift-fma.f64N/A
add-flipN/A
sub-flip-reverseN/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
lift--.f64N/A
sub-negate-revN/A
sub-negate-revN/A
lift--.f64N/A
lower-fma.f64N/A
Applied rewrites91.3%
if 1.9999999999999998e131 < r Initial program 85.5%
lift--.f64N/A
lift--.f64N/A
associate--l-N/A
lower--.f64N/A
lift-+.f64N/A
+-commutativeN/A
add-flipN/A
lower--.f64N/A
metadata-evalN/A
Applied rewrites91.8%
r_m = (fabs.f64 r) (FPCore (v w r_m) :precision binary64 (- (- (+ 3.0 (/ 2.0 (* r_m r_m))) (* (fma -2.0 v 3.0) (* 0.125 (* (* w r_m) (/ (* w r_m) (- 1.0 v)))))) 4.5))
r_m = fabs(r);
double code(double v, double w, double r_m) {
return ((3.0 + (2.0 / (r_m * r_m))) - (fma(-2.0, v, 3.0) * (0.125 * ((w * r_m) * ((w * r_m) / (1.0 - v)))))) - 4.5;
}
r_m = abs(r) function code(v, w, r_m) return Float64(Float64(Float64(3.0 + Float64(2.0 / Float64(r_m * r_m))) - Float64(fma(-2.0, v, 3.0) * Float64(0.125 * Float64(Float64(w * r_m) * Float64(Float64(w * r_m) / Float64(1.0 - v)))))) - 4.5) end
r_m = N[Abs[r], $MachinePrecision] code[v_, w_, r$95$m_] := N[(N[(N[(3.0 + N[(2.0 / N[(r$95$m * r$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(N[(-2.0 * v + 3.0), $MachinePrecision] * N[(0.125 * N[(N[(w * r$95$m), $MachinePrecision] * N[(N[(w * r$95$m), $MachinePrecision] / N[(1.0 - v), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 4.5), $MachinePrecision]
\begin{array}{l}
r_m = \left|r\right|
\\
\left(\left(3 + \frac{2}{r\_m \cdot r\_m}\right) - \mathsf{fma}\left(-2, v, 3\right) \cdot \left(0.125 \cdot \left(\left(w \cdot r\_m\right) \cdot \frac{w \cdot r\_m}{1 - v}\right)\right)\right) - 4.5
\end{array}
Initial program 85.5%
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-/.f6488.2
Applied rewrites88.2%
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
lift-*.f64N/A
associate-*l*N/A
lift-*.f64N/A
swap-sqrN/A
lift-*.f64N/A
lift-*.f64N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6499.7
Applied rewrites99.7%
r_m = (fabs.f64 r)
(FPCore (v w r_m)
:precision binary64
(let* ((t_0 (/ 2.0 (* r_m r_m))) (t_1 (+ 3.0 t_0)))
(if (<= v -3.25e+50)
(- (- t_1 (* (* (* (/ r_m (- 1.0 v)) w) (* w r_m)) (* -0.25 v))) 4.5)
(if (<= v 2.5e-7)
(- (- t_1 (/ (* 0.375 (* (* w r_m) (* w r_m))) 1.0)) 4.5)
(-
(fma
(* r_m w)
(* (* r_m w) (/ (* -0.25 v) (- 1.0 v)))
(- 1.5 t_0)))))))r_m = fabs(r);
double code(double v, double w, double r_m) {
double t_0 = 2.0 / (r_m * r_m);
double t_1 = 3.0 + t_0;
double tmp;
if (v <= -3.25e+50) {
tmp = (t_1 - ((((r_m / (1.0 - v)) * w) * (w * r_m)) * (-0.25 * v))) - 4.5;
} else if (v <= 2.5e-7) {
tmp = (t_1 - ((0.375 * ((w * r_m) * (w * r_m))) / 1.0)) - 4.5;
} else {
tmp = -fma((r_m * w), ((r_m * w) * ((-0.25 * v) / (1.0 - v))), (1.5 - t_0));
}
return tmp;
}
r_m = abs(r) function code(v, w, r_m) t_0 = Float64(2.0 / Float64(r_m * r_m)) t_1 = Float64(3.0 + t_0) tmp = 0.0 if (v <= -3.25e+50) tmp = Float64(Float64(t_1 - Float64(Float64(Float64(Float64(r_m / Float64(1.0 - v)) * w) * Float64(w * r_m)) * Float64(-0.25 * v))) - 4.5); elseif (v <= 2.5e-7) tmp = Float64(Float64(t_1 - Float64(Float64(0.375 * Float64(Float64(w * r_m) * Float64(w * r_m))) / 1.0)) - 4.5); else tmp = Float64(-fma(Float64(r_m * w), Float64(Float64(r_m * w) * Float64(Float64(-0.25 * v) / Float64(1.0 - v))), Float64(1.5 - t_0))); end return tmp end
r_m = N[Abs[r], $MachinePrecision]
code[v_, w_, r$95$m_] := Block[{t$95$0 = N[(2.0 / N[(r$95$m * r$95$m), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(3.0 + t$95$0), $MachinePrecision]}, If[LessEqual[v, -3.25e+50], N[(N[(t$95$1 - N[(N[(N[(N[(r$95$m / N[(1.0 - v), $MachinePrecision]), $MachinePrecision] * w), $MachinePrecision] * N[(w * r$95$m), $MachinePrecision]), $MachinePrecision] * N[(-0.25 * v), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 4.5), $MachinePrecision], If[LessEqual[v, 2.5e-7], N[(N[(t$95$1 - N[(N[(0.375 * N[(N[(w * r$95$m), $MachinePrecision] * N[(w * r$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 1.0), $MachinePrecision]), $MachinePrecision] - 4.5), $MachinePrecision], (-N[(N[(r$95$m * w), $MachinePrecision] * N[(N[(r$95$m * w), $MachinePrecision] * N[(N[(-0.25 * v), $MachinePrecision] / N[(1.0 - v), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(1.5 - t$95$0), $MachinePrecision]), $MachinePrecision])]]]]
\begin{array}{l}
r_m = \left|r\right|
\\
\begin{array}{l}
t_0 := \frac{2}{r\_m \cdot r\_m}\\
t_1 := 3 + t\_0\\
\mathbf{if}\;v \leq -3.25 \cdot 10^{+50}:\\
\;\;\;\;\left(t\_1 - \left(\left(\frac{r\_m}{1 - v} \cdot w\right) \cdot \left(w \cdot r\_m\right)\right) \cdot \left(-0.25 \cdot v\right)\right) - 4.5\\
\mathbf{elif}\;v \leq 2.5 \cdot 10^{-7}:\\
\;\;\;\;\left(t\_1 - \frac{0.375 \cdot \left(\left(w \cdot r\_m\right) \cdot \left(w \cdot r\_m\right)\right)}{1}\right) - 4.5\\
\mathbf{else}:\\
\;\;\;\;-\mathsf{fma}\left(r\_m \cdot w, \left(r\_m \cdot w\right) \cdot \frac{-0.25 \cdot v}{1 - v}, 1.5 - t\_0\right)\\
\end{array}
\end{array}
if v < -3.2500000000000001e50Initial program 85.5%
Taylor expanded in v around inf
lower-*.f6474.6
Applied rewrites74.6%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
lift-*.f64N/A
associate-*r/N/A
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f6477.2
Applied rewrites84.8%
if -3.2500000000000001e50 < v < 2.49999999999999989e-7Initial program 85.5%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lift-*.f64N/A
unswap-sqrN/A
lower-*.f64N/A
lower-*.f64N/A
lower-*.f6495.0
Applied rewrites95.0%
Taylor expanded in v around 0
Applied rewrites85.7%
Taylor expanded in v around 0
Applied rewrites93.5%
if 2.49999999999999989e-7 < v Initial program 85.5%
Taylor expanded in v around inf
lower-*.f6474.6
Applied rewrites74.6%
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
Applied rewrites74.6%
lift--.f64N/A
lift--.f64N/A
associate--r-N/A
lift--.f64N/A
+-commutativeN/A
Applied rewrites83.5%
r_m = (fabs.f64 r)
(FPCore (v w r_m)
:precision binary64
(let* ((t_0 (/ 2.0 (* r_m r_m)))
(t_1
(-
(fma
(* r_m w)
(* (* r_m w) (/ (* -0.25 v) (- 1.0 v)))
(- 1.5 t_0)))))
(if (<= v -3.25e+50)
t_1
(if (<= v 2.5e-7)
(- (- (+ 3.0 t_0) (/ (* 0.375 (* (* w r_m) (* w r_m))) 1.0)) 4.5)
t_1))))r_m = fabs(r);
double code(double v, double w, double r_m) {
double t_0 = 2.0 / (r_m * r_m);
double t_1 = -fma((r_m * w), ((r_m * w) * ((-0.25 * v) / (1.0 - v))), (1.5 - t_0));
double tmp;
if (v <= -3.25e+50) {
tmp = t_1;
} else if (v <= 2.5e-7) {
tmp = ((3.0 + t_0) - ((0.375 * ((w * r_m) * (w * r_m))) / 1.0)) - 4.5;
} else {
tmp = t_1;
}
return tmp;
}
r_m = abs(r) function code(v, w, r_m) t_0 = Float64(2.0 / Float64(r_m * r_m)) t_1 = Float64(-fma(Float64(r_m * w), Float64(Float64(r_m * w) * Float64(Float64(-0.25 * v) / Float64(1.0 - v))), Float64(1.5 - t_0))) tmp = 0.0 if (v <= -3.25e+50) tmp = t_1; elseif (v <= 2.5e-7) tmp = Float64(Float64(Float64(3.0 + t_0) - Float64(Float64(0.375 * Float64(Float64(w * r_m) * Float64(w * r_m))) / 1.0)) - 4.5); else tmp = t_1; end return tmp end
r_m = N[Abs[r], $MachinePrecision]
code[v_, w_, r$95$m_] := Block[{t$95$0 = N[(2.0 / N[(r$95$m * r$95$m), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = (-N[(N[(r$95$m * w), $MachinePrecision] * N[(N[(r$95$m * w), $MachinePrecision] * N[(N[(-0.25 * v), $MachinePrecision] / N[(1.0 - v), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(1.5 - t$95$0), $MachinePrecision]), $MachinePrecision])}, If[LessEqual[v, -3.25e+50], t$95$1, If[LessEqual[v, 2.5e-7], N[(N[(N[(3.0 + t$95$0), $MachinePrecision] - N[(N[(0.375 * N[(N[(w * r$95$m), $MachinePrecision] * N[(w * r$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 1.0), $MachinePrecision]), $MachinePrecision] - 4.5), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
r_m = \left|r\right|
\\
\begin{array}{l}
t_0 := \frac{2}{r\_m \cdot r\_m}\\
t_1 := -\mathsf{fma}\left(r\_m \cdot w, \left(r\_m \cdot w\right) \cdot \frac{-0.25 \cdot v}{1 - v}, 1.5 - t\_0\right)\\
\mathbf{if}\;v \leq -3.25 \cdot 10^{+50}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;v \leq 2.5 \cdot 10^{-7}:\\
\;\;\;\;\left(\left(3 + t\_0\right) - \frac{0.375 \cdot \left(\left(w \cdot r\_m\right) \cdot \left(w \cdot r\_m\right)\right)}{1}\right) - 4.5\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if v < -3.2500000000000001e50 or 2.49999999999999989e-7 < v Initial program 85.5%
Taylor expanded in v around inf
lower-*.f6474.6
Applied rewrites74.6%
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
Applied rewrites74.6%
lift--.f64N/A
lift--.f64N/A
associate--r-N/A
lift--.f64N/A
+-commutativeN/A
Applied rewrites83.5%
if -3.2500000000000001e50 < v < 2.49999999999999989e-7Initial program 85.5%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lift-*.f64N/A
unswap-sqrN/A
lower-*.f64N/A
lower-*.f64N/A
lower-*.f6495.0
Applied rewrites95.0%
Taylor expanded in v around 0
Applied rewrites85.7%
Taylor expanded in v around 0
Applied rewrites93.5%
r_m = (fabs.f64 r)
(FPCore (v w r_m)
:precision binary64
(let* ((t_0 (/ 2.0 (* r_m r_m))))
(if (<= r_m 2.2e+29)
(-
(fma
w
(* (* r_m r_m) (* (/ (fma (+ v v) 0.125 -0.375) (- v 1.0)) w))
(- 1.5 t_0)))
(-
(fma
(* (fma v 2.0 -3.0) 0.125)
(* (* (* w w) r_m) (/ r_m (- 1.0 v)))
t_0)
1.5))))r_m = fabs(r);
double code(double v, double w, double r_m) {
double t_0 = 2.0 / (r_m * r_m);
double tmp;
if (r_m <= 2.2e+29) {
tmp = -fma(w, ((r_m * r_m) * ((fma((v + v), 0.125, -0.375) / (v - 1.0)) * w)), (1.5 - t_0));
} else {
tmp = fma((fma(v, 2.0, -3.0) * 0.125), (((w * w) * r_m) * (r_m / (1.0 - v))), t_0) - 1.5;
}
return tmp;
}
r_m = abs(r) function code(v, w, r_m) t_0 = Float64(2.0 / Float64(r_m * r_m)) tmp = 0.0 if (r_m <= 2.2e+29) tmp = Float64(-fma(w, Float64(Float64(r_m * r_m) * Float64(Float64(fma(Float64(v + v), 0.125, -0.375) / Float64(v - 1.0)) * w)), Float64(1.5 - t_0))); else tmp = Float64(fma(Float64(fma(v, 2.0, -3.0) * 0.125), Float64(Float64(Float64(w * w) * r_m) * Float64(r_m / Float64(1.0 - v))), t_0) - 1.5); end return tmp end
r_m = N[Abs[r], $MachinePrecision]
code[v_, w_, r$95$m_] := Block[{t$95$0 = N[(2.0 / N[(r$95$m * r$95$m), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[r$95$m, 2.2e+29], (-N[(w * N[(N[(r$95$m * r$95$m), $MachinePrecision] * N[(N[(N[(N[(v + v), $MachinePrecision] * 0.125 + -0.375), $MachinePrecision] / N[(v - 1.0), $MachinePrecision]), $MachinePrecision] * w), $MachinePrecision]), $MachinePrecision] + N[(1.5 - t$95$0), $MachinePrecision]), $MachinePrecision]), N[(N[(N[(N[(v * 2.0 + -3.0), $MachinePrecision] * 0.125), $MachinePrecision] * N[(N[(N[(w * w), $MachinePrecision] * r$95$m), $MachinePrecision] * N[(r$95$m / N[(1.0 - v), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + t$95$0), $MachinePrecision] - 1.5), $MachinePrecision]]]
\begin{array}{l}
r_m = \left|r\right|
\\
\begin{array}{l}
t_0 := \frac{2}{r\_m \cdot r\_m}\\
\mathbf{if}\;r\_m \leq 2.2 \cdot 10^{+29}:\\
\;\;\;\;-\mathsf{fma}\left(w, \left(r\_m \cdot r\_m\right) \cdot \left(\frac{\mathsf{fma}\left(v + v, 0.125, -0.375\right)}{v - 1} \cdot w\right), 1.5 - t\_0\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(v, 2, -3\right) \cdot 0.125, \left(\left(w \cdot w\right) \cdot r\_m\right) \cdot \frac{r\_m}{1 - v}, t\_0\right) - 1.5\\
\end{array}
\end{array}
if r < 2.2000000000000001e29Initial program 85.5%
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.5
Applied rewrites90.0%
Applied rewrites97.0%
lift-fma.f64N/A
add-flipN/A
sub-flip-reverseN/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
lift--.f64N/A
sub-negate-revN/A
sub-negate-revN/A
lift--.f64N/A
lower-fma.f64N/A
Applied rewrites91.3%
if 2.2000000000000001e29 < r Initial program 85.5%
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-/.f6488.2
Applied rewrites88.2%
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
lift-*.f64N/A
associate-*l*N/A
lift-*.f64N/A
swap-sqrN/A
lift-*.f64N/A
lift-*.f64N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6499.7
Applied rewrites99.7%
Applied rewrites88.2%
r_m = (fabs.f64 r)
(FPCore (v w r_m)
:precision binary64
(let* ((t_0 (/ 2.0 (* r_m r_m)))
(t_1 (- (fma (* (* (* w r_m) r_m) w) 0.25 (- 1.5 t_0)))))
(if (<= v -3.25e+50)
t_1
(if (<= v 8.5e+73)
(- (- (+ 3.0 t_0) (/ (* 0.375 (* (* w r_m) (* w r_m))) 1.0)) 4.5)
t_1))))r_m = fabs(r);
double code(double v, double w, double r_m) {
double t_0 = 2.0 / (r_m * r_m);
double t_1 = -fma((((w * r_m) * r_m) * w), 0.25, (1.5 - t_0));
double tmp;
if (v <= -3.25e+50) {
tmp = t_1;
} else if (v <= 8.5e+73) {
tmp = ((3.0 + t_0) - ((0.375 * ((w * r_m) * (w * r_m))) / 1.0)) - 4.5;
} else {
tmp = t_1;
}
return tmp;
}
r_m = abs(r) function code(v, w, r_m) t_0 = Float64(2.0 / Float64(r_m * r_m)) t_1 = Float64(-fma(Float64(Float64(Float64(w * r_m) * r_m) * w), 0.25, Float64(1.5 - t_0))) tmp = 0.0 if (v <= -3.25e+50) tmp = t_1; elseif (v <= 8.5e+73) tmp = Float64(Float64(Float64(3.0 + t_0) - Float64(Float64(0.375 * Float64(Float64(w * r_m) * Float64(w * r_m))) / 1.0)) - 4.5); else tmp = t_1; end return tmp end
r_m = N[Abs[r], $MachinePrecision]
code[v_, w_, r$95$m_] := Block[{t$95$0 = N[(2.0 / N[(r$95$m * r$95$m), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = (-N[(N[(N[(N[(w * r$95$m), $MachinePrecision] * r$95$m), $MachinePrecision] * w), $MachinePrecision] * 0.25 + N[(1.5 - t$95$0), $MachinePrecision]), $MachinePrecision])}, If[LessEqual[v, -3.25e+50], t$95$1, If[LessEqual[v, 8.5e+73], N[(N[(N[(3.0 + t$95$0), $MachinePrecision] - N[(N[(0.375 * N[(N[(w * r$95$m), $MachinePrecision] * N[(w * r$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 1.0), $MachinePrecision]), $MachinePrecision] - 4.5), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
r_m = \left|r\right|
\\
\begin{array}{l}
t_0 := \frac{2}{r\_m \cdot r\_m}\\
t_1 := -\mathsf{fma}\left(\left(\left(w \cdot r\_m\right) \cdot r\_m\right) \cdot w, 0.25, 1.5 - t\_0\right)\\
\mathbf{if}\;v \leq -3.25 \cdot 10^{+50}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;v \leq 8.5 \cdot 10^{+73}:\\
\;\;\;\;\left(\left(3 + t\_0\right) - \frac{0.375 \cdot \left(\left(w \cdot r\_m\right) \cdot \left(w \cdot r\_m\right)\right)}{1}\right) - 4.5\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if v < -3.2500000000000001e50 or 8.4999999999999998e73 < v Initial program 85.5%
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.5
Applied rewrites90.0%
Applied rewrites97.0%
Taylor expanded in v around inf
Applied rewrites92.2%
if -3.2500000000000001e50 < v < 8.4999999999999998e73Initial program 85.5%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lift-*.f64N/A
unswap-sqrN/A
lower-*.f64N/A
lower-*.f64N/A
lower-*.f6495.0
Applied rewrites95.0%
Taylor expanded in v around 0
Applied rewrites85.7%
Taylor expanded in v around 0
Applied rewrites93.5%
r_m = (fabs.f64 r) (FPCore (v w r_m) :precision binary64 (- (fma (* (* (* w r_m) r_m) w) (/ (* (fma v 2.0 -3.0) 0.125) (- v 1.0)) (- 1.5 (/ 2.0 (* r_m r_m))))))
r_m = fabs(r);
double code(double v, double w, double r_m) {
return -fma((((w * r_m) * r_m) * w), ((fma(v, 2.0, -3.0) * 0.125) / (v - 1.0)), (1.5 - (2.0 / (r_m * r_m))));
}
r_m = abs(r) function code(v, w, r_m) return Float64(-fma(Float64(Float64(Float64(w * r_m) * r_m) * w), Float64(Float64(fma(v, 2.0, -3.0) * 0.125) / Float64(v - 1.0)), Float64(1.5 - Float64(2.0 / Float64(r_m * r_m))))) end
r_m = N[Abs[r], $MachinePrecision] code[v_, w_, r$95$m_] := (-N[(N[(N[(N[(w * r$95$m), $MachinePrecision] * r$95$m), $MachinePrecision] * w), $MachinePrecision] * N[(N[(N[(v * 2.0 + -3.0), $MachinePrecision] * 0.125), $MachinePrecision] / N[(v - 1.0), $MachinePrecision]), $MachinePrecision] + N[(1.5 - N[(2.0 / N[(r$95$m * r$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision])
\begin{array}{l}
r_m = \left|r\right|
\\
-\mathsf{fma}\left(\left(\left(w \cdot r\_m\right) \cdot r\_m\right) \cdot w, \frac{\mathsf{fma}\left(v, 2, -3\right) \cdot 0.125}{v - 1}, 1.5 - \frac{2}{r\_m \cdot r\_m}\right)
\end{array}
Initial program 85.5%
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.5
Applied rewrites90.0%
Applied rewrites97.0%
r_m = (fabs.f64 r)
(FPCore (v w r_m)
:precision binary64
(let* ((t_0 (* (* (* w r_m) r_m) w))
(t_1 (- 1.5 (/ 2.0 (* r_m r_m))))
(t_2 (- (fma t_0 0.25 t_1))))
(if (<= v -3.25e+50) t_2 (if (<= v 8.5e+73) (- (fma t_0 0.375 t_1)) t_2))))r_m = fabs(r);
double code(double v, double w, double r_m) {
double t_0 = ((w * r_m) * r_m) * w;
double t_1 = 1.5 - (2.0 / (r_m * r_m));
double t_2 = -fma(t_0, 0.25, t_1);
double tmp;
if (v <= -3.25e+50) {
tmp = t_2;
} else if (v <= 8.5e+73) {
tmp = -fma(t_0, 0.375, t_1);
} else {
tmp = t_2;
}
return tmp;
}
r_m = abs(r) function code(v, w, r_m) t_0 = Float64(Float64(Float64(w * r_m) * r_m) * w) t_1 = Float64(1.5 - Float64(2.0 / Float64(r_m * r_m))) t_2 = Float64(-fma(t_0, 0.25, t_1)) tmp = 0.0 if (v <= -3.25e+50) tmp = t_2; elseif (v <= 8.5e+73) tmp = Float64(-fma(t_0, 0.375, t_1)); else tmp = t_2; end return tmp end
r_m = N[Abs[r], $MachinePrecision]
code[v_, w_, r$95$m_] := Block[{t$95$0 = N[(N[(N[(w * r$95$m), $MachinePrecision] * r$95$m), $MachinePrecision] * w), $MachinePrecision]}, Block[{t$95$1 = N[(1.5 - N[(2.0 / N[(r$95$m * r$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = (-N[(t$95$0 * 0.25 + t$95$1), $MachinePrecision])}, If[LessEqual[v, -3.25e+50], t$95$2, If[LessEqual[v, 8.5e+73], (-N[(t$95$0 * 0.375 + t$95$1), $MachinePrecision]), t$95$2]]]]]
\begin{array}{l}
r_m = \left|r\right|
\\
\begin{array}{l}
t_0 := \left(\left(w \cdot r\_m\right) \cdot r\_m\right) \cdot w\\
t_1 := 1.5 - \frac{2}{r\_m \cdot r\_m}\\
t_2 := -\mathsf{fma}\left(t\_0, 0.25, t\_1\right)\\
\mathbf{if}\;v \leq -3.25 \cdot 10^{+50}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;v \leq 8.5 \cdot 10^{+73}:\\
\;\;\;\;-\mathsf{fma}\left(t\_0, 0.375, t\_1\right)\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
if v < -3.2500000000000001e50 or 8.4999999999999998e73 < v Initial program 85.5%
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.5
Applied rewrites90.0%
Applied rewrites97.0%
Taylor expanded in v around inf
Applied rewrites92.2%
if -3.2500000000000001e50 < v < 8.4999999999999998e73Initial program 85.5%
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.5
Applied rewrites90.0%
Applied rewrites97.0%
Taylor expanded in v around 0
Applied rewrites92.0%
r_m = (fabs.f64 r) (FPCore (v w r_m) :precision binary64 (if (<= r_m 1850000000.0) (- (fma (* (* (* w r_m) r_m) w) 0.25 (- 1.5 (/ 2.0 (* r_m r_m))))) (- (- 3.0 (/ (* 0.375 (* (* w r_m) (* w r_m))) 1.0)) 4.5)))
r_m = fabs(r);
double code(double v, double w, double r_m) {
double tmp;
if (r_m <= 1850000000.0) {
tmp = -fma((((w * r_m) * r_m) * w), 0.25, (1.5 - (2.0 / (r_m * r_m))));
} else {
tmp = (3.0 - ((0.375 * ((w * r_m) * (w * r_m))) / 1.0)) - 4.5;
}
return tmp;
}
r_m = abs(r) function code(v, w, r_m) tmp = 0.0 if (r_m <= 1850000000.0) tmp = Float64(-fma(Float64(Float64(Float64(w * r_m) * r_m) * w), 0.25, Float64(1.5 - Float64(2.0 / Float64(r_m * r_m))))); else tmp = Float64(Float64(3.0 - Float64(Float64(0.375 * Float64(Float64(w * r_m) * Float64(w * r_m))) / 1.0)) - 4.5); end return tmp end
r_m = N[Abs[r], $MachinePrecision] code[v_, w_, r$95$m_] := If[LessEqual[r$95$m, 1850000000.0], (-N[(N[(N[(N[(w * r$95$m), $MachinePrecision] * r$95$m), $MachinePrecision] * w), $MachinePrecision] * 0.25 + N[(1.5 - N[(2.0 / N[(r$95$m * r$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), N[(N[(3.0 - N[(N[(0.375 * N[(N[(w * r$95$m), $MachinePrecision] * N[(w * r$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 1.0), $MachinePrecision]), $MachinePrecision] - 4.5), $MachinePrecision]]
\begin{array}{l}
r_m = \left|r\right|
\\
\begin{array}{l}
\mathbf{if}\;r\_m \leq 1850000000:\\
\;\;\;\;-\mathsf{fma}\left(\left(\left(w \cdot r\_m\right) \cdot r\_m\right) \cdot w, 0.25, 1.5 - \frac{2}{r\_m \cdot r\_m}\right)\\
\mathbf{else}:\\
\;\;\;\;\left(3 - \frac{0.375 \cdot \left(\left(w \cdot r\_m\right) \cdot \left(w \cdot r\_m\right)\right)}{1}\right) - 4.5\\
\end{array}
\end{array}
if r < 1.85e9Initial program 85.5%
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.5
Applied rewrites90.0%
Applied rewrites97.0%
Taylor expanded in v around inf
Applied rewrites92.2%
if 1.85e9 < r Initial program 85.5%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lift-*.f64N/A
unswap-sqrN/A
lower-*.f64N/A
lower-*.f64N/A
lower-*.f6495.0
Applied rewrites95.0%
Taylor expanded in v around 0
Applied rewrites85.7%
Taylor expanded in v around 0
Applied rewrites93.5%
Taylor expanded in r around inf
Applied rewrites48.7%
r_m = (fabs.f64 r)
(FPCore (v w r_m)
:precision binary64
(if (<=
(-
(-
(+ 3.0 (/ 2.0 (* r_m r_m)))
(/ (* (* 0.125 (- 3.0 (* 2.0 v))) (* (* (* w w) r_m) r_m)) (- 1.0 v)))
4.5)
-1.5)
(- (- 3.0 (/ (* 0.375 (* (* w r_m) (* w r_m))) 1.0)) 4.5)
(- (- 1.5 (/ 2.0 (pow r_m 2.0))))))r_m = fabs(r);
double code(double v, double w, double r_m) {
double tmp;
if ((((3.0 + (2.0 / (r_m * r_m))) - (((0.125 * (3.0 - (2.0 * v))) * (((w * w) * r_m) * r_m)) / (1.0 - v))) - 4.5) <= -1.5) {
tmp = (3.0 - ((0.375 * ((w * r_m) * (w * r_m))) / 1.0)) - 4.5;
} else {
tmp = -(1.5 - (2.0 / pow(r_m, 2.0)));
}
return tmp;
}
r_m = private
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_m)
use fmin_fmax_functions
real(8), intent (in) :: v
real(8), intent (in) :: w
real(8), intent (in) :: r_m
real(8) :: tmp
if ((((3.0d0 + (2.0d0 / (r_m * r_m))) - (((0.125d0 * (3.0d0 - (2.0d0 * v))) * (((w * w) * r_m) * r_m)) / (1.0d0 - v))) - 4.5d0) <= (-1.5d0)) then
tmp = (3.0d0 - ((0.375d0 * ((w * r_m) * (w * r_m))) / 1.0d0)) - 4.5d0
else
tmp = -(1.5d0 - (2.0d0 / (r_m ** 2.0d0)))
end if
code = tmp
end function
r_m = Math.abs(r);
public static double code(double v, double w, double r_m) {
double tmp;
if ((((3.0 + (2.0 / (r_m * r_m))) - (((0.125 * (3.0 - (2.0 * v))) * (((w * w) * r_m) * r_m)) / (1.0 - v))) - 4.5) <= -1.5) {
tmp = (3.0 - ((0.375 * ((w * r_m) * (w * r_m))) / 1.0)) - 4.5;
} else {
tmp = -(1.5 - (2.0 / Math.pow(r_m, 2.0)));
}
return tmp;
}
r_m = math.fabs(r) def code(v, w, r_m): tmp = 0 if (((3.0 + (2.0 / (r_m * r_m))) - (((0.125 * (3.0 - (2.0 * v))) * (((w * w) * r_m) * r_m)) / (1.0 - v))) - 4.5) <= -1.5: tmp = (3.0 - ((0.375 * ((w * r_m) * (w * r_m))) / 1.0)) - 4.5 else: tmp = -(1.5 - (2.0 / math.pow(r_m, 2.0))) return tmp
r_m = abs(r) function code(v, w, r_m) tmp = 0.0 if (Float64(Float64(Float64(3.0 + Float64(2.0 / Float64(r_m * r_m))) - Float64(Float64(Float64(0.125 * Float64(3.0 - Float64(2.0 * v))) * Float64(Float64(Float64(w * w) * r_m) * r_m)) / Float64(1.0 - v))) - 4.5) <= -1.5) tmp = Float64(Float64(3.0 - Float64(Float64(0.375 * Float64(Float64(w * r_m) * Float64(w * r_m))) / 1.0)) - 4.5); else tmp = Float64(-Float64(1.5 - Float64(2.0 / (r_m ^ 2.0)))); end return tmp end
r_m = abs(r); function tmp_2 = code(v, w, r_m) tmp = 0.0; if ((((3.0 + (2.0 / (r_m * r_m))) - (((0.125 * (3.0 - (2.0 * v))) * (((w * w) * r_m) * r_m)) / (1.0 - v))) - 4.5) <= -1.5) tmp = (3.0 - ((0.375 * ((w * r_m) * (w * r_m))) / 1.0)) - 4.5; else tmp = -(1.5 - (2.0 / (r_m ^ 2.0))); end tmp_2 = tmp; end
r_m = N[Abs[r], $MachinePrecision] code[v_, w_, r$95$m_] := If[LessEqual[N[(N[(N[(3.0 + N[(2.0 / N[(r$95$m * r$95$m), $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$95$m), $MachinePrecision] * r$95$m), $MachinePrecision]), $MachinePrecision] / N[(1.0 - v), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 4.5), $MachinePrecision], -1.5], N[(N[(3.0 - N[(N[(0.375 * N[(N[(w * r$95$m), $MachinePrecision] * N[(w * r$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 1.0), $MachinePrecision]), $MachinePrecision] - 4.5), $MachinePrecision], (-N[(1.5 - N[(2.0 / N[Power[r$95$m, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision])]
\begin{array}{l}
r_m = \left|r\right|
\\
\begin{array}{l}
\mathbf{if}\;\left(\left(3 + \frac{2}{r\_m \cdot r\_m}\right) - \frac{\left(0.125 \cdot \left(3 - 2 \cdot v\right)\right) \cdot \left(\left(\left(w \cdot w\right) \cdot r\_m\right) \cdot r\_m\right)}{1 - v}\right) - 4.5 \leq -1.5:\\
\;\;\;\;\left(3 - \frac{0.375 \cdot \left(\left(w \cdot r\_m\right) \cdot \left(w \cdot r\_m\right)\right)}{1}\right) - 4.5\\
\mathbf{else}:\\
\;\;\;\;-\left(1.5 - \frac{2}{{r\_m}^{2}}\right)\\
\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.5Initial program 85.5%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lift-*.f64N/A
unswap-sqrN/A
lower-*.f64N/A
lower-*.f64N/A
lower-*.f6495.0
Applied rewrites95.0%
Taylor expanded in v around 0
Applied rewrites85.7%
Taylor expanded in v around 0
Applied rewrites93.5%
Taylor expanded in r around inf
Applied rewrites48.7%
if -1.5 < (-.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%
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.5
Applied rewrites90.0%
Taylor expanded in w around 0
lower-/.f64N/A
lower-pow.f6458.4
Applied rewrites58.4%
r_m = (fabs.f64 r)
(FPCore (v w r_m)
:precision binary64
(let* ((t_0 (/ 2.0 (* r_m r_m))))
(if (<=
(-
(-
(+ 3.0 t_0)
(/
(* (* 0.125 (- 3.0 (* 2.0 v))) (* (* (* w w) r_m) r_m))
(- 1.0 v)))
4.5)
-1.5)
(- (- 3.0 (/ (* 0.375 (* (* w r_m) (* w r_m))) 1.0)) 4.5)
(- (- t_0 -3.0) 4.5))))r_m = fabs(r);
double code(double v, double w, double r_m) {
double t_0 = 2.0 / (r_m * r_m);
double tmp;
if ((((3.0 + t_0) - (((0.125 * (3.0 - (2.0 * v))) * (((w * w) * r_m) * r_m)) / (1.0 - v))) - 4.5) <= -1.5) {
tmp = (3.0 - ((0.375 * ((w * r_m) * (w * r_m))) / 1.0)) - 4.5;
} else {
tmp = (t_0 - -3.0) - 4.5;
}
return tmp;
}
r_m = private
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_m)
use fmin_fmax_functions
real(8), intent (in) :: v
real(8), intent (in) :: w
real(8), intent (in) :: r_m
real(8) :: t_0
real(8) :: tmp
t_0 = 2.0d0 / (r_m * r_m)
if ((((3.0d0 + t_0) - (((0.125d0 * (3.0d0 - (2.0d0 * v))) * (((w * w) * r_m) * r_m)) / (1.0d0 - v))) - 4.5d0) <= (-1.5d0)) then
tmp = (3.0d0 - ((0.375d0 * ((w * r_m) * (w * r_m))) / 1.0d0)) - 4.5d0
else
tmp = (t_0 - (-3.0d0)) - 4.5d0
end if
code = tmp
end function
r_m = Math.abs(r);
public static double code(double v, double w, double r_m) {
double t_0 = 2.0 / (r_m * r_m);
double tmp;
if ((((3.0 + t_0) - (((0.125 * (3.0 - (2.0 * v))) * (((w * w) * r_m) * r_m)) / (1.0 - v))) - 4.5) <= -1.5) {
tmp = (3.0 - ((0.375 * ((w * r_m) * (w * r_m))) / 1.0)) - 4.5;
} else {
tmp = (t_0 - -3.0) - 4.5;
}
return tmp;
}
r_m = math.fabs(r) def code(v, w, r_m): t_0 = 2.0 / (r_m * r_m) tmp = 0 if (((3.0 + t_0) - (((0.125 * (3.0 - (2.0 * v))) * (((w * w) * r_m) * r_m)) / (1.0 - v))) - 4.5) <= -1.5: tmp = (3.0 - ((0.375 * ((w * r_m) * (w * r_m))) / 1.0)) - 4.5 else: tmp = (t_0 - -3.0) - 4.5 return tmp
r_m = abs(r) function code(v, w, r_m) t_0 = Float64(2.0 / Float64(r_m * r_m)) 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_m) * r_m)) / Float64(1.0 - v))) - 4.5) <= -1.5) tmp = Float64(Float64(3.0 - Float64(Float64(0.375 * Float64(Float64(w * r_m) * Float64(w * r_m))) / 1.0)) - 4.5); else tmp = Float64(Float64(t_0 - -3.0) - 4.5); end return tmp end
r_m = abs(r); function tmp_2 = code(v, w, r_m) t_0 = 2.0 / (r_m * r_m); tmp = 0.0; if ((((3.0 + t_0) - (((0.125 * (3.0 - (2.0 * v))) * (((w * w) * r_m) * r_m)) / (1.0 - v))) - 4.5) <= -1.5) tmp = (3.0 - ((0.375 * ((w * r_m) * (w * r_m))) / 1.0)) - 4.5; else tmp = (t_0 - -3.0) - 4.5; end tmp_2 = tmp; end
r_m = N[Abs[r], $MachinePrecision]
code[v_, w_, r$95$m_] := Block[{t$95$0 = N[(2.0 / N[(r$95$m * r$95$m), $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$95$m), $MachinePrecision] * r$95$m), $MachinePrecision]), $MachinePrecision] / N[(1.0 - v), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 4.5), $MachinePrecision], -1.5], N[(N[(3.0 - N[(N[(0.375 * N[(N[(w * r$95$m), $MachinePrecision] * N[(w * r$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 1.0), $MachinePrecision]), $MachinePrecision] - 4.5), $MachinePrecision], N[(N[(t$95$0 - -3.0), $MachinePrecision] - 4.5), $MachinePrecision]]]
\begin{array}{l}
r_m = \left|r\right|
\\
\begin{array}{l}
t_0 := \frac{2}{r\_m \cdot r\_m}\\
\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\_m\right) \cdot r\_m\right)}{1 - v}\right) - 4.5 \leq -1.5:\\
\;\;\;\;\left(3 - \frac{0.375 \cdot \left(\left(w \cdot r\_m\right) \cdot \left(w \cdot r\_m\right)\right)}{1}\right) - 4.5\\
\mathbf{else}:\\
\;\;\;\;\left(t\_0 - -3\right) - 4.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.5Initial program 85.5%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lift-*.f64N/A
unswap-sqrN/A
lower-*.f64N/A
lower-*.f64N/A
lower-*.f6495.0
Applied rewrites95.0%
Taylor expanded in v around 0
Applied rewrites85.7%
Taylor expanded in v around 0
Applied rewrites93.5%
Taylor expanded in r around inf
Applied rewrites48.7%
if -1.5 < (-.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 v around inf
lower-*.f6474.6
Applied rewrites74.6%
lift--.f64N/A
lift--.f64N/A
associate--l-N/A
lower--.f64N/A
lift-+.f64N/A
+-commutativeN/A
add-flipN/A
lower--.f64N/A
metadata-evalN/A
Applied rewrites74.4%
Taylor expanded in w around 0
Applied rewrites58.4%
r_m = (fabs.f64 r) (FPCore (v w r_m) :precision binary64 (- (- (/ 2.0 (* r_m r_m)) -3.0) 4.5))
r_m = fabs(r);
double code(double v, double w, double r_m) {
return ((2.0 / (r_m * r_m)) - -3.0) - 4.5;
}
r_m = private
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_m)
use fmin_fmax_functions
real(8), intent (in) :: v
real(8), intent (in) :: w
real(8), intent (in) :: r_m
code = ((2.0d0 / (r_m * r_m)) - (-3.0d0)) - 4.5d0
end function
r_m = Math.abs(r);
public static double code(double v, double w, double r_m) {
return ((2.0 / (r_m * r_m)) - -3.0) - 4.5;
}
r_m = math.fabs(r) def code(v, w, r_m): return ((2.0 / (r_m * r_m)) - -3.0) - 4.5
r_m = abs(r) function code(v, w, r_m) return Float64(Float64(Float64(2.0 / Float64(r_m * r_m)) - -3.0) - 4.5) end
r_m = abs(r); function tmp = code(v, w, r_m) tmp = ((2.0 / (r_m * r_m)) - -3.0) - 4.5; end
r_m = N[Abs[r], $MachinePrecision] code[v_, w_, r$95$m_] := N[(N[(N[(2.0 / N[(r$95$m * r$95$m), $MachinePrecision]), $MachinePrecision] - -3.0), $MachinePrecision] - 4.5), $MachinePrecision]
\begin{array}{l}
r_m = \left|r\right|
\\
\left(\frac{2}{r\_m \cdot r\_m} - -3\right) - 4.5
\end{array}
Initial program 85.5%
Taylor expanded in v around inf
lower-*.f6474.6
Applied rewrites74.6%
lift--.f64N/A
lift--.f64N/A
associate--l-N/A
lower--.f64N/A
lift-+.f64N/A
+-commutativeN/A
add-flipN/A
lower--.f64N/A
metadata-evalN/A
Applied rewrites74.4%
Taylor expanded in w around 0
Applied rewrites58.4%
r_m = (fabs.f64 r) (FPCore (v w r_m) :precision binary64 (/ 2.0 (* r_m r_m)))
r_m = fabs(r);
double code(double v, double w, double r_m) {
return 2.0 / (r_m * r_m);
}
r_m = private
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_m)
use fmin_fmax_functions
real(8), intent (in) :: v
real(8), intent (in) :: w
real(8), intent (in) :: r_m
code = 2.0d0 / (r_m * r_m)
end function
r_m = Math.abs(r);
public static double code(double v, double w, double r_m) {
return 2.0 / (r_m * r_m);
}
r_m = math.fabs(r) def code(v, w, r_m): return 2.0 / (r_m * r_m)
r_m = abs(r) function code(v, w, r_m) return Float64(2.0 / Float64(r_m * r_m)) end
r_m = abs(r); function tmp = code(v, w, r_m) tmp = 2.0 / (r_m * r_m); end
r_m = N[Abs[r], $MachinePrecision] code[v_, w_, r$95$m_] := N[(2.0 / N[(r$95$m * r$95$m), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
r_m = \left|r\right|
\\
\frac{2}{r\_m \cdot r\_m}
\end{array}
Initial program 85.5%
Taylor expanded in r around 0
lower-/.f64N/A
lower-pow.f6445.4
Applied rewrites45.4%
lift-pow.f64N/A
pow2N/A
lift-*.f6445.4
Applied rewrites45.4%
herbie shell --seed 2025159
(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))