
(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 14 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 (<= (+ (+ (+ x (* y z)) (* t a)) (* (* a z) b)) 2e+262) (fma (* a z) b (fma a t (fma z y x))) (fma z y (+ x (* a (fma b z t))))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if ((((x + (y * z)) + (t * a)) + ((a * z) * b)) <= 2e+262) {
tmp = fma((a * z), b, fma(a, t, fma(z, y, x)));
} else {
tmp = fma(z, y, (x + (a * fma(b, z, t))));
}
return tmp;
}
function code(x, y, z, t, a, b) tmp = 0.0 if (Float64(Float64(Float64(x + Float64(y * z)) + Float64(t * a)) + Float64(Float64(a * z) * b)) <= 2e+262) tmp = fma(Float64(a * z), b, fma(a, t, fma(z, y, x))); else tmp = fma(z, y, Float64(x + Float64(a * fma(b, z, t)))); end return tmp end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[N[(N[(N[(x + N[(y * z), $MachinePrecision]), $MachinePrecision] + N[(t * a), $MachinePrecision]), $MachinePrecision] + N[(N[(a * z), $MachinePrecision] * b), $MachinePrecision]), $MachinePrecision], 2e+262], N[(N[(a * z), $MachinePrecision] * b + N[(a * t + N[(z * y + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(z * y + N[(x + N[(a * N[(b * z + t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\left(\left(x + y \cdot z\right) + t \cdot a\right) + \left(a \cdot z\right) \cdot b \leq 2 \cdot 10^{+262}:\\
\;\;\;\;\mathsf{fma}\left(a \cdot z, b, \mathsf{fma}\left(a, t, \mathsf{fma}\left(z, y, x\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(z, y, x + a \cdot \mathsf{fma}\left(b, z, t\right)\right)\\
\end{array}
\end{array}
if (+.f64 (+.f64 (+.f64 x (*.f64 y z)) (*.f64 t a)) (*.f64 (*.f64 a z) b)) < 2e262Initial program 98.2%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6498.2
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6498.2
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6498.2
Applied rewrites98.2%
if 2e262 < (+.f64 (+.f64 (+.f64 x (*.f64 y z)) (*.f64 t a)) (*.f64 (*.f64 a z) b)) Initial program 77.3%
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.7%
(FPCore (x y z t a b)
:precision binary64
(if (<= b -1.45e-37)
(* (* b z) a)
(if (<= b 2.9e-167)
(fma a t x)
(if (<= b 6.4e-16)
(fma z y x)
(if (<= b 3.6e+93) (fma a t x) (* (* z a) b))))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (b <= -1.45e-37) {
tmp = (b * z) * a;
} else if (b <= 2.9e-167) {
tmp = fma(a, t, x);
} else if (b <= 6.4e-16) {
tmp = fma(z, y, x);
} else if (b <= 3.6e+93) {
tmp = fma(a, t, x);
} else {
tmp = (z * a) * b;
}
return tmp;
}
function code(x, y, z, t, a, b) tmp = 0.0 if (b <= -1.45e-37) tmp = Float64(Float64(b * z) * a); elseif (b <= 2.9e-167) tmp = fma(a, t, x); elseif (b <= 6.4e-16) tmp = fma(z, y, x); elseif (b <= 3.6e+93) tmp = fma(a, t, x); else tmp = Float64(Float64(z * a) * b); end return tmp end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[b, -1.45e-37], N[(N[(b * z), $MachinePrecision] * a), $MachinePrecision], If[LessEqual[b, 2.9e-167], N[(a * t + x), $MachinePrecision], If[LessEqual[b, 6.4e-16], N[(z * y + x), $MachinePrecision], If[LessEqual[b, 3.6e+93], N[(a * t + x), $MachinePrecision], N[(N[(z * a), $MachinePrecision] * b), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.45 \cdot 10^{-37}:\\
\;\;\;\;\left(b \cdot z\right) \cdot a\\
\mathbf{elif}\;b \leq 2.9 \cdot 10^{-167}:\\
\;\;\;\;\mathsf{fma}\left(a, t, x\right)\\
\mathbf{elif}\;b \leq 6.4 \cdot 10^{-16}:\\
\;\;\;\;\mathsf{fma}\left(z, y, x\right)\\
\mathbf{elif}\;b \leq 3.6 \cdot 10^{+93}:\\
\;\;\;\;\mathsf{fma}\left(a, t, x\right)\\
\mathbf{else}:\\
\;\;\;\;\left(z \cdot a\right) \cdot b\\
\end{array}
\end{array}
if b < -1.45000000000000002e-37Initial program 93.0%
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.4%
Taylor expanded in b around inf
Applied rewrites62.8%
if -1.45000000000000002e-37 < b < 2.90000000000000003e-167 or 6.40000000000000046e-16 < b < 3.5999999999999999e93Initial program 92.9%
Taylor expanded in z around 0
Applied rewrites72.8%
if 2.90000000000000003e-167 < b < 6.40000000000000046e-16Initial program 94.2%
Taylor expanded in a around 0
Applied rewrites71.0%
if 3.5999999999999999e93 < b Initial program 90.0%
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 rewrites86.9%
Taylor expanded in b around inf
Applied rewrites59.6%
Applied rewrites68.7%
(FPCore (x y z t a b)
:precision binary64
(if (<= b -1.45e-37)
(* (* b z) a)
(if (<= b 2.9e-167)
(fma a t x)
(if (<= b 6.4e-16)
(fma z y x)
(if (<= b 3.6e+93) (fma a t x) (* (* b a) z))))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (b <= -1.45e-37) {
tmp = (b * z) * a;
} else if (b <= 2.9e-167) {
tmp = fma(a, t, x);
} else if (b <= 6.4e-16) {
tmp = fma(z, y, x);
} else if (b <= 3.6e+93) {
tmp = fma(a, t, x);
} else {
tmp = (b * a) * z;
}
return tmp;
}
function code(x, y, z, t, a, b) tmp = 0.0 if (b <= -1.45e-37) tmp = Float64(Float64(b * z) * a); elseif (b <= 2.9e-167) tmp = fma(a, t, x); elseif (b <= 6.4e-16) tmp = fma(z, y, x); elseif (b <= 3.6e+93) tmp = fma(a, t, x); else tmp = Float64(Float64(b * a) * z); end return tmp end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[b, -1.45e-37], N[(N[(b * z), $MachinePrecision] * a), $MachinePrecision], If[LessEqual[b, 2.9e-167], N[(a * t + x), $MachinePrecision], If[LessEqual[b, 6.4e-16], N[(z * y + x), $MachinePrecision], If[LessEqual[b, 3.6e+93], N[(a * t + x), $MachinePrecision], N[(N[(b * a), $MachinePrecision] * z), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.45 \cdot 10^{-37}:\\
\;\;\;\;\left(b \cdot z\right) \cdot a\\
\mathbf{elif}\;b \leq 2.9 \cdot 10^{-167}:\\
\;\;\;\;\mathsf{fma}\left(a, t, x\right)\\
\mathbf{elif}\;b \leq 6.4 \cdot 10^{-16}:\\
\;\;\;\;\mathsf{fma}\left(z, y, x\right)\\
\mathbf{elif}\;b \leq 3.6 \cdot 10^{+93}:\\
\;\;\;\;\mathsf{fma}\left(a, t, x\right)\\
\mathbf{else}:\\
\;\;\;\;\left(b \cdot a\right) \cdot z\\
\end{array}
\end{array}
if b < -1.45000000000000002e-37Initial program 93.0%
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.4%
Taylor expanded in b around inf
Applied rewrites62.8%
if -1.45000000000000002e-37 < b < 2.90000000000000003e-167 or 6.40000000000000046e-16 < b < 3.5999999999999999e93Initial program 92.9%
Taylor expanded in z around 0
Applied rewrites72.8%
if 2.90000000000000003e-167 < b < 6.40000000000000046e-16Initial program 94.2%
Taylor expanded in a around 0
Applied rewrites71.0%
if 3.5999999999999999e93 < b Initial program 90.0%
Taylor expanded in b around inf
Applied rewrites61.5%
(FPCore (x y z t a b)
:precision binary64
(let* ((t_1 (* (* b a) z)))
(if (<= b -1.45e-37)
t_1
(if (<= b 2.9e-167)
(fma a t x)
(if (<= b 6.4e-16) (fma z y x) (if (<= b 3.6e+93) (fma a t 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 (b <= -1.45e-37) {
tmp = t_1;
} else if (b <= 2.9e-167) {
tmp = fma(a, t, x);
} else if (b <= 6.4e-16) {
tmp = fma(z, y, x);
} else if (b <= 3.6e+93) {
tmp = fma(a, t, 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 (b <= -1.45e-37) tmp = t_1; elseif (b <= 2.9e-167) tmp = fma(a, t, x); elseif (b <= 6.4e-16) tmp = fma(z, y, x); elseif (b <= 3.6e+93) tmp = fma(a, t, 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[b, -1.45e-37], t$95$1, If[LessEqual[b, 2.9e-167], N[(a * t + x), $MachinePrecision], If[LessEqual[b, 6.4e-16], N[(z * y + x), $MachinePrecision], If[LessEqual[b, 3.6e+93], N[(a * t + x), $MachinePrecision], t$95$1]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left(b \cdot a\right) \cdot z\\
\mathbf{if}\;b \leq -1.45 \cdot 10^{-37}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;b \leq 2.9 \cdot 10^{-167}:\\
\;\;\;\;\mathsf{fma}\left(a, t, x\right)\\
\mathbf{elif}\;b \leq 6.4 \cdot 10^{-16}:\\
\;\;\;\;\mathsf{fma}\left(z, y, x\right)\\
\mathbf{elif}\;b \leq 3.6 \cdot 10^{+93}:\\
\;\;\;\;\mathsf{fma}\left(a, t, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if b < -1.45000000000000002e-37 or 3.5999999999999999e93 < b Initial program 91.6%
Taylor expanded in b around inf
Applied rewrites60.5%
if -1.45000000000000002e-37 < b < 2.90000000000000003e-167 or 6.40000000000000046e-16 < b < 3.5999999999999999e93Initial program 92.9%
Taylor expanded in z around 0
Applied rewrites72.8%
if 2.90000000000000003e-167 < b < 6.40000000000000046e-16Initial program 94.2%
Taylor expanded in a around 0
Applied rewrites71.0%
(FPCore (x y z t a b)
:precision binary64
(if (<= t -4e+59)
(* a t)
(if (<= t 3.7e-216)
x
(if (<= t 4e-54) (* z y) (if (<= t 2.1e+15) x (* a t))))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (t <= -4e+59) {
tmp = a * t;
} else if (t <= 3.7e-216) {
tmp = x;
} else if (t <= 4e-54) {
tmp = z * y;
} else if (t <= 2.1e+15) {
tmp = x;
} 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 (t <= (-4d+59)) then
tmp = a * t
else if (t <= 3.7d-216) then
tmp = x
else if (t <= 4d-54) then
tmp = z * y
else if (t <= 2.1d+15) then
tmp = x
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 (t <= -4e+59) {
tmp = a * t;
} else if (t <= 3.7e-216) {
tmp = x;
} else if (t <= 4e-54) {
tmp = z * y;
} else if (t <= 2.1e+15) {
tmp = x;
} else {
tmp = a * t;
}
return tmp;
}
def code(x, y, z, t, a, b): tmp = 0 if t <= -4e+59: tmp = a * t elif t <= 3.7e-216: tmp = x elif t <= 4e-54: tmp = z * y elif t <= 2.1e+15: tmp = x else: tmp = a * t return tmp
function code(x, y, z, t, a, b) tmp = 0.0 if (t <= -4e+59) tmp = Float64(a * t); elseif (t <= 3.7e-216) tmp = x; elseif (t <= 4e-54) tmp = Float64(z * y); elseif (t <= 2.1e+15) tmp = x; else tmp = Float64(a * t); end return tmp end
function tmp_2 = code(x, y, z, t, a, b) tmp = 0.0; if (t <= -4e+59) tmp = a * t; elseif (t <= 3.7e-216) tmp = x; elseif (t <= 4e-54) tmp = z * y; elseif (t <= 2.1e+15) tmp = x; else tmp = a * t; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[t, -4e+59], N[(a * t), $MachinePrecision], If[LessEqual[t, 3.7e-216], x, If[LessEqual[t, 4e-54], N[(z * y), $MachinePrecision], If[LessEqual[t, 2.1e+15], x, N[(a * t), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -4 \cdot 10^{+59}:\\
\;\;\;\;a \cdot t\\
\mathbf{elif}\;t \leq 3.7 \cdot 10^{-216}:\\
\;\;\;\;x\\
\mathbf{elif}\;t \leq 4 \cdot 10^{-54}:\\
\;\;\;\;z \cdot y\\
\mathbf{elif}\;t \leq 2.1 \cdot 10^{+15}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;a \cdot t\\
\end{array}
\end{array}
if t < -3.99999999999999989e59 or 2.1e15 < t Initial program 91.7%
Taylor expanded in t around inf
Applied rewrites56.9%
if -3.99999999999999989e59 < t < 3.69999999999999996e-216 or 4.0000000000000001e-54 < t < 2.1e15Initial program 93.7%
Taylor expanded in x around inf
Applied rewrites32.0%
if 3.69999999999999996e-216 < t < 4.0000000000000001e-54Initial program 91.3%
Taylor expanded in y around inf
Applied rewrites55.4%
(FPCore (x y z t a b) :precision binary64 (if (or (<= b -5.8e-38) (not (<= b 3.5e-14))) (fma (fma b z t) a x) (fma a t (fma z y x))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if ((b <= -5.8e-38) || !(b <= 3.5e-14)) {
tmp = fma(fma(b, z, t), a, x);
} else {
tmp = fma(a, t, fma(z, y, x));
}
return tmp;
}
function code(x, y, z, t, a, b) tmp = 0.0 if ((b <= -5.8e-38) || !(b <= 3.5e-14)) tmp = fma(fma(b, z, t), a, x); else tmp = fma(a, t, fma(z, y, x)); end return tmp end
code[x_, y_, z_, t_, a_, b_] := If[Or[LessEqual[b, -5.8e-38], N[Not[LessEqual[b, 3.5e-14]], $MachinePrecision]], N[(N[(b * z + t), $MachinePrecision] * a + x), $MachinePrecision], N[(a * t + N[(z * y + x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -5.8 \cdot 10^{-38} \lor \neg \left(b \leq 3.5 \cdot 10^{-14}\right):\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(b, z, t\right), a, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(a, t, \mathsf{fma}\left(z, y, x\right)\right)\\
\end{array}
\end{array}
if b < -5.79999999999999988e-38 or 3.5000000000000002e-14 < b Initial program 93.1%
Taylor expanded in y around 0
Applied rewrites85.4%
if -5.79999999999999988e-38 < b < 3.5000000000000002e-14Initial program 91.8%
Taylor expanded in b around 0
Applied rewrites94.2%
Final simplification89.5%
(FPCore (x y z t a b) :precision binary64 (if (<= b -1.45e-37) (* (fma b z t) a) (if (<= b 4e+93) (fma a t (fma z y x)) (fma (* a z) b x))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (b <= -1.45e-37) {
tmp = fma(b, z, t) * a;
} else if (b <= 4e+93) {
tmp = fma(a, t, fma(z, y, x));
} else {
tmp = fma((a * z), b, x);
}
return tmp;
}
function code(x, y, z, t, a, b) tmp = 0.0 if (b <= -1.45e-37) tmp = Float64(fma(b, z, t) * a); elseif (b <= 4e+93) tmp = fma(a, t, fma(z, y, x)); else tmp = fma(Float64(a * z), b, x); end return tmp end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[b, -1.45e-37], N[(N[(b * z + t), $MachinePrecision] * a), $MachinePrecision], If[LessEqual[b, 4e+93], N[(a * t + N[(z * y + x), $MachinePrecision]), $MachinePrecision], N[(N[(a * z), $MachinePrecision] * b + x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.45 \cdot 10^{-37}:\\
\;\;\;\;\mathsf{fma}\left(b, z, t\right) \cdot a\\
\mathbf{elif}\;b \leq 4 \cdot 10^{+93}:\\
\;\;\;\;\mathsf{fma}\left(a, t, \mathsf{fma}\left(z, y, x\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(a \cdot z, b, x\right)\\
\end{array}
\end{array}
if b < -1.45000000000000002e-37Initial program 93.0%
Taylor expanded in a around inf
Applied rewrites77.1%
if -1.45000000000000002e-37 < b < 4.00000000000000017e93Initial program 93.2%
Taylor expanded in b around 0
Applied rewrites92.4%
if 4.00000000000000017e93 < b Initial program 90.0%
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 rewrites86.9%
lift-fma.f64N/A
+-commutativeN/A
lift-+.f64N/A
+-commutativeN/A
*-commutativeN/A
associate-+l+N/A
lift-*.f64N/A
lift-fma.f64N/A
distribute-lft-inN/A
*-commutativeN/A
associate-*l*N/A
*-commutativeN/A
associate-+r+N/A
+-commutativeN/A
lower-fma.f64N/A
lower-*.f64N/A
+-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f6492.0
Applied rewrites92.0%
Taylor expanded in x around inf
Applied rewrites80.2%
(FPCore (x y z t a b) :precision binary64 (if (or (<= a -1.36e-21) (not (<= a 2.6e-74))) (* (fma b z t) a) (fma z y x)))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if ((a <= -1.36e-21) || !(a <= 2.6e-74)) {
tmp = fma(b, z, t) * a;
} else {
tmp = fma(z, y, x);
}
return tmp;
}
function code(x, y, z, t, a, b) tmp = 0.0 if ((a <= -1.36e-21) || !(a <= 2.6e-74)) tmp = Float64(fma(b, z, t) * a); else tmp = fma(z, y, x); end return tmp end
code[x_, y_, z_, t_, a_, b_] := If[Or[LessEqual[a, -1.36e-21], N[Not[LessEqual[a, 2.6e-74]], $MachinePrecision]], N[(N[(b * z + t), $MachinePrecision] * a), $MachinePrecision], N[(z * y + x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -1.36 \cdot 10^{-21} \lor \neg \left(a \leq 2.6 \cdot 10^{-74}\right):\\
\;\;\;\;\mathsf{fma}\left(b, z, t\right) \cdot a\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(z, y, x\right)\\
\end{array}
\end{array}
if a < -1.3599999999999999e-21 or 2.6000000000000001e-74 < a Initial program 88.5%
Taylor expanded in a around inf
Applied rewrites80.9%
if -1.3599999999999999e-21 < a < 2.6000000000000001e-74Initial program 98.7%
Taylor expanded in a around 0
Applied rewrites76.8%
Final simplification79.3%
(FPCore (x y z t a b) :precision binary64 (if (or (<= z -820000000.0) (not (<= z 3.7e+22))) (* (fma b a y) z) (fma a t x)))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if ((z <= -820000000.0) || !(z <= 3.7e+22)) {
tmp = fma(b, a, y) * z;
} else {
tmp = fma(a, t, x);
}
return tmp;
}
function code(x, y, z, t, a, b) tmp = 0.0 if ((z <= -820000000.0) || !(z <= 3.7e+22)) tmp = Float64(fma(b, a, y) * z); else tmp = fma(a, t, x); end return tmp end
code[x_, y_, z_, t_, a_, b_] := If[Or[LessEqual[z, -820000000.0], N[Not[LessEqual[z, 3.7e+22]], $MachinePrecision]], N[(N[(b * a + y), $MachinePrecision] * z), $MachinePrecision], N[(a * t + x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -820000000 \lor \neg \left(z \leq 3.7 \cdot 10^{+22}\right):\\
\;\;\;\;\mathsf{fma}\left(b, a, y\right) \cdot z\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(a, t, x\right)\\
\end{array}
\end{array}
if z < -8.2e8 or 3.6999999999999998e22 < z Initial program 86.6%
Taylor expanded in z around inf
Applied rewrites74.7%
if -8.2e8 < z < 3.6999999999999998e22Initial program 98.2%
Taylor expanded in z around 0
Applied rewrites67.9%
Final simplification71.2%
(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 92.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 rewrites95.5%
(FPCore (x y z t a b) :precision binary64 (if (or (<= t -1.3e+105) (not (<= t 4.3e-54))) (fma a t x) (fma z y x)))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if ((t <= -1.3e+105) || !(t <= 4.3e-54)) {
tmp = fma(a, t, x);
} else {
tmp = fma(z, y, x);
}
return tmp;
}
function code(x, y, z, t, a, b) tmp = 0.0 if ((t <= -1.3e+105) || !(t <= 4.3e-54)) tmp = fma(a, t, x); else tmp = fma(z, y, x); end return tmp end
code[x_, y_, z_, t_, a_, b_] := If[Or[LessEqual[t, -1.3e+105], N[Not[LessEqual[t, 4.3e-54]], $MachinePrecision]], N[(a * t + x), $MachinePrecision], N[(z * y + x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -1.3 \cdot 10^{+105} \lor \neg \left(t \leq 4.3 \cdot 10^{-54}\right):\\
\;\;\;\;\mathsf{fma}\left(a, t, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(z, y, x\right)\\
\end{array}
\end{array}
if t < -1.3000000000000001e105 or 4.3e-54 < t Initial program 92.6%
Taylor expanded in z around 0
Applied rewrites71.4%
if -1.3000000000000001e105 < t < 4.3e-54Initial program 92.4%
Taylor expanded in a around 0
Applied rewrites53.1%
Final simplification61.8%
(FPCore (x y z t a b) :precision binary64 (if (or (<= a -1.65e+15) (not (<= a 8.8e-61))) (* a t) x))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if ((a <= -1.65e+15) || !(a <= 8.8e-61)) {
tmp = a * t;
} else {
tmp = x;
}
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 ((a <= (-1.65d+15)) .or. (.not. (a <= 8.8d-61))) then
tmp = a * t
else
tmp = x
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 ((a <= -1.65e+15) || !(a <= 8.8e-61)) {
tmp = a * t;
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z, t, a, b): tmp = 0 if (a <= -1.65e+15) or not (a <= 8.8e-61): tmp = a * t else: tmp = x return tmp
function code(x, y, z, t, a, b) tmp = 0.0 if ((a <= -1.65e+15) || !(a <= 8.8e-61)) tmp = Float64(a * t); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z, t, a, b) tmp = 0.0; if ((a <= -1.65e+15) || ~((a <= 8.8e-61))) tmp = a * t; else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_] := If[Or[LessEqual[a, -1.65e+15], N[Not[LessEqual[a, 8.8e-61]], $MachinePrecision]], N[(a * t), $MachinePrecision], x]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -1.65 \cdot 10^{+15} \lor \neg \left(a \leq 8.8 \cdot 10^{-61}\right):\\
\;\;\;\;a \cdot t\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if a < -1.65e15 or 8.80000000000000035e-61 < a Initial program 87.9%
Taylor expanded in t around inf
Applied rewrites44.7%
if -1.65e15 < a < 8.80000000000000035e-61Initial program 98.8%
Taylor expanded in x around inf
Applied rewrites40.4%
Final simplification42.9%
(FPCore (x y z t a b) :precision binary64 (if (<= y -9.2e+79) (* z y) (fma a t x)))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (y <= -9.2e+79) {
tmp = z * y;
} else {
tmp = fma(a, t, x);
}
return tmp;
}
function code(x, y, z, t, a, b) tmp = 0.0 if (y <= -9.2e+79) tmp = Float64(z * y); else tmp = fma(a, t, x); end return tmp end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[y, -9.2e+79], N[(z * y), $MachinePrecision], N[(a * t + x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -9.2 \cdot 10^{+79}:\\
\;\;\;\;z \cdot y\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(a, t, x\right)\\
\end{array}
\end{array}
if y < -9.2000000000000002e79Initial program 94.5%
Taylor expanded in y around inf
Applied rewrites62.1%
if -9.2000000000000002e79 < y Initial program 92.2%
Taylor expanded in z around 0
Applied rewrites53.5%
(FPCore (x y z t a b) :precision binary64 x)
double code(double x, double y, double z, double t, double a, double b) {
return x;
}
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
end function
public static double code(double x, double y, double z, double t, double a, double b) {
return x;
}
def code(x, y, z, t, a, b): return x
function code(x, y, z, t, a, b) return x end
function tmp = code(x, y, z, t, a, b) tmp = x; end
code[x_, y_, z_, t_, a_, b_] := x
\begin{array}{l}
\\
x
\end{array}
Initial program 92.5%
Taylor expanded in x around inf
Applied rewrites22.6%
(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 2025018
(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)))