
(FPCore (x y z t a b) :precision binary64 (+ (- (+ (+ x y) z) (* z (log t))) (* (- a 0.5) b)))
double code(double x, double y, double z, double t, double a, double b) {
return (((x + y) + z) - (z * log(t))) + ((a - 0.5) * 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) - (z * log(t))) + ((a - 0.5d0) * b)
end function
public static double code(double x, double y, double z, double t, double a, double b) {
return (((x + y) + z) - (z * Math.log(t))) + ((a - 0.5) * b);
}
def code(x, y, z, t, a, b): return (((x + y) + z) - (z * math.log(t))) + ((a - 0.5) * b)
function code(x, y, z, t, a, b) return Float64(Float64(Float64(Float64(x + y) + z) - Float64(z * log(t))) + Float64(Float64(a - 0.5) * b)) end
function tmp = code(x, y, z, t, a, b) tmp = (((x + y) + z) - (z * log(t))) + ((a - 0.5) * b); end
code[x_, y_, z_, t_, a_, b_] := N[(N[(N[(N[(x + y), $MachinePrecision] + z), $MachinePrecision] - N[(z * N[Log[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(a - 0.5), $MachinePrecision] * b), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(\left(x + y\right) + z\right) - z \cdot \log t\right) + \left(a - 0.5\right) \cdot b
\end{array}
Herbie found 13 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z t a b) :precision binary64 (+ (- (+ (+ x y) z) (* z (log t))) (* (- a 0.5) b)))
double code(double x, double y, double z, double t, double a, double b) {
return (((x + y) + z) - (z * log(t))) + ((a - 0.5) * 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) - (z * log(t))) + ((a - 0.5d0) * b)
end function
public static double code(double x, double y, double z, double t, double a, double b) {
return (((x + y) + z) - (z * Math.log(t))) + ((a - 0.5) * b);
}
def code(x, y, z, t, a, b): return (((x + y) + z) - (z * math.log(t))) + ((a - 0.5) * b)
function code(x, y, z, t, a, b) return Float64(Float64(Float64(Float64(x + y) + z) - Float64(z * log(t))) + Float64(Float64(a - 0.5) * b)) end
function tmp = code(x, y, z, t, a, b) tmp = (((x + y) + z) - (z * log(t))) + ((a - 0.5) * b); end
code[x_, y_, z_, t_, a_, b_] := N[(N[(N[(N[(x + y), $MachinePrecision] + z), $MachinePrecision] - N[(z * N[Log[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(a - 0.5), $MachinePrecision] * b), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(\left(x + y\right) + z\right) - z \cdot \log t\right) + \left(a - 0.5\right) \cdot b
\end{array}
(FPCore (x y z t a b) :precision binary64 (fma (- a 0.5) b (- (+ z (+ y x)) (* (log t) z))))
double code(double x, double y, double z, double t, double a, double b) {
return fma((a - 0.5), b, ((z + (y + x)) - (log(t) * z)));
}
function code(x, y, z, t, a, b) return fma(Float64(a - 0.5), b, Float64(Float64(z + Float64(y + x)) - Float64(log(t) * z))) end
code[x_, y_, z_, t_, a_, b_] := N[(N[(a - 0.5), $MachinePrecision] * b + N[(N[(z + N[(y + x), $MachinePrecision]), $MachinePrecision] - N[(N[Log[t], $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(a - 0.5, b, \left(z + \left(y + x\right)\right) - \log t \cdot z\right)
\end{array}
Initial program 99.8%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6499.8
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.8
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.8
lift-*.f64N/A
*-commutativeN/A
lower-*.f6499.8
Applied rewrites99.8%
(FPCore (x y z t a b) :precision binary64 (if (<= (+ x y) -1.5e-140) (fma (- a 0.5) b (- (+ x z) (* (log t) z))) (- (+ y z) (fma (log t) z (* (- 0.5 a) b)))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if ((x + y) <= -1.5e-140) {
tmp = fma((a - 0.5), b, ((x + z) - (log(t) * z)));
} else {
tmp = (y + z) - fma(log(t), z, ((0.5 - a) * b));
}
return tmp;
}
function code(x, y, z, t, a, b) tmp = 0.0 if (Float64(x + y) <= -1.5e-140) tmp = fma(Float64(a - 0.5), b, Float64(Float64(x + z) - Float64(log(t) * z))); else tmp = Float64(Float64(y + z) - fma(log(t), z, Float64(Float64(0.5 - a) * b))); end return tmp end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[N[(x + y), $MachinePrecision], -1.5e-140], N[(N[(a - 0.5), $MachinePrecision] * b + N[(N[(x + z), $MachinePrecision] - N[(N[Log[t], $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(y + z), $MachinePrecision] - N[(N[Log[t], $MachinePrecision] * z + N[(N[(0.5 - a), $MachinePrecision] * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x + y \leq -1.5 \cdot 10^{-140}:\\
\;\;\;\;\mathsf{fma}\left(a - 0.5, b, \left(x + z\right) - \log t \cdot z\right)\\
\mathbf{else}:\\
\;\;\;\;\left(y + z\right) - \mathsf{fma}\left(\log t, z, \left(0.5 - a\right) \cdot b\right)\\
\end{array}
\end{array}
if (+.f64 x y) < -1.50000000000000009e-140Initial program 99.8%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6499.8
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.8
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.8
lift-*.f64N/A
*-commutativeN/A
lower-*.f6499.8
Applied rewrites99.8%
Taylor expanded in y around 0
lower-+.f6478.5
Applied rewrites78.5%
if -1.50000000000000009e-140 < (+.f64 x y) Initial program 99.8%
Taylor expanded in x around 0
Applied rewrites78.9%
lift-+.f64N/A
lift--.f64N/A
associate-+l-N/A
lower--.f64N/A
sub-flipN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lift-*.f64N/A
distribute-lft-neg-outN/A
lift--.f64N/A
sub-negate-revN/A
lower-*.f64N/A
lower--.f6478.9
Applied rewrites78.9%
(FPCore (x y z t a b) :precision binary64 (if (<= (+ x y) -1e+107) (fma (- a 0.5) b (+ x y)) (- (+ y z) (fma (log t) z (* (- 0.5 a) b)))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if ((x + y) <= -1e+107) {
tmp = fma((a - 0.5), b, (x + y));
} else {
tmp = (y + z) - fma(log(t), z, ((0.5 - a) * b));
}
return tmp;
}
function code(x, y, z, t, a, b) tmp = 0.0 if (Float64(x + y) <= -1e+107) tmp = fma(Float64(a - 0.5), b, Float64(x + y)); else tmp = Float64(Float64(y + z) - fma(log(t), z, Float64(Float64(0.5 - a) * b))); end return tmp end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[N[(x + y), $MachinePrecision], -1e+107], N[(N[(a - 0.5), $MachinePrecision] * b + N[(x + y), $MachinePrecision]), $MachinePrecision], N[(N[(y + z), $MachinePrecision] - N[(N[Log[t], $MachinePrecision] * z + N[(N[(0.5 - a), $MachinePrecision] * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x + y \leq -1 \cdot 10^{+107}:\\
\;\;\;\;\mathsf{fma}\left(a - 0.5, b, x + y\right)\\
\mathbf{else}:\\
\;\;\;\;\left(y + z\right) - \mathsf{fma}\left(\log t, z, \left(0.5 - a\right) \cdot b\right)\\
\end{array}
\end{array}
if (+.f64 x y) < -9.9999999999999997e106Initial program 99.8%
Taylor expanded in z around 0
lower-+.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower--.f6478.3
Applied rewrites78.3%
lift-+.f64N/A
lift-+.f64N/A
associate-+r+N/A
lift-*.f64N/A
*-commutativeN/A
+-commutativeN/A
lower-fma.f64N/A
lower-+.f6478.3
Applied rewrites78.3%
if -9.9999999999999997e106 < (+.f64 x y) Initial program 99.8%
Taylor expanded in x around 0
Applied rewrites78.9%
lift-+.f64N/A
lift--.f64N/A
associate-+l-N/A
lower--.f64N/A
sub-flipN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lift-*.f64N/A
distribute-lft-neg-outN/A
lift--.f64N/A
sub-negate-revN/A
lower-*.f64N/A
lower--.f6478.9
Applied rewrites78.9%
(FPCore (x y z t a b)
:precision binary64
(if (<= z -1.65e+209)
(fma -0.5 b (fma z (- 1.0 (log t)) x))
(if (<= z 7.4e+224)
(fma (- a 0.5) b (+ x y))
(fma -0.5 b (- (+ y z) (* (log t) z))))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (z <= -1.65e+209) {
tmp = fma(-0.5, b, fma(z, (1.0 - log(t)), x));
} else if (z <= 7.4e+224) {
tmp = fma((a - 0.5), b, (x + y));
} else {
tmp = fma(-0.5, b, ((y + z) - (log(t) * z)));
}
return tmp;
}
function code(x, y, z, t, a, b) tmp = 0.0 if (z <= -1.65e+209) tmp = fma(-0.5, b, fma(z, Float64(1.0 - log(t)), x)); elseif (z <= 7.4e+224) tmp = fma(Float64(a - 0.5), b, Float64(x + y)); else tmp = fma(-0.5, b, Float64(Float64(y + z) - Float64(log(t) * z))); end return tmp end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[z, -1.65e+209], N[(-0.5 * b + N[(z * N[(1.0 - N[Log[t], $MachinePrecision]), $MachinePrecision] + x), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 7.4e+224], N[(N[(a - 0.5), $MachinePrecision] * b + N[(x + y), $MachinePrecision]), $MachinePrecision], N[(-0.5 * b + N[(N[(y + z), $MachinePrecision] - N[(N[Log[t], $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.65 \cdot 10^{+209}:\\
\;\;\;\;\mathsf{fma}\left(-0.5, b, \mathsf{fma}\left(z, 1 - \log t, x\right)\right)\\
\mathbf{elif}\;z \leq 7.4 \cdot 10^{+224}:\\
\;\;\;\;\mathsf{fma}\left(a - 0.5, b, x + y\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(-0.5, b, \left(y + z\right) - \log t \cdot z\right)\\
\end{array}
\end{array}
if z < -1.6499999999999999e209Initial program 99.8%
Taylor expanded in x around 0
Applied rewrites78.9%
Taylor expanded in a around 0
Applied rewrites55.1%
Taylor expanded in y around 0
lower--.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-log.f6454.7
Applied rewrites54.7%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6454.7
lift--.f64N/A
lift-+.f64N/A
associate--l+N/A
+-commutativeN/A
lift-*.f64N/A
*-rgt-identityN/A
distribute-lft-out--N/A
lower-fma.f64N/A
lower--.f6454.7
Applied rewrites54.7%
if -1.6499999999999999e209 < z < 7.40000000000000006e224Initial program 99.8%
Taylor expanded in z around 0
lower-+.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower--.f6478.3
Applied rewrites78.3%
lift-+.f64N/A
lift-+.f64N/A
associate-+r+N/A
lift-*.f64N/A
*-commutativeN/A
+-commutativeN/A
lower-fma.f64N/A
lower-+.f6478.3
Applied rewrites78.3%
if 7.40000000000000006e224 < z Initial program 99.8%
Taylor expanded in x around 0
Applied rewrites78.9%
Taylor expanded in a around 0
Applied rewrites55.1%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6455.1
lift-*.f64N/A
*-commutativeN/A
lift-*.f6455.1
Applied rewrites55.1%
(FPCore (x y z t a b)
:precision binary64
(let* ((t_1 (- 1.0 (log t))))
(if (<= z -1.65e+209)
(fma -0.5 b (fma z t_1 x))
(if (<= z 1.95e+226)
(fma (- a 0.5) b (+ x y))
(/ 1.0 (/ 1.0 (* z t_1)))))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = 1.0 - log(t);
double tmp;
if (z <= -1.65e+209) {
tmp = fma(-0.5, b, fma(z, t_1, x));
} else if (z <= 1.95e+226) {
tmp = fma((a - 0.5), b, (x + y));
} else {
tmp = 1.0 / (1.0 / (z * t_1));
}
return tmp;
}
function code(x, y, z, t, a, b) t_1 = Float64(1.0 - log(t)) tmp = 0.0 if (z <= -1.65e+209) tmp = fma(-0.5, b, fma(z, t_1, x)); elseif (z <= 1.95e+226) tmp = fma(Float64(a - 0.5), b, Float64(x + y)); else tmp = Float64(1.0 / Float64(1.0 / Float64(z * t_1))); end return tmp end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(1.0 - N[Log[t], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -1.65e+209], N[(-0.5 * b + N[(z * t$95$1 + x), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 1.95e+226], N[(N[(a - 0.5), $MachinePrecision] * b + N[(x + y), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(1.0 / N[(z * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := 1 - \log t\\
\mathbf{if}\;z \leq -1.65 \cdot 10^{+209}:\\
\;\;\;\;\mathsf{fma}\left(-0.5, b, \mathsf{fma}\left(z, t\_1, x\right)\right)\\
\mathbf{elif}\;z \leq 1.95 \cdot 10^{+226}:\\
\;\;\;\;\mathsf{fma}\left(a - 0.5, b, x + y\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\frac{1}{z \cdot t\_1}}\\
\end{array}
\end{array}
if z < -1.6499999999999999e209Initial program 99.8%
Taylor expanded in x around 0
Applied rewrites78.9%
Taylor expanded in a around 0
Applied rewrites55.1%
Taylor expanded in y around 0
lower--.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-log.f6454.7
Applied rewrites54.7%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6454.7
lift--.f64N/A
lift-+.f64N/A
associate--l+N/A
+-commutativeN/A
lift-*.f64N/A
*-rgt-identityN/A
distribute-lft-out--N/A
lower-fma.f64N/A
lower--.f6454.7
Applied rewrites54.7%
if -1.6499999999999999e209 < z < 1.94999999999999992e226Initial program 99.8%
Taylor expanded in z around 0
lower-+.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower--.f6478.3
Applied rewrites78.3%
lift-+.f64N/A
lift-+.f64N/A
associate-+r+N/A
lift-*.f64N/A
*-commutativeN/A
+-commutativeN/A
lower-fma.f64N/A
lower-+.f6478.3
Applied rewrites78.3%
if 1.94999999999999992e226 < z Initial program 99.8%
Taylor expanded in z around inf
lower-*.f64N/A
lower--.f64N/A
lower-log.f6422.8
Applied rewrites22.8%
lift-*.f64N/A
*-commutativeN/A
lift--.f64N/A
flip--N/A
associate-*l/N/A
lower-/.f64N/A
lower-*.f64N/A
metadata-evalN/A
lower--.f64N/A
lower-*.f64N/A
lower-+.f6422.5
Applied rewrites22.5%
lift-/.f64N/A
div-flipN/A
lower-/.f64N/A
div-flipN/A
lift-/.f64N/A
lower-/.f6422.5
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
lift--.f64N/A
metadata-evalN/A
lift-*.f64N/A
lift-+.f64N/A
flip--N/A
lower-*.f64N/A
Applied rewrites22.8%
(FPCore (x y z t a b)
:precision binary64
(let* ((t_1 (/ 1.0 (/ 1.0 (* z (- 1.0 (log t)))))))
(if (<= z -1.1e+251)
t_1
(if (<= z 1.95e+226) (fma (- a 0.5) b (+ x y)) t_1))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = 1.0 / (1.0 / (z * (1.0 - log(t))));
double tmp;
if (z <= -1.1e+251) {
tmp = t_1;
} else if (z <= 1.95e+226) {
tmp = fma((a - 0.5), b, (x + y));
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a, b) t_1 = Float64(1.0 / Float64(1.0 / Float64(z * Float64(1.0 - log(t))))) tmp = 0.0 if (z <= -1.1e+251) tmp = t_1; elseif (z <= 1.95e+226) tmp = fma(Float64(a - 0.5), b, Float64(x + y)); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(1.0 / N[(1.0 / N[(z * N[(1.0 - N[Log[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -1.1e+251], t$95$1, If[LessEqual[z, 1.95e+226], N[(N[(a - 0.5), $MachinePrecision] * b + N[(x + y), $MachinePrecision]), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{1}{\frac{1}{z \cdot \left(1 - \log t\right)}}\\
\mathbf{if}\;z \leq -1.1 \cdot 10^{+251}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \leq 1.95 \cdot 10^{+226}:\\
\;\;\;\;\mathsf{fma}\left(a - 0.5, b, x + y\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if z < -1.1e251 or 1.94999999999999992e226 < z Initial program 99.8%
Taylor expanded in z around inf
lower-*.f64N/A
lower--.f64N/A
lower-log.f6422.8
Applied rewrites22.8%
lift-*.f64N/A
*-commutativeN/A
lift--.f64N/A
flip--N/A
associate-*l/N/A
lower-/.f64N/A
lower-*.f64N/A
metadata-evalN/A
lower--.f64N/A
lower-*.f64N/A
lower-+.f6422.5
Applied rewrites22.5%
lift-/.f64N/A
div-flipN/A
lower-/.f64N/A
div-flipN/A
lift-/.f64N/A
lower-/.f6422.5
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
lift--.f64N/A
metadata-evalN/A
lift-*.f64N/A
lift-+.f64N/A
flip--N/A
lower-*.f64N/A
Applied rewrites22.8%
if -1.1e251 < z < 1.94999999999999992e226Initial program 99.8%
Taylor expanded in z around 0
lower-+.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower--.f6478.3
Applied rewrites78.3%
lift-+.f64N/A
lift-+.f64N/A
associate-+r+N/A
lift-*.f64N/A
*-commutativeN/A
+-commutativeN/A
lower-fma.f64N/A
lower-+.f6478.3
Applied rewrites78.3%
(FPCore (x y z t a b)
:precision binary64
(let* ((t_1 (* z (- 1.0 (log t)))))
(if (<= z -1.1e+251)
t_1
(if (<= z 1.95e+226) (fma (- a 0.5) b (+ x y)) t_1))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = z * (1.0 - log(t));
double tmp;
if (z <= -1.1e+251) {
tmp = t_1;
} else if (z <= 1.95e+226) {
tmp = fma((a - 0.5), b, (x + y));
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a, b) t_1 = Float64(z * Float64(1.0 - log(t))) tmp = 0.0 if (z <= -1.1e+251) tmp = t_1; elseif (z <= 1.95e+226) tmp = fma(Float64(a - 0.5), b, Float64(x + y)); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(z * N[(1.0 - N[Log[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -1.1e+251], t$95$1, If[LessEqual[z, 1.95e+226], N[(N[(a - 0.5), $MachinePrecision] * b + N[(x + y), $MachinePrecision]), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := z \cdot \left(1 - \log t\right)\\
\mathbf{if}\;z \leq -1.1 \cdot 10^{+251}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \leq 1.95 \cdot 10^{+226}:\\
\;\;\;\;\mathsf{fma}\left(a - 0.5, b, x + y\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if z < -1.1e251 or 1.94999999999999992e226 < z Initial program 99.8%
Taylor expanded in z around inf
lower-*.f64N/A
lower--.f64N/A
lower-log.f6422.8
Applied rewrites22.8%
if -1.1e251 < z < 1.94999999999999992e226Initial program 99.8%
Taylor expanded in z around 0
lower-+.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower--.f6478.3
Applied rewrites78.3%
lift-+.f64N/A
lift-+.f64N/A
associate-+r+N/A
lift-*.f64N/A
*-commutativeN/A
+-commutativeN/A
lower-fma.f64N/A
lower-+.f6478.3
Applied rewrites78.3%
(FPCore (x y z t a b) :precision binary64 (fma (- a 0.5) b (+ x y)))
double code(double x, double y, double z, double t, double a, double b) {
return fma((a - 0.5), b, (x + y));
}
function code(x, y, z, t, a, b) return fma(Float64(a - 0.5), b, Float64(x + y)) end
code[x_, y_, z_, t_, a_, b_] := N[(N[(a - 0.5), $MachinePrecision] * b + N[(x + y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(a - 0.5, b, x + y\right)
\end{array}
Initial program 99.8%
Taylor expanded in z around 0
lower-+.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower--.f6478.3
Applied rewrites78.3%
lift-+.f64N/A
lift-+.f64N/A
associate-+r+N/A
lift-*.f64N/A
*-commutativeN/A
+-commutativeN/A
lower-fma.f64N/A
lower-+.f6478.3
Applied rewrites78.3%
(FPCore (x y z t a b) :precision binary64 (if (<= (- (+ (+ x y) z) (* z (log t))) -1e-84) (+ x (* b (- a 0.5))) (fma (- a 0.5) b y)))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if ((((x + y) + z) - (z * log(t))) <= -1e-84) {
tmp = x + (b * (a - 0.5));
} else {
tmp = fma((a - 0.5), b, y);
}
return tmp;
}
function code(x, y, z, t, a, b) tmp = 0.0 if (Float64(Float64(Float64(x + y) + z) - Float64(z * log(t))) <= -1e-84) tmp = Float64(x + Float64(b * Float64(a - 0.5))); else tmp = fma(Float64(a - 0.5), b, y); end return tmp end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[N[(N[(N[(x + y), $MachinePrecision] + z), $MachinePrecision] - N[(z * N[Log[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], -1e-84], N[(x + N[(b * N[(a - 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(a - 0.5), $MachinePrecision] * b + y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\left(\left(x + y\right) + z\right) - z \cdot \log t \leq -1 \cdot 10^{-84}:\\
\;\;\;\;x + b \cdot \left(a - 0.5\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(a - 0.5, b, y\right)\\
\end{array}
\end{array}
if (-.f64 (+.f64 (+.f64 x y) z) (*.f64 z (log.f64 t))) < -1e-84Initial program 99.8%
Taylor expanded in z around 0
lower-+.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower--.f6478.3
Applied rewrites78.3%
Taylor expanded in y around 0
lower-*.f64N/A
lower--.f6457.4
Applied rewrites57.4%
if -1e-84 < (-.f64 (+.f64 (+.f64 x y) z) (*.f64 z (log.f64 t))) Initial program 99.8%
Taylor expanded in z around 0
lower-+.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower--.f6478.3
Applied rewrites78.3%
Taylor expanded in x around 0
lower-+.f64N/A
lower-*.f64N/A
lower--.f6457.9
Applied rewrites57.9%
lift-+.f64N/A
lift-*.f64N/A
*-commutativeN/A
+-commutativeN/A
lower-fma.f6457.9
Applied rewrites57.9%
(FPCore (x y z t a b) :precision binary64 (fma (- a 0.5) b y))
double code(double x, double y, double z, double t, double a, double b) {
return fma((a - 0.5), b, y);
}
function code(x, y, z, t, a, b) return fma(Float64(a - 0.5), b, y) end
code[x_, y_, z_, t_, a_, b_] := N[(N[(a - 0.5), $MachinePrecision] * b + y), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(a - 0.5, b, y\right)
\end{array}
Initial program 99.8%
Taylor expanded in z around 0
lower-+.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower--.f6478.3
Applied rewrites78.3%
Taylor expanded in x around 0
lower-+.f64N/A
lower-*.f64N/A
lower--.f6457.9
Applied rewrites57.9%
lift-+.f64N/A
lift-*.f64N/A
*-commutativeN/A
+-commutativeN/A
lower-fma.f6457.9
Applied rewrites57.9%
(FPCore (x y z t a b) :precision binary64 (let* ((t_1 (* (- a 0.5) b)) (t_2 (* b (- a 0.5)))) (if (<= t_1 -1e+133) t_2 (if (<= t_1 5e+164) (+ y (* -0.5 b)) t_2))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = (a - 0.5) * b;
double t_2 = b * (a - 0.5);
double tmp;
if (t_1 <= -1e+133) {
tmp = t_2;
} else if (t_1 <= 5e+164) {
tmp = y + (-0.5 * b);
} else {
tmp = t_2;
}
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) :: t_2
real(8) :: tmp
t_1 = (a - 0.5d0) * b
t_2 = b * (a - 0.5d0)
if (t_1 <= (-1d+133)) then
tmp = t_2
else if (t_1 <= 5d+164) then
tmp = y + ((-0.5d0) * b)
else
tmp = t_2
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 = (a - 0.5) * b;
double t_2 = b * (a - 0.5);
double tmp;
if (t_1 <= -1e+133) {
tmp = t_2;
} else if (t_1 <= 5e+164) {
tmp = y + (-0.5 * b);
} else {
tmp = t_2;
}
return tmp;
}
def code(x, y, z, t, a, b): t_1 = (a - 0.5) * b t_2 = b * (a - 0.5) tmp = 0 if t_1 <= -1e+133: tmp = t_2 elif t_1 <= 5e+164: tmp = y + (-0.5 * b) else: tmp = t_2 return tmp
function code(x, y, z, t, a, b) t_1 = Float64(Float64(a - 0.5) * b) t_2 = Float64(b * Float64(a - 0.5)) tmp = 0.0 if (t_1 <= -1e+133) tmp = t_2; elseif (t_1 <= 5e+164) tmp = Float64(y + Float64(-0.5 * b)); else tmp = t_2; end return tmp end
function tmp_2 = code(x, y, z, t, a, b) t_1 = (a - 0.5) * b; t_2 = b * (a - 0.5); tmp = 0.0; if (t_1 <= -1e+133) tmp = t_2; elseif (t_1 <= 5e+164) tmp = y + (-0.5 * b); else tmp = t_2; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(N[(a - 0.5), $MachinePrecision] * b), $MachinePrecision]}, Block[{t$95$2 = N[(b * N[(a - 0.5), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -1e+133], t$95$2, If[LessEqual[t$95$1, 5e+164], N[(y + N[(-0.5 * b), $MachinePrecision]), $MachinePrecision], t$95$2]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left(a - 0.5\right) \cdot b\\
t_2 := b \cdot \left(a - 0.5\right)\\
\mathbf{if}\;t\_1 \leq -1 \cdot 10^{+133}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;t\_1 \leq 5 \cdot 10^{+164}:\\
\;\;\;\;y + -0.5 \cdot b\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
if (*.f64 (-.f64 a #s(literal 1/2 binary64)) b) < -1e133 or 4.9999999999999995e164 < (*.f64 (-.f64 a #s(literal 1/2 binary64)) b) Initial program 99.8%
Taylor expanded in z around 0
lower-+.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower--.f6478.3
Applied rewrites78.3%
Taylor expanded in x around 0
lower-+.f64N/A
lower-*.f64N/A
lower--.f6457.9
Applied rewrites57.9%
Taylor expanded in y around 0
lower-*.f64N/A
lower--.f6437.4
Applied rewrites37.4%
if -1e133 < (*.f64 (-.f64 a #s(literal 1/2 binary64)) b) < 4.9999999999999995e164Initial program 99.8%
Taylor expanded in z around 0
lower-+.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower--.f6478.3
Applied rewrites78.3%
Taylor expanded in x around 0
lower-+.f64N/A
lower-*.f64N/A
lower--.f6457.9
Applied rewrites57.9%
Taylor expanded in a around 0
lower-*.f6434.2
Applied rewrites34.2%
(FPCore (x y z t a b) :precision binary64 (* b (- a 0.5)))
double code(double x, double y, double z, double t, double a, double b) {
return b * (a - 0.5);
}
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 = b * (a - 0.5d0)
end function
public static double code(double x, double y, double z, double t, double a, double b) {
return b * (a - 0.5);
}
def code(x, y, z, t, a, b): return b * (a - 0.5)
function code(x, y, z, t, a, b) return Float64(b * Float64(a - 0.5)) end
function tmp = code(x, y, z, t, a, b) tmp = b * (a - 0.5); end
code[x_, y_, z_, t_, a_, b_] := N[(b * N[(a - 0.5), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
b \cdot \left(a - 0.5\right)
\end{array}
Initial program 99.8%
Taylor expanded in z around 0
lower-+.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower--.f6478.3
Applied rewrites78.3%
Taylor expanded in x around 0
lower-+.f64N/A
lower-*.f64N/A
lower--.f6457.9
Applied rewrites57.9%
Taylor expanded in y around 0
lower-*.f64N/A
lower--.f6437.4
Applied rewrites37.4%
(FPCore (x y z t a b) :precision binary64 (* a b))
double code(double x, double y, double z, double t, double a, double b) {
return a * 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 = a * b
end function
public static double code(double x, double y, double z, double t, double a, double b) {
return a * b;
}
def code(x, y, z, t, a, b): return a * b
function code(x, y, z, t, a, b) return Float64(a * b) end
function tmp = code(x, y, z, t, a, b) tmp = a * b; end
code[x_, y_, z_, t_, a_, b_] := N[(a * b), $MachinePrecision]
\begin{array}{l}
\\
a \cdot b
\end{array}
Initial program 99.8%
Taylor expanded in a around inf
lower-*.f6425.7
Applied rewrites25.7%
herbie shell --seed 2025142
(FPCore (x y z t a b)
:name "Numeric.SpecFunctions:logBeta from math-functions-0.1.5.2, A"
:precision binary64
(+ (- (+ (+ x y) z) (* z (log t))) (* (- a 0.5) b)))