
(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 14 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) y) z)))
double code(double x, double y, double z, double t) {
return fma(log(y), x, ((log(t) - y) - z));
}
function code(x, y, z, t) return fma(log(y), x, Float64(Float64(log(t) - y) - z)) end
code[x_, y_, z_, t_] := N[(N[Log[y], $MachinePrecision] * x + N[(N[(N[Log[t], $MachinePrecision] - y), $MachinePrecision] - z), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(\log y, x, \left(\log t - y\right) - z\right)
\end{array}
Initial program 99.9%
lift-+.f64N/A
lift--.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-log.f64N/A
lift-log.f64N/A
+-commutativeN/A
associate--r+N/A
associate--l+N/A
lower--.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift-log.f64N/A
lift-log.f64N/A
+-commutativeN/A
lower-+.f6499.9
Applied rewrites99.9%
lift-+.f64N/A
lift--.f64N/A
lift-log.f64N/A
lift-log.f64N/A
lift-fma.f64N/A
associate--l+N/A
+-commutativeN/A
lower-fma.f64N/A
lift-log.f64N/A
associate--r+N/A
lower--.f64N/A
lower--.f64N/A
lift-log.f6499.9
Applied rewrites99.9%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (- (* x (log y)) y)))
(if (<= t_1 -5e+112)
(- y)
(if (<= t_1 5e+71) (+ (- z) (log t)) (* (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+112) {
tmp = -y;
} else if (t_1 <= 5e+71) {
tmp = -z + log(t);
} 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+112)) then
tmp = -y
else if (t_1 <= 5d+71) then
tmp = -z + log(t)
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+112) {
tmp = -y;
} else if (t_1 <= 5e+71) {
tmp = -z + Math.log(t);
} 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+112: tmp = -y elif t_1 <= 5e+71: tmp = -z + math.log(t) 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+112) tmp = Float64(-y); elseif (t_1 <= 5e+71) tmp = Float64(Float64(-z) + log(t)); 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+112) tmp = -y; elseif (t_1 <= 5e+71) tmp = -z + log(t); 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+112], (-y), If[LessEqual[t$95$1, 5e+71], N[((-z) + N[Log[t], $MachinePrecision]), $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^{+112}:\\
\;\;\;\;-y\\
\mathbf{elif}\;t\_1 \leq 5 \cdot 10^{+71}:\\
\;\;\;\;\left(-z\right) + \log t\\
\mathbf{else}:\\
\;\;\;\;\log y \cdot x\\
\end{array}
\end{array}
if (-.f64 (*.f64 x (log.f64 y)) y) < -5e112Initial program 99.8%
Taylor expanded in y around inf
mul-1-negN/A
lower-neg.f6453.2
Applied rewrites53.2%
if -5e112 < (-.f64 (*.f64 x (log.f64 y)) y) < 4.99999999999999972e71Initial program 100.0%
Taylor expanded in z around inf
mul-1-negN/A
lower-neg.f6478.3
Applied rewrites78.3%
if 4.99999999999999972e71 < (-.f64 (*.f64 x (log.f64 y)) y) Initial program 99.7%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
lift-log.f6487.3
Applied rewrites87.3%
(FPCore (x y z t) :precision binary64 (let* ((t_1 (- (* x (log y)) y))) (if (<= t_1 -5e+112) (- y) (if (<= t_1 5e+71) (- 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+112) {
tmp = -y;
} else if (t_1 <= 5e+71) {
tmp = -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+112)) then
tmp = -y
else if (t_1 <= 5d+71) then
tmp = -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+112) {
tmp = -y;
} else if (t_1 <= 5e+71) {
tmp = -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+112: tmp = -y elif t_1 <= 5e+71: tmp = -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+112) tmp = Float64(-y); elseif (t_1 <= 5e+71) tmp = Float64(-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+112) tmp = -y; elseif (t_1 <= 5e+71) tmp = -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+112], (-y), If[LessEqual[t$95$1, 5e+71], (-z), 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^{+112}:\\
\;\;\;\;-y\\
\mathbf{elif}\;t\_1 \leq 5 \cdot 10^{+71}:\\
\;\;\;\;-z\\
\mathbf{else}:\\
\;\;\;\;\log y \cdot x\\
\end{array}
\end{array}
if (-.f64 (*.f64 x (log.f64 y)) y) < -5e112Initial program 99.8%
Taylor expanded in y around inf
mul-1-negN/A
lower-neg.f6453.2
Applied rewrites53.2%
if -5e112 < (-.f64 (*.f64 x (log.f64 y)) y) < 4.99999999999999972e71Initial program 100.0%
Taylor expanded in z around inf
mul-1-negN/A
lower-neg.f6455.4
Applied rewrites55.4%
if 4.99999999999999972e71 < (-.f64 (*.f64 x (log.f64 y)) y) Initial program 99.7%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
lift-log.f6487.3
Applied rewrites87.3%
(FPCore (x y z t) :precision binary64 (if (or (<= z -510.0) (not (<= z 2.2e-7))) (- (* (log y) x) (+ z y)) (- (fma (log y) x (log t)) y)))
double code(double x, double y, double z, double t) {
double tmp;
if ((z <= -510.0) || !(z <= 2.2e-7)) {
tmp = (log(y) * x) - (z + y);
} else {
tmp = fma(log(y), x, log(t)) - y;
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if ((z <= -510.0) || !(z <= 2.2e-7)) tmp = Float64(Float64(log(y) * x) - Float64(z + y)); else tmp = Float64(fma(log(y), x, log(t)) - y); end return tmp end
code[x_, y_, z_, t_] := If[Or[LessEqual[z, -510.0], N[Not[LessEqual[z, 2.2e-7]], $MachinePrecision]], N[(N[(N[Log[y], $MachinePrecision] * x), $MachinePrecision] - N[(z + y), $MachinePrecision]), $MachinePrecision], N[(N[(N[Log[y], $MachinePrecision] * x + N[Log[t], $MachinePrecision]), $MachinePrecision] - y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -510 \lor \neg \left(z \leq 2.2 \cdot 10^{-7}\right):\\
\;\;\;\;\log y \cdot x - \left(z + y\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\log y, x, \log t\right) - y\\
\end{array}
\end{array}
if z < -510 or 2.2000000000000001e-7 < z Initial program 99.9%
lift-+.f64N/A
lift--.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-log.f64N/A
lift-log.f64N/A
+-commutativeN/A
associate--r+N/A
associate--l+N/A
lower--.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift-log.f64N/A
lift-log.f64N/A
+-commutativeN/A
lower-+.f6499.9
Applied rewrites99.9%
Taylor expanded in x around inf
*-commutativeN/A
lift-log.f64N/A
lift-*.f6499.5
Applied rewrites99.5%
if -510 < z < 2.2000000000000001e-7Initial program 99.8%
Taylor expanded in z around 0
lower--.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift-log.f64N/A
lift-log.f6499.8
Applied rewrites99.8%
Final simplification99.6%
(FPCore (x y z t) :precision binary64 (if (<= y 0.00024) (fma (log y) x (- (log t) z)) (- (* (log y) x) (+ z y))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 0.00024) {
tmp = fma(log(y), x, (log(t) - z));
} else {
tmp = (log(y) * x) - (z + y);
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (y <= 0.00024) tmp = fma(log(y), x, Float64(log(t) - z)); else tmp = Float64(Float64(log(y) * x) - Float64(z + y)); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[y, 0.00024], N[(N[Log[y], $MachinePrecision] * x + N[(N[Log[t], $MachinePrecision] - z), $MachinePrecision]), $MachinePrecision], N[(N[(N[Log[y], $MachinePrecision] * x), $MachinePrecision] - N[(z + y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 0.00024:\\
\;\;\;\;\mathsf{fma}\left(\log y, x, \log t - z\right)\\
\mathbf{else}:\\
\;\;\;\;\log y \cdot x - \left(z + y\right)\\
\end{array}
\end{array}
if y < 2.40000000000000006e-4Initial program 99.8%
lift-+.f64N/A
lift--.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-log.f64N/A
lift-log.f64N/A
+-commutativeN/A
associate--r+N/A
associate--l+N/A
lower--.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift-log.f64N/A
lift-log.f64N/A
+-commutativeN/A
lower-+.f6499.8
Applied rewrites99.8%
lift-+.f64N/A
lift--.f64N/A
lift-log.f64N/A
lift-log.f64N/A
lift-fma.f64N/A
associate--l+N/A
+-commutativeN/A
lower-fma.f64N/A
lift-log.f64N/A
associate--r+N/A
lower--.f64N/A
lower--.f64N/A
lift-log.f6499.8
Applied rewrites99.8%
Taylor expanded in y around 0
lift-log.f6499.5
Applied rewrites99.5%
if 2.40000000000000006e-4 < y Initial program 100.0%
lift-+.f64N/A
lift--.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-log.f64N/A
lift-log.f64N/A
+-commutativeN/A
associate--r+N/A
associate--l+N/A
lower--.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift-log.f64N/A
lift-log.f64N/A
+-commutativeN/A
lower-+.f64100.0
Applied rewrites100.0%
Taylor expanded in x around inf
*-commutativeN/A
lift-log.f64N/A
lift-*.f6497.9
Applied rewrites97.9%
(FPCore (x y z t) :precision binary64 (if (<= y 0.00024) (- (fma (log y) x (log t)) z) (- (* (log y) x) (+ z y))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 0.00024) {
tmp = fma(log(y), x, log(t)) - z;
} else {
tmp = (log(y) * x) - (z + y);
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (y <= 0.00024) tmp = Float64(fma(log(y), x, log(t)) - z); else tmp = Float64(Float64(log(y) * x) - Float64(z + y)); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[y, 0.00024], N[(N[(N[Log[y], $MachinePrecision] * x + N[Log[t], $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision], N[(N[(N[Log[y], $MachinePrecision] * x), $MachinePrecision] - N[(z + y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 0.00024:\\
\;\;\;\;\mathsf{fma}\left(\log y, x, \log t\right) - z\\
\mathbf{else}:\\
\;\;\;\;\log y \cdot x - \left(z + y\right)\\
\end{array}
\end{array}
if y < 2.40000000000000006e-4Initial program 99.8%
Taylor expanded in y around 0
lower--.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift-log.f64N/A
lift-log.f6499.5
Applied rewrites99.5%
if 2.40000000000000006e-4 < y Initial program 100.0%
lift-+.f64N/A
lift--.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-log.f64N/A
lift-log.f64N/A
+-commutativeN/A
associate--r+N/A
associate--l+N/A
lower--.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift-log.f64N/A
lift-log.f64N/A
+-commutativeN/A
lower-+.f64100.0
Applied rewrites100.0%
Taylor expanded in x around inf
*-commutativeN/A
lift-log.f64N/A
lift-*.f6497.9
Applied rewrites97.9%
(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(fma(log(y), x, log(t)) - Float64(z + y)) end
code[x_, y_, z_, t_] := N[(N[(N[Log[y], $MachinePrecision] * x + N[Log[t], $MachinePrecision]), $MachinePrecision] - N[(z + y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(\log y, x, \log t\right) - \left(z + y\right)
\end{array}
Initial program 99.9%
lift-+.f64N/A
lift--.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-log.f64N/A
lift-log.f64N/A
+-commutativeN/A
associate--r+N/A
associate--l+N/A
lower--.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift-log.f64N/A
lift-log.f64N/A
+-commutativeN/A
lower-+.f6499.9
Applied rewrites99.9%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (* (log y) x)) (t_2 (+ (- y) (log t))))
(if (<= z -1.15e+54)
(- z)
(if (<= z -1.55e-290)
t_2
(if (<= z 7e-137)
t_1
(if (<= z 3.7e-26) t_2 (if (<= z 2.45e+20) t_1 (- z))))))))
double code(double x, double y, double z, double t) {
double t_1 = log(y) * x;
double t_2 = -y + log(t);
double tmp;
if (z <= -1.15e+54) {
tmp = -z;
} else if (z <= -1.55e-290) {
tmp = t_2;
} else if (z <= 7e-137) {
tmp = t_1;
} else if (z <= 3.7e-26) {
tmp = t_2;
} else if (z <= 2.45e+20) {
tmp = t_1;
} else {
tmp = -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) :: t_1
real(8) :: t_2
real(8) :: tmp
t_1 = log(y) * x
t_2 = -y + log(t)
if (z <= (-1.15d+54)) then
tmp = -z
else if (z <= (-1.55d-290)) then
tmp = t_2
else if (z <= 7d-137) then
tmp = t_1
else if (z <= 3.7d-26) then
tmp = t_2
else if (z <= 2.45d+20) then
tmp = t_1
else
tmp = -z
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 t_2 = -y + Math.log(t);
double tmp;
if (z <= -1.15e+54) {
tmp = -z;
} else if (z <= -1.55e-290) {
tmp = t_2;
} else if (z <= 7e-137) {
tmp = t_1;
} else if (z <= 3.7e-26) {
tmp = t_2;
} else if (z <= 2.45e+20) {
tmp = t_1;
} else {
tmp = -z;
}
return tmp;
}
def code(x, y, z, t): t_1 = math.log(y) * x t_2 = -y + math.log(t) tmp = 0 if z <= -1.15e+54: tmp = -z elif z <= -1.55e-290: tmp = t_2 elif z <= 7e-137: tmp = t_1 elif z <= 3.7e-26: tmp = t_2 elif z <= 2.45e+20: tmp = t_1 else: tmp = -z return tmp
function code(x, y, z, t) t_1 = Float64(log(y) * x) t_2 = Float64(Float64(-y) + log(t)) tmp = 0.0 if (z <= -1.15e+54) tmp = Float64(-z); elseif (z <= -1.55e-290) tmp = t_2; elseif (z <= 7e-137) tmp = t_1; elseif (z <= 3.7e-26) tmp = t_2; elseif (z <= 2.45e+20) tmp = t_1; else tmp = Float64(-z); end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = log(y) * x; t_2 = -y + log(t); tmp = 0.0; if (z <= -1.15e+54) tmp = -z; elseif (z <= -1.55e-290) tmp = t_2; elseif (z <= 7e-137) tmp = t_1; elseif (z <= 3.7e-26) tmp = t_2; elseif (z <= 2.45e+20) tmp = t_1; else tmp = -z; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[Log[y], $MachinePrecision] * x), $MachinePrecision]}, Block[{t$95$2 = N[((-y) + N[Log[t], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -1.15e+54], (-z), If[LessEqual[z, -1.55e-290], t$95$2, If[LessEqual[z, 7e-137], t$95$1, If[LessEqual[z, 3.7e-26], t$95$2, If[LessEqual[z, 2.45e+20], t$95$1, (-z)]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \log y \cdot x\\
t_2 := \left(-y\right) + \log t\\
\mathbf{if}\;z \leq -1.15 \cdot 10^{+54}:\\
\;\;\;\;-z\\
\mathbf{elif}\;z \leq -1.55 \cdot 10^{-290}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;z \leq 7 \cdot 10^{-137}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \leq 3.7 \cdot 10^{-26}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;z \leq 2.45 \cdot 10^{+20}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;-z\\
\end{array}
\end{array}
if z < -1.14999999999999997e54 or 2.45e20 < z Initial program 99.9%
Taylor expanded in z around inf
mul-1-negN/A
lower-neg.f6470.2
Applied rewrites70.2%
if -1.14999999999999997e54 < z < -1.54999999999999995e-290 or 7.0000000000000002e-137 < z < 3.6999999999999999e-26Initial program 99.8%
Taylor expanded in y around inf
mul-1-negN/A
lower-neg.f6463.0
Applied rewrites63.0%
if -1.54999999999999995e-290 < z < 7.0000000000000002e-137 or 3.6999999999999999e-26 < z < 2.45e20Initial program 99.8%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
lift-log.f6471.1
Applied rewrites71.1%
(FPCore (x y z t) :precision binary64 (if (or (<= x -2.2) (not (<= x 1.5))) (- (* (log y) x) (+ z y)) (- (- (log t) y) z)))
double code(double x, double y, double z, double t) {
double tmp;
if ((x <= -2.2) || !(x <= 1.5)) {
tmp = (log(y) * x) - (z + y);
} 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 <= (-2.2d0)) .or. (.not. (x <= 1.5d0))) then
tmp = (log(y) * x) - (z + y)
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 <= -2.2) || !(x <= 1.5)) {
tmp = (Math.log(y) * x) - (z + y);
} else {
tmp = (Math.log(t) - y) - z;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (x <= -2.2) or not (x <= 1.5): tmp = (math.log(y) * x) - (z + y) else: tmp = (math.log(t) - y) - z return tmp
function code(x, y, z, t) tmp = 0.0 if ((x <= -2.2) || !(x <= 1.5)) tmp = Float64(Float64(log(y) * x) - Float64(z + y)); 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 <= -2.2) || ~((x <= 1.5))) tmp = (log(y) * x) - (z + y); else tmp = (log(t) - y) - z; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[x, -2.2], N[Not[LessEqual[x, 1.5]], $MachinePrecision]], N[(N[(N[Log[y], $MachinePrecision] * x), $MachinePrecision] - N[(z + y), $MachinePrecision]), $MachinePrecision], N[(N[(N[Log[t], $MachinePrecision] - y), $MachinePrecision] - z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.2 \lor \neg \left(x \leq 1.5\right):\\
\;\;\;\;\log y \cdot x - \left(z + y\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\log t - y\right) - z\\
\end{array}
\end{array}
if x < -2.2000000000000002 or 1.5 < x Initial program 99.7%
lift-+.f64N/A
lift--.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-log.f64N/A
lift-log.f64N/A
+-commutativeN/A
associate--r+N/A
associate--l+N/A
lower--.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift-log.f64N/A
lift-log.f64N/A
+-commutativeN/A
lower-+.f6499.8
Applied rewrites99.8%
Taylor expanded in x around inf
*-commutativeN/A
lift-log.f64N/A
lift-*.f6498.6
Applied rewrites98.6%
if -2.2000000000000002 < x < 1.5Initial program 100.0%
Taylor expanded in x around 0
associate--r+N/A
lower--.f64N/A
lower--.f64N/A
lift-log.f6499.2
Applied rewrites99.2%
Final simplification98.9%
(FPCore (x y z t) :precision binary64 (if (or (<= x -1.35e+78) (not (<= x 9.5e+96))) (fma (log y) x (- y)) (- (- (log t) y) z)))
double code(double x, double y, double z, double t) {
double tmp;
if ((x <= -1.35e+78) || !(x <= 9.5e+96)) {
tmp = fma(log(y), x, -y);
} else {
tmp = (log(t) - y) - z;
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if ((x <= -1.35e+78) || !(x <= 9.5e+96)) tmp = fma(log(y), x, Float64(-y)); else tmp = Float64(Float64(log(t) - y) - z); end return tmp end
code[x_, y_, z_, t_] := If[Or[LessEqual[x, -1.35e+78], N[Not[LessEqual[x, 9.5e+96]], $MachinePrecision]], N[(N[Log[y], $MachinePrecision] * x + (-y)), $MachinePrecision], N[(N[(N[Log[t], $MachinePrecision] - y), $MachinePrecision] - z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.35 \cdot 10^{+78} \lor \neg \left(x \leq 9.5 \cdot 10^{+96}\right):\\
\;\;\;\;\mathsf{fma}\left(\log y, x, -y\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\log t - y\right) - z\\
\end{array}
\end{array}
if x < -1.35000000000000002e78 or 9.50000000000000089e96 < x Initial program 99.7%
lift-+.f64N/A
lift--.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-log.f64N/A
lift-log.f64N/A
+-commutativeN/A
associate--r+N/A
associate--l+N/A
lower--.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift-log.f64N/A
lift-log.f64N/A
+-commutativeN/A
lower-+.f6499.7
Applied rewrites99.7%
lift-+.f64N/A
lift--.f64N/A
lift-log.f64N/A
lift-log.f64N/A
lift-fma.f64N/A
associate--l+N/A
+-commutativeN/A
lower-fma.f64N/A
lift-log.f64N/A
associate--r+N/A
lower--.f64N/A
lower--.f64N/A
lift-log.f6499.7
Applied rewrites99.7%
Taylor expanded in y around inf
mul-1-negN/A
lower-neg.f6486.6
Applied rewrites86.6%
if -1.35000000000000002e78 < x < 9.50000000000000089e96Initial program 100.0%
Taylor expanded in x around 0
associate--r+N/A
lower--.f64N/A
lower--.f64N/A
lift-log.f6493.4
Applied rewrites93.4%
Final simplification90.8%
(FPCore (x y z t) :precision binary64 (if (<= x -1.35e+78) (fma (log y) x (- y)) (if (<= x 1.85e+90) (- (- (log t) y) z) (fma (log y) x (- z)))))
double code(double x, double y, double z, double t) {
double tmp;
if (x <= -1.35e+78) {
tmp = fma(log(y), x, -y);
} else if (x <= 1.85e+90) {
tmp = (log(t) - y) - z;
} else {
tmp = fma(log(y), x, -z);
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (x <= -1.35e+78) tmp = fma(log(y), x, Float64(-y)); elseif (x <= 1.85e+90) tmp = Float64(Float64(log(t) - y) - z); else tmp = fma(log(y), x, Float64(-z)); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[x, -1.35e+78], N[(N[Log[y], $MachinePrecision] * x + (-y)), $MachinePrecision], If[LessEqual[x, 1.85e+90], N[(N[(N[Log[t], $MachinePrecision] - y), $MachinePrecision] - z), $MachinePrecision], N[(N[Log[y], $MachinePrecision] * x + (-z)), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.35 \cdot 10^{+78}:\\
\;\;\;\;\mathsf{fma}\left(\log y, x, -y\right)\\
\mathbf{elif}\;x \leq 1.85 \cdot 10^{+90}:\\
\;\;\;\;\left(\log t - y\right) - z\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\log y, x, -z\right)\\
\end{array}
\end{array}
if x < -1.35000000000000002e78Initial program 99.7%
lift-+.f64N/A
lift--.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-log.f64N/A
lift-log.f64N/A
+-commutativeN/A
associate--r+N/A
associate--l+N/A
lower--.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift-log.f64N/A
lift-log.f64N/A
+-commutativeN/A
lower-+.f6499.7
Applied rewrites99.7%
lift-+.f64N/A
lift--.f64N/A
lift-log.f64N/A
lift-log.f64N/A
lift-fma.f64N/A
associate--l+N/A
+-commutativeN/A
lower-fma.f64N/A
lift-log.f64N/A
associate--r+N/A
lower--.f64N/A
lower--.f64N/A
lift-log.f6499.8
Applied rewrites99.8%
Taylor expanded in y around inf
mul-1-negN/A
lower-neg.f6488.4
Applied rewrites88.4%
if -1.35000000000000002e78 < x < 1.85e90Initial program 100.0%
Taylor expanded in x around 0
associate--r+N/A
lower--.f64N/A
lower--.f64N/A
lift-log.f6493.3
Applied rewrites93.3%
if 1.85e90 < x Initial program 99.6%
lift-+.f64N/A
lift--.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-log.f64N/A
lift-log.f64N/A
+-commutativeN/A
associate--r+N/A
associate--l+N/A
lower--.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift-log.f64N/A
lift-log.f64N/A
+-commutativeN/A
lower-+.f6499.6
Applied rewrites99.6%
lift-+.f64N/A
lift--.f64N/A
lift-log.f64N/A
lift-log.f64N/A
lift-fma.f64N/A
associate--l+N/A
+-commutativeN/A
lower-fma.f64N/A
lift-log.f64N/A
associate--r+N/A
lower--.f64N/A
lower--.f64N/A
lift-log.f6499.7
Applied rewrites99.7%
Taylor expanded in z around inf
mul-1-negN/A
lift-neg.f6492.1
Applied rewrites92.1%
(FPCore (x y z t) :precision binary64 (if (or (<= x -1.9e+138) (not (<= x 9.5e+115))) (* (log y) x) (- (- (log t) y) z)))
double code(double x, double y, double z, double t) {
double tmp;
if ((x <= -1.9e+138) || !(x <= 9.5e+115)) {
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.9d+138)) .or. (.not. (x <= 9.5d+115))) 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.9e+138) || !(x <= 9.5e+115)) {
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.9e+138) or not (x <= 9.5e+115): 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.9e+138) || !(x <= 9.5e+115)) 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.9e+138) || ~((x <= 9.5e+115))) 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.9e+138], N[Not[LessEqual[x, 9.5e+115]], $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.9 \cdot 10^{+138} \lor \neg \left(x \leq 9.5 \cdot 10^{+115}\right):\\
\;\;\;\;\log y \cdot x\\
\mathbf{else}:\\
\;\;\;\;\left(\log t - y\right) - z\\
\end{array}
\end{array}
if x < -1.90000000000000006e138 or 9.4999999999999997e115 < x Initial program 99.7%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
lift-log.f6477.3
Applied rewrites77.3%
if -1.90000000000000006e138 < x < 9.4999999999999997e115Initial program 100.0%
Taylor expanded in x around 0
associate--r+N/A
lower--.f64N/A
lower--.f64N/A
lift-log.f6490.2
Applied rewrites90.2%
Final simplification85.9%
(FPCore (x y z t) :precision binary64 (if (or (<= z -1.15e+54) (not (<= z 800000000000.0))) (- z) (- y)))
double code(double x, double y, double z, double t) {
double tmp;
if ((z <= -1.15e+54) || !(z <= 800000000000.0)) {
tmp = -z;
} else {
tmp = -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 <= (-1.15d+54)) .or. (.not. (z <= 800000000000.0d0))) then
tmp = -z
else
tmp = -y
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((z <= -1.15e+54) || !(z <= 800000000000.0)) {
tmp = -z;
} else {
tmp = -y;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (z <= -1.15e+54) or not (z <= 800000000000.0): tmp = -z else: tmp = -y return tmp
function code(x, y, z, t) tmp = 0.0 if ((z <= -1.15e+54) || !(z <= 800000000000.0)) tmp = Float64(-z); else tmp = Float64(-y); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((z <= -1.15e+54) || ~((z <= 800000000000.0))) tmp = -z; else tmp = -y; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[z, -1.15e+54], N[Not[LessEqual[z, 800000000000.0]], $MachinePrecision]], (-z), (-y)]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.15 \cdot 10^{+54} \lor \neg \left(z \leq 800000000000\right):\\
\;\;\;\;-z\\
\mathbf{else}:\\
\;\;\;\;-y\\
\end{array}
\end{array}
if z < -1.14999999999999997e54 or 8e11 < z Initial program 99.9%
Taylor expanded in z around inf
mul-1-negN/A
lower-neg.f6469.6
Applied rewrites69.6%
if -1.14999999999999997e54 < z < 8e11Initial program 99.8%
Taylor expanded in y around inf
mul-1-negN/A
lower-neg.f6431.3
Applied rewrites31.3%
Final simplification48.9%
(FPCore (x y z t) :precision binary64 (- y))
double code(double x, double y, double z, double t) {
return -y;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z, t)
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
end function
public static double code(double x, double y, double z, double t) {
return -y;
}
def code(x, y, z, t): return -y
function code(x, y, z, t) return Float64(-y) end
function tmp = code(x, y, z, t) tmp = -y; end
code[x_, y_, z_, t_] := (-y)
\begin{array}{l}
\\
-y
\end{array}
Initial program 99.9%
Taylor expanded in y around inf
mul-1-negN/A
lower-neg.f6423.8
Applied rewrites23.8%
herbie shell --seed 2025064
(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)))