
(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}
Sampling outcomes in binary64 precision:
Herbie found 15 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 (fma (- z) (log t) (+ z (+ y x)))))
double code(double x, double y, double z, double t, double a, double b) {
return fma((a - 0.5), b, fma(-z, log(t), (z + (y + x))));
}
function code(x, y, z, t, a, b) return fma(Float64(a - 0.5), b, fma(Float64(-z), log(t), Float64(z + Float64(y + x)))) end
code[x_, y_, z_, t_, a_, b_] := N[(N[(a - 0.5), $MachinePrecision] * b + N[((-z) * N[Log[t], $MachinePrecision] + N[(z + N[(y + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(a - 0.5, b, \mathsf{fma}\left(-z, \log t, z + \left(y + x\right)\right)\right)
\end{array}
Initial program 99.8%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6499.9
lift--.f64N/A
lift-*.f64N/A
fp-cancel-sub-sign-invN/A
+-commutativeN/A
lower-fma.f64N/A
lower-neg.f6499.9
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.9
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.9
Applied rewrites99.9%
(FPCore (x y z t a b)
:precision binary64
(let* ((t_1 (- 1.0 (log t))) (t_2 (* (- a 0.5) b)))
(if (<= t_2 -4e+96)
(fma (- a 0.5) b (+ y x))
(if (<= t_2 2e+164) (fma t_1 z (+ y x)) (fma (- a 0.5) b (* t_1 z))))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = 1.0 - log(t);
double t_2 = (a - 0.5) * b;
double tmp;
if (t_2 <= -4e+96) {
tmp = fma((a - 0.5), b, (y + x));
} else if (t_2 <= 2e+164) {
tmp = fma(t_1, z, (y + x));
} else {
tmp = fma((a - 0.5), b, (t_1 * z));
}
return tmp;
}
function code(x, y, z, t, a, b) t_1 = Float64(1.0 - log(t)) t_2 = Float64(Float64(a - 0.5) * b) tmp = 0.0 if (t_2 <= -4e+96) tmp = fma(Float64(a - 0.5), b, Float64(y + x)); elseif (t_2 <= 2e+164) tmp = fma(t_1, z, Float64(y + x)); else tmp = fma(Float64(a - 0.5), b, Float64(t_1 * z)); end return tmp end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(1.0 - N[Log[t], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(a - 0.5), $MachinePrecision] * b), $MachinePrecision]}, If[LessEqual[t$95$2, -4e+96], N[(N[(a - 0.5), $MachinePrecision] * b + N[(y + x), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, 2e+164], N[(t$95$1 * z + N[(y + x), $MachinePrecision]), $MachinePrecision], N[(N[(a - 0.5), $MachinePrecision] * b + N[(t$95$1 * z), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := 1 - \log t\\
t_2 := \left(a - 0.5\right) \cdot b\\
\mathbf{if}\;t\_2 \leq -4 \cdot 10^{+96}:\\
\;\;\;\;\mathsf{fma}\left(a - 0.5, b, y + x\right)\\
\mathbf{elif}\;t\_2 \leq 2 \cdot 10^{+164}:\\
\;\;\;\;\mathsf{fma}\left(t\_1, z, y + x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(a - 0.5, b, t\_1 \cdot z\right)\\
\end{array}
\end{array}
if (*.f64 (-.f64 a #s(literal 1/2 binary64)) b) < -4.0000000000000002e96Initial program 99.9%
Taylor expanded in z around 0
+-commutativeN/A
+-commutativeN/A
associate-+l+N/A
*-commutativeN/A
+-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
+-commutativeN/A
lower-+.f6492.2
Applied rewrites92.2%
if -4.0000000000000002e96 < (*.f64 (-.f64 a #s(literal 1/2 binary64)) b) < 2e164Initial program 99.8%
Taylor expanded in z around 0
+-commutativeN/A
+-commutativeN/A
associate-+l+N/A
*-commutativeN/A
+-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
+-commutativeN/A
lower-+.f6470.0
Applied rewrites70.0%
Taylor expanded in b around 0
fp-cancel-sub-sign-invN/A
associate-+r+N/A
distribute-lft-neg-inN/A
mul-1-negN/A
associate-+r+N/A
+-commutativeN/A
Applied rewrites93.5%
if 2e164 < (*.f64 (-.f64 a #s(literal 1/2 binary64)) b) Initial program 99.9%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f64100.0
lift--.f64N/A
lift-*.f64N/A
fp-cancel-sub-sign-invN/A
+-commutativeN/A
lower-fma.f64N/A
lower-neg.f6499.9
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.9
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.9
Applied rewrites99.9%
Taylor expanded in y around 0
+-commutativeN/A
+-commutativeN/A
mul-1-negN/A
*-commutativeN/A
distribute-lft-neg-inN/A
mul-1-negN/A
distribute-lft1-inN/A
+-commutativeN/A
*-commutativeN/A
*-lft-identityN/A
metadata-evalN/A
distribute-lft-neg-outN/A
mul-1-negN/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
mul-1-negN/A
distribute-lft-neg-outN/A
metadata-evalN/A
*-lft-identityN/A
Applied rewrites97.8%
Taylor expanded in x around 0
Applied rewrites93.5%
(FPCore (x y z t a b)
:precision binary64
(let* ((t_1 (- 1.0 (log t))) (t_2 (* (- a 0.5) b)))
(if (<= t_2 -4e+96)
(fma (- a 0.5) b (+ y x))
(if (<= t_2 2e+164) (fma t_1 z (+ y x)) (fma t_1 z t_2)))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = 1.0 - log(t);
double t_2 = (a - 0.5) * b;
double tmp;
if (t_2 <= -4e+96) {
tmp = fma((a - 0.5), b, (y + x));
} else if (t_2 <= 2e+164) {
tmp = fma(t_1, z, (y + x));
} else {
tmp = fma(t_1, z, t_2);
}
return tmp;
}
function code(x, y, z, t, a, b) t_1 = Float64(1.0 - log(t)) t_2 = Float64(Float64(a - 0.5) * b) tmp = 0.0 if (t_2 <= -4e+96) tmp = fma(Float64(a - 0.5), b, Float64(y + x)); elseif (t_2 <= 2e+164) tmp = fma(t_1, z, Float64(y + x)); else tmp = fma(t_1, z, t_2); end return tmp end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(1.0 - N[Log[t], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(a - 0.5), $MachinePrecision] * b), $MachinePrecision]}, If[LessEqual[t$95$2, -4e+96], N[(N[(a - 0.5), $MachinePrecision] * b + N[(y + x), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, 2e+164], N[(t$95$1 * z + N[(y + x), $MachinePrecision]), $MachinePrecision], N[(t$95$1 * z + t$95$2), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := 1 - \log t\\
t_2 := \left(a - 0.5\right) \cdot b\\
\mathbf{if}\;t\_2 \leq -4 \cdot 10^{+96}:\\
\;\;\;\;\mathsf{fma}\left(a - 0.5, b, y + x\right)\\
\mathbf{elif}\;t\_2 \leq 2 \cdot 10^{+164}:\\
\;\;\;\;\mathsf{fma}\left(t\_1, z, y + x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(t\_1, z, t\_2\right)\\
\end{array}
\end{array}
if (*.f64 (-.f64 a #s(literal 1/2 binary64)) b) < -4.0000000000000002e96Initial program 99.9%
Taylor expanded in z around 0
+-commutativeN/A
+-commutativeN/A
associate-+l+N/A
*-commutativeN/A
+-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
+-commutativeN/A
lower-+.f6492.2
Applied rewrites92.2%
if -4.0000000000000002e96 < (*.f64 (-.f64 a #s(literal 1/2 binary64)) b) < 2e164Initial program 99.8%
Taylor expanded in z around 0
+-commutativeN/A
+-commutativeN/A
associate-+l+N/A
*-commutativeN/A
+-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
+-commutativeN/A
lower-+.f6470.0
Applied rewrites70.0%
Taylor expanded in b around 0
fp-cancel-sub-sign-invN/A
associate-+r+N/A
distribute-lft-neg-inN/A
mul-1-negN/A
associate-+r+N/A
+-commutativeN/A
Applied rewrites93.5%
if 2e164 < (*.f64 (-.f64 a #s(literal 1/2 binary64)) b) Initial program 99.9%
Taylor expanded in x around 0
associate--l+N/A
+-commutativeN/A
associate--l+N/A
*-rgt-identityN/A
distribute-lft-out--N/A
*-commutativeN/A
*-commutativeN/A
fp-cancel-sign-sub-invN/A
associate-+r-N/A
fp-cancel-sign-sub-invN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
lower-log.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f6495.8
Applied rewrites95.8%
Taylor expanded in y around 0
Applied rewrites93.5%
(FPCore (x y z t a b)
:precision binary64
(let* ((t_1 (* (- a 0.5) b)))
(if (or (<= t_1 -4e+96) (not (<= t_1 1e+158)))
(fma (- a 0.5) b (+ y x))
(fma (- 1.0 (log t)) z (+ y x)))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = (a - 0.5) * b;
double tmp;
if ((t_1 <= -4e+96) || !(t_1 <= 1e+158)) {
tmp = fma((a - 0.5), b, (y + x));
} else {
tmp = fma((1.0 - log(t)), z, (y + x));
}
return tmp;
}
function code(x, y, z, t, a, b) t_1 = Float64(Float64(a - 0.5) * b) tmp = 0.0 if ((t_1 <= -4e+96) || !(t_1 <= 1e+158)) tmp = fma(Float64(a - 0.5), b, Float64(y + x)); else tmp = fma(Float64(1.0 - log(t)), z, Float64(y + x)); end return tmp end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(N[(a - 0.5), $MachinePrecision] * b), $MachinePrecision]}, If[Or[LessEqual[t$95$1, -4e+96], N[Not[LessEqual[t$95$1, 1e+158]], $MachinePrecision]], N[(N[(a - 0.5), $MachinePrecision] * b + N[(y + x), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 - N[Log[t], $MachinePrecision]), $MachinePrecision] * z + N[(y + x), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left(a - 0.5\right) \cdot b\\
\mathbf{if}\;t\_1 \leq -4 \cdot 10^{+96} \lor \neg \left(t\_1 \leq 10^{+158}\right):\\
\;\;\;\;\mathsf{fma}\left(a - 0.5, b, y + x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(1 - \log t, z, y + x\right)\\
\end{array}
\end{array}
if (*.f64 (-.f64 a #s(literal 1/2 binary64)) b) < -4.0000000000000002e96 or 9.99999999999999953e157 < (*.f64 (-.f64 a #s(literal 1/2 binary64)) b) Initial program 99.9%
Taylor expanded in z around 0
+-commutativeN/A
+-commutativeN/A
associate-+l+N/A
*-commutativeN/A
+-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
+-commutativeN/A
lower-+.f6492.3
Applied rewrites92.3%
if -4.0000000000000002e96 < (*.f64 (-.f64 a #s(literal 1/2 binary64)) b) < 9.99999999999999953e157Initial program 99.8%
Taylor expanded in z around 0
+-commutativeN/A
+-commutativeN/A
associate-+l+N/A
*-commutativeN/A
+-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
+-commutativeN/A
lower-+.f6469.8
Applied rewrites69.8%
Taylor expanded in b around 0
fp-cancel-sub-sign-invN/A
associate-+r+N/A
distribute-lft-neg-inN/A
mul-1-negN/A
associate-+r+N/A
+-commutativeN/A
Applied rewrites93.5%
Final simplification92.9%
(FPCore (x y z t a b) :precision binary64 (if (<= (- (+ (+ x y) z) (* z (log t))) -5e-127) (fma b (- a 0.5) x) (fma b (- a 0.5) y)))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if ((((x + y) + z) - (z * log(t))) <= -5e-127) {
tmp = fma(b, (a - 0.5), x);
} else {
tmp = fma(b, (a - 0.5), 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))) <= -5e-127) tmp = fma(b, Float64(a - 0.5), x); else tmp = fma(b, Float64(a - 0.5), 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], -5e-127], N[(b * N[(a - 0.5), $MachinePrecision] + x), $MachinePrecision], N[(b * N[(a - 0.5), $MachinePrecision] + y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\left(\left(x + y\right) + z\right) - z \cdot \log t \leq -5 \cdot 10^{-127}:\\
\;\;\;\;\mathsf{fma}\left(b, a - 0.5, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(b, a - 0.5, y\right)\\
\end{array}
\end{array}
if (-.f64 (+.f64 (+.f64 x y) z) (*.f64 z (log.f64 t))) < -4.9999999999999997e-127Initial program 99.9%
Taylor expanded in z around 0
+-commutativeN/A
+-commutativeN/A
associate-+l+N/A
*-commutativeN/A
+-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
+-commutativeN/A
lower-+.f6482.9
Applied rewrites82.9%
Taylor expanded in y around 0
Applied rewrites59.8%
if -4.9999999999999997e-127 < (-.f64 (+.f64 (+.f64 x y) z) (*.f64 z (log.f64 t))) Initial program 99.8%
Taylor expanded in z around 0
+-commutativeN/A
+-commutativeN/A
associate-+l+N/A
*-commutativeN/A
+-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
+-commutativeN/A
lower-+.f6476.2
Applied rewrites76.2%
Taylor expanded in x around 0
Applied rewrites58.0%
(FPCore (x y z t a b)
:precision binary64
(let* ((t_1 (- 1.0 (log t))))
(if (<= (+ x y) -5e-127)
(fma (- a 0.5) b (fma t_1 z x))
(fma t_1 z (fma (- a 0.5) b y)))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = 1.0 - log(t);
double tmp;
if ((x + y) <= -5e-127) {
tmp = fma((a - 0.5), b, fma(t_1, z, x));
} else {
tmp = fma(t_1, z, fma((a - 0.5), b, y));
}
return tmp;
}
function code(x, y, z, t, a, b) t_1 = Float64(1.0 - log(t)) tmp = 0.0 if (Float64(x + y) <= -5e-127) tmp = fma(Float64(a - 0.5), b, fma(t_1, z, x)); else tmp = fma(t_1, z, fma(Float64(a - 0.5), b, y)); 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[N[(x + y), $MachinePrecision], -5e-127], N[(N[(a - 0.5), $MachinePrecision] * b + N[(t$95$1 * z + x), $MachinePrecision]), $MachinePrecision], N[(t$95$1 * z + N[(N[(a - 0.5), $MachinePrecision] * b + y), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := 1 - \log t\\
\mathbf{if}\;x + y \leq -5 \cdot 10^{-127}:\\
\;\;\;\;\mathsf{fma}\left(a - 0.5, b, \mathsf{fma}\left(t\_1, z, x\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(t\_1, z, \mathsf{fma}\left(a - 0.5, b, y\right)\right)\\
\end{array}
\end{array}
if (+.f64 x y) < -4.9999999999999997e-127Initial program 99.9%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6499.9
lift--.f64N/A
lift-*.f64N/A
fp-cancel-sub-sign-invN/A
+-commutativeN/A
lower-fma.f64N/A
lower-neg.f6499.9
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.9
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.9
Applied rewrites99.9%
Taylor expanded in y around 0
+-commutativeN/A
+-commutativeN/A
mul-1-negN/A
*-commutativeN/A
distribute-lft-neg-inN/A
mul-1-negN/A
distribute-lft1-inN/A
+-commutativeN/A
*-commutativeN/A
*-lft-identityN/A
metadata-evalN/A
distribute-lft-neg-outN/A
mul-1-negN/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
mul-1-negN/A
distribute-lft-neg-outN/A
metadata-evalN/A
*-lft-identityN/A
Applied rewrites76.2%
if -4.9999999999999997e-127 < (+.f64 x y) Initial program 99.8%
Taylor expanded in x around 0
associate--l+N/A
+-commutativeN/A
associate--l+N/A
*-rgt-identityN/A
distribute-lft-out--N/A
*-commutativeN/A
*-commutativeN/A
fp-cancel-sign-sub-invN/A
associate-+r-N/A
fp-cancel-sign-sub-invN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
lower-log.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f6481.5
Applied rewrites81.5%
(FPCore (x y z t a b)
:precision binary64
(let* ((t_1 (- 1.0 (log t))))
(if (<= (+ x y) -5e-127)
(fma t_1 z (fma (- a 0.5) b x))
(fma t_1 z (fma (- a 0.5) b y)))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = 1.0 - log(t);
double tmp;
if ((x + y) <= -5e-127) {
tmp = fma(t_1, z, fma((a - 0.5), b, x));
} else {
tmp = fma(t_1, z, fma((a - 0.5), b, y));
}
return tmp;
}
function code(x, y, z, t, a, b) t_1 = Float64(1.0 - log(t)) tmp = 0.0 if (Float64(x + y) <= -5e-127) tmp = fma(t_1, z, fma(Float64(a - 0.5), b, x)); else tmp = fma(t_1, z, fma(Float64(a - 0.5), b, y)); 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[N[(x + y), $MachinePrecision], -5e-127], N[(t$95$1 * z + N[(N[(a - 0.5), $MachinePrecision] * b + x), $MachinePrecision]), $MachinePrecision], N[(t$95$1 * z + N[(N[(a - 0.5), $MachinePrecision] * b + y), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := 1 - \log t\\
\mathbf{if}\;x + y \leq -5 \cdot 10^{-127}:\\
\;\;\;\;\mathsf{fma}\left(t\_1, z, \mathsf{fma}\left(a - 0.5, b, x\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(t\_1, z, \mathsf{fma}\left(a - 0.5, b, y\right)\right)\\
\end{array}
\end{array}
if (+.f64 x y) < -4.9999999999999997e-127Initial program 99.9%
Taylor expanded in y around 0
*-commutativeN/A
fp-cancel-sub-sign-invN/A
mul-1-negN/A
*-commutativeN/A
mul-1-negN/A
log-recN/A
+-commutativeN/A
+-commutativeN/A
associate-+l+N/A
associate-+r+N/A
Applied rewrites76.2%
if -4.9999999999999997e-127 < (+.f64 x y) Initial program 99.8%
Taylor expanded in x around 0
associate--l+N/A
+-commutativeN/A
associate--l+N/A
*-rgt-identityN/A
distribute-lft-out--N/A
*-commutativeN/A
*-commutativeN/A
fp-cancel-sign-sub-invN/A
associate-+r-N/A
fp-cancel-sign-sub-invN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
lower-log.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f6481.5
Applied rewrites81.5%
(FPCore (x y z t a b) :precision binary64 (if (<= y 3.9e+51) (fma (- 1.0 (log t)) z (fma (- a 0.5) b x)) (fma (- a 0.5) b (+ y x))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (y <= 3.9e+51) {
tmp = fma((1.0 - log(t)), z, fma((a - 0.5), b, x));
} else {
tmp = fma((a - 0.5), b, (y + x));
}
return tmp;
}
function code(x, y, z, t, a, b) tmp = 0.0 if (y <= 3.9e+51) tmp = fma(Float64(1.0 - log(t)), z, fma(Float64(a - 0.5), b, x)); else tmp = fma(Float64(a - 0.5), b, Float64(y + x)); end return tmp end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[y, 3.9e+51], N[(N[(1.0 - N[Log[t], $MachinePrecision]), $MachinePrecision] * z + N[(N[(a - 0.5), $MachinePrecision] * b + x), $MachinePrecision]), $MachinePrecision], N[(N[(a - 0.5), $MachinePrecision] * b + N[(y + x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 3.9 \cdot 10^{+51}:\\
\;\;\;\;\mathsf{fma}\left(1 - \log t, z, \mathsf{fma}\left(a - 0.5, b, x\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(a - 0.5, b, y + x\right)\\
\end{array}
\end{array}
if y < 3.89999999999999984e51Initial program 99.8%
Taylor expanded in y around 0
*-commutativeN/A
fp-cancel-sub-sign-invN/A
mul-1-negN/A
*-commutativeN/A
mul-1-negN/A
log-recN/A
+-commutativeN/A
+-commutativeN/A
associate-+l+N/A
associate-+r+N/A
Applied rewrites84.4%
if 3.89999999999999984e51 < y Initial program 99.8%
Taylor expanded in z around 0
+-commutativeN/A
+-commutativeN/A
associate-+l+N/A
*-commutativeN/A
+-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
+-commutativeN/A
lower-+.f6482.8
Applied rewrites82.8%
(FPCore (x y z t a b) :precision binary64 (if (<= z 4.9e+148) (fma (- a 0.5) b (+ y x)) (fma (- 1.0 (log t)) z y)))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (z <= 4.9e+148) {
tmp = fma((a - 0.5), b, (y + x));
} else {
tmp = fma((1.0 - log(t)), z, y);
}
return tmp;
}
function code(x, y, z, t, a, b) tmp = 0.0 if (z <= 4.9e+148) tmp = fma(Float64(a - 0.5), b, Float64(y + x)); else tmp = fma(Float64(1.0 - log(t)), z, y); end return tmp end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[z, 4.9e+148], N[(N[(a - 0.5), $MachinePrecision] * b + N[(y + x), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 - N[Log[t], $MachinePrecision]), $MachinePrecision] * z + y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq 4.9 \cdot 10^{+148}:\\
\;\;\;\;\mathsf{fma}\left(a - 0.5, b, y + x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(1 - \log t, z, y\right)\\
\end{array}
\end{array}
if z < 4.9e148Initial program 99.9%
Taylor expanded in z around 0
+-commutativeN/A
+-commutativeN/A
associate-+l+N/A
*-commutativeN/A
+-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
+-commutativeN/A
lower-+.f6485.7
Applied rewrites85.7%
if 4.9e148 < z Initial program 99.6%
Taylor expanded in x around 0
associate--l+N/A
+-commutativeN/A
associate--l+N/A
*-rgt-identityN/A
distribute-lft-out--N/A
*-commutativeN/A
*-commutativeN/A
fp-cancel-sign-sub-invN/A
associate-+r-N/A
fp-cancel-sign-sub-invN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
lower-log.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f6488.1
Applied rewrites88.1%
Taylor expanded in b around 0
Applied rewrites79.2%
(FPCore (x y z t a b) :precision binary64 (if (<= z 2.3e+208) (fma (- a 0.5) b (+ y x)) (* (- 1.0 (log t)) z)))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (z <= 2.3e+208) {
tmp = fma((a - 0.5), b, (y + x));
} else {
tmp = (1.0 - log(t)) * z;
}
return tmp;
}
function code(x, y, z, t, a, b) tmp = 0.0 if (z <= 2.3e+208) tmp = fma(Float64(a - 0.5), b, Float64(y + x)); else tmp = Float64(Float64(1.0 - log(t)) * z); end return tmp end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[z, 2.3e+208], N[(N[(a - 0.5), $MachinePrecision] * b + N[(y + x), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 - N[Log[t], $MachinePrecision]), $MachinePrecision] * z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq 2.3 \cdot 10^{+208}:\\
\;\;\;\;\mathsf{fma}\left(a - 0.5, b, y + x\right)\\
\mathbf{else}:\\
\;\;\;\;\left(1 - \log t\right) \cdot z\\
\end{array}
\end{array}
if z < 2.3e208Initial program 99.9%
Taylor expanded in z around 0
+-commutativeN/A
+-commutativeN/A
associate-+l+N/A
*-commutativeN/A
+-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
+-commutativeN/A
lower-+.f6484.4
Applied rewrites84.4%
if 2.3e208 < z Initial program 99.6%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
lower-log.f6477.2
Applied rewrites77.2%
(FPCore (x y z t a b) :precision binary64 (if (or (<= a -0.78) (not (<= a 4.4e-12))) (* b a) (* b -0.5)))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if ((a <= -0.78) || !(a <= 4.4e-12)) {
tmp = b * a;
} else {
tmp = b * -0.5;
}
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 <= (-0.78d0)) .or. (.not. (a <= 4.4d-12))) then
tmp = b * a
else
tmp = b * (-0.5d0)
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 <= -0.78) || !(a <= 4.4e-12)) {
tmp = b * a;
} else {
tmp = b * -0.5;
}
return tmp;
}
def code(x, y, z, t, a, b): tmp = 0 if (a <= -0.78) or not (a <= 4.4e-12): tmp = b * a else: tmp = b * -0.5 return tmp
function code(x, y, z, t, a, b) tmp = 0.0 if ((a <= -0.78) || !(a <= 4.4e-12)) tmp = Float64(b * a); else tmp = Float64(b * -0.5); end return tmp end
function tmp_2 = code(x, y, z, t, a, b) tmp = 0.0; if ((a <= -0.78) || ~((a <= 4.4e-12))) tmp = b * a; else tmp = b * -0.5; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_] := If[Or[LessEqual[a, -0.78], N[Not[LessEqual[a, 4.4e-12]], $MachinePrecision]], N[(b * a), $MachinePrecision], N[(b * -0.5), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -0.78 \lor \neg \left(a \leq 4.4 \cdot 10^{-12}\right):\\
\;\;\;\;b \cdot a\\
\mathbf{else}:\\
\;\;\;\;b \cdot -0.5\\
\end{array}
\end{array}
if a < -0.78000000000000003 or 4.39999999999999983e-12 < a Initial program 99.8%
Taylor expanded in a around inf
*-commutativeN/A
lower-*.f6448.1
Applied rewrites48.1%
if -0.78000000000000003 < a < 4.39999999999999983e-12Initial program 99.9%
Taylor expanded in z around 0
+-commutativeN/A
+-commutativeN/A
associate-+l+N/A
*-commutativeN/A
+-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
+-commutativeN/A
lower-+.f6480.1
Applied rewrites80.1%
Taylor expanded in b around inf
lower-*.f64N/A
lower--.f6424.6
Applied rewrites24.6%
Taylor expanded in a around 0
Applied rewrites23.7%
Final simplification37.5%
(FPCore (x y z t a b) :precision binary64 (fma (- a 0.5) b (+ y x)))
double code(double x, double y, double z, double t, double a, double b) {
return fma((a - 0.5), b, (y + x));
}
function code(x, y, z, t, a, b) return fma(Float64(a - 0.5), b, Float64(y + x)) end
code[x_, y_, z_, t_, a_, b_] := N[(N[(a - 0.5), $MachinePrecision] * b + N[(y + x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(a - 0.5, b, y + x\right)
\end{array}
Initial program 99.8%
Taylor expanded in z around 0
+-commutativeN/A
+-commutativeN/A
associate-+l+N/A
*-commutativeN/A
+-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
+-commutativeN/A
lower-+.f6479.5
Applied rewrites79.5%
(FPCore (x y z t a b) :precision binary64 (fma b (- a 0.5) x))
double code(double x, double y, double z, double t, double a, double b) {
return fma(b, (a - 0.5), x);
}
function code(x, y, z, t, a, b) return fma(b, Float64(a - 0.5), x) end
code[x_, y_, z_, t_, a_, b_] := N[(b * N[(a - 0.5), $MachinePrecision] + x), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(b, a - 0.5, x\right)
\end{array}
Initial program 99.8%
Taylor expanded in z around 0
+-commutativeN/A
+-commutativeN/A
associate-+l+N/A
*-commutativeN/A
+-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
+-commutativeN/A
lower-+.f6479.5
Applied rewrites79.5%
Taylor expanded in y around 0
Applied rewrites57.0%
(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
+-commutativeN/A
+-commutativeN/A
associate-+l+N/A
*-commutativeN/A
+-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
+-commutativeN/A
lower-+.f6479.5
Applied rewrites79.5%
Taylor expanded in b around inf
lower-*.f64N/A
lower--.f6438.0
Applied rewrites38.0%
(FPCore (x y z t a b) :precision binary64 (* b a))
double code(double x, double y, double z, double t, double a, double b) {
return b * 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)
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
end function
public static double code(double x, double y, double z, double t, double a, double b) {
return b * a;
}
def code(x, y, z, t, a, b): return b * a
function code(x, y, z, t, a, b) return Float64(b * a) end
function tmp = code(x, y, z, t, a, b) tmp = b * a; end
code[x_, y_, z_, t_, a_, b_] := N[(b * a), $MachinePrecision]
\begin{array}{l}
\\
b \cdot a
\end{array}
Initial program 99.8%
Taylor expanded in a around inf
*-commutativeN/A
lower-*.f6428.3
Applied rewrites28.3%
(FPCore (x y z t a b) :precision binary64 (+ (+ (+ x y) (/ (* (- 1.0 (pow (log t) 2.0)) z) (+ 1.0 (log t)))) (* (- a 0.5) b)))
double code(double x, double y, double z, double t, double a, double b) {
return ((x + y) + (((1.0 - pow(log(t), 2.0)) * z) / (1.0 + 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) + (((1.0d0 - (log(t) ** 2.0d0)) * z) / (1.0d0 + 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) + (((1.0 - Math.pow(Math.log(t), 2.0)) * z) / (1.0 + Math.log(t)))) + ((a - 0.5) * b);
}
def code(x, y, z, t, a, b): return ((x + y) + (((1.0 - math.pow(math.log(t), 2.0)) * z) / (1.0 + math.log(t)))) + ((a - 0.5) * b)
function code(x, y, z, t, a, b) return Float64(Float64(Float64(x + y) + Float64(Float64(Float64(1.0 - (log(t) ^ 2.0)) * z) / Float64(1.0 + log(t)))) + Float64(Float64(a - 0.5) * b)) end
function tmp = code(x, y, z, t, a, b) tmp = ((x + y) + (((1.0 - (log(t) ^ 2.0)) * z) / (1.0 + log(t)))) + ((a - 0.5) * b); end
code[x_, y_, z_, t_, a_, b_] := N[(N[(N[(x + y), $MachinePrecision] + N[(N[(N[(1.0 - N[Power[N[Log[t], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * z), $MachinePrecision] / N[(1.0 + N[Log[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(a - 0.5), $MachinePrecision] * b), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(x + y\right) + \frac{\left(1 - {\log t}^{2}\right) \cdot z}{1 + \log t}\right) + \left(a - 0.5\right) \cdot b
\end{array}
herbie shell --seed 2025017
(FPCore (x y z t a b)
:name "Numeric.SpecFunctions:logBeta from math-functions-0.1.5.2, A"
:precision binary64
:alt
(! :herbie-platform default (+ (+ (+ x y) (/ (* (- 1 (pow (log t) 2)) z) (+ 1 (log t)))) (* (- a 1/2) b)))
(+ (- (+ (+ x y) z) (* z (log t))) (* (- a 0.5) b)))