
(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}
Sampling outcomes in binary64 precision:
Herbie found 10 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 (* (/ x (+ 1.0 x)) (+ 1.0 (/ x y))))
double code(double x, double y) {
return (x / (1.0 + x)) * (1.0 + (x / 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 + (x / y))
end function
public static double code(double x, double y) {
return (x / (1.0 + x)) * (1.0 + (x / y));
}
def code(x, y): return (x / (1.0 + x)) * (1.0 + (x / y))
function code(x, y) return Float64(Float64(x / Float64(1.0 + x)) * Float64(1.0 + Float64(x / y))) end
function tmp = code(x, y) tmp = (x / (1.0 + x)) * (1.0 + (x / y)); end
code[x_, y_] := N[(N[(x / N[(1.0 + x), $MachinePrecision]), $MachinePrecision] * N[(1.0 + N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x}{1 + x} \cdot \left(1 + \frac{x}{y}\right)
\end{array}
Initial program 86.0%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6499.9
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.9
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.9
Applied rewrites99.9%
(FPCore (x y)
:precision binary64
(let* ((t_0 (/ (* x (+ (/ x y) 1.0)) (- x -1.0))))
(if (<= t_0 (- INFINITY))
(/ x y)
(if (<= t_0 0.999998)
(* (/ (+ y x) (fma y x y)) x)
(if (<= t_0 2.0)
(/ x (- x -1.0))
(if (<= t_0 4e+165) (/ (* (/ x y) x) (- x -1.0)) (/ x y)))))))
double code(double x, double y) {
double t_0 = (x * ((x / y) + 1.0)) / (x - -1.0);
double tmp;
if (t_0 <= -((double) INFINITY)) {
tmp = x / y;
} else if (t_0 <= 0.999998) {
tmp = ((y + x) / fma(y, x, y)) * x;
} else if (t_0 <= 2.0) {
tmp = x / (x - -1.0);
} else if (t_0 <= 4e+165) {
tmp = ((x / y) * x) / (x - -1.0);
} else {
tmp = x / y;
}
return tmp;
}
function code(x, y) t_0 = Float64(Float64(x * Float64(Float64(x / y) + 1.0)) / Float64(x - -1.0)) tmp = 0.0 if (t_0 <= Float64(-Inf)) tmp = Float64(x / y); elseif (t_0 <= 0.999998) tmp = Float64(Float64(Float64(y + x) / fma(y, x, y)) * x); elseif (t_0 <= 2.0) tmp = Float64(x / Float64(x - -1.0)); elseif (t_0 <= 4e+165) tmp = Float64(Float64(Float64(x / y) * x) / Float64(x - -1.0)); else tmp = Float64(x / y); 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]}, If[LessEqual[t$95$0, (-Infinity)], N[(x / y), $MachinePrecision], If[LessEqual[t$95$0, 0.999998], N[(N[(N[(y + x), $MachinePrecision] / N[(y * x + y), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision], If[LessEqual[t$95$0, 2.0], N[(x / N[(x - -1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 4e+165], N[(N[(N[(x / y), $MachinePrecision] * x), $MachinePrecision] / N[(x - -1.0), $MachinePrecision]), $MachinePrecision], N[(x / y), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x \cdot \left(\frac{x}{y} + 1\right)}{x - -1}\\
\mathbf{if}\;t\_0 \leq -\infty:\\
\;\;\;\;\frac{x}{y}\\
\mathbf{elif}\;t\_0 \leq 0.999998:\\
\;\;\;\;\frac{y + x}{\mathsf{fma}\left(y, x, y\right)} \cdot x\\
\mathbf{elif}\;t\_0 \leq 2:\\
\;\;\;\;\frac{x}{x - -1}\\
\mathbf{elif}\;t\_0 \leq 4 \cdot 10^{+165}:\\
\;\;\;\;\frac{\frac{x}{y} \cdot x}{x - -1}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y}\\
\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 3.9999999999999996e165 < (/.f64 (*.f64 x (+.f64 (/.f64 x y) #s(literal 1 binary64))) (+.f64 x #s(literal 1 binary64))) Initial program 44.6%
lift-+.f64N/A
unpow1N/A
metadata-evalN/A
sqrt-pow1N/A
pow2N/A
lift-/.f64N/A
lift-/.f64N/A
frac-timesN/A
associate-/l*N/A
frac-2neg-revN/A
distribute-lft-neg-outN/A
sqrt-prodN/A
lower-fma.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f64N/A
distribute-lft-neg-outN/A
frac-2neg-revN/A
lower-/.f64N/A
lower-*.f649.0
Applied rewrites9.0%
Taylor expanded in x around -inf
mul-1-negN/A
*-commutativeN/A
unpow2N/A
rem-square-sqrtN/A
associate-*r/N/A
distribute-lft-neg-inN/A
metadata-evalN/A
*-lft-identityN/A
lower-/.f64100.0
Applied rewrites100.0%
if -inf.0 < (/.f64 (*.f64 x (+.f64 (/.f64 x y) #s(literal 1 binary64))) (+.f64 x #s(literal 1 binary64))) < 0.999998000000000054Initial program 99.9%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6499.9
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.9
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.9
Applied rewrites99.9%
Taylor expanded in y around 0
div-add-revN/A
associate-/l/N/A
*-commutativeN/A
lower-/.f64N/A
+-commutativeN/A
unpow2N/A
distribute-lft-outN/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
distribute-lft-inN/A
*-rgt-identityN/A
lower-fma.f6483.4
Applied rewrites83.4%
Applied rewrites98.5%
if 0.999998000000000054 < (/.f64 (*.f64 x (+.f64 (/.f64 x y) #s(literal 1 binary64))) (+.f64 x #s(literal 1 binary64))) < 2Initial program 100.0%
Taylor expanded in y around inf
lower-/.f64N/A
rgt-mult-inverseN/A
*-rgt-identityN/A
distribute-lft-inN/A
+-commutativeN/A
distribute-lft-inN/A
fp-cancel-sign-sub-invN/A
*-rgt-identityN/A
distribute-lft-neg-outN/A
rgt-mult-inverseN/A
metadata-evalN/A
lower--.f6499.3
Applied rewrites99.3%
if 2 < (/.f64 (*.f64 x (+.f64 (/.f64 x y) #s(literal 1 binary64))) (+.f64 x #s(literal 1 binary64))) < 3.9999999999999996e165Initial program 99.7%
Taylor expanded in x around inf
unpow2N/A
associate-*l/N/A
lower-*.f64N/A
lower-/.f6497.1
Applied rewrites97.1%
Final simplification98.8%
(FPCore (x y)
:precision binary64
(let* ((t_0 (/ (* x (+ (/ x y) 1.0)) (- x -1.0))))
(if (<= t_0 -1e+15)
(/ x y)
(if (<= t_0 0.5)
(fma (- (/ x y) x) x x)
(if (<= t_0 2.0)
(/ x (- x -1.0))
(if (<= t_0 4e+165) (* (/ x (fma y x y)) x) (/ x y)))))))
double code(double x, double y) {
double t_0 = (x * ((x / y) + 1.0)) / (x - -1.0);
double tmp;
if (t_0 <= -1e+15) {
tmp = x / y;
} else if (t_0 <= 0.5) {
tmp = fma(((x / y) - x), x, x);
} else if (t_0 <= 2.0) {
tmp = x / (x - -1.0);
} else if (t_0 <= 4e+165) {
tmp = (x / fma(y, x, y)) * x;
} else {
tmp = x / y;
}
return tmp;
}
function code(x, y) t_0 = Float64(Float64(x * Float64(Float64(x / y) + 1.0)) / Float64(x - -1.0)) tmp = 0.0 if (t_0 <= -1e+15) tmp = Float64(x / y); elseif (t_0 <= 0.5) tmp = fma(Float64(Float64(x / y) - x), x, x); elseif (t_0 <= 2.0) tmp = Float64(x / Float64(x - -1.0)); elseif (t_0 <= 4e+165) tmp = Float64(Float64(x / fma(y, x, y)) * x); else tmp = Float64(x / y); 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]}, If[LessEqual[t$95$0, -1e+15], N[(x / y), $MachinePrecision], If[LessEqual[t$95$0, 0.5], 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, 4e+165], N[(N[(x / N[(y * x + y), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision], N[(x / y), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x \cdot \left(\frac{x}{y} + 1\right)}{x - -1}\\
\mathbf{if}\;t\_0 \leq -1 \cdot 10^{+15}:\\
\;\;\;\;\frac{x}{y}\\
\mathbf{elif}\;t\_0 \leq 0.5:\\
\;\;\;\;\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 4 \cdot 10^{+165}:\\
\;\;\;\;\frac{x}{\mathsf{fma}\left(y, x, y\right)} \cdot x\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y}\\
\end{array}
\end{array}
if (/.f64 (*.f64 x (+.f64 (/.f64 x y) #s(literal 1 binary64))) (+.f64 x #s(literal 1 binary64))) < -1e15 or 3.9999999999999996e165 < (/.f64 (*.f64 x (+.f64 (/.f64 x y) #s(literal 1 binary64))) (+.f64 x #s(literal 1 binary64))) Initial program 59.7%
lift-+.f64N/A
unpow1N/A
metadata-evalN/A
sqrt-pow1N/A
pow2N/A
lift-/.f64N/A
lift-/.f64N/A
frac-timesN/A
associate-/l*N/A
frac-2neg-revN/A
distribute-lft-neg-outN/A
sqrt-prodN/A
lower-fma.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f64N/A
distribute-lft-neg-outN/A
frac-2neg-revN/A
lower-/.f64N/A
lower-*.f646.7
Applied rewrites6.7%
Taylor expanded in x around -inf
mul-1-negN/A
*-commutativeN/A
unpow2N/A
rem-square-sqrtN/A
associate-*r/N/A
distribute-lft-neg-inN/A
metadata-evalN/A
*-lft-identityN/A
lower-/.f6493.7
Applied rewrites93.7%
if -1e15 < (/.f64 (*.f64 x (+.f64 (/.f64 x y) #s(literal 1 binary64))) (+.f64 x #s(literal 1 binary64))) < 0.5Initial program 99.9%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lift-+.f64N/A
flip-+N/A
associate-/r/N/A
associate-*l*N/A
lower-*.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
difference-of-squares-revN/A
difference-of-sqr--1-revN/A
metadata-evalN/A
lower-fma.f64N/A
metadata-evalN/A
lower-*.f64N/A
lower--.f6499.9
Applied rewrites99.9%
Taylor expanded in x around 0
*-commutativeN/A
+-commutativeN/A
distribute-lft1-inN/A
lower-fma.f64N/A
Applied rewrites99.3%
Taylor expanded in x around 0
Applied rewrites99.3%
if 0.5 < (/.f64 (*.f64 x (+.f64 (/.f64 x y) #s(literal 1 binary64))) (+.f64 x #s(literal 1 binary64))) < 2Initial program 100.0%
Taylor expanded in y around inf
lower-/.f64N/A
rgt-mult-inverseN/A
*-rgt-identityN/A
distribute-lft-inN/A
+-commutativeN/A
distribute-lft-inN/A
fp-cancel-sign-sub-invN/A
*-rgt-identityN/A
distribute-lft-neg-outN/A
rgt-mult-inverseN/A
metadata-evalN/A
lower--.f6497.0
Applied rewrites97.0%
if 2 < (/.f64 (*.f64 x (+.f64 (/.f64 x y) #s(literal 1 binary64))) (+.f64 x #s(literal 1 binary64))) < 3.9999999999999996e165Initial program 99.7%
Taylor expanded in y around 0
unpow2N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
+-commutativeN/A
distribute-lft-inN/A
*-rgt-identityN/A
lower-fma.f6481.0
Applied rewrites81.0%
Final simplification95.6%
(FPCore (x y)
:precision binary64
(let* ((t_0 (/ (* x (+ (/ x y) 1.0)) (- x -1.0))))
(if (<= t_0 -1e+15)
(/ x y)
(if (<= t_0 0.5)
(fma (- (/ x y) x) x x)
(if (<= t_0 2.0) (/ x (- x -1.0)) (/ x y))))))
double code(double x, double y) {
double t_0 = (x * ((x / y) + 1.0)) / (x - -1.0);
double tmp;
if (t_0 <= -1e+15) {
tmp = x / y;
} else if (t_0 <= 0.5) {
tmp = fma(((x / y) - x), x, x);
} else if (t_0 <= 2.0) {
tmp = x / (x - -1.0);
} else {
tmp = x / y;
}
return tmp;
}
function code(x, y) t_0 = Float64(Float64(x * Float64(Float64(x / y) + 1.0)) / Float64(x - -1.0)) tmp = 0.0 if (t_0 <= -1e+15) tmp = Float64(x / y); elseif (t_0 <= 0.5) tmp = fma(Float64(Float64(x / y) - x), x, x); elseif (t_0 <= 2.0) tmp = Float64(x / Float64(x - -1.0)); else tmp = Float64(x / y); 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]}, If[LessEqual[t$95$0, -1e+15], N[(x / y), $MachinePrecision], If[LessEqual[t$95$0, 0.5], 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], N[(x / y), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x \cdot \left(\frac{x}{y} + 1\right)}{x - -1}\\
\mathbf{if}\;t\_0 \leq -1 \cdot 10^{+15}:\\
\;\;\;\;\frac{x}{y}\\
\mathbf{elif}\;t\_0 \leq 0.5:\\
\;\;\;\;\mathsf{fma}\left(\frac{x}{y} - x, x, x\right)\\
\mathbf{elif}\;t\_0 \leq 2:\\
\;\;\;\;\frac{x}{x - -1}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y}\\
\end{array}
\end{array}
if (/.f64 (*.f64 x (+.f64 (/.f64 x y) #s(literal 1 binary64))) (+.f64 x #s(literal 1 binary64))) < -1e15 or 2 < (/.f64 (*.f64 x (+.f64 (/.f64 x y) #s(literal 1 binary64))) (+.f64 x #s(literal 1 binary64))) Initial program 67.4%
lift-+.f64N/A
unpow1N/A
metadata-evalN/A
sqrt-pow1N/A
pow2N/A
lift-/.f64N/A
lift-/.f64N/A
frac-timesN/A
associate-/l*N/A
frac-2neg-revN/A
distribute-lft-neg-outN/A
sqrt-prodN/A
lower-fma.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f64N/A
distribute-lft-neg-outN/A
frac-2neg-revN/A
lower-/.f64N/A
lower-*.f6410.2
Applied rewrites10.2%
Taylor expanded in x around -inf
mul-1-negN/A
*-commutativeN/A
unpow2N/A
rem-square-sqrtN/A
associate-*r/N/A
distribute-lft-neg-inN/A
metadata-evalN/A
*-lft-identityN/A
lower-/.f6486.5
Applied rewrites86.5%
if -1e15 < (/.f64 (*.f64 x (+.f64 (/.f64 x y) #s(literal 1 binary64))) (+.f64 x #s(literal 1 binary64))) < 0.5Initial program 99.9%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lift-+.f64N/A
flip-+N/A
associate-/r/N/A
associate-*l*N/A
lower-*.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
difference-of-squares-revN/A
difference-of-sqr--1-revN/A
metadata-evalN/A
lower-fma.f64N/A
metadata-evalN/A
lower-*.f64N/A
lower--.f6499.9
Applied rewrites99.9%
Taylor expanded in x around 0
*-commutativeN/A
+-commutativeN/A
distribute-lft1-inN/A
lower-fma.f64N/A
Applied rewrites99.3%
Taylor expanded in x around 0
Applied rewrites99.3%
if 0.5 < (/.f64 (*.f64 x (+.f64 (/.f64 x y) #s(literal 1 binary64))) (+.f64 x #s(literal 1 binary64))) < 2Initial program 100.0%
Taylor expanded in y around inf
lower-/.f64N/A
rgt-mult-inverseN/A
*-rgt-identityN/A
distribute-lft-inN/A
+-commutativeN/A
distribute-lft-inN/A
fp-cancel-sign-sub-invN/A
*-rgt-identityN/A
distribute-lft-neg-outN/A
rgt-mult-inverseN/A
metadata-evalN/A
lower--.f6497.0
Applied rewrites97.0%
Final simplification93.6%
(FPCore (x y)
:precision binary64
(let* ((t_0 (/ (* x (+ (/ x y) 1.0)) (- x -1.0))))
(if (or (<= t_0 (- INFINITY)) (not (<= t_0 4e+165)))
(/ x y)
(/ (fma (/ x y) x x) (- x -1.0)))))
double code(double x, double y) {
double t_0 = (x * ((x / y) + 1.0)) / (x - -1.0);
double tmp;
if ((t_0 <= -((double) INFINITY)) || !(t_0 <= 4e+165)) {
tmp = x / y;
} else {
tmp = fma((x / y), x, x) / (x - -1.0);
}
return tmp;
}
function code(x, y) t_0 = Float64(Float64(x * Float64(Float64(x / y) + 1.0)) / Float64(x - -1.0)) tmp = 0.0 if ((t_0 <= Float64(-Inf)) || !(t_0 <= 4e+165)) tmp = Float64(x / y); else tmp = Float64(fma(Float64(x / y), x, x) / Float64(x - -1.0)); 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]}, If[Or[LessEqual[t$95$0, (-Infinity)], N[Not[LessEqual[t$95$0, 4e+165]], $MachinePrecision]], N[(x / y), $MachinePrecision], N[(N[(N[(x / y), $MachinePrecision] * x + x), $MachinePrecision] / N[(x - -1.0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x \cdot \left(\frac{x}{y} + 1\right)}{x - -1}\\
\mathbf{if}\;t\_0 \leq -\infty \lor \neg \left(t\_0 \leq 4 \cdot 10^{+165}\right):\\
\;\;\;\;\frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\frac{x}{y}, x, x\right)}{x - -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 3.9999999999999996e165 < (/.f64 (*.f64 x (+.f64 (/.f64 x y) #s(literal 1 binary64))) (+.f64 x #s(literal 1 binary64))) Initial program 44.6%
lift-+.f64N/A
unpow1N/A
metadata-evalN/A
sqrt-pow1N/A
pow2N/A
lift-/.f64N/A
lift-/.f64N/A
frac-timesN/A
associate-/l*N/A
frac-2neg-revN/A
distribute-lft-neg-outN/A
sqrt-prodN/A
lower-fma.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f64N/A
distribute-lft-neg-outN/A
frac-2neg-revN/A
lower-/.f64N/A
lower-*.f649.0
Applied rewrites9.0%
Taylor expanded in x around -inf
mul-1-negN/A
*-commutativeN/A
unpow2N/A
rem-square-sqrtN/A
associate-*r/N/A
distribute-lft-neg-inN/A
metadata-evalN/A
*-lft-identityN/A
lower-/.f64100.0
Applied rewrites100.0%
if -inf.0 < (/.f64 (*.f64 x (+.f64 (/.f64 x y) #s(literal 1 binary64))) (+.f64 x #s(literal 1 binary64))) < 3.9999999999999996e165Initial program 99.9%
lift-*.f64N/A
lift-+.f64N/A
distribute-rgt-inN/A
*-lft-identityN/A
lower-fma.f6499.9
Applied rewrites99.9%
Final simplification99.9%
(FPCore (x y) :precision binary64 (let* ((t_0 (/ (* x (+ (/ x y) 1.0)) (- x -1.0)))) (if (or (<= t_0 -1e+15) (not (<= t_0 2.0))) (/ x y) (/ x (- x -1.0)))))
double code(double x, double y) {
double t_0 = (x * ((x / y) + 1.0)) / (x - -1.0);
double tmp;
if ((t_0 <= -1e+15) || !(t_0 <= 2.0)) {
tmp = x / y;
} else {
tmp = x / (x - -1.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 * ((x / y) + 1.0d0)) / (x - (-1.0d0))
if ((t_0 <= (-1d+15)) .or. (.not. (t_0 <= 2.0d0))) then
tmp = x / y
else
tmp = x / (x - (-1.0d0))
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 tmp;
if ((t_0 <= -1e+15) || !(t_0 <= 2.0)) {
tmp = x / y;
} else {
tmp = x / (x - -1.0);
}
return tmp;
}
def code(x, y): t_0 = (x * ((x / y) + 1.0)) / (x - -1.0) tmp = 0 if (t_0 <= -1e+15) or not (t_0 <= 2.0): tmp = x / y else: tmp = x / (x - -1.0) return tmp
function code(x, y) t_0 = Float64(Float64(x * Float64(Float64(x / y) + 1.0)) / Float64(x - -1.0)) tmp = 0.0 if ((t_0 <= -1e+15) || !(t_0 <= 2.0)) tmp = Float64(x / y); else tmp = Float64(x / Float64(x - -1.0)); end return tmp end
function tmp_2 = code(x, y) t_0 = (x * ((x / y) + 1.0)) / (x - -1.0); tmp = 0.0; if ((t_0 <= -1e+15) || ~((t_0 <= 2.0))) tmp = x / y; else tmp = x / (x - -1.0); 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]}, If[Or[LessEqual[t$95$0, -1e+15], N[Not[LessEqual[t$95$0, 2.0]], $MachinePrecision]], N[(x / y), $MachinePrecision], N[(x / N[(x - -1.0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x \cdot \left(\frac{x}{y} + 1\right)}{x - -1}\\
\mathbf{if}\;t\_0 \leq -1 \cdot 10^{+15} \lor \neg \left(t\_0 \leq 2\right):\\
\;\;\;\;\frac{x}{y}\\
\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))) < -1e15 or 2 < (/.f64 (*.f64 x (+.f64 (/.f64 x y) #s(literal 1 binary64))) (+.f64 x #s(literal 1 binary64))) Initial program 67.4%
lift-+.f64N/A
unpow1N/A
metadata-evalN/A
sqrt-pow1N/A
pow2N/A
lift-/.f64N/A
lift-/.f64N/A
frac-timesN/A
associate-/l*N/A
frac-2neg-revN/A
distribute-lft-neg-outN/A
sqrt-prodN/A
lower-fma.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f64N/A
distribute-lft-neg-outN/A
frac-2neg-revN/A
lower-/.f64N/A
lower-*.f6410.2
Applied rewrites10.2%
Taylor expanded in x around -inf
mul-1-negN/A
*-commutativeN/A
unpow2N/A
rem-square-sqrtN/A
associate-*r/N/A
distribute-lft-neg-inN/A
metadata-evalN/A
*-lft-identityN/A
lower-/.f6486.5
Applied rewrites86.5%
if -1e15 < (/.f64 (*.f64 x (+.f64 (/.f64 x y) #s(literal 1 binary64))) (+.f64 x #s(literal 1 binary64))) < 2Initial program 99.9%
Taylor expanded in y around inf
lower-/.f64N/A
rgt-mult-inverseN/A
*-rgt-identityN/A
distribute-lft-inN/A
+-commutativeN/A
distribute-lft-inN/A
fp-cancel-sign-sub-invN/A
*-rgt-identityN/A
distribute-lft-neg-outN/A
rgt-mult-inverseN/A
metadata-evalN/A
lower--.f6488.7
Applied rewrites88.7%
Final simplification87.8%
(FPCore (x y) :precision binary64 (let* ((t_0 (/ (* x (+ (/ x y) 1.0)) (- x -1.0)))) (if (or (<= t_0 -1e+15) (not (<= t_0 0.5))) (/ x y) (fma (- x) x x))))
double code(double x, double y) {
double t_0 = (x * ((x / y) + 1.0)) / (x - -1.0);
double tmp;
if ((t_0 <= -1e+15) || !(t_0 <= 0.5)) {
tmp = x / y;
} else {
tmp = fma(-x, x, x);
}
return tmp;
}
function code(x, y) t_0 = Float64(Float64(x * Float64(Float64(x / y) + 1.0)) / Float64(x - -1.0)) tmp = 0.0 if ((t_0 <= -1e+15) || !(t_0 <= 0.5)) tmp = Float64(x / y); else tmp = fma(Float64(-x), x, x); 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]}, If[Or[LessEqual[t$95$0, -1e+15], N[Not[LessEqual[t$95$0, 0.5]], $MachinePrecision]], N[(x / y), $MachinePrecision], N[((-x) * x + x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x \cdot \left(\frac{x}{y} + 1\right)}{x - -1}\\
\mathbf{if}\;t\_0 \leq -1 \cdot 10^{+15} \lor \neg \left(t\_0 \leq 0.5\right):\\
\;\;\;\;\frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(-x, x, x\right)\\
\end{array}
\end{array}
if (/.f64 (*.f64 x (+.f64 (/.f64 x y) #s(literal 1 binary64))) (+.f64 x #s(literal 1 binary64))) < -1e15 or 0.5 < (/.f64 (*.f64 x (+.f64 (/.f64 x y) #s(literal 1 binary64))) (+.f64 x #s(literal 1 binary64))) Initial program 73.1%
lift-+.f64N/A
unpow1N/A
metadata-evalN/A
sqrt-pow1N/A
pow2N/A
lift-/.f64N/A
lift-/.f64N/A
frac-timesN/A
associate-/l*N/A
frac-2neg-revN/A
distribute-lft-neg-outN/A
sqrt-prodN/A
lower-fma.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f64N/A
distribute-lft-neg-outN/A
frac-2neg-revN/A
lower-/.f64N/A
lower-*.f6415.1
Applied rewrites15.1%
Taylor expanded in x around -inf
mul-1-negN/A
*-commutativeN/A
unpow2N/A
rem-square-sqrtN/A
associate-*r/N/A
distribute-lft-neg-inN/A
metadata-evalN/A
*-lft-identityN/A
lower-/.f6472.1
Applied rewrites72.1%
if -1e15 < (/.f64 (*.f64 x (+.f64 (/.f64 x y) #s(literal 1 binary64))) (+.f64 x #s(literal 1 binary64))) < 0.5Initial program 99.9%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lift-+.f64N/A
flip-+N/A
associate-/r/N/A
associate-*l*N/A
lower-*.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
difference-of-squares-revN/A
difference-of-sqr--1-revN/A
metadata-evalN/A
lower-fma.f64N/A
metadata-evalN/A
lower-*.f64N/A
lower--.f6499.9
Applied rewrites99.9%
Taylor expanded in x around 0
*-commutativeN/A
+-commutativeN/A
distribute-lft1-inN/A
lower-fma.f64N/A
Applied rewrites99.3%
Taylor expanded in y around inf
Applied rewrites86.9%
Final simplification79.3%
(FPCore (x y) :precision binary64 (if (or (<= x -1.45e+144) (not (<= x 3.4e+71))) (/ x y) (* (/ (+ y x) (fma y x y)) x)))
double code(double x, double y) {
double tmp;
if ((x <= -1.45e+144) || !(x <= 3.4e+71)) {
tmp = x / y;
} else {
tmp = ((y + x) / fma(y, x, y)) * x;
}
return tmp;
}
function code(x, y) tmp = 0.0 if ((x <= -1.45e+144) || !(x <= 3.4e+71)) tmp = Float64(x / y); else tmp = Float64(Float64(Float64(y + x) / fma(y, x, y)) * x); end return tmp end
code[x_, y_] := If[Or[LessEqual[x, -1.45e+144], N[Not[LessEqual[x, 3.4e+71]], $MachinePrecision]], N[(x / y), $MachinePrecision], N[(N[(N[(y + x), $MachinePrecision] / N[(y * x + y), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.45 \cdot 10^{+144} \lor \neg \left(x \leq 3.4 \cdot 10^{+71}\right):\\
\;\;\;\;\frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;\frac{y + x}{\mathsf{fma}\left(y, x, y\right)} \cdot x\\
\end{array}
\end{array}
if x < -1.44999999999999999e144 or 3.3999999999999998e71 < x Initial program 59.8%
lift-+.f64N/A
unpow1N/A
metadata-evalN/A
sqrt-pow1N/A
pow2N/A
lift-/.f64N/A
lift-/.f64N/A
frac-timesN/A
associate-/l*N/A
frac-2neg-revN/A
distribute-lft-neg-outN/A
sqrt-prodN/A
lower-fma.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f64N/A
distribute-lft-neg-outN/A
frac-2neg-revN/A
lower-/.f64N/A
lower-*.f6414.7
Applied rewrites14.7%
Taylor expanded in x around -inf
mul-1-negN/A
*-commutativeN/A
unpow2N/A
rem-square-sqrtN/A
associate-*r/N/A
distribute-lft-neg-inN/A
metadata-evalN/A
*-lft-identityN/A
lower-/.f6488.4
Applied rewrites88.4%
if -1.44999999999999999e144 < x < 3.3999999999999998e71Initial program 97.8%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6499.9
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.9
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.9
Applied rewrites99.9%
Taylor expanded in y around 0
div-add-revN/A
associate-/l/N/A
*-commutativeN/A
lower-/.f64N/A
+-commutativeN/A
unpow2N/A
distribute-lft-outN/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
distribute-lft-inN/A
*-rgt-identityN/A
lower-fma.f6485.4
Applied rewrites85.4%
Applied rewrites97.6%
Final simplification94.8%
(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 86.0%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lift-+.f64N/A
flip-+N/A
associate-/r/N/A
associate-*l*N/A
lower-*.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
difference-of-squares-revN/A
difference-of-sqr--1-revN/A
metadata-evalN/A
lower-fma.f64N/A
metadata-evalN/A
lower-*.f64N/A
lower--.f6474.9
Applied rewrites74.9%
Taylor expanded in x around 0
*-commutativeN/A
+-commutativeN/A
distribute-lft1-inN/A
lower-fma.f64N/A
Applied rewrites58.2%
Taylor expanded in y around inf
Applied rewrites47.9%
Final simplification47.9%
(FPCore (x y) :precision binary64 (* 1.0 x))
double code(double x, double y) {
return 1.0 * 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 = 1.0d0 * x
end function
public static double code(double x, double y) {
return 1.0 * x;
}
def code(x, y): return 1.0 * x
function code(x, y) return Float64(1.0 * x) end
function tmp = code(x, y) tmp = 1.0 * x; end
code[x_, y_] := N[(1.0 * x), $MachinePrecision]
\begin{array}{l}
\\
1 \cdot x
\end{array}
Initial program 86.0%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6499.9
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.9
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.9
Applied rewrites99.9%
Taylor expanded in y around 0
div-add-revN/A
associate-/l/N/A
*-commutativeN/A
lower-/.f64N/A
+-commutativeN/A
unpow2N/A
distribute-lft-outN/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
distribute-lft-inN/A
*-rgt-identityN/A
lower-fma.f6471.2
Applied rewrites71.2%
Applied rewrites87.2%
Taylor expanded in x around 0
Applied rewrites43.6%
Final simplification43.6%
(FPCore (x y) :precision binary64 (* (/ x 1.0) (/ (+ (/ x y) 1.0) (+ x 1.0))))
double code(double x, double y) {
return (x / 1.0) * (((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 / 1.0d0) * (((x / y) + 1.0d0) / (x + 1.0d0))
end function
public static double code(double x, double y) {
return (x / 1.0) * (((x / y) + 1.0) / (x + 1.0));
}
def code(x, y): return (x / 1.0) * (((x / y) + 1.0) / (x + 1.0))
function code(x, y) return Float64(Float64(x / 1.0) * Float64(Float64(Float64(x / y) + 1.0) / Float64(x + 1.0))) end
function tmp = code(x, y) tmp = (x / 1.0) * (((x / y) + 1.0) / (x + 1.0)); end
code[x_, y_] := N[(N[(x / 1.0), $MachinePrecision] * N[(N[(N[(x / y), $MachinePrecision] + 1.0), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x}{1} \cdot \frac{\frac{x}{y} + 1}{x + 1}
\end{array}
herbie shell --seed 2024352
(FPCore (x y)
:name "Codec.Picture.Types:toneMapping from JuicyPixels-3.2.6.1"
:precision binary64
:alt
(! :herbie-platform default (* (/ x 1) (/ (+ (/ x y) 1) (+ x 1))))
(/ (* x (+ (/ x y) 1.0)) (+ x 1.0)))