
(FPCore (x y) :precision binary64 (/ (* x (+ (/ x y) 1.0)) (+ x 1.0)))
double code(double x, double y) {
return (x * ((x / y) + 1.0)) / (x + 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 = (x * ((x / y) + 1.0d0)) / (x + 1.0d0)
end function
public static double code(double x, double y) {
return (x * ((x / y) + 1.0)) / (x + 1.0);
}
def code(x, y): return (x * ((x / y) + 1.0)) / (x + 1.0)
function code(x, y) return Float64(Float64(x * Float64(Float64(x / y) + 1.0)) / Float64(x + 1.0)) end
function tmp = code(x, y) tmp = (x * ((x / y) + 1.0)) / (x + 1.0); end
code[x_, y_] := N[(N[(x * N[(N[(x / y), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x \cdot \left(\frac{x}{y} + 1\right)}{x + 1}
\end{array}
Herbie found 11 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y) :precision binary64 (/ (* x (+ (/ x y) 1.0)) (+ x 1.0)))
double code(double x, double y) {
return (x * ((x / y) + 1.0)) / (x + 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 = (x * ((x / y) + 1.0d0)) / (x + 1.0d0)
end function
public static double code(double x, double y) {
return (x * ((x / y) + 1.0)) / (x + 1.0);
}
def code(x, y): return (x * ((x / y) + 1.0)) / (x + 1.0)
function code(x, y) return Float64(Float64(x * Float64(Float64(x / y) + 1.0)) / Float64(x + 1.0)) end
function tmp = code(x, y) tmp = (x * ((x / y) + 1.0)) / (x + 1.0); end
code[x_, y_] := N[(N[(x * N[(N[(x / y), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x \cdot \left(\frac{x}{y} + 1\right)}{x + 1}
\end{array}
(FPCore (x y)
:precision binary64
(let* ((t_0 (/ (* x (+ (/ x y) 1.0)) (+ x 1.0)))
(t_1 (* (/ x (- x -1.0)) (/ x y))))
(if (<= t_0 (- INFINITY))
t_1
(if (<= t_0 2.0) (/ (fma (/ x y) x x) (- x -1.0)) t_1))))
double code(double x, double y) {
double t_0 = (x * ((x / y) + 1.0)) / (x + 1.0);
double t_1 = (x / (x - -1.0)) * (x / y);
double tmp;
if (t_0 <= -((double) INFINITY)) {
tmp = t_1;
} else if (t_0 <= 2.0) {
tmp = fma((x / y), x, x) / (x - -1.0);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y) t_0 = Float64(Float64(x * Float64(Float64(x / y) + 1.0)) / Float64(x + 1.0)) t_1 = Float64(Float64(x / Float64(x - -1.0)) * Float64(x / y)) tmp = 0.0 if (t_0 <= Float64(-Inf)) tmp = t_1; elseif (t_0 <= 2.0) tmp = Float64(fma(Float64(x / y), x, x) / Float64(x - -1.0)); else tmp = t_1; end return tmp end
code[x_, y_] := Block[{t$95$0 = N[(N[(x * N[(N[(x / y), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(x / N[(x - -1.0), $MachinePrecision]), $MachinePrecision] * N[(x / y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, (-Infinity)], t$95$1, If[LessEqual[t$95$0, 2.0], N[(N[(N[(x / y), $MachinePrecision] * x + x), $MachinePrecision] / N[(x - -1.0), $MachinePrecision]), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x \cdot \left(\frac{x}{y} + 1\right)}{x + 1}\\
t_1 := \frac{x}{x - -1} \cdot \frac{x}{y}\\
\mathbf{if}\;t\_0 \leq -\infty:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_0 \leq 2:\\
\;\;\;\;\frac{\mathsf{fma}\left(\frac{x}{y}, x, x\right)}{x - -1}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (/.f64 (*.f64 x (+.f64 (/.f64 x y) #s(literal 1 binary64))) (+.f64 x #s(literal 1 binary64))) < -inf.0 or 2 < (/.f64 (*.f64 x (+.f64 (/.f64 x y) #s(literal 1 binary64))) (+.f64 x #s(literal 1 binary64))) Initial program 88.2%
Taylor expanded in y around 0
unpow2N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f64N/A
+-commutativeN/A
distribute-lft-inN/A
*-rgt-identityN/A
lower-fma.f6445.4
Applied rewrites45.4%
lift-*.f64N/A
lift-/.f64N/A
lift-fma.f64N/A
associate-*r/N/A
*-commutativeN/A
+-commutativeN/A
distribute-rgt1-inN/A
add-flipN/A
metadata-evalN/A
times-fracN/A
lower-*.f64N/A
lift-/.f64N/A
lift--.f64N/A
lift-/.f6451.3
Applied rewrites51.3%
if -inf.0 < (/.f64 (*.f64 x (+.f64 (/.f64 x y) #s(literal 1 binary64))) (+.f64 x #s(literal 1 binary64))) < 2Initial program 88.2%
lift-*.f64N/A
lift-+.f64N/A
lift-/.f64N/A
distribute-rgt-inN/A
*-lft-identityN/A
lower-fma.f64N/A
lift-/.f6488.2
lift-+.f64N/A
add-flipN/A
metadata-evalN/A
lower--.f6488.2
Applied rewrites88.2%
(FPCore (x y) :precision binary64 (* (- (/ x y) -1.0) (/ x (- x -1.0))))
double code(double x, double y) {
return ((x / y) - -1.0) * (x / (x - -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 = ((x / y) - (-1.0d0)) * (x / (x - (-1.0d0)))
end function
public static double code(double x, double y) {
return ((x / y) - -1.0) * (x / (x - -1.0));
}
def code(x, y): return ((x / y) - -1.0) * (x / (x - -1.0))
function code(x, y) return Float64(Float64(Float64(x / y) - -1.0) * Float64(x / Float64(x - -1.0))) end
function tmp = code(x, y) tmp = ((x / y) - -1.0) * (x / (x - -1.0)); end
code[x_, y_] := N[(N[(N[(x / y), $MachinePrecision] - -1.0), $MachinePrecision] * N[(x / N[(x - -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(\frac{x}{y} - -1\right) \cdot \frac{x}{x - -1}
\end{array}
Initial program 88.2%
lift-+.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-/.f64N/A
*-commutativeN/A
+-commutativeN/A
associate-/l*N/A
lower-*.f64N/A
add-flipN/A
metadata-evalN/A
lower--.f64N/A
lift-/.f64N/A
lower-/.f64N/A
+-commutativeN/A
add-flipN/A
metadata-evalN/A
lower--.f6499.9
Applied rewrites99.9%
(FPCore (x y)
:precision binary64
(let* ((t_0 (/ (* x (+ (/ x y) 1.0)) (+ x 1.0)))
(t_1 (/ x (- x -1.0)))
(t_2 (* t_1 (/ x y))))
(if (<= t_0 -50000.0)
t_2
(if (<= t_0 5e-11) (fma (- (/ x y) x) x x) (if (<= t_0 2.0) t_1 t_2)))))
double code(double x, double y) {
double t_0 = (x * ((x / y) + 1.0)) / (x + 1.0);
double t_1 = x / (x - -1.0);
double t_2 = t_1 * (x / y);
double tmp;
if (t_0 <= -50000.0) {
tmp = t_2;
} else if (t_0 <= 5e-11) {
tmp = fma(((x / y) - x), x, x);
} else if (t_0 <= 2.0) {
tmp = t_1;
} else {
tmp = t_2;
}
return tmp;
}
function code(x, y) t_0 = Float64(Float64(x * Float64(Float64(x / y) + 1.0)) / Float64(x + 1.0)) t_1 = Float64(x / Float64(x - -1.0)) t_2 = Float64(t_1 * Float64(x / y)) tmp = 0.0 if (t_0 <= -50000.0) tmp = t_2; elseif (t_0 <= 5e-11) tmp = fma(Float64(Float64(x / y) - x), x, x); elseif (t_0 <= 2.0) tmp = t_1; else tmp = t_2; end return tmp end
code[x_, y_] := Block[{t$95$0 = N[(N[(x * N[(N[(x / y), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(x / N[(x - -1.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(t$95$1 * N[(x / y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -50000.0], t$95$2, If[LessEqual[t$95$0, 5e-11], N[(N[(N[(x / y), $MachinePrecision] - x), $MachinePrecision] * x + x), $MachinePrecision], If[LessEqual[t$95$0, 2.0], t$95$1, t$95$2]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x \cdot \left(\frac{x}{y} + 1\right)}{x + 1}\\
t_1 := \frac{x}{x - -1}\\
t_2 := t\_1 \cdot \frac{x}{y}\\
\mathbf{if}\;t\_0 \leq -50000:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;t\_0 \leq 5 \cdot 10^{-11}:\\
\;\;\;\;\mathsf{fma}\left(\frac{x}{y} - x, x, x\right)\\
\mathbf{elif}\;t\_0 \leq 2:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
if (/.f64 (*.f64 x (+.f64 (/.f64 x y) #s(literal 1 binary64))) (+.f64 x #s(literal 1 binary64))) < -5e4 or 2 < (/.f64 (*.f64 x (+.f64 (/.f64 x y) #s(literal 1 binary64))) (+.f64 x #s(literal 1 binary64))) Initial program 88.2%
Taylor expanded in y around 0
unpow2N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f64N/A
+-commutativeN/A
distribute-lft-inN/A
*-rgt-identityN/A
lower-fma.f6445.4
Applied rewrites45.4%
lift-*.f64N/A
lift-/.f64N/A
lift-fma.f64N/A
associate-*r/N/A
*-commutativeN/A
+-commutativeN/A
distribute-rgt1-inN/A
add-flipN/A
metadata-evalN/A
times-fracN/A
lower-*.f64N/A
lift-/.f64N/A
lift--.f64N/A
lift-/.f6451.3
Applied rewrites51.3%
if -5e4 < (/.f64 (*.f64 x (+.f64 (/.f64 x y) #s(literal 1 binary64))) (+.f64 x #s(literal 1 binary64))) < 5.00000000000000018e-11Initial program 88.2%
Taylor expanded in x around 0
+-commutativeN/A
distribute-lft-inN/A
*-commutativeN/A
*-rgt-identityN/A
lower-fma.f64N/A
sub-flipN/A
metadata-evalN/A
distribute-rgt-inN/A
associate-*l/N/A
*-lft-identityN/A
mul-1-negN/A
lower-+.f64N/A
lift-/.f64N/A
lower-neg.f6456.4
Applied rewrites56.4%
lift-+.f64N/A
lift-/.f64N/A
lift-neg.f64N/A
sub-flip-reverseN/A
lower--.f64N/A
lift-/.f6456.4
Applied rewrites56.4%
if 5.00000000000000018e-11 < (/.f64 (*.f64 x (+.f64 (/.f64 x y) #s(literal 1 binary64))) (+.f64 x #s(literal 1 binary64))) < 2Initial program 88.2%
Taylor expanded in y around inf
lower-/.f64N/A
+-commutativeN/A
add-flipN/A
metadata-evalN/A
lower--.f6450.8
Applied rewrites50.8%
(FPCore (x y)
:precision binary64
(let* ((t_0 (/ (* x (+ (/ x y) 1.0)) (+ x 1.0))) (t_1 (* x (/ 1.0 y))))
(if (<= t_0 -50000.0)
t_1
(if (<= t_0 5e-11)
(fma (- (/ x y) x) x x)
(if (<= t_0 2.0)
(/ x (- x -1.0))
(if (<= t_0 2e+274) (* x (/ x (fma y x y))) t_1))))))
double code(double x, double y) {
double t_0 = (x * ((x / y) + 1.0)) / (x + 1.0);
double t_1 = x * (1.0 / y);
double tmp;
if (t_0 <= -50000.0) {
tmp = t_1;
} else if (t_0 <= 5e-11) {
tmp = fma(((x / y) - x), x, x);
} else if (t_0 <= 2.0) {
tmp = x / (x - -1.0);
} else if (t_0 <= 2e+274) {
tmp = x * (x / fma(y, x, y));
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y) t_0 = Float64(Float64(x * Float64(Float64(x / y) + 1.0)) / Float64(x + 1.0)) t_1 = Float64(x * Float64(1.0 / y)) tmp = 0.0 if (t_0 <= -50000.0) tmp = t_1; elseif (t_0 <= 5e-11) tmp = fma(Float64(Float64(x / y) - x), x, x); elseif (t_0 <= 2.0) tmp = Float64(x / Float64(x - -1.0)); elseif (t_0 <= 2e+274) tmp = Float64(x * Float64(x / fma(y, x, y))); else tmp = t_1; end return tmp end
code[x_, y_] := Block[{t$95$0 = N[(N[(x * N[(N[(x / y), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(x * N[(1.0 / y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -50000.0], t$95$1, If[LessEqual[t$95$0, 5e-11], N[(N[(N[(x / y), $MachinePrecision] - x), $MachinePrecision] * x + x), $MachinePrecision], If[LessEqual[t$95$0, 2.0], N[(x / N[(x - -1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 2e+274], N[(x * N[(x / N[(y * x + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x \cdot \left(\frac{x}{y} + 1\right)}{x + 1}\\
t_1 := x \cdot \frac{1}{y}\\
\mathbf{if}\;t\_0 \leq -50000:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_0 \leq 5 \cdot 10^{-11}:\\
\;\;\;\;\mathsf{fma}\left(\frac{x}{y} - x, x, x\right)\\
\mathbf{elif}\;t\_0 \leq 2:\\
\;\;\;\;\frac{x}{x - -1}\\
\mathbf{elif}\;t\_0 \leq 2 \cdot 10^{+274}:\\
\;\;\;\;x \cdot \frac{x}{\mathsf{fma}\left(y, x, y\right)}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (/.f64 (*.f64 x (+.f64 (/.f64 x y) #s(literal 1 binary64))) (+.f64 x #s(literal 1 binary64))) < -5e4 or 1.99999999999999984e274 < (/.f64 (*.f64 x (+.f64 (/.f64 x y) #s(literal 1 binary64))) (+.f64 x #s(literal 1 binary64))) Initial program 88.2%
Taylor expanded in y around 0
unpow2N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f64N/A
+-commutativeN/A
distribute-lft-inN/A
*-rgt-identityN/A
lower-fma.f6445.4
Applied rewrites45.4%
Taylor expanded in x around inf
lower-/.f6439.1
Applied rewrites39.1%
if -5e4 < (/.f64 (*.f64 x (+.f64 (/.f64 x y) #s(literal 1 binary64))) (+.f64 x #s(literal 1 binary64))) < 5.00000000000000018e-11Initial program 88.2%
Taylor expanded in x around 0
+-commutativeN/A
distribute-lft-inN/A
*-commutativeN/A
*-rgt-identityN/A
lower-fma.f64N/A
sub-flipN/A
metadata-evalN/A
distribute-rgt-inN/A
associate-*l/N/A
*-lft-identityN/A
mul-1-negN/A
lower-+.f64N/A
lift-/.f64N/A
lower-neg.f6456.4
Applied rewrites56.4%
lift-+.f64N/A
lift-/.f64N/A
lift-neg.f64N/A
sub-flip-reverseN/A
lower--.f64N/A
lift-/.f6456.4
Applied rewrites56.4%
if 5.00000000000000018e-11 < (/.f64 (*.f64 x (+.f64 (/.f64 x y) #s(literal 1 binary64))) (+.f64 x #s(literal 1 binary64))) < 2Initial program 88.2%
Taylor expanded in y around inf
lower-/.f64N/A
+-commutativeN/A
add-flipN/A
metadata-evalN/A
lower--.f6450.8
Applied rewrites50.8%
if 2 < (/.f64 (*.f64 x (+.f64 (/.f64 x y) #s(literal 1 binary64))) (+.f64 x #s(literal 1 binary64))) < 1.99999999999999984e274Initial program 88.2%
Taylor expanded in y around 0
unpow2N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f64N/A
+-commutativeN/A
distribute-lft-inN/A
*-rgt-identityN/A
lower-fma.f6445.4
Applied rewrites45.4%
(FPCore (x y)
:precision binary64
(let* ((t_0 (/ (* x (+ (/ x y) 1.0)) (+ x 1.0))) (t_1 (* x (/ 1.0 y))))
(if (<= t_0 -50000.0)
t_1
(if (<= t_0 5e-11)
(fma (- (/ x y) x) x x)
(if (<= t_0 2.0) (/ x (- x -1.0)) t_1)))))
double code(double x, double y) {
double t_0 = (x * ((x / y) + 1.0)) / (x + 1.0);
double t_1 = x * (1.0 / y);
double tmp;
if (t_0 <= -50000.0) {
tmp = t_1;
} else if (t_0 <= 5e-11) {
tmp = fma(((x / y) - x), x, x);
} else if (t_0 <= 2.0) {
tmp = x / (x - -1.0);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y) t_0 = Float64(Float64(x * Float64(Float64(x / y) + 1.0)) / Float64(x + 1.0)) t_1 = Float64(x * Float64(1.0 / y)) tmp = 0.0 if (t_0 <= -50000.0) tmp = t_1; elseif (t_0 <= 5e-11) tmp = fma(Float64(Float64(x / y) - x), x, x); elseif (t_0 <= 2.0) tmp = Float64(x / Float64(x - -1.0)); else tmp = t_1; end return tmp end
code[x_, y_] := Block[{t$95$0 = N[(N[(x * N[(N[(x / y), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(x * N[(1.0 / y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -50000.0], t$95$1, If[LessEqual[t$95$0, 5e-11], N[(N[(N[(x / y), $MachinePrecision] - x), $MachinePrecision] * x + x), $MachinePrecision], If[LessEqual[t$95$0, 2.0], N[(x / N[(x - -1.0), $MachinePrecision]), $MachinePrecision], t$95$1]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x \cdot \left(\frac{x}{y} + 1\right)}{x + 1}\\
t_1 := x \cdot \frac{1}{y}\\
\mathbf{if}\;t\_0 \leq -50000:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_0 \leq 5 \cdot 10^{-11}:\\
\;\;\;\;\mathsf{fma}\left(\frac{x}{y} - x, x, x\right)\\
\mathbf{elif}\;t\_0 \leq 2:\\
\;\;\;\;\frac{x}{x - -1}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (/.f64 (*.f64 x (+.f64 (/.f64 x y) #s(literal 1 binary64))) (+.f64 x #s(literal 1 binary64))) < -5e4 or 2 < (/.f64 (*.f64 x (+.f64 (/.f64 x y) #s(literal 1 binary64))) (+.f64 x #s(literal 1 binary64))) Initial program 88.2%
Taylor expanded in y around 0
unpow2N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f64N/A
+-commutativeN/A
distribute-lft-inN/A
*-rgt-identityN/A
lower-fma.f6445.4
Applied rewrites45.4%
Taylor expanded in x around inf
lower-/.f6439.1
Applied rewrites39.1%
if -5e4 < (/.f64 (*.f64 x (+.f64 (/.f64 x y) #s(literal 1 binary64))) (+.f64 x #s(literal 1 binary64))) < 5.00000000000000018e-11Initial program 88.2%
Taylor expanded in x around 0
+-commutativeN/A
distribute-lft-inN/A
*-commutativeN/A
*-rgt-identityN/A
lower-fma.f64N/A
sub-flipN/A
metadata-evalN/A
distribute-rgt-inN/A
associate-*l/N/A
*-lft-identityN/A
mul-1-negN/A
lower-+.f64N/A
lift-/.f64N/A
lower-neg.f6456.4
Applied rewrites56.4%
lift-+.f64N/A
lift-/.f64N/A
lift-neg.f64N/A
sub-flip-reverseN/A
lower--.f64N/A
lift-/.f6456.4
Applied rewrites56.4%
if 5.00000000000000018e-11 < (/.f64 (*.f64 x (+.f64 (/.f64 x y) #s(literal 1 binary64))) (+.f64 x #s(literal 1 binary64))) < 2Initial program 88.2%
Taylor expanded in y around inf
lower-/.f64N/A
+-commutativeN/A
add-flipN/A
metadata-evalN/A
lower--.f6450.8
Applied rewrites50.8%
(FPCore (x y) :precision binary64 (let* ((t_0 (/ (* x (+ (/ x y) 1.0)) (+ x 1.0))) (t_1 (* x (/ 1.0 y)))) (if (<= t_0 -5e-5) t_1 (if (<= t_0 2.0) (/ x (- x -1.0)) t_1))))
double code(double x, double y) {
double t_0 = (x * ((x / y) + 1.0)) / (x + 1.0);
double t_1 = x * (1.0 / y);
double tmp;
if (t_0 <= -5e-5) {
tmp = t_1;
} else if (t_0 <= 2.0) {
tmp = x / (x - -1.0);
} 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 * ((x / y) + 1.0d0)) / (x + 1.0d0)
t_1 = x * (1.0d0 / y)
if (t_0 <= (-5d-5)) then
tmp = t_1
else if (t_0 <= 2.0d0) then
tmp = x / (x - (-1.0d0))
else
tmp = t_1
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = (x * ((x / y) + 1.0)) / (x + 1.0);
double t_1 = x * (1.0 / y);
double tmp;
if (t_0 <= -5e-5) {
tmp = t_1;
} else if (t_0 <= 2.0) {
tmp = x / (x - -1.0);
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y): t_0 = (x * ((x / y) + 1.0)) / (x + 1.0) t_1 = x * (1.0 / y) tmp = 0 if t_0 <= -5e-5: tmp = t_1 elif t_0 <= 2.0: tmp = x / (x - -1.0) else: tmp = t_1 return tmp
function code(x, y) t_0 = Float64(Float64(x * Float64(Float64(x / y) + 1.0)) / Float64(x + 1.0)) t_1 = Float64(x * Float64(1.0 / y)) tmp = 0.0 if (t_0 <= -5e-5) tmp = t_1; elseif (t_0 <= 2.0) tmp = Float64(x / Float64(x - -1.0)); else tmp = t_1; end return tmp end
function tmp_2 = code(x, y) t_0 = (x * ((x / y) + 1.0)) / (x + 1.0); t_1 = x * (1.0 / y); tmp = 0.0; if (t_0 <= -5e-5) tmp = t_1; elseif (t_0 <= 2.0) tmp = x / (x - -1.0); else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(N[(x * N[(N[(x / y), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(x * N[(1.0 / y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -5e-5], t$95$1, If[LessEqual[t$95$0, 2.0], N[(x / N[(x - -1.0), $MachinePrecision]), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x \cdot \left(\frac{x}{y} + 1\right)}{x + 1}\\
t_1 := x \cdot \frac{1}{y}\\
\mathbf{if}\;t\_0 \leq -5 \cdot 10^{-5}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_0 \leq 2:\\
\;\;\;\;\frac{x}{x - -1}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (/.f64 (*.f64 x (+.f64 (/.f64 x y) #s(literal 1 binary64))) (+.f64 x #s(literal 1 binary64))) < -5.00000000000000024e-5 or 2 < (/.f64 (*.f64 x (+.f64 (/.f64 x y) #s(literal 1 binary64))) (+.f64 x #s(literal 1 binary64))) Initial program 88.2%
Taylor expanded in y around 0
unpow2N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f64N/A
+-commutativeN/A
distribute-lft-inN/A
*-rgt-identityN/A
lower-fma.f6445.4
Applied rewrites45.4%
Taylor expanded in x around inf
lower-/.f6439.1
Applied rewrites39.1%
if -5.00000000000000024e-5 < (/.f64 (*.f64 x (+.f64 (/.f64 x y) #s(literal 1 binary64))) (+.f64 x #s(literal 1 binary64))) < 2Initial program 88.2%
Taylor expanded in y around inf
lower-/.f64N/A
+-commutativeN/A
add-flipN/A
metadata-evalN/A
lower--.f6450.8
Applied rewrites50.8%
(FPCore (x y) :precision binary64 (let* ((t_0 (/ (* x (+ (/ x y) 1.0)) (+ x 1.0))) (t_1 (/ (* x x) y))) (if (<= t_0 -5e-5) t_1 (if (<= t_0 2.0) (/ x (- x -1.0)) t_1))))
double code(double x, double y) {
double t_0 = (x * ((x / y) + 1.0)) / (x + 1.0);
double t_1 = (x * x) / y;
double tmp;
if (t_0 <= -5e-5) {
tmp = t_1;
} else if (t_0 <= 2.0) {
tmp = x / (x - -1.0);
} 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 * ((x / y) + 1.0d0)) / (x + 1.0d0)
t_1 = (x * x) / y
if (t_0 <= (-5d-5)) then
tmp = t_1
else if (t_0 <= 2.0d0) then
tmp = x / (x - (-1.0d0))
else
tmp = t_1
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = (x * ((x / y) + 1.0)) / (x + 1.0);
double t_1 = (x * x) / y;
double tmp;
if (t_0 <= -5e-5) {
tmp = t_1;
} else if (t_0 <= 2.0) {
tmp = x / (x - -1.0);
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y): t_0 = (x * ((x / y) + 1.0)) / (x + 1.0) t_1 = (x * x) / y tmp = 0 if t_0 <= -5e-5: tmp = t_1 elif t_0 <= 2.0: tmp = x / (x - -1.0) else: tmp = t_1 return tmp
function code(x, y) t_0 = Float64(Float64(x * Float64(Float64(x / y) + 1.0)) / Float64(x + 1.0)) t_1 = Float64(Float64(x * x) / y) tmp = 0.0 if (t_0 <= -5e-5) tmp = t_1; elseif (t_0 <= 2.0) tmp = Float64(x / Float64(x - -1.0)); else tmp = t_1; end return tmp end
function tmp_2 = code(x, y) t_0 = (x * ((x / y) + 1.0)) / (x + 1.0); t_1 = (x * x) / y; tmp = 0.0; if (t_0 <= -5e-5) tmp = t_1; elseif (t_0 <= 2.0) tmp = x / (x - -1.0); else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(N[(x * N[(N[(x / y), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(x * x), $MachinePrecision] / y), $MachinePrecision]}, If[LessEqual[t$95$0, -5e-5], t$95$1, If[LessEqual[t$95$0, 2.0], N[(x / N[(x - -1.0), $MachinePrecision]), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x \cdot \left(\frac{x}{y} + 1\right)}{x + 1}\\
t_1 := \frac{x \cdot x}{y}\\
\mathbf{if}\;t\_0 \leq -5 \cdot 10^{-5}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_0 \leq 2:\\
\;\;\;\;\frac{x}{x - -1}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (/.f64 (*.f64 x (+.f64 (/.f64 x y) #s(literal 1 binary64))) (+.f64 x #s(literal 1 binary64))) < -5.00000000000000024e-5 or 2 < (/.f64 (*.f64 x (+.f64 (/.f64 x y) #s(literal 1 binary64))) (+.f64 x #s(literal 1 binary64))) Initial program 88.2%
Taylor expanded in y around 0
unpow2N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f64N/A
+-commutativeN/A
distribute-lft-inN/A
*-rgt-identityN/A
lower-fma.f6445.4
Applied rewrites45.4%
lift-*.f64N/A
lift-/.f64N/A
lift-fma.f64N/A
associate-*r/N/A
*-commutativeN/A
+-commutativeN/A
distribute-rgt1-inN/A
add-flipN/A
metadata-evalN/A
times-fracN/A
lower-*.f64N/A
lift-/.f64N/A
lift--.f64N/A
lift-/.f6451.3
Applied rewrites51.3%
Taylor expanded in x around 0
lower-/.f64N/A
pow2N/A
lift-*.f6418.6
Applied rewrites18.6%
if -5.00000000000000024e-5 < (/.f64 (*.f64 x (+.f64 (/.f64 x y) #s(literal 1 binary64))) (+.f64 x #s(literal 1 binary64))) < 2Initial program 88.2%
Taylor expanded in y around inf
lower-/.f64N/A
+-commutativeN/A
add-flipN/A
metadata-evalN/A
lower--.f6450.8
Applied rewrites50.8%
(FPCore (x y) :precision binary64 (if (<= (/ (* x (+ (/ x y) 1.0)) (+ x 1.0)) -50000.0) (fma (- x) x x) (/ x (- x -1.0))))
double code(double x, double y) {
double tmp;
if (((x * ((x / y) + 1.0)) / (x + 1.0)) <= -50000.0) {
tmp = fma(-x, x, x);
} else {
tmp = x / (x - -1.0);
}
return tmp;
}
function code(x, y) tmp = 0.0 if (Float64(Float64(x * Float64(Float64(x / y) + 1.0)) / Float64(x + 1.0)) <= -50000.0) tmp = fma(Float64(-x), x, x); else tmp = Float64(x / Float64(x - -1.0)); end return tmp end
code[x_, y_] := If[LessEqual[N[(N[(x * N[(N[(x / y), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision], -50000.0], N[((-x) * x + x), $MachinePrecision], N[(x / N[(x - -1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{x \cdot \left(\frac{x}{y} + 1\right)}{x + 1} \leq -50000:\\
\;\;\;\;\mathsf{fma}\left(-x, x, x\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{x - -1}\\
\end{array}
\end{array}
if (/.f64 (*.f64 x (+.f64 (/.f64 x y) #s(literal 1 binary64))) (+.f64 x #s(literal 1 binary64))) < -5e4Initial program 88.2%
Taylor expanded in x around 0
+-commutativeN/A
distribute-lft-inN/A
*-commutativeN/A
*-rgt-identityN/A
lower-fma.f64N/A
sub-flipN/A
metadata-evalN/A
distribute-rgt-inN/A
associate-*l/N/A
*-lft-identityN/A
mul-1-negN/A
lower-+.f64N/A
lift-/.f64N/A
lower-neg.f6456.4
Applied rewrites56.4%
Taylor expanded in y around inf
+-commutativeN/A
lower-+.f64N/A
mul-1-negN/A
lower-neg.f64N/A
unpow2N/A
lower-*.f6443.0
Applied rewrites43.0%
lift-+.f64N/A
lift-*.f64N/A
lift-neg.f64N/A
distribute-lft-neg-inN/A
lower-fma.f64N/A
lower-neg.f6443.0
Applied rewrites43.0%
if -5e4 < (/.f64 (*.f64 x (+.f64 (/.f64 x y) #s(literal 1 binary64))) (+.f64 x #s(literal 1 binary64))) Initial program 88.2%
Taylor expanded in y around inf
lower-/.f64N/A
+-commutativeN/A
add-flipN/A
metadata-evalN/A
lower--.f6450.8
Applied rewrites50.8%
(FPCore (x y) :precision binary64 (if (<= (/ (* x (+ (/ x y) 1.0)) (+ x 1.0)) 4e-7) (fma (- x) x x) (- 1.0 (/ 1.0 x))))
double code(double x, double y) {
double tmp;
if (((x * ((x / y) + 1.0)) / (x + 1.0)) <= 4e-7) {
tmp = fma(-x, x, x);
} else {
tmp = 1.0 - (1.0 / x);
}
return tmp;
}
function code(x, y) tmp = 0.0 if (Float64(Float64(x * Float64(Float64(x / y) + 1.0)) / Float64(x + 1.0)) <= 4e-7) tmp = fma(Float64(-x), x, x); else tmp = Float64(1.0 - Float64(1.0 / x)); end return tmp end
code[x_, y_] := If[LessEqual[N[(N[(x * N[(N[(x / y), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision], 4e-7], N[((-x) * x + x), $MachinePrecision], N[(1.0 - N[(1.0 / x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{x \cdot \left(\frac{x}{y} + 1\right)}{x + 1} \leq 4 \cdot 10^{-7}:\\
\;\;\;\;\mathsf{fma}\left(-x, x, x\right)\\
\mathbf{else}:\\
\;\;\;\;1 - \frac{1}{x}\\
\end{array}
\end{array}
if (/.f64 (*.f64 x (+.f64 (/.f64 x y) #s(literal 1 binary64))) (+.f64 x #s(literal 1 binary64))) < 3.9999999999999998e-7Initial program 88.2%
Taylor expanded in x around 0
+-commutativeN/A
distribute-lft-inN/A
*-commutativeN/A
*-rgt-identityN/A
lower-fma.f64N/A
sub-flipN/A
metadata-evalN/A
distribute-rgt-inN/A
associate-*l/N/A
*-lft-identityN/A
mul-1-negN/A
lower-+.f64N/A
lift-/.f64N/A
lower-neg.f6456.4
Applied rewrites56.4%
Taylor expanded in y around inf
+-commutativeN/A
lower-+.f64N/A
mul-1-negN/A
lower-neg.f64N/A
unpow2N/A
lower-*.f6443.0
Applied rewrites43.0%
lift-+.f64N/A
lift-*.f64N/A
lift-neg.f64N/A
distribute-lft-neg-inN/A
lower-fma.f64N/A
lower-neg.f6443.0
Applied rewrites43.0%
if 3.9999999999999998e-7 < (/.f64 (*.f64 x (+.f64 (/.f64 x y) #s(literal 1 binary64))) (+.f64 x #s(literal 1 binary64))) Initial program 88.2%
Taylor expanded in y around inf
lower-/.f64N/A
+-commutativeN/A
add-flipN/A
metadata-evalN/A
lower--.f6450.8
Applied rewrites50.8%
Taylor expanded in x around inf
lower--.f64N/A
lower-/.f6414.3
Applied rewrites14.3%
(FPCore (x y) :precision binary64 (fma (- x) x x))
double code(double x, double y) {
return fma(-x, x, x);
}
function code(x, y) return fma(Float64(-x), x, x) end
code[x_, y_] := N[((-x) * x + x), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(-x, x, x\right)
\end{array}
Initial program 88.2%
Taylor expanded in x around 0
+-commutativeN/A
distribute-lft-inN/A
*-commutativeN/A
*-rgt-identityN/A
lower-fma.f64N/A
sub-flipN/A
metadata-evalN/A
distribute-rgt-inN/A
associate-*l/N/A
*-lft-identityN/A
mul-1-negN/A
lower-+.f64N/A
lift-/.f64N/A
lower-neg.f6456.4
Applied rewrites56.4%
Taylor expanded in y around inf
+-commutativeN/A
lower-+.f64N/A
mul-1-negN/A
lower-neg.f64N/A
unpow2N/A
lower-*.f6443.0
Applied rewrites43.0%
lift-+.f64N/A
lift-*.f64N/A
lift-neg.f64N/A
distribute-lft-neg-inN/A
lower-fma.f64N/A
lower-neg.f6443.0
Applied rewrites43.0%
(FPCore (x y) :precision binary64 x)
double code(double x, double y) {
return 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)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
code = x
end function
public static double code(double x, double y) {
return x;
}
def code(x, y): return x
function code(x, y) return x end
function tmp = code(x, y) tmp = x; end
code[x_, y_] := x
\begin{array}{l}
\\
x
\end{array}
Initial program 88.2%
Taylor expanded in x around 0
Applied rewrites38.8%
herbie shell --seed 2025132
(FPCore (x y)
:name "Codec.Picture.Types:toneMapping from JuicyPixels-3.2.6.1"
:precision binary64
(/ (* x (+ (/ x y) 1.0)) (+ x 1.0)))