
(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 15 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
(if (or (<= y -1.55e-62) (not (<= y 5.8e-171)))
(fma (- y x) (/ (- z t) (- a t)) x)
(*
(- x)
(-
(fma (/ (/ (* (- z t) y) x) (- a t)) -1.0 (/ z (- a t)))
(- (/ t (- a t)) -1.0)))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((y <= -1.55e-62) || !(y <= 5.8e-171)) {
tmp = fma((y - x), ((z - t) / (a - t)), x);
} else {
tmp = -x * (fma(((((z - t) * y) / x) / (a - t)), -1.0, (z / (a - t))) - ((t / (a - t)) - -1.0));
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if ((y <= -1.55e-62) || !(y <= 5.8e-171)) tmp = fma(Float64(y - x), Float64(Float64(z - t) / Float64(a - t)), x); else tmp = Float64(Float64(-x) * Float64(fma(Float64(Float64(Float64(Float64(z - t) * y) / x) / Float64(a - t)), -1.0, Float64(z / Float64(a - t))) - Float64(Float64(t / Float64(a - t)) - -1.0))); end return tmp end
code[x_, y_, z_, t_, a_] := If[Or[LessEqual[y, -1.55e-62], N[Not[LessEqual[y, 5.8e-171]], $MachinePrecision]], N[(N[(y - x), $MachinePrecision] * N[(N[(z - t), $MachinePrecision] / N[(a - t), $MachinePrecision]), $MachinePrecision] + x), $MachinePrecision], N[((-x) * N[(N[(N[(N[(N[(N[(z - t), $MachinePrecision] * y), $MachinePrecision] / x), $MachinePrecision] / N[(a - t), $MachinePrecision]), $MachinePrecision] * -1.0 + N[(z / N[(a - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(N[(t / N[(a - t), $MachinePrecision]), $MachinePrecision] - -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.55 \cdot 10^{-62} \lor \neg \left(y \leq 5.8 \cdot 10^{-171}\right):\\
\;\;\;\;\mathsf{fma}\left(y - x, \frac{z - t}{a - t}, x\right)\\
\mathbf{else}:\\
\;\;\;\;\left(-x\right) \cdot \left(\mathsf{fma}\left(\frac{\frac{\left(z - t\right) \cdot y}{x}}{a - t}, -1, \frac{z}{a - t}\right) - \left(\frac{t}{a - t} - -1\right)\right)\\
\end{array}
\end{array}
if y < -1.55e-62 or 5.7999999999999997e-171 < y Initial program 64.1%
lift-+.f64N/A
lift--.f64N/A
lift-/.f64N/A
lift--.f64N/A
lift--.f64N/A
lift-*.f64N/A
+-commutativeN/A
associate-/l*N/A
sub-divN/A
lower-fma.f64N/A
lift--.f64N/A
sub-divN/A
lower-/.f64N/A
lift--.f64N/A
lift--.f6490.2
Applied rewrites90.2%
if -1.55e-62 < y < 5.7999999999999997e-171Initial program 63.2%
Taylor expanded in x around -inf
associate-*r*N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower--.f64N/A
Applied rewrites86.5%
Final simplification89.0%
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (+ x (/ (* (- y x) (- z t)) (- a t)))))
(if (or (<= t_1 -2e-266) (not (<= t_1 0.0)))
(fma (- y x) (/ (- z t) (- a t)) x)
(fma (/ (* (- y x) (- z a)) t) -1.0 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-266) || !(t_1 <= 0.0)) {
tmp = fma((y - x), ((z - t) / (a - t)), x);
} else {
tmp = fma((((y - x) * (z - a)) / t), -1.0, 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-266) || !(t_1 <= 0.0)) tmp = fma(Float64(y - x), Float64(Float64(z - t) / Float64(a - t)), x); else tmp = fma(Float64(Float64(Float64(y - x) * Float64(z - a)) / t), -1.0, 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-266], N[Not[LessEqual[t$95$1, 0.0]], $MachinePrecision]], N[(N[(y - x), $MachinePrecision] * N[(N[(z - t), $MachinePrecision] / N[(a - t), $MachinePrecision]), $MachinePrecision] + x), $MachinePrecision], N[(N[(N[(N[(y - x), $MachinePrecision] * N[(z - a), $MachinePrecision]), $MachinePrecision] / t), $MachinePrecision] * -1.0 + 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^{-266} \lor \neg \left(t\_1 \leq 0\right):\\
\;\;\;\;\mathsf{fma}\left(y - x, \frac{z - t}{a - t}, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{\left(y - x\right) \cdot \left(z - a\right)}{t}, -1, y\right)\\
\end{array}
\end{array}
if (+.f64 x (/.f64 (*.f64 (-.f64 y x) (-.f64 z t)) (-.f64 a t))) < -2e-266 or 0.0 < (+.f64 x (/.f64 (*.f64 (-.f64 y x) (-.f64 z t)) (-.f64 a t))) Initial program 67.3%
lift-+.f64N/A
lift--.f64N/A
lift-/.f64N/A
lift--.f64N/A
lift--.f64N/A
lift-*.f64N/A
+-commutativeN/A
associate-/l*N/A
sub-divN/A
lower-fma.f64N/A
lift--.f64N/A
sub-divN/A
lower-/.f64N/A
lift--.f64N/A
lift--.f6487.9
Applied rewrites87.9%
if -2e-266 < (+.f64 x (/.f64 (*.f64 (-.f64 y x) (-.f64 z t)) (-.f64 a t))) < 0.0Initial program 4.0%
Taylor expanded in t around inf
associate--l+N/A
associate-*r/N/A
associate-*r/N/A
sub-divN/A
distribute-lft-out--N/A
associate-*r/N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites99.7%
Final simplification88.6%
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (+ x (/ (* (- y x) (- z t)) (- a t)))))
(if (or (<= t_1 -2e-266) (not (<= t_1 0.0)))
(fma (- y x) (/ (- z t) (- a t)) x)
(fma (/ (* (- y x) z) t) -1.0 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-266) || !(t_1 <= 0.0)) {
tmp = fma((y - x), ((z - t) / (a - t)), x);
} else {
tmp = fma((((y - x) * z) / t), -1.0, 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-266) || !(t_1 <= 0.0)) tmp = fma(Float64(y - x), Float64(Float64(z - t) / Float64(a - t)), x); else tmp = fma(Float64(Float64(Float64(y - x) * z) / t), -1.0, 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-266], N[Not[LessEqual[t$95$1, 0.0]], $MachinePrecision]], N[(N[(y - x), $MachinePrecision] * N[(N[(z - t), $MachinePrecision] / N[(a - t), $MachinePrecision]), $MachinePrecision] + x), $MachinePrecision], N[(N[(N[(N[(y - x), $MachinePrecision] * z), $MachinePrecision] / t), $MachinePrecision] * -1.0 + 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^{-266} \lor \neg \left(t\_1 \leq 0\right):\\
\;\;\;\;\mathsf{fma}\left(y - x, \frac{z - t}{a - t}, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{\left(y - x\right) \cdot z}{t}, -1, y\right)\\
\end{array}
\end{array}
if (+.f64 x (/.f64 (*.f64 (-.f64 y x) (-.f64 z t)) (-.f64 a t))) < -2e-266 or 0.0 < (+.f64 x (/.f64 (*.f64 (-.f64 y x) (-.f64 z t)) (-.f64 a t))) Initial program 67.3%
lift-+.f64N/A
lift--.f64N/A
lift-/.f64N/A
lift--.f64N/A
lift--.f64N/A
lift-*.f64N/A
+-commutativeN/A
associate-/l*N/A
sub-divN/A
lower-fma.f64N/A
lift--.f64N/A
sub-divN/A
lower-/.f64N/A
lift--.f64N/A
lift--.f6487.9
Applied rewrites87.9%
if -2e-266 < (+.f64 x (/.f64 (*.f64 (-.f64 y x) (-.f64 z t)) (-.f64 a t))) < 0.0Initial program 4.0%
Taylor expanded in t around inf
associate--l+N/A
associate-*r/N/A
associate-*r/N/A
sub-divN/A
distribute-lft-out--N/A
associate-*r/N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites99.7%
Taylor expanded in z around inf
Applied rewrites69.6%
Final simplification86.9%
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (* (- y x) (/ z a))))
(if (<= z -6.2e+39)
t_1
(if (<= z 3.8e-117) (+ x y) (if (<= z 1.25e+69) x t_1)))))
double code(double x, double y, double z, double t, double a) {
double t_1 = (y - x) * (z / a);
double tmp;
if (z <= -6.2e+39) {
tmp = t_1;
} else if (z <= 3.8e-117) {
tmp = x + y;
} else if (z <= 1.25e+69) {
tmp = 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 = (y - x) * (z / a)
if (z <= (-6.2d+39)) then
tmp = t_1
else if (z <= 3.8d-117) then
tmp = x + y
else if (z <= 1.25d+69) then
tmp = 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 = (y - x) * (z / a);
double tmp;
if (z <= -6.2e+39) {
tmp = t_1;
} else if (z <= 3.8e-117) {
tmp = x + y;
} else if (z <= 1.25e+69) {
tmp = x;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z, t, a): t_1 = (y - x) * (z / a) tmp = 0 if z <= -6.2e+39: tmp = t_1 elif z <= 3.8e-117: tmp = x + y elif z <= 1.25e+69: tmp = x else: tmp = t_1 return tmp
function code(x, y, z, t, a) t_1 = Float64(Float64(y - x) * Float64(z / a)) tmp = 0.0 if (z <= -6.2e+39) tmp = t_1; elseif (z <= 3.8e-117) tmp = Float64(x + y); elseif (z <= 1.25e+69) tmp = x; else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z, t, a) t_1 = (y - x) * (z / a); tmp = 0.0; if (z <= -6.2e+39) tmp = t_1; elseif (z <= 3.8e-117) tmp = x + y; elseif (z <= 1.25e+69) tmp = x; else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(N[(y - x), $MachinePrecision] * N[(z / a), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -6.2e+39], t$95$1, If[LessEqual[z, 3.8e-117], N[(x + y), $MachinePrecision], If[LessEqual[z, 1.25e+69], x, t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left(y - x\right) \cdot \frac{z}{a}\\
\mathbf{if}\;z \leq -6.2 \cdot 10^{+39}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \leq 3.8 \cdot 10^{-117}:\\
\;\;\;\;x + y\\
\mathbf{elif}\;z \leq 1.25 \cdot 10^{+69}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if z < -6.2000000000000005e39 or 1.25000000000000009e69 < z Initial program 63.3%
Taylor expanded in z around inf
sub-divN/A
associate-/l*N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift--.f64N/A
lift--.f6458.8
Applied rewrites58.8%
Taylor expanded in t around 0
Applied rewrites39.0%
lift-/.f64N/A
lift--.f64N/A
lift-*.f64N/A
associate-/l*N/A
lower-*.f64N/A
lift--.f64N/A
lower-/.f6449.4
Applied rewrites49.4%
if -6.2000000000000005e39 < z < 3.79999999999999972e-117Initial program 63.0%
Taylor expanded in t around inf
lift--.f6421.7
Applied rewrites21.7%
Taylor expanded in x around 0
Applied rewrites44.4%
if 3.79999999999999972e-117 < z < 1.25000000000000009e69Initial program 67.8%
Taylor expanded in a around inf
Applied rewrites42.4%
Final simplification46.1%
(FPCore (x y z t a)
:precision binary64
(if (<= a -2.65e+169)
x
(if (<= a -4e-76)
(+ x y)
(if (<= a 7.8e-267) (* (/ (- x y) t) z) (if (<= a 54.0) y x)))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (a <= -2.65e+169) {
tmp = x;
} else if (a <= -4e-76) {
tmp = x + y;
} else if (a <= 7.8e-267) {
tmp = ((x - y) / t) * z;
} else if (a <= 54.0) {
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 <= (-2.65d+169)) then
tmp = x
else if (a <= (-4d-76)) then
tmp = x + y
else if (a <= 7.8d-267) then
tmp = ((x - y) / t) * z
else if (a <= 54.0d0) 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 <= -2.65e+169) {
tmp = x;
} else if (a <= -4e-76) {
tmp = x + y;
} else if (a <= 7.8e-267) {
tmp = ((x - y) / t) * z;
} else if (a <= 54.0) {
tmp = y;
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z, t, a): tmp = 0 if a <= -2.65e+169: tmp = x elif a <= -4e-76: tmp = x + y elif a <= 7.8e-267: tmp = ((x - y) / t) * z elif a <= 54.0: tmp = y else: tmp = x return tmp
function code(x, y, z, t, a) tmp = 0.0 if (a <= -2.65e+169) tmp = x; elseif (a <= -4e-76) tmp = Float64(x + y); elseif (a <= 7.8e-267) tmp = Float64(Float64(Float64(x - y) / t) * z); elseif (a <= 54.0) tmp = y; else tmp = x; end return tmp end
function tmp_2 = code(x, y, z, t, a) tmp = 0.0; if (a <= -2.65e+169) tmp = x; elseif (a <= -4e-76) tmp = x + y; elseif (a <= 7.8e-267) tmp = ((x - y) / t) * z; elseif (a <= 54.0) tmp = y; else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := If[LessEqual[a, -2.65e+169], x, If[LessEqual[a, -4e-76], N[(x + y), $MachinePrecision], If[LessEqual[a, 7.8e-267], N[(N[(N[(x - y), $MachinePrecision] / t), $MachinePrecision] * z), $MachinePrecision], If[LessEqual[a, 54.0], y, x]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -2.65 \cdot 10^{+169}:\\
\;\;\;\;x\\
\mathbf{elif}\;a \leq -4 \cdot 10^{-76}:\\
\;\;\;\;x + y\\
\mathbf{elif}\;a \leq 7.8 \cdot 10^{-267}:\\
\;\;\;\;\frac{x - y}{t} \cdot z\\
\mathbf{elif}\;a \leq 54:\\
\;\;\;\;y\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if a < -2.64999999999999995e169 or 54 < a Initial program 63.5%
Taylor expanded in a around inf
Applied rewrites49.1%
if -2.64999999999999995e169 < a < -3.99999999999999971e-76Initial program 63.5%
Taylor expanded in t around inf
lift--.f6426.7
Applied rewrites26.7%
Taylor expanded in x around 0
Applied rewrites42.7%
if -3.99999999999999971e-76 < a < 7.79999999999999954e-267Initial program 53.9%
Taylor expanded in z around inf
sub-divN/A
associate-/l*N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift--.f64N/A
lift--.f6464.2
Applied rewrites64.2%
Taylor expanded in t around 0
Applied rewrites26.2%
Taylor expanded in t around inf
mul-1-negN/A
lower-neg.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lift--.f6449.9
Applied rewrites49.9%
Taylor expanded in z around 0
*-commutativeN/A
lower-*.f64N/A
sub-divN/A
lower-/.f64N/A
lower--.f6448.9
Applied rewrites48.9%
if 7.79999999999999954e-267 < a < 54Initial program 73.1%
Taylor expanded in t around inf
Applied rewrites40.7%
Final simplification46.1%
(FPCore (x y z t a)
:precision binary64
(if (<= a -2.65e+169)
x
(if (<= a -6.5e-96)
(+ x y)
(if (<= a 7.4e-268) (* x (/ (- z a) t)) (if (<= a 54.0) y x)))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (a <= -2.65e+169) {
tmp = x;
} else if (a <= -6.5e-96) {
tmp = x + y;
} else if (a <= 7.4e-268) {
tmp = x * ((z - a) / t);
} else if (a <= 54.0) {
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 <= (-2.65d+169)) then
tmp = x
else if (a <= (-6.5d-96)) then
tmp = x + y
else if (a <= 7.4d-268) then
tmp = x * ((z - a) / t)
else if (a <= 54.0d0) 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 <= -2.65e+169) {
tmp = x;
} else if (a <= -6.5e-96) {
tmp = x + y;
} else if (a <= 7.4e-268) {
tmp = x * ((z - a) / t);
} else if (a <= 54.0) {
tmp = y;
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z, t, a): tmp = 0 if a <= -2.65e+169: tmp = x elif a <= -6.5e-96: tmp = x + y elif a <= 7.4e-268: tmp = x * ((z - a) / t) elif a <= 54.0: tmp = y else: tmp = x return tmp
function code(x, y, z, t, a) tmp = 0.0 if (a <= -2.65e+169) tmp = x; elseif (a <= -6.5e-96) tmp = Float64(x + y); elseif (a <= 7.4e-268) tmp = Float64(x * Float64(Float64(z - a) / t)); elseif (a <= 54.0) tmp = y; else tmp = x; end return tmp end
function tmp_2 = code(x, y, z, t, a) tmp = 0.0; if (a <= -2.65e+169) tmp = x; elseif (a <= -6.5e-96) tmp = x + y; elseif (a <= 7.4e-268) tmp = x * ((z - a) / t); elseif (a <= 54.0) tmp = y; else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := If[LessEqual[a, -2.65e+169], x, If[LessEqual[a, -6.5e-96], N[(x + y), $MachinePrecision], If[LessEqual[a, 7.4e-268], N[(x * N[(N[(z - a), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision], If[LessEqual[a, 54.0], y, x]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -2.65 \cdot 10^{+169}:\\
\;\;\;\;x\\
\mathbf{elif}\;a \leq -6.5 \cdot 10^{-96}:\\
\;\;\;\;x + y\\
\mathbf{elif}\;a \leq 7.4 \cdot 10^{-268}:\\
\;\;\;\;x \cdot \frac{z - a}{t}\\
\mathbf{elif}\;a \leq 54:\\
\;\;\;\;y\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if a < -2.64999999999999995e169 or 54 < a Initial program 63.5%
Taylor expanded in a around inf
Applied rewrites49.1%
if -2.64999999999999995e169 < a < -6.50000000000000001e-96Initial program 62.7%
Taylor expanded in t around inf
lift--.f6426.7
Applied rewrites26.7%
Taylor expanded in x around 0
Applied rewrites41.6%
if -6.50000000000000001e-96 < a < 7.40000000000000036e-268Initial program 54.1%
Taylor expanded in t around inf
associate--l+N/A
associate-*r/N/A
associate-*r/N/A
sub-divN/A
distribute-lft-out--N/A
associate-*r/N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites72.8%
Taylor expanded in x around inf
lower-*.f64N/A
sub-divN/A
lower-/.f64N/A
lift--.f6444.7
Applied rewrites44.7%
if 7.40000000000000036e-268 < a < 54Initial program 73.1%
Taylor expanded in t around inf
Applied rewrites40.7%
Final simplification45.0%
(FPCore (x y z t a) :precision binary64 (if (or (<= t -1.32e+23) (not (<= t 2.45e+76))) (* y (/ (- z t) (- a t))) (fma (- y x) (/ z (- a t)) x)))
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((t <= -1.32e+23) || !(t <= 2.45e+76)) {
tmp = y * ((z - t) / (a - t));
} else {
tmp = fma((y - x), (z / (a - t)), x);
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if ((t <= -1.32e+23) || !(t <= 2.45e+76)) tmp = Float64(y * Float64(Float64(z - t) / Float64(a - t))); else tmp = fma(Float64(y - x), Float64(z / Float64(a - t)), x); end return tmp end
code[x_, y_, z_, t_, a_] := If[Or[LessEqual[t, -1.32e+23], N[Not[LessEqual[t, 2.45e+76]], $MachinePrecision]], N[(y * N[(N[(z - t), $MachinePrecision] / N[(a - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(y - x), $MachinePrecision] * N[(z / N[(a - t), $MachinePrecision]), $MachinePrecision] + x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -1.32 \cdot 10^{+23} \lor \neg \left(t \leq 2.45 \cdot 10^{+76}\right):\\
\;\;\;\;y \cdot \frac{z - t}{a - t}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(y - x, \frac{z}{a - t}, x\right)\\
\end{array}
\end{array}
if t < -1.3199999999999999e23 or 2.45000000000000013e76 < t Initial program 33.4%
lift-+.f64N/A
lift--.f64N/A
lift-/.f64N/A
lift--.f64N/A
lift--.f64N/A
lift-*.f64N/A
+-commutativeN/A
associate-/l*N/A
sub-divN/A
lower-fma.f64N/A
lift--.f64N/A
sub-divN/A
lower-/.f64N/A
lift--.f64N/A
lift--.f6467.5
Applied rewrites67.5%
Taylor expanded in y around inf
sub-divN/A
lower-*.f64N/A
lift-/.f64N/A
lift--.f64N/A
lift--.f6460.7
Applied rewrites60.7%
if -1.3199999999999999e23 < t < 2.45000000000000013e76Initial program 87.9%
lift-+.f64N/A
lift--.f64N/A
lift-/.f64N/A
lift--.f64N/A
lift--.f64N/A
lift-*.f64N/A
+-commutativeN/A
associate-/l*N/A
sub-divN/A
lower-fma.f64N/A
lift--.f64N/A
sub-divN/A
lower-/.f64N/A
lift--.f64N/A
lift--.f6495.8
Applied rewrites95.8%
Taylor expanded in z around inf
Applied rewrites91.5%
Final simplification77.9%
(FPCore (x y z t a) :precision binary64 (if (or (<= a -1.4e+20) (not (<= a 1.75e-98))) (fma (- y x) (/ (- z t) a) x) (fma (- z) (/ (- y x) t) y)))
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((a <= -1.4e+20) || !(a <= 1.75e-98)) {
tmp = fma((y - x), ((z - t) / a), x);
} else {
tmp = fma(-z, ((y - x) / t), y);
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if ((a <= -1.4e+20) || !(a <= 1.75e-98)) tmp = fma(Float64(y - x), Float64(Float64(z - t) / a), x); else tmp = fma(Float64(-z), Float64(Float64(y - x) / t), y); end return tmp end
code[x_, y_, z_, t_, a_] := If[Or[LessEqual[a, -1.4e+20], N[Not[LessEqual[a, 1.75e-98]], $MachinePrecision]], N[(N[(y - x), $MachinePrecision] * N[(N[(z - t), $MachinePrecision] / a), $MachinePrecision] + x), $MachinePrecision], N[((-z) * N[(N[(y - x), $MachinePrecision] / t), $MachinePrecision] + y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -1.4 \cdot 10^{+20} \lor \neg \left(a \leq 1.75 \cdot 10^{-98}\right):\\
\;\;\;\;\mathsf{fma}\left(y - x, \frac{z - t}{a}, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(-z, \frac{y - x}{t}, y\right)\\
\end{array}
\end{array}
if a < -1.4e20 or 1.7500000000000001e-98 < a Initial program 64.5%
Taylor expanded in a around inf
+-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lift--.f64N/A
lower-/.f64N/A
lift--.f6478.1
Applied rewrites78.1%
if -1.4e20 < a < 1.7500000000000001e-98Initial program 62.7%
Taylor expanded in t around inf
associate--l+N/A
associate-*r/N/A
associate-*r/N/A
sub-divN/A
distribute-lft-out--N/A
associate-*r/N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites68.4%
Taylor expanded in x around -inf
lower-/.f64N/A
lower-*.f64N/A
lift--.f6426.8
Applied rewrites26.8%
Taylor expanded in a around 0
+-commutativeN/A
associate-/l*N/A
sub-divN/A
associate-*r*N/A
mul-1-negN/A
lower-fma.f64N/A
lower-neg.f64N/A
sub-divN/A
lower-/.f64N/A
lift--.f6467.0
Applied rewrites67.0%
Final simplification73.7%
(FPCore (x y z t a) :precision binary64 (if (or (<= t -2.0) (not (<= t 4.9e+73))) (* y (/ (- z t) (- a t))) (fma (- y x) (/ z a) x)))
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((t <= -2.0) || !(t <= 4.9e+73)) {
tmp = y * ((z - t) / (a - t));
} else {
tmp = fma((y - x), (z / a), x);
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if ((t <= -2.0) || !(t <= 4.9e+73)) tmp = Float64(y * Float64(Float64(z - t) / Float64(a - t))); else tmp = fma(Float64(y - x), Float64(z / a), x); end return tmp end
code[x_, y_, z_, t_, a_] := If[Or[LessEqual[t, -2.0], N[Not[LessEqual[t, 4.9e+73]], $MachinePrecision]], N[(y * N[(N[(z - t), $MachinePrecision] / N[(a - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(y - x), $MachinePrecision] * N[(z / a), $MachinePrecision] + x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -2 \lor \neg \left(t \leq 4.9 \cdot 10^{+73}\right):\\
\;\;\;\;y \cdot \frac{z - t}{a - t}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(y - x, \frac{z}{a}, x\right)\\
\end{array}
\end{array}
if t < -2 or 4.8999999999999999e73 < t Initial program 35.4%
lift-+.f64N/A
lift--.f64N/A
lift-/.f64N/A
lift--.f64N/A
lift--.f64N/A
lift-*.f64N/A
+-commutativeN/A
associate-/l*N/A
sub-divN/A
lower-fma.f64N/A
lift--.f64N/A
sub-divN/A
lower-/.f64N/A
lift--.f64N/A
lift--.f6468.9
Applied rewrites68.9%
Taylor expanded in y around inf
sub-divN/A
lower-*.f64N/A
lift-/.f64N/A
lift--.f64N/A
lift--.f6460.7
Applied rewrites60.7%
if -2 < t < 4.8999999999999999e73Initial program 88.1%
lift-+.f64N/A
lift--.f64N/A
lift-/.f64N/A
lift--.f64N/A
lift--.f64N/A
lift-*.f64N/A
+-commutativeN/A
associate-/l*N/A
sub-divN/A
lower-fma.f64N/A
lift--.f64N/A
sub-divN/A
lower-/.f64N/A
lift--.f64N/A
lift--.f6495.7
Applied rewrites95.7%
Taylor expanded in t around 0
lower-/.f6478.5
Applied rewrites78.5%
Final simplification70.3%
(FPCore (x y z t a) :precision binary64 (if (or (<= t -5.5e+46) (not (<= t 4e+28))) (fma (- z) (/ (- y x) t) y) (fma (- y x) (/ z a) x)))
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((t <= -5.5e+46) || !(t <= 4e+28)) {
tmp = fma(-z, ((y - x) / t), y);
} else {
tmp = fma((y - x), (z / a), x);
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if ((t <= -5.5e+46) || !(t <= 4e+28)) tmp = fma(Float64(-z), Float64(Float64(y - x) / t), y); else tmp = fma(Float64(y - x), Float64(z / a), x); end return tmp end
code[x_, y_, z_, t_, a_] := If[Or[LessEqual[t, -5.5e+46], N[Not[LessEqual[t, 4e+28]], $MachinePrecision]], N[((-z) * N[(N[(y - x), $MachinePrecision] / t), $MachinePrecision] + y), $MachinePrecision], N[(N[(y - x), $MachinePrecision] * N[(z / a), $MachinePrecision] + x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -5.5 \cdot 10^{+46} \lor \neg \left(t \leq 4 \cdot 10^{+28}\right):\\
\;\;\;\;\mathsf{fma}\left(-z, \frac{y - x}{t}, y\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(y - x, \frac{z}{a}, x\right)\\
\end{array}
\end{array}
if t < -5.4999999999999998e46 or 3.99999999999999983e28 < t Initial program 29.4%
Taylor expanded in t around inf
associate--l+N/A
associate-*r/N/A
associate-*r/N/A
sub-divN/A
distribute-lft-out--N/A
associate-*r/N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites54.7%
Taylor expanded in x around -inf
lower-/.f64N/A
lower-*.f64N/A
lift--.f6420.5
Applied rewrites20.5%
Taylor expanded in a around 0
+-commutativeN/A
associate-/l*N/A
sub-divN/A
associate-*r*N/A
mul-1-negN/A
lower-fma.f64N/A
lower-neg.f64N/A
sub-divN/A
lower-/.f64N/A
lift--.f6459.8
Applied rewrites59.8%
if -5.4999999999999998e46 < t < 3.99999999999999983e28Initial program 88.9%
lift-+.f64N/A
lift--.f64N/A
lift-/.f64N/A
lift--.f64N/A
lift--.f64N/A
lift-*.f64N/A
+-commutativeN/A
associate-/l*N/A
sub-divN/A
lower-fma.f64N/A
lift--.f64N/A
sub-divN/A
lower-/.f64N/A
lift--.f64N/A
lift--.f6496.0
Applied rewrites96.0%
Taylor expanded in t around 0
lower-/.f6476.7
Applied rewrites76.7%
Final simplification69.6%
(FPCore (x y z t a) :precision binary64 (if (or (<= t -9.2e+44) (not (<= t 2.55e+57))) (fma (/ (- y x) t) a y) (fma (- y x) (/ z a) x)))
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((t <= -9.2e+44) || !(t <= 2.55e+57)) {
tmp = fma(((y - x) / t), a, y);
} else {
tmp = fma((y - x), (z / a), x);
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if ((t <= -9.2e+44) || !(t <= 2.55e+57)) tmp = fma(Float64(Float64(y - x) / t), a, y); else tmp = fma(Float64(y - x), Float64(z / a), x); end return tmp end
code[x_, y_, z_, t_, a_] := If[Or[LessEqual[t, -9.2e+44], N[Not[LessEqual[t, 2.55e+57]], $MachinePrecision]], N[(N[(N[(y - x), $MachinePrecision] / t), $MachinePrecision] * a + y), $MachinePrecision], N[(N[(y - x), $MachinePrecision] * N[(z / a), $MachinePrecision] + x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -9.2 \cdot 10^{+44} \lor \neg \left(t \leq 2.55 \cdot 10^{+57}\right):\\
\;\;\;\;\mathsf{fma}\left(\frac{y - x}{t}, a, y\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(y - x, \frac{z}{a}, x\right)\\
\end{array}
\end{array}
if t < -9.20000000000000018e44 or 2.55000000000000011e57 < t Initial program 28.5%
Taylor expanded in t around inf
associate--l+N/A
associate-*r/N/A
associate-*r/N/A
sub-divN/A
distribute-lft-out--N/A
associate-*r/N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites54.7%
Taylor expanded in x around -inf
lower-/.f64N/A
lower-*.f64N/A
lift--.f6421.4
Applied rewrites21.4%
Taylor expanded in z around 0
+-commutativeN/A
associate-/l*N/A
sub-divN/A
*-commutativeN/A
lower-fma.f64N/A
sub-divN/A
lower-/.f64N/A
lift--.f6453.7
Applied rewrites53.7%
if -9.20000000000000018e44 < t < 2.55000000000000011e57Initial program 89.6%
lift-+.f64N/A
lift--.f64N/A
lift-/.f64N/A
lift--.f64N/A
lift--.f64N/A
lift-*.f64N/A
+-commutativeN/A
associate-/l*N/A
sub-divN/A
lower-fma.f64N/A
lift--.f64N/A
sub-divN/A
lower-/.f64N/A
lift--.f64N/A
lift--.f6496.6
Applied rewrites96.6%
Taylor expanded in t around 0
lower-/.f6477.3
Applied rewrites77.3%
Final simplification67.4%
(FPCore (x y z t a) :precision binary64 (if (or (<= t -9.2e+44) (not (<= t 2.55e+57))) (fma (/ (- y x) t) a y) (fma z (/ (- y x) a) x)))
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((t <= -9.2e+44) || !(t <= 2.55e+57)) {
tmp = fma(((y - x) / t), a, y);
} else {
tmp = fma(z, ((y - x) / a), x);
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if ((t <= -9.2e+44) || !(t <= 2.55e+57)) tmp = fma(Float64(Float64(y - x) / t), a, y); else tmp = fma(z, Float64(Float64(y - x) / a), x); end return tmp end
code[x_, y_, z_, t_, a_] := If[Or[LessEqual[t, -9.2e+44], N[Not[LessEqual[t, 2.55e+57]], $MachinePrecision]], N[(N[(N[(y - x), $MachinePrecision] / t), $MachinePrecision] * a + y), $MachinePrecision], N[(z * N[(N[(y - x), $MachinePrecision] / a), $MachinePrecision] + x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -9.2 \cdot 10^{+44} \lor \neg \left(t \leq 2.55 \cdot 10^{+57}\right):\\
\;\;\;\;\mathsf{fma}\left(\frac{y - x}{t}, a, y\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(z, \frac{y - x}{a}, x\right)\\
\end{array}
\end{array}
if t < -9.20000000000000018e44 or 2.55000000000000011e57 < t Initial program 28.5%
Taylor expanded in t around inf
associate--l+N/A
associate-*r/N/A
associate-*r/N/A
sub-divN/A
distribute-lft-out--N/A
associate-*r/N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites54.7%
Taylor expanded in x around -inf
lower-/.f64N/A
lower-*.f64N/A
lift--.f6421.4
Applied rewrites21.4%
Taylor expanded in z around 0
+-commutativeN/A
associate-/l*N/A
sub-divN/A
*-commutativeN/A
lower-fma.f64N/A
sub-divN/A
lower-/.f64N/A
lift--.f6453.7
Applied rewrites53.7%
if -9.20000000000000018e44 < t < 2.55000000000000011e57Initial program 89.6%
Taylor expanded in t around 0
+-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f64N/A
lift--.f6476.6
Applied rewrites76.6%
Final simplification67.0%
(FPCore (x y z t a) :precision binary64 (if (or (<= t -1.4e+41) (not (<= t 1.8e+55))) (fma (/ (- y x) t) a y) x))
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((t <= -1.4e+41) || !(t <= 1.8e+55)) {
tmp = fma(((y - x) / t), a, y);
} else {
tmp = x;
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if ((t <= -1.4e+41) || !(t <= 1.8e+55)) tmp = fma(Float64(Float64(y - x) / t), a, y); else tmp = x; end return tmp end
code[x_, y_, z_, t_, a_] := If[Or[LessEqual[t, -1.4e+41], N[Not[LessEqual[t, 1.8e+55]], $MachinePrecision]], N[(N[(N[(y - x), $MachinePrecision] / t), $MachinePrecision] * a + y), $MachinePrecision], x]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -1.4 \cdot 10^{+41} \lor \neg \left(t \leq 1.8 \cdot 10^{+55}\right):\\
\;\;\;\;\mathsf{fma}\left(\frac{y - x}{t}, a, y\right)\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if t < -1.4e41 or 1.79999999999999994e55 < t Initial program 28.5%
Taylor expanded in t around inf
associate--l+N/A
associate-*r/N/A
associate-*r/N/A
sub-divN/A
distribute-lft-out--N/A
associate-*r/N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites54.7%
Taylor expanded in x around -inf
lower-/.f64N/A
lower-*.f64N/A
lift--.f6421.4
Applied rewrites21.4%
Taylor expanded in z around 0
+-commutativeN/A
associate-/l*N/A
sub-divN/A
*-commutativeN/A
lower-fma.f64N/A
sub-divN/A
lower-/.f64N/A
lift--.f6453.7
Applied rewrites53.7%
if -1.4e41 < t < 1.79999999999999994e55Initial program 89.6%
Taylor expanded in a around inf
Applied rewrites42.6%
Final simplification47.3%
(FPCore (x y z t a) :precision binary64 (if (<= t -5.2e+51) y (if (<= t 9.5e+77) x y)))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (t <= -5.2e+51) {
tmp = y;
} else if (t <= 9.5e+77) {
tmp = x;
} else {
tmp = y;
}
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 (t <= (-5.2d+51)) then
tmp = y
else if (t <= 9.5d+77) then
tmp = x
else
tmp = y
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a) {
double tmp;
if (t <= -5.2e+51) {
tmp = y;
} else if (t <= 9.5e+77) {
tmp = x;
} else {
tmp = y;
}
return tmp;
}
def code(x, y, z, t, a): tmp = 0 if t <= -5.2e+51: tmp = y elif t <= 9.5e+77: tmp = x else: tmp = y return tmp
function code(x, y, z, t, a) tmp = 0.0 if (t <= -5.2e+51) tmp = y; elseif (t <= 9.5e+77) tmp = x; else tmp = y; end return tmp end
function tmp_2 = code(x, y, z, t, a) tmp = 0.0; if (t <= -5.2e+51) tmp = y; elseif (t <= 9.5e+77) tmp = x; else tmp = y; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := If[LessEqual[t, -5.2e+51], y, If[LessEqual[t, 9.5e+77], x, y]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -5.2 \cdot 10^{+51}:\\
\;\;\;\;y\\
\mathbf{elif}\;t \leq 9.5 \cdot 10^{+77}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;y\\
\end{array}
\end{array}
if t < -5.2000000000000002e51 or 9.4999999999999998e77 < t Initial program 28.6%
Taylor expanded in t around inf
Applied rewrites40.9%
if -5.2000000000000002e51 < t < 9.4999999999999998e77Initial program 87.9%
Taylor expanded in a around inf
Applied rewrites41.6%
Final simplification41.3%
(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 63.8%
Taylor expanded in a around inf
Applied rewrites28.4%
Final simplification28.4%
(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 2025064
(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))))