
(FPCore (x y z t) :precision binary64 (- (+ (* x (log y)) (* z (log (- 1.0 y)))) t))
double code(double x, double y, double z, double t) {
return ((x * log(y)) + (z * log((1.0 - y)))) - t;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z, t)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = ((x * log(y)) + (z * log((1.0d0 - y)))) - t
end function
public static double code(double x, double y, double z, double t) {
return ((x * Math.log(y)) + (z * Math.log((1.0 - y)))) - t;
}
def code(x, y, z, t): return ((x * math.log(y)) + (z * math.log((1.0 - y)))) - t
function code(x, y, z, t) return Float64(Float64(Float64(x * log(y)) + Float64(z * log(Float64(1.0 - y)))) - t) end
function tmp = code(x, y, z, t) tmp = ((x * log(y)) + (z * log((1.0 - y)))) - t; end
code[x_, y_, z_, t_] := N[(N[(N[(x * N[Log[y], $MachinePrecision]), $MachinePrecision] + N[(z * N[Log[N[(1.0 - y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - t), $MachinePrecision]
\begin{array}{l}
\\
\left(x \cdot \log y + z \cdot \log \left(1 - y\right)\right) - t
\end{array}
Herbie found 9 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z t) :precision binary64 (- (+ (* x (log y)) (* z (log (- 1.0 y)))) t))
double code(double x, double y, double z, double t) {
return ((x * log(y)) + (z * log((1.0 - y)))) - t;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z, t)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = ((x * log(y)) + (z * log((1.0d0 - y)))) - t
end function
public static double code(double x, double y, double z, double t) {
return ((x * Math.log(y)) + (z * Math.log((1.0 - y)))) - t;
}
def code(x, y, z, t): return ((x * math.log(y)) + (z * math.log((1.0 - y)))) - t
function code(x, y, z, t) return Float64(Float64(Float64(x * log(y)) + Float64(z * log(Float64(1.0 - y)))) - t) end
function tmp = code(x, y, z, t) tmp = ((x * log(y)) + (z * log((1.0 - y)))) - t; end
code[x_, y_, z_, t_] := N[(N[(N[(x * N[Log[y], $MachinePrecision]), $MachinePrecision] + N[(z * N[Log[N[(1.0 - y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - t), $MachinePrecision]
\begin{array}{l}
\\
\left(x \cdot \log y + z \cdot \log \left(1 - y\right)\right) - t
\end{array}
(FPCore (x y z t) :precision binary64 (- (fma (log y) x (* (* (- (* (- (* -0.3333333333333333 y) 0.5) y) 1.0) y) z)) t))
double code(double x, double y, double z, double t) {
return fma(log(y), x, ((((((-0.3333333333333333 * y) - 0.5) * y) - 1.0) * y) * z)) - t;
}
function code(x, y, z, t) return Float64(fma(log(y), x, Float64(Float64(Float64(Float64(Float64(Float64(-0.3333333333333333 * y) - 0.5) * y) - 1.0) * y) * z)) - t) end
code[x_, y_, z_, t_] := N[(N[(N[Log[y], $MachinePrecision] * x + N[(N[(N[(N[(N[(N[(-0.3333333333333333 * y), $MachinePrecision] - 0.5), $MachinePrecision] * y), $MachinePrecision] - 1.0), $MachinePrecision] * y), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision] - t), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(\log y, x, \left(\left(\left(-0.3333333333333333 \cdot y - 0.5\right) \cdot y - 1\right) \cdot y\right) \cdot z\right) - t
\end{array}
Initial program 86.1%
Taylor expanded in y around 0
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f6499.5
Applied rewrites99.5%
lift-+.f64N/A
lift-*.f64N/A
lift-log.f64N/A
*-commutativeN/A
unpow1N/A
metadata-evalN/A
pow-powN/A
inv-powN/A
log-pow-revN/A
lower-fma.f64N/A
log-pow-revN/A
inv-powN/A
pow-powN/A
metadata-evalN/A
unpow1N/A
lift-log.f6499.5
lift-*.f64N/A
*-commutativeN/A
lower-*.f6499.5
Applied rewrites99.5%
(FPCore (x y z t) :precision binary64 (fma (log y) x (- (* (- (* (* z y) -0.5) z) y) t)))
double code(double x, double y, double z, double t) {
return fma(log(y), x, (((((z * y) * -0.5) - z) * y) - t));
}
function code(x, y, z, t) return fma(log(y), x, Float64(Float64(Float64(Float64(Float64(z * y) * -0.5) - z) * y) - t)) end
code[x_, y_, z_, t_] := N[(N[Log[y], $MachinePrecision] * x + N[(N[(N[(N[(N[(z * y), $MachinePrecision] * -0.5), $MachinePrecision] - z), $MachinePrecision] * y), $MachinePrecision] - t), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(\log y, x, \left(\left(z \cdot y\right) \cdot -0.5 - z\right) \cdot y - t\right)
\end{array}
Initial program 86.1%
lift--.f64N/A
lift-+.f64N/A
lift-*.f64N/A
lift-log.f64N/A
lift-*.f64N/A
lift--.f64N/A
lift-log.f64N/A
associate--l+N/A
*-commutativeN/A
lower-fma.f64N/A
lift-log.f64N/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-log.f64N/A
lift--.f6486.1
Applied rewrites86.1%
Taylor expanded in y around 0
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f6499.4
Applied rewrites99.4%
Taylor expanded in y around 0
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lift-*.f6499.4
Applied rewrites99.4%
(FPCore (x y z t) :precision binary64 (- (fma (log y) x (* (* (- (* -0.5 y) 1.0) y) z)) t))
double code(double x, double y, double z, double t) {
return fma(log(y), x, ((((-0.5 * y) - 1.0) * y) * z)) - t;
}
function code(x, y, z, t) return Float64(fma(log(y), x, Float64(Float64(Float64(Float64(-0.5 * y) - 1.0) * y) * z)) - t) end
code[x_, y_, z_, t_] := N[(N[(N[Log[y], $MachinePrecision] * x + N[(N[(N[(N[(-0.5 * y), $MachinePrecision] - 1.0), $MachinePrecision] * y), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision] - t), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(\log y, x, \left(\left(-0.5 \cdot y - 1\right) \cdot y\right) \cdot z\right) - t
\end{array}
Initial program 86.1%
Taylor expanded in y around 0
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f6499.5
Applied rewrites99.5%
lift-+.f64N/A
lift-*.f64N/A
lift-log.f64N/A
*-commutativeN/A
unpow1N/A
metadata-evalN/A
pow-powN/A
inv-powN/A
log-pow-revN/A
lower-fma.f64N/A
log-pow-revN/A
inv-powN/A
pow-powN/A
metadata-evalN/A
unpow1N/A
lift-log.f6499.5
lift-*.f64N/A
*-commutativeN/A
lower-*.f6499.5
Applied rewrites99.5%
Taylor expanded in y around 0
Applied rewrites99.4%
(FPCore (x y z t) :precision binary64 (- (fma (- y) z (* (log y) x)) t))
double code(double x, double y, double z, double t) {
return fma(-y, z, (log(y) * x)) - t;
}
function code(x, y, z, t) return Float64(fma(Float64(-y), z, Float64(log(y) * x)) - t) end
code[x_, y_, z_, t_] := N[(N[((-y) * z + N[(N[Log[y], $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision] - t), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(-y, z, \log y \cdot x\right) - t
\end{array}
Initial program 86.1%
Taylor expanded in y around 0
associate-*r*N/A
mul-1-negN/A
lower-fma.f64N/A
lower-neg.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-log.f6499.1
Applied rewrites99.1%
(FPCore (x y z t) :precision binary64 (if (<= x -6.2e-28) (fma (log y) x (- t)) (if (<= x 1.15e-62) (- (* (- y) z) t) (- (* (log y) x) t))))
double code(double x, double y, double z, double t) {
double tmp;
if (x <= -6.2e-28) {
tmp = fma(log(y), x, -t);
} else if (x <= 1.15e-62) {
tmp = (-y * z) - t;
} else {
tmp = (log(y) * x) - t;
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (x <= -6.2e-28) tmp = fma(log(y), x, Float64(-t)); elseif (x <= 1.15e-62) tmp = Float64(Float64(Float64(-y) * z) - t); else tmp = Float64(Float64(log(y) * x) - t); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[x, -6.2e-28], N[(N[Log[y], $MachinePrecision] * x + (-t)), $MachinePrecision], If[LessEqual[x, 1.15e-62], N[(N[((-y) * z), $MachinePrecision] - t), $MachinePrecision], N[(N[(N[Log[y], $MachinePrecision] * x), $MachinePrecision] - t), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -6.2 \cdot 10^{-28}:\\
\;\;\;\;\mathsf{fma}\left(\log y, x, -t\right)\\
\mathbf{elif}\;x \leq 1.15 \cdot 10^{-62}:\\
\;\;\;\;\left(-y\right) \cdot z - t\\
\mathbf{else}:\\
\;\;\;\;\log y \cdot x - t\\
\end{array}
\end{array}
if x < -6.19999999999999984e-28Initial program 93.2%
lift--.f64N/A
lift-+.f64N/A
lift-*.f64N/A
lift-log.f64N/A
lift-*.f64N/A
lift--.f64N/A
lift-log.f64N/A
associate--l+N/A
*-commutativeN/A
lower-fma.f64N/A
lift-log.f64N/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-log.f64N/A
lift--.f6493.2
Applied rewrites93.2%
Taylor expanded in y around 0
mul-1-negN/A
lift-neg.f6492.5
Applied rewrites92.5%
if -6.19999999999999984e-28 < x < 1.15e-62Initial program 77.1%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f64N/A
lift-log.f64N/A
lift-log.f64N/A
lift--.f6476.6
Applied rewrites76.6%
Taylor expanded in y around 0
mul-1-negN/A
+-commutativeN/A
associate-*r/N/A
*-commutativeN/A
lower-fma.f64N/A
lift-log.f64N/A
lift-/.f64N/A
lower-neg.f6498.4
Applied rewrites98.4%
Taylor expanded in x around 0
mul-1-negN/A
lift-neg.f6486.4
Applied rewrites86.4%
if 1.15e-62 < x Initial program 92.9%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
lift-log.f6492.4
Applied rewrites92.4%
(FPCore (x y z t) :precision binary64 (let* ((t_1 (- (* (log y) x) t))) (if (<= x -6.2e-28) t_1 (if (<= x 1.15e-62) (- (* (- y) z) t) t_1))))
double code(double x, double y, double z, double t) {
double t_1 = (log(y) * x) - t;
double tmp;
if (x <= -6.2e-28) {
tmp = t_1;
} else if (x <= 1.15e-62) {
tmp = (-y * z) - t;
} else {
tmp = t_1;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z, t)
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) :: t_1
real(8) :: tmp
t_1 = (log(y) * x) - t
if (x <= (-6.2d-28)) then
tmp = t_1
else if (x <= 1.15d-62) then
tmp = (-y * z) - t
else
tmp = t_1
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double t_1 = (Math.log(y) * x) - t;
double tmp;
if (x <= -6.2e-28) {
tmp = t_1;
} else if (x <= 1.15e-62) {
tmp = (-y * z) - t;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z, t): t_1 = (math.log(y) * x) - t tmp = 0 if x <= -6.2e-28: tmp = t_1 elif x <= 1.15e-62: tmp = (-y * z) - t else: tmp = t_1 return tmp
function code(x, y, z, t) t_1 = Float64(Float64(log(y) * x) - t) tmp = 0.0 if (x <= -6.2e-28) tmp = t_1; elseif (x <= 1.15e-62) tmp = Float64(Float64(Float64(-y) * z) - t); else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = (log(y) * x) - t; tmp = 0.0; if (x <= -6.2e-28) tmp = t_1; elseif (x <= 1.15e-62) tmp = (-y * z) - t; else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[(N[Log[y], $MachinePrecision] * x), $MachinePrecision] - t), $MachinePrecision]}, If[LessEqual[x, -6.2e-28], t$95$1, If[LessEqual[x, 1.15e-62], N[(N[((-y) * z), $MachinePrecision] - t), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \log y \cdot x - t\\
\mathbf{if}\;x \leq -6.2 \cdot 10^{-28}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq 1.15 \cdot 10^{-62}:\\
\;\;\;\;\left(-y\right) \cdot z - t\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if x < -6.19999999999999984e-28 or 1.15e-62 < x Initial program 93.1%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
lift-log.f6492.5
Applied rewrites92.5%
if -6.19999999999999984e-28 < x < 1.15e-62Initial program 77.1%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f64N/A
lift-log.f64N/A
lift-log.f64N/A
lift--.f6476.6
Applied rewrites76.6%
Taylor expanded in y around 0
mul-1-negN/A
+-commutativeN/A
associate-*r/N/A
*-commutativeN/A
lower-fma.f64N/A
lift-log.f64N/A
lift-/.f64N/A
lower-neg.f6498.4
Applied rewrites98.4%
Taylor expanded in x around 0
mul-1-negN/A
lift-neg.f6486.4
Applied rewrites86.4%
(FPCore (x y z t) :precision binary64 (let* ((t_1 (* (log y) x))) (if (<= x -4.8e+143) t_1 (if (<= x 4.5e-61) (- (* (- y) z) t) t_1))))
double code(double x, double y, double z, double t) {
double t_1 = log(y) * x;
double tmp;
if (x <= -4.8e+143) {
tmp = t_1;
} else if (x <= 4.5e-61) {
tmp = (-y * z) - t;
} else {
tmp = t_1;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z, t)
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) :: t_1
real(8) :: tmp
t_1 = log(y) * x
if (x <= (-4.8d+143)) then
tmp = t_1
else if (x <= 4.5d-61) then
tmp = (-y * z) - t
else
tmp = t_1
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double t_1 = Math.log(y) * x;
double tmp;
if (x <= -4.8e+143) {
tmp = t_1;
} else if (x <= 4.5e-61) {
tmp = (-y * z) - t;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z, t): t_1 = math.log(y) * x tmp = 0 if x <= -4.8e+143: tmp = t_1 elif x <= 4.5e-61: tmp = (-y * z) - t else: tmp = t_1 return tmp
function code(x, y, z, t) t_1 = Float64(log(y) * x) tmp = 0.0 if (x <= -4.8e+143) tmp = t_1; elseif (x <= 4.5e-61) tmp = Float64(Float64(Float64(-y) * z) - t); else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = log(y) * x; tmp = 0.0; if (x <= -4.8e+143) tmp = t_1; elseif (x <= 4.5e-61) tmp = (-y * z) - t; else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[Log[y], $MachinePrecision] * x), $MachinePrecision]}, If[LessEqual[x, -4.8e+143], t$95$1, If[LessEqual[x, 4.5e-61], N[(N[((-y) * z), $MachinePrecision] - t), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \log y \cdot x\\
\mathbf{if}\;x \leq -4.8 \cdot 10^{+143}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq 4.5 \cdot 10^{-61}:\\
\;\;\;\;\left(-y\right) \cdot z - t\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if x < -4.79999999999999959e143 or 4.5e-61 < x Initial program 94.5%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
lift-log.f6470.4
Applied rewrites70.4%
if -4.79999999999999959e143 < x < 4.5e-61Initial program 79.9%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f64N/A
lift-log.f64N/A
lift-log.f64N/A
lift--.f6477.4
Applied rewrites77.4%
Taylor expanded in y around 0
mul-1-negN/A
+-commutativeN/A
associate-*r/N/A
*-commutativeN/A
lower-fma.f64N/A
lift-log.f64N/A
lift-/.f64N/A
lower-neg.f6496.5
Applied rewrites96.5%
Taylor expanded in x around 0
mul-1-negN/A
lift-neg.f6478.0
Applied rewrites78.0%
(FPCore (x y z t) :precision binary64 (- (* (- y) z) t))
double code(double x, double y, double z, double t) {
return (-y * z) - t;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z, t)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = (-y * z) - t
end function
public static double code(double x, double y, double z, double t) {
return (-y * z) - t;
}
def code(x, y, z, t): return (-y * z) - t
function code(x, y, z, t) return Float64(Float64(Float64(-y) * z) - t) end
function tmp = code(x, y, z, t) tmp = (-y * z) - t; end
code[x_, y_, z_, t_] := N[(N[((-y) * z), $MachinePrecision] - t), $MachinePrecision]
\begin{array}{l}
\\
\left(-y\right) \cdot z - t
\end{array}
Initial program 86.1%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f64N/A
lift-log.f64N/A
lift-log.f64N/A
lift--.f6474.3
Applied rewrites74.3%
Taylor expanded in y around 0
mul-1-negN/A
+-commutativeN/A
associate-*r/N/A
*-commutativeN/A
lower-fma.f64N/A
lift-log.f64N/A
lift-/.f64N/A
lower-neg.f6487.3
Applied rewrites87.3%
Taylor expanded in x around 0
mul-1-negN/A
lift-neg.f6457.4
Applied rewrites57.4%
(FPCore (x y z t) :precision binary64 (- t))
double code(double x, double y, double z, double t) {
return -t;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z, t)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = -t
end function
public static double code(double x, double y, double z, double t) {
return -t;
}
def code(x, y, z, t): return -t
function code(x, y, z, t) return Float64(-t) end
function tmp = code(x, y, z, t) tmp = -t; end
code[x_, y_, z_, t_] := (-t)
\begin{array}{l}
\\
-t
\end{array}
Initial program 86.1%
Taylor expanded in t around inf
mul-1-negN/A
lower-neg.f6443.7
Applied rewrites43.7%
herbie shell --seed 2025120
(FPCore (x y z t)
:name "Numeric.SpecFunctions:invIncompleteBetaWorker from math-functions-0.1.5.2, B"
:precision binary64
(- (+ (* x (log y)) (* z (log (- 1.0 y)))) t))