
(FPCore (v w r) :precision binary64 (- (- (+ 3.0 (/ 2.0 (* r r))) (/ (* (* 0.125 (- 3.0 (* 2.0 v))) (* (* (* w w) r) r)) (- 1.0 v))) 4.5))
double code(double v, double w, double r) {
return ((3.0 + (2.0 / (r * r))) - (((0.125 * (3.0 - (2.0 * v))) * (((w * w) * r) * r)) / (1.0 - v))) - 4.5;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(v, w, r)
use fmin_fmax_functions
real(8), intent (in) :: v
real(8), intent (in) :: w
real(8), intent (in) :: r
code = ((3.0d0 + (2.0d0 / (r * r))) - (((0.125d0 * (3.0d0 - (2.0d0 * v))) * (((w * w) * r) * r)) / (1.0d0 - v))) - 4.5d0
end function
public static double code(double v, double w, double r) {
return ((3.0 + (2.0 / (r * r))) - (((0.125 * (3.0 - (2.0 * v))) * (((w * w) * r) * r)) / (1.0 - v))) - 4.5;
}
def code(v, w, r): return ((3.0 + (2.0 / (r * r))) - (((0.125 * (3.0 - (2.0 * v))) * (((w * w) * r) * r)) / (1.0 - v))) - 4.5
function code(v, w, r) return Float64(Float64(Float64(3.0 + Float64(2.0 / Float64(r * r))) - Float64(Float64(Float64(0.125 * Float64(3.0 - Float64(2.0 * v))) * Float64(Float64(Float64(w * w) * r) * r)) / Float64(1.0 - v))) - 4.5) end
function tmp = code(v, w, r) tmp = ((3.0 + (2.0 / (r * r))) - (((0.125 * (3.0 - (2.0 * v))) * (((w * w) * r) * r)) / (1.0 - v))) - 4.5; end
code[v_, w_, r_] := N[(N[(N[(3.0 + N[(2.0 / N[(r * r), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(N[(N[(0.125 * N[(3.0 - N[(2.0 * v), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[(N[(w * w), $MachinePrecision] * r), $MachinePrecision] * r), $MachinePrecision]), $MachinePrecision] / N[(1.0 - v), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 4.5), $MachinePrecision]
\left(\left(3 + \frac{2}{r \cdot r}\right) - \frac{\left(0.125 \cdot \left(3 - 2 \cdot v\right)\right) \cdot \left(\left(\left(w \cdot w\right) \cdot r\right) \cdot r\right)}{1 - v}\right) - 4.5
Herbie found 10 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (v w r) :precision binary64 (- (- (+ 3.0 (/ 2.0 (* r r))) (/ (* (* 0.125 (- 3.0 (* 2.0 v))) (* (* (* w w) r) r)) (- 1.0 v))) 4.5))
double code(double v, double w, double r) {
return ((3.0 + (2.0 / (r * r))) - (((0.125 * (3.0 - (2.0 * v))) * (((w * w) * r) * r)) / (1.0 - v))) - 4.5;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(v, w, r)
use fmin_fmax_functions
real(8), intent (in) :: v
real(8), intent (in) :: w
real(8), intent (in) :: r
code = ((3.0d0 + (2.0d0 / (r * r))) - (((0.125d0 * (3.0d0 - (2.0d0 * v))) * (((w * w) * r) * r)) / (1.0d0 - v))) - 4.5d0
end function
public static double code(double v, double w, double r) {
return ((3.0 + (2.0 / (r * r))) - (((0.125 * (3.0 - (2.0 * v))) * (((w * w) * r) * r)) / (1.0 - v))) - 4.5;
}
def code(v, w, r): return ((3.0 + (2.0 / (r * r))) - (((0.125 * (3.0 - (2.0 * v))) * (((w * w) * r) * r)) / (1.0 - v))) - 4.5
function code(v, w, r) return Float64(Float64(Float64(3.0 + Float64(2.0 / Float64(r * r))) - Float64(Float64(Float64(0.125 * Float64(3.0 - Float64(2.0 * v))) * Float64(Float64(Float64(w * w) * r) * r)) / Float64(1.0 - v))) - 4.5) end
function tmp = code(v, w, r) tmp = ((3.0 + (2.0 / (r * r))) - (((0.125 * (3.0 - (2.0 * v))) * (((w * w) * r) * r)) / (1.0 - v))) - 4.5; end
code[v_, w_, r_] := N[(N[(N[(3.0 + N[(2.0 / N[(r * r), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(N[(N[(0.125 * N[(3.0 - N[(2.0 * v), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[(N[(w * w), $MachinePrecision] * r), $MachinePrecision] * r), $MachinePrecision]), $MachinePrecision] / N[(1.0 - v), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 4.5), $MachinePrecision]
\left(\left(3 + \frac{2}{r \cdot r}\right) - \frac{\left(0.125 \cdot \left(3 - 2 \cdot v\right)\right) \cdot \left(\left(\left(w \cdot w\right) \cdot r\right) \cdot r\right)}{1 - v}\right) - 4.5
(FPCore (v w r)
:precision binary64
(let* ((t_0 (+ 3.0 (/ 2.0 (* r r))))
(t_1 (- (- t_0 (* (* 0.25 (* r w)) (* w r))) 4.5)))
(if (<= v -4.2e+61)
t_1
(if (<= v 8e-24) (- (- t_0 (* (* 0.375 (* r w)) (* w r))) 4.5) t_1))))double code(double v, double w, double r) {
double t_0 = 3.0 + (2.0 / (r * r));
double t_1 = (t_0 - ((0.25 * (r * w)) * (w * r))) - 4.5;
double tmp;
if (v <= -4.2e+61) {
tmp = t_1;
} else if (v <= 8e-24) {
tmp = (t_0 - ((0.375 * (r * w)) * (w * r))) - 4.5;
} else {
tmp = t_1;
}
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) :: t_1
real(8) :: tmp
t_0 = 3.0d0 + (2.0d0 / (r * r))
t_1 = (t_0 - ((0.25d0 * (r * w)) * (w * r))) - 4.5d0
if (v <= (-4.2d+61)) then
tmp = t_1
else if (v <= 8d-24) then
tmp = (t_0 - ((0.375d0 * (r * w)) * (w * r))) - 4.5d0
else
tmp = t_1
end if
code = tmp
end function
public static double code(double v, double w, double r) {
double t_0 = 3.0 + (2.0 / (r * r));
double t_1 = (t_0 - ((0.25 * (r * w)) * (w * r))) - 4.5;
double tmp;
if (v <= -4.2e+61) {
tmp = t_1;
} else if (v <= 8e-24) {
tmp = (t_0 - ((0.375 * (r * w)) * (w * r))) - 4.5;
} else {
tmp = t_1;
}
return tmp;
}
def code(v, w, r): t_0 = 3.0 + (2.0 / (r * r)) t_1 = (t_0 - ((0.25 * (r * w)) * (w * r))) - 4.5 tmp = 0 if v <= -4.2e+61: tmp = t_1 elif v <= 8e-24: tmp = (t_0 - ((0.375 * (r * w)) * (w * r))) - 4.5 else: tmp = t_1 return tmp
function code(v, w, r) t_0 = Float64(3.0 + Float64(2.0 / Float64(r * r))) t_1 = Float64(Float64(t_0 - Float64(Float64(0.25 * Float64(r * w)) * Float64(w * r))) - 4.5) tmp = 0.0 if (v <= -4.2e+61) tmp = t_1; elseif (v <= 8e-24) tmp = Float64(Float64(t_0 - Float64(Float64(0.375 * Float64(r * w)) * Float64(w * r))) - 4.5); else tmp = t_1; end return tmp end
function tmp_2 = code(v, w, r) t_0 = 3.0 + (2.0 / (r * r)); t_1 = (t_0 - ((0.25 * (r * w)) * (w * r))) - 4.5; tmp = 0.0; if (v <= -4.2e+61) tmp = t_1; elseif (v <= 8e-24) tmp = (t_0 - ((0.375 * (r * w)) * (w * r))) - 4.5; else tmp = t_1; end tmp_2 = tmp; end
code[v_, w_, r_] := Block[{t$95$0 = N[(3.0 + N[(2.0 / N[(r * r), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(t$95$0 - N[(N[(0.25 * N[(r * w), $MachinePrecision]), $MachinePrecision] * N[(w * r), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 4.5), $MachinePrecision]}, If[LessEqual[v, -4.2e+61], t$95$1, If[LessEqual[v, 8e-24], N[(N[(t$95$0 - N[(N[(0.375 * N[(r * w), $MachinePrecision]), $MachinePrecision] * N[(w * r), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 4.5), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
t_0 := 3 + \frac{2}{r \cdot r}\\
t_1 := \left(t\_0 - \left(0.25 \cdot \left(r \cdot w\right)\right) \cdot \left(w \cdot r\right)\right) - 4.5\\
\mathbf{if}\;v \leq -4.2 \cdot 10^{+61}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;v \leq 8 \cdot 10^{-24}:\\
\;\;\;\;\left(t\_0 - \left(0.375 \cdot \left(r \cdot w\right)\right) \cdot \left(w \cdot r\right)\right) - 4.5\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
if v < -4.2000000000000002e61 or 7.99999999999999939e-24 < v Initial program 84.7%
Taylor expanded in v around 0
lower-+.f64N/A
lower-*.f6484.7%
Applied rewrites84.7%
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lift-*.f64N/A
swap-sqrN/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
associate-*r*N/A
lower-*.f64N/A
Applied rewrites89.9%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
lift-*.f64N/A
*-commutativeN/A
associate-*l/N/A
lift-/.f64N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f6494.5%
Applied rewrites94.5%
Taylor expanded in v around inf
lower-*.f64N/A
lower-*.f6493.5%
Applied rewrites93.5%
if -4.2000000000000002e61 < v < 7.99999999999999939e-24Initial program 84.7%
Taylor expanded in v around 0
lower-+.f64N/A
lower-*.f6484.7%
Applied rewrites84.7%
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lift-*.f64N/A
swap-sqrN/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
associate-*r*N/A
lower-*.f64N/A
Applied rewrites89.9%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
lift-*.f64N/A
*-commutativeN/A
associate-*l/N/A
lift-/.f64N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f6494.5%
Applied rewrites94.5%
Taylor expanded in v around 0
lower-*.f64N/A
lower-*.f6493.3%
Applied rewrites93.3%
(FPCore (v w r)
:precision binary64
(let* ((t_0 (/ 2.0 (* r r))) (t_1 (+ 3.0 t_0)))
(if (<=
(-
(-
t_1
(/ (* (* 0.125 (- 3.0 (* 2.0 v))) (* (* (* w w) r) r)) (- 1.0 v)))
4.5)
(- INFINITY))
(- (- t_1 (* (* 0.25 (* r w)) (* w r))) 4.5)
(- (fma (* (/ (* (fma -0.25 v 0.375) (* w r)) (- v 1.0)) w) r t_0) 1.5))))double code(double v, double w, double r) {
double t_0 = 2.0 / (r * r);
double t_1 = 3.0 + t_0;
double tmp;
if (((t_1 - (((0.125 * (3.0 - (2.0 * v))) * (((w * w) * r) * r)) / (1.0 - v))) - 4.5) <= -((double) INFINITY)) {
tmp = (t_1 - ((0.25 * (r * w)) * (w * r))) - 4.5;
} else {
tmp = fma((((fma(-0.25, v, 0.375) * (w * r)) / (v - 1.0)) * w), r, t_0) - 1.5;
}
return tmp;
}
function code(v, w, r) t_0 = Float64(2.0 / Float64(r * r)) t_1 = Float64(3.0 + t_0) tmp = 0.0 if (Float64(Float64(t_1 - 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) <= Float64(-Inf)) tmp = Float64(Float64(t_1 - Float64(Float64(0.25 * Float64(r * w)) * Float64(w * r))) - 4.5); else tmp = Float64(fma(Float64(Float64(Float64(fma(-0.25, v, 0.375) * Float64(w * r)) / Float64(v - 1.0)) * w), r, t_0) - 1.5); end return tmp end
code[v_, w_, r_] := Block[{t$95$0 = N[(2.0 / N[(r * r), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(3.0 + t$95$0), $MachinePrecision]}, If[LessEqual[N[(N[(t$95$1 - 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], (-Infinity)], N[(N[(t$95$1 - N[(N[(0.25 * N[(r * w), $MachinePrecision]), $MachinePrecision] * N[(w * r), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 4.5), $MachinePrecision], N[(N[(N[(N[(N[(N[(-0.25 * v + 0.375), $MachinePrecision] * N[(w * r), $MachinePrecision]), $MachinePrecision] / N[(v - 1.0), $MachinePrecision]), $MachinePrecision] * w), $MachinePrecision] * r + t$95$0), $MachinePrecision] - 1.5), $MachinePrecision]]]]
\begin{array}{l}
t_0 := \frac{2}{r \cdot r}\\
t_1 := 3 + t\_0\\
\mathbf{if}\;\left(t\_1 - \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 -\infty:\\
\;\;\;\;\left(t\_1 - \left(0.25 \cdot \left(r \cdot w\right)\right) \cdot \left(w \cdot r\right)\right) - 4.5\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{\mathsf{fma}\left(-0.25, v, 0.375\right) \cdot \left(w \cdot r\right)}{v - 1} \cdot w, r, t\_0\right) - 1.5\\
\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 84.7%
Taylor expanded in v around 0
lower-+.f64N/A
lower-*.f6484.7%
Applied rewrites84.7%
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lift-*.f64N/A
swap-sqrN/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
associate-*r*N/A
lower-*.f64N/A
Applied rewrites89.9%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
lift-*.f64N/A
*-commutativeN/A
associate-*l/N/A
lift-/.f64N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f6494.5%
Applied rewrites94.5%
Taylor expanded in v around inf
lower-*.f64N/A
lower-*.f6493.5%
Applied rewrites93.5%
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)) Initial program 84.7%
Taylor expanded in v around 0
lower-+.f64N/A
lower-*.f6484.7%
Applied rewrites84.7%
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lift-*.f64N/A
swap-sqrN/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
associate-*r*N/A
lower-*.f64N/A
Applied rewrites89.9%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
lift-*.f64N/A
*-commutativeN/A
associate-*l/N/A
lift-/.f64N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f6494.5%
Applied rewrites94.5%
Applied rewrites95.1%
(FPCore (v w r) :precision binary64 (- (- (+ 3.0 (/ 2.0 (* r r))) (* (fma -2.0 v 3.0) (* (* w 0.125) (* (/ r (- 1.0 v)) (* w r))))) 4.5))
double code(double v, double w, double r) {
return ((3.0 + (2.0 / (r * r))) - (fma(-2.0, v, 3.0) * ((w * 0.125) * ((r / (1.0 - v)) * (w * r))))) - 4.5;
}
function code(v, w, r) return Float64(Float64(Float64(3.0 + Float64(2.0 / Float64(r * r))) - Float64(fma(-2.0, v, 3.0) * Float64(Float64(w * 0.125) * Float64(Float64(r / Float64(1.0 - v)) * Float64(w * r))))) - 4.5) end
code[v_, w_, r_] := N[(N[(N[(3.0 + N[(2.0 / N[(r * r), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(N[(-2.0 * v + 3.0), $MachinePrecision] * N[(N[(w * 0.125), $MachinePrecision] * N[(N[(r / N[(1.0 - v), $MachinePrecision]), $MachinePrecision] * N[(w * r), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 4.5), $MachinePrecision]
\left(\left(3 + \frac{2}{r \cdot r}\right) - \mathsf{fma}\left(-2, v, 3\right) \cdot \left(\left(w \cdot 0.125\right) \cdot \left(\frac{r}{1 - v} \cdot \left(w \cdot r\right)\right)\right)\right) - 4.5
Initial program 84.7%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lift-*.f64N/A
unswap-sqrN/A
lower-*.f64N/A
lower-*.f64N/A
lower-*.f6495.1%
Applied rewrites95.1%
Applied rewrites97.7%
(FPCore (v w r)
:precision binary64
(let* ((t_0 (* w (fabs r))))
(if (<= (fabs r) 7e-12)
(-
(-
(+ 3.0 (/ 2.0 (* (fabs r) (fabs r))))
(* (* 0.375 (* (fabs r) w)) t_0))
4.5)
(-
(- 3.0 (* (* (* (fma -0.25 v 0.375) w) (/ (fabs r) (- 1.0 v))) t_0))
4.5))))double code(double v, double w, double r) {
double t_0 = w * fabs(r);
double tmp;
if (fabs(r) <= 7e-12) {
tmp = ((3.0 + (2.0 / (fabs(r) * fabs(r)))) - ((0.375 * (fabs(r) * w)) * t_0)) - 4.5;
} else {
tmp = (3.0 - (((fma(-0.25, v, 0.375) * w) * (fabs(r) / (1.0 - v))) * t_0)) - 4.5;
}
return tmp;
}
function code(v, w, r) t_0 = Float64(w * abs(r)) tmp = 0.0 if (abs(r) <= 7e-12) tmp = Float64(Float64(Float64(3.0 + Float64(2.0 / Float64(abs(r) * abs(r)))) - Float64(Float64(0.375 * Float64(abs(r) * w)) * t_0)) - 4.5); else tmp = Float64(Float64(3.0 - Float64(Float64(Float64(fma(-0.25, v, 0.375) * w) * Float64(abs(r) / Float64(1.0 - v))) * t_0)) - 4.5); end return tmp end
code[v_, w_, r_] := Block[{t$95$0 = N[(w * N[Abs[r], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[Abs[r], $MachinePrecision], 7e-12], N[(N[(N[(3.0 + N[(2.0 / N[(N[Abs[r], $MachinePrecision] * N[Abs[r], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(N[(0.375 * N[(N[Abs[r], $MachinePrecision] * w), $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision] - 4.5), $MachinePrecision], N[(N[(3.0 - N[(N[(N[(N[(-0.25 * v + 0.375), $MachinePrecision] * w), $MachinePrecision] * N[(N[Abs[r], $MachinePrecision] / N[(1.0 - v), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision] - 4.5), $MachinePrecision]]]
\begin{array}{l}
t_0 := w \cdot \left|r\right|\\
\mathbf{if}\;\left|r\right| \leq 7 \cdot 10^{-12}:\\
\;\;\;\;\left(\left(3 + \frac{2}{\left|r\right| \cdot \left|r\right|}\right) - \left(0.375 \cdot \left(\left|r\right| \cdot w\right)\right) \cdot t\_0\right) - 4.5\\
\mathbf{else}:\\
\;\;\;\;\left(3 - \left(\left(\mathsf{fma}\left(-0.25, v, 0.375\right) \cdot w\right) \cdot \frac{\left|r\right|}{1 - v}\right) \cdot t\_0\right) - 4.5\\
\end{array}
if r < 7.0000000000000001e-12Initial program 84.7%
Taylor expanded in v around 0
lower-+.f64N/A
lower-*.f6484.7%
Applied rewrites84.7%
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lift-*.f64N/A
swap-sqrN/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
associate-*r*N/A
lower-*.f64N/A
Applied rewrites89.9%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
lift-*.f64N/A
*-commutativeN/A
associate-*l/N/A
lift-/.f64N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f6494.5%
Applied rewrites94.5%
Taylor expanded in v around 0
lower-*.f64N/A
lower-*.f6493.3%
Applied rewrites93.3%
if 7.0000000000000001e-12 < r Initial program 84.7%
Taylor expanded in v around 0
lower-+.f64N/A
lower-*.f6484.7%
Applied rewrites84.7%
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lift-*.f64N/A
swap-sqrN/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
associate-*r*N/A
lower-*.f64N/A
Applied rewrites89.9%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
lift-*.f64N/A
*-commutativeN/A
associate-*l/N/A
lift-/.f64N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f6494.5%
Applied rewrites94.5%
Taylor expanded in r around inf
Applied rewrites54.7%
(FPCore (v w r) :precision binary64 (- (fma (* (* (* (/ r (- 1.0 v)) w) (fma -0.25 v 0.375)) r) w (- 1.5 (/ 2.0 (* r r))))))
double code(double v, double w, double r) {
return -fma(((((r / (1.0 - v)) * w) * fma(-0.25, v, 0.375)) * r), w, (1.5 - (2.0 / (r * r))));
}
function code(v, w, r) return Float64(-fma(Float64(Float64(Float64(Float64(r / Float64(1.0 - v)) * w) * fma(-0.25, v, 0.375)) * r), w, Float64(1.5 - Float64(2.0 / Float64(r * r))))) end
code[v_, w_, r_] := (-N[(N[(N[(N[(N[(r / N[(1.0 - v), $MachinePrecision]), $MachinePrecision] * w), $MachinePrecision] * N[(-0.25 * v + 0.375), $MachinePrecision]), $MachinePrecision] * r), $MachinePrecision] * w + N[(1.5 - N[(2.0 / N[(r * r), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision])
-\mathsf{fma}\left(\left(\left(\frac{r}{1 - v} \cdot w\right) \cdot \mathsf{fma}\left(-0.25, v, 0.375\right)\right) \cdot r, w, 1.5 - \frac{2}{r \cdot r}\right)
Initial program 84.7%
Taylor expanded in v around 0
lower-+.f64N/A
lower-*.f6484.7%
Applied rewrites84.7%
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
Applied rewrites84.8%
lift--.f64N/A
lift--.f64N/A
associate--r-N/A
+-commutativeN/A
Applied rewrites96.4%
(FPCore (v w r) :precision binary64 (- (- (+ 3.0 (/ 2.0 (* r r))) (* (* 0.25 (* r w)) (* w r))) 4.5))
double code(double v, double w, double r) {
return ((3.0 + (2.0 / (r * r))) - ((0.25 * (r * w)) * (w * r))) - 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.25d0 * (r * w)) * (w * r))) - 4.5d0
end function
public static double code(double v, double w, double r) {
return ((3.0 + (2.0 / (r * r))) - ((0.25 * (r * w)) * (w * r))) - 4.5;
}
def code(v, w, r): return ((3.0 + (2.0 / (r * r))) - ((0.25 * (r * w)) * (w * r))) - 4.5
function code(v, w, r) return Float64(Float64(Float64(3.0 + Float64(2.0 / Float64(r * r))) - Float64(Float64(0.25 * Float64(r * w)) * Float64(w * r))) - 4.5) end
function tmp = code(v, w, r) tmp = ((3.0 + (2.0 / (r * r))) - ((0.25 * (r * w)) * (w * r))) - 4.5; end
code[v_, w_, r_] := N[(N[(N[(3.0 + N[(2.0 / N[(r * r), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(N[(0.25 * N[(r * w), $MachinePrecision]), $MachinePrecision] * N[(w * r), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 4.5), $MachinePrecision]
\left(\left(3 + \frac{2}{r \cdot r}\right) - \left(0.25 \cdot \left(r \cdot w\right)\right) \cdot \left(w \cdot r\right)\right) - 4.5
Initial program 84.7%
Taylor expanded in v around 0
lower-+.f64N/A
lower-*.f6484.7%
Applied rewrites84.7%
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lift-*.f64N/A
swap-sqrN/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
associate-*r*N/A
lower-*.f64N/A
Applied rewrites89.9%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
lift-*.f64N/A
*-commutativeN/A
associate-*l/N/A
lift-/.f64N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f6494.5%
Applied rewrites94.5%
Taylor expanded in v around inf
lower-*.f64N/A
lower-*.f6493.5%
Applied rewrites93.5%
(FPCore (v w r)
:precision binary64
(if (<=
(-
(-
(+ 3.0 (/ 2.0 (* r r)))
(/ (* (* 0.125 (- 3.0 (* 2.0 v))) (* (* (* w w) r) r)) (- 1.0 v)))
4.5)
-1.5)
(- (- 3.0 (/ (* 0.375 (* (* w r) (* w r))) (- 1.0 v))) 4.5)
(- (* 2.0 (/ 1.0 (pow r 2.0))) 1.5)))double code(double v, double w, double r) {
double tmp;
if ((((3.0 + (2.0 / (r * r))) - (((0.125 * (3.0 - (2.0 * v))) * (((w * w) * r) * r)) / (1.0 - v))) - 4.5) <= -1.5) {
tmp = (3.0 - ((0.375 * ((w * r) * (w * r))) / (1.0 - v))) - 4.5;
} else {
tmp = (2.0 * (1.0 / pow(r, 2.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) :: tmp
if ((((3.0d0 + (2.0d0 / (r * r))) - (((0.125d0 * (3.0d0 - (2.0d0 * v))) * (((w * w) * r) * r)) / (1.0d0 - v))) - 4.5d0) <= (-1.5d0)) then
tmp = (3.0d0 - ((0.375d0 * ((w * r) * (w * r))) / (1.0d0 - v))) - 4.5d0
else
tmp = (2.0d0 * (1.0d0 / (r ** 2.0d0))) - 1.5d0
end if
code = tmp
end function
public static double code(double v, double w, double r) {
double tmp;
if ((((3.0 + (2.0 / (r * r))) - (((0.125 * (3.0 - (2.0 * v))) * (((w * w) * r) * r)) / (1.0 - v))) - 4.5) <= -1.5) {
tmp = (3.0 - ((0.375 * ((w * r) * (w * r))) / (1.0 - v))) - 4.5;
} else {
tmp = (2.0 * (1.0 / Math.pow(r, 2.0))) - 1.5;
}
return tmp;
}
def code(v, w, r): tmp = 0 if (((3.0 + (2.0 / (r * r))) - (((0.125 * (3.0 - (2.0 * v))) * (((w * w) * r) * r)) / (1.0 - v))) - 4.5) <= -1.5: tmp = (3.0 - ((0.375 * ((w * r) * (w * r))) / (1.0 - v))) - 4.5 else: tmp = (2.0 * (1.0 / math.pow(r, 2.0))) - 1.5 return tmp
function code(v, w, r) tmp = 0.0 if (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) <= -1.5) tmp = Float64(Float64(3.0 - Float64(Float64(0.375 * Float64(Float64(w * r) * Float64(w * r))) / Float64(1.0 - v))) - 4.5); else tmp = Float64(Float64(2.0 * Float64(1.0 / (r ^ 2.0))) - 1.5); end return tmp end
function tmp_2 = code(v, w, r) tmp = 0.0; if ((((3.0 + (2.0 / (r * r))) - (((0.125 * (3.0 - (2.0 * v))) * (((w * w) * r) * r)) / (1.0 - v))) - 4.5) <= -1.5) tmp = (3.0 - ((0.375 * ((w * r) * (w * r))) / (1.0 - v))) - 4.5; else tmp = (2.0 * (1.0 / (r ^ 2.0))) - 1.5; end tmp_2 = tmp; end
code[v_, w_, r_] := If[LessEqual[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], -1.5], N[(N[(3.0 - N[(N[(0.375 * N[(N[(w * r), $MachinePrecision] * N[(w * r), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(1.0 - v), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 4.5), $MachinePrecision], N[(N[(2.0 * N[(1.0 / N[Power[r, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 1.5), $MachinePrecision]]
\begin{array}{l}
\mathbf{if}\;\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 \leq -1.5:\\
\;\;\;\;\left(3 - \frac{0.375 \cdot \left(\left(w \cdot r\right) \cdot \left(w \cdot r\right)\right)}{1 - v}\right) - 4.5\\
\mathbf{else}:\\
\;\;\;\;2 \cdot \frac{1}{{r}^{2}} - 1.5\\
\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 84.7%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lift-*.f64N/A
unswap-sqrN/A
lower-*.f64N/A
lower-*.f64N/A
lower-*.f6495.1%
Applied rewrites95.1%
Taylor expanded in v around 0
Applied rewrites85.2%
Taylor expanded in r around inf
Applied rewrites41.2%
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 84.7%
Taylor expanded in w around 0
lower--.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lower-pow.f6457.8%
Applied rewrites57.8%
(FPCore (v w r)
:precision binary64
(if (<=
(-
(-
(+ 3.0 (/ 2.0 (* r r)))
(/ (* (* 0.125 (- 3.0 (* 2.0 v))) (* (* (* w w) r) r)) (- 1.0 v)))
4.5)
-1.5)
(- (- 3.0 (/ (* 0.375 (* (* w r) (* w r))) (- 1.0 v))) 4.5)
(fma (/ 2.0 r) (/ 1.0 r) -1.5)))double code(double v, double w, double r) {
double tmp;
if ((((3.0 + (2.0 / (r * r))) - (((0.125 * (3.0 - (2.0 * v))) * (((w * w) * r) * r)) / (1.0 - v))) - 4.5) <= -1.5) {
tmp = (3.0 - ((0.375 * ((w * r) * (w * r))) / (1.0 - v))) - 4.5;
} else {
tmp = fma((2.0 / r), (1.0 / r), -1.5);
}
return tmp;
}
function code(v, w, r) tmp = 0.0 if (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) <= -1.5) tmp = Float64(Float64(3.0 - Float64(Float64(0.375 * Float64(Float64(w * r) * Float64(w * r))) / Float64(1.0 - v))) - 4.5); else tmp = fma(Float64(2.0 / r), Float64(1.0 / r), -1.5); end return tmp end
code[v_, w_, r_] := If[LessEqual[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], -1.5], N[(N[(3.0 - N[(N[(0.375 * N[(N[(w * r), $MachinePrecision] * N[(w * r), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(1.0 - v), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 4.5), $MachinePrecision], N[(N[(2.0 / r), $MachinePrecision] * N[(1.0 / r), $MachinePrecision] + -1.5), $MachinePrecision]]
\begin{array}{l}
\mathbf{if}\;\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 \leq -1.5:\\
\;\;\;\;\left(3 - \frac{0.375 \cdot \left(\left(w \cdot r\right) \cdot \left(w \cdot r\right)\right)}{1 - v}\right) - 4.5\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{2}{r}, \frac{1}{r}, -1.5\right)\\
\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 84.7%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lift-*.f64N/A
unswap-sqrN/A
lower-*.f64N/A
lower-*.f64N/A
lower-*.f6495.1%
Applied rewrites95.1%
Taylor expanded in v around 0
Applied rewrites85.2%
Taylor expanded in r around inf
Applied rewrites41.2%
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 84.7%
lift--.f64N/A
lift--.f64N/A
associate--l-N/A
lift-+.f64N/A
+-commutativeN/A
associate--l+N/A
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
mult-flipN/A
lower-fma.f64N/A
lower-/.f64N/A
lower-/.f64N/A
Applied rewrites91.4%
Taylor expanded in w around 0
Applied rewrites57.7%
(FPCore (v w r) :precision binary64 (fma (/ 2.0 r) (/ 1.0 r) -1.5))
double code(double v, double w, double r) {
return fma((2.0 / r), (1.0 / r), -1.5);
}
function code(v, w, r) return fma(Float64(2.0 / r), Float64(1.0 / r), -1.5) end
code[v_, w_, r_] := N[(N[(2.0 / r), $MachinePrecision] * N[(1.0 / r), $MachinePrecision] + -1.5), $MachinePrecision]
\mathsf{fma}\left(\frac{2}{r}, \frac{1}{r}, -1.5\right)
Initial program 84.7%
lift--.f64N/A
lift--.f64N/A
associate--l-N/A
lift-+.f64N/A
+-commutativeN/A
associate--l+N/A
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
mult-flipN/A
lower-fma.f64N/A
lower-/.f64N/A
lower-/.f64N/A
Applied rewrites91.4%
Taylor expanded in w around 0
Applied rewrites57.7%
(FPCore (v w r) :precision binary64 (/ 2.0 (* r r)))
double code(double v, double w, double r) {
return 2.0 / (r * r);
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(v, w, r)
use fmin_fmax_functions
real(8), intent (in) :: v
real(8), intent (in) :: w
real(8), intent (in) :: r
code = 2.0d0 / (r * r)
end function
public static double code(double v, double w, double r) {
return 2.0 / (r * r);
}
def code(v, w, r): return 2.0 / (r * r)
function code(v, w, r) return Float64(2.0 / Float64(r * r)) end
function tmp = code(v, w, r) tmp = 2.0 / (r * r); end
code[v_, w_, r_] := N[(2.0 / N[(r * r), $MachinePrecision]), $MachinePrecision]
\frac{2}{r \cdot r}
Initial program 84.7%
Taylor expanded in r around 0
lower-/.f64N/A
lower-pow.f6444.6%
Applied rewrites44.6%
lift-pow.f64N/A
pow2N/A
lift-*.f6444.6%
Applied rewrites44.6%
herbie shell --seed 2025179
(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))