
(FPCore (x y z t a) :precision binary64 (+ (/ (* 60.0 (- x y)) (- z t)) (* a 120.0)))
double code(double x, double y, double z, double t, double a) {
return ((60.0 * (x - y)) / (z - t)) + (a * 120.0);
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z, t, a)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
code = ((60.0d0 * (x - y)) / (z - t)) + (a * 120.0d0)
end function
public static double code(double x, double y, double z, double t, double a) {
return ((60.0 * (x - y)) / (z - t)) + (a * 120.0);
}
def code(x, y, z, t, a): return ((60.0 * (x - y)) / (z - t)) + (a * 120.0)
function code(x, y, z, t, a) return Float64(Float64(Float64(60.0 * Float64(x - y)) / Float64(z - t)) + Float64(a * 120.0)) end
function tmp = code(x, y, z, t, a) tmp = ((60.0 * (x - y)) / (z - t)) + (a * 120.0); end
code[x_, y_, z_, t_, a_] := N[(N[(N[(60.0 * N[(x - y), $MachinePrecision]), $MachinePrecision] / N[(z - t), $MachinePrecision]), $MachinePrecision] + N[(a * 120.0), $MachinePrecision]), $MachinePrecision]
\frac{60 \cdot \left(x - y\right)}{z - t} + a \cdot 120
Herbie found 13 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z t a) :precision binary64 (+ (/ (* 60.0 (- x y)) (- z t)) (* a 120.0)))
double code(double x, double y, double z, double t, double a) {
return ((60.0 * (x - y)) / (z - t)) + (a * 120.0);
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z, t, a)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
code = ((60.0d0 * (x - y)) / (z - t)) + (a * 120.0d0)
end function
public static double code(double x, double y, double z, double t, double a) {
return ((60.0 * (x - y)) / (z - t)) + (a * 120.0);
}
def code(x, y, z, t, a): return ((60.0 * (x - y)) / (z - t)) + (a * 120.0)
function code(x, y, z, t, a) return Float64(Float64(Float64(60.0 * Float64(x - y)) / Float64(z - t)) + Float64(a * 120.0)) end
function tmp = code(x, y, z, t, a) tmp = ((60.0 * (x - y)) / (z - t)) + (a * 120.0); end
code[x_, y_, z_, t_, a_] := N[(N[(N[(60.0 * N[(x - y), $MachinePrecision]), $MachinePrecision] / N[(z - t), $MachinePrecision]), $MachinePrecision] + N[(a * 120.0), $MachinePrecision]), $MachinePrecision]
\frac{60 \cdot \left(x - y\right)}{z - t} + a \cdot 120
(FPCore (x y z t a) :precision binary64 (fma a 120.0 (* (/ -60.0 (- z t)) (- y x))))
double code(double x, double y, double z, double t, double a) {
return fma(a, 120.0, ((-60.0 / (z - t)) * (y - x)));
}
function code(x, y, z, t, a) return fma(a, 120.0, Float64(Float64(-60.0 / Float64(z - t)) * Float64(y - x))) end
code[x_, y_, z_, t_, a_] := N[(a * 120.0 + N[(N[(-60.0 / N[(z - t), $MachinePrecision]), $MachinePrecision] * N[(y - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\mathsf{fma}\left(a, 120, \frac{-60}{z - t} \cdot \left(y - x\right)\right)
Initial program 99.3%
lift-+.f64N/A
+-commutativeN/A
lift-/.f64N/A
mult-flipN/A
lift-*.f64N/A
*-commutativeN/A
associate-*l*N/A
fp-cancel-sign-sub-invN/A
distribute-lft-neg-inN/A
distribute-rgt-neg-inN/A
fp-cancel-sub-sign-invN/A
lift-*.f64N/A
lift--.f64N/A
sub-negate-revN/A
distribute-rgt-neg-inN/A
distribute-lft-neg-outN/A
sub-negate-revN/A
lift--.f64N/A
associate-*l*N/A
*-commutativeN/A
lift-*.f64N/A
Applied rewrites99.8%
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (fma -60.0 (/ y (- z t)) (* 120.0 a))))
(if (<= y -9.6e+63)
t_1
(if (<= y 1.18e+39) (fma a 120.0 (/ (* 60.0 x) (- z t))) t_1))))double code(double x, double y, double z, double t, double a) {
double t_1 = fma(-60.0, (y / (z - t)), (120.0 * a));
double tmp;
if (y <= -9.6e+63) {
tmp = t_1;
} else if (y <= 1.18e+39) {
tmp = fma(a, 120.0, ((60.0 * x) / (z - t)));
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a) t_1 = fma(-60.0, Float64(y / Float64(z - t)), Float64(120.0 * a)) tmp = 0.0 if (y <= -9.6e+63) tmp = t_1; elseif (y <= 1.18e+39) tmp = fma(a, 120.0, Float64(Float64(60.0 * x) / Float64(z - t))); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(-60.0 * N[(y / N[(z - t), $MachinePrecision]), $MachinePrecision] + N[(120.0 * a), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -9.6e+63], t$95$1, If[LessEqual[y, 1.18e+39], N[(a * 120.0 + N[(N[(60.0 * x), $MachinePrecision] / N[(z - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1]]]
\begin{array}{l}
t_1 := \mathsf{fma}\left(-60, \frac{y}{z - t}, 120 \cdot a\right)\\
\mathbf{if}\;y \leq -9.6 \cdot 10^{+63}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;y \leq 1.18 \cdot 10^{+39}:\\
\;\;\;\;\mathsf{fma}\left(a, 120, \frac{60 \cdot x}{z - t}\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
if y < -9.6e63 or 1.18e39 < y Initial program 99.3%
Taylor expanded in x around 0
lower-fma.f64N/A
lower-/.f64N/A
lower--.f64N/A
lower-*.f6475.4%
Applied rewrites75.4%
if -9.6e63 < y < 1.18e39Initial program 99.3%
Taylor expanded in x around inf
lower-*.f6475.1%
Applied rewrites75.1%
lift-+.f64N/A
lift-*.f64N/A
+-commutativeN/A
lower-fma.f6475.1%
Applied rewrites75.1%
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (fma -60.0 (/ y (- z t)) (* 120.0 a))))
(if (<= y -9.6e+63)
t_1
(if (<= y 1.18e+39) (fma a 120.0 (* 60.0 (/ x (- z t)))) t_1))))double code(double x, double y, double z, double t, double a) {
double t_1 = fma(-60.0, (y / (z - t)), (120.0 * a));
double tmp;
if (y <= -9.6e+63) {
tmp = t_1;
} else if (y <= 1.18e+39) {
tmp = fma(a, 120.0, (60.0 * (x / (z - t))));
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a) t_1 = fma(-60.0, Float64(y / Float64(z - t)), Float64(120.0 * a)) tmp = 0.0 if (y <= -9.6e+63) tmp = t_1; elseif (y <= 1.18e+39) tmp = fma(a, 120.0, Float64(60.0 * Float64(x / Float64(z - t)))); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(-60.0 * N[(y / N[(z - t), $MachinePrecision]), $MachinePrecision] + N[(120.0 * a), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -9.6e+63], t$95$1, If[LessEqual[y, 1.18e+39], N[(a * 120.0 + N[(60.0 * N[(x / N[(z - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1]]]
\begin{array}{l}
t_1 := \mathsf{fma}\left(-60, \frac{y}{z - t}, 120 \cdot a\right)\\
\mathbf{if}\;y \leq -9.6 \cdot 10^{+63}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;y \leq 1.18 \cdot 10^{+39}:\\
\;\;\;\;\mathsf{fma}\left(a, 120, 60 \cdot \frac{x}{z - t}\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
if y < -9.6e63 or 1.18e39 < y Initial program 99.3%
Taylor expanded in x around 0
lower-fma.f64N/A
lower-/.f64N/A
lower--.f64N/A
lower-*.f6475.4%
Applied rewrites75.4%
if -9.6e63 < y < 1.18e39Initial program 99.3%
lift-+.f64N/A
+-commutativeN/A
lift-/.f64N/A
mult-flipN/A
lift-*.f64N/A
*-commutativeN/A
associate-*l*N/A
fp-cancel-sign-sub-invN/A
distribute-lft-neg-inN/A
distribute-rgt-neg-inN/A
fp-cancel-sub-sign-invN/A
lift-*.f64N/A
lift--.f64N/A
sub-negate-revN/A
distribute-rgt-neg-inN/A
distribute-lft-neg-outN/A
sub-negate-revN/A
lift--.f64N/A
associate-*l*N/A
*-commutativeN/A
lift-*.f64N/A
Applied rewrites99.8%
Taylor expanded in x around inf
lower-*.f64N/A
lower-/.f64N/A
lower--.f6475.4%
Applied rewrites75.4%
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (* 60.0 (/ (- x y) (- z t))))
(t_2 (/ (* 60.0 (- x y)) (- z t))))
(if (<= t_2 -20000000000000.0)
t_1
(if (<= t_2 4e+89) (fma -60.0 (/ y (- z t)) (* 120.0 a)) t_1))))double code(double x, double y, double z, double t, double a) {
double t_1 = 60.0 * ((x - y) / (z - t));
double t_2 = (60.0 * (x - y)) / (z - t);
double tmp;
if (t_2 <= -20000000000000.0) {
tmp = t_1;
} else if (t_2 <= 4e+89) {
tmp = fma(-60.0, (y / (z - t)), (120.0 * a));
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a) t_1 = Float64(60.0 * Float64(Float64(x - y) / Float64(z - t))) t_2 = Float64(Float64(60.0 * Float64(x - y)) / Float64(z - t)) tmp = 0.0 if (t_2 <= -20000000000000.0) tmp = t_1; elseif (t_2 <= 4e+89) tmp = fma(-60.0, Float64(y / Float64(z - t)), Float64(120.0 * a)); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(60.0 * N[(N[(x - y), $MachinePrecision] / N[(z - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(60.0 * N[(x - y), $MachinePrecision]), $MachinePrecision] / N[(z - t), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$2, -20000000000000.0], t$95$1, If[LessEqual[t$95$2, 4e+89], N[(-60.0 * N[(y / N[(z - t), $MachinePrecision]), $MachinePrecision] + N[(120.0 * a), $MachinePrecision]), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
t_1 := 60 \cdot \frac{x - y}{z - t}\\
t_2 := \frac{60 \cdot \left(x - y\right)}{z - t}\\
\mathbf{if}\;t\_2 \leq -20000000000000:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_2 \leq 4 \cdot 10^{+89}:\\
\;\;\;\;\mathsf{fma}\left(-60, \frac{y}{z - t}, 120 \cdot a\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
if (/.f64 (*.f64 #s(literal 60 binary64) (-.f64 x y)) (-.f64 z t)) < -2e13 or 4e89 < (/.f64 (*.f64 #s(literal 60 binary64) (-.f64 x y)) (-.f64 z t)) Initial program 99.3%
Taylor expanded in x around 0
lower-fma.f64N/A
lower-/.f64N/A
lower--.f64N/A
lower-*.f6475.4%
Applied rewrites75.4%
Taylor expanded in z around 0
lower-fma.f64N/A
lower-/.f64N/A
lower-*.f6455.0%
Applied rewrites55.0%
Taylor expanded in a around 0
lower-*.f64N/A
lower-/.f64N/A
lower--.f64N/A
lower--.f6450.7%
Applied rewrites50.7%
if -2e13 < (/.f64 (*.f64 #s(literal 60 binary64) (-.f64 x y)) (-.f64 z t)) < 4e89Initial program 99.3%
Taylor expanded in x around 0
lower-fma.f64N/A
lower-/.f64N/A
lower--.f64N/A
lower-*.f6475.4%
Applied rewrites75.4%
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (fma -60.0 (/ x t) (* 120.0 a))))
(if (<= a -1.08e-82)
t_1
(if (<= a 4e+46) (* 60.0 (/ (- x y) (- z t))) t_1))))double code(double x, double y, double z, double t, double a) {
double t_1 = fma(-60.0, (x / t), (120.0 * a));
double tmp;
if (a <= -1.08e-82) {
tmp = t_1;
} else if (a <= 4e+46) {
tmp = 60.0 * ((x - y) / (z - t));
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a) t_1 = fma(-60.0, Float64(x / t), Float64(120.0 * a)) tmp = 0.0 if (a <= -1.08e-82) tmp = t_1; elseif (a <= 4e+46) tmp = Float64(60.0 * Float64(Float64(x - y) / Float64(z - t))); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(-60.0 * N[(x / t), $MachinePrecision] + N[(120.0 * a), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[a, -1.08e-82], t$95$1, If[LessEqual[a, 4e+46], N[(60.0 * N[(N[(x - y), $MachinePrecision] / N[(z - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1]]]
\begin{array}{l}
t_1 := \mathsf{fma}\left(-60, \frac{x}{t}, 120 \cdot a\right)\\
\mathbf{if}\;a \leq -1.08 \cdot 10^{-82}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;a \leq 4 \cdot 10^{+46}:\\
\;\;\;\;60 \cdot \frac{x - y}{z - t}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
if a < -1.08e-82 or 4e46 < a Initial program 99.3%
Taylor expanded in z around 0
lower-fma.f64N/A
lower-/.f64N/A
lower--.f64N/A
lower-*.f6464.3%
Applied rewrites64.3%
Taylor expanded in x around inf
lower-/.f6455.4%
Applied rewrites55.4%
if -1.08e-82 < a < 4e46Initial program 99.3%
Taylor expanded in x around 0
lower-fma.f64N/A
lower-/.f64N/A
lower--.f64N/A
lower-*.f6475.4%
Applied rewrites75.4%
Taylor expanded in z around 0
lower-fma.f64N/A
lower-/.f64N/A
lower-*.f6455.0%
Applied rewrites55.0%
Taylor expanded in a around 0
lower-*.f64N/A
lower-/.f64N/A
lower--.f64N/A
lower--.f6450.7%
Applied rewrites50.7%
(FPCore (x y z t a)
:precision binary64
(if (<= z -9e-83)
(fma a 120.0 (* (/ -60.0 z) y))
(if (<= z 1.5e-22)
(fma -60.0 (/ x t) (* 120.0 a))
(fma -60.0 (/ y z) (* 120.0 a)))))double code(double x, double y, double z, double t, double a) {
double tmp;
if (z <= -9e-83) {
tmp = fma(a, 120.0, ((-60.0 / z) * y));
} else if (z <= 1.5e-22) {
tmp = fma(-60.0, (x / t), (120.0 * a));
} else {
tmp = fma(-60.0, (y / z), (120.0 * a));
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if (z <= -9e-83) tmp = fma(a, 120.0, Float64(Float64(-60.0 / z) * y)); elseif (z <= 1.5e-22) tmp = fma(-60.0, Float64(x / t), Float64(120.0 * a)); else tmp = fma(-60.0, Float64(y / z), Float64(120.0 * a)); end return tmp end
code[x_, y_, z_, t_, a_] := If[LessEqual[z, -9e-83], N[(a * 120.0 + N[(N[(-60.0 / z), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 1.5e-22], N[(-60.0 * N[(x / t), $MachinePrecision] + N[(120.0 * a), $MachinePrecision]), $MachinePrecision], N[(-60.0 * N[(y / z), $MachinePrecision] + N[(120.0 * a), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\mathbf{if}\;z \leq -9 \cdot 10^{-83}:\\
\;\;\;\;\mathsf{fma}\left(a, 120, \frac{-60}{z} \cdot y\right)\\
\mathbf{elif}\;z \leq 1.5 \cdot 10^{-22}:\\
\;\;\;\;\mathsf{fma}\left(-60, \frac{x}{t}, 120 \cdot a\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(-60, \frac{y}{z}, 120 \cdot a\right)\\
\end{array}
if z < -8.9999999999999999e-83Initial program 99.3%
lift-+.f64N/A
+-commutativeN/A
lift-/.f64N/A
mult-flipN/A
lift-*.f64N/A
*-commutativeN/A
associate-*l*N/A
fp-cancel-sign-sub-invN/A
distribute-lft-neg-inN/A
distribute-rgt-neg-inN/A
fp-cancel-sub-sign-invN/A
lift-*.f64N/A
lift--.f64N/A
sub-negate-revN/A
distribute-rgt-neg-inN/A
distribute-lft-neg-outN/A
sub-negate-revN/A
lift--.f64N/A
associate-*l*N/A
*-commutativeN/A
lift-*.f64N/A
Applied rewrites99.8%
Taylor expanded in x around 0
Applied rewrites75.4%
Taylor expanded in z around inf
lower-/.f6454.7%
Applied rewrites54.7%
if -8.9999999999999999e-83 < z < 1.5e-22Initial program 99.3%
Taylor expanded in z around 0
lower-fma.f64N/A
lower-/.f64N/A
lower--.f64N/A
lower-*.f6464.3%
Applied rewrites64.3%
Taylor expanded in x around inf
lower-/.f6455.4%
Applied rewrites55.4%
if 1.5e-22 < z Initial program 99.3%
Taylor expanded in x around 0
lower-fma.f64N/A
lower-/.f64N/A
lower--.f64N/A
lower-*.f6475.4%
Applied rewrites75.4%
Taylor expanded in z around inf
lower-/.f6454.7%
Applied rewrites54.7%
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (fma -60.0 (/ y z) (* 120.0 a))))
(if (<= z -9e-83)
t_1
(if (<= z 1.5e-22) (fma -60.0 (/ x t) (* 120.0 a)) t_1))))double code(double x, double y, double z, double t, double a) {
double t_1 = fma(-60.0, (y / z), (120.0 * a));
double tmp;
if (z <= -9e-83) {
tmp = t_1;
} else if (z <= 1.5e-22) {
tmp = fma(-60.0, (x / t), (120.0 * a));
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a) t_1 = fma(-60.0, Float64(y / z), Float64(120.0 * a)) tmp = 0.0 if (z <= -9e-83) tmp = t_1; elseif (z <= 1.5e-22) tmp = fma(-60.0, Float64(x / t), Float64(120.0 * a)); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(-60.0 * N[(y / z), $MachinePrecision] + N[(120.0 * a), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -9e-83], t$95$1, If[LessEqual[z, 1.5e-22], N[(-60.0 * N[(x / t), $MachinePrecision] + N[(120.0 * a), $MachinePrecision]), $MachinePrecision], t$95$1]]]
\begin{array}{l}
t_1 := \mathsf{fma}\left(-60, \frac{y}{z}, 120 \cdot a\right)\\
\mathbf{if}\;z \leq -9 \cdot 10^{-83}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \leq 1.5 \cdot 10^{-22}:\\
\;\;\;\;\mathsf{fma}\left(-60, \frac{x}{t}, 120 \cdot a\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
if z < -8.9999999999999999e-83 or 1.5e-22 < z Initial program 99.3%
Taylor expanded in x around 0
lower-fma.f64N/A
lower-/.f64N/A
lower--.f64N/A
lower-*.f6475.4%
Applied rewrites75.4%
Taylor expanded in z around inf
lower-/.f6454.7%
Applied rewrites54.7%
if -8.9999999999999999e-83 < z < 1.5e-22Initial program 99.3%
Taylor expanded in z around 0
lower-fma.f64N/A
lower-/.f64N/A
lower--.f64N/A
lower-*.f6464.3%
Applied rewrites64.3%
Taylor expanded in x around inf
lower-/.f6455.4%
Applied rewrites55.4%
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (fma a 120.0 (* (/ y t) 60.0))))
(if (<= t -3100.0)
t_1
(if (<= t 8e-19) (fma -60.0 (/ y z) (* 120.0 a)) t_1))))double code(double x, double y, double z, double t, double a) {
double t_1 = fma(a, 120.0, ((y / t) * 60.0));
double tmp;
if (t <= -3100.0) {
tmp = t_1;
} else if (t <= 8e-19) {
tmp = fma(-60.0, (y / z), (120.0 * a));
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a) t_1 = fma(a, 120.0, Float64(Float64(y / t) * 60.0)) tmp = 0.0 if (t <= -3100.0) tmp = t_1; elseif (t <= 8e-19) tmp = fma(-60.0, Float64(y / z), Float64(120.0 * a)); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(a * 120.0 + N[(N[(y / t), $MachinePrecision] * 60.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t, -3100.0], t$95$1, If[LessEqual[t, 8e-19], N[(-60.0 * N[(y / z), $MachinePrecision] + N[(120.0 * a), $MachinePrecision]), $MachinePrecision], t$95$1]]]
\begin{array}{l}
t_1 := \mathsf{fma}\left(a, 120, \frac{y}{t} \cdot 60\right)\\
\mathbf{if}\;t \leq -3100:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t \leq 8 \cdot 10^{-19}:\\
\;\;\;\;\mathsf{fma}\left(-60, \frac{y}{z}, 120 \cdot a\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
if t < -3100 or 7.9999999999999998e-19 < t Initial program 99.3%
Taylor expanded in x around 0
lower-fma.f64N/A
lower-/.f64N/A
lower--.f64N/A
lower-*.f6475.4%
Applied rewrites75.4%
Taylor expanded in z around 0
lower-fma.f64N/A
lower-/.f64N/A
lower-*.f6455.0%
Applied rewrites55.0%
lift-fma.f64N/A
lift-*.f64N/A
*-commutativeN/A
+-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6455.0%
Applied rewrites55.0%
if -3100 < t < 7.9999999999999998e-19Initial program 99.3%
Taylor expanded in x around 0
lower-fma.f64N/A
lower-/.f64N/A
lower--.f64N/A
lower-*.f6475.4%
Applied rewrites75.4%
Taylor expanded in z around inf
lower-/.f6454.7%
Applied rewrites54.7%
(FPCore (x y z t a) :precision binary64 (if (<= z 1.7e+111) (fma a 120.0 (* (/ y t) 60.0)) (* 120.0 a)))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (z <= 1.7e+111) {
tmp = fma(a, 120.0, ((y / t) * 60.0));
} else {
tmp = 120.0 * a;
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if (z <= 1.7e+111) tmp = fma(a, 120.0, Float64(Float64(y / t) * 60.0)); else tmp = Float64(120.0 * a); end return tmp end
code[x_, y_, z_, t_, a_] := If[LessEqual[z, 1.7e+111], N[(a * 120.0 + N[(N[(y / t), $MachinePrecision] * 60.0), $MachinePrecision]), $MachinePrecision], N[(120.0 * a), $MachinePrecision]]
\begin{array}{l}
\mathbf{if}\;z \leq 1.7 \cdot 10^{+111}:\\
\;\;\;\;\mathsf{fma}\left(a, 120, \frac{y}{t} \cdot 60\right)\\
\mathbf{else}:\\
\;\;\;\;120 \cdot a\\
\end{array}
if z < 1.7000000000000001e111Initial program 99.3%
Taylor expanded in x around 0
lower-fma.f64N/A
lower-/.f64N/A
lower--.f64N/A
lower-*.f6475.4%
Applied rewrites75.4%
Taylor expanded in z around 0
lower-fma.f64N/A
lower-/.f64N/A
lower-*.f6455.0%
Applied rewrites55.0%
lift-fma.f64N/A
lift-*.f64N/A
*-commutativeN/A
+-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6455.0%
Applied rewrites55.0%
if 1.7000000000000001e111 < z Initial program 99.3%
Taylor expanded in z around inf
lower-*.f6450.8%
Applied rewrites50.8%
(FPCore (x y z t a) :precision binary64 (if (<= z 1.7e+111) (fma 60.0 (/ y t) (* 120.0 a)) (* 120.0 a)))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (z <= 1.7e+111) {
tmp = fma(60.0, (y / t), (120.0 * a));
} else {
tmp = 120.0 * a;
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if (z <= 1.7e+111) tmp = fma(60.0, Float64(y / t), Float64(120.0 * a)); else tmp = Float64(120.0 * a); end return tmp end
code[x_, y_, z_, t_, a_] := If[LessEqual[z, 1.7e+111], N[(60.0 * N[(y / t), $MachinePrecision] + N[(120.0 * a), $MachinePrecision]), $MachinePrecision], N[(120.0 * a), $MachinePrecision]]
\begin{array}{l}
\mathbf{if}\;z \leq 1.7 \cdot 10^{+111}:\\
\;\;\;\;\mathsf{fma}\left(60, \frac{y}{t}, 120 \cdot a\right)\\
\mathbf{else}:\\
\;\;\;\;120 \cdot a\\
\end{array}
if z < 1.7000000000000001e111Initial program 99.3%
Taylor expanded in x around 0
lower-fma.f64N/A
lower-/.f64N/A
lower--.f64N/A
lower-*.f6475.4%
Applied rewrites75.4%
Taylor expanded in z around 0
lower-fma.f64N/A
lower-/.f64N/A
lower-*.f6455.0%
Applied rewrites55.0%
if 1.7000000000000001e111 < z Initial program 99.3%
Taylor expanded in z around inf
lower-*.f6450.8%
Applied rewrites50.8%
(FPCore (x y z t a) :precision binary64 (let* ((t_1 (* -60.0 (/ x t))) (t_2 (/ (* 60.0 (- x y)) (- z t)))) (if (<= t_2 -2e+147) t_1 (if (<= t_2 4e+89) (* 120.0 a) t_1))))
double code(double x, double y, double z, double t, double a) {
double t_1 = -60.0 * (x / t);
double t_2 = (60.0 * (x - y)) / (z - t);
double tmp;
if (t_2 <= -2e+147) {
tmp = t_1;
} else if (t_2 <= 4e+89) {
tmp = 120.0 * a;
} 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) :: t_2
real(8) :: tmp
t_1 = (-60.0d0) * (x / t)
t_2 = (60.0d0 * (x - y)) / (z - t)
if (t_2 <= (-2d+147)) then
tmp = t_1
else if (t_2 <= 4d+89) then
tmp = 120.0d0 * a
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 = -60.0 * (x / t);
double t_2 = (60.0 * (x - y)) / (z - t);
double tmp;
if (t_2 <= -2e+147) {
tmp = t_1;
} else if (t_2 <= 4e+89) {
tmp = 120.0 * a;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z, t, a): t_1 = -60.0 * (x / t) t_2 = (60.0 * (x - y)) / (z - t) tmp = 0 if t_2 <= -2e+147: tmp = t_1 elif t_2 <= 4e+89: tmp = 120.0 * a else: tmp = t_1 return tmp
function code(x, y, z, t, a) t_1 = Float64(-60.0 * Float64(x / t)) t_2 = Float64(Float64(60.0 * Float64(x - y)) / Float64(z - t)) tmp = 0.0 if (t_2 <= -2e+147) tmp = t_1; elseif (t_2 <= 4e+89) tmp = Float64(120.0 * a); else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z, t, a) t_1 = -60.0 * (x / t); t_2 = (60.0 * (x - y)) / (z - t); tmp = 0.0; if (t_2 <= -2e+147) tmp = t_1; elseif (t_2 <= 4e+89) tmp = 120.0 * a; else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(-60.0 * N[(x / t), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(60.0 * N[(x - y), $MachinePrecision]), $MachinePrecision] / N[(z - t), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$2, -2e+147], t$95$1, If[LessEqual[t$95$2, 4e+89], N[(120.0 * a), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
t_1 := -60 \cdot \frac{x}{t}\\
t_2 := \frac{60 \cdot \left(x - y\right)}{z - t}\\
\mathbf{if}\;t\_2 \leq -2 \cdot 10^{+147}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_2 \leq 4 \cdot 10^{+89}:\\
\;\;\;\;120 \cdot a\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
if (/.f64 (*.f64 #s(literal 60 binary64) (-.f64 x y)) (-.f64 z t)) < -2e147 or 4e89 < (/.f64 (*.f64 #s(literal 60 binary64) (-.f64 x y)) (-.f64 z t)) Initial program 99.3%
Taylor expanded in z around 0
lower-fma.f64N/A
lower-/.f64N/A
lower--.f64N/A
lower-*.f6464.3%
Applied rewrites64.3%
Taylor expanded in x around inf
lower-*.f64N/A
lower-/.f6416.3%
Applied rewrites16.3%
if -2e147 < (/.f64 (*.f64 #s(literal 60 binary64) (-.f64 x y)) (-.f64 z t)) < 4e89Initial program 99.3%
Taylor expanded in z around inf
lower-*.f6450.8%
Applied rewrites50.8%
(FPCore (x y z t a) :precision binary64 (if (<= a -1.08e-82) (* 120.0 a) (if (<= a 1.05e-42) (* 60.0 (/ y t)) (* 120.0 a))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (a <= -1.08e-82) {
tmp = 120.0 * a;
} else if (a <= 1.05e-42) {
tmp = 60.0 * (y / t);
} else {
tmp = 120.0 * a;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z, t, a)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
real(8) :: tmp
if (a <= (-1.08d-82)) then
tmp = 120.0d0 * a
else if (a <= 1.05d-42) then
tmp = 60.0d0 * (y / t)
else
tmp = 120.0d0 * a
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a) {
double tmp;
if (a <= -1.08e-82) {
tmp = 120.0 * a;
} else if (a <= 1.05e-42) {
tmp = 60.0 * (y / t);
} else {
tmp = 120.0 * a;
}
return tmp;
}
def code(x, y, z, t, a): tmp = 0 if a <= -1.08e-82: tmp = 120.0 * a elif a <= 1.05e-42: tmp = 60.0 * (y / t) else: tmp = 120.0 * a return tmp
function code(x, y, z, t, a) tmp = 0.0 if (a <= -1.08e-82) tmp = Float64(120.0 * a); elseif (a <= 1.05e-42) tmp = Float64(60.0 * Float64(y / t)); else tmp = Float64(120.0 * a); end return tmp end
function tmp_2 = code(x, y, z, t, a) tmp = 0.0; if (a <= -1.08e-82) tmp = 120.0 * a; elseif (a <= 1.05e-42) tmp = 60.0 * (y / t); else tmp = 120.0 * a; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := If[LessEqual[a, -1.08e-82], N[(120.0 * a), $MachinePrecision], If[LessEqual[a, 1.05e-42], N[(60.0 * N[(y / t), $MachinePrecision]), $MachinePrecision], N[(120.0 * a), $MachinePrecision]]]
\begin{array}{l}
\mathbf{if}\;a \leq -1.08 \cdot 10^{-82}:\\
\;\;\;\;120 \cdot a\\
\mathbf{elif}\;a \leq 1.05 \cdot 10^{-42}:\\
\;\;\;\;60 \cdot \frac{y}{t}\\
\mathbf{else}:\\
\;\;\;\;120 \cdot a\\
\end{array}
if a < -1.08e-82 or 1.05e-42 < a Initial program 99.3%
Taylor expanded in z around inf
lower-*.f6450.8%
Applied rewrites50.8%
if -1.08e-82 < a < 1.05e-42Initial program 99.3%
Taylor expanded in x around 0
lower-fma.f64N/A
lower-/.f64N/A
lower--.f64N/A
lower-*.f6475.4%
Applied rewrites75.4%
Taylor expanded in z around 0
lower-fma.f64N/A
lower-/.f64N/A
lower-*.f6455.0%
Applied rewrites55.0%
Taylor expanded in y around inf
lower-*.f64N/A
lower-/.f6416.2%
Applied rewrites16.2%
(FPCore (x y z t a) :precision binary64 (* 120.0 a))
double code(double x, double y, double z, double t, double a) {
return 120.0 * a;
}
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 = 120.0d0 * a
end function
public static double code(double x, double y, double z, double t, double a) {
return 120.0 * a;
}
def code(x, y, z, t, a): return 120.0 * a
function code(x, y, z, t, a) return Float64(120.0 * a) end
function tmp = code(x, y, z, t, a) tmp = 120.0 * a; end
code[x_, y_, z_, t_, a_] := N[(120.0 * a), $MachinePrecision]
120 \cdot a
Initial program 99.3%
Taylor expanded in z around inf
lower-*.f6450.8%
Applied rewrites50.8%
herbie shell --seed 2025212
(FPCore (x y z t a)
:name "Data.Colour.RGB:hslsv from colour-2.3.3, B"
:precision binary64
(+ (/ (* 60.0 (- x y)) (- z t)) (* a 120.0)))