
(FPCore (x y z t a) :precision binary64 (+ x (/ (* (- y z) (- t x)) (- a z))))
double code(double x, double y, double z, double t, double a) {
return x + (((y - z) * (t - x)) / (a - 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, a)
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), intent (in) :: a
code = x + (((y - z) * (t - x)) / (a - z))
end function
public static double code(double x, double y, double z, double t, double a) {
return x + (((y - z) * (t - x)) / (a - z));
}
def code(x, y, z, t, a): return x + (((y - z) * (t - x)) / (a - z))
function code(x, y, z, t, a) return Float64(x + Float64(Float64(Float64(y - z) * Float64(t - x)) / Float64(a - z))) end
function tmp = code(x, y, z, t, a) tmp = x + (((y - z) * (t - x)) / (a - z)); end
code[x_, y_, z_, t_, a_] := N[(x + N[(N[(N[(y - z), $MachinePrecision] * N[(t - x), $MachinePrecision]), $MachinePrecision] / N[(a - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \frac{\left(y - z\right) \cdot \left(t - x\right)}{a - z}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 15 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z t a) :precision binary64 (+ x (/ (* (- y z) (- t x)) (- a z))))
double code(double x, double y, double z, double t, double a) {
return x + (((y - z) * (t - x)) / (a - 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, a)
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), intent (in) :: a
code = x + (((y - z) * (t - x)) / (a - z))
end function
public static double code(double x, double y, double z, double t, double a) {
return x + (((y - z) * (t - x)) / (a - z));
}
def code(x, y, z, t, a): return x + (((y - z) * (t - x)) / (a - z))
function code(x, y, z, t, a) return Float64(x + Float64(Float64(Float64(y - z) * Float64(t - x)) / Float64(a - z))) end
function tmp = code(x, y, z, t, a) tmp = x + (((y - z) * (t - x)) / (a - z)); end
code[x_, y_, z_, t_, a_] := N[(x + N[(N[(N[(y - z), $MachinePrecision] * N[(t - x), $MachinePrecision]), $MachinePrecision] / N[(a - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \frac{\left(y - z\right) \cdot \left(t - x\right)}{a - z}
\end{array}
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (/ (- t x) z)))
(if (or (<= z -3.2e+143) (not (<= z 2.9e+94)))
(+ (+ (fma (* (fma -1.0 y a) t_1) (/ a z) (* (- y) t_1)) t) (* a t_1))
(fma (/ (- y z) (- a z)) (- t x) x))))
double code(double x, double y, double z, double t, double a) {
double t_1 = (t - x) / z;
double tmp;
if ((z <= -3.2e+143) || !(z <= 2.9e+94)) {
tmp = (fma((fma(-1.0, y, a) * t_1), (a / z), (-y * t_1)) + t) + (a * t_1);
} else {
tmp = fma(((y - z) / (a - z)), (t - x), x);
}
return tmp;
}
function code(x, y, z, t, a) t_1 = Float64(Float64(t - x) / z) tmp = 0.0 if ((z <= -3.2e+143) || !(z <= 2.9e+94)) tmp = Float64(Float64(fma(Float64(fma(-1.0, y, a) * t_1), Float64(a / z), Float64(Float64(-y) * t_1)) + t) + Float64(a * t_1)); else tmp = fma(Float64(Float64(y - z) / Float64(a - z)), Float64(t - x), x); end return tmp end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(N[(t - x), $MachinePrecision] / z), $MachinePrecision]}, If[Or[LessEqual[z, -3.2e+143], N[Not[LessEqual[z, 2.9e+94]], $MachinePrecision]], N[(N[(N[(N[(N[(-1.0 * y + a), $MachinePrecision] * t$95$1), $MachinePrecision] * N[(a / z), $MachinePrecision] + N[((-y) * t$95$1), $MachinePrecision]), $MachinePrecision] + t), $MachinePrecision] + N[(a * t$95$1), $MachinePrecision]), $MachinePrecision], N[(N[(N[(y - z), $MachinePrecision] / N[(a - z), $MachinePrecision]), $MachinePrecision] * N[(t - x), $MachinePrecision] + x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{t - x}{z}\\
\mathbf{if}\;z \leq -3.2 \cdot 10^{+143} \lor \neg \left(z \leq 2.9 \cdot 10^{+94}\right):\\
\;\;\;\;\left(\mathsf{fma}\left(\mathsf{fma}\left(-1, y, a\right) \cdot t\_1, \frac{a}{z}, \left(-y\right) \cdot t\_1\right) + t\right) + a \cdot t\_1\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{y - z}{a - z}, t - x, x\right)\\
\end{array}
\end{array}
if z < -3.20000000000000016e143 or 2.8999999999999998e94 < z Initial program 23.0%
lift-+.f64N/A
+-commutativeN/A
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f6449.9
Applied rewrites49.9%
Taylor expanded in z around inf
Applied rewrites87.8%
if -3.20000000000000016e143 < z < 2.8999999999999998e94Initial program 84.9%
lift-+.f64N/A
+-commutativeN/A
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f6494.0
Applied rewrites94.0%
Final simplification92.5%
(FPCore (x y z t a)
:precision binary64
(if (<= z -3.7e+141)
t
(if (<= z -1.5e-12)
(* (/ (- x t) z) y)
(if (<= z -3.5e-102)
(fma (/ x a) z x)
(if (<= z 5.9e+79) (* t (/ (- y z) a)) t)))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (z <= -3.7e+141) {
tmp = t;
} else if (z <= -1.5e-12) {
tmp = ((x - t) / z) * y;
} else if (z <= -3.5e-102) {
tmp = fma((x / a), z, x);
} else if (z <= 5.9e+79) {
tmp = t * ((y - z) / a);
} else {
tmp = t;
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if (z <= -3.7e+141) tmp = t; elseif (z <= -1.5e-12) tmp = Float64(Float64(Float64(x - t) / z) * y); elseif (z <= -3.5e-102) tmp = fma(Float64(x / a), z, x); elseif (z <= 5.9e+79) tmp = Float64(t * Float64(Float64(y - z) / a)); else tmp = t; end return tmp end
code[x_, y_, z_, t_, a_] := If[LessEqual[z, -3.7e+141], t, If[LessEqual[z, -1.5e-12], N[(N[(N[(x - t), $MachinePrecision] / z), $MachinePrecision] * y), $MachinePrecision], If[LessEqual[z, -3.5e-102], N[(N[(x / a), $MachinePrecision] * z + x), $MachinePrecision], If[LessEqual[z, 5.9e+79], N[(t * N[(N[(y - z), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision], t]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -3.7 \cdot 10^{+141}:\\
\;\;\;\;t\\
\mathbf{elif}\;z \leq -1.5 \cdot 10^{-12}:\\
\;\;\;\;\frac{x - t}{z} \cdot y\\
\mathbf{elif}\;z \leq -3.5 \cdot 10^{-102}:\\
\;\;\;\;\mathsf{fma}\left(\frac{x}{a}, z, x\right)\\
\mathbf{elif}\;z \leq 5.9 \cdot 10^{+79}:\\
\;\;\;\;t \cdot \frac{y - z}{a}\\
\mathbf{else}:\\
\;\;\;\;t\\
\end{array}
\end{array}
if z < -3.7000000000000003e141 or 5.9e79 < z Initial program 26.5%
Taylor expanded in y around 0
+-commutativeN/A
mul-1-negN/A
*-commutativeN/A
associate-/l*N/A
distribute-lft-neg-inN/A
mul-1-negN/A
lower-fma.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower--.f64N/A
lower-/.f64N/A
lower--.f6442.0
Applied rewrites42.0%
Taylor expanded in z around inf
Applied rewrites55.9%
Applied rewrites55.9%
if -3.7000000000000003e141 < z < -1.5000000000000001e-12Initial program 67.8%
Taylor expanded in z around inf
associate--l+N/A
distribute-lft-out--N/A
div-subN/A
+-commutativeN/A
mul-1-negN/A
div-subN/A
associate-/l*N/A
associate-/l*N/A
distribute-rgt-out--N/A
distribute-lft-neg-inN/A
lower-fma.f64N/A
Applied rewrites65.8%
Taylor expanded in y around inf
Applied rewrites49.8%
if -1.5000000000000001e-12 < z < -3.49999999999999986e-102Initial program 83.1%
Taylor expanded in y around 0
+-commutativeN/A
mul-1-negN/A
*-commutativeN/A
associate-/l*N/A
distribute-lft-neg-inN/A
mul-1-negN/A
lower-fma.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower--.f64N/A
lower-/.f64N/A
lower--.f6452.5
Applied rewrites52.5%
Taylor expanded in z around 0
Applied rewrites52.6%
Taylor expanded in x around inf
Applied rewrites52.9%
if -3.49999999999999986e-102 < z < 5.9e79Initial program 90.1%
Taylor expanded in x around 0
*-commutativeN/A
associate-/l*N/A
lower-*.f64N/A
lower--.f64N/A
lower-/.f64N/A
lower--.f6452.7
Applied rewrites52.7%
Taylor expanded in a around inf
Applied rewrites47.2%
Final simplification50.4%
(FPCore (x y z t a) :precision binary64 (if (or (<= z -4.6e+92) (not (<= z 2.9e+94))) (fma (/ (- (- t x)) z) (- y a) t) (fma (/ (- y z) (- a z)) (- t x) x)))
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((z <= -4.6e+92) || !(z <= 2.9e+94)) {
tmp = fma((-(t - x) / z), (y - a), t);
} else {
tmp = fma(((y - z) / (a - z)), (t - x), x);
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if ((z <= -4.6e+92) || !(z <= 2.9e+94)) tmp = fma(Float64(Float64(-Float64(t - x)) / z), Float64(y - a), t); else tmp = fma(Float64(Float64(y - z) / Float64(a - z)), Float64(t - x), x); end return tmp end
code[x_, y_, z_, t_, a_] := If[Or[LessEqual[z, -4.6e+92], N[Not[LessEqual[z, 2.9e+94]], $MachinePrecision]], N[(N[((-N[(t - x), $MachinePrecision]) / z), $MachinePrecision] * N[(y - a), $MachinePrecision] + t), $MachinePrecision], N[(N[(N[(y - z), $MachinePrecision] / N[(a - z), $MachinePrecision]), $MachinePrecision] * N[(t - x), $MachinePrecision] + x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -4.6 \cdot 10^{+92} \lor \neg \left(z \leq 2.9 \cdot 10^{+94}\right):\\
\;\;\;\;\mathsf{fma}\left(\frac{-\left(t - x\right)}{z}, y - a, t\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{y - z}{a - z}, t - x, x\right)\\
\end{array}
\end{array}
if z < -4.59999999999999997e92 or 2.8999999999999998e94 < z Initial program 29.7%
Taylor expanded in z around inf
associate--l+N/A
distribute-lft-out--N/A
div-subN/A
+-commutativeN/A
mul-1-negN/A
div-subN/A
associate-/l*N/A
associate-/l*N/A
distribute-rgt-out--N/A
distribute-lft-neg-inN/A
lower-fma.f64N/A
Applied rewrites85.9%
if -4.59999999999999997e92 < z < 2.8999999999999998e94Initial program 86.5%
lift-+.f64N/A
+-commutativeN/A
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f6495.2
Applied rewrites95.2%
Final simplification92.4%
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (fma (/ (- x t) a) z x)))
(if (<= a -4.4e-9)
t_1
(if (<= a 1.35e-102)
(* (/ (- x t) z) y)
(if (<= a 6.4e+66) (* t (/ (- y z) a)) t_1)))))
double code(double x, double y, double z, double t, double a) {
double t_1 = fma(((x - t) / a), z, x);
double tmp;
if (a <= -4.4e-9) {
tmp = t_1;
} else if (a <= 1.35e-102) {
tmp = ((x - t) / z) * y;
} else if (a <= 6.4e+66) {
tmp = t * ((y - z) / a);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a) t_1 = fma(Float64(Float64(x - t) / a), z, x) tmp = 0.0 if (a <= -4.4e-9) tmp = t_1; elseif (a <= 1.35e-102) tmp = Float64(Float64(Float64(x - t) / z) * y); elseif (a <= 6.4e+66) tmp = Float64(t * Float64(Float64(y - z) / a)); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(N[(N[(x - t), $MachinePrecision] / a), $MachinePrecision] * z + x), $MachinePrecision]}, If[LessEqual[a, -4.4e-9], t$95$1, If[LessEqual[a, 1.35e-102], N[(N[(N[(x - t), $MachinePrecision] / z), $MachinePrecision] * y), $MachinePrecision], If[LessEqual[a, 6.4e+66], N[(t * N[(N[(y - z), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(\frac{x - t}{a}, z, x\right)\\
\mathbf{if}\;a \leq -4.4 \cdot 10^{-9}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;a \leq 1.35 \cdot 10^{-102}:\\
\;\;\;\;\frac{x - t}{z} \cdot y\\
\mathbf{elif}\;a \leq 6.4 \cdot 10^{+66}:\\
\;\;\;\;t \cdot \frac{y - z}{a}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if a < -4.3999999999999997e-9 or 6.3999999999999999e66 < a Initial program 66.8%
Taylor expanded in y around 0
+-commutativeN/A
mul-1-negN/A
*-commutativeN/A
associate-/l*N/A
distribute-lft-neg-inN/A
mul-1-negN/A
lower-fma.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower--.f64N/A
lower-/.f64N/A
lower--.f6453.7
Applied rewrites53.7%
Taylor expanded in z around 0
Applied rewrites44.6%
if -4.3999999999999997e-9 < a < 1.35e-102Initial program 70.8%
Taylor expanded in z around inf
associate--l+N/A
distribute-lft-out--N/A
div-subN/A
+-commutativeN/A
mul-1-negN/A
div-subN/A
associate-/l*N/A
associate-/l*N/A
distribute-rgt-out--N/A
distribute-lft-neg-inN/A
lower-fma.f64N/A
Applied rewrites84.5%
Taylor expanded in y around inf
Applied rewrites57.6%
if 1.35e-102 < a < 6.3999999999999999e66Initial program 75.5%
Taylor expanded in x around 0
*-commutativeN/A
associate-/l*N/A
lower-*.f64N/A
lower--.f64N/A
lower-/.f64N/A
lower--.f6458.8
Applied rewrites58.8%
Taylor expanded in a around inf
Applied rewrites45.1%
Final simplification50.2%
(FPCore (x y z t a) :precision binary64 (if (or (<= z -70000000000.0) (not (<= z 9.5e-23))) (fma (/ (- (- t x)) z) (- y a) t) (fma (- y z) (/ (- t x) a) x)))
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((z <= -70000000000.0) || !(z <= 9.5e-23)) {
tmp = fma((-(t - x) / z), (y - a), t);
} else {
tmp = fma((y - z), ((t - x) / a), x);
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if ((z <= -70000000000.0) || !(z <= 9.5e-23)) tmp = fma(Float64(Float64(-Float64(t - x)) / z), Float64(y - a), t); else tmp = fma(Float64(y - z), Float64(Float64(t - x) / a), x); end return tmp end
code[x_, y_, z_, t_, a_] := If[Or[LessEqual[z, -70000000000.0], N[Not[LessEqual[z, 9.5e-23]], $MachinePrecision]], N[(N[((-N[(t - x), $MachinePrecision]) / z), $MachinePrecision] * N[(y - a), $MachinePrecision] + t), $MachinePrecision], N[(N[(y - z), $MachinePrecision] * N[(N[(t - x), $MachinePrecision] / a), $MachinePrecision] + x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -70000000000 \lor \neg \left(z \leq 9.5 \cdot 10^{-23}\right):\\
\;\;\;\;\mathsf{fma}\left(\frac{-\left(t - x\right)}{z}, y - a, t\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(y - z, \frac{t - x}{a}, x\right)\\
\end{array}
\end{array}
if z < -7e10 or 9.50000000000000058e-23 < z Initial program 44.7%
Taylor expanded in z around inf
associate--l+N/A
distribute-lft-out--N/A
div-subN/A
+-commutativeN/A
mul-1-negN/A
div-subN/A
associate-/l*N/A
associate-/l*N/A
distribute-rgt-out--N/A
distribute-lft-neg-inN/A
lower-fma.f64N/A
Applied rewrites78.7%
if -7e10 < z < 9.50000000000000058e-23Initial program 90.9%
Taylor expanded in a around inf
+-commutativeN/A
*-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower--.f64N/A
lower-/.f64N/A
lower--.f6481.2
Applied rewrites81.2%
Final simplification80.0%
(FPCore (x y z t a)
:precision binary64
(if (<= z -1.9e+140)
t
(if (<= z -3.5e-102)
(fma (/ x a) z x)
(if (<= z 5.9e+79) (* t (/ (- y z) a)) t))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (z <= -1.9e+140) {
tmp = t;
} else if (z <= -3.5e-102) {
tmp = fma((x / a), z, x);
} else if (z <= 5.9e+79) {
tmp = t * ((y - z) / a);
} else {
tmp = t;
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if (z <= -1.9e+140) tmp = t; elseif (z <= -3.5e-102) tmp = fma(Float64(x / a), z, x); elseif (z <= 5.9e+79) tmp = Float64(t * Float64(Float64(y - z) / a)); else tmp = t; end return tmp end
code[x_, y_, z_, t_, a_] := If[LessEqual[z, -1.9e+140], t, If[LessEqual[z, -3.5e-102], N[(N[(x / a), $MachinePrecision] * z + x), $MachinePrecision], If[LessEqual[z, 5.9e+79], N[(t * N[(N[(y - z), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision], t]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.9 \cdot 10^{+140}:\\
\;\;\;\;t\\
\mathbf{elif}\;z \leq -3.5 \cdot 10^{-102}:\\
\;\;\;\;\mathsf{fma}\left(\frac{x}{a}, z, x\right)\\
\mathbf{elif}\;z \leq 5.9 \cdot 10^{+79}:\\
\;\;\;\;t \cdot \frac{y - z}{a}\\
\mathbf{else}:\\
\;\;\;\;t\\
\end{array}
\end{array}
if z < -1.9e140 or 5.9e79 < z Initial program 26.5%
Taylor expanded in y around 0
+-commutativeN/A
mul-1-negN/A
*-commutativeN/A
associate-/l*N/A
distribute-lft-neg-inN/A
mul-1-negN/A
lower-fma.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower--.f64N/A
lower-/.f64N/A
lower--.f6442.0
Applied rewrites42.0%
Taylor expanded in z around inf
Applied rewrites55.9%
Applied rewrites55.9%
if -1.9e140 < z < -3.49999999999999986e-102Initial program 73.5%
Taylor expanded in y around 0
+-commutativeN/A
mul-1-negN/A
*-commutativeN/A
associate-/l*N/A
distribute-lft-neg-inN/A
mul-1-negN/A
lower-fma.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower--.f64N/A
lower-/.f64N/A
lower--.f6437.9
Applied rewrites37.9%
Taylor expanded in z around 0
Applied rewrites39.8%
Taylor expanded in x around inf
Applied rewrites33.5%
if -3.49999999999999986e-102 < z < 5.9e79Initial program 90.1%
Taylor expanded in x around 0
*-commutativeN/A
associate-/l*N/A
lower-*.f64N/A
lower--.f64N/A
lower-/.f64N/A
lower--.f6452.7
Applied rewrites52.7%
Taylor expanded in a around inf
Applied rewrites47.2%
Final simplification46.2%
(FPCore (x y z t a)
:precision binary64
(if (<= z -1.9e+140)
t
(if (<= z -2.8e-74)
(fma (/ x a) z x)
(if (<= z 1.7e+80) (* t (/ y (- a z))) t))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (z <= -1.9e+140) {
tmp = t;
} else if (z <= -2.8e-74) {
tmp = fma((x / a), z, x);
} else if (z <= 1.7e+80) {
tmp = t * (y / (a - z));
} else {
tmp = t;
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if (z <= -1.9e+140) tmp = t; elseif (z <= -2.8e-74) tmp = fma(Float64(x / a), z, x); elseif (z <= 1.7e+80) tmp = Float64(t * Float64(y / Float64(a - z))); else tmp = t; end return tmp end
code[x_, y_, z_, t_, a_] := If[LessEqual[z, -1.9e+140], t, If[LessEqual[z, -2.8e-74], N[(N[(x / a), $MachinePrecision] * z + x), $MachinePrecision], If[LessEqual[z, 1.7e+80], N[(t * N[(y / N[(a - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.9 \cdot 10^{+140}:\\
\;\;\;\;t\\
\mathbf{elif}\;z \leq -2.8 \cdot 10^{-74}:\\
\;\;\;\;\mathsf{fma}\left(\frac{x}{a}, z, x\right)\\
\mathbf{elif}\;z \leq 1.7 \cdot 10^{+80}:\\
\;\;\;\;t \cdot \frac{y}{a - z}\\
\mathbf{else}:\\
\;\;\;\;t\\
\end{array}
\end{array}
if z < -1.9e140 or 1.69999999999999996e80 < z Initial program 26.5%
Taylor expanded in y around 0
+-commutativeN/A
mul-1-negN/A
*-commutativeN/A
associate-/l*N/A
distribute-lft-neg-inN/A
mul-1-negN/A
lower-fma.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower--.f64N/A
lower-/.f64N/A
lower--.f6442.0
Applied rewrites42.0%
Taylor expanded in z around inf
Applied rewrites55.9%
Applied rewrites55.9%
if -1.9e140 < z < -2.79999999999999988e-74Initial program 69.0%
Taylor expanded in y around 0
+-commutativeN/A
mul-1-negN/A
*-commutativeN/A
associate-/l*N/A
distribute-lft-neg-inN/A
mul-1-negN/A
lower-fma.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower--.f64N/A
lower-/.f64N/A
lower--.f6440.2
Applied rewrites40.2%
Taylor expanded in z around 0
Applied rewrites40.4%
Taylor expanded in x around inf
Applied rewrites33.1%
if -2.79999999999999988e-74 < z < 1.69999999999999996e80Initial program 90.7%
Taylor expanded in x around 0
*-commutativeN/A
associate-/l*N/A
lower-*.f64N/A
lower--.f64N/A
lower-/.f64N/A
lower--.f6452.2
Applied rewrites52.2%
Taylor expanded in y around inf
Applied rewrites45.9%
Final simplification45.9%
(FPCore (x y z t a) :precision binary64 (if (<= z -550000000000.0) (fma (/ x z) (- y a) t) (if (<= z 9.2e-23) (fma (- y z) (/ (- t x) a) x) (fma (/ (- x t) z) y t))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (z <= -550000000000.0) {
tmp = fma((x / z), (y - a), t);
} else if (z <= 9.2e-23) {
tmp = fma((y - z), ((t - x) / a), x);
} else {
tmp = fma(((x - t) / z), y, t);
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if (z <= -550000000000.0) tmp = fma(Float64(x / z), Float64(y - a), t); elseif (z <= 9.2e-23) tmp = fma(Float64(y - z), Float64(Float64(t - x) / a), x); else tmp = fma(Float64(Float64(x - t) / z), y, t); end return tmp end
code[x_, y_, z_, t_, a_] := If[LessEqual[z, -550000000000.0], N[(N[(x / z), $MachinePrecision] * N[(y - a), $MachinePrecision] + t), $MachinePrecision], If[LessEqual[z, 9.2e-23], N[(N[(y - z), $MachinePrecision] * N[(N[(t - x), $MachinePrecision] / a), $MachinePrecision] + x), $MachinePrecision], N[(N[(N[(x - t), $MachinePrecision] / z), $MachinePrecision] * y + t), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -550000000000:\\
\;\;\;\;\mathsf{fma}\left(\frac{x}{z}, y - a, t\right)\\
\mathbf{elif}\;z \leq 9.2 \cdot 10^{-23}:\\
\;\;\;\;\mathsf{fma}\left(y - z, \frac{t - x}{a}, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{x - t}{z}, y, t\right)\\
\end{array}
\end{array}
if z < -5.5e11Initial program 44.9%
Taylor expanded in z around inf
associate--l+N/A
distribute-lft-out--N/A
div-subN/A
+-commutativeN/A
mul-1-negN/A
div-subN/A
associate-/l*N/A
associate-/l*N/A
distribute-rgt-out--N/A
distribute-lft-neg-inN/A
lower-fma.f64N/A
Applied rewrites78.4%
Taylor expanded in x around inf
Applied rewrites71.9%
if -5.5e11 < z < 9.2000000000000004e-23Initial program 90.9%
Taylor expanded in a around inf
+-commutativeN/A
*-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower--.f64N/A
lower-/.f64N/A
lower--.f6481.2
Applied rewrites81.2%
if 9.2000000000000004e-23 < z Initial program 44.4%
Taylor expanded in z around inf
associate--l+N/A
distribute-lft-out--N/A
div-subN/A
+-commutativeN/A
mul-1-negN/A
div-subN/A
associate-/l*N/A
associate-/l*N/A
distribute-rgt-out--N/A
distribute-lft-neg-inN/A
lower-fma.f64N/A
Applied rewrites79.1%
Taylor expanded in a around 0
Applied rewrites70.5%
Final simplification76.6%
(FPCore (x y z t a)
:precision binary64
(if (<= z -1.9e+140)
t
(if (<= z -3.5e-102)
(fma (/ x a) z x)
(if (<= z 1.6e+30) (* t (/ y a)) t))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (z <= -1.9e+140) {
tmp = t;
} else if (z <= -3.5e-102) {
tmp = fma((x / a), z, x);
} else if (z <= 1.6e+30) {
tmp = t * (y / a);
} else {
tmp = t;
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if (z <= -1.9e+140) tmp = t; elseif (z <= -3.5e-102) tmp = fma(Float64(x / a), z, x); elseif (z <= 1.6e+30) tmp = Float64(t * Float64(y / a)); else tmp = t; end return tmp end
code[x_, y_, z_, t_, a_] := If[LessEqual[z, -1.9e+140], t, If[LessEqual[z, -3.5e-102], N[(N[(x / a), $MachinePrecision] * z + x), $MachinePrecision], If[LessEqual[z, 1.6e+30], N[(t * N[(y / a), $MachinePrecision]), $MachinePrecision], t]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.9 \cdot 10^{+140}:\\
\;\;\;\;t\\
\mathbf{elif}\;z \leq -3.5 \cdot 10^{-102}:\\
\;\;\;\;\mathsf{fma}\left(\frac{x}{a}, z, x\right)\\
\mathbf{elif}\;z \leq 1.6 \cdot 10^{+30}:\\
\;\;\;\;t \cdot \frac{y}{a}\\
\mathbf{else}:\\
\;\;\;\;t\\
\end{array}
\end{array}
if z < -1.9e140 or 1.59999999999999986e30 < z Initial program 31.7%
Taylor expanded in y around 0
+-commutativeN/A
mul-1-negN/A
*-commutativeN/A
associate-/l*N/A
distribute-lft-neg-inN/A
mul-1-negN/A
lower-fma.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower--.f64N/A
lower-/.f64N/A
lower--.f6441.0
Applied rewrites41.0%
Taylor expanded in z around inf
Applied rewrites49.7%
Applied rewrites49.7%
if -1.9e140 < z < -3.49999999999999986e-102Initial program 73.5%
Taylor expanded in y around 0
+-commutativeN/A
mul-1-negN/A
*-commutativeN/A
associate-/l*N/A
distribute-lft-neg-inN/A
mul-1-negN/A
lower-fma.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower--.f64N/A
lower-/.f64N/A
lower--.f6437.9
Applied rewrites37.9%
Taylor expanded in z around 0
Applied rewrites39.8%
Taylor expanded in x around inf
Applied rewrites33.5%
if -3.49999999999999986e-102 < z < 1.59999999999999986e30Initial program 93.2%
Taylor expanded in x around 0
*-commutativeN/A
associate-/l*N/A
lower-*.f64N/A
lower--.f64N/A
lower-/.f64N/A
lower--.f6452.8
Applied rewrites52.8%
Taylor expanded in z around 0
Applied rewrites44.4%
Final simplification43.4%
(FPCore (x y z t a) :precision binary64 (if (<= z -1.9e+140) t (if (<= z -7.4e-75) (fma x (/ z a) x) (if (<= z 1.6e+30) (* t (/ y a)) t))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (z <= -1.9e+140) {
tmp = t;
} else if (z <= -7.4e-75) {
tmp = fma(x, (z / a), x);
} else if (z <= 1.6e+30) {
tmp = t * (y / a);
} else {
tmp = t;
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if (z <= -1.9e+140) tmp = t; elseif (z <= -7.4e-75) tmp = fma(x, Float64(z / a), x); elseif (z <= 1.6e+30) tmp = Float64(t * Float64(y / a)); else tmp = t; end return tmp end
code[x_, y_, z_, t_, a_] := If[LessEqual[z, -1.9e+140], t, If[LessEqual[z, -7.4e-75], N[(x * N[(z / a), $MachinePrecision] + x), $MachinePrecision], If[LessEqual[z, 1.6e+30], N[(t * N[(y / a), $MachinePrecision]), $MachinePrecision], t]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.9 \cdot 10^{+140}:\\
\;\;\;\;t\\
\mathbf{elif}\;z \leq -7.4 \cdot 10^{-75}:\\
\;\;\;\;\mathsf{fma}\left(x, \frac{z}{a}, x\right)\\
\mathbf{elif}\;z \leq 1.6 \cdot 10^{+30}:\\
\;\;\;\;t \cdot \frac{y}{a}\\
\mathbf{else}:\\
\;\;\;\;t\\
\end{array}
\end{array}
if z < -1.9e140 or 1.59999999999999986e30 < z Initial program 31.7%
Taylor expanded in y around 0
+-commutativeN/A
mul-1-negN/A
*-commutativeN/A
associate-/l*N/A
distribute-lft-neg-inN/A
mul-1-negN/A
lower-fma.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower--.f64N/A
lower-/.f64N/A
lower--.f6441.0
Applied rewrites41.0%
Taylor expanded in z around inf
Applied rewrites49.7%
Applied rewrites49.7%
if -1.9e140 < z < -7.40000000000000047e-75Initial program 69.0%
Taylor expanded in y around 0
+-commutativeN/A
mul-1-negN/A
*-commutativeN/A
associate-/l*N/A
distribute-lft-neg-inN/A
mul-1-negN/A
lower-fma.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower--.f64N/A
lower-/.f64N/A
lower--.f6440.2
Applied rewrites40.2%
Taylor expanded in t around 0
Applied rewrites30.1%
Taylor expanded in z around 0
Applied rewrites33.1%
if -7.40000000000000047e-75 < z < 1.59999999999999986e30Initial program 93.6%
Taylor expanded in x around 0
*-commutativeN/A
associate-/l*N/A
lower-*.f64N/A
lower--.f64N/A
lower-/.f64N/A
lower--.f6452.3
Applied rewrites52.3%
Taylor expanded in z around 0
Applied rewrites43.3%
Final simplification43.2%
(FPCore (x y z t a) :precision binary64 (if (or (<= a -9e+153) (not (<= a 245.0))) (fma (/ (- x t) a) z x) (fma (/ (- x t) z) y t)))
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((a <= -9e+153) || !(a <= 245.0)) {
tmp = fma(((x - t) / a), z, x);
} else {
tmp = fma(((x - t) / z), y, t);
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if ((a <= -9e+153) || !(a <= 245.0)) tmp = fma(Float64(Float64(x - t) / a), z, x); else tmp = fma(Float64(Float64(x - t) / z), y, t); end return tmp end
code[x_, y_, z_, t_, a_] := If[Or[LessEqual[a, -9e+153], N[Not[LessEqual[a, 245.0]], $MachinePrecision]], N[(N[(N[(x - t), $MachinePrecision] / a), $MachinePrecision] * z + x), $MachinePrecision], N[(N[(N[(x - t), $MachinePrecision] / z), $MachinePrecision] * y + t), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -9 \cdot 10^{+153} \lor \neg \left(a \leq 245\right):\\
\;\;\;\;\mathsf{fma}\left(\frac{x - t}{a}, z, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{x - t}{z}, y, t\right)\\
\end{array}
\end{array}
if a < -9.0000000000000002e153 or 245 < a Initial program 72.2%
Taylor expanded in y around 0
+-commutativeN/A
mul-1-negN/A
*-commutativeN/A
associate-/l*N/A
distribute-lft-neg-inN/A
mul-1-negN/A
lower-fma.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower--.f64N/A
lower-/.f64N/A
lower--.f6458.8
Applied rewrites58.8%
Taylor expanded in z around 0
Applied rewrites51.3%
if -9.0000000000000002e153 < a < 245Initial program 67.9%
Taylor expanded in z around inf
associate--l+N/A
distribute-lft-out--N/A
div-subN/A
+-commutativeN/A
mul-1-negN/A
div-subN/A
associate-/l*N/A
associate-/l*N/A
distribute-rgt-out--N/A
distribute-lft-neg-inN/A
lower-fma.f64N/A
Applied rewrites72.2%
Taylor expanded in a around 0
Applied rewrites66.8%
Final simplification61.4%
(FPCore (x y z t a) :precision binary64 (if (<= z -550000000000.0) (fma (/ x z) (- y a) t) (if (<= z 2.4e-24) (fma (/ y a) (- t x) x) (fma (/ (- x t) z) y t))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (z <= -550000000000.0) {
tmp = fma((x / z), (y - a), t);
} else if (z <= 2.4e-24) {
tmp = fma((y / a), (t - x), x);
} else {
tmp = fma(((x - t) / z), y, t);
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if (z <= -550000000000.0) tmp = fma(Float64(x / z), Float64(y - a), t); elseif (z <= 2.4e-24) tmp = fma(Float64(y / a), Float64(t - x), x); else tmp = fma(Float64(Float64(x - t) / z), y, t); end return tmp end
code[x_, y_, z_, t_, a_] := If[LessEqual[z, -550000000000.0], N[(N[(x / z), $MachinePrecision] * N[(y - a), $MachinePrecision] + t), $MachinePrecision], If[LessEqual[z, 2.4e-24], N[(N[(y / a), $MachinePrecision] * N[(t - x), $MachinePrecision] + x), $MachinePrecision], N[(N[(N[(x - t), $MachinePrecision] / z), $MachinePrecision] * y + t), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -550000000000:\\
\;\;\;\;\mathsf{fma}\left(\frac{x}{z}, y - a, t\right)\\
\mathbf{elif}\;z \leq 2.4 \cdot 10^{-24}:\\
\;\;\;\;\mathsf{fma}\left(\frac{y}{a}, t - x, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{x - t}{z}, y, t\right)\\
\end{array}
\end{array}
if z < -5.5e11Initial program 44.9%
Taylor expanded in z around inf
associate--l+N/A
distribute-lft-out--N/A
div-subN/A
+-commutativeN/A
mul-1-negN/A
div-subN/A
associate-/l*N/A
associate-/l*N/A
distribute-rgt-out--N/A
distribute-lft-neg-inN/A
lower-fma.f64N/A
Applied rewrites78.4%
Taylor expanded in x around inf
Applied rewrites71.9%
if -5.5e11 < z < 2.3999999999999998e-24Initial program 90.9%
lift-+.f64N/A
+-commutativeN/A
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f6498.1
Applied rewrites98.1%
Taylor expanded in z around 0
lower-/.f6479.9
Applied rewrites79.9%
if 2.3999999999999998e-24 < z Initial program 44.4%
Taylor expanded in z around inf
associate--l+N/A
distribute-lft-out--N/A
div-subN/A
+-commutativeN/A
mul-1-negN/A
div-subN/A
associate-/l*N/A
associate-/l*N/A
distribute-rgt-out--N/A
distribute-lft-neg-inN/A
lower-fma.f64N/A
Applied rewrites79.1%
Taylor expanded in a around 0
Applied rewrites70.5%
Final simplification75.9%
(FPCore (x y z t a) :precision binary64 (if (<= z -550000000000.0) (fma (/ x z) (- y a) t) (if (<= z 2.4e-24) (fma (/ (- t x) a) y x) (fma (/ (- x t) z) y t))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (z <= -550000000000.0) {
tmp = fma((x / z), (y - a), t);
} else if (z <= 2.4e-24) {
tmp = fma(((t - x) / a), y, x);
} else {
tmp = fma(((x - t) / z), y, t);
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if (z <= -550000000000.0) tmp = fma(Float64(x / z), Float64(y - a), t); elseif (z <= 2.4e-24) tmp = fma(Float64(Float64(t - x) / a), y, x); else tmp = fma(Float64(Float64(x - t) / z), y, t); end return tmp end
code[x_, y_, z_, t_, a_] := If[LessEqual[z, -550000000000.0], N[(N[(x / z), $MachinePrecision] * N[(y - a), $MachinePrecision] + t), $MachinePrecision], If[LessEqual[z, 2.4e-24], N[(N[(N[(t - x), $MachinePrecision] / a), $MachinePrecision] * y + x), $MachinePrecision], N[(N[(N[(x - t), $MachinePrecision] / z), $MachinePrecision] * y + t), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -550000000000:\\
\;\;\;\;\mathsf{fma}\left(\frac{x}{z}, y - a, t\right)\\
\mathbf{elif}\;z \leq 2.4 \cdot 10^{-24}:\\
\;\;\;\;\mathsf{fma}\left(\frac{t - x}{a}, y, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{x - t}{z}, y, t\right)\\
\end{array}
\end{array}
if z < -5.5e11Initial program 44.9%
Taylor expanded in z around inf
associate--l+N/A
distribute-lft-out--N/A
div-subN/A
+-commutativeN/A
mul-1-negN/A
div-subN/A
associate-/l*N/A
associate-/l*N/A
distribute-rgt-out--N/A
distribute-lft-neg-inN/A
lower-fma.f64N/A
Applied rewrites78.4%
Taylor expanded in x around inf
Applied rewrites71.9%
if -5.5e11 < z < 2.3999999999999998e-24Initial program 90.9%
Taylor expanded in z around 0
+-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
lower--.f6478.4
Applied rewrites78.4%
if 2.3999999999999998e-24 < z Initial program 44.4%
Taylor expanded in z around inf
associate--l+N/A
distribute-lft-out--N/A
div-subN/A
+-commutativeN/A
mul-1-negN/A
div-subN/A
associate-/l*N/A
associate-/l*N/A
distribute-rgt-out--N/A
distribute-lft-neg-inN/A
lower-fma.f64N/A
Applied rewrites79.1%
Taylor expanded in a around 0
Applied rewrites70.5%
Final simplification75.1%
(FPCore (x y z t a) :precision binary64 (if (or (<= z -110000000000.0) (not (<= z 1.6e+30))) t (* t (/ y a))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((z <= -110000000000.0) || !(z <= 1.6e+30)) {
tmp = t;
} else {
tmp = t * (y / a);
}
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, a)
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), intent (in) :: a
real(8) :: tmp
if ((z <= (-110000000000.0d0)) .or. (.not. (z <= 1.6d+30))) then
tmp = t
else
tmp = t * (y / a)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a) {
double tmp;
if ((z <= -110000000000.0) || !(z <= 1.6e+30)) {
tmp = t;
} else {
tmp = t * (y / a);
}
return tmp;
}
def code(x, y, z, t, a): tmp = 0 if (z <= -110000000000.0) or not (z <= 1.6e+30): tmp = t else: tmp = t * (y / a) return tmp
function code(x, y, z, t, a) tmp = 0.0 if ((z <= -110000000000.0) || !(z <= 1.6e+30)) tmp = t; else tmp = Float64(t * Float64(y / a)); end return tmp end
function tmp_2 = code(x, y, z, t, a) tmp = 0.0; if ((z <= -110000000000.0) || ~((z <= 1.6e+30))) tmp = t; else tmp = t * (y / a); end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := If[Or[LessEqual[z, -110000000000.0], N[Not[LessEqual[z, 1.6e+30]], $MachinePrecision]], t, N[(t * N[(y / a), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -110000000000 \lor \neg \left(z \leq 1.6 \cdot 10^{+30}\right):\\
\;\;\;\;t\\
\mathbf{else}:\\
\;\;\;\;t \cdot \frac{y}{a}\\
\end{array}
\end{array}
if z < -1.1e11 or 1.59999999999999986e30 < z Initial program 41.2%
Taylor expanded in y around 0
+-commutativeN/A
mul-1-negN/A
*-commutativeN/A
associate-/l*N/A
distribute-lft-neg-inN/A
mul-1-negN/A
lower-fma.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower--.f64N/A
lower-/.f64N/A
lower--.f6438.6
Applied rewrites38.6%
Taylor expanded in z around inf
Applied rewrites38.9%
Applied rewrites38.9%
if -1.1e11 < z < 1.59999999999999986e30Initial program 90.7%
Taylor expanded in x around 0
*-commutativeN/A
associate-/l*N/A
lower-*.f64N/A
lower--.f64N/A
lower-/.f64N/A
lower--.f6448.9
Applied rewrites48.9%
Taylor expanded in z around 0
Applied rewrites39.8%
Final simplification39.5%
(FPCore (x y z t a) :precision binary64 t)
double code(double x, double y, double z, double t, double a) {
return 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, a)
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), intent (in) :: a
code = t
end function
public static double code(double x, double y, double z, double t, double a) {
return t;
}
def code(x, y, z, t, a): return t
function code(x, y, z, t, a) return t end
function tmp = code(x, y, z, t, a) tmp = t; end
code[x_, y_, z_, t_, a_] := t
\begin{array}{l}
\\
t
\end{array}
Initial program 69.4%
Taylor expanded in y around 0
+-commutativeN/A
mul-1-negN/A
*-commutativeN/A
associate-/l*N/A
distribute-lft-neg-inN/A
mul-1-negN/A
lower-fma.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower--.f64N/A
lower-/.f64N/A
lower--.f6436.9
Applied rewrites36.9%
Taylor expanded in z around inf
Applied rewrites19.9%
Applied rewrites19.9%
Final simplification19.9%
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (- t (* (/ y z) (- t x)))))
(if (< z -1.2536131056095036e+188)
t_1
(if (< z 4.446702369113811e+64)
(+ x (/ (- y z) (/ (- a z) (- t x))))
t_1))))
double code(double x, double y, double z, double t, double a) {
double t_1 = t - ((y / z) * (t - x));
double tmp;
if (z < -1.2536131056095036e+188) {
tmp = t_1;
} else if (z < 4.446702369113811e+64) {
tmp = x + ((y - z) / ((a - z) / (t - x)));
} else {
tmp = t_1;
}
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, a)
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), intent (in) :: a
real(8) :: t_1
real(8) :: tmp
t_1 = t - ((y / z) * (t - x))
if (z < (-1.2536131056095036d+188)) then
tmp = t_1
else if (z < 4.446702369113811d+64) then
tmp = x + ((y - z) / ((a - z) / (t - x)))
else
tmp = t_1
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a) {
double t_1 = t - ((y / z) * (t - x));
double tmp;
if (z < -1.2536131056095036e+188) {
tmp = t_1;
} else if (z < 4.446702369113811e+64) {
tmp = x + ((y - z) / ((a - z) / (t - x)));
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z, t, a): t_1 = t - ((y / z) * (t - x)) tmp = 0 if z < -1.2536131056095036e+188: tmp = t_1 elif z < 4.446702369113811e+64: tmp = x + ((y - z) / ((a - z) / (t - x))) else: tmp = t_1 return tmp
function code(x, y, z, t, a) t_1 = Float64(t - Float64(Float64(y / z) * Float64(t - x))) tmp = 0.0 if (z < -1.2536131056095036e+188) tmp = t_1; elseif (z < 4.446702369113811e+64) tmp = Float64(x + Float64(Float64(y - z) / Float64(Float64(a - z) / Float64(t - x)))); else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z, t, a) t_1 = t - ((y / z) * (t - x)); tmp = 0.0; if (z < -1.2536131056095036e+188) tmp = t_1; elseif (z < 4.446702369113811e+64) tmp = x + ((y - z) / ((a - z) / (t - x))); else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(t - N[(N[(y / z), $MachinePrecision] * N[(t - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[Less[z, -1.2536131056095036e+188], t$95$1, If[Less[z, 4.446702369113811e+64], N[(x + N[(N[(y - z), $MachinePrecision] / N[(N[(a - z), $MachinePrecision] / N[(t - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := t - \frac{y}{z} \cdot \left(t - x\right)\\
\mathbf{if}\;z < -1.2536131056095036 \cdot 10^{+188}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z < 4.446702369113811 \cdot 10^{+64}:\\
\;\;\;\;x + \frac{y - z}{\frac{a - z}{t - x}}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
herbie shell --seed 2024352
(FPCore (x y z t a)
:name "Graphics.Rendering.Chart.Axis.Types:invLinMap from Chart-1.5.3"
:precision binary64
:alt
(! :herbie-platform default (if (< z -125361310560950360000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000) (- t (* (/ y z) (- t x))) (if (< z 44467023691138110000000000000000000000000000000000000000000000000) (+ x (/ (- y z) (/ (- a z) (- t x)))) (- t (* (/ y z) (- t x))))))
(+ x (/ (* (- y z) (- t x)) (- a z))))