
(FPCore (x y z t) :precision binary64 (+ (- (- (* x (log y)) y) z) (log t)))
double code(double x, double y, double z, double t) {
return (((x * log(y)) - y) - z) + log(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)) - y) - z) + log(t)
end function
public static double code(double x, double y, double z, double t) {
return (((x * Math.log(y)) - y) - z) + Math.log(t);
}
def code(x, y, z, t): return (((x * math.log(y)) - y) - z) + math.log(t)
function code(x, y, z, t) return Float64(Float64(Float64(Float64(x * log(y)) - y) - z) + log(t)) end
function tmp = code(x, y, z, t) tmp = (((x * log(y)) - y) - z) + log(t); end
code[x_, y_, z_, t_] := N[(N[(N[(N[(x * N[Log[y], $MachinePrecision]), $MachinePrecision] - y), $MachinePrecision] - z), $MachinePrecision] + N[Log[t], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(x \cdot \log y - y\right) - z\right) + \log t
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 10 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z t) :precision binary64 (+ (- (- (* x (log y)) y) z) (log t)))
double code(double x, double y, double z, double t) {
return (((x * log(y)) - y) - z) + log(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)) - y) - z) + log(t)
end function
public static double code(double x, double y, double z, double t) {
return (((x * Math.log(y)) - y) - z) + Math.log(t);
}
def code(x, y, z, t): return (((x * math.log(y)) - y) - z) + math.log(t)
function code(x, y, z, t) return Float64(Float64(Float64(Float64(x * log(y)) - y) - z) + log(t)) end
function tmp = code(x, y, z, t) tmp = (((x * log(y)) - y) - z) + log(t); end
code[x_, y_, z_, t_] := N[(N[(N[(N[(x * N[Log[y], $MachinePrecision]), $MachinePrecision] - y), $MachinePrecision] - z), $MachinePrecision] + N[Log[t], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(x \cdot \log y - y\right) - z\right) + \log t
\end{array}
(FPCore (x y z t) :precision binary64 (- (- (fma (log y) x (log t)) z) y))
double code(double x, double y, double z, double t) {
return (fma(log(y), x, log(t)) - z) - y;
}
function code(x, y, z, t) return Float64(Float64(fma(log(y), x, log(t)) - z) - y) end
code[x_, y_, z_, t_] := N[(N[(N[(N[Log[y], $MachinePrecision] * x + N[Log[t], $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision] - y), $MachinePrecision]
\begin{array}{l}
\\
\left(\mathsf{fma}\left(\log y, x, \log t\right) - z\right) - y
\end{array}
Initial program 99.9%
lift-+.f64N/A
+-commutativeN/A
lift--.f64N/A
lift--.f64N/A
associate--l-N/A
associate-+r-N/A
+-commutativeN/A
associate--r+N/A
lower--.f64N/A
lower--.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6499.9
Applied rewrites99.9%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (- (* x (log y)) y)))
(if (<= t_1 -5e+53)
(* -1.0 y)
(if (<= t_1 2000000.0) (- (log t) z) (* (log y) x)))))
double code(double x, double y, double z, double t) {
double t_1 = (x * log(y)) - y;
double tmp;
if (t_1 <= -5e+53) {
tmp = -1.0 * y;
} else if (t_1 <= 2000000.0) {
tmp = log(t) - z;
} else {
tmp = log(y) * x;
}
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 = (x * log(y)) - y
if (t_1 <= (-5d+53)) then
tmp = (-1.0d0) * y
else if (t_1 <= 2000000.0d0) then
tmp = log(t) - z
else
tmp = log(y) * x
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double t_1 = (x * Math.log(y)) - y;
double tmp;
if (t_1 <= -5e+53) {
tmp = -1.0 * y;
} else if (t_1 <= 2000000.0) {
tmp = Math.log(t) - z;
} else {
tmp = Math.log(y) * x;
}
return tmp;
}
def code(x, y, z, t): t_1 = (x * math.log(y)) - y tmp = 0 if t_1 <= -5e+53: tmp = -1.0 * y elif t_1 <= 2000000.0: tmp = math.log(t) - z else: tmp = math.log(y) * x return tmp
function code(x, y, z, t) t_1 = Float64(Float64(x * log(y)) - y) tmp = 0.0 if (t_1 <= -5e+53) tmp = Float64(-1.0 * y); elseif (t_1 <= 2000000.0) tmp = Float64(log(t) - z); else tmp = Float64(log(y) * x); end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = (x * log(y)) - y; tmp = 0.0; if (t_1 <= -5e+53) tmp = -1.0 * y; elseif (t_1 <= 2000000.0) tmp = log(t) - z; else tmp = log(y) * x; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[(x * N[Log[y], $MachinePrecision]), $MachinePrecision] - y), $MachinePrecision]}, If[LessEqual[t$95$1, -5e+53], N[(-1.0 * y), $MachinePrecision], If[LessEqual[t$95$1, 2000000.0], N[(N[Log[t], $MachinePrecision] - z), $MachinePrecision], N[(N[Log[y], $MachinePrecision] * x), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := x \cdot \log y - y\\
\mathbf{if}\;t\_1 \leq -5 \cdot 10^{+53}:\\
\;\;\;\;-1 \cdot y\\
\mathbf{elif}\;t\_1 \leq 2000000:\\
\;\;\;\;\log t - z\\
\mathbf{else}:\\
\;\;\;\;\log y \cdot x\\
\end{array}
\end{array}
if (-.f64 (*.f64 x (log.f64 y)) y) < -5.0000000000000004e53Initial program 99.9%
Taylor expanded in z around 0
lower--.f64N/A
Applied rewrites86.6%
Taylor expanded in y around inf
Applied rewrites78.1%
Taylor expanded in y around inf
Applied rewrites59.9%
if -5.0000000000000004e53 < (-.f64 (*.f64 x (log.f64 y)) y) < 2e6Initial program 100.0%
Taylor expanded in y around 0
lower--.f64N/A
Applied rewrites96.5%
Taylor expanded in x around 0
Applied rewrites95.2%
if 2e6 < (-.f64 (*.f64 x (log.f64 y)) y) Initial program 99.7%
Taylor expanded in x around 0
+-commutativeN/A
associate--r+N/A
*-lft-identityN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
+-commutativeN/A
+-commutativeN/A
associate--l+N/A
*-commutativeN/A
*-lft-identityN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
distribute-lft-inN/A
+-commutativeN/A
lower-fma.f64N/A
lower-log.f64N/A
mul-1-negN/A
lower-neg.f64N/A
+-commutativeN/A
lower-+.f6499.7
Applied rewrites99.7%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
lower-log.f6492.2
Applied rewrites92.2%
(FPCore (x y z t) :precision binary64 (if (or (<= x -4.5e+105) (not (<= x 1e+30))) (- (fma (log y) x (log t)) y) (- (- (log t) y) z)))
double code(double x, double y, double z, double t) {
double tmp;
if ((x <= -4.5e+105) || !(x <= 1e+30)) {
tmp = fma(log(y), x, log(t)) - y;
} else {
tmp = (log(t) - y) - z;
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if ((x <= -4.5e+105) || !(x <= 1e+30)) tmp = Float64(fma(log(y), x, log(t)) - y); else tmp = Float64(Float64(log(t) - y) - z); end return tmp end
code[x_, y_, z_, t_] := If[Or[LessEqual[x, -4.5e+105], N[Not[LessEqual[x, 1e+30]], $MachinePrecision]], N[(N[(N[Log[y], $MachinePrecision] * x + N[Log[t], $MachinePrecision]), $MachinePrecision] - y), $MachinePrecision], N[(N[(N[Log[t], $MachinePrecision] - y), $MachinePrecision] - z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -4.5 \cdot 10^{+105} \lor \neg \left(x \leq 10^{+30}\right):\\
\;\;\;\;\mathsf{fma}\left(\log y, x, \log t\right) - y\\
\mathbf{else}:\\
\;\;\;\;\left(\log t - y\right) - z\\
\end{array}
\end{array}
if x < -4.5000000000000001e105 or 1e30 < x Initial program 99.8%
Taylor expanded in z around 0
lower--.f64N/A
Applied rewrites90.1%
if -4.5000000000000001e105 < x < 1e30Initial program 100.0%
Taylor expanded in x around 0
associate--r+N/A
*-lft-identityN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
lower--.f64N/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lower--.f64N/A
lower-log.f6498.6
Applied rewrites98.6%
Final simplification95.0%
(FPCore (x y z t) :precision binary64 (if (<= y 5.1e+48) (fma (log y) x (- (log t) z)) (- (fma (log y) x (log t)) y)))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 5.1e+48) {
tmp = fma(log(y), x, (log(t) - z));
} else {
tmp = fma(log(y), x, log(t)) - y;
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (y <= 5.1e+48) tmp = fma(log(y), x, Float64(log(t) - z)); else tmp = Float64(fma(log(y), x, log(t)) - y); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[y, 5.1e+48], N[(N[Log[y], $MachinePrecision] * x + N[(N[Log[t], $MachinePrecision] - z), $MachinePrecision]), $MachinePrecision], N[(N[(N[Log[y], $MachinePrecision] * x + N[Log[t], $MachinePrecision]), $MachinePrecision] - y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 5.1 \cdot 10^{+48}:\\
\;\;\;\;\mathsf{fma}\left(\log y, x, \log t - z\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\log y, x, \log t\right) - y\\
\end{array}
\end{array}
if y < 5.0999999999999998e48Initial program 99.9%
Taylor expanded in y around 0
lower--.f64N/A
Applied rewrites98.0%
Applied rewrites98.0%
if 5.0999999999999998e48 < y Initial program 99.9%
Taylor expanded in z around 0
lower--.f64N/A
Applied rewrites87.7%
(FPCore (x y z t) :precision binary64 (let* ((t_1 (fma (log y) x (log t)))) (if (<= y 5.1e+48) (- t_1 z) (- t_1 y))))
double code(double x, double y, double z, double t) {
double t_1 = fma(log(y), x, log(t));
double tmp;
if (y <= 5.1e+48) {
tmp = t_1 - z;
} else {
tmp = t_1 - y;
}
return tmp;
}
function code(x, y, z, t) t_1 = fma(log(y), x, log(t)) tmp = 0.0 if (y <= 5.1e+48) tmp = Float64(t_1 - z); else tmp = Float64(t_1 - y); end return tmp end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[Log[y], $MachinePrecision] * x + N[Log[t], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, 5.1e+48], N[(t$95$1 - z), $MachinePrecision], N[(t$95$1 - y), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(\log y, x, \log t\right)\\
\mathbf{if}\;y \leq 5.1 \cdot 10^{+48}:\\
\;\;\;\;t\_1 - z\\
\mathbf{else}:\\
\;\;\;\;t\_1 - y\\
\end{array}
\end{array}
if y < 5.0999999999999998e48Initial program 99.9%
Taylor expanded in y around 0
lower--.f64N/A
Applied rewrites98.0%
if 5.0999999999999998e48 < y Initial program 99.9%
Taylor expanded in z around 0
lower--.f64N/A
Applied rewrites87.7%
(FPCore (x y z t) :precision binary64 (if (or (<= x -1.4e+106) (not (<= x 7.2e+73))) (* (log y) x) (- (- (log t) y) z)))
double code(double x, double y, double z, double t) {
double tmp;
if ((x <= -1.4e+106) || !(x <= 7.2e+73)) {
tmp = log(y) * x;
} else {
tmp = (log(t) - y) - z;
}
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) :: tmp
if ((x <= (-1.4d+106)) .or. (.not. (x <= 7.2d+73))) then
tmp = log(y) * x
else
tmp = (log(t) - y) - z
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((x <= -1.4e+106) || !(x <= 7.2e+73)) {
tmp = Math.log(y) * x;
} else {
tmp = (Math.log(t) - y) - z;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (x <= -1.4e+106) or not (x <= 7.2e+73): tmp = math.log(y) * x else: tmp = (math.log(t) - y) - z return tmp
function code(x, y, z, t) tmp = 0.0 if ((x <= -1.4e+106) || !(x <= 7.2e+73)) tmp = Float64(log(y) * x); else tmp = Float64(Float64(log(t) - y) - z); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((x <= -1.4e+106) || ~((x <= 7.2e+73))) tmp = log(y) * x; else tmp = (log(t) - y) - z; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[x, -1.4e+106], N[Not[LessEqual[x, 7.2e+73]], $MachinePrecision]], N[(N[Log[y], $MachinePrecision] * x), $MachinePrecision], N[(N[(N[Log[t], $MachinePrecision] - y), $MachinePrecision] - z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.4 \cdot 10^{+106} \lor \neg \left(x \leq 7.2 \cdot 10^{+73}\right):\\
\;\;\;\;\log y \cdot x\\
\mathbf{else}:\\
\;\;\;\;\left(\log t - y\right) - z\\
\end{array}
\end{array}
if x < -1.39999999999999996e106 or 7.1999999999999998e73 < x Initial program 99.8%
Taylor expanded in x around 0
+-commutativeN/A
associate--r+N/A
*-lft-identityN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
+-commutativeN/A
+-commutativeN/A
associate--l+N/A
*-commutativeN/A
*-lft-identityN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
distribute-lft-inN/A
+-commutativeN/A
lower-fma.f64N/A
lower-log.f64N/A
mul-1-negN/A
lower-neg.f64N/A
+-commutativeN/A
lower-+.f6499.8
Applied rewrites99.8%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
lower-log.f6469.8
Applied rewrites69.8%
if -1.39999999999999996e106 < x < 7.1999999999999998e73Initial program 100.0%
Taylor expanded in x around 0
associate--r+N/A
*-lft-identityN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
lower--.f64N/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lower--.f64N/A
lower-log.f6497.4
Applied rewrites97.4%
Final simplification86.3%
(FPCore (x y z t) :precision binary64 (if (or (<= z -5.8e+185) (not (<= z 8.5e+120))) (- z) (- (log t) y)))
double code(double x, double y, double z, double t) {
double tmp;
if ((z <= -5.8e+185) || !(z <= 8.5e+120)) {
tmp = -z;
} else {
tmp = log(t) - y;
}
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) :: tmp
if ((z <= (-5.8d+185)) .or. (.not. (z <= 8.5d+120))) then
tmp = -z
else
tmp = log(t) - y
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((z <= -5.8e+185) || !(z <= 8.5e+120)) {
tmp = -z;
} else {
tmp = Math.log(t) - y;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (z <= -5.8e+185) or not (z <= 8.5e+120): tmp = -z else: tmp = math.log(t) - y return tmp
function code(x, y, z, t) tmp = 0.0 if ((z <= -5.8e+185) || !(z <= 8.5e+120)) tmp = Float64(-z); else tmp = Float64(log(t) - y); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((z <= -5.8e+185) || ~((z <= 8.5e+120))) tmp = -z; else tmp = log(t) - y; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[z, -5.8e+185], N[Not[LessEqual[z, 8.5e+120]], $MachinePrecision]], (-z), N[(N[Log[t], $MachinePrecision] - y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -5.8 \cdot 10^{+185} \lor \neg \left(z \leq 8.5 \cdot 10^{+120}\right):\\
\;\;\;\;-z\\
\mathbf{else}:\\
\;\;\;\;\log t - y\\
\end{array}
\end{array}
if z < -5.79999999999999976e185 or 8.50000000000000026e120 < z Initial program 99.9%
Taylor expanded in z around inf
mul-1-negN/A
lower-neg.f6469.7
Applied rewrites69.7%
if -5.79999999999999976e185 < z < 8.50000000000000026e120Initial program 99.9%
Taylor expanded in z around 0
lower--.f64N/A
Applied rewrites93.5%
Taylor expanded in x around 0
Applied rewrites59.9%
Final simplification62.3%
(FPCore (x y z t) :precision binary64 (if (<= y 5.1e+48) (- (log t) z) (- (log t) y)))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 5.1e+48) {
tmp = log(t) - z;
} else {
tmp = log(t) - y;
}
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) :: tmp
if (y <= 5.1d+48) then
tmp = log(t) - z
else
tmp = log(t) - y
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (y <= 5.1e+48) {
tmp = Math.log(t) - z;
} else {
tmp = Math.log(t) - y;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= 5.1e+48: tmp = math.log(t) - z else: tmp = math.log(t) - y return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= 5.1e+48) tmp = Float64(log(t) - z); else tmp = Float64(log(t) - y); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (y <= 5.1e+48) tmp = log(t) - z; else tmp = log(t) - y; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, 5.1e+48], N[(N[Log[t], $MachinePrecision] - z), $MachinePrecision], N[(N[Log[t], $MachinePrecision] - y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 5.1 \cdot 10^{+48}:\\
\;\;\;\;\log t - z\\
\mathbf{else}:\\
\;\;\;\;\log t - y\\
\end{array}
\end{array}
if y < 5.0999999999999998e48Initial program 99.9%
Taylor expanded in y around 0
lower--.f64N/A
Applied rewrites98.0%
Taylor expanded in x around 0
Applied rewrites58.1%
if 5.0999999999999998e48 < y Initial program 99.9%
Taylor expanded in z around 0
lower--.f64N/A
Applied rewrites87.7%
Taylor expanded in x around 0
Applied rewrites70.9%
(FPCore (x y z t) :precision binary64 (if (<= y 5.1e+48) (- z) (* -1.0 y)))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 5.1e+48) {
tmp = -z;
} else {
tmp = -1.0 * y;
}
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) :: tmp
if (y <= 5.1d+48) then
tmp = -z
else
tmp = (-1.0d0) * y
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (y <= 5.1e+48) {
tmp = -z;
} else {
tmp = -1.0 * y;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= 5.1e+48: tmp = -z else: tmp = -1.0 * y return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= 5.1e+48) tmp = Float64(-z); else tmp = Float64(-1.0 * y); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (y <= 5.1e+48) tmp = -z; else tmp = -1.0 * y; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, 5.1e+48], (-z), N[(-1.0 * y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 5.1 \cdot 10^{+48}:\\
\;\;\;\;-z\\
\mathbf{else}:\\
\;\;\;\;-1 \cdot y\\
\end{array}
\end{array}
if y < 5.0999999999999998e48Initial program 99.9%
Taylor expanded in z around inf
mul-1-negN/A
lower-neg.f6431.4
Applied rewrites31.4%
if 5.0999999999999998e48 < y Initial program 99.9%
Taylor expanded in z around 0
lower--.f64N/A
Applied rewrites87.7%
Taylor expanded in y around inf
Applied rewrites87.7%
Taylor expanded in y around inf
Applied rewrites70.9%
(FPCore (x y z t) :precision binary64 (- z))
double code(double x, double y, double z, double t) {
return -z;
}
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 = -z
end function
public static double code(double x, double y, double z, double t) {
return -z;
}
def code(x, y, z, t): return -z
function code(x, y, z, t) return Float64(-z) end
function tmp = code(x, y, z, t) tmp = -z; end
code[x_, y_, z_, t_] := (-z)
\begin{array}{l}
\\
-z
\end{array}
Initial program 99.9%
Taylor expanded in z around inf
mul-1-negN/A
lower-neg.f6423.6
Applied rewrites23.6%
herbie shell --seed 2025017
(FPCore (x y z t)
:name "Numeric.SpecFunctions:incompleteGamma from math-functions-0.1.5.2, A"
:precision binary64
(+ (- (- (* x (log y)) y) z) (log t)))