
(FPCore (x y z t a b) :precision binary64 (+ (+ (+ x (* y z)) (* t a)) (* (* a z) b)))
double code(double x, double y, double z, double t, double a, double b) {
return ((x + (y * z)) + (t * a)) + ((a * z) * b);
}
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)
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
code = ((x + (y * z)) + (t * a)) + ((a * z) * b)
end function
public static double code(double x, double y, double z, double t, double a, double b) {
return ((x + (y * z)) + (t * a)) + ((a * z) * b);
}
def code(x, y, z, t, a, b): return ((x + (y * z)) + (t * a)) + ((a * z) * b)
function code(x, y, z, t, a, b) return Float64(Float64(Float64(x + Float64(y * z)) + Float64(t * a)) + Float64(Float64(a * z) * b)) end
function tmp = code(x, y, z, t, a, b) tmp = ((x + (y * z)) + (t * a)) + ((a * z) * b); end
code[x_, y_, z_, t_, a_, b_] := N[(N[(N[(x + N[(y * z), $MachinePrecision]), $MachinePrecision] + N[(t * a), $MachinePrecision]), $MachinePrecision] + N[(N[(a * z), $MachinePrecision] * b), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(x + y \cdot z\right) + t \cdot a\right) + \left(a \cdot z\right) \cdot b
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 13 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z t a b) :precision binary64 (+ (+ (+ x (* y z)) (* t a)) (* (* a z) b)))
double code(double x, double y, double z, double t, double a, double b) {
return ((x + (y * z)) + (t * a)) + ((a * z) * b);
}
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)
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
code = ((x + (y * z)) + (t * a)) + ((a * z) * b)
end function
public static double code(double x, double y, double z, double t, double a, double b) {
return ((x + (y * z)) + (t * a)) + ((a * z) * b);
}
def code(x, y, z, t, a, b): return ((x + (y * z)) + (t * a)) + ((a * z) * b)
function code(x, y, z, t, a, b) return Float64(Float64(Float64(x + Float64(y * z)) + Float64(t * a)) + Float64(Float64(a * z) * b)) end
function tmp = code(x, y, z, t, a, b) tmp = ((x + (y * z)) + (t * a)) + ((a * z) * b); end
code[x_, y_, z_, t_, a_, b_] := N[(N[(N[(x + N[(y * z), $MachinePrecision]), $MachinePrecision] + N[(t * a), $MachinePrecision]), $MachinePrecision] + N[(N[(a * z), $MachinePrecision] * b), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(x + y \cdot z\right) + t \cdot a\right) + \left(a \cdot z\right) \cdot b
\end{array}
(FPCore (x y z t a b) :precision binary64 (if (or (<= z -1.9e+189) (not (<= z 1.35e+140))) (fma (fma b a y) z x) (fma a (fma b z t) (fma z y x))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if ((z <= -1.9e+189) || !(z <= 1.35e+140)) {
tmp = fma(fma(b, a, y), z, x);
} else {
tmp = fma(a, fma(b, z, t), fma(z, y, x));
}
return tmp;
}
function code(x, y, z, t, a, b) tmp = 0.0 if ((z <= -1.9e+189) || !(z <= 1.35e+140)) tmp = fma(fma(b, a, y), z, x); else tmp = fma(a, fma(b, z, t), fma(z, y, x)); end return tmp end
code[x_, y_, z_, t_, a_, b_] := If[Or[LessEqual[z, -1.9e+189], N[Not[LessEqual[z, 1.35e+140]], $MachinePrecision]], N[(N[(b * a + y), $MachinePrecision] * z + x), $MachinePrecision], N[(a * N[(b * z + t), $MachinePrecision] + N[(z * y + x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.9 \cdot 10^{+189} \lor \neg \left(z \leq 1.35 \cdot 10^{+140}\right):\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(b, a, y\right), z, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(a, \mathsf{fma}\left(b, z, t\right), \mathsf{fma}\left(z, y, x\right)\right)\\
\end{array}
\end{array}
if z < -1.8999999999999999e189 or 1.35000000000000009e140 < z Initial program 73.4%
Taylor expanded in t around 0
+-commutativeN/A
+-commutativeN/A
associate-*r*N/A
distribute-rgt-inN/A
*-commutativeN/A
lower-fma.f64N/A
remove-double-negN/A
mul-1-negN/A
distribute-lft-outN/A
+-commutativeN/A
distribute-neg-inN/A
mul-1-negN/A
remove-double-negN/A
distribute-lft-neg-inN/A
fp-cancel-sub-sign-invN/A
*-commutativeN/A
fp-cancel-sub-sign-invN/A
*-commutativeN/A
distribute-lft-neg-inN/A
*-commutativeN/A
mul-1-negN/A
remove-double-negN/A
lower-fma.f6496.4
Applied rewrites96.4%
if -1.8999999999999999e189 < z < 1.35000000000000009e140Initial program 95.3%
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
+-commutativeN/A
associate-+r+N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lift-*.f64N/A
*-commutativeN/A
distribute-lft-outN/A
lower-fma.f64N/A
*-commutativeN/A
lower-fma.f6498.5
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6498.5
Applied rewrites98.5%
Final simplification97.9%
(FPCore (x y z t a b)
:precision binary64
(let* ((t_1 (+ (+ (+ x (* y z)) (* t a)) (* (* a z) b))))
(if (or (<= t_1 (- INFINITY)) (not (<= t_1 5e+279)))
(* (fma b a y) z)
(fma y z x))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = ((x + (y * z)) + (t * a)) + ((a * z) * b);
double tmp;
if ((t_1 <= -((double) INFINITY)) || !(t_1 <= 5e+279)) {
tmp = fma(b, a, y) * z;
} else {
tmp = fma(y, z, x);
}
return tmp;
}
function code(x, y, z, t, a, b) t_1 = Float64(Float64(Float64(x + Float64(y * z)) + Float64(t * a)) + Float64(Float64(a * z) * b)) tmp = 0.0 if ((t_1 <= Float64(-Inf)) || !(t_1 <= 5e+279)) tmp = Float64(fma(b, a, y) * z); else tmp = fma(y, z, x); end return tmp end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(N[(N[(x + N[(y * z), $MachinePrecision]), $MachinePrecision] + N[(t * a), $MachinePrecision]), $MachinePrecision] + N[(N[(a * z), $MachinePrecision] * b), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t$95$1, (-Infinity)], N[Not[LessEqual[t$95$1, 5e+279]], $MachinePrecision]], N[(N[(b * a + y), $MachinePrecision] * z), $MachinePrecision], N[(y * z + x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left(\left(x + y \cdot z\right) + t \cdot a\right) + \left(a \cdot z\right) \cdot b\\
\mathbf{if}\;t\_1 \leq -\infty \lor \neg \left(t\_1 \leq 5 \cdot 10^{+279}\right):\\
\;\;\;\;\mathsf{fma}\left(b, a, y\right) \cdot z\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(y, z, x\right)\\
\end{array}
\end{array}
if (+.f64 (+.f64 (+.f64 x (*.f64 y z)) (*.f64 t a)) (*.f64 (*.f64 a z) b)) < -inf.0 or 5.0000000000000002e279 < (+.f64 (+.f64 (+.f64 x (*.f64 y z)) (*.f64 t a)) (*.f64 (*.f64 a z) b)) Initial program 72.9%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
remove-double-negN/A
mul-1-negN/A
distribute-lft-outN/A
+-commutativeN/A
distribute-neg-inN/A
mul-1-negN/A
remove-double-negN/A
distribute-lft-neg-inN/A
fp-cancel-sub-sign-invN/A
*-commutativeN/A
fp-cancel-sub-sign-invN/A
*-commutativeN/A
distribute-lft-neg-inN/A
*-commutativeN/A
mul-1-negN/A
remove-double-negN/A
lower-fma.f6475.5
Applied rewrites75.5%
if -inf.0 < (+.f64 (+.f64 (+.f64 x (*.f64 y z)) (*.f64 t a)) (*.f64 (*.f64 a z) b)) < 5.0000000000000002e279Initial program 99.9%
lift-+.f64N/A
lift-*.f64N/A
fp-cancel-sign-sub-invN/A
fp-cancel-sub-sign-invN/A
lift-+.f64N/A
lift-+.f64N/A
+-commutativeN/A
associate-+l+N/A
associate-+l+N/A
lift-*.f64N/A
*-commutativeN/A
remove-double-negN/A
lift-*.f64N/A
associate-+r+N/A
lower-fma.f64N/A
lower-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
Applied rewrites95.8%
Taylor expanded in z around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f6486.4
Applied rewrites86.4%
Taylor expanded in a around 0
+-commutativeN/A
lower-fma.f6461.7
Applied rewrites61.7%
Final simplification67.0%
(FPCore (x y z t a b) :precision binary64 (if (<= a -1.2e+224) (* (* z b) a) (if (<= a -7.5e+96) (* a t) (if (<= a 7e+152) (fma y z x) (* (* b a) z)))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (a <= -1.2e+224) {
tmp = (z * b) * a;
} else if (a <= -7.5e+96) {
tmp = a * t;
} else if (a <= 7e+152) {
tmp = fma(y, z, x);
} else {
tmp = (b * a) * z;
}
return tmp;
}
function code(x, y, z, t, a, b) tmp = 0.0 if (a <= -1.2e+224) tmp = Float64(Float64(z * b) * a); elseif (a <= -7.5e+96) tmp = Float64(a * t); elseif (a <= 7e+152) tmp = fma(y, z, x); else tmp = Float64(Float64(b * a) * z); end return tmp end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[a, -1.2e+224], N[(N[(z * b), $MachinePrecision] * a), $MachinePrecision], If[LessEqual[a, -7.5e+96], N[(a * t), $MachinePrecision], If[LessEqual[a, 7e+152], N[(y * z + x), $MachinePrecision], N[(N[(b * a), $MachinePrecision] * z), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -1.2 \cdot 10^{+224}:\\
\;\;\;\;\left(z \cdot b\right) \cdot a\\
\mathbf{elif}\;a \leq -7.5 \cdot 10^{+96}:\\
\;\;\;\;a \cdot t\\
\mathbf{elif}\;a \leq 7 \cdot 10^{+152}:\\
\;\;\;\;\mathsf{fma}\left(y, z, x\right)\\
\mathbf{else}:\\
\;\;\;\;\left(b \cdot a\right) \cdot z\\
\end{array}
\end{array}
if a < -1.2e224Initial program 51.2%
Taylor expanded in a around inf
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-fma.f6495.5
Applied rewrites95.5%
Taylor expanded in z around inf
Applied rewrites85.9%
if -1.2e224 < a < -7.4999999999999996e96Initial program 90.2%
Taylor expanded in t around inf
lower-*.f6451.6
Applied rewrites51.6%
if -7.4999999999999996e96 < a < 6.99999999999999963e152Initial program 96.5%
lift-+.f64N/A
lift-*.f64N/A
fp-cancel-sign-sub-invN/A
fp-cancel-sub-sign-invN/A
lift-+.f64N/A
lift-+.f64N/A
+-commutativeN/A
associate-+l+N/A
associate-+l+N/A
lift-*.f64N/A
*-commutativeN/A
remove-double-negN/A
lift-*.f64N/A
associate-+r+N/A
lower-fma.f64N/A
lower-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
Applied rewrites94.5%
Taylor expanded in z around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f6486.3
Applied rewrites86.3%
Taylor expanded in a around 0
+-commutativeN/A
lower-fma.f6465.2
Applied rewrites65.2%
if 6.99999999999999963e152 < a Initial program 79.8%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
remove-double-negN/A
mul-1-negN/A
distribute-lft-outN/A
+-commutativeN/A
distribute-neg-inN/A
mul-1-negN/A
remove-double-negN/A
distribute-lft-neg-inN/A
fp-cancel-sub-sign-invN/A
*-commutativeN/A
fp-cancel-sub-sign-invN/A
*-commutativeN/A
distribute-lft-neg-inN/A
*-commutativeN/A
mul-1-negN/A
remove-double-negN/A
lower-fma.f6459.5
Applied rewrites59.5%
Taylor expanded in y around 0
Applied rewrites54.9%
Final simplification64.0%
(FPCore (x y z t a b)
:precision binary64
(let* ((t_1 (* (* b a) z)))
(if (<= a -1.2e+224)
t_1
(if (<= a -7.5e+96) (* a t) (if (<= a 7e+152) (fma y z x) t_1)))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = (b * a) * z;
double tmp;
if (a <= -1.2e+224) {
tmp = t_1;
} else if (a <= -7.5e+96) {
tmp = a * t;
} else if (a <= 7e+152) {
tmp = fma(y, z, x);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a, b) t_1 = Float64(Float64(b * a) * z) tmp = 0.0 if (a <= -1.2e+224) tmp = t_1; elseif (a <= -7.5e+96) tmp = Float64(a * t); elseif (a <= 7e+152) tmp = fma(y, z, x); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(N[(b * a), $MachinePrecision] * z), $MachinePrecision]}, If[LessEqual[a, -1.2e+224], t$95$1, If[LessEqual[a, -7.5e+96], N[(a * t), $MachinePrecision], If[LessEqual[a, 7e+152], N[(y * z + x), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left(b \cdot a\right) \cdot z\\
\mathbf{if}\;a \leq -1.2 \cdot 10^{+224}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;a \leq -7.5 \cdot 10^{+96}:\\
\;\;\;\;a \cdot t\\
\mathbf{elif}\;a \leq 7 \cdot 10^{+152}:\\
\;\;\;\;\mathsf{fma}\left(y, z, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if a < -1.2e224 or 6.99999999999999963e152 < a Initial program 70.9%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
remove-double-negN/A
mul-1-negN/A
distribute-lft-outN/A
+-commutativeN/A
distribute-neg-inN/A
mul-1-negN/A
remove-double-negN/A
distribute-lft-neg-inN/A
fp-cancel-sub-sign-invN/A
*-commutativeN/A
fp-cancel-sub-sign-invN/A
*-commutativeN/A
distribute-lft-neg-inN/A
*-commutativeN/A
mul-1-negN/A
remove-double-negN/A
lower-fma.f6466.4
Applied rewrites66.4%
Taylor expanded in y around 0
Applied rewrites61.8%
if -1.2e224 < a < -7.4999999999999996e96Initial program 90.2%
Taylor expanded in t around inf
lower-*.f6451.6
Applied rewrites51.6%
if -7.4999999999999996e96 < a < 6.99999999999999963e152Initial program 96.5%
lift-+.f64N/A
lift-*.f64N/A
fp-cancel-sign-sub-invN/A
fp-cancel-sub-sign-invN/A
lift-+.f64N/A
lift-+.f64N/A
+-commutativeN/A
associate-+l+N/A
associate-+l+N/A
lift-*.f64N/A
*-commutativeN/A
remove-double-negN/A
lift-*.f64N/A
associate-+r+N/A
lower-fma.f64N/A
lower-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
Applied rewrites94.5%
Taylor expanded in z around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f6486.3
Applied rewrites86.3%
Taylor expanded in a around 0
+-commutativeN/A
lower-fma.f6465.2
Applied rewrites65.2%
Final simplification63.3%
(FPCore (x y z t a b) :precision binary64 (if (or (<= y -2.35e+47) (not (<= y 1.95e-16))) (fma z y (fma t a x)) (fma (fma b z t) a x)))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if ((y <= -2.35e+47) || !(y <= 1.95e-16)) {
tmp = fma(z, y, fma(t, a, x));
} else {
tmp = fma(fma(b, z, t), a, x);
}
return tmp;
}
function code(x, y, z, t, a, b) tmp = 0.0 if ((y <= -2.35e+47) || !(y <= 1.95e-16)) tmp = fma(z, y, fma(t, a, x)); else tmp = fma(fma(b, z, t), a, x); end return tmp end
code[x_, y_, z_, t_, a_, b_] := If[Or[LessEqual[y, -2.35e+47], N[Not[LessEqual[y, 1.95e-16]], $MachinePrecision]], N[(z * y + N[(t * a + x), $MachinePrecision]), $MachinePrecision], N[(N[(b * z + t), $MachinePrecision] * a + x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.35 \cdot 10^{+47} \lor \neg \left(y \leq 1.95 \cdot 10^{-16}\right):\\
\;\;\;\;\mathsf{fma}\left(z, y, \mathsf{fma}\left(t, a, x\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(b, z, t\right), a, x\right)\\
\end{array}
\end{array}
if y < -2.34999999999999982e47 or 1.94999999999999989e-16 < y Initial program 86.7%
lift-+.f64N/A
lift-*.f64N/A
fp-cancel-sign-sub-invN/A
fp-cancel-sub-sign-invN/A
lift-+.f64N/A
lift-+.f64N/A
+-commutativeN/A
associate-+l+N/A
associate-+l+N/A
lift-*.f64N/A
*-commutativeN/A
remove-double-negN/A
lift-*.f64N/A
associate-+r+N/A
lower-fma.f64N/A
lower-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
Applied rewrites96.1%
Taylor expanded in z around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f6487.6
Applied rewrites87.6%
if -2.34999999999999982e47 < y < 1.94999999999999989e-16Initial program 92.4%
Taylor expanded in y around 0
distribute-lft-inN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f6493.2
Applied rewrites93.2%
Final simplification90.4%
(FPCore (x y z t a b) :precision binary64 (if (or (<= z -14000000.0) (not (<= z 9.2e+82))) (fma (fma b a y) z x) (fma (fma b z t) a x)))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if ((z <= -14000000.0) || !(z <= 9.2e+82)) {
tmp = fma(fma(b, a, y), z, x);
} else {
tmp = fma(fma(b, z, t), a, x);
}
return tmp;
}
function code(x, y, z, t, a, b) tmp = 0.0 if ((z <= -14000000.0) || !(z <= 9.2e+82)) tmp = fma(fma(b, a, y), z, x); else tmp = fma(fma(b, z, t), a, x); end return tmp end
code[x_, y_, z_, t_, a_, b_] := If[Or[LessEqual[z, -14000000.0], N[Not[LessEqual[z, 9.2e+82]], $MachinePrecision]], N[(N[(b * a + y), $MachinePrecision] * z + x), $MachinePrecision], N[(N[(b * z + t), $MachinePrecision] * a + x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -14000000 \lor \neg \left(z \leq 9.2 \cdot 10^{+82}\right):\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(b, a, y\right), z, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(b, z, t\right), a, x\right)\\
\end{array}
\end{array}
if z < -1.4e7 or 9.19999999999999953e82 < z Initial program 78.0%
Taylor expanded in t around 0
+-commutativeN/A
+-commutativeN/A
associate-*r*N/A
distribute-rgt-inN/A
*-commutativeN/A
lower-fma.f64N/A
remove-double-negN/A
mul-1-negN/A
distribute-lft-outN/A
+-commutativeN/A
distribute-neg-inN/A
mul-1-negN/A
remove-double-negN/A
distribute-lft-neg-inN/A
fp-cancel-sub-sign-invN/A
*-commutativeN/A
fp-cancel-sub-sign-invN/A
*-commutativeN/A
distribute-lft-neg-inN/A
*-commutativeN/A
mul-1-negN/A
remove-double-negN/A
lower-fma.f6489.3
Applied rewrites89.3%
if -1.4e7 < z < 9.19999999999999953e82Initial program 98.6%
Taylor expanded in y around 0
distribute-lft-inN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f6485.7
Applied rewrites85.7%
Final simplification87.3%
(FPCore (x y z t a b) :precision binary64 (if (or (<= t -5.8e+105) (not (<= t 1.4e+21))) (fma z y (* t a)) (fma (fma b a y) z x)))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if ((t <= -5.8e+105) || !(t <= 1.4e+21)) {
tmp = fma(z, y, (t * a));
} else {
tmp = fma(fma(b, a, y), z, x);
}
return tmp;
}
function code(x, y, z, t, a, b) tmp = 0.0 if ((t <= -5.8e+105) || !(t <= 1.4e+21)) tmp = fma(z, y, Float64(t * a)); else tmp = fma(fma(b, a, y), z, x); end return tmp end
code[x_, y_, z_, t_, a_, b_] := If[Or[LessEqual[t, -5.8e+105], N[Not[LessEqual[t, 1.4e+21]], $MachinePrecision]], N[(z * y + N[(t * a), $MachinePrecision]), $MachinePrecision], N[(N[(b * a + y), $MachinePrecision] * z + x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -5.8 \cdot 10^{+105} \lor \neg \left(t \leq 1.4 \cdot 10^{+21}\right):\\
\;\;\;\;\mathsf{fma}\left(z, y, t \cdot a\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(b, a, y\right), z, x\right)\\
\end{array}
\end{array}
if t < -5.8000000000000002e105 or 1.4e21 < t Initial program 83.5%
lift-+.f64N/A
lift-*.f64N/A
fp-cancel-sign-sub-invN/A
fp-cancel-sub-sign-invN/A
lift-+.f64N/A
lift-+.f64N/A
+-commutativeN/A
associate-+l+N/A
associate-+l+N/A
lift-*.f64N/A
*-commutativeN/A
remove-double-negN/A
lift-*.f64N/A
associate-+r+N/A
lower-fma.f64N/A
lower-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
Applied rewrites96.3%
Taylor expanded in z around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f6488.2
Applied rewrites88.2%
Taylor expanded in x around 0
Applied rewrites76.0%
if -5.8000000000000002e105 < t < 1.4e21Initial program 93.7%
Taylor expanded in t around 0
+-commutativeN/A
+-commutativeN/A
associate-*r*N/A
distribute-rgt-inN/A
*-commutativeN/A
lower-fma.f64N/A
remove-double-negN/A
mul-1-negN/A
distribute-lft-outN/A
+-commutativeN/A
distribute-neg-inN/A
mul-1-negN/A
remove-double-negN/A
distribute-lft-neg-inN/A
fp-cancel-sub-sign-invN/A
*-commutativeN/A
fp-cancel-sub-sign-invN/A
*-commutativeN/A
distribute-lft-neg-inN/A
*-commutativeN/A
mul-1-negN/A
remove-double-negN/A
lower-fma.f6488.6
Applied rewrites88.6%
Final simplification83.6%
(FPCore (x y z t a b) :precision binary64 (if (or (<= a -1.45e-19) (not (<= a 1.22e+51))) (* (fma b z t) a) (fma y z x)))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if ((a <= -1.45e-19) || !(a <= 1.22e+51)) {
tmp = fma(b, z, t) * a;
} else {
tmp = fma(y, z, x);
}
return tmp;
}
function code(x, y, z, t, a, b) tmp = 0.0 if ((a <= -1.45e-19) || !(a <= 1.22e+51)) tmp = Float64(fma(b, z, t) * a); else tmp = fma(y, z, x); end return tmp end
code[x_, y_, z_, t_, a_, b_] := If[Or[LessEqual[a, -1.45e-19], N[Not[LessEqual[a, 1.22e+51]], $MachinePrecision]], N[(N[(b * z + t), $MachinePrecision] * a), $MachinePrecision], N[(y * z + x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -1.45 \cdot 10^{-19} \lor \neg \left(a \leq 1.22 \cdot 10^{+51}\right):\\
\;\;\;\;\mathsf{fma}\left(b, z, t\right) \cdot a\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(y, z, x\right)\\
\end{array}
\end{array}
if a < -1.45e-19 or 1.22000000000000005e51 < a Initial program 81.0%
Taylor expanded in a around inf
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-fma.f6477.5
Applied rewrites77.5%
if -1.45e-19 < a < 1.22000000000000005e51Initial program 98.4%
lift-+.f64N/A
lift-*.f64N/A
fp-cancel-sign-sub-invN/A
fp-cancel-sub-sign-invN/A
lift-+.f64N/A
lift-+.f64N/A
+-commutativeN/A
associate-+l+N/A
associate-+l+N/A
lift-*.f64N/A
*-commutativeN/A
remove-double-negN/A
lift-*.f64N/A
associate-+r+N/A
lower-fma.f64N/A
lower-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
Applied rewrites93.2%
Taylor expanded in z around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f6489.0
Applied rewrites89.0%
Taylor expanded in a around 0
+-commutativeN/A
lower-fma.f6472.9
Applied rewrites72.9%
Final simplification75.2%
(FPCore (x y z t a b) :precision binary64 (if (or (<= a -4.5e+99) (not (<= a 3.5e+152))) (* (* a z) b) (fma y z x)))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if ((a <= -4.5e+99) || !(a <= 3.5e+152)) {
tmp = (a * z) * b;
} else {
tmp = fma(y, z, x);
}
return tmp;
}
function code(x, y, z, t, a, b) tmp = 0.0 if ((a <= -4.5e+99) || !(a <= 3.5e+152)) tmp = Float64(Float64(a * z) * b); else tmp = fma(y, z, x); end return tmp end
code[x_, y_, z_, t_, a_, b_] := If[Or[LessEqual[a, -4.5e+99], N[Not[LessEqual[a, 3.5e+152]], $MachinePrecision]], N[(N[(a * z), $MachinePrecision] * b), $MachinePrecision], N[(y * z + x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -4.5 \cdot 10^{+99} \lor \neg \left(a \leq 3.5 \cdot 10^{+152}\right):\\
\;\;\;\;\left(a \cdot z\right) \cdot b\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(y, z, x\right)\\
\end{array}
\end{array}
if a < -4.5e99 or 3.49999999999999981e152 < a Initial program 75.2%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
remove-double-negN/A
mul-1-negN/A
distribute-lft-outN/A
+-commutativeN/A
distribute-neg-inN/A
mul-1-negN/A
remove-double-negN/A
distribute-lft-neg-inN/A
fp-cancel-sub-sign-invN/A
*-commutativeN/A
fp-cancel-sub-sign-invN/A
*-commutativeN/A
distribute-lft-neg-inN/A
*-commutativeN/A
mul-1-negN/A
remove-double-negN/A
lower-fma.f6461.2
Applied rewrites61.2%
Taylor expanded in y around 0
Applied rewrites52.9%
if -4.5e99 < a < 3.49999999999999981e152Initial program 96.5%
lift-+.f64N/A
lift-*.f64N/A
fp-cancel-sign-sub-invN/A
fp-cancel-sub-sign-invN/A
lift-+.f64N/A
lift-+.f64N/A
+-commutativeN/A
associate-+l+N/A
associate-+l+N/A
lift-*.f64N/A
*-commutativeN/A
remove-double-negN/A
lift-*.f64N/A
associate-+r+N/A
lower-fma.f64N/A
lower-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
Applied rewrites94.5%
Taylor expanded in z around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f6486.3
Applied rewrites86.3%
Taylor expanded in a around 0
+-commutativeN/A
lower-fma.f6464.9
Applied rewrites64.9%
Final simplification61.0%
(FPCore (x y z t a b) :precision binary64 (fma z y (+ x (* a (fma b z t)))))
double code(double x, double y, double z, double t, double a, double b) {
return fma(z, y, (x + (a * fma(b, z, t))));
}
function code(x, y, z, t, a, b) return fma(z, y, Float64(x + Float64(a * fma(b, z, t)))) end
code[x_, y_, z_, t_, a_, b_] := N[(z * y + N[(x + N[(a * N[(b * z + t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(z, y, x + a \cdot \mathsf{fma}\left(b, z, t\right)\right)
\end{array}
Initial program 89.6%
lift-+.f64N/A
lift-*.f64N/A
fp-cancel-sign-sub-invN/A
fp-cancel-sub-sign-invN/A
lift-+.f64N/A
lift-+.f64N/A
+-commutativeN/A
associate-+l+N/A
associate-+l+N/A
lift-*.f64N/A
*-commutativeN/A
remove-double-negN/A
lift-*.f64N/A
associate-+r+N/A
lower-fma.f64N/A
lower-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
Applied rewrites95.9%
(FPCore (x y z t a b) :precision binary64 (if (or (<= t -6.5e+167) (not (<= t 1.3e+109))) (* a t) (fma y z x)))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if ((t <= -6.5e+167) || !(t <= 1.3e+109)) {
tmp = a * t;
} else {
tmp = fma(y, z, x);
}
return tmp;
}
function code(x, y, z, t, a, b) tmp = 0.0 if ((t <= -6.5e+167) || !(t <= 1.3e+109)) tmp = Float64(a * t); else tmp = fma(y, z, x); end return tmp end
code[x_, y_, z_, t_, a_, b_] := If[Or[LessEqual[t, -6.5e+167], N[Not[LessEqual[t, 1.3e+109]], $MachinePrecision]], N[(a * t), $MachinePrecision], N[(y * z + x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -6.5 \cdot 10^{+167} \lor \neg \left(t \leq 1.3 \cdot 10^{+109}\right):\\
\;\;\;\;a \cdot t\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(y, z, x\right)\\
\end{array}
\end{array}
if t < -6.5e167 or 1.2999999999999999e109 < t Initial program 82.6%
Taylor expanded in t around inf
lower-*.f6463.4
Applied rewrites63.4%
if -6.5e167 < t < 1.2999999999999999e109Initial program 92.1%
lift-+.f64N/A
lift-*.f64N/A
fp-cancel-sign-sub-invN/A
fp-cancel-sub-sign-invN/A
lift-+.f64N/A
lift-+.f64N/A
+-commutativeN/A
associate-+l+N/A
associate-+l+N/A
lift-*.f64N/A
*-commutativeN/A
remove-double-negN/A
lift-*.f64N/A
associate-+r+N/A
lower-fma.f64N/A
lower-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
Applied rewrites94.9%
Taylor expanded in z around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f6470.5
Applied rewrites70.5%
Taylor expanded in a around 0
+-commutativeN/A
lower-fma.f6456.5
Applied rewrites56.5%
Final simplification58.4%
(FPCore (x y z t a b) :precision binary64 (if (or (<= y -1.8e+140) (not (<= y 0.75))) (* y z) (* a t)))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if ((y <= -1.8e+140) || !(y <= 0.75)) {
tmp = y * z;
} else {
tmp = 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, b)
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) :: tmp
if ((y <= (-1.8d+140)) .or. (.not. (y <= 0.75d0))) then
tmp = y * z
else
tmp = a * t
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if ((y <= -1.8e+140) || !(y <= 0.75)) {
tmp = y * z;
} else {
tmp = a * t;
}
return tmp;
}
def code(x, y, z, t, a, b): tmp = 0 if (y <= -1.8e+140) or not (y <= 0.75): tmp = y * z else: tmp = a * t return tmp
function code(x, y, z, t, a, b) tmp = 0.0 if ((y <= -1.8e+140) || !(y <= 0.75)) tmp = Float64(y * z); else tmp = Float64(a * t); end return tmp end
function tmp_2 = code(x, y, z, t, a, b) tmp = 0.0; if ((y <= -1.8e+140) || ~((y <= 0.75))) tmp = y * z; else tmp = a * t; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_] := If[Or[LessEqual[y, -1.8e+140], N[Not[LessEqual[y, 0.75]], $MachinePrecision]], N[(y * z), $MachinePrecision], N[(a * t), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.8 \cdot 10^{+140} \lor \neg \left(y \leq 0.75\right):\\
\;\;\;\;y \cdot z\\
\mathbf{else}:\\
\;\;\;\;a \cdot t\\
\end{array}
\end{array}
if y < -1.8e140 or 0.75 < y Initial program 87.5%
lift-+.f64N/A
lift-*.f64N/A
fp-cancel-sign-sub-invN/A
fp-cancel-sub-sign-invN/A
lift-+.f64N/A
lift-+.f64N/A
+-commutativeN/A
associate-+l+N/A
associate-+l+N/A
lift-*.f64N/A
*-commutativeN/A
remove-double-negN/A
lift-*.f64N/A
associate-+r+N/A
lower-fma.f64N/A
lower-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
Applied rewrites96.8%
Taylor expanded in z around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f6489.5
Applied rewrites89.5%
Taylor expanded in y around inf
lower-*.f6453.3
Applied rewrites53.3%
if -1.8e140 < y < 0.75Initial program 90.8%
Taylor expanded in t around inf
lower-*.f6433.5
Applied rewrites33.5%
Final simplification40.8%
(FPCore (x y z t a b) :precision binary64 (* y z))
double code(double x, double y, double z, double t, double a, double b) {
return y * z;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z, t, a, b)
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
code = y * z
end function
public static double code(double x, double y, double z, double t, double a, double b) {
return y * z;
}
def code(x, y, z, t, a, b): return y * z
function code(x, y, z, t, a, b) return Float64(y * z) end
function tmp = code(x, y, z, t, a, b) tmp = y * z; end
code[x_, y_, z_, t_, a_, b_] := N[(y * z), $MachinePrecision]
\begin{array}{l}
\\
y \cdot z
\end{array}
Initial program 89.6%
lift-+.f64N/A
lift-*.f64N/A
fp-cancel-sign-sub-invN/A
fp-cancel-sub-sign-invN/A
lift-+.f64N/A
lift-+.f64N/A
+-commutativeN/A
associate-+l+N/A
associate-+l+N/A
lift-*.f64N/A
*-commutativeN/A
remove-double-negN/A
lift-*.f64N/A
associate-+r+N/A
lower-fma.f64N/A
lower-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
Applied rewrites95.9%
Taylor expanded in z around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f6475.6
Applied rewrites75.6%
Taylor expanded in y around inf
lower-*.f6426.3
Applied rewrites26.3%
(FPCore (x y z t a b)
:precision binary64
(let* ((t_1 (+ (* z (+ (* b a) y)) (+ x (* t a)))))
(if (< z -11820553527347888000.0)
t_1
(if (< z 4.7589743188364287e-122)
(+ (* (+ (* b z) t) a) (+ (* z y) x))
t_1))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = (z * ((b * a) + y)) + (x + (t * a));
double tmp;
if (z < -11820553527347888000.0) {
tmp = t_1;
} else if (z < 4.7589743188364287e-122) {
tmp = (((b * z) + t) * a) + ((z * y) + x);
} else {
tmp = t_1;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z, t, a, b)
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) :: t_1
real(8) :: tmp
t_1 = (z * ((b * a) + y)) + (x + (t * a))
if (z < (-11820553527347888000.0d0)) then
tmp = t_1
else if (z < 4.7589743188364287d-122) then
tmp = (((b * z) + t) * a) + ((z * y) + x)
else
tmp = t_1
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a, double b) {
double t_1 = (z * ((b * a) + y)) + (x + (t * a));
double tmp;
if (z < -11820553527347888000.0) {
tmp = t_1;
} else if (z < 4.7589743188364287e-122) {
tmp = (((b * z) + t) * a) + ((z * y) + x);
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z, t, a, b): t_1 = (z * ((b * a) + y)) + (x + (t * a)) tmp = 0 if z < -11820553527347888000.0: tmp = t_1 elif z < 4.7589743188364287e-122: tmp = (((b * z) + t) * a) + ((z * y) + x) else: tmp = t_1 return tmp
function code(x, y, z, t, a, b) t_1 = Float64(Float64(z * Float64(Float64(b * a) + y)) + Float64(x + Float64(t * a))) tmp = 0.0 if (z < -11820553527347888000.0) tmp = t_1; elseif (z < 4.7589743188364287e-122) tmp = Float64(Float64(Float64(Float64(b * z) + t) * a) + Float64(Float64(z * y) + x)); else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z, t, a, b) t_1 = (z * ((b * a) + y)) + (x + (t * a)); tmp = 0.0; if (z < -11820553527347888000.0) tmp = t_1; elseif (z < 4.7589743188364287e-122) tmp = (((b * z) + t) * a) + ((z * y) + x); else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(N[(z * N[(N[(b * a), $MachinePrecision] + y), $MachinePrecision]), $MachinePrecision] + N[(x + N[(t * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[Less[z, -11820553527347888000.0], t$95$1, If[Less[z, 4.7589743188364287e-122], N[(N[(N[(N[(b * z), $MachinePrecision] + t), $MachinePrecision] * a), $MachinePrecision] + N[(N[(z * y), $MachinePrecision] + x), $MachinePrecision]), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := z \cdot \left(b \cdot a + y\right) + \left(x + t \cdot a\right)\\
\mathbf{if}\;z < -11820553527347888000:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z < 4.7589743188364287 \cdot 10^{-122}:\\
\;\;\;\;\left(b \cdot z + t\right) \cdot a + \left(z \cdot y + x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
herbie shell --seed 2024358
(FPCore (x y z t a b)
:name "Graphics.Rasterific.CubicBezier:cachedBezierAt from Rasterific-0.6.1"
:precision binary64
:alt
(! :herbie-platform default (if (< z -11820553527347888000) (+ (* z (+ (* b a) y)) (+ x (* t a))) (if (< z 47589743188364287/1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000) (+ (* (+ (* b z) t) a) (+ (* z y) x)) (+ (* z (+ (* b a) y)) (+ x (* t a))))))
(+ (+ (+ x (* y z)) (* t a)) (* (* a z) b)))