
(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}
Herbie found 11 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 (let* ((t_1 (+ (+ (+ x (* y z)) (* t a)) (* (* a z) b)))) (if (<= t_1 INFINITY) t_1 (* a (fma z b t)))))
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)) {
tmp = t_1;
} else {
tmp = a * fma(z, b, t);
}
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 <= Inf) tmp = t_1; else tmp = Float64(a * fma(z, b, t)); 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[LessEqual[t$95$1, Infinity], t$95$1, N[(a * N[(z * b + t), $MachinePrecision]), $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:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;a \cdot \mathsf{fma}\left(z, b, t\right)\\
\end{array}
\end{array}
if (+.f64 (+.f64 (+.f64 x (*.f64 y z)) (*.f64 t a)) (*.f64 (*.f64 a z) b)) < +inf.0Initial program 92.1%
if +inf.0 < (+.f64 (+.f64 (+.f64 x (*.f64 y z)) (*.f64 t a)) (*.f64 (*.f64 a z) b)) Initial program 92.1%
Taylor expanded in a around inf
Applied rewrites51.3%
Applied rewrites51.3%
(FPCore (x y z t a b) :precision binary64 (if (<= t -4.4e+86) (fma (fma b z t) a x) (if (<= t 7.2e+57) (fma (fma b a y) z x) (+ x (fma a t (* y z))))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (t <= -4.4e+86) {
tmp = fma(fma(b, z, t), a, x);
} else if (t <= 7.2e+57) {
tmp = fma(fma(b, a, y), z, x);
} else {
tmp = x + fma(a, t, (y * z));
}
return tmp;
}
function code(x, y, z, t, a, b) tmp = 0.0 if (t <= -4.4e+86) tmp = fma(fma(b, z, t), a, x); elseif (t <= 7.2e+57) tmp = fma(fma(b, a, y), z, x); else tmp = Float64(x + fma(a, t, Float64(y * z))); end return tmp end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[t, -4.4e+86], N[(N[(b * z + t), $MachinePrecision] * a + x), $MachinePrecision], If[LessEqual[t, 7.2e+57], N[(N[(b * a + y), $MachinePrecision] * z + x), $MachinePrecision], N[(x + N[(a * t + N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -4.4 \cdot 10^{+86}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(b, z, t\right), a, x\right)\\
\mathbf{elif}\;t \leq 7.2 \cdot 10^{+57}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(b, a, y\right), z, x\right)\\
\mathbf{else}:\\
\;\;\;\;x + \mathsf{fma}\left(a, t, y \cdot z\right)\\
\end{array}
\end{array}
if t < -4.40000000000000006e86Initial program 92.1%
Taylor expanded in y around 0
Applied rewrites73.5%
Applied rewrites74.2%
if -4.40000000000000006e86 < t < 7.2000000000000005e57Initial program 92.1%
Taylor expanded in t around 0
Applied rewrites69.5%
Applied rewrites74.0%
if 7.2000000000000005e57 < t Initial program 92.1%
Taylor expanded in t around 0
Applied rewrites69.5%
Applied rewrites74.0%
Taylor expanded in b around 0
Applied rewrites77.4%
(FPCore (x y z t a b)
:precision binary64
(let* ((t_1 (fma (fma b z t) a x)))
(if (<= a -580000000000.0)
t_1
(if (<= a 1.9e+23) (fma (fma b a y) z x) t_1))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = fma(fma(b, z, t), a, x);
double tmp;
if (a <= -580000000000.0) {
tmp = t_1;
} else if (a <= 1.9e+23) {
tmp = fma(fma(b, a, y), z, x);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a, b) t_1 = fma(fma(b, z, t), a, x) tmp = 0.0 if (a <= -580000000000.0) tmp = t_1; elseif (a <= 1.9e+23) tmp = fma(fma(b, a, 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 * z + t), $MachinePrecision] * a + x), $MachinePrecision]}, If[LessEqual[a, -580000000000.0], t$95$1, If[LessEqual[a, 1.9e+23], N[(N[(b * a + y), $MachinePrecision] * z + x), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(\mathsf{fma}\left(b, z, t\right), a, x\right)\\
\mathbf{if}\;a \leq -580000000000:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;a \leq 1.9 \cdot 10^{+23}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(b, a, y\right), z, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if a < -5.8e11 or 1.89999999999999987e23 < a Initial program 92.1%
Taylor expanded in y around 0
Applied rewrites73.5%
Applied rewrites74.2%
if -5.8e11 < a < 1.89999999999999987e23Initial program 92.1%
Taylor expanded in t around 0
Applied rewrites69.5%
Applied rewrites74.0%
(FPCore (x y z t a b) :precision binary64 (if (<= t -2.15e+89) (* a (fma z b t)) (if (<= t 1.08e+94) (fma (fma b a y) z x) (fma a t (* y z)))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (t <= -2.15e+89) {
tmp = a * fma(z, b, t);
} else if (t <= 1.08e+94) {
tmp = fma(fma(b, a, y), z, x);
} else {
tmp = fma(a, t, (y * z));
}
return tmp;
}
function code(x, y, z, t, a, b) tmp = 0.0 if (t <= -2.15e+89) tmp = Float64(a * fma(z, b, t)); elseif (t <= 1.08e+94) tmp = fma(fma(b, a, y), z, x); else tmp = fma(a, t, Float64(y * z)); end return tmp end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[t, -2.15e+89], N[(a * N[(z * b + t), $MachinePrecision]), $MachinePrecision], If[LessEqual[t, 1.08e+94], N[(N[(b * a + y), $MachinePrecision] * z + x), $MachinePrecision], N[(a * t + N[(y * z), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -2.15 \cdot 10^{+89}:\\
\;\;\;\;a \cdot \mathsf{fma}\left(z, b, t\right)\\
\mathbf{elif}\;t \leq 1.08 \cdot 10^{+94}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(b, a, y\right), z, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(a, t, y \cdot z\right)\\
\end{array}
\end{array}
if t < -2.1500000000000001e89Initial program 92.1%
Taylor expanded in a around inf
Applied rewrites51.3%
Applied rewrites51.3%
if -2.1500000000000001e89 < t < 1.08e94Initial program 92.1%
Taylor expanded in t around 0
Applied rewrites69.5%
Applied rewrites74.0%
if 1.08e94 < t Initial program 92.1%
Taylor expanded in t around 0
Applied rewrites69.5%
Applied rewrites74.0%
Taylor expanded in b around 0
Applied rewrites77.4%
Taylor expanded in x around 0
Applied rewrites53.9%
(FPCore (x y z t a b) :precision binary64 (let* ((t_1 (* a (fma z b t)))) (if (<= a -200000000000.0) t_1 (if (<= a 2e+22) (fma z y x) t_1))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = a * fma(z, b, t);
double tmp;
if (a <= -200000000000.0) {
tmp = t_1;
} else if (a <= 2e+22) {
tmp = fma(z, y, x);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a, b) t_1 = Float64(a * fma(z, b, t)) tmp = 0.0 if (a <= -200000000000.0) tmp = t_1; elseif (a <= 2e+22) tmp = fma(z, y, x); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(a * N[(z * b + t), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[a, -200000000000.0], t$95$1, If[LessEqual[a, 2e+22], N[(z * y + x), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := a \cdot \mathsf{fma}\left(z, b, t\right)\\
\mathbf{if}\;a \leq -200000000000:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;a \leq 2 \cdot 10^{+22}:\\
\;\;\;\;\mathsf{fma}\left(z, y, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if a < -2e11 or 2e22 < a Initial program 92.1%
Taylor expanded in a around inf
Applied rewrites51.3%
Applied rewrites51.3%
if -2e11 < a < 2e22Initial program 92.1%
Taylor expanded in t around 0
Applied rewrites69.5%
Applied rewrites74.0%
Taylor expanded in a around 0
Applied rewrites51.5%
Applied rewrites51.5%
(FPCore (x y z t a b)
:precision binary64
(if (<= a -600000000000.0)
(+ x (* a t))
(if (<= a 0.00023)
(fma z y x)
(if (<= a 1.02e+62) (fma a t (* y z)) (* a (* b z))))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (a <= -600000000000.0) {
tmp = x + (a * t);
} else if (a <= 0.00023) {
tmp = fma(z, y, x);
} else if (a <= 1.02e+62) {
tmp = fma(a, t, (y * z));
} else {
tmp = a * (b * z);
}
return tmp;
}
function code(x, y, z, t, a, b) tmp = 0.0 if (a <= -600000000000.0) tmp = Float64(x + Float64(a * t)); elseif (a <= 0.00023) tmp = fma(z, y, x); elseif (a <= 1.02e+62) tmp = fma(a, t, Float64(y * z)); else tmp = Float64(a * Float64(b * z)); end return tmp end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[a, -600000000000.0], N[(x + N[(a * t), $MachinePrecision]), $MachinePrecision], If[LessEqual[a, 0.00023], N[(z * y + x), $MachinePrecision], If[LessEqual[a, 1.02e+62], N[(a * t + N[(y * z), $MachinePrecision]), $MachinePrecision], N[(a * N[(b * z), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -600000000000:\\
\;\;\;\;x + a \cdot t\\
\mathbf{elif}\;a \leq 0.00023:\\
\;\;\;\;\mathsf{fma}\left(z, y, x\right)\\
\mathbf{elif}\;a \leq 1.02 \cdot 10^{+62}:\\
\;\;\;\;\mathsf{fma}\left(a, t, y \cdot z\right)\\
\mathbf{else}:\\
\;\;\;\;a \cdot \left(b \cdot z\right)\\
\end{array}
\end{array}
if a < -6e11Initial program 92.1%
Taylor expanded in t around 0
Applied rewrites69.5%
Applied rewrites74.0%
Taylor expanded in z around 0
Applied rewrites52.1%
if -6e11 < a < 2.3000000000000001e-4Initial program 92.1%
Taylor expanded in t around 0
Applied rewrites69.5%
Applied rewrites74.0%
Taylor expanded in a around 0
Applied rewrites51.5%
Applied rewrites51.5%
if 2.3000000000000001e-4 < a < 1.02000000000000002e62Initial program 92.1%
Taylor expanded in t around 0
Applied rewrites69.5%
Applied rewrites74.0%
Taylor expanded in b around 0
Applied rewrites77.4%
Taylor expanded in x around 0
Applied rewrites53.9%
if 1.02000000000000002e62 < a Initial program 92.1%
Taylor expanded in z around inf
Applied rewrites50.9%
Taylor expanded in y around 0
Applied rewrites26.7%
(FPCore (x y z t a b) :precision binary64 (if (<= a -600000000000.0) (+ x (* a t)) (if (<= a 5.7e+69) (fma z y x) (* a (* b z)))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (a <= -600000000000.0) {
tmp = x + (a * t);
} else if (a <= 5.7e+69) {
tmp = fma(z, y, x);
} else {
tmp = a * (b * z);
}
return tmp;
}
function code(x, y, z, t, a, b) tmp = 0.0 if (a <= -600000000000.0) tmp = Float64(x + Float64(a * t)); elseif (a <= 5.7e+69) tmp = fma(z, y, x); else tmp = Float64(a * Float64(b * z)); end return tmp end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[a, -600000000000.0], N[(x + N[(a * t), $MachinePrecision]), $MachinePrecision], If[LessEqual[a, 5.7e+69], N[(z * y + x), $MachinePrecision], N[(a * N[(b * z), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -600000000000:\\
\;\;\;\;x + a \cdot t\\
\mathbf{elif}\;a \leq 5.7 \cdot 10^{+69}:\\
\;\;\;\;\mathsf{fma}\left(z, y, x\right)\\
\mathbf{else}:\\
\;\;\;\;a \cdot \left(b \cdot z\right)\\
\end{array}
\end{array}
if a < -6e11Initial program 92.1%
Taylor expanded in t around 0
Applied rewrites69.5%
Applied rewrites74.0%
Taylor expanded in z around 0
Applied rewrites52.1%
if -6e11 < a < 5.7e69Initial program 92.1%
Taylor expanded in t around 0
Applied rewrites69.5%
Applied rewrites74.0%
Taylor expanded in a around 0
Applied rewrites51.5%
Applied rewrites51.5%
if 5.7e69 < a Initial program 92.1%
Taylor expanded in z around inf
Applied rewrites50.9%
Taylor expanded in y around 0
Applied rewrites26.7%
(FPCore (x y z t a b) :precision binary64 (let* ((t_1 (+ x (* a t)))) (if (<= a -600000000000.0) t_1 (if (<= a 1.42e+29) (fma z y x) t_1))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = x + (a * t);
double tmp;
if (a <= -600000000000.0) {
tmp = t_1;
} else if (a <= 1.42e+29) {
tmp = fma(z, y, x);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a, b) t_1 = Float64(x + Float64(a * t)) tmp = 0.0 if (a <= -600000000000.0) tmp = t_1; elseif (a <= 1.42e+29) tmp = fma(z, y, x); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(x + N[(a * t), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[a, -600000000000.0], t$95$1, If[LessEqual[a, 1.42e+29], N[(z * y + x), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := x + a \cdot t\\
\mathbf{if}\;a \leq -600000000000:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;a \leq 1.42 \cdot 10^{+29}:\\
\;\;\;\;\mathsf{fma}\left(z, y, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if a < -6e11 or 1.42e29 < a Initial program 92.1%
Taylor expanded in t around 0
Applied rewrites69.5%
Applied rewrites74.0%
Taylor expanded in z around 0
Applied rewrites52.1%
if -6e11 < a < 1.42e29Initial program 92.1%
Taylor expanded in t around 0
Applied rewrites69.5%
Applied rewrites74.0%
Taylor expanded in a around 0
Applied rewrites51.5%
Applied rewrites51.5%
(FPCore (x y z t a b) :precision binary64 (if (<= a -1.7e+71) (* a t) (fma z y x)))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (a <= -1.7e+71) {
tmp = a * t;
} else {
tmp = fma(z, y, x);
}
return tmp;
}
function code(x, y, z, t, a, b) tmp = 0.0 if (a <= -1.7e+71) tmp = Float64(a * t); else tmp = fma(z, y, x); end return tmp end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[a, -1.7e+71], N[(a * t), $MachinePrecision], N[(z * y + x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -1.7 \cdot 10^{+71}:\\
\;\;\;\;a \cdot t\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(z, y, x\right)\\
\end{array}
\end{array}
if a < -1.6999999999999999e71Initial program 92.1%
Taylor expanded in a around inf
Applied rewrites51.3%
Taylor expanded in z around 0
Applied rewrites28.8%
if -1.6999999999999999e71 < a Initial program 92.1%
Taylor expanded in t around 0
Applied rewrites69.5%
Applied rewrites74.0%
Taylor expanded in a around 0
Applied rewrites51.5%
Applied rewrites51.5%
(FPCore (x y z t a b) :precision binary64 (if (<= a -600000000000.0) (* a t) (if (<= a 1.42e+29) (* y z) (* a t))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (a <= -600000000000.0) {
tmp = a * t;
} else if (a <= 1.42e+29) {
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 (a <= (-600000000000.0d0)) then
tmp = a * t
else if (a <= 1.42d+29) 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 (a <= -600000000000.0) {
tmp = a * t;
} else if (a <= 1.42e+29) {
tmp = y * z;
} else {
tmp = a * t;
}
return tmp;
}
def code(x, y, z, t, a, b): tmp = 0 if a <= -600000000000.0: tmp = a * t elif a <= 1.42e+29: tmp = y * z else: tmp = a * t return tmp
function code(x, y, z, t, a, b) tmp = 0.0 if (a <= -600000000000.0) tmp = Float64(a * t); elseif (a <= 1.42e+29) 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 (a <= -600000000000.0) tmp = a * t; elseif (a <= 1.42e+29) tmp = y * z; else tmp = a * t; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[a, -600000000000.0], N[(a * t), $MachinePrecision], If[LessEqual[a, 1.42e+29], N[(y * z), $MachinePrecision], N[(a * t), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -600000000000:\\
\;\;\;\;a \cdot t\\
\mathbf{elif}\;a \leq 1.42 \cdot 10^{+29}:\\
\;\;\;\;y \cdot z\\
\mathbf{else}:\\
\;\;\;\;a \cdot t\\
\end{array}
\end{array}
if a < -6e11 or 1.42e29 < a Initial program 92.1%
Taylor expanded in a around inf
Applied rewrites51.3%
Taylor expanded in z around 0
Applied rewrites28.8%
if -6e11 < a < 1.42e29Initial program 92.1%
Taylor expanded in t around 0
Applied rewrites69.5%
Applied rewrites74.0%
Taylor expanded in y around inf
Applied rewrites28.1%
(FPCore (x y z t a b) :precision binary64 (* a t))
double code(double x, double y, double z, double t, double a, double b) {
return a * t;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z, t, a, 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 = a * t
end function
public static double code(double x, double y, double z, double t, double a, double b) {
return a * t;
}
def code(x, y, z, t, a, b): return a * t
function code(x, y, z, t, a, b) return Float64(a * t) end
function tmp = code(x, y, z, t, a, b) tmp = a * t; end
code[x_, y_, z_, t_, a_, b_] := N[(a * t), $MachinePrecision]
\begin{array}{l}
\\
a \cdot t
\end{array}
Initial program 92.1%
Taylor expanded in a around inf
Applied rewrites51.3%
Taylor expanded in z around 0
Applied rewrites28.8%
herbie shell --seed 2025161
(FPCore (x y z t a b)
:name "Graphics.Rasterific.CubicBezier:cachedBezierAt from Rasterific-0.6.1"
:precision binary64
(+ (+ (+ x (* y z)) (* t a)) (* (* a z) b)))