
(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 17 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 (+ x (/ (* (- y z) (- t x)) (- a z)))))
(if (<= t_1 (- INFINITY))
(fma (/ (fma -1.0 t x) z) (- y a) t)
(if (<= t_1 -1e-263)
t_1
(if (<= t_1 0.0)
(fma (- (- t x)) (/ (- y a) z) t)
(if (<= t_1 1e+291)
t_1
(+ x (* (* (/ (- t x) (- a z)) (- 1.0 (/ z y))) y))))))))
double code(double x, double y, double z, double t, double a) {
double t_1 = x + (((y - z) * (t - x)) / (a - z));
double tmp;
if (t_1 <= -((double) INFINITY)) {
tmp = fma((fma(-1.0, t, x) / z), (y - a), t);
} else if (t_1 <= -1e-263) {
tmp = t_1;
} else if (t_1 <= 0.0) {
tmp = fma(-(t - x), ((y - a) / z), t);
} else if (t_1 <= 1e+291) {
tmp = t_1;
} else {
tmp = x + ((((t - x) / (a - z)) * (1.0 - (z / y))) * y);
}
return tmp;
}
function code(x, y, z, t, a) t_1 = Float64(x + Float64(Float64(Float64(y - z) * Float64(t - x)) / Float64(a - z))) tmp = 0.0 if (t_1 <= Float64(-Inf)) tmp = fma(Float64(fma(-1.0, t, x) / z), Float64(y - a), t); elseif (t_1 <= -1e-263) tmp = t_1; elseif (t_1 <= 0.0) tmp = fma(Float64(-Float64(t - x)), Float64(Float64(y - a) / z), t); elseif (t_1 <= 1e+291) tmp = t_1; else tmp = Float64(x + Float64(Float64(Float64(Float64(t - x) / Float64(a - z)) * Float64(1.0 - Float64(z / y))) * y)); end return tmp end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(x + N[(N[(N[(y - z), $MachinePrecision] * N[(t - x), $MachinePrecision]), $MachinePrecision] / N[(a - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, (-Infinity)], N[(N[(N[(-1.0 * t + x), $MachinePrecision] / z), $MachinePrecision] * N[(y - a), $MachinePrecision] + t), $MachinePrecision], If[LessEqual[t$95$1, -1e-263], t$95$1, If[LessEqual[t$95$1, 0.0], N[((-N[(t - x), $MachinePrecision]) * N[(N[(y - a), $MachinePrecision] / z), $MachinePrecision] + t), $MachinePrecision], If[LessEqual[t$95$1, 1e+291], t$95$1, N[(x + N[(N[(N[(N[(t - x), $MachinePrecision] / N[(a - z), $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(z / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := x + \frac{\left(y - z\right) \cdot \left(t - x\right)}{a - z}\\
\mathbf{if}\;t\_1 \leq -\infty:\\
\;\;\;\;\mathsf{fma}\left(\frac{\mathsf{fma}\left(-1, t, x\right)}{z}, y - a, t\right)\\
\mathbf{elif}\;t\_1 \leq -1 \cdot 10^{-263}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_1 \leq 0:\\
\;\;\;\;\mathsf{fma}\left(-\left(t - x\right), \frac{y - a}{z}, t\right)\\
\mathbf{elif}\;t\_1 \leq 10^{+291}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;x + \left(\frac{t - x}{a - z} \cdot \left(1 - \frac{z}{y}\right)\right) \cdot y\\
\end{array}
\end{array}
if (+.f64 x (/.f64 (*.f64 (-.f64 y z) (-.f64 t x)) (-.f64 a z))) < -inf.0Initial program 36.1%
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 rewrites73.3%
if -inf.0 < (+.f64 x (/.f64 (*.f64 (-.f64 y z) (-.f64 t x)) (-.f64 a z))) < -1e-263 or 0.0 < (+.f64 x (/.f64 (*.f64 (-.f64 y z) (-.f64 t x)) (-.f64 a z))) < 9.9999999999999996e290Initial program 96.8%
if -1e-263 < (+.f64 x (/.f64 (*.f64 (-.f64 y z) (-.f64 t x)) (-.f64 a z))) < 0.0Initial program 9.1%
Taylor expanded in y around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites8.7%
Taylor expanded in x around 0
Applied rewrites3.3%
Taylor expanded in z around inf
associate--l+N/A
associate-*r/N/A
associate-*r/N/A
associate-*r*N/A
mul-1-negN/A
div-subN/A
mul-1-negN/A
associate-*r*N/A
distribute-lft-out--N/A
associate-*r/N/A
+-commutativeN/A
Applied rewrites99.9%
if 9.9999999999999996e290 < (+.f64 x (/.f64 (*.f64 (-.f64 y z) (-.f64 t x)) (-.f64 a z))) Initial program 40.8%
Taylor expanded in y around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites70.1%
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (fma (/ (fma -1.0 t x) z) (- y a) t))
(t_2 (+ x (/ (* (- y z) (- t x)) (- a z)))))
(if (<= t_2 (- INFINITY))
t_1
(if (<= t_2 -1e-263)
t_2
(if (<= t_2 0.0)
(fma (- (- t x)) (/ (- y a) z) t)
(if (<= t_2 5e+298) t_2 t_1))))))
double code(double x, double y, double z, double t, double a) {
double t_1 = fma((fma(-1.0, t, x) / z), (y - a), t);
double t_2 = x + (((y - z) * (t - x)) / (a - z));
double tmp;
if (t_2 <= -((double) INFINITY)) {
tmp = t_1;
} else if (t_2 <= -1e-263) {
tmp = t_2;
} else if (t_2 <= 0.0) {
tmp = fma(-(t - x), ((y - a) / z), t);
} else if (t_2 <= 5e+298) {
tmp = t_2;
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a) t_1 = fma(Float64(fma(-1.0, t, x) / z), Float64(y - a), t) t_2 = Float64(x + Float64(Float64(Float64(y - z) * Float64(t - x)) / Float64(a - z))) tmp = 0.0 if (t_2 <= Float64(-Inf)) tmp = t_1; elseif (t_2 <= -1e-263) tmp = t_2; elseif (t_2 <= 0.0) tmp = fma(Float64(-Float64(t - x)), Float64(Float64(y - a) / z), t); elseif (t_2 <= 5e+298) tmp = t_2; else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(N[(N[(-1.0 * t + x), $MachinePrecision] / z), $MachinePrecision] * N[(y - a), $MachinePrecision] + t), $MachinePrecision]}, Block[{t$95$2 = N[(x + N[(N[(N[(y - z), $MachinePrecision] * N[(t - x), $MachinePrecision]), $MachinePrecision] / N[(a - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$2, (-Infinity)], t$95$1, If[LessEqual[t$95$2, -1e-263], t$95$2, If[LessEqual[t$95$2, 0.0], N[((-N[(t - x), $MachinePrecision]) * N[(N[(y - a), $MachinePrecision] / z), $MachinePrecision] + t), $MachinePrecision], If[LessEqual[t$95$2, 5e+298], t$95$2, t$95$1]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(\frac{\mathsf{fma}\left(-1, t, x\right)}{z}, y - a, t\right)\\
t_2 := x + \frac{\left(y - z\right) \cdot \left(t - x\right)}{a - z}\\
\mathbf{if}\;t\_2 \leq -\infty:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_2 \leq -1 \cdot 10^{-263}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;t\_2 \leq 0:\\
\;\;\;\;\mathsf{fma}\left(-\left(t - x\right), \frac{y - a}{z}, t\right)\\
\mathbf{elif}\;t\_2 \leq 5 \cdot 10^{+298}:\\
\;\;\;\;t\_2\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (+.f64 x (/.f64 (*.f64 (-.f64 y z) (-.f64 t x)) (-.f64 a z))) < -inf.0 or 5.0000000000000003e298 < (+.f64 x (/.f64 (*.f64 (-.f64 y z) (-.f64 t x)) (-.f64 a z))) Initial program 37.0%
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 rewrites71.1%
if -inf.0 < (+.f64 x (/.f64 (*.f64 (-.f64 y z) (-.f64 t x)) (-.f64 a z))) < -1e-263 or 0.0 < (+.f64 x (/.f64 (*.f64 (-.f64 y z) (-.f64 t x)) (-.f64 a z))) < 5.0000000000000003e298Initial program 96.8%
if -1e-263 < (+.f64 x (/.f64 (*.f64 (-.f64 y z) (-.f64 t x)) (-.f64 a z))) < 0.0Initial program 9.1%
Taylor expanded in y around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites8.7%
Taylor expanded in x around 0
Applied rewrites3.3%
Taylor expanded in z around inf
associate--l+N/A
associate-*r/N/A
associate-*r/N/A
associate-*r*N/A
mul-1-negN/A
div-subN/A
mul-1-negN/A
associate-*r*N/A
distribute-lft-out--N/A
associate-*r/N/A
+-commutativeN/A
Applied rewrites99.9%
(FPCore (x y z t a) :precision binary64 (if (or (<= a -3.5e+72) (not (<= a 5.3e-30))) (fma (- y z) (/ (- t x) a) x) (fma (- (- t x)) (/ (- y a) z) t)))
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((a <= -3.5e+72) || !(a <= 5.3e-30)) {
tmp = fma((y - z), ((t - x) / a), x);
} else {
tmp = fma(-(t - x), ((y - a) / z), t);
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if ((a <= -3.5e+72) || !(a <= 5.3e-30)) tmp = fma(Float64(y - z), Float64(Float64(t - x) / a), x); else tmp = fma(Float64(-Float64(t - x)), Float64(Float64(y - a) / z), t); end return tmp end
code[x_, y_, z_, t_, a_] := If[Or[LessEqual[a, -3.5e+72], N[Not[LessEqual[a, 5.3e-30]], $MachinePrecision]], N[(N[(y - z), $MachinePrecision] * N[(N[(t - x), $MachinePrecision] / a), $MachinePrecision] + x), $MachinePrecision], N[((-N[(t - x), $MachinePrecision]) * N[(N[(y - a), $MachinePrecision] / z), $MachinePrecision] + t), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -3.5 \cdot 10^{+72} \lor \neg \left(a \leq 5.3 \cdot 10^{-30}\right):\\
\;\;\;\;\mathsf{fma}\left(y - z, \frac{t - x}{a}, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(-\left(t - x\right), \frac{y - a}{z}, t\right)\\
\end{array}
\end{array}
if a < -3.5000000000000001e72 or 5.29999999999999974e-30 < a Initial program 70.7%
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--.f6482.9
Applied rewrites82.9%
if -3.5000000000000001e72 < a < 5.29999999999999974e-30Initial program 67.8%
Taylor expanded in y around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites59.4%
Taylor expanded in x around 0
Applied rewrites48.0%
Taylor expanded in z around inf
associate--l+N/A
associate-*r/N/A
associate-*r/N/A
associate-*r*N/A
mul-1-negN/A
div-subN/A
mul-1-negN/A
associate-*r*N/A
distribute-lft-out--N/A
associate-*r/N/A
+-commutativeN/A
Applied rewrites78.8%
Final simplification80.6%
(FPCore (x y z t a) :precision binary64 (if (or (<= a -1.8e-14) (not (<= a 2.7e-30))) (fma (- y z) (/ (- t x) a) x) (fma (- y) (/ (- t x) z) t)))
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((a <= -1.8e-14) || !(a <= 2.7e-30)) {
tmp = fma((y - z), ((t - x) / a), x);
} else {
tmp = fma(-y, ((t - x) / z), t);
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if ((a <= -1.8e-14) || !(a <= 2.7e-30)) tmp = fma(Float64(y - z), Float64(Float64(t - x) / a), x); else tmp = fma(Float64(-y), Float64(Float64(t - x) / z), t); end return tmp end
code[x_, y_, z_, t_, a_] := If[Or[LessEqual[a, -1.8e-14], N[Not[LessEqual[a, 2.7e-30]], $MachinePrecision]], N[(N[(y - z), $MachinePrecision] * N[(N[(t - x), $MachinePrecision] / a), $MachinePrecision] + x), $MachinePrecision], N[((-y) * N[(N[(t - x), $MachinePrecision] / z), $MachinePrecision] + t), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -1.8 \cdot 10^{-14} \lor \neg \left(a \leq 2.7 \cdot 10^{-30}\right):\\
\;\;\;\;\mathsf{fma}\left(y - z, \frac{t - x}{a}, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(-y, \frac{t - x}{z}, t\right)\\
\end{array}
\end{array}
if a < -1.7999999999999999e-14 or 2.69999999999999987e-30 < a Initial program 69.0%
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--.f6477.6
Applied rewrites77.6%
if -1.7999999999999999e-14 < a < 2.69999999999999987e-30Initial program 69.1%
Taylor expanded in y around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites57.7%
Taylor expanded in z around inf
associate--l+N/A
associate-*r/N/A
associate-*r/N/A
associate-*r*N/A
mul-1-negN/A
div-subN/A
mul-1-negN/A
associate-*r*N/A
distribute-lft-out--N/A
associate-*r/N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites78.3%
Taylor expanded in a around 0
Applied rewrites76.3%
Final simplification77.0%
(FPCore (x y z t a) :precision binary64 (if (or (<= a -1.45e-45) (not (<= a 2.7e-30))) (fma (/ (- t x) a) y x) (fma (- y) (/ (- t x) z) t)))
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((a <= -1.45e-45) || !(a <= 2.7e-30)) {
tmp = fma(((t - x) / a), y, x);
} else {
tmp = fma(-y, ((t - x) / z), t);
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if ((a <= -1.45e-45) || !(a <= 2.7e-30)) tmp = fma(Float64(Float64(t - x) / a), y, x); else tmp = fma(Float64(-y), Float64(Float64(t - x) / z), t); end return tmp end
code[x_, y_, z_, t_, a_] := If[Or[LessEqual[a, -1.45e-45], N[Not[LessEqual[a, 2.7e-30]], $MachinePrecision]], N[(N[(N[(t - x), $MachinePrecision] / a), $MachinePrecision] * y + x), $MachinePrecision], N[((-y) * N[(N[(t - x), $MachinePrecision] / z), $MachinePrecision] + t), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -1.45 \cdot 10^{-45} \lor \neg \left(a \leq 2.7 \cdot 10^{-30}\right):\\
\;\;\;\;\mathsf{fma}\left(\frac{t - x}{a}, y, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(-y, \frac{t - x}{z}, t\right)\\
\end{array}
\end{array}
if a < -1.45e-45 or 2.69999999999999987e-30 < a Initial program 69.7%
Taylor expanded in z around 0
+-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
lower--.f6466.7
Applied rewrites66.7%
if -1.45e-45 < a < 2.69999999999999987e-30Initial program 68.3%
Taylor expanded in y around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites57.3%
Taylor expanded in z around inf
associate--l+N/A
associate-*r/N/A
associate-*r/N/A
associate-*r*N/A
mul-1-negN/A
div-subN/A
mul-1-negN/A
associate-*r*N/A
distribute-lft-out--N/A
associate-*r/N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites79.1%
Taylor expanded in a around 0
Applied rewrites77.7%
Final simplification71.8%
(FPCore (x y z t a) :precision binary64 (if (or (<= z -5e-37) (not (<= z 7.2e-14))) (fma (- y) (/ (- x) z) t) (fma (/ (- t x) a) y x)))
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((z <= -5e-37) || !(z <= 7.2e-14)) {
tmp = fma(-y, (-x / z), t);
} else {
tmp = fma(((t - x) / a), y, x);
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if ((z <= -5e-37) || !(z <= 7.2e-14)) tmp = fma(Float64(-y), Float64(Float64(-x) / z), t); else tmp = fma(Float64(Float64(t - x) / a), y, x); end return tmp end
code[x_, y_, z_, t_, a_] := If[Or[LessEqual[z, -5e-37], N[Not[LessEqual[z, 7.2e-14]], $MachinePrecision]], N[((-y) * N[((-x) / z), $MachinePrecision] + t), $MachinePrecision], N[(N[(N[(t - x), $MachinePrecision] / a), $MachinePrecision] * y + x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -5 \cdot 10^{-37} \lor \neg \left(z \leq 7.2 \cdot 10^{-14}\right):\\
\;\;\;\;\mathsf{fma}\left(-y, \frac{-x}{z}, t\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{t - x}{a}, y, x\right)\\
\end{array}
\end{array}
if z < -4.9999999999999997e-37 or 7.1999999999999996e-14 < z Initial program 50.7%
Taylor expanded in y around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites53.1%
Taylor expanded in z around inf
associate--l+N/A
associate-*r/N/A
associate-*r/N/A
associate-*r*N/A
mul-1-negN/A
div-subN/A
mul-1-negN/A
associate-*r*N/A
distribute-lft-out--N/A
associate-*r/N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites65.5%
Taylor expanded in a around 0
Applied rewrites67.3%
Taylor expanded in x around inf
Applied rewrites60.1%
if -4.9999999999999997e-37 < z < 7.1999999999999996e-14Initial program 87.7%
Taylor expanded in z around 0
+-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
lower--.f6475.4
Applied rewrites75.4%
Final simplification67.7%
(FPCore (x y z t a) :precision binary64 (if (or (<= a -1.8e-14) (not (<= a 3.1e-47))) (fma (/ (- t x) a) y x) (fma (- t) (/ y z) t)))
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((a <= -1.8e-14) || !(a <= 3.1e-47)) {
tmp = fma(((t - x) / a), y, x);
} else {
tmp = fma(-t, (y / z), t);
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if ((a <= -1.8e-14) || !(a <= 3.1e-47)) tmp = fma(Float64(Float64(t - x) / a), y, x); else tmp = fma(Float64(-t), Float64(y / z), t); end return tmp end
code[x_, y_, z_, t_, a_] := If[Or[LessEqual[a, -1.8e-14], N[Not[LessEqual[a, 3.1e-47]], $MachinePrecision]], N[(N[(N[(t - x), $MachinePrecision] / a), $MachinePrecision] * y + x), $MachinePrecision], N[((-t) * N[(y / z), $MachinePrecision] + t), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -1.8 \cdot 10^{-14} \lor \neg \left(a \leq 3.1 \cdot 10^{-47}\right):\\
\;\;\;\;\mathsf{fma}\left(\frac{t - x}{a}, y, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(-t, \frac{y}{z}, t\right)\\
\end{array}
\end{array}
if a < -1.7999999999999999e-14 or 3.0999999999999998e-47 < a Initial program 68.5%
Taylor expanded in z around 0
+-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
lower--.f6467.2
Applied rewrites67.2%
if -1.7999999999999999e-14 < a < 3.0999999999999998e-47Initial program 69.6%
Taylor expanded in y around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites57.1%
Taylor expanded in z around inf
associate--l+N/A
associate-*r/N/A
associate-*r/N/A
associate-*r*N/A
mul-1-negN/A
div-subN/A
mul-1-negN/A
associate-*r*N/A
distribute-lft-out--N/A
associate-*r/N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites79.9%
Taylor expanded in a around 0
Applied rewrites76.3%
Taylor expanded in x around 0
Applied rewrites63.4%
Final simplification65.4%
(FPCore (x y z t a) :precision binary64 (if (or (<= a -1.8e-14) (not (<= a 2.3e-68))) (+ x (* (/ y a) t)) (fma (- t) (/ y z) t)))
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((a <= -1.8e-14) || !(a <= 2.3e-68)) {
tmp = x + ((y / a) * t);
} else {
tmp = fma(-t, (y / z), t);
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if ((a <= -1.8e-14) || !(a <= 2.3e-68)) tmp = Float64(x + Float64(Float64(y / a) * t)); else tmp = fma(Float64(-t), Float64(y / z), t); end return tmp end
code[x_, y_, z_, t_, a_] := If[Or[LessEqual[a, -1.8e-14], N[Not[LessEqual[a, 2.3e-68]], $MachinePrecision]], N[(x + N[(N[(y / a), $MachinePrecision] * t), $MachinePrecision]), $MachinePrecision], N[((-t) * N[(y / z), $MachinePrecision] + t), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -1.8 \cdot 10^{-14} \lor \neg \left(a \leq 2.3 \cdot 10^{-68}\right):\\
\;\;\;\;x + \frac{y}{a} \cdot t\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(-t, \frac{y}{z}, t\right)\\
\end{array}
\end{array}
if a < -1.7999999999999999e-14 or 2.29999999999999997e-68 < a Initial program 69.0%
Taylor expanded in z around 0
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f6458.4
Applied rewrites58.4%
Taylor expanded in t around inf
Applied rewrites61.8%
Taylor expanded in x around 0
Applied rewrites60.2%
if -1.7999999999999999e-14 < a < 2.29999999999999997e-68Initial program 69.1%
Taylor expanded in y around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites56.9%
Taylor expanded in z around inf
associate--l+N/A
associate-*r/N/A
associate-*r/N/A
associate-*r*N/A
mul-1-negN/A
div-subN/A
mul-1-negN/A
associate-*r*N/A
distribute-lft-out--N/A
associate-*r/N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites82.5%
Taylor expanded in a around 0
Applied rewrites77.7%
Taylor expanded in x around 0
Applied rewrites64.4%
Final simplification62.0%
(FPCore (x y z t a) :precision binary64 (if (or (<= a -4.6e+86) (not (<= a 8.5e+25))) (* (- y z) (/ t a)) (fma (- t) (/ y z) t)))
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((a <= -4.6e+86) || !(a <= 8.5e+25)) {
tmp = (y - z) * (t / a);
} else {
tmp = fma(-t, (y / z), t);
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if ((a <= -4.6e+86) || !(a <= 8.5e+25)) tmp = Float64(Float64(y - z) * Float64(t / a)); else tmp = fma(Float64(-t), Float64(y / z), t); end return tmp end
code[x_, y_, z_, t_, a_] := If[Or[LessEqual[a, -4.6e+86], N[Not[LessEqual[a, 8.5e+25]], $MachinePrecision]], N[(N[(y - z), $MachinePrecision] * N[(t / a), $MachinePrecision]), $MachinePrecision], N[((-t) * N[(y / z), $MachinePrecision] + t), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -4.6 \cdot 10^{+86} \lor \neg \left(a \leq 8.5 \cdot 10^{+25}\right):\\
\;\;\;\;\left(y - z\right) \cdot \frac{t}{a}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(-t, \frac{y}{z}, t\right)\\
\end{array}
\end{array}
if a < -4.59999999999999979e86 or 8.5000000000000007e25 < a Initial program 68.8%
Taylor expanded in x around 0
*-commutativeN/A
associate-/l*N/A
lower-*.f64N/A
lower--.f64N/A
lower-/.f64N/A
lower--.f6443.9
Applied rewrites43.9%
Taylor expanded in z around 0
Applied rewrites37.9%
if -4.59999999999999979e86 < a < 8.5000000000000007e25Initial program 69.2%
Taylor expanded in y around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites61.7%
Taylor expanded in z around inf
associate--l+N/A
associate-*r/N/A
associate-*r/N/A
associate-*r*N/A
mul-1-negN/A
div-subN/A
mul-1-negN/A
associate-*r*N/A
distribute-lft-out--N/A
associate-*r/N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites70.0%
Taylor expanded in a around 0
Applied rewrites67.0%
Taylor expanded in x around 0
Applied rewrites54.6%
Final simplification48.6%
(FPCore (x y z t a) :precision binary64 (if (or (<= z -1.65e-37) (not (<= z 1.04e-72))) (fma (- t) (/ y z) t) (* t (/ y (- a z)))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((z <= -1.65e-37) || !(z <= 1.04e-72)) {
tmp = fma(-t, (y / z), t);
} else {
tmp = t * (y / (a - z));
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if ((z <= -1.65e-37) || !(z <= 1.04e-72)) tmp = fma(Float64(-t), Float64(y / z), t); else tmp = Float64(t * Float64(y / Float64(a - z))); end return tmp end
code[x_, y_, z_, t_, a_] := If[Or[LessEqual[z, -1.65e-37], N[Not[LessEqual[z, 1.04e-72]], $MachinePrecision]], N[((-t) * N[(y / z), $MachinePrecision] + t), $MachinePrecision], N[(t * N[(y / N[(a - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.65 \cdot 10^{-37} \lor \neg \left(z \leq 1.04 \cdot 10^{-72}\right):\\
\;\;\;\;\mathsf{fma}\left(-t, \frac{y}{z}, t\right)\\
\mathbf{else}:\\
\;\;\;\;t \cdot \frac{y}{a - z}\\
\end{array}
\end{array}
if z < -1.64999999999999991e-37 or 1.04e-72 < z Initial program 53.6%
Taylor expanded in y around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites54.8%
Taylor expanded in z around inf
associate--l+N/A
associate-*r/N/A
associate-*r/N/A
associate-*r*N/A
mul-1-negN/A
div-subN/A
mul-1-negN/A
associate-*r*N/A
distribute-lft-out--N/A
associate-*r/N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites64.0%
Taylor expanded in a around 0
Applied rewrites65.3%
Taylor expanded in x around 0
Applied rewrites49.9%
if -1.64999999999999991e-37 < z < 1.04e-72Initial program 87.7%
Taylor expanded in x around 0
*-commutativeN/A
associate-/l*N/A
lower-*.f64N/A
lower--.f64N/A
lower-/.f64N/A
lower--.f6446.6
Applied rewrites46.6%
Taylor expanded in y around inf
Applied rewrites45.8%
Final simplification48.0%
(FPCore (x y z t a) :precision binary64 (if (<= z -1.65e-37) (fma (- t) (/ y z) t) (if (<= z 1.12e-72) (* t (/ y (- a z))) (fma (- y) (/ t z) t))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (z <= -1.65e-37) {
tmp = fma(-t, (y / z), t);
} else if (z <= 1.12e-72) {
tmp = t * (y / (a - z));
} else {
tmp = fma(-y, (t / z), t);
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if (z <= -1.65e-37) tmp = fma(Float64(-t), Float64(y / z), t); elseif (z <= 1.12e-72) tmp = Float64(t * Float64(y / Float64(a - z))); else tmp = fma(Float64(-y), Float64(t / z), t); end return tmp end
code[x_, y_, z_, t_, a_] := If[LessEqual[z, -1.65e-37], N[((-t) * N[(y / z), $MachinePrecision] + t), $MachinePrecision], If[LessEqual[z, 1.12e-72], N[(t * N[(y / N[(a - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[((-y) * N[(t / z), $MachinePrecision] + t), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.65 \cdot 10^{-37}:\\
\;\;\;\;\mathsf{fma}\left(-t, \frac{y}{z}, t\right)\\
\mathbf{elif}\;z \leq 1.12 \cdot 10^{-72}:\\
\;\;\;\;t \cdot \frac{y}{a - z}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(-y, \frac{t}{z}, t\right)\\
\end{array}
\end{array}
if z < -1.64999999999999991e-37Initial program 55.4%
Taylor expanded in y around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites60.4%
Taylor expanded in z around inf
associate--l+N/A
associate-*r/N/A
associate-*r/N/A
associate-*r*N/A
mul-1-negN/A
div-subN/A
mul-1-negN/A
associate-*r*N/A
distribute-lft-out--N/A
associate-*r/N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites64.3%
Taylor expanded in a around 0
Applied rewrites63.1%
Taylor expanded in x around 0
Applied rewrites53.6%
if -1.64999999999999991e-37 < z < 1.12000000000000005e-72Initial program 87.7%
Taylor expanded in x around 0
*-commutativeN/A
associate-/l*N/A
lower-*.f64N/A
lower--.f64N/A
lower-/.f64N/A
lower--.f6446.6
Applied rewrites46.6%
Taylor expanded in y around inf
Applied rewrites45.8%
if 1.12000000000000005e-72 < z Initial program 52.1%
Taylor expanded in y around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites49.9%
Taylor expanded in z around inf
associate--l+N/A
associate-*r/N/A
associate-*r/N/A
associate-*r*N/A
mul-1-negN/A
div-subN/A
mul-1-negN/A
associate-*r*N/A
distribute-lft-out--N/A
associate-*r/N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites63.8%
Taylor expanded in a around 0
Applied rewrites67.1%
Taylor expanded in x around 0
Applied rewrites46.8%
(FPCore (x y z t a) :precision binary64 (if (<= z -2.8e-11) (fma a (/ t z) t) (if (<= z 3.3e+18) (* t (/ y (- a z))) (* (- t) -1.0))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (z <= -2.8e-11) {
tmp = fma(a, (t / z), t);
} else if (z <= 3.3e+18) {
tmp = t * (y / (a - z));
} else {
tmp = -t * -1.0;
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if (z <= -2.8e-11) tmp = fma(a, Float64(t / z), t); elseif (z <= 3.3e+18) tmp = Float64(t * Float64(y / Float64(a - z))); else tmp = Float64(Float64(-t) * -1.0); end return tmp end
code[x_, y_, z_, t_, a_] := If[LessEqual[z, -2.8e-11], N[(a * N[(t / z), $MachinePrecision] + t), $MachinePrecision], If[LessEqual[z, 3.3e+18], N[(t * N[(y / N[(a - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[((-t) * -1.0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -2.8 \cdot 10^{-11}:\\
\;\;\;\;\mathsf{fma}\left(a, \frac{t}{z}, t\right)\\
\mathbf{elif}\;z \leq 3.3 \cdot 10^{+18}:\\
\;\;\;\;t \cdot \frac{y}{a - z}\\
\mathbf{else}:\\
\;\;\;\;\left(-t\right) \cdot -1\\
\end{array}
\end{array}
if z < -2.8e-11Initial program 53.2%
Taylor expanded in x around 0
*-commutativeN/A
associate-/l*N/A
lower-*.f64N/A
lower--.f64N/A
lower-/.f64N/A
lower--.f6460.3
Applied rewrites60.3%
Taylor expanded in y around 0
Applied rewrites52.5%
Taylor expanded in z around inf
Applied rewrites46.4%
if -2.8e-11 < z < 3.3e18Initial program 86.9%
Taylor expanded in x around 0
*-commutativeN/A
associate-/l*N/A
lower-*.f64N/A
lower--.f64N/A
lower-/.f64N/A
lower--.f6445.0
Applied rewrites45.0%
Taylor expanded in y around inf
Applied rewrites43.1%
if 3.3e18 < z Initial program 45.5%
Taylor expanded in x around 0
*-commutativeN/A
associate-/l*N/A
lower-*.f64N/A
lower--.f64N/A
lower-/.f64N/A
lower--.f6451.8
Applied rewrites51.8%
Taylor expanded in y around 0
Applied rewrites59.4%
Taylor expanded in z around inf
Applied rewrites46.9%
(FPCore (x y z t a) :precision binary64 (if (or (<= z -4.2e-37) (not (<= z 2e-6))) (* (- t) -1.0) (/ (* t y) a)))
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((z <= -4.2e-37) || !(z <= 2e-6)) {
tmp = -t * -1.0;
} 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 <= (-4.2d-37)) .or. (.not. (z <= 2d-6))) then
tmp = -t * (-1.0d0)
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 <= -4.2e-37) || !(z <= 2e-6)) {
tmp = -t * -1.0;
} else {
tmp = (t * y) / a;
}
return tmp;
}
def code(x, y, z, t, a): tmp = 0 if (z <= -4.2e-37) or not (z <= 2e-6): tmp = -t * -1.0 else: tmp = (t * y) / a return tmp
function code(x, y, z, t, a) tmp = 0.0 if ((z <= -4.2e-37) || !(z <= 2e-6)) tmp = Float64(Float64(-t) * -1.0); else tmp = Float64(Float64(t * y) / a); end return tmp end
function tmp_2 = code(x, y, z, t, a) tmp = 0.0; if ((z <= -4.2e-37) || ~((z <= 2e-6))) tmp = -t * -1.0; else tmp = (t * y) / a; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := If[Or[LessEqual[z, -4.2e-37], N[Not[LessEqual[z, 2e-6]], $MachinePrecision]], N[((-t) * -1.0), $MachinePrecision], N[(N[(t * y), $MachinePrecision] / a), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -4.2 \cdot 10^{-37} \lor \neg \left(z \leq 2 \cdot 10^{-6}\right):\\
\;\;\;\;\left(-t\right) \cdot -1\\
\mathbf{else}:\\
\;\;\;\;\frac{t \cdot y}{a}\\
\end{array}
\end{array}
if z < -4.2000000000000002e-37 or 1.99999999999999991e-6 < z Initial program 51.4%
Taylor expanded in x around 0
*-commutativeN/A
associate-/l*N/A
lower-*.f64N/A
lower--.f64N/A
lower-/.f64N/A
lower--.f6456.4
Applied rewrites56.4%
Taylor expanded in y around 0
Applied rewrites53.8%
Taylor expanded in z around inf
Applied rewrites44.9%
if -4.2000000000000002e-37 < z < 1.99999999999999991e-6Initial program 86.4%
Taylor expanded in x around 0
*-commutativeN/A
associate-/l*N/A
lower-*.f64N/A
lower--.f64N/A
lower-/.f64N/A
lower--.f6444.3
Applied rewrites44.3%
Taylor expanded in z around 0
Applied rewrites32.5%
Final simplification38.6%
(FPCore (x y z t a) :precision binary64 (if (<= z -5e-37) (fma a (/ t z) t) (if (<= z 2e-6) (/ (* t y) a) (* (- t) -1.0))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (z <= -5e-37) {
tmp = fma(a, (t / z), t);
} else if (z <= 2e-6) {
tmp = (t * y) / a;
} else {
tmp = -t * -1.0;
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if (z <= -5e-37) tmp = fma(a, Float64(t / z), t); elseif (z <= 2e-6) tmp = Float64(Float64(t * y) / a); else tmp = Float64(Float64(-t) * -1.0); end return tmp end
code[x_, y_, z_, t_, a_] := If[LessEqual[z, -5e-37], N[(a * N[(t / z), $MachinePrecision] + t), $MachinePrecision], If[LessEqual[z, 2e-6], N[(N[(t * y), $MachinePrecision] / a), $MachinePrecision], N[((-t) * -1.0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -5 \cdot 10^{-37}:\\
\;\;\;\;\mathsf{fma}\left(a, \frac{t}{z}, t\right)\\
\mathbf{elif}\;z \leq 2 \cdot 10^{-6}:\\
\;\;\;\;\frac{t \cdot y}{a}\\
\mathbf{else}:\\
\;\;\;\;\left(-t\right) \cdot -1\\
\end{array}
\end{array}
if z < -4.9999999999999997e-37Initial program 54.7%
Taylor expanded in x around 0
*-commutativeN/A
associate-/l*N/A
lower-*.f64N/A
lower--.f64N/A
lower-/.f64N/A
lower--.f6460.2
Applied rewrites60.2%
Taylor expanded in y around 0
Applied rewrites51.0%
Taylor expanded in z around inf
Applied rewrites45.1%
if -4.9999999999999997e-37 < z < 1.99999999999999991e-6Initial program 86.4%
Taylor expanded in x around 0
*-commutativeN/A
associate-/l*N/A
lower-*.f64N/A
lower--.f64N/A
lower-/.f64N/A
lower--.f6444.3
Applied rewrites44.3%
Taylor expanded in z around 0
Applied rewrites32.5%
if 1.99999999999999991e-6 < z Initial program 48.1%
Taylor expanded in x around 0
*-commutativeN/A
associate-/l*N/A
lower-*.f64N/A
lower--.f64N/A
lower-/.f64N/A
lower--.f6452.6
Applied rewrites52.6%
Taylor expanded in y around 0
Applied rewrites56.6%
Taylor expanded in z around inf
Applied rewrites44.7%
(FPCore (x y z t a) :precision binary64 (* (- t) -1.0))
double code(double x, double y, double z, double t, double a) {
return -t * -1.0;
}
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 * (-1.0d0)
end function
public static double code(double x, double y, double z, double t, double a) {
return -t * -1.0;
}
def code(x, y, z, t, a): return -t * -1.0
function code(x, y, z, t, a) return Float64(Float64(-t) * -1.0) end
function tmp = code(x, y, z, t, a) tmp = -t * -1.0; end
code[x_, y_, z_, t_, a_] := N[((-t) * -1.0), $MachinePrecision]
\begin{array}{l}
\\
\left(-t\right) \cdot -1
\end{array}
Initial program 69.0%
Taylor expanded in x around 0
*-commutativeN/A
associate-/l*N/A
lower-*.f64N/A
lower--.f64N/A
lower-/.f64N/A
lower--.f6450.3
Applied rewrites50.3%
Taylor expanded in y around 0
Applied rewrites30.6%
Taylor expanded in z around inf
Applied rewrites25.2%
(FPCore (x y z t a) :precision binary64 (+ x (- t x)))
double code(double x, double y, double z, double t, double a) {
return x + (t - 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, 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 + (t - x)
end function
public static double code(double x, double y, double z, double t, double a) {
return x + (t - x);
}
def code(x, y, z, t, a): return x + (t - x)
function code(x, y, z, t, a) return Float64(x + Float64(t - x)) end
function tmp = code(x, y, z, t, a) tmp = x + (t - x); end
code[x_, y_, z_, t_, a_] := N[(x + N[(t - x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \left(t - x\right)
\end{array}
Initial program 69.0%
Taylor expanded in z around inf
lower--.f6420.0
Applied rewrites20.0%
(FPCore (x y z t a) :precision binary64 (+ x (- x)))
double code(double x, double y, double z, double t, double a) {
return x + -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, 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 + -x
end function
public static double code(double x, double y, double z, double t, double a) {
return x + -x;
}
def code(x, y, z, t, a): return x + -x
function code(x, y, z, t, a) return Float64(x + Float64(-x)) end
function tmp = code(x, y, z, t, a) tmp = x + -x; end
code[x_, y_, z_, t_, a_] := N[(x + (-x)), $MachinePrecision]
\begin{array}{l}
\\
x + \left(-x\right)
\end{array}
Initial program 69.0%
Taylor expanded in z around inf
lower--.f6420.0
Applied rewrites20.0%
Taylor expanded in x around inf
Applied rewrites2.7%
(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 2025017
(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))))