
(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]
\left(\left(x \cdot \log y - y\right) - z\right) + \log t
Herbie found 8 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]
\left(\left(x \cdot \log y - y\right) - z\right) + \log t
(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, Float64(log(t) - z)) - y) end
code[x_, y_, z_, t_] := N[(N[(N[Log[y], $MachinePrecision] * x + N[(N[Log[t], $MachinePrecision] - z), $MachinePrecision]), $MachinePrecision] - y), $MachinePrecision]
\mathsf{fma}\left(\log y, x, \log t - z\right) - y
Initial program 99.9%
lift-+.f64N/A
+-commutativeN/A
add-flipN/A
lift--.f64N/A
sub-negate-revN/A
lift--.f64N/A
associate--r-N/A
associate--r+N/A
lower--.f64N/A
sub-flipN/A
sub-negate-revN/A
associate--l+N/A
lower--.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6499.9%
Applied rewrites99.9%
lift--.f64N/A
lift-fma.f64N/A
associate--l+N/A
lower-fma.f64N/A
lower--.f6499.9%
Applied rewrites99.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(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]
\left(\mathsf{fma}\left(\log y, x, \log t\right) - z\right) - y
Initial program 99.9%
lift-+.f64N/A
+-commutativeN/A
add-flipN/A
lift--.f64N/A
sub-negate-revN/A
lift--.f64N/A
associate--r-N/A
associate--r+N/A
lower--.f64N/A
sub-flipN/A
sub-negate-revN/A
associate--l+N/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
(if (<= y 4.7e+76)
(+ (- (* x (log y)) z) (log t))
(if (<= y 2.9e+135)
(- (* z (- (/ (log t) z) 1.0)) y)
(- (fma (log y) x (log t)) y))))double code(double x, double y, double z, double t) {
double tmp;
if (y <= 4.7e+76) {
tmp = ((x * log(y)) - z) + log(t);
} else if (y <= 2.9e+135) {
tmp = (z * ((log(t) / z) - 1.0)) - y;
} else {
tmp = fma(log(y), x, log(t)) - y;
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (y <= 4.7e+76) tmp = Float64(Float64(Float64(x * log(y)) - z) + log(t)); elseif (y <= 2.9e+135) tmp = Float64(Float64(z * Float64(Float64(log(t) / z) - 1.0)) - y); else tmp = Float64(fma(log(y), x, log(t)) - y); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[y, 4.7e+76], N[(N[(N[(x * N[Log[y], $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision] + N[Log[t], $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 2.9e+135], N[(N[(z * N[(N[(N[Log[t], $MachinePrecision] / z), $MachinePrecision] - 1.0), $MachinePrecision]), $MachinePrecision] - y), $MachinePrecision], N[(N[(N[Log[y], $MachinePrecision] * x + N[Log[t], $MachinePrecision]), $MachinePrecision] - y), $MachinePrecision]]]
\begin{array}{l}
\mathbf{if}\;y \leq 4.7 \cdot 10^{+76}:\\
\;\;\;\;\left(x \cdot \log y - z\right) + \log t\\
\mathbf{elif}\;y \leq 2.9 \cdot 10^{+135}:\\
\;\;\;\;z \cdot \left(\frac{\log t}{z} - 1\right) - y\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\log y, x, \log t\right) - y\\
\end{array}
if y < 4.7000000000000003e76Initial program 99.9%
Taylor expanded in y around 0
lower--.f64N/A
lower-*.f64N/A
lower-log.f6471.0%
Applied rewrites71.0%
if 4.7000000000000003e76 < y < 2.8999999999999999e135Initial program 99.9%
lift-+.f64N/A
+-commutativeN/A
add-flipN/A
lift--.f64N/A
sub-negate-revN/A
lift--.f64N/A
associate--r-N/A
associate--r+N/A
lower--.f64N/A
sub-flipN/A
sub-negate-revN/A
associate--l+N/A
lower--.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6499.9%
Applied rewrites99.9%
Taylor expanded in x around 0
lower--.f64N/A
lower-log.f6470.6%
Applied rewrites70.6%
Taylor expanded in z around inf
lower-*.f64N/A
lower--.f64N/A
lower-/.f64N/A
lower-log.f6470.4%
Applied rewrites70.4%
if 2.8999999999999999e135 < y Initial program 99.9%
Taylor expanded in z around 0
lower--.f64N/A
lower-+.f64N/A
lower-log.f64N/A
lower-*.f64N/A
lower-log.f6470.0%
Applied rewrites70.0%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lift-fma.f6470.0%
Applied rewrites70.0%
(FPCore (x y z t) :precision binary64 (let* ((t_1 (- (fma (log y) x (log t)) y))) (if (<= x -5.2e+132) t_1 (if (<= x 11500.0) (- (- (log t) z) y) t_1))))
double code(double x, double y, double z, double t) {
double t_1 = fma(log(y), x, log(t)) - y;
double tmp;
if (x <= -5.2e+132) {
tmp = t_1;
} else if (x <= 11500.0) {
tmp = (log(t) - z) - y;
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t) t_1 = Float64(fma(log(y), x, log(t)) - y) tmp = 0.0 if (x <= -5.2e+132) tmp = t_1; elseif (x <= 11500.0) tmp = Float64(Float64(log(t) - z) - y); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[(N[Log[y], $MachinePrecision] * x + N[Log[t], $MachinePrecision]), $MachinePrecision] - y), $MachinePrecision]}, If[LessEqual[x, -5.2e+132], t$95$1, If[LessEqual[x, 11500.0], N[(N[(N[Log[t], $MachinePrecision] - z), $MachinePrecision] - y), $MachinePrecision], t$95$1]]]
\begin{array}{l}
t_1 := \mathsf{fma}\left(\log y, x, \log t\right) - y\\
\mathbf{if}\;x \leq -5.2 \cdot 10^{+132}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq 11500:\\
\;\;\;\;\left(\log t - z\right) - y\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
if x < -5.2e132 or 11500 < x Initial program 99.9%
Taylor expanded in z around 0
lower--.f64N/A
lower-+.f64N/A
lower-log.f64N/A
lower-*.f64N/A
lower-log.f6470.0%
Applied rewrites70.0%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lift-fma.f6470.0%
Applied rewrites70.0%
if -5.2e132 < x < 11500Initial program 99.9%
lift-+.f64N/A
+-commutativeN/A
add-flipN/A
lift--.f64N/A
sub-negate-revN/A
lift--.f64N/A
associate--r-N/A
associate--r+N/A
lower--.f64N/A
sub-flipN/A
sub-negate-revN/A
associate--l+N/A
lower--.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6499.9%
Applied rewrites99.9%
Taylor expanded in x around 0
lower--.f64N/A
lower-log.f6470.6%
Applied rewrites70.6%
(FPCore (x y z t) :precision binary64 (- (- (log t) z) y))
double code(double x, double y, double z, double t) {
return (log(t) - z) - 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 = (log(t) - z) - y
end function
public static double code(double x, double y, double z, double t) {
return (Math.log(t) - z) - y;
}
def code(x, y, z, t): return (math.log(t) - z) - y
function code(x, y, z, t) return Float64(Float64(log(t) - z) - y) end
function tmp = code(x, y, z, t) tmp = (log(t) - z) - y; end
code[x_, y_, z_, t_] := N[(N[(N[Log[t], $MachinePrecision] - z), $MachinePrecision] - y), $MachinePrecision]
\left(\log t - z\right) - y
Initial program 99.9%
lift-+.f64N/A
+-commutativeN/A
add-flipN/A
lift--.f64N/A
sub-negate-revN/A
lift--.f64N/A
associate--r-N/A
associate--r+N/A
lower--.f64N/A
sub-flipN/A
sub-negate-revN/A
associate--l+N/A
lower--.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6499.9%
Applied rewrites99.9%
Taylor expanded in x around 0
lower--.f64N/A
lower-log.f6470.6%
Applied rewrites70.6%
(FPCore (x y z t) :precision binary64 (if (<= z -3.3e+103) (- z) (if (<= z 1.1e+61) (- (log t) y) (- z))))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -3.3e+103) {
tmp = -z;
} else if (z <= 1.1e+61) {
tmp = log(t) - y;
} 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) :: tmp
if (z <= (-3.3d+103)) then
tmp = -z
else if (z <= 1.1d+61) then
tmp = log(t) - y
else
tmp = -z
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (z <= -3.3e+103) {
tmp = -z;
} else if (z <= 1.1e+61) {
tmp = Math.log(t) - y;
} else {
tmp = -z;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if z <= -3.3e+103: tmp = -z elif z <= 1.1e+61: tmp = math.log(t) - y else: tmp = -z return tmp
function code(x, y, z, t) tmp = 0.0 if (z <= -3.3e+103) tmp = Float64(-z); elseif (z <= 1.1e+61) tmp = Float64(log(t) - y); else tmp = Float64(-z); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (z <= -3.3e+103) tmp = -z; elseif (z <= 1.1e+61) tmp = log(t) - y; else tmp = -z; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[z, -3.3e+103], (-z), If[LessEqual[z, 1.1e+61], N[(N[Log[t], $MachinePrecision] - y), $MachinePrecision], (-z)]]
\begin{array}{l}
\mathbf{if}\;z \leq -3.3 \cdot 10^{+103}:\\
\;\;\;\;-z\\
\mathbf{elif}\;z \leq 1.1 \cdot 10^{+61}:\\
\;\;\;\;\log t - y\\
\mathbf{else}:\\
\;\;\;\;-z\\
\end{array}
if z < -3.30000000000000009e103 or 1.1e61 < z Initial program 99.9%
Taylor expanded in z around inf
lower-*.f6430.7%
Applied rewrites30.7%
lift-*.f64N/A
mul-1-negN/A
lower-neg.f6430.7%
Applied rewrites30.7%
if -3.30000000000000009e103 < z < 1.1e61Initial program 99.9%
Taylor expanded in z around 0
lower--.f64N/A
lower-+.f64N/A
lower-log.f64N/A
lower-*.f64N/A
lower-log.f6470.0%
Applied rewrites70.0%
Taylor expanded in x around 0
lower-log.f6441.4%
Applied rewrites41.4%
(FPCore (x y z t) :precision binary64 (if (<= y 2.9e+135) (- z) (- y)))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 2.9e+135) {
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 (y <= 2.9d+135) 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 (y <= 2.9e+135) {
tmp = -z;
} else {
tmp = -y;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= 2.9e+135: tmp = -z else: tmp = -y return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= 2.9e+135) tmp = Float64(-z); else tmp = Float64(-y); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (y <= 2.9e+135) tmp = -z; else tmp = -y; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, 2.9e+135], (-z), (-y)]
\begin{array}{l}
\mathbf{if}\;y \leq 2.9 \cdot 10^{+135}:\\
\;\;\;\;-z\\
\mathbf{else}:\\
\;\;\;\;-y\\
\end{array}
if y < 2.8999999999999999e135Initial program 99.9%
Taylor expanded in z around inf
lower-*.f6430.7%
Applied rewrites30.7%
lift-*.f64N/A
mul-1-negN/A
lower-neg.f6430.7%
Applied rewrites30.7%
if 2.8999999999999999e135 < y Initial program 99.9%
lift-+.f64N/A
+-commutativeN/A
add-flipN/A
lift--.f64N/A
sub-negate-revN/A
lift--.f64N/A
associate--r-N/A
associate--r+N/A
lower--.f64N/A
sub-flipN/A
sub-negate-revN/A
associate--l+N/A
lower--.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6499.9%
Applied rewrites99.9%
lift--.f64N/A
lift-fma.f64N/A
associate--l+N/A
lower-fma.f64N/A
lower--.f6499.9%
Applied rewrites99.9%
Taylor expanded in y around inf
lower-*.f6430.0%
Applied rewrites30.0%
lift-*.f64N/A
mul-1-negN/A
lift-neg.f6430.0%
Applied rewrites30.0%
(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)
-z
Initial program 99.9%
Taylor expanded in z around inf
lower-*.f6430.7%
Applied rewrites30.7%
lift-*.f64N/A
mul-1-negN/A
lower-neg.f6430.7%
Applied rewrites30.7%
herbie shell --seed 2025188
(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)))