
(FPCore (x y z t) :precision binary64 (/ (* x (- y z)) (- t z)))
double code(double x, double y, double z, double t) {
return (x * (y - z)) / (t - z);
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z, t)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = (x * (y - z)) / (t - z)
end function
public static double code(double x, double y, double z, double t) {
return (x * (y - z)) / (t - z);
}
def code(x, y, z, t): return (x * (y - z)) / (t - z)
function code(x, y, z, t) return Float64(Float64(x * Float64(y - z)) / Float64(t - z)) end
function tmp = code(x, y, z, t) tmp = (x * (y - z)) / (t - z); end
code[x_, y_, z_, t_] := N[(N[(x * N[(y - z), $MachinePrecision]), $MachinePrecision] / N[(t - z), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x \cdot \left(y - z\right)}{t - z}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 12 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z t) :precision binary64 (/ (* x (- y z)) (- t z)))
double code(double x, double y, double z, double t) {
return (x * (y - z)) / (t - z);
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z, t)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = (x * (y - z)) / (t - z)
end function
public static double code(double x, double y, double z, double t) {
return (x * (y - z)) / (t - z);
}
def code(x, y, z, t): return (x * (y - z)) / (t - z)
function code(x, y, z, t) return Float64(Float64(x * Float64(y - z)) / Float64(t - z)) end
function tmp = code(x, y, z, t) tmp = (x * (y - z)) / (t - z); end
code[x_, y_, z_, t_] := N[(N[(x * N[(y - z), $MachinePrecision]), $MachinePrecision] / N[(t - z), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x \cdot \left(y - z\right)}{t - z}
\end{array}
x\_m = (fabs.f64 x)
x\_s = (copysign.f64 #s(literal 1 binary64) x)
(FPCore (x_s x_m y z t)
:precision binary64
(let* ((t_1 (/ (* x_m (- y z)) (- t z))))
(*
x_s
(if (<= t_1 0.0)
(* x_m (* (/ (- y z) (+ z t)) (/ (+ z t) (- t z))))
(if (<= t_1 5e+303) t_1 (* (/ x_m (- t z)) (- y z)))))))x\_m = fabs(x);
x\_s = copysign(1.0, x);
double code(double x_s, double x_m, double y, double z, double t) {
double t_1 = (x_m * (y - z)) / (t - z);
double tmp;
if (t_1 <= 0.0) {
tmp = x_m * (((y - z) / (z + t)) * ((z + t) / (t - z)));
} else if (t_1 <= 5e+303) {
tmp = t_1;
} else {
tmp = (x_m / (t - z)) * (y - z);
}
return x_s * tmp;
}
x\_m = private
x\_s = private
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_s, x_m, y, z, t)
use fmin_fmax_functions
real(8), intent (in) :: x_s
real(8), intent (in) :: x_m
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: t_1
real(8) :: tmp
t_1 = (x_m * (y - z)) / (t - z)
if (t_1 <= 0.0d0) then
tmp = x_m * (((y - z) / (z + t)) * ((z + t) / (t - z)))
else if (t_1 <= 5d+303) then
tmp = t_1
else
tmp = (x_m / (t - z)) * (y - z)
end if
code = x_s * tmp
end function
x\_m = Math.abs(x);
x\_s = Math.copySign(1.0, x);
public static double code(double x_s, double x_m, double y, double z, double t) {
double t_1 = (x_m * (y - z)) / (t - z);
double tmp;
if (t_1 <= 0.0) {
tmp = x_m * (((y - z) / (z + t)) * ((z + t) / (t - z)));
} else if (t_1 <= 5e+303) {
tmp = t_1;
} else {
tmp = (x_m / (t - z)) * (y - z);
}
return x_s * tmp;
}
x\_m = math.fabs(x) x\_s = math.copysign(1.0, x) def code(x_s, x_m, y, z, t): t_1 = (x_m * (y - z)) / (t - z) tmp = 0 if t_1 <= 0.0: tmp = x_m * (((y - z) / (z + t)) * ((z + t) / (t - z))) elif t_1 <= 5e+303: tmp = t_1 else: tmp = (x_m / (t - z)) * (y - z) return x_s * tmp
x\_m = abs(x) x\_s = copysign(1.0, x) function code(x_s, x_m, y, z, t) t_1 = Float64(Float64(x_m * Float64(y - z)) / Float64(t - z)) tmp = 0.0 if (t_1 <= 0.0) tmp = Float64(x_m * Float64(Float64(Float64(y - z) / Float64(z + t)) * Float64(Float64(z + t) / Float64(t - z)))); elseif (t_1 <= 5e+303) tmp = t_1; else tmp = Float64(Float64(x_m / Float64(t - z)) * Float64(y - z)); end return Float64(x_s * tmp) end
x\_m = abs(x); x\_s = sign(x) * abs(1.0); function tmp_2 = code(x_s, x_m, y, z, t) t_1 = (x_m * (y - z)) / (t - z); tmp = 0.0; if (t_1 <= 0.0) tmp = x_m * (((y - z) / (z + t)) * ((z + t) / (t - z))); elseif (t_1 <= 5e+303) tmp = t_1; else tmp = (x_m / (t - z)) * (y - z); end tmp_2 = x_s * tmp; end
x\_m = N[Abs[x], $MachinePrecision]
x\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[x$95$s_, x$95$m_, y_, z_, t_] := Block[{t$95$1 = N[(N[(x$95$m * N[(y - z), $MachinePrecision]), $MachinePrecision] / N[(t - z), $MachinePrecision]), $MachinePrecision]}, N[(x$95$s * If[LessEqual[t$95$1, 0.0], N[(x$95$m * N[(N[(N[(y - z), $MachinePrecision] / N[(z + t), $MachinePrecision]), $MachinePrecision] * N[(N[(z + t), $MachinePrecision] / N[(t - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 5e+303], t$95$1, N[(N[(x$95$m / N[(t - z), $MachinePrecision]), $MachinePrecision] * N[(y - z), $MachinePrecision]), $MachinePrecision]]]), $MachinePrecision]]
\begin{array}{l}
x\_m = \left|x\right|
\\
x\_s = \mathsf{copysign}\left(1, x\right)
\\
\begin{array}{l}
t_1 := \frac{x\_m \cdot \left(y - z\right)}{t - z}\\
x\_s \cdot \begin{array}{l}
\mathbf{if}\;t\_1 \leq 0:\\
\;\;\;\;x\_m \cdot \left(\frac{y - z}{z + t} \cdot \frac{z + t}{t - z}\right)\\
\mathbf{elif}\;t\_1 \leq 5 \cdot 10^{+303}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;\frac{x\_m}{t - z} \cdot \left(y - z\right)\\
\end{array}
\end{array}
\end{array}
if (/.f64 (*.f64 x (-.f64 y z)) (-.f64 t z)) < -0.0Initial program 88.9%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6485.2
Applied rewrites85.2%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
*-commutativeN/A
lift-*.f64N/A
lift--.f64N/A
flip--N/A
difference-of-squares-revN/A
lift-+.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-+.f64N/A
associate-/r/N/A
lift-+.f64N/A
flip-+N/A
difference-of-squares-revN/A
lift-+.f64N/A
lift--.f64N/A
*-commutativeN/A
lift--.f64N/A
associate-/l*N/A
associate-*r*N/A
Applied rewrites96.6%
if -0.0 < (/.f64 (*.f64 x (-.f64 y z)) (-.f64 t z)) < 4.9999999999999997e303Initial program 98.9%
if 4.9999999999999997e303 < (/.f64 (*.f64 x (-.f64 y z)) (-.f64 t z)) Initial program 36.3%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6499.8
Applied rewrites99.8%
x\_m = (fabs.f64 x)
x\_s = (copysign.f64 #s(literal 1 binary64) x)
(FPCore (x_s x_m y z t)
:precision binary64
(let* ((t_1 (/ (* x_m (- y z)) (- t z))))
(*
x_s
(if (or (<= t_1 -4e+289) (not (<= t_1 5e+303)))
(* (/ x_m (- t z)) (- y z))
t_1))))x\_m = fabs(x);
x\_s = copysign(1.0, x);
double code(double x_s, double x_m, double y, double z, double t) {
double t_1 = (x_m * (y - z)) / (t - z);
double tmp;
if ((t_1 <= -4e+289) || !(t_1 <= 5e+303)) {
tmp = (x_m / (t - z)) * (y - z);
} else {
tmp = t_1;
}
return x_s * tmp;
}
x\_m = private
x\_s = private
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_s, x_m, y, z, t)
use fmin_fmax_functions
real(8), intent (in) :: x_s
real(8), intent (in) :: x_m
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: t_1
real(8) :: tmp
t_1 = (x_m * (y - z)) / (t - z)
if ((t_1 <= (-4d+289)) .or. (.not. (t_1 <= 5d+303))) then
tmp = (x_m / (t - z)) * (y - z)
else
tmp = t_1
end if
code = x_s * tmp
end function
x\_m = Math.abs(x);
x\_s = Math.copySign(1.0, x);
public static double code(double x_s, double x_m, double y, double z, double t) {
double t_1 = (x_m * (y - z)) / (t - z);
double tmp;
if ((t_1 <= -4e+289) || !(t_1 <= 5e+303)) {
tmp = (x_m / (t - z)) * (y - z);
} else {
tmp = t_1;
}
return x_s * tmp;
}
x\_m = math.fabs(x) x\_s = math.copysign(1.0, x) def code(x_s, x_m, y, z, t): t_1 = (x_m * (y - z)) / (t - z) tmp = 0 if (t_1 <= -4e+289) or not (t_1 <= 5e+303): tmp = (x_m / (t - z)) * (y - z) else: tmp = t_1 return x_s * tmp
x\_m = abs(x) x\_s = copysign(1.0, x) function code(x_s, x_m, y, z, t) t_1 = Float64(Float64(x_m * Float64(y - z)) / Float64(t - z)) tmp = 0.0 if ((t_1 <= -4e+289) || !(t_1 <= 5e+303)) tmp = Float64(Float64(x_m / Float64(t - z)) * Float64(y - z)); else tmp = t_1; end return Float64(x_s * tmp) end
x\_m = abs(x); x\_s = sign(x) * abs(1.0); function tmp_2 = code(x_s, x_m, y, z, t) t_1 = (x_m * (y - z)) / (t - z); tmp = 0.0; if ((t_1 <= -4e+289) || ~((t_1 <= 5e+303))) tmp = (x_m / (t - z)) * (y - z); else tmp = t_1; end tmp_2 = x_s * tmp; end
x\_m = N[Abs[x], $MachinePrecision]
x\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[x$95$s_, x$95$m_, y_, z_, t_] := Block[{t$95$1 = N[(N[(x$95$m * N[(y - z), $MachinePrecision]), $MachinePrecision] / N[(t - z), $MachinePrecision]), $MachinePrecision]}, N[(x$95$s * If[Or[LessEqual[t$95$1, -4e+289], N[Not[LessEqual[t$95$1, 5e+303]], $MachinePrecision]], N[(N[(x$95$m / N[(t - z), $MachinePrecision]), $MachinePrecision] * N[(y - z), $MachinePrecision]), $MachinePrecision], t$95$1]), $MachinePrecision]]
\begin{array}{l}
x\_m = \left|x\right|
\\
x\_s = \mathsf{copysign}\left(1, x\right)
\\
\begin{array}{l}
t_1 := \frac{x\_m \cdot \left(y - z\right)}{t - z}\\
x\_s \cdot \begin{array}{l}
\mathbf{if}\;t\_1 \leq -4 \cdot 10^{+289} \lor \neg \left(t\_1 \leq 5 \cdot 10^{+303}\right):\\
\;\;\;\;\frac{x\_m}{t - z} \cdot \left(y - z\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
\end{array}
if (/.f64 (*.f64 x (-.f64 y z)) (-.f64 t z)) < -4.0000000000000002e289 or 4.9999999999999997e303 < (/.f64 (*.f64 x (-.f64 y z)) (-.f64 t z)) Initial program 49.7%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6499.9
Applied rewrites99.9%
if -4.0000000000000002e289 < (/.f64 (*.f64 x (-.f64 y z)) (-.f64 t z)) < 4.9999999999999997e303Initial program 98.0%
Final simplification98.4%
x\_m = (fabs.f64 x)
x\_s = (copysign.f64 #s(literal 1 binary64) x)
(FPCore (x_s x_m y z t)
:precision binary64
(*
x_s
(if (<= z -5.2e-17)
(fma (- x_m) (/ y z) x_m)
(if (<= z 1.5e-81)
(* (/ x_m (- t z)) y)
(if (<= z 6.2e+54) (/ (* (- y z) x_m) t) (fma (- y) (/ x_m z) x_m))))))x\_m = fabs(x);
x\_s = copysign(1.0, x);
double code(double x_s, double x_m, double y, double z, double t) {
double tmp;
if (z <= -5.2e-17) {
tmp = fma(-x_m, (y / z), x_m);
} else if (z <= 1.5e-81) {
tmp = (x_m / (t - z)) * y;
} else if (z <= 6.2e+54) {
tmp = ((y - z) * x_m) / t;
} else {
tmp = fma(-y, (x_m / z), x_m);
}
return x_s * tmp;
}
x\_m = abs(x) x\_s = copysign(1.0, x) function code(x_s, x_m, y, z, t) tmp = 0.0 if (z <= -5.2e-17) tmp = fma(Float64(-x_m), Float64(y / z), x_m); elseif (z <= 1.5e-81) tmp = Float64(Float64(x_m / Float64(t - z)) * y); elseif (z <= 6.2e+54) tmp = Float64(Float64(Float64(y - z) * x_m) / t); else tmp = fma(Float64(-y), Float64(x_m / z), x_m); end return Float64(x_s * tmp) end
x\_m = N[Abs[x], $MachinePrecision]
x\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[x$95$s_, x$95$m_, y_, z_, t_] := N[(x$95$s * If[LessEqual[z, -5.2e-17], N[((-x$95$m) * N[(y / z), $MachinePrecision] + x$95$m), $MachinePrecision], If[LessEqual[z, 1.5e-81], N[(N[(x$95$m / N[(t - z), $MachinePrecision]), $MachinePrecision] * y), $MachinePrecision], If[LessEqual[z, 6.2e+54], N[(N[(N[(y - z), $MachinePrecision] * x$95$m), $MachinePrecision] / t), $MachinePrecision], N[((-y) * N[(x$95$m / z), $MachinePrecision] + x$95$m), $MachinePrecision]]]]), $MachinePrecision]
\begin{array}{l}
x\_m = \left|x\right|
\\
x\_s = \mathsf{copysign}\left(1, x\right)
\\
x\_s \cdot \begin{array}{l}
\mathbf{if}\;z \leq -5.2 \cdot 10^{-17}:\\
\;\;\;\;\mathsf{fma}\left(-x\_m, \frac{y}{z}, x\_m\right)\\
\mathbf{elif}\;z \leq 1.5 \cdot 10^{-81}:\\
\;\;\;\;\frac{x\_m}{t - z} \cdot y\\
\mathbf{elif}\;z \leq 6.2 \cdot 10^{+54}:\\
\;\;\;\;\frac{\left(y - z\right) \cdot x\_m}{t}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(-y, \frac{x\_m}{z}, x\_m\right)\\
\end{array}
\end{array}
if z < -5.20000000000000006e-17Initial program 79.9%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6467.2
Applied rewrites67.2%
Taylor expanded in z around inf
associate--l+N/A
fp-cancel-sub-sign-invN/A
metadata-evalN/A
*-lft-identityN/A
associate-*r/N/A
div-add-revN/A
mul-1-negN/A
distribute-rgt-neg-inN/A
mul-1-negN/A
*-commutativeN/A
distribute-lft-inN/A
+-commutativeN/A
+-commutativeN/A
*-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
Applied rewrites71.5%
Taylor expanded in t around 0
Applied rewrites80.4%
if -5.20000000000000006e-17 < z < 1.4999999999999999e-81Initial program 93.8%
Taylor expanded in y around inf
associate-*l/N/A
lower-*.f64N/A
lower-/.f64N/A
lower--.f6485.1
Applied rewrites85.1%
if 1.4999999999999999e-81 < z < 6.1999999999999999e54Initial program 99.7%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6488.4
Applied rewrites88.4%
Taylor expanded in t around inf
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f6479.0
Applied rewrites79.0%
if 6.1999999999999999e54 < z Initial program 74.6%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6469.1
Applied rewrites69.1%
Taylor expanded in z around inf
associate--l+N/A
fp-cancel-sub-sign-invN/A
metadata-evalN/A
*-lft-identityN/A
associate-*r/N/A
div-add-revN/A
mul-1-negN/A
distribute-rgt-neg-inN/A
mul-1-negN/A
*-commutativeN/A
distribute-lft-inN/A
+-commutativeN/A
+-commutativeN/A
*-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
Applied rewrites85.2%
Taylor expanded in y around inf
Applied rewrites85.4%
Final simplification83.4%
x\_m = (fabs.f64 x)
x\_s = (copysign.f64 #s(literal 1 binary64) x)
(FPCore (x_s x_m y z t)
:precision binary64
(*
x_s
(if (<= z -165000.0)
(* x_m (- 1.0 (/ (- y t) z)))
(if (<= z 6.6e+201)
(* (/ x_m (- t z)) (- y z))
(* (/ z (- t z)) (- x_m))))))x\_m = fabs(x);
x\_s = copysign(1.0, x);
double code(double x_s, double x_m, double y, double z, double t) {
double tmp;
if (z <= -165000.0) {
tmp = x_m * (1.0 - ((y - t) / z));
} else if (z <= 6.6e+201) {
tmp = (x_m / (t - z)) * (y - z);
} else {
tmp = (z / (t - z)) * -x_m;
}
return x_s * tmp;
}
x\_m = private
x\_s = private
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_s, x_m, y, z, t)
use fmin_fmax_functions
real(8), intent (in) :: x_s
real(8), intent (in) :: x_m
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: tmp
if (z <= (-165000.0d0)) then
tmp = x_m * (1.0d0 - ((y - t) / z))
else if (z <= 6.6d+201) then
tmp = (x_m / (t - z)) * (y - z)
else
tmp = (z / (t - z)) * -x_m
end if
code = x_s * tmp
end function
x\_m = Math.abs(x);
x\_s = Math.copySign(1.0, x);
public static double code(double x_s, double x_m, double y, double z, double t) {
double tmp;
if (z <= -165000.0) {
tmp = x_m * (1.0 - ((y - t) / z));
} else if (z <= 6.6e+201) {
tmp = (x_m / (t - z)) * (y - z);
} else {
tmp = (z / (t - z)) * -x_m;
}
return x_s * tmp;
}
x\_m = math.fabs(x) x\_s = math.copysign(1.0, x) def code(x_s, x_m, y, z, t): tmp = 0 if z <= -165000.0: tmp = x_m * (1.0 - ((y - t) / z)) elif z <= 6.6e+201: tmp = (x_m / (t - z)) * (y - z) else: tmp = (z / (t - z)) * -x_m return x_s * tmp
x\_m = abs(x) x\_s = copysign(1.0, x) function code(x_s, x_m, y, z, t) tmp = 0.0 if (z <= -165000.0) tmp = Float64(x_m * Float64(1.0 - Float64(Float64(y - t) / z))); elseif (z <= 6.6e+201) tmp = Float64(Float64(x_m / Float64(t - z)) * Float64(y - z)); else tmp = Float64(Float64(z / Float64(t - z)) * Float64(-x_m)); end return Float64(x_s * tmp) end
x\_m = abs(x); x\_s = sign(x) * abs(1.0); function tmp_2 = code(x_s, x_m, y, z, t) tmp = 0.0; if (z <= -165000.0) tmp = x_m * (1.0 - ((y - t) / z)); elseif (z <= 6.6e+201) tmp = (x_m / (t - z)) * (y - z); else tmp = (z / (t - z)) * -x_m; end tmp_2 = x_s * tmp; end
x\_m = N[Abs[x], $MachinePrecision]
x\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[x$95$s_, x$95$m_, y_, z_, t_] := N[(x$95$s * If[LessEqual[z, -165000.0], N[(x$95$m * N[(1.0 - N[(N[(y - t), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 6.6e+201], N[(N[(x$95$m / N[(t - z), $MachinePrecision]), $MachinePrecision] * N[(y - z), $MachinePrecision]), $MachinePrecision], N[(N[(z / N[(t - z), $MachinePrecision]), $MachinePrecision] * (-x$95$m)), $MachinePrecision]]]), $MachinePrecision]
\begin{array}{l}
x\_m = \left|x\right|
\\
x\_s = \mathsf{copysign}\left(1, x\right)
\\
x\_s \cdot \begin{array}{l}
\mathbf{if}\;z \leq -165000:\\
\;\;\;\;x\_m \cdot \left(1 - \frac{y - t}{z}\right)\\
\mathbf{elif}\;z \leq 6.6 \cdot 10^{+201}:\\
\;\;\;\;\frac{x\_m}{t - z} \cdot \left(y - z\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{z}{t - z} \cdot \left(-x\_m\right)\\
\end{array}
\end{array}
if z < -165000Initial program 78.9%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6465.5
Applied rewrites65.5%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
*-commutativeN/A
lift-*.f64N/A
lift--.f64N/A
flip--N/A
difference-of-squares-revN/A
lift-+.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-+.f64N/A
associate-/r/N/A
lift-+.f64N/A
flip-+N/A
difference-of-squares-revN/A
lift-+.f64N/A
lift--.f64N/A
*-commutativeN/A
lift--.f64N/A
associate-/l*N/A
associate-*r*N/A
Applied rewrites99.8%
Taylor expanded in z around inf
fp-cancel-sub-sign-invN/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
metadata-evalN/A
*-lft-identityN/A
associate-+l-N/A
div-subN/A
lower--.f64N/A
lower-/.f64N/A
lower--.f6479.8
Applied rewrites79.8%
if -165000 < z < 6.6e201Initial program 91.5%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6491.2
Applied rewrites91.2%
if 6.6e201 < z Initial program 71.7%
Taylor expanded in y around 0
mul-1-negN/A
associate-/l*N/A
*-commutativeN/A
distribute-rgt-neg-inN/A
mul-1-negN/A
lower-*.f64N/A
lower-/.f64N/A
lower--.f64N/A
mul-1-negN/A
lower-neg.f6499.9
Applied rewrites99.9%
x\_m = (fabs.f64 x)
x\_s = (copysign.f64 #s(literal 1 binary64) x)
(FPCore (x_s x_m y z t)
:precision binary64
(*
x_s
(if (or (<= z -5.2e-17) (not (<= z 6.2e+54)))
(fma (- x_m) (/ y z) x_m)
(/ (* (- y z) x_m) t))))x\_m = fabs(x);
x\_s = copysign(1.0, x);
double code(double x_s, double x_m, double y, double z, double t) {
double tmp;
if ((z <= -5.2e-17) || !(z <= 6.2e+54)) {
tmp = fma(-x_m, (y / z), x_m);
} else {
tmp = ((y - z) * x_m) / t;
}
return x_s * tmp;
}
x\_m = abs(x) x\_s = copysign(1.0, x) function code(x_s, x_m, y, z, t) tmp = 0.0 if ((z <= -5.2e-17) || !(z <= 6.2e+54)) tmp = fma(Float64(-x_m), Float64(y / z), x_m); else tmp = Float64(Float64(Float64(y - z) * x_m) / t); end return Float64(x_s * tmp) end
x\_m = N[Abs[x], $MachinePrecision]
x\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[x$95$s_, x$95$m_, y_, z_, t_] := N[(x$95$s * If[Or[LessEqual[z, -5.2e-17], N[Not[LessEqual[z, 6.2e+54]], $MachinePrecision]], N[((-x$95$m) * N[(y / z), $MachinePrecision] + x$95$m), $MachinePrecision], N[(N[(N[(y - z), $MachinePrecision] * x$95$m), $MachinePrecision] / t), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
x\_m = \left|x\right|
\\
x\_s = \mathsf{copysign}\left(1, x\right)
\\
x\_s \cdot \begin{array}{l}
\mathbf{if}\;z \leq -5.2 \cdot 10^{-17} \lor \neg \left(z \leq 6.2 \cdot 10^{+54}\right):\\
\;\;\;\;\mathsf{fma}\left(-x\_m, \frac{y}{z}, x\_m\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(y - z\right) \cdot x\_m}{t}\\
\end{array}
\end{array}
if z < -5.20000000000000006e-17 or 6.1999999999999999e54 < z Initial program 77.5%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6468.1
Applied rewrites68.1%
Taylor expanded in z around inf
associate--l+N/A
fp-cancel-sub-sign-invN/A
metadata-evalN/A
*-lft-identityN/A
associate-*r/N/A
div-add-revN/A
mul-1-negN/A
distribute-rgt-neg-inN/A
mul-1-negN/A
*-commutativeN/A
distribute-lft-inN/A
+-commutativeN/A
+-commutativeN/A
*-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
Applied rewrites77.8%
Taylor expanded in t around 0
Applied rewrites82.6%
if -5.20000000000000006e-17 < z < 6.1999999999999999e54Initial program 94.8%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6491.7
Applied rewrites91.7%
Taylor expanded in t around inf
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f6474.6
Applied rewrites74.6%
Final simplification78.2%
x\_m = (fabs.f64 x)
x\_s = (copysign.f64 #s(literal 1 binary64) x)
(FPCore (x_s x_m y z t)
:precision binary64
(*
x_s
(if (or (<= z -3.9e-73) (not (<= z 4.2e+54)))
(fma (- x_m) (/ y z) x_m)
(/ (* y x_m) t))))x\_m = fabs(x);
x\_s = copysign(1.0, x);
double code(double x_s, double x_m, double y, double z, double t) {
double tmp;
if ((z <= -3.9e-73) || !(z <= 4.2e+54)) {
tmp = fma(-x_m, (y / z), x_m);
} else {
tmp = (y * x_m) / t;
}
return x_s * tmp;
}
x\_m = abs(x) x\_s = copysign(1.0, x) function code(x_s, x_m, y, z, t) tmp = 0.0 if ((z <= -3.9e-73) || !(z <= 4.2e+54)) tmp = fma(Float64(-x_m), Float64(y / z), x_m); else tmp = Float64(Float64(y * x_m) / t); end return Float64(x_s * tmp) end
x\_m = N[Abs[x], $MachinePrecision]
x\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[x$95$s_, x$95$m_, y_, z_, t_] := N[(x$95$s * If[Or[LessEqual[z, -3.9e-73], N[Not[LessEqual[z, 4.2e+54]], $MachinePrecision]], N[((-x$95$m) * N[(y / z), $MachinePrecision] + x$95$m), $MachinePrecision], N[(N[(y * x$95$m), $MachinePrecision] / t), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
x\_m = \left|x\right|
\\
x\_s = \mathsf{copysign}\left(1, x\right)
\\
x\_s \cdot \begin{array}{l}
\mathbf{if}\;z \leq -3.9 \cdot 10^{-73} \lor \neg \left(z \leq 4.2 \cdot 10^{+54}\right):\\
\;\;\;\;\mathsf{fma}\left(-x\_m, \frac{y}{z}, x\_m\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{y \cdot x\_m}{t}\\
\end{array}
\end{array}
if z < -3.89999999999999982e-73 or 4.19999999999999972e54 < z Initial program 78.9%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6470.1
Applied rewrites70.1%
Taylor expanded in z around inf
associate--l+N/A
fp-cancel-sub-sign-invN/A
metadata-evalN/A
*-lft-identityN/A
associate-*r/N/A
div-add-revN/A
mul-1-negN/A
distribute-rgt-neg-inN/A
mul-1-negN/A
*-commutativeN/A
distribute-lft-inN/A
+-commutativeN/A
+-commutativeN/A
*-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
Applied rewrites74.6%
Taylor expanded in t around 0
Applied rewrites78.9%
if -3.89999999999999982e-73 < z < 4.19999999999999972e54Initial program 95.0%
Taylor expanded in z around 0
lower-/.f64N/A
*-commutativeN/A
lower-*.f6467.5
Applied rewrites67.5%
Final simplification73.1%
x\_m = (fabs.f64 x)
x\_s = (copysign.f64 #s(literal 1 binary64) x)
(FPCore (x_s x_m y z t)
:precision binary64
(*
x_s
(if (<= z -5.8e-17)
(* x_m (- 1.0 (/ (- y t) z)))
(if (<= z 6.8e+54) (/ (* y x_m) (- t z)) (fma (- y) (/ x_m z) x_m)))))x\_m = fabs(x);
x\_s = copysign(1.0, x);
double code(double x_s, double x_m, double y, double z, double t) {
double tmp;
if (z <= -5.8e-17) {
tmp = x_m * (1.0 - ((y - t) / z));
} else if (z <= 6.8e+54) {
tmp = (y * x_m) / (t - z);
} else {
tmp = fma(-y, (x_m / z), x_m);
}
return x_s * tmp;
}
x\_m = abs(x) x\_s = copysign(1.0, x) function code(x_s, x_m, y, z, t) tmp = 0.0 if (z <= -5.8e-17) tmp = Float64(x_m * Float64(1.0 - Float64(Float64(y - t) / z))); elseif (z <= 6.8e+54) tmp = Float64(Float64(y * x_m) / Float64(t - z)); else tmp = fma(Float64(-y), Float64(x_m / z), x_m); end return Float64(x_s * tmp) end
x\_m = N[Abs[x], $MachinePrecision]
x\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[x$95$s_, x$95$m_, y_, z_, t_] := N[(x$95$s * If[LessEqual[z, -5.8e-17], N[(x$95$m * N[(1.0 - N[(N[(y - t), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 6.8e+54], N[(N[(y * x$95$m), $MachinePrecision] / N[(t - z), $MachinePrecision]), $MachinePrecision], N[((-y) * N[(x$95$m / z), $MachinePrecision] + x$95$m), $MachinePrecision]]]), $MachinePrecision]
\begin{array}{l}
x\_m = \left|x\right|
\\
x\_s = \mathsf{copysign}\left(1, x\right)
\\
x\_s \cdot \begin{array}{l}
\mathbf{if}\;z \leq -5.8 \cdot 10^{-17}:\\
\;\;\;\;x\_m \cdot \left(1 - \frac{y - t}{z}\right)\\
\mathbf{elif}\;z \leq 6.8 \cdot 10^{+54}:\\
\;\;\;\;\frac{y \cdot x\_m}{t - z}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(-y, \frac{x\_m}{z}, x\_m\right)\\
\end{array}
\end{array}
if z < -5.8000000000000006e-17Initial program 79.9%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6467.2
Applied rewrites67.2%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
*-commutativeN/A
lift-*.f64N/A
lift--.f64N/A
flip--N/A
difference-of-squares-revN/A
lift-+.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-+.f64N/A
associate-/r/N/A
lift-+.f64N/A
flip-+N/A
difference-of-squares-revN/A
lift-+.f64N/A
lift--.f64N/A
*-commutativeN/A
lift--.f64N/A
associate-/l*N/A
associate-*r*N/A
Applied rewrites99.8%
Taylor expanded in z around inf
fp-cancel-sub-sign-invN/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
metadata-evalN/A
*-lft-identityN/A
associate-+l-N/A
div-subN/A
lower--.f64N/A
lower-/.f64N/A
lower--.f6480.7
Applied rewrites80.7%
if -5.8000000000000006e-17 < z < 6.8000000000000001e54Initial program 94.8%
Taylor expanded in y around inf
*-commutativeN/A
lower-*.f6482.0
Applied rewrites82.0%
if 6.8000000000000001e54 < z Initial program 74.6%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6469.1
Applied rewrites69.1%
Taylor expanded in z around inf
associate--l+N/A
fp-cancel-sub-sign-invN/A
metadata-evalN/A
*-lft-identityN/A
associate-*r/N/A
div-add-revN/A
mul-1-negN/A
distribute-rgt-neg-inN/A
mul-1-negN/A
*-commutativeN/A
distribute-lft-inN/A
+-commutativeN/A
+-commutativeN/A
*-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
Applied rewrites85.2%
Taylor expanded in y around inf
Applied rewrites85.4%
Final simplification82.4%
x\_m = (fabs.f64 x)
x\_s = (copysign.f64 #s(literal 1 binary64) x)
(FPCore (x_s x_m y z t)
:precision binary64
(*
x_s
(if (<= z -5.8e-17)
(fma (- x_m) (/ y z) x_m)
(if (<= z 6.8e+54) (/ (* y x_m) (- t z)) (fma (- y) (/ x_m z) x_m)))))x\_m = fabs(x);
x\_s = copysign(1.0, x);
double code(double x_s, double x_m, double y, double z, double t) {
double tmp;
if (z <= -5.8e-17) {
tmp = fma(-x_m, (y / z), x_m);
} else if (z <= 6.8e+54) {
tmp = (y * x_m) / (t - z);
} else {
tmp = fma(-y, (x_m / z), x_m);
}
return x_s * tmp;
}
x\_m = abs(x) x\_s = copysign(1.0, x) function code(x_s, x_m, y, z, t) tmp = 0.0 if (z <= -5.8e-17) tmp = fma(Float64(-x_m), Float64(y / z), x_m); elseif (z <= 6.8e+54) tmp = Float64(Float64(y * x_m) / Float64(t - z)); else tmp = fma(Float64(-y), Float64(x_m / z), x_m); end return Float64(x_s * tmp) end
x\_m = N[Abs[x], $MachinePrecision]
x\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[x$95$s_, x$95$m_, y_, z_, t_] := N[(x$95$s * If[LessEqual[z, -5.8e-17], N[((-x$95$m) * N[(y / z), $MachinePrecision] + x$95$m), $MachinePrecision], If[LessEqual[z, 6.8e+54], N[(N[(y * x$95$m), $MachinePrecision] / N[(t - z), $MachinePrecision]), $MachinePrecision], N[((-y) * N[(x$95$m / z), $MachinePrecision] + x$95$m), $MachinePrecision]]]), $MachinePrecision]
\begin{array}{l}
x\_m = \left|x\right|
\\
x\_s = \mathsf{copysign}\left(1, x\right)
\\
x\_s \cdot \begin{array}{l}
\mathbf{if}\;z \leq -5.8 \cdot 10^{-17}:\\
\;\;\;\;\mathsf{fma}\left(-x\_m, \frac{y}{z}, x\_m\right)\\
\mathbf{elif}\;z \leq 6.8 \cdot 10^{+54}:\\
\;\;\;\;\frac{y \cdot x\_m}{t - z}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(-y, \frac{x\_m}{z}, x\_m\right)\\
\end{array}
\end{array}
if z < -5.8000000000000006e-17Initial program 79.9%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6467.2
Applied rewrites67.2%
Taylor expanded in z around inf
associate--l+N/A
fp-cancel-sub-sign-invN/A
metadata-evalN/A
*-lft-identityN/A
associate-*r/N/A
div-add-revN/A
mul-1-negN/A
distribute-rgt-neg-inN/A
mul-1-negN/A
*-commutativeN/A
distribute-lft-inN/A
+-commutativeN/A
+-commutativeN/A
*-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
Applied rewrites71.5%
Taylor expanded in t around 0
Applied rewrites80.4%
if -5.8000000000000006e-17 < z < 6.8000000000000001e54Initial program 94.8%
Taylor expanded in y around inf
*-commutativeN/A
lower-*.f6482.0
Applied rewrites82.0%
if 6.8000000000000001e54 < z Initial program 74.6%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6469.1
Applied rewrites69.1%
Taylor expanded in z around inf
associate--l+N/A
fp-cancel-sub-sign-invN/A
metadata-evalN/A
*-lft-identityN/A
associate-*r/N/A
div-add-revN/A
mul-1-negN/A
distribute-rgt-neg-inN/A
mul-1-negN/A
*-commutativeN/A
distribute-lft-inN/A
+-commutativeN/A
+-commutativeN/A
*-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
Applied rewrites85.2%
Taylor expanded in y around inf
Applied rewrites85.4%
Final simplification82.3%
x\_m = (fabs.f64 x)
x\_s = (copysign.f64 #s(literal 1 binary64) x)
(FPCore (x_s x_m y z t)
:precision binary64
(*
x_s
(if (<= z -5.2e-17)
(fma (- x_m) (/ y z) x_m)
(if (<= z 6.2e+54) (/ (* (- y z) x_m) t) (fma (- y) (/ x_m z) x_m)))))x\_m = fabs(x);
x\_s = copysign(1.0, x);
double code(double x_s, double x_m, double y, double z, double t) {
double tmp;
if (z <= -5.2e-17) {
tmp = fma(-x_m, (y / z), x_m);
} else if (z <= 6.2e+54) {
tmp = ((y - z) * x_m) / t;
} else {
tmp = fma(-y, (x_m / z), x_m);
}
return x_s * tmp;
}
x\_m = abs(x) x\_s = copysign(1.0, x) function code(x_s, x_m, y, z, t) tmp = 0.0 if (z <= -5.2e-17) tmp = fma(Float64(-x_m), Float64(y / z), x_m); elseif (z <= 6.2e+54) tmp = Float64(Float64(Float64(y - z) * x_m) / t); else tmp = fma(Float64(-y), Float64(x_m / z), x_m); end return Float64(x_s * tmp) end
x\_m = N[Abs[x], $MachinePrecision]
x\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[x$95$s_, x$95$m_, y_, z_, t_] := N[(x$95$s * If[LessEqual[z, -5.2e-17], N[((-x$95$m) * N[(y / z), $MachinePrecision] + x$95$m), $MachinePrecision], If[LessEqual[z, 6.2e+54], N[(N[(N[(y - z), $MachinePrecision] * x$95$m), $MachinePrecision] / t), $MachinePrecision], N[((-y) * N[(x$95$m / z), $MachinePrecision] + x$95$m), $MachinePrecision]]]), $MachinePrecision]
\begin{array}{l}
x\_m = \left|x\right|
\\
x\_s = \mathsf{copysign}\left(1, x\right)
\\
x\_s \cdot \begin{array}{l}
\mathbf{if}\;z \leq -5.2 \cdot 10^{-17}:\\
\;\;\;\;\mathsf{fma}\left(-x\_m, \frac{y}{z}, x\_m\right)\\
\mathbf{elif}\;z \leq 6.2 \cdot 10^{+54}:\\
\;\;\;\;\frac{\left(y - z\right) \cdot x\_m}{t}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(-y, \frac{x\_m}{z}, x\_m\right)\\
\end{array}
\end{array}
if z < -5.20000000000000006e-17Initial program 79.9%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6467.2
Applied rewrites67.2%
Taylor expanded in z around inf
associate--l+N/A
fp-cancel-sub-sign-invN/A
metadata-evalN/A
*-lft-identityN/A
associate-*r/N/A
div-add-revN/A
mul-1-negN/A
distribute-rgt-neg-inN/A
mul-1-negN/A
*-commutativeN/A
distribute-lft-inN/A
+-commutativeN/A
+-commutativeN/A
*-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
Applied rewrites71.5%
Taylor expanded in t around 0
Applied rewrites80.4%
if -5.20000000000000006e-17 < z < 6.1999999999999999e54Initial program 94.8%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6491.7
Applied rewrites91.7%
Taylor expanded in t around inf
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f6474.6
Applied rewrites74.6%
if 6.1999999999999999e54 < z Initial program 74.6%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6469.1
Applied rewrites69.1%
Taylor expanded in z around inf
associate--l+N/A
fp-cancel-sub-sign-invN/A
metadata-evalN/A
*-lft-identityN/A
associate-*r/N/A
div-add-revN/A
mul-1-negN/A
distribute-rgt-neg-inN/A
mul-1-negN/A
*-commutativeN/A
distribute-lft-inN/A
+-commutativeN/A
+-commutativeN/A
*-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
Applied rewrites85.2%
Taylor expanded in y around inf
Applied rewrites85.4%
Final simplification78.2%
x\_m = (fabs.f64 x)
x\_s = (copysign.f64 #s(literal 1 binary64) x)
(FPCore (x_s x_m y z t)
:precision binary64
(*
x_s
(if (or (<= z -750.0) (not (<= z 1.42e+54)))
(fma (/ x_m z) t x_m)
(* x_m (/ y t)))))x\_m = fabs(x);
x\_s = copysign(1.0, x);
double code(double x_s, double x_m, double y, double z, double t) {
double tmp;
if ((z <= -750.0) || !(z <= 1.42e+54)) {
tmp = fma((x_m / z), t, x_m);
} else {
tmp = x_m * (y / t);
}
return x_s * tmp;
}
x\_m = abs(x) x\_s = copysign(1.0, x) function code(x_s, x_m, y, z, t) tmp = 0.0 if ((z <= -750.0) || !(z <= 1.42e+54)) tmp = fma(Float64(x_m / z), t, x_m); else tmp = Float64(x_m * Float64(y / t)); end return Float64(x_s * tmp) end
x\_m = N[Abs[x], $MachinePrecision]
x\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[x$95$s_, x$95$m_, y_, z_, t_] := N[(x$95$s * If[Or[LessEqual[z, -750.0], N[Not[LessEqual[z, 1.42e+54]], $MachinePrecision]], N[(N[(x$95$m / z), $MachinePrecision] * t + x$95$m), $MachinePrecision], N[(x$95$m * N[(y / t), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
x\_m = \left|x\right|
\\
x\_s = \mathsf{copysign}\left(1, x\right)
\\
x\_s \cdot \begin{array}{l}
\mathbf{if}\;z \leq -750 \lor \neg \left(z \leq 1.42 \cdot 10^{+54}\right):\\
\;\;\;\;\mathsf{fma}\left(\frac{x\_m}{z}, t, x\_m\right)\\
\mathbf{else}:\\
\;\;\;\;x\_m \cdot \frac{y}{t}\\
\end{array}
\end{array}
if z < -750 or 1.41999999999999995e54 < z Initial program 77.3%
Taylor expanded in y around 0
mul-1-negN/A
associate-/l*N/A
*-commutativeN/A
distribute-rgt-neg-inN/A
mul-1-negN/A
lower-*.f64N/A
lower-/.f64N/A
lower--.f64N/A
mul-1-negN/A
lower-neg.f6470.6
Applied rewrites70.6%
Taylor expanded in z around inf
Applied rewrites62.3%
if -750 < z < 1.41999999999999995e54Initial program 94.8%
Taylor expanded in z around 0
lower-/.f64N/A
*-commutativeN/A
lower-*.f6464.4
Applied rewrites64.4%
Applied rewrites64.9%
Final simplification63.7%
x\_m = (fabs.f64 x) x\_s = (copysign.f64 #s(literal 1 binary64) x) (FPCore (x_s x_m y z t) :precision binary64 (* x_s (* x_m (/ y t))))
x\_m = fabs(x);
x\_s = copysign(1.0, x);
double code(double x_s, double x_m, double y, double z, double t) {
return x_s * (x_m * (y / t));
}
x\_m = private
x\_s = private
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_s, x_m, y, z, t)
use fmin_fmax_functions
real(8), intent (in) :: x_s
real(8), intent (in) :: x_m
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = x_s * (x_m * (y / t))
end function
x\_m = Math.abs(x);
x\_s = Math.copySign(1.0, x);
public static double code(double x_s, double x_m, double y, double z, double t) {
return x_s * (x_m * (y / t));
}
x\_m = math.fabs(x) x\_s = math.copysign(1.0, x) def code(x_s, x_m, y, z, t): return x_s * (x_m * (y / t))
x\_m = abs(x) x\_s = copysign(1.0, x) function code(x_s, x_m, y, z, t) return Float64(x_s * Float64(x_m * Float64(y / t))) end
x\_m = abs(x); x\_s = sign(x) * abs(1.0); function tmp = code(x_s, x_m, y, z, t) tmp = x_s * (x_m * (y / t)); end
x\_m = N[Abs[x], $MachinePrecision]
x\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[x$95$s_, x$95$m_, y_, z_, t_] := N[(x$95$s * N[(x$95$m * N[(y / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
x\_m = \left|x\right|
\\
x\_s = \mathsf{copysign}\left(1, x\right)
\\
x\_s \cdot \left(x\_m \cdot \frac{y}{t}\right)
\end{array}
Initial program 87.1%
Taylor expanded in z around 0
lower-/.f64N/A
*-commutativeN/A
lower-*.f6441.4
Applied rewrites41.4%
Applied rewrites42.1%
x\_m = (fabs.f64 x) x\_s = (copysign.f64 #s(literal 1 binary64) x) (FPCore (x_s x_m y z t) :precision binary64 (* x_s (* (/ x_m z) t)))
x\_m = fabs(x);
x\_s = copysign(1.0, x);
double code(double x_s, double x_m, double y, double z, double t) {
return x_s * ((x_m / z) * t);
}
x\_m = private
x\_s = private
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_s, x_m, y, z, t)
use fmin_fmax_functions
real(8), intent (in) :: x_s
real(8), intent (in) :: x_m
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = x_s * ((x_m / z) * t)
end function
x\_m = Math.abs(x);
x\_s = Math.copySign(1.0, x);
public static double code(double x_s, double x_m, double y, double z, double t) {
return x_s * ((x_m / z) * t);
}
x\_m = math.fabs(x) x\_s = math.copysign(1.0, x) def code(x_s, x_m, y, z, t): return x_s * ((x_m / z) * t)
x\_m = abs(x) x\_s = copysign(1.0, x) function code(x_s, x_m, y, z, t) return Float64(x_s * Float64(Float64(x_m / z) * t)) end
x\_m = abs(x); x\_s = sign(x) * abs(1.0); function tmp = code(x_s, x_m, y, z, t) tmp = x_s * ((x_m / z) * t); end
x\_m = N[Abs[x], $MachinePrecision]
x\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[x$95$s_, x$95$m_, y_, z_, t_] := N[(x$95$s * N[(N[(x$95$m / z), $MachinePrecision] * t), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
x\_m = \left|x\right|
\\
x\_s = \mathsf{copysign}\left(1, x\right)
\\
x\_s \cdot \left(\frac{x\_m}{z} \cdot t\right)
\end{array}
Initial program 87.1%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6481.1
Applied rewrites81.1%
Taylor expanded in z around inf
associate--l+N/A
fp-cancel-sub-sign-invN/A
metadata-evalN/A
*-lft-identityN/A
associate-*r/N/A
div-add-revN/A
mul-1-negN/A
distribute-rgt-neg-inN/A
mul-1-negN/A
*-commutativeN/A
distribute-lft-inN/A
+-commutativeN/A
+-commutativeN/A
*-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
Applied rewrites51.3%
Taylor expanded in t around inf
Applied rewrites6.0%
Final simplification6.0%
(FPCore (x y z t) :precision binary64 (/ x (/ (- t z) (- y z))))
double code(double x, double y, double z, double t) {
return x / ((t - z) / (y - z));
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z, t)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = x / ((t - z) / (y - z))
end function
public static double code(double x, double y, double z, double t) {
return x / ((t - z) / (y - z));
}
def code(x, y, z, t): return x / ((t - z) / (y - z))
function code(x, y, z, t) return Float64(x / Float64(Float64(t - z) / Float64(y - z))) end
function tmp = code(x, y, z, t) tmp = x / ((t - z) / (y - z)); end
code[x_, y_, z_, t_] := N[(x / N[(N[(t - z), $MachinePrecision] / N[(y - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x}{\frac{t - z}{y - z}}
\end{array}
herbie shell --seed 2024359
(FPCore (x y z t)
:name "Graphics.Rendering.Chart.Plot.AreaSpots:renderAreaSpots4D from Chart-1.5.3"
:precision binary64
:alt
(! :herbie-platform default (/ x (/ (- t z) (- y z))))
(/ (* x (- y z)) (- t z)))