
(FPCore (x y z) :precision binary64 (- (+ (- x (* (+ y 0.5) (log y))) y) z))
double code(double x, double y, double z) {
return ((x - ((y + 0.5) * log(y))) + y) - 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)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = ((x - ((y + 0.5d0) * log(y))) + y) - z
end function
public static double code(double x, double y, double z) {
return ((x - ((y + 0.5) * Math.log(y))) + y) - z;
}
def code(x, y, z): return ((x - ((y + 0.5) * math.log(y))) + y) - z
function code(x, y, z) return Float64(Float64(Float64(x - Float64(Float64(y + 0.5) * log(y))) + y) - z) end
function tmp = code(x, y, z) tmp = ((x - ((y + 0.5) * log(y))) + y) - z; end
code[x_, y_, z_] := N[(N[(N[(x - N[(N[(y + 0.5), $MachinePrecision] * N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + y), $MachinePrecision] - z), $MachinePrecision]
\left(\left(x - \left(y + 0.5\right) \cdot \log y\right) + y\right) - z
Herbie found 9 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z) :precision binary64 (- (+ (- x (* (+ y 0.5) (log y))) y) z))
double code(double x, double y, double z) {
return ((x - ((y + 0.5) * log(y))) + y) - 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)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = ((x - ((y + 0.5d0) * log(y))) + y) - z
end function
public static double code(double x, double y, double z) {
return ((x - ((y + 0.5) * Math.log(y))) + y) - z;
}
def code(x, y, z): return ((x - ((y + 0.5) * math.log(y))) + y) - z
function code(x, y, z) return Float64(Float64(Float64(x - Float64(Float64(y + 0.5) * log(y))) + y) - z) end
function tmp = code(x, y, z) tmp = ((x - ((y + 0.5) * log(y))) + y) - z; end
code[x_, y_, z_] := N[(N[(N[(x - N[(N[(y + 0.5), $MachinePrecision] * N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + y), $MachinePrecision] - z), $MachinePrecision]
\left(\left(x - \left(y + 0.5\right) \cdot \log y\right) + y\right) - z
(FPCore (x y z) :precision binary64 (- (- y (* (log y) (- y -0.5))) (- z x)))
double code(double x, double y, double z) {
return (y - (log(y) * (y - -0.5))) - (z - x);
}
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)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (y - (log(y) * (y - (-0.5d0)))) - (z - x)
end function
public static double code(double x, double y, double z) {
return (y - (Math.log(y) * (y - -0.5))) - (z - x);
}
def code(x, y, z): return (y - (math.log(y) * (y - -0.5))) - (z - x)
function code(x, y, z) return Float64(Float64(y - Float64(log(y) * Float64(y - -0.5))) - Float64(z - x)) end
function tmp = code(x, y, z) tmp = (y - (log(y) * (y - -0.5))) - (z - x); end
code[x_, y_, z_] := N[(N[(y - N[(N[Log[y], $MachinePrecision] * N[(y - -0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(z - x), $MachinePrecision]), $MachinePrecision]
\left(y - \log y \cdot \left(y - -0.5\right)\right) - \left(z - x\right)
Initial program 99.8%
lift--.f64N/A
sub-negate-revN/A
lift-+.f64N/A
add-flipN/A
lift--.f64N/A
lift-*.f64N/A
fp-cancel-sub-sign-invN/A
associate--l+N/A
associate--r+N/A
sub-negateN/A
lower--.f64N/A
Applied rewrites99.8%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (- x (+ z (* 0.5 (log y))))))
(if (<= x -1420000.0)
t_0
(if (<= x 4.4e+59) (- (- y (* (log y) (+ 0.5 y))) z) t_0))))double code(double x, double y, double z) {
double t_0 = x - (z + (0.5 * log(y)));
double tmp;
if (x <= -1420000.0) {
tmp = t_0;
} else if (x <= 4.4e+59) {
tmp = (y - (log(y) * (0.5 + y))) - z;
} else {
tmp = t_0;
}
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)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: t_0
real(8) :: tmp
t_0 = x - (z + (0.5d0 * log(y)))
if (x <= (-1420000.0d0)) then
tmp = t_0
else if (x <= 4.4d+59) then
tmp = (y - (log(y) * (0.5d0 + y))) - z
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = x - (z + (0.5 * Math.log(y)));
double tmp;
if (x <= -1420000.0) {
tmp = t_0;
} else if (x <= 4.4e+59) {
tmp = (y - (Math.log(y) * (0.5 + y))) - z;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = x - (z + (0.5 * math.log(y))) tmp = 0 if x <= -1420000.0: tmp = t_0 elif x <= 4.4e+59: tmp = (y - (math.log(y) * (0.5 + y))) - z else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(x - Float64(z + Float64(0.5 * log(y)))) tmp = 0.0 if (x <= -1420000.0) tmp = t_0; elseif (x <= 4.4e+59) tmp = Float64(Float64(y - Float64(log(y) * Float64(0.5 + y))) - z); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = x - (z + (0.5 * log(y))); tmp = 0.0; if (x <= -1420000.0) tmp = t_0; elseif (x <= 4.4e+59) tmp = (y - (log(y) * (0.5 + y))) - z; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(x - N[(z + N[(0.5 * N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -1420000.0], t$95$0, If[LessEqual[x, 4.4e+59], N[(N[(y - N[(N[Log[y], $MachinePrecision] * N[(0.5 + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision], t$95$0]]]
\begin{array}{l}
t_0 := x - \left(z + 0.5 \cdot \log y\right)\\
\mathbf{if}\;x \leq -1420000:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 4.4 \cdot 10^{+59}:\\
\;\;\;\;\left(y - \log y \cdot \left(0.5 + y\right)\right) - z\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
if x < -1.42e6 or 4.3999999999999999e59 < x Initial program 99.8%
Taylor expanded in y around 0
lower--.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-log.f6471.2%
Applied rewrites71.2%
if -1.42e6 < x < 4.3999999999999999e59Initial program 99.8%
Taylor expanded in x around 0
lower--.f64N/A
lower-*.f64N/A
lower-log.f64N/A
lower-+.f6470.1%
Applied rewrites70.1%
(FPCore (x y z) :precision binary64 (if (<= y 3.2e+87) (- x (+ z (* 0.5 (log y)))) (- (* (- 1.0 (log y)) y) z)))
double code(double x, double y, double z) {
double tmp;
if (y <= 3.2e+87) {
tmp = x - (z + (0.5 * log(y)));
} else {
tmp = ((1.0 - log(y)) * 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)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (y <= 3.2d+87) then
tmp = x - (z + (0.5d0 * log(y)))
else
tmp = ((1.0d0 - log(y)) * y) - z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= 3.2e+87) {
tmp = x - (z + (0.5 * Math.log(y)));
} else {
tmp = ((1.0 - Math.log(y)) * y) - z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 3.2e+87: tmp = x - (z + (0.5 * math.log(y))) else: tmp = ((1.0 - math.log(y)) * y) - z return tmp
function code(x, y, z) tmp = 0.0 if (y <= 3.2e+87) tmp = Float64(x - Float64(z + Float64(0.5 * log(y)))); else tmp = Float64(Float64(Float64(1.0 - log(y)) * y) - z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= 3.2e+87) tmp = x - (z + (0.5 * log(y))); else tmp = ((1.0 - log(y)) * y) - z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 3.2e+87], N[(x - N[(z + N[(0.5 * N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(1.0 - N[Log[y], $MachinePrecision]), $MachinePrecision] * y), $MachinePrecision] - z), $MachinePrecision]]
\begin{array}{l}
\mathbf{if}\;y \leq 3.2 \cdot 10^{+87}:\\
\;\;\;\;x - \left(z + 0.5 \cdot \log y\right)\\
\mathbf{else}:\\
\;\;\;\;\left(1 - \log y\right) \cdot y - z\\
\end{array}
if y < 3.2e87Initial program 99.8%
Taylor expanded in y around 0
lower--.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-log.f6471.2%
Applied rewrites71.2%
if 3.2e87 < y Initial program 99.8%
Taylor expanded in y around -inf
lower-*.f64N/A
lower-+.f64N/A
lower-log.f64N/A
lower-/.f6457.4%
Applied rewrites57.4%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6457.4%
lift-+.f64N/A
lift-log.f64N/A
lift-/.f64N/A
log-recN/A
lift-log.f64N/A
sub-flip-reverseN/A
lower--.f6457.4%
Applied rewrites57.4%
(FPCore (x y z) :precision binary64 (- x (+ z (* 0.5 (log y)))))
double code(double x, double y, double z) {
return x - (z + (0.5 * log(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)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = x - (z + (0.5d0 * log(y)))
end function
public static double code(double x, double y, double z) {
return x - (z + (0.5 * Math.log(y)));
}
def code(x, y, z): return x - (z + (0.5 * math.log(y)))
function code(x, y, z) return Float64(x - Float64(z + Float64(0.5 * log(y)))) end
function tmp = code(x, y, z) tmp = x - (z + (0.5 * log(y))); end
code[x_, y_, z_] := N[(x - N[(z + N[(0.5 * N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
x - \left(z + 0.5 \cdot \log y\right)
Initial program 99.8%
Taylor expanded in y around 0
lower--.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-log.f6471.2%
Applied rewrites71.2%
(FPCore (x y z) :precision binary64 (if (<= x -1420000.0) (* (- 1.0 (/ z x)) x) (if (<= x 4.4e+59) (- (* -0.5 (log y)) z) (- (+ (* 1.0 x) y) z))))
double code(double x, double y, double z) {
double tmp;
if (x <= -1420000.0) {
tmp = (1.0 - (z / x)) * x;
} else if (x <= 4.4e+59) {
tmp = (-0.5 * log(y)) - z;
} else {
tmp = ((1.0 * x) + 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)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (x <= (-1420000.0d0)) then
tmp = (1.0d0 - (z / x)) * x
else if (x <= 4.4d+59) then
tmp = ((-0.5d0) * log(y)) - z
else
tmp = ((1.0d0 * x) + y) - z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (x <= -1420000.0) {
tmp = (1.0 - (z / x)) * x;
} else if (x <= 4.4e+59) {
tmp = (-0.5 * Math.log(y)) - z;
} else {
tmp = ((1.0 * x) + y) - z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= -1420000.0: tmp = (1.0 - (z / x)) * x elif x <= 4.4e+59: tmp = (-0.5 * math.log(y)) - z else: tmp = ((1.0 * x) + y) - z return tmp
function code(x, y, z) tmp = 0.0 if (x <= -1420000.0) tmp = Float64(Float64(1.0 - Float64(z / x)) * x); elseif (x <= 4.4e+59) tmp = Float64(Float64(-0.5 * log(y)) - z); else tmp = Float64(Float64(Float64(1.0 * x) + y) - z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= -1420000.0) tmp = (1.0 - (z / x)) * x; elseif (x <= 4.4e+59) tmp = (-0.5 * log(y)) - z; else tmp = ((1.0 * x) + y) - z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -1420000.0], N[(N[(1.0 - N[(z / x), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision], If[LessEqual[x, 4.4e+59], N[(N[(-0.5 * N[Log[y], $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision], N[(N[(N[(1.0 * x), $MachinePrecision] + y), $MachinePrecision] - z), $MachinePrecision]]]
\begin{array}{l}
\mathbf{if}\;x \leq -1420000:\\
\;\;\;\;\left(1 - \frac{z}{x}\right) \cdot x\\
\mathbf{elif}\;x \leq 4.4 \cdot 10^{+59}:\\
\;\;\;\;-0.5 \cdot \log y - z\\
\mathbf{else}:\\
\;\;\;\;\left(1 \cdot x + y\right) - z\\
\end{array}
if x < -1.42e6Initial program 99.8%
lift--.f64N/A
sub-flipN/A
lift-+.f64N/A
lift--.f64N/A
associate-+l-N/A
associate-+l-N/A
sub-to-multN/A
lower-unsound-*.f64N/A
Applied rewrites80.7%
Taylor expanded in z around inf
lower-/.f6448.7%
Applied rewrites48.7%
if -1.42e6 < x < 4.3999999999999999e59Initial program 99.8%
lift--.f64N/A
sub-negate-revN/A
lift-+.f64N/A
add-flipN/A
lift--.f64N/A
lift-*.f64N/A
fp-cancel-sub-sign-invN/A
associate--l+N/A
associate--r+N/A
sub-negateN/A
lower--.f64N/A
Applied rewrites99.8%
Taylor expanded in y around 0
lower-*.f64N/A
lower-log.f6471.2%
Applied rewrites71.2%
Taylor expanded in x around 0
Applied rewrites42.2%
if 4.3999999999999999e59 < x Initial program 99.8%
lift--.f64N/A
sub-to-multN/A
lower-unsound-*.f64N/A
lower-unsound--.f64N/A
lower-unsound-/.f6488.2%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6488.2%
lift-+.f64N/A
add-flipN/A
lower--.f64N/A
metadata-eval88.2%
Applied rewrites88.2%
Taylor expanded in x around inf
Applied rewrites57.4%
(FPCore (x y z) :precision binary64 (- (+ (* 1.0 x) y) z))
double code(double x, double y, double z) {
return ((1.0 * x) + y) - 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)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = ((1.0d0 * x) + y) - z
end function
public static double code(double x, double y, double z) {
return ((1.0 * x) + y) - z;
}
def code(x, y, z): return ((1.0 * x) + y) - z
function code(x, y, z) return Float64(Float64(Float64(1.0 * x) + y) - z) end
function tmp = code(x, y, z) tmp = ((1.0 * x) + y) - z; end
code[x_, y_, z_] := N[(N[(N[(1.0 * x), $MachinePrecision] + y), $MachinePrecision] - z), $MachinePrecision]
\left(1 \cdot x + y\right) - z
Initial program 99.8%
lift--.f64N/A
sub-to-multN/A
lower-unsound-*.f64N/A
lower-unsound--.f64N/A
lower-unsound-/.f6488.2%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6488.2%
lift-+.f64N/A
add-flipN/A
lower--.f64N/A
metadata-eval88.2%
Applied rewrites88.2%
Taylor expanded in x around inf
Applied rewrites57.4%
(FPCore (x y z) :precision binary64 (if (<= x -1420000.0) (* 1.0 x) (if (<= x 4.4e+59) (- z) (* 1.0 x))))
double code(double x, double y, double z) {
double tmp;
if (x <= -1420000.0) {
tmp = 1.0 * x;
} else if (x <= 4.4e+59) {
tmp = -z;
} else {
tmp = 1.0 * 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)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (x <= (-1420000.0d0)) then
tmp = 1.0d0 * x
else if (x <= 4.4d+59) then
tmp = -z
else
tmp = 1.0d0 * x
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (x <= -1420000.0) {
tmp = 1.0 * x;
} else if (x <= 4.4e+59) {
tmp = -z;
} else {
tmp = 1.0 * x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= -1420000.0: tmp = 1.0 * x elif x <= 4.4e+59: tmp = -z else: tmp = 1.0 * x return tmp
function code(x, y, z) tmp = 0.0 if (x <= -1420000.0) tmp = Float64(1.0 * x); elseif (x <= 4.4e+59) tmp = Float64(-z); else tmp = Float64(1.0 * x); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= -1420000.0) tmp = 1.0 * x; elseif (x <= 4.4e+59) tmp = -z; else tmp = 1.0 * x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -1420000.0], N[(1.0 * x), $MachinePrecision], If[LessEqual[x, 4.4e+59], (-z), N[(1.0 * x), $MachinePrecision]]]
\begin{array}{l}
\mathbf{if}\;x \leq -1420000:\\
\;\;\;\;1 \cdot x\\
\mathbf{elif}\;x \leq 4.4 \cdot 10^{+59}:\\
\;\;\;\;-z\\
\mathbf{else}:\\
\;\;\;\;1 \cdot x\\
\end{array}
if x < -1.42e6 or 4.3999999999999999e59 < x Initial program 99.8%
lift--.f64N/A
sub-flipN/A
lift-+.f64N/A
lift--.f64N/A
associate-+l-N/A
associate-+l-N/A
sub-to-multN/A
lower-unsound-*.f64N/A
Applied rewrites80.7%
Taylor expanded in x around inf
Applied rewrites30.7%
if -1.42e6 < x < 4.3999999999999999e59Initial program 99.8%
Taylor expanded in z around inf
lower-*.f6429.3%
Applied rewrites29.3%
lift-*.f64N/A
mul-1-negN/A
lift-neg.f6429.3%
Applied rewrites29.3%
(FPCore (x y z) :precision binary64 (- z))
double code(double x, double y, double z) {
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)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = -z
end function
public static double code(double x, double y, double z) {
return -z;
}
def code(x, y, z): return -z
function code(x, y, z) return Float64(-z) end
function tmp = code(x, y, z) tmp = -z; end
code[x_, y_, z_] := (-z)
-z
Initial program 99.8%
Taylor expanded in z around inf
lower-*.f6429.3%
Applied rewrites29.3%
lift-*.f64N/A
mul-1-negN/A
lift-neg.f6429.3%
Applied rewrites29.3%
herbie shell --seed 2025258
(FPCore (x y z)
:name "Numeric.SpecFunctions:stirlingError from math-functions-0.1.5.2"
:precision binary64
(- (+ (- x (* (+ y 0.5) (log y))) y) z))