
(FPCore (x y z) :precision binary64 (/ (* x (- y z)) y))
double code(double x, double y, double z) {
return (x * (y - z)) / 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 = (x * (y - z)) / y
end function
public static double code(double x, double y, double z) {
return (x * (y - z)) / y;
}
def code(x, y, z): return (x * (y - z)) / y
function code(x, y, z) return Float64(Float64(x * Float64(y - z)) / y) end
function tmp = code(x, y, z) tmp = (x * (y - z)) / y; end
code[x_, y_, z_] := N[(N[(x * N[(y - z), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]
\begin{array}{l}
\\
\frac{x \cdot \left(y - z\right)}{y}
\end{array}
Herbie found 6 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z) :precision binary64 (/ (* x (- y z)) y))
double code(double x, double y, double z) {
return (x * (y - z)) / 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 = (x * (y - z)) / y
end function
public static double code(double x, double y, double z) {
return (x * (y - z)) / y;
}
def code(x, y, z): return (x * (y - z)) / y
function code(x, y, z) return Float64(Float64(x * Float64(y - z)) / y) end
function tmp = code(x, y, z) tmp = (x * (y - z)) / y; end
code[x_, y_, z_] := N[(N[(x * N[(y - z), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]
\begin{array}{l}
\\
\frac{x \cdot \left(y - z\right)}{y}
\end{array}
(FPCore (x y z) :precision binary64 (if (<= z -2.4e+67) (fma (/ (- x) y) z x) (fma (- x) (/ z y) x)))
double code(double x, double y, double z) {
double tmp;
if (z <= -2.4e+67) {
tmp = fma((-x / y), z, x);
} else {
tmp = fma(-x, (z / y), x);
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (z <= -2.4e+67) tmp = fma(Float64(Float64(-x) / y), z, x); else tmp = fma(Float64(-x), Float64(z / y), x); end return tmp end
code[x_, y_, z_] := If[LessEqual[z, -2.4e+67], N[(N[((-x) / y), $MachinePrecision] * z + x), $MachinePrecision], N[((-x) * N[(z / y), $MachinePrecision] + x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -2.4 \cdot 10^{+67}:\\
\;\;\;\;\mathsf{fma}\left(\frac{-x}{y}, z, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(-x, \frac{z}{y}, x\right)\\
\end{array}
\end{array}
if z < -2.40000000000000002e67Initial program 87.9%
Taylor expanded in y around inf
+-commutativeN/A
associate-/l*N/A
associate-*r*N/A
lower-fma.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower-/.f6491.4
Applied rewrites91.4%
lift-neg.f64N/A
mul-1-negN/A
lift-/.f64N/A
lower-fma.f64N/A
associate-*r/N/A
associate-*l/N/A
associate-*r/N/A
lower-fma.f64N/A
mul-1-negN/A
distribute-frac-negN/A
lift-/.f64N/A
lift-neg.f6494.2
Applied rewrites94.2%
if -2.40000000000000002e67 < z Initial program 83.5%
Taylor expanded in y around inf
+-commutativeN/A
associate-/l*N/A
associate-*r*N/A
lower-fma.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower-/.f6497.4
Applied rewrites97.4%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (/ (* x (- y z)) y)) (t_1 (/ (* x (- z)) y)))
(if (<= t_0 -2e-226)
t_1
(if (<= t_0 5e+178) x (if (<= t_0 5e+245) t_1 (* y (/ x y)))))))
double code(double x, double y, double z) {
double t_0 = (x * (y - z)) / y;
double t_1 = (x * -z) / y;
double tmp;
if (t_0 <= -2e-226) {
tmp = t_1;
} else if (t_0 <= 5e+178) {
tmp = x;
} else if (t_0 <= 5e+245) {
tmp = t_1;
} else {
tmp = y * (x / 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) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = (x * (y - z)) / y
t_1 = (x * -z) / y
if (t_0 <= (-2d-226)) then
tmp = t_1
else if (t_0 <= 5d+178) then
tmp = x
else if (t_0 <= 5d+245) then
tmp = t_1
else
tmp = y * (x / y)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = (x * (y - z)) / y;
double t_1 = (x * -z) / y;
double tmp;
if (t_0 <= -2e-226) {
tmp = t_1;
} else if (t_0 <= 5e+178) {
tmp = x;
} else if (t_0 <= 5e+245) {
tmp = t_1;
} else {
tmp = y * (x / y);
}
return tmp;
}
def code(x, y, z): t_0 = (x * (y - z)) / y t_1 = (x * -z) / y tmp = 0 if t_0 <= -2e-226: tmp = t_1 elif t_0 <= 5e+178: tmp = x elif t_0 <= 5e+245: tmp = t_1 else: tmp = y * (x / y) return tmp
function code(x, y, z) t_0 = Float64(Float64(x * Float64(y - z)) / y) t_1 = Float64(Float64(x * Float64(-z)) / y) tmp = 0.0 if (t_0 <= -2e-226) tmp = t_1; elseif (t_0 <= 5e+178) tmp = x; elseif (t_0 <= 5e+245) tmp = t_1; else tmp = Float64(y * Float64(x / y)); end return tmp end
function tmp_2 = code(x, y, z) t_0 = (x * (y - z)) / y; t_1 = (x * -z) / y; tmp = 0.0; if (t_0 <= -2e-226) tmp = t_1; elseif (t_0 <= 5e+178) tmp = x; elseif (t_0 <= 5e+245) tmp = t_1; else tmp = y * (x / y); end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(x * N[(y - z), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]}, Block[{t$95$1 = N[(N[(x * (-z)), $MachinePrecision] / y), $MachinePrecision]}, If[LessEqual[t$95$0, -2e-226], t$95$1, If[LessEqual[t$95$0, 5e+178], x, If[LessEqual[t$95$0, 5e+245], t$95$1, N[(y * N[(x / y), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x \cdot \left(y - z\right)}{y}\\
t_1 := \frac{x \cdot \left(-z\right)}{y}\\
\mathbf{if}\;t\_0 \leq -2 \cdot 10^{-226}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_0 \leq 5 \cdot 10^{+178}:\\
\;\;\;\;x\\
\mathbf{elif}\;t\_0 \leq 5 \cdot 10^{+245}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;y \cdot \frac{x}{y}\\
\end{array}
\end{array}
if (/.f64 (*.f64 x (-.f64 y z)) y) < -1.99999999999999984e-226 or 4.9999999999999999e178 < (/.f64 (*.f64 x (-.f64 y z)) y) < 5.00000000000000034e245Initial program 87.4%
Taylor expanded in y around 0
mul-1-negN/A
lower-neg.f6452.9
Applied rewrites52.9%
if -1.99999999999999984e-226 < (/.f64 (*.f64 x (-.f64 y z)) y) < 4.9999999999999999e178Initial program 89.7%
Taylor expanded in y around inf
Applied rewrites60.8%
if 5.00000000000000034e245 < (/.f64 (*.f64 x (-.f64 y z)) y) Initial program 65.9%
Taylor expanded in y around inf
Applied rewrites9.7%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6443.7
Applied rewrites43.7%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (/ (* x (- y z)) y)))
(if (<= t_0 -2e-226)
(* (/ (- x) y) z)
(if (<= t_0 5e+298) x (* y (/ x y))))))
double code(double x, double y, double z) {
double t_0 = (x * (y - z)) / y;
double tmp;
if (t_0 <= -2e-226) {
tmp = (-x / y) * z;
} else if (t_0 <= 5e+298) {
tmp = x;
} else {
tmp = y * (x / 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) :: t_0
real(8) :: tmp
t_0 = (x * (y - z)) / y
if (t_0 <= (-2d-226)) then
tmp = (-x / y) * z
else if (t_0 <= 5d+298) then
tmp = x
else
tmp = y * (x / y)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = (x * (y - z)) / y;
double tmp;
if (t_0 <= -2e-226) {
tmp = (-x / y) * z;
} else if (t_0 <= 5e+298) {
tmp = x;
} else {
tmp = y * (x / y);
}
return tmp;
}
def code(x, y, z): t_0 = (x * (y - z)) / y tmp = 0 if t_0 <= -2e-226: tmp = (-x / y) * z elif t_0 <= 5e+298: tmp = x else: tmp = y * (x / y) return tmp
function code(x, y, z) t_0 = Float64(Float64(x * Float64(y - z)) / y) tmp = 0.0 if (t_0 <= -2e-226) tmp = Float64(Float64(Float64(-x) / y) * z); elseif (t_0 <= 5e+298) tmp = x; else tmp = Float64(y * Float64(x / y)); end return tmp end
function tmp_2 = code(x, y, z) t_0 = (x * (y - z)) / y; tmp = 0.0; if (t_0 <= -2e-226) tmp = (-x / y) * z; elseif (t_0 <= 5e+298) tmp = x; else tmp = y * (x / y); end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(x * N[(y - z), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]}, If[LessEqual[t$95$0, -2e-226], N[(N[((-x) / y), $MachinePrecision] * z), $MachinePrecision], If[LessEqual[t$95$0, 5e+298], x, N[(y * N[(x / y), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x \cdot \left(y - z\right)}{y}\\
\mathbf{if}\;t\_0 \leq -2 \cdot 10^{-226}:\\
\;\;\;\;\frac{-x}{y} \cdot z\\
\mathbf{elif}\;t\_0 \leq 5 \cdot 10^{+298}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;y \cdot \frac{x}{y}\\
\end{array}
\end{array}
if (/.f64 (*.f64 x (-.f64 y z)) y) < -1.99999999999999984e-226Initial program 86.5%
Taylor expanded in y around 0
associate-*r/N/A
associate-*r*N/A
associate-*l/N/A
associate-*r/N/A
lower-*.f64N/A
associate-*r/N/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f6450.7
Applied rewrites50.7%
if -1.99999999999999984e-226 < (/.f64 (*.f64 x (-.f64 y z)) y) < 5.0000000000000003e298Initial program 91.1%
Taylor expanded in y around inf
Applied rewrites57.2%
if 5.0000000000000003e298 < (/.f64 (*.f64 x (-.f64 y z)) y) Initial program 60.6%
Taylor expanded in y around inf
Applied rewrites6.2%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6448.3
Applied rewrites48.3%
(FPCore (x y z) :precision binary64 (if (<= (/ (* x (- y z)) y) -5.0) (* (/ (- x) y) z) (fma (- x) (/ z y) x)))
double code(double x, double y, double z) {
double tmp;
if (((x * (y - z)) / y) <= -5.0) {
tmp = (-x / y) * z;
} else {
tmp = fma(-x, (z / y), x);
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (Float64(Float64(x * Float64(y - z)) / y) <= -5.0) tmp = Float64(Float64(Float64(-x) / y) * z); else tmp = fma(Float64(-x), Float64(z / y), x); end return tmp end
code[x_, y_, z_] := If[LessEqual[N[(N[(x * N[(y - z), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision], -5.0], N[(N[((-x) / y), $MachinePrecision] * z), $MachinePrecision], N[((-x) * N[(z / y), $MachinePrecision] + x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{x \cdot \left(y - z\right)}{y} \leq -5:\\
\;\;\;\;\frac{-x}{y} \cdot z\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(-x, \frac{z}{y}, x\right)\\
\end{array}
\end{array}
if (/.f64 (*.f64 x (-.f64 y z)) y) < -5Initial program 81.5%
Taylor expanded in y around 0
associate-*r/N/A
associate-*r*N/A
associate-*l/N/A
associate-*r/N/A
lower-*.f64N/A
associate-*r/N/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f6459.6
Applied rewrites59.6%
if -5 < (/.f64 (*.f64 x (-.f64 y z)) y) Initial program 85.8%
Taylor expanded in y around inf
+-commutativeN/A
associate-/l*N/A
associate-*r*N/A
lower-fma.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower-/.f6497.3
Applied rewrites97.3%
(FPCore (x y z) :precision binary64 (if (<= (/ (* x (- y z)) y) 5e+298) x (* y (/ x y))))
double code(double x, double y, double z) {
double tmp;
if (((x * (y - z)) / y) <= 5e+298) {
tmp = x;
} else {
tmp = y * (x / 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 (((x * (y - z)) / y) <= 5d+298) then
tmp = x
else
tmp = y * (x / y)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (((x * (y - z)) / y) <= 5e+298) {
tmp = x;
} else {
tmp = y * (x / y);
}
return tmp;
}
def code(x, y, z): tmp = 0 if ((x * (y - z)) / y) <= 5e+298: tmp = x else: tmp = y * (x / y) return tmp
function code(x, y, z) tmp = 0.0 if (Float64(Float64(x * Float64(y - z)) / y) <= 5e+298) tmp = x; else tmp = Float64(y * Float64(x / y)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (((x * (y - z)) / y) <= 5e+298) tmp = x; else tmp = y * (x / y); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[N[(N[(x * N[(y - z), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision], 5e+298], x, N[(y * N[(x / y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{x \cdot \left(y - z\right)}{y} \leq 5 \cdot 10^{+298}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;y \cdot \frac{x}{y}\\
\end{array}
\end{array}
if (/.f64 (*.f64 x (-.f64 y z)) y) < 5.0000000000000003e298Initial program 88.6%
Taylor expanded in y around inf
Applied rewrites52.0%
if 5.0000000000000003e298 < (/.f64 (*.f64 x (-.f64 y z)) y) Initial program 60.6%
Taylor expanded in y around inf
Applied rewrites6.2%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6448.3
Applied rewrites48.3%
(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 x end
function tmp = code(x, y, z) tmp = x; end
code[x_, y_, z_] := x
\begin{array}{l}
\\
x
\end{array}
Initial program 84.4%
Taylor expanded in y around inf
Applied rewrites49.6%
(FPCore (x y z) :precision binary64 (if (< z -2.060202331921739e+104) (- x (/ (* z x) y)) (if (< z 1.6939766013828526e+213) (/ x (/ y (- y z))) (* (- y z) (/ x y)))))
double code(double x, double y, double z) {
double tmp;
if (z < -2.060202331921739e+104) {
tmp = x - ((z * x) / y);
} else if (z < 1.6939766013828526e+213) {
tmp = x / (y / (y - z));
} else {
tmp = (y - z) * (x / 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 (z < (-2.060202331921739d+104)) then
tmp = x - ((z * x) / y)
else if (z < 1.6939766013828526d+213) then
tmp = x / (y / (y - z))
else
tmp = (y - z) * (x / y)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z < -2.060202331921739e+104) {
tmp = x - ((z * x) / y);
} else if (z < 1.6939766013828526e+213) {
tmp = x / (y / (y - z));
} else {
tmp = (y - z) * (x / y);
}
return tmp;
}
def code(x, y, z): tmp = 0 if z < -2.060202331921739e+104: tmp = x - ((z * x) / y) elif z < 1.6939766013828526e+213: tmp = x / (y / (y - z)) else: tmp = (y - z) * (x / y) return tmp
function code(x, y, z) tmp = 0.0 if (z < -2.060202331921739e+104) tmp = Float64(x - Float64(Float64(z * x) / y)); elseif (z < 1.6939766013828526e+213) tmp = Float64(x / Float64(y / Float64(y - z))); else tmp = Float64(Float64(y - z) * Float64(x / y)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z < -2.060202331921739e+104) tmp = x - ((z * x) / y); elseif (z < 1.6939766013828526e+213) tmp = x / (y / (y - z)); else tmp = (y - z) * (x / y); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Less[z, -2.060202331921739e+104], N[(x - N[(N[(z * x), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], If[Less[z, 1.6939766013828526e+213], N[(x / N[(y / N[(y - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(y - z), $MachinePrecision] * N[(x / y), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z < -2.060202331921739 \cdot 10^{+104}:\\
\;\;\;\;x - \frac{z \cdot x}{y}\\
\mathbf{elif}\;z < 1.6939766013828526 \cdot 10^{+213}:\\
\;\;\;\;\frac{x}{\frac{y}{y - z}}\\
\mathbf{else}:\\
\;\;\;\;\left(y - z\right) \cdot \frac{x}{y}\\
\end{array}
\end{array}
herbie shell --seed 2025105
(FPCore (x y z)
:name "Diagrams.Backend.Cairo.Internal:setTexture from diagrams-cairo-1.3.0.3"
:precision binary64
:alt
(! :herbie-platform default (if (< z -206020233192173900000000000000000000000000000000000000000000000000000000000000000000000000000000000000000) (- x (/ (* z x) y)) (if (< z 1693976601382852600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000) (/ x (/ y (- y z))) (* (- y z) (/ x y)))))
(/ (* x (- y z)) y))