
(FPCore (x y z t a b c i) :precision binary64 (+ (+ (+ (+ (+ (* x (log y)) z) t) a) (* (- b 0.5) (log c))) (* y i)))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
return (((((x * log(y)) + z) + t) + a) + ((b - 0.5) * log(c))) + (y * i);
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z, t, a, b, c, i)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: i
code = (((((x * log(y)) + z) + t) + a) + ((b - 0.5d0) * log(c))) + (y * i)
end function
public static double code(double x, double y, double z, double t, double a, double b, double c, double i) {
return (((((x * Math.log(y)) + z) + t) + a) + ((b - 0.5) * Math.log(c))) + (y * i);
}
def code(x, y, z, t, a, b, c, i): return (((((x * math.log(y)) + z) + t) + a) + ((b - 0.5) * math.log(c))) + (y * i)
function code(x, y, z, t, a, b, c, i) return Float64(Float64(Float64(Float64(Float64(Float64(x * log(y)) + z) + t) + a) + Float64(Float64(b - 0.5) * log(c))) + Float64(y * i)) end
function tmp = code(x, y, z, t, a, b, c, i) tmp = (((((x * log(y)) + z) + t) + a) + ((b - 0.5) * log(c))) + (y * i); end
code[x_, y_, z_, t_, a_, b_, c_, i_] := N[(N[(N[(N[(N[(N[(x * N[Log[y], $MachinePrecision]), $MachinePrecision] + z), $MachinePrecision] + t), $MachinePrecision] + a), $MachinePrecision] + N[(N[(b - 0.5), $MachinePrecision] * N[Log[c], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(y * i), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(\left(\left(x \cdot \log y + z\right) + t\right) + a\right) + \left(b - 0.5\right) \cdot \log c\right) + y \cdot i
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 12 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z t a b c i) :precision binary64 (+ (+ (+ (+ (+ (* x (log y)) z) t) a) (* (- b 0.5) (log c))) (* y i)))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
return (((((x * log(y)) + z) + t) + a) + ((b - 0.5) * log(c))) + (y * i);
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z, t, a, b, c, i)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: i
code = (((((x * log(y)) + z) + t) + a) + ((b - 0.5d0) * log(c))) + (y * i)
end function
public static double code(double x, double y, double z, double t, double a, double b, double c, double i) {
return (((((x * Math.log(y)) + z) + t) + a) + ((b - 0.5) * Math.log(c))) + (y * i);
}
def code(x, y, z, t, a, b, c, i): return (((((x * math.log(y)) + z) + t) + a) + ((b - 0.5) * math.log(c))) + (y * i)
function code(x, y, z, t, a, b, c, i) return Float64(Float64(Float64(Float64(Float64(Float64(x * log(y)) + z) + t) + a) + Float64(Float64(b - 0.5) * log(c))) + Float64(y * i)) end
function tmp = code(x, y, z, t, a, b, c, i) tmp = (((((x * log(y)) + z) + t) + a) + ((b - 0.5) * log(c))) + (y * i); end
code[x_, y_, z_, t_, a_, b_, c_, i_] := N[(N[(N[(N[(N[(N[(x * N[Log[y], $MachinePrecision]), $MachinePrecision] + z), $MachinePrecision] + t), $MachinePrecision] + a), $MachinePrecision] + N[(N[(b - 0.5), $MachinePrecision] * N[Log[c], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(y * i), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(\left(\left(x \cdot \log y + z\right) + t\right) + a\right) + \left(b - 0.5\right) \cdot \log c\right) + y \cdot i
\end{array}
(FPCore (x y z t a b c i) :precision binary64 (fma y i (fma (log c) (- b 0.5) (+ a (+ t (fma (log y) x z))))))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
return fma(y, i, fma(log(c), (b - 0.5), (a + (t + fma(log(y), x, z)))));
}
function code(x, y, z, t, a, b, c, i) return fma(y, i, fma(log(c), Float64(b - 0.5), Float64(a + Float64(t + fma(log(y), x, z))))) end
code[x_, y_, z_, t_, a_, b_, c_, i_] := N[(y * i + N[(N[Log[c], $MachinePrecision] * N[(b - 0.5), $MachinePrecision] + N[(a + N[(t + N[(N[Log[y], $MachinePrecision] * x + z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(y, i, \mathsf{fma}\left(\log c, b - 0.5, a + \left(t + \mathsf{fma}\left(\log y, x, z\right)\right)\right)\right)
\end{array}
Initial program 99.8%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6499.8
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6499.9
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.9
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.9
lift-+.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6499.9
Applied rewrites99.9%
(FPCore (x y z t a b c i) :precision binary64 (if (or (<= x -7.5e+106) (not (<= x 1.22e+97))) (+ (fma i y (fma (log y) x (fma -0.5 (log c) z))) a) (+ (+ a t) (fma (- b 0.5) (log c) (fma i y z)))))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double tmp;
if ((x <= -7.5e+106) || !(x <= 1.22e+97)) {
tmp = fma(i, y, fma(log(y), x, fma(-0.5, log(c), z))) + a;
} else {
tmp = (a + t) + fma((b - 0.5), log(c), fma(i, y, z));
}
return tmp;
}
function code(x, y, z, t, a, b, c, i) tmp = 0.0 if ((x <= -7.5e+106) || !(x <= 1.22e+97)) tmp = Float64(fma(i, y, fma(log(y), x, fma(-0.5, log(c), z))) + a); else tmp = Float64(Float64(a + t) + fma(Float64(b - 0.5), log(c), fma(i, y, z))); end return tmp end
code[x_, y_, z_, t_, a_, b_, c_, i_] := If[Or[LessEqual[x, -7.5e+106], N[Not[LessEqual[x, 1.22e+97]], $MachinePrecision]], N[(N[(i * y + N[(N[Log[y], $MachinePrecision] * x + N[(-0.5 * N[Log[c], $MachinePrecision] + z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + a), $MachinePrecision], N[(N[(a + t), $MachinePrecision] + N[(N[(b - 0.5), $MachinePrecision] * N[Log[c], $MachinePrecision] + N[(i * y + z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -7.5 \cdot 10^{+106} \lor \neg \left(x \leq 1.22 \cdot 10^{+97}\right):\\
\;\;\;\;\mathsf{fma}\left(i, y, \mathsf{fma}\left(\log y, x, \mathsf{fma}\left(-0.5, \log c, z\right)\right)\right) + a\\
\mathbf{else}:\\
\;\;\;\;\left(a + t\right) + \mathsf{fma}\left(b - 0.5, \log c, \mathsf{fma}\left(i, y, z\right)\right)\\
\end{array}
\end{array}
if x < -7.50000000000000058e106 or 1.21999999999999997e97 < x Initial program 99.7%
Taylor expanded in t around 0
+-commutativeN/A
lower-+.f64N/A
Applied rewrites90.3%
Taylor expanded in b around 0
Applied rewrites82.2%
if -7.50000000000000058e106 < x < 1.21999999999999997e97Initial program 99.9%
Taylor expanded in x around 0
associate-+r+N/A
lower-+.f64N/A
lower-+.f64N/A
associate-+r+N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
lower-log.f64N/A
+-commutativeN/A
lower-fma.f6499.9
Applied rewrites99.9%
Final simplification93.6%
(FPCore (x y z t a b c i) :precision binary64 (if (or (<= x -5.4e+132) (not (<= x 9.6e+94))) (fma (- b 0.5) (log c) (fma (log y) x (+ z a))) (+ (+ a t) (fma (- b 0.5) (log c) (fma i y z)))))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double tmp;
if ((x <= -5.4e+132) || !(x <= 9.6e+94)) {
tmp = fma((b - 0.5), log(c), fma(log(y), x, (z + a)));
} else {
tmp = (a + t) + fma((b - 0.5), log(c), fma(i, y, z));
}
return tmp;
}
function code(x, y, z, t, a, b, c, i) tmp = 0.0 if ((x <= -5.4e+132) || !(x <= 9.6e+94)) tmp = fma(Float64(b - 0.5), log(c), fma(log(y), x, Float64(z + a))); else tmp = Float64(Float64(a + t) + fma(Float64(b - 0.5), log(c), fma(i, y, z))); end return tmp end
code[x_, y_, z_, t_, a_, b_, c_, i_] := If[Or[LessEqual[x, -5.4e+132], N[Not[LessEqual[x, 9.6e+94]], $MachinePrecision]], N[(N[(b - 0.5), $MachinePrecision] * N[Log[c], $MachinePrecision] + N[(N[Log[y], $MachinePrecision] * x + N[(z + a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(a + t), $MachinePrecision] + N[(N[(b - 0.5), $MachinePrecision] * N[Log[c], $MachinePrecision] + N[(i * y + z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -5.4 \cdot 10^{+132} \lor \neg \left(x \leq 9.6 \cdot 10^{+94}\right):\\
\;\;\;\;\mathsf{fma}\left(b - 0.5, \log c, \mathsf{fma}\left(\log y, x, z + a\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\left(a + t\right) + \mathsf{fma}\left(b - 0.5, \log c, \mathsf{fma}\left(i, y, z\right)\right)\\
\end{array}
\end{array}
if x < -5.3999999999999999e132 or 9.5999999999999993e94 < x Initial program 99.7%
Taylor expanded in t around 0
+-commutativeN/A
lower-+.f64N/A
Applied rewrites90.6%
Taylor expanded in i around inf
Applied rewrites59.0%
Taylor expanded in y around 0
Applied rewrites76.0%
Applied rewrites76.0%
if -5.3999999999999999e132 < x < 9.5999999999999993e94Initial program 99.9%
Taylor expanded in x around 0
associate-+r+N/A
lower-+.f64N/A
lower-+.f64N/A
associate-+r+N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
lower-log.f64N/A
+-commutativeN/A
lower-fma.f6498.3
Applied rewrites98.3%
Final simplification91.0%
(FPCore (x y z t a b c i) :precision binary64 (+ (fma i y (fma (log y) x (fma (- b 0.5) (log c) z))) a))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
return fma(i, y, fma(log(y), x, fma((b - 0.5), log(c), z))) + a;
}
function code(x, y, z, t, a, b, c, i) return Float64(fma(i, y, fma(log(y), x, fma(Float64(b - 0.5), log(c), z))) + a) end
code[x_, y_, z_, t_, a_, b_, c_, i_] := N[(N[(i * y + N[(N[Log[y], $MachinePrecision] * x + N[(N[(b - 0.5), $MachinePrecision] * N[Log[c], $MachinePrecision] + z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + a), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(i, y, \mathsf{fma}\left(\log y, x, \mathsf{fma}\left(b - 0.5, \log c, z\right)\right)\right) + a
\end{array}
Initial program 99.8%
Taylor expanded in t around 0
+-commutativeN/A
lower-+.f64N/A
Applied rewrites83.7%
(FPCore (x y z t a b c i)
:precision binary64
(if (<= x -5.5e+174)
(+ (+ a z) (fma -0.5 (log c) (* x (log y))))
(if (<= x 1.1e+210)
(+ (+ a t) (fma (- b 0.5) (log c) (fma i y z)))
(+ (* (log y) x) (* y i)))))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double tmp;
if (x <= -5.5e+174) {
tmp = (a + z) + fma(-0.5, log(c), (x * log(y)));
} else if (x <= 1.1e+210) {
tmp = (a + t) + fma((b - 0.5), log(c), fma(i, y, z));
} else {
tmp = (log(y) * x) + (y * i);
}
return tmp;
}
function code(x, y, z, t, a, b, c, i) tmp = 0.0 if (x <= -5.5e+174) tmp = Float64(Float64(a + z) + fma(-0.5, log(c), Float64(x * log(y)))); elseif (x <= 1.1e+210) tmp = Float64(Float64(a + t) + fma(Float64(b - 0.5), log(c), fma(i, y, z))); else tmp = Float64(Float64(log(y) * x) + Float64(y * i)); end return tmp end
code[x_, y_, z_, t_, a_, b_, c_, i_] := If[LessEqual[x, -5.5e+174], N[(N[(a + z), $MachinePrecision] + N[(-0.5 * N[Log[c], $MachinePrecision] + N[(x * N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.1e+210], N[(N[(a + t), $MachinePrecision] + N[(N[(b - 0.5), $MachinePrecision] * N[Log[c], $MachinePrecision] + N[(i * y + z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[Log[y], $MachinePrecision] * x), $MachinePrecision] + N[(y * i), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -5.5 \cdot 10^{+174}:\\
\;\;\;\;\left(a + z\right) + \mathsf{fma}\left(-0.5, \log c, x \cdot \log y\right)\\
\mathbf{elif}\;x \leq 1.1 \cdot 10^{+210}:\\
\;\;\;\;\left(a + t\right) + \mathsf{fma}\left(b - 0.5, \log c, \mathsf{fma}\left(i, y, z\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\log y \cdot x + y \cdot i\\
\end{array}
\end{array}
if x < -5.4999999999999998e174Initial program 99.5%
Taylor expanded in t around 0
+-commutativeN/A
lower-+.f64N/A
Applied rewrites92.7%
Taylor expanded in i around inf
Applied rewrites51.6%
Taylor expanded in y around 0
Applied rewrites81.9%
Taylor expanded in b around 0
Applied rewrites75.8%
if -5.4999999999999998e174 < x < 1.09999999999999993e210Initial program 99.9%
Taylor expanded in x around 0
associate-+r+N/A
lower-+.f64N/A
lower-+.f64N/A
associate-+r+N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
lower-log.f64N/A
+-commutativeN/A
lower-fma.f6494.1
Applied rewrites94.1%
if 1.09999999999999993e210 < x Initial program 99.7%
lift-+.f64N/A
lift-+.f64N/A
associate-+l+N/A
lift-+.f64N/A
flip-+N/A
flip-+N/A
frac-addN/A
lower-/.f64N/A
Applied rewrites1.6%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites99.8%
Taylor expanded in x around inf
Applied rewrites83.9%
(FPCore (x y z t a b c i) :precision binary64 (if (or (<= x -1.7e+207) (not (<= x 1.1e+210))) (+ (* (log y) x) (* y i)) (+ (+ a t) (fma (- b 0.5) (log c) (fma i y z)))))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double tmp;
if ((x <= -1.7e+207) || !(x <= 1.1e+210)) {
tmp = (log(y) * x) + (y * i);
} else {
tmp = (a + t) + fma((b - 0.5), log(c), fma(i, y, z));
}
return tmp;
}
function code(x, y, z, t, a, b, c, i) tmp = 0.0 if ((x <= -1.7e+207) || !(x <= 1.1e+210)) tmp = Float64(Float64(log(y) * x) + Float64(y * i)); else tmp = Float64(Float64(a + t) + fma(Float64(b - 0.5), log(c), fma(i, y, z))); end return tmp end
code[x_, y_, z_, t_, a_, b_, c_, i_] := If[Or[LessEqual[x, -1.7e+207], N[Not[LessEqual[x, 1.1e+210]], $MachinePrecision]], N[(N[(N[Log[y], $MachinePrecision] * x), $MachinePrecision] + N[(y * i), $MachinePrecision]), $MachinePrecision], N[(N[(a + t), $MachinePrecision] + N[(N[(b - 0.5), $MachinePrecision] * N[Log[c], $MachinePrecision] + N[(i * y + z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.7 \cdot 10^{+207} \lor \neg \left(x \leq 1.1 \cdot 10^{+210}\right):\\
\;\;\;\;\log y \cdot x + y \cdot i\\
\mathbf{else}:\\
\;\;\;\;\left(a + t\right) + \mathsf{fma}\left(b - 0.5, \log c, \mathsf{fma}\left(i, y, z\right)\right)\\
\end{array}
\end{array}
if x < -1.6999999999999999e207 or 1.09999999999999993e210 < x Initial program 99.6%
lift-+.f64N/A
lift-+.f64N/A
associate-+l+N/A
lift-+.f64N/A
flip-+N/A
flip-+N/A
frac-addN/A
lower-/.f64N/A
Applied rewrites1.0%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites99.6%
Taylor expanded in x around inf
Applied rewrites83.0%
if -1.6999999999999999e207 < x < 1.09999999999999993e210Initial program 99.9%
Taylor expanded in x around 0
associate-+r+N/A
lower-+.f64N/A
lower-+.f64N/A
associate-+r+N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
lower-log.f64N/A
+-commutativeN/A
lower-fma.f6493.4
Applied rewrites93.4%
Final simplification91.6%
(FPCore (x y z t a b c i) :precision binary64 (if (or (<= x -1.7e+207) (not (<= x 1.1e+210))) (+ (* (log y) x) (* y i)) (fma y i (+ (fma (- b 0.5) (log c) z) a))))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double tmp;
if ((x <= -1.7e+207) || !(x <= 1.1e+210)) {
tmp = (log(y) * x) + (y * i);
} else {
tmp = fma(y, i, (fma((b - 0.5), log(c), z) + a));
}
return tmp;
}
function code(x, y, z, t, a, b, c, i) tmp = 0.0 if ((x <= -1.7e+207) || !(x <= 1.1e+210)) tmp = Float64(Float64(log(y) * x) + Float64(y * i)); else tmp = fma(y, i, Float64(fma(Float64(b - 0.5), log(c), z) + a)); end return tmp end
code[x_, y_, z_, t_, a_, b_, c_, i_] := If[Or[LessEqual[x, -1.7e+207], N[Not[LessEqual[x, 1.1e+210]], $MachinePrecision]], N[(N[(N[Log[y], $MachinePrecision] * x), $MachinePrecision] + N[(y * i), $MachinePrecision]), $MachinePrecision], N[(y * i + N[(N[(N[(b - 0.5), $MachinePrecision] * N[Log[c], $MachinePrecision] + z), $MachinePrecision] + a), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.7 \cdot 10^{+207} \lor \neg \left(x \leq 1.1 \cdot 10^{+210}\right):\\
\;\;\;\;\log y \cdot x + y \cdot i\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(y, i, \mathsf{fma}\left(b - 0.5, \log c, z\right) + a\right)\\
\end{array}
\end{array}
if x < -1.6999999999999999e207 or 1.09999999999999993e210 < x Initial program 99.6%
lift-+.f64N/A
lift-+.f64N/A
associate-+l+N/A
lift-+.f64N/A
flip-+N/A
flip-+N/A
frac-addN/A
lower-/.f64N/A
Applied rewrites1.0%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites99.6%
Taylor expanded in x around inf
Applied rewrites83.0%
if -1.6999999999999999e207 < x < 1.09999999999999993e210Initial program 99.9%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6499.9
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6499.9
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.9
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.9
lift-+.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6499.9
Applied rewrites99.9%
Taylor expanded in x around 0
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
lower-fma.f64N/A
lower-log.f64N/A
lower--.f6493.4
Applied rewrites93.4%
Taylor expanded in t around 0
Applied rewrites75.1%
Final simplification76.4%
(FPCore (x y z t a b c i) :precision binary64 (if (or (<= x -1.7e+207) (not (<= x 1.1e+210))) (+ (* (log y) x) (* y i)) (+ (fma i y (fma (log c) (- b 0.5) z)) a)))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double tmp;
if ((x <= -1.7e+207) || !(x <= 1.1e+210)) {
tmp = (log(y) * x) + (y * i);
} else {
tmp = fma(i, y, fma(log(c), (b - 0.5), z)) + a;
}
return tmp;
}
function code(x, y, z, t, a, b, c, i) tmp = 0.0 if ((x <= -1.7e+207) || !(x <= 1.1e+210)) tmp = Float64(Float64(log(y) * x) + Float64(y * i)); else tmp = Float64(fma(i, y, fma(log(c), Float64(b - 0.5), z)) + a); end return tmp end
code[x_, y_, z_, t_, a_, b_, c_, i_] := If[Or[LessEqual[x, -1.7e+207], N[Not[LessEqual[x, 1.1e+210]], $MachinePrecision]], N[(N[(N[Log[y], $MachinePrecision] * x), $MachinePrecision] + N[(y * i), $MachinePrecision]), $MachinePrecision], N[(N[(i * y + N[(N[Log[c], $MachinePrecision] * N[(b - 0.5), $MachinePrecision] + z), $MachinePrecision]), $MachinePrecision] + a), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.7 \cdot 10^{+207} \lor \neg \left(x \leq 1.1 \cdot 10^{+210}\right):\\
\;\;\;\;\log y \cdot x + y \cdot i\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(i, y, \mathsf{fma}\left(\log c, b - 0.5, z\right)\right) + a\\
\end{array}
\end{array}
if x < -1.6999999999999999e207 or 1.09999999999999993e210 < x Initial program 99.6%
lift-+.f64N/A
lift-+.f64N/A
associate-+l+N/A
lift-+.f64N/A
flip-+N/A
flip-+N/A
frac-addN/A
lower-/.f64N/A
Applied rewrites1.0%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites99.6%
Taylor expanded in x around inf
Applied rewrites83.0%
if -1.6999999999999999e207 < x < 1.09999999999999993e210Initial program 99.9%
Taylor expanded in t around 0
+-commutativeN/A
lower-+.f64N/A
Applied rewrites81.7%
Taylor expanded in x around 0
Applied rewrites75.1%
Final simplification76.4%
(FPCore (x y z t a b c i) :precision binary64 (if (or (<= i -7.5e-26) (not (<= i 1.06e+155))) (+ (* (+ (/ z i) y) i) a) (+ (fma (log c) (- b 0.5) z) a)))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double tmp;
if ((i <= -7.5e-26) || !(i <= 1.06e+155)) {
tmp = (((z / i) + y) * i) + a;
} else {
tmp = fma(log(c), (b - 0.5), z) + a;
}
return tmp;
}
function code(x, y, z, t, a, b, c, i) tmp = 0.0 if ((i <= -7.5e-26) || !(i <= 1.06e+155)) tmp = Float64(Float64(Float64(Float64(z / i) + y) * i) + a); else tmp = Float64(fma(log(c), Float64(b - 0.5), z) + a); end return tmp end
code[x_, y_, z_, t_, a_, b_, c_, i_] := If[Or[LessEqual[i, -7.5e-26], N[Not[LessEqual[i, 1.06e+155]], $MachinePrecision]], N[(N[(N[(N[(z / i), $MachinePrecision] + y), $MachinePrecision] * i), $MachinePrecision] + a), $MachinePrecision], N[(N[(N[Log[c], $MachinePrecision] * N[(b - 0.5), $MachinePrecision] + z), $MachinePrecision] + a), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;i \leq -7.5 \cdot 10^{-26} \lor \neg \left(i \leq 1.06 \cdot 10^{+155}\right):\\
\;\;\;\;\left(\frac{z}{i} + y\right) \cdot i + a\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\log c, b - 0.5, z\right) + a\\
\end{array}
\end{array}
if i < -7.4999999999999994e-26 or 1.06000000000000005e155 < i Initial program 99.9%
Taylor expanded in t around 0
+-commutativeN/A
lower-+.f64N/A
Applied rewrites87.4%
Taylor expanded in i around inf
Applied rewrites87.3%
Taylor expanded in z around inf
Applied rewrites66.6%
if -7.4999999999999994e-26 < i < 1.06000000000000005e155Initial program 99.8%
Taylor expanded in t around 0
+-commutativeN/A
lower-+.f64N/A
Applied rewrites81.3%
Taylor expanded in i around inf
Applied rewrites39.7%
Taylor expanded in y around 0
Applied rewrites76.3%
Taylor expanded in x around 0
Applied rewrites53.2%
Final simplification58.6%
(FPCore (x y z t a b c i) :precision binary64 (if (or (<= x -6.2e+174) (not (<= x 1.05e+210))) (* (log y) x) (+ (* (+ (/ z i) y) i) a)))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double tmp;
if ((x <= -6.2e+174) || !(x <= 1.05e+210)) {
tmp = log(y) * x;
} else {
tmp = (((z / i) + y) * i) + a;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z, t, a, b, c, i)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: i
real(8) :: tmp
if ((x <= (-6.2d+174)) .or. (.not. (x <= 1.05d+210))) then
tmp = log(y) * x
else
tmp = (((z / i) + y) * i) + a
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double tmp;
if ((x <= -6.2e+174) || !(x <= 1.05e+210)) {
tmp = Math.log(y) * x;
} else {
tmp = (((z / i) + y) * i) + a;
}
return tmp;
}
def code(x, y, z, t, a, b, c, i): tmp = 0 if (x <= -6.2e+174) or not (x <= 1.05e+210): tmp = math.log(y) * x else: tmp = (((z / i) + y) * i) + a return tmp
function code(x, y, z, t, a, b, c, i) tmp = 0.0 if ((x <= -6.2e+174) || !(x <= 1.05e+210)) tmp = Float64(log(y) * x); else tmp = Float64(Float64(Float64(Float64(z / i) + y) * i) + a); end return tmp end
function tmp_2 = code(x, y, z, t, a, b, c, i) tmp = 0.0; if ((x <= -6.2e+174) || ~((x <= 1.05e+210))) tmp = log(y) * x; else tmp = (((z / i) + y) * i) + a; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_, c_, i_] := If[Or[LessEqual[x, -6.2e+174], N[Not[LessEqual[x, 1.05e+210]], $MachinePrecision]], N[(N[Log[y], $MachinePrecision] * x), $MachinePrecision], N[(N[(N[(N[(z / i), $MachinePrecision] + y), $MachinePrecision] * i), $MachinePrecision] + a), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -6.2 \cdot 10^{+174} \lor \neg \left(x \leq 1.05 \cdot 10^{+210}\right):\\
\;\;\;\;\log y \cdot x\\
\mathbf{else}:\\
\;\;\;\;\left(\frac{z}{i} + y\right) \cdot i + a\\
\end{array}
\end{array}
if x < -6.2e174 or 1.0499999999999999e210 < x Initial program 99.6%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6499.6
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6499.6
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.6
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.6
lift-+.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6499.6
Applied rewrites99.6%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
lower-log.f6464.4
Applied rewrites64.4%
if -6.2e174 < x < 1.0499999999999999e210Initial program 99.9%
Taylor expanded in t around 0
+-commutativeN/A
lower-+.f64N/A
Applied rewrites81.7%
Taylor expanded in i around inf
Applied rewrites61.4%
Taylor expanded in z around inf
Applied rewrites50.0%
Final simplification52.8%
(FPCore (x y z t a b c i) :precision binary64 (+ (* (+ (/ z i) y) i) a))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
return (((z / i) + y) * i) + a;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z, t, a, b, c, i)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: i
code = (((z / i) + y) * i) + a
end function
public static double code(double x, double y, double z, double t, double a, double b, double c, double i) {
return (((z / i) + y) * i) + a;
}
def code(x, y, z, t, a, b, c, i): return (((z / i) + y) * i) + a
function code(x, y, z, t, a, b, c, i) return Float64(Float64(Float64(Float64(z / i) + y) * i) + a) end
function tmp = code(x, y, z, t, a, b, c, i) tmp = (((z / i) + y) * i) + a; end
code[x_, y_, z_, t_, a_, b_, c_, i_] := N[(N[(N[(N[(z / i), $MachinePrecision] + y), $MachinePrecision] * i), $MachinePrecision] + a), $MachinePrecision]
\begin{array}{l}
\\
\left(\frac{z}{i} + y\right) \cdot i + a
\end{array}
Initial program 99.8%
Taylor expanded in t around 0
+-commutativeN/A
lower-+.f64N/A
Applied rewrites83.7%
Taylor expanded in i around inf
Applied rewrites59.0%
Taylor expanded in z around inf
Applied rewrites44.0%
(FPCore (x y z t a b c i) :precision binary64 (* i y))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
return i * y;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z, t, a, b, c, i)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: i
code = i * y
end function
public static double code(double x, double y, double z, double t, double a, double b, double c, double i) {
return i * y;
}
def code(x, y, z, t, a, b, c, i): return i * y
function code(x, y, z, t, a, b, c, i) return Float64(i * y) end
function tmp = code(x, y, z, t, a, b, c, i) tmp = i * y; end
code[x_, y_, z_, t_, a_, b_, c_, i_] := N[(i * y), $MachinePrecision]
\begin{array}{l}
\\
i \cdot y
\end{array}
Initial program 99.8%
Taylor expanded in y around inf
lower-*.f6423.5
Applied rewrites23.5%
herbie shell --seed 2025008
(FPCore (x y z t a b c i)
:name "Numeric.SpecFunctions:logBeta from math-functions-0.1.5.2, B"
:precision binary64
(+ (+ (+ (+ (+ (* x (log y)) z) t) a) (* (- b 0.5) (log c))) (* y i)))