
(FPCore (x y z t a b c i) :precision binary64 (* 2.0 (- (+ (* x y) (* z t)) (* (* (+ a (* b c)) c) i))))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
return 2.0 * (((x * y) + (z * t)) - (((a + (b * c)) * c) * i));
}
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, b, c, i)
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), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: i
code = 2.0d0 * (((x * y) + (z * t)) - (((a + (b * c)) * c) * i))
end function
public static double code(double x, double y, double z, double t, double a, double b, double c, double i) {
return 2.0 * (((x * y) + (z * t)) - (((a + (b * c)) * c) * i));
}
def code(x, y, z, t, a, b, c, i): return 2.0 * (((x * y) + (z * t)) - (((a + (b * c)) * c) * i))
function code(x, y, z, t, a, b, c, i) return Float64(2.0 * Float64(Float64(Float64(x * y) + Float64(z * t)) - Float64(Float64(Float64(a + Float64(b * c)) * c) * i))) end
function tmp = code(x, y, z, t, a, b, c, i) tmp = 2.0 * (((x * y) + (z * t)) - (((a + (b * c)) * c) * i)); end
code[x_, y_, z_, t_, a_, b_, c_, i_] := N[(2.0 * N[(N[(N[(x * y), $MachinePrecision] + N[(z * t), $MachinePrecision]), $MachinePrecision] - N[(N[(N[(a + N[(b * c), $MachinePrecision]), $MachinePrecision] * c), $MachinePrecision] * i), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
2 \cdot \left(\left(x \cdot y + z \cdot t\right) - \left(\left(a + b \cdot c\right) \cdot c\right) \cdot i\right)
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 12 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z t a b c i) :precision binary64 (* 2.0 (- (+ (* x y) (* z t)) (* (* (+ a (* b c)) c) i))))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
return 2.0 * (((x * y) + (z * t)) - (((a + (b * c)) * c) * i));
}
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, b, c, i)
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), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: i
code = 2.0d0 * (((x * y) + (z * t)) - (((a + (b * c)) * c) * i))
end function
public static double code(double x, double y, double z, double t, double a, double b, double c, double i) {
return 2.0 * (((x * y) + (z * t)) - (((a + (b * c)) * c) * i));
}
def code(x, y, z, t, a, b, c, i): return 2.0 * (((x * y) + (z * t)) - (((a + (b * c)) * c) * i))
function code(x, y, z, t, a, b, c, i) return Float64(2.0 * Float64(Float64(Float64(x * y) + Float64(z * t)) - Float64(Float64(Float64(a + Float64(b * c)) * c) * i))) end
function tmp = code(x, y, z, t, a, b, c, i) tmp = 2.0 * (((x * y) + (z * t)) - (((a + (b * c)) * c) * i)); end
code[x_, y_, z_, t_, a_, b_, c_, i_] := N[(2.0 * N[(N[(N[(x * y), $MachinePrecision] + N[(z * t), $MachinePrecision]), $MachinePrecision] - N[(N[(N[(a + N[(b * c), $MachinePrecision]), $MachinePrecision] * c), $MachinePrecision] * i), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
2 \cdot \left(\left(x \cdot y + z \cdot t\right) - \left(\left(a + b \cdot c\right) \cdot c\right) \cdot i\right)
\end{array}
(FPCore (x y z t a b c i)
:precision binary64
(let* ((t_1 (+ (* x y) (* z t))))
(if (<= (* 2.0 (- t_1 (* (* (+ a (* b c)) c) i))) INFINITY)
(* 2.0 (- t_1 (* (fma c b a) (* i c))))
(* (* c (* (* i c) b)) -2.0))))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double t_1 = (x * y) + (z * t);
double tmp;
if ((2.0 * (t_1 - (((a + (b * c)) * c) * i))) <= ((double) INFINITY)) {
tmp = 2.0 * (t_1 - (fma(c, b, a) * (i * c)));
} else {
tmp = (c * ((i * c) * b)) * -2.0;
}
return tmp;
}
function code(x, y, z, t, a, b, c, i) t_1 = Float64(Float64(x * y) + Float64(z * t)) tmp = 0.0 if (Float64(2.0 * Float64(t_1 - Float64(Float64(Float64(a + Float64(b * c)) * c) * i))) <= Inf) tmp = Float64(2.0 * Float64(t_1 - Float64(fma(c, b, a) * Float64(i * c)))); else tmp = Float64(Float64(c * Float64(Float64(i * c) * b)) * -2.0); end return tmp end
code[x_, y_, z_, t_, a_, b_, c_, i_] := Block[{t$95$1 = N[(N[(x * y), $MachinePrecision] + N[(z * t), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(2.0 * N[(t$95$1 - N[(N[(N[(a + N[(b * c), $MachinePrecision]), $MachinePrecision] * c), $MachinePrecision] * i), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], Infinity], N[(2.0 * N[(t$95$1 - N[(N[(c * b + a), $MachinePrecision] * N[(i * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(c * N[(N[(i * c), $MachinePrecision] * b), $MachinePrecision]), $MachinePrecision] * -2.0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := x \cdot y + z \cdot t\\
\mathbf{if}\;2 \cdot \left(t\_1 - \left(\left(a + b \cdot c\right) \cdot c\right) \cdot i\right) \leq \infty:\\
\;\;\;\;2 \cdot \left(t\_1 - \mathsf{fma}\left(c, b, a\right) \cdot \left(i \cdot c\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\left(c \cdot \left(\left(i \cdot c\right) \cdot b\right)\right) \cdot -2\\
\end{array}
\end{array}
if (*.f64 #s(literal 2 binary64) (-.f64 (+.f64 (*.f64 x y) (*.f64 z t)) (*.f64 (*.f64 (+.f64 a (*.f64 b c)) c) i))) < +inf.0Initial program 95.3%
lift-*.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-*.f64N/A
associate-*l*N/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6499.5
Applied rewrites99.5%
if +inf.0 < (*.f64 #s(literal 2 binary64) (-.f64 (+.f64 (*.f64 x y) (*.f64 z t)) (*.f64 (*.f64 (+.f64 a (*.f64 b c)) c) i))) Initial program 0.0%
Taylor expanded in b around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6482.0
Applied rewrites82.0%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lower-*.f64N/A
*-commutativeN/A
lift-*.f6482.0
Applied rewrites82.0%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lift-*.f64N/A
*-commutativeN/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f6482.0
Applied rewrites82.0%
(FPCore (x y z t a b c i)
:precision binary64
(let* ((t_1 (* -2.0 (* (* (fma c b a) i) c))) (t_2 (* (* (+ a (* b c)) c) i)))
(if (<= t_2 -1e+276)
t_1
(if (<= t_2 -2e+113)
(* 2.0 (- (* y x) (* a (* i c))))
(if (<= t_2 2e+237) (* 2.0 (fma t z (* y x))) t_1)))))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double t_1 = -2.0 * ((fma(c, b, a) * i) * c);
double t_2 = ((a + (b * c)) * c) * i;
double tmp;
if (t_2 <= -1e+276) {
tmp = t_1;
} else if (t_2 <= -2e+113) {
tmp = 2.0 * ((y * x) - (a * (i * c)));
} else if (t_2 <= 2e+237) {
tmp = 2.0 * fma(t, z, (y * x));
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a, b, c, i) t_1 = Float64(-2.0 * Float64(Float64(fma(c, b, a) * i) * c)) t_2 = Float64(Float64(Float64(a + Float64(b * c)) * c) * i) tmp = 0.0 if (t_2 <= -1e+276) tmp = t_1; elseif (t_2 <= -2e+113) tmp = Float64(2.0 * Float64(Float64(y * x) - Float64(a * Float64(i * c)))); elseif (t_2 <= 2e+237) tmp = Float64(2.0 * fma(t, z, Float64(y * x))); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_, b_, c_, i_] := Block[{t$95$1 = N[(-2.0 * N[(N[(N[(c * b + a), $MachinePrecision] * i), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(N[(a + N[(b * c), $MachinePrecision]), $MachinePrecision] * c), $MachinePrecision] * i), $MachinePrecision]}, If[LessEqual[t$95$2, -1e+276], t$95$1, If[LessEqual[t$95$2, -2e+113], N[(2.0 * N[(N[(y * x), $MachinePrecision] - N[(a * N[(i * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, 2e+237], N[(2.0 * N[(t * z + N[(y * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := -2 \cdot \left(\left(\mathsf{fma}\left(c, b, a\right) \cdot i\right) \cdot c\right)\\
t_2 := \left(\left(a + b \cdot c\right) \cdot c\right) \cdot i\\
\mathbf{if}\;t\_2 \leq -1 \cdot 10^{+276}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_2 \leq -2 \cdot 10^{+113}:\\
\;\;\;\;2 \cdot \left(y \cdot x - a \cdot \left(i \cdot c\right)\right)\\
\mathbf{elif}\;t\_2 \leq 2 \cdot 10^{+237}:\\
\;\;\;\;2 \cdot \mathsf{fma}\left(t, z, y \cdot x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (*.f64 (*.f64 (+.f64 a (*.f64 b c)) c) i) < -1.0000000000000001e276 or 1.99999999999999988e237 < (*.f64 (*.f64 (+.f64 a (*.f64 b c)) c) i) Initial program 80.3%
Taylor expanded in i around inf
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f6492.9
Applied rewrites92.9%
if -1.0000000000000001e276 < (*.f64 (*.f64 (+.f64 a (*.f64 b c)) c) i) < -2e113Initial program 99.8%
lift-*.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-*.f64N/A
associate-*l*N/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6499.7
Applied rewrites99.7%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f6495.6
Applied rewrites95.6%
Taylor expanded in a around inf
Applied rewrites81.9%
if -2e113 < (*.f64 (*.f64 (+.f64 a (*.f64 b c)) c) i) < 1.99999999999999988e237Initial program 99.1%
Taylor expanded in c around 0
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6480.7
Applied rewrites80.7%
(FPCore (x y z t a b c i)
:precision binary64
(let* ((t_1 (* (* (+ a (* b c)) c) i)))
(if (<= t_1 -1e+276)
(* (* c (* (* i c) b)) -2.0)
(if (<= t_1 -2e+113)
(* (* (* a c) i) -2.0)
(if (<= t_1 1e+238)
(* 2.0 (fma t z (* y x)))
(* (* (* i (* b c)) c) -2.0))))))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double t_1 = ((a + (b * c)) * c) * i;
double tmp;
if (t_1 <= -1e+276) {
tmp = (c * ((i * c) * b)) * -2.0;
} else if (t_1 <= -2e+113) {
tmp = ((a * c) * i) * -2.0;
} else if (t_1 <= 1e+238) {
tmp = 2.0 * fma(t, z, (y * x));
} else {
tmp = ((i * (b * c)) * c) * -2.0;
}
return tmp;
}
function code(x, y, z, t, a, b, c, i) t_1 = Float64(Float64(Float64(a + Float64(b * c)) * c) * i) tmp = 0.0 if (t_1 <= -1e+276) tmp = Float64(Float64(c * Float64(Float64(i * c) * b)) * -2.0); elseif (t_1 <= -2e+113) tmp = Float64(Float64(Float64(a * c) * i) * -2.0); elseif (t_1 <= 1e+238) tmp = Float64(2.0 * fma(t, z, Float64(y * x))); else tmp = Float64(Float64(Float64(i * Float64(b * c)) * c) * -2.0); end return tmp end
code[x_, y_, z_, t_, a_, b_, c_, i_] := Block[{t$95$1 = N[(N[(N[(a + N[(b * c), $MachinePrecision]), $MachinePrecision] * c), $MachinePrecision] * i), $MachinePrecision]}, If[LessEqual[t$95$1, -1e+276], N[(N[(c * N[(N[(i * c), $MachinePrecision] * b), $MachinePrecision]), $MachinePrecision] * -2.0), $MachinePrecision], If[LessEqual[t$95$1, -2e+113], N[(N[(N[(a * c), $MachinePrecision] * i), $MachinePrecision] * -2.0), $MachinePrecision], If[LessEqual[t$95$1, 1e+238], N[(2.0 * N[(t * z + N[(y * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(i * N[(b * c), $MachinePrecision]), $MachinePrecision] * c), $MachinePrecision] * -2.0), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left(\left(a + b \cdot c\right) \cdot c\right) \cdot i\\
\mathbf{if}\;t\_1 \leq -1 \cdot 10^{+276}:\\
\;\;\;\;\left(c \cdot \left(\left(i \cdot c\right) \cdot b\right)\right) \cdot -2\\
\mathbf{elif}\;t\_1 \leq -2 \cdot 10^{+113}:\\
\;\;\;\;\left(\left(a \cdot c\right) \cdot i\right) \cdot -2\\
\mathbf{elif}\;t\_1 \leq 10^{+238}:\\
\;\;\;\;2 \cdot \mathsf{fma}\left(t, z, y \cdot x\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\left(i \cdot \left(b \cdot c\right)\right) \cdot c\right) \cdot -2\\
\end{array}
\end{array}
if (*.f64 (*.f64 (+.f64 a (*.f64 b c)) c) i) < -1.0000000000000001e276Initial program 80.9%
Taylor expanded in b around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6478.9
Applied rewrites78.9%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lower-*.f64N/A
*-commutativeN/A
lift-*.f6478.9
Applied rewrites78.9%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lift-*.f64N/A
*-commutativeN/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f6478.9
Applied rewrites78.9%
if -1.0000000000000001e276 < (*.f64 (*.f64 (+.f64 a (*.f64 b c)) c) i) < -2e113Initial program 99.8%
Taylor expanded in a around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6458.9
Applied rewrites58.9%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f6459.0
Applied rewrites59.0%
if -2e113 < (*.f64 (*.f64 (+.f64 a (*.f64 b c)) c) i) < 1e238Initial program 99.2%
Taylor expanded in c around 0
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6480.1
Applied rewrites80.1%
if 1e238 < (*.f64 (*.f64 (+.f64 a (*.f64 b c)) c) i) Initial program 79.3%
Taylor expanded in a around 0
fp-cancel-sub-sign-invN/A
mul-1-negN/A
associate-*r*N/A
+-commutativeN/A
associate-*r*N/A
mul-1-negN/A
lower-fma.f64N/A
lower-neg.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6463.3
Applied rewrites63.3%
Taylor expanded in i around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
*-commutativeN/A
+-commutativeN/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
+-commutativeN/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
+-commutativeN/A
lower-fma.f6493.1
Applied rewrites93.1%
Taylor expanded in a around 0
lower-*.f6473.9
Applied rewrites73.9%
(FPCore (x y z t a b c i)
:precision binary64
(let* ((t_1 (* (* c (* (* i c) b)) -2.0)) (t_2 (* (* (+ a (* b c)) c) i)))
(if (<= t_2 -1e+276)
t_1
(if (<= t_2 -2e+113)
(* (* (* a c) i) -2.0)
(if (<= t_2 1e+238) (* 2.0 (fma t z (* y x))) t_1)))))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double t_1 = (c * ((i * c) * b)) * -2.0;
double t_2 = ((a + (b * c)) * c) * i;
double tmp;
if (t_2 <= -1e+276) {
tmp = t_1;
} else if (t_2 <= -2e+113) {
tmp = ((a * c) * i) * -2.0;
} else if (t_2 <= 1e+238) {
tmp = 2.0 * fma(t, z, (y * x));
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a, b, c, i) t_1 = Float64(Float64(c * Float64(Float64(i * c) * b)) * -2.0) t_2 = Float64(Float64(Float64(a + Float64(b * c)) * c) * i) tmp = 0.0 if (t_2 <= -1e+276) tmp = t_1; elseif (t_2 <= -2e+113) tmp = Float64(Float64(Float64(a * c) * i) * -2.0); elseif (t_2 <= 1e+238) tmp = Float64(2.0 * fma(t, z, Float64(y * x))); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_, b_, c_, i_] := Block[{t$95$1 = N[(N[(c * N[(N[(i * c), $MachinePrecision] * b), $MachinePrecision]), $MachinePrecision] * -2.0), $MachinePrecision]}, Block[{t$95$2 = N[(N[(N[(a + N[(b * c), $MachinePrecision]), $MachinePrecision] * c), $MachinePrecision] * i), $MachinePrecision]}, If[LessEqual[t$95$2, -1e+276], t$95$1, If[LessEqual[t$95$2, -2e+113], N[(N[(N[(a * c), $MachinePrecision] * i), $MachinePrecision] * -2.0), $MachinePrecision], If[LessEqual[t$95$2, 1e+238], N[(2.0 * N[(t * z + N[(y * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left(c \cdot \left(\left(i \cdot c\right) \cdot b\right)\right) \cdot -2\\
t_2 := \left(\left(a + b \cdot c\right) \cdot c\right) \cdot i\\
\mathbf{if}\;t\_2 \leq -1 \cdot 10^{+276}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_2 \leq -2 \cdot 10^{+113}:\\
\;\;\;\;\left(\left(a \cdot c\right) \cdot i\right) \cdot -2\\
\mathbf{elif}\;t\_2 \leq 10^{+238}:\\
\;\;\;\;2 \cdot \mathsf{fma}\left(t, z, y \cdot x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (*.f64 (*.f64 (+.f64 a (*.f64 b c)) c) i) < -1.0000000000000001e276 or 1e238 < (*.f64 (*.f64 (+.f64 a (*.f64 b c)) c) i) Initial program 80.1%
Taylor expanded in b around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6473.7
Applied rewrites73.7%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lower-*.f64N/A
*-commutativeN/A
lift-*.f6473.6
Applied rewrites73.6%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lift-*.f64N/A
*-commutativeN/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f6475.4
Applied rewrites75.4%
if -1.0000000000000001e276 < (*.f64 (*.f64 (+.f64 a (*.f64 b c)) c) i) < -2e113Initial program 99.8%
Taylor expanded in a around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6458.9
Applied rewrites58.9%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f6459.0
Applied rewrites59.0%
if -2e113 < (*.f64 (*.f64 (+.f64 a (*.f64 b c)) c) i) < 1e238Initial program 99.2%
Taylor expanded in c around 0
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6480.1
Applied rewrites80.1%
(FPCore (x y z t a b c i)
:precision binary64
(let* ((t_1 (* (* (+ a (* b c)) c) i)))
(if (or (<= t_1 -1e-79) (not (<= t_1 50000.0)))
(* 2.0 (- (* t z) (* (* (fma c b a) i) c)))
(* 2.0 (fma t z (* y x))))))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double t_1 = ((a + (b * c)) * c) * i;
double tmp;
if ((t_1 <= -1e-79) || !(t_1 <= 50000.0)) {
tmp = 2.0 * ((t * z) - ((fma(c, b, a) * i) * c));
} else {
tmp = 2.0 * fma(t, z, (y * x));
}
return tmp;
}
function code(x, y, z, t, a, b, c, i) t_1 = Float64(Float64(Float64(a + Float64(b * c)) * c) * i) tmp = 0.0 if ((t_1 <= -1e-79) || !(t_1 <= 50000.0)) tmp = Float64(2.0 * Float64(Float64(t * z) - Float64(Float64(fma(c, b, a) * i) * c))); else tmp = Float64(2.0 * fma(t, z, Float64(y * x))); end return tmp end
code[x_, y_, z_, t_, a_, b_, c_, i_] := Block[{t$95$1 = N[(N[(N[(a + N[(b * c), $MachinePrecision]), $MachinePrecision] * c), $MachinePrecision] * i), $MachinePrecision]}, If[Or[LessEqual[t$95$1, -1e-79], N[Not[LessEqual[t$95$1, 50000.0]], $MachinePrecision]], N[(2.0 * N[(N[(t * z), $MachinePrecision] - N[(N[(N[(c * b + a), $MachinePrecision] * i), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(2.0 * N[(t * z + N[(y * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left(\left(a + b \cdot c\right) \cdot c\right) \cdot i\\
\mathbf{if}\;t\_1 \leq -1 \cdot 10^{-79} \lor \neg \left(t\_1 \leq 50000\right):\\
\;\;\;\;2 \cdot \left(t \cdot z - \left(\mathsf{fma}\left(c, b, a\right) \cdot i\right) \cdot c\right)\\
\mathbf{else}:\\
\;\;\;\;2 \cdot \mathsf{fma}\left(t, z, y \cdot x\right)\\
\end{array}
\end{array}
if (*.f64 (*.f64 (+.f64 a (*.f64 b c)) c) i) < -1e-79 or 5e4 < (*.f64 (*.f64 (+.f64 a (*.f64 b c)) c) i) Initial program 87.8%
Taylor expanded in x around 0
lower--.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f6482.5
Applied rewrites82.5%
if -1e-79 < (*.f64 (*.f64 (+.f64 a (*.f64 b c)) c) i) < 5e4Initial program 98.7%
Taylor expanded in c around 0
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6494.2
Applied rewrites94.2%
Final simplification86.2%
(FPCore (x y z t a b c i)
:precision binary64
(let* ((t_1 (* (* (+ a (* b c)) c) i)))
(if (or (<= t_1 -1e+105) (not (<= t_1 2e+237)))
(* -2.0 (* (* (fma c b a) i) c))
(* 2.0 (fma t z (* y x))))))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double t_1 = ((a + (b * c)) * c) * i;
double tmp;
if ((t_1 <= -1e+105) || !(t_1 <= 2e+237)) {
tmp = -2.0 * ((fma(c, b, a) * i) * c);
} else {
tmp = 2.0 * fma(t, z, (y * x));
}
return tmp;
}
function code(x, y, z, t, a, b, c, i) t_1 = Float64(Float64(Float64(a + Float64(b * c)) * c) * i) tmp = 0.0 if ((t_1 <= -1e+105) || !(t_1 <= 2e+237)) tmp = Float64(-2.0 * Float64(Float64(fma(c, b, a) * i) * c)); else tmp = Float64(2.0 * fma(t, z, Float64(y * x))); end return tmp end
code[x_, y_, z_, t_, a_, b_, c_, i_] := Block[{t$95$1 = N[(N[(N[(a + N[(b * c), $MachinePrecision]), $MachinePrecision] * c), $MachinePrecision] * i), $MachinePrecision]}, If[Or[LessEqual[t$95$1, -1e+105], N[Not[LessEqual[t$95$1, 2e+237]], $MachinePrecision]], N[(-2.0 * N[(N[(N[(c * b + a), $MachinePrecision] * i), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision], N[(2.0 * N[(t * z + N[(y * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left(\left(a + b \cdot c\right) \cdot c\right) \cdot i\\
\mathbf{if}\;t\_1 \leq -1 \cdot 10^{+105} \lor \neg \left(t\_1 \leq 2 \cdot 10^{+237}\right):\\
\;\;\;\;-2 \cdot \left(\left(\mathsf{fma}\left(c, b, a\right) \cdot i\right) \cdot c\right)\\
\mathbf{else}:\\
\;\;\;\;2 \cdot \mathsf{fma}\left(t, z, y \cdot x\right)\\
\end{array}
\end{array}
if (*.f64 (*.f64 (+.f64 a (*.f64 b c)) c) i) < -9.9999999999999994e104 or 1.99999999999999988e237 < (*.f64 (*.f64 (+.f64 a (*.f64 b c)) c) i) Initial program 83.8%
Taylor expanded in i around inf
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f6485.5
Applied rewrites85.5%
if -9.9999999999999994e104 < (*.f64 (*.f64 (+.f64 a (*.f64 b c)) c) i) < 1.99999999999999988e237Initial program 99.1%
Taylor expanded in c around 0
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6481.2
Applied rewrites81.2%
Final simplification83.4%
(FPCore (x y z t a b c i)
:precision binary64
(let* ((t_1 (* (+ a (* b c)) c)))
(if (or (<= t_1 -4e+123) (not (<= t_1 2e+180)))
(* 2.0 (- (* t z) (* (* (fma c b a) i) c)))
(* 2.0 (- (fma t z (* y x)) (* (* i c) a))))))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double t_1 = (a + (b * c)) * c;
double tmp;
if ((t_1 <= -4e+123) || !(t_1 <= 2e+180)) {
tmp = 2.0 * ((t * z) - ((fma(c, b, a) * i) * c));
} else {
tmp = 2.0 * (fma(t, z, (y * x)) - ((i * c) * a));
}
return tmp;
}
function code(x, y, z, t, a, b, c, i) t_1 = Float64(Float64(a + Float64(b * c)) * c) tmp = 0.0 if ((t_1 <= -4e+123) || !(t_1 <= 2e+180)) tmp = Float64(2.0 * Float64(Float64(t * z) - Float64(Float64(fma(c, b, a) * i) * c))); else tmp = Float64(2.0 * Float64(fma(t, z, Float64(y * x)) - Float64(Float64(i * c) * a))); end return tmp end
code[x_, y_, z_, t_, a_, b_, c_, i_] := Block[{t$95$1 = N[(N[(a + N[(b * c), $MachinePrecision]), $MachinePrecision] * c), $MachinePrecision]}, If[Or[LessEqual[t$95$1, -4e+123], N[Not[LessEqual[t$95$1, 2e+180]], $MachinePrecision]], N[(2.0 * N[(N[(t * z), $MachinePrecision] - N[(N[(N[(c * b + a), $MachinePrecision] * i), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(2.0 * N[(N[(t * z + N[(y * x), $MachinePrecision]), $MachinePrecision] - N[(N[(i * c), $MachinePrecision] * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left(a + b \cdot c\right) \cdot c\\
\mathbf{if}\;t\_1 \leq -4 \cdot 10^{+123} \lor \neg \left(t\_1 \leq 2 \cdot 10^{+180}\right):\\
\;\;\;\;2 \cdot \left(t \cdot z - \left(\mathsf{fma}\left(c, b, a\right) \cdot i\right) \cdot c\right)\\
\mathbf{else}:\\
\;\;\;\;2 \cdot \left(\mathsf{fma}\left(t, z, y \cdot x\right) - \left(i \cdot c\right) \cdot a\right)\\
\end{array}
\end{array}
if (*.f64 (+.f64 a (*.f64 b c)) c) < -3.99999999999999991e123 or 2e180 < (*.f64 (+.f64 a (*.f64 b c)) c) Initial program 83.1%
Taylor expanded in x around 0
lower--.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f6491.0
Applied rewrites91.0%
if -3.99999999999999991e123 < (*.f64 (+.f64 a (*.f64 b c)) c) < 2e180Initial program 99.2%
Taylor expanded in b around 0
lower--.f64N/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6494.0
Applied rewrites94.0%
Final simplification92.5%
(FPCore (x y z t a b c i)
:precision binary64
(let* ((t_1 (* (* (+ a (* b c)) c) i)))
(if (or (<= t_1 -2e+113) (not (<= t_1 2e+237)))
(* (* (* i c) a) -2.0)
(* 2.0 (fma t z (* y x))))))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double t_1 = ((a + (b * c)) * c) * i;
double tmp;
if ((t_1 <= -2e+113) || !(t_1 <= 2e+237)) {
tmp = ((i * c) * a) * -2.0;
} else {
tmp = 2.0 * fma(t, z, (y * x));
}
return tmp;
}
function code(x, y, z, t, a, b, c, i) t_1 = Float64(Float64(Float64(a + Float64(b * c)) * c) * i) tmp = 0.0 if ((t_1 <= -2e+113) || !(t_1 <= 2e+237)) tmp = Float64(Float64(Float64(i * c) * a) * -2.0); else tmp = Float64(2.0 * fma(t, z, Float64(y * x))); end return tmp end
code[x_, y_, z_, t_, a_, b_, c_, i_] := Block[{t$95$1 = N[(N[(N[(a + N[(b * c), $MachinePrecision]), $MachinePrecision] * c), $MachinePrecision] * i), $MachinePrecision]}, If[Or[LessEqual[t$95$1, -2e+113], N[Not[LessEqual[t$95$1, 2e+237]], $MachinePrecision]], N[(N[(N[(i * c), $MachinePrecision] * a), $MachinePrecision] * -2.0), $MachinePrecision], N[(2.0 * N[(t * z + N[(y * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left(\left(a + b \cdot c\right) \cdot c\right) \cdot i\\
\mathbf{if}\;t\_1 \leq -2 \cdot 10^{+113} \lor \neg \left(t\_1 \leq 2 \cdot 10^{+237}\right):\\
\;\;\;\;\left(\left(i \cdot c\right) \cdot a\right) \cdot -2\\
\mathbf{else}:\\
\;\;\;\;2 \cdot \mathsf{fma}\left(t, z, y \cdot x\right)\\
\end{array}
\end{array}
if (*.f64 (*.f64 (+.f64 a (*.f64 b c)) c) i) < -2e113 or 1.99999999999999988e237 < (*.f64 (*.f64 (+.f64 a (*.f64 b c)) c) i) Initial program 83.6%
Taylor expanded in a around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6440.3
Applied rewrites40.3%
if -2e113 < (*.f64 (*.f64 (+.f64 a (*.f64 b c)) c) i) < 1.99999999999999988e237Initial program 99.1%
Taylor expanded in c around 0
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6480.7
Applied rewrites80.7%
Final simplification60.2%
(FPCore (x y z t a b c i)
:precision binary64
(let* ((t_1 (* (* (+ a (* b c)) c) i)))
(if (or (<= t_1 -2e+113) (not (<= t_1 1e+68)))
(* (* (* i c) a) -2.0)
(* 2.0 (* t z)))))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double t_1 = ((a + (b * c)) * c) * i;
double tmp;
if ((t_1 <= -2e+113) || !(t_1 <= 1e+68)) {
tmp = ((i * c) * a) * -2.0;
} else {
tmp = 2.0 * (t * z);
}
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, b, c, i)
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), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: i
real(8) :: t_1
real(8) :: tmp
t_1 = ((a + (b * c)) * c) * i
if ((t_1 <= (-2d+113)) .or. (.not. (t_1 <= 1d+68))) then
tmp = ((i * c) * a) * (-2.0d0)
else
tmp = 2.0d0 * (t * z)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double t_1 = ((a + (b * c)) * c) * i;
double tmp;
if ((t_1 <= -2e+113) || !(t_1 <= 1e+68)) {
tmp = ((i * c) * a) * -2.0;
} else {
tmp = 2.0 * (t * z);
}
return tmp;
}
def code(x, y, z, t, a, b, c, i): t_1 = ((a + (b * c)) * c) * i tmp = 0 if (t_1 <= -2e+113) or not (t_1 <= 1e+68): tmp = ((i * c) * a) * -2.0 else: tmp = 2.0 * (t * z) return tmp
function code(x, y, z, t, a, b, c, i) t_1 = Float64(Float64(Float64(a + Float64(b * c)) * c) * i) tmp = 0.0 if ((t_1 <= -2e+113) || !(t_1 <= 1e+68)) tmp = Float64(Float64(Float64(i * c) * a) * -2.0); else tmp = Float64(2.0 * Float64(t * z)); end return tmp end
function tmp_2 = code(x, y, z, t, a, b, c, i) t_1 = ((a + (b * c)) * c) * i; tmp = 0.0; if ((t_1 <= -2e+113) || ~((t_1 <= 1e+68))) tmp = ((i * c) * a) * -2.0; else tmp = 2.0 * (t * z); end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_, c_, i_] := Block[{t$95$1 = N[(N[(N[(a + N[(b * c), $MachinePrecision]), $MachinePrecision] * c), $MachinePrecision] * i), $MachinePrecision]}, If[Or[LessEqual[t$95$1, -2e+113], N[Not[LessEqual[t$95$1, 1e+68]], $MachinePrecision]], N[(N[(N[(i * c), $MachinePrecision] * a), $MachinePrecision] * -2.0), $MachinePrecision], N[(2.0 * N[(t * z), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left(\left(a + b \cdot c\right) \cdot c\right) \cdot i\\
\mathbf{if}\;t\_1 \leq -2 \cdot 10^{+113} \lor \neg \left(t\_1 \leq 10^{+68}\right):\\
\;\;\;\;\left(\left(i \cdot c\right) \cdot a\right) \cdot -2\\
\mathbf{else}:\\
\;\;\;\;2 \cdot \left(t \cdot z\right)\\
\end{array}
\end{array}
if (*.f64 (*.f64 (+.f64 a (*.f64 b c)) c) i) < -2e113 or 9.99999999999999953e67 < (*.f64 (*.f64 (+.f64 a (*.f64 b c)) c) i) Initial program 85.6%
Taylor expanded in a around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6440.4
Applied rewrites40.4%
if -2e113 < (*.f64 (*.f64 (+.f64 a (*.f64 b c)) c) i) < 9.99999999999999953e67Initial program 99.0%
Taylor expanded in z around inf
lower-*.f6453.3
Applied rewrites53.3%
Final simplification45.8%
(FPCore (x y z t a b c i)
:precision binary64
(let* ((t_1 (* (* (+ a (* b c)) c) i)))
(if (or (<= t_1 -2e+113) (not (<= t_1 0.01)))
(* (* (* a c) i) -2.0)
(* 2.0 (* t z)))))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double t_1 = ((a + (b * c)) * c) * i;
double tmp;
if ((t_1 <= -2e+113) || !(t_1 <= 0.01)) {
tmp = ((a * c) * i) * -2.0;
} else {
tmp = 2.0 * (t * z);
}
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, b, c, i)
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), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: i
real(8) :: t_1
real(8) :: tmp
t_1 = ((a + (b * c)) * c) * i
if ((t_1 <= (-2d+113)) .or. (.not. (t_1 <= 0.01d0))) then
tmp = ((a * c) * i) * (-2.0d0)
else
tmp = 2.0d0 * (t * z)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double t_1 = ((a + (b * c)) * c) * i;
double tmp;
if ((t_1 <= -2e+113) || !(t_1 <= 0.01)) {
tmp = ((a * c) * i) * -2.0;
} else {
tmp = 2.0 * (t * z);
}
return tmp;
}
def code(x, y, z, t, a, b, c, i): t_1 = ((a + (b * c)) * c) * i tmp = 0 if (t_1 <= -2e+113) or not (t_1 <= 0.01): tmp = ((a * c) * i) * -2.0 else: tmp = 2.0 * (t * z) return tmp
function code(x, y, z, t, a, b, c, i) t_1 = Float64(Float64(Float64(a + Float64(b * c)) * c) * i) tmp = 0.0 if ((t_1 <= -2e+113) || !(t_1 <= 0.01)) tmp = Float64(Float64(Float64(a * c) * i) * -2.0); else tmp = Float64(2.0 * Float64(t * z)); end return tmp end
function tmp_2 = code(x, y, z, t, a, b, c, i) t_1 = ((a + (b * c)) * c) * i; tmp = 0.0; if ((t_1 <= -2e+113) || ~((t_1 <= 0.01))) tmp = ((a * c) * i) * -2.0; else tmp = 2.0 * (t * z); end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_, c_, i_] := Block[{t$95$1 = N[(N[(N[(a + N[(b * c), $MachinePrecision]), $MachinePrecision] * c), $MachinePrecision] * i), $MachinePrecision]}, If[Or[LessEqual[t$95$1, -2e+113], N[Not[LessEqual[t$95$1, 0.01]], $MachinePrecision]], N[(N[(N[(a * c), $MachinePrecision] * i), $MachinePrecision] * -2.0), $MachinePrecision], N[(2.0 * N[(t * z), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left(\left(a + b \cdot c\right) \cdot c\right) \cdot i\\
\mathbf{if}\;t\_1 \leq -2 \cdot 10^{+113} \lor \neg \left(t\_1 \leq 0.01\right):\\
\;\;\;\;\left(\left(a \cdot c\right) \cdot i\right) \cdot -2\\
\mathbf{else}:\\
\;\;\;\;2 \cdot \left(t \cdot z\right)\\
\end{array}
\end{array}
if (*.f64 (*.f64 (+.f64 a (*.f64 b c)) c) i) < -2e113 or 0.0100000000000000002 < (*.f64 (*.f64 (+.f64 a (*.f64 b c)) c) i) Initial program 85.9%
Taylor expanded in a around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6440.0
Applied rewrites40.0%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f6438.2
Applied rewrites38.2%
if -2e113 < (*.f64 (*.f64 (+.f64 a (*.f64 b c)) c) i) < 0.0100000000000000002Initial program 99.0%
Taylor expanded in z around inf
lower-*.f6454.3
Applied rewrites54.3%
Final simplification44.7%
(FPCore (x y z t a b c i) :precision binary64 (if (or (<= (* x y) -1e+169) (not (<= (* x y) 5e+201))) (* 2.0 (* y x)) (* 2.0 (* t z))))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double tmp;
if (((x * y) <= -1e+169) || !((x * y) <= 5e+201)) {
tmp = 2.0 * (y * x);
} else {
tmp = 2.0 * (t * z);
}
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, b, c, i)
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), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: i
real(8) :: tmp
if (((x * y) <= (-1d+169)) .or. (.not. ((x * y) <= 5d+201))) then
tmp = 2.0d0 * (y * x)
else
tmp = 2.0d0 * (t * z)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double tmp;
if (((x * y) <= -1e+169) || !((x * y) <= 5e+201)) {
tmp = 2.0 * (y * x);
} else {
tmp = 2.0 * (t * z);
}
return tmp;
}
def code(x, y, z, t, a, b, c, i): tmp = 0 if ((x * y) <= -1e+169) or not ((x * y) <= 5e+201): tmp = 2.0 * (y * x) else: tmp = 2.0 * (t * z) return tmp
function code(x, y, z, t, a, b, c, i) tmp = 0.0 if ((Float64(x * y) <= -1e+169) || !(Float64(x * y) <= 5e+201)) tmp = Float64(2.0 * Float64(y * x)); else tmp = Float64(2.0 * Float64(t * z)); end return tmp end
function tmp_2 = code(x, y, z, t, a, b, c, i) tmp = 0.0; if (((x * y) <= -1e+169) || ~(((x * y) <= 5e+201))) tmp = 2.0 * (y * x); else tmp = 2.0 * (t * z); end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_, c_, i_] := If[Or[LessEqual[N[(x * y), $MachinePrecision], -1e+169], N[Not[LessEqual[N[(x * y), $MachinePrecision], 5e+201]], $MachinePrecision]], N[(2.0 * N[(y * x), $MachinePrecision]), $MachinePrecision], N[(2.0 * N[(t * z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \cdot y \leq -1 \cdot 10^{+169} \lor \neg \left(x \cdot y \leq 5 \cdot 10^{+201}\right):\\
\;\;\;\;2 \cdot \left(y \cdot x\right)\\
\mathbf{else}:\\
\;\;\;\;2 \cdot \left(t \cdot z\right)\\
\end{array}
\end{array}
if (*.f64 x y) < -9.99999999999999934e168 or 4.9999999999999995e201 < (*.f64 x y) Initial program 86.8%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f6467.5
Applied rewrites67.5%
if -9.99999999999999934e168 < (*.f64 x y) < 4.9999999999999995e201Initial program 92.6%
Taylor expanded in z around inf
lower-*.f6436.4
Applied rewrites36.4%
Final simplification43.7%
(FPCore (x y z t a b c i) :precision binary64 (* 2.0 (* t z)))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
return 2.0 * (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, a, b, c, i)
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), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: i
code = 2.0d0 * (t * z)
end function
public static double code(double x, double y, double z, double t, double a, double b, double c, double i) {
return 2.0 * (t * z);
}
def code(x, y, z, t, a, b, c, i): return 2.0 * (t * z)
function code(x, y, z, t, a, b, c, i) return Float64(2.0 * Float64(t * z)) end
function tmp = code(x, y, z, t, a, b, c, i) tmp = 2.0 * (t * z); end
code[x_, y_, z_, t_, a_, b_, c_, i_] := N[(2.0 * N[(t * z), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
2 \cdot \left(t \cdot z\right)
\end{array}
Initial program 91.2%
Taylor expanded in z around inf
lower-*.f6430.7
Applied rewrites30.7%
herbie shell --seed 2025085
(FPCore (x y z t a b c i)
:name "Diagrams.ThreeD.Shapes:frustum from diagrams-lib-1.3.0.3, A"
:precision binary64
:alt
(! :herbie-platform default (* 2 (- (+ (* x y) (* z t)) (* (+ a (* b c)) (* c i)))))
(* 2.0 (- (+ (* x y) (* z t)) (* (* (+ a (* b c)) c) i))))