
(FPCore (x y z t a) :precision binary64 (/ (- (* x y) (* z t)) a))
double code(double x, double y, double z, double t, double a) {
return ((x * y) - (z * t)) / 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 = ((x * y) - (z * t)) / a
end function
public static double code(double x, double y, double z, double t, double a) {
return ((x * y) - (z * t)) / a;
}
def code(x, y, z, t, a): return ((x * y) - (z * t)) / a
function code(x, y, z, t, a) return Float64(Float64(Float64(x * y) - Float64(z * t)) / a) end
function tmp = code(x, y, z, t, a) tmp = ((x * y) - (z * t)) / a; end
code[x_, y_, z_, t_, a_] := N[(N[(N[(x * y), $MachinePrecision] - N[(z * t), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision]
\begin{array}{l}
\\
\frac{x \cdot y - z \cdot t}{a}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 9 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z t a) :precision binary64 (/ (- (* x y) (* z t)) a))
double code(double x, double y, double z, double t, double a) {
return ((x * y) - (z * t)) / 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 = ((x * y) - (z * t)) / a
end function
public static double code(double x, double y, double z, double t, double a) {
return ((x * y) - (z * t)) / a;
}
def code(x, y, z, t, a): return ((x * y) - (z * t)) / a
function code(x, y, z, t, a) return Float64(Float64(Float64(x * y) - Float64(z * t)) / a) end
function tmp = code(x, y, z, t, a) tmp = ((x * y) - (z * t)) / a; end
code[x_, y_, z_, t_, a_] := N[(N[(N[(x * y), $MachinePrecision] - N[(z * t), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision]
\begin{array}{l}
\\
\frac{x \cdot y - z \cdot t}{a}
\end{array}
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (- (* x y) (* z t))))
(if (or (<= t_1 -5e+296) (not (<= t_1 4e+249)))
(fma (/ y a) x (* (- t) (/ z a)))
(/ (fma (- z) t (* y x)) a))))
double code(double x, double y, double z, double t, double a) {
double t_1 = (x * y) - (z * t);
double tmp;
if ((t_1 <= -5e+296) || !(t_1 <= 4e+249)) {
tmp = fma((y / a), x, (-t * (z / a)));
} else {
tmp = fma(-z, t, (y * x)) / a;
}
return tmp;
}
function code(x, y, z, t, a) t_1 = Float64(Float64(x * y) - Float64(z * t)) tmp = 0.0 if ((t_1 <= -5e+296) || !(t_1 <= 4e+249)) tmp = fma(Float64(y / a), x, Float64(Float64(-t) * Float64(z / a))); else tmp = Float64(fma(Float64(-z), t, Float64(y * x)) / a); end return tmp end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(N[(x * y), $MachinePrecision] - N[(z * t), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t$95$1, -5e+296], N[Not[LessEqual[t$95$1, 4e+249]], $MachinePrecision]], N[(N[(y / a), $MachinePrecision] * x + N[((-t) * N[(z / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[((-z) * t + N[(y * x), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := x \cdot y - z \cdot t\\
\mathbf{if}\;t\_1 \leq -5 \cdot 10^{+296} \lor \neg \left(t\_1 \leq 4 \cdot 10^{+249}\right):\\
\;\;\;\;\mathsf{fma}\left(\frac{y}{a}, x, \left(-t\right) \cdot \frac{z}{a}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(-z, t, y \cdot x\right)}{a}\\
\end{array}
\end{array}
if (-.f64 (*.f64 x y) (*.f64 z t)) < -5.0000000000000001e296 or 3.9999999999999997e249 < (-.f64 (*.f64 x y) (*.f64 z t)) Initial program 69.5%
lift-/.f64N/A
lift--.f64N/A
div-subN/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
fp-cancel-sub-sign-invN/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-neg.f64N/A
lower-/.f6496.7
Applied rewrites96.7%
if -5.0000000000000001e296 < (-.f64 (*.f64 x y) (*.f64 z t)) < 3.9999999999999997e249Initial program 99.2%
lift--.f64N/A
lift-*.f64N/A
fp-cancel-sub-sign-invN/A
+-commutativeN/A
lower-fma.f64N/A
lower-neg.f6499.2
lift-*.f64N/A
*-commutativeN/A
lower-*.f6499.2
Applied rewrites99.2%
Final simplification98.6%
(FPCore (x y z t a) :precision binary64 (if (<= (* x y) (- INFINITY)) (* (/ x a) y) (if (<= (* x y) 2e+170) (/ (fma (- z) t (* y x)) a) (* x (/ y a)))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((x * y) <= -((double) INFINITY)) {
tmp = (x / a) * y;
} else if ((x * y) <= 2e+170) {
tmp = fma(-z, t, (y * x)) / a;
} else {
tmp = x * (y / a);
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if (Float64(x * y) <= Float64(-Inf)) tmp = Float64(Float64(x / a) * y); elseif (Float64(x * y) <= 2e+170) tmp = Float64(fma(Float64(-z), t, Float64(y * x)) / a); else tmp = Float64(x * Float64(y / a)); end return tmp end
code[x_, y_, z_, t_, a_] := If[LessEqual[N[(x * y), $MachinePrecision], (-Infinity)], N[(N[(x / a), $MachinePrecision] * y), $MachinePrecision], If[LessEqual[N[(x * y), $MachinePrecision], 2e+170], N[(N[((-z) * t + N[(y * x), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision], N[(x * N[(y / a), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \cdot y \leq -\infty:\\
\;\;\;\;\frac{x}{a} \cdot y\\
\mathbf{elif}\;x \cdot y \leq 2 \cdot 10^{+170}:\\
\;\;\;\;\frac{\mathsf{fma}\left(-z, t, y \cdot x\right)}{a}\\
\mathbf{else}:\\
\;\;\;\;x \cdot \frac{y}{a}\\
\end{array}
\end{array}
if (*.f64 x y) < -inf.0Initial program 65.7%
Taylor expanded in x around inf
associate-*l/N/A
lower-*.f64N/A
lower-/.f6499.9
Applied rewrites99.9%
if -inf.0 < (*.f64 x y) < 2.00000000000000007e170Initial program 96.9%
lift--.f64N/A
lift-*.f64N/A
fp-cancel-sub-sign-invN/A
+-commutativeN/A
lower-fma.f64N/A
lower-neg.f6496.9
lift-*.f64N/A
*-commutativeN/A
lower-*.f6496.9
Applied rewrites96.9%
if 2.00000000000000007e170 < (*.f64 x y) Initial program 76.8%
Taylor expanded in x around inf
associate-*l/N/A
lower-*.f64N/A
lower-/.f6496.7
Applied rewrites96.7%
Applied rewrites96.9%
(FPCore (x y z t a) :precision binary64 (if (<= (* x y) (- INFINITY)) (* (/ x a) y) (if (<= (* x y) 2e+170) (/ (- (* x y) (* z t)) a) (* x (/ y a)))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((x * y) <= -((double) INFINITY)) {
tmp = (x / a) * y;
} else if ((x * y) <= 2e+170) {
tmp = ((x * y) - (z * t)) / a;
} else {
tmp = x * (y / a);
}
return tmp;
}
public static double code(double x, double y, double z, double t, double a) {
double tmp;
if ((x * y) <= -Double.POSITIVE_INFINITY) {
tmp = (x / a) * y;
} else if ((x * y) <= 2e+170) {
tmp = ((x * y) - (z * t)) / a;
} else {
tmp = x * (y / a);
}
return tmp;
}
def code(x, y, z, t, a): tmp = 0 if (x * y) <= -math.inf: tmp = (x / a) * y elif (x * y) <= 2e+170: tmp = ((x * y) - (z * t)) / a else: tmp = x * (y / a) return tmp
function code(x, y, z, t, a) tmp = 0.0 if (Float64(x * y) <= Float64(-Inf)) tmp = Float64(Float64(x / a) * y); elseif (Float64(x * y) <= 2e+170) tmp = Float64(Float64(Float64(x * y) - Float64(z * t)) / a); else tmp = Float64(x * Float64(y / a)); end return tmp end
function tmp_2 = code(x, y, z, t, a) tmp = 0.0; if ((x * y) <= -Inf) tmp = (x / a) * y; elseif ((x * y) <= 2e+170) tmp = ((x * y) - (z * t)) / a; else tmp = x * (y / a); end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := If[LessEqual[N[(x * y), $MachinePrecision], (-Infinity)], N[(N[(x / a), $MachinePrecision] * y), $MachinePrecision], If[LessEqual[N[(x * y), $MachinePrecision], 2e+170], N[(N[(N[(x * y), $MachinePrecision] - N[(z * t), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision], N[(x * N[(y / a), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \cdot y \leq -\infty:\\
\;\;\;\;\frac{x}{a} \cdot y\\
\mathbf{elif}\;x \cdot y \leq 2 \cdot 10^{+170}:\\
\;\;\;\;\frac{x \cdot y - z \cdot t}{a}\\
\mathbf{else}:\\
\;\;\;\;x \cdot \frac{y}{a}\\
\end{array}
\end{array}
if (*.f64 x y) < -inf.0Initial program 65.7%
Taylor expanded in x around inf
associate-*l/N/A
lower-*.f64N/A
lower-/.f6499.9
Applied rewrites99.9%
if -inf.0 < (*.f64 x y) < 2.00000000000000007e170Initial program 96.9%
if 2.00000000000000007e170 < (*.f64 x y) Initial program 76.8%
Taylor expanded in x around inf
associate-*l/N/A
lower-*.f64N/A
lower-/.f6496.7
Applied rewrites96.7%
Applied rewrites96.9%
(FPCore (x y z t a) :precision binary64 (if (or (<= (* x y) -2e+29) (not (<= (* x y) 2e+66))) (* x (/ y a)) (* (- z) (/ t a))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (((x * y) <= -2e+29) || !((x * y) <= 2e+66)) {
tmp = x * (y / a);
} else {
tmp = -z * (t / 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 (((x * y) <= (-2d+29)) .or. (.not. ((x * y) <= 2d+66))) then
tmp = x * (y / a)
else
tmp = -z * (t / a)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a) {
double tmp;
if (((x * y) <= -2e+29) || !((x * y) <= 2e+66)) {
tmp = x * (y / a);
} else {
tmp = -z * (t / a);
}
return tmp;
}
def code(x, y, z, t, a): tmp = 0 if ((x * y) <= -2e+29) or not ((x * y) <= 2e+66): tmp = x * (y / a) else: tmp = -z * (t / a) return tmp
function code(x, y, z, t, a) tmp = 0.0 if ((Float64(x * y) <= -2e+29) || !(Float64(x * y) <= 2e+66)) tmp = Float64(x * Float64(y / a)); else tmp = Float64(Float64(-z) * Float64(t / a)); end return tmp end
function tmp_2 = code(x, y, z, t, a) tmp = 0.0; if (((x * y) <= -2e+29) || ~(((x * y) <= 2e+66))) tmp = x * (y / a); else tmp = -z * (t / a); end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := If[Or[LessEqual[N[(x * y), $MachinePrecision], -2e+29], N[Not[LessEqual[N[(x * y), $MachinePrecision], 2e+66]], $MachinePrecision]], N[(x * N[(y / a), $MachinePrecision]), $MachinePrecision], N[((-z) * N[(t / a), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \cdot y \leq -2 \cdot 10^{+29} \lor \neg \left(x \cdot y \leq 2 \cdot 10^{+66}\right):\\
\;\;\;\;x \cdot \frac{y}{a}\\
\mathbf{else}:\\
\;\;\;\;\left(-z\right) \cdot \frac{t}{a}\\
\end{array}
\end{array}
if (*.f64 x y) < -1.99999999999999983e29 or 1.99999999999999989e66 < (*.f64 x y) Initial program 86.3%
Taylor expanded in x around inf
associate-*l/N/A
lower-*.f64N/A
lower-/.f6483.2
Applied rewrites83.2%
Applied rewrites84.9%
if -1.99999999999999983e29 < (*.f64 x y) < 1.99999999999999989e66Initial program 96.3%
Taylor expanded in x around 0
associate-*r/N/A
mul-1-negN/A
distribute-rgt-neg-inN/A
mul-1-negN/A
associate-*l/N/A
*-commutativeN/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower-/.f6467.4
Applied rewrites67.4%
Final simplification75.5%
(FPCore (x y z t a) :precision binary64 (if (or (<= (* x y) -2e+29) (not (<= (* x y) 2e+66))) (* x (/ y a)) (* (/ (- z) a) t)))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (((x * y) <= -2e+29) || !((x * y) <= 2e+66)) {
tmp = x * (y / a);
} else {
tmp = (-z / a) * t;
}
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 (((x * y) <= (-2d+29)) .or. (.not. ((x * y) <= 2d+66))) then
tmp = x * (y / a)
else
tmp = (-z / a) * t
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a) {
double tmp;
if (((x * y) <= -2e+29) || !((x * y) <= 2e+66)) {
tmp = x * (y / a);
} else {
tmp = (-z / a) * t;
}
return tmp;
}
def code(x, y, z, t, a): tmp = 0 if ((x * y) <= -2e+29) or not ((x * y) <= 2e+66): tmp = x * (y / a) else: tmp = (-z / a) * t return tmp
function code(x, y, z, t, a) tmp = 0.0 if ((Float64(x * y) <= -2e+29) || !(Float64(x * y) <= 2e+66)) tmp = Float64(x * Float64(y / a)); else tmp = Float64(Float64(Float64(-z) / a) * t); end return tmp end
function tmp_2 = code(x, y, z, t, a) tmp = 0.0; if (((x * y) <= -2e+29) || ~(((x * y) <= 2e+66))) tmp = x * (y / a); else tmp = (-z / a) * t; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := If[Or[LessEqual[N[(x * y), $MachinePrecision], -2e+29], N[Not[LessEqual[N[(x * y), $MachinePrecision], 2e+66]], $MachinePrecision]], N[(x * N[(y / a), $MachinePrecision]), $MachinePrecision], N[(N[((-z) / a), $MachinePrecision] * t), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \cdot y \leq -2 \cdot 10^{+29} \lor \neg \left(x \cdot y \leq 2 \cdot 10^{+66}\right):\\
\;\;\;\;x \cdot \frac{y}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{-z}{a} \cdot t\\
\end{array}
\end{array}
if (*.f64 x y) < -1.99999999999999983e29 or 1.99999999999999989e66 < (*.f64 x y) Initial program 86.3%
Taylor expanded in x around inf
associate-*l/N/A
lower-*.f64N/A
lower-/.f6483.2
Applied rewrites83.2%
Applied rewrites84.9%
if -1.99999999999999983e29 < (*.f64 x y) < 1.99999999999999989e66Initial program 96.3%
Applied rewrites40.1%
Taylor expanded in x around 0
*-commutativeN/A
associate-*l/N/A
lower-*.f64N/A
*-commutativeN/A
unpow2N/A
rem-square-sqrtN/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f6475.6
Applied rewrites75.6%
Final simplification79.9%
(FPCore (x y z t a) :precision binary64 (if (<= (* x y) -2e+29) (* x (/ y a)) (if (<= (* x y) 5e+43) (/ (* (- z) t) a) (* (/ x a) y))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((x * y) <= -2e+29) {
tmp = x * (y / a);
} else if ((x * y) <= 5e+43) {
tmp = (-z * t) / a;
} else {
tmp = (x / a) * 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 ((x * y) <= (-2d+29)) then
tmp = x * (y / a)
else if ((x * y) <= 5d+43) then
tmp = (-z * t) / a
else
tmp = (x / a) * y
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a) {
double tmp;
if ((x * y) <= -2e+29) {
tmp = x * (y / a);
} else if ((x * y) <= 5e+43) {
tmp = (-z * t) / a;
} else {
tmp = (x / a) * y;
}
return tmp;
}
def code(x, y, z, t, a): tmp = 0 if (x * y) <= -2e+29: tmp = x * (y / a) elif (x * y) <= 5e+43: tmp = (-z * t) / a else: tmp = (x / a) * y return tmp
function code(x, y, z, t, a) tmp = 0.0 if (Float64(x * y) <= -2e+29) tmp = Float64(x * Float64(y / a)); elseif (Float64(x * y) <= 5e+43) tmp = Float64(Float64(Float64(-z) * t) / a); else tmp = Float64(Float64(x / a) * y); end return tmp end
function tmp_2 = code(x, y, z, t, a) tmp = 0.0; if ((x * y) <= -2e+29) tmp = x * (y / a); elseif ((x * y) <= 5e+43) tmp = (-z * t) / a; else tmp = (x / a) * y; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := If[LessEqual[N[(x * y), $MachinePrecision], -2e+29], N[(x * N[(y / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(x * y), $MachinePrecision], 5e+43], N[(N[((-z) * t), $MachinePrecision] / a), $MachinePrecision], N[(N[(x / a), $MachinePrecision] * y), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \cdot y \leq -2 \cdot 10^{+29}:\\
\;\;\;\;x \cdot \frac{y}{a}\\
\mathbf{elif}\;x \cdot y \leq 5 \cdot 10^{+43}:\\
\;\;\;\;\frac{\left(-z\right) \cdot t}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{a} \cdot y\\
\end{array}
\end{array}
if (*.f64 x y) < -1.99999999999999983e29Initial program 88.6%
Taylor expanded in x around inf
associate-*l/N/A
lower-*.f64N/A
lower-/.f6483.2
Applied rewrites83.2%
Applied rewrites84.4%
if -1.99999999999999983e29 < (*.f64 x y) < 5.0000000000000004e43Initial program 96.7%
Taylor expanded in x around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f6479.5
Applied rewrites79.5%
if 5.0000000000000004e43 < (*.f64 x y) Initial program 84.0%
Taylor expanded in x around inf
associate-*l/N/A
lower-*.f64N/A
lower-/.f6478.5
Applied rewrites78.5%
(FPCore (x y z t a) :precision binary64 (if (<= y 1.75e-107) (* (/ x a) y) (* x (/ y a))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (y <= 1.75e-107) {
tmp = (x / a) * y;
} else {
tmp = x * (y / a);
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z, t, a)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
real(8) :: tmp
if (y <= 1.75d-107) then
tmp = (x / a) * y
else
tmp = x * (y / a)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a) {
double tmp;
if (y <= 1.75e-107) {
tmp = (x / a) * y;
} else {
tmp = x * (y / a);
}
return tmp;
}
def code(x, y, z, t, a): tmp = 0 if y <= 1.75e-107: tmp = (x / a) * y else: tmp = x * (y / a) return tmp
function code(x, y, z, t, a) tmp = 0.0 if (y <= 1.75e-107) tmp = Float64(Float64(x / a) * y); else tmp = Float64(x * Float64(y / a)); end return tmp end
function tmp_2 = code(x, y, z, t, a) tmp = 0.0; if (y <= 1.75e-107) tmp = (x / a) * y; else tmp = x * (y / a); end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := If[LessEqual[y, 1.75e-107], N[(N[(x / a), $MachinePrecision] * y), $MachinePrecision], N[(x * N[(y / a), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.75 \cdot 10^{-107}:\\
\;\;\;\;\frac{x}{a} \cdot y\\
\mathbf{else}:\\
\;\;\;\;x \cdot \frac{y}{a}\\
\end{array}
\end{array}
if y < 1.74999999999999993e-107Initial program 92.5%
Taylor expanded in x around inf
associate-*l/N/A
lower-*.f64N/A
lower-/.f6450.6
Applied rewrites50.6%
if 1.74999999999999993e-107 < y Initial program 90.2%
Taylor expanded in x around inf
associate-*l/N/A
lower-*.f64N/A
lower-/.f6462.7
Applied rewrites62.7%
Applied rewrites67.3%
(FPCore (x y z t a) :precision binary64 (* x (/ y a)))
double code(double x, double y, double z, double t, double a) {
return x * (y / 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 = x * (y / a)
end function
public static double code(double x, double y, double z, double t, double a) {
return x * (y / a);
}
def code(x, y, z, t, a): return x * (y / a)
function code(x, y, z, t, a) return Float64(x * Float64(y / a)) end
function tmp = code(x, y, z, t, a) tmp = x * (y / a); end
code[x_, y_, z_, t_, a_] := N[(x * N[(y / a), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot \frac{y}{a}
\end{array}
Initial program 91.6%
Taylor expanded in x around inf
associate-*l/N/A
lower-*.f64N/A
lower-/.f6455.2
Applied rewrites55.2%
Applied rewrites56.5%
(FPCore (x y z t a) :precision binary64 (* (/ z a) t))
double code(double x, double y, double z, double t, double a) {
return (z / 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 = (z / a) * t
end function
public static double code(double x, double y, double z, double t, double a) {
return (z / a) * t;
}
def code(x, y, z, t, a): return (z / a) * t
function code(x, y, z, t, a) return Float64(Float64(z / a) * t) end
function tmp = code(x, y, z, t, a) tmp = (z / a) * t; end
code[x_, y_, z_, t_, a_] := N[(N[(z / a), $MachinePrecision] * t), $MachinePrecision]
\begin{array}{l}
\\
\frac{z}{a} \cdot t
\end{array}
Initial program 91.6%
Applied rewrites24.4%
Taylor expanded in x around 0
*-commutativeN/A
associate-*l/N/A
lower-*.f64N/A
*-commutativeN/A
unpow2N/A
rem-square-sqrtN/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f6450.4
Applied rewrites50.4%
Applied rewrites12.4%
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (- (* (/ y a) x) (* (/ t a) z))))
(if (< z -2.468684968699548e+170)
t_1
(if (< z 6.309831121978371e-71) (/ (- (* x y) (* z t)) a) t_1))))
double code(double x, double y, double z, double t, double a) {
double t_1 = ((y / a) * x) - ((t / a) * z);
double tmp;
if (z < -2.468684968699548e+170) {
tmp = t_1;
} else if (z < 6.309831121978371e-71) {
tmp = ((x * y) - (z * t)) / 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) :: tmp
t_1 = ((y / a) * x) - ((t / a) * z)
if (z < (-2.468684968699548d+170)) then
tmp = t_1
else if (z < 6.309831121978371d-71) then
tmp = ((x * y) - (z * t)) / 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 = ((y / a) * x) - ((t / a) * z);
double tmp;
if (z < -2.468684968699548e+170) {
tmp = t_1;
} else if (z < 6.309831121978371e-71) {
tmp = ((x * y) - (z * t)) / a;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z, t, a): t_1 = ((y / a) * x) - ((t / a) * z) tmp = 0 if z < -2.468684968699548e+170: tmp = t_1 elif z < 6.309831121978371e-71: tmp = ((x * y) - (z * t)) / a else: tmp = t_1 return tmp
function code(x, y, z, t, a) t_1 = Float64(Float64(Float64(y / a) * x) - Float64(Float64(t / a) * z)) tmp = 0.0 if (z < -2.468684968699548e+170) tmp = t_1; elseif (z < 6.309831121978371e-71) tmp = Float64(Float64(Float64(x * y) - Float64(z * t)) / a); else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z, t, a) t_1 = ((y / a) * x) - ((t / a) * z); tmp = 0.0; if (z < -2.468684968699548e+170) tmp = t_1; elseif (z < 6.309831121978371e-71) tmp = ((x * y) - (z * t)) / a; else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(N[(N[(y / a), $MachinePrecision] * x), $MachinePrecision] - N[(N[(t / a), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]}, If[Less[z, -2.468684968699548e+170], t$95$1, If[Less[z, 6.309831121978371e-71], N[(N[(N[(x * y), $MachinePrecision] - N[(z * t), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{y}{a} \cdot x - \frac{t}{a} \cdot z\\
\mathbf{if}\;z < -2.468684968699548 \cdot 10^{+170}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z < 6.309831121978371 \cdot 10^{-71}:\\
\;\;\;\;\frac{x \cdot y - z \cdot t}{a}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
herbie shell --seed 2024352
(FPCore (x y z t a)
:name "Data.Colour.Matrix:inverse from colour-2.3.3, B"
:precision binary64
:alt
(! :herbie-platform default (if (< z -246868496869954800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000) (- (* (/ y a) x) (* (/ t a) z)) (if (< z 6309831121978371/100000000000000000000000000000000000000000000000000000000000000000000000000000000000000) (/ (- (* x y) (* z t)) a) (- (* (/ y a) x) (* (/ t a) z)))))
(/ (- (* x y) (* z t)) a))