
(FPCore (x y z) :precision binary64 (/ (* x (+ (- y z) 1.0)) z))
double code(double x, double y, double z) {
return (x * ((y - z) + 1.0)) / z;
}
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(x, y, z)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (x * ((y - z) + 1.0d0)) / z
end function
public static double code(double x, double y, double z) {
return (x * ((y - z) + 1.0)) / z;
}
def code(x, y, z): return (x * ((y - z) + 1.0)) / z
function code(x, y, z) return Float64(Float64(x * Float64(Float64(y - z) + 1.0)) / z) end
function tmp = code(x, y, z) tmp = (x * ((y - z) + 1.0)) / z; end
code[x_, y_, z_] := N[(N[(x * N[(N[(y - z), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]
\frac{x \cdot \left(\left(y - z\right) + 1\right)}{z}
Herbie found 10 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z) :precision binary64 (/ (* x (+ (- y z) 1.0)) z))
double code(double x, double y, double z) {
return (x * ((y - z) + 1.0)) / z;
}
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(x, y, z)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (x * ((y - z) + 1.0d0)) / z
end function
public static double code(double x, double y, double z) {
return (x * ((y - z) + 1.0)) / z;
}
def code(x, y, z): return (x * ((y - z) + 1.0)) / z
function code(x, y, z) return Float64(Float64(x * Float64(Float64(y - z) + 1.0)) / z) end
function tmp = code(x, y, z) tmp = (x * ((y - z) + 1.0)) / z; end
code[x_, y_, z_] := N[(N[(x * N[(N[(y - z), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]
\frac{x \cdot \left(\left(y - z\right) + 1\right)}{z}
(FPCore (x y z)
:precision binary64
(let* ((t_0 (fma (/ y z) x (- x))))
(if (<= z -3.9e+15)
t_0
(if (<= z 1200000000.0) (- (/ (fma x y x) z) x) t_0))))double code(double x, double y, double z) {
double t_0 = fma((y / z), x, -x);
double tmp;
if (z <= -3.9e+15) {
tmp = t_0;
} else if (z <= 1200000000.0) {
tmp = (fma(x, y, x) / z) - x;
} else {
tmp = t_0;
}
return tmp;
}
function code(x, y, z) t_0 = fma(Float64(y / z), x, Float64(-x)) tmp = 0.0 if (z <= -3.9e+15) tmp = t_0; elseif (z <= 1200000000.0) tmp = Float64(Float64(fma(x, y, x) / z) - x); else tmp = t_0; end return tmp end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(y / z), $MachinePrecision] * x + (-x)), $MachinePrecision]}, If[LessEqual[z, -3.9e+15], t$95$0, If[LessEqual[z, 1200000000.0], N[(N[(N[(x * y + x), $MachinePrecision] / z), $MachinePrecision] - x), $MachinePrecision], t$95$0]]]
\begin{array}{l}
t_0 := \mathsf{fma}\left(\frac{y}{z}, x, -x\right)\\
\mathbf{if}\;z \leq -3.9 \cdot 10^{+15}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq 1200000000:\\
\;\;\;\;\frac{\mathsf{fma}\left(x, y, x\right)}{z} - x\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
if z < -3.9e15 or 1.2e9 < z Initial program 88.2%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6495.7%
lift-+.f64N/A
add-flipN/A
lower--.f64N/A
metadata-eval95.7%
Applied rewrites95.7%
Applied rewrites95.7%
Taylor expanded in y around inf
lower-/.f6471.2%
Applied rewrites71.2%
if -3.9e15 < z < 1.2e9Initial program 88.2%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6495.7%
lift-+.f64N/A
add-flipN/A
lower--.f64N/A
metadata-eval95.7%
Applied rewrites95.7%
Applied rewrites95.9%
(FPCore (x y z)
:precision binary64
(*
(copysign 1.0 x)
(if (<= (fabs x) 5e-20)
(- (/ (fma (fabs x) y (fabs x)) z) (fabs x))
(fma (/ (- y -1.0) z) (fabs x) (- (fabs x))))))double code(double x, double y, double z) {
double tmp;
if (fabs(x) <= 5e-20) {
tmp = (fma(fabs(x), y, fabs(x)) / z) - fabs(x);
} else {
tmp = fma(((y - -1.0) / z), fabs(x), -fabs(x));
}
return copysign(1.0, x) * tmp;
}
function code(x, y, z) tmp = 0.0 if (abs(x) <= 5e-20) tmp = Float64(Float64(fma(abs(x), y, abs(x)) / z) - abs(x)); else tmp = fma(Float64(Float64(y - -1.0) / z), abs(x), Float64(-abs(x))); end return Float64(copysign(1.0, x) * tmp) end
code[x_, y_, z_] := N[(N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * If[LessEqual[N[Abs[x], $MachinePrecision], 5e-20], N[(N[(N[(N[Abs[x], $MachinePrecision] * y + N[Abs[x], $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision] - N[Abs[x], $MachinePrecision]), $MachinePrecision], N[(N[(N[(y - -1.0), $MachinePrecision] / z), $MachinePrecision] * N[Abs[x], $MachinePrecision] + (-N[Abs[x], $MachinePrecision])), $MachinePrecision]]), $MachinePrecision]
\mathsf{copysign}\left(1, x\right) \cdot \begin{array}{l}
\mathbf{if}\;\left|x\right| \leq 5 \cdot 10^{-20}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\left|x\right|, y, \left|x\right|\right)}{z} - \left|x\right|\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{y - -1}{z}, \left|x\right|, -\left|x\right|\right)\\
\end{array}
if x < 4.9999999999999999e-20Initial program 88.2%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6495.7%
lift-+.f64N/A
add-flipN/A
lower--.f64N/A
metadata-eval95.7%
Applied rewrites95.7%
Applied rewrites95.9%
if 4.9999999999999999e-20 < x Initial program 88.2%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6495.7%
lift-+.f64N/A
add-flipN/A
lower--.f64N/A
metadata-eval95.7%
Applied rewrites95.7%
Applied rewrites95.7%
(FPCore (x y z)
:precision binary64
(*
(copysign 1.0 x)
(if (<= (fabs x) 1e-28)
(- (/ (fma (fabs x) y (fabs x)) z) (fabs x))
(* (/ (fabs x) z) (- (- y z) -1.0)))))double code(double x, double y, double z) {
double tmp;
if (fabs(x) <= 1e-28) {
tmp = (fma(fabs(x), y, fabs(x)) / z) - fabs(x);
} else {
tmp = (fabs(x) / z) * ((y - z) - -1.0);
}
return copysign(1.0, x) * tmp;
}
function code(x, y, z) tmp = 0.0 if (abs(x) <= 1e-28) tmp = Float64(Float64(fma(abs(x), y, abs(x)) / z) - abs(x)); else tmp = Float64(Float64(abs(x) / z) * Float64(Float64(y - z) - -1.0)); end return Float64(copysign(1.0, x) * tmp) end
code[x_, y_, z_] := N[(N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * If[LessEqual[N[Abs[x], $MachinePrecision], 1e-28], N[(N[(N[(N[Abs[x], $MachinePrecision] * y + N[Abs[x], $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision] - N[Abs[x], $MachinePrecision]), $MachinePrecision], N[(N[(N[Abs[x], $MachinePrecision] / z), $MachinePrecision] * N[(N[(y - z), $MachinePrecision] - -1.0), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\mathsf{copysign}\left(1, x\right) \cdot \begin{array}{l}
\mathbf{if}\;\left|x\right| \leq 10^{-28}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\left|x\right|, y, \left|x\right|\right)}{z} - \left|x\right|\\
\mathbf{else}:\\
\;\;\;\;\frac{\left|x\right|}{z} \cdot \left(\left(y - z\right) - -1\right)\\
\end{array}
if x < 9.9999999999999997e-29Initial program 88.2%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6495.7%
lift-+.f64N/A
add-flipN/A
lower--.f64N/A
metadata-eval95.7%
Applied rewrites95.7%
Applied rewrites95.9%
if 9.9999999999999997e-29 < x Initial program 88.2%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6488.8%
lift-+.f64N/A
add-flipN/A
lower--.f64N/A
metadata-eval88.8%
Applied rewrites88.8%
(FPCore (x y z) :precision binary64 (let* ((t_0 (fma (/ y z) x (- x)))) (if (<= z -3.9e+15) t_0 (if (<= z 5.6e-30) (/ (fma y x x) z) t_0))))
double code(double x, double y, double z) {
double t_0 = fma((y / z), x, -x);
double tmp;
if (z <= -3.9e+15) {
tmp = t_0;
} else if (z <= 5.6e-30) {
tmp = fma(y, x, x) / z;
} else {
tmp = t_0;
}
return tmp;
}
function code(x, y, z) t_0 = fma(Float64(y / z), x, Float64(-x)) tmp = 0.0 if (z <= -3.9e+15) tmp = t_0; elseif (z <= 5.6e-30) tmp = Float64(fma(y, x, x) / z); else tmp = t_0; end return tmp end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(y / z), $MachinePrecision] * x + (-x)), $MachinePrecision]}, If[LessEqual[z, -3.9e+15], t$95$0, If[LessEqual[z, 5.6e-30], N[(N[(y * x + x), $MachinePrecision] / z), $MachinePrecision], t$95$0]]]
\begin{array}{l}
t_0 := \mathsf{fma}\left(\frac{y}{z}, x, -x\right)\\
\mathbf{if}\;z \leq -3.9 \cdot 10^{+15}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq 5.6 \cdot 10^{-30}:\\
\;\;\;\;\frac{\mathsf{fma}\left(y, x, x\right)}{z}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
if z < -3.9e15 or 5.5999999999999998e-30 < z Initial program 88.2%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6495.7%
lift-+.f64N/A
add-flipN/A
lower--.f64N/A
metadata-eval95.7%
Applied rewrites95.7%
Applied rewrites95.7%
Taylor expanded in y around inf
lower-/.f6471.2%
Applied rewrites71.2%
if -3.9e15 < z < 5.5999999999999998e-30Initial program 88.2%
lift-*.f64N/A
*-commutativeN/A
lift-+.f64N/A
distribute-lft1-inN/A
lower-fma.f6488.2%
Applied rewrites88.2%
Taylor expanded in z around 0
lower-/.f64N/A
lower-+.f64N/A
lower-*.f6461.9%
Applied rewrites61.9%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6461.9%
Applied rewrites61.9%
(FPCore (x y z) :precision binary64 (if (<= z -1.2e+26) (- x) (if (<= z 6e+81) (* (/ x z) (- y -1.0)) (- x))))
double code(double x, double y, double z) {
double tmp;
if (z <= -1.2e+26) {
tmp = -x;
} else if (z <= 6e+81) {
tmp = (x / z) * (y - -1.0);
} else {
tmp = -x;
}
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(x, y, z)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (z <= (-1.2d+26)) then
tmp = -x
else if (z <= 6d+81) then
tmp = (x / z) * (y - (-1.0d0))
else
tmp = -x
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= -1.2e+26) {
tmp = -x;
} else if (z <= 6e+81) {
tmp = (x / z) * (y - -1.0);
} else {
tmp = -x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -1.2e+26: tmp = -x elif z <= 6e+81: tmp = (x / z) * (y - -1.0) else: tmp = -x return tmp
function code(x, y, z) tmp = 0.0 if (z <= -1.2e+26) tmp = Float64(-x); elseif (z <= 6e+81) tmp = Float64(Float64(x / z) * Float64(y - -1.0)); else tmp = Float64(-x); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -1.2e+26) tmp = -x; elseif (z <= 6e+81) tmp = (x / z) * (y - -1.0); else tmp = -x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -1.2e+26], (-x), If[LessEqual[z, 6e+81], N[(N[(x / z), $MachinePrecision] * N[(y - -1.0), $MachinePrecision]), $MachinePrecision], (-x)]]
\begin{array}{l}
\mathbf{if}\;z \leq -1.2 \cdot 10^{+26}:\\
\;\;\;\;-x\\
\mathbf{elif}\;z \leq 6 \cdot 10^{+81}:\\
\;\;\;\;\frac{x}{z} \cdot \left(y - -1\right)\\
\mathbf{else}:\\
\;\;\;\;-x\\
\end{array}
if z < -1.2e26 or 5.9999999999999999e81 < z Initial program 88.2%
Taylor expanded in z around inf
lower-*.f6437.9%
Applied rewrites37.9%
lift-*.f64N/A
mul-1-negN/A
lower-neg.f6437.9%
Applied rewrites37.9%
if -1.2e26 < z < 5.9999999999999999e81Initial program 88.2%
lift-*.f64N/A
*-commutativeN/A
lift-+.f64N/A
distribute-lft1-inN/A
lower-fma.f6488.2%
Applied rewrites88.2%
Taylor expanded in z around 0
lower-/.f64N/A
lower-+.f64N/A
lower-*.f6461.9%
Applied rewrites61.9%
lift-/.f64N/A
lift-+.f64N/A
lift-*.f64N/A
*-commutativeN/A
distribute-rgt1-inN/A
metadata-evalN/A
sub-flipN/A
associate-/l*N/A
lift-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f6462.1%
Applied rewrites62.1%
(FPCore (x y z) :precision binary64 (if (<= z -6e+15) (- x) (if (<= z 6e+81) (/ (fma y x x) z) (- x))))
double code(double x, double y, double z) {
double tmp;
if (z <= -6e+15) {
tmp = -x;
} else if (z <= 6e+81) {
tmp = fma(y, x, x) / z;
} else {
tmp = -x;
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (z <= -6e+15) tmp = Float64(-x); elseif (z <= 6e+81) tmp = Float64(fma(y, x, x) / z); else tmp = Float64(-x); end return tmp end
code[x_, y_, z_] := If[LessEqual[z, -6e+15], (-x), If[LessEqual[z, 6e+81], N[(N[(y * x + x), $MachinePrecision] / z), $MachinePrecision], (-x)]]
\begin{array}{l}
\mathbf{if}\;z \leq -6 \cdot 10^{+15}:\\
\;\;\;\;-x\\
\mathbf{elif}\;z \leq 6 \cdot 10^{+81}:\\
\;\;\;\;\frac{\mathsf{fma}\left(y, x, x\right)}{z}\\
\mathbf{else}:\\
\;\;\;\;-x\\
\end{array}
if z < -6e15 or 5.9999999999999999e81 < z Initial program 88.2%
Taylor expanded in z around inf
lower-*.f6437.9%
Applied rewrites37.9%
lift-*.f64N/A
mul-1-negN/A
lower-neg.f6437.9%
Applied rewrites37.9%
if -6e15 < z < 5.9999999999999999e81Initial program 88.2%
lift-*.f64N/A
*-commutativeN/A
lift-+.f64N/A
distribute-lft1-inN/A
lower-fma.f6488.2%
Applied rewrites88.2%
Taylor expanded in z around 0
lower-/.f64N/A
lower-+.f64N/A
lower-*.f6461.9%
Applied rewrites61.9%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6461.9%
Applied rewrites61.9%
(FPCore (x y z) :precision binary64 (let* ((t_0 (/ (* x y) z))) (if (<= y -1e+36) t_0 (if (<= y 4.8e+36) (- (/ x z) x) t_0))))
double code(double x, double y, double z) {
double t_0 = (x * y) / z;
double tmp;
if (y <= -1e+36) {
tmp = t_0;
} else if (y <= 4.8e+36) {
tmp = (x / z) - x;
} else {
tmp = t_0;
}
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(x, y, z)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: t_0
real(8) :: tmp
t_0 = (x * y) / z
if (y <= (-1d+36)) then
tmp = t_0
else if (y <= 4.8d+36) then
tmp = (x / z) - x
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = (x * y) / z;
double tmp;
if (y <= -1e+36) {
tmp = t_0;
} else if (y <= 4.8e+36) {
tmp = (x / z) - x;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = (x * y) / z tmp = 0 if y <= -1e+36: tmp = t_0 elif y <= 4.8e+36: tmp = (x / z) - x else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(Float64(x * y) / z) tmp = 0.0 if (y <= -1e+36) tmp = t_0; elseif (y <= 4.8e+36) tmp = Float64(Float64(x / z) - x); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = (x * y) / z; tmp = 0.0; if (y <= -1e+36) tmp = t_0; elseif (y <= 4.8e+36) tmp = (x / z) - x; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(x * y), $MachinePrecision] / z), $MachinePrecision]}, If[LessEqual[y, -1e+36], t$95$0, If[LessEqual[y, 4.8e+36], N[(N[(x / z), $MachinePrecision] - x), $MachinePrecision], t$95$0]]]
\begin{array}{l}
t_0 := \frac{x \cdot y}{z}\\
\mathbf{if}\;y \leq -1 \cdot 10^{+36}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 4.8 \cdot 10^{+36}:\\
\;\;\;\;\frac{x}{z} - x\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
if y < -1e36 or 4.7999999999999998e36 < y Initial program 88.2%
Taylor expanded in y around inf
lower-*.f6438.1%
Applied rewrites38.1%
if -1e36 < y < 4.7999999999999998e36Initial program 88.2%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6495.7%
lift-+.f64N/A
add-flipN/A
lower--.f64N/A
metadata-eval95.7%
Applied rewrites95.7%
Applied rewrites95.7%
Taylor expanded in y around 0
lower--.f64N/A
lower-/.f6465.6%
Applied rewrites65.6%
(FPCore (x y z) :precision binary64 (let* ((t_0 (* (/ y z) x))) (if (<= y -1e+36) t_0 (if (<= y 4.8e+36) (- (/ x z) x) t_0))))
double code(double x, double y, double z) {
double t_0 = (y / z) * x;
double tmp;
if (y <= -1e+36) {
tmp = t_0;
} else if (y <= 4.8e+36) {
tmp = (x / z) - x;
} else {
tmp = t_0;
}
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(x, y, z)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: t_0
real(8) :: tmp
t_0 = (y / z) * x
if (y <= (-1d+36)) then
tmp = t_0
else if (y <= 4.8d+36) then
tmp = (x / z) - x
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = (y / z) * x;
double tmp;
if (y <= -1e+36) {
tmp = t_0;
} else if (y <= 4.8e+36) {
tmp = (x / z) - x;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = (y / z) * x tmp = 0 if y <= -1e+36: tmp = t_0 elif y <= 4.8e+36: tmp = (x / z) - x else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(Float64(y / z) * x) tmp = 0.0 if (y <= -1e+36) tmp = t_0; elseif (y <= 4.8e+36) tmp = Float64(Float64(x / z) - x); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = (y / z) * x; tmp = 0.0; if (y <= -1e+36) tmp = t_0; elseif (y <= 4.8e+36) tmp = (x / z) - x; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(y / z), $MachinePrecision] * x), $MachinePrecision]}, If[LessEqual[y, -1e+36], t$95$0, If[LessEqual[y, 4.8e+36], N[(N[(x / z), $MachinePrecision] - x), $MachinePrecision], t$95$0]]]
\begin{array}{l}
t_0 := \frac{y}{z} \cdot x\\
\mathbf{if}\;y \leq -1 \cdot 10^{+36}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 4.8 \cdot 10^{+36}:\\
\;\;\;\;\frac{x}{z} - x\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
if y < -1e36 or 4.7999999999999998e36 < y Initial program 88.2%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6495.7%
lift-+.f64N/A
add-flipN/A
lower--.f64N/A
metadata-eval95.7%
Applied rewrites95.7%
Taylor expanded in y around inf
lower-/.f6436.0%
Applied rewrites36.0%
if -1e36 < y < 4.7999999999999998e36Initial program 88.2%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6495.7%
lift-+.f64N/A
add-flipN/A
lower--.f64N/A
metadata-eval95.7%
Applied rewrites95.7%
Applied rewrites95.7%
Taylor expanded in y around 0
lower--.f64N/A
lower-/.f6465.6%
Applied rewrites65.6%
(FPCore (x y z) :precision binary64 (- (/ x z) x))
double code(double x, double y, double z) {
return (x / z) - x;
}
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(x, y, z)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (x / z) - x
end function
public static double code(double x, double y, double z) {
return (x / z) - x;
}
def code(x, y, z): return (x / z) - x
function code(x, y, z) return Float64(Float64(x / z) - x) end
function tmp = code(x, y, z) tmp = (x / z) - x; end
code[x_, y_, z_] := N[(N[(x / z), $MachinePrecision] - x), $MachinePrecision]
\frac{x}{z} - x
Initial program 88.2%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6495.7%
lift-+.f64N/A
add-flipN/A
lower--.f64N/A
metadata-eval95.7%
Applied rewrites95.7%
Applied rewrites95.7%
Taylor expanded in y around 0
lower--.f64N/A
lower-/.f6465.6%
Applied rewrites65.6%
(FPCore (x y z) :precision binary64 (- x))
double code(double x, double y, double z) {
return -x;
}
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(x, y, z)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = -x
end function
public static double code(double x, double y, double z) {
return -x;
}
def code(x, y, z): return -x
function code(x, y, z) return Float64(-x) end
function tmp = code(x, y, z) tmp = -x; end
code[x_, y_, z_] := (-x)
-x
Initial program 88.2%
Taylor expanded in z around inf
lower-*.f6437.9%
Applied rewrites37.9%
lift-*.f64N/A
mul-1-negN/A
lower-neg.f6437.9%
Applied rewrites37.9%
herbie shell --seed 2025191
(FPCore (x y z)
:name "Diagrams.TwoD.Segment.Bernstein:evaluateBernstein from diagrams-lib-1.3.0.3"
:precision binary64
(/ (* x (+ (- y z) 1.0)) z))