
(FPCore (x y z t a) :precision binary64 (+ x (/ (* (- y x) (- z t)) (- a t))))
double code(double x, double y, double z, double t, double a) {
return x + (((y - x) * (z - t)) / (a - 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 = x + (((y - x) * (z - t)) / (a - t))
end function
public static double code(double x, double y, double z, double t, double a) {
return x + (((y - x) * (z - t)) / (a - t));
}
def code(x, y, z, t, a): return x + (((y - x) * (z - t)) / (a - t))
function code(x, y, z, t, a) return Float64(x + Float64(Float64(Float64(y - x) * Float64(z - t)) / Float64(a - t))) end
function tmp = code(x, y, z, t, a) tmp = x + (((y - x) * (z - t)) / (a - t)); end
code[x_, y_, z_, t_, a_] := N[(x + N[(N[(N[(y - x), $MachinePrecision] * N[(z - t), $MachinePrecision]), $MachinePrecision] / N[(a - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \frac{\left(y - x\right) \cdot \left(z - t\right)}{a - t}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 16 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z t a) :precision binary64 (+ x (/ (* (- y x) (- z t)) (- a t))))
double code(double x, double y, double z, double t, double a) {
return x + (((y - x) * (z - t)) / (a - 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 = x + (((y - x) * (z - t)) / (a - t))
end function
public static double code(double x, double y, double z, double t, double a) {
return x + (((y - x) * (z - t)) / (a - t));
}
def code(x, y, z, t, a): return x + (((y - x) * (z - t)) / (a - t))
function code(x, y, z, t, a) return Float64(x + Float64(Float64(Float64(y - x) * Float64(z - t)) / Float64(a - t))) end
function tmp = code(x, y, z, t, a) tmp = x + (((y - x) * (z - t)) / (a - t)); end
code[x_, y_, z_, t_, a_] := N[(x + N[(N[(N[(y - x), $MachinePrecision] * N[(z - t), $MachinePrecision]), $MachinePrecision] / N[(a - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \frac{\left(y - x\right) \cdot \left(z - t\right)}{a - t}
\end{array}
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (+ x (/ (* (- y x) (- z t)) (- a t)))))
(if (<= t_1 (- INFINITY))
(fma (/ (fma -1.0 y x) t) (- z a) y)
(if (<= t_1 -2e-250)
t_1
(if (<= t_1 0.0)
(+ (/ (* (- y x) (- z a)) (- t)) y)
(fma (/ (- z t) (- a t)) (- y x) x))))))
double code(double x, double y, double z, double t, double a) {
double t_1 = x + (((y - x) * (z - t)) / (a - t));
double tmp;
if (t_1 <= -((double) INFINITY)) {
tmp = fma((fma(-1.0, y, x) / t), (z - a), y);
} else if (t_1 <= -2e-250) {
tmp = t_1;
} else if (t_1 <= 0.0) {
tmp = (((y - x) * (z - a)) / -t) + y;
} else {
tmp = fma(((z - t) / (a - t)), (y - x), x);
}
return tmp;
}
function code(x, y, z, t, a) t_1 = Float64(x + Float64(Float64(Float64(y - x) * Float64(z - t)) / Float64(a - t))) tmp = 0.0 if (t_1 <= Float64(-Inf)) tmp = fma(Float64(fma(-1.0, y, x) / t), Float64(z - a), y); elseif (t_1 <= -2e-250) tmp = t_1; elseif (t_1 <= 0.0) tmp = Float64(Float64(Float64(Float64(y - x) * Float64(z - a)) / Float64(-t)) + y); else tmp = fma(Float64(Float64(z - t) / Float64(a - t)), Float64(y - x), x); end return tmp end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(x + N[(N[(N[(y - x), $MachinePrecision] * N[(z - t), $MachinePrecision]), $MachinePrecision] / N[(a - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, (-Infinity)], N[(N[(N[(-1.0 * y + x), $MachinePrecision] / t), $MachinePrecision] * N[(z - a), $MachinePrecision] + y), $MachinePrecision], If[LessEqual[t$95$1, -2e-250], t$95$1, If[LessEqual[t$95$1, 0.0], N[(N[(N[(N[(y - x), $MachinePrecision] * N[(z - a), $MachinePrecision]), $MachinePrecision] / (-t)), $MachinePrecision] + y), $MachinePrecision], N[(N[(N[(z - t), $MachinePrecision] / N[(a - t), $MachinePrecision]), $MachinePrecision] * N[(y - x), $MachinePrecision] + x), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := x + \frac{\left(y - x\right) \cdot \left(z - t\right)}{a - t}\\
\mathbf{if}\;t\_1 \leq -\infty:\\
\;\;\;\;\mathsf{fma}\left(\frac{\mathsf{fma}\left(-1, y, x\right)}{t}, z - a, y\right)\\
\mathbf{elif}\;t\_1 \leq -2 \cdot 10^{-250}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_1 \leq 0:\\
\;\;\;\;\frac{\left(y - x\right) \cdot \left(z - a\right)}{-t} + y\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{z - t}{a - t}, y - x, x\right)\\
\end{array}
\end{array}
if (+.f64 x (/.f64 (*.f64 (-.f64 y x) (-.f64 z t)) (-.f64 a t))) < -inf.0Initial program 39.9%
Taylor expanded in t around inf
Applied rewrites83.4%
if -inf.0 < (+.f64 x (/.f64 (*.f64 (-.f64 y x) (-.f64 z t)) (-.f64 a t))) < -2.0000000000000001e-250Initial program 95.9%
if -2.0000000000000001e-250 < (+.f64 x (/.f64 (*.f64 (-.f64 y x) (-.f64 z t)) (-.f64 a t))) < 0.0Initial program 3.7%
lift-+.f64N/A
+-commutativeN/A
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f643.7
Applied rewrites3.7%
Taylor expanded in t around inf
Applied rewrites99.4%
if 0.0 < (+.f64 x (/.f64 (*.f64 (-.f64 y x) (-.f64 z t)) (-.f64 a t))) Initial program 75.0%
lift-+.f64N/A
+-commutativeN/A
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f6495.3
Applied rewrites95.3%
Final simplification93.5%
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (+ x (/ (* (- y x) (- z t)) (- a t)))))
(if (or (<= t_1 -2e-250) (not (<= t_1 0.0)))
(fma (/ (- z t) (- a t)) (- y x) x)
(+ (/ (* (- y x) (- z a)) (- t)) y))))
double code(double x, double y, double z, double t, double a) {
double t_1 = x + (((y - x) * (z - t)) / (a - t));
double tmp;
if ((t_1 <= -2e-250) || !(t_1 <= 0.0)) {
tmp = fma(((z - t) / (a - t)), (y - x), x);
} else {
tmp = (((y - x) * (z - a)) / -t) + y;
}
return tmp;
}
function code(x, y, z, t, a) t_1 = Float64(x + Float64(Float64(Float64(y - x) * Float64(z - t)) / Float64(a - t))) tmp = 0.0 if ((t_1 <= -2e-250) || !(t_1 <= 0.0)) tmp = fma(Float64(Float64(z - t) / Float64(a - t)), Float64(y - x), x); else tmp = Float64(Float64(Float64(Float64(y - x) * Float64(z - a)) / Float64(-t)) + y); end return tmp end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(x + N[(N[(N[(y - x), $MachinePrecision] * N[(z - t), $MachinePrecision]), $MachinePrecision] / N[(a - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t$95$1, -2e-250], N[Not[LessEqual[t$95$1, 0.0]], $MachinePrecision]], N[(N[(N[(z - t), $MachinePrecision] / N[(a - t), $MachinePrecision]), $MachinePrecision] * N[(y - x), $MachinePrecision] + x), $MachinePrecision], N[(N[(N[(N[(y - x), $MachinePrecision] * N[(z - a), $MachinePrecision]), $MachinePrecision] / (-t)), $MachinePrecision] + y), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := x + \frac{\left(y - x\right) \cdot \left(z - t\right)}{a - t}\\
\mathbf{if}\;t\_1 \leq -2 \cdot 10^{-250} \lor \neg \left(t\_1 \leq 0\right):\\
\;\;\;\;\mathsf{fma}\left(\frac{z - t}{a - t}, y - x, x\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(y - x\right) \cdot \left(z - a\right)}{-t} + y\\
\end{array}
\end{array}
if (+.f64 x (/.f64 (*.f64 (-.f64 y x) (-.f64 z t)) (-.f64 a t))) < -2.0000000000000001e-250 or 0.0 < (+.f64 x (/.f64 (*.f64 (-.f64 y x) (-.f64 z t)) (-.f64 a t))) Initial program 75.1%
lift-+.f64N/A
+-commutativeN/A
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f6491.2
Applied rewrites91.2%
if -2.0000000000000001e-250 < (+.f64 x (/.f64 (*.f64 (-.f64 y x) (-.f64 z t)) (-.f64 a t))) < 0.0Initial program 3.7%
lift-+.f64N/A
+-commutativeN/A
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f643.7
Applied rewrites3.7%
Taylor expanded in t around inf
Applied rewrites99.4%
Final simplification91.7%
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (+ x (/ (* (- y x) (- z t)) (- a t)))))
(if (or (<= t_1 -2e-250) (not (<= t_1 0.0)))
(fma (/ (- z t) (- a t)) (- y x) x)
(fma (/ x t) (- z a) y))))
double code(double x, double y, double z, double t, double a) {
double t_1 = x + (((y - x) * (z - t)) / (a - t));
double tmp;
if ((t_1 <= -2e-250) || !(t_1 <= 0.0)) {
tmp = fma(((z - t) / (a - t)), (y - x), x);
} else {
tmp = fma((x / t), (z - a), y);
}
return tmp;
}
function code(x, y, z, t, a) t_1 = Float64(x + Float64(Float64(Float64(y - x) * Float64(z - t)) / Float64(a - t))) tmp = 0.0 if ((t_1 <= -2e-250) || !(t_1 <= 0.0)) tmp = fma(Float64(Float64(z - t) / Float64(a - t)), Float64(y - x), x); else tmp = fma(Float64(x / t), Float64(z - a), y); end return tmp end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(x + N[(N[(N[(y - x), $MachinePrecision] * N[(z - t), $MachinePrecision]), $MachinePrecision] / N[(a - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t$95$1, -2e-250], N[Not[LessEqual[t$95$1, 0.0]], $MachinePrecision]], N[(N[(N[(z - t), $MachinePrecision] / N[(a - t), $MachinePrecision]), $MachinePrecision] * N[(y - x), $MachinePrecision] + x), $MachinePrecision], N[(N[(x / t), $MachinePrecision] * N[(z - a), $MachinePrecision] + y), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := x + \frac{\left(y - x\right) \cdot \left(z - t\right)}{a - t}\\
\mathbf{if}\;t\_1 \leq -2 \cdot 10^{-250} \lor \neg \left(t\_1 \leq 0\right):\\
\;\;\;\;\mathsf{fma}\left(\frac{z - t}{a - t}, y - x, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{x}{t}, z - a, y\right)\\
\end{array}
\end{array}
if (+.f64 x (/.f64 (*.f64 (-.f64 y x) (-.f64 z t)) (-.f64 a t))) < -2.0000000000000001e-250 or 0.0 < (+.f64 x (/.f64 (*.f64 (-.f64 y x) (-.f64 z t)) (-.f64 a t))) Initial program 75.1%
lift-+.f64N/A
+-commutativeN/A
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f6491.2
Applied rewrites91.2%
if -2.0000000000000001e-250 < (+.f64 x (/.f64 (*.f64 (-.f64 y x) (-.f64 z t)) (-.f64 a t))) < 0.0Initial program 3.7%
Taylor expanded in t around inf
Applied rewrites88.3%
Taylor expanded in x around inf
Applied rewrites88.3%
Final simplification91.0%
(FPCore (x y z t a) :precision binary64 (if (or (<= a -1.3e-46) (not (<= a 5.5e+24))) (fma (/ (- z t) (- a t)) y x) (fma (/ (fma -1.0 y x) t) (- z a) y)))
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((a <= -1.3e-46) || !(a <= 5.5e+24)) {
tmp = fma(((z - t) / (a - t)), y, x);
} else {
tmp = fma((fma(-1.0, y, x) / t), (z - a), y);
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if ((a <= -1.3e-46) || !(a <= 5.5e+24)) tmp = fma(Float64(Float64(z - t) / Float64(a - t)), y, x); else tmp = fma(Float64(fma(-1.0, y, x) / t), Float64(z - a), y); end return tmp end
code[x_, y_, z_, t_, a_] := If[Or[LessEqual[a, -1.3e-46], N[Not[LessEqual[a, 5.5e+24]], $MachinePrecision]], N[(N[(N[(z - t), $MachinePrecision] / N[(a - t), $MachinePrecision]), $MachinePrecision] * y + x), $MachinePrecision], N[(N[(N[(-1.0 * y + x), $MachinePrecision] / t), $MachinePrecision] * N[(z - a), $MachinePrecision] + y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -1.3 \cdot 10^{-46} \lor \neg \left(a \leq 5.5 \cdot 10^{+24}\right):\\
\;\;\;\;\mathsf{fma}\left(\frac{z - t}{a - t}, y, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{\mathsf{fma}\left(-1, y, x\right)}{t}, z - a, y\right)\\
\end{array}
\end{array}
if a < -1.3000000000000001e-46 or 5.5000000000000002e24 < a Initial program 74.9%
lift-+.f64N/A
+-commutativeN/A
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f6491.4
Applied rewrites91.4%
Taylor expanded in x around 0
Applied rewrites85.1%
if -1.3000000000000001e-46 < a < 5.5000000000000002e24Initial program 66.3%
Taylor expanded in t around inf
Applied rewrites81.4%
Final simplification83.2%
(FPCore (x y z t a) :precision binary64 (if (or (<= a -1.8e-131) (not (<= a 7e-113))) (fma (/ (- z t) (- a t)) y x) (fma (/ (- x y) t) z y)))
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((a <= -1.8e-131) || !(a <= 7e-113)) {
tmp = fma(((z - t) / (a - t)), y, x);
} else {
tmp = fma(((x - y) / t), z, y);
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if ((a <= -1.8e-131) || !(a <= 7e-113)) tmp = fma(Float64(Float64(z - t) / Float64(a - t)), y, x); else tmp = fma(Float64(Float64(x - y) / t), z, y); end return tmp end
code[x_, y_, z_, t_, a_] := If[Or[LessEqual[a, -1.8e-131], N[Not[LessEqual[a, 7e-113]], $MachinePrecision]], N[(N[(N[(z - t), $MachinePrecision] / N[(a - t), $MachinePrecision]), $MachinePrecision] * y + x), $MachinePrecision], N[(N[(N[(x - y), $MachinePrecision] / t), $MachinePrecision] * z + y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -1.8 \cdot 10^{-131} \lor \neg \left(a \leq 7 \cdot 10^{-113}\right):\\
\;\;\;\;\mathsf{fma}\left(\frac{z - t}{a - t}, y, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{x - y}{t}, z, y\right)\\
\end{array}
\end{array}
if a < -1.8e-131 or 7.00000000000000057e-113 < a Initial program 73.4%
lift-+.f64N/A
+-commutativeN/A
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f6487.6
Applied rewrites87.6%
Taylor expanded in x around 0
Applied rewrites79.2%
if -1.8e-131 < a < 7.00000000000000057e-113Initial program 64.7%
Taylor expanded in t around inf
Applied rewrites88.1%
Taylor expanded in x around 0
Applied rewrites57.8%
Taylor expanded in a around 0
Applied rewrites86.8%
Final simplification81.7%
(FPCore (x y z t a)
:precision binary64
(if (<= t -6.5e+133)
y
(if (<= t -3.65e-79)
(/ (* (- x y) z) t)
(if (<= t 7.8e+127) (fma (/ z a) y x) (fma a (/ y t) y)))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (t <= -6.5e+133) {
tmp = y;
} else if (t <= -3.65e-79) {
tmp = ((x - y) * z) / t;
} else if (t <= 7.8e+127) {
tmp = fma((z / a), y, x);
} else {
tmp = fma(a, (y / t), y);
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if (t <= -6.5e+133) tmp = y; elseif (t <= -3.65e-79) tmp = Float64(Float64(Float64(x - y) * z) / t); elseif (t <= 7.8e+127) tmp = fma(Float64(z / a), y, x); else tmp = fma(a, Float64(y / t), y); end return tmp end
code[x_, y_, z_, t_, a_] := If[LessEqual[t, -6.5e+133], y, If[LessEqual[t, -3.65e-79], N[(N[(N[(x - y), $MachinePrecision] * z), $MachinePrecision] / t), $MachinePrecision], If[LessEqual[t, 7.8e+127], N[(N[(z / a), $MachinePrecision] * y + x), $MachinePrecision], N[(a * N[(y / t), $MachinePrecision] + y), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -6.5 \cdot 10^{+133}:\\
\;\;\;\;y\\
\mathbf{elif}\;t \leq -3.65 \cdot 10^{-79}:\\
\;\;\;\;\frac{\left(x - y\right) \cdot z}{t}\\
\mathbf{elif}\;t \leq 7.8 \cdot 10^{+127}:\\
\;\;\;\;\mathsf{fma}\left(\frac{z}{a}, y, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(a, \frac{y}{t}, y\right)\\
\end{array}
\end{array}
if t < -6.5000000000000004e133Initial program 42.2%
Taylor expanded in t around inf
Applied rewrites57.9%
if -6.5000000000000004e133 < t < -3.6499999999999999e-79Initial program 75.1%
Taylor expanded in t around inf
Applied rewrites72.5%
Taylor expanded in x around 0
Applied rewrites45.2%
Taylor expanded in z around inf
Applied rewrites42.5%
if -3.6499999999999999e-79 < t < 7.79999999999999962e127Initial program 85.4%
lift-+.f64N/A
+-commutativeN/A
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f6493.2
Applied rewrites93.2%
Taylor expanded in x around 0
Applied rewrites75.5%
Taylor expanded in t around 0
Applied rewrites68.2%
if 7.79999999999999962e127 < t Initial program 37.4%
Taylor expanded in t around inf
Applied rewrites87.9%
Taylor expanded in x around 0
Applied rewrites70.2%
Taylor expanded in z around 0
Applied rewrites57.8%
Final simplification59.4%
(FPCore (x y z t a) :precision binary64 (if (or (<= a -6.5e-29) (not (<= a 7.5e+46))) (fma (/ (- z t) a) y x) (fma (/ (- x y) t) z y)))
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((a <= -6.5e-29) || !(a <= 7.5e+46)) {
tmp = fma(((z - t) / a), y, x);
} else {
tmp = fma(((x - y) / t), z, y);
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if ((a <= -6.5e-29) || !(a <= 7.5e+46)) tmp = fma(Float64(Float64(z - t) / a), y, x); else tmp = fma(Float64(Float64(x - y) / t), z, y); end return tmp end
code[x_, y_, z_, t_, a_] := If[Or[LessEqual[a, -6.5e-29], N[Not[LessEqual[a, 7.5e+46]], $MachinePrecision]], N[(N[(N[(z - t), $MachinePrecision] / a), $MachinePrecision] * y + x), $MachinePrecision], N[(N[(N[(x - y), $MachinePrecision] / t), $MachinePrecision] * z + y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -6.5 \cdot 10^{-29} \lor \neg \left(a \leq 7.5 \cdot 10^{+46}\right):\\
\;\;\;\;\mathsf{fma}\left(\frac{z - t}{a}, y, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{x - y}{t}, z, y\right)\\
\end{array}
\end{array}
if a < -6.5e-29 or 7.5000000000000003e46 < a Initial program 73.9%
lift-+.f64N/A
+-commutativeN/A
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f6491.3
Applied rewrites91.3%
Taylor expanded in x around 0
Applied rewrites85.6%
Taylor expanded in t around 0
Applied rewrites76.1%
if -6.5e-29 < a < 7.5000000000000003e46Initial program 67.6%
Taylor expanded in t around inf
Applied rewrites80.9%
Taylor expanded in x around 0
Applied rewrites56.5%
Taylor expanded in a around 0
Applied rewrites77.2%
Final simplification76.7%
(FPCore (x y z t a) :precision binary64 (if (or (<= t -3.65e-79) (not (<= t 2.05e+14))) (fma (/ (- x y) t) z y) (fma (/ (- y x) a) z x)))
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((t <= -3.65e-79) || !(t <= 2.05e+14)) {
tmp = fma(((x - y) / t), z, y);
} else {
tmp = fma(((y - x) / a), z, x);
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if ((t <= -3.65e-79) || !(t <= 2.05e+14)) tmp = fma(Float64(Float64(x - y) / t), z, y); else tmp = fma(Float64(Float64(y - x) / a), z, x); end return tmp end
code[x_, y_, z_, t_, a_] := If[Or[LessEqual[t, -3.65e-79], N[Not[LessEqual[t, 2.05e+14]], $MachinePrecision]], N[(N[(N[(x - y), $MachinePrecision] / t), $MachinePrecision] * z + y), $MachinePrecision], N[(N[(N[(y - x), $MachinePrecision] / a), $MachinePrecision] * z + x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -3.65 \cdot 10^{-79} \lor \neg \left(t \leq 2.05 \cdot 10^{+14}\right):\\
\;\;\;\;\mathsf{fma}\left(\frac{x - y}{t}, z, y\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{y - x}{a}, z, x\right)\\
\end{array}
\end{array}
if t < -3.6499999999999999e-79 or 2.05e14 < t Initial program 57.7%
Taylor expanded in t around inf
Applied rewrites78.6%
Taylor expanded in x around 0
Applied rewrites55.7%
Taylor expanded in a around 0
Applied rewrites72.8%
if -3.6499999999999999e-79 < t < 2.05e14Initial program 88.5%
Taylor expanded in t around 0
Applied rewrites79.1%
Final simplification75.4%
(FPCore (x y z t a) :precision binary64 (if (or (<= a -6.2e-29) (not (<= a 1.2e+47))) (fma (/ z a) y x) (fma (/ (- x y) t) z y)))
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((a <= -6.2e-29) || !(a <= 1.2e+47)) {
tmp = fma((z / a), y, x);
} else {
tmp = fma(((x - y) / t), z, y);
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if ((a <= -6.2e-29) || !(a <= 1.2e+47)) tmp = fma(Float64(z / a), y, x); else tmp = fma(Float64(Float64(x - y) / t), z, y); end return tmp end
code[x_, y_, z_, t_, a_] := If[Or[LessEqual[a, -6.2e-29], N[Not[LessEqual[a, 1.2e+47]], $MachinePrecision]], N[(N[(z / a), $MachinePrecision] * y + x), $MachinePrecision], N[(N[(N[(x - y), $MachinePrecision] / t), $MachinePrecision] * z + y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -6.2 \cdot 10^{-29} \lor \neg \left(a \leq 1.2 \cdot 10^{+47}\right):\\
\;\;\;\;\mathsf{fma}\left(\frac{z}{a}, y, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{x - y}{t}, z, y\right)\\
\end{array}
\end{array}
if a < -6.20000000000000052e-29 or 1.20000000000000009e47 < a Initial program 73.9%
lift-+.f64N/A
+-commutativeN/A
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f6491.3
Applied rewrites91.3%
Taylor expanded in x around 0
Applied rewrites85.6%
Taylor expanded in t around 0
Applied rewrites70.8%
if -6.20000000000000052e-29 < a < 1.20000000000000009e47Initial program 67.6%
Taylor expanded in t around inf
Applied rewrites80.9%
Taylor expanded in x around 0
Applied rewrites56.5%
Taylor expanded in a around 0
Applied rewrites77.2%
Final simplification74.2%
(FPCore (x y z t a) :precision binary64 (if (<= a -6.2e-29) (fma (- z t) (/ (- y x) a) x) (if (<= a 7.5e+46) (fma (/ (- x y) t) z y) (fma (/ (- z t) a) y x))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (a <= -6.2e-29) {
tmp = fma((z - t), ((y - x) / a), x);
} else if (a <= 7.5e+46) {
tmp = fma(((x - y) / t), z, y);
} else {
tmp = fma(((z - t) / a), y, x);
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if (a <= -6.2e-29) tmp = fma(Float64(z - t), Float64(Float64(y - x) / a), x); elseif (a <= 7.5e+46) tmp = fma(Float64(Float64(x - y) / t), z, y); else tmp = fma(Float64(Float64(z - t) / a), y, x); end return tmp end
code[x_, y_, z_, t_, a_] := If[LessEqual[a, -6.2e-29], N[(N[(z - t), $MachinePrecision] * N[(N[(y - x), $MachinePrecision] / a), $MachinePrecision] + x), $MachinePrecision], If[LessEqual[a, 7.5e+46], N[(N[(N[(x - y), $MachinePrecision] / t), $MachinePrecision] * z + y), $MachinePrecision], N[(N[(N[(z - t), $MachinePrecision] / a), $MachinePrecision] * y + x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -6.2 \cdot 10^{-29}:\\
\;\;\;\;\mathsf{fma}\left(z - t, \frac{y - x}{a}, x\right)\\
\mathbf{elif}\;a \leq 7.5 \cdot 10^{+46}:\\
\;\;\;\;\mathsf{fma}\left(\frac{x - y}{t}, z, y\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{z - t}{a}, y, x\right)\\
\end{array}
\end{array}
if a < -6.20000000000000052e-29Initial program 67.8%
Taylor expanded in a around inf
Applied rewrites69.7%
if -6.20000000000000052e-29 < a < 7.5000000000000003e46Initial program 67.6%
Taylor expanded in t around inf
Applied rewrites80.9%
Taylor expanded in x around 0
Applied rewrites56.5%
Taylor expanded in a around 0
Applied rewrites77.2%
if 7.5000000000000003e46 < a Initial program 80.3%
lift-+.f64N/A
+-commutativeN/A
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f6494.3
Applied rewrites94.3%
Taylor expanded in x around 0
Applied rewrites90.6%
Taylor expanded in t around 0
Applied rewrites85.7%
Final simplification77.4%
(FPCore (x y z t a) :precision binary64 (if (or (<= t -3.65e-79) (not (<= t 1.52e+19))) (fma (- y) (/ z t) y) (fma (/ z a) y x)))
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((t <= -3.65e-79) || !(t <= 1.52e+19)) {
tmp = fma(-y, (z / t), y);
} else {
tmp = fma((z / a), y, x);
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if ((t <= -3.65e-79) || !(t <= 1.52e+19)) tmp = fma(Float64(-y), Float64(z / t), y); else tmp = fma(Float64(z / a), y, x); end return tmp end
code[x_, y_, z_, t_, a_] := If[Or[LessEqual[t, -3.65e-79], N[Not[LessEqual[t, 1.52e+19]], $MachinePrecision]], N[((-y) * N[(z / t), $MachinePrecision] + y), $MachinePrecision], N[(N[(z / a), $MachinePrecision] * y + x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -3.65 \cdot 10^{-79} \lor \neg \left(t \leq 1.52 \cdot 10^{+19}\right):\\
\;\;\;\;\mathsf{fma}\left(-y, \frac{z}{t}, y\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{z}{a}, y, x\right)\\
\end{array}
\end{array}
if t < -3.6499999999999999e-79 or 1.52e19 < t Initial program 57.7%
Taylor expanded in t around inf
Applied rewrites78.6%
Taylor expanded in x around 0
Applied rewrites55.7%
Taylor expanded in z around inf
Applied rewrites55.4%
if -3.6499999999999999e-79 < t < 1.52e19Initial program 88.5%
lift-+.f64N/A
+-commutativeN/A
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f6495.2
Applied rewrites95.2%
Taylor expanded in x around 0
Applied rewrites78.5%
Taylor expanded in t around 0
Applied rewrites74.6%
Final simplification63.4%
(FPCore (x y z t a) :precision binary64 (if (or (<= t -1.15e+15) (not (<= t 7.8e+127))) (fma a (/ y t) y) (fma (/ z a) y x)))
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((t <= -1.15e+15) || !(t <= 7.8e+127)) {
tmp = fma(a, (y / t), y);
} else {
tmp = fma((z / a), y, x);
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if ((t <= -1.15e+15) || !(t <= 7.8e+127)) tmp = fma(a, Float64(y / t), y); else tmp = fma(Float64(z / a), y, x); end return tmp end
code[x_, y_, z_, t_, a_] := If[Or[LessEqual[t, -1.15e+15], N[Not[LessEqual[t, 7.8e+127]], $MachinePrecision]], N[(a * N[(y / t), $MachinePrecision] + y), $MachinePrecision], N[(N[(z / a), $MachinePrecision] * y + x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -1.15 \cdot 10^{+15} \lor \neg \left(t \leq 7.8 \cdot 10^{+127}\right):\\
\;\;\;\;\mathsf{fma}\left(a, \frac{y}{t}, y\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{z}{a}, y, x\right)\\
\end{array}
\end{array}
if t < -1.15e15 or 7.79999999999999962e127 < t Initial program 48.5%
Taylor expanded in t around inf
Applied rewrites82.2%
Taylor expanded in x around 0
Applied rewrites58.6%
Taylor expanded in z around 0
Applied rewrites49.0%
if -1.15e15 < t < 7.79999999999999962e127Initial program 85.5%
lift-+.f64N/A
+-commutativeN/A
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f6492.6
Applied rewrites92.6%
Taylor expanded in x around 0
Applied rewrites75.7%
Taylor expanded in t around 0
Applied rewrites62.8%
Final simplification57.3%
(FPCore (x y z t a) :precision binary64 (if (or (<= t -1.15e+15) (not (<= t 6.5e-13))) y (fma t (/ x a) x)))
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((t <= -1.15e+15) || !(t <= 6.5e-13)) {
tmp = y;
} else {
tmp = fma(t, (x / a), x);
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if ((t <= -1.15e+15) || !(t <= 6.5e-13)) tmp = y; else tmp = fma(t, Float64(x / a), x); end return tmp end
code[x_, y_, z_, t_, a_] := If[Or[LessEqual[t, -1.15e+15], N[Not[LessEqual[t, 6.5e-13]], $MachinePrecision]], y, N[(t * N[(x / a), $MachinePrecision] + x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -1.15 \cdot 10^{+15} \lor \neg \left(t \leq 6.5 \cdot 10^{-13}\right):\\
\;\;\;\;y\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(t, \frac{x}{a}, x\right)\\
\end{array}
\end{array}
if t < -1.15e15 or 6.49999999999999957e-13 < t Initial program 53.5%
Taylor expanded in t around inf
Applied rewrites44.8%
if -1.15e15 < t < 6.49999999999999957e-13Initial program 88.2%
Taylor expanded in x around inf
Applied rewrites56.7%
Taylor expanded in a around inf
Applied rewrites51.9%
Taylor expanded in z around 0
Applied rewrites40.7%
Final simplification42.8%
(FPCore (x y z t a) :precision binary64 (if (<= a -3.1e+84) x (if (<= a 1.3e+33) (fma a (/ y t) y) (fma t (/ x a) x))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (a <= -3.1e+84) {
tmp = x;
} else if (a <= 1.3e+33) {
tmp = fma(a, (y / t), y);
} else {
tmp = fma(t, (x / a), x);
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if (a <= -3.1e+84) tmp = x; elseif (a <= 1.3e+33) tmp = fma(a, Float64(y / t), y); else tmp = fma(t, Float64(x / a), x); end return tmp end
code[x_, y_, z_, t_, a_] := If[LessEqual[a, -3.1e+84], x, If[LessEqual[a, 1.3e+33], N[(a * N[(y / t), $MachinePrecision] + y), $MachinePrecision], N[(t * N[(x / a), $MachinePrecision] + x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -3.1 \cdot 10^{+84}:\\
\;\;\;\;x\\
\mathbf{elif}\;a \leq 1.3 \cdot 10^{+33}:\\
\;\;\;\;\mathsf{fma}\left(a, \frac{y}{t}, y\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(t, \frac{x}{a}, x\right)\\
\end{array}
\end{array}
if a < -3.10000000000000003e84Initial program 69.2%
Taylor expanded in a around inf
Applied rewrites62.5%
if -3.10000000000000003e84 < a < 1.2999999999999999e33Initial program 67.0%
Taylor expanded in t around inf
Applied rewrites76.9%
Taylor expanded in x around 0
Applied rewrites54.6%
Taylor expanded in z around 0
Applied rewrites38.0%
if 1.2999999999999999e33 < a Initial program 80.4%
Taylor expanded in x around inf
Applied rewrites50.7%
Taylor expanded in a around inf
Applied rewrites49.1%
Taylor expanded in z around 0
Applied rewrites47.6%
Final simplification44.4%
(FPCore (x y z t a) :precision binary64 (if (<= a -3.3e+83) x (if (<= a 1.3e+33) y x)))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (a <= -3.3e+83) {
tmp = x;
} else if (a <= 1.3e+33) {
tmp = y;
} else {
tmp = x;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z, t, 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 (a <= (-3.3d+83)) then
tmp = x
else if (a <= 1.3d+33) then
tmp = y
else
tmp = x
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a) {
double tmp;
if (a <= -3.3e+83) {
tmp = x;
} else if (a <= 1.3e+33) {
tmp = y;
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z, t, a): tmp = 0 if a <= -3.3e+83: tmp = x elif a <= 1.3e+33: tmp = y else: tmp = x return tmp
function code(x, y, z, t, a) tmp = 0.0 if (a <= -3.3e+83) tmp = x; elseif (a <= 1.3e+33) tmp = y; else tmp = x; end return tmp end
function tmp_2 = code(x, y, z, t, a) tmp = 0.0; if (a <= -3.3e+83) tmp = x; elseif (a <= 1.3e+33) tmp = y; else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := If[LessEqual[a, -3.3e+83], x, If[LessEqual[a, 1.3e+33], y, x]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -3.3 \cdot 10^{+83}:\\
\;\;\;\;x\\
\mathbf{elif}\;a \leq 1.3 \cdot 10^{+33}:\\
\;\;\;\;y\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if a < -3.29999999999999985e83 or 1.2999999999999999e33 < a Initial program 75.8%
Taylor expanded in a around inf
Applied rewrites53.7%
if -3.29999999999999985e83 < a < 1.2999999999999999e33Initial program 67.0%
Taylor expanded in t around inf
Applied rewrites33.6%
Final simplification41.8%
(FPCore (x y z t a) :precision binary64 x)
double code(double x, double y, double z, double t, double a) {
return x;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z, t, 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
end function
public static double code(double x, double y, double z, double t, double a) {
return x;
}
def code(x, y, z, t, a): return x
function code(x, y, z, t, a) return x end
function tmp = code(x, y, z, t, a) tmp = x; end
code[x_, y_, z_, t_, a_] := x
\begin{array}{l}
\\
x
\end{array}
Initial program 70.6%
Taylor expanded in a around inf
Applied rewrites26.5%
Final simplification26.5%
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (+ x (* (/ (- y x) 1.0) (/ (- z t) (- a t))))))
(if (< a -1.6153062845442575e-142)
t_1
(if (< a 3.774403170083174e-182) (- y (* (/ z t) (- y x))) t_1))))
double code(double x, double y, double z, double t, double a) {
double t_1 = x + (((y - x) / 1.0) * ((z - t) / (a - t)));
double tmp;
if (a < -1.6153062845442575e-142) {
tmp = t_1;
} else if (a < 3.774403170083174e-182) {
tmp = y - ((z / t) * (y - 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 = x + (((y - x) / 1.0d0) * ((z - t) / (a - t)))
if (a < (-1.6153062845442575d-142)) then
tmp = t_1
else if (a < 3.774403170083174d-182) then
tmp = y - ((z / t) * (y - 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 = x + (((y - x) / 1.0) * ((z - t) / (a - t)));
double tmp;
if (a < -1.6153062845442575e-142) {
tmp = t_1;
} else if (a < 3.774403170083174e-182) {
tmp = y - ((z / t) * (y - x));
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z, t, a): t_1 = x + (((y - x) / 1.0) * ((z - t) / (a - t))) tmp = 0 if a < -1.6153062845442575e-142: tmp = t_1 elif a < 3.774403170083174e-182: tmp = y - ((z / t) * (y - x)) else: tmp = t_1 return tmp
function code(x, y, z, t, a) t_1 = Float64(x + Float64(Float64(Float64(y - x) / 1.0) * Float64(Float64(z - t) / Float64(a - t)))) tmp = 0.0 if (a < -1.6153062845442575e-142) tmp = t_1; elseif (a < 3.774403170083174e-182) tmp = Float64(y - Float64(Float64(z / t) * Float64(y - x))); else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z, t, a) t_1 = x + (((y - x) / 1.0) * ((z - t) / (a - t))); tmp = 0.0; if (a < -1.6153062845442575e-142) tmp = t_1; elseif (a < 3.774403170083174e-182) tmp = y - ((z / t) * (y - x)); else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(x + N[(N[(N[(y - x), $MachinePrecision] / 1.0), $MachinePrecision] * N[(N[(z - t), $MachinePrecision] / N[(a - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[Less[a, -1.6153062845442575e-142], t$95$1, If[Less[a, 3.774403170083174e-182], N[(y - N[(N[(z / t), $MachinePrecision] * N[(y - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := x + \frac{y - x}{1} \cdot \frac{z - t}{a - t}\\
\mathbf{if}\;a < -1.6153062845442575 \cdot 10^{-142}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;a < 3.774403170083174 \cdot 10^{-182}:\\
\;\;\;\;y - \frac{z}{t} \cdot \left(y - x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
herbie shell --seed 2025021
(FPCore (x y z t a)
:name "Graphics.Rendering.Chart.Axis.Types:linMap from Chart-1.5.3"
:precision binary64
:alt
(! :herbie-platform default (if (< a -646122513817703/4000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000) (+ x (* (/ (- y x) 1) (/ (- z t) (- a t)))) (if (< a 1887201585041587/50000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000) (- y (* (/ z t) (- y x))) (+ x (* (/ (- y x) 1) (/ (- z t) (- a t)))))))
(+ x (/ (* (- y x) (- z t)) (- a t))))