
(FPCore (x y z t) :precision binary64 (+ x (/ (* (- y x) z) t)))
double code(double x, double y, double z, double t) {
return x + (((y - x) * z) / t);
}
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 - x) * z) / t)
end function
public static double code(double x, double y, double z, double t) {
return x + (((y - x) * z) / t);
}
def code(x, y, z, t): return x + (((y - x) * z) / t)
function code(x, y, z, t) return Float64(x + Float64(Float64(Float64(y - x) * z) / t)) end
function tmp = code(x, y, z, t) tmp = x + (((y - x) * z) / t); end
code[x_, y_, z_, t_] := N[(x + N[(N[(N[(y - x), $MachinePrecision] * z), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \frac{\left(y - x\right) \cdot z}{t}
\end{array}
Herbie found 9 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z t) :precision binary64 (+ x (/ (* (- y x) z) t)))
double code(double x, double y, double z, double t) {
return x + (((y - x) * z) / t);
}
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 - x) * z) / t)
end function
public static double code(double x, double y, double z, double t) {
return x + (((y - x) * z) / t);
}
def code(x, y, z, t): return x + (((y - x) * z) / t)
function code(x, y, z, t) return Float64(x + Float64(Float64(Float64(y - x) * z) / t)) end
function tmp = code(x, y, z, t) tmp = x + (((y - x) * z) / t); end
code[x_, y_, z_, t_] := N[(x + N[(N[(N[(y - x), $MachinePrecision] * z), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \frac{\left(y - x\right) \cdot z}{t}
\end{array}
(FPCore (x y z t) :precision binary64 (if (<= z -1.55e-95) (fma (/ (- y x) t) z x) (fma (/ z t) (- y x) x)))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -1.55e-95) {
tmp = fma(((y - x) / t), z, x);
} else {
tmp = fma((z / t), (y - x), x);
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (z <= -1.55e-95) tmp = fma(Float64(Float64(y - x) / t), z, x); else tmp = fma(Float64(z / t), Float64(y - x), x); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[z, -1.55e-95], N[(N[(N[(y - x), $MachinePrecision] / t), $MachinePrecision] * z + x), $MachinePrecision], N[(N[(z / t), $MachinePrecision] * N[(y - x), $MachinePrecision] + x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.55 \cdot 10^{-95}:\\
\;\;\;\;\mathsf{fma}\left(\frac{y - x}{t}, z, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{z}{t}, y - x, x\right)\\
\end{array}
\end{array}
if z < -1.54999999999999996e-95Initial program 89.6%
lift-+.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift--.f64N/A
+-commutativeN/A
associate-*l/N/A
sub-divN/A
lower-fma.f64N/A
sub-divN/A
lower-/.f64N/A
lift--.f6497.7
Applied rewrites97.7%
if -1.54999999999999996e-95 < z Initial program 94.5%
lift-+.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift--.f64N/A
+-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
lift--.f6497.9
Applied rewrites97.9%
(FPCore (x y z t) :precision binary64 (fma (/ z t) (- y x) x))
double code(double x, double y, double z, double t) {
return fma((z / t), (y - x), x);
}
function code(x, y, z, t) return fma(Float64(z / t), Float64(y - x), x) end
code[x_, y_, z_, t_] := N[(N[(z / t), $MachinePrecision] * N[(y - x), $MachinePrecision] + x), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(\frac{z}{t}, y - x, x\right)
\end{array}
Initial program 92.9%
lift-+.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift--.f64N/A
+-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
lift--.f6497.9
Applied rewrites97.9%
(FPCore (x y z t) :precision binary64 (if (<= t -4e+69) (fma y (/ z t) x) (if (<= t 1.7e-114) (/ (* (- y x) z) t) (fma (/ y t) z x))))
double code(double x, double y, double z, double t) {
double tmp;
if (t <= -4e+69) {
tmp = fma(y, (z / t), x);
} else if (t <= 1.7e-114) {
tmp = ((y - x) * z) / t;
} else {
tmp = fma((y / t), z, x);
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (t <= -4e+69) tmp = fma(y, Float64(z / t), x); elseif (t <= 1.7e-114) tmp = Float64(Float64(Float64(y - x) * z) / t); else tmp = fma(Float64(y / t), z, x); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[t, -4e+69], N[(y * N[(z / t), $MachinePrecision] + x), $MachinePrecision], If[LessEqual[t, 1.7e-114], N[(N[(N[(y - x), $MachinePrecision] * z), $MachinePrecision] / t), $MachinePrecision], N[(N[(y / t), $MachinePrecision] * z + x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -4 \cdot 10^{+69}:\\
\;\;\;\;\mathsf{fma}\left(y, \frac{z}{t}, x\right)\\
\mathbf{elif}\;t \leq 1.7 \cdot 10^{-114}:\\
\;\;\;\;\frac{\left(y - x\right) \cdot z}{t}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{y}{t}, z, x\right)\\
\end{array}
\end{array}
if t < -4.0000000000000003e69Initial program 85.3%
Taylor expanded in x around 0
Applied rewrites82.6%
lift-+.f64N/A
+-commutativeN/A
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
lower-fma.f64N/A
lift-/.f6487.5
Applied rewrites87.5%
if -4.0000000000000003e69 < t < 1.69999999999999991e-114Initial program 97.9%
Taylor expanded in z around inf
sub-divN/A
associate-/l*N/A
*-commutativeN/A
lift--.f64N/A
lift-*.f64N/A
lift-/.f6481.9
Applied rewrites81.9%
if 1.69999999999999991e-114 < t Initial program 90.6%
lift-+.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift--.f64N/A
+-commutativeN/A
associate-*l/N/A
sub-divN/A
lower-fma.f64N/A
sub-divN/A
lower-/.f64N/A
lift--.f6496.6
Applied rewrites96.6%
Taylor expanded in x around 0
lower-/.f6480.5
Applied rewrites80.5%
(FPCore (x y z t) :precision binary64 (if (<= x -6.4e+96) (* (- 1.0 (/ z t)) x) (if (<= x 3.9) (fma (/ y t) z x) (- x (* x (/ z t))))))
double code(double x, double y, double z, double t) {
double tmp;
if (x <= -6.4e+96) {
tmp = (1.0 - (z / t)) * x;
} else if (x <= 3.9) {
tmp = fma((y / t), z, x);
} else {
tmp = x - (x * (z / t));
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (x <= -6.4e+96) tmp = Float64(Float64(1.0 - Float64(z / t)) * x); elseif (x <= 3.9) tmp = fma(Float64(y / t), z, x); else tmp = Float64(x - Float64(x * Float64(z / t))); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[x, -6.4e+96], N[(N[(1.0 - N[(z / t), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision], If[LessEqual[x, 3.9], N[(N[(y / t), $MachinePrecision] * z + x), $MachinePrecision], N[(x - N[(x * N[(z / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -6.4 \cdot 10^{+96}:\\
\;\;\;\;\left(1 - \frac{z}{t}\right) \cdot x\\
\mathbf{elif}\;x \leq 3.9:\\
\;\;\;\;\mathsf{fma}\left(\frac{y}{t}, z, x\right)\\
\mathbf{else}:\\
\;\;\;\;x - x \cdot \frac{z}{t}\\
\end{array}
\end{array}
if x < -6.40000000000000013e96Initial program 89.0%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
cancel-sign-subN/A
metadata-evalN/A
*-lft-identityN/A
lower--.f64N/A
lower-/.f6492.4
Applied rewrites92.4%
if -6.40000000000000013e96 < x < 3.89999999999999991Initial program 94.5%
lift-+.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift--.f64N/A
+-commutativeN/A
associate-*l/N/A
sub-divN/A
lower-fma.f64N/A
sub-divN/A
lower-/.f64N/A
lift--.f6494.3
Applied rewrites94.3%
Taylor expanded in x around 0
lower-/.f6480.1
Applied rewrites80.1%
if 3.89999999999999991 < x Initial program 92.1%
lift-+.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift--.f64N/A
+-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
lift--.f6499.9
Applied rewrites99.9%
Taylor expanded in y around 0
associate-*l/N/A
*-commutativeN/A
+-commutativeN/A
fp-cancel-sign-sub-invN/A
distribute-lft-neg-outN/A
associate-*r/N/A
distribute-frac-neg2N/A
mul-1-negN/A
frac-2negN/A
lower--.f64N/A
associate-/l*N/A
lower-*.f64N/A
lift-/.f6487.9
Applied rewrites87.9%
(FPCore (x y z t) :precision binary64 (let* ((t_1 (* (- 1.0 (/ z t)) x))) (if (<= x -6.4e+96) t_1 (if (<= x 3.9) (fma (/ y t) z x) t_1))))
double code(double x, double y, double z, double t) {
double t_1 = (1.0 - (z / t)) * x;
double tmp;
if (x <= -6.4e+96) {
tmp = t_1;
} else if (x <= 3.9) {
tmp = fma((y / t), z, x);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t) t_1 = Float64(Float64(1.0 - Float64(z / t)) * x) tmp = 0.0 if (x <= -6.4e+96) tmp = t_1; elseif (x <= 3.9) tmp = fma(Float64(y / t), z, x); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[(1.0 - N[(z / t), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision]}, If[LessEqual[x, -6.4e+96], t$95$1, If[LessEqual[x, 3.9], N[(N[(y / t), $MachinePrecision] * z + x), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left(1 - \frac{z}{t}\right) \cdot x\\
\mathbf{if}\;x \leq -6.4 \cdot 10^{+96}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq 3.9:\\
\;\;\;\;\mathsf{fma}\left(\frac{y}{t}, z, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if x < -6.40000000000000013e96 or 3.89999999999999991 < x Initial program 90.8%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
cancel-sign-subN/A
metadata-evalN/A
*-lft-identityN/A
lower--.f64N/A
lower-/.f6489.7
Applied rewrites89.7%
if -6.40000000000000013e96 < x < 3.89999999999999991Initial program 94.5%
lift-+.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift--.f64N/A
+-commutativeN/A
associate-*l/N/A
sub-divN/A
lower-fma.f64N/A
sub-divN/A
lower-/.f64N/A
lift--.f6494.3
Applied rewrites94.3%
Taylor expanded in x around 0
lower-/.f6480.1
Applied rewrites80.1%
(FPCore (x y z t) :precision binary64 (let* ((t_1 (fma y (/ z t) x))) (if (<= t -1.35e-135) t_1 (if (<= t -1.3e-236) (* (/ (- z) t) x) t_1))))
double code(double x, double y, double z, double t) {
double t_1 = fma(y, (z / t), x);
double tmp;
if (t <= -1.35e-135) {
tmp = t_1;
} else if (t <= -1.3e-236) {
tmp = (-z / t) * x;
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t) t_1 = fma(y, Float64(z / t), x) tmp = 0.0 if (t <= -1.35e-135) tmp = t_1; elseif (t <= -1.3e-236) tmp = Float64(Float64(Float64(-z) / t) * x); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(y * N[(z / t), $MachinePrecision] + x), $MachinePrecision]}, If[LessEqual[t, -1.35e-135], t$95$1, If[LessEqual[t, -1.3e-236], N[(N[((-z) / t), $MachinePrecision] * x), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(y, \frac{z}{t}, x\right)\\
\mathbf{if}\;t \leq -1.35 \cdot 10^{-135}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t \leq -1.3 \cdot 10^{-236}:\\
\;\;\;\;\frac{-z}{t} \cdot x\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if t < -1.34999999999999999e-135 or -1.3e-236 < t Initial program 92.5%
Taylor expanded in x around 0
Applied rewrites73.3%
lift-+.f64N/A
+-commutativeN/A
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
lower-fma.f64N/A
lift-/.f6476.9
Applied rewrites76.9%
if -1.34999999999999999e-135 < t < -1.3e-236Initial program 97.8%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
cancel-sign-subN/A
metadata-evalN/A
*-lft-identityN/A
lower--.f64N/A
lower-/.f6460.5
Applied rewrites60.5%
Taylor expanded in z around inf
associate-*r/N/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f6450.1
Applied rewrites50.1%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (/ (* z y) t)))
(if (<= t -2.9e+73)
x
(if (<= t -1.55e-135)
t_1
(if (<= t -9.2e-237) (* (/ (- z) t) x) (if (<= t 5.4e-39) t_1 x))))))
double code(double x, double y, double z, double t) {
double t_1 = (z * y) / t;
double tmp;
if (t <= -2.9e+73) {
tmp = x;
} else if (t <= -1.55e-135) {
tmp = t_1;
} else if (t <= -9.2e-237) {
tmp = (-z / t) * x;
} else if (t <= 5.4e-39) {
tmp = t_1;
} 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) :: t_1
real(8) :: tmp
t_1 = (z * y) / t
if (t <= (-2.9d+73)) then
tmp = x
else if (t <= (-1.55d-135)) then
tmp = t_1
else if (t <= (-9.2d-237)) then
tmp = (-z / t) * x
else if (t <= 5.4d-39) then
tmp = t_1
else
tmp = x
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double t_1 = (z * y) / t;
double tmp;
if (t <= -2.9e+73) {
tmp = x;
} else if (t <= -1.55e-135) {
tmp = t_1;
} else if (t <= -9.2e-237) {
tmp = (-z / t) * x;
} else if (t <= 5.4e-39) {
tmp = t_1;
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z, t): t_1 = (z * y) / t tmp = 0 if t <= -2.9e+73: tmp = x elif t <= -1.55e-135: tmp = t_1 elif t <= -9.2e-237: tmp = (-z / t) * x elif t <= 5.4e-39: tmp = t_1 else: tmp = x return tmp
function code(x, y, z, t) t_1 = Float64(Float64(z * y) / t) tmp = 0.0 if (t <= -2.9e+73) tmp = x; elseif (t <= -1.55e-135) tmp = t_1; elseif (t <= -9.2e-237) tmp = Float64(Float64(Float64(-z) / t) * x); elseif (t <= 5.4e-39) tmp = t_1; else tmp = x; end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = (z * y) / t; tmp = 0.0; if (t <= -2.9e+73) tmp = x; elseif (t <= -1.55e-135) tmp = t_1; elseif (t <= -9.2e-237) tmp = (-z / t) * x; elseif (t <= 5.4e-39) tmp = t_1; else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[(z * y), $MachinePrecision] / t), $MachinePrecision]}, If[LessEqual[t, -2.9e+73], x, If[LessEqual[t, -1.55e-135], t$95$1, If[LessEqual[t, -9.2e-237], N[(N[((-z) / t), $MachinePrecision] * x), $MachinePrecision], If[LessEqual[t, 5.4e-39], t$95$1, x]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{z \cdot y}{t}\\
\mathbf{if}\;t \leq -2.9 \cdot 10^{+73}:\\
\;\;\;\;x\\
\mathbf{elif}\;t \leq -1.55 \cdot 10^{-135}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t \leq -9.2 \cdot 10^{-237}:\\
\;\;\;\;\frac{-z}{t} \cdot x\\
\mathbf{elif}\;t \leq 5.4 \cdot 10^{-39}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if t < -2.9000000000000002e73 or 5.4000000000000001e-39 < t Initial program 87.2%
Taylor expanded in z around 0
Applied rewrites59.7%
if -2.9000000000000002e73 < t < -1.55e-135 or -9.20000000000000046e-237 < t < 5.4000000000000001e-39Initial program 98.0%
Taylor expanded in x around 0
lower-/.f64N/A
*-commutativeN/A
lower-*.f6447.7
Applied rewrites47.7%
if -1.55e-135 < t < -9.20000000000000046e-237Initial program 97.6%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
cancel-sign-subN/A
metadata-evalN/A
*-lft-identityN/A
lower--.f64N/A
lower-/.f6460.4
Applied rewrites60.4%
Taylor expanded in z around inf
associate-*r/N/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f6450.0
Applied rewrites50.0%
(FPCore (x y z t) :precision binary64 (if (<= t -8.5e+76) x (if (<= t 5.4e-39) (* y (/ z t)) x)))
double code(double x, double y, double z, double t) {
double tmp;
if (t <= -8.5e+76) {
tmp = x;
} else if (t <= 5.4e-39) {
tmp = y * (z / t);
} 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 (t <= (-8.5d+76)) then
tmp = x
else if (t <= 5.4d-39) then
tmp = y * (z / t)
else
tmp = x
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (t <= -8.5e+76) {
tmp = x;
} else if (t <= 5.4e-39) {
tmp = y * (z / t);
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if t <= -8.5e+76: tmp = x elif t <= 5.4e-39: tmp = y * (z / t) else: tmp = x return tmp
function code(x, y, z, t) tmp = 0.0 if (t <= -8.5e+76) tmp = x; elseif (t <= 5.4e-39) tmp = Float64(y * Float64(z / t)); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (t <= -8.5e+76) tmp = x; elseif (t <= 5.4e-39) tmp = y * (z / t); else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[t, -8.5e+76], x, If[LessEqual[t, 5.4e-39], N[(y * N[(z / t), $MachinePrecision]), $MachinePrecision], x]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -8.5 \cdot 10^{+76}:\\
\;\;\;\;x\\
\mathbf{elif}\;t \leq 5.4 \cdot 10^{-39}:\\
\;\;\;\;y \cdot \frac{z}{t}\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if t < -8.49999999999999992e76 or 5.4000000000000001e-39 < t Initial program 87.2%
Taylor expanded in z around 0
Applied rewrites59.7%
if -8.49999999999999992e76 < t < 5.4000000000000001e-39Initial program 97.9%
lift-+.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift--.f64N/A
+-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
lift--.f6497.6
Applied rewrites97.6%
Taylor expanded in x around 0
associate-*l/N/A
*-commutativeN/A
+-commutativeN/A
associate-/l*N/A
lower-*.f64N/A
lift-/.f6451.0
Applied rewrites51.0%
(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 92.9%
Taylor expanded in z around 0
Applied rewrites38.1%
herbie shell --seed 2025119
(FPCore (x y z t)
:name "Numeric.Histogram:binBounds from Chart-1.5.3"
:precision binary64
(+ x (/ (* (- y x) z) t)))