
(FPCore (x y) :precision binary64 (+ x (* (- 1.0 x) (- 1.0 y))))
double code(double x, double y) {
return x + ((1.0 - x) * (1.0 - 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)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
code = x + ((1.0d0 - x) * (1.0d0 - y))
end function
public static double code(double x, double y) {
return x + ((1.0 - x) * (1.0 - y));
}
def code(x, y): return x + ((1.0 - x) * (1.0 - y))
function code(x, y) return Float64(x + Float64(Float64(1.0 - x) * Float64(1.0 - y))) end
function tmp = code(x, y) tmp = x + ((1.0 - x) * (1.0 - y)); end
code[x_, y_] := N[(x + N[(N[(1.0 - x), $MachinePrecision] * N[(1.0 - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \left(1 - x\right) \cdot \left(1 - y\right)
\end{array}
Herbie found 8 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y) :precision binary64 (+ x (* (- 1.0 x) (- 1.0 y))))
double code(double x, double y) {
return x + ((1.0 - x) * (1.0 - 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)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
code = x + ((1.0d0 - x) * (1.0d0 - y))
end function
public static double code(double x, double y) {
return x + ((1.0 - x) * (1.0 - y));
}
def code(x, y): return x + ((1.0 - x) * (1.0 - y))
function code(x, y) return Float64(x + Float64(Float64(1.0 - x) * Float64(1.0 - y))) end
function tmp = code(x, y) tmp = x + ((1.0 - x) * (1.0 - y)); end
code[x_, y_] := N[(x + N[(N[(1.0 - x), $MachinePrecision] * N[(1.0 - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \left(1 - x\right) \cdot \left(1 - y\right)
\end{array}
(FPCore (x y) :precision binary64 (fma y x (- 1.0 y)))
double code(double x, double y) {
return fma(y, x, (1.0 - y));
}
function code(x, y) return fma(y, x, Float64(1.0 - y)) end
code[x_, y_] := N[(y * x + N[(1.0 - y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(y, x, 1 - y\right)
\end{array}
Initial program 77.4%
Taylor expanded in y around 0
associate-*r*N/A
mul-1-negN/A
fp-cancel-sub-signN/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift--.f64100.0
Applied rewrites100.0%
lift--.f64N/A
lift--.f64N/A
lower-*.f64N/A
*-lft-identityN/A
associate-*r*N/A
distribute-lft-out--N/A
metadata-evalN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
+-commutativeN/A
distribute-lft1-inN/A
associate-*r*N/A
associate--l-N/A
associate-*r*N/A
mul-1-negN/A
fp-cancel-sign-sub-invN/A
+-commutativeN/A
associate--l+N/A
*-commutativeN/A
lower-fma.f64N/A
lift--.f64100.0
Applied rewrites100.0%
(FPCore (x y) :precision binary64 (if (<= y -210000000000.0) (* (- x 1.0) y) (if (<= y 8.5e-7) (- 1.0 (* (- x) y)) (- (* y x) y))))
double code(double x, double y) {
double tmp;
if (y <= -210000000000.0) {
tmp = (x - 1.0) * y;
} else if (y <= 8.5e-7) {
tmp = 1.0 - (-x * y);
} else {
tmp = (y * x) - 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)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= (-210000000000.0d0)) then
tmp = (x - 1.0d0) * y
else if (y <= 8.5d-7) then
tmp = 1.0d0 - (-x * y)
else
tmp = (y * x) - y
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= -210000000000.0) {
tmp = (x - 1.0) * y;
} else if (y <= 8.5e-7) {
tmp = 1.0 - (-x * y);
} else {
tmp = (y * x) - y;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -210000000000.0: tmp = (x - 1.0) * y elif y <= 8.5e-7: tmp = 1.0 - (-x * y) else: tmp = (y * x) - y return tmp
function code(x, y) tmp = 0.0 if (y <= -210000000000.0) tmp = Float64(Float64(x - 1.0) * y); elseif (y <= 8.5e-7) tmp = Float64(1.0 - Float64(Float64(-x) * y)); else tmp = Float64(Float64(y * x) - y); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= -210000000000.0) tmp = (x - 1.0) * y; elseif (y <= 8.5e-7) tmp = 1.0 - (-x * y); else tmp = (y * x) - y; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -210000000000.0], N[(N[(x - 1.0), $MachinePrecision] * y), $MachinePrecision], If[LessEqual[y, 8.5e-7], N[(1.0 - N[((-x) * y), $MachinePrecision]), $MachinePrecision], N[(N[(y * x), $MachinePrecision] - y), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -210000000000:\\
\;\;\;\;\left(x - 1\right) \cdot y\\
\mathbf{elif}\;y \leq 8.5 \cdot 10^{-7}:\\
\;\;\;\;1 - \left(-x\right) \cdot y\\
\mathbf{else}:\\
\;\;\;\;y \cdot x - y\\
\end{array}
\end{array}
if y < -2.1e11Initial program 100.0%
Taylor expanded in y around 0
associate-*r*N/A
mul-1-negN/A
fp-cancel-sub-signN/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift--.f64100.0
Applied rewrites100.0%
Taylor expanded in x around inf
mul-1-negN/A
lower-neg.f6452.2
Applied rewrites52.2%
Taylor expanded in y around inf
*-lft-identityN/A
associate-*r*N/A
distribute-lft-out--N/A
metadata-evalN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
+-commutativeN/A
distribute-rgt1-inN/A
mul-1-negN/A
fp-cancel-sub-signN/A
associate-+l-N/A
*-commutativeN/A
+-commutativeN/A
*-commutativeN/A
lower-*.f64N/A
lower--.f6499.9
Applied rewrites99.9%
if -2.1e11 < y < 8.50000000000000014e-7Initial program 55.2%
Taylor expanded in y around 0
associate-*r*N/A
mul-1-negN/A
fp-cancel-sub-signN/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift--.f64100.0
Applied rewrites100.0%
Taylor expanded in x around inf
mul-1-negN/A
lower-neg.f6498.5
Applied rewrites98.5%
if 8.50000000000000014e-7 < y Initial program 99.9%
Taylor expanded in y around 0
associate-*r*N/A
mul-1-negN/A
fp-cancel-sub-signN/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift--.f64100.0
Applied rewrites100.0%
Taylor expanded in x around inf
mul-1-negN/A
lower-neg.f6448.8
Applied rewrites48.8%
Taylor expanded in y around inf
*-lft-identityN/A
associate-*r*N/A
distribute-lft-out--N/A
metadata-evalN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
+-commutativeN/A
distribute-rgt1-inN/A
mul-1-negN/A
fp-cancel-sub-signN/A
associate-+l-N/A
*-commutativeN/A
+-commutativeN/A
*-commutativeN/A
lower-*.f64N/A
lower--.f6498.1
Applied rewrites98.1%
lift-*.f64N/A
lift--.f64N/A
*-commutativeN/A
metadata-evalN/A
fp-cancel-sub-sign-invN/A
metadata-evalN/A
metadata-evalN/A
distribute-rgt-outN/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lower--.f64N/A
*-commutativeN/A
lower-*.f6498.1
Applied rewrites98.1%
(FPCore (x y) :precision binary64 (if (<= y -2.5e-53) (* (- x 1.0) y) (if (<= y 6.3e-65) (- 1.0 y) (- (* y x) y))))
double code(double x, double y) {
double tmp;
if (y <= -2.5e-53) {
tmp = (x - 1.0) * y;
} else if (y <= 6.3e-65) {
tmp = 1.0 - y;
} else {
tmp = (y * x) - 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)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= (-2.5d-53)) then
tmp = (x - 1.0d0) * y
else if (y <= 6.3d-65) then
tmp = 1.0d0 - y
else
tmp = (y * x) - y
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= -2.5e-53) {
tmp = (x - 1.0) * y;
} else if (y <= 6.3e-65) {
tmp = 1.0 - y;
} else {
tmp = (y * x) - y;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -2.5e-53: tmp = (x - 1.0) * y elif y <= 6.3e-65: tmp = 1.0 - y else: tmp = (y * x) - y return tmp
function code(x, y) tmp = 0.0 if (y <= -2.5e-53) tmp = Float64(Float64(x - 1.0) * y); elseif (y <= 6.3e-65) tmp = Float64(1.0 - y); else tmp = Float64(Float64(y * x) - y); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= -2.5e-53) tmp = (x - 1.0) * y; elseif (y <= 6.3e-65) tmp = 1.0 - y; else tmp = (y * x) - y; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -2.5e-53], N[(N[(x - 1.0), $MachinePrecision] * y), $MachinePrecision], If[LessEqual[y, 6.3e-65], N[(1.0 - y), $MachinePrecision], N[(N[(y * x), $MachinePrecision] - y), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.5 \cdot 10^{-53}:\\
\;\;\;\;\left(x - 1\right) \cdot y\\
\mathbf{elif}\;y \leq 6.3 \cdot 10^{-65}:\\
\;\;\;\;1 - y\\
\mathbf{else}:\\
\;\;\;\;y \cdot x - y\\
\end{array}
\end{array}
if y < -2.5e-53Initial program 94.4%
Taylor expanded in y around 0
associate-*r*N/A
mul-1-negN/A
fp-cancel-sub-signN/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift--.f64100.0
Applied rewrites100.0%
Taylor expanded in x around inf
mul-1-negN/A
lower-neg.f6458.2
Applied rewrites58.2%
Taylor expanded in y around inf
*-lft-identityN/A
associate-*r*N/A
distribute-lft-out--N/A
metadata-evalN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
+-commutativeN/A
distribute-rgt1-inN/A
mul-1-negN/A
fp-cancel-sub-signN/A
associate-+l-N/A
*-commutativeN/A
+-commutativeN/A
*-commutativeN/A
lower-*.f64N/A
lower--.f6492.2
Applied rewrites92.2%
if -2.5e-53 < y < 6.2999999999999997e-65Initial program 53.6%
Taylor expanded in x around 0
lift--.f6480.6
Applied rewrites80.6%
if 6.2999999999999997e-65 < y Initial program 93.0%
Taylor expanded in y around 0
associate-*r*N/A
mul-1-negN/A
fp-cancel-sub-signN/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift--.f64100.0
Applied rewrites100.0%
Taylor expanded in x around inf
mul-1-negN/A
lower-neg.f6456.4
Applied rewrites56.4%
Taylor expanded in y around inf
*-lft-identityN/A
associate-*r*N/A
distribute-lft-out--N/A
metadata-evalN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
+-commutativeN/A
distribute-rgt1-inN/A
mul-1-negN/A
fp-cancel-sub-signN/A
associate-+l-N/A
*-commutativeN/A
+-commutativeN/A
*-commutativeN/A
lower-*.f64N/A
lower--.f6490.2
Applied rewrites90.2%
lift-*.f64N/A
lift--.f64N/A
*-commutativeN/A
metadata-evalN/A
fp-cancel-sub-sign-invN/A
metadata-evalN/A
metadata-evalN/A
distribute-rgt-outN/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lower--.f64N/A
*-commutativeN/A
lower-*.f6490.2
Applied rewrites90.2%
(FPCore (x y) :precision binary64 (let* ((t_0 (* (- x 1.0) y))) (if (<= y -2.5e-53) t_0 (if (<= y 6.3e-65) (- 1.0 y) t_0))))
double code(double x, double y) {
double t_0 = (x - 1.0) * y;
double tmp;
if (y <= -2.5e-53) {
tmp = t_0;
} else if (y <= 6.3e-65) {
tmp = 1.0 - y;
} 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)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: t_0
real(8) :: tmp
t_0 = (x - 1.0d0) * y
if (y <= (-2.5d-53)) then
tmp = t_0
else if (y <= 6.3d-65) then
tmp = 1.0d0 - y
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = (x - 1.0) * y;
double tmp;
if (y <= -2.5e-53) {
tmp = t_0;
} else if (y <= 6.3e-65) {
tmp = 1.0 - y;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y): t_0 = (x - 1.0) * y tmp = 0 if y <= -2.5e-53: tmp = t_0 elif y <= 6.3e-65: tmp = 1.0 - y else: tmp = t_0 return tmp
function code(x, y) t_0 = Float64(Float64(x - 1.0) * y) tmp = 0.0 if (y <= -2.5e-53) tmp = t_0; elseif (y <= 6.3e-65) tmp = Float64(1.0 - y); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y) t_0 = (x - 1.0) * y; tmp = 0.0; if (y <= -2.5e-53) tmp = t_0; elseif (y <= 6.3e-65) tmp = 1.0 - y; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(N[(x - 1.0), $MachinePrecision] * y), $MachinePrecision]}, If[LessEqual[y, -2.5e-53], t$95$0, If[LessEqual[y, 6.3e-65], N[(1.0 - y), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(x - 1\right) \cdot y\\
\mathbf{if}\;y \leq -2.5 \cdot 10^{-53}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 6.3 \cdot 10^{-65}:\\
\;\;\;\;1 - y\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if y < -2.5e-53 or 6.2999999999999997e-65 < y Initial program 93.7%
Taylor expanded in y around 0
associate-*r*N/A
mul-1-negN/A
fp-cancel-sub-signN/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift--.f64100.0
Applied rewrites100.0%
Taylor expanded in x around inf
mul-1-negN/A
lower-neg.f6457.3
Applied rewrites57.3%
Taylor expanded in y around inf
*-lft-identityN/A
associate-*r*N/A
distribute-lft-out--N/A
metadata-evalN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
+-commutativeN/A
distribute-rgt1-inN/A
mul-1-negN/A
fp-cancel-sub-signN/A
associate-+l-N/A
*-commutativeN/A
+-commutativeN/A
*-commutativeN/A
lower-*.f64N/A
lower--.f6491.2
Applied rewrites91.2%
if -2.5e-53 < y < 6.2999999999999997e-65Initial program 53.6%
Taylor expanded in x around 0
lift--.f6480.6
Applied rewrites80.6%
(FPCore (x y) :precision binary64 (if (<= x -21000000000.0) (* y x) (if (<= x 1.1e+72) (- 1.0 y) (* y x))))
double code(double x, double y) {
double tmp;
if (x <= -21000000000.0) {
tmp = y * x;
} else if (x <= 1.1e+72) {
tmp = 1.0 - y;
} else {
tmp = 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)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (x <= (-21000000000.0d0)) then
tmp = y * x
else if (x <= 1.1d+72) then
tmp = 1.0d0 - y
else
tmp = y * x
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= -21000000000.0) {
tmp = y * x;
} else if (x <= 1.1e+72) {
tmp = 1.0 - y;
} else {
tmp = y * x;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -21000000000.0: tmp = y * x elif x <= 1.1e+72: tmp = 1.0 - y else: tmp = y * x return tmp
function code(x, y) tmp = 0.0 if (x <= -21000000000.0) tmp = Float64(y * x); elseif (x <= 1.1e+72) tmp = Float64(1.0 - y); else tmp = Float64(y * x); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -21000000000.0) tmp = y * x; elseif (x <= 1.1e+72) tmp = 1.0 - y; else tmp = y * x; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -21000000000.0], N[(y * x), $MachinePrecision], If[LessEqual[x, 1.1e+72], N[(1.0 - y), $MachinePrecision], N[(y * x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -21000000000:\\
\;\;\;\;y \cdot x\\
\mathbf{elif}\;x \leq 1.1 \cdot 10^{+72}:\\
\;\;\;\;1 - y\\
\mathbf{else}:\\
\;\;\;\;y \cdot x\\
\end{array}
\end{array}
if x < -2.1e10 or 1.1e72 < x Initial program 53.1%
Taylor expanded in x around -inf
*-commutativeN/A
lower-*.f6476.8
Applied rewrites76.8%
if -2.1e10 < x < 1.1e72Initial program 96.1%
Taylor expanded in x around 0
lift--.f6492.7
Applied rewrites92.7%
(FPCore (x y) :precision binary64 (- 1.0 y))
double code(double x, double y) {
return 1.0 - 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)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
code = 1.0d0 - y
end function
public static double code(double x, double y) {
return 1.0 - y;
}
def code(x, y): return 1.0 - y
function code(x, y) return Float64(1.0 - y) end
function tmp = code(x, y) tmp = 1.0 - y; end
code[x_, y_] := N[(1.0 - y), $MachinePrecision]
\begin{array}{l}
\\
1 - y
\end{array}
Initial program 77.4%
Taylor expanded in x around 0
lift--.f6463.3
Applied rewrites63.3%
(FPCore (x y) :precision binary64 (if (<= (- 1.0 y) 0.9999995) (- y) (if (<= (- 1.0 y) 1e+57) 1.0 (- y))))
double code(double x, double y) {
double tmp;
if ((1.0 - y) <= 0.9999995) {
tmp = -y;
} else if ((1.0 - y) <= 1e+57) {
tmp = 1.0;
} 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)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if ((1.0d0 - y) <= 0.9999995d0) then
tmp = -y
else if ((1.0d0 - y) <= 1d+57) then
tmp = 1.0d0
else
tmp = -y
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((1.0 - y) <= 0.9999995) {
tmp = -y;
} else if ((1.0 - y) <= 1e+57) {
tmp = 1.0;
} else {
tmp = -y;
}
return tmp;
}
def code(x, y): tmp = 0 if (1.0 - y) <= 0.9999995: tmp = -y elif (1.0 - y) <= 1e+57: tmp = 1.0 else: tmp = -y return tmp
function code(x, y) tmp = 0.0 if (Float64(1.0 - y) <= 0.9999995) tmp = Float64(-y); elseif (Float64(1.0 - y) <= 1e+57) tmp = 1.0; else tmp = Float64(-y); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((1.0 - y) <= 0.9999995) tmp = -y; elseif ((1.0 - y) <= 1e+57) tmp = 1.0; else tmp = -y; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[N[(1.0 - y), $MachinePrecision], 0.9999995], (-y), If[LessEqual[N[(1.0 - y), $MachinePrecision], 1e+57], 1.0, (-y)]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;1 - y \leq 0.9999995:\\
\;\;\;\;-y\\
\mathbf{elif}\;1 - y \leq 10^{+57}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;-y\\
\end{array}
\end{array}
if (-.f64 #s(literal 1 binary64) y) < 0.999999500000000041 or 1.00000000000000005e57 < (-.f64 #s(literal 1 binary64) y) Initial program 99.9%
Taylor expanded in x around 0
lift--.f6451.4
Applied rewrites51.4%
Taylor expanded in y around inf
mul-1-negN/A
lift-neg.f6450.3
Applied rewrites50.3%
if 0.999999500000000041 < (-.f64 #s(literal 1 binary64) y) < 1.00000000000000005e57Initial program 58.5%
Taylor expanded in y around 0
Applied rewrites68.8%
(FPCore (x y) :precision binary64 1.0)
double code(double x, double y) {
return 1.0;
}
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)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
code = 1.0d0
end function
public static double code(double x, double y) {
return 1.0;
}
def code(x, y): return 1.0
function code(x, y) return 1.0 end
function tmp = code(x, y) tmp = 1.0; end
code[x_, y_] := 1.0
\begin{array}{l}
\\
1
\end{array}
Initial program 77.4%
Taylor expanded in y around 0
Applied rewrites38.6%
herbie shell --seed 2025112
(FPCore (x y)
:name "Graphics.Rendering.Chart.Plot.Vectors:renderPlotVectors from Chart-1.5.3"
:precision binary64
(+ x (* (- 1.0 x) (- 1.0 y))))