
(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 7 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 (- x 1.0) y 1.0))
double code(double x, double y) {
return fma((x - 1.0), y, 1.0);
}
function code(x, y) return fma(Float64(x - 1.0), y, 1.0) end
code[x_, y_] := N[(N[(x - 1.0), $MachinePrecision] * y + 1.0), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(x - 1, y, 1\right)
\end{array}
Initial program 77.5%
Taylor expanded in y around 0
mul-1-negN/A
rgt-mult-inverseN/A
distribute-rgt-neg-outN/A
mul-1-negN/A
distribute-lft-inN/A
mul-1-negN/A
sub-flip-reverseN/A
sub-negate-revN/A
associate--r+N/A
distribute-rgt-neg-inN/A
mul-1-negN/A
mul-1-negN/A
distribute-rgt-neg-inN/A
sub-negate-revN/A
+-commutativeN/A
associate--l+N/A
sub-negate-revN/A
mul-1-negN/A
Applied rewrites100.0%
(FPCore (x y)
:precision binary64
(let* ((t_0 (+ x (* (- 1.0 x) (- 1.0 y)))))
(if (<= t_0 0.0)
(- (* y x) y)
(if (<= t_0 2.0) (- 1.0 y) (* (- x 1.0) y)))))
double code(double x, double y) {
double t_0 = x + ((1.0 - x) * (1.0 - y));
double tmp;
if (t_0 <= 0.0) {
tmp = (y * x) - y;
} else if (t_0 <= 2.0) {
tmp = 1.0 - y;
} else {
tmp = (x - 1.0) * y;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y)
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 - x) * (1.0d0 - y))
if (t_0 <= 0.0d0) then
tmp = (y * x) - y
else if (t_0 <= 2.0d0) then
tmp = 1.0d0 - y
else
tmp = (x - 1.0d0) * y
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = x + ((1.0 - x) * (1.0 - y));
double tmp;
if (t_0 <= 0.0) {
tmp = (y * x) - y;
} else if (t_0 <= 2.0) {
tmp = 1.0 - y;
} else {
tmp = (x - 1.0) * y;
}
return tmp;
}
def code(x, y): t_0 = x + ((1.0 - x) * (1.0 - y)) tmp = 0 if t_0 <= 0.0: tmp = (y * x) - y elif t_0 <= 2.0: tmp = 1.0 - y else: tmp = (x - 1.0) * y return tmp
function code(x, y) t_0 = Float64(x + Float64(Float64(1.0 - x) * Float64(1.0 - y))) tmp = 0.0 if (t_0 <= 0.0) tmp = Float64(Float64(y * x) - y); elseif (t_0 <= 2.0) tmp = Float64(1.0 - y); else tmp = Float64(Float64(x - 1.0) * y); end return tmp end
function tmp_2 = code(x, y) t_0 = x + ((1.0 - x) * (1.0 - y)); tmp = 0.0; if (t_0 <= 0.0) tmp = (y * x) - y; elseif (t_0 <= 2.0) tmp = 1.0 - y; else tmp = (x - 1.0) * y; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(x + N[(N[(1.0 - x), $MachinePrecision] * N[(1.0 - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, 0.0], N[(N[(y * x), $MachinePrecision] - y), $MachinePrecision], If[LessEqual[t$95$0, 2.0], N[(1.0 - y), $MachinePrecision], N[(N[(x - 1.0), $MachinePrecision] * y), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x + \left(1 - x\right) \cdot \left(1 - y\right)\\
\mathbf{if}\;t\_0 \leq 0:\\
\;\;\;\;y \cdot x - y\\
\mathbf{elif}\;t\_0 \leq 2:\\
\;\;\;\;1 - y\\
\mathbf{else}:\\
\;\;\;\;\left(x - 1\right) \cdot y\\
\end{array}
\end{array}
if (+.f64 x (*.f64 (-.f64 #s(literal 1 binary64) x) (-.f64 #s(literal 1 binary64) y))) < 0.0Initial program 77.5%
Taylor expanded in y around inf
mul-1-negN/A
*-commutativeN/A
distribute-lft-neg-outN/A
mul-1-negN/A
lower-*.f64N/A
mul-1-negN/A
sub-negate-revN/A
lower--.f6463.5
Applied rewrites63.5%
lift-*.f64N/A
lift--.f64N/A
*-commutativeN/A
sub-negate-revN/A
mul-1-negN/A
mul-1-negN/A
sub-negate-revN/A
sub-flipN/A
metadata-evalN/A
distribute-rgt-outN/A
mul-1-negN/A
sub-flip-reverseN/A
lower--.f64N/A
*-commutativeN/A
lift-*.f6463.5
Applied rewrites63.5%
if 0.0 < (+.f64 x (*.f64 (-.f64 #s(literal 1 binary64) x) (-.f64 #s(literal 1 binary64) y))) < 2Initial program 77.5%
Taylor expanded in x around 0
lift--.f6462.1
Applied rewrites62.1%
if 2 < (+.f64 x (*.f64 (-.f64 #s(literal 1 binary64) x) (-.f64 #s(literal 1 binary64) y))) Initial program 77.5%
Taylor expanded in y around inf
mul-1-negN/A
*-commutativeN/A
distribute-lft-neg-outN/A
mul-1-negN/A
lower-*.f64N/A
mul-1-negN/A
sub-negate-revN/A
lower--.f6463.5
Applied rewrites63.5%
(FPCore (x y) :precision binary64 (let* ((t_0 (+ x (* (- 1.0 x) (- 1.0 y)))) (t_1 (* (- x 1.0) y))) (if (<= t_0 0.0) t_1 (if (<= t_0 2.0) (- 1.0 y) t_1))))
double code(double x, double y) {
double t_0 = x + ((1.0 - x) * (1.0 - y));
double t_1 = (x - 1.0) * y;
double tmp;
if (t_0 <= 0.0) {
tmp = t_1;
} else if (t_0 <= 2.0) {
tmp = 1.0 - y;
} else {
tmp = t_1;
}
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) :: t_1
real(8) :: tmp
t_0 = x + ((1.0d0 - x) * (1.0d0 - y))
t_1 = (x - 1.0d0) * y
if (t_0 <= 0.0d0) then
tmp = t_1
else if (t_0 <= 2.0d0) then
tmp = 1.0d0 - y
else
tmp = t_1
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = x + ((1.0 - x) * (1.0 - y));
double t_1 = (x - 1.0) * y;
double tmp;
if (t_0 <= 0.0) {
tmp = t_1;
} else if (t_0 <= 2.0) {
tmp = 1.0 - y;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y): t_0 = x + ((1.0 - x) * (1.0 - y)) t_1 = (x - 1.0) * y tmp = 0 if t_0 <= 0.0: tmp = t_1 elif t_0 <= 2.0: tmp = 1.0 - y else: tmp = t_1 return tmp
function code(x, y) t_0 = Float64(x + Float64(Float64(1.0 - x) * Float64(1.0 - y))) t_1 = Float64(Float64(x - 1.0) * y) tmp = 0.0 if (t_0 <= 0.0) tmp = t_1; elseif (t_0 <= 2.0) tmp = Float64(1.0 - y); else tmp = t_1; end return tmp end
function tmp_2 = code(x, y) t_0 = x + ((1.0 - x) * (1.0 - y)); t_1 = (x - 1.0) * y; tmp = 0.0; if (t_0 <= 0.0) tmp = t_1; elseif (t_0 <= 2.0) tmp = 1.0 - y; else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(x + N[(N[(1.0 - x), $MachinePrecision] * N[(1.0 - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(x - 1.0), $MachinePrecision] * y), $MachinePrecision]}, If[LessEqual[t$95$0, 0.0], t$95$1, If[LessEqual[t$95$0, 2.0], N[(1.0 - y), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x + \left(1 - x\right) \cdot \left(1 - y\right)\\
t_1 := \left(x - 1\right) \cdot y\\
\mathbf{if}\;t\_0 \leq 0:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_0 \leq 2:\\
\;\;\;\;1 - y\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (+.f64 x (*.f64 (-.f64 #s(literal 1 binary64) x) (-.f64 #s(literal 1 binary64) y))) < 0.0 or 2 < (+.f64 x (*.f64 (-.f64 #s(literal 1 binary64) x) (-.f64 #s(literal 1 binary64) y))) Initial program 77.5%
Taylor expanded in y around inf
mul-1-negN/A
*-commutativeN/A
distribute-lft-neg-outN/A
mul-1-negN/A
lower-*.f64N/A
mul-1-negN/A
sub-negate-revN/A
lower--.f6463.5
Applied rewrites63.5%
if 0.0 < (+.f64 x (*.f64 (-.f64 #s(literal 1 binary64) x) (-.f64 #s(literal 1 binary64) y))) < 2Initial program 77.5%
Taylor expanded in x around 0
lift--.f6462.1
Applied rewrites62.1%
(FPCore (x y) :precision binary64 (if (<= x -1.52e+29) (* y x) (if (<= x 1150000000.0) (- 1.0 y) (* y x))))
double code(double x, double y) {
double tmp;
if (x <= -1.52e+29) {
tmp = y * x;
} else if (x <= 1150000000.0) {
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 <= (-1.52d+29)) then
tmp = y * x
else if (x <= 1150000000.0d0) 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 <= -1.52e+29) {
tmp = y * x;
} else if (x <= 1150000000.0) {
tmp = 1.0 - y;
} else {
tmp = y * x;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -1.52e+29: tmp = y * x elif x <= 1150000000.0: tmp = 1.0 - y else: tmp = y * x return tmp
function code(x, y) tmp = 0.0 if (x <= -1.52e+29) tmp = Float64(y * x); elseif (x <= 1150000000.0) 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 <= -1.52e+29) tmp = y * x; elseif (x <= 1150000000.0) tmp = 1.0 - y; else tmp = y * x; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -1.52e+29], N[(y * x), $MachinePrecision], If[LessEqual[x, 1150000000.0], N[(1.0 - y), $MachinePrecision], N[(y * x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.52 \cdot 10^{+29}:\\
\;\;\;\;y \cdot x\\
\mathbf{elif}\;x \leq 1150000000:\\
\;\;\;\;1 - y\\
\mathbf{else}:\\
\;\;\;\;y \cdot x\\
\end{array}
\end{array}
if x < -1.52e29 or 1.15e9 < x Initial program 77.5%
Taylor expanded in x around -inf
*-commutativeN/A
lower-*.f6439.3
Applied rewrites39.3%
if -1.52e29 < x < 1.15e9Initial program 77.5%
Taylor expanded in x around 0
lift--.f6462.1
Applied rewrites62.1%
(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.5%
Taylor expanded in x around 0
lift--.f6462.1
Applied rewrites62.1%
(FPCore (x y) :precision binary64 (let* ((t_0 (+ x (* (- 1.0 x) (- 1.0 y))))) (if (<= t_0 -2e+54) (- y) (if (<= t_0 1e+20) 1.0 (- y)))))
double code(double x, double y) {
double t_0 = x + ((1.0 - x) * (1.0 - y));
double tmp;
if (t_0 <= -2e+54) {
tmp = -y;
} else if (t_0 <= 1e+20) {
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) :: t_0
real(8) :: tmp
t_0 = x + ((1.0d0 - x) * (1.0d0 - y))
if (t_0 <= (-2d+54)) then
tmp = -y
else if (t_0 <= 1d+20) then
tmp = 1.0d0
else
tmp = -y
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = x + ((1.0 - x) * (1.0 - y));
double tmp;
if (t_0 <= -2e+54) {
tmp = -y;
} else if (t_0 <= 1e+20) {
tmp = 1.0;
} else {
tmp = -y;
}
return tmp;
}
def code(x, y): t_0 = x + ((1.0 - x) * (1.0 - y)) tmp = 0 if t_0 <= -2e+54: tmp = -y elif t_0 <= 1e+20: tmp = 1.0 else: tmp = -y return tmp
function code(x, y) t_0 = Float64(x + Float64(Float64(1.0 - x) * Float64(1.0 - y))) tmp = 0.0 if (t_0 <= -2e+54) tmp = Float64(-y); elseif (t_0 <= 1e+20) tmp = 1.0; else tmp = Float64(-y); end return tmp end
function tmp_2 = code(x, y) t_0 = x + ((1.0 - x) * (1.0 - y)); tmp = 0.0; if (t_0 <= -2e+54) tmp = -y; elseif (t_0 <= 1e+20) tmp = 1.0; else tmp = -y; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(x + N[(N[(1.0 - x), $MachinePrecision] * N[(1.0 - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -2e+54], (-y), If[LessEqual[t$95$0, 1e+20], 1.0, (-y)]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x + \left(1 - x\right) \cdot \left(1 - y\right)\\
\mathbf{if}\;t\_0 \leq -2 \cdot 10^{+54}:\\
\;\;\;\;-y\\
\mathbf{elif}\;t\_0 \leq 10^{+20}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;-y\\
\end{array}
\end{array}
if (+.f64 x (*.f64 (-.f64 #s(literal 1 binary64) x) (-.f64 #s(literal 1 binary64) y))) < -2.0000000000000002e54 or 1e20 < (+.f64 x (*.f64 (-.f64 #s(literal 1 binary64) x) (-.f64 #s(literal 1 binary64) y))) Initial program 77.5%
Taylor expanded in y around inf
mul-1-negN/A
*-commutativeN/A
distribute-lft-neg-outN/A
mul-1-negN/A
lower-*.f64N/A
mul-1-negN/A
sub-negate-revN/A
lower--.f6463.5
Applied rewrites63.5%
Taylor expanded in x around 0
mul-1-negN/A
lower-neg.f6426.4
Applied rewrites26.4%
if -2.0000000000000002e54 < (+.f64 x (*.f64 (-.f64 #s(literal 1 binary64) x) (-.f64 #s(literal 1 binary64) y))) < 1e20Initial program 77.5%
Taylor expanded in y around 0
mul-1-negN/A
rgt-mult-inverseN/A
distribute-rgt-neg-outN/A
mul-1-negN/A
distribute-lft-inN/A
mul-1-negN/A
sub-flip-reverseN/A
sub-negate-revN/A
associate--r+N/A
distribute-rgt-neg-inN/A
mul-1-negN/A
mul-1-negN/A
distribute-rgt-neg-inN/A
sub-negate-revN/A
+-commutativeN/A
associate--l+N/A
sub-negate-revN/A
mul-1-negN/A
Applied rewrites100.0%
Taylor expanded in y around 0
Applied rewrites37.7%
(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.5%
Taylor expanded in y around 0
mul-1-negN/A
rgt-mult-inverseN/A
distribute-rgt-neg-outN/A
mul-1-negN/A
distribute-lft-inN/A
mul-1-negN/A
sub-flip-reverseN/A
sub-negate-revN/A
associate--r+N/A
distribute-rgt-neg-inN/A
mul-1-negN/A
mul-1-negN/A
distribute-rgt-neg-inN/A
sub-negate-revN/A
+-commutativeN/A
associate--l+N/A
sub-negate-revN/A
mul-1-negN/A
Applied rewrites100.0%
Taylor expanded in y around 0
Applied rewrites37.7%
herbie shell --seed 2025136
(FPCore (x y)
:name "Graphics.Rendering.Chart.Plot.Vectors:renderPlotVectors from Chart-1.5.3"
:precision binary64
(+ x (* (- 1.0 x) (- 1.0 y))))