
(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 (let* ((t_1 (fma (/ (- y x) t) z x))) (if (<= t -9.2e-8) t_1 (if (<= t 1e-46) (+ x (/ (* (- y x) z) t)) t_1))))
double code(double x, double y, double z, double t) {
double t_1 = fma(((y - x) / t), z, x);
double tmp;
if (t <= -9.2e-8) {
tmp = t_1;
} else if (t <= 1e-46) {
tmp = x + (((y - x) * z) / t);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t) t_1 = fma(Float64(Float64(y - x) / t), z, x) tmp = 0.0 if (t <= -9.2e-8) tmp = t_1; elseif (t <= 1e-46) tmp = Float64(x + Float64(Float64(Float64(y - x) * z) / t)); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[(N[(y - x), $MachinePrecision] / t), $MachinePrecision] * z + x), $MachinePrecision]}, If[LessEqual[t, -9.2e-8], t$95$1, If[LessEqual[t, 1e-46], N[(x + N[(N[(N[(y - x), $MachinePrecision] * z), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(\frac{y - x}{t}, z, x\right)\\
\mathbf{if}\;t \leq -9.2 \cdot 10^{-8}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t \leq 10^{-46}:\\
\;\;\;\;x + \frac{\left(y - x\right) \cdot z}{t}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if t < -9.2000000000000003e-8 or 1.00000000000000002e-46 < t Initial program 88.9%
Applied rewrites98.4%
if -9.2000000000000003e-8 < t < 1.00000000000000002e-46Initial program 98.4%
(FPCore (x y z t) :precision binary64 (if (<= y -2.05e+139) (fma (/ z t) y x) (fma (/ (- y x) t) z x)))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= -2.05e+139) {
tmp = fma((z / t), y, x);
} else {
tmp = fma(((y - x) / t), z, x);
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (y <= -2.05e+139) tmp = fma(Float64(z / t), y, x); else tmp = fma(Float64(Float64(y - x) / t), z, x); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[y, -2.05e+139], N[(N[(z / t), $MachinePrecision] * y + x), $MachinePrecision], N[(N[(N[(y - x), $MachinePrecision] / t), $MachinePrecision] * z + x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.05 \cdot 10^{+139}:\\
\;\;\;\;\mathsf{fma}\left(\frac{z}{t}, y, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{y - x}{t}, z, x\right)\\
\end{array}
\end{array}
if y < -2.0500000000000001e139Initial program 90.1%
Taylor expanded in x around 0
Applied rewrites85.9%
lift-+.f64N/A
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
fp-cancel-sign-sub-invN/A
fp-cancel-sub-sign-invN/A
+-commutativeN/A
remove-double-negN/A
*-commutativeN/A
lower-fma.f64N/A
lift-/.f6492.2
Applied rewrites92.2%
if -2.0500000000000001e139 < y Initial program 93.7%
Applied rewrites93.3%
(FPCore (x y z t) :precision binary64 (let* ((t_1 (fma (/ z t) y x))) (if (<= y -3.2e-52) t_1 (if (<= y 4.8e-22) (* (- 1.0 (/ z t)) x) t_1))))
double code(double x, double y, double z, double t) {
double t_1 = fma((z / t), y, x);
double tmp;
if (y <= -3.2e-52) {
tmp = t_1;
} else if (y <= 4.8e-22) {
tmp = (1.0 - (z / t)) * x;
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t) t_1 = fma(Float64(z / t), y, x) tmp = 0.0 if (y <= -3.2e-52) tmp = t_1; elseif (y <= 4.8e-22) tmp = Float64(Float64(1.0 - Float64(z / t)) * x); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[(z / t), $MachinePrecision] * y + x), $MachinePrecision]}, If[LessEqual[y, -3.2e-52], t$95$1, If[LessEqual[y, 4.8e-22], N[(N[(1.0 - N[(z / t), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(\frac{z}{t}, y, x\right)\\
\mathbf{if}\;y \leq -3.2 \cdot 10^{-52}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;y \leq 4.8 \cdot 10^{-22}:\\
\;\;\;\;\left(1 - \frac{z}{t}\right) \cdot x\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if y < -3.2000000000000001e-52 or 4.80000000000000005e-22 < y Initial program 91.7%
Taylor expanded in x around 0
Applied rewrites83.6%
lift-+.f64N/A
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
fp-cancel-sign-sub-invN/A
fp-cancel-sub-sign-invN/A
+-commutativeN/A
remove-double-negN/A
*-commutativeN/A
lower-fma.f64N/A
lift-/.f6487.7
Applied rewrites87.7%
if -3.2000000000000001e-52 < y < 4.80000000000000005e-22Initial program 95.1%
Taylor expanded in x around inf
+-commutativeN/A
distribute-rgt-inN/A
*-commutativeN/A
*-commutativeN/A
associate-*l*N/A
associate-/l*N/A
*-commutativeN/A
*-commutativeN/A
fp-cancel-sign-sub-invN/A
mul-1-negN/A
associate-/l*N/A
distribute-lft-neg-inN/A
distribute-lft-out--N/A
distribute-lft-neg-outN/A
mul-1-negN/A
mul-1-negN/A
distribute-lft-neg-outN/A
distribute-lft-out--N/A
Applied rewrites84.3%
(FPCore (x y z t) :precision binary64 (if (<= (+ x (/ (* (- y x) z) t)) (- INFINITY)) (* (/ (- z) t) x) (fma (/ z t) y x)))
double code(double x, double y, double z, double t) {
double tmp;
if ((x + (((y - x) * z) / t)) <= -((double) INFINITY)) {
tmp = (-z / t) * x;
} else {
tmp = fma((z / t), y, x);
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (Float64(x + Float64(Float64(Float64(y - x) * z) / t)) <= Float64(-Inf)) tmp = Float64(Float64(Float64(-z) / t) * x); else tmp = fma(Float64(z / t), y, x); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[N[(x + N[(N[(N[(y - x), $MachinePrecision] * z), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision], (-Infinity)], N[(N[((-z) / t), $MachinePrecision] * x), $MachinePrecision], N[(N[(z / t), $MachinePrecision] * y + x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x + \frac{\left(y - x\right) \cdot z}{t} \leq -\infty:\\
\;\;\;\;\frac{-z}{t} \cdot x\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{z}{t}, y, x\right)\\
\end{array}
\end{array}
if (+.f64 x (/.f64 (*.f64 (-.f64 y x) z) t)) < -inf.0Initial program 81.6%
Taylor expanded in x around inf
+-commutativeN/A
distribute-rgt-inN/A
*-commutativeN/A
*-commutativeN/A
associate-*l*N/A
associate-/l*N/A
*-commutativeN/A
*-commutativeN/A
fp-cancel-sign-sub-invN/A
mul-1-negN/A
associate-/l*N/A
distribute-lft-neg-inN/A
distribute-lft-out--N/A
distribute-lft-neg-outN/A
mul-1-negN/A
mul-1-negN/A
distribute-lft-neg-outN/A
distribute-lft-out--N/A
Applied rewrites60.0%
Taylor expanded in z around inf
associate-*r/N/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f6454.0
Applied rewrites54.0%
if -inf.0 < (+.f64 x (/.f64 (*.f64 (-.f64 y x) z) t)) Initial program 95.4%
Taylor expanded in x around 0
Applied rewrites77.6%
lift-+.f64N/A
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
fp-cancel-sign-sub-invN/A
fp-cancel-sub-sign-invN/A
+-commutativeN/A
remove-double-negN/A
*-commutativeN/A
lower-fma.f64N/A
lift-/.f6478.9
Applied rewrites78.9%
(FPCore (x y z t) :precision binary64 (if (<= (+ x (/ (* (- y x) z) t)) (- INFINITY)) (* (/ (- z) t) x) (fma (/ y t) z x)))
double code(double x, double y, double z, double t) {
double tmp;
if ((x + (((y - x) * z) / t)) <= -((double) INFINITY)) {
tmp = (-z / t) * x;
} else {
tmp = fma((y / t), z, x);
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (Float64(x + Float64(Float64(Float64(y - x) * z) / t)) <= Float64(-Inf)) tmp = Float64(Float64(Float64(-z) / t) * x); else tmp = fma(Float64(y / t), z, x); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[N[(x + N[(N[(N[(y - x), $MachinePrecision] * z), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision], (-Infinity)], N[(N[((-z) / t), $MachinePrecision] * x), $MachinePrecision], N[(N[(y / t), $MachinePrecision] * z + x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x + \frac{\left(y - x\right) \cdot z}{t} \leq -\infty:\\
\;\;\;\;\frac{-z}{t} \cdot x\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{y}{t}, z, x\right)\\
\end{array}
\end{array}
if (+.f64 x (/.f64 (*.f64 (-.f64 y x) z) t)) < -inf.0Initial program 81.6%
Taylor expanded in x around inf
+-commutativeN/A
distribute-rgt-inN/A
*-commutativeN/A
*-commutativeN/A
associate-*l*N/A
associate-/l*N/A
*-commutativeN/A
*-commutativeN/A
fp-cancel-sign-sub-invN/A
mul-1-negN/A
associate-/l*N/A
distribute-lft-neg-inN/A
distribute-lft-out--N/A
distribute-lft-neg-outN/A
mul-1-negN/A
mul-1-negN/A
distribute-lft-neg-outN/A
distribute-lft-out--N/A
Applied rewrites60.0%
Taylor expanded in z around inf
associate-*r/N/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f6454.0
Applied rewrites54.0%
if -inf.0 < (+.f64 x (/.f64 (*.f64 (-.f64 y x) z) t)) Initial program 95.4%
Applied rewrites91.5%
Taylor expanded in x around 0
lower-/.f6475.5
Applied rewrites75.5%
(FPCore (x y z t) :precision binary64 (if (<= t -6.5e+60) x (if (<= t 4.1e+116) (* (/ z t) y) x)))
double code(double x, double y, double z, double t) {
double tmp;
if (t <= -6.5e+60) {
tmp = x;
} else if (t <= 4.1e+116) {
tmp = (z / t) * y;
} 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 <= (-6.5d+60)) then
tmp = x
else if (t <= 4.1d+116) then
tmp = (z / t) * y
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 <= -6.5e+60) {
tmp = x;
} else if (t <= 4.1e+116) {
tmp = (z / t) * y;
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if t <= -6.5e+60: tmp = x elif t <= 4.1e+116: tmp = (z / t) * y else: tmp = x return tmp
function code(x, y, z, t) tmp = 0.0 if (t <= -6.5e+60) tmp = x; elseif (t <= 4.1e+116) tmp = Float64(Float64(z / t) * y); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (t <= -6.5e+60) tmp = x; elseif (t <= 4.1e+116) tmp = (z / t) * y; else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[t, -6.5e+60], x, If[LessEqual[t, 4.1e+116], N[(N[(z / t), $MachinePrecision] * y), $MachinePrecision], x]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -6.5 \cdot 10^{+60}:\\
\;\;\;\;x\\
\mathbf{elif}\;t \leq 4.1 \cdot 10^{+116}:\\
\;\;\;\;\frac{z}{t} \cdot y\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if t < -6.49999999999999931e60 or 4.0999999999999998e116 < t Initial program 84.6%
Taylor expanded in z around 0
Applied rewrites64.6%
if -6.49999999999999931e60 < t < 4.0999999999999998e116Initial program 97.8%
Applied rewrites90.2%
Taylor expanded in x around 0
*-commutativeN/A
associate-*l/N/A
lower-*.f64N/A
lift-/.f6448.6
Applied rewrites48.6%
(FPCore (x y z t) :precision binary64 (if (<= t -3.7e+61) x (if (<= t 2.8e+111) (/ (* z y) t) x)))
double code(double x, double y, double z, double t) {
double tmp;
if (t <= -3.7e+61) {
tmp = x;
} else if (t <= 2.8e+111) {
tmp = (z * y) / 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 <= (-3.7d+61)) then
tmp = x
else if (t <= 2.8d+111) then
tmp = (z * y) / 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 <= -3.7e+61) {
tmp = x;
} else if (t <= 2.8e+111) {
tmp = (z * y) / t;
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if t <= -3.7e+61: tmp = x elif t <= 2.8e+111: tmp = (z * y) / t else: tmp = x return tmp
function code(x, y, z, t) tmp = 0.0 if (t <= -3.7e+61) tmp = x; elseif (t <= 2.8e+111) tmp = Float64(Float64(z * y) / t); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (t <= -3.7e+61) tmp = x; elseif (t <= 2.8e+111) tmp = (z * y) / t; else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[t, -3.7e+61], x, If[LessEqual[t, 2.8e+111], N[(N[(z * y), $MachinePrecision] / t), $MachinePrecision], x]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -3.7 \cdot 10^{+61}:\\
\;\;\;\;x\\
\mathbf{elif}\;t \leq 2.8 \cdot 10^{+111}:\\
\;\;\;\;\frac{z \cdot y}{t}\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if t < -3.70000000000000003e61 or 2.7999999999999999e111 < t Initial program 84.6%
Taylor expanded in z around 0
Applied rewrites64.6%
if -3.70000000000000003e61 < t < 2.7999999999999999e111Initial program 97.8%
Taylor expanded in x around 0
lower-/.f64N/A
remove-double-negN/A
mul-1-negN/A
*-commutativeN/A
associate-*l*N/A
distribute-lft-neg-inN/A
lower-*.f64N/A
distribute-lft-neg-outN/A
metadata-evalN/A
*-lft-identity46.9
Applied rewrites46.9%
(FPCore (x y z t) :precision binary64 (if (<= x -4.1e+86) x (if (<= x 1.75e-25) (* (/ y t) z) x)))
double code(double x, double y, double z, double t) {
double tmp;
if (x <= -4.1e+86) {
tmp = x;
} else if (x <= 1.75e-25) {
tmp = (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 <= (-4.1d+86)) then
tmp = x
else if (x <= 1.75d-25) then
tmp = (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 <= -4.1e+86) {
tmp = x;
} else if (x <= 1.75e-25) {
tmp = (y / t) * z;
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if x <= -4.1e+86: tmp = x elif x <= 1.75e-25: tmp = (y / t) * z else: tmp = x return tmp
function code(x, y, z, t) tmp = 0.0 if (x <= -4.1e+86) tmp = x; elseif (x <= 1.75e-25) tmp = Float64(Float64(y / t) * z); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (x <= -4.1e+86) tmp = x; elseif (x <= 1.75e-25) tmp = (y / t) * z; else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[x, -4.1e+86], x, If[LessEqual[x, 1.75e-25], N[(N[(y / t), $MachinePrecision] * z), $MachinePrecision], x]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -4.1 \cdot 10^{+86}:\\
\;\;\;\;x\\
\mathbf{elif}\;x \leq 1.75 \cdot 10^{-25}:\\
\;\;\;\;\frac{y}{t} \cdot z\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if x < -4.0999999999999999e86 or 1.7500000000000001e-25 < x Initial program 91.1%
Taylor expanded in z around 0
Applied rewrites47.8%
if -4.0999999999999999e86 < x < 1.7500000000000001e-25Initial program 94.9%
Taylor expanded in x around 0
lower-/.f64N/A
remove-double-negN/A
mul-1-negN/A
*-commutativeN/A
associate-*l*N/A
distribute-lft-neg-inN/A
lower-*.f64N/A
distribute-lft-neg-outN/A
metadata-evalN/A
*-lft-identity53.4
Applied rewrites53.4%
lift-*.f64N/A
lift-/.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lift-/.f6452.7
Applied rewrites52.7%
(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 93.2%
Taylor expanded in z around 0
Applied rewrites38.7%
herbie shell --seed 2025130
(FPCore (x y z t)
:name "Numeric.Histogram:binBounds from Chart-1.5.3"
:precision binary64
(+ x (/ (* (- y x) z) t)))