
(FPCore (x y z) :precision binary64 (/ (+ x (* y (- z x))) z))
double code(double x, double y, double z) {
return (x + (y * (z - x))) / 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 - x))) / z
end function
public static double code(double x, double y, double z) {
return (x + (y * (z - x))) / z;
}
def code(x, y, z): return (x + (y * (z - x))) / z
function code(x, y, z) return Float64(Float64(x + Float64(y * Float64(z - x))) / z) end
function tmp = code(x, y, z) tmp = (x + (y * (z - x))) / z; end
code[x_, y_, z_] := N[(N[(x + N[(y * N[(z - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]
\frac{x + y \cdot \left(z - x\right)}{z}
Herbie found 10 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z) :precision binary64 (/ (+ x (* y (- z x))) z))
double code(double x, double y, double z) {
return (x + (y * (z - x))) / 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 - x))) / z
end function
public static double code(double x, double y, double z) {
return (x + (y * (z - x))) / z;
}
def code(x, y, z): return (x + (y * (z - x))) / z
function code(x, y, z) return Float64(Float64(x + Float64(y * Float64(z - x))) / z) end
function tmp = code(x, y, z) tmp = (x + (y * (z - x))) / z; end
code[x_, y_, z_] := N[(N[(x + N[(y * N[(z - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]
\frac{x + y \cdot \left(z - x\right)}{z}
(FPCore (x y z) :precision binary64 (fma (/ x z) (- 1.0 y) y))
double code(double x, double y, double z) {
return fma((x / z), (1.0 - y), y);
}
function code(x, y, z) return fma(Float64(x / z), Float64(1.0 - y), y) end
code[x_, y_, z_] := N[(N[(x / z), $MachinePrecision] * N[(1.0 - y), $MachinePrecision] + y), $MachinePrecision]
\mathsf{fma}\left(\frac{x}{z}, 1 - y, y\right)
Initial program 87.9%
lift-/.f64N/A
mult-flipN/A
associate-*r/N/A
*-rgt-identityN/A
lift-+.f64N/A
+-commutativeN/A
add-flipN/A
lift-*.f64N/A
lift--.f64N/A
sub-flipN/A
distribute-lft-inN/A
associate--l+N/A
add-to-fraction-revN/A
lower-+.f64N/A
lower-/.f64N/A
add-flip-revN/A
*-commutativeN/A
*-commutativeN/A
distribute-rgt-neg-outN/A
distribute-lft-neg-outN/A
lower-fma.f64N/A
lower-neg.f6496.0%
Applied rewrites96.0%
lift-+.f64N/A
+-commutativeN/A
remove-double-negN/A
lift-neg.f64N/A
lift-/.f64N/A
lift-fma.f64N/A
distribute-lft1-inN/A
associate-/l*N/A
*-commutativeN/A
lift-neg.f64N/A
remove-double-negN/A
lower-fma.f64N/A
lower-/.f64N/A
+-commutativeN/A
lift-neg.f64N/A
sub-flipN/A
lower--.f6499.9%
Applied rewrites99.9%
(FPCore (x y z) :precision binary64 (let* ((t_0 (* (/ (- z x) z) y))) (if (<= y -5e+27) t_0 (if (<= y 5e+25) (/ (fma (- z x) y x) z) t_0))))
double code(double x, double y, double z) {
double t_0 = ((z - x) / z) * y;
double tmp;
if (y <= -5e+27) {
tmp = t_0;
} else if (y <= 5e+25) {
tmp = fma((z - x), y, x) / z;
} else {
tmp = t_0;
}
return tmp;
}
function code(x, y, z) t_0 = Float64(Float64(Float64(z - x) / z) * y) tmp = 0.0 if (y <= -5e+27) tmp = t_0; elseif (y <= 5e+25) tmp = Float64(fma(Float64(z - x), y, x) / z); else tmp = t_0; end return tmp end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(N[(z - x), $MachinePrecision] / z), $MachinePrecision] * y), $MachinePrecision]}, If[LessEqual[y, -5e+27], t$95$0, If[LessEqual[y, 5e+25], N[(N[(N[(z - x), $MachinePrecision] * y + x), $MachinePrecision] / z), $MachinePrecision], t$95$0]]]
\begin{array}{l}
t_0 := \frac{z - x}{z} \cdot y\\
\mathbf{if}\;y \leq -5 \cdot 10^{+27}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 5 \cdot 10^{+25}:\\
\;\;\;\;\frac{\mathsf{fma}\left(z - x, y, x\right)}{z}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
if y < -4.99999999999999979e27 or 5.00000000000000024e25 < y Initial program 87.9%
Taylor expanded in y around inf
lower-/.f64N/A
lower-*.f64N/A
lower--.f6454.5%
Applied rewrites54.5%
lift-/.f64N/A
lift--.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
lift--.f6468.6%
Applied rewrites68.6%
if -4.99999999999999979e27 < y < 5.00000000000000024e25Initial program 87.9%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6488.0%
Applied rewrites88.0%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* (/ (- z x) z) y)))
(if (<= y -1400000000000.0)
t_0
(if (<= y 110000000.0) (fma (/ x z) 1.0 y) t_0))))double code(double x, double y, double z) {
double t_0 = ((z - x) / z) * y;
double tmp;
if (y <= -1400000000000.0) {
tmp = t_0;
} else if (y <= 110000000.0) {
tmp = fma((x / z), 1.0, y);
} else {
tmp = t_0;
}
return tmp;
}
function code(x, y, z) t_0 = Float64(Float64(Float64(z - x) / z) * y) tmp = 0.0 if (y <= -1400000000000.0) tmp = t_0; elseif (y <= 110000000.0) tmp = fma(Float64(x / z), 1.0, y); else tmp = t_0; end return tmp end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(N[(z - x), $MachinePrecision] / z), $MachinePrecision] * y), $MachinePrecision]}, If[LessEqual[y, -1400000000000.0], t$95$0, If[LessEqual[y, 110000000.0], N[(N[(x / z), $MachinePrecision] * 1.0 + y), $MachinePrecision], t$95$0]]]
\begin{array}{l}
t_0 := \frac{z - x}{z} \cdot y\\
\mathbf{if}\;y \leq -1400000000000:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 110000000:\\
\;\;\;\;\mathsf{fma}\left(\frac{x}{z}, 1, y\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
if y < -1.4e12 or 1.1e8 < y Initial program 87.9%
Taylor expanded in y around inf
lower-/.f64N/A
lower-*.f64N/A
lower--.f6454.5%
Applied rewrites54.5%
lift-/.f64N/A
lift--.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
lift--.f6468.6%
Applied rewrites68.6%
if -1.4e12 < y < 1.1e8Initial program 87.9%
lift-/.f64N/A
mult-flipN/A
associate-*r/N/A
*-rgt-identityN/A
lift-+.f64N/A
+-commutativeN/A
add-flipN/A
lift-*.f64N/A
lift--.f64N/A
sub-flipN/A
distribute-lft-inN/A
associate--l+N/A
add-to-fraction-revN/A
lower-+.f64N/A
lower-/.f64N/A
add-flip-revN/A
*-commutativeN/A
*-commutativeN/A
distribute-rgt-neg-outN/A
distribute-lft-neg-outN/A
lower-fma.f64N/A
lower-neg.f6496.0%
Applied rewrites96.0%
lift-+.f64N/A
+-commutativeN/A
remove-double-negN/A
lift-neg.f64N/A
lift-/.f64N/A
lift-fma.f64N/A
distribute-lft1-inN/A
associate-/l*N/A
*-commutativeN/A
lift-neg.f64N/A
remove-double-negN/A
lower-fma.f64N/A
lower-/.f64N/A
+-commutativeN/A
lift-neg.f64N/A
sub-flipN/A
lower--.f6499.9%
Applied rewrites99.9%
Taylor expanded in y around 0
Applied rewrites77.9%
(FPCore (x y z) :precision binary64 (if (<= y -2.4e+122) (* (/ (- z x) z) y) (fma x (/ (- 1.0 y) z) y)))
double code(double x, double y, double z) {
double tmp;
if (y <= -2.4e+122) {
tmp = ((z - x) / z) * y;
} else {
tmp = fma(x, ((1.0 - y) / z), y);
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (y <= -2.4e+122) tmp = Float64(Float64(Float64(z - x) / z) * y); else tmp = fma(x, Float64(Float64(1.0 - y) / z), y); end return tmp end
code[x_, y_, z_] := If[LessEqual[y, -2.4e+122], N[(N[(N[(z - x), $MachinePrecision] / z), $MachinePrecision] * y), $MachinePrecision], N[(x * N[(N[(1.0 - y), $MachinePrecision] / z), $MachinePrecision] + y), $MachinePrecision]]
\begin{array}{l}
\mathbf{if}\;y \leq -2.4 \cdot 10^{+122}:\\
\;\;\;\;\frac{z - x}{z} \cdot y\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(x, \frac{1 - y}{z}, y\right)\\
\end{array}
if y < -2.4000000000000002e122Initial program 87.9%
Taylor expanded in y around inf
lower-/.f64N/A
lower-*.f64N/A
lower--.f6454.5%
Applied rewrites54.5%
lift-/.f64N/A
lift--.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
lift--.f6468.6%
Applied rewrites68.6%
if -2.4000000000000002e122 < y Initial program 87.9%
lift-/.f64N/A
mult-flipN/A
associate-*r/N/A
*-rgt-identityN/A
lift-+.f64N/A
+-commutativeN/A
add-flipN/A
lift-*.f64N/A
lift--.f64N/A
sub-flipN/A
distribute-lft-inN/A
associate--l+N/A
add-to-fraction-revN/A
lower-+.f64N/A
lower-/.f64N/A
add-flip-revN/A
*-commutativeN/A
*-commutativeN/A
distribute-rgt-neg-outN/A
distribute-lft-neg-outN/A
lower-fma.f64N/A
lower-neg.f6496.0%
Applied rewrites96.0%
lift-+.f64N/A
+-commutativeN/A
lift-/.f64N/A
lift-fma.f64N/A
distribute-lft1-inN/A
*-commutativeN/A
associate-/l*N/A
frac-2neg-revN/A
+-commutativeN/A
lift-neg.f64N/A
sub-flipN/A
sub-negate-revN/A
lift--.f64N/A
lower-fma.f64N/A
Applied rewrites95.9%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* (/ y z) (- z x))))
(if (<= y -1400000000000.0)
t_0
(if (<= y 110000000.0) (fma (/ x z) 1.0 y) t_0))))double code(double x, double y, double z) {
double t_0 = (y / z) * (z - x);
double tmp;
if (y <= -1400000000000.0) {
tmp = t_0;
} else if (y <= 110000000.0) {
tmp = fma((x / z), 1.0, y);
} else {
tmp = t_0;
}
return tmp;
}
function code(x, y, z) t_0 = Float64(Float64(y / z) * Float64(z - x)) tmp = 0.0 if (y <= -1400000000000.0) tmp = t_0; elseif (y <= 110000000.0) tmp = fma(Float64(x / z), 1.0, y); else tmp = t_0; end return tmp end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(y / z), $MachinePrecision] * N[(z - x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -1400000000000.0], t$95$0, If[LessEqual[y, 110000000.0], N[(N[(x / z), $MachinePrecision] * 1.0 + y), $MachinePrecision], t$95$0]]]
\begin{array}{l}
t_0 := \frac{y}{z} \cdot \left(z - x\right)\\
\mathbf{if}\;y \leq -1400000000000:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 110000000:\\
\;\;\;\;\mathsf{fma}\left(\frac{x}{z}, 1, y\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
if y < -1.4e12 or 1.1e8 < y Initial program 87.9%
Taylor expanded in y around inf
lower-/.f64N/A
lower-*.f64N/A
lower--.f6454.5%
Applied rewrites54.5%
lift-/.f64N/A
lift--.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
lift--.f6457.0%
Applied rewrites57.0%
if -1.4e12 < y < 1.1e8Initial program 87.9%
lift-/.f64N/A
mult-flipN/A
associate-*r/N/A
*-rgt-identityN/A
lift-+.f64N/A
+-commutativeN/A
add-flipN/A
lift-*.f64N/A
lift--.f64N/A
sub-flipN/A
distribute-lft-inN/A
associate--l+N/A
add-to-fraction-revN/A
lower-+.f64N/A
lower-/.f64N/A
add-flip-revN/A
*-commutativeN/A
*-commutativeN/A
distribute-rgt-neg-outN/A
distribute-lft-neg-outN/A
lower-fma.f64N/A
lower-neg.f6496.0%
Applied rewrites96.0%
lift-+.f64N/A
+-commutativeN/A
remove-double-negN/A
lift-neg.f64N/A
lift-/.f64N/A
lift-fma.f64N/A
distribute-lft1-inN/A
associate-/l*N/A
*-commutativeN/A
lift-neg.f64N/A
remove-double-negN/A
lower-fma.f64N/A
lower-/.f64N/A
+-commutativeN/A
lift-neg.f64N/A
sub-flipN/A
lower--.f6499.9%
Applied rewrites99.9%
Taylor expanded in y around 0
Applied rewrites77.9%
(FPCore (x y z) :precision binary64 (if (<= y 1.5e+25) (fma (/ x z) 1.0 y) (* (/ y z) z)))
double code(double x, double y, double z) {
double tmp;
if (y <= 1.5e+25) {
tmp = fma((x / z), 1.0, y);
} else {
tmp = (y / z) * z;
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (y <= 1.5e+25) tmp = fma(Float64(x / z), 1.0, y); else tmp = Float64(Float64(y / z) * z); end return tmp end
code[x_, y_, z_] := If[LessEqual[y, 1.5e+25], N[(N[(x / z), $MachinePrecision] * 1.0 + y), $MachinePrecision], N[(N[(y / z), $MachinePrecision] * z), $MachinePrecision]]
\begin{array}{l}
\mathbf{if}\;y \leq 1.5 \cdot 10^{+25}:\\
\;\;\;\;\mathsf{fma}\left(\frac{x}{z}, 1, y\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{z} \cdot z\\
\end{array}
if y < 1.50000000000000003e25Initial program 87.9%
lift-/.f64N/A
mult-flipN/A
associate-*r/N/A
*-rgt-identityN/A
lift-+.f64N/A
+-commutativeN/A
add-flipN/A
lift-*.f64N/A
lift--.f64N/A
sub-flipN/A
distribute-lft-inN/A
associate--l+N/A
add-to-fraction-revN/A
lower-+.f64N/A
lower-/.f64N/A
add-flip-revN/A
*-commutativeN/A
*-commutativeN/A
distribute-rgt-neg-outN/A
distribute-lft-neg-outN/A
lower-fma.f64N/A
lower-neg.f6496.0%
Applied rewrites96.0%
lift-+.f64N/A
+-commutativeN/A
remove-double-negN/A
lift-neg.f64N/A
lift-/.f64N/A
lift-fma.f64N/A
distribute-lft1-inN/A
associate-/l*N/A
*-commutativeN/A
lift-neg.f64N/A
remove-double-negN/A
lower-fma.f64N/A
lower-/.f64N/A
+-commutativeN/A
lift-neg.f64N/A
sub-flipN/A
lower--.f6499.9%
Applied rewrites99.9%
Taylor expanded in y around 0
Applied rewrites77.9%
if 1.50000000000000003e25 < y Initial program 87.9%
Taylor expanded in y around inf
lower-/.f64N/A
lower-*.f64N/A
lower--.f6454.5%
Applied rewrites54.5%
lift-/.f64N/A
lift--.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
lift--.f6457.0%
Applied rewrites57.0%
Taylor expanded in x around 0
Applied rewrites37.4%
(FPCore (x y z) :precision binary64 (let* ((t_0 (* (/ y z) z))) (if (<= y -1.75e+164) t_0 (if (<= y 1.5e+25) (/ (fma z y x) z) t_0))))
double code(double x, double y, double z) {
double t_0 = (y / z) * z;
double tmp;
if (y <= -1.75e+164) {
tmp = t_0;
} else if (y <= 1.5e+25) {
tmp = fma(z, y, x) / z;
} else {
tmp = t_0;
}
return tmp;
}
function code(x, y, z) t_0 = Float64(Float64(y / z) * z) tmp = 0.0 if (y <= -1.75e+164) tmp = t_0; elseif (y <= 1.5e+25) tmp = Float64(fma(z, y, x) / z); else tmp = t_0; end return tmp end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(y / z), $MachinePrecision] * z), $MachinePrecision]}, If[LessEqual[y, -1.75e+164], t$95$0, If[LessEqual[y, 1.5e+25], N[(N[(z * y + x), $MachinePrecision] / z), $MachinePrecision], t$95$0]]]
\begin{array}{l}
t_0 := \frac{y}{z} \cdot z\\
\mathbf{if}\;y \leq -1.75 \cdot 10^{+164}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 1.5 \cdot 10^{+25}:\\
\;\;\;\;\frac{\mathsf{fma}\left(z, y, x\right)}{z}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
if y < -1.7499999999999999e164 or 1.50000000000000003e25 < y Initial program 87.9%
Taylor expanded in y around inf
lower-/.f64N/A
lower-*.f64N/A
lower--.f6454.5%
Applied rewrites54.5%
lift-/.f64N/A
lift--.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
lift--.f6457.0%
Applied rewrites57.0%
Taylor expanded in x around 0
Applied rewrites37.4%
if -1.7499999999999999e164 < y < 1.50000000000000003e25Initial program 87.9%
Taylor expanded in x around 0
Applied rewrites68.3%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6468.3%
Applied rewrites68.3%
(FPCore (x y z) :precision binary64 (let* ((t_0 (* (/ y z) z))) (if (<= y -1.25e-111) t_0 (if (<= y 110000000.0) (/ x z) t_0))))
double code(double x, double y, double z) {
double t_0 = (y / z) * z;
double tmp;
if (y <= -1.25e-111) {
tmp = t_0;
} else if (y <= 110000000.0) {
tmp = x / z;
} 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) * z
if (y <= (-1.25d-111)) then
tmp = t_0
else if (y <= 110000000.0d0) then
tmp = x / z
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) * z;
double tmp;
if (y <= -1.25e-111) {
tmp = t_0;
} else if (y <= 110000000.0) {
tmp = x / z;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = (y / z) * z tmp = 0 if y <= -1.25e-111: tmp = t_0 elif y <= 110000000.0: tmp = x / z else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(Float64(y / z) * z) tmp = 0.0 if (y <= -1.25e-111) tmp = t_0; elseif (y <= 110000000.0) tmp = Float64(x / z); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = (y / z) * z; tmp = 0.0; if (y <= -1.25e-111) tmp = t_0; elseif (y <= 110000000.0) tmp = x / z; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(y / z), $MachinePrecision] * z), $MachinePrecision]}, If[LessEqual[y, -1.25e-111], t$95$0, If[LessEqual[y, 110000000.0], N[(x / z), $MachinePrecision], t$95$0]]]
\begin{array}{l}
t_0 := \frac{y}{z} \cdot z\\
\mathbf{if}\;y \leq -1.25 \cdot 10^{-111}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 110000000:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
if y < -1.2500000000000001e-111 or 1.1e8 < y Initial program 87.9%
Taylor expanded in y around inf
lower-/.f64N/A
lower-*.f64N/A
lower--.f6454.5%
Applied rewrites54.5%
lift-/.f64N/A
lift--.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
lift--.f6457.0%
Applied rewrites57.0%
Taylor expanded in x around 0
Applied rewrites37.4%
if -1.2500000000000001e-111 < y < 1.1e8Initial program 87.9%
Taylor expanded in y around 0
lower-/.f6439.4%
Applied rewrites39.4%
(FPCore (x y z) :precision binary64 (if (<= y -1.25e-111) y (if (<= y 110000000.0) (/ x z) y)))
double code(double x, double y, double z) {
double tmp;
if (y <= -1.25e-111) {
tmp = y;
} else if (y <= 110000000.0) {
tmp = x / z;
} else {
tmp = y;
}
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 (y <= (-1.25d-111)) then
tmp = y
else if (y <= 110000000.0d0) then
tmp = x / z
else
tmp = y
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -1.25e-111) {
tmp = y;
} else if (y <= 110000000.0) {
tmp = x / z;
} else {
tmp = y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -1.25e-111: tmp = y elif y <= 110000000.0: tmp = x / z else: tmp = y return tmp
function code(x, y, z) tmp = 0.0 if (y <= -1.25e-111) tmp = y; elseif (y <= 110000000.0) tmp = Float64(x / z); else tmp = y; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -1.25e-111) tmp = y; elseif (y <= 110000000.0) tmp = x / z; else tmp = y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -1.25e-111], y, If[LessEqual[y, 110000000.0], N[(x / z), $MachinePrecision], y]]
\begin{array}{l}
\mathbf{if}\;y \leq -1.25 \cdot 10^{-111}:\\
\;\;\;\;y\\
\mathbf{elif}\;y \leq 110000000:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;y\\
\end{array}
if y < -1.2500000000000001e-111 or 1.1e8 < y Initial program 87.9%
Taylor expanded in x around 0
Applied rewrites41.0%
if -1.2500000000000001e-111 < y < 1.1e8Initial program 87.9%
Taylor expanded in y around 0
lower-/.f6439.4%
Applied rewrites39.4%
(FPCore (x y z) :precision binary64 y)
double code(double x, double y, double z) {
return y;
}
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 = y
end function
public static double code(double x, double y, double z) {
return y;
}
def code(x, y, z): return y
function code(x, y, z) return y end
function tmp = code(x, y, z) tmp = y; end
code[x_, y_, z_] := y
y
Initial program 87.9%
Taylor expanded in x around 0
Applied rewrites41.0%
herbie shell --seed 2025183
(FPCore (x y z)
:name "Diagrams.Backend.Rasterific:rasterificRadialGradient from diagrams-rasterific-1.3.1.3"
:precision binary64
(/ (+ x (* y (- z x))) z))