
(FPCore (x y z t) :precision binary64 (/ (* x (- y z)) (- t z)))
double code(double x, double y, double z, double t) {
return (x * (y - z)) / (t - 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, t)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = (x * (y - z)) / (t - z)
end function
public static double code(double x, double y, double z, double t) {
return (x * (y - z)) / (t - z);
}
def code(x, y, z, t): return (x * (y - z)) / (t - z)
function code(x, y, z, t) return Float64(Float64(x * Float64(y - z)) / Float64(t - z)) end
function tmp = code(x, y, z, t) tmp = (x * (y - z)) / (t - z); end
code[x_, y_, z_, t_] := N[(N[(x * N[(y - z), $MachinePrecision]), $MachinePrecision] / N[(t - z), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x \cdot \left(y - z\right)}{t - z}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 10 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z t) :precision binary64 (/ (* x (- y z)) (- t z)))
double code(double x, double y, double z, double t) {
return (x * (y - z)) / (t - 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, t)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = (x * (y - z)) / (t - z)
end function
public static double code(double x, double y, double z, double t) {
return (x * (y - z)) / (t - z);
}
def code(x, y, z, t): return (x * (y - z)) / (t - z)
function code(x, y, z, t) return Float64(Float64(x * Float64(y - z)) / Float64(t - z)) end
function tmp = code(x, y, z, t) tmp = (x * (y - z)) / (t - z); end
code[x_, y_, z_, t_] := N[(N[(x * N[(y - z), $MachinePrecision]), $MachinePrecision] / N[(t - z), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x \cdot \left(y - z\right)}{t - z}
\end{array}
(FPCore (x y z t) :precision binary64 (* x (/ (- y z) (- t z))))
double code(double x, double y, double z, double t) {
return x * ((y - z) / (t - 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, t)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = x * ((y - z) / (t - z))
end function
public static double code(double x, double y, double z, double t) {
return x * ((y - z) / (t - z));
}
def code(x, y, z, t): return x * ((y - z) / (t - z))
function code(x, y, z, t) return Float64(x * Float64(Float64(y - z) / Float64(t - z))) end
function tmp = code(x, y, z, t) tmp = x * ((y - z) / (t - z)); end
code[x_, y_, z_, t_] := N[(x * N[(N[(y - z), $MachinePrecision] / N[(t - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot \frac{y - z}{t - z}
\end{array}
Initial program 85.4%
lift--.f64N/A
lift-/.f64N/A
lift--.f64N/A
lift-*.f64N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f64N/A
lift--.f64N/A
lift--.f6495.3
Applied rewrites95.3%
(FPCore (x y z t) :precision binary64 (if (<= (/ (* x (- y z)) (- t z)) 0.0) (* x (/ y (- t z))) x))
double code(double x, double y, double z, double t) {
double tmp;
if (((x * (y - z)) / (t - z)) <= 0.0) {
tmp = x * (y / (t - z));
} 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, t)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: tmp
if (((x * (y - z)) / (t - z)) <= 0.0d0) then
tmp = x * (y / (t - z))
else
tmp = x
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (((x * (y - z)) / (t - z)) <= 0.0) {
tmp = x * (y / (t - z));
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if ((x * (y - z)) / (t - z)) <= 0.0: tmp = x * (y / (t - z)) else: tmp = x return tmp
function code(x, y, z, t) tmp = 0.0 if (Float64(Float64(x * Float64(y - z)) / Float64(t - z)) <= 0.0) tmp = Float64(x * Float64(y / Float64(t - z))); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (((x * (y - z)) / (t - z)) <= 0.0) tmp = x * (y / (t - z)); else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[N[(N[(x * N[(y - z), $MachinePrecision]), $MachinePrecision] / N[(t - z), $MachinePrecision]), $MachinePrecision], 0.0], N[(x * N[(y / N[(t - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], x]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{x \cdot \left(y - z\right)}{t - z} \leq 0:\\
\;\;\;\;x \cdot \frac{y}{t - z}\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if (/.f64 (*.f64 x (-.f64 y z)) (-.f64 t z)) < 0.0Initial program 86.7%
Taylor expanded in y around inf
associate-/l*N/A
lower-*.f64N/A
lower-/.f64N/A
lift--.f6452.4
Applied rewrites52.4%
if 0.0 < (/.f64 (*.f64 x (-.f64 y z)) (-.f64 t z)) Initial program 83.6%
Taylor expanded in z around inf
Applied rewrites41.3%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (fma t (/ x z) x)))
(if (<= z -5.5e-28)
t_1
(if (<= z 13800000.0)
(* (/ x (- t z)) y)
(if (<= z 3.5e+108) (* x (/ (- y z) t)) t_1)))))
double code(double x, double y, double z, double t) {
double t_1 = fma(t, (x / z), x);
double tmp;
if (z <= -5.5e-28) {
tmp = t_1;
} else if (z <= 13800000.0) {
tmp = (x / (t - z)) * y;
} else if (z <= 3.5e+108) {
tmp = x * ((y - z) / t);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t) t_1 = fma(t, Float64(x / z), x) tmp = 0.0 if (z <= -5.5e-28) tmp = t_1; elseif (z <= 13800000.0) tmp = Float64(Float64(x / Float64(t - z)) * y); elseif (z <= 3.5e+108) tmp = Float64(x * Float64(Float64(y - z) / t)); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(t * N[(x / z), $MachinePrecision] + x), $MachinePrecision]}, If[LessEqual[z, -5.5e-28], t$95$1, If[LessEqual[z, 13800000.0], N[(N[(x / N[(t - z), $MachinePrecision]), $MachinePrecision] * y), $MachinePrecision], If[LessEqual[z, 3.5e+108], N[(x * N[(N[(y - z), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(t, \frac{x}{z}, x\right)\\
\mathbf{if}\;z \leq -5.5 \cdot 10^{-28}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \leq 13800000:\\
\;\;\;\;\frac{x}{t - z} \cdot y\\
\mathbf{elif}\;z \leq 3.5 \cdot 10^{+108}:\\
\;\;\;\;x \cdot \frac{y - z}{t}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if z < -5.49999999999999967e-28 or 3.5000000000000002e108 < z Initial program 77.7%
Taylor expanded in z around inf
associate--l+N/A
associate-*r/N/A
associate-*r/N/A
sub-divN/A
distribute-lft-out--N/A
associate-*r/N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
fp-cancel-sub-sign-invN/A
*-commutativeN/A
lower-fma.f64N/A
lower-*.f64N/A
lower-neg.f6475.1
Applied rewrites75.1%
Taylor expanded in y around 0
+-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f6464.1
Applied rewrites64.1%
if -5.49999999999999967e-28 < z < 1.38e7Initial program 92.4%
Taylor expanded in y around inf
*-commutativeN/A
lower-*.f64N/A
associate-*r/N/A
associate-*r*N/A
times-fracN/A
lower-fma.f64N/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower-/.f64N/A
lift--.f64N/A
lower-/.f64N/A
lift--.f6490.3
Applied rewrites90.3%
Taylor expanded in y around inf
lift-/.f64N/A
lift--.f6480.2
Applied rewrites80.2%
if 1.38e7 < z < 3.5000000000000002e108Initial program 88.7%
lift--.f64N/A
lift-/.f64N/A
lift--.f64N/A
lift-*.f64N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f64N/A
lift--.f64N/A
lift--.f6499.8
Applied rewrites99.8%
Taylor expanded in z around 0
Applied rewrites61.2%
(FPCore (x y z t) :precision binary64 (if (or (<= z -2.7e-29) (not (<= z 1.75e-33))) (fma (* (/ y z) x) -1.0 x) (* (/ x (- t z)) y)))
double code(double x, double y, double z, double t) {
double tmp;
if ((z <= -2.7e-29) || !(z <= 1.75e-33)) {
tmp = fma(((y / z) * x), -1.0, x);
} else {
tmp = (x / (t - z)) * y;
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if ((z <= -2.7e-29) || !(z <= 1.75e-33)) tmp = fma(Float64(Float64(y / z) * x), -1.0, x); else tmp = Float64(Float64(x / Float64(t - z)) * y); end return tmp end
code[x_, y_, z_, t_] := If[Or[LessEqual[z, -2.7e-29], N[Not[LessEqual[z, 1.75e-33]], $MachinePrecision]], N[(N[(N[(y / z), $MachinePrecision] * x), $MachinePrecision] * -1.0 + x), $MachinePrecision], N[(N[(x / N[(t - z), $MachinePrecision]), $MachinePrecision] * y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -2.7 \cdot 10^{-29} \lor \neg \left(z \leq 1.75 \cdot 10^{-33}\right):\\
\;\;\;\;\mathsf{fma}\left(\frac{y}{z} \cdot x, -1, x\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{t - z} \cdot y\\
\end{array}
\end{array}
if z < -2.70000000000000023e-29 or 1.7499999999999999e-33 < z Initial program 80.4%
Taylor expanded in z around inf
associate--l+N/A
associate-*r/N/A
associate-*r/N/A
sub-divN/A
distribute-lft-out--N/A
associate-*r/N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
fp-cancel-sub-sign-invN/A
*-commutativeN/A
lower-fma.f64N/A
lower-*.f64N/A
lower-neg.f6470.4
Applied rewrites70.4%
Taylor expanded in y around inf
associate-*r/N/A
*-commutativeN/A
lower-*.f64N/A
lift-/.f6476.0
Applied rewrites76.0%
if -2.70000000000000023e-29 < z < 1.7499999999999999e-33Initial program 92.0%
Taylor expanded in y around inf
*-commutativeN/A
lower-*.f64N/A
associate-*r/N/A
associate-*r*N/A
times-fracN/A
lower-fma.f64N/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower-/.f64N/A
lift--.f64N/A
lower-/.f64N/A
lift--.f6489.9
Applied rewrites89.9%
Taylor expanded in y around inf
lift-/.f64N/A
lift--.f6481.8
Applied rewrites81.8%
Final simplification78.5%
(FPCore (x y z t) :precision binary64 (if (or (<= z -2.7e-29) (not (<= z 1.75e-33))) (* x (/ (- y z) (- z))) (* (/ x (- t z)) y)))
double code(double x, double y, double z, double t) {
double tmp;
if ((z <= -2.7e-29) || !(z <= 1.75e-33)) {
tmp = x * ((y - z) / -z);
} else {
tmp = (x / (t - z)) * 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, t)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: tmp
if ((z <= (-2.7d-29)) .or. (.not. (z <= 1.75d-33))) then
tmp = x * ((y - z) / -z)
else
tmp = (x / (t - z)) * y
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((z <= -2.7e-29) || !(z <= 1.75e-33)) {
tmp = x * ((y - z) / -z);
} else {
tmp = (x / (t - z)) * y;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (z <= -2.7e-29) or not (z <= 1.75e-33): tmp = x * ((y - z) / -z) else: tmp = (x / (t - z)) * y return tmp
function code(x, y, z, t) tmp = 0.0 if ((z <= -2.7e-29) || !(z <= 1.75e-33)) tmp = Float64(x * Float64(Float64(y - z) / Float64(-z))); else tmp = Float64(Float64(x / Float64(t - z)) * y); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((z <= -2.7e-29) || ~((z <= 1.75e-33))) tmp = x * ((y - z) / -z); else tmp = (x / (t - z)) * y; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[z, -2.7e-29], N[Not[LessEqual[z, 1.75e-33]], $MachinePrecision]], N[(x * N[(N[(y - z), $MachinePrecision] / (-z)), $MachinePrecision]), $MachinePrecision], N[(N[(x / N[(t - z), $MachinePrecision]), $MachinePrecision] * y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -2.7 \cdot 10^{-29} \lor \neg \left(z \leq 1.75 \cdot 10^{-33}\right):\\
\;\;\;\;x \cdot \frac{y - z}{-z}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{t - z} \cdot y\\
\end{array}
\end{array}
if z < -2.70000000000000023e-29 or 1.7499999999999999e-33 < z Initial program 80.4%
Taylor expanded in z around inf
mul-1-negN/A
lower-neg.f6461.1
Applied rewrites61.1%
lift-/.f64N/A
lift--.f64N/A
lift-*.f64N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f64N/A
lift--.f6475.9
Applied rewrites75.9%
if -2.70000000000000023e-29 < z < 1.7499999999999999e-33Initial program 92.0%
Taylor expanded in y around inf
*-commutativeN/A
lower-*.f64N/A
associate-*r/N/A
associate-*r*N/A
times-fracN/A
lower-fma.f64N/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower-/.f64N/A
lift--.f64N/A
lower-/.f64N/A
lift--.f6489.9
Applied rewrites89.9%
Taylor expanded in y around inf
lift-/.f64N/A
lift--.f6481.8
Applied rewrites81.8%
Final simplification78.5%
(FPCore (x y z t) :precision binary64 (if (<= y -2.7e+29) (* x (/ y (- t z))) (if (<= y 2.1e+15) (* x (/ (- z) (- t z))) (/ (* x y) (- t z)))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= -2.7e+29) {
tmp = x * (y / (t - z));
} else if (y <= 2.1e+15) {
tmp = x * (-z / (t - z));
} else {
tmp = (x * y) / (t - z);
}
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, t)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: tmp
if (y <= (-2.7d+29)) then
tmp = x * (y / (t - z))
else if (y <= 2.1d+15) then
tmp = x * (-z / (t - z))
else
tmp = (x * y) / (t - z)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (y <= -2.7e+29) {
tmp = x * (y / (t - z));
} else if (y <= 2.1e+15) {
tmp = x * (-z / (t - z));
} else {
tmp = (x * y) / (t - z);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= -2.7e+29: tmp = x * (y / (t - z)) elif y <= 2.1e+15: tmp = x * (-z / (t - z)) else: tmp = (x * y) / (t - z) return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= -2.7e+29) tmp = Float64(x * Float64(y / Float64(t - z))); elseif (y <= 2.1e+15) tmp = Float64(x * Float64(Float64(-z) / Float64(t - z))); else tmp = Float64(Float64(x * y) / Float64(t - z)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (y <= -2.7e+29) tmp = x * (y / (t - z)); elseif (y <= 2.1e+15) tmp = x * (-z / (t - z)); else tmp = (x * y) / (t - z); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, -2.7e+29], N[(x * N[(y / N[(t - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 2.1e+15], N[(x * N[((-z) / N[(t - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x * y), $MachinePrecision] / N[(t - z), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.7 \cdot 10^{+29}:\\
\;\;\;\;x \cdot \frac{y}{t - z}\\
\mathbf{elif}\;y \leq 2.1 \cdot 10^{+15}:\\
\;\;\;\;x \cdot \frac{-z}{t - z}\\
\mathbf{else}:\\
\;\;\;\;\frac{x \cdot y}{t - z}\\
\end{array}
\end{array}
if y < -2.7e29Initial program 83.5%
Taylor expanded in y around inf
associate-/l*N/A
lower-*.f64N/A
lower-/.f64N/A
lift--.f6474.5
Applied rewrites74.5%
if -2.7e29 < y < 2.1e15Initial program 83.4%
lift--.f64N/A
lift-/.f64N/A
lift--.f64N/A
lift-*.f64N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f64N/A
lift--.f64N/A
lift--.f6497.1
Applied rewrites97.1%
Taylor expanded in y around 0
mul-1-negN/A
lift-neg.f6480.6
Applied rewrites80.6%
if 2.1e15 < y Initial program 91.9%
Taylor expanded in y around inf
Applied rewrites73.5%
(FPCore (x y z t) :precision binary64 (if (or (<= z -5.5e-28) (not (<= z 1400000000000.0))) (fma t (/ x z) x) (* (/ x (- t z)) y)))
double code(double x, double y, double z, double t) {
double tmp;
if ((z <= -5.5e-28) || !(z <= 1400000000000.0)) {
tmp = fma(t, (x / z), x);
} else {
tmp = (x / (t - z)) * y;
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if ((z <= -5.5e-28) || !(z <= 1400000000000.0)) tmp = fma(t, Float64(x / z), x); else tmp = Float64(Float64(x / Float64(t - z)) * y); end return tmp end
code[x_, y_, z_, t_] := If[Or[LessEqual[z, -5.5e-28], N[Not[LessEqual[z, 1400000000000.0]], $MachinePrecision]], N[(t * N[(x / z), $MachinePrecision] + x), $MachinePrecision], N[(N[(x / N[(t - z), $MachinePrecision]), $MachinePrecision] * y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -5.5 \cdot 10^{-28} \lor \neg \left(z \leq 1400000000000\right):\\
\;\;\;\;\mathsf{fma}\left(t, \frac{x}{z}, x\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{t - z} \cdot y\\
\end{array}
\end{array}
if z < -5.49999999999999967e-28 or 1.4e12 < z Initial program 79.4%
Taylor expanded in z around inf
associate--l+N/A
associate-*r/N/A
associate-*r/N/A
sub-divN/A
distribute-lft-out--N/A
associate-*r/N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
fp-cancel-sub-sign-invN/A
*-commutativeN/A
lower-fma.f64N/A
lower-*.f64N/A
lower-neg.f6470.3
Applied rewrites70.3%
Taylor expanded in y around 0
+-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f6459.1
Applied rewrites59.1%
if -5.49999999999999967e-28 < z < 1.4e12Initial program 92.5%
Taylor expanded in y around inf
*-commutativeN/A
lower-*.f64N/A
associate-*r/N/A
associate-*r*N/A
times-fracN/A
lower-fma.f64N/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower-/.f64N/A
lift--.f64N/A
lower-/.f64N/A
lift--.f6489.6
Applied rewrites89.6%
Taylor expanded in y around inf
lift-/.f64N/A
lift--.f6479.0
Applied rewrites79.0%
Final simplification68.2%
(FPCore (x y z t) :precision binary64 (if (or (<= z -3.7e-34) (not (<= z 4.8e-51))) x (* (/ x t) y)))
double code(double x, double y, double z, double t) {
double tmp;
if ((z <= -3.7e-34) || !(z <= 4.8e-51)) {
tmp = x;
} else {
tmp = (x / t) * 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, t)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: tmp
if ((z <= (-3.7d-34)) .or. (.not. (z <= 4.8d-51))) then
tmp = x
else
tmp = (x / t) * y
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((z <= -3.7e-34) || !(z <= 4.8e-51)) {
tmp = x;
} else {
tmp = (x / t) * y;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (z <= -3.7e-34) or not (z <= 4.8e-51): tmp = x else: tmp = (x / t) * y return tmp
function code(x, y, z, t) tmp = 0.0 if ((z <= -3.7e-34) || !(z <= 4.8e-51)) tmp = x; else tmp = Float64(Float64(x / t) * y); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((z <= -3.7e-34) || ~((z <= 4.8e-51))) tmp = x; else tmp = (x / t) * y; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[z, -3.7e-34], N[Not[LessEqual[z, 4.8e-51]], $MachinePrecision]], x, N[(N[(x / t), $MachinePrecision] * y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -3.7 \cdot 10^{-34} \lor \neg \left(z \leq 4.8 \cdot 10^{-51}\right):\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{t} \cdot y\\
\end{array}
\end{array}
if z < -3.69999999999999988e-34 or 4.8e-51 < z Initial program 81.0%
Taylor expanded in z around inf
Applied rewrites56.0%
if -3.69999999999999988e-34 < z < 4.8e-51Initial program 91.7%
Taylor expanded in y around inf
*-commutativeN/A
lower-*.f64N/A
associate-*r/N/A
associate-*r*N/A
times-fracN/A
lower-fma.f64N/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower-/.f64N/A
lift--.f64N/A
lower-/.f64N/A
lift--.f6489.4
Applied rewrites89.4%
Taylor expanded in z around 0
lower-/.f6469.2
Applied rewrites69.2%
Final simplification61.4%
(FPCore (x y z t) :precision binary64 (if (<= z -3.7e-34) (fma t (/ x z) x) (if (<= z 4.8e-51) (* (/ x t) y) x)))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -3.7e-34) {
tmp = fma(t, (x / z), x);
} else if (z <= 4.8e-51) {
tmp = (x / t) * y;
} else {
tmp = x;
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (z <= -3.7e-34) tmp = fma(t, Float64(x / z), x); elseif (z <= 4.8e-51) tmp = Float64(Float64(x / t) * y); else tmp = x; end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[z, -3.7e-34], N[(t * N[(x / z), $MachinePrecision] + x), $MachinePrecision], If[LessEqual[z, 4.8e-51], N[(N[(x / t), $MachinePrecision] * y), $MachinePrecision], x]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -3.7 \cdot 10^{-34}:\\
\;\;\;\;\mathsf{fma}\left(t, \frac{x}{z}, x\right)\\
\mathbf{elif}\;z \leq 4.8 \cdot 10^{-51}:\\
\;\;\;\;\frac{x}{t} \cdot y\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if z < -3.69999999999999988e-34Initial program 79.3%
Taylor expanded in z around inf
associate--l+N/A
associate-*r/N/A
associate-*r/N/A
sub-divN/A
distribute-lft-out--N/A
associate-*r/N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
fp-cancel-sub-sign-invN/A
*-commutativeN/A
lower-fma.f64N/A
lower-*.f64N/A
lower-neg.f6473.6
Applied rewrites73.6%
Taylor expanded in y around 0
+-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f6460.1
Applied rewrites60.1%
if -3.69999999999999988e-34 < z < 4.8e-51Initial program 91.7%
Taylor expanded in y around inf
*-commutativeN/A
lower-*.f64N/A
associate-*r/N/A
associate-*r*N/A
times-fracN/A
lower-fma.f64N/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower-/.f64N/A
lift--.f64N/A
lower-/.f64N/A
lift--.f6489.4
Applied rewrites89.4%
Taylor expanded in z around 0
lower-/.f6469.2
Applied rewrites69.2%
if 4.8e-51 < z Initial program 83.2%
Taylor expanded in z around inf
Applied rewrites52.5%
(FPCore (x y z t) :precision binary64 x)
double code(double x, double y, double z, double t) {
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, t)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = x
end function
public static double code(double x, double y, double z, double t) {
return x;
}
def code(x, y, z, t): return x
function code(x, y, z, t) return x end
function tmp = code(x, y, z, t) tmp = x; end
code[x_, y_, z_, t_] := x
\begin{array}{l}
\\
x
\end{array}
Initial program 85.4%
Taylor expanded in z around inf
Applied rewrites36.7%
(FPCore (x y z t) :precision binary64 (/ x (/ (- t z) (- y z))))
double code(double x, double y, double z, double t) {
return x / ((t - z) / (y - 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, t)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = x / ((t - z) / (y - z))
end function
public static double code(double x, double y, double z, double t) {
return x / ((t - z) / (y - z));
}
def code(x, y, z, t): return x / ((t - z) / (y - z))
function code(x, y, z, t) return Float64(x / Float64(Float64(t - z) / Float64(y - z))) end
function tmp = code(x, y, z, t) tmp = x / ((t - z) / (y - z)); end
code[x_, y_, z_, t_] := N[(x / N[(N[(t - z), $MachinePrecision] / N[(y - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x}{\frac{t - z}{y - z}}
\end{array}
herbie shell --seed 2025073
(FPCore (x y z t)
:name "Graphics.Rendering.Chart.Plot.AreaSpots:renderAreaSpots4D from Chart-1.5.3"
:precision binary64
:alt
(! :herbie-platform default (/ x (/ (- t z) (- y z))))
(/ (* x (- y z)) (- t z)))